Merge remote-tracking branch 'origin/feat/dev_251201' into feat/dev_251201
This commit is contained in:
@@ -60,6 +60,10 @@ public class LabelAllocateCoreService {
|
||||
return labelAllocateRepository.findLatestProjectInfo();
|
||||
}
|
||||
|
||||
public UUID findLastLabelWorkState() {
|
||||
return labelAllocateRepository.findLastLabelWorkState();
|
||||
}
|
||||
|
||||
public List<WorkerStatistics> findWorkerStatistics(
|
||||
Long analUid, String workerType, String search, String sortType) {
|
||||
return labelAllocateRepository.findWorkerStatistics(analUid, workerType, search, sortType);
|
||||
|
||||
@@ -36,6 +36,9 @@ public interface LabelAllocateRepositoryCustom {
|
||||
// 최신 프로젝트 정보 조회 (analUid 없이)
|
||||
ProjectInfo findLatestProjectInfo();
|
||||
|
||||
// 최신 작업 상태의 UUID 조회
|
||||
UUID findLastLabelWorkState();
|
||||
|
||||
// 작업자 통계 조회
|
||||
List<WorkerStatistics> findWorkerStatistics(
|
||||
Long analUid, String workerType, String search, String sortType);
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.kamco.cd.kamcoback.label.dto.WorkerStatsDto.WorkerStatistics;
|
||||
import com.kamco.cd.kamcoback.postgres.entity.LabelingAssignmentEntity;
|
||||
import com.kamco.cd.kamcoback.postgres.entity.MapSheetAnalInferenceEntity;
|
||||
import com.kamco.cd.kamcoback.postgres.entity.QMemberEntity;
|
||||
import com.querydsl.core.BooleanBuilder;
|
||||
import com.querydsl.core.types.Expression;
|
||||
import com.querydsl.core.types.Projections;
|
||||
import com.querydsl.core.types.dsl.BooleanExpression;
|
||||
@@ -37,12 +38,9 @@ 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;
|
||||
@@ -72,6 +70,7 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
|
||||
.from(mapSheetAnalDataInferenceGeomEntity)
|
||||
.where(
|
||||
lastId == null ? null : mapSheetAnalDataInferenceGeomEntity.geoUid.gt(lastId),
|
||||
mapSheetAnalDataInferenceGeomEntity.pnu.isNotNull(),
|
||||
mapSheetAnalDataInferenceGeomEntity.compareYyyy.eq(compareYyyy),
|
||||
mapSheetAnalDataInferenceGeomEntity.targetYyyy.eq(targetYyyy),
|
||||
mapSheetAnalDataInferenceGeomEntity.stage.eq(stage),
|
||||
@@ -160,6 +159,7 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
|
||||
.select(mapSheetAnalDataInferenceGeomEntity.geoUid.count())
|
||||
.from(mapSheetAnalDataInferenceGeomEntity)
|
||||
.where(
|
||||
mapSheetAnalDataInferenceGeomEntity.pnu.isNotNull(),
|
||||
mapSheetAnalDataInferenceGeomEntity.compareYyyy.eq(compareYyyy),
|
||||
mapSheetAnalDataInferenceGeomEntity.targetYyyy.eq(targetYyyy),
|
||||
mapSheetAnalDataInferenceGeomEntity.stage.eq(stage),
|
||||
@@ -584,6 +584,11 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
|
||||
QMemberEntity worker = QMemberEntity.memberEntity;
|
||||
QMemberEntity inspector = new QMemberEntity("inspector");
|
||||
|
||||
// remainCnt
|
||||
Expression<Long> remainCnt =
|
||||
Expressions.numberTemplate(
|
||||
Long.class, "({0} - {1} - {2})", assignedCnt, skipCnt, completeCnt);
|
||||
|
||||
return queryFactory
|
||||
.select(
|
||||
Projections.constructor(
|
||||
@@ -597,7 +602,8 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
|
||||
percent,
|
||||
Expressions.constant(0), // TODO: 순위, 꼭 해야할지?
|
||||
labelingAssignmentEntity.workStatDttm.min(),
|
||||
inspector.name.min()))
|
||||
inspector.name.min(),
|
||||
remainCnt))
|
||||
.from(worker)
|
||||
.innerJoin(labelingAssignmentEntity)
|
||||
.on(
|
||||
@@ -648,9 +654,9 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
|
||||
.select(
|
||||
mapSheetAnalInferenceEntity.compareYyyy,
|
||||
mapSheetAnalInferenceEntity.targetYyyy,
|
||||
mapSheetAnalInferenceEntity.analTitle,
|
||||
mapSheetAnalInferenceEntity.stage,
|
||||
mapSheetAnalInferenceEntity.gukyuinApplyDttm,
|
||||
mapSheetAnalInferenceEntity.analStrtDttm,
|
||||
mapSheetAnalInferenceEntity.createdDttm,
|
||||
mapSheetAnalInferenceEntity.uuid)
|
||||
.from(mapSheetAnalInferenceEntity)
|
||||
.where(mapSheetAnalInferenceEntity.id.eq(analUid))
|
||||
@@ -662,45 +668,48 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
|
||||
|
||||
Integer compareYyyy = result.get(mapSheetAnalInferenceEntity.compareYyyy);
|
||||
Integer targetYyyy = result.get(mapSheetAnalInferenceEntity.targetYyyy);
|
||||
String analTitle = result.get(mapSheetAnalInferenceEntity.analTitle);
|
||||
Integer stage = result.get(mapSheetAnalInferenceEntity.stage);
|
||||
ZonedDateTime gukyuinApplyDttm = result.get(mapSheetAnalInferenceEntity.gukyuinApplyDttm);
|
||||
ZonedDateTime analStrtDttm = result.get(mapSheetAnalInferenceEntity.analStrtDttm);
|
||||
ZonedDateTime createdDttm = result.get(mapSheetAnalInferenceEntity.createdDttm);
|
||||
UUID uuid = result.get(mapSheetAnalInferenceEntity.uuid);
|
||||
|
||||
// 변화탐지년도 생성
|
||||
String detectionYear =
|
||||
(compareYyyy != null && targetYyyy != null) ? compareYyyy + "-" + targetYyyy : null;
|
||||
|
||||
// 회차 추출 (예: "8회차" → "8")
|
||||
String round = extractRoundFromTitle(analTitle);
|
||||
// 회차를 stage 컬럼에서 가져옴
|
||||
String round = stage != null ? String.valueOf(stage) : null;
|
||||
|
||||
return ProjectInfo.builder()
|
||||
.detectionYear(detectionYear)
|
||||
.round(round)
|
||||
.reflectionDate(formatDate(gukyuinApplyDttm))
|
||||
.startDate(formatDate(analStrtDttm))
|
||||
.stage(round)
|
||||
.gukyuinApplyDttm(gukyuinApplyDttm)
|
||||
.startDttm(createdDttm)
|
||||
.uuid(uuid != null ? uuid.toString() : null)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProjectInfo findLatestProjectInfo() {
|
||||
// 최신 target_yyyy를 기준으로 프로젝트 정보 조회
|
||||
// 최근 집계용 UUID 조회 - 작업이 할당된 최신 프로젝트 우선
|
||||
UUID uuid = findLastLabelWorkState();
|
||||
|
||||
if (uuid == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// UUID로 프로젝트 정보 조회
|
||||
var result =
|
||||
queryFactory
|
||||
.select(
|
||||
mapSheetAnalInferenceEntity.compareYyyy,
|
||||
mapSheetAnalInferenceEntity.targetYyyy,
|
||||
mapSheetAnalInferenceEntity.analTitle,
|
||||
mapSheetAnalInferenceEntity.stage,
|
||||
mapSheetAnalInferenceEntity.gukyuinApplyDttm,
|
||||
mapSheetAnalInferenceEntity.analStrtDttm,
|
||||
mapSheetAnalInferenceEntity.createdDttm,
|
||||
mapSheetAnalInferenceEntity.uuid)
|
||||
.from(mapSheetAnalInferenceEntity)
|
||||
.orderBy(
|
||||
mapSheetAnalInferenceEntity.targetYyyy.desc(),
|
||||
mapSheetAnalInferenceEntity.compareYyyy.desc(),
|
||||
mapSheetAnalInferenceEntity.createdDttm.desc())
|
||||
.limit(1)
|
||||
.where(mapSheetAnalInferenceEntity.uuid.eq(uuid))
|
||||
.fetchOne();
|
||||
|
||||
if (result == null) {
|
||||
@@ -709,45 +718,59 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
|
||||
|
||||
Integer compareYyyy = result.get(mapSheetAnalInferenceEntity.compareYyyy);
|
||||
Integer targetYyyy = result.get(mapSheetAnalInferenceEntity.targetYyyy);
|
||||
String analTitle = result.get(mapSheetAnalInferenceEntity.analTitle);
|
||||
Integer stage = result.get(mapSheetAnalInferenceEntity.stage);
|
||||
ZonedDateTime gukyuinApplyDttm = result.get(mapSheetAnalInferenceEntity.gukyuinApplyDttm);
|
||||
ZonedDateTime analStrtDttm = result.get(mapSheetAnalInferenceEntity.analStrtDttm);
|
||||
UUID uuid = result.get(mapSheetAnalInferenceEntity.uuid);
|
||||
ZonedDateTime createdDttm = result.get(mapSheetAnalInferenceEntity.createdDttm);
|
||||
|
||||
// 변화탐지년도 생성
|
||||
String detectionYear =
|
||||
(compareYyyy != null && targetYyyy != null) ? compareYyyy + "-" + targetYyyy : null;
|
||||
|
||||
// 회차 추출 (예: "8회차" → "8")
|
||||
String round = extractRoundFromTitle(analTitle);
|
||||
// 회차를 stage 컬럼에서 가져옴
|
||||
String round = stage != null ? String.valueOf(stage) : null;
|
||||
|
||||
return ProjectInfo.builder()
|
||||
.detectionYear(detectionYear)
|
||||
.round(round)
|
||||
.reflectionDate(formatDate(gukyuinApplyDttm))
|
||||
.startDate(formatDate(analStrtDttm))
|
||||
.uuid(uuid != null ? uuid.toString() : null)
|
||||
.stage(round)
|
||||
.gukyuinApplyDttm(gukyuinApplyDttm)
|
||||
.startDttm(createdDttm)
|
||||
.uuid(uuid.toString())
|
||||
.build();
|
||||
}
|
||||
|
||||
/** 제목에서 회차 숫자 추출 예: "8회차", "제8회차" → "8" */
|
||||
private String extractRoundFromTitle(String title) {
|
||||
if (title == null || title.isEmpty()) {
|
||||
return null;
|
||||
@Override
|
||||
public UUID findLastLabelWorkState() {
|
||||
BooleanBuilder whereBuilder = new BooleanBuilder();
|
||||
|
||||
// 1. 작업이 할당된 프로젝트 중 최신 UUID 조회
|
||||
UUID uuid =
|
||||
queryFactory
|
||||
.select(mapSheetAnalInferenceEntity.uuid)
|
||||
.from(mapSheetAnalInferenceEntity)
|
||||
.innerJoin(labelingAssignmentEntity)
|
||||
.on(mapSheetAnalInferenceEntity.id.eq(labelingAssignmentEntity.analUid))
|
||||
.where(whereBuilder)
|
||||
.orderBy(
|
||||
mapSheetAnalInferenceEntity.compareYyyy.desc(),
|
||||
mapSheetAnalInferenceEntity.targetYyyy.desc(),
|
||||
mapSheetAnalInferenceEntity.stage.desc())
|
||||
.fetchFirst();
|
||||
|
||||
// 2. 작업이 할당된 프로젝트가 없으면 전체 프로젝트 중 최신 UUID 조회
|
||||
if (uuid == null) {
|
||||
uuid =
|
||||
queryFactory
|
||||
.select(mapSheetAnalInferenceEntity.uuid)
|
||||
.from(mapSheetAnalInferenceEntity)
|
||||
.where(whereBuilder)
|
||||
.orderBy(
|
||||
mapSheetAnalInferenceEntity.compareYyyy.desc(),
|
||||
mapSheetAnalInferenceEntity.targetYyyy.desc(),
|
||||
mapSheetAnalInferenceEntity.stage.desc())
|
||||
.fetchFirst();
|
||||
}
|
||||
|
||||
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"));
|
||||
return uuid;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -966,6 +989,11 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
|
||||
QMemberEntity inspector = QMemberEntity.memberEntity;
|
||||
QMemberEntity worker = new QMemberEntity("worker");
|
||||
|
||||
// remainCnt
|
||||
Expression<Long> remainCnt =
|
||||
Expressions.numberTemplate(
|
||||
Long.class, "({0} - {1} - {2})", assignedCnt, skipCnt, completeCnt);
|
||||
|
||||
return queryFactory
|
||||
.select(
|
||||
Projections.constructor(
|
||||
@@ -979,7 +1007,8 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
|
||||
percent,
|
||||
Expressions.constant(0), // TODO: 순위, 꼭 해야할지?
|
||||
labelingAssignmentEntity.inspectStatDttm.min(),
|
||||
worker.name.min()))
|
||||
worker.name.min(),
|
||||
remainCnt))
|
||||
.from(inspector)
|
||||
.innerJoin(labelingAssignmentEntity)
|
||||
.on(
|
||||
|
||||
@@ -23,6 +23,8 @@ import com.querydsl.jpa.impl.JPAQueryFactory;
|
||||
import jakarta.persistence.EntityManager;
|
||||
import jakarta.persistence.PersistenceContext;
|
||||
import java.time.LocalDate;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
@@ -111,10 +113,23 @@ public class LabelWorkRepositoryImpl extends QuerydslRepositorySupport
|
||||
&& !searchReq.getStrtDttm().isEmpty()
|
||||
&& searchReq.getEndDttm() != null
|
||||
&& !searchReq.getEndDttm().isEmpty()) {
|
||||
|
||||
ZoneId zoneId = ZoneId.of("Asia/Seoul");
|
||||
|
||||
ZonedDateTime start =
|
||||
LocalDate.parse(searchReq.getStrtDttm(), DateTimeFormatter.BASIC_ISO_DATE)
|
||||
.atStartOfDay(zoneId);
|
||||
|
||||
ZonedDateTime end =
|
||||
LocalDate.parse(searchReq.getEndDttm(), DateTimeFormatter.BASIC_ISO_DATE)
|
||||
.plusDays(1)
|
||||
.atStartOfDay(zoneId);
|
||||
|
||||
whereSubBuilder.and(
|
||||
Expressions.stringTemplate(
|
||||
"to_char({0}, 'YYYYMMDD')", mapSheetAnalDataInferenceGeomEntity.labelStateDttm)
|
||||
.between(searchReq.getStrtDttm(), searchReq.getEndDttm()));
|
||||
mapSheetAnalDataInferenceGeomEntity
|
||||
.labelStateDttm
|
||||
.goe(start)
|
||||
.and(mapSheetAnalDataInferenceGeomEntity.labelStateDttm.lt(end)));
|
||||
}
|
||||
|
||||
List<LabelWorkMng> foundContent =
|
||||
@@ -137,6 +152,11 @@ public class LabelWorkRepositoryImpl extends QuerydslRepositorySupport
|
||||
.then(1L)
|
||||
.otherwise(0L)
|
||||
.sum(),
|
||||
new CaseBuilder()
|
||||
.when(mapSheetAnalDataInferenceGeomEntity.labelState.eq("ASSIGNED"))
|
||||
.then(1L)
|
||||
.otherwise(0L)
|
||||
.sum(),
|
||||
new CaseBuilder()
|
||||
.when(mapSheetAnalDataInferenceGeomEntity.labelState.eq("STOP"))
|
||||
.then(1L)
|
||||
@@ -172,23 +192,6 @@ public class LabelWorkRepositoryImpl extends QuerydslRepositorySupport
|
||||
.limit(pageable.getPageSize())
|
||||
.fetch();
|
||||
|
||||
/*
|
||||
Long countQuery =
|
||||
queryFactory
|
||||
.select(mapSheetAnalDataInferenceEntity.count())
|
||||
.from(mapSheetAnalDataInferenceEntity)
|
||||
.leftJoin(mapSheetAnalDataInferenceGeomEntity)
|
||||
.on(whereSubBuilder)
|
||||
.where(whereBuilder)
|
||||
.groupBy(
|
||||
mapSheetAnalDataInferenceEntity.compareYyyy,
|
||||
mapSheetAnalDataInferenceEntity.targetYyyy,
|
||||
mapSheetAnalDataInferenceEntity.stage
|
||||
)
|
||||
.fetchOne();
|
||||
|
||||
*/
|
||||
|
||||
Long total =
|
||||
queryFactory
|
||||
.select(mapSheetAnalInferenceEntity.uuid.countDistinct())
|
||||
|
||||
Reference in New Issue
Block a user