Merge branch 'feat/infer_dev_260107' of https://10.100.0.10:3210/dabeeo/kamco-dabeeo-backoffice into feat/infer_dev_260107
This commit is contained in:
@@ -7,7 +7,7 @@ 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.dto.GukYuinDto.GukYuinLinkableRes;
|
||||||
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.Parameter;
|
||||||
@@ -114,12 +114,12 @@ public class GukYuinApiController {
|
|||||||
mediaType = "application/json",
|
mediaType = "application/json",
|
||||||
schema =
|
schema =
|
||||||
@Schema(
|
@Schema(
|
||||||
implementation = GukYuinDto.isLinkDto.class,
|
implementation = GukYuinLinkableRes.class,
|
||||||
description = "TRUE:연동가능, FALSE:연동 불가능"))),
|
description = "TRUE:연동가능, FALSE:연동 불가능"))),
|
||||||
@ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content),
|
@ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content),
|
||||||
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content)
|
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content)
|
||||||
})
|
})
|
||||||
public ApiResponseDto<GukYuinDto.isLinkDto> getIsLinkGukYuin(
|
public ApiResponseDto<GukYuinLinkableRes> getIsLinkGukYuin(
|
||||||
@Parameter(description = "uuid", example = "5799eb21-4780-48b0-a82e-e58dcbb8806b")
|
@Parameter(description = "uuid", example = "5799eb21-4780-48b0-a82e-e58dcbb8806b")
|
||||||
@PathVariable
|
@PathVariable
|
||||||
UUID uuid) {
|
UUID uuid) {
|
||||||
|
|||||||
@@ -1,19 +1,48 @@
|
|||||||
package com.kamco.cd.kamcoback.gukyuin.dto;
|
package com.kamco.cd.kamcoback.gukyuin.dto;
|
||||||
|
|
||||||
|
import com.kamco.cd.kamcoback.common.utils.enums.EnumType;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
public class GukYuinDto {
|
public class GukYuinDto {
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@NoArgsConstructor
|
public static class GukYuinLinkableRes {
|
||||||
@AllArgsConstructor
|
|
||||||
public static class isLinkDto {
|
|
||||||
|
|
||||||
private Boolean isLinkable;
|
private boolean linkable;
|
||||||
|
// private GukYuinLinkFailCode code;
|
||||||
private String message;
|
private String message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 실패 코드 enum */
|
||||||
|
@Getter
|
||||||
|
@AllArgsConstructor
|
||||||
|
public enum GukYuinLinkFailCode implements EnumType {
|
||||||
|
OK("연동 가능"),
|
||||||
|
NOT_FOUND("대상 회차가 없습니다."),
|
||||||
|
SCOPE_PART_NOT_ALLOWED("부분 도엽은 연동 불가능 합니다."),
|
||||||
|
HAS_RUNNING_INFERENCE("라벨링 진행 중 회차가 있습니다."),
|
||||||
|
OTHER_GUKYUIN_IN_PROGRESS("국유in 연동 진행 중 회차가 있습니다.");
|
||||||
|
|
||||||
|
private final String desc;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getId() {
|
||||||
|
return name();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getText() {
|
||||||
|
return desc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Repository가 반환할 Fact(조회 결과)
|
||||||
|
public record GukYuinLinkFacts(
|
||||||
|
boolean existsLearn,
|
||||||
|
boolean isPartScope,
|
||||||
|
boolean hasRunningInference,
|
||||||
|
boolean hasOtherUnfinishedGukYuin) {}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,9 @@ 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.gukyuin.dto.GukYuinDto.GukYuinLinkFacts;
|
||||||
|
import com.kamco.cd.kamcoback.gukyuin.dto.GukYuinDto.GukYuinLinkFailCode;
|
||||||
|
import com.kamco.cd.kamcoback.gukyuin.dto.GukYuinDto.GukYuinLinkableRes;
|
||||||
import com.kamco.cd.kamcoback.postgres.core.GukYuinCoreService;
|
import com.kamco.cd.kamcoback.postgres.core.GukYuinCoreService;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -100,7 +102,35 @@ public class GukYuinApiService {
|
|||||||
* @param uuid uuid
|
* @param uuid uuid
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public GukYuinDto.isLinkDto getIsLinkGukYuin(UUID uuid) {
|
public GukYuinLinkableRes getIsLinkGukYuin(UUID uuid) {
|
||||||
return gukyuinCoreService.getIsLinkGukYuin(uuid);
|
GukYuinLinkFacts f = gukyuinCoreService.findLinkFacts(uuid);
|
||||||
|
GukYuinLinkFailCode code = decideCode(f);
|
||||||
|
|
||||||
|
GukYuinLinkableRes res = new GukYuinLinkableRes();
|
||||||
|
// res.setCode(code);
|
||||||
|
res.setLinkable(code == GukYuinLinkFailCode.OK);
|
||||||
|
res.setMessage(code.getDesc());
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
private GukYuinLinkFailCode decideCode(GukYuinLinkFacts f) {
|
||||||
|
|
||||||
|
if (!f.existsLearn()) {
|
||||||
|
return GukYuinLinkFailCode.NOT_FOUND;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (f.isPartScope()) {
|
||||||
|
return GukYuinLinkFailCode.SCOPE_PART_NOT_ALLOWED;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (f.hasRunningInference()) {
|
||||||
|
return GukYuinLinkFailCode.HAS_RUNNING_INFERENCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (f.hasOtherUnfinishedGukYuin()) {
|
||||||
|
return GukYuinLinkFailCode.OTHER_GUKYUIN_IN_PROGRESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
return GukYuinLinkFailCode.OK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
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.gukyuin.dto.GukYuinDto.GukYuinLinkFacts;
|
||||||
import com.kamco.cd.kamcoback.postgres.repository.Inference.MapSheetLearnRepository;
|
import com.kamco.cd.kamcoback.postgres.repository.Inference.MapSheetLearnRepository;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
@@ -18,7 +18,7 @@ public class GukYuinCoreService {
|
|||||||
* @param uuid uuid
|
* @param uuid uuid
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public GukYuinDto.isLinkDto getIsLinkGukYuin(UUID uuid) {
|
public GukYuinLinkFacts findLinkFacts(UUID uuid) {
|
||||||
return mapSheetLearnRepository.getIsLinkGukYuin(uuid);
|
return mapSheetLearnRepository.findLinkFacts(uuid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +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.gukyuin.dto.GukYuinDto.GukYuinLinkFacts;
|
||||||
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;
|
||||||
@@ -42,5 +42,5 @@ public interface MapSheetLearnRepositoryCustom {
|
|||||||
|
|
||||||
Page<Geom> getInferenceGeomList(UUID uuid, SearchGeoReq searchGeoReq);
|
Page<Geom> getInferenceGeomList(UUID uuid, SearchGeoReq searchGeoReq);
|
||||||
|
|
||||||
GukYuinDto.isLinkDto getIsLinkGukYuin(UUID uuid);
|
GukYuinLinkFacts findLinkFacts(UUID uuid);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ 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.GukYuinDto.GukYuinLinkFacts;
|
||||||
import com.kamco.cd.kamcoback.gukyuin.dto.GukYuinStatus;
|
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;
|
||||||
@@ -26,6 +26,8 @@ import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.InferenceStatusDe
|
|||||||
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.MapSheetScope;
|
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.QMapSheetAnalInferenceEntity;
|
||||||
|
import com.kamco.cd.kamcoback.postgres.entity.QMapSheetLearnEntity;
|
||||||
import com.kamco.cd.kamcoback.postgres.entity.QModelMngEntity;
|
import com.kamco.cd.kamcoback.postgres.entity.QModelMngEntity;
|
||||||
import com.querydsl.core.BooleanBuilder;
|
import com.querydsl.core.BooleanBuilder;
|
||||||
import com.querydsl.core.types.Expression;
|
import com.querydsl.core.types.Expression;
|
||||||
@@ -513,67 +515,49 @@ public class MapSheetLearnRepositoryImpl implements MapSheetLearnRepositoryCusto
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public GukYuinDto.isLinkDto getIsLinkGukYuin(UUID uuid) {
|
public GukYuinLinkFacts findLinkFacts(UUID uuid) {
|
||||||
GukYuinDto.isLinkDto dto = new GukYuinDto.isLinkDto();
|
|
||||||
|
|
||||||
MapSheetLearnEntity learn =
|
MapSheetLearnEntity learn =
|
||||||
queryFactory
|
queryFactory
|
||||||
.selectFrom(mapSheetLearnEntity)
|
.selectFrom(QMapSheetLearnEntity.mapSheetLearnEntity)
|
||||||
.where(mapSheetLearnEntity.uuid.eq(uuid))
|
.where(QMapSheetLearnEntity.mapSheetLearnEntity.uuid.eq(uuid))
|
||||||
.fetchOne();
|
.fetchOne();
|
||||||
|
|
||||||
if (learn == null) {
|
if (learn == null) {
|
||||||
dto.setIsLinkable(false);
|
return new GukYuinLinkFacts(false, false, false, false);
|
||||||
dto.setMessage("데이터가 없습니다.");
|
|
||||||
return dto;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MapSheetScope.PART.getId().equals(learn.getMapSheetScope())) {
|
boolean isPartScope = MapSheetScope.PART.getId().equals(learn.getMapSheetScope());
|
||||||
dto.setIsLinkable(false);
|
|
||||||
dto.setMessage("분석도엽 전체만 국유in 연동이 가능합니다.");
|
|
||||||
return dto;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 같은 연도에 ASSIGNED/ING inference 존재 여부
|
QMapSheetAnalInferenceEntity inf = QMapSheetAnalInferenceEntity.mapSheetAnalInferenceEntity;
|
||||||
Boolean hasRunningInference =
|
QMapSheetLearnEntity learn2 = new QMapSheetLearnEntity("learn2");
|
||||||
|
QMapSheetLearnEntity learnQ = QMapSheetLearnEntity.mapSheetLearnEntity;
|
||||||
|
|
||||||
|
boolean hasRunningInference =
|
||||||
queryFactory
|
queryFactory
|
||||||
.selectOne()
|
.selectOne()
|
||||||
.from(mapSheetAnalInferenceEntity)
|
.from(inf)
|
||||||
.join(mapSheetLearnEntity)
|
.join(learn2)
|
||||||
.on(mapSheetAnalInferenceEntity.learnId.eq(mapSheetLearnEntity.id))
|
.on(inf.learnId.eq(learn2.id))
|
||||||
.where(
|
.where(
|
||||||
mapSheetLearnEntity.compareYyyy.eq(learn.getCompareYyyy()),
|
learn2.compareYyyy.eq(learn.getCompareYyyy()),
|
||||||
mapSheetLearnEntity.targetYyyy.eq(learn.getTargetYyyy()),
|
learn2.targetYyyy.eq(learn.getTargetYyyy()),
|
||||||
mapSheetAnalInferenceEntity.analState.in("ASSIGNED", "ING"))
|
inf.analState.in("ASSIGNED", "ING"))
|
||||||
.fetchFirst()
|
.fetchFirst()
|
||||||
!= null;
|
!= null;
|
||||||
|
|
||||||
if (hasRunningInference) {
|
boolean hasOtherUnfinishedGukYuin =
|
||||||
dto.setIsLinkable(false);
|
|
||||||
dto.setMessage("라벨링 중인 회차가 있습니다.");
|
|
||||||
return dto;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 같은 연도에 아직 국유인 종료 안 된 다른 learn 존재 여부
|
|
||||||
Boolean hasOtherUnfinishedGukYuin =
|
|
||||||
queryFactory
|
queryFactory
|
||||||
.selectOne()
|
.selectOne()
|
||||||
.from(mapSheetLearnEntity)
|
.from(learnQ)
|
||||||
.where(
|
.where(
|
||||||
mapSheetLearnEntity.compareYyyy.eq(learn.getCompareYyyy()),
|
learnQ.compareYyyy.eq(learn.getCompareYyyy()),
|
||||||
mapSheetLearnEntity.targetYyyy.eq(learn.getTargetYyyy()),
|
learnQ.targetYyyy.eq(learn.getTargetYyyy()),
|
||||||
mapSheetLearnEntity.applyStatus.eq(GukYuinStatus.IN_PROGRESS.getId()),
|
learnQ.applyStatus.eq(GukYuinStatus.IN_PROGRESS.getId()),
|
||||||
mapSheetLearnEntity.uuid.ne(learn.getUuid()))
|
learnQ.uuid.ne(learn.getUuid()))
|
||||||
.fetchFirst()
|
.fetchFirst()
|
||||||
!= null;
|
!= null;
|
||||||
|
|
||||||
if (hasOtherUnfinishedGukYuin) {
|
return new GukYuinLinkFacts(true, isPartScope, hasRunningInference, hasOtherUnfinishedGukYuin);
|
||||||
dto.setIsLinkable(false);
|
|
||||||
dto.setMessage("국유in 연동중인 회차가 있습니다.");
|
|
||||||
return dto;
|
|
||||||
}
|
|
||||||
|
|
||||||
dto.setIsLinkable(true);
|
|
||||||
return dto;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user