중간 커밋... 상품용 작업 중

main
박성영 2 weeks ago
parent a75f03fe3e
commit f5c924ce86

@ -19,8 +19,6 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
@ -54,20 +52,20 @@ public class ComparisonServiceImpl extends EgovAbstractServiceImpl implements Co
String vhclno = existingData.getVhclno();
log.info("========== 비교 로직 시작: {} ==========", vhclno);
// ========== 1. 상품용 체크 ==========
String productUseResult = checkProductUse(existingData);
if (productUseResult != null) {
log.info("========== 비교 로직 종료 (상품용): {} ==========", vhclno);
return productUseResult;
}
// ========== 2. 이첩 체크 ==========
String transferResult = checkTransfer(existingData);
// ========== 1. 이첩 체크 ==========
String transferResult = checkTransferCase115Day(existingData);
if (transferResult != null) {
log.info("========== 비교 로직 종료 (이첩): {} ==========", vhclno);
return transferResult;
}
// ========== 2. 상품용 체크 - api-1번호출.소유자명.contains("상품용") ==========
String productUseResult = checkProductUseCase1(existingData);
if (productUseResult != null) {
log.info("========== 비교 로직 종료 (상품용): {} ==========", vhclno);
return productUseResult;
}
// ========== 3. 향후 추가될 비교 로직들 ==========
// String investigationClosedResult = checkInvestigationClosed(existingData);
// if (investigationClosedResult != null) {
@ -84,7 +82,7 @@ public class ComparisonServiceImpl extends EgovAbstractServiceImpl implements Co
// ========================================
/**
* 1. ( )
* 1. api-1..contains("상품용")
*
* API 4:
* 1) (, =) ,
@ -105,7 +103,7 @@ public class ComparisonServiceImpl extends EgovAbstractServiceImpl implements Co
* @param existingData
* @return 02 () null ()
*/
private String checkProductUse(CarFfnlgTrgtVO existingData) {
private String checkProductUseCase1(CarFfnlgTrgtVO existingData) {
String vhclno = existingData.getVhclno();
String inspYmd = existingData.getInspYmd();
String vldPrdExpryYmd = existingData.getVldPrdExpryYmd();
@ -300,6 +298,208 @@ public class ComparisonServiceImpl extends EgovAbstractServiceImpl implements Co
}
}
/**
* 2. not( api-1..contains("상품용") )
*
* API 4:
* 1) (, =) ,
* 2) (, =) , , ,
* 3) ()(, , , ) List
* 4) (, = CHG_YMD)
*
* :
* - 1: "상품용"
* - 2: ( 11)
* CHG_YMD <=
* CHG_YMD
* CHG_TASK_SE_CD == "11" ()
* - 3: 4 API == .contains("상품용")
*
* @param existingData
* @return 02 () null ()
*/
private String checkProductUseCase2(CarFfnlgTrgtVO existingData) {
String vhclno = existingData.getVhclno();
String inspYmd = existingData.getInspYmd();
String vldPrdExpryYmd = existingData.getVldPrdExpryYmd();
String inspEndYmd = existingData.getInspEndYmd();
try {
// ========== Step 1: 자동차기본정보 조회 (차량번호, 부과일자=검사일) ==========
log.info("[상품용] Step 1: 자동차기본정보 조회 - 차량번호: {}, 검사일: {}", vhclno, inspYmd);
NewBasicRequest step1Request = createBasicRequest(vhclno, null, inspYmd);
NewBasicResponse step1Response = apiService.getBasicInfo(step1Request);
bassMatterLogService.updateCarFfnlgTrgtIdByTxIdNewTx(step1Response, existingData.getCarFfnlgTrgtId());
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.getCarFfnlgTrgtId());
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.getCarFfnlgTrgtId());
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("[상품용] 갑부 상세 레코드 검색 시작 - 검사일: {}, 검사종료일자: {}", inspYmd, inspEndYmd);
NewLedgerResponse.Record targetRecord = null;
LocalDate latestChgDate = null;
LocalDate inspDate = DateUtil.parseDate(inspYmd);
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 <= 검사종료일자
LocalDate inspEndDate = DateUtil.parseDate(inspEndYmd);
if (chgDate.isAfter(inspEndDate)) {
log.debug("[상품용] CHG_YMD > 검사종료일자 - 변경일자: {}, 검사종료일자: {}", chgYmd, inspEndYmd);
continue;
}
if (chgDate.isAfter(inspDate)) {
log.debug("[상품용] CHG_YMD > 검사일 - 변경일자: {}, 검사일: {}", chgYmd, inspYmd);
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);
NewBasicResponse step4Response = apiService.getBasicInfo(step4Request);
bassMatterLogService.updateCarFfnlgTrgtIdByTxIdNewTx(step4Response, existingData.getCarFfnlgTrgtId());
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 시점의 소유자명
log.info("[상품용] Step 4 결과 - 소유자명: {}", step4OwnerName);
// ========== 소유자명 비교 ==========
if (step4OwnerName == null || !step4OwnerName.equals("상품용")) {
log.debug("[상품용] 소유자명 상품용 아님 - Step4 소유자명: {}", step4OwnerName);
return null;
}
log.info("[상품용] 소유자명 상품용 확인! - 소유자명: {}", step1OwnerName);
log.info("[상품용] 모든 조건 충족! 차량번호: {}, 변경일자: {}", vhclno, targetChgYmd);
// ========== 비고 생성 ==========
String rmrk = buildProductUseRemark(
step1Record, step4Record, targetRecord,
vldPrdExpryYmd, inspEndYmd
);
// ========== 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.setCarRegFrmbkChgTaskSeCd(targetRecord.getChgTaskSeCd());
existingData.setCarRegFrmbkChgTaskSeNm(targetRecord.getChgTaskSeNm());
existingData.setCarRegFrmbkChgYmd(targetRecord.getChgYmd());
existingData.setCarRegFrmbkDtl(buildLedgerRecordDetail(targetRecord));
existingData.setRmrk(rmrk);
int updateCount = carFfnlgTrgtMapper.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);
}
}
/**
* 2.
*
@ -313,7 +513,7 @@ public class ComparisonServiceImpl extends EgovAbstractServiceImpl implements Co
* @param existingData
* @return 03 () null ()
*/
private String checkTransfer(CarFfnlgTrgtVO existingData) {
private String checkTransferCase115Day(CarFfnlgTrgtVO existingData) {
String vhclno = existingData.getVhclno();
try {

Loading…
Cancel
Save