Merge pull request 'feat/dev_251201' (#137) from feat/dev_251201 into develop
Reviewed-on: https://kamco.gitea.gs.dabeeo.com/dabeeo/kamco-dabeeo-backoffice/pulls/137
This commit is contained in:
@@ -4,7 +4,10 @@ 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.UserList;
|
||||
import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.searchReq;
|
||||
import com.kamco.cd.kamcoback.label.dto.WorkerStatsDto.ProjectInfo;
|
||||
import com.kamco.cd.kamcoback.label.dto.WorkerStatsDto.WorkProgressInfo;
|
||||
import com.kamco.cd.kamcoback.label.dto.WorkerStatsDto.WorkerStatistics;
|
||||
import com.kamco.cd.kamcoback.postgres.entity.LabelingAssignmentEntity;
|
||||
@@ -13,6 +16,7 @@ import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@@ -26,18 +30,12 @@ public class LabelAllocateCoreService {
|
||||
return labelAllocateRepository.fetchNextIds(lastId, batchSize, compareYyyy, targetYyyy, stage);
|
||||
}
|
||||
|
||||
public void assignOwner(
|
||||
List<AllocateInfoDto> ids,
|
||||
String userId,
|
||||
Integer compareYyyy,
|
||||
Integer targetYyyy,
|
||||
Integer stage) {
|
||||
labelAllocateRepository.assignOwner(ids, userId, compareYyyy, targetYyyy, stage);
|
||||
public void assignOwner(List<AllocateInfoDto> ids, String userId, Long analUid) {
|
||||
labelAllocateRepository.assignOwner(ids, userId, analUid);
|
||||
}
|
||||
|
||||
public List<LabelAllocateDto.Basic> findAssignedLabelerList(
|
||||
Integer compareYyyy, Integer targetYyyy, Integer stage) {
|
||||
return labelAllocateRepository.findAssignedLabelerList(compareYyyy, targetYyyy, stage).stream()
|
||||
public List<LabelAllocateDto.Basic> findAssignedLabelerList(Long analUid) {
|
||||
return labelAllocateRepository.findAssignedLabelerList(analUid).stream()
|
||||
.map(LabelingAssignmentEntity::toDto)
|
||||
.toList();
|
||||
}
|
||||
@@ -54,14 +52,13 @@ public class LabelAllocateCoreService {
|
||||
return labelAllocateRepository.availUserList(role);
|
||||
}
|
||||
|
||||
public ProjectInfo findProjectInfo(Long analUid) {
|
||||
return labelAllocateRepository.findProjectInfo(analUid);
|
||||
}
|
||||
|
||||
public List<WorkerStatistics> findWorkerStatistics(
|
||||
Long analUid,
|
||||
String workerType,
|
||||
String searchName,
|
||||
String searchEmployeeNo,
|
||||
String sortType) {
|
||||
return labelAllocateRepository.findWorkerStatistics(
|
||||
analUid, workerType, searchName, searchEmployeeNo, sortType);
|
||||
Long analUid, String workerType, String search, String sortType) {
|
||||
return labelAllocateRepository.findWorkerStatistics(analUid, workerType, search, sortType);
|
||||
}
|
||||
|
||||
public WorkProgressInfo findWorkProgressInfo(Long analUid) {
|
||||
@@ -77,13 +74,8 @@ public class LabelAllocateCoreService {
|
||||
labelAllocateRepository.assignInspectorBulk(assignmentUids, inspectorUid);
|
||||
}
|
||||
|
||||
public InferenceDetail findInferenceDetail(
|
||||
Integer compareYyyy, Integer targetYyyy, Integer stage) {
|
||||
return labelAllocateRepository.findInferenceDetail(compareYyyy, targetYyyy, stage);
|
||||
}
|
||||
|
||||
public Long findLabelUnCompleteCnt(Long analUid) {
|
||||
return labelAllocateRepository.findLabelUnCompleteCnt(analUid);
|
||||
public InferenceDetail findInferenceDetail(String uuid) {
|
||||
return labelAllocateRepository.findInferenceDetail(uuid);
|
||||
}
|
||||
|
||||
public List<Long> fetchNextMoveIds(
|
||||
@@ -96,8 +88,29 @@ public class LabelAllocateCoreService {
|
||||
labelAllocateRepository.assignOwnerMove(sub, userId);
|
||||
}
|
||||
|
||||
public LabelerDetail findLabelerDetail(
|
||||
String userId, Integer compareYyyy, Integer targetYyyy, Integer stage) {
|
||||
return labelAllocateRepository.findLabelerDetail(userId, compareYyyy, targetYyyy, stage);
|
||||
public LabelerDetail findLabelerDetail(String userId, String uuid) {
|
||||
return labelAllocateRepository.findLabelerDetail(userId, uuid);
|
||||
}
|
||||
|
||||
public Long findMapSheetAnalInferenceUid(Integer compareYyyy, Integer targetYyyy, Integer stage) {
|
||||
return labelAllocateRepository.findMapSheetAnalInferenceUid(compareYyyy, targetYyyy, stage);
|
||||
}
|
||||
|
||||
public void insertInspector(Long analUid, String inspector) {
|
||||
labelAllocateRepository.insertInspector(analUid, inspector);
|
||||
}
|
||||
|
||||
public Page<LabelingStatDto> findLabelerDailyStat(
|
||||
searchReq searchReq, String uuid, String userId) {
|
||||
return labelAllocateRepository.findLabelerDailyStat(searchReq, uuid, userId);
|
||||
}
|
||||
|
||||
public Page<LabelingStatDto> findInspectorDailyStat(
|
||||
searchReq searchReq, String uuid, String userId) {
|
||||
return labelAllocateRepository.findInspectorDailyStat(searchReq, uuid, userId);
|
||||
}
|
||||
|
||||
public LabelerDetail findInspectorDetail(String userId, String uuid) {
|
||||
return labelAllocateRepository.findInspectorDetail(userId, uuid);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +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.postgres.repository.label.LabelWorkRepository;
|
||||
import com.kamco.cd.kamcoback.postgres.repository.members.MembersRepository;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -12,8 +17,40 @@ import org.springframework.stereotype.Service;
|
||||
public class LabelWorkCoreService {
|
||||
|
||||
private final LabelWorkRepository labelWorkRepository;
|
||||
private final MembersRepository membersRepository;
|
||||
|
||||
/**
|
||||
* 변화탐지 년도 셀렉트박스 조회
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public List<ChangeDetectYear> getChangeDetectYear() {
|
||||
return labelWorkRepository.findChangeDetectYearList().stream()
|
||||
.map(
|
||||
e ->
|
||||
new ChangeDetectYear(
|
||||
e.getCompareYyyy() + "-" + e.getTargetYyyy(),
|
||||
e.getCompareYyyy() + "-" + e.getTargetYyyy()))
|
||||
.toList();
|
||||
}
|
||||
|
||||
/**
|
||||
* 라벨링작업 관리 목록 조회
|
||||
*
|
||||
* @param searchReq
|
||||
* @return
|
||||
*/
|
||||
public Page<LabelWorkMng> labelWorkMngList(LabelWorkDto.LabelWorkMngSearchReq searchReq) {
|
||||
return labelWorkRepository.labelWorkMngList(searchReq);
|
||||
}
|
||||
|
||||
/**
|
||||
* 작업배정 정보 조회
|
||||
*
|
||||
* @param uuid
|
||||
* @return
|
||||
*/
|
||||
public LabelWorkMngDetail findLabelWorkMngDetail(UUID uuid) {
|
||||
return labelWorkRepository.findLabelWorkMngDetail(uuid);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.Table;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.UUID;
|
||||
|
||||
@Entity
|
||||
@@ -40,6 +41,15 @@ public class LabelingAssignmentEntity extends CommonDateEntity {
|
||||
@Column(name = "anal_uid")
|
||||
private Long analUid;
|
||||
|
||||
@Column(name = "inspect_state")
|
||||
private String inspectState;
|
||||
|
||||
@Column(name = "work_stat_dttm")
|
||||
private ZonedDateTime workStatDttm;
|
||||
|
||||
@Column(name = "inspect_stat_dttm")
|
||||
private ZonedDateTime inspectStatDttm;
|
||||
|
||||
public LabelAllocateDto.Basic toDto() {
|
||||
return new LabelAllocateDto.Basic(
|
||||
this.assignmentUid,
|
||||
@@ -52,6 +62,9 @@ public class LabelingAssignmentEntity extends CommonDateEntity {
|
||||
this.learnGeomUid,
|
||||
this.analUid,
|
||||
super.getCreatedDate(),
|
||||
super.getModifiedDate());
|
||||
super.getModifiedDate(),
|
||||
this.inspectState,
|
||||
this.workStatDttm,
|
||||
this.inspectStatDttm);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.kamco.cd.kamcoback.postgres.entity;
|
||||
|
||||
import com.kamco.cd.kamcoback.label.dto.LabelInspectorDto;
|
||||
import com.kamco.cd.kamcoback.postgres.CommonDateEntity;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.Table;
|
||||
import java.util.UUID;
|
||||
|
||||
@Entity
|
||||
@Table(name = "tb_labeling_inspector")
|
||||
public class LabelingInspectorEntity extends CommonDateEntity {
|
||||
|
||||
@Id
|
||||
@Column(name = "operator_uid")
|
||||
private UUID operatorUid;
|
||||
|
||||
@Column(name = "anal_uid")
|
||||
private Long analUid;
|
||||
|
||||
@Column(name = "inspector_uid")
|
||||
private String inspectorUid;
|
||||
|
||||
public LabelInspectorDto.Basic toDto() {
|
||||
return new LabelInspectorDto.Basic(
|
||||
this.operatorUid,
|
||||
this.analUid,
|
||||
this.inspectorUid,
|
||||
super.getCreatedDate(),
|
||||
super.getModifiedDate());
|
||||
}
|
||||
}
|
||||
@@ -36,18 +36,29 @@ public class InferenceResultRepositoryImpl implements InferenceResultRepositoryC
|
||||
String sql =
|
||||
"""
|
||||
INSERT INTO tb_map_sheet_anal_inference (
|
||||
compare_yyyy,
|
||||
target_yyyy,
|
||||
stage,
|
||||
anal_title
|
||||
)
|
||||
SELECT
|
||||
r.input1 AS compare_yyyy,
|
||||
r.input2 AS target_yyyy,
|
||||
r.stage,
|
||||
CONCAT(r.stage ,'_', r.input1 ,'_', r.input2) AS anal_title
|
||||
FROM inference_results r
|
||||
GROUP BY r.stage, r.input1, r.input2;
|
||||
stage,
|
||||
compare_yyyy,
|
||||
target_yyyy,
|
||||
anal_title,
|
||||
detecting_cnt,
|
||||
created_dttm,
|
||||
updated_dttm
|
||||
)
|
||||
SELECT
|
||||
r.stage,
|
||||
r.input1 AS compare_yyyy,
|
||||
r.input2 AS target_yyyy,
|
||||
CONCAT(r.stage, '_', r.input1, '_', r.input2) AS anal_title,
|
||||
COUNT(*) AS detecting_cnt,
|
||||
now(),
|
||||
now()
|
||||
FROM inference_results r
|
||||
GROUP BY r.stage, r.input1, r.input2
|
||||
ON CONFLICT (stage, compare_yyyy, target_yyyy)
|
||||
DO UPDATE SET
|
||||
detecting_cnt = EXCLUDED.detecting_cnt,
|
||||
anal_title = EXCLUDED.anal_title,
|
||||
updated_dttm = now()
|
||||
""";
|
||||
|
||||
return em.createNativeQuery(sql).executeUpdate();
|
||||
@@ -67,30 +78,42 @@ public class InferenceResultRepositoryImpl implements InferenceResultRepositoryC
|
||||
String sql =
|
||||
"""
|
||||
INSERT INTO tb_map_sheet_anal_data_inference (
|
||||
anal_uid,
|
||||
stage,
|
||||
compare_yyyy,
|
||||
target_yyyy,
|
||||
map_sheet_num,
|
||||
created_dttm,
|
||||
updated_dttm,
|
||||
detecting_cnt,
|
||||
file_created_yn,
|
||||
detecting_cnt
|
||||
created_dttm,
|
||||
updated_dttm
|
||||
)
|
||||
SELECT
|
||||
ai.id AS anal_uid,
|
||||
r.stage,
|
||||
r.input1 AS compare_yyyy,
|
||||
r.input2 AS target_yyyy,
|
||||
r.map_id AS map_sheet_num,
|
||||
now() AS created_dttm,
|
||||
now() AS updated_dttm,
|
||||
false AS file_created_yn,
|
||||
count(*) AS detecting_cnt
|
||||
COUNT(*) AS detecting_cnt,
|
||||
false AS file_created_yn,
|
||||
now(),
|
||||
now()
|
||||
FROM inference_results r
|
||||
GROUP BY r.stage, r.input1, r.input2, r.map_id
|
||||
JOIN tb_map_sheet_anal_inference ai
|
||||
ON ai.stage = r.stage
|
||||
AND ai.compare_yyyy = r.input1
|
||||
AND ai.target_yyyy = r.input2
|
||||
GROUP BY
|
||||
ai.id,
|
||||
r.stage,
|
||||
r.input1,
|
||||
r.input2,
|
||||
r.map_id
|
||||
ON CONFLICT (stage, compare_yyyy, target_yyyy, map_sheet_num)
|
||||
DO UPDATE SET
|
||||
updated_dttm = now(),
|
||||
detecting_cnt = EXCLUDED.detecting_cnt
|
||||
anal_uid = EXCLUDED.anal_uid,
|
||||
detecting_cnt = EXCLUDED.detecting_cnt,
|
||||
updated_dttm = now()
|
||||
""";
|
||||
|
||||
return em.createNativeQuery(sql).executeUpdate();
|
||||
@@ -109,46 +132,70 @@ public class InferenceResultRepositoryImpl implements InferenceResultRepositoryC
|
||||
|
||||
String sql =
|
||||
"""
|
||||
INSERT INTO tb_map_sheet_anal_data_inference_geom (
|
||||
uuid, stage, cd_prob, compare_yyyy, target_yyyy, map_sheet_num,
|
||||
class_before_cd, class_before_prob, class_after_cd, class_after_prob,
|
||||
geom, area, data_uid, created_dttm, updated_dttm,
|
||||
file_created_yn
|
||||
INSERT INTO tb_map_sheet_anal_data_inference_geom (
|
||||
uuid,
|
||||
stage,
|
||||
cd_prob,
|
||||
compare_yyyy,
|
||||
target_yyyy,
|
||||
map_sheet_num,
|
||||
class_before_cd,
|
||||
class_before_prob,
|
||||
class_after_cd,
|
||||
class_after_prob,
|
||||
geom,
|
||||
area,
|
||||
data_uid,
|
||||
file_created_yn,
|
||||
created_dttm,
|
||||
updated_dttm
|
||||
)
|
||||
SELECT
|
||||
x.uuid, x.stage, x.cd_prob, x.compare_yyyy, x.target_yyyy, x.map_sheet_num,
|
||||
x.class_before_cd, x.class_before_prob, x.class_after_cd, x.class_after_prob,
|
||||
x.geom, x.area, x.data_uid, x.created_dttm, x.updated_dttm,
|
||||
false AS file_created_yn
|
||||
x.uuid,
|
||||
x.stage,
|
||||
x.cd_prob,
|
||||
x.compare_yyyy,
|
||||
x.target_yyyy,
|
||||
x.map_sheet_num,
|
||||
x.class_before_cd,
|
||||
x.class_before_prob,
|
||||
x.class_after_cd,
|
||||
x.class_after_prob,
|
||||
x.geom,
|
||||
x.area,
|
||||
x.data_uid,
|
||||
false,
|
||||
x.created_dttm,
|
||||
x.updated_dttm
|
||||
FROM (
|
||||
SELECT DISTINCT ON (r.uuid)
|
||||
r.uuid,
|
||||
r.stage,
|
||||
r.cd_prob,
|
||||
r.input1 AS compare_yyyy,
|
||||
r.input2 AS target_yyyy,
|
||||
r.map_id AS map_sheet_num,
|
||||
r.before_class AS class_before_cd,
|
||||
r.before_probability AS class_before_prob,
|
||||
r.after_class AS class_after_cd,
|
||||
r.after_probability AS class_after_prob,
|
||||
CASE
|
||||
WHEN r.geometry IS NULL THEN NULL
|
||||
WHEN left(r.geometry, 2) = '01'
|
||||
THEN ST_SetSRID(ST_GeomFromWKB(decode(r.geometry, 'hex')), 5186)
|
||||
ELSE ST_GeomFromText(r.geometry, 5186)
|
||||
END AS geom,
|
||||
r.area,
|
||||
di.data_uid,
|
||||
r.created_dttm,
|
||||
r.updated_dttm
|
||||
FROM inference_results r
|
||||
JOIN tb_map_sheet_anal_data_inference di
|
||||
ON di.stage = r.stage
|
||||
AND di.compare_yyyy = r.input1
|
||||
AND di.target_yyyy = r.input2
|
||||
AND di.map_sheet_num = r.map_id
|
||||
ORDER BY r.uuid, r.updated_dttm DESC NULLS LAST, r.uid DESC
|
||||
SELECT DISTINCT ON (r.uuid)
|
||||
r.uuid,
|
||||
r.stage,
|
||||
r.cd_prob,
|
||||
r.input1 AS compare_yyyy,
|
||||
r.input2 AS target_yyyy,
|
||||
r.map_id AS map_sheet_num,
|
||||
r.before_class AS class_before_cd,
|
||||
r.before_probability AS class_before_prob,
|
||||
r.after_class AS class_after_cd,
|
||||
r.after_probability AS class_after_prob,
|
||||
CASE
|
||||
WHEN r.geometry IS NULL THEN NULL
|
||||
WHEN LEFT(r.geometry, 2) = '01'
|
||||
THEN ST_SetSRID(ST_GeomFromWKB(decode(r.geometry, 'hex')), 5186)
|
||||
ELSE ST_GeomFromText(r.geometry, 5186)
|
||||
END AS geom,
|
||||
r.area,
|
||||
di.data_uid,
|
||||
r.created_dttm,
|
||||
r.updated_dttm
|
||||
FROM inference_results r
|
||||
JOIN tb_map_sheet_anal_data_inference di
|
||||
ON di.stage = r.stage
|
||||
AND di.compare_yyyy = r.input1
|
||||
AND di.target_yyyy = r.input2
|
||||
AND di.map_sheet_num = r.map_id
|
||||
ORDER BY r.uuid, r.updated_dttm DESC NULLS LAST, r.uid DESC
|
||||
) x
|
||||
ON CONFLICT (uuid)
|
||||
DO UPDATE SET
|
||||
|
||||
@@ -1,30 +1,28 @@
|
||||
package com.kamco.cd.kamcoback.postgres.repository.label;
|
||||
|
||||
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.UserList;
|
||||
import com.kamco.cd.kamcoback.label.dto.WorkerStatsDto.ProjectInfo;
|
||||
import com.kamco.cd.kamcoback.label.dto.WorkerStatsDto.WorkProgressInfo;
|
||||
import com.kamco.cd.kamcoback.label.dto.WorkerStatsDto.WorkerStatistics;
|
||||
import com.kamco.cd.kamcoback.postgres.entity.LabelingAssignmentEntity;
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import org.springframework.data.domain.Page;
|
||||
|
||||
public interface LabelAllocateRepositoryCustom {
|
||||
|
||||
List<AllocateInfoDto> fetchNextIds(
|
||||
Long lastId, Long batchSize, Integer compareYyyy, Integer targetYyyy, Integer stage);
|
||||
|
||||
void assignOwner(
|
||||
List<AllocateInfoDto> ids,
|
||||
String userId,
|
||||
Integer compareYyyy,
|
||||
Integer targetYyyy,
|
||||
Integer stage);
|
||||
void assignOwner(List<AllocateInfoDto> ids, String userId, Long analUid);
|
||||
|
||||
List<LabelingAssignmentEntity> findAssignedLabelerList(
|
||||
Integer compareYyyy, Integer targetYyyy, Integer stage);
|
||||
List<LabelingAssignmentEntity> findAssignedLabelerList(Long analUid);
|
||||
|
||||
Long findLabelUnAssignedCnt(Integer stage, Integer compareYyyy, Integer targetYyyy);
|
||||
|
||||
@@ -32,9 +30,12 @@ public interface LabelAllocateRepositoryCustom {
|
||||
|
||||
List<UserList> availUserList(String role);
|
||||
|
||||
// 프로젝트 정보 조회
|
||||
ProjectInfo findProjectInfo(Long analUid);
|
||||
|
||||
// 작업자 통계 조회
|
||||
List<WorkerStatistics> findWorkerStatistics(
|
||||
Long analUid, String workerType, String searchName, String searchEmployeeNo, String sortType);
|
||||
Long analUid, String workerType, String search, String sortType);
|
||||
|
||||
// 작업 진행 현황 조회
|
||||
WorkProgressInfo findWorkProgressInfo(Long analUid);
|
||||
@@ -44,15 +45,24 @@ public interface LabelAllocateRepositoryCustom {
|
||||
|
||||
void assignInspectorBulk(List<UUID> assignmentUids, String inspectorUid);
|
||||
|
||||
InferenceDetail findInferenceDetail(Integer compareYyyy, Integer targetYyyy, Integer stage);
|
||||
InferenceDetail findInferenceDetail(String uuid);
|
||||
|
||||
public List<Long> fetchNextMoveIds(
|
||||
List<Long> fetchNextMoveIds(
|
||||
Long lastId, Long batchSize, Integer compareYyyy, Integer targetYyyy, Integer stage);
|
||||
|
||||
Long findLabelUnCompleteCnt(Long analUid);
|
||||
|
||||
void assignOwnerMove(List<Long> sub, String userId);
|
||||
|
||||
LabelerDetail findLabelerDetail(
|
||||
String userId, Integer compareYyyy, Integer targetYyyy, Integer stage);
|
||||
LabelerDetail findLabelerDetail(String userId, String uuid);
|
||||
|
||||
Long findMapSheetAnalInferenceUid(Integer compareYyyy, Integer targetYyyy, Integer stage);
|
||||
|
||||
void insertInspector(Long analUid, String inspector);
|
||||
|
||||
Page<LabelingStatDto> findLabelerDailyStat(
|
||||
LabelAllocateDto.searchReq searchReq, String uuid, String userId);
|
||||
|
||||
Page<LabelingStatDto> findInspectorDailyStat(
|
||||
LabelAllocateDto.searchReq searchReq, String uuid, String userId);
|
||||
|
||||
LabelerDetail findInspectorDetail(String userId, String uuid);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
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.QMapSheetAnalDataInferenceEntity.mapSheetAnalDataInferenceEntity;
|
||||
import static com.kamco.cd.kamcoback.postgres.entity.QLabelingInspectorEntity.labelingInspectorEntity;
|
||||
import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetAnalDataInferenceGeomEntity.mapSheetAnalDataInferenceGeomEntity;
|
||||
import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetAnalEntity.mapSheetAnalEntity;
|
||||
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.LabelAllocateDto;
|
||||
@@ -12,13 +13,15 @@ import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.InferenceDetail;
|
||||
import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.InspectState;
|
||||
import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.LabelState;
|
||||
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.UserList;
|
||||
import com.kamco.cd.kamcoback.label.dto.WorkerStatsDto.ProjectInfo;
|
||||
import com.kamco.cd.kamcoback.label.dto.WorkerStatsDto.WorkProgressInfo;
|
||||
import com.kamco.cd.kamcoback.label.dto.WorkerStatsDto.WorkerStatistics;
|
||||
import com.kamco.cd.kamcoback.postgres.entity.LabelingAssignmentEntity;
|
||||
import com.kamco.cd.kamcoback.postgres.entity.MapSheetAnalDataInferenceEntity;
|
||||
import com.kamco.cd.kamcoback.postgres.entity.MapSheetAnalEntity;
|
||||
import com.kamco.cd.kamcoback.postgres.entity.MapSheetAnalInferenceEntity;
|
||||
import com.kamco.cd.kamcoback.postgres.entity.QMemberEntity;
|
||||
import com.querydsl.core.types.Expression;
|
||||
import com.querydsl.core.types.Projections;
|
||||
import com.querydsl.core.types.dsl.BooleanExpression;
|
||||
import com.querydsl.core.types.dsl.CaseBuilder;
|
||||
@@ -34,11 +37,17 @@ import java.time.LocalDate;
|
||||
import java.time.LocalTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageImpl;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Slf4j
|
||||
@@ -73,27 +82,17 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
|
||||
}
|
||||
|
||||
@Override
|
||||
public void assignOwner(
|
||||
List<AllocateInfoDto> ids,
|
||||
String userId,
|
||||
Integer compareYyyy,
|
||||
Integer targetYyyy,
|
||||
Integer stage) {
|
||||
public void assignOwner(List<AllocateInfoDto> ids, String userId, Long analUid) {
|
||||
|
||||
// analUid로 분석 정보 조회
|
||||
MapSheetAnalDataInferenceEntity analEntity =
|
||||
MapSheetAnalInferenceEntity analEntity =
|
||||
queryFactory
|
||||
.selectFrom(mapSheetAnalDataInferenceEntity)
|
||||
.where(
|
||||
mapSheetAnalDataInferenceEntity.compareYyyy.eq(compareYyyy),
|
||||
mapSheetAnalDataInferenceEntity.targetYyyy.eq(targetYyyy),
|
||||
mapSheetAnalDataInferenceEntity.stage.eq(stage))
|
||||
.orderBy(mapSheetAnalDataInferenceEntity.analUid.asc())
|
||||
.limit(1)
|
||||
.selectFrom(mapSheetAnalInferenceEntity)
|
||||
.where(mapSheetAnalInferenceEntity.id.eq(analUid))
|
||||
.fetchOne();
|
||||
|
||||
if (Objects.isNull(analEntity)) {
|
||||
throw new EntityNotFoundException("MapSheetAnalEntity not found for analUid: ");
|
||||
throw new EntityNotFoundException("MapSheetAnalInferenceEntity not found for analUid: ");
|
||||
}
|
||||
|
||||
// data_geom 테이블에 label state 를 ASSIGNED 로 update
|
||||
@@ -125,7 +124,7 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
|
||||
.setParameter(3, userId)
|
||||
.setParameter(4, LabelState.ASSIGNED.getId())
|
||||
.setParameter(5, info.getMapSheetNum())
|
||||
.setParameter(6, analEntity.getAnalUid())
|
||||
.setParameter(6, analEntity.getId())
|
||||
.executeUpdate();
|
||||
}
|
||||
|
||||
@@ -134,28 +133,22 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LabelingAssignmentEntity> findAssignedLabelerList(
|
||||
Integer compareYyyy, Integer targetYyyy, Integer stage) {
|
||||
public List<LabelingAssignmentEntity> findAssignedLabelerList(Long analUid) {
|
||||
// analUid로 분석 정보 조회
|
||||
MapSheetAnalDataInferenceEntity analEntity =
|
||||
MapSheetAnalInferenceEntity analEntity =
|
||||
queryFactory
|
||||
.selectFrom(mapSheetAnalDataInferenceEntity)
|
||||
.where(
|
||||
mapSheetAnalDataInferenceEntity.compareYyyy.eq(compareYyyy),
|
||||
mapSheetAnalDataInferenceEntity.targetYyyy.eq(targetYyyy),
|
||||
mapSheetAnalDataInferenceEntity.stage.eq(stage))
|
||||
.orderBy(mapSheetAnalDataInferenceEntity.analUid.asc())
|
||||
.limit(1)
|
||||
.selectFrom(mapSheetAnalInferenceEntity)
|
||||
.where(mapSheetAnalInferenceEntity.id.eq(analUid))
|
||||
.fetchOne();
|
||||
|
||||
if (Objects.isNull(analEntity)) {
|
||||
throw new EntityNotFoundException("MapSheetAnalEntity not found for analUid: ");
|
||||
throw new EntityNotFoundException("mapSheetAnalInferenceEntity not found for analUid: ");
|
||||
}
|
||||
|
||||
return queryFactory
|
||||
.selectFrom(labelingAssignmentEntity)
|
||||
.where(
|
||||
labelingAssignmentEntity.analUid.eq(analEntity.getAnalUid()),
|
||||
labelingAssignmentEntity.analUid.eq(analEntity.getId()),
|
||||
labelingAssignmentEntity.workState.eq(LabelState.ASSIGNED.getId()),
|
||||
labelingAssignmentEntity.inspectorUid.isNull())
|
||||
.orderBy(labelingAssignmentEntity.workerUid.asc())
|
||||
@@ -204,11 +197,7 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
|
||||
|
||||
@Override
|
||||
public List<WorkerStatistics> findWorkerStatistics(
|
||||
Long analUid,
|
||||
String workerType,
|
||||
String searchName,
|
||||
String searchEmployeeNo,
|
||||
String sortType) {
|
||||
Long analUid, String workerType, String search, String sortType) {
|
||||
|
||||
// 작업자 유형에 따른 필드 선택
|
||||
StringExpression workerIdField =
|
||||
@@ -221,14 +210,11 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
|
||||
? labelingAssignmentEntity.inspectorUid.isNotNull()
|
||||
: labelingAssignmentEntity.workerUid.isNotNull();
|
||||
|
||||
// 검색 조건
|
||||
// 검색 조건 (이름 또는 사번으로 검색)
|
||||
BooleanExpression searchCondition = null;
|
||||
if (searchName != null && !searchName.isEmpty()) {
|
||||
searchCondition = memberEntity.name.contains(searchName);
|
||||
}
|
||||
if (searchEmployeeNo != null && !searchEmployeeNo.isEmpty()) {
|
||||
BooleanExpression empCondition = memberEntity.employeeNo.contains(searchEmployeeNo);
|
||||
searchCondition = searchCondition == null ? empCondition : searchCondition.and(empCondition);
|
||||
if (search != null && !search.isEmpty()) {
|
||||
searchCondition =
|
||||
memberEntity.name.contains(search).or(memberEntity.employeeNo.contains(search));
|
||||
}
|
||||
|
||||
// 완료, 스킵, 남은 작업 계산
|
||||
@@ -258,6 +244,9 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
|
||||
.sum();
|
||||
|
||||
// 기본 통계 조회 쿼리
|
||||
BooleanExpression analUidCondition =
|
||||
analUid != null ? labelingAssignmentEntity.analUid.eq(analUid) : null;
|
||||
|
||||
var baseQuery =
|
||||
queryFactory
|
||||
.select(
|
||||
@@ -274,7 +263,7 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
|
||||
"REVIEWER".equals(workerType)
|
||||
? memberEntity.employeeNo.eq(labelingAssignmentEntity.inspectorUid)
|
||||
: memberEntity.employeeNo.eq(labelingAssignmentEntity.workerUid))
|
||||
.where(labelingAssignmentEntity.analUid.eq(analUid), workerCondition, searchCondition)
|
||||
.where(analUidCondition, workerCondition, searchCondition)
|
||||
.groupBy(workerIdField, memberEntity.name);
|
||||
|
||||
// 정렬 조건 적용
|
||||
@@ -286,6 +275,12 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
|
||||
case "REMAINING_ASC":
|
||||
baseQuery.orderBy(remainingSum.asc());
|
||||
break;
|
||||
case "COMPLETED_DESC":
|
||||
baseQuery.orderBy(completedSum.desc());
|
||||
break;
|
||||
case "COMPLETED_ASC":
|
||||
baseQuery.orderBy(completedSum.asc());
|
||||
break;
|
||||
case "NAME_ASC":
|
||||
baseQuery.orderBy(memberEntity.name.asc());
|
||||
break;
|
||||
@@ -321,85 +316,102 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
|
||||
|
||||
@Override
|
||||
public WorkProgressInfo findWorkProgressInfo(Long analUid) {
|
||||
BooleanExpression analUidCondition =
|
||||
analUid != null ? labelingAssignmentEntity.analUid.eq(analUid) : null;
|
||||
|
||||
// 전체 배정 건수
|
||||
Long totalAssigned =
|
||||
queryFactory
|
||||
.select(labelingAssignmentEntity.count())
|
||||
.from(labelingAssignmentEntity)
|
||||
.where(labelingAssignmentEntity.analUid.eq(analUid))
|
||||
.where(analUidCondition)
|
||||
.fetchOne();
|
||||
|
||||
// 완료 + 스킵 건수
|
||||
Long completedCount =
|
||||
// === 라벨링 통계 ===
|
||||
// 라벨링 완료: LABEL_FIN, TEST_ING, DONE (검수 포함)
|
||||
Long labelingCompleted =
|
||||
queryFactory
|
||||
.select(labelingAssignmentEntity.count())
|
||||
.from(labelingAssignmentEntity)
|
||||
.where(
|
||||
labelingAssignmentEntity.analUid.eq(analUid),
|
||||
labelingAssignmentEntity.workState.in("DONE", "SKIP"))
|
||||
analUidCondition,
|
||||
labelingAssignmentEntity.workState.in("LABEL_FIN", "TEST_ING", "DONE"))
|
||||
.fetchOne();
|
||||
|
||||
// 투입된 라벨러 수 (고유한 worker_uid 수)
|
||||
// 스킵 건수
|
||||
Long skipCount =
|
||||
queryFactory
|
||||
.select(labelingAssignmentEntity.count())
|
||||
.from(labelingAssignmentEntity)
|
||||
.where(analUidCondition, labelingAssignmentEntity.workState.eq("SKIP"))
|
||||
.fetchOne();
|
||||
|
||||
// 투입된 라벨러 수
|
||||
Long labelerCount =
|
||||
queryFactory
|
||||
.select(labelingAssignmentEntity.workerUid.countDistinct())
|
||||
.from(labelingAssignmentEntity)
|
||||
.where(
|
||||
labelingAssignmentEntity.analUid.eq(analUid),
|
||||
labelingAssignmentEntity.workerUid.isNotNull())
|
||||
.where(analUidCondition, labelingAssignmentEntity.workerUid.isNotNull())
|
||||
.fetchOne();
|
||||
|
||||
// 남은 라벨링 작업 데이터 수
|
||||
Long remainingLabelCount =
|
||||
// === 검수 통계 ===
|
||||
// 검수 완료: DONE만
|
||||
Long inspectionCompleted =
|
||||
queryFactory
|
||||
.select(labelingAssignmentEntity.count())
|
||||
.from(labelingAssignmentEntity)
|
||||
.where(
|
||||
labelingAssignmentEntity.analUid.eq(analUid),
|
||||
labelingAssignmentEntity.workerUid.isNotNull(),
|
||||
labelingAssignmentEntity.workState.notIn("DONE", "SKIP"))
|
||||
.where(analUidCondition, labelingAssignmentEntity.workState.eq("DONE"))
|
||||
.fetchOne();
|
||||
|
||||
// 투입된 검수자 수 (고유한 inspector_uid 수)
|
||||
// 투입된 검수자 수
|
||||
Long inspectorCount =
|
||||
queryFactory
|
||||
.select(labelingAssignmentEntity.inspectorUid.countDistinct())
|
||||
.from(labelingAssignmentEntity)
|
||||
.where(
|
||||
labelingAssignmentEntity.analUid.eq(analUid),
|
||||
labelingAssignmentEntity.inspectorUid.isNotNull())
|
||||
.where(analUidCondition, labelingAssignmentEntity.inspectorUid.isNotNull())
|
||||
.fetchOne();
|
||||
|
||||
// 남은 검수 작업 데이터 수
|
||||
Long remainingInspectCount =
|
||||
queryFactory
|
||||
.select(labelingAssignmentEntity.count())
|
||||
.from(labelingAssignmentEntity)
|
||||
.where(
|
||||
labelingAssignmentEntity.analUid.eq(analUid),
|
||||
labelingAssignmentEntity.inspectorUid.isNotNull(),
|
||||
labelingAssignmentEntity.workState.notIn("DONE"))
|
||||
.fetchOne();
|
||||
// 남은 작업 건수 계산
|
||||
long total = totalAssigned != null ? totalAssigned : 0L;
|
||||
long labelCompleted = labelingCompleted != null ? labelingCompleted : 0L;
|
||||
long inspectCompleted = inspectionCompleted != null ? inspectionCompleted : 0L;
|
||||
long skipped = skipCount != null ? skipCount : 0L;
|
||||
|
||||
long labelingRemaining = total - labelCompleted - skipped;
|
||||
long inspectionRemaining = total - inspectCompleted - skipped;
|
||||
|
||||
// 진행률 계산
|
||||
double progressRate = 0.0;
|
||||
if (totalAssigned != null && totalAssigned > 0) {
|
||||
progressRate =
|
||||
(completedCount != null ? completedCount.doubleValue() : 0.0) / totalAssigned * 100;
|
||||
}
|
||||
double labelingRate = total > 0 ? (double) labelCompleted / total * 100 : 0.0;
|
||||
double inspectionRate = total > 0 ? (double) inspectCompleted / total * 100 : 0.0;
|
||||
|
||||
// 작업 상태 판단 (간단하게 진행률 100%면 종료, 아니면 진행중)
|
||||
String workStatus = (progressRate >= 100.0) ? "종료" : "진행중";
|
||||
// 상태 판단
|
||||
String labelingStatus = labelingRemaining > 0 ? "진행중" : "완료";
|
||||
String inspectionStatus = inspectionRemaining > 0 ? "진행중" : "완료";
|
||||
|
||||
return WorkProgressInfo.builder()
|
||||
.labelingProgressRate(progressRate)
|
||||
.workStatus(workStatus)
|
||||
.completedCount(completedCount != null ? completedCount : 0L)
|
||||
.totalAssignedCount(totalAssigned != null ? totalAssigned : 0L)
|
||||
// 라벨링
|
||||
.labelingProgressRate(labelingRate)
|
||||
.labelingStatus(labelingStatus)
|
||||
.labelingTotalCount(total)
|
||||
.labelingCompletedCount(labelCompleted)
|
||||
.labelingSkipCount(skipped)
|
||||
.labelingRemainingCount(labelingRemaining)
|
||||
.labelerCount(labelerCount != null ? labelerCount : 0L)
|
||||
.remainingLabelCount(remainingLabelCount != null ? remainingLabelCount : 0L)
|
||||
// 검수
|
||||
.inspectionProgressRate(inspectionRate)
|
||||
.inspectionStatus(inspectionStatus)
|
||||
.inspectionTotalCount(total)
|
||||
.inspectionCompletedCount(inspectCompleted)
|
||||
.inspectionSkipCount(skipped)
|
||||
.inspectionRemainingCount(inspectionRemaining)
|
||||
.inspectorCount(inspectorCount != null ? inspectorCount : 0L)
|
||||
.remainingInspectCount(remainingInspectCount != null ? remainingInspectCount : 0L)
|
||||
// 레거시 호환 필드 (Deprecated)
|
||||
.progressRate(labelingRate)
|
||||
.totalAssignedCount(total)
|
||||
.completedCount(labelCompleted)
|
||||
.remainingLabelCount(labelingRemaining)
|
||||
.remainingInspectCount(inspectionRemaining)
|
||||
.workStatus(labelingStatus)
|
||||
.build();
|
||||
}
|
||||
|
||||
@@ -416,12 +428,15 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
|
||||
? labelingAssignmentEntity.inspectorUid.eq(workerId)
|
||||
: labelingAssignmentEntity.workerUid.eq(workerId);
|
||||
|
||||
BooleanExpression analUidCondition =
|
||||
analUid != null ? labelingAssignmentEntity.analUid.eq(analUid) : null;
|
||||
|
||||
Long count =
|
||||
queryFactory
|
||||
.select(labelingAssignmentEntity.count())
|
||||
.from(labelingAssignmentEntity)
|
||||
.where(
|
||||
labelingAssignmentEntity.analUid.eq(analUid),
|
||||
analUidCondition,
|
||||
workerCondition,
|
||||
labelingAssignmentEntity.workState.in(
|
||||
LabelState.DONE.getId(), LabelState.SKIP.getId()),
|
||||
@@ -443,20 +458,18 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
|
||||
}
|
||||
|
||||
@Override
|
||||
public InferenceDetail findInferenceDetail(
|
||||
Integer compareYyyy, Integer targetYyyy, Integer stage) {
|
||||
public InferenceDetail findInferenceDetail(String uuid) {
|
||||
// analUid로 분석 정보 조회
|
||||
MapSheetAnalDataInferenceEntity analEntity =
|
||||
MapSheetAnalInferenceEntity analEntity =
|
||||
queryFactory
|
||||
.selectFrom(mapSheetAnalDataInferenceEntity)
|
||||
.where(
|
||||
mapSheetAnalDataInferenceEntity.compareYyyy.eq(compareYyyy),
|
||||
mapSheetAnalDataInferenceEntity.targetYyyy.eq(targetYyyy),
|
||||
mapSheetAnalDataInferenceEntity.stage.eq(stage))
|
||||
.orderBy(mapSheetAnalDataInferenceEntity.analUid.asc())
|
||||
.limit(1)
|
||||
.selectFrom(mapSheetAnalInferenceEntity)
|
||||
.where(mapSheetAnalInferenceEntity.uuid.eq(UUID.fromString(uuid)))
|
||||
.fetchOne();
|
||||
|
||||
if (Objects.isNull(analEntity)) {
|
||||
throw new EntityNotFoundException("MapSheetAnalInferenceEntity not found for analUid: ");
|
||||
}
|
||||
|
||||
return queryFactory
|
||||
.select(
|
||||
Projections.constructor(
|
||||
@@ -470,7 +483,7 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
|
||||
.from(mapSheetAnalEntity)
|
||||
.innerJoin(labelingAssignmentEntity)
|
||||
.on(mapSheetAnalEntity.id.eq(labelingAssignmentEntity.analUid))
|
||||
.where(mapSheetAnalEntity.id.eq(analEntity.getAnalUid()))
|
||||
.where(mapSheetAnalEntity.id.eq(analEntity.getId()))
|
||||
.groupBy(
|
||||
mapSheetAnalEntity.analTitle,
|
||||
mapSheetAnalEntity.gukyuinApplyDttm,
|
||||
@@ -498,30 +511,6 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
|
||||
.fetch();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long findLabelUnCompleteCnt(Long analUid) {
|
||||
MapSheetAnalEntity entity =
|
||||
queryFactory
|
||||
.selectFrom(mapSheetAnalEntity)
|
||||
.where(mapSheetAnalEntity.id.eq(analUid))
|
||||
.fetchOne();
|
||||
|
||||
if (Objects.isNull(entity)) {
|
||||
throw new EntityNotFoundException();
|
||||
}
|
||||
|
||||
return queryFactory
|
||||
.select(mapSheetAnalDataInferenceGeomEntity.geoUid.count())
|
||||
.from(mapSheetAnalDataInferenceGeomEntity)
|
||||
.where(
|
||||
mapSheetAnalDataInferenceGeomEntity.compareYyyy.eq(entity.getCompareYyyy()),
|
||||
mapSheetAnalDataInferenceGeomEntity.targetYyyy.eq(entity.getTargetYyyy()),
|
||||
mapSheetAnalDataInferenceGeomEntity.stage.eq(4), // TODO: 회차 컬럼을 가져와야 할 듯?
|
||||
mapSheetAnalDataInferenceGeomEntity.labelState.in(
|
||||
LabelState.ASSIGNED.getId(), LabelState.SKIP.getId()))
|
||||
.fetchOne();
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public void assignOwnerMove(List<Long> sub, String userId) {
|
||||
@@ -535,8 +524,7 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
|
||||
}
|
||||
|
||||
@Override
|
||||
public LabelerDetail findLabelerDetail(
|
||||
String userId, Integer compareYyyy, Integer targetYyyy, Integer stage) {
|
||||
public LabelerDetail findLabelerDetail(String userId, String uuid) {
|
||||
NumberExpression<Long> assignedCnt =
|
||||
new CaseBuilder()
|
||||
.when(labelingAssignmentEntity.workState.eq(LabelState.ASSIGNED.getId()))
|
||||
@@ -570,19 +558,14 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
|
||||
completeCnt));
|
||||
|
||||
// analUid로 분석 정보 조회
|
||||
MapSheetAnalDataInferenceEntity analEntity =
|
||||
MapSheetAnalInferenceEntity analEntity =
|
||||
queryFactory
|
||||
.selectFrom(mapSheetAnalDataInferenceEntity)
|
||||
.where(
|
||||
mapSheetAnalDataInferenceEntity.compareYyyy.eq(compareYyyy),
|
||||
mapSheetAnalDataInferenceEntity.targetYyyy.eq(targetYyyy),
|
||||
mapSheetAnalDataInferenceEntity.stage.eq(stage))
|
||||
.orderBy(mapSheetAnalDataInferenceEntity.analUid.asc())
|
||||
.limit(1)
|
||||
.selectFrom(mapSheetAnalInferenceEntity)
|
||||
.where(mapSheetAnalInferenceEntity.uuid.eq(UUID.fromString(uuid)))
|
||||
.fetchOne();
|
||||
|
||||
if (Objects.isNull(analEntity)) {
|
||||
throw new EntityNotFoundException("MapSheetAnalEntity not found for analUid: ");
|
||||
throw new EntityNotFoundException("MapSheetAnalInferenceEntity not found for analUid: ");
|
||||
}
|
||||
|
||||
QMemberEntity worker = QMemberEntity.memberEntity;
|
||||
@@ -600,17 +583,349 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
|
||||
completeCnt,
|
||||
percent,
|
||||
Expressions.constant(0), // TODO: 순위, 꼭 해야할지?
|
||||
labelingAssignmentEntity.createdDate.min(),
|
||||
labelingAssignmentEntity.workStatDttm.min(),
|
||||
inspector.name.min()))
|
||||
.from(worker)
|
||||
.innerJoin(labelingAssignmentEntity)
|
||||
.on(
|
||||
worker.employeeNo.eq(labelingAssignmentEntity.workerUid),
|
||||
labelingAssignmentEntity.analUid.eq(analEntity.getAnalUid()))
|
||||
labelingAssignmentEntity.analUid.eq(analEntity.getId()))
|
||||
.leftJoin(inspector)
|
||||
.on(labelingAssignmentEntity.inspectorUid.eq(inspector.employeeNo))
|
||||
.where(worker.employeeNo.eq(userId))
|
||||
.groupBy(worker.userRole, worker.name, worker.employeeNo)
|
||||
.fetchOne();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long findMapSheetAnalInferenceUid(Integer compareYyyy, Integer targetYyyy, Integer stage) {
|
||||
return queryFactory
|
||||
.select(mapSheetAnalInferenceEntity.id)
|
||||
.from(mapSheetAnalInferenceEntity)
|
||||
.where(
|
||||
mapSheetAnalInferenceEntity.compareYyyy.eq(compareYyyy),
|
||||
mapSheetAnalInferenceEntity.targetYyyy.eq(targetYyyy),
|
||||
mapSheetAnalInferenceEntity.stage.eq(stage))
|
||||
.fetchOne();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insertInspector(Long analUid, String inspector) {
|
||||
queryFactory
|
||||
.insert(labelingInspectorEntity)
|
||||
.columns(
|
||||
labelingInspectorEntity.operatorUid,
|
||||
labelingInspectorEntity.analUid,
|
||||
labelingInspectorEntity.inspectorUid)
|
||||
.values(UUID.randomUUID(), analUid, inspector)
|
||||
.execute();
|
||||
|
||||
em.flush();
|
||||
em.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProjectInfo findProjectInfo(Long analUid) {
|
||||
if (analUid == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var result =
|
||||
queryFactory
|
||||
.select(
|
||||
mapSheetAnalEntity.compareYyyy,
|
||||
mapSheetAnalEntity.targetYyyy,
|
||||
mapSheetAnalEntity.analTitle,
|
||||
mapSheetAnalEntity.gukyuinApplyDttm,
|
||||
mapSheetAnalEntity.analStrtDttm)
|
||||
.from(mapSheetAnalEntity)
|
||||
.where(mapSheetAnalEntity.id.eq(analUid))
|
||||
.fetchOne();
|
||||
|
||||
if (result == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Integer compareYyyy = result.get(mapSheetAnalEntity.compareYyyy);
|
||||
Integer targetYyyy = result.get(mapSheetAnalEntity.targetYyyy);
|
||||
String analTitle = result.get(mapSheetAnalEntity.analTitle);
|
||||
ZonedDateTime gukyuinApplyDttm = result.get(mapSheetAnalEntity.gukyuinApplyDttm);
|
||||
ZonedDateTime analStrtDttm = result.get(mapSheetAnalEntity.analStrtDttm);
|
||||
|
||||
// 변화탐지년도 생성
|
||||
String detectionYear =
|
||||
(compareYyyy != null && targetYyyy != null) ? compareYyyy + "-" + targetYyyy : null;
|
||||
|
||||
// 회차 추출 (예: "8회차" → "8")
|
||||
String round = extractRoundFromTitle(analTitle);
|
||||
|
||||
return ProjectInfo.builder()
|
||||
.detectionYear(detectionYear)
|
||||
.round(round)
|
||||
.reflectionDate(formatDate(gukyuinApplyDttm))
|
||||
.startDate(formatDate(analStrtDttm))
|
||||
.build();
|
||||
}
|
||||
|
||||
/** 제목에서 회차 숫자 추출 예: "8회차", "제8회차" → "8" */
|
||||
private String extractRoundFromTitle(String title) {
|
||||
if (title == null || title.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Pattern pattern = Pattern.compile("(\\d+)회차");
|
||||
Matcher matcher = pattern.matcher(title);
|
||||
|
||||
return matcher.find() ? matcher.group(1) : null;
|
||||
}
|
||||
|
||||
/** ZonedDateTime을 "yyyy-MM-dd" 형식으로 변환 */
|
||||
private String formatDate(ZonedDateTime dateTime) {
|
||||
if (dateTime == null) {
|
||||
return null;
|
||||
}
|
||||
return dateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<LabelingStatDto> findLabelerDailyStat(
|
||||
LabelAllocateDto.searchReq searchReq, String uuid, String userId) {
|
||||
// 날짜 포맷
|
||||
Expression<String> workDate =
|
||||
Expressions.stringTemplate(
|
||||
"TO_CHAR({0}, 'YYYY-MM-DD')", labelingAssignmentEntity.workStatDttm);
|
||||
|
||||
// 날짜별 전체 건수
|
||||
Expression<Long> dailyTotalCnt = Expressions.numberTemplate(Long.class, "COUNT(*)");
|
||||
|
||||
// ⭐ 전체 기간 총 건수 (윈도우 함수)
|
||||
Expression<Long> totalCnt = Expressions.numberTemplate(Long.class, "SUM(COUNT(*)) OVER ()");
|
||||
|
||||
// 상태별 카운트 (Postgres FILTER 사용)
|
||||
Expression<Long> assignedCnt =
|
||||
Expressions.numberTemplate(
|
||||
Long.class,
|
||||
"COUNT(*) FILTER (WHERE {0} = 'ASSIGNED')",
|
||||
labelingAssignmentEntity.workState);
|
||||
|
||||
Expression<Long> skipCnt =
|
||||
Expressions.numberTemplate(
|
||||
Long.class, "COUNT(*) FILTER (WHERE {0} = 'SKIP')", labelingAssignmentEntity.workState);
|
||||
|
||||
Expression<Long> completeCnt =
|
||||
Expressions.numberTemplate(
|
||||
Long.class,
|
||||
"COUNT(*) FILTER (WHERE {0} = 'COMPLETE')",
|
||||
labelingAssignmentEntity.workState);
|
||||
|
||||
Expression<Long> remainCnt =
|
||||
Expressions.numberTemplate(Long.class, "({0} - {1} - {2})", totalCnt, skipCnt, completeCnt);
|
||||
|
||||
// analUid로 분석 정보 조회
|
||||
MapSheetAnalInferenceEntity analEntity =
|
||||
queryFactory
|
||||
.selectFrom(mapSheetAnalInferenceEntity)
|
||||
.where(mapSheetAnalInferenceEntity.uuid.eq(UUID.fromString(uuid)))
|
||||
.fetchOne();
|
||||
|
||||
if (Objects.isNull(analEntity)) {
|
||||
throw new EntityNotFoundException("MapSheetAnalInferenceEntity not found for analUid: ");
|
||||
}
|
||||
|
||||
Pageable pageable = searchReq.toPageable();
|
||||
List<LabelingStatDto> foundContent =
|
||||
queryFactory
|
||||
.select(
|
||||
Projections.constructor(
|
||||
LabelingStatDto.class,
|
||||
workDate,
|
||||
dailyTotalCnt,
|
||||
totalCnt, // ⭐ 전체 일자 배정 건수
|
||||
assignedCnt,
|
||||
skipCnt,
|
||||
completeCnt,
|
||||
remainCnt))
|
||||
.from(labelingAssignmentEntity)
|
||||
.where(
|
||||
labelingAssignmentEntity.workerUid.eq(userId),
|
||||
labelingAssignmentEntity.analUid.eq(analEntity.getId()))
|
||||
.groupBy(workDate)
|
||||
.orderBy(labelingAssignmentEntity.workStatDttm.min().asc())
|
||||
.offset(pageable.getOffset())
|
||||
.limit(pageable.getPageSize())
|
||||
.fetch();
|
||||
|
||||
Long countQuery =
|
||||
queryFactory
|
||||
.select(workDate)
|
||||
.from(labelingAssignmentEntity)
|
||||
.where(
|
||||
labelingAssignmentEntity.workerUid.eq(userId),
|
||||
labelingAssignmentEntity.analUid.eq(analEntity.getId()))
|
||||
.distinct()
|
||||
.fetch()
|
||||
.stream()
|
||||
.count();
|
||||
|
||||
return new PageImpl<>(foundContent, pageable, countQuery);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<LabelingStatDto> findInspectorDailyStat(
|
||||
LabelAllocateDto.searchReq searchReq, String uuid, String userId) {
|
||||
// 날짜 포맷
|
||||
Expression<String> workDate =
|
||||
Expressions.stringTemplate(
|
||||
"TO_CHAR({0}, 'YYYY-MM-DD')", labelingAssignmentEntity.inspectStatDttm);
|
||||
|
||||
// 날짜별 전체 건수
|
||||
Expression<Long> dailyTotalCnt = Expressions.numberTemplate(Long.class, "COUNT(*)");
|
||||
|
||||
// ⭐ 전체 기간 총 건수 (윈도우 함수)
|
||||
Expression<Long> totalCnt = Expressions.numberTemplate(Long.class, "SUM(COUNT(*)) OVER ()");
|
||||
|
||||
// 상태별 카운트 (Postgres FILTER 사용)
|
||||
Expression<Long> assignedCnt =
|
||||
Expressions.numberTemplate(
|
||||
Long.class,
|
||||
"COUNT(*) FILTER (WHERE {0} = 'UNCONFIRM')",
|
||||
labelingAssignmentEntity.inspectState);
|
||||
|
||||
Expression<Long> skipCnt =
|
||||
Expressions.numberTemplate(
|
||||
Long.class,
|
||||
"COUNT(*) FILTER (WHERE {0} = 'EXCEPT')",
|
||||
labelingAssignmentEntity.inspectState);
|
||||
|
||||
Expression<Long> completeCnt =
|
||||
Expressions.numberTemplate(
|
||||
Long.class,
|
||||
"COUNT(*) FILTER (WHERE {0} = 'COMPLETE')",
|
||||
labelingAssignmentEntity.inspectState);
|
||||
|
||||
Expression<Long> remainCnt =
|
||||
Expressions.numberTemplate(Long.class, "({0} - {1} - {2})", totalCnt, skipCnt, completeCnt);
|
||||
|
||||
// analUid로 분석 정보 조회
|
||||
MapSheetAnalInferenceEntity analEntity =
|
||||
queryFactory
|
||||
.selectFrom(mapSheetAnalInferenceEntity)
|
||||
.where(mapSheetAnalInferenceEntity.uuid.eq(UUID.fromString(uuid)))
|
||||
.fetchOne();
|
||||
|
||||
if (Objects.isNull(analEntity)) {
|
||||
throw new EntityNotFoundException("MapSheetAnalInferenceEntity not found for analUid: ");
|
||||
}
|
||||
|
||||
Pageable pageable = searchReq.toPageable();
|
||||
List<LabelingStatDto> foundContent =
|
||||
queryFactory
|
||||
.select(
|
||||
Projections.constructor(
|
||||
LabelingStatDto.class,
|
||||
workDate,
|
||||
dailyTotalCnt,
|
||||
totalCnt, // ⭐ 전체 일자 배정 건수
|
||||
assignedCnt,
|
||||
skipCnt,
|
||||
completeCnt,
|
||||
remainCnt))
|
||||
.from(labelingAssignmentEntity)
|
||||
.where(
|
||||
labelingAssignmentEntity.inspectorUid.eq(userId),
|
||||
labelingAssignmentEntity.analUid.eq(analEntity.getId()))
|
||||
.groupBy(workDate)
|
||||
.orderBy(labelingAssignmentEntity.inspectStatDttm.min().asc())
|
||||
.offset(pageable.getOffset())
|
||||
.limit(pageable.getPageSize())
|
||||
.fetch();
|
||||
|
||||
Long countQuery =
|
||||
queryFactory
|
||||
.select(workDate)
|
||||
.from(labelingAssignmentEntity)
|
||||
.where(
|
||||
labelingAssignmentEntity.inspectorUid.eq(userId),
|
||||
labelingAssignmentEntity.analUid.eq(analEntity.getId()))
|
||||
.distinct()
|
||||
.fetch()
|
||||
.stream()
|
||||
.count();
|
||||
|
||||
return new PageImpl<>(foundContent, pageable, countQuery);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LabelerDetail findInspectorDetail(String userId, String uuid) {
|
||||
NumberExpression<Long> assignedCnt =
|
||||
new CaseBuilder()
|
||||
.when(labelingAssignmentEntity.inspectState.eq(InspectState.UNCONFIRM.getId()))
|
||||
.then(1L)
|
||||
.otherwise((Long) null)
|
||||
.count();
|
||||
|
||||
NumberExpression<Long> skipCnt =
|
||||
new CaseBuilder()
|
||||
.when(labelingAssignmentEntity.inspectState.eq(InspectState.EXCEPT.getId()))
|
||||
.then(1L)
|
||||
.otherwise((Long) null)
|
||||
.count();
|
||||
|
||||
NumberExpression<Long> completeCnt =
|
||||
new CaseBuilder()
|
||||
.when(labelingAssignmentEntity.inspectState.eq(InspectState.COMPLETE.getId()))
|
||||
.then(1L)
|
||||
.otherwise((Long) null)
|
||||
.count();
|
||||
|
||||
NumberExpression<Double> percent =
|
||||
new CaseBuilder()
|
||||
.when(completeCnt.eq(0L))
|
||||
.then(0.0)
|
||||
.otherwise(
|
||||
Expressions.numberTemplate(
|
||||
Double.class,
|
||||
"round({0} / {1}, 2)",
|
||||
labelingAssignmentEntity.count(),
|
||||
completeCnt));
|
||||
|
||||
// analUid로 분석 정보 조회
|
||||
MapSheetAnalInferenceEntity analEntity =
|
||||
queryFactory
|
||||
.selectFrom(mapSheetAnalInferenceEntity)
|
||||
.where(mapSheetAnalInferenceEntity.uuid.eq(UUID.fromString(uuid)))
|
||||
.fetchOne();
|
||||
|
||||
if (Objects.isNull(analEntity)) {
|
||||
throw new EntityNotFoundException("MapSheetAnalInferenceEntity not found for analUid: ");
|
||||
}
|
||||
|
||||
QMemberEntity inspector = QMemberEntity.memberEntity;
|
||||
QMemberEntity worker = new QMemberEntity("worker");
|
||||
|
||||
return queryFactory
|
||||
.select(
|
||||
Projections.constructor(
|
||||
LabelerDetail.class,
|
||||
inspector.userRole,
|
||||
inspector.name,
|
||||
inspector.employeeNo,
|
||||
assignedCnt,
|
||||
skipCnt,
|
||||
completeCnt,
|
||||
percent,
|
||||
Expressions.constant(0), // TODO: 순위, 꼭 해야할지?
|
||||
labelingAssignmentEntity.inspectStatDttm.min(),
|
||||
worker.name.min()))
|
||||
.from(inspector)
|
||||
.innerJoin(labelingAssignmentEntity)
|
||||
.on(
|
||||
inspector.employeeNo.eq(labelingAssignmentEntity.inspectorUid),
|
||||
labelingAssignmentEntity.analUid.eq(analEntity.getId()))
|
||||
.leftJoin(worker)
|
||||
.on(labelingAssignmentEntity.workerUid.eq(worker.employeeNo))
|
||||
.where(inspector.employeeNo.eq(userId))
|
||||
.groupBy(inspector.userRole, inspector.name, inspector.employeeNo)
|
||||
.fetchOne();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,9 +2,17 @@ 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.postgres.entity.MapSheetAnalInferenceEntity;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import org.springframework.data.domain.Page;
|
||||
|
||||
public interface LabelWorkRepositoryCustom {
|
||||
|
||||
List<MapSheetAnalInferenceEntity> findChangeDetectYearList();
|
||||
|
||||
public Page<LabelWorkMng> labelWorkMngList(LabelWorkDto.LabelWorkMngSearchReq searchReq);
|
||||
|
||||
LabelWorkMngDetail findLabelWorkMngDetail(UUID uuid);
|
||||
}
|
||||
|
||||
@@ -1,22 +1,29 @@
|
||||
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.QMapSheetAnalDataInferenceEntity.mapSheetAnalDataInferenceEntity;
|
||||
import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetAnalDataInferenceGeomEntity.mapSheetAnalDataInferenceGeomEntity;
|
||||
import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetAnalInferenceEntity.mapSheetAnalInferenceEntity;
|
||||
|
||||
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.postgres.entity.MapSheetAnalDataGeomEntity;
|
||||
import com.kamco.cd.kamcoback.postgres.entity.MapSheetAnalInferenceEntity;
|
||||
import com.querydsl.core.BooleanBuilder;
|
||||
import com.querydsl.core.types.Projections;
|
||||
import com.querydsl.core.types.dsl.CaseBuilder;
|
||||
import com.querydsl.core.types.dsl.Expressions;
|
||||
import com.querydsl.core.types.dsl.NumberExpression;
|
||||
import com.querydsl.core.types.dsl.StringExpression;
|
||||
import com.querydsl.jpa.JPAExpressions;
|
||||
import com.querydsl.jpa.impl.JPAQueryFactory;
|
||||
import jakarta.persistence.EntityManager;
|
||||
import jakarta.persistence.PersistenceContext;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageImpl;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
@@ -39,20 +46,59 @@ public class LabelWorkRepositoryImpl extends QuerydslRepositorySupport
|
||||
this.queryFactory = queryFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* 변화탐지 년도 셀렉트박스 조회
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<MapSheetAnalInferenceEntity> findChangeDetectYearList() {
|
||||
return queryFactory
|
||||
.selectFrom(mapSheetAnalInferenceEntity)
|
||||
.where(
|
||||
mapSheetAnalInferenceEntity.id.in(
|
||||
JPAExpressions.select(mapSheetAnalInferenceEntity.id.min())
|
||||
.from(mapSheetAnalInferenceEntity)
|
||||
.groupBy(
|
||||
mapSheetAnalInferenceEntity.compareYyyy,
|
||||
mapSheetAnalInferenceEntity.targetYyyy)))
|
||||
.orderBy(
|
||||
mapSheetAnalInferenceEntity.compareYyyy.asc(),
|
||||
mapSheetAnalInferenceEntity.targetYyyy.asc())
|
||||
.fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 라벨링 작업관리 목록 조회
|
||||
*
|
||||
* @param searchReq
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Page<LabelWorkMng> labelWorkMngList(LabelWorkDto.LabelWorkMngSearchReq searchReq) {
|
||||
|
||||
Pageable pageable = PageRequest.of(searchReq.getPage(), searchReq.getSize());
|
||||
BooleanBuilder whereBuilder = new BooleanBuilder();
|
||||
BooleanBuilder whereSubDataBuilder = new BooleanBuilder();
|
||||
BooleanBuilder whereSubBuilder = new BooleanBuilder();
|
||||
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
|
||||
if (StringUtils.isNotBlank(searchReq.getDetectYear())) {
|
||||
String[] years = searchReq.getDetectYear().split("-");
|
||||
|
||||
if (searchReq.getDetectYyyy() != null) {
|
||||
whereBuilder.and(mapSheetAnalDataInferenceEntity.targetYyyy.eq(searchReq.getDetectYyyy()));
|
||||
if (years.length == 2) {
|
||||
Integer compareYear = Integer.valueOf(years[0]);
|
||||
Integer targetYear = Integer.valueOf(years[1]);
|
||||
|
||||
whereBuilder.and(
|
||||
mapSheetAnalDataInferenceEntity
|
||||
.compareYyyy
|
||||
.eq(compareYear)
|
||||
.and(mapSheetAnalDataInferenceEntity.targetYyyy.eq(targetYear)));
|
||||
}
|
||||
}
|
||||
|
||||
// mapSheetAnalDataInferenceGeomEntity.dataUid.eq(mapSheetAnalDataInferenceEntity.id)
|
||||
whereSubDataBuilder.and(
|
||||
mapSheetAnalInferenceEntity.id.eq(mapSheetAnalDataInferenceEntity.analUid));
|
||||
|
||||
whereSubBuilder.and(
|
||||
mapSheetAnalDataInferenceGeomEntity.dataUid.eq(mapSheetAnalDataInferenceEntity.id));
|
||||
@@ -61,15 +107,10 @@ public class LabelWorkRepositoryImpl extends QuerydslRepositorySupport
|
||||
&& !searchReq.getStrtDttm().isEmpty()
|
||||
&& searchReq.getEndDttm() != null
|
||||
&& !searchReq.getEndDttm().isEmpty()) {
|
||||
|
||||
// whereSubBuilder.and(mapSheetAnalDataInferenceGeomEntity.labelStateDttm.isNotNull());
|
||||
whereSubBuilder.and(
|
||||
Expressions.stringTemplate(
|
||||
"to_char({0}, 'YYYYMMDD')", mapSheetAnalDataInferenceGeomEntity.labelStateDttm)
|
||||
.between(searchReq.getStrtDttm(), searchReq.getEndDttm()));
|
||||
|
||||
// whereBuilder.and(mapSheetAnalDataInferenceGeomEntity.labelStateDttm.min().isNotNull());
|
||||
|
||||
}
|
||||
|
||||
List<LabelWorkMng> foundContent =
|
||||
@@ -77,9 +118,10 @@ public class LabelWorkRepositoryImpl extends QuerydslRepositorySupport
|
||||
.select(
|
||||
Projections.constructor(
|
||||
LabelWorkMng.class,
|
||||
mapSheetAnalDataInferenceEntity.compareYyyy,
|
||||
mapSheetAnalDataInferenceEntity.targetYyyy,
|
||||
mapSheetAnalDataInferenceEntity.stage,
|
||||
mapSheetAnalInferenceEntity.uuid,
|
||||
mapSheetAnalInferenceEntity.compareYyyy,
|
||||
mapSheetAnalInferenceEntity.targetYyyy,
|
||||
mapSheetAnalInferenceEntity.stage,
|
||||
mapSheetAnalDataInferenceEntity.createdDttm.min(),
|
||||
mapSheetAnalDataInferenceGeomEntity.dataUid.count(),
|
||||
mapSheetAnalDataInferenceGeomEntity.dataUid.count(),
|
||||
@@ -99,17 +141,21 @@ public class LabelWorkRepositoryImpl extends QuerydslRepositorySupport
|
||||
.otherwise(0L)
|
||||
.sum(),
|
||||
mapSheetAnalDataInferenceGeomEntity.labelStateDttm.min()))
|
||||
.from(mapSheetAnalDataInferenceEntity)
|
||||
.from(mapSheetAnalInferenceEntity)
|
||||
.innerJoin(mapSheetAnalDataInferenceEntity)
|
||||
.on(whereSubDataBuilder)
|
||||
.innerJoin(mapSheetAnalDataInferenceGeomEntity)
|
||||
.on(whereSubBuilder)
|
||||
.where(whereBuilder)
|
||||
.groupBy(
|
||||
mapSheetAnalDataInferenceEntity.compareYyyy,
|
||||
mapSheetAnalDataInferenceEntity.targetYyyy,
|
||||
mapSheetAnalDataInferenceEntity.stage)
|
||||
mapSheetAnalInferenceEntity.uuid,
|
||||
mapSheetAnalInferenceEntity.compareYyyy,
|
||||
mapSheetAnalInferenceEntity.targetYyyy,
|
||||
mapSheetAnalInferenceEntity.stage)
|
||||
.orderBy(
|
||||
mapSheetAnalDataInferenceEntity.targetYyyy.desc(),
|
||||
mapSheetAnalDataInferenceEntity.stage.desc())
|
||||
mapSheetAnalInferenceEntity.targetYyyy.desc(),
|
||||
mapSheetAnalInferenceEntity.compareYyyy.desc(),
|
||||
mapSheetAnalInferenceEntity.stage.desc())
|
||||
.offset(pageable.getOffset())
|
||||
.limit(pageable.getPageSize())
|
||||
.fetch();
|
||||
@@ -131,8 +177,62 @@ public class LabelWorkRepositoryImpl extends QuerydslRepositorySupport
|
||||
|
||||
*/
|
||||
|
||||
Long countQuery = foundContent.stream().count();
|
||||
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, countQuery);
|
||||
return new PageImpl<>(foundContent, pageable, total);
|
||||
}
|
||||
|
||||
/**
|
||||
* 작업배정 상세조회
|
||||
*
|
||||
* @param uuid
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public LabelWorkMngDetail findLabelWorkMngDetail(UUID uuid) {
|
||||
|
||||
NumberExpression<Long> labelTotCnt = mapSheetAnalDataInferenceGeomEntity.geoUid.count();
|
||||
NumberExpression<Long> labelerCnt = labelingAssignmentEntity.workerUid.count();
|
||||
NumberExpression<Long> reviewerCnt = labelingAssignmentEntity.inspectorUid.count();
|
||||
|
||||
return queryFactory
|
||||
.select(
|
||||
Projections.constructor(
|
||||
LabelWorkMngDetail.class,
|
||||
mapSheetAnalInferenceEntity
|
||||
.compareYyyy
|
||||
.stringValue()
|
||||
.concat("-")
|
||||
.concat(mapSheetAnalInferenceEntity.targetYyyy.stringValue()),
|
||||
mapSheetAnalInferenceEntity.stage,
|
||||
mapSheetAnalInferenceEntity.createdDttm,
|
||||
labelTotCnt,
|
||||
labelerCnt,
|
||||
reviewerCnt))
|
||||
.from(mapSheetAnalInferenceEntity)
|
||||
.leftJoin(mapSheetAnalDataInferenceEntity)
|
||||
.on(mapSheetAnalInferenceEntity.id.eq(mapSheetAnalDataInferenceEntity.analUid))
|
||||
.leftJoin(mapSheetAnalDataInferenceGeomEntity)
|
||||
.on(mapSheetAnalDataInferenceEntity.id.eq(mapSheetAnalDataInferenceGeomEntity.dataUid))
|
||||
.leftJoin(labelingAssignmentEntity)
|
||||
.on(
|
||||
mapSheetAnalDataInferenceGeomEntity.geoUid.eq(
|
||||
labelingAssignmentEntity.inferenceGeomUid))
|
||||
.where(mapSheetAnalInferenceEntity.uuid.eq(uuid))
|
||||
.groupBy(
|
||||
mapSheetAnalInferenceEntity.compareYyyy,
|
||||
mapSheetAnalInferenceEntity.targetYyyy,
|
||||
mapSheetAnalInferenceEntity.stage,
|
||||
mapSheetAnalInferenceEntity.createdDttm)
|
||||
.fetchOne();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user