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

Reviewed-on: https://kamco.gitea.gs.dabeeo.com/dabeeo/kamco-dabeeo-backoffice/pulls/153
This commit is contained in:
2026-01-06 12:13:25 +09:00
5 changed files with 99 additions and 109 deletions

View File

@@ -16,6 +16,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import java.time.LocalDate;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
@@ -71,10 +72,10 @@ public class LabelWorkerApiController {
public ApiResponseDto<Page<LabelWorkMng>> labelWorkMngList( public ApiResponseDto<Page<LabelWorkMng>> labelWorkMngList(
@Parameter(description = "변화탐지년도", example = "2022-2024") @RequestParam(required = false) @Parameter(description = "변화탐지년도", example = "2022-2024") @RequestParam(required = false)
String detectYear, String detectYear,
@Parameter(description = "시작일", example = "20220101") @RequestParam(required = false) @Parameter(description = "시작일", example = "2022-01-01") @RequestParam(required = false)
String strtDttm, LocalDate strtDttm,
@Parameter(description = "종료일", example = "20261201") @RequestParam(required = false) @Parameter(description = "종료일", example = "2026-12-01") @RequestParam(required = false)
String endDttm, LocalDate endDttm,
@Parameter(description = "페이지 번호 (0부터 시작)", example = "0") @RequestParam(defaultValue = "0") @Parameter(description = "페이지 번호 (0부터 시작)", example = "0") @RequestParam(defaultValue = "0")
int page, int page,
@Parameter(description = "페이지 크기", example = "20") @RequestParam(defaultValue = "20") @Parameter(description = "페이지 크기", example = "20") @RequestParam(defaultValue = "20")
@@ -126,6 +127,12 @@ public class LabelWorkerApiController {
String userRole, String userRole,
@Parameter(description = "검색어", example = "20261201") @RequestParam(required = false) @Parameter(description = "검색어", example = "20261201") @RequestParam(required = false)
String searchVal, String searchVal,
@Parameter(
description = "정렬",
example = "",
schema = @Schema(allowableValues = {"remindCnt desc", "doneCnt desc"}))
@RequestParam(required = false)
String sort,
@Parameter(description = "페이지 번호 (0부터 시작)", example = "0") @RequestParam(defaultValue = "0") @Parameter(description = "페이지 번호 (0부터 시작)", example = "0") @RequestParam(defaultValue = "0")
int page, int page,
@Parameter(description = "페이지 크기", example = "20") @RequestParam(defaultValue = "20") @Parameter(description = "페이지 크기", example = "20") @RequestParam(defaultValue = "20")
@@ -139,6 +146,7 @@ public class LabelWorkerApiController {
searchReq.setUserRole(userRole); searchReq.setUserRole(userRole);
searchReq.setSearchVal(searchVal); searchReq.setSearchVal(searchVal);
searchReq.setUuid(uuid); searchReq.setUuid(uuid);
searchReq.setSort(sort);
searchReq.setPage(page); searchReq.setPage(page);
searchReq.setSize(size); searchReq.setSize(size);
return ApiResponseDto.ok(labelWorkService.findlabelWorkStateList(searchReq)); return ApiResponseDto.ok(labelWorkService.findlabelWorkStateList(searchReq));

View File

@@ -5,6 +5,7 @@ import com.kamco.cd.kamcoback.common.utils.enums.Enums;
import com.kamco.cd.kamcoback.common.utils.interfaces.JsonFormatDttm; import com.kamco.cd.kamcoback.common.utils.interfaces.JsonFormatDttm;
import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.LabelMngState; import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.LabelMngState;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import java.time.LocalDate;
import java.time.ZonedDateTime; import java.time.ZonedDateTime;
import java.util.UUID; import java.util.UUID;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
@@ -120,11 +121,11 @@ public class LabelWorkDto {
@Schema(description = "변화탐지년도", example = "2024") @Schema(description = "변화탐지년도", example = "2024")
private String detectYear; private String detectYear;
@Schema(description = "시작일", example = "20260101") @Schema(description = "시작일", example = "2026-01-01")
private String strtDttm; private LocalDate strtDttm;
@Schema(description = "종료일", example = "20261201") @Schema(description = "종료일", example = "2026-12-01")
private String endDttm; private LocalDate endDttm;
public Pageable toPageable() { public Pageable toPageable() {
@@ -211,6 +212,9 @@ public class LabelWorkDto {
@Schema(description = "종료일", example = "20261201") @Schema(description = "종료일", example = "20261201")
private String uuid; private String uuid;
@Schema(description = "정렬(remindCnt desc, doneCnt desc)", example = "remindCnt desc")
private String sort;
public Pageable toPageable() { public Pageable toPageable() {
return PageRequest.of(page, size); return PageRequest.of(page, size);

View File

@@ -74,31 +74,11 @@ public class LabelAllocateService {
index = end; index = end;
} }
// 검수자에게 userCount명 만큼 할당 // 검수자 할당 테이블에 insert. TODO: 익일 배치로 라벨링 완료된 내역을 검수자에게 할당해야 함
List<LabelAllocateDto.Basic> list = labelAllocateCoreService.findAssignedLabelerList(analUid);
for (String inspector : targetInspectors) { for (String inspector : targetInspectors) {
labelAllocateCoreService.insertInspector(analUid, inspector); labelAllocateCoreService.insertInspector(analUid, inspector);
} }
// int from = 0;
// for (TargetInspector inspector : targetInspectors) {
// int to = Math.min(from + inspector.getUserCount(), list.size());
//
// if (from >= to) {
// break;
// }
//
// List<UUID> assignmentUids =
// list.subList(from,
// to).stream().map(LabelAllocateDto.Basic::getAssignmentUid).toList();
//
// labelAllocateCoreService.assignInspectorBulk(assignmentUids,
// inspector.getInspectorUid());
//
// from = to;
// }
return new ApiResponseDto.ResponseObj(ApiResponseCode.OK, "배정이 완료되었습니다."); return new ApiResponseDto.ResponseObj(ApiResponseCode.OK, "배정이 완료되었습니다.");
} }

View File

@@ -6,6 +6,7 @@ import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetAnalDataInferenceG
import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetAnalInferenceEntity.mapSheetAnalInferenceEntity; import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetAnalInferenceEntity.mapSheetAnalInferenceEntity;
import static com.kamco.cd.kamcoback.postgres.entity.QMemberEntity.memberEntity; import static com.kamco.cd.kamcoback.postgres.entity.QMemberEntity.memberEntity;
import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.LabelState;
import com.kamco.cd.kamcoback.label.dto.LabelWorkDto; import com.kamco.cd.kamcoback.label.dto.LabelWorkDto;
import com.kamco.cd.kamcoback.label.dto.LabelWorkDto.LabelWorkMng; import com.kamco.cd.kamcoback.label.dto.LabelWorkDto.LabelWorkMng;
import com.kamco.cd.kamcoback.label.dto.LabelWorkDto.LabelWorkMngDetail; import com.kamco.cd.kamcoback.label.dto.LabelWorkDto.LabelWorkMngDetail;
@@ -13,8 +14,11 @@ import com.kamco.cd.kamcoback.label.dto.LabelWorkDto.WorkerState;
import com.kamco.cd.kamcoback.postgres.entity.MapSheetAnalDataGeomEntity; import com.kamco.cd.kamcoback.postgres.entity.MapSheetAnalDataGeomEntity;
import com.kamco.cd.kamcoback.postgres.entity.MapSheetAnalInferenceEntity; import com.kamco.cd.kamcoback.postgres.entity.MapSheetAnalInferenceEntity;
import com.querydsl.core.BooleanBuilder; import com.querydsl.core.BooleanBuilder;
import com.querydsl.core.types.OrderSpecifier;
import com.querydsl.core.types.Projections; import com.querydsl.core.types.Projections;
import com.querydsl.core.types.dsl.BooleanExpression;
import com.querydsl.core.types.dsl.CaseBuilder; import com.querydsl.core.types.dsl.CaseBuilder;
import com.querydsl.core.types.dsl.DateTimePath;
import com.querydsl.core.types.dsl.Expressions; import com.querydsl.core.types.dsl.Expressions;
import com.querydsl.core.types.dsl.NumberExpression; import com.querydsl.core.types.dsl.NumberExpression;
import com.querydsl.core.types.dsl.StringExpression; import com.querydsl.core.types.dsl.StringExpression;
@@ -26,6 +30,7 @@ import java.time.LocalDate;
import java.time.ZoneId; import java.time.ZoneId;
import java.time.ZonedDateTime; import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@@ -109,21 +114,13 @@ public class LabelWorkRepositoryImpl extends QuerydslRepositorySupport
whereSubBuilder.and( whereSubBuilder.and(
mapSheetAnalDataInferenceGeomEntity.dataUid.eq(mapSheetAnalDataInferenceEntity.id)); mapSheetAnalDataInferenceGeomEntity.dataUid.eq(mapSheetAnalDataInferenceEntity.id));
if (searchReq.getStrtDttm() != null if (searchReq.getStrtDttm() != null && searchReq.getEndDttm() != null) {
&& !searchReq.getStrtDttm().isEmpty()
&& searchReq.getEndDttm() != null
&& !searchReq.getEndDttm().isEmpty()) {
ZoneId zoneId = ZoneId.of("Asia/Seoul"); ZoneId zoneId = ZoneId.of("Asia/Seoul");
ZonedDateTime start = ZonedDateTime start = searchReq.getStrtDttm().atStartOfDay(zoneId);
LocalDate.parse(searchReq.getStrtDttm(), DateTimeFormatter.BASIC_ISO_DATE)
.atStartOfDay(zoneId);
ZonedDateTime end = ZonedDateTime end = searchReq.getEndDttm().plusDays(1).atStartOfDay(zoneId);
LocalDate.parse(searchReq.getEndDttm(), DateTimeFormatter.BASIC_ISO_DATE)
.plusDays(1)
.atStartOfDay(zoneId);
whereSubBuilder.and( whereSubBuilder.and(
mapSheetAnalDataInferenceGeomEntity mapSheetAnalDataInferenceGeomEntity
@@ -208,21 +205,14 @@ public class LabelWorkRepositoryImpl extends QuerydslRepositorySupport
@Override @Override
public Page<WorkerState> findlabelWorkStateList(LabelWorkDto.WorkerStateSearchReq searchReq) { public Page<WorkerState> findlabelWorkStateList(LabelWorkDto.WorkerStateSearchReq searchReq) {
Pageable pageable = PageRequest.of(searchReq.getPage(), searchReq.getSize()); Pageable pageable = PageRequest.of(searchReq.getPage(), searchReq.getSize());
BooleanBuilder whereBuilder = new BooleanBuilder(); BooleanBuilder whereBuilder = new BooleanBuilder();
BooleanBuilder whereSubBuilder = new BooleanBuilder(); BooleanBuilder whereSubBuilder = new BooleanBuilder();
List<OrderSpecifier<?>> orderSpecifiers = new ArrayList<>();
UUID uuid = UUID.fromString(searchReq.getUuid()); UUID uuid = UUID.fromString(searchReq.getUuid());
LocalDate threeDaysAgo = LocalDate.now().minusDays(3);
String s3 = threeDaysAgo.format(DateTimeFormatter.ofPattern("YYYY-MM-DD"));
LocalDate twoDaysAgo = LocalDate.now().minusDays(2);
String s2 = twoDaysAgo.format(DateTimeFormatter.ofPattern("YYYY-MM-DD"));
LocalDate oneDaysAgo = LocalDate.now().minusDays(1);
String s1 = oneDaysAgo.format(DateTimeFormatter.ofPattern("YYYY-MM-DD"));
if (searchReq.getUserRole() != null && !searchReq.getUserRole().isEmpty()) { if (searchReq.getUserRole() != null && !searchReq.getUserRole().isEmpty()) {
whereSubBuilder.and(memberEntity.userRole.eq(searchReq.getUserRole())); whereSubBuilder.and(memberEntity.userRole.eq(searchReq.getUserRole()));
} }
@@ -238,6 +228,43 @@ public class LabelWorkRepositoryImpl extends QuerydslRepositorySupport
whereSubBuilder.and(labelingAssignmentEntity.workerUid.eq(memberEntity.userId)); whereSubBuilder.and(labelingAssignmentEntity.workerUid.eq(memberEntity.userId));
NumberExpression<Long> assignedCnt = labelingAssignmentEntity.workerUid.count();
NumberExpression<Long> doneCnt =
this.caseSumExpression(labelingAssignmentEntity.workState.eq(LabelState.DONE.name()));
NumberExpression<Long> skipCnt =
this.caseSumExpression(labelingAssignmentEntity.workState.eq(LabelState.SKIP.name()));
NumberExpression<Long> day3AgoDoneCnt =
this.caseSumExpression(
labelingAssignmentEntity
.workState
.eq(LabelState.DONE.name())
.and(this.fromDateEqExpression(labelingAssignmentEntity.modifiedDate, -3)));
NumberExpression<Long> day2AgoDoneCnt =
this.caseSumExpression(
labelingAssignmentEntity
.workState
.eq(LabelState.DONE.name())
.and(this.fromDateEqExpression(labelingAssignmentEntity.modifiedDate, -2)));
NumberExpression<Long> day1AgoDoneCnt =
this.caseSumExpression(
labelingAssignmentEntity
.workState
.eq(LabelState.DONE.name())
.and(this.fromDateEqExpression(labelingAssignmentEntity.modifiedDate, -1)));
NumberExpression<Long> remainingCnt = assignedCnt.subtract(doneCnt);
if (searchReq.getSort() == null || searchReq.getSort().isEmpty()) {
orderSpecifiers.add(memberEntity.name.asc());
} else if (searchReq.getSort().equals("doneCnt desc")) {
orderSpecifiers.add(doneCnt.desc());
} else if (searchReq.getSort().equals("remindCnt desc")) {
orderSpecifiers.add(remainingCnt.desc());
}
List<WorkerState> foundContent = List<WorkerState> foundContent =
queryFactory queryFactory
.select( .select(
@@ -246,61 +273,12 @@ public class LabelWorkRepositoryImpl extends QuerydslRepositorySupport
memberEntity.userRole, memberEntity.userRole,
memberEntity.name, memberEntity.name,
memberEntity.userId, memberEntity.userId,
labelingAssignmentEntity.workerUid.count().as("assignedCnt"), assignedCnt.as("assignedCnt"),
new CaseBuilder() doneCnt.as("doneCnt"),
.when(labelingAssignmentEntity.workState.eq("DONE")) skipCnt.as("skipCnt"),
.then(1L) day3AgoDoneCnt.as("day3AgoDoneCnt"),
.otherwise(0L) day2AgoDoneCnt.as("day2AgoDoneCnt"),
.sum() day1AgoDoneCnt.as("day1AgoDoneCnt")))
.as("doneCnt"),
new CaseBuilder()
.when(labelingAssignmentEntity.workState.eq("SKIP"))
.then(1L)
.otherwise(0L)
.sum()
.as("skipCnt"),
new CaseBuilder()
.when(
labelingAssignmentEntity
.workState
.eq("DONE")
.and(
Expressions.stringTemplate(
"to_char({0}, 'YYYY-MM-DD')",
labelingAssignmentEntity.modifiedDate)
.eq(s3)))
.then(1L)
.otherwise(0L)
.sum()
.as("day3AgoDoneCnt"),
new CaseBuilder()
.when(
labelingAssignmentEntity
.workState
.eq("DONE")
.and(
Expressions.stringTemplate(
"to_char({0}, 'YYYY-MM-DD')",
labelingAssignmentEntity.modifiedDate)
.eq(s2)))
.then(1L)
.otherwise(0L)
.sum()
.as("day2AgoDoneCnt"),
new CaseBuilder()
.when(
labelingAssignmentEntity
.workState
.eq("DONE")
.and(
Expressions.stringTemplate(
"to_char({0}, 'YYYY-MM-DD')",
labelingAssignmentEntity.modifiedDate)
.eq(s1)))
.then(1L)
.otherwise(0L)
.sum()
.as("day1AgoDoneCnt")))
.from(labelingAssignmentEntity) .from(labelingAssignmentEntity)
.innerJoin(mapSheetAnalInferenceEntity) .innerJoin(mapSheetAnalInferenceEntity)
.on( .on(
@@ -312,6 +290,7 @@ public class LabelWorkRepositoryImpl extends QuerydslRepositorySupport
.on(whereSubBuilder) .on(whereSubBuilder)
.where(whereBuilder) .where(whereBuilder)
.groupBy(memberEntity.userRole, memberEntity.name, memberEntity.userId) .groupBy(memberEntity.userRole, memberEntity.name, memberEntity.userId)
.orderBy(orderSpecifiers.toArray(new OrderSpecifier[0]))
.offset(pageable.getOffset()) .offset(pageable.getOffset())
.limit(pageable.getPageSize()) .limit(pageable.getPageSize())
.fetch(); .fetch();
@@ -413,4 +392,21 @@ public class LabelWorkRepositoryImpl extends QuerydslRepositorySupport
mapSheetAnalInferenceEntity.createdDttm) mapSheetAnalInferenceEntity.createdDttm)
.fetchOne(); .fetchOne();
} }
public NumberExpression<Long> caseSumExpression(BooleanExpression condition) {
NumberExpression<Long> sumExp = new CaseBuilder().when(condition).then(1L).otherwise(0L).sum();
return sumExp;
}
public BooleanExpression fromDateEqExpression(DateTimePath<ZonedDateTime> path, int addDayCnt) {
LocalDate threeDaysAgo = LocalDate.now().plusDays(addDayCnt);
String toDate = threeDaysAgo.format(DateTimeFormatter.ofPattern("YYYY-MM-DD"));
BooleanExpression condition =
Expressions.stringTemplate("to_char({0}, 'YYYY-MM-DD')", path).eq(toDate);
return condition;
}
} }

View File

@@ -15,7 +15,7 @@ import com.querydsl.core.types.dsl.Expressions;
import com.querydsl.core.types.dsl.StringExpression; import com.querydsl.core.types.dsl.StringExpression;
import com.querydsl.jpa.impl.JPAQueryFactory; import com.querydsl.jpa.impl.JPAQueryFactory;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.ZoneId;
import java.time.ZonedDateTime; import java.time.ZonedDateTime;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
@@ -98,12 +98,14 @@ public class ErrorLogRepositoryImpl extends QuerydslRepositorySupport
if (Objects.isNull(startDate) || Objects.isNull(endDate)) { if (Objects.isNull(startDate) || Objects.isNull(endDate)) {
return null; return null;
} }
LocalDateTime startDateTime = startDate.atStartOfDay();
LocalDateTime endDateTime = endDate.plusDays(1).atStartOfDay(); ZoneId zoneId = ZoneId.of("Asia/Seoul");
ZonedDateTime startDateTime = startDate.atStartOfDay(zoneId);
ZonedDateTime endDateTime = endDate.plusDays(1).atStartOfDay(zoneId);
return auditLogEntity return auditLogEntity
.createdDate .createdDate
.goe(ZonedDateTime.from(startDateTime)) .goe(startDateTime)
.and(auditLogEntity.createdDate.lt(ZonedDateTime.from(endDateTime))); .and(auditLogEntity.createdDate.lt(endDateTime));
} }
private BooleanExpression eventStatusEqFailed() { private BooleanExpression eventStatusEqFailed() {