From 2e1c62e96099b066720a896d78e4bbcde4eb8319 Mon Sep 17 00:00:00 2001 From: leebeomjun Date: Fri, 15 Dec 2023 10:29:02 +0900 Subject: [PATCH] =?UTF-8?q?=EB=8B=A8=EC=86=8D=EA=B4=80=EB=A6=AC=20?= =?UTF-8?q?=EC=97=91=EC=85=80=EC=A0=80=EC=9E=A5=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xit/fims/crdn/web/Crdn06Controller.java | 99 ++++++++++++------- 1 file changed, 66 insertions(+), 33 deletions(-) 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 c795ccad..acc25762 100644 --- a/src/main/java/cokr/xit/fims/crdn/web/Crdn06Controller.java +++ b/src/main/java/cokr/xit/fims/crdn/web/Crdn06Controller.java @@ -1,7 +1,9 @@ package cokr.xit.fims.crdn.web; +import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.function.BiFunction; import javax.annotation.Resource; @@ -10,9 +12,11 @@ import org.springframework.web.servlet.ModelAndView; import cokr.xit.base.code.CommonCode; import cokr.xit.base.file.xls.XLSWriter; +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.CmmnUtil; import cokr.xit.fims.crdn.Crdn; import cokr.xit.fims.crdn.CrdnQuery; import cokr.xit.fims.crdn.dao.GlobalStngMapper; @@ -85,41 +89,70 @@ public class Crdn06Controller extends ApplicationController { if("xls".equals(query.getDownload())) { XLSWriter xlsx = new XLSWriter() - .setTemplate("template/xls/excl-list-tmpl.xlsx") - .setFilename("단속자료 목록.xlsx") - .worksheet(0); - - /* - CellStyle header = xlsx.cellStyle(new XLSWriter.Styler() - .width(20) - .foregroundColor(HSSFColor.HSSFColorPredefined.LIGHT_BLUE.getIndex()) - .configure(styler -> { - Font font = xlsx.workbook().createFont(); - font.setColor(HSSFColor.HSSFColorPredefined.WHITE.getIndex()); - styler.font(font); - }) - ); */ + .setFilename("단속자료 목록.xlsx") + .worksheet(0); + CellStyle numeric = xlsx.n_nn0(); - xlsx - /* - .cell(0, 0) - .value("단속자료 목록", XLSWriter.Styler.CENTER) - .merge(0, 15) - .cell(3, 0) - .rowValues(List.of( - "업무구분", header, "부과제외일자", header, "부과제외구분", header, "부과제외사유", header, "기타내용", header, - "민원신청번호", header, "민원접수번호", header, "민원접수일자", header, "단속일시", header, "차량번호", header, - "법정동", header, "단속장소", header, "과태료금액", header, "처리상태", header, "납부자명", header, "납부자생일", header - )) */ - - .cell(4, 0) - .values( - crdnService.getCrackdownList(query.setFetchSize(0)), - "TASK_SE_NM", xlsx.format(r -> xlsx.str2date(r.get("LEVY_EXCL_YMD"))), "LEVY_EXCL_SE_NM", "LEVY_EXCL_RSN_NM", "ETC_CN", - "CVLCPT_APLY_NO", "CVLCPT_RCPT_NO", xlsx.format(r -> xlsx.str2date(r.get("CVLCPT_RCPT_YMD"))), xlsx.format(r -> xlsx.str2date(r.get("CRDN_YMD")) + " " + xlsx.str2time(r.get("CRDN_TM"))), - "VHRNO", "CRDN_STDG_NM", "CRDN_PLC", xlsx.style("FFNLG_AMT", numeric), "CRDN_STTS_NM", "RTPYR_NM", xlsx.format(r -> xlsx.str2date(r.get("RTPYR_BRDT"))) - ); + String[] excelTitle = query.getExcelTitle(); + List titles = new ArrayList(); + for(int i = 0; i < excelTitle.length; i++) { + String item = excelTitle[i]; + titles.add(item); + } + + int[] excelTitleWidth = query.getExcelTitleWidth(); + List widths = new ArrayList<>(); + for(int i = 0; i < excelTitleWidth.length; i++) { + int item = excelTitleWidth[i]; + widths.add(item); + } + + List headerStylers = CmmnUtil.makeHeadersByDiffrentWidths(widths, xlsx); + + xlsx.cell(0, 0) + .value("단속자료 목록", XLSWriter.Styler.CENTER) + .merge(0, 15) + .cell(3, 0) + .rowValues(CmmnUtil.mergeListByIndex(titles, headerStylers)); + + List list = crdnService.getCrackdownList(query.setFetchSize(0)); + + + BiFunction getValue = (title1, noting) -> { + switch(title1) { + case "자료출처": + return "CRDN_INPT_SE_NM"; + case "차량번호": + return "VHRNO"; + case "위반일시": + return xlsx.format(o -> xlsx.str2datetime(o.get("CRDN_YMD_TM"))); + case "단속장소": + return "CRDN_PLC"; + case "체납액": + return ""; + case "사진건수": + return "ATCH_FILE_CNT"; + case "스티커번호": + return "CRDN_SN"; + case "장애차량확인": + return "PARKNG_PSBLTY_RSLT_NM"; + case "처리상태": + return "CRDN_STTS_NM"; + case "제외사유": + return "LEVY_EXCL_RSN_NM"; + case "제외처리일자": + return "LEVY_EXCL_YMD"; + case "제외내역": + return "LEVY_EXCL_ETC_CN"; + } + return ""; + }; + + + + xlsx.cell(4, 0) + .values(list, titles.stream().map((item) -> { return getValue.apply(item, null); }).toArray()); return new ModelAndView("xlsView").addObject("xls", xlsx); }