feat: 移除工艺物料与混产模板实体、新增产线清线与 PLC 监控实时推送、看板双屏增强
- 移除实体:MES 删除 FlowMaterial(工艺物料)与 MixProductionTemplate(混产模板)全套(schema/ent 生成码/handler/logic),清理关联路由与种子 - 新增功能:产线清线(line_clearance handler + logic)、PLC 监控 WebSocket 实时推送(ws/plc_monitor_hub + handler) - 看板增强:新增管理屏与 KPI 组件(BoardManage/BoardKpi),调整演示屏 Mock 与各看板面板 - MES 完善:PLC 匹配/扭矩扫描/签收、工艺卡 PDF 与工单、AGV 链路、叫料/备料/在制品/短料预测等逻辑与前端调整 - 工位终端:删除离线面板 OfflinePanel,调整主界面/物料面板与 api/store/handler/路由 - WMS:AGV 托盘、物料与 MES 客户端调整及前端帮助/基础数据/叫料/托盘页 - 文档:更新产线API/客户问题/案例/部署手册/问题记录
This commit is contained in:
@@ -44,36 +44,13 @@ type WorkOrderReq struct {
|
||||
|
||||
// CreateWorkOrder 创建工单(状态恒 CREATED,后续用状态流转按钮推进)
|
||||
func (s *Service) CreateWorkOrder(ctx context.Context, req WorkOrderReq, operator string) error {
|
||||
// 2026-11-13 拍板:排产/建工单必须读取「当前产线在用的混产模板」并校验产品范围。
|
||||
// 同模板内多工单(多成品)混产直接放行;模板外新产品必须先清线并切换当前模板,
|
||||
// 不允许排产偷偷把新产品塞进不属于它的产线配置里。
|
||||
// 2026-11-16 fail-close 收口:无在用模板 / 产品编码缺失一律拒绝,堵住"没配模板就跳过校验"的旁路。
|
||||
tplName, products, tErr := s.ActiveMixProducts(ctx)
|
||||
if tErr != nil {
|
||||
return tErr
|
||||
}
|
||||
// 收集式校验(报错一次收全 + 每条带怎么办,2026-10-20):字段问题全部列出、一次性返回,不再串行 return
|
||||
// 2026-11-18 定稿:删除「可生产清单/混产模板」建单门禁——换产风险由换绑时的清线确认单兜底,建单不再拦产品。
|
||||
ve := verr.New()
|
||||
if tplName == "" {
|
||||
ve.Add("mixTemplate", "当前产线没有设置「在用」混产模板,无法创建工单",
|
||||
"先到「工位管理」配置工位工艺绑定并保存为混产模板,再到混产模板页将其设为当前在用模板")
|
||||
}
|
||||
pc := strings.TrimSpace(req.ProductCode)
|
||||
if pc == "" {
|
||||
ve.Add("productCode", "工单缺少产品编码,无法校验混产范围",
|
||||
"请先确认所选产品型号档案已生成产品编码,再创建工单")
|
||||
} else if tplName != "" {
|
||||
allowed := false
|
||||
for _, c := range products {
|
||||
if c == pc {
|
||||
allowed = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !allowed {
|
||||
ve.Add("productCode", fmt.Sprintf("当前产线在用混产模板「%s」不含成品 %s", tplName, pc),
|
||||
"跨模板引入新产品需先清线,再到「产线管理 → 混产配置」新建或切换当前混产模板")
|
||||
}
|
||||
ve.Add("productCode", "工单缺少产品编码",
|
||||
"请重新选择产品型号,保存后系统自动带出产品编码")
|
||||
}
|
||||
if req.ProductTypeId == 0 {
|
||||
ve.Add("productTypeId", "请选择产品型号", "在「产品型号」下拉中选择本次要生产的产品")
|
||||
@@ -105,7 +82,7 @@ func (s *Service) CreateWorkOrder(ctx context.Context, req WorkOrderReq, operato
|
||||
items, cve := s.ValidateFlowCombinationCollect(ctx, req.FlowCombination)
|
||||
comboItems = items
|
||||
ve.Merge(cve)
|
||||
// 工序工位严格校验(2026-10-20 工单建单需求):每道工序都选、工位号严格递增(无产品工艺则交由既有逻辑)
|
||||
// 工艺工位严格校验(2026-10-20 工单建单需求):每道工艺都选、工位号严格递增(无产品工艺则交由既有逻辑)
|
||||
if sve := s.ValidateWorkOrderComboStrict(ctx, req.ProductProcessId, req.FlowCombination); sve.Len() > 0 {
|
||||
ve.Merge(sve)
|
||||
}
|
||||
@@ -282,7 +259,7 @@ func (s *Service) UpdateWorkOrder(ctx context.Context, req WorkOrderReq, operato
|
||||
// 唯一例外:PAUSED 改线=「转产」,保留既有两步走闸门(GuardTransferReroute:退库收货+接驳台清空)。
|
||||
if old.Status != "DONE" && old.Status != "CANCELLED" && old.Status != "PAUSED" {
|
||||
if req.FlowCombination != nil && !flowCombinationEqual(old.FlowCombination, req.FlowCombination) {
|
||||
return errors.New("该工单未完成,工艺路线(工序/工位组合)禁止修改;如需调整,请取消工单后重新建单,或先「暂停工单」按转产流程改线")
|
||||
return errors.New("该工单未完成,工艺路线(工艺/工位组合)禁止修改;如需调整,请取消工单后重新建单,或先「暂停工单」按转产流程改线")
|
||||
}
|
||||
if req.ProductProcessId > 0 && req.ProductProcessId != old.ProductProcessId {
|
||||
return errors.New("该工单未完成,来源产品工艺禁止变更;如需调整,请取消工单后重新建单")
|
||||
@@ -302,7 +279,7 @@ func (s *Service) UpdateWorkOrder(ctx context.Context, req WorkOrderReq, operato
|
||||
items, cve := s.ValidateFlowCombinationCollect(ctx, req.FlowCombination)
|
||||
comboItems = items
|
||||
ve.Merge(cve)
|
||||
// 工序工位严格校验(2026-10-20 工单建单需求):每道工序都选、工位号严格递增(无产品工艺则交由既有逻辑)
|
||||
// 工艺工位严格校验(2026-10-20 工单建单需求):每道工艺都选、工位号严格递增(无产品工艺则交由既有逻辑)
|
||||
if sve := s.ValidateWorkOrderComboStrict(ctx, req.ProductProcessId, req.FlowCombination); sve.Len() > 0 {
|
||||
ve.Merge(sve)
|
||||
}
|
||||
@@ -384,7 +361,7 @@ func (s *Service) UpdateWorkOrder(ctx context.Context, req WorkOrderReq, operato
|
||||
// keyword:跨字段模糊(工单号/产品编码/产品名称/合同号 任一命中),供下拉远程搜索用;
|
||||
// limit:>0 时启用截断(封顶 200),仅下拉搜索场景传参,列表页不传=全量,行为向后兼容;
|
||||
// offset:>0 时跳过前 N 条,配合 limit 供下拉滚动分页(不传=0,行为向后兼容);
|
||||
// firstStation:>0 时只返回「第1道工序候选工位含该工位」的工单(2026-11-16 上线建档下拉专用,
|
||||
// firstStation:>0 时只返回「第1道工艺候选工位含该工位」的工单(2026-11-16 上线建档下拉专用,
|
||||
// 与建档落点资格校验同口径),0=不过滤,行为向后兼容。
|
||||
func (s *Service) ListWorkOrders(ctx context.Context, orderNo, status, productCode, productName, contractNo, ownershipType, keyword string, limit, offset int, firstStation int) ([]*ent.WorkOrder, error) {
|
||||
q := s.ctx.EntClient.WorkOrder.Query()
|
||||
@@ -392,7 +369,21 @@ func (s *Service) ListWorkOrders(ctx context.Context, orderNo, status, productCo
|
||||
q = q.Where(workorder.WorkOrderNoContainsFold(orderNo))
|
||||
}
|
||||
if status != "" {
|
||||
q = q.Where(workorder.Status(status))
|
||||
// 支持逗号分隔多值(如工单下发下拉的"在产"=CREATED,IN_PROGRESS,PAUSED,RELEASED)。
|
||||
// 单值行为与原来完全一致,所有现有调用点零影响。
|
||||
if parts := strings.Split(status, ","); len(parts) > 1 {
|
||||
vals := make([]string, 0, len(parts))
|
||||
for _, p := range parts {
|
||||
if v := strings.TrimSpace(p); v != "" {
|
||||
vals = append(vals, v)
|
||||
}
|
||||
}
|
||||
if len(vals) > 0 {
|
||||
q = q.Where(workorder.StatusIn(vals...))
|
||||
}
|
||||
} else {
|
||||
q = q.Where(workorder.Status(strings.TrimSpace(status)))
|
||||
}
|
||||
}
|
||||
if productCode != "" {
|
||||
q = q.Where(workorder.ProductCodeContainsFold(productCode))
|
||||
|
||||
Reference in New Issue
Block a user