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:
2026-01-13 15:53:21 +09:00
5 changed files with 52 additions and 31 deletions

View File

@@ -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());

View File

@@ -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();
} }

View File

@@ -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());
} }

View File

@@ -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");
}
} }

View File

@@ -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() {
@@ -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();
@@ -181,7 +179,7 @@ public class MapSheetInferenceJobService {
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);
@@ -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();