Merge branch 'feat/dev_251201' of https://10.100.0.10:3210/dabeeo/kamco-dabeeo-backoffice into feat/dev_251201

This commit is contained in:
2026-01-05 14:46:48 +09:00
13 changed files with 410 additions and 27 deletions

View File

@@ -18,6 +18,7 @@ import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
@@ -113,7 +114,7 @@ public class InnopamApiController {
return detectMastService.selectDetectMast(dtctMstId);
}
@Operation(summary = "탐지객체 PNU 리스트 조회", description = "탐지객체 PNU 리스트 조회")
@Operation(summary = "탐지객체 랜덤 PNU 리스트 조회", description = "탐지객체 PNU 랜덤값을 생성해서 보여준다")
@ApiResponses(
value = {
@ApiResponse(
@@ -149,4 +150,29 @@ public class InnopamApiController {
detectMastSearch.setFeatureId(featureId);
return new FeaturePnuDto();
}
@Operation(
summary = "탐지객체 랜덤 PNU GEOM 업데이트(이노펨에 없는 API)",
description = "탐지객체 랜덤 PNU GEOM 업데이트(이노펨에 없는 API)")
@ApiResponses(
value = {
@ApiResponse(
responseCode = "201",
description = "pnu 업데이트 성공",
content =
@Content(
mediaType = "application/json",
schema = @Schema(implementation = Integer.class))),
@ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content),
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content)
})
@PutMapping("/pnu/{cprsBfYr}/{cprsAfYr}/{dtctSno}")
public Integer updatePnuList(
@PathVariable String cprsBfYr, @PathVariable String cprsAfYr, @PathVariable String dtctSno) {
DetectMastSearch detectMastSearch = new DetectMastSearch();
detectMastSearch.setCprsAdYr(cprsAfYr);
detectMastSearch.setCprsBfYr(cprsBfYr);
detectMastSearch.setDtctSno(Integer.parseInt(dtctSno));
return detectMastService.updatePnuData(detectMastSearch);
}
}

View File

@@ -4,6 +4,7 @@ import com.kamco.cd.kamcoback.Innopam.dto.DetectMastDto;
import com.kamco.cd.kamcoback.Innopam.dto.DetectMastDto.Basic;
import com.kamco.cd.kamcoback.Innopam.dto.DetectMastDto.DetectMastReq;
import com.kamco.cd.kamcoback.Innopam.dto.DetectMastDto.DetectMastSearch;
import com.kamco.cd.kamcoback.Innopam.dto.DetectMastDto.FeaturePnuDto;
import com.kamco.cd.kamcoback.Innopam.postgres.entity.DetectMastEntity;
import com.kamco.cd.kamcoback.Innopam.postgres.repository.DetectMastRepository;
import java.util.List;
@@ -59,4 +60,8 @@ public class DetectMastCoreService {
DetectMastEntity detectMastEntity = detectMastRepository.findPnuData(detectMast);
return detectMastEntity.getPathNm();
}
public Integer updatePnu(List<FeaturePnuDto> list) {
return detectMastRepository.updateGeomPnu(list);
}
}

View File

@@ -1,6 +1,7 @@
package com.kamco.cd.kamcoback.Innopam.postgres.repository;
import com.kamco.cd.kamcoback.Innopam.dto.DetectMastDto.DetectMastSearch;
import com.kamco.cd.kamcoback.Innopam.dto.DetectMastDto.FeaturePnuDto;
import com.kamco.cd.kamcoback.Innopam.postgres.entity.DetectMastEntity;
import java.util.List;
@@ -9,4 +10,6 @@ public interface DetectMastRepositoryCustom {
public List<DetectMastEntity> findDetectMastList(DetectMastSearch detectMast);
public DetectMastEntity findPnuData(DetectMastSearch detectMast);
Integer updateGeomPnu(List<FeaturePnuDto> list);
}

View File

