Commit dab364f3 authored by zhuwei's avatar zhuwei

批量获取地铁站经纬度

parent 09cbf120
...@@ -5,6 +5,7 @@ namespace app\index\controller; ...@@ -5,6 +5,7 @@ namespace app\index\controller;
use app\index\extend\Basic; use app\index\extend\Basic;
use app\index\service\HouseService; use app\index\service\HouseService;
use app\model\GBusinessDistrict; use app\model\GBusinessDistrict;
use app\model\MetroStations;
use think\Log; use think\Log;
/** /**
...@@ -65,6 +66,52 @@ class BatchProcessing extends Basic ...@@ -65,6 +66,52 @@ class BatchProcessing extends Basic
return $this->response("200", "处理完成",['成功数'=>$success_num,'失败数'=>$fail]); return $this->response("200", "处理完成",['成功数'=>$success_num,'失败数'=>$fail]);
} }
/**
* 批量获取地铁站经纬度
* @return \think\Response
*/
public function getMetroStationsLatAadLng(){
$model = new MetroStations();
$house_service = new HouseService();
$field = 'id,name,city,longitude';
$get_params[] = ['EXP', "`longitude` = '' or `longitude` is null "];
$model_res = $model->getMetroStations($field, $get_params);
$success_num = 0;
$fail = 0;
foreach ($model_res as $key => $v) {
$id = $v['id'];
$address = $v['name'].'地铁站';
$city = $v['city'];
/*获取商圈经纬度*/
$res = $house_service->getLatLng($address, $city);
if($res){
$success_num ++;
$longitude = $res['lng'];//'经度'
$latitude = $res['lat'];//'维度'
}else{
$fail ++;
$longitude = '';//'经度'
$latitude = '';//'维度'
$log_text = '地铁站名:'.$v['name'].' 城市: '.$v['city'].' 数据库ID: '.$id;
big_log($log_text); //记录日志
}
$insert=[];
$insert["id"] = $id;
$insert["longitude"] = $longitude;// 经度范围-180~180
$insert["latitude"] = $latitude;// 纬度范围-90~90
$res = $model->updateMetroStations($insert);//int(1)
$log_text = '地铁站名:'.$v['name'].' 城市: '.$v['city'].' 纬度,经度: ['.$latitude.','.$longitude.'] 数据库写入返回值: '.$res;
big_log($log_text); //记录日志
}
return $this->response("200", "处理完成",['成功数'=>$success_num,'失败数'=>$fail]);
}
} }
...@@ -47,4 +47,21 @@ class MetroStations extends BaseModel ...@@ -47,4 +47,21 @@ class MetroStations extends BaseModel
->where($where) ->where($where)
->select(); ->select();
} }
public function getMetroStations($field,$params)
{
$result = $this
->field($field)
->where($params)
->select();
return $result;
}
public function updateMetroStations($params)
{
$result = $this->update($params);
//dump($this->getLastSql());
return $result;
}
} }
...@@ -413,8 +413,9 @@ Route::group('index', [ ...@@ -413,8 +413,9 @@ Route::group('index', [
'delPerformanceReport' => ['index/PerformanceReport/delPerformanceReport', ['method' => 'get | post']],//删除 'delPerformanceReport' => ['index/PerformanceReport/delPerformanceReport', ['method' => 'get | post']],//删除
//批量处理控制器 //批量处理控制器
'getCityLatAadLng' => ['index/BatchProcessing/getCityLatAadLng', ['method' => 'get | post']],//批量设置商圈的经纬度 'getCityLatAadLng' => [ 'index/BatchProcessing/getCityLatAadLng', [ 'method' => 'get | post' ] ],//批量设置商圈的经纬度
'updatePhoneFollowUpIsShow' => ['index/BatchProcessing/updatePhoneFollowUpIsShow', ['method' => 'get | post']],//批量设置商圈的经纬度 'getMetroStationsLatAadLng' => [ 'index/BatchProcessing/getMetroStationsLatAadLng', [ 'method' => 'get | post' ] ],//
'updatePhoneFollowUpIsShow' => [ 'index/BatchProcessing/updatePhoneFollowUpIsShow', [ 'method' => 'get | post' ] ],//批量设置商圈的经纬度
//站点相关 //站点相关
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment