|
@@ -124,17 +124,38 @@ class ApiAction extends Action {
|
|
|
public function get_map_index_data( ){
|
|
|
$this->token_verify();
|
|
|
$deviceNumber = $_GET['data']['deviceNumber'];
|
|
|
+ $licensePlate = $_GET['data']['licensePlate'];
|
|
|
|
|
|
if(!$deviceNumber){
|
|
|
$this->api_fail(C('FAIL'),'faild, no deviceNumber !');
|
|
|
}
|
|
|
|
|
|
- //获取车辆最新位置
|
|
|
+ //获取车辆最新位置mysql
|
|
|
+ /*
|
|
|
$result = M('jms_vehicle')->field('GpsLongitude, GpsLatitude, Address, FenceShapeInfo, LockStatus, FenceAlarmEnable, Battery, GpsOnlineTime, Speed, CityId')->where(array('DeviceNumber' => $deviceNumber))->find();
|
|
|
+ */
|
|
|
+
|
|
|
+ //redis获取
|
|
|
+ $vehicle = Redis('fdrc_vehicle','hash');
|
|
|
+ //var_dump($vehicle);
|
|
|
+ $vehicleInfo = $vehicle->get($deviceNumber);
|
|
|
+ $vehicleInfo = json_decode($vehicleInfo, true);
|
|
|
+
|
|
|
+
|
|
|
+ $rlfd_vehicle_fence = Redis('rlfd_vehicle_fence','hash');
|
|
|
+ $fence = $rlfd_vehicle_fence->get($licensePlate);
|
|
|
+ //$fence = json_decode($fence, true);
|
|
|
+
|
|
|
+ $lastLocReis = Redis('rfld_gps_last_location','hash');
|
|
|
+ $lastLoction = $lastLocReis->get(strtoupper($gpsNumber));
|
|
|
+ $lastLoction = $lastLoction = json_decode($lastLocation, true);
|
|
|
+
|
|
|
+ /*
|
|
|
if(!$result){
|
|
|
- $this->api_fail(C('FAIL'),'cant find this vehicl !');
|
|
|
+ $this->api_fail(C('FAIL'),'cant find this vehicle !');
|
|
|
}
|
|
|
- $onlineTimeStamp = strtotime($result['GpsOnlineTime']);
|
|
|
+ */
|
|
|
+ $onlineTimeStamp = strtotime($lastLoction['GpsOnlineTime']);
|
|
|
if(!$onlineTimeStamp){
|
|
|
$onlineTimeStamp = 0;
|
|
|
}
|
|
@@ -149,12 +170,12 @@ class ApiAction extends Action {
|
|
|
}
|
|
|
*/
|
|
|
$mapData = array(
|
|
|
- 'vehicleLocation' => array('longitude' => $result['GpsLongitude'], 'latitude' => $result['GpsLatitude']),
|
|
|
- 'vehicleAddress' => $result['Address'],
|
|
|
- 'lockStatus' => $result['LockStatus'],
|
|
|
- 'fenceShapeInfo' => $result['FenceShapeInfo'],
|
|
|
- 'battery' => $result['Battery'],
|
|
|
- 'fenceAlarmStatus' => $result['FenceAlarmEnable'],
|
|
|
+ 'vehicleLocation' => array('longitude' => $lastLoction['GpsLongitude'], 'latitude' => $lastLoction['GpsLatitude']),
|
|
|
+ // 'vehicleAddress' => $result['Address'],
|
|
|
+ 'lockStatus' => $vehicleInfo['LockStatus'],
|
|
|
+ 'fenceShapeInfo' => $fence,
|
|
|
+ 'battery' => $lastLoction['Battery'],
|
|
|
+ // 'fenceAlarmStatus' => $result['FenceAlarmEnable'],
|
|
|
'onlineTime' => $onlineTimeStamp,
|
|
|
'speed' => $result['Speed']
|
|
|
);
|
|
@@ -521,14 +542,15 @@ class ApiAction extends Action {
|
|
|
if( !$gps_number || !$search_date){
|
|
|
json_fail('请检查GPS标签或者日期 !');
|
|
|
}
|
|
|
- $list = $this->getBTGpsRoute($search_date,$gps_number);
|
|
|
- //$list = $this->getBTGpsRoute($search_date, '1');
|
|
|
-
|
|
|
+ //$list = $this->getBTGpsRoute($search_date,'1');
|
|
|
+ $list = $this->getBTGpsRoute($search_date, $gps_number); //test
|
|
|
+ $lngLatAlter = new \Jms\Algo\Geometry();
|
|
|
$respData = array();
|
|
|
foreach($list as $v){
|
|
|
+ $alterRes = $lngLatAlter->convertBd09ToGcj02($v['Latitude'], $v['Longitude']);
|
|
|
$nv = array(
|
|
|
- 'lat' => $v['Latitude'],
|
|
|
- 'lng' => $v['Longitude'],
|
|
|
+ 'lat' => $alterRes['lat'],
|
|
|
+ 'lng' => $alterRes['lng'],
|
|
|
'speed' => $v['Speed'],
|
|
|
'deviceTime' => $v['OnlineTime']
|
|
|
);
|
|
@@ -582,27 +604,10 @@ class ApiAction extends Action {
|
|
|
}
|
|
|
$drivingData = array();
|
|
|
|
|
|
- $todayDate = date('Y-m-d');
|
|
|
- $todayCache = S($gpsNumber.'_cache'.$todayDate);
|
|
|
- if(!$todayCache){
|
|
|
- $todayData = $this->searchDrivingData($gpsNumber, $date);
|
|
|
- array_push($drivingData, $todayData);
|
|
|
- $todayCache = S($gpsNumber.'_cache'.$todayData, $todayData, 3600*24);
|
|
|
- }else{
|
|
|
- $newOnlineTime = M('jms_vehicle')->where(array('GpsDeviceNumber' => $gpsNumber))->getField('GpsOnlineTime');
|
|
|
- $nTime = strtotime($newOnlineTime);
|
|
|
- $oTime = strtotime($lastOnlineTime);
|
|
|
- if($nTime == $oTime){
|
|
|
- array_push($drivingData, $todayCache);
|
|
|
- }else{
|
|
|
- $todayData = $this->searchDrivingData($gpsNumber, $date);
|
|
|
- array_push($drivingData, $todayData);
|
|
|
- $todayCache = S($gpsNumber.'_cache'.$todayDate, $todayData, 3600*24);
|
|
|
- }
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
for($i = $days-1; $i > 0; --$i){
|
|
|
- $preStr2time = strtotime('-'.$i.'days', 1555689600);
|
|
|
+ $preStr2time = strtotime('-'.$i.'days');
|
|
|
$date = date('Y-m-d', $preStr2time);
|
|
|
/*
|
|
|
$where = array(
|
|
@@ -632,6 +637,26 @@ class ApiAction extends Action {
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+ //当日
|
|
|
+ $todayDate = date('Y-m-d');
|
|
|
+
|
|
|
+ $todayCache = S($gpsNumber.'_cache'.$todayDate);
|
|
|
+ if(!$todayCache){
|
|
|
+ $todayData = $this->searchDrivingData($gpsNumber, $todayDate);
|
|
|
+ array_push($drivingData, $todayData);
|
|
|
+ $todayCache = S($gpsNumber.'_cache'.$todayData, $todayData, 3600*24);
|
|
|
+ }else{
|
|
|
+ $newOnlineTime = M('jms_vehicle')->where(array('GpsDeviceNumber' => $gpsNumber))->getField('GpsOnlineTime');
|
|
|
+ $nTime = strtotime($newOnlineTime);
|
|
|
+ $oTime = strtotime($lastOnlineTime);
|
|
|
+ if($nTime == $oTime){
|
|
|
+ array_push($drivingData, $todayCache);
|
|
|
+ }else{
|
|
|
+ $todayData = $this->searchDrivingData($gpsNumber, $date);
|
|
|
+ array_push($drivingData, $todayData);
|
|
|
+ $todayCache = S($gpsNumber.'_cache'.$todayDate, $todayData, 3600*24);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
//dump($drivingData);
|
|
|
if(!$drivingData){
|
|
@@ -721,7 +746,8 @@ class ApiAction extends Action {
|
|
|
public function get_vehicle_ElectronicPlateUrl( ){
|
|
|
$this->token_verify();
|
|
|
$userid = I('userid');
|
|
|
- $electronicPlateUrl = M('jms_vehicle')->where(array('ID'=>$userid))->field('FrontElectronicPlateUrl,BackElectronicPlateUrl')->cache(true,24*60*60)->select();
|
|
|
+ $result = M('jms_vehicle')->where(array('ID'=>$userid))->field('FrontElectronicPlateUrl,BackElectronicPlateUrl')->cache('key',86400)->select();
|
|
|
+ $electronicPlateUrl = S('key');
|
|
|
$this->api_success('成功',$electronicPlateUrl[0]);
|
|
|
}
|
|
|
|