@@ -2,10 +2,14 @@ package com.kamco.cd.kamcoback.Innopam.postgres.repository;
import static com.kamco.cd.kamcoback.Innopam.postgres.entity.QDetectMastEntity.detectMastEntity;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.kamco.cd.kamcoback.Innopam.dto.DetectMastDto.DetectMastSearch;
import com.kamco.cd.kamcoback.Innopam.dto.DetectMastDto.FeaturePnuDto;
import com.kamco.cd.kamcoback.Innopam.postgres.entity.DetectMastEntity;
import com.querydsl.core.BooleanBuilder;
import com.querydsl.jpa.impl.JPAQueryFactory;
import jakarta.persistence.EntityManager;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.StringUtils;
@@ -15,7 +19,9 @@ import org.springframework.stereotype.Repository;
@RequiredArgsConstructor
public class DetectMastRepositoryImpl implements DetectMastRepositoryCustom {
private final EntityManager em;
private final JPAQueryFactory queryFactory;
private final ObjectMapper objectMapper;
@Override
public List<DetectMastEntity> findDetectMastList(DetectMastSearch detectMast) {
@@ -56,4 +62,33 @@ public class DetectMastRepositoryImpl implements DetectMastRepositoryCustom {
.where(whereBuilder)
.fetchOne();
}
@Override
public Integer updateGeomPnu(List<FeaturePnuDto> list) {
if (list == null || list.isEmpty()) {
return 0;
}
String sql =
"""
UPDATE tb_map_sheet_anal_data_inference_geom g
SET pnu = j.pnu
FROM (
SELECT
(elem->>'featureId')::uuid AS feature_uuid,
(elem->>'pnu')::bigint AS pnu
FROM jsonb_array_elements(CAST(:json AS jsonb)) AS elem
) j
WHERE g.uuid = j.feature_uuid;
""";
String json = "";
try {
json = objectMapper.writeValueAsString(list);
} catch (JsonProcessingException e) {
throw new RuntimeException("PNU 업데이트 실패", e);
}
return em.createNativeQuery(sql).setParameter("json", json).executeUpdate();
}
}

View File

@@ -57,12 +57,34 @@ public class DetectMastService {
String dirPath =
"local".equals(profile)
? "/Users/bokmin/detect/result/2023_2024/4"
? "/Users/bokmin/detect/result/"
+ detectMast.getCprsBfYr()
+ "_"
+ detectMast.getCprsAdYr()
+ "/"
+ detectMast.getDtctSno()
: detectMastCoreService.findPnuData(detectMast);
return extractFeaturePnusRandom(dirPath);
}
@Transactional
public Integer updatePnuData(DetectMastSearch detectMast) {
String dirPath =
"local".equals(profile)
? "/Users/bokmin/detect/result/"
+ detectMast.getCprsBfYr()
+ "_"
+ detectMast.getCprsAdYr()
+ "/"
+ detectMast.getDtctSno()
: detectMastCoreService.findPnuData(detectMast);
List<FeaturePnuDto> list = extractFeaturePnusRandom(dirPath);
return detectMastCoreService.updatePnu(list);
}
/** 하위 폴더까지 .geojson 파일들에서 polygon_id만 뽑음 병렬처리(parallel) 제거: IO + parallel은 거의 항상 느려짐 */
private List<FeaturePnuDto> extractFeaturePnusRandom(String dirPath) {

View File

@@ -6,6 +6,8 @@ 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.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.service.LabelWorkService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
@@ -102,4 +104,36 @@ public class LabelWorkerApiController {
@Parameter(description = "uuid") @PathVariable UUID uuid) {
return ApiResponseDto.ok(labelWorkService.findLabelWorkMngDetail(uuid));
}
@Operation(summary = "작업현황 관리 > 현황 목록 조회", description = "작업현황 관리 > 현황 목록 조회")
@ApiResponses(
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<Page<WorkerState>> 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) {
LabelWorkDto.WorkerStateSearchReq searchReq = new WorkerStateSearchReq();
searchReq.setUserRole(userRole);
searchReq.setSearchVal(searchVal);
searchReq.setPage(page);
searchReq.setSize(size);
return ApiResponseDto.ok(labelWorkService.findlabelWorkStateList(searchReq));
}
}

View File

@@ -8,6 +8,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
import java.time.ZonedDateTime;
import java.util.UUID;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@@ -127,4 +128,84 @@ public class LabelWorkDto {
return PageRequest.of(page, size);
}
}
@Getter
@Setter
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Schema(description = "작업자 통계 응답")
public static class WorkerState {
@Schema(description = "작업자 유형 (LABELER/INSPECTOR)")
private String userRole;
@Schema(description = "작업자 ID (사번)")
private String name;
@Schema(description = "작업자 이름")
private String userId;
@Schema(description = "배정개수")
private Long assignedCnt;
@Schema(description = "완료개수")
private Long doneCnt;
@Schema(description = "Skip개수")
private Long skipCnt;
@Schema(description = "Skip개수")
private Long day3AgoDoneCnt;
@Schema(description = "Skip개수")
private Long day2AgoDoneCnt;
@Schema(description = "Skip개수")
private Long day1AgoDoneCnt;
public Long getremindCnt() {
return this.assignedCnt - this.doneCnt;
}
public double getDoneRate() {
if (this.doneCnt == null || this.assignedCnt == 0) {
return 0.0;
}
return (double) this.doneCnt / this.assignedCnt * 100.0;
}
public String getUserRoleName() {
if (this.userRole.equals("LABELER")) {
return "라벨러";
}
return "검수자";
}
}
@Schema(name = "WorkerStateSearchReq", description = "라벨작업관리 검색 요청")
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public static class WorkerStateSearchReq {
// 페이징 파라미터
@Schema(description = "페이지 번호 (0부터 시작) ", example = "0")
private int page = 0;
@Schema(description = "페이지 크기", example = "20")
private int size = 20;
@Schema(description = "유형", example = "LABELER")
private String userRole;
@Schema(description = "종료일", example = "20261201")
private String searchVal;
public Pageable toPageable() {
return PageRequest.of(page, size);
}
}
}

