diff --git a/src/main/java/cokr/xit/adds/nims/dao/DsuseMgtStatisticsMapper.java b/src/main/java/cokr/xit/adds/nims/dao/DsuseMgtStatisticsMapper.java index 0b63570..e110755 100644 --- a/src/main/java/cokr/xit/adds/nims/dao/DsuseMgtStatisticsMapper.java +++ b/src/main/java/cokr/xit/adds/nims/dao/DsuseMgtStatisticsMapper.java @@ -20,4 +20,10 @@ public interface DsuseMgtStatisticsMapper extends AbstractMapper { */ List selectDsuseMgtNcrdAndPrtmStatistics(DsuseMgtStatisticsQuery query); + /** + * 제품별 폐기 현황 + * @return 마약/항정 and 중점/일반 별 통계 목록 + */ + List selectDsuseMgtDsuseQyByPrdStatistics(DsuseMgtStatisticsQuery query); + } diff --git a/src/main/java/cokr/xit/adds/nims/service/AddsNimsService.java b/src/main/java/cokr/xit/adds/nims/service/AddsNimsService.java index b45bf6e..f960eb0 100644 --- a/src/main/java/cokr/xit/adds/nims/service/AddsNimsService.java +++ b/src/main/java/cokr/xit/adds/nims/service/AddsNimsService.java @@ -12,4 +12,5 @@ public interface AddsNimsService { List getDsuseMgtRsltImgList(DsuseMgtRsltQuery query); List getDsuseMgtNcrdAndPrtmStatistics(DsuseMgtStatisticsQuery query); + List getDsuseMgtDsuseQyByPrdStatistics(DsuseMgtStatisticsQuery query); } diff --git a/src/main/java/cokr/xit/adds/nims/service/bean/AddsNimsServiceBean.java b/src/main/java/cokr/xit/adds/nims/service/bean/AddsNimsServiceBean.java index fa77ef3..30ecb67 100644 --- a/src/main/java/cokr/xit/adds/nims/service/bean/AddsNimsServiceBean.java +++ b/src/main/java/cokr/xit/adds/nims/service/bean/AddsNimsServiceBean.java @@ -42,4 +42,9 @@ public class AddsNimsServiceBean extends AbstractServiceBean implements AddsNims public List getDsuseMgtNcrdAndPrtmStatistics(DsuseMgtStatisticsQuery query) { return dsuseMgtStatisticsMapper.selectDsuseMgtNcrdAndPrtmStatistics(query); } + + @Override + public List getDsuseMgtDsuseQyByPrdStatistics(DsuseMgtStatisticsQuery query) { + return dsuseMgtStatisticsMapper.selectDsuseMgtDsuseQyByPrdStatistics(query); + } } 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 1b33a94..f49fdeb 100644 --- a/src/main/java/cokr/xit/adds/nims/web/AddsNimsController.java +++ b/src/main/java/cokr/xit/adds/nims/web/AddsNimsController.java @@ -351,52 +351,101 @@ public class AddsNimsController extends ApplicationController { //------------------------------------------------------------------------------------------------- @RequestMapping(value = "/getDsuseMgtNcrdAndPrtmStatistics.do", name="마약/항정 and 중점/일반 별 통계") 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); + if(!"xls".equals(query.getDownload())) { + return setCollectionInfo(new ModelAndView("jsonView"), + addsNimsService.getDsuseMgtNcrdAndPrtmStatistics(query), "", ""); + } + + 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()); + } + + @RequestMapping(value = "/getDsuseMgtDsuseQyByPrdStatistics.do", name="제품별 폐기 현황 통계") + public ModelAndView getDsuseMgtDsuseQyByPrdStatistics(DsuseMgtStatisticsQuery query) { + if(!"xls".equals(query.getDownload())) { + return setCollectionInfo(new ModelAndView("jsonView"), + addsNimsService.getDsuseMgtDsuseQyByPrdStatistics(query), "", ""); + } + 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.getDsuseMgtDsuseQyByPrdStatistics(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()); } //------------------------------------------------------------------------------------------------- // 보고 문서 관리 @@ -460,14 +509,24 @@ public class AddsNimsController extends ApplicationController { return mav; } - @RequestMapping(value = "/dsuseMgtStatistics.do", name="폐기관리 통계 메인") + @RequestMapping(value = "/dsuseMgtNcrdAndPrtmStatistics.do", name="마약류 구분별 통계 메인") public ModelAndView dsuseMgtStatistics() { - ModelAndView mav = new ModelAndView("adds/nims/dsuseMgtStatistics-main"); + ModelAndView mav = new ModelAndView("adds/nims/dsuseMgtNcrdAndPrtmStatistics-main"); + setCmmCode("ADDS11", mav); + List deptList = sggDeptService.getDepartmentList(new DepartmentQuery()); + mav.addObject("DEPTList", deptList); + + return mav.addObject("pageName", "dsuseMgtNcrdAndPrtmStatistics") /* View(jsp)에서 사용할 id 뒤에 붙일 suffix */; + } + + @RequestMapping(value = "/dsuseMgtDsuseQyByPrdStatistics.do", name="마약류 제품별 폐기 현황 메인") + public ModelAndView dsuseMgtDsuseQyByPrdStatistics() { + ModelAndView mav = new ModelAndView("adds/nims/dsuseMgtDsuseQyByPrdStatistics-main"); setCmmCode("ADDS11", mav); List deptList = sggDeptService.getDepartmentList(new DepartmentQuery()); mav.addObject("DEPTList", deptList); - return mav.addObject("pageName", "dsuseMgtStatistics") /* View(jsp)에서 사용할 id 뒤에 붙일 suffix */; + return mav.addObject("pageName", "dsuseMgtDsuseQyByPrdStatistics") /* View(jsp)에서 사용할 id 뒤에 붙일 suffix */; } //------------------------------------------------------------------------------------------------- // menu 호출 처리 diff --git a/src/main/resources/sql/mapper/adds/nims/dsuseMgtStatistics-mapper.xml b/src/main/resources/sql/mapper/adds/nims/dsuseMgtStatistics-mapper.xml index a59a309..61a071b 100644 --- a/src/main/resources/sql/mapper/adds/nims/dsuseMgtStatistics-mapper.xml +++ b/src/main/resources/sql/mapper/adds/nims/dsuseMgtStatistics-mapper.xml @@ -16,9 +16,22 @@ , IF(tpi.prtm_se_nm = '일반관리대상', 1, 0) AS '일반관리대상' , IF(tpi.prtm_se_nm = '중점관리대상', 1, 0) AS '중점관리대상' , COUNT(tpi.prduct_cd) OVER(PARTITION BY tdm.dept_cd) AS TOTAL - FROM tb_dsuse_mgt tdm - JOIN tb_dsuse_mgt_dtl tdmd ON tdm.dscdmng_id = tdmd.dscdmng_id - JOIN tb_prduct_info tpi ON tdmd.prduct_cd = tpi.prduct_cd + FROM tb_dsuse_mgt tdm + JOIN tb_dsuse_mgt_dtl tdmd ON tdm.dscdmng_id = tdmd.dscdmng_id + JOIN tb_prduct_info tpi ON tdmd.prduct_cd = tpi.prduct_cd + WHERE tdm.use_yn = 'Y' + + AND tdm.dept_cd = #{schSggCd} + + + AND tdm.dsuse_de =]]> #{schDateFrom} + + + AND tdm.dsuse_de #{schDateTo} + + + AND tdm.prgrs_stts_cd = #{schSttsCd} + ) SELECT T.* , ROW_NUMBER() over (ORDER BY T.dept_cd) AS ROW_NUM @@ -35,9 +48,9 @@ , SUM(tgt.일반관리대상) AS '일반관리대상' , SUM(tgt.중점관리대상) AS '중점관리대상' , SUM(tgt.비마약류 + tgt.일반관리대상 + tgt.중점관리대상) AS '중점일반계' - FROM tgt - GROUP BY tgt.dept_cd - UNION ALL + FROM tgt + GROUP BY tgt.dept_cd + UNION ALL SELECT 'TOTAL' AS dept_cd , SUM(tgt.대마) AS '대마' , SUM(tgt.마약) AS '마약' @@ -50,10 +63,72 @@ , SUM(tgt.일반관리대상) AS '일반관리대상' , SUM(tgt.중점관리대상) AS '중점관리대상' , SUM(tgt.비마약류 + tgt.일반관리대상 + tgt.중점관리대상) AS '중점일반계' - FROM tgt + FROM tgt ) T LEFT JOIN tb_dept td ON T.dept_cd = td.dept_cd + diff --git a/src/main/webapp/WEB-INF/jsp/adds/nims/dsuseMgtDsuseQyByPrdStatistics-main.jsp b/src/main/webapp/WEB-INF/jsp/adds/nims/dsuseMgtDsuseQyByPrdStatistics-main.jsp new file mode 100644 index 0000000..cc4067c --- /dev/null +++ b/src/main/webapp/WEB-INF/jsp/adds/nims/dsuseMgtDsuseQyByPrdStatistics-main.jsp @@ -0,0 +1,383 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" isELIgnored="false" session="false"%> +<%@ include file="/WEB-INF/jsp/include/taglib.jsp"%> +폐기 보고 확인 + +
+ +
+ +
+ +
+
+
+ +
+
+ +
+
+
+
+
+
+ + +
+ +
+ + +
+ + +
+ + + diff --git a/src/main/webapp/WEB-INF/jsp/adds/nims/dsuseMgtStatistics-main.jsp b/src/main/webapp/WEB-INF/jsp/adds/nims/dsuseMgtNcrdAndPrtmStatistics-main.jsp similarity index 92% rename from src/main/webapp/WEB-INF/jsp/adds/nims/dsuseMgtStatistics-main.jsp rename to src/main/webapp/WEB-INF/jsp/adds/nims/dsuseMgtNcrdAndPrtmStatistics-main.jsp index b2d84f0..552b554 100644 --- a/src/main/webapp/WEB-INF/jsp/adds/nims/dsuseMgtStatistics-main.jsp +++ b/src/main/webapp/WEB-INF/jsp/adds/nims/dsuseMgtNcrdAndPrtmStatistics-main.jsp @@ -11,7 +11,7 @@