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 TypeMethodDescriptionboolean
void
addConstraint
(IWorkingHoursLevelConstraint wohLevelConstraint) Adds aConstraint
to theWorkingHours
so onlyResources
with that specificQualification
will be able to serve theNodes
to which thoseWorkingHours
are applied.void
addConstraint
(IMultiWorkingHoursLevelConstraint wohLevelConstraint) void
Adds a certainINodeColor
to theResource
.void
addQualification
(IQualification qualification) Adds aIQualification
to theIWorkingHours
, which means that by adding aIConstraint
to theINode
, they are limited to whichNodes
they 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 theNodeColorCapacityItem
which limit the amount ofColor
codedNodes
aResource
can give service to.getConnectionHook
(String toId) Gets theConstraints
set on theIResource
.boolean
Gets if theResource
is allowed to do anovernight stay
.Gets thelocalFlexTime
in milliseconds.Gets thefreePostWorkDrivingTerminationTime
in milliseconds.Gets thelocalMaxPillarAfterHoursTime
ofIPillarNode
in milliseconds.Gets thelocalMaxRouteStartReductionTime
in milliseconds.Gets thelocalMaxRouteStartReductionTime
forIPillarNode
in milliseconds.Gets theDuration
of the potential localstayout cycle
.Gets the start of the localstayout cycle
.double
Gets theWorkingHours.maxDistance
, which is the maximal distance in km aResource
is allowed to travel without aIViolation
per day.double
Gets maximum number of hours aResource
is allowed to work per day inhours
.Gets the aMap
of theNodeColorCapacity
.Gets theINodeColor
that are in use.Map<Class<? extends IQualification>,
IQualification> Gets theIQualification
of theIWorkingHours
.boolean
hasHook()
boolean
Checks if the route is closed or not, the default value isfalse
.Checks whether thelocalMaxRouteStartReductionTime
is included in theWorkingHours
.Checks whether the potentially setlocalMaxRouteStartReductionTime
can only be used for driving, not for working.Checks whether the potentially setlocalMaxRouteStartReductionTime
forIPillarNode
can only be used for driving, not for working.boolean
Checks if anyINodeColor
has been set through the use of aNodeColorCapacityItem
.boolean
void
setIsAvailableForStay
(boolean isAvailableForStay) Sets if theResource
is allowed for anovernight stay
instead of returning to the starting location.void
setIsClosedRoute
(boolean isClosedRoute) Sets theRoute
to aclosed Route
.boolean
setLocalFlexTime
(Duration idleTimeReductionTime) Sets the amount of time aResource
can be expected to start working later and stay longer at work if needed.boolean
setLocalMaxFreePostWorkDrivingTerminationTime
(Duration postWorkingHourTimeReductionTime) Sets the amount of time theResource
can be expected to drive home to its starting location in its free time.boolean
setLocalMaxFreePostWorkDrivingTerminationTime
(Duration postTimeReductionTime, boolean onlyApplyOnOvertime) Sets the local max free post work driving termination time.boolean
setLocalMaxPillarAfterHoursTime
(Duration maxPillarEndOverTime) Sets the amount of time afterWorkingHours
within which aIPillarNode
can be set.boolean
setLocalMaxRouteStartReductionTime
(Duration maxRouteStartReductionTime, boolean isOnlyUsedForDriving) Sets the maximum time which theResource
can be expected to drive to the firstNode
in its private time.boolean
setLocalMaxRouteStartReductionTimePillar
(Duration maxRouteStartReductionTime, boolean isOnlyUsedForDriving) Sets thelocalMaxRouteStartReductionTime
forIPillarNode
.void
setLocalReductionTimeIsIncludedInWorkingTime
(boolean isIncludedInTotalWorkingTime) Sets whether thelocalMaxRouteStartReductionTime
is included in theWorkingHours
.void
setLocalStayOutCycleDefinition
(Duration cycle, LocalDate cycleStart) Sets theDuration
of the cycle within which the maximum number ofovernight stays
are allowed and within which the minimumrecovery time
(WorkingHours
withoutovernight stays
) has to be observed.void
setMaxDistance
(javax.measure.Quantity<javax.measure.quantity.Length> maxDistance) Sets the maximal distance that aResource
is allowed to travel per day, cannot be null.void
setMaxHours
(Duration maxWorkingTime) Deprecated.void
setMaxWorkingTime
(Duration maxWorkingTime) Sets the maximum number of hours aResource
is allowed to work per day.void
setResourceDepot
(IResourceDepot depot) boolean
setStartTimeHook
(Duration routeStartTimeHookDuration) Methods inherited from interface java.lang.Comparable
compareTo
Methods inherited from interface com.dna.jopt.member.unit.hours.IDutyHours
getFlavour, getTimeWindow, isPrefferedHour, setIsPrefferedHour
-
Method Details
-
getMaxHours
double getMaxHours()Gets maximum number of hours aResource
is 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 aResource
is allowed to travel without aIViolation
per day.- Returns:
- double
maxDistance
in km. By default it is not usable and the value is -1.
-
getIsAvailableForStay
boolean getIsAvailableForStay()Gets if theResource
is allowed to do anovernight stay
. TheNode
also needsINode.setIsStayNode(boolean)
set totrue
so this function can be used.This method is specific for the set
WorkingHours
and can therefore be specific for certain days in the week (noovernight stays
on Fridays.- Returns:
- boolean, the default value is
true
.
-
setIsAvailableForStay
void setIsAvailableForStay(boolean isAvailableForStay) Sets if theResource
is allowed for anovernight stay
instead of returning to the starting location. TheNode
also needsINode.setIsStayNode(boolean)
set totrue
so this function can be used.- Parameters:
isAvailableForStay
- boolean, the default value istrue
.
-
setMaxWorkingTime
Sets the maximum number of hours aResource
is allowed to work per day.- Parameters:
maxWorkingTime
- the maximal working time
-
setMaxHours
Deprecated.please usesetMaxWorkingTime(Duration)
insteadDecrecated methodSets the
WorkingHours.maxHours
aResource
is 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 aResource
is allowed to travel per day, cannot be null.- Parameters:
maxDistance
- the quantity, will becasted
to kilometre
-
setIsClosedRoute
void setIsClosedRoute(boolean isClosedRoute) Sets theRoute
to aclosed Route
. Aclosed Route
is aRoute
where theResource
is going to its home afterwards. Anopen Route
is aRoute
where theResource
is simply staying at the lastNode
ifOverNightStay
also has been activated or where theResource
has 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 Route
is aRoute
where theResource
is going to its home afterwards. Anopen Route
is aRoute
where theResource
is simply staying at the lastNode
ifOverNightStay
also has been activated or where theResource
has to travel home outside of theWorkingHours
. The default value is true.- Returns:
- the boolean
isClosedRoute
- See Also:
-
setLocalStayOutCycleDefinition
Sets theDuration
of the cycle within which the maximum number ofovernight stays
are allowed and within which the minimumrecovery time
(WorkingHours
withoutovernight stays
) has to be observed. Therecovery time
is set inIResource.setStayOutCycleDefinition(Duration, LocalDate)
.Without setting the cycle the maximal number of
overnight stays
will not be refreshed and count for the full duration of theWorkingHours
. The cycle can be applied to the localResource
which means it will stay the same for thisResource
throughout theOptimization
. If like here setlocally
it is only valid for thisWorkingHours
and the cycle can change depending on the dates or time in the week. It can for example be set that noovernight stays
are allowed on Fridays.- Parameters:
cycle
- duration of the cyclecycleStart
- the localDate of the cycle start
-
getLocalStayOutCycle
Gets theDuration
of 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 theResource
can be expected to drive to the firstNode
in its private time.If the
OpeningHours
of aNode
and theWorkingHours
of aResource
start at 8 the driving time is an hour and theResource
'slocalMaxRouteStartReductionTime
is 30 Minutes theResource
will start driving towards theNode
at 7.30 (outside of itsWorkingHours
) and arrive there at 8.30.The
Boolean
defines whether thelocalMaxRouteStartReductionTime
can only be used for driving or not and is usually set totrue
. TheResource
can not work in thelocalMaxRouteStartReductionTime
in that case.If like here set
locally
thelocalMaxRouteStartReductionTime
is 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 thelocalMaxRouteStartReductionTime
forIPillarNode
. Overwrites the setlocalMaxRouteStartReductionTime
and sets the new value forPillars
. If nolocalMaxRouteStartReductionTime
has been set, sets the new value forPillars
only.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 thelocalMaxRouteStartReductionTime
is included in theWorkingHours
. The default value isfalse
. Iffalse
andsetLocalMaxRouteStartReductionTime(Duration, boolean)
is set totrue
the driving time to the firstNode
has to be done in theResources
private 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 setlocalMaxRouteStartReductionTime
can 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
localMaxRouteStartReductionTime
has been set
-
isLocalReductionTimeOnlyUsedForDrivingPillar
Checks whether the potentially setlocalMaxRouteStartReductionTime
forIPillarNode
can 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
localMaxRouteStartReductionTime
has been set
-
isLocalReductionTimeIncludedInWorkingTime
Checks whether thelocalMaxRouteStartReductionTime
is included in theWorkingHours
. The default value isfalse
. Iffalse
andsetLocalMaxRouteStartReductionTime(Duration, boolean)
is set totrue
the driving time to the firstNode
has to be done in theResources
private timeFor more information please see
setLocalMaxRouteStartReductionTime(Duration, boolean)
.- Returns:
- the status of an empty Optional if no
localMaxRouteStartReductionTime
has been set
-
getLocalMaxRouteStartReductionTimeMillis
Gets thelocalMaxRouteStartReductionTime
in milliseconds.For more information please see
setLocalMaxRouteStartReductionTime(Duration, boolean)
.- Returns:
- the status or an empty optional if no
localMaxRouteStartReductionTime
has been set
-
getLocalMaxRouteStartReductionTimeMillisPillar
Gets thelocalMaxRouteStartReductionTime
forIPillarNode
in milliseconds.For more information please see
setLocalMaxRouteStartReductionTimePillar(Duration, boolean)
andsetLocalMaxRouteStartReductionTime(Duration, boolean)
.- Returns:
- the status or an empty optional if no
localMaxRouteStartReductionTime
has been set
-
setLocalFlexTime
Sets the amount of time aResource
can be expected to start working later and stay longer at work if needed.If the first
Node
is at 11, theResources WorkingHours
started at 8 and thelocalFlexTime
is set to 3 hours, theResource
starts working at 11 and has to stay 3 hours longer at work than usual. If thelocalFlexTime
in the above example is set to 2 hours, theResource
will 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 thelocalFlexTime
in milliseconds.For more information please see
setLocalFlexTime(Duration)
.- Returns:
- the long local flex time in milliseconds, an empty Optional if no
localFlexTime
has been set
-
setLocalMaxFreePostWorkDrivingTerminationTime
Sets the amount of time theResource
can be expected to drive home to its starting location in its free time.If returning from the last
Node
to the starting location takes 1 hour and thefreePostWorkDrivingTerminationTime
is 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 time
locally. Therefore different times can be set for differentWorkingHours
. If the time should be valid for all theWorkingHours
of aResource
please 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 thefreePostWorkDrivingTerminationTime
in milliseconds.For more information please see
setLocalMaxFreePostWorkDrivingTerminationTime(Duration)
.- Returns:
- the value or an empty Optional if no
freePostWorkDrivingTerminationTime
has been set
-
setLocalMaxPillarAfterHoursTime
Sets the amount of time afterWorkingHours
within which aIPillarNode
can be set. TheResources
have to visit thisPillar
even 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 theWorkingHours
of aPillar
please 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 thelocalMaxPillarAfterHoursTime
ofIPillarNode
in 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:
copy
in interfaceIDutyHours
- Returns:
- a copy of the WorkingHours
-
addConstraint
Adds aConstraint
to theWorkingHours
so onlyResources
with that specificQualification
will be able to serve theNodes
to which thoseWorkingHours
are applied.For examples see
UKPostCodeQualification
andUKPostCodeConstraint
- Parameters:
wohLevelConstraint
- the iWorkingHoursLevelConstraint to add to the workingHours
-
addConstraint
-
getMultiConstraints
List<IMultiWorkingHoursLevelConstraint> getMultiConstraints() -
getConstraints
List<IWorkingHoursLevelConstraint> getConstraints()Gets theConstraints
set on theIResource
. TheResource
can only work onNodes
within within the range of itsConstraint
.An example of its implementation is
UKPostCodeConstraint
.- Returns:
- the workingHours constraints
-
addNodeColorCapacity
Adds a certainINodeColor
to theResource
. This way can be made sure thatNodes
with a certainColor
are 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 theNodeColorCapacityItem
which limit the amount ofColor
codedNodes
aResource
can give service to. This way can be made sure thatNodes
with a certainColor
are 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 anyINodeColor
has been set through the use of aNodeColorCapacityItem
.- Returns:
- true if this is the case
-
getPresentColorCodes
Gets theINodeColor
that are in use.- Returns:
- the Color codes
- See Also:
-
getNodeColorCapacityMap
Map<Integer,NodeColorCapacityItem> getNodeColorCapacityMap()Gets the aMap
of theNodeColorCapacity
. For more information please seeINodeColor
andNodeColorCapacityItem
.- Returns:
- the map of colorCapacity
-
addQualification
Adds aIQualification
to theIWorkingHours
, which means that by adding aIConstraint
to theINode
, they are limited to whichNodes
they can give service.- Parameters:
qualification
- the IQualification that is to be added
-
getQualifications
Map<Class<? extends IQualification>,IQualification> getQualifications()Gets theIQualification
of 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