Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/endre rekkefoelge innsending ap ut #3383

Merged
merged 3 commits into from
Jan 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import reactor.util.function.Tuple2;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Objects;
Expand Down Expand Up @@ -99,13 +100,13 @@ public static PensjonforvalterResponse mergePensjonforvalterResponses(List<Pensj

var status = new HashMap<String, PensjonforvalterResponse.Response>();
responser.forEach(respons -> respons.getStatus()
.forEach(detalj -> {
if (detalj.getResponse().isResponse2xx()) {
status.putIfAbsent(detalj.getMiljo(), detalj.getResponse());
} else {
status.put(detalj.getMiljo(), detalj.getResponse());
}
}));
.forEach(detalj -> {
if (detalj.getResponse().isResponse2xx()) {
status.putIfAbsent(detalj.getMiljo(), detalj.getResponse());
} else {
status.put(detalj.getMiljo(), detalj.getResponse());
}
}));

return PensjonforvalterResponse.builder()
.status(status.entrySet().stream()
Expand All @@ -129,8 +130,9 @@ public Flux<ClientFuture> gjenopprett(RsDollyUtvidetBestilling bestilling, Dolly
.collect(Collectors.toSet()));

var bestillingId = bestilling.getId();
var statusResultat = new ArrayList<String>();

return Flux.from(pensjonforvalterConsumer.getMiljoer())
return Flux.from(Flux.from(pensjonforvalterConsumer.getMiljoer())
.flatMap(tilgjengeligeMiljoer -> {
bestilteMiljoer.set(bestilteMiljoer.get().stream()
.filter(tilgjengeligeMiljoer::contains)
Expand All @@ -156,50 +158,66 @@ public Flux<ClientFuture> gjenopprett(RsDollyUtvidetBestilling bestilling, Dolly
log.warn("Persondata for {} gir tom response fra PDL", dollyPerson.getIdent());
}
})
.map(utvidetPersondata -> Flux.concat(
opprettPersoner(dollyPerson.getIdent(), tilgjengeligeMiljoer, utvidetPersondata.getT1())
.map(response -> PENSJON_FORVALTER + decodeStatus(response, dollyPerson.getIdent())),

lagreSamboer(dollyPerson.getIdent(), tilgjengeligeMiljoer)
.map(response -> SAMBOER_REGISTER + decodeStatus(response, dollyPerson.getIdent())),

lagreInntekt(bestilling1.getPensjonforvalter(), dollyPerson.getIdent(), bestilteMiljoer.get(),
progress.getIsTpsSyncEnv())
.map(response -> POPP_INNTEKTSREGISTER + decodeStatus(response, dollyPerson.getIdent())),

Flux.just(bestilling1)
.filter(bestilling2 -> nonNull(bestilling2.getPensjonforvalter()))
.map(RsDollyUtvidetBestilling::getPensjonforvalter)
.flatMap(pensjon -> Flux.merge(

lagreTpForhold(pensjon, dollyPerson.getIdent(), bestilteMiljoer.get())
.map(response -> TP_FORHOLD + decodeStatus(response, dollyPerson.getIdent())),

lagreAlderspensjon(
pensjon,
utvidetPersondata,
dollyPerson.getIdent(),
bestilteMiljoer.get(),
isOpprettEndre,
bestillingId,
progress.getIsTpsSyncEnv())
.map(response -> PEN_ALDERSPENSJON + decodeStatus(response, dollyPerson.getIdent())),

lagreUforetrygd(
pensjon,
utvidetPersondata.getT2(),
dollyPerson.getIdent(),
bestilteMiljoer.get(),
isOpprettEndre,
bestillingId,
progress.getIsTpsSyncEnv())
.map(response -> PEN_UFORETRYGD + decodeStatus(response, dollyPerson.getIdent())))))))

.flatMap(Flux::from)
.filter(StringUtils::isNotBlank)
.collect(Collectors.joining(SEP));
.flatMap(utvidetPersondata -> Flux.concat(
opprettPersoner(dollyPerson.getIdent(), tilgjengeligeMiljoer, utvidetPersondata.getT1())
.map(response -> PENSJON_FORVALTER + decodeStatus(response, dollyPerson.getIdent())),

lagreSamboer(dollyPerson.getIdent(), tilgjengeligeMiljoer)
.map(response -> SAMBOER_REGISTER + decodeStatus(response, dollyPerson.getIdent()))
)
.collectList()
.doOnNext(statusResultat::addAll)
.map(status -> Flux.just(bestilling1)
.filter(bestilling2 -> nonNull(bestilling2.getPensjonforvalter()))
.map(RsDollyUtvidetBestilling::getPensjonforvalter)
.flatMap(pensjon -> Flux.merge(

lagreInntekt(pensjon,
dollyPerson.getIdent(), bestilteMiljoer.get(),
progress.getIsTpsSyncEnv())
.map(response -> POPP_INNTEKTSREGISTER + decodeStatus(response, dollyPerson.getIdent())),

lagreTpForhold(pensjon, dollyPerson.getIdent(), bestilteMiljoer.get())
.map(response -> TP_FORHOLD + decodeStatus(response, dollyPerson.getIdent()))
)
.collectList()
.doOnNext(statusResultat::addAll)

.map(status2 -> Flux.just(pensjon)
.flatMap(pensjon2 -> Flux.merge(

lagreAlderspensjon(
pensjon2,
utvidetPersondata,
dollyPerson.getIdent(),
bestilteMiljoer.get(),
isOpprettEndre,
bestillingId,
progress.getIsTpsSyncEnv())
.map(response -> PEN_ALDERSPENSJON + decodeStatus(response, dollyPerson.getIdent())),

lagreUforetrygd(
pensjon2,
utvidetPersondata.getT2(),
dollyPerson.getIdent(),
bestilteMiljoer.get(),
isOpprettEndre,
bestillingId,
progress.getIsTpsSyncEnv())
.map(response -> PEN_UFORETRYGD + decodeStatus(response, dollyPerson.getIdent()))
)
.collectList()
.doOnNext(statusResultat::addAll)
))))));
})
.map(status -> futurePersist(dollyPerson, progress, status));
.flatMap(Flux::from)
.flatMap(Flux::from)
.flatMap(Flux::fromIterable)
.collectList()
.map(status -> statusResultat.stream()
.filter(StringUtils::isNotBlank)
.collect(Collectors.joining("$")))
.map(status2 -> futurePersist(dollyPerson, progress, status2)));
}

