|
|
|
|
@ -1,5 +1,6 @@
|
|
|
|
|
package cokr.xit.fims.sndb.web;
|
|
|
|
|
|
|
|
|
|
import java.io.InputStream;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
@ -10,6 +11,7 @@ import javax.annotation.Resource;
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
|
|
|
|
|
import org.apache.poi.ss.usermodel.CellStyle;
|
|
|
|
|
import org.springframework.core.io.ClassPathResource;
|
|
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
import org.springframework.web.servlet.ModelAndView;
|
|
|
|
|
@ -260,7 +262,7 @@ public class Sndb01Controller extends ApplicationController {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private String now() {
|
|
|
|
|
return dateFormats.format("yyyyMMddHHmmss", System.currentTimeMillis());
|
|
|
|
|
return dateFormats.format("yyyyMMdd_HHmmss", System.currentTimeMillis());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**계고장 발송 대상 정보 화면(sndb/sndb01/020-info)을 연다.
|
|
|
|
|
@ -434,49 +436,77 @@ public class Sndb01Controller extends ApplicationController {
|
|
|
|
|
List<?> result = sndngDtlService.getSndngDtlList(setFetchSize(req));
|
|
|
|
|
return setPagingInfo(new ModelAndView("jsonView"), result, "");
|
|
|
|
|
} else {
|
|
|
|
|
List<CellDef> cellDefs = fromJson(req.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();
|
|
|
|
|
CellStyle dateYMD = format.yyyy_mm_dd();
|
|
|
|
|
CellStyle dateDT = format.yyyy_mm_dd_hh_mm_ss();
|
|
|
|
|
|
|
|
|
|
List<DataObject> list = sndngDtlService.getSndngDtlList(req.setFetchSize(0));
|
|
|
|
|
|
|
|
|
|
Map<String,Object> valueMap = new HashMap<String,Object>();
|
|
|
|
|
valueMap.put("발송상태", format.of("SNDNG_DTL_STTS_NM").style(center));
|
|
|
|
|
valueMap.put("등기번호", format.of("RG_NO").style(center));
|
|
|
|
|
valueMap.put("발송일자", FormatMaker.yyyy_mm_dd(format, "SNDNG_YMD").style(dateYMD));
|
|
|
|
|
valueMap.put("납기일자", FormatMaker.yyyy_mm_dd(format, "SNDNG_END_YMD").style(dateYMD));
|
|
|
|
|
valueMap.put("성명", format.of("RCPN_NM"));
|
|
|
|
|
valueMap.put("우편번호", format.of("RCPN_ZIP").style(center));
|
|
|
|
|
valueMap.put("주소", format.of("RCPN_ADDR"));
|
|
|
|
|
valueMap.put("상세주소", format.of("RCPN_DTL_ADDR"));
|
|
|
|
|
valueMap.put("배달일자", FormatMaker.yyyy_mm_dd(format, "DLVR_YMD").style(dateYMD));
|
|
|
|
|
valueMap.put("배달시각", format.of("DLVR_TM").style(center));
|
|
|
|
|
valueMap.put("미배달사유", format.of("UNDLVR_RSN_NM"));
|
|
|
|
|
valueMap.put("수령인", format.of("ACTL_RCPN_NM"));
|
|
|
|
|
valueMap.put("수령인관계", format.of("RCPN_REL_NM"));
|
|
|
|
|
valueMap.put("단속일시", format.of("CRDN_DT").style(center));
|
|
|
|
|
valueMap.put("차량번호", format.of("VHRNO"));
|
|
|
|
|
valueMap.put("단속법정동", format.of("CRDN_STDG_NM"));
|
|
|
|
|
valueMap.put("단속장소", format.of("CRDN_PLC"));
|
|
|
|
|
valueMap.put("과태료금액", format.of("FFNLG_AMT").style(numeric));
|
|
|
|
|
valueMap.put("등록일시", FormatMaker.yyyy_mm_dd_hh_mm_ss(format, "REG_DT").style(dateDT));
|
|
|
|
|
valueMap.put("등록사용자", format.of("RGTR_NM").style(center));
|
|
|
|
|
valueMap.put("수정일시", FormatMaker.yyyy_mm_dd_hh_mm_ss(format, "MDFCN_DT").style(dateDT));
|
|
|
|
|
valueMap.put("수정사용자", format.of("MDFR_NM").style(center));
|
|
|
|
|
|
|
|
|
|
CellDef.setValues(cellDefs, valueMap);
|
|
|
|
|
|
|
|
|
|
xlsx.cell(0, 0).value("계고장 발송 상세").value(center).merge(0, cellDefs.size() - 1)
|
|
|
|
|
.cell(3, 0).rowValues(CellDef.header(cellDefs, () -> StyleMaker.headerStyle(xlsx)))
|
|
|
|
|
.cell(4, 0).values(list, CellDef.values(cellDefs.stream().map(i -> {if (i.getValue() instanceof Format) {i.setField(null);}; return i;}).toList()));
|
|
|
|
|
|
|
|
|
|
return new ModelAndView("downloadView")
|
|
|
|
|
.addObject("download", xlsx.getDownloadable().setFilename("계고장 발송상세" + "_목록_" + now() + ".xlsx"));
|
|
|
|
|
String template = req.getType();
|
|
|
|
|
if (isEmpty(template)) {
|
|
|
|
|
List<CellDef> cellDefs = fromJson(req.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();
|
|
|
|
|
CellStyle dateYMD = format.yyyy_mm_dd();
|
|
|
|
|
CellStyle dateDT = format.yyyy_mm_dd_hh_mm_ss();
|
|
|
|
|
|
|
|
|
|
Map<String,Object> valueMap = new HashMap<String,Object>();
|
|
|
|
|
valueMap.put("발송상태", format.of("SNDNG_DTL_STTS_NM").style(center));
|
|
|
|
|
valueMap.put("등기번호", format.of("RG_NO").style(center));
|
|
|
|
|
valueMap.put("발송일자", FormatMaker.yyyy_mm_dd(format, "SNDNG_YMD").style(dateYMD));
|
|
|
|
|
valueMap.put("납기일자", FormatMaker.yyyy_mm_dd(format, "SNDNG_END_YMD").style(dateYMD));
|
|
|
|
|
valueMap.put("성명", format.of("RCPN_NM"));
|
|
|
|
|
valueMap.put("우편번호", format.of("RCPN_ZIP").style(center));
|
|
|
|
|
valueMap.put("주소", format.of("RCPN_ADDR"));
|
|
|
|
|
valueMap.put("상세주소", format.of("RCPN_DTL_ADDR"));
|
|
|
|
|
valueMap.put("배달일자", FormatMaker.yyyy_mm_dd(format, "DLVR_YMD").style(dateYMD));
|
|
|
|
|
valueMap.put("배달시각", format.of("DLVR_TM").style(center));
|
|
|
|
|
valueMap.put("미배달사유", format.of("UNDLVR_RSN_NM"));
|
|
|
|
|
valueMap.put("수령인", format.of("ACTL_RCPN_NM"));
|
|
|
|
|
valueMap.put("수령인관계", format.of("RCPN_REL_NM"));
|
|
|
|
|
valueMap.put("단속일시", format.of("CRDN_DT").style(center));
|
|
|
|
|
valueMap.put("차량번호", format.of("VHRNO"));
|
|
|
|
|
valueMap.put("단속법정동", format.of("CRDN_STDG_NM"));
|
|
|
|
|
valueMap.put("단속장소", format.of("CRDN_PLC"));
|
|
|
|
|
valueMap.put("과태료금액", format.of("FFNLG_AMT").style(numeric));
|
|
|
|
|
valueMap.put("등록일시", FormatMaker.yyyy_mm_dd_hh_mm_ss(format, "REG_DT").style(dateDT));
|
|
|
|
|
valueMap.put("등록사용자", format.of("RGTR_NM").style(center));
|
|
|
|
|
valueMap.put("수정일시", FormatMaker.yyyy_mm_dd_hh_mm_ss(format, "MDFCN_DT").style(dateDT));
|
|
|
|
|
valueMap.put("수정사용자", format.of("MDFR_NM").style(center));
|
|
|
|
|
|
|
|
|
|
CellDef.setValues(cellDefs, valueMap);
|
|
|
|
|
|
|
|
|
|
xlsx.cell(0, 0).value("계고장 발송 상세").value(center).merge(0, cellDefs.size() - 1)
|
|
|
|
|
.cell(3, 0).rowValues(CellDef.header(cellDefs, () -> StyleMaker.headerStyle(xlsx)))
|
|
|
|
|
.cell(4, 0).values(list, CellDef.values(cellDefs.stream().map(i -> {if (i.getValue() instanceof Format) {i.setField(null);}; return i;}).toList()));
|
|
|
|
|
|
|
|
|
|
return new ModelAndView("downloadView")
|
|
|
|
|
.addObject("download", xlsx.getDownloadable().setFilename("계고장 발송상세" + "_목록_" + now() + ".xlsx"));
|
|
|
|
|
} else {
|
|
|
|
|
try (InputStream input = new ClassPathResource("template/" + template).getInputStream()) {
|
|
|
|
|
int rowIndex = 1;
|
|
|
|
|
XLSWriter xlsx = new XLSWriter().template(input).worksheet(0);
|
|
|
|
|
|
|
|
|
|
for (DataObject row: list) {
|
|
|
|
|
xlsx.cell(rowIndex, 0)
|
|
|
|
|
.rowValues(List.of("보통", "환부", "규격", 25))
|
|
|
|
|
.cell(rowIndex, 4)
|
|
|
|
|
.rowValues(List.of(
|
|
|
|
|
row.get("RCPN_NM"),
|
|
|
|
|
row.get("RCPN_ZIP"),
|
|
|
|
|
row.get("RCPN_ADDR"),
|
|
|
|
|
row.get("RCPN_DTL_ADDR"),
|
|
|
|
|
ifEmpty(row.get("RTPYR_MBL_TELNO"), () -> row.get("RTPYR_TELNO")),
|
|
|
|
|
row.get("SNDNG_DTL_ID"),
|
|
|
|
|
row.get("TTL_NM"),
|
|
|
|
|
row.get("ETC_CN")
|
|
|
|
|
));
|
|
|
|
|
++rowIndex;
|
|
|
|
|
}
|
|
|
|
|
return new ModelAndView("downloadView")
|
|
|
|
|
.addObject("download", xlsx.getDownloadable().setFilename("우편등록_" + now() + ".xls"));
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
throw runtimeException(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|