|
|
|
|
@ -1,10 +1,7 @@
|
|
|
|
|
package com.worker.scheduler.smg.service;
|
|
|
|
|
|
|
|
|
|
import com.worker.domain.entity.*;
|
|
|
|
|
import com.worker.domain.repo.cp.CpAnswerRepository;
|
|
|
|
|
import com.worker.domain.repo.cp.CpBdongRepository;
|
|
|
|
|
import com.worker.domain.repo.cp.CpMainRepository;
|
|
|
|
|
import com.worker.domain.repo.cp.CpSetinfoRepository;
|
|
|
|
|
import com.worker.domain.repo.cp.*;
|
|
|
|
|
import com.worker.domain.repo.ep.EpSetinfoRepository;
|
|
|
|
|
import com.worker.dto.SinmungoDto;
|
|
|
|
|
import com.worker.util.common.CommonUtils;
|
|
|
|
|
@ -18,7 +15,9 @@ import org.springframework.core.env.Environment;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import java.nio.file.Paths;
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
|
import java.time.Year;
|
|
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
@ -41,6 +40,8 @@ public class DbPolling {
|
|
|
|
|
|
|
|
|
|
private final CpMainRepository cpMainRepository;
|
|
|
|
|
private final CpAnswerRepository cpAnswerRepository;
|
|
|
|
|
private final CpMainEtc1Repository cpMainEtc1Repository;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public SinmungoDto.SetInfo findSetInfo() {
|
|
|
|
|
|
|
|
|
|
@ -80,7 +81,9 @@ public class DbPolling {
|
|
|
|
|
String mmCode = getMaxMmCode(setInfo);
|
|
|
|
|
|
|
|
|
|
List<CpMain> cpMainList = cpList.stream()
|
|
|
|
|
.map(xml -> CpMain.builder()
|
|
|
|
|
.map(xml -> {
|
|
|
|
|
String sgpos = getSgPosByReason(setInfo, xml.getPeti_reason_l());
|
|
|
|
|
return CpMain.builder()
|
|
|
|
|
.mmCode(mmCode)
|
|
|
|
|
.mmSggcode(setInfo.getCpSetinfo().getIntValue1().toString())
|
|
|
|
|
.mmIngb("1") //접수구분
|
|
|
|
|
@ -89,8 +92,8 @@ public class DbPolling {
|
|
|
|
|
.mmSgnm(xml.getPeter_name_v()) //신고자 이름
|
|
|
|
|
.mmSgtel(xml.getDuty_id_v()) //담당자 아이디
|
|
|
|
|
.mmSgcont(trim(xml.getPeti_reason_l())) // 신고내용
|
|
|
|
|
.mmSgpos(getSgPosByReason(setInfo, xml.getPeti_reason_l())) //사고발생지역 주소추출
|
|
|
|
|
// .mmBdcode() //사고발생지역 코드
|
|
|
|
|
.mmSgpos(sgpos) //사고발생지역 주소추출
|
|
|
|
|
.mmBdcode(getBdcodeBySgpos(setInfo, sgpos)) //사고발생지역 코드
|
|
|
|
|
.mmImagecnt(Integer.parseInt(xml.getApndfilcount())) // 이미지 갯수
|
|
|
|
|
// .mmImagegb() //동영상여부
|
|
|
|
|
.mmCarno(null) // 차량번호
|
|
|
|
|
@ -100,13 +103,14 @@ public class DbPolling {
|
|
|
|
|
.mmInuser(0) //등록자
|
|
|
|
|
// .mmIndt() //등록일시
|
|
|
|
|
.mmState("01") //처리상태
|
|
|
|
|
.mmStateDt() //마지막 처리일시
|
|
|
|
|
.mmStateDt(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"))) //마지막 처리일시
|
|
|
|
|
.mmDlgb("2") //등록구분
|
|
|
|
|
.mmOmcode("0") //소유주테이블 코드 (논리fk)
|
|
|
|
|
// .mmGpsX()
|
|
|
|
|
// .mmGpsY()
|
|
|
|
|
.mmGpsX(getGpsByReason(xml.getPeti_reason_l(), "위도"))
|
|
|
|
|
.mmGpsY(getGpsByReason(xml.getPeti_reason_l(), "경도"))
|
|
|
|
|
.mmVideofilenm("" + "Z.mp4")
|
|
|
|
|
.build())
|
|
|
|
|
.build();
|
|
|
|
|
})
|
|
|
|
|
.collect(Collectors.toUnmodifiableList());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -137,6 +141,7 @@ public class DbPolling {
|
|
|
|
|
//
|
|
|
|
|
// cpMainRepository.saveAll(cpMainList);
|
|
|
|
|
// cpAnswerRepository.saveAll(cpAnswerList);
|
|
|
|
|
// cpMainEtc1Repository.saveAll(cpMainEtc1List);
|
|
|
|
|
|
|
|
|
|
// fileBackup(setInfo, cpList);
|
|
|
|
|
}
|
|
|
|
|
@ -195,6 +200,45 @@ public class DbPolling {
|
|
|
|
|
.orElse(null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 1차 추출한 sgpos로 Bdong에 BdCode 추출.
|
|
|
|
|
* */
|
|
|
|
|
private String getBdcodeBySgpos(SinmungoDto.SetInfo setInfo, String sgpos) {
|
|
|
|
|
|
|
|
|
|
if (sgpos == null || setInfo == null || setInfo.getCpBdongList() == null) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return setInfo.getCpBdongList().stream()
|
|
|
|
|
.filter(bdong -> sgpos.contains(bdong.getBdDongName())) // 주소에 포함되는지 확인
|
|
|
|
|
.map(CpBdong::getBdCode) // bdcode만 추출
|
|
|
|
|
.findFirst() // 첫 매칭 항목만 사용
|
|
|
|
|
.orElse(null); // 없으면 null
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 신고내역에서 위도와 경도를 추출한다.
|
|
|
|
|
* */
|
|
|
|
|
private String getGpsByReason(String peti_reason_l, String param) {
|
|
|
|
|
if (peti_reason_l == null || param == null) return null;
|
|
|
|
|
|
|
|
|
|
return Arrays.stream(peti_reason_l.split("\\r?\\n"))
|
|
|
|
|
.filter(line -> line.contains("위도") && line.contains("경도"))
|
|
|
|
|
.map(String::trim)
|
|
|
|
|
.map(line -> {
|
|
|
|
|
// 예: "발생지역 위도:37.38497 경도:127.12325"
|
|
|
|
|
for (String word : line.split("\\s+")) {
|
|
|
|
|
if (word.startsWith(param + ":")) {
|
|
|
|
|
return word.substring((param + ":").length());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
})
|
|
|
|
|
.filter(Objects::nonNull)
|
|
|
|
|
.findFirst()
|
|
|
|
|
.orElse(null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* LawGB(위반코드)와 과태료 금액을 신고내역에서 추출한다.
|
|
|
|
|
* */
|
|
|
|
|
@ -207,7 +251,7 @@ public class DbPolling {
|
|
|
|
|
} else if (peti_reason_l.contains(LawGBEnum.SIGN.getCodeNm())) {
|
|
|
|
|
return LawGBEnum.SIGN;
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
return LawGBEnum.UNKNOWN;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|