fix: 마지막 성공 일시 세팅 방법 수정
This commit is contained in:
부모
fe447c9f68
커밋
3cdb8e024f
@ -30,6 +30,8 @@ import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
import org.springframework.web.reactive.function.client.WebClient;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
@ -56,11 +58,6 @@ public class CompanyComplianceImportRangeJobConfig extends BaseMultiStepJobConfi
|
||||
private int lastExecutionBufferHours;
|
||||
|
||||
protected String getApiKey() {return "COMPANY_COMPLIANCE_IMPORT_API";}
|
||||
protected String getBatchUpdateSql() {
|
||||
return String.format(
|
||||
"UPDATE %s.BATCH_LAST_EXECUTION SET LAST_SUCCESS_DATE = NOW() - INTERVAL '%d HOURS', UPDATED_AT = NOW() WHERE API_KEY = '%s'",
|
||||
targetSchema, lastExecutionBufferHours, getApiKey());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getChunkSize() {
|
||||
@ -215,11 +212,25 @@ public class CompanyComplianceImportRangeJobConfig extends BaseMultiStepJobConfi
|
||||
@Bean
|
||||
public Tasklet companyComplianceLastExecutionUpdateTasklet() {
|
||||
return (contribution, chunkContext) -> {
|
||||
log.info(">>>>> 모든 스텝 성공: BATCH_LAST_EXECUTION 업데이트 시작 (버퍼: {}시간)", lastExecutionBufferHours);
|
||||
String toDateStr = chunkContext.getStepContext()
|
||||
.getStepExecution().getJobExecution()
|
||||
.getExecutionContext().getString("batchToDate", null);
|
||||
|
||||
jdbcTemplate.execute(getBatchUpdateSql());
|
||||
LocalDateTime successDate;
|
||||
if (toDateStr != null) {
|
||||
successDate = LocalDateTime.parse(toDateStr).minusHours(lastExecutionBufferHours);
|
||||
log.info(">>>>> BATCH_LAST_EXECUTION 업데이트 시작 (캡처된 toDate - {}시간 버퍼: {})", lastExecutionBufferHours, successDate);
|
||||
} else {
|
||||
successDate = LocalDateTime.now().minusHours(lastExecutionBufferHours);
|
||||
log.warn(">>>>> batchToDate가 없어 현재 시간 - {}시간 버퍼 사용: {}", lastExecutionBufferHours, successDate);
|
||||
}
|
||||
|
||||
log.info(">>>>> BATCH_LAST_EXECUTION 업데이트 완료 (LAST_SUCCESS_DATE = NOW() - {}시간)", lastExecutionBufferHours);
|
||||
jdbcTemplate.update(
|
||||
String.format("UPDATE %s.BATCH_LAST_EXECUTION SET LAST_SUCCESS_DATE = ?, UPDATED_AT = NOW() WHERE API_KEY = ?", targetSchema),
|
||||
Timestamp.valueOf(successDate), getApiKey()
|
||||
);
|
||||
|
||||
log.info(">>>>> BATCH_LAST_EXECUTION 업데이트 완료 (LAST_SUCCESS_DATE = {})", successDate);
|
||||
return RepeatStatus.FINISHED;
|
||||
};
|
||||
}
|
||||
|
||||
@ -30,6 +30,8 @@ import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
import org.springframework.web.reactive.function.client.WebClient;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
@ -55,11 +57,6 @@ public class ComplianceImportRangeJobConfig extends BaseMultiStepJobConfig<Compl
|
||||
private int lastExecutionBufferHours;
|
||||
|
||||
protected String getApiKey() {return "COMPLIANCE_IMPORT_API";}
|
||||
protected String getBatchUpdateSql() {
|
||||
return String.format(
|
||||
"UPDATE %s.BATCH_LAST_EXECUTION SET LAST_SUCCESS_DATE = NOW() - INTERVAL '%d HOURS', UPDATED_AT = NOW() WHERE API_KEY = '%s'",
|
||||
targetSchema, lastExecutionBufferHours, getApiKey());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getChunkSize() {
|
||||
@ -217,11 +214,25 @@ public class ComplianceImportRangeJobConfig extends BaseMultiStepJobConfig<Compl
|
||||
@Bean
|
||||
public Tasklet complianceLastExecutionUpdateTasklet() {
|
||||
return (contribution, chunkContext) -> {
|
||||
log.info(">>>>> 모든 스텝 성공: BATCH_LAST_EXECUTION 업데이트 시작 (버퍼: {}시간)", lastExecutionBufferHours);
|
||||
String toDateStr = chunkContext.getStepContext()
|
||||
.getStepExecution().getJobExecution()
|
||||
.getExecutionContext().getString("batchToDate", null);
|
||||
|
||||
jdbcTemplate.execute(getBatchUpdateSql());
|
||||
LocalDateTime successDate;
|
||||
if (toDateStr != null) {
|
||||
successDate = LocalDateTime.parse(toDateStr).minusHours(lastExecutionBufferHours);
|
||||
log.info(">>>>> BATCH_LAST_EXECUTION 업데이트 시작 (캡처된 toDate - {}시간 버퍼: {})", lastExecutionBufferHours, successDate);
|
||||
} else {
|
||||
successDate = LocalDateTime.now().minusHours(lastExecutionBufferHours);
|
||||
log.warn(">>>>> batchToDate가 없어 현재 시간 - {}시간 버퍼 사용: {}", lastExecutionBufferHours, successDate);
|
||||
}
|
||||
|
||||
log.info(">>>>> BATCH_LAST_EXECUTION 업데이트 완료 (LAST_SUCCESS_DATE = NOW() - {}시간)", lastExecutionBufferHours);
|
||||
jdbcTemplate.update(
|
||||
String.format("UPDATE %s.BATCH_LAST_EXECUTION SET LAST_SUCCESS_DATE = ?, UPDATED_AT = NOW() WHERE API_KEY = ?", targetSchema),
|
||||
Timestamp.valueOf(successDate), getApiKey()
|
||||
);
|
||||
|
||||
log.info(">>>>> BATCH_LAST_EXECUTION 업데이트 완료 (LAST_SUCCESS_DATE = {})", successDate);
|
||||
return RepeatStatus.FINISHED;
|
||||
};
|
||||
}
|
||||
|
||||
@ -30,6 +30,9 @@ import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
import org.springframework.web.reactive.function.client.WebClient;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Slf4j
|
||||
@Configuration
|
||||
public class EventImportJobConfig extends BaseMultiStepJobConfig<EventDetailDto, EventDetailEntity> {
|
||||
@ -51,11 +54,6 @@ public class EventImportJobConfig extends BaseMultiStepJobConfig<EventDetailDto,
|
||||
private int lastExecutionBufferHours;
|
||||
|
||||
protected String getApiKey() {return "EVENT_IMPORT_API";}
|
||||
protected String getBatchUpdateSql() {
|
||||
return String.format(
|
||||
"UPDATE %s.BATCH_LAST_EXECUTION SET LAST_SUCCESS_DATE = NOW() - INTERVAL '%d HOURS', UPDATED_AT = NOW() WHERE API_KEY = '%s'",
|
||||
targetSchema, lastExecutionBufferHours, getApiKey());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getChunkSize() {
|
||||
@ -162,11 +160,25 @@ public class EventImportJobConfig extends BaseMultiStepJobConfig<EventDetailDto,
|
||||
@Bean
|
||||
public Tasklet eventLastExecutionUpdateTasklet() {
|
||||
return (contribution, chunkContext) -> {
|
||||
log.info(">>>>> 모든 스텝 성공: BATCH_LAST_EXECUTION 업데이트 시작 (버퍼: {}시간)", lastExecutionBufferHours);
|
||||
String toDateStr = chunkContext.getStepContext()
|
||||
.getStepExecution().getJobExecution()
|
||||
.getExecutionContext().getString("batchToDate", null);
|
||||
|
||||
jdbcTemplate.execute(getBatchUpdateSql());
|
||||
LocalDateTime successDate;
|
||||
if (toDateStr != null) {
|
||||
successDate = LocalDateTime.parse(toDateStr).minusHours(lastExecutionBufferHours);
|
||||
log.info(">>>>> BATCH_LAST_EXECUTION 업데이트 시작 (캡처된 toDate - {}시간 버퍼: {})", lastExecutionBufferHours, successDate);
|
||||
} else {
|
||||
successDate = LocalDateTime.now().minusHours(lastExecutionBufferHours);
|
||||
log.warn(">>>>> batchToDate가 없어 현재 시간 - {}시간 버퍼 사용: {}", lastExecutionBufferHours, successDate);
|
||||
}
|
||||
|
||||
log.info(">>>>> BATCH_LAST_EXECUTION 업데이트 완료 (LAST_SUCCESS_DATE = NOW() - {}시간)", lastExecutionBufferHours);
|
||||
jdbcTemplate.update(
|
||||
String.format("UPDATE %s.BATCH_LAST_EXECUTION SET LAST_SUCCESS_DATE = ?, UPDATED_AT = NOW() WHERE API_KEY = ?", targetSchema),
|
||||
Timestamp.valueOf(successDate), getApiKey()
|
||||
);
|
||||
|
||||
log.info(">>>>> BATCH_LAST_EXECUTION 업데이트 완료 (LAST_SUCCESS_DATE = {})", successDate);
|
||||
return RepeatStatus.FINISHED;
|
||||
};
|
||||
}
|
||||
|
||||
@ -29,6 +29,9 @@ import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
import org.springframework.web.reactive.function.client.WebClient;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Slf4j
|
||||
@Configuration
|
||||
public class AnchorageCallsRangeJobConfig extends BaseMultiStepJobConfig<AnchorageCallsDto, AnchorageCallsEntity> {
|
||||
@ -49,8 +52,6 @@ public class AnchorageCallsRangeJobConfig extends BaseMultiStepJobConfig<Anchora
|
||||
private String targetSchema;
|
||||
|
||||
protected String getApiKey() {return "ANCHORAGE_CALLS_IMPORT_API";}
|
||||
protected String getBatchUpdateSql() {
|
||||
return String.format("UPDATE %s.BATCH_LAST_EXECUTION SET LAST_SUCCESS_DATE = NOW(), UPDATED_AT = NOW() WHERE API_KEY = '%s'", targetSchema, getApiKey());}
|
||||
|
||||
|
||||
public AnchorageCallsRangeJobConfig(
|
||||
@ -149,11 +150,25 @@ public class AnchorageCallsRangeJobConfig extends BaseMultiStepJobConfig<Anchora
|
||||
@Bean
|
||||
public Tasklet anchorageCallsLastExecutionUpdateTasklet() {
|
||||
return (contribution, chunkContext) -> {
|
||||
log.info(">>>>> 모든 스텝 성공: BATCH_LAST_EXECUTION 업데이트 시작");
|
||||
String toDateStr = chunkContext.getStepContext()
|
||||
.getStepExecution().getJobExecution()
|
||||
.getExecutionContext().getString("batchToDate", null);
|
||||
|
||||
jdbcTemplate.execute(getBatchUpdateSql());
|
||||
LocalDateTime successDate;
|
||||
if (toDateStr != null) {
|
||||
successDate = LocalDateTime.parse(toDateStr);
|
||||
log.info(">>>>> BATCH_LAST_EXECUTION 업데이트 시작 (캡처된 toDate: {})", successDate);
|
||||
} else {
|
||||
successDate = LocalDateTime.now();
|
||||
log.warn(">>>>> batchToDate가 없어 현재 시간 사용: {}", successDate);
|
||||
}
|
||||
|
||||
log.info(">>>>> BATCH_LAST_EXECUTION 업데이트 완료");
|
||||
jdbcTemplate.update(
|
||||
String.format("UPDATE %s.BATCH_LAST_EXECUTION SET LAST_SUCCESS_DATE = ?, UPDATED_AT = NOW() WHERE API_KEY = ?", targetSchema),
|
||||
Timestamp.valueOf(successDate), getApiKey()
|
||||
);
|
||||
|
||||
log.info(">>>>> BATCH_LAST_EXECUTION 업데이트 완료 (LAST_SUCCESS_DATE = {})", successDate);
|
||||
return RepeatStatus.FINISHED;
|
||||
};
|
||||
}
|
||||
|
||||
@ -29,6 +29,9 @@ import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
import org.springframework.web.reactive.function.client.WebClient;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Slf4j
|
||||
@Configuration
|
||||
public class BerthCallsRangJobConfig extends BaseMultiStepJobConfig<BerthCallsDto, BerthCallsEntity> {
|
||||
@ -48,8 +51,6 @@ public class BerthCallsRangJobConfig extends BaseMultiStepJobConfig<BerthCallsDt
|
||||
private String targetSchema;
|
||||
|
||||
protected String getApiKey() {return "BERTH_CALLS_IMPORT_API";}
|
||||
protected String getBatchUpdateSql() {
|
||||
return String.format("UPDATE %s.BATCH_LAST_EXECUTION SET LAST_SUCCESS_DATE = NOW(), UPDATED_AT = NOW() WHERE API_KEY = '%s'", targetSchema, getApiKey());}
|
||||
|
||||
public BerthCallsRangJobConfig(
|
||||
JobRepository jobRepository,
|
||||
@ -143,11 +144,25 @@ public class BerthCallsRangJobConfig extends BaseMultiStepJobConfig<BerthCallsDt
|
||||
@Bean
|
||||
public Tasklet berthCallsLastExecutionUpdateTasklet() {
|
||||
return (contribution, chunkContext) -> {
|
||||
log.info(">>>>> 모든 스텝 성공: BATCH_LAST_EXECUTION 업데이트 시작");
|
||||
String toDateStr = chunkContext.getStepContext()
|
||||
.getStepExecution().getJobExecution()
|
||||
.getExecutionContext().getString("batchToDate", null);
|
||||
|
||||
jdbcTemplate.execute(getBatchUpdateSql());
|
||||
LocalDateTime successDate;
|
||||
if (toDateStr != null) {
|
||||
successDate = LocalDateTime.parse(toDateStr);
|
||||
log.info(">>>>> BATCH_LAST_EXECUTION 업데이트 시작 (캡처된 toDate: {})", successDate);
|
||||
} else {
|
||||
successDate = LocalDateTime.now();
|
||||
log.warn(">>>>> batchToDate가 없어 현재 시간 사용: {}", successDate);
|
||||
}
|
||||
|
||||
log.info(">>>>> BATCH_LAST_EXECUTION 업데이트 완료");
|
||||
jdbcTemplate.update(
|
||||
String.format("UPDATE %s.BATCH_LAST_EXECUTION SET LAST_SUCCESS_DATE = ?, UPDATED_AT = NOW() WHERE API_KEY = ?", targetSchema),
|
||||
Timestamp.valueOf(successDate), getApiKey()
|
||||
);
|
||||
|
||||
log.info(">>>>> BATCH_LAST_EXECUTION 업데이트 완료 (LAST_SUCCESS_DATE = {})", successDate);
|
||||
return RepeatStatus.FINISHED;
|
||||
};
|
||||
}
|
||||
|
||||
@ -29,6 +29,9 @@ import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
import org.springframework.web.reactive.function.client.WebClient;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Slf4j
|
||||
@Configuration
|
||||
public class CurrentlyAtRangeJobConfig extends BaseMultiStepJobConfig<CurrentlyAtDto, CurrentlyAtEntity> {
|
||||
@ -48,8 +51,6 @@ public class CurrentlyAtRangeJobConfig extends BaseMultiStepJobConfig<CurrentlyA
|
||||
private String targetSchema;
|
||||
|
||||
protected String getApiKey() {return "CURRENTLY_AT_IMPORT_API";}
|
||||
protected String getBatchUpdateSql() {
|
||||
return String.format("UPDATE %s.BATCH_LAST_EXECUTION SET LAST_SUCCESS_DATE = NOW(), UPDATED_AT = NOW() WHERE API_KEY = '%s'", targetSchema, getApiKey());}
|
||||
|
||||
public CurrentlyAtRangeJobConfig(
|
||||
JobRepository jobRepository,
|
||||
@ -141,11 +142,25 @@ public class CurrentlyAtRangeJobConfig extends BaseMultiStepJobConfig<CurrentlyA
|
||||
@Bean
|
||||
public Tasklet currentlyAtLastExecutionUpdateTasklet() {
|
||||
return (contribution, chunkContext) -> {
|
||||
log.info(">>>>> 모든 스텝 성공: BATCH_LAST_EXECUTION 업데이트 시작");
|
||||
String toDateStr = chunkContext.getStepContext()
|
||||
.getStepExecution().getJobExecution()
|
||||
.getExecutionContext().getString("batchToDate", null);
|
||||
|
||||
jdbcTemplate.execute(getBatchUpdateSql());
|
||||
LocalDateTime successDate;
|
||||
if (toDateStr != null) {
|
||||
successDate = LocalDateTime.parse(toDateStr);
|
||||
log.info(">>>>> BATCH_LAST_EXECUTION 업데이트 시작 (캡처된 toDate: {})", successDate);
|
||||
} else {
|
||||
successDate = LocalDateTime.now();
|
||||
log.warn(">>>>> batchToDate가 없어 현재 시간 사용: {}", successDate);
|
||||
}
|
||||
|
||||
log.info(">>>>> BATCH_LAST_EXECUTION 업데이트 완료");
|
||||
jdbcTemplate.update(
|
||||
String.format("UPDATE %s.BATCH_LAST_EXECUTION SET LAST_SUCCESS_DATE = ?, UPDATED_AT = NOW() WHERE API_KEY = ?", targetSchema),
|
||||
Timestamp.valueOf(successDate), getApiKey()
|
||||
);
|
||||
|
||||
log.info(">>>>> BATCH_LAST_EXECUTION 업데이트 완료 (LAST_SUCCESS_DATE = {})", successDate);
|
||||
return RepeatStatus.FINISHED;
|
||||
};
|
||||
}
|
||||
|
||||
@ -29,6 +29,9 @@ import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
import org.springframework.web.reactive.function.client.WebClient;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Slf4j
|
||||
@Configuration
|
||||
public class DestinationsRangeJobConfig extends BaseMultiStepJobConfig<DestinationDto, DestinationEntity> {
|
||||
@ -48,8 +51,6 @@ public class DestinationsRangeJobConfig extends BaseMultiStepJobConfig<Destinati
|
||||
private String targetSchema;
|
||||
|
||||
protected String getApiKey() {return "DESTINATIONS_IMPORT_API";}
|
||||
protected String getBatchUpdateSql() {
|
||||
return String.format("UPDATE %s.BATCH_LAST_EXECUTION SET LAST_SUCCESS_DATE = NOW(), UPDATED_AT = NOW() WHERE API_KEY = '%s'", targetSchema, getApiKey());}
|
||||
|
||||
|
||||
public DestinationsRangeJobConfig(
|
||||
@ -144,11 +145,25 @@ public class DestinationsRangeJobConfig extends BaseMultiStepJobConfig<Destinati
|
||||
@Bean
|
||||
public Tasklet destinationsLastExecutionUpdateTasklet() {
|
||||
return (contribution, chunkContext) -> {
|
||||
log.info(">>>>> 모든 스텝 성공: BATCH_LAST_EXECUTION 업데이트 시작");
|
||||
String toDateStr = chunkContext.getStepContext()
|
||||
.getStepExecution().getJobExecution()
|
||||
.getExecutionContext().getString("batchToDate", null);
|
||||
|
||||
jdbcTemplate.execute(getBatchUpdateSql());
|
||||
LocalDateTime successDate;
|
||||
if (toDateStr != null) {
|
||||
successDate = LocalDateTime.parse(toDateStr);
|
||||
log.info(">>>>> BATCH_LAST_EXECUTION 업데이트 시작 (캡처된 toDate: {})", successDate);
|
||||
} else {
|
||||
successDate = LocalDateTime.now();
|
||||
log.warn(">>>>> batchToDate가 없어 현재 시간 사용: {}", successDate);
|
||||
}
|
||||
|
||||
log.info(">>>>> BATCH_LAST_EXECUTION 업데이트 완료");
|
||||
jdbcTemplate.update(
|
||||
String.format("UPDATE %s.BATCH_LAST_EXECUTION SET LAST_SUCCESS_DATE = ?, UPDATED_AT = NOW() WHERE API_KEY = ?", targetSchema),
|
||||
Timestamp.valueOf(successDate), getApiKey()
|
||||
);
|
||||
|
||||
log.info(">>>>> BATCH_LAST_EXECUTION 업데이트 완료 (LAST_SUCCESS_DATE = {})", successDate);
|
||||
return RepeatStatus.FINISHED;
|
||||
};
|
||||
}
|
||||
|
||||
@ -29,6 +29,9 @@ import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
import org.springframework.web.reactive.function.client.WebClient;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Slf4j
|
||||
@Configuration
|
||||
public class ShipPortCallsRangeJobConfig extends BaseMultiStepJobConfig<PortCallsDto, PortCallsEntity> {
|
||||
@ -48,8 +51,6 @@ public class ShipPortCallsRangeJobConfig extends BaseMultiStepJobConfig<PortCall
|
||||
private String targetSchema;
|
||||
|
||||
protected String getApiKey() {return "PORT_CALLS_IMPORT_API";}
|
||||
protected String getBatchUpdateSql() {
|
||||
return String.format("UPDATE %s.BATCH_LAST_EXECUTION SET LAST_SUCCESS_DATE = NOW(), UPDATED_AT = NOW() WHERE API_KEY = '%s'", targetSchema, getApiKey());}
|
||||
|
||||
public ShipPortCallsRangeJobConfig(
|
||||
JobRepository jobRepository,
|
||||
@ -145,11 +146,25 @@ public class ShipPortCallsRangeJobConfig extends BaseMultiStepJobConfig<PortCall
|
||||
@Bean
|
||||
public Tasklet portCallsLastExecutionUpdateTasklet() {
|
||||
return (contribution, chunkContext) -> {
|
||||
log.info(">>>>> 모든 스텝 성공: BATCH_LAST_EXECUTION 업데이트 시작");
|
||||
String toDateStr = chunkContext.getStepContext()
|
||||
.getStepExecution().getJobExecution()
|
||||
.getExecutionContext().getString("batchToDate", null);
|
||||
|
||||
jdbcTemplate.execute(getBatchUpdateSql());
|
||||
LocalDateTime successDate;
|
||||
if (toDateStr != null) {
|
||||
successDate = LocalDateTime.parse(toDateStr);
|
||||
log.info(">>>>> BATCH_LAST_EXECUTION 업데이트 시작 (캡처된 toDate: {})", successDate);
|
||||
} else {
|
||||
successDate = LocalDateTime.now();
|
||||
log.warn(">>>>> batchToDate가 없어 현재 시간 사용: {}", successDate);
|
||||
}
|
||||
|
||||
log.info(">>>>> BATCH_LAST_EXECUTION 업데이트 완료");
|
||||
jdbcTemplate.update(
|
||||
String.format("UPDATE %s.BATCH_LAST_EXECUTION SET LAST_SUCCESS_DATE = ?, UPDATED_AT = NOW() WHERE API_KEY = ?", targetSchema),
|
||||
Timestamp.valueOf(successDate), getApiKey()
|
||||
);
|
||||
|
||||
log.info(">>>>> BATCH_LAST_EXECUTION 업데이트 완료 (LAST_SUCCESS_DATE = {})", successDate);
|
||||
return RepeatStatus.FINISHED;
|
||||
};
|
||||
}
|
||||
|
||||
@ -29,6 +29,9 @@ import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
import org.springframework.web.reactive.function.client.WebClient;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Slf4j
|
||||
@Configuration
|
||||
public class StsOperationRangeJobConfig extends BaseMultiStepJobConfig<StsOperationDto, StsOperationEntity> {
|
||||
@ -48,8 +51,6 @@ public class StsOperationRangeJobConfig extends BaseMultiStepJobConfig<StsOperat
|
||||
private String targetSchema;
|
||||
|
||||
protected String getApiKey() {return "STS_OPERATION_IMPORT_API";}
|
||||
protected String getBatchUpdateSql() {
|
||||
return String.format("UPDATE %s.BATCH_LAST_EXECUTION SET LAST_SUCCESS_DATE = NOW(), UPDATED_AT = NOW() WHERE API_KEY = '%s'", targetSchema, getApiKey());}
|
||||
|
||||
|
||||
public StsOperationRangeJobConfig(
|
||||
@ -143,11 +144,25 @@ public class StsOperationRangeJobConfig extends BaseMultiStepJobConfig<StsOperat
|
||||
@Bean
|
||||
public Tasklet stsOperationLastExecutionUpdateTasklet() {
|
||||
return (contribution, chunkContext) -> {
|
||||
log.info(">>>>> 모든 스텝 성공: BATCH_LAST_EXECUTION 업데이트 시작");
|
||||
String toDateStr = chunkContext.getStepContext()
|
||||
.getStepExecution().getJobExecution()
|
||||
.getExecutionContext().getString("batchToDate", null);
|
||||
|
||||
jdbcTemplate.execute(getBatchUpdateSql());
|
||||
LocalDateTime successDate;
|
||||
if (toDateStr != null) {
|
||||
successDate = LocalDateTime.parse(toDateStr);
|
||||
log.info(">>>>> BATCH_LAST_EXECUTION 업데이트 시작 (캡처된 toDate: {})", successDate);
|
||||
} else {
|
||||
successDate = LocalDateTime.now();
|
||||
log.warn(">>>>> batchToDate가 없어 현재 시간 사용: {}", successDate);
|
||||
}
|
||||
|
||||
log.info(">>>>> BATCH_LAST_EXECUTION 업데이트 완료");
|
||||
jdbcTemplate.update(
|
||||
String.format("UPDATE %s.BATCH_LAST_EXECUTION SET LAST_SUCCESS_DATE = ?, UPDATED_AT = NOW() WHERE API_KEY = ?", targetSchema),
|
||||
Timestamp.valueOf(successDate), getApiKey()
|
||||
);
|
||||
|
||||
log.info(">>>>> BATCH_LAST_EXECUTION 업데이트 완료 (LAST_SUCCESS_DATE = {})", successDate);
|
||||
return RepeatStatus.FINISHED;
|
||||
};
|
||||
}
|
||||
|
||||
@ -29,6 +29,9 @@ import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
import org.springframework.web.reactive.function.client.WebClient;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Slf4j
|
||||
@Configuration
|
||||
public class TerminalCallsRangeJobConfig extends BaseMultiStepJobConfig<TerminalCallsDto, TerminalCallsEntity> {
|
||||
@ -48,8 +51,6 @@ public class TerminalCallsRangeJobConfig extends BaseMultiStepJobConfig<Terminal
|
||||
private String targetSchema;
|
||||
|
||||
protected String getApiKey() {return "TERMINAL_CALLS_IMPORT_API";}
|
||||
protected String getBatchUpdateSql() {
|
||||
return String.format("UPDATE %s.BATCH_LAST_EXECUTION SET LAST_SUCCESS_DATE = NOW(), UPDATED_AT = NOW() WHERE API_KEY = '%s'", targetSchema, getApiKey());}
|
||||
|
||||
|
||||
public TerminalCallsRangeJobConfig(
|
||||
@ -143,11 +144,25 @@ public class TerminalCallsRangeJobConfig extends BaseMultiStepJobConfig<Terminal
|
||||
@Bean
|
||||
public Tasklet terminalCallsLastExecutionUpdateTasklet() {
|
||||
return (contribution, chunkContext) -> {
|
||||
log.info(">>>>> 모든 스텝 성공: BATCH_LAST_EXECUTION 업데이트 시작");
|
||||
String toDateStr = chunkContext.getStepContext()
|
||||
.getStepExecution().getJobExecution()
|
||||
.getExecutionContext().getString("batchToDate", null);
|
||||
|
||||
jdbcTemplate.execute(getBatchUpdateSql());
|
||||
LocalDateTime successDate;
|
||||
if (toDateStr != null) {
|
||||
successDate = LocalDateTime.parse(toDateStr);
|
||||
log.info(">>>>> BATCH_LAST_EXECUTION 업데이트 시작 (캡처된 toDate: {})", successDate);
|
||||
} else {
|
||||
successDate = LocalDateTime.now();
|
||||
log.warn(">>>>> batchToDate가 없어 현재 시간 사용: {}", successDate);
|
||||
}
|
||||
|
||||
log.info(">>>>> BATCH_LAST_EXECUTION 업데이트 완료");
|
||||
jdbcTemplate.update(
|
||||
String.format("UPDATE %s.BATCH_LAST_EXECUTION SET LAST_SUCCESS_DATE = ?, UPDATED_AT = NOW() WHERE API_KEY = ?", targetSchema),
|
||||
Timestamp.valueOf(successDate), getApiKey()
|
||||
);
|
||||
|
||||
log.info(">>>>> BATCH_LAST_EXECUTION 업데이트 완료 (LAST_SUCCESS_DATE = {})", successDate);
|
||||
return RepeatStatus.FINISHED;
|
||||
};
|
||||
}
|
||||
|
||||
@ -28,6 +28,9 @@ import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
import org.springframework.web.reactive.function.client.WebClient;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Slf4j
|
||||
@Configuration
|
||||
public class TransitsRangeJobConfig extends BaseMultiStepJobConfig<TransitsDto, TransitsEntity> {
|
||||
@ -47,8 +50,6 @@ public class TransitsRangeJobConfig extends BaseMultiStepJobConfig<TransitsDto,
|
||||
private String targetSchema;
|
||||
|
||||
protected String getApiKey() {return "TRANSITS_IMPORT_API";}
|
||||
protected String getBatchUpdateSql() {
|
||||
return String.format("UPDATE %s.BATCH_LAST_EXECUTION SET LAST_SUCCESS_DATE = NOW(), UPDATED_AT = NOW() WHERE API_KEY = '%s'", targetSchema, getApiKey());}
|
||||
|
||||
public TransitsRangeJobConfig(
|
||||
JobRepository jobRepository,
|
||||
@ -141,11 +142,25 @@ public class TransitsRangeJobConfig extends BaseMultiStepJobConfig<TransitsDto,
|
||||
@Bean
|
||||
public Tasklet transitsLastExecutionUpdateTasklet() {
|
||||
return (contribution, chunkContext) -> {
|
||||
log.info(">>>>> 모든 스텝 성공: BATCH_LAST_EXECUTION 업데이트 시작");
|
||||
String toDateStr = chunkContext.getStepContext()
|
||||
.getStepExecution().getJobExecution()
|
||||
.getExecutionContext().getString("batchToDate", null);
|
||||
|
||||
jdbcTemplate.execute(getBatchUpdateSql());
|
||||
LocalDateTime successDate;
|
||||
if (toDateStr != null) {
|
||||
successDate = LocalDateTime.parse(toDateStr);
|
||||
log.info(">>>>> BATCH_LAST_EXECUTION 업데이트 시작 (캡처된 toDate: {})", successDate);
|
||||
} else {
|
||||
successDate = LocalDateTime.now();
|
||||
log.warn(">>>>> batchToDate가 없어 현재 시간 사용: {}", successDate);
|
||||
}
|
||||
|
||||
log.info(">>>>> BATCH_LAST_EXECUTION 업데이트 완료");
|
||||
jdbcTemplate.update(
|
||||
String.format("UPDATE %s.BATCH_LAST_EXECUTION SET LAST_SUCCESS_DATE = ?, UPDATED_AT = NOW() WHERE API_KEY = ?", targetSchema),
|
||||
Timestamp.valueOf(successDate), getApiKey()
|
||||
);
|
||||
|
||||
log.info(">>>>> BATCH_LAST_EXECUTION 업데이트 완료 (LAST_SUCCESS_DATE = {})", successDate);
|
||||
return RepeatStatus.FINISHED;
|
||||
};
|
||||
}
|
||||
|
||||
@ -32,6 +32,9 @@ import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
import org.springframework.web.reactive.function.client.WebClient;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Slf4j
|
||||
@Configuration
|
||||
public class PscInspectionJobConfig extends BaseMultiStepJobConfig<PscInspectionDto, PscInspectionEntity> {
|
||||
@ -53,11 +56,6 @@ public class PscInspectionJobConfig extends BaseMultiStepJobConfig<PscInspection
|
||||
private int lastExecutionBufferHours;
|
||||
|
||||
protected String getApiKey() {return "PSC_IMPORT_API";}
|
||||
protected String getBatchUpdateSql() {
|
||||
return String.format(
|
||||
"UPDATE %s.BATCH_LAST_EXECUTION SET LAST_SUCCESS_DATE = NOW() - INTERVAL '%d HOURS', UPDATED_AT = NOW() WHERE API_KEY = '%s'",
|
||||
targetSchema, lastExecutionBufferHours, getApiKey());
|
||||
}
|
||||
|
||||
public PscInspectionJobConfig(
|
||||
JobRepository jobRepository,
|
||||
@ -168,11 +166,25 @@ public class PscInspectionJobConfig extends BaseMultiStepJobConfig<PscInspection
|
||||
@Bean
|
||||
public Tasklet pscLastExecutionUpdateTasklet() {
|
||||
return (contribution, chunkContext) -> {
|
||||
log.info(">>>>> 모든 스텝 성공: BATCH_LAST_EXECUTION 업데이트 시작 (버퍼: {}시간)", lastExecutionBufferHours);
|
||||
String toDateStr = chunkContext.getStepContext()
|
||||
.getStepExecution().getJobExecution()
|
||||
.getExecutionContext().getString("batchToDate", null);
|
||||
|
||||
jdbcTemplate.execute(getBatchUpdateSql());
|
||||
LocalDateTime successDate;
|
||||
if (toDateStr != null) {
|
||||
successDate = LocalDateTime.parse(toDateStr).minusHours(lastExecutionBufferHours);
|
||||
log.info(">>>>> BATCH_LAST_EXECUTION 업데이트 시작 (캡처된 toDate - {}시간 버퍼: {})", lastExecutionBufferHours, successDate);
|
||||
} else {
|
||||
successDate = LocalDateTime.now().minusHours(lastExecutionBufferHours);
|
||||
log.warn(">>>>> batchToDate가 없어 현재 시간 - {}시간 버퍼 사용: {}", lastExecutionBufferHours, successDate);
|
||||
}
|
||||
|
||||
log.info(">>>>> BATCH_LAST_EXECUTION 업데이트 완료 (LAST_SUCCESS_DATE = NOW() - {}시간)", lastExecutionBufferHours);
|
||||
jdbcTemplate.update(
|
||||
String.format("UPDATE %s.BATCH_LAST_EXECUTION SET LAST_SUCCESS_DATE = ?, UPDATED_AT = NOW() WHERE API_KEY = ?", targetSchema),
|
||||
Timestamp.valueOf(successDate), getApiKey()
|
||||
);
|
||||
|
||||
log.info(">>>>> BATCH_LAST_EXECUTION 업데이트 완료 (LAST_SUCCESS_DATE = {})", successDate);
|
||||
return RepeatStatus.FINISHED;
|
||||
};
|
||||
}
|
||||
|
||||
@ -30,6 +30,9 @@ import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
import org.springframework.web.reactive.function.client.WebClient;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Slf4j
|
||||
@Configuration
|
||||
public class RiskImportRangeJobConfig extends BaseMultiStepJobConfig<RiskDto, RiskEntity> {
|
||||
@ -51,11 +54,6 @@ public class RiskImportRangeJobConfig extends BaseMultiStepJobConfig<RiskDto, Ri
|
||||
private int lastExecutionBufferHours;
|
||||
|
||||
protected String getApiKey() {return "RISK_IMPORT_API";}
|
||||
protected String getBatchUpdateSql() {
|
||||
return String.format(
|
||||
"UPDATE %s.BATCH_LAST_EXECUTION SET LAST_SUCCESS_DATE = NOW() - INTERVAL '%d HOURS', UPDATED_AT = NOW() WHERE API_KEY = '%s'",
|
||||
targetSchema, lastExecutionBufferHours, getApiKey());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@ -160,11 +158,25 @@ public class RiskImportRangeJobConfig extends BaseMultiStepJobConfig<RiskDto, Ri
|
||||
@Bean
|
||||
public Tasklet riskLastExecutionUpdateTasklet() {
|
||||
return (contribution, chunkContext) -> {
|
||||
log.info(">>>>> 모든 스텝 성공: BATCH_LAST_EXECUTION 업데이트 시작 (버퍼: {}시간)", lastExecutionBufferHours);
|
||||
String toDateStr = chunkContext.getStepContext()
|
||||
.getStepExecution().getJobExecution()
|
||||
.getExecutionContext().getString("batchToDate", null);
|
||||
|
||||
jdbcTemplate.execute(getBatchUpdateSql());
|
||||
LocalDateTime successDate;
|
||||
if (toDateStr != null) {
|
||||
successDate = LocalDateTime.parse(toDateStr).minusHours(lastExecutionBufferHours);
|
||||
log.info(">>>>> BATCH_LAST_EXECUTION 업데이트 시작 (캡처된 toDate - {}시간 버퍼: {})", lastExecutionBufferHours, successDate);
|
||||
} else {
|
||||
successDate = LocalDateTime.now().minusHours(lastExecutionBufferHours);
|
||||
log.warn(">>>>> batchToDate가 없어 현재 시간 - {}시간 버퍼 사용: {}", lastExecutionBufferHours, successDate);
|
||||
}
|
||||
|
||||
log.info(">>>>> BATCH_LAST_EXECUTION 업데이트 완료 (LAST_SUCCESS_DATE = NOW() - {}시간)", lastExecutionBufferHours);
|
||||
jdbcTemplate.update(
|
||||
String.format("UPDATE %s.BATCH_LAST_EXECUTION SET LAST_SUCCESS_DATE = ?, UPDATED_AT = NOW() WHERE API_KEY = ?", targetSchema),
|
||||
Timestamp.valueOf(successDate), getApiKey()
|
||||
);
|
||||
|
||||
log.info(">>>>> BATCH_LAST_EXECUTION 업데이트 완료 (LAST_SUCCESS_DATE = {})", successDate);
|
||||
return RepeatStatus.FINISHED;
|
||||
};
|
||||
}
|
||||
|
||||
@ -15,6 +15,8 @@ import org.springframework.transaction.PlatformTransactionManager;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@ -36,13 +38,6 @@ public class ShipDetailSyncJobConfig {
|
||||
return "SHIP_DETAIL_SYNC_API";
|
||||
}
|
||||
|
||||
// 마지막 실행 일자 업데이트 SQL
|
||||
protected String getBatchUpdateSql() {
|
||||
return String.format(
|
||||
"UPDATE %s.BATCH_LAST_EXECUTION SET LAST_SUCCESS_DATE = NOW() - INTERVAL '%d HOURS', UPDATED_AT = NOW() WHERE API_KEY = '%s'",
|
||||
targetSchema, lastExecutionBufferHours, getApiKey()
|
||||
);
|
||||
}
|
||||
|
||||
public ShipDetailSyncJobConfig(
|
||||
JobRepository jobRepository,
|
||||
@ -85,6 +80,13 @@ public class ShipDetailSyncJobConfig {
|
||||
@Bean
|
||||
public Tasklet shipMasterAndCoreSyncTasklet() {
|
||||
return (contribution, chunkContext) -> {
|
||||
// 배치 시작 시점 캡처 (LastExecutionUpdate에서 사용)
|
||||
LocalDateTime toDate = LocalDateTime.now();
|
||||
chunkContext.getStepContext()
|
||||
.getStepExecution().getJobExecution()
|
||||
.getExecutionContext().put("batchToDate", toDate.toString());
|
||||
log.info(">>>>> batchToDate 캡처: {}", toDate);
|
||||
|
||||
log.info(">>>>> SHIP MASTER & CORE20 동기화 프로시저 호출 시작");
|
||||
|
||||
// PostgreSQL 기준 프로시저 호출 (CALL)
|
||||
@ -142,11 +144,25 @@ public class ShipDetailSyncJobConfig {
|
||||
@Bean
|
||||
public Tasklet shipDetailSyncLastExecutionUpdateTasklet() {
|
||||
return (contribution, chunkContext) -> {
|
||||
log.info(">>>>> 모든 테이블 동기화 성공: BATCH_LAST_EXECUTION 업데이트 시작 (버퍼: {}시간)", lastExecutionBufferHours);
|
||||
String toDateStr = chunkContext.getStepContext()
|
||||
.getStepExecution().getJobExecution()
|
||||
.getExecutionContext().getString("batchToDate", null);
|
||||
|
||||
jdbcTemplate.execute(getBatchUpdateSql());
|
||||
LocalDateTime successDate;
|
||||
if (toDateStr != null) {
|
||||
successDate = LocalDateTime.parse(toDateStr).minusHours(lastExecutionBufferHours);
|
||||
log.info(">>>>> BATCH_LAST_EXECUTION 업데이트 시작 (캡처된 toDate - {}시간 버퍼: {})", lastExecutionBufferHours, successDate);
|
||||
} else {
|
||||
successDate = LocalDateTime.now().minusHours(lastExecutionBufferHours);
|
||||
log.warn(">>>>> batchToDate가 없어 현재 시간 - {}시간 버퍼 사용: {}", lastExecutionBufferHours, successDate);
|
||||
}
|
||||
|
||||
log.info(">>>>> BATCH_LAST_EXECUTION 업데이트 완료 (LAST_SUCCESS_DATE = NOW() - {}시간)", lastExecutionBufferHours);
|
||||
jdbcTemplate.update(
|
||||
String.format("UPDATE %s.BATCH_LAST_EXECUTION SET LAST_SUCCESS_DATE = ?, UPDATED_AT = NOW() WHERE API_KEY = ?", targetSchema),
|
||||
Timestamp.valueOf(successDate), getApiKey()
|
||||
);
|
||||
|
||||
log.info(">>>>> BATCH_LAST_EXECUTION 업데이트 완료 (LAST_SUCCESS_DATE = {})", successDate);
|
||||
return RepeatStatus.FINISHED;
|
||||
};
|
||||
}
|
||||
|
||||
@ -34,6 +34,8 @@ import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
import org.springframework.web.reactive.function.client.WebClient;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@ -73,11 +75,6 @@ public class ShipDetailUpdateJobConfig extends BaseMultiStepJobConfig<ShipDetail
|
||||
private int lastExecutionBufferHours;
|
||||
|
||||
protected String getApiKey() {return "SHIP_DETAIL_UPDATE_API";}
|
||||
protected String getBatchUpdateSql() {
|
||||
return String.format(
|
||||
"UPDATE %s.BATCH_LAST_EXECUTION SET LAST_SUCCESS_DATE = NOW() - INTERVAL '%d HOURS', UPDATED_AT = NOW() WHERE API_KEY = '%s'",
|
||||
targetSchema, lastExecutionBufferHours, getApiKey());
|
||||
}
|
||||
|
||||
|
||||
public ShipDetailUpdateJobConfig(
|
||||
@ -226,11 +223,25 @@ public class ShipDetailUpdateJobConfig extends BaseMultiStepJobConfig<ShipDetail
|
||||
@Bean
|
||||
public Tasklet shipDetailLastExecutionUpdateTasklet() {
|
||||
return (contribution, chunkContext) -> {
|
||||
log.info(">>>>> 모든 스텝 성공: BATCH_LAST_EXECUTION 업데이트 시작 (버퍼: {}시간)", lastExecutionBufferHours);
|
||||
String toDateStr = chunkContext.getStepContext()
|
||||
.getStepExecution().getJobExecution()
|
||||
.getExecutionContext().getString("batchToDate", null);
|
||||
|
||||
jdbcTemplate.execute(getBatchUpdateSql());
|
||||
LocalDateTime successDate;
|
||||
if (toDateStr != null) {
|
||||
successDate = LocalDateTime.parse(toDateStr).minusHours(lastExecutionBufferHours);
|
||||
log.info(">>>>> BATCH_LAST_EXECUTION 업데이트 시작 (캡처된 toDate - {}시간 버퍼: {})", lastExecutionBufferHours, successDate);
|
||||
} else {
|
||||
successDate = LocalDateTime.now().minusHours(lastExecutionBufferHours);
|
||||
log.warn(">>>>> batchToDate가 없어 현재 시간 - {}시간 버퍼 사용: {}", lastExecutionBufferHours, successDate);
|
||||
}
|
||||
|
||||
log.info(">>>>> BATCH_LAST_EXECUTION 업데이트 완료 (LAST_SUCCESS_DATE = NOW() - {}시간)", lastExecutionBufferHours);
|
||||
jdbcTemplate.update(
|
||||
String.format("UPDATE %s.BATCH_LAST_EXECUTION SET LAST_SUCCESS_DATE = ?, UPDATED_AT = NOW() WHERE API_KEY = ?", targetSchema),
|
||||
Timestamp.valueOf(successDate), getApiKey()
|
||||
);
|
||||
|
||||
log.info(">>>>> BATCH_LAST_EXECUTION 업데이트 완료 (LAST_SUCCESS_DATE = {})", successDate);
|
||||
return RepeatStatus.FINISHED;
|
||||
};
|
||||
}
|
||||
|
||||
@ -66,9 +66,12 @@ public class BatchDateService {
|
||||
// 정상 모드: last_success_date ~ now()
|
||||
return repository.findDateRangeByApiKey(apiKey)
|
||||
.map(projection -> {
|
||||
LocalDateTime toDate = LocalDateTime.now();
|
||||
saveToDateToJobContext(toDate);
|
||||
|
||||
Map<String, String> params = new HashMap<>();
|
||||
putDateParams(params, "from", projection.getLastSuccessDate());
|
||||
putDateParams(params, "to", LocalDateTime.now());
|
||||
putDateParams(params, "to", toDate);
|
||||
params.put("shipsCategory", "0");
|
||||
return params;
|
||||
})
|
||||
@ -93,9 +96,12 @@ public class BatchDateService {
|
||||
// 정상 모드: last_success_date ~ now()
|
||||
return repository.findDateRangeByApiKey(apiKey)
|
||||
.map(projection -> {
|
||||
LocalDateTime toDate = LocalDateTime.now();
|
||||
saveToDateToJobContext(toDate);
|
||||
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put(dateParam1, formatToUtc(projection.getLastSuccessDate(), formatter));
|
||||
params.put(dateParam2, formatToUtc(LocalDateTime.now(), formatter));
|
||||
params.put(dateParam2, formatToUtc(toDate, formatter));
|
||||
return params;
|
||||
})
|
||||
.orElseGet(() -> {
|
||||
@ -152,6 +158,23 @@ public class BatchDateService {
|
||||
return params;
|
||||
}
|
||||
|
||||
/**
|
||||
* 배치 시작 시 캡처한 toDate를 JobExecutionContext에 저장
|
||||
* LastExecutionUpdateTasklet에서 이 값을 꺼내 LAST_SUCCESS_DATE로 사용
|
||||
*/
|
||||
private void saveToDateToJobContext(LocalDateTime toDate) {
|
||||
try {
|
||||
StepContext context = StepSynchronizationManager.getContext();
|
||||
if (context != null && context.getStepExecution() != null) {
|
||||
context.getStepExecution().getJobExecution()
|
||||
.getExecutionContext().put("batchToDate", toDate.toString());
|
||||
log.debug("batchToDate JobContext 저장 완료: {}", toDate);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.warn("batchToDate JobContext 저장 실패", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* LocalDateTime에서 연, 월, 일을 추출하여 Map에 담는 헬퍼 메소드
|
||||
*/
|
||||
|
||||
불러오는 중...
Reference in New Issue
Block a user