|
@@ -2,6 +2,7 @@
|
|
|
|
|
|
namespace app\common\server;
|
|
|
|
|
|
+use app\common\model\Devicelistmodel;
|
|
|
use app\common\model\FacilityModel;
|
|
|
use app\common\model\ShalarmlistModel;
|
|
|
use app\common\model\ShinfoModel;
|
|
@@ -117,6 +118,7 @@ class SouhuanAnalysis
|
|
|
*/
|
|
|
public function getmacforUD($str, $device_id_code)
|
|
|
{
|
|
|
+ Log::write($str, 'shouhuan');
|
|
|
$data = explode(",", $str);
|
|
|
$is_gps = $data[3];
|
|
|
$is_success = false;
|
|
@@ -168,15 +170,23 @@ class SouhuanAnalysis
|
|
|
$macs = join("|", $macs_arr);
|
|
|
$accesstype = 1;
|
|
|
$url = "http://apilocate.amap.com/position?macs=" . $macs . "&bts=" . $bts . "&nearbts=" . $nearbts . "&network=GSM&cdma=0&accesstype=" . $accesstype . "&output=json&key=" . $apikey;
|
|
|
+ Log::write($url, 'shouhuan');
|
|
|
$result = curl_request($url);
|
|
|
+ Log::write($result, 'shouhuan');
|
|
|
if ('10000' === $result['infocode']) {
|
|
|
$resultdata = $result['result'];
|
|
|
- $locations = explode(",", $resultdata['location']);
|
|
|
- $use_gps_long = $locations[0];
|
|
|
- $use_gps_lat = $locations[1];
|
|
|
- $address_desc = $resultdata['desc'];
|
|
|
- $accesstype = 2;
|
|
|
- $is_success = true;
|
|
|
+ if (isset($resultdata['location'])) {
|
|
|
+ $locations = explode(",", $resultdata['location']);
|
|
|
+ $use_gps_long = $locations[0];
|
|
|
+ $use_gps_lat = $locations[1];
|
|
|
+ $address_desc = $resultdata['desc'];
|
|
|
+ $accesstype = 2;
|
|
|
+ $is_success = true;
|
|
|
+ }else{
|
|
|
+ Log::write($url, 'shouhuan');
|
|
|
+ Log::write($result, 'shouhuan');
|
|
|
+ $accesstype = -2;
|
|
|
+ }
|
|
|
} else {
|
|
|
Log::write($url, 'shouhuan');
|
|
|
Log::write($result, 'shouhuan');
|
|
@@ -189,10 +199,14 @@ class SouhuanAnalysis
|
|
|
$gps_str = $use_gps_long . "," . $use_gps_lat;
|
|
|
$url = "https://restapi.amap.com/v3/assistant/coordinate/convert?locations=" . $gps_str . "&coordsys=gps&output=JSON&key=" . $apikey;
|
|
|
$result = curl_request($url);
|
|
|
+ Log::write($url, 'shouhuan');
|
|
|
+ Log::write($result, 'shouhuan');
|
|
|
if ('10000' == $result['infocode']) {
|
|
|
$locations = $result['locations'];
|
|
|
$url = "https://restapi.amap.com/v3/geocode/regeo?location=" . $locations . "&key=" . $apikey;
|
|
|
$result = curl_request($url);
|
|
|
+ Log::write($url, 'shouhuan');
|
|
|
+ Log::write($result, 'shouhuan');
|
|
|
if ('10000' == $result['infocode']) {
|
|
|
$address_desc = $result['regeocode']['formatted_address'];
|
|
|
$is_success = true;
|
|
@@ -846,6 +860,14 @@ class SouhuanAnalysis
|
|
|
$data['shinfo_id'] = $sshinfo_id;
|
|
|
$data['facility_id'] = $facility_id;
|
|
|
$data['createtime'] = date('Y-m-d H:i:s');
|
|
|
+ $result = $this->getmacforUD($original_str, $device_id_code);
|
|
|
+ $data['use_gps_long'] = $result['use_gps_long'];
|
|
|
+ $data['use_gps_lat'] = $result['use_gps_lat'];
|
|
|
+ $data['location'] = $result['address_desc'];
|
|
|
+ $m_dl = new Devicelistmodel();
|
|
|
+ $uid = $m_dl->getuidbydeviceid($device_id_code);
|
|
|
+ $uid = empty($uid) ? 0 : $uid;
|
|
|
+ $data['user_id'] = $uid;
|
|
|
$said = $m_sa->insertData($data);
|
|
|
if (empty($said)) {
|
|
|
$msg = "报警信息添加失败:" . $original_str;
|