feat(aistargetdbsync): core20 테이블 최신 위치 동기화 대상 추가

This commit is contained in:
HYOJIN 2026-03-04 13:45:02 +09:00
부모 b6d3a769e3
커밋 dfd898e6de
3개의 변경된 파일44개의 추가작업 그리고 19개의 파일을 삭제

파일 보기

@ -12,4 +12,5 @@ import java.util.List;
public interface ShipLastPositionSyncRepository { public interface ShipLastPositionSyncRepository {
int updateLastPositions(List<AisTargetEntity> entities); int updateLastPositions(List<AisTargetEntity> entities);
void updateLastPositionsTemp(List<AisTargetEntity> entities);
} }

파일 보기

@ -59,24 +59,27 @@ public class ShipLastPositionSyncRepositoryImpl implements ShipLastPositionSyncR
ancrg_yn = ? ancrg_yn = ?
WHERE imo_no = ? WHERE imo_no = ?
""".formatted(getTableName()); """.formatted(getTableName());
// return """ }
// UPDATE new_snp.core20
// SET lastseen = ?::timestamptz, private String getCoreUpdateSql() {
// lastport = ?, return """
// position_latitude = ?, UPDATE new_snp.core20
// position_longitude = ?, SET lastseen = ?::timestamptz,
// destination = ?, lastport = ?,
// eta = ?::timestamptz, position_latitude = ?,
// heading = ?, position_longitude = ?,
// cog = ?, destination = ?,
// speedservice = ?, eta = ?::timestamptz,
// navstat = ?, heading = ?,
// tonnes_cargo = ?, cog = ?,
// extra_info = ?, speedservice = ?,
// in_sts = ?, navstat = ?,
// on_berth = ? tonnes_cargo = ?,
// WHERE lrno = ?; extra_info = ?,
// """; in_sts = ?,
on_berth = ?
WHERE lrno = ?;
""";
} }
@Override @Override
@ -100,10 +103,30 @@ public class ShipLastPositionSyncRepositoryImpl implements ShipLastPositionSyncR
} }
} }
log.info("Ship Last Position 동기화 완료: 대상={} 건, 갱신={} 건", entities.size(), totalUpdated); log.info("Ship Last Position 동기화 완료 ({}): 대상={} 건, 갱신={} 건", tableName, entities.size(), totalUpdated);
return totalUpdated; return totalUpdated;
} }
@Override
@Transactional
public void updateLastPositionsTemp(List<AisTargetEntity> entities) {
String sql = getCoreUpdateSql();
int totalUpdated = 0;
int[][] batchResults = jdbcTemplate.batchUpdate(sql, entities, BATCH_SIZE,
(ps, entity) -> setUpdateParameters(ps, entity));
for (int[] batchResult : batchResults) {
for (int result : batchResult) {
if (result > 0) {
totalUpdated += result;
}
}
}
log.info("Ship Last Position 동기화 완료 (Core20): 대상={} 건, 갱신={} 건", entities.size(), totalUpdated);
}
private void setUpdateParameters(PreparedStatement ps, AisTargetEntity entity) throws java.sql.SQLException { private void setUpdateParameters(PreparedStatement ps, AisTargetEntity entity) throws java.sql.SQLException {
int idx = 1; int idx = 1;

파일 보기

@ -98,6 +98,7 @@ public class ShipLastPositionSyncTasklet implements Tasklet {
// 4. DB UPDATE // 4. DB UPDATE
int updated = repository.updateLastPositions(latestPerImo); int updated = repository.updateLastPositions(latestPerImo);
repository.updateLastPositionsTemp(latestPerImo); // 임시 추가
long elapsed = System.currentTimeMillis() - startTime; long elapsed = System.currentTimeMillis() - startTime;