Merge branch 'feat/infer_dev_260107' of https://kamco.gitea.gs.dabeeo.com/dabeeo/kamco-dabeeo-backoffice into feat/infer_dev_260107

This commit is contained in:
Moon
2026-01-20 16:14:49 +09:00
37 changed files with 460 additions and 162 deletions

View File

@@ -74,11 +74,16 @@ public class ChangeDetectionApiController {
@Parameter(description = "5k/50k 구분(SCALE_5K/SCALE_50K))", required = true)
@RequestParam(defaultValue = "SCALE_50K")
MapScaleType scale,
@Parameter(
description = "변화탐지 년도(차수) /year-list 의 uuid",
example = "8584e8d4-53b3-4582-bde2-28a81495a626")
@RequestParam
UUID uuid,
@Parameter(description = "이전 년도", example = "2023") @RequestParam Integer beforeYear,
@Parameter(description = "이후 년도", example = "2024") @RequestParam Integer afterYear,
@Parameter(description = "도엽번호(5k)", example = "35905086") @RequestParam String mapSheetNum) {
ChangeDetectionDto.CogUrlReq req =
new ChangeDetectionDto.CogUrlReq(beforeYear, afterYear, mapSheetNum, type, scale);
new ChangeDetectionDto.CogUrlReq(uuid, beforeYear, afterYear, mapSheetNum, type, scale);
return ApiResponseDto.ok(changeDetectionService.getChangeDetectionCogUrl(req));
}

View File

