Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tl_estate
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hujun
tl_estate
Commits
bdc525c9
Commit
bdc525c9
authored
Oct 17, 2018
by
zhuwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
批量设置商圈的经纬度
parent
c141c95d
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
132 additions
and
4 deletions
+132
-4
BatchProcessing.php
application/index/controller/BatchProcessing.php
+97
-0
ImageDepot.php
application/index/controller/ImageDepot.php
+4
-4
GBusinessDistrict.php
application/model/GBusinessDistrict.php
+27
-0
route.php
application/route.php
+4
-0
No files found.
application/index/controller/BatchProcessing.php
0 → 100755
View file @
bdc525c9
<?php
namespace
app\index\controller
;
use
app\index\extend\Basic
;
use
app\model\GBusinessDistrict
;
use
think\Log
;
/**
* 批量处理控制器(数据库一些数据需要批量处理下)
* Class BatchProcessing
* @package app\index\controller
*/
class
BatchProcessing
extends
Basic
{
public
function
__construct
(
$request
=
null
)
{
parent
::
__construct
(
$request
);
}
/**
* 批量设置商圈的经纬度
*/
public
function
getCityLatAadLng
(){
$model
=
new
GBusinessDistrict
();
$field
=
'id,name,city'
;
$get_params
=
''
;
$model_res
=
$model
->
getBusinessDistrict
(
$field
,
$get_params
);
$success_num
=
0
;
$fail
=
0
;
foreach
(
$model_res
as
$key
=>
$v
)
{
//dump($v['name']);
//dump($v['city']);
$id
=
$v
[
'id'
];
$address
=
$v
[
'name'
];
$city
=
$v
[
'city'
];
$res
=
$this
->
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
;
Log
::
write
(
$log_text
,
'获取商圈经纬度-失败'
);
//记录日志
}
$insert
=
[];
$insert
[
"id"
]
=
$id
;
$insert
[
"longitude"
]
=
$longitude
;
$insert
[
"latitude"
]
=
$latitude
;
$res
=
$model
->
updateBusinessDistrict
(
$insert
);
//int(1)
$log_text
=
'商圈:'
.
$v
[
'name'
]
.
' 城市: '
.
$v
[
'city'
]
.
' 经度: '
.
$longitude
.
' 纬度: '
.
$latitude
.
' 数据库写入返回值: '
.
$res
;
Log
::
write
(
$log_text
,
'获取商圈经纬度'
);
//记录日志
}
return
$this
->
response
(
"200"
,
"处理完成"
,[
'成功数'
=>
$success_num
,
'失败数'
=>
$fail
]);
}
/**
* @param string $address 地址
* @param string $city 城市名
* @return array
*/
function
getLatLng
(
$address
=
''
,
$city
=
''
)
{
$result
=
array
();
$ak
=
'eqkGg4WQehHn4k7ssWZTv8RPvydUm35s'
;
//您的百度地图ak,可以去百度开发者中心去免费申请
$url
=
"http://api.map.baidu.com/geocoder/v2/?callback=renderOption&output=json&address="
.
$address
.
"&city="
.
$city
.
"&ak="
.
$ak
;
$data
=
file_get_contents
(
$url
);
$data
=
str_replace
(
'renderOption&&renderOption('
,
''
,
$data
);
$data
=
str_replace
(
')'
,
''
,
$data
);
$data
=
json_decode
(
$data
,
true
);
if
(
!
empty
(
$data
)
&&
$data
[
'status'
]
==
0
)
{
$result
[
'lat'
]
=
$data
[
'result'
][
'location'
][
'lat'
];
$result
[
'lng'
]
=
$data
[
'result'
][
'location'
][
'lng'
];
return
$result
;
//返回经纬度结果
}
else
{
return
null
;
}
}
}
application/index/controller/ImageDepot.php
View file @
bdc525c9
...
@@ -5,7 +5,9 @@ namespace app\index\controller;
...
@@ -5,7 +5,9 @@ namespace app\index\controller;
use
app\index\extend\Basic
;
use
app\index\extend\Basic
;
use
app\index\service\ImageDepotService
;
use
app\index\service\ImageDepotService
;
use
app\index\service\UserService
;
use
app\index\service\UserService
;
use
app\model\GBusinessDistrict
;
use
app\model\GImageDepot
;
use
app\model\GImageDepot
;
use
think\Log
;
/**
/**
* zhuwei
* zhuwei
...
@@ -177,14 +179,12 @@ class ImageDepot extends Basic
...
@@ -177,14 +179,12 @@ class ImageDepot extends Basic
$user_service
=
new
UserService
();
$user_service
=
new
UserService
();
$is_outstrip_twenty_four_hours
=
$user_service
->
isUserProtect
(
1
);
$is_outstrip_twenty_four_hours
=
$user_service
->
isUserProtect
(
1
);
dump
(
$is_outstrip_twenty_four_hours
);
dump
(
$is_outstrip_twenty_four_hours
);
if
(
$is_outstrip_twenty_four_hours
==
0
)
{
if
(
$is_outstrip_twenty_four_hours
==
0
)
{
dump
(
'保护器内'
);
dump
(
'保护器内'
);
}
else
{
}
else
{
dump
(
'超过保护期'
);
dump
(
'超过保护期'
);
}
}
}
}
}
}
application/model/GBusinessDistrict.php
View file @
bdc525c9
...
@@ -7,4 +7,31 @@ use think\Model;
...
@@ -7,4 +7,31 @@ use think\Model;
class
GBusinessDistrict
extends
BaseModel
class
GBusinessDistrict
extends
BaseModel
{
{
protected
$table
=
'g_business_district'
;
protected
$table
=
'g_business_district'
;
/**
* 查询数据
* 朱伟 2018-10-17 14:58:36
*/
public
function
getBusinessDistrict
(
$field
,
$params
)
{
$result
=
$this
->
field
(
$field
)
//->alias('a')
->
where
(
$params
)
->
select
();
//dump($this->getLastSql());
return
$result
;
}
/**
* 更新数据
* 朱伟 2018-10-17 14:58:36
*/
public
function
updateBusinessDistrict
(
$params
)
{
$result
=
$this
->
update
(
$params
);
//dump($this->getLastSql());
return
$result
;
}
}
}
application/route.php
View file @
bdc525c9
...
@@ -330,6 +330,10 @@ Route::group('index', [
...
@@ -330,6 +330,10 @@ Route::group('index', [
'getPerformanceReportList'
=>
[
'index/PerformanceReport/getPerformanceReportList'
,
[
'method'
=>
'get | post'
]
],
'getPerformanceReportList'
=>
[
'index/PerformanceReport/getPerformanceReportList'
,
[
'method'
=>
'get | post'
]
],
'delPerformanceReport'
=>
[
'index/PerformanceReport/delPerformanceReport'
,
[
'method'
=>
'get | post'
]
],
//删除
'delPerformanceReport'
=>
[
'index/PerformanceReport/delPerformanceReport'
,
[
'method'
=>
'get | post'
]
],
//删除
//批量处理控制器
'getCityLatAadLng'
=>
[
'index/BatchProcessing/getCityLatAadLng'
,
[
'method'
=>
'get | post'
]
],
//批量设置商圈的经纬度
]);
]);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment