### feat: `Step 0` 공통 로직 추가 및 delay_checker 업데이트

- **`Step 0` 공통 로직 도입**
  - `ComparisonServiceImpl`에 차량번호 기반 API 호출(`Step 0`) 공통화:
    - API 호출하여 `step0Response` 객체 생성.
    - 결과 데이터 유효성 검증 후 체크 로직에서 재사용.
    - 필요 시 null 반환 및 적절한 로그 출력(`log.warn` / `log.error`).

- **`delay_checker` 클래스 메서드 시그니처 수정**
  - 기존 `check(CarFfnlgTrgtVO existingData, String userOrgCd)` →
    `check(CarFfnlgTrgtVO existingData, String userOrgCd, NewBasicResponse step0Response)`로 변경:
    - `OwnerCloseWithin31Checker`, `ProductUseChecker`, `TransferCase115DayChecker` 등 전범위 반영.
    - `step0Response`를 활용하여 기존 중복 API 호출 제거.
    - 불필요한 `Step 0` 호출 및 데이터 매핑 로직 제거.

- **로직 개선 및 코드 정리**
  - 중복 호출 제거 및 API 응답 데이터 재사용을 위해 호출 순서 정리:
    - 공통 체크(상품용/명의이전 등) → 내사종결 → 날짜 수정 및 부과 순서로 간소화.
    - 각 단계별 로직 정리 및 부적절한 중복 호출 제거.

- **기타**
  - 불필요한 주석 제거 및 메서드 내 주석 추가로 가독성 강화.
  - `createBasicRequest` 메서드 추가로 API 호출 로직 캡슐화.
main
박성영 3 days ago
parent bccccf3966
commit eb4a466a3c

