feat: 完成产线与仓储系统多模块迭代升级
本次迭代覆盖MES与WMS核心业务: 1. 新增接驳台托盘传感器读取与AGV对接能力 2. 完善工单排产、备料流程与权限体系拆分 3. 优化看板接口与前端路由、样式 4. 新增操作日志、库存盘点与角色保护逻辑 5. 修复代理地址、BOM保存等已知问题
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"time"
|
||||
|
||||
"bj_power_mes/ent"
|
||||
"bj_power_mes/ent/dailyplan"
|
||||
"bj_power_mes/ent/scanrecord"
|
||||
"bj_power_mes/ent/workorder"
|
||||
"bj_power_mes/ent/workpiece"
|
||||
@@ -49,7 +50,7 @@ func (s *Service) ReportScan(ctx context.Context, req ScanReq, operator string)
|
||||
return nil
|
||||
}
|
||||
|
||||
// bumpWorkOrderProgress 增加工单已完成数量
|
||||
// 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 {
|
||||
@@ -63,6 +64,32 @@ func (s *Service) bumpWorkOrderProgress(ctx context.Context, orderNo, sn string)
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
// ListScanRecords 查询扫码报工记录
|
||||
func (s *Service) ListScanRecords(ctx context.Context, sn, orderNo string) ([]*ent.ScanRecord, error) {
|
||||
q := s.ctx.EntClient.ScanRecord.Query()
|
||||
|
||||
Reference in New Issue
Block a user