feat: 新增收集式校验错误弹窗及工位报警语音播报

新增 ErrorListDialog 组件用于统一展示结构化校验错误信息,实现报错一次收全;新增工位报警语音播报功能,通过浏览器 SpeechSynthesis 播放本工位相关报警;调整物料类别及序列号字段文案,移除「其他」类别;新增工单实际开始字段及采集方式配置;优化 AGV 及 PlcSend 页签刷新逻辑;新增看板物料追溯及工位报警接口;删除 PLC 强制写 M 位及相关测试代码;同步数据库字段注释及补丁。
This commit is contained in:
SunYF
2026-10-20 16:36:26 +08:00
parent f743cf21fb
commit b0c048d9aa
126 changed files with 4603 additions and 1639 deletions
+35 -11
View File
@@ -11,6 +11,7 @@ import (
"bj_power_mes/ent"
"bj_power_mes/ent/station"
"bj_power_mes/internal/verr"
)
// ---------- 工单工艺组合(work_order.flow_combination)路线派生 ----------
@@ -82,38 +83,61 @@ func StationFlowMapOfWO(items []FlowItem) map[int]int {
return m
}
// ValidateFlowCombination 保存工单时校验工艺组合:
// 非空、工艺存在且启用(ACTIVE)、工位存在且 ENABLED 且当前绑定工艺与工单一致、工位号不重复;返回按工位号升序的条目。
// ValidateFlowCombination 保存工单时校验工艺组合(收集式实现,见 ValidateFlowCombinationCollect;
// 保留原签名供既有调用方使用,错误为收集式 ValidationError,handler 经 FailErr 输出结构化清单)。
func (s *Service) ValidateFlowCombination(ctx context.Context, raw []map[string]int) ([]FlowItem, error) {
items, ve := s.ValidateFlowCombinationCollect(ctx, raw)
return items, ve.OrNil()
}
// ValidateFlowCombinationCollect 收集式组合校验(报错一次收全,2026-10-20):
// 逐条检查每个组合项,重复/停用/不存在/绑定不匹配等问题全部列出、不串行 return;
// 每条错误带「怎么办」,能跳转解决的给 action(去工艺页/去工位管理)。
func (s *Service) ValidateFlowCombinationCollect(ctx context.Context, raw []map[string]int) ([]FlowItem, *verr.ValidationError) {
items := flowMapsToItems(raw)
ve := verr.New()
if len(items) == 0 {
return nil, errors.New("请先选择工艺组合(至少一条 工艺+工位)")
ve.Add("flowCombination", "请先选择工艺组合", "至少选择一条「工艺+工位」:从产品工艺带出,或在工单编辑中手动勾选")
return nil, ve
}
sort.SliceStable(items, func(i, j int) bool { return items[i].StationNo < items[j].StationNo })
seen := map[int]bool{}
for _, it := range items {
if seen[it.StationNo] {
return nil, fmt.Errorf("工位 %d 在工艺组合中重复", it.StationNo)
ve.Add("flowCombination", fmt.Sprintf("工位 %d 在工艺组合中重复", it.StationNo),
fmt.Sprintf("同一工位只能出现一次,删除工位 %d 的重复行", it.StationNo))
continue
}
seen[it.StationNo] = true
flow, err := s.ctx.EntClient.ProcessFlow.Get(ctx, it.FlowId)
if err != nil {
return nil, fmt.Errorf("工艺不存在(ID=%d)", it.FlowId)
ve.Add("flowCombination", fmt.Sprintf("工艺不存在(ID=%d)", it.FlowId),
"删除该组合行后,从工艺下拉中重新选择")
continue
}
if flow.Status != "ACTIVE" {
return nil, fmt.Errorf("工艺「%s」已停用", flow.Name)
ve.AddAction("flowCombination", fmt.Sprintf("工艺「%s」已停用", flow.Name),
"到「工艺」页启用该工艺,或在组合中移除该工艺行", "去工艺页", "/process-flow")
continue
}
exist, err := s.ctx.EntClient.Station.Query().Where(station.StationNo(it.StationNo)).First(ctx)
if err != nil {
return nil, fmt.Errorf("工位 %d 不存在", it.StationNo)
ve.Add("flowCombination", fmt.Sprintf("工位 %d 不存在", it.StationNo),
"在组合中移除该工位行,或到「工位管理」新增该工位")
continue
}
// 工位当前绑定工艺必须与工单一致且工位启用(与排产校验 ValidateWOCombinationForSchedule 同口径同文案),
// 工位当前绑定工艺必须与工单一致且工位启用(与排产校验 ValidateWOCombinationForSchedule 同口径),
// 否则工单下发后工位被改绑/停用会导致路线漂移
if exist.FlowId != it.FlowId || exist.Status != "ENABLED" {
return nil, fmt.Errorf("工位%d当前工艺与工单不匹配", it.StationNo)
if exist.Status != "ENABLED" {
ve.AddAction("flowCombination", fmt.Sprintf("工位%d 已停用", it.StationNo),
"到「工位管理」启用该工位,或在组合中移除该工位行", "去工位管理", "/station")
} else if exist.FlowId != it.FlowId {
ve.AddAction("flowCombination", fmt.Sprintf("工位%d 当前绑定工艺与工单不一致", it.StationNo),
fmt.Sprintf("到「工位管理」把工位%d 绑回「%s」,或在组合中改选该工位当前绑定的工艺", it.StationNo, flow.Name),
"去工位管理", "/station")
}
}
return items, nil
return items, ve
}
// ValidateWOCombinationForSchedule 排产前校验(工单组合是唯一路线源头,排产只继承不可改):