-
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 #477 from MTES-MCT/feature/474-aem-v2
feat(AEM): v2 of AEM base on mission-action
- Loading branch information
Showing
29 changed files
with
1,960 additions
and
0 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
.../src/main/kotlin/fr/gouv/dgampa/rapportnav/domain/entities/aem/v2/AEMCulturalMaritime2.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,37 @@ | ||
package fr.gouv.dgampa.rapportnav.domain.entities.aem.v2 | ||
|
||
import fr.gouv.dgampa.rapportnav.domain.entities.mission.v2.MissionEnvActionEntity | ||
import fr.gouv.dgampa.rapportnav.domain.utils.AEMUtils | ||
|
||
data class AEMCulturalMaritime2( | ||
val nbrOfHourAtSea: Double? = 0.0, //4.4.1 | ||
val nbrOfScientificOperation: Double? = 0.0, // 4.4.2 | ||
val nbrOfBCMPoliceOperation: Double? = 0.0, // 4.4.3 | ||
) { | ||
constructor( | ||
envActions: List<MissionEnvActionEntity?> | ||
) : this( | ||
nbrOfScientificOperation = scientificCampaignActionEntities(envActions).size.toDouble(), | ||
nbrOfBCMPoliceOperation = culturalMaritimeActionEntities(envActions).size.toDouble(), | ||
nbrOfHourAtSea = AEMUtils.getDurationInHours2(culturalMaritimeActionEntities(envActions)), | ||
) | ||
|
||
companion object { | ||
private val scientificCampaignControlPlanSubThemeIds = listOf(165); | ||
private val culturalMaritimeWellBeingControlPlanThemeIds = listOf(104); | ||
private fun culturalMaritimeActionEntities(envActions: List<MissionEnvActionEntity?>): List<MissionEnvActionEntity?> { | ||
return envActions.filter { action -> | ||
action?.controlPlans?.map { c -> c.themeId } | ||
?.intersect(culturalMaritimeWellBeingControlPlanThemeIds)?.isEmpty() == false | ||
} | ||
} | ||
|
||
private fun scientificCampaignActionEntities(envActions: List<MissionEnvActionEntity?>): List<MissionEnvActionEntity?> { | ||
return envActions.filter { action -> | ||
action?.controlPlans?.flatMap { it.subThemeIds!! } | ||
?.intersect(scientificCampaignControlPlanSubThemeIds)?.isEmpty() == false | ||
} | ||
} | ||
} | ||
} | ||
|
38 changes: 38 additions & 0 deletions
38
backend/src/main/kotlin/fr/gouv/dgampa/rapportnav/domain/entities/aem/v2/AEMEnvTraffic2.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,38 @@ | ||
package fr.gouv.dgampa.rapportnav.domain.entities.aem.v2 | ||
|
||
import fr.gouv.dgampa.rapportnav.domain.entities.mission.v2.MissionEnvActionEntity | ||
import fr.gouv.dgampa.rapportnav.domain.utils.AEMUtils | ||
|
||
data class AEMEnvTraffic2( | ||
val nbrOfHourAtSea: Double? = 0.0, //3.3.1 | ||
val nbrOfRedirectShip: Double? = 0.0, // 3.3.3 | ||
val nbrOfSeizure: Double? = 0.0 // 3.3.4 | ||
) { | ||
constructor( | ||
envActions: List<MissionEnvActionEntity?> | ||
) : this( | ||
nbrOfHourAtSea = AEMUtils.getDurationInHours2(protectedSpeciesActionEntities(envActions)), | ||
nbrOfRedirectShip = getNbrRedirectShip(envActions), | ||
nbrOfSeizure = getNbrOfSeizure(envActions) | ||
) {} | ||
companion object { | ||
private val protectedSpeciesControlPlanThemeIds = listOf(103); | ||
fun getNbrRedirectShip(envActions: List<MissionEnvActionEntity?>): Double { | ||
return 0.0; //TODO Complete from MonitorEnv | ||
} | ||
|
||
fun getNbrOfSeizure(envActions: List<MissionEnvActionEntity?>): Double { | ||
return 0.0; //TODO Complete from MonitorEnv | ||
} | ||
|
||
fun protectedSpeciesActionEntities(envActions: List<MissionEnvActionEntity?>): List<MissionEnvActionEntity?> { | ||
|
||
val protectedSpeciesActions = envActions.filter { | ||
it?.controlPlans?.map { c -> c.themeId } | ||
?.intersect(protectedSpeciesControlPlanThemeIds)?.isEmpty() == false | ||
} | ||
return protectedSpeciesActions; | ||
} | ||
|
||
} | ||
} |
76 changes: 76 additions & 0 deletions
76
backend/src/main/kotlin/fr/gouv/dgampa/rapportnav/domain/entities/aem/v2/AEMIllegalFish2.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,76 @@ | ||
package fr.gouv.dgampa.rapportnav.domain.entities.aem.v2 | ||
|
||
import fr.gouv.dgampa.rapportnav.domain.entities.mission.fish.fishActions.InfractionType | ||
import fr.gouv.dgampa.rapportnav.domain.entities.mission.v2.MissionFishActionEntity | ||
import fr.gouv.dgampa.rapportnav.domain.utils.ComputeDurationUtils | ||
|
||
data class AEMIllegalFish2( | ||
val nbrOfHourAtSea: Double? = 0.0, //4.3.1 | ||
val nbrOfPolFishAction: Double? = 0.0, // 4.3.3 | ||
val nbrOfTargetedVessel: Double? = 0.0, // 4.3.5 | ||
val nbrOfInfractionWithPV: Double? = 0.0, // 4.3.6 | ||
val nbrOfInfraction: Double? = 0.0, // 4.3.7 | ||
val nbrOfSeizureAndDiversionVessel: Double? = 0.0, // 4.3.8 | ||
val quantityOfFish: Double? = 0.0 //4.3.9 | ||
) { | ||
constructor( | ||
fishActions: List<MissionFishActionEntity?> | ||
) : this( | ||
nbrOfHourAtSea = getNbrOfHourAtSea(fishActions), | ||
nbrOfPolFishAction = fishActions.size.toDouble(), | ||
nbrOfTargetedVessel = fishActions.size.toDouble(), | ||
nbrOfInfraction = getNbrOfInfraction(fishActions), | ||
nbrOfInfractionWithPV = getNbrOfInfractionWithPV(fishActions), | ||
nbrOfSeizureAndDiversionVessel = getNbrOfSeizureAndDiversionVessel(fishActions), | ||
quantityOfFish = getQuantityOfFish(fishActions) | ||
) { | ||
} | ||
|
||
companion object { | ||
fun getNbrOfHourAtSea(fishActions: List<MissionFishActionEntity?>): Double { | ||
return fishActions.fold(0.0) { acc, fishAction -> | ||
acc.plus( | ||
ComputeDurationUtils.durationInHours( | ||
startDateTimeUtc = fishAction?.startDateTimeUtc, | ||
endDateTimeUtc = fishAction?.endDateTimeUtc | ||
) | ||
) | ||
}; | ||
} | ||
|
||
fun getNbrOfInfraction(fishActions: List<MissionFishActionEntity?>): Double { | ||
return fishActions.filterNotNull().fold(0.0) { acc, c -> | ||
acc.plus(c.gearInfractions?.count { it.natinf != null } ?: 0) | ||
.plus(c.otherInfractions?.count { it.natinf != null } ?: 0) | ||
.plus(c.speciesInfractions?.count { it.natinf != null } ?: 0) | ||
.plus(c.logbookInfractions?.count { it.natinf != null } ?: 0) | ||
}; | ||
} | ||
|
||
fun getNbrOfInfractionWithPV(fishActions: List<MissionFishActionEntity?>): Double { | ||
return fishActions.filterNotNull() | ||
.fold(0.0) { acc, c -> | ||
acc.plus(c.gearInfractions?.filter { g -> g.infractionType == InfractionType.WITH_RECORD }?.size ?: 0) | ||
.plus( | ||
c.otherInfractions?.filter { o -> o.infractionType == InfractionType.WITH_RECORD }?.size ?: 0 | ||
) | ||
.plus( | ||
c.speciesInfractions?.filter { s -> s.infractionType == InfractionType.WITH_RECORD }?.size ?: 0 | ||
) | ||
.plus( | ||
c.logbookInfractions?.filter { l -> l.infractionType == InfractionType.WITH_RECORD }?.size ?: 0 | ||
) | ||
}; | ||
} | ||
|
||
fun getNbrOfSeizureAndDiversionVessel(fishActions: List<MissionFishActionEntity?>): Double { | ||
return fishActions.filter { it?.seizureAndDiversion == true }.size.toDouble(); | ||
} | ||
|
||
fun getQuantityOfFish(fishActions: List<MissionFishActionEntity?>): Double { | ||
return fishActions | ||
.filterNotNull() | ||
.sumOf { it.speciesQuantitySeized?.toDouble() ?: 0.0 } } | ||
|
||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
...rc/main/kotlin/fr/gouv/dgampa/rapportnav/domain/entities/aem/v2/AEMIllegalImmigration2.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,51 @@ | ||
package fr.gouv.dgampa.rapportnav.domain.entities.aem.v2 | ||
|
||
import fr.gouv.dgampa.rapportnav.domain.entities.mission.nav.action.ActionType | ||
import fr.gouv.dgampa.rapportnav.domain.entities.mission.v2.MissionNavActionEntity | ||
import fr.gouv.dgampa.rapportnav.domain.utils.AEMUtils | ||
|
||
data class AEMIllegalImmigration2( | ||
val nbrOfHourAtSea: Double? = 0.0, //3.4.1 | ||
val nbrOfInterceptedVessel: Double? = 0.0, // 3.4.3 | ||
val nbrOfInterceptedMigrant: Double? = 0.0, // 3.4.4 | ||
val nbrOfSuspectedSmuggler: Double? = 0.0 // 3.4.4 | ||
) { | ||
constructor( | ||
navActions: List<MissionNavActionEntity> | ||
) : this( | ||
nbrOfHourAtSea = AEMUtils.getDurationInHours2(getIllegalActions(navActions)), | ||
nbrOfInterceptedVessel = getNbrOfInterceptedVessel(getIllegalActions(navActions)), | ||
nbrOfInterceptedMigrant = getNbrOfInterceptedMigrant(getIllegalActions(navActions)), | ||
nbrOfSuspectedSmuggler = getNbrOfSuspectedSmuggler(getIllegalActions(navActions)) | ||
) {} | ||
|
||
companion object { | ||
fun getNbrOfInterceptedVessel(illegalActions: List<MissionNavActionEntity?>): Double { | ||
return illegalActions.fold(0.0) { acc, illegalAction -> | ||
acc.plus( | ||
illegalAction?.nbOfInterceptedVessels ?: 0 | ||
) | ||
} | ||
} | ||
|
||
fun getNbrOfInterceptedMigrant(illegalActions: List<MissionNavActionEntity?>): Double { | ||
return illegalActions.fold(0.0) { acc, illegalAction -> | ||
acc.plus( | ||
illegalAction?.nbOfInterceptedMigrants ?: 0 | ||
) | ||
} | ||
} | ||
|
||
fun getNbrOfSuspectedSmuggler(illegalActions: List<MissionNavActionEntity?>): Double { | ||
return illegalActions.fold(0.0) { acc, illegalAction -> | ||
acc.plus( | ||
illegalAction?.nbOfSuspectedSmugglers ?: 0 | ||
) | ||
} | ||
} | ||
|
||
private fun getIllegalActions(navActions: List<MissionNavActionEntity>): List<MissionNavActionEntity?> { | ||
return navActions.filter { it.actionType == ActionType.ILLEGAL_IMMIGRATION } | ||
} | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
...d/src/main/kotlin/fr/gouv/dgampa/rapportnav/domain/entities/aem/v2/AEMMigrationRescue2.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,57 @@ | ||
package fr.gouv.dgampa.rapportnav.domain.entities.aem.v2 | ||
|
||
import fr.gouv.dgampa.rapportnav.domain.entities.mission.nav.action.ActionType | ||
import fr.gouv.dgampa.rapportnav.domain.entities.mission.v2.MissionNavActionEntity | ||
import fr.gouv.dgampa.rapportnav.domain.utils.AEMUtils | ||
|
||
data class AEMMigrationRescue2( | ||
val nbrOfHourAtSea: Double? = 0.0, // 1.2.1 | ||
val nbrOfOperation: Double? = 0.0,// 1.2.3 | ||
val nbrOfVesselsTrackedWithoutIntervention: Double? = 0.0, //1.2.4 | ||
val nbrAssistedVesselsReturningToShore: Double? = 0.0, //1.2.5 | ||
val nbrOfRescuedOperation: Double? = 0.0, //1.2.6 | ||
val nbrPersonsRescued: Double? = 0.0,// 1.2.7 | ||
) { | ||
constructor( | ||
navActions: List<MissionNavActionEntity> | ||
) : this( | ||
nbrOfRescuedOperation = getMigrationRescueActions(navActions).size.toDouble(), | ||
nbrOfHourAtSea = AEMUtils.getDurationInHours2(getMigrationRescueActions(navActions)), | ||
nbrPersonsRescued = getNbrPersonsRescued(getMigrationRescueActions(navActions)), | ||
nbrOfOperation = getMigrationRescueActions(navActions).size.toDouble(), //TODO: Define correctly what that means | ||
nbrAssistedVesselsReturningToShore = getAssistedVesselsReturningToShore(getMigrationRescueActions(navActions)), | ||
nbrOfVesselsTrackedWithoutIntervention = getNbrOfVesselsTrackedWithoutIntervention( | ||
getMigrationRescueActions( | ||
navActions | ||
) | ||
) | ||
|
||
) | ||
|
||
companion object { | ||
fun getNbrPersonsRescued(actionRescues: List<MissionNavActionEntity?>): Double { | ||
return actionRescues.fold(0.0) { acc, actionRescue -> acc.plus(actionRescue?.numberPersonsRescued ?: 0) } | ||
} | ||
|
||
fun getNbrOfVesselsTrackedWithoutIntervention(actionRescues: List<MissionNavActionEntity?>): Double { | ||
return actionRescues.fold(0.0) { acc, actionRescue -> | ||
acc.plus( | ||
actionRescue?.nbOfVesselsTrackedWithoutIntervention ?: 0 | ||
) | ||
} | ||
} | ||
|
||
fun getAssistedVesselsReturningToShore(actionRescues: List<MissionNavActionEntity?>): Double { | ||
return actionRescues.fold(0.0) { acc, actionRescue -> | ||
acc.plus( | ||
actionRescue?.nbAssistedVesselsReturningToShore ?: 0 | ||
) | ||
} | ||
} | ||
|
||
private fun getMigrationRescueActions(navActions: List<MissionNavActionEntity>): List<MissionNavActionEntity?> { | ||
return navActions.filter { it.actionType == ActionType.RESCUE } | ||
.filter { it.isMigrationRescue == true } | ||
} | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
...n/fr/gouv/dgampa/rapportnav/domain/entities/aem/v2/AEMNotPollutionControlSurveillance2.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,50 @@ | ||
package fr.gouv.dgampa.rapportnav.domain.entities.aem.v2 | ||
|
||
import fr.gouv.dgampa.rapportnav.domain.entities.mission.env.envActions.InfractionTypeEnum | ||
import fr.gouv.dgampa.rapportnav.domain.entities.mission.v2.MissionEnvActionEntity | ||
import fr.gouv.dgampa.rapportnav.domain.utils.AEMUtils | ||
|
||
data class AEMNotPollutionControlSurveillance2( | ||
val nbrOfHourAtSea: Double? = 0.0, //4.1.1 | ||
val nbrOfAction: Double? = 0.0, // 4.1.3 | ||
val nbrOfInfraction: Double? = 0.0, // 4.1.4 | ||
val nbrOfInfractionWithNotice: Double? = 0.0 // 4.1.5 | ||
) { | ||
constructor( | ||
envActions: List<MissionEnvActionEntity?> | ||
) : this( | ||
nbrOfHourAtSea = AEMUtils.getDurationInHours2(getNotPollutionActions(envActions)), | ||
nbrOfAction = getNotPollutionActions(envActions).size.toDouble(), | ||
nbrOfInfraction = getNbrOfInfraction(getNotPollutionActions(envActions)), | ||
nbrOfInfractionWithNotice = getNbrOfInfractionWithNotice(getNotPollutionActions(envActions)) | ||
) { | ||
|
||
} | ||
|
||
companion object { | ||
|
||
fun getNbrOfInfraction(notPollutionActions: List<MissionEnvActionEntity?>): Double { | ||
return notPollutionActions | ||
.fold(0.0) { acc, c -> | ||
acc.plus(c?.envInfractions?.flatMap { it.natinf ?: listOf() }?.size ?: 0) | ||
} | ||
} | ||
|
||
fun getNbrOfInfractionWithNotice(notPollutionActions: List<MissionEnvActionEntity?>): Double { | ||
return notPollutionActions.fold(0.0) { acc, c -> | ||
acc.plus( | ||
c?.envInfractions?.filter { it.infractionType == InfractionTypeEnum.WITH_REPORT }?.size ?: 0 | ||
) | ||
} | ||
} | ||
|
||
private fun getNotPollutionActions(envActions: List<MissionEnvActionEntity?>): List<MissionEnvActionEntity?> { | ||
val illicitRejects = listOf(19, 102); | ||
return envActions.filter { | ||
it?.controlPlans?.map { c -> c.themeId }?.intersect(illicitRejects)?.isEmpty() == true | ||
} | ||
} | ||
|
||
} | ||
} | ||
|
31 changes: 31 additions & 0 deletions
31
.../main/kotlin/fr/gouv/dgampa/rapportnav/domain/entities/aem/v2/AEMOutOfMigrationRescue2.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,31 @@ | ||
package fr.gouv.dgampa.rapportnav.domain.entities.aem.v2 | ||
|
||
import fr.gouv.dgampa.rapportnav.domain.entities.mission.nav.action.ActionType | ||
import fr.gouv.dgampa.rapportnav.domain.entities.mission.v2.MissionNavActionEntity | ||
import fr.gouv.dgampa.rapportnav.domain.utils.AEMUtils | ||
|
||
data class AEMOutOfMigrationRescue2( | ||
val nbrOfHourAtSea: Double? = 0.0, //1.1.1 | ||
val nbrOfRescuedOperation: Double? = 0.0, //1.1.3. | ||
val nbrPersonsRescued: Double? = 0.0, //1.1.4 | ||
) { | ||
constructor( | ||
navActions: List<MissionNavActionEntity> | ||
) : this( | ||
nbrOfRescuedOperation = getMigrationRescueActions(navActions).size.toDouble(), | ||
nbrPersonsRescued = getNbrPersonsRescued(getMigrationRescueActions(navActions)), | ||
nbrOfHourAtSea = AEMUtils.getDurationInHours2(getMigrationRescueActions(navActions)), | ||
) { | ||
} | ||
|
||
companion object { | ||
fun getNbrPersonsRescued(actionRescues: List<MissionNavActionEntity?>): Double { | ||
return actionRescues.fold(0.0) { acc, actionRescue -> acc.plus(actionRescue?.numberPersonsRescued ?: 0) } | ||
} | ||
|
||
private fun getMigrationRescueActions(navActions: List<MissionNavActionEntity>): List<MissionNavActionEntity?> { | ||
return navActions.filter { it.actionType == ActionType.RESCUE } | ||
.filter { it.isMigrationRescue != true }; | ||
} | ||
} | ||
} |
Oops, something went wrong.