ソースを参照

feat(s8): t3e add order flow frontend api client

YY968XX 2 ヶ月 前
コミット
44a0ead94d
1 ファイル変更227 行追加0 行削除
  1. 227 0
      Web/src/views/aidop/s8/api/s8OrderFlowDomainApi.ts

+ 227 - 0
Web/src/views/aidop/s8/api/s8OrderFlowDomainApi.ts

@@ -0,0 +1,227 @@
+// ORDER-FLOW-S8-INTEGRATED-DOMAIN-RESET-1 t3e:S8 订单执行链路正式 API client。
+// 与旧 demo 客户端 s8OrderFlowApi.ts 并存:
+//   - 旧 demo:/api/aidop/s8/demo/order-flow + soNo/stageKey 老命名(保留直到清理切片)
+//   - 本文件:/api/aidop/s8/order-flow + orderCode/orderFlowCode 正式命名(对齐后端 AdoS8OrderFlowDtos.cs)
+// 本切片只新增 client 与 TS 类型,不切换页面调用,不删除旧 client。
+import service from '/@/utils/request';
+
+function unwrap<T>(res: { data: T }): T {
+	return res.data;
+}
+
+// ────────────────────────────────────────────────────────────
+// Types:与后端 AdoS8OrderFlowDtos.cs 字段一一对齐
+// ────────────────────────────────────────────────────────────
+
+export interface OrderFlowOrderQuery {
+	tenantId?: number;
+	factoryId?: number;
+	keyword?: string;
+	currentFlowCode?: string;
+	customerCode?: string;
+	productLine?: string;
+	region?: string;
+	workflowStatus?: string;
+	scenarioCode?: string;
+}
+
+export interface OrderFlowOrderListItem {
+	orderCode: string;
+	productName: string;
+	productLine: string;
+	customerCode: string;
+	customerName: string;
+	customerType: string;
+	region: string;
+	priority: string;
+	workflowStatus: string;
+	currentOrderFlowCode: string;
+	currentOrderFlowName: string;
+	currentStatus: string;
+	releaseAt: string;
+	targetCycleDays: number;
+	actualCycleDays: number | null;
+	currentCycleDays: number | null;
+	nodeVarianceDays: number | null;
+	cumulativeVarianceDays: number | null;
+	/** 来自 ado_s8_exception 实时聚合,order 主档表无 exception_count 列。 */
+	exceptionCount: number;
+	exceptionStatus: string;
+	responseMinutes: number | null;
+	processingMinutes: number | null;
+	totalLossMinutes: number | null;
+	scenarioCode: string;
+	dataSource: string;
+}
+
+export interface OrderFlowSubstepUnit {
+	unitCode: string;
+	unitName: string;
+	piHours: number;
+	actualHours: number | null;
+	status: string;
+	sortNo: number;
+}
+
+export interface OrderFlowSubstep {
+	substepCode: string;
+	substepName: string;
+	piHours: number;
+	actualHours: number | null;
+	status: string;
+	sortNo: number;
+	units: OrderFlowSubstepUnit[];
+}
+
+export interface OrderFlowStage {
+	orderFlowCode: string;
+	orderFlowName: string;
+	ownerDept: string | null;
+	sortNo: number;
+	plannedDays: number;
+	actualDays: number | null;
+	targetAt: string;
+	actualStartAt: string | null;
+	actualEndAt: string | null;
+	status: string;
+	nodeVarianceDays: number | null;
+	cumulativeVarianceDays: number | null;
+	substeps: OrderFlowSubstep[];
+}
+
+export interface OrderFlowOrderDetail extends OrderFlowOrderListItem {
+	lifecycle: OrderFlowStage[];
+}
+
+export interface OrderFlowChain {
+	order: OrderFlowOrderDetail;
+	procurementPivot: OrderFlowProcurementPivot | null;
+}
+
+export interface OrderFlowAggregateQuery {
+	tenantId?: number;
+	factoryId?: number;
+	/** BASELINE_PPT | CURRENT_FILTERED */
+	scope: string;
+	orderCodes?: string[];
+}
+
+export interface OrderFlowStageAggregate {
+	orderFlowCode: string;
+	orderFlowName: string;
+	kpiAvgDays: number;
+	actualAvgDays: number;
+	/** 整数百分比,例如 0~100,不是 0.0~1.0 的小数。 */
+	onTimeRate: number;
+	green: number;
+	yellow: number;
+	red: number;
+	pending: number;
+}
+
+export interface OrderFlowAggregate {
+	scope: string;
+	totalOrders: number;
+	totalCustomers: number;
+	avgResponseMinutes: number;
+	avgProcessingMinutes: number;
+	avgLossMinutes: number;
+	stageAggregates: OrderFlowStageAggregate[];
+}
+
+export interface OrderFlowProcurementPivotQuery {
+	tenantId?: number;
+	factoryId?: number;
+	/** BASELINE_PPT */
+	scope: string;
+	orderCodes?: string[];
+}
+
+export interface OrderFlowKeyMaterial {
+	materialCode: string;
+	avgCycleDays: number;
+	cycleStatus: string;
+	impactCount: number | null;
+	kitRate: number | null;
+	resultStatus: string;
+}
+
+export interface OrderFlowSupplierBreakdown {
+	materialCode: string;
+	supplierCode: string;
+	avgCycleDays: number;
+	status: string;
+}
+
+export interface OrderFlowSpecBreakdown {
+	materialCode: string;
+	specCode: string;
+	avgCycleDays: number;
+	status: string;
+}
+
+export interface OrderFlowProcurementMatrixCell {
+	cycleDays: number;
+	status: string;
+}
+
+export interface OrderFlowProcurementMatrixRow {
+	supplierCode: string;
+	cells: Record<string, OrderFlowProcurementMatrixCell>;
+}
+
+export interface OrderFlowProcurementPivot {
+	scope: string;
+	keyMaterials: OrderFlowKeyMaterial[];
+	supplierBreakdown: OrderFlowSupplierBreakdown[];
+	specBreakdown: OrderFlowSpecBreakdown[];
+	matrixByMaterial: Record<string, OrderFlowProcurementMatrixRow[]>;
+}
+
+// ────────────────────────────────────────────────────────────
+// API methods
+// ────────────────────────────────────────────────────────────
+
+const BASE = '/api/aidop/s8/order-flow';
+
+export function getOrderFlowOrders(query: OrderFlowOrderQuery = {}) {
+	return service
+		.get<OrderFlowOrderListItem[]>(`${BASE}/orders`, { params: query })
+		.then(unwrap);
+}
+
+export function getOrderFlowOrder(orderCode: string, tenantId?: number, factoryId?: number) {
+	return service
+		.get<OrderFlowOrderDetail | null>(`${BASE}/orders/${encodeURIComponent(orderCode)}`, {
+			params: { tenantId, factoryId },
+		})
+		.then(unwrap);
+}
+
+export function getOrderFlowChain(orderCode: string, tenantId?: number, factoryId?: number) {
+	return service
+		.get<OrderFlowChain | null>(`${BASE}/orders/${encodeURIComponent(orderCode)}/chain`, {
+			params: { tenantId, factoryId },
+		})
+		.then(unwrap);
+}
+
+export function getOrderFlowAggregate(query: OrderFlowAggregateQuery) {
+	return service
+		.get<OrderFlowAggregate>(`${BASE}/aggregate`, { params: query })
+		.then(unwrap);
+}
+
+export function getOrderFlowProcurementPivot(query: OrderFlowProcurementPivotQuery) {
+	return service
+		.get<OrderFlowProcurementPivot>(`${BASE}/procurement-pivot`, { params: query })
+		.then(unwrap);
+}
+
+export const s8OrderFlowDomainApi = {
+	getOrderFlowOrders,
+	getOrderFlowOrder,
+	getOrderFlowChain,
+	getOrderFlowAggregate,
+	getOrderFlowProcurementPivot,
+};