From 4d605f943c4818fa05302c4d462cb4d08b42d652 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=B0=95=EC=84=B1=EC=98=81?= Date: Thu, 4 Dec 2025 11:13:23 +0900 Subject: [PATCH] =?UTF-8?q?=EC=88=9C=EC=88=98=20=EB=AA=85=EC=9D=98?= =?UTF-8?q?=EC=9D=B4=EC=A0=84=20=EB=A1=9C=EC=A7=81=20=EC=B2=98=EB=A6=AC=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD=EC=A4=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../checker/OwnerCloseWithin31Checker.java | 17 +++++++---- .../impl/checker/OwnerLevyOver31Checker.java | 28 +++++++++++-------- 2 files changed, 27 insertions(+), 18 deletions(-) diff --git a/src/main/java/go/kr/project/carInspectionPenalty/registration/service/impl/checker/OwnerCloseWithin31Checker.java b/src/main/java/go/kr/project/carInspectionPenalty/registration/service/impl/checker/OwnerCloseWithin31Checker.java index 250630c..8deb001 100644 --- a/src/main/java/go/kr/project/carInspectionPenalty/registration/service/impl/checker/OwnerCloseWithin31Checker.java +++ b/src/main/java/go/kr/project/carInspectionPenalty/registration/service/impl/checker/OwnerCloseWithin31Checker.java @@ -111,12 +111,13 @@ public class OwnerCloseWithin31Checker extends AbstractComparisonChecker { return null; } - // ========== 갑부 상세에서 검사기간 내 명의이전 레코드 찾기 ========== + // ========== 갑부 상세에서 검사기간 내 명의이전 레코드 찾기 (가장 최근 일자) ========== log.info("[내사종결-명의이전] 갑부 상세 레코드 검색 시작 - 유효기간만료일: {}, 검사종료일자: {}", vldPrdExpryYmd, inspEndYmd); NewLedgerResponse.Record targetRecord = null; LocalDate vldPrdExpryDate = DateUtil.parseDate(vldPrdExpryYmd); LocalDate inspEndDate = DateUtil.parseDate(inspEndYmd); + LocalDate latestChgDate = null; for (NewLedgerResponse.Record record : ledgerRecords) { String chgYmd = record.getChgYmd(); @@ -135,9 +136,13 @@ public class OwnerCloseWithin31Checker extends AbstractComparisonChecker { // 조건: 유효기간만료일 <= CHG_YMD <= 검사종료일자 if ((chgDate.isEqual(vldPrdExpryDate) || chgDate.isAfter(vldPrdExpryDate)) && (chgDate.isEqual(inspEndDate) || chgDate.isBefore(inspEndDate))) { - targetRecord = record; - log.debug("[내사종결-명의이전] 검사기간 내 명의이전 발견 - 변경일자: {}, 변경업무: {}", chgYmd, chgTaskSeCd); - break; // 첫 번째 발견된 명의이전 사용 + + // 가장 최근 일자 선택 + if (latestChgDate == null || chgDate.isAfter(latestChgDate)) { + targetRecord = record; + latestChgDate = chgDate; + log.debug("[내사종결-명의이전] 검사기간 내 명의이전 발견 - 변경일자: {}, 변경업무: {}", chgYmd, chgTaskSeCd); + } } } @@ -163,7 +168,7 @@ public class OwnerCloseWithin31Checker extends AbstractComparisonChecker { log.info("[내사종결-명의이전] 명의이전일자가 검사일의 {}일 이내 확인 - 변경일자: {}, 검사일: {}, 일수차이: {}일", DAYS_THRESHOLD, targetChgYmd, inspYmd, daysBetween); - // ========== Step 4: 자동차기본정보 조회 (차대번호, 부과일자=CHG_YMD -1일) ========== + // ========== Step 4: 자동차기본정보 조회 (차대번호, 부과일자=CHG_YMD) ========== LocalDate targetDate = DateUtil.parseDate(targetChgYmd); NewBasicRequest step4Request = createBasicRequest(null, vin, targetDate.format(DATE_FORMATTER)); NewBasicResponse step4Response = apiService.getBasicInfo(step4Request); @@ -180,7 +185,7 @@ public class OwnerCloseWithin31Checker extends AbstractComparisonChecker { log.info("[내사종결-명의이전] Step 4 결과 - 소유자명: {}", step4OwnerName); - // 명의이전 전 소유자가 상품용 아님 + // 검사기간내 명의변경 소유자와 검사일의 소유자가 같냐 if (step4OwnerName == null || step4RprsvOwnrIdecno.contains(step1RprsvOwnrIdecno)) { log.debug("[내사종결-명의이전] 명의이전 전 소유자가 상품용 - Step4 소유자명: {}", step4OwnerName); return null; diff --git a/src/main/java/go/kr/project/carInspectionPenalty/registration/service/impl/checker/OwnerLevyOver31Checker.java b/src/main/java/go/kr/project/carInspectionPenalty/registration/service/impl/checker/OwnerLevyOver31Checker.java index 209471c..ce2751c 100644 --- a/src/main/java/go/kr/project/carInspectionPenalty/registration/service/impl/checker/OwnerLevyOver31Checker.java +++ b/src/main/java/go/kr/project/carInspectionPenalty/registration/service/impl/checker/OwnerLevyOver31Checker.java @@ -58,6 +58,7 @@ public class OwnerLevyOver31Checker extends AbstractComparisonChecker { 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); @@ -116,6 +117,7 @@ public class OwnerLevyOver31Checker extends AbstractComparisonChecker { NewLedgerResponse.Record targetRecord = null; LocalDate vldPrdExpryDate = DateUtil.parseDate(vldPrdExpryYmd); LocalDate inspEndDate = DateUtil.parseDate(inspEndYmd); + LocalDate latestChgDate = null; for (NewLedgerResponse.Record record : ledgerRecords) { String chgYmd = record.getChgYmd(); @@ -134,9 +136,13 @@ public class OwnerLevyOver31Checker extends AbstractComparisonChecker { // 조건: 유효기간만료일 <= CHG_YMD <= 검사종료일자 if ((chgDate.isEqual(vldPrdExpryDate) || chgDate.isAfter(vldPrdExpryDate)) && (chgDate.isEqual(inspEndDate) || chgDate.isBefore(inspEndDate))) { - targetRecord = record; - log.debug("[날짜수정후부과-명의이전] 검사기간 내 명의이전 발견 - 변경일자: {}, 변경업무: {}", chgYmd, chgTaskSeCd); - break; // 첫 번째 발견된 명의이전 사용 + + // 가장 최근 일자 선택 + if (latestChgDate == null || chgDate.isAfter(latestChgDate)) { + targetRecord = record; + latestChgDate = chgDate; + log.debug("[내사종결-명의이전] 검사기간 내 명의이전 발견 - 변경일자: {}, 변경업무: {}", chgYmd, chgTaskSeCd); + } } } @@ -162,28 +168,26 @@ public class OwnerLevyOver31Checker extends AbstractComparisonChecker { log.info("[날짜수정후부과-명의이전] 명의이전일자가 검사일의 {}일 초과 확인 - 변경일자: {}, 검사일: {}, 일수차이: {}일", DAYS_THRESHOLD, targetChgYmd, inspYmd, daysBetween); - // ========== Step 4: 자동차기본정보 조회 (차대번호, 부과일자=CHG_YMD -1일) ========== + // ========== Step 4: 자동차기본정보 조회 (차대번호, 부과일자=CHG_YMD) ========== 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); + NewBasicRequest step4Request = createBasicRequest(null, vin, targetDate.format(DATE_FORMATTER)); NewBasicResponse step4Response = apiService.getBasicInfo(step4Request); bassMatterLogService.updateCarFfnlgTrgtIdByTxIdNewTx(step4Response, existingData.getCarFfnlgTrgtId()); if (step4Response == null || step4Response.getRecord() == null || step4Response.getRecord().isEmpty()) { - log.warn("[날짜수정후부과-명의이전] Step 4 응답 없음 - 차대번호: {}, 부과일자: {}", vin, targetChgYmdMinus1); + 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 || step4OwnerName.contains("상품용")) { - log.debug("[날짜수정후부과-명의이전] 명의이전 전 소유자가 상품용 - Step4 소유자명: {}", step4OwnerName); + // 검사기간내 명의변경 소유자와 검사일의 소유자가 같냐 + if (step4OwnerName == null || step4RprsvOwnrIdecno.contains(step1RprsvOwnrIdecno)) { + log.debug("[내사종결-명의이전] 명의이전 전 소유자가 상품용 - Step4 소유자명: {}", step4OwnerName); return null; }