|
|
|
|
@ -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,8 +60,7 @@ 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);
|
|
|
|
|
@ -76,30 +73,30 @@ public class OutsourcingFileMaker extends AbstractBean {
|
|
|
|
|
|
|
|
|
|
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(),
|
|
|
|
|
|