From abed515853879424bb523a3e313e8c41de308c0b Mon Sep 17 00:00:00 2001 From: leebeomjun Date: Tue, 28 Nov 2023 15:14:13 +0900 Subject: [PATCH] =?UTF-8?q?pdf=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 | 8 + .../cokr/xit/fims/cmmn/hwp/HWPPrintUtil.java | 8 - .../xit/fims/cmmn/pdf/DefaultOtptStng.java | 13 + .../cokr/xit/fims/cmmn/pdf/PDFFormat.java | 10 +- .../cokr/xit/fims/cmmn/pdf/PDFPrintUtil.java | 30 +-- .../xit/fims/cmmn/pdf/format/Advntce.java | 237 +++++++++++++++++- .../sprt/service/bean/Sprt01ServiceBean.java | 34 ++- .../sql/mapper/fims/cmmn/stng-mapper.xml | 3 + .../fims/sprt/integrationSearch-mapper.xml | 2 + 9 files changed, 301 insertions(+), 44 deletions(-) diff --git a/src/main/java/cokr/xit/fims/cmmn/PrintUtil.java b/src/main/java/cokr/xit/fims/cmmn/PrintUtil.java index e71e4e79..6ef4fbbe 100644 --- a/src/main/java/cokr/xit/fims/cmmn/PrintUtil.java +++ b/src/main/java/cokr/xit/fims/cmmn/PrintUtil.java @@ -23,6 +23,14 @@ public class PrintUtil { protected UserInfo printRequestUserInfo; + public String getPrintRequestDt() { + return this.printRequestDt; + } + + public void setPrintRequestDt(String printRequestDt) { + this.printRequestDt = printRequestDt; + } + public UserInfo getPrintRequestUserInfo() { return this.printRequestUserInfo; }; 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 4a3230dc..ad2f9e6c 100644 --- a/src/main/java/cokr/xit/fims/cmmn/hwp/HWPPrintUtil.java +++ b/src/main/java/cokr/xit/fims/cmmn/hwp/HWPPrintUtil.java @@ -52,14 +52,6 @@ public class HWPPrintUtil extends PrintUtil { this.formatKorName = formatKorName; } - public String getPrintRequestDt() { - return this.printRequestDt; - } - - public void setPrintRequestDt(String printRequestDt) { - this.printRequestDt = printRequestDt; - } - public int getRecordPerPartFile() { return this.recordPerPartFile; } diff --git a/src/main/java/cokr/xit/fims/cmmn/pdf/DefaultOtptStng.java b/src/main/java/cokr/xit/fims/cmmn/pdf/DefaultOtptStng.java index 0ae57d80..1b4520be 100644 --- a/src/main/java/cokr/xit/fims/cmmn/pdf/DefaultOtptStng.java +++ b/src/main/java/cokr/xit/fims/cmmn/pdf/DefaultOtptStng.java @@ -19,14 +19,24 @@ public class DefaultOtptStng { this.fontSize=10; this.fontColor="BLACK"; this.fontStyle="FILL"; + + this.forPost = false; + this.unique = false; } public DefaultOtptStng a4(float leftPstn, float topPstn) { this.a4 = new Pstn(leftPstn, topPstn); + this.unique = true; return this; } public DefaultOtptStng letter(float leftPstn, float topPstn) { this.letter = new Pstn(leftPstn, topPstn); + this.unique = true; + return this; + } + + public DefaultOtptStng post() { + this.forPost = true; return this; } @@ -73,10 +83,13 @@ public class DefaultOtptStng { private String otptBscVl; private Pstn a4; private Pstn letter; + private boolean unique; + private boolean forPost; private float widthSz; private float heightSz; private String fontNm; private int fontSize; private String fontColor; private String fontStyle; + } diff --git a/src/main/java/cokr/xit/fims/cmmn/pdf/PDFFormat.java b/src/main/java/cokr/xit/fims/cmmn/pdf/PDFFormat.java index fca836e7..1610368f 100644 --- a/src/main/java/cokr/xit/fims/cmmn/pdf/PDFFormat.java +++ b/src/main/java/cokr/xit/fims/cmmn/pdf/PDFFormat.java @@ -28,7 +28,15 @@ public abstract class PDFFormat { } } - public abstract String getMappingValue(String otptNm, String defaultValue, + public void addForPost(DefaultOtptStng... defaultOtptStngs) { + for(DefaultOtptStng defaultOtptStng : defaultOtptStngs) { + this.defaultOtptStng.add(defaultOtptStng.post()); + } + }; + + public abstract String getMappingValue(String otptNm, String defaultValue, boolean forPost, DataObject dataObject, PrintOption printOption, PDFPrintUtil pdfPrintUtil); + public abstract String getValueForPost(String otptNm, String defaultValue, + DataObject dataObject, PrintOption printOption, PDFPrintUtil pdfPrintUtil); } 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 9be96f80..88f60cc3 100644 --- a/src/main/java/cokr/xit/fims/cmmn/pdf/PDFPrintUtil.java +++ b/src/main/java/cokr/xit/fims/cmmn/pdf/PDFPrintUtil.java @@ -129,16 +129,8 @@ public class PDFPrintUtil extends PrintUtil { } } - public PDType0Font getFontStng(DefaultOtptStng defaultStng, DataObject sggStng, Map fontMap) { - if(sggStng != null && !sggStng.isEmpty() && !sggStng.string("FONT_NM").equals("")) { - return fontMap.get(sggStng.string("FONT_NM")); - } else { - return fontMap.get(defaultStng.getFontNm()); - } - } - public float[] getPstnStng(DefaultOtptStng defaultStng, DataObject sggStng, String otptPaperSeCd) { - if(sggStng != null && !sggStng.isEmpty()) { + if(!sggStng.string("LEFT_PSTN").equals("") && !sggStng.string("TOP_PSTN").equals("")) { return new float[] { sggStng.number("LEFT_PSTN").floatValue(), sggStng.number("TOP_PSTN").floatValue() @@ -151,8 +143,16 @@ public class PDFPrintUtil extends PrintUtil { } } + public PDType0Font getFontType(DefaultOtptStng defaultStng, DataObject sggStng, Map fontMap) { + if(sggStng != null && !sggStng.isEmpty() && !sggStng.string("FONT_NM").equals("")) { + return fontMap.get(sggStng.string("FONT_NM")); + } else { + return fontMap.get(defaultStng.getFontNm()); + } + } + public int getFontSize(DefaultOtptStng defaultStng, DataObject sggStng) { - if(sggStng != null && !sggStng.isEmpty() && !sggStng.string("FONT_SIZE").equals("")) { + if(!sggStng.string("FONT_SIZE").equals("")) { return sggStng.number("FONT_SIZE").intValue(); } else { return defaultStng.getFontSize(); @@ -160,7 +160,7 @@ public class PDFPrintUtil extends PrintUtil { } public RenderingMode getFontStyle(DefaultOtptStng defaultStng, DataObject sggStng) { - if(sggStng != null && !sggStng.isEmpty() && !sggStng.string("FONT_STYLE").equals("")) { + if(!sggStng.string("FONT_STYLE").equals("")) { return RenderingMode.valueOf(sggStng.string("FONT_STYLE")); } else { return RenderingMode.valueOf(defaultStng.getFontStyle()); @@ -168,7 +168,7 @@ public class PDFPrintUtil extends PrintUtil { } public PDColor getFontColor(DefaultOtptStng defaultStng, DataObject sggStng) { - if(sggStng != null && !sggStng.isEmpty() && !sggStng.string("FONT_COLOR").equals("")) { + if(!sggStng.string("FONT_COLOR").equals("")) { return PDFColors.getColor(sggStng.string("FONT_COLOR")); } else { return PDFColors.getColor(defaultStng.getFontColor()); @@ -176,10 +176,10 @@ public class PDFPrintUtil extends PrintUtil { } public float[] getSize(DefaultOtptStng defaultStng, DataObject sggStng) { - if(sggStng != null && !sggStng.isEmpty()) { + if(!sggStng.string("WIDTH_SZ").equals("") && !sggStng.string("HEIGHT_SZ").equals("")) { return new float[] { - sggStng.number("LEFT_PSTN").floatValue(), - sggStng.number("TOP_PSTN").floatValue() + sggStng.number("WIDTH_SZ").floatValue(), + sggStng.number("HEIGHT_SZ").floatValue() }; } else { return new float[] { 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 index c600afe0..66c395ae 100644 --- a/src/main/java/cokr/xit/fims/cmmn/pdf/format/Advntce.java +++ b/src/main/java/cokr/xit/fims/cmmn/pdf/format/Advntce.java @@ -1,5 +1,7 @@ package cokr.xit.fims.cmmn.pdf.format; +import cokr.xit.fims.cmmn.CmmnUtil; +import cokr.xit.fims.cmmn.FactionUtil; import cokr.xit.fims.cmmn.pdf.PDFFormat; import cokr.xit.fims.cmmn.pdf.PDFPrintUtil; import cokr.xit.fims.sprt.PrintOption; @@ -12,32 +14,249 @@ import cokr.xit.foundation.data.DataObject; public class Advntce extends PDFFormat { public Advntce(){ + addForPost( + text("postReceiverAddr","").post().a4(0, 0).letter(0, 0), + text("postReceiverDtlAddr","").post().a4(0, 0).letter(0, 0), + text("postReceiverZip","").a4(0, 0).letter(0, 0), + text("postReceiver","").a4(0, 0).letter(0, 0), + + image("postSenderLogo","").a4(10, 0).letter(0, 0).size(0, 0), + text("postSenderInst","").a4(10, 10).letter(0, 0), + text("postSenderDept","").a4(50, 10).letter(0, 0), + text("postSenderAddr","").a4(10, 20).letter(0, 0), + text("postSenderDtlAddr","").a4(10, 30).letter(0, 0), + text("postSenderZip","").a4(10, 40).letter(0, 0), + text("postSenderTel","").a4(10, 50).letter(0, 0), + text("postSenderFax","").a4(50, 50).letter(0, 0) + ); + add( - text("CRDN_YMD","").a4(105, 150).letter(0, 0), - text("VHRNO","").a4(30, 30).letter(0, 0) + image("background","").a4(0, 0).letter(0, 0).size(0, 0), + image("photo1","").a4(0, 0).letter(0, 0).size(0, 0), + + text("rtpyrNm",""), + text("rtpyrNo",""), + text("rtpyrAddr",""), + text("rtpyrDtlAddr",""), + text("rtpyrFullAddr",""), + + text("vhrno",""), + text("crdnYmd",""), + text("crdnYmdTm",""), + text("crdnPlc",""), + text("ffnlgCarmdlNm",""), + text("vltnArtcl",""), + text("vltnLawNm",""), + text("crdnSn",""), - //image("OFFCS1","OFFCS").a4(0, 0).letter(0, 0).size(0, 0), - //image("OFFCS2","OFFCS").a4(0, 0).letter(0, 0).size(0, 0), - //image("OFFCS3","OFFCS").a4(0, 0).letter(0, 0).size(0, 0) + text("amt",""), + text("untilYmd",""), + + text("vrActno",""), + text("vrActno1",""), + text("vrActno2",""), + text("vrActno3",""), + text("vrActno4",""), + text("vrActno5",""), + text("vrActno6",""), + text("vrActno7",""), + text("vrActno8",""), + text("vrActno9",""), + text("vrActno10",""), + text("epayNo",""), + + text("otptYmd",""), + text("offcsText",""), + image("offcs","").size(20, 20) ); } @Override - public String getMappingValue(String otptNm, String defaultValue, + public String getMappingValue(String otptNm, String defaultValue, boolean forPost, DataObject dataObject, PrintOption printOption, PDFPrintUtil pdfPrintUtil) { String result = ""; + if(forPost) { + return this.getValueForPost(otptNm, defaultValue, dataObject, printOption, pdfPrintUtil); + } switch(otptNm) { - case "VHRNO" -> { + case "background" -> { + result = dataObject.string(""); + } + case "photo1" -> { + result = dataObject.string("CRDN_PHOTO1"); + } + case "photo2" -> { + result = dataObject.string("CRDN_PHOTO2"); + } + case "photo3" -> { + result = dataObject.string("CRDN_PHOTO3"); + } + case "photo4" -> { + result = dataObject.string("CRDN_PHOTO4"); + } + + case "rtpyrNm" -> { + result = dataObject.string("RTPYR_NM"); + } + case "rtpyrNo" -> { + result = dataObject.string("RTPYR_NO"); + } + case "rtpyrAddr" -> { + result = dataObject.string("RTPYR_ADDR"); + } + case "rtpyrDtlAddr" -> { + result = dataObject.string("RTPYR_DTL_ADDR"); + } + case "rtpyrFullAddr" -> { + result = dataObject.string("RTPYR_FULL_ADDR"); + } + case "rtpyrZip" -> { + result = dataObject.string("RTPYR_ZIP"); + } + case "vhrno" -> { result = dataObject.string("VHRNO"); } - case "CRDN_YMD" -> { - result = DataFormat.yyyy_mm_dd("CRDN_YMD"); + case "crdnYmd" -> { + result = DataFormat.yyyy_mm_dd(dataObject.string("CRDN_YMD")); + } + case "crdnYmdTm" -> { + result = CmmnUtil.yyyy_mm_dd_hh_mm_ss(dataObject.string("CRDN_YMD_TM")); + } + case "crdnPlc" -> { + result = dataObject.string("CRDN_PLC"); + } + case "ffnlgCarmdlNm" -> { + result = dataObject.string("FFNLG_CARMDL_NM"); + } + case "vltnArtcl" -> { + result = dataObject.string("VLTN_ARTCL"); + } + case "vltnLawNm" -> { + result = dataObject.string("VLTN_LAW_NM"); + } + case "crdnSn" -> { + result = dataObject.string("CRDN_SN"); + } + case "amt" -> { + result = CmmnUtil.addCommaToNumber(dataObject.string("")); + } + case "untilYmd" -> { + result = DataFormat.yyyy_mm_dd(dataObject.string("")); } + case "vrActno" -> { + result = dataObject.string("VR_ACTNO"); + } + case "vrActno1" -> { + result = dataObject.string("VR_ACTNO1"); + } + case "vrActno2" -> { + result = dataObject.string("VR_ACTNO2"); + } + case "vrActno3" -> { + result = dataObject.string("VR_ACTNO3"); + } + case "vrActno4" -> { + result = dataObject.string("VR_ACTNO4"); + } + case "vrActno5" -> { + result = dataObject.string("VR_ACTNO5"); + } + case "vrActno6" -> { + result = dataObject.string("VR_ACTNO6"); + } + case "vrActno7" -> { + result = dataObject.string("VR_ACTNO7"); + } + case "vrActno8" -> { + result = dataObject.string("VR_ACTNO8"); + } + case "vrActno9" -> { + result = dataObject.string("VR_ACTNO9"); + } + case "vrActno10" -> { + result = dataObject.string("VR_ACTNO10"); + } + case "epayNo" -> { + result = dataObject.string("EPAY_NO"); + } + + case "otptYmd" -> { + result = DataFormat.yyyy_mm_dd(pdfPrintUtil.getPrintRequestDt().substring(0,8)); + } + case "otptDt" -> { + result = CmmnUtil.yyyy_mm_dd_hh_mm_ss(pdfPrintUtil.getPrintRequestDt()); + } + case "otptYYYY" -> { + result = pdfPrintUtil.getPrintRequestDt().substring(0,4); + } + case "otptMM" -> { + result = pdfPrintUtil.getPrintRequestDt().substring(4,6); + } + case "otptDD" -> { + result = pdfPrintUtil.getPrintRequestDt().substring(6,8); } + case "offcsText" -> { + String instNm = (String) pdfPrintUtil.getPrintRequestUserInfo().getInfo().get("instNm"); + instNm = FactionUtil.getLastWord(instNm); + instNm = FactionUtil.getInstituteLeader(instNm, true); + result = instNm; + } + case "offcs" -> { + result = printOption.getGlobalVariable().get("offcsFilePath"); + } + + } + + return result; + } + + @Override + public String getValueForPost(String otptNm, String defaultValue, + DataObject dataObject, PrintOption printOption, PDFPrintUtil pdfPrintUtil) { + String result = ""; + + switch(otptNm) { + case "postReceiverAddr" -> { + result = dataObject.string("RTPYR_ADDR"); + } + case "postReceiverDtlAddr" -> { + result = dataObject.string("RTPYR_DTL_ADDR"); + } + case "postReceiverZip" -> { + result = dataObject.string("RTPYR_ZIP"); + } + case "postReceiver" -> { + result = dataObject.string("RTPYR_NM"); + } + case "postSenderLogo" -> { + result = dataObject.string(""); + } + case "postSenderInst" -> { + result = (String)pdfPrintUtil.getPrintRequestUserInfo().getInfo().get("instNm"); + } + case "postSenderDept" -> { + result = (String)pdfPrintUtil.getPrintRequestUserInfo().getInfo().get("deptNm"); + } + case "postSenderAddr" -> { + result = printOption.getGlobalVariable().get("instAddr"); + } + case "postSenderDtlAddr" -> { + result = printOption.getGlobalVariable().get("instDaddr"); + } + case "postSenderZip" -> { + result = printOption.getGlobalVariable().get("isntZip"); + } + case "postSenderTel" -> { + result = printOption.getGlobalVariable().get("deptTelno"); + } + case "postSenderFax" -> { + result = printOption.getGlobalVariable().get("deptFxno"); + } + } return result; } 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 a1280f15..fadd9ab8 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 @@ -5,7 +5,6 @@ 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; @@ -276,6 +275,20 @@ public class Sprt01ServiceBean extends AbstractServiceBean implements Sprt01Serv sprtQuery.setCrdnIDs(crdnIds); List dataObjectList = integrationSearchMapper.selectIntegrationDataList(sprtQuery); + DataObject userStngInfo = stngBean.getStng("user"); + DataObject sggStngInfo = stngBean.getStng("sgg"); + DataObject deptStngInfo = stngBean.getStng("dept"); + + Map globalVariable = printOption.getGlobalVariable(); + globalVariable.put("offcsFilePath", sggStngInfo.string("OFFCS_FILE_PATH")); + globalVariable.put("instAddr", sggStngInfo.string("INST_ADDR")); + globalVariable.put("instDaddr", sggStngInfo.string("INST_DADDR")); + globalVariable.put("instZip", sggStngInfo.string("INST_ZIP")); + globalVariable.put("deptTelno", deptStngInfo.string("DEPT_TELNO")); + globalVariable.put("deptFxno", deptStngInfo.string("DEPT_FXNO")); + printOption.setGlobalVariable(globalVariable); + + try { String otptPaperSeCd = printOption.getOtptPaperSeCd(); PDFPrintUtil pdfPrintUtil = new PDFPrintUtil(); @@ -335,8 +348,6 @@ public class Sprt01ServiceBean extends AbstractServiceBean implements Sprt01Serv otptStngQuery.setOtptPaperSeCd(otptPaperSeCd); List otptStng = otptStngMapper.selectOtptStngList(otptStngQuery); - Map byOtptItemStng = otptStng.stream() - .collect(Collectors.toMap((item) -> item.string("OTPT_NM"), (item) -> item)); for(DataObject dataObject : dataObjectList) { //페이지생성(건별) @@ -352,22 +363,23 @@ public class Sprt01ServiceBean extends AbstractServiceBean implements Sprt01Serv pdfPrintUtil.renderFoldLine(contentStream, paperWidth, paperHeight); - for(DefaultOtptStng predefined : predefinedList) { - String otptNm = predefined.getOtptNm(); - DataObject otptItemStng = byOtptItemStng.get(otptNm); - - float[] pstn = pdfPrintUtil.getPstnStng(predefined, otptItemStng, otptPaperSeCd); + for(DataObject otptItemStng : otptStng) { + String otptNm = otptItemStng.string("OTPT_NM"); + DefaultOtptStng predefined = predefinedList.stream() + .filter(item -> item.getOtptNm().equals(otptNm)).toList().get(0); + float[] pstn = pdfPrintUtil.getPstnStng(predefined, otptItemStng, otptPaperSeCd); + boolean forPost = predefined.isForPost(); String defaultValue = predefined.getOtptBscVl(); if(predefined.getContentType().equals("text")) { - PDType0Font font = pdfPrintUtil.getFontStng(predefined, otptItemStng, fontMap); + PDType0Font font = pdfPrintUtil.getFontType(predefined, otptItemStng, fontMap); int fontSz = pdfPrintUtil.getFontSize(predefined, otptItemStng); RenderingMode fontStyle = pdfPrintUtil.getFontStyle(predefined, otptItemStng); PDColor fontColor = pdfPrintUtil.getFontColor(predefined, otptItemStng); - String textValue = pdfFormat.getMappingValue(otptNm,defaultValue,dataObject,printOption,pdfPrintUtil); + String textValue = pdfFormat.getMappingValue(otptNm,defaultValue,forPost,dataObject,printOption,pdfPrintUtil); pdfPrintUtil.writeText(contentStream, textValue, pstn, font, fontSz, fontStyle, fontColor); @@ -375,7 +387,7 @@ public class Sprt01ServiceBean extends AbstractServiceBean implements Sprt01Serv float[] size = pdfPrintUtil.getSize(predefined, otptItemStng); - String imagePath = pdfFormat.getMappingValue(otptNm,defaultValue,dataObject,printOption,pdfPrintUtil); + String imagePath = pdfFormat.getMappingValue(otptNm,defaultValue,forPost,dataObject,printOption,pdfPrintUtil); pdfPrintUtil.insertImage(doc, contentStream, imagePath, pstn, size); diff --git a/src/main/resources/sql/mapper/fims/cmmn/stng-mapper.xml b/src/main/resources/sql/mapper/fims/cmmn/stng-mapper.xml index 1b005098..7a90fdd9 100644 --- a/src/main/resources/sql/mapper/fims/cmmn/stng-mapper.xml +++ b/src/main/resources/sql/mapper/fims/cmmn/stng-mapper.xml @@ -29,6 +29,9 @@ SELECT SGG_CD THEN INST_ADDR ELSE CONCAT(INST_ADDR,' ',INST_DADDR) END) AS INST_FULL_ADDR + , INST_ADRR + , INST_DADDR + , INST_ZIP , OFFCS_FILE_PATH , OFFCS_FILE_NM FROM TB_SGG_INFO diff --git a/src/main/resources/sql/mapper/fims/sprt/integrationSearch-mapper.xml b/src/main/resources/sql/mapper/fims/sprt/integrationSearch-mapper.xml index 8f0477b0..d4cc672d 100644 --- a/src/main/resources/sql/mapper/fims/sprt/integrationSearch-mapper.xml +++ b/src/main/resources/sql/mapper/fims/sprt/integrationSearch-mapper.xml @@ -56,6 +56,8 @@ , C.CRDN_PLC /* 단속 장소 */ , CA.DTL_CRDN_PLC /* 상세 단속 장소 */ , C.VLTN_ID /* 위반 ID */ + , VI.VLTN_ARTCL /* 위반 항목 */ + , VI.VLTN_LAW_NM /* 위반 법 명 */ , IFNULL(CA.TOWNG_YN,'N') AS TOWNG_YN /* 견인 여부 */ , (SELECT GET_CODE_NM('CMM006', IFNULL(CA.TOWNG_YN,'N')) FROM DUAL) AS TOWNG_YN_NM /* 견인 여부 명 */ , C.CRDN_STTS_CHG_DT /* 단속 상태 변경 일시 */