refactor: 동기화 현황 화면 노출 테이블 목록 정리 (#11)
- source-schema.tables.ship-001 (tb_ship_default_info) 제거 - target-schema.tables.ship-002 (tb_ship_main_info) 제거 - target ship-001 → ship-002로 키 변경 (source와 매핑 일치) - source risk-compliance 키 변경: 002→003, 003→006 (target과 매핑 일치) - ShipDataWriter: saveShipMainInfo 호출 제거 - ShipRepository/Impl: saveShipMainInfo, bindShipMainInfo 제거 - ShipDataSql: getShipMainInfoUpsertSql 제거 - SyncStatusService: source-target 양쪽 매핑된 테이블만 조회 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
부모
d55fba7226
커밋
174219ce13
@ -13,9 +13,6 @@ public class TableMetaInfo {
|
||||
*/
|
||||
|
||||
// Ship Tables
|
||||
@Value("${app.batch.source-schema.tables.ship-001}")
|
||||
public String sourceShipData;
|
||||
|
||||
@Value("${app.batch.source-schema.tables.ship-002}")
|
||||
public String sourceShipDetailData;
|
||||
|
||||
@ -158,10 +155,10 @@ public class TableMetaInfo {
|
||||
@Value("${app.batch.source-schema.tables.risk-compliance-001}")
|
||||
public String sourceRisk;
|
||||
|
||||
@Value("${app.batch.source-schema.tables.risk-compliance-002}")
|
||||
@Value("${app.batch.source-schema.tables.risk-compliance-003}")
|
||||
public String sourceCompliance;
|
||||
|
||||
@Value("${app.batch.source-schema.tables.risk-compliance-003}")
|
||||
@Value("${app.batch.source-schema.tables.risk-compliance-006}")
|
||||
public String sourceTbCompanyComplianceInfo;
|
||||
|
||||
|
||||
@ -172,11 +169,8 @@ public class TableMetaInfo {
|
||||
*/
|
||||
|
||||
// Ship Tables
|
||||
@Value("${app.batch.target-schema.tables.ship-001}")
|
||||
public String targetTbShipInfoMst;
|
||||
|
||||
@Value("${app.batch.target-schema.tables.ship-002}")
|
||||
public String targetTbShipMainInfo;
|
||||
public String targetTbShipInfoMst;
|
||||
|
||||
@Value("${app.batch.target-schema.tables.ship-003}")
|
||||
public String targetTbShipAddInfo;
|
||||
|
||||
@ -142,59 +142,6 @@ public class ShipDataSql {
|
||||
""".formatted(TARGET_SCHEMA, targetTable);
|
||||
}
|
||||
|
||||
public static String getShipMainInfoUpsertSql(String targetTable) {
|
||||
return """
|
||||
INSERT INTO %s.%s (
|
||||
crt_dt, creatr_id,
|
||||
imo_no, mmsi_no, ship_nm, clsgn_no, country_nm,
|
||||
ship_reg_hrbr, clfic_asctn_nm, ship_knd_lv_five, ship_knd_dtl_lv_five,
|
||||
ship_build_yy, shpyrd_nm, ship_whlnth, ship_molbth, ship_depth, ship_draft,
|
||||
ship_total_ton, dwt, cntnr_units, svc_crspd, main_engine_fom,
|
||||
ship_status, ship_operator, ship_country_cd, ship_knd_lv_two, cargo_type,
|
||||
last_mdfcn_dt
|
||||
)
|
||||
VALUES (
|
||||
CURRENT_TIMESTAMP, 'SYSTEM',
|
||||
?, ?, ?, ?, ?,
|
||||
?, ?, ?, ?, ?,
|
||||
?, ?, ?, ?, ?,
|
||||
?, ?, ?, ?, ?,
|
||||
?, ?, ?, ?, ?,
|
||||
?
|
||||
)
|
||||
ON CONFLICT (imo_no)
|
||||
DO UPDATE SET
|
||||
mdfcn_dt = CURRENT_TIMESTAMP,
|
||||
mdfr_id = 'SYSTEM',
|
||||
mmsi_no = EXCLUDED.mmsi_no,
|
||||
ship_nm = EXCLUDED.ship_nm,
|
||||
clsgn_no = EXCLUDED.clsgn_no,
|
||||
country_nm = EXCLUDED.country_nm,
|
||||
ship_reg_hrbr = EXCLUDED.ship_reg_hrbr,
|
||||
clfic_asctn_nm = EXCLUDED.clfic_asctn_nm,
|
||||
ship_knd_lv_five = EXCLUDED.ship_knd_lv_five,
|
||||
ship_knd_dtl_lv_five = EXCLUDED.ship_knd_dtl_lv_five,
|
||||
ship_build_yy = EXCLUDED.ship_build_yy,
|
||||
shpyrd_nm = EXCLUDED.shpyrd_nm,
|
||||
ship_whlnth = EXCLUDED.ship_whlnth,
|
||||
ship_molbth = EXCLUDED.ship_molbth,
|
||||
ship_depth = EXCLUDED.ship_depth,
|
||||
ship_draft = EXCLUDED.ship_draft,
|
||||
ship_total_ton = EXCLUDED.ship_total_ton,
|
||||
dwt = EXCLUDED.dwt,
|
||||
cntnr_units = EXCLUDED.cntnr_units,
|
||||
svc_crspd = EXCLUDED.svc_crspd,
|
||||
main_engine_fom = EXCLUDED.main_engine_fom,
|
||||
ship_status = EXCLUDED.ship_status,
|
||||
ship_operator = EXCLUDED.ship_operator,
|
||||
ship_country_cd = EXCLUDED.ship_country_cd,
|
||||
ship_knd_lv_two = EXCLUDED.ship_knd_lv_two,
|
||||
cargo_type = EXCLUDED.cargo_type,
|
||||
last_mdfcn_dt = EXCLUDED.last_mdfcn_dt;
|
||||
""".formatted(TARGET_SCHEMA, targetTable);
|
||||
}
|
||||
|
||||
|
||||
public static String getShipAddInfoUpsertSql(String targetTable) {
|
||||
return """
|
||||
INSERT INTO %s.%s (
|
||||
|
||||
@ -35,7 +35,6 @@ import java.util.List;
|
||||
*/
|
||||
public interface ShipRepository {
|
||||
void saveShipInfoMst(List<ShipInfoMstEntity> shipInfoMstEntityList);
|
||||
void saveShipMainInfo(List<ShipInfoMstEntity> shipInfoMstEntityList);
|
||||
void saveShipAddInfo(List<ShipAddInfoEntity> shipAddInfoEntityList);
|
||||
void saveBareboatCharterHistory(List<BareboatCharterHistoryEntity> bareboatCharterHistoryEntityList);
|
||||
void saveCallsignAndMmsiHistory(List<CallsignAndMmsiHistoryEntity> callsignAndMmsiHistoryEntityList);
|
||||
|
||||
@ -96,23 +96,6 @@ public class ShipRepositoryImpl extends MultiDataSourceJdbcRepository<ShipInfoMs
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveShipMainInfo(List<ShipInfoMstEntity> shipInfoMstEntityList) {
|
||||
String core20Sql = ShipDataSql.getShipMainInfoUpsertSql(tableMetaInfo.targetTbShipMainInfo);
|
||||
if (shipInfoMstEntityList == null || shipInfoMstEntityList.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
batchJdbcTemplate.batchUpdate(core20Sql, shipInfoMstEntityList, shipInfoMstEntityList.size(),
|
||||
(ps, entity) -> {
|
||||
try {
|
||||
bindShipMainInfo(ps, (ShipInfoMstEntity) entity);
|
||||
} catch (Exception e) {
|
||||
log.error("배치 삽입 파라미터 설정 실패", e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void bindShipInfoMst(PreparedStatement pstmt, ShipInfoMstEntity entity) throws Exception {
|
||||
int idx = 1;
|
||||
pstmt.setString(idx++, entity.getDatasetVer());
|
||||
@ -201,36 +184,6 @@ public class ShipRepositoryImpl extends MultiDataSourceJdbcRepository<ShipInfoMs
|
||||
pstmt.setString(idx++, entity.getLastMdfcnDt());
|
||||
}
|
||||
|
||||
public void bindShipMainInfo(PreparedStatement pstmt, ShipInfoMstEntity entity) throws Exception {
|
||||
int idx = 1;
|
||||
pstmt.setString(idx++, entity.getImoNo());
|
||||
pstmt.setString(idx++, entity.getMmsiNo());
|
||||
pstmt.setString(idx++, entity.getShipNm());
|
||||
pstmt.setString(idx++, entity.getClsgnNo());
|
||||
pstmt.setString(idx++, entity.getShipNtnlty());
|
||||
pstmt.setString(idx++, entity.getLoadPort());
|
||||
pstmt.setString(idx++, entity.getClfic());
|
||||
pstmt.setString(idx++, entity.getShipTypeLvFive());
|
||||
pstmt.setString(idx++, entity.getShipTypeLvFiveDtldType());
|
||||
pstmt.setString(idx++, entity.getBuildYy());
|
||||
pstmt.setString(idx++, entity.getShpyrd());
|
||||
pstmt.setObject(idx++, entity.getWhlnthLoa(), Types.DOUBLE);
|
||||
pstmt.setObject(idx++, entity.getFormnBreadth(), Types.DOUBLE);
|
||||
pstmt.setObject(idx++, entity.getDepth(), Types.DOUBLE);
|
||||
pstmt.setObject(idx++, entity.getDraft(), Types.DOUBLE);
|
||||
pstmt.setString(idx++, entity.getGt());
|
||||
pstmt.setString(idx++, entity.getDwt());
|
||||
pstmt.setString(idx++, entity.getTeuCnt());
|
||||
pstmt.setObject(idx++, entity.getSvcSpd(), Types.DOUBLE);
|
||||
pstmt.setString(idx++, entity.getMainEngineType());
|
||||
pstmt.setString(idx++, entity.getShipStatus());
|
||||
pstmt.setString(idx++, entity.getOperator());
|
||||
pstmt.setString(idx++, entity.getNtnltyCd());
|
||||
pstmt.setString(idx++, entity.getShipTypeLvTwo());
|
||||
pstmt.setString(idx++, entity.getShipTypeLvThr());
|
||||
pstmt.setString(idx++, entity.getLastMdfcnDt());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveShipAddInfo(List<ShipAddInfoEntity> shipAddInfoEntityList) {
|
||||
String sql = ShipDataSql.getShipAddInfoUpsertSql(tableMetaInfo.targetTbShipAddInfo);
|
||||
|
||||
@ -22,6 +22,5 @@ public class ShipDataWriter extends BaseChunkedWriter<ShipInfoMstEntity> {
|
||||
return;
|
||||
}
|
||||
shipRepository.saveShipInfoMst(items); // 선박_정보_마스터 [ID: S&P-SHIP-001]
|
||||
shipRepository.saveShipMainInfo(items); // 선박_주요_정보 [ID: S&P-SHIP-002]
|
||||
}
|
||||
}
|
||||
|
||||
@ -70,11 +70,13 @@ public class SyncStatusService {
|
||||
ExecutorService executor = Executors.newFixedThreadPool(
|
||||
Math.min(sourceTables.size(), 10));
|
||||
|
||||
// source와 target 양쪽 모두 매핑된 테이블만 조회
|
||||
List<CompletableFuture<SyncTableStatus>> futures = sourceTables.entrySet().stream()
|
||||
.filter(entry -> targetTables.containsKey(entry.getKey()))
|
||||
.map(entry -> CompletableFuture.supplyAsync(() -> {
|
||||
String tableKey = entry.getKey();
|
||||
String sourceTable = entry.getValue();
|
||||
String targetTable = targetTables.getOrDefault(tableKey, "");
|
||||
String targetTable = targetTables.get(tableKey);
|
||||
|
||||
try {
|
||||
return queryTableStatus(tableKey, sourceTable, targetTable);
|
||||
|
||||
@ -107,7 +107,6 @@ app:
|
||||
source-schema:
|
||||
name: std_snp_data
|
||||
tables:
|
||||
ship-001: tb_ship_default_info
|
||||
ship-002: tb_ship_info_mst
|
||||
ship-003: tb_ship_add_info
|
||||
ship-004: tb_ship_bbctr_hstry
|
||||
@ -153,13 +152,12 @@ app:
|
||||
code-001: tb_ship_type_cd
|
||||
code-002: tb_ship_country_cd
|
||||
risk-compliance-001: tb_ship_risk_info
|
||||
risk-compliance-002: tb_ship_compliance_info
|
||||
risk-compliance-003: tb_company_compliance_info
|
||||
risk-compliance-003: tb_ship_compliance_info
|
||||
risk-compliance-006: tb_company_compliance_info
|
||||
target-schema:
|
||||
name: std_snp_svc
|
||||
tables:
|
||||
ship-001: tb_ship_info_mst
|
||||
ship-002: tb_ship_main_info
|
||||
ship-002: tb_ship_info_mst
|
||||
ship-003: tb_ship_add_info
|
||||
ship-004: tb_ship_bbctr_hstry
|
||||
ship-005: tb_ship_idntf_info_hstry
|
||||
|
||||
불러오는 중...
Reference in New Issue
Block a user