From fd0354f1d0966f9b524b089daf30723671bf5698 Mon Sep 17 00:00:00 2001 From: jingchuan Date: Wed, 12 Aug 2026 17:34:26 +0800 Subject: [PATCH 1/6] fix(sample-progress): sync all OA flow statuses --- .../src/app/intake/oa-board/page.tsx | 2 +- .../server/services/oa-board-sync.service.ts | 3 +++ .../services/sample-progress.service.ts | 20 ++++++++++++++++--- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/furniture-3d-system/src/app/intake/oa-board/page.tsx b/furniture-3d-system/src/app/intake/oa-board/page.tsx index 5f993d63..8a605618 100644 --- a/furniture-3d-system/src/app/intake/oa-board/page.tsx +++ b/furniture-3d-system/src/app/intake/oa-board/page.tsx @@ -128,7 +128,7 @@ export default async function OaBoardPage({ const dashboard = canViewDailyReport ? result.dashboard : { ...result.dashboard, dailyReport: undefined } - await sampleProgressService.syncFromOaItems(dashboard.items) + await sampleProgressService.syncFromOaDashboard() const sampleProgressItems = await sampleProgressService.listStored() return ( diff --git a/furniture-3d-system/src/server/services/oa-board-sync.service.ts b/furniture-3d-system/src/server/services/oa-board-sync.service.ts index 1a53384a..056c91bf 100644 --- a/furniture-3d-system/src/server/services/oa-board-sync.service.ts +++ b/furniture-3d-system/src/server/services/oa-board-sync.service.ts @@ -1189,6 +1189,9 @@ function toFlowStatusLabel(status: string | null | undefined, result: string | n if (normalizedStatus === 'TERMINATED') { return '已终止' } + if (normalizedStatus === 'CANCELED' || normalizedStatus === 'CANCELLED') { + return '已撤销' + } if (normalizedStatus === 'COMPLETED' && normalizedResult === 'REFUSE') { return '已拒绝' } diff --git a/furniture-3d-system/src/server/services/sample-progress.service.ts b/furniture-3d-system/src/server/services/sample-progress.service.ts index 6fc631af..b9bab2b6 100644 --- a/furniture-3d-system/src/server/services/sample-progress.service.ts +++ b/furniture-3d-system/src/server/services/sample-progress.service.ts @@ -91,6 +91,15 @@ function sampleStatusFromFlow(item: OaBoardProjectListItemDTO) { return undefined } +const SAMPLE_PROGRESS_SYNC_FLOW_STATUSES = [ + 'RUNNING', + 'COMPLETED', + 'TERMINATED', + 'CANCELED', + 'CANCELLED', + 'REFUSED', +] + function linkedProductId(workflowLink: string) { try { const segments = new URL(workflowLink).pathname.split('/').filter(Boolean) @@ -160,7 +169,7 @@ async function syncFromOaItems(items: OaBoardProjectListItemDTO[]) { await sampleProgressRepository.createMany(rows) await Promise.all(items.map((item) => { const openingCode = (item.formSummary.openingCode || item.openingCode || '').trim().toUpperCase() - if (!openingCode || !sampleArrival(item)) return Promise.resolve({ count: 0 }) + if (!openingCode) return Promise.resolve({ count: 0 }) const workflowLink = item.formSummary.workflowLink || '' const productId = linkedProductId(workflowLink) return sampleProgressRepository.updateOaFields({ @@ -191,10 +200,15 @@ function comparable(value: unknown) { export const sampleProgressService = { async syncFromOaItems(items: OaBoardProjectListItemDTO[]) { await syncFromOaItems(items) }, + async syncFromOaDashboard() { + const dashboard = await oaBoardService.getDashboard({ + overallStatus: SAMPLE_PROGRESS_SYNC_FLOW_STATUSES, + }) + await syncFromOaItems(dashboard.items) + }, async listStored() { return (await sampleProgressRepository.list()).map(serialize) }, async list() { - const dashboard = await oaBoardService.getDashboard().catch(() => null) - if (dashboard) await syncFromOaItems(dashboard.items) + await this.syncFromOaDashboard().catch(() => undefined) return this.listStored() }, getOaPrefill: readOaPrefill, From 7a25001d6babcf6d61b357b8bd39e808edbe1fdb Mon Sep 17 00:00:00 2001 From: jingchuan Date: Wed, 12 Aug 2026 17:48:52 +0800 Subject: [PATCH 2/6] fix(sample-progress): retain reached cancelled sample nodes --- furniture-3d-system/src/server/services/oa-board.service.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/furniture-3d-system/src/server/services/oa-board.service.ts b/furniture-3d-system/src/server/services/oa-board.service.ts index ea98098d..83dad2ff 100644 --- a/furniture-3d-system/src/server/services/oa-board.service.ts +++ b/furniture-3d-system/src/server/services/oa-board.service.ts @@ -1715,7 +1715,11 @@ function toProjectListItem(record: PreviewProjectRecord): OaBoardProjectListItem const nodeAssessments = record.flowInstances .flatMap((flowInstance) => flowInstance.taskRecords - .filter((taskRecord) => taskRecord.status !== 'CANCELED') + .filter( + (taskRecord) => + taskRecord.status !== 'CANCELED' || + (taskRecord.nodeName === '确认打样出货时间' && Boolean(taskRecord.startedAtSource)), + ) .map((taskRecord) => ({ flowType: flowInstance.flowType, flowLabel: From e2d739d1d4771960bc3bedcc3153d292968713e3 Mon Sep 17 00:00:00 2001 From: jingchuan Date: Thu, 13 Aug 2026 09:08:33 +0800 Subject: [PATCH 3/6] fix(sample-progress): count only active managed samples --- .../src/app/intake/sample-progress/SampleProgressClient.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/furniture-3d-system/src/app/intake/sample-progress/SampleProgressClient.tsx b/furniture-3d-system/src/app/intake/sample-progress/SampleProgressClient.tsx index b50bf34a..dd78d7d4 100644 --- a/furniture-3d-system/src/app/intake/sample-progress/SampleProgressClient.tsx +++ b/furniture-3d-system/src/app/intake/sample-progress/SampleProgressClient.tsx @@ -36,6 +36,7 @@ export default function SampleProgressClient({ initialItems, currentUserName, em }), [items, keyword, status]) const totalPages = Math.max(1, Math.ceil(filtered.length / PAGE_SIZE)) const rows = filtered.slice((Math.min(page, totalPages) - 1) * PAGE_SIZE, Math.min(page, totalPages) * PAGE_SIZE) + const activeCount = items.filter((item) => !hiddenTerminalStatuses.has(item.status)).length const overdueCount = items.filter(isOverdue).length const statusCounts = SAMPLE_PROGRESS_STATUSES.map((value) => ({ value, count: items.filter((item) => item.status === value).length })) @@ -54,7 +55,7 @@ export default function SampleProgressClient({ initialItems, currentUserName, em
- } label="在管打样" value={`${items.length} 款`} tone="plain" /> + } label="在管打样" value={`${activeCount} 款`} tone="plain" /> } label="交期已超期" value={`${overdueCount} 款`} tone={overdueCount ? 'danger' : 'plain'} />
From 1433428cf7115253160e85ed0595b27515e2b824 Mon Sep 17 00:00:00 2001 From: jingchuan Date: Thu, 13 Aug 2026 10:38:22 +0800 Subject: [PATCH 4/6] fix(sample-progress): show current OA sample stage count --- .../src/app/intake/oa-board/OaBoardClient.tsx | 4 +++- .../src/app/intake/oa-board/page.tsx | 2 ++ .../intake/sample-progress/SampleProgressClient.tsx | 5 ++--- .../src/app/intake/sample-progress/page.tsx | 3 ++- .../src/app/sample-progress-preview/page.tsx | 2 +- .../src/server/services/sample-progress.service.ts | 13 +++++++++++++ 6 files changed, 23 insertions(+), 6 deletions(-) diff --git a/furniture-3d-system/src/app/intake/oa-board/OaBoardClient.tsx b/furniture-3d-system/src/app/intake/oa-board/OaBoardClient.tsx index 07de933e..ce846df6 100644 --- a/furniture-3d-system/src/app/intake/oa-board/OaBoardClient.tsx +++ b/furniture-3d-system/src/app/intake/oa-board/OaBoardClient.tsx @@ -3308,11 +3308,13 @@ export default function OaBoardClient({ dashboard, loadErrorMessage, sampleProgressItems = [], + currentSampleStageCount = 0, currentUserName = '', }: { dashboard: OaBoardDashboardDTO loadErrorMessage?: string | null sampleProgressItems?: SampleProgressDTO[] + currentSampleStageCount?: number currentUserName?: string }) { const { items: allItems, stageGraph, dailyReport, monthlyReport } = dashboard @@ -4473,7 +4475,7 @@ export default function OaBoardClient({ ) : activeTab === 'brand-planning' ? ( ) : activeTab === 'sample-progress' ? ( - + ) : activeTab === 'timeout-analysis' ? ( ) diff --git a/furniture-3d-system/src/app/intake/sample-progress/SampleProgressClient.tsx b/furniture-3d-system/src/app/intake/sample-progress/SampleProgressClient.tsx index dd78d7d4..c15aac25 100644 --- a/furniture-3d-system/src/app/intake/sample-progress/SampleProgressClient.tsx +++ b/furniture-3d-system/src/app/intake/sample-progress/SampleProgressClient.tsx @@ -17,7 +17,7 @@ const inputDate = (value: string | Date) => { return Number.isNaN(date.getTime()) ? '' : date.toISOString().slice(0, 10) } -export default function SampleProgressClient({ initialItems, currentUserName, embedded = false }: { initialItems: SampleProgressDTO[]; currentUserName: string; embedded?: boolean }) { +export default function SampleProgressClient({ initialItems, currentUserName, currentSampleStageCount = 0, embedded = false }: { initialItems: SampleProgressDTO[]; currentUserName: string; currentSampleStageCount?: number; embedded?: boolean }) { const [items, setItems] = useState(initialItems) const [keyword, setKeyword] = useState('') const [status, setStatus] = useState('ACTIVE') @@ -36,7 +36,6 @@ export default function SampleProgressClient({ initialItems, currentUserName, em }), [items, keyword, status]) const totalPages = Math.max(1, Math.ceil(filtered.length / PAGE_SIZE)) const rows = filtered.slice((Math.min(page, totalPages) - 1) * PAGE_SIZE, Math.min(page, totalPages) * PAGE_SIZE) - const activeCount = items.filter((item) => !hiddenTerminalStatuses.has(item.status)).length const overdueCount = items.filter(isOverdue).length const statusCounts = SAMPLE_PROGRESS_STATUSES.map((value) => ({ value, count: items.filter((item) => item.status === value).length })) @@ -55,7 +54,7 @@ export default function SampleProgressClient({ initialItems, currentUserName, em
- } label="在管打样" value={`${activeCount} 款`} tone="plain" /> + } label="当前打样节点" value={`${currentSampleStageCount} 款`} tone="plain" /> } label="交期已超期" value={`${overdueCount} 款`} tone={overdueCount ? 'danger' : 'plain'} />
diff --git a/furniture-3d-system/src/app/intake/sample-progress/page.tsx b/furniture-3d-system/src/app/intake/sample-progress/page.tsx index 7891473f..6340f0bd 100644 --- a/furniture-3d-system/src/app/intake/sample-progress/page.tsx +++ b/furniture-3d-system/src/app/intake/sample-progress/page.tsx @@ -6,5 +6,6 @@ export const dynamic = 'force-dynamic' export default async function SampleProgressPage() { const { user } = await requireSession('/login') const items = await sampleProgressService.list() - return + const currentSampleStageCount = await sampleProgressService.countCurrentSampleStage() + return } diff --git a/furniture-3d-system/src/app/sample-progress-preview/page.tsx b/furniture-3d-system/src/app/sample-progress-preview/page.tsx index 1b877483..c9822691 100644 --- a/furniture-3d-system/src/app/sample-progress-preview/page.tsx +++ b/furniture-3d-system/src/app/sample-progress-preview/page.tsx @@ -8,4 +8,4 @@ const samples: SampleProgressDTO[] = [ { id: 'preview-3', openingCode: 'XP202607220009', productDevelopmentFlowUrl: 'https://oa.example.com/product-development/process/XP202607220009', orderDate: '2026-07-22T00:00:00.000Z', sampleDueDate: '2026-08-06T00:00:00.000Z', oaReachedAt: '2026-07-23T01:00:00.000Z', anomaly: 'NONE', imageUrl: null, productSize: '1800 x 400 x 450 mm', color: '深灰', material: '实木多层板 + 岩板', sampleQuantity: 1, brand: '索菲亚', supplier: '嘉兴木业', finalSampleFactory: '嘉兴木业', status: 'COMPLETED', designer: '张凯', purchaseOwner: '孙丽', merchandiserOwner: '方敏', progressDescription: '实物审样通过,打样已完结', requestedCost: 2200, actualCost: 2180, followUpOwner: '孙丽', createdBy: null, updatedBy: null, createdAt: now, updatedAt: now }, ] -export default function SampleProgressPreviewPage() { return } +export default function SampleProgressPreviewPage() { return } diff --git a/furniture-3d-system/src/server/services/sample-progress.service.ts b/furniture-3d-system/src/server/services/sample-progress.service.ts index b9bab2b6..d7dc6d63 100644 --- a/furniture-3d-system/src/server/services/sample-progress.service.ts +++ b/furniture-3d-system/src/server/services/sample-progress.service.ts @@ -100,6 +100,13 @@ const SAMPLE_PROGRESS_SYNC_FLOW_STATUSES = [ 'REFUSED', ] +function isCurrentSampleStage(item: OaBoardProjectListItemDTO) { + if (item.currentStageName?.trim() === '产品打样') return true + return String(item.formSummary.approvalStageDisplay || item.currentApprovalStageName || '') + .split(/[\s,,、;/]+/) + .includes('产品打样') +} + function linkedProductId(workflowLink: string) { try { const segments = new URL(workflowLink).pathname.split('/').filter(Boolean) @@ -206,6 +213,12 @@ export const sampleProgressService = { }) await syncFromOaItems(dashboard.items) }, + async countCurrentSampleStage() { + const dashboard = await oaBoardService.getDashboard({ + overallStatus: SAMPLE_PROGRESS_SYNC_FLOW_STATUSES, + }) + return dashboard.items.filter(isCurrentSampleStage).length + }, async listStored() { return (await sampleProgressRepository.list()).map(serialize) }, async list() { await this.syncFromOaDashboard().catch(() => undefined) From 5318a303465a8ff9dc71443707979decc24d1ff1 Mon Sep 17 00:00:00 2001 From: jingchuan Date: Thu, 13 Aug 2026 10:57:13 +0800 Subject: [PATCH 5/6] fix(sample-progress): align board with current OA stage --- .../src/app/intake/oa-board/OaBoardClient.tsx | 6 ++--- .../src/app/intake/oa-board/page.tsx | 4 ++-- .../sample-progress/SampleProgressClient.tsx | 23 +++++++++++-------- .../src/app/intake/sample-progress/page.tsx | 4 ++-- .../src/app/sample-progress-preview/page.tsx | 2 +- .../services/sample-progress.service.ts | 7 ++++-- 6 files changed, 26 insertions(+), 20 deletions(-) diff --git a/furniture-3d-system/src/app/intake/oa-board/OaBoardClient.tsx b/furniture-3d-system/src/app/intake/oa-board/OaBoardClient.tsx index ce846df6..0a157949 100644 --- a/furniture-3d-system/src/app/intake/oa-board/OaBoardClient.tsx +++ b/furniture-3d-system/src/app/intake/oa-board/OaBoardClient.tsx @@ -3308,13 +3308,13 @@ export default function OaBoardClient({ dashboard, loadErrorMessage, sampleProgressItems = [], - currentSampleStageCount = 0, + currentSampleStageOpeningCodes = [], currentUserName = '', }: { dashboard: OaBoardDashboardDTO loadErrorMessage?: string | null sampleProgressItems?: SampleProgressDTO[] - currentSampleStageCount?: number + currentSampleStageOpeningCodes?: string[] currentUserName?: string }) { const { items: allItems, stageGraph, dailyReport, monthlyReport } = dashboard @@ -4475,7 +4475,7 @@ export default function OaBoardClient({ ) : activeTab === 'brand-planning' ? ( ) : activeTab === 'sample-progress' ? ( - + ) : activeTab === 'timeout-analysis' ? ( ) diff --git a/furniture-3d-system/src/app/intake/sample-progress/SampleProgressClient.tsx b/furniture-3d-system/src/app/intake/sample-progress/SampleProgressClient.tsx index c15aac25..9efd4218 100644 --- a/furniture-3d-system/src/app/intake/sample-progress/SampleProgressClient.tsx +++ b/furniture-3d-system/src/app/intake/sample-progress/SampleProgressClient.tsx @@ -17,10 +17,10 @@ const inputDate = (value: string | Date) => { return Number.isNaN(date.getTime()) ? '' : date.toISOString().slice(0, 10) } -export default function SampleProgressClient({ initialItems, currentUserName, currentSampleStageCount = 0, embedded = false }: { initialItems: SampleProgressDTO[]; currentUserName: string; currentSampleStageCount?: number; embedded?: boolean }) { +export default function SampleProgressClient({ initialItems, currentUserName, currentSampleStageOpeningCodes = [], embedded = false }: { initialItems: SampleProgressDTO[]; currentUserName: string; currentSampleStageOpeningCodes?: string[]; embedded?: boolean }) { const [items, setItems] = useState(initialItems) const [keyword, setKeyword] = useState('') - const [status, setStatus] = useState('ACTIVE') + const [status, setStatus] = useState('CURRENT_STAGE') const [page, setPage] = useState(1) const [editing, setEditing] = useState(null) const [saving, setSaving] = useState(false) @@ -29,15 +29,17 @@ export default function SampleProgressClient({ initialItems, currentUserName, cu const [previewImage, setPreviewImage] = useState(null) const canEdit = (item: SampleProgressDTO) => canEditSampleProgress(currentUserName, item) + const currentStageCodes = useMemo(() => new Set(currentSampleStageOpeningCodes.map((code) => code.trim().toUpperCase())), [currentSampleStageOpeningCodes]) + const currentStageItems = useMemo(() => items.filter((item) => currentStageCodes.has(item.openingCode.trim().toUpperCase())), [currentStageCodes, items]) const filtered = useMemo(() => items.filter((item) => { const haystack = [item.openingCode, item.brand, item.supplier, item.designer, item.purchaseOwner, item.color, item.material].join(' ').toLowerCase() - const statusMatches = status === 'ALL' || (status === 'ACTIVE' ? !hiddenTerminalStatuses.has(item.status) : item.status === status) + const statusMatches = status === 'ALL' || (status === 'CURRENT_STAGE' ? currentStageCodes.has(item.openingCode.trim().toUpperCase()) : item.status === status) return (!keyword || haystack.includes(keyword.toLowerCase())) && statusMatches - }), [items, keyword, status]) + }), [currentStageCodes, items, keyword, status]) const totalPages = Math.max(1, Math.ceil(filtered.length / PAGE_SIZE)) const rows = filtered.slice((Math.min(page, totalPages) - 1) * PAGE_SIZE, Math.min(page, totalPages) * PAGE_SIZE) - const overdueCount = items.filter(isOverdue).length - const statusCounts = SAMPLE_PROGRESS_STATUSES.map((value) => ({ value, count: items.filter((item) => item.status === value).length })) + const overdueCount = currentStageItems.filter(isOverdue).length + const statusCounts = SAMPLE_PROGRESS_STATUSES.map((value) => ({ value, count: currentStageItems.filter((item) => item.status === value).length })) async function remove(item: SampleProgressDTO) { if (!window.confirm(`确认删除 ${item.openingCode} 的打样记录?`)) return @@ -53,12 +55,13 @@ export default function SampleProgressClient({ initialItems, currentUserName, cu -
- } label="当前打样节点" value={`${currentSampleStageCount} 款`} tone="plain" /> +
+ } label="当前打样节点" value={`${currentStageItems.length} 款`} tone="plain" /> } label="交期已超期" value={`${overdueCount} 款`} tone={overdueCount ? 'danger' : 'plain'} /> + } label="OA 台账匹配" value={`${currentStageItems.length} / ${currentStageCodes.size}`} tone={currentStageItems.length === currentStageCodes.size ? 'success' : 'danger'} />
-
+
{statusCounts.map(({ value, count }) => (