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
108ba6b2
Commit
108ba6b2
authored
Sep 25, 2023
by
dong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix20230721
parent
ebf4a949
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
15 deletions
+35
-15
apps/models.py
+16
-0
apps/utils/industry_enterprise_num.py
+15
-15
apps/view_radar/view.py
+4
-0
No files found.
apps/models.py
View file @
108ba6b2
...
@@ -43,6 +43,22 @@ class IndustryChain(db.Model):
...
@@ -43,6 +43,22 @@ class IndustryChain(db.Model):
enterprise_num
=
db
.
Column
(
db
.
Integer
,
comment
=
'相关全企业表数量'
)
enterprise_num
=
db
.
Column
(
db
.
Integer
,
comment
=
'相关全企业表数量'
)
class
IndustryChain1
(
db
.
Model
):
__tablename_
=
"industry_chain1"
__table_args__
=
({
'comment'
:
'新版产业链数据数据表'
})
# 添加表注释
id
=
db
.
Column
(
db
.
Integer
,
primary_key
=
True
,
autoincrement
=
True
,
comment
=
'主键id'
)
industry_name
=
db
.
Column
(
db
.
String
(
20
),
comment
=
'行业名称'
)
icon_url
=
db
.
Column
(
db
.
String
(
255
),
comment
=
'未选中时行业图标'
)
icon_url1
=
db
.
Column
(
db
.
String
(
255
),
comment
=
'选中时行业图标'
)
status
=
db
.
Column
(
db
.
Integer
,
doc
=
'启用状态1启用,2禁用'
,
comment
=
'启用状态1启用,2禁用'
)
# 启用状态1启用,2禁用
industry_type
=
db
.
Column
(
db
.
Integer
,
comment
=
'行业类型(0是产业集群,1是上游行业,2是中游行业,3是下游行业)'
)
relate_id
=
db
.
Column
(
db
.
Integer
,
comment
=
'关系id(关联哪个产业环节'
)
chain_id
=
db
.
Column
(
db
.
Integer
,
comment
=
'关系id(关联哪个产业链'
)
# enterprise = db.relationship('Enterprise', backref=db.backref('enterprise'))
enterprise_num
=
db
.
Column
(
db
.
Integer
,
comment
=
'相关全企业表数量'
)
# 全国企业
# 全国企业
class
Enterprise
(
db
.
Model
):
class
Enterprise
(
db
.
Model
):
__tablename__
=
"enterprise"
__tablename__
=
"enterprise"
...
...
apps/utils/industry_enterprise_num.py
View file @
108ba6b2
# # # -*- coding:utf-8 -*-
# # # -*- coding:utf-8 -*-
# import threading
# import threading
# from apps.models import IndustryChain, Enterprise
# from apps.models import IndustryChain
1
, Enterprise
# from manager import app
# from manager import app
# from apps import db
# from apps import db
#
#
#
#
# """
# """
# IndustryChain或者Enterprise数据表更新后,
# IndustryChain
1
或者Enterprise数据表更新后,
# 计算产业环节相关企业的数量并填充到IndustryChain的enterprise_num字段中。
# 计算产业环节相关企业的数量并填充到IndustryChain
1
的enterprise_num字段中。
# """
# """
#
#
#
#
# def handle():
# def handle():
# with app.app_context():
# with app.app_context():
# industry_obj_list = IndustryChain.query.all()
# industry_obj_list = IndustryChain
1
.query.all()
# print(industry_obj_list)
# print(industry_obj_list)
# # 读取industry_chain数据表的产业名称
# # 读取industry_chain数据表的产业名称
# for industry_obj in industry_obj_list:
# for industry_obj in industry_obj_list:
...
@@ -27,7 +27,7 @@
...
@@ -27,7 +27,7 @@
# continue
# continue
#
#
# else:
# else:
# indu_obj_li = IndustryChain
.query.filter(IndustryChain
.relate_id == indu_id).all()
# indu_obj_li = IndustryChain
1.query.filter(IndustryChain1
.relate_id == indu_id).all()
# for indu_obj in indu_obj_li:
# for indu_obj in indu_obj_li:
# indu_name = indu_obj.industry_name
# indu_name = indu_obj.industry_name
# print("正在查询【{}】的相关企业......".format(indu_name))
# print("正在查询【{}】的相关企业......".format(indu_name))
...
@@ -59,29 +59,29 @@
...
@@ -59,29 +59,29 @@
# # -*- coding:utf-8 -*-
# # -*- coding:utf-8 -*-
import
threading
import
threading
from
apps.models
import
IndustryChain
,
Enterprise
from
apps.models
import
IndustryChain
1
,
Enterprise
from
manager
import
app
from
manager
import
app
from
apps
import
db
from
apps
import
db
"""
"""
IndustryChain或者Enterprise数据表更新后,
IndustryChain
1
或者Enterprise数据表更新后,
计算产业环节相关企业去重后的数量并填充到IndustryChain的enterprise_num字段中。
计算产业环节相关企业去重后的数量并填充到IndustryChain
1
的enterprise_num字段中。
"""
"""
def
get_product_li
(
product
,
chain_id
):
def
get_product_li
(
product
,
chain_id
):
res_two_li
=
[]
res_two_li
=
[]
res_three_li
=
[]
res_three_li
=
[]
product_id
=
IndustryChain
.
query
.
filter_by
(
industry_name
=
product
,
chain_id
=
chain_id
)
.
first
()
.
id
product_id
=
IndustryChain
1
.
query
.
filter_by
(
industry_name
=
product
,
chain_id
=
chain_id
)
.
first
()
.
id
product_li
=
[{
"chain_name"
:
product
,
"chain_name_id"
:
product_id
}]
product_li
=
[{
"chain_name"
:
product
,
"chain_name_id"
:
product_id
}]
chain_one_obj_list
=
IndustryChain
.
query
.
filter_by
(
relate_id
=
product_id
,
chain_id
=
chain_id
)
.
all
()
chain_one_obj_list
=
IndustryChain
1
.
query
.
filter_by
(
relate_id
=
product_id
,
chain_id
=
chain_id
)
.
all
()
res_one_li
=
[{
"chain_name"
:
chain_one_obj
.
industry_name
,
res_one_li
=
[{
"chain_name"
:
chain_one_obj
.
industry_name
,
"chain_name_id"
:
chain_one_obj
.
id
"chain_name_id"
:
chain_one_obj
.
id
}
for
chain_one_obj
in
chain_one_obj_list
]
}
for
chain_one_obj
in
chain_one_obj_list
]
for
res_one
in
res_one_li
:
for
res_one
in
res_one_li
:
chain_two_obj_list
=
IndustryChain
.
query
.
filter_by
(
relate_id
=
res_one
[
"chain_name_id"
])
.
all
()
chain_two_obj_list
=
IndustryChain
1
.
query
.
filter_by
(
relate_id
=
res_one
[
"chain_name_id"
])
.
all
()
res_two
=
[{
"chain_name"
:
chain_one_obj
.
industry_name
,
res_two
=
[{
"chain_name"
:
chain_one_obj
.
industry_name
,
"chain_name_id"
:
chain_one_obj
.
id
"chain_name_id"
:
chain_one_obj
.
id
}
for
chain_one_obj
in
chain_two_obj_list
]
}
for
chain_one_obj
in
chain_two_obj_list
]
...
@@ -89,7 +89,7 @@ def get_product_li(product, chain_id):
...
@@ -89,7 +89,7 @@ def get_product_li(product, chain_id):
res_one_li
.
extend
(
res_two
)
res_one_li
.
extend
(
res_two
)
for
res_two
in
res_two_li
:
for
res_two
in
res_two_li
:
chain_three_obj_list
=
IndustryChain
.
query
.
filter_by
(
relate_id
=
res_two
[
"chain_name_id"
])
.
all
()
chain_three_obj_list
=
IndustryChain
1
.
query
.
filter_by
(
relate_id
=
res_two
[
"chain_name_id"
])
.
all
()
res_three
=
[{
"chain_name"
:
chain_one_obj
.
industry_name
,
res_three
=
[{
"chain_name"
:
chain_one_obj
.
industry_name
,
"chain_name_id"
:
chain_one_obj
.
id
"chain_name_id"
:
chain_one_obj
.
id
}
for
chain_one_obj
in
chain_three_obj_list
]
}
for
chain_one_obj
in
chain_three_obj_list
]
...
@@ -97,7 +97,7 @@ def get_product_li(product, chain_id):
...
@@ -97,7 +97,7 @@ def get_product_li(product, chain_id):
res_one_li
.
extend
(
res_three
)
res_one_li
.
extend
(
res_three
)
# print(res_one_li)
# print(res_one_li)
for
res_three
in
res_three_li
:
for
res_three
in
res_three_li
:
chain_four_obj_list
=
IndustryChain
.
query
.
filter_by
(
relate_id
=
res_three
[
"chain_name_id"
])
.
all
()
chain_four_obj_list
=
IndustryChain
1
.
query
.
filter_by
(
relate_id
=
res_three
[
"chain_name_id"
])
.
all
()
res_four
=
[{
"chain_name"
:
chain_one_obj
.
industry_name
,
res_four
=
[{
"chain_name"
:
chain_one_obj
.
industry_name
,
"chain_name_id"
:
chain_one_obj
.
id
"chain_name_id"
:
chain_one_obj
.
id
}
for
chain_one_obj
in
chain_four_obj_list
]
}
for
chain_one_obj
in
chain_four_obj_list
]
...
@@ -108,8 +108,8 @@ def get_product_li(product, chain_id):
...
@@ -108,8 +108,8 @@ def get_product_li(product, chain_id):
def
handle
():
def
handle
():
with
app
.
app_context
():
with
app
.
app_context
():
industry_obj_list
=
IndustryChain
.
query
.
all
()
industry_obj_list
=
IndustryChain
1
.
query
.
all
()
# industry_obj_list = IndustryChain
.query.filter(IndustryChain
.id == 604).all()
# industry_obj_list = IndustryChain
1.query.filter(IndustryChain1
.id == 604).all()
# print(industry_obj_list)
# print(industry_obj_list)
# 读取industry_chain数据表的产业名称
# 读取industry_chain数据表的产业名称
for
industry_obj
in
industry_obj_list
:
for
industry_obj
in
industry_obj_list
:
...
...
apps/view_radar/view.py
View file @
108ba6b2
...
@@ -14,6 +14,7 @@ from datetime import datetime
...
@@ -14,6 +14,7 @@ from datetime import datetime
# import datetime
# import datetime
from
apps
import
db
,
constants
,
redis_store
from
apps
import
db
,
constants
,
redis_store
from
apps.utils.neo4j_conn
import
conn_neo4j
from
apps.utils.neo4j_conn
import
conn_neo4j
from
apps.view_atlas.view
import
get_product_li
'''
'''
1055 Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated
1055 Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated
...
@@ -1214,6 +1215,9 @@ def radar_enums():
...
@@ -1214,6 +1215,9 @@ def radar_enums():
enterprise
=
enterprise
.
filter_by
(
city
=
city
)
enterprise
=
enterprise
.
filter_by
(
city
=
city
)
if
district
:
if
district
:
enterprise
=
enterprise
.
filter_by
(
district
=
district
)
enterprise
=
enterprise
.
filter_by
(
district
=
district
)
indu_obj_li
=
get_product_li
(
product
,
inid
)
if
product
:
if
product
:
# 有可能会变成模糊查询
# 有可能会变成模糊查询
enterprise
=
enterprise
.
filter
(
or_
(
enterprise
=
enterprise
.
filter
(
or_
(
...
...
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