-
Notifications
You must be signed in to change notification settings - Fork 2
TFP-6044 journalpost sikkerhetsnett #2589
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
Merged
Merged
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
domene/src/main/java/no/nav/foreldrepenger/mottak/task/SikkerhetsnettTask.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package no.nav.foreldrepenger.mottak.task; | ||
|
||
import java.util.stream.Collectors; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import jakarta.enterprise.context.Dependent; | ||
import jakarta.inject.Inject; | ||
import no.nav.foreldrepenger.journalføring.domene.JournalpostId; | ||
import no.nav.foreldrepenger.journalføring.oppgave.Journalføringsoppgave; | ||
import no.nav.foreldrepenger.journalføring.oppgave.domene.NyOppgave; | ||
import no.nav.foreldrepenger.journalføring.oppgave.lager.AktørId; | ||
import no.nav.foreldrepenger.mottak.behandlendeenhet.EnhetsTjeneste; | ||
import no.nav.foreldrepenger.mottak.journal.ArkivTjeneste; | ||
import no.nav.foreldrepenger.mottak.task.sikkerhetsnett.SikkerhetsnettKlient; | ||
import no.nav.foreldrepenger.mottak.task.sikkerhetsnett.SikkerhetsnettResponse; | ||
import no.nav.vedtak.felles.prosesstask.api.ProsessTask; | ||
import no.nav.vedtak.felles.prosesstask.api.ProsessTaskData; | ||
import no.nav.vedtak.felles.prosesstask.api.ProsessTaskHandler; | ||
|
||
@Dependent | ||
@ProsessTask(value = "vedlikehold.tasks.sikkerhetsnett", cronExpression = "0 29 6 * * *", maxFailedRuns = 1) // Endre siste asterisk til WED | ||
public class SikkerhetsnettTask implements ProsessTaskHandler { | ||
|
||
private static final Logger LOG = LoggerFactory.getLogger(SikkerhetsnettTask.class); | ||
|
||
private final ArkivTjeneste arkivTjeneste; | ||
private final EnhetsTjeneste enhetsTjeneste; | ||
private final Journalføringsoppgave journalføringsoppgave; | ||
private final SikkerhetsnettKlient sikkerhetsnettKlient; | ||
|
||
@Inject | ||
public SikkerhetsnettTask(ArkivTjeneste arkivTjeneste, | ||
EnhetsTjeneste enhetsTjeneste, | ||
Journalføringsoppgave journalføringsoppgave, | ||
SikkerhetsnettKlient sikkerhetsnettKlient) { | ||
this.arkivTjeneste = arkivTjeneste; | ||
this.enhetsTjeneste = enhetsTjeneste; | ||
this.journalføringsoppgave = journalføringsoppgave; | ||
this.sikkerhetsnettKlient = sikkerhetsnettKlient; | ||
} | ||
|
||
@Override | ||
public void doTask(ProsessTaskData prosessTaskData) { | ||
var åpneJournalposterUtenOppgave = sikkerhetsnettKlient.hentÅpneJournalposterEldreEnn(7).stream() | ||
.filter(jp -> jp.mottaksKanal() == null || !"EESSI".equals(jp.mottaksKanal())) | ||
.filter(jp -> !journalføringsoppgave.finnesÅpeneJournalføringsoppgaverFor(JournalpostId.fra(jp.journalpostId()))) | ||
.toList(); | ||
LOG.info("FPFORDEL SIKKERHETSNETT fant {} journalposter uten oppgave. {}", åpneJournalposterUtenOppgave.size(), | ||
åpneJournalposterUtenOppgave.stream().map(SikkerhetsnettResponse::journalpostId).collect(Collectors.joining(","))); | ||
åpneJournalposterUtenOppgave.forEach(this::opprettOppgave); | ||
} | ||
|
||
private void opprettOppgave(SikkerhetsnettResponse jp) { | ||
var journalpostId = JournalpostId.fra(jp.journalpostId()); | ||
var journalpost = arkivTjeneste.hentArkivJournalpost(journalpostId.getVerdi()); | ||
var aktørId = journalpost.getBrukerAktørId().map(AktørId::new).orElse(null); | ||
var aktørIdString = journalpost.getBrukerAktørId().orElse(null); | ||
var enhet = enhetsTjeneste.hentFordelingEnhetId(journalpost.getJournalfoerendeEnhet(), aktørIdString); | ||
var nyoppgave = new NyOppgave(journalpostId, enhet, aktørId, null, journalpost.getBehandlingstema(), "Journalføring"); | ||
if (EnhetsTjeneste.NK_ENHET_ID.equals(enhet)) { | ||
journalføringsoppgave.opprettGosysJournalføringsoppgaveFor(nyoppgave); | ||
} else { | ||
journalføringsoppgave.opprettJournalføringsoppgaveFor(nyoppgave); | ||
} | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
.../src/main/java/no/nav/foreldrepenger/mottak/task/sikkerhetsnett/SikkerhetsnettKlient.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package no.nav.foreldrepenger.mottak.task.sikkerhetsnett; | ||
|
||
import java.util.List; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import jakarta.enterprise.context.Dependent; | ||
import jakarta.ws.rs.core.UriBuilder; | ||
import no.nav.foreldrepenger.fordel.kodeverdi.Tema; | ||
import no.nav.vedtak.felles.integrasjon.rest.RestClient; | ||
import no.nav.vedtak.felles.integrasjon.rest.RestClientConfig; | ||
import no.nav.vedtak.felles.integrasjon.rest.RestConfig; | ||
import no.nav.vedtak.felles.integrasjon.rest.RestRequest; | ||
import no.nav.vedtak.felles.integrasjon.rest.TokenFlow; | ||
|
||
@Dependent | ||
@RestClientConfig(tokenConfig = TokenFlow.ADAPTIVE, endpointProperty = "sikkerhetsnett.url", | ||
endpointDefault = "http://dokarkiv.teamdokumenthandtering/rest/journalpostapi/v1/finnMottatteJournalposter", | ||
scopesProperty = "dokarkiv.scopes", scopesDefault = "api://prod-fss.teamdokumenthandtering.dokarkiv/.default") | ||
public class SikkerhetsnettKlient { | ||
|
||
private final RestClient restKlient; | ||
private final RestConfig restConfig; | ||
|
||
protected SikkerhetsnettKlient() { | ||
this(RestClient.client()); | ||
} | ||
|
||
protected SikkerhetsnettKlient(RestClient client) { | ||
this.restKlient = client; | ||
this.restConfig = RestConfig.forClient(this.getClass()); | ||
} | ||
|
||
|
||
public List<SikkerhetsnettResponse> hentÅpneJournalposterEldreEnn(int antallDagerGamle) { | ||
var opprett = UriBuilder.fromUri(restConfig.endpoint()) | ||
.queryParam("tema", Tema.FORELDRE_OG_SVANGERSKAPSPENGER.getOffisiellKode()) | ||
.queryParam("antallDagerGamle", String.valueOf(antallDagerGamle)) | ||
.build(); | ||
var restRequest = RestRequest.newGET(opprett, restConfig); | ||
return restKlient.sendReturnList(restRequest, SikkerhetsnettResponse.class); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
...rc/main/java/no/nav/foreldrepenger/mottak/task/sikkerhetsnett/SikkerhetsnettResponse.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package no.nav.foreldrepenger.mottak.task.sikkerhetsnett; | ||
|
||
public record SikkerhetsnettResponse(String journalpostId, | ||
String mottaksKanal, | ||
String behandlingstema, | ||
String journalforendeEnhet) { | ||
|
||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.