국유인 실태조사 적합여부 업데이트 로직 수정, 라벨링 건수 조건 수정
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.kamco.cd.kamcoback.scheduler.service;
|
||||
|
||||
import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectContDto.StbltResult;
|
||||
import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectMastDto.LearnKeyDto;
|
||||
import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectMastDto.RlbDtctDto;
|
||||
import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectMastDto.RlbDtctMastDto;
|
||||
@@ -10,6 +11,8 @@ import java.time.LocalDate;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
@@ -37,7 +40,7 @@ public class GukYuinApiStbltJobService {
|
||||
}
|
||||
|
||||
/** 국유인 연동 후, 실태조사 적합여부 확인하여 update */
|
||||
@Scheduled(cron = "0 0 3 * * *") // 0 0 3 * * *
|
||||
@Scheduled(cron = "0 0 3 * * *")
|
||||
public void findGukYuinEligibleForSurvey() {
|
||||
if (isLocalProfile()) {
|
||||
return;
|
||||
@@ -68,6 +71,45 @@ public class GukYuinApiStbltJobService {
|
||||
gukYuinStbltJobCoreService.updateGukYuinEligibleForSurvey(resultUid, stbltDto);
|
||||
}
|
||||
|
||||
Map<String, StbltResult> resultMap =
|
||||
result.getResult().stream()
|
||||
.collect(Collectors.groupingBy(RlbDtctMastDto::getChnDtctObjtId))
|
||||
.entrySet()
|
||||
.stream()
|
||||
.collect(
|
||||
Collectors.toMap(
|
||||
Map.Entry::getKey,
|
||||
e -> {
|
||||
List<RlbDtctMastDto> pnuList = e.getValue();
|
||||
|
||||
boolean hasY = pnuList.stream().anyMatch(v -> "Y".equals(v.getStbltYn()));
|
||||
|
||||
String fitYn = hasY ? "Y" : "N";
|
||||
|
||||
RlbDtctMastDto selected =
|
||||
hasY
|
||||
? pnuList.stream()
|
||||
.filter(v -> "Y".equals(v.getStbltYn()))
|
||||
.findFirst()
|
||||
.orElse(null)
|
||||
: pnuList.stream()
|
||||
.filter(v -> "N".equals(v.getStbltYn()))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
|
||||
if (selected == null) {
|
||||
return null; // 방어 코드
|
||||
}
|
||||
|
||||
return new StbltResult(
|
||||
fitYn, selected.getIncyCd(), selected.getIncyRsnCont());
|
||||
}));
|
||||
|
||||
resultMap.forEach(
|
||||
(resultUid, StbltResult) -> {
|
||||
gukYuinStbltJobCoreService.updateGukYuinObjectStbltYn(resultUid, StbltResult);
|
||||
});
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("[GUKYUIN] failed uid={}", dto.getChnDtctMstId(), e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user