|
|
@@ -1,4 +1,5 @@
|
|
|
using Admin.NET.Plugin.AiDOP.Dto.S8;
|
|
|
+using Admin.NET.Plugin.AiDOP.Entity.S0.Warehouse;
|
|
|
using Admin.NET.Plugin.AiDOP.Entity.S8;
|
|
|
using Admin.NET.Plugin.AiDOP.Infrastructure.S8;
|
|
|
|
|
|
@@ -8,16 +9,19 @@ public class S8MonitoringService : ITransient
|
|
|
{
|
|
|
private readonly SqlSugarRepository<AdoS8Exception> _rep;
|
|
|
private readonly SqlSugarRepository<AdoS8ExceptionType> _typeRep;
|
|
|
- private readonly SqlSugarRepository<SysOrg> _orgRep;
|
|
|
+ // S8-OVERVIEW-DEPT-LABEL-HYDRATION-1:部门名称水合改用 AdoS0DepartmentMaster(DepartmentMaster 表,
|
|
|
+ // RecID=1/2 映射真实部门),与 S8DashboardService / S8ExceptionService 主数据水合口径一致。
|
|
|
+ // SysOrg 的 Id 为雪花,不与 ado_s8_exception.responsible_dept_id (1/2) 匹配,不能作部门名来源。
|
|
|
+ private readonly SqlSugarRepository<AdoS0DepartmentMaster> _deptRep;
|
|
|
|
|
|
public S8MonitoringService(
|
|
|
SqlSugarRepository<AdoS8Exception> rep,
|
|
|
SqlSugarRepository<AdoS8ExceptionType> typeRep,
|
|
|
- SqlSugarRepository<SysOrg> orgRep)
|
|
|
+ SqlSugarRepository<AdoS0DepartmentMaster> deptRep)
|
|
|
{
|
|
|
_rep = rep;
|
|
|
_typeRep = typeRep;
|
|
|
- _orgRep = orgRep;
|
|
|
+ _deptRep = deptRep;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
@@ -96,12 +100,17 @@ public class S8MonitoringService : ITransient
|
|
|
.OrderBy(c => CategoryOrder(c.Category))
|
|
|
.ToList();
|
|
|
|
|
|
- // ── ByDept:按 ResponsibleDeptId 聚合,JOIN SysOrg 取部门名称 ──
|
|
|
+ // ── ByDept:按 ResponsibleDeptId 聚合,JOIN AdoS0DepartmentMaster(DepartmentMaster)取部门名称 ──
|
|
|
+ // S8-OVERVIEW-DEPT-LABEL-HYDRATION-1:原使用 SysOrg 但其 Id 是雪花,与 dept_id=1/2 不匹配 → 100% fallback;
|
|
|
+ // 改用 DepartmentMaster(RecID=1=质量部 / RecID=2=生产部),与 dashboard 部门口径对齐。
|
|
|
var deptIds = events.Select(e => e.ResponsibleDeptId).Where(id => id > 0).Distinct().ToList();
|
|
|
var deptNameMap = deptIds.Count == 0
|
|
|
? new Dictionary<long, string>()
|
|
|
- : (await _orgRep.AsQueryable().Where(o => deptIds.Contains(o.Id)).Select(o => new { o.Id, o.Name }).ToListAsync())
|
|
|
- .ToDictionary(o => o.Id, o => o.Name);
|
|
|
+ : (await _deptRep.AsQueryable()
|
|
|
+ .Where(d => deptIds.Contains(d.Id))
|
|
|
+ .Select(d => new { d.Id, Name = d.Descr ?? d.Department })
|
|
|
+ .ToListAsync())
|
|
|
+ .ToDictionary(d => d.Id, d => d.Name ?? string.Empty);
|
|
|
|
|
|
var byDept = events
|
|
|
.Where(e => e.ResponsibleDeptId > 0)
|
|
|
@@ -112,7 +121,7 @@ public class S8MonitoringService : ITransient
|
|
|
var closed = g.Count(e => e.Status == "CLOSED");
|
|
|
return new AdoS8DeptSummary
|
|
|
{
|
|
|
- DeptName = deptNameMap.TryGetValue(g.Key, out var n) ? n : $"部门{g.Key}",
|
|
|
+ DeptName = deptNameMap.TryGetValue(g.Key, out var n) && !string.IsNullOrEmpty(n) ? n : $"部门{g.Key}",
|
|
|
Total = total,
|
|
|
AvgProcessHours = AvgHours(g.Select(e => (e.CreatedAt, e.ClosedAt))),
|
|
|
CloseRate = total == 0 ? 0 : Math.Round(closed * 100.0 / total, 1),
|