🔥 Risk&Compliance Current/History 수집 방식 변경

This commit is contained in:
hyojin kim 2026-01-20 10:09:59 +09:00
부모 21368ffaff
커밋 9fed34e1bc
12개의 변경된 파일154개의 추가작업 그리고 236개의 파일을 삭제

파일 보기

@ -91,9 +91,8 @@ public class CompanyComplianceImportRangeJobConfig extends BaseMultiStepJobConfi
protected Job createJobFlow(JobBuilder jobBuilder) {
return jobBuilder
.start(companyComplianceImportRangeStep()) // 1단계 실행
.next(currentCompanyComplianceUpdateStep()) // 2단계 실행 (1단계 실패 실행 )
.next(companyComplianceHistoryValueChangeManageStep()) // 3단계 실행 (2단계 실패 실행 )
.next(companyComplianceLastExecutionUpdateStep()) // 4단계: 모두 완료 , BATCH_LAST_EXECUTION 마지막 성공일자 업데이트
.next(companyComplianceHistoryValueChangeManageStep()) // 2단계 실행 (2단계 실패 실행 )
.next(companyComplianceLastExecutionUpdateStep()) // 3단계: 모두 완료 , BATCH_LAST_EXECUTION 마지막 성공일자 업데이트
.build();
}
@ -131,30 +130,9 @@ public class CompanyComplianceImportRangeJobConfig extends BaseMultiStepJobConfi
public Step companyComplianceImportRangeStep() {
return step();
}
/**
* 2단계: Current Company Compliance 업데이트
*/
@Bean
public Tasklet currentCompanyComplianceUpsertTasklet() {
return (contribution, chunkContext) -> {
log.info(">>>>> Company Compliance Upsert 프로시저 호출 시작");
// PostgreSQL 기준 프로시저 호출 (CALL)
jdbcTemplate.execute("CALL new_snp.upsert_current_company_compliance()");
log.info(">>>>> Company Compliance Upsert 프로시저 호출 완료");
return RepeatStatus.FINISHED;
};
}
@Bean(name = "CurrentCompanyComplianceUpdateStep")
public Step currentCompanyComplianceUpdateStep() {
return new StepBuilder("CurrentCompanyComplianceUpdateStep", jobRepository)
.tasklet(currentCompanyComplianceUpsertTasklet(), transactionManager)
.build();
}
/**
* 3단계: Compliance History Value Change 관리
* 2단계: Compliance History Value Change 관리
*/
@Bean
public Tasklet companyComplianceHistoryValueChangeManageTasklet() {
@ -204,7 +182,7 @@ public class CompanyComplianceImportRangeJobConfig extends BaseMultiStepJobConfi
}
/**
* 4단계: 모든 스텝 성공 배치 실행 로그(날짜) 업데이트
* 3단계: 모든 스텝 성공 배치 실행 로그(날짜) 업데이트
*/
@Bean
public Tasklet companyComplianceLastExecutionUpdateTasklet() {

파일 보기

@ -87,9 +87,8 @@ public class ComplianceImportRangeJobConfig extends BaseMultiStepJobConfig<Compl
protected Job createJobFlow(JobBuilder jobBuilder) {
return jobBuilder
.start(complianceImportRangeStep()) // 1단계 실행
.next(currentComplianceUpdateStep()) // 2단계 실행 (1단계 실패 실행 )
.next(complianceHistoryValueChangeManageStep()) // 3단계 실행 (2단계 실패 실행 )
.next(complianceLastExecutionUpdateStep()) // 4단계: 모두 완료 , BATCH_LAST_EXECUTION 마지막 성공일자 업데이트
.next(complianceHistoryValueChangeManageStep()) // 2단계 실행 (2단계 실패 실행 )
.next(complianceLastExecutionUpdateStep()) // 3단계: 모두 완료 , BATCH_LAST_EXECUTION 마지막 성공일자 업데이트
.build();
}
@ -127,30 +126,9 @@ public class ComplianceImportRangeJobConfig extends BaseMultiStepJobConfig<Compl
public Step complianceImportRangeStep() {
return step();
}
/**
* 2단계: Current Compliance 업데이트
*/
@Bean
public Tasklet currentComplianceUpsertTasklet() {
return (contribution, chunkContext) -> {
log.info(">>>>> Compliance Upsert 프로시저 호출 시작");
// PostgreSQL 기준 프로시저 호출 (CALL)
jdbcTemplate.execute("CALL new_snp.upsert_current_compliance()");
log.info(">>>>> Compliance Upsert 프로시저 호출 완료");
return RepeatStatus.FINISHED;
};
}
@Bean(name = "CurrentComplianceUpdateStep")
public Step currentComplianceUpdateStep() {
return new StepBuilder("CurrentComplianceUpdateStep", jobRepository)
.tasklet(currentComplianceUpsertTasklet(), transactionManager)
.build();
}
/**
* 3단계: Compliance History Value Change 관리
* 2단계: Compliance History Value Change 관리
*/
@Bean
public Tasklet complianceHistoryValueChangeManageTasklet() {
@ -200,7 +178,7 @@ public class ComplianceImportRangeJobConfig extends BaseMultiStepJobConfig<Compl
}
/**
* 4단계: 모든 스텝 성공 배치 실행 로그(날짜) 업데이트
* 3단계: 모든 스텝 성공 배치 실행 로그(날짜) 업데이트
*/
@Bean
public Tasklet complianceLastExecutionUpdateTasklet() {

파일 보기

@ -6,4 +6,5 @@ import java.util.List;
public interface CompanyComplianceRepository {
void saveCompanyComplianceAll(List<CompanyComplianceEntity> items);
void saveCompanyComplianceHistoryAll(List<CompanyComplianceEntity> items);
}

파일 보기

@ -40,15 +40,19 @@ public class CompanyComplianceRepositoryImpl extends BaseJdbcRepository<CompanyC
@Override
protected String getUpdateSql() {
return null;
}
protected String getUpdateSql(String targetTable, String targetIndex) {
return """
INSERT INTO new_snp.tb_company_compliance_hstry(
INSERT INTO new_snp.%s(
owcode, lastupdated,
companyoverallcompliancestatus, companyonaustraliansanctionlist, companyonbessanctionlist, companyoncanadiansanctionlist, companyinofacsanctionedcountry,
companyinfatfjurisdiction, companyoneusanctionlist, companyonofacsanctionlist, companyonofacnonsdnsanctionlist, companyonofacssilist,
companyonswisssanctionlist, companyonuaesanctionlist, companyonunsanctionlist, parentcompanycompliancerisk
)VALUES(
?, ?::timestamp, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?
)ON CONFLICT (owcode, lastupdated)
)ON CONFLICT (%s)
DO UPDATE SET
companyoverallcompliancestatus = EXCLUDED.companyoverallcompliancestatus,
companyonaustraliansanctionlist = EXCLUDED.companyonaustraliansanctionlist,
@ -64,7 +68,7 @@ public class CompanyComplianceRepositoryImpl extends BaseJdbcRepository<CompanyC
companyonuaesanctionlist = EXCLUDED.companyonuaesanctionlist,
companyonunsanctionlist = EXCLUDED.companyonunsanctionlist,
parentcompanycompliancerisk = EXCLUDED.parentcompanycompliancerisk
""";
""".formatted(targetTable, targetIndex);
}
@Override
@ -102,7 +106,24 @@ public class CompanyComplianceRepositoryImpl extends BaseJdbcRepository<CompanyC
if (items == null || items.isEmpty()) {
return;
}
jdbcTemplate.batchUpdate(getUpdateSql(), items, items.size(),
jdbcTemplate.batchUpdate(getUpdateSql("tb_company_compliance_info", "owcode"), items, items.size(),
(ps, entity) -> {
try {
setUpdateParameters(ps, entity);
} catch (Exception e) {
log.error("배치 수정 파라미터 설정 실패", e);
throw new RuntimeException(e);
}
});
log.info("{} 전체 저장 완료: 수정={} 건", getEntityName(), items.size());
}
@Override
public void saveCompanyComplianceHistoryAll(List<CompanyComplianceEntity> items) {
if (items == null || items.isEmpty()) {
return;
}
jdbcTemplate.batchUpdate(getUpdateSql("tb_company_compliance_hstry", "owcode, lastupdated"), items, items.size(),
(ps, entity) -> {
try {
setUpdateParameters(ps, entity);

파일 보기

@ -6,4 +6,5 @@ import java.util.List;
public interface ComplianceRepository {
void saveComplianceAll(List<ComplianceEntity> items);
void saveComplianceHistoryAll(List<ComplianceEntity> items);
}

파일 보기

@ -41,8 +41,12 @@ public class ComplianceRepositoryImpl extends BaseJdbcRepository<ComplianceEntit
@Override
protected String getUpdateSql() {
return null;
}
protected String getUpdateSql(String targetTable, String targetIndex) {
return """
INSERT INTO new_snp.compliance_history (
INSERT INTO new_snp.%s (
lrimoshipno, dateamended, legaloverall, shipbessanctionlist, shipdarkactivityindicator,
shipdetailsnolongermaintained, shipeusanctionlist, shipflagdisputed, shipflagsanctionedcountry,
shiphistoricalflagsanctionedcountry, shipofacnonsdnsanctionlist, shipofacsanctionlist,
@ -58,7 +62,7 @@ public class ComplianceRepositoryImpl extends BaseJdbcRepository<ComplianceEntit
VALUES (
?, ?::timestamptz, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?
)
ON CONFLICT (lrimoshipno, dateamended)
ON CONFLICT (%s)
DO UPDATE SET
legaloverall = EXCLUDED.legaloverall,
shipbessanctionlist = EXCLUDED.shipbessanctionlist,
@ -93,7 +97,7 @@ public class ComplianceRepositoryImpl extends BaseJdbcRepository<ComplianceEntit
shipstspartnernoncompliancelast12m = EXCLUDED.shipstspartnernoncompliancelast12m,
shipswisssanctionlist = EXCLUDED.shipswisssanctionlist,
shipunsanctionlist = EXCLUDED.shipunsanctionlist
""";
""".formatted(targetTable, targetIndex);
}
@Override
@ -151,7 +155,24 @@ public class ComplianceRepositoryImpl extends BaseJdbcRepository<ComplianceEntit
if (items == null || items.isEmpty()) {
return;
}
jdbcTemplate.batchUpdate(getUpdateSql(), items, items.size(),
jdbcTemplate.batchUpdate(getUpdateSql("compliance", "lrimoshipno"), items, items.size(),
(ps, entity) -> {
try {
setUpdateParameters(ps, entity);
} catch (Exception e) {
log.error("배치 수정 파라미터 설정 실패", e);
throw new RuntimeException(e);
}
});
log.info("{} 전체 저장 완료: 수정={} 건", getEntityName(), items.size());
}
@Override
public void saveComplianceHistoryAll(List<ComplianceEntity> items) {
if (items == null || items.isEmpty()) {
return;
}
jdbcTemplate.batchUpdate(getUpdateSql("compliance_history", "lrimoshipno, dateamended"), items, items.size(),
(ps, entity) -> {
try {
setUpdateParameters(ps, entity);

파일 보기

@ -20,5 +20,6 @@ public class CompanyComplianceDataWriter extends BaseWriter<CompanyComplianceEnt
@Override
protected void writeItems(List<CompanyComplianceEntity> items) throws Exception {
complianceRepository.saveCompanyComplianceAll(items);
complianceRepository.saveCompanyComplianceHistoryAll(items);
}
}

파일 보기

@ -19,5 +19,6 @@ public class ComplianceDataWriter extends BaseWriter<ComplianceEntity> {
@Override
protected void writeItems(List<ComplianceEntity> items) throws Exception {
complianceRepository.saveComplianceAll(items);
complianceRepository.saveComplianceHistoryAll(items);
}
}

파일 보기

@ -85,8 +85,7 @@ public class RiskImportRangeJobConfig extends BaseMultiStepJobConfig<RiskDto, Ri
protected Job createJobFlow(JobBuilder jobBuilder) {
return jobBuilder
.start(riskRangeImportStep()) // 1단계: API 데이터 적재
.next(currentRiskUpdateStep()) // 2단계: 프로시저 실행으로 데이터 동기화
.next(riskLastExecutionUpdateStep()) // 3단계: 모두 완료 , BATCH_LAST_EXECUTION 마지막 성공일자 업데이트
.next(riskLastExecutionUpdateStep()) // 2단계: 모두 완료 , BATCH_LAST_EXECUTION 마지막 성공일자 업데이트
.build();
}
@ -122,30 +121,9 @@ public class RiskImportRangeJobConfig extends BaseMultiStepJobConfig<RiskDto, Ri
public Step riskRangeImportStep() {
return step();
}
/**
* 2단계: Current Risk 업데이트
*/
@Bean
public Tasklet currentRiskUpsertTasklet() {
return (contribution, chunkContext) -> {
log.info(">>>>> Risk Upsert 프로시저 호출 시작");
// PostgreSQL 기준 프로시저 호출 (CALL)
jdbcTemplate.execute("CALL new_snp.upsert_current_risk()");
log.info(">>>>> Risk Upsert 프로시저 호출 완료");
return RepeatStatus.FINISHED;
};
}
@Bean(name = "CurrentRiskUpdateStep")
public Step currentRiskUpdateStep() {
return new StepBuilder("CurrentRiskUpdateStep", jobRepository)
.tasklet(currentRiskUpsertTasklet(), transactionManager)
.build();
}
/**
* 3단계: 모든 스텝 성공 배치 실행 로그(날짜) 업데이트
* 2단계: 모든 스텝 성공 배치 실행 로그(날짜) 업데이트
*/
@Bean
public Tasklet riskLastExecutionUpdateTasklet() {

파일 보기

@ -6,4 +6,5 @@ import java.util.List;
public interface RiskRepository {
void saveRiskAll(List<RiskEntity> items);
void saveRiskHistoryAll(List<RiskEntity> items);
}

파일 보기

@ -40,116 +40,76 @@ public class RiskRepositoryImpl extends BaseJdbcRepository<RiskEntity, Long> imp
@Override
protected String getUpdateSql() {
return null;
}
protected String getUpdateSql(String targetTable, String targetIndex) {
return """
INSERT INTO new_snp.risk_history (
lrno, lastupdated, riskdatamaintained, dayssincelastseenonais, dayssincelastseenonaisnarrative,
daysunderais, daysunderaisnarrative, imocorrectonais, imocorrectonaisnarrative, sailingundername,
sailingundernamenarrative, anomalousmessagesfrommmsi, anomalousmessagesfrommmsinarrative,
mostrecentdarkactivity, mostrecentdarkactivitynarrative, portcalls, portcallsnarrative, portrisk,
portrisknarrative, stsoperations, stsoperationsnarrative, driftinghighseas, driftinghighseasnarrative,
riskevents, riskeventnarrative, riskeventnarrativeextended, flagchanges, flagchangenarrative,
flagparismouperformance, flagparismouperformancenarrative, flagtokyomoupeformance, flagtokyomoupeformancenarrative,
flaguscgmouperformance, flaguscgmouperformancenarrative, uscgqualship21, uscgqualship21narrative,
timesincepscinspection, timesincepscinspectionnarrative, pscinspections, pscinspectionnarrative,
pscdefects, pscdefectsnarrative, pscdetentions, pscdetentionsnarrative, currentsmccertificate,
currentsmccertificatenarrative, docchanges, docchangesnarrative, currentclass, currentclassnarrative,
currentclassnarrativeextended, classstatuschanges, classstatuschangesnarrative, pandicoverage,
pandicoveragenarrative, pandicoveragenarrativeextended, namechanges, namechangesnarrative, gbochanges,
gbochangesnarrative, ageofship, ageofshipnarrative, iuufishingviolation, iuufishingnarrative,
draughtchanges, draughtchangesnarrative, mostrecentsanctionedportcall, mostrecentsanctionedportcallnarrative,
singleshipoperation, singleshipoperationnarrative, fleetsafety, fleetsafetynarrative, fleetpsc,
fleetpscnarrative, specialsurveyoverdue, specialsurveyoverduenarrative, ownerunknown, ownerunknownnarrative,
russianportcall, russianportcallnarrative, russianownerregistration, russianownerregistrationnarrative,
russiansts, russianstsnarrative
)
VALUES (
?, ?::timestamptz, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?
)
ON CONFLICT (lrno, lastupdated)
DO UPDATE SET
riskdatamaintained = EXCLUDED.riskdatamaintained,
dayssincelastseenonais = EXCLUDED.dayssincelastseenonais,
dayssincelastseenonaisnarrative = EXCLUDED.dayssincelastseenonaisnarrative,
daysunderais = EXCLUDED.daysunderais,
daysunderaisnarrative = EXCLUDED.daysunderaisnarrative,
imocorrectonais = EXCLUDED.imocorrectonais,
imocorrectonaisnarrative = EXCLUDED.imocorrectonaisnarrative,
sailingundername = EXCLUDED.sailingundername,
sailingundernamenarrative = EXCLUDED.sailingundernamenarrative,
anomalousmessagesfrommmsi = EXCLUDED.anomalousmessagesfrommmsi,
anomalousmessagesfrommmsinarrative = EXCLUDED.anomalousmessagesfrommmsinarrative,
mostrecentdarkactivity = EXCLUDED.mostrecentdarkactivity,
mostrecentdarkactivitynarrative = EXCLUDED.mostrecentdarkactivitynarrative,
portcalls = EXCLUDED.portcalls,
portcallsnarrative = EXCLUDED.portcallsnarrative,
portrisk = EXCLUDED.portrisk,
portrisknarrative = EXCLUDED.portrisknarrative,
stsoperations = EXCLUDED.stsoperations,
stsoperationsnarrative = EXCLUDED.stsoperationsnarrative,
driftinghighseas = EXCLUDED.driftinghighseas,
driftinghighseasnarrative = EXCLUDED.driftinghighseasnarrative,
riskevents = EXCLUDED.riskevents,
riskeventnarrative = EXCLUDED.riskeventnarrative,
riskeventnarrativeextended = EXCLUDED.riskeventnarrativeextended,
flagchanges = EXCLUDED.flagchanges,
flagchangenarrative = EXCLUDED.flagchangenarrative,
flagparismouperformance = EXCLUDED.flagparismouperformance,
flagparismouperformancenarrative = EXCLUDED.flagparismouperformancenarrative,
flagtokyomoupeformance = EXCLUDED.flagtokyomoupeformance,
flagtokyomoupeformancenarrative = EXCLUDED.flagtokyomoupeformancenarrative,
flaguscgmouperformance = EXCLUDED.flaguscgmouperformance,
flaguscgmouperformancenarrative = EXCLUDED.flaguscgmouperformancenarrative,
uscgqualship21 = EXCLUDED.uscgqualship21,
uscgqualship21narrative = EXCLUDED.uscgqualship21narrative,
timesincepscinspection = EXCLUDED.timesincepscinspection,
timesincepscinspectionnarrative = EXCLUDED.timesincepscinspectionnarrative,
pscinspections = EXCLUDED.pscinspections,
pscinspectionnarrative = EXCLUDED.pscinspectionnarrative,
pscdefects = EXCLUDED.pscdefects,
pscdefectsnarrative = EXCLUDED.pscdefectsnarrative,
pscdetentions = EXCLUDED.pscdetentions,
pscdetentionsnarrative = EXCLUDED.pscdetentionsnarrative,
currentsmccertificate = EXCLUDED.currentsmccertificate,
currentsmccertificatenarrative = EXCLUDED.currentsmccertificatenarrative,
docchanges = EXCLUDED.docchanges,
docchangesnarrative = EXCLUDED.docchangesnarrative,
currentclass = EXCLUDED.currentclass,
currentclassnarrative = EXCLUDED.currentclassnarrative,
currentclassnarrativeextended = EXCLUDED.currentclassnarrativeextended,
classstatuschanges = EXCLUDED.classstatuschanges,
classstatuschangesnarrative = EXCLUDED.classstatuschangesnarrative,
pandicoverage = EXCLUDED.pandicoverage,
pandicoveragenarrative = EXCLUDED.pandicoveragenarrative,
pandicoveragenarrativeextended = EXCLUDED.pandicoveragenarrativeextended,
namechanges = EXCLUDED.namechanges,
namechangesnarrative = EXCLUDED.namechangesnarrative,
gbochanges = EXCLUDED.gbochanges,
gbochangesnarrative = EXCLUDED.gbochangesnarrative,
ageofship = EXCLUDED.ageofship,
ageofshipnarrative = EXCLUDED.ageofshipnarrative,
iuufishingviolation = EXCLUDED.iuufishingviolation,
iuufishingnarrative = EXCLUDED.iuufishingnarrative,
draughtchanges = EXCLUDED.draughtchanges,
draughtchangesnarrative = EXCLUDED.draughtchangesnarrative,
mostrecentsanctionedportcall = EXCLUDED.mostrecentsanctionedportcall,
mostrecentsanctionedportcallnarrative = EXCLUDED.mostrecentsanctionedportcallnarrative,
singleshipoperation = EXCLUDED.singleshipoperation,
singleshipoperationnarrative = EXCLUDED.singleshipoperationnarrative,
fleetsafety = EXCLUDED.fleetsafety,
fleetsafetynarrative = EXCLUDED.fleetsafetynarrative,
fleetpsc = EXCLUDED.fleetpsc,
fleetpscnarrative = EXCLUDED.fleetpscnarrative,
specialsurveyoverdue = EXCLUDED.specialsurveyoverdue,
specialsurveyoverduenarrative = EXCLUDED.specialsurveyoverduenarrative,
ownerunknown = EXCLUDED.ownerunknown,
ownerunknownnarrative = EXCLUDED.ownerunknownnarrative,
russianportcall = EXCLUDED.russianportcall,
russianportcallnarrative = EXCLUDED.russianportcallnarrative,
russianownerregistration = EXCLUDED.russianownerregistration,
russianownerregistrationnarrative = EXCLUDED.russianownerregistrationnarrative,
russiansts = EXCLUDED.russiansts,
russianstsnarrative = EXCLUDED.russianstsnarrative
""";
INSERT INTO new_snp.%s (
lrno, lastupdated,
riskdatamaintained, dayssincelastseenonais, daysunderais, imocorrectonais, sailingundername,
anomalousmessagesfrommmsi, mostrecentdarkactivity, portcalls, portrisk, stsoperations,
driftinghighseas, riskevents, flagchanges, flagparismouperformance, flagtokyomoupeformance,
flaguscgmouperformance, uscgqualship21, timesincepscinspection, pscinspections, pscdefects,
pscdetentions, currentsmccertificate, docchanges, currentclass, classstatuschanges,
pandicoverage, namechanges, gbochanges, ageofship, iuufishingviolation,
draughtchanges, mostrecentsanctionedportcall, singleshipoperation, fleetsafety, fleetpsc,
specialsurveyoverdue, ownerunknown, russianportcall, russianownerregistration, russiansts
)
VALUES (
?, ?::timestamptz,
?, ?, ?, ?, ?,
?, ?, ?, ?, ?,
?, ?, ?, ?, ?,
?, ?, ?, ?, ?,
?, ?, ?, ?, ?,
?, ?, ?, ?, ?,
?, ?, ?, ?, ?,
?, ?, ?, ?, ?
)
ON CONFLICT (%s)
DO UPDATE SET
riskdatamaintained = EXCLUDED.riskdatamaintained,
dayssincelastseenonais = EXCLUDED.dayssincelastseenonais,
daysunderais = EXCLUDED.daysunderais,
imocorrectonais = EXCLUDED.imocorrectonais,
sailingundername = EXCLUDED.sailingundername,
anomalousmessagesfrommmsi = EXCLUDED.anomalousmessagesfrommmsi,
mostrecentdarkactivity = EXCLUDED.mostrecentdarkactivity,
portcalls = EXCLUDED.portcalls,
portrisk = EXCLUDED.portrisk,
stsoperations = EXCLUDED.stsoperations,
driftinghighseas = EXCLUDED.driftinghighseas,
riskevents = EXCLUDED.riskevents,
flagchanges = EXCLUDED.flagchanges,
flagparismouperformance = EXCLUDED.flagparismouperformance,
flagtokyomoupeformance = EXCLUDED.flagtokyomoupeformance,
flaguscgmouperformance = EXCLUDED.flaguscgmouperformance,
uscgqualship21 = EXCLUDED.uscgqualship21,
timesincepscinspection = EXCLUDED.timesincepscinspection,
pscinspections = EXCLUDED.pscinspections,
pscdefects = EXCLUDED.pscdefects,
pscdetentions = EXCLUDED.pscdetentions,
currentsmccertificate = EXCLUDED.currentsmccertificate,
docchanges = EXCLUDED.docchanges,
currentclass = EXCLUDED.currentclass,
classstatuschanges = EXCLUDED.classstatuschanges,
pandicoverage = EXCLUDED.pandicoverage,
namechanges = EXCLUDED.namechanges,
gbochanges = EXCLUDED.gbochanges,
ageofship = EXCLUDED.ageofship,
iuufishingviolation = EXCLUDED.iuufishingviolation,
draughtchanges = EXCLUDED.draughtchanges,
mostrecentsanctionedportcall = EXCLUDED.mostrecentsanctionedportcall,
singleshipoperation = EXCLUDED.singleshipoperation,
fleetsafety = EXCLUDED.fleetsafety,
fleetpsc = EXCLUDED.fleetpsc,
specialsurveyoverdue = EXCLUDED.specialsurveyoverdue,
ownerunknown = EXCLUDED.ownerunknown,
russianportcall = EXCLUDED.russianportcall,
russianownerregistration = EXCLUDED.russianownerregistration,
russiansts = EXCLUDED.russiansts
""".formatted(targetTable, targetIndex);
}
@Override
@ -164,86 +124,44 @@ public class RiskRepositoryImpl extends BaseJdbcRepository<RiskEntity, Long> imp
ps.setString(idx++, entity.getLastUpdated());
ps.setObject(idx++, entity.getRiskDataMaintained(), java.sql.Types.INTEGER);
ps.setObject(idx++, entity.getDaysSinceLastSeenOnAIS(), java.sql.Types.INTEGER);
ps.setString(idx++, entity.getDaysSinceLastSeenOnAISNarrative());
ps.setObject(idx++, entity.getDaysUnderAIS(), java.sql.Types.INTEGER);
ps.setString(idx++, entity.getDaysUnderAISNarrative());
ps.setObject(idx++, entity.getImoCorrectOnAIS(), java.sql.Types.INTEGER);
ps.setString(idx++, entity.getImoCorrectOnAISNarrative());
ps.setObject(idx++, entity.getSailingUnderName(), java.sql.Types.INTEGER);
ps.setString(idx++, entity.getSailingUnderNameNarrative());
ps.setObject(idx++, entity.getAnomalousMessagesFromMMSI(), java.sql.Types.INTEGER);
ps.setString(idx++, entity.getAnomalousMessagesFromMMSINarrative());
ps.setObject(idx++, entity.getMostRecentDarkActivity(), java.sql.Types.INTEGER);
ps.setString(idx++, entity.getMostRecentDarkActivityNarrative());
ps.setObject(idx++, entity.getPortCalls(), java.sql.Types.INTEGER);
ps.setString(idx++, entity.getPortCallsNarrative());
ps.setObject(idx++, entity.getPortRisk(), java.sql.Types.INTEGER);
ps.setString(idx++, entity.getPortRiskNarrative());
ps.setObject(idx++, entity.getStsOperations(), java.sql.Types.INTEGER);
ps.setString(idx++, entity.getStsOperationsNarrative());
ps.setObject(idx++, entity.getDriftingHighSeas(), java.sql.Types.INTEGER);
ps.setString(idx++, entity.getDriftingHighSeasNarrative());
ps.setObject(idx++, entity.getRiskEvents(), java.sql.Types.INTEGER);
ps.setString(idx++, entity.getRiskEventNarrative());
ps.setString(idx++, entity.getRiskEventNarrativeExtended());
ps.setObject(idx++, entity.getFlagChanges(), java.sql.Types.INTEGER);
ps.setString(idx++, entity.getFlagChangeNarrative());
ps.setObject(idx++, entity.getFlagParisMOUPerformance(), java.sql.Types.INTEGER);
ps.setString(idx++, entity.getFlagParisMOUPerformanceNarrative());
ps.setObject(idx++, entity.getFlagTokyoMOUPeformance(), java.sql.Types.INTEGER);
ps.setString(idx++, entity.getFlagTokyoMOUPeformanceNarrative());
ps.setObject(idx++, entity.getFlagUSCGMOUPerformance(), java.sql.Types.INTEGER);
ps.setString(idx++, entity.getFlagUSCGMOUPerformanceNarrative());
ps.setObject(idx++, entity.getUscgQualship21(), java.sql.Types.INTEGER);
ps.setString(idx++, entity.getUscgQualship21Narrative());
ps.setObject(idx++, entity.getTimeSincePSCInspection(), java.sql.Types.INTEGER);
ps.setString(idx++, entity.getTimeSincePSCInspectionNarrative());
ps.setObject(idx++, entity.getPscInspections(), java.sql.Types.INTEGER);
ps.setString(idx++, entity.getPscInspectionNarrative());
ps.setObject(idx++, entity.getPscDefects(), java.sql.Types.INTEGER);
ps.setString(idx++, entity.getPscDefectsNarrative());
ps.setObject(idx++, entity.getPscDetentions(), java.sql.Types.INTEGER);
ps.setString(idx++, entity.getPscDetentionsNarrative());
ps.setObject(idx++, entity.getCurrentSMCCertificate(), java.sql.Types.INTEGER);
ps.setString(idx++, entity.getCurrentSMCCertificateNarrative());
ps.setObject(idx++, entity.getDocChanges(), java.sql.Types.INTEGER);
ps.setString(idx++, entity.getDocChangesNarrative());
ps.setObject(idx++, entity.getCurrentClass(), java.sql.Types.INTEGER);
ps.setString(idx++, entity.getCurrentClassNarrative());
ps.setString(idx++, entity.getCurrentClassNarrativeExtended());
ps.setObject(idx++, entity.getClassStatusChanges(), java.sql.Types.INTEGER);
ps.setString(idx++, entity.getClassStatusChangesNarrative());
ps.setObject(idx++, entity.getPandICoverage(), java.sql.Types.INTEGER);
ps.setString(idx++, entity.getPandICoverageNarrative());
ps.setString(idx++, entity.getPandICoverageNarrativeExtended());
ps.setObject(idx++, entity.getNameChanges(), java.sql.Types.INTEGER);
ps.setString(idx++, entity.getNameChangesNarrative());
ps.setObject(idx++, entity.getGboChanges(), java.sql.Types.INTEGER);
ps.setString(idx++, entity.getGboChangesNarrative());
ps.setObject(idx++, entity.getAgeOfShip(), java.sql.Types.INTEGER);
ps.setString(idx++, entity.getAgeofShipNarrative());
ps.setObject(idx++, entity.getIuuFishingViolation(), java.sql.Types.INTEGER);
ps.setString(idx++, entity.getIuuFishingNarrative());
ps.setObject(idx++, entity.getDraughtChanges(), java.sql.Types.INTEGER);
ps.setString(idx++, entity.getDraughtChangesNarrative());
ps.setObject(idx++, entity.getMostRecentSanctionedPortCall(), java.sql.Types.INTEGER);
ps.setString(idx++, entity.getMostRecentSanctionedPortCallNarrative());
ps.setObject(idx++, entity.getSingleShipOperation(), java.sql.Types.INTEGER);
ps.setString(idx++, entity.getSingleShipOperationNarrative());
ps.setObject(idx++, entity.getFleetSafety(), java.sql.Types.INTEGER);
ps.setString(idx++, entity.getFleetSafetyNarrative());
ps.setObject(idx++, entity.getFleetPSC(), java.sql.Types.INTEGER);
ps.setString(idx++, entity.getFleetPSCNarrative());
ps.setObject(idx++, entity.getSpecialSurveyOverdue(), java.sql.Types.INTEGER);
ps.setString(idx++, entity.getSpecialSurveyOverdueNarrative());
ps.setObject(idx++, entity.getOwnerUnknown(), java.sql.Types.INTEGER);
ps.setString(idx++, entity.getOwnerUnknownNarrative());
ps.setObject(idx++, entity.getRussianPortCall(), java.sql.Types.INTEGER);
ps.setString(idx++, entity.getRussianPortCallNarrative());
ps.setObject(idx++, entity.getRussianOwnerRegistration(), java.sql.Types.INTEGER);
ps.setString(idx++, entity.getRussianOwnerRegistrationNarrative());
ps.setObject(idx++, entity.getRussianSTS(), java.sql.Types.INTEGER);
ps.setString(idx++, entity.getRussianSTSNarrative());
}
@Override
@ -256,7 +174,25 @@ public class RiskRepositoryImpl extends BaseJdbcRepository<RiskEntity, Long> imp
if (items == null || items.isEmpty()) {
return;
}
jdbcTemplate.batchUpdate(getUpdateSql(), items, items.size(),
jdbcTemplate.batchUpdate(getUpdateSql("risk", "lrno"), items, items.size(),
(ps, entity) -> {
try {
setUpdateParameters(ps, entity);
} catch (Exception e) {
log.error("배치 수정 파라미터 설정 실패", e);
throw new RuntimeException(e);
}
});
log.info("{} 전체 저장 완료: 수정={} 건", getEntityName(), items.size());
}
@Override
public void saveRiskHistoryAll(List<RiskEntity> items) {
if (items == null || items.isEmpty()) {
return;
}
jdbcTemplate.batchUpdate(getUpdateSql("risk_history", "lrno, lastupdated"), items, items.size(),
(ps, entity) -> {
try {
setUpdateParameters(ps, entity);

파일 보기

@ -19,5 +19,6 @@ public class RiskDataWriter extends BaseWriter<RiskEntity> {
@Override
protected void writeItems(List<RiskEntity> items) throws Exception {
riskRepository.saveRiskAll(items);
riskRepository.saveRiskHistoryAll(items);
}
}