时钟与 JWT:验签按「谁签发谁的时间为准」,向签发方取 /api/server-time, 对端地址由既有 BaseURL 自动推导;不再要求现场人工 w32tm 对时。 排产 C 方案:工单状态不再回写排产,排产只表示启用开关;启用排产是唯一 开工开关,未启用不允许建档上件;完工/取消后工单进度从工单派生、叫料池 按工单状态重算;逐日手改后合计为准;日期筛选默认空=全部日期。 叫料配送 B 方案:新增 DELIVERED 待签收态,货真到工位才从 PREPARED 转 DELIVERED、工人签收再转 DONE;PREPARED 在途不可签收/退库;叫料队列一屏 显示 PENDING+PREPARED、支持批量完成备料;配送链改按工位凑车,一张配送单 =一个托盘=一个工位,只在配送单页新建,未派车可删可改;新建弹窗直列有货 工位;派车硬门禁要求接驳台传感器检测到托盘;删除改为事务内复核状态、 带 PENDING 条件删单头,防止并发派车时误删。 装配记账:新增已装量 installedQty 与追溯绑定 traceBind,落实「总账=分账 之和」;追溯件绑定/撤销回补、非序列号件报工按单台用量自动扣已装;报工前 按工位×物料核对累计已签收 ≥ 已消耗,不够拦下。 工件与工位终端:建档/重上线增加上料位可达性校验与 PLC 送件、半截补齐防 重复扣库;终端去轮询改事件驱动(报警/工件到位/点位/停单即时推送),铃铛 只挂消息类预警、与待办角标分家;刷新保留拧紧录入;跨服务连线失败不再 误报成数据库故障;新增 BJ_POWER_DEV=1 单进程调试模式(不起守护/托盘)。 告警:新增处置字段 resolved_at/resolved_by,红点=待处置数,确认关闭才消。 清理:删除 migrate 中 SHIPPED→DELIVERED 兼容补丁;场景1测试断言改为 现行 PREPARED / DELIVERED;同步更新案例.md、现场对时操作卡.md 与 ent 生成代码。
79 lines
2.8 KiB
Go
79 lines
2.8 KiB
Go
package logic
|
|
|
|
import (
|
|
"context"
|
|
|
|
"bj_power_mes/ent/materialqtyreport"
|
|
"bj_power_mes/ent/materialrequest"
|
|
"bj_power_mes/ent/shortagerequest"
|
|
"bj_power_mes/internal/syncfailure"
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
)
|
|
|
|
// TodoItem 单个菜单的待办数量
|
|
type TodoItem struct {
|
|
MenuCode string `json:"menuCode"`
|
|
Count int `json:"count"`
|
|
}
|
|
|
|
// todoMenus 固定的 7 类待办菜单(前端 MainLayout 按已渲染菜单显示角标)
|
|
var todoMenus = []string{
|
|
"produce.call", // 叫料待处理
|
|
"produce.return", // 退料待确认
|
|
"produce.shortage", // 补料待审批
|
|
"produce.qtyreport", // 数量不符待处理
|
|
"produce.sign", // 待审核签字
|
|
"produce.alert", // 异常预警(全类型未处置数,处置完才消)
|
|
"sys.syncfailure", // 同步失败待重试(sync_failure 表 PENDING 数,重试成功才消)
|
|
}
|
|
|
|
// 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)
|
|
// 同步失败待重试:sync_failure 表 PENDING 行数(跨系统通知失败,人工重试成功才消)
|
|
n, err = syncfailure.CountPending(s.ctx.SQLDB)
|
|
count("sys.syncfailure", 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
|
|
}
|