|
|
@@ -80,6 +80,7 @@ public class S8ExceptionService : ITransient
|
|
|
SceneCode = e.SceneCode,
|
|
|
SceneName = sc.SceneName,
|
|
|
ResponsibleDeptId = e.ResponsibleDeptId,
|
|
|
+ OccurrenceDeptId = e.OccurrenceDeptId,
|
|
|
AssigneeId = e.AssigneeId,
|
|
|
SlaDeadline = e.SlaDeadline,
|
|
|
TimeoutFlag = e.TimeoutFlag,
|
|
|
@@ -102,7 +103,7 @@ public class S8ExceptionService : ITransient
|
|
|
r.SeverityLabel = S8Labels.SeverityLabel(r.Severity);
|
|
|
}
|
|
|
|
|
|
- await FillDisplayNamesAsync(list);
|
|
|
+ await FillDisplayNamesAsync(list, q.FactoryId);
|
|
|
return (total, list);
|
|
|
}
|
|
|
|
|
|
@@ -187,18 +188,20 @@ public class S8ExceptionService : ITransient
|
|
|
var d = rows[0];
|
|
|
d.StatusLabel = S8Labels.StatusLabel(d.Status);
|
|
|
d.SeverityLabel = S8Labels.SeverityLabel(d.Severity);
|
|
|
- await FillDisplayNamesAsync(new[] { d });
|
|
|
+ await FillDisplayNamesAsync(new[] { d }, factoryId);
|
|
|
return d;
|
|
|
}
|
|
|
|
|
|
- private async Task FillDisplayNamesAsync(IEnumerable<AdoS8ExceptionListItemDto> rows)
|
|
|
+ // S8-DEPT-DISPLAY-CONSISTENCY-1(P0-A-2/A-3):list 行也水合 OccurrenceDeptName;
|
|
|
+ // 部门查询加 factory_ref_id 二次约束,避免跨 factory 同名 / 同 RecID 错位。
|
|
|
+ private async Task FillDisplayNamesAsync(IEnumerable<AdoS8ExceptionListItemDto> rows, long factoryId)
|
|
|
{
|
|
|
var list = rows.ToList();
|
|
|
if (list.Count == 0) return;
|
|
|
|
|
|
var deptIds = list
|
|
|
.Select(x => x.ResponsibleDeptId)
|
|
|
- .Concat(list.OfType<AdoS8ExceptionDetailDto>().Select(x => x.OccurrenceDeptId))
|
|
|
+ .Concat(list.Select(x => x.OccurrenceDeptId))
|
|
|
.Where(x => x > 0)
|
|
|
.Distinct()
|
|
|
.ToList();
|
|
|
@@ -214,7 +217,7 @@ public class S8ExceptionService : ITransient
|
|
|
var deptMap = deptIds.Count == 0
|
|
|
? new Dictionary<long, string>()
|
|
|
: (await _deptRep.AsQueryable()
|
|
|
- .Where(x => deptIds.Contains(x.Id))
|
|
|
+ .Where(x => deptIds.Contains(x.Id) && x.FactoryRefId == factoryId)
|
|
|
.Select(x => new { x.Id, Name = x.Descr ?? x.Department })
|
|
|
.ToListAsync())
|
|
|
.ToDictionary(x => x.Id, x => x.Name);
|
|
|
@@ -251,24 +254,29 @@ public class S8ExceptionService : ITransient
|
|
|
|
|
|
foreach (var row in list)
|
|
|
{
|
|
|
+ row.ResponsibleDeptName = ResolveDeptName(row.ResponsibleDeptId, deptMap);
|
|
|
+ row.OccurrenceDeptName = ResolveDeptName(row.OccurrenceDeptId, deptMap);
|
|
|
+ row.AssigneeName = row.AssigneeId.HasValue ? empMap.GetValueOrDefault(row.AssigneeId.Value) : null;
|
|
|
+
|
|
|
if (row is AdoS8ExceptionDetailDto detail)
|
|
|
{
|
|
|
- detail.ResponsibleDeptName = deptMap.GetValueOrDefault(detail.ResponsibleDeptId);
|
|
|
- detail.OccurrenceDeptName = deptMap.GetValueOrDefault(detail.OccurrenceDeptId);
|
|
|
- detail.AssigneeName = detail.AssigneeId.HasValue ? empMap.GetValueOrDefault(detail.AssigneeId.Value) : null;
|
|
|
detail.ReporterName = detail.ReporterId.HasValue
|
|
|
? (reporterUserMap.GetValueOrDefault(detail.ReporterId.Value) ?? empMap.GetValueOrDefault(detail.ReporterId.Value))
|
|
|
: null;
|
|
|
detail.VerifierName = detail.VerifierId.HasValue ? empMap.GetValueOrDefault(detail.VerifierId.Value) : null;
|
|
|
}
|
|
|
- else
|
|
|
- {
|
|
|
- row.ResponsibleDeptName = deptMap.GetValueOrDefault(row.ResponsibleDeptId);
|
|
|
- row.AssigneeName = row.AssigneeId.HasValue ? empMap.GetValueOrDefault(row.AssigneeId.Value) : null;
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ // S8-DEPT-DISPLAY-CONSISTENCY-1(P0-A-3):dept fallback —— 0/缺失=未归属,查不到名=部门ID:{id}。
|
|
|
+ private static string? ResolveDeptName(long deptId, Dictionary<long, string> deptMap)
|
|
|
+ {
|
|
|
+ if (deptId <= 0) return "未归属";
|
|
|
+ return deptMap.TryGetValue(deptId, out var name) && !string.IsNullOrWhiteSpace(name)
|
|
|
+ ? name
|
|
|
+ : $"部门ID:{deptId}";
|
|
|
+ }
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// S2-EW:debug-only 软删 RelatedObjectCode 以 "TEST_G09_" 开头的异常。
|
|
|
/// 调用方仅限 <see cref="Controllers.S8.AdoS8WatchDebugController"/>,由其 _debugEndpointEnabled 守门。
|