pdf출력 수정

main
이범준 12 months ago
parent 1805a013f8
commit abed515853

@ -23,6 +23,14 @@ public class PrintUtil {
protected UserInfo printRequestUserInfo; protected UserInfo printRequestUserInfo;
public String getPrintRequestDt() {
return this.printRequestDt;
}
public void setPrintRequestDt(String printRequestDt) {
this.printRequestDt = printRequestDt;
}
public UserInfo getPrintRequestUserInfo() { public UserInfo getPrintRequestUserInfo() {
return this.printRequestUserInfo; return this.printRequestUserInfo;
}; };

@ -52,14 +52,6 @@ public class HWPPrintUtil extends PrintUtil {
this.formatKorName = formatKorName; this.formatKorName = formatKorName;
} }
public String getPrintRequestDt() {
return this.printRequestDt;
}
public void setPrintRequestDt(String printRequestDt) {
this.printRequestDt = printRequestDt;
}
public int getRecordPerPartFile() { public int getRecordPerPartFile() {
return this.recordPerPartFile; return this.recordPerPartFile;
} }

@ -19,14 +19,24 @@ public class DefaultOtptStng {
this.fontSize=10; this.fontSize=10;
this.fontColor="BLACK"; this.fontColor="BLACK";
this.fontStyle="FILL"; this.fontStyle="FILL";
this.forPost = false;
this.unique = false;
} }
public DefaultOtptStng a4(float leftPstn, float topPstn) { public DefaultOtptStng a4(float leftPstn, float topPstn) {
this.a4 = new Pstn(leftPstn, topPstn); this.a4 = new Pstn(leftPstn, topPstn);
this.unique = true;
return this; return this;
} }
public DefaultOtptStng letter(float leftPstn, float topPstn) { public DefaultOtptStng letter(float leftPstn, float topPstn) {
this.letter = new Pstn(leftPstn, topPstn); this.letter = new Pstn(leftPstn, topPstn);
this.unique = true;
return this;
}
public DefaultOtptStng post() {
this.forPost = true;
return this; return this;
} }
@ -73,10 +83,13 @@ public class DefaultOtptStng {
private String otptBscVl; private String otptBscVl;
private Pstn a4; private Pstn a4;
private Pstn letter; private Pstn letter;
private boolean unique;
private boolean forPost;
private float widthSz; private float widthSz;
private float heightSz; private float heightSz;
private String fontNm; private String fontNm;
private int fontSize; private int fontSize;
private String fontColor; private String fontColor;
private String fontStyle; private String fontStyle;
} }

@ -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); DataObject dataObject, PrintOption printOption, PDFPrintUtil pdfPrintUtil);
public abstract String getValueForPost(String otptNm, String defaultValue,
DataObject dataObject, PrintOption printOption, PDFPrintUtil pdfPrintUtil);
} }

