소스 정리

main
이범준 7 months ago
parent 08da87490d
commit 377709d15d

@ -1,13 +1,12 @@
package cokr.xit.fims.cmmn; package cokr.xit.fims.cmmn;
import java.io.File;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import cokr.xit.foundation.UserInfo; import cokr.xit.foundation.UserInfo;
import cokr.xit.foundation.data.DataObject;
public class Print { public class Print {
@ -22,10 +21,15 @@ public class Print {
protected int fileNameIndex = 0; protected int fileNameIndex = 0;
private String formatName; protected String extension;
private String formatKorName; protected String formatName;
protected String formatKorName;
public String setExtension(String extension) {
return this.extension = extension;
}
public String getFormatName() { public String getFormatName() {
return this.formatName; return this.formatName;
@ -68,11 +72,6 @@ public class Print {
} }
public int getTotalDataCount(List<DataObject> dataObjectList) {
int totalDataCount = dataObjectList.size();
return totalDataCount;
}
public boolean getPrivateInfoYn(PrintOption printOption) { public boolean getPrivateInfoYn(PrintOption printOption) {
boolean privateInfoYn = true; boolean privateInfoYn = true;
@ -91,4 +90,24 @@ public class Print {
return map; return map;
} }
public String pathForNewFile(){
SimpleDateFormat ymdhmsFormat = new SimpleDateFormat("yyyyMMddHHmmss");
String currentTime = ymdhmsFormat.format(new Date());
String year = currentTime.substring(0, 4);
String month = currentTime.substring(4, 6);
String day = currentTime.substring(6, 8);
String formatFileResultRootPath = "files" + File.separator + "result" + File.separator + "print";
String formatFileResultFolderPath = formatFileResultRootPath
+ File.separator + year + File.separator + month + File.separator + day;
File formatFileResultFolder = new File(formatFileResultFolderPath);
if(!formatFileResultFolder.exists()) {
formatFileResultFolder.mkdirs();
}
String resultPath = formatFileResultFolderPath + File.separator + currentTime +"_"+ this.getFileNameIndex() + "."+this.extension;
this.setFileNameIndex(this.getFileNameIndex()+1);
return resultPath;
}
} }

@ -74,10 +74,6 @@ public class CrdnConfirm extends HWPFormat {
writer.table(0, 0, 13).setValues(List.of(newObj)); writer.table(0, 0, 13).setValues(List.of(newObj));
String tempPath = this.pathForNewFile(currentRunCount+1);
writer.write(tempPath);
resultFilesPath.add(tempPath);
} }

@ -65,7 +65,7 @@ public class CrdnList extends HWPFormat {
writer.setValue("주민번호", "*************"); writer.setValue("주민번호", "*************");
} }
writer.setValue("주소", globalRtpyrFullAddr); writer.setValue("주소", globalRtpyrFullAddr);
writer.setValue("총건수", DataFormat.n_nn0(print.getTotalDataCount(this.data))); writer.setValue("총건수", DataFormat.n_nn0(this.data.size()));
writer.setValue("총금액", DataFormat.n_nn0(globalTotalAmount)); writer.setValue("총금액", DataFormat.n_nn0(globalTotalAmount));
String instNm = (String) print.getPrintRequestUserInfo().getInfo().get("instNm"); String instNm = (String) print.getPrintRequestUserInfo().getInfo().get("instNm");
@ -93,7 +93,7 @@ public class CrdnList extends HWPFormat {
writer.table(2, 0, 3).setValues(list); writer.table(2, 0, 3).setValues(list);
String tempPath = this.pathForNewFile(currentRunCount+1); String tempPath = this.print.pathForNewFile();
writer.write(tempPath); writer.write(tempPath);
resultFilesPath.add(tempPath); resultFilesPath.add(tempPath);

@ -54,6 +54,10 @@ public class CvlcptOrgn extends HWPFormat {
@Override @Override
public HashMap<String, Object> makeFile(){ public HashMap<String, Object> makeFile(){
runAsWriter(); runAsWriter();
String tempPath = this.print.pathForNewFile();
writer.write(tempPath);
resultFilesPath.add(tempPath);
writer = null; writer = null;
currentRunCount++; currentRunCount++;
@ -63,6 +67,10 @@ public class CvlcptOrgn extends HWPFormat {
maxRunCount = data2.size()+1; maxRunCount = data2.size()+1;
while(currentRunCount != maxRunCount) { while(currentRunCount != maxRunCount) {
runAsWriter(); runAsWriter();
String tempPath_i = this.print.pathForNewFile();
writer.write(tempPath_i);
resultFilesPath.add(tempPath_i);
writer = null; writer = null;
currentRunCount++; currentRunCount++;
} }
@ -120,9 +128,6 @@ public class CvlcptOrgn extends HWPFormat {
} }
String tempPath = this.pathForNewFile(currentRunCount+1);
writer.write(tempPath);
resultFilesPath.add(tempPath);
} }

@ -74,9 +74,6 @@ public class DlbrDecsnList extends HWPFormat {
writer.setValue("심의회원명7", one.string("DLBR_MBR_NM7")); writer.setValue("심의회원명7", one.string("DLBR_MBR_NM7"));
writer.setValue("담당자검토의견", one.string("PIC_RVW_OPNN")); writer.setValue("담당자검토의견", one.string("PIC_RVW_OPNN"));
String tempPath = this.pathForNewFile(currentRunCount+1);
writer.write(tempPath);
resultFilesPath.add(tempPath);
} }

@ -1,9 +1,7 @@
package cokr.xit.fims.cmmn.hwp.format; package cokr.xit.fims.cmmn.hwp.format;
import java.io.File; import java.io.File;
import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -35,11 +33,16 @@ public abstract class HWPFormat {
this.data = dataObjectList; this.data = dataObjectList;
this.printOption = printOption; this.printOption = printOption;
this.print = print; this.print = print;
this.print.setExtension("hwp");
} }
public HashMap<String, Object> makeFile(){ public HashMap<String, Object> makeFile(){
while(currentRunCount != maxRunCount) { while(currentRunCount != maxRunCount) {
runAsWriter(); runAsWriter();
String tempPath = this.print.pathForNewFile();
writer.write(tempPath);
resultFilesPath.add(tempPath);
writer = null; writer = null;
currentRunCount++; currentRunCount++;
} }
@ -91,29 +94,6 @@ public abstract class HWPFormat {
public abstract List<String> getDownloadDataNames(); public abstract List<String> getDownloadDataNames();
public String pathForNewFile(int fileIndex) {
try {
SimpleDateFormat ymdhmsFormat = new SimpleDateFormat("yyyyMMddHHmmss");
String currentTime = ymdhmsFormat.format(new Date());
String year = currentTime.substring(0, 4);
String month = currentTime.substring(4, 6);
String day = currentTime.substring(6, 8);
String formatFileResultRootPath = "files" + File.separator + "result" + File.separator + "print";
String formatFileResultFolderPath = formatFileResultRootPath
+ File.separator + year + File.separator + month + File.separator + day;
File formatFileResultFolder = new File(formatFileResultFolderPath);
if(!formatFileResultFolder.exists()) {
formatFileResultFolder.mkdirs();
}
String resultHwpPath = formatFileResultFolderPath + File.separator + currentTime +"_"+fileIndex+ ".hwp";
return resultHwpPath;
} catch (Exception e){
throw new RuntimeException("한글 파일 출력 중 오류가 발생하였습니다.");
}
}
} }

@ -77,10 +77,6 @@ public class RcvmtConfirm extends HWPFormat {
writer.table(0, 0, 12).setValues(List.of(newObj)); writer.table(0, 0, 12).setValues(List.of(newObj));
String tempPath = this.pathForNewFile(currentRunCount+1);
writer.write(tempPath);
resultFilesPath.add(tempPath);
} }

@ -108,10 +108,6 @@ public class ReportOnClaims extends HWPFormat {
}).toList(); }).toList();
writer.table(0, 9, 2).setValues(list); writer.table(0, 9, 2).setValues(list);
String tempPath = this.pathForNewFile(currentRunCount+1);
writer.write(tempPath);
resultFilesPath.add(tempPath);
} }

