feat: 多系统新增扫码中间件与 AGV 对接,优化拧紧与退库流程

新增扫码中间件支持网络型扫码枪键盘注入,AGV 对接从 WMS 迁至 MES 统一管理;新增拧紧不合格人工处置与 PLC 对账机制,优化退库单关联与工位终端功能,同时清理旧 AGV 任务表,完善数据库与配置项。
This commit is contained in:
SunYF
2026-10-14 17:24:59 +08:00
parent 8e6048c64b
commit f65a52d9e1
170 changed files with 15415 additions and 10572 deletions
@@ -111,4 +111,42 @@ func tighteningRecordHandler(ctx *svc.ServiceContext) http.HandlerFunc {
fmt.Sprintf("拧紧录入 sn=%s 步骤=%s 扭矩=%.1f 结果=%s", req.Sn, req.StepName, req.Torque, req.Result))
ok(w, map[string]any{"id": id, "result": req.Result})
}
}
// tighteningLiveHandler GET /api/tightening/live —— 返回 OP 控制器最近推送、尚未确认上报的拧紧结果(前端轮询预填)。
func tighteningLiveHandler(ctx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
if ctx.Tightening == nil || !ctx.Tightening.Enabled() {
ok(w, map[string]any{"enabled": false, "list": []any{}})
return
}
ok(w, map[string]any{"enabled": true, "list": ctx.Tightening.Latest()})
}
}
// tighteningConsumeHandler POST /api/tightening/consume —— 操作工点「完成」后标记某条 OP 缓冲结果为已确认(防重复上报)。
// 入参 {id}。
func tighteningConsumeHandler(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 struct {
ID int64 `json:"id"`
}
if err := json.Unmarshal(payload, &req); err != nil {
fail(w, http.StatusBadRequest, "请求体解析失败")
return
}
if req.ID <= 0 {
fail(w, http.StatusBadRequest, "缺少缓冲结果 ID")
return
}
if ctx.Tightening != nil {
ctx.Tightening.Consume(req.ID)
}
ok(w, map[string]any{"ok": true})
}
}