외주가공발주서 pdf 첨부 오류 수정

This commit is contained in:
2026-01-27 18:02:13 +09:00
parent 677e4342af
commit 8c287e714c

View File

@@ -3007,11 +3007,30 @@ public class PurchaseOrderService {
masterInfo.put("EXCELFILE_NAME", excelName);
masterInfo.put("APPR_COMPLETE_DATE", frm2.format(cal.getTime()));
// 발주서 테이블 내용 생성
String contents_table = this.makePoContentsTable(masterInfo, detailList, apprList, multiMasterList);
// pdfSessionId 확인 (PDF 첨부 여부 결정)
String pdfSessionId = CommonUtils.checkNull(paramMap.get("pdfSessionId"));
boolean isPdfAttach = false;
// 메일 본문 생성 (사용자 입력 내용 + 발주서 테이블)
String mailContents = this.makeMailContentsWithUserInput(contents, contents_table);
// PDF 파일 존재 여부 확인
if(!"".equals(pdfSessionId)) {
String tempDir = System.getProperty("java.io.tmpdir");
File pdfFile = new File(tempDir + File.separator + pdfSessionId + ".pdf");
isPdfAttach = pdfFile.exists();
}
// 발주서 테이블 내용 생성 (PDF 첨부 시에는 사용하지 않음)
String contents_table = "";
if(!isPdfAttach) {
contents_table = this.makePoContentsTable(masterInfo, detailList, apprList, multiMasterList);
}
// 메일 본문 생성 (PDF 첨부 시에는 사용자 입력 내용만, 아니면 테이블 포함)
String mailContents = "";
if(isPdfAttach) {
mailContents = this.makeMailContentsWithoutTable(contents);
} else {
mailContents = this.makeMailContentsWithUserInput(contents, contents_table);
}
// 수신인 이메일 목록 생성
ArrayList<String> toUserIdList = new ArrayList<String>();
@@ -3044,10 +3063,26 @@ public class PurchaseOrderService {
// 첨부파일 목록 생성
ArrayList<HashMap> attachFileList = new ArrayList<HashMap>();
// 1. 발주서 엑셀 파일 첨부
HashMap excelFile = this.makeMailAttachFileOrderSheet(masterInfo, contents_table);
if(excelFile != null) {
attachFileList.add(excelFile);
// 1. 발주서 첨부 (PDF 또는 엑셀)
if(isPdfAttach) {
// PDF 파일 첨부
String tempDir = System.getProperty("java.io.tmpdir");
File pdfFile = new File(tempDir + File.separator + pdfSessionId + ".pdf");
String pdfFileName = "발주서_" + poNo + "_" + todayKor + ".pdf";
HashMap pdfFileMap = new HashMap();
pdfFileMap.put(Constants.Db.COL_FILE_REAL_NAME, pdfFileName);
pdfFileMap.put(Constants.Db.COL_FILE_SAVED_NAME, pdfFile.getName());
pdfFileMap.put(Constants.Db.COL_FILE_PATH, tempDir);
attachFileList.add(pdfFileMap);
System.out.println("발주서 PDF 첨부 완료: " + pdfFile.getAbsolutePath());
} else {
// 엑셀 파일 첨부 (PDF 없을 때)
HashMap excelFile = this.makeMailAttachFileOrderSheet(masterInfo, contents_table);
if(excelFile != null) {
attachFileList.add(excelFile);
}
}
// 2. 도면 파일 압축 첨부 (includeDrawingFiles가 Y인 경우에만)
@@ -3108,6 +3143,36 @@ public class PurchaseOrderService {
return resultMap;
}
/**
* 사용자 입력 내용만으로 메일 본문 생성 (PDF 첨부 시 테이블 없이)
* @param userContents 사용자가 입력한 메일 내용
* @return 완성된 메일 본문
*/
private String makeMailContentsWithoutTable(String userContents) {
StringBuffer sb = new StringBuffer();
sb.append("<!DOCTYPE html><html lang='ko' dir='ltr'>");
sb.append("<head>");
sb.append(" <meta http-equiv='Content-Type' content='text/html; charset=euc-kr'>");
sb.append(" <style>");
sb.append(" @import url(http://fonts.googleapis.com/earlyaccess/notosanskr.css);");
sb.append(" @import url(https://fonts.googleapis.com/css?family=Roboto:100,300,500,500,700,900);");
sb.append(" body {font-family: 'Noto Sans KR', sans-serif; background: #fff; width: 100%; position:relative;}");
sb.append(" </style>");
sb.append("</head>");
sb.append("<body style='margin:0; padding:20px;'>");
// 사용자 입력 내용 (줄바꿈을 <br>로 변환)
sb.append("<div style='white-space: pre-line;'>");
sb.append(userContents.replace("\n", "<br>"));
sb.append("</div>");
sb.append("<div style='margin-top: 20px; color: #666;'>※ 발주서는 첨부파일(PDF)을 확인해주세요.</div>");
sb.append("</body>");
sb.append("</html>");
return sb.toString();
}
/**
* 사용자 입력 내용과 발주서 테이블을 합친 메일 본문 생성
* @param userContents 사용자가 입력한 메일 내용