Add population of hours based on shift selected. #531
This commit is contained in:
parent
f5759c8cea
commit
44afc498c1
2 changed files with 49 additions and 37 deletions
|
|
@ -46,7 +46,7 @@ class AnalyticsController extends Controller
|
||||||
['Sun - Fri', 6, 0, 1, 2, 3, 4], // Sun - Fri
|
['Sun - Fri', 6, 0, 1, 2, 3, 4], // Sun - Fri
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $hour_shifts = [
|
//protected $hour_shifts = [
|
||||||
/*
|
/*
|
||||||
['00:00 - 09:00', 0, 1, 2, 3, 4, 5, 6, 7, 8],
|
['00:00 - 09:00', 0, 1, 2, 3, 4, 5, 6, 7, 8],
|
||||||
['01:00 - 10:00', 1, 2, 3, 4, 5, 6, 7, 8, 9],
|
['01:00 - 10:00', 1, 2, 3, 4, 5, 6, 7, 8, 9],
|
||||||
|
|
@ -56,8 +56,8 @@ class AnalyticsController extends Controller
|
||||||
['05:00 - 14:00', 5, 6, 7, 8, 9, 10, 11, 12, 13],
|
['05:00 - 14:00', 5, 6, 7, 8, 9, 10, 11, 12, 13],
|
||||||
['06:00 - 15:00', 6, 7, 8, 9, 10, 11, 12, 13, 14],
|
['06:00 - 15:00', 6, 7, 8, 9, 10, 11, 12, 13, 14],
|
||||||
*/
|
*/
|
||||||
['07:00 - 16:00', 7, 8, 9, 10, 11, 12, 13, 14, 15],
|
//['07:00 - 16:00', 7, 8, 9, 10, 11, 12, 13, 14, 15],
|
||||||
['08:00 - 17:00', 8, 9, 10, 11, 12, 13, 14, 15, 16],
|
//['08:00 - 17:00', 8, 9, 10, 11, 12, 13, 14, 15, 16],
|
||||||
/*
|
/*
|
||||||
['09:00 - 18:00', 9, 10, 11, 12, 13, 14, 15, 16, 17],
|
['09:00 - 18:00', 9, 10, 11, 12, 13, 14, 15, 16, 17],
|
||||||
['10:00 - 19:00', 10, 11, 12, 13, 14, 15, 16, 17, 18],
|
['10:00 - 19:00', 10, 11, 12, 13, 14, 15, 16, 17, 18],
|
||||||
|
|
@ -75,7 +75,7 @@ class AnalyticsController extends Controller
|
||||||
['22:00 - 07:00', 22, 23, 0, 1, 2, 3, 4, 5, 6],
|
['22:00 - 07:00', 22, 23, 0, 1, 2, 3, 4, 5, 6],
|
||||||
['23:00 - 08:00', 23, 0, 1, 2, 3, 4, 5, 6, 7],
|
['23:00 - 08:00', 23, 0, 1, 2, 3, 4, 5, 6, 7],
|
||||||
*/
|
*/
|
||||||
];
|
//];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Menu(selected="analytics_forecast")
|
* @Menu(selected="analytics_forecast")
|
||||||
|
|
@ -123,8 +123,9 @@ class AnalyticsController extends Controller
|
||||||
$shift = $req->request->get('shift_schedule');
|
$shift = $req->request->get('shift_schedule');
|
||||||
|
|
||||||
// TODO: populate the hour_shift array, depending on the shift selected
|
// TODO: populate the hour_shift array, depending on the shift selected
|
||||||
$hour_shift = $this->populateHourShift($shift);
|
$hour_shifts = $this->populateHourShift($shift);
|
||||||
|
|
||||||
|
error_log(print_r($hour_shifts, true));
|
||||||
// error_log(print_r($hub_list, true));
|
// error_log(print_r($hub_list, true));
|
||||||
|
|
||||||
// $hub_list = [ 6, 4, 36, 7, 8, 126, 127, 18, 12, 9, 60, 10, 21, 135 ];
|
// $hub_list = [ 6, 4, 36, 7, 8, 126, 127, 18, 12, 9, 60, 10, 21, 135 ];
|
||||||
|
|
@ -176,7 +177,7 @@ class AnalyticsController extends Controller
|
||||||
// error_log(print_r($scheduler_data, true));
|
// error_log(print_r($scheduler_data, true));
|
||||||
|
|
||||||
// run scheduler
|
// run scheduler
|
||||||
$sched_res = $this->runScheduler($scheduler_data);
|
$sched_res = $this->runScheduler($scheduler_data, $hour_shifts, $shift);
|
||||||
|
|
||||||
// tally total JOs for the month
|
// tally total JOs for the month
|
||||||
foreach ($scheduler_data as $sday_data)
|
foreach ($scheduler_data as $sday_data)
|
||||||
|
|
@ -251,7 +252,7 @@ class AnalyticsController extends Controller
|
||||||
return $day_data;
|
return $day_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function runScheduler($scheduler_data)
|
protected function runScheduler($scheduler_data, $hour_shifts, $shift)
|
||||||
{
|
{
|
||||||
// run python script to solve scheduling for riders
|
// run python script to solve scheduling for riders
|
||||||
|
|
||||||
|
|
@ -266,13 +267,18 @@ class AnalyticsController extends Controller
|
||||||
foreach ($scheduler_data as $weekday_data)
|
foreach ($scheduler_data as $weekday_data)
|
||||||
$args[] = implode('-', $weekday_data);
|
$args[] = implode('-', $weekday_data);
|
||||||
|
|
||||||
// error_log(print_r($args, true));
|
// add shift
|
||||||
|
$args[] = $shift;
|
||||||
|
|
||||||
|
//error_log(print_r($args, true));
|
||||||
|
|
||||||
error_log('running...' . $sched_script);
|
error_log('running...' . $sched_script);
|
||||||
|
|
||||||
$proc = new Process($args);
|
$proc = new Process($args);
|
||||||
$proc->run();
|
$proc->run();
|
||||||
|
|
||||||
|
//error_log('getErrorOutput() ' . $proc->getErrorOutput());
|
||||||
|
|
||||||
if (!$proc->isSuccessful())
|
if (!$proc->isSuccessful())
|
||||||
error_log('SCHEDULER DID NOT RUN PROPERLY');
|
error_log('SCHEDULER DID NOT RUN PROPERLY');
|
||||||
|
|
||||||
|
|
@ -311,7 +317,7 @@ class AnalyticsController extends Controller
|
||||||
|
|
||||||
$total_riders += $rider_count;
|
$total_riders += $rider_count;
|
||||||
|
|
||||||
$label = $this->day_shifts[$day_shift_index][0] . ' ' . $this->hour_shifts[$hour_shift_index][0];
|
$label = $this->day_shifts[$day_shift_index][0] . ' ' . $hour_shifts[$hour_shift_index][0];
|
||||||
|
|
||||||
$shifts[] = [
|
$shifts[] = [
|
||||||
'label' => $label,
|
'label' => $label,
|
||||||
|
|
@ -322,8 +328,8 @@ class AnalyticsController extends Controller
|
||||||
$rider_hours = [];
|
$rider_hours = [];
|
||||||
for ($i = 0; $i < 24; $i++)
|
for ($i = 0; $i < 24; $i++)
|
||||||
$rider_hours[$i] = 0;
|
$rider_hours[$i] = 0;
|
||||||
for ($i = 1; $i < count($this->hour_shifts[$hour_shift_index]); $i++)
|
for ($i = 1; $i < count($hour_shifts[$hour_shift_index]); $i++)
|
||||||
$rider_hours[$this->hour_shifts[$hour_shift_index][$i]] = 1;
|
$rider_hours[$hour_shifts[$hour_shift_index][$i]] = 1;
|
||||||
|
|
||||||
// error_log('allocating ' . $rider_count . ' for ' . $label);
|
// error_log('allocating ' . $rider_count . ' for ' . $label);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -45,32 +45,38 @@ def main():
|
||||||
for hour_index in range(0, len(hours)):
|
for hour_index in range(0, len(hours)):
|
||||||
req_hours[day_index][hour_index] = int(hours_data[hour_index])
|
req_hours[day_index][hour_index] = int(hours_data[hour_index])
|
||||||
|
|
||||||
# all hour shifts available
|
shift = sys.argv[8]
|
||||||
hour_shifts = [
|
hour_shifts = []
|
||||||
#['00 - 09', 0, 1, 2, 3, 4, 5, 6, 7, 8],
|
if shift == "24_7":
|
||||||
#['01 - 10', 1, 2, 3, 4, 5, 6, 7, 8, 9],
|
hour_shifts = [
|
||||||
#['02 - 11', 2, 3, 4, 5, 6, 7, 8, 9, 10],
|
['00 - 09', 0, 1, 2, 3, 4, 5, 6, 7, 8],
|
||||||
#['03 - 12', 3, 4, 5, 6, 7, 8, 9, 10, 11],
|
['01 - 10', 1, 2, 3, 4, 5, 6, 7, 8, 9],
|
||||||
#['04 - 13', 4, 5, 6, 7, 8, 9, 10, 11, 12],
|
['02 - 11', 2, 3, 4, 5, 6, 7, 8, 9, 10],
|
||||||
#['05 - 14', 5, 6, 7, 8, 9, 10, 11, 12, 13],
|
['03 - 12', 3, 4, 5, 6, 7, 8, 9, 10, 11],
|
||||||
#['06 - 15', 6, 7, 8, 9, 10, 11, 12, 13, 14],
|
['04 - 13', 4, 5, 6, 7, 8, 9, 10, 11, 12],
|
||||||
['07 - 16', 7, 8, 9, 10, 11, 12, 13, 14, 15],
|
['05 - 14', 5, 6, 7, 8, 9, 10, 11, 12, 13],
|
||||||
['08 - 17', 8, 9, 10, 11, 12, 13, 14, 15, 16]]
|
['06 - 15', 6, 7, 8, 9, 10, 11, 12, 13, 14],
|
||||||
#['09 - 18', 9, 10, 11, 12, 13, 14, 15, 16, 17],
|
['07 - 16', 7, 8, 9, 10, 11, 12, 13, 14, 15],
|
||||||
#['10 - 19', 10, 11, 12, 13, 14, 15, 16, 17, 18],
|
['08 - 17', 8, 9, 10, 11, 12, 13, 14, 15, 16],
|
||||||
#['11 - 20', 11, 12, 13, 14, 15, 16, 17, 18, 19],
|
['09 - 18', 9, 10, 11, 12, 13, 14, 15, 16, 17],
|
||||||
#['12 - 21', 12, 13, 14, 15, 16, 17, 18, 19, 20],
|
['10 - 19', 10, 11, 12, 13, 14, 15, 16, 17, 18],
|
||||||
#['13 - 22', 13, 14, 15, 16, 17, 18, 19, 20, 21],
|
['11 - 20', 11, 12, 13, 14, 15, 16, 17, 18, 19],
|
||||||
#['14 - 23', 14, 15, 16, 17, 18, 19, 20, 21, 22],
|
['12 - 21', 12, 13, 14, 15, 16, 17, 18, 19, 20],
|
||||||
#['15 - 00', 15, 16, 17, 18, 19, 20, 21, 22, 23],
|
['13 - 22', 13, 14, 15, 16, 17, 18, 19, 20, 21],
|
||||||
#['16 - 01', 16, 17, 18, 19, 20, 21, 22, 23, 0],
|
['14 - 23', 14, 15, 16, 17, 18, 19, 20, 21, 22],
|
||||||
#['17 - 02', 17, 18, 19, 20, 21, 22, 23, 0, 1],
|
['15 - 00', 15, 16, 17, 18, 19, 20, 21, 22, 23],
|
||||||
#['18 - 03', 18, 19, 20, 21, 22, 23, 0, 1, 2],
|
['16 - 01', 16, 17, 18, 19, 20, 21, 22, 23, 0],
|
||||||
#['19 - 04', 19, 20, 21, 22, 23, 0, 1, 2, 3],
|
['17 - 02', 17, 18, 19, 20, 21, 22, 23, 0, 1],
|
||||||
#['20 - 05', 20, 21, 22, 23, 0, 1, 2, 3, 4],
|
['18 - 03', 18, 19, 20, 21, 22, 23, 0, 1, 2],
|
||||||
#['21 - 06', 21, 22, 23, 0, 1, 2, 3, 4, 5],
|
['19 - 04', 19, 20, 21, 22, 23, 0, 1, 2, 3],
|
||||||
#['22 - 07', 22, 23, 0, 1, 2, 3, 4, 5, 6],
|
['20 - 05', 20, 21, 22, 23, 0, 1, 2, 3, 4],
|
||||||
#['23 - 08', 23, 0, 1, 2, 3, 4, 5, 6, 7]]
|
['21 - 06', 21, 22, 23, 0, 1, 2, 3, 4, 5],
|
||||||
|
['22 - 07', 22, 23, 0, 1, 2, 3, 4, 5, 6],
|
||||||
|
['23 - 08', 23, 0, 1, 2, 3, 4, 5, 6, 7]]
|
||||||
|
if shift == "8AM_5PM":
|
||||||
|
hour_shifts = [
|
||||||
|
['07 - 16', 7, 8, 9, 10, 11, 12, 13, 14, 15],
|
||||||
|
['08 - 17', 8, 9, 10, 11, 12, 13, 14, 15, 16]]
|
||||||
|
|
||||||
# all possible days riders come in
|
# all possible days riders come in
|
||||||
day_shifts = [
|
day_shifts = [
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue