diff options
| author | joonhoekim <26rote@gmail.com> | 2025-11-03 19:40:47 +0900 |
|---|---|---|
| committer | joonhoekim <26rote@gmail.com> | 2025-11-03 19:40:47 +0900 |
| commit | 16dcdfe67bd7488a9b2ee1e0389602ec9dd7976b (patch) | |
| tree | 851ffccce5499bb0f9e46755f429d5601d13c637 /lib/vendor-document-list/enhanced-document-service.ts | |
| parent | 6a1740b9f89efe724624e5acfd8588bf42f6c906 (diff) | |
(김준회) dolce: Document Type 옆 숫자: project 필터링 대응하도록 개선
Diffstat (limited to 'lib/vendor-document-list/enhanced-document-service.ts')
| -rw-r--r-- | lib/vendor-document-list/enhanced-document-service.ts | 36 |
1 files changed, 29 insertions, 7 deletions
diff --git a/lib/vendor-document-list/enhanced-document-service.ts b/lib/vendor-document-list/enhanced-document-service.ts index bafa61dc..6f9eda01 100644 --- a/lib/vendor-document-list/enhanced-document-service.ts +++ b/lib/vendor-document-list/enhanced-document-service.ts @@ -1187,14 +1187,34 @@ export async function getDocumentDetails(documentId: number) { // B4 세부 통계 계산 (GTT Deliverable vs SHI Input) const b4Stats = { - gttDeliverableCount: documents.filter(doc => + gttDeliverableCount: documents.filter(doc => doc.drawingKind === 'B4' && doc.drawingMoveGbn === '도면입수' ).length, - shiInputCount: documents.filter(doc => + shiInputCount: documents.filter(doc => doc.drawingKind === 'B4' && doc.drawingMoveGbn === '도면제출' ).length, } + // 🔥 프로젝트별 B4 통계 계산 (전체 개수를 기반으로) + const projectB4StatsMap = new Map<string, { gttDeliverableCount: number, shiInputCount: number }>() + documents.forEach(doc => { + if (doc.drawingKind === 'B4') { + const code = doc.projectCode || 'Unknown' + const current = projectB4StatsMap.get(code) || { gttDeliverableCount: 0, shiInputCount: 0 } + if (doc.drawingMoveGbn === '도면입수') { + current.gttDeliverableCount++ + } else if (doc.drawingMoveGbn === '도면제출') { + current.shiInputCount++ + } + projectB4StatsMap.set(code, current) + } + }) + + // 프로젝트별 B4 통계를 배열로 변환 + const projectB4Stats = Array.from(projectB4StatsMap.entries()) + .sort((a, b) => a[0].localeCompare(b[0])) + .map(([code, stats]) => ({ code, ...stats })) + // 🔥 프로젝트 코드별 통계 계산 const projectCodeMap = new Map<string, number>() documents.forEach(doc => { @@ -1217,15 +1237,17 @@ export async function getDocumentDetails(documentId: number) { primaryDrawingKind: primaryDrawingKind || null, b4Stats, // B4 세부 통계 추가 projectCodeStats, // 🔥 프로젝트 코드 통계 추가 + projectB4Stats, // 🔥 프로젝트별 B4 통계 추가 } } catch (err) { console.error("Error fetching user vendor document stats:", err) - return { - stats: {}, - totalDocuments: 0, - primaryDrawingKind: null, + return { + stats: {}, + totalDocuments: 0, + primaryDrawingKind: null, b4Stats: { gttDeliverableCount: 0, shiInputCount: 0 }, - projectCodeStats: [] + projectCodeStats: [], + projectB4Stats: [] } } } |
