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

병합
HYOJIN feature/ISSUE-18-ais-last-position-update-target 에서 develop 로 1 commits 를 머지했습니다 2026-03-04 18:04:22 +09:00
3개의 변경된 파일44개의 추가작업 그리고 19개의 파일을 삭제

파일 보기

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

파일 보기

@ -59,24 +59,27 @@ public class ShipLastPositionSyncRepositoryImpl implements ShipLastPositionSyncR
ancrg_yn = ?
WHERE imo_no = ?
""".formatted(getTableName());
// return """
// UPDATE new_snp.core20
// SET lastseen = ?::timestamptz,
// lastport = ?,
// position_latitude = ?,
// position_longitude = ?,
// destination = ?,
// eta = ?::timestamptz,
// heading = ?,
// cog = ?,
// speedservice = ?,
// navstat = ?,
// tonnes_cargo = ?,
// extra_info = ?,
// in_sts = ?,
// on_berth = ?
// WHERE lrno = ?;
// """;
}
private String getCoreUpdateSql() {
return """
UPDATE new_snp.core20
SET lastseen = ?::timestamptz,
lastport = ?,
position_latitude = ?,
position_longitude = ?,
destination = ?,
eta = ?::timestamptz,
heading = ?,
cog = ?,
speedservice = ?,
navstat = ?,
tonnes_cargo = ?,
extra_info = ?,
in_sts = ?,
on_berth = ?
WHERE lrno = ?;
""";
}
@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;
}
@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 {
int idx = 1;

파일 보기

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