AdoS8MonitoringController.cs 5.8 KB

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