refactor: 重构工艺工序相关命名与数据模型
1. 全局替换"工序"为"工艺"统一术语,包括页面文案、枚举、注释
2. 重构工单与工件工艺数据模型:
- 新增工艺组合表flow_material作为备料/齐套唯一源头
- 新增工位状态表station_state支持自主停单/恢复接单
- 移除station_process派工表,改用工单工艺组合作为路线唯一源头
- 替换processCode为flowId作为工艺关联标识
- 重构工件当前进度字段为currentStationNo
3. 删除冗余的静态备份资源文件
4. 调整物料选择组件默认启用仅显示激活物料
5. 优化工单创建/编辑逻辑,新增工艺组合校验与保存
This commit is contained in:
@@ -111,8 +111,19 @@ func (s *Service) buildWorkOrderProgress(ctx context.Context, today time.Time) [
|
||||
return []WorkOrderProgress{}
|
||||
}
|
||||
date := today.Format("2006-01-02")
|
||||
// 当前产线工位路线(按今日派工派生),全工单共用展示
|
||||
routeStr, _ := RouteStationsStr(ctx, s.ctx.EntClient, date, "")
|
||||
// 当前产线工艺组合(唯一路线源头 = 工单 flow_combination):取执行中工单,无则取最新已下发工单
|
||||
routeStr := ""
|
||||
if cur, err := s.ctx.EntClient.WorkOrder.Query().
|
||||
Where(workorder.Status("IN_PROGRESS")).Order(ent.Desc(workorder.FieldID)).First(ctx); err == nil {
|
||||
if items, _ := RouteStationsFromWO(ctx, s.ctx.EntClient, cur); len(items) > 0 {
|
||||
routeStr = RouteStationsStrOfWO(items)
|
||||
}
|
||||
} else if rel, err := s.ctx.EntClient.WorkOrder.Query().
|
||||
Where(workorder.Status("RELEASED")).Order(ent.Desc(workorder.FieldID)).First(ctx); err == nil {
|
||||
if items, _ := RouteStationsFromWO(ctx, s.ctx.EntClient, rel); len(items) > 0 {
|
||||
routeStr = RouteStationsStrOfWO(items)
|
||||
}
|
||||
}
|
||||
list := make([]WorkOrderProgress, 0, len(wos))
|
||||
for _, w := range wos {
|
||||
item := WorkOrderProgress{
|
||||
@@ -128,7 +139,7 @@ func (s *Service) buildWorkOrderProgress(ctx context.Context, today time.Time) [
|
||||
DailyPlanQty: s.sumDailyPlanQtyByOrder(ctx, date, w.WorkOrderNo),
|
||||
DailyDoneQty: s.countWorkpieceDoneByOrder(ctx, today, w.WorkOrderNo),
|
||||
}
|
||||
item.CurrentProcess = "工序 " + routeStr
|
||||
item.CurrentProcess = "工艺组合 " + routeStr
|
||||
list = append(list, item)
|
||||
}
|
||||
// 进行中的工单排前面,同状态按 ID 倒序
|
||||
@@ -241,9 +252,9 @@ func (s *Service) buildTrace(ctx context.Context) TraceStats {
|
||||
items := make([]TraceItem, 0, len(wps))
|
||||
for _, w := range wps {
|
||||
item := TraceItem{
|
||||
Sn: w.Sn,
|
||||
OrderNo: w.OrderNo,
|
||||
Status: w.Status,
|
||||
Sn: w.Sn,
|
||||
OrderNo: w.OrderNo,
|
||||
Status: w.Status,
|
||||
OnlineAt: fmtDashboardTime(orZero(w.OnlineAt)),
|
||||
DoneAt: fmtDashboardTime(orZero(w.DoneAt)),
|
||||
}
|
||||
@@ -275,7 +286,10 @@ func (s *Service) loadTraceSteps(ctx context.Context, sn string) []TraceStep {
|
||||
// 该工件的拧紧数据:按工位聚合,用于展示每道工序的实际扭矩
|
||||
tq, _ := s.ctx.EntClient.TorqueRecord.Query().
|
||||
Where(torquerecord.SnEQ(sn)).All(ctx)
|
||||
type agg struct{ count, ng int; sum float64 }
|
||||
type agg struct {
|
||||
count, ng int
|
||||
sum float64
|
||||
}
|
||||
byStation := map[string]*agg{}
|
||||
for _, t := range tq {
|
||||
a, ok := byStation[t.StationNo]
|
||||
@@ -293,7 +307,7 @@ func (s *Service) loadTraceSteps(ctx context.Context, sn string) []TraceStep {
|
||||
out := make([]TraceStep, 0, len(steps))
|
||||
for _, st := range steps {
|
||||
ts := TraceStep{
|
||||
ProcessCode: st.ProcessCode,
|
||||
FlowId: st.FlowId,
|
||||
ProcessName: st.ProcessName,
|
||||
StationNo: atoiSafe(st.StationNo),
|
||||
Operator: st.Operator,
|
||||
@@ -440,7 +454,7 @@ func (s *Service) buildEquipment(ctx context.Context, today time.Time) []Station
|
||||
v.LastActiveAt = fmtDashboardTime(orZero(r.EndedAt))
|
||||
v.CurrentSn = r.Sn
|
||||
v.CurrentOperator = r.Operator
|
||||
v.CurrentProcess = r.ProcessCode
|
||||
v.CurrentFlowId = r.FlowId
|
||||
}
|
||||
if v.Status != "alarm" {
|
||||
if strings.EqualFold(r.Result, "NG") {
|
||||
@@ -569,12 +583,12 @@ func (s *Service) buildPerformance(ctx context.Context, today time.Time) []RankI
|
||||
out := make([]RankItem, 0, len(byOp))
|
||||
for op, a := range byOp {
|
||||
item := RankItem{
|
||||
Key: op,
|
||||
Label: op,
|
||||
Count: a.count,
|
||||
Key: op,
|
||||
Label: op,
|
||||
Count: a.count,
|
||||
OkCount: a.ok,
|
||||
NgCount: a.ng,
|
||||
OkRate: safeRate(float64(a.ok), float64(a.count)),
|
||||
OkRate: safeRate(float64(a.ok), float64(a.count)),
|
||||
}
|
||||
for no := range a.stations {
|
||||
item.StationNos = append(item.StationNos, no)
|
||||
@@ -668,7 +682,7 @@ func (s *Service) buildEvents(ctx context.Context) []EventItem {
|
||||
}
|
||||
name := st.ProcessName
|
||||
if name == "" {
|
||||
name = "工序" + itoa(st.ProcessCode)
|
||||
name = "工艺" + itoa(st.FlowId)
|
||||
}
|
||||
out = append(out, EventItem{
|
||||
Time: fmtDateTimeHm(orZero(st.EndedAt)),
|
||||
|
||||
Reference in New Issue
Block a user