🔇 Ships API Log Control

This commit is contained in:
hyojin kim 2026-01-12 14:41:08 +09:00
부모 c3dabd370c
커밋 5305f61a41
10개의 변경된 파일18개의 추가작업 그리고 34개의 파일을 삭제

파일 보기

@ -61,6 +61,11 @@ public class MaritimeApiWebClientConfig {
return WebClient.builder() return WebClient.builder()
.baseUrl(maritimeApiUrl) .baseUrl(maritimeApiUrl)
.filter((request, next) -> {
// [핵심] 여기서 최종 완성된 URI를 로그로 출력합니다.
log.info(">>>> API Request: [{} {}]", request.method(), request.url());
return next.exchange(request);
})
.defaultHeaders(headers -> headers.setBasicAuth(maritimeApiUsername, maritimeApiPassword)) .defaultHeaders(headers -> headers.setBasicAuth(maritimeApiUsername, maritimeApiPassword))
.codecs(configurer -> configurer .codecs(configurer -> configurer
.defaultCodecs() .defaultCodecs()
@ -93,6 +98,11 @@ public class MaritimeApiWebClientConfig {
return WebClient.builder() return WebClient.builder()
.baseUrl(maritimeServiceApiUrl) .baseUrl(maritimeServiceApiUrl)
.filter((request, next) -> {
// [핵심] 여기서 최종 완성된 URI를 로그로 출력합니다.
log.info(">>>> API Request: [{} {}]", request.method(), request.url());
return next.exchange(request);
})
.defaultHeaders(headers -> headers.setBasicAuth(maritimeApiUsername, maritimeApiPassword)) .defaultHeaders(headers -> headers.setBasicAuth(maritimeApiUsername, maritimeApiPassword))
.codecs(configurer -> configurer .codecs(configurer -> configurer
.defaultCodecs() .defaultCodecs()

파일 보기

@ -61,7 +61,6 @@ public class EventDataReader extends BaseApiReader<EventDetailDto> {
@Override @Override
protected void beforeFetch() { protected void beforeFetch() {
// 1. 기간내 기록된 Event List 조회 (API 요청) // 1. 기간내 기록된 Event List 조회 (API 요청)
log.info("Event API 호출");
EventResponse response = callEventApiWithBatch(); EventResponse response = callEventApiWithBatch();
// 2-1. Event List 에서 EventID List 추출 // 2-1. Event List 에서 EventID List 추출
// 2-2. Event List 에서 Map<EventId,Map<StartDate,EndDate>> 추출 // 2-2. Event List 에서 Map<EventId,Map<StartDate,EndDate>> 추출
@ -99,9 +98,6 @@ public class EventDataReader extends BaseApiReader<EventDetailDto> {
int currentBatchNumber = (currentBatchIndex / batchSize) + 1; int currentBatchNumber = (currentBatchIndex / batchSize) + 1;
int totalBatches = (int) Math.ceil((double) eventIds.size() / batchSize); int totalBatches = (int) Math.ceil((double) eventIds.size() / batchSize);
log.info("[{}] 배치 {}/{} 처리 중 (Event ID : {} 개)...",
getReaderName(), currentBatchNumber, totalBatches, currentBatch.size());
try { try {
// API 호출 // API 호출
EventDetailResponse response = callEventDetailApiWithBatch(currentBatch.get(0)); EventDetailResponse response = callEventDetailApiWithBatch(currentBatch.get(0));
@ -192,15 +188,8 @@ public class EventDataReader extends BaseApiReader<EventDetailDto> {
private EventResponse callEventApiWithBatch() { private EventResponse callEventApiWithBatch() {
Map<String, String> params = batchDateService.getDateRangeWithoutTimeParams(getApiKey()); Map<String, String> params = batchDateService.getDateRangeWithoutTimeParams(getApiKey());
String url = getApiPath(); String url = getApiPath();
log.info("[{}] Events API Date Range: {} → {}",
getReaderName(),
String.format("%s-%s-%s",params.get("fromYear"),params.get("fromMonth"),params.get("fromDay")),
String.format("%s-%s-%s",params.get("toYear"),params.get("toMonth"),params.get("toDay"))
);
return webClient.get() return webClient.get()
.uri(url, uriBuilder -> uriBuilder .uri(url, uriBuilder -> uriBuilder
// 맵에서 파라미터 값을 동적으로 가져와 세팅 // 맵에서 파라미터 값을 동적으로 가져와 세팅

파일 보기

@ -96,15 +96,8 @@ public class PscApiReader extends BaseApiReader<PscInspectionDto> {
private List<PscInspectionDto> callApiWithBatch() { private List<PscInspectionDto> callApiWithBatch() {
Map<String, String> params = batchDateService.getDateRangeWithoutTimeParams(getApiKey()); Map<String, String> params = batchDateService.getDateRangeWithoutTimeParams(getApiKey());
String url = getApiPath(); String url = getApiPath();
log.info("[{}] PSC API Date Range: {} → {}",
getReaderName(),
String.format("%s-%s-%s",params.get("fromYear"),params.get("fromMonth"),params.get("fromDay")),
String.format("%s-%s-%s",params.get("toYear"),params.get("toMonth"),params.get("toDay"))
);
String json = webClient.get() String json = webClient.get()
.uri(url, uriBuilder -> uriBuilder .uri(url, uriBuilder -> uriBuilder
.queryParam("shipsCategory", params.get("shipsCategory")) .queryParam("shipsCategory", params.get("shipsCategory"))

파일 보기

@ -139,7 +139,7 @@ public class PscAllCertificateRepositoryImpl extends BaseJdbcRepository<PscAllCe
@Override @Override
public void saveAllCertificates(List<PscAllCertificateEntity> entities) { public void saveAllCertificates(List<PscAllCertificateEntity> entities) {
if (entities == null || entities.isEmpty()) return; if (entities == null || entities.isEmpty()) return;
log.info("PSC AllCertificates 저장 시작 = {}건", entities.size()); // log.info("PSC AllCertificates 저장 시작 = {}건", entities.size());
batchInsert(entities); batchInsert(entities);
} }

파일 보기

@ -132,7 +132,7 @@ public class PscCertificateRepositoryImpl extends BaseJdbcRepository<PscCertific
@Override @Override
public void saveCertificates(List<PscCertificateEntity> entities) { public void saveCertificates(List<PscCertificateEntity> entities) {
if (entities == null || entities.isEmpty()) return; if (entities == null || entities.isEmpty()) return;
log.info("PSC Certificate 저장 시작 = {}건", entities.size()); // log.info("PSC Certificate 저장 시작 = {}건", entities.size());
batchInsert(entities); batchInsert(entities);
} }

파일 보기

@ -156,7 +156,7 @@ public class PscDefectRepositoryImpl extends BaseJdbcRepository<PscDefectEntity,
@Override @Override
public void saveDefects(List<PscDefectEntity> entities) { public void saveDefects(List<PscDefectEntity> entities) {
if (entities == null || entities.isEmpty()) return; if (entities == null || entities.isEmpty()) return;
log.info("PSC Defect 저장 시작 = {}건", entities.size()); // log.info("PSC Defect 저장 시작 = {}건", entities.size());
batchInsert(entities); batchInsert(entities);
} }

파일 보기

@ -165,7 +165,7 @@ public class PscInspectionRepositoryImpl extends BaseJdbcRepository<PscInspectio
@Override @Override
public void saveAll(List<PscInspectionEntity> entities) { public void saveAll(List<PscInspectionEntity> entities) {
if (entities == null || entities.isEmpty()) return; if (entities == null || entities.isEmpty()) return;
log.info("PSC Inspection 저장 시작 = {}건", entities.size()); // log.info("PSC Inspection 저장 시작 = {}건", entities.size());
batchInsert(entities); batchInsert(entities);
} }

파일 보기

@ -32,7 +32,7 @@ public class ShipDetailDataProcessor extends BaseProcessor<ShipDetailComparisonD
// 1. 해시 비교 (변경 감지) // 1. 해시 비교 (변경 감지)
if (isChanged(previousHash, currentHash)) { if (isChanged(previousHash, currentHash)) {
log.info("선박 데이터 변경 감지: imoNumber={}", imo); //log.info("선박 데이터 변경 감지: imoNumber={}", imo);
// 2. 증분 데이터 추출 (Map 기반으로 업데이트 데이터 구성) // 2. 증분 데이터 추출 (Map 기반으로 업데이트 데이터 구성)
// Core20 // Core20

파일 보기

@ -222,8 +222,6 @@ public class ShipDetailUpdateDataReader extends BaseApiReader<ShipDetailComparis
private ShipDetailApiResponse callApiWithBatch(String imoNumbers) { private ShipDetailApiResponse callApiWithBatch(String imoNumbers) {
String url = getApiPath() + "?IMONumbers=" + imoNumbers; String url = getApiPath() + "?IMONumbers=" + imoNumbers;
log.info("[{}] API 호출: {}", getReaderName(), url);
return webClient.get() return webClient.get()
.uri(url) .uri(url)
.retrieve() .retrieve()
@ -253,12 +251,6 @@ public class ShipDetailUpdateDataReader extends BaseApiReader<ShipDetailComparis
String url = getShipUpdateApiPath(); String url = getShipUpdateApiPath();
log.info("[{}] Ship Detail Update Date Range: {} → {}",
getReaderName(),
String.format("%s-%s-%s",params.get("fromYear"),params.get("fromMonth"),params.get("fromDay")),
String.format("%s-%s-%s",params.get("toYear"),params.get("toMonth"),params.get("toDay"))
);
return webClient.get() return webClient.get()
.uri(url, uriBuilder -> uriBuilder .uri(url, uriBuilder -> uriBuilder
// 맵에서 파라미터 값을 동적으로 가져와 세팅 // 맵에서 파라미터 값을 동적으로 가져와 세팅

파일 보기

@ -1,12 +1,12 @@
package com.snp.batch.service; package com.snp.batch.service;
import com.snp.batch.global.model.BatchLastExecution;
import com.snp.batch.global.repository.BatchLastExecutionRepository; import com.snp.batch.global.repository.BatchLastExecutionRepository;
import jakarta.transaction.Transactional;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.time.*; import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;