feat: 完成多模块迭代更新
- 新增过程巡检按步骤上报、数量不符上报、工位退料功能 - 增加工单工程编号三级归属字段 - 新增物料安全库存与缺货预警 - 新增附件管理、退库单管理模块 - 优化生产看板展示逻辑与前端页面文案 - 清理冗余的工艺路线相关代码与备份文件
This commit is contained in:
@@ -4,8 +4,6 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"bj_power_mes/ent"
|
||||
@@ -19,7 +17,6 @@ type WorkOrderReq struct {
|
||||
Id int `json:"id"`
|
||||
WorkOrderNo string `json:"workOrderNo"`
|
||||
ProductTypeId int `json:"productTypeId"`
|
||||
RouteId int `json:"routeId"`
|
||||
ProductCode string `json:"productCode"`
|
||||
ProductName string `json:"productName"`
|
||||
Quantity int `json:"quantity"`
|
||||
@@ -27,6 +24,10 @@ type WorkOrderReq struct {
|
||||
Status string `json:"status"`
|
||||
PlanStart string `json:"planStart"`
|
||||
PlanEnd string `json:"planEnd"`
|
||||
// 工程编号体系(合同 → 工程编号 → 产品序号)
|
||||
ContractNo string `json:"contractNo"`
|
||||
ProjectNo string `json:"projectNo"`
|
||||
ProductSerial string `json:"productSerial"`
|
||||
}
|
||||
|
||||
// CreateWorkOrder 创建工单(状态恒 CREATED,后续用状态流转按钮推进)
|
||||
@@ -47,38 +48,24 @@ func (s *Service) CreateWorkOrder(ctx context.Context, req WorkOrderReq, operato
|
||||
if status != "CREATED" {
|
||||
status = "CREATED" // 创建恒为已创建;不允许直接创建到后续状态
|
||||
}
|
||||
routeSnapshot := []map[string]any{}
|
||||
if req.RouteId > 0 {
|
||||
route, rerr := s.GetRoute(ctx, req.RouteId)
|
||||
if rerr != nil {
|
||||
return rerr
|
||||
}
|
||||
snapshot, lineStations := s.BuildRouteSnapshot(route)
|
||||
routeSnapshot = snapshot
|
||||
if len(lineStations) > 0 {
|
||||
parts := make([]string, 0, len(lineStations))
|
||||
for _, no := range lineStations {
|
||||
parts = append(parts, strconv.Itoa(no))
|
||||
}
|
||||
req.ProcessSeq = strings.Join(parts, ",")
|
||||
} else {
|
||||
req.ProcessSeq = ""
|
||||
}
|
||||
} else {
|
||||
if req.ProcessSeq == "" {
|
||||
req.ProcessSeq = FullProcessSeq
|
||||
} else if err := ValidateProcessSeq(req.ProcessSeq); err != nil {
|
||||
return err
|
||||
}
|
||||
req.ProcessSeq = NormalizeProcessSeq(req.ProcessSeq)
|
||||
// 工位组合=本工单要经过的工位,按工位号升序(传送带不回走)。
|
||||
// 完整的产线定义 = 关联工位(station.flow_id)+ 工位号 1→12 顺序,不再有独立的"工艺路线"对象。
|
||||
if req.ProcessSeq == "" {
|
||||
req.ProcessSeq = FullProcessSeq
|
||||
} else if err := ValidateProcessSeq(req.ProcessSeq); err != nil {
|
||||
return err
|
||||
}
|
||||
req.ProcessSeq = NormalizeProcessSeq(req.ProcessSeq)
|
||||
b := s.ctx.EntClient.WorkOrder.Create().
|
||||
SetWorkOrderNo(req.WorkOrderNo).
|
||||
SetProductTypeId(req.ProductTypeId).
|
||||
SetProductCode(req.ProductCode).
|
||||
SetProductName(req.ProductName).
|
||||
SetQuantity(req.Quantity).
|
||||
SetProcessSeq(req.ProcessSeq).SetRouteId(req.RouteId).SetRouteSnapshot(routeSnapshot).
|
||||
SetProcessSeq(req.ProcessSeq).
|
||||
SetContractNo(req.ContractNo).
|
||||
SetProjectNo(req.ProjectNo).
|
||||
SetProductSerial(req.ProductSerial).
|
||||
SetStatus(status)
|
||||
if req.PlanStart != "" {
|
||||
if t, err := parseDate(req.PlanStart); err == nil {
|
||||
@@ -116,7 +103,8 @@ func (s *Service) UpdateWorkOrder(ctx context.Context, req WorkOrderReq, operato
|
||||
}
|
||||
req.ProcessSeq = NormalizeProcessSeq(req.ProcessSeq)
|
||||
}
|
||||
u := s.ctx.EntClient.WorkOrder.UpdateOneID(req.Id).SetProcessSeq(req.ProcessSeq)
|
||||
u := s.ctx.EntClient.WorkOrder.UpdateOneID(req.Id).SetProcessSeq(req.ProcessSeq).
|
||||
SetContractNo(req.ContractNo).SetProjectNo(req.ProjectNo).SetProductSerial(req.ProductSerial)
|
||||
if req.Quantity > 0 {
|
||||
u.SetQuantity(req.Quantity)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user