| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- import { s8MonitoringApi, type S8MonitoringSummary, type S8ModuleOrderSummary, type S8Period } from './s8MonitoringApi';
- import { loadConfiguredAnomalyTypes } from './s8MonitoringCellApi';
- export interface DeliveryAnomalyType {
- key: string;
- label: string;
- total: number;
- avgProcessHours: number;
- closeRate: number;
- }
- export interface DeliveryMonitoringData {
- summary: S8MonitoringSummary;
- modules: S8ModuleOrderSummary[];
- anomalyTypes: DeliveryAnomalyType[];
- }
- // S8-DELIVERY-PAGE-TYPE-PRUNE-AND-TREND-ALIGN-1:Delivery 页类型卡收敛为 2 类;
- // 显示名「总装发货延期」仅 delivery 大屏展示,不改 ado_s8_exception_type.type_name。
- const DELIVERY_ANOMALY_SPECS = [
- {
- key: 'order-due-date-delay',
- label: '订单交期延期',
- totalCellCode: 'DELIVERY_ANOMALY_ORDER_DUE_DATE_DELAY',
- analysisCellCode: 'DELIVERY_CAT_ORDER_DUE_DATE_DELAY',
- },
- {
- key: 'delivery-delay-warning',
- label: '总装发货延期',
- totalCellCode: 'DELIVERY_ANOMALY_DELIVERY_DELAY_WARNING',
- analysisCellCode: 'DELIVERY_CAT_DELIVERY_DELAY_WARNING',
- },
- ] as const;
- const EMPTY_SUMMARY: S8MonitoringSummary = { total: 0, red: 0, yellow: 0, green: 0, timeout: 0, byModule: [] };
- export const s8DeliveryMonitoringApi = {
- /** 获取交付域汇总摘要;moduleCodes 由 page-config 派生(fallback 走 STAGE_META_FALLBACK)。空数组时直接返回空态,不退化为后端全量。 */
- summary: (moduleCodes: string[], period?: S8Period): Promise<S8MonitoringSummary> =>
- moduleCodes.length === 0
- ? Promise.resolve({ ...EMPTY_SUMMARY, byModule: [] })
- : s8MonitoringApi.summary({ moduleCode: moduleCodes.join(','), period }),
- /** 获取交付域各阶段订单统计;按 moduleCodes 过滤 byModule 全集。空数组时不调接口,直接返回空数组。 */
- modules: (moduleCodes: string[], period?: S8Period): Promise<S8ModuleOrderSummary[]> => {
- if (moduleCodes.length === 0) return Promise.resolve([]);
- const set = new Set(moduleCodes);
- return s8MonitoringApi.orderGrid({ period }).then((data) =>
- data.modules.filter((m) => set.has(m.moduleCode)),
- );
- },
- /** 获取交付异常类型明细;接口失败返回空数组(不再回退到示例数据) */
- anomalyTypes: (): Promise<DeliveryAnomalyType[]> =>
- loadConfiguredAnomalyTypes('DELIVERY', [...DELIVERY_ANOMALY_SPECS]),
- };
|