지연 - 명의이전 - 일단 접수 02 상태 그대로
parent
7985785bd4
commit
733986b838
@ -1,236 +0,0 @@
|
||||
package go.kr.project.carInspectionPenalty.registrationOm.service.impl.om_checker;
|
||||
|
||||
import egovframework.constant.TaskPrcsSttsConstants;
|
||||
import egovframework.exception.MessageException;
|
||||
import egovframework.util.DateUtil;
|
||||
import go.kr.project.api.model.request.NewBasicRequest;
|
||||
import go.kr.project.api.model.request.NewLedgerRequest;
|
||||
import go.kr.project.api.model.response.NewBasicResponse;
|
||||
import go.kr.project.api.model.response.NewLedgerResponse;
|
||||
import go.kr.project.api.service.ExternalVehicleApiService;
|
||||
import go.kr.project.api.service.VmisCarBassMatterInqireLogService;
|
||||
import go.kr.project.api.service.VmisCarLedgerFrmbkLogService;
|
||||
import go.kr.project.carInspectionPenalty.registrationOm.mapper.CarFfnlgTrgtIncmpMapper;
|
||||
import go.kr.project.carInspectionPenalty.registrationOm.model.CarFfnlgTrgtIncmpVO;
|
||||
import go.kr.project.carInspectionPenalty.registrationOm.service.impl.ComparisonOmRemarkBuilder;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 4. 내사종결 검증 - 순수 명의이전 (31일 이내) (미필)
|
||||
*
|
||||
* <p>부과일자 소유자가 상품용이 아니고, 명의이전 전 소유자도 상품용이 아닌 경우</p>
|
||||
* <p>미필의 경우 부과일자 = 검사유효기간 종료일 + 146일</p>
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class OwnerCloseWithin31OmChecker extends AbstractComparisonOmChecker {
|
||||
|
||||
public OwnerCloseWithin31OmChecker(CarFfnlgTrgtIncmpMapper carFfnlgTrgtIncmpMapper,
|
||||
ExternalVehicleApiService apiService,
|
||||
VmisCarBassMatterInqireLogService bassMatterLogService,
|
||||
VmisCarLedgerFrmbkLogService ledgerLogService) {
|
||||
super(carFfnlgTrgtIncmpMapper, apiService, bassMatterLogService, ledgerLogService);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String check(CarFfnlgTrgtIncmpVO existingData) {
|
||||
String vhclno = existingData.getVhclno();
|
||||
String levyCrtrYmd = existingData.getLevyCrtrYmd(); // 미필: 검사유효기간 종료일 + 146일
|
||||
String inspVldPrd = existingData.getInspVldPrd(); // 검사유효기간
|
||||
|
||||
// 검사유효기간에서 시작일과 종료일 추출
|
||||
String inspVldPrdStart = null;
|
||||
String inspVldPrdEnd = null;
|
||||
if (inspVldPrd != null && inspVldPrd.contains("~")) {
|
||||
String[] dates = inspVldPrd.split("~");
|
||||
inspVldPrdStart = dates[0].trim().replace("-", "");
|
||||
inspVldPrdEnd = dates.length > 1 ? dates[1].trim().replace("-", "") : null;
|
||||
}
|
||||
|
||||
try {
|
||||
// ========== Step 1: 자동차기본정보 조회 (차량번호, 부과일자=검사유효기간 종료일+146일) ==========
|
||||
log.info("[내사종결-명의이전-미필] Step 1: 자동차기본정보 조회 - 차량번호: {}, 부과일자: {}", vhclno, levyCrtrYmd);
|
||||
|
||||
NewBasicRequest step1Request = createBasicRequest(vhclno, null, levyCrtrYmd);
|
||||
NewBasicResponse step1Response = apiService.getBasicInfo(step1Request);
|
||||
bassMatterLogService.updateCarFfnlgTrgtIdByTxIdNewTx(step1Response, existingData.getCarFfnlgTrgtIncmpId());
|
||||
|
||||
if (step1Response == null || step1Response.getRecord() == null || step1Response.getRecord().isEmpty()) {
|
||||
log.warn("[내사종결-명의이전-미필] Step 1 응답 없음 - 차량번호: {}", vhclno);
|
||||
return null;
|
||||
}
|
||||
|
||||
NewBasicResponse.Record step1Record = step1Response.getRecord().get(0);
|
||||
String vin = step1Record.getVin(); // 차대번호
|
||||
String step1OwnerName = step1Record.getRprsOwnrNm(); // 부과일자 기준 소유자명
|
||||
String step1RprsvOwnrIdecno = step1Record.getRprsvOwnrIdecno(); // 부과일자 기준 대표소유자 회원번호
|
||||
|
||||
log.info("[내사종결-명의이전-미필] Step 1 결과 - 차대번호: {}, 소유자명: {}", vin, step1OwnerName);
|
||||
|
||||
// 부과일자 소유자가 상품용 아님
|
||||
if (step1OwnerName != null && step1OwnerName.contains("상품용")) {
|
||||
log.debug("[내사종결-명의이전-미필] 부과일자 소유자가 상품용 - 차량번호: {}, 소유자명: {}", vhclno, step1OwnerName);
|
||||
return null;
|
||||
}
|
||||
|
||||
log.info("[내사종결-명의이전-미필] 부과일자 소유자가 상품용 아님 - 차량번호: {}, 소유자명: {}", vhclno, step1OwnerName);
|
||||
|
||||
// ========== Step 2: 자동차기본정보 조회 (차대번호, 부과일자=오늘일자) ==========
|
||||
String today = LocalDate.now().format(DATE_FORMATTER);
|
||||
log.info("[내사종결-명의이전-미필] Step 2: 자동차기본정보 조회 - 차대번호: {}, 오늘일자: {}", vin, today);
|
||||
|
||||
NewBasicRequest step2Request = createBasicRequest(null, vin, today);
|
||||
NewBasicResponse step2Response = apiService.getBasicInfo(step2Request);
|
||||
bassMatterLogService.updateCarFfnlgTrgtIdByTxIdNewTx(step2Response, existingData.getCarFfnlgTrgtIncmpId());
|
||||
|
||||
if (step2Response == null || step2Response.getRecord() == null || step2Response.getRecord().isEmpty()) {
|
||||
log.warn("[내사종결-명의이전-미필] Step 2 응답 없음 - 차대번호: {}", vin);
|
||||
return null;
|
||||
}
|
||||
|
||||
NewBasicResponse.Record step2Record = step2Response.getRecord().get(0);
|
||||
String currentVhclno = step2Record.getVhrno();
|
||||
String currentOwnerName = step2Record.getRprsOwnrNm();
|
||||
String currentIdecno = step2Record.getRprsvOwnrIdecno();
|
||||
String currentLegalDongCode = step2Record.getUsgsrhldStdgCd();
|
||||
|
||||
log.info("[내사종결-명의이전-미필] Step 2 결과 - 차량번호: {}, 성명: {}, 주민번호: {}, 법정동코드: {}",
|
||||
currentVhclno, currentOwnerName, currentIdecno, currentLegalDongCode);
|
||||
|
||||
// ========== Step 3: 자동차등록원부(갑) 조회 ==========
|
||||
log.info("[내사종결-명의이전-미필] Step 3: 자동차등록원부(갑) 조회 - 차량번호: {}, 성명: {}, 주민번호: {}, 법정동코드: {}",
|
||||
currentVhclno, currentOwnerName, currentIdecno, currentLegalDongCode);
|
||||
|
||||
NewLedgerRequest step3Request = createLedgerRequest(currentVhclno, currentOwnerName, currentIdecno, currentLegalDongCode);
|
||||
NewLedgerResponse step3Response = apiService.getLedgerInfo(step3Request);
|
||||
ledgerLogService.updateCarFfnlgTrgtIdByTxIdNewTx(step3Response, existingData.getCarFfnlgTrgtIncmpId());
|
||||
|
||||
if (step3Response == null) {
|
||||
log.warn("[내사종결-명의이전-미필] Step 3 응답 없음 - 차량번호: {}", currentVhclno);
|
||||
return null;
|
||||
}
|
||||
|
||||
List<NewLedgerResponse.Record> ledgerRecords = step3Response.getRecord();
|
||||
if (ledgerRecords == null || ledgerRecords.isEmpty()) {
|
||||
log.debug("[내사종결-명의이전-미필] 갑부 상세 내역 없음 - 차량번호: {}", vhclno);
|
||||
return null;
|
||||
}
|
||||
|
||||
// ========== 갑부 상세에서 검사유효기간 내 명의이전 레코드 찾기 (가장 최근 일자) ==========
|
||||
log.info("[내사종결-명의이전-미필] 갑부 상세 레코드 검색 시작 - 검사유효기간 시작일: {}, 검사유효기간 종료일: {}", inspVldPrdStart, inspVldPrdEnd);
|
||||
|
||||
NewLedgerResponse.Record targetRecord = null;
|
||||
LocalDate inspVldPrdStartDate = DateUtil.parseDate(inspVldPrdStart);
|
||||
LocalDate inspVldPrdEndDate = DateUtil.parseDate(inspVldPrdEnd);
|
||||
LocalDate latestChgDate = null;
|
||||
|
||||
for (NewLedgerResponse.Record record : ledgerRecords) {
|
||||
String chgYmd = record.getChgYmd();
|
||||
String chgTaskSeCd = record.getChgTaskSeCd();
|
||||
|
||||
// 조건: CHG_TASK_SE_CD == "11" (명의이전)
|
||||
if (!"11".equals(chgTaskSeCd) || chgYmd == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
LocalDate chgDate = DateUtil.parseDate(chgYmd);
|
||||
if (chgDate == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 조건: 검사유효기간 시작일 <= CHG_YMD <= 검사유효기간 종료일
|
||||
if ((chgDate.isEqual(inspVldPrdStartDate) || chgDate.isAfter(inspVldPrdStartDate)) &&
|
||||
(chgDate.isEqual(inspVldPrdEndDate) || chgDate.isBefore(inspVldPrdEndDate))) {
|
||||
|
||||
// 가장 최근 일자 선택
|
||||
if (latestChgDate == null || chgDate.isAfter(latestChgDate)) {
|
||||
targetRecord = record;
|
||||
latestChgDate = chgDate;
|
||||
log.debug("[내사종결-명의이전-미필] 검사유효기간 내 명의이전 발견 - 변경일자: {}, 변경업무: {}", chgYmd, chgTaskSeCd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (targetRecord == null) {
|
||||
log.debug("[내사종결-명의이전-미필] 검사유효기간 내 명의이전 레코드 없음 - 차량번호: {}", vhclno);
|
||||
return null;
|
||||
}
|
||||
|
||||
String targetChgYmd = targetRecord.getChgYmd();
|
||||
log.info("[내사종결-명의이전-미필] 검사유효기간 내 명의이전 발견! 변경일자: {}, 변경업무: {}", targetChgYmd, targetRecord.getChgTaskSeNm());
|
||||
|
||||
// ========== 명의이전일자 ~ 부과일자 사이의 일수 계산 ==========
|
||||
LocalDate chgDate = DateUtil.parseDate(targetChgYmd);
|
||||
LocalDate levyDate = DateUtil.parseDate(levyCrtrYmd);
|
||||
long daysBetween = java.time.temporal.ChronoUnit.DAYS.between(chgDate, levyDate);
|
||||
|
||||
if (daysBetween < 0 || daysBetween > DAYS_THRESHOLD) {
|
||||
log.debug("[내사종결-명의이전-미필] 명의이전일자가 부과일자의 {}일 이내가 아님 - 변경일자: {}, 부과일자: {}, 일수차이: {}일",
|
||||
DAYS_THRESHOLD, targetChgYmd, levyCrtrYmd, daysBetween);
|
||||
return null;
|
||||
}
|
||||
|
||||
log.info("[내사종결-명의이전-미필] 명의이전일자가 부과일자의 {}일 이내 확인 - 변경일자: {}, 부과일자: {}, 일수차이: {}일",
|
||||
DAYS_THRESHOLD, targetChgYmd, levyCrtrYmd, daysBetween);
|
||||
|
||||
// ========== Step 4: 자동차기본정보 조회 (차대번호, 부과일자=CHG_YMD) ==========
|
||||
LocalDate targetDate = DateUtil.parseDate(targetChgYmd);
|
||||
NewBasicRequest step4Request = createBasicRequest(null, vin, targetDate.format(DATE_FORMATTER));
|
||||
NewBasicResponse step4Response = apiService.getBasicInfo(step4Request);
|
||||
bassMatterLogService.updateCarFfnlgTrgtIdByTxIdNewTx(step4Response, existingData.getCarFfnlgTrgtIncmpId());
|
||||
|
||||
if (step4Response == null || step4Response.getRecord() == null || step4Response.getRecord().isEmpty()) {
|
||||
log.warn("[내사종결-명의이전-미필] Step 4 응답 없음 - 차대번호: {}, 부과일자: {}", vin, targetDate.format(DATE_FORMATTER));
|
||||
return null;
|
||||
}
|
||||
|
||||
NewBasicResponse.Record step4Record = step4Response.getRecord().get(0);
|
||||
String step4OwnerName = step4Record.getRprsOwnrNm(); // CHG_YMD 시점의 소유자명
|
||||
String step4RprsvOwnrIdecno = step4Record.getRprsvOwnrIdecno(); // 대표소유자 회원번호
|
||||
|
||||
log.info("[내사종결-명의이전-미필] Step 4 결과 - 소유자명: {}", step4OwnerName);
|
||||
|
||||
// 검사유효기간내 명의변경 소유자와 부과일자의 소유자가 같냐
|
||||
if (step4OwnerName == null || !step4RprsvOwnrIdecno.contains(step1RprsvOwnrIdecno)) {
|
||||
log.debug("[내사종결-명의이전-미필] 명의이전 전 소유자가 상품용 - Step4 소유자명: {}", step4OwnerName);
|
||||
return null;
|
||||
}
|
||||
|
||||
log.info("[내사종결-명의이전-미필] 명의이전 전 소유자가 상품용 아님 - 소유자명: {}", step4OwnerName);
|
||||
|
||||
// ========== 비고 생성 ==========
|
||||
String rmrk = ComparisonOmRemarkBuilder.buildOwnerChangeRemark(
|
||||
step1Record, step4Record, targetRecord,
|
||||
vhclno, levyCrtrYmd, inspVldPrdStart, inspVldPrdEnd, daysBetween
|
||||
);
|
||||
|
||||
// ========== DB 업데이트 ==========
|
||||
existingData.setCarBassMatterInqireId(step1Response.getGeneratedId());
|
||||
existingData.setCarLedgerFrmbkId(step3Response.getGeneratedId());
|
||||
existingData.setTaskPrcsSttsCd(TaskPrcsSttsConstants.TASK_PRCS_STTS_CD_04_INVESTIGATION_CLOSED);
|
||||
existingData.setTaskPrcsYmd(LocalDate.now().format(DATE_FORMATTER));
|
||||
existingData.setCarBscMttrInqFlnm(step4OwnerName);
|
||||
existingData.setCarRegFrmbkChgTaskSeCd(targetRecord.getChgTaskSeCd());
|
||||
existingData.setCarRegFrmbkChgTaskSeNm(targetRecord.getChgTaskSeNm());
|
||||
existingData.setCarRegFrmbkChgYmd(targetRecord.getChgYmd().replace("-", ""));
|
||||
existingData.setCarRegFrmbkDtl(ComparisonOmRemarkBuilder.buildLedgerRecordDetail(targetRecord));
|
||||
existingData.setRmrk(rmrk);
|
||||
|
||||
int updateCount = carFfnlgTrgtIncmpMapper.update(existingData);
|
||||
if (updateCount == 0) {
|
||||
throw new MessageException(String.format("[내사종결-명의이전-미필] 업데이트 실패: %s", vhclno));
|
||||
}
|
||||
|
||||
log.info("[내사종결-명의이전-미필] 처리 완료! 차량번호: {}", vhclno);
|
||||
return TaskPrcsSttsConstants.TASK_PRCS_STTS_CD_04_INVESTIGATION_CLOSED;
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("[내사종결-명의이전-미필] 검증 중 오류 발생 - 차량번호: {}", vhclno, e);
|
||||
throw new MessageException(String.format("[내사종결-명의이전-미필] 검증 중 오류 발생 - 차량번호: %s", vhclno), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,236 +0,0 @@
|
||||
package go.kr.project.carInspectionPenalty.registrationOm.service.impl.om_checker;
|
||||
|
||||
import egovframework.constant.TaskPrcsSttsConstants;
|
||||
import egovframework.exception.MessageException;
|
||||
import egovframework.util.DateUtil;
|
||||
import go.kr.project.api.model.request.NewBasicRequest;
|
||||
import go.kr.project.api.model.request.NewLedgerRequest;
|
||||
import go.kr.project.api.model.response.NewBasicResponse;
|
||||
import go.kr.project.api.model.response.NewLedgerResponse;
|
||||
import go.kr.project.api.service.ExternalVehicleApiService;
|
||||
import go.kr.project.api.service.VmisCarBassMatterInqireLogService;
|
||||
import go.kr.project.api.service.VmisCarLedgerFrmbkLogService;
|
||||
import go.kr.project.carInspectionPenalty.registrationOm.mapper.CarFfnlgTrgtIncmpMapper;
|
||||
import go.kr.project.carInspectionPenalty.registrationOm.model.CarFfnlgTrgtIncmpVO;
|
||||
import go.kr.project.carInspectionPenalty.registrationOm.service.impl.ComparisonOmRemarkBuilder;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 6. 날짜 수정 후 부과 검증 - 순수 명의이전 (31일 초과) (미필)
|
||||
*
|
||||
* <p>부과일자 소유자가 상품용이 아니고, 명의이전 전 소유자도 상품용이 아니며, 31일 초과인 경우</p>
|
||||
* <p>미필의 경우 부과일자 = 검사유효기간 종료일 + 146일</p>
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class OwnerLevyOver31OmChecker extends AbstractComparisonOmChecker {
|
||||
|
||||
public OwnerLevyOver31OmChecker(CarFfnlgTrgtIncmpMapper carFfnlgTrgtIncmpMapper,
|
||||
ExternalVehicleApiService apiService,
|
||||
VmisCarBassMatterInqireLogService bassMatterLogService,
|
||||
VmisCarLedgerFrmbkLogService ledgerLogService) {
|
||||
super(carFfnlgTrgtIncmpMapper, apiService, bassMatterLogService, ledgerLogService);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String check(CarFfnlgTrgtIncmpVO existingData) {
|
||||
String vhclno = existingData.getVhclno();
|
||||
String levyCrtrYmd = existingData.getLevyCrtrYmd(); // 미필: 검사유효기간 종료일 + 146일
|
||||
String inspVldPrd = existingData.getInspVldPrd(); // 검사유효기간
|
||||
|
||||
// 검사유효기간에서 시작일과 종료일 추출
|
||||
String inspVldPrdStart = null;
|
||||
String inspVldPrdEnd = null;
|
||||
if (inspVldPrd != null && inspVldPrd.contains("~")) {
|
||||
String[] dates = inspVldPrd.split("~");
|
||||
inspVldPrdStart = dates[0].trim().replace("-", "");
|
||||
inspVldPrdEnd = dates.length > 1 ? dates[1].trim().replace("-", "") : null;
|
||||
}
|
||||
|
||||
try {
|
||||
// ========== Step 1: 자동차기본정보 조회 (차량번호, 부과일자=검사유효기간 종료일+146일) ==========
|
||||
log.info("[날짜수정후부과-명의이전-미필] Step 1: 자동차기본정보 조회 - 차량번호: {}, 부과일자: {}", vhclno, levyCrtrYmd);
|
||||
|
||||
NewBasicRequest step1Request = createBasicRequest(vhclno, null, levyCrtrYmd);
|
||||
NewBasicResponse step1Response = apiService.getBasicInfo(step1Request);
|
||||
bassMatterLogService.updateCarFfnlgTrgtIdByTxIdNewTx(step1Response, existingData.getCarFfnlgTrgtIncmpId());
|
||||
|
||||
if (step1Response == null || step1Response.getRecord() == null || step1Response.getRecord().isEmpty()) {
|
||||
log.warn("[날짜수정후부과-명의이전-미필] Step 1 응답 없음 - 차량번호: {}", vhclno);
|
||||
return null;
|
||||
}
|
||||
|
||||
NewBasicResponse.Record step1Record = step1Response.getRecord().get(0);
|
||||
String vin = step1Record.getVin(); // 차대번호
|
||||
String step1OwnerName = step1Record.getRprsOwnrNm(); // 부과일자 기준 소유자명
|
||||
String step1RprsvOwnrIdecno = step1Record.getRprsvOwnrIdecno(); // 부과일자 기준 대표소유자 회원번호
|
||||
|
||||
log.info("[날짜수정후부과-명의이전-미필] Step 1 결과 - 차대번호: {}, 소유자명: {}", vin, step1OwnerName);
|
||||
|
||||
// 부과일자 소유자가 상품용 아님
|
||||
if (step1OwnerName != null && step1OwnerName.contains("상품용")) {
|
||||
log.debug("[날짜수정후부과-명의이전-미필] 부과일자 소유자가 상품용 - 차량번호: {}, 소유자명: {}", vhclno, step1OwnerName);
|
||||
return null;
|
||||
}
|
||||
|
||||
log.info("[날짜수정후부과-명의이전-미필] 부과일자 소유자가 상품용 아님 - 차량번호: {}, 소유자명: {}", vhclno, step1OwnerName);
|
||||
|
||||
// ========== Step 2: 자동차기본정보 조회 (차대번호, 부과일자=오늘일자) ==========
|
||||
String today = LocalDate.now().format(DATE_FORMATTER);
|
||||
log.info("[날짜수정후부과-명의이전-미필] Step 2: 자동차기본정보 조회 - 차대번호: {}, 오늘일자: {}", vin, today);
|
||||
|
||||
NewBasicRequest step2Request = createBasicRequest(null, vin, today);
|
||||
NewBasicResponse step2Response = apiService.getBasicInfo(step2Request);
|
||||
bassMatterLogService.updateCarFfnlgTrgtIdByTxIdNewTx(step2Response, existingData.getCarFfnlgTrgtIncmpId());
|
||||
|
||||
if (step2Response == null || step2Response.getRecord() == null || step2Response.getRecord().isEmpty()) {
|
||||
log.warn("[날짜수정후부과-명의이전-미필] Step 2 응답 없음 - 차대번호: {}", vin);
|
||||
return null;
|
||||
}
|
||||
|
||||
NewBasicResponse.Record step2Record = step2Response.getRecord().get(0);
|
||||
String currentVhclno = step2Record.getVhrno();
|
||||
String currentOwnerName = step2Record.getRprsOwnrNm();
|
||||
String currentIdecno = step2Record.getRprsvOwnrIdecno();
|
||||
String currentLegalDongCode = step2Record.getUsgsrhldStdgCd();
|
||||
|
||||
log.info("[날짜수정후부과-명의이전-미필] Step 2 결과 - 차량번호: {}, 성명: {}, 주민번호: {}, 법정동코드: {}",
|
||||
currentVhclno, currentOwnerName, currentIdecno, currentLegalDongCode);
|
||||
|
||||
// ========== Step 3: 자동차등록원부(갑) 조회 ==========
|
||||
log.info("[날짜수정후부과-명의이전-미필] Step 3: 자동차등록원부(갑) 조회 - 차량번호: {}, 성명: {}, 주민번호: {}, 법정동코드: {}",
|
||||
currentVhclno, currentOwnerName, currentIdecno, currentLegalDongCode);
|
||||
|
||||
NewLedgerRequest step3Request = createLedgerRequest(currentVhclno, currentOwnerName, currentIdecno, currentLegalDongCode);
|
||||
NewLedgerResponse step3Response = apiService.getLedgerInfo(step3Request);
|
||||
ledgerLogService.updateCarFfnlgTrgtIdByTxIdNewTx(step3Response, existingData.getCarFfnlgTrgtIncmpId());
|
||||
|
||||
if (step3Response == null) {
|
||||
log.warn("[날짜수정후부과-명의이전-미필] Step 3 응답 없음 - 차량번호: {}", currentVhclno);
|
||||
return null;
|
||||
}
|
||||
|
||||
List<NewLedgerResponse.Record> ledgerRecords = step3Response.getRecord();
|
||||
if (ledgerRecords == null || ledgerRecords.isEmpty()) {
|
||||
log.debug("[날짜수정후부과-명의이전-미필] 갑부 상세 내역 없음 - 차량번호: {}", vhclno);
|
||||
return null;
|
||||
}
|
||||
|
||||
// ========== 갑부 상세에서 검사유효기간 내 명의이전 레코드 찾기 ==========
|
||||
log.info("[날짜수정후부과-명의이전-미필] 갑부 상세 레코드 검색 시작 - 검사유효기간 시작일: {}, 검사유효기간 종료일: {}", inspVldPrdStart, inspVldPrdEnd);
|
||||
|
||||
NewLedgerResponse.Record targetRecord = null;
|
||||
LocalDate inspVldPrdStartDate = DateUtil.parseDate(inspVldPrdStart);
|
||||
LocalDate inspVldPrdEndDate = DateUtil.parseDate(inspVldPrdEnd);
|
||||
LocalDate latestChgDate = null;
|
||||
|
||||
for (NewLedgerResponse.Record record : ledgerRecords) {
|
||||
String chgYmd = record.getChgYmd();
|
||||
String chgTaskSeCd = record.getChgTaskSeCd();
|
||||
|
||||
// 조건: CHG_TASK_SE_CD == "11" (명의이전)
|
||||
if (!"11".equals(chgTaskSeCd) || chgYmd == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
LocalDate chgDate = DateUtil.parseDate(chgYmd);
|
||||
if (chgDate == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 조건: 검사유효기간 시작일 <= CHG_YMD <= 검사유효기간 종료일
|
||||
if ((chgDate.isEqual(inspVldPrdStartDate) || chgDate.isAfter(inspVldPrdStartDate)) &&
|
||||
(chgDate.isEqual(inspVldPrdEndDate) || chgDate.isBefore(inspVldPrdEndDate))) {
|
||||
|
||||
// 가장 최근 일자 선택
|
||||
if (latestChgDate == null || chgDate.isAfter(latestChgDate)) {
|
||||
targetRecord = record;
|
||||
latestChgDate = chgDate;
|
||||
log.debug("[내사종결-명의이전-미필] 검사유효기간 내 명의이전 발견 - 변경일자: {}, 변경업무: {}", chgYmd, chgTaskSeCd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (targetRecord == null) {
|
||||
log.debug("[날짜수정후부과-명의이전-미필] 검사유효기간 내 명의이전 레코드 없음 - 차량번호: {}", vhclno);
|
||||
return null;
|
||||
}
|
||||
|
||||
String targetChgYmd = targetRecord.getChgYmd();
|
||||
log.info("[날짜수정후부과-명의이전-미필] 검사유효기간 내 명의이전 발견! 변경일자: {}, 변경업무: {}", targetChgYmd, targetRecord.getChgTaskSeNm());
|
||||
|
||||
// ========== 명의이전일자 ~ 부과일자 사이의 일수 계산 ==========
|
||||
LocalDate chgDate = DateUtil.parseDate(targetChgYmd);
|
||||
LocalDate levyDate = DateUtil.parseDate(levyCrtrYmd);
|
||||
long daysBetween = java.time.temporal.ChronoUnit.DAYS.between(chgDate, levyDate);
|
||||
|
||||
if (daysBetween <= DAYS_THRESHOLD) {
|
||||
log.debug("[날짜수정후부과-명의이전-미필] 명의이전일자가 부과일자의 {}일 이내임 - 변경일자: {}, 부과일자: {}, 일수차이: {}일",
|
||||
DAYS_THRESHOLD, targetChgYmd, levyCrtrYmd, daysBetween);
|
||||
return null;
|
||||
}
|
||||
|
||||
log.info("[날짜수정후부과-명의이전-미필] 명의이전일자가 부과일자의 {}일 초과 확인 - 변경일자: {}, 부과일자: {}, 일수차이: {}일",
|
||||
DAYS_THRESHOLD, targetChgYmd, levyCrtrYmd, daysBetween);
|
||||
|
||||
// ========== Step 4: 자동차기본정보 조회 (차대번호, 부과일자=CHG_YMD) ==========
|
||||
LocalDate targetDate = DateUtil.parseDate(targetChgYmd);
|
||||
NewBasicRequest step4Request = createBasicRequest(null, vin, targetDate.format(DATE_FORMATTER));
|
||||
NewBasicResponse step4Response = apiService.getBasicInfo(step4Request);
|
||||
bassMatterLogService.updateCarFfnlgTrgtIdByTxIdNewTx(step4Response, existingData.getCarFfnlgTrgtIncmpId());
|
||||
|
||||
if (step4Response == null || step4Response.getRecord() == null || step4Response.getRecord().isEmpty()) {
|
||||
log.warn("[날짜수정후부과-명의이전-미필] Step 4 응답 없음 - 차대번호: {}, 부과일자: {}", vin, targetDate.format(DATE_FORMATTER));
|
||||
return null;
|
||||
}
|
||||
|
||||
NewBasicResponse.Record step4Record = step4Response.getRecord().get(0);
|
||||
String step4OwnerName = step4Record.getRprsOwnrNm(); // CHG_YMD 시점의 소유자명
|
||||
String step4RprsvOwnrIdecno = step4Record.getRprsvOwnrIdecno(); // 대표소유자 회원번호
|
||||
|
||||
log.info("[날짜수정후부과-명의이전-미필] Step 4 결과 - 소유자명: {}", step4OwnerName);
|
||||
|
||||
// 검사유효기간내 명의변경 소유자와 부과일자의 소유자가 같냐
|
||||
if (step4OwnerName == null || !step4RprsvOwnrIdecno.contains(step1RprsvOwnrIdecno)) {
|
||||
log.debug("[내사종결-명의이전-미필] 명의이전 전 소유자가 상품용 - Step4 소유자명: {}", step4OwnerName);
|
||||
return null;
|
||||
}
|
||||
|
||||
log.info("[날짜수정후부과-명의이전-미필] 명의이전 전 소유자가 상품용 아님 - 소유자명: {}", step4OwnerName);
|
||||
|
||||
// ========== 비고 생성 ==========
|
||||
String rmrk = ComparisonOmRemarkBuilder.buildOwnerChangeRemark(
|
||||
step1Record, step4Record, targetRecord,
|
||||
vhclno, levyCrtrYmd, inspVldPrdStart, inspVldPrdEnd, daysBetween
|
||||
);
|
||||
|
||||
// ========== DB 업데이트 ==========
|
||||
existingData.setCarBassMatterInqireId(step1Response.getGeneratedId());
|
||||
existingData.setCarLedgerFrmbkId(step3Response.getGeneratedId());
|
||||
existingData.setTaskPrcsSttsCd(TaskPrcsSttsConstants.TASK_PRCS_STTS_CD_05_DATE_MODIFIED_LEVY);
|
||||
existingData.setTaskPrcsYmd(LocalDate.now().format(DATE_FORMATTER));
|
||||
existingData.setCarBscMttrInqFlnm(step4OwnerName);
|
||||
existingData.setCarRegFrmbkChgTaskSeCd(targetRecord.getChgTaskSeCd());
|
||||
existingData.setCarRegFrmbkChgTaskSeNm(targetRecord.getChgTaskSeNm());
|
||||
existingData.setCarRegFrmbkChgYmd(targetRecord.getChgYmd().replace("-", ""));
|
||||
existingData.setCarRegFrmbkDtl(ComparisonOmRemarkBuilder.buildLedgerRecordDetail(targetRecord));
|
||||
existingData.setRmrk(rmrk);
|
||||
|
||||
int updateCount = carFfnlgTrgtIncmpMapper.update(existingData);
|
||||
if (updateCount == 0) {
|
||||
throw new MessageException(String.format("[날짜수정후부과-명의이전-미필] 업데이트 실패: %s", vhclno));
|
||||
}
|
||||
|
||||
log.info("[날짜수정후부과-명의이전-미필] 처리 완료! 차량번호: {}", vhclno);
|
||||
return TaskPrcsSttsConstants.TASK_PRCS_STTS_CD_05_DATE_MODIFIED_LEVY;
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("[날짜수정후부과-명의이전-미필] 검증 중 오류 발생 - 차량번호: {}", vhclno, e);
|
||||
throw new MessageException(String.format("[날짜수정후부과-명의이전-미필] 검증 중 오류 발생 - 차량번호: %s", vhclno), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,235 +0,0 @@
|
||||
package go.kr.project.carInspectionPenalty.registrationOm.service.impl.om_checker;
|
||||
|
||||
import egovframework.constant.TaskPrcsSttsConstants;
|
||||
import egovframework.exception.MessageException;
|
||||
import egovframework.util.DateUtil;
|
||||
import go.kr.project.api.model.request.NewBasicRequest;
|
||||
import go.kr.project.api.model.request.NewLedgerRequest;
|
||||
import go.kr.project.api.model.response.NewBasicResponse;
|
||||
import go.kr.project.api.model.response.NewLedgerResponse;
|
||||
import go.kr.project.api.service.ExternalVehicleApiService;
|
||||
import go.kr.project.api.service.VmisCarBassMatterInqireLogService;
|
||||
import go.kr.project.api.service.VmisCarLedgerFrmbkLogService;
|
||||
import go.kr.project.carInspectionPenalty.registrationOm.mapper.CarFfnlgTrgtIncmpMapper;
|
||||
import go.kr.project.carInspectionPenalty.registrationOm.model.CarFfnlgTrgtIncmpVO;
|
||||
import go.kr.project.carInspectionPenalty.registrationOm.service.impl.ComparisonOmRemarkBuilder;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 5. 날짜 수정 후 부과 검증 - 명의이전 이전소유자 상품용, 31일 초과 (미필)
|
||||
*
|
||||
* <p>명의이전 이전 소유자가 상품용이고, 명의이전일자가 부과일자의 31일 초과인 경우</p>
|
||||
* <p>미필의 경우 부과일자 = 검사유효기간 종료일 + 146일</p>
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class ProductLevyOver31OmChecker extends AbstractComparisonOmChecker {
|
||||
|
||||
public ProductLevyOver31OmChecker(CarFfnlgTrgtIncmpMapper carFfnlgTrgtIncmpMapper,
|
||||
ExternalVehicleApiService apiService,
|
||||
VmisCarBassMatterInqireLogService bassMatterLogService,
|
||||
VmisCarLedgerFrmbkLogService ledgerLogService) {
|
||||
super(carFfnlgTrgtIncmpMapper, apiService, bassMatterLogService, ledgerLogService);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String check(CarFfnlgTrgtIncmpVO existingData) {
|
||||
String vhclno = existingData.getVhclno();
|
||||
String levyCrtrYmd = existingData.getLevyCrtrYmd(); // 미필: 검사유효기간 종료일 + 146일
|
||||
String inspVldPrd = existingData.getInspVldPrd(); // 검사유효기간
|
||||
|
||||
// 검사유효기간에서 시작일과 종료일 추출
|
||||
String inspVldPrdStart = null;
|
||||
String inspVldPrdEnd = null;
|
||||
if (inspVldPrd != null && inspVldPrd.contains("~")) {
|
||||
String[] dates = inspVldPrd.split("~");
|
||||
inspVldPrdStart = dates[0].trim().replace("-", "");
|
||||
inspVldPrdEnd = dates.length > 1 ? dates[1].trim().replace("-", "") : null;
|
||||
}
|
||||
|
||||
try {
|
||||
// ========== Step 1: 자동차기본정보 조회 (차량번호, 부과일자=검사유효기간 종료일+146일) ==========
|
||||
log.info("[날짜수정후부과-명의이전 상품용-미필] Step 1: 자동차기본정보 조회 - 차량번호: {}, 부과일자: {}", vhclno, levyCrtrYmd);
|
||||
|
||||
NewBasicRequest step1Request = createBasicRequest(vhclno, null, levyCrtrYmd);
|
||||
NewBasicResponse step1Response = apiService.getBasicInfo(step1Request);
|
||||
bassMatterLogService.updateCarFfnlgTrgtIdByTxIdNewTx(step1Response, existingData.getCarFfnlgTrgtIncmpId());
|
||||
|
||||
if (step1Response == null || step1Response.getRecord() == null || step1Response.getRecord().isEmpty()) {
|
||||
log.warn("[날짜수정후부과-명의이전 상품용-미필] Step 1 응답 없음 - 차량번호: {}", vhclno);
|
||||
return null;
|
||||
}
|
||||
|
||||
NewBasicResponse.Record step1Record = step1Response.getRecord().get(0);
|
||||
String vin = step1Record.getVin(); // 차대번호
|
||||
String step1OwnerName = step1Record.getRprsOwnrNm(); // 부과일자 기준 소유자명
|
||||
|
||||
log.info("[날짜수정후부과-명의이전 상품용-미필] Step 1 결과 - 차대번호: {}, 소유자명: {}", vin, step1OwnerName);
|
||||
|
||||
// 조건 1: 소유자명에 "상품용" 포함 여부 확인
|
||||
if (step1OwnerName == null || step1OwnerName.contains("상품용")) {
|
||||
log.debug("[날짜수정후부과-명의이전 상품용-미필] 소유자명에 '상품용' 미포함 - 차량번호: {}, 소유자명: {}", vhclno, step1OwnerName);
|
||||
return null;
|
||||
}
|
||||
|
||||
log.info("[날짜수정후부과-명의이전 상품용-미필] 소유자명에 '상품용' 포함 확인! - 차량번호: {}, 소유자명: {}", vhclno, step1OwnerName);
|
||||
|
||||
// ========== Step 2: 자동차기본정보 조회 (차대번호, 부과일자=오늘일자) ==========
|
||||
String today = LocalDate.now().format(DATE_FORMATTER);
|
||||
log.info("[날짜수정후부과-명의이전 상품용-미필] Step 2: 자동차기본정보 조회 - 차대번호: {}, 오늘일자: {}", vin, today);
|
||||
|
||||
NewBasicRequest step2Request = createBasicRequest(null, vin, today);
|
||||
NewBasicResponse step2Response = apiService.getBasicInfo(step2Request);
|
||||
bassMatterLogService.updateCarFfnlgTrgtIdByTxIdNewTx(step2Response, existingData.getCarFfnlgTrgtIncmpId());
|
||||
|
||||
if (step2Response == null || step2Response.getRecord() == null || step2Response.getRecord().isEmpty()) {
|
||||
log.warn("[날짜수정후부과-명의이전 상품용-미필] Step 2 응답 없음 - 차대번호: {}", vin);
|
||||
return null;
|
||||
}
|
||||
|
||||
NewBasicResponse.Record step2Record = step2Response.getRecord().get(0);
|
||||
String currentVhclno = step2Record.getVhrno();
|
||||
String currentOwnerName = step2Record.getRprsOwnrNm();
|
||||
String currentIdecno = step2Record.getRprsvOwnrIdecno();
|
||||
String currentLegalDongCode = step2Record.getUsgsrhldStdgCd();
|
||||
|
||||
log.info("[날짜수정후부과-명의이전 상품용-미필] Step 2 결과 - 차량번호: {}, 성명: {}, 주민번호: {}, 법정동코드: {}",
|
||||
currentVhclno, currentOwnerName, currentIdecno, currentLegalDongCode);
|
||||
|
||||
// ========== Step 3: 자동차등록원부(갑) 조회 ==========
|
||||
log.info("[날짜수정후부과-명의이전 상품용-미필] Step 3: 자동차등록원부(갑) 조회 - 차량번호: {}, 성명: {}, 주민번호: {}, 법정동코드: {}",
|
||||
currentVhclno, currentOwnerName, currentIdecno, currentLegalDongCode);
|
||||
|
||||
NewLedgerRequest step3Request = createLedgerRequest(currentVhclno, currentOwnerName, currentIdecno, currentLegalDongCode);
|
||||
NewLedgerResponse step3Response = apiService.getLedgerInfo(step3Request);
|
||||
ledgerLogService.updateCarFfnlgTrgtIdByTxIdNewTx(step3Response, existingData.getCarFfnlgTrgtIncmpId());
|
||||
|
||||
if (step3Response == null) {
|
||||
log.warn("[날짜수정후부과-명의이전 상품용-미필] Step 3 응답 없음 - 차량번호: {}", currentVhclno);
|
||||
return null;
|
||||
}
|
||||
|
||||
List<NewLedgerResponse.Record> ledgerRecords = step3Response.getRecord();
|
||||
if (ledgerRecords == null || ledgerRecords.isEmpty()) {
|
||||
log.debug("[날짜수정후부과-명의이전 상품용-미필] 갑부 상세 내역 없음 - 차량번호: {}", vhclno);
|
||||
return null;
|
||||
}
|
||||
|
||||
// ========== 갑부 상세에서 조건에 맞는 레코드 찾기 ==========
|
||||
log.info("[날짜수정후부과-명의이전 상품용-미필] 갑부 상세 레코드 검색 시작 - 부과일자: {}, 검사유효기간 종료일: {}", levyCrtrYmd, inspVldPrdEnd);
|
||||
|
||||
NewLedgerResponse.Record targetRecord = null;
|
||||
LocalDate latestChgDate = null;
|
||||
LocalDate levyDate = DateUtil.parseDate(levyCrtrYmd);
|
||||
|
||||
for (NewLedgerResponse.Record record : ledgerRecords) {
|
||||
String chgYmd = record.getChgYmd();
|
||||
String chgTaskSeCd = record.getChgTaskSeCd();
|
||||
|
||||
// 조건: CHG_TASK_SE_CD == "11" (명의이전)
|
||||
if (!"11".equals(chgTaskSeCd) || chgYmd == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
LocalDate chgDate = DateUtil.parseDate(chgYmd);
|
||||
if (chgDate == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 조건: CHG_YMD <= 부과일자
|
||||
if (chgDate.isAfter(levyDate)) {
|
||||
log.debug("[날짜수정후부과-명의이전 상품용-미필] CHG_YMD > 부과일자 - 변경일자: {}, 부과일자: {}", chgYmd, levyCrtrYmd);
|
||||
continue;
|
||||
}
|
||||
|
||||
// 가장 마지막 일자 찾기
|
||||
if (latestChgDate == null || chgDate.isAfter(latestChgDate)) {
|
||||
latestChgDate = chgDate;
|
||||
targetRecord = record;
|
||||
log.debug("[날짜수정후부과-명의이전 상품용-미필] 조건 충족 레코드 발견 - 변경일자: {}, 변경업무: {}", chgYmd, chgTaskSeCd);
|
||||
}
|
||||
}
|
||||
|
||||
if (targetRecord == null) {
|
||||
log.debug("[날짜수정후부과-명의이전 상품용-미필] 조건에 맞는 명의이전 레코드 없음 - 차량번호: {}", vhclno);
|
||||
return null;
|
||||
}
|
||||
|
||||
// 조건: 가장 마지막 명의이전일자가 부과일자의 기준일수 초과인지 확인
|
||||
long daysBetween = java.time.temporal.ChronoUnit.DAYS.between(latestChgDate, levyDate);
|
||||
if (daysBetween <= DAYS_THRESHOLD) {
|
||||
log.debug("[날짜수정후부과-명의이전 상품용-미필] 명의이전일자가 부과일자의 {}일 이내임 - 변경일자: {}, 부과일자: {}, 일수차이: {}일",
|
||||
DAYS_THRESHOLD, targetRecord.getChgYmd(), levyCrtrYmd, daysBetween);
|
||||
return null;
|
||||
}
|
||||
log.info("[날짜수정후부과-명의이전 상품용-미필] 명의이전일자가 부과일자의 {}일 초과 확인 - 변경일자: {}, 부과일자: {}, 일수차이: {}일",
|
||||
DAYS_THRESHOLD, targetRecord.getChgYmd(), levyCrtrYmd, daysBetween);
|
||||
|
||||
String targetChgYmd = targetRecord.getChgYmd();
|
||||
log.info("[날짜수정후부과-미필] 조건 충족 레코드 선택! 변경일자: {}, 변경업무: {}", targetChgYmd, targetRecord.getChgTaskSeNm());
|
||||
|
||||
// ========== Step 4: 자동차기본정보 조회 (차대번호, 부과일자=CHG_YMD -1일) ==========
|
||||
LocalDate targetDate = DateUtil.parseDate(targetChgYmd);
|
||||
String targetChgYmdMinus1 = targetDate.minusDays(1).format(DATE_FORMATTER);
|
||||
log.info("[날짜수정후부과-명의이전 상품용-미필] Step 4: 자동차기본정보 조회 - 차대번호: {}, 부과일자: {} (원본: {})", vin, targetChgYmdMinus1, targetChgYmd);
|
||||
|
||||
NewBasicRequest step4Request = createBasicRequest(null, vin, targetChgYmdMinus1);
|
||||
NewBasicResponse step4Response = apiService.getBasicInfo(step4Request);
|
||||
bassMatterLogService.updateCarFfnlgTrgtIdByTxIdNewTx(step4Response, existingData.getCarFfnlgTrgtIncmpId());
|
||||
|
||||
if (step4Response == null || step4Response.getRecord() == null || step4Response.getRecord().isEmpty()) {
|
||||
log.warn("[날짜수정후부과-명의이전 상품용-미필] Step 4 응답 없음 - 차대번호: {}, 부과일자: {}", vin, targetChgYmdMinus1);
|
||||
return null;
|
||||
}
|
||||
|
||||
NewBasicResponse.Record step4Record = step4Response.getRecord().get(0);
|
||||
String step4OwnerName = step4Record.getRprsOwnrNm(); // CHG_YMD 시점의 소유자명
|
||||
|
||||
log.info("[날짜수정후부과-명의이전 상품용-미필] Step 4 결과 - 소유자명: {}", step4OwnerName);
|
||||
|
||||
// ========== 소유자명 비교 - 상품용 포함 여부 확인 ==========
|
||||
if (step4OwnerName == null || !step4OwnerName.contains("상품용")) {
|
||||
log.debug("[날짜수정후부과-명의이전 상품용-미필] 소유자명에 '상품용' 미포함 - Step4 소유자명: {}", step4OwnerName);
|
||||
return null;
|
||||
}
|
||||
|
||||
log.info("[날짜수정후부과-명의이전 상품용-미필] 명의이전 시점 소유자명에 '상품용' 확인! - 소유자명: {}", step4OwnerName);
|
||||
|
||||
log.info("[날짜수정후부과-명의이전 상품용-미필] 모든 조건 충족! 차량번호: {}, 변경일자: {}", vhclno, targetChgYmd);
|
||||
|
||||
// ========== 비고 생성 ==========
|
||||
String rmrk = ComparisonOmRemarkBuilder.buildProductCloseLevyRemark(
|
||||
step1Record, step4Record, targetRecord,
|
||||
vhclno, levyCrtrYmd, inspVldPrdStart, inspVldPrdEnd, daysBetween
|
||||
);
|
||||
|
||||
// ========== DB 업데이트 ==========
|
||||
existingData.setCarBassMatterInqireId(step1Response.getGeneratedId());
|
||||
existingData.setCarLedgerFrmbkId(step3Response.getGeneratedId());
|
||||
existingData.setTaskPrcsSttsCd(TaskPrcsSttsConstants.TASK_PRCS_STTS_CD_05_DATE_MODIFIED_LEVY);
|
||||
existingData.setTaskPrcsYmd(LocalDate.now().format(DATE_FORMATTER));
|
||||
existingData.setCarBscMttrInqFlnm(step4OwnerName);
|
||||
existingData.setCarRegFrmbkChgTaskSeCd(targetRecord.getChgTaskSeCd());
|
||||
existingData.setCarRegFrmbkChgTaskSeNm(targetRecord.getChgTaskSeNm());
|
||||
existingData.setCarRegFrmbkChgYmd(targetRecord.getChgYmd().replace("-", ""));
|
||||
existingData.setCarRegFrmbkDtl(ComparisonOmRemarkBuilder.buildLedgerRecordDetail(targetRecord));
|
||||
existingData.setRmrk(rmrk);
|
||||
|
||||
int updateCount = carFfnlgTrgtIncmpMapper.update(existingData);
|
||||
if (updateCount == 0) {
|
||||
throw new MessageException(String.format("[날짜수정후부과-명의이전 상품용-미필] 업데이트 실패: %s", vhclno));
|
||||
}
|
||||
|
||||
log.info("[날짜수정후부과-명의이전 상품용-미필] 처리 완료! 차량번호: {}", vhclno);
|
||||
return TaskPrcsSttsConstants.TASK_PRCS_STTS_CD_05_DATE_MODIFIED_LEVY;
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("[날짜수정후부과-명의이전 상품용-미필] 검증 중 오류 발생 - 차량번호: {}", vhclno, e);
|
||||
throw new MessageException(String.format("[날짜수정후부과-명의이전 상품용-미필] 검증 중 오류 발생 - 차량번호: %s", vhclno), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,229 +0,0 @@
|
||||
package go.kr.project.carInspectionPenalty.registrationOm.service.impl.om_checker;
|
||||
|
||||
import egovframework.constant.TaskPrcsSttsConstants;
|
||||
import egovframework.exception.MessageException;
|
||||
import egovframework.util.DateUtil;
|
||||
import go.kr.project.api.model.request.NewBasicRequest;
|
||||
import go.kr.project.api.model.request.NewLedgerRequest;
|
||||
import go.kr.project.api.model.response.NewBasicResponse;
|
||||
import go.kr.project.api.model.response.NewLedgerResponse;
|
||||
import go.kr.project.api.service.ExternalVehicleApiService;
|
||||
import go.kr.project.api.service.VmisCarBassMatterInqireLogService;
|
||||
import go.kr.project.api.service.VmisCarLedgerFrmbkLogService;
|
||||
import go.kr.project.carInspectionPenalty.registrationOm.mapper.CarFfnlgTrgtIncmpMapper;
|
||||
import go.kr.project.carInspectionPenalty.registrationOm.model.CarFfnlgTrgtIncmpVO;
|
||||
import go.kr.project.carInspectionPenalty.registrationOm.service.impl.ComparisonOmRemarkBuilder;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 2. 상품용-변경등록 체크 (미필)
|
||||
*
|
||||
* <p>api-1번호출.소유자명.contains("상품용")</p>
|
||||
* <p>미필의 경우 부과일자 = 검사유효기간 종료일 + 146일</p>
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class ProductUseOmChangeChecker extends AbstractComparisonOmChecker {
|
||||
|
||||
public ProductUseOmChangeChecker(CarFfnlgTrgtIncmpMapper carFfnlgTrgtIncmpMapper,
|
||||
ExternalVehicleApiService apiService,
|
||||
VmisCarBassMatterInqireLogService bassMatterLogService,
|
||||
VmisCarLedgerFrmbkLogService ledgerLogService) {
|
||||
super(carFfnlgTrgtIncmpMapper, apiService, bassMatterLogService, ledgerLogService);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String check(CarFfnlgTrgtIncmpVO existingData) {
|
||||
String vhclno = existingData.getVhclno();
|
||||
String levyCrtrYmd = existingData.getLevyCrtrYmd(); // 미필: 검사유효기간 종료일 + 146일
|
||||
String inspVldPrd = existingData.getInspVldPrd(); // 검사유효기간
|
||||
|
||||
// 검사유효기간에서 시작일과 종료일 추출
|
||||
String inspVldPrdStart = null;
|
||||
String inspVldPrdEnd = null;
|
||||
if (inspVldPrd != null && inspVldPrd.contains("~")) {
|
||||
String[] dates = inspVldPrd.split("~");
|
||||
inspVldPrdStart = dates[0].trim().replace("-", "");
|
||||
inspVldPrdEnd = dates.length > 1 ? dates[1].trim().replace("-", "") : null;
|
||||
}
|
||||
|
||||
try {
|
||||
// ========== Step 1: 자동차기본정보 조회 (차량번호, 부과일자=검사유효기간 종료일+146일) ==========
|
||||
log.info("[상품용-변경등록-미필] Step 1: 자동차기본정보 조회 - 차량번호: {}, 부과일자: {}", vhclno, levyCrtrYmd);
|
||||
|
||||
NewBasicRequest step1Request = createBasicRequest(vhclno, null, levyCrtrYmd);
|
||||
NewBasicResponse step1Response = apiService.getBasicInfo(step1Request);
|
||||
bassMatterLogService.updateCarFfnlgTrgtIdByTxIdNewTx(step1Response, existingData.getCarFfnlgTrgtIncmpId());
|
||||
|
||||
if (step1Response == null || step1Response.getRecord() == null || step1Response.getRecord().isEmpty()) {
|
||||
log.warn("[상품용-변경등록-미필] Step 1 응답 없음 - 차량번호: {}", vhclno);
|
||||
return null;
|
||||
}
|
||||
|
||||
NewBasicResponse.Record step1Record = step1Response.getRecord().get(0);
|
||||
String vin = step1Record.getVin(); // 차대번호
|
||||
String step1OwnerName = step1Record.getRprsOwnrNm(); // 부과일자 기준 소유자명
|
||||
String step1RprsvOwnrIdecno = step1Record.getRprsvOwnrIdecno(); // 부과일자 기준 대표소유자 회원번호
|
||||
|
||||
log.info("[상품용-변경등록-미필] Step 1 결과 - 차대번호: {}, 소유자명: {}", vin, step1OwnerName);
|
||||
|
||||
// 조건 1: 소유자명에 "상품용" 포함 여부 확인
|
||||
if (step1OwnerName == null || !step1OwnerName.contains("상품용")) {
|
||||
log.debug("[상품용-변경등록-미필] 소유자명에 '상품용' 미포함 - 차량번호: {}, 소유자명: {}", vhclno, step1OwnerName);
|
||||
return null;
|
||||
}
|
||||
|
||||
log.info("[상품용-변경등록-미필] 소유자명에 '상품용' 포함 확인! - 차량번호: {}, 소유자명: {}", vhclno, step1OwnerName);
|
||||
|
||||
// ========== Step 2: 자동차기본정보 조회 (차대번호, 부과일자=오늘일자) ==========
|
||||
String today = LocalDate.now().format(DATE_FORMATTER);
|
||||
log.info("[상품용-변경등록-미필] Step 2: 자동차기본정보 조회 - 차대번호: {}, 오늘일자: {}", vin, today);
|
||||
|
||||
NewBasicRequest step2Request = createBasicRequest(null, vin, today);
|
||||
NewBasicResponse step2Response = apiService.getBasicInfo(step2Request);
|
||||
bassMatterLogService.updateCarFfnlgTrgtIdByTxIdNewTx(step2Response, existingData.getCarFfnlgTrgtIncmpId());
|
||||
|
||||
if (step2Response == null || step2Response.getRecord() == null || step2Response.getRecord().isEmpty()) {
|
||||
log.warn("[상품용-변경등록-미필] Step 2 응답 없음 - 차대번호: {}", vin);
|
||||
return null;
|
||||
}
|
||||
|
||||
NewBasicResponse.Record step2Record = step2Response.getRecord().get(0);
|
||||
String currentVhclno = step2Record.getVhrno();
|
||||
String currentOwnerName = step2Record.getRprsOwnrNm();
|
||||
String currentIdecno = step2Record.getRprsvOwnrIdecno();
|
||||
String currentLegalDongCode = step2Record.getUsgsrhldStdgCd();
|
||||
|
||||
log.info("[상품용-변경등록-미필] Step 2 결과 - 차량번호: {}, 성명: {}, 주민번호: {}, 법정동코드: {}",
|
||||
currentVhclno, currentOwnerName, currentIdecno, currentLegalDongCode);
|
||||
|
||||
// ========== Step 3: 자동차등록원부(갑) 조회 ==========
|
||||
log.info("[상품용-변경등록-미필] Step 3: 자동차등록원부(갑) 조회 - 차량번호: {}, 성명: {}, 주민번호: {}, 법정동코드: {}",
|
||||
currentVhclno, currentOwnerName, currentIdecno, currentLegalDongCode);
|
||||
|
||||
NewLedgerRequest step3Request = createLedgerRequest(currentVhclno, currentOwnerName, currentIdecno, currentLegalDongCode);
|
||||
NewLedgerResponse step3Response = apiService.getLedgerInfo(step3Request);
|
||||
ledgerLogService.updateCarFfnlgTrgtIdByTxIdNewTx(step3Response, existingData.getCarFfnlgTrgtIncmpId());
|
||||
|
||||
if (step3Response == null) {
|
||||
log.warn("[상품용-변경등록-미필] Step 3 응답 없음 - 차량번호: {}", currentVhclno);
|
||||
return null;
|
||||
}
|
||||
|
||||
List<NewLedgerResponse.Record> ledgerRecords = step3Response.getRecord();
|
||||
if (ledgerRecords == null || ledgerRecords.isEmpty()) {
|
||||
log.debug("[상품용-변경등록-미필] 갑부 상세 내역 없음 - 차량번호: {}", vhclno);
|
||||
return null;
|
||||
}
|
||||
|
||||
// ========== 갑부 상세에서 조건에 맞는 레코드 찾기 ==========
|
||||
log.info("[상품용-변경등록-미필] 갑부 상세 레코드 검색 시작 - 부과일자: {}, 검사유효기간 종료일: {}", levyCrtrYmd, inspVldPrdEnd);
|
||||
|
||||
NewLedgerResponse.Record targetRecord = null;
|
||||
LocalDate latestChgDate = null;
|
||||
|
||||
for (NewLedgerResponse.Record record : ledgerRecords) {
|
||||
String chgYmd = record.getChgYmd();
|
||||
String chgTaskSeCd = record.getChgTaskSeCd();
|
||||
|
||||
// 조건: CHG_TASK_SE_CD == "21" (변경등록)
|
||||
if (!"21".equals(chgTaskSeCd) || chgYmd == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
LocalDate chgDate = DateUtil.parseDate(chgYmd);
|
||||
if (chgDate == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 조건: CHG_YMD <= 검사유효기간 종료일
|
||||
LocalDate inspVldPrdEndDate = DateUtil.parseDate(inspVldPrdEnd);
|
||||
if (chgDate.isAfter(inspVldPrdEndDate)) {
|
||||
log.debug("[상품용-변경등록-미필] CHG_YMD > 검사유효기간 종료일 - 변경일자: {}, 검사유효기간 종료일: {}", chgYmd, inspVldPrdEnd);
|
||||
continue;
|
||||
}
|
||||
|
||||
String spcablMttr = record.getSpcablMttr();
|
||||
if (!spcablMttr.contains("성명")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 가장 마지막 일자 찾기
|
||||
if (latestChgDate == null || chgDate.isAfter(latestChgDate)) {
|
||||
latestChgDate = chgDate;
|
||||
targetRecord = record;
|
||||
log.debug("[상품용-변경등록-미필] 조건 충족 레코드 발견 - 변경일자: {}, 변경업무: {}", chgYmd, chgTaskSeCd);
|
||||
}
|
||||
}
|
||||
|
||||
if (targetRecord == null) {
|
||||
log.debug("[상품용-변경등록-미필] 조건에 맞는 변경등록 레코드 없음 - 차량번호: {}", vhclno);
|
||||
return null;
|
||||
}
|
||||
|
||||
String targetChgYmd = targetRecord.getChgYmd();
|
||||
log.info("[상품용-변경등록-미필] 조건 충족 레코드 선택! 변경일자: {}, 변경업무: {}", targetChgYmd, targetRecord.getChgTaskSeNm());
|
||||
|
||||
// ========== Step 4: 자동차기본정보 조회 (차대번호, 부과일자=CHG_YMD) ==========
|
||||
log.info("[상품용-변경등록-미필] Step 4: 자동차기본정보 조회 - 차대번호: {}, 부과일자: {}", vin, targetChgYmd);
|
||||
|
||||
NewBasicRequest step4Request = createBasicRequest(null, vin, targetChgYmd.replace("-", ""));
|
||||
NewBasicResponse step4Response = apiService.getBasicInfo(step4Request);
|
||||
bassMatterLogService.updateCarFfnlgTrgtIdByTxIdNewTx(step4Response, existingData.getCarFfnlgTrgtIncmpId());
|
||||
|
||||
if (step4Response == null || step4Response.getRecord() == null || step4Response.getRecord().isEmpty()) {
|
||||
log.warn("[상품용-변경등록-미필] Step 4 응답 없음 - 차대번호: {}, 부과일자: {}", vin, targetChgYmd);
|
||||
return null;
|
||||
}
|
||||
|
||||
NewBasicResponse.Record step4Record = step4Response.getRecord().get(0);
|
||||
String step4OwnerName = step4Record.getRprsOwnrNm(); // CHG_YMD 시점의 소유자명
|
||||
String step4RprsvOwnrIdecno = step4Record.getRprsvOwnrIdecno(); // 대표소유자 회원번호
|
||||
|
||||
log.info("[상품용-변경등록-미필] Step 4 결과 - 소유자명: {}", step4OwnerName);
|
||||
|
||||
// ========== 소유자 회원번호 비교 ==========
|
||||
if (step4OwnerName == null || !step4RprsvOwnrIdecno.equals(step1RprsvOwnrIdecno)) {
|
||||
log.debug("[상품용-변경등록-미필] 소유자 불일치 - Step1 소유자: {}, Step4 소유자: {}", step1RprsvOwnrIdecno, step4RprsvOwnrIdecno);
|
||||
return null;
|
||||
}
|
||||
|
||||
log.info("[상품용-변경등록-미필] 소유자 일치 확인! - 소유자명: {}", step1OwnerName);
|
||||
log.info("[상품용-변경등록-미필] 모든 조건 충족! 차량번호: {}, 변경일자: {}", vhclno, targetChgYmd);
|
||||
|
||||
// ========== 비고 생성 ==========
|
||||
String rmrk = ComparisonOmRemarkBuilder.buildProductUseChangeRemark(
|
||||
step1Record, step4Record, targetRecord,
|
||||
inspVldPrdEnd, levyCrtrYmd
|
||||
);
|
||||
|
||||
// ========== DB 업데이트 ==========
|
||||
existingData.setCarBassMatterInqireId(step1Response.getGeneratedId());
|
||||
existingData.setCarLedgerFrmbkId(step3Response.getGeneratedId());
|
||||
existingData.setTaskPrcsSttsCd(TaskPrcsSttsConstants.TASK_PRCS_STTS_CD_02_PRODUCT_USE);
|
||||
existingData.setTaskPrcsYmd(LocalDate.now().format(DATE_FORMATTER));
|
||||
existingData.setCarBscMttrInqFlnm(step4OwnerName);
|
||||
existingData.setCarRegFrmbkChgTaskSeCd(targetRecord.getChgTaskSeCd());
|
||||
existingData.setCarRegFrmbkChgTaskSeNm(targetRecord.getChgTaskSeNm());
|
||||
existingData.setCarRegFrmbkChgYmd(targetRecord.getChgYmd().replace("-", ""));
|
||||
existingData.setCarRegFrmbkDtl(ComparisonOmRemarkBuilder.buildLedgerRecordDetail(targetRecord));
|
||||
existingData.setRmrk(rmrk);
|
||||
|
||||
int updateCount = carFfnlgTrgtIncmpMapper.update(existingData);
|
||||
if (updateCount == 0) {
|
||||
throw new MessageException(String.format("[상품용-변경등록-미필] 업데이트 실패: %s", vhclno));
|
||||
}
|
||||
|
||||
log.info("[상품용-변경등록-미필] 처리 완료! 차량번호: {}", vhclno);
|
||||
return TaskPrcsSttsConstants.TASK_PRCS_STTS_CD_02_PRODUCT_USE;
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("[상품용-변경등록-미필] 검증 중 오류 발생 - 차량번호: {}", vhclno, e);
|
||||
throw new MessageException(String.format("[상품용-변경등록-미필] 검증 중 오류 발생 - 차량번호: %s", vhclno), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue