From 91f9aca222f5f445021a8b4932cd2ee5af977a5b Mon Sep 17 00:00:00 2001 From: leebj Date: Tue, 23 Jul 2024 13:15:16 +0900 Subject: [PATCH] =?UTF-8?q?=ED=86=B5=EA=B3=84=20=EC=A0=95=EB=A0=AC=20?= =?UTF-8?q?=EC=88=98=EC=A0=95,=20=ED=8F=B0=ED=8A=B8=20=EC=88=98=EC=A0=95,?= =?UTF-8?q?=20=EC=97=91=EC=85=80=EC=A0=80=EC=9E=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../adds/nims/DsuseMgtStatisticsQuery.java | 19 +++++-- .../xit/adds/nims/web/AddsNimsController.java | 52 ++++++++++++++++++- .../jsp/adds/nims/dsuseMgtStatistics-main.jsp | 43 ++++++++++----- 3 files changed, 97 insertions(+), 17 deletions(-) diff --git a/src/main/java/cokr/xit/adds/nims/DsuseMgtStatisticsQuery.java b/src/main/java/cokr/xit/adds/nims/DsuseMgtStatisticsQuery.java index 509c919..198cd18 100644 --- a/src/main/java/cokr/xit/adds/nims/DsuseMgtStatisticsQuery.java +++ b/src/main/java/cokr/xit/adds/nims/DsuseMgtStatisticsQuery.java @@ -9,6 +9,8 @@ public class DsuseMgtStatisticsQuery extends QueryRequest{ private static final long serialVersionUID = 1L; + private String cellDefs; + //검색조건 private String schSggCd; // 관활 관청 private String schDateFrom; // 검색 일자 시작 @@ -20,6 +22,15 @@ public class DsuseMgtStatisticsQuery extends QueryRequest{ private String useYn; // 사용 여부 private String nimsRptYn; // NIMS 보고 여부 + public String getCellDefs() { + return ifEmpty(cellDefs, () -> null); + } + + public T setCellDefs(String cellDefs) { + this.cellDefs = cellDefs; + return self(); + } + public String getNimsRptYn() { return ifEmpty(nimsRptYn, () -> null); } @@ -55,7 +66,7 @@ public class DsuseMgtStatisticsQuery extends QueryRequest{ this.schDateTo = schDateTo; return self(); } - + public String getSchBsshCd() { return ifEmpty(schBsshCd, () -> null); } @@ -64,7 +75,7 @@ public class DsuseMgtStatisticsQuery extends QueryRequest{ this.schBsshCd = schBsshCd; return self(); } - + public String getSchSttsCd() { return ifEmpty(schSttsCd, () -> null); } @@ -73,7 +84,7 @@ public class DsuseMgtStatisticsQuery extends QueryRequest{ this.schSttsCd = schSttsCd; return self(); } - + public String getdeptCd() { return ifEmpty(deptCd, () -> null); } @@ -91,7 +102,7 @@ public class DsuseMgtStatisticsQuery extends QueryRequest{ this.userId = userId; return self(); } - + public String getuseYn() { return ifEmpty(useYn, () -> null); } diff --git a/src/main/java/cokr/xit/adds/nims/web/AddsNimsController.java b/src/main/java/cokr/xit/adds/nims/web/AddsNimsController.java index 75e02ab..1b33a94 100644 --- a/src/main/java/cokr/xit/adds/nims/web/AddsNimsController.java +++ b/src/main/java/cokr/xit/adds/nims/web/AddsNimsController.java @@ -19,6 +19,10 @@ import java.util.stream.IntStream; 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.json.simple.JSONObject; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Controller; @@ -49,7 +53,12 @@ import cokr.xit.adds.nims.service.DsuseMgtDocService; import cokr.xit.adds.nims.service.DsuseMgtReceiptService; import cokr.xit.applib.Print; import cokr.xit.applib.PrintOption; +import cokr.xit.applib.xls.StyleMaker; 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.FileInfo; import cokr.xit.base.file.FileInfo.Relation; import cokr.xit.base.file.service.FileQuery; @@ -344,7 +353,48 @@ public class AddsNimsController extends ApplicationController { public ModelAndView getDsuseMgtNcrdAndPrtmStatistics(DsuseMgtStatisticsQuery query) { //query.setOrderBy("dsuse_de DESC, dsuse_mth_cd, dscdmng_id"); //setFetchSize(query); - + if("xls".equals(query.getDownload())) { + List cellDefs = fromJson(query.getCellDefs(), CellDef.listType()); + XLSWriter xlsx = new XLSWriter().worksheet(0); + Format format = new Format(xlsx); + CellStyle center = format.cellStyle(Style.CENTER); + CellStyle numeric = format.n_nn0(); + + List list = addsNimsService.getDsuseMgtNcrdAndPrtmStatistics(query); + + Map valueMap = new HashMap(); + valueMap.put("관할관청", format.of("dept_nm").style(center)); + valueMap.put("대마", format.of("대마").style(numeric)); + valueMap.put("마약", format.of("마약").style(numeric)); + valueMap.put("한외마약", format.of("한외마약").style(numeric)); + valueMap.put("향정", format.of("향정").style(numeric)); + valueMap.put("향정제외", format.of("향정제외").style(numeric)); + valueMap.put("기타", format.of("기타").style(numeric)); + valueMap.put("계", format.of("마약향정계").style(numeric)); + valueMap.put("비마약류", format.of("비마약류").style(numeric)); + valueMap.put("일반관리대상", format.of("일반관리대상").style(numeric)); + valueMap.put("중점관리대상", format.of("중점관리대상").style(numeric)); + valueMap.put("계", format.of("중점일반계").style(numeric)); + + CellDef.setValues(cellDefs, valueMap); + + Style headerStyle2 = new Style().foregroundColor(HSSFColor.HSSFColorPredefined.GREY_50_PERCENT.getIndex()) + .configure(styl -> { + Font font = xlsx.workbook().createFont(); + font.setColor(HSSFColor.HSSFColorPredefined.BLACK.getIndex()); + styl.alignment(HorizontalAlignment.CENTER); + }); + + xlsx.cell(0, 0).value("폐기보고 통계").value(center).merge(0, cellDefs.size()-1); + xlsx.cell(2, 1).value("마약/향정 구분").value(headerStyle2).merge(1, 7); + xlsx.cell(2, 8).value("중점/일반 구분").value(headerStyle2).merge(8, 11); + 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())); + + ModelAndView mav = new ModelAndView("downloadView"); + mav.addObject("download", xlsx.getDownloadable().setFilename("폐기보고 통계.xlsx")); + return mav.addObject("downloadData", list).addObject("dataNames", cellDefs.stream().map(CellDef::getLabel).toList()); + } return setCollectionInfo(new ModelAndView("jsonView"), addsNimsService.getDsuseMgtNcrdAndPrtmStatistics(query),"",""); // return addsNimsService.getDsuseMgtNcrdAndPrtmStatistics(query); } diff --git a/src/main/webapp/WEB-INF/jsp/adds/nims/dsuseMgtStatistics-main.jsp b/src/main/webapp/WEB-INF/jsp/adds/nims/dsuseMgtStatistics-main.jsp index 5a488ef..b2d84f0 100644 --- a/src/main/webapp/WEB-INF/jsp/adds/nims/dsuseMgtStatistics-main.jsp +++ b/src/main/webapp/WEB-INF/jsp/adds/nims/dsuseMgtStatistics-main.jsp @@ -56,10 +56,18 @@ + +
+
+ +
+
@@ -74,9 +82,9 @@
- - - + + + @@ -90,17 +98,17 @@ - + - +