|
|
|
|
@@ -3,11 +3,15 @@ package com.kamco.cd.kamcoback.postgres.repository.label;
|
|
|
|
|
import static com.kamco.cd.kamcoback.postgres.entity.QLabelingAssignmentEntity.labelingAssignmentEntity;
|
|
|
|
|
import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetAnalDataInferenceGeomEntity.mapSheetAnalDataInferenceGeomEntity;
|
|
|
|
|
import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetAnalEntity.mapSheetAnalEntity;
|
|
|
|
|
import static com.kamco.cd.kamcoback.postgres.entity.QMemberEntity.memberEntity;
|
|
|
|
|
|
|
|
|
|
import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto;
|
|
|
|
|
import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.LabelState;
|
|
|
|
|
import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.UserList;
|
|
|
|
|
import com.kamco.cd.kamcoback.postgres.entity.LabelingAssignmentEntity;
|
|
|
|
|
import com.kamco.cd.kamcoback.postgres.entity.MapSheetAnalDataGeomEntity;
|
|
|
|
|
import com.kamco.cd.kamcoback.postgres.entity.MapSheetAnalEntity;
|
|
|
|
|
import com.querydsl.core.types.Projections;
|
|
|
|
|
import com.querydsl.core.types.dsl.Expressions;
|
|
|
|
|
import com.querydsl.core.types.dsl.StringExpression;
|
|
|
|
|
import com.querydsl.jpa.impl.JPAQueryFactory;
|
|
|
|
|
@@ -24,13 +28,12 @@ import org.springframework.stereotype.Repository;
|
|
|
|
|
@Slf4j
|
|
|
|
|
@Repository
|
|
|
|
|
public class LabelAllocateRepositoryImpl extends QuerydslRepositorySupport
|
|
|
|
|
implements LabelAllocateRepositoryCustom {
|
|
|
|
|
implements LabelAllocateRepositoryCustom {
|
|
|
|
|
|
|
|
|
|
private final JPAQueryFactory queryFactory;
|
|
|
|
|
private final StringExpression NULL_STRING = Expressions.stringTemplate("cast(null as text)");
|
|
|
|
|
|
|
|
|
|
@PersistenceContext
|
|
|
|
|
private EntityManager em;
|
|
|
|
|
@PersistenceContext private EntityManager em;
|
|
|
|
|
|
|
|
|
|
public LabelAllocateRepositoryImpl(JPAQueryFactory queryFactory) {
|
|
|
|
|
super(MapSheetAnalDataGeomEntity.class);
|
|
|
|
|
@@ -41,50 +44,48 @@ public class LabelAllocateRepositoryImpl extends QuerydslRepositorySupport
|
|
|
|
|
public List<Long> fetchNextIds(Long lastId, int batchSize) {
|
|
|
|
|
|
|
|
|
|
return queryFactory
|
|
|
|
|
.select(mapSheetAnalDataInferenceGeomEntity.geoUid)
|
|
|
|
|
.from(mapSheetAnalDataInferenceGeomEntity)
|
|
|
|
|
.where(
|
|
|
|
|
// mapSheetAnalDataGeomEntity.pnu.isNotNull(), //TODO: Mockup 진행 이후 확인하기
|
|
|
|
|
lastId == null ? null : mapSheetAnalDataInferenceGeomEntity.geoUid.gt(lastId),
|
|
|
|
|
mapSheetAnalDataInferenceGeomEntity.compareYyyy.eq(2022),
|
|
|
|
|
mapSheetAnalDataInferenceGeomEntity.targetYyyy.eq(2024),
|
|
|
|
|
mapSheetAnalDataInferenceGeomEntity.labelState.isNull())
|
|
|
|
|
.orderBy(mapSheetAnalDataInferenceGeomEntity.geoUid.asc())
|
|
|
|
|
.limit(batchSize)
|
|
|
|
|
.fetch();
|
|
|
|
|
.select(mapSheetAnalDataInferenceGeomEntity.geoUid)
|
|
|
|
|
.from(mapSheetAnalDataInferenceGeomEntity)
|
|
|
|
|
.where(
|
|
|
|
|
// mapSheetAnalDataGeomEntity.pnu.isNotNull(), //TODO: Mockup 진행 이후 확인하기
|
|
|
|
|
lastId == null ? null : mapSheetAnalDataInferenceGeomEntity.geoUid.gt(lastId),
|
|
|
|
|
mapSheetAnalDataInferenceGeomEntity.compareYyyy.eq(2022),
|
|
|
|
|
mapSheetAnalDataInferenceGeomEntity.targetYyyy.eq(2024),
|
|
|
|
|
mapSheetAnalDataInferenceGeomEntity.labelState.isNull())
|
|
|
|
|
.orderBy(mapSheetAnalDataInferenceGeomEntity.geoUid.asc())
|
|
|
|
|
.limit(batchSize)
|
|
|
|
|
.fetch();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void assignOwner(List<Long> ids, String userId) {
|
|
|
|
|
|
|
|
|
|
//data_geom 테이블에 label state 를 ASSIGNED 로 update
|
|
|
|
|
// data_geom 테이블에 label state 를 ASSIGNED 로 update
|
|
|
|
|
queryFactory
|
|
|
|
|
.update(mapSheetAnalDataInferenceGeomEntity)
|
|
|
|
|
.set(mapSheetAnalDataInferenceGeomEntity.labelState, LabelState.ASSIGNED.getId())
|
|
|
|
|
.where(mapSheetAnalDataInferenceGeomEntity.geoUid.in(ids))
|
|
|
|
|
.execute();
|
|
|
|
|
.update(mapSheetAnalDataInferenceGeomEntity)
|
|
|
|
|
.set(mapSheetAnalDataInferenceGeomEntity.labelState, LabelState.ASSIGNED.getId())
|
|
|
|
|
.where(mapSheetAnalDataInferenceGeomEntity.geoUid.in(ids))
|
|
|
|
|
.execute();
|
|
|
|
|
|
|
|
|
|
//라벨러 할당 테이블에 insert
|
|
|
|
|
// 라벨러 할당 테이블에 insert
|
|
|
|
|
for (Long geoUid : ids) {
|
|
|
|
|
queryFactory
|
|
|
|
|
.insert(labelingAssignmentEntity)
|
|
|
|
|
.columns(
|
|
|
|
|
labelingAssignmentEntity.assignmentUid,
|
|
|
|
|
labelingAssignmentEntity.inferenceGeomUid,
|
|
|
|
|
labelingAssignmentEntity.workerUid,
|
|
|
|
|
labelingAssignmentEntity.workState,
|
|
|
|
|
labelingAssignmentEntity.assignGroupId,
|
|
|
|
|
labelingAssignmentEntity.analUid
|
|
|
|
|
)
|
|
|
|
|
.values(
|
|
|
|
|
UUID.randomUUID(),
|
|
|
|
|
geoUid,
|
|
|
|
|
userId,
|
|
|
|
|
LabelState.ASSIGNED.getId(),
|
|
|
|
|
"", //TODO: 도엽번호
|
|
|
|
|
3
|
|
|
|
|
)
|
|
|
|
|
.execute();
|
|
|
|
|
.insert(labelingAssignmentEntity)
|
|
|
|
|
.columns(
|
|
|
|
|
labelingAssignmentEntity.assignmentUid,
|
|
|
|
|
labelingAssignmentEntity.inferenceGeomUid,
|
|
|
|
|
labelingAssignmentEntity.workerUid,
|
|
|
|
|
labelingAssignmentEntity.workState,
|
|
|
|
|
labelingAssignmentEntity.assignGroupId,
|
|
|
|
|
labelingAssignmentEntity.analUid)
|
|
|
|
|
.values(
|
|
|
|
|
UUID.randomUUID(),
|
|
|
|
|
geoUid,
|
|
|
|
|
userId,
|
|
|
|
|
LabelState.ASSIGNED.getId(),
|
|
|
|
|
"", // TODO: 도엽번호
|
|
|
|
|
3)
|
|
|
|
|
.execute();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
em.flush();
|
|
|
|
|
@@ -94,45 +95,59 @@ public class LabelAllocateRepositoryImpl extends QuerydslRepositorySupport
|
|
|
|
|
@Override
|
|
|
|
|
public List<LabelingAssignmentEntity> findAssignedLabelerList(Long analUid) {
|
|
|
|
|
return queryFactory
|
|
|
|
|
.selectFrom(labelingAssignmentEntity)
|
|
|
|
|
.where(
|
|
|
|
|
labelingAssignmentEntity.analUid.eq(analUid),
|
|
|
|
|
labelingAssignmentEntity.workState.eq(LabelState.ASSIGNED.getId()),
|
|
|
|
|
labelingAssignmentEntity.inspectorUid.isNull()
|
|
|
|
|
)
|
|
|
|
|
.orderBy(labelingAssignmentEntity.workerUid.asc())
|
|
|
|
|
.fetch();
|
|
|
|
|
.selectFrom(labelingAssignmentEntity)
|
|
|
|
|
.where(
|
|
|
|
|
labelingAssignmentEntity.analUid.eq(analUid),
|
|
|
|
|
labelingAssignmentEntity.workState.eq(LabelState.ASSIGNED.getId()),
|
|
|
|
|
labelingAssignmentEntity.inspectorUid.isNull())
|
|
|
|
|
.orderBy(labelingAssignmentEntity.workerUid.asc())
|
|
|
|
|
.fetch();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Long findLabelUnAssignedCnt(Long analUid) {
|
|
|
|
|
MapSheetAnalEntity entity = queryFactory.selectFrom(mapSheetAnalEntity).where(mapSheetAnalEntity.id.eq(analUid)).fetchOne();
|
|
|
|
|
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.isNull()
|
|
|
|
|
)
|
|
|
|
|
.fetchOne()
|
|
|
|
|
;
|
|
|
|
|
.select(mapSheetAnalDataInferenceGeomEntity.geoUid.count())
|
|
|
|
|
.from(mapSheetAnalDataInferenceGeomEntity)
|
|
|
|
|
.where(
|
|
|
|
|
mapSheetAnalDataInferenceGeomEntity.compareYyyy.eq(entity.getCompareYyyy()),
|
|
|
|
|
mapSheetAnalDataInferenceGeomEntity.targetYyyy.eq(entity.getTargetYyyy()),
|
|
|
|
|
mapSheetAnalDataInferenceGeomEntity.stage.eq(4), // TODO: 회차 컬럼을 가져와야 할 듯?
|
|
|
|
|
mapSheetAnalDataInferenceGeomEntity.labelState.isNull())
|
|
|
|
|
.fetchOne();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void assignInspector(UUID assignmentUid, String inspectorUid) {
|
|
|
|
|
queryFactory
|
|
|
|
|
.update(labelingAssignmentEntity)
|
|
|
|
|
.set(labelingAssignmentEntity.inspectorUid, inspectorUid)
|
|
|
|
|
.where(
|
|
|
|
|
labelingAssignmentEntity.assignmentUid.eq(assignmentUid)
|
|
|
|
|
)
|
|
|
|
|
.execute();
|
|
|
|
|
.update(labelingAssignmentEntity)
|
|
|
|
|
.set(labelingAssignmentEntity.inspectorUid, inspectorUid)
|
|
|
|
|
.where(labelingAssignmentEntity.assignmentUid.eq(assignmentUid))
|
|
|
|
|
.execute();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<UserList> availUserList(String role) {
|
|
|
|
|
return queryFactory
|
|
|
|
|
.select(
|
|
|
|
|
Projections.constructor(
|
|
|
|
|
LabelAllocateDto.UserList.class,
|
|
|
|
|
memberEntity.userRole,
|
|
|
|
|
memberEntity.employeeNo,
|
|
|
|
|
memberEntity.name))
|
|
|
|
|
.from(memberEntity)
|
|
|
|
|
.where(memberEntity.userRole.eq(role), memberEntity.status.eq("ACTIVE"))
|
|
|
|
|
.orderBy(memberEntity.name.asc())
|
|
|
|
|
.fetch();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|