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
+12 -21
View File
@@ -172,33 +172,24 @@ func (s *Service) HandleQtyReport(ctx context.Context, id int, handleType, note,
if rep.DiffQty <= 0 {
return nil, errors.New("本单为「多发」,不能走补发;请选择退库或调整")
}
// 目标接驳台:取该工位关联的接驳台(一个工位可绑多个接驳台,取第一个;无则空,由 WMS 侧按默认处理)
// 目标接驳台:取该工位关联的接驳台(一个工位可绑多个接驳台,取第一个)
dock := ""
if dk, e := s.ctx.EntClient.Dock.Query().
Where(dockent.StationNo(rep.StationNo)).First(ctx); e == nil {
dock = dk.DockCode
}
reqNo := fmt.Sprintf("MR%d", time.Now().UnixNano())
create := s.ctx.EntClient.MaterialRequest.Create().
SetRequestNo(reqNo).
SetOrderNo(rep.OrderNo).
SetPlanDate(time.Now().Format("2006-01-02")).
SetMaterialCode(rep.MaterialCode).
SetMaterialName(rep.MaterialName).
SetReqQty(float64(rep.DiffQty)).
SetStatus("PENDING").
SetStationNo(rep.StationNo).
SetSource("REFILL").
SetNeedAgv(true).
SetRefReportNo(qtyReportNo(rep.ID)).
SetOperator(operator)
if dock != "" {
create = create.SetTargetDock(dock)
// 补发=叫料池另一入口(B5:多种入口消耗同一池子,耗尽即止):
// 生成 source=REFILL 的叫料单(PENDING,占用池子可用量),后续走仓库完成备料→签收链路。
n, e := s.CreateCallOrders(ctx, rep.StationNo,
[]CallItem{{MaterialCode: rep.MaterialCode, Qty: int(rep.DiffQty), Dock: dock}},
"REFILL", qtyReportNo(rep.ID), operator)
if e != nil {
return nil, fmt.Errorf("生成补发叫料单失败:%w", e)
}
if _, e := create.Save(ctx); e != nil {
return nil, fmt.Errorf("生成补料单失败:%w", e)
if n == 0 {
return nil, errors.New("生成补发叫料单失败:无有效明细")
}
docNo = reqNo
docNo = qtyReportNo(rep.ID) + "-REFILL"
case "RETURN":
if rep.DiffQty >= 0 {
@@ -209,7 +200,7 @@ func (s *Service) HandleQtyReport(ctx context.Context, id int, handleType, note,
return nil, errors.New("WMS 未配置,无法生成退库单")
}
if e := s.ctx.Wms.CreateReturnOrder(ctx, rep.OrderNo, rep.Sn, rep.MaterialCode, rep.MaterialName,
"", "数量不符多发退回", operator, rep.StationNo, sendQty, ""); e != nil {
"", "数量不符多发退回", operator, rep.StationNo, sendQty, "", ""); e != nil {
return nil, fmt.Errorf("生成退库单失败:%w", e)
}
docNo = fmt.Sprintf("RO-%s", qtyReportNo(rep.ID))