-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Legger inn oppfølgingsoppgave hvis unntak uten frist Ligger bak en featuretoggle, så funksjonaliteten kan gå ut i dev kun. * Sender inn featuretoggleservice * wip daglige jobber * legge til service for håndtere opprette oppfølgsingsoppgaver * rette byggefeil etter merge * revert la til linjeskift pga ktlint * wip * opprette oppgave ved unntak utløper * definere tomDato en plass * Update apps/etterlatte-tidshendelser/src/main/kotlin/no/nav/etterlatte/tidshendelser/JobbScheduler.kt Co-authored-by: Øyvind Stette Haarberg <[email protected]> * Update apps/etterlatte-behandling/src/main/kotlin/behandling/aktivitetsplikt/AktivitetspliktDao.kt Co-authored-by: Øyvind Stette Haarberg <[email protected]> * fjerne todo --------- Co-authored-by: Øyvind Haarberg <[email protected]>
- Loading branch information
1 parent
79cf01a
commit 0e93431
Showing
14 changed files
with
201 additions
and
31 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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
33 changes: 33 additions & 0 deletions
33
...tte-behandling/src/main/kotlin/behandling/jobs/AktivitetspliktOppgaveUnntakUtloeperJob.kt
This file contains 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,33 @@ | ||
package no.nav.etterlatte.behandling.jobs | ||
|
||
import no.nav.etterlatte.jobs.LoggerInfo | ||
import no.nav.etterlatte.jobs.fixedRateCancellableTimer | ||
import no.nav.etterlatte.libs.common.TimerJob | ||
import org.slf4j.LoggerFactory | ||
import java.time.Duration | ||
import java.util.Timer | ||
|
||
class AktivitetspliktOppgaveUnntakUtloeperJob( | ||
private val aktivitetspliktOppgaveUnntakUtloeperJobService: AktivitetspliktOppgaveUnntakUtloeperJobService, | ||
private val erLeader: () -> Boolean, | ||
private val initialDelay: Long, | ||
private val interval: Duration, | ||
) : TimerJob { | ||
private val logger = LoggerFactory.getLogger(this::class.java) | ||
private val jobbNavn = this::class.simpleName | ||
|
||
override fun schedule(): Timer { | ||
logger.info("Starter jobb $jobbNavn med interval $interval") | ||
|
||
return fixedRateCancellableTimer( | ||
name = jobbNavn, | ||
initialDelay = initialDelay, | ||
loggerInfo = LoggerInfo(logger = logger, loggTilSikkerLogg = false), | ||
period = interval.toMillis(), | ||
) { | ||
if (erLeader()) { | ||
aktivitetspliktOppgaveUnntakUtloeperJobService.run() | ||
} | ||
} | ||
} | ||
} |
93 changes: 93 additions & 0 deletions
93
...andling/src/main/kotlin/behandling/jobs/AktivitetspliktOppgaveUnntakUtloeperJobService.kt
This file contains 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,93 @@ | ||
package no.nav.etterlatte.behandling.jobs | ||
|
||
import kotlinx.coroutines.DelicateCoroutinesApi | ||
import kotlinx.coroutines.newSingleThreadContext | ||
import kotlinx.coroutines.runBlocking | ||
import no.nav.etterlatte.behandling.aktivitetsplikt.AktivitetspliktDao | ||
import no.nav.etterlatte.behandling.aktivitetsplikt.AktivitetspliktOppgaveToggles | ||
import no.nav.etterlatte.behandling.aktivitetsplikt.AktivitetspliktService | ||
import no.nav.etterlatte.behandling.klienter.VedtakKlient | ||
import no.nav.etterlatte.funksjonsbrytere.FeatureToggleService | ||
import no.nav.etterlatte.libs.common.oppgave.OppgaveKilde | ||
import no.nav.etterlatte.libs.common.oppgave.OppgaveType | ||
import no.nav.etterlatte.libs.common.tidspunkt.toTidspunkt | ||
import no.nav.etterlatte.libs.ktor.token.HardkodaSystembruker | ||
import no.nav.etterlatte.oppgave.OppgaveService | ||
import org.slf4j.LoggerFactory | ||
import java.time.LocalDate | ||
|
||
class AktivitetspliktOppgaveUnntakUtloeperJobService( | ||
private val aktivitetspliktDao: AktivitetspliktDao, | ||
private val aktivitetspliktService: AktivitetspliktService, | ||
private val oppgaveService: OppgaveService, | ||
private val vedtakKlient: VedtakKlient, | ||
private val featureToggleService: FeatureToggleService, | ||
) { | ||
private val logger = LoggerFactory.getLogger(this::class.java) | ||
|
||
@OptIn(DelicateCoroutinesApi::class) | ||
fun run() { | ||
if (featureToggleService.isEnabled(AktivitetspliktOppgaveToggles.UNNTAK_MED_FRIST, false)) { | ||
logger.info("Starter jobb for å lage oppfølgingsoppgaver for unntak med frist") | ||
newSingleThreadContext("aktivitetspliktOppgaveUnntakUtloeperJob").use { ctx -> | ||
Runtime.getRuntime().addShutdownHook(Thread { ctx.close() }) | ||
runBlocking(ctx) { | ||
opprettOppfoelgingsOppgaveForAktivitetspliktUnntakUtloeper() | ||
} | ||
} | ||
} else { | ||
logger.info("Jobb for å lage oppfølgingsoppgaver for unntak med frist er skrudd av") | ||
} | ||
} | ||
|
||
private suspend fun opprettOppfoelgingsOppgaveForAktivitetspliktUnntakUtloeper() { | ||
val tomDato = LocalDate.now().plusMonths(2) | ||
val sakIds = aktivitetspliktDao.finnSakerKlarForOppfoelgingsoppgaveVarigUnntakUtloeper(tomDato) | ||
logger.info("Fant ${sakIds.size} saker som skal sjekkes for oppfølgingsoppgaver unntak utløper") | ||
|
||
sakIds.forEach { sakId -> | ||
if (!vedtakKlient | ||
.sakHarLopendeVedtakPaaDato( | ||
sakId, | ||
tomDato, | ||
HardkodaSystembruker.oppgave, | ||
).erLoepende | ||
) { | ||
logger.info("Lager ikke oppfølgingsoppgave for sak $sakId grunnen ikke løpende på dato $tomDato") | ||
return@forEach | ||
} | ||
|
||
val sak = aktivitetspliktService.hentVurderingForSak(sakId) | ||
val oppgaveReferanser = | ||
oppgaveService | ||
.hentOppgaverForSak(sakId) | ||
.filter { it.type == OppgaveType.OPPFOELGING } | ||
.map { it.referanse } | ||
|
||
sak.unntak | ||
.filter { it.tom != null && it.tom <= tomDato } | ||
.forEach { unntak -> | ||
val harOppave = oppgaveReferanser.any { unntak.id.toString() == it } | ||
if (harOppave) { | ||
return@forEach | ||
} else { | ||
logger.info("Oppretter oppfølgingsoppgave for sak $sakId for unntak ${unntak.id}") | ||
oppgaveService.opprettOppgave( | ||
referanse = unntak.id.toString(), | ||
sakId = sakId, | ||
kilde = OppgaveKilde.SAKSBEHANDLER, | ||
type = OppgaveType.OPPFOELGING, | ||
merknad = "Unntak ${unntak.unntak.lesbartNavn} utløper", | ||
frist = | ||
unntak.tom!! | ||
.minusMonths(1) | ||
.atStartOfDay() | ||
.toTidspunkt(), | ||
saksbehandler = null, | ||
gruppeId = null, | ||
) | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains 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 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 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 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 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
Oops, something went wrong.