@ -111,10 +111,6 @@ public class RequestForDelivery extends HWPFormat {
}).toList(); }).toList();
writer.table(0, 9, 1).setValues(list); writer.table(0, 9, 1).setValues(list);
String tempPath = this.pathForNewFile(currentRunCount+1);
writer.write(tempPath);
resultFilesPath.add(tempPath);
} }

@ -81,9 +81,6 @@ public class SvbtcList extends HWPFormat {
}).toList(); }).toList();
writer.table(2, 2, 2).setValues(list); writer.table(2, 2, 2).setValues(list);
String tempPath = this.pathForNewFile(currentRunCount+1);
writer.write(tempPath);
resultFilesPath.add(tempPath);
} }

@ -4,10 +4,8 @@ import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Comparator; import java.util.Comparator;
import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -54,6 +52,7 @@ public abstract class PDFPrintFormat {
initDefaultStng(); initDefaultStng();
this.print = print; this.print = print;
this.print.setExtension("pdf");
this.printOption = printOption; this.printOption = printOption;
this.otptBscStng = otptBscStng; this.otptBscStng = otptBscStng;
this.otptArtclStngList = otptArtclStngList; this.otptArtclStngList = otptArtclStngList;
@ -231,7 +230,7 @@ public abstract class PDFPrintFormat {
PDFWriter writer = new PDFWriter(); PDFWriter writer = new PDFWriter();
String resultFilePath = this.filePathForNewFile(); String resultFilePath = this.print.pathForNewFile();
//폰트 로드 //폰트 로드
@ -466,36 +465,6 @@ public abstract class PDFPrintFormat {
public String filePathForNewFile() {
SimpleDateFormat ymdhmsFormat = new SimpleDateFormat("yyyyMMddHHmmss");
String currentTime = ymdhmsFormat.format(new Date());
String year = currentTime.substring(0, 4);
String month = currentTime.substring(4, 6);
String day = currentTime.substring(6, 8);
String fileResultRootPath = "files" + File.separator + "result" + File.separator + "print";
String fileResultFolderPath = fileResultRootPath
+ File.separator + year + File.separator + month + File.separator + day;
File formatFileResultFolder = new File(fileResultFolderPath);
if(!formatFileResultFolder.exists()) {
formatFileResultFolder.mkdirs();
}
String resultPdfPath = fileResultFolderPath
+ File.separator + currentTime + "_" + (print.getFileNameIndex()) + ".pdf";
this.print.setFileNameIndex(this.print.getFileNameIndex()+1);
return resultPdfPath;
}
/** /**
* mm pdf . * mm pdf .
*/ */

@ -12,6 +12,7 @@ import cokr.xit.foundation.data.DataFormat;
public class FormatMaker { public class FormatMaker {
@SuppressWarnings("rawtypes")
public static Format photoCellForApproval(Format format, Comment comment, String key) { public static Format photoCellForApproval(Format format, Comment comment, String key) {
return format.of(key) return format.of(key)
.value(obj -> { .value(obj -> {
@ -47,6 +48,7 @@ public class FormatMaker {
} }
@SuppressWarnings("rawtypes")
public static Format yyyy_mm_dd_hh_mm_ss(Format format, String key) { public static Format yyyy_mm_dd_hh_mm_ss(Format format, String key) {
return format.of(key).value(o -> { return format.of(key).value(o -> {
return DataFormat.yyyy_mm_dd_hh_mm_ss(((Map) o).get(key)); return DataFormat.yyyy_mm_dd_hh_mm_ss(((Map) o).get(key));
@ -54,6 +56,7 @@ public class FormatMaker {
} }
@SuppressWarnings("rawtypes")
public static Format yyyy_mm_dd(Format format, String key) { public static Format yyyy_mm_dd(Format format, String key) {
return format.of(key).value(o -> { return format.of(key).value(o -> {
return DataFormat.yyyy_mm_dd(((Map) o).get(key)); return DataFormat.yyyy_mm_dd(((Map) o).get(key));

@ -19,7 +19,6 @@ import javax.net.ssl.SSLSession;
import javax.net.ssl.TrustManager; import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager; import javax.net.ssl.X509TrustManager;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;

Loading…
Cancel
Save