추론 수정
This commit is contained in:
@@ -286,58 +286,72 @@ public class InferenceResultService {
|
||||
throw new CustomApiException("NOT_FOUND_COMPARE_YEAR", HttpStatus.NOT_FOUND);
|
||||
}
|
||||
|
||||
log.info("targetMngList size = {}", targetMngList.size());
|
||||
log.info("compareMngList size = {}", compareMngList.size());
|
||||
log.info("Difference in count = {}", targetMngList.size() - compareMngList.size());
|
||||
|
||||
// 로그용 원본 카운트 (fallback 추가 전)
|
||||
// 로그용 원본 카운트 (이전도엽 추가 전)
|
||||
int targetTotal = targetMngList.size();
|
||||
int compareTotalBeforeFallback = compareMngList.size();
|
||||
|
||||
// target - compare 구해서 이전년도로 compare 보완
|
||||
List<String> compareNums0 =
|
||||
compareMngList.stream().map(MngListDto::getMapSheetNum).filter(Objects::nonNull).toList();
|
||||
// 기준연도 기준 비교연도 구해서 이전년도로 compare 보완 하기위해서 도엽번호만 정리
|
||||
Set<String> compareSet0 =
|
||||
compareMngList.stream()
|
||||
.map(MngListDto::getMapSheetNum)
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
// 기준연도에 없는 도엽을 비교년도 이전 도엽에서 찾아서 추가하기
|
||||
// 기준연도 기준 비교연도에 도협번호가 없으면 이전연도 조회해서 compare 보완, 없는거 담기
|
||||
List<String> targetOnlyMapSheetNums =
|
||||
targetMngList.stream()
|
||||
.map(MngListDto::getMapSheetNum)
|
||||
.filter(Objects::nonNull)
|
||||
.filter(num -> !compareNums0.contains(num))
|
||||
.filter(num -> !compareSet0.contains(num))
|
||||
.toList();
|
||||
|
||||
// 이전년도(fallback) 추가
|
||||
log.info("targetOnlyMapSheetNums in count = {}", targetOnlyMapSheetNums.size());
|
||||
|
||||
// 이전연도 초회 추가
|
||||
compareMngList.addAll(
|
||||
mapSheetMngCoreService.findFallbackCompareYearByMapSheets(
|
||||
req.getCompareYyyy(), targetOnlyMapSheetNums));
|
||||
|
||||
log.info("fallback compare size= {}", compareMngList.size());
|
||||
|
||||
// 이전연도 추가 후 compare 총 개수
|
||||
int compareTotalAfterFallback = compareMngList.size();
|
||||
|
||||
// 교집합 도엽번호(mapSheetNums) 교집합 생성
|
||||
List<String> compareNums1 =
|
||||
compareMngList.stream().map(MngListDto::getMapSheetNum).filter(Objects::nonNull).toList();
|
||||
// 이전연도 추가한 기준연도 값 도협번호만 담기
|
||||
Set<String> compareSet1 =
|
||||
compareMngList.stream()
|
||||
.map(MngListDto::getMapSheetNum)
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
// 기준연도 교집합
|
||||
// 기준연도 기준으로 비교연도에 있는것만 담기 (도협번호) 결국 비교년도와 개수가 같아짐
|
||||
List<String> mapSheetNums =
|
||||
targetMngList.stream()
|
||||
.map(MngListDto::getMapSheetNum)
|
||||
.filter(Objects::nonNull)
|
||||
.filter(compareNums1::contains)
|
||||
.filter(compareSet1::contains)
|
||||
.toList();
|
||||
|
||||
int intersection = mapSheetNums.size();
|
||||
|
||||
// 서로 같은 것만 남기기: compare 모두 교집합
|
||||
Set<String> intersectionSet = new HashSet<>(mapSheetNums);
|
||||
|
||||
// 비교연도 같은거 담기(dto list)
|
||||
compareMngList =
|
||||
compareMngList.stream()
|
||||
.filter(c -> c.getMapSheetNum() != null)
|
||||
.filter(c -> mapSheetNums.contains(c.getMapSheetNum()))
|
||||
.filter(c -> intersectionSet.contains(c.getMapSheetNum()))
|
||||
.toList();
|
||||
|
||||
// target도 교집합으로 줄이기
|
||||
// 기준연도 같은거 담기(dto list)
|
||||
List<MngListDto> filteredTargetMngList =
|
||||
targetMngList.stream()
|
||||
.filter(t -> t.getMapSheetNum() != null)
|
||||
.filter(t -> mapSheetNums.contains(t.getMapSheetNum()))
|
||||
.filter(t -> intersectionSet.contains(t.getMapSheetNum()))
|
||||
.toList();
|
||||
|
||||
// 로그
|
||||
|
||||
Reference in New Issue
Block a user