feat(mes): 添加定时同步可生产数量到WMS及BOM项相关标准字段

- 在main.go中添加定时任务每10分钟同步可生产数量到WMS系统
- 为BomItem实体添加relatedStandard字段及相关CRUD方法
- 为InspectionRecord实体添加reportNo、materialCode、materialName等字段
- 更新ent schema确保新字段的验证和默认值设置
- 添加必要的数据库迁移和字段映射逻辑
This commit is contained in:
SunYF
2026-09-17 12:49:07 +08:00
parent b4b274301d
commit 1cc93795ce
191 changed files with 24504 additions and 1250 deletions
+33 -1
View File
@@ -28,6 +28,8 @@ type WorkOrderReq struct {
ContractNo string `json:"contractNo"`
ProjectNo string `json:"projectNo"`
ProductSerial string `json:"productSerial"`
// 完成日期(必填,前端强制;yyyy-MM-dd)
DueDate string `json:"dueDate"`
}
// CreateWorkOrder 创建工单(状态恒 CREATED,后续用状态流转按钮推进)
@@ -77,6 +79,14 @@ func (s *Service) CreateWorkOrder(ctx context.Context, req WorkOrderReq, operato
b.SetPlanEnd(t)
}
}
// 完成日期(Item M):前端必填,后端有值即落库
if req.DueDate != "" {
if t, err := parseDate(req.DueDate); err == nil {
b.SetDueDate(t)
}
}
// 创建人(Item M):取当前登录用户
b.SetCreatedBy(operator)
if _, err := b.Save(ctx); err != nil {
return err
}
@@ -124,6 +134,11 @@ func (s *Service) UpdateWorkOrder(ctx context.Context, req WorkOrderReq, operato
u.SetPlanEnd(t)
}
}
if req.DueDate != "" {
if t, err := parseDate(req.DueDate); err == nil {
u.SetDueDate(t)
}
}
if err := u.Exec(ctx); err != nil {
return err
}
@@ -136,7 +151,7 @@ func (s *Service) UpdateWorkOrder(ctx context.Context, req WorkOrderReq, operato
}
// ListWorkOrders 查询工单(支持工单号/状态/产品编码/产品名称 过滤)
func (s *Service) ListWorkOrders(ctx context.Context, orderNo, status, productCode, productName string) ([]*ent.WorkOrder, error) {
func (s *Service) ListWorkOrders(ctx context.Context, orderNo, status, productCode, productName, contractNo, projectNo, dueFrom, dueTo string) ([]*ent.WorkOrder, error) {
q := s.ctx.EntClient.WorkOrder.Query()
if orderNo != "" {
q = q.Where(workorder.WorkOrderNoContains(orderNo))
@@ -150,6 +165,23 @@ func (s *Service) ListWorkOrders(ctx context.Context, orderNo, status, productCo
if productName != "" {
q = q.Where(workorder.ProductNameContains(productName))
}
if contractNo != "" {
q = q.Where(workorder.ContractNoContains(contractNo))
}
if projectNo != "" {
q = q.Where(workorder.ProjectNoContains(projectNo))
}
// 完成日期范围(Item M
if dueFrom != "" {
if t, err := parseDate(dueFrom); err == nil {
q = q.Where(workorder.DueDateGTE(t))
}
}
if dueTo != "" {
if t, err := parseDate(dueTo); err == nil {
q = q.Where(workorder.DueDateLTE(t))
}
}
return q.Order(ent.Desc(workorder.FieldCreatedAt), ent.Desc(workorder.FieldID)).All(ctx)
}