|
|
@ -1,8 +1,16 @@
|
|
|
|
package cokr.xit.fims.sprt.service.bean;
|
|
|
|
package cokr.xit.fims.sprt.service.bean;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.BufferedWriter;
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
|
|
|
import java.io.FileWriter;
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.io.InputStream;
|
|
|
|
import java.io.InputStream;
|
|
|
|
|
|
|
|
import java.nio.file.Files;
|
|
|
|
|
|
|
|
import java.nio.file.StandardCopyOption;
|
|
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Comparator;
|
|
|
|
import java.util.Comparator;
|
|
|
|
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Map;
|
|
|
@ -22,6 +30,8 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
|
|
import cokr.xit.base.file.service.FileQuery;
|
|
|
|
import cokr.xit.base.file.service.FileQuery;
|
|
|
|
import cokr.xit.base.file.service.bean.FileBean;
|
|
|
|
import cokr.xit.base.file.service.bean.FileBean;
|
|
|
|
|
|
|
|
import cokr.xit.fims.cmmn.CmmnUtil;
|
|
|
|
|
|
|
|
import cokr.xit.fims.cmmn.Hangul;
|
|
|
|
import cokr.xit.fims.cmmn.hwp.AddUtil;
|
|
|
|
import cokr.xit.fims.cmmn.hwp.AddUtil;
|
|
|
|
import cokr.xit.fims.cmmn.hwp.HWPFormatWriter;
|
|
|
|
import cokr.xit.fims.cmmn.hwp.HWPFormatWriter;
|
|
|
|
import cokr.xit.fims.cmmn.hwp.HWPPrintUtil;
|
|
|
|
import cokr.xit.fims.cmmn.hwp.HWPPrintUtil;
|
|
|
@ -37,6 +47,7 @@ import cokr.xit.fims.cmmn.pdf.PstnAndSize;
|
|
|
|
import cokr.xit.fims.cmmn.pdf.format.Advntce;
|
|
|
|
import cokr.xit.fims.cmmn.pdf.format.Advntce;
|
|
|
|
import cokr.xit.fims.cmmn.pdf.format.Nht;
|
|
|
|
import cokr.xit.fims.cmmn.pdf.format.Nht;
|
|
|
|
import cokr.xit.fims.cmmn.service.bean.FactionBean;
|
|
|
|
import cokr.xit.fims.cmmn.service.bean.FactionBean;
|
|
|
|
|
|
|
|
import cokr.xit.fims.cmmn.service.bean.MosaicBean;
|
|
|
|
import cokr.xit.fims.cmmn.service.bean.StngBean;
|
|
|
|
import cokr.xit.fims.cmmn.service.bean.StngBean;
|
|
|
|
import cokr.xit.fims.crdn.Crdn;
|
|
|
|
import cokr.xit.fims.crdn.Crdn;
|
|
|
|
import cokr.xit.fims.crdn.CrdnQuery;
|
|
|
|
import cokr.xit.fims.crdn.CrdnQuery;
|
|
|
@ -53,6 +64,7 @@ import cokr.xit.foundation.data.DataObject;
|
|
|
|
import kr.dogfoot.hwplib.object.HWPFile;
|
|
|
|
import kr.dogfoot.hwplib.object.HWPFile;
|
|
|
|
import kr.dogfoot.hwplib.reader.HWPReader;
|
|
|
|
import kr.dogfoot.hwplib.reader.HWPReader;
|
|
|
|
import kr.dogfoot.hwplib.writer.HWPWriter;
|
|
|
|
import kr.dogfoot.hwplib.writer.HWPWriter;
|
|
|
|
|
|
|
|
import net.lingala.zip4j.ZipFile;
|
|
|
|
|
|
|
|
|
|
|
|
/**통합 조회 서비스 구현체.
|
|
|
|
/**통합 조회 서비스 구현체.
|
|
|
|
*
|
|
|
|
*
|
|
|
@ -89,6 +101,9 @@ public class Sprt01ServiceBean extends AbstractServiceBean implements Sprt01Serv
|
|
|
|
@Resource(name = "otptStngMapper")
|
|
|
|
@Resource(name = "otptStngMapper")
|
|
|
|
protected OtptStngMapper otptStngMapper;
|
|
|
|
protected OtptStngMapper otptStngMapper;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource(name="mosaicBean")
|
|
|
|
|
|
|
|
private MosaicBean mosaicBean;
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public List<DataObject> getIntegrationDataList(SprtQuery query) {
|
|
|
|
public List<DataObject> getIntegrationDataList(SprtQuery query) {
|
|
|
|
return sprt01Bean.getIntegrationDataList(query);
|
|
|
|
return sprt01Bean.getIntegrationDataList(query);
|
|
|
@ -511,9 +526,115 @@ public class Sprt01ServiceBean extends AbstractServiceBean implements Sprt01Serv
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public Map<String, String> makeOutsourcingFile(String formatName, PrintOption printOption, String[] crdnIds) {
|
|
|
|
public Map<String, String> makeOutsourcingFile(String formatName, PrintOption printOption, String[] crdnIds) {
|
|
|
|
return null;
|
|
|
|
Map<String,String> result = new HashMap<>();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Hangul hangul = new Hangul(2);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SimpleDateFormat ymdhmsFormat = new SimpleDateFormat("yyyyMMddHHmmss");
|
|
|
|
|
|
|
|
String currentTime = ymdhmsFormat.format(new Date());
|
|
|
|
|
|
|
|
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+"result"+File.separator+"outsourcing"
|
|
|
|
|
|
|
|
+ File.separator + year + File.separator + month + File.separator + day
|
|
|
|
|
|
|
|
+ File.separator + currentTime;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
File folder = new File(outsourcingResultPath);
|
|
|
|
|
|
|
|
if(!folder.exists()) {
|
|
|
|
|
|
|
|
folder.mkdirs();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String printKorName = "사전통지";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
SprtQuery sprtQuery = new SprtQuery();
|
|
|
|
|
|
|
|
sprtQuery.setCrdnIDs(crdnIds);
|
|
|
|
|
|
|
|
List<DataObject> dataObjectList = integrationSearchMapper.selectIntegrationDataList(sprtQuery);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String imagesFolderName = yyyymmdd + printKorName;
|
|
|
|
|
|
|
|
String metaFileName = yyyymmdd + printKorName + "(외주파일).txt";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String imagesFolderPath = outsourcingResultPath + File.separator + imagesFolderName;
|
|
|
|
|
|
|
|
String metaFilePath = outsourcingResultPath + File.separator + metaFileName;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for(int i=0; i < dataObjectList.size(); i++) {
|
|
|
|
|
|
|
|
DataObject dataObject = dataObjectList.get(i);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FileQuery fileQuery = new FileQuery();
|
|
|
|
|
|
|
|
fileQuery.setInfoType(Crdn.INF_TYPE);
|
|
|
|
|
|
|
|
fileQuery.setInfoKeys(dataObject.string("CRDN_ID"));
|
|
|
|
|
|
|
|
List<DataObject> fileInfoList = fileBean.getFileList(fileQuery);
|
|
|
|
|
|
|
|
if(fileInfoList == null) {
|
|
|
|
|
|
|
|
fileInfoList = new ArrayList<DataObject>();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
for(int j=0; j < fileInfoList.size(); j++){
|
|
|
|
|
|
|
|
DataObject fileInfo = fileInfoList.get(j);
|
|
|
|
|
|
|
|
List<DataObject> mosaicInfos = mosaicBean.getMosaicList(fileInfo.string("FILE_ID"));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
File orgnFile = new File(fileInfo.string("FILE_PATH"));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String modifiedFileName = "P"+fileInfo.string("INF_KEY")+CmmnUtil.indexToAlphabet(j, true)+"."+"JPG";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String modifiedFilePath = imagesFolderPath + File.separator + modifiedFileName;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
File modifiedFile = new File(modifiedFilePath);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(mosaicInfos != null) {
|
|
|
|
|
|
|
|
CmmnUtil.createMaskedImage(orgnFile, modifiedFile, mosaicInfos);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
Files.copy(orgnFile.toPath(), modifiedFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
dataObject.set("CRDN_PHOTO"+(j+1), modifiedFilePath);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
File file = new File(metaFilePath);
|
|
|
|
|
|
|
|
if (!file.exists()) {
|
|
|
|
|
|
|
|
file.createNewFile();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
FileWriter fw = new FileWriter(file);
|
|
|
|
|
|
|
|
BufferedWriter writer = new BufferedWriter(fw);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//외주파일 설정
|
|
|
|
|
|
|
|
List<DataObject> printItems = new ArrayList<DataObject>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for(int i=0; i < dataObjectList.size(); i++) {
|
|
|
|
|
|
|
|
DataObject dataObject = dataObjectList.get(i);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(i != 0) {
|
|
|
|
|
|
|
|
writer.write("\n");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
String line = "";
|
|
|
|
|
|
|
|
for(DataObject printItem : printItems){
|
|
|
|
|
|
|
|
String colNm = printItem.string("COL_NM");
|
|
|
|
|
|
|
|
int byteCnt = printItem.number("BYTE_CNT").intValue();
|
|
|
|
|
|
|
|
line += hangul.rpadByte(dataObject.string(colNm), byteCnt, " ");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
writer.write(line);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
writer.close();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String zipFileName = yyyymmdd + printKorName + ".zip";
|
|
|
|
|
|
|
|
String zipFilePath = outsourcingResultPath + File.separator + zipFileName;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ZipFile zipFile = new ZipFile(zipFilePath);
|
|
|
|
|
|
|
|
zipFile.addFile(new File(metaFilePath));
|
|
|
|
|
|
|
|
zipFile.addFolder(new File(imagesFolderPath));
|
|
|
|
|
|
|
|
zipFile.close();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
result.put("filePath", zipFilePath);
|
|
|
|
|
|
|
|
result.put("fileName", zipFileName);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
|
|
|
throw new RuntimeException("외주파일생성 중 오류가 발생하였습니다.");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|