|
- <?php
- /**
- *
- * ============================================================================
- * * 版权所有 蜘蛛出行 * *
- * 网站地址: http://www.zhizhuchuxing.com
- * ----------------------------------------------------------------------------
- * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和
- * 使用;不允许对程序代码以任何形式任何目的的再发布。
- * ============================================================================
- * Author By: Redstop
- * PhpStorm TopController.php
- * Create By 2017/5/15 10:03 $
- */
-
- namespace backend\modules\api\controllers;
- use yii\web\Controller;
- use backend\modules\api\logic\GetGpsData;
- use Yii;
-
- class GpsController extends Controller
- {
- public $enableCsrfValidation = false;
- /**
- * Function Description:入口文件
- * Function Name: actionIndex
- *
- * @return bool
- *
- * @author Redstop
- */
- public function actionIndex()
- {
- return 'hello me';
- }
- /**
- * Function Description:根据账号名查询相关信息
- * Function Name: actionIndex
- *
- * @return bool
- *
- * @author Redstop
- */
- public function actionGetBusGps()
- {
- $request = Yii::$app->request;
- $user_name = $request->post("user_name");
- $user_psd = $request->post("user_psd");
- $bus_no = $request->post("bus_no");
-
- if( $user_name == false || $user_psd == false || $bus_no == false || strlen($user_name) <= 0 || strlen($user_psd) <= 0 || strlen($bus_no) <= 0 ) {
- $return_array = array("code" => 401, "error_message" => "缺少必要发送参数");
- return json_encode($return_array);
- }
- $check_result = $this->checkUserNameAndPassword( $user_name, $user_psd );
- if( $check_result == false ) {
- $return_array = array("code" => 400, "error_message" => "用户名密码错误");
- return json_encode($return_array);
- }
- $real_bus_no = urldecode($bus_no);
- $objGps = new GetGpsData();
- $bus_gps_info = $objGps->getBusGpsLastInfo($real_bus_no);
- if( false == $bus_gps_info ) {
- $return_array = array("code" => 201, "error_message" => "", "gps_data" => array());
- return json_encode($return_array);
- }
-
- $return_array = array("code" => 201, "error_message" => "");
- $gps_data_array = array();
- foreach( $bus_gps_info as $bus_gps_tmp ) {
- $insert_array = array();
- $insert_array["bus_no"] = $bus_gps_tmp["bus_no"];
- $insert_array["latitude"] = $bus_gps_tmp["latitude"];
- $insert_array["longitude"] = $bus_gps_tmp["longitude"];
- $insert_array["speed"] = $bus_gps_tmp["gpsSpeed"] > 0 ? $bus_gps_tmp["gpsSpeed"] : $bus_gps_tmp["speed"];
- $insert_array["direction"] = $bus_gps_tmp["direction"];
- $insert_array["update_time"] = $bus_gps_tmp["update_time"];
- $gps_data_array[$bus_gps_tmp["bus_no"]] = $insert_array;
- }
-
- $return_array["gps_data"] = $gps_data_array;
- return json_encode($return_array);
- }
-
- /**
- * Function Description:账号的check(加密规则)
- * Function Name: actionIndex
- *
- * @return bool
- *
- * @author Redstop
- */
- public function checkUserNameAndPassword( $user_name, $user_psd )
- {
- $corrent_pwd = $this->getPwdFromUser($user_name);
- return $corrent_pwd == $user_psd ? true : false;
- }
-
- /**
- * Function Description:检查验证号码
- * Function Name: actionIndex
- *
- * @return bool
- *
- * @author Redstop
- */
- public function getPwdFromUser( $user_name )
- {
- $user_password = strtolower(MD5("zz|".$user_name."|cx"));
- return $user_password;
- }
-
-
- //获取新GPS的实时位置的尝试
- public function actionGetNewGpsData() {
- $soap_service = \Yii::$app->soapGps;
- $request = Yii::$app->request;
- $carLPN = $request->post("carLPN");
- $re = $soap_service->LoadCarsRealInfo(['pool_CarLPN_DateTime' => $carLPN , "lastQueryTime" => date("Y-m-d H:i:s"), "serviceIP" => "61.129.251.7", "servicePort" => '8873']);
- return json_encode($re);
- }
- }
|