feat(aistargetdbsync): core20 테이블 최신 위치 동기화 대상 추가 #20
@ -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;
|
||||
|
||||
|
||||
불러오는 중...
Reference in New Issue
Block a user