feat: 退料闭环定稿(损耗台账/备料清单/退料AGV自动派车/剩余量参考)+ 工位托盘守卫

- MES 新增损耗台账 loss_ledger,差异确认损耗接口 ConfirmReceiveLoss(按工单归集)
- 备料清单 preparation:MES 按 日计划×工单×工位×物料 实时计算,WMS 只读展示 PreparationList
- 退料闭环:N5 工位托盘守卫(未完成禁止退料)、退料 AGV 自动派车(JBT21 空位判定 + 托盘回收链路)、退料参考剩余量接口(应剩余=实备-已耗-已退-已损)
- 新增 AGV 车辆状态表 agv_vehicle_state 及查询
- 整合接驳台/叫料池/库存锁既有闭环,清理 sql 目录注释生成脚本与 catalog,更新文档
This commit is contained in:
SunYF
2026-11-04 19:06:03 +08:00
parent 42bcf395d2
commit 46fcb59079
123 changed files with 10666 additions and 3227 deletions
@@ -76,6 +76,10 @@ func RegisterHandlers(server *rest.Server, ctx *svc.ServiceContext) {
{Method: http.MethodPost, Path: "/api/emergency/call", Handler: emergencyCallHandler(ctx)},
{Method: http.MethodPost, Path: "/api/qty-report", Handler: qtyReportHandler(ctx)},
{Method: http.MethodPost, Path: "/api/return-material", Handler: returnMaterialHandler(ctx)},
// 退料单列表/取消/余量参考值(2026-11-04 口径定稿:工位可取消自己 PENDING 退料单)
{Method: http.MethodGet, Path: "/api/return-list", Handler: stationReturnListHandler(ctx)},
{Method: http.MethodPost, Path: "/api/return-cancel", Handler: stationReturnCancelHandler(ctx)},
{Method: http.MethodGet, Path: "/api/return-reference", Handler: stationReturnReferenceHandler(ctx)},
// 下班/结束作业闭环(2026-11-03):查询班次(退出提示)+ 下班提交(自检接驳台剩余物料)
{Method: http.MethodGet, Path: "/api/shift", Handler: shiftGetHandler(ctx)},
{Method: http.MethodPost, Path: "/api/off-duty", Handler: offDutyHandler(ctx)},
@@ -113,6 +113,51 @@ 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)
mesJSON(w, resp, perr)
}
}
// stationReturnCancelHandler POST /api/return-cancel {returnNo, reason}
// 工位取消自己发起的 PENDING 退料单(MES 转发 WMS 校验工位归属后取消;已收货不可取消)。
func stationReturnCancelHandler(ctx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
payload, err := io.ReadAll(r.Body)
if err != nil {
fail(w, http.StatusBadRequest, "请求体读取失败")
return
}
var req map[string]any
if err := json.Unmarshal(payload, &req); err != nil {
fail(w, http.StatusBadRequest, "请求体解析失败")
return
}
if rn, _ := req["returnNo"].(string); rn == "" {
fail(w, http.StatusBadRequest, "returnNo 必填")
return
}
req["stationNo"] = stationNoFromRequest(ctx)
injectOperator(req, r)
body, _ := json.Marshal(req)
resp, _, perr := ctx.Mes.Post("/api/internal/station/return-cancel", json.RawMessage(body))
mesJSON(w, resp, perr)
}
}
// stationReturnReferenceHandler GET /api/return-reference
// 工位终端余量参考值(剩余余量=应剩余量−已退余量−已损耗;仅展示不阻断提交)。
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)
mesJSON(w, resp, perr)
}
}
// shiftGetHandler GET /api/shift —— 当前班次状态(退出登录前提示「未下班」用,2026-11-03 下班闭环)。
func shiftGetHandler(ctx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {