flag calc
This commit is contained in:
parent
7176a49814
commit
4e6ab1a862
1 changed files with 29 additions and 46 deletions
|
|
@ -1,6 +1,7 @@
|
|||
package ru.nbch.credit_tracker.service.task.impl;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||
|
|
@ -20,7 +21,6 @@ import java.util.concurrent.ThreadPoolExecutor;
|
|||
import java.util.concurrent.TimeUnit;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||
import ru.nbch.credit_tracker.entities.app.PhoneFidMap;
|
||||
import ru.nbch.credit_tracker.mapper.signal.PhoneFidMapMapper;
|
||||
import ru.nbch.credit_tracker.model.SubjectProfile;
|
||||
import ru.nbch.credit_tracker.model.impl.SubjectPayload;
|
||||
|
|
@ -95,7 +95,9 @@ public class FlagsEnricher implements Runnable {
|
|||
Map<Integer, Integer> flag90ByPastDueArrear = flagsService.findFlag90ByPastDueArrear(fids, yearAgo);
|
||||
Map<Integer, Integer> flag90ByRuPaymt = flagsService.findFlag90ByRuPaymt(fids, yearAgo);
|
||||
|
||||
List<PhoneFidMap> phoneFidMaps = subjects.stream().map(subject -> {
|
||||
String json;
|
||||
try {
|
||||
json = mapper.writeValueAsString(subjects.stream().map(subject -> {
|
||||
Integer debt5000 = null;
|
||||
Integer flagDays90 = null;
|
||||
LocalDateTime calculatedAt = null;
|
||||
|
|
@ -108,39 +110,20 @@ public class FlagsEnricher implements Runnable {
|
|||
calculatedAt = LocalDateTime.now();
|
||||
}
|
||||
|
||||
return PhoneFidMap.builder()
|
||||
.phone(subject.getPhone())
|
||||
.subjectId(subject.getIdentifier())
|
||||
.packageId(subjectPayload.getPackageId())
|
||||
.fid(subject.getFid())
|
||||
.flagDebt5000(debt5000)
|
||||
.flag90days(flagDays90)
|
||||
.calculatedAt(calculatedAt)
|
||||
.build();
|
||||
}).toList();
|
||||
|
||||
List<PhoneFidMap> nullObjs = phoneFidMaps.stream().filter(Objects::isNull).toList();
|
||||
log.debug("null objs: {}", nullObjs.size());
|
||||
if (!nullObjs.isEmpty()) {
|
||||
int i = 0;
|
||||
i++;
|
||||
}
|
||||
String json = null;
|
||||
try {
|
||||
json = mapper.writeValueAsString(
|
||||
phoneFidMaps.stream()
|
||||
.filter(Objects::nonNull)
|
||||
.map(p -> new HashMap() {{
|
||||
put("subject_id", p.getSubjectId());
|
||||
put("fid", p.getFid());
|
||||
put("phone", p.getPhone());
|
||||
put("package_id", p.getPackageId());
|
||||
put("flag_debt5000", p.getFlagDebt5000());
|
||||
put("flag_90_12", p.getFlag90days());
|
||||
put("calculated_at", p.getCalculatedAt());
|
||||
}}
|
||||
).toList());
|
||||
} catch (Exception e) {
|
||||
Integer finalDebt500 = debt5000;
|
||||
Integer finalFlagDays9 = flagDays90;
|
||||
LocalDateTime finalCalculatedAt = calculatedAt;
|
||||
return new HashMap<String, Object>() {{
|
||||
put("subject_id", subject.getIdentifier());
|
||||
put("fid", subject.getFid());
|
||||
put("phone", subject.getPhone());
|
||||
put("package_id", subjectPayload.getPackageId());
|
||||
put("flag_debt5000", finalDebt500);
|
||||
put("flag_90_12", finalFlagDays9);
|
||||
put("calculated_at", finalCalculatedAt);
|
||||
}};
|
||||
}).toList());
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
phoneFidMapMapper.registerJson(json);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue