-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #438 from MTES-MCT/feat/mission-interservices
feat: introduce missions inter-services
- Loading branch information
Showing
90 changed files
with
3,909 additions
and
1,174 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
...ain/kotlin/fr/gouv/dgampa/rapportnav/domain/entities/mission/nav/export/ExportModeEnum.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package fr.gouv.dgampa.rapportnav.domain.entities.mission.nav.export | ||
|
||
// if you update this enum, update it too in the API and frontend | ||
enum class ExportModeEnum { | ||
INDIVIDUAL_MISSION, // Export one single mission into one document | ||
COMBINED_MISSIONS_IN_ONE, // Export several missions combined into one mission into one document | ||
MULTIPLE_MISSIONS_ZIPPED // Export several missions into several documents into a zip | ||
} |
8 changes: 8 additions & 0 deletions
8
...tlin/fr/gouv/dgampa/rapportnav/domain/entities/mission/nav/export/ExportReportTypeEnum.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package fr.gouv.dgampa.rapportnav.domain.entities.mission.nav.export | ||
|
||
// if you update this enum, update it too in the API and frontend | ||
enum class ExportReportTypeEnum { | ||
ALL, // all at once | ||
AEM, // aka tableaux AEM | ||
PATROL // aka rapport de patrouille | ||
} |
6 changes: 0 additions & 6 deletions
6
...in/fr/gouv/dgampa/rapportnav/domain/entities/mission/nav/export/MissionAEMExportEntity.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 0 additions & 93 deletions
93
.../kotlin/fr/gouv/dgampa/rapportnav/domain/use_cases/mission/export/ExportZipMissionsAEM.kt
This file was deleted.
Oops, something went wrong.
62 changes: 62 additions & 0 deletions
62
.../fr/gouv/dgampa/rapportnav/domain/use_cases/mission/export/v2/ExportMissionAEMCombined.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package fr.gouv.dgampa.rapportnav.domain.use_cases.mission.export.v2 | ||
|
||
import fr.gouv.dgampa.rapportnav.config.UseCase | ||
import fr.gouv.dgampa.rapportnav.domain.entities.mission.MissionEntity | ||
import fr.gouv.dgampa.rapportnav.domain.entities.mission.nav.export.MissionExportEntity | ||
import fr.gouv.dgampa.rapportnav.domain.use_cases.mission.GetMission | ||
import fr.gouv.dgampa.rapportnav.domain.use_cases.utils.FormatDateTime | ||
import org.slf4j.LoggerFactory | ||
|
||
@UseCase | ||
class ExportMissionAEMCombined( | ||
private val formatDateTime: FormatDateTime, | ||
private val exportMissionAEMSingle: ExportMissionAEMSingle, | ||
private val getMissionById: GetMission, | ||
) { | ||
|
||
private val logger = LoggerFactory.getLogger(ExportMissionAEMCombined::class.java) | ||
|
||
|
||
/** | ||
* Returns a merged Rapport de Patrouille | ||
* Taking several missions and combining them into one | ||
* | ||
* @param missionIds a list of Mission Ids | ||
* @return a MissionExportEntity with file name and content | ||
*/ | ||
fun execute(missionIds: List<Int>): MissionExportEntity? { | ||
|
||
try { | ||
|
||
// retrieve missions | ||
var missions = mutableListOf<MissionEntity>() | ||
|
||
for (missionId in missionIds) { | ||
val mission = getMissionById.execute(missionId) | ||
if (mission != null) { | ||
missions.add(mission) | ||
} | ||
} | ||
|
||
// bundle actions and other stuff | ||
val firstMission = missions.first() // Take all other fields from the first mission | ||
val combinedActions = missions.flatMap { it.actions.orEmpty() } // Aggregate all actions from all missions | ||
val mission = | ||
firstMission.copy(actions = MissionEntity.sortActions(combinedActions)) // Create a new instance with aggregated actions | ||
|
||
// create file | ||
val output = exportMissionAEMSingle.createFile(mission = mission) | ||
|
||
|
||
return MissionExportEntity( | ||
fileName = "tableaux-AEM-combinés_${formatDateTime.formatDate(missions.first().startDateTimeUtc)}.ods", | ||
fileContent = output?.fileContent.orEmpty() | ||
) | ||
|
||
} catch (e: Exception) { | ||
logger.error("[AEM] - error while generating report : ${e.message}") | ||
return null | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.