-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1372 from navikt/resend-statistikk-iverksett-søkn…
…adsbehandling Legg til endepunkt for å resende søknadsbehandlingsvedtak
- Loading branch information
Showing
20 changed files
with
253 additions
and
5 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
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
10 changes: 10 additions & 0 deletions
10
...in/src/main/kotlin/no/nav/su/se/bakover/domain/vedtak/VedtakIverksattSøknadsbehandling.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,10 @@ | ||
package no.nav.su.se.bakover.domain.vedtak | ||
|
||
import no.nav.su.se.bakover.domain.søknadsbehandling.IverksattSøknadsbehandling | ||
|
||
/** | ||
* Grupperer avslag og innvilgelser. | ||
*/ | ||
sealed interface VedtakIverksattSøknadsbehandling : Stønadsvedtak { | ||
override val behandling: IverksattSøknadsbehandling | ||
} |
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
8 changes: 8 additions & 0 deletions
8
...c/main/kotlin/no/nav/su/se/bakover/service/statistikk/ResendStatistikkhendelserService.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,8 @@ | ||
package no.nav.su.se.bakover.service.statistikk | ||
|
||
import java.time.LocalDate | ||
|
||
interface ResendStatistikkhendelserService { | ||
|
||
fun resendIverksattSøknadsbehandling(fraOgMedDato: LocalDate) | ||
} |
64 changes: 64 additions & 0 deletions
64
...in/kotlin/no/nav/su/se/bakover/service/statistikk/ResendStatistikkhendelserServiceImpl.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,64 @@ | ||
package no.nav.su.se.bakover.service.statistikk | ||
|
||
import arrow.core.Either | ||
import arrow.core.getOrElse | ||
import no.nav.su.se.bakover.domain.sak.SakRepo | ||
import no.nav.su.se.bakover.domain.statistikk.StatistikkEvent | ||
import no.nav.su.se.bakover.domain.statistikk.StatistikkEventObserver | ||
import no.nav.su.se.bakover.domain.vedtak.Avslagsvedtak | ||
import no.nav.su.se.bakover.domain.vedtak.VedtakInnvilgetSøknadsbehandling | ||
import no.nav.su.se.bakover.domain.vedtak.VedtakIverksattSøknadsbehandling | ||
import no.nav.su.se.bakover.domain.vedtak.VedtakRepo | ||
import org.slf4j.LoggerFactory | ||
import java.time.LocalDate | ||
|
||
/** | ||
* Har som ansvar og resende hendelser som ikke har blitt sendt til statistikk. | ||
*/ | ||
class ResendStatistikkhendelserServiceImpl( | ||
private val vedtakRepo: VedtakRepo, | ||
private val sakRepo: SakRepo, | ||
private val statistikkEventObserver: StatistikkEventObserver, | ||
) : ResendStatistikkhendelserService { | ||
|
||
private val log = LoggerFactory.getLogger(this::class.java) | ||
|
||
override fun resendIverksattSøknadsbehandling( | ||
fraOgMedDato: LocalDate, | ||
) { | ||
log.info("Resend statistikk: Starter resend av statistikk for søknadsbehandlingvedtak fra og med $fraOgMedDato.") | ||
vedtakRepo.hentSøknadsbehandlingsvedtakFraOgMed(fraOgMedDato).also { | ||
log.info("Resend statistikk: Fant ${it.size} søknadsbehandlingvedtak fra og med $fraOgMedDato som skal resendes.") | ||
}.forEachIndexed { index, vedtakId -> | ||
|
||
log.info("Resend statistikk: for søknadsbehandlingvedtak $vedtakId") | ||
sakRepo.hentSakForVedtak(vedtakId).let { sak -> | ||
val vedtak = Either.catch { | ||
sak!!.vedtakListe.single { it.id == vedtakId } as VedtakIverksattSøknadsbehandling | ||
}.getOrElse { | ||
log.error( | ||
"Resend statistikk: Fant ikke sak for vedtak ($vedtakId) eller var ikke av type VedtakIverksattSøknadsbehandling. FraOgMedDato: $fraOgMedDato", | ||
it, | ||
) | ||
if (index == 0) { | ||
log.error("Resend statistikk: Siden vi feilet på første element, avbryter vi. FraOgMedDato: $fraOgMedDato, vedtakId:$vedtakId") | ||
return | ||
} | ||
return@forEachIndexed | ||
} | ||
when (vedtak) { | ||
is VedtakInnvilgetSøknadsbehandling -> { | ||
statistikkEventObserver.handle(StatistikkEvent.Behandling.Søknad.Iverksatt.Innvilget(vedtak)) | ||
statistikkEventObserver.handle(StatistikkEvent.Stønadsvedtak(vedtak) { sak!! }) | ||
log.info("Resend statistikk: Sendte statistikk for VedtakInnvilgetSøknadsbehandling $vedtakId. FraOgMedDato: $fraOgMedDato.") | ||
} | ||
|
||
is Avslagsvedtak -> { | ||
statistikkEventObserver.handle(StatistikkEvent.Behandling.Søknad.Iverksatt.Avslag(vedtak)) | ||
log.info("Resend statistikk: Sendte statistikk for Avslagsvedtak $vedtakId. FraOgMedDato: $fraOgMedDato") | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
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
36 changes: 36 additions & 0 deletions
36
web/src/main/kotlin/no/nav/su/se/bakover/web/routes/drift/ResendStatistikkRoute.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,36 @@ | ||
package no.nav.su.se.bakover.web.routes.drift | ||
|
||
import io.ktor.http.HttpStatusCode | ||
import io.ktor.server.application.call | ||
import io.ktor.server.routing.Route | ||
import io.ktor.server.routing.post | ||
import kotlinx.coroutines.CoroutineScope | ||
import kotlinx.coroutines.Dispatchers | ||
import kotlinx.coroutines.launch | ||
import no.nav.su.se.bakover.common.Brukerrolle | ||
import no.nav.su.se.bakover.common.infrastructure.web.Resultat | ||
import no.nav.su.se.bakover.common.infrastructure.web.svar | ||
import no.nav.su.se.bakover.common.infrastructure.web.withBody | ||
import no.nav.su.se.bakover.service.statistikk.ResendStatistikkhendelserService | ||
import no.nav.su.se.bakover.web.features.authorize | ||
import java.time.LocalDate | ||
|
||
internal fun Route.resendStatistikkRoute( | ||
resendStatistikkhendelserService: ResendStatistikkhendelserService, | ||
) { | ||
data class Body( | ||
val fraOgMed: String, | ||
) | ||
|
||
post("/drift/resend-statistikk/vedtak/søknadsbehandling") { | ||
authorize(Brukerrolle.Drift) { | ||
call.withBody<Body> { body -> | ||
CoroutineScope(Dispatchers.IO).launch { | ||
resendStatistikkhendelserService.resendIverksattSøknadsbehandling(LocalDate.parse(body.fraOgMed)) | ||
} | ||
|
||
call.svar(Resultat.json(HttpStatusCode.Accepted, """{"status": "Accepted"}""")) | ||
} | ||
} | ||
} | ||
} |
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.