From 3ae19995f7ea6c543bb7e92e33f2b5b71ed95255 Mon Sep 17 00:00:00 2001 From: leebeomjun Date: Fri, 15 Dec 2023 14:33:00 +0900 Subject: [PATCH] =?UTF-8?q?=ED=91=9C=EC=A7=80=EC=A0=95=EB=B3=B4=20?= =?UTF-8?q?=EB=AF=B8=ED=99=95=EC=9D=B8=EC=9E=90=EB=A3=8C=20=EC=97=91?= =?UTF-8?q?=EC=85=80=EB=8B=A4=EC=9A=B4=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xit/fims/crdn/web/Crdn03Controller.java | 56 +++++++++++++++++++ .../sql/mapper/fims/crdn/crdn-list-mapper.xml | 1 + .../WEB-INF/jsp/fims/crdn/crdn03010-main.jsp | 14 ++++- 3 files changed, 70 insertions(+), 1 deletion(-) diff --git a/src/main/java/cokr/xit/fims/crdn/web/Crdn03Controller.java b/src/main/java/cokr/xit/fims/crdn/web/Crdn03Controller.java index 1c7ec78e..d6fc58af 100644 --- a/src/main/java/cokr/xit/fims/crdn/web/Crdn03Controller.java +++ b/src/main/java/cokr/xit/fims/crdn/web/Crdn03Controller.java @@ -1,21 +1,28 @@ 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; +import org.apache.poi.ss.usermodel.CellStyle; 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; import cokr.xit.fims.crdn.service.CrdnService; import cokr.xit.fims.crdn.service.CrdnStngService; +import cokr.xit.foundation.data.DataObject; /**표지정보확인 서비스 웹 컨트롤러.
* {웹 컨텍스트}/crdn/crdn03 로 접근할 수 있다. @@ -72,6 +79,55 @@ public class Crdn03Controller extends ApplicationController { String sggCd = globalStngMapper.selectSggCd(curDeptCode); query.setSggCd(sggCd); + + if("xls".equals(query.getDownload())) { + 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); + } + + XLSWriter xlsx = new XLSWriter() + .setFilename("표지정보미확인자료 목록.xlsx") + .worksheet(0); + List headerStylers = CmmnUtil.makeHeadersByDiffrentWidths(widths, xlsx); + CellStyle numeric = xlsx.n_nn0(); + + xlsx.cell(0, 0) + .value("표지정보미확인자료 목록", XLSWriter.Styler.CENTER) + .merge(0, titles.size()-1) + .cell(3, 0) + .rowValues(CmmnUtil.mergeListByIndex(titles, headerStylers)); + + List list = crdnService.getCrackdownList(query.setFetchSize(0)); + + BiFunction getValue = (titleNm, noting) -> { + switch(titleNm) { + case "자료출처": return "CRDN_INPT_SE_NM"; + case "위반일시": return xlsx.format(o -> xlsx.str2datetime(o.get("CRDN_YMD_TM"))); + case "차량번호": return "VHRNO"; + case "법정동": return "CRDN_STDG_NM"; + case "잔액": return xlsx.style("BLNC", numeric); + case "사진건수": return "ATCH_FILE_CNT"; + case "발행번호": return "CRDN_SN"; + } + return ""; + }; + + xlsx.cell(4, 0) + .values(list, titles.stream().map((item) -> { return getValue.apply(item, null); }).toArray()); + + return new ModelAndView("xlsView").addObject("xls", xlsx); + } + return setCollectionInfo(new ModelAndView("jsonView"), crdnService.getCrackdownList(query),""); } 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 0b9f49b9..4caed824 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 @@ -391,6 +391,7 @@ SELECT C.CRDN_ID , C.SGG_CD , C.TASK_SE_CD , C.CRDN_INPT_SE_CD + , (SELECT GET_CODE_NM('FIM003', C.CRDN_INPT_SE_CD) FROM DUAL) AS CRDN_INPT_SE_NM , CONCAT(C.CRDN_YMD,'',C.CRDN_TM) AS CRDN_YMD_TM , C.VHRNO , C.CRDN_STDG_NM diff --git a/src/main/webapp/WEB-INF/jsp/fims/crdn/crdn03010-main.jsp b/src/main/webapp/WEB-INF/jsp/fims/crdn/crdn03010-main.jsp index 98c99474..64d1b80f 100644 --- a/src/main/webapp/WEB-INF/jsp/fims/crdn/crdn03010-main.jsp +++ b/src/main/webapp/WEB-INF/jsp/fims/crdn/crdn03010-main.jsp @@ -300,7 +300,19 @@ $(document).ready(function(){ **************************************************************************/ $('#btnReset--${pageName}').on('click', () => $P.fnReset()); $('#btnSearch--${pageName}').on('click', () => $P.searchCrdnList()); - + $('#btnExcel--${pageName}').on('click', function(){ + + if($P.crdnControl.dataset.empty){ + alert("조회된 자료가 없습니다."); + return; + } + + var headerInfo = $("#crdnTheadTr--${pageName} th").not(".dummy-th").not(":eq(0)").getHeaderInfo(); + $P.crdnControl.query.excelTitle = headerInfo.excelTitle; + $P.crdnControl.query.excelTitleWidth = headerInfo.excelTitleWidth; + $P.crdnControl.download(); + }); + fnMakeScrollableTable($("#table-responsive--${pageName}")[0], $P.scrollCrdnList); $('#btnUpdateToConfirmData--${pageName}').on('click', () => {