diff --git a/src/main/java/cokr/xit/fims/cmmn/CmmnUtil.java b/src/main/java/cokr/xit/fims/cmmn/CmmnUtil.java index c3c257b9..b9f4e370 100644 --- a/src/main/java/cokr/xit/fims/cmmn/CmmnUtil.java +++ b/src/main/java/cokr/xit/fims/cmmn/CmmnUtil.java @@ -5,6 +5,7 @@ import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; +import java.text.DecimalFormat; import java.text.SimpleDateFormat; import java.time.DayOfWeek; import java.time.LocalDate; @@ -35,11 +36,21 @@ public class CmmnUtil { return str; } + /** + * 문자열 안의 모든 문자가 숫자인지 테스트한다. + * @param 문자열 + * @return boolean + */ public static boolean isNumeric(String str) { String REGEXP_PATTERN_NUMBER = "^[\\d]*$"; return Pattern.matches(REGEXP_PATTERN_NUMBER, str); } + /** + * 문자열 안의 모든 문자가 한글인지 테스트한다. + * @param 문자열 + * @return boolean + */ public static boolean isKorean(String str) { String REGEXP_PATTERN_KOR = "^[가-힣]*$"; return Pattern.matches(REGEXP_PATTERN_KOR, str); @@ -234,6 +245,11 @@ public class CmmnUtil { return yyyyMMddFormat.format(cal.getTime()); } + /** + * 날짜형 문자열 입력받아 요일을 한글 문자 하나로 반환한다. + * @param dateStr 날짜 + * @return 요일 + */ public static String getDayOfWeek(String dateStr) { int y = Integer.parseInt(dateStr.substring(0,4)); int m = Integer.parseInt(dateStr.substring(4,6)); @@ -243,4 +259,32 @@ public class CmmnUtil { String dow = dayOfWeek.getDisplayName(TextStyle.SHORT, Locale.KOREAN); return dow; } + + /**'-'와 ':'로 구분된 날짜(yyyy-MM-dd hh:mm:ss)를 반환한다. + * @param dateStr '-',':'이 없는 날짜 + * @return '-'와 ':'로로 구분된 날짜 + */ + public static String yyyy_mm_dd_hh_mm_ss(String dateStr) { + if (dateStr == null || dateStr.equals("")) return ""; + + return dateStr.substring(0, 4) + "-" + dateStr.substring(4, 6) + "-" + dateStr.substring(6, 8) + + " " + dateStr.substring(8, 10) + ":" + dateStr.substring(10, 12) + ":" + dateStr.substring(12, 14); + } + + /** 숫자형 문자열에 세자리 마다 콤마를 찍어 반환한다. + * @param str 숫자형 문자열 + * @return 콤마가 표시된 숫자형 문자열 + */ + public static String addCommaToNumber(String str) { + if (str == null || str.equals("")) return ""; + + int number = Integer.parseInt(str); + DecimalFormat decFormat = new DecimalFormat("###,###"); + return decFormat.format(number); + } + + public static String addCommaToNumber(int number) { + DecimalFormat decFormat = new DecimalFormat("###,###"); + return decFormat.format(number); + } } diff --git a/src/main/java/cokr/xit/fims/cmmn/FactionUtil.java b/src/main/java/cokr/xit/fims/cmmn/FactionUtil.java new file mode 100644 index 00000000..5ac3e38f --- /dev/null +++ b/src/main/java/cokr/xit/fims/cmmn/FactionUtil.java @@ -0,0 +1,10 @@ +package cokr.xit.fims.cmmn; + +public class FactionUtil { + + public static String getLastWord(String faction) { + String splitString[] = faction.split(" ", -1); + return splitString[splitString.length-1]; + } + +} diff --git a/src/main/java/cokr/xit/fims/cmmn/dao/FactionMapper.java b/src/main/java/cokr/xit/fims/cmmn/dao/FactionMapper.java index 92722ed7..3bf299bf 100644 --- a/src/main/java/cokr/xit/fims/cmmn/dao/FactionMapper.java +++ b/src/main/java/cokr/xit/fims/cmmn/dao/FactionMapper.java @@ -34,4 +34,9 @@ public interface FactionMapper extends AbstractMapper { */ List selectAbleFactionList(Map params); + /**사용자의 시군구코드,시군구명,기관코드,기관명,부서코드,부서명을 반환한다.
+ * @param 사용자ID + * @return 시군구코드,시군구명,기관코드,기관명,부서코드,부서명 + */ + DataObject selectFactionInfoOfUser(String userId); } diff --git a/src/main/java/cokr/xit/fims/cmmn/hwp/AddUtil.java b/src/main/java/cokr/xit/fims/cmmn/hwp/AddUtil.java new file mode 100644 index 00000000..48154c3a --- /dev/null +++ b/src/main/java/cokr/xit/fims/cmmn/hwp/AddUtil.java @@ -0,0 +1,77 @@ +package cokr.xit.fims.cmmn.hwp; +import java.util.ArrayList; + +import kr.dogfoot.hwplib.object.HWPFile; +import kr.dogfoot.hwplib.object.bodytext.ParagraphListInterface; +import kr.dogfoot.hwplib.object.bodytext.control.Control; +import kr.dogfoot.hwplib.object.bodytext.control.ControlType; +import kr.dogfoot.hwplib.object.bodytext.control.table.Cell; +import kr.dogfoot.hwplib.object.bodytext.paragraph.Paragraph; +import kr.dogfoot.hwplib.object.bodytext.paragraph.ParagraphList; +import kr.dogfoot.hwplib.tool.objectfinder.ControlFilter; +import kr.dogfoot.hwplib.tool.paragraphadder.ParagraphAdder; + +public class AddUtil { + + /**한글파일을 병합한다. + * @param attachHWPFile 기준파일 마지막 페이지에 붙일 파일, baseHWPFile 기준 파일 + * @return + */ + public static void appendToLast(HWPFile attachHWPFile, HWPFile baseHWPFile) throws Exception { + + if (attachHWPFile != null && baseHWPFile != null) { + + + Paragraph attachParagraph = attachHWPFile.getBodyText().getSectionList().get(0).getParagraph(0); + + + ParagraphListInterface baseSection = baseHWPFile.getBodyText().getSectionList().get(0); + + ParagraphAdder paraAdder = new ParagraphAdder(baseHWPFile, baseSection); + paraAdder.add(attachHWPFile, attachParagraph); + + } + } + + /** 외부 한글파일의 테이블을 기준파일의 특정 테이블셀에 삽입한다. + * @param attachHWPFile 테이블을 가져올 외부파일, baseHWPFile 기준 파일, cell 기준 파일의 테이블셀 + * @return + */ + public static void insertTableInCell(HWPFile attachHWPFile, HWPFile baseHWPFile, Cell cell) throws Exception { + + Paragraph attachParagraph = attachHWPFile.getBodyText().getSectionList().get(0).getParagraph(0); + + + boolean isEmptyCell = true; + + ParagraphList cpl = cell.getParagraphList(); + if(cpl.getParagraphCount() >= 1) { + ArrayList cl = cpl.getParagraph(0).getControlList(); + if(cl != null && cl.size() != 0) { + + ControlFilter tableFilter = (control, paragrpah, section) -> { + ControlType ct = control.getType(); + if(ct.getCtrlId() == ControlType.Table.getCtrlId()) { + return true; + } else { + return false; + } + }; + + for(Control c : cl) { + boolean matched = tableFilter.isMatched(c, null, null); + if(matched) { + isEmptyCell = false; + } + } + } + } + + if(isEmptyCell) { + cpl.deleteAllParagraphs(); + } + + ParagraphAdder paraAdder = new ParagraphAdder(baseHWPFile, cpl); + paraAdder.add(attachHWPFile, attachParagraph); + } +} diff --git a/src/main/java/cokr/xit/fims/cmmn/hwp/AddingParagraphBetweenHWPFile.java b/src/main/java/cokr/xit/fims/cmmn/hwp/AddingParagraphBetweenHWPFile.java deleted file mode 100644 index d8cc0f98..00000000 --- a/src/main/java/cokr/xit/fims/cmmn/hwp/AddingParagraphBetweenHWPFile.java +++ /dev/null @@ -1,23 +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.tool.paragraphadder.ParagraphAdder; - -public class AddingParagraphBetweenHWPFile { - public static void fileMerge(HWPFile sourceHWPFile, HWPFile targetHWPFile) throws Exception { - - if (sourceHWPFile != null && targetHWPFile != null) { - - ParagraphListInterface targetFirstSection = targetHWPFile.getBodyText().getSectionList().get(0); - - Paragraph sourceParagraph = sourceHWPFile.getBodyText().getSectionList().get(0).getParagraph(0); - - ParagraphAdder paraAdder = new ParagraphAdder(targetHWPFile, targetFirstSection); - paraAdder.add(sourceHWPFile, sourceParagraph); - - - - } - } -} diff --git a/src/main/java/cokr/xit/fims/cmmn/hwp/ClickHereEditor.java b/src/main/java/cokr/xit/fims/cmmn/hwp/ClickHereEditor.java new file mode 100644 index 00000000..66be94eb --- /dev/null +++ b/src/main/java/cokr/xit/fims/cmmn/hwp/ClickHereEditor.java @@ -0,0 +1,25 @@ +package cokr.xit.fims.cmmn.hwp; + +import java.util.ArrayList; + +import kr.dogfoot.hwplib.object.HWPFile; +import kr.dogfoot.hwplib.tool.objectfinder.FieldFinder; + +public class ClickHereEditor { + private HWPFile whpFile; + + public ClickHereEditor(HWPFile whpFile){ + this.whpFile = whpFile; + } + + public void set(String clickHereName, String value) { + try { + ArrayList 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/PrintUtil.java b/src/main/java/cokr/xit/fims/cmmn/hwp/PrintUtil.java new file mode 100644 index 00000000..4eb94a5f --- /dev/null +++ b/src/main/java/cokr/xit/fims/cmmn/hwp/PrintUtil.java @@ -0,0 +1,262 @@ +package cokr.xit.fims.cmmn.hwp; + +import java.io.File; +import java.io.InputStream; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +import org.springframework.core.io.ClassPathResource; + +import cokr.xit.fims.cmmn.CmmnUtil; +import cokr.xit.fims.cmmn.FactionUtil; +import cokr.xit.fims.sprt.PrintOption; +import cokr.xit.foundation.UserInfo; +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.reader.HWPReader; +import kr.dogfoot.hwplib.tool.objectfinder.CellFinder; +import kr.dogfoot.hwplib.writer.HWPWriter; + +public class PrintUtil { + + private String formatType; + private String formatName; + private String formatKorName; + private String printRequestDt; + private int recordPerPartFile; + + private String baseFormatFilePath; + private String attachFormatFilePath; + + private UserInfo printRequestUserInfo; + + private int totalPartFileCount; + + public String getFormatType() { + return this.formatType; + } + + public String getFormatName() { + return this.formatName; + } + + public String getFormatKorName() { + return this.formatKorName; + } + + public String getPrintRequestDt() { + return this.printRequestDt; + } + + public UserInfo getPrintRequestUserInfo() { + return this.printRequestUserInfo; + }; + + public int getRecordPerPartFile() { + return this.recordPerPartFile; + } + + public int getTotalPartFileCount() { + return this.totalPartFileCount; + } + + public String getBaseFormatFilePath() { + return this.baseFormatFilePath; + } + + public String getAttachFormatFilePath() { + return this.attachFormatFilePath; + } + + public void calcTotalPartFileCount(int totalDataCount) { + + if(this.formatType.equals("list")) { + + if(totalDataCount <= this.recordPerPartFile) { + this.totalPartFileCount = 1; + } else { + + int mod = (totalDataCount % this.recordPerPartFile); + + this.totalPartFileCount = (totalDataCount - mod) / this.recordPerPartFile; + if(mod > 0) { + this.totalPartFileCount = this.totalPartFileCount + 1; + } + + } + } else { + this.totalPartFileCount = totalDataCount; + } + + } + + + public void setPrintRequestUserInfo(UserInfo printRequestUserInfo) { + this.printRequestUserInfo = printRequestUserInfo; + }; + + public void setting(String formatType, String formatName) { + this.formatType = formatType; + this.formatName = formatName; + SimpleDateFormat ymdhmsFormat = new SimpleDateFormat("yyyyMMddHHmmss"); + this.printRequestDt = ymdhmsFormat.format(new Date()); + + if(!formatType.equals("list")) { + this.recordPerPartFile = 1; + } else { + switch (formatName) { + case "crdnList": { + this.recordPerPartFile = 6; + } + + } + } + + switch (formatName) { + case "crdnConfirm": { + this.formatKorName = "단속확인서"; + this.baseFormatFilePath = "format/crdnConfirm.hwp"; + this.attachFormatFilePath = ""; + } + case "crdnList": { + this.formatKorName = "단속내역서"; + this.baseFormatFilePath = "format/crdnList_root.hwp"; + this.attachFormatFilePath = "format/crdnList_inner.hwp"; + } + + } + + } + + /**한글 포맷 파일을 복사하여 새 한글파일을 생성한다. + * @param formatFile 한글 포맷 파일 + * @return 새 파일 경로 + */ + public String newFileFromFormatFile() { + try { + + InputStream baseFormatIS = new ClassPathResource(this.getBaseFormatFilePath()).getInputStream(); + HWPFile baseFormatFile = HWPReader.fromInputStream(baseFormatIS); + + SimpleDateFormat ymdhmsFormat = new SimpleDateFormat("yyyyMMddHHmmss"); + String currentTime = ymdhmsFormat.format(new Date()); + String year = currentTime.substring(0, 4); + String month = currentTime.substring(4, 6); + String day = currentTime.substring(6, 8); + String formatFileResultRootPath = "files" + File.separator + "result" + File.separator + "print"; + String formatFileResultFolderPath = formatFileResultRootPath + + File.separator + year + File.separator + month + File.separator + day; + File formatFileResultFolder = new File(formatFileResultFolderPath); + if(!formatFileResultFolder.exists()) { + formatFileResultFolder.mkdirs(); + } + String resultHwpPath = formatFileResultFolderPath + File.separator + currentTime + ".hwp"; + + HWPWriter.toFile(baseFormatFile, resultHwpPath); + return resultHwpPath; + + } catch (Exception e){ + throw new RuntimeException("한글 파일 출력 중 오류가 발생하였습니다."); + } + + } + + /**한글 파일의 공통정보를 입력한다. + * @param dataObjectList 데이터목록, baseFile 한글파일 + * @return + */ + public void setGlobalInfo(PrintOption printOption, List dataObjectList, HWPFile baseFile) { + int totalDataCount = dataObjectList.size(); + + + boolean privateInfoYn = true; + if(printOption.getPrivateInfoYn() != null && printOption.getPrivateInfoYn().equals("N")) { + privateInfoYn = false; + } + + + if(this.formatName.equals("crdnList")){ + + 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(); + + //상단 + ClickHereEditor baseFileEditor = new ClickHereEditor(baseFile); + baseFileEditor.set("성명", globalRtpyrNm); + if(privateInfoYn) { + baseFileEditor.set("주민번호", globalRtpyrNo); + } else { + baseFileEditor.set("주민번호", "*************"); + } + + baseFileEditor.set("주소", globalRtpyrFullAddr); + baseFileEditor.set("총건수", CmmnUtil.addCommaToNumber(totalDataCount)); + baseFileEditor.set("총금액", CmmnUtil.addCommaToNumber(globalTotalAmount)); + baseFileEditor.set("출력일시", CmmnUtil.yyyy_mm_dd_hh_mm_ss(this.printRequestDt)); + + String instNm = (String) this.printRequestUserInfo.getInfo().get("instNm"); + instNm = FactionUtil.getLastWord(instNm); + baseFileEditor.set("발신", instNm); + } + } + + /**한글파일 서식에 대해 데이터 건별로 처리한다. + * @param dataObject 데이터, baseFile 한글파일 + * @return + */ + public void setBySingleData(PrintOption printOption, DataObject dataObject, HWPFile baseFile) { + try { + if(this.formatType.equals("list")) { + InputStream attachFormatIS = new ClassPathResource(this.getAttachFormatFilePath()).getInputStream(); + HWPFile attachFormatFile = HWPReader.fromInputStream(attachFormatIS); + ClickHereEditor attachFileEditor = new ClickHereEditor(attachFormatFile); + + if(this.formatName.equals("crdnList")){ + + 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"))); + } + + + ArrayList cellList = CellFinder.findAll(baseFile, "내부"); + Cell cell = cellList.get(0); + + + AddUtil.insertTableInCell(attachFormatFile, baseFile, cell); + + + } else { + + + + } + } catch(Exception e) { + e.printStackTrace(); + throw new RuntimeException("한글 파일 출력 중 오류가 발생하였습니다."); + } + + } + +} diff --git a/src/main/java/cokr/xit/fims/cmmn/service/bean/FactionBean.java b/src/main/java/cokr/xit/fims/cmmn/service/bean/FactionBean.java new file mode 100644 index 00000000..c322be87 --- /dev/null +++ b/src/main/java/cokr/xit/fims/cmmn/service/bean/FactionBean.java @@ -0,0 +1,43 @@ +package cokr.xit.fims.cmmn.service.bean; + +import java.util.Map; + +import javax.annotation.Resource; + +import org.springframework.stereotype.Component; + +import cokr.xit.base.user.dao.UserMapper; +import cokr.xit.fims.cmmn.dao.FactionMapper; +import cokr.xit.fims.crdn.dao.GlobalStngMapper; +import cokr.xit.foundation.AbstractComponent; +import cokr.xit.foundation.UserInfo; +import cokr.xit.foundation.data.DataObject; + +@Component("factionBean") +public class FactionBean extends AbstractComponent { + + @Resource(name = "factionMapper") + private FactionMapper factionMapper; + + @Resource(name = "globalStngMapper") + private GlobalStngMapper globalStngMapper; + + @Resource(name = "userMapper") + private UserMapper userMapper; + + public void initUserInfo(UserInfo userInfo) { + + DataObject factionInfo = factionMapper.selectFactionInfoOfUser(userInfo.getId()); + + Map infoMap = userInfo.getInfo(); + infoMap.put("sggCd", factionInfo.string("SGG_CD")); + infoMap.put("sggNm", factionInfo.string("SGG_NM")); + infoMap.put("instCd", factionInfo.string("INST_CD")); + infoMap.put("instNm", factionInfo.string("INST_NM")); + infoMap.put("deptCd", factionInfo.string("DEPT_CD")); + infoMap.put("deptNm", factionInfo.string("DEPT_NM")); + + userInfo.setInfo(infoMap); + } + +} diff --git a/src/main/java/cokr/xit/fims/cvlc/service/bean/CrdnCvlcptServiceBean.java b/src/main/java/cokr/xit/fims/cvlc/service/bean/CrdnCvlcptServiceBean.java index 49b35e82..20680e4a 100644 --- a/src/main/java/cokr/xit/fims/cvlc/service/bean/CrdnCvlcptServiceBean.java +++ b/src/main/java/cokr/xit/fims/cvlc/service/bean/CrdnCvlcptServiceBean.java @@ -23,7 +23,7 @@ import cokr.xit.fims.cmmn.CmmnUtil; import cokr.xit.fims.cmmn.CrdnSttsHstry; import cokr.xit.fims.cmmn.dao.CrdnPayerHstryMapper; import cokr.xit.fims.cmmn.dao.CrdnSttsHstryMapper; -import cokr.xit.fims.cmmn.hwp.AddingParagraphBetweenHWPFile; +import cokr.xit.fims.cmmn.hwp.AddUtil; import cokr.xit.fims.cmmn.hwp.InsertingImageCell; import cokr.xit.fims.cmmn.service.bean.CrdnSttsHstryBean; import cokr.xit.fims.crdn.Crdn; @@ -219,7 +219,7 @@ public class CrdnCvlcptServiceBean extends AbstractServiceBean implements CrdnCv InsertingImageCell.IMPL_InsertPicture(attachFormatFile, "왼쪽아래사진", fileInfoList.get(i+2).string("URL")); if(i+3 < photoCnt) InsertingImageCell.IMPL_InsertPicture(attachFormatFile, "오른쪽아래사진", fileInfoList.get(i+3).string("URL")); - AddingParagraphBetweenHWPFile.fileMerge(attachFormatFile, resultFile); + AddUtil.appendToLast(attachFormatFile, resultFile); } HWPWriter.toFile(resultFile, resultHwpPath); diff --git a/src/main/java/cokr/xit/fims/sprt/PrintOption.java b/src/main/java/cokr/xit/fims/sprt/PrintOption.java new file mode 100644 index 00000000..f95f2da9 --- /dev/null +++ b/src/main/java/cokr/xit/fims/sprt/PrintOption.java @@ -0,0 +1,12 @@ +package cokr.xit.fims.sprt; + +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +public class PrintOption { + + String privateInfoYn; //개인정보표시 + +} diff --git a/src/main/java/cokr/xit/fims/sprt/service/Sprt01Service.java b/src/main/java/cokr/xit/fims/sprt/service/Sprt01Service.java index d1c512f8..08c0f6b2 100644 --- a/src/main/java/cokr/xit/fims/sprt/service/Sprt01Service.java +++ b/src/main/java/cokr/xit/fims/sprt/service/Sprt01Service.java @@ -1,7 +1,9 @@ package cokr.xit.fims.sprt.service; import java.util.List; +import java.util.Map; +import cokr.xit.fims.sprt.PrintOption; import cokr.xit.fims.sprt.SprtQuery; import cokr.xit.foundation.data.DataObject; @@ -29,4 +31,13 @@ public interface Sprt01Service { */ boolean updateEtcCn(String etcCn, String... crdnIds); + /** 한글 서식 출력물을 생성한다. + * @param formatType 서식유형 ,formatName 서식명, printOption 출력옵션, crdnIds 출력대상 + * @return map 출력 요청 결과 + *
  • filePath: 결과 파일 경로
  • + *
  • fileName: 다운로드 파일명
  • + *
+ */ + Map makeFileFromHwpFormat(String formatType, String formatName, PrintOption printOption, String... crdnIds); + } diff --git a/src/main/java/cokr/xit/fims/sprt/service/bean/Sprt01ServiceBean.java b/src/main/java/cokr/xit/fims/sprt/service/bean/Sprt01ServiceBean.java index cfeec6c9..818558a6 100644 --- a/src/main/java/cokr/xit/fims/sprt/service/bean/Sprt01ServiceBean.java +++ b/src/main/java/cokr/xit/fims/sprt/service/bean/Sprt01ServiceBean.java @@ -1,15 +1,28 @@ package cokr.xit.fims.sprt.service.bean; +import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; import javax.annotation.Resource; import org.springframework.stereotype.Service; +import cokr.xit.fims.cmmn.hwp.AddUtil; +import cokr.xit.fims.cmmn.hwp.PrintUtil; +import cokr.xit.fims.cmmn.service.bean.FactionBean; +import cokr.xit.fims.crdn.CrdnQuery; +import cokr.xit.fims.crdn.dao.CrdnListMapper; +import cokr.xit.fims.sprt.PrintOption; import cokr.xit.fims.sprt.SprtQuery; import cokr.xit.fims.sprt.service.Sprt01Service; +import cokr.xit.foundation.UserInfo; import cokr.xit.foundation.component.AbstractServiceBean; import cokr.xit.foundation.data.DataObject; +import kr.dogfoot.hwplib.object.HWPFile; +import kr.dogfoot.hwplib.reader.HWPReader; +import kr.dogfoot.hwplib.writer.HWPWriter; /**통합 조회 서비스 구현체. * @@ -28,6 +41,12 @@ public class Sprt01ServiceBean extends AbstractServiceBean implements Sprt01Serv @Resource(name="sprt01Bean") protected Sprt01Bean sprt01Bean; + @Resource(name="factionBean") + protected FactionBean factionBean; + + @Resource(name="crdnListMapper") + protected CrdnListMapper crdnListMapper; + @Override public List getIntegrationDataList(SprtQuery query) { return sprt01Bean.getIntegrationDataList(query); @@ -40,4 +59,97 @@ public class Sprt01ServiceBean extends AbstractServiceBean implements Sprt01Serv } + @Override + public Map makeFileFromHwpFormat(String formatType, String formatName, PrintOption printOption, String... crdnIds) { + Map result = new HashMap<>(); + + PrintUtil printUtil = new PrintUtil(); + printUtil.setting(formatType, formatName); + + UserInfo userInfo = currentUser(); + factionBean.initUserInfo(userInfo); + printUtil.setPrintRequestUserInfo(userInfo); + + List dataObjectList = null; + + if(formatName.equals("crdnList")) { + CrdnQuery query = new CrdnQuery(); + query.setCrdnIDs(crdnIds); + dataObjectList = crdnListMapper.selectCrackdownList(query); + } else if(formatName.equals("crdnConfirm")) { + CrdnQuery query = new CrdnQuery(); + query.setCrdnIDs(crdnIds); + dataObjectList = crdnListMapper.selectCrackdownList(query); + } + + int totalDataCount = dataObjectList.size(); + List partFileList = new ArrayList<>(); + printUtil.calcTotalPartFileCount(totalDataCount); + + + try { + + int dataIndex = 0; + + for(int partFileIndex = 0; partFileIndex < printUtil.getTotalPartFileCount(); partFileIndex++) { + + //새 파일 생성 + String resultHwpPath = printUtil.newFileFromFormatFile(); + HWPFile resultFile = HWPReader.fromFile(resultHwpPath); + + //공통사항 세팅 + printUtil.setGlobalInfo(printOption, dataObjectList, resultFile); + HWPWriter.toFile(resultFile, resultHwpPath); + + //데이터 건별 처리 + for(int recordIndex = 0; recordIndex < printUtil.getRecordPerPartFile(); recordIndex++) { + if(dataIndex < dataObjectList.size()) { + DataObject dataObject = dataObjectList.get(dataIndex); + + printUtil.setBySingleData(printOption, dataObject, resultFile); + } + + if(formatType.equals("list")) { + dataIndex++; + } + + } + + if(!formatType.equals("list")) { + dataIndex++; + } + + HWPWriter.toFile(resultFile, resultHwpPath); + partFileList.add(resultHwpPath); + } + + //결과파일 병합 + if(partFileList.size() >= 2) { + String basePath = partFileList.get(0); + HWPFile baseFile = HWPReader.fromFile(basePath); + + + for(int i=2; i <= partFileList.size();i++) { + String attachPath = partFileList.get(i-1); + HWPFile attachFile = HWPReader.fromFile(attachPath); + AddUtil.appendToLast(attachFile, baseFile); + } + HWPWriter.toFile(baseFile, basePath); + } + + String downlaodFileName = printUtil.getFormatKorName()+"_"+printUtil.getPrintRequestDt()+".hwp"; + result.put("fileName", downlaodFileName); + result.put("filePath", partFileList.get(0)); + + } catch (Exception e) { + e.printStackTrace(); + throw new RuntimeException("한글 파일 출력 중 오류가 발생하였습니다."); + + } + + return result; + } + + + } 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 403d98f8..cb9e3b0e 100644 --- a/src/main/java/cokr/xit/fims/sprt/web/Sprt01Controller.java +++ b/src/main/java/cokr/xit/fims/sprt/web/Sprt01Controller.java @@ -14,8 +14,10 @@ import cokr.xit.base.code.CommonCode; import cokr.xit.base.user.ManagedUser; import cokr.xit.base.user.dao.UserMapper; import cokr.xit.base.web.ApplicationController; +import cokr.xit.fims.crdn.Crdn; import cokr.xit.fims.crdn.dao.GlobalStngMapper; import cokr.xit.fims.sprt.Keyword; +import cokr.xit.fims.sprt.PrintOption; import cokr.xit.fims.sprt.SprtQuery; import cokr.xit.fims.sprt.service.Sprt01Service; import cokr.xit.foundation.data.DataObject; @@ -43,6 +45,8 @@ public class Sprt01Controller extends ApplicationController { inputEtcCnMain = "/100/info.do", inputEtcCn = "/100/update.do", printCrdnMain = "/110/info.do", + makeCrdnListFileFromHwpFormat = "/110/makeCrdnListFileFromHwpFormat.do", + makeCrdnConfirmFileFromHwpFormat = "/110/makeCrdnConfirmFileFromHwpFormat.do", printBillMain = "/120/info.do" ; } @@ -241,7 +245,7 @@ public class Sprt01Controller extends ApplicationController { */ public ModelAndView inputEtcCnMain(String... crdnIds) { ModelAndView mav = new ModelAndView("fims/sprt/sprt01100-info"); - + mav.addObject("pageName", "sprt01100-info"); mav.addObject("crdnIds", toJson(crdnIds)); return mav; @@ -255,12 +259,12 @@ public class Sprt01Controller extends ApplicationController { * "saved": 저장되었으면 true, 그렇지 않으면 false * } */ - public ModelAndView inputEtcCn(String etcCn, String... crdnIds) { + public ModelAndView inputEtcCn(Crdn crdn, String... crdnIds) { ModelAndView mav = new ModelAndView("jsonView"); boolean saved = false; - saved = sprt01Service.updateEtcCn(etcCn, crdnIds); + saved = sprt01Service.updateEtcCn(crdn.getEtcCn(), crdnIds); mav.addObject("saved", saved); @@ -273,21 +277,53 @@ public class Sprt01Controller extends ApplicationController { */ public ModelAndView printCrdnMain(String... crdnIds) { ModelAndView mav = new ModelAndView("fims/sprt/sprt01110-info"); - + mav.addObject("pageName", "sprt01110-info"); mav.addObject("crdnIds", toJson(crdnIds)); return mav; } + /** 단속내역서를 한글 파일로 작성한다. + * @return hwp파일 + */ + public ModelAndView makeCrdnListFileFromHwpFormat(String privateInfoYn, String[] crdnIds) { + Map result = null; + String format = "crdnList"; + PrintOption printOption = new PrintOption(); + printOption.setPrivateInfoYn(privateInfoYn); + + result = sprt01Service.makeFileFromHwpFormat("list", format, printOption ,crdnIds); + + ModelAndView mav = new ModelAndView("jsonView"); + mav.addAllObjects(result); + return mav; + } + + /** 단속확인서를 한글 파일로 작성한다. + * @return hwp파일 + */ + public ModelAndView makeCrdnConfirmFileFromHwpFormat(String[] crdnIds) { + Map result = null; + String format = "crdnConfirm"; + PrintOption printOption = new PrintOption(); + + result = sprt01Service.makeFileFromHwpFormat("info", format, printOption, crdnIds); + + ModelAndView mav = new ModelAndView("jsonView"); + mav.addAllObjects(result); + return mav; + } + /**교부청구서,채권신고서 출력 화면을 연다. * * @return /fims/sprt/sprt01120 */ public ModelAndView printBillMain(String... crdnIds) { ModelAndView mav = new ModelAndView("fims/sprt/sprt01120-info"); - + mav.addObject("pageName", "sprt01120-info"); mav.addObject("crdnIds", toJson(crdnIds)); return mav; } + } diff --git a/src/main/java/cokr/xit/fims/task/web/CmnController.java b/src/main/java/cokr/xit/fims/task/web/CmnController.java index 365218f8..fd974a6b 100644 --- a/src/main/java/cokr/xit/fims/task/web/CmnController.java +++ b/src/main/java/cokr/xit/fims/task/web/CmnController.java @@ -6,6 +6,7 @@ import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.servlet.ModelAndView; +import cokr.xit.fims.crdn.Crdn; import cokr.xit.fims.sprt.SprtQuery; import cokr.xit.fims.stat.StatQuery; @@ -356,8 +357,8 @@ public class CmnController { @Override @RequestMapping(name="특기사항 일괄 입력", value=METHOD_URL.inputEtcCn) - public ModelAndView inputEtcCn(String etcCn, String... crdnIds) { - return super.inputEtcCn(etcCn, crdnIds); + public ModelAndView inputEtcCn(Crdn crdn, String... crdnIds) { + return super.inputEtcCn(crdn, crdnIds); } @Override @@ -366,6 +367,18 @@ public class CmnController { return super.printCrdnMain(crdnIds); } + @Override + @RequestMapping(name="단속 내역서 한글 파일 생성", value=METHOD_URL.makeCrdnListFileFromHwpFormat) + public ModelAndView makeCrdnListFileFromHwpFormat(String privateInfoYn, String... crdnIds) { + return super.makeCrdnListFileFromHwpFormat(privateInfoYn, crdnIds); + } + + @Override + @RequestMapping(name="단속 확인서 한글 파일 생성", value=METHOD_URL.makeCrdnConfirmFileFromHwpFormat) + public ModelAndView makeCrdnConfirmFileFromHwpFormat(String... crdnIds) { + return super.makeCrdnConfirmFileFromHwpFormat(crdnIds); + } + @Override @RequestMapping(name="교부청구서,채권신고서 출력 화면", value=METHOD_URL.printBillMain) public ModelAndView printBillMain(String... crdnIds) { diff --git a/src/main/resources/format/crdnConfirm.hwp b/src/main/resources/format/crdnConfirm.hwp new file mode 100644 index 00000000..f1f5719c Binary files /dev/null and b/src/main/resources/format/crdnConfirm.hwp differ diff --git a/src/main/resources/format/crdnList_inner.hwp b/src/main/resources/format/crdnList_inner.hwp new file mode 100644 index 00000000..a1d23a61 Binary files /dev/null and b/src/main/resources/format/crdnList_inner.hwp differ diff --git a/src/main/resources/format/crdnList_root.hwp b/src/main/resources/format/crdnList_root.hwp new file mode 100644 index 00000000..97c77309 Binary files /dev/null and b/src/main/resources/format/crdnList_root.hwp differ diff --git a/src/main/resources/sql/mapper/fims/cmmn/faction-mapper.xml b/src/main/resources/sql/mapper/fims/cmmn/faction-mapper.xml index f6e8ce5c..a0ee1715 100644 --- a/src/main/resources/sql/mapper/fims/cmmn/faction-mapper.xml +++ b/src/main/resources/sql/mapper/fims/cmmn/faction-mapper.xml @@ -47,4 +47,18 @@ FROM DUAL + + \ No newline at end of file diff --git a/src/main/resources/sql/mapper/fims/crdn/crdn-list-mapper.xml b/src/main/resources/sql/mapper/fims/crdn/crdn-list-mapper.xml index 28a742d1..b1bba302 100644 --- a/src/main/resources/sql/mapper/fims/crdn/crdn-list-mapper.xml +++ b/src/main/resources/sql/mapper/fims/crdn/crdn-list-mapper.xml @@ -10,6 +10,7 @@ SELECT C.CRDN_ID , C.SGG_CD , (SELECT SGG_NM FROM TB_SGG_INFO WHERE SGG_CD = C.SGG_CD) AS SGG_NM , C.TASK_SE_CD + , (SELECT GET_CODE_NM('FIM054', C.TASK_SE_CD) FROM DUAL) AS TASK_SE_NM , C.CRDN_REG_SE_CD , C.CRDN_INPT_SE_CD , C.LINK_TBL_NM @@ -40,6 +41,11 @@ SELECT C.CRDN_ID , C.OPNN_SBMSN_YN , L.LEVY_ID , (CONCAT(L.FYR, '-', L.LEVY_NO)) AS GOJI_NO + , L.EPAYNO + , L.VR_ACTNO + , (L.LEVY_PCPTAX + L.LEVY_ADAMT + L.INSPY_INT) AS LEVY_AMT + , L.DUDT_YMD + , L.RCVMT_YMD , C.CRDN_STTS_CD , (SELECT GET_CODE_NM('FIM010', C.CRDN_STTS_CD) FROM DUAL) AS CRDN_STTS_NM , C.CRDN_STTS_CHG_DT @@ -85,6 +91,8 @@ SELECT C.CRDN_ID , LE.LEVY_EXCL_YMD , LE.ETC_CN AS LEVY_EXCL_ETC_CN , P.RTPYR_NM + , P.RTPYR_NO + , CONCAT(P.ADDR, ' ', P.DTL_ADDR) AS RTPYR_FULL_ADDR /* 납부자 전체 주소 */ , C.DEL_YN , C.RGTR , C.REG_DT @@ -104,6 +112,9 @@ WHERE C.DEL_YN = 'N' AND C.SGG_CD = #{sggCd} AND C.CRDN_ID = #{crdnId} + + AND C.CRDN_ID IN (#{CRDN_ID}) + AND C.TASK_SE_CD = #{taskSeCd} AND C.VHRNO LIKE CONCAT('%', #{vhrno}, '%') AND C.CRDN_INPT_SE_CD = #{crdnInptSeCd} diff --git a/src/main/resources/sql/mapper/fims/sprt/integrationSearch-mapper.xml b/src/main/resources/sql/mapper/fims/sprt/integrationSearch-mapper.xml index 4566f6dc..e375df96 100644 --- a/src/main/resources/sql/mapper/fims/sprt/integrationSearch-mapper.xml +++ b/src/main/resources/sql/mapper/fims/sprt/integrationSearch-mapper.xml @@ -176,7 +176,7 @@ LEFT OUTER JOIN TB_RCVMT R ON (L.LEVY_ID = R.LEVY_ID AND R.DEL_YN = 'N - AND L.RPM_SZR_VHRNO LIKE CONCAT ('%' || #{item.value} || '%') + AND L.RPM_SZR_VHRNO LIKE CONCAT ('%' , #{item.value} , '%') AND L.RPM_SZR_VHRNO = #{item.value} @@ -186,7 +186,7 @@ LEFT OUTER JOIN TB_RCVMT R ON (L.LEVY_ID = R.LEVY_ID AND R.DEL_YN = 'N - AND C.VHRNO LIKE CONCAT ('%' || #{item.value} || '%') + AND C.VHRNO LIKE CONCAT ('%' , #{item.value} , '%') AND C.VHRNO = #{item.value} @@ -196,7 +196,7 @@ LEFT OUTER JOIN TB_RCVMT R ON (L.LEVY_ID = R.LEVY_ID AND R.DEL_YN = 'N - AND P.RTPYR_NM LIKE CONCAT ('%' || #{item.value} || '%') + AND P.RTPYR_NM LIKE CONCAT ('%' , #{item.value} , '%') AND P.RTPYR_NM = #{item.value} @@ -226,10 +226,10 @@ LEFT OUTER JOIN TB_RCVMT R ON (L.LEVY_ID = R.LEVY_ID AND R.DEL_YN = 'N - AND P.ADDR LIKE CONCAT ('%' || #{item.value} || '%') + AND P.ADDR LIKE CONCAT ('%' , #{item.value} , '%') - AND P.DTL_ADDR LIKE CONCAT ('%' || #{item.value} || '%') + AND P.DTL_ADDR LIKE CONCAT ('%' , #{item.value} , '%') AND CONCAT(L.FYR, '-', L.LEVY_NO) = #{item.value} @@ -253,7 +253,7 @@ LEFT OUTER JOIN TB_RCVMT R ON (L.LEVY_ID = R.LEVY_ID AND R.DEL_YN = 'N AND C.CRDN_STDG_NM = #{item.value} - AND C.CRDN_PLC LIKE CONCAT ('%' || #{item.value} || '%') + AND C.CRDN_PLC LIKE CONCAT ('%' , #{item.value} , '%') AND CC.CVLCPT_LIST_NO = #{item.value} diff --git a/src/main/webapp/WEB-INF/jsp/fims/sprt/sprt01110-info.jsp b/src/main/webapp/WEB-INF/jsp/fims/sprt/sprt01110-info.jsp index 511d382b..a25444f5 100644 --- a/src/main/webapp/WEB-INF/jsp/fims/sprt/sprt01110-info.jsp +++ b/src/main/webapp/WEB-INF/jsp/fims/sprt/sprt01110-info.jsp @@ -9,10 +9,10 @@
- - + +
@@ -73,6 +73,8 @@
+ +
@@ -93,6 +95,52 @@ $(document).ready(function(){ $("#tbody--${pageName}").setCurrentRow(key); } + //단속내역서 파일 생성 + $P.fnMakeCrdnListFile = () => { + + var privateInfoYn = "Y"; + if($("#privateInfoYn--${pageName}").is(":checked")){ + privateInfoYn = "N"; + } + + ajax.post({ + url : wctx.url("/sprt/sprt01/110/makeCrdnListFileFromHwpFormat.do"), + data : { + crdnIds : $P.crdnIds.join(","), + privateInfoYn : privateInfoYn + }, + success : resp => { + var a = document.createElement("a"); + a.href = resp.filePath; + a.download = resp.fileName; + document.getElementById("tempArea--${pageName}").appendChild(a); + a.click(); + document.getElementById("tempArea--${pageName}").removeChild(a); + } + }); + } + + $P.fnMakeCrdnConfirmFile = () => { + ajax.post({ + url : wctx.url("/sprt/sprt01/110/makeCrdnConfirmFileFromHwpFormat.do"), + data : { + crdnIds : $P.crdnIds.join(",") + }, + success : resp => { + var a = document.createElement("a"); + a.href = resp.filePath; + a.download = resp.fileName; + document.getElementById("tempArea--${pageName}").appendChild(a); + a.click(); + document.getElementById("tempArea--${pageName}").removeChild(a); + } + }); + } + + //버튼 이벤트 + $("#btnPrintCrdnList--${pageName}").on("click", () => $P.fnMakeCrdnListFile() ); + $("#btnPrintCrdnConfirm--${pageName}").on("click", () => $P.fnMakeCrdnConfirmFile() ); + //첫번째 줄 클릭 $("#tbody--${pageName}").find("tr:eq(0)").click(); });