From 338e9c448c9548876cd0ff4338d85105adff30ca Mon Sep 17 00:00:00 2001 From: teddy Date: Mon, 5 Jan 2026 14:46:26 +0900 Subject: [PATCH] =?UTF-8?q?=EB=9D=BC=EB=B2=A8=EB=A7=81=EC=9E=91=EC=97=85?= =?UTF-8?q?=20=EA=B4=80=EB=A6=AC=20=EB=AA=A9=EB=A1=9D=EC=A1=B0=ED=9A=8C=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../label/LabelWorkerApiController.java | 37 ++-- .../cd/kamcoback/label/dto/LabelWorkDto.java | 5 +- .../label/service/LabelAllocateService.java | 17 +- .../label/service/LabelWorkService.java | 4 +- .../postgres/core/LabelWorkCoreService.java | 11 +- .../label/LabelWorkRepositoryCustom.java | 4 +- .../label/LabelWorkRepositoryImpl.java | 180 +++++++++--------- 7 files changed, 118 insertions(+), 140 deletions(-) diff --git a/src/main/java/com/kamco/cd/kamcoback/label/LabelWorkerApiController.java b/src/main/java/com/kamco/cd/kamcoback/label/LabelWorkerApiController.java index fa7cf915..3d85d264 100644 --- a/src/main/java/com/kamco/cd/kamcoback/label/LabelWorkerApiController.java +++ b/src/main/java/com/kamco/cd/kamcoback/label/LabelWorkerApiController.java @@ -8,7 +8,6 @@ import com.kamco.cd.kamcoback.label.dto.LabelWorkDto.LabelWorkMngDetail; import com.kamco.cd.kamcoback.label.dto.LabelWorkDto.LabelWorkMngSearchReq; import com.kamco.cd.kamcoback.label.dto.LabelWorkDto.WorkerState; import com.kamco.cd.kamcoback.label.dto.LabelWorkDto.WorkerStateSearchReq; -import com.kamco.cd.kamcoback.label.dto.WorkerStatsDto.WorkerStatistics; import com.kamco.cd.kamcoback.label.service.LabelWorkService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; @@ -108,25 +107,27 @@ public class LabelWorkerApiController { @Operation(summary = "작업현황 관리 > 현황 목록 조회", description = "작업현황 관리 > 현황 목록 조회") @ApiResponses( - value = { - @ApiResponse( - responseCode = "200", - description = "조회 성공", - content = - @Content( - mediaType = "application/json", - schema = @Schema(implementation = CommonCodeDto.Basic.class))), - @ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content), - @ApiResponse(responseCode = "500", description = "서버 오류", content = @Content) - }) + value = { + @ApiResponse( + responseCode = "200", + description = "조회 성공", + content = + @Content( + mediaType = "application/json", + schema = @Schema(implementation = Page.class))), + @ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content), + @ApiResponse(responseCode = "500", description = "서버 오류", content = @Content) + }) @GetMapping("/work-state-list") public ApiResponseDto> findWorkStateList( - @Parameter(description = "유형", example = "LABELER") @RequestParam(required = false) String userRole, - @Parameter(description = "검색어", example = "20261201") @RequestParam(required = false) String searchVal, - @Parameter(description = "페이지 번호 (0부터 시작)", example = "0") @RequestParam(defaultValue = "0") - int page, - @Parameter(description = "페이지 크기", example = "20") @RequestParam(defaultValue = "20") - int size) { + @Parameter(description = "유형", example = "LABELER") @RequestParam(required = false) + String userRole, + @Parameter(description = "검색어", example = "20261201") @RequestParam(required = false) + String searchVal, + @Parameter(description = "페이지 번호 (0부터 시작)", example = "0") @RequestParam(defaultValue = "0") + int page, + @Parameter(description = "페이지 크기", example = "20") @RequestParam(defaultValue = "20") + int size) { LabelWorkDto.WorkerStateSearchReq searchReq = new WorkerStateSearchReq(); searchReq.setUserRole(userRole); diff --git a/src/main/java/com/kamco/cd/kamcoback/label/dto/LabelWorkDto.java b/src/main/java/com/kamco/cd/kamcoback/label/dto/LabelWorkDto.java index d895ad1b..de845206 100644 --- a/src/main/java/com/kamco/cd/kamcoback/label/dto/LabelWorkDto.java +++ b/src/main/java/com/kamco/cd/kamcoback/label/dto/LabelWorkDto.java @@ -4,7 +4,6 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.kamco.cd.kamcoback.common.utils.enums.Enums; 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.WorkerStatsDto.DailyHistory; import io.swagger.v3.oas.annotations.media.Schema; import java.time.ZonedDateTime; import java.util.UUID; @@ -130,7 +129,6 @@ public class LabelWorkDto { } } - @Getter @Setter @Builder @@ -167,7 +165,7 @@ public class LabelWorkDto { private Long day1AgoDoneCnt; public Long getremindCnt() { - return this.assignedCnt - this.doneCnt; + return this.assignedCnt - this.doneCnt; } public double getDoneRate() { @@ -183,7 +181,6 @@ public class LabelWorkDto { } return "검수자"; } - } @Schema(name = "WorkerStateSearchReq", description = "라벨작업관리 검색 요청") diff --git a/src/main/java/com/kamco/cd/kamcoback/label/service/LabelAllocateService.java b/src/main/java/com/kamco/cd/kamcoback/label/service/LabelAllocateService.java index 6681d1e4..df8b039a 100644 --- a/src/main/java/com/kamco/cd/kamcoback/label/service/LabelAllocateService.java +++ b/src/main/java/com/kamco/cd/kamcoback/label/service/LabelAllocateService.java @@ -8,7 +8,6 @@ import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.InferenceDetail; import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.LabelerDetail; import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.TargetUser; import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.UserList; -import com.kamco.cd.kamcoback.label.dto.WorkerStatsDto.DailyHistory; import com.kamco.cd.kamcoback.label.dto.WorkerStatsDto.WorkerListResponse; import com.kamco.cd.kamcoback.label.dto.WorkerStatsDto.WorkerStatistics; import com.kamco.cd.kamcoback.postgres.core.LabelAllocateCoreService; @@ -122,12 +121,7 @@ public class LabelAllocateService { * @return 작업자 목록 및 통계 */ public WorkerListResponse getWorkerStatistics( - Long analUid, - String workerType, - String search, - String sortType, - Integer page, - Integer size) { + Long analUid, String workerType, String search, String sortType, Integer page, Integer size) { // 프로젝트 정보 조회 (analUid가 있을 때만) var projectInfo = labelAllocateCoreService.findProjectInfo(analUid); @@ -135,12 +129,9 @@ public class LabelAllocateService { // 작업 진행 현황 조회 var progressInfo = labelAllocateCoreService.findWorkProgressInfo(analUid); - - // 작업자 통계 조회 List workers = - labelAllocateCoreService.findWorkerStatistics( - analUid, workerType, search, sortType); + labelAllocateCoreService.findWorkerStatistics(analUid, workerType, search, sortType); // 각 작업자별 3일치 처리량 조회 LocalDate today = LocalDate.now(); @@ -156,10 +147,6 @@ public class LabelAllocateService { worker.getWorkerId(), workerType, today.minusDays(3), analUid); long average = (day1Count + day2Count + day3Count) / 3; - - - - } // 페이징 처리 diff --git a/src/main/java/com/kamco/cd/kamcoback/label/service/LabelWorkService.java b/src/main/java/com/kamco/cd/kamcoback/label/service/LabelWorkService.java index 3e336a38..f6405984 100644 --- a/src/main/java/com/kamco/cd/kamcoback/label/service/LabelWorkService.java +++ b/src/main/java/com/kamco/cd/kamcoback/label/service/LabelWorkService.java @@ -3,9 +3,8 @@ package com.kamco.cd.kamcoback.label.service; import com.kamco.cd.kamcoback.label.dto.LabelWorkDto; import com.kamco.cd.kamcoback.label.dto.LabelWorkDto.ChangeDetectYear; import com.kamco.cd.kamcoback.label.dto.LabelWorkDto.LabelWorkMng; -import com.kamco.cd.kamcoback.label.dto.LabelWorkDto.WorkerState; -import com.kamco.cd.kamcoback.label.dto.WorkerStatsDto.WorkerStatistics; import com.kamco.cd.kamcoback.label.dto.LabelWorkDto.LabelWorkMngDetail; +import com.kamco.cd.kamcoback.label.dto.LabelWorkDto.WorkerState; import com.kamco.cd.kamcoback.postgres.core.LabelWorkCoreService; import java.util.List; import java.util.UUID; @@ -52,7 +51,6 @@ public class LabelWorkService { return labelWorkCoreService.getChangeDetectYear(); } - public Page findlabelWorkStateList(LabelWorkDto.WorkerStateSearchReq searchReq) { return labelWorkCoreService.findlabelWorkStateList(searchReq); diff --git a/src/main/java/com/kamco/cd/kamcoback/postgres/core/LabelWorkCoreService.java b/src/main/java/com/kamco/cd/kamcoback/postgres/core/LabelWorkCoreService.java index ffec3b34..4b236c13 100644 --- a/src/main/java/com/kamco/cd/kamcoback/postgres/core/LabelWorkCoreService.java +++ b/src/main/java/com/kamco/cd/kamcoback/postgres/core/LabelWorkCoreService.java @@ -1,10 +1,13 @@ package com.kamco.cd.kamcoback.postgres.core; import com.kamco.cd.kamcoback.label.dto.LabelWorkDto; +import com.kamco.cd.kamcoback.label.dto.LabelWorkDto.ChangeDetectYear; 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.WorkerState; -import com.kamco.cd.kamcoback.label.dto.WorkerStatsDto.WorkerStatistics; import com.kamco.cd.kamcoback.postgres.repository.label.LabelWorkRepository; +import java.util.List; +import java.util.UUID; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; import org.springframework.stereotype.Service; @@ -40,10 +43,10 @@ public class LabelWorkCoreService { return labelWorkRepository.labelWorkMngList(searchReq); } - public Page findlabelWorkStateList(LabelWorkDto.WorkerStateSearchReq searchReq) - { + public Page findlabelWorkStateList(LabelWorkDto.WorkerStateSearchReq searchReq) { return labelWorkRepository.findlabelWorkStateList(searchReq); - }; + } + ; /** * 작업배정 정보 조회 diff --git a/src/main/java/com/kamco/cd/kamcoback/postgres/repository/label/LabelWorkRepositoryCustom.java b/src/main/java/com/kamco/cd/kamcoback/postgres/repository/label/LabelWorkRepositoryCustom.java index 4db287c3..baf773e7 100644 --- a/src/main/java/com/kamco/cd/kamcoback/postgres/repository/label/LabelWorkRepositoryCustom.java +++ b/src/main/java/com/kamco/cd/kamcoback/postgres/repository/label/LabelWorkRepositoryCustom.java @@ -2,9 +2,8 @@ package com.kamco.cd.kamcoback.postgres.repository.label; 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.WorkerState; -import com.kamco.cd.kamcoback.label.dto.WorkerStatsDto.WorkerStatistics; import com.kamco.cd.kamcoback.label.dto.LabelWorkDto.LabelWorkMngDetail; +import com.kamco.cd.kamcoback.label.dto.LabelWorkDto.WorkerState; import com.kamco.cd.kamcoback.postgres.entity.MapSheetAnalInferenceEntity; import java.util.List; import java.util.UUID; @@ -19,5 +18,4 @@ public interface LabelWorkRepositoryCustom { LabelWorkMngDetail findLabelWorkMngDetail(UUID uuid); Page findlabelWorkStateList(LabelWorkDto.WorkerStateSearchReq searchReq); - } diff --git a/src/main/java/com/kamco/cd/kamcoback/postgres/repository/label/LabelWorkRepositoryImpl.java b/src/main/java/com/kamco/cd/kamcoback/postgres/repository/label/LabelWorkRepositoryImpl.java index 0b56ace1..dbc1d4cb 100644 --- a/src/main/java/com/kamco/cd/kamcoback/postgres/repository/label/LabelWorkRepositoryImpl.java +++ b/src/main/java/com/kamco/cd/kamcoback/postgres/repository/label/LabelWorkRepositoryImpl.java @@ -1,21 +1,15 @@ package com.kamco.cd.kamcoback.postgres.repository.label; import static com.kamco.cd.kamcoback.postgres.entity.QLabelingAssignmentEntity.labelingAssignmentEntity; -import static com.kamco.cd.kamcoback.postgres.entity.QLabelingAssignmentEntity.labelingAssignmentEntity; -import static com.kamco.cd.kamcoback.postgres.entity.QMapInkx5kEntity.mapInkx5kEntity; import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetAnalDataInferenceEntity.mapSheetAnalDataInferenceEntity; import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetAnalDataInferenceGeomEntity.mapSheetAnalDataInferenceGeomEntity; import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetAnalInferenceEntity.mapSheetAnalInferenceEntity; -import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetMngEntity.mapSheetMngEntity; -import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetMngHstEntity.mapSheetMngHstEntity; import static com.kamco.cd.kamcoback.postgres.entity.QMemberEntity.memberEntity; 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.LabelWorkMngDetail; import com.kamco.cd.kamcoback.label.dto.LabelWorkDto.WorkerState; -import com.kamco.cd.kamcoback.label.dto.WorkerStatsDto.WorkerStatistics; -import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto; import com.kamco.cd.kamcoback.postgres.entity.MapSheetAnalDataGeomEntity; import com.kamco.cd.kamcoback.postgres.entity.MapSheetAnalInferenceEntity; import com.querydsl.core.BooleanBuilder; @@ -196,22 +190,21 @@ public class LabelWorkRepositoryImpl extends QuerydslRepositorySupport */ Long total = - queryFactory - .select(mapSheetAnalInferenceEntity.uuid.countDistinct()) - .from(mapSheetAnalInferenceEntity) - .innerJoin(mapSheetAnalDataInferenceEntity) - .on(whereSubDataBuilder) - .innerJoin(mapSheetAnalDataInferenceGeomEntity) - .on(whereSubBuilder) - .where(whereBuilder) - .fetchOne(); + queryFactory + .select(mapSheetAnalInferenceEntity.uuid.countDistinct()) + .from(mapSheetAnalInferenceEntity) + .innerJoin(mapSheetAnalDataInferenceEntity) + .on(whereSubDataBuilder) + .innerJoin(mapSheetAnalDataInferenceGeomEntity) + .on(whereSubBuilder) + .where(whereBuilder) + .fetchOne(); return new PageImpl<>(foundContent, pageable, total); } - @Override - public Page findlabelWorkStateList(LabelWorkDto.WorkerStateSearchReq searchReq){ + public Page findlabelWorkStateList(LabelWorkDto.WorkerStateSearchReq searchReq) { Pageable pageable = PageRequest.of(searchReq.getPage(), searchReq.getSize()); BooleanBuilder whereBuilder = new BooleanBuilder(); BooleanBuilder whereSubBuilder = new BooleanBuilder(); @@ -225,89 +218,92 @@ public class LabelWorkRepositoryImpl extends QuerydslRepositorySupport 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())); } - if (searchReq.getSearchVal() != null && ! searchReq.getSearchVal().isEmpty()) { + if (searchReq.getSearchVal() != null && !searchReq.getSearchVal().isEmpty()) { whereSubBuilder.and( - Expressions.stringTemplate( - "{0}",memberEntity.userId) - .likeIgnoreCase("%" + searchReq.getSearchVal() + "%") - .or( - Expressions.stringTemplate( - "{0}",memberEntity.name) + Expressions.stringTemplate("{0}", memberEntity.userId) .likeIgnoreCase("%" + searchReq.getSearchVal() + "%") - ) - ); + .or( + Expressions.stringTemplate("{0}", memberEntity.name) + .likeIgnoreCase("%" + searchReq.getSearchVal() + "%"))); } - whereSubBuilder.and( - labelingAssignmentEntity.workerUid.eq(memberEntity.userId)); + whereSubBuilder.and(labelingAssignmentEntity.workerUid.eq(memberEntity.userId)); List foundContent = - queryFactory - .select( - Projections.constructor( - WorkerState.class, - memberEntity.userRole, - memberEntity.name, - memberEntity.userId, - labelingAssignmentEntity.workerUid.count().as("assignedCnt"), - new CaseBuilder() - .when(labelingAssignmentEntity.workState.eq("DONE")) - .then(1L) - .otherwise(0L) - .sum() - .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) - .innerJoin(memberEntity) - .on(whereSubBuilder) - .where(whereBuilder) - .groupBy( - memberEntity.userRole, - memberEntity.name, - memberEntity.userId) - .offset(pageable.getOffset()) - .limit(pageable.getPageSize()) - .fetch(); + queryFactory + .select( + Projections.constructor( + WorkerState.class, + memberEntity.userRole, + memberEntity.name, + memberEntity.userId, + labelingAssignmentEntity.workerUid.count().as("assignedCnt"), + new CaseBuilder() + .when(labelingAssignmentEntity.workState.eq("DONE")) + .then(1L) + .otherwise(0L) + .sum() + .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) + .innerJoin(memberEntity) + .on(whereSubBuilder) + .where(whereBuilder) + .groupBy(memberEntity.userRole, memberEntity.name, memberEntity.userId) + .offset(pageable.getOffset()) + .limit(pageable.getPageSize()) + .fetch(); /* Long countQuery = @@ -376,6 +372,4 @@ public class LabelWorkRepositoryImpl extends QuerydslRepositorySupport mapSheetAnalInferenceEntity.createdDttm) .fetchOne(); } - - }