feat: 来料检处置项实体与复检、日排产达成对比、PLC/WMS 传输日志

- WMS 新增「检验处置项」实体(schema + ent 生成码),配套检验记录实体调整与复检接口,完善来料检/不良退货/入库检验前端
- MES 日排产:新增达成率统计与计划对比逻辑,调整日排产前端与流程卡/工序流
- 日志与传输:MES 新增 PLC 日志与 WMS 客户端传输日志,WMS 新增 MES 客户端传输日志
- MES 其他:扫码、工单/工件、AGV 客户端与告警、产品导入等逻辑完善及前端调整
- 工位终端:上线面板/作业面板、工件 handler 与 MES 客户端调整
- 配置与文档:更新 mes-api.yaml、三端构建产物与问题记录文档
This commit is contained in:
SunYF
2026-11-16 16:42:44 +08:00
parent b32ec7c03d
commit d92ca803d5
72 changed files with 5135 additions and 1526 deletions
@@ -62,13 +62,14 @@ func bomHandler(ctx *svc.ServiceContext) http.HandlerFunc {
}
}
// orderQueryHandler GET /api/order/query?orderNo=&keyword=&status=&limit= —— 代理 MES /api/internal/order/query。
// orderQueryHandler GET /api/order/query?orderNo=&keyword=&status=&limit=&stationNo= —— 代理 MES /api/internal/order/query。
// 上线建档选工单后带出产品编码/名称(用于查物料清单应领料)。
// 2026-11-10:透传远程搜索关键字与条数上限,工单下拉不再一次拉全量。
// 2026-11-16:透传 stationNo(MES 侧按「第1道工序候选工位含本工位」过滤,与建档落点资格校验同口径)。
func orderQueryHandler(ctx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
params := url.Values{}
for _, k := range []string{"orderNo", "keyword", "status", "limit"} {
for _, k := range []string{"orderNo", "keyword", "status", "limit", "stationNo"} {
if v := strings.TrimSpace(r.URL.Query().Get(k)); v != "" {
params.Set(k, v)
}
@@ -12,6 +12,8 @@ import (
"sync"
"time"
"github.com/zeromicro/go-zero/core/logx"
"bj_power_workstation/internal/tightening"
)
@@ -126,13 +128,16 @@ func (c *Client) GetStream(path string, query url.Values) (io.ReadCloser, error)
req.Header.Set("Accept", "text/event-stream")
resp, err := c.streamClient.Do(req)
if err != nil {
logx.Errorf("[终端→MES] <-- SSE connect error %s err=%v", u, err)
return nil, err
}
if resp.StatusCode != http.StatusOK {
body, _ := io.ReadAll(resp.Body)
resp.Body.Close()
logx.Errorf("[终端→MES] <-- SSE HTTP %d %s body=%s", resp.StatusCode, u, truncate(string(body), 200))
return nil, fmt.Errorf("MES %s 返回 %d:%s", path, resp.StatusCode, truncate(string(body), 200))
}
logx.Infof("[终端→MES] <-- SSE connected %s", u)
return resp.Body, nil
}
@@ -153,9 +158,18 @@ func (c *Client) do(method, u string, body io.Reader, bearer string) ([]byte, ht
c.Touch(bearer)
}
}
// 2026-11-16 联调:请求行日志(body 截断 1000;method/u 齐全可定位每一次跨系统调用)
var reqBodyForLog []byte
if body != nil && method == http.MethodPost {
reqBodyForLog, _ = io.ReadAll(body)
req.Body = io.NopCloser(bytes.NewReader(reqBodyForLog))
}
logx.Infof("[终端→MES] --> %s %s body=%s", method, u, truncate(string(reqBodyForLog), 1000))
resp, err := c.httpClient.Do(req)
if err != nil {
// 2026-11-16 联调:终端→MES 全量交互落日志(传输错误单独记录,grep "[终端→MES]")
logx.WithContext(req.Context()).Errorf("[终端→MES] <-- transport error %s %s err=%v", method, u, err)
return nil, nil, err
}
defer resp.Body.Close()
@@ -164,6 +178,8 @@ func (c *Client) do(method, u string, body io.Reader, bearer string) ([]byte, ht
if err != nil {
return nil, resp.Header, err
}
// 请求/响应全量日志(请求体在下面 marshal 后记录;这里记录响应)
logx.WithContext(req.Context()).Infof("[终端→MES] <-- HTTP %d %s body=%s", resp.StatusCode, u, truncate(string(respBody), 1000))
if resp.StatusCode == http.StatusUnauthorized {
// 401 = 工位登录态过期/无效:调用方据此提示重新登录。
return respBody, resp.Header, fmt.Errorf("MES %s %s: %w", method, u, ErrAuth)