AdoS8MonitoringController.cs 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. using Admin.NET.Plugin.AiDOP.Infrastructure.S8;
  2. using Admin.NET.Plugin.AiDOP.Const.S8;
  3. using Admin.NET.Plugin.AiDOP.Dto.S8;
  4. using Admin.NET.Plugin.AiDOP.Infrastructure;
  5. using Admin.NET.Plugin.AiDOP.Service.S8;
  6. namespace Admin.NET.Plugin.AiDOP.Controllers.S8;
  7. [ApiController]
  8. [Route("api/aidop/s8/monitoring")]
  9. [NonUnify]
  10. public class AdoS8MonitoringController : ControllerBase
  11. {
  12. private readonly S8MonitoringService _svc;
  13. private readonly S8TrustedScopeResolver _scope;
  14. public AdoS8MonitoringController(S8MonitoringService svc, S8TrustedScopeResolver scope)
  15. {
  16. _svc = svc;
  17. _scope = scope;
  18. }
  19. /// <summary>
  20. /// 异常监控汇总——供 4 个监控页顶部徽标和模块汇总表使用。
  21. /// sceneCode 不传时返回全部模块聚合(综合全景页)。
  22. /// </summary>
  23. [HttpGet("summary")]
  24. [S8Permission(S8PermissionCatalog.DashboardRead)]
  25. public async Task<IActionResult> GetSummaryAsync([FromQuery] AdoS8MonitoringSummaryQueryDto q)
  26. {
  27. // S8-TENANT-FACTORY-P0-CLOSURE-1:作用域一律服务端解析,覆盖客户端传入值。
  28. var scope = await _scope.ResolveAsync();
  29. q.TenantId = scope.TenantId;
  30. q.FactoryId = scope.FactoryId;
  31. return Ok(await _svc.GetSummaryAsync(q));
  32. }
  33. /// <summary>
  34. /// 9宫格数据:S1-S7 订单健康分布 + S8业务类别汇总 + S9部门汇总。
  35. /// </summary>
  36. [HttpGet("order-grid")]
  37. [S8Permission(S8PermissionCatalog.DashboardRead)]
  38. public async Task<IActionResult> GetOrderGridAsync([FromQuery] string? period = null)
  39. {
  40. var scope = await _scope.ResolveAsync();
  41. return Ok(await _svc.GetOrderGridAsync(scope.TenantId, scope.FactoryId, period));
  42. }
  43. /// <summary>
  44. /// S8-DELIVERY-PAGE-TYPE-TOTAL-ALIGN-1:Delivery 页近 N 日交付异常趋势。
  45. /// 口径 module_code IN (S1,S7) AND exception_type_code IN
  46. /// (ORDER_DUE_DATE_DELAY / PRODUCT_DESIGN_DELAY / DELIVERY_DELAY_WARNING)。
  47. /// </summary>
  48. [HttpGet("delivery-trend")]
  49. [S8Permission(S8PermissionCatalog.DashboardRead)]
  50. public async Task<IActionResult> GetDeliveryTrendAsync(long tenantId = 1, long factoryId = 1, int days = 7, string? period = null)
  51. {
  52. // Compatibility-only. Security scope is resolved server-side.
  53. _ = tenantId; _ = factoryId;
  54. var scope = await _scope.ResolveAsync();
  55. return Ok(await _svc.GetDeliveryTrendAsync(scope.TenantId, scope.FactoryId, days, period));
  56. }
  57. /// <summary>
  58. /// S8-PRODUCTION-PAGE-TYPE-TITLE-AND-TREND-ALIGN-1:Production 页近 N 日生产异常趋势。
  59. /// 口径 module_code IN (S2,S6) AND exception_type_code IN
  60. /// (EQUIP_FAULT / MFG_MATERIAL_ABNORMAL / MFG_QUALITY_ABNORMAL / BODY_PRODUCTION_DELAY_WARNING)。
  61. /// </summary>
  62. [HttpGet("production-trend")]
  63. [S8Permission(S8PermissionCatalog.DashboardRead)]
  64. public async Task<IActionResult> GetProductionTrendAsync(long tenantId = 1, long factoryId = 1, int days = 7, string? period = null)
  65. {
  66. // Compatibility-only. Security scope is resolved server-side.
  67. _ = tenantId; _ = factoryId;
  68. var scope = await _scope.ResolveAsync();
  69. return Ok(await _svc.GetProductionTrendAsync(scope.TenantId, scope.FactoryId, days, period));
  70. }
  71. /// <summary>
  72. /// S8-SUPPLY-PAGE-TYPE-TOTAL-ALIGN-1:Supply 页近 N 日供应异常趋势。
  73. /// 口径 module_code IN (S3,S4,S5) AND exception_type_code IN 11 类供应异常
  74. /// (供应商回复交期 / 供应商发货 / 供应商交付延期预警 / 仓库收货 / IQC 检验 / 仓库上架 /
  75. /// 仓库工单备料 / 仓库工单发料 / 采购执行延期 / 物料库存 / 库存周转)。
  76. /// </summary>
  77. [HttpGet("supply-trend")]
  78. [S8Permission(S8PermissionCatalog.DashboardRead)]
  79. public async Task<IActionResult> GetSupplyTrendAsync(long tenantId = 1, long factoryId = 1, int days = 7, string? period = null)
  80. {
  81. // Compatibility-only. Security scope is resolved server-side.
  82. _ = tenantId; _ = factoryId;
  83. var scope = await _scope.ResolveAsync();
  84. return Ok(await _svc.GetSupplyTrendAsync(scope.TenantId, scope.FactoryId, days, period));
  85. }
  86. /// <summary>
  87. /// S8-SIDEBAR-TYPE-CARD-WINDOW-TOGGLE-1:专题页右侧异常类型卡同窗口同分母聚合。
  88. /// domain ∈ {DELIVERY, PRODUCTION, SUPPLY};window ∈ {LAST_24H(默认), LAST_7D};period 优先于 window。
  89. /// </summary>
  90. [HttpGet("domain-type-metrics")]
  91. [S8Permission(S8PermissionCatalog.DashboardRead)]
  92. public async Task<IActionResult> GetDomainTypeMetricsAsync(string domain, string window = "LAST_24H", string? period = null, long tenantId = 1, long factoryId = 1)
  93. {
  94. // Compatibility-only. Security scope is resolved server-side.
  95. _ = tenantId; _ = factoryId;
  96. var scope = await _scope.ResolveAsync();
  97. return Ok(await _svc.GetDomainTypeMetricsAsync(domain, window, scope.TenantId, scope.FactoryId, period));
  98. }
  99. /// <summary>
  100. /// TASK-010:S9 卡片 QDC 四主线运营聚合(质量 / 交付 / 成本 / 库存)。
  101. /// </summary>
  102. [HttpGet("qdc-summary")]
  103. [S8Permission(S8PermissionCatalog.DashboardRead)]
  104. public async Task<IActionResult> GetQdcSummaryAsync(long tenantId = 1, long factoryId = 1, string? period = null)
  105. {
  106. // Compatibility-only. Security scope is resolved server-side.
  107. _ = tenantId; _ = factoryId;
  108. var scope = await _scope.ResolveAsync();
  109. return Ok(await _svc.GetQdcSummaryAsync(scope.TenantId, scope.FactoryId, period));
  110. }
  111. /// <summary>
  112. /// TASK-012-S9-QDC-RATIO-MIGRATION-2:S9 result KPI summary(订单交付率/到货达成率/检验合格率/工单完工率)。
  113. /// 与 qdc-summary 是不同语义:本接口返回结果指标占位,待真实计算入口(RATIO-REAL-1)后续接入。
  114. /// </summary>
  115. [HttpGet("result-kpi-summary")]
  116. [S8Permission(S8PermissionCatalog.DashboardRead)]
  117. public async Task<IActionResult> GetResultKpiSummaryAsync(long tenantId = 1, long factoryId = 1)
  118. {
  119. // Compatibility-only. Security scope is resolved server-side.
  120. _ = tenantId; _ = factoryId;
  121. var scope = await _scope.ResolveAsync();
  122. return Ok(await _svc.GetResultKpiSummaryAsync(scope.TenantId, scope.FactoryId));
  123. }
  124. }