Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 
 
 
 

122 rader
4.2 KiB

  1. <?php
  2. /**
  3. *
  4. * ============================================================================
  5. * * 版权所有 蜘蛛出行 * *
  6. * 网站地址: http://www.zhizhuchuxing.com
  7. * ----------------------------------------------------------------------------
  8. * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和
  9. * 使用;不允许对程序代码以任何形式任何目的的再发布。
  10. * ============================================================================
  11. * Author By: Redstop
  12. * PhpStorm TopController.php
  13. * Create By 2017/5/15 10:03 $
  14. */
  15. namespace backend\modules\api\controllers;
  16. use yii\web\Controller;
  17. use backend\modules\api\logic\GetGpsData;
  18. use Yii;
  19. class GpsController extends Controller
  20. {
  21. public $enableCsrfValidation = false;
  22. /**
  23. * Function Description:入口文件
  24. * Function Name: actionIndex
  25. *
  26. * @return bool
  27. *
  28. * @author Redstop
  29. */
  30. public function actionIndex()
  31. {
  32. return 'hello me';
  33. }
  34. /**
  35. * Function Description:根据账号名查询相关信息
  36. * Function Name: actionIndex
  37. *
  38. * @return bool
  39. *
  40. * @author Redstop
  41. */
  42. public function actionGetBusGps()
  43. {
  44. $request = Yii::$app->request;
  45. $user_name = $request->post("user_name");
  46. $user_psd = $request->post("user_psd");
  47. $bus_no = $request->post("bus_no");
  48. if( $user_name == false || $user_psd == false || $bus_no == false || strlen($user_name) <= 0 || strlen($user_psd) <= 0 || strlen($bus_no) <= 0 ) {
  49. $return_array = array("code" => 401, "error_message" => "缺少必要发送参数");
  50. return json_encode($return_array);
  51. }
  52. $check_result = $this->checkUserNameAndPassword( $user_name, $user_psd );
  53. if( $check_result == false ) {
  54. $return_array = array("code" => 400, "error_message" => "用户名密码错误");
  55. return json_encode($return_array);
  56. }
  57. $real_bus_no = urldecode($bus_no);
  58. $objGps = new GetGpsData();
  59. $bus_gps_info = $objGps->getBusGpsLastInfo($real_bus_no);
  60. if( false == $bus_gps_info ) {
  61. $return_array = array("code" => 201, "error_message" => "", "gps_data" => array());
  62. return json_encode($return_array);
  63. }
  64. $return_array = array("code" => 201, "error_message" => "");
  65. $gps_data_array = array();
  66. foreach( $bus_gps_info as $bus_gps_tmp ) {
  67. $insert_array = array();
  68. $insert_array["bus_no"] = $bus_gps_tmp["bus_no"];
  69. $insert_array["latitude"] = $bus_gps_tmp["latitude"];
  70. $insert_array["longitude"] = $bus_gps_tmp["longitude"];
  71. $insert_array["speed"] = $bus_gps_tmp["gpsSpeed"] > 0 ? $bus_gps_tmp["gpsSpeed"] : $bus_gps_tmp["speed"];
  72. $insert_array["direction"] = $bus_gps_tmp["direction"];
  73. $insert_array["update_time"] = $bus_gps_tmp["update_time"];
  74. $gps_data_array[$bus_gps_tmp["bus_no"]] = $insert_array;
  75. }
  76. $return_array["gps_data"] = $gps_data_array;
  77. return json_encode($return_array);
  78. }
  79. /**
  80. * Function Description:账号的check(加密规则)
  81. * Function Name: actionIndex
  82. *
  83. * @return bool
  84. *
  85. * @author Redstop
  86. */
  87. public function checkUserNameAndPassword( $user_name, $user_psd )
  88. {
  89. $corrent_pwd = $this->getPwdFromUser($user_name);
  90. return $corrent_pwd == $user_psd ? true : false;
  91. }
  92. /**
  93. * Function Description:检查验证号码
  94. * Function Name: actionIndex
  95. *
  96. * @return bool
  97. *
  98. * @author Redstop
  99. */
  100. public function getPwdFromUser( $user_name )
  101. {
  102. $user_password = strtolower(MD5("zz|".$user_name."|cx"));
  103. return $user_password;
  104. }
  105. //获取新GPS的实时位置的尝试
  106. public function actionGetNewGpsData() {
  107. $soap_service = \Yii::$app->soapGps;
  108. $request = Yii::$app->request;
  109. $carLPN = $request->post("carLPN");
  110. $re = $soap_service->LoadCarsRealInfo(['pool_CarLPN_DateTime' => $carLPN , "lastQueryTime" => date("Y-m-d H:i:s"), "serviceIP" => "61.129.251.7", "servicePort" => '8873']);
  111. return json_encode($re);
  112. }
  113. }