@ -129,16 +129,8 @@ public class PDFPrintUtil extends PrintUtil {
} }
} }
public PDType0Font getFontStng(DefaultOtptStng defaultStng, DataObject sggStng, Map<String, PDType0Font> 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) { 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[] { return new float[] {
sggStng.number("LEFT_PSTN").floatValue(), sggStng.number("LEFT_PSTN").floatValue(),
sggStng.number("TOP_PSTN").floatValue() sggStng.number("TOP_PSTN").floatValue()
@ -151,8 +143,16 @@ public class PDFPrintUtil extends PrintUtil {
} }
} }
public PDType0Font getFontType(DefaultOtptStng defaultStng, DataObject sggStng, Map<String, PDType0Font> 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) { 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(); return sggStng.number("FONT_SIZE").intValue();
} else { } else {
return defaultStng.getFontSize(); return defaultStng.getFontSize();
@ -160,7 +160,7 @@ public class PDFPrintUtil extends PrintUtil {
} }
public RenderingMode getFontStyle(DefaultOtptStng defaultStng, DataObject sggStng) { 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")); return RenderingMode.valueOf(sggStng.string("FONT_STYLE"));
} else { } else {
return RenderingMode.valueOf(defaultStng.getFontStyle()); return RenderingMode.valueOf(defaultStng.getFontStyle());
@ -168,7 +168,7 @@ public class PDFPrintUtil extends PrintUtil {
} }
public PDColor getFontColor(DefaultOtptStng defaultStng, DataObject sggStng) { 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")); return PDFColors.getColor(sggStng.string("FONT_COLOR"));
} else { } else {
return PDFColors.getColor(defaultStng.getFontColor()); return PDFColors.getColor(defaultStng.getFontColor());
@ -176,10 +176,10 @@ public class PDFPrintUtil extends PrintUtil {
} }
public float[] getSize(DefaultOtptStng defaultStng, DataObject sggStng) { 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[] { return new float[] {
sggStng.number("LEFT_PSTN").floatValue(), sggStng.number("WIDTH_SZ").floatValue(),
sggStng.number("TOP_PSTN").floatValue() sggStng.number("HEIGHT_SZ").floatValue()
}; };
} else { } else {
return new float[] { return new float[] {

@ -1,5 +1,7 @@
package cokr.xit.fims.cmmn.pdf.format; 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.PDFFormat;
import cokr.xit.fims.cmmn.pdf.PDFPrintUtil; import cokr.xit.fims.cmmn.pdf.PDFPrintUtil;
import cokr.xit.fims.sprt.PrintOption; import cokr.xit.fims.sprt.PrintOption;
@ -12,32 +14,249 @@ import cokr.xit.foundation.data.DataObject;
public class Advntce extends PDFFormat { public class Advntce extends PDFFormat {
public Advntce(){ 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( add(
text("CRDN_YMD","").a4(105, 150).letter(0, 0), image("background","").a4(0, 0).letter(0, 0).size(0, 0),
text("VHRNO","").a4(30, 30).letter(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), text("amt",""),
//image("OFFCS2","OFFCS").a4(0, 0).letter(0, 0).size(0, 0), text("untilYmd",""),
//image("OFFCS3","OFFCS").a4(0, 0).letter(0, 0).size(0, 0)
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 @Override
public String getMappingValue(String otptNm, String defaultValue, public String getMappingValue(String otptNm, String defaultValue, boolean forPost,
DataObject dataObject, PrintOption printOption, PDFPrintUtil pdfPrintUtil) { DataObject dataObject, PrintOption printOption, PDFPrintUtil pdfPrintUtil) {
String result = ""; String result = "";
if(forPost) {
return this.getValueForPost(otptNm, defaultValue, dataObject, printOption, pdfPrintUtil);
}
switch(otptNm) { 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"); result = dataObject.string("VHRNO");
} }
case "CRDN_YMD" -> { case "crdnYmd" -> {
result = DataFormat.yyyy_mm_dd("CRDN_YMD"); 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; return result;
} }

@ -5,7 +5,6 @@ import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors;
import javax.annotation.Resource; import javax.annotation.Resource;
@ -276,6 +275,20 @@ public class Sprt01ServiceBean extends AbstractServiceBean implements Sprt01Serv
sprtQuery.setCrdnIDs(crdnIds); sprtQuery.setCrdnIDs(crdnIds);
List<DataObject> dataObjectList = integrationSearchMapper.selectIntegrationDataList(sprtQuery); List<DataObject> dataObjectList = integrationSearchMapper.selectIntegrationDataList(sprtQuery);
DataObject userStngInfo = stngBean.getStng("user");
DataObject sggStngInfo = stngBean.getStng("sgg");
DataObject deptStngInfo = stngBean.getStng("dept");
Map<String, String> 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 { try {
String otptPaperSeCd = printOption.getOtptPaperSeCd(); String otptPaperSeCd = printOption.getOtptPaperSeCd();
PDFPrintUtil pdfPrintUtil = new PDFPrintUtil(); PDFPrintUtil pdfPrintUtil = new PDFPrintUtil();
@ -335,8 +348,6 @@ public class Sprt01ServiceBean extends AbstractServiceBean implements Sprt01Serv
otptStngQuery.setOtptPaperSeCd(otptPaperSeCd); otptStngQuery.setOtptPaperSeCd(otptPaperSeCd);
List<DataObject> otptStng = otptStngMapper.selectOtptStngList(otptStngQuery); List<DataObject> otptStng = otptStngMapper.selectOtptStngList(otptStngQuery);
Map<String, DataObject> byOtptItemStng = otptStng.stream()
.collect(Collectors.toMap((item) -> item.string("OTPT_NM"), (item) -> item));
for(DataObject dataObject : dataObjectList) { for(DataObject dataObject : dataObjectList) {
//페이지생성(건별) //페이지생성(건별)
@ -352,22 +363,23 @@ public class Sprt01ServiceBean extends AbstractServiceBean implements Sprt01Serv
pdfPrintUtil.renderFoldLine(contentStream, paperWidth, paperHeight); pdfPrintUtil.renderFoldLine(contentStream, paperWidth, paperHeight);
for(DefaultOtptStng predefined : predefinedList) { for(DataObject otptItemStng : otptStng) {
String otptNm = predefined.getOtptNm(); String otptNm = otptItemStng.string("OTPT_NM");
DataObject otptItemStng = byOtptItemStng.get(otptNm); DefaultOtptStng predefined = predefinedList.stream()
.filter(item -> item.getOtptNm().equals(otptNm)).toList().get(0);
float[] pstn = pdfPrintUtil.getPstnStng(predefined, otptItemStng, otptPaperSeCd);
float[] pstn = pdfPrintUtil.getPstnStng(predefined, otptItemStng, otptPaperSeCd);
boolean forPost = predefined.isForPost();
String defaultValue = predefined.getOtptBscVl(); String defaultValue = predefined.getOtptBscVl();
if(predefined.getContentType().equals("text")) { 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); int fontSz = pdfPrintUtil.getFontSize(predefined, otptItemStng);
RenderingMode fontStyle = pdfPrintUtil.getFontStyle(predefined, otptItemStng); RenderingMode fontStyle = pdfPrintUtil.getFontStyle(predefined, otptItemStng);
PDColor fontColor = pdfPrintUtil.getFontColor(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); 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); 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); pdfPrintUtil.insertImage(doc, contentStream, imagePath, pstn, size);

@ -29,6 +29,9 @@ SELECT SGG_CD
THEN INST_ADDR THEN INST_ADDR
ELSE CONCAT(INST_ADDR,' ',INST_DADDR) ELSE CONCAT(INST_ADDR,' ',INST_DADDR)
END) AS INST_FULL_ADDR <!-- 기관 전체 주소 --> END) AS INST_FULL_ADDR <!-- 기관 전체 주소 -->
, INST_ADRR
, INST_DADDR
, INST_ZIP
, OFFCS_FILE_PATH <!-- 직인 파일 경로 --> , OFFCS_FILE_PATH <!-- 직인 파일 경로 -->
, OFFCS_FILE_NM <!-- 직인 파일 명 --> , OFFCS_FILE_NM <!-- 직인 파일 명 -->
FROM TB_SGG_INFO FROM TB_SGG_INFO

@ -56,6 +56,8 @@
, C.CRDN_PLC /* 단속 장소 */ , C.CRDN_PLC /* 단속 장소 */
, CA.DTL_CRDN_PLC /* 상세 단속 장소 */ , CA.DTL_CRDN_PLC /* 상세 단속 장소 */
, C.VLTN_ID /* 위반 ID */ , C.VLTN_ID /* 위반 ID */
, VI.VLTN_ARTCL /* 위반 항목 */
, VI.VLTN_LAW_NM /* 위반 법 명 */
, IFNULL(CA.TOWNG_YN,'N') AS TOWNG_YN /* 견인 여부 */ , IFNULL(CA.TOWNG_YN,'N') AS TOWNG_YN /* 견인 여부 */
, (SELECT GET_CODE_NM('CMM006', IFNULL(CA.TOWNG_YN,'N')) FROM DUAL) AS TOWNG_YN_NM /* 견인 여부 명 */ , (SELECT GET_CODE_NM('CMM006', IFNULL(CA.TOWNG_YN,'N')) FROM DUAL) AS TOWNG_YN_NM /* 견인 여부 명 */
, C.CRDN_STTS_CHG_DT /* 단속 상태 변경 일시 */ , C.CRDN_STTS_CHG_DT /* 단속 상태 변경 일시 */

Loading…
Cancel
Save