Skip to content

Commit

Permalink
Oppdatering av status feilet sjekker om kjøring er ferdigstilt
Browse files Browse the repository at this point in the history
  • Loading branch information
Bjodn committed Nov 21, 2024
1 parent 4d9225e commit f7f1c08
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import no.nav.etterlatte.libs.common.sak.KjoeringStatus
import no.nav.etterlatte.libs.common.sak.LagreKjoeringRequest
import no.nav.etterlatte.libs.common.sak.SakId
import no.nav.etterlatte.libs.database.setSakId
import no.nav.etterlatte.libs.database.single
import no.nav.etterlatte.libs.database.singleOrNull
import no.nav.etterlatte.libs.database.toList

class OmregningDao(
Expand Down Expand Up @@ -151,7 +151,7 @@ class OmregningDao(
fun hentNyligsteLinjeForKjoering(
kjoering: String,
sakId: SakId,
): Pair<Long, KjoeringStatus> =
): Pair<Long, KjoeringStatus>? =
connection.hentConnection { connection ->
with(connection) {
val statement =
Expand All @@ -166,7 +166,7 @@ class OmregningDao(
)
statement.setString(1, kjoering)
statement.setLong(2, sakId.sakId)
statement.executeQuery().single {
statement.executeQuery().singleOrNull {
Pair(
getLong("sak_id"),
KjoeringStatus.valueOf(getString("status")),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import no.nav.etterlatte.libs.common.sak.LagreKjoeringRequest
import no.nav.etterlatte.libs.common.sak.SakId
import no.nav.etterlatte.libs.ktor.token.BrukerTokenInfo
import no.nav.etterlatte.libs.ktor.token.HardkodaSystembruker
import no.nav.etterlatte.logger

class OmregningService(
private val behandlingService: BehandlingService,
Expand All @@ -26,6 +27,15 @@ class OmregningService(
bruker: BrukerTokenInfo,
) {
if (request.status == KjoeringStatus.FEILA) {
omregningDao.hentNyligsteLinjeForKjoering(request.kjoering, request.sakId)?.let { (_, sisteStatus) ->
if (sisteStatus.erFerdigstilt()) {
logger.error(
"Omregning har kjørt og feilet etter å ha blitt ferdigstilt. kjøring=${request.kjoering}, sak=${request.sakId}, feilendeSteg=${request.feilendeSteg}",
)
return
}
}

behandlingService.hentAapenOmregning(request.sakId)?.let {
if (it.status.kanAvbrytes()) {
behandlingService.avbrytBehandling(it.id, bruker)
Expand All @@ -42,8 +52,8 @@ class OmregningService(
omregningDao.lagreKjoering(request)
}

fun lagreDistribuertBrevEllerIverksattBehandlinga(request: KjoeringDistEllerIverksattRequest) {
val (_, sisteStatus) = omregningDao.hentNyligsteLinjeForKjoering(request.kjoering, request.sakId)
omregningDao.lagreDistribuertBrevEllerIverksattBehandlinga(request, sisteStatus)
}
fun lagreDistribuertBrevEllerIverksattBehandlinga(request: KjoeringDistEllerIverksattRequest) =
omregningDao.hentNyligsteLinjeForKjoering(request.kjoering, request.sakId)?.let { (_, sisteStatus) ->
omregningDao.lagreDistribuertBrevEllerIverksattBehandlinga(request, sisteStatus)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,22 @@ enum class KjoeringStatus {
KLAR,
STARTA,
FEILA,
IKKE_LOEPENDE,
IKKE_LOEPENDE, // Muligens ikke i bruk lenger?
FERDIGSTILT,
FERDIGSTILT_FATTET,
TIL_MANUELL,
TIL_MANUELL_UTEN_OPPGAVE,
;

fun erFerdigstilt() =
this in
listOf(
FERDIGSTILT,
FERDIGSTILT_FATTET,
TIL_MANUELL,
TIL_MANUELL_UTEN_OPPGAVE,
IKKE_LOEPENDE,
)
}

enum class DisttribuertEllerIverksatt {
Expand Down

0 comments on commit f7f1c08

Please sign in to comment.