|
- <?php
- /**
- * Created by PhpStorm.
- * User: Miracle
- * Date: 2016/9/5
- * Time: 10:51
- * 调度算法
- */
- require_once __DIR__ . '/common.php';
-
- class dispatch_algorithm extends virtifyUsers
- {
-
- private $nj_nt_prod_id = "449860";
- private $nt_nj_prod_id = "449865";
-
- /**
- * //全排列方法
- * @param string $first
- * @param $arr
- * @param array $results
- * Array ( [0] => 1-2-3 [1] => 1-3-2 [2] => 2-1-3 [3] => 2-3-1 [4] => 3-1-2 [5] => 3-2-1 ) 结果格式
- */
- function Permutate($first = '', $arr, &$results = array())
- {
- $len = count($arr);
- if ($len == 1) {
- $results[] = $first . '-' . $arr[0];
- } else {
- for ($i = 0; $i < $len; $i++) {
- $tmp = $arr[0];
- $arr[0] = $arr[$i];
- $arr[$i] = $tmp;
- if ($first != '') {
- $this->Permutate($first . '-' . $arr[0], array_slice($arr, 1), $results);
- } else {
- $this->Permutate($first . $arr[0], array_slice($arr, 1), $results);
- }
- }
- }
- }
-
- /**
- * //调度方法
- * @param $order_list
- * @param $new_order
- * @param $array_start
- * @param $array_end
- * @return string|void
- */
- function dispatch($prodID, $order_list, $new_order, $array_start, $array_end, $run_date, $should_be_count,$bool_total_time)
- {
- $is_xiecheng = false;//判断是否是携程的订单
- $order_num = count($order_list) + 1;//将会有多少订单上车
- $order_list[$order_num - 1]["order_id"] = $new_order["order_id"];
- $order_list[$order_num - 1]["num"] = $new_order["num"];
- $order_list[$order_num - 1]["startx_y"] = $new_order["startx_y"];
- $order_list[$order_num - 1]["endx_y"] = $new_order["endx_y"];
- for ($temp_xiecheng_i = 0; $temp_xiecheng_i < $order_num; $temp_xiecheng_i++) {
- if (($order_list[$temp_xiecheng_i]["startx_y"] == "32.116682,118.784105" && $order_list[$temp_xiecheng_i]["endx_y"] == "32.011714,120.894448") || ($order_list[$temp_xiecheng_i]["startx_y"] == "32.011714,120.894448" && $order_list[$temp_xiecheng_i]["endx_y"] == "32.116682,118.784105")) {
- $is_xiecheng = true;//是携程的订单
- }
- }
- $arr = range(1, $order_num);//1-3的全排列
- //默认相同地点或很近地点时间为0
- for ($start_i = 1; $start_i <= $order_num; $start_i++) {
- for ($start_ii = 1; $start_ii <= $order_num; $start_ii++) {
- if ($array_start[$start_i][$start_ii] <= 2) {
- $array_start[$start_i][$start_ii] = 0;//默认相同地点或很近地点时间为0
- }
- }
- }
- for ($end_i = 1; $end_i <= $order_num; $end_i++) {
- for ($end_ii = 1; $end_ii <= $order_num; $end_ii++) {
- if ($array_end[$end_i][$end_ii] <= 2) {
- $array_end[$end_i][$end_ii] = 0;//默认相同地点或很近地点时间为0
- }
- }
- }
- $Permutate_results = array();
- $this->Permutate($first = '', $arr, $Permutate_results);
- $totol = count($Permutate_results);
- $Permutate_array = array();
- for ($ii = 0; $ii < $totol; $ii++) {
- $Permutate_array[$ii] = explode('-', $Permutate_results[$ii]);//切分字符串变成数组
- }
- $min_start_cost_time = 9999;//起始地最小耗时
- $min_start_arr_num = 0;//记录起始最小耗时的排列位置
- for ($i = 0; $i < $totol; $i++) {
- //遍历每一种全排列计算冗余时间
- $totol_start_cost = 0;//每种组合实际消耗时间
- for ($j = 0; $j < $order_num - 1; $j++) {
- //计算每一个点
- $totol_start_cost = $totol_start_cost + $array_start[$Permutate_array[$i][$j]][$Permutate_array[$i][$j + 1]];
- }
- if ($totol_start_cost < $min_start_cost_time) {
- $min_start_arr_num = $i;//记录接人最小耗时组合
- $min_start_cost_time = $totol_start_cost;//记录接人最小耗时时间值
- }
- }
- $arr_start_rev = array();
- $temp_j = $order_num - 1;
- $arr_start_rev_cost = 0;//翻转接人耗时
- for ($temp_i = 0; $temp_i < $order_num; $temp_i++) {
- $arr_start_rev[$temp_i] = $Permutate_array[$min_start_arr_num][$temp_j];
- $temp_j--;//翻转接人数组
- }
- for ($j = 0; $j < $order_num - 1; $j++) {
- $arr_start_rev_cost = $arr_start_rev_cost + $array_start[$arr_start_rev[$j]][$arr_start_rev[$j + 1]];
- }
- $min_end_cost_time = 9999;//起始地最小耗时
- $min_end_arr_num = 0;//记录起始最小耗时的排列位置
- for ($i = 0; $i < $totol; $i++) {
- //遍历每一种全排列计算冗余时间
- $totol_end_cost = 0;//每种组合实际消耗时间
- for ($j = 0; $j < $order_num - 1; $j++) {
- //计算每一个点
- $totol_end_cost = $array_end[$Permutate_array[$i][$j]][$Permutate_array[$i][$j + 1]] + $totol_end_cost;
- }
- if ($totol_end_cost < $min_end_cost_time) {
- $min_end_arr_num = $i;//记录送人最小耗时组合
- $min_end_cost_time = $totol_end_cost;//记录送人最小耗时时间值
- }
- }
- $arr_end_rev = array();
- $temp_j = $order_num - 1;
- $arr_end_rev_cost = 0;//翻转送人耗时
- for ($temp_i = 0; $temp_i < $order_num; $temp_i++) {
- $arr_end_rev[$temp_i] = $Permutate_array[$min_end_arr_num][$temp_j];
- $temp_j--;//翻转送人数组
- }
- for ($j = 0; $j < $order_num - 1; $j++) {
- $arr_end_rev_cost = $arr_end_rev_cost + $array_end[$arr_end_rev[$j]][$arr_end_rev[$j + 1]];
- }
- $start = array(
- "$min_start_cost_time" . '-' . $order_list[$Permutate_array[$min_start_arr_num][$order_num - 1] - 1]["startx_y"] => $Permutate_array[$min_start_arr_num],
- "$arr_start_rev_cost" . '-' . $order_list[$Permutate_array[$min_start_arr_num][0] - 1]["startx_y"] => $arr_start_rev
- );
- $end = array(
- "$min_end_cost_time" . '-' . $order_list[$Permutate_array[$min_end_arr_num][0] - 1]["startx_y"] => $Permutate_array[$min_end_arr_num],
- "$arr_end_rev_cost" . '-' . $order_list[$Permutate_array[$min_end_arr_num][$order_num - 1] - 1]["startx_y"] => $arr_end_rev
- );
- #region 求出四种组合方式中用时最短的线路
- $min_time_list = array();
- foreach ($start as $k => $v) {
- foreach ($end as $key => $value) {
- $begin_lat_lon = explode('-', $k);
- $end_lat_lon = explode('-', $key);
- $time = commonUtils::baiduShortTime($begin_lat_lon[1], $end_lat_lon[1]);
- $current_route = $v;
- $total_route = array_merge($current_route, $value);
- $total_time = array("min_time" => $begin_lat_lon[0] + ceil($time / 60) + $end_lat_lon[0], "route" => $total_route, "middle_time" => ceil($time / 60));
- array_push($min_time_list, $total_time);
- }
- }
- $max_time = 999999;
- $min_route_arr = array();
- $middleTime = 0;
- $min_time_list_count = count($min_time_list);
- for ($i = 0; $i < $min_time_list_count; $i++) {
- if ($min_time_list[$i]["min_time"] < $max_time) {
- $max_time = $min_time_list[$i]["min_time"];
- $middleTime = $min_time_list[$i]["middle_time"]; //接人的最后一个点到送人的第一个点的最短时间
- $min_route_arr = $min_time_list[$i]["route"];
- }
- }
-
- $road1 = array("location" => "32.135283,120.230875", "nt" => "77", "nj" => "129");//高速路1 广陵枢纽与沪陕高速公路交叉口(地址:江苏省泰州市泰兴市)to:高速路标记点到南通的最短时间 go:高速路标记点到南京的最短时间
- $road2 = array("location" => "31.749506,120.140182", "nt" => "89", "nj" => "116");//高速路2 江苏省常州市武进区横林枢纽立交桥
- if ($is_xiecheng) {
- //携程的订单
- $temp_time_on_the_way = strtotime($run_date);
- $time_on_the_way = date("Y-m-d H:i", $temp_time_on_the_way); //到携程的时间
- } else {
- //不是携程的订单
- $temp_time_on_the_way = strtotime($run_date) + 210 * 60;
- $time_on_the_way = date("Y-m-d H:i", $temp_time_on_the_way); //到南通的时间
- }
-
- #endregion
- //调用处理冗余时间逻辑方法
- $res = $this->redundantTime($order_list, $middleTime, $min_route_arr, $array_start, $array_end, $road1, $road2, $prodID, $time_on_the_way, $is_xiecheng,$should_be_count,$bool_total_time);
- if ($res) {
- return $res;
- } else {
- return false;
- }
-
- }
-
- /**
- * 处理冗余时间逻辑
- * @param $order_list
- * @param $middleTime
- * @param $min_route_arr
- * @param $start_arr
- * @param $end_arr
- * @return array|bool
- */
- function redundantTime($order_list, $middleTime, $min_route_arr, $start_arr, $end_arr, $road1, $road2, $prodID, $time_on_the_way, $is_xiecheng, $should_be_count,$bool_total_time)
- {
- writeLog("heyikai_startarr:" . json_encode($start_arr));
- writeLog("heyikai_endarr:" . json_encode($end_arr));
- $boolean_total_time=$bool_total_time;
- $new_order_is_xiecheng = false;//新订单是否是携程 1是0否
- $xiecheng_order = $is_xiecheng;//是否是携程的订单 1是0否
- $redundantTime_count = $should_be_count;
- $go_where = $prodID;//去哪儿
- $point_a = $road1;//关键点a
- $point_b = $road2;//关键点b
- $run_time = ceil(strtotime($time_on_the_way) / 60);//到达关键点时间
- $go_time_arr = array();//接客时间数组
- $send_time_arr = array();//送客时间数组
- $every_one_go_cost_tiem_arr = array();//每位乘客的接客耗时
- $every_one_send_cost_tiem_arr = array();//每位乘客的接客耗时
- $can_seat_in = true;
- $info = "";
- $min_route_num = count($min_route_arr);
- $order_count = count($order_list);//订单号
- $total_cost_time = 0;
- if (($order_list[$order_count - 1]["startx_y"] == "32.116682,118.784105" && $order_list[$order_count - 1]["endx_y"] == "32.011714,120.894448") || ($order_list[$order_count - 1]["startx_y"] == "32.011714,120.894448" && $order_list[$order_count - 1]["endx_y"] == "32.116682,118.784105")) {
- $new_order_is_xiecheng = true;//如果最后一个订单是携程,变为真
- }
- writeLog("贺奕凯_新订单是否是携程:" . json_encode($new_order_is_xiecheng));
- for ($i = 0; $i < $min_route_num - 1; $i++) {
- //遍历路线数组
- if ($i < $order_count - 1) {
- $total_cost_time = $total_cost_time + $start_arr[$min_route_arr[$i]][$min_route_arr[$i + 1]];
- } elseif ($i == $order_count) {
- $total_cost_time = $total_cost_time + $middleTime + $end_arr[$min_route_arr[$i]][$min_route_arr[$i + 1]];
- }
- if ($i > $order_count) {
- $total_cost_time = $total_cost_time + $end_arr[$min_route_arr[$i]][$min_route_arr[$i + 1]];
- }
- }
- if ($total_cost_time > 360) {
- if ($xiecheng_order) {
- $can_seat_in = true;
- $info = "总时间超过360分钟,携程订单为真";
- } else {
- if($bool_total_time){
- //要算冗余和总时长
- $can_seat_in = false;
- $info = "总时间超过360分钟";
- }else{
- $can_seat_in =true;
- $info = "总时间超过360分钟,但是不考虑";
- }
-
- }
- }
- for ($jj = 0; $jj < $order_count; $jj++) {
- $ry_cost_time = 0;
- for ($j = $jj; $j < $min_route_num - 1; $j++) {
- if ($j < $order_count - 1) {
- $ry_cost_time = $ry_cost_time + $start_arr[$min_route_arr[$j]][$min_route_arr[$j + 1]];
- } elseif (($j + 1) == $order_count) {
- $ry_cost_time = $ry_cost_time + $middleTime;
- }
- if ($j >= $order_count) {
- $ry_cost_time = $ry_cost_time + $end_arr[$min_route_arr[$j]][$min_route_arr[$j + 1]];
- }
- if ($min_route_arr[$jj] == $min_route_arr[$j + 1]) {
- if ($ry_cost_time > 60) {
- if (($order_list[$jj]["startx_y"] == "32.116682,118.784105" && $order_list[$jj]["endx_y"] == "32.011714,120.894448") || ($order_list[$jj]["startx_y"] == "32.011714,120.894448" && $order_list[$jj]["endx_y"] == "32.116682,118.784105")) {
- //这点是携程点
- $can_seat_in = true;
- // $info = "冗余时间超过30分钟";
- // /*break;保证数据完整*/
- } else {
- //不是携程点
- if ($new_order_is_xiecheng) {
- //新订单是携程的
- $can_seat_in = true;
- } else {
- //新订单不是携程的
- $can_seat_in = false;
- }
- // $info = "冗余时间超过30分钟";
- // /*break;保证数据完整*/
- }
- }
- }
- }
- }
- if (!$redundantTime_count) {
- //特殊情况1,退票 不算冗余和时长
- $can_seat_in = true;
- }
- if(!$bool_total_time){
- //特殊情况2,cs系统 不算冗余和时长
- $can_seat_in = true;
- }
- if ($can_seat_in) {
- $can_seat_in_orderid_list = array();
- for ($i = 0; $i < $min_route_num; $i++) {
- $can_seat_in_orderid_list[$i] = $order_list[$min_route_arr[$i] - 1]["order_id"];
- }
- //$min_route_arr;行车路线
- ////$every_one_go_cost_tiem_arr=array();//每位乘客的接客耗时
- //$every_one_send_cost_tiem_arr=array();//每位乘客的接客耗时
- for ($i = 0; $i < $order_count; $i++) {
- //计算每个订单接人的耗时
- $every_one_go_cost_tiem_arr[$i] = 0;
- for ($ii = $i; $ii < $order_count; $ii++) {
- if ($ii == ($order_count - 1)) {
- $every_one_go_cost_tiem_arr[$i] = $every_one_go_cost_tiem_arr[$i] + 0;
- } else {
- $every_one_go_cost_tiem_arr[$i] = $every_one_go_cost_tiem_arr[$i] + $start_arr[$min_route_arr[$ii]][$min_route_arr[$ii + 1]];
- }
- }
- }
- for ($i = $min_route_num - 1; $i > ($order_count - 1); $i--) {
- $every_one_send_cost_tiem_arr[$i - $order_count] = 0;
- for ($ii = $i; $ii > ($order_count - 1); $ii--) {
- if ($ii == $order_count) {
- $every_one_send_cost_tiem_arr[$i - $order_count] = $every_one_send_cost_tiem_arr[$i - $order_count] + 0;
- } else {
- $every_one_send_cost_tiem_arr[$i - $order_count] = $every_one_send_cost_tiem_arr[$i - $order_count] + $end_arr[$min_route_arr[$ii - 1]][$min_route_arr[$ii]];
- }
- }
- }
- $last_go = $min_route_arr[$order_count - 1];//最后一个接
- $frist_send = $min_route_arr[$order_count];//第一个送
- $last_go_where = $order_list[$last_go - 1]["startx_y"];
- $frist_send_where = $order_list[$frist_send - 1]["endx_y"];
- $time1 = commonUtils::baiduShortTime($last_go_where, $point_a["location"]) + commonUtils::baiduShortTime($point_a["location"], $frist_send_where);
- $time2 = commonUtils::baiduShortTime($last_go_where, $point_b["location"]) + commonUtils::baiduShortTime($point_b["location"], $frist_send_where);
- // $every_one_go_cost_tiem_arr=array();//每位乘客的接客耗时
- ////$every_one_send_cost_tiem_arr=array();//每位乘客的接客耗时
- if ($xiecheng_order) {
- //携程订单
- $time_xiecheng = ceil(strtotime($time_on_the_way) / 60);//到携程的时间分钟
- //$every_one_go_cost_tiem_arr 接人耗时数组
- //$every_one_send_cost_tiem_arr 送人耗时数组
- //$min_route_arr 行车队列 1423 1324
- //$min_route_num 最短路径数组长度
- writeLog("heyikai_到携程时间:" . json_encode($time_xiecheng));
- writeLog("heyikai_接人耗时:" . json_encode($every_one_go_cost_tiem_arr));
- writeLog("heyikai_送人耗时:" . json_encode($every_one_send_cost_tiem_arr));
- $xiecheng_time_array = array();//携程时间数组
- $xiecheng_number = 0;//记录第一个携程订单位置
- // for ($temp_ii = 0; $temp_ii < $order_count; $temp_ii++) {
- // if (($order_list[$temp_ii]["startx_y"] == "32.116682,118.784105" && $order_list[$temp_ii]["endx_y"] == "32.011714,120.894448") || ($order_list[$temp_ii]["startx_y"] == "32.011714,120.894448" && $order_list[$temp_ii]["endx_y"] == "32.116682,118.784105")) {
- // $xiecheng_number = $temp_ii;//找到第一个携程订单
- // writeLog("heyikai_第一个携程订单位置:".json_encode($xiecheng_number));
- // break;
- // }
- // }
- for ($temp_ii = 0; $temp_ii < $order_count; $temp_ii++) {
- if (($order_list[$min_route_arr[$temp_ii] - 1]["startx_y"] == "32.116682,118.784105" && $order_list[$min_route_arr[$temp_ii] - 1]["endx_y"] == "32.011714,120.894448") || ($order_list[$min_route_arr[$temp_ii] - 1]["startx_y"] == "32.011714,120.894448" && $order_list[$min_route_arr[$temp_ii] - 1]["endx_y"] == "32.116682,118.784105")) {
- $xiecheng_number = $temp_ii;//找到第一个携程订单
- writeLog("heyikai_第一个携程订单位置:" . json_encode($xiecheng_number));
- break;
- }
- }
- $xiecheng_time_array[$xiecheng_number] = $time_xiecheng;//固定到携程时间
- writeLog("heyikai_已经固定到携程订单时间:" . json_encode($xiecheng_time_array[$xiecheng_number]));
- for ($temp_f = ($xiecheng_number - 1); $temp_f >= 0; $temp_f--) {
- //计算携程前一点和以前的时间
- $xiecheng_time_array[$temp_f] = $xiecheng_time_array[($temp_f + 1)] - $start_arr[$min_route_arr[$temp_f]][$min_route_arr[($temp_f + 1)]];
- }
- for ($temp_e = ($xiecheng_number + 1); $temp_e < $min_route_num; $temp_e++) {
- //计算携程后一点和以后的时间
- $xiecheng_time_array[$temp_e] = $xiecheng_time_array[($temp_e - 1)] + $start_arr[$min_route_arr[$temp_e - 1]][$min_route_arr[($temp_e)]];
- }
- //计算中间时间
- $during_time = commonUtils::baiduShortTime($order_list[$min_route_arr[$order_count - 1] - 1]["startx_y"], $order_list[$min_route_arr[$order_count] - 1]["endx_y"]);
- //确定第一个终点的时间
- writeLog("heyikai_中间时间:" . json_encode($during_time));
- writeLog("heyikai_中间起点:" . json_encode($order_list[$min_route_arr[$order_count - 1] - 1]["startx_y"]));
- writeLog("heyikai_中间终点:" . json_encode($order_list[$min_route_arr[$order_count] - 1]["endx_y"]));
- $xiecheng_time_array[$order_count] = $xiecheng_time_array[$order_count - 1] + $during_time;
- for ($temp_temp_end = ($order_count + 1); $temp_temp_end < $min_route_num; $temp_temp_end++) {
- //计算第一个点以后的时间
- $xiecheng_time_array[$temp_temp_end] = $xiecheng_time_array[($temp_temp_end - 1)] + $end_arr[$min_route_arr[($temp_temp_end - 1)]][$min_route_arr[$temp_temp_end]];
- }
- $final_xiecheng = array();//携程最终返回
- for ($temp_xiecheng_i = 0; $temp_xiecheng_i < $min_route_num; $temp_xiecheng_i++) {
- $final_xiecheng[$temp_xiecheng_i]["time"] = date("Y-m-d H:i", $xiecheng_time_array[$temp_xiecheng_i] * 60);
- $final_xiecheng[$temp_xiecheng_i]["order_id"] = $order_list[$min_route_arr[$temp_xiecheng_i] - 1]["order_id"];
- }
- writeLog("heyikai:" . json_encode($final_xiecheng));
- return $final_xiecheng;
- } else {
- //不是携程订单
- if ($go_where == $this->nj_nt_prod_id) {
- //南京去南通方向
- if ($time1 > $time2) {
- //选point_b
- $temp_time = $run_time - $point_b["nt"];
- $temp_time_go = $temp_time - commonUtils::baiduShortTime($last_go_where, $point_b["location"]);
- for ($i = 0; $i < $order_count; $i++) {
- $every_one_go_cost_tiem_arr[$i] = $temp_time_go - $every_one_go_cost_tiem_arr[$i];
- }
- $temp_time_send = $temp_time + commonUtils::baiduShortTime($point_b["location"], $frist_send_where);
- for ($i = 0; $i < $order_count; $i++) {
- $every_one_send_cost_tiem_arr[$i] = $temp_time_send + $every_one_send_cost_tiem_arr[$i];
- }
- } else {
- //选point_a
- $temp_time = $run_time - $point_a["nt"];
- $temp_time_go = $temp_time - commonUtils::baiduShortTime($last_go_where, $point_a["location"]);
- for ($i = 0; $i < $order_count; $i++) {
- $every_one_go_cost_tiem_arr[$i] = $temp_time_go - $every_one_go_cost_tiem_arr[$i];
- }
- $temp_time_send = $temp_time + commonUtils::baiduShortTime($point_a["location"], $frist_send_where);
- for ($i = 0; $i < $order_count; $i++) {
- $every_one_send_cost_tiem_arr[$i] = $temp_time_send + $every_one_send_cost_tiem_arr[$i];
- }
- }
- } elseif ($go_where == $this->nt_nj_prod_id) {
- //南通去南京方向
- if ($time1 > $time2) {
- //选point_b
- $temp_time = $run_time - $point_b["nj"];
- $temp_time_go = $temp_time - commonUtils::baiduShortTime($last_go_where, $point_b["location"]);
- for ($i = 0; $i < $order_count; $i++) {
- $every_one_go_cost_tiem_arr[$i] = $temp_time_go - $every_one_go_cost_tiem_arr[$i];
- }
- $temp_time_send = $temp_time + commonUtils::baiduShortTime($point_b["location"], $frist_send_where);
- for ($i = 0; $i < $order_count; $i++) {
- $every_one_send_cost_tiem_arr[$i] = $temp_time_send + $every_one_send_cost_tiem_arr[$i];
- }
- } else {
- //选point_a
- $temp_time = $run_time - $point_a["nj"];
- $temp_time_go = $temp_time - commonUtils::baiduShortTime($last_go_where, $point_a["location"]);
- for ($i = 0; $i < $order_count; $i++) {
- $every_one_go_cost_tiem_arr[$i] = $temp_time_go - $every_one_go_cost_tiem_arr[$i];
- }
- $temp_time_send = $temp_time + commonUtils::baiduShortTime($point_a["location"], $frist_send_where);
- for ($i = 0; $i < $order_count; $i++) {
- $every_one_send_cost_tiem_arr[$i] = $temp_time_send + $every_one_send_cost_tiem_arr[$i];
- }
- }
- } else {
- return false;
- }
- for ($i = 0; $i < $order_count; $i++) {
- $every_one_go_cost_tiem_arr[$i] = date("Y-m-d H:i", $every_one_go_cost_tiem_arr[$i] * 60);
- }
- for ($i = 0; $i < $order_count; $i++) {
- $every_one_send_cost_tiem_arr[$i] = date("Y-m-d H:i", $every_one_send_cost_tiem_arr[$i] * 60);
- }
- $final_result = array();
- for ($i = 0; $i < $min_route_num; $i++) {
- if ($i < $order_count) {
- //接人
- $final_result[$i]["order_id"] = $can_seat_in_orderid_list[$i];
- $final_result[$i]["time"] = $every_one_go_cost_tiem_arr[$i];
- } else {
- //送人
- $final_result[$i]["order_id"] = $can_seat_in_orderid_list[$i];
- $final_result[$i]["time"] = $every_one_send_cost_tiem_arr[$i - $order_count];
- }
-
- }
- return $final_result;
- }
- } else {
- return false;
- }
- }
- }
-
- /*
- * 勿删
- * $road1 = array("location" => "32.135283,120.230875,", "nt" => "77", "nj" => "129");//高速路1 广陵枢纽与沪陕高速公路交叉口(地址:江苏省泰州市泰兴市)to:高速路标记点到南通的最短时间 go:高速路标记点到南京的最短时间
- $road2 = array("location" => "31.749506,120.140182", "nt" => "89", "nj" => "116");//高速路2 江苏省常州市武进区横林枢纽立交桥
- */
- //测试
- /*$test = new test();
- //传入的订单数组
- $order_list = array(
- 0 => array("order_id" => 10001, "num" => 2, "startx_y" => '32.037596,118.769413', "endx_y" => '31.978861,120.915932'),
- 1 => array("order_id" => 10002, "num" => 2, "startx_y" => '32.04072,118.753993', "endx_y" => '32.01604,120.863561'),
- 2 => array("order_id" => 10003, "num" => 1, "startx_y" => '32.034166,118.746134', "endx_y" => '31.98495,120.923472')
- );
-
- //新加入订单信息
- $new_order = array("order_id" => "10004", "num" => "1", "startx_y" => "32.021622,118.728496", "endx_y" => "32.064859,120.815552");
-
- //起点时间矩阵
- $array_start = array(
- 1 => array(1 => 0, 2 => 7, 3 => 9, 4 => 11),
- 2 => array(1 => 6, 2 => 0, 3 => 8, 4 => 2),
- 3 => array(1 => 7, 2 => 10, 3 => 0, 4 => 25),
- 4 => array(1 => 7, 2 => 14, 3 => 10, 4 => 0)
- );
- //终点时间矩阵
- $array_end = array(
- 1 => array(1 => 0, 2 => 5, 3 => 11, 4 => 5),
- 2 => array(1 => 3, 2 => 0, 3 => 8, 4 => 20),
- 3 => array(1 => 11, 2 => 5, 3 => 0, 4 => 12),
- 4 => array(1 => 15, 2 => 8, 3 => 11, 4 => 0)
- );
- $res = $test->Control($order_list, $new_order, $array_start, $array_end);
- var_dump($res);*/
|