-
Notifications
You must be signed in to change notification settings - Fork 2
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
Behandle automatisk inntekt task #2815
Changes from 10 commits
e0dae7b
097e7f7
8e8fd8c
05de769
6f769c7
60ff710
489c87a
e75acb5
511ca6d
81e79b7
a945414
af8cf31
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
package no.nav.familie.ef.sak.behandling.revurdering | ||
|
||
import no.nav.familie.ef.sak.behandling.BehandlingService | ||
import no.nav.familie.ef.sak.behandling.domain.BehandlingType | ||
import no.nav.familie.ef.sak.fagsak.FagsakService | ||
import no.nav.familie.ef.sak.fagsak.domain.Fagsak | ||
import no.nav.familie.ef.sak.infrastruktur.config.ObjectMapperProvider.objectMapper | ||
import no.nav.familie.ef.sak.infrastruktur.featuretoggle.FeatureToggleService | ||
import no.nav.familie.ef.sak.infrastruktur.featuretoggle.Toggle | ||
import no.nav.familie.kontrakter.ef.felles.BehandlingÅrsak | ||
import no.nav.familie.kontrakter.felles.ef.StønadType | ||
import no.nav.familie.prosessering.AsyncTaskStep | ||
import no.nav.familie.prosessering.TaskStepBeskrivelse | ||
import no.nav.familie.prosessering.domene.Task | ||
import org.slf4j.LoggerFactory | ||
import org.springframework.stereotype.Service | ||
import java.util.Properties | ||
|
||
data class PayloadBehandleAutomatiskInntektsendringTask( | ||
val personIdent: String, | ||
val ukeÅr: String, | ||
) | ||
|
||
@Service | ||
@TaskStepBeskrivelse( | ||
taskStepType = BehandleAutomatiskInntektsendringTask.TYPE, | ||
beskrivelse = "Skal automatisk opprette en ny behandling ved automatisk inntektsendring", | ||
) | ||
class BehandleAutomatiskInntektsendringTask( | ||
private val behandlingService: BehandlingService, | ||
private val fagsakService: FagsakService, | ||
private val featureToggleService: FeatureToggleService, | ||
) : AsyncTaskStep { | ||
private val secureLogger = LoggerFactory.getLogger("secureLogger") | ||
|
||
override fun doTask(task: Task) { | ||
val toggle = featureToggleService.isEnabled(Toggle.BEHANDLE_AUTOMATISK_INNTEKTSENDRING) | ||
|
||
val personIdent = task.payload | ||
val fagsak = | ||
fagsakService.finnFagsak( | ||
personIdenter = setOf(personIdent), | ||
stønadstype = StønadType.OVERGANGSSTØNAD, | ||
) | ||
|
||
loggInfoOpprett(personIdent, fagsak) | ||
|
||
if (toggle) { | ||
if (fagsak != null) { | ||
loggInfoOpprett(personIdent, fagsak) | ||
|
||
behandlingService.opprettBehandling( | ||
behandlingType = BehandlingType.REVURDERING, | ||
fagsakId = fagsak.id, | ||
behandlingsårsak = BehandlingÅrsak.AUTOMATISK_INNTEKTSENDRING, | ||
) | ||
} else { | ||
secureLogger.error("Finner ikke fagsak for personIdent=$personIdent på stønadstype=${StønadType.OVERGANGSSTØNAD} under automatisk inntektsendring") | ||
} | ||
} | ||
} | ||
|
||
companion object { | ||
const val TYPE = "behandleAutomatiskInntektsendringTask" | ||
|
||
fun opprettTask(payload: String): Task { | ||
val payloadObject = objectMapper.readValue(payload, PayloadBehandleAutomatiskInntektsendringTask::class.java) | ||
|
||
return Task( | ||
type = TYPE, | ||
payload = payload, | ||
properties = | ||
Properties().apply { | ||
this["personIdent"] = payloadObject.personIdent | ||
}, | ||
) | ||
} | ||
} | ||
|
||
fun loggInfoOpprett( | ||
personIdent: String, | ||
fagsak: Fagsak?, | ||
) { | ||
secureLogger.info("Kan opprette behandling med $personIdent stønadstype=${StønadType.OVERGANGSSTØNAD} faksakId ${fagsak?.id}") | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -81,4 +81,11 @@ class RevurderingController( | |
tilgangService.validerTilgangTilBehandling(behandlingId, AuditLoggerEvent.ACCESS) | ||
return Ressurs.success(revurderingService.hentRevurderingsinformasjon(behandlingId)) | ||
} | ||
|
||
@PostMapping("opprett-automatisk") | ||
fun opprettAutomatiskInntektsendringsTask( | ||
@RequestBody personIdenter: List<String>, | ||
) { | ||
revurderingService.opprettAutomatiskInntektsendringTask(personIdenter) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Kunne dette like greit vært gjort i endepunktet There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Enig i det, byttet 👍 |
||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