포맷파일 로드 방식 변경

main
이범준 1 year ago
parent f31bdf8007
commit 0bdcb9ff39

@ -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<String, String> 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<String> strings = new ArrayList<String>();
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("한글 파일 출력 중 오류가 발생하였습니다.");
}

Loading…
Cancel
Save