From d38244b1b384d893804fb33b2f81cfde02c8a6e9 Mon Sep 17 00:00:00 2001 From: leebeomjun Date: Mon, 19 Feb 2024 16:26:09 +0900 Subject: [PATCH] =?UTF-8?q?=ED=95=9C=EA=B8=80=ED=8C=8C=EC=9D=BC=20?= =?UTF-8?q?=EB=8B=A4=EC=9A=B4=EB=A1=9C=EB=93=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cokr/xit/base/file/hwp/HWPWriter.java | 130 ++++++++++++ .../cokr/xit/base/file/pdf/PDFWriter.java | 5 + .../fims/cmmn/{PrintUtil.java => Print.java} | 52 ++++- .../xit/fims/cmmn/hwp/HWPFormatWriter.java | 35 ---- .../xit/fims/cmmn/hwp/format/CrdnConfirm.java | 45 +++-- .../xit/fims/cmmn/hwp/format/CrdnList.java | 50 ++--- .../xit/fims/cmmn/hwp/format/CvlcptOrgn.java | 95 +++++++++ .../fims/cmmn/hwp/format/DlbrDecsnList.java | 41 ++-- .../HWPFormat.java} | 69 ++++--- .../fims/cmmn/hwp/format/RcvmtConfirm.java | 47 ++--- .../fims/cmmn/hwp/format/ReportOnClaims.java | 48 ++--- .../cmmn/hwp/format/RequestForDelivery.java | 48 ++--- .../xit/fims/cmmn/hwp/format/SvbtcList.java | 41 ++-- .../cmmn/pdf/extration/PDFExtractionUtil.java | 4 +- .../xit/fims/cmmn/pdf/print/PDFPrintUtil.java | 13 +- .../fims/cvlc/service/CrdnCvlcptService.java | 9 - .../service/bean/CrdnCvlcptServiceBean.java | 140 ------------- .../xit/fims/cvlc/web/Cvlc01Controller.java | 62 +++++- .../fims/excl/service/OpnnSbmsnService.java | 12 +- .../service/bean/OpnnSbmsnServiceBean.java | 96 --------- .../xit/fims/excl/web/Excl02Controller.java | 26 ++- .../xit/fims/sndb/service/SvbtcService.java | 12 +- .../sndb/service/bean/SvbtcServiceBean.java | 118 +---------- .../xit/fims/sndb/web/Sndb01Controller.java | 27 ++- .../service/IntegrationSearchService.java | 9 - .../bean/IntegrationSearchServiceBean.java | 185 ------------------ .../xit/fims/sprt/web/Sprt01Controller.java | 137 ++++++++++++- .../WEB-INF/jsp/fims/sprt/sprt01110-info.jsp | 20 +- 28 files changed, 734 insertions(+), 842 deletions(-) create mode 100644 src/main/java/cokr/xit/base/file/hwp/HWPWriter.java create mode 100644 src/main/java/cokr/xit/base/file/pdf/PDFWriter.java rename src/main/java/cokr/xit/fims/cmmn/{PrintUtil.java => Print.java} (74%) delete mode 100644 src/main/java/cokr/xit/fims/cmmn/hwp/HWPFormatWriter.java create mode 100644 src/main/java/cokr/xit/fims/cmmn/hwp/format/CvlcptOrgn.java rename src/main/java/cokr/xit/fims/cmmn/hwp/{HWPPrintUtil.java => format/HWPFormat.java} (72%) diff --git a/src/main/java/cokr/xit/base/file/hwp/HWPWriter.java b/src/main/java/cokr/xit/base/file/hwp/HWPWriter.java new file mode 100644 index 00000000..1a37bed4 --- /dev/null +++ b/src/main/java/cokr/xit/base/file/hwp/HWPWriter.java @@ -0,0 +1,130 @@ +package cokr.xit.base.file.hwp; + +import java.io.File; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.springframework.core.io.ClassPathResource; + +import cokr.xit.fims.cmmn.Print; +import cokr.xit.fims.cmmn.hwp.AddUtil; +import cokr.xit.fims.cmmn.hwp.format.HWPFormat; +import cokr.xit.fims.sprt.PrintOption; +import cokr.xit.foundation.UserInfo; +import cokr.xit.foundation.data.DataObject; +import kr.dogfoot.hwplib.object.HWPFile; +import kr.dogfoot.hwplib.reader.HWPReader; + +public class HWPWriter { + protected Print print; + protected HWPFormat format; + + protected UserInfo printRequestUserInfo; + + public void setPrintRequestUserInfo(UserInfo printRequestUserInfo) { + this.printRequestUserInfo = printRequestUserInfo; + }; + public UserInfo getPrintRequestUserInfo() { + return this.printRequestUserInfo; + }; + public HWPFormat setFormat(HWPFormat format) { + return this.format = format; + }; + + public Map makeFileFromHwpFormat(String formatType, Print print, PrintOption printOption, List dataObjectList) { + Map result = new HashMap<>(); + + this.print = new Print(); + this.format.setting(print); + + + int totalDataCount = dataObjectList.size(); + List partFileList = new ArrayList<>(); + this.format.calcTotalPartFileCount(totalDataCount); + + + try { + + int dataIndex = 0; + for(int partFileIndex = 0; partFileIndex < this.format.getTotalPartFileCount(); partFileIndex++) { + + //새 파일 생성 + String resultHwpPath = this.format.newFileFromFormatFile(print); + HWPFile resultFile = HWPReader.fromFile(resultHwpPath); + + //공통사항 세팅 + this.format.writeGlobalInfo(resultFile, dataObjectList, printOption, print); + + kr.dogfoot.hwplib.writer.HWPWriter.toFile(resultFile, resultHwpPath); + + //데이터 건별 처리 + for(int recordIndex = 0; recordIndex < this.format.getRecordPerPartFile(); recordIndex++) { + if(dataIndex < dataObjectList.size()) { + DataObject dataObject = dataObjectList.get(dataIndex); + + if(formatType.equals("list")) { + InputStream attachFormatIS = new ClassPathResource(this.format.getAttachFormatFilePath()).getInputStream(); + HWPFile attachFormatFile = HWPReader.fromInputStream(attachFormatIS); + + this.format.writeSingleDataInfo(null, attachFormatFile, dataObject, print); + + AddUtil.insertTableInCell(attachFormatFile, resultFile, "내부"); + + } else if(formatType.equals("info")){ + + this.format.writeSingleDataInfo(resultFile, null, dataObject, print); + } + + } + + if(formatType.equals("list")) { + dataIndex++; + } + + } + + if(!formatType.equals("list")) { + dataIndex++; + } + + kr.dogfoot.hwplib.writer.HWPWriter.toFile(resultFile, resultHwpPath); + partFileList.add(resultHwpPath); + } + + //결과파일 병합 + if(partFileList.size() >= 2) { + String basePath = partFileList.get(0); + HWPFile baseFile = HWPReader.fromFile(basePath); + + + for(int i=2; i <= partFileList.size();i++) { + String attachPath = partFileList.get(i-1); + HWPFile attachFile = HWPReader.fromFile(attachPath); + AddUtil.appendToLast(attachFile, baseFile); + } + + kr.dogfoot.hwplib.writer.HWPWriter.toFile(baseFile, basePath); + + for(int i=2; i <= partFileList.size();i++) { + (new File(partFileList.get(i-1))).delete(); + } + } + + String downlaodFileName = print.getFormatKorName()+"_"+print.getPrintRequestDt()+".hwp"; + result.put("filename", downlaodFileName); + String filePath = partFileList.get(0); + result.put("filePath", filePath); + result.put("file", new File(filePath)); + + } catch (Exception e) { + e.printStackTrace(); + throw new RuntimeException("한글 파일 출력 중 오류가 발생하였습니다."); + + } + + return result; + } +} diff --git a/src/main/java/cokr/xit/base/file/pdf/PDFWriter.java b/src/main/java/cokr/xit/base/file/pdf/PDFWriter.java new file mode 100644 index 00000000..1b1a097c --- /dev/null +++ b/src/main/java/cokr/xit/base/file/pdf/PDFWriter.java @@ -0,0 +1,5 @@ +package cokr.xit.base.file.pdf; + +public class PDFWriter { + +} diff --git a/src/main/java/cokr/xit/fims/cmmn/PrintUtil.java b/src/main/java/cokr/xit/fims/cmmn/Print.java similarity index 74% rename from src/main/java/cokr/xit/fims/cmmn/PrintUtil.java rename to src/main/java/cokr/xit/fims/cmmn/Print.java index 6ef4fbbe..1d129fe7 100644 --- a/src/main/java/cokr/xit/fims/cmmn/PrintUtil.java +++ b/src/main/java/cokr/xit/fims/cmmn/Print.java @@ -10,34 +10,66 @@ import cokr.xit.fims.sprt.PrintOption; import cokr.xit.foundation.UserInfo; import cokr.xit.foundation.data.DataObject; -public class PrintUtil { +public class Print { - public PrintUtil(){ + public Print(){ SimpleDateFormat ymdhmsFormat = new SimpleDateFormat("yyyyMMddHHmmss"); this.printRequestDt = ymdhmsFormat.format(new Date()); } - protected int fileNameIndex = 0; - protected String printRequestDt; protected UserInfo printRequestUserInfo; - public String getPrintRequestDt() { - return this.printRequestDt; + protected int fileNameIndex = 0; + + private String formatName; + + private String formatKorName; + + + public String getFormatName() { + return this.formatName; } - public void setPrintRequestDt(String printRequestDt) { - this.printRequestDt = printRequestDt; + public void setFormatName(String formatName) { + this.formatName = formatName; + } + + public String getFormatKorName() { + return this.formatKorName; + } + + public void setFormatKorName(String formatKorName) { + this.formatKorName = formatKorName; } public UserInfo getPrintRequestUserInfo() { return this.printRequestUserInfo; - }; + } public void setPrintRequestUserInfo(UserInfo printRequestUserInfo) { this.printRequestUserInfo = printRequestUserInfo; - }; + } + + public String getPrintRequestDt() { + return this.printRequestDt; + } + + public void setPrintRequestDt(String printRequestDt) { + this.printRequestDt = printRequestDt; + } + + + public int getFileNameIndex() { + return this.fileNameIndex; + } + public int setFileNameIndex(int fileNameIndex) { + return this.fileNameIndex = fileNameIndex; + } + + + public float mmToPt(float mm) { return mm * 2.83465f; diff --git a/src/main/java/cokr/xit/fims/cmmn/hwp/HWPFormatWriter.java b/src/main/java/cokr/xit/fims/cmmn/hwp/HWPFormatWriter.java deleted file mode 100644 index 6debbd5e..00000000 --- a/src/main/java/cokr/xit/fims/cmmn/hwp/HWPFormatWriter.java +++ /dev/null @@ -1,35 +0,0 @@ -package cokr.xit.fims.cmmn.hwp; - -import java.util.List; - -import cokr.xit.fims.sprt.PrintOption; -import cokr.xit.foundation.data.DataObject; -import kr.dogfoot.hwplib.object.HWPFile; - -public interface HWPFormatWriter { - - - - /** 포맷 형식별 기초 설정 적용. - * @param hwpPrintUtil - * @return - */ - void setting(HWPPrintUtil hwpPrintUtil); - - void setting(HWPPrintUtil hwpPrintUtil, int cnt); - - /** 한글파일 공통사항 적용 - * @param - * @return - */ - void writeGlobalInfo(HWPFile baseFile, List dataObjectList, - PrintOption printOption, HWPPrintUtil hwpPrintUtil); - - /** 데이터 건별 한글파일 처리 - * @param - * @return - */ - void writeSingleDataInfo(HWPFile baseFile, HWPFile attachFile, DataObject dataObject, - HWPPrintUtil hwpPrintUtil); - -} diff --git a/src/main/java/cokr/xit/fims/cmmn/hwp/format/CrdnConfirm.java b/src/main/java/cokr/xit/fims/cmmn/hwp/format/CrdnConfirm.java index d94c4841..c6931997 100644 --- a/src/main/java/cokr/xit/fims/cmmn/hwp/format/CrdnConfirm.java +++ b/src/main/java/cokr/xit/fims/cmmn/hwp/format/CrdnConfirm.java @@ -3,9 +3,8 @@ package cokr.xit.fims.cmmn.hwp.format; import java.util.List; import cokr.xit.fims.cmmn.CmmnUtil; +import cokr.xit.fims.cmmn.Print; import cokr.xit.fims.cmmn.hwp.ClickHereEditor; -import cokr.xit.fims.cmmn.hwp.HWPFormatWriter; -import cokr.xit.fims.cmmn.hwp.HWPPrintUtil; import cokr.xit.fims.cmmn.hwp.InsertingImageCell; import cokr.xit.fims.mngt.FactionUtil; import cokr.xit.fims.sprt.PrintOption; @@ -15,40 +14,44 @@ import kr.dogfoot.hwplib.object.HWPFile; /** * 단속확인서 */ -public class CrdnConfirm implements HWPFormatWriter { +public class CrdnConfirm extends HWPFormat { + @Override - public void setting(HWPPrintUtil hwpPrintUtil) { - hwpPrintUtil.setFormatName("crdnConfirm"); - hwpPrintUtil.setFormatKorName("단속확인서"); + public void setting(Print print) { + print.setFormatName("crdnConfirm"); + print.setFormatKorName("단속확인서"); - hwpPrintUtil.setFormatType("info"); - hwpPrintUtil.setRecordPerPartFile(1); + this.setFormatType("info"); + this.setRecordPerPartFile(1); - hwpPrintUtil.setBaseFormatFilePath("template/hwp/crdnConfirm.hwp"); - hwpPrintUtil.setAttachFormatFilePath(""); + this.setBaseFormatFilePath("template/hwp/crdnConfirm.hwp"); + this.setAttachFormatFilePath(""); } + @Override - public void setting(HWPPrintUtil hwpPrintUtil, int recordCnt) { - hwpPrintUtil.setFormatName("crdnConfirm"); - hwpPrintUtil.setFormatKorName("단속확인서"); + public void setting(Print print, int recordCnt) { + print.setFormatName("crdnConfirm"); + print.setFormatKorName("단속확인서"); - hwpPrintUtil.setFormatType("info"); - hwpPrintUtil.setRecordPerPartFile(recordCnt); + this.setFormatType("info"); + this.setRecordPerPartFile(recordCnt); - hwpPrintUtil.setBaseFormatFilePath("template/hwp/crdnConfirm.hwp"); - hwpPrintUtil.setAttachFormatFilePath(""); + this.setBaseFormatFilePath("template/hwp/crdnConfirm.hwp"); + this.setAttachFormatFilePath(""); } + @Override public void writeGlobalInfo(HWPFile baseFile, List dataObjectList, PrintOption printOption, - HWPPrintUtil hwpPrintUtil) { + Print print) { } + @Override public void writeSingleDataInfo(HWPFile baseFile, HWPFile attachFile, - DataObject dataObject, HWPPrintUtil hwpPrintUtil) { + DataObject dataObject, Print print) { ClickHereEditor baseFileEditor = new ClickHereEditor(baseFile); @@ -66,14 +69,14 @@ public class CrdnConfirm implements HWPFormatWriter { baseFileEditor.set("주소", dataObject.string("RTPYR_FULL_ADDR")); baseFileEditor.set("우편번호", dataObject.string("RTPYR_ZIP")); - String printRequestYmd = hwpPrintUtil.getPrintRequestDt().substring(0, 8); + String printRequestYmd = print.getPrintRequestDt().substring(0, 8); String yyyy = printRequestYmd.substring(0, 4); String mm = printRequestYmd.substring(4, 6); String dd = printRequestYmd.substring(6, 8); String ymd = yyyy+"년 "+mm+"월 "+dd+"일"; baseFileEditor.set("연월일", ymd); - String instNm = (String) hwpPrintUtil.getPrintRequestUserInfo().getInfo().get("instNm"); + String instNm = (String) print.getPrintRequestUserInfo().getInfo().get("instNm"); instNm = FactionUtil.getInstituteLeader(instNm, false); baseFileEditor.set("발신", instNm); diff --git a/src/main/java/cokr/xit/fims/cmmn/hwp/format/CrdnList.java b/src/main/java/cokr/xit/fims/cmmn/hwp/format/CrdnList.java index 08112658..681a8168 100644 --- a/src/main/java/cokr/xit/fims/cmmn/hwp/format/CrdnList.java +++ b/src/main/java/cokr/xit/fims/cmmn/hwp/format/CrdnList.java @@ -3,9 +3,8 @@ package cokr.xit.fims.cmmn.hwp.format; import java.util.List; import cokr.xit.fims.cmmn.CmmnUtil; +import cokr.xit.fims.cmmn.Print; import cokr.xit.fims.cmmn.hwp.ClickHereEditor; -import cokr.xit.fims.cmmn.hwp.HWPFormatWriter; -import cokr.xit.fims.cmmn.hwp.HWPPrintUtil; import cokr.xit.fims.mngt.FactionUtil; import cokr.xit.fims.sprt.PrintOption; import cokr.xit.foundation.data.DataFormat; @@ -15,36 +14,38 @@ import kr.dogfoot.hwplib.object.HWPFile; /** * 단속내역서 */ -public class CrdnList implements HWPFormatWriter { +public class CrdnList extends HWPFormat { + @Override - public void setting(HWPPrintUtil hwpPrintUtil) { - hwpPrintUtil.setFormatName("crdnList"); - hwpPrintUtil.setFormatKorName("단속내역서"); + public void setting(Print print) { + print.setFormatName("crdnList"); + print.setFormatKorName("단속내역서"); - hwpPrintUtil.setFormatType("list"); - hwpPrintUtil.setRecordPerPartFile(6); + this.setFormatType("list"); + this.setRecordPerPartFile(6); - hwpPrintUtil.setBaseFormatFilePath("template/hwp/crdnList_root.hwp"); - hwpPrintUtil.setAttachFormatFilePath("template/hwp/crdnList_inner.hwp"); + this.setBaseFormatFilePath("template/hwp/crdnList_root.hwp"); + this.setAttachFormatFilePath("template/hwp/crdnList_inner.hwp"); } + @Override - public void setting(HWPPrintUtil hwpPrintUtil, int recordCnt) { - hwpPrintUtil.setFormatName("crdnList"); - hwpPrintUtil.setFormatKorName("단속내역서"); + public void setting(Print print, int recordCnt) { + print.setFormatName("crdnList"); + print.setFormatKorName("단속내역서"); - hwpPrintUtil.setFormatType("list"); - hwpPrintUtil.setRecordPerPartFile(recordCnt); + this.setFormatType("list"); + this.setRecordPerPartFile(recordCnt); - hwpPrintUtil.setBaseFormatFilePath("template/hwp/crdnList_root.hwp"); - hwpPrintUtil.setAttachFormatFilePath("template/hwp/crdnList_inner.hwp"); + this.setBaseFormatFilePath("template/hwp/crdnList_root.hwp"); + this.setAttachFormatFilePath("template/hwp/crdnList_inner.hwp"); } + @Override public void writeGlobalInfo(HWPFile baseFile, List dataObjectList, - PrintOption printOption, HWPPrintUtil hwpPrintUtil - ) { + PrintOption printOption, Print print) { ClickHereEditor baseFileEditor = new ClickHereEditor(baseFile); @@ -55,26 +56,27 @@ public class CrdnList implements HWPFormatWriter { //상단 baseFileEditor.set("성명", globalRtpyrNm); - if(hwpPrintUtil.getPrivateInfoYn(printOption)) { + if(print.getPrivateInfoYn(printOption)) { baseFileEditor.set("주민번호", globalRtpyrNo); } else { baseFileEditor.set("주민번호", "*************"); } baseFileEditor.set("주소", globalRtpyrFullAddr); - baseFileEditor.set("총건수", CmmnUtil.addCommaToNumber(hwpPrintUtil.getTotalDataCount(dataObjectList))); + baseFileEditor.set("총건수", CmmnUtil.addCommaToNumber(print.getTotalDataCount(dataObjectList))); baseFileEditor.set("총금액", CmmnUtil.addCommaToNumber(globalTotalAmount)); - baseFileEditor.set("출력일시", CmmnUtil.yyyy_mm_dd_hh_mm_ss(hwpPrintUtil.getPrintRequestDt())); + baseFileEditor.set("출력일시", CmmnUtil.yyyy_mm_dd_hh_mm_ss(print.getPrintRequestDt())); - String instNm = (String) hwpPrintUtil.getPrintRequestUserInfo().getInfo().get("instNm"); + String instNm = (String) print.getPrintRequestUserInfo().getInfo().get("instNm"); instNm = FactionUtil.getLastWord(instNm); instNm = FactionUtil.getInstituteLeader(instNm, false); baseFileEditor.set("발신", instNm); } + @Override public void writeSingleDataInfo(HWPFile baseFile, HWPFile attachFile, - DataObject dataObject, HWPPrintUtil hwpPrintUtil) { + DataObject dataObject, Print print) { ClickHereEditor attachFileEditor = new ClickHereEditor(attachFile); diff --git a/src/main/java/cokr/xit/fims/cmmn/hwp/format/CvlcptOrgn.java b/src/main/java/cokr/xit/fims/cmmn/hwp/format/CvlcptOrgn.java new file mode 100644 index 00000000..9057b0bc --- /dev/null +++ b/src/main/java/cokr/xit/fims/cmmn/hwp/format/CvlcptOrgn.java @@ -0,0 +1,95 @@ +package cokr.xit.fims.cmmn.hwp.format; + +import java.io.InputStream; +import java.util.List; + +import org.springframework.core.io.ClassPathResource; + +import cokr.xit.fims.cmmn.CmmnUtil; +import cokr.xit.fims.cmmn.Print; +import cokr.xit.fims.cmmn.hwp.AddUtil; +import cokr.xit.fims.cmmn.hwp.ClickHereEditor; +import cokr.xit.fims.cmmn.hwp.InsertingImageCell; +import cokr.xit.fims.sprt.PrintOption; +import cokr.xit.foundation.data.DataFormat; +import cokr.xit.foundation.data.DataObject; +import kr.dogfoot.hwplib.object.HWPFile; +import kr.dogfoot.hwplib.reader.HWPReader; + + +public class CvlcptOrgn extends HWPFormat { + + @Override + public void setting(Print print) { + print.setFormatName("cvlcptOrgn"); + print.setFormatKorName("민원원본내역"); + + this.setFormatType("info"); + this.setRecordPerPartFile(1); + + this.setBaseFormatFilePath("template/hwp/cvlcptOrgnl_text.hwp"); + this.setAttachFormatFilePath("template/hwp/cvlcptOrgnl_photo.hwp"); + } + + @Override + public void setting(Print print, int cnt) { + } + + @Override + public void writeGlobalInfo(HWPFile baseFile, List dataObjectList, PrintOption printOption, + Print print) { + } + + @Override + public void writeSingleDataInfo(HWPFile baseFile, HWPFile attachFile, DataObject dataObject, Print print) { + + ClickHereEditor baseFileEditor = new ClickHereEditor(baseFile); + + baseFileEditor.set("신청자", dataObject.string("CVLCPT_APLCNT_NM")); + baseFileEditor.set("접수일자", DataFormat.yyyy_mm_dd(dataObject.string("CVLCPT_RCPT_YMD"))); + + String cvlcptRrcsPrnmntDt = dataObject.string("CVLCPT_PRCS_PRNMNT_DT"); + if(cvlcptRrcsPrnmntDt.length() > 8) { + cvlcptRrcsPrnmntDt = cvlcptRrcsPrnmntDt.substring(0, 8); + } + + baseFileEditor.set("처리기한", DataFormat.yyyy_mm_dd(cvlcptRrcsPrnmntDt)); + baseFileEditor.set("접수번호", dataObject.string("CVLCPT_RCPT_NO")); + baseFileEditor.set("목록번호", dataObject.string("CVLCPT_LIST_NO")); + + String cvlcptAplyCn = dataObject.string("CVLCPT_APLY_CN"); + cvlcptAplyCn = CmmnUtil.escapeHTMLEntity(cvlcptAplyCn); + baseFileEditor.set("민원내용", cvlcptAplyCn); + + try { + + if(dataObject.string("PHOTO0") != null && !dataObject.string("PHOTO0").equals("")) { + System.out.println("원본사진있음"); + + int photoCnt = dataObject.number("ORGN_PHOTO_CNT").intValue(); + int PHOTO_COUNT_PER_PAGE = 4; + + for(int i=0; i < photoCnt; i += PHOTO_COUNT_PER_PAGE) { + + InputStream attachFormatIS = new ClassPathResource(this.attachFormatFilePath).getInputStream(); + HWPFile attachFormatFile = HWPReader.fromInputStream(attachFormatIS); + InsertingImageCell.IMPL_InsertPicture(attachFormatFile, "왼쪽위사진", dataObject.string("PHOTO"+i)); + if(i+1 < photoCnt) + InsertingImageCell.IMPL_InsertPicture(attachFormatFile, "오른쪽위사진", dataObject.string("PHOTO"+(i+1))); + if(i+2 < photoCnt) + InsertingImageCell.IMPL_InsertPicture(attachFormatFile, "왼쪽아래사진", dataObject.string("PHOTO"+(i+2))); + if(i+3 < photoCnt) + InsertingImageCell.IMPL_InsertPicture(attachFormatFile, "오른쪽아래사진", dataObject.string("PHOTO"+(i+3))); + AddUtil.appendToLast(attachFormatFile, baseFile); + + } + + } else { + System.out.println("원본사진없음"); + } + } catch (Exception e) { + throw new RuntimeException("[F]"+e); + } + } + +} diff --git a/src/main/java/cokr/xit/fims/cmmn/hwp/format/DlbrDecsnList.java b/src/main/java/cokr/xit/fims/cmmn/hwp/format/DlbrDecsnList.java index 327cfc19..727a55cd 100644 --- a/src/main/java/cokr/xit/fims/cmmn/hwp/format/DlbrDecsnList.java +++ b/src/main/java/cokr/xit/fims/cmmn/hwp/format/DlbrDecsnList.java @@ -2,46 +2,49 @@ package cokr.xit.fims.cmmn.hwp.format; import java.util.List; +import cokr.xit.fims.cmmn.Print; import cokr.xit.fims.cmmn.hwp.ClickHereEditor; -import cokr.xit.fims.cmmn.hwp.HWPFormatWriter; -import cokr.xit.fims.cmmn.hwp.HWPPrintUtil; import cokr.xit.fims.sprt.PrintOption; import cokr.xit.foundation.data.DataObject; import kr.dogfoot.hwplib.object.HWPFile; -public class DlbrDecsnList implements HWPFormatWriter { +public class DlbrDecsnList extends HWPFormat { + @Override - public void setting(HWPPrintUtil hwpPrintUtil) { - hwpPrintUtil.setFormatName("dlbrDecsn"); - hwpPrintUtil.setFormatKorName("의견제출심의결의서"); + public void setting(Print print) { + print.setFormatName("dlbrDecsn"); + print.setFormatKorName("의견제출심의결의서"); - hwpPrintUtil.setFormatType("info"); - hwpPrintUtil.setRecordPerPartFile(1); + this.setFormatType("info"); + this.setRecordPerPartFile(1); - hwpPrintUtil.setBaseFormatFilePath("template/hwp/opnnDlbrDecsnForm.hwp"); - hwpPrintUtil.setAttachFormatFilePath(""); + this.setBaseFormatFilePath("template/hwp/opnnDlbrDecsnForm.hwp"); + this.setAttachFormatFilePath(""); } + @Override - public void setting(HWPPrintUtil hwpPrintUtil, int recordCnt) { - hwpPrintUtil.setFormatName("dlbrDecsn"); - hwpPrintUtil.setFormatKorName("의견제출심의결의서"); + public void setting(Print print, int recordCnt) { + print.setFormatName("dlbrDecsn"); + print.setFormatKorName("의견제출심의결의서"); - hwpPrintUtil.setFormatType("info"); - hwpPrintUtil.setRecordPerPartFile(recordCnt); + this.setFormatType("info"); + this.setRecordPerPartFile(recordCnt); - hwpPrintUtil.setBaseFormatFilePath("template/hwp/opnnDlbrDecsnForm.hwp"); - hwpPrintUtil.setAttachFormatFilePath(""); + this.setBaseFormatFilePath("template/hwp/opnnDlbrDecsnForm.hwp"); + this.setAttachFormatFilePath(""); } + @Override - public void writeGlobalInfo(HWPFile baseFile, List dataObjectList, PrintOption printOption, HWPPrintUtil hwpPrintUtil) { + public void writeGlobalInfo(HWPFile baseFile, List dataObjectList, PrintOption printOption, Print print) { } + @Override - public void writeSingleDataInfo(HWPFile baseFile, HWPFile attachFile, DataObject dataObject, HWPPrintUtil hwpPrintUtil) { + public void writeSingleDataInfo(HWPFile baseFile, HWPFile attachFile, DataObject dataObject, Print print) { // ClickHereEditor baseFileEditor = new ClickHereEditor(baseFile); diff --git a/src/main/java/cokr/xit/fims/cmmn/hwp/HWPPrintUtil.java b/src/main/java/cokr/xit/fims/cmmn/hwp/format/HWPFormat.java similarity index 72% rename from src/main/java/cokr/xit/fims/cmmn/hwp/HWPPrintUtil.java rename to src/main/java/cokr/xit/fims/cmmn/hwp/format/HWPFormat.java index ad2f9e6c..38554d29 100644 --- a/src/main/java/cokr/xit/fims/cmmn/hwp/HWPPrintUtil.java +++ b/src/main/java/cokr/xit/fims/cmmn/hwp/format/HWPFormat.java @@ -1,32 +1,31 @@ -package cokr.xit.fims.cmmn.hwp; +package cokr.xit.fims.cmmn.hwp.format; import java.io.File; import java.io.InputStream; import java.text.SimpleDateFormat; import java.util.Date; +import java.util.List; import org.springframework.core.io.ClassPathResource; -import cokr.xit.fims.cmmn.PrintUtil; +import cokr.xit.fims.cmmn.Print; +import cokr.xit.fims.sprt.PrintOption; +import cokr.xit.foundation.data.DataObject; import kr.dogfoot.hwplib.object.HWPFile; import kr.dogfoot.hwplib.reader.HWPReader; import kr.dogfoot.hwplib.writer.HWPWriter; -public class HWPPrintUtil extends PrintUtil { +public abstract class HWPFormat { - private String formatType; + protected String formatType; - private String formatName; + protected int recordPerPartFile; - private String formatKorName; + protected String baseFormatFilePath; - private int recordPerPartFile; + protected String attachFormatFilePath; - private String baseFormatFilePath; - - private String attachFormatFilePath; - - private int totalPartFileCount; + protected int totalPartFileCount; public String getFormatType() { return this.formatType; @@ -35,23 +34,6 @@ public class HWPPrintUtil extends PrintUtil { public void setFormatType(String formatType) { this.formatType = formatType; } - - public String getFormatName() { - return this.formatName; - } - - public void setFormatName(String formatName) { - this.formatName = formatName; - } - - public String getFormatKorName() { - return this.formatKorName; - } - - public void setFormatKorName(String formatKorName) { - this.formatKorName = formatKorName; - } - public int getRecordPerPartFile() { return this.recordPerPartFile; } @@ -84,6 +66,7 @@ public class HWPPrintUtil extends PrintUtil { this.attachFormatFilePath = attachFormatFilePath; } + /** 신규로 생성될 한글 파일 건수를 계산한다. * @param 총 데이터 건수 * @return @@ -115,7 +98,7 @@ public class HWPPrintUtil extends PrintUtil { * @param formatFile 한글 포맷 파일 * @return 새 파일 경로 */ - public String newFileFromFormatFile() { + public String newFileFromFormatFile(Print print) { try { InputStream baseFormatIS = new ClassPathResource(this.getBaseFormatFilePath()).getInputStream(); @@ -134,7 +117,9 @@ public class HWPPrintUtil extends PrintUtil { formatFileResultFolder.mkdirs(); } String resultHwpPath = formatFileResultFolderPath - + File.separator + currentTime + "_" + (this.fileNameIndex++) + ".hwp"; + + File.separator + currentTime + "_" + (print.getFileNameIndex()) + ".hwp"; + + print.setFileNameIndex(print.getFileNameIndex()+1); HWPWriter.toFile(baseFormatFile, resultHwpPath); return resultHwpPath; @@ -145,4 +130,26 @@ public class HWPPrintUtil extends PrintUtil { } + /** 포맷 형식별 기초 설정 적용. + * @param hwpPrintUtil + * @return + */ + public abstract void setting(Print print); + + public abstract void setting(Print print, int cnt); + + /** 한글파일 공통사항 적용 + * @param + * @return + */ + public abstract void writeGlobalInfo(HWPFile baseFile, List dataObjectList, + PrintOption printOption, Print print); + + /** 데이터 건별 한글파일 처리 + * @param + * @return + */ + public abstract void writeSingleDataInfo(HWPFile baseFile, HWPFile attachFile, DataObject dataObject, + Print print); + } diff --git a/src/main/java/cokr/xit/fims/cmmn/hwp/format/RcvmtConfirm.java b/src/main/java/cokr/xit/fims/cmmn/hwp/format/RcvmtConfirm.java index b66cbda0..edf9258b 100644 --- a/src/main/java/cokr/xit/fims/cmmn/hwp/format/RcvmtConfirm.java +++ b/src/main/java/cokr/xit/fims/cmmn/hwp/format/RcvmtConfirm.java @@ -3,9 +3,8 @@ package cokr.xit.fims.cmmn.hwp.format; import java.util.List; import cokr.xit.fims.cmmn.CmmnUtil; +import cokr.xit.fims.cmmn.Print; import cokr.xit.fims.cmmn.hwp.ClickHereEditor; -import cokr.xit.fims.cmmn.hwp.HWPFormatWriter; -import cokr.xit.fims.cmmn.hwp.HWPPrintUtil; import cokr.xit.fims.mngt.FactionUtil; import cokr.xit.fims.sprt.PrintOption; import cokr.xit.foundation.data.DataFormat; @@ -15,40 +14,44 @@ import kr.dogfoot.hwplib.object.HWPFile; /** * 납부확인서 */ -public class RcvmtConfirm implements HWPFormatWriter { +public class RcvmtConfirm extends HWPFormat { + @Override - public void setting(HWPPrintUtil hwpPrintUtil) { - hwpPrintUtil.setFormatName("rcvmtConfirm"); - hwpPrintUtil.setFormatKorName("납부확인서"); + public void setting(Print print) { + print.setFormatName("rcvmtConfirm"); + print.setFormatKorName("납부확인서"); - hwpPrintUtil.setFormatType("info"); - hwpPrintUtil.setRecordPerPartFile(1); + this.setFormatType("info"); + this.setRecordPerPartFile(1); - hwpPrintUtil.setBaseFormatFilePath("template/hwp/rcvmtConfirm.hwp"); - hwpPrintUtil.setAttachFormatFilePath(""); + this.setBaseFormatFilePath("template/hwp/rcvmtConfirm.hwp"); + this.setAttachFormatFilePath(""); } + @Override - public void setting(HWPPrintUtil hwpPrintUtil, int recordCnt) { - hwpPrintUtil.setFormatName("rcvmtConfirm"); - hwpPrintUtil.setFormatKorName("납부확인서"); + public void setting(Print print, int recordCnt) { + print.setFormatName("rcvmtConfirm"); + print.setFormatKorName("납부확인서"); - hwpPrintUtil.setFormatType("info"); - hwpPrintUtil.setRecordPerPartFile(recordCnt); + this.setFormatType("info"); + this.setRecordPerPartFile(recordCnt); - hwpPrintUtil.setBaseFormatFilePath("template/hwp/rcvmtConfirm.hwp"); - hwpPrintUtil.setAttachFormatFilePath(""); + this.setBaseFormatFilePath("template/hwp/rcvmtConfirm.hwp"); + this.setAttachFormatFilePath(""); } + @Override public void writeGlobalInfo(HWPFile baseFile, List dataObjectList, PrintOption printOption, - HWPPrintUtil hwpPrintUtil) { + Print print) { } + @Override public void writeSingleDataInfo(HWPFile baseFile, HWPFile attachFile, - DataObject dataObject, HWPPrintUtil hwpPrintUtil) { + DataObject dataObject, Print print) { ClickHereEditor baseFileEditor = new ClickHereEditor(baseFile); @@ -66,10 +69,10 @@ public class RcvmtConfirm implements HWPFormatWriter { baseFileEditor.set("수납일자", DataFormat.yyyy_mm_dd(dataObject.string("RCVMT_YMD"))); baseFileEditor.set("수납금액", CmmnUtil.addCommaToNumber(dataObject.string("RCVMT_AMT"))); - baseFileEditor.set("연월일시분초", CmmnUtil.yyyy_mm_dd_hh_mm_ss(hwpPrintUtil.getPrintRequestDt())); - baseFileEditor.set("확인자", hwpPrintUtil.getPrintRequestUserInfo().getName()); + baseFileEditor.set("연월일시분초", CmmnUtil.yyyy_mm_dd_hh_mm_ss(print.getPrintRequestDt())); + baseFileEditor.set("확인자", print.getPrintRequestUserInfo().getName()); - String instNm = (String) hwpPrintUtil.getPrintRequestUserInfo().getInfo().get("instNm"); + String instNm = (String) print.getPrintRequestUserInfo().getInfo().get("instNm"); instNm = FactionUtil.getInstituteLeader(instNm, false); baseFileEditor.set("발신", instNm); diff --git a/src/main/java/cokr/xit/fims/cmmn/hwp/format/ReportOnClaims.java b/src/main/java/cokr/xit/fims/cmmn/hwp/format/ReportOnClaims.java index 2d73d066..2300e3be 100644 --- a/src/main/java/cokr/xit/fims/cmmn/hwp/format/ReportOnClaims.java +++ b/src/main/java/cokr/xit/fims/cmmn/hwp/format/ReportOnClaims.java @@ -6,9 +6,8 @@ import java.util.Map; import org.egovframe.rte.fdl.string.EgovStringUtil; import cokr.xit.fims.cmmn.CmmnUtil; +import cokr.xit.fims.cmmn.Print; import cokr.xit.fims.cmmn.hwp.ClickHereEditor; -import cokr.xit.fims.cmmn.hwp.HWPFormatWriter; -import cokr.xit.fims.cmmn.hwp.HWPPrintUtil; import cokr.xit.fims.cmmn.hwp.InsertingImageCell; import cokr.xit.fims.mngt.FactionUtil; import cokr.xit.fims.sprt.PrintOption; @@ -19,45 +18,47 @@ import kr.dogfoot.hwplib.object.HWPFile; /** * 채권신고서 */ -public class ReportOnClaims implements HWPFormatWriter { +public class ReportOnClaims extends HWPFormat { + @Override - public void setting(HWPPrintUtil hwpPrintUtil) { - hwpPrintUtil.setFormatName("reportOnClaims"); - hwpPrintUtil.setFormatKorName("채권신고서"); + public void setting(Print print) { + print.setFormatName("reportOnClaims"); + print.setFormatKorName("채권신고서"); - hwpPrintUtil.setFormatType("list"); - hwpPrintUtil.setRecordPerPartFile(7); + this.setFormatType("list"); + this.setRecordPerPartFile(7); - hwpPrintUtil.setBaseFormatFilePath("template/hwp/reportOnClaims_root.hwp"); - hwpPrintUtil.setAttachFormatFilePath("template/hwp/reportOnClaims_inner.hwp"); + this.setBaseFormatFilePath("template/hwp/reportOnClaims_root.hwp"); + this.setAttachFormatFilePath("template/hwp/reportOnClaims_inner.hwp"); } @Override - public void setting(HWPPrintUtil hwpPrintUtil, int recordCnt) { - hwpPrintUtil.setFormatName("reportOnClaims"); - hwpPrintUtil.setFormatKorName("채권신고서"); + public void setting(Print print, int recordCnt) { + print.setFormatName("reportOnClaims"); + print.setFormatKorName("채권신고서"); - hwpPrintUtil.setFormatType("list"); - hwpPrintUtil.setRecordPerPartFile(recordCnt); + this.setFormatType("list"); + this.setRecordPerPartFile(recordCnt); - hwpPrintUtil.setBaseFormatFilePath("template/hwp/reportOnClaims_root.hwp"); - hwpPrintUtil.setAttachFormatFilePath("template/hwp/reportOnClaims_inner.hwp"); + this.setBaseFormatFilePath("template/hwp/reportOnClaims_root.hwp"); + this.setAttachFormatFilePath("template/hwp/reportOnClaims_inner.hwp"); } + @Override public void writeGlobalInfo(HWPFile baseFile, List dataObjectList, PrintOption printOption, - HWPPrintUtil hwpPrintUtil) { + Print print) { - Map globalVariable = hwpPrintUtil.getGlobalVariable(printOption); + Map globalVariable = print.getGlobalVariable(printOption); ClickHereEditor baseFileEditor = new ClickHereEditor(baseFile); baseFileEditor.set("주소", globalVariable.get("deptAddr")); baseFileEditor.set("전화", globalVariable.get("deptTelno")); baseFileEditor.set("팩스", globalVariable.get("deptFxno")); - baseFileEditor.set("담당자", hwpPrintUtil.getPrintRequestUserInfo().getName()); + baseFileEditor.set("담당자", print.getPrintRequestUserInfo().getName()); baseFileEditor.set("사건번호", EgovStringUtil.null2void(globalVariable.get("caseNo"))); baseFileEditor.set("체납자성명", EgovStringUtil.null2void(globalVariable.get("rtpyrNm"))); @@ -70,14 +71,14 @@ public class ReportOnClaims implements HWPFormatWriter { baseFileEditor.set("합계금액", CmmnUtil.addCommaToNumber(sumOfList)); baseFileEditor.set("합계금액한글", CmmnUtil.convertNumberToHangul(sumOfList)); - String printRequestYmd = hwpPrintUtil.getPrintRequestDt().substring(0, 8); + String printRequestYmd = print.getPrintRequestDt().substring(0, 8); String yyyy = printRequestYmd.substring(0, 4); String mm = printRequestYmd.substring(4, 6); String dd = printRequestYmd.substring(6, 8); String ymd = yyyy+"년 "+mm+"월 "+dd+"일"; baseFileEditor.set("연월일", ymd); - String instNm = (String) hwpPrintUtil.getPrintRequestUserInfo().getInfo().get("instNm"); + String instNm = (String) print.getPrintRequestUserInfo().getInfo().get("instNm"); instNm = FactionUtil.getLastWord(instNm); instNm = FactionUtil.getInstituteLeader(instNm, false); baseFileEditor.set("발신", instNm); @@ -91,9 +92,10 @@ public class ReportOnClaims implements HWPFormatWriter { } + @Override public void writeSingleDataInfo(HWPFile baseFile, HWPFile attachFile, - DataObject dataObject, HWPPrintUtil hwpPrintUtil) { + DataObject dataObject, Print print) { ClickHereEditor attachFileEditor = new ClickHereEditor(attachFile); diff --git a/src/main/java/cokr/xit/fims/cmmn/hwp/format/RequestForDelivery.java b/src/main/java/cokr/xit/fims/cmmn/hwp/format/RequestForDelivery.java index 83aba7a1..542fadd1 100644 --- a/src/main/java/cokr/xit/fims/cmmn/hwp/format/RequestForDelivery.java +++ b/src/main/java/cokr/xit/fims/cmmn/hwp/format/RequestForDelivery.java @@ -6,9 +6,8 @@ import java.util.Map; import org.egovframe.rte.fdl.string.EgovStringUtil; import cokr.xit.fims.cmmn.CmmnUtil; +import cokr.xit.fims.cmmn.Print; import cokr.xit.fims.cmmn.hwp.ClickHereEditor; -import cokr.xit.fims.cmmn.hwp.HWPFormatWriter; -import cokr.xit.fims.cmmn.hwp.HWPPrintUtil; import cokr.xit.fims.cmmn.hwp.InsertingImageCell; import cokr.xit.fims.mngt.FactionUtil; import cokr.xit.fims.sprt.PrintOption; @@ -19,39 +18,41 @@ import kr.dogfoot.hwplib.object.HWPFile; /** * 교부청구서 */ -public class RequestForDelivery implements HWPFormatWriter { +public class RequestForDelivery extends HWPFormat { @Override - public void setting(HWPPrintUtil hwpPrintUtil) { - hwpPrintUtil.setFormatName("requestForDelivery"); - hwpPrintUtil.setFormatKorName("교부청구서"); + public void setting(Print print) { + print.setFormatName("requestForDelivery"); + print.setFormatKorName("교부청구서"); - hwpPrintUtil.setFormatType("list"); - hwpPrintUtil.setRecordPerPartFile(7); + this.setFormatType("list"); + this.setRecordPerPartFile(7); - hwpPrintUtil.setBaseFormatFilePath("template/hwp/requestForDelivery_root.hwp"); - hwpPrintUtil.setAttachFormatFilePath("template/hwp/requestForDelivery_inner.hwp"); + this.setBaseFormatFilePath("template/hwp/requestForDelivery_root.hwp"); + this.setAttachFormatFilePath("template/hwp/requestForDelivery_inner.hwp"); } + @Override - public void setting(HWPPrintUtil hwpPrintUtil, int recordCnt) { - hwpPrintUtil.setFormatName("requestForDelivery"); - hwpPrintUtil.setFormatKorName("교부청구서"); + public void setting(Print print, int recordCnt) { + print.setFormatName("requestForDelivery"); + print.setFormatKorName("교부청구서"); - hwpPrintUtil.setFormatType("list"); - hwpPrintUtil.setRecordPerPartFile(recordCnt); + this.setFormatType("list"); + this.setRecordPerPartFile(recordCnt); - hwpPrintUtil.setBaseFormatFilePath("template/hwp/requestForDelivery_root.hwp"); - hwpPrintUtil.setAttachFormatFilePath("template/hwp/requestForDelivery_inner.hwp"); + this.setBaseFormatFilePath("template/hwp/requestForDelivery_root.hwp"); + this.setAttachFormatFilePath("template/hwp/requestForDelivery_inner.hwp"); } + @Override public void writeGlobalInfo(HWPFile baseFile, List dataObjectList, - PrintOption printOption, HWPPrintUtil hwpPrintUtil) { + PrintOption printOption, Print print) { ClickHereEditor baseFileEditor = new ClickHereEditor(baseFile); - Map globalVariable = hwpPrintUtil.getGlobalVariable(printOption); + Map globalVariable = print.getGlobalVariable(printOption); baseFileEditor.set("문서번호", EgovStringUtil.null2void(globalVariable.get("docNo"))); baseFileEditor.set("사건번호", EgovStringUtil.null2void(globalVariable.get("caseNo"))); @@ -70,11 +71,11 @@ public class RequestForDelivery implements HWPFormatWriter { baseFileEditor.set("개설은행", globalVariable.get("dtbnBankNm")); baseFileEditor.set("계좌번호", globalVariable.get("dtbnActno")); - String instNm = (String) hwpPrintUtil.getPrintRequestUserInfo().getInfo().get("instNm"); - String deptNm = (String) hwpPrintUtil.getPrintRequestUserInfo().getInfo().get("deptNm"); + String instNm = (String) print.getPrintRequestUserInfo().getInfo().get("instNm"); + String deptNm = (String) print.getPrintRequestUserInfo().getInfo().get("deptNm"); baseFileEditor.set("예금주", instNm + " " + deptNm); - String printRequestYmd = hwpPrintUtil.getPrintRequestDt().substring(0, 8); + String printRequestYmd = print.getPrintRequestDt().substring(0, 8); String yyyy = printRequestYmd.substring(0, 4); String mm = printRequestYmd.substring(4, 6); String dd = printRequestYmd.substring(6, 8); @@ -92,9 +93,10 @@ public class RequestForDelivery implements HWPFormatWriter { } } + @Override public void writeSingleDataInfo(HWPFile baseFile, HWPFile attachFile, - DataObject dataObject, HWPPrintUtil hwpPrintUtil) { + DataObject dataObject, Print print) { ClickHereEditor attachFileEditor = new ClickHereEditor(attachFile); diff --git a/src/main/java/cokr/xit/fims/cmmn/hwp/format/SvbtcList.java b/src/main/java/cokr/xit/fims/cmmn/hwp/format/SvbtcList.java index b40378f5..d6d9d520 100644 --- a/src/main/java/cokr/xit/fims/cmmn/hwp/format/SvbtcList.java +++ b/src/main/java/cokr/xit/fims/cmmn/hwp/format/SvbtcList.java @@ -2,42 +2,44 @@ package cokr.xit.fims.cmmn.hwp.format; import java.util.List; +import cokr.xit.fims.cmmn.Print; import cokr.xit.fims.cmmn.hwp.ClickHereEditor; -import cokr.xit.fims.cmmn.hwp.HWPFormatWriter; -import cokr.xit.fims.cmmn.hwp.HWPPrintUtil; import cokr.xit.fims.cmmn.hwp.InsertingImageCell; import cokr.xit.fims.sprt.PrintOption; import cokr.xit.foundation.data.DataObject; import kr.dogfoot.hwplib.object.HWPFile; -public class SvbtcList implements HWPFormatWriter { +public class SvbtcList extends HWPFormat { + @Override - public void setting(HWPPrintUtil hwpPrintUtil) { - hwpPrintUtil.setFormatName("svbtc"); - hwpPrintUtil.setFormatKorName("공시송달"); + public void setting(Print print) { + print.setFormatName("svbtc"); + print.setFormatKorName("공시송달"); - hwpPrintUtil.setFormatType("list"); - hwpPrintUtil.setRecordPerPartFile(9); + this.setFormatType("list"); + this.setRecordPerPartFile(9); - hwpPrintUtil.setBaseFormatFilePath("template/hwp/svbtcList_root.hwp"); - hwpPrintUtil.setAttachFormatFilePath("template/hwp/svbtcList_inner.hwp"); + this.setBaseFormatFilePath("template/hwp/svbtcList_root.hwp"); + this.setAttachFormatFilePath("template/hwp/svbtcList_inner.hwp"); } + @Override - public void setting(HWPPrintUtil hwpPrintUtil, int recordCnt) { - hwpPrintUtil.setFormatName("svbtc"); - hwpPrintUtil.setFormatKorName("공시송달"); + public void setting(Print print, int recordCnt) { + print.setFormatName("svbtc"); + print.setFormatKorName("공시송달"); - hwpPrintUtil.setFormatType("list"); - hwpPrintUtil.setRecordPerPartFile(recordCnt); + this.setFormatType("list"); + this.setRecordPerPartFile(recordCnt); - hwpPrintUtil.setBaseFormatFilePath("template/hwp/svbtcList_root.hwp"); - hwpPrintUtil.setAttachFormatFilePath("template/hwp/svbtcList_inner.hwp"); + this.setBaseFormatFilePath("template/hwp/svbtcList_root.hwp"); + this.setAttachFormatFilePath("template/hwp/svbtcList_inner.hwp"); } + @Override - public void writeGlobalInfo(HWPFile baseFile, List dataObjectList, PrintOption printOption, HWPPrintUtil hwpPrintUtil) { + public void writeGlobalInfo(HWPFile baseFile, List dataObjectList, PrintOption printOption, Print print) { // ClickHereEditor baseFileEditor = new ClickHereEditor(baseFile); @@ -58,8 +60,9 @@ public class SvbtcList implements HWPFormatWriter { } } + @Override - public void writeSingleDataInfo(HWPFile baseFile, HWPFile attachFile, DataObject dataObject, HWPPrintUtil hwpPrintUtil) { + public void writeSingleDataInfo(HWPFile baseFile, HWPFile attachFile, DataObject dataObject, Print print) { // ClickHereEditor attachFileEditor = new ClickHereEditor(attachFile); diff --git a/src/main/java/cokr/xit/fims/cmmn/pdf/extration/PDFExtractionUtil.java b/src/main/java/cokr/xit/fims/cmmn/pdf/extration/PDFExtractionUtil.java index 88a6c854..c3b3ef41 100644 --- a/src/main/java/cokr/xit/fims/cmmn/pdf/extration/PDFExtractionUtil.java +++ b/src/main/java/cokr/xit/fims/cmmn/pdf/extration/PDFExtractionUtil.java @@ -12,12 +12,12 @@ import org.apache.pdfbox.pdmodel.PDDocument; import org.apache.pdfbox.pdmodel.PDPage; import org.apache.pdfbox.pdmodel.PDPageTree; -import cokr.xit.fims.cmmn.PrintUtil; +import cokr.xit.fims.cmmn.Print; import cokr.xit.foundation.data.DataObject; public class PDFExtractionUtil { public static List extract(String pdfPath, List extractStngs) { - PrintUtil printUtil = new PrintUtil(); + Print printUtil = new Print(); List extractList = new ArrayList(); diff --git a/src/main/java/cokr/xit/fims/cmmn/pdf/print/PDFPrintUtil.java b/src/main/java/cokr/xit/fims/cmmn/pdf/print/PDFPrintUtil.java index 3a34c0f7..4ef4148d 100644 --- a/src/main/java/cokr/xit/fims/cmmn/pdf/print/PDFPrintUtil.java +++ b/src/main/java/cokr/xit/fims/cmmn/pdf/print/PDFPrintUtil.java @@ -18,7 +18,7 @@ import org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject; import org.apache.pdfbox.pdmodel.graphics.state.RenderingMode; import org.springframework.core.io.ClassPathResource; -import cokr.xit.fims.cmmn.PrintUtil; +import cokr.xit.fims.cmmn.Print; import cokr.xit.fims.cmmn.pdf.PDFColors; import cokr.xit.fims.cmmn.pdf.PDFCoordinate; import cokr.xit.fims.cmmn.pdf.Pstn; @@ -26,12 +26,10 @@ import cokr.xit.fims.cmmn.pdf.PstnAndSize; import cokr.xit.fims.cmmn.pdf.Size; import cokr.xit.foundation.data.DataObject; -public class PDFPrintUtil extends PrintUtil { +public class PDFPrintUtil extends Print { private float[] paperMilimeter = new float[2]; - private String formatKorName; - public void setting(String paperType) { if(paperType.equals("01")) { this.paperMilimeter = new float[] {210.0f , 297.0f}; @@ -40,13 +38,6 @@ public class PDFPrintUtil extends PrintUtil { } } - public String getFormatKorName() { - return this.formatKorName; - } - - public String setFormatKorName(String formatKorName) { - return this.formatKorName = formatKorName; - } public String filePathForNewFile() { diff --git a/src/main/java/cokr/xit/fims/cvlc/service/CrdnCvlcptService.java b/src/main/java/cokr/xit/fims/cvlc/service/CrdnCvlcptService.java index a6739786..a66c8426 100644 --- a/src/main/java/cokr/xit/fims/cvlc/service/CrdnCvlcptService.java +++ b/src/main/java/cokr/xit/fims/cvlc/service/CrdnCvlcptService.java @@ -34,15 +34,6 @@ public interface CrdnCvlcptService { */ DataObject getAnswerPreview(CrdnQuery query); - /** 한글 서식 출력물을 생성한다. - * @param query 출력 요청 - * @return map 출력 요청 결과 - *
  • filePath: 결과 파일 경로
  • - *
  • fileName: 다운로드 파일명
  • - *
- */ - Map makeFileFromHwpFormat(CrdnQuery query); - /** 민원 자료에 대해 반송(회수)처리한다. * @param crdnID 단속ID * @return 저장여부 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 73ac9f02..e704ff7d 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,19 +1,13 @@ 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; -import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.stream.Collectors; import javax.annotation.Resource; -import org.springframework.core.io.ClassPathResource; import org.springframework.stereotype.Service; import cokr.xit.base.file.service.FileQuery; @@ -22,8 +16,6 @@ import cokr.xit.fims.cmmn.CmmnUtil; import cokr.xit.fims.cmmn.CrdnSttsHstry; import cokr.xit.fims.cmmn.dao.CrdnPayerHstryMapper; import cokr.xit.fims.cmmn.dao.CrdnSttsHstryMapper; -import cokr.xit.fims.cmmn.hwp.AddUtil; -import cokr.xit.fims.cmmn.hwp.InsertingImageCell; import cokr.xit.fims.cmmn.service.bean.CrdnSttsHstryBean; import cokr.xit.fims.crdn.Crdn; import cokr.xit.fims.crdn.CrdnQuery; @@ -43,10 +35,6 @@ import cokr.xit.fims.sprt.service.bean.MediaBean; import cokr.xit.foundation.component.AbstractServiceBean; import cokr.xit.foundation.data.DataObject; import cokr.xit.interfaces.disabledparking.service.bean.DisabledParkingBean; -import kr.dogfoot.hwplib.object.HWPFile; -import kr.dogfoot.hwplib.reader.HWPReader; -import kr.dogfoot.hwplib.tool.objectfinder.FieldFinder; -import kr.dogfoot.hwplib.writer.HWPWriter; @Service("crdnCvlcptService") public class CrdnCvlcptServiceBean extends AbstractServiceBean implements CrdnCvlcptService { @@ -144,134 +132,6 @@ public class CrdnCvlcptServiceBean extends AbstractServiceBean implements CrdnCv return dataObjectList; } - @Override - public Map makeFileFromHwpFormat(CrdnQuery query) { - String baseFormatFilePath = ("template/hwp/cvlcptOrgnl_text.hwp"); - String attachFormatFilePath = ("template/hwp/cvlcptOrgnl_photo.hwp"); - - DataObject dataObject = crdnCvlcptMainBean.getCivilComplaintOriginalInfo(query); - SimpleDateFormat ymdhmsFormat = new SimpleDateFormat("yyyyMMddHHmmss"); - SimpleDateFormat ymdFormat = new SimpleDateFormat("yyyyMMdd"); - SimpleDateFormat ymdHypenFormat = new SimpleDateFormat("yyyy-MM-dd"); - - try { - - InputStream baseFormatIS = new ClassPathResource(baseFormatFilePath).getInputStream(); - - HWPFile baseFormatFile = HWPReader.fromInputStream(baseFormatIS); - - ArrayList strings = new ArrayList(); - strings.add(dataObject.string("CVLCPT_APLCNT_NM")); - FieldFinder.setClickHereText(baseFormatFile, "신청자", strings); - - strings = new ArrayList(); - String cvlcptRcptYmd = dataObject.string("CVLCPT_RCPT_YMD"); - cvlcptRcptYmd = ymdHypenFormat.format(ymdFormat.parse(cvlcptRcptYmd)); - strings.add(cvlcptRcptYmd); - FieldFinder.setClickHereText(baseFormatFile, "접수일자", strings); - - strings = new ArrayList(); - String cvlcptRrcsPrnmntDt = dataObject.string("CVLCPT_PRCS_PRNMNT_DT"); - if(cvlcptRrcsPrnmntDt.length() > 8) { - cvlcptRrcsPrnmntDt = cvlcptRrcsPrnmntDt.substring(0, 8); - } - cvlcptRrcsPrnmntDt = ymdHypenFormat.format(ymdFormat.parse(cvlcptRrcsPrnmntDt)); - - strings.add(cvlcptRrcsPrnmntDt); - FieldFinder.setClickHereText(baseFormatFile, "처리기한", strings); - - strings = new ArrayList(); - strings.add(dataObject.string("CVLCPT_RCPT_NO")); - FieldFinder.setClickHereText(baseFormatFile, "접수번호", strings); - - strings = new ArrayList(); - strings.add(dataObject.string("CVLCPT_LIST_NO")); - FieldFinder.setClickHereText(baseFormatFile, "목록번호", strings); - - strings = new ArrayList(); - String cvlcptAplyCn = dataObject.string("CVLCPT_APLY_CN"); - cvlcptAplyCn = CmmnUtil.escapeHTMLEntity(cvlcptAplyCn); - strings.add(cvlcptAplyCn); - FieldFinder.setClickHereText(baseFormatFile, "민원내용", strings); - - String currentTime = ymdhmsFormat.format(new Date()); - String year = currentTime.substring(0, 4); - String month = currentTime.substring(4, 6); - String day = currentTime.substring(6, 8); - - String formatFileResultRootPath = "files" + File.separator + "result" + File.separator + "print"; - String formatFileResultFolderPath = formatFileResultRootPath - + File.separator + year + File.separator + month + File.separator + day; - - File formatFileResultFolder = new File(formatFileResultFolderPath); - - if(!formatFileResultFolder.exists()) { - formatFileResultFolder.mkdirs(); - } - String resultHwpPath = formatFileResultFolderPath + File.separator + currentTime + ".hwp"; - - HWPWriter.toFile(baseFormatFile, resultHwpPath); - - HWPFile resultFile = HWPReader.fromFile(resultHwpPath); - - String linkTblNm = dataObject.string("LINK_TBL_NM"); - if(!(ifEmpty(linkTblNm, () -> "").equals(""))) { - FileQuery fileQuery = new FileQuery(); - - if(linkTblNm.equals("TB_ESB_INTERFACE")) { - fileQuery.setInfoType("010"); - } else if(linkTblNm.equals("TB_SAEOL")) { - fileQuery.setInfoType("020"); - } else { - throw new RuntimeException("한글 파일 출력 중 오류가 발생하였습니다."); - } - - fileQuery.setInfoKeys(dataObject.string("LINK_ID")); - - List fileInfoList = fileBean.getFileList(fileQuery); - - fileInfoList = fileInfoList.stream() - .filter(fileInfo -> fileInfo.string("MIME_TYPE").startsWith("image")) - .collect(Collectors.toList()); - - if(fileInfoList != null && fileInfoList.size() > 0) { - int photoCnt = fileInfoList.size(); - int PHOTO_COUNT_PER_PAGE = 4; - - for(int i=0; i < photoCnt; i += PHOTO_COUNT_PER_PAGE) { - - 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")); - if(i+2 < photoCnt) - InsertingImageCell.IMPL_InsertPicture(attachFormatFile, "왼쪽아래사진", fileInfoList.get(i+2).string("URL")); - if(i+3 < photoCnt) - InsertingImageCell.IMPL_InsertPicture(attachFormatFile, "오른쪽아래사진", fileInfoList.get(i+3).string("URL")); - AddUtil.appendToLast(attachFormatFile, resultFile); - - } - - HWPWriter.toFile(resultFile, resultHwpPath); - } - } - - String downlaodFileName = "민원내역원본_" + currentTime + ".hwp"; - Map result = Map.of( - "filename", downlaodFileName, - "filePath", resultHwpPath, - "file", new File(resultHwpPath) - ); - - return result; - - } catch (Exception e) { - throw new RuntimeException("한글 파일 출력 중 오류가 발생하였습니다."); - - } - } - @Override public DataObject getCivilComplaintOriginalInfo(CrdnQuery query) { return crdnCvlcptMainBean.getCivilComplaintOriginalInfo(query); diff --git a/src/main/java/cokr/xit/fims/cvlc/web/Cvlc01Controller.java b/src/main/java/cokr/xit/fims/cvlc/web/Cvlc01Controller.java index d35f68b4..99a37fd0 100644 --- a/src/main/java/cokr/xit/fims/cvlc/web/Cvlc01Controller.java +++ b/src/main/java/cokr/xit/fims/cvlc/web/Cvlc01Controller.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; @@ -14,6 +15,9 @@ import org.springframework.web.servlet.ModelAndView; import com.fasterxml.jackson.core.type.TypeReference; import cokr.xit.base.code.CommonCode; +import cokr.xit.base.file.hwp.HWPWriter; +import cokr.xit.base.file.service.FileQuery; +import cokr.xit.base.file.service.bean.FileBean; import cokr.xit.base.file.xls.XLSWriter; import cokr.xit.base.file.xls.XLSWriter.CellDef; import cokr.xit.base.file.xls.XLSWriter.Styler; @@ -21,6 +25,8 @@ import cokr.xit.base.user.ManagedUser; import cokr.xit.base.user.dao.UserMapper; import cokr.xit.base.web.ApplicationController; import cokr.xit.fims.cmmn.CmmnUtil; +import cokr.xit.fims.cmmn.Print; +import cokr.xit.fims.cmmn.hwp.format.CvlcptOrgn; import cokr.xit.fims.cmmn.service.bean.StngBean; import cokr.xit.fims.crdn.Crdn; import cokr.xit.fims.crdn.CrdnQuery; @@ -28,6 +34,9 @@ import cokr.xit.fims.crdn.dao.GlobalStngMapper; import cokr.xit.fims.crdn.service.CrdnService; import cokr.xit.fims.cvlc.CrdnCvlcpt; import cokr.xit.fims.cvlc.service.CrdnCvlcptService; +import cokr.xit.fims.cvlc.service.bean.CrdnCvlcptMainBean; +import cokr.xit.fims.mngt.service.bean.FactionBean; +import cokr.xit.fims.sprt.PrintOption; import cokr.xit.foundation.UserInfo; import cokr.xit.foundation.data.DataObject; @@ -68,6 +77,15 @@ public class Cvlc01Controller extends ApplicationController { @Resource(name = "stngBean") private StngBean stngBean; + @Resource(name = "fileBean") + private FileBean fileBean; + + @Resource(name = "factionBean") + private FactionBean factionBean; + + @Resource(name = "crdnCvlcptMainBean") + private CrdnCvlcptMainBean crdnCvlcptMainBean; + /** 민원 접수 자료 메인화면을 연다. * @return fims/cvlc/cvlc01010-main */ @@ -193,7 +211,49 @@ public class Cvlc01Controller extends ApplicationController { */ public ModelAndView makeFileFromHwpFormat(CrdnQuery query) { ModelAndView mav = new ModelAndView("downloadView"); - Map result = crdnCvlcptService.makeFileFromHwpFormat(query); + DataObject dataObject = crdnCvlcptMainBean.getCivilComplaintOriginalInfo(query); + List dataObjectList = new ArrayList(); + dataObjectList.add(dataObject); + String linkTblNm = dataObject.string("LINK_TBL_NM"); + if(!(ifEmpty(linkTblNm, () -> "").equals(""))) { + FileQuery fileQuery = new FileQuery(); + + if(linkTblNm.equals("TB_ESB_INTERFACE")) { + fileQuery.setInfoType("010"); + } else if(linkTblNm.equals("TB_SAEOL")) { + fileQuery.setInfoType("020"); + } else { + throw new RuntimeException("한글 파일 출력 중 오류가 발생하였습니다."); + } + + fileQuery.setInfoKeys(dataObject.string("LINK_ID")); + + List fileInfoList = fileBean.getFileList(fileQuery); + + fileInfoList = fileInfoList.stream() + .filter(fileInfo -> fileInfo.string("MIME_TYPE").startsWith("image")) + .collect(Collectors.toList()); + + if(fileInfoList != null && fileInfoList.size() > 0) { + int photoCnt = fileInfoList.size(); + + for(int i=0; i < photoCnt; i++) { + dataObject.put("PHOTO"+i, fileInfoList.get(i).string("URL")); + } + + dataObject.put("ORGN_PHOTO_CNT", photoCnt); + } + } + + + HWPWriter hwpWriter = new HWPWriter(); + PrintOption printOption = new PrintOption(); + UserInfo userInfo = currentUser(); + factionBean.initUserInfo(userInfo); + Print print = new Print(); + print.setPrintRequestUserInfo(userInfo); + hwpWriter.setFormat(new CvlcptOrgn()); + Map result = hwpWriter.makeFileFromHwpFormat("info", print, printOption, dataObjectList); mav.addAllObjects(result); return mav; diff --git a/src/main/java/cokr/xit/fims/excl/service/OpnnSbmsnService.java b/src/main/java/cokr/xit/fims/excl/service/OpnnSbmsnService.java index 014cb530..01c4259b 100644 --- a/src/main/java/cokr/xit/fims/excl/service/OpnnSbmsnService.java +++ b/src/main/java/cokr/xit/fims/excl/service/OpnnSbmsnService.java @@ -1,12 +1,10 @@ package cokr.xit.fims.excl.service; import java.util.List; -import java.util.Map; import cokr.xit.base.file.FileInfo; -import cokr.xit.fims.excl.OpnnSbmsn; -import cokr.xit.fims.sprt.PrintOption; import cokr.xit.fims.excl.LevyExclQuery; +import cokr.xit.fims.excl.OpnnSbmsn; import cokr.xit.foundation.data.DataObject; /**의견제출 대장 관리 서비스 인터페이스. @@ -75,13 +73,5 @@ public interface OpnnSbmsnService { */ String removeOpnnSbmsn(OpnnSbmsn opnnSbmsn); - /** 한글 서식 출력물을 생성한다. - * @param formatType 서식유형 ,formatName 서식명, printOption 출력옵션, opnnIDs 출력대상 - * @return map 출력 요청 결과 - *
  • filePath: 결과 파일 경로
  • - *
  • fileName: 다운로드 파일명
  • - *
- */ - Map makeDlbrDecsnFileFromHwpFormat(String formatType, String formatName, PrintOption printOption, LevyExclQuery req); } diff --git a/src/main/java/cokr/xit/fims/excl/service/bean/OpnnSbmsnServiceBean.java b/src/main/java/cokr/xit/fims/excl/service/bean/OpnnSbmsnServiceBean.java index 2443182b..204f8662 100644 --- a/src/main/java/cokr/xit/fims/excl/service/bean/OpnnSbmsnServiceBean.java +++ b/src/main/java/cokr/xit/fims/excl/service/bean/OpnnSbmsnServiceBean.java @@ -1,31 +1,18 @@ package cokr.xit.fims.excl.service.bean; -import java.io.File; -import java.util.ArrayList; -import java.util.HashMap; import java.util.List; -import java.util.Map; import javax.annotation.Resource; import org.springframework.stereotype.Service; import cokr.xit.base.file.FileInfo; -import cokr.xit.fims.cmmn.hwp.AddUtil; -import cokr.xit.fims.cmmn.hwp.format.DlbrDecsnList; -import cokr.xit.fims.cmmn.hwp.HWPFormatWriter; -import cokr.xit.fims.cmmn.hwp.HWPPrintUtil; import cokr.xit.fims.excl.LevyExclQuery; import cokr.xit.fims.excl.OpnnSbmsn; import cokr.xit.fims.excl.service.OpnnSbmsnService; import cokr.xit.fims.mngt.service.bean.FactionBean; -import cokr.xit.fims.sprt.PrintOption; -import cokr.xit.foundation.UserInfo; import cokr.xit.foundation.component.AbstractServiceBean; import cokr.xit.foundation.data.DataObject; -import kr.dogfoot.hwplib.object.HWPFile; -import kr.dogfoot.hwplib.reader.HWPReader; -import kr.dogfoot.hwplib.writer.HWPWriter; /**의견제출 대장 서비스 구현체. * @@ -78,89 +65,6 @@ public class OpnnSbmsnServiceBean extends AbstractServiceBean implements OpnnSbm return opnnSbmsnBean.updateOpnnSbmsnAnswer(opnnSbmsn); } - @Override - public Map makeDlbrDecsnFileFromHwpFormat(String formatType, String formatName, PrintOption printOption, LevyExclQuery req) { - Map result = new HashMap<>(); - - HWPPrintUtil printUtil = new HWPPrintUtil(); - HWPFormatWriter hwpFormatWriter = new DlbrDecsnList(); - hwpFormatWriter.setting(printUtil); - - UserInfo userInfo = currentUser(); - factionBean.initUserInfo(userInfo); - printUtil.setPrintRequestUserInfo(userInfo); - - List dataObjectList = null; - - dataObjectList = opnnSbmsnBean.getOpnnSbmsnDlbrDecsns(req); - - int totalDataCount = dataObjectList.size(); - List partFileList = new ArrayList<>(); - printUtil.calcTotalPartFileCount(totalDataCount); - - try { - int dataIndex = 0; - - for(int partFileIndex = 0; partFileIndex < printUtil.getTotalPartFileCount(); partFileIndex++) { - // 새 파일 생성 - String resultHwpPath = printUtil.newFileFromFormatFile(); - HWPFile resultFile = HWPReader.fromFile(resultHwpPath); - - // 공통사항 세팅 - hwpFormatWriter.writeGlobalInfo(resultFile, dataObjectList, printOption, printUtil); - HWPWriter.toFile(resultFile, resultHwpPath); - - // 데이터 건별 처리 - for (int recordIndex = 0; recordIndex < printUtil.getRecordPerPartFile(); recordIndex++) { - if (dataIndex < dataObjectList.size()) { - DataObject dataObject = dataObjectList.get(dataIndex); - hwpFormatWriter.writeSingleDataInfo(resultFile, null, dataObject, printUtil); - } - - if (formatType.equals("list")) { - dataIndex++; - } - } - - if (!formatType.equals("list")) { - dataIndex++; - } - - HWPWriter.toFile(resultFile, resultHwpPath); - partFileList.add(resultHwpPath); - } - - // 결과 파일 병합 - if (partFileList.size() >= 2) { - String basePath = partFileList.get(0); - HWPFile baseFile = HWPReader.fromFile(basePath); - - for (int iLoop = 2; iLoop <= partFileList.size(); iLoop++) { - String attachPath = partFileList.get(iLoop - 1); - HWPFile attachFile = HWPReader.fromFile(attachPath); - AddUtil.appendToLast(attachFile, baseFile); - } - - HWPWriter.toFile(baseFile, basePath); - - for (int i = 2; i <= partFileList.size(); i++) { - (new File(partFileList.get(i-1))).delete(); - } - } - - String downlaodFileName = printUtil.getFormatKorName() + "_" + printUtil.getPrintRequestDt() + ".hwp"; - String filePath = partFileList.get(0); - - result.put("filename", downlaodFileName); - result.put("filePath", filePath); - result.put("file", new File(filePath)); - } catch (Exception e) { - e.printStackTrace(); - throw new RuntimeException("한글 파일 출력 중 오류가 발생하였습니다."); - } - - return result; - } @Override public String removeOpnnSbmsn(OpnnSbmsn opnnSbmsn) { diff --git a/src/main/java/cokr/xit/fims/excl/web/Excl02Controller.java b/src/main/java/cokr/xit/fims/excl/web/Excl02Controller.java index ead432cc..82168eaa 100644 --- a/src/main/java/cokr/xit/fims/excl/web/Excl02Controller.java +++ b/src/main/java/cokr/xit/fims/excl/web/Excl02Controller.java @@ -14,6 +14,7 @@ import org.springframework.web.servlet.ModelAndView; import cokr.xit.base.code.CommonCode; import cokr.xit.base.file.FileInfo; +import cokr.xit.base.file.hwp.HWPWriter; import cokr.xit.base.file.service.FileService; import cokr.xit.base.file.web.FileInfoFactory; import cokr.xit.base.file.xls.XLSWriter; @@ -22,11 +23,16 @@ import cokr.xit.base.file.xls.XLSWriter.Styler; import cokr.xit.base.user.ManagedUser; import cokr.xit.base.web.ApplicationController; import cokr.xit.fims.cmmn.CmmnUtil; +import cokr.xit.fims.cmmn.Print; +import cokr.xit.fims.cmmn.hwp.format.DlbrDecsnList; import cokr.xit.fims.cmmn.service.bean.StngBean; -import cokr.xit.fims.excl.OpnnSbmsn; import cokr.xit.fims.excl.LevyExclQuery; +import cokr.xit.fims.excl.OpnnSbmsn; import cokr.xit.fims.excl.service.OpnnSbmsnService; +import cokr.xit.fims.excl.service.bean.OpnnSbmsnBean; +import cokr.xit.fims.mngt.service.bean.FactionBean; import cokr.xit.fims.sprt.PrintOption; +import cokr.xit.foundation.UserInfo; import cokr.xit.foundation.data.DataObject; /**의견제출 대장 서비스의 웹 컨트롤러 @@ -68,6 +74,12 @@ public class Excl02Controller extends ApplicationController { @Resource(name = "stngBean") private StngBean stngBean; + @Resource(name = "factionBean") + private FactionBean factionBean; + + @Resource(name = "opnnSbmsnBean") + private OpnnSbmsnBean opnnSbmsnBean; + /**의견제출 대장 관리 메인화면(fims/excl/excl02/010-main)을 연다. * * @return /fims/excl/excl02010 @@ -338,10 +350,18 @@ public class Excl02Controller extends ApplicationController { * } */ public ModelAndView makeDlbrDecsnFileFromHwpFormat(LevyExclQuery req) { - // + + HWPWriter hwpWriter = new HWPWriter(); PrintOption printOption = new PrintOption(); + UserInfo userInfo = currentUser(); + factionBean.initUserInfo(userInfo); + Print print = new Print(); + print.setPrintRequestUserInfo(userInfo); + + hwpWriter.setFormat(new DlbrDecsnList()); - Map result = opnnSbmsnService.makeDlbrDecsnFileFromHwpFormat("info", "dlbrDecsn", printOption ,req); + List dataObjectList = opnnSbmsnBean.getOpnnSbmsnDlbrDecsns(req); + Map result = hwpWriter.makeFileFromHwpFormat("info", print, printOption, dataObjectList); ModelAndView mav = new ModelAndView("downloadView"); mav.addAllObjects(result); diff --git a/src/main/java/cokr/xit/fims/sndb/service/SvbtcService.java b/src/main/java/cokr/xit/fims/sndb/service/SvbtcService.java index 750f12c6..317eab32 100644 --- a/src/main/java/cokr/xit/fims/sndb/service/SvbtcService.java +++ b/src/main/java/cokr/xit/fims/sndb/service/SvbtcService.java @@ -1,13 +1,10 @@ package cokr.xit.fims.sndb.service; import java.util.List; -import java.util.Map; -import cokr.xit.foundation.data.DataObject; - -import cokr.xit.fims.sndb.Svbtc; -import cokr.xit.fims.sprt.PrintOption; import cokr.xit.fims.sndb.SndbQuery; +import cokr.xit.fims.sndb.Svbtc; +import cokr.xit.foundation.data.DataObject; /**공시송달 대장 관리 서비스 인터페이스. * @@ -51,11 +48,6 @@ public interface SvbtcService { */ List getSvbtcDtls(SndbQuery req); - /**지정한 조건에 따라 공시송달 상세 객체들을 반환한다. - * @param req 공시송달 IDs - * @return - */ - Map makeSvbtcFileFromHwpFormat(String formatType, String formatName, PrintOption printOption, SndbQuery req); /**공시송달 대장 정보를 등록한다. * @param svbtc 공시송달 대장 diff --git a/src/main/java/cokr/xit/fims/sndb/service/bean/SvbtcServiceBean.java b/src/main/java/cokr/xit/fims/sndb/service/bean/SvbtcServiceBean.java index e641493c..19c8638c 100644 --- a/src/main/java/cokr/xit/fims/sndb/service/bean/SvbtcServiceBean.java +++ b/src/main/java/cokr/xit/fims/sndb/service/bean/SvbtcServiceBean.java @@ -1,31 +1,17 @@ package cokr.xit.fims.sndb.service.bean; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.HashMap; import java.util.List; -import java.util.Map; import javax.annotation.Resource; -import org.springframework.core.io.ClassPathResource; import org.springframework.stereotype.Service; -import cokr.xit.foundation.UserInfo; -import cokr.xit.foundation.component.AbstractServiceBean; -import cokr.xit.foundation.data.DataObject; -import kr.dogfoot.hwplib.object.HWPFile; -import kr.dogfoot.hwplib.reader.HWPReader; -import kr.dogfoot.hwplib.writer.HWPWriter; -import cokr.xit.fims.sndb.Svbtc; -import cokr.xit.fims.cmmn.hwp.AddUtil; -import cokr.xit.fims.cmmn.hwp.HWPFormatWriter; -import cokr.xit.fims.cmmn.hwp.HWPPrintUtil; -import cokr.xit.fims.cmmn.hwp.format.SvbtcList; import cokr.xit.fims.mngt.service.bean.FactionBean; import cokr.xit.fims.sndb.SndbQuery; +import cokr.xit.fims.sndb.Svbtc; import cokr.xit.fims.sndb.service.SvbtcService; -import cokr.xit.fims.sprt.PrintOption; +import cokr.xit.foundation.component.AbstractServiceBean; +import cokr.xit.foundation.data.DataObject; /**공시송달 대장 서비스 구현체. * @@ -73,104 +59,6 @@ public class SvbtcServiceBean extends AbstractServiceBean implements SvbtcServic return svbtcBean.getSvbtcDtls(req); } - @Override - public Map makeSvbtcFileFromHwpFormat(String formatType, String formatName, PrintOption printOption, SndbQuery req) { - // return - Map result = new HashMap<>(); - - HWPPrintUtil printUtil = new HWPPrintUtil(); - HWPFormatWriter hwpFormatWriter = new SvbtcList(); - - // 사용자 조회 - UserInfo userInfo = currentUser(); - factionBean.initUserInfo(userInfo); - printUtil.setPrintRequestUserInfo(userInfo); - - // 자료 조회 - req.setSggCd((String)userInfo.getInfo().get("sggCd")); - req.setDeptCd((String)userInfo.getInfo().get("deptCd")); - req.setOrderBy("SV.SVBTC_ID, SD.SNDNG_DTL_ID"); - - List dataObjectList = svbtcBean.getSvbtcPrint(req); - - int totalDataCount = dataObjectList.size(); - - // 한글 포맷 setting - hwpFormatWriter.setting(printUtil, totalDataCount); - - // - printUtil.calcTotalPartFileCount(totalDataCount); - - List partFileList = new ArrayList<>(); - - try { - int dataIndex = 0; - for(int partFileIndex = 0; partFileIndex < printUtil.getTotalPartFileCount(); partFileIndex++) { - - // 새 파일 생성 - String resultHwpPath = printUtil.newFileFromFormatFile(); - HWPFile resultFile = HWPReader.fromFile(resultHwpPath); - - // 공통사항 세팅 - hwpFormatWriter.writeGlobalInfo(resultFile, dataObjectList, printOption, printUtil); - HWPWriter.toFile(resultFile, resultHwpPath); - - // 데이터 건별 처리 - for (int recordIndex = 0; recordIndex < printUtil.getRecordPerPartFile(); recordIndex++) { - if (dataIndex < dataObjectList.size()) { - DataObject dataObject = dataObjectList.get(dataIndex); - - if (formatType.equals("list")) { - InputStream attachFormatIS = new ClassPathResource(printUtil.getAttachFormatFilePath()).getInputStream(); - HWPFile attachFormatFile = HWPReader.fromInputStream(attachFormatIS); - - hwpFormatWriter.writeSingleDataInfo(null, attachFormatFile, dataObject, printUtil); - - AddUtil.insertTableInCell(attachFormatFile, resultFile, "내부"); - } else { - hwpFormatWriter.writeSingleDataInfo(resultFile, null, dataObject, printUtil); - } - } - - if (formatType.equals("list")) { - dataIndex++; - } - } - - if (!formatType.equals("list")) { - dataIndex++; - } - - HWPWriter.toFile(resultFile, resultHwpPath); - partFileList.add(resultHwpPath); - } - - // 결과 파일 병합 - if (partFileList.size() >= 2) { - String basePath = partFileList.get(0); - HWPFile baseFile = HWPReader.fromFile(basePath); - - for (int iLoop = 2; iLoop <= partFileList.size(); iLoop++) { - String attachPath = partFileList.get(iLoop - 1); - HWPFile attachFile = HWPReader.fromFile(attachPath); - AddUtil.appendToLast(attachFile, baseFile); - } - - HWPWriter.toFile(baseFile, basePath); - } - - String downlaodFileName = printUtil.getFormatKorName() + "_" + printUtil.getPrintRequestDt() + ".hwp"; - - result.put("fileName", downlaodFileName); - result.put("filePath", partFileList.get(0)); - } catch (Exception e) { - e.printStackTrace(); - throw new RuntimeException("한글 파일 출력 중 오류가 발생하였습니다."); - } - - return result; - } - @Override public String createSvbtc(SndbQuery req, Svbtc svbtc) { return svbtcBean.createSvbtc(req, svbtc); diff --git a/src/main/java/cokr/xit/fims/sndb/web/Sndb01Controller.java b/src/main/java/cokr/xit/fims/sndb/web/Sndb01Controller.java index 18b94410..46106774 100644 --- a/src/main/java/cokr/xit/fims/sndb/web/Sndb01Controller.java +++ b/src/main/java/cokr/xit/fims/sndb/web/Sndb01Controller.java @@ -11,6 +11,7 @@ import org.apache.poi.ss.usermodel.CellStyle; import org.springframework.web.servlet.ModelAndView; import cokr.xit.base.code.CommonCode; +import cokr.xit.base.file.hwp.HWPWriter; import cokr.xit.base.file.xls.XLSWriter; import cokr.xit.base.file.xls.XLSWriter.CellDef; import cokr.xit.base.file.xls.XLSWriter.Styler; @@ -18,7 +19,9 @@ import cokr.xit.base.user.ManagedUser; import cokr.xit.base.web.ApplicationController; import cokr.xit.fims.cmmn.CmmnQuery; import cokr.xit.fims.cmmn.CmmnUtil; +import cokr.xit.fims.cmmn.Print; import cokr.xit.fims.cmmn.service.bean.StngBean; +import cokr.xit.fims.mngt.service.bean.FactionBean; import cokr.xit.fims.mngt.service.bean.TaskBean; import cokr.xit.fims.sndb.SndbQuery; import cokr.xit.fims.sndb.Sndng; @@ -27,8 +30,10 @@ import cokr.xit.fims.sndb.Svbtc; import cokr.xit.fims.sndb.service.SndngDtlService; import cokr.xit.fims.sndb.service.SndngService; import cokr.xit.fims.sndb.service.SvbtcService; +import cokr.xit.fims.sndb.service.bean.SvbtcBean; import cokr.xit.fims.sprt.PrintOption; import cokr.xit.fims.sprt.service.IntegrationSearchService; +import cokr.xit.foundation.UserInfo; import cokr.xit.foundation.data.DataObject; /**발송 대장 서비스의 웹 컨트롤러 @@ -118,6 +123,12 @@ public class Sndb01Controller extends ApplicationController { @Resource(name="stngBean") private StngBean stngBean; + @Resource(name="factionBean") + private FactionBean factionBean; + + @Resource(name="svbtcBean") + private SvbtcBean svbtcBean; + /**계고장 발송 대상 자료 메인화면(sndb/sndb01/010-main)을 연다. * @return /sndb/sndb01/010-main */ @@ -1456,11 +1467,23 @@ public class Sndb01Controller extends ApplicationController { * @return 공시송달 hwp파일 */ public ModelAndView makeSvbtcFileFromHwpFormat(SndbQuery req) { - Map result = null; + Map result = null; + HWPWriter hwpWriter = new HWPWriter(); PrintOption printOption = new PrintOption(); + UserInfo userInfo = currentUser(); + factionBean.initUserInfo(userInfo); + + req.setSggCd((String)userInfo.getInfo().get("sggCd")); + req.setDeptCd((String)userInfo.getInfo().get("deptCd")); + req.setOrderBy("SV.SVBTC_ID, SD.SNDNG_DTL_ID"); + + List dataObjectList = svbtcBean.getSvbtcPrint(req); + + Print print = new Print(); + print.setPrintRequestUserInfo(userInfo); - result = svbtcService.makeSvbtcFileFromHwpFormat("list", "svbtc", printOption, req); + result = hwpWriter.makeFileFromHwpFormat("list", print, printOption, dataObjectList); ModelAndView mav = new ModelAndView("jsonView"); diff --git a/src/main/java/cokr/xit/fims/sprt/service/IntegrationSearchService.java b/src/main/java/cokr/xit/fims/sprt/service/IntegrationSearchService.java index d409edb0..86dd9ad1 100644 --- a/src/main/java/cokr/xit/fims/sprt/service/IntegrationSearchService.java +++ b/src/main/java/cokr/xit/fims/sprt/service/IntegrationSearchService.java @@ -31,15 +31,6 @@ public interface IntegrationSearchService { */ String updateEtcCn(String etcCn, String... crdnIds); - /** 한글 서식 출력물을 생성한다. - * @param formatType 서식유형 ,formatName 서식명, printOption 출력옵션, crdnIds 출력대상 - * @return map 출력 요청 결과 - *
  • filename: 다운로드 파일명
  • - *
  • filePath: 결과 파일 경로
  • - *
  • file: 결과 파일
  • - *
- */ - Map makeFileFromHwpFormat(String formatType, String formatName, PrintOption printOption, String... crdnIds); /** pdf 출력물을 생성한다. * @param formatType 서식유형 ,formatName 서식명, printOption 출력옵션, crdnIds 출력대상 diff --git a/src/main/java/cokr/xit/fims/sprt/service/bean/IntegrationSearchServiceBean.java b/src/main/java/cokr/xit/fims/sprt/service/bean/IntegrationSearchServiceBean.java index 4e8e3259..aef08f72 100644 --- a/src/main/java/cokr/xit/fims/sprt/service/bean/IntegrationSearchServiceBean.java +++ b/src/main/java/cokr/xit/fims/sprt/service/bean/IntegrationSearchServiceBean.java @@ -33,14 +33,6 @@ import cokr.xit.base.file.service.FileQuery; import cokr.xit.base.file.service.bean.FileBean; import cokr.xit.fims.cmmn.CmmnUtil; import cokr.xit.fims.cmmn.Hangul; -import cokr.xit.fims.cmmn.hwp.AddUtil; -import cokr.xit.fims.cmmn.hwp.HWPFormatWriter; -import cokr.xit.fims.cmmn.hwp.HWPPrintUtil; -import cokr.xit.fims.cmmn.hwp.format.CrdnConfirm; -import cokr.xit.fims.cmmn.hwp.format.CrdnList; -import cokr.xit.fims.cmmn.hwp.format.RcvmtConfirm; -import cokr.xit.fims.cmmn.hwp.format.ReportOnClaims; -import cokr.xit.fims.cmmn.hwp.format.RequestForDelivery; import cokr.xit.fims.cmmn.pdf.PstnAndSize; import cokr.xit.fims.cmmn.pdf.print.DefaultOtptArtclStng; import cokr.xit.fims.cmmn.pdf.print.PDFPrintUtil; @@ -49,7 +41,6 @@ import cokr.xit.fims.cmmn.pdf.print.format.Nht; import cokr.xit.fims.cmmn.pdf.print.format.PDFPrintFormat; import cokr.xit.fims.cmmn.service.bean.StngBean; import cokr.xit.fims.crdn.Crdn; -import cokr.xit.fims.crdn.CrdnQuery; import cokr.xit.fims.crdn.dao.CrdnListMapper; import cokr.xit.fims.mngt.service.bean.FactionBean; import cokr.xit.fims.sprt.OtptStngQuery; @@ -61,9 +52,6 @@ import cokr.xit.fims.sprt.service.IntegrationSearchService; import cokr.xit.foundation.UserInfo; import cokr.xit.foundation.component.AbstractServiceBean; import cokr.xit.foundation.data.DataObject; -import kr.dogfoot.hwplib.object.HWPFile; -import kr.dogfoot.hwplib.reader.HWPReader; -import kr.dogfoot.hwplib.writer.HWPWriter; import net.lingala.zip4j.ZipFile; /**통합 조회 서비스 구현체. @@ -120,180 +108,7 @@ public class IntegrationSearchServiceBean extends AbstractServiceBean implements } } - @Override - public Map makeFileFromHwpFormat(String formatType, String formatName, PrintOption printOption, String... crdnIds) { - Map result = new HashMap<>(); - - HWPPrintUtil printUtil = new HWPPrintUtil(); - UserInfo userInfo = currentUser(); - factionBean.initUserInfo(userInfo); - printUtil.setPrintRequestUserInfo(userInfo); - - - HWPFormatWriter hwpFormatWriter = null; - switch (formatName) { - case "crdnConfirm" -> { hwpFormatWriter = new CrdnConfirm(); } - case "crdnList" -> { hwpFormatWriter = new CrdnList(); } - case "reportOnClaims" -> { hwpFormatWriter = new ReportOnClaims(); } - case "requestForDelivery" -> { hwpFormatWriter = new RequestForDelivery(); } - case "rcvmtConfirm" -> { hwpFormatWriter = new RcvmtConfirm(); } - } - hwpFormatWriter.setting(printUtil); - - - DataObject sggStngInfo = stngBean.getStng("sgg"); - DataObject deptStngInfo = stngBean.getStng("dept"); - - List dataObjectList = null; - - if(formatName.equals("crdnList")) { - CrdnQuery query = new CrdnQuery(); - query.setCrdnIds(crdnIds); - dataObjectList = crdnListMapper.selectCrackdownList(query); - } else if(formatName.equals("crdnConfirm")) { - CrdnQuery query = new CrdnQuery(); - query.setCrdnIds(crdnIds); - dataObjectList = crdnListMapper.selectCrackdownList(query); - - for(int i=0; i < dataObjectList.size(); i++) { - DataObject dataObject = dataObjectList.get(i); - String crndId = dataObject.string("CRDN_ID"); - - FileQuery fileQuery = new FileQuery(); - fileQuery.setInfoType(Crdn.INF_TYPE); - fileQuery.setInfoKeys(crndId); - List fileInfoList = fileBean.getFileList(fileQuery); - if(fileInfoList != null && fileInfoList.size() > 0) { - dataObject.set("PHOTO1", fileInfoList.get(0).string("URL")); - if(fileInfoList.size() >= 2) - dataObject.set("PHOTO2", fileInfoList.get(1).string("URL")); - if(fileInfoList.size() >= 3) - dataObject.set("PHOTO3", fileInfoList.get(2).string("URL")); - if(fileInfoList.size() >= 4) - dataObject.set("PHOTO4", fileInfoList.get(3).string("URL")); - } - - } - } else if(formatName.equals("requestForDelivery")) { - SprtQuery sprtQuery = new SprtQuery(); - sprtQuery.setCrdnIds(crdnIds); - dataObjectList = integrationSearchMapper.selectIntegrationDataList(sprtQuery); - - Map globalVariable = printOption.getGlobalVariable(); - - globalVariable.put("dtbnBankNm", deptStngInfo.string("DTBN_BANK_NM")); - globalVariable.put("dtbnActno", deptStngInfo.string("DTBN_ACTNO")); - globalVariable.put("offcsFilePath", sggStngInfo.string("OFFCS_FILE_PATH")); - - printOption.setGlobalVariable(globalVariable); - - } else if(formatName.equals("reportOnClaims")) { - SprtQuery sprtQuery = new SprtQuery(); - sprtQuery.setCrdnIds(crdnIds); - dataObjectList = integrationSearchMapper.selectIntegrationDataList(sprtQuery); - - Map globalVariable = printOption.getGlobalVariable(); - - String deptNm = (String) printUtil.getPrintRequestUserInfo().getInfo().get("deptNm"); - String deptAddr = sggStngInfo.string("INST_FULL_ADDR") + " " + deptNm; - globalVariable.put("deptAddr", deptAddr); - globalVariable.put("deptTelno", deptStngInfo.string("DEPT_TELNO")); - globalVariable.put("deptFxno", deptStngInfo.string("DEPT_FXNO")); - globalVariable.put("offcsFilePath", sggStngInfo.string("OFFCS_FILE_PATH")); - - printOption.setGlobalVariable(globalVariable); - } else if(formatName.equals("rcvmtConfirm")) { - SprtQuery sprtQuery = new SprtQuery(); - sprtQuery.setCrdnIds(crdnIds); - dataObjectList = integrationSearchMapper.selectIntegrationDataList(sprtQuery); - } - int totalDataCount = dataObjectList.size(); - List partFileList = new ArrayList<>(); - printUtil.calcTotalPartFileCount(totalDataCount); - - - try { - - int dataIndex = 0; - for(int partFileIndex = 0; partFileIndex < printUtil.getTotalPartFileCount(); partFileIndex++) { - - //새 파일 생성 - String resultHwpPath = printUtil.newFileFromFormatFile(); - HWPFile resultFile = HWPReader.fromFile(resultHwpPath); - - //공통사항 세팅 - hwpFormatWriter.writeGlobalInfo(resultFile, dataObjectList, printOption, printUtil); - - HWPWriter.toFile(resultFile, resultHwpPath); - - //데이터 건별 처리 - for(int recordIndex = 0; recordIndex < printUtil.getRecordPerPartFile(); recordIndex++) { - if(dataIndex < dataObjectList.size()) { - DataObject dataObject = dataObjectList.get(dataIndex); - - if(formatType.equals("list")) { - InputStream attachFormatIS = new ClassPathResource(printUtil.getAttachFormatFilePath()).getInputStream(); - HWPFile attachFormatFile = HWPReader.fromInputStream(attachFormatIS); - - hwpFormatWriter.writeSingleDataInfo(null, attachFormatFile, dataObject, printUtil); - - AddUtil.insertTableInCell(attachFormatFile, resultFile, "내부"); - - } else { - - hwpFormatWriter.writeSingleDataInfo(resultFile, null, dataObject, printUtil); - } - - } - - if(formatType.equals("list")) { - dataIndex++; - } - - } - - if(!formatType.equals("list")) { - dataIndex++; - } - - HWPWriter.toFile(resultFile, resultHwpPath); - partFileList.add(resultHwpPath); - } - - //결과파일 병합 - if(partFileList.size() >= 2) { - String basePath = partFileList.get(0); - HWPFile baseFile = HWPReader.fromFile(basePath); - - - for(int i=2; i <= partFileList.size();i++) { - String attachPath = partFileList.get(i-1); - HWPFile attachFile = HWPReader.fromFile(attachPath); - AddUtil.appendToLast(attachFile, baseFile); - } - - HWPWriter.toFile(baseFile, basePath); - - for(int i=2; i <= partFileList.size();i++) { - (new File(partFileList.get(i-1))).delete(); - } - } - - String downlaodFileName = printUtil.getFormatKorName()+"_"+printUtil.getPrintRequestDt()+".hwp"; - result.put("filename", downlaodFileName); - String filePath = partFileList.get(0); - result.put("filePath", filePath); - result.put("file", new File(filePath)); - - } catch (Exception e) { - e.printStackTrace(); - throw new RuntimeException("한글 파일 출력 중 오류가 발생하였습니다."); - - } - - return result; - } @Override public Map makePdfFile(String formatType, String formatName, PrintOption printOption, String[] crdnIds) { diff --git a/src/main/java/cokr/xit/fims/sprt/web/Sprt01Controller.java b/src/main/java/cokr/xit/fims/sprt/web/Sprt01Controller.java index d3841896..968cc252 100644 --- a/src/main/java/cokr/xit/fims/sprt/web/Sprt01Controller.java +++ b/src/main/java/cokr/xit/fims/sprt/web/Sprt01Controller.java @@ -18,6 +18,9 @@ import org.springframework.web.servlet.ModelAndView; import com.fasterxml.jackson.core.type.TypeReference; import cokr.xit.base.code.CommonCode; +import cokr.xit.base.file.hwp.HWPWriter; +import cokr.xit.base.file.service.FileQuery; +import cokr.xit.base.file.service.bean.FileBean; import cokr.xit.base.file.xls.XLSWriter; import cokr.xit.base.file.xls.XLSWriter.CellDef; import cokr.xit.base.file.xls.XLSWriter.Styler; @@ -25,8 +28,16 @@ import cokr.xit.base.user.ManagedUser; import cokr.xit.base.user.dao.UserMapper; import cokr.xit.base.web.ApplicationController; import cokr.xit.fims.cmmn.CmmnUtil; +import cokr.xit.fims.cmmn.Print; +import cokr.xit.fims.cmmn.hwp.format.CrdnConfirm; +import cokr.xit.fims.cmmn.hwp.format.CrdnList; +import cokr.xit.fims.cmmn.hwp.format.RcvmtConfirm; +import cokr.xit.fims.cmmn.hwp.format.ReportOnClaims; +import cokr.xit.fims.cmmn.hwp.format.RequestForDelivery; import cokr.xit.fims.cmmn.service.bean.StngBean; import cokr.xit.fims.crdn.Crdn; +import cokr.xit.fims.crdn.CrdnQuery; +import cokr.xit.fims.crdn.dao.CrdnListMapper; import cokr.xit.fims.crdn.dao.GlobalStngMapper; import cokr.xit.fims.mngt.service.bean.FactionBean; import cokr.xit.fims.mngt.service.bean.TaskBean; @@ -35,9 +46,11 @@ import cokr.xit.fims.sprt.OtptForm; import cokr.xit.fims.sprt.OtptStngQuery; import cokr.xit.fims.sprt.PrintOption; import cokr.xit.fims.sprt.SprtQuery; +import cokr.xit.fims.sprt.dao.IntegrationSearchMapper; import cokr.xit.fims.sprt.service.IntegrationSearchService; import cokr.xit.fims.sprt.service.bean.OtptStngBean; import cokr.xit.fims.stat.dao.StatMapper; +import cokr.xit.foundation.UserInfo; import cokr.xit.foundation.data.DataObject; /**통합 조회 서비스의 웹 컨트롤러 @@ -98,6 +111,9 @@ public class Sprt01Controller extends ApplicationController { @Resource(name="otptStngBean") protected OtptStngBean otptStngBean; + @Resource(name = "fileBean") + private FileBean fileBean; + @Resource(name = "taskBean") private TaskBean taskBean; @@ -107,6 +123,12 @@ public class Sprt01Controller extends ApplicationController { @Resource(name = "stngBean") private StngBean stngBean; + @Resource(name = "crdnListMapper") + private CrdnListMapper crdnListMapper; + + @Resource(name = "integrationSearchMapper") + private IntegrationSearchMapper integrationSearchMapper; + /**통합 조회 메인화면(fims/sprt/sprt01/010-main)을 연다. * * @return /fims/sprt/sprt01010 @@ -420,7 +442,20 @@ public class Sprt01Controller extends ApplicationController { PrintOption printOption = new PrintOption(); printOption.setPrivateInfoYn(privateInfoYn); - Map result = integrationSearchService.makeFileFromHwpFormat("list", "crdnList", printOption ,crdnIds); + CrdnQuery query = new CrdnQuery(); + query.setCrdnIds(crdnIds); + List DataObjectList = crdnListMapper.selectCrackdownList(query); + HWPWriter hwpWriter = new HWPWriter(); + UserInfo userInfo = currentUser(); + factionBean.initUserInfo(userInfo); + Print print = new Print(); + print.setPrintRequestUserInfo(userInfo); + + DataObject sggStngInfo = stngBean.getStng("sgg"); + DataObject deptStngInfo = stngBean.getStng("dept"); + + hwpWriter.setFormat(new CrdnList()); + Map result = hwpWriter.makeFileFromHwpFormat("list", print, printOption, DataObjectList); ModelAndView mav = new ModelAndView("downloadView"); mav.addAllObjects(result); @@ -434,7 +469,40 @@ public class Sprt01Controller extends ApplicationController { PrintOption printOption = new PrintOption(); - Map result = integrationSearchService.makeFileFromHwpFormat("info", "crdnConfirm", printOption, crdnIds); + CrdnQuery query = new CrdnQuery(); + query.setCrdnIds(crdnIds); + List dataObjectList = crdnListMapper.selectCrackdownList(query); + + for(int i=0; i < dataObjectList.size(); i++) { + DataObject dataObject = dataObjectList.get(i); + String crndId = dataObject.string("CRDN_ID"); + + FileQuery fileQuery = new FileQuery(); + fileQuery.setInfoType(Crdn.INF_TYPE); + fileQuery.setInfoKeys(crndId); + List fileInfoList = fileBean.getFileList(fileQuery); + if(fileInfoList != null && fileInfoList.size() > 0) { + dataObject.set("PHOTO1", fileInfoList.get(0).string("URL")); + if(fileInfoList.size() >= 2) + dataObject.set("PHOTO2", fileInfoList.get(1).string("URL")); + if(fileInfoList.size() >= 3) + dataObject.set("PHOTO3", fileInfoList.get(2).string("URL")); + if(fileInfoList.size() >= 4) + dataObject.set("PHOTO4", fileInfoList.get(3).string("URL")); + } + + } + HWPWriter hwpWriter = new HWPWriter(); + UserInfo userInfo = currentUser(); + factionBean.initUserInfo(userInfo); + Print print = new Print(); + print.setPrintRequestUserInfo(userInfo); + + DataObject sggStngInfo = stngBean.getStng("sgg"); + DataObject deptStngInfo = stngBean.getStng("dept"); + + hwpWriter.setFormat(new CrdnConfirm()); + Map result = hwpWriter.makeFileFromHwpFormat("info", print, printOption, dataObjectList); ModelAndView mav = new ModelAndView("downloadView"); mav.addAllObjects(result); @@ -473,7 +541,26 @@ public class Sprt01Controller extends ApplicationController { printOption.setGlobalVariable(globalVariable); - Map result = integrationSearchService.makeFileFromHwpFormat("list", "requestForDelivery", printOption, crdnIds); + SprtQuery sprtQuery = new SprtQuery(); + sprtQuery.setCrdnIds(crdnIds); + List dataObjectList = integrationSearchMapper.selectIntegrationDataList(sprtQuery); + + HWPWriter hwpWriter = new HWPWriter(); + UserInfo userInfo = currentUser(); + factionBean.initUserInfo(userInfo); + Print print = new Print(); + print.setPrintRequestUserInfo(userInfo); + + DataObject sggStngInfo = stngBean.getStng("sgg"); + DataObject deptStngInfo = stngBean.getStng("dept"); + Map globalVariable2 = printOption.getGlobalVariable(); + globalVariable2.put("dtbnBankNm", deptStngInfo.string("DTBN_BANK_NM")); + globalVariable2.put("dtbnActno", deptStngInfo.string("DTBN_ACTNO")); + globalVariable2.put("offcsFilePath", sggStngInfo.string("OFFCS_FILE_PATH")); + printOption.setGlobalVariable(globalVariable2); + + hwpWriter.setFormat(new RequestForDelivery()); + Map result = hwpWriter.makeFileFromHwpFormat("list", print, printOption, dataObjectList); mav.addAllObjects(result); return mav; } @@ -485,7 +572,7 @@ public class Sprt01Controller extends ApplicationController { ModelAndView mav = new ModelAndView("downloadView"); Map globalVariable = new HashMap(); - System.out.println("json확인"); + System.out.println(globalVariableInfo); DataObject dataObject = fromJson(globalVariableInfo, DataObject.class); @@ -496,8 +583,31 @@ public class Sprt01Controller extends ApplicationController { printOption.setGlobalVariable(globalVariable); + SprtQuery sprtQuery = new SprtQuery(); + sprtQuery.setCrdnIds(crdnIds); + List dataObjectList = integrationSearchMapper.selectIntegrationDataList(sprtQuery); + + + HWPWriter hwpWriter = new HWPWriter(); + UserInfo userInfo = currentUser(); + factionBean.initUserInfo(userInfo); + Print print = new Print(); + print.setPrintRequestUserInfo(userInfo); + + DataObject sggStngInfo = stngBean.getStng("sgg"); + DataObject deptStngInfo = stngBean.getStng("dept"); + Map globalVariable2 = printOption.getGlobalVariable(); + String deptNm = (String) hwpWriter.getPrintRequestUserInfo().getInfo().get("deptNm"); + String deptAddr = sggStngInfo.string("INST_FULL_ADDR") + " " + deptNm; + globalVariable2.put("deptAddr", deptAddr); + globalVariable2.put("deptTelno", deptStngInfo.string("DEPT_TELNO")); + globalVariable2.put("deptFxno", deptStngInfo.string("DEPT_FXNO")); + globalVariable2.put("offcsFilePath", sggStngInfo.string("OFFCS_FILE_PATH")); + printOption.setGlobalVariable(globalVariable2); + + hwpWriter.setFormat(new ReportOnClaims()); + Map result = hwpWriter.makeFileFromHwpFormat("list", print, printOption, dataObjectList); - Map result = integrationSearchService.makeFileFromHwpFormat("list", "reportOnClaims", printOption, crdnIds); mav.addAllObjects(result); return mav; @@ -511,7 +621,22 @@ public class Sprt01Controller extends ApplicationController { PrintOption printOption = new PrintOption(); printOption.setGlobalVariable(new HashMap()); - Map result = integrationSearchService.makeFileFromHwpFormat("info", "rcvmtConfirm", printOption, crdnIds); + + SprtQuery sprtQuery = new SprtQuery(); + sprtQuery.setCrdnIds(crdnIds); + List dataObjectList = integrationSearchMapper.selectIntegrationDataList(sprtQuery); + + HWPWriter hwpWriter = new HWPWriter(); + UserInfo userInfo = currentUser(); + factionBean.initUserInfo(userInfo); + Print print = new Print(); + print.setPrintRequestUserInfo(userInfo); + + DataObject sggStngInfo = stngBean.getStng("sgg"); + DataObject deptStngInfo = stngBean.getStng("dept"); + + hwpWriter.setFormat(new RcvmtConfirm()); + Map result = hwpWriter.makeFileFromHwpFormat("info", print, printOption, dataObjectList); mav.addAllObjects(result); return mav; diff --git a/src/main/webapp/WEB-INF/jsp/fims/sprt/sprt01110-info.jsp b/src/main/webapp/WEB-INF/jsp/fims/sprt/sprt01110-info.jsp index b29e8ad3..f964991d 100644 --- a/src/main/webapp/WEB-INF/jsp/fims/sprt/sprt01110-info.jsp +++ b/src/main/webapp/WEB-INF/jsp/fims/sprt/sprt01110-info.jsp @@ -113,22 +113,12 @@ $(document).ready(function(){ } $P.fnMakeCrdnConfirmFile = () => { - ajax.post({ - url : wctx.url("/sprt/sprt01/110/makeCrdnConfirmFileFromHwpFormat.do"), - data : { - crdnIds : $P.crdnIds.join(",") - }, - success : (resp) => { - if(resp.filePath != null && resp.filePath != ""){ - var a = document.createElement("a"); - a.href = resp.filePath; - a.download = resp.fileName; - document.getElementById("tempArea--${pageName}").appendChild(a); - a.click(); - document.getElementById("tempArea--${pageName}").removeChild(a); - } - } + var url = wctx.url("/sprt/sprt01/110/makeCrdnConfirmFileFromHwpFormat.do"); + var parameter = toQuery({ + crdnIds : $P.crdnIds.join(",") }); + + document.location.href = url + "?" + parameter; } $P.fnExcelDown = () => {