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
40d16fe8
Commit
40d16fe8
authored
Jul 06, 2023
by
dong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix20230706
parent
edb51ccb
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
166 additions
and
69 deletions
+166
-69
apps/utils/industry_enterprise_num.py
+160
-0
apps/utils/insert_chain_master.py
+0
-0
apps/utils/insert_company_hots.py
+3
-13
apps/utils/merge_company.py
+0
-0
apps/view_atlas/view_es_con.py
+3
-0
industry_enterprise_num.py
+0
-56
No files found.
apps/utils/industry_enterprise_num.py
0 → 100644
View file @
40d16fe8
# # # -*- coding:utf-8 -*-
# import threading
# from apps.models import IndustryChain, Enterprise
# from manager import app
# from apps import db
#
#
# """
# IndustryChain或者Enterprise数据表更新后,
# 计算产业环节相关企业的数量并填充到IndustryChain的enterprise_num字段中。
# """
#
#
# def handle():
# with app.app_context():
# industry_obj_list = IndustryChain.query.all()
# print(industry_obj_list)
# # 读取industry_chain数据表的产业名称
# for industry_obj in industry_obj_list:
# industry_name = industry_obj.industry_name
# indu_id = industry_obj.id
# chain_id = industry_obj.chain_id
# # 读取全国企业表,模糊匹配product_all字段
# if industry_name in ["钢铁", "光机电", "煤层气", "装备制造", "铸造",
# "煤化工", "新材料", "绿色建材", "医药", "丝麻纺织服装",
# "现代服务业", "数字经济", "文化旅游"]:
# continue
#
# else:
# indu_obj_li = IndustryChain.query.filter(IndustryChain.relate_id == indu_id).all()
# for indu_obj in indu_obj_li:
# indu_name = indu_obj.industry_name
# print("正在查询【{}】的相关企业......".format(indu_name))
# enterprise_num1 = Enterprise.query.filter(
# Enterprise.c_type == chain_id,
# Enterprise.product_all.like("%{}%".format(industry_name))
# ).count()
# print(enterprise_num1)
# enterprise_num2 = Enterprise.query.filter(
# Enterprise.c_type1 == chain_id,
# Enterprise.product_all1.like("%{}%".format(industry_name))
# ).count()
# print(enterprise_num2)
# enterprise_num3 = Enterprise.query.filter(
# Enterprise.c_type2 == chain_id,
# Enterprise.product_all2.like("%{}%".format(industry_name))
# ).count()
# print(enterprise_num3)
# enterprise_num = enterprise_num1 + enterprise_num2 + enterprise_num3
# industry_obj.enterprise_num = enterprise_num
# # db.session.commit()
# print("产品【{}】已完成, 共有{}家相关企业。".format(indu_name, enterprise_num))
#
#
# if __name__ == '__main__':
# t = threading.Thread(target=handle)
# t.start()
# # -*- coding:utf-8 -*-
import
threading
from
apps.models
import
IndustryChain
,
Enterprise
from
manager
import
app
from
apps
import
db
"""
IndustryChain或者Enterprise数据表更新后,
计算产业环节相关企业去重后的数量并填充到IndustryChain的enterprise_num字段中。
"""
def
get_product_li
(
product
,
chain_id
):
res_two_li
=
[]
res_three_li
=
[]
product_id
=
IndustryChain
.
query
.
filter_by
(
industry_name
=
product
,
chain_id
=
chain_id
)
.
first
()
.
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
()
res_one_li
=
[{
"chain_name"
:
chain_one_obj
.
industry_name
,
"chain_name_id"
:
chain_one_obj
.
id
}
for
chain_one_obj
in
chain_one_obj_list
]
for
res_one
in
res_one_li
:
chain_two_obj_list
=
IndustryChain
.
query
.
filter_by
(
relate_id
=
res_one
[
"chain_name_id"
])
.
all
()
res_two
=
[{
"chain_name"
:
chain_one_obj
.
industry_name
,
"chain_name_id"
:
chain_one_obj
.
id
}
for
chain_one_obj
in
chain_two_obj_list
]
res_two_li
.
extend
(
res_two
)
res_one_li
.
extend
(
res_two
)
for
res_two
in
res_two_li
:
chain_three_obj_list
=
IndustryChain
.
query
.
filter_by
(
relate_id
=
res_two
[
"chain_name_id"
])
.
all
()
res_three
=
[{
"chain_name"
:
chain_one_obj
.
industry_name
,
"chain_name_id"
:
chain_one_obj
.
id
}
for
chain_one_obj
in
chain_three_obj_list
]
res_three_li
.
extend
(
res_three
)
res_one_li
.
extend
(
res_three
)
# print(res_one_li)
for
res_three
in
res_three_li
:
chain_four_obj_list
=
IndustryChain
.
query
.
filter_by
(
relate_id
=
res_three
[
"chain_name_id"
])
.
all
()
res_four
=
[{
"chain_name"
:
chain_one_obj
.
industry_name
,
"chain_name_id"
:
chain_one_obj
.
id
}
for
chain_one_obj
in
chain_four_obj_list
]
res_one_li
.
extend
(
res_four
)
res_one_li
.
extend
(
product_li
)
return
[
res_one
[
"chain_name"
]
for
res_one
in
res_one_li
]
def
handle
():
with
app
.
app_context
():
industry_obj_list
=
IndustryChain
.
query
.
all
()
# industry_obj_list = IndustryChain.query.filter(IndustryChain.id == 604).all()
# print(industry_obj_list)
# 读取industry_chain数据表的产业名称
for
industry_obj
in
industry_obj_list
:
industry_name
=
industry_obj
.
industry_name
# 读取全国企业表,模糊匹配product_all字段
if
industry_name
in
[
"钢铁"
,
"光机电"
,
"煤层气"
,
"装备制造"
,
"铸造"
,
"煤化工"
,
"新材料"
,
"绿色建材"
,
"医药"
,
"丝麻纺织服装"
,
"现代服务业"
,
"数字经济"
,
"文化旅游"
]:
continue
else
:
chain_id
=
industry_obj
.
chain_id
indu_obj_li
=
get_product_li
(
industry_name
,
chain_id
)
# total_enterprise_num = 0
company
=
[]
for
indu_name
in
indu_obj_li
:
# indu_name = indu_obj.industry_name
print
(
"正在查询【{}】的相关企业......"
.
format
(
indu_name
))
company1
=
Enterprise
.
query
.
filter
(
Enterprise
.
c_type
==
chain_id
,
Enterprise
.
product_all
.
like
(
"
%
{}
%
"
.
format
(
indu_name
))
)
.
all
()
company
+=
company1
# print(company1)
company2
=
Enterprise
.
query
.
filter
(
Enterprise
.
c_type1
==
chain_id
,
Enterprise
.
product_all1
.
like
(
"
%
{}
%
"
.
format
(
indu_name
))
)
.
all
()
company
+=
company2
# print(company2)
company3
=
Enterprise
.
query
.
filter
(
Enterprise
.
c_type2
==
chain_id
,
Enterprise
.
product_all2
.
like
(
"
%
{}
%
"
.
format
(
indu_name
))
)
.
all
()
company
+=
company3
print
(
"产品【{}】已完成, 共有{}家相关企业。"
.
format
(
indu_name
,
len
(
company1
+
company2
+
company3
)))
company
=
set
(
company
)
# 去重
enterprise_num
=
len
(
company
)
industry_obj
.
enterprise_num
=
enterprise_num
db
.
session
.
commit
()
print
(
"=======产品【{}】已完成, 共有{}家相关企业=======。"
.
format
(
industry_name
,
enterprise_num
))
if
__name__
==
'__main__'
:
t
=
threading
.
Thread
(
target
=
handle
)
t
.
start
()
insert_chain_master.py
→
apps/utils/
insert_chain_master.py
View file @
40d16fe8
File moved
insert_company_hots.py
→
apps/utils/
insert_company_hots.py
View file @
40d16fe8
...
...
@@ -12,23 +12,13 @@ from apps import db
def
handle
():
with
app
.
app_context
():
#
company_obj_list = Company.query.all()
company_obj_list
=
Enterprise
.
query
.
get
(
1111
)
company_obj_list
=
Company
.
query
.
all
()
# company_obj_list = Enterprise.query.all(
)
# print(company_obj_list)
# 读取企业数据表的资质
i
=
1
for
company_obj
in
company_obj_list
:
# for id in range(305515, 5944047):
# try:
# company_obj = Enterprise.query.get(id)
# if not company_obj:
# continue
# except:
# continue
grade_li
=
[]
# if company_obj.company_name == '山东中联佳裕软件股份有限公司':
# print('--')
if
company_obj
.
isfive
and
company_obj
.
isfive
==
'1'
:
# 五百强
grade_li
.
append
(
5
)
else
:
...
...
@@ -79,7 +69,7 @@ def handle():
total_grede
=
0
company_obj
.
hots
=
total_grede
db
.
session
.
commit
()
print
(
str
(
i
/
5944031
*
100
)
+
'
%
'
)
print
(
str
(
i
/
975
*
100
)
+
'
%
'
)
i
+=
1
...
...
merge_company.py
→
apps/utils/
merge_company.py
View file @
40d16fe8
File moved
apps/view_atlas/view_es_con.py
View file @
40d16fe8
...
...
@@ -357,6 +357,9 @@ def find_next():
return
jsonify
(
code
=
RET
.
OK
,
msg
=
"获取成功"
,
data
=
result
)
else
:
return
jsonify
(
code
=
RET
.
NODATA
,
msg
=
"无数据"
)
else
:
return
jsonify
(
code
=
RET
.
NODATA
,
msg
=
"无数据"
)
except
Exception
as
e
:
current_app
.
logger
.
error
(
e
)
return
jsonify
(
code
=
RET
.
DBERR
,
msg
=
"数据异常"
,
data
=
{})
...
...
industry_enterprise_num.py
deleted
100644 → 0
View file @
edb51ccb
# # -*- coding:utf-8 -*-
import
threading
from
apps.models
import
IndustryChain
,
Enterprise
from
manager
import
app
from
apps
import
db
"""
IndustryChain或者Enterprise数据表更新后,
计算产业环节相关企业的数量并填充到IndustryChain的enterprise_num字段中。
"""
def
handle
():
with
app
.
app_context
():
industry_obj_list
=
IndustryChain
.
query
.
all
()
print
(
industry_obj_list
)
# 读取industry_chain数据表的产业名称
for
industry_obj
in
industry_obj_list
:
industry_name
=
industry_obj
.
industry_name
indu_id
=
industry_obj
.
id
chain_id
=
industry_obj
.
chain_id
# 读取全国企业表,模糊匹配product_all字段
if
industry_name
in
[
"钢铁"
,
"光机电"
,
"煤层气"
,
"装备制造"
,
"铸造"
,
"煤化工"
,
"新材料"
,
"绿色建材"
,
"医药"
,
"丝麻纺织服装"
,
"现代服务业"
,
"数字经济"
,
"文化旅游"
]:
continue
else
:
indu_obj_li
=
IndustryChain
.
query
.
filter
(
relate_id
=
indu_id
)
.
all
()
for
indu_obj
in
indu_obj_li
:
indu_name
=
indu_obj
.
industry_name
print
(
"正在查询【{}】的相关企业......"
.
format
(
indu_name
))
enterprise_num1
=
Enterprise
.
query
.
filter
(
Enterprise
.
c_type
==
chain_id
,
Enterprise
.
product_all
.
like
(
"
%
{}
%
"
.
format
(
industry_name
))
)
.
count
()
enterprise_num2
=
Enterprise
.
query
.
filter
(
Enterprise
.
c_type1
==
chain_id
,
Enterprise
.
product_all1
.
like
(
"
%
{}
%
"
.
format
(
industry_name
))
)
.
count
()
enterprise_num3
=
Enterprise
.
query
.
filter
(
Enterprise
.
c_type2
==
chain_id
,
Enterprise
.
product_all2
.
like
(
"
%
{}
%
"
.
format
(
industry_name
))
)
.
count
()
enterprise_num
=
enterprise_num1
+
enterprise_num2
+
enterprise_num3
industry_obj
.
enterprise_num
=
enterprise_num
db
.
session
.
commit
()
print
(
"产品【{}】已完成, 共有{}家相关企业。"
.
format
(
industry_name
,
enterprise_num
))
if
__name__
==
'__main__'
:
t
=
threading
.
Thread
(
target
=
handle
)
t
.
start
()
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