feat: 退料闭环定稿(损耗台账/备料清单/退料AGV自动派车/剩余量参考)+ 工位托盘守卫
- MES 新增损耗台账 loss_ledger,差异确认损耗接口 ConfirmReceiveLoss(按工单归集) - 备料清单 preparation:MES 按 日计划×工单×工位×物料 实时计算,WMS 只读展示 PreparationList - 退料闭环:N5 工位托盘守卫(未完成禁止退料)、退料 AGV 自动派车(JBT21 空位判定 + 托盘回收链路)、退料参考剩余量接口(应剩余=实备-已耗-已退-已损) - 新增 AGV 车辆状态表 agv_vehicle_state 及查询 - 整合接驳台/叫料池/库存锁既有闭环,清理 sql 目录注释生成脚本与 catalog,更新文档
This commit is contained in:
@@ -302,6 +302,13 @@ func (s *Service) UpdateWorkOrder(ctx context.Context, req WorkOrderReq, operato
|
||||
u.SetPlanEnd(t)
|
||||
}
|
||||
}
|
||||
// 转产两步走(2026-11-03 定论):先人工盘库退料、库房确认收货(退库闭环)后,才允许改线——
|
||||
// 严禁一键全自动连锁。前置闸门不过则本次改线直接被拒。
|
||||
if old.Status == "PAUSED" && len(req.FlowCombination) > 0 {
|
||||
if terr := s.GuardTransferReroute(ctx, old, req.FlowCombination); terr != nil {
|
||||
return terr
|
||||
}
|
||||
}
|
||||
if err := u.Exec(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -309,8 +316,8 @@ func (s *Service) UpdateWorkOrder(ctx context.Context, req WorkOrderReq, operato
|
||||
if err == nil {
|
||||
s.ctx.EventLog.Write(ctx, "work.order.update", wo.WorkOrderNo, operator, "work_order", wo.WorkOrderNo, "更新工单", nil)
|
||||
}
|
||||
// 转产连锁(2026-11-03 拍板):工单已暂停且本次修改了工艺组合 → 旧工位退料+在制转移+新工位重排备料。
|
||||
// 改线本身已落库;转产失败只记日志/事件,不影响改线(现场可据此复核)。
|
||||
// 转产改线后置动作(退料已由人工完成并通过前置闸门):在制工件转移 + 新工位重排备料。
|
||||
// 失败只记日志/事件,不影响改线(现场可据此复核)。
|
||||
if old.Status == "PAUSED" && len(req.FlowCombination) > 0 {
|
||||
if terr := s.TransferProduction(ctx, old, old.FlowCombination, req.FlowCombination, operator); terr != nil {
|
||||
s.ctx.EventLog.Write(ctx, "work.order.transfer.fail", old.WorkOrderNo, operator, "work_order", old.WorkOrderNo,
|
||||
@@ -555,6 +562,9 @@ type ForceCompleteReport struct {
|
||||
PendingCalls []string `json:"pendingCalls"` // PENDING 叫料单(自动取消)
|
||||
ShippedCalls []string `json:"shippedCalls"` // SHIPPED 叫料单(人工签收或退回)
|
||||
InProduction int `json:"inProduction"` // 在制工件数(必须 0 才能关单)
|
||||
// R11(2026-11-03 拍板):已报废/取走登记件数。实物去向落定 = 完工报工或报废登记(SCRAPPED 不计在制);
|
||||
// 强完前必须走完部分报废登记,此数供核对单展示。
|
||||
ScrapCount int `json:"scrapCount"`
|
||||
}
|
||||
|
||||
// stationsOfOrder 圈定工单排产覆盖的工位号集合:来自日排产 stationPlanQty 的键(工位号字符串)。
|
||||
@@ -628,6 +638,9 @@ func (s *Service) buildForceCompleteReport(ctx context.Context, wo *ent.WorkOrde
|
||||
// ③ 在制工件
|
||||
rep.InProduction, _ = s.ctx.EntClient.Workpiece.Query().
|
||||
Where(workpiece.OrderNo(wo.WorkOrderNo), workpiece.StatusIn("ONLINE", "PROCESSING")).Count(ctx)
|
||||
// ④ 已报废/取走登记件数(R11 2026-11-03 拍板:核对单展示,先报废登记后强完)
|
||||
rep.ScrapCount, _ = s.ctx.EntClient.Workpiece.Query().
|
||||
Where(workpiece.OrderNo(wo.WorkOrderNo), workpiece.Status("SCRAPPED")).Count(ctx)
|
||||
return rep, nil
|
||||
}
|
||||
|
||||
@@ -650,7 +663,7 @@ func (s *Service) ForceComplete(ctx context.Context, id int, reason, operator st
|
||||
return nil, err
|
||||
}
|
||||
if rep.InProduction > 0 {
|
||||
return nil, fmt.Errorf("还有 %d 件在制,请先下线完工或报废(不允许随单终止)", rep.InProduction)
|
||||
return nil, fmt.Errorf("还有 %d 件在制,实物去向必须先落定:正常完工报工,或先在「工件追溯」页走「报废 / 人工取走登记」(原因必填)后再强制完工", rep.InProduction)
|
||||
}
|
||||
// PENDING 叫料自动取消(释放占用额度);单张失败不阻断关单,失败明细进 event_log
|
||||
pendingBefore := append([]string(nil), rep.PendingCalls...) // 取消前快照(event_log 留痕用)
|
||||
|
||||
Reference in New Issue
Block a user