@@ -29,52 +29,58 @@ internal class Uttrekksjobb(private val dataSource: DataSource, private val clie
29
29
}
30
30
31
31
internal suspend fun hentInntekterOgSjekk () {
32
- delay(TimeUnit .SECONDS .toMillis(10 ))
33
- val stringBuilder = StringBuilder ().append(System .lineSeparator()).append(" ***********************************************" )
34
- inntekter.forEach { inntektId ->
35
- val result = using(sessionOf(dataSource)) { session ->
36
- session.run (
37
- queryOf(
38
- " SELECT kontekstid, beregningsdato, aktørId FROM inntekt_v1_person_mapping WHERE inntektid = :id " ,
39
- mapOf (
40
- " id" to inntektId
41
- )
42
- ).map {
43
- Result (
44
- inntektsId = inntektId,
45
- beregningsdato = it.localDate(" beregningsdato" ),
46
- vedtakId = it.int(" kontekstid" ),
47
- aktørId = it.string(" aktørId" ),
48
- )
49
- }.asSingle
50
- ) ? : throw IllegalStateException (" Kunne ikke hendte id" )
51
- }
52
- val inntekt: InntektkomponentResponse = client.getInntekt(
53
- InntektkomponentRequest (
54
- aktørId = result.aktørId,
55
- månedFom = result.opptjeningsperiode.sisteAvsluttendeKalenderMåned,
56
- månedTom = result.opptjeningsperiode.førsteMåned
32
+ try {
33
+ delay(TimeUnit .SECONDS .toMillis(10 ))
34
+ logger.info { " Starter Uttrekksjobb " }
35
+ val stringBuilder = StringBuilder ().append(System .lineSeparator()).append(" ***********************************************" )
36
+ inntekter.forEach { inntektId ->
37
+ val result = using(sessionOf(dataSource)) { session ->
38
+ session.run (
39
+ queryOf(
40
+ " SELECT kontekstid, beregningsdato, aktørId FROM inntekt_v1_person_mapping WHERE inntektid = :id " ,
41
+ mapOf (
42
+ " id" to inntektId
43
+ )
44
+ ).map {
45
+ Result (
46
+ inntektsId = inntektId,
47
+ beregningsdato = it.localDate(" beregningsdato" ),
48
+ vedtakId = it.int(" kontekstid" ),
49
+ aktørId = it.string(" aktørId" ),
50
+ )
51
+ }.asSingle
52
+ ) ? : throw IllegalStateException (" Kunne ikke hendte id" )
53
+ }
54
+ val inntekt: InntektkomponentResponse = client.getInntekt(
55
+ InntektkomponentRequest (
56
+ aktørId = result.aktørId,
57
+ månedFom = result.opptjeningsperiode.førsteMåned,
58
+ månedTom = result.opptjeningsperiode.sisteAvsluttendeKalenderMåned
59
+ )
57
60
)
58
- )
59
- val sisteMnd: ArbeidsInntektMaaned ? =
60
- inntekt.arbeidsInntektMaaned?.maxByOrNull { it.aarMaaned }
61
+ val sisteMnd: ArbeidsInntektMaaned ? =
62
+ inntekt.arbeidsInntektMaaned?.maxByOrNull { it.aarMaaned }
61
63
62
- stringBuilder.append(System .lineSeparator()).append(" Inntekt" ).append(" \t " )
64
+ stringBuilder.append(System .lineSeparator()).append(" Inntekt" ).append(" \t " )
63
65
64
- if (sisteMnd == null ) {
66
+ if (sisteMnd == null ) {
65
67
66
- stringBuilder.append(" Tom arbeids inntekt maaned $inntektId " )
67
- } else if (sisteMnd.arbeidsInntektInformasjon == null ) {
68
- stringBuilder.append(" Tom arbeidsInntektInformasjon $inntektId " )
69
- } else if (sisteMnd.arbeidsInntektInformasjon.inntektListe?.isEmpty() == true ) {
70
- stringBuilder.append(" Tom inntektList $inntektId " )
71
- } else if (sisteMnd.arbeidsInntektInformasjon.inntektListe?.isEmpty() == false ) {
72
- stringBuilder.append(" Ikke tom inntektList $inntektId " )
68
+ stringBuilder.append(" Tom arbeids inntekt maaned $inntektId " )
69
+ } else if (sisteMnd.arbeidsInntektInformasjon == null ) {
70
+ stringBuilder.append(" Tom arbeidsInntektInformasjon $inntektId " )
71
+ } else if (sisteMnd.arbeidsInntektInformasjon.inntektListe?.isEmpty() == true ) {
72
+ stringBuilder.append(" Tom inntektList $inntektId " )
73
+ } else if (sisteMnd.arbeidsInntektInformasjon.inntektListe?.isEmpty() == false ) {
74
+ stringBuilder.append(" Ikke tom inntektList $inntektId " )
75
+ }
73
76
}
74
- }
75
- stringBuilder.append(System .lineSeparator()).append(" ***********************************************" )
76
- logger.info {
77
- stringBuilder.toString()
77
+ stringBuilder.append(System .lineSeparator()).append(" ***********************************************" )
78
+ logger.info {
79
+ stringBuilder.toString()
80
+ }
81
+ logger.info { " Uttrekksjobb ferdig" }
82
+ } catch (e: Exception ) {
83
+ logger.error(e) { " Uttrekksjobb feilet" }
78
84
}
79
85
}
80
86
0 commit comments