AdoS8MonitoringController.cs 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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. return Ok(await _svc.GetSummaryAsync(q));
  31. }
  32. /// <summary>
  33. /// 9宫格数据:S1-S7 订单健康分布 + S8业务类别汇总 + S9部门汇总。
  34. /// </summary>
  35. [HttpGet("order-grid")]
  36. [S8Permission(S8PermissionCatalog.DashboardRead)]
  37. public async Task<IActionResult> GetOrderGridAsync([FromQuery] string? period = null)
  38. {
  39. var scope = await _scope.ResolveAsync();
  40. return Ok(await _svc.GetOrderGridAsync(scope.TenantId, period));
  41. }
  42. /// <summary>
  43. /// S8-DELIVERY-PAGE-TYPE-TOTAL-ALIGN-1:Delivery 页近 N 日交付异常趋势。
  44. /// 口径 module_code IN (S1,S7) AND exception_type_code IN
  45. /// (ORDER_DUE_DATE_DELAY / PRODUCT_DESIGN_DELAY / DELIVERY_DELAY_WARNING)。
  46. /// </summary>
  47. [HttpGet("delivery-trend")]
  48. [S8Permission(S8PermissionCatalog.DashboardRead)]
  49. public async Task<IActionResult> GetDeliveryTrendAsync(long tenantId = 1, long factoryId = 1, int days = 7, string? period = null)
  50. {
  51. // Compatibility-only. Security scope is resolved server-side.
  52. _ = tenantId; _ = factoryId;
  53. var scope = await _scope.ResolveAsync();
  54. return Ok(await _svc.GetDeliveryTrendAsync(scope.TenantId, days, period));
  55. }
  56. /// <summary>
  57. /// S8-PRODUCTION-PAGE-TYPE-TITLE-AND-TREND-ALIGN-1:Production 页近 N 日生产异常趋势。
  58. /// 口径 module_code IN (S2,S6) AND exception_type_code IN
  59. /// (EQUIP_FAULT / MFG_MATERIAL_ABNORMAL / MFG_QUALITY_ABNORMAL / BODY_PRODUCTION_DELAY_WARNING)。
  60. /// </summary>
  61. [HttpGet("production-trend")]
  62. [S8Permission(S8PermissionCatalog.DashboardRead)]
  63. public async Task<IActionResult> GetProductionTrendAsync(long tenantId = 1, long factoryId = 1, int days = 7, string? period = null)
  64. {
  65. // Compatibility-only. Security scope is resolved server-side.
  66. _ = tenantId; _ = factoryId;
  67. var scope = await _scope.ResolveAsync();
  68. return Ok(await _svc.GetProductionTrendAsync(scope.TenantId, days, period));
  69. }
  70. /// <summary>
  71. /// S8-SUPPLY-PAGE-TYPE-TOTAL-ALIGN-1:Supply 页近 N 日供应异常趋势。
  72. /// 口径 module_code IN (S3,S4,S5) AND exception_type_code IN 11 类供应异常
  73. /// (供应商回复交期 / 供应商发货 / 供应商交付延期预警 / 仓库收货 / IQC 检验 / 仓库上架 /
  74. /// 仓库工单备料 / 仓库工单发料 / 采购执行延期 / 物料库存 / 库存周转)。
  75. /// </summary>
  76. [HttpGet("supply-trend")]
  77. [S8Permission(S8PermissionCatalog.DashboardRead)]
  78. public async Task<IActionResult> GetSupplyTrendAsync(long tenantId = 1, long factoryId = 1, int days = 7, string? period = null)
  79. {
  80. // Compatibility-only. Security scope is resolved server-side.
  81. _ = tenantId; _ = factoryId;
  82. var scope = await _scope.ResolveAsync();
  83. return Ok(await _svc.GetSupplyTrendAsync(scope.TenantId, days, period));
  84. }
  85. /// <summary>
  86. /// S8-SIDEBAR-TYPE-CARD-WINDOW-TOGGLE-1:专题页右侧异常类型卡同窗口同分母聚合。
  87. /// domain ∈ {DELIVERY, PRODUCTION, SUPPLY};window ∈ {LAST_24H(默认), LAST_7D};period 优先于 window。
  88. /// </summary>
  89. [HttpGet("domain-type-metrics")]
  90. [S8Permission(S8PermissionCatalog.DashboardRead)]
  91. public async Task<IActionResult> GetDomainTypeMetricsAsync(string domain, string window = "LAST_24H", string? period = null, long tenantId = 1, long factoryId = 1)
  92. {
  93. // Compatibility-only. Security scope is resolved server-side.
  94. _ = tenantId; _ = factoryId;
  95. var scope = await _scope.ResolveAsync();
  96. return Ok(await _svc.GetDomainTypeMetricsAsync(domain, window, scope.TenantId, period));
  97. }
  98. /// <summary>
  99. /// TASK-010:S9 卡片 QDC 四主线运营聚合(质量 / 交付 / 成本 / 库存)。
  100. /// </summary>
  101. [HttpGet("qdc-summary")]
  102. [S8Permission(S8PermissionCatalog.DashboardRead)]
  103. public async Task<IActionResult> GetQdcSummaryAsync(long tenantId = 1, long factoryId = 1, string? period = null)
  104. {
  105. // Compatibility-only. Security scope is resolved server-side.
  106. _ = tenantId; _ = factoryId;
  107. var scope = await _scope.ResolveAsync();
  108. return Ok(await _svc.GetQdcSummaryAsync(scope.TenantId, period));
  109. }
  110. /// <summary>
  111. /// TASK-012-S9-QDC-RATIO-MIGRATION-2:S9 result KPI summary(订单交付率/到货达成率/检验合格率/工单完工率)。
  112. /// 与 qdc-summary 是不同语义:本接口返回结果指标占位,待真实计算入口(RATIO-REAL-1)后续接入。
  113. /// </summary>
  114. [HttpGet("result-kpi-summary")]
  115. [S8Permission(S8PermissionCatalog.DashboardRead)]
  116. public async Task<IActionResult> GetResultKpiSummaryAsync(long tenantId = 1, long factoryId = 1)
  117. {
  118. // Compatibility-only. Security scope is resolved server-side.
  119. _ = tenantId; _ = factoryId;
  120. var scope = await _scope.ResolveAsync();
  121. return Ok(await _svc.GetResultKpiSummaryAsync(scope.TenantId));
  122. }
  123. }