fix: 제품 구분별 현황 통계 엑셀 출력 및 화면 출력 fix

dev
Jonguk. Lim 4 months ago
parent 154b6a7f75
commit 4a3257909d

@ -930,6 +930,7 @@ public class AddsNimsController extends ApplicationController {
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<DataObject> list = addsNimsService.getDsuseMgtNcrdAndPrtmStatistics(query);
@ -941,12 +942,11 @@ public class AddsNimsController extends ApplicationController {
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("폐기건수", 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())
@ -965,10 +965,12 @@ public class AddsNimsController extends ApplicationController {
xlsx.cell(0, 1).value("마약류 제품 구분별 현황").value(center).merge(1, cellDefs.size()-1);
// 관할관청 - rowspan
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);
xlsx.cell(2, 1).value("마약/향정 구분(폐기건수 / 폐기수량)").value(headerStyle2).merge(1, 6);
xlsx.cell(2, 7).value("중점/일반 구분(폐기건수 / 폐기수량)").value(headerStyle2).merge(7, 9);
xlsx.cell(2, 10).value("폐기건수").value(headerStyle).merge(2, 3, 10, 10);
xlsx.cell(2, 11).value("폐기수량").value(headerStyle).merge(2, 3, 11, 11);
List<CellDef> cellDefs2 = cellDefs.subList(1, cellDefs.size());
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()));

