feat: 来料检处置项实体与复检、日排产达成对比、PLC/WMS 传输日志
- WMS 新增「检验处置项」实体(schema + ent 生成码),配套检验记录实体调整与复检接口,完善来料检/不良退货/入库检验前端 - MES 日排产:新增达成率统计与计划对比逻辑,调整日排产前端与流程卡/工序流 - 日志与传输:MES 新增 PLC 日志与 WMS 客户端传输日志,WMS 新增 MES 客户端传输日志 - MES 其他:扫码、工单/工件、AGV 客户端与告警、产品导入等逻辑完善及前端调整 - 工位终端:上线面板/作业面板、工件 handler 与 MES 客户端调整 - 配置与文档:更新 mes-api.yaml、三端构建产物与问题记录文档
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user