한글파일 다운로드 수정

main
이범준 9 months ago
parent 4e7c8516c1
commit d38244b1b3

@ -0,0 +1,130 @@
package cokr.xit.base.file.hwp;
import java.io.File;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.core.io.ClassPathResource;
import cokr.xit.fims.cmmn.Print;
import cokr.xit.fims.cmmn.hwp.AddUtil;
import cokr.xit.fims.cmmn.hwp.format.HWPFormat;
import cokr.xit.fims.sprt.PrintOption;
import cokr.xit.foundation.UserInfo;
import cokr.xit.foundation.data.DataObject;
import kr.dogfoot.hwplib.object.HWPFile;
import kr.dogfoot.hwplib.reader.HWPReader;
public class HWPWriter {
protected Print print;
protected HWPFormat format;
protected UserInfo printRequestUserInfo;
public void setPrintRequestUserInfo(UserInfo printRequestUserInfo) {
this.printRequestUserInfo = printRequestUserInfo;
};
public UserInfo getPrintRequestUserInfo() {
return this.printRequestUserInfo;
};
public HWPFormat setFormat(HWPFormat format) {
return this.format = format;
};
public Map<String, Object> makeFileFromHwpFormat(String formatType, Print print, PrintOption printOption, List<DataObject> dataObjectList) {
Map<String, Object> result = new HashMap<>();
this.print = new Print();
this.format.setting(print);
int totalDataCount = dataObjectList.size();
List<String> partFileList = new ArrayList<>();
this.format.calcTotalPartFileCount(totalDataCount);
try {
int dataIndex = 0;
for(int partFileIndex = 0; partFileIndex < this.format.getTotalPartFileCount(); partFileIndex++) {
//새 파일 생성
String resultHwpPath = this.format.newFileFromFormatFile(print);
HWPFile resultFile = HWPReader.fromFile(resultHwpPath);
//공통사항 세팅
this.format.writeGlobalInfo(resultFile, dataObjectList, printOption, print);
kr.dogfoot.hwplib.writer.HWPWriter.toFile(resultFile, resultHwpPath);
//데이터 건별 처리
for(int recordIndex = 0; recordIndex < this.format.getRecordPerPartFile(); recordIndex++) {
if(dataIndex < dataObjectList.size()) {
DataObject dataObject = dataObjectList.get(dataIndex);
if(formatType.equals("list")) {
InputStream attachFormatIS = new ClassPathResource(this.format.getAttachFormatFilePath()).getInputStream();
HWPFile attachFormatFile = HWPReader.fromInputStream(attachFormatIS);
this.format.writeSingleDataInfo(null, attachFormatFile, dataObject, print);
AddUtil.insertTableInCell(attachFormatFile, resultFile, "내부");
} else if(formatType.equals("info")){
this.format.writeSingleDataInfo(resultFile, null, dataObject, print);
}
}
if(formatType.equals("list")) {
dataIndex++;
}
}
if(!formatType.equals("list")) {
dataIndex++;
}
kr.dogfoot.hwplib.writer.HWPWriter.toFile(resultFile, resultHwpPath);
partFileList.add(resultHwpPath);
}
//결과파일 병합
if(partFileList.size() >= 2) {
String basePath = partFileList.get(0);
HWPFile baseFile = HWPReader.fromFile(basePath);
for(int i=2; i <= partFileList.size();i++) {
String attachPath = partFileList.get(i-1);
HWPFile attachFile = HWPReader.fromFile(attachPath);
AddUtil.appendToLast(attachFile, baseFile);
}
kr.dogfoot.hwplib.writer.HWPWriter.toFile(baseFile, basePath);
for(int i=2; i <= partFileList.size();i++) {
(new File(partFileList.get(i-1))).delete();
}
}
String downlaodFileName = print.getFormatKorName()+"_"+print.getPrintRequestDt()+".hwp";
result.put("filename", downlaodFileName);
String filePath = partFileList.get(0);
result.put("filePath", filePath);
result.put("file", new File(filePath));
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("한글 파일 출력 중 오류가 발생하였습니다.");
}
return result;
}
}

@ -0,0 +1,5 @@
package cokr.xit.base.file.pdf;
public class PDFWriter {
}

