Commit b1c0e280 by dong

Merge remote-tracking branch 'origin/master'

parents 54f72912 d7013478
...@@ -1215,23 +1215,59 @@ def radar_enums(): ...@@ -1215,23 +1215,59 @@ def radar_enums():
enterprise = enterprise.filter_by(city=city) enterprise = enterprise.filter_by(city=city)
if district: if district:
enterprise = enterprise.filter_by(district=district) enterprise = enterprise.filter_by(district=district)
size = []
if product: if product:
# 有可能会变成模糊查询 # 有可能会变成模糊查询
enterprise = enterprise.filter(or_( # enterprise = enterprise.filter(or_(
Enterprise.product_all.like("%{}%".format(product)), # Enterprise.product_all.like("%{}%".format(product)),
Enterprise.product_all1.like("%{}%".format(product)), # Enterprise.product_all1.like("%{}%".format(product)),
Enterprise.product_all2.like("%{}%".format(product)) # Enterprise.product_all2.like("%{}%".format(product))
) # ))
) company = []
nums_all = enterprise.count() # 企业总数 indu_obj_li = get_product_li(product, inid)
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 = list(set(company))
size = len(company)
nums_all = size if size else enterprise.count() # 企业总数
nums_dengl = enterprise.filter_by(dengl="1").count() # 瞪羚企业 if product:
nums_hignew = enterprise.filter_by(high_new="1").count() # 高新技术企业 nums_dengl = len([tmp.id for tmp in company if tmp.dengl == "1"]) # 瞪羚企业
nums_tbe = enterprise.filter_by(tbe="1").count() # 科技型中小企业 nums_hignew = len([tmp.id for tmp in company if tmp.high_new == "1"]) # 高新技术企业
nums_quoted = enterprise.filter_by(quoted_company="1").count() # 上市企业 nums_tbe = len([tmp.id for tmp in company if tmp.tbe == "1"]) # 科技型中小企业
nums_financ = enterprise.filter_by(fianacing="1").count() # 有融资小企业 nums_quoted = len([tmp.id for tmp in company if tmp.quoted_company == "1"]) # 上市企业
nums_unicorn = enterprise.filter_by(unicorn="1").count() # 独角兽企业 nums_financ = len([tmp.id for tmp in company if tmp.fianacing == "1"]) # 有融资小企业
nums_unicorn = len([tmp.id for tmp in company if tmp.unicorn == "1"]) # 独角兽企业
else:
nums_dengl = enterprise.filter(Enterprise.dengl == "1").count() # 瞪羚企业
nums_hignew = enterprise.filter(Enterprise.high_new == "1").count() # 高新技术企业
nums_tbe = enterprise.filter(Enterprise.tbe == "1").count() # 科技型中小企业
nums_quoted = enterprise.filter(Enterprise.quoted_company == "1").count() # 上市企业
nums_financ = enterprise.filter(Enterprise.fianacing == "1").count() # 有融资小企业
nums_unicorn = enterprise.filter(Enterprise.unicorn == "1").count() # 独角兽企业
nums_capital = round( nums_capital = round(
float(enterprise.with_entities(func.sum(Enterprise.capital_nums)).scalar() if enterprise.with_entities( float(enterprise.with_entities(func.sum(Enterprise.capital_nums)).scalar() if enterprise.with_entities(
...@@ -1251,13 +1287,14 @@ def radar_enums(): ...@@ -1251,13 +1287,14 @@ def radar_enums():
redis_store.setex(name_query, 30 * 24 * 3600, json.dumps(data)) redis_store.setex(name_query, 30 * 24 * 3600, json.dumps(data))
# redis_store.set(name_query, json.dumps(data)) # redis_store.set(name_query, json.dumps(data))
# redis_store.expire(name_query, 30 * 24 * 3600) # redis_store.expire(name_query, 30 * 24 * 3600)
print("redis") # print("redis")
return jsonify(code=RET.OK, msg="获取成功", data=data) return jsonify(code=RET.OK, msg="获取成功", data=data)
except Exception as e: except Exception as e:
current_app.logger.error(e) current_app.logger.error(e)
return jsonify(code=RET.DBERR, msg="数据库查询错误") return jsonify(code=RET.DBERR, msg="数据库查询错误")
def get_product_li(product, chain_id): def get_product_li(product, chain_id):
res_two_li = [] res_two_li = []
res_three_li = [] res_three_li = []
...@@ -1441,12 +1478,36 @@ def newList1(): ...@@ -1441,12 +1478,36 @@ def newList1():
enterprise = enterprise.filter_by(city=city) enterprise = enterprise.filter_by(city=city)
if district: if district:
enterprise = enterprise.filter_by(district=district) enterprise = enterprise.filter_by(district=district)
company = []
if product: if product:
enterprise = enterprise.filter(or_( # enterprise = enterprise.filter(or_(
Enterprise.product_all.like("%{}%".format(product)), # Enterprise.product_all.like("%{}%".format(product)),
Enterprise.product_all1.like("%{}%".format(product)), # Enterprise.product_all1.like("%{}%".format(product)),
Enterprise.product_all2.like("%{}%".format(product)) # Enterprise.product_all2.like("%{}%".format(product))
)) # ))
indu_obj_li = get_product_li(product, inid)
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
company = set(company)
if name: if name:
enterprise = enterprise.filter(Enterprise.company_name.like("%{}%".format(name))) enterprise = enterprise.filter(Enterprise.company_name.like("%{}%".format(name)))
if select == "1": # 瞪羚 if select == "1": # 瞪羚
...@@ -1472,6 +1533,36 @@ def newList1(): ...@@ -1472,6 +1533,36 @@ def newList1():
enterprise = enterprise enterprise = enterprise
size = enterprise.count() size = enterprise.count()
enters = enterprise.order_by(Enterprise.hots.desc()).paginate(page, perpage).items enters = enterprise.order_by(Enterprise.hots.desc()).paginate(page, perpage).items
if product:
if select == "1": # 瞪羚
remind = "瞪羚企业"
company = [tmp for tmp in company if tmp.dengl == "1"]
elif select == "2": # 高新
remind = "高新技术企业"
company = [tmp for tmp in company if tmp.high_new == "1"]
elif select == "3": # 科技型中小企业
remind = "科技型中小企业"
company = [tmp for tmp in company if tmp.tbe == "1"]
elif select == "4": # 上市
remind = "上市企业"
company = [tmp for tmp in company if tmp.quoted_company == "1"]
elif select == "5": # 融资
remind = "融资企业"
company = [tmp for tmp in company if tmp.fianacing == "1"]
elif select == "6": # 独角兽
remind = "独角兽企业"
company = [tmp for tmp in company if tmp.unicorn == "1"]
size = len(company)
company1 = sorted(company, key=lambda x: x.hots, reverse=True) # 排序
enterprise_obj_list = company1[(page - 1) * perpage:page * perpage] # 分页
enter = [{"id": i.id,
"name": i.company_name,
"hots": i.hots,
"industry": i.company_industry if i.company_industry else "-", # 行业
"build_date": str(i.build_date)[:10] if i.build_date else "-", # 时间
"capital": i.capital if i.capital else "-", # 注册资本
} for i in enterprise_obj_list]
else:
enter = [{"id": i.id, enter = [{"id": i.id,
"name": i.company_name, "name": i.company_name,
"hots": i.hots, "hots": i.hots,
......
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