|
|
|
|
@ -7,11 +7,11 @@ import java.util.Comparator;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.Optional;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
|
|
|
|
import org.apache.commons.io.FilenameUtils;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import cokr.xit.base.file.FileInfo;
|
|
|
|
|
@ -20,6 +20,7 @@ import cokr.xit.base.file.web.FileInfoFactory;
|
|
|
|
|
import cokr.xit.base.user.dao.UserMapper;
|
|
|
|
|
import cokr.xit.fims.cmmn.CmmnUtil;
|
|
|
|
|
import cokr.xit.fims.crdn.Crdn;
|
|
|
|
|
import cokr.xit.fims.crdn.CrdnQuery;
|
|
|
|
|
import cokr.xit.fims.crdn.Team;
|
|
|
|
|
import cokr.xit.fims.crdn.dao.CrdnTeamMapper;
|
|
|
|
|
import cokr.xit.fims.crdn.receive.eqpmnt.SingleFileParser;
|
|
|
|
|
@ -46,6 +47,8 @@ public class ImportServiceBean extends AbstractServiceBean implements ImportServ
|
|
|
|
|
private CrdnService crdnService;
|
|
|
|
|
@Resource(name = "crdnBean")
|
|
|
|
|
private CrdnBean crdnBean;
|
|
|
|
|
@Resource(name = "crdnStngBean")
|
|
|
|
|
private CrdnStngBean crdnStngBean;
|
|
|
|
|
|
|
|
|
|
@Resource(name="userMapper")
|
|
|
|
|
protected UserMapper userMapper;
|
|
|
|
|
@ -83,152 +86,178 @@ public class ImportServiceBean extends AbstractServiceBean implements ImportServ
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public HashMap<String, Object> createCrdnByEquipmentLinkFile(Map<String,String> processInfo, List<DataObject> linkFileInfoList) {
|
|
|
|
|
public HashMap<String, Object> createCrdnByEquipmentLinkFile(Map<String,String> processInfo, List<DataObject> fileList) {
|
|
|
|
|
String workPath = processInfo.get("workPath");
|
|
|
|
|
String taskSeCd = processInfo.get("taskSeCd");
|
|
|
|
|
String orgID = currentUser().getOrgID();
|
|
|
|
|
String fileGroupType = processInfo.get("fileGroupType");
|
|
|
|
|
boolean statByTeamEquipment = TaskProcessor.get().statByTeamEquipment(taskSeCd);
|
|
|
|
|
HashMap<String, Object> resultMap = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
Crdn crdn = new Crdn();
|
|
|
|
|
crdn.setCrdnRegSeCd("07");
|
|
|
|
|
crdn.setTaskSeCd(taskSeCd);
|
|
|
|
|
crdn.setSggCd(currentUser().getOrgID());
|
|
|
|
|
Map<String, Object> dividedInfo = this.divideInformation(linkFileInfoList, fileGroupType);
|
|
|
|
|
|
|
|
|
|
DataObject metaFileInfo = (DataObject)dividedInfo.get("metaInfo");
|
|
|
|
|
List<DataObject> imageFileInfoList = CmmnUtil.getDataObjectListFromMap(dividedInfo,"imageInfo");
|
|
|
|
|
DataObject bgngData = (DataObject)dividedInfo.get("bgngData");
|
|
|
|
|
DataObject endData = (DataObject)dividedInfo.get("endData");
|
|
|
|
|
|
|
|
|
|
//1. 연계파일정보를 단속 엔티티로 변환
|
|
|
|
|
crdnTimeRangeSet(crdn, bgngData, endData);
|
|
|
|
|
|
|
|
|
|
String crdnInptSeCd = switch (blankIfEmpty(metaFileInfo.get("LINK_ENT_NM"))) {
|
|
|
|
|
case "ino" -> "11";
|
|
|
|
|
case "knl" -> "12";
|
|
|
|
|
default -> "15";
|
|
|
|
|
};
|
|
|
|
|
crdn.setCrdnInptSeCd(crdnInptSeCd);
|
|
|
|
|
crdn.setVltnCd(ifEmpty(metaFileInfo.string("VLTN_CD"), () -> "01"));
|
|
|
|
|
crdn.setCrdnSpareaCd(ifEmpty(metaFileInfo.string("CRDN_SPAREA_CD"), () -> "00"));
|
|
|
|
|
|
|
|
|
|
crdn.setVhrno(metaFileInfo.string("VHRNO"));
|
|
|
|
|
crdn.setCrdnYmd(metaFileInfo.string("CRDN_YMD"));
|
|
|
|
|
crdn.setCrdnTm(metaFileInfo.string("CRDN_TM"));
|
|
|
|
|
if (crdn.getCrdnBgngTm() == null) {
|
|
|
|
|
crdn.setCrdnBgngTm(metaFileInfo.string("CRDN_BGNG_TM"));
|
|
|
|
|
crdn.setCrdnEndTm(metaFileInfo.string("CRDN_END_TM"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
crdn.setGpsX(metaFileInfo.string("GPS_X"));
|
|
|
|
|
crdn.setGpsY(metaFileInfo.string("GPS_Y"));
|
|
|
|
|
crdn.setCrdnPlc(metaFileInfo.string("CRDN_PLC"));
|
|
|
|
|
crdn.setCrdnRoadNm(metaFileInfo.string("CRDN_ROAD_NM"));
|
|
|
|
|
crdn.setCrdnStdgNm(metaFileInfo.string("CRDN_STDG_NM"));
|
|
|
|
|
|
|
|
|
|
crdn.setCrdnSeCd(metaFileInfo.string("CRDN_SE_CD"));
|
|
|
|
|
crdn.setMoscX(metaFileInfo.string("MOSC_X"));
|
|
|
|
|
crdn.setMoscY(metaFileInfo.string("MOSC_Y"));
|
|
|
|
|
|
|
|
|
|
if (TaskProcessor.get().statByTeamEquipment(taskSeCd)) {
|
|
|
|
|
if (!isEmpty(crdn.getCrdnSeCd()) && !isEmpty(metaFileInfo.string("EQPMNT_CD"))) {
|
|
|
|
|
Team team = new Team();
|
|
|
|
|
team.setSggCd(crdn.getSggCd());
|
|
|
|
|
team.setTaskSeCd(taskSeCd);
|
|
|
|
|
team.setTeamNm(metaFileInfo.string("EQPMNT_CD"));
|
|
|
|
|
DataObject teamInfo = crdnTeamMapper.selectTeamInfoByName(team);
|
|
|
|
|
|
|
|
|
|
if (teamInfo != null && crdn.getCrdnSeCd().equals(teamInfo.string("CRDN_SE_CD"))) {
|
|
|
|
|
crdn.setTeamId(teamInfo.string("TEAM_ID"));
|
|
|
|
|
List<DataObject> crdnList = divideFiles(fileList).stream()
|
|
|
|
|
.map(dividedInfo -> {
|
|
|
|
|
Crdn crdn = new Crdn();
|
|
|
|
|
crdn.setCrdnRegSeCd("07");
|
|
|
|
|
crdn.setTaskSeCd(taskSeCd);
|
|
|
|
|
crdn.setSggCd(orgID);
|
|
|
|
|
|
|
|
|
|
DataObject metaInfo = (DataObject)dividedInfo.get("metaInfo");
|
|
|
|
|
List<DataObject> imageList = CmmnUtil.getDataObjectListFromMap(dividedInfo,"imageInfo");
|
|
|
|
|
DataObject bgngData = (DataObject)dividedInfo.get("bgngData");
|
|
|
|
|
DataObject endData = (DataObject)dividedInfo.get("endData");
|
|
|
|
|
//1. 연계파일정보를 단속 엔티티로 변환
|
|
|
|
|
crdnTimeRangeSet(crdn, bgngData, endData);
|
|
|
|
|
|
|
|
|
|
String crdnInptSeCd = switch (blankIfEmpty(metaInfo.get("LINK_ENT_NM"))) {
|
|
|
|
|
case "ino" -> "11";
|
|
|
|
|
case "knl" -> "12";
|
|
|
|
|
default -> "15";
|
|
|
|
|
};
|
|
|
|
|
crdn.setCrdnInptSeCd(crdnInptSeCd);
|
|
|
|
|
crdn.setVltnCd(ifEmpty(metaInfo.string("VLTN_CD"), () -> "01"));
|
|
|
|
|
crdn.setCrdnSpareaCd(ifEmpty(metaInfo.string("CRDN_SPAREA_CD"), () -> "00"));
|
|
|
|
|
|
|
|
|
|
crdn.setVhrno(metaInfo.string("VHRNO"));
|
|
|
|
|
crdn.setCrdnYmd(metaInfo.string("CRDN_YMD"));
|
|
|
|
|
crdn.setCrdnTm(metaInfo.string("CRDN_TM"));
|
|
|
|
|
if (isEmpty(crdn.getCrdnBgngTm())) {
|
|
|
|
|
crdn.setCrdnBgngTm(metaInfo.string("CRDN_BGNG_TM"));
|
|
|
|
|
crdn.setCrdnEndTm(metaInfo.string("CRDN_END_TM"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//metaFileInfo.string("PLATE_WIDTH");
|
|
|
|
|
//metaFileInfo.string("PLATE_HEIGHT");
|
|
|
|
|
List<FileInfo> fileInfoList = this.parsedDataInfoToFileInfo(imageFileInfoList, fileGroupType);
|
|
|
|
|
|
|
|
|
|
crdn.setGpsX(metaInfo.string("GPS_X"));
|
|
|
|
|
crdn.setGpsY(metaInfo.string("GPS_Y"));
|
|
|
|
|
crdn.setCrdnPlc(metaInfo.string("CRDN_PLC"));
|
|
|
|
|
crdn.setCrdnRoadNm(metaInfo.string("CRDN_ROAD_NM"));
|
|
|
|
|
crdn.setCrdnStdgNm(metaInfo.string("CRDN_STDG_NM"));
|
|
|
|
|
|
|
|
|
|
crdn.setCrdnSeCd(metaInfo.string("CRDN_SE_CD"));
|
|
|
|
|
crdn.setMoscX(metaInfo.string("MOSC_X"));
|
|
|
|
|
crdn.setMoscY(metaInfo.string("MOSC_Y"));
|
|
|
|
|
|
|
|
|
|
if (statByTeamEquipment) {
|
|
|
|
|
if (!isEmpty(crdn.getCrdnSeCd()) && !isEmpty(metaInfo.string("EQPMNT_CD"))) {
|
|
|
|
|
Team team = new Team();
|
|
|
|
|
team.setSggCd(crdn.getSggCd());
|
|
|
|
|
team.setTaskSeCd(taskSeCd);
|
|
|
|
|
team.setTeamNm(metaInfo.string("EQPMNT_CD"));
|
|
|
|
|
DataObject teamInfo = crdnTeamMapper.selectTeamInfoByName(team);
|
|
|
|
|
|
|
|
|
|
if (teamInfo != null && crdn.getCrdnSeCd().equals(teamInfo.string("CRDN_SE_CD"))) {
|
|
|
|
|
crdn.setTeamId(teamInfo.string("TEAM_ID"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//metaInfo.string("PLATE_WIDTH");
|
|
|
|
|
//metaInfo.string("PLATE_HEIGHT");
|
|
|
|
|
List<FileInfo> fileInfos = parseDataInfoToFileInfo(imageList, fileGroupType);
|
|
|
|
|
DataObject result = new DataObject()
|
|
|
|
|
.set("crdn", crdn)
|
|
|
|
|
.set("fileInfos", fileInfos);
|
|
|
|
|
return result;
|
|
|
|
|
})
|
|
|
|
|
.toList();
|
|
|
|
|
|
|
|
|
|
List<Crdn> crdns = crdnList.stream()
|
|
|
|
|
.map(info -> (Crdn)info.get("crdn"))
|
|
|
|
|
.toList();
|
|
|
|
|
//2. 차적 조회
|
|
|
|
|
importBean.setVehicleInfo(List.of(crdn));
|
|
|
|
|
|
|
|
|
|
importBean.setVehicleInfo(crdns);
|
|
|
|
|
|
|
|
|
|
List<String>
|
|
|
|
|
vhrnos = crdns.stream().map(crdn -> crdn.getVhrno()).toList(),
|
|
|
|
|
exempted = crdnStngBean.selectExemptionVehicleList(new CrdnQuery().setVhrnos(vhrnos).setSggCd(orgID))
|
|
|
|
|
.stream()
|
|
|
|
|
.map(row -> row.string("VHRNO"))
|
|
|
|
|
.toList();
|
|
|
|
|
//3.등록
|
|
|
|
|
boolean saved = crdnBean.create(null, crdn, fileInfoList);
|
|
|
|
|
HashMap<String, Object> resultMap = new HashMap<>();
|
|
|
|
|
resultMap.put("saved", saved);
|
|
|
|
|
|
|
|
|
|
if (saved) {
|
|
|
|
|
for (DataObject delInfo : linkFileInfoList) {
|
|
|
|
|
crdnBean.removeEquipmentLinkFile(workPath, delInfo.string("FILE_NAME"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!isEmpty(crdn.getErsrRegYmd())) {
|
|
|
|
|
String vhrno = crdn.getVhrno();
|
|
|
|
|
String ersrRegYmd = crdn.getErsrRegYmd();
|
|
|
|
|
String ersrYear = ersrRegYmd.substring(0, 4);
|
|
|
|
|
String ersrMonth = ersrRegYmd.substring(4, 6);
|
|
|
|
|
String ersrDay = ersrRegYmd.substring(6, 8);
|
|
|
|
|
crdnList.forEach(info -> {
|
|
|
|
|
Crdn crdn = (Crdn)info.get("crdn");
|
|
|
|
|
if (exempted.contains(crdn.getVhrno()))
|
|
|
|
|
crdn.setCrdnSttsCd("81"); // 면제차량
|
|
|
|
|
boolean saved = crdnBean.create(null, crdn, (List<FileInfo>)info.get("fileInfos"));
|
|
|
|
|
resultMap.put("saved", saved);
|
|
|
|
|
if (saved) {
|
|
|
|
|
if (!isEmpty(crdn.getErsrRegYmd())) {
|
|
|
|
|
String vhrno = crdn.getVhrno();
|
|
|
|
|
String ersrRegYmd = crdn.getErsrRegYmd();
|
|
|
|
|
String ersrYear = ersrRegYmd.substring(0, 4);
|
|
|
|
|
String ersrMonth = ersrRegYmd.substring(4, 6);
|
|
|
|
|
String ersrDay = ersrRegYmd.substring(6, 8);
|
|
|
|
|
|
|
|
|
|
resultMap.put("alertMessage", vhrno + " : " + ersrYear + "년" + ersrMonth + "월" + ersrDay + "일로 말소된 차량입니다.");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
resultMap.put("alertMessage", vhrno + " : " + ersrYear + "년" + ersrMonth + "월" + ersrDay + "일로 말소된 차량입니다.");
|
|
|
|
|
} else {
|
|
|
|
|
resultMap.put("failReason", "기타 오류");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
resultMap.put("failReason", "기타 오류");
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
fileList.forEach(delInfo -> crdnBean.removeEquipmentLinkFile(workPath, delInfo.string("FILE_NAME")));
|
|
|
|
|
|
|
|
|
|
return resultMap;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**파싱된 데이터 목록을 메타정보, 이미지정보목록, 최초단속자료, 최종단속자료로 분리한다. <br />
|
|
|
|
|
* @param linkFileInfoList 연계파일정보목록, fileGroupType 연계파일그룹형식
|
|
|
|
|
* @param fileList 연계파일정보목록, fileGroupType 연계파일그룹형식
|
|
|
|
|
* @return 메타정보, 이미지정보목록, 최초단속자료, 최종단속자료
|
|
|
|
|
*/
|
|
|
|
|
public Map<String,Object> divideInformation(List<DataObject> linkFileInfoList, String fileGroupType) {
|
|
|
|
|
Map<String, Object> result = new HashMap<String, Object>();
|
|
|
|
|
|
|
|
|
|
DataObject metaFileInfo = null;
|
|
|
|
|
List<DataObject> imageFileInfoList = new ArrayList<DataObject>();
|
|
|
|
|
DataObject[] bgngAndEnd = {null, null};
|
|
|
|
|
|
|
|
|
|
if ("TXT".equals(fileGroupType)) {
|
|
|
|
|
for (DataObject linkFileInfo : linkFileInfoList) {
|
|
|
|
|
if (linkFileInfo.string("FILE_EXTENSION").toUpperCase().equals("TXT")) {
|
|
|
|
|
metaFileInfo = linkFileInfo;
|
|
|
|
|
} else {
|
|
|
|
|
imageFileInfoList.add(linkFileInfo);
|
|
|
|
|
private List<DataObject> divideFiles(List<DataObject> fileList) {
|
|
|
|
|
Map<String, List<DataObject>> byName = fileList.stream().collect(Collectors.groupingBy(fileInfo -> {
|
|
|
|
|
String filename = fileInfo.string("FILE_NAME");
|
|
|
|
|
return filename.substring(0, filename.lastIndexOf("_"));
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
List<DataObject> list = byName.values().stream()
|
|
|
|
|
.map(files -> {
|
|
|
|
|
DataObject result = new DataObject();
|
|
|
|
|
DataObject metaInfo = null;
|
|
|
|
|
List<DataObject> imgs = null;
|
|
|
|
|
DataObject[] bgngAndEnd = null;
|
|
|
|
|
|
|
|
|
|
DataObject first = files.get(0);
|
|
|
|
|
String groupType = first.string("FILE_GROUP_TYPE");
|
|
|
|
|
if ("TXT".equalsIgnoreCase(groupType)) {
|
|
|
|
|
Optional<DataObject> found = files.stream()
|
|
|
|
|
.filter(file -> "TXT".equalsIgnoreCase(file.string("FILE_EXTENSION")))
|
|
|
|
|
.findFirst();
|
|
|
|
|
if (found.isPresent()) {
|
|
|
|
|
files.remove(metaInfo = found.get());
|
|
|
|
|
}
|
|
|
|
|
imgs = files;
|
|
|
|
|
bgngAndEnd = getBgngDataAndEndData(imgs);
|
|
|
|
|
} else if ("JPG".equalsIgnoreCase(groupType)) {
|
|
|
|
|
bgngAndEnd = getBgngDataAndEndData(imgs = files);
|
|
|
|
|
metaInfo = bgngAndEnd[1] == null ? first : bgngAndEnd[1];
|
|
|
|
|
} else if ("BIN".equalsIgnoreCase(groupType)) {
|
|
|
|
|
metaInfo = first;
|
|
|
|
|
imgs = new ArrayList<>();
|
|
|
|
|
for (int i = 1, otherPhotoCnt = toInt(metaInfo.get("PHOTO_CNT")); i <= otherPhotoCnt; i++){
|
|
|
|
|
String fileName = metaInfo.string("B64IMAGE" + i + "_NM");
|
|
|
|
|
String b64str = metaInfo.string("B64IMAGE" + i);
|
|
|
|
|
DataObject dataObject = new DataObject()
|
|
|
|
|
.set("B64IMAGE_NM", fileName)
|
|
|
|
|
.set("B64IMAGE", b64str);
|
|
|
|
|
imgs.add(dataObject);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
bgngAndEnd = getBgngDataAndEndData(imageFileInfoList);
|
|
|
|
|
} else if ("JPG".equals(fileGroupType)){
|
|
|
|
|
imageFileInfoList = linkFileInfoList;
|
|
|
|
|
bgngAndEnd = getBgngDataAndEndData(linkFileInfoList);
|
|
|
|
|
metaFileInfo = bgngAndEnd[1] == null ? linkFileInfoList.get(0) : bgngAndEnd[1];
|
|
|
|
|
} else if ("BIN".equals(fileGroupType)) {
|
|
|
|
|
metaFileInfo = linkFileInfoList.get(0);
|
|
|
|
|
for (int i = 1, otherPhotoCnt = toInt(metaFileInfo.get("PHOTO_CNT")); i <= otherPhotoCnt; i++){
|
|
|
|
|
String fileName = metaFileInfo.string("B64IMAGE"+i+"_NM");
|
|
|
|
|
String b64str = metaFileInfo.string("B64IMAGE"+i);
|
|
|
|
|
DataObject dataObject = new DataObject();
|
|
|
|
|
dataObject.put("B64IMAGE_NM", fileName);
|
|
|
|
|
dataObject.put("B64IMAGE", b64str);
|
|
|
|
|
imageFileInfoList.add(dataObject);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result.put("metaInfo", metaFileInfo);
|
|
|
|
|
result.put("imageInfo", imageFileInfoList);
|
|
|
|
|
result.put("bgngData", bgngAndEnd[0]);
|
|
|
|
|
result.put("endData", bgngAndEnd[1]);
|
|
|
|
|
result
|
|
|
|
|
.set("metaInfo", metaInfo)
|
|
|
|
|
.set("imageInfo", imgs)
|
|
|
|
|
.set("bgngData", bgngAndEnd[0])
|
|
|
|
|
.set("endData", bgngAndEnd[1]);
|
|
|
|
|
return result;
|
|
|
|
|
})
|
|
|
|
|
.toList();
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**단속이미지정보 목록 내에서 최초단속자료와 최종단속자료를 반환한다. 단속일시 정보가 없을 경우 null을 반환한다. <br />
|
|
|
|
|
* @param imageDataList 단속이미지정보 목록
|
|
|
|
|
* @return 최초단속자료, 최종단속자료
|
|
|
|
|
*/
|
|
|
|
|
public DataObject[] getBgngDataAndEndData(List<DataObject> imageDataList) {
|
|
|
|
|
private DataObject[] getBgngDataAndEndData(List<DataObject> imageDataList) {
|
|
|
|
|
DataObject[] bgngAndEnd = {null, null};
|
|
|
|
|
|
|
|
|
|
if (!isEmpty(imageDataList.get(0).get("CRDN_TIMESTAMP"))) {
|
|
|
|
|
@ -251,7 +280,7 @@ public class ImportServiceBean extends AbstractServiceBean implements ImportServ
|
|
|
|
|
* @param crdn 단속대장, bgngData 최초단속자료, endData 최종단속자료
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public void crdnTimeRangeSet(Crdn crdn, DataObject bgngData, DataObject endData) {
|
|
|
|
|
private void crdnTimeRangeSet(Crdn crdn, DataObject bgngData, DataObject endData) {
|
|
|
|
|
if (isEmpty(bgngData) || isEmpty(endData)) return;
|
|
|
|
|
|
|
|
|
|
String crdnBgngTm = endData.string("CRDN_BGNG_TM");
|
|
|
|
|
@ -268,32 +297,32 @@ public class ImportServiceBean extends AbstractServiceBean implements ImportServ
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**단속이미지정보를 List<FileInfo>로 변환한다. <br />
|
|
|
|
|
* @param imageFileInfoList 단속이미지정보 목록, fileGroupType 연계파일그룹형식
|
|
|
|
|
* @param imageList 단속이미지정보 목록, fileGroupType 연계파일그룹형식
|
|
|
|
|
* @return fileInfo리스트
|
|
|
|
|
*/
|
|
|
|
|
public List<FileInfo> parsedDataInfoToFileInfo(List<DataObject> imageFileInfoList, String fileGroupType){
|
|
|
|
|
private List<FileInfo> parseDataInfoToFileInfo(List<DataObject> imageList, String fileGroupType){
|
|
|
|
|
try {
|
|
|
|
|
List<FileInfo> fileInfoList = null;
|
|
|
|
|
List<FileInfo> fileInfos = null;
|
|
|
|
|
if ("JPG,TXT".contains(fileGroupType)) {
|
|
|
|
|
List<File> files = imageFileInfoList.stream()
|
|
|
|
|
.map(imageFileInfo -> new File(imageFileInfo.string("FILE_PATH")))
|
|
|
|
|
List<File> files = imageList.stream()
|
|
|
|
|
.map(imageInfo -> new File(imageInfo.string("FILE_PATH")))
|
|
|
|
|
.toList();
|
|
|
|
|
|
|
|
|
|
fileInfoList = new FileInfoFactory().createFileInfos(null, files);
|
|
|
|
|
for (int i = 0; i < fileInfoList.size(); i++) {
|
|
|
|
|
FileInfo fileInfo = fileInfoList.get(i);
|
|
|
|
|
fileInfo.setName("image" + i + "." + FilenameUtils.getExtension(fileInfo.getName()));
|
|
|
|
|
fileInfos = new FileInfoFactory().createFileInfos(null, files);
|
|
|
|
|
for (int i = 0; i < fileInfos.size(); i++) {
|
|
|
|
|
FileInfo fileInfo = fileInfos.get(i);
|
|
|
|
|
fileInfo.setName("image" + i + "." + fileInfo.getExtension());
|
|
|
|
|
}
|
|
|
|
|
} else if ("BIN".equals(fileGroupType)) {
|
|
|
|
|
fileInfoList = new ArrayList<>();
|
|
|
|
|
for (int i = 0; i < imageFileInfoList.size(); i++){
|
|
|
|
|
String fileName = imageFileInfoList.get(i).string("B64IMAGE_NM");
|
|
|
|
|
String b64str = imageFileInfoList.get(i).string("B64IMAGE");
|
|
|
|
|
fileInfos = new ArrayList<>();
|
|
|
|
|
for (int i = 0; i < imageList.size(); i++){
|
|
|
|
|
String fileName = imageList.get(i).string("B64IMAGE_NM");
|
|
|
|
|
String b64str = imageList.get(i).string("B64IMAGE");
|
|
|
|
|
FileInfo FileInfo = SingleFileParser.base64ToFileInfo(fileName, b64str, (i + 1));
|
|
|
|
|
fileInfoList.add(FileInfo);
|
|
|
|
|
fileInfos.add(FileInfo);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return fileInfoList;
|
|
|
|
|
return fileInfos;
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
throw runtimeException(e);
|
|
|
|
|
}
|
|
|
|
|
|