Commit 2e1140de by dong

fix20230331

parent 119e1bfc
......@@ -264,9 +264,8 @@ def search():
try:
es = Elasticsearch([{'host': '39.100.39.50', 'port': 9200}])
# data = es.search(index="jincheng_pictext_index_202301131004_a6181e52", body=body)
# data = es.search(index="jincheng_pictext_index_202302281056_9053decc", body=body)
data = es.search(index="jincheng_pictext_index_202303161620_76c624b8", body=body)
# data = es.search(index="jincheng_pictext_index_202303161620_76c624b8", body=body)
data = es.search(index="jc_enterperise1", body=body)
data_list = []
# print(data_list)
size = data["hits"]['total']
......
......@@ -1108,7 +1108,7 @@ def search_enterprise():
return jsonify(code=RET.DBERR, msg='查询出错!')
def get_company_li(product):
def get_product_li(product):
res_two_li = []
res_three_li = []
product_id = IndustryChain.query.filter_by(industry_name=product).first().id
......@@ -1189,7 +1189,7 @@ def industry_enterprise():
if product:
# 点击上级环节,展示本级所有企业
product_li = get_company_li(product)
product_li = get_product_li(product)
company1 = []
for product in product_li:
company2 = ''
......@@ -1199,8 +1199,8 @@ def industry_enterprise():
company1 += company2
company1 = set(company1)
size = len(company1)
company1 = sorted(company1, key=lambda x: x.hots, reverse=True)
companys = company1[(page - 1) * perpage:page * perpage]
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:
......
......@@ -11,6 +11,7 @@ import json
import requests
from apps import db, constants, redis_store
from apps.view_360company.view import create_body
from view_atlas.view import get_product_li
'''本页接口使用全国企业库enterprise'''
graph = conn_neo4j()
......@@ -417,12 +418,6 @@ def attract_enterprise():
Enterprise.c_type1 == inid,
Enterprise.c_type2 == inid
))
if product:
enterprise = enterprise.filter(or_(
Enterprise.product_all.like("%{}%".format(product)),
Enterprise.product_all1.like("%{}%".format(product)),
Enterprise.product_all2.like("%{}%".format(product))
))
enterprise_obj = enterprise.filter(
# Enterprise.product_all.like("%{}%".format(product)) if product else text(''),
......@@ -445,7 +440,21 @@ def attract_enterprise():
Enterprise.chain_master == '1' if qualificat == '链主企业' else text(''),
Enterprise.serve == '1' if qualificat == '限额以上服务业企业' else text('')
)
if product:
company1 = []
product_li = get_product_li(product)
for product in product_li:
enterprise = enterprise.filter(or_(
Enterprise.product_all.like("%{}%".format(product)),
Enterprise.product_all1.like("%{}%".format(product)),
Enterprise.product_all2.like("%{}%".format(product))
)).all()
company1 += enterprise
company1 = set(company1)
size = len(company1)
company1 = sorted(company1, key=lambda x: x.hots, reverse=True) # 排序
enterprise_obj_list = company1[(page - 1) * perpage:page * perpage] # 分页
else:
size = enterprise_obj.count()
enterprise_obj_list = enterprise_obj.order_by(Enterprise.hots.desc()).paginate(page, perpage).items
......
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