diff --git a/src/main/java/cokr/xit/base/file/hwp/HWPWriter.java b/src/main/java/cokr/xit/base/file/hwp/HWPWriter.java deleted file mode 100644 index 1ea1431b..00000000 --- a/src/main/java/cokr/xit/base/file/hwp/HWPWriter.java +++ /dev/null @@ -1,128 +0,0 @@ -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.PrintOption; -import cokr.xit.fims.cmmn.hwp.AddUtil; -import cokr.xit.fims.cmmn.hwp.format.HWPFormat; -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; - - public void setFormat(HWPFormat format) { - this.format = format; - }; - - public HWPFormat getFormat() { - return this.format; - }; - - public void setPrint(Print print) { - this.print = print; - }; - - public Map makeFileFromHwpFormat(String formatType, PrintOption printOption, List dataObjectList) { - Map result = new HashMap<>(); - - this.format.setting(this.print); - - - int totalDataCount = dataObjectList.size(); - List 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(this.print); - HWPFile resultFile = HWPReader.fromFile(resultHwpPath); - - //공통사항 세팅 - this.format.writeGlobalInfo(resultFile, dataObjectList, printOption, this.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, this.print); - - AddUtil.insertTableInCell(attachFormatFile, resultFile, "내부"); - - } else if(formatType.equals("info")){ - - this.format.writeSingleDataInfo(resultFile, null, dataObject, this.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++) { - if(!(new File(partFileList.get(i-1))).delete()) { - throw new RuntimeException("한글 파일 출력 중 오류가 발생하였습니다."); - } - } - } - - String downlaodFileName = this.print.getFormatKorName()+"_"+this.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) { - throw new RuntimeException("한글 파일 출력 중 오류가 발생하였습니다."); - } - - return result; - } -} diff --git a/src/main/java/cokr/xit/fims/cmmn/CmmnUtil.java b/src/main/java/cokr/xit/fims/cmmn/CmmnUtil.java index e7b1b2f5..a0db5923 100644 --- a/src/main/java/cokr/xit/fims/cmmn/CmmnUtil.java +++ b/src/main/java/cokr/xit/fims/cmmn/CmmnUtil.java @@ -38,6 +38,7 @@ import org.springframework.core.io.ClassPathResource; import cokr.xit.base.file.xls.XLSWriter; import cokr.xit.base.file.xls.XLSWriter.CommentSupport; +import cokr.xit.fims.cmmn.xls.CellDecorator; import cokr.xit.fims.sndb.service.bean.SndngBean; import cokr.xit.foundation.data.DataObject; import cokr.xit.foundation.util.DateFormats; diff --git a/src/main/java/cokr/xit/fims/cmmn/hwp/AddUtil.java b/src/main/java/cokr/xit/fims/cmmn/hwp/AddUtil.java deleted file mode 100644 index 3f4417d0..00000000 --- a/src/main/java/cokr/xit/fims/cmmn/hwp/AddUtil.java +++ /dev/null @@ -1,53 +0,0 @@ -package cokr.xit.fims.cmmn.hwp; -import kr.dogfoot.hwplib.object.HWPFile; -import kr.dogfoot.hwplib.object.bodytext.ParagraphListInterface; -import kr.dogfoot.hwplib.object.bodytext.paragraph.Paragraph; -import kr.dogfoot.hwplib.object.bodytext.paragraph.ParagraphList; -import kr.dogfoot.hwplib.tool.objectfinder.CellFinder; -import kr.dogfoot.hwplib.tool.paragraphadder.ParagraphAdder; -import kr.dogfoot.hwplib.tool.paragraphadder.ParagraphMerger; - -public class AddUtil { - - /**한글파일을 병합한다. - * @param attachHWPFile 기준파일 마지막 페이지에 붙일 파일, baseHWPFile 기준 파일 - * @return - */ - public static void appendToLast(HWPFile attachHWPFile, HWPFile baseHWPFile) throws Exception { - - if (attachHWPFile != null && baseHWPFile != null) { - - Paragraph[] ps = attachHWPFile.getBodyText().getSectionList().get(0).getParagraphs(); - - ParagraphListInterface baseSection = baseHWPFile.getBodyText().getLastSection(); - - ParagraphAdder paraAdder = new ParagraphAdder(baseHWPFile, baseSection); - - for(int i=0; i strings = new ArrayList(); - strings.add(value); - FieldFinder.setClickHereText(whpFile, clickHereName, strings); - } catch (Exception e){ - throw new RuntimeException("한글 문서 생성 중 오류가 발생하였습니다."); - } - - } -} diff --git a/src/main/java/cokr/xit/fims/cmmn/hwp/HwpMerge.java b/src/main/java/cokr/xit/fims/cmmn/hwp/HwpMerge.java new file mode 100644 index 00000000..fc6d992a --- /dev/null +++ b/src/main/java/cokr/xit/fims/cmmn/hwp/HwpMerge.java @@ -0,0 +1,32 @@ +package cokr.xit.fims.cmmn.hwp; +import kr.dogfoot.hwplib.object.HWPFile; +import kr.dogfoot.hwplib.object.bodytext.ParagraphListInterface; +import kr.dogfoot.hwplib.object.bodytext.paragraph.Paragraph; +import kr.dogfoot.hwplib.tool.paragraphadder.ParagraphAdder; + +public class HwpMerge { + + /**한글파일을 병합한다. + * @param attachHWPFile 기준파일 마지막 페이지에 붙일 파일, baseHWPFile 기준 파일 + * @return + */ + public static void appendToLast(HWPFile attachHWPFile, HWPFile baseHWPFile) throws Exception { + + if (attachHWPFile != null && baseHWPFile != null) { + + Paragraph[] ps = attachHWPFile.getBodyText().getSectionList().get(0).getParagraphs(); + + ParagraphListInterface baseSection = baseHWPFile.getBodyText().getLastSection(); + + ParagraphAdder paraAdder = new ParagraphAdder(baseHWPFile, baseSection); + + for(int i=0; i cellList = CellFinder.findAll(hwpFile, fieldName); - if(cellList != null && !cellList.isEmpty()) { - Cell c = cellList.get(0); - int cellWidth = (int)c.getListHeader().getWidth(); - int cellHeight = (int)c.getListHeader().getHeight(); - shapePosition = new Rectangle(1, 1, cellWidth, cellHeight); - - Paragraph firstPara = c.getParagraphList().getParagraph(0); - ParaText paraText = firstPara.getText(); - if (paraText == null) { - firstPara.createText(); - paraText = firstPara.getText(); - } - - // 문단에서 사각형 컨트롤의 위치를 표현하기 위한 확장 문자를 넣는다. - paraText.addExtendCharForGSO(); - - // 문단에 사각형 컨트롤 추가한다. - rectangle = (ControlRectangle) firstPara.addNewGsoControl(GsoControlType.Rectangle); - } - } - - private void setCtrlHeaderGso() { - CtrlHeaderGso hdr = rectangle.getHeader(); - GsoHeaderProperty prop = hdr.getProperty(); - prop.setLikeWord(false); - prop.setApplyLineSpace(false); - prop.setVertRelTo(VertRelTo.Para); - prop.setVertRelativeArrange(RelativeArrange.TopOrLeft); - prop.setHorzRelTo(HorzRelTo.Para); - prop.setHorzRelativeArrange(RelativeArrange.TopOrLeft); - prop.setVertRelToParaLimit(true); - prop.setAllowOverlap(true); - prop.setWidthCriterion(WidthCriterion.Absolute); - prop.setHeightCriterion(HeightCriterion.Absolute); - prop.setProtectSize(false); - prop.setTextFlowMethod(TextFlowMethod.FitWithText); - prop.setTextHorzArrange(TextHorzArrange.BothSides); - prop.setObjectNumberSort(ObjectNumberSort.Figure); - - hdr.setyOffset(shapePosition.y); - hdr.setxOffset(shapePosition.x); - hdr.setWidth(shapePosition.width); - hdr.setHeight(shapePosition.height); - hdr.setzOrder(0); - hdr.setOutterMarginLeft(0); - hdr.setOutterMarginRight(0); - hdr.setOutterMarginTop(0); - hdr.setOutterMarginBottom(0); - hdr.setInstanceId(instanceID); - hdr.setPreventPageDivide(false); - hdr.getExplanation().setBytes(null); - } - - public int fromMM(int mm) { - if (mm == 0) { - return 1; - } - - return (int) ((double) mm * 72000.0f / 254.0f + 0.5f); - } - - private void setShapeComponent() { - ShapeComponentNormal sc = (ShapeComponentNormal) rectangle.getShapeComponent(); - sc.setOffsetX(0); - sc.setOffsetY(0); - sc.setGroupingCount(0); - sc.setLocalFileVersion(1); - sc.setWidthAtCreate(shapePosition.width); - sc.setHeightAtCreate(shapePosition.height); - sc.setWidthAtCurrent(shapePosition.width); - sc.setHeightAtCurrent(shapePosition.height); - sc.setRotateAngle(0); - sc.setRotateXCenter((shapePosition.width / 2)); - sc.setRotateYCenter((shapePosition.height / 2)); - - sc.createLineInfo(); - LineInfo li = sc.getLineInfo(); - li.getProperty().setLineEndShape(LineEndShape.Flat); - li.getProperty().setStartArrowShape(LineArrowShape.None); - li.getProperty().setStartArrowSize(LineArrowSize.MiddleMiddle); - li.getProperty().setEndArrowShape(LineArrowShape.None); - li.getProperty().setEndArrowSize(LineArrowSize.MiddleMiddle); - li.getProperty().setFillStartArrow(true); - li.getProperty().setFillEndArrow(true); - li.getProperty().setLineType(LineType.None); - li.setOutlineStyle(OutlineStyle.Normal); - li.setThickness(0); - li.getColor().setValue(0); - - sc.createFillInfo(); - FillInfo fi = sc.getFillInfo(); - fi.getType().setPatternFill(false); - fi.getType().setImageFill(true); - fi.getType().setGradientFill(false); - fi.createImageFill(); - ImageFill imgF = fi.getImageFill(); - imgF.setImageFillType(ImageFillType.FitSize); - imgF.getPictureInfo().setBrightness((byte) 0); - imgF.getPictureInfo().setContrast((byte) 0); - imgF.getPictureInfo().setEffect(PictureEffect.RealPicture); - imgF.getPictureInfo().setBinItemID(binDataID); - - sc.createShadowInfo(); - ShadowInfo si = sc.getShadowInfo(); - si.setType(ShadowType.None); - si.getColor().setValue(0xc4c4c4); - si.setOffsetX(283); - si.setOffsetY(283); - si.setTransparent((short) 0); - - sc.setMatrixsNormal(); - } - - private void setShapeComponentRectangle() { - ShapeComponentRectangle scr = rectangle.getShapeComponentRectangle(); - scr.setRoundRate((byte) 0); - scr.setX1(0); - scr.setY1(0); - scr.setX2(shapePosition.width); - scr.setY2(0); - scr.setX3(shapePosition.width); - scr.setY3(shapePosition.height); - scr.setX4(0); - scr.setY4(shapePosition.height); - } -} diff --git a/src/main/java/cokr/xit/fims/cmmn/hwp/OffcsCellFinder.java b/src/main/java/cokr/xit/fims/cmmn/hwp/OffcsCellFinder.java new file mode 100644 index 00000000..8f3bd9e8 --- /dev/null +++ b/src/main/java/cokr/xit/fims/cmmn/hwp/OffcsCellFinder.java @@ -0,0 +1,43 @@ +package cokr.xit.fims.cmmn.hwp; + +import java.util.ArrayList; + +import cokr.xit.base.docs.hwp.HWPWriter; +import kr.dogfoot.hwplib.object.bodytext.control.Control; +import kr.dogfoot.hwplib.object.bodytext.control.ControlTable; +import kr.dogfoot.hwplib.object.bodytext.control.ControlType; +import kr.dogfoot.hwplib.object.bodytext.control.table.Cell; +import kr.dogfoot.hwplib.object.bodytext.control.table.Row; +import kr.dogfoot.hwplib.tool.objectfinder.ControlFinder; + +public class OffcsCellFinder { + + + public static Cell find(HWPWriter writer) { + ArrayList find = ControlFinder.find(writer.getFile(), (control, paragrpah, section) -> { + if(control.getType().equals(ControlType.Table)) { + ArrayList rl = ((ControlTable)control).getRowList(); + if(rl.size() == 1) { + ArrayList cl = rl.get(0).getCellList(); + if(cl.size() == 1) { + String fn = cl.get(0).getListHeader().getFieldName(); + if(fn != null && !fn.equals("")) { + if(fn.equals("직인")) { + return true; + } + } + } + } + } + return false; + }); + + if(find != null && !find.isEmpty()) { + ControlTable tableForOffcs = (ControlTable) find.get(0); + Cell cell = tableForOffcs.getRowList().get(0).getCellList().get(0); + return cell; + } + + return null; + } +} diff --git a/src/main/java/cokr/xit/fims/cmmn/hwp/format/CrdnConfirm.java b/src/main/java/cokr/xit/fims/cmmn/hwp/format/CrdnConfirm.java index 56d1e7b1..aa92ac78 100644 --- a/src/main/java/cokr/xit/fims/cmmn/hwp/format/CrdnConfirm.java +++ b/src/main/java/cokr/xit/fims/cmmn/hwp/format/CrdnConfirm.java @@ -2,11 +2,10 @@ package cokr.xit.fims.cmmn.hwp.format; import java.util.List; +import cokr.xit.base.docs.hwp.HWPWriter; import cokr.xit.fims.cmmn.CmmnUtil; import cokr.xit.fims.cmmn.Print; import cokr.xit.fims.cmmn.PrintOption; -import cokr.xit.fims.cmmn.hwp.ClickHereEditor; -import cokr.xit.fims.cmmn.hwp.InsertingImageCell; import cokr.xit.fims.mngt.FactionUtil; import cokr.xit.foundation.data.DataObject; import kr.dogfoot.hwplib.object.HWPFile; @@ -16,92 +15,71 @@ import kr.dogfoot.hwplib.object.HWPFile; */ public class CrdnConfirm extends HWPFormat { - @Override - public List getDownloadDataNames() { - return List.of("과태료구분","차량번호","단속일시","위반내용","단속장소","단속동","단속조","소유자명","소유자주소"); + public CrdnConfirm(PrintOption printOption, Print print, List dataObjectList) { + super(printOption, print, dataObjectList); + this.maxRunCount = dataObjectList.size(); + this.formatFilePath = "template/hwp/crdnConfirm.hwp"; + this.print.setFormatKorName("단속확인서"); + this.print.setFormatName("crdnConfirm"); } @Override - public void setting(Print print) { - print.setFormatName("crdnConfirm"); - print.setFormatKorName("단속확인서"); - - this.setFormatType("info"); - this.setRecordPerPartFile(1); - - this.setBaseFormatFilePath("template/hwp/crdnConfirm.hwp"); - this.setAttachFormatFilePath(""); + public List getDownloadDataNames() { + return List.of("과태료구분","차량번호","단속일시","위반내용","단속장소","단속동","단속조","소유자명","소유자주소"); } - @Override - public void setting(Print print, int recordCnt) { - print.setFormatName("crdnConfirm"); - print.setFormatKorName("단속확인서"); - - this.setFormatType("info"); - this.setRecordPerPartFile(recordCnt); - - this.setBaseFormatFilePath("template/hwp/crdnConfirm.hwp"); - this.setAttachFormatFilePath(""); - } - @Override - public void writeGlobalInfo(HWPFile baseFile, List 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("TASK_SE_NM")); - baseFileEditor.set("차량번호", dataObject.string("VHRNO")); - String crdnYmdTm = dataObject.string("CRDN_YMD_TM"); - crdnYmdTm = CmmnUtil.yyyy_mm_dd_hh_mm_ss(crdnYmdTm); - baseFileEditor.set("단속일시", crdnYmdTm); - - baseFileEditor.set("위반내용", dataObject.string("VLTN_ARTCL")); - baseFileEditor.set("단속장소", dataObject.string("CRDN_PLC")); - baseFileEditor.set("단속동", dataObject.string("CRDN_STDG_NM")); - baseFileEditor.set("단속조", dataObject.string("TEAM_NM")); - baseFileEditor.set("소유자", dataObject.string("RTPYR_NM")); - baseFileEditor.set("주소", dataObject.string("RTPYR_FULL_ADDR")); - baseFileEditor.set("우편번호", dataObject.string("RTPYR_ZIP")); + public void runAsWriter() { + HWPFile hwpFile = HWPWriter.classpath(this.formatFilePath); + this.writer = new HWPWriter(hwpFile); 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) print.getPrintRequestUserInfo().getInfo().get("instNm"); - instNm = FactionUtil.getInstituteLeader(instNm, false); - baseFileEditor.set("발신", instNm); - - try { - if(!dataObject.string("PHOTO1").equals("")) { - InsertingImageCell.IMPL_InsertPicture(baseFile, "왼쪽위사진", dataObject.string("PHOTO1")); - } - if(!dataObject.string("PHOTO2").equals("")) { - InsertingImageCell.IMPL_InsertPicture(baseFile, "오른쪽위사진", dataObject.string("PHOTO2")); - } - if(!dataObject.string("PHOTO3").equals("")) { - InsertingImageCell.IMPL_InsertPicture(baseFile, "왼쪽아래사진", dataObject.string("PHOTO3")); - } - if(!dataObject.string("PHOTO4").equals("")) { - InsertingImageCell.IMPL_InsertPicture(baseFile, "오른쪽아래사진", dataObject.string("PHOTO4")); - } - } catch(Exception e) { - - throw new RuntimeException("한글 파일 출력 중 오류가 발생하였습니다."); + + String instNm = FactionUtil.getInstituteLeader((String)print.getPrintRequestUserInfo().getInfo().get("instNm"), false); + + + DataObject one = data.get(currentRunCount); + DataObject newObj = (DataObject) new DataObject() + .set("과태료", one.string("TASK_SE_NM")) + .set("차량번호", one.string("VHRNO")) + .set("단속일시", CmmnUtil.yyyy_mm_dd_hh_mm_ss(one.string("CRDN_YMD_TM"))) + .set("위반내용", one.string("VLTN_ARTCL")) + .set("단속장소", one.string("CRDN_PLC")) + .set("단속동", one.string("CRDN_STDG_NM")) + .set("단속조", one.string("TEAM_NM")) + .set("소유자", one.string("RTPYR_NM")) + .set("주소", one.string("RTPYR_FULL_ADDR")) + .set("우편번호", one.string("RTPYR_ZIP")) + .set("연월일", ymd) + .set("발신", instNm); + + if(!one.string("PHOTO1").equals("")) { + newObj.set("왼쪽위사진", writer.image().add(one.string("PHOTO1"))); + } + if(!one.string("PHOTO2").equals("")) { + newObj.set("오른쪽위사진", writer.image().add(one.string("PHOTO2"))); } + if(!one.string("PHOTO3").equals("")) { + newObj.set("왼쪽아래사진", writer.image().add(one.string("PHOTO3"))); + } + if(!one.string("PHOTO4").equals("")) { + newObj.set("오른쪽아래사진", writer.image().add(one.string("PHOTO4"))); + } + + writer.table(0, 0, 13).setValues(List.of(newObj)); + + String tempPath = this.pathForNewFile(currentRunCount+1); + writer.write(tempPath); + resultFilesPath.add(tempPath); } + + } diff --git a/src/main/java/cokr/xit/fims/cmmn/hwp/format/CrdnList.java b/src/main/java/cokr/xit/fims/cmmn/hwp/format/CrdnList.java index 39a68947..bbf26961 100644 --- a/src/main/java/cokr/xit/fims/cmmn/hwp/format/CrdnList.java +++ b/src/main/java/cokr/xit/fims/cmmn/hwp/format/CrdnList.java @@ -2,11 +2,12 @@ package cokr.xit.fims.cmmn.hwp.format; import java.util.ArrayList; import java.util.List; +import java.util.stream.IntStream; +import cokr.xit.base.docs.hwp.HWPWriter; import cokr.xit.fims.cmmn.CmmnUtil; import cokr.xit.fims.cmmn.Print; import cokr.xit.fims.cmmn.PrintOption; -import cokr.xit.fims.cmmn.hwp.ClickHereEditor; import cokr.xit.fims.mngt.FactionUtil; import cokr.xit.foundation.data.DataFormat; import cokr.xit.foundation.data.DataObject; @@ -17,6 +18,14 @@ import kr.dogfoot.hwplib.object.HWPFile; */ public class CrdnList extends HWPFormat { + public CrdnList(PrintOption printOption, Print print, List dataObjectList){ + super(printOption, print, dataObjectList); + this.maxRunCount = 1; + this.formatFilePath = "template/hwp/crdnList.hwp"; + this.print.setFormatKorName("단속내역서"); + this.print.setFormatName("crdnList"); + } + @Override public List getDownloadDataNames() { List list = new ArrayList<>(); @@ -37,86 +46,59 @@ public class CrdnList extends HWPFormat { return list; } - @Override - public void setting(Print print) { - print.setFormatName("crdnList"); - print.setFormatKorName("단속내역서"); - - this.setFormatType("list"); - this.setRecordPerPartFile(6); - - this.setBaseFormatFilePath("template/hwp/crdnList_root.hwp"); - this.setAttachFormatFilePath("template/hwp/crdnList_inner.hwp"); - } - - - @Override - public void setting(Print print, int recordCnt) { - print.setFormatName("crdnList"); - print.setFormatKorName("단속내역서"); - - this.setFormatType("list"); - this.setRecordPerPartFile(recordCnt); - - this.setBaseFormatFilePath("template/hwp/crdnList_root.hwp"); - this.setAttachFormatFilePath("template/hwp/crdnList_inner.hwp"); - } @Override - public void writeGlobalInfo(HWPFile baseFile, List dataObjectList, - PrintOption printOption, Print print) { + public void runAsWriter() { + HWPFile hwpFile = HWPWriter.classpath(this.formatFilePath); + this.writer = new HWPWriter(hwpFile); - ClickHereEditor baseFileEditor = new ClickHereEditor(baseFile); + String globalRtpyrNm = data.get(0).string("RTPYR_NM"); + String globalRtpyrNo = data.get(0).string("RTPYR_NO"); + String globalRtpyrFullAddr = data.get(0).string("RTPYR_FULL_ADDR"); + int globalTotalAmount = data.stream().mapToInt(i -> i.number("LEVY_AMT").intValue()).sum(); - String globalRtpyrNm = dataObjectList.get(0).string("RTPYR_NM"); - String globalRtpyrNo = dataObjectList.get(0).string("RTPYR_NO"); - String globalRtpyrFullAddr = dataObjectList.get(0).string("RTPYR_FULL_ADDR"); - int globalTotalAmount = dataObjectList.stream().mapToInt(i -> i.number("LEVY_AMT").intValue()).sum(); - - //상단 - baseFileEditor.set("성명", globalRtpyrNm); + writer.setValue("출력일시", CmmnUtil.yyyy_mm_dd_hh_mm_ss(print.getPrintRequestDt())); + writer.setValue("성명", globalRtpyrNm); if(print.getPrivateInfoYn(printOption)) { - baseFileEditor.set("주민번호", globalRtpyrNo); + writer.setValue("주민번호", globalRtpyrNo); } else { - baseFileEditor.set("주민번호", "*************"); + writer.setValue("주민번호", "*************"); } - - baseFileEditor.set("주소", globalRtpyrFullAddr); - baseFileEditor.set("총건수", CmmnUtil.addCommaToNumber(print.getTotalDataCount(dataObjectList))); - baseFileEditor.set("총금액", CmmnUtil.addCommaToNumber(globalTotalAmount)); - baseFileEditor.set("출력일시", CmmnUtil.yyyy_mm_dd_hh_mm_ss(print.getPrintRequestDt())); + writer.setValue("주소", globalRtpyrFullAddr); + writer.setValue("총건수", DataFormat.n_nn0(print.getTotalDataCount(this.data))); + writer.setValue("총금액", DataFormat.n_nn0(globalTotalAmount)); String instNm = (String) print.getPrintRequestUserInfo().getInfo().get("instNm"); instNm = FactionUtil.getLastWord(instNm); - baseFileEditor.set("발신", instNm); - } - + writer.setValue("발신", instNm); + + List list = IntStream.rangeClosed(1, this.data.size()).boxed().map(i -> { + DataObject one = data.get(i-1); + return (DataObject) new DataObject() + .set("과태료", one.string("TASK_SE_NM")) + .set("시군구명", one.string("SGG_NM")) + .set("단속일시", CmmnUtil.yyyy_mm_dd_hh_mm_ss(one.string("CRDN_YMD_TM"))) + .set("단속장소", one.string("CRDN_PLC")) + .set("차량번호", one.string("VHRNO")) + .set("대체차량번호", one.string("RPM_SZR_VHRNO")) + .set("고지번호", one.string("GOJI_NO")) + .set("금액", DataFormat.n_nn0(one.string("LEVY_AMT"))) + .set("가상계좌번호", one.string("VR_ACTNO")) + .set("전자납부번호", one.string("EPAYNO")) + .set("처리상태", one.string("CRDN_STTS_NM")) + .set("처리일자", DataFormat.yyyy_mm_dd(one.string("CRDN_STTS_CHG_DT").substring(0, 8))) + .set("납부기한", DataFormat.yyyy_mm_dd(one.string("DUDT_YMD"))) + .set("수납일자", DataFormat.yyyy_mm_dd(one.string("RCVMT_YMD"))); + }).toList(); + writer.table(2, 0, 3).setValues(list); + + + String tempPath = this.pathForNewFile(currentRunCount+1); + writer.write(tempPath); + resultFilesPath.add(tempPath); - @Override - public void writeSingleDataInfo(HWPFile baseFile, HWPFile attachFile, - DataObject dataObject, Print print) { - - ClickHereEditor attachFileEditor = new ClickHereEditor(attachFile); - - attachFileEditor.set("과태료", dataObject.string("TASK_SE_NM")); - attachFileEditor.set("시군구명", dataObject.string("SGG_NM")); - String crdnYmdTm = dataObject.string("CRDN_YMD_TM"); - crdnYmdTm = CmmnUtil.yyyy_mm_dd_hh_mm_ss(crdnYmdTm); - attachFileEditor.set("단속일시", crdnYmdTm); - attachFileEditor.set("단속장소", dataObject.string("CRDN_PLC")); - attachFileEditor.set("차량번호", dataObject.string("VHRNO")); - attachFileEditor.set("대체차량번호", dataObject.string("RPM_SZR_VHRNO")); - attachFileEditor.set("고지번호", dataObject.string("GOJI_NO")); - attachFileEditor.set("금액", CmmnUtil.addCommaToNumber(dataObject.string("LEVY_AMT"))); - attachFileEditor.set("가상계좌번호", dataObject.string("VR_ACTNO")); - attachFileEditor.set("전자납부번호", dataObject.string("EPAYNO")); - attachFileEditor.set("처리상태", dataObject.string("CRDN_STTS_NM")); - String crdnSttsChgDt = dataObject.string("CRDN_STTS_CHG_DT"); - crdnSttsChgDt = DataFormat.yyyy_mm_dd(crdnSttsChgDt.substring(0, 8)); - attachFileEditor.set("처리일자", crdnSttsChgDt); - attachFileEditor.set("납부기한", DataFormat.yyyy_mm_dd(dataObject.string("DUDT_YMD"))); - attachFileEditor.set("수납일자", DataFormat.yyyy_mm_dd(dataObject.string("RCVMT_YMD"))); } + } diff --git a/src/main/java/cokr/xit/fims/cmmn/hwp/format/CvlcptOrgn.java b/src/main/java/cokr/xit/fims/cmmn/hwp/format/CvlcptOrgn.java index a168b5c4..7a9ba3c1 100644 --- a/src/main/java/cokr/xit/fims/cmmn/hwp/format/CvlcptOrgn.java +++ b/src/main/java/cokr/xit/fims/cmmn/hwp/format/CvlcptOrgn.java @@ -1,98 +1,130 @@ package cokr.xit.fims.cmmn.hwp.format; -import java.io.InputStream; +import java.util.ArrayList; +import java.util.HashMap; import java.util.List; -import org.springframework.core.io.ClassPathResource; - +import cokr.xit.base.docs.hwp.HWPWriter; import cokr.xit.fims.cmmn.CmmnUtil; import cokr.xit.fims.cmmn.Print; import cokr.xit.fims.cmmn.PrintOption; -import cokr.xit.fims.cmmn.hwp.AddUtil; -import cokr.xit.fims.cmmn.hwp.ClickHereEditor; -import cokr.xit.fims.cmmn.hwp.InsertingImageCell; 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 { + private List data2 = null; - @Override - public List getDownloadDataNames() { - return List.of("접수번호","신청자","접수일자","처리기한","민원목록번호","민원내용"); - } + public CvlcptOrgn(PrintOption printOption, Print print, List dataObjectList) { + super(printOption, print, dataObjectList); + this.maxRunCount = 1; + this.formatFilePath = "template/hwp/cvlcptOrgnl_text.hwp"; + this.print.setFormatKorName("민원원본내역"); + this.print.setFormatName("cvlcptOrgnl"); - @Override - public void setting(Print print) { - print.setFormatName("cvlcptOrgn"); - print.setFormatKorName("민원원본내역"); + this.data2 = new ArrayList(); + if(!dataObjectList.get(0).string("PHOTO0").equals("")) { + + int photoCnt = dataObjectList.get(0).number("ORGN_PHOTO_CNT").intValue(); + int PHOTO_COUNT_PER_PAGE = 4; - this.setFormatType("info"); - this.setRecordPerPartFile(1); + for(int i=0; i < photoCnt; i += PHOTO_COUNT_PER_PAGE) { - this.setBaseFormatFilePath("template/hwp/cvlcptOrgnl_text.hwp"); - this.setAttachFormatFilePath("template/hwp/cvlcptOrgnl_photo.hwp"); + DataObject photoObj = new DataObject(); + + photoObj.set("PHOTO1", dataObjectList.get(0).string("PHOTO"+i)); + if(i+1 < photoCnt) + photoObj.set("PHOTO2", dataObjectList.get(0).string("PHOTO"+(i+1))); + if(i+2 < photoCnt) + photoObj.set("PHOTO3", dataObjectList.get(0).string("PHOTO"+(i+2))); + if(i+3 < photoCnt) + photoObj.set("PHOTO4", dataObjectList.get(0).string("PHOTO"+(i+3))); + + data2.add(photoObj); + } + } } @Override - public void setting(Print print, int cnt) { + public List getDownloadDataNames() { + return List.of("접수번호","신청자","접수일자","처리기한","민원목록번호","민원내용"); } @Override - public void writeGlobalInfo(HWPFile baseFile, List dataObjectList, PrintOption printOption, - Print print) { + public HashMap makeFile(){ + runAsWriter(); + writer = null; + currentRunCount++; + + if(data2 != null && data2.size() > 0) { + + formatFilePath = "template/hwp/cvlcptOrgnl_photo.hwp"; + maxRunCount = data2.size()+1; + while(currentRunCount != maxRunCount) { + runAsWriter(); + writer = null; + currentRunCount++; + } + } + + return getResult(); } - @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"))); + @Override + public void runAsWriter() { - String cvlcptRrcsPrnmntDt = dataObject.string("CVLCPT_PRCS_PRNMNT_DT"); - if(cvlcptRrcsPrnmntDt.length() > 8) { - cvlcptRrcsPrnmntDt = cvlcptRrcsPrnmntDt.substring(0, 8); - } + HWPFile hwpFile = HWPWriter.classpath(this.formatFilePath); + this.writer = new HWPWriter(hwpFile); - baseFileEditor.set("처리기한", DataFormat.yyyy_mm_dd(cvlcptRrcsPrnmntDt)); - baseFileEditor.set("접수번호", dataObject.string("CVLCPT_RCPT_NO")); - baseFileEditor.set("목록번호", dataObject.string("CVLCPT_LIST_NO")); + if(this.formatFilePath.equals("template/hwp/cvlcptOrgnl_text.hwp")) { - String cvlcptAplyCn = dataObject.string("CVLCPT_APLY_CN"); - cvlcptAplyCn = CmmnUtil.escapeHTMLEntity(cvlcptAplyCn); - baseFileEditor.set("민원내용", cvlcptAplyCn); - try { + DataObject one = data.get(0); - if(dataObject.string("PHOTO0") != null && !dataObject.string("PHOTO0").equals("")) { + writer.setValue("신청자", one.string("CVLCPT_APLCNT_NM")); + writer.setValue("접수일자", DataFormat.yyyy_mm_dd(one.string("CVLCPT_RCPT_YMD"))); - int photoCnt = dataObject.number("ORGN_PHOTO_CNT").intValue(); - int PHOTO_COUNT_PER_PAGE = 4; + String cvlcptRrcsPrnmntDt = one.string("CVLCPT_PRCS_PRNMNT_DT"); + if(cvlcptRrcsPrnmntDt.length() > 8) { + cvlcptRrcsPrnmntDt = cvlcptRrcsPrnmntDt.substring(0, 8); + } - for(int i=0; i < photoCnt; i += PHOTO_COUNT_PER_PAGE) { + writer.setValue("처리기한", DataFormat.yyyy_mm_dd(cvlcptRrcsPrnmntDt)); + writer.setValue("접수번호", one.string("CVLCPT_RCPT_NO")); + writer.setValue("목록번호", one.string("CVLCPT_LIST_NO")); - 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); + String cvlcptAplyCn = one.string("CVLCPT_APLY_CN"); + cvlcptAplyCn = CmmnUtil.escapeHTMLEntity(cvlcptAplyCn); + writer.setValue("민원내용", cvlcptAplyCn); - } + } else { + DataObject one = data2.get(currentRunCount-1); + DataObject newObj = new DataObject(); + if(!one.string("PHOTO1").equals("")) { + newObj.set("왼쪽위사진", writer.image().add(one.string("PHOTO1"))); } - } catch (Exception e) { - throw new RuntimeException("[F]"+e); + if(!one.string("PHOTO2").equals("")) { + newObj.set("오른쪽위사진", writer.image().add(one.string("PHOTO2"))); + } + if(!one.string("PHOTO3").equals("")) { + newObj.set("왼쪽아래사진", writer.image().add(one.string("PHOTO3"))); + } + if(!one.string("PHOTO4").equals("")) { + newObj.set("오른쪽아래사진", writer.image().add(one.string("PHOTO4"))); + } + writer.table(0, 0, 2).setValues(List.of(newObj)); + } + + String tempPath = this.pathForNewFile(currentRunCount+1); + writer.write(tempPath); + resultFilesPath.add(tempPath); } + } diff --git a/src/main/java/cokr/xit/fims/cmmn/hwp/format/DlbrDecsnList.java b/src/main/java/cokr/xit/fims/cmmn/hwp/format/DlbrDecsnList.java index fbe98ba1..6b5dbdaa 100644 --- a/src/main/java/cokr/xit/fims/cmmn/hwp/format/DlbrDecsnList.java +++ b/src/main/java/cokr/xit/fims/cmmn/hwp/format/DlbrDecsnList.java @@ -3,14 +3,22 @@ package cokr.xit.fims.cmmn.hwp.format; import java.util.ArrayList; import java.util.List; +import cokr.xit.base.docs.hwp.HWPWriter; import cokr.xit.fims.cmmn.Print; import cokr.xit.fims.cmmn.PrintOption; -import cokr.xit.fims.cmmn.hwp.ClickHereEditor; import cokr.xit.foundation.data.DataObject; import kr.dogfoot.hwplib.object.HWPFile; public class DlbrDecsnList extends HWPFormat { + public DlbrDecsnList(PrintOption printOption, Print print, List dataObjectList) { + super(printOption, print, dataObjectList); + this.maxRunCount = dataObjectList.size(); + this.formatFilePath = "template/hwp/opnnDlbrDecsnForm.hwp"; + this.print.setFormatKorName("의견제출심의결의서"); + this.print.setFormatName("dlbrDecsnList"); + } + @Override public List getDownloadDataNames() { List list = new ArrayList<>(); @@ -29,72 +37,47 @@ public class DlbrDecsnList extends HWPFormat { return list; } - @Override - public void setting(Print print) { - print.setFormatName("dlbrDecsn"); - print.setFormatKorName("의견제출심의결의서"); - - this.setFormatType("info"); - this.setRecordPerPartFile(1); - - this.setBaseFormatFilePath("template/hwp/opnnDlbrDecsnForm.hwp"); - this.setAttachFormatFilePath(""); - } @Override - public void setting(Print print, int recordCnt) { - print.setFormatName("dlbrDecsn"); - print.setFormatKorName("의견제출심의결의서"); - - this.setFormatType("info"); - this.setRecordPerPartFile(recordCnt); + public void runAsWriter() { + HWPFile hwpFile = HWPWriter.classpath(this.formatFilePath); + this.writer = new HWPWriter(hwpFile); + + DataObject one = data.get(currentRunCount); + + writer.setValue("접수번호", one.string("RCPT_NO_MASK")); + writer.setValue("접수일", one.string("RCPT_YMD_MASK")); + writer.setValue("위반정보", one.string("TASK_SE_NM")); + writer.setValue("진술자명", one.string("STTR_NM")); + writer.setValue("진술자생년월일", one.string("STTR_BRDT_FORMAT")); + writer.setValue("진술자연락처", one.string("STTR_CTTPC")); + writer.setValue("소유주관계", one.string("OWNR_REL_NM")); + writer.setValue("진술자주소", one.string("STTR_WHOL_ADDR")); + writer.setValue("차량번호", one.string("VHRNO")); + writer.setValue("단속일시", one.string("CRDN_YMD_TM_MASK")); + writer.setValue("단속장소", one.string("CRDN_PLC")); + writer.setValue("의견제출내용", one.string("OPNN_SBMSN_CN")); + writer.setValue("심의회원직급1", one.string("DLBR_MBR_JBGD1")); + writer.setValue("심의회원명1", one.string("DLBR_MBR_NM1")); + writer.setValue("심의회원직급2", one.string("DLBR_MBR_JBGD2")); + writer.setValue("심의회원명2", one.string("DLBR_MBR_NM2")); + writer.setValue("심의회원직급3", one.string("DLBR_MBR_JBGD3")); + writer.setValue("심의회원명3", one.string("DLBR_MBR_NM3")); + writer.setValue("심의회원직급4", one.string("DLBR_MBR_JBGD4")); + writer.setValue("심의회원명4", one.string("DLBR_MBR_NM4")); + writer.setValue("심의회원직급5", one.string("DLBR_MBR_JBGD5")); + writer.setValue("심의회원명5", one.string("DLBR_MBR_NM5")); + writer.setValue("심의회원직급6", one.string("DLBR_MBR_JBGD6")); + writer.setValue("심의회원명6", one.string("DLBR_MBR_NM6")); + writer.setValue("심의회원직급7", one.string("DLBR_MBR_JBGD7")); + writer.setValue("심의회원명7", one.string("DLBR_MBR_NM7")); + writer.setValue("담당자검토의견", one.string("PIC_RVW_OPNN")); + + String tempPath = this.pathForNewFile(currentRunCount+1); + writer.write(tempPath); + resultFilesPath.add(tempPath); - this.setBaseFormatFilePath("template/hwp/opnnDlbrDecsnForm.hwp"); - this.setAttachFormatFilePath(""); } - - @Override - public void writeGlobalInfo(HWPFile baseFile, List 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("RCPT_NO_MASK")); - baseFileEditor.set("접수일", dataObject.string("RCPT_YMD_MASK")); - baseFileEditor.set("위반정보", dataObject.string("TASK_SE_NM")); - baseFileEditor.set("진술자명", dataObject.string("STTR_NM")); - baseFileEditor.set("진술자생년월일", dataObject.string("STTR_BRDT_FORMAT")); - baseFileEditor.set("진술자연락처", dataObject.string("STTR_CTTPC")); - baseFileEditor.set("소유주관계", dataObject.string("OWNR_REL_NM")); - baseFileEditor.set("진술자주소", dataObject.string("STTR_WHOL_ADDR")); - baseFileEditor.set("차량번호", dataObject.string("VHRNO")); - baseFileEditor.set("단속일시", dataObject.string("CRDN_YMD_TM_MASK")); - baseFileEditor.set("단속장소", dataObject.string("CRDN_PLC")); - baseFileEditor.set("의견제출내용", dataObject.string("OPNN_SBMSN_CN")); - baseFileEditor.set("심의회원직급1", dataObject.string("DLBR_MBR_JBGD1")); - baseFileEditor.set("심의회원명1", dataObject.string("DLBR_MBR_NM1")); - baseFileEditor.set("심의회원직급2", dataObject.string("DLBR_MBR_JBGD2")); - baseFileEditor.set("심의회원명2", dataObject.string("DLBR_MBR_NM2")); - baseFileEditor.set("심의회원직급3", dataObject.string("DLBR_MBR_JBGD3")); - baseFileEditor.set("심의회원명3", dataObject.string("DLBR_MBR_NM3")); - baseFileEditor.set("심의회원직급4", dataObject.string("DLBR_MBR_JBGD4")); - baseFileEditor.set("심의회원명4", dataObject.string("DLBR_MBR_NM4")); - baseFileEditor.set("심의회원직급5", dataObject.string("DLBR_MBR_JBGD5")); - baseFileEditor.set("심의회원명5", dataObject.string("DLBR_MBR_NM5")); - baseFileEditor.set("심의회원직급6", dataObject.string("DLBR_MBR_JBGD6")); - baseFileEditor.set("심의회원명6", dataObject.string("DLBR_MBR_NM6")); - baseFileEditor.set("심의회원직급7", dataObject.string("DLBR_MBR_JBGD7")); - baseFileEditor.set("심의회원명7", dataObject.string("DLBR_MBR_NM7")); - baseFileEditor.set("담당자검토의견", dataObject.string("PIC_RVW_OPNN")); - } - - - } diff --git a/src/main/java/cokr/xit/fims/cmmn/hwp/format/HWPFormat.java b/src/main/java/cokr/xit/fims/cmmn/hwp/format/HWPFormat.java index 3373b74d..73d96f5e 100644 --- a/src/main/java/cokr/xit/fims/cmmn/hwp/format/HWPFormat.java +++ b/src/main/java/cokr/xit/fims/cmmn/hwp/format/HWPFormat.java @@ -1,108 +1,98 @@ package cokr.xit.fims.cmmn.hwp.format; import java.io.File; -import java.io.InputStream; import java.text.SimpleDateFormat; +import java.util.ArrayList; import java.util.Date; +import java.util.HashMap; import java.util.List; -import org.springframework.core.io.ClassPathResource; - +import cokr.xit.base.docs.hwp.HWPWriter; import cokr.xit.fims.cmmn.Print; import cokr.xit.fims.cmmn.PrintOption; +import cokr.xit.fims.cmmn.hwp.HwpMerge; 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 abstract class HWPFormat { - protected String formatType; - protected int recordPerPartFile; - - protected String baseFormatFilePath; - - protected String attachFormatFilePath; +public abstract class HWPFormat { + protected HWPWriter writer; - protected int totalPartFileCount; + protected PrintOption printOption; + protected Print print; + protected List data; - public String getFormatType() { - return this.formatType; - } + protected String formatFilePath; - public void setFormatType(String formatType) { - this.formatType = formatType; - } - public int getRecordPerPartFile() { - return this.recordPerPartFile; - } + protected int currentRunCount; + protected int maxRunCount; + protected List resultFilesPath; - public void setRecordPerPartFile(int recordPerPartFile) { - this.recordPerPartFile = recordPerPartFile; + public HWPFormat(PrintOption printOption, Print print, List dataObjectList) { + this.resultFilesPath = new ArrayList(); + this.currentRunCount = 0; + this.data = dataObjectList; + this.printOption = printOption; + this.print = print; } - public int getTotalPartFileCount() { - return this.totalPartFileCount; - } + public HashMap makeFile(){ + while(currentRunCount != maxRunCount) { + runAsWriter(); + writer = null; + currentRunCount++; + } - public void setTotalPartFileCount(int totalPartFileCount) { - this.totalPartFileCount = totalPartFileCount; - } + return getResult(); + }; - public String getBaseFormatFilePath() { - return this.baseFormatFilePath; - } - public void setBaseFormatFilePath(String baseFormatFilePath) { - this.baseFormatFilePath = baseFormatFilePath; - } + protected abstract void runAsWriter(); - public String getAttachFormatFilePath() { - return this.attachFormatFilePath; - } + protected HashMap getResult(){ + HashMap result = new HashMap(); - public void setAttachFormatFilePath(String attachFormatFilePath) { - this.attachFormatFilePath = attachFormatFilePath; - } + String downlaodFileName = this.print.getFormatKorName()+"_"+this.print.getPrintRequestDt()+".hwp"; + if(resultFilesPath.size() >= 2) { - /** 신규로 생성될 한글 파일 건수를 계산한다. - * @param 총 데이터 건수 - * @return - */ - public void calcTotalPartFileCount(int totalDataCount) { + try { + String basePath = resultFilesPath.get(0); + HWPFile baseFile = HWPReader.fromFile(basePath); - if(this.formatType.equals("list")) { - if(totalDataCount <= this.recordPerPartFile) { - this.totalPartFileCount = 1; - } else { + for(int i=2; i <= resultFilesPath.size();i++) { + String attachPath = resultFilesPath.get(i-1); + HWPFile attachFile = HWPReader.fromFile(attachPath); + HwpMerge.appendToLast(attachFile, baseFile); + } - int mod = (totalDataCount % this.recordPerPartFile); + kr.dogfoot.hwplib.writer.HWPWriter.toFile(baseFile, basePath); + } catch (Exception e) { + throw new RuntimeException("한글 파일 출력 중 오류가 발생하였습니다."); + } - this.totalPartFileCount = (totalDataCount - mod) / this.recordPerPartFile; - if(mod > 0) { - this.totalPartFileCount = this.totalPartFileCount + 1; + for(int i=2; i <= resultFilesPath.size();i++) { + if(!(new File(resultFilesPath.get(i-1))).delete()) { + throw new RuntimeException("한글 파일 출력 중 오류가 발생하였습니다."); } - } - } else { - this.totalPartFileCount = totalDataCount; } - } + result.put("filename", downlaodFileName); + result.put("filePath", resultFilesPath.get(0)); + result.put("file", new File(resultFilesPath.get(0))); + result.put("downloadData", data); + result.put("dataNames", getDownloadDataNames()); + return result; + }; - /**한글 포맷 파일을 복사하여 새 한글파일을 생성한다. - * @param formatFile 한글 포맷 파일 - * @return 새 파일 경로 - */ - public String newFileFromFormatFile(Print print) { - try { + public abstract List getDownloadDataNames(); - InputStream baseFormatIS = new ClassPathResource(this.getBaseFormatFilePath()).getInputStream(); - HWPFile baseFormatFile = HWPReader.fromInputStream(baseFormatIS); + public String pathForNewFile(int fileIndex) { + try { SimpleDateFormat ymdhmsFormat = new SimpleDateFormat("yyyyMMddHHmmss"); String currentTime = ymdhmsFormat.format(new Date()); @@ -116,12 +106,8 @@ public abstract class HWPFormat { if(!formatFileResultFolder.exists()) { formatFileResultFolder.mkdirs(); } - String resultHwpPath = formatFileResultFolderPath - + File.separator + currentTime + "_" + (print.getFileNameIndex()) + ".hwp"; - - print.setFileNameIndex(print.getFileNameIndex()+1); + String resultHwpPath = formatFileResultFolderPath + File.separator + currentTime +"_"+fileIndex+ ".hwp"; - HWPWriter.toFile(baseFormatFile, resultHwpPath); return resultHwpPath; } catch (Exception e){ @@ -130,28 +116,4 @@ public abstract class HWPFormat { } - /** 포맷 형식별 기초 설정 적용. - * @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 dataObjectList, - PrintOption printOption, Print print); - - /** 데이터 건별 한글파일 처리 - * @param - * @return - */ - public abstract void writeSingleDataInfo(HWPFile baseFile, HWPFile attachFile, DataObject dataObject, - Print print); - - public abstract List getDownloadDataNames(); - } diff --git a/src/main/java/cokr/xit/fims/cmmn/hwp/format/RcvmtConfirm.java b/src/main/java/cokr/xit/fims/cmmn/hwp/format/RcvmtConfirm.java index a2078a0a..c71bc6ec 100644 --- a/src/main/java/cokr/xit/fims/cmmn/hwp/format/RcvmtConfirm.java +++ b/src/main/java/cokr/xit/fims/cmmn/hwp/format/RcvmtConfirm.java @@ -3,10 +3,10 @@ package cokr.xit.fims.cmmn.hwp.format; import java.util.ArrayList; import java.util.List; +import cokr.xit.base.docs.hwp.HWPWriter; import cokr.xit.fims.cmmn.CmmnUtil; import cokr.xit.fims.cmmn.Print; import cokr.xit.fims.cmmn.PrintOption; -import cokr.xit.fims.cmmn.hwp.ClickHereEditor; import cokr.xit.fims.mngt.FactionUtil; import cokr.xit.foundation.data.DataFormat; import cokr.xit.foundation.data.DataObject; @@ -17,6 +17,15 @@ import kr.dogfoot.hwplib.object.HWPFile; */ public class RcvmtConfirm extends HWPFormat { + public RcvmtConfirm(PrintOption printOption, Print print, List dataObjectList) { + super(printOption, print, dataObjectList); + + this.maxRunCount = dataObjectList.size(); + this.formatFilePath = "template/hwp/rcvmtConfirm.hwp"; + print.setFormatKorName("납부확인서"); + print.setFormatName("rcvmtConfirm"); + } + @Override public List getDownloadDataNames() { List list = new ArrayList<>(); @@ -35,65 +44,45 @@ public class RcvmtConfirm extends HWPFormat { return list; } - @Override - public void setting(Print print) { - print.setFormatName("rcvmtConfirm"); - print.setFormatKorName("납부확인서"); - - this.setFormatType("info"); - this.setRecordPerPartFile(1); - - this.setBaseFormatFilePath("template/hwp/rcvmtConfirm.hwp"); - this.setAttachFormatFilePath(""); - } @Override - public void setting(Print print, int recordCnt) { - print.setFormatName("rcvmtConfirm"); - print.setFormatKorName("납부확인서"); + public void runAsWriter() { + HWPFile hwpFile = HWPWriter.classpath(this.formatFilePath); + this.writer = new HWPWriter(hwpFile); - this.setFormatType("info"); - this.setRecordPerPartFile(recordCnt); + String instNm = FactionUtil.getInstituteLeader((String) print.getPrintRequestUserInfo().getInfo().get("instNm"), false); - this.setBaseFormatFilePath("template/hwp/rcvmtConfirm.hwp"); - this.setAttachFormatFilePath(""); - } + DataObject one = data.get(currentRunCount); + DataObject newObj = (DataObject) new DataObject() + .set("위반명1", one.string("TASK_SE_NM")) + .set("위반명2", one.string("TASK_SE_NM")) + .set("위반차량", one.string("VHRNO")) + .set("대체차량", one.string("RPM_SZR_VHRNO")) + .set("위반금액", CmmnUtil.addCommaToNumber(one.string("FFNLG_AMT"))) + .set("단속일자", DataFormat.yyyy_mm_dd(one.string("CRDN_YMD"))) + .set("단속장소", one.string("CRDN_PLC")) + .set("소유자", one.string("RTPYR_NM")) + //.set("주민번호", one.string("RTPYR_NO")) + .set("주소", one.string("RTPYR_FULL_ADDR")) + .set("고지번호", one.string("GOJI_NO")) + .set("수납일자", DataFormat.yyyy_mm_dd(one.string("RCVMT_YMD"))) + .set("수납금액", CmmnUtil.addCommaToNumber(one.string("RCVMT_AMT"))) + .set("연월일시분초", CmmnUtil.yyyy_mm_dd_hh_mm_ss(print.getPrintRequestDt())) + .set("확인자", print.getPrintRequestUserInfo().getName()) + .set("발신", instNm) + ; - @Override - public void writeGlobalInfo(HWPFile baseFile, List dataObjectList, PrintOption printOption, - Print print) { - } + writer.table(0, 0, 12).setValues(List.of(newObj)); - @Override - public void writeSingleDataInfo(HWPFile baseFile, HWPFile attachFile, - DataObject dataObject, Print print) { - - ClickHereEditor baseFileEditor = new ClickHereEditor(baseFile); - - baseFileEditor.set("위반명1", dataObject.string("TASK_SE_NM")); - baseFileEditor.set("위반명2", dataObject.string("TASK_SE_NM")); - baseFileEditor.set("위반차량", dataObject.string("VHRNO")); - baseFileEditor.set("대체차량", dataObject.string("RPM_SZR_VHRNO")); - baseFileEditor.set("위반금액", CmmnUtil.addCommaToNumber(dataObject.string("FFNLG_AMT"))); - baseFileEditor.set("단속일자", DataFormat.yyyy_mm_dd(dataObject.string("CRDN_YMD"))); - baseFileEditor.set("단속장소", dataObject.string("CRDN_PLC")); - baseFileEditor.set("소유자", dataObject.string("RTPYR_NM")); - baseFileEditor.set("주민번호", dataObject.string("RTPYR_NO")); - baseFileEditor.set("주소", dataObject.string("RTPYR_FULL_ADDR")); - baseFileEditor.set("고지번호", dataObject.string("GOJI_NO")); - 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(print.getPrintRequestDt())); - baseFileEditor.set("확인자", print.getPrintRequestUserInfo().getName()); - - String instNm = (String) print.getPrintRequestUserInfo().getInfo().get("instNm"); - instNm = FactionUtil.getInstituteLeader(instNm, false); - baseFileEditor.set("발신", instNm); + + String tempPath = this.pathForNewFile(currentRunCount+1); + writer.write(tempPath); + resultFilesPath.add(tempPath); } + } diff --git a/src/main/java/cokr/xit/fims/cmmn/hwp/format/ReportOnClaims.java b/src/main/java/cokr/xit/fims/cmmn/hwp/format/ReportOnClaims.java index 9fd71f2d..af918a5b 100644 --- a/src/main/java/cokr/xit/fims/cmmn/hwp/format/ReportOnClaims.java +++ b/src/main/java/cokr/xit/fims/cmmn/hwp/format/ReportOnClaims.java @@ -1,26 +1,39 @@ package cokr.xit.fims.cmmn.hwp.format; +import java.awt.Rectangle; import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.function.BiConsumer; +import java.util.stream.IntStream; import org.egovframe.rte.fdl.string.EgovStringUtil; +import cokr.xit.base.docs.hwp.HWPWriter; import cokr.xit.fims.cmmn.CmmnUtil; import cokr.xit.fims.cmmn.Print; import cokr.xit.fims.cmmn.PrintOption; -import cokr.xit.fims.cmmn.hwp.ClickHereEditor; -import cokr.xit.fims.cmmn.hwp.InsertingImageCell; +import cokr.xit.fims.cmmn.hwp.OffcsCellFinder; import cokr.xit.fims.mngt.FactionUtil; import cokr.xit.foundation.data.DataFormat; import cokr.xit.foundation.data.DataObject; import kr.dogfoot.hwplib.object.HWPFile; +import kr.dogfoot.hwplib.object.bodytext.control.table.Cell; +import kr.dogfoot.hwplib.object.bodytext.paragraph.Paragraph; /** * 채권신고서 */ public class ReportOnClaims extends HWPFormat { + public ReportOnClaims(PrintOption printOption, Print print, List dataObjectList) { + super(printOption, print, dataObjectList); + this.maxRunCount = 1; + this.formatFilePath = "template/hwp/reportOnClaims.hwp"; + this.print.setFormatKorName("채권신고서"); + this.print.setFormatName("reportOnClaims"); + } + @Override public List getDownloadDataNames() { List list = new ArrayList<>(); @@ -33,92 +46,74 @@ public class ReportOnClaims extends HWPFormat { return list; } - @Override - public void setting(Print print) { - print.setFormatName("reportOnClaims"); - print.setFormatKorName("채권신고서"); - - this.setFormatType("list"); - this.setRecordPerPartFile(7); - - this.setBaseFormatFilePath("template/hwp/reportOnClaims_root.hwp"); - this.setAttachFormatFilePath("template/hwp/reportOnClaims_inner.hwp"); - } - - @Override - public void setting(Print print, int recordCnt) { - print.setFormatName("reportOnClaims"); - print.setFormatKorName("채권신고서"); - - this.setFormatType("list"); - this.setRecordPerPartFile(recordCnt); - - this.setBaseFormatFilePath("template/hwp/reportOnClaims_root.hwp"); - this.setAttachFormatFilePath("template/hwp/reportOnClaims_inner.hwp"); - } @Override - public void writeGlobalInfo(HWPFile baseFile, List dataObjectList, PrintOption printOption, - Print print) { + public void runAsWriter() { + HWPFile hwpFile = HWPWriter.classpath(this.formatFilePath); + this.writer = new HWPWriter(hwpFile); + Map globalVariable = printOption.getGlobalVariable(); - Map globalVariable = print.getGlobalVariable(printOption); + String offcsFilePath = EgovStringUtil.null2void(globalVariable.get("offcsFilePath")); + if(!offcsFilePath.equals("")) { + BiConsumer bc = writer.image().add(offcsFilePath); - ClickHereEditor baseFileEditor = new ClickHereEditor(baseFile); + Cell cell = OffcsCellFinder.find(writer); + if(cell != null) { + Paragraph para = cell.getParagraphList().getParagraph(0); + int width = (int)cell.getListHeader().getWidth(), + height = (int)cell.getListHeader().getHeight(); + bc.accept(para, new Rectangle(1, 1, width, height)); + } - baseFileEditor.set("주소", globalVariable.get("deptAddr")); - baseFileEditor.set("전화", globalVariable.get("deptTelno")); - baseFileEditor.set("팩스", globalVariable.get("deptFxno")); - baseFileEditor.set("담당자", print.getPrintRequestUserInfo().getName()); - - baseFileEditor.set("사건번호", EgovStringUtil.null2void(globalVariable.get("caseNo"))); - baseFileEditor.set("체납자성명", EgovStringUtil.null2void(globalVariable.get("rtpyrNm"))); - baseFileEditor.set("체납자번호", EgovStringUtil.null2void(globalVariable.get("rtpyrNo"))); - baseFileEditor.set("체납자주소", EgovStringUtil.null2void(globalVariable.get("rtpyrFullAddr"))); - - int sumOfList = dataObjectList.stream().mapToInt(item -> item.number("SUM_AMT").intValue()).sum(); + } - baseFileEditor.set("채권청구액", CmmnUtil.addCommaToNumber(sumOfList)); - baseFileEditor.set("합계금액", CmmnUtil.addCommaToNumber(sumOfList)); - baseFileEditor.set("합계금액한글", CmmnUtil.convertNumberToHangul(sumOfList)); + writer.setValue("주소", globalVariable.get("deptAddr")); + writer.setValue("전화", globalVariable.get("deptTelno")); + writer.setValue("팩스", globalVariable.get("deptFxno")); + writer.setValue("담당자", print.getPrintRequestUserInfo().getName()); + writer.setValue("사건번호", EgovStringUtil.null2void(globalVariable.get("caseNo"))); + writer.setValue("체납자성명", EgovStringUtil.null2void(globalVariable.get("rtpyrNm"))); + writer.setValue("체납자번호", EgovStringUtil.null2void(globalVariable.get("rtpyrNo"))); + writer.setValue("체납자주소", EgovStringUtil.null2void(globalVariable.get("rtpyrFullAddr"))); + int sumOfList = data.stream().mapToInt(item -> item.number("SUM_AMT").intValue()).sum(); + writer.setValue("채권청구액", CmmnUtil.addCommaToNumber(sumOfList)); + writer.setValue("합계금액", CmmnUtil.addCommaToNumber(sumOfList)); + writer.setValue("합계금액한글", CmmnUtil.convertNumberToHangul(sumOfList)); 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); + writer.setValue("연월일", ymd); String instNm = (String) print.getPrintRequestUserInfo().getInfo().get("instNm"); instNm = FactionUtil.getLastWord(instNm); instNm = FactionUtil.getInstituteLeader(instNm, false); - baseFileEditor.set("발신", instNm); - - try { - InsertingImageCell.IMPL_InsertPicture(baseFile, "직인", globalVariable.get("offcsFilePath")); - } catch (Exception e) { - - throw new RuntimeException("한글 파일 출력 중 오류가 발생하였습니다."); - } + writer.setValue("발신", instNm); + + List list = IntStream.rangeClosed(1, this.data.size()).boxed().map(i -> { + DataObject one = data.get(i-1); + DataObject newObj = (DataObject) new DataObject() + .set("년도", one.string("FYR")) + .set("과세번호", one.string("GOJI_NO")) + .set("법정기일", DataFormat.yyyy_mm_dd(one.string("DUDT_YMD"))) + .set("세목", one.string("TXITM_NM")) + .set("세액", CmmnUtil.addCommaToNumber(one.string("LEVY_PCPTAX"))) + .set("가산금", CmmnUtil.addCommaToNumber(one.string("LEVY_ADAMT"))) + .set("합계", CmmnUtil.addCommaToNumber(one.string("SUM_AMT"))); + return newObj; + }).toList(); + writer.table(0, 9, 2).setValues(list); + + String tempPath = this.pathForNewFile(currentRunCount+1); + writer.write(tempPath); + resultFilesPath.add(tempPath); } - @Override - public void writeSingleDataInfo(HWPFile baseFile, HWPFile attachFile, - DataObject dataObject, Print print) { - - ClickHereEditor attachFileEditor = new ClickHereEditor(attachFile); - - attachFileEditor.set("년도", dataObject.string("FYR")); - attachFileEditor.set("과세번호", dataObject.string("GOJI_NO")); - attachFileEditor.set("법정기일", DataFormat.yyyy_mm_dd(dataObject.string("DUDT_YMD"))); - attachFileEditor.set("세목", dataObject.string("TXITM_NM")); - attachFileEditor.set("세액", CmmnUtil.addCommaToNumber(dataObject.string("LEVY_PCPTAX"))); - attachFileEditor.set("가산금", CmmnUtil.addCommaToNumber(dataObject.string("LEVY_ADAMT"))); - attachFileEditor.set("합계", CmmnUtil.addCommaToNumber(dataObject.string("SUM_AMT"))); - - } } diff --git a/src/main/java/cokr/xit/fims/cmmn/hwp/format/RequestForDelivery.java b/src/main/java/cokr/xit/fims/cmmn/hwp/format/RequestForDelivery.java index e262a3ba..9553c575 100644 --- a/src/main/java/cokr/xit/fims/cmmn/hwp/format/RequestForDelivery.java +++ b/src/main/java/cokr/xit/fims/cmmn/hwp/format/RequestForDelivery.java @@ -1,26 +1,39 @@ package cokr.xit.fims.cmmn.hwp.format; +import java.awt.Rectangle; import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.function.BiConsumer; +import java.util.stream.IntStream; import org.egovframe.rte.fdl.string.EgovStringUtil; +import cokr.xit.base.docs.hwp.HWPWriter; import cokr.xit.fims.cmmn.CmmnUtil; import cokr.xit.fims.cmmn.Print; import cokr.xit.fims.cmmn.PrintOption; -import cokr.xit.fims.cmmn.hwp.ClickHereEditor; -import cokr.xit.fims.cmmn.hwp.InsertingImageCell; +import cokr.xit.fims.cmmn.hwp.OffcsCellFinder; import cokr.xit.fims.mngt.FactionUtil; import cokr.xit.foundation.data.DataFormat; import cokr.xit.foundation.data.DataObject; import kr.dogfoot.hwplib.object.HWPFile; +import kr.dogfoot.hwplib.object.bodytext.control.table.Cell; +import kr.dogfoot.hwplib.object.bodytext.paragraph.Paragraph; /** * 교부청구서 */ public class RequestForDelivery extends HWPFormat { + public RequestForDelivery(PrintOption printOption, Print print, List dataObjectList) { + super(printOption, print, dataObjectList); + this.maxRunCount = 1; + this.formatFilePath = "template/hwp/requestForDelivery.hwp"; + this.print.setFormatKorName("교부청구서"); + this.print.setFormatName("requestForDelivery"); + } + @Override public List getDownloadDataNames() { List list = new ArrayList<>(); @@ -31,90 +44,79 @@ public class RequestForDelivery extends HWPFormat { return list; } - @Override - public void setting(Print print) { - print.setFormatName("requestForDelivery"); - print.setFormatKorName("교부청구서"); - - this.setFormatType("list"); - this.setRecordPerPartFile(7); - this.setBaseFormatFilePath("template/hwp/requestForDelivery_root.hwp"); - this.setAttachFormatFilePath("template/hwp/requestForDelivery_inner.hwp"); - } @Override - public void setting(Print print, int recordCnt) { - print.setFormatName("requestForDelivery"); - print.setFormatKorName("교부청구서"); - - this.setFormatType("list"); - this.setRecordPerPartFile(recordCnt); - - this.setBaseFormatFilePath("template/hwp/requestForDelivery_root.hwp"); - this.setAttachFormatFilePath("template/hwp/requestForDelivery_inner.hwp"); - } + public void runAsWriter() { + HWPFile hwpFile = HWPWriter.classpath(this.formatFilePath); + this.writer = new HWPWriter(hwpFile); + Map globalVariable = printOption.getGlobalVariable(); - @Override - public void writeGlobalInfo(HWPFile baseFile, List dataObjectList, - PrintOption printOption, Print print) { - - ClickHereEditor baseFileEditor = new ClickHereEditor(baseFile); + String offcsFilePath = EgovStringUtil.null2void(globalVariable.get("offcsFilePath")); + if(!offcsFilePath.equals("")) { + BiConsumer bc = writer.image().add(offcsFilePath); - Map globalVariable = print.getGlobalVariable(printOption); + Cell cell = OffcsCellFinder.find(writer); + if(cell != null) { + Paragraph para = cell.getParagraphList().getParagraph(0); + int width = (int)cell.getListHeader().getWidth(), + height = (int)cell.getListHeader().getHeight(); + bc.accept(para, new Rectangle(1, 1, width, height)); + } - baseFileEditor.set("문서번호", EgovStringUtil.null2void(globalVariable.get("docNo"))); - baseFileEditor.set("사건번호", EgovStringUtil.null2void(globalVariable.get("caseNo"))); - baseFileEditor.set("수신", EgovStringUtil.null2void(globalVariable.get("receiver"))); - baseFileEditor.set("체납자성명", EgovStringUtil.null2void(globalVariable.get("rtpyrNm"))); - baseFileEditor.set("체납자번호", EgovStringUtil.null2void(globalVariable.get("rtpyrNo"))); - baseFileEditor.set("차량번호", EgovStringUtil.null2void(globalVariable.get("vhrno"))); - baseFileEditor.set("주소", EgovStringUtil.null2void(globalVariable.get("rtpyrFullAddr"))); + } - int sumOfList = dataObjectList.stream().mapToInt(item -> item.number("SUM_AMT").intValue()).sum(); - baseFileEditor.set("합계금액", CmmnUtil.addCommaToNumber(sumOfList)); - baseFileEditor.set("교부청구금액", CmmnUtil.addCommaToNumber(sumOfList)); - baseFileEditor.set("교부청구금액한글", CmmnUtil.convertNumberToHangul(sumOfList)); + writer.setValue("문서번호", EgovStringUtil.null2void(globalVariable.get("docNo"))); + writer.setValue("사건번호", EgovStringUtil.null2void(globalVariable.get("caseNo"))); + writer.setValue("수신", EgovStringUtil.null2void(globalVariable.get("receiver"))); + writer.setValue("체납자성명", EgovStringUtil.null2void(globalVariable.get("rtpyrNm"))); + writer.setValue("체납자번호", EgovStringUtil.null2void(globalVariable.get("rtpyrNo"))); + writer.setValue("차량번호", EgovStringUtil.null2void(globalVariable.get("vhrno"))); + writer.setValue("주소", EgovStringUtil.null2void(globalVariable.get("rtpyrFullAddr"))); - baseFileEditor.set("개설은행", globalVariable.get("dtbnBankNm")); - baseFileEditor.set("계좌번호", globalVariable.get("dtbnActno")); + int sumOfList = data.stream().mapToInt(item -> item.number("SUM_AMT").intValue()).sum(); + writer.setValue("합계금액", CmmnUtil.addCommaToNumber(sumOfList)); + writer.setValue("교부청구금액", CmmnUtil.addCommaToNumber(sumOfList)); + writer.setValue("교부청구금액한글", CmmnUtil.convertNumberToHangul(sumOfList)); + writer.setValue("개설은행", EgovStringUtil.null2void(globalVariable.get("dtbnBankNm"))); + writer.setValue("계좌번호", EgovStringUtil.null2void(globalVariable.get("dtbnActno"))); String instNm = (String) print.getPrintRequestUserInfo().getInfo().get("instNm"); String deptNm = (String) print.getPrintRequestUserInfo().getInfo().get("deptNm"); - baseFileEditor.set("예금주", instNm + " " + deptNm); + writer.setValue("예금주", instNm + " " + deptNm); 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); + writer.setValue("연월일", ymd); instNm = FactionUtil.getLastWord(instNm); instNm = FactionUtil.getInstituteLeader(instNm, false); - baseFileEditor.set("발신", instNm); + writer.setValue("발신", instNm); + + List list = IntStream.rangeClosed(1, this.data.size()).boxed().map(i -> { + DataObject one = data.get(i-1); + DataObject newObj = (DataObject) new DataObject() + .set("징수과목", one.string("TXITM_NM")) + .set("고지번호", one.string("GOJI_NO")) + .set("과태료계", CmmnUtil.addCommaToNumber(one.string("SUM_AMT"))) + .set("법정기일", DataFormat.yyyy_mm_dd(one.string("DUDT_YMD"))) + ; + return newObj; + }).toList(); + writer.table(0, 9, 1).setValues(list); + + String tempPath = this.pathForNewFile(currentRunCount+1); + writer.write(tempPath); + resultFilesPath.add(tempPath); - try { - InsertingImageCell.IMPL_InsertPicture(baseFile, "직인", globalVariable.get("offcsFilePath")); - } catch (Exception e) { - throw new RuntimeException("한글 파일 출력 중 오류가 발생하였습니다."); - } } - @Override - public void writeSingleDataInfo(HWPFile baseFile, HWPFile attachFile, - DataObject dataObject, Print print) { - - ClickHereEditor attachFileEditor = new ClickHereEditor(attachFile); - - attachFileEditor.set("징수과목", dataObject.string("TXITM_NM")); - attachFileEditor.set("고지번호", dataObject.string("GOJI_NO")); - attachFileEditor.set("과태료계", CmmnUtil.addCommaToNumber(dataObject.string("SUM_AMT"))); - attachFileEditor.set("법정기일", DataFormat.yyyy_mm_dd(dataObject.string("DUDT_YMD"))); - } } diff --git a/src/main/java/cokr/xit/fims/cmmn/hwp/format/SvbtcList.java b/src/main/java/cokr/xit/fims/cmmn/hwp/format/SvbtcList.java index e06a9249..0a5d7a57 100644 --- a/src/main/java/cokr/xit/fims/cmmn/hwp/format/SvbtcList.java +++ b/src/main/java/cokr/xit/fims/cmmn/hwp/format/SvbtcList.java @@ -1,17 +1,32 @@ package cokr.xit.fims.cmmn.hwp.format; +import java.awt.Rectangle; import java.util.ArrayList; import java.util.List; +import java.util.function.BiConsumer; +import java.util.stream.IntStream; +import org.egovframe.rte.fdl.string.EgovStringUtil; + +import cokr.xit.base.docs.hwp.HWPWriter; import cokr.xit.fims.cmmn.Print; import cokr.xit.fims.cmmn.PrintOption; -import cokr.xit.fims.cmmn.hwp.ClickHereEditor; -import cokr.xit.fims.cmmn.hwp.InsertingImageCell; +import cokr.xit.fims.cmmn.hwp.OffcsCellFinder; import cokr.xit.foundation.data.DataObject; import kr.dogfoot.hwplib.object.HWPFile; +import kr.dogfoot.hwplib.object.bodytext.control.table.Cell; +import kr.dogfoot.hwplib.object.bodytext.paragraph.Paragraph; public class SvbtcList extends HWPFormat { + public SvbtcList(PrintOption printOption, Print print, List dataObjectList) { + super(printOption, print, dataObjectList); + this.maxRunCount = 1; + this.formatFilePath = "template/hwp/svbtcList.hwp"; + this.print.setFormatKorName("공시송달"); + this.print.setFormatName("svbtc"); + } + @Override public List getDownloadDataNames() { List list = new ArrayList<>(); @@ -25,67 +40,52 @@ public class SvbtcList extends HWPFormat { return list; } - @Override - public void setting(Print print) { - print.setFormatName("svbtc"); - print.setFormatKorName("공시송달"); - - this.setFormatType("list"); - this.setRecordPerPartFile(9); - - this.setBaseFormatFilePath("template/hwp/svbtcList_root.hwp"); - this.setAttachFormatFilePath("template/hwp/svbtcList_inner.hwp"); - } - - - @Override - public void setting(Print print, int recordCnt) { - print.setFormatName("svbtc"); - print.setFormatKorName("공시송달"); - - this.setFormatType("list"); - this.setRecordPerPartFile(recordCnt); - - this.setBaseFormatFilePath("template/hwp/svbtcList_root.hwp"); - this.setAttachFormatFilePath("template/hwp/svbtcList_inner.hwp"); - } - @Override - public void writeGlobalInfo(HWPFile baseFile, List dataObjectList, PrintOption printOption, Print print) { - // - ClickHereEditor baseFileEditor = new ClickHereEditor(baseFile); - - baseFileEditor.set("문서번호", dataObjectList.get(0).string("INPUT_DOC_NO")); - baseFileEditor.set("제목", dataObjectList.get(0).string("INPUT_TTL_NM")); - baseFileEditor.set("공고기간", dataObjectList.get(0).string("INPUT_SVBTC_DATE")); - baseFileEditor.set("기관장", dataObjectList.get(0).string("INST_LEADER")); - baseFileEditor.set("부서명", dataObjectList.get(0).string("SGG_DEPT_NM")); - baseFileEditor.set("부서전화번호", "☎" + dataObjectList.get(0).string("DEPT_TELNO")); - - try { - if (!dataObjectList.get(0).string("OFFCS_FILE_PATH").equals("")) { - InsertingImageCell.IMPL_InsertPicture(baseFile, "직인", dataObjectList.get(0).string("OFFCS_FILE_PATH")); + public void runAsWriter() { + HWPFile hwpFile = HWPWriter.classpath(this.formatFilePath); + this.writer = new HWPWriter(hwpFile); + + String offcsFilePath = EgovStringUtil.null2void(data.get(0).string("OFFCS_FILE_PATH")); + if(!offcsFilePath.equals("")) { + BiConsumer bc = writer.image().add(offcsFilePath); + + Cell cell = OffcsCellFinder.find(writer); + if(cell != null) { + Paragraph para = cell.getParagraphList().getParagraph(0); + int width = (int)cell.getListHeader().getWidth(), + height = (int)cell.getListHeader().getHeight(); + bc.accept(para, new Rectangle(1, 1, width, height)); } - } catch(Exception e) { - - throw new RuntimeException("한글 파일 출력 중 오류가 발생하였습니다."); } + + writer.setValue("문서번호", data.get(0).string("INPUT_DOC_NO")); + writer.setValue("제목", data.get(0).string("INPUT_TTL_NM")); + writer.setValue("공고기간", data.get(0).string("INPUT_SVBTC_DATE")); + writer.setValue("기관장", data.get(0).string("INST_LEADER")); + writer.setValue("부서명", data.get(0).string("SGG_DEPT_NM")); + writer.setValue("부서전화번호", "☎" + data.get(0).string("DEPT_TELNO")); + + + List list = IntStream.rangeClosed(1, this.data.size()).boxed().map(i -> { + DataObject one = data.get(i-1); + return (DataObject) new DataObject() + .set("성명", one.string("RCPN_NM_MASK")) + .set("주소", one.string("WHOL_ADDR_MASK")) + .set("차량번호", one.string("VHRNO_MASK")) + .set("위반장소", one.string("CRDN_PLC")) + .set("위반일자", one.string("CRDN_DT")) + .set("반송일자", one.string("DLVR_YMD_MASK")) + .set("반송사유", one.string("UNDLVR_RSN_NM")) + ; + }).toList(); + writer.table(2, 2, 2).setValues(list); + + String tempPath = this.pathForNewFile(currentRunCount+1); + writer.write(tempPath); + resultFilesPath.add(tempPath); } - @Override - public void writeSingleDataInfo(HWPFile baseFile, HWPFile attachFile, DataObject dataObject, Print print) { - // - ClickHereEditor attachFileEditor = new ClickHereEditor(attachFile); - - attachFileEditor.set("성명", dataObject.string("RCPN_NM_MASK")); - attachFileEditor.set("주소", dataObject.string("WHOL_ADDR_MASK")); - attachFileEditor.set("차량번호", dataObject.string("VHRNO_MASK")); - attachFileEditor.set("위반장소", dataObject.string("CRDN_PLC")); - attachFileEditor.set("위반일자", dataObject.string("CRDN_DT")); - attachFileEditor.set("반송일자", dataObject.string("DLVR_YMD_MASK")); - attachFileEditor.set("반송사유", dataObject.string("UNDLVR_RSN_NM")); - } } diff --git a/src/main/java/cokr/xit/fims/cmmn/CellDecorator.java b/src/main/java/cokr/xit/fims/cmmn/xls/CellDecorator.java similarity index 94% rename from src/main/java/cokr/xit/fims/cmmn/CellDecorator.java rename to src/main/java/cokr/xit/fims/cmmn/xls/CellDecorator.java index 614a9c5c..83151bfb 100644 --- a/src/main/java/cokr/xit/fims/cmmn/CellDecorator.java +++ b/src/main/java/cokr/xit/fims/cmmn/xls/CellDecorator.java @@ -1,4 +1,4 @@ -package cokr.xit.fims.cmmn; +package cokr.xit.fims.cmmn.xls; import java.util.Map; import java.util.function.Function; diff --git a/src/main/java/cokr/xit/fims/crdn/web/Crdn06Controller.java b/src/main/java/cokr/xit/fims/crdn/web/Crdn06Controller.java index ffbb0fda..9fcacf15 100644 --- a/src/main/java/cokr/xit/fims/crdn/web/Crdn06Controller.java +++ b/src/main/java/cokr/xit/fims/crdn/web/Crdn06Controller.java @@ -21,9 +21,9 @@ import cokr.xit.base.file.xls.XLSWriter.Styler; import cokr.xit.base.user.ManagedUser; import cokr.xit.base.user.dao.UserMapper; import cokr.xit.base.web.ApplicationController; -import cokr.xit.fims.cmmn.CellDecorator; import cokr.xit.fims.cmmn.CmmnUtil; import cokr.xit.fims.cmmn.service.bean.StngBean; +import cokr.xit.fims.cmmn.xls.CellDecorator; import cokr.xit.fims.crdn.Crdn; import cokr.xit.fims.crdn.CrdnQuery; import cokr.xit.fims.crdn.dao.CrdnStngMapper; diff --git a/src/main/java/cokr/xit/fims/cvlc/web/Cvlc01Controller.java b/src/main/java/cokr/xit/fims/cvlc/web/Cvlc01Controller.java index fd47728f..b72296d5 100644 --- a/src/main/java/cokr/xit/fims/cvlc/web/Cvlc01Controller.java +++ b/src/main/java/cokr/xit/fims/cvlc/web/Cvlc01Controller.java @@ -17,7 +17,6 @@ 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; @@ -224,10 +223,20 @@ public class Cvlc01Controller extends ApplicationController { @Task @RequestMapping(name="민원내역 원본 한글 파일 생성", value=METHOD_URL.makeFileFromHwpFormat) public ModelAndView makeFileFromHwpFormat(CrdnQuery query) { - ModelAndView mav = new ModelAndView("downloadView"); + + PrintOption printOption = new PrintOption(); + + UserInfo userInfo = currentUser(); + factionBean.initUserInfo(userInfo); + Print print = new Print(); + print.setPrintRequestUserInfo(userInfo); + + + DataObject dataObject = crdnCvlcptMainBean.getCivilComplaintOriginalInfo(query); List dataObjectList = new ArrayList(); dataObjectList.add(dataObject); + String linkTblNm = dataObject.string("LINK_TBL_NM"); if(!(ifEmpty(linkTblNm, () -> "").equals(""))) { FileQuery fileQuery = new FileQuery(); @@ -259,20 +268,11 @@ public class Cvlc01Controller extends ApplicationController { } } + CvlcptOrgn hwpFormat = new CvlcptOrgn(printOption, print, dataObjectList); + HashMap result = hwpFormat.makeFile(); - HWPWriter hwpWriter = new HWPWriter(); - PrintOption printOption = new PrintOption(); - UserInfo userInfo = currentUser(); - factionBean.initUserInfo(userInfo); - Print print = new Print(); - print.setPrintRequestUserInfo(userInfo); - hwpWriter.setPrint(print); - hwpWriter.setFormat(new CvlcptOrgn()); - Map result = hwpWriter.makeFileFromHwpFormat("info", printOption, dataObjectList); - + ModelAndView mav = new ModelAndView("downloadView"); mav.addAllObjects(result); - mav.addObject("downloadData", dataObjectList); - mav.addObject("dataNames", hwpWriter.getFormat().getDownloadDataNames()); return mav; } diff --git a/src/main/java/cokr/xit/fims/cvlc/web/Cvlc02Controller.java b/src/main/java/cokr/xit/fims/cvlc/web/Cvlc02Controller.java index 9ec4f266..ecb658d4 100644 --- a/src/main/java/cokr/xit/fims/cvlc/web/Cvlc02Controller.java +++ b/src/main/java/cokr/xit/fims/cvlc/web/Cvlc02Controller.java @@ -22,9 +22,9 @@ import cokr.xit.base.file.xls.XLSWriter.Styler; import cokr.xit.base.user.ManagedUser; import cokr.xit.base.user.dao.UserMapper; import cokr.xit.base.web.ApplicationController; -import cokr.xit.fims.cmmn.CellDecorator; import cokr.xit.fims.cmmn.CmmnUtil; import cokr.xit.fims.cmmn.service.bean.StngBean; +import cokr.xit.fims.cmmn.xls.CellDecorator; import cokr.xit.fims.crdn.Crdn; import cokr.xit.fims.crdn.CrdnQuery; import cokr.xit.fims.crdn.service.CrdnService; diff --git a/src/main/java/cokr/xit/fims/excl/web/Excl02Controller.java b/src/main/java/cokr/xit/fims/excl/web/Excl02Controller.java index 399434dc..b78b155d 100644 --- a/src/main/java/cokr/xit/fims/excl/web/Excl02Controller.java +++ b/src/main/java/cokr/xit/fims/excl/web/Excl02Controller.java @@ -16,7 +16,6 @@ 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; @@ -371,22 +370,20 @@ public class Excl02Controller extends ApplicationController { @RequestMapping(name="의견제출 심의의결서 출력", value=METHOD_URL.makeDlbrDecsnFileFromHwpFormat) 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.setPrint(print); - hwpWriter.setFormat(new DlbrDecsnList()); + + PrintOption printOption = new PrintOption(); List dataObjectList = opnnSbmsnBean.getOpnnSbmsnDlbrDecsns(req); - Map result = hwpWriter.makeFileFromHwpFormat("info", printOption, dataObjectList); - ModelAndView mav = new ModelAndView("downloadView"); + DlbrDecsnList hwpFormat = new DlbrDecsnList(printOption, print, dataObjectList); + HashMap result = hwpFormat.makeFile(); + ModelAndView mav = new ModelAndView("downloadView"); mav.addAllObjects(result); - mav.addObject("downloadData", dataObjectList); - mav.addObject("dataNames", hwpWriter.getFormat().getDownloadDataNames()); + return mav; } diff --git a/src/main/java/cokr/xit/fims/sndb/web/Sndb01Controller.java b/src/main/java/cokr/xit/fims/sndb/web/Sndb01Controller.java index 293a2680..3fbab4d1 100644 --- a/src/main/java/cokr/xit/fims/sndb/web/Sndb01Controller.java +++ b/src/main/java/cokr/xit/fims/sndb/web/Sndb01Controller.java @@ -15,7 +15,6 @@ import org.springframework.web.servlet.ModelAndView; import cokr.xit.base.code.CommonCode; import cokr.xit.base.file.etc.OutsourcingFileWriter; -import cokr.xit.base.file.hwp.HWPWriter; import cokr.xit.base.file.pdf.PDFWriter; import cokr.xit.base.file.service.FileQuery; import cokr.xit.base.file.service.bean.FileBean; @@ -31,6 +30,7 @@ import cokr.xit.fims.cmmn.OutsourcingStngQuery; import cokr.xit.fims.cmmn.Print; import cokr.xit.fims.cmmn.PrintOption; import cokr.xit.fims.cmmn.dao.OtptStngMapper; +import cokr.xit.fims.cmmn.hwp.format.SvbtcList; import cokr.xit.fims.cmmn.pdf.print.format.Advntce; import cokr.xit.fims.cmmn.service.bean.OutsourcingStngBean; import cokr.xit.fims.cmmn.service.bean.StngBean; @@ -1563,30 +1563,24 @@ public class Sndb01Controller extends ApplicationController { @Task @RequestMapping(name="공시송달 한글 저장", value=METHOD_URL.makeSvbtcFileFromHwpFormat) public ModelAndView makeSvbtcFileFromHwpFormat(SndbQuery req) { - Map result = null; - HWPWriter hwpWriter = new HWPWriter(); - PrintOption printOption = new PrintOption(); + UserInfo userInfo = currentUser(); factionBean.initUserInfo(userInfo); + Print print = new Print(); + print.setPrintRequestUserInfo(userInfo); + + PrintOption printOption = new PrintOption(); req.setSggCd((String)userInfo.getInfo().get("sggCd")); req.setDeptCd((String)userInfo.getInfo().get("deptCd")); req.setOrderBy("SV.SVBTC_ID, SD.SNDNG_DTL_ID"); - List dataObjectList = svbtcBean.getSvbtcPrint(req); - Print print = new Print(); - print.setPrintRequestUserInfo(userInfo); - hwpWriter.setPrint(print); - - result = hwpWriter.makeFileFromHwpFormat("list", printOption, dataObjectList); - - ModelAndView mav = new ModelAndView("jsonView"); - + SvbtcList hwpFormat = new SvbtcList(printOption, print, dataObjectList); + HashMap result = hwpFormat.makeFile(); + ModelAndView mav = new ModelAndView("downloadView"); mav.addAllObjects(result); - mav.addObject("downloadData", dataObjectList); - mav.addObject("dataNames", hwpWriter.getFormat().getDownloadDataNames()); return mav; } diff --git a/src/main/java/cokr/xit/fims/sprt/web/Sprt01Controller.java b/src/main/java/cokr/xit/fims/sprt/web/Sprt01Controller.java index 844c5a41..a8e1847b 100644 --- a/src/main/java/cokr/xit/fims/sprt/web/Sprt01Controller.java +++ b/src/main/java/cokr/xit/fims/sprt/web/Sprt01Controller.java @@ -20,7 +20,6 @@ import com.fasterxml.jackson.core.type.TypeReference; import cokr.xit.base.code.CommonCode; import cokr.xit.base.file.etc.OutsourcingFileWriter; -import cokr.xit.base.file.hwp.HWPWriter; import cokr.xit.base.file.pdf.PDFWriter; import cokr.xit.base.file.service.FileQuery; import cokr.xit.base.file.service.bean.FileBean; @@ -460,26 +459,24 @@ public class Sprt01Controller extends ApplicationController { */ @RequestMapping(name="단속 내역서 한글 파일 생성", value=METHOD_URL.makeCrdnListFileFromHwpFormat) public ModelAndView makeCrdnListFileFromHwpFormat(String privateInfoYn, String... crdnIds) { + PrintOption printOption = new PrintOption(); printOption.setPrivateInfoYn(privateInfoYn); - - CrdnQuery query = new CrdnQuery(); - query.setCrdnIds(crdnIds); - List dataObjectList = crdnListMapper.selectCrackdownList(query); - HWPWriter hwpWriter = new HWPWriter(); UserInfo userInfo = currentUser(); factionBean.initUserInfo(userInfo); Print print = new Print(); print.setPrintRequestUserInfo(userInfo); - hwpWriter.setPrint(print); - hwpWriter.setFormat(new CrdnList()); - Map result = hwpWriter.makeFileFromHwpFormat("list", printOption, dataObjectList); + CrdnQuery query = new CrdnQuery(); + query.setCrdnIds(crdnIds); + List dataObjectList = crdnListMapper.selectCrackdownList(query); + + + CrdnList hwpFormat = new CrdnList(printOption, print, dataObjectList); + HashMap result = hwpFormat.makeFile(); ModelAndView mav = new ModelAndView("downloadView"); mav.addAllObjects(result); - mav.addObject("downloadData", dataObjectList); - mav.addObject("dataNames", hwpWriter.getFormat().getDownloadDataNames()); return mav; } @@ -491,6 +488,11 @@ public class Sprt01Controller extends ApplicationController { PrintOption printOption = new PrintOption(); + UserInfo userInfo = currentUser(); + factionBean.initUserInfo(userInfo); + Print print = new Print(); + print.setPrintRequestUserInfo(userInfo); + CrdnQuery query = new CrdnQuery(); query.setCrdnIds(crdnIds); List dataObjectList = crdnListMapper.selectCrackdownList(query); @@ -514,21 +516,13 @@ public class Sprt01Controller extends ApplicationController { } } - HWPWriter hwpWriter = new HWPWriter(); - UserInfo userInfo = currentUser(); - factionBean.initUserInfo(userInfo); - Print print = new Print(); - print.setPrintRequestUserInfo(userInfo); - hwpWriter.setPrint(print); - - hwpWriter.setFormat(new CrdnConfirm()); - Map result = hwpWriter.makeFileFromHwpFormat("info", printOption, dataObjectList); + CrdnConfirm hwpFormat = new CrdnConfirm(printOption, print, dataObjectList); + HashMap result = hwpFormat.makeFile(); ModelAndView mav = new ModelAndView("downloadView"); mav.addAllObjects(result); - mav.addObject("downloadData", dataObjectList); - mav.addObject("dataNames", hwpWriter.getFormat().getDownloadDataNames()); + return mav; } @@ -550,7 +544,9 @@ public class Sprt01Controller extends ApplicationController { */ @RequestMapping(name="교부청구서 한글 파일 생성", value=METHOD_URL.makeRequestForDeliveryFileFromHwpFormat) public ModelAndView makeRequestForDeliveryFileFromHwpFormat(PrintOption printOption, String globalVariableInfo, String... crdnIds) { - ModelAndView mav = new ModelAndView("downloadView"); + + DataObject sggStngInfo = stngBean.getStng("sgg"); + DataObject deptStngInfo = stngBean.getStng("dept"); Map globalVariable = new HashMap(); @@ -563,33 +559,26 @@ public class Sprt01Controller extends ApplicationController { globalVariable.put("rtpyrNo", dataObject.string("rtpyrNo")); globalVariable.put("vhrno", dataObject.string("vhrno")); globalVariable.put("rtpyrFullAddr", dataObject.string("rtpyrFullAddr")); - + 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); - SprtQuery sprtQuery = new SprtQuery(); - sprtQuery.setCrdnIds(crdnIds); - List dataObjectList = integrationSearchMapper.selectIntegrationDataList(sprtQuery); - - HWPWriter hwpWriter = new HWPWriter(); UserInfo userInfo = currentUser(); factionBean.initUserInfo(userInfo); Print print = new Print(); print.setPrintRequestUserInfo(userInfo); - hwpWriter.setPrint(print); - DataObject sggStngInfo = stngBean.getStng("sgg"); - DataObject deptStngInfo = stngBean.getStng("dept"); - Map 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 result = hwpWriter.makeFileFromHwpFormat("list", printOption, dataObjectList); + SprtQuery sprtQuery = new SprtQuery(); + sprtQuery.setCrdnIds(crdnIds); + List dataObjectList = integrationSearchMapper.selectIntegrationDataList(sprtQuery); + + + RequestForDelivery hwpFormat = new RequestForDelivery(printOption, print, dataObjectList); + HashMap result = hwpFormat.makeFile(); + ModelAndView mav = new ModelAndView("downloadView"); mav.addAllObjects(result); - mav.addObject("downloadData", dataObjectList); - mav.addObject("dataNames", hwpWriter.getFormat().getDownloadDataNames()); + return mav; } @@ -598,11 +587,16 @@ public class Sprt01Controller extends ApplicationController { */ @RequestMapping(name="채권신고서 한글 파일 생성", value=METHOD_URL.makeReportOnClaimsFileFromHwpFormat) public ModelAndView makeReportOnClaimsFileFromHwpFormat(PrintOption printOption, String globalVariableInfo, String... crdnIds) { - ModelAndView mav = new ModelAndView("downloadView"); + DataObject sggStngInfo = stngBean.getStng("sgg"); + DataObject deptStngInfo = stngBean.getStng("dept"); + + UserInfo userInfo = currentUser(); + factionBean.initUserInfo(userInfo); + Print print = new Print(); + print.setPrintRequestUserInfo(userInfo); Map globalVariable = new HashMap(); - System.out.println(globalVariableInfo); DataObject dataObject = fromJson(globalVariableInfo, DataObject.class); globalVariable.put("caseNo", dataObject.string("caseNo")); @@ -610,6 +604,12 @@ public class Sprt01Controller extends ApplicationController { globalVariable.put("rtpyrNo", dataObject.string("rtpyrNo")); globalVariable.put("rtpyrFullAddr", dataObject.string("rtpyrFullAddr")); + String deptNm = (String) print.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); SprtQuery sprtQuery = new SprtQuery(); @@ -617,30 +617,10 @@ public class Sprt01Controller extends ApplicationController { List dataObjectList = integrationSearchMapper.selectIntegrationDataList(sprtQuery); - HWPWriter hwpWriter = new HWPWriter(); - UserInfo userInfo = currentUser(); - factionBean.initUserInfo(userInfo); - Print print = new Print(); - print.setPrintRequestUserInfo(userInfo); - hwpWriter.setPrint(print); - - DataObject sggStngInfo = stngBean.getStng("sgg"); - DataObject deptStngInfo = stngBean.getStng("dept"); - Map globalVariable2 = printOption.getGlobalVariable(); - String deptNm = (String) print.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 result = hwpWriter.makeFileFromHwpFormat("list", printOption, dataObjectList); - + ReportOnClaims hwpFormat = new ReportOnClaims(printOption, print, dataObjectList); + HashMap result = hwpFormat.makeFile(); + ModelAndView mav = new ModelAndView("downloadView"); mav.addAllObjects(result); - mav.addObject("downloadData", dataObjectList); - mav.addObject("dataNames", hwpWriter.getFormat().getDownloadDataNames()); return mav; } @@ -649,7 +629,11 @@ public class Sprt01Controller extends ApplicationController { */ @RequestMapping(name="납부확인서 한글 파일 생성", value=METHOD_URL.makeRcvmtConfirmFileFromHwpFormat) public ModelAndView makeRcvmtConfirmFileFromHwpFormat(String... crdnIds) { - ModelAndView mav = new ModelAndView("downloadView"); + + UserInfo userInfo = currentUser(); + factionBean.initUserInfo(userInfo); + Print print = new Print(); + print.setPrintRequestUserInfo(userInfo); PrintOption printOption = new PrintOption(); printOption.setGlobalVariable(new HashMap()); @@ -658,18 +642,11 @@ public class Sprt01Controller extends ApplicationController { sprtQuery.setCrdnIds(crdnIds); List dataObjectList = integrationSearchMapper.selectIntegrationDataList(sprtQuery); - HWPWriter hwpWriter = new HWPWriter(); - UserInfo userInfo = currentUser(); - factionBean.initUserInfo(userInfo); - Print print = new Print(); - print.setPrintRequestUserInfo(userInfo); - hwpWriter.setPrint(print); - - hwpWriter.setFormat(new RcvmtConfirm()); - Map result = hwpWriter.makeFileFromHwpFormat("info", printOption, dataObjectList); + RcvmtConfirm hwpFormat = new RcvmtConfirm(printOption, print, dataObjectList); + HashMap result = hwpFormat.makeFile(); + ModelAndView mav = new ModelAndView("downloadView"); mav.addAllObjects(result); - mav.addObject("downloadData", dataObjectList); - mav.addObject("dataNames", hwpWriter.getFormat().getDownloadDataNames()); + return mav; } diff --git a/src/main/resources/template/hwp/crdnConfirm.hwp b/src/main/resources/template/hwp/crdnConfirm.hwp index 0f7056c9..d6fcfca6 100644 Binary files a/src/main/resources/template/hwp/crdnConfirm.hwp and b/src/main/resources/template/hwp/crdnConfirm.hwp differ diff --git a/src/main/resources/template/hwp/crdnList.hwp b/src/main/resources/template/hwp/crdnList.hwp new file mode 100644 index 00000000..ddacb1ea Binary files /dev/null and b/src/main/resources/template/hwp/crdnList.hwp differ diff --git a/src/main/resources/template/hwp/crdnList_inner.hwp b/src/main/resources/template/hwp/crdnList_inner.hwp deleted file mode 100644 index f0f7c432..00000000 Binary files a/src/main/resources/template/hwp/crdnList_inner.hwp and /dev/null differ diff --git a/src/main/resources/template/hwp/crdnList_root.hwp b/src/main/resources/template/hwp/crdnList_root.hwp deleted file mode 100644 index bbeb63fa..00000000 Binary files a/src/main/resources/template/hwp/crdnList_root.hwp and /dev/null differ diff --git a/src/main/resources/template/hwp/rcvmtConfirm.hwp b/src/main/resources/template/hwp/rcvmtConfirm.hwp index 10e181f7..5f0da303 100644 Binary files a/src/main/resources/template/hwp/rcvmtConfirm.hwp and b/src/main/resources/template/hwp/rcvmtConfirm.hwp differ diff --git a/src/main/resources/template/hwp/reportOnClaims.hwp b/src/main/resources/template/hwp/reportOnClaims.hwp new file mode 100644 index 00000000..adaee47a Binary files /dev/null and b/src/main/resources/template/hwp/reportOnClaims.hwp differ diff --git a/src/main/resources/template/hwp/reportOnClaims_inner.hwp b/src/main/resources/template/hwp/reportOnClaims_inner.hwp deleted file mode 100644 index 59bc6a66..00000000 Binary files a/src/main/resources/template/hwp/reportOnClaims_inner.hwp and /dev/null differ diff --git a/src/main/resources/template/hwp/reportOnClaims_root.hwp b/src/main/resources/template/hwp/reportOnClaims_root.hwp deleted file mode 100644 index 61fa6e8b..00000000 Binary files a/src/main/resources/template/hwp/reportOnClaims_root.hwp and /dev/null differ diff --git a/src/main/resources/template/hwp/requestForDelivery.hwp b/src/main/resources/template/hwp/requestForDelivery.hwp new file mode 100644 index 00000000..fb7f3a76 Binary files /dev/null and b/src/main/resources/template/hwp/requestForDelivery.hwp differ diff --git a/src/main/resources/template/hwp/requestForDelivery_inner.hwp b/src/main/resources/template/hwp/requestForDelivery_inner.hwp deleted file mode 100644 index 48754ea7..00000000 Binary files a/src/main/resources/template/hwp/requestForDelivery_inner.hwp and /dev/null differ diff --git a/src/main/resources/template/hwp/requestForDelivery_root.hwp b/src/main/resources/template/hwp/requestForDelivery_root.hwp deleted file mode 100644 index 424be877..00000000 Binary files a/src/main/resources/template/hwp/requestForDelivery_root.hwp and /dev/null differ diff --git a/src/main/resources/template/hwp/svbtcList.hwp b/src/main/resources/template/hwp/svbtcList.hwp new file mode 100644 index 00000000..8a40b65a Binary files /dev/null and b/src/main/resources/template/hwp/svbtcList.hwp differ diff --git a/src/main/resources/template/hwp/svbtcList_root.hwp b/src/main/resources/template/hwp/svbtcList_root.hwp deleted file mode 100644 index a67e5cb4..00000000 Binary files a/src/main/resources/template/hwp/svbtcList_root.hwp and /dev/null differ diff --git a/src/main/webapp/WEB-INF/jsp/fims/sndb/sndb01240-main.jsp b/src/main/webapp/WEB-INF/jsp/fims/sndb/sndb01240-main.jsp index 64867f45..27b46a74 100644 --- a/src/main/webapp/WEB-INF/jsp/fims/sndb/sndb01240-main.jsp +++ b/src/main/webapp/WEB-INF/jsp/fims/sndb/sndb01240-main.jsp @@ -447,22 +447,13 @@ params.printTtlNm = obj.ttlNm; // 제목 params.printSvbtcDate = obj.textDate; // 공고 기한 - ajax.get({ - url : wctx.url("/" + params.taskSeCd + $P.PrefixUrl + "/240/makeSvbtcHwp.do") - , data : params || {} - , success : resp => { - if (resp.filePath != null && resp.filePath != "") { - let a = document.createElement("a"); + + let url = wctx.url("/" + params.taskSeCd + $P.PrefixUrl + "/240/makeSvbtcHwp.do"); - a.href = resp.filePath; - a.download = resp.fileName; + let parameter = toQuery(params); - document.getElementById("tempArea--${pageName}").appendChild(a); - a.click(); - document.getElementById("tempArea--${pageName}").removeChild(a); - } - } - }); + document.location.href = url + "?" + parameter; + } // 공시송달 수정 diff --git a/src/main/webapp/WEB-INF/jsp/fims/sndb/sndb01250-info.jsp b/src/main/webapp/WEB-INF/jsp/fims/sndb/sndb01250-info.jsp index 75ca3f20..62beffa1 100644 --- a/src/main/webapp/WEB-INF/jsp/fims/sndb/sndb01250-info.jsp +++ b/src/main/webapp/WEB-INF/jsp/fims/sndb/sndb01250-info.jsp @@ -337,6 +337,8 @@ // 한글파일 출력 $P.callbackDocNoTtl = (obj) => { + let selected = $P.control.dataset.getKeys("selected"); + // 서버에 전송할 data(파라미터) 생성 let params = { sggCd : $P.control.dataset.getValue("SGG_CD") // 시군구 코드 @@ -349,26 +351,19 @@ params.printTtlNm = obj.ttlNm; // 제목 params.printSvbtcDate = obj.textDate; // 공고 기한 - ajax.get({ - url : wctx.url("/" + params.taskSeCd + $P.PrefixUrl + "/240/makeSvbtcHwp.do") - , data : params || {} - , success : resp => { - if (resp.filePath != null && resp.filePath != "") { - let a = document.createElement("a"); + + let url = wctx.url("/" + params.taskSeCd + $P.PrefixUrl + "/240/makeSvbtcHwp.do"); - a.href = resp.filePath; - a.download = resp.fileName; + let parameter = toQuery(params); - document.getElementById("tempArea--${pageName}").appendChild(a); - a.click(); - document.getElementById("tempArea--${pageName}").removeChild(a); - } - } - }); + document.location.href = url + "?" + parameter; + } // 삭제 사유 callback $P.callbackRsn = (obj) => { + let selected = $P.control.dataset.getKeys("selected"); + // 서버에 전송할 data(파라미터) 생성 let params = {}; params.sndngDtlIds = selected.join(","); // 발송 상세 IDs