- 创建案例.md文档,包含业务场景清单、业务流程、案例和回归测试三份完整文档 - WMS库房管理系统涵盖入库、出库、库存、检验、盘点等24个业务场景 - MES产线控制系统包含工单、排产、BOM、备料、质检、追溯等23个业务场景 - 工位终端系统支持上线、报工、下线、领料、巡检等15个现场作业场景 - 主链路从合同到成品入库,异常链路处理不合格、数量不符、退料等情况 - 删除MES客户端中的ScanRecord相关代码,精简客户端结构 - 更新客户端初始化逻辑,移除扫描记录相关的依赖注入配置
50 lines
1.4 KiB
Go
50 lines
1.4 KiB
Go
package logic
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"bj_power_mes/ent/dailyplan"
|
|
"bj_power_mes/ent/workorder"
|
|
)
|
|
|
|
// bumpWorkOrderProgress 增加工单已完成数量(由完工动作驱动)
|
|
func (s *Service) bumpWorkOrderProgress(ctx context.Context, orderNo, sn string) {
|
|
wo, err := s.ctx.EntClient.WorkOrder.Query().Where(workorder.WorkOrderNo(orderNo)).First(ctx)
|
|
if err != nil || wo == nil {
|
|
return
|
|
}
|
|
if wo.FinishedNum >= wo.Quantity {
|
|
return
|
|
}
|
|
_, _ = s.ctx.EntClient.WorkOrder.UpdateOneID(wo.ID).
|
|
SetFinishedNum(wo.FinishedNum + 1).
|
|
SetStatus("IN_PROGRESS").Save(ctx)
|
|
}
|
|
|
|
// bumpDailyPlanCompleted 工单完工联动当日排产:completedQty+1,达到 planQty 置 DONE。
|
|
// 当天没有匹配排产则跳过(不做自动建单)。仅由真正的完工事件调用。
|
|
func (s *Service) bumpDailyPlanCompleted(ctx context.Context, orderNo string, t time.Time) {
|
|
date := t.Format("2006-01-02")
|
|
plans, err := s.ctx.EntClient.DailyPlan.Query().
|
|
Where(dailyplan.OrderNo(orderNo), dailyplan.PlanDate(date)).
|
|
Where(dailyplan.StatusIn("PENDING", "PROCESSING", "DONE")).All(ctx)
|
|
if err != nil || len(plans) == 0 {
|
|
return
|
|
}
|
|
for _, p := range plans {
|
|
if p.CompletedQty >= p.PlanQty {
|
|
continue
|
|
}
|
|
newQty := p.CompletedQty + 1
|
|
st := p.Status
|
|
if newQty >= p.PlanQty {
|
|
st = "DONE"
|
|
} else if st == "PENDING" {
|
|
st = "PROCESSING"
|
|
}
|
|
_, _ = s.ctx.EntClient.DailyPlan.UpdateOneID(p.ID).
|
|
SetCompletedQty(newQty).SetStatus(st).Save(ctx)
|
|
}
|
|
}
|