- 移除 bj_power_dashboard 旧 React 大屏源码(迁移至 2D SVG 方案) - MES/WMS/工位终端前端:清理 help.js 与 PageHelp 帮助文档,统一操作列与布局,接入请求拦截器 - 新增收集式校验错误弹窗(ErrorListDialog 统一拦截 3015,逐条列现象+建议) - 新增托盘程序(tray)与 WebSocket(ws) 实时通知模块(三端共用) - MES/WMS 物料档案新增同步状态字段,补齐双向失败重推与默认角色 seed - 工单/产能/产品工艺/日排产逻辑调整;拧紧枪按工位配置 - 新增迁移 SQL:扭矩按工位、sysconfig 序列修复 - 更新 技术约束/案例/部署手册/项目说明 等文档
74 lines
2.4 KiB
Go
74 lines
2.4 KiB
Go
package logic
|
|
|
|
import (
|
|
"context"
|
|
|
|
"bj_power_mes/ent/materialqtyreport"
|
|
"bj_power_mes/ent/materialrequest"
|
|
"bj_power_mes/ent/shortagerequest"
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
)
|
|
|
|
// TodoItem 单个菜单的待办数量
|
|
type TodoItem struct {
|
|
MenuCode string `json:"menuCode"`
|
|
Count int `json:"count"`
|
|
}
|
|
|
|
// todoMenus 固定的 6 类待办菜单(前端 MainLayout 按已渲染菜单显示角标)
|
|
var todoMenus = []string{
|
|
"produce.call", // 叫料待处理
|
|
"produce.return", // 退料待确认
|
|
"produce.shortage", // 补料待审批
|
|
"produce.qtyreport", // 数量不符待处理
|
|
"produce.sign", // 待审核签字
|
|
"produce.alert", // 异常预警
|
|
}
|
|
|
|
// TodoStats 统计 6 类待办数量。任一查询失败记 0 并用 logx 记日志后继续,不整体失败。
|
|
func (s *Service) TodoStats(ctx context.Context) ([]TodoItem, int, error) {
|
|
counts := map[string]int{}
|
|
count := func(code string, n int, err error) {
|
|
if err != nil {
|
|
logx.Errorf("待办统计[%s]失败,按 0 计:%v", code, err)
|
|
return
|
|
}
|
|
counts[code] = n
|
|
}
|
|
// 叫料待处理:material_request.status = PENDING
|
|
n, err := s.ctx.EntClient.MaterialRequest.Query().
|
|
Where(materialrequest.Status("PENDING")).Count(ctx)
|
|
count("produce.call", n, err)
|
|
// 退料待确认:material_request.status = RETURNING
|
|
n, err = s.ctx.EntClient.MaterialRequest.Query().
|
|
Where(materialrequest.Status("RETURNING")).Count(ctx)
|
|
count("produce.return", n, err)
|
|
// 补料待审批:shortage_request.status = PENDING
|
|
n, err = s.ctx.EntClient.ShortageRequest.Query().
|
|
Where(shortagerequest.Status("PENDING")).Count(ctx)
|
|
count("produce.shortage", n, err)
|
|
// 数量不符待处理:material_qty_report.status IN (PENDING, PROCESSING)
|
|
n, err = s.ctx.EntClient.MaterialQtyReport.Query().
|
|
Where(materialqtyreport.StatusIn("PENDING", "PROCESSING")).Count(ctx)
|
|
count("produce.qtyreport", n, err)
|
|
// 待审核签字:复用 PendingAudits 的 step_sign_record 聚合口径,取总数
|
|
_, n, err = s.PendingAudits(ctx, PendingAuditFilter{})
|
|
count("produce.sign", n, err)
|
|
// 异常预警:alert.status = UNREAD
|
|
n, err = s.UnreadAlertCount(ctx)
|
|
count("produce.alert", n, err)
|
|
|
|
items := make([]TodoItem, 0, len(todoMenus))
|
|
total := 0
|
|
for _, code := range todoMenus {
|
|
c := counts[code]
|
|
if c < 0 {
|
|
c = 0
|
|
}
|
|
items = append(items, TodoItem{MenuCode: code, Count: c})
|
|
total += c
|
|
}
|
|
return items, total, nil
|
|
}
|