|
|
|
@ -1,6 +1,9 @@
|
|
|
|
|
package cokr.xit.fims.crdn.service.bean;
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.math.BigInteger;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Comparator;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
@ -8,10 +11,12 @@ 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;
|
|
|
|
|
import cokr.xit.base.file.service.bean.FileBean;
|
|
|
|
|
import cokr.xit.base.file.web.FileInfoFactory;
|
|
|
|
|
import cokr.xit.fims.crdn.Crdn;
|
|
|
|
|
import cokr.xit.fims.crdn.dao.GlobalStngMapper;
|
|
|
|
|
import cokr.xit.fims.crdn.service.CrdnService;
|
|
|
|
@ -71,35 +76,96 @@ public class ImportServiceBean extends AbstractServiceBean implements ImportServ
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public HashMap<String, Object> createCrdnByEquipmentLinkFile(String entType, List<DataObject> linkFileInfoList) {
|
|
|
|
|
public HashMap<String, Object> createCrdnByEquipmentLinkFile(String taskSeCd, String entType, List<DataObject> linkFileInfoList) {
|
|
|
|
|
HashMap<String, Object> resultMap = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
resultMap.put("saved", false);
|
|
|
|
|
boolean saved = false;
|
|
|
|
|
|
|
|
|
|
Crdn crdn = new Crdn();
|
|
|
|
|
crdn.setCrdnRegSeCd("07");
|
|
|
|
|
crdn.setTaskSeCd(taskSeCd);
|
|
|
|
|
|
|
|
|
|
List<FileInfo> fileInfoList = new ArrayList<FileInfo>();
|
|
|
|
|
|
|
|
|
|
if(entType.equals("이노")) {
|
|
|
|
|
crdn.setCrdnInptSeCd("11");
|
|
|
|
|
|
|
|
|
|
crdn.setVltnCd("01");
|
|
|
|
|
|
|
|
|
|
//1. 연계파일정보를 단속 엔티티로 변환
|
|
|
|
|
DataObject bgngData = linkFileInfoList.stream()
|
|
|
|
|
.min(Comparator.comparing(item -> new BigInteger(item.string("CRDN_YMD_TM"))))
|
|
|
|
|
.orElseThrow();
|
|
|
|
|
|
|
|
|
|
DataObject endData = linkFileInfoList.stream()
|
|
|
|
|
.max(Comparator.comparing(item -> new BigInteger(item.string("CRDN_YMD_TM"))))
|
|
|
|
|
.orElseThrow();
|
|
|
|
|
|
|
|
|
|
crdn.setCrdnBgngTm(bgngData.string("CRDN_YMD_TM").substring(8));
|
|
|
|
|
crdn.setCrdnEndTm(endData.string("CRDN_YMD_TM").substring(8));
|
|
|
|
|
|
|
|
|
|
DataObject linkFileInfo = endData;
|
|
|
|
|
crdn.setSggCd(globalStngMapper.selectSggCdForCurrentUser());
|
|
|
|
|
crdn.setVhrno(linkFileInfo.string("VHRNO"));
|
|
|
|
|
crdn.setCrdnYmd(linkFileInfo.string("CRDN_YMD_TM").substring(0,8));
|
|
|
|
|
crdn.setCrdnTm(linkFileInfo.string("CRDN_YMD_TM").substring(8));
|
|
|
|
|
crdn.setGpsX(linkFileInfo.string("LOCATION_X"));
|
|
|
|
|
crdn.setGpsY(linkFileInfo.string("LOCATION_Y"));
|
|
|
|
|
crdn.setCrdnStdgNm(linkFileInfo.string("CRDN_STDG_NM"));
|
|
|
|
|
crdn.setCrdnPlc(linkFileInfo.string("CRDN_PLC"));
|
|
|
|
|
|
|
|
|
|
//linkFileInfo.string("DEVICE_ID");
|
|
|
|
|
//linkFileInfo.string("CRDN_ADDRESS");
|
|
|
|
|
|
|
|
|
|
List<File> files = new ArrayList<>();
|
|
|
|
|
for (DataObject linkFileInfo0 : linkFileInfoList) {
|
|
|
|
|
files.add(new File(linkFileInfo0.string("FILE_PATH")));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//1. 연계파일정보 to Crdn
|
|
|
|
|
fileInfoList = new FileInfoFactory().createFileInfos(null, files);
|
|
|
|
|
for (int iLoop = 0; iLoop < fileInfoList.size(); iLoop++) {
|
|
|
|
|
fileInfoList.get(iLoop).setName("image"+iLoop+"."+FilenameUtils.getExtension(fileInfoList.get(iLoop).getName()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//2. 차적
|
|
|
|
|
crdn.setCrdnYmd(globalStngMapper.selectSggCdForCurrentUser());
|
|
|
|
|
crdn.setVhrno("47너7721");
|
|
|
|
|
crdn.setCrdnYmd("20230922");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(entType.equals("KNL")) {
|
|
|
|
|
crdn.setCrdnInptSeCd("12");
|
|
|
|
|
|
|
|
|
|
List<Crdn> crdns = new ArrayList<Crdn>();
|
|
|
|
|
crdns.add(crdn);
|
|
|
|
|
importBean.setVehicleInfo(crdns);
|
|
|
|
|
crdn.setVltnCd("01");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//3.등록
|
|
|
|
|
//saved = crdnBean.create(null, c, null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//2. 차적 조회
|
|
|
|
|
List<Crdn> crdns = new ArrayList<Crdn>();
|
|
|
|
|
crdns.add(crdn);
|
|
|
|
|
importBean.setVehicleInfo(crdns);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//resultMap.put("alertMessage", "년 월 일로 말소된 차량입니다.");
|
|
|
|
|
//3.등록
|
|
|
|
|
saved = crdnBean.create(null, crdn, fileInfoList);
|
|
|
|
|
|
|
|
|
|
//resultMap.put("failReason", "");
|
|
|
|
|
resultMap.put("saved", saved);
|
|
|
|
|
|
|
|
|
|
if(saved) {
|
|
|
|
|
for(DataObject delInfo : linkFileInfoList) {
|
|
|
|
|
crdnBean.removeEquipmentLinkFile(entType, delInfo.string("FILE_NAME"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!ifEmpty(crdn.getErsrRegYmd(), () -> "").equals("")) {
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
String alertMessage = vhrno + " : " + ersrYear + "년" + ersrMonth + "월" + ersrDay + "일로 말소된 차량입니다.";
|
|
|
|
|
resultMap.put("alertMessage", alertMessage);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
resultMap.put("failReason", "기타 오류");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return resultMap;
|
|
|
|
|
}
|
|
|
|
|