private static Mono<List<PdlPersonBolk.PersonBolk>> getPdlPerson(Flux<PdlPersonBolk.Data> persondata) {
Expand Down Expand Up @@ -455,7 +473,8 @@ private static Flux<PensjonforvalterResponse> getStatus(String miljoe, Integer s
}

@SuppressWarnings("java:S3740")
private void saveAPTransaksjonId(String ident, String miljoe, Long bestillingId, SystemTyper type, AtomicReference vedtak) {
private void saveAPTransaksjonId(String ident, String miljoe, Long bestillingId, SystemTyper
type, AtomicReference vedtak) {

log.info("Lagrer transaksjon for {} i {} ", ident, miljoe);

Expand All @@ -473,10 +492,6 @@ private void saveAPTransaksjonId(String ident, String miljoe, Long bestillingId,
private Flux<PensjonforvalterResponse> lagreInntekt(PensjonData pensjonData, String ident,
Set<String> miljoer, List<String> isTpsSyncEnv) {

if (isNull(pensjonData)) {
return Flux.empty();
}

return Flux.just(pensjonData)
.filter(PensjonData::hasInntekt)
.map(PensjonData::getInntekt)
Expand All @@ -496,7 +511,8 @@ private Flux<PensjonforvalterResponse> lagreInntekt(PensjonData pensjonData, Str
}));
}

private Mono<PensjonforvalterResponse> lagreTpForhold(PensjonData pensjonData, String ident, Set<String> miljoer) {
private Mono<PensjonforvalterResponse> lagreTpForhold(PensjonData pensjonData, String
ident, Set<String> miljoer) {

return Flux.just(pensjonData)
.filter(PensjonData::hasTp)
Expand Down
Loading