|
- <?php
- /*
- Author:LB
- Compeny:Spiders Travel
- */
- require_once '../Common/Mysql.php';
- if (ALLOW_ORIGIN)
- header("Access-Control-Allow-Origin:*");
- $c = file_get_contents('php://input');
- $android=json_decode($c,true);
- $method=$android['method'];
- $pdo=conn1();
- $data=array("code"=>"-100","info"=>"接口开始");
- //$pdo=conn1();
- //$pdo=conn1();
- switch ($method){
- case 'sendScannerLinked':
- $driverId=$android['data']['driverId'];
- $driverName=$android['data']['driverName'];
- $dev=$android['data']['dev'];
- $isLinkedScanner=$android['data']['isLinkedScanner'];
- $sql = " INSERT INTO driver_scanner_linked(DRIVER_ID,DRIVER_NAME,DEV,IS_LINKED_SCANNER,CREATE_TIME) values('{$driverId}','{$driverName}','{$dev}','{$isLinkedScanner}',now())";
- if(is_object($pdo)){
- $result=$pdo->query($sql);
- if( $result == false ) {
- $data['code']='-1';
- $data['info']='插入失败';
- break;
- }
- $json=$result->fetchAll(PDO::FETCH_ASSOC);
- $result->closeCursor();
- if( $json != false ){
- $data['code'] = '0';
- $data['info'] = '插入相关信息成功';
- $data['data'] = $json[0];
- }else{
- $data['code'] = '0';
- $data['info'] = '';
- $data['data'] = "";
- }
- }
- break;
- //根据线路id获取所有的订单信息
- case 'getAllOrderInformation':
- $runId=$android['data']['runId'];
- $sql="CALL DRIVER_GET_ORDER_INFO('".$runId."')";
- if(is_object($pdo)){
- $result=$pdo->query($sql);
- $json=$result->fetchAll(PDO::FETCH_ASSOC);
- $result->closeCursor();
- if($json&&$json[0]&&$json[0]['orderId']){
- $data['code']='0';
- $data['info']='获取乘客信息成功';
- $data['data']=$json;
-
- }else{
- $data['code']='0';
- $data['info']='';
- $data['data']=array();
- }
- }
- break;
-
- //上传当前app的版本号
- case 'updateAppStatus':
- $driverResId=$android['data']['driverResId'];
- $versionCode=$android['data']['versionCode'];
- $sql="CALL DRIVER_UPDATE_APP_STATUS_CHANGE('".$driverResId."','".$versionCode."')";
- writeLog("updateAppStatus:".$sql);
- if(is_object($pdo)){
- $result=$pdo->query($sql);
- $json=$result->fetchAll(PDO::FETCH_ASSOC);
- $result->closeCursor();
-
- }
- $data['code'] = '0';
- $data['info'] = '';
- $data['data'] = "";
- break;
- //获取当前司机的app更新状态,0是没有更新,1是需要更新
- case 'getAppUpdateStatus':
- $driverResId=$android['data']['driverResId'];
- $sql="CALL DRIVER_UPDATE_APP_STATUS('".$driverResId."')";
- if(is_object($pdo)){
- $result=$pdo->query($sql);
- $json=$result->fetchAll(PDO::FETCH_ASSOC);
- $result->closeCursor();
- if($json){
- if(count($json)>0){
-
- $data['code'] = '0';
- $data['info'] = '获取司机app更新状态成功';
- $json[0]["driverResId"] = $json[0]["driverResId"];
- $json[0]["driverBusType"] = $json[0]["driverBusType"];
- $json[0]["appUpdateStatus"] = $json[0]["appUpdateStatus"];
- $json[0]["driverUpdateTime"] = $json[0]["driverUpdateTime"];
- $json[0]["publishUpdateTime"] = $json[0]["publishUpdateTime"];
- $json[0]["downloadAddress"] = $json[0]["downloadAddress"];
- $json[0]["versionCode"] = $json[0]["versionCode"];
- $data['data'] = $json[0];
-
-
- }
- }else{
- $data['code']='1';
- $data['info']='更新状态获取失败code:1';
- }
- }
- break;
-
- //如果该任务以后还有139,那么将该任务置为141
- case 'autoUpdateStatus':
- $driver_res_id=$android['data']['driverResId'];
- $runId=$android['data']['runId'];
- $sql="CALL DRIVER_AUTO_UPDATE_STATUS('".$driver_res_id."','".$runId."')";
- if(is_object($pdo)){
- $result=$pdo->query($sql);
- $json=$result->fetchAll(PDO::FETCH_ASSOC);
- $result->closeCursor();
-
- }
- $data['code'] = '0';
- $data['info'] = '';
- $data['data'] = "";
- break;
-
- //点击了结束行程按钮,将行程置为141
- case 'updateBusStatus':
- $run_id = $android['data']['runId'];
- $bus_order_id = $android['data']['busOrderId'];
- $status = $android['data']['status'];
- $sql = " update run_bus set run_bus.run_bus_status = '{$status}' where run_bus.run_id = '{$run_id}' and run_bus.bus_order_id = '{$bus_order_id}'";
- if(is_object($pdo)){
- $result=$pdo->query($sql);
- }
- $data['code'] = '0';
- $data['info'] = '';
- $data['data'] = "";
- break;
-
- //更改乘客上车状态
- case 'updateCheckStatus':
- $run_id = $android['data']['runId'];
- $order_id = $android['data']['orderId'];
-
- $status = $android['data']['status'];
- $bus_no = $android['data']['busNo'];
- $sql =
- "insert into order_check_tickets(order_id,run_id,bus_no,check_status,check_time,check_station) values('{$order_id}','{$run_id}','{$bus_no}','{$status}',now(),0)";
- if(is_object($pdo)){
- $result=$pdo->query($sql);
- }
- $data['code'] = '0';
- $data['info'] = '成功更改';
- $data['data'] = "";
- break;
- //通过车牌号获取蓝牙地址
- case 'getAddressByCar':
- $bus_res_id = $android['data']['busResId'];//实际上是车牌号码
- $sql = " SELECT base_resource.RES_ID,base_resource_property.PROPERTY FROM base_resource,base_resource_property WHERE base_resource.RES_NAME='{$bus_res_id}' AND base_resource_property.RES_ID = base_resource.RES_ID AND base_resource_property.TYPE_ID=276 ";
- if(is_object($pdo)){
- $result=$pdo->query($sql);
- if( $result == false ) {
- $data['code']='-1';
- $data['info']='查询失败';
- $data['blueToothAddress']="";
- break;
- }
- $json=$result->fetchAll(PDO::FETCH_ASSOC);
- $result->closeCursor();
- if( $json != false ){
- $data['code'] = '0';
- $data['info'] = '获取扫码设备信息成功';
- $json[0]["blueToothAddress"] = $json[0]["PROPERTY"];
- $data['data'] = $json[0];
- }else{
- $data['code'] = '0';
- $data['info'] = '';
- $data['data'] = "";
- }
- }
- break;
- case 'getAllBlueToothAddress':
- $sql = " SELECT machine_code FROM scan_machine_code WHERE cancel_flag = 0 ";
- if(is_object($pdo)){
- $result=$pdo->query($sql);
- if( $result == false ) {
- $data['code']='-1';
- $data['info']='查询失败';
- $data['data']="";
- break;
- }
- $json=$result->fetchAll(PDO::FETCH_ASSOC);
- $result->closeCursor();
- if( $json != false ){
- $return_data = array();
- foreach( $json as $json_info ) {
- $return_data[] = $json_info["machine_code"];
- }
- $data['code'] = '0';
- $data['info'] = '获取扫码设备信息成功';
- $data['data'] = $return_data;
- }else{
- $data['code'] = '0';
- $data['info'] = '';
- $data['data'] = array();
- }
- }
- break;
- case 'getCode':
- $userId=isset($android['data']['userId'])?$android['data']['userId']:'';
- $phone=isset($android['data']['phone'])?$android['data']['phone']:'';
- $div=isset($android['data']['div'])?$android['data']['div']:'';
- $sql="CALL DRIVER_GET_CODE('".$userId."','".$phone."','".$div."')";
- if(is_object($pdo)){
- $result=$pdo->query($sql);
- $json=$result->fetchAll(PDO::FETCH_ASSOC);
- $result->closeCursor();
- if($json){
- if(count($json)>0){
- if($json[0]['code'] == '0'){
- $data['code']=$json[0]['code'];
- $data['info']=$json[0]['info'];
- $data['data']=$json[0];
- //$Phones='15670428930;';
- $Phones=$phone;
- //$url='http://www.mxtong.net.cn/GateWay/Services.asmx/DirectSend?UserID=995596&Account=alert&Password=zzcx8888&Phones='.$Phones.'&Content='.$data['data']['codeinfo'].'【蜘蛛行】&SendTime=&SendType=1&PostFixNumber=';
- $url='http://hprpt2.eucp.b2m.cn:8080/sdkproxy/sendsms.action?cdkey=8SDK-EMY-6699-RISUM&password=175348&phone='.$phone.'&message=【蜘蛛行】'.$data['data']['codeinfo'];
- $html=httpRequest($url);
- }else{
- $data['code']=$json[0]['code'];
- if($json[0]['info'] == 181){
- $data['info']='该手机号码不存在';
- }else{
- $data['info']=$json[0]['info'];
- }
- }
- }
- }else{
- $data['code']='1';
- $data['info']='获取验证码失败';
- }
- }
- break;
- case 'login':
- $userId=isset($android['data']['userId'])?$android['data']['userId']:'';
- $phone=isset($android['data']['phone'])?$android['data']['phone']:'';
- $dev=isset($android['data']['dev'])?$android['data']['dev']:'';
- $code=isset($android['data']['code'])?$android['data']['code']:'';
- $sql="CALL DRIVER_LOGIN('".$userId."','".$phone."','".$dev."','".$code."')";
- if(is_object($pdo)){
- $result=$pdo->query($sql);
- $json=$result->fetchAll(PDO::FETCH_ASSOC);
- $result->closeCursor();
- if($json){
- if(count($json)>0){
- if($json[0]['code'] == '0'){
- $data['code']=$json[0]['code'];
- $data['info']=$json[0]['info'];
- $data['data']=$json[0];
- $a=$json[0]['bus_type'];
- file_put_contents("log.txt", $a . " 操作时间:" . date("Y-m-d h:i:s", time()) . PHP_EOL, FILE_APPEND);
- }else{
- $data['code']=$json[0]['code'];
- if($json[0]['info'] == 182){
- $data['info']='登录失败';
- }else{
- $data['info']=$json[0]['info'];
- }
- }
- }
- }else{
- $data['code']='1';
- $data['info']='登录失败';
- }
- }
- break;
- case 'logout':
- $userId=isset($android['data']['userId'])?$android['data']['userId']:'';
- $phone=isset($android['data']['phone'])?$android['data']['phone']:'';
- $dev=isset($android['data']['dev'])?$android['data']['dev']:'';
- $sql="CALL DRIVER_LOGOUT('".$userId."','".$phone."','".$dev."')";
- if(is_object($pdo)){
- $result=$pdo->query($sql);
- $json=$result->fetchAll(PDO::FETCH_ASSOC);
- $result->closeCursor();
- if($json){
- if(count($json)>0){
- if($json[0]['code'] == '0'){
- $data['code']=$json[0]['code'];
- $data['info']=$json[0]['info'];
-
- }else{
- $data['code']=$json[0]['code'];
- if($json[0]['info'] == 183){
- $data['info']='登出失败';
- }else{
- $data['info']=$json[0]['info'];
- }
- }
- }
- }else{
- $data['code']='1';
- $data['info']='登出失败';
- }
- }
- break;
- case 'pastLine':
- $userId=isset($android['data']['userId'])?$android['data']['userId']:'';
- $currPage=isset($android['data']['currpage'])?$android['data']['currpage']:'1';
- $pageSize=isset($android['data']['pageSize'])?$android['data']['pageSize']:'20';
- $resId=isset($android['data']['resId'])?$android['data']['resId']:'';
- $sql="CALL DRIVER_PAST_LINE('".$userId."','".$currPage."','".$pageSize."','".$resId."')";
- writeLog("DRIVER_PAST_LINE::::".$sql);
- if(is_object($pdo)){
- $result=$pdo->query($sql);
- $j = 1;
- if($result){
- $data['code']='0';
- $data['info']='';
- do{
- $rowset = $result->fetchAll(PDO::FETCH_ASSOC);
- if($j==1){
- $data['currpage']=$rowset[0]['currpage'];
- $data['totalPage']=$rowset[0]['total_page'];
- $data['total']=$rowset[0]['total'];
- $data['pageSize']=$rowset[0]['page_size'];
- }else if ($j==2){
- $json=$rowset;
- $lineList=array();
- $i=0;
- $k=0;
- $runId='';
- $stationList=array();
- foreach ($json as $js){
- if($runId==''){
- $runId=$js['runId'];
- $lineList[$i]['runId']=$js['runId'];
- $lineList[$i]['plate']=$js['plate'];
- $lineList[$i]['runDate']=$js['runDate'];
- $lineList[$i]['runTime']=$js['runTime'];
- $lineList[$i]['seatCount']=$js['seatCount'];
- $lineList[$i]['saledCount']=$js['saledCount'];
- $lineList[$i]['line']=$js['line'];
- $stationList[$k]['areaName']=$js['areaName'];
- $stationList[$k]['startTime']=$js['startTime'];
- $stationList[$k]['orderID']=$js['orderID'];
- $lineList[$i]['stationList']=$stationList;
- }else{
- if($runId==$js['runId']){
- $runId=$js['runId'];
- $k++;
- $stationList[$k]['areaName']=$js['areaName'];
- $stationList[$k]['startTime']=$js['startTime'];
- $stationList[$k]['orderID']=$js['orderID'];
- $lineList[$i]['stationList']=$stationList;
- }else{
- $runId=$js['runId'];
- $i++;
- $k=0;
- $stationList=array();
- $runId=$js['runId'];
- $lineList[$i]['runId']=$js['runId'];
- $lineList[$i]['plate']=$js['plate'];
- $lineList[$i]['runDate']=$js['runDate'];
- $lineList[$i]['runTime']=$js['runTime'];
- $lineList[$i]['seatCount']=$js['seatCount'];
- $lineList[$i]['saledCount']=$js['saledCount'];
- $lineList[$i]['line']=$js['line'];
- $stationList[$k]['areaName']=$js['areaName'];
- $stationList[$k]['startTime']=$js['startTime'];
- $stationList[$k]['orderID']=$js['orderID'];
- $lineList[$i]['stationList']=$stationList;
- }
- }
- }
- $i=0;
- $k=0;
- $data['data']=$lineList;
- }else{
- }
- $j++;
- }while ($result->nextRowset());
- $result->closeCursor();
- }else{
- $data['code']='0';
- $data['info']='暂无历史线路';
- $data['data']=array();
- }
- }else{
- $data['code']='1';
- $data['info']='获取历史线路失败';
- }
- break;
- case 'futureLine':
- $userId=isset($android['data']['userId'])?$android['data']['userId']:'';
- $currPage=isset($android['data']['currpage'])?$android['data']['currpage']:'1';
- $pageSize=isset($android['data']['pageSize'])?$android['data']['pageSize']:'20';
- $resId=isset($android['data']['resId'])?$android['data']['resId']:'';
- $sql="CALL DRIVER_FUTURE_LINE('".$userId."','".$currPage."','".$pageSize."','".$resId."')";
- if(is_object($pdo)){
- $result=$pdo->query($sql);
- $j = 1;
- if($result){
- $data['code']='0';
- $data['info']='';
- do{
- $rowset = $result->fetchAll(PDO::FETCH_ASSOC);
- if($j==1){
- $data['currpage']=$rowset[0]['currpage'];
- $data['totalPage']=$rowset[0]['total_page'];
- $data['total']=$rowset[0]['total'];
- $data['pageSize']=$rowset[0]['page_size'];
- }else if ($j==2){
- $json=$rowset;
- $lineList=array();
- $i=0;
- $k=0;
- $runId='';
- $stationList=array();
- foreach ($json as $js){
- if($runId==''){
- $runId=$js['runId'];
- $lineList[$i]['runId']=$js['runId'];
- $lineList[$i]['plate']=$js['plate'];
- $lineList[$i]['runDate']=$js['runDate'];
- $lineList[$i]['runTime']=$js['runTime'];
- $lineList[$i]['seatCount']=$js['seatCount'];
- $lineList[$i]['saledCount']=$js['saledCount'];
- $lineList[$i]['line']=$js['line'];
- $stationList[$k]['areaName']=$js['areaName'];
- $stationList[$k]['startTime']=$js['startTime'];
- $stationList[$k]['orderID']=$js['orderID'];
- $lineList[$i]['stationList']=$stationList;
- }else{
- if($runId==$js['runId']){
- $runId=$js['runId'];
- $k++;
- $stationList[$k]['areaName']=$js['areaName'];
- $stationList[$k]['startTime']=$js['startTime'];
- $stationList[$k]['orderID']=$js['orderID'];
- $lineList[$i]['stationList']=$stationList;
- }else{
- $runId=$js['runId'];
- $i++;
- $k=0;
- $stationList=array();
- $runId=$js['runId'];
- $lineList[$i]['runId']=$js['runId'];
- $lineList[$i]['plate']=$js['plate'];
- $lineList[$i]['runDate']=$js['runDate'];
- $lineList[$i]['runTime']=$js['runTime'];
- $lineList[$i]['seatCount']=$js['seatCount'];
- $lineList[$i]['saledCount']=$js['saledCount'];
- $lineList[$i]['line']=$js['line'];
- $stationList[$k]['areaName']=$js['areaName'];
- $stationList[$k]['startTime']=$js['startTime'];
- $stationList[$k]['orderID']=$js['orderID'];
- $lineList[$i]['stationList']=$stationList;
- }
- }
- }
- $i=0;
- $k=0;
- $data['data']=$lineList;
- }else{
- }
- $j++;
- }while ($result->nextRowset());
- $result->closeCursor();
- }else{
- $data['code']='0';
- $data['info']='暂无未来线路';
- $data['data']=array();
- }
- }else{
- $data['code']='1';
- $data['info']='获取未来线路';
- }
- break;
- case 'getUserStationInfo':
- $userId=isset($android['data']['userId'])?$android['data']['userId']:'';
- $runId=isset($android['data']['runId'])?$android['data']['runId']:'';
- $busOrderId=isset($android['data']['busOrderId'])?$android['data']['busOrderId']:'';
- $stationResId=isset($android['data']['stationResId'])?$android['data']['stationResId']:'';
- $sql="CALL DRIVER_GET_STATION_USER_INFO('".$userId."','".$runId."','".$busOrderId."','".$stationResId."')";
- if(is_object($pdo)){
- $result=$pdo->query($sql);
- $json=$result->fetchAll(PDO::FETCH_ASSOC);
- $result->closeCursor();
- if($json&&$json[0]&&$json[0]['userName']){
- $data['code']='0';
- $data['info']='获取站点用户信息成功';
- $data['data']=$json;
-
- }else{
- $data['code']='0';
- $data['info']='';
- $data['data']=array();
- }
- }
- break;
- case 'getDriverinfo':
- $userId=isset($android['data']['userId'])?$android['data']['userId']:'';
- $resId=isset($android['data']['resId'])?$android['data']['resId']:'';
- $sql="CALL DRIVER_GET_INFO('".$userId."','".$resId."')";
- if(is_object($pdo)){
- $result=$pdo->query($sql);
- $json=$result->fetchAll(PDO::FETCH_ASSOC);
- $result->closeCursor();
- if($json){
- $data['code']='0';
- $data['info']='获取司机信息成功';
- $data['data']=$json[0];
-
- }else{
- $data['code']='1';
- $data['info']='获取司机信息失败';
- }
- }
- break;
- case 'checkTicket':
- $userId=isset($android['data']['userId'])?$android['data']['userId']:'';
- $runId=isset($android['data']['runId'])?$android['data']['runId']:'';
- $busOrderId=isset($android['data']['busOrderId'])?$android['data']['busOrderId']:'';
- $orderId=isset($android['data']['orderId'])?$android['data']['orderId']:'';
- $stationId=isset($android['data']['stationId'])?$android['data']['stationId']:'';
- $checkTicketType=isset($android['data']['checkTicketType'])?$android['data']['checkTicketType']:'';
- $sql="CALL DRIVER_CHECK_TICKET_ORDER('".$userId."','".$runId."','".$busOrderId."','".$orderId."','".$stationId."','".$checkTicketType."')";
- writeLog($sql);
- if(is_object($pdo)){
- $result=$pdo->query($sql);
- if( $result != false ) {
- $json = $result->fetchAll(PDO::FETCH_ASSOC);
- $result->closeCursor();
- } else {
- $json = false;
- }
- if($json){
- if($json[0]['num']>0){
- $data['code']='0';
- $data['info']='';
- $data['data']=$json[0];
- }else{
- $data['code']='1';
- $data['info']='检票失败';
- }
-
- }else{
- $data['code']='1';
- $data['info']='检票失败';
- }
- }
- break;
- case 'runningLine':
- $userId=isset($android['data']['userId'])?$android['data']['userId']:'';
- $resId=isset($android['data']['resId'])?$android['data']['resId']:'';
-
- $sql="CALL DRIVER_RUNNING_LINE('".$userId."','".$resId."')";
- if(is_object($pdo)){
- $result=$pdo->query($sql);
- $json=$result->fetchAll(PDO::FETCH_ASSOC);
- $result->closeCursor();
- if($json){
- $lineList=array();
- $i=0;
- $k=0;
- $runId='';
- $stationList=array();
- foreach ($json as $js){
- if($runId==''){
- $runId=$js['runId'];
- $d['runId']=$js['runId'];
- $d['number']=$js['number'];
- $d['plate']=$js['plate'];
- $d['runDate']=$js['runDate'];
- $d['runTime']=$js['runTime'];
- $d['runStatus']=$js['runStatus'];
- $d['seatCount']=$js['seatCount'];
- $d['saledCount']=$js['saledCount'];
- $d['currentOrderId']=$js['currentOrderId'];
- $d['line']=$js['line'];
- $stationList[$k]['areaName']=$js['areaName'];
- $stationList[$k]['startTime']=$js['startTime'];
- $stationList[$k]['orderID']=$js['orderID'];
- $stationList[$k]['stationName']=$js['stationName'];
- $stationList[$k]['stationResId']=$js['stationResId'];
- $stationList[$k]['inOutType']=$js['inOutType'];
- $stationList[$k]['longitude']=$js['longitude'];
- $stationList[$k]['latitude']=$js['latitude'];
- $d['stationList']=$stationList;
- }else{
- if($runId==$js['runId']){
- $runId=$js['runId'];
- $k++;
- $stationList[$k]['areaName']=$js['areaName'];
- $stationList[$k]['startTime']=$js['startTime'];
- $stationList[$k]['orderID']=$js['orderID'];
- $stationList[$k]['stationName']=$js['stationName'];
- $stationList[$k]['stationResId']=$js['stationResId'];
- $stationList[$k]['inOutType']=$js['inOutType'];
- $stationList[$k]['longitude']=$js['longitude'];
- $stationList[$k]['latitude']=$js['latitude'];
- $d['stationList']=$stationList;
- }else{
- $runId=$js['runId'];
- $i++;
- $k=0;
- $stationList=array();
- $runId=$js['runId'];
- $d['runId']=$js['runId'];
- $d['number']=$js['number'];
- $d['plate']=$js['plate'];
- $d['runDate']=$js['runDate'];
- $d['runTime']=$js['runTime'];
- $d['runStatus']=$js['runStatus'];
- $d['seatCount']=$js['seatCount'];
- $d['saledCount']=$js['saledCount'];
- $d['currentOrderId']=$js['currentOrderId'];
- $d['line']=$js['line'];
- $stationList[$k]['areaName']=$js['areaName'];
- $stationList[$k]['startTime']=$js['startTime'];
- $stationList[$k]['orderID']=$js['orderID'];
- $stationList[$k]['stationName']=$js['stationName'];
- $stationList[$k]['stationResId']=$js['stationResId'];
- $stationList[$k]['inOutType']=$js['inOutType'];
- $stationList[$k]['longitude']=$js['longitude'];
- $stationList[$k]['latitude']=$js['latitude'];
- $d['stationList']=$stationList;
- }
- }
- }
- $i=0;
- $k=0;
- $data['code']='0';
- $data['info']='';
- $data['data']=$d;
- //$data['lineList']=$lineList;
- }else{
- $data['code']='0';
- $data['info']='暂无今日线路';
- //$data['data']=array();
- }
- }else{
- $data['code']='1';
- $data['info']='获取当前线路失败';
- }
- break;
-
- case 'futureLineDetail':
- $runId=isset($android['data']['runId'])?$android['data']['runId']:'';
- $sql="CALL DRIVER_FUTURE_LINE_DETAIL('".$runId."')";
- if(is_object($pdo)){
- $result=$pdo->query($sql);
- $json=$result->fetchAll(PDO::FETCH_ASSOC);
- $result->closeCursor();
- if($json){
- $lineList=array();
- $i=0;
- $k=0;
- $runId='';
- $stationList=array();
- foreach ($json as $js){
- if($runId==''){
- $runId=$js['runId'];
- $d['runId']=$js['runId'];
- $d['number']=$js['number'];
- $d['plate']=$js['plate'];
- $d['runDate']=$js['runDate'];
- $d['runTime']=$js['runTime'];
- $d['runStatus']=$js['runStatus'];
- $d['seatCount']=$js['seatCount'];
- $d['currentOrderId']=$js['currentOrderId'];
- $d['line']=$js['line'];
- $stationList[$k]['areaName']=$js['areaName'];
- $stationList[$k]['startTime']=$js['startTime'];
- $stationList[$k]['orderID']=$js['orderID'];
- $stationList[$k]['stationName']=$js['stationName'];
- $stationList[$k]['stationResId']=$js['stationResId'];
- $stationList[$k]['inOutType']=$js['inOutType'];
- $stationList[$k]['longitude']=$js['longitude'];
- $stationList[$k]['latitude']=$js['latitude'];
- $d['stationList']=$stationList;
- }else{
- if($runId==$js['runId']){
- $runId=$js['runId'];
- $k++;
- $stationList[$k]['areaName']=$js['areaName'];
- $stationList[$k]['startTime']=$js['startTime'];
- $stationList[$k]['orderID']=$js['orderID'];
- $stationList[$k]['stationName']=$js['stationName'];
- $stationList[$k]['stationResId']=$js['stationResId'];
- $stationList[$k]['inOutType']=$js['inOutType'];
- $stationList[$k]['longitude']=$js['longitude'];
- $stationList[$k]['latitude']=$js['latitude'];
- $d['stationList']=$stationList;
- }else{
- $runId=$js['runId'];
- $i++;
- $k=0;
- $stationList=array();
- $runId=$js['runId'];
- $d['runId']=$js['runId'];
- $d['number']=$js['number'];
- $d['plate']=$js['plate'];
- $d['runDate']=$js['runDate'];
- $d['runTime']=$js['runTime'];
- $d['runStatus']=$js['runStatus'];
- $d['seatCount']=$js['seatCount'];
- $d['currentOrderId']=$js['currentOrderId'];
- $d['line']=$js['line'];
- $stationList[$k]['areaName']=$js['areaName'];
- $stationList[$k]['startTime']=$js['startTime'];
- $stationList[$k]['orderID']=$js['orderID'];
- $stationList[$k]['stationName']=$js['stationName'];
- $stationList[$k]['stationResId']=$js['stationResId'];
- $stationList[$k]['inOutType']=$js['inOutType'];
- $stationList[$k]['longitude']=$js['longitude'];
- $stationList[$k]['latitude']=$js['latitude'];
- $d['stationList']=$stationList;
- }
- }
- }
- $i=0;
- $k=0;
- $data['code']='0';
- $data['info']='';
- $data['data']=$d;
- //$data['lineList']=$lineList;
- }else{
- $data['code']='0';
- $data['info']='暂无今日线路';
- //$data['data']=array();
- }
- }else{
- $data['code']='1';
- $data['info']='获取当前线路失败';
- }
- break;
-
-
- case 'driverStationInfo':
- $userId=1;
- $runId=isset($android['data']['runId'])?$android['data']['runId']:'';
- $busOrderId=isset($android['data']['busOrderId'])?$android['data']['busOrderId']:'';
- $resId=isset($android['data']['stationResId'])?$android['data']['stationResId']:'';
- $sql="CALL driver_station_info('".$userId."','".$runId."','".$busOrderId."','".$resId."')";
- if(is_object($pdo)){
- $result=$pdo->query($sql);
- $json=$result->fetchAll(PDO::FETCH_ASSOC);
- $result->closeCursor();
- if($json){
- if(count($json)>0){
- if($json[0]['code'] == '0'){
- $data['code']=$json[0]['code'];
- $data['info']=$json[0]['info'];
- $data['data']=$json[0];
- }else{
- $data['code']=$json[0]['code'];
- $data['info']='获取站点失败';
- }
- }
- }else{
- $data['code']='1';
- $data['info']='获取站点失败';
- }
- }
- break;
- case 'busPosUp':
- $runId=isset($android['data']['runId'])?$android['data']['runId']:'';
- $busOrderId=isset($android['data']['busOrderId'])?$android['data']['busOrderId']:'';
- $serial=isset($android['data']['serial'])?$android['data']['serial']:'';
- $posX=isset($android['data']['posX'])?$android['data']['posX']:'';
- $posY=isset($android['data']['posY'])?$android['data']['posY']:'';
- $driver=isset($android['data']['driver'])?$android['data']['driver']:'';
- $sql="CALL DRIVER_BUS_POS_UP('".$runId."','".$busOrderId."','".$serial."','".$posX."','".$posY."','".$driver."')";
- if(is_object($pdo)){
- $result=$pdo->query($sql);
- $json=$result->fetchAll(PDO::FETCH_ASSOC);
- $result->closeCursor();
- if(count($json) >0 && $json[0]['count']>0){
- $data['code']='0';
- $data['info']='上传坐标数据成功';
- }else{
- $data['code']='1';
- $data['info']='上传坐标数据失败';
- }
- }else{
- $data['code']='1';
- $data['info']='上传坐标数据失败';
- }
- break;
- case 'cxZd':
- $runId=isset($android['data']['runId'])?$android['data']['runId']:'';
- $busOrderId=isset($android['data']['busOrderId'])?$android['data']['busOrderId']:'';
- $status=isset($android['data']['status'])?$android['data']['status']:0;
- $currentOrderId=isset($android['data']['currentOrderId'])?$android['data']['currentOrderId']:0;
- $sql="CALL DRIVER_CX_ZD('".$runId."','".$busOrderId."','".$status."','".$currentOrderId."')";
- if(is_object($pdo)){
- $result=$pdo->query($sql);
- $json=$result->fetchAll(PDO::FETCH_ASSOC);
- $result->closeCursor();
- if(count($json) >0 && $json[0]['res_name']){
- $data['code']='0';
- $data['info']='更新距离位置状态成功';
- }else{
- $data['code']='1';
- $data['info']='更新距离位置失败';
- }
- }else{
- $data['code']='1';
- $data['info']='更新距离位置失败';
- }
- break;
- case 'getCheckInfo':
- $runId=isset($android['data']['runId'])?$android['data']['runId']:'';
- $busOrderId=isset($android['data']['busOrderId'])?$android['data']['busOrderId']:'';
- $stationId=isset($android['data']['stationId'])?$android['data']['stationId']:0;
- $sql="CALL DERVER_CK_SEL('".$runId."','".$busOrderId."','".$stationId."')";
- if(is_object($pdo)){
- $result=$pdo->query($sql);
- $json=$result->fetchAll(PDO::FETCH_ASSOC);
- $result->closeCursor();
- if(count($json) >0){
- $data['code']='0';
- $data['info']='';
- $data['data']=$json[0];
- }else{
- $data['code']='1';
- $data['info']='获取检票状态失败';
- }
- }else{
- $data['code']='1';
- $data['info']='获取检票状态失败';
- }
- break;
- case 'getCarCnt':
- $runId=isset($android['data']['runId'])?$android['data']['runId']:'';
- $busOrderId=isset($android['data']['busOrderId'])?$android['data']['busOrderId']:'';
- $stationId=isset($android['data']['stationId'])?$android['data']['stationId']:0;
- $sql="CALL DRIVER_CAR_CNT('".$runId."','".$stationId."','".$busOrderId."')";
- if(is_object($pdo)){
- $result=$pdo->query($sql);
- $json=$result->fetchAll(PDO::FETCH_ASSOC);
- $result->closeCursor();
- if(count($json) >0){
- $data['code']='0';
- $data['info']='';
- $data['data']=$json[0];
- }else{
- $data['code']='0';
- $data['info']='暂无数据';
- }
- }else{
- $data['code']='1';
- $data['info']='获取乘客信息失败';
- }
- break;
- case 'updateBusStation':
- //173953,1,121.43,31.17
- $runId=isset($android['data']['runId'])?$android['data']['runId']:"";
- $busOrderId=isset($android['data']['busOrderId'])?$android['data']['busOrderId']:'';
- // 经度 Longitude,纬度 latitude
- $longitude=$android['data']['longitude'];
- $latitude=$android['data']['latitude'];
- if($runId=="" || $busOrderId=="" || $longitude=="" || $latitude==""){
- $data['code']='-1';
- $data['info']='缺少参数';
- echo json_encode($data);exit();
- }
- $sql="CALL DRIVER_UPDATE_BUS_STATION(".$runId.",".$busOrderId.",".$longitude.",".$latitude.")";
- writeLog('updateBusStation sql='.$sql);
- if(is_object($pdo)){
- $result=$pdo->query($sql);
- if($result){
- $json=$result->fetchAll(PDO::FETCH_ASSOC);
- $result->closeCursor();
- $data['code']=isset($json[0]['errcode'])?$json[0]['errcode']:"-5";
- $data['info']=isset($json[0]['errinfo'])?$json[0]['errinfo']:"未从数据库获得返回值";
- echo json_encode($data);exit();
- }else{
- $data['code']='-2';
- $data['info']='数据库错误';
- echo json_encode($data);exit();
- }
- }else{
- $data['code']="-3";
- $data['info']="连接数据库错误";
- echo json_encode($data);exit();
- }
- break;
-
- case 'getAllStationInformation':
- $driver_res_id = $android['data']['driver_res_id'];
- $run_date = date('Y-m-d',time());
- $run_time = date('H:i',time());
- $order_array = array();
-
- $sql = "SELECT
- a.run_id,
- a.bus_order_id,
- a.send_bus_driver_res_id,
- a.send_bus_no,
- a.send_driver_name,
- a.send_driver_mobile,
- b.run_date,
- b.run_time
- FROM
- run_bus as a,
- run_main as b
- WHERE
- a.run_id = b.run_id
- AND a.cancel_flag = 0
- AND a.run_bus_status = 139
- AND a.send_status = 143
- AND a.send_bus_driver_res_id = " . $driver_res_id . "
- and b.run_date >= '" . $run_date . "'
- ORDER by
- b.run_date asc,
- b.run_time asc
- LIMIT 1";
-
- $result=$pdo->query($sql);
- $driver_info=$result->fetchAll(PDO::FETCH_ASSOC);
- if(count($driver_info) == 1){
- $driver_info = $driver_info[0];
- $run_date = $driver_info['run_date'];
- $run_id = $driver_info['run_id'];
- $bus_order_id = $driver_info['bus_order_id'];
- $bus_no = $driver_info['send_bus_no'];
- $driver_name = $driver_info['send_driver_name'];
- $driver_mobile = $driver_info['send_driver_mobile'];
- $run_time = $driver_info['run_time'];
-
- $sql = "select a.type_id,a.property from opera_product_property as a,run_main as b where a.prod_id = b.prod_id and a.type_id in (125,126) and b.run_id = " . $run_id;
- $result=$pdo->query($sql);
- $area_id=$result->fetchAll(PDO::FETCH_ASSOC);
- foreach($area_id as $k => $v){
- if($v['type_id'] == 125){
- $start_id = $v['property'];
- $sql = "select area_name from base_area where id = " . $start_id;
- $result=$pdo->query($sql);
- $start_area=$result->fetchAll(PDO::FETCH_ASSOC);
- $start_area = $start_area[0]['area_name'];
- }else{
- $end_id = $v['property'];
- $sql = "select area_name from base_area where id = " . $end_id;
- $result=$pdo->query($sql);
- $end_area=$result->fetchAll(PDO::FETCH_ASSOC);
- $end_area = $end_area[0]['area_name'];
- }
- }
-
- $sql = "SELECT
- order_main.order_id,
- order_main.customer_name,
- order_main.customer_mobile,
- order_main.order_description,
- order_main.prod_start_station_area_name,
- order_main.prod_end_station_area_name,
- order_check_tickets.check_status
-
-
- FROM
- order_main left join order_check_tickets on order_main.order_id = order_check_tickets.order_id
- WHERE
- cancel_flag = 0 and (order_status = 146 or order_status = 147)
- AND order_main.order_id IN (
- SELECT
- parent_order_id
- FROM
- order_main
- WHERE
- run_id = " . $run_id . "
- AND run_bus_order_id = " . $bus_order_id . "
- AND cancel_flag = 0
- GROUP BY
- parent_order_id
- )";
- $result=$pdo->query($sql);
- $order_no=$result->fetchAll(PDO::FETCH_ASSOC);
-
- if(count($order_no) > 0){
- foreach($order_no as $k => $v){
- $order_array[$v['order_id']] = $v;
- $order_id_array[$v['order_id']] = $v['order_id'];
- }
-
- $sql = "select id,check_status,order_id from order_check_tickets where order_id in (" . implode(",",$order_id_array) . ")";
- $result=$pdo->query($sql);
- $order_check=$result->fetchAll(PDO::FETCH_ASSOC);
-
-
- foreach($order_check as $k => $v){
- $order_array[$v['order_id']]['check_id']=$v['id'];
- $order_array[$v['order_id']]['check_status'] = $v['check_status'];
- }
- $order_array = array_values($order_array);
-
- $sql = "select prod_id,order_id,station,lat_long,station_type,station_time from run_bus_station_view where cancel_flag = 0 and run_id = " . $run_id . " and bus_no = " . $bus_order_id;
- $result=$pdo->query($sql);
- $station_view=$result->fetchAll(PDO::FETCH_ASSOC);
- $station_view = $station_view[0];
-
- }else{
- $order_array = array();
- $station_view = array();
- }
- $list['run_id'] = $run_id;
- $list['run_date'] = $run_date;
- $list['run_time'] = $run_time;
- $list['bus_no'] = $bus_no;
- $list['bus_order_id'] = $bus_order_id;
- $list['driver_name'] = $driver_name;
- $list['driver_mobile'] = $driver_mobile;
- $list['order'] = $order_array;
- $list['station_view'] = $station_view;
- $list['status_type'] = '0';
- $data['code'] = '0';
- $data['info'] = '成功';
- $data['data'] = $list;
-
-
- }else{
- $sql = "SELECT
- a.run_id,
- a.bus_order_id,
- a.send_bus_driver_res_id,
- a.send_bus_no,
- a.send_driver_name,
- a.send_driver_mobile,
- b.run_date,
- b.run_time
- FROM
- run_bus as a,
- run_main as b
- WHERE
- a.run_id = b.run_id
- AND a.cancel_flag = 0
- AND a.run_bus_status = 138
- AND a.send_status = 143
- AND a.send_bus_driver_res_id = " . $driver_res_id . "
- and b.run_date >= '" . $run_date . "'
- and b.run_time >= '" . $run_time . "'
- ORDER by
- b.run_date asc,
- b.run_time asc
- LIMIT 1";
- file_put_contents("ttt.txt", $sql . " 操作时间:" . date("Y-m-d h:i:s", time()) . PHP_EOL, FILE_APPEND);
- $result=$pdo->query($sql);
- $driver_info=$result->fetchAll(PDO::FETCH_ASSOC);
-
- if(count($driver_info) == 1){
- $driver_info = $driver_info[0];
- $run_date = $driver_info['run_date'];
- $run_id = $driver_info['run_id'];
- $bus_order_id = $driver_info['bus_order_id'];
- $bus_no = $driver_info['send_bus_no'];
- $driver_name = $driver_info['send_driver_name'];
- $driver_mobile = $driver_info['send_driver_mobile'];
- $run_time = $driver_info['run_time'];
-
- $sql = "SELECT
- order_id,
- customer_name,
- customer_mobile,
- order_description,
- prod_start_station_area_name,
- prod_end_station_area_name
- FROM
- order_main
- WHERE
- cancel_flag = 0 and (order_status = 146 or order_status = 147)
- AND order_id IN (
- SELECT
- parent_order_id
- FROM
- order_main
- WHERE
- run_id = " . $run_id . "
- AND run_bus_order_id = " . $bus_order_id . "
- AND cancel_flag = 0
- GROUP BY
- parent_order_id
- )";
- $result=$pdo->query($sql);
- $order_no=$result->fetchAll(PDO::FETCH_ASSOC);
-
- $sql = "select a.type_id,a.property from opera_product_property as a,run_main as b where a.prod_id = b.prod_id and a.type_id in (125,126) and b.run_id = " . $run_id;
- $result=$pdo->query($sql);
- $area_id=$result->fetchAll(PDO::FETCH_ASSOC);
-
- foreach($area_id as $k => $v){
- if($v['type_id'] == 125){
- $start_id = $v['property'];
- $sql = "select area_name from base_area where id = " . $start_id;
- $result=$pdo->query($sql);
- $start_area=$result->fetchAll(PDO::FETCH_ASSOC);
- $start_area = $start_area[0]['area_name'];
- }else{
- $end_id = $v['property'];
- $sql = "select area_name from base_area where id = " . $end_id;
- $result=$pdo->query($sql);
- $end_area=$result->fetchAll(PDO::FETCH_ASSOC);
- $end_area = $end_area[0]['area_name'];
- }
- }
-
- if(count($order_no) > 0){
- foreach($order_no as $k => $v){
- $order_array[$v['order_id']] = $v;
- $order_id_array[$v['order_id']] = $v['order_id'];
- }
-
- $sql = "select id,check_status,order_id from order_check_tickets where order_id in (" . implode(",",$order_id_array) . ")";
- $result=$pdo->query($sql);
- $order_check=$result->fetchAll(PDO::FETCH_ASSOC);
-
- foreach($order_check as $k => $v){
- $order_array[$v['order_id']]['check_id']=$v['id'];
- $order_array[$v['order_id']]['check_status'] = $v['check_status'];
- }
- $order_array = array_values($order_array);
-
- $sql = "select prod_id,order_id,station,lat_long,station_type,station_time from run_bus_station_view where cancel_flag = 0 and run_id = " . $run_id . " and bus_no = " . $bus_order_id;
- $result=$pdo->query($sql);
- $station_view=$result->fetchAll(PDO::FETCH_ASSOC);
- $station_view = $station_view[0];
-
- }else{
- $order_array = array();
- $station_view = array();
- }
- $list['run_id'] = $run_id;
- $list['run_date'] = $run_date;
- $list['run_time'] = $run_time;
- $list['start_area'] = $start_area;
- $list['end_area'] = $end_area;
- $list['bus_no'] = $bus_no;
- $list['bus_order_id'] = $bus_order_id;
- $list['driver_name'] = $driver_name;
- $list['driver_mobile'] = $driver_mobile;
- $list['order'] = $order_array;
- $list['station_view'] = $station_view;
- $list['status_type'] = '1';
- $data['code'] = '0';
- $data['info'] = '成功';
- $data['data'] = $list;
-
-
- }else{
- $data['code'] = '-1';
- $data['info'] = '没有调度好的行程';
- $data['data'] = array();
- }
- }
- break;
-
- default:
- break;
- }
- if(is_array($data)){
- echo json_encode($data);
- }
- exit;
|