Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
geoserver
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
backend
geoserver
Commits
508a9f42
Commit
508a9f42
authored
Sep 21, 2019
by
gaoming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
刷新redis数据
parent
a82f21e3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
17 deletions
+45
-17
deploy_conf.xml
deploy_conf.xml
+5
-0
views.py
home/views.py
+40
-17
No files found.
deploy_conf.xml
0 → 100644
View file @
508a9f42
<?xml version="1.0" encoding="utf-8"?>
<gm_rpcd_config>
<info
config_name=
"deploy"
version=
"1.0"
/>
<config
name=
"log_dir"
value=
"/data/log/geoserver"
/>
</gm_rpcd_config>
home/views.py
View file @
508a9f42
...
...
@@ -43,6 +43,23 @@ def nearly_hospitals(q_lat,q_lng,radis=500,unit="km",count=20):
}
return
data
@bind
(
'geoserver/home/refresh'
)
def
refresh
():
'''刷新redis中数据'''
result
=
{
"result"
:
True
,
"data"
:[],
"message"
:
""
}
try
:
refresh_cache_locations
()
except
Exception
as
e
:
result
.
update
({
"result"
:
False
,
"message"
:
str
(
e
)})
return
result
@bind
(
"geoserver/home/hospitals_distance"
)
def
specify_hospitals_distance
(
q_lng
,
q_lat
,
hospital_ids
):
'''
...
...
@@ -51,25 +68,31 @@ def specify_hospitals_distance(q_lng,q_lat,hospital_ids):
cache_key
=
"hospital_location"
#锁定临时的key
result
=
[]
temp_key
=
"hospital_location_temp"
lock_key
=
"hospital_location_lock"
with
r
.
lock
(
lock_key
,
blocking_timeout
=
15
)
as
lock
:
r
.
geoadd
(
cache_key
,
float
(
q_lng
),
float
(
q_lat
),
temp_key
)
for
item
in
hospital_ids
:
distance
=
r
.
geodist
(
cache_key
,
temp_key
,
item
)
if
not
distance
:
distance
=
0
result
.
append
({
"id"
:
item
,
"distance"
:
distance
})
#排序
result
=
sorted
(
result
,
key
=
lambda
x
:
x
.
get
(
"distance"
))
data
=
[]
message
=
""
result
=
True
try
:
temp_key
=
"hospital_location_temp"
lock_key
=
"hospital_location_lock"
with
r
.
lock
(
lock_key
,
blocking_timeout
=
15
)
as
lock
:
r
.
geoadd
(
cache_key
,
float
(
q_lng
),
float
(
q_lat
),
temp_key
)
for
item
in
hospital_ids
:
distance
=
r
.
geodist
(
cache_key
,
temp_key
,
item
)
if
not
distance
:
distance
=
0
data
.
append
({
"id"
:
item
,
"distance"
:
distance
})
#排序
data
=
sorted
(
data
,
key
=
lambda
x
:
x
.
get
(
"distance"
))
except
Exception
as
e
:
result
,
message
=
False
,
str
(
e
)
data
=
{
"result"
:
True
,
"data"
:
result
,
"message"
:
""
"result"
:
result
,
"data"
:
data
,
"message"
:
message
}
return
data
...
...
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