Commit cdaaaeee authored by Georgios Dagkakis's avatar Georgios Dagkakis

allow the definition of shift in weekends

parent 07cb738f
...@@ -141,7 +141,7 @@ class ReadJSShifts(plugin.InputPreparationPlugin, TimeSupportMixin): ...@@ -141,7 +141,7 @@ class ReadJSShifts(plugin.InputPreparationPlugin, TimeSupportMixin):
#sorts the list in case the records were not entered in correct ascending order #sorts the list in case the records were not entered in correct ascending order
for info in exceptionShiftPattern: for info in exceptionShiftPattern:
exceptionShiftPattern[info].sort(key=itemgetter(0)) exceptionShiftPattern[info].sort(key=itemgetter(0))
# ================================================================ # ================================================================
#create default pattern for all operators (10 days long) #create default pattern for all operators (10 days long)
timeStartList = [] timeStartList = []
...@@ -188,23 +188,30 @@ class ReadJSShifts(plugin.InputPreparationPlugin, TimeSupportMixin): ...@@ -188,23 +188,30 @@ class ReadJSShifts(plugin.InputPreparationPlugin, TimeSupportMixin):
# calculate the number of days till the end of the exception # calculate the number of days till the end of the exception
else: else:
exceptionDay = math.floor((exception[-1] - hoursToEndFirstDay.total_seconds()/3600)/24) + 1 exceptionDay = math.floor((exception[-1] - hoursToEndFirstDay.total_seconds()/3600)/24) + 1
for index2, default in enumerate(defaultShiftPattern[node]): # check the weekday
# check if we still are in the first day exceptionDate=now+datetime.timedelta(days=exceptionDay)
if hoursToEndFirstDay.total_seconds()/3600 > default[-1]: # if it is weekend create shift entry for that date. The default pattern does not need to be changed
defaultDay = 0 if exceptionDate.weekday() in [5,6]:
# calculate the number of days till the end of the default shift defaultShiftPattern[node].append(exception)
else: # for exceptions in weekdays
defaultDay = math.floor((default[-1] - hoursToEndFirstDay.total_seconds()/3600)/24) + 1 else:
if exceptionDay == defaultDay: for index2, default in enumerate(defaultShiftPattern[node]):
# update the defaultShiftPattern of the node (operator or machine) # check if we still are in the first day
# if the exception day has not been modified then delete the previous entry and use the first exception that occurs if hoursToEndFirstDay.total_seconds()/3600 > default[-1]:
if not exceptionDay in modifiedDefaultDays: defaultDay = 0
defaultShiftPattern[node][index2] = exception # calculate the number of days till the end of the default shift
# otherwise append it at the end else:
else: defaultDay = math.floor((default[-1] - hoursToEndFirstDay.total_seconds()/3600)/24) + 1
defaultShiftPattern[node].append(exception) if exceptionDay == defaultDay:
modifiedDefaultDays.append(exceptionDay) # the day has been modified, add to the modified days # update the defaultShiftPattern of the node (operator or machine)
break # if the exception day has not been modified then delete the previous entry and use the first exception that occurs
if not exceptionDay in modifiedDefaultDays:
defaultShiftPattern[node][index2] = exception
# otherwise append it at the end
else:
defaultShiftPattern[node].append(exception)
modifiedDefaultDays.append(exceptionDay) # the day has been modified, add to the modified days
break
# update the interruptions of the nodes that have a defaultShiftPattern # update the interruptions of the nodes that have a defaultShiftPattern
if node in defaultShiftPattern: if node in defaultShiftPattern:
# sort the shift pattern of every node # sort the shift pattern of every node
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment