From af30681837aa081866d0137b553a9c5eabbf720d Mon Sep 17 00:00:00 2001 From: "CANCERYS\\kw093" Date: Mon, 22 Dec 2025 14:08:36 +0800 Subject: [PATCH] update --- src/app/api/do/actions.tsx | 4 +- src/app/api/jo/actions.ts | 4 +- .../ProductionProcessStepExecution.tsx | 86 +++++++++++++++++-- 3 files changed, 82 insertions(+), 12 deletions(-) diff --git a/src/app/api/do/actions.tsx b/src/app/api/do/actions.tsx index 6f70823..5d54928 100644 --- a/src/app/api/do/actions.tsx +++ b/src/app/api/do/actions.tsx @@ -173,9 +173,9 @@ export const fetchDoRecordByPage = cache(async (data?: SearchDeliveryOrderInfoRe return response }) -export const fetchTicketReleaseTable = cache(async ()=> { +export const fetchTicketReleaseTable = cache(async (startDate: string, endDate: string)=> { return await serverFetchJson( - `${BASE_API_URL}/doPickOrder/ticket-release-table`, + `${BASE_API_URL}/doPickOrder/ticket-release-table/${startDate}&${endDate}`, { method: "GET", } diff --git a/src/app/api/jo/actions.ts b/src/app/api/jo/actions.ts index 76f6284..c291f92 100644 --- a/src/app/api/jo/actions.ts +++ b/src/app/api/jo/actions.ts @@ -409,7 +409,9 @@ export interface JobOrderProcessLineDetailResponse { description: string; equipmentId: number; startTime: string | number[]; // API 返回的是数组格式 - endTime: string | number[]; // API 返回的是数组格式 + endTime: string | number[]; + stopTime: string | number[]; + totalPausedTimeMs?: number; // API 返回的是数组格式 status: string; outputFromProcessQty: number; outputFromProcessUom: string; diff --git a/src/components/ProductionProcess/ProductionProcessStepExecution.tsx b/src/components/ProductionProcess/ProductionProcessStepExecution.tsx index 03cc773..f0d3cd1 100644 --- a/src/components/ProductionProcess/ProductionProcessStepExecution.tsx +++ b/src/components/ProductionProcess/ProductionProcessStepExecution.tsx @@ -133,8 +133,27 @@ const ProductionProcessStepExecution: React.FC { + if (!stopTime) return null; + + if (Array.isArray(stopTime)) { + const [year, month, day, hour = 0, minute = 0, second = 0] = stopTime; + return new Date(year, month - 1, day, hour, minute, second); + } else { + return new Date(stopTime); + } + }; + const update = () => { if (isPaused) { // If paused, freeze the time at the last calculated value - // If we don't have a frozen value yet, calculate it based on current time + // If we don't have a frozen value yet, calculate it based on stopTime if (!frozenRemainingTime) { - const now = new Date(); - const elapsed = now.getTime() - start.getTime(); + // ✅ 修复问题2:正确处理 stopTime 的类型(string | number[]) + const pauseTime = lineDetail.stopTime + ? parseStopTime(lineDetail.stopTime) + : null; + + // 如果没有 stopTime,使用当前时间(首次暂停时) + const pauseTimeToUse = pauseTime && !isNaN(pauseTime.getTime()) + ? pauseTime + : new Date(); + + // ✅ 计算总暂停时间(所有已恢复的暂停记录) + const totalPausedTimeMs = (lineDetail as any).totalPausedTimeMs || 0; + + console.log("⏸️ Paused - calculating frozen time:", { + stopTime: lineDetail.stopTime, + pauseTime: pauseTimeToUse, + startTime: start, + totalPausedTimeMs: totalPausedTimeMs, + }); + + // ✅ 实际工作时间 = 暂停时间 - 开始时间 - 已恢复的暂停时间 + const elapsed = pauseTimeToUse.getTime() - start.getTime() - totalPausedTimeMs; const remaining = durationMs - elapsed; if (remaining <= 0) { @@ -182,6 +233,7 @@ const ProductionProcessStepExecution: React.FC clearInterval(timer); } - }, [lineDetail?.durationInMinutes, lineDetail?.startTime, lineDetail?.status, lineDetail?.productProcessIssueStatus]); + }, [lineDetail?.durationInMinutes, lineDetail?.startTime, lineDetail?.status, lineDetail?.productProcessIssueStatus, lineDetail?.stopTime, frozenRemainingTime]); // Reset frozen time when status changes from paused to in progress useEffect(() => {