추론관리 > 분석결과 목록 조회 추가
공통코드 repository 패키지 이동
This commit is contained in:
@@ -10,7 +10,6 @@ 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 java.util.List;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
@@ -43,7 +42,7 @@ public class InferenceResultApiController {
|
||||
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content)
|
||||
})
|
||||
@GetMapping("/list")
|
||||
public ApiResponseDto<Page<InferenceResultDto.Basic>> getInferenceResultList(
|
||||
public ApiResponseDto<Page<InferenceResultDto.AnalResList>> getInferenceResultList(
|
||||
@Parameter(description = "분석상태", example = "0000")
|
||||
@RequestParam(required = false)
|
||||
String statCode,
|
||||
@@ -53,7 +52,7 @@ public class InferenceResultApiController {
|
||||
int page
|
||||
) {
|
||||
InferenceResultDto.SearchReq searchReq = new InferenceResultDto.SearchReq(statCode, title, page, 20, null);
|
||||
Page<InferenceResultDto.Basic> zoos = inferenceResultService.getInferenceResultList(searchReq);
|
||||
return ApiResponseDto.ok(zoos);
|
||||
Page<InferenceResultDto.AnalResList> analResList = inferenceResultService.getInferenceResultList(searchReq);
|
||||
return ApiResponseDto.ok(analResList);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,6 +49,47 @@ public class InferenceResultDto {
|
||||
}
|
||||
}
|
||||
|
||||
@Schema(name = "AnalysisResultList", description = "분석결과 목록")
|
||||
@Getter
|
||||
public static class AnalResList {
|
||||
private Long id;
|
||||
private String analTitle;
|
||||
private String analMapSheet;
|
||||
private Long detectingCnt;
|
||||
@JsonFormatDttm
|
||||
private ZonedDateTime analStrtDttm;
|
||||
@JsonFormatDttm
|
||||
private ZonedDateTime analEndDttm;
|
||||
private Integer analSs;
|
||||
private String analState;
|
||||
private String analStateNm;
|
||||
private String gukyuinUsed;
|
||||
|
||||
public AnalResList(
|
||||
Long id,
|
||||
String analTitle,
|
||||
String analMapSheet,
|
||||
Long detectingCnt,
|
||||
ZonedDateTime analStrtDttm,
|
||||
ZonedDateTime analEndDttm,
|
||||
Integer analSs,
|
||||
String analState,
|
||||
String analStateNm,
|
||||
String gukyuinUsed
|
||||
) {
|
||||
this.id = id;
|
||||
this.analTitle = analTitle;
|
||||
this.analMapSheet = analMapSheet;
|
||||
this.detectingCnt = detectingCnt;
|
||||
this.analStrtDttm = analStrtDttm;
|
||||
this.analEndDttm = analEndDttm;
|
||||
this.analSs = analSs;
|
||||
this.analState = analState;
|
||||
this.analStateNm = analStateNm;
|
||||
this.gukyuinUsed = gukyuinUsed;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Schema(name = "InferenceResultSearchReq", description = "분석결과 목록 요청 정보")
|
||||
@Getter
|
||||
|
||||
@@ -15,7 +15,12 @@ public class InferenceResultService {
|
||||
|
||||
private final InferenceResultCoreService inferenceResultCoreService;
|
||||
|
||||
public Page<Basic> getInferenceResultList(InferenceResultDto.SearchReq searchReq) {
|
||||
/**
|
||||
* 추론관리 > 분석결과 목록 조회
|
||||
* @param searchReq
|
||||
* @return
|
||||
*/
|
||||
public Page<InferenceResultDto.AnalResList> getInferenceResultList(InferenceResultDto.SearchReq searchReq) {
|
||||
return inferenceResultCoreService.getInferenceResultList(searchReq);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,10 +4,11 @@ import com.kamco.cd.kamcoback.code.dto.CommonCodeDto;
|
||||
import com.kamco.cd.kamcoback.code.dto.CommonCodeDto.Basic;
|
||||
import com.kamco.cd.kamcoback.common.service.BaseCoreService;
|
||||
import com.kamco.cd.kamcoback.postgres.entity.CommonCodeEntity;
|
||||
import com.kamco.cd.kamcoback.postgres.repository.CommonCodeRepository;
|
||||
import com.kamco.cd.kamcoback.postgres.repository.code.CommonCodeRepository;
|
||||
import com.kamco.cd.kamcoback.zoo.dto.AnimalDto.SearchReq;
|
||||
import jakarta.persistence.EntityNotFoundException;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -72,6 +73,16 @@ public class CommonCodeCoreService
|
||||
return commonCodeRepository.findByCode(code).stream().map(CommonCodeEntity::toDto).toList();
|
||||
}
|
||||
|
||||
/**
|
||||
* 공통코드 이름 조회
|
||||
* @param parentCodeCd
|
||||
* @param childCodeCd
|
||||
* @return
|
||||
*/
|
||||
public Optional<String> getCode(String parentCodeCd, String childCodeCd) {
|
||||
return commonCodeRepository.getCode(parentCodeCd, childCodeCd);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(Long id) {
|
||||
CommonCodeEntity entity =
|
||||
|
||||
@@ -1,44 +1,23 @@
|
||||
package com.kamco.cd.kamcoback.postgres.core;
|
||||
|
||||
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 java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Transactional(readOnly = true)
|
||||
public class InferenceResultCoreService {
|
||||
|
||||
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()
|
||||
);
|
||||
/**
|
||||
* 추론관리 > 분석결과 목록 조회
|
||||
* @param searchReq
|
||||
* @return
|
||||
*/
|
||||
public Page<InferenceResultDto.AnalResList> getInferenceResultList(InferenceResultDto.SearchReq searchReq) {
|
||||
return inferenceResultRepository.getInferenceResultList(searchReq);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,9 +2,12 @@ package com.kamco.cd.kamcoback.postgres.entity;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.FetchType;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.SequenceGenerator;
|
||||
import jakarta.persistence.Table;
|
||||
import jakarta.validation.constraints.Size;
|
||||
@@ -84,4 +87,7 @@ public class MapSheetAnalEntity {
|
||||
@Column(name = "anal_title")
|
||||
private String analTitle;
|
||||
|
||||
@Column(name = "detecting_cnt")
|
||||
private Long detectingCnt;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.kamco.cd.kamcoback.postgres.repository.Inference;
|
||||
|
||||
import com.kamco.cd.kamcoback.postgres.entity.MapSheetLearnDataEntity;
|
||||
import com.kamco.cd.kamcoback.postgres.entity.MapSheetAnalEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface InferenceResultRepository extends JpaRepository<MapSheetLearnDataEntity, Long>, InferenceResultRepositoryCustom {
|
||||
public interface InferenceResultRepository extends JpaRepository<MapSheetAnalEntity, Long>, InferenceResultRepositoryCustom {
|
||||
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.kamco.cd.kamcoback.postgres.repository.Inference;
|
||||
|
||||
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto;
|
||||
import com.kamco.cd.kamcoback.postgres.entity.MapSheetAnalDataEntity;
|
||||
import com.kamco.cd.kamcoback.postgres.entity.MapSheetAnalEntity;
|
||||
import org.springframework.data.domain.Page;
|
||||
|
||||
public interface InferenceResultRepositoryCustom {
|
||||
Page<MapSheetAnalDataEntity> getInferenceResultList(InferenceResultDto.SearchReq searchReq);
|
||||
Page<InferenceResultDto.AnalResList> getInferenceResultList(InferenceResultDto.SearchReq searchReq);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
package com.kamco.cd.kamcoback.postgres.repository.Inference;
|
||||
|
||||
|
||||
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.kamco.cd.kamcoback.postgres.entity.QMapSheetAnalEntity;
|
||||
import com.querydsl.core.types.Projections;
|
||||
import com.querydsl.core.types.dsl.Expressions;
|
||||
import com.querydsl.jpa.impl.JPAQueryFactory;
|
||||
import java.util.List;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -12,30 +11,63 @@ import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageImpl;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import com.querydsl.core.BooleanBuilder;
|
||||
|
||||
@Repository
|
||||
@RequiredArgsConstructor
|
||||
public class InferenceResultRepositoryImpl implements InferenceResultRepositoryCustom {
|
||||
|
||||
private final JPAQueryFactory queryFactory;
|
||||
private final QMapSheetAnalDataEntity mapSheetAnalData = QMapSheetAnalDataEntity.mapSheetAnalDataEntity;
|
||||
private final QMapSheetAnalEntity mapSheetAnal = QMapSheetAnalEntity.mapSheetAnalEntity;
|
||||
|
||||
|
||||
@Override
|
||||
public Page<MapSheetAnalDataEntity> getInferenceResultList(InferenceResultDto.SearchReq searchReq) {
|
||||
public Page<InferenceResultDto.AnalResList> getInferenceResultList(InferenceResultDto.SearchReq searchReq) {
|
||||
Pageable pageable = searchReq.toPageable();
|
||||
JPAQuery<MapSheetAnalDataEntity> query =
|
||||
queryFactory.selectFrom(mapSheetAnalData)
|
||||
;
|
||||
|
||||
long total = query.fetchCount();
|
||||
// "0000" 전체조회
|
||||
BooleanBuilder builder = new BooleanBuilder();
|
||||
if (searchReq.getStatCode() != null && !"0000".equals(searchReq.getStatCode())) {
|
||||
builder.and(mapSheetAnal.analState.eq(searchReq.getStatCode()));
|
||||
}
|
||||
|
||||
List<MapSheetAnalDataEntity> content =
|
||||
query
|
||||
// 제목
|
||||
if (searchReq.getTitle() != null) {
|
||||
builder.and(mapSheetAnal.analTitle.like("%" + searchReq.getTitle() + "%"));
|
||||
}
|
||||
|
||||
List<InferenceResultDto.AnalResList> content = queryFactory
|
||||
.select(Projections.constructor(InferenceResultDto.AnalResList.class,
|
||||
mapSheetAnal.id,
|
||||
mapSheetAnal.analTitle,
|
||||
mapSheetAnal.analMapSheet,
|
||||
mapSheetAnal.detectingCnt,
|
||||
mapSheetAnal.analStrtDttm,
|
||||
mapSheetAnal.analEndDttm,
|
||||
mapSheetAnal.analSs,
|
||||
mapSheetAnal.analState,
|
||||
Expressions.stringTemplate("fn_code_name({0}, {1})", "0002", mapSheetAnal.analState),
|
||||
mapSheetAnal.gukyuinUsed
|
||||
))
|
||||
.from(mapSheetAnal)
|
||||
.where(
|
||||
builder
|
||||
)
|
||||
.offset(pageable.getOffset())
|
||||
.limit(pageable.getPageSize())
|
||||
.orderBy(mapSheetAnalData.createdDttm.desc())
|
||||
.orderBy(mapSheetAnal.createdDttm.desc())
|
||||
.fetch();
|
||||
|
||||
long total = queryFactory
|
||||
.select(mapSheetAnal.id)
|
||||
.from(mapSheetAnal)
|
||||
.where(
|
||||
builder
|
||||
)
|
||||
.fetchCount();
|
||||
|
||||
return new PageImpl<>(content, pageable, total);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.kamco.cd.kamcoback.postgres.repository;
|
||||
package com.kamco.cd.kamcoback.postgres.repository.code;
|
||||
|
||||
import com.kamco.cd.kamcoback.postgres.entity.CommonCodeEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.kamco.cd.kamcoback.postgres.repository;
|
||||
package com.kamco.cd.kamcoback.postgres.repository.code;
|
||||
|
||||
import com.kamco.cd.kamcoback.code.dto.CommonCodeDto;
|
||||
import com.kamco.cd.kamcoback.postgres.entity.CommonCodeEntity;
|
||||
@@ -13,4 +13,6 @@ public interface CommonCodeRepositoryCustom {
|
||||
List<CommonCodeEntity> findByAll();
|
||||
|
||||
void updateOrder(CommonCodeDto.OrderReq req);
|
||||
|
||||
Optional<String> getCode(String parentCodeCd, String childCodeCd);
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.kamco.cd.kamcoback.postgres.repository;
|
||||
package com.kamco.cd.kamcoback.postgres.repository.code;
|
||||
|
||||
import static com.kamco.cd.kamcoback.postgres.entity.QCommonCodeEntity.commonCodeEntity;
|
||||
|
||||
@@ -83,6 +83,22 @@ public class CommonCodeRepositoryImpl extends QuerydslRepositorySupport
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<String> getCode(String parentCodeCd, String childCodeCd) {
|
||||
QCommonCodeEntity parent = QCommonCodeEntity.commonCodeEntity;
|
||||
QCommonCodeEntity child = new QCommonCodeEntity("child");
|
||||
|
||||
String result = queryFactory
|
||||
.select(child.name)
|
||||
.from(child)
|
||||
.join(child.parent, parent)
|
||||
.where(parent.code.eq(parentCodeCd)
|
||||
.and(child.code.eq(childCodeCd)))
|
||||
.fetchFirst(); // 단일 결과만
|
||||
|
||||
return Optional.ofNullable(result);
|
||||
}
|
||||
|
||||
private List<CommonCodeEntity> findAllByIds(Set<Long> ids) {
|
||||
return queryFactory
|
||||
.selectFrom(commonCodeEntity)
|
||||
Reference in New Issue
Block a user