🔥 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) { protected Job createJobFlow(JobBuilder jobBuilder) {
return jobBuilder return jobBuilder
.start(companyComplianceImportRangeStep()) // 1단계 실행 .start(companyComplianceImportRangeStep()) // 1단계 실행
.next(currentCompanyComplianceUpdateStep()) // 2단계 실행 (1단계 실패 실행 ) .next(companyComplianceHistoryValueChangeManageStep()) // 2단계 실행 (2단계 실패 실행 )
.next(companyComplianceHistoryValueChangeManageStep()) // 3단계 실행 (2단계 실패 실행 ) .next(companyComplianceLastExecutionUpdateStep()) // 3단계: 모두 완료 , BATCH_LAST_EXECUTION 마지막 성공일자 업데이트
.next(companyComplianceLastExecutionUpdateStep()) // 4단계: 모두 완료 , BATCH_LAST_EXECUTION 마지막 성공일자 업데이트
.build(); .build();
} }
@ -131,30 +130,9 @@ public class CompanyComplianceImportRangeJobConfig extends BaseMultiStepJobConfi
public Step companyComplianceImportRangeStep() { public Step companyComplianceImportRangeStep() {
return step(); 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 @Bean
public Tasklet companyComplianceHistoryValueChangeManageTasklet() { public Tasklet companyComplianceHistoryValueChangeManageTasklet() {
@ -204,7 +182,7 @@ public class CompanyComplianceImportRangeJobConfig extends BaseMultiStepJobConfi
} }
/** /**
* 4단계: 모든 스텝 성공 배치 실행 로그(날짜) 업데이트 * 3단계: 모든 스텝 성공 배치 실행 로그(날짜) 업데이트
*/ */
@Bean @Bean
public Tasklet companyComplianceLastExecutionUpdateTasklet() { public Tasklet companyComplianceLastExecutionUpdateTasklet() {

파일 보기

@ -87,9 +87,8 @@ public class ComplianceImportRangeJobConfig extends BaseMultiStepJobConfig<Compl
protected Job createJobFlow(JobBuilder jobBuilder) { protected Job createJobFlow(JobBuilder jobBuilder) {
return jobBuilder return jobBuilder
.start(complianceImportRangeStep()) // 1단계 실행 .start(complianceImportRangeStep()) // 1단계 실행
.next(currentComplianceUpdateStep()) // 2단계 실행 (1단계 실패 실행 ) .next(complianceHistoryValueChangeManageStep()) // 2단계 실행 (2단계 실패 실행 )
.next(complianceHistoryValueChangeManageStep()) // 3단계 실행 (2단계 실패 실행 ) .next(complianceLastExecutionUpdateStep()) // 3단계: 모두 완료 , BATCH_LAST_EXECUTION 마지막 성공일자 업데이트
.next(complianceLastExecutionUpdateStep()) // 4단계: 모두 완료 , BATCH_LAST_EXECUTION 마지막 성공일자 업데이트
.build(); .build();
} }
@ -127,30 +126,9 @@ public class ComplianceImportRangeJobConfig extends BaseMultiStepJobConfig<Compl
public Step complianceImportRangeStep() { public Step complianceImportRangeStep() {
return step(); 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 @Bean
public Tasklet complianceHistoryValueChangeManageTasklet() { public Tasklet complianceHistoryValueChangeManageTasklet() {
@ -200,7 +178,7 @@ public class ComplianceImportRangeJobConfig extends BaseMultiStepJobConfig<Compl
} }
/** /**
* 4단계: 모든 스텝 성공 배치 실행 로그(날짜) 업데이트 * 3단계: 모든 스텝 성공 배치 실행 로그(날짜) 업데이트
*/ */
@Bean @Bean
public Tasklet complianceLastExecutionUpdateTasklet() { public Tasklet complianceLastExecutionUpdateTasklet() {

파일 보기

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

파일 보기

@ -40,15 +40,19 @@ public class CompanyComplianceRepositoryImpl extends BaseJdbcRepository<CompanyC
@Override @Override
protected String getUpdateSql() { protected String getUpdateSql() {
return null;
}
protected String getUpdateSql(String targetTable, String targetIndex) {
return """ return """
INSERT INTO new_snp.tb_company_compliance_hstry( INSERT INTO new_snp.%s(
owcode, lastupdated, owcode, lastupdated,
companyoverallcompliancestatus, companyonaustraliansanctionlist, companyonbessanctionlist, companyoncanadiansanctionlist, companyinofacsanctionedcountry, companyoverallcompliancestatus, companyonaustraliansanctionlist, companyonbessanctionlist, companyoncanadiansanctionlist, companyinofacsanctionedcountry,
companyinfatfjurisdiction, companyoneusanctionlist, companyonofacsanctionlist, companyonofacnonsdnsanctionlist, companyonofacssilist, companyinfatfjurisdiction, companyoneusanctionlist, companyonofacsanctionlist, companyonofacnonsdnsanctionlist, companyonofacssilist,
companyonswisssanctionlist, companyonuaesanctionlist, companyonunsanctionlist, parentcompanycompliancerisk companyonswisssanctionlist, companyonuaesanctionlist, companyonunsanctionlist, parentcompanycompliancerisk
)VALUES( )VALUES(
?, ?::timestamp, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? ?, ?::timestamp, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?
)ON CONFLICT (owcode, lastupdated) )ON CONFLICT (%s)
DO UPDATE SET DO UPDATE SET
companyoverallcompliancestatus = EXCLUDED.companyoverallcompliancestatus, companyoverallcompliancestatus = EXCLUDED.companyoverallcompliancestatus,
companyonaustraliansanctionlist = EXCLUDED.companyonaustraliansanctionlist, companyonaustraliansanctionlist = EXCLUDED.companyonaustraliansanctionlist,
@ -64,7 +68,7 @@ public class CompanyComplianceRepositoryImpl extends BaseJdbcRepository<CompanyC
companyonuaesanctionlist = EXCLUDED.companyonuaesanctionlist, companyonuaesanctionlist = EXCLUDED.companyonuaesanctionlist,
companyonunsanctionlist = EXCLUDED.companyonunsanctionlist, companyonunsanctionlist = EXCLUDED.companyonunsanctionlist,
parentcompanycompliancerisk = EXCLUDED.parentcompanycompliancerisk parentcompanycompliancerisk = EXCLUDED.parentcompanycompliancerisk
"""; """.formatted(targetTable, targetIndex);
} }
@Override @Override
@ -102,7 +106,24 @@ public class CompanyComplianceRepositoryImpl extends BaseJdbcRepository<CompanyC
if (items == null || items.isEmpty()) { if (items == null || items.isEmpty()) {
return; 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) -> { (ps, entity) -> {
try { try {
setUpdateParameters(ps, entity); setUpdateParameters(ps, entity);

파일 보기

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

파일 보기

@ -41,8 +41,12 @@ public class ComplianceRepositoryImpl extends BaseJdbcRepository<ComplianceEntit
@Override @Override
protected String getUpdateSql() { protected String getUpdateSql() {
return null;
}
protected String getUpdateSql(String targetTable, String targetIndex) {
return """ return """
INSERT INTO new_snp.compliance_history ( INSERT INTO new_snp.%s (
lrimoshipno, dateamended, legaloverall, shipbessanctionlist, shipdarkactivityindicator, lrimoshipno, dateamended, legaloverall, shipbessanctionlist, shipdarkactivityindicator,
shipdetailsnolongermaintained, shipeusanctionlist, shipflagdisputed, shipflagsanctionedcountry, shipdetailsnolongermaintained, shipeusanctionlist, shipflagdisputed, shipflagsanctionedcountry,
shiphistoricalflagsanctionedcountry, shipofacnonsdnsanctionlist, shipofacsanctionlist, shiphistoricalflagsanctionedcountry, shipofacnonsdnsanctionlist, shipofacsanctionlist,
@ -58,7 +62,7 @@ public class ComplianceRepositoryImpl extends BaseJdbcRepository<ComplianceEntit
VALUES ( VALUES (
?, ?::timestamptz, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? ?, ?::timestamptz, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?
) )
ON CONFLICT (lrimoshipno, dateamended) ON CONFLICT (%s)
DO UPDATE SET DO UPDATE SET
legaloverall = EXCLUDED.legaloverall, legaloverall = EXCLUDED.legaloverall,
shipbessanctionlist = EXCLUDED.shipbessanctionlist, shipbessanctionlist = EXCLUDED.shipbessanctionlist,
@ -93,7 +97,7 @@ public class ComplianceRepositoryImpl extends BaseJdbcRepository<ComplianceEntit
shipstspartnernoncompliancelast12m = EXCLUDED.shipstspartnernoncompliancelast12m, shipstspartnernoncompliancelast12m = EXCLUDED.shipstspartnernoncompliancelast12m,
shipswisssanctionlist = EXCLUDED.shipswisssanctionlist, shipswisssanctionlist = EXCLUDED.shipswisssanctionlist,
shipunsanctionlist = EXCLUDED.shipunsanctionlist shipunsanctionlist = EXCLUDED.shipunsanctionlist
"""; """.formatted(targetTable, targetIndex);
} }
@Override @Override
@ -151,7 +155,24 @@ public class ComplianceRepositoryImpl extends BaseJdbcRepository<ComplianceEntit
if (items == null || items.isEmpty()) { if (items == null || items.isEmpty()) {
return; 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) -> { (ps, entity) -> {
try { try {
setUpdateParameters(ps, entity); setUpdateParameters(ps, entity);

파일 보기

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

파일 보기

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

파일 보기

@ -85,8 +85,7 @@ public class RiskImportRangeJobConfig extends BaseMultiStepJobConfig<RiskDto, Ri
protected Job createJobFlow(JobBuilder jobBuilder) { protected Job createJobFlow(JobBuilder jobBuilder) {
return jobBuilder return jobBuilder
.start(riskRangeImportStep()) // 1단계: API 데이터 적재 .start(riskRangeImportStep()) // 1단계: API 데이터 적재
.next(currentRiskUpdateStep()) // 2단계: 프로시저 실행으로 데이터 동기화 .next(riskLastExecutionUpdateStep()) // 2단계: 모두 완료 , BATCH_LAST_EXECUTION 마지막 성공일자 업데이트
.next(riskLastExecutionUpdateStep()) // 3단계: 모두 완료 , BATCH_LAST_EXECUTION 마지막 성공일자 업데이트
.build(); .build();
} }
@ -122,30 +121,9 @@ public class RiskImportRangeJobConfig extends BaseMultiStepJobConfig<RiskDto, Ri
public Step riskRangeImportStep() { public Step riskRangeImportStep() {
return step(); 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 @Bean
public Tasklet riskLastExecutionUpdateTasklet() { public Tasklet riskLastExecutionUpdateTasklet() {

파일 보기

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

파일 보기

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

파일 보기

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