Merge pull request 'feat/infer_dev_260107' (#226) from feat/infer_dev_260107 into develop
Reviewed-on: https://kamco.gitea.gs.dabeeo.com/dabeeo/kamco-dabeeo-backoffice/pulls/226
This commit is contained in:
@@ -96,7 +96,7 @@ public class InferenceResultService {
|
|||||||
|
|
||||||
// 기준년도 조회
|
// 기준년도 조회
|
||||||
List<MngListDto> targetList = mapSheetMngCoreService.getHstMapSheetList(req.getTargetYyyy());
|
List<MngListDto> targetList = mapSheetMngCoreService.getHstMapSheetList(req.getTargetYyyy());
|
||||||
req.setMapSheetNum(this.createdMngDto(req, targetList));
|
req.setMapSheetNum(createdMngDto(req, targetList));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// 부분
|
// 부분
|
||||||
@@ -107,7 +107,7 @@ public class InferenceResultService {
|
|||||||
// 기준년도 조회
|
// 기준년도 조회
|
||||||
List<MngListDto> targetList =
|
List<MngListDto> targetList =
|
||||||
mapSheetMngCoreService.getHstMapSheetList(req.getTargetYyyy(), mapTargetIds);
|
mapSheetMngCoreService.getHstMapSheetList(req.getTargetYyyy(), mapTargetIds);
|
||||||
req.setMapSheetNum(this.createdMngDto(req, targetList));
|
req.setMapSheetNum(createdMngDto(req, targetList));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (req.getMapSheetNum().isEmpty()) {
|
if (req.getMapSheetNum().isEmpty()) {
|
||||||
@@ -116,7 +116,9 @@ public class InferenceResultService {
|
|||||||
|
|
||||||
// 추론 테이블 저장
|
// 추론 테이블 저장
|
||||||
UUID uuid = inferenceResultCoreService.saveInferenceInfo(req);
|
UUID uuid = inferenceResultCoreService.saveInferenceInfo(req);
|
||||||
this.startInference(req, uuid);
|
|
||||||
|
// 추론 실행 API 호출
|
||||||
|
startInference(req, uuid);
|
||||||
|
|
||||||
return uuid;
|
return uuid;
|
||||||
}
|
}
|
||||||
@@ -198,9 +200,9 @@ public class InferenceResultService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String modelComparePath =
|
String modelComparePath =
|
||||||
this.getSceneInference(String.valueOf(req.getCompareYyyy()), mapSheetNumList);
|
getSceneInference(String.valueOf(req.getCompareYyyy()), mapSheetNumList);
|
||||||
String modelTargetPath =
|
String modelTargetPath =
|
||||||
this.getSceneInference(String.valueOf(req.getTargetYyyy()), mapSheetNumList);
|
getSceneInference(String.valueOf(req.getTargetYyyy()), mapSheetNumList);
|
||||||
|
|
||||||
pred_requests_areas predRequestsAreas = new pred_requests_areas();
|
pred_requests_areas predRequestsAreas = new pred_requests_areas();
|
||||||
predRequestsAreas.setInput1_year(req.getCompareYyyy());
|
predRequestsAreas.setInput1_year(req.getCompareYyyy());
|
||||||
|
|||||||
@@ -104,13 +104,13 @@ public class InferenceResultCoreService {
|
|||||||
buffer.add(e);
|
buffer.add(e);
|
||||||
|
|
||||||
if (buffer.size() == CHUNK) {
|
if (buffer.size() == CHUNK) {
|
||||||
this.flushChunk(buffer);
|
flushChunk(buffer);
|
||||||
buffer.clear();
|
buffer.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!buffer.isEmpty()) {
|
if (!buffer.isEmpty()) {
|
||||||
this.flushChunk(buffer);
|
flushChunk(buffer);
|
||||||
buffer.clear();
|
buffer.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -144,8 +144,9 @@ public class MapSheetLearnRepositoryImpl implements MapSheetLearnRepositoryCusto
|
|||||||
return Optional.ofNullable(
|
return Optional.ofNullable(
|
||||||
queryFactory
|
queryFactory
|
||||||
.selectFrom(mapSheetLearnEntity)
|
.selectFrom(mapSheetLearnEntity)
|
||||||
.where(mapSheetLearnEntity.status.eq(status))
|
.where(mapSheetLearnEntity.id.eq(106L))
|
||||||
.limit(1)
|
// .where(mapSheetLearnEntity.status.eq(status))
|
||||||
|
// .limit(1)
|
||||||
.fetchOne());
|
.fetchOne());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.kamco.cd.kamcoback.scheduler;
|
|||||||
import com.kamco.cd.kamcoback.code.dto.CommonCodeDto;
|
import com.kamco.cd.kamcoback.code.dto.CommonCodeDto;
|
||||||
import com.kamco.cd.kamcoback.code.service.CommonCodeService;
|
import com.kamco.cd.kamcoback.code.service.CommonCodeService;
|
||||||
import com.kamco.cd.kamcoback.config.api.ApiResponseDto;
|
import com.kamco.cd.kamcoback.config.api.ApiResponseDto;
|
||||||
|
import com.kamco.cd.kamcoback.scheduler.service.MapSheetInferenceJobService;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
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;
|
||||||
@@ -10,6 +11,7 @@ import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
|||||||
import io.swagger.v3.oas.annotations.responses.ApiResponses;
|
import io.swagger.v3.oas.annotations.responses.ApiResponses;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PutMapping;
|
import org.springframework.web.bind.annotation.PutMapping;
|
||||||
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;
|
||||||
@@ -23,6 +25,7 @@ public class MapSheetMngFileJobApiController {
|
|||||||
|
|
||||||
private final CommonCodeService commonCodeService;
|
private final CommonCodeService commonCodeService;
|
||||||
private final MapSheetMngFileJobController mapSheetMngFileJobController;
|
private final MapSheetMngFileJobController mapSheetMngFileJobController;
|
||||||
|
private final MapSheetInferenceJobService mapSheetInferenceJobService;
|
||||||
|
|
||||||
@Operation(summary = "영상관리 파일 싱크 스캐쥴러 Start/Stop", description = "영상관리 파일 싱크 스캐쥴러 Start/Stop API")
|
@Operation(summary = "영상관리 파일 싱크 스캐쥴러 Start/Stop", description = "영상관리 파일 싱크 스캐쥴러 Start/Stop API")
|
||||||
@ApiResponses(
|
@ApiResponses(
|
||||||
@@ -46,4 +49,22 @@ public class MapSheetMngFileJobApiController {
|
|||||||
|
|
||||||
return ApiResponseDto.createOK("OK");
|
return ApiResponseDto.createOK("OK");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/inference-batch")
|
||||||
|
@ApiResponses(
|
||||||
|
value = {
|
||||||
|
@ApiResponse(
|
||||||
|
responseCode = "200",
|
||||||
|
description = "실행 성공",
|
||||||
|
content =
|
||||||
|
@Content(
|
||||||
|
mediaType = "application/json",
|
||||||
|
schema = @Schema(implementation = String.class))),
|
||||||
|
@ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content),
|
||||||
|
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content)
|
||||||
|
})
|
||||||
|
public ApiResponseDto<String> inferenceRunBatch() {
|
||||||
|
// mapSheetInferenceJobService.runBatch();
|
||||||
|
return ApiResponseDto.createOK("OK");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,9 +48,7 @@ public class MapSheetInferenceJobService {
|
|||||||
@Value("${inference.url}")
|
@Value("${inference.url}")
|
||||||
private String inferenceUrl;
|
private String inferenceUrl;
|
||||||
|
|
||||||
/**
|
/** 추론 진행 배치 1분 */
|
||||||
* 추론 진행 배치 1분
|
|
||||||
*/
|
|
||||||
@Scheduled(fixedDelay = 60_000)
|
@Scheduled(fixedDelay = 60_000)
|
||||||
@Transactional
|
@Transactional
|
||||||
public void runBatch() {
|
public void runBatch() {
|
||||||
@@ -61,7 +59,7 @@ public class MapSheetInferenceJobService {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
InferenceBatchSheet batchSheet =
|
InferenceBatchSheet batchSheet =
|
||||||
inferenceResultCoreService.getInferenceResultByStatus(Status.IN_PROGRESS.getId());
|
inferenceResultCoreService.getInferenceResultByStatus(Status.IN_PROGRESS.getId());
|
||||||
|
|
||||||
if (batchSheet == null) {
|
if (batchSheet == null) {
|
||||||
return;
|
return;
|
||||||
@@ -88,7 +86,7 @@ public class MapSheetInferenceJobService {
|
|||||||
String url = batchUrl + "/" + batchId;
|
String url = batchUrl + "/" + batchId;
|
||||||
|
|
||||||
ExternalCallResult<String> result =
|
ExternalCallResult<String> result =
|
||||||
externalHttpClient.call(url, HttpMethod.GET, null, headers, String.class);
|
externalHttpClient.call(url, HttpMethod.GET, null, headers, String.class);
|
||||||
|
|
||||||
int status = result.statusCode();
|
int status = result.statusCode();
|
||||||
if (status < 200 || status >= 300) {
|
if (status < 200 || status >= 300) {
|
||||||
@@ -103,23 +101,23 @@ public class MapSheetInferenceJobService {
|
|||||||
int failedJobs = dto.getFailedJobs();
|
int failedJobs = dto.getFailedJobs();
|
||||||
|
|
||||||
// 성공, 실패 값 더해서 total 과 같으면 완료
|
// 성공, 실패 값 더해서 total 과 같으면 완료
|
||||||
String inferStatus = this.setStatus(totalJobs, completedJobs, failedJobs);
|
String inferStatus = setStatus(totalJobs, completedJobs, failedJobs);
|
||||||
|
|
||||||
if ("COMPLETED".equals(inferStatus)) {
|
if ("COMPLETED".equals(inferStatus)) {
|
||||||
String type = batchSheet.getRunningModelType();
|
String type = batchSheet.getRunningModelType();
|
||||||
|
|
||||||
if (type.equals("M1")) {
|
if (type.equals("M1")) {
|
||||||
// M1 완료되었으면 M2 실행
|
// M1 완료되었으면 M2 실행
|
||||||
this.startInference(
|
startInference(
|
||||||
batchSheet.getId(), batchSheet.getUuid(), "M2", batchSheet.getM2ModelUuid());
|
batchSheet.getId(), batchSheet.getUuid(), "M2", batchSheet.getM2ModelUuid());
|
||||||
// 종료시간
|
// 종료시간
|
||||||
this.updateProcessingEndTimeByModel(batchSheet.getUuid(), ZonedDateTime.now(), "M1");
|
updateProcessingEndTimeByModel(batchSheet.getUuid(), ZonedDateTime.now(), "M1");
|
||||||
} else if (type.equals("M2")) {
|
} else if (type.equals("M2")) {
|
||||||
// M2 완료되었으면 M3 실행
|
// M2 완료되었으면 M3 실행
|
||||||
this.startInference(
|
startInference(
|
||||||
batchSheet.getId(), batchSheet.getUuid(), "M3", batchSheet.getM3ModelUuid());
|
batchSheet.getId(), batchSheet.getUuid(), "M3", batchSheet.getM3ModelUuid());
|
||||||
// 종료시간
|
// 종료시간
|
||||||
this.updateProcessingEndTimeByModel(batchSheet.getUuid(), ZonedDateTime.now(), "M2");
|
updateProcessingEndTimeByModel(batchSheet.getUuid(), ZonedDateTime.now(), "M2");
|
||||||
} else if (type.equals("M3")) {
|
} else if (type.equals("M3")) {
|
||||||
// 완료
|
// 완료
|
||||||
SaveInferenceAiDto saveInferenceAiDto = new SaveInferenceAiDto();
|
SaveInferenceAiDto saveInferenceAiDto = new SaveInferenceAiDto();
|
||||||
@@ -129,7 +127,7 @@ public class MapSheetInferenceJobService {
|
|||||||
saveInferenceAiDto.setType(type);
|
saveInferenceAiDto.setType(type);
|
||||||
inferenceResultCoreService.update(saveInferenceAiDto);
|
inferenceResultCoreService.update(saveInferenceAiDto);
|
||||||
// 종료시간
|
// 종료시간
|
||||||
this.updateProcessingEndTimeByModel(batchSheet.getUuid(), ZonedDateTime.now(), "M3");
|
updateProcessingEndTimeByModel(batchSheet.getUuid(), ZonedDateTime.now(), "M3");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
SaveInferenceAiDto saveInferenceAiDto = new SaveInferenceAiDto();
|
SaveInferenceAiDto saveInferenceAiDto = new SaveInferenceAiDto();
|
||||||
@@ -148,7 +146,7 @@ public class MapSheetInferenceJobService {
|
|||||||
private void startInference(Long id, UUID uuid, String type, UUID modelUuid) {
|
private void startInference(Long id, UUID uuid, String type, UUID modelUuid) {
|
||||||
|
|
||||||
InferenceProgressDto progressDto =
|
InferenceProgressDto progressDto =
|
||||||
inferenceResultCoreService.getInferenceAiResultById(id, type, modelUuid);
|
inferenceResultCoreService.getInferenceAiResultById(id, type, modelUuid);
|
||||||
|
|
||||||
String inferenceType = "";
|
String inferenceType = "";
|
||||||
|
|
||||||
@@ -164,24 +162,24 @@ public class MapSheetInferenceJobService {
|
|||||||
predRequestsAreas.setInput1_year(progressDto.getPred_requests_areas().getInput1_year());
|
predRequestsAreas.setInput1_year(progressDto.getPred_requests_areas().getInput1_year());
|
||||||
predRequestsAreas.setInput2_year(progressDto.getPred_requests_areas().getInput2_year());
|
predRequestsAreas.setInput2_year(progressDto.getPred_requests_areas().getInput2_year());
|
||||||
predRequestsAreas.setInput1_scene_path(
|
predRequestsAreas.setInput1_scene_path(
|
||||||
progressDto.getPred_requests_areas().getInput1_scene_path());
|
progressDto.getPred_requests_areas().getInput1_scene_path());
|
||||||
predRequestsAreas.setInput2_scene_path(
|
predRequestsAreas.setInput2_scene_path(
|
||||||
progressDto.getPred_requests_areas().getInput2_scene_path());
|
progressDto.getPred_requests_areas().getInput2_scene_path());
|
||||||
|
|
||||||
InferenceSendDto m = new InferenceSendDto();
|
InferenceSendDto m = new InferenceSendDto();
|
||||||
m.setPred_requests_areas(predRequestsAreas);
|
m.setPred_requests_areas(predRequestsAreas);
|
||||||
m.setModel_version(progressDto.getModelVersion());
|
m.setModel_version(progressDto.getModelVersion());
|
||||||
m.setCd_model_path(progressDto.getCdModelPath() + "/" + progressDto.getCdModelFileName());
|
m.setCd_model_path(progressDto.getCdModelPath() + "/" + progressDto.getCdModelFileName());
|
||||||
m.setCd_model_config(
|
m.setCd_model_config(
|
||||||
progressDto.getCdModelConfigPath() + "/" + progressDto.getCdModelConfigFileName());
|
progressDto.getCdModelConfigPath() + "/" + progressDto.getCdModelConfigFileName());
|
||||||
m.setCls_model_path(
|
m.setCls_model_path(
|
||||||
progressDto.getCdModelClsPath() + "/" + progressDto.getCdModelClsFileName());
|
progressDto.getCdModelClsPath() + "/" + progressDto.getCdModelClsFileName());
|
||||||
m.setCls_model_version(progressDto.getClsModelVersion());
|
m.setCls_model_version(progressDto.getClsModelVersion());
|
||||||
m.setCd_model_type(inferenceType);
|
m.setCd_model_type(inferenceType);
|
||||||
m.setPriority(progressDto.getPriority());
|
m.setPriority(progressDto.getPriority());
|
||||||
|
|
||||||
// 추론 다음모델 실행
|
// 추론 다음모델 실행
|
||||||
Long batchId = this.ensureAccepted(m);
|
Long batchId = ensureAccepted(m);
|
||||||
|
|
||||||
SaveInferenceAiDto saveInferenceAiDto = new SaveInferenceAiDto();
|
SaveInferenceAiDto saveInferenceAiDto = new SaveInferenceAiDto();
|
||||||
saveInferenceAiDto.setUuid(uuid);
|
saveInferenceAiDto.setUuid(uuid);
|
||||||
@@ -217,7 +215,7 @@ public class MapSheetInferenceJobService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ExternalCallResult<String> result =
|
ExternalCallResult<String> result =
|
||||||
externalHttpClient.call(inferenceUrl, HttpMethod.POST, dto, headers, String.class);
|
externalHttpClient.call(inferenceUrl, HttpMethod.POST, dto, headers, String.class);
|
||||||
|
|
||||||
int status = result.statusCode();
|
int status = result.statusCode();
|
||||||
String body = result.body();
|
String body = result.body();
|
||||||
@@ -230,8 +228,7 @@ public class MapSheetInferenceJobService {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
List<Map<String, Object>> list =
|
List<Map<String, Object>> list =
|
||||||
om.readValue(body, new TypeReference<List<Map<String, Object>>>() {
|
om.readValue(body, new TypeReference<List<Map<String, Object>>>() {});
|
||||||
});
|
|
||||||
|
|
||||||
Integer batchIdInt = (Integer) list.get(0).get("batch_id");
|
Integer batchIdInt = (Integer) list.get(0).get("batch_id");
|
||||||
batchId = batchIdInt.longValue();
|
batchId = batchIdInt.longValue();
|
||||||
|
|||||||
Reference in New Issue
Block a user