라벨할당 로직 수정
This commit is contained in:
@@ -34,6 +34,7 @@ import jakarta.persistence.EntityManager;
|
|||||||
import jakarta.persistence.EntityNotFoundException;
|
import jakarta.persistence.EntityNotFoundException;
|
||||||
import jakarta.persistence.PersistenceContext;
|
import jakarta.persistence.PersistenceContext;
|
||||||
import jakarta.transaction.Transactional;
|
import jakarta.transaction.Transactional;
|
||||||
|
import java.sql.PreparedStatement;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.LocalTime;
|
import java.time.LocalTime;
|
||||||
import java.time.ZoneId;
|
import java.time.ZoneId;
|
||||||
@@ -43,6 +44,7 @@ import java.util.Objects;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.hibernate.Session;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.PageImpl;
|
import org.springframework.data.domain.PageImpl;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
@@ -106,27 +108,41 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
|
|||||||
.execute();
|
.execute();
|
||||||
|
|
||||||
// 라벨러 할당 테이블에 insert
|
// 라벨러 할당 테이블에 insert
|
||||||
String sql =
|
Session session = em.unwrap(Session.class);
|
||||||
"""
|
|
||||||
|
session.doWork(
|
||||||
|
connection -> {
|
||||||
|
String sql =
|
||||||
|
"""
|
||||||
insert into tb_labeling_assignment
|
insert into tb_labeling_assignment
|
||||||
(assignment_uid, inference_geom_uid, worker_uid,
|
(assignment_uid, inference_geom_uid, worker_uid,
|
||||||
work_state, assign_group_id, anal_uid)
|
work_state, assign_group_id, anal_uid)
|
||||||
values (?, ?, ?, ?, ?, ?)
|
values (?, ?, ?, ?, ?, ?)
|
||||||
""";
|
""";
|
||||||
|
|
||||||
for (AllocateInfoDto info : ids) {
|
try (PreparedStatement ps = connection.prepareStatement(sql)) {
|
||||||
em.createNativeQuery(sql)
|
int batchSize = 0;
|
||||||
.setParameter(1, UUID.randomUUID())
|
|
||||||
.setParameter(2, info.getGeoUid())
|
|
||||||
.setParameter(3, userId)
|
|
||||||
.setParameter(4, LabelState.ASSIGNED.getId())
|
|
||||||
.setParameter(5, info.getMapSheetNum())
|
|
||||||
.setParameter(6, analEntity.getId())
|
|
||||||
.executeUpdate();
|
|
||||||
}
|
|
||||||
|
|
||||||
em.flush();
|
for (AllocateInfoDto info : ids) {
|
||||||
em.clear();
|
ps.setObject(1, UUID.randomUUID());
|
||||||
|
ps.setLong(2, info.getGeoUid());
|
||||||
|
ps.setString(3, userId);
|
||||||
|
ps.setString(4, LabelState.ASSIGNED.getId());
|
||||||
|
ps.setString(5, String.valueOf(info.getMapSheetNum()));
|
||||||
|
ps.setLong(6, analEntity.getId());
|
||||||
|
|
||||||
|
ps.addBatch();
|
||||||
|
batchSize++;
|
||||||
|
|
||||||
|
if (batchSize % 1000 == 0) {
|
||||||
|
ps.executeBatch();
|
||||||
|
ps.clearBatch();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ps.executeBatch();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user