Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
 
 
 
 

1165 Zeilen
39 KiB

  1. <?php
  2. /*
  3. Author:LB
  4. Compeny:Spiders Travel
  5. */
  6. require_once '../Common/Mysql.php';
  7. if (ALLOW_ORIGIN)
  8. header("Access-Control-Allow-Origin:*");
  9. $c = file_get_contents('php://input');
  10. $android=json_decode($c,true);
  11. $method=$android['method'];
  12. $pdo=conn1();
  13. $data=array("code"=>"-100","info"=>"接口开始");
  14. //$pdo=conn1();
  15. //$pdo=conn1();
  16. switch ($method){
  17. case 'sendScannerLinked':
  18. $driverId=$android['data']['driverId'];
  19. $driverName=$android['data']['driverName'];
  20. $dev=$android['data']['dev'];
  21. $isLinkedScanner=$android['data']['isLinkedScanner'];
  22. $sql = " INSERT INTO driver_scanner_linked(DRIVER_ID,DRIVER_NAME,DEV,IS_LINKED_SCANNER,CREATE_TIME) values('{$driverId}','{$driverName}','{$dev}','{$isLinkedScanner}',now())";
  23. if(is_object($pdo)){
  24. $result=$pdo->query($sql);
  25. if( $result == false ) {
  26. $data['code']='-1';
  27. $data['info']='插入失败';
  28. break;
  29. }
  30. $json=$result->fetchAll(PDO::FETCH_ASSOC);
  31. $result->closeCursor();
  32. if( $json != false ){
  33. $data['code'] = '0';
  34. $data['info'] = '插入相关信息成功';
  35. $data['data'] = $json[0];
  36. }else{
  37. $data['code'] = '0';
  38. $data['info'] = '';
  39. $data['data'] = "";
  40. }
  41. }
  42. break;
  43. //根据线路id获取所有的订单信息
  44. case 'getAllOrderInformation':
  45. $runId=$android['data']['runId'];
  46. $sql="CALL DRIVER_GET_ORDER_INFO('".$runId."')";
  47. if(is_object($pdo)){
  48. $result=$pdo->query($sql);
  49. $json=$result->fetchAll(PDO::FETCH_ASSOC);
  50. $result->closeCursor();
  51. if($json&&$json[0]&&$json[0]['orderId']){
  52. $data['code']='0';
  53. $data['info']='获取乘客信息成功';
  54. $data['data']=$json;
  55. }else{
  56. $data['code']='0';
  57. $data['info']='';
  58. $data['data']=array();
  59. }
  60. }
  61. break;
  62. //上传当前app的版本号
  63. case 'updateAppStatus':
  64. $driverResId=$android['data']['driverResId'];
  65. $versionCode=$android['data']['versionCode'];
  66. $sql="CALL DRIVER_UPDATE_APP_STATUS_CHANGE('".$driverResId."','".$versionCode."')";
  67. writeLog("updateAppStatus:".$sql);
  68. if(is_object($pdo)){
  69. $result=$pdo->query($sql);
  70. $json=$result->fetchAll(PDO::FETCH_ASSOC);
  71. $result->closeCursor();
  72. }
  73. $data['code'] = '0';
  74. $data['info'] = '';
  75. $data['data'] = "";
  76. break;
  77. //获取当前司机的app更新状态,0是没有更新,1是需要更新
  78. case 'getAppUpdateStatus':
  79. $driverResId=$android['data']['driverResId'];
  80. $sql="CALL DRIVER_UPDATE_APP_STATUS('".$driverResId."')";
  81. if(is_object($pdo)){
  82. $result=$pdo->query($sql);
  83. $json=$result->fetchAll(PDO::FETCH_ASSOC);
  84. $result->closeCursor();
  85. if($json){
  86. if(count($json)>0){
  87. $data['code'] = '0';
  88. $data['info'] = '获取司机app更新状态成功';
  89. $json[0]["driverResId"] = $json[0]["driverResId"];
  90. $json[0]["driverBusType"] = $json[0]["driverBusType"];
  91. $json[0]["appUpdateStatus"] = $json[0]["appUpdateStatus"];
  92. $json[0]["driverUpdateTime"] = $json[0]["driverUpdateTime"];
  93. $json[0]["publishUpdateTime"] = $json[0]["publishUpdateTime"];
  94. $json[0]["downloadAddress"] = $json[0]["downloadAddress"];
  95. $json[0]["versionCode"] = $json[0]["versionCode"];
  96. $data['data'] = $json[0];
  97. }
  98. }else{
  99. $data['code']='1';
  100. $data['info']='更新状态获取失败code:1';
  101. }
  102. }
  103. break;
  104. //如果该任务以后还有139,那么将该任务置为141
  105. case 'autoUpdateStatus':
  106. $driver_res_id=$android['data']['driverResId'];
  107. $runId=$android['data']['runId'];
  108. $sql="CALL DRIVER_AUTO_UPDATE_STATUS('".$driver_res_id."','".$runId."')";
  109. if(is_object($pdo)){
  110. $result=$pdo->query($sql);
  111. $json=$result->fetchAll(PDO::FETCH_ASSOC);
  112. $result->closeCursor();
  113. }
  114. $data['code'] = '0';
  115. $data['info'] = '';
  116. $data['data'] = "";
  117. break;
  118. //点击了结束行程按钮,将行程置为141
  119. case 'updateBusStatus':
  120. $run_id = $android['data']['runId'];
  121. $bus_order_id = $android['data']['busOrderId'];
  122. $status = $android['data']['status'];
  123. $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}'";
  124. if(is_object($pdo)){
  125. $result=$pdo->query($sql);
  126. }
  127. $data['code'] = '0';
  128. $data['info'] = '';
  129. $data['data'] = "";
  130. break;
  131. //更改乘客上车状态
  132. case 'updateCheckStatus':
  133. $run_id = $android['data']['runId'];
  134. $order_id = $android['data']['orderId'];
  135. $status = $android['data']['status'];
  136. $bus_no = $android['data']['busNo'];
  137. $sql =
  138. "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)";
  139. if(is_object($pdo)){
  140. $result=$pdo->query($sql);
  141. }
  142. $data['code'] = '0';
  143. $data['info'] = '成功更改';
  144. $data['data'] = "";
  145. break;
  146. //通过车牌号获取蓝牙地址
  147. case 'getAddressByCar':
  148. $bus_res_id = $android['data']['busResId'];//实际上是车牌号码
  149. $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 ";
  150. if(is_object($pdo)){
  151. $result=$pdo->query($sql);
  152. if( $result == false ) {
  153. $data['code']='-1';
  154. $data['info']='查询失败';
  155. $data['blueToothAddress']="";
  156. break;
  157. }
  158. $json=$result->fetchAll(PDO::FETCH_ASSOC);
  159. $result->closeCursor();
  160. if( $json != false ){
  161. $data['code'] = '0';
  162. $data['info'] = '获取扫码设备信息成功';
  163. $json[0]["blueToothAddress"] = $json[0]["PROPERTY"];
  164. $data['data'] = $json[0];
  165. }else{
  166. $data['code'] = '0';
  167. $data['info'] = '';
  168. $data['data'] = "";
  169. }
  170. }
  171. break;
  172. case 'getAllBlueToothAddress':
  173. $sql = " SELECT machine_code FROM scan_machine_code WHERE cancel_flag = 0 ";
  174. if(is_object($pdo)){
  175. $result=$pdo->query($sql);
  176. if( $result == false ) {
  177. $data['code']='-1';
  178. $data['info']='查询失败';
  179. $data['data']="";
  180. break;
  181. }
  182. $json=$result->fetchAll(PDO::FETCH_ASSOC);
  183. $result->closeCursor();
  184. if( $json != false ){
  185. $return_data = array();
  186. foreach( $json as $json_info ) {
  187. $return_data[] = $json_info["machine_code"];
  188. }
  189. $data['code'] = '0';
  190. $data['info'] = '获取扫码设备信息成功';
  191. $data['data'] = $return_data;
  192. }else{
  193. $data['code'] = '0';
  194. $data['info'] = '';
  195. $data['data'] = array();
  196. }
  197. }
  198. break;
  199. case 'getCode':
  200. $userId=isset($android['data']['userId'])?$android['data']['userId']:'';
  201. $phone=isset($android['data']['phone'])?$android['data']['phone']:'';
  202. $div=isset($android['data']['div'])?$android['data']['div']:'';
  203. $sql="CALL DRIVER_GET_CODE('".$userId."','".$phone."','".$div."')";
  204. if(is_object($pdo)){
  205. $result=$pdo->query($sql);
  206. $json=$result->fetchAll(PDO::FETCH_ASSOC);
  207. $result->closeCursor();
  208. if($json){
  209. if(count($json)>0){
  210. if($json[0]['code'] == '0'){
  211. $data['code']=$json[0]['code'];
  212. $data['info']=$json[0]['info'];
  213. $data['data']=$json[0];
  214. //$Phones='15670428930;';
  215. $Phones=$phone;
  216. //$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=';
  217. $url='http://hprpt2.eucp.b2m.cn:8080/sdkproxy/sendsms.action?cdkey=8SDK-EMY-6699-RISUM&password=175348&phone='.$phone.'&message=【蜘蛛行】'.$data['data']['codeinfo'];
  218. $html=httpRequest($url);
  219. }else{
  220. $data['code']=$json[0]['code'];
  221. if($json[0]['info'] == 181){
  222. $data['info']='该手机号码不存在';
  223. }else{
  224. $data['info']=$json[0]['info'];
  225. }
  226. }
  227. }
  228. }else{
  229. $data['code']='1';
  230. $data['info']='获取验证码失败';
  231. }
  232. }
  233. break;
  234. case 'login':
  235. $userId=isset($android['data']['userId'])?$android['data']['userId']:'';
  236. $phone=isset($android['data']['phone'])?$android['data']['phone']:'';
  237. $dev=isset($android['data']['dev'])?$android['data']['dev']:'';
  238. $code=isset($android['data']['code'])?$android['data']['code']:'';
  239. $sql="CALL DRIVER_LOGIN('".$userId."','".$phone."','".$dev."','".$code."')";
  240. if(is_object($pdo)){
  241. $result=$pdo->query($sql);
  242. $json=$result->fetchAll(PDO::FETCH_ASSOC);
  243. $result->closeCursor();
  244. if($json){
  245. if(count($json)>0){
  246. if($json[0]['code'] == '0'){
  247. $data['code']=$json[0]['code'];
  248. $data['info']=$json[0]['info'];
  249. $data['data']=$json[0];
  250. $a=$json[0]['bus_type'];
  251. file_put_contents("log.txt", $a . " 操作时间:" . date("Y-m-d h:i:s", time()) . PHP_EOL, FILE_APPEND);
  252. }else{
  253. $data['code']=$json[0]['code'];
  254. if($json[0]['info'] == 182){
  255. $data['info']='登录失败';
  256. }else{
  257. $data['info']=$json[0]['info'];
  258. }
  259. }
  260. }
  261. }else{
  262. $data['code']='1';
  263. $data['info']='登录失败';
  264. }
  265. }
  266. break;
  267. case 'logout':
  268. $userId=isset($android['data']['userId'])?$android['data']['userId']:'';
  269. $phone=isset($android['data']['phone'])?$android['data']['phone']:'';
  270. $dev=isset($android['data']['dev'])?$android['data']['dev']:'';
  271. $sql="CALL DRIVER_LOGOUT('".$userId."','".$phone."','".$dev."')";
  272. if(is_object($pdo)){
  273. $result=$pdo->query($sql);
  274. $json=$result->fetchAll(PDO::FETCH_ASSOC);
  275. $result->closeCursor();
  276. if($json){
  277. if(count($json)>0){
  278. if($json[0]['code'] == '0'){
  279. $data['code']=$json[0]['code'];
  280. $data['info']=$json[0]['info'];
  281. }else{
  282. $data['code']=$json[0]['code'];
  283. if($json[0]['info'] == 183){
  284. $data['info']='登出失败';
  285. }else{
  286. $data['info']=$json[0]['info'];
  287. }
  288. }
  289. }
  290. }else{
  291. $data['code']='1';
  292. $data['info']='登出失败';
  293. }
  294. }
  295. break;
  296. case 'pastLine':
  297. $userId=isset($android['data']['userId'])?$android['data']['userId']:'';
  298. $currPage=isset($android['data']['currpage'])?$android['data']['currpage']:'1';
  299. $pageSize=isset($android['data']['pageSize'])?$android['data']['pageSize']:'20';
  300. $resId=isset($android['data']['resId'])?$android['data']['resId']:'';
  301. $sql="CALL DRIVER_PAST_LINE('".$userId."','".$currPage."','".$pageSize."','".$resId."')";
  302. writeLog("DRIVER_PAST_LINE::::".$sql);
  303. if(is_object($pdo)){
  304. $result=$pdo->query($sql);
  305. $j = 1;
  306. if($result){
  307. $data['code']='0';
  308. $data['info']='';
  309. do{
  310. $rowset = $result->fetchAll(PDO::FETCH_ASSOC);
  311. if($j==1){
  312. $data['currpage']=$rowset[0]['currpage'];
  313. $data['totalPage']=$rowset[0]['total_page'];
  314. $data['total']=$rowset[0]['total'];
  315. $data['pageSize']=$rowset[0]['page_size'];
  316. }else if ($j==2){
  317. $json=$rowset;
  318. $lineList=array();
  319. $i=0;
  320. $k=0;
  321. $runId='';
  322. $stationList=array();
  323. foreach ($json as $js){
  324. if($runId==''){
  325. $runId=$js['runId'];
  326. $lineList[$i]['runId']=$js['runId'];
  327. $lineList[$i]['plate']=$js['plate'];
  328. $lineList[$i]['runDate']=$js['runDate'];
  329. $lineList[$i]['runTime']=$js['runTime'];
  330. $lineList[$i]['seatCount']=$js['seatCount'];
  331. $lineList[$i]['saledCount']=$js['saledCount'];
  332. $lineList[$i]['line']=$js['line'];
  333. $stationList[$k]['areaName']=$js['areaName'];
  334. $stationList[$k]['startTime']=$js['startTime'];
  335. $stationList[$k]['orderID']=$js['orderID'];
  336. $lineList[$i]['stationList']=$stationList;
  337. }else{
  338. if($runId==$js['runId']){
  339. $runId=$js['runId'];
  340. $k++;
  341. $stationList[$k]['areaName']=$js['areaName'];
  342. $stationList[$k]['startTime']=$js['startTime'];
  343. $stationList[$k]['orderID']=$js['orderID'];
  344. $lineList[$i]['stationList']=$stationList;
  345. }else{
  346. $runId=$js['runId'];
  347. $i++;
  348. $k=0;
  349. $stationList=array();
  350. $runId=$js['runId'];
  351. $lineList[$i]['runId']=$js['runId'];
  352. $lineList[$i]['plate']=$js['plate'];
  353. $lineList[$i]['runDate']=$js['runDate'];
  354. $lineList[$i]['runTime']=$js['runTime'];
  355. $lineList[$i]['seatCount']=$js['seatCount'];
  356. $lineList[$i]['saledCount']=$js['saledCount'];
  357. $lineList[$i]['line']=$js['line'];
  358. $stationList[$k]['areaName']=$js['areaName'];
  359. $stationList[$k]['startTime']=$js['startTime'];
  360. $stationList[$k]['orderID']=$js['orderID'];
  361. $lineList[$i]['stationList']=$stationList;
  362. }
  363. }
  364. }
  365. $i=0;
  366. $k=0;
  367. $data['data']=$lineList;
  368. }else{
  369. }
  370. $j++;
  371. }while ($result->nextRowset());
  372. $result->closeCursor();
  373. }else{
  374. $data['code']='0';
  375. $data['info']='暂无历史线路';
  376. $data['data']=array();
  377. }
  378. }else{
  379. $data['code']='1';
  380. $data['info']='获取历史线路失败';
  381. }
  382. break;
  383. case 'futureLine':
  384. $userId=isset($android['data']['userId'])?$android['data']['userId']:'';
  385. $currPage=isset($android['data']['currpage'])?$android['data']['currpage']:'1';
  386. $pageSize=isset($android['data']['pageSize'])?$android['data']['pageSize']:'20';
  387. $resId=isset($android['data']['resId'])?$android['data']['resId']:'';
  388. $sql="CALL DRIVER_FUTURE_LINE('".$userId."','".$currPage."','".$pageSize."','".$resId."')";
  389. if(is_object($pdo)){
  390. $result=$pdo->query($sql);
  391. $j = 1;
  392. if($result){
  393. $data['code']='0';
  394. $data['info']='';
  395. do{
  396. $rowset = $result->fetchAll(PDO::FETCH_ASSOC);
  397. if($j==1){
  398. $data['currpage']=$rowset[0]['currpage'];
  399. $data['totalPage']=$rowset[0]['total_page'];
  400. $data['total']=$rowset[0]['total'];
  401. $data['pageSize']=$rowset[0]['page_size'];
  402. }else if ($j==2){
  403. $json=$rowset;
  404. $lineList=array();
  405. $i=0;
  406. $k=0;
  407. $runId='';
  408. $stationList=array();
  409. foreach ($json as $js){
  410. if($runId==''){
  411. $runId=$js['runId'];
  412. $lineList[$i]['runId']=$js['runId'];
  413. $lineList[$i]['plate']=$js['plate'];
  414. $lineList[$i]['runDate']=$js['runDate'];
  415. $lineList[$i]['runTime']=$js['runTime'];
  416. $lineList[$i]['seatCount']=$js['seatCount'];
  417. $lineList[$i]['saledCount']=$js['saledCount'];
  418. $lineList[$i]['line']=$js['line'];
  419. $stationList[$k]['areaName']=$js['areaName'];
  420. $stationList[$k]['startTime']=$js['startTime'];
  421. $stationList[$k]['orderID']=$js['orderID'];
  422. $lineList[$i]['stationList']=$stationList;
  423. }else{
  424. if($runId==$js['runId']){
  425. $runId=$js['runId'];
  426. $k++;
  427. $stationList[$k]['areaName']=$js['areaName'];
  428. $stationList[$k]['startTime']=$js['startTime'];
  429. $stationList[$k]['orderID']=$js['orderID'];
  430. $lineList[$i]['stationList']=$stationList;
  431. }else{
  432. $runId=$js['runId'];
  433. $i++;
  434. $k=0;
  435. $stationList=array();
  436. $runId=$js['runId'];
  437. $lineList[$i]['runId']=$js['runId'];
  438. $lineList[$i]['plate']=$js['plate'];
  439. $lineList[$i]['runDate']=$js['runDate'];
  440. $lineList[$i]['runTime']=$js['runTime'];
  441. $lineList[$i]['seatCount']=$js['seatCount'];
  442. $lineList[$i]['saledCount']=$js['saledCount'];
  443. $lineList[$i]['line']=$js['line'];
  444. $stationList[$k]['areaName']=$js['areaName'];
  445. $stationList[$k]['startTime']=$js['startTime'];
  446. $stationList[$k]['orderID']=$js['orderID'];
  447. $lineList[$i]['stationList']=$stationList;
  448. }
  449. }
  450. }
  451. $i=0;
  452. $k=0;
  453. $data['data']=$lineList;
  454. }else{
  455. }
  456. $j++;
  457. }while ($result->nextRowset());
  458. $result->closeCursor();
  459. }else{
  460. $data['code']='0';
  461. $data['info']='暂无未来线路';
  462. $data['data']=array();
  463. }
  464. }else{
  465. $data['code']='1';
  466. $data['info']='获取未来线路';
  467. }
  468. break;
  469. case 'getUserStationInfo':
  470. $userId=isset($android['data']['userId'])?$android['data']['userId']:'';
  471. $runId=isset($android['data']['runId'])?$android['data']['runId']:'';
  472. $busOrderId=isset($android['data']['busOrderId'])?$android['data']['busOrderId']:'';
  473. $stationResId=isset($android['data']['stationResId'])?$android['data']['stationResId']:'';
  474. $sql="CALL DRIVER_GET_STATION_USER_INFO('".$userId."','".$runId."','".$busOrderId."','".$stationResId."')";
  475. if(is_object($pdo)){
  476. $result=$pdo->query($sql);
  477. $json=$result->fetchAll(PDO::FETCH_ASSOC);
  478. $result->closeCursor();
  479. if($json&&$json[0]&&$json[0]['userName']){
  480. $data['code']='0';
  481. $data['info']='获取站点用户信息成功';
  482. $data['data']=$json;
  483. }else{
  484. $data['code']='0';
  485. $data['info']='';
  486. $data['data']=array();
  487. }
  488. }
  489. break;
  490. case 'getDriverinfo':
  491. $userId=isset($android['data']['userId'])?$android['data']['userId']:'';
  492. $resId=isset($android['data']['resId'])?$android['data']['resId']:'';
  493. $sql="CALL DRIVER_GET_INFO('".$userId."','".$resId."')";
  494. if(is_object($pdo)){
  495. $result=$pdo->query($sql);
  496. $json=$result->fetchAll(PDO::FETCH_ASSOC);
  497. $result->closeCursor();
  498. if($json){
  499. $data['code']='0';
  500. $data['info']='获取司机信息成功';
  501. $data['data']=$json[0];
  502. }else{
  503. $data['code']='1';
  504. $data['info']='获取司机信息失败';
  505. }
  506. }
  507. break;
  508. case 'checkTicket':
  509. $userId=isset($android['data']['userId'])?$android['data']['userId']:'';
  510. $runId=isset($android['data']['runId'])?$android['data']['runId']:'';
  511. $busOrderId=isset($android['data']['busOrderId'])?$android['data']['busOrderId']:'';
  512. $orderId=isset($android['data']['orderId'])?$android['data']['orderId']:'';
  513. $stationId=isset($android['data']['stationId'])?$android['data']['stationId']:'';
  514. $checkTicketType=isset($android['data']['checkTicketType'])?$android['data']['checkTicketType']:'';
  515. $sql="CALL DRIVER_CHECK_TICKET_ORDER('".$userId."','".$runId."','".$busOrderId."','".$orderId."','".$stationId."','".$checkTicketType."')";
  516. writeLog($sql);
  517. if(is_object($pdo)){
  518. $result=$pdo->query($sql);
  519. if( $result != false ) {
  520. $json = $result->fetchAll(PDO::FETCH_ASSOC);
  521. $result->closeCursor();
  522. } else {
  523. $json = false;
  524. }
  525. if($json){
  526. if($json[0]['num']>0){
  527. $data['code']='0';
  528. $data['info']='';
  529. $data['data']=$json[0];
  530. }else{
  531. $data['code']='1';
  532. $data['info']='检票失败';
  533. }
  534. }else{
  535. $data['code']='1';
  536. $data['info']='检票失败';
  537. }
  538. }
  539. break;
  540. case 'runningLine':
  541. $userId=isset($android['data']['userId'])?$android['data']['userId']:'';
  542. $resId=isset($android['data']['resId'])?$android['data']['resId']:'';
  543. $sql="CALL DRIVER_RUNNING_LINE('".$userId."','".$resId."')";
  544. if(is_object($pdo)){
  545. $result=$pdo->query($sql);
  546. $json=$result->fetchAll(PDO::FETCH_ASSOC);
  547. $result->closeCursor();
  548. if($json){
  549. $lineList=array();
  550. $i=0;
  551. $k=0;
  552. $runId='';
  553. $stationList=array();
  554. foreach ($json as $js){
  555. if($runId==''){
  556. $runId=$js['runId'];
  557. $d['runId']=$js['runId'];
  558. $d['number']=$js['number'];
  559. $d['plate']=$js['plate'];
  560. $d['runDate']=$js['runDate'];
  561. $d['runTime']=$js['runTime'];
  562. $d['runStatus']=$js['runStatus'];
  563. $d['seatCount']=$js['seatCount'];
  564. $d['saledCount']=$js['saledCount'];
  565. $d['currentOrderId']=$js['currentOrderId'];
  566. $d['line']=$js['line'];
  567. $stationList[$k]['areaName']=$js['areaName'];
  568. $stationList[$k]['startTime']=$js['startTime'];
  569. $stationList[$k]['orderID']=$js['orderID'];
  570. $stationList[$k]['stationName']=$js['stationName'];
  571. $stationList[$k]['stationResId']=$js['stationResId'];
  572. $stationList[$k]['inOutType']=$js['inOutType'];
  573. $stationList[$k]['longitude']=$js['longitude'];
  574. $stationList[$k]['latitude']=$js['latitude'];
  575. $d['stationList']=$stationList;
  576. }else{
  577. if($runId==$js['runId']){
  578. $runId=$js['runId'];
  579. $k++;
  580. $stationList[$k]['areaName']=$js['areaName'];
  581. $stationList[$k]['startTime']=$js['startTime'];
  582. $stationList[$k]['orderID']=$js['orderID'];
  583. $stationList[$k]['stationName']=$js['stationName'];
  584. $stationList[$k]['stationResId']=$js['stationResId'];
  585. $stationList[$k]['inOutType']=$js['inOutType'];
  586. $stationList[$k]['longitude']=$js['longitude'];
  587. $stationList[$k]['latitude']=$js['latitude'];
  588. $d['stationList']=$stationList;
  589. }else{
  590. $runId=$js['runId'];
  591. $i++;
  592. $k=0;
  593. $stationList=array();
  594. $runId=$js['runId'];
  595. $d['runId']=$js['runId'];
  596. $d['number']=$js['number'];
  597. $d['plate']=$js['plate'];
  598. $d['runDate']=$js['runDate'];
  599. $d['runTime']=$js['runTime'];
  600. $d['runStatus']=$js['runStatus'];
  601. $d['seatCount']=$js['seatCount'];
  602. $d['saledCount']=$js['saledCount'];
  603. $d['currentOrderId']=$js['currentOrderId'];
  604. $d['line']=$js['line'];
  605. $stationList[$k]['areaName']=$js['areaName'];
  606. $stationList[$k]['startTime']=$js['startTime'];
  607. $stationList[$k]['orderID']=$js['orderID'];
  608. $stationList[$k]['stationName']=$js['stationName'];
  609. $stationList[$k]['stationResId']=$js['stationResId'];
  610. $stationList[$k]['inOutType']=$js['inOutType'];
  611. $stationList[$k]['longitude']=$js['longitude'];
  612. $stationList[$k]['latitude']=$js['latitude'];
  613. $d['stationList']=$stationList;
  614. }
  615. }
  616. }
  617. $i=0;
  618. $k=0;
  619. $data['code']='0';
  620. $data['info']='';
  621. $data['data']=$d;
  622. //$data['lineList']=$lineList;
  623. }else{
  624. $data['code']='0';
  625. $data['info']='暂无今日线路';
  626. //$data['data']=array();
  627. }
  628. }else{
  629. $data['code']='1';
  630. $data['info']='获取当前线路失败';
  631. }
  632. break;
  633. case 'futureLineDetail':
  634. $runId=isset($android['data']['runId'])?$android['data']['runId']:'';
  635. $sql="CALL DRIVER_FUTURE_LINE_DETAIL('".$runId."')";
  636. if(is_object($pdo)){
  637. $result=$pdo->query($sql);
  638. $json=$result->fetchAll(PDO::FETCH_ASSOC);
  639. $result->closeCursor();
  640. if($json){
  641. $lineList=array();
  642. $i=0;
  643. $k=0;
  644. $runId='';
  645. $stationList=array();
  646. foreach ($json as $js){
  647. if($runId==''){
  648. $runId=$js['runId'];
  649. $d['runId']=$js['runId'];
  650. $d['number']=$js['number'];
  651. $d['plate']=$js['plate'];
  652. $d['runDate']=$js['runDate'];
  653. $d['runTime']=$js['runTime'];
  654. $d['runStatus']=$js['runStatus'];
  655. $d['seatCount']=$js['seatCount'];
  656. $d['currentOrderId']=$js['currentOrderId'];
  657. $d['line']=$js['line'];
  658. $stationList[$k]['areaName']=$js['areaName'];
  659. $stationList[$k]['startTime']=$js['startTime'];
  660. $stationList[$k]['orderID']=$js['orderID'];
  661. $stationList[$k]['stationName']=$js['stationName'];
  662. $stationList[$k]['stationResId']=$js['stationResId'];
  663. $stationList[$k]['inOutType']=$js['inOutType'];
  664. $stationList[$k]['longitude']=$js['longitude'];
  665. $stationList[$k]['latitude']=$js['latitude'];
  666. $d['stationList']=$stationList;
  667. }else{
  668. if($runId==$js['runId']){
  669. $runId=$js['runId'];
  670. $k++;
  671. $stationList[$k]['areaName']=$js['areaName'];
  672. $stationList[$k]['startTime']=$js['startTime'];
  673. $stationList[$k]['orderID']=$js['orderID'];
  674. $stationList[$k]['stationName']=$js['stationName'];
  675. $stationList[$k]['stationResId']=$js['stationResId'];
  676. $stationList[$k]['inOutType']=$js['inOutType'];
  677. $stationList[$k]['longitude']=$js['longitude'];
  678. $stationList[$k]['latitude']=$js['latitude'];
  679. $d['stationList']=$stationList;
  680. }else{
  681. $runId=$js['runId'];
  682. $i++;
  683. $k=0;
  684. $stationList=array();
  685. $runId=$js['runId'];
  686. $d['runId']=$js['runId'];
  687. $d['number']=$js['number'];
  688. $d['plate']=$js['plate'];
  689. $d['runDate']=$js['runDate'];
  690. $d['runTime']=$js['runTime'];
  691. $d['runStatus']=$js['runStatus'];
  692. $d['seatCount']=$js['seatCount'];
  693. $d['currentOrderId']=$js['currentOrderId'];
  694. $d['line']=$js['line'];
  695. $stationList[$k]['areaName']=$js['areaName'];
  696. $stationList[$k]['startTime']=$js['startTime'];
  697. $stationList[$k]['orderID']=$js['orderID'];
  698. $stationList[$k]['stationName']=$js['stationName'];
  699. $stationList[$k]['stationResId']=$js['stationResId'];
  700. $stationList[$k]['inOutType']=$js['inOutType'];
  701. $stationList[$k]['longitude']=$js['longitude'];
  702. $stationList[$k]['latitude']=$js['latitude'];
  703. $d['stationList']=$stationList;
  704. }
  705. }
  706. }
  707. $i=0;
  708. $k=0;
  709. $data['code']='0';
  710. $data['info']='';
  711. $data['data']=$d;
  712. //$data['lineList']=$lineList;
  713. }else{
  714. $data['code']='0';
  715. $data['info']='暂无今日线路';
  716. //$data['data']=array();
  717. }
  718. }else{
  719. $data['code']='1';
  720. $data['info']='获取当前线路失败';
  721. }
  722. break;
  723. case 'driverStationInfo':
  724. $userId=1;
  725. $runId=isset($android['data']['runId'])?$android['data']['runId']:'';
  726. $busOrderId=isset($android['data']['busOrderId'])?$android['data']['busOrderId']:'';
  727. $resId=isset($android['data']['stationResId'])?$android['data']['stationResId']:'';
  728. $sql="CALL driver_station_info('".$userId."','".$runId."','".$busOrderId."','".$resId."')";
  729. if(is_object($pdo)){
  730. $result=$pdo->query($sql);
  731. $json=$result->fetchAll(PDO::FETCH_ASSOC);
  732. $result->closeCursor();
  733. if($json){
  734. if(count($json)>0){
  735. if($json[0]['code'] == '0'){
  736. $data['code']=$json[0]['code'];
  737. $data['info']=$json[0]['info'];
  738. $data['data']=$json[0];
  739. }else{
  740. $data['code']=$json[0]['code'];
  741. $data['info']='获取站点失败';
  742. }
  743. }
  744. }else{
  745. $data['code']='1';
  746. $data['info']='获取站点失败';
  747. }
  748. }
  749. break;
  750. case 'busPosUp':
  751. $runId=isset($android['data']['runId'])?$android['data']['runId']:'';
  752. $busOrderId=isset($android['data']['busOrderId'])?$android['data']['busOrderId']:'';
  753. $serial=isset($android['data']['serial'])?$android['data']['serial']:'';
  754. $posX=isset($android['data']['posX'])?$android['data']['posX']:'';
  755. $posY=isset($android['data']['posY'])?$android['data']['posY']:'';
  756. $driver=isset($android['data']['driver'])?$android['data']['driver']:'';
  757. $sql="CALL DRIVER_BUS_POS_UP('".$runId."','".$busOrderId."','".$serial."','".$posX."','".$posY."','".$driver."')";
  758. if(is_object($pdo)){
  759. $result=$pdo->query($sql);
  760. $json=$result->fetchAll(PDO::FETCH_ASSOC);
  761. $result->closeCursor();
  762. if(count($json) >0 && $json[0]['count']>0){
  763. $data['code']='0';
  764. $data['info']='上传坐标数据成功';
  765. }else{
  766. $data['code']='1';
  767. $data['info']='上传坐标数据失败';
  768. }
  769. }else{
  770. $data['code']='1';
  771. $data['info']='上传坐标数据失败';
  772. }
  773. break;
  774. case 'cxZd':
  775. $runId=isset($android['data']['runId'])?$android['data']['runId']:'';
  776. $busOrderId=isset($android['data']['busOrderId'])?$android['data']['busOrderId']:'';
  777. $status=isset($android['data']['status'])?$android['data']['status']:0;
  778. $currentOrderId=isset($android['data']['currentOrderId'])?$android['data']['currentOrderId']:0;
  779. $sql="CALL DRIVER_CX_ZD('".$runId."','".$busOrderId."','".$status."','".$currentOrderId."')";
  780. if(is_object($pdo)){
  781. $result=$pdo->query($sql);
  782. $json=$result->fetchAll(PDO::FETCH_ASSOC);
  783. $result->closeCursor();
  784. if(count($json) >0 && $json[0]['res_name']){
  785. $data['code']='0';
  786. $data['info']='更新距离位置状态成功';
  787. }else{
  788. $data['code']='1';
  789. $data['info']='更新距离位置失败';
  790. }
  791. }else{
  792. $data['code']='1';
  793. $data['info']='更新距离位置失败';
  794. }
  795. break;
  796. case 'getCheckInfo':
  797. $runId=isset($android['data']['runId'])?$android['data']['runId']:'';
  798. $busOrderId=isset($android['data']['busOrderId'])?$android['data']['busOrderId']:'';
  799. $stationId=isset($android['data']['stationId'])?$android['data']['stationId']:0;
  800. $sql="CALL DERVER_CK_SEL('".$runId."','".$busOrderId."','".$stationId."')";
  801. if(is_object($pdo)){
  802. $result=$pdo->query($sql);
  803. $json=$result->fetchAll(PDO::FETCH_ASSOC);
  804. $result->closeCursor();
  805. if(count($json) >0){
  806. $data['code']='0';
  807. $data['info']='';
  808. $data['data']=$json[0];
  809. }else{
  810. $data['code']='1';
  811. $data['info']='获取检票状态失败';
  812. }
  813. }else{
  814. $data['code']='1';
  815. $data['info']='获取检票状态失败';
  816. }
  817. break;
  818. case 'getCarCnt':
  819. $runId=isset($android['data']['runId'])?$android['data']['runId']:'';
  820. $busOrderId=isset($android['data']['busOrderId'])?$android['data']['busOrderId']:'';
  821. $stationId=isset($android['data']['stationId'])?$android['data']['stationId']:0;
  822. $sql="CALL DRIVER_CAR_CNT('".$runId."','".$stationId."','".$busOrderId."')";
  823. if(is_object($pdo)){
  824. $result=$pdo->query($sql);
  825. $json=$result->fetchAll(PDO::FETCH_ASSOC);
  826. $result->closeCursor();
  827. if(count($json) >0){
  828. $data['code']='0';
  829. $data['info']='';
  830. $data['data']=$json[0];
  831. }else{
  832. $data['code']='0';
  833. $data['info']='暂无数据';
  834. }
  835. }else{
  836. $data['code']='1';
  837. $data['info']='获取乘客信息失败';
  838. }
  839. break;
  840. case 'updateBusStation':
  841. //173953,1,121.43,31.17
  842. $runId=isset($android['data']['runId'])?$android['data']['runId']:"";
  843. $busOrderId=isset($android['data']['busOrderId'])?$android['data']['busOrderId']:'';
  844. // 经度 Longitude,纬度 latitude
  845. $longitude=$android['data']['longitude'];
  846. $latitude=$android['data']['latitude'];
  847. if($runId=="" || $busOrderId=="" || $longitude=="" || $latitude==""){
  848. $data['code']='-1';
  849. $data['info']='缺少参数';
  850. echo json_encode($data);exit();
  851. }
  852. $sql="CALL DRIVER_UPDATE_BUS_STATION(".$runId.",".$busOrderId.",".$longitude.",".$latitude.")";
  853. writeLog('updateBusStation sql='.$sql);
  854. if(is_object($pdo)){
  855. $result=$pdo->query($sql);
  856. if($result){
  857. $json=$result->fetchAll(PDO::FETCH_ASSOC);
  858. $result->closeCursor();
  859. $data['code']=isset($json[0]['errcode'])?$json[0]['errcode']:"-5";
  860. $data['info']=isset($json[0]['errinfo'])?$json[0]['errinfo']:"未从数据库获得返回值";
  861. echo json_encode($data);exit();
  862. }else{
  863. $data['code']='-2';
  864. $data['info']='数据库错误';
  865. echo json_encode($data);exit();
  866. }
  867. }else{
  868. $data['code']="-3";
  869. $data['info']="连接数据库错误";
  870. echo json_encode($data);exit();
  871. }
  872. break;
  873. case 'getAllStationInformation':
  874. $driver_res_id = $android['data']['driver_res_id'];
  875. $run_date = date('Y-m-d',time());
  876. $run_time = date('H:i',time());
  877. $order_array = array();
  878. $sql = "SELECT
  879. a.run_id,
  880. a.bus_order_id,
  881. a.send_bus_driver_res_id,
  882. a.send_bus_no,
  883. a.send_driver_name,
  884. a.send_driver_mobile,
  885. b.run_date,
  886. b.run_time
  887. FROM
  888. run_bus as a,
  889. run_main as b
  890. WHERE
  891. a.run_id = b.run_id
  892. AND a.cancel_flag = 0
  893. AND a.run_bus_status = 139
  894. AND a.send_status = 143
  895. AND a.send_bus_driver_res_id = " . $driver_res_id . "
  896. and b.run_date >= '" . $run_date . "'
  897. ORDER by
  898. b.run_date asc,
  899. b.run_time asc
  900. LIMIT 1";
  901. $result=$pdo->query($sql);
  902. $driver_info=$result->fetchAll(PDO::FETCH_ASSOC);
  903. if(count($driver_info) == 1){
  904. $driver_info = $driver_info[0];
  905. $run_date = $driver_info['run_date'];
  906. $run_id = $driver_info['run_id'];
  907. $bus_order_id = $driver_info['bus_order_id'];
  908. $bus_no = $driver_info['send_bus_no'];
  909. $driver_name = $driver_info['send_driver_name'];
  910. $driver_mobile = $driver_info['send_driver_mobile'];
  911. $run_time = $driver_info['run_time'];
  912. $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;
  913. $result=$pdo->query($sql);
  914. $area_id=$result->fetchAll(PDO::FETCH_ASSOC);
  915. foreach($area_id as $k => $v){
  916. if($v['type_id'] == 125){
  917. $start_id = $v['property'];
  918. $sql = "select area_name from base_area where id = " . $start_id;
  919. $result=$pdo->query($sql);
  920. $start_area=$result->fetchAll(PDO::FETCH_ASSOC);
  921. $start_area = $start_area[0]['area_name'];
  922. }else{
  923. $end_id = $v['property'];
  924. $sql = "select area_name from base_area where id = " . $end_id;
  925. $result=$pdo->query($sql);
  926. $end_area=$result->fetchAll(PDO::FETCH_ASSOC);
  927. $end_area = $end_area[0]['area_name'];
  928. }
  929. }
  930. $sql = "SELECT
  931. order_main.order_id,
  932. order_main.customer_name,
  933. order_main.customer_mobile,
  934. order_main.order_description,
  935. order_main.prod_start_station_area_name,
  936. order_main.prod_end_station_area_name,
  937. order_check_tickets.check_status
  938. FROM
  939. order_main left join order_check_tickets on order_main.order_id = order_check_tickets.order_id
  940. WHERE
  941. cancel_flag = 0 and (order_status = 146 or order_status = 147)
  942. AND order_main.order_id IN (
  943. SELECT
  944. parent_order_id
  945. FROM
  946. order_main
  947. WHERE
  948. run_id = " . $run_id . "
  949. AND run_bus_order_id = " . $bus_order_id . "
  950. AND cancel_flag = 0
  951. GROUP BY
  952. parent_order_id
  953. )";
  954. $result=$pdo->query($sql);
  955. $order_no=$result->fetchAll(PDO::FETCH_ASSOC);
  956. if(count($order_no) > 0){
  957. foreach($order_no as $k => $v){
  958. $order_array[$v['order_id']] = $v;
  959. $order_id_array[$v['order_id']] = $v['order_id'];
  960. }
  961. $sql = "select id,check_status,order_id from order_check_tickets where order_id in (" . implode(",",$order_id_array) . ")";
  962. $result=$pdo->query($sql);
  963. $order_check=$result->fetchAll(PDO::FETCH_ASSOC);
  964. foreach($order_check as $k => $v){
  965. $order_array[$v['order_id']]['check_id']=$v['id'];
  966. $order_array[$v['order_id']]['check_status'] = $v['check_status'];
  967. }
  968. $order_array = array_values($order_array);
  969. $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;
  970. $result=$pdo->query($sql);
  971. $station_view=$result->fetchAll(PDO::FETCH_ASSOC);
  972. $station_view = $station_view[0];
  973. }else{
  974. $order_array = array();
  975. $station_view = array();
  976. }
  977. $list['run_id'] = $run_id;
  978. $list['run_date'] = $run_date;
  979. $list['run_time'] = $run_time;
  980. $list['bus_no'] = $bus_no;
  981. $list['bus_order_id'] = $bus_order_id;
  982. $list['driver_name'] = $driver_name;
  983. $list['driver_mobile'] = $driver_mobile;
  984. $list['order'] = $order_array;
  985. $list['station_view'] = $station_view;
  986. $list['status_type'] = '0';
  987. $data['code'] = '0';
  988. $data['info'] = '成功';
  989. $data['data'] = $list;
  990. }else{
  991. $sql = "SELECT
  992. a.run_id,
  993. a.bus_order_id,
  994. a.send_bus_driver_res_id,
  995. a.send_bus_no,
  996. a.send_driver_name,
  997. a.send_driver_mobile,
  998. b.run_date,
  999. b.run_time
  1000. FROM
  1001. run_bus as a,
  1002. run_main as b
  1003. WHERE
  1004. a.run_id = b.run_id
  1005. AND a.cancel_flag = 0
  1006. AND a.run_bus_status = 138
  1007. AND a.send_status = 143
  1008. AND a.send_bus_driver_res_id = " . $driver_res_id . "
  1009. and b.run_date >= '" . $run_date . "'
  1010. and b.run_time >= '" . $run_time . "'
  1011. ORDER by
  1012. b.run_date asc,
  1013. b.run_time asc
  1014. LIMIT 1";
  1015. file_put_contents("ttt.txt", $sql . " 操作时间:" . date("Y-m-d h:i:s", time()) . PHP_EOL, FILE_APPEND);
  1016. $result=$pdo->query($sql);
  1017. $driver_info=$result->fetchAll(PDO::FETCH_ASSOC);
  1018. if(count($driver_info) == 1){
  1019. $driver_info = $driver_info[0];
  1020. $run_date = $driver_info['run_date'];
  1021. $run_id = $driver_info['run_id'];
  1022. $bus_order_id = $driver_info['bus_order_id'];
  1023. $bus_no = $driver_info['send_bus_no'];
  1024. $driver_name = $driver_info['send_driver_name'];
  1025. $driver_mobile = $driver_info['send_driver_mobile'];
  1026. $run_time = $driver_info['run_time'];
  1027. $sql = "SELECT
  1028. order_id,
  1029. customer_name,
  1030. customer_mobile,
  1031. order_description,
  1032. prod_start_station_area_name,
  1033. prod_end_station_area_name
  1034. FROM
  1035. order_main
  1036. WHERE
  1037. cancel_flag = 0 and (order_status = 146 or order_status = 147)
  1038. AND order_id IN (
  1039. SELECT
  1040. parent_order_id
  1041. FROM
  1042. order_main
  1043. WHERE
  1044. run_id = " . $run_id . "
  1045. AND run_bus_order_id = " . $bus_order_id . "
  1046. AND cancel_flag = 0
  1047. GROUP BY
  1048. parent_order_id
  1049. )";
  1050. $result=$pdo->query($sql);
  1051. $order_no=$result->fetchAll(PDO::FETCH_ASSOC);
  1052. $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;
  1053. $result=$pdo->query($sql);
  1054. $area_id=$result->fetchAll(PDO::FETCH_ASSOC);
  1055. foreach($area_id as $k => $v){
  1056. if($v['type_id'] == 125){
  1057. $start_id = $v['property'];
  1058. $sql = "select area_name from base_area where id = " . $start_id;
  1059. $result=$pdo->query($sql);
  1060. $start_area=$result->fetchAll(PDO::FETCH_ASSOC);
  1061. $start_area = $start_area[0]['area_name'];
  1062. }else{
  1063. $end_id = $v['property'];
  1064. $sql = "select area_name from base_area where id = " . $end_id;
  1065. $result=$pdo->query($sql);
  1066. $end_area=$result->fetchAll(PDO::FETCH_ASSOC);
  1067. $end_area = $end_area[0]['area_name'];
  1068. }
  1069. }
  1070. if(count($order_no) > 0){
  1071. foreach($order_no as $k => $v){
  1072. $order_array[$v['order_id']] = $v;
  1073. $order_id_array[$v['order_id']] = $v['order_id'];
  1074. }
  1075. $sql = "select id,check_status,order_id from order_check_tickets where order_id in (" . implode(",",$order_id_array) . ")";
  1076. $result=$pdo->query($sql);
  1077. $order_check=$result->fetchAll(PDO::FETCH_ASSOC);
  1078. foreach($order_check as $k => $v){
  1079. $order_array[$v['order_id']]['check_id']=$v['id'];
  1080. $order_array[$v['order_id']]['check_status'] = $v['check_status'];
  1081. }
  1082. $order_array = array_values($order_array);
  1083. $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;
  1084. $result=$pdo->query($sql);
  1085. $station_view=$result->fetchAll(PDO::FETCH_ASSOC);
  1086. $station_view = $station_view[0];
  1087. }else{
  1088. $order_array = array();
  1089. $station_view = array();
  1090. }
  1091. $list['run_id'] = $run_id;
  1092. $list['run_date'] = $run_date;
  1093. $list['run_time'] = $run_time;
  1094. $list['start_area'] = $start_area;
  1095. $list['end_area'] = $end_area;
  1096. $list['bus_no'] = $bus_no;
  1097. $list['bus_order_id'] = $bus_order_id;
  1098. $list['driver_name'] = $driver_name;
  1099. $list['driver_mobile'] = $driver_mobile;
  1100. $list['order'] = $order_array;
  1101. $list['station_view'] = $station_view;
  1102. $list['status_type'] = '1';
  1103. $data['code'] = '0';
  1104. $data['info'] = '成功';
  1105. $data['data'] = $list;
  1106. }else{
  1107. $data['code'] = '-1';
  1108. $data['info'] = '没有调度好的行程';
  1109. $data['data'] = array();
  1110. }
  1111. }
  1112. break;
  1113. default:
  1114. break;
  1115. }
  1116. if(is_array($data)){
  1117. echo json_encode($data);
  1118. }
  1119. exit;