통계 정렬 수정, 폰트 수정, 엑셀저장 추가

dev
이범준 4 months ago
parent fd9a33f6df
commit 91f9aca222

@ -9,6 +9,8 @@ public class DsuseMgtStatisticsQuery extends QueryRequest{
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private String cellDefs;
//검색조건 //검색조건
private String schSggCd; // 관활 관청 private String schSggCd; // 관활 관청
private String schDateFrom; // 검색 일자 시작 private String schDateFrom; // 검색 일자 시작
@ -20,6 +22,15 @@ public class DsuseMgtStatisticsQuery extends QueryRequest{
private String useYn; // 사용 여부 private String useYn; // 사용 여부
private String nimsRptYn; // NIMS 보고 여부 private String nimsRptYn; // NIMS 보고 여부
public String getCellDefs() {
return ifEmpty(cellDefs, () -> null);
}
public <T extends DsuseMgtStatisticsQuery> T setCellDefs(String cellDefs) {
this.cellDefs = cellDefs;
return self();
}
public String getNimsRptYn() { public String getNimsRptYn() {
return ifEmpty(nimsRptYn, () -> null); return ifEmpty(nimsRptYn, () -> null);
} }

@ -19,6 +19,10 @@ import java.util.stream.IntStream;
import javax.annotation.Resource; 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.json.simple.JSONObject;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller; 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.adds.nims.service.DsuseMgtReceiptService;
import cokr.xit.applib.Print; import cokr.xit.applib.Print;
import cokr.xit.applib.PrintOption; import cokr.xit.applib.PrintOption;
import cokr.xit.applib.xls.StyleMaker;
import cokr.xit.base.code.CommonCode; 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;
import cokr.xit.base.file.FileInfo.Relation; import cokr.xit.base.file.FileInfo.Relation;
import cokr.xit.base.file.service.FileQuery; import cokr.xit.base.file.service.FileQuery;
@ -344,7 +353,48 @@ public class AddsNimsController extends ApplicationController {
public ModelAndView getDsuseMgtNcrdAndPrtmStatistics(DsuseMgtStatisticsQuery query) { public ModelAndView getDsuseMgtNcrdAndPrtmStatistics(DsuseMgtStatisticsQuery query) {
//query.setOrderBy("dsuse_de DESC, dsuse_mth_cd, dscdmng_id"); //query.setOrderBy("dsuse_de DESC, dsuse_mth_cd, dscdmng_id");
//setFetchSize(query); //setFetchSize(query);
if("xls".equals(query.getDownload())) {
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.getDsuseMgtNcrdAndPrtmStatistics(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 setCollectionInfo(new ModelAndView("jsonView"), addsNimsService.getDsuseMgtNcrdAndPrtmStatistics(query),"",""); return setCollectionInfo(new ModelAndView("jsonView"), addsNimsService.getDsuseMgtNcrdAndPrtmStatistics(query),"","");
// return addsNimsService.getDsuseMgtNcrdAndPrtmStatistics(query); // return addsNimsService.getDsuseMgtNcrdAndPrtmStatistics(query);
} }

@ -56,10 +56,18 @@
<button type="button" class="btn btn-search w-px-120" id="btnSearch--${pageName}" title="검색"> <button type="button" class="btn btn-search w-px-120" id="btnSearch--${pageName}" title="검색">
검색 검색
</button> </button>
</div> </div>
</div> </div>
</div> </div>
</form> </form>
<div class="mt-3">
<div class="float-end">
<button type="button" class="btn btn-excel w-px-120" id="btnExcel--${pageName}" title="엑셀 저장">
엑셀
</button>
</div>
</div>
<!-- 업무 버튼 및 건수 표시 --> <!-- 업무 버튼 및 건수 표시 -->
<div class="d-flex flex-row justify-content-between p-3"> <div class="d-flex flex-row justify-content-between p-3">
<div> <div>
@ -74,9 +82,9 @@
<div class="table-responsive ox-scroll oy-scroll" style="height: 580px !important;" id="table-responsive--${pageName}"> <div class="table-responsive ox-scroll oy-scroll" style="height: 580px !important;" id="table-responsive--${pageName}">
<table class="table-layout-fixed dataTable datatables-ajax table table-bordered no-footer" id="DataTables_Table_0--${pageName}" aria-describedby="DataTables_Table_0_info"> <table class="table-layout-fixed dataTable datatables-ajax table table-bordered no-footer" id="DataTables_Table_0--${pageName}" aria-describedby="DataTables_Table_0_info">
<thead class="sticky-thead"> <thead class="sticky-thead">
<tr> <tr id="theadTr0--${pageName}">
<th class="cmn text-center" style="width: 60px;" rowspan="2">NO.</th> <th class="cmn text-center align-content-center p-1" style="width: 60px;" rowspan="2">NO.</th>
<th class="cmn" style="width: 170px;" rowspan="2">관할관청</th> <th class="cmn align-content-center p-1" style="width: 170px;" rowspan="2">관할관청</th>
<th class="cmn" colspan="7">마약 / 향정 구분</th> <th class="cmn" colspan="7">마약 / 향정 구분</th>
<th class="cmn" colspan="4">중점 / 일반 구분</th> <th class="cmn" colspan="4">중점 / 일반 구분</th>
</tr> </tr>
@ -90,17 +98,17 @@
<th class="cmn" style="width: 90px;">향정</th> <th class="cmn" style="width: 90px;">향정</th>
<th class="cmn" style="width: 90px;">향정제외</th> <th class="cmn" style="width: 90px;">향정제외</th>
<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: 90px;">비마약류</th>
<th class="cmn" style="width: 120px;">일반관리대상</th> <th class="cmn" style="width: 120px;">일반관리대상</th>
<th class="cmn" style="width: 120px;">중점관리대상</th> <th class="cmn" style="width: 120px;">중점관리대상</th>
<th class="cmn" style="width: 90px;">계</th> <th class="cmn text-blue" style="width: 90px;">계</th>
</tr> </tr>
</thead> </thead>
<tbody id="tbody--${pageName}"> <tbody id="tbody--${pageName}">
</tbody> </tbody>
<template id="${infoPrefix}Row--${pageName}"> <template id="${infoPrefix}Row--${pageName}">
<tr data-key="{dept_cd}"> <tr data-key="{dept_cd}" class="{fw-bold-if-total}">
<td class="cmn text-center" onclick="{onclick}" ondblclick="{ondblclick}">{ROW_NUM}</td> <td class="cmn text-center" onclick="{onclick}" ondblclick="{ondblclick}">{ROW_NUM}</td>
<td class="cmn text-center" onclick="{onclick}" ondblclick="{ondblclick}">{dept_nm}</td> <td class="cmn text-center" onclick="{onclick}" ondblclick="{ondblclick}">{dept_nm}</td>
<td class="text-end" onclick="{onclick}" ondblclick="{ondblclick}">{대마}</td> <td class="text-end" onclick="{onclick}" ondblclick="{ondblclick}">{대마}</td>
@ -109,11 +117,11 @@
<td class="text-end" onclick="{onclick}" ondblclick="{ondblclick}">{향정}</td> <td class="text-end" onclick="{onclick}" ondblclick="{ondblclick}">{향정}</td>
<td class="text-end" onclick="{onclick}" ondblclick="{ondblclick}">{향정제외}</td> <td class="text-end" onclick="{onclick}" ondblclick="{ondblclick}">{향정제외}</td>
<td class="text-end" onclick="{onclick}" ondblclick="{ondblclick}">{기타}</td> <td class="text-end" onclick="{onclick}" ondblclick="{ondblclick}">{기타}</td>
<td class="text-end" onclick="{onclick}" ondblclick="{ondblclick}">{마약향정계}</td> <td class="text-end text-blue" onclick="{onclick}" ondblclick="{ondblclick}">{마약향정계}</td>
<td class="text-end" onclick="{onclick}" ondblclick="{ondblclick}">{비마약류}</td> <td class="text-end" onclick="{onclick}" ondblclick="{ondblclick}">{비마약류}</td>
<td class="text-end" onclick="{onclick}" ondblclick="{ondblclick}">{일반관리대상}</td> <td class="text-end" onclick="{onclick}" ondblclick="{ondblclick}">{일반관리대상}</td>
<td class="text-end" onclick="{onclick}" ondblclick="{ondblclick}">{중점관리대상}</td> <td class="text-end" onclick="{onclick}" ondblclick="{ondblclick}">{중점관리대상}</td>
<td class="text-end" onclick="{onclick}" ondblclick="{ondblclick}">{중점일반계}</td> <td class="text-end text-blue" onclick="{onclick}" ondblclick="{ondblclick}">{중점일반계}</td>
</tr> </tr>
</template> </template>
<template id="${infoPrefix}NotFound--${pageName}"> <template id="${infoPrefix}NotFound--${pageName}">
@ -207,8 +215,16 @@
foundTr.appendChild(this.cloneNode(true)); foundTr.appendChild(this.cloneNode(true));
}); });
let replacer = (str, dataItem) => str let replacer = (str, dataItem) => {
.replace(/{onclick}/gi, "pageObject['${pageName}'].control.setCurrent('" + dataItem.getValue("dept_cd") + "');"); str = str.replace(/{onclick}/gi, "pageObject['${pageName}'].control.setCurrent('" + 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, "");
}
return str;
}
let trs = empty ? [document.getElementById("${infoPrefix}NotFound--${pageName}").content.outerHTML] let trs = empty ? [document.getElementById("${infoPrefix}NotFound--${pageName}").content.outerHTML]
: ${infoPrefix}List.inStrings(foundTr.outerHTML, replacer); : ${infoPrefix}List.inStrings(foundTr.outerHTML, replacer);
@ -289,8 +305,11 @@
} }
// DataTables(그리드) // DataTables(그리드)
let cellDefs = getCellDefs($("#theadTr--${pageName} th").not(".dummy-th").not(":eq(0)") let cellDefs = getCellDefs(
, $($("#${infoPrefix}Row--${pageName}")[0].content).find("td").not(".dummy-td").not(":eq(0)")); $("#theadTr0--${pageName} th, #theadTr--${pageName} th")
.not(".dummy-th").not(":eq(0)").not("[colspan]"),
$($("#${infoPrefix}Row--${pageName}")[0].content).find("td")
.not(".dummy-td").not(":eq(0)").not("[colspan]"));
$P.control.query.cellDefs = cellDefs; $P.control.query.cellDefs = cellDefs;
$P.control.download(); $P.control.download();

Loading…
Cancel
Save