Skip to content

Commit

Permalink
fix : 사회서비스 유형을 가진 정책들 중에서 가장 임박한 정책을 구하는 로직에서 신청종료일이 Null일 때 오류 해결
Browse files Browse the repository at this point in the history
LHS-11 committed Feb 5, 2024
1 parent 14899db commit 3e32701
Showing 1 changed file with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -47,7 +47,7 @@ public Map<SupportPolicyType, Policy> recommendPolicy(User user) {

Policy mostImminentEndDateSocialServicePolicy = recommendPolicy.stream()
.filter(p -> p.getSupportPolicyTypes().contains(SupportPolicyType.SOCIAL_SERVICE))
.filter(p -> p.getApplyEndDate().isAfter(now))
.filter(p -> p.getApplyEndDate() != null && p.getApplyEndDate().isAfter(now))
.min(Comparator.comparing(p -> ChronoUnit.DAYS.between(now, p.getApplyEndDate())))
.orElse(null);

@@ -64,7 +64,6 @@ public Map<SupportPolicyType, Policy> recommendPolicy(User user) {
if (mostImminentEndDateSocialServicePolicy != null) {
result.put(SupportPolicyType.SOCIAL_SERVICE, mostImminentEndDateSocialServicePolicy);
}

if (mostImminentEndDateSocialServicePolicy == null) {
mostImminentEndDateSocialServicePolicy = recommendPolicy.stream()
.filter(p -> p.getSupportPolicyTypes().contains(SupportPolicyType.SOCIAL_SERVICE))
@@ -73,6 +72,7 @@ public Map<SupportPolicyType, Policy> recommendPolicy(User user) {
result.put(SupportPolicyType.SOCIAL_SERVICE, mostImminentEndDateSocialServicePolicy);
}


return result;
}

@@ -147,15 +147,21 @@ private static boolean isJobDenial(User user, Policy policy) {
Set<JobType> policyJobTypes = policy.getJobTypes();
Set<JobType> userJobTypes = user.getJobs();
userJobTypes.retainAll(policyJobTypes);
return userJobTypes.isEmpty() && !(policy.getJobTypes().contains(JobType.UNLIMITED));
return userJobTypes.isEmpty() && (!(policy.getJobTypes().contains(JobType.UNLIMITED) || policy.getJobTypes() == null));
}

private static boolean isEducationDenial(User user, Policy policy) {
return !policy.getEducationTypes().contains(user.getEducationType()) && !policy.getEducationTypes().contains(EducationType.UNLIMITED);
}

/**
* 1. 정책의 지역코드가 중앙부처가 아니어야함
* 1-1. 정책의 지역코드와 유저의 지역코드가 틀려야함
* 1-2. 정책의
*/
private static boolean isLocalDenial(User user, Policy policy) {
return user.getAddress().getAreaCode() != policy.getAreaCode()
|| (policy.getCityCode() != null && policy.getCityCode() != user.getAddress().getCityCode());
return !policy.getAreaCode().equals(AreaCode.CENTRAL_GOVERNMENT)
&& (user.getAddress().getAreaCode() != policy.getAreaCode()
|| (policy.getCityCode() != null && policy.getCityCode() != user.getAddress().getCityCode()));
}
}

0 comments on commit 3e32701

Please sign in to comment.