feat: 完成多模块迭代更新
- 新增过程巡检按步骤上报、数量不符上报、工位退料功能 - 增加工单工程编号三级归属字段 - 新增物料安全库存与缺货预警 - 新增附件管理、退库单管理模块 - 优化生产看板展示逻辑与前端页面文案 - 清理冗余的工艺路线相关代码与备份文件
This commit is contained in:
@@ -361,76 +361,10 @@ func (s *Service) StationTask(ctx context.Context, stationNo int) (map[string]an
|
||||
for _, w := range wos {
|
||||
orderNos = append(orderNos, w.WorkOrderNo)
|
||||
}
|
||||
// M4:工位终端按"工艺路线段"驱动(段=并行工位组,谁空停谁)。
|
||||
// 解析活跃工单的 routeSnapshot,找出本工位所属的路线段,供终端按段执行流程。
|
||||
routeSegments := []map[string]any{}
|
||||
for _, w := range wos {
|
||||
if len(w.RouteSnapshot) == 0 {
|
||||
continue
|
||||
}
|
||||
for _, seg := range w.RouteSnapshot {
|
||||
stations, _ := seg["stations"].([]any)
|
||||
inSeg := false
|
||||
for _, sv := range stations {
|
||||
switch n := sv.(type) {
|
||||
case float64:
|
||||
if int(n) == stationNo {
|
||||
inSeg = true
|
||||
}
|
||||
case int:
|
||||
if n == stationNo {
|
||||
inSeg = true
|
||||
}
|
||||
}
|
||||
if inSeg {
|
||||
break
|
||||
}
|
||||
}
|
||||
if !inSeg {
|
||||
continue
|
||||
}
|
||||
flowId := 0
|
||||
if fv, ok := seg["flowId"].(float64); ok {
|
||||
flowId = int(fv)
|
||||
} else if fv, ok := seg["flowId"].(int); ok {
|
||||
flowId = fv
|
||||
}
|
||||
routeSegments = append(routeSegments, map[string]any{
|
||||
"orderNo": w.WorkOrderNo,
|
||||
"seq": seg["seq"],
|
||||
"segmentType": seg["segmentType"],
|
||||
"flowId": flowId,
|
||||
"stations": stations,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// 按段驱动:本工位实际执行的工艺流程取自「本工位所属路线段」的 flowId;
|
||||
// 工单未配置路线段(旧数据/未排路线)时回退到工位绑定的 flow_id。
|
||||
activeFlowId := 0
|
||||
currentSegment := map[string]any{}
|
||||
minSeq := -1
|
||||
for _, sg := range routeSegments {
|
||||
seq, _ := sg["seq"].(float64)
|
||||
seqInt := int(seq)
|
||||
if sgv, ok := sg["seq"].(int); ok {
|
||||
seqInt = sgv
|
||||
}
|
||||
if minSeq < 0 || seqInt < minSeq {
|
||||
minSeq, currentSegment = seqInt, sg
|
||||
}
|
||||
}
|
||||
if len(currentSegment) > 0 {
|
||||
switch v := currentSegment["flowId"].(type) {
|
||||
case int:
|
||||
activeFlowId = v
|
||||
case float64:
|
||||
activeFlowId = int(v)
|
||||
}
|
||||
}
|
||||
if activeFlowId == 0 {
|
||||
activeFlowId = st.FlowId
|
||||
}
|
||||
// M4:工位终端按「本工位绑定的工艺流程」驱动。
|
||||
// 产线定义 = 关联工位(station.flow_id)+ 工位号 1→12 顺序,已无独立"工艺路线/路线段"对象。
|
||||
// 本工位要干哪些步骤,完全取决于 station.flow_id 指向的流程图,工单的 processSeq 只决定走哪些工位。
|
||||
activeFlowId := st.FlowId
|
||||
var flow *ent.ProcessFlow
|
||||
if activeFlowId > 0 {
|
||||
flow, _ = s.ctx.EntClient.ProcessFlow.Get(ctx, activeFlowId)
|
||||
@@ -440,15 +374,13 @@ func (s *Service) StationTask(ctx context.Context, stationNo int) (map[string]an
|
||||
steps = s.flowSteps(ctx, flow.ID)
|
||||
}
|
||||
return map[string]any{
|
||||
"stationNo": st.StationNo,
|
||||
"stationName": st.Name,
|
||||
"flowId": activeFlowId,
|
||||
"segment": currentSegment,
|
||||
"flow": flow,
|
||||
"flowActive": flow != nil && flow.Status == "ACTIVE",
|
||||
"steps": steps,
|
||||
"orderNos": orderNos,
|
||||
"routeSegments": routeSegments,
|
||||
"stationNo": st.StationNo,
|
||||
"stationName": st.Name,
|
||||
"flowId": activeFlowId,
|
||||
"flow": flow,
|
||||
"flowActive": flow != nil && flow.Status == "ACTIVE",
|
||||
"steps": steps,
|
||||
"orderNos": orderNos,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user