Skip to content

Commit

Permalink
Avaries VMS - Clôturer les avaries quand ils émettent à quai et autom…
Browse files Browse the repository at this point in the history
…atiser l'envoi de la notification de reprise (#3490)

## Linked issues

- Resolve #3221

@louptheron J'ai fait
- [x] data : 
  - Une émission clôture une avarie, qu'elle soit à quai ou en mer
- Archivage et notification systématique (au préalable les navires en
statut autre que "Au port" passaient en "Fin d'avarie" et la
notification n'était pas envoyée automatiquement, il fallait une action
humaine)
- [x] Back : suppression du `stage` `END_OF_MALFUNCTION`.
- [x] il reste à virer la colonne du kanban dans le front

Il reste les données historiques en base de données, notamment les
actions de changement de `stage` qui incluent le `stage`
`END_OF_MALFUNCTION` donc au-delà de la suppression de la colonne "Fin
d'avarie" dans le kanban il faut peut-être faire gaffe à comment vont
s'afficher les changements de stage dans l'historique de ces avaries :


![image](https://github.com/user-attachments/assets/2636697a-538e-48fd-a4a0-770a98db242f)

C'est pour cette raison que je n'ai pas supprimé la valeur
`END_OF_MALFUNCTION` de l'Enum en back.

Ou alors il faut penser à une migration pour virer toutes ces data et
supprimer complètement ce stage des données.
  • Loading branch information
VincentAntoine committed Aug 7, 2024
2 parents e27282b + 1ed1ee5 commit 38813cf
Show file tree
Hide file tree
Showing 28 changed files with 141 additions and 508 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ class UpdateBeaconMalfunction(
require(vesselStatus != null || stage != null) {
"No value to update"
}
if (stage == Stage.END_OF_MALFUNCTION) {
if (stage == Stage.ARCHIVED) {
require(endOfBeaconMalfunctionReason != null) {
"Cannot end malfunction without giving an endOfBeaconMalfunctionReason"
"Cannot archive malfunction without giving an endOfBeaconMalfunctionReason"
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class GetVesselBeaconMalfunctions(

val resume = VesselBeaconMalfunctionsResume.fromBeaconMalfunctions(beaconMalfunctionsWithDetails)
val currentBeaconMalfunction = beaconMalfunctionsWithDetails.find {
it.beaconMalfunction.stage != Stage.ARCHIVED && it.beaconMalfunction.stage != Stage.END_OF_MALFUNCTION
it.beaconMalfunction.stage != Stage.ARCHIVED
}
val history = beaconMalfunctionsWithDetails.filter {
it.beaconMalfunction.id != currentBeaconMalfunction?.beaconMalfunction?.id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ class BeaconMalfunctionController(
private val getBeaconMalfunction: GetBeaconMalfunction,
private val saveBeaconMalfunctionComment: SaveBeaconMalfunctionComment,
private val requestNotification: RequestNotification,
private val archiveBeaconMalfunctions: ArchiveBeaconMalfunctions,
) {

@GetMapping(value = [""])
Expand Down Expand Up @@ -52,16 +51,6 @@ class BeaconMalfunctionController(
}
}

@PutMapping(value = ["/archive"], consumes = ["application/json"])
@Operation(summary = "Archive multiple beacon malfunctions")
fun archiveBeaconMalfunctions(
@RequestBody ids: List<Int>,
): List<BeaconMalfunctionResumeAndDetailsDataOutput> {
return archiveBeaconMalfunctions.execute(ids).map {
BeaconMalfunctionResumeAndDetailsDataOutput.fromBeaconMalfunctionResumeAndDetails(it)
}
}

@ResponseStatus(HttpStatus.CREATED)
@PostMapping(value = ["/{beaconMalfunctionId}/comments"], consumes = ["application/json"])
@Operation(summary = "Save a beacon malfunction comment and return the updated beacon malfunction")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ VALUES (1, 'FAK000999999', 'CALLME', 'DONTSINK', 'GB', 'INTERNAL_REFERENCE_NUMBE
'INITIAL_ENCOUNTER', NOW() - ('1 WEEK')::interval, null, NOW(), null, 1,
'MALFUNCTION_AT_SEA_INITIAL_NOTIFICATION', 'FGEDX85', 'ACTIVATED'),
(2, 'FAK000999999', 'CALLME', 'DONTSINK', 'GB', 'INTERNAL_REFERENCE_NUMBER', 'PHENOMENE', 'AT_SEA',
'END_OF_MALFUNCTION', NOW() - ('8 WEEKS')::interval, NOW() - ('6 WEEKS')::interval,
'ARCHIVED', NOW() - ('8 WEEKS')::interval, NOW() - ('6 WEEKS')::interval,
NOW() - ('6 WEEKS')::interval, 'RESUMED_TRANSMISSION', 1, null, 'FGEDX85', 'ACTIVATED'),
(3, 'U_W0NTFINDME', 'QGDF', 'TALK2ME', 'FR', 'IRCS', 'MALOTRU', 'NO_NEWS', 'FOUR_HOUR_REPORT',
NOW() - ('2 WEEK')::interval, null, NOW() - ('1 WEEK')::interval, null, 2, null, '123456', 'UNSUPERVISED'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ VALUES (3, 'STAGE', 'INITIAL_ENCOUNTER', 'AT_QUAY', NOW() - ('2 WEEK')::interval
(3, 'STAGE', 'AT_QUAY', 'FOUR_HOUR_REPORT', NOW() - ('1 WEEK')::interval),
(3, 'VESSEL_STATUS', 'AT_SEA', 'NO_NEWS', NOW() - ('1 DAY')::interval),
(1, 'VESSEL_STATUS', 'AT_PORT', 'ACTIVITY_DETECTED', NOW() - ('4 DAYS')::interval),
(2, 'STAGE', 'INITIAL_ENCOUNTER', 'END_OF_MALFUNCTION', NOW() - ('6 WEEK')::interval);
(2, 'STAGE', 'INITIAL_ENCOUNTER', 'ARCHIVED', NOW() - ('6 WEEK')::interval);
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class VesselBeaconMalfunctionsResumeUTests {
beaconMalfunction = BeaconMalfunction(
1, "FR224226850", "1236514", "IRCS",
"fr", VesselIdentifier.INTERNAL_REFERENCE_NUMBER, "BIDUBULE", VesselStatus.AT_SEA,
Stage.END_OF_MALFUNCTION, now.minusYears(2), null, now.minusYears(2),
Stage.ARCHIVED, now.minusYears(2), null, now.minusYears(2),
beaconNumber = "123465", beaconStatusAtMalfunctionCreation = BeaconStatus.ACTIVATED, vesselId = 123,
),
comments = listOf(
Expand All @@ -45,7 +45,7 @@ class VesselBeaconMalfunctionsResumeUTests {
beaconMalfunction = BeaconMalfunction(
2, "FR224226850", "1236514", "IRCS",
"fr", VesselIdentifier.INTERNAL_REFERENCE_NUMBER, "BIDUBULE", VesselStatus.AT_SEA,
Stage.END_OF_MALFUNCTION, now.minusMinutes(23), null, now.minusMinutes(23),
Stage.ARCHIVED, now.minusMinutes(23), null, now.minusMinutes(23),
beaconNumber = "123465", beaconStatusAtMalfunctionCreation = BeaconStatus.ACTIVATED, vesselId = 123,
),
comments = listOf(
Expand All @@ -70,7 +70,7 @@ class VesselBeaconMalfunctionsResumeUTests {
beaconMalfunction = BeaconMalfunction(
3, "FR224226850", "1236514", "IRCS",
"fr", VesselIdentifier.INTERNAL_REFERENCE_NUMBER, "BIDUBULE", VesselStatus.AT_SEA,
Stage.END_OF_MALFUNCTION, now.minusMinutes(5), null, now.minusMinutes(5),
Stage.ARCHIVED, now.minusMinutes(5), null, now.minusMinutes(5),
beaconNumber = "123465", beaconStatusAtMalfunctionCreation = BeaconStatus.ACTIVATED, vesselId = 123,
),
comments = listOf(
Expand Down Expand Up @@ -102,7 +102,7 @@ class VesselBeaconMalfunctionsResumeUTests {
beaconMalfunction = BeaconMalfunction(
4, "FR224226850", "1236514", "IRCS",
"fr", VesselIdentifier.INTERNAL_REFERENCE_NUMBER, "BIDUBULE", VesselStatus.AT_PORT,
Stage.END_OF_MALFUNCTION, lastBeaconDateTime, null, lastBeaconDateTime,
Stage.ARCHIVED, lastBeaconDateTime, null, lastBeaconDateTime,
beaconNumber = "123465", beaconStatusAtMalfunctionCreation = BeaconStatus.ACTIVATED, vesselId = 123,
),
comments = listOf(
Expand Down Expand Up @@ -152,7 +152,7 @@ class VesselBeaconMalfunctionsResumeUTests {
beaconMalfunction = BeaconMalfunction(
1, "FR224226850", "1236514", "IRCS",
"fr", VesselIdentifier.INTERNAL_REFERENCE_NUMBER, "BIDUBULE", VesselStatus.AT_SEA,
Stage.END_OF_MALFUNCTION, lastBeaconDateTime, null, lastBeaconDateTime,
Stage.ARCHIVED, lastBeaconDateTime, null, lastBeaconDateTime,
beaconNumber = "123465", beaconStatusAtMalfunctionCreation = BeaconStatus.ACTIVATED, vesselId = 123,
),
comments = listOf(
Expand All @@ -169,7 +169,7 @@ class VesselBeaconMalfunctionsResumeUTests {
beaconMalfunction = BeaconMalfunction(
2, "FR224226852", "1236514", "IRCS",
"fr", VesselIdentifier.INTERNAL_REFERENCE_NUMBER, "BIDUBULE", VesselStatus.AT_PORT,
Stage.END_OF_MALFUNCTION, now, null, now,
Stage.ARCHIVED, now, null, now,
beaconNumber = "123465", beaconStatusAtMalfunctionCreation = BeaconStatus.ACTIVATED, vesselId = 123,
),
comments = listOf(
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class GetAllBeaconMalfunctionsUTests {
),
BeaconMalfunction(
2, "FR224226850", "1236514", "IRCS",
null, VesselIdentifier.INTERNAL_REFERENCE_NUMBER, "BIDUBULE", VesselStatus.AT_SEA, Stage.END_OF_MALFUNCTION,
null, VesselIdentifier.INTERNAL_REFERENCE_NUMBER, "BIDUBULE", VesselStatus.AT_SEA, Stage.TARGETING_VESSEL,
ZonedDateTime.now(), ZonedDateTime.now(), ZonedDateTime.now(),
beaconNumber = "123465", beaconStatusAtMalfunctionCreation = BeaconStatus.ACTIVATED, endOfBeaconMalfunctionReason = EndOfBeaconMalfunctionReason.RESUMED_TRANSMISSION, vesselId = 123,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class GetBeaconMalfunctionUTests {
.willReturn(
BeaconMalfunction(
1, "FR224226850", "1236514", "IRCS",
null, VesselIdentifier.INTERNAL_REFERENCE_NUMBER, "BIDUBULE", VesselStatus.AT_SEA, Stage.END_OF_MALFUNCTION,
null, VesselIdentifier.INTERNAL_REFERENCE_NUMBER, "BIDUBULE", VesselStatus.AT_SEA, Stage.ARCHIVED,
ZonedDateTime.now(), null, ZonedDateTime.now(),
beaconNumber = "123465", beaconStatusAtMalfunctionCreation = BeaconStatus.ACTIVATED, vesselId = 1,
),
Expand All @@ -55,7 +55,7 @@ class GetBeaconMalfunctionUTests {
listOf(
BeaconMalfunction(
1, "FR224226850", "1236514", "IRCS",
null, VesselIdentifier.INTERNAL_REFERENCE_NUMBER, "BIDUBULE", VesselStatus.AT_SEA, Stage.END_OF_MALFUNCTION,
null, VesselIdentifier.INTERNAL_REFERENCE_NUMBER, "BIDUBULE", VesselStatus.AT_SEA, Stage.ARCHIVED,
ZonedDateTime.now(), null, ZonedDateTime.now(),
beaconNumber = "123465", beaconStatusAtMalfunctionCreation = BeaconStatus.ACTIVATED, vesselId = 1,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class GetVesselBeaconMalfunctionsUTests {
listOf(
BeaconMalfunction(
1, "FR224226850", "1236514", "IRCS",
null, VesselIdentifier.INTERNAL_REFERENCE_NUMBER, "BIDUBULE", VesselStatus.AT_SEA, Stage.END_OF_MALFUNCTION,
null, VesselIdentifier.INTERNAL_REFERENCE_NUMBER, "BIDUBULE", VesselStatus.AT_SEA, Stage.ARCHIVED,
ZonedDateTime.now(), null, ZonedDateTime.now(),
beaconNumber = "123465", beaconStatusAtMalfunctionCreation = BeaconStatus.ACTIVATED, vesselId = 1,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,22 @@ class UpdateBeaconMalfunctionUTests {
}

@Test
fun `execute Should throw an exception When the Stage is END_OF_MALFUNCTION but there si no endOfBeaconMalfunctionReason`() {
fun `execute Should throw an exception When the Stage is ARCHIVED but there si no endOfBeaconMalfunctionReason`() {
// When
val throwable = catchThrowable {
UpdateBeaconMalfunction(
beaconMalfunctionsRepository,
beaconMalfunctionActionRepository,
getBeaconMalfunction,
)
.execute(1, null, Stage.END_OF_MALFUNCTION, null)
.execute(1, null, Stage.ARCHIVED, null)
}

// Then
assertThat(throwable).isInstanceOf(IllegalArgumentException::class.java)
assertThat(throwable.message).contains("Cannot end malfunction without giving an endOfBeaconMalfunctionReason")
assertThat(throwable.message).contains(
"Cannot archive malfunction without giving an endOfBeaconMalfunctionReason",
)
}

@Test
Expand Down
Loading

0 comments on commit 38813cf

Please sign in to comment.