라벨할당 로직 수정
This commit is contained in:
@@ -34,6 +34,7 @@ import jakarta.persistence.EntityManager;
|
||||
import jakarta.persistence.EntityNotFoundException;
|
||||
import jakarta.persistence.PersistenceContext;
|
||||
import jakarta.transaction.Transactional;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalTime;
|
||||
import java.time.ZoneId;
|
||||
@@ -43,6 +44,7 @@ import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.hibernate.Session;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageImpl;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
@@ -106,27 +108,41 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
|
||||
.execute();
|
||||
|
||||
// 라벨러 할당 테이블에 insert
|
||||
String sql =
|
||||
"""
|
||||
Session session = em.unwrap(Session.class);
|
||||
|
||||
session.doWork(
|
||||
connection -> {
|
||||
String sql =
|
||||
"""
|
||||
insert into tb_labeling_assignment
|
||||
(assignment_uid, inference_geom_uid, worker_uid,
|
||||
work_state, assign_group_id, anal_uid)
|
||||
values (?, ?, ?, ?, ?, ?)
|
||||
""";
|
||||
|
||||
for (AllocateInfoDto info : ids) {
|
||||
em.createNativeQuery(sql)
|
||||
.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();
|
||||
}
|
||||
try (PreparedStatement ps = connection.prepareStatement(sql)) {
|
||||
int batchSize = 0;
|
||||
|
||||
em.flush();
|
||||
em.clear();
|
||||
for (AllocateInfoDto info : ids) {
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user