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