refactor: 重构工艺工序相关命名与数据模型

1.  全局替换"工序"为"工艺"统一术语,包括页面文案、枚举、注释
2.  重构工单与工件工艺数据模型:
    - 新增工艺组合表flow_material作为备料/齐套唯一源头
    - 新增工位状态表station_state支持自主停单/恢复接单
    - 移除station_process派工表,改用工单工艺组合作为路线唯一源头
    - 替换processCode为flowId作为工艺关联标识
    - 重构工件当前进度字段为currentStationNo
3.  删除冗余的静态备份资源文件
4.  调整物料选择组件默认启用仅显示激活物料
5.  优化工单创建/编辑逻辑,新增工艺组合校验与保存
This commit is contained in:
SunYF
2026-09-22 11:32:29 +08:00
parent 932700ca65
commit d609ff8a9e
185 changed files with 8623 additions and 4501 deletions
+9 -14
View File
@@ -18,7 +18,7 @@ type PlcSendReq struct {
}
// SendProcess 下发 PLC 工序码。
// 路线由「今日工位派工(station_process)」派生,不再手填组合串(全改关联表)
// 路线 = 工单工艺组合(唯一路线源头,工位号升序),不再按日派工派生
// 约束:① SN 必须属于所选工单且已进线(未完工);② 上一条工序未收到完成信号,不下发下一条(模拟 S7 握手)。
func (s *Service) SendProcess(ctx context.Context, req PlcSendReq, operator string) (*ent.PlcSendLog, error) {
if req.OrderNo == "" {
@@ -27,19 +27,7 @@ func (s *Service) SendProcess(ctx context.Context, req PlcSendReq, operator stri
if req.Sn == "" {
return nil, errors.New("请填写/扫描工件 SN")
}
// 路线由今日工位派工派生
combination, err := RouteStationsStr(ctx, s.ctx.EntClient, TodayStr(), "")
if err != nil {
return nil, err
}
if combination == "" {
return nil, errors.New("今日未配置工位派工,无法下发 PLC 工序码")
}
route, err := RouteStations(ctx, s.ctx.EntClient, TodayStr(), "")
if err != nil {
return nil, err
}
// 校验①:SN 归属工单且已进线
// 校验工单并取工艺组合(唯一路线源头)
wo, err := s.ctx.EntClient.WorkOrder.Query().Where(workorder.WorkOrderNo(req.OrderNo)).First(ctx)
if err != nil {
return nil, errors.New("工单不存在:" + req.OrderNo)
@@ -47,6 +35,13 @@ func (s *Service) SendProcess(ctx context.Context, req PlcSendReq, operator stri
if wo.Status == "DONE" || wo.Status == "CANCELLED" {
return nil, errors.New("该工单已完成或已取消,不能下发")
}
items, _ := RouteStationsFromWO(ctx, s.ctx.EntClient, wo)
if len(items) == 0 {
return nil, errors.New("该工单未配置工艺组合,无法下发 PLC 工序码")
}
combination := RouteStationsStrOfWO(items)
route := RouteStationsOfWO(items)
// 校验①:SN 归属工单且已进线
wp, err := s.ctx.EntClient.Workpiece.Query().
Where(workpiece.Sn(req.Sn), workpiece.OrderNo(req.OrderNo)).First(ctx)
if err != nil {