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
f5b3584b
Commit
f5b3584b
authored
Feb 14, 2023
by
dong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix202302014
parent
5f68cf03
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
66 additions
and
40 deletions
+66
-40
apps/models.py
+2
-1
apps/view_atlas/view.py
+28
-0
enterprise_to_industry_chain.py
+36
-39
No files found.
apps/models.py
View file @
f5b3584b
...
@@ -37,7 +37,8 @@ class IndustryChain(db.Model):
...
@@ -37,7 +37,8 @@ class IndustryChain(db.Model):
icon_url1
=
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禁用
status
=
db
.
Column
(
db
.
Integer
,
doc
=
'启用状态1启用,2禁用'
,
comment
=
'启用状态1启用,2禁用'
)
# 启用状态1启用,2禁用
industry_type
=
db
.
Column
(
db
.
Integer
,
comment
=
'行业类型(0是产业集群,1是上游行业,2是中游行业,3是下游行业)'
)
industry_type
=
db
.
Column
(
db
.
Integer
,
comment
=
'行业类型(0是产业集群,1是上游行业,2是中游行业,3是下游行业)'
)
relate_id
=
db
.
Column
(
db
.
Integer
,
comment
=
'关系id(关联与哪个产业环节'
)
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
=
db
.
relationship
(
'Enterprise'
,
backref
=
db
.
backref
(
'enterprise'
))
enterprise_num
=
db
.
Column
(
db
.
Integer
,
comment
=
'相关全企业表数量'
)
enterprise_num
=
db
.
Column
(
db
.
Integer
,
comment
=
'相关全企业表数量'
)
...
...
apps/view_atlas/view.py
View file @
f5b3584b
...
@@ -137,6 +137,34 @@ def get_count(industry_id, chain_name, flag):
...
@@ -137,6 +137,34 @@ def get_count(industry_id, chain_name, flag):
Enterprise
.
c_type
==
industry_id
,
Enterprise
.
c_type
==
industry_id
,
)
.
count
()
)
.
count
()
return
company_count
return
company_count
# def get_count(industry_id, chain_name, flag):
# company_count = ''
# if flag == 1: # 晋城
# if chain_name in ["钢铁", "光机电", "煤层气", "装备制造", "铸造",
# "煤化工", "新材料", "绿色建材", "医药", "丝麻纺织服装",
# "现代服务业", "数字经济", "文化旅游"]:
# company_count = Company.query.filter(
# # Company.product_all.like('%{}%'.format(chain_name)),
# Company.c_type == industry_id
# ).count()
# else:
# company_count = Company.query.filter(
# Company.product_all.like('%{}%'.format(chain_name)),
# Company.c_type == industry_id,
# ).count()
# if flag == 2: # 全国
# if chain_name in ["钢铁", "光机电", "煤层气", "装备制造", "铸造",
# "煤化工", "新材料", "绿色建材", "医药", "丝麻纺织服装",
# "现代服务业", "数字经济", "文化旅游"]:
# chain_obj = IndustryChain.query.get(id=industry_id)
# company_count = chain_obj.enterprise_num
# else:
# chain_obj = IndustryChain.query.filter(
# IndustryChain.industry_name == chain_name,
# IndustryChain.chain_id == industry_id,
# ).first()
# company_count = chain_obj.enterprise_num
# return company_count
# def find_up_thr1(industry_type, industry_id):
# def find_up_thr1(industry_type, industry_id):
...
...
enterprise_to_industry_chain.py
View file @
f5b3584b
...
@@ -23,62 +23,59 @@ def handle():
...
@@ -23,62 +23,59 @@ def handle():
# 读取industry_chain数据表的产业名称
# 读取industry_chain数据表的产业名称
num
=
0
num
=
0
for
industry_obj
in
industry_obj_list
:
for
industry_obj
in
industry_obj_list
:
# # 清空原有关联企业
# industry_obj.enterprise = []
# db.session.commit()
industry_name
=
industry_obj
.
industry_name
industry_name
=
industry_obj
.
industry_name
industry_id
=
industry_obj
.
id
industry_id
=
industry_obj
.
id
chain_id
=
industry_obj
.
chain_id
# 读取全国企业表,模糊匹配product_all字段
# 读取全国企业表,模糊匹配product_all字段
if
industry_name
in
[
"钢铁"
,
"光机电"
,
"煤层气"
,
"装备制造"
,
"铸造"
,
if
industry_name
in
[
"钢铁"
,
"光机电"
,
"煤层气"
,
"装备制造"
,
"铸造"
,
"煤化工"
,
"新材料"
,
"绿色建材"
,
"医药"
,
"丝麻纺织服装"
,
"煤化工"
,
"新材料"
,
"绿色建材"
,
"医药"
,
"丝麻纺织服装"
,
"现代服务业"
,
"数字经济"
,
"文化旅游"
]:
"现代服务业"
,
"数字经济"
,
"文化旅游"
]:
print
(
"正在查询【{}】的相关企业......"
.
format
(
industry_name
))
print
(
"正在查询【{}】的相关企业......"
.
format
(
industry_name
))
enterprise_list
=
Enterprise
.
query
.
filter
(
Enterprise
.
c_type
==
industry_id
)
.
all
()
enterprise_list
=
Enterprise
.
query
.
filter
(
Enterprise
.
c_type
==
industry_id
)
.
count
()
else
:
else
:
print
(
"正在查询【{}】的相关企业......"
.
format
(
industry_name
))
print
(
"正在查询【{}】的相关企业......"
.
format
(
industry_name
))
enterprise_list
=
Enterprise
.
query
.
filter
(
Enterprise
.
product_all
.
like
(
"
%
{}
%
"
.
format
(
industry_name
)),
enterprise_list
=
Enterprise
.
query
.
filter
(
Enterprise
.
product_all
.
like
(
"
%
{}
%
"
.
format
(
industry_name
)),
Enterprise
.
c_type
==
industry_id
)
.
all
()
Enterprise
.
c_type
==
chain_id
)
.
count
()
if
not
enterprise_list
:
if
not
enterprise_list
:
continue
enterprise_list
=
0
# 清空原有关联企业
# 清空原有关联企业
enterprise_list_num
=
len
(
enterprise_list
)
#
enterprise_list_num = len(enterprise_list)
industry_obj
.
enterprise_num
=
enterprise_list
_num
industry_obj
.
enterprise_num
=
enterprise_list
industry_obj
.
enterprise
=
[]
#
industry_obj.enterprise = []
db
.
session
.
commit
()
db
.
session
.
commit
()
enterprise_num
=
0
#
enterprise_num = 0
for
enterprise_obj
in
enterprise_list
:
#
for enterprise_obj in enterprise_list:
industry_obj
.
enterprise
.
append
(
enterprise_obj
)
#
industry_obj.enterprise.append(enterprise_obj)
enterprise_num
+=
1
#
enterprise_num += 1
enterprise_list_num
-=
1
#
enterprise_list_num -= 1
if
enterprise_num
>=
5
00
:
# if enterprise_num >= 1
00:
db
.
session
.
commit
()
#
db.session.commit()
enterprise_num
=
0
#
enterprise_num = 0
continue
#
continue
elif
enterprise_list_num
==
0
and
enterprise_num
==
400
:
# #
elif enterprise_list_num == 0 and enterprise_num == 400:
db
.
session
.
commit
()
# #
db.session.commit()
enterprise_num
=
0
# #
enterprise_num = 0
continue
# #
continue
elif
enterprise_list_num
==
0
and
enterprise_num
==
300
:
# #
elif enterprise_list_num == 0 and enterprise_num == 300:
db
.
session
.
commit
()
# #
db.session.commit()
enterprise_num
=
0
# #
enterprise_num = 0
continue
# #
continue
elif
enterprise_list_num
==
0
and
enterprise_num
==
200
:
# #
elif enterprise_list_num == 0 and enterprise_num == 200:
db
.
session
.
commit
()
# #
db.session.commit()
enterprise_num
=
0
# #
enterprise_num = 0
continue
# #
continue
elif
enterprise_list_num
==
0
and
enterprise_num
==
100
:
# #
elif enterprise_list_num == 0 and enterprise_num == 100:
db
.
session
.
commit
()
# #
db.session.commit()
enterprise_num
=
0
# #
enterprise_num = 0
continue
# #
continue
else
:
#
else:
pass
#
pass
db
.
session
.
commit
()
#
db.session.commit()
# continue
# continue
print
(
"产业链【{}】已完成
"
.
format
(
industry_name
))
print
(
"产业链【{}】已完成
, 数量【{}】个"
.
format
(
industry_name
,
enterprise_list
))
continue
continue
# enterprise_num += 1
# enterprise_num += 1
...
...
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