feat: 会话令牌与守卫、看板组件及工位终端功能完善

- 用户表扩展:MES/WMS user 实体新增字段,新增 active_token 迁移 SQL(2026-11-11)
- 会话机制:MES 新增 session_guard,重构 token/auth/jwt/perm 与路由;WMS/工作站同步令牌续签与鉴权
- 看板(board):调整 MES 看板产线/生产/侧栏/仓库组件及样式;WMS 看板展示页同步调整
- 工位终端后端:完善报警流、绑定、PLC 对账、拧紧、proxy、上报、站点告警/操作等 handler,补充 mes client/store
- 工位终端前端:登录/主界面/各操作面板调整,新增滚动分页与多语言 yaml 文案,刷新构建产物
- MES 业务:新增流程链 logic,调整待审核/产能支撑/产品工艺/设置页、PLC 监控与帮助文档,刷新构建产物
- 更新问题记录文档
This commit is contained in:
SunYF
2026-11-11 14:36:16 +08:00
parent 619fc8983d
commit 7b7d27d150
79 changed files with 2056 additions and 471 deletions
@@ -33,7 +33,7 @@ func inspectionSubmitHandler(ctx *svc.ServiceContext) http.HandlerFunc {
}
injectOperator(req, r)
body, _ := json.Marshal(req)
resp, _, perr := ctx.Mes.Post("/api/internal/station/inspection", json.RawMessage(body))
resp, _, perr := ctx.Mes.Post("/api/internal/station/inspection", json.RawMessage(body), bearerOf(r))
mesJSON(w, resp, perr)
}
}
@@ -54,7 +54,7 @@ func emergencyCallHandler(ctx *svc.ServiceContext) http.HandlerFunc {
}
injectOperator(req, r)
body, _ := json.Marshal(req)
resp, _, perr := ctx.Mes.Post("/api/internal/station/emergency", json.RawMessage(body))
resp, _, perr := ctx.Mes.Post("/api/internal/station/emergency", json.RawMessage(body), bearerOf(r))
mesJSON(w, resp, perr)
}
}
@@ -79,7 +79,7 @@ func qtyReportHandler(ctx *svc.ServiceContext) http.HandlerFunc {
}
injectOperator(req, r)
body, _ := json.Marshal(req)
resp, _, perr := ctx.Mes.Post("/api/internal/station/qty-report", json.RawMessage(body))
resp, _, perr := ctx.Mes.Post("/api/internal/station/qty-report", json.RawMessage(body), bearerOf(r))
mesJSON(w, resp, perr)
}
}
@@ -108,7 +108,7 @@ func returnMaterialHandler(ctx *svc.ServiceContext) http.HandlerFunc {
}
injectOperator(req, r)
body, _ := json.Marshal(req)
resp, _, perr := ctx.Mes.Post("/api/internal/station/return-material", json.RawMessage(body))
resp, _, perr := ctx.Mes.Post("/api/internal/station/return-material", json.RawMessage(body), bearerOf(r))
mesJSON(w, resp, perr)
}
}
@@ -116,8 +116,8 @@ func returnMaterialHandler(ctx *svc.ServiceContext) http.HandlerFunc {
// stationReturnListHandler GET /api/return-list —— 工位终端「我的退料单」列表(PENDING 可取消)。
func stationReturnListHandler(ctx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
stationNo := stationNoFromRequest(ctx)
resp, _, perr := ctx.Mes.Get("/api/internal/station/return-list?stationNo="+strconv.Itoa(stationNo), nil)
stationNo := stationNoOf(ctx, r)
resp, _, perr := ctx.Mes.Get("/api/internal/station/return-list?stationNo="+strconv.Itoa(stationNo), nil, bearerOf(r))
mesJSON(w, resp, perr)
}
}
@@ -140,10 +140,10 @@ func stationReturnCancelHandler(ctx *svc.ServiceContext) http.HandlerFunc {
fail(w, http.StatusBadRequest, "returnNo 必填")
return
}
req["stationNo"] = stationNoFromRequest(ctx)
req["stationNo"] = stationNoOf(ctx, r)
injectOperator(req, r)
body, _ := json.Marshal(req)
resp, _, perr := ctx.Mes.Post("/api/internal/station/return-cancel", json.RawMessage(body))
resp, _, perr := ctx.Mes.Post("/api/internal/station/return-cancel", json.RawMessage(body), bearerOf(r))
mesJSON(w, resp, perr)
}
}
@@ -152,8 +152,8 @@ func stationReturnCancelHandler(ctx *svc.ServiceContext) http.HandlerFunc {
// 工位终端余量参考值(剩余余量=应剩余量−已退余量−已损耗;仅展示不阻断提交)。
func stationReturnReferenceHandler(ctx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
stationNo := stationNoFromRequest(ctx)
resp, _, perr := ctx.Mes.Get("/api/internal/station/return-reference?stationNo="+strconv.Itoa(stationNo), nil)
stationNo := stationNoOf(ctx, r)
resp, _, perr := ctx.Mes.Get("/api/internal/station/return-reference?stationNo="+strconv.Itoa(stationNo), nil, bearerOf(r))
mesJSON(w, resp, perr)
}
}
@@ -161,8 +161,8 @@ func stationReturnReferenceHandler(ctx *svc.ServiceContext) http.HandlerFunc {
// shiftGetHandler GET /api/shift —— 当前班次状态(退出登录前提示「未下班」用,2026-11-03 下班闭环)。
func shiftGetHandler(ctx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
stationNo := stationNoFromRequest(ctx)
resp, _, perr := ctx.Mes.Get("/api/internal/station/shift?stationNo="+strconv.Itoa(stationNo), nil)
stationNo := stationNoOf(ctx, r)
resp, _, perr := ctx.Mes.Get("/api/internal/station/shift?stationNo="+strconv.Itoa(stationNo), nil, bearerOf(r))
mesJSON(w, resp, perr)
}
}
@@ -181,21 +181,23 @@ func offDutyHandler(ctx *svc.ServiceContext) http.HandlerFunc {
fail(w, http.StatusBadRequest, "请求体解析失败")
return
}
req["stationNo"] = stationNoFromRequest(ctx)
req["stationNo"] = stationNoOf(ctx, r)
injectOperator(req, r)
body, _ := json.Marshal(req)
resp, _, perr := ctx.Mes.Post("/api/internal/station/off-duty", json.RawMessage(body))
resp, _, perr := ctx.Mes.Post("/api/internal/station/off-duty", json.RawMessage(body), bearerOf(r))
mesJSON(w, resp, perr)
}
}
// stationNoFromRequest 业务工位号(2026-11-09 拍板):配置固定工位(>0)直接用配置;
// 未配置(<=0,登录页选择)时回退登录会话保存的实际工位号(登录响应 stationNo 落 SQLite session)。
func stationNoFromRequest(ctx *svc.ServiceContext) int {
// stationNoOf 业务工位号(2026-11-09 拍板;多会话版 2026-11-11 改按请求定位):
// 配置固定工位(>0)直接用配置;未配置(<=0,登录页选择)时按请求 Bearer 定位登录会话,
// 取该会话绑定的实际工位号(登录响应 stationNo 落 SQLite session)。
// 多会话下同一实例可同时登录多个工位,工位号必须随请求走,不能再用全局会话。
func stationNoOf(ctx *svc.ServiceContext, r *http.Request) int {
if ctx.Config.Station.StationNo > 0 {
return ctx.Config.Station.StationNo
}
if ss, err := ctx.Store.GetStationSession(); err == nil && ss != nil {
if ss, err := ctx.Store.GetStationSessionByToken(bearerOf(r)); err == nil && ss != nil {
return ss.StationNo
}
return 0
@@ -210,7 +212,7 @@ func inspectionUploadHandler(ctx *svc.ServiceContext) http.HandlerFunc {
fail(w, http.StatusBadRequest, "请求体读取失败")
return
}
resp, _, perr := ctx.Mes.Post("/api/internal/station/inspection-upload", json.RawMessage(payload))
resp, _, perr := ctx.Mes.Post("/api/internal/station/inspection-upload", json.RawMessage(payload), bearerOf(r))
mesJSON(w, resp, perr)
}
}