From 63cd58c7cca608fb93ecb1c6fa76d6234f9eee70 Mon Sep 17 00:00:00 2001 From: kristenhaerum Date: Thu, 14 Sep 2023 13:43:55 +0200 Subject: [PATCH] Lagt til synkronisering for alle #deploy-test-dolly-backend --- .../service/DollyBestillingService.java | 2 + .../service/GjenopprettBestillingService.java | 7 +-- .../service/GjenopprettGruppeService.java | 9 ++- .../service/GjenopprettIdentService.java | 9 ++- .../ImportAvPersonerFraPdlService.java | 9 ++- .../service/LeggTilPaaGruppeService.java | 9 ++- .../service/OppdaterPersonService.java | 9 ++- .../OpprettPersonerByKriterierService.java | 8 +-- ...PersonerFraIdenterMedKriterierService.java | 21 ++++--- .../command/PersonGetCommand.java | 11 ++-- .../service/TpsPersonService.java | 55 +++++++++++++++---- .../service/TransaksjonMappingService.java | 8 +++ 12 files changed, 113 insertions(+), 44 deletions(-) diff --git a/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/service/DollyBestillingService.java b/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/service/DollyBestillingService.java index 23a49dc2bc4..5660bc09105 100644 --- a/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/service/DollyBestillingService.java +++ b/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/service/DollyBestillingService.java @@ -12,6 +12,7 @@ import no.nav.dolly.bestilling.pdldata.dto.PdlResponse; import no.nav.dolly.bestilling.pensjonforvalter.PensjonforvalterClient; import no.nav.dolly.bestilling.tagshendelseslager.TagsHendelseslagerClient; +import no.nav.dolly.bestilling.tpsmessagingservice.service.TpsPersonService; import no.nav.dolly.domain.jpa.Bestilling; import no.nav.dolly.domain.jpa.BestillingProgress; import no.nav.dolly.domain.jpa.Bruker; @@ -56,6 +57,7 @@ public class DollyBestillingService { protected final PdlDataConsumer pdlDataConsumer; protected final ErrorStatusDecoder errorStatusDecoder; protected final TransactionHelperService transactionHelperService; + protected final TpsPersonService tpsPersonService; public static Set getEnvironments(String miljoer) { return isNotBlank(miljoer) ? Set.of(miljoer.split(",")) : emptySet(); diff --git a/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/service/GjenopprettBestillingService.java b/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/service/GjenopprettBestillingService.java index 4de758de632..4d0812abc0f 100644 --- a/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/service/GjenopprettBestillingService.java +++ b/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/service/GjenopprettBestillingService.java @@ -37,7 +37,6 @@ public class GjenopprettBestillingService extends DollyBestillingService { private final BestillingProgressService bestillingProgressService; private final PersonServiceClient personServiceClient; - private final TpsPersonService tpsPersonService; public GjenopprettBestillingService( IdentService identService, @@ -59,11 +58,11 @@ public GjenopprettBestillingService( counterCustomRegistry, pdlDataConsumer, errorStatusDecoder, - transactionHelperService + transactionHelperService, + tpsPersonService ); this.bestillingProgressService = bestillingProgressService; this.personServiceClient = personServiceClient; - this.tpsPersonService = tpsPersonService; } @Async @@ -94,7 +93,7 @@ public void executeAsync(Bestilling bestilling) { .map(ClientFuture::get) .filter(BestillingProgress::isPdlSync) .flatMap(pdlSync -> Flux.concat( - tpsPersonService.syncPerson(dollyPerson, bestKriterier, progress) + tpsPersonService.syncPerson(bestKriterier, progress, false) .map(ClientFuture::get), gjenopprettKlienter(dollyPerson, bestKriterier, fase2Klienter(), diff --git a/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/service/GjenopprettGruppeService.java b/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/service/GjenopprettGruppeService.java index 43854168ad6..2dc9ed4eb64 100644 --- a/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/service/GjenopprettGruppeService.java +++ b/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/service/GjenopprettGruppeService.java @@ -7,6 +7,7 @@ import no.nav.dolly.bestilling.pdldata.PdlDataConsumer; import no.nav.dolly.bestilling.pdldata.dto.PdlResponse; import no.nav.dolly.bestilling.personservice.PersonServiceClient; +import no.nav.dolly.bestilling.tpsmessagingservice.service.TpsPersonService; import no.nav.dolly.domain.jpa.Bestilling; import no.nav.dolly.domain.jpa.BestillingProgress; import no.nav.dolly.domain.resultset.RsDollyBestilling; @@ -49,7 +50,8 @@ public GjenopprettGruppeService( ErrorStatusDecoder errorStatusDecoder, PdlDataConsumer pdlDataConsumer, TransactionHelperService transactionHelperService, - PersonServiceClient personServiceClient + PersonServiceClient personServiceClient, + TpsPersonService tpsPersonService ) { super( identService, @@ -59,7 +61,8 @@ public GjenopprettGruppeService( counterCustomRegistry, pdlDataConsumer, errorStatusDecoder, - transactionHelperService + transactionHelperService, + tpsPersonService ); this.personServiceClient = personServiceClient; } @@ -106,6 +109,8 @@ public void executeAsync(Bestilling bestilling) { .doOnNext(request -> log.info("Startet gjenopprett bestilling {} for ident: {}", request.getId(), testident.getIdent())) .flatMapSequential(bestillingRequest -> Flux.concat( + tpsPersonService.syncPerson(bestillingRequest, progress, false) + .map(ClientFuture::get), gjenopprettKlienter(dollyPerson, bestillingRequest, fase2Klienter(), progress, false), diff --git a/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/service/GjenopprettIdentService.java b/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/service/GjenopprettIdentService.java index 09fdcc674e9..c02b314f15c 100644 --- a/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/service/GjenopprettIdentService.java +++ b/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/service/GjenopprettIdentService.java @@ -7,6 +7,7 @@ import no.nav.dolly.bestilling.pdldata.PdlDataConsumer; import no.nav.dolly.bestilling.pdldata.dto.PdlResponse; import no.nav.dolly.bestilling.personservice.PersonServiceClient; +import no.nav.dolly.bestilling.tpsmessagingservice.service.TpsPersonService; import no.nav.dolly.domain.jpa.Bestilling; import no.nav.dolly.domain.jpa.BestillingProgress; import no.nav.dolly.domain.resultset.RsDollyBestilling; @@ -49,7 +50,8 @@ public GjenopprettIdentService( ErrorStatusDecoder errorStatusDecoder, PdlDataConsumer pdlDataConsumer, TransactionHelperService transactionHelperService, - PersonServiceClient personServiceClient + PersonServiceClient personServiceClient, + TpsPersonService tpsPersonService ) { super( identService, @@ -59,7 +61,8 @@ public GjenopprettIdentService( counterCustomRegistry, pdlDataConsumer, errorStatusDecoder, - transactionHelperService + transactionHelperService, + tpsPersonService ); this.personServiceClient = personServiceClient; } @@ -108,6 +111,8 @@ public void executeAsync(Bestilling bestilling) { log.info("Startet gjenopprett bestilling {} for ident: {}", request.getId(), testident.getIdent())) .flatMap(bestillingRequest -> Flux.concat( + tpsPersonService.syncPerson(bestillingRequest, progress, false) + .map(ClientFuture::get), gjenopprettKlienter(dollyPerson, bestillingRequest, fase2Klienter(), progress, false), diff --git a/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/service/ImportAvPersonerFraPdlService.java b/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/service/ImportAvPersonerFraPdlService.java index 9db6d8c686a..4a5c6d94b0f 100644 --- a/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/service/ImportAvPersonerFraPdlService.java +++ b/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/service/ImportAvPersonerFraPdlService.java @@ -6,6 +6,7 @@ import no.nav.dolly.bestilling.ClientRegister; import no.nav.dolly.bestilling.pdldata.PdlDataConsumer; import no.nav.dolly.bestilling.personservice.PersonServiceClient; +import no.nav.dolly.bestilling.tpsmessagingservice.service.TpsPersonService; import no.nav.dolly.domain.jpa.Bestilling; import no.nav.dolly.domain.jpa.BestillingProgress; import no.nav.dolly.domain.resultset.RsDollyBestillingRequest; @@ -43,7 +44,8 @@ public ImportAvPersonerFraPdlService(IdentService identService, ErrorStatusDecoder errorStatusDecoder, PdlDataConsumer pdlDataConsumer, TransactionHelperService transactionHelperService, - PersonServiceClient personServiceClient) { + PersonServiceClient personServiceClient, + TpsPersonService tpsPersonService) { super( identService, bestillingService, @@ -52,7 +54,8 @@ public ImportAvPersonerFraPdlService(IdentService identService, counterCustomRegistry, pdlDataConsumer, errorStatusDecoder, - transactionHelperService + transactionHelperService, + tpsPersonService ); this.personServiceClient = personServiceClient; } @@ -82,6 +85,8 @@ public void executeAsync(Bestilling bestilling) { .filter(BestillingProgress::isPdlSync) .flatMap(pdlSync -> Flux.concat( + tpsPersonService.syncPerson(bestKriterier, progress, true) + .map(ClientFuture::get), gjenopprettKlienter(dollyPerson, bestKriterier, fase2Klienter(), progress, true), diff --git a/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/service/LeggTilPaaGruppeService.java b/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/service/LeggTilPaaGruppeService.java index d70afcd7023..0cbb4e0d06e 100644 --- a/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/service/LeggTilPaaGruppeService.java +++ b/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/service/LeggTilPaaGruppeService.java @@ -8,6 +8,7 @@ import no.nav.dolly.bestilling.pdldata.PdlDataConsumer; import no.nav.dolly.bestilling.pdldata.dto.PdlResponse; import no.nav.dolly.bestilling.personservice.PersonServiceClient; +import no.nav.dolly.bestilling.tpsmessagingservice.service.TpsPersonService; import no.nav.dolly.domain.jpa.Bestilling; import no.nav.dolly.domain.jpa.BestillingProgress; import no.nav.dolly.domain.resultset.RsDollyBestillingRequest; @@ -55,7 +56,8 @@ public LeggTilPaaGruppeService( ErrorStatusDecoder errorStatusDecoder, PdlDataConsumer pdlDataConsumer, TransactionHelperService transactionHelperService, - PersonServiceClient personServiceClient) { + PersonServiceClient personServiceClient, + TpsPersonService tpsPersonService) { super( identService, bestillingService, @@ -64,7 +66,8 @@ public LeggTilPaaGruppeService( counterCustomRegistry, pdlDataConsumer, errorStatusDecoder, - transactionHelperService + transactionHelperService, + tpsPersonService ); this.personServiceClient = personServiceClient; this.mapperFacade = mapperFacade; @@ -104,6 +107,8 @@ public void executeAsync(Bestilling bestilling) { .filter(BestillingProgress::isPdlSync) .flatMap(pdlSync -> Flux.concat( + tpsPersonService.syncPerson(bestKriterier, progress, true) + .map(ClientFuture::get), gjenopprettKlienter(dollyPerson, bestKriterier, fase2Klienter(), progress, true), diff --git a/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/service/OppdaterPersonService.java b/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/service/OppdaterPersonService.java index c3fd600822b..2abf4bc7cbe 100644 --- a/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/service/OppdaterPersonService.java +++ b/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/service/OppdaterPersonService.java @@ -8,6 +8,7 @@ import no.nav.dolly.bestilling.pdldata.PdlDataConsumer; import no.nav.dolly.bestilling.pdldata.dto.PdlResponse; import no.nav.dolly.bestilling.personservice.PersonServiceClient; +import no.nav.dolly.bestilling.tpsmessagingservice.service.TpsPersonService; import no.nav.dolly.domain.jpa.Bestilling; import no.nav.dolly.domain.jpa.BestillingProgress; import no.nav.dolly.domain.resultset.RsDollyUpdateRequest; @@ -50,7 +51,8 @@ public OppdaterPersonService( ErrorStatusDecoder errorStatusDecoder, PdlDataConsumer pdlDataConsumer, TransactionHelperService transactionHelperService, - PersonServiceClient personServiceClient) { + PersonServiceClient personServiceClient, + TpsPersonService tpsPersonService) { super( identService, bestillingService, @@ -59,7 +61,8 @@ public OppdaterPersonService( counterCustomRegistry, pdlDataConsumer, errorStatusDecoder, - transactionHelperService + transactionHelperService, + tpsPersonService ); this.personServiceClient = personServiceClient; this.mapperFacade = mapperFacade; @@ -93,6 +96,8 @@ public void oppdaterPersonAsync(RsDollyUpdateRequest request, Bestilling bestill .filter(BestillingProgress::isPdlSync) .flatMap(pdlSync -> Flux.concat( + tpsPersonService.syncPerson(request, progress, true) + .map(ClientFuture::get), gjenopprettKlienter(dollyPerson, request, fase2Klienter(), progress, true), diff --git a/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/service/OpprettPersonerByKriterierService.java b/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/service/OpprettPersonerByKriterierService.java index c49c189e6af..b077333fd5e 100644 --- a/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/service/OpprettPersonerByKriterierService.java +++ b/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/service/OpprettPersonerByKriterierService.java @@ -38,8 +38,6 @@ public class OpprettPersonerByKriterierService extends DollyBestillingService { private final PersonServiceClient personServiceClient; private final MapperFacade mapperFacade; - private final TpsPersonService tpsPersonService; - public OpprettPersonerByKriterierService( IdentService identService, BestillingService bestillingService, @@ -60,11 +58,11 @@ public OpprettPersonerByKriterierService( counterCustomRegistry, pdlDataConsumer, errorStatusDecoder, - transactionHelperService + transactionHelperService, + tpsPersonService ); this.personServiceClient = personServiceClient; this.mapperFacade = mapperFacade; - this.tpsPersonService = tpsPersonService; } @Async @@ -96,7 +94,7 @@ public void executeAsync(Bestilling bestilling) { .map(ClientFuture::get) .filter(BestillingProgress::isPdlSync) .flatMap(pdlSync -> Flux.concat( - tpsPersonService.syncPerson(dollyPerson, bestKriterier, progress) + tpsPersonService.syncPerson(bestKriterier, progress, true) .map(ClientFuture::get), gjenopprettKlienter(dollyPerson, bestKriterier, fase2Klienter(), diff --git a/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/service/OpprettPersonerFraIdenterMedKriterierService.java b/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/service/OpprettPersonerFraIdenterMedKriterierService.java index 539abc25e7f..f70f59da21f 100644 --- a/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/service/OpprettPersonerFraIdenterMedKriterierService.java +++ b/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/service/OpprettPersonerFraIdenterMedKriterierService.java @@ -7,6 +7,7 @@ import no.nav.dolly.bestilling.ClientRegister; import no.nav.dolly.bestilling.pdldata.PdlDataConsumer; import no.nav.dolly.bestilling.personservice.PersonServiceClient; +import no.nav.dolly.bestilling.tpsmessagingservice.service.TpsPersonService; import no.nav.dolly.domain.jpa.Bestilling; import no.nav.dolly.domain.jpa.BestillingProgress; import no.nav.dolly.domain.resultset.RsDollyBestillingRequest; @@ -48,7 +49,8 @@ public OpprettPersonerFraIdenterMedKriterierService( ErrorStatusDecoder errorStatusDecoder, PdlDataConsumer pdlDataConsumer, TransactionHelperService transactionHelperService, - PersonServiceClient personServiceClient) { + PersonServiceClient personServiceClient, + TpsPersonService tpsPersonService) { super( identService, bestillingService, @@ -57,7 +59,8 @@ public OpprettPersonerFraIdenterMedKriterierService( counterCustomRegistry, pdlDataConsumer, errorStatusDecoder, - transactionHelperService + transactionHelperService, + tpsPersonService ); this.mapperFacade = mapperFacade; this.personServiceClient = personServiceClient; @@ -94,12 +97,14 @@ public void executeAsync(Bestilling bestilling) { .map(ClientFuture::get) .filter(BestillingProgress::isPdlSync) .flatMap(pdlSync -> Flux.concat( - gjenopprettKlienter(dollyPerson, bestKriterier, - fase2Klienter(), - progress, true), - gjenopprettKlienter(dollyPerson, bestKriterier, - fase3Klienter(), - progress, true)))))) + tpsPersonService.syncPerson(bestKriterier, progress, true) + .map(ClientFuture::get), + gjenopprettKlienter(dollyPerson, bestKriterier, + fase2Klienter(), + progress, true), + gjenopprettKlienter(dollyPerson, bestKriterier, + fase3Klienter(), + progress, true)))))) .onErrorResume(throwable -> { var error = errorStatusDecoder.getErrorText( WebClientFilter.getStatus(throwable), WebClientFilter.getMessage(throwable)); diff --git a/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/tpsmessagingservice/command/PersonGetCommand.java b/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/tpsmessagingservice/command/PersonGetCommand.java index ea882b9285c..d79bc072565 100644 --- a/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/tpsmessagingservice/command/PersonGetCommand.java +++ b/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/tpsmessagingservice/command/PersonGetCommand.java @@ -7,9 +7,8 @@ import org.springframework.http.HttpHeaders; import org.springframework.web.reactive.function.client.WebClient; import reactor.core.publisher.Flux; -import reactor.util.retry.Retry; +import reactor.core.publisher.Mono; -import java.time.Duration; import java.util.List; import java.util.concurrent.Callable; @@ -36,8 +35,10 @@ public Flux call() { .header(HttpHeaders.AUTHORIZATION, "Bearer " + token) .retrieve() .bodyToFlux(PersonMiljoeDTO.class) - .doOnError(WebClientFilter::logErrorMessage) - .retryWhen(Retry.backoff(3, Duration.ofSeconds(5)) - .filter(WebClientFilter::is5xxException)); + .onErrorResume(throwable -> Mono.just(PersonMiljoeDTO.builder() + .status("FEIL") + .melding(WebClientFilter.getStatus(throwable).getReasonPhrase()) + .utfyllendeMelding(WebClientFilter.getMessage(throwable)) + .build())); } } diff --git a/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/tpsmessagingservice/service/TpsPersonService.java b/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/tpsmessagingservice/service/TpsPersonService.java index e09ff0f5893..4a819a3a907 100644 --- a/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/tpsmessagingservice/service/TpsPersonService.java +++ b/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/tpsmessagingservice/service/TpsPersonService.java @@ -5,9 +5,10 @@ import no.nav.dolly.bestilling.ClientFuture; import no.nav.dolly.bestilling.tpsmessagingservice.TpsMessagingConsumer; import no.nav.dolly.domain.jpa.BestillingProgress; -import no.nav.dolly.domain.resultset.RsDollyBestillingRequest; -import no.nav.dolly.domain.resultset.dolly.DollyPerson; +import no.nav.dolly.domain.resultset.RsDollyUtvidetBestilling; +import no.nav.dolly.domain.resultset.SystemTyper; import no.nav.dolly.errorhandling.ErrorStatusDecoder; +import no.nav.dolly.service.TransaksjonMappingService; import no.nav.dolly.util.TransactionHelperService; import no.nav.testnav.libs.dto.tpsmessagingservice.v1.PersonMiljoeDTO; import org.apache.commons.lang3.StringUtils; @@ -25,6 +26,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; +import static java.util.Objects.isNull; import static java.util.Objects.nonNull; @Slf4j @@ -34,28 +36,53 @@ public class TpsPersonService { private static final List PENSJON_MILJOER = List.of("q1", "q2"); private static final String TPS_SYNC_START = "Info: Synkronisering mot TPS startet ... %d ms"; - private static final long TIMEOUT_MILLIES = 835; + private static final long TIMEOUT_MILLIES = 839; private static final int MAX_SEKUNDER = 45; private final TpsMessagingConsumer tpsMessagingConsumer; private final TransactionHelperService transactionHelperService; + private final TransaksjonMappingService transaksjonMappingService; - public Flux syncPerson(DollyPerson dollyPerson, RsDollyBestillingRequest bestilling, BestillingProgress progress) { + public Flux syncPerson(RsDollyUtvidetBestilling bestilling, BestillingProgress progress, boolean isOpprettEndre) { long startTime = System.currentTimeMillis(); return Flux.from(Flux.fromIterable(bestilling.getEnvironments()) .filter(PENSJON_MILJOER::contains) - .filter(penMiljoe -> nonNull(bestilling.getPensjonforvalter()) && - (nonNull(bestilling.getPensjonforvalter().getAlderspensjon()) || - nonNull(bestilling.getPensjonforvalter().getUforetrygd()))) + .filter(penMiljoe -> isRelevantBestilling(bestilling) && + (isOpprettEndre || !isTransaksjonMapping(progress.getIdent(), bestilling, bestilling.getEnvironments()))) .collectList() - .flatMap(penMiljoer -> getTpsPerson(LocalTime.now().plusSeconds(MAX_SEKUNDER), LocalTime.now(), dollyPerson.getIdent(), + .filter(penMiljoer -> !penMiljoer.isEmpty()) + .flatMap(penMiljoer -> getTpsPerson(LocalTime.now().plusSeconds(MAX_SEKUNDER), LocalTime.now(), progress.getIdent(), penMiljoer, Collections.emptyList(), progress, new AtomicInteger(0)) - .map(status -> prepareResult(dollyPerson.getIdent(), status, bestilling.getEnvironments(), startTime)) + .map(status -> prepareResult(progress.getIdent(), status, bestilling.getEnvironments(), startTime)) .map(status -> futurePersist(progress, status)))); } + private boolean isRelevantBestilling(RsDollyUtvidetBestilling bestilling) { + + return nonNull(bestilling.getPensjonforvalter()) && + (nonNull(bestilling.getPensjonforvalter().getAlderspensjon()) || + nonNull(bestilling.getPensjonforvalter().getUforetrygd())); + } + + private boolean isTransaksjonMapping(String ident, RsDollyUtvidetBestilling bestilling, Set miljoer) { + + var transaksjoner = transaksjonMappingService.getTransaksjonMapping(ident); + + return (isNull(bestilling.getPensjonforvalter().getAlderspensjon()) || + transaksjoner.stream() + .anyMatch(transaksjon -> miljoer.stream() + .anyMatch(miljoe -> SystemTyper.PEN_AP.name().equals(transaksjon.getSystem()) && + miljoe.equals(transaksjon.getMiljoe())))) && + + (isNull(bestilling.getPensjonforvalter().getUforetrygd()) || + transaksjoner.stream() + .anyMatch(transaksjon2 -> miljoer.stream() + .anyMatch(miljoe -> SystemTyper.PEN_UT.name().equals(transaksjon2.getSystem()) && + miljoe.equals(transaksjon2.getMiljoe())))); + } + private Mono> getTpsPerson(LocalTime tidSlutt, LocalTime tidNo, String ident, List miljoer, List status, BestillingProgress progress, AtomicInteger counter) { @@ -66,6 +93,10 @@ private Mono> getTpsPerson(LocalTime tidSlutt, LocalTime t } else { + log.info(status.stream() + .map(sts1 -> sts1.getStatus() + ": " + sts1.getMelding() + " " + sts1.getUtfyllendeMelding()) + .collect(Collectors.joining(", "))); + transactionHelperService.persister(progress, BestillingProgress::setTpsSyncStatus, miljoer.stream() .map(miljoe -> String.format("%s:%s", miljoe, String.format(TPS_SYNC_START, counter.get() * TIMEOUT_MILLIES))) @@ -86,11 +117,11 @@ private List prepareResult(String ident, List log.info("Synkronisering mot TPS for {} tok {} ms.", ident, System.currentTimeMillis() - startTime); } else { - log.error("Synkronisering mot TPS for {} gitt opp etter {} ms.", ident, System.currentTimeMillis() - startTime); + log.warn("Synkronisering mot TPS for {} gitt opp etter {} ms.", ident, System.currentTimeMillis() - startTime); } return Stream.of(status, miljoer.stream() - .filter(miljoe -> status.stream().noneMatch(status1 -> status1.getMiljoe().equals(miljoe))) + .filter(miljoe -> status.stream().noneMatch(status1 -> miljoe.equals(status1.getMiljoe()))) .map(miljoe -> PersonMiljoeDTO.builder() .miljoe(miljoe) .status("NOK") @@ -109,7 +140,7 @@ private ClientFuture futurePersist(BestillingProgress progress, List String.format("%s:%s", detalj.getMiljoe(), ErrorStatusDecoder.encodeStatus(detalj.isOk() ? detalj.getStatus() : - StringUtils.trimToEmpty(String.format("%s %s", detalj.getMelding(), detalj.getUtfyllendeMelding()))))) + StringUtils.trimToEmpty(String.format("FEIL: %s", detalj.getUtfyllendeMelding()))))) .collect(Collectors.joining(","))); return progress; }; diff --git a/apps/dolly-backend/src/main/java/no/nav/dolly/service/TransaksjonMappingService.java b/apps/dolly-backend/src/main/java/no/nav/dolly/service/TransaksjonMappingService.java index 261c1642107..00c8d2c6a36 100644 --- a/apps/dolly-backend/src/main/java/no/nav/dolly/service/TransaksjonMappingService.java +++ b/apps/dolly-backend/src/main/java/no/nav/dolly/service/TransaksjonMappingService.java @@ -30,6 +30,14 @@ public List getTransaksjonMapping(String system, String id .toList(); } + @Transactional(readOnly = true) + public List getTransaksjonMapping(String ident) { + + return transaksjonMappingRepository.findAllByBestillingIdAndIdent(null, ident).stream() + .map(transasjon -> mapperFacade.map(transasjon, RsTransaksjonMapping.class)) + .toList(); + } + public boolean existAlready(SystemTyper system, String ident, String miljoe) { return transaksjonMappingRepository.findAllBySystemAndIdent(system.name(), ident)