feat: 核心业务实体扩充(混产模板/产品BOM/试制记录)、WMS 库存检验增强与前端通用能力
- MES 新增实体:混产模板、产品BOM、产品工艺物料、试制记录(schema + ent 生成码 + logic/handler/前端页) - WMS 实体增强:检验记录、库存、半成品重构;新增序列号库存与短缺代报 - AGV 与产能:AGV 手动点位与链路、物料守卫、短缺预测、原因字典 - 前端通用能力:新增下一步引导组件 NextStepBar,统一帮助文档/布局/请求拦截与操作列 - 工位终端:界面与各 handler 调整(api/store/绑定/PLC/拧紧/上报等) - 配置与文档:更新 mes-api.yaml、WMS README 及案例/产线API/问题记录/项目说明/流程说明
This commit is contained in:
@@ -17,7 +17,13 @@ import (
|
||||
// mesJSON 透传 MES 响应体;网络不可达时返回 502 中文提示。
|
||||
func mesJSON(w http.ResponseWriter, body []byte, err error) bool {
|
||||
if err != nil {
|
||||
fail(w, http.StatusBadGateway, "MES 服务不可达:"+errString(err))
|
||||
// 2026-11-13 修复:MES 侧把 401 折叠成 "station auth expired or invalid",
|
||||
// 原实现把鉴权失败一并包装成 502「MES 服务不可达」,误导用户以为网络断了。
|
||||
if strings.Contains(errString(err), "auth expired") || strings.Contains(errString(err), "401") {
|
||||
fail(w, http.StatusUnauthorized, "工位登录已失效,请重新登录后再操作")
|
||||
return false
|
||||
}
|
||||
failMes(w, err, "MES 服务不可达:"+errString(err))
|
||||
return false
|
||||
}
|
||||
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
||||
@@ -29,7 +35,7 @@ func mesJSON(w http.ResponseWriter, body []byte, err error) bool {
|
||||
// linePointsHandler GET /api/line/points(产线点位台账:当前每个点位上的工件)
|
||||
func linePointsHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
body, _, err := ctx.Mes.Get("/api/internal/line/points", nil)
|
||||
body, _, err := ctx.Mes.Get("/api/internal/line/points", nil, bearerOf(r))
|
||||
mesJSON(w, body, err)
|
||||
}
|
||||
}
|
||||
@@ -70,7 +76,7 @@ func callPoolHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
if v := strings.TrimSpace(r.URL.Query().Get("stationNo")); v != "" {
|
||||
q.Set("stationNo", v)
|
||||
}
|
||||
body, _, err := ctx.Mes.Get("/api/internal/call/pool", q)
|
||||
body, _, err := ctx.Mes.Get("/api/internal/call/pool", q, bearerOf(r))
|
||||
mesJSON(w, body, err)
|
||||
}
|
||||
}
|
||||
@@ -110,7 +116,7 @@ func callListHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
q.Set(k, v)
|
||||
}
|
||||
}
|
||||
body, _, err := ctx.Mes.Get("/api/internal/material-requests", q)
|
||||
body, _, err := ctx.Mes.Get("/api/internal/material-requests", q, bearerOf(r))
|
||||
mesJSON(w, body, err)
|
||||
}
|
||||
}
|
||||
@@ -125,7 +131,7 @@ func callPlanDetailHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
if v := strings.TrimSpace(r.URL.Query().Get("stationNo")); v != "" {
|
||||
q.Set("stationNo", v)
|
||||
}
|
||||
body, _, err := ctx.Mes.Get("/api/internal/call/plan-detail", q)
|
||||
body, _, err := ctx.Mes.Get("/api/internal/call/plan-detail", q, bearerOf(r))
|
||||
mesJSON(w, body, err)
|
||||
}
|
||||
}
|
||||
@@ -138,7 +144,7 @@ func stationDockPalletsHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
if v := strings.TrimSpace(r.URL.Query().Get("stationNo")); v != "" {
|
||||
q.Set("stationNo", v)
|
||||
}
|
||||
body, _, err := ctx.Mes.Get("/api/internal/dock/station-pallets", q)
|
||||
body, _, err := ctx.Mes.Get("/api/internal/dock/station-pallets", q, bearerOf(r))
|
||||
mesJSON(w, body, err)
|
||||
}
|
||||
}
|
||||
@@ -176,7 +182,7 @@ func materialDetailHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
if v := strings.TrimSpace(r.URL.Query().Get("stationNo")); v != "" {
|
||||
q.Set("stationNo", v)
|
||||
}
|
||||
body, _, err := ctx.Mes.Get("/api/internal/call/material-detail", q)
|
||||
body, _, err := ctx.Mes.Get("/api/internal/call/material-detail", q, bearerOf(r))
|
||||
mesJSON(w, body, err)
|
||||
}
|
||||
}
|
||||
@@ -221,7 +227,7 @@ func callStateHandler(ctx *svc.ServiceContext, mesPath, action string) http.Hand
|
||||
body, _ := json.Marshal(req)
|
||||
resp, _, err := ctx.Mes.Post(mesPath, json.RawMessage(body), bearerOf(r))
|
||||
if err != nil {
|
||||
fail(w, http.StatusBadGateway, action+"失败:MES 不可达")
|
||||
failMes(w, err, action+"失败:MES 不可达")
|
||||
return
|
||||
}
|
||||
mesJSON(w, resp, err)
|
||||
@@ -231,7 +237,20 @@ func callStateHandler(ctx *svc.ServiceContext, mesPath, action string) http.Hand
|
||||
// docksHandler GET /api/docks 接驳台列表(代理 MES /api/internal/docks;终端按工位过滤 左L/右R)
|
||||
func docksHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
body, _, err := ctx.Mes.Get("/api/internal/docks", url.Values{})
|
||||
body, _, err := ctx.Mes.Get("/api/internal/docks", url.Values{}, bearerOf(r))
|
||||
mesJSON(w, body, err)
|
||||
}
|
||||
}
|
||||
|
||||
// reasonDictHandler GET /api/dict/reasons?kind=stop|defect|loss 原因基础字典
|
||||
//(2026-11-14 用户拍板:工位终端停机/不良原因由自由文本改下拉,MES 为唯一真源,终端代理)
|
||||
func reasonDictHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
q := url.Values{}
|
||||
if v := strings.TrimSpace(r.URL.Query().Get("kind")); v != "" {
|
||||
q.Set("kind", v)
|
||||
}
|
||||
body, _, err := ctx.Mes.Get("/api/internal/dict/reasons", q, bearerOf(r))
|
||||
mesJSON(w, body, err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user