标签:查询 The exists map result when column read lock file
/**
* 获取边界
* @return mixed
* @return false|string
* @throws \Exception
*/
public function actionBorder()
{
$lock_file = "/tmp/process.lock";
$lock_file_handle = fopen($lock_file, ‘w‘);
if ($lock_file_handle === false)
die("Can not create lock file {$lock_file}\n");
if (!flock($lock_file_handle, LOCK_EX + LOCK_NB)) {
die(date("Y-m-d H:i:s") . " Process already exists.\n");
}
$cache = \Yii::$app->cache;
// $cache->delete(‘amap_border‘);
$result = $cache->get(‘amap_border‘);
if($result) {
// return json_encode($result);
}
$gaode_url = ‘https://restapi.amap.com/v3/config/district?keywords=110100&subdistrict=0&extensions=all&key=****‘;
$curl = new HttpCurl();
$response_json = $curl->get($gaode_url);
$response_arr = json_decode($response_json, true);
$left_lng = 0;
$up_lat = 0;
$right_lng = 0;
$down_lat = 0;
$lng_lat_arr = [];
$lng_lat_tmp_arr = [];
$result_arr_list = [];
if($response_arr[‘status‘] == 1){
$lng_lat_str = isset($response_arr[‘districts‘][0][‘polyline‘]) ? $response_arr[‘districts‘][0][‘polyline‘] : ‘‘;
$lng_lat_tmp_list = explode(‘|‘, $lng_lat_str);
$i = 1;
foreach ($lng_lat_tmp_list as $k=>$lng_lat_tmp){
$lng_lat_arr_tmp = explode(‘;‘, $lng_lat_tmp);
foreach ($lng_lat_arr_tmp as $lng_lat_arr_v) {
// 17152
if(!($i % 10)) {
$lng_lat_t_arr = explode(‘,‘, $lng_lat_arr_v);
$result_tmp[‘lng‘] = $lng_lat_t_arr[0];
$result_tmp