Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 
 
 

52 řádky
1.6 KiB

  1. <?php
  2. /**
  3. *
  4. * ============================================================================
  5. * * 版权所有 蜘蛛出行 * *
  6. * 网站地址: http://www.zhizhuchuxing.com
  7. * ----------------------------------------------------------------------------
  8. * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和
  9. * 使用;不允许对程序代码以任何形式任何目的的再发布。
  10. * ============================================================================
  11. * Author By: Redstop
  12. * PhpStorm GetGpsData.php
  13. * Create By 2017/6/2 18:16 $
  14. */
  15. namespace backend\modules\api\logic;
  16. use yii\db\Query;
  17. class GetGpsData extends Query
  18. {
  19. /**
  20. * Function Description:
  21. * Function Name:
  22. *
  23. * @author Redstop
  24. */
  25. public function getBusGpsLastInfo( $bus_no )
  26. {
  27. $current_day = date("Y-m-d");
  28. $bus_no_array = explode(",", $bus_no);
  29. $res1 = (new Query())->select('max(m.id) as id ')
  30. ->from('gps_new as m')
  31. ->where(['and', ['in', 'm.bus_no', $bus_no_array], ['=', 'm.run_date', $current_day]])
  32. ->groupBy("m.bus_no")
  33. ->all();
  34. if( !$res1 ) {
  35. return false;
  36. }
  37. $gps_id_array = array();
  38. foreach( $res1 as $res_info ) {
  39. $gps_id_array[] = $res_info["id"];
  40. }
  41. $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')
  42. ->from('gps_new as m')
  43. ->where(['and', ['in', 'm.id', $gps_id_array]])
  44. ->all();
  45. return $res2;
  46. }
  47. }