From 0bdcb9ff39d830a247b6240d17463aa136867523 Mon Sep 17 00:00:00 2001 From: leebeomjun Date: Thu, 14 Sep 2023 10:51:11 +0900 Subject: [PATCH] =?UTF-8?q?=ED=8F=AC=EB=A7=B7=ED=8C=8C=EC=9D=BC=20?= =?UTF-8?q?=EB=A1=9C=EB=93=9C=20=EB=B0=A9=EC=8B=9D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/bean/CrdnCvlcptServiceBean.java | 30 ++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/src/main/java/cokr/xit/fims/cvlc/service/bean/CrdnCvlcptServiceBean.java b/src/main/java/cokr/xit/fims/cvlc/service/bean/CrdnCvlcptServiceBean.java index 2a60d934..f3324075 100644 --- a/src/main/java/cokr/xit/fims/cvlc/service/bean/CrdnCvlcptServiceBean.java +++ b/src/main/java/cokr/xit/fims/cvlc/service/bean/CrdnCvlcptServiceBean.java @@ -1,6 +1,7 @@ package cokr.xit.fims.cvlc.service.bean; import java.io.File; +import java.io.InputStream; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Arrays; @@ -12,8 +13,8 @@ import java.util.stream.Collectors; import javax.annotation.Resource; +import org.springframework.core.io.ClassPathResource; import org.springframework.stereotype.Service; -import org.springframework.util.ResourceUtils; import cokr.xit.base.file.FileInfo; import cokr.xit.base.file.service.FileQuery; @@ -119,8 +120,8 @@ public class CrdnCvlcptServiceBean extends AbstractServiceBean implements CrdnCv @Override public Map makeFileFromHwpFormat(CrdnQuery query) { - String baseFormatFilePath = ("classpath:format/cvlcptOrgnl_text.hwp"); - String attachFormatFilePath = ("classpath:format/cvlcptOrgnl_photo.hwp"); + String baseFormatFilePath = ("format/cvlcptOrgnl_text.hwp"); + String attachFormatFilePath = ("format/cvlcptOrgnl_photo.hwp"); DataObject dataObject = crdnCvlcptMainBean.getCivilComplaintOriginalInfo(query); SimpleDateFormat ymdhmsFormat = new SimpleDateFormat("yyyyMMddHHmmss"); @@ -128,11 +129,13 @@ public class CrdnCvlcptServiceBean extends AbstractServiceBean implements CrdnCv SimpleDateFormat ymdHypenFormat = new SimpleDateFormat("yyyy-MM-dd"); try { + System.out.println("서식파일 파일객체 로드"); + InputStream baseFormatIS = new ClassPathResource(baseFormatFilePath).getInputStream(); - File file = ResourceUtils.getFile(baseFormatFilePath); - - HWPFile baseFormatFile = HWPReader.fromFile(file); + System.out.println("서식파일 hwp파일객체 로드"); + HWPFile baseFormatFile = HWPReader.fromInputStream(baseFormatIS); + System.out.println("누름틀 값 매핑"); ArrayList strings = new ArrayList(); strings.add(dataObject.string("CVLCPT_APLCNT_NM")); FieldFinder.setClickHereText(baseFormatFile, "신청자", strings); @@ -172,18 +175,23 @@ public class CrdnCvlcptServiceBean extends AbstractServiceBean implements CrdnCv String formatFileResultFolderPath = formatFileResultRootPath + File.separator + year + File.separator + month + File.separator + day; + System.out.println("결과파일 객체 생성"); File formatFileResultFolder = new File(formatFileResultFolderPath); + + System.out.println("폴더생성"); if(!formatFileResultFolder.exists()) { formatFileResultFolder.mkdirs(); } String resultHwpPath = formatFileResultFolderPath + File.separator + currentTime + ".hwp"; + System.out.println("결과파일 쓰기"); HWPWriter.toFile(baseFormatFile, resultHwpPath); + System.out.println("결과파일 읽기"); HWPFile resultFile = HWPReader.fromFile(resultHwpPath); String linkTblNm = dataObject.string("LINK_TBL_NM"); - if(!linkTblNm.equals("")) { + if(!(ifEmpty(linkTblNm, () -> "").equals(""))) { FileQuery fileQuery = new FileQuery(); if(linkTblNm.equals("TB_ESB_INTERFACE")) { @@ -208,8 +216,9 @@ public class CrdnCvlcptServiceBean extends AbstractServiceBean implements CrdnCv int PHOTO_COUNT_PER_PAGE = 4; for(int i=0; i < photoCnt; i += PHOTO_COUNT_PER_PAGE) { - file = ResourceUtils.getFile(attachFormatFilePath); - HWPFile attachFormatFile = HWPReader.fromFile(file); + + InputStream attachFormatIS = new ClassPathResource(attachFormatFilePath).getInputStream(); + HWPFile attachFormatFile = HWPReader.fromInputStream(attachFormatIS); InsertingImageCell.IMPL_InsertPicture(attachFormatFile, "왼쪽위사진", fileInfoList.get(i).string("URL")); if(i+1 < photoCnt) InsertingImageCell.IMPL_InsertPicture(attachFormatFile, "오른쪽위사진", fileInfoList.get(i+1).string("URL")); @@ -233,7 +242,8 @@ public class CrdnCvlcptServiceBean extends AbstractServiceBean implements CrdnCv return result; } catch (Exception e) { - e.printStackTrace(); + System.out.println("에러출력"); + System.out.println(e.toString()); throw new RuntimeException("한글 파일 출력 중 오류가 발생하였습니다."); }