@@ -86,6 +86,7 @@ public class ChangeDetectionDto {
@AllArgsConstructor
public static class CogUrlReq {
private UUID uuid;
private Integer beforeYear;
private Integer afterYear;
private String mapSheetNum;

View File

@@ -6,17 +6,50 @@ import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import lombok.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Component;
@Log4j2
@Component
@RequiredArgsConstructor
public class ExternalJarRunner {
public void run(String jarPath, String batchIds, String inferenceId, String mapIds) {
private static final long TIMEOUT_MINUTES = 30;
/**
* shp 파일 생성
*
* @param jarPath jar 경로
* @param batchIds 배치 아이디
* @param inferenceId uid
* @param mapIds 도엽 Id
*/
public void run(String jarPath, String batchIds, String inferenceId, String mapIds) {
List<String> args = new ArrayList<>();
addArg(args, "converter.inference-id", inferenceId);
addArg(args, "converter.map-ids", mapIds);
addArg(args, "converter.batch-ids", batchIds);
execJar(jarPath, args);
}
/**
* geoserver 등록
*
* @param jarPath jar 파일경로
* @param register shp 경로
* @param layer geoserver에 등록될 레이어 이름
*/
public void run(String jarPath, String register, String layer) {
List<String> args = new ArrayList<>();
addArg(args, "register", register);
addArg(args, "layer", layer);
execJar(jarPath, args);
}
private void execJar(String jarPath, List<String> args) {
StringBuilder out = new StringBuilder();
try {
@@ -24,16 +57,7 @@ public class ExternalJarRunner {
cmd.add("java");
cmd.add("-jar");
cmd.add(jarPath);
if (inferenceId != null && !inferenceId.isBlank()) {
cmd.add("--converter.inference-id=" + inferenceId);
}
if (mapIds != null && !mapIds.isBlank()) {
cmd.add("--converter.map-ids=" + mapIds);
}
if (batchIds != null && !batchIds.isBlank()) {
cmd.add("--converter.batch-ids=" + batchIds);
}
cmd.addAll(args);
ProcessBuilder pb = new ProcessBuilder(cmd);
pb.redirectErrorStream(true);
@@ -49,7 +73,7 @@ public class ExternalJarRunner {
}
}
boolean finished = p.waitFor(30, TimeUnit.MINUTES);
boolean finished = p.waitFor(TIMEOUT_MINUTES, TimeUnit.MINUTES);
if (!finished) {
p.destroyForcibly();
throw new RuntimeException("jar timeout\n" + out);
@@ -66,4 +90,10 @@ public class ExternalJarRunner {
log.error("jar execution error. output=\n{}", out, e);
}
}
private void addArg(List<String> args, String key, String value) {
if (value != null && !value.isBlank()) {
args.add("--" + key + "=" + value);
}
}
}

View File

@@ -25,10 +25,11 @@ import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.time.LocalDate;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import lombok.RequiredArgsConstructor;
import org.springframework.core.io.FileSystemResource;
@@ -45,7 +46,6 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.util.UriUtils;
@Tag(name = "추론관리", description = "추론관리 API")
@RequestMapping("/api/inference")
@@ -423,30 +423,32 @@ public class InferenceResultApiController {
throws IOException {
String path;
String uid;
try {
path = String.valueOf(inferenceResultService.shpDownloadPath(uuid));
Map<String, Object> map = inferenceResultService.shpDownloadPath(uuid);
path = String.valueOf(map.get("path"));
uid = String.valueOf(map.get("uid"));
} catch (CustomApiException e) {
// 데이터 없음 등 404
return ResponseEntity.status(e.getStatus()).build();
}
Path zipPath = Path.of(path);
FileSystemResource resource = new FileSystemResource(zipPath);
if (!resource.exists() || !resource.isReadable()) {
if (!Files.exists(zipPath) || !Files.isReadable(zipPath)) {
return ResponseEntity.notFound().build();
}
String filename = zipPath.getFileName().toString();
String encodedFilename = UriUtils.encode(filename, StandardCharsets.UTF_8);
FileSystemResource resource = new FileSystemResource(zipPath);
String filename = uid + ".zip";
long fileSize = Files.size(zipPath);
return ResponseEntity.ok()
.contentType(MediaType.APPLICATION_OCTET_STREAM)
.header(
HttpHeaders.CONTENT_DISPOSITION,
"attachment; filename=\"" + filename + "\"; filename*=UTF-8''" + encodedFilename)
.contentLength(resource.contentLength())
.body((Resource) resource);
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + filename + "\"")
.contentLength(fileSize)
.body(resource);
}
@Operation(summary = "shp 파일 다운로드 이력", description = "추론관리 분석결과 shp 파일 다운로드 이력")
@@ -490,4 +492,24 @@ public class InferenceResultApiController {
return ApiResponseDto.ok(inferenceResultService.getDownloadAudit(searchReq, downloadReq));
}
@Operation(summary = "추론 실행중인 도엽 목록", description = "추론관리 실행중인 도엽명 5k 목록")
@ApiResponses({
@ApiResponse(
responseCode = "200",
description = "검색 성공",
content =
@Content(
mediaType = "application/json",
schema = @Schema(implementation = ApiResponseDto.class))),
@ApiResponse(responseCode = "400", description = "잘못된 검색 조건", content = @Content),
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content)
})
@GetMapping(value = "/running-map/{uuid}")
public ApiResponseDto<List<String>> getInferenceRunMapName(
@Parameter(description = "uuid", example = "9d213416-0e9e-429a-b037-070e6a29946e")
@PathVariable
UUID uuid) {
return ApiResponseDto.ok(inferenceResultService.getInferenceRunMapId(uuid));
}
}

View File

@@ -41,6 +41,7 @@ import jakarta.validation.constraints.NotNull;
import java.nio.file.Path;
import java.time.ZonedDateTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@@ -578,11 +579,16 @@ public class InferenceResultService {
* @param uuid
* @return
*/
public Path shpDownloadPath(UUID uuid) {
public Map<String, Object> shpDownloadPath(UUID uuid) {
InferenceLearnDto dto = inferenceResultCoreService.getInferenceUid(uuid);
String uid = dto.getUid();
Path path = Path.of(datasetDir).resolve(uid).resolve("merge").resolve(uid + ".zip");
return Path.of(datasetDir).resolve(uid).resolve("merge").resolve(uid + ".zip");
Map<String, Object> downloadMap = new HashMap<>();
downloadMap.put("uid", uid);
downloadMap.put("path", path);
return downloadMap;
}
/**
@@ -595,4 +601,14 @@ public class InferenceResultService {
AuditLogDto.searchReq searchReq, DownloadReq downloadReq) {
return auditLogCoreService.findLogByAccount(searchReq, downloadReq);
}
/**
* 실행중인 추론 도엽명 목록
*
* @param uuid uuid
* @return
*/
public List<String> getInferenceRunMapId(UUID uuid) {
return inferenceResultCoreService.getInferenceRunMapId(uuid);
}
}

View File

@@ -123,7 +123,7 @@ public class LabelAllocateApiController {
int targetYyyy = Integer.parseInt(dto.getYyyy().split("-")[1]);
return ApiResponseDto.okObject(
labelAllocateService.allocateAsc(
dto.getStage(), dto.getLabelers(), dto.getInspectors(), compareYyyy, targetYyyy));
dto.getUuid(), dto.getLabelers(), dto.getInspectors(), compareYyyy, targetYyyy));
}
@Operation(summary = "작업현황 관리 > 변화탐지 회차 정보", description = "작업현황 관리 > 변화탐지 회차 정보")
@@ -318,4 +318,16 @@ public class LabelAllocateApiController {
LabelAllocateDto.searchReq searchReq = new LabelAllocateDto.searchReq(page, size, "");
return ApiResponseDto.ok(labelAllocateService.findWorkHistoryList(searchReq, userId, type));
}
@Operation(summary = "라벨링 작업 중인 회차 있는지 여부", description = "라벨링 작업 중인 회차 있는지 여부")
@ApiResponses(
value = {
@ApiResponse(responseCode = "200", description = "조회 성공"),
@ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음"),
@ApiResponse(responseCode = "500", description = "서버 오류")
})
@GetMapping("/ing-process-cnt")
public ApiResponseDto<Long> labelingIngProcessCnt() {
return ApiResponseDto.ok(labelAllocateService.findLabelingIngProcessCnt());
}
}

View File

@@ -86,6 +86,12 @@ public class LabelAllocateDto {
@AllArgsConstructor
public static class AllocateDto {
@Schema(
description = "회차 마스터 key",
example = "f97dc186-e6d3-4645-9737-3173dde8dc64",
required = true)
private UUID uuid;
@Schema(description = "비교년도-기준년도", example = "2022-2024", required = true)
private String yyyy;
@@ -95,7 +101,7 @@ public class LabelAllocateDto {
// @Schema(description = "기준년도", example = "2024", required = true)
// private Integer targetYyyy;
@Schema(description = "회차", example = "4", required = true)
@Schema(description = "회차", example = "4")
private Integer stage;
@Schema(

View File

@@ -46,8 +46,8 @@ public class LabelWorkDto {
private Long labelCompleteTotCnt;
@JsonFormatDttm private ZonedDateTime labelStartDttm;
// tb_map_sheet_anal_inference.anal_state 컬럼 값 -> 미사용
// private String analState;
// tb_map_sheet_anal_inference.anal_state 컬럼 값
private String analState;
// tb_labeling_assignment 테이블에서 stagnation_yn = 'N'인 정상 진행 건수
private Long normalProgressCnt;
@@ -73,9 +73,9 @@ public class LabelWorkDto {
/** 라벨링 상태 반환 (tb_map_sheet_anal_inference.anal_state 기준) */
public String getLabelState() {
// anal_state 값이 있으면 해당 값 사용 -> 우선은 미사용
// if (this.analState != null && !this.analState.isEmpty()) {
// return this.analState;
// }
if (this.analState != null && !this.analState.isEmpty()) {
return this.analState;
}
// anal_state 값이 없으면 기존 로직으로 폴백
String mngState = LabelMngState.PENDING.getId();
@@ -84,10 +84,10 @@ public class LabelWorkDto {
mngState = LabelMngState.PENDING.getId();
} else if (this.labelTotCnt > 0 && this.labelAssignCnt > 0 && this.labelCompleteTotCnt == 0) {
mngState = LabelMngState.ASSIGNED.getId();
} else if (this.labelCompleteTotCnt > 0) {
mngState = LabelMngState.ING.getId();
} else if (this.labelingClosedYn.equals("Y") && this.inspectionClosedYn.equals("Y")) {
mngState = LabelMngState.FINISH.getId();
} else if (this.labelCompleteTotCnt > 0) {
mngState = LabelMngState.ING.getId();
}
return mngState;

View File

@@ -5,6 +5,7 @@ import com.kamco.cd.kamcoback.config.api.ApiResponseDto.ApiResponseCode;
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;
import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.LabelMngState;
import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.LabelerDetail;
import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.LabelingStatDto;
import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.MoveInfo;
@@ -18,6 +19,7 @@ import com.kamco.cd.kamcoback.label.dto.WorkerStatsDto.WorkerListResponse;
import com.kamco.cd.kamcoback.postgres.core.LabelAllocateCoreService;
import java.util.List;
import java.util.Objects;
import java.util.UUID;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Service;
@@ -37,13 +39,13 @@ public class LabelAllocateService {
/**
* 도엽 기준 asc sorting 해서 할당 수만큼 배정하는 로직
*
* @param stage 회차
* @param uuid 회차 key
* @param targetUsers 라벨러 목록
* @param targetInspectors 검수자 목록
*/
@Transactional
public ApiResponseDto.ResponseObj allocateAsc(
Integer stage,
UUID uuid,
List<TargetUser> targetUsers,
List<String> targetInspectors,
Integer compareYyyy,
@@ -51,8 +53,7 @@ public class LabelAllocateService {
Long lastId = null;
// geom 잔여건수 조회
Long chargeCnt =
labelAllocateCoreService.findLabelUnAssignedCnt(stage, compareYyyy, targetYyyy);
Long chargeCnt = labelAllocateCoreService.findLabelUnAssignedCnt(uuid);
if (chargeCnt <= 0) {
return new ApiResponseDto.ResponseObj(ApiResponseCode.DUPLICATE_DATA, "이미 배정완료된 회차 입니다.");
}
@@ -63,12 +64,10 @@ public class LabelAllocateService {
ApiResponseCode.BAD_REQUEST, "총 잔여건수와 요청 값의 합계가 맞지 않습니다.");
}
List<AllocateInfoDto> allIds =
labelAllocateCoreService.fetchNextIds(lastId, chargeCnt, compareYyyy, targetYyyy, stage);
List<AllocateInfoDto> allIds = labelAllocateCoreService.fetchNextIds(lastId, chargeCnt, uuid);
// MapSheetAnalInferenceEntity analUid 가져오기
Long analUid =
labelAllocateCoreService.findMapSheetAnalInferenceUid(compareYyyy, targetYyyy, stage);
Long analUid = labelAllocateCoreService.findMapSheetAnalInferenceUid(uuid);
int index = 0;
for (TargetUser target : targetUsers) {
@@ -82,11 +81,13 @@ public class LabelAllocateService {
labelAllocateCoreService.insertLabelerUser(analUid, target.getUserId(), target.getDemand());
}
// 검수자 할당 테이블에 insert. TODO: 익일 배치로 라벨링 완료된 내역을 검수자에게 할당해야 함
// 검수자 할당 테이블에 insert.
for (String inspector : targetInspectors) {
labelAllocateCoreService.insertInspector(analUid, inspector);
}
labelAllocateCoreService.updateAnalInferenceMngState(uuid, LabelMngState.ASSIGNED.getId());
return new ApiResponseDto.ResponseObj(ApiResponseCode.OK, "배정이 완료되었습니다.");
}
@@ -257,6 +258,8 @@ public class LabelAllocateService {
}
labelAllocateCoreService.updateClosedYnByUuid(targetUuid, closedType, closedYn);
labelAllocateCoreService.updateAnalInferenceMngState(
UUID.fromString(targetUuid), LabelMngState.FINISH.getId());
}
public Page<WorkHistoryDto> findWorkHistoryList(searchReq searchReq, String userId, String type) {
@@ -266,4 +269,8 @@ public class LabelAllocateService {
return labelAllocateCoreService.workReviewerHistoryList(searchReq, userId);
}
}
public Long findLabelingIngProcessCnt() {
return labelAllocateCoreService.findLabelingIngProcessCnt();
}
}

View File

@@ -350,7 +350,8 @@ public class MapSheetMngService {
List<MngDto> mngList = mapSheetMngCoreService.findMapSheetMngList();
List<MngYyyyDto> yearList =
mngList.stream()
.filter(dto -> "DONE".equals(dto.getMngState()) || "TAKINGERROR".equals(dto.getMngState()))
.filter(
dto -> "DONE".equals(dto.getMngState()) || "TAKINGERROR".equals(dto.getMngState()))
.map(dto -> new MngYyyyDto(dto.getMngYyyy(), dto.getMngPath()))
.toList();

View File

@@ -476,4 +476,14 @@ public class InferenceResultCoreService {
dto.setUid(entity.getUid());
return dto;
}
/**
* 실행중인 추론 도엽명 목록
*
* @param uuid 추론 실행중인 uuid
* @return
*/
public List<String> getInferenceRunMapId(UUID uuid) {
return mapSheetLearn5kRepository.getInferenceRunMapId(uuid);
}
}

View File

@@ -27,9 +27,8 @@ public class LabelAllocateCoreService {
private final LabelAllocateRepository labelAllocateRepository;
public List<AllocateInfoDto> fetchNextIds(
Long lastId, Long batchSize, Integer compareYyyy, Integer targetYyyy, Integer stage) {
return labelAllocateRepository.fetchNextIds(lastId, batchSize, compareYyyy, targetYyyy, stage);
public List<AllocateInfoDto> fetchNextIds(Long lastId, Long batchSize, UUID uuid) {
return labelAllocateRepository.fetchNextIds(lastId, batchSize, uuid);
}
public void assignOwner(List<AllocateInfoDto> ids, String userId, Long analUid) {
@@ -42,8 +41,8 @@ public class LabelAllocateCoreService {
.toList();
}
public Long findLabelUnAssignedCnt(Integer stage, Integer compareYyyy, Integer targetYyyy) {
return labelAllocateRepository.findLabelUnAssignedCnt(stage, compareYyyy, targetYyyy);
public Long findLabelUnAssignedCnt(UUID uuid) {
return labelAllocateRepository.findLabelUnAssignedCnt(uuid);
}
public void assignInspector(UUID assignmentUid, String inspectorUid) {
@@ -144,8 +143,8 @@ public class LabelAllocateCoreService {
return detail;
}
public Long findMapSheetAnalInferenceUid(Integer compareYyyy, Integer targetYyyy, Integer stage) {
return labelAllocateRepository.findMapSheetAnalInferenceUid(compareYyyy, targetYyyy, stage);
public Long findMapSheetAnalInferenceUid(UUID uuid) {
return labelAllocateRepository.findMapSheetAnalInferenceUid(uuid);
}
public void insertInspector(Long analUid, String inspector) {
@@ -227,4 +226,12 @@ public class LabelAllocateCoreService {
public Page<WorkHistoryDto> workReviewerHistoryList(searchReq searchReq, String userId) {
return labelAllocateRepository.workReviewerHistoryList(searchReq, userId);
}
public void updateAnalInferenceMngState(UUID uuid, String status) {
labelAllocateRepository.updateAnalInferenceMngState(uuid, status);
}
public Long findLabelingIngProcessCnt() {
return labelAllocateRepository.findLabelingIngProcessCnt();
}
}

View File

@@ -4,6 +4,7 @@ import com.kamco.cd.kamcoback.postgres.repository.trainingdata.TrainingDataLabel
import com.kamco.cd.kamcoback.trainingdata.dto.TrainingDataLabelDto;
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.InferenceIdInfo;
import com.kamco.cd.kamcoback.trainingdata.dto.TrainingDataLabelDto.LabelFeatureRequest.LabelProperties;
import com.kamco.cd.kamcoback.trainingdata.dto.TrainingDataLabelDto.LabelingGeometryInfo;
import com.kamco.cd.kamcoback.trainingdata.dto.TrainingDataLabelDto.LabelingListDto;
@@ -29,7 +30,7 @@ public class TrainingDataLabelCoreService {
return trainingDataLabelRepository.findLabelingAssignedGeom(assignmentUid);
}
public Long findLabelingAssignmentGeoUid(String assignmentUid) {
public InferenceIdInfo findLabelingAssignmentGeoUid(String assignmentUid) {
return trainingDataLabelRepository.findLabelingAssignmentGeoUid(assignmentUid);
}
@@ -89,4 +90,8 @@ public class TrainingDataLabelCoreService {
String mapSheetNum, Integer beforeYear, Integer afterYear) {
return trainingDataLabelRepository.getCogImageUrl(mapSheetNum, beforeYear, afterYear);
}
public void updateAnalInferenceMngState(Long analUid, String status) {
trainingDataLabelRepository.updateAnalInferenceMngState(analUid, status);
}
}

View File

@@ -1,6 +1,7 @@
package com.kamco.cd.kamcoback.postgres.core;
import com.kamco.cd.kamcoback.postgres.repository.trainingdata.TrainingDataReviewRepository;
import com.kamco.cd.kamcoback.trainingdata.dto.TrainingDataLabelDto.InferenceIdInfo;
import com.kamco.cd.kamcoback.trainingdata.dto.TrainingDataReviewDto;
import com.kamco.cd.kamcoback.trainingdata.dto.TrainingDataReviewDto.DefaultPaging;
import com.kamco.cd.kamcoback.trainingdata.dto.TrainingDataReviewDto.DetailRes;
@@ -29,7 +30,7 @@ public class TrainingDataReviewCoreService {
return trainingDataReviewRepository.findReviewAssignedGeom(operatorUid);
}
public Long findReviewOperatorGeoUid(String operatorUid) {
public InferenceIdInfo findReviewOperatorGeoUid(String operatorUid) {
return trainingDataReviewRepository.findReviewOperatorGeoUid(operatorUid);
}
@@ -89,4 +90,8 @@ public class TrainingDataReviewCoreService {
String mapSheetNum, Integer beforeYear, Integer afterYear) {
return trainingDataReviewRepository.getCogImageUrl(mapSheetNum, beforeYear, afterYear);
}
public void updateAnalInferenceMngState(Long analUid, String status) {
trainingDataReviewRepository.updateAnalInferenceMngState(analUid, status);
}
}

View File

@@ -37,4 +37,8 @@ public class TrainingDataReviewJobCoreService {
public void lockInspectors(Long analUid, List<String> reviewerIds) {
trainingDataReviewJobRepository.lockInspectors(analUid, reviewerIds);
}
public void updateGeomUidTestState(List<Long> geomUids) {
trainingDataReviewJobRepository.updateGeomUidTestState(geomUids);
}
}

View File

@@ -30,12 +30,6 @@ public class InferenceResultsTestingEntity {
@Column(name = "map_id", length = Integer.MAX_VALUE)
private String mapId;
@Column(name = "source_1", length = Integer.MAX_VALUE)
private String source1;
@Column(name = "source_2", length = Integer.MAX_VALUE)
private String source2;
@Column(name = "model_version", length = Integer.MAX_VALUE)
private String modelVersion;
@@ -60,9 +54,6 @@ public class InferenceResultsTestingEntity {
@Column(name = "area")
private Double area;
@Column(name = "cd_prob")
private Double cdProb;
@Column(name = "before_c", length = Integer.MAX_VALUE)
private String beforeC;
@@ -75,12 +66,6 @@ public class InferenceResultsTestingEntity {
@Column(name = "after_p")
private Double afterP;
@Column(name = "input1")
private Long input1;
@Column(name = "input2")
private Long input2;
@Id
@NotNull
@ColumnDefault("nextval('inference_results_testing_seq_seq')")

View File

@@ -187,7 +187,7 @@ public class MapSheetLearnEntity {
private int m3FailedJobs = 0;
@Column(name = "uid", nullable = false)
private String uid = UUID.randomUUID().toString().replace("-", "");
private String uid = UUID.randomUUID().toString().replace("-", "").toUpperCase();
public InferenceResultDto.ResultList toDto() {
return new InferenceResultDto.ResultList(

View File

@@ -52,7 +52,8 @@ public class InferenceResultRepositoryImpl implements InferenceResultRepositoryC
m1_model_batch_id,
m2_model_batch_id,
m3_model_batch_id,
learn_id
learn_id,
anal_state
)
SELECT
r.stage,
@@ -64,7 +65,8 @@ public class InferenceResultRepositoryImpl implements InferenceResultRepositoryC
r.m1_model_batch_id,
r.m2_model_batch_id,
r.m3_model_batch_id,
r.id
r.id,
LabelMngState.PENDING.getId()
FROM tb_map_sheet_learn r
WHERE r.id = :id
ON CONFLICT (stage, compare_yyyy, target_yyyy)
@@ -217,11 +219,15 @@ public class InferenceResultRepositoryImpl implements InferenceResultRepositoryC
msl.m2_model_batch_id,
msl.m3_model_batch_id
)
inner join tb_map_sheet_anal_data_inference msadi
on msadi.anal_uid = msl.anal_uid
INNER JOIN tb_map_sheet_anal_data_inference msadi
ON msadi.anal_uid = msl.anal_uid
AND r.map_id ~ '^[0-9]+$'
AND r.map_id::bigint = msadi.map_sheet_num
where msl.anal_uid = :analUid
AND r.map_id::bigint = msadi.map_sheet_num
WHERE msl.anal_uid = :analUid
AND r.before_c is not null
AND r.before_p is not null
AND r.after_c is not null
AND r.after_p is not null
ORDER BY r.uid, r.created_date DESC NULLS LAST
) x
ON CONFLICT (result_uid)

View File

@@ -6,4 +6,6 @@ import java.util.UUID;
public interface MapSheetLearn5kRepositoryCustom {
void saveFail5k(UUID uuid, List<Long> failMapIds, String type);
List<String> getInferenceRunMapId(UUID uuid);
}

View File

@@ -1,9 +1,11 @@
package com.kamco.cd.kamcoback.postgres.repository.Inference;
import static com.kamco.cd.kamcoback.postgres.entity.QMapInkx5kEntity.mapInkx5kEntity;
import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetLearn5kEntity.mapSheetLearn5kEntity;
import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetLearnEntity.mapSheetLearnEntity;
import com.querydsl.core.types.dsl.BooleanPath;
import com.querydsl.core.types.dsl.Expressions;
import com.querydsl.jpa.impl.JPAQueryFactory;
import java.util.List;
import java.util.UUID;
@@ -59,4 +61,25 @@ public class MapSheetLearn5kRepositoryImpl implements MapSheetLearn5kRepositoryC
.and(mapSheetLearn5kEntity.mapSheetNum.in(failMapIds)))
.execute();
}
@Override
public List<String> getInferenceRunMapId(UUID uuid) {
return queryFactory
.select(mapInkx5kEntity.mapidNm)
.from(mapSheetLearnEntity)
.innerJoin(mapSheetLearn5kEntity)
.on(mapSheetLearn5kEntity.learn.id.eq(mapSheetLearnEntity.id))
.innerJoin(mapInkx5kEntity)
.on(
Expressions.booleanTemplate(
"function('regexp_match', {0}, '^[0-9]+$') is not null",
mapInkx5kEntity.mapidcdNo)
.and(
mapSheetLearn5kEntity.mapSheetNum.eq(
Expressions.numberTemplate(
Long.class, "cast({0} as long)", mapInkx5kEntity.mapidcdNo))))
.where(mapSheetLearnEntity.uuid.eq(uuid))
.groupBy(mapInkx5kEntity.mapidNm)
.fetch();
}
}

View File

@@ -24,6 +24,7 @@ import com.kamco.cd.kamcoback.postgres.entity.MapSheetLearnEntity;
import com.kamco.cd.kamcoback.postgres.entity.QModelMngEntity;
import com.querydsl.core.BooleanBuilder;
import com.querydsl.core.types.Projections;
import com.querydsl.core.types.dsl.BooleanExpression;
import com.querydsl.core.types.dsl.CaseBuilder;
import com.querydsl.core.types.dsl.Expressions;
import com.querydsl.core.types.dsl.NumberExpression;
@@ -360,42 +361,56 @@ public class MapSheetLearnRepositoryImpl implements MapSheetLearnRepositoryCusto
@Override
public Page<Geom> getInferenceGeomList(UUID uuid, SearchGeoReq searchGeoReq) {
Pageable pageable = searchGeoReq.toPageable();
BooleanBuilder builder = new BooleanBuilder();
BooleanBuilder where = new BooleanBuilder();
// analUid로 분석 정보 조회
// 1) 분석 엔티티 조회
MapSheetLearnEntity analEntity =
queryFactory
.selectFrom(mapSheetLearnEntity)
.where(mapSheetLearnEntity.uuid.eq(uuid))
.fetchOne();
if (Objects.isNull(analEntity)) {
if (analEntity == null) {
throw new CustomApiException("NOT_FOUND_DATA", HttpStatus.NOT_FOUND);
}
// 추론결과 id
builder.and(mapSheetAnalInferenceEntity.learnId.eq(analEntity.getId()));
// 2) where 조건
where.and(mapSheetAnalInferenceEntity.learnId.eq(analEntity.getId()));
// 기준년도 분류
if (searchGeoReq.getTargetClass() != null && !searchGeoReq.getTargetClass().equals("")) {
builder.and(
if (searchGeoReq.getTargetClass() != null && !searchGeoReq.getTargetClass().isBlank()) {
where.and(
mapSheetAnalDataInferenceGeomEntity.classAfterCd.eq(
searchGeoReq.getTargetClass().toLowerCase()));
}
// 비교년도 분류
if (searchGeoReq.getCompareClass() != null && !searchGeoReq.getCompareClass().equals("")) {
builder.and(
if (searchGeoReq.getCompareClass() != null && !searchGeoReq.getCompareClass().isBlank()) {
where.and(
mapSheetAnalDataInferenceGeomEntity.classBeforeCd.eq(
searchGeoReq.getCompareClass().toLowerCase()));
}
// 분석도엽
if (searchGeoReq.getMapSheetNum() != null) {
Long mapSheetNum = searchGeoReq.getMapSheetNum();
builder.and(mapSheetAnalDataInferenceGeomEntity.mapSheetNum.like("%" + mapSheetNum + "%"));
//
// where.and(mapSheetAnalDataInferenceGeomEntity.mapSheetNum.eq(searchGeoReq.getMapSheetNum()));
where.and(
mapSheetAnalDataInferenceGeomEntity.mapSheetNum.like(
"%" + searchGeoReq.getMapSheetNum() + "%"));
}
where.and(mapSheetAnalDataInferenceGeomEntity.classAfterCd.isNotNull());
where.and(mapSheetAnalDataInferenceGeomEntity.classAfterProb.isNotNull());
where.and(mapSheetAnalDataInferenceGeomEntity.classBeforeCd.isNotNull());
where.and(mapSheetAnalDataInferenceGeomEntity.classBeforeProb.isNotNull());
// 3) inkx 조인 조건: JPQL/HQL에서 '~' 불가 → function('regexp_match', ...) 사용
BooleanExpression inkxIsNumeric =
Expressions.booleanTemplate(
"function('regexp_match', {0}, '^[0-9]+$') is not null", mapInkx5kEntity.mapidcdNo);
NumberExpression<Long> inkxNoAsLong =
Expressions.numberTemplate(Long.class, "cast({0} as long)", mapInkx5kEntity.mapidcdNo);
// 4) content
List<Geom> content =
queryFactory
.select(
@@ -411,45 +426,32 @@ public class MapSheetLearnRepositoryImpl implements MapSheetLearnRepositoryCusto
mapSheetAnalDataInferenceGeomEntity.classAfterCd,
mapSheetAnalDataInferenceGeomEntity.classAfterProb,
mapSheetAnalDataInferenceGeomEntity.mapSheetNum,
mapInkx5kEntity.mapidNm
// Expressions.stringTemplate(
// "ST_AsGeoJSON({0})",
// mapSheetAnalDataInferenceGeomEntity.geom),
// Expressions.stringTemplate(
// "ST_AsGeoJSON({0})",
// mapSheetAnalDataInferenceGeomEntity.geomCenter)
))
mapInkx5kEntity.mapidNm))
.from(mapSheetAnalInferenceEntity)
.join(mapSheetAnalDataInferenceEntity)
.on(mapSheetAnalDataInferenceEntity.analUid.eq(mapSheetAnalInferenceEntity.id))
.join(mapSheetAnalDataInferenceGeomEntity)
.on(mapSheetAnalDataInferenceGeomEntity.dataUid.eq(mapSheetAnalDataInferenceEntity.id))
.join(mapInkx5kEntity)
.on(
mapSheetAnalDataInferenceGeomEntity.mapSheetNum.eq(
Expressions.numberTemplate(
Long.class, "CAST({0} AS long)", mapInkx5kEntity.mapidcdNo)))
.where(builder)
.on(inkxIsNumeric.and(mapSheetAnalDataInferenceGeomEntity.mapSheetNum.eq(inkxNoAsLong)))
.where(where)
.orderBy(mapSheetAnalDataInferenceGeomEntity.geoUid.desc())
.offset(pageable.getOffset())
.limit(pageable.getPageSize())
.fetch();
long total =
// 5) total (조인 최소화 유지)
Long total =
queryFactory
.select(mapSheetAnalDataInferenceGeomEntity.geoUid)
.select(mapSheetAnalDataInferenceGeomEntity.geoUid.count())
.from(mapSheetAnalInferenceEntity)
.join(mapSheetAnalDataInferenceEntity)
.on(mapSheetAnalDataInferenceEntity.analUid.eq(mapSheetAnalInferenceEntity.id))
.join(mapSheetAnalDataInferenceGeomEntity)
.on(mapSheetAnalDataInferenceGeomEntity.dataUid.eq(mapSheetAnalDataInferenceEntity.id))
.join(mapInkx5kEntity)
.on(
mapSheetAnalDataInferenceGeomEntity.mapSheetNum.eq(
Expressions.numberTemplate(
Long.class, "CAST({0} AS long)", mapInkx5kEntity.mapidcdNo)))
.where(builder)
.fetchCount();
.where(where)
.fetchOne();
return new PageImpl<>(content, pageable, total);
return new PageImpl<>(content, pageable, total == null ? 0L : total);
}
}

View File

@@ -12,6 +12,7 @@ import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.kamco.cd.kamcoback.changedetection.dto.ChangeDetectionDto;
import com.kamco.cd.kamcoback.changedetection.dto.ChangeDetectionDto.DetectSearchType;
import com.kamco.cd.kamcoback.changedetection.dto.ChangeDetectionDto.MapScaleType;
import com.kamco.cd.kamcoback.changedetection.dto.ChangeDetectionDto.MapSheetList;
import com.kamco.cd.kamcoback.postgres.entity.MapSheetAnalDataInferenceGeomEntity;
@@ -111,6 +112,26 @@ public class ChangeDetectionRepositoryImpl extends QuerydslRepositorySupport
@Override
public ChangeDetectionDto.CogUrlDto getChangeDetectionCogUrl(ChangeDetectionDto.CogUrlReq req) {
String mapSheetNum = req.getMapSheetNum();
if (req.getType().equals(DetectSearchType.MAPSHEET)
&& req.getScale().equals(MapScaleType.SCALE_50K)) {
mapSheetNum =
queryFactory
.select(mapSheetAnalDataInferenceEntity.mapSheetNum.stringValue())
.from(mapSheetAnalInferenceEntity)
.innerJoin(mapSheetAnalDataInferenceEntity)
.on(mapSheetAnalInferenceEntity.id.eq(mapSheetAnalDataInferenceEntity.analUid))
.where(
mapSheetAnalInferenceEntity.uuid.eq(req.getUuid()),
mapSheetAnalDataInferenceEntity
.mapSheetNum
.stringValue()
.like("%" + req.getMapSheetNum() + "%"))
.orderBy(mapSheetAnalDataInferenceEntity.mapSheetNum.asc())
.fetchFirst();
}
ChangeDetectionDto.CogUrlData data =
queryFactory
.select(
@@ -128,7 +149,7 @@ public class ChangeDetectionRepositoryImpl extends QuerydslRepositorySupport
.year
.eq(req.getBeforeYear())
.or(imageryEntity.year.eq(req.getAfterYear())),
imageryEntity.scene5k.eq(req.getMapSheetNum()))
imageryEntity.scene5k.eq(mapSheetNum))
.groupBy(mapInkx5kEntity.geom)
.fetchOne();
@@ -191,6 +212,7 @@ public class ChangeDetectionRepositoryImpl extends QuerydslRepositorySupport
.where(
mapSheetAnalInferenceEntity.uuid.eq(uuid),
mapScaleTypeAnalDataSearchExpression(scale, mapSheetNum))
.orderBy(mapSheetAnalDataInferenceGeomEntity.mapSheetNum.asc())
.fetch();
ObjectMapper mapper = new ObjectMapper();
@@ -313,7 +335,8 @@ public class ChangeDetectionRepositoryImpl extends QuerydslRepositorySupport
.on(mapSheetAnalDataInferenceEntity.mapSheetNum.stringValue().eq(mapInkx5kEntity.mapidcdNo))
.innerJoin(mapInkx5kEntity.mapInkx50k, mapInkx50kEntity)
.where(mapSheetAnalInferenceEntity.uuid.eq(uuid))
.orderBy(mapInkx5kEntity.mapidcdNo.asc())
.groupBy(mapInkx50kEntity.mapidcdNo, mapInkx50kEntity.mapidNm)
.orderBy(mapInkx50kEntity.mapidcdNo.asc())
.fetch();
}

View File

@@ -20,14 +20,13 @@ import org.springframework.data.domain.Page;
public interface LabelAllocateRepositoryCustom {
List<AllocateInfoDto> fetchNextIds(
Long lastId, Long batchSize, Integer compareYyyy, Integer targetYyyy, Integer stage);
List<AllocateInfoDto> fetchNextIds(Long lastId, Long batchSize, UUID uuid);
void assignOwner(List<AllocateInfoDto> ids, String userId, Long analUid);
List<LabelingAssignmentEntity> findAssignedLabelerList(Long analUid);
Long findLabelUnAssignedCnt(Integer stage, Integer compareYyyy, Integer targetYyyy);
Long findLabelUnAssignedCnt(UUID uuid);
void assignInspector(UUID assignmentUid, String userId);
@@ -74,7 +73,7 @@ public interface LabelAllocateRepositoryCustom {
/** UUID로 analUid 조회 */
Long findAnalUidByUuid(String uuid);
Long findMapSheetAnalInferenceUid(Integer compareYyyy, Integer targetYyyy, Integer stage);
Long findMapSheetAnalInferenceUid(UUID uuid);
void insertInspector(Long analUid, String inspector);
@@ -101,4 +100,8 @@ public interface LabelAllocateRepositoryCustom {
Page<WorkHistoryDto> workLabelHistoryList(LabelAllocateDto.searchReq searchReq, String userId);
Page<WorkHistoryDto> workReviewerHistoryList(searchReq searchReq, String userId);
void updateAnalInferenceMngState(UUID uuid, String status);
Long findLabelingIngProcessCnt();
}

View File

@@ -13,6 +13,7 @@ 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;
import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.InspectState;
import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.LabelMngState;
import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.LabelState;
import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.LabelerDetail;
import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.LabelingStatDto;
@@ -66,8 +67,7 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
@PersistenceContext private EntityManager em;
@Override
public List<AllocateInfoDto> fetchNextIds(
Long lastId, Long batchSize, Integer compareYyyy, Integer targetYyyy, Integer stage) {
public List<AllocateInfoDto> fetchNextIds(Long lastId, Long batchSize, UUID uuid) {
return queryFactory
.select(
@@ -76,14 +76,17 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
mapSheetAnalDataInferenceGeomEntity.geoUid,
mapSheetAnalDataInferenceGeomEntity.mapSheetNum,
mapSheetAnalDataInferenceGeomEntity.pnu))
.from(mapSheetAnalDataInferenceGeomEntity)
.where(
lastId == null ? null : mapSheetAnalDataInferenceGeomEntity.geoUid.gt(lastId),
.from(mapSheetAnalInferenceEntity)
.innerJoin(mapSheetAnalDataInferenceEntity)
.on(mapSheetAnalInferenceEntity.id.eq(mapSheetAnalDataInferenceEntity.analUid))
.innerJoin(mapSheetAnalDataInferenceGeomEntity)
.on(
mapSheetAnalDataInferenceEntity.id.eq(mapSheetAnalDataInferenceGeomEntity.dataUid),
mapSheetAnalDataInferenceGeomEntity.pnu.isNotNull(),
mapSheetAnalDataInferenceGeomEntity.compareYyyy.eq(compareYyyy),
mapSheetAnalDataInferenceGeomEntity.targetYyyy.eq(targetYyyy),
mapSheetAnalDataInferenceGeomEntity.stage.eq(stage),
mapSheetAnalDataInferenceGeomEntity.labelState.isNull())
.where(
mapSheetAnalInferenceEntity.uuid.eq(uuid),
lastId == null ? null : mapSheetAnalDataInferenceGeomEntity.geoUid.gt(lastId))
.orderBy(mapSheetAnalDataInferenceGeomEntity.mapSheetNum.asc())
.limit(batchSize)
.fetch();
@@ -177,17 +180,19 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
}
@Override
public Long findLabelUnAssignedCnt(Integer stage, Integer compareYyyy, Integer targetYyyy) {
public Long findLabelUnAssignedCnt(UUID uuid) {
return queryFactory
.select(mapSheetAnalDataInferenceGeomEntity.geoUid.count())
.from(mapSheetAnalDataInferenceGeomEntity)
.where(
.from(mapSheetAnalInferenceEntity)
.innerJoin(mapSheetAnalDataInferenceEntity)
.on(mapSheetAnalInferenceEntity.id.eq(mapSheetAnalDataInferenceEntity.analUid))
.innerJoin(mapSheetAnalDataInferenceGeomEntity)
.on(
mapSheetAnalDataInferenceEntity.id.eq(mapSheetAnalDataInferenceGeomEntity.dataUid),
mapSheetAnalDataInferenceGeomEntity.pnu.isNotNull(),
mapSheetAnalDataInferenceGeomEntity.compareYyyy.eq(compareYyyy),
mapSheetAnalDataInferenceGeomEntity.targetYyyy.eq(targetYyyy),
mapSheetAnalDataInferenceGeomEntity.stage.eq(stage),
mapSheetAnalDataInferenceGeomEntity.labelState.isNull())
.where(mapSheetAnalInferenceEntity.uuid.eq(uuid))
.fetchOne();
}
@@ -912,14 +917,11 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
}
@Override
public Long findMapSheetAnalInferenceUid(Integer compareYyyy, Integer targetYyyy, Integer stage) {
public Long findMapSheetAnalInferenceUid(UUID uuid) {
return queryFactory
.select(mapSheetAnalInferenceEntity.id)
.from(mapSheetAnalInferenceEntity)
.where(
mapSheetAnalInferenceEntity.compareYyyy.eq(compareYyyy),
mapSheetAnalInferenceEntity.targetYyyy.eq(targetYyyy),
mapSheetAnalInferenceEntity.stage.eq(stage))
.where(mapSheetAnalInferenceEntity.uuid.eq(uuid))
.fetchOne();
}
@@ -1784,4 +1786,23 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
return new PageImpl<>(list, pageable, countQuery != null ? countQuery : 0L);
}
@Override
public void updateAnalInferenceMngState(UUID uuid, String status) {
queryFactory
.update(mapSheetAnalInferenceEntity)
.set(mapSheetAnalInferenceEntity.analState, status)
.set(mapSheetAnalInferenceEntity.updatedDttm, ZonedDateTime.now())
.where(mapSheetAnalInferenceEntity.uuid.eq(uuid))
.execute();
}
@Override
public Long findLabelingIngProcessCnt() {
return queryFactory
.select(mapSheetAnalInferenceEntity.id.count())
.from(mapSheetAnalInferenceEntity)
.where(mapSheetAnalInferenceEntity.analState.eq(LabelMngState.ING.getId()))
.fetchOne();
}
}

View File

@@ -138,7 +138,9 @@ public class LabelWorkRepositoryImpl implements LabelWorkRepositoryCustom {
mapSheetAnalDataInferenceGeomEntity
.pnu
.isNotNull()
.and(mapSheetAnalDataInferenceGeomEntity.pnu.ne(0L))
.and(
mapSheetAnalDataInferenceGeomEntity.pnu
.isNotNull()) // TODO: 이노팸 연동 후 0 이상이라고 해야할 듯
.and(mapSheetAnalDataInferenceGeomEntity.passYn.eq(Boolean.FALSE)))
.then(1L)
.otherwise(0L)
@@ -198,9 +200,8 @@ public class LabelWorkRepositoryImpl implements LabelWorkRepositoryCustom {
.otherwise(0L)
.sum(),
mapSheetAnalDataInferenceGeomEntity.labelStateDttm.min(),
// analState: tb_map_sheet_anal_inference.anal_state -> 우선은 미사용, java 단에서 로직화 해서
// 내려줌
// mapSheetAnalInferenceEntity.analState,
// analState: tb_map_sheet_anal_inference.anal_state
mapSheetAnalInferenceEntity.analState,
// normalProgressCnt: stagnation_yn = 'N'인 건수 (서브쿼리)
normalProgressCntSubQuery,
// totalAssignmentCnt: 총 배정 건수 (서브쿼리)

View File

@@ -16,4 +16,6 @@ public interface TrainingDataReviewJobRepositoryCustom {
void assignReviewerBatch(List<UUID> assignmentUids, String reviewerId);
Tasks findAssignmentTask(String assignmentUid);
void updateGeomUidTestState(List<Long> geomUids);
}

View File

@@ -2,6 +2,7 @@ package com.kamco.cd.kamcoback.postgres.repository.scheduler;
import static com.kamco.cd.kamcoback.postgres.entity.QLabelingAssignmentEntity.labelingAssignmentEntity;
import static com.kamco.cd.kamcoback.postgres.entity.QLabelingInspectorEntity.labelingInspectorEntity;
import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetAnalDataInferenceGeomEntity.mapSheetAnalDataInferenceGeomEntity;
import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.InspectState;
import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.LabelState;
@@ -99,6 +100,7 @@ public class TrainingDataReviewJobRepositoryImpl extends QuerydslRepositorySuppo
.update(labelingAssignmentEntity)
.set(labelingAssignmentEntity.inspectorUid, reviewerId)
.set(labelingAssignmentEntity.inspectState, InspectState.UNCONFIRM.getId())
.set(labelingAssignmentEntity.modifiedDate, ZonedDateTime.now())
.where(labelingAssignmentEntity.assignmentUid.eq(assignmentUid))
.execute();
}
@@ -115,6 +117,7 @@ public class TrainingDataReviewJobRepositoryImpl extends QuerydslRepositorySuppo
.update(labelingAssignmentEntity)
.set(labelingAssignmentEntity.inspectorUid, reviewerId)
.set(labelingAssignmentEntity.inspectState, InspectState.UNCONFIRM.getId())
.set(labelingAssignmentEntity.modifiedDate, ZonedDateTime.now())
.where(labelingAssignmentEntity.assignmentUid.in(assignmentUids))
.execute();
}
@@ -132,4 +135,14 @@ public class TrainingDataReviewJobRepositoryImpl extends QuerydslRepositorySuppo
.where(labelingAssignmentEntity.assignmentUid.eq(UUID.fromString(assignmentUid)))
.fetchOne();
}
@Override
public void updateGeomUidTestState(List<Long> geomUids) {
queryFactory
.update(mapSheetAnalDataInferenceGeomEntity)
.set(mapSheetAnalDataInferenceGeomEntity.testState, InspectState.UNCONFIRM.getId())
.set(mapSheetAnalDataInferenceGeomEntity.updatedDttm, ZonedDateTime.now())
.where(mapSheetAnalDataInferenceGeomEntity.geoUid.in(geomUids))
.execute();
}
}

View File

@@ -3,6 +3,7 @@ package com.kamco.cd.kamcoback.postgres.repository.trainingdata;
import com.kamco.cd.kamcoback.trainingdata.dto.TrainingDataLabelDto;
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.InferenceIdInfo;
import com.kamco.cd.kamcoback.trainingdata.dto.TrainingDataLabelDto.LabelFeatureRequest.LabelProperties;
import com.kamco.cd.kamcoback.trainingdata.dto.TrainingDataLabelDto.LabelingGeometryInfo;
import com.kamco.cd.kamcoback.trainingdata.dto.TrainingDataLabelDto.LabelingListDto;
@@ -18,7 +19,7 @@ public interface TrainingDataLabelRepositoryCustom {
LabelingGeometryInfo findLabelingAssignedGeom(String assignmentUid);
Long findLabelingAssignmentGeoUid(String assignmentUid);
InferenceIdInfo findLabelingAssignmentGeoUid(String assignmentUid);
void updateLabelingStateAssignment(String assignmentUid, String status);
@@ -37,4 +38,6 @@ public interface TrainingDataLabelRepositoryCustom {
TrainingDataLabelDto.CogImageResponse getCogImageUrl(
String mapSheetNum, Integer beforeYear, Integer afterYear);
void updateAnalInferenceMngState(Long analUid, String status);
}

View File

@@ -4,6 +4,7 @@ import static com.kamco.cd.kamcoback.postgres.entity.QImageryEntity.imageryEntit
import static com.kamco.cd.kamcoback.postgres.entity.QLabelingAssignmentEntity.labelingAssignmentEntity;
import static com.kamco.cd.kamcoback.postgres.entity.QMapInkx5kEntity.mapInkx5kEntity;
import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetAnalDataInferenceGeomEntity.mapSheetAnalDataInferenceGeomEntity;
import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetAnalInferenceEntity.mapSheetAnalInferenceEntity;
import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetLearnDataGeomEntity.mapSheetLearnDataGeomEntity;
import com.fasterxml.jackson.databind.JsonNode;
@@ -19,6 +20,7 @@ import com.kamco.cd.kamcoback.trainingdata.dto.TrainingDataLabelDto.DefaultPagin
import com.kamco.cd.kamcoback.trainingdata.dto.TrainingDataLabelDto.DetailRes;
import com.kamco.cd.kamcoback.trainingdata.dto.TrainingDataLabelDto.InferenceDataGeometry;
import com.kamco.cd.kamcoback.trainingdata.dto.TrainingDataLabelDto.InferenceDataGeometry.InferenceProperties;
import com.kamco.cd.kamcoback.trainingdata.dto.TrainingDataLabelDto.InferenceIdInfo;
import com.kamco.cd.kamcoback.trainingdata.dto.TrainingDataLabelDto.InspectionResultInfo;
import com.kamco.cd.kamcoback.trainingdata.dto.TrainingDataLabelDto.LabelFeatureRequest.LabelProperties;
import com.kamco.cd.kamcoback.trainingdata.dto.TrainingDataLabelDto.LabelingGeometryInfo;
@@ -174,9 +176,13 @@ public class TrainingDataLabelRepositoryImpl extends QuerydslRepositorySupport
}
@Override
public Long findLabelingAssignmentGeoUid(String assignmentUid) {
public InferenceIdInfo findLabelingAssignmentGeoUid(String assignmentUid) {
return queryFactory
.select(labelingAssignmentEntity.inferenceGeomUid)
.select(
Projections.constructor(
InferenceIdInfo.class,
labelingAssignmentEntity.inferenceGeomUid,
labelingAssignmentEntity.analUid))
.from(labelingAssignmentEntity)
.where(labelingAssignmentEntity.assignmentUid.eq(UUID.fromString(assignmentUid)))
.fetchOne();
@@ -838,6 +844,16 @@ public class TrainingDataLabelRepositoryImpl extends QuerydslRepositorySupport
}
}
@Override
public void updateAnalInferenceMngState(Long analUid, String status) {
queryFactory
.update(mapSheetAnalInferenceEntity)
.set(mapSheetAnalInferenceEntity.analState, status)
.set(mapSheetAnalInferenceEntity.updatedDttm, ZonedDateTime.now())
.where(mapSheetAnalInferenceEntity.id.eq(analUid))
.execute();
}
private StringExpression makeCogUrl(NumberPath<Integer> year) {
return new CaseBuilder()
.when(imageryEntity.year.eq(year))

View File

@@ -1,5 +1,6 @@
package com.kamco.cd.kamcoback.postgres.repository.trainingdata;
import com.kamco.cd.kamcoback.trainingdata.dto.TrainingDataLabelDto.InferenceIdInfo;
import com.kamco.cd.kamcoback.trainingdata.dto.TrainingDataReviewDto;
import com.kamco.cd.kamcoback.trainingdata.dto.TrainingDataReviewDto.DefaultPaging;
import com.kamco.cd.kamcoback.trainingdata.dto.TrainingDataReviewDto.DetailRes;
@@ -18,7 +19,7 @@ public interface TrainingDataReviewRepositoryCustom {
ReviewGeometryInfo findReviewAssignedGeom(String operatorUid);
Long findReviewOperatorGeoUid(String operatorUid);
InferenceIdInfo findReviewOperatorGeoUid(String operatorUid);
void updateReviewStateOperator(String operatorUid, String status);
@@ -37,4 +38,6 @@ public interface TrainingDataReviewRepositoryCustom {
TrainingDataReviewDto.CogImageResponse getCogImageUrl(
String mapSheetNum, Integer beforeYear, Integer afterYear);
void updateAnalInferenceMngState(Long analUid, String status);
}

View File

@@ -4,6 +4,7 @@ import static com.kamco.cd.kamcoback.postgres.entity.QImageryEntity.imageryEntit
import static com.kamco.cd.kamcoback.postgres.entity.QLabelingAssignmentEntity.labelingAssignmentEntity;
import static com.kamco.cd.kamcoback.postgres.entity.QMapInkx5kEntity.mapInkx5kEntity;
import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetAnalDataInferenceGeomEntity.mapSheetAnalDataInferenceGeomEntity;
import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetAnalInferenceEntity.mapSheetAnalInferenceEntity;
import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetLearnDataGeomEntity.mapSheetLearnDataGeomEntity;
import static com.kamco.cd.kamcoback.postgres.entity.QMemberEntity.memberEntity;
@@ -12,6 +13,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.InspectState;
import com.kamco.cd.kamcoback.postgres.entity.LabelingAssignmentEntity;
import com.kamco.cd.kamcoback.postgres.entity.MapSheetAnalDataInferenceGeomEntity;
import com.kamco.cd.kamcoback.trainingdata.dto.TrainingDataLabelDto.InferenceIdInfo;
import com.kamco.cd.kamcoback.trainingdata.dto.TrainingDataReviewDto;
import com.kamco.cd.kamcoback.trainingdata.dto.TrainingDataReviewDto.ChangeDetectionInfo;
import com.kamco.cd.kamcoback.trainingdata.dto.TrainingDataReviewDto.ClassificationInfo;
@@ -177,9 +179,13 @@ public class TrainingDataReviewRepositoryImpl extends QuerydslRepositorySupport
}
@Override
public Long findReviewOperatorGeoUid(String operatorUid) {
public InferenceIdInfo findReviewOperatorGeoUid(String operatorUid) {
return queryFactory
.select(labelingAssignmentEntity.inferenceGeomUid)
.select(
Projections.constructor(
InferenceIdInfo.class,
labelingAssignmentEntity.inferenceGeomUid,
labelingAssignmentEntity.analUid))
.from(labelingAssignmentEntity)
.where(labelingAssignmentEntity.assignmentUid.eq(UUID.fromString(operatorUid)))
.fetchOne();
@@ -209,6 +215,15 @@ public class TrainingDataReviewRepositoryImpl extends QuerydslRepositorySupport
@Override
public void updateReviewPolygonClass(
Long inferenceGeomUid, Geometry geometry, Properties properties, String status) {
// inference_geom 테이블에 상태 업데이트
queryFactory
.update(mapSheetAnalDataInferenceGeomEntity)
.set(mapSheetAnalDataInferenceGeomEntity.testStateDttm, ZonedDateTime.now())
.set(mapSheetAnalDataInferenceGeomEntity.testState, status)
.where(mapSheetAnalDataInferenceGeomEntity.geoUid.eq(inferenceGeomUid))
.execute();
// inference_geom 테이블 정보 가져오기
MapSheetAnalDataInferenceGeomEntity entity =
queryFactory
@@ -859,6 +874,16 @@ public class TrainingDataReviewRepositoryImpl extends QuerydslRepositorySupport
}
}
@Override
public void updateAnalInferenceMngState(Long analUid, String status) {
queryFactory
.update(mapSheetAnalInferenceEntity)
.set(mapSheetAnalInferenceEntity.analState, status)
.set(mapSheetAnalInferenceEntity.updatedDttm, ZonedDateTime.now())
.where(mapSheetAnalInferenceEntity.id.eq(analUid))
.execute();
}
private StringExpression makeCogUrl(NumberPath<Integer> year) {
return new CaseBuilder()
.when(imageryEntity.year.eq(year))

View File

@@ -53,8 +53,11 @@ public class MapSheetInferenceJobService {
@Value("${inference.jar-path}")
private String jarPath;
/** 추론 진행 배치 1분 */
@Scheduled(fixedDelay = 60_000)
@Value("${file.dataset-dir}")
private String datasetDir;
/** 추론 진행 배치 1분 60_000 */
@Scheduled(fixedDelay = 30_000)
public void runBatch() {
if (isLocalProfile()) {
return;
@@ -242,6 +245,10 @@ public class MapSheetInferenceJobService {
// uid 기준 merge shp, geojson 파일 생성
externalJarRunner.run(jarPath, batchId, inferenceId, "");
// uid 기준 도엽별 shp 파일 geoserver 등록
String register = datasetDir + "/" + inferenceId + "/" + "merge" + "/" + inferenceId + ".shp";
externalJarRunner.run(jarPath, register, inferenceId);
}
/**

View File

@@ -80,8 +80,10 @@ public class TrainingDataReviewJobService {
List<UUID> assignmentUids =
assignedTasks.stream().map(Tasks::getAssignmentUid).toList();
trainingDataReviewJobCoreService.assignReviewerBatch(assignmentUids, reviewerId);
List<Long> geomUids = assignedTasks.stream().map(Tasks::getInferenceUid).toList();
trainingDataReviewJobCoreService.updateGeomUidTestState(geomUids);
});
}
} catch (Exception e) {
@@ -108,7 +110,7 @@ public class TrainingDataReviewJobService {
return result;
}
// 라벨러 완료,SKIP 시 호출
// 라벨러 완료,SKIP 시 호출 -> 미사용
@Transactional
public void assignRealtime(String assignmentUid) {
Tasks task = trainingDataReviewJobCoreService.findAssignmentTask(assignmentUid);
@@ -127,5 +129,9 @@ public class TrainingDataReviewJobService {
trainingDataReviewJobCoreService.lockInspectors(analUid, order);
trainingDataReviewJobCoreService.assignReviewer(task.getAssignmentUid(), order.getFirst());
List<Long> geomUids = new ArrayList<>();
geomUids.add(task.getInferenceUid());
trainingDataReviewJobCoreService.updateGeomUidTestState(geomUids);
}
}

View File

@@ -557,7 +557,9 @@ public class TrainingDataReviewApiController {
trainingDataReviewService.getCogImageUrl(mapSheetNum, beforeYear, afterYear));
}
@Hidden
@Operation(
summary = "검수할당 스케줄링(수동 호출)",
description = "스케줄링이 실패한 경우 수동 호출하는 API, 어제 라벨링 완료된 것을 해당 검수자들에게 할당함")
@GetMapping("/run-schedule")
public ApiResponseDto<Void> runTrainingReviewSchedule() {
trainingDataReviewJobService.assignReviewerYesterdayLabelComplete();

View File

@@ -204,6 +204,19 @@ public class TrainingDataLabelDto {
}
}
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public static class InferenceIdInfo {
@Schema(description = "inferenceGeomUid")
private Long inferenceGeomUid;
@Schema(description = "analUid")
private Long analUid;
}
@Schema(name = "LearnDataGeometry", description = "LearnDataGeometry")
@Getter
@Setter

View File

@@ -2,11 +2,13 @@ package com.kamco.cd.kamcoback.trainingdata.service;
import com.kamco.cd.kamcoback.config.api.ApiResponseDto.ApiResponseCode;
import com.kamco.cd.kamcoback.config.api.ApiResponseDto.ResponseObj;
import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.LabelMngState;
import com.kamco.cd.kamcoback.postgres.core.TrainingDataLabelCoreService;
import com.kamco.cd.kamcoback.scheduler.service.TrainingDataReviewJobService;
import com.kamco.cd.kamcoback.trainingdata.dto.TrainingDataLabelDto;
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.InferenceIdInfo;
import com.kamco.cd.kamcoback.trainingdata.dto.TrainingDataLabelDto.LabelFeatureRequest;
import com.kamco.cd.kamcoback.trainingdata.dto.TrainingDataLabelDto.LabelingGeometryInfo;
import com.kamco.cd.kamcoback.trainingdata.dto.TrainingDataLabelDto.LabelingListDto;
@@ -44,8 +46,8 @@ public class TrainingDataLabelService {
public String saveLabelingFeature(LabelFeatureRequest request) {
String status = "";
String assignmentUid = request.getAssignmentUid();
Long inferenceGeomUid =
trainingDataLabelCoreService.findLabelingAssignmentGeoUid(assignmentUid);
InferenceIdInfo info = trainingDataLabelCoreService.findLabelingAssignmentGeoUid(assignmentUid);
Long inferenceGeomUid = info.getInferenceGeomUid();
if (request.getGeometry() == null || request.getGeometry().isEmpty()) {
// SKIP 상태만 업데이트
status = "SKIP";
@@ -58,8 +60,9 @@ public class TrainingDataLabelService {
inferenceGeomUid, request.getGeometry(), request.getProperties(), status);
}
// 라벨링 완료하면 실시간 검수 할당 (1건)
trainingDataReviewJobService.assignRealtime(assignmentUid);
// 회차 진행 상태 update
trainingDataLabelCoreService.updateAnalInferenceMngState(
info.getAnalUid(), LabelMngState.ING.getId());
return status;
}

View File

@@ -2,7 +2,9 @@ package com.kamco.cd.kamcoback.trainingdata.service;
import com.kamco.cd.kamcoback.config.api.ApiResponseDto.ApiResponseCode;
import com.kamco.cd.kamcoback.config.api.ApiResponseDto.ResponseObj;
import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.LabelMngState;
import com.kamco.cd.kamcoback.postgres.core.TrainingDataReviewCoreService;
import com.kamco.cd.kamcoback.trainingdata.dto.TrainingDataLabelDto.InferenceIdInfo;
import com.kamco.cd.kamcoback.trainingdata.dto.TrainingDataReviewDto;
import com.kamco.cd.kamcoback.trainingdata.dto.TrainingDataReviewDto.DefaultPaging;
import com.kamco.cd.kamcoback.trainingdata.dto.TrainingDataReviewDto.DetailRes;
@@ -39,7 +41,8 @@ public class TrainingDataReviewService {
public String saveReviewFeature(GeoFeatureRequest request) {
String status = "";
String operatorUid = request.getOperatorUid();
Long inferenceGeomUid = trainingDataReviewCoreService.findReviewOperatorGeoUid(operatorUid);
InferenceIdInfo info = trainingDataReviewCoreService.findReviewOperatorGeoUid(operatorUid);
Long inferenceGeomUid = info.getInferenceGeomUid();
if (request.getGeometry() == null || request.getGeometry().isEmpty()) {
// EXCEPT 상태만 업데이트
@@ -52,6 +55,11 @@ public class TrainingDataReviewService {
trainingDataReviewCoreService.updateReviewPolygonClass(
inferenceGeomUid, request.getGeometry(), request.getProperties(), status);
}
// 회차 진행 상태 update
trainingDataReviewCoreService.updateAnalInferenceMngState(
info.getAnalUid(), LabelMngState.ING.getId());
return status;
}