Commit 108ba6b2 by dong

fix20230721

parent ebf4a949
......@@ -43,6 +43,22 @@ class IndustryChain(db.Model):
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):
__tablename__ = "enterprise"
......
# # # -*- coding:utf-8 -*-
# import threading
# from apps.models import IndustryChain, Enterprise
# from apps.models import IndustryChain1, Enterprise
# from manager import app
# from apps import db
#
#
# """
# IndustryChain或者Enterprise数据表更新后,
# 计算产业环节相关企业的数量并填充到IndustryChain的enterprise_num字段中。
# IndustryChain1或者Enterprise数据表更新后,
# 计算产业环节相关企业的数量并填充到IndustryChain1的enterprise_num字段中。
# """
#
#
# def handle():
# with app.app_context():
# industry_obj_list = IndustryChain.query.all()
# industry_obj_list = IndustryChain1.query.all()
# print(industry_obj_list)
# # 读取industry_chain数据表的产业名称
# for industry_obj in industry_obj_list:
......@@ -27,7 +27,7 @@
# continue
#
# else:
# indu_obj_li = IndustryChain.query.filter(IndustryChain.relate_id == indu_id).all()
# indu_obj_li = IndustryChain1.query.filter(IndustryChain1.relate_id == indu_id).all()
# for indu_obj in indu_obj_li:
# indu_name = indu_obj.industry_name
# print("正在查询【{}】的相关企业......".format(indu_name))
......@@ -59,29 +59,29 @@
# # -*- coding:utf-8 -*-
import threading
from apps.models import IndustryChain, Enterprise
from apps.models import IndustryChain1, Enterprise
from manager import app
from apps import db
"""
IndustryChain或者Enterprise数据表更新后,
计算产业环节相关企业去重后的数量并填充到IndustryChain的enterprise_num字段中。
IndustryChain1或者Enterprise数据表更新后,
计算产业环节相关企业去重后的数量并填充到IndustryChain1的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_id = IndustryChain1.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()
chain_one_obj_list = IndustryChain1.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()
chain_two_obj_list = IndustryChain1.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]
......@@ -89,7 +89,7 @@ def get_product_li(product, chain_id):
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()
chain_three_obj_list = IndustryChain1.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]
......@@ -97,7 +97,7 @@ def get_product_li(product, chain_id):
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()
chain_four_obj_list = IndustryChain1.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]
......@@ -108,8 +108,8 @@ def get_product_li(product, chain_id):
def handle():
with app.app_context():
industry_obj_list = IndustryChain.query.all()
# industry_obj_list = IndustryChain.query.filter(IndustryChain.id == 604).all()
industry_obj_list = IndustryChain1.query.all()
# industry_obj_list = IndustryChain1.query.filter(IndustryChain1.id == 604).all()
# print(industry_obj_list)
# 读取industry_chain数据表的产业名称
for industry_obj in industry_obj_list:
......
......@@ -14,6 +14,7 @@ from datetime import datetime
# import datetime
from apps import db, constants, redis_store
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
......@@ -1214,6 +1215,9 @@ def radar_enums():
enterprise = enterprise.filter_by(city=city)
if district:
enterprise = enterprise.filter_by(district=district)
indu_obj_li = get_product_li(product, inid)
if product:
# 有可能会变成模糊查询
enterprise = enterprise.filter(or_(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment