|
|
@@ -48,7 +48,10 @@ public class Delivery implements ValueObject<Delivery> {
|
|
48
|
48
|
Delivery updateOnRouting(RouteSpecification routeSpecification, Itinerary itinerary) {
|
|
49
|
49
|
Validate.notNull(routeSpecification, "Route specification is required");
|
|
50
|
50
|
|
|
51
|
|
- return new Delivery(this.lastEvent, itinerary, routeSpecification);
|
|
|
51
|
+ Delivery delivery = new Delivery(this.lastEvent, itinerary, routeSpecification);
|
|
|
52
|
+ delivery.misdirected = false;
|
|
|
53
|
+ delivery.nextExpectedActivity = delivery.calculateNextExpectedActivity(routeSpecification, itinerary);
|
|
|
54
|
+ return delivery;
|
|
52
|
55
|
}
|
|
53
|
56
|
|
|
54
|
57
|
/**
|
|
|
@@ -223,6 +226,21 @@ public class Delivery implements ValueObject<Delivery> {
|
|
223
|
226
|
}
|
|
224
|
227
|
|
|
225
|
228
|
private HandlingActivity calculateNextExpectedActivity(RouteSpecification routeSpecification, Itinerary itinerary) {
|
|
|
229
|
+ /*
|
|
|
230
|
+ Capture:
|
|
|
231
|
+
|
|
|
232
|
+ Cargo is misdirected but has been rerouted. Next expected acivity should be to load according to first leg
|
|
|
233
|
+ of new itinerary.
|
|
|
234
|
+
|
|
|
235
|
+ and
|
|
|
236
|
+
|
|
|
237
|
+ even if a cargo is misdirected, we expect it to be unloaded at next stop.
|
|
|
238
|
+
|
|
|
239
|
+ */
|
|
|
240
|
+ if (misdirected && ROUTED.equals(routingStatus)) {
|
|
|
241
|
+
|
|
|
242
|
+ }
|
|
|
243
|
+
|
|
226
|
244
|
if (!onTrack()) return NO_ACTIVITY;
|
|
227
|
245
|
|
|
228
|
246
|
if (lastEvent == null) return new HandlingActivity(HandlingEvent.Type.RECEIVE, routeSpecification.origin());
|