|
|
|
@ -1,22 +1,28 @@
|
|
|
|
|
package cokr.xit.fims.crdn.web;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.function.BiFunction;
|
|
|
|
|
import java.util.function.Supplier;
|
|
|
|
|
|
|
|
|
|
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.springframework.web.servlet.ModelAndView;
|
|
|
|
|
|
|
|
|
|
import com.fasterxml.jackson.core.type.TypeReference;
|
|
|
|
|
|
|
|
|
|
import cokr.xit.base.code.CommonCode;
|
|
|
|
|
import cokr.xit.base.file.xls.XLSWriter;
|
|
|
|
|
import cokr.xit.base.file.xls.XLSWriter.CellDef;
|
|
|
|
|
import cokr.xit.base.file.xls.XLSWriter.Styler;
|
|
|
|
|
import cokr.xit.base.user.ManagedUser;
|
|
|
|
|
import cokr.xit.base.user.dao.UserMapper;
|
|
|
|
|
import cokr.xit.base.web.ApplicationController;
|
|
|
|
|
import cokr.xit.fims.cmmn.CmmnUtil;
|
|
|
|
|
import cokr.xit.fims.crdn.Crdn;
|
|
|
|
|
import cokr.xit.fims.crdn.CrdnQuery;
|
|
|
|
|
import cokr.xit.fims.crdn.dao.GlobalStngMapper;
|
|
|
|
@ -88,57 +94,49 @@ public class Crdn06Controller extends ApplicationController {
|
|
|
|
|
query.setSggCd(sggCd);
|
|
|
|
|
|
|
|
|
|
if("xls".equals(query.getDownload())) {
|
|
|
|
|
String[] excelTitle = query.getExcelTitle();
|
|
|
|
|
List<String> titles = new ArrayList<String>();
|
|
|
|
|
for(int i = 0; i < excelTitle.length; i++) {
|
|
|
|
|
String item = excelTitle[i];
|
|
|
|
|
titles.add(item);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int[] excelTitleWidth = query.getExcelTitleWidth();
|
|
|
|
|
List<Integer> widths = new ArrayList<>();
|
|
|
|
|
for(int i = 0; i < excelTitleWidth.length; i++) {
|
|
|
|
|
int item = excelTitleWidth[i];
|
|
|
|
|
widths.add(item);
|
|
|
|
|
}
|
|
|
|
|
ArrayList<CellDef> cellDefs = fromJson(query.getCellDefs(), new TypeReference<ArrayList<CellDef>>() {});
|
|
|
|
|
|
|
|
|
|
XLSWriter xlsx = new XLSWriter()
|
|
|
|
|
.setFilename("단속자료 목록.xlsx")
|
|
|
|
|
.worksheet(0);
|
|
|
|
|
List<Styler> headerStylers = CmmnUtil.makeHeadersByDiffrentWidths(widths, xlsx);
|
|
|
|
|
|
|
|
|
|
Supplier<Styler> defaultHeader = () -> new XLSWriter.Styler()
|
|
|
|
|
.foregroundColor(HSSFColor.HSSFColorPredefined.GREY_25_PERCENT.getIndex())
|
|
|
|
|
.configure(styler -> {
|
|
|
|
|
Font font = xlsx.workbook().createFont();
|
|
|
|
|
font.setColor(HSSFColor.HSSFColorPredefined.BLACK.getIndex());
|
|
|
|
|
styler.font(font);
|
|
|
|
|
styler.alignment(HorizontalAlignment.CENTER);
|
|
|
|
|
});
|
|
|
|
|
CellStyle center = xlsx.cellStyle(Styler.CENTER);
|
|
|
|
|
CellStyle numeric = xlsx.n_nn0();
|
|
|
|
|
CellStyle dateYMD = xlsx.yyyy_mm_dd();
|
|
|
|
|
CellStyle dateDT = xlsx.yyyy_mm_dd_hh_mm_ss();
|
|
|
|
|
|
|
|
|
|
List<DataObject> list = crdnService.getCrackdownList(query.setFetchSize(0));
|
|
|
|
|
Map<String, Object> valueMap = new HashMap<String, Object>();
|
|
|
|
|
valueMap.put("자료출처", xlsx.style("CRDN_INPT_SE_NM", center));
|
|
|
|
|
valueMap.put("차량번호", "VHRNO");
|
|
|
|
|
valueMap.put("위반일시", xlsx.format(o -> xlsx.str2datetime(o.get("CRDN_YMD_TM"))).style(dateDT));
|
|
|
|
|
valueMap.put("단속장소", "CRDN_PLC");
|
|
|
|
|
valueMap.put("체납액", "ATCH_FILE_CNT");
|
|
|
|
|
valueMap.put("사진건수", xlsx.style("ATCH_FILE_CNT", center));
|
|
|
|
|
valueMap.put("스티커번호", "CRDN_SN");
|
|
|
|
|
valueMap.put("장애차량확인", xlsx.style("PARKNG_PSBLTY_RSLT_NM", center));
|
|
|
|
|
valueMap.put("처리상태", xlsx.style("CRDN_STTS_NM", center));
|
|
|
|
|
valueMap.put("제외사유", xlsx.style("LEVY_EXCL_RSN_NM", center));
|
|
|
|
|
valueMap.put("제외처리일자", xlsx.format(o -> xlsx.str2date(o.get("LEVY_EXCL_YMD"))).style(dateYMD));
|
|
|
|
|
valueMap.put("제외내역", "LEVY_EXCL_ETC_CN");
|
|
|
|
|
|
|
|
|
|
CellDef.setValues(cellDefs, valueMap);
|
|
|
|
|
|
|
|
|
|
xlsx.cell(0, 0)
|
|
|
|
|
.value("단속자료 목록", center)
|
|
|
|
|
.merge(0, titles.size()-1)
|
|
|
|
|
.merge(0, cellDefs.size()-1)
|
|
|
|
|
.cell(3, 0)
|
|
|
|
|
.rowValues(CmmnUtil.mergeListByIndex(titles, headerStylers));
|
|
|
|
|
|
|
|
|
|
List<DataObject> list = crdnService.getCrackdownList(query.setFetchSize(0));
|
|
|
|
|
|
|
|
|
|
BiFunction<String, String, ?> getValue = (titleNm, nothing) -> {
|
|
|
|
|
switch(titleNm) {
|
|
|
|
|
case "자료출처": return xlsx.style("CRDN_INPT_SE_NM", center);
|
|
|
|
|
case "차량번호": return "VHRNO";
|
|
|
|
|
case "위반일시": return xlsx.format(o -> xlsx.str2datetime(o.get("CRDN_YMD_TM"))).style(dateDT);
|
|
|
|
|
case "단속장소": return "CRDN_PLC";
|
|
|
|
|
case "체납액": return "";
|
|
|
|
|
case "사진건수": return xlsx.style("ATCH_FILE_CNT", center);
|
|
|
|
|
case "스티커번호": return "CRDN_SN";
|
|
|
|
|
case "장애차량확인": return xlsx.style("PARKNG_PSBLTY_RSLT_NM", center);
|
|
|
|
|
case "처리상태": return xlsx.style("CRDN_STTS_NM", center);
|
|
|
|
|
case "제외사유": return xlsx.style("LEVY_EXCL_RSN_NM", center);
|
|
|
|
|
case "제외처리일자": return xlsx.format(o -> xlsx.str2date(o.get("LEVY_EXCL_YMD"))).style(dateYMD);
|
|
|
|
|
case "제외내역": return "LEVY_EXCL_ETC_CN";
|
|
|
|
|
}
|
|
|
|
|
return "";
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
xlsx.cell(4, 0)
|
|
|
|
|
.values(list, titles.stream().map((item) -> { return getValue.apply(item, null); }).toArray());
|
|
|
|
|
.rowValues(CellDef.header(cellDefs, defaultHeader))
|
|
|
|
|
.cell(4, 0)
|
|
|
|
|
.values(list, CellDef.values(cellDefs));
|
|
|
|
|
|
|
|
|
|
return new ModelAndView("xlsView").addObject("xls", xlsx);
|
|
|
|
|
}
|
|
|
|
|