From dcceb0818fbe6ee1a56a6241ce3dbcceca1997ec Mon Sep 17 00:00:00 2001 From: leebeomjun Date: Mon, 22 Apr 2024 14:09:34 +0900 Subject: [PATCH] no message --- .../cokr/xit/fims/cmmn/xls/FormatMaker.java | 10 --- .../xit/fims/crdn/web/Crdn06Controller.java | 8 +- .../xit/fims/cvlc/web/Cvlc01Controller.java | 75 +++++++++---------- 3 files changed, 40 insertions(+), 53 deletions(-) diff --git a/src/main/java/cokr/xit/fims/cmmn/xls/FormatMaker.java b/src/main/java/cokr/xit/fims/cmmn/xls/FormatMaker.java index 0d5d6b29..ead9351d 100644 --- a/src/main/java/cokr/xit/fims/cmmn/xls/FormatMaker.java +++ b/src/main/java/cokr/xit/fims/cmmn/xls/FormatMaker.java @@ -61,16 +61,6 @@ public class FormatMaker { }).style(dateYMD); } - public static Format key(Format format, CellStyle style, String key) { - return format.of(key).value(o -> { - return ((Map) o).get(key); - }).style(style); - } - public static Format key(Format format, String key) { - return format.of(key).value(o -> { - return ((Map) o).get(key); - }); - } } 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 c631f7c0..34b26089 100644 --- a/src/main/java/cokr/xit/fims/crdn/web/Crdn06Controller.java +++ b/src/main/java/cokr/xit/fims/crdn/web/Crdn06Controller.java @@ -131,15 +131,15 @@ public class Crdn06Controller extends ApplicationController { CellStyle dateDT = format.yyyy_mm_dd_hh_mm_ss(); Map valueMap = new HashMap(); - valueMap.put("자료출처", FormatMaker.key(format, center, "CRDN_INPT_SE_NM")); + valueMap.put("자료출처", format.of("CRDN_INPT_SE_NM").style(center)); valueMap.put("차량번호", left); valueMap.put("위반일시", FormatMaker.yyyy_mm_dd_hh_mm_ss(format,dateDT,"CRDN_YMD_TM")); valueMap.put("단속장소", left); valueMap.put("사진건수", center); valueMap.put("스티커번호", left); - valueMap.put("장애차량확인", FormatMaker.key(format, center, "PARKNG_PSBLTY_RSLT_NM")); - valueMap.put("처리상태", FormatMaker.key(format, center, "CRDN_STTS_NM")); - valueMap.put("제외사유", FormatMaker.key(format, center, "LEVY_EXCL_RSN_NM")); + valueMap.put("장애차량확인", format.of("PARKNG_PSBLTY_RSLT_NM").style(center)); + valueMap.put("처리상태", format.of("CRDN_STTS_NM").style(center)); + valueMap.put("제외사유", format.of("LEVY_EXCL_RSN_NM").style(center)); valueMap.put("제외처리일자", FormatMaker.yyyy_mm_dd(format,dateYMD,"LEVY_EXCL_YMD")); valueMap.put("제외내역", left); if(ifEmpty(query.getIncludePhoto(), () -> "").equals("Y")) { 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 b72296d5..f99b98db 100644 --- a/src/main/java/cokr/xit/fims/cvlc/web/Cvlc01Controller.java +++ b/src/main/java/cokr/xit/fims/cvlc/web/Cvlc01Controller.java @@ -10,6 +10,7 @@ import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import org.apache.poi.ss.usermodel.CellStyle; +import org.apache.poi.ss.usermodel.HorizontalAlignment; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.servlet.ModelAndView; @@ -17,11 +18,12 @@ import org.springframework.web.servlet.ModelAndView; import com.fasterxml.jackson.core.type.TypeReference; import cokr.xit.base.code.CommonCode; +import cokr.xit.base.docs.xls.CellDef; +import cokr.xit.base.docs.xls.Format; +import cokr.xit.base.docs.xls.Style; +import cokr.xit.base.docs.xls.XLSWriter; import cokr.xit.base.file.service.FileQuery; import cokr.xit.base.file.service.bean.FileBean; -import cokr.xit.base.file.xls.XLSWriter; -import cokr.xit.base.file.xls.XLSWriter.CellDef; -import cokr.xit.base.file.xls.XLSWriter.Styler; import cokr.xit.base.user.ManagedUser; import cokr.xit.base.user.dao.UserMapper; import cokr.xit.base.web.ApplicationController; @@ -30,6 +32,8 @@ import cokr.xit.fims.cmmn.Print; import cokr.xit.fims.cmmn.PrintOption; import cokr.xit.fims.cmmn.hwp.format.CvlcptOrgn; import cokr.xit.fims.cmmn.service.bean.StngBean; +import cokr.xit.fims.cmmn.xls.FormatMaker; +import cokr.xit.fims.cmmn.xls.StyleMaker; import cokr.xit.fims.crdn.Crdn; import cokr.xit.fims.crdn.CrdnQuery; import cokr.xit.fims.crdn.dao.CrdnStngMapper; @@ -125,49 +129,42 @@ public class Cvlc01Controller extends ApplicationController { query.setSggCd(sggCd); if("xls".equals(query.getDownload())) { - ArrayList cellDefs = fromJson(query.getCellDefs(), new TypeReference>() {}); - - XLSWriter xlsx = new XLSWriter() - .setFilename("민원접수자료 목록.xlsx") - .worksheet(0); - CellStyle center = xlsx.cellStyle(Styler.CENTER); - CellStyle dateYMD = xlsx.yyyy_mm_dd(); - CellStyle dateDT = xlsx.yyyy_mm_dd_hh_mm_ss(); + ArrayList cellDefs = fromJson(query.getCellDefs(), new TypeReference>() {}); - List list = crdnCvlcptService.getCivilComplaintList(query.setFetchSize(0)); + XLSWriter xlsx = new XLSWriter().worksheet(0).trackWidth(CmmnUtil.intArray(cellDefs.size())); + Format format = new Format(xlsx); + CellStyle center = format.cellStyle(new Style().alignment(HorizontalAlignment.CENTER)); + CellStyle left = format.cellStyle(new Style().alignment(HorizontalAlignment.LEFT)); + CellStyle dateYMD = format.yyyy_mm_dd(); + CellStyle dateDT = format.yyyy_mm_dd_hh_mm_ss(); Map valueMap = new HashMap(); - valueMap.put("접수번호", xlsx.style("CVLCPT_RCPT_NO", center)); - valueMap.put("목록번호", xlsx.style("CVLCPT_LIST_NO", center)); - valueMap.put("등록구분", xlsx.style("CRDN_REG_SE_NM", center)); - valueMap.put("신고자", xlsx.style("CVLCPT_APLCNT_NM", center)); - valueMap.put("담당자", xlsx.style("CVLCPT_PRCS_PIC_NM", center)); - valueMap.put("담당자전화번호", xlsx.style("CVLCPT_PRCS_PIC_TELNO", center)); - valueMap.put("접수일자", xlsx.format(o -> xlsx.str2date(o.get("CVLCPT_RCPT_YMD"))).style(dateYMD)); - valueMap.put("처리기한", xlsx.format(o -> { - if(o.get("CVLCPT_PRCS_PRNMNT_DT") != null && ((String)o.get("CVLCPT_PRCS_PRNMNT_DT")).length() > 8) { - return xlsx.str2datetime(o.get("CVLCPT_PRCS_PRNMNT_DT")); - } else { - return xlsx.str2date(o.get("CVLCPT_PRCS_PRNMNT_DT")); - } - }).style(dateDT)); - valueMap.put("위반일시", xlsx.format(o -> xlsx.str2datetime(o.get("CRDN_YMD_TM"))).style(dateDT)); - valueMap.put("위반내용", xlsx.style("VLTN_ARTCL", center)); - valueMap.put("차량번호", "VHRNO"); - valueMap.put("사진건수", xlsx.style("ATCH_FILE_CNT", center)); + valueMap.put("접수번호", center); + valueMap.put("목록번호", center); + valueMap.put("등록구분", format.of("CRDN_REG_SE_NM").style(center)); + valueMap.put("신고자", center); + valueMap.put("담당자", center); + valueMap.put("담당자전화번호", center); + valueMap.put("접수일자", FormatMaker.yyyy_mm_dd(format,dateYMD,"CVLCPT_RCPT_YMD")); + valueMap.put("처리기한", FormatMaker.yyyy_mm_dd_hh_mm_ss(format,dateDT,"CVLCPT_PRCS_PRNMNT_DT")); + valueMap.put("위반일시", FormatMaker.yyyy_mm_dd_hh_mm_ss(format,dateDT,"CRDN_YMD_TM")); + valueMap.put("위반내용", center); + valueMap.put("차량번호", left); + valueMap.put("사진건수", center); CellDef.setValues(cellDefs, valueMap); - xlsx.cell(0, 0) - .value("민원접수자료 목록", center) - .merge(0, cellDefs.size()-1) - .cell(3, 0) - .rowValues(CellDef.header(cellDefs, () -> CmmnUtil.headerStyle(xlsx))) - .cell(4, 0) - .values(list, CellDef.values(cellDefs)); + List list = crdnCvlcptService.getCivilComplaintList(query.setFetchSize(0)); - return new ModelAndView("xlsView").addObject("xls", xlsx) - .addObject("downloadData", list).addObject("dataNames", cellDefs.stream().map(CellDef::getLabel).toList()); + xlsx.cell(0, 0).value("민원접수자료 목록").value(center).merge(0, cellDefs.size()-1); + xlsx.cell(3, 0).rowValues(CellDef.header(cellDefs, () -> StyleMaker.headerStyle(xlsx))); + xlsx.cell(4, 0).values(list, CellDef.values(cellDefs.stream().map(i -> {if(i.getValue() instanceof Format) {i.setField(null);}; return i;}).toList())); + xlsx.autoWidth(); + ModelAndView mav = new ModelAndView("downloadView"); + mav.addObject("download", xlsx.getDownloadable().setFilename("민원접수자료 목록.xlsx")); + mav.addObject("downloadData", list); + mav.addObject("dataNames", cellDefs.stream().map(CellDef::getLabel).toList()); + return mav; } return setCollectionInfo(new ModelAndView("jsonView"), crdnCvlcptService.getCivilComplaintList(query),"","");