|
|
@@ -1,13 +1,17 @@
|
|
|
// ORDER-FLOW-S8-INTEGRATED-DOMAIN-RESET-1 t3g:正式 API DTO → 旧 SalesOrderExecution 字段映射。
|
|
|
-// 仅供订单执行档案总览 (SoOrderExecutionDashboardPage) 的最小消费,不含 lifecycle 详情。
|
|
|
-// Chain 页面暂不切换;总览页只读 store.filteredOrders / store.allOrders / kpiAverages / filterOptions / filteredCustomerGroups,
|
|
|
-// 这些 getter 全部基于 SalesOrderExecution 的扁平字段,不进入 lifecycle,所以 lifecycle 留空数组即可。
|
|
|
+// t3h:补 lifecycle mapper + OrderFlowCode 大写到 OrderNodeKey 小写的协议翻译表。
|
|
|
+// Chain 页面暂不切换;总览页展开后五阶段对照表通过 loadDetailFromDomain 注入 lifecycle。
|
|
|
import { EXECUTION_OBSERVED_AT } from '/@/views/aidop/s8/monitoring/data/order-execution/customers';
|
|
|
import type {
|
|
|
OrderNodeKey,
|
|
|
SalesOrderExecution,
|
|
|
+ StageSnapshot,
|
|
|
} from '/@/views/aidop/s8/monitoring/data/order-execution/types';
|
|
|
-import type { OrderFlowOrderListItem } from '/@/views/aidop/s8/api/s8OrderFlowDomainApi';
|
|
|
+import type {
|
|
|
+ OrderFlowOrderDetail,
|
|
|
+ OrderFlowOrderListItem,
|
|
|
+ OrderFlowStage,
|
|
|
+} from '/@/views/aidop/s8/api/s8OrderFlowDomainApi';
|
|
|
|
|
|
// 'YYYY-MM-DD HH:mm' → 'MM-DD HH:mm';'YYYY-MM-DD' → 'MM-DD'。与旧 store.mapStage 同义,复制以避免跨文件依赖。
|
|
|
function toMonthDayTime(s: string | null | undefined): string {
|
|
|
@@ -36,8 +40,44 @@ function asExceptionStatus(v: string): SalesOrderExecution['exceptionStatus'] {
|
|
|
return v === '处理中' || v === '已闭环' ? v : '待响应';
|
|
|
}
|
|
|
|
|
|
+// ORDER_FLOW 协议翻译表:后端 5 大写 code → 前端 OrderNodeKey 小写 union。
|
|
|
+// 未识别值兜底为 order_review(首阶段),与现网 5 阶段 seed 一致;不抛错以避免阻塞首屏渲染。
|
|
|
+const ORDER_FLOW_CODE_TO_NODE_KEY: Record<string, OrderNodeKey> = {
|
|
|
+ ORDER_REVIEW_PLAN_CALC: 'order_review',
|
|
|
+ PRODUCT_DESIGN: 'product_design',
|
|
|
+ MATERIAL_PURCHASE: 'material_procurement',
|
|
|
+ BODY_PRODUCTION: 'body_production',
|
|
|
+ FINAL_ASSEMBLY_DELIVERY: 'final_assembly_shipping',
|
|
|
+};
|
|
|
+
|
|
|
+export function mapOrderFlowCodeToNodeKey(code: string | null | undefined): OrderNodeKey {
|
|
|
+ return (code && ORDER_FLOW_CODE_TO_NODE_KEY[code]) || 'order_review';
|
|
|
+}
|
|
|
+
|
|
|
+function asStageStatus(v: string): StageSnapshot['status'] {
|
|
|
+ return v === 'green' || v === 'yellow' || v === 'red' || v === 'pending' ? v : 'pending';
|
|
|
+}
|
|
|
+
|
|
|
+export function mapDomainStage(stage: OrderFlowStage): StageSnapshot {
|
|
|
+ return {
|
|
|
+ key: mapOrderFlowCodeToNodeKey(stage.orderFlowCode),
|
|
|
+ name: stage.orderFlowName,
|
|
|
+ targetDate: toMonthDayTime(stage.targetAt),
|
|
|
+ actualReachedAt: stage.actualEndAt ? toMonthDayTime(stage.actualEndAt) : null,
|
|
|
+ actualDays: stage.actualDays,
|
|
|
+ nodeVarianceDays: stage.nodeVarianceDays,
|
|
|
+ cumulativeVarianceDays: stage.cumulativeVarianceDays,
|
|
|
+ status: asStageStatus(stage.status),
|
|
|
+ };
|
|
|
+}
|
|
|
+
|
|
|
+export function mapDomainOrderDetailLifecycle(detail: OrderFlowOrderDetail): StageSnapshot[] {
|
|
|
+ if (!detail || !Array.isArray(detail.lifecycle)) return [];
|
|
|
+ return detail.lifecycle.map(mapDomainStage);
|
|
|
+}
|
|
|
+
|
|
|
export function mapDomainOrderListItem(dto: OrderFlowOrderListItem): SalesOrderExecution {
|
|
|
- const currentKey = dto.currentOrderFlowCode as OrderNodeKey;
|
|
|
+ const currentKey = mapOrderFlowCodeToNodeKey(dto.currentOrderFlowCode);
|
|
|
return {
|
|
|
soNo: dto.orderCode,
|
|
|
orderId: dto.orderCode.replace(/^SO/, 'ORD'),
|