@ -1,6 +1,10 @@
package go.kr.project.carInspectionPenalty.registration.service.impl;
import egovframework.util.SessionUtil;
import go.kr.project.api.model.request.NewBasicRequest;
import go.kr.project.api.model.response.NewBasicResponse;
import go.kr.project.api.service.ExternalVehicleApiService;
import go.kr.project.api.service.VmisCarBassMatterInqireLogService;
import go.kr.project.carInspectionPenalty.registration.model.CarFfnlgTrgtVO;
import go.kr.project.carInspectionPenalty.registration.service.ComparisonService;
import go.kr.project.carInspectionPenalty.registration.service.impl.delay_checker.*;
@ -10,6 +14,9 @@ import lombok.extern.slf4j.Slf4j;
import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl;
import org.springframework.stereotype.Service;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
/**
*
*
@ -28,6 +35,11 @@ public class ComparisonServiceImpl extends EgovAbstractServiceImpl implements Co
private final OwnerLevyOver31Checker ownerLevyOver31Checker;
private final TransferCase115DayChecker transferCase115DayChecker;
private final ExternalVehicleApiService apiService;
private final VmisCarBassMatterInqireLogService bassMatterLogService;
private static final DateTimeFormatter DATE_FORMATTER = DateTimeFormatter.ofPattern("yyyyMMdd");
/**
*
*
@ -54,50 +66,69 @@ public class ComparisonServiceImpl extends EgovAbstractServiceImpl implements Co
// 사용자 조직코드 추출
String userOrgCd = userInfo != null ? userInfo.getOrgCd() : null;
// ========== Step 0: 자동차기본정보 조회 (차량번호 + 오늘일자) - 한번만 호출 ==========
log.info("[공통] Step 0: 자동차기본정보 조회 - 차량번호: {}, 현재일", vhclno);
NewBasicResponse step0Response = null;
try {
NewBasicRequest step0Request = createBasicRequest(vhclno, null, LocalDate.now().format(DATE_FORMATTER));
step0Response = apiService.getBasicInfo(step0Request);
bassMatterLogService.updateCarFfnlgTrgtIdByTxIdNewTx(step0Response, existingData.getCarFfnlgTrgtId());
if (step0Response == null || step0Response.getRecord() == null || step0Response.getRecord().isEmpty()) {
log.warn("[공통] Step 0 응답 없음 - 차량번호: {}", vhclno);
log.info("========== 비교 로직 종료 (Step 0 응답 없음): {} ==========", vhclno);
return null;
}
} catch (Exception e) {
log.error("[공통] Step 0 호출 중 오류 발생 - 차량번호: {}", vhclno, e);
log.info("========== 비교 로직 종료 (Step 0 오류): {} ==========", vhclno);
return null;
}
// ========== 1. 상품용 체크 - api-1번호출.소유자명.contains("상품용") ==========
String productUseResult = productUseChecker.check(existingData, userOrgCd);
String productUseResult = productUseChecker.check(existingData, userOrgCd, step0Response);
if (productUseResult != null) {
log.info("========== 비교 로직 종료 (상품용): {} ==========", vhclno);
return productUseResult;
}
// ========== 2. 상품용 체크 - api-1번호출.소유자명.contains("상품용-변경등록") ==========
String productUseChangeResult = productUseChnageChecker.check(existingData, userOrgCd);
String productUseChangeResult = productUseChnageChecker.check(existingData, userOrgCd, step0Response);
if (productUseChangeResult != null) {
log.info("========== 비교 로직 종료 (상품용-변경등록): {} ==========", vhclno);
return productUseChangeResult;
}
// ========== 3. 내사종결 체크 - 명의이전 이전소유자 상품용, 31일 이내 ==========
String investigationClosedByProductResult = productCloseWithin31Checker.check(existingData, userOrgCd);
String investigationClosedByProductResult = productCloseWithin31Checker.check(existingData, userOrgCd, step0Response);
if (investigationClosedByProductResult != null) {
log.info("========== 비교 로직 종료 (내사종결 - 명의이전 이전소유자 상품용, 31일 이내): {} ==========", vhclno);
return investigationClosedByProductResult;
}
// ========== 4. 내사종결 체크 - 명의이전, 31일 이내 ==========
String investigationClosedByOwnerChangeResult = ownerCloseWithin31Checker.check(existingData, userOrgCd);
String investigationClosedByOwnerChangeResult = ownerCloseWithin31Checker.check(existingData, userOrgCd, step0Response);
if (investigationClosedByOwnerChangeResult != null) {
log.info("========== 비교 로직 종료 (내사종결 - 명의이전, 31일 이내): {} ==========", vhclno);
return investigationClosedByOwnerChangeResult;
}
// ========== 5. 이첩 체크 ==========
String transferResult = transferCase115DayChecker.check(existingData, userOrgCd);
String transferResult = transferCase115DayChecker.check(existingData, userOrgCd, step0Response);
if (transferResult != null) {
log.info("========== 비교 로직 종료 (이첩): {} ==========", vhclno);
return transferResult;
}
// ========== 6. 날짜 수정 후 부과 체크 - 명의이전 이전소유자 상품용, 31일 초과 ==========
String dateModifiedLevyByProductResult = productLevyOver31Checker.check(existingData, userOrgCd);
String dateModifiedLevyByProductResult = productLevyOver31Checker.check(existingData, userOrgCd, step0Response);
if (dateModifiedLevyByProductResult != null) {
log.info("========== 비교 로직 종료 (날짜 수정 후 부과 - 명의이전 이전소유자, 31일 초과): {} ==========", vhclno);
return dateModifiedLevyByProductResult;
}
// ========== 7. 날짜 수정 후 부과 체크 - 명의이전, 31일 초과 ==========
String dateModifiedLevyByOwnerChangeOverResult = ownerLevyOver31Checker.check(existingData, userOrgCd);
String dateModifiedLevyByOwnerChangeOverResult = ownerLevyOver31Checker.check(existingData, userOrgCd, step0Response);
if (dateModifiedLevyByOwnerChangeOverResult != null) {
log.info("========== 비교 로직 종료 (날짜 수정 후 부과 - 명의이전, 31일 초과): {} ==========", vhclno);
return dateModifiedLevyByOwnerChangeOverResult;
@ -108,4 +139,27 @@ public class ComparisonServiceImpl extends EgovAbstractServiceImpl implements Co
log.info("========== 비교 로직 종료 (미적용): {} ==========", vhclno);
return null;
}
/**
*
*/
private NewBasicRequest createBasicRequest(String vhrno, String vin, String levyCrtrYmd) {
NewBasicRequest request = new NewBasicRequest();
NewBasicRequest.Record record = new NewBasicRequest.Record();
record.setLevyCrtrYmd(levyCrtrYmd);
if (vhrno != null) {
// API 호출 시 '*' 특수문자 제거 (전출차량 표시용)
String cleanVhrno = vhrno.replace("*", "");
record.setVhrno(cleanVhrno);
record.setInqSeCd("3"); // 3: 자동차번호
} else if (vin != null) {
record.setVin(vin);
record.setInqSeCd("2"); // 2: 차대번호
}
request.setRecord(java.util.Arrays.asList(record));
return request;
}
}

