우편모아 등록 파일 생성 추가

main
mjkhan21 5 months ago
parent f1f8497b4b
commit 84c8f0856d

@ -10,9 +10,7 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Map;
@ -62,44 +60,43 @@ public class OutsourcingFileMaker extends AbstractBean {
}
public Map<String, Object> makeFile() {
SimpleDateFormat ymdhmsFormat = new SimpleDateFormat("yyyyMMddHHmmss");
String currentTime = ymdhmsFormat.format(new Date());
String currentTime = dateFormats.now();
String year = currentTime.substring(0, 4);
String month = currentTime.substring(4, 6);
String day = currentTime.substring(6, 8);
String yyyymmdd = year+month+day;
String outsourcingResultPath = "files"+File.separator+"temp"+File.separator+"outsourcing"
+ File.separator + year + File.separator + month + File.separator + day
+ File.separator + currentTime;
+ File.separator + year + File.separator + month + File.separator + day
+ File.separator + currentTime;
ensureDir(outsourcingResultPath);
try {
String imagesFolderName = yyyymmdd + printKorName;
String metaFileName = yyyymmdd + printKorName + "(외주파일).txt";
String metaFileName = imagesFolderName + "(외주파일).txt";
String imagesFolderPath = outsourcingResultPath + File.separator + imagesFolderName;
String metaFilePath = outsourcingResultPath + File.separator + metaFileName;
File imagesFolderPathFile = ensureDir(imagesFolderPath);
for(DataObject dataObject: data) {
for (DataObject dataObject: data) {
CmmnUtil.setOcrInfo(dataObject);
CmmnUtil.setBarcode(dataObject);
String sndngDtlId = dataObject.string("SNDNG_DTL_ID");
int crdnPhotoCnt = toInt(dataObject.get("CRDN_PHOTO_CNT"));
for(int j=0; j < crdnPhotoCnt; j++){
for (int j = 0; j < crdnPhotoCnt; j++){
String orgnFilePath = dataObject.string("CRDN_PHOTO"+(j+1));
String fileKey = dataObject.string("CRDN_PHOTO"+(j+1)+"KEY");
if(isEmpty(orgnFilePath)) continue;
if (isEmpty(orgnFilePath)) continue;
if(!orgnFilePath.startsWith("files")) {
if (!orgnFilePath.startsWith("files")) {
orgnFilePath = CmmnUtil.copyStaticResource(orgnFilePath, false);
}
File orgnFile = new File(orgnFilePath);
if(!orgnFile.exists() || !orgnFile.canRead()) continue;
if (!orgnFile.exists() || !orgnFile.canRead()) continue;
InputStream orgnFileInputStream = new FileInputStream(orgnFile);
@ -107,7 +104,7 @@ public class OutsourcingFileMaker extends AbstractBean {
String modifiedFilePath = imagesFolderPath + File.separator + modifiedFileName;
File modifiedFile = new File(modifiedFilePath);
if(dataObject.get("MOS"+fileKey) != null) {
if (dataObject.get("MOS"+fileKey) != null) {
CmmnUtil.createMaskedImage(orgnFileInputStream, modifiedFile, CmmnUtil.getDataObjectListFromMap(dataObject,"MOS"+fileKey));
} else {
Files.copy(orgnFileInputStream, modifiedFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
@ -119,20 +116,20 @@ public class OutsourcingFileMaker extends AbstractBean {
File metaFile = new File(metaFilePath);
if (!metaFile.exists()) {
if(!metaFile.createNewFile())
if (!metaFile.createNewFile())
throw new RuntimeException("외주파일생성 중 오류가 발생하였습니다.");
}
FileWriter fw = new FileWriter(metaFile);
BufferedWriter writer = new BufferedWriter(fw);
Hangul hangul = new Hangul(2);
for(int i=0; i < data.size(); i++) {
for (int i = 0; i < data.size(); i++) {
DataObject dataObject = data.get(i);
if(i != 0)
if (i != 0)
writer.write("\n");
String line = "";
for(DataObject printStngItem : printStngItems){
for (DataObject printStngItem : printStngItems){
String artclNm = printStngItem.string("ARTCL_NM");
String artclValue = switch (artclNm) {
case "OTPT_YMD" -> yyyymmdd;
@ -143,7 +140,7 @@ public class OutsourcingFileMaker extends AbstractBean {
};
//포매팅
if(!printStngItem.string("FORMATTING").equals("")) {
if (!isEmpty(printStngItem.string("FORMATTING"))) {
String formatting = printStngItem.string("FORMATTING");
switch (formatting) {
case "zip(hypen)": {
@ -159,10 +156,10 @@ public class OutsourcingFileMaker extends AbstractBean {
break;
}
default:
if(formatting.startsWith("date(")) {
if (formatting.startsWith("date(")) {
String dtlFormatting = formatting.substring(5, formatting.length()-1);
if(dtlFormatting.contains("~") && artclValue.contains("~")) {
if (dtlFormatting.contains("~") && artclValue.contains("~")) {
String from = CmmnUtil.dateNFormat(artclValue.split("~",-1)[0], dtlFormatting.split("~",-1)[0]);
String to = CmmnUtil.dateNFormat(artclValue.split("~",-1)[1], dtlFormatting.split("~",-1)[1]);
@ -177,7 +174,7 @@ public class OutsourcingFileMaker extends AbstractBean {
//공백 패딩 방향
int byteCnt = toInt(printStngItem.get("ARTCL_SZ"));
if(printStngItem.string("PADDING_DIRECTION").equals("left")) {
if (printStngItem.string("PADDING_DIRECTION").equals("left")) {
line += hangul.lpadByte(artclValue, byteCnt, " ");
} else {
line += hangul.rpadByte(artclValue, byteCnt, " ");
@ -196,7 +193,7 @@ public class OutsourcingFileMaker extends AbstractBean {
metaFile.delete();
File[] images = imagesFolderPathFile.listFiles();
for(File image : images) {
for (File image : images) {
image.delete();
}
imagesFolderPathFile.delete();
@ -226,7 +223,7 @@ public class OutsourcingFileMaker extends AbstractBean {
public Downloadable getDownloadable() {
return new Downloadable()
.setContentType("application/zip")
.setContentType(ZIP.MIME_TYPE)
.setWriter(this::write);
}
@ -250,6 +247,7 @@ public class OutsourcingFileMaker extends AbstractBean {
new PredefinedSet("ATCH_FILE_CNT", "첨부파일갯수"),
new PredefinedSet("FFNLG_CRDN_AMT", "과태료단속금액"),
new PredefinedSet("LAST_AMT", "최종금액"),
new PredefinedSet("MINUS_AMT", "감경금액"),
new PredefinedSet("RG_NO", "등기번호"),
new PredefinedSet("OCR0", "OCR0").offLog(),
new PredefinedSet("OCR0_1", "OCR0_1").offLog(),

@ -174,7 +174,7 @@ public class SnisBean extends AbstractBean {
});
// 발송대상 ID별 사전통지 생성
String now = dateFormats.format("yyyyMMddHHmmss", System.currentTimeMillis());
String now = dateFormats.now();
UserInfo currentUser = currentUser();
DataObject userInfo = userBean.getUserInfo(currentUser.getId());
return targets.stream().collect(Collectors.toMap(

@ -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);
}
}
}
}

@ -213,6 +213,8 @@
, (SELECT USER_NM FROM TB_USER X WHERE X.USER_ID = SD.MDFR) AS MDFR_NM <!-- 수정자 명 -->
, C.CRDN_STTS_CD <!-- 단속 상태 코드 -->
, C.CRDN_STTS_CHG_DT <!-- 단속 상태 변경 일시 -->
, P.RTPYR_TELNO <!-- 전화번호 -->
, P.RTPYR_MBL_TELNO <!-- 휴대전화번호 -->
, S.SGG_CD <!-- 시군구 코드 -->
, S.DEPT_CD <!-- 부서 코드 -->
, S.TASK_SE_CD <!-- 업무 구분 코드 -->
@ -231,6 +233,7 @@
, S.RSND_YN <!-- 재발송 여부 -->
FROM TB_SNDNG_DTL SD
INNER JOIN TB_CRDN C ON (SD.CRDN_ID = C.CRDN_ID)
INNER JOIN TB_PAYER P ON (C.RTPYR_ID = P.RTPYR_ID)
LEFT OUTER JOIN TB_SNDNG S ON (SD.SNDNG_ID = S.SNDNG_ID)
</sql>

Loading…
Cancel
Save