Merge pull request '[KC-108] 분석도엽 ai api호출 테스트중' (#196) from feat/infer_dev_260107 into develop
Reviewed-on: https://kamco.gitea.gs.dabeeo.com/dabeeo/kamco-dabeeo-backoffice/pulls/196
This commit is contained in:
@@ -11,7 +11,7 @@ import lombok.Setter;
|
|||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
public class InferenceSendDto {
|
public class InferenceSendDto {
|
||||||
|
|
||||||
private PredRequestsAreas predRequestsAreas;
|
private pred_requests_areas pred_requests_areas;
|
||||||
private String model_version;
|
private String model_version;
|
||||||
private String cd_model_path;
|
private String cd_model_path;
|
||||||
private String cd_model_config;
|
private String cd_model_config;
|
||||||
@@ -24,7 +24,7 @@ public class InferenceSendDto {
|
|||||||
@Setter
|
@Setter
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
public static class PredRequestsAreas {
|
public static class pred_requests_areas {
|
||||||
|
|
||||||
private Integer input1_year;
|
private Integer input1_year;
|
||||||
private Integer input2_year;
|
private Integer input2_year;
|
||||||
|
|||||||
@@ -14,13 +14,13 @@ import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.MapSheetNumDto;
|
|||||||
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.MapSheetScope;
|
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.MapSheetScope;
|
||||||
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.ResultList;
|
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.ResultList;
|
||||||
import com.kamco.cd.kamcoback.inference.dto.InferenceSendDto;
|
import com.kamco.cd.kamcoback.inference.dto.InferenceSendDto;
|
||||||
|
import com.kamco.cd.kamcoback.inference.dto.InferenceSendDto.pred_requests_areas;
|
||||||
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto.MngListCompareDto;
|
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto.MngListCompareDto;
|
||||||
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto.MngListDto;
|
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto.MngListDto;
|
||||||
import com.kamco.cd.kamcoback.model.dto.ModelMngDto.Basic;
|
import com.kamco.cd.kamcoback.model.dto.ModelMngDto.Basic;
|
||||||
import com.kamco.cd.kamcoback.postgres.core.InferenceResultCoreService;
|
import com.kamco.cd.kamcoback.postgres.core.InferenceResultCoreService;
|
||||||
import com.kamco.cd.kamcoback.postgres.core.MapSheetMngCoreService;
|
import com.kamco.cd.kamcoback.postgres.core.MapSheetMngCoreService;
|
||||||
import com.kamco.cd.kamcoback.postgres.core.ModelMngCoreService;
|
import com.kamco.cd.kamcoback.postgres.core.ModelMngCoreService;
|
||||||
import com.kamco.cd.kamcoback.scene.dto.MapInkxMngDto.Search5kReq;
|
|
||||||
import jakarta.validation.constraints.NotNull;
|
import jakarta.validation.constraints.NotNull;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -70,27 +70,42 @@ public class InferenceResultService {
|
|||||||
*/
|
*/
|
||||||
@Transactional
|
@Transactional
|
||||||
public UUID saveInferenceInfo(InferenceResultDto.RegReq req) {
|
public UUID saveInferenceInfo(InferenceResultDto.RegReq req) {
|
||||||
// 전체일때 5k도협 가져오기
|
|
||||||
List<MapSheetNumDto> mapSheetTargetNum = new ArrayList<>();
|
|
||||||
List<MapSheetNumDto> mapSheetCompareNum = new ArrayList<>();
|
|
||||||
|
|
||||||
// 분석대상 도엽이 전체일때
|
// 분석대상 도엽이 전체일때
|
||||||
if (MapSheetScope.ALL.getId().equals(req.getMapSheetScope())) {
|
if (MapSheetScope.ALL.getId().equals(req.getMapSheetScope())) {
|
||||||
Search5kReq mapReq = new Search5kReq();
|
|
||||||
mapReq.setUseInference("USE");
|
|
||||||
|
|
||||||
List<String> mapTargetIds = new ArrayList<>();
|
|
||||||
// 기준년도 조회
|
// 기준년도 조회
|
||||||
List<MngListDto> targetList = mapSheetMngCoreService.getHstMapSheetList(req.getTargetYyyy());
|
List<MngListDto> targetList = mapSheetMngCoreService.getHstMapSheetList(req.getTargetYyyy());
|
||||||
|
req.setMapSheetNum(this.createdMngDto(req, targetList));
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// 부분
|
||||||
|
|
||||||
|
List<String> mapTargetIds = new ArrayList<>();
|
||||||
|
req.getMapSheetNum().forEach(dto -> mapTargetIds.add(dto.getMapSheetNum()));
|
||||||
|
|
||||||
|
// 기준년도 조회
|
||||||
|
List<MngListDto> targetList =
|
||||||
|
mapSheetMngCoreService.getHstMapSheetList(req.getTargetYyyy(), mapTargetIds);
|
||||||
|
req.setMapSheetNum(this.createdMngDto(req, targetList));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 추론 테이블 저장
|
||||||
|
UUID uuid = inferenceResultCoreService.saveInferenceInfo(req);
|
||||||
|
this.startInference(req);
|
||||||
|
|
||||||
|
return uuid;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 비교년도 탐지 제이터 옵션 별로 조회하여 req에 적용
|
||||||
|
private List<MapSheetNumDto> createdMngDto(
|
||||||
|
InferenceResultDto.RegReq req, List<MngListDto> targetList) {
|
||||||
|
List<String> mapTargetIds = new ArrayList<>();
|
||||||
|
|
||||||
targetList.forEach(
|
targetList.forEach(
|
||||||
hstMapSheet -> {
|
hstMapSheet -> {
|
||||||
// 비교년도는 target 년도 기준으로 가져옴 파라미터 만들기
|
// 비교년도는 target 년도 기준으로 가져옴 파라미터 만들기
|
||||||
mapTargetIds.add(hstMapSheet.getMapSheetNum());
|
mapTargetIds.add(hstMapSheet.getMapSheetNum());
|
||||||
//
|
|
||||||
// mapSheetNumDto.setMapSheetNum(hstMapSheet.getMapSheetNum());
|
|
||||||
// mapSheetNumDto.setMapSheetName(hstMapSheet.getMapSheetName());
|
|
||||||
// mapSheetTargetNum.add(mapSheetNumDto);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// 비교년도 조회
|
// 비교년도 조회
|
||||||
@@ -116,6 +131,7 @@ public class InferenceResultService {
|
|||||||
.map(String::trim) // 공백/개행 방지
|
.map(String::trim) // 공백/개행 방지
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
|
// target 기준 compare 비교하여 서로 있는것만 저장
|
||||||
List<String> commonIds =
|
List<String> commonIds =
|
||||||
mapTargetIds.stream()
|
mapTargetIds.stream()
|
||||||
.filter(Objects::nonNull)
|
.filter(Objects::nonNull)
|
||||||
@@ -123,14 +139,10 @@ public class InferenceResultService {
|
|||||||
.filter(compareSet::contains)
|
.filter(compareSet::contains)
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
System.out.println("mapTargetIds size=" + mapTargetIds.size());
|
|
||||||
System.out.println("mapCompareIds size=" + mapCompareIds.size());
|
|
||||||
System.out.println("commonIds size=" + commonIds.size());
|
|
||||||
System.out.println(commonIds);
|
|
||||||
|
|
||||||
Set<String> commonIdSet =
|
Set<String> commonIdSet =
|
||||||
commonIds.stream().filter(Objects::nonNull).map(String::trim).collect(Collectors.toSet());
|
commonIds.stream().filter(Objects::nonNull).map(String::trim).collect(Collectors.toSet());
|
||||||
|
|
||||||
|
// 저장하기위해 파라미터 다시 구성
|
||||||
List<MapSheetNumDto> mapSheetNum =
|
List<MapSheetNumDto> mapSheetNum =
|
||||||
targetList.stream()
|
targetList.stream()
|
||||||
.filter(dto -> dto.getMapSheetNum() != null)
|
.filter(dto -> dto.getMapSheetNum() != null)
|
||||||
@@ -144,42 +156,45 @@ public class InferenceResultService {
|
|||||||
})
|
})
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
} else {
|
return mapSheetNum;
|
||||||
// 부분ㄹ
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 추론 테이블 저장
|
/**
|
||||||
// UUID uuid = inferenceResultCoreService.saveInferenceInfo(req);
|
* 추론 실행 API 호출
|
||||||
//
|
*
|
||||||
// List<String> mapSheetNumList = new ArrayList<>();
|
* @param req
|
||||||
// for (MapSheetNumDto mapSheetDto : mapSheetNum) {
|
*/
|
||||||
// mapSheetNumList.add(mapSheetDto.getMapSheetNum());
|
private void startInference(InferenceResultDto.RegReq req) {
|
||||||
// }
|
|
||||||
//
|
|
||||||
// String modelComparePath =
|
|
||||||
// this.getSceneInference(String.valueOf(req.getCompareYyyy()), mapSheetNumList);
|
|
||||||
// String modelTargetPath =
|
|
||||||
// this.getSceneInference(String.valueOf(req.getTargetYyyy()), mapSheetNumList);
|
|
||||||
//
|
|
||||||
// PredRequestsAreas predRequestsAreas = new PredRequestsAreas();
|
|
||||||
// predRequestsAreas.setInput1_year(req.getCompareYyyy());
|
|
||||||
// predRequestsAreas.setInput2_year(req.getTargetYyyy());
|
|
||||||
// predRequestsAreas.setInput1_scene_path(modelComparePath);
|
|
||||||
// predRequestsAreas.setInput2_scene_path(modelTargetPath);
|
|
||||||
//
|
|
||||||
// InferenceSendDto m1 = this.getModelInfo(req.getModel1Uuid());
|
|
||||||
// InferenceSendDto m2 = this.getModelInfo(req.getModel2Uuid());
|
|
||||||
// InferenceSendDto m3 = this.getModelInfo(req.getModel3Uuid());
|
|
||||||
//
|
|
||||||
// m1.setPredRequestsAreas(predRequestsAreas);
|
|
||||||
// m2.setPredRequestsAreas(predRequestsAreas);
|
|
||||||
// m3.setPredRequestsAreas(predRequestsAreas);
|
|
||||||
|
|
||||||
// ensureAccepted(m1);
|
List<MapSheetNumDto> mapSheetNum = req.getMapSheetNum();
|
||||||
|
List<String> mapSheetNumList = new ArrayList<>();
|
||||||
|
|
||||||
|
for (MapSheetNumDto mapSheetDto : mapSheetNum) {
|
||||||
|
mapSheetNumList.add(mapSheetDto.getMapSheetNum());
|
||||||
|
}
|
||||||
|
|
||||||
|
String modelComparePath =
|
||||||
|
this.getSceneInference(String.valueOf(req.getCompareYyyy()), mapSheetNumList);
|
||||||
|
String modelTargetPath =
|
||||||
|
this.getSceneInference(String.valueOf(req.getTargetYyyy()), mapSheetNumList);
|
||||||
|
|
||||||
|
pred_requests_areas predRequestsAreas = new pred_requests_areas();
|
||||||
|
predRequestsAreas.setInput1_year(req.getCompareYyyy());
|
||||||
|
predRequestsAreas.setInput2_year(req.getTargetYyyy());
|
||||||
|
predRequestsAreas.setInput1_scene_path(modelComparePath);
|
||||||
|
predRequestsAreas.setInput2_scene_path(modelTargetPath);
|
||||||
|
|
||||||
|
InferenceSendDto m1 = this.getModelInfo(req.getModel1Uuid());
|
||||||
|
InferenceSendDto m2 = this.getModelInfo(req.getModel2Uuid());
|
||||||
|
InferenceSendDto m3 = this.getModelInfo(req.getModel3Uuid());
|
||||||
|
|
||||||
|
m1.setPred_requests_areas(predRequestsAreas);
|
||||||
|
m2.setPred_requests_areas(predRequestsAreas);
|
||||||
|
m3.setPred_requests_areas(predRequestsAreas);
|
||||||
|
|
||||||
|
ensureAccepted(m1);
|
||||||
// ensureAccepted(m2);
|
// ensureAccepted(m2);
|
||||||
// ensureAccepted(m3);
|
// ensureAccepted(m3);
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -190,7 +205,9 @@ public class InferenceResultService {
|
|||||||
private void ensureAccepted(InferenceSendDto dto) {
|
private void ensureAccepted(InferenceSendDto dto) {
|
||||||
log.info("dto null? {}", dto == null);
|
log.info("dto null? {}", dto == null);
|
||||||
ObjectMapper om = new ObjectMapper();
|
ObjectMapper om = new ObjectMapper();
|
||||||
|
String json = "";
|
||||||
try {
|
try {
|
||||||
|
json = om.writeValueAsString(dto);
|
||||||
log.info("dto json={}", om.writeValueAsString(dto));
|
log.info("dto json={}", om.writeValueAsString(dto));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error(e.getMessage());
|
log.error(e.getMessage());
|
||||||
@@ -200,7 +217,7 @@ public class InferenceResultService {
|
|||||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||||
|
|
||||||
ExternalCallResult result =
|
ExternalCallResult result =
|
||||||
externalHttpClient.call(inferenceUrl, HttpMethod.POST, dto, headers);
|
externalHttpClient.call(inferenceUrl, HttpMethod.POST, json, headers);
|
||||||
|
|
||||||
if (!result.success()) {
|
if (!result.success()) {
|
||||||
throw new CustomApiException("BAD_GATEWAY", HttpStatus.BAD_GATEWAY);
|
throw new CustomApiException("BAD_GATEWAY", HttpStatus.BAD_GATEWAY);
|
||||||
|
|||||||
@@ -242,6 +242,10 @@ public class MapSheetMngCoreService {
|
|||||||
return mapSheetMngRepository.findByHstMapSheetTargetList(mngYyyy);
|
return mapSheetMngRepository.findByHstMapSheetTargetList(mngYyyy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<MngListDto> getHstMapSheetList(int mngYyyy, List<String> mapIds) {
|
||||||
|
return mapSheetMngRepository.findByHstMapSheetTargetList(mngYyyy, mapIds);
|
||||||
|
}
|
||||||
|
|
||||||
public List<MngListCompareDto> getByHstMapSheetCompareList(int mngYyyy, List<String> mapId) {
|
public List<MngListCompareDto> getByHstMapSheetCompareList(int mngYyyy, List<String> mapId) {
|
||||||
return mapSheetMngRepository.findByHstMapSheetCompareList(mngYyyy, mapId);
|
return mapSheetMngRepository.findByHstMapSheetCompareList(mngYyyy, mapId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,6 +63,8 @@ public interface MapSheetMngRepositoryCustom {
|
|||||||
|
|
||||||
List<MngListDto> findByHstMapSheetTargetList(int mngYyyy);
|
List<MngListDto> findByHstMapSheetTargetList(int mngYyyy);
|
||||||
|
|
||||||
|
List<MngListDto> findByHstMapSheetTargetList(int mngYyyy, List<String> mapIds);
|
||||||
|
|
||||||
List<MngListCompareDto> findByHstMapSheetCompareList(int mngYyyy, List<String> mapId);
|
List<MngListCompareDto> findByHstMapSheetCompareList(int mngYyyy, List<String> mapId);
|
||||||
|
|
||||||
MapSheetMngDto.MngFilesDto findByFileUidMapSheetFile(Long fileUid);
|
MapSheetMngDto.MngFilesDto findByFileUidMapSheetFile(Long fileUid);
|
||||||
|
|||||||
@@ -498,6 +498,27 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport
|
|||||||
.fetch();
|
.fetch();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<MngListDto> findByHstMapSheetTargetList(int mngYyyy, List<String> mapIds) {
|
||||||
|
BooleanBuilder whereBuilder = new BooleanBuilder();
|
||||||
|
whereBuilder.and(mapSheetMngHstEntity.mngYyyy.eq(mngYyyy));
|
||||||
|
whereBuilder.and(mapSheetMngHstEntity.mapSheetNum.in(mapIds));
|
||||||
|
whereBuilder.and(mapSheetMngHstEntity.dataState.eq("DONE"));
|
||||||
|
whereBuilder.and(mapSheetMngHstEntity.syncState.eq("DONE"));
|
||||||
|
whereBuilder.and(mapSheetMngHstEntity.useInference.eq("USE"));
|
||||||
|
|
||||||
|
return queryFactory
|
||||||
|
.select(
|
||||||
|
Projections.constructor(
|
||||||
|
MngListDto.class,
|
||||||
|
mapSheetMngHstEntity.mngYyyy,
|
||||||
|
mapSheetMngHstEntity.mapSheetNum,
|
||||||
|
mapSheetMngHstEntity.mapSheetName))
|
||||||
|
.from(mapSheetMngHstEntity)
|
||||||
|
.where(whereBuilder)
|
||||||
|
.fetch();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<MngListCompareDto> findByHstMapSheetCompareList(int mngYyyy, List<String> mapIds) {
|
public List<MngListCompareDto> findByHstMapSheetCompareList(int mngYyyy, List<String> mapIds) {
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user