|
|
@ -6,6 +6,7 @@ import java.io.FileInputStream;
|
|
|
|
import java.io.FileWriter;
|
|
|
|
import java.io.FileWriter;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.io.InputStream;
|
|
|
|
import java.io.InputStream;
|
|
|
|
|
|
|
|
import java.io.OutputStream;
|
|
|
|
import java.nio.file.Files;
|
|
|
|
import java.nio.file.Files;
|
|
|
|
import java.nio.file.StandardCopyOption;
|
|
|
|
import java.nio.file.StandardCopyOption;
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
@ -16,16 +17,29 @@ import java.util.Map;
|
|
|
|
|
|
|
|
|
|
|
|
import org.egovframe.rte.fdl.string.EgovStringUtil;
|
|
|
|
import org.egovframe.rte.fdl.string.EgovStringUtil;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import cokr.xit.foundation.Downloadable;
|
|
|
|
import cokr.xit.foundation.data.DataFormat;
|
|
|
|
import cokr.xit.foundation.data.DataFormat;
|
|
|
|
import cokr.xit.foundation.data.DataObject;
|
|
|
|
import cokr.xit.foundation.data.DataObject;
|
|
|
|
import net.lingala.zip4j.ZipFile;
|
|
|
|
import net.lingala.zip4j.ZipFile;
|
|
|
|
|
|
|
|
|
|
|
|
public class OutsourcingFileMaker {
|
|
|
|
public class OutsourcingFileMaker {
|
|
|
|
|
|
|
|
protected String printKorName;
|
|
|
|
|
|
|
|
protected PrintOption printOption;
|
|
|
|
|
|
|
|
protected List<DataObject> data;
|
|
|
|
|
|
|
|
protected List<DataObject> printStngItems;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected String resultZipFilePath;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public OutsourcingFileMaker(String printKorName, PrintOption printOption, List<DataObject> printStngItems,
|
|
|
|
|
|
|
|
List<DataObject> data){
|
|
|
|
|
|
|
|
this.printKorName = printKorName;
|
|
|
|
|
|
|
|
this.printOption = printOption;
|
|
|
|
|
|
|
|
this.data = data;
|
|
|
|
|
|
|
|
this.printStngItems = printStngItems;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Map<String, Object> makeOutsourcingFile(String printKorName, PrintOption printOption,
|
|
|
|
public Map<String, Object> makeFile() {
|
|
|
|
List<DataObject> dataObjectList, List<DataObject> printStngItems) {
|
|
|
|
|
|
|
|
Map<String, Object> result = new HashMap<>();
|
|
|
|
Map<String, Object> result = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
|
|
Hangul hangul = new Hangul(2);
|
|
|
|
Hangul hangul = new Hangul(2);
|
|
|
@ -60,8 +74,8 @@ public class OutsourcingFileMaker {
|
|
|
|
imagesFolderPathFile.mkdirs();
|
|
|
|
imagesFolderPathFile.mkdirs();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for(int i=0; i < dataObjectList.size(); i++) {
|
|
|
|
for(int i=0; i < data.size(); i++) {
|
|
|
|
DataObject dataObject = dataObjectList.get(i);
|
|
|
|
DataObject dataObject = data.get(i);
|
|
|
|
|
|
|
|
|
|
|
|
CmmnUtil.setOcrInfo(dataObject);
|
|
|
|
CmmnUtil.setOcrInfo(dataObject);
|
|
|
|
CmmnUtil.setBarcode(dataObject);
|
|
|
|
CmmnUtil.setBarcode(dataObject);
|
|
|
@ -103,18 +117,18 @@ public class OutsourcingFileMaker {
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
File file = new File(metaFilePath);
|
|
|
|
File metaFile = new File(metaFilePath);
|
|
|
|
if (!file.exists()) {
|
|
|
|
if (!metaFile.exists()) {
|
|
|
|
if(!file.createNewFile()) {
|
|
|
|
if(!metaFile.createNewFile()) {
|
|
|
|
throw new RuntimeException("외주파일생성 중 오류가 발생하였습니다.");
|
|
|
|
throw new RuntimeException("외주파일생성 중 오류가 발생하였습니다.");
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
FileWriter fw = new FileWriter(file);
|
|
|
|
FileWriter fw = new FileWriter(metaFile);
|
|
|
|
BufferedWriter writer = new BufferedWriter(fw);
|
|
|
|
BufferedWriter writer = new BufferedWriter(fw);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for(int i=0; i < dataObjectList.size(); i++) {
|
|
|
|
for(int i=0; i < data.size(); i++) {
|
|
|
|
DataObject dataObject = dataObjectList.get(i);
|
|
|
|
DataObject dataObject = data.get(i);
|
|
|
|
|
|
|
|
|
|
|
|
if(i != 0) {
|
|
|
|
if(i != 0) {
|
|
|
|
writer.write("\n");
|
|
|
|
writer.write("\n");
|
|
|
@ -202,9 +216,15 @@ public class OutsourcingFileMaker {
|
|
|
|
zipFile.addFolder(new File(imagesFolderPath));
|
|
|
|
zipFile.addFolder(new File(imagesFolderPath));
|
|
|
|
zipFile.close();
|
|
|
|
zipFile.close();
|
|
|
|
|
|
|
|
|
|
|
|
result.put("filename", zipFileName);
|
|
|
|
metaFile.delete();
|
|
|
|
result.put("filePath", zipFilePath);
|
|
|
|
File[] images = imagesFolderPathFile.listFiles();
|
|
|
|
result.put("file", new File(zipFilePath));
|
|
|
|
for(File image : images) {
|
|
|
|
|
|
|
|
image.delete();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
imagesFolderPathFile.delete();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
resultZipFilePath = zipFilePath;
|
|
|
|
|
|
|
|
result.put("download", this.getDownloadable().setFilename(zipFileName));
|
|
|
|
|
|
|
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
} catch (IOException e) {
|
|
|
|
throw new RuntimeException("외주파일생성 중 오류가 발생하였습니다.");
|
|
|
|
throw new RuntimeException("외주파일생성 중 오류가 발생하였습니다.");
|
|
|
@ -212,4 +232,22 @@ public class OutsourcingFileMaker {
|
|
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void write(OutputStream out) {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
FileInputStream fis = new FileInputStream(resultZipFilePath);
|
|
|
|
|
|
|
|
fis.transferTo(out);
|
|
|
|
|
|
|
|
fis.close();
|
|
|
|
|
|
|
|
new File(resultZipFilePath).delete();
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Downloadable getDownloadable() {
|
|
|
|
|
|
|
|
return new Downloadable()
|
|
|
|
|
|
|
|
.setContentType("application/zip")
|
|
|
|
|
|
|
|
.setWriter(this::write);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|