From 724ca237f414eace3e7c39e0fc8f709cc7eb83d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98yvind=20N=2E=20Wed=C3=B8e?= Date: Tue, 10 Dec 2024 13:40:03 +0100 Subject: [PATCH] Create merkantil task when unable to assign behandling after creation. --- .../oppgave/service/ExternalMottakFacade.kt | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/no/nav/klage/oppgave/service/ExternalMottakFacade.kt b/src/main/kotlin/no/nav/klage/oppgave/service/ExternalMottakFacade.kt index 549f0f498..47d22399b 100644 --- a/src/main/kotlin/no/nav/klage/oppgave/service/ExternalMottakFacade.kt +++ b/src/main/kotlin/no/nav/klage/oppgave/service/ExternalMottakFacade.kt @@ -33,7 +33,7 @@ class ExternalMottakFacade( val behandling = mottakService.createMottakForKlageAnkeV3(oversendtKlageAnke) if (oversendtKlageAnke.saksbehandlerIdent != null) { - setSaksbehandler(behandling = behandling, saksbehandlerIdent = oversendtKlageAnke.saksbehandlerIdent) + tryToSetSaksbehandler(behandling = behandling, saksbehandlerIdent = oversendtKlageAnke.saksbehandlerIdent) } tryToSendSvarbrev(behandling, hindreAutomatiskSvarbrev = oversendtKlageAnke.hindreAutomatiskSvarbrev == true) @@ -49,7 +49,7 @@ class ExternalMottakFacade( val behandling = mottakService.createMottakForKlageAnkeV3(oversendtKlageAnke) if (oversendtKlageAnke.saksbehandlerIdent != null) { - setSaksbehandler(behandling = behandling, saksbehandlerIdent = oversendtKlageAnke.saksbehandlerIdent) + tryToSetSaksbehandler(behandling = behandling, saksbehandlerIdent = oversendtKlageAnke.saksbehandlerIdent) } tryToSendSvarbrev(behandling, hindreAutomatiskSvarbrev = oversendtKlageAnke.hindreAutomatiskSvarbrev == true) @@ -74,6 +74,23 @@ class ExternalMottakFacade( } } + private fun tryToSetSaksbehandler( + behandling: Behandling, + saksbehandlerIdent: String + ) { + try { + setSaksbehandler( + behandling = behandling, + saksbehandlerIdent = saksbehandlerIdent, + ) + } catch (e: Exception) { + mottakService.createTaskForMerkantil( + behandlingId = behandling.id, + reason = "Klarte ikke å tildele behandling ${behandling.id} til saksbehandlerIdent $saksbehandlerIdent. Feilmelding: ${e.message}" + ) + } + } + private fun setSaksbehandler(behandling: Behandling, saksbehandlerIdent: String) { logger.debug("Preparing to set saksbehandler. Getting enhet for saksbehandler $saksbehandlerIdent") val enhetForSaksbehandler = try {