추론관리 분석결과 목록조회 추가
This commit is contained in:
@@ -55,7 +55,7 @@ public class GeoJsonFileMonitorService {
|
|||||||
* 스케줄러를 통한 파일 모니터링
|
* 스케줄러를 통한 파일 모니터링
|
||||||
* 설정된 cron 표현식에 따라 주기적으로 실행
|
* 설정된 cron 표현식에 따라 주기적으로 실행
|
||||||
*/
|
*/
|
||||||
@Scheduled(cron = "#{@geoJsonMonitorConfig.cronExpression}")
|
// @Scheduled(cron = "#{@geoJsonMonitorConfig.cronExpression}")
|
||||||
public void monitorFiles() {
|
public void monitorFiles() {
|
||||||
log.debug("파일 모니터링 시작");
|
log.debug("파일 모니터링 시작");
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,21 @@
|
|||||||
package com.kamco.cd.kamcoback.inference;
|
package com.kamco.cd.kamcoback.inference;
|
||||||
|
|
||||||
|
import com.kamco.cd.kamcoback.config.api.ApiResponseDto;
|
||||||
|
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto;
|
||||||
import com.kamco.cd.kamcoback.inference.service.InferenceResultService;
|
import com.kamco.cd.kamcoback.inference.service.InferenceResultService;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Content;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||||
|
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 java.util.List;
|
import java.util.List;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
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.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
@Tag(name = "분석결과", description = "추론관리 분석결과")
|
@Tag(name = "분석결과", description = "추론관리 분석결과")
|
||||||
@@ -15,4 +26,34 @@ public class InferenceResultApiController {
|
|||||||
|
|
||||||
private final InferenceResultService inferenceResultService;
|
private final InferenceResultService inferenceResultService;
|
||||||
|
|
||||||
|
@Operation(
|
||||||
|
summary = "추론관리 분석결과 목록 조회",
|
||||||
|
description =
|
||||||
|
"분석상태, 제목으로 분석결과를 조회 합니다.")
|
||||||
|
@ApiResponses(
|
||||||
|
value = {
|
||||||
|
@ApiResponse(
|
||||||
|
responseCode = "200",
|
||||||
|
description = "검색 성공",
|
||||||
|
content =
|
||||||
|
@Content(
|
||||||
|
mediaType = "application/json",
|
||||||
|
schema = @Schema(implementation = Page.class))),
|
||||||
|
@ApiResponse(responseCode = "400", description = "잘못된 검색 조건", content = @Content),
|
||||||
|
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content)
|
||||||
|
})
|
||||||
|
@GetMapping("/list")
|
||||||
|
public ApiResponseDto<Page<InferenceResultDto.Basic>> getInferenceResultList(
|
||||||
|
@Parameter(description = "분석상태", example = "0000")
|
||||||
|
@RequestParam(required = false)
|
||||||
|
String statCode,
|
||||||
|
@Parameter(description = "검색", example = "2023_2024년도") @RequestParam(required = false)
|
||||||
|
String title,
|
||||||
|
@Parameter(description = "페이지 번호 (0부터 시작)", example = "0") @RequestParam(defaultValue = "0")
|
||||||
|
int page
|
||||||
|
) {
|
||||||
|
InferenceResultDto.SearchReq searchReq = new InferenceResultDto.SearchReq(statCode, title, page, 20, null);
|
||||||
|
Page<InferenceResultDto.Basic> zoos = inferenceResultService.getInferenceResultList(searchReq);
|
||||||
|
return ApiResponseDto.ok(zoos);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,80 @@
|
|||||||
|
package com.kamco.cd.kamcoback.inference.dto;
|
||||||
|
|
||||||
|
import com.kamco.cd.kamcoback.common.utils.interfaces.JsonFormatDttm;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import java.time.ZonedDateTime;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.Setter;
|
||||||
|
import org.springframework.data.domain.PageRequest;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.data.domain.Sort;
|
||||||
|
|
||||||
|
public class InferenceResultDto {
|
||||||
|
|
||||||
|
@Schema(name = "InferenceResultBasic", description = "분석결과 기본 정보")
|
||||||
|
@Getter
|
||||||
|
public static class Basic {
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
private String dataName;
|
||||||
|
private Long mapSheepNum;
|
||||||
|
private Long detectingCnt;
|
||||||
|
@JsonFormatDttm
|
||||||
|
private ZonedDateTime analStrtDttm;
|
||||||
|
@JsonFormatDttm
|
||||||
|
private ZonedDateTime analEndDttm;
|
||||||
|
private Long analSec;
|
||||||
|
private String analState;
|
||||||
|
|
||||||
|
public Basic(
|
||||||
|
Long id,
|
||||||
|
String dataName,
|
||||||
|
Long mapSheepNum,
|
||||||
|
Long detectingCnt,
|
||||||
|
ZonedDateTime analStrtDttm,
|
||||||
|
ZonedDateTime analEndDttm,
|
||||||
|
Long analSec,
|
||||||
|
String analState
|
||||||
|
) {
|
||||||
|
this.id = id;
|
||||||
|
this.dataName = dataName;
|
||||||
|
this.mapSheepNum = mapSheepNum;
|
||||||
|
this.detectingCnt = detectingCnt;
|
||||||
|
this.analStrtDttm = analStrtDttm;
|
||||||
|
this.analEndDttm = analEndDttm;
|
||||||
|
this.analSec = analSec;
|
||||||
|
this.analState = analState;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Schema(name = "InferenceResultSearchReq", description = "분석결과 목록 요청 정보")
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public static class SearchReq {
|
||||||
|
|
||||||
|
// 검색 조건
|
||||||
|
private String statCode;
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
// 페이징 파라미터
|
||||||
|
private int page = 0;
|
||||||
|
private int size = 20;
|
||||||
|
private String sort;
|
||||||
|
|
||||||
|
public Pageable toPageable() {
|
||||||
|
if (sort != null && !sort.isEmpty()) {
|
||||||
|
String[] sortParams = sort.split(",");
|
||||||
|
String property = sortParams[0];
|
||||||
|
Sort.Direction direction =
|
||||||
|
sortParams.length > 1 ? Sort.Direction.fromString(sortParams[1]) : Sort.Direction.ASC;
|
||||||
|
return PageRequest.of(page, size, Sort.by(direction, property));
|
||||||
|
}
|
||||||
|
return PageRequest.of(page, size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,10 @@
|
|||||||
package com.kamco.cd.kamcoback.inference.service;
|
package com.kamco.cd.kamcoback.inference.service;
|
||||||
|
|
||||||
|
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto;
|
||||||
|
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.Basic;
|
||||||
import com.kamco.cd.kamcoback.postgres.core.InferenceResultCoreService;
|
import com.kamco.cd.kamcoback.postgres.core.InferenceResultCoreService;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
@@ -12,6 +15,12 @@ public class InferenceResultService {
|
|||||||
|
|
||||||
private final InferenceResultCoreService inferenceResultCoreService;
|
private final InferenceResultCoreService inferenceResultCoreService;
|
||||||
|
|
||||||
|
public Page<Basic> getInferenceResultList(InferenceResultDto.SearchReq searchReq) {
|
||||||
|
return inferenceResultCoreService.getInferenceResultList(searchReq);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
package com.kamco.cd.kamcoback.postgres.core;
|
package com.kamco.cd.kamcoback.postgres.core;
|
||||||
|
|
||||||
import com.kamco.cd.kamcoback.common.service.BaseCoreService;
|
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto;
|
||||||
|
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.Basic;
|
||||||
|
import com.kamco.cd.kamcoback.postgres.entity.MapSheetAnalDataEntity;
|
||||||
import com.kamco.cd.kamcoback.postgres.repository.Inference.InferenceResultRepository;
|
import com.kamco.cd.kamcoback.postgres.repository.Inference.InferenceResultRepository;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
@@ -17,4 +20,25 @@ public class InferenceResultCoreService {
|
|||||||
|
|
||||||
private final InferenceResultRepository inferenceResultRepository;
|
private final InferenceResultRepository inferenceResultRepository;
|
||||||
|
|
||||||
|
public Page<Basic> getInferenceResultList(InferenceResultDto.SearchReq searchReq) {
|
||||||
|
Page<MapSheetAnalDataEntity> list = inferenceResultRepository.getInferenceResultList(searchReq);
|
||||||
|
List<Basic> result =
|
||||||
|
list.getContent().stream()
|
||||||
|
.map(infList ->toDto(infList))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
return new PageImpl<>(result, list.getPageable(), list.getTotalElements());
|
||||||
|
}
|
||||||
|
|
||||||
|
private Basic toDto(MapSheetAnalDataEntity entity) {
|
||||||
|
return new Basic(
|
||||||
|
entity.getId(),
|
||||||
|
entity.getDataName(),
|
||||||
|
entity.getMapSheepNum(),
|
||||||
|
entity.getDetectingCnt(),
|
||||||
|
entity.getAnalStrtDttm(),
|
||||||
|
entity.getAnalEndDttm(),
|
||||||
|
entity.getAnalSec(),
|
||||||
|
entity.getAnalState()
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import jakarta.persistence.Table;
|
|||||||
import jakarta.validation.constraints.Size;
|
import jakarta.validation.constraints.Size;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.time.LocalTime;
|
import java.time.LocalTime;
|
||||||
|
import java.time.ZonedDateTime;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
@@ -51,14 +52,14 @@ public class MapSheetAnalDataEntity {
|
|||||||
|
|
||||||
@ColumnDefault("now()")
|
@ColumnDefault("now()")
|
||||||
@Column(name = "created_dttm")
|
@Column(name = "created_dttm")
|
||||||
private Instant createdDttm;
|
private ZonedDateTime createdDttm;
|
||||||
|
|
||||||
@Column(name = "created_uid")
|
@Column(name = "created_uid")
|
||||||
private Long createdUid;
|
private Long createdUid;
|
||||||
|
|
||||||
@ColumnDefault("now()")
|
@ColumnDefault("now()")
|
||||||
@Column(name = "updated_dttm")
|
@Column(name = "updated_dttm")
|
||||||
private Instant updatedDttm;
|
private ZonedDateTime updatedDttm;
|
||||||
|
|
||||||
@Column(name = "updated_uid")
|
@Column(name = "updated_uid")
|
||||||
private Long updatedUid;
|
private Long updatedUid;
|
||||||
@@ -79,13 +80,13 @@ public class MapSheetAnalDataEntity {
|
|||||||
|
|
||||||
@ColumnDefault("now()")
|
@ColumnDefault("now()")
|
||||||
@Column(name = "data_state_dttm")
|
@Column(name = "data_state_dttm")
|
||||||
private Instant dataStateDttm;
|
private ZonedDateTime dataStateDttm;
|
||||||
|
|
||||||
@Column(name = "anal_strt_dttm")
|
@Column(name = "anal_strt_dttm")
|
||||||
private Instant analStrtDttm;
|
private ZonedDateTime analStrtDttm;
|
||||||
|
|
||||||
@Column(name = "anal_end_dttm")
|
@Column(name = "anal_end_dttm")
|
||||||
private LocalTime analEndDttm;
|
private ZonedDateTime analEndDttm;
|
||||||
|
|
||||||
@Column(name = "anal_sec")
|
@Column(name = "anal_sec")
|
||||||
private Long analSec;
|
private Long analSec;
|
||||||
@@ -100,4 +101,7 @@ public class MapSheetAnalDataEntity {
|
|||||||
@Column(name = "map_sheep_num")
|
@Column(name = "map_sheep_num")
|
||||||
private Long mapSheepNum;
|
private Long mapSheepNum;
|
||||||
|
|
||||||
|
@Column(name = "detecting_cnt")
|
||||||
|
private Long detectingCnt;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
package com.kamco.cd.kamcoback.postgres.repository.Inference;
|
package com.kamco.cd.kamcoback.postgres.repository.Inference;
|
||||||
|
|
||||||
public interface InferenceResultRepositoryCustom {
|
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto;
|
||||||
|
import com.kamco.cd.kamcoback.postgres.entity.MapSheetAnalDataEntity;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
|
||||||
|
public interface InferenceResultRepositoryCustom {
|
||||||
|
Page<MapSheetAnalDataEntity> getInferenceResultList(InferenceResultDto.SearchReq searchReq);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,16 @@
|
|||||||
package com.kamco.cd.kamcoback.postgres.repository.Inference;
|
package com.kamco.cd.kamcoback.postgres.repository.Inference;
|
||||||
|
|
||||||
|
|
||||||
import com.kamco.cd.kamcoback.postgres.entity.QMapSheetLearnDataEntity;
|
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto;
|
||||||
|
import com.kamco.cd.kamcoback.postgres.entity.MapSheetAnalDataEntity;
|
||||||
|
import com.kamco.cd.kamcoback.postgres.entity.QMapSheetAnalDataEntity;
|
||||||
|
import com.querydsl.jpa.impl.JPAQuery;
|
||||||
import com.querydsl.jpa.impl.JPAQueryFactory;
|
import com.querydsl.jpa.impl.JPAQueryFactory;
|
||||||
|
import java.util.List;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.data.domain.PageImpl;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
@@ -11,7 +18,24 @@ import org.springframework.stereotype.Repository;
|
|||||||
public class InferenceResultRepositoryImpl implements InferenceResultRepositoryCustom {
|
public class InferenceResultRepositoryImpl implements InferenceResultRepositoryCustom {
|
||||||
|
|
||||||
private final JPAQueryFactory queryFactory;
|
private final JPAQueryFactory queryFactory;
|
||||||
private final QMapSheetLearnDataEntity qSheetLearnData = QMapSheetLearnDataEntity.mapSheetLearnDataEntity;
|
private final QMapSheetAnalDataEntity mapSheetAnalData = QMapSheetAnalDataEntity.mapSheetAnalDataEntity;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Page<MapSheetAnalDataEntity> getInferenceResultList(InferenceResultDto.SearchReq searchReq) {
|
||||||
|
Pageable pageable = searchReq.toPageable();
|
||||||
|
JPAQuery<MapSheetAnalDataEntity> query =
|
||||||
|
queryFactory.selectFrom(mapSheetAnalData)
|
||||||
|
;
|
||||||
|
|
||||||
|
long total = query.fetchCount();
|
||||||
|
|
||||||
|
List<MapSheetAnalDataEntity> content =
|
||||||
|
query
|
||||||
|
.offset(pageable.getOffset())
|
||||||
|
.limit(pageable.getPageSize())
|
||||||
|
.orderBy(mapSheetAnalData.createdDttm.desc())
|
||||||
|
.fetch();
|
||||||
|
return new PageImpl<>(content, pageable, total);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user