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
@@ -59,3 +59,47 @@ func DailyPlanCompareExportHandler(svcCtx *svc.ServiceContext) http.HandlerFunc
_, _ = w.Write(buf.Bytes())
}
}
// DailyPlanAttainmentHandler GET /daily-plans/attainment?start=&end= 计划 vs 实际(完工流水汇聚,2026-11-16)。
func DailyPlanAttainmentHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
q := r.URL.Query()
res, err := logic.New(svcCtx).DailyPlanAttainment(r.Context(), q.Get("start"), q.Get("end"))
if err != nil {
httpx.Fail(w, 3603, err.Error())
return
}
httpx.Ok(w, res)
}
}
// DailyPlanAttainmentExportHandler GET /daily-plans/attainment/export?start=&end= 直出 xlsx。
func DailyPlanAttainmentExportHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
q := r.URL.Query()
res, err := logic.New(svcCtx).DailyPlanAttainment(r.Context(), q.Get("start"), q.Get("end"))
if err != nil {
httpx.Fail(w, 3604, err.Error())
return
}
f := excelize.NewFile()
const sheet = "计划vs实际"
_ = f.SetSheetName("Sheet1", sheet)
headers := []interface{}{"日期", "工单号", "计划数量", "实际完成", "差异"}
_ = f.SetSheetRow(sheet, "A1", &headers)
for i, it := range res {
row := []interface{}{it.Date, it.OrderNo, it.PlanQty, it.DoneQty, it.Diff}
_ = f.SetSheetRow(sheet, "A"+strconv.Itoa(i+2), &row)
}
buf, e := f.WriteToBuffer()
_ = f.Close()
if e != nil {
httpx.Fail(w, 3604, "生成 Excel 失败:"+e.Error())
return
}
w.Header().Set("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
w.Header().Set("Content-Disposition",
"attachment; filename=\"daily_plan_attainment.xlsx\"; filename*=UTF-8''"+url.PathEscape("日排产计划vs实际.xlsx"))
_, _ = w.Write(buf.Bytes())
}
}
@@ -226,11 +226,16 @@ func OrderQueryInternalHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
orderNo := r.URL.Query().Get("orderNo")
keyword := r.URL.Query().Get("keyword")
status := r.URL.Query().Get("status")
// firstStation(2026-11-16 上线建档下拉专用):>0 时只返回第1道工序候选工位含该工位的工单
firstStation := 0
if n, e := strconv.Atoi(r.URL.Query().Get("stationNo")); e == nil && n > 0 {
firstStation = n
}
limit := 0
if n, e := strconv.Atoi(r.URL.Query().Get("limit")); e == nil && n > 0 {
limit = n
}
list, err := logic.New(svcCtx).ListWorkOrders(r.Context(), orderNo, status, "", "", "", "", keyword, limit, 0)
list, err := logic.New(svcCtx).ListWorkOrders(r.Context(), orderNo, status, "", "", "", "", keyword, limit, 0, firstStation)
if err != nil {
httpx.Fail(w, 2004, err.Error())
return
@@ -244,7 +244,7 @@ func ListWorkOrdersHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
data, err := logic.New(svcCtx).ListWorkOrders(r.Context(),
q.Get("orderNo"), q.Get("status"), q.Get("productCode"), q.Get("productName"),
q.Get("contractNo"), q.Get("ownershipType"),
q.Get("keyword"), limit, offset)
q.Get("keyword"), limit, offset, 0)
if err != nil {
httpx.Fail(w, 3004, err.Error())
return
@@ -628,6 +628,9 @@ func RegisterProductionRoutes(server *rest.Server, serverCtx *svc.ServiceContext
// ---------- 日排产历史对比(问题4):查询 + xlsx 导出 ----------
{Method: http.MethodGet, Path: "/daily-plans/compare", Handler: production.DailyPlanCompareHandler(serverCtx)},
{Method: http.MethodGet, Path: "/daily-plans/compare/export", Handler: production.DailyPlanCompareExportHandler(serverCtx)},
// ---------- 计划 vs 实际(2026-11-16 死结6:完工流水汇聚,不建新表) ----------
{Method: http.MethodGet, Path: "/daily-plans/attainment", Handler: production.DailyPlanAttainmentHandler(serverCtx)},
{Method: http.MethodGet, Path: "/daily-plans/attainment/export", Handler: production.DailyPlanAttainmentExportHandler(serverCtx)},
// ---------- 工单 SN 前缀(问题5):仅 CREATED 可改,事务重生成全部 SN ----------
{Method: http.MethodPost, Path: "/work-orders/sn-prefix", Handler: production.SnPrefixHandler(serverCtx)},
// ---------- 待办统计快照(问题8):WebSocket 长连接见下方单独注册 ----------