pdf출력 수정

main
이범준 12 months ago
parent 187fef2946
commit eea9a2776a

@ -1,6 +1,5 @@
package cokr.xit.fims.cmmn.pdf; package cokr.xit.fims.cmmn.pdf;
import cokr.xit.fims.cmmn.pdf.format.Pstn;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
@ -8,10 +7,9 @@ import lombok.Setter;
@Setter @Setter
public class DefaultOtptStng { public class DefaultOtptStng {
public DefaultOtptStng(String contentType, String otptNm, String colNm, String otptBscVl){ public DefaultOtptStng(String contentType, String otptNm, String otptBscVl){
this.contentType = contentType; this.contentType = contentType;
this.otptNm=otptNm; this.otptNm=otptNm;
this.colNm=colNm;
this.otptBscVl=otptBscVl; this.otptBscVl=otptBscVl;
this.widthSz=0; this.widthSz=0;
@ -72,7 +70,6 @@ public class DefaultOtptStng {
private String contentType; private String contentType;
private String otptNm; private String otptNm;
private String colNm;
private String otptBscVl; private String otptBscVl;
private Pstn a4; private Pstn a4;
private Pstn letter; private Pstn letter;

@ -3,7 +3,10 @@ package cokr.xit.fims.cmmn.pdf;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public class PDFFormat { import cokr.xit.fims.sprt.PrintOption;
import cokr.xit.foundation.data.DataObject;
public abstract class PDFFormat {
protected List<DefaultOtptStng> defaultOtptStng = new ArrayList<DefaultOtptStng>(); protected List<DefaultOtptStng> defaultOtptStng = new ArrayList<DefaultOtptStng>();
@ -11,12 +14,12 @@ public class PDFFormat {
return this.defaultOtptStng; return this.defaultOtptStng;
} }
public DefaultOtptStng text(String otptNm, String colNm, String otptBscVl){ public DefaultOtptStng text(String otptNm, String otptBscVl){
return new DefaultOtptStng("text", otptNm, colNm, otptBscVl); return new DefaultOtptStng("text", otptNm, otptBscVl);
} }
public DefaultOtptStng image(String otptNm, String colNm){ public DefaultOtptStng image(String otptNm, String otptBscVl){
return new DefaultOtptStng("image" ,otptNm, colNm, ""); return new DefaultOtptStng("image", otptNm, otptBscVl);
} }
public void add(DefaultOtptStng... defaultOtptStngs){ public void add(DefaultOtptStng... defaultOtptStngs){
@ -25,4 +28,7 @@ public class PDFFormat {
} }
} }
public abstract String getMappingValue(String otptNm, String defaultValue,
DataObject dataObject, PrintOption printOption, PDFPrintUtil pdfPrintUtil);
} }

@ -175,39 +175,6 @@ public class PDFPrintUtil extends PrintUtil {
} }
} }
public String getTextValue(DefaultOtptStng defaultStng, DataObject sggStng, DataObject dataObject) {
String textValue = "";
if(sggStng != null && !sggStng.isEmpty() && !sggStng.string("COL_NM").equals("")) {
textValue = dataObject.string(sggStng.string("COL_NM"));
if(textValue.equals("")) {
textValue = sggStng.string("OTPT_BSC_VL");
}
} else {
textValue = dataObject.string(defaultStng.getColNm());
if(textValue.equals("")) {
textValue = defaultStng.getOtptBscVl();
}
}
return textValue;
}
public String getImagePath(DefaultOtptStng defaultStng, DataObject sggStng, DataObject dataObject) {
if(sggStng != null && !sggStng.isEmpty() && !sggStng.string("COL_NM").equals("")) {
return dataObject.string(sggStng.string("COL_NM"));
} else {
return dataObject.string(defaultStng.getColNm());
}
}
public float[] getSize(DefaultOtptStng defaultStng, DataObject sggStng) { public float[] getSize(DefaultOtptStng defaultStng, DataObject sggStng) {
if(sggStng != null && !sggStng.isEmpty()) { if(sggStng != null && !sggStng.isEmpty()) {
return new float[] { return new float[] {

@ -1,4 +1,4 @@
package cokr.xit.fims.cmmn.pdf.format; package cokr.xit.fims.cmmn.pdf;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;

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

@ -353,26 +353,30 @@ public class Sprt01ServiceBean extends AbstractServiceBean implements Sprt01Serv
for(DefaultOtptStng predefined : predefinedList) { for(DefaultOtptStng predefined : predefinedList) {
String otptNm = predefined.getOtptNm();
DataObject otptItemStng = byOtptItemStng.get(predefined.getOtptNm()); DataObject otptItemStng = byOtptItemStng.get(otptNm);
float[] pstn = pdfPrintUtil.getPstnStng(predefined, otptItemStng, otptPaperSeCd); float[] pstn = pdfPrintUtil.getPstnStng(predefined, otptItemStng, otptPaperSeCd);
if(predefined.getContentType().equals("text")) { String defaultValue = predefined.getOtptBscVl();
String textValue = pdfPrintUtil.getTextValue(predefined, otptItemStng, dataObject); if(predefined.getContentType().equals("text")) {
PDType0Font font = pdfPrintUtil.getFontStng(predefined, otptItemStng, fontMap); PDType0Font font = pdfPrintUtil.getFontStng(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);
pdfPrintUtil.writeText(contentStream, textValue, pstn, font, fontSz, fontStyle, fontColor); pdfPrintUtil.writeText(contentStream, textValue, pstn, font, fontSz, fontStyle, fontColor);
} else if(predefined.getContentType().equals("image")) { } else if(predefined.getContentType().equals("image")) {
String imagePath = pdfPrintUtil.getImagePath(predefined, otptItemStng, dataObject);
float[] size = pdfPrintUtil.getSize(predefined, otptItemStng); float[] size = pdfPrintUtil.getSize(predefined, otptItemStng);
String imagePath = pdfFormat.getMappingValue(otptNm,defaultValue,dataObject,printOption,pdfPrintUtil);
pdfPrintUtil.insertImage(doc, contentStream, imagePath, pstn, size); pdfPrintUtil.insertImage(doc, contentStream, imagePath, pstn, size);
} }

@ -9,9 +9,7 @@ SELECT OTPT_FORM_ID
, TASK_SE_CD , TASK_SE_CD
, SNDNG_SE_CD , SNDNG_SE_CD
, OTPT_PAPER_SE_CD , OTPT_PAPER_SE_CD
, COL_NM
, OTPT_NM , OTPT_NM
, OTPT_BSC_VL
, LEFT_PSTN , LEFT_PSTN
, TOP_PSTN , TOP_PSTN
, WIDTH_SZ , WIDTH_SZ

Loading…
Cancel
Save