@ -6,6 +6,10 @@
/* 마약/항정 and 중점/일반 별 통계 */
WITH tgt AS (
SELECT tdm.dept_cd
, tdm.dscdmng_id
, tpi.nrcd_se_nm
, tpi.prtm_se_nm
, tdmd.dsuse_qy
, IF(tpi.nrcd_se_nm = '대마', 1, '0') AS 대마
, IF(tpi.nrcd_se_nm = '마약', 1, '0') AS 마약
, IF(tpi.nrcd_se_nm = '한외마약', 1, '0') AS 한외마약
@ -46,54 +50,50 @@
, IF(td.dept_nm IS NULL, T.dept_cd, dept_nm) AS dept_nm
FROM (
SELECT tgt.dept_cd
, COUNT(tgt.dscdmng_id) AS dsuseCnt
, SUM(tgt.dsuse_qy) AS dsuseQy
, SUM(tgt.대마) AS 대마
, SUM(tgt.마약) AS 마약
, SUM(tgt.한외마약) AS 한외마약
, SUM(tgt.향정) AS 향정
, SUM(tgt.향정제외) AS 향정제외
, SUM(tgt.기타) AS 기타
, SUM(tgt.대마 + tgt.마약 + tgt.한외마약 + tgt.향정 + tgt.향정제외 + tgt.기타) AS 마약향정계
, SUM(tgt.비마약류) AS 비마약류
, SUM(tgt.일반관리대상) AS 일반관리대상
, SUM(tgt.중점관리대상) AS 중점관리대상
, SUM(tgt.비마약류 + tgt.일반관리대상 + tgt.중점관리대상) AS 중점일반계
, SUM(tgt.대마qy) AS 대마qy
, SUM(tgt.마약qy) AS 마약qy
, SUM(tgt.한외마약qy) AS 한외마약qy
, SUM(tgt.향정qy) AS 향정qy
, SUM(tgt.향정제외qy) AS 향정제외qy
, SUM(tgt.기타qy) AS 기타qy
, SUM(tgt.대마qy + tgt.마약qy + tgt.한외마약qy + tgt.향정qy + tgt.향정제외qy + tgt.기타qy) AS 마약향정계qy
, SUM(tgt.비마약류qy) AS 비마약류qy
, SUM(tgt.일반관리대상qy) AS 일반관리대상qy
, SUM(tgt.중점관리대상qy) AS 중점관리대상qy
, SUM(tgt.비마약류qy + tgt.일반관리대상qy + tgt.중점관리대상qy) AS 중점일반계qy
FROM tgt
GROUP BY tgt.dept_cd
UNION ALL
SELECT 'TOTAL' AS dept_cd
, COUNT(tgt.dscdmng_id) AS dsuseCnt
, SUM(tgt.dsuse_qy) AS dsuseQy
, SUM(tgt.대마) AS 대마
, SUM(tgt.마약) AS 마약
, SUM(tgt.한외마약) AS 한외마약
, SUM(tgt.향정) AS 향정
, SUM(tgt.향정제외) AS 향정제외
, SUM(tgt.기타) AS 기타
, SUM(tgt.대마 + tgt.마약 + tgt.한외마약 + tgt.향정 + tgt.향정제외 + tgt.기타) AS 마약향정계
, SUM(tgt.비마약류) AS 비마약류
, SUM(tgt.일반관리대상) AS 일반관리대상
, SUM(tgt.중점관리대상) AS 중점관리대상
, SUM(tgt.비마약류 + tgt.일반관리대상 + tgt.중점관리대상) AS 중점일반계
, SUM(tgt.대마qy) AS 대마qy
, SUM(tgt.마약qy) AS 마약qy
, SUM(tgt.한외마약qy) AS 한외마약qy
, SUM(tgt.향정qy) AS 향정qy
, SUM(tgt.향정제외qy) AS 향정제외qy
, SUM(tgt.기타qy) AS 기타qy
, SUM(tgt.대마qy + tgt.마약qy + tgt.한외마약qy + tgt.향정qy + tgt.향정제외qy + tgt.기타qy) AS 마약향정계qy
, SUM(tgt.비마약류qy) AS 비마약류qy
, SUM(tgt.일반관리대상qy) AS 일반관리대상qy
, SUM(tgt.중점관리대상qy) AS 중점관리대상qy
, SUM(tgt.비마약류qy + tgt.일반관리대상qy + tgt.중점관리대상qy) AS 중점일반계qy
FROM tgt
) T
LEFT JOIN tb_dept td

@ -87,8 +87,10 @@
<thead class="sticky-thead">
<tr id="theadTr0--${pageName}">
<th class="cmn align-content-center p-1" style="width: 170px;" rowspan="2">관할관청</th>
<th class="cmn fw-bold" colspan="7">마약 / 향정 구분 (폐기건수 / 폐기수량)</th>
<th class="cmn fw-bold" colspan="4">중점 / 일반 구분 (폐기건수 / 폐기수량)</th>
<th class="cmn fw-bold" colspan="6">마약 / 향정 구분 (폐기건수 / 폐기수량)</th>
<th class="cmn fw-bold" colspan="3">중점 / 일반 구분 (폐기건수 / 폐기수량)</th>
<th class="cmn align-content-center p-1 text-blue" style="width: 100px;" rowspan="2">폐기건수</th>
<th class="cmn align-content-center p-1 text-blue" style="width: 100px;" rowspan="2">폐기수량</th>
</tr>
<tr id="theadTr--${pageName}"
data-by="by--${pageName}" data-by-output="byOutput--${pageName}" data-main-option="mainOption--${pageName}" data-sub-option="subOption--${pageName}">
@ -98,11 +100,9 @@
<th class="cmn" style="width: 90px;">향정</th>
<th class="cmn" style="width: 90px;">향정제외</th>
<th class="cmn" style="width: 90px;">기타</th>
<th class="cmn text-blue" style="width: 90px;">마약향정계</th>
<th class="cmn" style="width: 90px;">비마약류</th>
<th class="cmn" style="width: 120px;">일반관리대상</th>
<th class="cmn" style="width: 120px;">중점관리대상</th>
<th class="cmn text-blue" style="width: 90px;">중점일반계</th>
</tr>
</thead>
<tbody id="tbody--${pageName}">
@ -116,11 +116,11 @@
<td class="text-end" onclick="{onclick}" ondblclick="{ondblclick}">{향정} / {향정qy}</td>
<td class="text-end" onclick="{onclick}" ondblclick="{ondblclick}">{향정제외} / {향정제외qy}</td>
<td class="text-end" onclick="{onclick}" ondblclick="{ondblclick}">{기타} / {기타qy}</td>
<td class="text-end text-blue" onclick="{onclick}" ondblclick="{ondblclick}">{마약향정계} / {마약향정계qy}</td>
<td class="text-end" onclick="{onclick}" ondblclick="{ondblclick}">{비마약류} / {비마약류qy}</td>
<td class="text-end" onclick="{onclick}" ondblclick="{ondblclick}">{일반관리대상} / {일반관리대상qy}</td>
<td class="text-end" onclick="{onclick}" ondblclick="{ondblclick}">{중점관리대상} / {중점관리대상qy}</td>
<td class="text-end text-blue" onclick="{onclick}" ondblclick="{ondblclick}">{중점일반계} / {중점일반계qy}</td>
<td class="text-end text-blue" onclick="{onclick}" ondblclick="{ondblclick}">{dsuseCnt}</td>
<td class="text-end text-blue" onclick="{onclick}" ondblclick="{ondblclick}">{dsuseQy}</td>
</tr>
</template>
<template id="${infoPrefix}NotFound--${pageName}">
@ -208,6 +208,40 @@
$("#tbody--${pageName}").setCurrentRow(key);
};
$P.control.getInfo = (deptCd) => {
let dialogTitle = "NIMS 폐기 보고 확인 등록";
let row = $P.control.dataset.getCurrent();
if (typeof row == "undefined" || row == null || row == "") return;
let params = $P.formFields.get(); // 검색 조건
if(!$('#chkDsuseDe--${pageName}').is(":checked")){
$P.control.query.schDateFrom = '';
$P.control.query.schDateTo = '';
}
params = {
...params,
deptCd: row.dept_cd,
nrcdSeNm: row.nrcdSeNm,
prtmSeNm: row.prtm_se_nm,
};
ajax.get({
url : wctx.url("/adds/nims/dsuseMgtMapping-info.do")
, data : params
, success : resp => {
dialog.open({
id : $P.control.prefixed("Dialog")
, title : dialogTitle
, content : resp
, size : "xxl"
, onClose : () => {
$P.control.reload({all : true});
}
});
}
});
}
/**************************************************************************
* DataTables 이벤트
@ -227,8 +261,8 @@
});
let replacer = (str, dataItem) => {
str = str.replace(/{onclick}/gi, "pageObject['${pageName}'].control.setCurrent('" + dataItem.getValue("dept_cd") + "');")
if(dataItem.getValue("dept_cd") == "TOTAL"){
str = str.replace(/{ondblclick}/gi, "pageObject['${pageName}'].control.getInfo('" + dataItem.getValue("dept_cd") + ");");
if(dataItem.getValue("dept_cd") === "TOTAL"){
str = str.replace(/{fw-bold-if-total}/gi, "fw-bold");
} else {
str = str.replace(/{fw-bold-if-total}/gi, "");
@ -315,14 +349,19 @@
return;
}
// 처음 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);
// DataTables(그리드)
let cellDefs = getCellDefs(
$("#theadTr0--${pageName} th, #theadTr--${pageName} th")
.not(".dummy-th").not("[colspan]"),
$P.control.query.cellDefs = getCellDefs(
$([...firstColNames, ...middleColNames, ...lastColNames]),
$($("#${infoPrefix}Row--${pageName}")[0].content).find("td")
.not(".dummy-td").not(":eq(0)").not("[colspan]"));
console.table("cellDefs", cellDefs);
$P.control.query.cellDefs = cellDefs;
.not(".dummy-td").not(":eq(0)").not("[colspan]")
);
$P.control.download();
}

Loading…
Cancel
Save