[KC-151] 재할당 이전 로직으로 수정
This commit is contained in:
@@ -49,8 +49,7 @@ public class LabelAllocateDto {
|
||||
WAIT("대기"),
|
||||
ASSIGNED("배정"),
|
||||
SKIP("스킵"),
|
||||
DONE("완료"),
|
||||
COMPLETE("완료");
|
||||
DONE("완료");
|
||||
|
||||
private String desc;
|
||||
|
||||
@@ -202,8 +201,6 @@ public class LabelAllocateDto {
|
||||
private Integer stage;
|
||||
private ZonedDateTime gukyuinDttm;
|
||||
private Long count;
|
||||
private Long labelCnt;
|
||||
private Long inspectorCnt;
|
||||
}
|
||||
|
||||
@Getter
|
||||
|
||||
@@ -12,9 +12,7 @@ import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.TargetUser;
|
||||
import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.UserList;
|
||||
import com.kamco.cd.kamcoback.label.dto.WorkerStatsDto.WorkerListResponse;
|
||||
import com.kamco.cd.kamcoback.postgres.core.LabelAllocateCoreService;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.data.domain.Page;
|
||||
@@ -123,7 +121,6 @@ public class LabelAllocateService {
|
||||
public ApiResponseDto.ResponseObj allocateMove(
|
||||
Integer totalCnt, String uuid, List<String> targetUsers, String userId) {
|
||||
|
||||
Map<String, Integer> result = new LinkedHashMap<>();
|
||||
int userCount = targetUsers.size();
|
||||
if (userCount <= 0) {
|
||||
return new ApiResponseDto.ResponseObj(ApiResponseCode.BAD_REQUEST, "재할당할 라벨러를 선택해주세요.");
|
||||
@@ -132,6 +129,11 @@ public class LabelAllocateService {
|
||||
int base = totalCnt / userCount;
|
||||
int remainder = totalCnt % userCount;
|
||||
|
||||
Long lastId = null;
|
||||
List<Long> allIds =
|
||||
labelAllocateCoreService.fetchNextMoveIds(lastId, totalCnt.longValue(), uuid, userId);
|
||||
|
||||
int index = 0;
|
||||
for (int i = 0; i < userCount; i++) {
|
||||
int assignCount = base;
|
||||
|
||||
@@ -140,11 +142,15 @@ public class LabelAllocateService {
|
||||
assignCount += remainder;
|
||||
}
|
||||
|
||||
result.put(targetUsers.get(i), assignCount);
|
||||
|
||||
// TODO: 재할당 테이블에 update 까지만 하고 나머지는 배치에서 처리하기?
|
||||
labelAllocateCoreService.assignOwnerReAllocate(
|
||||
uuid, userId, targetUsers.get(i), (long) assignCount);
|
||||
// labelAllocateCoreService.assignOwnerReAllocate(
|
||||
// uuid, userId, targetUsers.get(i), (long) assignCount);
|
||||
|
||||
int end = index + assignCount;
|
||||
List<Long> sub = allIds.subList(index, end);
|
||||
|
||||
labelAllocateCoreService.assignOwnerMove(sub, targetUsers.get(i));
|
||||
index = end;
|
||||
}
|
||||
|
||||
// Long lastId = null;
|
||||
|
||||
@@ -87,15 +87,8 @@ public class LabelAllocateCoreService {
|
||||
return labelAllocateRepository.findInferenceDetail(uuid);
|
||||
}
|
||||
|
||||
public List<Long> fetchNextMoveIds(
|
||||
Long lastId,
|
||||
Long batchSize,
|
||||
Integer compareYyyy,
|
||||
Integer targetYyyy,
|
||||
Integer stage,
|
||||
String userId) {
|
||||
return labelAllocateRepository.fetchNextMoveIds(
|
||||
lastId, batchSize, compareYyyy, targetYyyy, stage, userId);
|
||||
public List<Long> fetchNextMoveIds(Long lastId, Long batchSize, String uuid, String userId) {
|
||||
return labelAllocateRepository.fetchNextMoveIds(lastId, batchSize, uuid, userId);
|
||||
}
|
||||
|
||||
public void assignOwnerMove(List<Long> sub, String userId) {
|
||||
|
||||
@@ -54,13 +54,7 @@ public interface LabelAllocateRepositoryCustom {
|
||||
|
||||
InferenceDetail findInferenceDetail(String uuid);
|
||||
|
||||
List<Long> fetchNextMoveIds(
|
||||
Long lastId,
|
||||
Long batchSize,
|
||||
Integer compareYyyy,
|
||||
Integer targetYyyy,
|
||||
Integer stage,
|
||||
String userId);
|
||||
List<Long> fetchNextMoveIds(Long lastId, Long batchSize, String uuid, String userId);
|
||||
|
||||
void assignOwnerMove(List<Long> sub, String userId);
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetAnalDataInferenceG
|
||||
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.common.enums.StatusType;
|
||||
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;
|
||||
@@ -493,38 +494,35 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
|
||||
Projections.constructor(
|
||||
InferenceDetail.class,
|
||||
mapSheetAnalInferenceEntity.analTitle,
|
||||
Expressions.numberTemplate(Integer.class, "{0}", 4),
|
||||
mapSheetAnalInferenceEntity.stage,
|
||||
mapSheetAnalInferenceEntity.gukyuinApplyDttm,
|
||||
mapSheetAnalInferenceEntity.detectingCnt,
|
||||
labelingAssignmentEntity.workerUid.countDistinct(),
|
||||
labelingAssignmentEntity.inspectorUid.countDistinct()))
|
||||
mapSheetAnalDataInferenceGeomEntity.geoUid.count()))
|
||||
.from(mapSheetAnalInferenceEntity)
|
||||
.innerJoin(labelingAssignmentEntity)
|
||||
.on(mapSheetAnalInferenceEntity.id.eq(labelingAssignmentEntity.analUid))
|
||||
.leftJoin(mapSheetAnalDataInferenceGeomEntity)
|
||||
.on(
|
||||
mapSheetAnalInferenceEntity.compareYyyy.eq(
|
||||
mapSheetAnalDataInferenceGeomEntity.compareYyyy),
|
||||
mapSheetAnalInferenceEntity.targetYyyy.eq(
|
||||
mapSheetAnalDataInferenceGeomEntity.targetYyyy),
|
||||
mapSheetAnalInferenceEntity.stage.eq(mapSheetAnalDataInferenceGeomEntity.stage),
|
||||
mapSheetAnalDataInferenceGeomEntity.pnu.gt(0),
|
||||
mapSheetAnalDataInferenceGeomEntity.passYn.isFalse())
|
||||
.where(mapSheetAnalInferenceEntity.id.eq(analEntity.getId()))
|
||||
.groupBy(
|
||||
mapSheetAnalInferenceEntity.analTitle,
|
||||
mapSheetAnalInferenceEntity.stage,
|
||||
mapSheetAnalInferenceEntity.gukyuinApplyDttm,
|
||||
mapSheetAnalInferenceEntity.detectingCnt)
|
||||
.fetchOne();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Long> fetchNextMoveIds(
|
||||
Long lastId,
|
||||
Long batchSize,
|
||||
Integer compareYyyy,
|
||||
Integer targetYyyy,
|
||||
Integer stage,
|
||||
String userId) {
|
||||
public List<Long> fetchNextMoveIds(Long lastId, Long batchSize, String uuid, String userId) {
|
||||
|
||||
MapSheetAnalInferenceEntity analEntity =
|
||||
queryFactory
|
||||
.selectFrom(mapSheetAnalInferenceEntity)
|
||||
.where(
|
||||
mapSheetAnalInferenceEntity.compareYyyy.eq(compareYyyy),
|
||||
mapSheetAnalInferenceEntity.targetYyyy.eq(targetYyyy),
|
||||
mapSheetAnalInferenceEntity.stage.eq(stage))
|
||||
.where(mapSheetAnalInferenceEntity.uuid.eq(UUID.fromString(uuid)))
|
||||
.fetchOne();
|
||||
|
||||
if (Objects.isNull(analEntity)) {
|
||||
@@ -539,7 +537,9 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
|
||||
labelingAssignmentEntity.workState.eq(LabelState.ASSIGNED.getId()),
|
||||
labelingAssignmentEntity.analUid.eq(analEntity.getId()),
|
||||
lastId == null ? null : labelingAssignmentEntity.inferenceGeomUid.gt(lastId))
|
||||
.orderBy(labelingAssignmentEntity.inferenceGeomUid.asc())
|
||||
.orderBy(
|
||||
labelingAssignmentEntity.assignGroupId.asc(),
|
||||
labelingAssignmentEntity.inferenceGeomUid.asc())
|
||||
.limit(batchSize)
|
||||
.fetch();
|
||||
}
|
||||
@@ -574,7 +574,7 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
|
||||
|
||||
NumberExpression<Long> completeCnt =
|
||||
new CaseBuilder()
|
||||
.when(labelingAssignmentEntity.workState.eq(LabelState.COMPLETE.getId()))
|
||||
.when(labelingAssignmentEntity.workState.eq(LabelState.DONE.getId()))
|
||||
.then(1L)
|
||||
.otherwise((Long) null)
|
||||
.count();
|
||||
@@ -1050,7 +1050,7 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
|
||||
.when(
|
||||
labelingAssignmentEntity
|
||||
.workState
|
||||
.eq(LabelState.COMPLETE.getId())
|
||||
.eq(LabelState.DONE.getId())
|
||||
.or(labelingAssignmentEntity.workState.eq(LabelState.SKIP.getId())))
|
||||
.then(1L)
|
||||
.otherwise(0L)
|
||||
@@ -1103,7 +1103,9 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
|
||||
percent))
|
||||
.from(labelingAssignmentEntity)
|
||||
.innerJoin(memberEntity)
|
||||
.on(labelingAssignmentEntity.workerUid.eq(memberEntity.employeeNo))
|
||||
.on(
|
||||
labelingAssignmentEntity.workerUid.eq(memberEntity.employeeNo),
|
||||
memberEntity.status.eq(StatusType.ACTIVE.getId()))
|
||||
.where(
|
||||
labelingAssignmentEntity.analUid.eq(analEntity.getId()),
|
||||
labelingAssignmentEntity.workerUid.ne(userId))
|
||||
@@ -1112,7 +1114,10 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
|
||||
completeCnt
|
||||
.multiply(2)
|
||||
.goe(totalCnt)) // 진행률 평균 이상인 것들만 조회 => percent 를 바로 쓰면 having절에 무리가 갈 수 있다고 함
|
||||
.orderBy(completeCnt.desc()) // TODO: 도엽번호? PNU? 로 정렬하여 보여주기?
|
||||
.orderBy(
|
||||
completeCnt
|
||||
.desc()) // TODO: 현재는 잔여건수가 제일 적은(=완료건수가 높은) 순서로 desc, 추후 도엽번호? PNU? 로 정렬하여
|
||||
// 보여주기?
|
||||
.fetch();
|
||||
|
||||
return new MoveInfo(userChargeCnt, list);
|
||||
|
||||
Reference in New Issue
Block a user