Commit ced9c00f by dong

fix20230407

parent 48ffdf42
...@@ -154,19 +154,7 @@ def attract_cnums(): ...@@ -154,19 +154,7 @@ def attract_cnums():
)) ))
company1 = [] company1 = []
if product: if product:
product_li = get_product_li(product) company1, size = get_enterprise_num(product, inid)
for product in product_li:
enterprise2 = ''
enterprise2 = enterprise.filter(or_(
Enterprise.product_all.like("%{}%".format(product)),
Enterprise.product_all1.like("%{}%".format(product)),
Enterprise.product_all2.like("%{}%".format(product))
)).all()
company1 += enterprise2
company1 = list(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: else:
pass pass
# print(enterprise) # print(enterprise)
...@@ -411,6 +399,37 @@ def search_enterprise(): ...@@ -411,6 +399,37 @@ def search_enterprise():
return jsonify(code=RET.DBERR, msg='查询出错!') return jsonify(code=RET.DBERR, msg='查询出错!')
def get_enterprise_num(product, inid):
indu_obj_li = get_product_li(product)
# 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 == inid,
Enterprise.product_all.like("%{}%".format(indu_name))
).all()
company += company1
# print(company1)
company2 = Enterprise.query.filter(
Enterprise.c_type1 == inid,
Enterprise.product_all1.like("%{}%".format(indu_name))
).all()
company += company2
# print(company2)
company3 = Enterprise.query.filter(
Enterprise.c_type2 == inid,
Enterprise.product_all2.like("%{}%".format(indu_name))
).all()
company += company3
# print("产品【{}】已完成, 共有{}家相关企业。".format(indu_name, len(company1 + company2 + company3)))
company = set(company) # 去重
size = len(company)
return company, size
# 全国企业列表 # 全国企业列表
@api_map.route('/AttractEnterprise', methods=['POST']) @api_map.route('/AttractEnterprise', methods=['POST'])
def attract_enterprise(): def attract_enterprise():
...@@ -471,19 +490,8 @@ def attract_enterprise(): ...@@ -471,19 +490,8 @@ def attract_enterprise():
Enterprise.serve == '1' if qualificat == '限额以上服务业企业' else text('') Enterprise.serve == '1' if qualificat == '限额以上服务业企业' else text('')
) )
if product: if product:
company1 = [] company, size = get_enterprise_num(product, inid)
product_li = get_product_li(product) company1 = sorted(company, key=lambda x: x.hots, reverse=True) # 排序
for product in product_li:
enterprise2 = ''
enterprise2 = enterprise.filter(or_(
Enterprise.product_all.like("%{}%".format(product)),
Enterprise.product_all1.like("%{}%".format(product)),
Enterprise.product_all2.like("%{}%".format(product))
)).all()
company1 += enterprise2
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] # 分页 enterprise_obj_list = company1[(page - 1) * perpage:page * perpage] # 分页
else: else:
size = enterprise.count() size = enterprise.count()
......
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