Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mancheng
Overview
Overview
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
mancheng
Commits
48ffdf42
Commit
48ffdf42
authored
Apr 06, 2023
by
dong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix20230406
parent
6417c799
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
13 deletions
+42
-13
apps/view_map/view.py
+42
-13
No files found.
apps/view_map/view.py
View file @
48ffdf42
...
...
@@ -148,23 +148,37 @@ def attract_cnums():
try
:
enterprise
=
Enterprise
.
query
.
filter
(
or_
(
Enterprise
.
c_type
==
inid
,
Enterprise
.
c_type1
==
inid
,
Enterprise
.
c_type2
==
inid
))
Enterprise
.
c_type
==
inid
,
Enterprise
.
c_type1
==
inid
,
Enterprise
.
c_type2
==
inid
))
company1
=
[]
if
product
:
enterprise
=
enterprise
.
filter
(
or_
(
Enterprise
.
product_all
.
like
(
"
%
{}
%
"
.
format
(
product
)),
Enterprise
.
product_all1
.
like
(
"
%
{}
%
"
.
format
(
product
)),
Enterprise
.
product_all2
.
like
(
"
%
{}
%
"
.
format
(
product
))
))
product_li
=
get_product_li
(
product
)
for
product
in
product_li
:
enterprise2
=
''
enterprise2
=
enterprise
.
filter
(
or_
(
Enterprise
.
product_all
.
like
(
"
%
{}
%
"
.
format
(
product
)),
Enterprise
.
product_all1
.
like
(
"
%
{}
%
"
.
format
(
product
)),
Enterprise
.
product_all2
.
like
(
"
%
{}
%
"
.
format
(
product
))
))
.
all
()
company1
+=
enterprise2
company1
=
list
(
set
(
company1
))
# size = len(company1)
# company1 = sorted(company1, key=lambda x: x.hots, reverse=True) # 排序
# enterprise_obj_list = company1[(page - 1) * perpage:page * perpage] # 分页
else
:
pass
# print(enterprise)
df
=
list
()
if
not
province
:
# 全国,省数据
provinces
=
Enterprise
.
query
.
with_entities
(
Enterprise
.
province
)
.
distinct
()
.
all
()
provinces
=
[
i
[
0
]
for
i
in
provinces
if
i
[
0
]]
# 拿到省份的无重复值
for
pro
in
provinces
:
num
=
enterprise
.
filter_by
(
province
=
pro
)
.
count
()
if
product
:
num
=
len
([
company
for
company
in
company1
if
company
.
province
==
pro
])
else
:
num
=
enterprise
.
filter_by
(
province
=
pro
)
.
count
()
df
.
append
({
"name"
:
pro
,
"value"
:
num
})
df
=
sorted
(
df
,
key
=
lambda
x
:
x
[
"value"
],
reverse
=
True
)
redis_store
.
setex
(
name_query
,
30
*
24
*
3600
,
json
.
dumps
(
df
[:
5
]))
...
...
@@ -173,7 +187,11 @@ def attract_cnums():
cities
=
Enterprise
.
query
.
filter_by
(
province
=
province
)
.
with_entities
(
Enterprise
.
city
)
.
distinct
()
.
all
()
cities
=
[
i
[
0
]
for
i
in
cities
if
i
[
0
]]
# 拿到城市的无重复值
for
cit
in
cities
:
num
=
enterprise
.
filter_by
(
province
=
province
,
city
=
cit
)
.
count
()
if
product
:
num
=
len
([
company
for
company
in
company1
if
company
.
province
==
province
and
company
.
city
==
cit
])
else
:
num
=
enterprise
.
filter_by
(
province
=
province
,
city
=
cit
)
.
count
()
# num = enterprise.filter_by(province=province, city=cit).count()
df
.
append
({
"name"
:
cit
,
"value"
:
num
})
df
=
sorted
(
df
,
key
=
lambda
x
:
x
[
"value"
],
reverse
=
True
)
redis_store
.
setex
(
name_query
,
30
*
24
*
3600
,
json
.
dumps
(
df
[:
5
]))
...
...
@@ -183,13 +201,24 @@ def attract_cnums():
Enterprise
.
district
)
.
distinct
()
.
all
()
districts
=
[
i
[
0
]
for
i
in
districts
if
i
[
0
]]
# 拿到区县的无重复值
for
dis
in
districts
:
num
=
enterprise
.
filter_by
(
province
=
province
,
city
=
city
,
district
=
dis
)
.
count
()
if
product
:
num
=
len
([
company
for
company
in
company1
if
company
.
province
==
province
and
company
.
city
==
city
and
company
.
district
==
dis
])
else
:
num
=
enterprise
.
filter_by
(
province
=
province
,
city
=
city
,
district
=
dis
)
.
count
()
# num = enterprise.filter_by(province=province, city=city, district=dis).count()
df
.
append
({
"name"
:
dis
,
"value"
:
num
})
df
=
sorted
(
df
,
key
=
lambda
x
:
x
[
"value"
],
reverse
=
True
)
redis_store
.
setex
(
name_query
,
30
*
24
*
3600
,
json
.
dumps
(
df
[:
5
]))
return
jsonify
(
code
=
RET
.
OK
,
msg
=
"获取成功"
,
data
=
df
[:
5
])
if
province
and
city
and
district
:
# 区数据
num
=
enterprise
.
filter_by
(
province
=
province
,
city
=
city
,
district
=
district
)
.
count
()
if
product
:
num
=
len
([
company
for
company
in
company1
if
company
.
province
==
province
and
company
.
city
==
city
and
company
.
district
==
district
])
else
:
num
=
enterprise
.
filter_by
(
province
=
province
,
city
=
city
,
district
=
district
)
.
count
()
# num = enterprise.filter_by(province=province, city=city, district=district).count()
df
.
append
({
"name"
:
district
,
"value"
:
num
})
df
=
sorted
(
df
,
key
=
lambda
x
:
x
[
"value"
],
reverse
=
True
)
data
=
df
[:
5
]
...
...
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