fix: 취급업종별폐기현황, 취급자별폐기현황 엑셀다운로드 구현

dev
Jonguk. Lim 4 months ago
parent 3c991074da
commit 154b6a7f75

@ -384,47 +384,7 @@ public class AddsNimsController extends ApplicationController {
return setCollectionInfo(new ModelAndView("jsonView"),
addsNimsService.getDsuseMgtDsuseQyByIndutyStatistics(query), "", "");
}
List<CellDef> 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<DataObject> list = addsNimsService.getDsuseMgtDsuseQyByIndutyStatistics(query);
Map<String, Object> valueMap = new HashMap<String, Object>();
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 excelDownloadDsuseMgtDsuseQyByIndutyStatistics(query);
}
@RequestMapping(value = "/getDsuseMgtDsuseQyByBsshStatistics.do", name="취급자별 폐기 현황 통계")
@ -975,17 +935,17 @@ public class AddsNimsController extends ApplicationController {
Map<String, Object> 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));
valueMap.put("대마", a_slash_b(format, "대마", "대마Qy").style(right));
valueMap.put("마약", a_slash_b(format, "마약", "마약Qy").style(right));
valueMap.put("한외마약", a_slash_b(format, "한외마약", "한외마약Qy").style(right));
valueMap.put("향정", a_slash_b(format, "향정", "향정Qy").style(right));
valueMap.put("향정제외", a_slash_b(format, "향정제외", "향정제외Qy").style(right));
valueMap.put("기타", a_slash_b(format, "기타", "기타Qy").style(right));
valueMap.put("마약향정계", a_slash_b(format, "마약향정계", "마약향정계Qy").style(right));
valueMap.put("비마약류", a_slash_b(format, "비마약류", "비마약류Qy").style(right));
valueMap.put("일반관리대상", a_slash_b(format, "일반관리대상", "일반관리대상Qy").style(right));
valueMap.put("중점관리대상", a_slash_b(format, "중점관리대상", "중점관리대상Qy").style(right));
valueMap.put("중점일반계", a_slash_b(format, "중점일반계", "중점일반계Qy").style(right));
CellDef.setValues(cellDefs, valueMap);
@ -1007,8 +967,10 @@ public class AddsNimsController extends ApplicationController {
xlsx.cell(2, 0).value("관할관청").value(headerStyle).merge(2, 3, 0, 0);
xlsx.cell(2, 1).value("마약/향정 구분(폐기건수 / 폐기수량)").value(headerStyle2).merge(1, 7);
xlsx.cell(2, 8).value("중점/일반 구분(폐기건수 / 폐기수량)").value(headerStyle2).merge(8, 11);
List<CellDef> cellDefs2 = cellDefs.subList(1, cellDefs.size());
xlsx.cell(3, 1).rowValues(CellDef.header(cellDefs2, () -> StyleMaker.headerStyle(xlsx)));
// data
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");
@ -1029,15 +991,15 @@ public class AddsNimsController extends ApplicationController {
List<DataObject> list = addsNimsService.getDsuseMgtDsuseQyByPrdStatistics(query);
Map<String, Object> valueMap = new HashMap<String, Object>();
Map<String, Object> 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("신청서접수", a_slash_b(format, "receiptCnt", "receiptQy").style(right));
valueMap.put("결과[통보]처리", a_slash_b(format, "rsltCnt", "rsltQy").style(right));
valueMap.put("폐기보고확인", a_slash_b(format, "mappingCnt", "mappingQy").style(right));
valueMap.put("보고완료", a_slash_b(format, "cpltCnt", "cpltQy").style(right));
valueMap.put("폐기건수", format.of("dsuseCnt").style(numeric));
valueMap.put("폐기수량", format.of("dsuseQy").style(numeric));
@ -1066,8 +1028,11 @@ public class AddsNimsController extends ApplicationController {
xlsx.cell(2, 4).value("처리상태 별 (폐기건수 / 폐기수량)").value(headerStyle2).merge(4, 7);
xlsx.cell(2, 8).value("폐기건수").value(headerStyle).merge(2, 3, 8, 8);
xlsx.cell(2, 9).value("폐기수량").value(headerStyle).merge(2, 3, 9, 9);
List<CellDef> cellDefs2 = cellDefs.subList(4, cellDefs.size()-2);
xlsx.cell(3, 4).rowValues(CellDef.header(cellDefs2, () -> StyleMaker.headerStyle(xlsx)));
List<CellDef> cellDefs2 = cellDefs.subList(5, cellDefs.size()-2);
xlsx.cell(3, 5).rowValues(CellDef.header(cellDefs2, () -> StyleMaker.headerStyle(xlsx)));
// data
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");
@ -1087,22 +1052,25 @@ public class AddsNimsController extends ApplicationController {
List<DataObject> list = addsNimsService.getDsuseMgtDsuseQyByIndutyStatistics(query);
Map<String, Object> valueMap = new HashMap<String, Object>();
Map<String, Object> 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));
valueMap.put("마약류취급의료업", a_slash_b(format, "마약류취급의료업", "마약류취급의료업Qy").style(right));
valueMap.put("마약류소매업", a_slash_b(format, "마약류소매업", "마약류소매업Qy").style(right));
valueMap.put("마약류도매업", a_slash_b(format, "마약류도매업", "마약류도매업Qy").style(right));
valueMap.put("마약류제조업", a_slash_b(format, "마약류제조업", "마약류제조업Qy").style(right));
valueMap.put("마약류수출입업", a_slash_b(format, "마약류수출입업", "마약류수출입업Qy").style(right));
valueMap.put("마약류원료사용", a_slash_b(format, "마약류원료사용", "마약류원료사용Qy").style(right));
valueMap.put("마약류취급학술연구", a_slash_b(format, "마약류취급학술연구", "마약류취급학술연구Qy").style(right));
valueMap.put("폐기건수", format.of("dsuseCnt").style(numeric));
valueMap.put("폐기수량", format.of("dsuseQy").style(numeric));
CellDef.setValues(cellDefs, valueMap);
Style headerStyle = new Style().foregroundColor(HSSFColor.HSSFColorPredefined.GREY_25_PERCENT.getIndex())
.configure(styl -> {
styl.alignment(HorizontalAlignment.CENTER);
styl.alignment(VerticalAlignment.CENTER);
});
Style headerStyle2 = new Style().foregroundColor(HSSFColor.HSSFColorPredefined.GREY_50_PERCENT.getIndex())
.configure(styl -> {
Font font = xlsx.workbook().createFont();
@ -1110,10 +1078,16 @@ public class AddsNimsController extends ApplicationController {
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(0, 0).value("마약류 취급 업종별 폐기 현황").value(center).merge(0, cellDefs.size()-1);
xlsx.cell(2, 0).value("관할관청").value(headerStyle).merge(2, 3, 0, 0);
xlsx.cell(2, 1).value("업종별 구분 (폐기건수 / 폐시수량)").value(headerStyle2).merge(1, 7);
xlsx.cell(2, 8).value("폐기건수").value(headerStyle).merge(2, 3, 8, 8);
xlsx.cell(2, 9).value("폐기수량").value(headerStyle).merge(2, 3, 9, 9);
List<CellDef> cellDefs2 = cellDefs.subList(1, cellDefs.size()-2);
xlsx.cell(3, 1).rowValues(CellDef.header(cellDefs2, () -> StyleMaker.headerStyle(xlsx)));
// data
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");
@ -1129,26 +1103,30 @@ public class AddsNimsController extends ApplicationController {
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<DataObject> list = addsNimsService.getDsuseMgtDsuseQyByBsshStatistics(query);
Map<String, Object> valueMap = new HashMap<String, Object>();
Map<String, Object> valueMap = new HashMap<>();
valueMap.put("NO.", format.of("ROW_NUM").style(center));
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));
valueMap.put("취급자번호", format.of("bssh_cd").style(center));
valueMap.put("취급업체명", format.of("bssh_nm").style(left));
valueMap.put("대표자", format.of("rprsntv_nm").style(center));
valueMap.put("신청서접수", a_slash_b(format, "receiptCnt", "receiptQy").style(right));
valueMap.put("폐기결과[통보]처리", a_slash_b(format, "rsltCnt", "rsltQy").style(right));
valueMap.put("폐기보고확인", a_slash_b(format, "mappingCnt", "mappingQy").style(right));
valueMap.put("보고완료", a_slash_b(format, "cpltCnt", "cpltQy").style(right));
valueMap.put("폐기건수", format.of("dsuseCnt").style(numeric));
valueMap.put("폐기수량", format.of("dsuseQy").style(numeric));
CellDef.setValues(cellDefs, valueMap);
Style headerStyle = new Style().foregroundColor(HSSFColor.HSSFColorPredefined.GREY_25_PERCENT.getIndex())
.configure(styl -> {
styl.alignment(HorizontalAlignment.CENTER);
styl.alignment(VerticalAlignment.CENTER);
});
Style headerStyle2 = new Style().foregroundColor(HSSFColor.HSSFColorPredefined.GREY_50_PERCENT.getIndex())
.configure(styl -> {
Font font = xlsx.workbook().createFont();
@ -1156,10 +1134,20 @@ public class AddsNimsController extends ApplicationController {
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(0, 0).value("마약류 취급자별 폐기 현황").value(center).merge(0, cellDefs.size()-1);
xlsx.cell(2, 0).value("NO.").value(headerStyle).merge(2, 3, 0, 0);
xlsx.cell(2, 1).value("관할관청").value(headerStyle).merge(2, 3, 1, 1);
xlsx.cell(2, 2).value("취급자번호").value(headerStyle).merge(2, 3, 2, 2);
xlsx.cell(2, 3).value("취급업체명").value(headerStyle).merge(2, 3, 3, 3);
xlsx.cell(2, 4).value("대표자").value(headerStyle).merge(2, 3, 4, 4);
xlsx.cell(2, 5).value("처리상태 별 (폐기건수 / 폐기수량)").value(headerStyle2).merge(5, 8);
xlsx.cell(2, 9).value("폐기건수").value(headerStyle).merge(2, 3, 9, 9);
xlsx.cell(2, 10).value("폐기수량").value(headerStyle).merge(2, 3, 10, 10);
List<CellDef> cellDefs2 = cellDefs.subList(5, cellDefs.size()-2);
xlsx.cell(3, 5).rowValues(CellDef.header(cellDefs2, () -> StyleMaker.headerStyle(xlsx)));
// data
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");
@ -1169,7 +1157,7 @@ public class AddsNimsController extends ApplicationController {
.addObject("dataNames", cellDefs.stream().map(CellDef::getLabel).toList());
}
private static Format a_slash_ab(Format format, String a, String b) {
private static Format a_slash_b(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);

@ -294,13 +294,18 @@
return;
}
// DataTables(그리드)
let cellDefs = getCellDefs(
$("#theadTr0--${pageName} th, #theadTr--${pageName} th")
.not(".dummy-th").not(":eq(0)").not("[colspan]"),
// 처음 5개의 th 요소 선택
let firstColNames = $(`#theadTr0--${pageName} th`).not("[colspan]").slice(0, 5);
// 중간의 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 = getCellDefs(
$([...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();
}

@ -303,13 +303,18 @@
return;
}
// DataTables(그리드)
let cellDefs = getCellDefs(
$("#theadTr0--${pageName} th, #theadTr--${pageName} th")
.not(".dummy-th").not(":eq(0)").not("[colspan]"),
// 처음 1개의 th 요소 선택
let firstColNames = $(`#theadTr0--${pageName} th`).not("[colspan]").slice(0, 1);
// 중간의 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 = getCellDefs(
$([...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();
}

@ -382,36 +382,4 @@
// 2. 초기 설정 및 업무 구분 변경
$P.fnReset();
});
// function getCellDefs2(ths, $tds, fieldGetterOption){
// let cellDefs = [];
//
// ths.forEach((th, idx) => {
// let label = $(ths).text();
// label = label.replace("\n", "");
// label = label.replace("\t", "");
// label = label.replace(" ", "");
//
// if(label !== ""){
// let field = "";
// if(fieldGetterOption != null){
// field = fieldGetterOption($tds.eq(idx));
// } else {
// field = $tds.eq(idx).text();
// }
// field = field.replace("{", "");
// field = field.replace("}", "");
// field = field.replace("\n", "");
// field = field.replace("\t", "");
// field = field.replace(" ", "");
//
// cellDefs.push({
// label : label,
// width : Math.ceil($(ths).outerWidth()/10) + 2,
// field : field
// });
// }
// });
// return JSON.stringify(cellDefs);
// }
</script>

Loading…
Cancel
Save