Commit b6cfee50 by dong

fix20230328

parent 4c60aeda
...@@ -1108,6 +1108,42 @@ def search_enterprise(): ...@@ -1108,6 +1108,42 @@ def search_enterprise():
return jsonify(code=RET.DBERR, msg='查询出错!') return jsonify(code=RET.DBERR, msg='查询出错!')
def get_company_li(product):
res_two_li = []
res_three_li = []
product_id = IndustryChain.query.filter_by(industry_name=product).first().id
product_li = [{"chain_name": product, "chain_name_id": product_id}]
chain_one_obj_list = IndustryChain.query.filter_by(relate_id=product_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]
# 点击产业联动显示企业 # 点击产业联动显示企业
@api_atlas.route('/industry/enterprise', methods=['POST']) @api_atlas.route('/industry/enterprise', methods=['POST'])
# @login_required # @login_required
...@@ -1135,12 +1171,8 @@ def industry_enterprise(): ...@@ -1135,12 +1171,8 @@ def industry_enterprise():
Company.company_name.like('%{}%'.format(company_name)) if company_name else text(''), Company.company_name.like('%{}%'.format(company_name)) if company_name else text(''),
Company.status == status if status else text('') Company.status == status if status else text('')
) )
# if industry_level == 1:
company = company.filter(Company.c_type == inid) company = company.filter(Company.c_type == inid)
# else:
if product:
company = company.filter(Company.product_all.like("%{}%".format(product)))
company = company.filter( company = company.filter(
Company.high_new == '1' if aptitude == '高新技术企业' else text(''), Company.high_new == '1' if aptitude == '高新技术企业' else text(''),
Company.tbe == '1' if aptitude == '科技型中小企业' else text(''), Company.tbe == '1' if aptitude == '科技型中小企业' else text(''),
...@@ -1154,8 +1186,26 @@ def industry_enterprise(): ...@@ -1154,8 +1186,26 @@ def industry_enterprise():
Company.serve == '1' if aptitude == '限额以上服务业' else text(''), Company.serve == '1' if aptitude == '限额以上服务业' else text(''),
Company.chain_master == '1' if aptitude == '链主企业' else text(''), Company.chain_master == '1' if aptitude == '链主企业' else text(''),
) )
size = company.count()
companys = company.order_by(Company.hots.desc()).paginate(page, perpage).items # 企业热度倒序 if product:
# 点击上级环节,展示本级所有企业
product_li = get_company_li(product)
company1 = []
for product in product_li:
company2 = ''
company2 = company.filter(
Company.product_all.like("%{}%".format(product))
).all()
company1 += company2
size = len(set(company1))
company1 = sorted(company1, key=lambda x: x.hots, reverse=True)
companys = company1[(page - 1) * perpage:page * perpage]
# companys = company1.order_by(Company.hots.desc()).paginate(page, perpage).items # 企业热度倒序
else:
size = company.count()
companys = company.order_by(Company.hots.desc()).paginate(page, perpage).items # 企业热度倒序
df = [{"id": i.id, df = [{"id": i.id,
"company_name": i.company_name, "company_name": i.company_name,
......
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