국유인in 연동 가능여부 api

This commit is contained in:
2026-01-22 20:40:58 +09:00
parent cf93244969
commit f0eb5b839a
8 changed files with 182 additions and 7 deletions

View File

@@ -7,8 +7,10 @@ import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectMastDto.ChngDetectMastSearch
import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectMastDto.ResReturn; import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectMastDto.ResReturn;
import com.kamco.cd.kamcoback.gukyuin.dto.DetectMastDto.Basic; import com.kamco.cd.kamcoback.gukyuin.dto.DetectMastDto.Basic;
import com.kamco.cd.kamcoback.gukyuin.dto.DetectMastDto.DetectMastReq; import com.kamco.cd.kamcoback.gukyuin.dto.DetectMastDto.DetectMastReq;
import com.kamco.cd.kamcoback.gukyuin.dto.GukYuinDto;
import com.kamco.cd.kamcoback.gukyuin.service.GukYuinApiService; import com.kamco.cd.kamcoback.gukyuin.service.GukYuinApiService;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponse;
@@ -19,13 +21,14 @@ import java.util.List;
import java.util.UUID; import java.util.UUID;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
@Tag(name = "국유 연동 API", description = "국유 연동 API") @Tag(name = "국유in 연동 API", description = "국유in 연동 API")
@RestController @RestController
@RequiredArgsConstructor @RequiredArgsConstructor
@RequestMapping("/api/gukyuin/") @RequestMapping("/api/gukyuin/")
@@ -99,8 +102,27 @@ public class GukYuinApiController {
return gukYuinApiService.list(searchDto); return gukYuinApiService.list(searchDto);
} }
public ApiResponseDto<Boolean> getIsLinkGukYuin(UUID uuid) { @Operation(summary = "국유in연동 가능여부 확인", description = "국유in연동 가능여부 확인")
gukYuinApiService.getIsLinkGukYuin(uuid); @GetMapping("/is-link/{uuid}")
return ApiResponseDto.ok(false); @ApiResponses(
value = {
@ApiResponse(
responseCode = "200",
description = "목록 성공",
content =
@Content(
mediaType = "application/json",
schema =
@Schema(
implementation = GukYuinDto.isLinkDto.class,
description = "TRUE:연동가능, FALSE:연동 불가능"))),
@ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content),
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content)
})
public ApiResponseDto<GukYuinDto.isLinkDto> getIsLinkGukYuin(
@Parameter(description = "uuid", example = "5799eb21-4780-48b0-a82e-e58dcbb8806b")
@PathVariable
UUID uuid) {
return ApiResponseDto.ok(gukYuinApiService.getIsLinkGukYuin(uuid));
} }
} }

View File

@@ -0,0 +1,19 @@
package com.kamco.cd.kamcoback.gukyuin.dto;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
public class GukYuinDto {
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public static class isLinkDto {
private Boolean isLinkable;
private String message;
}
}

View File

@@ -0,0 +1,25 @@
package com.kamco.cd.kamcoback.gukyuin.dto;
import com.kamco.cd.kamcoback.common.utils.enums.EnumType;
import lombok.AllArgsConstructor;
import lombok.Getter;
@Getter
@AllArgsConstructor
public enum GukYuinStatus implements EnumType {
PENDING("대기"),
IN_PROGRESS("사용"),
COMPLETED("완료");
private final String desc;
@Override
public String getId() {
return name();
}
@Override
public String getText() {
return desc;
}
}

View File

@@ -5,6 +5,8 @@ import com.kamco.cd.kamcoback.config.resttemplate.ExternalHttpClient;
import com.kamco.cd.kamcoback.config.resttemplate.ExternalHttpClient.ExternalCallResult; import com.kamco.cd.kamcoback.config.resttemplate.ExternalHttpClient.ExternalCallResult;
import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectMastDto; import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectMastDto;
import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectMastDto.ResReturn; import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectMastDto.ResReturn;
import com.kamco.cd.kamcoback.gukyuin.dto.GukYuinDto;
import com.kamco.cd.kamcoback.postgres.core.GukYuinCoreService;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
@@ -28,6 +30,7 @@ public class GukYuinApiService {
@Value("${gukyuin.mast}") @Value("${gukyuin.mast}")
private String gukyuinMastUrl; private String gukyuinMastUrl;
private final GukYuinCoreService gukyuinCoreService;
private final ExternalHttpClient externalHttpClient; private final ExternalHttpClient externalHttpClient;
private final NetUtils netUtils = new NetUtils(); private final NetUtils netUtils = new NetUtils();
@@ -91,7 +94,13 @@ public class GukYuinApiService {
return masterList; return masterList;
} }
public Boolean getIsLinkGukYuin(UUID uuid) { /**
return false; * 국유in연동 가능여부 확인
*
* @param uuid uuid
* @return
*/
public GukYuinDto.isLinkDto getIsLinkGukYuin(UUID uuid) {
return gukyuinCoreService.getIsLinkGukYuin(uuid);
} }
} }

