| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- using Admin.NET.Plugin.AiDOP.Dto.S8;
- using Admin.NET.Plugin.AiDOP.Infrastructure;
- using Admin.NET.Plugin.AiDOP.Service.S8;
- namespace Admin.NET.Plugin.AiDOP.Controllers.S8;
- [ApiController]
- [Route("api/aidop/s8/monitoring")]
- [NonUnify]
- public class AdoS8MonitoringController : ControllerBase
- {
- private readonly S8MonitoringService _svc;
- private readonly S8TrustedScopeResolver _scope;
- public AdoS8MonitoringController(S8MonitoringService svc, S8TrustedScopeResolver scope)
- {
- _svc = svc;
- _scope = scope;
- }
- /// <summary>
- /// 异常监控汇总——供 4 个监控页顶部徽标和模块汇总表使用。
- /// sceneCode 不传时返回全部模块聚合(综合全景页)。
- /// </summary>
- [HttpGet("summary")]
- public async Task<IActionResult> GetSummaryAsync([FromQuery] AdoS8MonitoringSummaryQueryDto q)
- {
- // S8-TENANT-FACTORY-P0-CLOSURE-1:作用域一律服务端解析,覆盖客户端传入值。
- var scope = await _scope.ResolveAsync();
- q.TenantId = scope.TenantId;
- q.FactoryId = scope.FactoryId;
- return Ok(await _svc.GetSummaryAsync(q));
- }
- /// <summary>
- /// 9宫格数据:S1-S7 订单健康分布 + S8业务类别汇总 + S9部门汇总。
- /// </summary>
- [HttpGet("order-grid")]
- public async Task<IActionResult> GetOrderGridAsync([FromQuery] string? period = null)
- {
- var scope = await _scope.ResolveAsync();
- return Ok(await _svc.GetOrderGridAsync(scope.TenantId, scope.FactoryId, period));
- }
- /// <summary>
- /// S8-DELIVERY-PAGE-TYPE-TOTAL-ALIGN-1:Delivery 页近 N 日交付异常趋势。
- /// 口径 module_code IN (S1,S7) AND exception_type_code IN
- /// (ORDER_DUE_DATE_DELAY / PRODUCT_DESIGN_DELAY / DELIVERY_DELAY_WARNING)。
- /// </summary>
- [HttpGet("delivery-trend")]
- public async Task<IActionResult> GetDeliveryTrendAsync(long tenantId = 1, long factoryId = 1, int days = 7, string? period = null)
- {
- // Compatibility-only. Security scope is resolved server-side.
- _ = tenantId; _ = factoryId;
- var scope = await _scope.ResolveAsync();
- return Ok(await _svc.GetDeliveryTrendAsync(scope.TenantId, scope.FactoryId, days, period));
- }
- /// <summary>
- /// S8-PRODUCTION-PAGE-TYPE-TITLE-AND-TREND-ALIGN-1:Production 页近 N 日生产异常趋势。
- /// 口径 module_code IN (S2,S6) AND exception_type_code IN
- /// (EQUIP_FAULT / MFG_MATERIAL_ABNORMAL / MFG_QUALITY_ABNORMAL / BODY_PRODUCTION_DELAY_WARNING)。
- /// </summary>
- [HttpGet("production-trend")]
- public async Task<IActionResult> GetProductionTrendAsync(long tenantId = 1, long factoryId = 1, int days = 7, string? period = null)
- {
- // Compatibility-only. Security scope is resolved server-side.
- _ = tenantId; _ = factoryId;
- var scope = await _scope.ResolveAsync();
- return Ok(await _svc.GetProductionTrendAsync(scope.TenantId, scope.FactoryId, days, period));
- }
- /// <summary>
- /// S8-SUPPLY-PAGE-TYPE-TOTAL-ALIGN-1:Supply 页近 N 日供应异常趋势。
- /// 口径 module_code IN (S3,S4,S5) AND exception_type_code IN 11 类供应异常
- /// (供应商回复交期 / 供应商发货 / 供应商交付延期预警 / 仓库收货 / IQC 检验 / 仓库上架 /
- /// 仓库工单备料 / 仓库工单发料 / 采购执行延期 / 物料库存 / 库存周转)。
- /// </summary>
- [HttpGet("supply-trend")]
- public async Task<IActionResult> GetSupplyTrendAsync(long tenantId = 1, long factoryId = 1, int days = 7, string? period = null)
- {
- // Compatibility-only. Security scope is resolved server-side.
- _ = tenantId; _ = factoryId;
- var scope = await _scope.ResolveAsync();
- return Ok(await _svc.GetSupplyTrendAsync(scope.TenantId, scope.FactoryId, days, period));
- }
- /// <summary>
- /// S8-SIDEBAR-TYPE-CARD-WINDOW-TOGGLE-1:专题页右侧异常类型卡同窗口同分母聚合。
- /// domain ∈ {DELIVERY, PRODUCTION, SUPPLY};window ∈ {LAST_24H(默认), LAST_7D};period 优先于 window。
- /// </summary>
- [HttpGet("domain-type-metrics")]
- public async Task<IActionResult> GetDomainTypeMetricsAsync(string domain, string window = "LAST_24H", string? period = null, long tenantId = 1, long factoryId = 1)
- {
- // Compatibility-only. Security scope is resolved server-side.
- _ = tenantId; _ = factoryId;
- var scope = await _scope.ResolveAsync();
- return Ok(await _svc.GetDomainTypeMetricsAsync(domain, window, scope.TenantId, scope.FactoryId, period));
- }
- /// <summary>
- /// TASK-010:S9 卡片 QDC 四主线运营聚合(质量 / 交付 / 成本 / 库存)。
- /// </summary>
- [HttpGet("qdc-summary")]
- public async Task<IActionResult> GetQdcSummaryAsync(long tenantId = 1, long factoryId = 1, string? period = null)
- {
- // Compatibility-only. Security scope is resolved server-side.
- _ = tenantId; _ = factoryId;
- var scope = await _scope.ResolveAsync();
- return Ok(await _svc.GetQdcSummaryAsync(scope.TenantId, scope.FactoryId, period));
- }
- /// <summary>
- /// TASK-012-S9-QDC-RATIO-MIGRATION-2:S9 result KPI summary(订单交付率/到货达成率/检验合格率/工单完工率)。
- /// 与 qdc-summary 是不同语义:本接口返回结果指标占位,待真实计算入口(RATIO-REAL-1)后续接入。
- /// </summary>
- [HttpGet("result-kpi-summary")]
- public async Task<IActionResult> GetResultKpiSummaryAsync(long tenantId = 1, long factoryId = 1)
- {
- // Compatibility-only. Security scope is resolved server-side.
- _ = tenantId; _ = factoryId;
- var scope = await _scope.ResolveAsync();
- return Ok(await _svc.GetResultKpiSummaryAsync(scope.TenantId, scope.FactoryId));
- }
- }
|