fix: 구매신청 엑셀 수량 표시 개선 및 FLANGE 품목명 개선

- 구매신청 관리 페이지 수량을 정수로 표시 (3.000 EA → 3 EA)
- JSON 저장 시 수량 정수 변환
- FLANGE 품목명 세분화: WN RF, SO RF, ORIFICE FLANGE, SPECTACLE BLIND 등
- 구매관리 페이지 엑셀 다운로드 데이터 구조 개선
- 디버그 로그 추가
This commit is contained in:
Hyungi Ahn
2025-10-14 15:29:01 +09:00
parent 5a21ef8f6c
commit 72126ef78d
8 changed files with 2640 additions and 3528 deletions

View File

@@ -157,7 +157,59 @@ const formatMaterialForExcel = (material, includeComparison = false) => {
} else if (category === 'FITTING') {
itemName = material.fitting_details?.fitting_type || 'FITTING';
} else if (category === 'FLANGE') {
itemName = 'FLANGE';
// 플랜지 타입 추출
const desc = cleanDescription.toUpperCase();
console.log('🔍 FLANGE 품목명 추출:', cleanDescription);
if (material.flange_details) {
console.log(' flange_details:', material.flange_details);
const flangeType = material.flange_details.flange_type || '';
const originalFlangeType = material.flange_details.original_flange_type || '';
const facingType = material.flange_details.facing_type || '';
// 특수 플랜지 타입 우선
if (desc.includes('ORIFICE')) {
itemName = 'ORIFICE FLANGE';
} else if (desc.includes('SPECTACLE')) {
itemName = 'SPECTACLE BLIND';
} else if (desc.includes('PADDLE')) {
itemName = 'PADDLE BLIND';
} else if (desc.includes('SPACER')) {
itemName = 'SPACER';
} else if (desc.includes('BLIND')) {
itemName = 'BLIND FLANGE';
} else {
// 일반 플랜지: flange_type 사용 (WN RF, SO RF 등)
itemName = flangeType || 'FLANGE';
}
} else {
console.log(' flange_details 없음, description에서 추출');
// flange_details가 없으면 description에서 추출
if (desc.includes('ORIFICE')) {
itemName = 'ORIFICE FLANGE';
} else if (desc.includes('SPECTACLE') || desc.includes('SPEC')) {
itemName = 'SPECTACLE BLIND';
} else if (desc.includes('PADDLE')) {
itemName = 'PADDLE BLIND';
} else if (desc.includes('SPACER')) {
itemName = 'SPACER';
} else if (desc.includes('BLIND')) {
itemName = 'BLIND FLANGE';
} else if (desc.includes(' SW') || desc.includes(',SW') || desc.includes(', SW')) {
itemName = 'FLANGE SW';
} else if (desc.includes(' BW') || desc.includes(',BW') || desc.includes(', BW')) {
itemName = 'FLANGE BW';
} else if (desc.includes('RTJ')) {
itemName = 'FLANGE RTJ';
} else if (desc.includes(' FF') || desc.includes('FULL FACE')) {
itemName = 'FLANGE FF';
} else if (desc.includes(' RF') || desc.includes('RAISED')) {
itemName = 'FLANGE RF';
} else {
itemName = 'FLANGE';
}
}
console.log(' → 품목명:', itemName);
} else if (category === 'VALVE') {
itemName = 'VALVE';
} else if (category === 'GASKET') {
@@ -494,19 +546,27 @@ const formatMaterialForExcel = (material, includeComparison = false) => {
*/
export const exportMaterialsToExcel = (materials, filename, additionalInfo = {}) => {
try {
console.log('🔧 exportMaterialsToExcel 시작:', materials.length, '개 자재');
// 카테고리별로 그룹화
const categoryGroups = groupMaterialsByCategory(materials);
console.log('📁 카테고리별 그룹:', Object.keys(categoryGroups).map(k => `${k}: ${categoryGroups[k].length}`));
// 전체 자재 합치기 (먼저 계산)
const consolidatedMaterials = consolidateMaterials(materials);
console.log('📦 합쳐진 자재:', consolidatedMaterials.length, '개');
// 새 워크북 생성
const workbook = XLSX.utils.book_new();
// 카테고리별 시트 생성 (합쳐진 자재)
Object.entries(categoryGroups).forEach(([category, items]) => {
console.log(`📄 ${category} 시트 생성 중... (${items.length}개 자재)`);
const consolidatedItems = consolidateMaterials(items);
console.log(` → 합쳐진 결과: ${consolidatedItems.length}`);
const formattedItems = consolidatedItems.map(material => formatMaterialForExcel(material));
console.log(` → 포맷 완료: ${formattedItems.length}`);
if (formattedItems.length > 0) {
const categorySheet = XLSX.utils.json_to_sheet(formattedItems);