View File

@@ -1,8 +1,24 @@
package com.kamco.cd.kamcoback.postgres.core; package com.kamco.cd.kamcoback.postgres.core;
import com.kamco.cd.kamcoback.gukyuin.dto.GukYuinDto;
import com.kamco.cd.kamcoback.postgres.repository.Inference.MapSheetLearnRepository;
import java.util.UUID;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@Service @Service
@RequiredArgsConstructor @RequiredArgsConstructor
public class GukYuinCoreService {} public class GukYuinCoreService {
private final MapSheetLearnRepository mapSheetLearnRepository;
/**
* 국유in연동 가능여부 확인
*
* @param uuid uuid
* @return
*/
public GukYuinDto.isLinkDto getIsLinkGukYuin(UUID uuid) {
return mapSheetLearnRepository.getIsLinkGukYuin(uuid);
}
}

View File

@@ -1,5 +1,6 @@
package com.kamco.cd.kamcoback.postgres.entity; package com.kamco.cd.kamcoback.postgres.entity;
import com.kamco.cd.kamcoback.gukyuin.dto.GukYuinStatus;
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto; import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto;
import jakarta.persistence.Column; import jakarta.persistence.Column;
import jakarta.persistence.Entity; import jakarta.persistence.Entity;
@@ -186,6 +187,12 @@ public class MapSheetLearnEntity {
@Column(name = "m3_failed_jobs", nullable = false) @Column(name = "m3_failed_jobs", nullable = false)
private int m3FailedJobs = 0; private int m3FailedJobs = 0;
@Column(name = "apply_status")
private String applyStatus = GukYuinStatus.PENDING.getId();
@Column(name = "apply_status_dttm")
private ZonedDateTime applyStatusDttm;
@Column(name = "uid", nullable = false) @Column(name = "uid", nullable = false)
private String uid = UUID.randomUUID().toString().replace("-", "").toUpperCase(); private String uid = UUID.randomUUID().toString().replace("-", "").toUpperCase();

View File

@@ -1,5 +1,6 @@
package com.kamco.cd.kamcoback.postgres.repository.Inference; package com.kamco.cd.kamcoback.postgres.repository.Inference;
import com.kamco.cd.kamcoback.gukyuin.dto.GukYuinDto;
import com.kamco.cd.kamcoback.inference.dto.InferenceDetailDto.AnalResultInfo; import com.kamco.cd.kamcoback.inference.dto.InferenceDetailDto.AnalResultInfo;
import com.kamco.cd.kamcoback.inference.dto.InferenceDetailDto.BboxPointDto; import com.kamco.cd.kamcoback.inference.dto.InferenceDetailDto.BboxPointDto;
import com.kamco.cd.kamcoback.inference.dto.InferenceDetailDto.Dashboard; import com.kamco.cd.kamcoback.inference.dto.InferenceDetailDto.Dashboard;
@@ -40,4 +41,6 @@ public interface MapSheetLearnRepositoryCustom {
List<Dashboard> getInferenceClassCountList(UUID uuid); List<Dashboard> getInferenceClassCountList(UUID uuid);
Page<Geom> getInferenceGeomList(UUID uuid, SearchGeoReq searchGeoReq); Page<Geom> getInferenceGeomList(UUID uuid, SearchGeoReq searchGeoReq);
GukYuinDto.isLinkDto getIsLinkGukYuin(UUID uuid);
} }

View File

