Skip to content
This repository has been archived by the owner on Nov 29, 2024. It is now read-only.

Commit

Permalink
add the time for unloading all goods only for the CollectionCarrier; …
Browse files Browse the repository at this point in the history
…seperate method for throwing the handling event from shipment logging
  • Loading branch information
kt86 committed Nov 17, 2023
1 parent 385e1db commit fedadaf
Showing 1 changed file with 35 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,16 +120,39 @@ public void handleEvent(CarrierTourEndEvent event) {
if (serviceActivity.getLocation() == transshipmentHubResource.getStartLinkId()
&& allServicesAreInOnePoint(tour)
&& (tour.getStartLinkId() != transshipmentHubResource.getStartLinkId())) {
logHandlingInHub(serviceActivity.getService(), event, tour );

final CarrierService carrierService = serviceActivity.getService();
final LSPShipment lspShipment = servicesWaitedFor.get(carrierService).shipment;
// NOTE: Do NOT add time vor unloading all goods, because they are included for the main run (Service activity at end of tour)
final double expHandlingDuration = transshipmentHubResource.getCapacityNeedFixed() + (transshipmentHubResource.getCapacityNeedLinear() * lspShipment.getSize());
final double startTime = event.getTime() ;
final double endTime = startTime + expHandlingDuration;

logHandlingInHub(serviceActivity.getService(), event, startTime, endTime);
throwHandlingEvent(event, lspShipment, expHandlingDuration);
}
}
}
}
} else if ((ResourceImplementationUtils.getCarrierType(carrier) == ResourceImplementationUtils.CARRIER_TYPE.collectionCarrier)) {
for (TourElement tourElement : tour.getTourElements()) {
if (tourElement instanceof ServiceActivity serviceActivity ) {
if (tour.getEndLinkId() == transshipmentHubResource.getStartLinkId())
logHandlingInHub(serviceActivity.getService(), event, tour );
if (tour.getEndLinkId() == transshipmentHubResource.getStartLinkId()) {

final CarrierService carrierService = serviceActivity.getService();
final LSPShipment lspShipment = servicesWaitedFor.get(carrierService).shipment;

//TODO: Adding this here to be more in line with the schedule and have the shipment log fitting to it.
// This does NOT mean, that it really makes sense, because we decided for some reasons, that the handlingEvent start once the vehicle has arrived.
// It may change again, once we have unloading events available.
final double expUnloadingTime = getTotalUnloadingTime(tour);
final double expHandlingDuration = transshipmentHubResource.getCapacityNeedFixed() + (transshipmentHubResource.getCapacityNeedLinear() * lspShipment.getSize());
final double startTime = event.getTime() + expUnloadingTime;
final double endTime = startTime + expHandlingDuration;

logHandlingInHub(carrierService, event, startTime, endTime);
throwHandlingEvent(event, lspShipment, expHandlingDuration);
}
}
}
}
Expand Down Expand Up @@ -158,18 +181,10 @@ private double getTotalUnloadingTime(Tour tour) {
return totalTime;
}

private void logHandlingInHub(CarrierService carrierService, CarrierTourEndEvent event, Tour tour) {
private void logHandlingInHub(CarrierService carrierService, CarrierTourEndEvent event, double startTime, double endTime) {

LSPShipment lspShipment = servicesWaitedFor.get(carrierService).shipment;

//TODO: Adding this here to be more in line with the schedule and have the shipment log fitting to it.
// This does NOT mean, that it really makes sense, because we decided for some reasons, that the handlingEvent start once the vehicle has arrived.
// It may change again, once we have unloading events available.
double expUnloadingTime = getTotalUnloadingTime(tour);
double expHandlingDuration = transshipmentHubResource.getCapacityNeedFixed() + transshipmentHubResource.getCapacityNeedLinear() * lspShipment.getSize();
final double startTime = event.getTime() + expUnloadingTime ;
double endTime = startTime + expUnloadingTime+ expHandlingDuration;

{ //Old logging approach - will be removed at some point in time
ShipmentPlanElement handle = ShipmentUtils.LoggedShipmentHandleBuilder.newInstance()
.setLinkId(linkId)
Expand All @@ -183,12 +198,15 @@ private void logHandlingInHub(CarrierService carrierService, CarrierTourEndEvent
lspShipment.getShipmentLog().addPlanElement(loadId, handle);
}
}
{ // New event-based approach
//Todo: We need to decide what we write into the exp. handling duration: See #175 for discussion.
// The start time, must start at the same time as the triggering event. -> keep events stream ordered.
eventsManager.processEvent(new HandlingInHubStartsEvent(event.getTime(), linkId, lspShipment.getId(), resourceId, expHandlingDuration));
}


}

private void throwHandlingEvent(CarrierTourEndEvent event, LSPShipment lspShipment, double expHandlingDuration) {
// New event-based approach
//Todo: We need to decide what we write into the exp. handling duration: See #175 for discussion.
// The start time, must start at the same time as the triggering event. -> keep events stream ordered.
eventsManager.processEvent(new HandlingInHubStartsEvent(event.getTime(), linkId, lspShipment.getId(), resourceId, expHandlingDuration));
}

private double getUnloadEndTime(Tour tour) {
Expand Down

0 comments on commit fedadaf

Please sign in to comment.