feat&refactor: 2026-09-22 半成品业务模型重构与功能完善
- 重构半成品流转逻辑:进度权威源改为 workpiece.currentStationNo,新增 completedText 快照字段,废除 doneProcessCodes - 清理物料品类中半成品类型,存量数据幂等清理,调整物料管理方式文案为批次/序列号 - 新增日排产状态专用更新接口,修复工单工艺校验逻辑 - 新增物料档案代理接口、深路径文件下载接口 - 优化前端界面文案与工位选择逻辑,补充追溯页半成品流转展示 - 调整WMS端物料品类校验与入库接口契约 - 新增/更新数据库表结构与实体类代码
This commit is contained in:
@@ -328,6 +328,45 @@ func (s *Service) DeleteDailyPlan(ctx context.Context, id int) error {
|
||||
return s.ctx.EntClient.DailyPlan.DeleteOneID(id).Exec(ctx)
|
||||
}
|
||||
|
||||
// SetDailyPlanStatus 日排产启用/停用(人工专用入口,POST /daily-plans/:id/status):
|
||||
// 仅允许 PENDING(待执行)↔CONFIRMED(已启用) 之间切换;执行中/已完成/已取消由系统联动维护,无人工入口。
|
||||
// 启用(→CONFIRMED)前校验所属工单(按排产 orderNo 查)状态必须为 RELEASED 或 IN_PROGRESS。
|
||||
// 只 UPDATE status 字段,绝不触碰计划数量/分产量等其它列。
|
||||
func (s *Service) SetDailyPlanStatus(ctx context.Context, id int, target, operator string) error {
|
||||
if id <= 0 {
|
||||
return errors.New("缺少排产 id")
|
||||
}
|
||||
if target != "PENDING" && target != "CONFIRMED" {
|
||||
return errors.New("仅支持 启用/停用 操作")
|
||||
}
|
||||
p, err := s.ctx.EntClient.DailyPlan.Get(ctx, id)
|
||||
if err != nil {
|
||||
return errors.New("日排产不存在")
|
||||
}
|
||||
if p.Status != "PENDING" && p.Status != "CONFIRMED" {
|
||||
return errors.New("仅支持 启用/停用 操作")
|
||||
}
|
||||
if p.Status == target {
|
||||
return nil // 幂等:状态相同直接成功
|
||||
}
|
||||
if target == "CONFIRMED" {
|
||||
wo, err := s.ctx.EntClient.WorkOrder.Query().Where(workorder.WorkOrderNo(p.OrderNo)).First(ctx)
|
||||
if err != nil {
|
||||
return errors.New("工单不存在")
|
||||
}
|
||||
if wo.Status != "RELEASED" && wo.Status != "IN_PROGRESS" {
|
||||
return errors.New("工单未下发,不能启用排产")
|
||||
}
|
||||
}
|
||||
if err := s.ctx.EntClient.DailyPlan.UpdateOneID(id).SetStatus(target).Exec(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
s.ctx.EventLog.Write(ctx, "daily.plan.status", p.OrderNo, operator, "daily_plan", p.OrderNo,
|
||||
"排产启用/停用", map[string]any{"id": id, "from": p.Status, "to": target})
|
||||
s.notifyDashboard()
|
||||
return nil
|
||||
}
|
||||
|
||||
// ---------- 自动排产(引导式) ----------
|
||||
|
||||
// DateSegment 日期区间 [start, end](含两端),yyyy-MM-dd
|
||||
|
||||
Reference in New Issue
Block a user