From 5e40fc10d90a12c5886b14672ff3c71e0ca7f7e7 Mon Sep 17 00:00:00 2001 From: leebeomjun Date: Mon, 27 Nov 2023 13:05:26 +0900 Subject: [PATCH] =?UTF-8?q?=ED=95=9C=EA=B8=80=20=EC=B6=9C=EB=A0=A5=20pdf?= =?UTF-8?q?=EC=B6=9C=EB=A0=A5=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/cokr/xit/fims/cmmn/PrintUtil.java | 62 +++ .../xit/fims/cmmn/hwp/HWPFormatWriter.java | 33 ++ .../cokr/xit/fims/cmmn/hwp/HWPPrintUtil.java | 376 ++---------------- .../xit/fims/cmmn/hwp/format/CrdnConfirm.java | 85 ++++ .../xit/fims/cmmn/hwp/format/CrdnList.java | 86 ++++ .../fims/cmmn/hwp/format/RcvmtConfirm.java | 63 +++ .../fims/cmmn/hwp/format/ReportOnClaims.java | 92 +++++ .../cmmn/hwp/format/RequestForDelivery.java | 90 +++++ .../cokr/xit/fims/cmmn/pdf/PDFCoordinate.java | 21 + .../cokr/xit/fims/cmmn/pdf/PDFPrintUtil.java | 81 +++- .../xit/fims/cmmn/pdf/format/Advntce.java | 5 + .../cokr/xit/fims/sprt/OtptStngQuery.java | 33 ++ .../java/cokr/xit/fims/sprt/PrintOption.java | 14 +- .../xit/fims/sprt/dao/OtptStngMapper.java | 20 + .../sprt/service/bean/Sprt01ServiceBean.java | 199 ++++++++- .../xit/fims/sprt/web/Sprt01Controller.java | 8 +- .../cokr/xit/fims/task/web/CmnController.java | 8 +- .../sql/mapper/fims/sprt/otptStng-mapper.xml | 29 ++ .../WEB-INF/jsp/fims/sprt/sprt01010-main.jsp | 12 + .../WEB-INF/jsp/fims/sprt/sprt01140-info.jsp | 22 +- 20 files changed, 981 insertions(+), 358 deletions(-) create mode 100644 src/main/java/cokr/xit/fims/cmmn/PrintUtil.java create mode 100644 src/main/java/cokr/xit/fims/cmmn/hwp/HWPFormatWriter.java create mode 100644 src/main/java/cokr/xit/fims/cmmn/hwp/format/CrdnConfirm.java create mode 100644 src/main/java/cokr/xit/fims/cmmn/hwp/format/CrdnList.java create mode 100644 src/main/java/cokr/xit/fims/cmmn/hwp/format/RcvmtConfirm.java create mode 100644 src/main/java/cokr/xit/fims/cmmn/hwp/format/ReportOnClaims.java create mode 100644 src/main/java/cokr/xit/fims/cmmn/hwp/format/RequestForDelivery.java create mode 100644 src/main/java/cokr/xit/fims/cmmn/pdf/PDFCoordinate.java create mode 100644 src/main/java/cokr/xit/fims/cmmn/pdf/format/Advntce.java create mode 100644 src/main/java/cokr/xit/fims/sprt/OtptStngQuery.java create mode 100644 src/main/java/cokr/xit/fims/sprt/dao/OtptStngMapper.java create mode 100644 src/main/resources/sql/mapper/fims/sprt/otptStng-mapper.xml diff --git a/src/main/java/cokr/xit/fims/cmmn/PrintUtil.java b/src/main/java/cokr/xit/fims/cmmn/PrintUtil.java new file mode 100644 index 00000000..e71e4e79 --- /dev/null +++ b/src/main/java/cokr/xit/fims/cmmn/PrintUtil.java @@ -0,0 +1,62 @@ +package cokr.xit.fims.cmmn; + +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import cokr.xit.fims.sprt.PrintOption; +import cokr.xit.foundation.UserInfo; +import cokr.xit.foundation.data.DataObject; + +public class PrintUtil { + + public PrintUtil(){ + SimpleDateFormat ymdhmsFormat = new SimpleDateFormat("yyyyMMddHHmmss"); + this.printRequestDt = ymdhmsFormat.format(new Date()); + } + + protected int fileNameIndex = 0; + + protected String printRequestDt; + + protected UserInfo printRequestUserInfo; + + public UserInfo getPrintRequestUserInfo() { + return this.printRequestUserInfo; + }; + + public void setPrintRequestUserInfo(UserInfo printRequestUserInfo) { + this.printRequestUserInfo = printRequestUserInfo; + }; + + public float mmToPt(float mm) { + return mm * 2.83465f; + } + + + public int getTotalDataCount(List dataObjectList) { + int totalDataCount = dataObjectList.size(); + return totalDataCount; + } + + public boolean getPrivateInfoYn(PrintOption printOption) { + + boolean privateInfoYn = true; + if(printOption != null && printOption.getPrivateInfoYn() != null && printOption.getPrivateInfoYn().equals("N")) { + privateInfoYn = false; + } + return privateInfoYn; + } + + public Map getGlobalVariable(PrintOption printOption) { + + Map map = new HashMap(); + if(printOption != null && printOption.getGlobalVariable() != null && !printOption.getGlobalVariable().isEmpty()) { + map = printOption.getGlobalVariable(); + } + return map; + } + +} diff --git a/src/main/java/cokr/xit/fims/cmmn/hwp/HWPFormatWriter.java b/src/main/java/cokr/xit/fims/cmmn/hwp/HWPFormatWriter.java new file mode 100644 index 00000000..e6f49eb1 --- /dev/null +++ b/src/main/java/cokr/xit/fims/cmmn/hwp/HWPFormatWriter.java @@ -0,0 +1,33 @@ +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); + + /** 한글파일 공통사항 적용 + * @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/HWPPrintUtil.java b/src/main/java/cokr/xit/fims/cmmn/hwp/HWPPrintUtil.java index 0a39d1d8..4a3230dc 100644 --- a/src/main/java/cokr/xit/fims/cmmn/hwp/HWPPrintUtil.java +++ b/src/main/java/cokr/xit/fims/cmmn/hwp/HWPPrintUtil.java @@ -4,75 +4,98 @@ import java.io.File; import java.io.InputStream; import java.text.SimpleDateFormat; import java.util.Date; -import java.util.List; -import java.util.Map; import org.springframework.core.io.ClassPathResource; -import cokr.xit.fims.cmmn.CmmnUtil; -import cokr.xit.fims.cmmn.FactionUtil; -import cokr.xit.fims.sprt.PrintOption; -import cokr.xit.foundation.UserInfo; -import cokr.xit.foundation.data.DataFormat; -import cokr.xit.foundation.data.DataObject; +import cokr.xit.fims.cmmn.PrintUtil; import kr.dogfoot.hwplib.object.HWPFile; import kr.dogfoot.hwplib.reader.HWPReader; import kr.dogfoot.hwplib.writer.HWPWriter; -public class HWPPrintUtil { +public class HWPPrintUtil extends PrintUtil { private String formatType; + private String formatName; + private String formatKorName; - private String printRequestDt; + private int recordPerPartFile; private String baseFormatFilePath; - private String attachFormatFilePath; - private UserInfo printRequestUserInfo; + private String attachFormatFilePath; private int totalPartFileCount; - private int fileNameIndex; - public String getFormatType() { return this.formatType; } + 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 String getPrintRequestDt() { return this.printRequestDt; } - public UserInfo getPrintRequestUserInfo() { - return this.printRequestUserInfo; - }; + public void setPrintRequestDt(String printRequestDt) { + this.printRequestDt = printRequestDt; + } public int getRecordPerPartFile() { return this.recordPerPartFile; } + public void setRecordPerPartFile(int recordPerPartFile) { + this.recordPerPartFile = recordPerPartFile; + } + public int getTotalPartFileCount() { return this.totalPartFileCount; } + public void setTotalPartFileCount(int totalPartFileCount) { + this.totalPartFileCount = totalPartFileCount; + } + public String getBaseFormatFilePath() { return this.baseFormatFilePath; } + public void setBaseFormatFilePath(String baseFormatFilePath) { + this.baseFormatFilePath = baseFormatFilePath; + } + public String getAttachFormatFilePath() { return this.attachFormatFilePath; } + public void setAttachFormatFilePath(String attachFormatFilePath) { + this.attachFormatFilePath = attachFormatFilePath; + } + /** 신규로 생성될 한글 파일 건수를 계산한다. + * @param 총 데이터 건수 + * @return + */ public void calcTotalPartFileCount(int totalDataCount) { if(this.formatType.equals("list")) { @@ -96,70 +119,6 @@ public class HWPPrintUtil { } - public void setPrintRequestUserInfo(UserInfo printRequestUserInfo) { - this.printRequestUserInfo = printRequestUserInfo; - }; - - public void setting(String formatType, String formatName) { - this.formatType = formatType; - this.formatName = formatName; - SimpleDateFormat ymdhmsFormat = new SimpleDateFormat("yyyyMMddHHmmss"); - this.printRequestDt = ymdhmsFormat.format(new Date()); - - if(!formatType.equals("list")) { - this.recordPerPartFile = 1; - } else { - switch (formatName) { - case "crdnList": { - this.recordPerPartFile = 6; - break; - } - case "requestForDelivery": { - this.recordPerPartFile = 7; - break; - } - case "reportOnClaims": { - this.recordPerPartFile = 7; - break; - } - } - } - - switch (formatName) { - case "crdnConfirm": { - this.formatKorName = "단속확인서"; - this.baseFormatFilePath = "format/crdnConfirm.hwp"; - this.attachFormatFilePath = ""; - break; - } - case "crdnList": { - this.formatKorName = "단속내역서"; - this.baseFormatFilePath = "format/crdnList_root.hwp"; - this.attachFormatFilePath = "format/crdnList_inner.hwp"; - break; - } - case "requestForDelivery": { - this.formatKorName = "교부청구서"; - this.baseFormatFilePath = "format/requestForDelivery_root.hwp"; - this.attachFormatFilePath = "format/requestForDelivery_inner.hwp"; - break; - } - case "reportOnClaims": { - this.formatKorName = "채권신고서"; - this.baseFormatFilePath = "format/reportOnClaims_root.hwp"; - this.attachFormatFilePath = "format/reportOnClaims_inner.hwp"; - break; - } - case "rcvmtConfirm": { - this.formatKorName = "납부확인서"; - this.baseFormatFilePath = "format/rcvmtConfirm.hwp"; - this.attachFormatFilePath = ""; - break; - } - } - - } - /**한글 포맷 파일을 복사하여 새 한글파일을 생성한다. * @param formatFile 한글 포맷 파일 * @return 새 파일 경로 @@ -194,259 +153,4 @@ public class HWPPrintUtil { } - /**한글 파일의 공통정보를 입력한다. - * @param dataObjectList 데이터목록, baseFile 한글파일 - * @return - */ - public void setGlobalInfo(PrintOption printOption, List dataObjectList, HWPFile baseFile) { - int totalDataCount = dataObjectList.size(); - - boolean privateInfoYn = true; - if(printOption.getPrivateInfoYn() != null && printOption.getPrivateInfoYn().equals("N")) { - privateInfoYn = false; - } - - Map globalVariable = printOption.getGlobalVariable(); - - if(this.formatName.equals("crdnList")){ - - String globalRtpyrNm = dataObjectList.get(0).string("RTPYR_NM"); - String globalRtpyrNo = dataObjectList.get(0).string("RTPYR_NO"); - String globalRtpyrFullAddr = dataObjectList.get(0).string("RTPYR_FULL_ADDR"); - int globalTotalAmount = dataObjectList.stream().mapToInt(i -> i.number("LEVY_AMT").intValue()).sum(); - - //상단 - ClickHereEditor baseFileEditor = new ClickHereEditor(baseFile); - baseFileEditor.set("성명", globalRtpyrNm); - if(privateInfoYn) { - baseFileEditor.set("주민번호", globalRtpyrNo); - } else { - baseFileEditor.set("주민번호", "*************"); - } - - baseFileEditor.set("주소", globalRtpyrFullAddr); - baseFileEditor.set("총건수", CmmnUtil.addCommaToNumber(totalDataCount)); - baseFileEditor.set("총금액", CmmnUtil.addCommaToNumber(globalTotalAmount)); - baseFileEditor.set("출력일시", CmmnUtil.yyyy_mm_dd_hh_mm_ss(this.printRequestDt)); - - String instNm = (String) this.printRequestUserInfo.getInfo().get("instNm"); - instNm = FactionUtil.getLastWord(instNm); - instNm = FactionUtil.getInstituteLeader(instNm, false); - baseFileEditor.set("발신", instNm); - } - else if(this.formatName.equals("requestForDelivery")){ - - ClickHereEditor baseFileEditor = new ClickHereEditor(baseFile); - - baseFileEditor.set("문서번호", globalVariable.get("docNo")); - baseFileEditor.set("사건번호", globalVariable.get("caseNo")); - baseFileEditor.set("수신", globalVariable.get("receiver")); - baseFileEditor.set("체납자성명", globalVariable.get("rtpyrNm")); - baseFileEditor.set("체납자번호", globalVariable.get("rtpyrNo")); - baseFileEditor.set("차량번호", globalVariable.get("vhrno")); - baseFileEditor.set("주소", globalVariable.get("rtpyrFullAddr")); - - int sumOfList = dataObjectList.stream().mapToInt(item -> item.number("SUM_AMT").intValue()).sum(); - - baseFileEditor.set("합계금액", CmmnUtil.addCommaToNumber(sumOfList)); - baseFileEditor.set("교부청구금액", CmmnUtil.addCommaToNumber(sumOfList)); - baseFileEditor.set("교부청구금액한글", CmmnUtil.convertNumberToHangul(sumOfList)); - - baseFileEditor.set("개설은행", globalVariable.get("dtbnBankNm")); - baseFileEditor.set("계좌번호", globalVariable.get("dtbnActno")); - - String instNm = (String) this.printRequestUserInfo.getInfo().get("instNm"); - String deptNm = (String) this.printRequestUserInfo.getInfo().get("deptNm"); - baseFileEditor.set("예금주", instNm + " " + deptNm); - - String printRequestYmd = this.printRequestDt.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); - - instNm = FactionUtil.getLastWord(instNm); - instNm = FactionUtil.getInstituteLeader(instNm, false); - baseFileEditor.set("발신", instNm); - - try { - InsertingImageCell.IMPL_InsertPicture(baseFile, "직인", globalVariable.get("offcsFilePath")); - } catch (Exception e) { - throw new RuntimeException("한글 파일 출력 중 오류가 발생하였습니다."); - } - } - else if(this.formatName.equals("reportOnClaims")){ - - ClickHereEditor baseFileEditor = new ClickHereEditor(baseFile); - - baseFileEditor.set("주소", globalVariable.get("deptAddr")); - baseFileEditor.set("전화", globalVariable.get("deptTelno")); - baseFileEditor.set("팩스", globalVariable.get("deptFxno")); - baseFileEditor.set("담당자", this.printRequestUserInfo.getName()); - - baseFileEditor.set("사건번호", globalVariable.get("caseNo")); - baseFileEditor.set("체납자성명", globalVariable.get("rtpyrNm")); - baseFileEditor.set("체납자번호", globalVariable.get("rtpyrNo")); - baseFileEditor.set("체납자주소", globalVariable.get("rtpyrFullAddr")); - - int sumOfList = dataObjectList.stream().mapToInt(item -> item.number("SUM_AMT").intValue()).sum(); - - baseFileEditor.set("채권청구액", CmmnUtil.addCommaToNumber(sumOfList)); - baseFileEditor.set("합계금액", CmmnUtil.addCommaToNumber(sumOfList)); - baseFileEditor.set("합계금액한글", CmmnUtil.convertNumberToHangul(sumOfList)); - - String printRequestYmd = this.printRequestDt.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) this.printRequestUserInfo.getInfo().get("instNm"); - instNm = FactionUtil.getLastWord(instNm); - instNm = FactionUtil.getInstituteLeader(instNm, false); - baseFileEditor.set("발신", instNm); - - try { - InsertingImageCell.IMPL_InsertPicture(baseFile, "직인", globalVariable.get("offcsFilePath")); - } catch (Exception e) { - e.printStackTrace(); - throw new RuntimeException("한글 파일 출력 중 오류가 발생하였습니다."); - } - } - } - - /**한글파일 서식에 대해 데이터 건별로 처리한다. - * @param dataObject 데이터, baseFile 한글파일 - * @return - */ - public void setBySingleData(PrintOption printOption, DataObject dataObject, HWPFile baseFile) { - try { - if(this.formatType.equals("list")) { - InputStream attachFormatIS = new ClassPathResource(this.getAttachFormatFilePath()).getInputStream(); - HWPFile attachFormatFile = HWPReader.fromInputStream(attachFormatIS); - ClickHereEditor attachFileEditor = new ClickHereEditor(attachFormatFile); - - if(this.formatName.equals("crdnList")){ - - attachFileEditor.set("과태료", dataObject.string("TASK_SE_NM")); - attachFileEditor.set("시군구명", dataObject.string("SGG_NM")); - String crdnYmdTm = dataObject.string("CRDN_YMD_TM"); - crdnYmdTm = CmmnUtil.yyyy_mm_dd_hh_mm_ss(crdnYmdTm); - attachFileEditor.set("단속일시", crdnYmdTm); - attachFileEditor.set("단속장소", dataObject.string("CRDN_PLC")); - attachFileEditor.set("차량번호", dataObject.string("VHRNO")); - attachFileEditor.set("대체차량번호", dataObject.string("RPM_SZR_VHRNO")); - attachFileEditor.set("고지번호", dataObject.string("GOJI_NO")); - attachFileEditor.set("금액", CmmnUtil.addCommaToNumber(dataObject.string("LEVY_AMT"))); - attachFileEditor.set("가상계좌번호", dataObject.string("VR_ACTNO")); - attachFileEditor.set("전자납부번호", dataObject.string("EPAYNO")); - attachFileEditor.set("처리상태", dataObject.string("CRDN_STTS_NM")); - String crdnSttsChgDt = dataObject.string("CRDN_STTS_CHG_DT"); - crdnSttsChgDt = DataFormat.yyyy_mm_dd(crdnSttsChgDt.substring(0, 8)); - attachFileEditor.set("처리일자", crdnSttsChgDt); - attachFileEditor.set("납부기한", DataFormat.yyyy_mm_dd(dataObject.string("DUDT_YMD"))); - attachFileEditor.set("수납일자", DataFormat.yyyy_mm_dd(dataObject.string("RCVMT_YMD"))); - } - else if(this.formatName.equals("requestForDelivery")){ - - attachFileEditor.set("징수과목", dataObject.string("TXITM_NM")); - attachFileEditor.set("고지번호", dataObject.string("GOJI_NO")); - attachFileEditor.set("과태료계", CmmnUtil.addCommaToNumber(dataObject.string("SUM_AMT"))); - attachFileEditor.set("법정기일", DataFormat.yyyy_mm_dd(dataObject.string("DUDT_YMD"))); - - } - else if(this.formatName.equals("reportOnClaims")){ - - attachFileEditor.set("년도", dataObject.string("FYR")); - attachFileEditor.set("과세번호", dataObject.string("GOJI_NO")); - attachFileEditor.set("법정기일", DataFormat.yyyy_mm_dd(dataObject.string("DUDT_YMD"))); - attachFileEditor.set("세목", dataObject.string("TXITM_NM")); - attachFileEditor.set("세액", CmmnUtil.addCommaToNumber(dataObject.string("LEVY_PCPTAX"))); - attachFileEditor.set("가산금", CmmnUtil.addCommaToNumber(dataObject.string("LEVY_ADAMT"))); - attachFileEditor.set("합계", CmmnUtil.addCommaToNumber(dataObject.string("SUM_AMT"))); - } - - - AddUtil.insertTableInCell(attachFormatFile, baseFile, "내부"); - - - } else { - ClickHereEditor baseFileEditor = new ClickHereEditor(baseFile); - - if(this.formatName.equals("crdnConfirm")){ - - baseFileEditor.set("과태료", dataObject.string("TASK_SE_NM")); - baseFileEditor.set("차량번호", dataObject.string("VHRNO")); - String crdnYmdTm = dataObject.string("CRDN_YMD_TM"); - crdnYmdTm = CmmnUtil.yyyy_mm_dd_hh_mm_ss(crdnYmdTm); - baseFileEditor.set("단속일시", crdnYmdTm); - - baseFileEditor.set("위반내용", dataObject.string("VLTN_ARTCL")); - baseFileEditor.set("단속장소", dataObject.string("CRDN_PLC")); - baseFileEditor.set("단속동", dataObject.string("CRDN_STDG_NM")); - baseFileEditor.set("단속조", dataObject.string("TEAM_NM")); - baseFileEditor.set("소유자", dataObject.string("RTPYR_NM")); - baseFileEditor.set("주소", dataObject.string("RTPYR_FULL_ADDR")); - baseFileEditor.set("우편번호", dataObject.string("RTPYR_ZIP")); - - String printRequestYmd = this.printRequestDt.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) this.printRequestUserInfo.getInfo().get("instNm"); - instNm = FactionUtil.getInstituteLeader(instNm, false); - baseFileEditor.set("발신", instNm); - - if(!dataObject.string("PHOTO1").equals("")) { - InsertingImageCell.IMPL_InsertPicture(baseFile, "왼쪽위사진", dataObject.string("PHOTO1")); - } - if(!dataObject.string("PHOTO2").equals("")) { - InsertingImageCell.IMPL_InsertPicture(baseFile, "오른쪽위사진", dataObject.string("PHOTO2")); - } - if(!dataObject.string("PHOTO3").equals("")) { - InsertingImageCell.IMPL_InsertPicture(baseFile, "왼쪽아래사진", dataObject.string("PHOTO3")); - } - if(!dataObject.string("PHOTO4").equals("")) { - InsertingImageCell.IMPL_InsertPicture(baseFile, "오른쪽아래사진", dataObject.string("PHOTO4")); - } - - } - else if(this.formatName.equals("rcvmtConfirm")) { - - baseFileEditor.set("위반명1", dataObject.string("TASK_SE_NM")); - baseFileEditor.set("위반명2", dataObject.string("TASK_SE_NM")); - baseFileEditor.set("위반차량", dataObject.string("VHRNO")); - baseFileEditor.set("대체차량", dataObject.string("RPM_SZR_VHRNO")); - baseFileEditor.set("위반금액", CmmnUtil.addCommaToNumber(dataObject.string("FFNLG_AMT"))); - baseFileEditor.set("단속일자", DataFormat.yyyy_mm_dd(dataObject.string("CRDN_YMD"))); - baseFileEditor.set("단속장소", dataObject.string("CRDN_PLC")); - baseFileEditor.set("소유자", dataObject.string("RTPYR_NM")); - baseFileEditor.set("주민번호", dataObject.string("RTPYR_NO")); - baseFileEditor.set("주소", dataObject.string("RTPYR_FULL_ADDR")); - baseFileEditor.set("고지번호", dataObject.string("GOJI_NO")); - 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(this.printRequestDt)); - baseFileEditor.set("확인자", this.printRequestUserInfo.getName()); - - String instNm = (String) this.printRequestUserInfo.getInfo().get("instNm"); - instNm = FactionUtil.getInstituteLeader(instNm, false); - baseFileEditor.set("발신", instNm); - - } - - } - } catch(Exception e) { - e.printStackTrace(); - throw new RuntimeException("한글 파일 출력 중 오류가 발생하였습니다."); - } - - } - } 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 new file mode 100644 index 00000000..e799b7df --- /dev/null +++ b/src/main/java/cokr/xit/fims/cmmn/hwp/format/CrdnConfirm.java @@ -0,0 +1,85 @@ +package cokr.xit.fims.cmmn.hwp.format; + +import java.util.List; + +import cokr.xit.fims.cmmn.CmmnUtil; +import cokr.xit.fims.cmmn.FactionUtil; +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 CrdnConfirm implements HWPFormatWriter { + + @Override + public void setting(HWPPrintUtil hwpPrintUtil) { + hwpPrintUtil.setFormatName("crdnConfirm"); + hwpPrintUtil.setFormatKorName("단속확인서"); + + hwpPrintUtil.setFormatType("info"); + hwpPrintUtil.setRecordPerPartFile(1); + + hwpPrintUtil.setBaseFormatFilePath("format/crdnConfirm.hwp"); + hwpPrintUtil.setAttachFormatFilePath(""); + } + + @Override + public void writeGlobalInfo(HWPFile baseFile, List dataObjectList, PrintOption printOption, + HWPPrintUtil hwpPrintUtil) { + } + + @Override + public void writeSingleDataInfo(HWPFile baseFile, HWPFile attachFile, + DataObject dataObject, HWPPrintUtil hwpPrintUtil) { + + ClickHereEditor baseFileEditor = new ClickHereEditor(baseFile); + + baseFileEditor.set("과태료", dataObject.string("TASK_SE_NM")); + baseFileEditor.set("차량번호", dataObject.string("VHRNO")); + String crdnYmdTm = dataObject.string("CRDN_YMD_TM"); + crdnYmdTm = CmmnUtil.yyyy_mm_dd_hh_mm_ss(crdnYmdTm); + baseFileEditor.set("단속일시", crdnYmdTm); + + baseFileEditor.set("위반내용", dataObject.string("VLTN_ARTCL")); + baseFileEditor.set("단속장소", dataObject.string("CRDN_PLC")); + baseFileEditor.set("단속동", dataObject.string("CRDN_STDG_NM")); + baseFileEditor.set("단속조", dataObject.string("TEAM_NM")); + baseFileEditor.set("소유자", dataObject.string("RTPYR_NM")); + baseFileEditor.set("주소", dataObject.string("RTPYR_FULL_ADDR")); + baseFileEditor.set("우편번호", dataObject.string("RTPYR_ZIP")); + + String printRequestYmd = hwpPrintUtil.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"); + instNm = FactionUtil.getInstituteLeader(instNm, false); + baseFileEditor.set("발신", instNm); + + try { + if(!dataObject.string("PHOTO1").equals("")) { + InsertingImageCell.IMPL_InsertPicture(baseFile, "왼쪽위사진", dataObject.string("PHOTO1")); + } + if(!dataObject.string("PHOTO2").equals("")) { + InsertingImageCell.IMPL_InsertPicture(baseFile, "오른쪽위사진", dataObject.string("PHOTO2")); + } + if(!dataObject.string("PHOTO3").equals("")) { + InsertingImageCell.IMPL_InsertPicture(baseFile, "왼쪽아래사진", dataObject.string("PHOTO3")); + } + if(!dataObject.string("PHOTO4").equals("")) { + InsertingImageCell.IMPL_InsertPicture(baseFile, "오른쪽아래사진", dataObject.string("PHOTO4")); + } + } catch(Exception e) { + e.printStackTrace(); + throw new RuntimeException("한글 파일 출력 중 오류가 발생하였습니다."); + } + + } + +} 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 new file mode 100644 index 00000000..dca2d57e --- /dev/null +++ b/src/main/java/cokr/xit/fims/cmmn/hwp/format/CrdnList.java @@ -0,0 +1,86 @@ +package cokr.xit.fims.cmmn.hwp.format; + +import java.util.List; + +import cokr.xit.fims.cmmn.CmmnUtil; +import cokr.xit.fims.cmmn.FactionUtil; +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.DataFormat; +import cokr.xit.foundation.data.DataObject; +import kr.dogfoot.hwplib.object.HWPFile; + +public class CrdnList implements HWPFormatWriter { + + @Override + public void setting(HWPPrintUtil hwpPrintUtil) { + hwpPrintUtil.setFormatName("crdnList"); + hwpPrintUtil.setFormatKorName("단속내역서"); + + hwpPrintUtil.setFormatType("list"); + hwpPrintUtil.setRecordPerPartFile(6); + + hwpPrintUtil.setBaseFormatFilePath("format/crdnList_root.hwp"); + hwpPrintUtil.setAttachFormatFilePath("format/crdnList_inner.hwp"); + } + + @Override + public void writeGlobalInfo(HWPFile baseFile, List dataObjectList, + PrintOption printOption, HWPPrintUtil hwpPrintUtil + ) { + + ClickHereEditor baseFileEditor = new ClickHereEditor(baseFile); + + String globalRtpyrNm = dataObjectList.get(0).string("RTPYR_NM"); + String globalRtpyrNo = dataObjectList.get(0).string("RTPYR_NO"); + String globalRtpyrFullAddr = dataObjectList.get(0).string("RTPYR_FULL_ADDR"); + int globalTotalAmount = dataObjectList.stream().mapToInt(i -> i.number("LEVY_AMT").intValue()).sum(); + + //상단 + baseFileEditor.set("성명", globalRtpyrNm); + if(hwpPrintUtil.getPrivateInfoYn(printOption)) { + baseFileEditor.set("주민번호", globalRtpyrNo); + } else { + baseFileEditor.set("주민번호", "*************"); + } + + baseFileEditor.set("주소", globalRtpyrFullAddr); + baseFileEditor.set("총건수", CmmnUtil.addCommaToNumber(hwpPrintUtil.getTotalDataCount(dataObjectList))); + baseFileEditor.set("총금액", CmmnUtil.addCommaToNumber(globalTotalAmount)); + baseFileEditor.set("출력일시", CmmnUtil.yyyy_mm_dd_hh_mm_ss(hwpPrintUtil.getPrintRequestDt())); + + String instNm = (String) hwpPrintUtil.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) { + + ClickHereEditor attachFileEditor = new ClickHereEditor(attachFile); + + attachFileEditor.set("과태료", dataObject.string("TASK_SE_NM")); + attachFileEditor.set("시군구명", dataObject.string("SGG_NM")); + String crdnYmdTm = dataObject.string("CRDN_YMD_TM"); + crdnYmdTm = CmmnUtil.yyyy_mm_dd_hh_mm_ss(crdnYmdTm); + attachFileEditor.set("단속일시", crdnYmdTm); + attachFileEditor.set("단속장소", dataObject.string("CRDN_PLC")); + attachFileEditor.set("차량번호", dataObject.string("VHRNO")); + attachFileEditor.set("대체차량번호", dataObject.string("RPM_SZR_VHRNO")); + attachFileEditor.set("고지번호", dataObject.string("GOJI_NO")); + attachFileEditor.set("금액", CmmnUtil.addCommaToNumber(dataObject.string("LEVY_AMT"))); + attachFileEditor.set("가상계좌번호", dataObject.string("VR_ACTNO")); + attachFileEditor.set("전자납부번호", dataObject.string("EPAYNO")); + attachFileEditor.set("처리상태", dataObject.string("CRDN_STTS_NM")); + String crdnSttsChgDt = dataObject.string("CRDN_STTS_CHG_DT"); + crdnSttsChgDt = DataFormat.yyyy_mm_dd(crdnSttsChgDt.substring(0, 8)); + attachFileEditor.set("처리일자", crdnSttsChgDt); + attachFileEditor.set("납부기한", DataFormat.yyyy_mm_dd(dataObject.string("DUDT_YMD"))); + attachFileEditor.set("수납일자", DataFormat.yyyy_mm_dd(dataObject.string("RCVMT_YMD"))); + } + +} 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 new file mode 100644 index 00000000..5db80456 --- /dev/null +++ b/src/main/java/cokr/xit/fims/cmmn/hwp/format/RcvmtConfirm.java @@ -0,0 +1,63 @@ +package cokr.xit.fims.cmmn.hwp.format; + +import java.util.List; + +import cokr.xit.fims.cmmn.CmmnUtil; +import cokr.xit.fims.cmmn.FactionUtil; +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.DataFormat; +import cokr.xit.foundation.data.DataObject; +import kr.dogfoot.hwplib.object.HWPFile; + +public class RcvmtConfirm implements HWPFormatWriter { + + @Override + public void setting(HWPPrintUtil hwpPrintUtil) { + hwpPrintUtil.setFormatName("rcvmtConfirm"); + hwpPrintUtil.setFormatKorName("납부확인서"); + + hwpPrintUtil.setFormatType("info"); + hwpPrintUtil.setRecordPerPartFile(1); + + hwpPrintUtil.setBaseFormatFilePath("format/rcvmtConfirm.hwp"); + hwpPrintUtil.setAttachFormatFilePath(""); + } + + @Override + public void writeGlobalInfo(HWPFile baseFile, List dataObjectList, PrintOption printOption, + HWPPrintUtil hwpPrintUtil) { + } + + @Override + public void writeSingleDataInfo(HWPFile baseFile, HWPFile attachFile, + DataObject dataObject, HWPPrintUtil hwpPrintUtil) { + + ClickHereEditor baseFileEditor = new ClickHereEditor(baseFile); + + baseFileEditor.set("위반명1", dataObject.string("TASK_SE_NM")); + baseFileEditor.set("위반명2", dataObject.string("TASK_SE_NM")); + baseFileEditor.set("위반차량", dataObject.string("VHRNO")); + baseFileEditor.set("대체차량", dataObject.string("RPM_SZR_VHRNO")); + baseFileEditor.set("위반금액", CmmnUtil.addCommaToNumber(dataObject.string("FFNLG_AMT"))); + baseFileEditor.set("단속일자", DataFormat.yyyy_mm_dd(dataObject.string("CRDN_YMD"))); + baseFileEditor.set("단속장소", dataObject.string("CRDN_PLC")); + baseFileEditor.set("소유자", dataObject.string("RTPYR_NM")); + baseFileEditor.set("주민번호", dataObject.string("RTPYR_NO")); + baseFileEditor.set("주소", dataObject.string("RTPYR_FULL_ADDR")); + baseFileEditor.set("고지번호", dataObject.string("GOJI_NO")); + 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()); + + String instNm = (String) hwpPrintUtil.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 new file mode 100644 index 00000000..d14cc2ac --- /dev/null +++ b/src/main/java/cokr/xit/fims/cmmn/hwp/format/ReportOnClaims.java @@ -0,0 +1,92 @@ +package cokr.xit.fims.cmmn.hwp.format; + +import java.util.List; +import java.util.Map; + +import cokr.xit.fims.cmmn.CmmnUtil; +import cokr.xit.fims.cmmn.FactionUtil; +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.DataFormat; +import cokr.xit.foundation.data.DataObject; +import kr.dogfoot.hwplib.object.HWPFile; + +public class ReportOnClaims implements HWPFormatWriter { + + @Override + public void setting(HWPPrintUtil hwpPrintUtil) { + hwpPrintUtil.setFormatName("채권신고서"); + hwpPrintUtil.setFormatKorName("reportOnClaims"); + + hwpPrintUtil.setFormatType("list"); + hwpPrintUtil.setRecordPerPartFile(7); + + hwpPrintUtil.setBaseFormatFilePath("format/reportOnClaims_root.hwp"); + hwpPrintUtil.setAttachFormatFilePath("format/reportOnClaims_inner.hwp"); + } + + @Override + public void writeGlobalInfo(HWPFile baseFile, List dataObjectList, PrintOption printOption, + HWPPrintUtil hwpPrintUtil) { + + Map globalVariable = hwpPrintUtil.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("사건번호", globalVariable.get("caseNo")); + baseFileEditor.set("체납자성명", globalVariable.get("rtpyrNm")); + baseFileEditor.set("체납자번호", globalVariable.get("rtpyrNo")); + baseFileEditor.set("체납자주소", globalVariable.get("rtpyrFullAddr")); + + int sumOfList = dataObjectList.stream().mapToInt(item -> item.number("SUM_AMT").intValue()).sum(); + + baseFileEditor.set("채권청구액", CmmnUtil.addCommaToNumber(sumOfList)); + baseFileEditor.set("합계금액", CmmnUtil.addCommaToNumber(sumOfList)); + baseFileEditor.set("합계금액한글", CmmnUtil.convertNumberToHangul(sumOfList)); + + String printRequestYmd = hwpPrintUtil.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"); + instNm = FactionUtil.getLastWord(instNm); + instNm = FactionUtil.getInstituteLeader(instNm, false); + baseFileEditor.set("발신", instNm); + + try { + InsertingImageCell.IMPL_InsertPicture(baseFile, "직인", globalVariable.get("offcsFilePath")); + } catch (Exception e) { + e.printStackTrace(); + throw new RuntimeException("한글 파일 출력 중 오류가 발생하였습니다."); + } + + } + + @Override + public void writeSingleDataInfo(HWPFile baseFile, HWPFile attachFile, + DataObject dataObject, HWPPrintUtil hwpPrintUtil) { + + ClickHereEditor attachFileEditor = new ClickHereEditor(attachFile); + + attachFileEditor.set("년도", dataObject.string("FYR")); + attachFileEditor.set("과세번호", dataObject.string("GOJI_NO")); + attachFileEditor.set("법정기일", DataFormat.yyyy_mm_dd(dataObject.string("DUDT_YMD"))); + attachFileEditor.set("세목", dataObject.string("TXITM_NM")); + attachFileEditor.set("세액", CmmnUtil.addCommaToNumber(dataObject.string("LEVY_PCPTAX"))); + attachFileEditor.set("가산금", CmmnUtil.addCommaToNumber(dataObject.string("LEVY_ADAMT"))); + attachFileEditor.set("합계", CmmnUtil.addCommaToNumber(dataObject.string("SUM_AMT"))); + + } + +} 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 new file mode 100644 index 00000000..b58f76bd --- /dev/null +++ b/src/main/java/cokr/xit/fims/cmmn/hwp/format/RequestForDelivery.java @@ -0,0 +1,90 @@ +package cokr.xit.fims.cmmn.hwp.format; + +import java.util.List; +import java.util.Map; + +import cokr.xit.fims.cmmn.CmmnUtil; +import cokr.xit.fims.cmmn.FactionUtil; +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.DataFormat; +import cokr.xit.foundation.data.DataObject; +import kr.dogfoot.hwplib.object.HWPFile; + +public class RequestForDelivery implements HWPFormatWriter { + + @Override + public void setting(HWPPrintUtil hwpPrintUtil) { + hwpPrintUtil.setFormatName("교부청구서"); + hwpPrintUtil.setFormatKorName("requestForDelivery"); + + hwpPrintUtil.setFormatType("list"); + hwpPrintUtil.setRecordPerPartFile(7); + + hwpPrintUtil.setBaseFormatFilePath("format/requestForDelivery_root.hwp"); + hwpPrintUtil.setAttachFormatFilePath("format/requestForDelivery_inner.hwp"); + } + + @Override + public void writeGlobalInfo(HWPFile baseFile, List dataObjectList, + PrintOption printOption, HWPPrintUtil hwpPrintUtil) { + + ClickHereEditor baseFileEditor = new ClickHereEditor(baseFile); + + Map globalVariable = hwpPrintUtil.getGlobalVariable(printOption); + + baseFileEditor.set("문서번호", globalVariable.get("docNo")); + baseFileEditor.set("사건번호", globalVariable.get("caseNo")); + baseFileEditor.set("수신", globalVariable.get("receiver")); + baseFileEditor.set("체납자성명", globalVariable.get("rtpyrNm")); + baseFileEditor.set("체납자번호", globalVariable.get("rtpyrNo")); + baseFileEditor.set("차량번호", globalVariable.get("vhrno")); + baseFileEditor.set("주소", globalVariable.get("rtpyrFullAddr")); + + int sumOfList = dataObjectList.stream().mapToInt(item -> item.number("SUM_AMT").intValue()).sum(); + + baseFileEditor.set("합계금액", CmmnUtil.addCommaToNumber(sumOfList)); + baseFileEditor.set("교부청구금액", CmmnUtil.addCommaToNumber(sumOfList)); + baseFileEditor.set("교부청구금액한글", CmmnUtil.convertNumberToHangul(sumOfList)); + + 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"); + baseFileEditor.set("예금주", instNm + " " + deptNm); + + String printRequestYmd = hwpPrintUtil.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); + + instNm = FactionUtil.getLastWord(instNm); + instNm = FactionUtil.getInstituteLeader(instNm, false); + baseFileEditor.set("발신", instNm); + + try { + InsertingImageCell.IMPL_InsertPicture(baseFile, "직인", globalVariable.get("offcsFilePath")); + } catch (Exception e) { + throw new RuntimeException("한글 파일 출력 중 오류가 발생하였습니다."); + } + } + + @Override + public void writeSingleDataInfo(HWPFile baseFile, HWPFile attachFile, + DataObject dataObject, HWPPrintUtil hwpPrintUtil) { + + ClickHereEditor attachFileEditor = new ClickHereEditor(attachFile); + + attachFileEditor.set("징수과목", dataObject.string("TXITM_NM")); + attachFileEditor.set("고지번호", dataObject.string("GOJI_NO")); + attachFileEditor.set("과태료계", CmmnUtil.addCommaToNumber(dataObject.string("SUM_AMT"))); + attachFileEditor.set("법정기일", DataFormat.yyyy_mm_dd(dataObject.string("DUDT_YMD"))); + } + +} diff --git a/src/main/java/cokr/xit/fims/cmmn/pdf/PDFCoordinate.java b/src/main/java/cokr/xit/fims/cmmn/pdf/PDFCoordinate.java new file mode 100644 index 00000000..eaa26267 --- /dev/null +++ b/src/main/java/cokr/xit/fims/cmmn/pdf/PDFCoordinate.java @@ -0,0 +1,21 @@ +package cokr.xit.fims.cmmn.pdf; + +public class PDFCoordinate { + private float x; + private float y; + private float maxY; + public PDFCoordinate(float xpt, float ypt, float maxY) { + this.x = xpt; + this.y = ypt; + this.maxY = maxY; + } + + public float[] offset() { + return new float[] {x, -y}; + } + + public float[] absolute() { + return new float[] {x, maxY-y}; + } + +} diff --git a/src/main/java/cokr/xit/fims/cmmn/pdf/PDFPrintUtil.java b/src/main/java/cokr/xit/fims/cmmn/pdf/PDFPrintUtil.java index 4143033d..ec16c5d5 100644 --- a/src/main/java/cokr/xit/fims/cmmn/pdf/PDFPrintUtil.java +++ b/src/main/java/cokr/xit/fims/cmmn/pdf/PDFPrintUtil.java @@ -1,12 +1,28 @@ package cokr.xit.fims.cmmn.pdf; +import java.awt.Color; import java.io.File; +import java.io.IOException; import java.text.SimpleDateFormat; import java.util.Date; -public class PDFPrintUtil { +import org.apache.pdfbox.pdmodel.PDPageContentStream; +import org.apache.pdfbox.pdmodel.font.PDType0Font; +import org.apache.pdfbox.pdmodel.graphics.state.RenderingMode; - private int fileNameIndex = 0; +import cokr.xit.fims.cmmn.PrintUtil; + +public class PDFPrintUtil extends PrintUtil { + + private float[] paperMilimeter = new float[2]; + + public void setting(String paperType) { + if(paperType.equals("01")) { + this.paperMilimeter = new float[] {210 , 297}; + } else if(paperType.equals("02")){ + this.paperMilimeter = new float[] {216 , 279}; + } + } public String filePathForNewFile() { @@ -27,9 +43,68 @@ public class PDFPrintUtil { String resultPdfPath = fileResultFolderPath + File.separator + currentTime + "_" + (this.fileNameIndex++) + ".pdf"; - return resultPdfPath; } + // + public PDFCoordinate toPDFCoordinate(float[] XYmm) { + float Xmm = XYmm[0]; + float Ymm = XYmm[1]; + + float Xpt = mmToPt(Xmm); + float Ypt = mmToPt(Ymm); + + float YptMax = mmToPt(this.paperMilimeter[1]); + + return new PDFCoordinate(Xpt, Ypt, YptMax); + } + + // + public void writeText(PDPageContentStream contentStream, String text, float[] XYmm, + PDType0Font font, int fontSize, RenderingMode fontStyle, Color fontColor) { + try { + + float[] xyOffset = this.toPDFCoordinate(XYmm).offset(); + contentStream.beginText(); + contentStream.setFont(font, fontSize); + + contentStream.setRenderingMode(fontStyle); + + contentStream.setNonStrokingColor(fontColor); + + contentStream.newLineAtOffset(xyOffset[0], xyOffset[1]); + contentStream.showText(text); + contentStream.endText(); + + } catch (IOException e) { + throw new RuntimeException("PDF 파일 출력 중 오류가 발생하였습니다."); + } + + } + + public void renderFoldLine(PDPageContentStream contentStream, float paperWidth, float paperHeight) { + float foldHeight = 712/3; + + float bottomFold = foldHeight; //하단접는곳 + float topFold = foldHeight * 2; //상단접는곳 + + if(paperHeight == 842f) { + bottomFold += 130f; + topFold += 130f; + } + + try { + contentStream.setLineDashPattern(new float[]{3,1}, 0); + contentStream.moveTo(0, topFold); + contentStream.lineTo(paperWidth, topFold); + contentStream.stroke(); + contentStream.moveTo(0, bottomFold); + contentStream.lineTo(paperWidth, bottomFold); + contentStream.stroke(); + contentStream.setLineDashPattern(new float[]{}, 0); + } catch (IOException e) { + throw new RuntimeException("PDF 파일 출력 중 오류가 발생하였습니다."); + } + } } diff --git a/src/main/java/cokr/xit/fims/cmmn/pdf/format/Advntce.java b/src/main/java/cokr/xit/fims/cmmn/pdf/format/Advntce.java new file mode 100644 index 00000000..fd8da20b --- /dev/null +++ b/src/main/java/cokr/xit/fims/cmmn/pdf/format/Advntce.java @@ -0,0 +1,5 @@ +package cokr.xit.fims.cmmn.pdf.format; + +public class Advntce { + +} diff --git a/src/main/java/cokr/xit/fims/sprt/OtptStngQuery.java b/src/main/java/cokr/xit/fims/sprt/OtptStngQuery.java new file mode 100644 index 00000000..2bd1ba10 --- /dev/null +++ b/src/main/java/cokr/xit/fims/sprt/OtptStngQuery.java @@ -0,0 +1,33 @@ +package cokr.xit.fims.sprt; + +import cokr.xit.fims.cmmn.CmmnQuery; + +public class OtptStngQuery extends CmmnQuery { + + private static final long serialVersionUID = 1L; + + //발송구분코드 + private String sndngSeCd; + + //출력용지구분코드 + private String otptPaperSeCd; + + public String getSndngSeCd() { + return ifEmpty(sndngSeCd, () -> null); + } + + public T setSndngSeCd(String sndngSeCd) { + this.sndngSeCd = sndngSeCd; + return self(); + } + + public String getOtptPaperSeCd() { + return ifEmpty(otptPaperSeCd, () -> null); + } + + public T setOtptPaperSeCd(String otptPaperSeCd) { + this.otptPaperSeCd = otptPaperSeCd; + return self(); + } + +} diff --git a/src/main/java/cokr/xit/fims/sprt/PrintOption.java b/src/main/java/cokr/xit/fims/sprt/PrintOption.java index 7bdca268..30f9928b 100644 --- a/src/main/java/cokr/xit/fims/sprt/PrintOption.java +++ b/src/main/java/cokr/xit/fims/sprt/PrintOption.java @@ -12,11 +12,21 @@ public class PrintOption { /** * 개인정보 표시 여부 */ - String privateInfoYn; + private String privateInfoYn; + + /** + * 용지구분 + */ + private String otptPaperSeCd; + + /** + * 업무구분 + */ + private String taskSeCd; /** * 전역 변수 */ - Map globalVariable; + private Map globalVariable; } diff --git a/src/main/java/cokr/xit/fims/sprt/dao/OtptStngMapper.java b/src/main/java/cokr/xit/fims/sprt/dao/OtptStngMapper.java new file mode 100644 index 00000000..65f105a2 --- /dev/null +++ b/src/main/java/cokr/xit/fims/sprt/dao/OtptStngMapper.java @@ -0,0 +1,20 @@ +package cokr.xit.fims.sprt.dao; + +import java.util.List; + +import org.egovframe.rte.psl.dataaccess.mapper.Mapper; + +import cokr.xit.fims.sprt.OtptStngQuery; +import cokr.xit.foundation.component.AbstractMapper; +import cokr.xit.foundation.data.DataObject; + +@Mapper("otptStngMapper") +public interface OtptStngMapper extends AbstractMapper { + + /**지정한 조건에 따라 출력물 설정을 조회한다..
+ * @param query 출력물 설정 조회 조건 + * @return 출력물 설정 항목 + */ + List selectOtptStngList(OtptStngQuery query); + +} diff --git a/src/main/java/cokr/xit/fims/sprt/service/bean/Sprt01ServiceBean.java b/src/main/java/cokr/xit/fims/sprt/service/bean/Sprt01ServiceBean.java index fc57be0a..0bfbb820 100644 --- a/src/main/java/cokr/xit/fims/sprt/service/bean/Sprt01ServiceBean.java +++ b/src/main/java/cokr/xit/fims/sprt/service/bean/Sprt01ServiceBean.java @@ -1,5 +1,7 @@ package cokr.xit.fims.sprt.service.bean; +import java.awt.Color; +import java.io.InputStream; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -7,20 +9,36 @@ import java.util.Map; import javax.annotation.Resource; +import org.apache.pdfbox.pdmodel.PDDocument; +import org.apache.pdfbox.pdmodel.PDPage; +import org.apache.pdfbox.pdmodel.PDPageContentStream; +import org.apache.pdfbox.pdmodel.common.PDRectangle; +import org.apache.pdfbox.pdmodel.font.PDType0Font; +import org.apache.pdfbox.pdmodel.graphics.state.RenderingMode; +import org.springframework.core.io.ClassPathResource; import org.springframework.stereotype.Service; import cokr.xit.base.file.service.FileQuery; import cokr.xit.base.file.service.bean.FileBean; 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.PDFPrintUtil; import cokr.xit.fims.cmmn.service.bean.FactionBean; 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.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.dao.OtptStngMapper; import cokr.xit.fims.sprt.service.Sprt01Service; import cokr.xit.foundation.UserInfo; import cokr.xit.foundation.component.AbstractServiceBean; @@ -61,6 +79,9 @@ public class Sprt01ServiceBean extends AbstractServiceBean implements Sprt01Serv @Resource(name = "integrationSearchMapper") protected IntegrationSearchMapper integrationSearchMapper; + @Resource(name = "otptStngMapper") + protected OtptStngMapper otptStngMapper; + @Override public List getIntegrationDataList(SprtQuery query) { return sprt01Bean.getIntegrationDataList(query); @@ -78,12 +99,22 @@ public class Sprt01ServiceBean extends AbstractServiceBean implements Sprt01Serv Map result = new HashMap<>(); HWPPrintUtil printUtil = new HWPPrintUtil(); - printUtil.setting(formatType, formatName); - 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"); @@ -166,7 +197,8 @@ public class Sprt01ServiceBean extends AbstractServiceBean implements Sprt01Serv HWPFile resultFile = HWPReader.fromFile(resultHwpPath); //공통사항 세팅 - printUtil.setGlobalInfo(printOption, dataObjectList, resultFile); + hwpFormatWriter.writeGlobalInfo(resultFile, dataObjectList, printOption, printUtil); + HWPWriter.toFile(resultFile, resultHwpPath); //데이터 건별 처리 @@ -174,7 +206,19 @@ public class Sprt01ServiceBean extends AbstractServiceBean implements Sprt01Serv if(dataIndex < dataObjectList.size()) { DataObject dataObject = dataObjectList.get(dataIndex); - printUtil.setBySingleData(printOption, dataObject, resultFile); + 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")) { @@ -222,9 +266,156 @@ public class Sprt01ServiceBean extends AbstractServiceBean implements Sprt01Serv public Map makePdfFile(String formatType, String formatName, PrintOption printOption, String[] crdnIds) { Map result = new HashMap<>(); + SprtQuery sprtQuery = new SprtQuery(); + sprtQuery.setCrdnIDs(crdnIds); + List dataObjectList = integrationSearchMapper.selectIntegrationDataList(sprtQuery); + + try { + String otptPaperSeCd = printOption.getOtptPaperSeCd(); + PDFPrintUtil pdfPrintUtil = new PDFPrintUtil(); + UserInfo userInfo = currentUser(); + factionBean.initUserInfo(userInfo); + pdfPrintUtil.setPrintRequestUserInfo(userInfo); + + // + pdfPrintUtil.setting(otptPaperSeCd); + + + String resultFilePath = pdfPrintUtil.filePathForNewFile(); + + + PDDocument doc = new PDDocument();//pdf문서 생성 + + //폰트 로드 + Map fontMap = Map.of( + "notokrBold", PDType0Font.load(doc, new ClassPathResource("fonts/notokr-bold.ttf").getInputStream()), + "gulim", PDType0Font.load(doc, new ClassPathResource("fonts/gulim.ttf").getInputStream()), + "gulimche", PDType0Font.load(doc, new ClassPathResource("fonts/gulimche.ttf").getInputStream()), + "batang", PDType0Font.load(doc, new ClassPathResource("fonts/batang.ttf").getInputStream()), + "batangche", PDType0Font.load(doc, new ClassPathResource("fonts/batangche.ttf").getInputStream()), + "dotum", PDType0Font.load(doc, new ClassPathResource("fonts/dotum.ttf").getInputStream()), + "dotumche", PDType0Font.load(doc, new ClassPathResource("fonts/dotumche.ttf").getInputStream()), + "gungsuh", PDType0Font.load(doc, new ClassPathResource("fonts/gungsuh.ttf").getInputStream()), + "gungsuhche", PDType0Font.load(doc, new ClassPathResource("fonts/gungsuhche.ttf").getInputStream()) + ); + + //용지 크기 설정 + PDRectangle paper = null; + if(otptPaperSeCd.equals("01")) { + paper = PDRectangle.A4; + } else { + paper = PDRectangle.LETTER; + } + + float paperWidth = paper.getWidth(); + float paperHeight = paper.getHeight(); + + OtptStngQuery otptStngQuery = new OtptStngQuery(); + otptStngQuery.setSggCd((String) pdfPrintUtil.getPrintRequestUserInfo().getInfo().get("SGG_CD")); + otptStngQuery.setTaskSeCd(printOption.getTaskSeCd()); + + String sndngSeCd = ""; + if(formatName.equals("advntce")) { + sndngSeCd = "02"; + } + otptStngQuery.setSndngSeCd(sndngSeCd); + otptStngQuery.setOtptPaperSeCd(otptPaperSeCd); + + List otptStng = otptStngMapper.selectOtptStngList(otptStngQuery); + + for(DataObject dataObject : dataObjectList) { + //페이지생성(건별) + PDPage blankPage = new PDPage(paper); + doc.addPage(blankPage); + + // 작업 페이지 설정 + PDPage page = doc.getPage(doc.getNumberOfPages()-1); + // 컨텐츠 스트림 열기 + PDPageContentStream contentStream = new PDPageContentStream(doc, page); + + + //접는곳 점선 그리기 + pdfPrintUtil.renderFoldLine(contentStream, paperWidth, paperHeight); + + + //이미지 그리기 + //단속 이미지 로드(건별) + //PDImageXObject crdnPhotoImage = PDImageXObject.createFromFile("samplefiles/sample.JPG", doc); + + //float photosXstart; + //float photosYstart; + //float photosXend; + //float photosYend; + //단속사진 + //contentStream.drawImage(crdnPhotoImage, 300, 280, 250, 280); + //사각형(모자이크) + //contentStream.addRect(0, 0, 0, 0); + //직인 + //float[] offcsLocation = {300, 50}; + //float offcsSize = 20; + //contentStream.drawImage(offcsImage, offcsLocation[0], offcsLocation[1], offcsSize, offcsSize); + + //지자체로고 + //contentStream.drawImage(logoImage, ?, ?, logoWidth, logoHeight); + //배경 이미지 + //contentStream.drawImage(pdImage, 0, 0, paperWidth, paperHeight); + + + + + for(DataObject otptItemStng : otptStng) { + + String otptNm = otptItemStng.string("OTPT_NM"); + + String dataValue = dataObject.string(otptItemStng.string("COL_NM")); + if(dataValue.equals("")) { + dataValue = otptItemStng.string("OTPT_BSC_VL"); + } + + float[] pstn = new float[] { + otptItemStng.number("LEFT_PSTN").floatValue(), + otptItemStng.number("TOP_PSTN").floatValue() + }; + + PDType0Font font = fontMap.get("gulim"); + if(!otptItemStng.string("FONT_NM").equals("")) { + font = fontMap.get(otptItemStng.string("FONT_NM")); + } + int fontSz = 10; + if(otptItemStng.number("FONT_SIZE").intValue() != 0) { + fontSz = otptItemStng.number("FONT_SIZE").intValue(); + } + RenderingMode fontStyle = RenderingMode.valueOf("FILL"); + if(!otptItemStng.string("FONT_STYLE").equals("")) { + fontStyle = RenderingMode.valueOf(otptItemStng.string("FONT_STYLE")); + } + Color fontColor = Color.getColor("BLACK"); + if(!otptItemStng.string("FONT_COLOR").equals("")) { + fontColor = Color.getColor(otptItemStng.string("FONT_COLOR")); + } + + pdfPrintUtil.writeText(contentStream, dataValue, pstn, font, fontSz, fontStyle, fontColor); + + } + + contentStream.close(); + } + + + doc.save(resultFilePath); + doc.close(); + + result.put("fileName", "사전통지서.pdf"); + result.put("filePath", resultFilePath); + + } catch (Exception e) { + e.printStackTrace(); + throw new RuntimeException(); + } + return result; } 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 f3b7cb25..f197fe6e 100644 --- a/src/main/java/cokr/xit/fims/sprt/web/Sprt01Controller.java +++ b/src/main/java/cokr/xit/fims/sprt/web/Sprt01Controller.java @@ -384,11 +384,9 @@ public class Sprt01Controller extends ApplicationController { /** 사전통지서를 PDF 파일로 작성한다. * @return 사전통지서 PDF파일 */ - public ModelAndView makeAdvntcePdf(String[] crdnIds) { + public ModelAndView makeAdvntcePdf(PrintOption printOption, String[] crdnIds) { ModelAndView mav = new ModelAndView("jsonView"); - PrintOption printOption = new PrintOption(); - Map result = sprt01Service.makePdfFile("info", "advntce", printOption, crdnIds); mav.addAllObjects(result); @@ -399,11 +397,9 @@ public class Sprt01Controller extends ApplicationController { /** 사전통지 정보로 txt파일,이미지파일을 생성하고 압축파일로 반환한다. * @return 사전통지서 압축파일 */ - public ModelAndView makeAdvntceOutsourcing(String[] crdnIds) { + public ModelAndView makeAdvntceOutsourcing(PrintOption printOption, String[] crdnIds) { ModelAndView mav = new ModelAndView("jsonView"); - PrintOption printOption = new PrintOption(); - Map result = sprt01Service.makeOutsourcingFile("advntce", printOption, crdnIds); mav.addAllObjects(result); diff --git a/src/main/java/cokr/xit/fims/task/web/CmnController.java b/src/main/java/cokr/xit/fims/task/web/CmnController.java index 583cc826..1a2daf7e 100644 --- a/src/main/java/cokr/xit/fims/task/web/CmnController.java +++ b/src/main/java/cokr/xit/fims/task/web/CmnController.java @@ -422,14 +422,14 @@ public class CmnController { @Override @RequestMapping(name="사전통지서 pdf 파일 생성", value=METHOD_URL.makeAdvntcePdf) - public ModelAndView makeAdvntcePdf(String... crdnIds) { - return super.makeAdvntcePdf(crdnIds); + public ModelAndView makeAdvntcePdf(PrintOption printOption, String... crdnIds) { + return super.makeAdvntcePdf(printOption, crdnIds); } @Override @RequestMapping(name="사전통지서 외주 파일 생성", value=METHOD_URL.makeAdvntceOutsourcing) - public ModelAndView makeAdvntceOutsourcing(String... crdnIds) { - return super.makeAdvntceOutsourcing(crdnIds); + public ModelAndView makeAdvntceOutsourcing(PrintOption printOption, String... crdnIds) { + return super.makeAdvntceOutsourcing(printOption, crdnIds); } } diff --git a/src/main/resources/sql/mapper/fims/sprt/otptStng-mapper.xml b/src/main/resources/sql/mapper/fims/sprt/otptStng-mapper.xml new file mode 100644 index 00000000..ac6a755a --- /dev/null +++ b/src/main/resources/sql/mapper/fims/sprt/otptStng-mapper.xml @@ -0,0 +1,29 @@ + + + + +