| ... |
... |
@@ -158,7 +158,7 @@ public class ComputeRF1Action extends AbstractLevel0Action<ComputeRF1Configurati |
|
158
|
158
|
}
|
|
159
|
159
|
|
|
160
|
160
|
@Override
|
|
161
|
|
- protected boolean executeAction() throws Exception {
|
|
|
161
|
+ protected boolean executeAction() {
|
|
162
|
162
|
|
|
163
|
163
|
Set<Vessel> allVessel = tripsByVessel.keySet();
|
|
164
|
164
|
|
| ... |
... |
@@ -174,29 +174,24 @@ public class ComputeRF1Action extends AbstractLevel0Action<ComputeRF1Configurati |
|
174
|
174
|
log.debug("Treat vessel " + vessel.getLabel1());
|
|
175
|
175
|
}
|
|
176
|
176
|
|
|
177
|
|
- List<Trip> tripsForVessel =
|
|
178
|
|
- Lists.newArrayList(tripsByVessel.get(vessel));
|
|
|
177
|
+ List<Trip> tripsForVessel = Lists.newArrayList(tripsByVessel.get(vessel));
|
|
179
|
178
|
TripTopiaDao.sortTrips(tripsForVessel);
|
|
180
|
179
|
result |= doExecuteForVessel(vessel, tripsForVessel);
|
|
181
|
180
|
}
|
|
182
|
181
|
|
|
183
|
|
- addInfoMessage(l(locale, "t3.level0.computeRF1.totalCatchWeightRF1",
|
|
184
|
|
- totalCatchWeightRF1));
|
|
185
|
|
- addInfoMessage(l(locale, "t3.level0.computeRF1.totalLandingWeight",
|
|
186
|
|
- totalLandingWeight));
|
|
|
182
|
+ addInfoMessage(l(locale, "t3.level0.computeRF1.totalCatchWeightRF1", totalCatchWeightRF1));
|
|
|
183
|
+ addInfoMessage(l(locale, "t3.level0.computeRF1.totalLandingWeight", totalLandingWeight));
|
|
187
|
184
|
}
|
|
188
|
185
|
|
|
189
|
186
|
return result;
|
|
190
|
187
|
}
|
|
191
|
188
|
|
|
192
|
|
- protected boolean doExecuteForVessel(Vessel vessel,
|
|
193
|
|
- List<Trip> tripList) throws Exception {
|
|
|
189
|
+ protected boolean doExecuteForVessel(Vessel vessel, List<Trip> tripList) {
|
|
194
|
190
|
|
|
195
|
191
|
incrementsProgression();
|
|
196
|
192
|
|
|
197
|
193
|
String vesselStr = decorate(vessel);
|
|
198
|
|
- addInfoMessage(l(locale, "t3.level0.computeRF1.treat.vessel",
|
|
199
|
|
- vesselStr));
|
|
|
194
|
+ addInfoMessage(l(locale, "t3.level0.computeRF1.treat.vessel", vesselStr));
|
|
200
|
195
|
|
|
201
|
196
|
if (CollectionUtils.isEmpty(tripList)) {
|
|
202
|
197
|
|
| ... |
... |
@@ -205,8 +200,7 @@ public class ComputeRF1Action extends AbstractLevel0Action<ComputeRF1Configurati |
|
205
|
200
|
return false;
|
|
206
|
201
|
}
|
|
207
|
202
|
|
|
208
|
|
- addInfoMessage(l(locale, "t3.level0.computeRF1.trips.to.use.for.vessel",
|
|
209
|
|
- tripList.size(), vesselStr));
|
|
|
203
|
+ addInfoMessage(l(locale, "t3.level0.computeRF1.trips.to.use.for.vessel", tripList.size(), vesselStr));
|
|
210
|
204
|
|
|
211
|
205
|
// get country of the vessel (always use the fleet country)
|
|
212
|
206
|
Country country = vessel.getFleetCountry();
|
| ... |
... |
@@ -228,13 +222,12 @@ public class ComputeRF1Action extends AbstractLevel0Action<ComputeRF1Configurati |
|
228
|
222
|
|
|
229
|
223
|
// there is some species to use for rf1 computation
|
|
230
|
224
|
StringBuilder sb = new StringBuilder();
|
|
231
|
|
- for (Species specy : species) {
|
|
232
|
|
- sb.append(", ").append(decorate(specy));
|
|
|
225
|
+ for (Species aSpecies : species) {
|
|
|
226
|
+ sb.append(", ").append(decorate(aSpecies));
|
|
233
|
227
|
}
|
|
234
|
228
|
|
|
235
|
229
|
String message = l(locale, "t3.level0.computeRF1.species.to.use",
|
|
236
|
|
- species.size(), sb.substring(2)
|
|
237
|
|
- );
|
|
|
230
|
+ species.size(), sb.substring(2));
|
|
238
|
231
|
if (log.isInfoEnabled()) {
|
|
239
|
232
|
log.info(message);
|
|
240
|
233
|
}
|
| ... |
... |
@@ -247,20 +240,15 @@ public class ComputeRF1Action extends AbstractLevel0Action<ComputeRF1Configurati |
|
247
|
240
|
// split trips by complete trips
|
|
248
|
241
|
List<CompleteTrip> completeTrips = tripDAO.toCompleteTrip(tripList);
|
|
249
|
242
|
|
|
250
|
|
- addInfoMessage(
|
|
251
|
|
- l(locale, "t3.level0.computeRF1.complete.trips.to.use.for.vessel",
|
|
252
|
|
- completeTrips.size(), vesselStr));
|
|
|
243
|
+ addInfoMessage(l(locale, "t3.level0.computeRF1.complete.trips.to.use.for.vessel",
|
|
|
244
|
+ completeTrips.size(), vesselStr));
|
|
253
|
245
|
|
|
254
|
246
|
nbCompleteTrips += completeTrips.size();
|
|
255
|
247
|
|
|
256
|
248
|
for (CompleteTrip completeTrip : completeTrips) {
|
|
257
|
249
|
|
|
258
|
250
|
// consume the completeTrip
|
|
259
|
|
- treatCompleteTrip(completeTrip,
|
|
260
|
|
- species,
|
|
261
|
|
- minimumRate,
|
|
262
|
|
- maximumRate
|
|
263
|
|
- );
|
|
|
251
|
+ treatCompleteTrip(completeTrip, species, minimumRate, maximumRate);
|
|
264
|
252
|
|
|
265
|
253
|
// complete trip was consumed
|
|
266
|
254
|
completeTrip.removeTrips(tripList);
|
| ... |
... |
@@ -288,10 +276,7 @@ public class ComputeRF1Action extends AbstractLevel0Action<ComputeRF1Configurati |
|
288
|
276
|
return true;
|
|
289
|
277
|
}
|
|
290
|
278
|
|
|
291
|
|
- private void treatCompleteTrip(CompleteTrip completeTrip,
|
|
292
|
|
- Collection<Species> species,
|
|
293
|
|
- float minimumRate,
|
|
294
|
|
- float maximumRate) {
|
|
|
279
|
+ private void treatCompleteTrip(CompleteTrip completeTrip, Collection<Species> species, float minimumRate, float maximumRate) {
|
|
295
|
280
|
|
|
296
|
281
|
int completionStatus;
|
|
297
|
282
|
|
| ... |
... |
@@ -306,9 +291,9 @@ public class ComputeRF1Action extends AbstractLevel0Action<ComputeRF1Configurati |
|
306
|
291
|
}
|
|
307
|
292
|
applyCompletionStatus(completeTrip, completionStatus);
|
|
308
|
293
|
|
|
309
|
|
- boolean allwithLogBook = TripTopiaDao.isTripsAllWithLogBook(completeTrip);
|
|
|
294
|
+ boolean allWithLogBook = TripTopiaDao.isTripsAllWithLogBook(completeTrip);
|
|
310
|
295
|
|
|
311
|
|
- if (!allwithLogBook) {
|
|
|
296
|
+ if (!allWithLogBook) {
|
|
312
|
297
|
|
|
313
|
298
|
// there is some trips with no log book
|
|
314
|
299
|
// reject all the complete trip
|
| ... |
... |
@@ -350,8 +335,7 @@ public class ComputeRF1Action extends AbstractLevel0Action<ComputeRF1Configurati |
|
350
|
335
|
completeTrip.getDepartureTrip().getVesselLabel(),
|
|
351
|
336
|
DecoratorService.formatDate(completeTrip.getDepartureTrip().getDepartureDate()),
|
|
352
|
337
|
DecoratorService.formatDate(completeTrip.getLandingTrip().getLandingDate()),
|
|
353
|
|
- rf1,
|
|
354
|
|
- minimumRate);
|
|
|
338
|
+ rf1, minimumRate);
|
|
355
|
339
|
addWarningMessage(warnMessage);
|
|
356
|
340
|
nbCompleteAcceptedTripsWithBadRF1++;
|
|
357
|
341
|
}
|
| ... |
... |
@@ -363,8 +347,7 @@ public class ComputeRF1Action extends AbstractLevel0Action<ComputeRF1Configurati |
|
363
|
347
|
completeTrip.getDepartureTrip().getVesselLabel(),
|
|
364
|
348
|
DecoratorService.formatDate(completeTrip.getDepartureTrip().getDepartureDate()),
|
|
365
|
349
|
DecoratorService.formatDate(completeTrip.getLandingTrip().getLandingDate()),
|
|
366
|
|
- rf1,
|
|
367
|
|
- maximumRate);
|
|
|
350
|
+ rf1, maximumRate);
|
|
368
|
351
|
addWarningMessage(warnMessage);
|
|
369
|
352
|
nbCompleteAcceptedTripsWithBadRF1++;
|
|
370
|
353
|
}
|
| ... |
... |
@@ -377,18 +360,13 @@ public class ComputeRF1Action extends AbstractLevel0Action<ComputeRF1Configurati |
|
377
|
360
|
}
|
|
378
|
361
|
}
|
|
379
|
362
|
|
|
380
|
|
- private void applyCompletionStatus(Iterable<Trip> trips,
|
|
381
|
|
- int completionStatus) {
|
|
382
|
|
-
|
|
|
363
|
+ private void applyCompletionStatus(Iterable<Trip> trips, int completionStatus) {
|
|
383
|
364
|
for (Trip trip : trips) {
|
|
384
|
|
-
|
|
385
|
365
|
trip.setCompletionStatus(completionStatus);
|
|
386
|
366
|
}
|
|
387
|
367
|
}
|
|
388
|
368
|
|
|
389
|
|
- private void applyRF1(Float rf1,
|
|
390
|
|
- CompleteTrip trips,
|
|
391
|
|
- Collection<Species> species) {
|
|
|
369
|
+ private void applyRF1(Float rf1, CompleteTrip trips, Collection<Species> species) {
|
|
392
|
370
|
|
|
393
|
371
|
for (Trip trip : trips) {
|
|
394
|
372
|
|
| ... |
... |
@@ -400,42 +378,30 @@ public class ComputeRF1Action extends AbstractLevel0Action<ComputeRF1Configurati |
|
400
|
378
|
|
|
401
|
379
|
// means can not apply any rf1 : rf1 must stay at null...
|
|
402
|
380
|
rf1ToUse = null;
|
|
403
|
|
- addWarningMessage(
|
|
404
|
|
- l(locale, "t3.level0.computeRF1.warning.no.logbook",
|
|
405
|
|
- tripStr)
|
|
406
|
|
- );
|
|
|
381
|
+ addWarningMessage(l(locale, "t3.level0.computeRF1.warning.no.logbook", tripStr));
|
|
407
|
382
|
}
|
|
408
|
383
|
|
|
409
|
384
|
trip.applyRf1(rf1ToUse, species);
|
|
410
|
385
|
markTripAsTreated(trip);
|
|
411
|
|
- addInfoMessage(
|
|
412
|
|
- l(locale, "t3.level0.computeRF1.resume.rf1.for.trip",
|
|
413
|
|
- tripStr, rf1ToUse)
|
|
414
|
|
- );
|
|
|
386
|
+ addInfoMessage(l(locale, "t3.level0.computeRF1.resume.rf1.for.trip", tripStr, rf1ToUse));
|
|
415
|
387
|
}
|
|
416
|
388
|
}
|
|
417
|
389
|
|
|
418
|
|
- protected void updateTotalWeights(CompleteTrip completeTrip,
|
|
419
|
|
- Collection<Species> species) {
|
|
|
390
|
+ protected void updateTotalWeights(CompleteTrip completeTrip, Collection<Species> species) {
|
|
420
|
391
|
|
|
421
|
392
|
|
|
422
|
|
- float tripTotalCatchWeightRf1 =
|
|
423
|
|
- completeTrip.getElementaryCatchTotalWeightRf1(species);
|
|
|
393
|
+ float tripTotalCatchWeightRf1 = completeTrip.getElementaryCatchTotalWeightRf1(species);
|
|
424
|
394
|
totalCatchWeightRF1 += tripTotalCatchWeightRf1;
|
|
425
|
395
|
|
|
426
|
|
- float tripTotalLandingWeight =
|
|
427
|
|
- completeTrip.getElementaryLandingTotalWeight(species);
|
|
|
396
|
+ float tripTotalLandingWeight = completeTrip.getElementaryLandingTotalWeight(species);
|
|
428
|
397
|
totalLandingWeight += tripTotalLandingWeight;
|
|
429
|
398
|
if (log.isInfoEnabled()) {
|
|
430
|
|
-
|
|
431
|
|
- log.info("After trip " + decorate(completeTrip.getLandingTrip()) +
|
|
432
|
|
- " tripTotalCatchWeightRf1 = " + tripTotalCatchWeightRf1 +
|
|
433
|
|
- " tripTotalLandingWeight = " + tripTotalLandingWeight);
|
|
|
399
|
+ log.info(String.format("After trip %s tripTotalCatchWeightRf1 = %s tripTotalLandingWeight = %s",
|
|
|
400
|
+ decorate(completeTrip.getLandingTrip()), tripTotalCatchWeightRf1, tripTotalLandingWeight));
|
|
434
|
401
|
}
|
|
435
|
402
|
if (log.isDebugEnabled()) {
|
|
436
|
|
- log.debug("After trip " + decorate(completeTrip.getLandingTrip()) +
|
|
437
|
|
- " totalCatchWeightRF1 = " + totalCatchWeightRF1 +
|
|
438
|
|
- " totalLandingWeight = " + totalLandingWeight);
|
|
|
403
|
+ log.debug(String.format("After trip %s totalCatchWeightRF1 = %s totalLandingWeight = %s",
|
|
|
404
|
+ decorate(completeTrip.getLandingTrip()), totalCatchWeightRF1, totalLandingWeight));
|
|
439
|
405
|
}
|
|
440
|
406
|
// for (Trip trip : completeTrip) {
|
|
441
|
407
|
//
|
| ... |
... |
@@ -461,8 +427,7 @@ public class ComputeRF1Action extends AbstractLevel0Action<ComputeRF1Configurati |
|
461
|
427
|
// }
|
|
462
|
428
|
}
|
|
463
|
429
|
|
|
464
|
|
- protected float computeRF1ForCompleteTrip(Iterable<Trip> completeTrip,
|
|
465
|
|
- Collection<Species> speciesList) {
|
|
|
430
|
+ protected float computeRF1ForCompleteTrip(Iterable<Trip> completeTrip, Collection<Species> speciesList) {
|
|
466
|
431
|
|
|
467
|
432
|
// do the computation of rf1 for all trips of the complete trip
|
|
468
|
433
|
float sumLanding = 0;
|
| ... |
... |
@@ -477,10 +442,8 @@ public class ComputeRF1Action extends AbstractLevel0Action<ComputeRF1Configurati |
|
477
|
442
|
log.debug("Start count for trip " + tripStr);
|
|
478
|
443
|
}
|
|
479
|
444
|
|
|
480
|
|
- float elementaryLandingTotalWeight =
|
|
481
|
|
- trip.getElementaryLandingTotalWeight(speciesList);
|
|
482
|
|
- float elementaryCatchTotalWeight =
|
|
483
|
|
- trip.getElementaryCatchTotalWeight(speciesList);
|
|
|
445
|
+ float elementaryLandingTotalWeight = trip.getElementaryLandingTotalWeight(speciesList);
|
|
|
446
|
+ float elementaryCatchTotalWeight = trip.getElementaryCatchTotalWeight(speciesList);
|
|
484
|
447
|
|
|
485
|
448
|
if (elementaryCatchTotalWeight == 0 &&
|
|
486
|
449
|
elementaryLandingTotalWeight > 0) {
|
| ... |
... |
@@ -488,24 +451,19 @@ public class ComputeRF1Action extends AbstractLevel0Action<ComputeRF1Configurati |
|
488
|
451
|
// Add a warning, seems not possible to have no catches and landing :
|
|
489
|
452
|
// the logBookAvaibility flag should be setted to 0.
|
|
490
|
453
|
|
|
491
|
|
- addWarningMessage(
|
|
492
|
|
- l(locale, "t3.level0.computeRF1.warning.no.catches.but.some.landings",
|
|
493
|
|
- tripStr, elementaryLandingTotalWeight)
|
|
494
|
|
- );
|
|
|
454
|
+ addWarningMessage(l(locale, "t3.level0.computeRF1.warning.no.catches.but.some.landings",
|
|
|
455
|
+ tripStr, elementaryLandingTotalWeight));
|
|
495
|
456
|
}
|
|
496
|
457
|
|
|
497
|
458
|
if (elementaryCatchTotalWeight > 0 && elementaryLandingTotalWeight == 0) {
|
|
498
|
459
|
|
|
499
|
460
|
// Special case : no landing
|
|
500
|
|
-
|
|
501
|
461
|
// do not take account of the catch weight
|
|
502
|
|
- elementaryCatchTotalWeight = 0;
|
|
|
462
|
+ // in fact (see https://gitlab.com/ultreiaio/ird-t3/issues/283), we do not want to loose this catches
|
|
|
463
|
+ //elementaryCatchTotalWeight = 0;
|
|
503
|
464
|
|
|
504
|
|
- addWarningMessage(
|
|
505
|
|
- l(locale, "t3.level0.computeRF1.warning.no.landings.but.some.catches",
|
|
506
|
|
- tripStr,
|
|
507
|
|
- elementaryLandingTotalWeight)
|
|
508
|
|
- );
|
|
|
465
|
+ addWarningMessage(l(locale, "t3.level0.computeRF1.warning.no.landings.but.some.catches",
|
|
|
466
|
+ tripStr, elementaryLandingTotalWeight));
|
|
509
|
467
|
}
|
|
510
|
468
|
|
|
511
|
469
|
float localMarketTotalWeight = trip.getFalseFishesWeight();
|
| ... |
... |
@@ -536,10 +494,8 @@ public class ComputeRF1Action extends AbstractLevel0Action<ComputeRF1Configurati |
|
536
|
494
|
log.debug("Computed rf1 " + rf1);
|
|
537
|
495
|
}
|
|
538
|
496
|
|
|
539
|
|
- addInfoMessage(
|
|
540
|
|
- l(locale, "t3.level0.computeRF1.resume.for.complete.trip",
|
|
|
497
|
+ addInfoMessage(l(locale, "t3.level0.computeRF1.resume.for.complete.trip",
|
|
541
|
498
|
sumCatch, sumLanding, sumLocalMarket, sumLocalMarketDetailled, rf1));
|
|
542
|
|
-
|
|
543
|
499
|
return rf1;
|
|
544
|
500
|
}
|
|
545
|
501
|
|