|
- <?php
- /*
- * wechat 2.0
- * Copyright (c) 2016 yixi wei http://zhizhuchuxing.com/
- * Date: 2016.09.07
- * Something is to pay QQ1062140302
- */
-
- header("Access-Control-Allow-Origin:*");
- // require_once '../../../config/Mysql.php';
- // $pdo= conn1();
- $fleet_id = 0;
- if(isset($_POST["bus_no"])) {
- $order_bus_no = $_POST["bus_no"];
- $driver_name = isset($_POST['driver_name'])?$_POST['driver_name']:'';
- $sql = "select base_resource_property.RES_ID,base_resource_property.PROPERTY FROM base_resource_property,base_resource WHERE base_resource_property.TYPE_ID = 18 AND base_resource_property.RES_ID = base_resource.RES_ID AND base_resource.RES_NAME='{$order_bus_no}'";
- $result = $pdo->query($sql);
- if( $result != false ) {
- $rowset = $result->fetchAll(PDO::FETCH_ASSOC);
- $fleet_id = $rowset == false ? 0 : $rowset[0]["PROPERTY"];
- }
- } else {
- $order_bus_no ='0';
- $driver_name= '';
- }
- $get_car_postion_flag = false;
- if( $fleet_id == "9477" ) {
- $car_position = get_bailian_bus_position($order_bus_no);
- if( false != $car_position ) {
- $get_car_postion_flag = true;
- $j = $car_position['lon'];
- $w = $car_position['lat'];
- $speed = $car_position['speed'];
- }
- }
- if( $get_car_postion_flag == false ) {
- if ($p = getposition($order_bus_no)) { //通过北斗查找车辆信息
- $j = $p['Data'][0]['vehicle']['longitude'];
- $w = $p['Data'][0]['vehicle']['latitude'];
- $speed = $p['Data'][0]['vehicle']['gpsSpeed'];
- } else {
- //$order_driver_name = $rowset[0]["SEND_DRIVER_NAME"];
- $sql = "SELECT b.PROPERTY FROM base_resource a LEFT JOIN `base_resource_property` b on a.RES_ID =b.RES_ID where b.TYPE_ID=283 and a.RES_NAME ='" . $order_bus_no . "'";
- //$pdo = conn();
- $result = $pdo->query($sql);
- $rowset = $result->fetchAll(PDO::FETCH_ASSOC);
-
- $sql_res = "SELECT res_id from base_resource where RES_NAME='" . $driver_name . "'";
- $res_id = $pdo->query($sql_res);
- $res_id_a = $res_id->fetchAll(PDO::FETCH_ASSOC);
- $sql_phone = "SELECT pos_x,pos_y from run_bus_pos where driver_id='" . $res_id_a[0]["res_id"] . "' order by log_time desc";
- $res_phone = $pdo->query($sql_phone);
- $pos_arr = $res_phone->fetchAll(PDO::FETCH_ASSOC);
- //$pdo = conn();
- //$result_name = $pdo -> query($sql_name);
- //$rowset_name = $result_name -> fetchAll(PDO::FETCH_ASSOC);
- if (isset($rowset[0]['PROPERTY'])) {
- $position = get_position($rowset[0]['PROPERTY']);
- $j = $position['j'];
- $w = $position['w'];
- $speed = $position['speed'];
- } elseif (isset($pos_arr[0]['pos_x'])) {
-
- $j = $pos_arr[0]['pos_y'];
- $w = $pos_arr[0]['pos_x'];
- $speed = '0';
- } else {
- $j = '0';
- $w = '0';
- $speed = '0';
- }
- }
- }
-
-
- $signPackage['j'] =$j;
- $signPackage['w'] =$w;
- $signPackage['speed'] =$speed;
-
- echo json_encode(array('code'=>'0','info'=>'','list'=>$signPackage));
|