[KC-108] ai api batch 작업중

This commit is contained in:
2026-01-12 20:03:04 +09:00
parent ededc512d6
commit 9022f05cc5
13 changed files with 207 additions and 86 deletions

View File

@@ -228,6 +228,15 @@ public class InferenceResultCoreService {
entity.setStatus(status);
}
public List<InferenceServerStatusDto> getInferenceServerStatusList(){return mapSheetLearnRepository.getInferenceServerStatusList();
public List<InferenceServerStatusDto> getInferenceServerStatusList() {
return mapSheetLearnRepository.getInferenceServerStatusList();
}
public Long getInferenceResultByStatus(String status) {
MapSheetLearnEntity entity =
mapSheetLearnRepository
.getInferenceResultByStatus(status)
.orElseThrow(() -> new EntityNotFoundException(status));
return entity.getBatchId();
}
}

View File

@@ -44,5 +44,4 @@ public class GpuMetricEntity {
@Column(name = "gpu_mem_total")
private Float gpuMemTotal;
}

View File

@@ -55,5 +55,4 @@ public class SystemMetricEntity {
@Column(name = "memused")
private Float memused;
}

View File

@@ -3,9 +3,9 @@ package com.kamco.cd.kamcoback.postgres.repository.Inference;
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto;
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.InferenceServerStatusDto;
import com.kamco.cd.kamcoback.postgres.entity.MapSheetLearnEntity;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
import java.util.List;
import org.springframework.data.domain.Page;
public interface MapSheetLearnRepositoryCustom {
@@ -15,4 +15,6 @@ public interface MapSheetLearnRepositoryCustom {
Optional<MapSheetLearnEntity> getInferenceResultByUuid(UUID uuid);
List<InferenceServerStatusDto> getInferenceServerStatusList();
Optional<MapSheetLearnEntity> getInferenceResultByStatus(String status);
}

View File

@@ -94,35 +94,49 @@ public class MapSheetLearnRepositoryImpl implements MapSheetLearnRepositoryCusto
BooleanBuilder builder = new BooleanBuilder();
List<Integer> latestIds = queryFactory
.select(systemMetricEntity.id1.max())
.from(systemMetricEntity)
.groupBy(systemMetricEntity.serverName)
.fetch();
List<Integer> latestIds =
queryFactory
.select(systemMetricEntity.id1.max())
.from(systemMetricEntity)
.groupBy(systemMetricEntity.serverName)
.fetch();
List<Integer> latestGpuIds = queryFactory
.select(gpuMetricEntity.id1.max())
.from(gpuMetricEntity)
.groupBy(gpuMetricEntity.serverName)
.fetch();
List<Integer> latestGpuIds =
queryFactory
.select(gpuMetricEntity.id1.max())
.from(gpuMetricEntity)
.groupBy(gpuMetricEntity.serverName)
.fetch();
List<InferenceServerStatusDto> foundContent = queryFactory
.select(Projections.constructor(
InferenceServerStatusDto.class,
systemMetricEntity.serverName,
systemMetricEntity.cpuUser,
systemMetricEntity.cpuSystem,
systemMetricEntity.memused,
systemMetricEntity.kbmemused,
gpuMetricEntity.gpuUtil
))
.from(systemMetricEntity)
.leftJoin(gpuMetricEntity).on(gpuMetricEntity.serverName.eq(systemMetricEntity.serverName))
.where(systemMetricEntity.id1.in(latestIds)) // In 절 사용
.orderBy(systemMetricEntity.serverName.asc())
.limit(4)
.fetch();
List<InferenceServerStatusDto> foundContent =
queryFactory
.select(
Projections.constructor(
InferenceServerStatusDto.class,
systemMetricEntity.serverName,
systemMetricEntity.cpuUser,
systemMetricEntity.cpuSystem,
systemMetricEntity.memused,
systemMetricEntity.kbmemused,
gpuMetricEntity.gpuUtil))
.from(systemMetricEntity)
.leftJoin(gpuMetricEntity)
.on(gpuMetricEntity.serverName.eq(systemMetricEntity.serverName))
.where(systemMetricEntity.id1.in(latestIds)) // In 절 사용
.orderBy(systemMetricEntity.serverName.asc())
.limit(4)
.fetch();
return foundContent;
}
@Override
public Optional<MapSheetLearnEntity> getInferenceResultByStatus(String status) {
return Optional.ofNullable(
queryFactory
.selectFrom(mapSheetLearnEntity)
.where(mapSheetLearnEntity.status.eq(status))
.limit(1)
.fetchOne());
}
}