@ -10,34 +10,66 @@ import cokr.xit.fims.sprt.PrintOption;
import cokr.xit.foundation.UserInfo;
import cokr.xit.foundation.data.DataObject;
public class PrintUtil {
public class Print {
public PrintUtil(){
public Print(){
SimpleDateFormat ymdhmsFormat = new SimpleDateFormat("yyyyMMddHHmmss");
this.printRequestDt = ymdhmsFormat.format(new Date());
}
protected int fileNameIndex = 0;
protected String printRequestDt;
protected UserInfo printRequestUserInfo;
public String getPrintRequestDt() {
return this.printRequestDt;
protected int fileNameIndex = 0;
private String formatName;
private String formatKorName;
public String getFormatName() {
return this.formatName;
}
public void setPrintRequestDt(String printRequestDt) {
this.printRequestDt = printRequestDt;
public void setFormatName(String formatName) {
this.formatName = formatName;
}
public String getFormatKorName() {
return this.formatKorName;
}
public void setFormatKorName(String formatKorName) {
this.formatKorName = formatKorName;
}
public UserInfo getPrintRequestUserInfo() {
return this.printRequestUserInfo;
};
}
public void setPrintRequestUserInfo(UserInfo printRequestUserInfo) {
this.printRequestUserInfo = printRequestUserInfo;
};
}
public String getPrintRequestDt() {
return this.printRequestDt;
}
public void setPrintRequestDt(String printRequestDt) {
this.printRequestDt = printRequestDt;
}
public int getFileNameIndex() {
return this.fileNameIndex;
}
public int setFileNameIndex(int fileNameIndex) {
return this.fileNameIndex = fileNameIndex;
}
public float mmToPt(float mm) {
return mm * 2.83465f;

@ -1,35 +0,0 @@
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);
void setting(HWPPrintUtil hwpPrintUtil, int cnt);
/**
* @param
* @return
*/
void writeGlobalInfo(HWPFile baseFile, List<DataObject> dataObjectList,
PrintOption printOption, HWPPrintUtil hwpPrintUtil);
/**
* @param
* @return
*/
void writeSingleDataInfo(HWPFile baseFile, HWPFile attachFile, DataObject dataObject,
HWPPrintUtil hwpPrintUtil);
}

@ -3,9 +3,8 @@ package cokr.xit.fims.cmmn.hwp.format;
import java.util.List;
import cokr.xit.fims.cmmn.CmmnUtil;
import cokr.xit.fims.cmmn.Print;
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.mngt.FactionUtil;
import cokr.xit.fims.sprt.PrintOption;
@ -15,40 +14,44 @@ import kr.dogfoot.hwplib.object.HWPFile;
/**
*
*/
public class CrdnConfirm implements HWPFormatWriter {
public class CrdnConfirm extends HWPFormat {
@Override
public void setting(HWPPrintUtil hwpPrintUtil) {
hwpPrintUtil.setFormatName("crdnConfirm");
hwpPrintUtil.setFormatKorName("단속확인서");
public void setting(Print print) {
print.setFormatName("crdnConfirm");
print.setFormatKorName("단속확인서");
hwpPrintUtil.setFormatType("info");
hwpPrintUtil.setRecordPerPartFile(1);
this.setFormatType("info");
this.setRecordPerPartFile(1);
hwpPrintUtil.setBaseFormatFilePath("template/hwp/crdnConfirm.hwp");
hwpPrintUtil.setAttachFormatFilePath("");
this.setBaseFormatFilePath("template/hwp/crdnConfirm.hwp");
this.setAttachFormatFilePath("");
}
@Override
public void setting(HWPPrintUtil hwpPrintUtil, int recordCnt) {
hwpPrintUtil.setFormatName("crdnConfirm");
hwpPrintUtil.setFormatKorName("단속확인서");
public void setting(Print print, int recordCnt) {
print.setFormatName("crdnConfirm");
print.setFormatKorName("단속확인서");
hwpPrintUtil.setFormatType("info");
hwpPrintUtil.setRecordPerPartFile(recordCnt);
this.setFormatType("info");
this.setRecordPerPartFile(recordCnt);
hwpPrintUtil.setBaseFormatFilePath("template/hwp/crdnConfirm.hwp");
hwpPrintUtil.setAttachFormatFilePath("");
this.setBaseFormatFilePath("template/hwp/crdnConfirm.hwp");
this.setAttachFormatFilePath("");
}
@Override
public void writeGlobalInfo(HWPFile baseFile, List<DataObject> dataObjectList, PrintOption printOption,
HWPPrintUtil hwpPrintUtil) {
Print print) {
}
@Override
public void writeSingleDataInfo(HWPFile baseFile, HWPFile attachFile,
DataObject dataObject, HWPPrintUtil hwpPrintUtil) {
DataObject dataObject, Print print) {
ClickHereEditor baseFileEditor = new ClickHereEditor(baseFile);
@ -66,14 +69,14 @@ public class CrdnConfirm implements HWPFormatWriter {
baseFileEditor.set("주소", dataObject.string("RTPYR_FULL_ADDR"));
baseFileEditor.set("우편번호", dataObject.string("RTPYR_ZIP"));
String printRequestYmd = hwpPrintUtil.getPrintRequestDt().substring(0, 8);
String printRequestYmd = print.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");
String instNm = (String) print.getPrintRequestUserInfo().getInfo().get("instNm");
instNm = FactionUtil.getInstituteLeader(instNm, false);
baseFileEditor.set("발신", instNm);

@ -3,9 +3,8 @@ package cokr.xit.fims.cmmn.hwp.format;
import java.util.List;
import cokr.xit.fims.cmmn.CmmnUtil;
import cokr.xit.fims.cmmn.Print;
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.mngt.FactionUtil;
import cokr.xit.fims.sprt.PrintOption;
import cokr.xit.foundation.data.DataFormat;
@ -15,36 +14,38 @@ import kr.dogfoot.hwplib.object.HWPFile;
/**
*
*/
public class CrdnList implements HWPFormatWriter {
public class CrdnList extends HWPFormat {
@Override
public void setting(HWPPrintUtil hwpPrintUtil) {
hwpPrintUtil.setFormatName("crdnList");
hwpPrintUtil.setFormatKorName("단속내역서");
public void setting(Print print) {
print.setFormatName("crdnList");
print.setFormatKorName("단속내역서");
hwpPrintUtil.setFormatType("list");
hwpPrintUtil.setRecordPerPartFile(6);
this.setFormatType("list");
this.setRecordPerPartFile(6);
hwpPrintUtil.setBaseFormatFilePath("template/hwp/crdnList_root.hwp");
hwpPrintUtil.setAttachFormatFilePath("template/hwp/crdnList_inner.hwp");
this.setBaseFormatFilePath("template/hwp/crdnList_root.hwp");
this.setAttachFormatFilePath("template/hwp/crdnList_inner.hwp");
}
@Override
public void setting(HWPPrintUtil hwpPrintUtil, int recordCnt) {
hwpPrintUtil.setFormatName("crdnList");
hwpPrintUtil.setFormatKorName("단속내역서");
public void setting(Print print, int recordCnt) {
print.setFormatName("crdnList");
print.setFormatKorName("단속내역서");
hwpPrintUtil.setFormatType("list");
hwpPrintUtil.setRecordPerPartFile(recordCnt);
this.setFormatType("list");
this.setRecordPerPartFile(recordCnt);
hwpPrintUtil.setBaseFormatFilePath("template/hwp/crdnList_root.hwp");
hwpPrintUtil.setAttachFormatFilePath("template/hwp/crdnList_inner.hwp");
this.setBaseFormatFilePath("template/hwp/crdnList_root.hwp");
this.setAttachFormatFilePath("template/hwp/crdnList_inner.hwp");
}
@Override
public void writeGlobalInfo(HWPFile baseFile, List<DataObject> dataObjectList,
PrintOption printOption, HWPPrintUtil hwpPrintUtil
) {
PrintOption printOption, Print print) {
ClickHereEditor baseFileEditor = new ClickHereEditor(baseFile);
@ -55,26 +56,27 @@ public class CrdnList implements HWPFormatWriter {
//상단
baseFileEditor.set("성명", globalRtpyrNm);
if(hwpPrintUtil.getPrivateInfoYn(printOption)) {
if(print.getPrivateInfoYn(printOption)) {
baseFileEditor.set("주민번호", globalRtpyrNo);
} else {
baseFileEditor.set("주민번호", "*************");
}
baseFileEditor.set("주소", globalRtpyrFullAddr);
baseFileEditor.set("총건수", CmmnUtil.addCommaToNumber(hwpPrintUtil.getTotalDataCount(dataObjectList)));
baseFileEditor.set("총건수", CmmnUtil.addCommaToNumber(print.getTotalDataCount(dataObjectList)));
baseFileEditor.set("총금액", CmmnUtil.addCommaToNumber(globalTotalAmount));
baseFileEditor.set("출력일시", CmmnUtil.yyyy_mm_dd_hh_mm_ss(hwpPrintUtil.getPrintRequestDt()));
baseFileEditor.set("출력일시", CmmnUtil.yyyy_mm_dd_hh_mm_ss(print.getPrintRequestDt()));
String instNm = (String) hwpPrintUtil.getPrintRequestUserInfo().getInfo().get("instNm");
String instNm = (String) print.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) {
DataObject dataObject, Print print) {
ClickHereEditor attachFileEditor = new ClickHereEditor(attachFile);

@ -0,0 +1,95 @@
package cokr.xit.fims.cmmn.hwp.format;
import java.io.InputStream;
import java.util.List;
import org.springframework.core.io.ClassPathResource;
import cokr.xit.fims.cmmn.CmmnUtil;
import cokr.xit.fims.cmmn.Print;
import cokr.xit.fims.cmmn.hwp.AddUtil;
import cokr.xit.fims.cmmn.hwp.ClickHereEditor;
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;
import kr.dogfoot.hwplib.reader.HWPReader;
public class CvlcptOrgn extends HWPFormat {
@Override
public void setting(Print print) {
print.setFormatName("cvlcptOrgn");
print.setFormatKorName("민원원본내역");
this.setFormatType("info");
this.setRecordPerPartFile(1);
this.setBaseFormatFilePath("template/hwp/cvlcptOrgnl_text.hwp");
this.setAttachFormatFilePath("template/hwp/cvlcptOrgnl_photo.hwp");
}
@Override
public void setting(Print print, int cnt) {
}
@Override
public void writeGlobalInfo(HWPFile baseFile, List<DataObject> dataObjectList, PrintOption printOption,
Print print) {
}
@Override
public void writeSingleDataInfo(HWPFile baseFile, HWPFile attachFile, DataObject dataObject, Print print) {
ClickHereEditor baseFileEditor = new ClickHereEditor(baseFile);
baseFileEditor.set("신청자", dataObject.string("CVLCPT_APLCNT_NM"));
baseFileEditor.set("접수일자", DataFormat.yyyy_mm_dd(dataObject.string("CVLCPT_RCPT_YMD")));
String cvlcptRrcsPrnmntDt = dataObject.string("CVLCPT_PRCS_PRNMNT_DT");
if(cvlcptRrcsPrnmntDt.length() > 8) {
cvlcptRrcsPrnmntDt = cvlcptRrcsPrnmntDt.substring(0, 8);
}
baseFileEditor.set("처리기한", DataFormat.yyyy_mm_dd(cvlcptRrcsPrnmntDt));
baseFileEditor.set("접수번호", dataObject.string("CVLCPT_RCPT_NO"));
baseFileEditor.set("목록번호", dataObject.string("CVLCPT_LIST_NO"));
String cvlcptAplyCn = dataObject.string("CVLCPT_APLY_CN");
cvlcptAplyCn = CmmnUtil.escapeHTMLEntity(cvlcptAplyCn);
baseFileEditor.set("민원내용", cvlcptAplyCn);
try {
if(dataObject.string("PHOTO0") != null && !dataObject.string("PHOTO0").equals("")) {
System.out.println("원본사진있음");
int photoCnt = dataObject.number("ORGN_PHOTO_CNT").intValue();
int PHOTO_COUNT_PER_PAGE = 4;
for(int i=0; i < photoCnt; i += PHOTO_COUNT_PER_PAGE) {
InputStream attachFormatIS = new ClassPathResource(this.attachFormatFilePath).getInputStream();
HWPFile attachFormatFile = HWPReader.fromInputStream(attachFormatIS);
InsertingImageCell.IMPL_InsertPicture(attachFormatFile, "왼쪽위사진", dataObject.string("PHOTO"+i));
if(i+1 < photoCnt)
InsertingImageCell.IMPL_InsertPicture(attachFormatFile, "오른쪽위사진", dataObject.string("PHOTO"+(i+1)));
if(i+2 < photoCnt)
InsertingImageCell.IMPL_InsertPicture(attachFormatFile, "왼쪽아래사진", dataObject.string("PHOTO"+(i+2)));
if(i+3 < photoCnt)
InsertingImageCell.IMPL_InsertPicture(attachFormatFile, "오른쪽아래사진", dataObject.string("PHOTO"+(i+3)));
AddUtil.appendToLast(attachFormatFile, baseFile);
}
} else {
System.out.println("원본사진없음");
}
} catch (Exception e) {
throw new RuntimeException("[F]"+e);
}
}
}

@ -2,46 +2,49 @@ package cokr.xit.fims.cmmn.hwp.format;
import java.util.List;
import cokr.xit.fims.cmmn.Print;
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.DataObject;
import kr.dogfoot.hwplib.object.HWPFile;
public class DlbrDecsnList implements HWPFormatWriter {
public class DlbrDecsnList extends HWPFormat {
@Override
public void setting(HWPPrintUtil hwpPrintUtil) {
hwpPrintUtil.setFormatName("dlbrDecsn");
hwpPrintUtil.setFormatKorName("의견제출심의결의서");
public void setting(Print print) {
print.setFormatName("dlbrDecsn");
print.setFormatKorName("의견제출심의결의서");
hwpPrintUtil.setFormatType("info");
hwpPrintUtil.setRecordPerPartFile(1);
this.setFormatType("info");
this.setRecordPerPartFile(1);
hwpPrintUtil.setBaseFormatFilePath("template/hwp/opnnDlbrDecsnForm.hwp");
hwpPrintUtil.setAttachFormatFilePath("");
this.setBaseFormatFilePath("template/hwp/opnnDlbrDecsnForm.hwp");
this.setAttachFormatFilePath("");
}
@Override
public void setting(HWPPrintUtil hwpPrintUtil, int recordCnt) {
hwpPrintUtil.setFormatName("dlbrDecsn");
hwpPrintUtil.setFormatKorName("의견제출심의결의서");
public void setting(Print print, int recordCnt) {
print.setFormatName("dlbrDecsn");
print.setFormatKorName("의견제출심의결의서");
hwpPrintUtil.setFormatType("info");
hwpPrintUtil.setRecordPerPartFile(recordCnt);
this.setFormatType("info");
this.setRecordPerPartFile(recordCnt);
hwpPrintUtil.setBaseFormatFilePath("template/hwp/opnnDlbrDecsnForm.hwp");
hwpPrintUtil.setAttachFormatFilePath("");
this.setBaseFormatFilePath("template/hwp/opnnDlbrDecsnForm.hwp");
this.setAttachFormatFilePath("");
}
@Override
public void writeGlobalInfo(HWPFile baseFile, List<DataObject> dataObjectList, PrintOption printOption, HWPPrintUtil hwpPrintUtil) {
public void writeGlobalInfo(HWPFile baseFile, List<DataObject> dataObjectList, PrintOption printOption, Print print) {
}
@Override
public void writeSingleDataInfo(HWPFile baseFile, HWPFile attachFile, DataObject dataObject, HWPPrintUtil hwpPrintUtil) {
public void writeSingleDataInfo(HWPFile baseFile, HWPFile attachFile, DataObject dataObject, Print print) {
//
ClickHereEditor baseFileEditor = new ClickHereEditor(baseFile);

@ -1,32 +1,31 @@
package cokr.xit.fims.cmmn.hwp;
package cokr.xit.fims.cmmn.hwp.format;
import java.io.File;
import java.io.InputStream;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import org.springframework.core.io.ClassPathResource;
import cokr.xit.fims.cmmn.PrintUtil;
import cokr.xit.fims.cmmn.Print;
import cokr.xit.fims.sprt.PrintOption;
import cokr.xit.foundation.data.DataObject;
import kr.dogfoot.hwplib.object.HWPFile;
import kr.dogfoot.hwplib.reader.HWPReader;
import kr.dogfoot.hwplib.writer.HWPWriter;
public class HWPPrintUtil extends PrintUtil {
public abstract class HWPFormat {
private String formatType;
protected String formatType;
private String formatName;
protected int recordPerPartFile;
private String formatKorName;
protected String baseFormatFilePath;
private int recordPerPartFile;
protected String attachFormatFilePath;
private String baseFormatFilePath;
private String attachFormatFilePath;
private int totalPartFileCount;
protected int totalPartFileCount;
public String getFormatType() {
return this.formatType;
@ -35,23 +34,6 @@ public class HWPPrintUtil extends PrintUtil {
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 int getRecordPerPartFile() {
return this.recordPerPartFile;
}
@ -84,6 +66,7 @@ public class HWPPrintUtil extends PrintUtil {
this.attachFormatFilePath = attachFormatFilePath;
}
/** .
* @param
* @return
@ -115,7 +98,7 @@ public class HWPPrintUtil extends PrintUtil {
* @param formatFile
* @return
*/
public String newFileFromFormatFile() {
public String newFileFromFormatFile(Print print) {
try {
InputStream baseFormatIS = new ClassPathResource(this.getBaseFormatFilePath()).getInputStream();
@ -134,7 +117,9 @@ public class HWPPrintUtil extends PrintUtil {
formatFileResultFolder.mkdirs();
}
String resultHwpPath = formatFileResultFolderPath
+ File.separator + currentTime + "_" + (this.fileNameIndex++) + ".hwp";
+ File.separator + currentTime + "_" + (print.getFileNameIndex()) + ".hwp";
print.setFileNameIndex(print.getFileNameIndex()+1);
HWPWriter.toFile(baseFormatFile, resultHwpPath);
return resultHwpPath;
@ -145,4 +130,26 @@ public class HWPPrintUtil extends PrintUtil {
}
/** .
* @param hwpPrintUtil
* @return
*/
public abstract void setting(Print print);
public abstract void setting(Print print, int cnt);
/**
* @param
* @return
*/
public abstract void writeGlobalInfo(HWPFile baseFile, List<DataObject> dataObjectList,
PrintOption printOption, Print print);
/**
* @param
* @return
*/
public abstract void writeSingleDataInfo(HWPFile baseFile, HWPFile attachFile, DataObject dataObject,
Print print);
}

@ -3,9 +3,8 @@ package cokr.xit.fims.cmmn.hwp.format;
import java.util.List;
import cokr.xit.fims.cmmn.CmmnUtil;
import cokr.xit.fims.cmmn.Print;
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.mngt.FactionUtil;
import cokr.xit.fims.sprt.PrintOption;
import cokr.xit.foundation.data.DataFormat;
@ -15,40 +14,44 @@ import kr.dogfoot.hwplib.object.HWPFile;
/**
*
*/
public class RcvmtConfirm implements HWPFormatWriter {
public class RcvmtConfirm extends HWPFormat {
@Override
public void setting(HWPPrintUtil hwpPrintUtil) {
hwpPrintUtil.setFormatName("rcvmtConfirm");
hwpPrintUtil.setFormatKorName("납부확인서");
public void setting(Print print) {
print.setFormatName("rcvmtConfirm");
print.setFormatKorName("납부확인서");
hwpPrintUtil.setFormatType("info");
hwpPrintUtil.setRecordPerPartFile(1);
this.setFormatType("info");
this.setRecordPerPartFile(1);
hwpPrintUtil.setBaseFormatFilePath("template/hwp/rcvmtConfirm.hwp");
hwpPrintUtil.setAttachFormatFilePath("");
this.setBaseFormatFilePath("template/hwp/rcvmtConfirm.hwp");
this.setAttachFormatFilePath("");
}
@Override
public void setting(HWPPrintUtil hwpPrintUtil, int recordCnt) {
hwpPrintUtil.setFormatName("rcvmtConfirm");
hwpPrintUtil.setFormatKorName("납부확인서");
public void setting(Print print, int recordCnt) {
print.setFormatName("rcvmtConfirm");
print.setFormatKorName("납부확인서");
hwpPrintUtil.setFormatType("info");
hwpPrintUtil.setRecordPerPartFile(recordCnt);
this.setFormatType("info");
this.setRecordPerPartFile(recordCnt);
hwpPrintUtil.setBaseFormatFilePath("template/hwp/rcvmtConfirm.hwp");
hwpPrintUtil.setAttachFormatFilePath("");
this.setBaseFormatFilePath("template/hwp/rcvmtConfirm.hwp");
this.setAttachFormatFilePath("");
}
@Override
public void writeGlobalInfo(HWPFile baseFile, List<DataObject> dataObjectList, PrintOption printOption,
HWPPrintUtil hwpPrintUtil) {
Print print) {
}
@Override
public void writeSingleDataInfo(HWPFile baseFile, HWPFile attachFile,
DataObject dataObject, HWPPrintUtil hwpPrintUtil) {
DataObject dataObject, Print print) {
ClickHereEditor baseFileEditor = new ClickHereEditor(baseFile);
@ -66,10 +69,10 @@ public class RcvmtConfirm implements HWPFormatWriter {
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());
baseFileEditor.set("연월일시분초", CmmnUtil.yyyy_mm_dd_hh_mm_ss(print.getPrintRequestDt()));
baseFileEditor.set("확인자", print.getPrintRequestUserInfo().getName());
String instNm = (String) hwpPrintUtil.getPrintRequestUserInfo().getInfo().get("instNm");
String instNm = (String) print.getPrintRequestUserInfo().getInfo().get("instNm");
instNm = FactionUtil.getInstituteLeader(instNm, false);
baseFileEditor.set("발신", instNm);

@ -6,9 +6,8 @@ import java.util.Map;
import org.egovframe.rte.fdl.string.EgovStringUtil;
import cokr.xit.fims.cmmn.CmmnUtil;
import cokr.xit.fims.cmmn.Print;
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.mngt.FactionUtil;
import cokr.xit.fims.sprt.PrintOption;
@ -19,45 +18,47 @@ import kr.dogfoot.hwplib.object.HWPFile;
/**
*
*/
public class ReportOnClaims implements HWPFormatWriter {
public class ReportOnClaims extends HWPFormat {
@Override
public void setting(HWPPrintUtil hwpPrintUtil) {
hwpPrintUtil.setFormatName("reportOnClaims");
hwpPrintUtil.setFormatKorName("채권신고서");
public void setting(Print print) {
print.setFormatName("reportOnClaims");
print.setFormatKorName("채권신고서");
hwpPrintUtil.setFormatType("list");
hwpPrintUtil.setRecordPerPartFile(7);
this.setFormatType("list");
this.setRecordPerPartFile(7);
hwpPrintUtil.setBaseFormatFilePath("template/hwp/reportOnClaims_root.hwp");
hwpPrintUtil.setAttachFormatFilePath("template/hwp/reportOnClaims_inner.hwp");
this.setBaseFormatFilePath("template/hwp/reportOnClaims_root.hwp");
this.setAttachFormatFilePath("template/hwp/reportOnClaims_inner.hwp");
}
@Override
public void setting(HWPPrintUtil hwpPrintUtil, int recordCnt) {
hwpPrintUtil.setFormatName("reportOnClaims");
hwpPrintUtil.setFormatKorName("채권신고서");
public void setting(Print print, int recordCnt) {
print.setFormatName("reportOnClaims");
print.setFormatKorName("채권신고서");
hwpPrintUtil.setFormatType("list");
hwpPrintUtil.setRecordPerPartFile(recordCnt);
this.setFormatType("list");
this.setRecordPerPartFile(recordCnt);
hwpPrintUtil.setBaseFormatFilePath("template/hwp/reportOnClaims_root.hwp");
hwpPrintUtil.setAttachFormatFilePath("template/hwp/reportOnClaims_inner.hwp");
this.setBaseFormatFilePath("template/hwp/reportOnClaims_root.hwp");
this.setAttachFormatFilePath("template/hwp/reportOnClaims_inner.hwp");
}
@Override
public void writeGlobalInfo(HWPFile baseFile, List<DataObject> dataObjectList, PrintOption printOption,
HWPPrintUtil hwpPrintUtil) {
Print print) {
Map<String,String> globalVariable = hwpPrintUtil.getGlobalVariable(printOption);
Map<String,String> globalVariable = print.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("담당자", print.getPrintRequestUserInfo().getName());
baseFileEditor.set("사건번호", EgovStringUtil.null2void(globalVariable.get("caseNo")));
baseFileEditor.set("체납자성명", EgovStringUtil.null2void(globalVariable.get("rtpyrNm")));
@ -70,14 +71,14 @@ public class ReportOnClaims implements HWPFormatWriter {
baseFileEditor.set("합계금액", CmmnUtil.addCommaToNumber(sumOfList));
baseFileEditor.set("합계금액한글", CmmnUtil.convertNumberToHangul(sumOfList));
String printRequestYmd = hwpPrintUtil.getPrintRequestDt().substring(0, 8);
String printRequestYmd = print.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");
String instNm = (String) print.getPrintRequestUserInfo().getInfo().get("instNm");
instNm = FactionUtil.getLastWord(instNm);
instNm = FactionUtil.getInstituteLeader(instNm, false);
baseFileEditor.set("발신", instNm);
@ -91,9 +92,10 @@ public class ReportOnClaims implements HWPFormatWriter {
}
@Override
public void writeSingleDataInfo(HWPFile baseFile, HWPFile attachFile,
DataObject dataObject, HWPPrintUtil hwpPrintUtil) {
DataObject dataObject, Print print) {
ClickHereEditor attachFileEditor = new ClickHereEditor(attachFile);

@ -6,9 +6,8 @@ import java.util.Map;
import org.egovframe.rte.fdl.string.EgovStringUtil;
import cokr.xit.fims.cmmn.CmmnUtil;
import cokr.xit.fims.cmmn.Print;
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.mngt.FactionUtil;
import cokr.xit.fims.sprt.PrintOption;
@ -19,39 +18,41 @@ import kr.dogfoot.hwplib.object.HWPFile;
/**
*
*/
public class RequestForDelivery implements HWPFormatWriter {
public class RequestForDelivery extends HWPFormat {
@Override
public void setting(HWPPrintUtil hwpPrintUtil) {
hwpPrintUtil.setFormatName("requestForDelivery");
hwpPrintUtil.setFormatKorName("교부청구서");
public void setting(Print print) {
print.setFormatName("requestForDelivery");
print.setFormatKorName("교부청구서");
hwpPrintUtil.setFormatType("list");
hwpPrintUtil.setRecordPerPartFile(7);
this.setFormatType("list");
this.setRecordPerPartFile(7);
hwpPrintUtil.setBaseFormatFilePath("template/hwp/requestForDelivery_root.hwp");
hwpPrintUtil.setAttachFormatFilePath("template/hwp/requestForDelivery_inner.hwp");
this.setBaseFormatFilePath("template/hwp/requestForDelivery_root.hwp");
this.setAttachFormatFilePath("template/hwp/requestForDelivery_inner.hwp");
}
@Override
public void setting(HWPPrintUtil hwpPrintUtil, int recordCnt) {
hwpPrintUtil.setFormatName("requestForDelivery");
hwpPrintUtil.setFormatKorName("교부청구서");
public void setting(Print print, int recordCnt) {
print.setFormatName("requestForDelivery");
print.setFormatKorName("교부청구서");
hwpPrintUtil.setFormatType("list");
hwpPrintUtil.setRecordPerPartFile(recordCnt);
this.setFormatType("list");
this.setRecordPerPartFile(recordCnt);
hwpPrintUtil.setBaseFormatFilePath("template/hwp/requestForDelivery_root.hwp");
hwpPrintUtil.setAttachFormatFilePath("template/hwp/requestForDelivery_inner.hwp");
this.setBaseFormatFilePath("template/hwp/requestForDelivery_root.hwp");
this.setAttachFormatFilePath("template/hwp/requestForDelivery_inner.hwp");
}
@Override
public void writeGlobalInfo(HWPFile baseFile, List<DataObject> dataObjectList,
PrintOption printOption, HWPPrintUtil hwpPrintUtil) {
PrintOption printOption, Print print) {
ClickHereEditor baseFileEditor = new ClickHereEditor(baseFile);
Map<String,String> globalVariable = hwpPrintUtil.getGlobalVariable(printOption);
Map<String,String> globalVariable = print.getGlobalVariable(printOption);
baseFileEditor.set("문서번호", EgovStringUtil.null2void(globalVariable.get("docNo")));
baseFileEditor.set("사건번호", EgovStringUtil.null2void(globalVariable.get("caseNo")));
@ -70,11 +71,11 @@ public class RequestForDelivery implements HWPFormatWriter {
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");
String instNm = (String) print.getPrintRequestUserInfo().getInfo().get("instNm");
String deptNm = (String) print.getPrintRequestUserInfo().getInfo().get("deptNm");
baseFileEditor.set("예금주", instNm + " " + deptNm);
String printRequestYmd = hwpPrintUtil.getPrintRequestDt().substring(0, 8);
String printRequestYmd = print.getPrintRequestDt().substring(0, 8);
String yyyy = printRequestYmd.substring(0, 4);
String mm = printRequestYmd.substring(4, 6);
String dd = printRequestYmd.substring(6, 8);
@ -92,9 +93,10 @@ public class RequestForDelivery implements HWPFormatWriter {
}
}
@Override
public void writeSingleDataInfo(HWPFile baseFile, HWPFile attachFile,
DataObject dataObject, HWPPrintUtil hwpPrintUtil) {
DataObject dataObject, Print print) {
ClickHereEditor attachFileEditor = new ClickHereEditor(attachFile);

@ -2,42 +2,44 @@ package cokr.xit.fims.cmmn.hwp.format;
import java.util.List;
import cokr.xit.fims.cmmn.Print;
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 SvbtcList implements HWPFormatWriter {
public class SvbtcList extends HWPFormat {
@Override
public void setting(HWPPrintUtil hwpPrintUtil) {
hwpPrintUtil.setFormatName("svbtc");
hwpPrintUtil.setFormatKorName("공시송달");
public void setting(Print print) {
print.setFormatName("svbtc");
print.setFormatKorName("공시송달");
hwpPrintUtil.setFormatType("list");
hwpPrintUtil.setRecordPerPartFile(9);
this.setFormatType("list");
this.setRecordPerPartFile(9);
hwpPrintUtil.setBaseFormatFilePath("template/hwp/svbtcList_root.hwp");
hwpPrintUtil.setAttachFormatFilePath("template/hwp/svbtcList_inner.hwp");
this.setBaseFormatFilePath("template/hwp/svbtcList_root.hwp");
this.setAttachFormatFilePath("template/hwp/svbtcList_inner.hwp");
}
@Override
public void setting(HWPPrintUtil hwpPrintUtil, int recordCnt) {
hwpPrintUtil.setFormatName("svbtc");
hwpPrintUtil.setFormatKorName("공시송달");
public void setting(Print print, int recordCnt) {
print.setFormatName("svbtc");
print.setFormatKorName("공시송달");
hwpPrintUtil.setFormatType("list");
hwpPrintUtil.setRecordPerPartFile(recordCnt);
this.setFormatType("list");
this.setRecordPerPartFile(recordCnt);
hwpPrintUtil.setBaseFormatFilePath("template/hwp/svbtcList_root.hwp");
hwpPrintUtil.setAttachFormatFilePath("template/hwp/svbtcList_inner.hwp");
this.setBaseFormatFilePath("template/hwp/svbtcList_root.hwp");
this.setAttachFormatFilePath("template/hwp/svbtcList_inner.hwp");
}
@Override
public void writeGlobalInfo(HWPFile baseFile, List<DataObject> dataObjectList, PrintOption printOption, HWPPrintUtil hwpPrintUtil) {
public void writeGlobalInfo(HWPFile baseFile, List<DataObject> dataObjectList, PrintOption printOption, Print print) {
//
ClickHereEditor baseFileEditor = new ClickHereEditor(baseFile);
@ -58,8 +60,9 @@ public class SvbtcList implements HWPFormatWriter {
}
}
@Override
public void writeSingleDataInfo(HWPFile baseFile, HWPFile attachFile, DataObject dataObject, HWPPrintUtil hwpPrintUtil) {
public void writeSingleDataInfo(HWPFile baseFile, HWPFile attachFile, DataObject dataObject, Print print) {
//
ClickHereEditor attachFileEditor = new ClickHereEditor(attachFile);

@ -12,12 +12,12 @@ import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.PDPage;
import org.apache.pdfbox.pdmodel.PDPageTree;
import cokr.xit.fims.cmmn.PrintUtil;
import cokr.xit.fims.cmmn.Print;
import cokr.xit.foundation.data.DataObject;
public class PDFExtractionUtil {
public static List<Extraction> extract(String pdfPath, List<DataObject> extractStngs) {
PrintUtil printUtil = new PrintUtil();
Print printUtil = new Print();
List<Extraction> extractList = new ArrayList<Extraction>();

@ -18,7 +18,7 @@ import org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject;
import org.apache.pdfbox.pdmodel.graphics.state.RenderingMode;
import org.springframework.core.io.ClassPathResource;
import cokr.xit.fims.cmmn.PrintUtil;
import cokr.xit.fims.cmmn.Print;
import cokr.xit.fims.cmmn.pdf.PDFColors;
import cokr.xit.fims.cmmn.pdf.PDFCoordinate;
import cokr.xit.fims.cmmn.pdf.Pstn;
@ -26,12 +26,10 @@ import cokr.xit.fims.cmmn.pdf.PstnAndSize;
import cokr.xit.fims.cmmn.pdf.Size;
import cokr.xit.foundation.data.DataObject;
public class PDFPrintUtil extends PrintUtil {
public class PDFPrintUtil extends Print {
private float[] paperMilimeter = new float[2];
private String formatKorName;
public void setting(String paperType) {
if(paperType.equals("01")) {
this.paperMilimeter = new float[] {210.0f , 297.0f};
@ -40,13 +38,6 @@ public class PDFPrintUtil extends PrintUtil {
}
}
public String getFormatKorName() {
return this.formatKorName;
}
public String setFormatKorName(String formatKorName) {
return this.formatKorName = formatKorName;
}
public String filePathForNewFile() {

@ -34,15 +34,6 @@ public interface CrdnCvlcptService {
*/
DataObject getAnswerPreview(CrdnQuery query);
/** .
* @param query
* @return map
* <ul><li>filePath: </li>
* <li>fileName: </li>
* </ul>
*/
Map<String, Object> makeFileFromHwpFormat(CrdnQuery query);
/** ().
* @param crdnID ID
* @return

@ -1,19 +1,13 @@
package cokr.xit.fims.cvlc.service.bean;
import java.io.File;
import java.io.InputStream;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import javax.annotation.Resource;
import org.springframework.core.io.ClassPathResource;
import org.springframework.stereotype.Service;
import cokr.xit.base.file.service.FileQuery;
@ -22,8 +16,6 @@ import cokr.xit.fims.cmmn.CmmnUtil;
import cokr.xit.fims.cmmn.CrdnSttsHstry;
import cokr.xit.fims.cmmn.dao.CrdnPayerHstryMapper;
import cokr.xit.fims.cmmn.dao.CrdnSttsHstryMapper;
import cokr.xit.fims.cmmn.hwp.AddUtil;
import cokr.xit.fims.cmmn.hwp.InsertingImageCell;
import cokr.xit.fims.cmmn.service.bean.CrdnSttsHstryBean;
import cokr.xit.fims.crdn.Crdn;
import cokr.xit.fims.crdn.CrdnQuery;
@ -43,10 +35,6 @@ import cokr.xit.fims.sprt.service.bean.MediaBean;
import cokr.xit.foundation.component.AbstractServiceBean;
import cokr.xit.foundation.data.DataObject;
import cokr.xit.interfaces.disabledparking.service.bean.DisabledParkingBean;
import kr.dogfoot.hwplib.object.HWPFile;
import kr.dogfoot.hwplib.reader.HWPReader;
import kr.dogfoot.hwplib.tool.objectfinder.FieldFinder;
import kr.dogfoot.hwplib.writer.HWPWriter;
@Service("crdnCvlcptService")
public class CrdnCvlcptServiceBean extends AbstractServiceBean implements CrdnCvlcptService {
@ -144,134 +132,6 @@ public class CrdnCvlcptServiceBean extends AbstractServiceBean implements CrdnCv
return dataObjectList;
}
@Override
public Map<String, Object> makeFileFromHwpFormat(CrdnQuery query) {
String baseFormatFilePath = ("template/hwp/cvlcptOrgnl_text.hwp");
String attachFormatFilePath = ("template/hwp/cvlcptOrgnl_photo.hwp");
DataObject dataObject = crdnCvlcptMainBean.getCivilComplaintOriginalInfo(query);
SimpleDateFormat ymdhmsFormat = new SimpleDateFormat("yyyyMMddHHmmss");
SimpleDateFormat ymdFormat = new SimpleDateFormat("yyyyMMdd");
SimpleDateFormat ymdHypenFormat = new SimpleDateFormat("yyyy-MM-dd");
try {
InputStream baseFormatIS = new ClassPathResource(baseFormatFilePath).getInputStream();
HWPFile baseFormatFile = HWPReader.fromInputStream(baseFormatIS);
ArrayList<String> strings = new ArrayList<String>();
strings.add(dataObject.string("CVLCPT_APLCNT_NM"));
FieldFinder.setClickHereText(baseFormatFile, "신청자", strings);
strings = new ArrayList<String>();
String cvlcptRcptYmd = dataObject.string("CVLCPT_RCPT_YMD");
cvlcptRcptYmd = ymdHypenFormat.format(ymdFormat.parse(cvlcptRcptYmd));
strings.add(cvlcptRcptYmd);
FieldFinder.setClickHereText(baseFormatFile, "접수일자", strings);
strings = new ArrayList<String>();
String cvlcptRrcsPrnmntDt = dataObject.string("CVLCPT_PRCS_PRNMNT_DT");
if(cvlcptRrcsPrnmntDt.length() > 8) {
cvlcptRrcsPrnmntDt = cvlcptRrcsPrnmntDt.substring(0, 8);
}
cvlcptRrcsPrnmntDt = ymdHypenFormat.format(ymdFormat.parse(cvlcptRrcsPrnmntDt));
strings.add(cvlcptRrcsPrnmntDt);
FieldFinder.setClickHereText(baseFormatFile, "처리기한", strings);
strings = new ArrayList<String>();
strings.add(dataObject.string("CVLCPT_RCPT_NO"));
FieldFinder.setClickHereText(baseFormatFile, "접수번호", strings);
strings = new ArrayList<String>();
strings.add(dataObject.string("CVLCPT_LIST_NO"));
FieldFinder.setClickHereText(baseFormatFile, "목록번호", strings);
strings = new ArrayList<String>();
String cvlcptAplyCn = dataObject.string("CVLCPT_APLY_CN");
cvlcptAplyCn = CmmnUtil.escapeHTMLEntity(cvlcptAplyCn);
strings.add(cvlcptAplyCn);
FieldFinder.setClickHereText(baseFormatFile, "민원내용", strings);
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 + ".hwp";
HWPWriter.toFile(baseFormatFile, resultHwpPath);
HWPFile resultFile = HWPReader.fromFile(resultHwpPath);
String linkTblNm = dataObject.string("LINK_TBL_NM");
if(!(ifEmpty(linkTblNm, () -> "").equals(""))) {
FileQuery fileQuery = new FileQuery();
if(linkTblNm.equals("TB_ESB_INTERFACE")) {
fileQuery.setInfoType("010");
} else if(linkTblNm.equals("TB_SAEOL")) {
fileQuery.setInfoType("020");
} else {
throw new RuntimeException("한글 파일 출력 중 오류가 발생하였습니다.");
}
fileQuery.setInfoKeys(dataObject.string("LINK_ID"));
List<DataObject> fileInfoList = fileBean.getFileList(fileQuery);
fileInfoList = fileInfoList.stream()
.filter(fileInfo -> fileInfo.string("MIME_TYPE").startsWith("image"))
.collect(Collectors.toList());
if(fileInfoList != null && fileInfoList.size() > 0) {
int photoCnt = fileInfoList.size();
int PHOTO_COUNT_PER_PAGE = 4;
for(int i=0; i < photoCnt; i += PHOTO_COUNT_PER_PAGE) {
InputStream attachFormatIS = new ClassPathResource(attachFormatFilePath).getInputStream();
HWPFile attachFormatFile = HWPReader.fromInputStream(attachFormatIS);
InsertingImageCell.IMPL_InsertPicture(attachFormatFile, "왼쪽위사진", fileInfoList.get(i).string("URL"));
if(i+1 < photoCnt)
InsertingImageCell.IMPL_InsertPicture(attachFormatFile, "오른쪽위사진", fileInfoList.get(i+1).string("URL"));
if(i+2 < photoCnt)
InsertingImageCell.IMPL_InsertPicture(attachFormatFile, "왼쪽아래사진", fileInfoList.get(i+2).string("URL"));
if(i+3 < photoCnt)
InsertingImageCell.IMPL_InsertPicture(attachFormatFile, "오른쪽아래사진", fileInfoList.get(i+3).string("URL"));
AddUtil.appendToLast(attachFormatFile, resultFile);
}
HWPWriter.toFile(resultFile, resultHwpPath);
}
}
String downlaodFileName = "민원내역원본_" + currentTime + ".hwp";
Map<String, Object> result = Map.of(
"filename", downlaodFileName,
"filePath", resultHwpPath,
"file", new File(resultHwpPath)
);
return result;
} catch (Exception e) {
throw new RuntimeException("한글 파일 출력 중 오류가 발생하였습니다.");
}
}
@Override
public DataObject getCivilComplaintOriginalInfo(CrdnQuery query) {
return crdnCvlcptMainBean.getCivilComplaintOriginalInfo(query);

@ -4,6 +4,7 @@ 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;
import javax.servlet.http.HttpServletRequest;
@ -14,6 +15,9 @@ import org.springframework.web.servlet.ModelAndView;
import com.fasterxml.jackson.core.type.TypeReference;
import cokr.xit.base.code.CommonCode;
import cokr.xit.base.file.hwp.HWPWriter;
import cokr.xit.base.file.service.FileQuery;
import cokr.xit.base.file.service.bean.FileBean;
import cokr.xit.base.file.xls.XLSWriter;
import cokr.xit.base.file.xls.XLSWriter.CellDef;
import cokr.xit.base.file.xls.XLSWriter.Styler;
@ -21,6 +25,8 @@ import cokr.xit.base.user.ManagedUser;
import cokr.xit.base.user.dao.UserMapper;
import cokr.xit.base.web.ApplicationController;
import cokr.xit.fims.cmmn.CmmnUtil;
import cokr.xit.fims.cmmn.Print;
import cokr.xit.fims.cmmn.hwp.format.CvlcptOrgn;
import cokr.xit.fims.cmmn.service.bean.StngBean;
import cokr.xit.fims.crdn.Crdn;
import cokr.xit.fims.crdn.CrdnQuery;
@ -28,6 +34,9 @@ import cokr.xit.fims.crdn.dao.GlobalStngMapper;
import cokr.xit.fims.crdn.service.CrdnService;
import cokr.xit.fims.cvlc.CrdnCvlcpt;
import cokr.xit.fims.cvlc.service.CrdnCvlcptService;
import cokr.xit.fims.cvlc.service.bean.CrdnCvlcptMainBean;
import cokr.xit.fims.mngt.service.bean.FactionBean;
import cokr.xit.fims.sprt.PrintOption;
import cokr.xit.foundation.UserInfo;
import cokr.xit.foundation.data.DataObject;
@ -68,6 +77,15 @@ public class Cvlc01Controller extends ApplicationController {
@Resource(name = "stngBean")
private StngBean stngBean;
@Resource(name = "fileBean")
private FileBean fileBean;
@Resource(name = "factionBean")
private FactionBean factionBean;
@Resource(name = "crdnCvlcptMainBean")
private CrdnCvlcptMainBean crdnCvlcptMainBean;
/** .
* @return fims/cvlc/cvlc01010-main
*/
@ -193,7 +211,49 @@ public class Cvlc01Controller extends ApplicationController {
*/
public ModelAndView makeFileFromHwpFormat(CrdnQuery query) {
ModelAndView mav = new ModelAndView("downloadView");
Map<String, Object> result = crdnCvlcptService.makeFileFromHwpFormat(query);
DataObject dataObject = crdnCvlcptMainBean.getCivilComplaintOriginalInfo(query);
List<DataObject> dataObjectList = new ArrayList<DataObject>();
dataObjectList.add(dataObject);
String linkTblNm = dataObject.string("LINK_TBL_NM");
if(!(ifEmpty(linkTblNm, () -> "").equals(""))) {
FileQuery fileQuery = new FileQuery();
if(linkTblNm.equals("TB_ESB_INTERFACE")) {
fileQuery.setInfoType("010");
} else if(linkTblNm.equals("TB_SAEOL")) {
fileQuery.setInfoType("020");
} else {
throw new RuntimeException("한글 파일 출력 중 오류가 발생하였습니다.");
}
fileQuery.setInfoKeys(dataObject.string("LINK_ID"));
List<DataObject> fileInfoList = fileBean.getFileList(fileQuery);
fileInfoList = fileInfoList.stream()
.filter(fileInfo -> fileInfo.string("MIME_TYPE").startsWith("image"))
.collect(Collectors.toList());
if(fileInfoList != null && fileInfoList.size() > 0) {
int photoCnt = fileInfoList.size();
for(int i=0; i < photoCnt; i++) {
dataObject.put("PHOTO"+i, fileInfoList.get(i).string("URL"));
}
dataObject.put("ORGN_PHOTO_CNT", photoCnt);
}
}
HWPWriter hwpWriter = new HWPWriter();
PrintOption printOption = new PrintOption();
UserInfo userInfo = currentUser();
factionBean.initUserInfo(userInfo);
Print print = new Print();
print.setPrintRequestUserInfo(userInfo);
hwpWriter.setFormat(new CvlcptOrgn());
Map<String, Object> result = hwpWriter.makeFileFromHwpFormat("info", print, printOption, dataObjectList);
mav.addAllObjects(result);
return mav;

@ -1,12 +1,10 @@
package cokr.xit.fims.excl.service;
import java.util.List;
import java.util.Map;
import cokr.xit.base.file.FileInfo;
import cokr.xit.fims.excl.OpnnSbmsn;
import cokr.xit.fims.sprt.PrintOption;
import cokr.xit.fims.excl.LevyExclQuery;
import cokr.xit.fims.excl.OpnnSbmsn;
import cokr.xit.foundation.data.DataObject;
/** .
@ -75,13 +73,5 @@ public interface OpnnSbmsnService {
*/
String removeOpnnSbmsn(OpnnSbmsn opnnSbmsn);
/** .
* @param formatType ,formatName , printOption , opnnIDs
* @return map
* <ul><li>filePath: </li>
* <li>fileName: </li>
* </ul>
*/
Map<String, Object> makeDlbrDecsnFileFromHwpFormat(String formatType, String formatName, PrintOption printOption, LevyExclQuery req);
}

@ -1,31 +1,18 @@
package cokr.xit.fims.excl.service.bean;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import cokr.xit.base.file.FileInfo;
import cokr.xit.fims.cmmn.hwp.AddUtil;
import cokr.xit.fims.cmmn.hwp.format.DlbrDecsnList;
import cokr.xit.fims.cmmn.hwp.HWPFormatWriter;
import cokr.xit.fims.cmmn.hwp.HWPPrintUtil;
import cokr.xit.fims.excl.LevyExclQuery;
import cokr.xit.fims.excl.OpnnSbmsn;
import cokr.xit.fims.excl.service.OpnnSbmsnService;
import cokr.xit.fims.mngt.service.bean.FactionBean;
import cokr.xit.fims.sprt.PrintOption;
import cokr.xit.foundation.UserInfo;
import cokr.xit.foundation.component.AbstractServiceBean;
import cokr.xit.foundation.data.DataObject;
import kr.dogfoot.hwplib.object.HWPFile;
import kr.dogfoot.hwplib.reader.HWPReader;
import kr.dogfoot.hwplib.writer.HWPWriter;
/** .
*
@ -78,89 +65,6 @@ public class OpnnSbmsnServiceBean extends AbstractServiceBean implements OpnnSbm
return opnnSbmsnBean.updateOpnnSbmsnAnswer(opnnSbmsn);
}
@Override
public Map<String, Object> makeDlbrDecsnFileFromHwpFormat(String formatType, String formatName, PrintOption printOption, LevyExclQuery req) {
Map<String, Object> result = new HashMap<>();
HWPPrintUtil printUtil = new HWPPrintUtil();
HWPFormatWriter hwpFormatWriter = new DlbrDecsnList();
hwpFormatWriter.setting(printUtil);
UserInfo userInfo = currentUser();
factionBean.initUserInfo(userInfo);
printUtil.setPrintRequestUserInfo(userInfo);
List<DataObject> dataObjectList = null;
dataObjectList = opnnSbmsnBean.getOpnnSbmsnDlbrDecsns(req);
int totalDataCount = dataObjectList.size();
List<String> partFileList = new ArrayList<>();
printUtil.calcTotalPartFileCount(totalDataCount);
try {
int dataIndex = 0;
for(int partFileIndex = 0; partFileIndex < printUtil.getTotalPartFileCount(); partFileIndex++) {
// 새 파일 생성
String resultHwpPath = printUtil.newFileFromFormatFile();
HWPFile resultFile = HWPReader.fromFile(resultHwpPath);
// 공통사항 세팅
hwpFormatWriter.writeGlobalInfo(resultFile, dataObjectList, printOption, printUtil);
HWPWriter.toFile(resultFile, resultHwpPath);
// 데이터 건별 처리
for (int recordIndex = 0; recordIndex < printUtil.getRecordPerPartFile(); recordIndex++) {
if (dataIndex < dataObjectList.size()) {
DataObject dataObject = dataObjectList.get(dataIndex);
hwpFormatWriter.writeSingleDataInfo(resultFile, null, dataObject, printUtil);
}
if (formatType.equals("list")) {
dataIndex++;
}
}
if (!formatType.equals("list")) {
dataIndex++;
}
HWPWriter.toFile(resultFile, resultHwpPath);
partFileList.add(resultHwpPath);
}
// 결과 파일 병합
if (partFileList.size() >= 2) {
String basePath = partFileList.get(0);
HWPFile baseFile = HWPReader.fromFile(basePath);
for (int iLoop = 2; iLoop <= partFileList.size(); iLoop++) {
String attachPath = partFileList.get(iLoop - 1);
HWPFile attachFile = HWPReader.fromFile(attachPath);
AddUtil.appendToLast(attachFile, baseFile);
}
HWPWriter.toFile(baseFile, basePath);
for (int i = 2; i <= partFileList.size(); i++) {
(new File(partFileList.get(i-1))).delete();
}
}
String downlaodFileName = printUtil.getFormatKorName() + "_" + printUtil.getPrintRequestDt() + ".hwp";
String filePath = partFileList.get(0);
result.put("filename", downlaodFileName);
result.put("filePath", filePath);
result.put("file", new File(filePath));
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("한글 파일 출력 중 오류가 발생하였습니다.");
}
return result;
}
@Override
public String removeOpnnSbmsn(OpnnSbmsn opnnSbmsn) {

@ -14,6 +14,7 @@ import org.springframework.web.servlet.ModelAndView;
import cokr.xit.base.code.CommonCode;
import cokr.xit.base.file.FileInfo;
import cokr.xit.base.file.hwp.HWPWriter;
import cokr.xit.base.file.service.FileService;
import cokr.xit.base.file.web.FileInfoFactory;
import cokr.xit.base.file.xls.XLSWriter;
@ -22,11 +23,16 @@ import cokr.xit.base.file.xls.XLSWriter.Styler;
import cokr.xit.base.user.ManagedUser;
import cokr.xit.base.web.ApplicationController;
import cokr.xit.fims.cmmn.CmmnUtil;
import cokr.xit.fims.cmmn.Print;
import cokr.xit.fims.cmmn.hwp.format.DlbrDecsnList;
import cokr.xit.fims.cmmn.service.bean.StngBean;
import cokr.xit.fims.excl.OpnnSbmsn;
import cokr.xit.fims.excl.LevyExclQuery;
import cokr.xit.fims.excl.OpnnSbmsn;
import cokr.xit.fims.excl.service.OpnnSbmsnService;
import cokr.xit.fims.excl.service.bean.OpnnSbmsnBean;
import cokr.xit.fims.mngt.service.bean.FactionBean;
import cokr.xit.fims.sprt.PrintOption;
import cokr.xit.foundation.UserInfo;
import cokr.xit.foundation.data.DataObject;
/**
@ -68,6 +74,12 @@ public class Excl02Controller extends ApplicationController {
@Resource(name = "stngBean")
private StngBean stngBean;
@Resource(name = "factionBean")
private FactionBean factionBean;
@Resource(name = "opnnSbmsnBean")
private OpnnSbmsnBean opnnSbmsnBean;
/** (fims/excl/excl02/010-main) .
*
* @return /fims/excl/excl02010
@ -338,10 +350,18 @@ public class Excl02Controller extends ApplicationController {
* }</code></pre>
*/
public ModelAndView makeDlbrDecsnFileFromHwpFormat(LevyExclQuery req) {
//
HWPWriter hwpWriter = new HWPWriter();
PrintOption printOption = new PrintOption();
UserInfo userInfo = currentUser();
factionBean.initUserInfo(userInfo);
Print print = new Print();
print.setPrintRequestUserInfo(userInfo);
hwpWriter.setFormat(new DlbrDecsnList());
Map<String,Object> result = opnnSbmsnService.makeDlbrDecsnFileFromHwpFormat("info", "dlbrDecsn", printOption ,req);
List<DataObject> dataObjectList = opnnSbmsnBean.getOpnnSbmsnDlbrDecsns(req);
Map<String,Object> result = hwpWriter.makeFileFromHwpFormat("info", print, printOption, dataObjectList);
ModelAndView mav = new ModelAndView("downloadView");
mav.addAllObjects(result);

@ -1,13 +1,10 @@
package cokr.xit.fims.sndb.service;
import java.util.List;
import java.util.Map;
import cokr.xit.foundation.data.DataObject;
import cokr.xit.fims.sndb.Svbtc;
import cokr.xit.fims.sprt.PrintOption;
import cokr.xit.fims.sndb.SndbQuery;
import cokr.xit.fims.sndb.Svbtc;
import cokr.xit.foundation.data.DataObject;
/** .
*
@ -51,11 +48,6 @@ public interface SvbtcService {
*/
List<DataObject> getSvbtcDtls(SndbQuery req);
/** .
* @param req IDs
* @return
*/
Map<String, String> makeSvbtcFileFromHwpFormat(String formatType, String formatName, PrintOption printOption, SndbQuery req);
/** .
* @param svbtc

@ -1,31 +1,17 @@
package cokr.xit.fims.sndb.service.bean;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import org.springframework.core.io.ClassPathResource;
import org.springframework.stereotype.Service;
import cokr.xit.foundation.UserInfo;
import cokr.xit.foundation.component.AbstractServiceBean;
import cokr.xit.foundation.data.DataObject;
import kr.dogfoot.hwplib.object.HWPFile;
import kr.dogfoot.hwplib.reader.HWPReader;
import kr.dogfoot.hwplib.writer.HWPWriter;
import cokr.xit.fims.sndb.Svbtc;
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.SvbtcList;
import cokr.xit.fims.mngt.service.bean.FactionBean;
import cokr.xit.fims.sndb.SndbQuery;
import cokr.xit.fims.sndb.Svbtc;
import cokr.xit.fims.sndb.service.SvbtcService;
import cokr.xit.fims.sprt.PrintOption;
import cokr.xit.foundation.component.AbstractServiceBean;
import cokr.xit.foundation.data.DataObject;
/** .
*
@ -73,104 +59,6 @@ public class SvbtcServiceBean extends AbstractServiceBean implements SvbtcServic
return svbtcBean.getSvbtcDtls(req);
}
@Override
public Map<String, String> makeSvbtcFileFromHwpFormat(String formatType, String formatName, PrintOption printOption, SndbQuery req) {
// return
Map<String, String> result = new HashMap<>();
HWPPrintUtil printUtil = new HWPPrintUtil();
HWPFormatWriter hwpFormatWriter = new SvbtcList();
// 사용자 조회
UserInfo userInfo = currentUser();
factionBean.initUserInfo(userInfo);
printUtil.setPrintRequestUserInfo(userInfo);
// 자료 조회
req.setSggCd((String)userInfo.getInfo().get("sggCd"));
req.setDeptCd((String)userInfo.getInfo().get("deptCd"));
req.setOrderBy("SV.SVBTC_ID, SD.SNDNG_DTL_ID");
List<DataObject> dataObjectList = svbtcBean.getSvbtcPrint(req);
int totalDataCount = dataObjectList.size();
// 한글 포맷 setting
hwpFormatWriter.setting(printUtil, totalDataCount);
//
printUtil.calcTotalPartFileCount(totalDataCount);
List<String> partFileList = new ArrayList<>();
try {
int dataIndex = 0;
for(int partFileIndex = 0; partFileIndex < printUtil.getTotalPartFileCount(); partFileIndex++) {
// 새 파일 생성
String resultHwpPath = printUtil.newFileFromFormatFile();
HWPFile resultFile = HWPReader.fromFile(resultHwpPath);
// 공통사항 세팅
hwpFormatWriter.writeGlobalInfo(resultFile, dataObjectList, printOption, printUtil);
HWPWriter.toFile(resultFile, resultHwpPath);
// 데이터 건별 처리
for (int recordIndex = 0; recordIndex < printUtil.getRecordPerPartFile(); recordIndex++) {
if (dataIndex < dataObjectList.size()) {
DataObject dataObject = dataObjectList.get(dataIndex);
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")) {
dataIndex++;
}
}
if (!formatType.equals("list")) {
dataIndex++;
}
HWPWriter.toFile(resultFile, resultHwpPath);
partFileList.add(resultHwpPath);
}
// 결과 파일 병합
if (partFileList.size() >= 2) {
String basePath = partFileList.get(0);
HWPFile baseFile = HWPReader.fromFile(basePath);
for (int iLoop = 2; iLoop <= partFileList.size(); iLoop++) {
String attachPath = partFileList.get(iLoop - 1);
HWPFile attachFile = HWPReader.fromFile(attachPath);
AddUtil.appendToLast(attachFile, baseFile);
}
HWPWriter.toFile(baseFile, basePath);
}
String downlaodFileName = printUtil.getFormatKorName() + "_" + printUtil.getPrintRequestDt() + ".hwp";
result.put("fileName", downlaodFileName);
result.put("filePath", partFileList.get(0));
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("한글 파일 출력 중 오류가 발생하였습니다.");
}
return result;
}
@Override
public String createSvbtc(SndbQuery req, Svbtc svbtc) {
return svbtcBean.createSvbtc(req, svbtc);

@ -11,6 +11,7 @@ import org.apache.poi.ss.usermodel.CellStyle;
import org.springframework.web.servlet.ModelAndView;
import cokr.xit.base.code.CommonCode;
import cokr.xit.base.file.hwp.HWPWriter;
import cokr.xit.base.file.xls.XLSWriter;
import cokr.xit.base.file.xls.XLSWriter.CellDef;
import cokr.xit.base.file.xls.XLSWriter.Styler;
@ -18,7 +19,9 @@ import cokr.xit.base.user.ManagedUser;
import cokr.xit.base.web.ApplicationController;
import cokr.xit.fims.cmmn.CmmnQuery;
import cokr.xit.fims.cmmn.CmmnUtil;
import cokr.xit.fims.cmmn.Print;
import cokr.xit.fims.cmmn.service.bean.StngBean;
import cokr.xit.fims.mngt.service.bean.FactionBean;
import cokr.xit.fims.mngt.service.bean.TaskBean;
import cokr.xit.fims.sndb.SndbQuery;
import cokr.xit.fims.sndb.Sndng;
@ -27,8 +30,10 @@ import cokr.xit.fims.sndb.Svbtc;
import cokr.xit.fims.sndb.service.SndngDtlService;
import cokr.xit.fims.sndb.service.SndngService;
import cokr.xit.fims.sndb.service.SvbtcService;
import cokr.xit.fims.sndb.service.bean.SvbtcBean;
import cokr.xit.fims.sprt.PrintOption;
import cokr.xit.fims.sprt.service.IntegrationSearchService;
import cokr.xit.foundation.UserInfo;
import cokr.xit.foundation.data.DataObject;
/**
@ -118,6 +123,12 @@ public class Sndb01Controller extends ApplicationController {
@Resource(name="stngBean")
private StngBean stngBean;
@Resource(name="factionBean")
private FactionBean factionBean;
@Resource(name="svbtcBean")
private SvbtcBean svbtcBean;
/** (sndb/sndb01/010-main) .
* @return /sndb/sndb01/010-main
*/
@ -1456,11 +1467,23 @@ public class Sndb01Controller extends ApplicationController {
* @return hwp
*/
public ModelAndView makeSvbtcFileFromHwpFormat(SndbQuery req) {
Map<String,String> result = null;
Map<String,Object> result = null;
HWPWriter hwpWriter = new HWPWriter();
PrintOption printOption = new PrintOption();
UserInfo userInfo = currentUser();
factionBean.initUserInfo(userInfo);
req.setSggCd((String)userInfo.getInfo().get("sggCd"));
req.setDeptCd((String)userInfo.getInfo().get("deptCd"));
req.setOrderBy("SV.SVBTC_ID, SD.SNDNG_DTL_ID");
List<DataObject> dataObjectList = svbtcBean.getSvbtcPrint(req);
Print print = new Print();
print.setPrintRequestUserInfo(userInfo);
result = svbtcService.makeSvbtcFileFromHwpFormat("list", "svbtc", printOption, req);
result = hwpWriter.makeFileFromHwpFormat("list", print, printOption, dataObjectList);
ModelAndView mav = new ModelAndView("jsonView");

@ -31,15 +31,6 @@ public interface IntegrationSearchService {
*/
String updateEtcCn(String etcCn, String... crdnIds);
/** .
* @param formatType ,formatName , printOption , crdnIds
* @return map
* <ul><li>filename: </li>
* <li>filePath: </li>
* <li>file: </li>
* </ul>
*/
Map<String, Object> makeFileFromHwpFormat(String formatType, String formatName, PrintOption printOption, String... crdnIds);
/** pdf .
* @param formatType ,formatName , printOption , crdnIds

@ -33,14 +33,6 @@ import cokr.xit.base.file.service.FileQuery;
import cokr.xit.base.file.service.bean.FileBean;
import cokr.xit.fims.cmmn.CmmnUtil;
import cokr.xit.fims.cmmn.Hangul;
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.PstnAndSize;
import cokr.xit.fims.cmmn.pdf.print.DefaultOtptArtclStng;
import cokr.xit.fims.cmmn.pdf.print.PDFPrintUtil;
@ -49,7 +41,6 @@ import cokr.xit.fims.cmmn.pdf.print.format.Nht;
import cokr.xit.fims.cmmn.pdf.print.format.PDFPrintFormat;
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.mngt.service.bean.FactionBean;
import cokr.xit.fims.sprt.OtptStngQuery;
@ -61,9 +52,6 @@ import cokr.xit.fims.sprt.service.IntegrationSearchService;
import cokr.xit.foundation.UserInfo;
import cokr.xit.foundation.component.AbstractServiceBean;
import cokr.xit.foundation.data.DataObject;
import kr.dogfoot.hwplib.object.HWPFile;
import kr.dogfoot.hwplib.reader.HWPReader;
import kr.dogfoot.hwplib.writer.HWPWriter;
import net.lingala.zip4j.ZipFile;
/** .
@ -120,180 +108,7 @@ public class IntegrationSearchServiceBean extends AbstractServiceBean implements
}
}
@Override
public Map<String, Object> makeFileFromHwpFormat(String formatType, String formatName, PrintOption printOption, String... crdnIds) {
Map<String, Object> result = new HashMap<>();
HWPPrintUtil printUtil = new HWPPrintUtil();
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");
List<DataObject> dataObjectList = null;
if(formatName.equals("crdnList")) {
CrdnQuery query = new CrdnQuery();
query.setCrdnIds(crdnIds);
dataObjectList = crdnListMapper.selectCrackdownList(query);
} else if(formatName.equals("crdnConfirm")) {
CrdnQuery query = new CrdnQuery();
query.setCrdnIds(crdnIds);
dataObjectList = crdnListMapper.selectCrackdownList(query);
for(int i=0; i < dataObjectList.size(); i++) {
DataObject dataObject = dataObjectList.get(i);
String crndId = dataObject.string("CRDN_ID");
FileQuery fileQuery = new FileQuery();
fileQuery.setInfoType(Crdn.INF_TYPE);
fileQuery.setInfoKeys(crndId);
List<DataObject> fileInfoList = fileBean.getFileList(fileQuery);
if(fileInfoList != null && fileInfoList.size() > 0) {
dataObject.set("PHOTO1", fileInfoList.get(0).string("URL"));
if(fileInfoList.size() >= 2)
dataObject.set("PHOTO2", fileInfoList.get(1).string("URL"));
if(fileInfoList.size() >= 3)
dataObject.set("PHOTO3", fileInfoList.get(2).string("URL"));
if(fileInfoList.size() >= 4)
dataObject.set("PHOTO4", fileInfoList.get(3).string("URL"));
}
}
} else if(formatName.equals("requestForDelivery")) {
SprtQuery sprtQuery = new SprtQuery();
sprtQuery.setCrdnIds(crdnIds);
dataObjectList = integrationSearchMapper.selectIntegrationDataList(sprtQuery);
Map<String, String> globalVariable = printOption.getGlobalVariable();
globalVariable.put("dtbnBankNm", deptStngInfo.string("DTBN_BANK_NM"));
globalVariable.put("dtbnActno", deptStngInfo.string("DTBN_ACTNO"));
globalVariable.put("offcsFilePath", sggStngInfo.string("OFFCS_FILE_PATH"));
printOption.setGlobalVariable(globalVariable);
} else if(formatName.equals("reportOnClaims")) {
SprtQuery sprtQuery = new SprtQuery();
sprtQuery.setCrdnIds(crdnIds);
dataObjectList = integrationSearchMapper.selectIntegrationDataList(sprtQuery);
Map<String, String> globalVariable = printOption.getGlobalVariable();
String deptNm = (String) printUtil.getPrintRequestUserInfo().getInfo().get("deptNm");
String deptAddr = sggStngInfo.string("INST_FULL_ADDR") + " " + deptNm;
globalVariable.put("deptAddr", deptAddr);
globalVariable.put("deptTelno", deptStngInfo.string("DEPT_TELNO"));
globalVariable.put("deptFxno", deptStngInfo.string("DEPT_FXNO"));
globalVariable.put("offcsFilePath", sggStngInfo.string("OFFCS_FILE_PATH"));
printOption.setGlobalVariable(globalVariable);
} else if(formatName.equals("rcvmtConfirm")) {
SprtQuery sprtQuery = new SprtQuery();
sprtQuery.setCrdnIds(crdnIds);
dataObjectList = integrationSearchMapper.selectIntegrationDataList(sprtQuery);
}
int totalDataCount = dataObjectList.size();
List<String> partFileList = new ArrayList<>();
printUtil.calcTotalPartFileCount(totalDataCount);
try {
int dataIndex = 0;
for(int partFileIndex = 0; partFileIndex < printUtil.getTotalPartFileCount(); partFileIndex++) {
//새 파일 생성
String resultHwpPath = printUtil.newFileFromFormatFile();
HWPFile resultFile = HWPReader.fromFile(resultHwpPath);
//공통사항 세팅
hwpFormatWriter.writeGlobalInfo(resultFile, dataObjectList, printOption, printUtil);
HWPWriter.toFile(resultFile, resultHwpPath);
//데이터 건별 처리
for(int recordIndex = 0; recordIndex < printUtil.getRecordPerPartFile(); recordIndex++) {
if(dataIndex < dataObjectList.size()) {
DataObject dataObject = dataObjectList.get(dataIndex);
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")) {
dataIndex++;
}
}
if(!formatType.equals("list")) {
dataIndex++;
}
HWPWriter.toFile(resultFile, resultHwpPath);
partFileList.add(resultHwpPath);
}
//결과파일 병합
if(partFileList.size() >= 2) {
String basePath = partFileList.get(0);
HWPFile baseFile = HWPReader.fromFile(basePath);
for(int i=2; i <= partFileList.size();i++) {
String attachPath = partFileList.get(i-1);
HWPFile attachFile = HWPReader.fromFile(attachPath);
AddUtil.appendToLast(attachFile, baseFile);
}
HWPWriter.toFile(baseFile, basePath);
for(int i=2; i <= partFileList.size();i++) {
(new File(partFileList.get(i-1))).delete();
}
}
String downlaodFileName = printUtil.getFormatKorName()+"_"+printUtil.getPrintRequestDt()+".hwp";
result.put("filename", downlaodFileName);
String filePath = partFileList.get(0);
result.put("filePath", filePath);
result.put("file", new File(filePath));
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("한글 파일 출력 중 오류가 발생하였습니다.");
}
return result;
}
@Override
public Map<String, Object> makePdfFile(String formatType, String formatName, PrintOption printOption, String[] crdnIds) {

@ -18,6 +18,9 @@ import org.springframework.web.servlet.ModelAndView;
import com.fasterxml.jackson.core.type.TypeReference;
import cokr.xit.base.code.CommonCode;
import cokr.xit.base.file.hwp.HWPWriter;
import cokr.xit.base.file.service.FileQuery;
import cokr.xit.base.file.service.bean.FileBean;
import cokr.xit.base.file.xls.XLSWriter;
import cokr.xit.base.file.xls.XLSWriter.CellDef;
import cokr.xit.base.file.xls.XLSWriter.Styler;
@ -25,8 +28,16 @@ import cokr.xit.base.user.ManagedUser;
import cokr.xit.base.user.dao.UserMapper;
import cokr.xit.base.web.ApplicationController;
import cokr.xit.fims.cmmn.CmmnUtil;
import cokr.xit.fims.cmmn.Print;
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.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.crdn.dao.GlobalStngMapper;
import cokr.xit.fims.mngt.service.bean.FactionBean;
import cokr.xit.fims.mngt.service.bean.TaskBean;
@ -35,9 +46,11 @@ import cokr.xit.fims.sprt.OtptForm;
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.service.IntegrationSearchService;
import cokr.xit.fims.sprt.service.bean.OtptStngBean;
import cokr.xit.fims.stat.dao.StatMapper;
import cokr.xit.foundation.UserInfo;
import cokr.xit.foundation.data.DataObject;
/**
@ -98,6 +111,9 @@ public class Sprt01Controller extends ApplicationController {
@Resource(name="otptStngBean")
protected OtptStngBean otptStngBean;
@Resource(name = "fileBean")
private FileBean fileBean;
@Resource(name = "taskBean")
private TaskBean taskBean;
@ -107,6 +123,12 @@ public class Sprt01Controller extends ApplicationController {
@Resource(name = "stngBean")
private StngBean stngBean;
@Resource(name = "crdnListMapper")
private CrdnListMapper crdnListMapper;
@Resource(name = "integrationSearchMapper")
private IntegrationSearchMapper integrationSearchMapper;
/** (fims/sprt/sprt01/010-main) .
*
* @return /fims/sprt/sprt01010
@ -420,7 +442,20 @@ public class Sprt01Controller extends ApplicationController {
PrintOption printOption = new PrintOption();
printOption.setPrivateInfoYn(privateInfoYn);
Map<String,Object> result = integrationSearchService.makeFileFromHwpFormat("list", "crdnList", printOption ,crdnIds);
CrdnQuery query = new CrdnQuery();
query.setCrdnIds(crdnIds);
List<DataObject> DataObjectList = crdnListMapper.selectCrackdownList(query);
HWPWriter hwpWriter = new HWPWriter();
UserInfo userInfo = currentUser();
factionBean.initUserInfo(userInfo);
Print print = new Print();
print.setPrintRequestUserInfo(userInfo);
DataObject sggStngInfo = stngBean.getStng("sgg");
DataObject deptStngInfo = stngBean.getStng("dept");
hwpWriter.setFormat(new CrdnList());
Map<String,Object> result = hwpWriter.makeFileFromHwpFormat("list", print, printOption, DataObjectList);
ModelAndView mav = new ModelAndView("downloadView");
mav.addAllObjects(result);
@ -434,7 +469,40 @@ public class Sprt01Controller extends ApplicationController {
PrintOption printOption = new PrintOption();
Map<String,Object> result = integrationSearchService.makeFileFromHwpFormat("info", "crdnConfirm", printOption, crdnIds);
CrdnQuery query = new CrdnQuery();
query.setCrdnIds(crdnIds);
List<DataObject> dataObjectList = crdnListMapper.selectCrackdownList(query);
for(int i=0; i < dataObjectList.size(); i++) {
DataObject dataObject = dataObjectList.get(i);
String crndId = dataObject.string("CRDN_ID");
FileQuery fileQuery = new FileQuery();
fileQuery.setInfoType(Crdn.INF_TYPE);
fileQuery.setInfoKeys(crndId);
List<DataObject> fileInfoList = fileBean.getFileList(fileQuery);
if(fileInfoList != null && fileInfoList.size() > 0) {
dataObject.set("PHOTO1", fileInfoList.get(0).string("URL"));
if(fileInfoList.size() >= 2)
dataObject.set("PHOTO2", fileInfoList.get(1).string("URL"));
if(fileInfoList.size() >= 3)
dataObject.set("PHOTO3", fileInfoList.get(2).string("URL"));
if(fileInfoList.size() >= 4)
dataObject.set("PHOTO4", fileInfoList.get(3).string("URL"));
}
}
HWPWriter hwpWriter = new HWPWriter();
UserInfo userInfo = currentUser();
factionBean.initUserInfo(userInfo);
Print print = new Print();
print.setPrintRequestUserInfo(userInfo);
DataObject sggStngInfo = stngBean.getStng("sgg");
DataObject deptStngInfo = stngBean.getStng("dept");
hwpWriter.setFormat(new CrdnConfirm());
Map<String,Object> result = hwpWriter.makeFileFromHwpFormat("info", print, printOption, dataObjectList);
ModelAndView mav = new ModelAndView("downloadView");
mav.addAllObjects(result);
@ -473,7 +541,26 @@ public class Sprt01Controller extends ApplicationController {
printOption.setGlobalVariable(globalVariable);
Map<String,Object> result = integrationSearchService.makeFileFromHwpFormat("list", "requestForDelivery", printOption, crdnIds);
SprtQuery sprtQuery = new SprtQuery();
sprtQuery.setCrdnIds(crdnIds);
List<DataObject> dataObjectList = integrationSearchMapper.selectIntegrationDataList(sprtQuery);
HWPWriter hwpWriter = new HWPWriter();
UserInfo userInfo = currentUser();
factionBean.initUserInfo(userInfo);
Print print = new Print();
print.setPrintRequestUserInfo(userInfo);
DataObject sggStngInfo = stngBean.getStng("sgg");
DataObject deptStngInfo = stngBean.getStng("dept");
Map<String, String> globalVariable2 = printOption.getGlobalVariable();
globalVariable2.put("dtbnBankNm", deptStngInfo.string("DTBN_BANK_NM"));
globalVariable2.put("dtbnActno", deptStngInfo.string("DTBN_ACTNO"));
globalVariable2.put("offcsFilePath", sggStngInfo.string("OFFCS_FILE_PATH"));
printOption.setGlobalVariable(globalVariable2);
hwpWriter.setFormat(new RequestForDelivery());
Map<String,Object> result = hwpWriter.makeFileFromHwpFormat("list", print, printOption, dataObjectList);
mav.addAllObjects(result);
return mav;
}
@ -485,7 +572,7 @@ public class Sprt01Controller extends ApplicationController {
ModelAndView mav = new ModelAndView("downloadView");
Map<String, String> globalVariable = new HashMap<String,String>();
System.out.println("json확인");
System.out.println(globalVariableInfo);
DataObject dataObject = fromJson(globalVariableInfo, DataObject.class);
@ -496,8 +583,31 @@ public class Sprt01Controller extends ApplicationController {
printOption.setGlobalVariable(globalVariable);
SprtQuery sprtQuery = new SprtQuery();
sprtQuery.setCrdnIds(crdnIds);
List<DataObject> dataObjectList = integrationSearchMapper.selectIntegrationDataList(sprtQuery);
HWPWriter hwpWriter = new HWPWriter();
UserInfo userInfo = currentUser();
factionBean.initUserInfo(userInfo);
Print print = new Print();
print.setPrintRequestUserInfo(userInfo);
DataObject sggStngInfo = stngBean.getStng("sgg");
DataObject deptStngInfo = stngBean.getStng("dept");
Map<String, String> globalVariable2 = printOption.getGlobalVariable();
String deptNm = (String) hwpWriter.getPrintRequestUserInfo().getInfo().get("deptNm");
String deptAddr = sggStngInfo.string("INST_FULL_ADDR") + " " + deptNm;
globalVariable2.put("deptAddr", deptAddr);
globalVariable2.put("deptTelno", deptStngInfo.string("DEPT_TELNO"));
globalVariable2.put("deptFxno", deptStngInfo.string("DEPT_FXNO"));
globalVariable2.put("offcsFilePath", sggStngInfo.string("OFFCS_FILE_PATH"));
printOption.setGlobalVariable(globalVariable2);
hwpWriter.setFormat(new ReportOnClaims());
Map<String,Object> result = hwpWriter.makeFileFromHwpFormat("list", print, printOption, dataObjectList);
Map<String,Object> result = integrationSearchService.makeFileFromHwpFormat("list", "reportOnClaims", printOption, crdnIds);
mav.addAllObjects(result);
return mav;
@ -511,7 +621,22 @@ public class Sprt01Controller extends ApplicationController {
PrintOption printOption = new PrintOption();
printOption.setGlobalVariable(new HashMap<String,String>());
Map<String,Object> result = integrationSearchService.makeFileFromHwpFormat("info", "rcvmtConfirm", printOption, crdnIds);
SprtQuery sprtQuery = new SprtQuery();
sprtQuery.setCrdnIds(crdnIds);
List<DataObject> dataObjectList = integrationSearchMapper.selectIntegrationDataList(sprtQuery);
HWPWriter hwpWriter = new HWPWriter();
UserInfo userInfo = currentUser();
factionBean.initUserInfo(userInfo);
Print print = new Print();
print.setPrintRequestUserInfo(userInfo);
DataObject sggStngInfo = stngBean.getStng("sgg");
DataObject deptStngInfo = stngBean.getStng("dept");
hwpWriter.setFormat(new RcvmtConfirm());
Map<String,Object> result = hwpWriter.makeFileFromHwpFormat("info", print, printOption, dataObjectList);
mav.addAllObjects(result);
return mav;

@ -113,22 +113,12 @@ $(document).ready(function(){
}
$P.fnMakeCrdnConfirmFile = () => {
ajax.post({
url : wctx.url("/sprt/sprt01/110/makeCrdnConfirmFileFromHwpFormat.do"),
data : {
crdnIds : $P.crdnIds.join(",")
},
success : (resp) => {
if(resp.filePath != null && resp.filePath != ""){
var a = document.createElement("a");
a.href = resp.filePath;
a.download = resp.fileName;
document.getElementById("tempArea--${pageName}").appendChild(a);
a.click();
document.getElementById("tempArea--${pageName}").removeChild(a);
}
}
var url = wctx.url("/sprt/sprt01/110/makeCrdnConfirmFileFromHwpFormat.do");
var parameter = toQuery({
crdnIds : $P.crdnIds.join(",")
});
document.location.href = url + "?" + parameter;
}
$P.fnExcelDown = () => {

Loading…
Cancel
Save