Merge branch '531-add-24-7-and-current-configuration-for-rider-scheduling' into 'master'
Resolve "Add 24/7 and current configuration for rider scheduling" Closes #531 See merge request jankstudio/resq!616
This commit is contained in:
commit
3e75ddb618
4 changed files with 127 additions and 37 deletions
|
|
@ -22,6 +22,8 @@ use DateInterval;
|
|||
use App\Entity\JobOrder;
|
||||
use App\Entity\Hub;
|
||||
|
||||
use App\Ramcar\ShiftSchedule;
|
||||
|
||||
class AnalyticsController extends Controller
|
||||
{
|
||||
protected $weekdays = [
|
||||
|
|
@ -44,7 +46,7 @@ class AnalyticsController extends Controller
|
|||
['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],
|
||||
['01:00 - 10:00', 1, 2, 3, 4, 5, 6, 7, 8, 9],
|
||||
|
|
@ -54,8 +56,8 @@ class AnalyticsController extends Controller
|
|||
['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],
|
||||
*/
|
||||
['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],
|
||||
//['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],
|
||||
/*
|
||||
['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],
|
||||
|
|
@ -73,7 +75,7 @@ class AnalyticsController extends Controller
|
|||
['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],
|
||||
*/
|
||||
];
|
||||
//];
|
||||
|
||||
/**
|
||||
* @Menu(selected="analytics_forecast")
|
||||
|
|
@ -94,6 +96,7 @@ class AnalyticsController extends Controller
|
|||
$params = [
|
||||
'hub_list' => $hub_list,
|
||||
'default_hubs' => $hub_ids,
|
||||
'shift_schedules' => ShiftSchedule::getCollection(),
|
||||
];
|
||||
|
||||
return $this->render('analytics/forecast_form.html.twig', $params);
|
||||
|
|
@ -117,6 +120,12 @@ class AnalyticsController extends Controller
|
|||
$date_from = DateTime::createFromFormat('d M Y', $req->request->get('date_from'));
|
||||
$date_to = DateTime::createFromFormat('d M Y', $req->request->get('date_to'));
|
||||
|
||||
$shift = $req->request->get('shift_schedule');
|
||||
|
||||
// TODO: populate the hour_shift array, depending on the shift selected
|
||||
$hour_shifts = $this->populateHourShift($shift);
|
||||
|
||||
error_log(print_r($hour_shifts, true));
|
||||
// error_log(print_r($hub_list, true));
|
||||
|
||||
// $hub_list = [ 6, 4, 36, 7, 8, 126, 127, 18, 12, 9, 60, 10, 21, 135 ];
|
||||
|
|
@ -168,7 +177,7 @@ class AnalyticsController extends Controller
|
|||
// error_log(print_r($scheduler_data, true));
|
||||
|
||||
// run scheduler
|
||||
$sched_res = $this->runScheduler($scheduler_data);
|
||||
$sched_res = $this->runScheduler($scheduler_data, $hour_shifts, $shift);
|
||||
|
||||
// tally total JOs for the month
|
||||
foreach ($scheduler_data as $sday_data)
|
||||
|
|
@ -243,7 +252,7 @@ class AnalyticsController extends Controller
|
|||
return $day_data;
|
||||
}
|
||||
|
||||
protected function runScheduler($scheduler_data)
|
||||
protected function runScheduler($scheduler_data, $hour_shifts, $shift)
|
||||
{
|
||||
// run python script to solve scheduling for riders
|
||||
|
||||
|
|
@ -258,13 +267,18 @@ class AnalyticsController extends Controller
|
|||
foreach ($scheduler_data as $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);
|
||||
|
||||
$proc = new Process($args);
|
||||
$proc->run();
|
||||
|
||||
//error_log('getErrorOutput() ' . $proc->getErrorOutput());
|
||||
|
||||
if (!$proc->isSuccessful())
|
||||
error_log('SCHEDULER DID NOT RUN PROPERLY');
|
||||
|
||||
|
|
@ -303,7 +317,7 @@ class AnalyticsController extends Controller
|
|||
|
||||
$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[] = [
|
||||
'label' => $label,
|
||||
|
|
@ -314,8 +328,8 @@ class AnalyticsController extends Controller
|
|||
$rider_hours = [];
|
||||
for ($i = 0; $i < 24; $i++)
|
||||
$rider_hours[$i] = 0;
|
||||
for ($i = 1; $i < count($this->hour_shifts[$hour_shift_index]); $i++)
|
||||
$rider_hours[$this->hour_shifts[$hour_shift_index][$i]] = 1;
|
||||
for ($i = 1; $i < count($hour_shifts[$hour_shift_index]); $i++)
|
||||
$rider_hours[$hour_shifts[$hour_shift_index][$i]] = 1;
|
||||
|
||||
// error_log('allocating ' . $rider_count . ' for ' . $label);
|
||||
|
||||
|
|
@ -661,4 +675,46 @@ class AnalyticsController extends Controller
|
|||
protected function solveRiderSchedule()
|
||||
{
|
||||
}
|
||||
|
||||
protected function populateHourShift($shift)
|
||||
{
|
||||
$hour_shift = [];
|
||||
|
||||
if ($shift == '24_7') {
|
||||
$hour_shift = [
|
||||
['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],
|
||||
['02:00 - 11:00', 2, 3, 4, 5, 6, 7, 8, 9, 10],
|
||||
['03:00 - 12:00', 3, 4, 5, 6, 7, 8, 9, 10, 11],
|
||||
['04:00 - 13:00', 4, 5, 6, 7, 8, 9, 10, 11, 12],
|
||||
['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],
|
||||
['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],
|
||||
['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],
|
||||
['11:00 - 20:00', 11, 12, 13, 14, 15, 16, 17, 18, 19],
|
||||
['12:00 - 21:00', 12, 13, 14, 15, 16, 17, 18, 19, 20],
|
||||
['13:00 - 22:00', 13, 14, 15, 16, 17, 18, 19, 20, 21],
|
||||
['14:00 - 23:00', 14, 15, 16, 17, 18, 19, 20, 21, 22],
|
||||
['15:00 - 00:00', 15, 16, 17, 18, 19, 20, 21, 22, 23],
|
||||
['16:00 - 01:00', 16, 17, 18, 19, 20, 21, 22, 23, 0],
|
||||
['17:00 - 02:00', 17, 18, 19, 20, 21, 22, 23, 0, 1],
|
||||
['18:00 - 03:00', 18, 19, 20, 21, 22, 23, 0, 1, 2],
|
||||
['19:00 - 04:00', 19, 20, 21, 22, 23, 0, 1, 2, 3],
|
||||
['20:00 - 05:00', 20, 21, 22, 23, 0, 1, 2, 3, 4],
|
||||
['21:00 - 06:00', 21, 22, 23, 0, 1, 2, 3, 4, 5],
|
||||
['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],
|
||||
];
|
||||
}
|
||||
if ($shift == '8AM_5PM') {
|
||||
$hour_shift = [
|
||||
['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],
|
||||
];
|
||||
}
|
||||
|
||||
return $hour_shift;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
14
src/Ramcar/ShiftSchedule.php
Normal file
14
src/Ramcar/ShiftSchedule.php
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
|
||||
namespace App\Ramcar;
|
||||
|
||||
class ShiftSchedule extends NameValue
|
||||
{
|
||||
const SCHED_24_7 = '24_7';
|
||||
const SCHED_8_5 = '8AM_5PM';
|
||||
|
||||
const COLLECTION = [
|
||||
'24_7' => '24/7 Schedule',
|
||||
'8AM_5PM' => '8AM-5PM Schedule',
|
||||
];
|
||||
}
|
||||
|
|
@ -30,6 +30,17 @@
|
|||
<form id="row-form" class="m-form m-form--fit m-form--label-align-right m-form--group-seperator-dashed" method="post" action="{{ url('analytics_forecast_submit') }}">
|
||||
|
||||
<div class="m-portlet__body">
|
||||
<div class="form-group m-form__group row no-border">
|
||||
<div class="col-lg-6">
|
||||
<label data-field="shift_schedule">Shift Schedule</label>
|
||||
<select id="shift_schedule" class="form-control m-input" name="shift_schedule">
|
||||
{% for key, schedule in shift_schedules %}
|
||||
<option value="{{ key }}">{{ schedule }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
<div class="form-control-feedback hide" data-field="shift_schedule"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group m-form__group row no-border">
|
||||
<div class="col-lg-6">
|
||||
<label data-field="time_from">Restrict Time From</label>
|
||||
|
|
|
|||
|
|
@ -38,39 +38,48 @@ def main():
|
|||
req_hours = [[0 for x in range(len(hours))] for y in range(len(days))]
|
||||
|
||||
# get arguments
|
||||
# there will be 7 arguments, monday to sunday schedule
|
||||
# there will be 8 arguments, monday to sunday schedule and the shift selected
|
||||
# sample argument:
|
||||
# 0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0 0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0 0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0 0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0 0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0 0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0 0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0 24_7
|
||||
for day_index in range(0, len(days)):
|
||||
hours_string = sys.argv[day_index + 1]
|
||||
hours_data = hours_string.split('-')
|
||||
for hour_index in range(0, len(hours)):
|
||||
req_hours[day_index][hour_index] = int(hours_data[hour_index])
|
||||
|
||||
# all hour shifts available
|
||||
hour_shifts = [
|
||||
#['00 - 09', 0, 1, 2, 3, 4, 5, 6, 7, 8],
|
||||
#['01 - 10', 1, 2, 3, 4, 5, 6, 7, 8, 9],
|
||||
#['02 - 11', 2, 3, 4, 5, 6, 7, 8, 9, 10],
|
||||
#['03 - 12', 3, 4, 5, 6, 7, 8, 9, 10, 11],
|
||||
#['04 - 13', 4, 5, 6, 7, 8, 9, 10, 11, 12],
|
||||
#['05 - 14', 5, 6, 7, 8, 9, 10, 11, 12, 13],
|
||||
#['06 - 15', 6, 7, 8, 9, 10, 11, 12, 13, 14],
|
||||
['07 - 16', 7, 8, 9, 10, 11, 12, 13, 14, 15],
|
||||
['08 - 17', 8, 9, 10, 11, 12, 13, 14, 15, 16]]
|
||||
#['09 - 18', 9, 10, 11, 12, 13, 14, 15, 16, 17],
|
||||
#['10 - 19', 10, 11, 12, 13, 14, 15, 16, 17, 18],
|
||||
#['11 - 20', 11, 12, 13, 14, 15, 16, 17, 18, 19],
|
||||
#['12 - 21', 12, 13, 14, 15, 16, 17, 18, 19, 20],
|
||||
#['13 - 22', 13, 14, 15, 16, 17, 18, 19, 20, 21],
|
||||
#['14 - 23', 14, 15, 16, 17, 18, 19, 20, 21, 22],
|
||||
#['15 - 00', 15, 16, 17, 18, 19, 20, 21, 22, 23],
|
||||
#['16 - 01', 16, 17, 18, 19, 20, 21, 22, 23, 0],
|
||||
#['17 - 02', 17, 18, 19, 20, 21, 22, 23, 0, 1],
|
||||
#['18 - 03', 18, 19, 20, 21, 22, 23, 0, 1, 2],
|
||||
#['19 - 04', 19, 20, 21, 22, 23, 0, 1, 2, 3],
|
||||
#['20 - 05', 20, 21, 22, 23, 0, 1, 2, 3, 4],
|
||||
#['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]]
|
||||
# index of shift selected is 8
|
||||
shift = sys.argv[8]
|
||||
hour_shifts = []
|
||||
if shift == "24_7":
|
||||
hour_shifts = [
|
||||
['00 - 09', 0, 1, 2, 3, 4, 5, 6, 7, 8],
|
||||
['01 - 10', 1, 2, 3, 4, 5, 6, 7, 8, 9],
|
||||
['02 - 11', 2, 3, 4, 5, 6, 7, 8, 9, 10],
|
||||
['03 - 12', 3, 4, 5, 6, 7, 8, 9, 10, 11],
|
||||
['04 - 13', 4, 5, 6, 7, 8, 9, 10, 11, 12],
|
||||
['05 - 14', 5, 6, 7, 8, 9, 10, 11, 12, 13],
|
||||
['06 - 15', 6, 7, 8, 9, 10, 11, 12, 13, 14],
|
||||
['07 - 16', 7, 8, 9, 10, 11, 12, 13, 14, 15],
|
||||
['08 - 17', 8, 9, 10, 11, 12, 13, 14, 15, 16],
|
||||
['09 - 18', 9, 10, 11, 12, 13, 14, 15, 16, 17],
|
||||
['10 - 19', 10, 11, 12, 13, 14, 15, 16, 17, 18],
|
||||
['11 - 20', 11, 12, 13, 14, 15, 16, 17, 18, 19],
|
||||
['12 - 21', 12, 13, 14, 15, 16, 17, 18, 19, 20],
|
||||
['13 - 22', 13, 14, 15, 16, 17, 18, 19, 20, 21],
|
||||
['14 - 23', 14, 15, 16, 17, 18, 19, 20, 21, 22],
|
||||
['15 - 00', 15, 16, 17, 18, 19, 20, 21, 22, 23],
|
||||
['16 - 01', 16, 17, 18, 19, 20, 21, 22, 23, 0],
|
||||
['17 - 02', 17, 18, 19, 20, 21, 22, 23, 0, 1],
|
||||
['18 - 03', 18, 19, 20, 21, 22, 23, 0, 1, 2],
|
||||
['19 - 04', 19, 20, 21, 22, 23, 0, 1, 2, 3],
|
||||
['20 - 05', 20, 21, 22, 23, 0, 1, 2, 3, 4],
|
||||
['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
|
||||
day_shifts = [
|
||||
|
|
|
|||
Loading…
Reference in a new issue