Skip to content

Commit

Permalink
Rapport de patrouille - use dates as strings
Browse files Browse the repository at this point in the history
  • Loading branch information
lwih committed Mar 13, 2024
1 parent ea6f70f commit 777d886
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@ package fr.gouv.dgampa.rapportnav.domain.repositories.mission

import fr.gouv.dgampa.rapportnav.domain.entities.mission.nav.crew.MissionCrewEntity
import fr.gouv.dgampa.rapportnav.domain.entities.mission.nav.export.MissionExportEntity
import java.time.LocalDate
import java.time.ZonedDateTime

data class ExportParams(
val service: String?,
val id: String,
val startDateTime: ZonedDateTime?,
val endDateTime: ZonedDateTime?,
val startDateTime: String?,
val endDateTime: String?,
val presenceMer: Map<String, Int>,
val presenceQuai: Map<String, Int>,
val indisponibilite: Map<String, Int>,
Expand All @@ -21,7 +19,7 @@ data class ExportParams(
val goMarine: Float?,
val essence: Float?,
val crew: List<MissionCrewEntity>,
val timeline: Map<LocalDate, List<String>>?
val timeline: Map<String, List<String>>?
)

interface IRpnExportRepository {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,21 @@ package fr.gouv.dgampa.rapportnav.domain.use_cases.mission.action

import fr.gouv.dgampa.rapportnav.config.UseCase
import fr.gouv.dgampa.rapportnav.domain.entities.mission.MissionActionEntity
import java.time.LocalDate

@UseCase
class GroupActionByDate {
fun execute(actions: List<MissionActionEntity>?): Map<LocalDate, List<MissionActionEntity>>? {
fun execute(actions: List<MissionActionEntity>?): Map<String, List<MissionActionEntity>>? {
return actions?.groupBy { action ->
when (action) {
is MissionActionEntity.EnvAction -> action.envAction?.controlAction?.action?.actionStartDateTimeUtc?.toLocalDate()
is MissionActionEntity.FishAction -> action.fishAction.controlAction?.action?.actionDatetimeUtc?.toLocalDate()
is MissionActionEntity.NavAction -> action.navAction.startDateTimeUtc.toLocalDate()
is MissionActionEntity.EnvAction -> action.envAction?.controlAction?.action?.actionStartDateTimeUtc?.takeIf { true }
?.toLocalDate().toString()

is MissionActionEntity.FishAction -> action.fishAction.controlAction?.action?.actionDatetimeUtc?.takeIf { true }
?.toLocalDate().toString()

is MissionActionEntity.NavAction -> action.navAction.startDateTimeUtc.takeIf { true }
?.toLocalDate().toString()

else -> null // Handle other types of actions, if any
}
}?.mapNotNull { (date, actions) ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ class ExportMission(
val exportParams = ExportParams(
service = mission.openBy,
id = "pam" + mission.id,
startDateTime = mission.startDateTimeUtc,
endDateTime = mission.endDateTimeUtc,
startDateTime = mission.startDateTimeUtc.toString(),
endDateTime = mission.endDateTimeUtc?.toString(),
presenceMer = durations["atSeaDurations"].orEmpty(),
presenceQuai = durations["dockingDurations"].orEmpty(),
indisponibilite = durations["unavailabilityDurations"].orEmpty(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,20 @@ import fr.gouv.dgampa.rapportnav.domain.entities.mission.MissionActionEntity
import fr.gouv.dgampa.rapportnav.domain.entities.mission.env.envActions.EnvActionControlEntity
import fr.gouv.dgampa.rapportnav.domain.entities.mission.fish.fishActions.InfractionType
import fr.gouv.dgampa.rapportnav.domain.entities.mission.fish.fishActions.MissionAction
import fr.gouv.dgampa.rapportnav.domain.entities.mission.nav.action.*
import fr.gouv.dgampa.rapportnav.domain.entities.mission.nav.action.ActionControlEntity
import fr.gouv.dgampa.rapportnav.domain.entities.mission.nav.action.ActionFreeNoteEntity
import fr.gouv.dgampa.rapportnav.domain.entities.mission.nav.action.ActionStatusEntity
import fr.gouv.dgampa.rapportnav.domain.entities.mission.nav.action.ActionType
import fr.gouv.dgampa.rapportnav.domain.entities.mission.nav.status.mapActionStatusTypeToHumanString
import fr.gouv.dgampa.rapportnav.domain.use_cases.mission.action.GroupActionByDate
import java.time.LocalDate
import java.time.ZonedDateTime

@UseCase
class FormatActionsForTimeline(
private val groupActionByDate: GroupActionByDate,
) {

fun formatTimeline(actions: List<MissionActionEntity>?): Map<LocalDate, List<String>>? {
fun formatTimeline(actions: List<MissionActionEntity>?): Map<String, List<String>>? {

if (actions.isNullOrEmpty()) {
return null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ class APIRpnExportRepository(
val content = ExportMissionODTInput(
service = params.service,
id = params.id,
startDateTime = params.startDateTime?.toString(),
endDateTime = params.endDateTime?.toString(),
startDateTime = params.startDateTime,
endDateTime = params.endDateTime,
presenceMer = params.presenceMer,
presenceQuai = params.presenceQuai,
indisponibilite = params.indisponibilite,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package fr.gouv.dgampa.rapportnav.infrastructure.rapportnav1.adapters.inputs

import fr.gouv.dgampa.rapportnav.domain.entities.mission.nav.crew.MissionCrewEntity
import java.time.LocalDate

class ExportMissionODTInput (
class ExportMissionODTInput(
val service: String?,
val id: String?,
val startDateTime: String?,
Expand All @@ -19,5 +18,5 @@ class ExportMissionODTInput (
val goMarine: Float?,
val essence: Float?,
val crew: List<MissionCrewEntity>,
val timeline: Map<LocalDate, List<String>>?
val timeline: Map<String, List<String>>?
)

0 comments on commit 777d886

Please sign in to comment.