|
|
|
|
@@ -8,10 +8,12 @@ import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetLearnDataGeomEntit
|
|
|
|
|
|
|
|
|
|
import com.fasterxml.jackson.databind.JsonNode;
|
|
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
|
|
import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.LabelState;
|
|
|
|
|
import com.kamco.cd.kamcoback.postgres.entity.LabelingAssignmentEntity;
|
|
|
|
|
import com.kamco.cd.kamcoback.postgres.entity.MapSheetAnalDataInferenceGeomEntity;
|
|
|
|
|
import com.kamco.cd.kamcoback.trainingdata.dto.TrainingDataLabelDto.ChangeDetectionInfo;
|
|
|
|
|
import com.kamco.cd.kamcoback.trainingdata.dto.TrainingDataLabelDto.ClassificationInfo;
|
|
|
|
|
import com.kamco.cd.kamcoback.trainingdata.dto.TrainingDataLabelDto.DefaultPaging;
|
|
|
|
|
import com.kamco.cd.kamcoback.trainingdata.dto.TrainingDataLabelDto.DetailRes;
|
|
|
|
|
import com.kamco.cd.kamcoback.trainingdata.dto.TrainingDataLabelDto.GeoFeatureRequest.Properties;
|
|
|
|
|
import com.kamco.cd.kamcoback.trainingdata.dto.TrainingDataLabelDto.InferenceDataGeometry;
|
|
|
|
|
@@ -23,6 +25,7 @@ import com.kamco.cd.kamcoback.trainingdata.dto.TrainingDataLabelDto.LearnDataGeo
|
|
|
|
|
import com.kamco.cd.kamcoback.trainingdata.dto.TrainingDataLabelDto.LearnDataGeometry.LearnProperties;
|
|
|
|
|
import com.kamco.cd.kamcoback.trainingdata.dto.TrainingDataLabelDto.SummaryRes;
|
|
|
|
|
import com.kamco.cd.kamcoback.trainingdata.dto.TrainingDataLabelDto.searchReq;
|
|
|
|
|
import com.querydsl.core.Tuple;
|
|
|
|
|
import com.querydsl.core.types.Projections;
|
|
|
|
|
import com.querydsl.core.types.dsl.BooleanExpression;
|
|
|
|
|
import com.querydsl.core.types.dsl.CaseBuilder;
|
|
|
|
|
@@ -32,11 +35,13 @@ import com.querydsl.core.types.dsl.StringExpression;
|
|
|
|
|
import com.querydsl.jpa.impl.JPAQueryFactory;
|
|
|
|
|
import jakarta.persistence.EntityNotFoundException;
|
|
|
|
|
import java.time.LocalDate;
|
|
|
|
|
import java.time.ZoneId;
|
|
|
|
|
import java.time.ZonedDateTime;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Objects;
|
|
|
|
|
import java.util.Optional;
|
|
|
|
|
import java.util.UUID;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.locationtech.jts.geom.Geometry;
|
|
|
|
|
import org.springframework.data.domain.Page;
|
|
|
|
|
import org.springframework.data.domain.PageImpl;
|
|
|
|
|
@@ -44,6 +49,7 @@ import org.springframework.data.domain.PageRequest;
|
|
|
|
|
import org.springframework.data.domain.Pageable;
|
|
|
|
|
import org.springframework.data.jpa.repository.support.QuerydslRepositorySupport;
|
|
|
|
|
|
|
|
|
|
@Slf4j
|
|
|
|
|
public class TrainingDataLabelRepositoryImpl extends QuerydslRepositorySupport
|
|
|
|
|
implements TrainingDataLabelRepositoryCustom {
|
|
|
|
|
|
|
|
|
|
@@ -57,6 +63,24 @@ public class TrainingDataLabelRepositoryImpl extends QuerydslRepositorySupport
|
|
|
|
|
@Override
|
|
|
|
|
public Page<LabelingListDto> findLabelingAssignedList(
|
|
|
|
|
searchReq searchReq, String userId, String status) {
|
|
|
|
|
|
|
|
|
|
// 완료된 라벨은 오늘만, 나머지는 전체 조회
|
|
|
|
|
LocalDate today = LocalDate.now(ZoneId.of("Asia/Seoul"));
|
|
|
|
|
ZonedDateTime start = today.atStartOfDay(ZoneId.of("Asia/Seoul"));
|
|
|
|
|
ZonedDateTime end = start.plusDays(1);
|
|
|
|
|
|
|
|
|
|
BooleanExpression doneToday =
|
|
|
|
|
labelingAssignmentEntity
|
|
|
|
|
.workState
|
|
|
|
|
.eq(LabelState.DONE.getId())
|
|
|
|
|
.and(labelingAssignmentEntity.workStatDttm.goe(start))
|
|
|
|
|
.and(labelingAssignmentEntity.workStatDttm.lt(end));
|
|
|
|
|
|
|
|
|
|
BooleanExpression assignedOrSkip =
|
|
|
|
|
labelingAssignmentEntity.workState.in(LabelState.SKIP.getId(), LabelState.ASSIGNED.getId());
|
|
|
|
|
|
|
|
|
|
BooleanExpression dayStateCondition = doneToday.or(assignedOrSkip);
|
|
|
|
|
|
|
|
|
|
Pageable pageable = PageRequest.of(searchReq.getPage(), searchReq.getSize());
|
|
|
|
|
List<LabelingListDto> list =
|
|
|
|
|
queryFactory
|
|
|
|
|
@@ -77,12 +101,14 @@ public class TrainingDataLabelRepositoryImpl extends QuerydslRepositorySupport
|
|
|
|
|
mapSheetAnalDataInferenceGeomEntity.geoUid))
|
|
|
|
|
.innerJoin(mapInkx5kEntity)
|
|
|
|
|
.on(labelingAssignmentEntity.assignGroupId.eq(mapInkx5kEntity.mapidcdNo))
|
|
|
|
|
.where(labelingAssignmentEntity.workerUid.eq(userId), statusInLabelState(status))
|
|
|
|
|
.where(labelingAssignmentEntity.workerUid.eq(userId), dayStateCondition)
|
|
|
|
|
.offset(pageable.getOffset())
|
|
|
|
|
.limit(pageable.getPageSize())
|
|
|
|
|
.orderBy(
|
|
|
|
|
labelingAssignmentEntity.assignGroupId.asc(),
|
|
|
|
|
labelingAssignmentEntity.inferenceGeomUid.asc())
|
|
|
|
|
labelingAssignmentEntity.createdDate.asc(),
|
|
|
|
|
labelingAssignmentEntity.inferenceGeomUid
|
|
|
|
|
.asc() // 008288b5-5911-41d5-b8fc-b8c8f33d5434 / 362
|
|
|
|
|
)
|
|
|
|
|
.fetch();
|
|
|
|
|
|
|
|
|
|
Long count =
|
|
|
|
|
@@ -96,8 +122,7 @@ public class TrainingDataLabelRepositoryImpl extends QuerydslRepositorySupport
|
|
|
|
|
mapSheetAnalDataInferenceGeomEntity.geoUid))
|
|
|
|
|
.innerJoin(mapInkx5kEntity)
|
|
|
|
|
.on(labelingAssignmentEntity.assignGroupId.eq(mapInkx5kEntity.mapidcdNo))
|
|
|
|
|
.where(
|
|
|
|
|
labelingAssignmentEntity.workerUid.eq(userId), statusInLabelState(status))
|
|
|
|
|
.where(labelingAssignmentEntity.workerUid.eq(userId), dayStateCondition)
|
|
|
|
|
.fetchOne())
|
|
|
|
|
.orElse(0L);
|
|
|
|
|
|
|
|
|
|
@@ -534,6 +559,72 @@ public class TrainingDataLabelRepositoryImpl extends QuerydslRepositorySupport
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public DefaultPaging getDefaultPagingNumber(String userId) {
|
|
|
|
|
|
|
|
|
|
ZoneId KST = ZoneId.of("Asia/Seoul");
|
|
|
|
|
ZonedDateTime todayStart = ZonedDateTime.now(KST).toLocalDate().atStartOfDay(KST);
|
|
|
|
|
ZonedDateTime todayEnd = todayStart.plusDays(1);
|
|
|
|
|
|
|
|
|
|
BooleanExpression doneToday =
|
|
|
|
|
labelingAssignmentEntity
|
|
|
|
|
.workState
|
|
|
|
|
.eq(LabelState.DONE.getId())
|
|
|
|
|
.and(labelingAssignmentEntity.workStatDttm.goe(todayStart))
|
|
|
|
|
.and(labelingAssignmentEntity.workStatDttm.lt(todayEnd));
|
|
|
|
|
|
|
|
|
|
BooleanExpression assignedOrSkip =
|
|
|
|
|
labelingAssignmentEntity.workState.in(LabelState.SKIP.getId(), LabelState.ASSIGNED.getId());
|
|
|
|
|
|
|
|
|
|
BooleanExpression stateCondition = doneToday.or(assignedOrSkip);
|
|
|
|
|
|
|
|
|
|
Tuple firstAssigned =
|
|
|
|
|
queryFactory
|
|
|
|
|
.select(
|
|
|
|
|
labelingAssignmentEntity.assignmentUid,
|
|
|
|
|
labelingAssignmentEntity.createdDate,
|
|
|
|
|
labelingAssignmentEntity.inferenceGeomUid)
|
|
|
|
|
.from(labelingAssignmentEntity)
|
|
|
|
|
.where(
|
|
|
|
|
labelingAssignmentEntity.workerUid.eq(userId),
|
|
|
|
|
stateCondition,
|
|
|
|
|
labelingAssignmentEntity.workState.eq(LabelState.ASSIGNED.getId()))
|
|
|
|
|
.orderBy(
|
|
|
|
|
labelingAssignmentEntity.createdDate.asc(),
|
|
|
|
|
labelingAssignmentEntity.inferenceGeomUid.asc())
|
|
|
|
|
.limit(1)
|
|
|
|
|
.fetchOne();
|
|
|
|
|
|
|
|
|
|
if (firstAssigned == null) {
|
|
|
|
|
return DefaultPaging.builder().page(0).assignmentUid(null).build();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UUID firstAssignedUid = firstAssigned.get(labelingAssignmentEntity.assignmentUid);
|
|
|
|
|
ZonedDateTime createdDttm = firstAssigned.get(labelingAssignmentEntity.createdDate);
|
|
|
|
|
Long inferenceGeomUid = firstAssigned.get(labelingAssignmentEntity.inferenceGeomUid);
|
|
|
|
|
|
|
|
|
|
BooleanExpression beforeCondition =
|
|
|
|
|
labelingAssignmentEntity
|
|
|
|
|
.createdDate
|
|
|
|
|
.lt(createdDttm)
|
|
|
|
|
.or(
|
|
|
|
|
labelingAssignmentEntity
|
|
|
|
|
.createdDate
|
|
|
|
|
.eq(createdDttm)
|
|
|
|
|
.and(labelingAssignmentEntity.inferenceGeomUid.lt(inferenceGeomUid)));
|
|
|
|
|
|
|
|
|
|
Long beforeCnt =
|
|
|
|
|
queryFactory
|
|
|
|
|
.select(labelingAssignmentEntity.count())
|
|
|
|
|
.from(labelingAssignmentEntity)
|
|
|
|
|
.where(
|
|
|
|
|
labelingAssignmentEntity.workerUid.eq(userId), beforeCondition.and(stateCondition))
|
|
|
|
|
.fetchOne();
|
|
|
|
|
|
|
|
|
|
int page = (int) (beforeCnt / 20); // 기본 사이즈 20
|
|
|
|
|
return DefaultPaging.builder().page(page).assignmentUid(firstAssignedUid).build();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private StringExpression makeCogUrl(NumberPath<Integer> year) {
|
|
|
|
|
return new CaseBuilder()
|
|
|
|
|
.when(imageryEntity.year.eq(year))
|
|
|
|
|
|