Interface IWorkingHours
- All Superinterfaces:
Comparable<IDutyHours>,IDutyHours,Serializable
- All Known Implementing Classes:
WorkingHours
IWorkingHours. WorkingHours are the schedule in which the
work orders of a specific resources have to be performed. Through WorkingHours
a resources can have a different schedule for each day, be allowed to stay
over night and have its total working time limited.
IWorkingHours and IOpeningHours are both extend IDutyHours, however
IWorkingHour does have improved functionality, IOpeningHours does not.
Implementation example:
List<IWorkingHours> workingHours = new ArrayList<IWorkingHours>();
workingHours.add(
new WorkingHours(
ZonedDateTime.of(2020, MAY, 6, 8, 0, 0, 0, ZoneId.of("Europe/Berlin")),
ZonedDateTime.of(2020, MAY, 6, 17, 0, 0, 0, ZoneId.of("Europe/Berlin"))));
- Since:
- 28/08/2018
- Version:
- 07/10/2019
- Author:
- DNA
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.dna.jopt.member.unit.hours.IDutyHours
IDutyHours.DutyHoursFlavour -
Method Summary
Modifier and TypeMethodDescriptionbooleanvoidaddConstraint(IWorkingHoursLevelConstraint wohLevelConstraint) Adds aConstraintto theWorkingHoursso onlyResourceswith that specificQualificationwill be able to serve theNodesto which thoseWorkingHoursare applied.voidaddConstraint(IMultiWorkingHoursLevelConstraint wohLevelConstraint) voidAdds a certainINodeColorto theResource.voidaddQualification(IQualification qualification) Adds aIQualificationto theIWorkingHours, which means that by adding aIConstraintto theINode, they are limited to whichNodesthey can give service.copy()Returns a copy ofWorkingHours(this.getBegin(), this.getEnd(), this.getZoneId())and invokesWorkingHours.takeOverProperties(com.dna.jopt.member.unit.hours.IWorkingHours, com.dna.jopt.member.unit.hours.IWorkingHours)to also copy the properties.getColorCapacityItemByColorCode(int colorCode) Gets theNodeColorCapacityItemwhich limit the amount ofColorcodedNodesaResourcecan give service to.getConnectionHook(String toId) Gets theConstraintsset on theIResource.booleanGets if theResourceis allowed to do anovernight stay.Gets thelocalFlexTimein milliseconds.Gets thefreePostWorkDrivingTerminationTimein milliseconds.Gets thelocalMaxPillarAfterHoursTimeofIPillarNodein milliseconds.Gets thelocalMaxRouteStartReductionTimein milliseconds.Gets thelocalMaxRouteStartReductionTimeforIPillarNodein milliseconds.Gets theDurationof the potential localstayout cycle.Gets the start of the localstayout cycle.doubleGets theWorkingHours.maxDistance, which is the maximal distance in km aResourceis allowed to travel without aIViolationper day.doubleGets maximum number of hours aResourceis allowed to work per day inhours.Gets the aMapof theNodeColorCapacity.Gets theINodeColorthat are in use.Map<Class<? extends IQualification>,IQualification> Gets theIQualificationof theIWorkingHours.booleanhasHook()booleanChecks if the route is closed or not, the default value isfalse.Checks whether thelocalMaxRouteStartReductionTimeis included in theWorkingHours.Checks whether the potentially setlocalMaxRouteStartReductionTimecan only be used for driving, not for working.Checks whether the potentially setlocalMaxRouteStartReductionTimeforIPillarNodecan only be used for driving, not for working.booleanChecks if anyINodeColorhas been set through the use of aNodeColorCapacityItem.booleanvoidsetIsAvailableForStay(boolean isAvailableForStay) Sets if theResourceis allowed for anovernight stayinstead of returning to the starting location.voidsetIsClosedRoute(boolean isClosedRoute) Sets theRouteto aclosed Route.booleansetLocalFlexTime(Duration idleTimeReductionTime) Sets the amount of time aResourcecan be expected to start working later and stay longer at work if needed.booleansetLocalMaxFreePostWorkDrivingTerminationTime(Duration postWorkingHourTimeReductionTime) Sets the amount of time theResourcecan be expected to drive home to its starting location in its free time.booleansetLocalMaxFreePostWorkDrivingTerminationTime(Duration postTimeReductionTime, boolean onlyApplyOnOvertime) Sets the local max free post work driving termination time.booleansetLocalMaxPillarAfterHoursTime(Duration maxPillarEndOverTime) Sets the amount of time afterWorkingHourswithin which aIPillarNodecan be set.booleansetLocalMaxRouteStartReductionTime(Duration maxRouteStartReductionTime, boolean isOnlyUsedForDriving) Sets the maximum time which theResourcecan be expected to drive to the firstNodein its private time.booleansetLocalMaxRouteStartReductionTimePillar(Duration maxRouteStartReductionTime, boolean isOnlyUsedForDriving) Sets thelocalMaxRouteStartReductionTimeforIPillarNode.voidsetLocalReductionTimeIsIncludedInWorkingTime(boolean isIncludedInTotalWorkingTime) Sets whether thelocalMaxRouteStartReductionTimeis included in theWorkingHours.voidsetLocalStayOutCycleDefinition(Duration cycle, LocalDate cycleStart) Sets theDurationof the cycle within which the maximum number ofovernight staysare allowed and within which the minimumrecovery time(WorkingHourswithoutovernight stays) has to be observed.voidsetMaxDistance(javax.measure.Quantity<javax.measure.quantity.Length> maxDistance) Sets the maximal distance that aResourceis allowed to travel per day, cannot be null.voidsetMaxHours(Duration maxWorkingTime) Deprecated.voidsetMaxWorkingTime(Duration maxWorkingTime) Sets the maximum number of hours aResourceis allowed to work per day.voidsetResourceDepot(IResourceDepot depot) booleansetStartTimeHook(Duration routeStartTimeHookDuration) Methods inherited from interface java.lang.Comparable
compareToMethods inherited from interface com.dna.jopt.member.unit.hours.IDutyHours
getFlavour, getTimeWindow, isPrefferedHour, setIsPrefferedHour
-
Method Details
-
getMaxHours
double getMaxHours()Gets maximum number of hours aResourceis allowed to work per day inhours. By default it is not usable and the value is -1.- Returns:
- the double
maxHours.
-
getMaxDistanceKm
double getMaxDistanceKm()Gets theWorkingHours.maxDistance, which is the maximal distance in km aResourceis allowed to travel without aIViolationper day.- Returns:
- double
maxDistancein km. By default it is not usable and the value is -1.
-
getIsAvailableForStay
boolean getIsAvailableForStay()Gets if theResourceis allowed to do anovernight stay. TheNodealso needsINode.setIsStayNode(boolean)set totrueso this function can be used.This method is specific for the set
WorkingHoursand can therefore be specific for certain days in the week (noovernight stayson Fridays.- Returns:
- boolean, the default value is
true.
-
setIsAvailableForStay
void setIsAvailableForStay(boolean isAvailableForStay) Sets if theResourceis allowed for anovernight stayinstead of returning to the starting location. TheNodealso needsINode.setIsStayNode(boolean)set totrueso this function can be used.- Parameters:
isAvailableForStay- boolean, the default value istrue.
-
setMaxWorkingTime
Sets the maximum number of hours aResourceis allowed to work per day.- Parameters:
maxWorkingTime- the maximal working time
-
setMaxHours
Deprecated.please usesetMaxWorkingTime(Duration)insteadDecrecated methodSets the
WorkingHours.maxHoursaResourceis allowed to work per day.- Parameters:
maxWorkingTime- the double to be set formaxHours
-
setMaxDistance
void setMaxDistance(javax.measure.Quantity<javax.measure.quantity.Length> maxDistance) Sets the maximal distance that aResourceis allowed to travel per day, cannot be null.- Parameters:
maxDistance- the quantity, will becastedto kilometre
-
setIsClosedRoute
void setIsClosedRoute(boolean isClosedRoute) Sets theRouteto aclosed Route. Aclosed Routeis aRoutewhere theResourceis going to its home afterwards. Anopen Routeis aRoutewhere theResourceis simply staying at the lastNodeifOverNightStayalso has been activated or where theResourcehas to travel home outside of theWorkingHours. The default value is true.- Parameters:
isClosedRoute- the boolean if the Route is a closed Route- See Also:
-
isClosedRoute
boolean isClosedRoute()Checks if the route is closed or not, the default value isfalse. Aclosed Routeis aRoutewhere theResourceis going to its home afterwards. Anopen Routeis aRoutewhere theResourceis simply staying at the lastNodeifOverNightStayalso has been activated or where theResourcehas to travel home outside of theWorkingHours. The default value is true.- Returns:
- the boolean
isClosedRoute - See Also:
-
setLocalStayOutCycleDefinition
Sets theDurationof the cycle within which the maximum number ofovernight staysare allowed and within which the minimumrecovery time(WorkingHourswithoutovernight stays) has to be observed. Therecovery timeis set inIResource.setStayOutCycleDefinition(Duration, LocalDate).Without setting the cycle the maximal number of
overnight stayswill not be refreshed and count for the full duration of theWorkingHours. The cycle can be applied to the localResourcewhich means it will stay the same for thisResourcethroughout theOptimization. If like here setlocallyit is only valid for thisWorkingHoursand the cycle can change depending on the dates or time in the week. It can for example be set that noovernight staysare allowed on Fridays.- Parameters:
cycle- duration of the cyclecycleStart- the localDate of the cycle start
-
getLocalStayOutCycle
Gets theDurationof the potential localstayout cycle.For more information please see
setLocalStayOutCycleDefinition(Duration, LocalDate).- Returns:
- the duration of the local stayOutCycle
-
getLocalStayOutCycleStart
Gets the start of the localstayout cycle.For more information please see
setLocalStayOutCycleDefinition(Duration, LocalDate).- Returns:
- the date of the localStayCycleStart
-
setLocalMaxRouteStartReductionTime
boolean setLocalMaxRouteStartReductionTime(Duration maxRouteStartReductionTime, boolean isOnlyUsedForDriving) Sets the maximum time which theResourcecan be expected to drive to the firstNodein its private time.If the
OpeningHoursof aNodeand theWorkingHoursof aResourcestart at 8 the driving time is an hour and theResource'slocalMaxRouteStartReductionTimeis 30 Minutes theResourcewill start driving towards theNodeat 7.30 (outside of itsWorkingHours) and arrive there at 8.30.The
Booleandefines whether thelocalMaxRouteStartReductionTimecan only be used for driving or not and is usually set totrue. TheResourcecan not work in thelocalMaxRouteStartReductionTimein that case.If like here set
locallythelocalMaxRouteStartReductionTimeis only valid for these specificWorkingHours.- Parameters:
maxRouteStartReductionTime- the duration of the maxRouteStartReductionTimeisOnlyUsedForDriving- the boolean whether the time can only be used for driving- Returns:
- false if reductionTime is null or negative
-
setLocalMaxRouteStartReductionTimePillar
boolean setLocalMaxRouteStartReductionTimePillar(Duration maxRouteStartReductionTime, boolean isOnlyUsedForDriving) Sets thelocalMaxRouteStartReductionTimeforIPillarNode. Overwrites the setlocalMaxRouteStartReductionTimeand sets the new value forPillars. If nolocalMaxRouteStartReductionTimehas been set, sets the new value forPillarsonly.For more information please see
setLocalMaxRouteStartReductionTime(Duration, boolean).- Parameters:
maxRouteStartReductionTime- the duration of the localMaxStartReductionTimePillarisOnlyUsedForDriving- the boolean whether it is only used for driving- Returns:
- false if reductionTime is null or negative
-
setLocalReductionTimeIsIncludedInWorkingTime
void setLocalReductionTimeIsIncludedInWorkingTime(boolean isIncludedInTotalWorkingTime) Sets whether thelocalMaxRouteStartReductionTimeis included in theWorkingHours. The default value isfalse. IffalseandsetLocalMaxRouteStartReductionTime(Duration, boolean)is set totruethe driving time to the firstNodehas to be done in theResourcesprivate timeFor more information please see
setLocalMaxRouteStartReductionTime(Duration, boolean).- Parameters:
isIncludedInTotalWorkingTime- the boolean whether reduction time is included in the WorkingHours
-
isLocalReductionTimeOnlyUsedForDriving
Checks whether the potentially setlocalMaxRouteStartReductionTimecan only be used for driving, not for working. Per default this is set totrue.For more information please see
setLocalMaxRouteStartReductionTime(Duration, boolean)- Returns:
- the checked status or an empty Optional if no
localMaxRouteStartReductionTimehas been set
-
isLocalReductionTimeOnlyUsedForDrivingPillar
Checks whether the potentially setlocalMaxRouteStartReductionTimeforIPillarNodecan only be used for driving, not for working. Per default this is set totrue.For more information please see
setLocalMaxRouteStartReductionTime(Duration, boolean)andsetLocalMaxRouteStartReductionTimePillar(Duration, boolean).- Returns:
- the checked status or an empty Optional if no
localMaxRouteStartReductionTimehas been set
-
isLocalReductionTimeIncludedInWorkingTime
Checks whether thelocalMaxRouteStartReductionTimeis included in theWorkingHours. The default value isfalse. IffalseandsetLocalMaxRouteStartReductionTime(Duration, boolean)is set totruethe driving time to the firstNodehas to be done in theResourcesprivate timeFor more information please see
setLocalMaxRouteStartReductionTime(Duration, boolean).- Returns:
- the status of an empty Optional if no
localMaxRouteStartReductionTimehas been set
-
getLocalMaxRouteStartReductionTimeMillis
Gets thelocalMaxRouteStartReductionTimein milliseconds.For more information please see
setLocalMaxRouteStartReductionTime(Duration, boolean).- Returns:
- the status or an empty optional if no
localMaxRouteStartReductionTimehas been set
-
getLocalMaxRouteStartReductionTimeMillisPillar
Gets thelocalMaxRouteStartReductionTimeforIPillarNodein milliseconds.For more information please see
setLocalMaxRouteStartReductionTimePillar(Duration, boolean)andsetLocalMaxRouteStartReductionTime(Duration, boolean).- Returns:
- the status or an empty optional if no
localMaxRouteStartReductionTimehas been set
-
setLocalFlexTime
Sets the amount of time aResourcecan be expected to start working later and stay longer at work if needed.If the first
Nodeis at 11, theResources WorkingHoursstarted at 8 and thelocalFlexTimeis set to 3 hours, theResourcestarts working at 11 and has to stay 3 hours longer at work than usual. If thelocalFlexTimein the above example is set to 2 hours, theResourcewill be idle from 10-11 but it is considered working time.- Parameters:
idleTimeReductionTime- the duration of the idle time reduction time- Returns:
- true if the setting was accepted
-
getLocalFlexTimeMillis
Gets thelocalFlexTimein milliseconds.For more information please see
setLocalFlexTime(Duration).- Returns:
- the long local flex time in milliseconds, an empty Optional if no
localFlexTimehas been set
-
setLocalMaxFreePostWorkDrivingTerminationTime
Sets the amount of time theResourcecan be expected to drive home to its starting location in its free time.If returning from the last
Nodeto the starting location takes 1 hour and thefreePostWorkDrivingTerminationTimeis set to 40 minutes, those 40 minutes of the drive home are considered private time.This method sets the
local free post work driving termination timelocally. Therefore different times can be set for differentWorkingHours. If the time should be valid for all theWorkingHoursof aResourceplease useIResource.setMaxFreePostWorkDrivingTerminationTime(Duration).- Parameters:
postWorkingHourTimeReductionTime- the duration free time that needs to be used to drive home- Returns:
- true if the setting was accepted
-
setLocalMaxFreePostWorkDrivingTerminationTime
boolean setLocalMaxFreePostWorkDrivingTerminationTime(Duration postTimeReductionTime, boolean onlyApplyOnOvertime) Sets the local max free post work driving termination time. If onlyApplyOnOvertime is true, the post driving time is only utilized if the route shows overtime. Moreover, the maximal utilized time is the overtime itself (or, if lower, the postWorkingHourTimeReductionTime).- Parameters:
postTimeReductionTime- the post time reduction timeonlyApplyOnOvertime- the only apply on overtime- Returns:
- true, if successful
-
isLocalOnlyApplyFreePostWorkDrivingOnOvertime
-
getLocalMaxFreePostWorkDrivingTerminationTimeMillis
Gets thefreePostWorkDrivingTerminationTimein milliseconds.For more information please see
setLocalMaxFreePostWorkDrivingTerminationTime(Duration).- Returns:
- the value or an empty Optional if no
freePostWorkDrivingTerminationTimehas been set
-
setLocalMaxPillarAfterHoursTime
Sets the amount of time afterWorkingHourswithin which aIPillarNodecan be set. TheResourceshave to visit thisPillareven tough it is outside ofWorkingHours.This method in only valid for a specific set of
WorkingHours. If you want to set the same time for all theWorkingHoursof aPillarplease useIResource.setMaxPillarAfterHoursTime(Duration)- Parameters:
maxPillarEndOverTime- the duration after WorkingHours within which a Pillar still has to be given service- Returns:
- true if the setting was accepted
-
getLocalMaxPillarAfterHoursTime
Gets thelocalMaxPillarAfterHoursTimeofIPillarNodein milliseconds.For more information please see
setLocalMaxPillarAfterHoursTime(Duration).- Returns:
- the long localMaxPillarAfterHoursTime
-
copy
IWorkingHours copy()Returns a copy ofWorkingHours(this.getBegin(), this.getEnd(), this.getZoneId())and invokesWorkingHours.takeOverProperties(com.dna.jopt.member.unit.hours.IWorkingHours, com.dna.jopt.member.unit.hours.IWorkingHours)to also copy the properties.- Specified by:
copyin interfaceIDutyHours- Returns:
- a copy of the WorkingHours
-
addConstraint
Adds aConstraintto theWorkingHoursso onlyResourceswith that specificQualificationwill be able to serve theNodesto which thoseWorkingHoursare applied.For examples see
UKPostCodeQualificationandUKPostCodeConstraint- Parameters:
wohLevelConstraint- the iWorkingHoursLevelConstraint to add to the workingHours
-
addConstraint
-
getMultiConstraints
List<IMultiWorkingHoursLevelConstraint> getMultiConstraints() -
getConstraints
List<IWorkingHoursLevelConstraint> getConstraints()Gets theConstraintsset on theIResource. TheResourcecan only work onNodeswithin within the range of itsConstraint.An example of its implementation is
UKPostCodeConstraint.- Returns:
- the workingHours constraints
-
addNodeColorCapacity
Adds a certainINodeColorto theResource. This way can be made sure thatNodeswith a certainColorare not overrepresented and can be used for white space generation.Implementation example:
double preventivePercent = 0.2; double contractorPercent = 0.5; double breakfixPercent = 0.7; workingHours.forEach(wh -> { wh.addNodeColorCapacity(new NodeColorCapacityItem(NodeColors.PREVENTIVE,preventivePercent)); wh.addNodeColorCapacity(new NodeColorCapacityItem(NodeColors.BREAKFIX,breakfixPercent)); wh.addNodeColorCapacity(new NodeColorCapacityItem(NodeColors.CONTRACTOR,contractorPercent)); }- Parameters:
item- the nodeColorCapacityItem- See Also:
-
getColorCapacityItemByColorCode
Gets theNodeColorCapacityItemwhich limit the amount ofColorcodedNodesaResourcecan give service to. This way can be made sure thatNodeswith a certainColorare not overrepresented and can be used for white space generation.- Parameters:
colorCode- the int code of the color- Returns:
- the NodeColorCapacityItem or an empty Optional if no colorCapaciy has been set.
- See Also:
-
isNodeColorCodingInUse
boolean isNodeColorCodingInUse()Checks if anyINodeColorhas been set through the use of aNodeColorCapacityItem.- Returns:
- true if this is the case
-
getPresentColorCodes
Gets theINodeColorthat are in use.- Returns:
- the Color codes
- See Also:
-
getNodeColorCapacityMap
Map<Integer,NodeColorCapacityItem> getNodeColorCapacityMap()Gets the aMapof theNodeColorCapacity. For more information please seeINodeColorandNodeColorCapacityItem.- Returns:
- the map of colorCapacity
-
addQualification
Adds aIQualificationto theIWorkingHours, which means that by adding aIConstraintto theINode, they are limited to whichNodesthey can give service.- Parameters:
qualification- the IQualification that is to be added
-
getQualifications
Map<Class<? extends IQualification>,IQualification> getQualifications()Gets theIQualificationof theIWorkingHours.- Returns:
- the node qualifications
- See Also:
-
setResourceDepot
-
getResourceDepot
Optional<IResourceDepot> getResourceDepot() -
setStartTimeHook
-
getRouteStartShiftMillisHook
-
hasHook
boolean hasHook() -
addConnectionHook
-
getConnectionHook
-
getConnectionHooks
Optional<Map<String,ReducedNodeEdgeConnectorItem>> getConnectionHooks() -
setConnectionHooks
-
setMaxWorkingTime(Duration)instead