Commit 7c8a5980 by ma_dev

更新产业招商雷达企业速览和企业列表

parent 5af42a53
......@@ -1216,50 +1216,48 @@ def radar_enums():
if district:
enterprise = enterprise.filter_by(district=district)
# if product:
# # 有可能会变成模糊查询
# enterprise = enterprise.filter(or_(
# Enterprise.product_all.like("%{}%".format(product)),
# Enterprise.product_all1.like("%{}%".format(product)),
# Enterprise.product_all2.like("%{}%".format(product))
# )
# )
# 统计企业数量
# name_map_value = {}
# if product:
# industry_obj = IndustryChain.query.filter_by(industry_name=product).first()
# industry_id = industry_obj.chain_id
# chain_id = industry_obj.chain_id
# result = redis_store.get('chain_id_{}'.format(industry_id))
# if result:
# result = json.loads(result)
# nodeList = result.get("nodeList")
# else:
# flag = 2
# nodeList = [find_up_thr1(chain_id, 1, industry_id, flag),
# find_up_thr1(chain_id, 2, industry_id, flag),
# find_up_thr1(chain_id, 3, industry_id, flag)]
# for node1 in nodeList:
# for node2 in node1["subNodeList"]:
# name_map_value[node2["node"]] = node2["enterprise_count"]
# for node3 in node2["subNodeList"]:
# name_map_value[node3["node"]] = node3["enterprise_count"]
# for node4 in node3["subNodeList"]:
# name_map_value[node4["node"]] = node4["enterprise_count"]
# nums_all = name_map_value.get(product) if name_map_value.get(product) else enterprise.count() # 企业总数
# nums_all = enterprise.count() # 企业总数
industry_obj = IndustryChain.query.filter_by(industry_name=product).first()
nums_all = industry_obj.enterprise_num if industry_obj else enterprise.count()
nums_dengl = enterprise.filter_by(dengl="1").count() # 瞪羚企业
nums_hignew = enterprise.filter_by(high_new="1").count() # 高新技术企业
nums_tbe = enterprise.filter_by(tbe="1").count() # 科技型中小企业
nums_quoted = enterprise.filter_by(quoted_company="1").count() # 上市企业
nums_financ = enterprise.filter_by(fianacing="1").count() # 有融资小企业
nums_unicorn = enterprise.filter_by(unicorn="1").count() # 独角兽企业
company = []
if product:
# 有可能会变成模糊查询
# enterprise = enterprise.filter(or_(
# Enterprise.product_all.like("%{}%".format(product)),
# Enterprise.product_all1.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
# print("产品【{}】已完成, 共有{}家相关企业。".format(indu_name, len(company1 + company2 + company3)))
company = len(set(company))
nums_all = company if company else enterprise.count() # 企业总数
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(
float(enterprise.with_entities(func.sum(Enterprise.capital_nums)).scalar() if enterprise.with_entities(
......@@ -1286,6 +1284,7 @@ def radar_enums():
current_app.logger.error(e)
return jsonify(code=RET.DBERR, msg="数据库查询错误")
def get_product_li(product, chain_id):
res_two_li = []
res_three_li = []
......@@ -1469,12 +1468,36 @@ def newList1():
enterprise = enterprise.filter_by(city=city)
if district:
enterprise = enterprise.filter_by(district=district)
company = []
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 = enterprise.filter(or_(
# Enterprise.product_all.like("%{}%".format(product)),
# Enterprise.product_all1.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:
enterprise = enterprise.filter(Enterprise.company_name.like("%{}%".format(name)))
if select == "1": # 瞪羚
......@@ -1500,13 +1523,25 @@ def newList1():
enterprise = enterprise
size = enterprise.count()
enters = enterprise.order_by(Enterprise.hots.desc()).paginate(page, perpage).items
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 enters]
if product:
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,
"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 enters]
data = {"remind": remind, "enter": enter, "size": size}
......
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