View File

@@ -6,15 +6,15 @@ import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto;
import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.AllocateInfoDto;
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.LabelingStatDto;
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.WorkerListResponse;
import com.kamco.cd.kamcoback.label.dto.WorkerStatsDto.WorkerStatistics;
import com.kamco.cd.kamcoback.postgres.core.LabelAllocateCoreService;
import java.time.LocalDate;
import java.util.List;
import java.util.Objects;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -23,6 +23,9 @@ import org.springframework.transaction.annotation.Transactional;
@Transactional
public class LabelAllocateService {
private static final int STAGNATION_THRESHOLD = 10; // 정체 판단 기준 (3일 평균 처리량)
private static final int BATCH_SIZE = 100; // 배정 배치 크기
private final LabelAllocateCoreService labelAllocateCoreService;
public LabelAllocateService(LabelAllocateCoreService labelAllocateCoreService) {
@@ -113,10 +116,12 @@ public class LabelAllocateService {
* @param workerType 작업자 유형 (LABELER/INSPECTOR)
* @param search 검색어 (이름 또는 사번)
* @param sortType 정렬 조건
* @param page 페이지 번호 (0부터 시작)
* @param size 페이지 크기
* @return 작업자 목록 및 통계
*/
public WorkerListResponse getWorkerStatistics(
Long analUid, String workerType, String search, String sortType) {
Long analUid, String workerType, String search, String sortType, Integer page, Integer size) {
// 프로젝트 정보 조회 (analUid가 있을 때만)
var projectInfo = labelAllocateCoreService.findProjectInfo(analUid);
@@ -124,7 +129,44 @@ public class LabelAllocateService {
// 작업 진행 현황 조회
var progressInfo = labelAllocateCoreService.findWorkProgressInfo(analUid);
return WorkerListResponse.builder().projectInfo(projectInfo).progressInfo(progressInfo).build();
// 작업자 통계 조회
List<WorkerStatistics> workers =
labelAllocateCoreService.findWorkerStatistics(analUid, workerType, search, sortType);
// 각 작업자별 3일치 처리량 조회
LocalDate today = LocalDate.now();
for (WorkerStatistics worker : workers) {
Long day1Count =
labelAllocateCoreService.findDailyProcessedCount(
worker.getWorkerId(), workerType, today.minusDays(1), analUid);
Long day2Count =
labelAllocateCoreService.findDailyProcessedCount(
worker.getWorkerId(), workerType, today.minusDays(2), analUid);
Long day3Count =
labelAllocateCoreService.findDailyProcessedCount(
worker.getWorkerId(), workerType, today.minusDays(3), analUid);
long average = (day1Count + day2Count + day3Count) / 3;
}
// 페이징 처리
long totalElements = workers.size();
int totalPages = (int) Math.ceil((double) totalElements / size);
int fromIndex = page * size;
int toIndex = Math.min(fromIndex + size, workers.size());
List<WorkerStatistics> pagedWorkers =
(fromIndex < workers.size()) ? workers.subList(fromIndex, toIndex) : List.of();
return WorkerListResponse.builder()
.projectInfo(projectInfo)
.progressInfo(progressInfo)
.workers(pagedWorkers)
.currentPage(page)
.pageSize(size)
.totalElements(totalElements)
.totalPages(totalPages)
.build();
}
public InferenceDetail findInferenceDetail(String uuid) {
@@ -160,20 +202,7 @@ public class LabelAllocateService {
return new ApiResponseDto.ResponseObj(ApiResponseCode.OK, "이관을 완료하였습니다.");
}
public LabelerDetail findUserDetail(String userId, String uuid, String type) {
if (type.equals("LABELER")) {
public LabelerDetail findLabelerDetail(String userId, String uuid) {
return labelAllocateCoreService.findLabelerDetail(userId, uuid);
} else {
return labelAllocateCoreService.findInspectorDetail(userId, uuid);
}
}
public Page<LabelingStatDto> findDaliyList(
LabelAllocateDto.searchReq searchReq, String uuid, String userId, String type) {
if (type.equals("LABELER")) {
return labelAllocateCoreService.findLabelerDailyStat(searchReq, uuid, userId);
} else {
return labelAllocateCoreService.findInspectorDailyStat(searchReq, uuid, userId);
}
}
}

View File

@@ -4,6 +4,7 @@ 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.postgres.core.LabelWorkCoreService;
import java.util.List;
import java.util.UUID;
@@ -49,4 +50,9 @@ public class LabelWorkService {
public List<ChangeDetectYear> getChangeDetectYear() {
return labelWorkCoreService.getChangeDetectYear();
}
public Page<WorkerState> findlabelWorkStateList(LabelWorkDto.WorkerStateSearchReq searchReq) {
return labelWorkCoreService.findlabelWorkStateList(searchReq);
}
}

View File

@@ -4,8 +4,8 @@ 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.postgres.repository.label.LabelWorkRepository;
import com.kamco.cd.kamcoback.postgres.repository.members.MembersRepository;
import java.util.List;
import java.util.UUID;
import lombok.RequiredArgsConstructor;
@@ -17,7 +17,6 @@ import org.springframework.stereotype.Service;
public class LabelWorkCoreService {
private final LabelWorkRepository labelWorkRepository;
private final MembersRepository membersRepository;
/**
* 변화탐지 년도 셀렉트박스 조회
@@ -44,6 +43,11 @@ public class LabelWorkCoreService {
return labelWorkRepository.labelWorkMngList(searchReq);
}
public Page<WorkerState> findlabelWorkStateList(LabelWorkDto.WorkerStateSearchReq searchReq) {
return labelWorkRepository.findlabelWorkStateList(searchReq);
}
;
/**
* 작업배정 정보 조회
*

View File

@@ -5,7 +5,6 @@ import com.kamco.cd.kamcoback.postgres.entity.QMapSheetAnalDataInferenceEntity;
import com.kamco.cd.kamcoback.postgres.entity.QMapSheetAnalDataInferenceGeomEntity;
import com.querydsl.jpa.impl.JPAQueryFactory;
import jakarta.persistence.EntityManager;
import jakarta.persistence.PersistenceContext;
import java.time.ZonedDateTime;
import java.util.List;
import lombok.RequiredArgsConstructor;
@@ -16,8 +15,7 @@ import org.springframework.stereotype.Repository;
public class InferenceResultRepositoryImpl implements InferenceResultRepositoryCustom {
private final JPAQueryFactory queryFactory;
@PersistenceContext private final EntityManager em;
private final EntityManager em;
/** tb_map_sheet_anal_data_inference */
private final QMapSheetAnalDataInferenceEntity inferenceEntity =

View File

@@ -3,6 +3,7 @@ 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.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;
@@ -15,4 +16,6 @@ public interface LabelWorkRepositoryCustom {
public Page<LabelWorkMng> labelWorkMngList(LabelWorkDto.LabelWorkMngSearchReq searchReq);
LabelWorkMngDetail findLabelWorkMngDetail(UUID uuid);
Page<WorkerState> findlabelWorkStateList(LabelWorkDto.WorkerStateSearchReq searchReq);
}

View File

@@ -4,10 +4,12 @@ import static com.kamco.cd.kamcoback.postgres.entity.QLabelingAssignmentEntity.l
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.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.postgres.entity.MapSheetAnalDataGeomEntity;
import com.kamco.cd.kamcoback.postgres.entity.MapSheetAnalInferenceEntity;
import com.querydsl.core.BooleanBuilder;
@@ -20,6 +22,8 @@ import com.querydsl.jpa.JPAExpressions;
import com.querydsl.jpa.impl.JPAQueryFactory;
import jakarta.persistence.EntityManager;
import jakarta.persistence.PersistenceContext;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.List;
import java.util.UUID;
import lombok.extern.slf4j.Slf4j;
@@ -124,7 +128,15 @@ public class LabelWorkRepositoryImpl extends QuerydslRepositorySupport
mapSheetAnalInferenceEntity.stage,
mapSheetAnalDataInferenceEntity.createdDttm.min(),
mapSheetAnalDataInferenceGeomEntity.dataUid.count(),
mapSheetAnalDataInferenceGeomEntity.dataUid.count(),
new CaseBuilder()
.when(
mapSheetAnalDataInferenceGeomEntity
.pnu
.isNotNull()
.and(mapSheetAnalDataInferenceGeomEntity.pnu.ne(0L)))
.then(1L)
.otherwise(0L)
.sum(),
new CaseBuilder()
.when(mapSheetAnalDataInferenceGeomEntity.labelState.eq("STOP"))
.then(1L)
@@ -191,6 +203,131 @@ public class LabelWorkRepositoryImpl extends QuerydslRepositorySupport
return new PageImpl<>(foundContent, pageable, total);
}
@Override
public Page<WorkerState> findlabelWorkStateList(LabelWorkDto.WorkerStateSearchReq searchReq) {
Pageable pageable = PageRequest.of(searchReq.getPage(), searchReq.getSize());
BooleanBuilder whereBuilder = new BooleanBuilder();
BooleanBuilder whereSubBuilder = new BooleanBuilder();
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()) {
whereSubBuilder.and(memberEntity.userRole.eq(searchReq.getUserRole()));
}
if (searchReq.getSearchVal() != null && !searchReq.getSearchVal().isEmpty()) {
whereSubBuilder.and(
Expressions.stringTemplate("{0}", memberEntity.userId)
.likeIgnoreCase("%" + searchReq.getSearchVal() + "%")
.or(
Expressions.stringTemplate("{0}", memberEntity.name)
.likeIgnoreCase("%" + searchReq.getSearchVal() + "%")));
}
whereSubBuilder.and(labelingAssignmentEntity.workerUid.eq(memberEntity.userId));
List<WorkerState> 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();
/*
Long countQuery =
queryFactory
.select(labelingAssignmentEntity.workerUid.count())
.from(labelingAssignmentEntity)
.where(whereBuilder)
.fetchOne();
*/
Long total =
queryFactory
.select(mapSheetAnalInferenceEntity.uuid.countDistinct())
.from(mapSheetAnalInferenceEntity)
.innerJoin(mapSheetAnalDataInferenceEntity)
.on(whereSubDataBuilder)
.innerJoin(mapSheetAnalDataInferenceGeomEntity)
.on(whereSubBuilder)
.where(whereBuilder)
.fetchOne();
return new PageImpl<>(foundContent, pageable, total);
}
/**
* 작업배정 상세조회
*