feat: 完成客户第12条需求+多系统改造

1. 新增预警表添加工单号字段,支持按工单号检索预警
2. 添加工单过滤在制品/绩效报表/预警中心查询
3. 补全WMS台账字段口径与权限配置
4. 修复备料单与数量不符处理流程
5. 新增配送进度/库位联动/自动出库功能
6. 修复AGV配送状态更新逻辑
7. 优化退料与库存管理细节
This commit is contained in:
SunYF
2026-09-19 17:04:58 +08:00
parent 62e45b7379
commit 05b0b8a909
89 changed files with 7912 additions and 429 deletions
+9 -3
View File
@@ -55,6 +55,7 @@ type AlertQuery struct {
Type string
From string
To string
OrderNo string // 工单号(模糊,客户第12条:记录查看加一项看工单号查询)
Page int
PageSize int
}
@@ -78,6 +79,9 @@ func (s *Service) ListAlerts(ctx context.Context, q AlertQuery) ([]*ent.Alert, i
query = query.Where(alert.CreatedAtLT(t.Add(24 * time.Hour)))
}
}
if q.OrderNo != "" {
query = query.Where(alert.OrderNoContainsFold(q.OrderNo))
}
total, err := query.Count(ctx)
if err != nil {
return nil, 0, err
@@ -117,7 +121,8 @@ func alertDirection(typ string) int {
// Evaluate 预警规则评估:遍历启用且类型匹配的规则,命中阈值则写 alert 消息。
// 由业务事件触发(如拧紧不合格),也可手动调用。
func (s *Service) Evaluate(ctx context.Context, typ string, value float64, title, content, refType, refId string) {
// orderNo:关联工单号(可空),写入 alert.order_no 供预警中心按工单号检索。
func (s *Service) Evaluate(ctx context.Context, typ string, value float64, title, content, refType, refId, orderNo string) {
rules, err := s.ctx.EntClient.AlertRule.Query().
Where(alertrule.Type(typ), alertrule.Enabled(true)).All(ctx)
if err != nil || len(rules) == 0 {
@@ -129,14 +134,15 @@ func (s *Service) Evaluate(ctx context.Context, typ string, value float64, title
if !hit {
continue
}
_ = s.createAlert(ctx, r.ID, typ, title, content, refType, refId, r.Receiver)
_ = s.createAlert(ctx, r.ID, typ, title, content, refType, refId, orderNo, r.Receiver)
}
}
func (s *Service) createAlert(ctx context.Context, ruleId int, typ, title, content, refType, refId, receiver string) error {
func (s *Service) createAlert(ctx context.Context, ruleId int, typ, title, content, refType, refId, orderNo, receiver string) error {
_, err := s.ctx.EntClient.Alert.Create().
SetRuleId(ruleId).SetType(typ).SetTitle(title).
SetContent(content).SetRefType(refType).SetRefId(refId).
SetOrderNo(orderNo).
SetReceiver(receiver).SetStatus("UNREAD").Save(ctx)
return err
}