요약정보 API 추가
This commit is contained in:
@@ -46,7 +46,7 @@ public class InferenceResultApiController {
|
||||
@Parameter(description = "분석상태", example = "0000")
|
||||
@RequestParam(required = false)
|
||||
String statCode,
|
||||
@Parameter(description = "검색", example = "2023_2024년도") @RequestParam(required = false)
|
||||
@Parameter(description = "제목", example = "2023_2024년도") @RequestParam(required = false)
|
||||
String title,
|
||||
@Parameter(description = "페이지 번호 (0부터 시작)", example = "0") @RequestParam(defaultValue = "0")
|
||||
int page
|
||||
@@ -55,4 +55,18 @@ public class InferenceResultApiController {
|
||||
Page<InferenceResultDto.AnalResList> analResList = inferenceResultService.getInferenceResultList(searchReq);
|
||||
return ApiResponseDto.ok(analResList);
|
||||
}
|
||||
|
||||
@Operation(
|
||||
summary = "추론관리 분석결과 요약정보",
|
||||
description =
|
||||
"분석결과 요약정보를 조회합니다.")
|
||||
@GetMapping("/summary")
|
||||
public ApiResponseDto<InferenceResultDto.AnalResSummary> getInferenceResultSummary(
|
||||
@Parameter(description = "목록 id", example = "1")
|
||||
@RequestParam Long id) {
|
||||
return ApiResponseDto.ok(inferenceResultService.getInferenceResultSummary(id));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -60,7 +60,8 @@ public class InferenceResultDto {
|
||||
private ZonedDateTime analStrtDttm;
|
||||
@JsonFormatDttm
|
||||
private ZonedDateTime analEndDttm;
|
||||
private Integer analSs;
|
||||
private Long analSec;
|
||||
private Long analPredSec;
|
||||
private String analState;
|
||||
private String analStateNm;
|
||||
private String gukyuinUsed;
|
||||
@@ -72,7 +73,8 @@ public class InferenceResultDto {
|
||||
Long detectingCnt,
|
||||
ZonedDateTime analStrtDttm,
|
||||
ZonedDateTime analEndDttm,
|
||||
Integer analSs,
|
||||
Long analSec,
|
||||
Long analPredSec,
|
||||
String analState,
|
||||
String analStateNm,
|
||||
String gukyuinUsed
|
||||
@@ -83,13 +85,61 @@ public class InferenceResultDto {
|
||||
this.detectingCnt = detectingCnt;
|
||||
this.analStrtDttm = analStrtDttm;
|
||||
this.analEndDttm = analEndDttm;
|
||||
this.analSs = analSs;
|
||||
this.analSec = analSec;
|
||||
this.analPredSec = analPredSec;
|
||||
this.analState = analState;
|
||||
this.analStateNm = analStateNm;
|
||||
this.gukyuinUsed = gukyuinUsed;
|
||||
}
|
||||
}
|
||||
|
||||
@Schema(name = "AnalysisResultSummary", description = "분석결과 요약정보")
|
||||
@Getter
|
||||
public static class AnalResSummary {
|
||||
private Long id;
|
||||
private String modelInfo;
|
||||
private Integer targetYyyy;
|
||||
private Integer compareYyyy;
|
||||
private String analMapSheet;
|
||||
@JsonFormatDttm
|
||||
private ZonedDateTime analStrtDttm;
|
||||
@JsonFormatDttm
|
||||
private ZonedDateTime analEndDttm;
|
||||
private Long analSec;
|
||||
private Long analPredSec;
|
||||
private String resultUrl;
|
||||
private Long detectingCnt;
|
||||
private Double accuracy;
|
||||
|
||||
public AnalResSummary(
|
||||
Long id,
|
||||
String modelInfo,
|
||||
Integer targetYyyy,
|
||||
Integer compareYyyy,
|
||||
String analMapSheet,
|
||||
ZonedDateTime analStrtDttm,
|
||||
ZonedDateTime analEndDttm,
|
||||
Long analSec,
|
||||
Long analPredSec,
|
||||
String resultUrl,
|
||||
Long detectingCnt,
|
||||
Double accuracy
|
||||
) {
|
||||
this.id = id;
|
||||
this.modelInfo = modelInfo;
|
||||
this.targetYyyy = targetYyyy;
|
||||
this.compareYyyy = compareYyyy;
|
||||
this.analMapSheet = analMapSheet;
|
||||
this.analStrtDttm = analStrtDttm;
|
||||
this.analEndDttm = analEndDttm;
|
||||
this.analSec = analSec;
|
||||
this.analPredSec = analPredSec;
|
||||
this.resultUrl = resultUrl;
|
||||
this.detectingCnt = detectingCnt;
|
||||
this.accuracy = accuracy;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Schema(name = "InferenceResultSearchReq", description = "분석결과 목록 요청 정보")
|
||||
@Getter
|
||||
|
||||
@@ -24,6 +24,14 @@ public class InferenceResultService {
|
||||
return inferenceResultCoreService.getInferenceResultList(searchReq);
|
||||
}
|
||||
|
||||
/**
|
||||
* 분석결과 요약정보
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public InferenceResultDto.AnalResSummary getInferenceResultSummary(Long id) {
|
||||
return inferenceResultCoreService.getInferenceResultSummary(id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.kamco.cd.kamcoback.postgres.core;
|
||||
|
||||
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto;
|
||||
import com.kamco.cd.kamcoback.postgres.repository.Inference.InferenceResultRepository;
|
||||
import jakarta.persistence.EntityNotFoundException;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -20,4 +21,14 @@ public class InferenceResultCoreService {
|
||||
public Page<InferenceResultDto.AnalResList> getInferenceResultList(InferenceResultDto.SearchReq searchReq) {
|
||||
return inferenceResultRepository.getInferenceResultList(searchReq);
|
||||
}
|
||||
|
||||
/**
|
||||
* 분석결과 요약정보
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public InferenceResultDto.AnalResSummary getInferenceResultSummary(Long id) {
|
||||
InferenceResultDto.AnalResSummary summary = inferenceResultRepository.getInferenceResultSummary(id).orElseThrow(() -> new EntityNotFoundException("요약정보를 찾을 수 없습니다. " + id));
|
||||
return summary;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,10 @@ public class MapSheetAnalEntity {
|
||||
private ZonedDateTime analEndDttm;
|
||||
|
||||
@Column(name = "anal_sec")
|
||||
private Integer analSs;
|
||||
private Long analSec;
|
||||
|
||||
@Column(name = "anal_pred_sec")
|
||||
private Long analPredSec;
|
||||
|
||||
@Size(max = 20)
|
||||
@Column(name = "anal_state", length = 20)
|
||||
|
||||
@@ -2,8 +2,10 @@ package com.kamco.cd.kamcoback.postgres.repository.Inference;
|
||||
|
||||
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto;
|
||||
import com.kamco.cd.kamcoback.postgres.entity.MapSheetAnalEntity;
|
||||
import java.util.Optional;
|
||||
import org.springframework.data.domain.Page;
|
||||
|
||||
public interface InferenceResultRepositoryCustom {
|
||||
Page<InferenceResultDto.AnalResList> getInferenceResultList(InferenceResultDto.SearchReq searchReq);
|
||||
Optional<InferenceResultDto.AnalResSummary> getInferenceResultSummary(Long id);
|
||||
}
|
||||
|
||||
@@ -1,11 +1,22 @@
|
||||
package com.kamco.cd.kamcoback.postgres.repository.Inference;
|
||||
|
||||
import com.kamco.cd.kamcoback.common.utils.interfaces.JsonFormatDttm;
|
||||
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto;
|
||||
import com.kamco.cd.kamcoback.postgres.entity.ModelVerEntity;
|
||||
import com.kamco.cd.kamcoback.postgres.entity.QMapSheetAnalEntity;
|
||||
import com.kamco.cd.kamcoback.postgres.entity.QModelMngEntity;
|
||||
import com.kamco.cd.kamcoback.postgres.entity.QModelVerEntity;
|
||||
import com.querydsl.core.Tuple;
|
||||
import com.querydsl.core.types.Projections;
|
||||
import com.querydsl.core.types.dsl.Expressions;
|
||||
import com.querydsl.core.types.dsl.NumberExpression;
|
||||
import com.querydsl.jpa.JPAExpressions;
|
||||
import com.querydsl.jpa.JPQLQuery;
|
||||
import com.querydsl.jpa.impl.JPAQueryFactory;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageImpl;
|
||||
@@ -19,8 +30,15 @@ public class InferenceResultRepositoryImpl implements InferenceResultRepositoryC
|
||||
|
||||
private final JPAQueryFactory queryFactory;
|
||||
private final QMapSheetAnalEntity mapSheetAnal = QMapSheetAnalEntity.mapSheetAnalEntity;
|
||||
private final QModelMngEntity tmm = QModelMngEntity.modelMngEntity;
|
||||
private final QModelVerEntity tmv = QModelVerEntity.modelVerEntity;
|
||||
|
||||
|
||||
/**
|
||||
* 분석결과 목록 조회
|
||||
* @param searchReq
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Page<InferenceResultDto.AnalResList> getInferenceResultList(InferenceResultDto.SearchReq searchReq) {
|
||||
Pageable pageable = searchReq.toPageable();
|
||||
@@ -44,7 +62,8 @@ public class InferenceResultRepositoryImpl implements InferenceResultRepositoryC
|
||||
mapSheetAnal.detectingCnt,
|
||||
mapSheetAnal.analStrtDttm,
|
||||
mapSheetAnal.analEndDttm,
|
||||
mapSheetAnal.analSs,
|
||||
mapSheetAnal.analSec,
|
||||
mapSheetAnal.analPredSec,
|
||||
mapSheetAnal.analState,
|
||||
Expressions.stringTemplate("fn_code_name({0}, {1})", "0002", mapSheetAnal.analState),
|
||||
mapSheetAnal.gukyuinUsed
|
||||
@@ -70,4 +89,45 @@ public class InferenceResultRepositoryImpl implements InferenceResultRepositoryC
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 분석결과 요약정보
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Optional<InferenceResultDto.AnalResSummary> getInferenceResultSummary(Long id) {
|
||||
|
||||
// 1. 최신 버전 UID를 가져오는 서브쿼리
|
||||
JPQLQuery<Long> latestVerUidSub = JPAExpressions
|
||||
.select(tmv.id.max())
|
||||
.from(tmv)
|
||||
.where(tmv.modelUid.eq(tmm.id));
|
||||
|
||||
Optional<InferenceResultDto.AnalResSummary> content = Optional.ofNullable(queryFactory
|
||||
.select(Projections.constructor(InferenceResultDto.AnalResSummary.class,
|
||||
mapSheetAnal.id,
|
||||
tmm.modelNm.concat(" ").concat(tmv.modelVer).as("modelInfo"),
|
||||
mapSheetAnal.targetYyyy,
|
||||
mapSheetAnal.compareYyyy,
|
||||
mapSheetAnal.analMapSheet,
|
||||
mapSheetAnal.analStrtDttm,
|
||||
mapSheetAnal.analEndDttm,
|
||||
mapSheetAnal.analSec,
|
||||
mapSheetAnal.analPredSec,
|
||||
mapSheetAnal.resultUrl,
|
||||
mapSheetAnal.detectingCnt,
|
||||
mapSheetAnal.accuracy
|
||||
))
|
||||
.from(mapSheetAnal)
|
||||
.leftJoin(tmm).on(mapSheetAnal.modelUid.eq(tmm.id))
|
||||
.leftJoin(tmv).on(
|
||||
tmv.modelUid.eq(tmm.id)
|
||||
.and(tmv.id.eq(latestVerUidSub))
|
||||
)
|
||||
.where(mapSheetAnal.id.eq(id))
|
||||
.fetchOne()
|
||||
);
|
||||
return content;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user