go
This commit is contained in:
@@ -17,7 +17,7 @@ import operator
|
||||
|
||||
use_neos = False
|
||||
|
||||
weeks_to_rota = 26
|
||||
weeks_to_rota = 52
|
||||
|
||||
sites = ("truro", "exeter", "torquay", "barnstaple", "plymouth")
|
||||
|
||||
@@ -29,13 +29,13 @@ Rota = RotaBuilder(datetime.date(2020, 9, 7),
|
||||
|
||||
rota_collections = {
|
||||
"current": deepcopy(Rota),
|
||||
"extended proc nights only": deepcopy(Rota),
|
||||
"no weekends": deepcopy(Rota),
|
||||
"no twighlights": deepcopy(Rota),
|
||||
"no nights": deepcopy(Rota),
|
||||
"nights + proc twighlights3 + normal weekends": deepcopy(Rota),
|
||||
"nights + proc twighlights4 + normal weekends": deepcopy(Rota),
|
||||
"nights + proc twighlights + proc weekends": deepcopy(Rota),
|
||||
# "extended proc nights only": deepcopy(Rota),
|
||||
# "no weekends": deepcopy(Rota),
|
||||
# "no twighlights": deepcopy(Rota),
|
||||
# "no nights": deepcopy(Rota),
|
||||
# "nights + proc twighlights3 + normal weekends": deepcopy(Rota),
|
||||
# "nights + proc twighlights4 + normal weekends": deepcopy(Rota),
|
||||
# "nights + proc twighlights + proc weekends": deepcopy(Rota),
|
||||
}
|
||||
|
||||
rota_collections['current'].add_shifts(
|
||||
@@ -86,249 +86,257 @@ rota_collections['current'].add_shifts(
|
||||
constraints=["night"]),
|
||||
)
|
||||
|
||||
rota_collections['extended proc nights only'].add_shifts(
|
||||
#SingleShift((sites), "night", 12.5, days, balance_weighting=1, workers_required=3, rota_on_nwds=True),
|
||||
SingleShift((sites),
|
||||
"night_weekday",
|
||||
13,
|
||||
days[:4],
|
||||
balance_offset=5,
|
||||
balance_weighting=1,
|
||||
workers_required=3,
|
||||
force_as_block=False,
|
||||
rota_on_nwds=True,
|
||||
constraints=["night"]),
|
||||
SingleShift((sites),
|
||||
"night_weekend",
|
||||
13,
|
||||
days[4:],
|
||||
balance_offset=4,
|
||||
balance_weighting=1,
|
||||
workers_required=3,
|
||||
force_as_block=False,
|
||||
rota_on_nwds=True,
|
||||
constraints=["night"]),
|
||||
)
|
||||
# rota_collections['extended proc nights only'].add_shifts(
|
||||
# #SingleShift((sites), "night", 12.5, days, balance_weighting=1, workers_required=3, rota_on_nwds=True),
|
||||
# SingleShift((sites),
|
||||
# "night_weekday",
|
||||
# 13,
|
||||
# days[:4],
|
||||
# balance_offset=5,
|
||||
# balance_weighting=1,
|
||||
# workers_required=3,
|
||||
# force_as_block=False,
|
||||
# rota_on_nwds=True,
|
||||
# constraints=["night"]),
|
||||
# SingleShift((sites),
|
||||
# "night_weekend",
|
||||
# 13,
|
||||
# days[4:],
|
||||
# balance_offset=4,
|
||||
# balance_weighting=1,
|
||||
# workers_required=3,
|
||||
# force_as_block=False,
|
||||
# rota_on_nwds=True,
|
||||
# constraints=["night"]),
|
||||
# )
|
||||
|
||||
rota_collections['no weekends'].add_shifts(
|
||||
SingleShift(("exeter", ), "exeter_twilight", 12.5, days[:5]),
|
||||
SingleShift(("truro", ), "truro_twilight", 12.5, days[:5]),
|
||||
SingleShift(("torquay", ), "torquay_twilight", 12.5, days[:5]),
|
||||
SingleShift(("plymouth", ), "plymouth_twilight", 12.5, days[:5]),
|
||||
#SingleShift((sites), "night", 12.5, days, balance_weighting=1, workers_required=3, rota_on_nwds=True),
|
||||
SingleShift((sites),
|
||||
"night_weekday",
|
||||
13,
|
||||
days[:4],
|
||||
balance_offset=5,
|
||||
balance_weighting=1,
|
||||
workers_required=3,
|
||||
force_as_block=False,
|
||||
rota_on_nwds=True,
|
||||
constraints=["night"]),
|
||||
SingleShift((sites),
|
||||
"night_weekend",
|
||||
13,
|
||||
days[4:],
|
||||
balance_offset=4,
|
||||
balance_weighting=1,
|
||||
workers_required=3,
|
||||
force_as_block=False,
|
||||
rota_on_nwds=True,
|
||||
constraints=["night"]),
|
||||
)
|
||||
# rota_collections['no weekends'].add_shifts(
|
||||
# SingleShift(("exeter", ), "exeter_twilight", 12.5, days[:5]),
|
||||
# SingleShift(("truro", ), "truro_twilight", 12.5, days[:5]),
|
||||
# SingleShift(("torquay", ), "torquay_twilight", 12.5, days[:5]),
|
||||
# SingleShift(("plymouth", ), "plymouth_twilight", 12.5, days[:5]),
|
||||
# #SingleShift((sites), "night", 12.5, days, balance_weighting=1, workers_required=3, rota_on_nwds=True),
|
||||
# SingleShift((sites),
|
||||
# "night_weekday",
|
||||
# 13,
|
||||
# days[:4],
|
||||
# balance_offset=5,
|
||||
# balance_weighting=1,
|
||||
# workers_required=3,
|
||||
# force_as_block=False,
|
||||
# rota_on_nwds=True,
|
||||
# constraints=["night"]),
|
||||
# SingleShift((sites),
|
||||
# "night_weekend",
|
||||
# 13,
|
||||
# days[4:],
|
||||
# balance_offset=4,
|
||||
# balance_weighting=1,
|
||||
# workers_required=3,
|
||||
# force_as_block=False,
|
||||
# rota_on_nwds=True,
|
||||
# constraints=["night"]),
|
||||
# )
|
||||
|
||||
rota_collections['no twighlights'].add_shifts(
|
||||
SingleShift(("exeter", ),
|
||||
"weekend_exeter",
|
||||
12.5,
|
||||
days[5:],
|
||||
assign_as_block=True),
|
||||
SingleShift(("truro", ),
|
||||
"weekend_truro",
|
||||
12.5,
|
||||
days[5:],
|
||||
assign_as_block=True),
|
||||
SingleShift(("torquay", ),
|
||||
"weekend_torquay",
|
||||
12.5,
|
||||
days[5:],
|
||||
assign_as_block=True),
|
||||
SingleShift(("plymouth", ),
|
||||
"weekend_plymouth",
|
||||
8,
|
||||
days[5:],
|
||||
workers_required=2,
|
||||
assign_as_block=True),
|
||||
#SingleShift((sites), "night", 12.5, days, balance_weighting=1, workers_required=3, rota_on_nwds=True),
|
||||
SingleShift((sites),
|
||||
"night_weekday",
|
||||
13,
|
||||
days[:4],
|
||||
balance_offset=5,
|
||||
balance_weighting=1,
|
||||
workers_required=3,
|
||||
force_as_block=False,
|
||||
rota_on_nwds=True,
|
||||
constraints=["night"]),
|
||||
SingleShift((sites),
|
||||
"night_weekend",
|
||||
13,
|
||||
days[4:],
|
||||
balance_offset=4,
|
||||
balance_weighting=1,
|
||||
workers_required=3,
|
||||
force_as_block=False,
|
||||
rota_on_nwds=True,
|
||||
constraints=["night"]),
|
||||
)
|
||||
# rota_collections['no twighlights'].add_shifts(
|
||||
# SingleShift(("exeter", ),
|
||||
# "weekend_exeter",
|
||||
# 12.5,
|
||||
# days[5:],
|
||||
# assign_as_block=True),
|
||||
# SingleShift(("truro", ),
|
||||
# "weekend_truro",
|
||||
# 12.5,
|
||||
# days[5:],
|
||||
# assign_as_block=True),
|
||||
# SingleShift(("torquay", ),
|
||||
# "weekend_torquay",
|
||||
# 12.5,
|
||||
# days[5:],
|
||||
# assign_as_block=True),
|
||||
# SingleShift(("plymouth", ),
|
||||
# "weekend_plymouth",
|
||||
# 8,
|
||||
# days[5:],
|
||||
# workers_required=2,
|
||||
# assign_as_block=True),
|
||||
# #SingleShift((sites), "night", 12.5, days, balance_weighting=1, workers_required=3, rota_on_nwds=True),
|
||||
# SingleShift((sites),
|
||||
# "night_weekday",
|
||||
# 13,
|
||||
# days[:4],
|
||||
# balance_offset=5,
|
||||
# balance_weighting=1,
|
||||
# workers_required=3,
|
||||
# force_as_block=False,
|
||||
# rota_on_nwds=True,
|
||||
# constraints=["night"]),
|
||||
# SingleShift((sites),
|
||||
# "night_weekend",
|
||||
# 13,
|
||||
# days[4:],
|
||||
# balance_offset=4,
|
||||
# balance_weighting=1,
|
||||
# workers_required=3,
|
||||
# force_as_block=False,
|
||||
# rota_on_nwds=True,
|
||||
# constraints=["night"]),
|
||||
# )
|
||||
|
||||
rota_collections['no nights'].add_shifts(
|
||||
SingleShift(("exeter", ), "exeter_twilight", 12.5, days[:5]),
|
||||
SingleShift(("truro", ), "truro_twilight", 12.5, days[:5]),
|
||||
SingleShift(("torquay", ), "torquay_twilight", 12.5, days[:5]),
|
||||
SingleShift(("plymouth", ), "plymouth_twilight", 12.5, days[:5]),
|
||||
SingleShift(("exeter", ),
|
||||
"weekend_exeter",
|
||||
12.5,
|
||||
days[5:],
|
||||
assign_as_block=True),
|
||||
SingleShift(("truro", ),
|
||||
"weekend_truro",
|
||||
12.5,
|
||||
days[5:],
|
||||
assign_as_block=True),
|
||||
SingleShift(("torquay", ),
|
||||
"weekend_torquay",
|
||||
12.5,
|
||||
days[5:],
|
||||
assign_as_block=True),
|
||||
SingleShift(("plymouth", ),
|
||||
"weekend_plymouth",
|
||||
8,
|
||||
days[5:],
|
||||
workers_required=2,
|
||||
assign_as_block=True),
|
||||
#SingleShift((sites), "night", 12.5, days, balance_weighting=1, workers_required=3, rota_on_nwds=True),
|
||||
)
|
||||
# rota_collections['no nights'].add_shifts(
|
||||
# SingleShift(("exeter", ), "exeter_twilight", 12.5, days[:5]),
|
||||
# SingleShift(("truro", ), "truro_twilight", 12.5, days[:5]),
|
||||
# SingleShift(("torquay", ), "torquay_twilight", 12.5, days[:5]),
|
||||
# SingleShift(("plymouth", ), "plymouth_twilight", 12.5, days[:5]),
|
||||
# SingleShift(("exeter", ),
|
||||
# "weekend_exeter",
|
||||
# 12.5,
|
||||
# days[5:],
|
||||
# assign_as_block=True),
|
||||
# SingleShift(("truro", ),
|
||||
# "weekend_truro",
|
||||
# 12.5,
|
||||
# days[5:],
|
||||
# assign_as_block=True),
|
||||
# SingleShift(("torquay", ),
|
||||
# "weekend_torquay",
|
||||
# 12.5,
|
||||
# days[5:],
|
||||
# assign_as_block=True),
|
||||
# SingleShift(("plymouth", ),
|
||||
# "weekend_plymouth",
|
||||
# 8,
|
||||
# days[5:],
|
||||
# workers_required=2,
|
||||
# assign_as_block=True),
|
||||
# #SingleShift((sites), "night", 12.5, days, balance_weighting=1, workers_required=3, rota_on_nwds=True),
|
||||
# )
|
||||
|
||||
rota_collections['nights + proc twighlights4 + normal weekends'].add_shifts(
|
||||
SingleShift((sites), "proc_twilight", 12.5, days[:5], workers_required=4),
|
||||
SingleShift(("exeter", ),
|
||||
"weekend_exeter",
|
||||
12.5,
|
||||
days[5:],
|
||||
assign_as_block=True),
|
||||
SingleShift(("truro", ),
|
||||
"weekend_truro",
|
||||
12.5,
|
||||
days[5:],
|
||||
assign_as_block=True),
|
||||
SingleShift(("torquay", ),
|
||||
"weekend_torquay",
|
||||
12.5,
|
||||
days[5:],
|
||||
assign_as_block=True),
|
||||
SingleShift(("plymouth", ),
|
||||
"weekend_plymouth",
|
||||
8,
|
||||
days[5:],
|
||||
workers_required=2,
|
||||
assign_as_block=True),
|
||||
#SingleShift((sites), "night", 12.5, days, balance_weighting=1, workers_required=3, rota_on_nwds=True),
|
||||
SingleShift((sites),
|
||||
"night_weekday",
|
||||
12.25,
|
||||
days[:4],
|
||||
balance_offset=5,
|
||||
balance_weighting=1,
|
||||
workers_required=3,
|
||||
force_as_block=False,
|
||||
rota_on_nwds=True,
|
||||
constraints=["night"]),
|
||||
SingleShift((sites),
|
||||
"night_weekend",
|
||||
12.25,
|
||||
days[4:],
|
||||
balance_offset=4,
|
||||
balance_weighting=1,
|
||||
workers_required=3,
|
||||
force_as_block=False,
|
||||
rota_on_nwds=True,
|
||||
constraints=["night"]),
|
||||
)
|
||||
# rota_collections['nights + proc twighlights4 + normal weekends'].add_shifts(
|
||||
# SingleShift((sites), "proc_twilight", 12.5, days[:5], workers_required=4),
|
||||
# SingleShift(("exeter", ),
|
||||
# "weekend_exeter",
|
||||
# 12.5,
|
||||
# days[5:],
|
||||
# assign_as_block=True),
|
||||
# SingleShift(("truro", ),
|
||||
# "weekend_truro",
|
||||
# 12.5,
|
||||
# days[5:],
|
||||
# assign_as_block=True),
|
||||
# SingleShift(("torquay", ),
|
||||
# "weekend_torquay",
|
||||
# 12.5,
|
||||
# days[5:],
|
||||
# assign_as_block=True),
|
||||
# SingleShift(("plymouth", ),
|
||||
# "weekend_plymouth",
|
||||
# 8,
|
||||
# days[5:],
|
||||
# workers_required=2,
|
||||
# assign_as_block=True),
|
||||
# #SingleShift((sites), "night", 12.5, days, balance_weighting=1, workers_required=3, rota_on_nwds=True),
|
||||
# SingleShift((sites),
|
||||
# "night_weekday",
|
||||
# 12.25,
|
||||
# days[:4],
|
||||
# balance_offset=5,
|
||||
# balance_weighting=1,
|
||||
# workers_required=3,
|
||||
# force_as_block=False,
|
||||
# rota_on_nwds=True,
|
||||
# constraints=["night"]),
|
||||
# SingleShift((sites),
|
||||
# "night_weekend",
|
||||
# 12.25,
|
||||
# days[4:],
|
||||
# balance_offset=4,
|
||||
# balance_weighting=1,
|
||||
# workers_required=3,
|
||||
# force_as_block=False,
|
||||
# rota_on_nwds=True,
|
||||
# constraints=["night"]),
|
||||
# )
|
||||
|
||||
rota_collections['nights + proc twighlights3 + normal weekends'].add_shifts(
|
||||
SingleShift((sites), "proc_twilight", 12.5, days[:5], workers_required=3),
|
||||
SingleShift(("exeter", ),
|
||||
"weekend_exeter",
|
||||
12.5,
|
||||
days[5:],
|
||||
assign_as_block=True),
|
||||
SingleShift(("truro", ),
|
||||
"weekend_truro",
|
||||
12.5,
|
||||
days[5:],
|
||||
assign_as_block=True),
|
||||
SingleShift(("torquay", ),
|
||||
"weekend_torquay",
|
||||
12.5,
|
||||
days[5:],
|
||||
assign_as_block=True),
|
||||
SingleShift(("plymouth", ),
|
||||
"weekend_plymouth",
|
||||
8,
|
||||
days[5:],
|
||||
workers_required=2,
|
||||
assign_as_block=True),
|
||||
#SingleShift((sites), "night", 12.5, days, balance_weighting=1, workers_required=3, rota_on_nwds=True),
|
||||
SingleShift((sites),
|
||||
"night_weekday",
|
||||
12.25,
|
||||
days[:4],
|
||||
balance_offset=5,
|
||||
balance_weighting=1,
|
||||
workers_required=3,
|
||||
force_as_block=False,
|
||||
rota_on_nwds=True,
|
||||
constraints=["night"]),
|
||||
SingleShift((sites),
|
||||
"night_weekend",
|
||||
12.25,
|
||||
days[4:],
|
||||
balance_offset=4,
|
||||
balance_weighting=1,
|
||||
workers_required=3,
|
||||
force_as_block=False,
|
||||
rota_on_nwds=True,
|
||||
constraints=["night"]),
|
||||
)
|
||||
# rota_collections['nights + proc twighlights3 + normal weekends'].add_shifts(
|
||||
# SingleShift((sites), "proc_twilight", 12.5, days[:5], workers_required=3),
|
||||
# SingleShift(("exeter", ),
|
||||
# "weekend_exeter",
|
||||
# 12.5,
|
||||
# days[5:],
|
||||
# assign_as_block=True),
|
||||
# SingleShift(("truro", ),
|
||||
# "weekend_truro",
|
||||
# 12.5,
|
||||
# days[5:],
|
||||
# assign_as_block=True),
|
||||
# SingleShift(("torquay", ),
|
||||
# "weekend_torquay",
|
||||
# 12.5,
|
||||
# days[5:],
|
||||
# assign_as_block=True),
|
||||
# SingleShift(("plymouth", ),
|
||||
# "weekend_plymouth",
|
||||
# 8,
|
||||
# days[5:],
|
||||
# workers_required=2,
|
||||
# assign_as_block=True),
|
||||
# #SingleShift((sites), "night", 12.5, days, balance_weighting=1, workers_required=3, rota_on_nwds=True),
|
||||
# SingleShift((sites),
|
||||
# "night_weekday",
|
||||
# 12.25,
|
||||
# days[:4],
|
||||
# balance_offset=5,
|
||||
# balance_weighting=1,
|
||||
# workers_required=3,
|
||||
# force_as_block=False,
|
||||
# rota_on_nwds=True,
|
||||
# constraints=["night"]),
|
||||
# SingleShift((sites),
|
||||
# "night_weekend",
|
||||
# 12.25,
|
||||
# days[4:],
|
||||
# balance_offset=4,
|
||||
# balance_weighting=1,
|
||||
# workers_required=3,
|
||||
# force_as_block=False,
|
||||
# rota_on_nwds=True,
|
||||
# constraints=["night"]),
|
||||
# )
|
||||
|
||||
rota_collections['nights + proc twighlights + proc weekends'].add_shifts(
|
||||
SingleShift((sites), "proc_twilight", 12.5, days[:5], workers_required=3),
|
||||
SingleShift((sites), "proc_weekends", 12.5, days[5:], workers_required=3),
|
||||
#SingleShift((sites), "night", 12.5, days, balance_weighting=1, workers_required=3, rota_on_nwds=True),
|
||||
SingleShift((sites),
|
||||
"night_weekday",
|
||||
12.25,
|
||||
days[:4],
|
||||
balance_offset=5,
|
||||
balance_weighting=1,
|
||||
workers_required=3,
|
||||
force_as_block=False,
|
||||
rota_on_nwds=True,
|
||||
constraints=["night"]),
|
||||
SingleShift((sites),
|
||||
"night_weekend",
|
||||
12.25,
|
||||
days[4:],
|
||||
balance_offset=4,
|
||||
balance_weighting=1,
|
||||
workers_required=3,
|
||||
force_as_block=False,
|
||||
rota_on_nwds=True,
|
||||
constraints=["night"]),
|
||||
)
|
||||
# rota_collections['nights + proc twighlights + proc weekends'].add_shifts(
|
||||
# SingleShift((sites), "proc_twilight", 12.5, days[:5], workers_required=3),
|
||||
# SingleShift((sites), "proc_weekends", 12.5, days[5:], workers_required=3),
|
||||
# #SingleShift((sites), "night", 12.5, days, balance_weighting=1, workers_required=3, rota_on_nwds=True),
|
||||
# SingleShift((sites),
|
||||
# "night_weekday",
|
||||
# 12.25,
|
||||
# days[:4],
|
||||
# balance_offset=5,
|
||||
# balance_weighting=1,
|
||||
# workers_required=3,
|
||||
# force_as_block=False,
|
||||
# rota_on_nwds=True,
|
||||
# constraints=["night"]),
|
||||
# SingleShift((sites),
|
||||
# "night_weekend",
|
||||
# 12.25,
|
||||
# days[4:],
|
||||
# balance_offset=4,
|
||||
# balance_weighting=1,
|
||||
# workers_required=3,
|
||||
# force_as_block=False,
|
||||
# rota_on_nwds=True,
|
||||
# constraints=["night"]),
|
||||
# )
|
||||
|
||||
|
||||
load_leave = True
|
||||
|
||||
if load_leave:
|
||||
import leave
|
||||
|
||||
leave = leave.load_leave()
|
||||
|
||||
# Import trainee data
|
||||
import csv
|
||||
@@ -347,16 +355,24 @@ with open('trainees.csv', newline='') as f:
|
||||
if fte == "0":
|
||||
continue
|
||||
|
||||
nwds = nwd.split(",").title() if nwd else None
|
||||
nwds = nwd.split("/") if nwd else None
|
||||
end_date = end_date if end_date else None
|
||||
oop = oop.split("-") if oop else None
|
||||
|
||||
|
||||
if load_leave:
|
||||
if name not in leave:
|
||||
raise ValueError("{} not found it leave requests".format(name))
|
||||
|
||||
leave_requests = [i[0] for i in leave[name] if i[0] != ""]
|
||||
|
||||
#print(nwds, end_date, oop)
|
||||
for rot in rota_collections:
|
||||
|
||||
Rota = rota_collections[rot]
|
||||
Rota.add_worker(
|
||||
Worker(Rota, n, name, site.lower(), int(grade[2]), int(fte),
|
||||
nwds, end_date, oop))
|
||||
nwds, end_date, oop, not_available_to_work=leave_requests))
|
||||
|
||||
with open("rotas.html", "w") as f:
|
||||
f.write("""<html>
|
||||
@@ -412,19 +428,19 @@ for rot in rota_collections:
|
||||
|
||||
ResultsHolder.export_rota_to_csv("rotas/" + rot)
|
||||
with open("rotas.html", "a") as f:
|
||||
f.write("----------------------------")
|
||||
f.write("<hr>")
|
||||
f.write("<h2>{}</h2>".format(rot))
|
||||
f.write("----------------------------")
|
||||
#f.write("----------------------------")
|
||||
f.write("\n\n")
|
||||
|
||||
for s in Rota.shifts:
|
||||
f.write("<pre>{}</pre>".format(s.get_shift_summary()))
|
||||
f.write("<div id='{}-{}-shift-summary' class='shift-summary'>{}</div>".format(rot, s.name, s.get_shift_summary()))
|
||||
f.write("\n")
|
||||
f.write("\n\n")
|
||||
|
||||
f.write(ResultsHolder.get_worker_timetable_html(table_name=rot))
|
||||
f.write("\n\n")
|
||||
f.write("<pre>{}</pre>".format(worker_shift_summary))
|
||||
f.write("<pre class='worker-shift-summary'>{}</pre>".format(worker_shift_summary))
|
||||
f.write("\n\n\n")
|
||||
#workers_no_pref = ResultsHolder.get_no_preference(Rota.model.no_pref) # list with the non-satisfied workers (work on Sat but not on Sun)
|
||||
#worker_night_block = ResultsHolder.get_night_blocks()
|
||||
|
||||
Reference in New Issue
Block a user