라벨할당 수정, 상세 조회 API
This commit is contained in:
@@ -463,7 +463,8 @@ public class GlobalExceptionHandler {
|
|||||||
String stackTraceStr =
|
String stackTraceStr =
|
||||||
Arrays.stream(stackTrace)
|
Arrays.stream(stackTrace)
|
||||||
.map(StackTraceElement::toString)
|
.map(StackTraceElement::toString)
|
||||||
.collect(Collectors.joining("\n"));
|
.collect(Collectors.joining("\n"))
|
||||||
|
.substring(0, 255);
|
||||||
|
|
||||||
ErrorLogEntity errorLogEntity =
|
ErrorLogEntity errorLogEntity =
|
||||||
new ErrorLogEntity(
|
new ErrorLogEntity(
|
||||||
|
|||||||
@@ -3,8 +3,7 @@ package com.kamco.cd.kamcoback.label;
|
|||||||
import com.kamco.cd.kamcoback.code.dto.CommonCodeDto;
|
import com.kamco.cd.kamcoback.code.dto.CommonCodeDto;
|
||||||
import com.kamco.cd.kamcoback.config.api.ApiResponseDto;
|
import com.kamco.cd.kamcoback.config.api.ApiResponseDto;
|
||||||
import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto;
|
import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto;
|
||||||
import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.TargetInspector;
|
import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.InferenceDetail;
|
||||||
import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.TargetUser;
|
|
||||||
import com.kamco.cd.kamcoback.label.dto.WorkerStatsDto.WorkerListResponse;
|
import com.kamco.cd.kamcoback.label.dto.WorkerStatsDto.WorkerListResponse;
|
||||||
import com.kamco.cd.kamcoback.label.service.LabelAllocateService;
|
import com.kamco.cd.kamcoback.label.service.LabelAllocateService;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
@@ -69,7 +68,7 @@ public class LabelAllocateApiController {
|
|||||||
})
|
})
|
||||||
@GetMapping("/avail-user")
|
@GetMapping("/avail-user")
|
||||||
public ApiResponseDto<List<LabelAllocateDto.UserList>> availUserList(
|
public ApiResponseDto<List<LabelAllocateDto.UserList>> availUserList(
|
||||||
@Parameter(description = "사용자 역할 (LABELER: 라벨러, INSPECTOR: 검수자)", example = "LABELER")
|
@Parameter(description = "사용자 역할 (LABELER: 라벨러, REVIEWER: 검수자)", example = "LABELER")
|
||||||
@RequestParam
|
@RequestParam
|
||||||
@Schema()
|
@Schema()
|
||||||
String role) {
|
String role) {
|
||||||
@@ -78,10 +77,9 @@ public class LabelAllocateApiController {
|
|||||||
|
|
||||||
@Operation(
|
@Operation(
|
||||||
summary = "작업자 목록 및 3일치 통계 조회",
|
summary = "작업자 목록 및 3일치 통계 조회",
|
||||||
description =
|
description = """
|
||||||
"""
|
학습데이터 제작 현황 조회 API입니다.
|
||||||
학습데이터 제작 현황 조회 API입니다.
|
""")
|
||||||
""")
|
|
||||||
@ApiResponses(
|
@ApiResponses(
|
||||||
value = {
|
value = {
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
@@ -97,93 +95,93 @@ public class LabelAllocateApiController {
|
|||||||
description = "라벨러 작업자들의 통계 정보",
|
description = "라벨러 작업자들의 통계 정보",
|
||||||
value =
|
value =
|
||||||
"""
|
"""
|
||||||
{
|
{
|
||||||
"data": {
|
"data": {
|
||||||
"progressInfo": {
|
"progressInfo": {
|
||||||
"labelingProgressRate": 79.34,
|
"labelingProgressRate": 79.34,
|
||||||
"workStatus": "진행중",
|
"workStatus": "진행중",
|
||||||
"completedCount": 6554,
|
"completedCount": 6554,
|
||||||
"totalAssignedCount": 8258,
|
"totalAssignedCount": 8258,
|
||||||
"labelerCount": 5,
|
"labelerCount": 5,
|
||||||
"remainingLabelCount": 1704,
|
"remainingLabelCount": 1704,
|
||||||
"inspectorCount": 3,
|
"inspectorCount": 3,
|
||||||
"remainingInspectCount": 890
|
"remainingInspectCount": 890
|
||||||
},
|
|
||||||
"workers": [
|
|
||||||
{
|
|
||||||
"workerId": "1234567",
|
|
||||||
"workerName": "김라벨",
|
|
||||||
"workerType": "LABELER",
|
|
||||||
"totalAssigned": 1500,
|
|
||||||
"completed": 1100,
|
|
||||||
"skipped": 50,
|
|
||||||
"remaining": 350,
|
|
||||||
"history": {
|
|
||||||
"day1Ago": 281,
|
|
||||||
"day2Ago": 302,
|
|
||||||
"day3Ago": 294,
|
|
||||||
"average": 292
|
|
||||||
},
|
|
||||||
"isStagnated": false
|
|
||||||
},
|
},
|
||||||
{
|
"workers": [
|
||||||
"workerId": "2345678",
|
{
|
||||||
"workerName": "이작업",
|
"workerId": "1234567",
|
||||||
"workerType": "LABELER",
|
"workerName": "김라벨",
|
||||||
"totalAssigned": 2000,
|
"workerType": "LABELER",
|
||||||
"completed": 1850,
|
"totalAssigned": 1500,
|
||||||
"skipped": 100,
|
"completed": 1100,
|
||||||
"remaining": 50,
|
"skipped": 50,
|
||||||
"history": {
|
"remaining": 350,
|
||||||
"day1Ago": 5,
|
"history": {
|
||||||
"day2Ago": 3,
|
"day1Ago": 281,
|
||||||
"day3Ago": 8,
|
"day2Ago": 302,
|
||||||
"average": 5
|
"day3Ago": 294,
|
||||||
|
"average": 292
|
||||||
|
},
|
||||||
|
"isStagnated": false
|
||||||
},
|
},
|
||||||
"isStagnated": true
|
{
|
||||||
}
|
"workerId": "2345678",
|
||||||
]
|
"workerName": "이작업",
|
||||||
|
"workerType": "LABELER",
|
||||||
|
"totalAssigned": 2000,
|
||||||
|
"completed": 1850,
|
||||||
|
"skipped": 100,
|
||||||
|
"remaining": 50,
|
||||||
|
"history": {
|
||||||
|
"day1Ago": 5,
|
||||||
|
"day2Ago": 3,
|
||||||
|
"day3Ago": 8,
|
||||||
|
"average": 5
|
||||||
|
},
|
||||||
|
"isStagnated": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
"""),
|
||||||
"""),
|
|
||||||
@ExampleObject(
|
@ExampleObject(
|
||||||
name = "검수자 조회 예시",
|
name = "검수자 조회 예시",
|
||||||
description = "검수자 작업자들의 통계 정보",
|
description = "검수자 작업자들의 통계 정보",
|
||||||
value =
|
value =
|
||||||
"""
|
"""
|
||||||
{
|
{
|
||||||
"data": {
|
"data": {
|
||||||
"progressInfo": {
|
"progressInfo": {
|
||||||
"labelingProgressRate": 79.34,
|
"labelingProgressRate": 79.34,
|
||||||
"workStatus": "진행중",
|
"workStatus": "진행중",
|
||||||
"completedCount": 6554,
|
"completedCount": 6554,
|
||||||
"totalAssignedCount": 8258,
|
"totalAssignedCount": 8258,
|
||||||
"labelerCount": 5,
|
"labelerCount": 5,
|
||||||
"remainingLabelCount": 1704,
|
"remainingLabelCount": 1704,
|
||||||
"inspectorCount": 3,
|
"inspectorCount": 3,
|
||||||
"remainingInspectCount": 890
|
"remainingInspectCount": 890
|
||||||
},
|
},
|
||||||
"workers": [
|
"workers": [
|
||||||
{
|
{
|
||||||
"workerId": "9876543",
|
"workerId": "9876543",
|
||||||
"workerName": "박검수",
|
"workerName": "박검수",
|
||||||
"workerType": "INSPECTOR",
|
"workerType": "REVIEWER",
|
||||||
"totalAssigned": 1200,
|
"totalAssigned": 1200,
|
||||||
"completed": 980,
|
"completed": 980,
|
||||||
"skipped": 20,
|
"skipped": 20,
|
||||||
"remaining": 200,
|
"remaining": 200,
|
||||||
"history": {
|
"history": {
|
||||||
"day1Ago": 150,
|
"day1Ago": 150,
|
||||||
"day2Ago": 145,
|
"day2Ago": 145,
|
||||||
"day3Ago": 155,
|
"day3Ago": 155,
|
||||||
"average": 150
|
"average": 150
|
||||||
},
|
},
|
||||||
"isStagnated": false
|
"isStagnated": false
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
""")
|
||||||
""")
|
|
||||||
})),
|
})),
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
responseCode = "404",
|
responseCode = "404",
|
||||||
@@ -227,7 +225,7 @@ public class LabelAllocateApiController {
|
|||||||
example = "LABELER",
|
example = "LABELER",
|
||||||
schema =
|
schema =
|
||||||
@Schema(
|
@Schema(
|
||||||
allowableValues = {"LABELER", "INSPECTOR"},
|
allowableValues = {"LABELER", "REVIEWER"},
|
||||||
defaultValue = "LABELER"))
|
defaultValue = "LABELER"))
|
||||||
@RequestParam(required = false)
|
@RequestParam(required = false)
|
||||||
String type,
|
String type,
|
||||||
@@ -259,22 +257,40 @@ public class LabelAllocateApiController {
|
|||||||
analUid, workerType, searchName, searchEmployeeNo, sort));
|
analUid, workerType, searchName, searchEmployeeNo, sort));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 라벨링 수량 할당하는 로직 테스트
|
@ApiResponses(
|
||||||
|
value = {
|
||||||
|
@ApiResponse(
|
||||||
|
responseCode = "201",
|
||||||
|
description = "등록 성공",
|
||||||
|
content =
|
||||||
|
@Content(
|
||||||
|
mediaType = "application/json",
|
||||||
|
schema = @Schema(implementation = Long.class))),
|
||||||
|
@ApiResponse(responseCode = "400", description = "잘못된 요청 데이터", content = @Content),
|
||||||
|
@ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content),
|
||||||
|
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content)
|
||||||
|
})
|
||||||
@PostMapping("/allocate")
|
@PostMapping("/allocate")
|
||||||
public ApiResponseDto<Void> labelAllocate(@RequestBody LabelAllocateDto dto) {
|
public ApiResponseDto<Void> labelAllocate(
|
||||||
|
@io.swagger.v3.oas.annotations.parameters.RequestBody(
|
||||||
|
description = "라벨링 수량 할당",
|
||||||
|
required = true,
|
||||||
|
content =
|
||||||
|
@Content(
|
||||||
|
mediaType = "application/json",
|
||||||
|
schema = @Schema(implementation = LabelAllocateDto.AllocateDto.class)))
|
||||||
|
@RequestBody
|
||||||
|
LabelAllocateDto.AllocateDto dto)
|
||||||
|
throws Exception {
|
||||||
|
|
||||||
List<TargetUser> targets =
|
labelAllocateService.allocateAsc(
|
||||||
List.of(
|
dto.getAutoType(), dto.getStage(), dto.getLabelers(), dto.getInspectors());
|
||||||
new TargetUser("1234567", 1000),
|
|
||||||
new TargetUser("2345678", 400),
|
|
||||||
new TargetUser("3456789", 440));
|
|
||||||
List<TargetInspector> inspectors =
|
|
||||||
List.of(
|
|
||||||
new TargetInspector("9876543", 1000),
|
|
||||||
new TargetInspector("8765432", 340),
|
|
||||||
new TargetInspector("98765432", 500));
|
|
||||||
labelAllocateService.allocateAsc(targets, inspectors);
|
|
||||||
|
|
||||||
return ApiResponseDto.ok(null);
|
return ApiResponseDto.ok(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping
|
||||||
|
public ApiResponseDto<InferenceDetail> findInferenceDetail(@RequestParam Long analUid) {
|
||||||
|
return ApiResponseDto.ok(labelAllocateService.findInferenceDetail(analUid));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,9 @@ package com.kamco.cd.kamcoback.label.dto;
|
|||||||
|
|
||||||
import com.kamco.cd.kamcoback.common.utils.enums.CodeExpose;
|
import com.kamco.cd.kamcoback.common.utils.enums.CodeExpose;
|
||||||
import com.kamco.cd.kamcoback.common.utils.enums.EnumType;
|
import com.kamco.cd.kamcoback.common.utils.enums.EnumType;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import java.time.ZonedDateTime;
|
import java.time.ZonedDateTime;
|
||||||
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
@@ -78,10 +80,31 @@ public class LabelAllocateDto {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@AllArgsConstructor
|
||||||
|
public static class AllocateDto {
|
||||||
|
|
||||||
|
@Schema(description = "자동/수동여부(AUTO/MANUAL)", example = "AUTO")
|
||||||
|
private String autoType;
|
||||||
|
|
||||||
|
@Schema(description = "회차", example = "4")
|
||||||
|
private Integer stage;
|
||||||
|
|
||||||
|
@Schema(description = "라벨러 할당 목록")
|
||||||
|
private List<TargetUser> labelers;
|
||||||
|
|
||||||
|
@Schema(description = "검수자 할당 목록")
|
||||||
|
private List<TargetInspector> inspectors;
|
||||||
|
}
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
public static class TargetUser {
|
public static class TargetUser {
|
||||||
|
|
||||||
|
@Schema(description = "라벨러 사번", example = "labeler44")
|
||||||
private final String userId;
|
private final String userId;
|
||||||
|
|
||||||
|
@Schema(description = "할당 건수", example = "200")
|
||||||
private final int demand;
|
private final int demand;
|
||||||
|
|
||||||
public TargetUser(String userId, int demand) {
|
public TargetUser(String userId, int demand) {
|
||||||
@@ -94,7 +117,10 @@ public class LabelAllocateDto {
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public static class TargetInspector {
|
public static class TargetInspector {
|
||||||
|
|
||||||
|
@Schema(description = "검수자 사번", example = "K20251212001")
|
||||||
private final String inspectorUid;
|
private final String inspectorUid;
|
||||||
|
|
||||||
|
@Schema(description = "할당 명수", example = "3")
|
||||||
private int userCount;
|
private int userCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,4 +151,17 @@ public class LabelAllocateDto {
|
|||||||
private String employeeNo;
|
private String employeeNo;
|
||||||
private String name;
|
private String name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@AllArgsConstructor
|
||||||
|
public static class InferenceDetail {
|
||||||
|
|
||||||
|
private String analTitle;
|
||||||
|
private Integer stage;
|
||||||
|
private ZonedDateTime gukyuinDttm;
|
||||||
|
private Long count;
|
||||||
|
private Long labelCnt;
|
||||||
|
private Long inspectorCnt;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.kamco.cd.kamcoback.label.service;
|
package com.kamco.cd.kamcoback.label.service;
|
||||||
|
|
||||||
import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto;
|
import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto;
|
||||||
|
import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.InferenceDetail;
|
||||||
import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.TargetInspector;
|
import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.TargetInspector;
|
||||||
import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.TargetUser;
|
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.LabelAllocateDto.UserList;
|
||||||
@@ -10,7 +11,7 @@ import com.kamco.cd.kamcoback.label.dto.WorkerStatsDto.WorkerStatistics;
|
|||||||
import com.kamco.cd.kamcoback.postgres.core.LabelAllocateCoreService;
|
import com.kamco.cd.kamcoback.postgres.core.LabelAllocateCoreService;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.UUID;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
@@ -29,57 +30,56 @@ public class LabelAllocateService {
|
|||||||
/**
|
/**
|
||||||
* 도엽 기준 asc sorting 해서 할당 수만큼 배정하는 로직
|
* 도엽 기준 asc sorting 해서 할당 수만큼 배정하는 로직
|
||||||
*
|
*
|
||||||
* @param targetUsers 라벨러 타겟 목록
|
* @param targetUsers
|
||||||
* @param targetInspectors 검수자 타겟 목록
|
|
||||||
*/
|
*/
|
||||||
@Transactional
|
@Transactional
|
||||||
public void allocateAsc(List<TargetUser> targetUsers, List<TargetInspector> targetInspectors) {
|
public void allocateAsc(
|
||||||
|
String autoType,
|
||||||
|
Integer stage,
|
||||||
|
List<TargetUser> targetUsers,
|
||||||
|
List<TargetInspector> targetInspectors)
|
||||||
|
throws Exception {
|
||||||
Long lastId = null;
|
Long lastId = null;
|
||||||
|
|
||||||
// geom 잔여건수 != 프론트에서 넘어 온 총 건수 -> return
|
// geom 잔여건수 != 프론트에서 넘어 온 총 건수 -> return
|
||||||
Long chargeCnt = labelAllocateCoreService.findLabelUnAssignedCnt(3L); // TODO
|
Long chargeCnt = labelAllocateCoreService.findLabelUnAssignedCnt(3L); // TODO
|
||||||
Long totalDemand = targetUsers.stream().mapToLong(TargetUser::getDemand).sum();
|
// Long totalDemand = targetUsers.stream().mapToLong(TargetUser::getDemand).sum();
|
||||||
if (!Objects.equals(chargeCnt, totalDemand)) {
|
// if (!Objects.equals(chargeCnt, totalDemand)) {
|
||||||
log.info("chargeCnt != totalDemand");
|
// log.info("chargeCnt != totalDemand");
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
|
if (chargeCnt <= 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 라벨러에게 건수만큼 할당
|
List<Long> allIds = labelAllocateCoreService.fetchNextIds(lastId, chargeCnt);
|
||||||
|
int index = 0;
|
||||||
for (TargetUser target : targetUsers) {
|
for (TargetUser target : targetUsers) {
|
||||||
int remaining = target.getDemand();
|
int end = index + target.getDemand();
|
||||||
|
List<Long> sub = allIds.subList(index, end);
|
||||||
|
|
||||||
while (remaining > 0) {
|
labelAllocateCoreService.assignOwner(sub, target.getUserId());
|
||||||
|
index = end;
|
||||||
int batchSize = Math.min(remaining, 100);
|
|
||||||
List<Long> ids = labelAllocateCoreService.fetchNextIds(lastId, batchSize);
|
|
||||||
|
|
||||||
if (ids.isEmpty()) {
|
|
||||||
return; // 더이상 할당할 데이터가 없으면 return
|
|
||||||
}
|
|
||||||
|
|
||||||
labelAllocateCoreService.assignOwner(ids, target.getUserId());
|
|
||||||
|
|
||||||
remaining -= ids.size();
|
|
||||||
lastId = ids.get(ids.size() - 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 검수자에게 userCount명 만큼 할당
|
// 검수자에게 userCount명 만큼 할당
|
||||||
List<LabelAllocateDto.Basic> list = labelAllocateCoreService.findAssignedLabelerList(3L);
|
List<LabelAllocateDto.Basic> list = labelAllocateCoreService.findAssignedLabelerList(3L);
|
||||||
int reviewerIndex = 0;
|
int from = 0;
|
||||||
int count = 0;
|
|
||||||
log.info("list : " + list.size());
|
|
||||||
|
|
||||||
for (LabelAllocateDto.Basic labeler : list) {
|
for (TargetInspector inspector : targetInspectors) {
|
||||||
TargetInspector inspector = targetInspectors.get(reviewerIndex);
|
int to = Math.min(from + inspector.getUserCount(), list.size());
|
||||||
labelAllocateCoreService.assignInspector(
|
|
||||||
labeler.getAssignmentUid(), inspector.getInspectorUid());
|
|
||||||
count++;
|
|
||||||
|
|
||||||
if (count == inspector.getUserCount()) {
|
if (from >= to) {
|
||||||
reviewerIndex++;
|
break;
|
||||||
count = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<UUID> assignmentUids =
|
||||||
|
list.subList(from, to).stream().map(LabelAllocateDto.Basic::getAssignmentUid).toList();
|
||||||
|
|
||||||
|
labelAllocateCoreService.assignInspectorBulk(assignmentUids, inspector.getInspectorUid());
|
||||||
|
|
||||||
|
from = to;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -145,4 +145,8 @@ public class LabelAllocateService {
|
|||||||
|
|
||||||
return WorkerListResponse.builder().progressInfo(progressInfo).workers(workers).build();
|
return WorkerListResponse.builder().progressInfo(progressInfo).workers(workers).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public InferenceDetail findInferenceDetail(Long analUid) {
|
||||||
|
return labelAllocateCoreService.findInferenceDetail(analUid);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.kamco.cd.kamcoback.postgres.core;
|
package com.kamco.cd.kamcoback.postgres.core;
|
||||||
|
|
||||||
import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto;
|
import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto;
|
||||||
|
import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.InferenceDetail;
|
||||||
import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.UserList;
|
import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.UserList;
|
||||||
import com.kamco.cd.kamcoback.label.dto.WorkerStatsDto.WorkProgressInfo;
|
import com.kamco.cd.kamcoback.label.dto.WorkerStatsDto.WorkProgressInfo;
|
||||||
import com.kamco.cd.kamcoback.label.dto.WorkerStatsDto.WorkerStatistics;
|
import com.kamco.cd.kamcoback.label.dto.WorkerStatsDto.WorkerStatistics;
|
||||||
@@ -18,7 +19,7 @@ public class LabelAllocateCoreService {
|
|||||||
|
|
||||||
private final LabelAllocateRepository labelAllocateRepository;
|
private final LabelAllocateRepository labelAllocateRepository;
|
||||||
|
|
||||||
public List<Long> fetchNextIds(Long lastId, int batchSize) {
|
public List<Long> fetchNextIds(Long lastId, Long batchSize) {
|
||||||
return labelAllocateRepository.fetchNextIds(lastId, batchSize);
|
return labelAllocateRepository.fetchNextIds(lastId, batchSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,4 +63,12 @@ public class LabelAllocateCoreService {
|
|||||||
String workerId, String workerType, LocalDate date, Long analUid) {
|
String workerId, String workerType, LocalDate date, Long analUid) {
|
||||||
return labelAllocateRepository.findDailyProcessedCount(workerId, workerType, date, analUid);
|
return labelAllocateRepository.findDailyProcessedCount(workerId, workerType, date, analUid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void assignInspectorBulk(List<UUID> assignmentUids, String inspectorUid) {
|
||||||
|
labelAllocateRepository.assignInspectorBulk(assignmentUids, inspectorUid);
|
||||||
|
}
|
||||||
|
|
||||||
|
public InferenceDetail findInferenceDetail(Long analUid) {
|
||||||
|
return labelAllocateRepository.findInferenceDetail(analUid);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -103,4 +103,7 @@ public class MapSheetAnalEntity {
|
|||||||
@ColumnDefault("now()")
|
@ColumnDefault("now()")
|
||||||
@Column(name = "updated_dttm")
|
@Column(name = "updated_dttm")
|
||||||
private ZonedDateTime updatedDttm;
|
private ZonedDateTime updatedDttm;
|
||||||
|
|
||||||
|
@Column(name = "gukyuin_apply_dttm")
|
||||||
|
private ZonedDateTime gukyuinApplyDttm;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.kamco.cd.kamcoback.postgres.repository.label;
|
package com.kamco.cd.kamcoback.postgres.repository.label;
|
||||||
|
|
||||||
|
import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.InferenceDetail;
|
||||||
import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.UserList;
|
import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.UserList;
|
||||||
import com.kamco.cd.kamcoback.label.dto.WorkerStatsDto.WorkProgressInfo;
|
import com.kamco.cd.kamcoback.label.dto.WorkerStatsDto.WorkProgressInfo;
|
||||||
import com.kamco.cd.kamcoback.label.dto.WorkerStatsDto.WorkerStatistics;
|
import com.kamco.cd.kamcoback.label.dto.WorkerStatsDto.WorkerStatistics;
|
||||||
@@ -10,7 +11,7 @@ import java.util.UUID;
|
|||||||
|
|
||||||
public interface LabelAllocateRepositoryCustom {
|
public interface LabelAllocateRepositoryCustom {
|
||||||
|
|
||||||
List<Long> fetchNextIds(Long lastId, int batchSize);
|
List<Long> fetchNextIds(Long lastId, Long batchSize);
|
||||||
|
|
||||||
void assignOwner(List<Long> ids, String userId);
|
void assignOwner(List<Long> ids, String userId);
|
||||||
|
|
||||||
@@ -31,4 +32,8 @@ public interface LabelAllocateRepositoryCustom {
|
|||||||
|
|
||||||
// 작업자별 일일 처리량 조회
|
// 작업자별 일일 처리량 조회
|
||||||
Long findDailyProcessedCount(String workerId, String workerType, LocalDate date, Long analUid);
|
Long findDailyProcessedCount(String workerId, String workerType, LocalDate date, Long analUid);
|
||||||
|
|
||||||
|
void assignInspectorBulk(List<UUID> assignmentUids, String inspectorUid);
|
||||||
|
|
||||||
|
InferenceDetail findInferenceDetail(Long analUid);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetAnalEntity.mapShee
|
|||||||
import static com.kamco.cd.kamcoback.postgres.entity.QMemberEntity.memberEntity;
|
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;
|
||||||
|
import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.InferenceDetail;
|
||||||
import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.LabelState;
|
import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.LabelState;
|
||||||
import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.UserList;
|
import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.UserList;
|
||||||
import com.kamco.cd.kamcoback.label.dto.WorkerStatsDto.WorkProgressInfo;
|
import com.kamco.cd.kamcoback.label.dto.WorkerStatsDto.WorkProgressInfo;
|
||||||
@@ -15,6 +16,7 @@ import com.kamco.cd.kamcoback.postgres.entity.MapSheetAnalEntity;
|
|||||||
import com.querydsl.core.types.Projections;
|
import com.querydsl.core.types.Projections;
|
||||||
import com.querydsl.core.types.dsl.BooleanExpression;
|
import com.querydsl.core.types.dsl.BooleanExpression;
|
||||||
import com.querydsl.core.types.dsl.CaseBuilder;
|
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.NumberExpression;
|
||||||
import com.querydsl.core.types.dsl.StringExpression;
|
import com.querydsl.core.types.dsl.StringExpression;
|
||||||
import com.querydsl.jpa.impl.JPAQueryFactory;
|
import com.querydsl.jpa.impl.JPAQueryFactory;
|
||||||
@@ -42,7 +44,7 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
|
|||||||
@PersistenceContext private EntityManager em;
|
@PersistenceContext private EntityManager em;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Long> fetchNextIds(Long lastId, int batchSize) {
|
public List<Long> fetchNextIds(Long lastId, Long batchSize) {
|
||||||
|
|
||||||
return queryFactory
|
return queryFactory
|
||||||
.select(mapSheetAnalDataInferenceGeomEntity.geoUid)
|
.select(mapSheetAnalDataInferenceGeomEntity.geoUid)
|
||||||
@@ -53,7 +55,7 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
|
|||||||
mapSheetAnalDataInferenceGeomEntity.compareYyyy.eq(2022),
|
mapSheetAnalDataInferenceGeomEntity.compareYyyy.eq(2022),
|
||||||
mapSheetAnalDataInferenceGeomEntity.targetYyyy.eq(2024),
|
mapSheetAnalDataInferenceGeomEntity.targetYyyy.eq(2024),
|
||||||
mapSheetAnalDataInferenceGeomEntity.labelState.isNull())
|
mapSheetAnalDataInferenceGeomEntity.labelState.isNull())
|
||||||
.orderBy(mapSheetAnalDataInferenceGeomEntity.geoUid.asc())
|
.orderBy(mapSheetAnalDataInferenceGeomEntity.mapSheetNum.asc())
|
||||||
.limit(batchSize)
|
.limit(batchSize)
|
||||||
.fetch();
|
.fetch();
|
||||||
}
|
}
|
||||||
@@ -65,28 +67,28 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
|
|||||||
queryFactory
|
queryFactory
|
||||||
.update(mapSheetAnalDataInferenceGeomEntity)
|
.update(mapSheetAnalDataInferenceGeomEntity)
|
||||||
.set(mapSheetAnalDataInferenceGeomEntity.labelState, LabelState.ASSIGNED.getId())
|
.set(mapSheetAnalDataInferenceGeomEntity.labelState, LabelState.ASSIGNED.getId())
|
||||||
|
.set(mapSheetAnalDataInferenceGeomEntity.labelStateDttm, ZonedDateTime.now())
|
||||||
.where(mapSheetAnalDataInferenceGeomEntity.geoUid.in(ids))
|
.where(mapSheetAnalDataInferenceGeomEntity.geoUid.in(ids))
|
||||||
.execute();
|
.execute();
|
||||||
|
|
||||||
// 라벨러 할당 테이블에 insert
|
// 라벨러 할당 테이블에 insert
|
||||||
|
String sql =
|
||||||
|
"""
|
||||||
|
insert into tb_labeling_assignment
|
||||||
|
(assignment_uid, inference_geom_uid, worker_uid,
|
||||||
|
work_state, assign_group_id, anal_uid)
|
||||||
|
values (?, ?, ?, ?, ?, ?)
|
||||||
|
""";
|
||||||
|
|
||||||
for (Long geoUid : ids) {
|
for (Long geoUid : ids) {
|
||||||
queryFactory
|
em.createNativeQuery(sql)
|
||||||
.insert(labelingAssignmentEntity)
|
.setParameter(1, UUID.randomUUID())
|
||||||
.columns(
|
.setParameter(2, geoUid)
|
||||||
labelingAssignmentEntity.assignmentUid,
|
.setParameter(3, userId)
|
||||||
labelingAssignmentEntity.inferenceGeomUid,
|
.setParameter(4, LabelState.ASSIGNED.getId())
|
||||||
labelingAssignmentEntity.workerUid,
|
.setParameter(5, "")
|
||||||
labelingAssignmentEntity.workState,
|
.setParameter(6, 3)
|
||||||
labelingAssignmentEntity.assignGroupId,
|
.executeUpdate();
|
||||||
labelingAssignmentEntity.analUid)
|
|
||||||
.values(
|
|
||||||
UUID.randomUUID(),
|
|
||||||
geoUid,
|
|
||||||
userId,
|
|
||||||
LabelState.ASSIGNED.getId(),
|
|
||||||
"", // TODO: 도엽번호
|
|
||||||
3)
|
|
||||||
.execute();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
em.flush();
|
em.flush();
|
||||||
@@ -379,4 +381,38 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
|
|||||||
|
|
||||||
return count != null ? count : 0L;
|
return count != null ? count : 0L;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void assignInspectorBulk(List<UUID> assignmentUids, String inspectorUid) {
|
||||||
|
queryFactory
|
||||||
|
.update(labelingAssignmentEntity)
|
||||||
|
.set(labelingAssignmentEntity.inspectorUid, inspectorUid)
|
||||||
|
.where(labelingAssignmentEntity.assignmentUid.in(assignmentUids))
|
||||||
|
.execute();
|
||||||
|
|
||||||
|
em.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public InferenceDetail findInferenceDetail(Long analUid) {
|
||||||
|
return queryFactory
|
||||||
|
.select(
|
||||||
|
Projections.constructor(
|
||||||
|
InferenceDetail.class,
|
||||||
|
mapSheetAnalEntity.analTitle,
|
||||||
|
Expressions.numberTemplate(Integer.class, "{0}", 4),
|
||||||
|
mapSheetAnalEntity.gukyuinApplyDttm,
|
||||||
|
mapSheetAnalEntity.detectingCnt,
|
||||||
|
labelingAssignmentEntity.workerUid.countDistinct(),
|
||||||
|
labelingAssignmentEntity.inspectorUid.countDistinct()))
|
||||||
|
.from(mapSheetAnalEntity)
|
||||||
|
.innerJoin(labelingAssignmentEntity)
|
||||||
|
.on(mapSheetAnalEntity.id.eq(labelingAssignmentEntity.analUid))
|
||||||
|
.where(mapSheetAnalEntity.id.eq(analUid))
|
||||||
|
.groupBy(
|
||||||
|
mapSheetAnalEntity.analTitle,
|
||||||
|
mapSheetAnalEntity.gukyuinApplyDttm,
|
||||||
|
mapSheetAnalEntity.detectingCnt)
|
||||||
|
.fetchOne();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user