Merge pull request 'feat/dev_251201' (#150) from feat/dev_251201 into develop

Reviewed-on: https://kamco.gitea.gs.dabeeo.com/dabeeo/kamco-dabeeo-backoffice/pulls/150
This commit is contained in:
2026-01-05 17:53:56 +09:00
7 changed files with 100 additions and 19 deletions

View File

@@ -131,9 +131,14 @@ public class LabelWorkerApiController {
@Parameter(description = "페이지 크기", example = "20") @RequestParam(defaultValue = "20")
int size) {
// 대상추출(최근)
UUID lstUuid = labelWorkService.findLastLabelWorkState();
String uuid = lstUuid.toString();
LabelWorkDto.WorkerStateSearchReq searchReq = new WorkerStateSearchReq();
searchReq.setUserRole(userRole);
searchReq.setSearchVal(searchVal);
searchReq.setUuid(uuid);
searchReq.setPage(page);
searchReq.setSize(size);
return ApiResponseDto.ok(labelWorkService.findlabelWorkStateList(searchReq));

View File

@@ -158,13 +158,13 @@ public class LabelWorkDto {
@Schema(description = "Skip개수")
private Long skipCnt;
@Schema(description = "Skip개수")
@Schema(description = "3일전처리개수")
private Long day3AgoDoneCnt;
@Schema(description = "Skip개수")
@Schema(description = "2일전처리개수")
private Long day2AgoDoneCnt;
@Schema(description = "Skip개수")
@Schema(description = "1일전처리개수")
private Long day1AgoDoneCnt;
public Long getremindCnt() {
@@ -172,10 +172,12 @@ public class LabelWorkDto {
}
public double getDoneRate() {
if (this.doneCnt == null || this.assignedCnt == 0) {
Long dayDoneCnt = this.day3AgoDoneCnt + this.day2AgoDoneCnt + this.day1AgoDoneCnt;
if (dayDoneCnt == null || dayDoneCnt == 0) {
return 0.0;
}
return (double) this.doneCnt / this.assignedCnt * 100.0;
return (double) dayDoneCnt / 3;
}
public String getUserRoleName() {

View File

@@ -55,4 +55,8 @@ public class LabelWorkService {
return labelWorkCoreService.findlabelWorkStateList(searchReq);
}
public UUID findLastLabelWorkState() {
return labelWorkCoreService.findLastLabelWorkState();
}
}

View File

@@ -57,4 +57,8 @@ public class LabelWorkCoreService {
public LabelWorkMngDetail findLabelWorkMngDetail(UUID uuid) {
return labelWorkRepository.findLabelWorkMngDetail(uuid);
}
public UUID findLastLabelWorkState() {
return labelWorkRepository.findLastLabelWorkState();
}
}

View File

@@ -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

View File

@@ -18,4 +18,6 @@ public interface LabelWorkRepositoryCustom {
LabelWorkMngDetail findLabelWorkMngDetail(UUID uuid);
Page<WorkerState> findlabelWorkStateList(LabelWorkDto.WorkerStateSearchReq searchReq);
UUID findLastLabelWorkState();
}

View File

@@ -212,6 +212,8 @@ public class LabelWorkRepositoryImpl extends QuerydslRepositorySupport
BooleanBuilder whereBuilder = new BooleanBuilder();
BooleanBuilder whereSubBuilder = new BooleanBuilder();
UUID uuid = UUID.fromString(searchReq.getUuid());
LocalDate threeDaysAgo = LocalDate.now().minusDays(3);
String s3 = threeDaysAgo.format(DateTimeFormatter.ofPattern("YYYY-MM-DD"));
@@ -300,6 +302,12 @@ public class LabelWorkRepositoryImpl extends QuerydslRepositorySupport
.sum()
.as("day1AgoDoneCnt")))
.from(labelingAssignmentEntity)
.innerJoin(mapSheetAnalInferenceEntity)
.on(
mapSheetAnalInferenceEntity
.uuid
.eq(uuid)
.and(labelingAssignmentEntity.analUid.eq(mapSheetAnalInferenceEntity.id)))
.innerJoin(memberEntity)
.on(whereSubBuilder)
.where(whereBuilder)
@@ -312,6 +320,12 @@ public class LabelWorkRepositoryImpl extends QuerydslRepositorySupport
queryFactory
.select(labelingAssignmentEntity.workerUid.countDistinct())
.from(labelingAssignmentEntity)
.innerJoin(mapSheetAnalInferenceEntity)
.on(
mapSheetAnalInferenceEntity
.uuid
.eq(uuid)
.and(labelingAssignmentEntity.analUid.eq(mapSheetAnalInferenceEntity.id)))
.innerJoin(memberEntity)
.on(whereSubBuilder)
.where(whereBuilder)
@@ -321,6 +335,40 @@ public class LabelWorkRepositoryImpl extends QuerydslRepositorySupport
return new PageImpl<>(foundContent, pageable, countQuery);
}
@Override
public UUID findLastLabelWorkState() {
BooleanBuilder whereBuilder = new BooleanBuilder();
UUID uuid =
queryFactory
.select(mapSheetAnalInferenceEntity.uuid)
.from(mapSheetAnalInferenceEntity)
.innerJoin(labelingAssignmentEntity)
.on(mapSheetAnalInferenceEntity.id.eq(labelingAssignmentEntity.analUid))
.where(whereBuilder)
.orderBy(
mapSheetAnalInferenceEntity.compareYyyy.desc(),
mapSheetAnalInferenceEntity.targetYyyy.desc(),
mapSheetAnalInferenceEntity.stage.desc())
.fetchFirst();
if (uuid == null) {
uuid =
queryFactory
.select(mapSheetAnalInferenceEntity.uuid)
.from(mapSheetAnalInferenceEntity)
.where(whereBuilder)
.orderBy(
mapSheetAnalInferenceEntity.compareYyyy.desc(),
mapSheetAnalInferenceEntity.targetYyyy.desc(),
mapSheetAnalInferenceEntity.stage.desc())
.fetchFirst();
}
return uuid;
}
/**
* 작업배정 상세조회
*