@ -1,5 +1,6 @@
package go.kr.project.carInspectionPenalty.registration.service.impl.delay_checker;
import go.kr.project.api.model.response.NewBasicResponse;
import go.kr.project.carInspectionPenalty.registration.model.CarFfnlgTrgtVO;
/**
@ -14,7 +15,8 @@ public interface ComparisonChecker {
*
* @param existingData
* @param userOrgCd
* @param step0Response Step 0 API ( + )
* @return null ()
*/
String check(CarFfnlgTrgtVO existingData, String userOrgCd);
String check(CarFfnlgTrgtVO existingData, String userOrgCd, NewBasicResponse step0Response);
}

@ -36,7 +36,7 @@ public class OwnerCloseWithin31Checker extends AbstractComparisonChecker {
}
@Override
public String check(CarFfnlgTrgtVO existingData, String userOrgCd) {
public String check(CarFfnlgTrgtVO existingData, String userOrgCd, NewBasicResponse step0Response) {
String vhclno = existingData.getVhclno();
String inspYmd = existingData.getInspYmd().replace("-", "");
String vldPrdExpryYmd = existingData.getVldPrdExpryYmd().replace("-", "");
@ -44,11 +44,7 @@ public class OwnerCloseWithin31Checker extends AbstractComparisonChecker {
try {
log.info("[내사종결-명의이전] Step 0: 자동차기본정보 조회 - 차량번호: {}, 현재일", vhclno);
NewBasicRequest step0Request = createBasicRequest(vhclno, null, LocalDate.now().format(DATE_FORMATTER));
NewBasicResponse step0Response = apiService.getBasicInfo(step0Request);
bassMatterLogService.updateCarFfnlgTrgtIdByTxIdNewTx(step0Response, existingData.getCarFfnlgTrgtId());
// Step 0: 공통으로 이미 호출됨 - step0Response 사용
if (step0Response == null || step0Response.getRecord() == null || step0Response.getRecord().isEmpty()) {
log.warn("[내사종결-명의이전] Step 0 응답 없음 - 차량번호: {}", vhclno);
return null;

@ -36,7 +36,7 @@ public class OwnerLevyOver31Checker extends AbstractComparisonChecker {
}
@Override
public String check(CarFfnlgTrgtVO existingData, String userOrgCd) {
public String check(CarFfnlgTrgtVO existingData, String userOrgCd, NewBasicResponse step0Response) {
String vhclno = existingData.getVhclno();
String inspYmd = existingData.getInspYmd().replace("-", "");
String vldPrdExpryYmd = existingData.getVldPrdExpryYmd().replace("-", "");
@ -44,11 +44,7 @@ public class OwnerLevyOver31Checker extends AbstractComparisonChecker {
try {
log.info("[날짜수정후부과-명의이전] Step 0: 자동차기본정보 조회 - 차량번호: {}, 현재일", vhclno);
NewBasicRequest step0Request = createBasicRequest(vhclno, null, LocalDate.now().format(DATE_FORMATTER));
NewBasicResponse step0Response = apiService.getBasicInfo(step0Request);
bassMatterLogService.updateCarFfnlgTrgtIdByTxIdNewTx(step0Response, existingData.getCarFfnlgTrgtId());
// Step 0: 공통으로 이미 호출됨 - step0Response 사용
if (step0Response == null || step0Response.getRecord() == null || step0Response.getRecord().isEmpty()) {
log.warn("[날짜수정후부과-명의이전] Step 0 응답 없음 - 차량번호: {}", vhclno);
return null;

@ -36,7 +36,7 @@ public class ProductCloseWithin31Checker extends AbstractComparisonChecker {
}
@Override
public String check(CarFfnlgTrgtVO existingData, String userOrgCd) {
public String check(CarFfnlgTrgtVO existingData, String userOrgCd, NewBasicResponse step0Response) {
String vhclno = existingData.getVhclno();
String inspYmd = existingData.getInspYmd().replace("-", "");
String vldPrdExpryYmd = existingData.getVldPrdExpryYmd().replace("-", "");
@ -44,11 +44,7 @@ public class ProductCloseWithin31Checker extends AbstractComparisonChecker {
try {
log.info("[내사종결-명의이전 상품용] Step 0: 자동차기본정보 조회 - 차량번호: {}, 현재일", vhclno);
NewBasicRequest step0Request = createBasicRequest(vhclno, null, LocalDate.now().format(DATE_FORMATTER));
NewBasicResponse step0Response = apiService.getBasicInfo(step0Request);
bassMatterLogService.updateCarFfnlgTrgtIdByTxIdNewTx(step0Response, existingData.getCarFfnlgTrgtId());
// Step 0: 공통으로 이미 호출됨 - step0Response 사용
if (step0Response == null || step0Response.getRecord() == null || step0Response.getRecord().isEmpty()) {
log.warn("[내사종결-명의이전 상품용] Step 0 응답 없음 - 차량번호: {}", vhclno);
return null;

@ -36,7 +36,7 @@ public class ProductLevyOver31Checker extends AbstractComparisonChecker {
}
@Override
public String check(CarFfnlgTrgtVO existingData, String userOrgCd) {
public String check(CarFfnlgTrgtVO existingData, String userOrgCd, NewBasicResponse step0Response) {
String vhclno = existingData.getVhclno();
String inspYmd = existingData.getInspYmd().replace("-", "");
String vldPrdExpryYmd = existingData.getVldPrdExpryYmd().replace("-", "");
@ -44,11 +44,7 @@ public class ProductLevyOver31Checker extends AbstractComparisonChecker {
try {
log.info("[날짜수정후부과-명의이전 상품용] Step 0: 자동차기본정보 조회 - 차량번호: {}, 현재일", vhclno);
NewBasicRequest step0Request = createBasicRequest(vhclno, null, LocalDate.now().format(DATE_FORMATTER));
NewBasicResponse step0Response = apiService.getBasicInfo(step0Request);
bassMatterLogService.updateCarFfnlgTrgtIdByTxIdNewTx(step0Response, existingData.getCarFfnlgTrgtId());
// Step 0: 공통으로 이미 호출됨 - step0Response 사용
if (step0Response == null || step0Response.getRecord() == null || step0Response.getRecord().isEmpty()) {
log.warn("[날짜수정후부과-명의이전 상품용] Step 0 응답 없음 - 차량번호: {}", vhclno);
return null;

@ -36,7 +36,7 @@ public class ProductUseChecker extends AbstractComparisonChecker {
}
@Override
public String check(CarFfnlgTrgtVO existingData, String userOrgCd) {
public String check(CarFfnlgTrgtVO existingData, String userOrgCd, NewBasicResponse step0Response) {
String vhclno = existingData.getVhclno();
String inspYmd = existingData.getInspYmd().replace("-", "");
String vldPrdExpryYmd = existingData.getVldPrdExpryYmd().replace("-", "");
@ -44,18 +44,14 @@ public class ProductUseChecker extends AbstractComparisonChecker {
try {
log.info("[상품용] Step 0: 자동차기본정보 조회 - 차량번호: {}, 현재일", vhclno);
NewBasicRequest step0Request = createBasicRequest(vhclno, null, LocalDate.now().format(DATE_FORMATTER));
NewBasicResponse step0Response = apiService.getBasicInfo(step0Request);
bassMatterLogService.updateCarFfnlgTrgtIdByTxIdNewTx(step0Response, existingData.getCarFfnlgTrgtId());
if (step0Response == null || step0Response.getRecord() == null || step0Response.getRecord().isEmpty()) {
log.warn("[상품용] Step 0 응답 없음 - 차량번호: {}", vhclno);
return null;
}
// Step 0: 공통으로 이미 호출됨 - step0Response 사용
if (step0Response == null || step0Response.getRecord() == null || step0Response.getRecord().isEmpty()) {
log.warn("[상품용] Step 0 응답 없음 - 차량번호: {}", vhclno);
return null;
}
NewBasicResponse.Record step0Record = step0Response.getRecord().get(0);
String step0vin = step0Record.getVin(); // 차대번호
NewBasicResponse.Record step0Record = step0Response.getRecord().get(0);
String step0vin = step0Record.getVin(); // 차대번호
// ========== Step 1: 자동차기본정보 조회 (차대번호, 부과일자=검사일) ==========
log.info("[상품용] Step 1: 자동차기본정보 조회 - 차대번호: {}, 검사일: {}", step0vin, inspYmd);

@ -36,7 +36,7 @@ public class ProductUseChnageChecker extends AbstractComparisonChecker {
}
@Override
public String check(CarFfnlgTrgtVO existingData, String userOrgCd) {
public String check(CarFfnlgTrgtVO existingData, String userOrgCd, NewBasicResponse step0Response) {
String vhclno = existingData.getVhclno();
String inspYmd = existingData.getInspYmd().replace("-", "");
String vldPrdExpryYmd = existingData.getVldPrdExpryYmd().replace("-", "");
@ -44,18 +44,14 @@ public class ProductUseChnageChecker extends AbstractComparisonChecker {
try {
log.info("[상품용] Step 0: 자동차기본정보 조회 - 차량번호: {}, 현재일", vhclno);
NewBasicRequest step0Request = createBasicRequest(vhclno, null, LocalDate.now().format(DATE_FORMATTER));
NewBasicResponse step0Response = apiService.getBasicInfo(step0Request);
bassMatterLogService.updateCarFfnlgTrgtIdByTxIdNewTx(step0Response, existingData.getCarFfnlgTrgtId());
if (step0Response == null || step0Response.getRecord() == null || step0Response.getRecord().isEmpty()) {
log.warn("[상품용] Step 0 응답 없음 - 차량번호: {}", vhclno);
return null;
}
// Step 0: 공통으로 이미 호출됨 - step0Response 사용
if (step0Response == null || step0Response.getRecord() == null || step0Response.getRecord().isEmpty()) {
log.warn("[상품용-변경등록] Step 0 응답 없음 - 차량번호: {}", vhclno);
return null;
}
NewBasicResponse.Record step0Record = step0Response.getRecord().get(0);
String step0vin = step0Record.getVin(); // 차대번호
NewBasicResponse.Record step0Record = step0Response.getRecord().get(0);
String step0vin = step0Record.getVin(); // 차대번호
// ========== Step 1: 자동차기본정보 조회 (차량번호, 부과일자=검사일) ==========
log.info("[상품용-변경등록] Step 1: 자동차기본정보 조회 - 차대번호: {}, 검사일: {}", step0vin, inspYmd);

@ -33,7 +33,7 @@ public class TransferCase115DayChecker extends AbstractComparisonChecker {
}
@Override
public String check(CarFfnlgTrgtVO existingData, String userOrgCd) {
public String check(CarFfnlgTrgtVO existingData, String userOrgCd, NewBasicResponse step0Response) {
String vhclno = existingData.getVhclno();
try {
@ -66,18 +66,14 @@ public class TransferCase115DayChecker extends AbstractComparisonChecker {
log.info("[이첩-1] 부과기준일 = 검사일자 = {}", levyCrtrYmd);
}
log.info("[이첩] Step 0: 자동차기본정보 조회 - 차량번호: {}, 현재일", vhclno);
NewBasicRequest step0Request = createBasicRequest(vhclno, null, LocalDate.now().format(DATE_FORMATTER));
NewBasicResponse step0Response = apiService.getBasicInfo(step0Request);
bassMatterLogService.updateCarFfnlgTrgtIdByTxIdNewTx(step0Response, existingData.getCarFfnlgTrgtId());
if (step0Response == null || step0Response.getRecord() == null || step0Response.getRecord().isEmpty()) {
log.warn("[이첩] Step 0 응답 없음 - 차량번호: {}", vhclno);
return null;
}
// Step 0: 공통으로 이미 호출됨 - step0Response 사용
if (step0Response == null || step0Response.getRecord() == null || step0Response.getRecord().isEmpty()) {
log.warn("[이첩] Step 0 응답 없음 - 차량번호: {}", vhclno);
return null;
}
NewBasicResponse.Record step0Record = step0Response.getRecord().get(0);
String step0vin = step0Record.getVin(); // 차대번호
NewBasicResponse.Record step0Record = step0Response.getRecord().get(0);
String step0vin = step0Record.getVin(); // 차대번호
// 자동차기본정보 API 호출 (부과기준일 기준)
log.info("[{}] 자동차기본정보 조회 - 차대번호: {}, 부과기준일: {}", transferType, step0vin, levyCrtrYmd);

Loading…
Cancel
Save