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 9485ebe..ffd784c 100644 --- a/src/main/java/cokr/xit/adds/nims/web/AddsNimsController.java +++ b/src/main/java/cokr/xit/adds/nims/web/AddsNimsController.java @@ -365,49 +365,7 @@ public class AddsNimsController extends ApplicationController { 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 right = format.cellStyle(Style.RIGHT); - CellStyle numeric = format.n_nn0(); - - List list = addsNimsService.getDsuseMgtNcrdAndPrtmStatistics(query); - - Map valueMap = new HashMap<>(); - valueMap.put("관할관청", format.of("dept_nm").style(center)); - valueMap.put("대마", a_slash_ab(format, "대마", "Qy").style(right)); - valueMap.put("마약", a_slash_ab(format, "마약", "Qy").style(right)); - valueMap.put("한외마약", a_slash_ab(format, "한외마약", "Qy").style(right)); - valueMap.put("향정", a_slash_ab(format, "향정", "Qy").style(right)); - valueMap.put("향정제외", a_slash_ab(format, "향정제외", "Qy").style(right)); - valueMap.put("기타", a_slash_ab(format, "기타", "Qy").style(right)); - valueMap.put("마약향정계", a_slash_ab(format, "마약향정계", "Qy").style(numeric)); - valueMap.put("비마약류", a_slash_ab(format, "비마약류", "Qy").style(right)); - valueMap.put("일반관리대상", a_slash_ab(format, "일반관리대상", "Qy").style(right)); - valueMap.put("중점관리대상", a_slash_ab(format, "중점관리대상", "Qy").style(right)); - valueMap.put("중점일반계", a_slash_ab(format, "중점일반계", "Qy").style(right)); - - 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 excelDownloadDsuseMgtNcrdAndPrtmStatistics(query); } @RequestMapping(value = "/getDsuseMgtDsuseQyByPrdStatistics.do", name="제품별 폐기 현황 통계") @@ -416,47 +374,7 @@ public class AddsNimsController extends ApplicationController { 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("prduct_cd").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 excelDownloadDsuseMgtDsuseQyByPrdStatistics(query); } @RequestMapping(value = "/getDsuseMgtDsuseQyByIndutyStatistics.do", name="취급자 업종별 폐기 현황 통계") @@ -514,53 +432,59 @@ public class AddsNimsController extends ApplicationController { return setCollectionInfo(new ModelAndView("jsonView"), addsNimsService.getDsuseMgtDsuseQyByBsshStatistics(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.getDsuseMgtDsuseQyByBsshStatistics(query); + return excelDownloadDsuseMgtDsuseQyByBsshStatistics(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)); + //------------------------------------------------------------------------------------------------- + // ApiKey 관리 + //------------------------------------------------------------------------------------------------- + @RequestMapping(value = "/apiKey-list.do", name="apiKey 관리 조회") + public ModelAndView getApiKeyList(ApiKeyQuery query) { + setFetchSize(query); - CellDef.setValues(cellDefs, valueMap); + return setCollectionInfo(new ModelAndView("jsonView"), apiKeyService.getApiKeyList(query),"",""); + } - 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); - }); + @RequestMapping(value = "/apiKey-info.do", name="apiKey 관리 상세") + public ModelAndView getApiKeyInfo(ApiKeyQuery query) { + ModelAndView mav = new ModelAndView("adds/nims/apiKey-info"); + List deptList = sggDeptService.getDepartmentList(new DepartmentQuery()); + mav.addObject("DEPTList", deptList); + mav.addObject("apiKeyInfo", toJson(query)); - 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())); + return mav.addObject("pageName", "apiKeyInfoPopup"); // View(jsp)에서 사용할 id 뒤에 붙일 suffix + } - ModelAndView mav = new ModelAndView("downloadView"); - mav.addObject("download", xlsx.getDownloadable().setFilename("취급자별 폐기 현황.xlsx")); + @RequestMapping(value = "/updateApiKey.do", name="apiKey 수정") + public ModelAndView updateApiKey(ApiKeyQuery query) { + boolean saved = false; + String rtnMsg = apiKeyService.updateApiKey(query); + if(rtnMsg.contains("[S]")) { + saved = true; + } + return new ModelAndView("jsonView") + .addObject("saved", saved) + .addObject("rtnMsg", rtnMsg); + } - return mav.addObject("downloadData", list).addObject("dataNames", cellDefs.stream().map(CellDef::getLabel).toList()); + @RequestMapping(value = "/inertApiKey.do", name="apiKey 등록") + public ModelAndView insertApiKey(ApiKeyQuery query) { + boolean saved = false; + String rtnMsg = apiKeyService.createApiKey(query); + if(rtnMsg.contains("[S]")) { + saved = true; + } + return new ModelAndView("jsonView") + .addObject("saved", saved) + .addObject("rtnMsg", rtnMsg); } //------------------------------------------------------------------------------------------------- - // 보고 문서 관리 + // ApiKey 관리 //------------------------------------------------------------------------------------------------- - - + //------------------------------------------------------------------------------------------------- // menu 처리 //------------------------------------------------------------------------------------------------- @@ -657,6 +581,17 @@ public class AddsNimsController extends ApplicationController { return mav.addObject("pageName", "dsuseMgtDsuseQyByBsshStatistics") /* View(jsp)에서 사용할 id 뒤에 붙일 suffix */; } + + @RequestMapping(value = "/apiKeyMain.do", name="apiKey 관리 메인") + public ModelAndView apiKeyMain() { + + ModelAndView mav = new ModelAndView("adds/nims/apiKey-main"); + + List deptList = sggDeptService.getDepartmentList(new DepartmentQuery()); + mav.addObject("DEPTList", deptList); + + return mav.addObject("pageName", "apiKeyMain") /* View(jsp)에서 사용할 id 뒤에 붙일 suffix */; + } //------------------------------------------------------------------------------------------------- // menu 호출 처리 //------------------------------------------------------------------------------------------------- @@ -691,62 +626,6 @@ public class AddsNimsController extends ApplicationController { // 마약류폐기보고 팝업 //------------------------------------------------------------------------------------------------- - //------------------------------------------------------------------------------------------------- - // ApiKey 관리 - //------------------------------------------------------------------------------------------------- - @RequestMapping(value = "/apiKeyMain.do", name="apiKey 관리 메인") - public ModelAndView apiKeyMain() { - - ModelAndView mav = new ModelAndView("adds/nims/apiKey-main"); - - List deptList = sggDeptService.getDepartmentList(new DepartmentQuery()); - mav.addObject("DEPTList", deptList); - - return mav.addObject("pageName", "apiKeyMain") /* View(jsp)에서 사용할 id 뒤에 붙일 suffix */; - } - - @RequestMapping(value = "/apiKey-list.do", name="apiKey 관리 조회") - public ModelAndView getApiKeyList(ApiKeyQuery query) { - setFetchSize(query); - - return setCollectionInfo(new ModelAndView("jsonView"), apiKeyService.getApiKeyList(query),"",""); - } - - @RequestMapping(value = "/apiKey-info.do", name="apiKey 관리 상세") - public ModelAndView getApiKeyInfo(ApiKeyQuery query) { - ModelAndView mav = new ModelAndView("adds/nims/apiKey-info"); - List deptList = sggDeptService.getDepartmentList(new DepartmentQuery()); - mav.addObject("DEPTList", deptList); - mav.addObject("apiKeyInfo", toJson(query)); - - return mav.addObject("pageName", "apiKeyInfoPopup"); // View(jsp)에서 사용할 id 뒤에 붙일 suffix - } - - @RequestMapping(value = "/updateApiKey.do", name="apiKey 수정") - public ModelAndView updateApiKey(ApiKeyQuery query) { - boolean saved = false; - String rtnMsg = apiKeyService.updateApiKey(query); - if(rtnMsg.contains("[S]")) { - saved = true; - } - return new ModelAndView("jsonView") - .addObject("saved", saved) - .addObject("rtnMsg", rtnMsg); - } - - @RequestMapping(value = "/inertApiKey.do", name="apiKey 등록") - public ModelAndView insertApiKey(ApiKeyQuery query) { - boolean saved = false; - String rtnMsg = apiKeyService.createApiKey(query); - if(rtnMsg.contains("[S]")) { - saved = true; - } - return new ModelAndView("jsonView") - .addObject("saved", saved) - .addObject("rtnMsg", rtnMsg); - } - - //------------------------------------------------------------------------------------------------- // API server call //------------------------------------------------------------------------------------------------- @@ -1084,16 +963,200 @@ public class AddsNimsController extends ApplicationController { byteOut.write((dsuseMgtJsonStr + lineSeparator).getBytes(StandardCharsets.UTF_8)); } + private ModelAndView excelDownloadDsuseMgtNcrdAndPrtmStatistics(DsuseMgtStatisticsQuery 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 right = format.cellStyle(Style.RIGHT); + + List list = addsNimsService.getDsuseMgtNcrdAndPrtmStatistics(query); + + Map valueMap = new HashMap<>(); + valueMap.put("관할관청", format.of("dept_nm").style(center)); + valueMap.put("대마", a_slash_ab(format, "대마", "대마Qy").style(right)); + valueMap.put("마약", a_slash_ab(format, "마약", "마약Qy").style(right)); + valueMap.put("한외마약", a_slash_ab(format, "한외마약", "한외마약Qy").style(right)); + valueMap.put("향정", a_slash_ab(format, "향정", "향정Qy").style(right)); + valueMap.put("향정제외", a_slash_ab(format, "향정제외", "향정제외Qy").style(right)); + valueMap.put("기타", a_slash_ab(format, "기타", "기타Qy").style(right)); + valueMap.put("마약향정계", a_slash_ab(format, "마약향정계", "마약향정계Qy").style(right)); + valueMap.put("비마약류", a_slash_ab(format, "비마약류", "비마약류Qy").style(right)); + valueMap.put("일반관리대상", a_slash_ab(format, "일반관리대상", "일반관리대상Qy").style(right)); + valueMap.put("중점관리대상", a_slash_ab(format, "중점관리대상", "중점관리대상Qy").style(right)); + valueMap.put("중점일반계", a_slash_ab(format, "중점일반계", "중점일반계Qy").style(right)); + + 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()); + } + + private ModelAndView excelDownloadDsuseMgtDsuseQyByPrdStatistics(DsuseMgtStatisticsQuery 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 right = format.cellStyle(Style.RIGHT); + CellStyle left = format.cellStyle(Style.LEFT); + CellStyle numeric = format.cellStyle(Style.N_NN0); + + List list = addsNimsService.getDsuseMgtDsuseQyByPrdStatistics(query); + + Map valueMap = new HashMap(); + valueMap.put("No.", format.of("ROW_NUM").style(center)); + valueMap.put("관할관청", format.of("dept_nm").style(center)); + valueMap.put("제품코드", format.of("prduct_cd").style(center)); + valueMap.put("제품명", format.of("prduct_nm").style(left)); + valueMap.put("신청서접수", a_slash_ab(format, "receiptCnt", "receiptQy").style(right)); + valueMap.put("결과[통보]처리", a_slash_ab(format, "rsltCnt", "rsltQy").style(right)); + valueMap.put("폐기보고확인", a_slash_ab(format, "mappingCnt", "mappingQy").style(right)); + valueMap.put("보고완료", a_slash_ab(format, "cpltCnt", "cpltQy").style(right)); + valueMap.put("폐기건수", format.of("dsuseCnt").style(numeric)); + valueMap.put("폐기수량", format.of("dsuseQy").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()); + } + + private ModelAndView excelDownloadDsuseMgtDsuseQyByIndutyStatistics(DsuseMgtStatisticsQuery 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 right = format.cellStyle(Style.RIGHT); + CellStyle numeric = format.cellStyle(Style.N_NN0); + + List list = addsNimsService.getDsuseMgtDsuseQyByIndutyStatistics(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()); + } + + private ModelAndView excelDownloadDsuseMgtDsuseQyByBsshStatistics(DsuseMgtStatisticsQuery 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 right = format.cellStyle(Style.RIGHT); + CellStyle numeric = format.cellStyle(Style.N_NN0); + + List list = addsNimsService.getDsuseMgtDsuseQyByBsshStatistics(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()); + } + private static Format a_slash_ab(Format format, String a, String b) { return format.of(a).value((o) -> { //return ((Map)o).get(a) + " / " + ((Map)o).get(a + b); Number aa = (Number)((Map)o).get(a); - Number bb = (Number)((Map)o).get(a + b); + Number bb = (Number)((Map)o).get(b); //return aa.intValue() + " / " + bb.intValue(); NumberFormat nf = NumberFormat.getInstance(); return nf.format(aa.intValue()) + " / " + nf.format(bb.intValue()); }); } + + //------------------------------------------------------------------------------------------------- // private method //------------------------------------------------------------------------------------------------- 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 index 960fd99..1ee1736 100644 --- a/src/main/webapp/WEB-INF/jsp/adds/nims/dsuseMgtDsuseQyByPrdStatistics-main.jsp +++ b/src/main/webapp/WEB-INF/jsp/adds/nims/dsuseMgtDsuseQyByPrdStatistics-main.jsp @@ -296,13 +296,18 @@ return; } - // DataTables(그리드) - let cellDefs = getCellDefs( - $("#theadTr0--${pageName} th, #theadTr--${pageName} th") - .not(".dummy-th").not("[colspan]"), + // 처음 4개의 th 요소 선택 + let firstColNames = $(`#theadTr0--${pageName} th`).not("[colspan]").slice(0, 4); + // 중간의 th 요소 선택 + let middleColNames = $(`#theadTr--${pageName} th`).not(".dummy-th").not("[colspan]"); + // 끝에서 2개의 th 요소 선택 + let lastColNames = $(`#theadTr0--${pageName} th`).not("[colspan]").slice(-2); + + $P.control.query.cellDefs = getCellDefs2( + [...firstColNames, ...middleColNames, ...lastColNames], $($("#${infoPrefix}Row--${pageName}")[0].content).find("td") - .not(".dummy-td").not(":eq(0)").not("[colspan]")); - $P.control.query.cellDefs = cellDefs; + .not(".dummy-td").not(":eq(0)").not("[colspan]") + ); $P.control.download(); } @@ -378,4 +383,43 @@ $P.fnReset(); }); +function getCellDefs2(ths, $tds, fieldGetterOption){ + let cellDefs = []; + + for(let i=0; i < ths.length; i++){ + + let label = $(ths[i]).text(); + label = label.replace("\n", ""); + label = label.replace("\t", ""); + label = label.replace(" ", ""); + + if(label !== ""){ + + let width = $(ths[i]).outerWidth(); + width = Math.ceil(width/10) + 2; + + let field = ""; + if(fieldGetterOption != null){ + field = fieldGetterOption($tds.eq(i)); + } else { + field = $tds.eq(i).text(); + } + + field = field.replace("{", ""); + field = field.replace("}", ""); + field = field.replace("\n", ""); + field = field.replace("\t", ""); + field = field.replace(" ", ""); + + cellDefs.push({ + label : label, + width : width, + field : field + }); + } + + } + + return JSON.stringify(cellDefs); +}