|
@@ -468,30 +468,16 @@ class ScreenService extends Service
|
|
|
$model->where('time','>=',$time);
|
|
|
$return_gps = $model->get()->toArray();
|
|
|
if(! empty($return_gps)){
|
|
|
- $first_position = "";
|
|
|
+ $first_postition = "";
|
|
|
$location = [];
|
|
|
foreach ($return_gps as $value){
|
|
|
- if(empty ($first_postition)) {
|
|
|
- $first_position = $value['value'];
|
|
|
+ if(empty($first_postition)) {
|
|
|
+ $first_postition = $value['value'];
|
|
|
}
|
|
|
$location[] = $value['value'];
|
|
|
}
|
|
|
- $url = 'https://restapi.amap.com/v3/geocode/regeo?location='.$first_position.'&key='.SystemL::GaoDeMapKey;
|
|
|
- try{
|
|
|
- $return = $this->curlOpen($url);
|
|
|
- $return = json_decode($return,true);
|
|
|
- if(! empty($return['status'])){
|
|
|
- $position = $return['regeocode']['addressComponent'] ?? [];
|
|
|
- $result = [
|
|
|
- 'province' => $position['province'] ?? '',
|
|
|
- 'city' => $position['city'] ?? '',
|
|
|
- 'district' => $position['district'] ?? '',
|
|
|
- 'location' => $location
|
|
|
- ];
|
|
|
- }
|
|
|
- }catch (\Exception $exception){
|
|
|
-// return [false,$exception->getMessage()];
|
|
|
- }
|
|
|
+ $result['location'] = $location;
|
|
|
+ $this->getLocation($first_postition,$result);
|
|
|
}
|
|
|
|
|
|
//温度湿度
|
|
@@ -607,6 +593,15 @@ class ScreenService extends Service
|
|
|
$data[$key]['warning'] = $val['value'] ? '是' : '否';
|
|
|
}elseif(empty($data[$key]['gps']) && $map2[$code] == DeviceType::type_four){
|
|
|
$data[$key]['gps'] = $val['value'];
|
|
|
+ $tmp = [
|
|
|
+ 'province' => '',
|
|
|
+ 'city' => '',
|
|
|
+ 'district' => '',
|
|
|
+ ];
|
|
|
+ $this->getLocation($val['value'],$tmp);
|
|
|
+ $data[$key]['province'] = $tmp['province'];
|
|
|
+ $data[$key]['city'] = $tmp['city'];
|
|
|
+ $data[$key]['district'] = $tmp['district'];
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -615,4 +610,19 @@ class ScreenService extends Service
|
|
|
|
|
|
return $data;
|
|
|
}
|
|
|
+
|
|
|
+ public function getLocation($position,&$result){
|
|
|
+ $url = 'https://restapi.amap.com/v3/geocode/regeo?location='.$position.'&key='.SystemL::GaoDeMapKey;
|
|
|
+ try{
|
|
|
+ $return = $this->curlOpen($url);
|
|
|
+ $return = json_decode($return,true);
|
|
|
+ if(! empty($return['status'])){
|
|
|
+ $position = $return['regeocode']['addressComponent'] ?? [];
|
|
|
+ $result['province'] = $position['province'] ?? '';
|
|
|
+ $result['city'] = $position['city'] ?? '';
|
|
|
+ $result['district'] = $position['district'] ?? '';
|
|
|
+ }
|
|
|
+ }catch (\Exception $exception){
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|