|
- <?php
- /**
- *
- * ============================================================================
- * * 版权所有 蜘蛛出行 * *
- * 网站地址: http://www.zhizhuchuxing.com
- * ----------------------------------------------------------------------------
- * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和
- * 使用;不允许对程序代码以任何形式任何目的的再发布。
- * ============================================================================
- * Author By: Redstop
- * PhpStorm GetGpsData.php
- * Create By 2017/6/2 18:16 $
- */
-
- namespace backend\modules\api\logic;
-
- use yii\db\Query;
-
- class GetGpsData extends Query
- {
- /**
- * Function Description:
- * Function Name:
- *
- * @author Redstop
- */
- public function getBusGpsLastInfo( $bus_no )
- {
- $current_day = date("Y-m-d");
- $bus_no_array = explode(",", $bus_no);
- $res1 = (new Query())->select('max(m.id) as id ')
- ->from('gps_new as m')
- ->where(['and', ['in', 'm.bus_no', $bus_no_array], ['=', 'm.run_date', $current_day]])
- ->groupBy("m.bus_no")
- ->all();
- if( !$res1 ) {
- return false;
- }
- $gps_id_array = array();
- foreach( $res1 as $res_info ) {
- $gps_id_array[] = $res_info["id"];
- }
-
- $res2 = (new Query())->select('m.id,m.bus_no, m.latitude, m.longitude, m.gpsSpeed, m.speed, m.direction, m.create_time as update_time')
- ->from('gps_new as m')
- ->where(['and', ['in', 'm.id', $gps_id_array]])
- ->all();
- return $res2;
- }
-
- }
|