@@ -12,6 +12,8 @@ import static com.kamco.cd.kamcoback.postgres.entity.QSystemMetricEntity.systemM
import com.kamco.cd.kamcoback.common.exception.CustomApiException; import com.kamco.cd.kamcoback.common.exception.CustomApiException;
import com.kamco.cd.kamcoback.common.utils.DateRange; import com.kamco.cd.kamcoback.common.utils.DateRange;
import com.kamco.cd.kamcoback.gukyuin.dto.GukYuinDto;
import com.kamco.cd.kamcoback.gukyuin.dto.GukYuinStatus;
import com.kamco.cd.kamcoback.inference.dto.InferenceDetailDto.AnalResultInfo; import com.kamco.cd.kamcoback.inference.dto.InferenceDetailDto.AnalResultInfo;
import com.kamco.cd.kamcoback.inference.dto.InferenceDetailDto.BboxPointDto; import com.kamco.cd.kamcoback.inference.dto.InferenceDetailDto.BboxPointDto;
import com.kamco.cd.kamcoback.inference.dto.InferenceDetailDto.Dashboard; import com.kamco.cd.kamcoback.inference.dto.InferenceDetailDto.Dashboard;
@@ -21,6 +23,7 @@ import com.kamco.cd.kamcoback.inference.dto.InferenceProgressDto;
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto; import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto;
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.InferenceServerStatusDto; import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.InferenceServerStatusDto;
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.InferenceStatusDetailDto; import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.InferenceStatusDetailDto;
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.MapSheetScope;
import com.kamco.cd.kamcoback.model.service.ModelMngService; import com.kamco.cd.kamcoback.model.service.ModelMngService;
import com.kamco.cd.kamcoback.postgres.entity.MapSheetLearnEntity; import com.kamco.cd.kamcoback.postgres.entity.MapSheetLearnEntity;
import com.kamco.cd.kamcoback.postgres.entity.QModelMngEntity; import com.kamco.cd.kamcoback.postgres.entity.QModelMngEntity;
@@ -502,4 +505,75 @@ public class MapSheetLearnRepositoryImpl implements MapSheetLearnRepositoryCusto
return new PageImpl<>(content, pageable, total == null ? 0L : total); return new PageImpl<>(content, pageable, total == null ? 0L : total);
} }
/**
* 국유in연동 가능여부 확인
*
* @param uuid uuid
* @return
*/
@Override
public GukYuinDto.isLinkDto getIsLinkGukYuin(UUID uuid) {
GukYuinDto.isLinkDto dto = new GukYuinDto.isLinkDto();
MapSheetLearnEntity learn =
queryFactory
.selectFrom(mapSheetLearnEntity)
.where(mapSheetLearnEntity.uuid.eq(uuid))
.fetchOne();
if (learn == null) {
dto.setIsLinkable(false);
dto.setMessage("데이터가 없습니다.");
return dto;
}
if (MapSheetScope.PART.getId().equals(learn.getMapSheetScope())) {
dto.setIsLinkable(false);
dto.setMessage("분석도엽 전체만 국유in 연동이 가능합니다.");
return dto;
}
// 같은 연도에 ASSIGNED/ING inference 존재 여부
Boolean hasRunningInference =
queryFactory
.selectOne()
.from(mapSheetAnalInferenceEntity)
.join(mapSheetLearnEntity)
.on(mapSheetAnalInferenceEntity.learnId.eq(mapSheetLearnEntity.id))
.where(
mapSheetLearnEntity.compareYyyy.eq(learn.getCompareYyyy()),
mapSheetLearnEntity.targetYyyy.eq(learn.getTargetYyyy()),
mapSheetAnalInferenceEntity.analState.in("ASSIGNED", "ING"))
.fetchFirst()
!= null;
if (hasRunningInference) {
dto.setIsLinkable(false);
dto.setMessage("라벨링 중인 회차가 있습니다.");
return dto;
}
// 같은 연도에 아직 국유인 종료 안 된 다른 learn 존재 여부
Boolean hasOtherUnfinishedGukYuin =
queryFactory
.selectOne()
.from(mapSheetLearnEntity)
.where(
mapSheetLearnEntity.compareYyyy.eq(learn.getCompareYyyy()),
mapSheetLearnEntity.targetYyyy.eq(learn.getTargetYyyy()),
mapSheetLearnEntity.applyStatus.eq(GukYuinStatus.IN_PROGRESS.getId()),
mapSheetLearnEntity.uuid.ne(learn.getUuid()))
.fetchFirst()
!= null;
if (hasOtherUnfinishedGukYuin) {
dto.setIsLinkable(false);
dto.setMessage("국유in 연동중인 회차가 있습니다.");
return dto;
}
dto.setIsLinkable(true);
return dto;
}
} }