From f61ad60c84ead4a1c77a4496edeaba705157a600 Mon Sep 17 00:00:00 2001 From: mjkhan21 Date: Wed, 27 Dec 2023 14:52:16 +0900 Subject: [PATCH] =?UTF-8?q?=EC=97=91=EC=85=80=20=EB=8B=A4=EC=9A=B4?= =?UTF-8?q?=EB=A1=9C=EB=93=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/cokr/xit/fims/cmmn/CmmnUtil.java | 12 ++++- .../xit/fims/crdn/web/Crdn06Controller.java | 45 +++++++------------ 2 files changed, 26 insertions(+), 31 deletions(-) diff --git a/src/main/java/cokr/xit/fims/cmmn/CmmnUtil.java b/src/main/java/cokr/xit/fims/cmmn/CmmnUtil.java index fb0cc35d..29299c34 100644 --- a/src/main/java/cokr/xit/fims/cmmn/CmmnUtil.java +++ b/src/main/java/cokr/xit/fims/cmmn/CmmnUtil.java @@ -477,4 +477,14 @@ public class CmmnUtil { return result; } -} + public static XLSWriter.Styler headerStyle(XLSWriter xlsx) { + return new XLSWriter.Styler() + .foregroundColor(HSSFColor.HSSFColorPredefined.GREY_25_PERCENT.getIndex()) + .configure(styler -> { + Font font = xlsx.workbook().createFont(); + font.setColor(HSSFColor.HSSFColorPredefined.BLACK.getIndex()); + styler.font(font); + styler.alignment(HorizontalAlignment.CENTER); + }); + } +} \ No newline at end of file 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 b57d1b46..eaa51bd7 100644 --- a/src/main/java/cokr/xit/fims/crdn/web/Crdn06Controller.java +++ b/src/main/java/cokr/xit/fims/crdn/web/Crdn06Controller.java @@ -1,17 +1,12 @@ package cokr.xit.fims.crdn.web; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.function.Supplier; import javax.annotation.Resource; -import org.apache.poi.hssf.util.HSSFColor; import org.apache.poi.ss.usermodel.CellStyle; -import org.apache.poi.ss.usermodel.Font; -import org.apache.poi.ss.usermodel.HorizontalAlignment; import org.springframework.web.servlet.ModelAndView; import com.fasterxml.jackson.core.type.TypeReference; @@ -23,6 +18,7 @@ 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; @@ -100,41 +96,30 @@ public class Crdn06Controller extends ApplicationController { .setFilename("단속자료 목록.xlsx") .worksheet(0); - Supplier defaultHeader = () -> new XLSWriter.Styler() - .foregroundColor(HSSFColor.HSSFColorPredefined.GREY_25_PERCENT.getIndex()) - .configure(styler -> { - Font font = xlsx.workbook().createFont(); - font.setColor(HSSFColor.HSSFColorPredefined.BLACK.getIndex()); - styler.font(font); - styler.alignment(HorizontalAlignment.CENTER); - }); CellStyle center = xlsx.cellStyle(Styler.CENTER); - CellStyle numeric = xlsx.n_nn0(); CellStyle dateYMD = xlsx.yyyy_mm_dd(); CellStyle dateDT = xlsx.yyyy_mm_dd_hh_mm_ss(); List list = crdnService.getCrackdownList(query.setFetchSize(0)); - Map valueMap = new HashMap(); - valueMap.put("자료출처", xlsx.style("CRDN_INPT_SE_NM", center)); - valueMap.put("차량번호", "VHRNO"); - valueMap.put("위반일시", xlsx.format(o -> xlsx.str2datetime(o.get("CRDN_YMD_TM"))).style(dateDT)); - valueMap.put("단속장소", "CRDN_PLC"); - valueMap.put("체납액", "ATCH_FILE_CNT"); - valueMap.put("사진건수", xlsx.style("ATCH_FILE_CNT", center)); - valueMap.put("스티커번호", "CRDN_SN"); - valueMap.put("장애차량확인", xlsx.style("PARKNG_PSBLTY_RSLT_NM", center)); - valueMap.put("처리상태", xlsx.style("CRDN_STTS_NM", center)); - valueMap.put("제외사유", xlsx.style("LEVY_EXCL_RSN_NM", center)); - valueMap.put("제외처리일자", xlsx.format(o -> xlsx.str2date(o.get("LEVY_EXCL_YMD"))).style(dateYMD)); - valueMap.put("제외내역", "LEVY_EXCL_ETC_CN"); - - CellDef.setValues(cellDefs, valueMap); + + CellDef.setValues( + cellDefs, + Map.of( + "자료출처", xlsx.style("CRDN_INPT_SE_NM", center), + "위반일시", xlsx.format(o -> xlsx.str2datetime(o.get("CRDN_YMD_TM"))).style(dateDT), + "사진건수", xlsx.style("ATCH_FILE_CNT", center), + "장애차량확인", xlsx.style("PARKNG_PSBLTY_RSLT_NM", center), + "처리상태", xlsx.style("CRDN_STTS_NM", center), + "제외사유", xlsx.style("LEVY_EXCL_RSN_NM", center), + "제외처리일자", xlsx.format(o -> xlsx.str2date(o.get("LEVY_EXCL_YMD"))).style(dateYMD) + ) + ); xlsx.cell(0, 0) .value("단속자료 목록", center) .merge(0, cellDefs.size()-1) .cell(3, 0) - .rowValues(CellDef.header(cellDefs, defaultHeader)) + .rowValues(CellDef.header(cellDefs, () -> CmmnUtil.headerStyle(xlsx))) .cell(4, 0) .values(list, CellDef.values(cellDefs));