Commit 5ad47d48 by dong

fix202302017

parent 6493e675
......@@ -390,6 +390,12 @@ def attract_enterprise():
district = area[2]
page = req_dict.get("page") # 分页页码
perpage = req_dict.get("perpage") # 分页大小
name_query = "AttractEnterprise" + str(inid) + province + city + district + product
if redis_store.get(name_query) is not None:
data = json.loads(redis_store.get(name_query))
return jsonify(code=RET.OK, msg="获取成功", data=data)
if not all([page, perpage]):
return jsonify(code=RET.PARAMERR, msg="参数不完整")
......@@ -447,5 +453,157 @@ def attract_enterprise():
except Exception as e:
current_app.logger.error(e)
return jsonify(code=RET.DBERR, msg="数据库查询错误")
# redis缓存
try:
redis_store.setex(name_query, 30 * 24 * 3600, json.dumps(data))
except:
return jsonify(code=RET.DBERR, msg="redis保存失败!")
return jsonify(code=RET.OK, msg="获取成功", data=data)
# 全国企业列表(Es)
# @api_map.route('/AttractEnterpriseEs', methods=['POST'])
# def attract_enterprise_es():
# req_dict = request.get_json()
# inid = req_dict.get("inid") # 行业id
# company_name = req_dict.get("company_name") # 产业产品名称筛选
# entype = req_dict.get("entype") # 企业类型id
# qualificat = req_dict.get("qualificat") # 企业资质id
# quoted = req_dict.get("quoted") # 上市板块(A股,1)(创业股,2)(港股,3)(新三股,4)(新四股,5)(中小板,6)
# product = req_dict.get("product") # 产业产品选择
#
# area = req_dict.get("area") # ["省","市","区"]
# province = area[0]
# city = area[1]
# district = area[2]
# page = req_dict.get("page") # 分页页码
# perpage = req_dict.get("perpage") # 分页大小
# if not all([page, perpage]):
# return jsonify(code=RET.PARAMERR, msg="参数不完整")
#
# # 页数
# if not page:
# page = 1
# page = int(page)
# page = (page - 1) * per_page
#
# args_query = dict() # 查询字段
# args_term = dict() # 条件字典
#
# args_query["company_name"] = "公司"
# # 搜索框
# if company:
# args_query["company_name"] = company
#
# if f_name:
# args_term['f_name'] = f_name
# # 公司资质
# if qualificat:
# if qualificat == 1:
# args_term['isfive'] = 1
# if qualificat == 2:
# args_term['quoted_company'] = 1
# if qualificat == 3:
# args_term['fianacing'] = 1
# if qualificat == 4:
# args_term['high_new'] = 1
# if qualificat == 5:
# args_term['tbe'] = 1
# if qualificat == 6:
# args_term['dengl'] = 1
# if qualificat == 7:
# args_term['unicorn'] = 1
# # 注册资本
# if capital_id:
# args_term['capital_id'] = capital_id
# # 上市状态
# if public_id:
# args_term['public_id'] = public_id
# # 省
# if province:
# args_term['province'] = province
# # 市
# if city:
# args_term['city'] = city
# # 区
# if district:
# args_term['district'] = district
#
# # 成立时间
# if yearid:
# args_term['yearid'] = yearid
# # 融资轮次
# if roundid:
# args_term['roundid'] = roundid
# # 企业状态
# if status:
# args_term['status'] = status
# # 企业规模
# if scale_range:
# args_term['scale_range'] = scale_range
# # 公司类型
# if entypeid:
# args_term['entypeid'] = entypeid
#
# body = create_body(page, per_page, args_query, args_term)
# if not company:
# del body["query"]["bool"]["must"][0]
#
# 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_202302151628_bedd5ee8", body=body)
# data_list = []
# # print(data_list)
# size = data["hits"]['total']
#
# # 数据的列表添加进去
# for i in data["hits"]['hits']:
# if company:
# # 判断高亮,然后添加
# data_list.append({
# "id": i["_source"]["mysql_id"],
# "company": i["highlight"]["company_name"][0] if "company_name" in i["highlight"] else i["_source"][
# "company_name"],
# "area": i["_source"]["province"] + i["_source"]["city"] + i["_source"]["district"],
# "createtime": i["_source"]["build_date"],
# "legal": i["_source"]["legal"],
# "capital": i["_source"]["capital"],
# "entype": i["_source"]["entype"],
# "address": i["_source"]["address"],
# "telephone": i["_source"]["telephone"],
# "high_new": '高新技术企业' if i["_source"]["high_new"] == "1" else '',
# "tbe": '科技型中小企业' if i["_source"]["tbe"] == "1" else '',
# "fianacing": '融资企业' if i["_source"]["fianacing"] == "1" else '',
# "quoted_company": '上市企业' if i["_source"]["quoted_company"] == "1" else '',
# "dengl": '瞪羚企业' if i["_source"]["dengl"] == "1" else '',
# "unicorn": '独角兽企业' if i["_source"]["unicorn"] == "1" else '',
# "isfive": '500强企业' if i["_source"]["isfive"] == '1' else '',
# })
# else:
# data_list.append({
# "id": i["_source"]["mysql_id"],
# "company": i["_source"]["company_name"],
# "area": i["_source"]["province"] + i["_source"]["city"] + i["_source"]["district"],
# "createtime": i["_source"]["build_date"],
# "legal": i["_source"]["legal"],
# "capital": i["_source"]["capital"],
# "entype": i["_source"]["entype"],
# "address": i["_source"]["address"],
# "telephone": i["_source"]["telephone"],
# "high_new": '高新技术企业' if i["_source"]["high_new"] == "1" else '',
# "tbe": '科技型中小企业' if i["_source"]["tbe"] == "1" else '',
# "fianacing": '融资企业' if i["_source"]["fianacing"] == "1" else '',
# "quoted_company": '上市企业' if i["_source"]["quoted_company"] == "1" else '',
# "dengl": '瞪羚企业' if i["_source"]["dengl"] == "1" else '',
# "unicorn": '独角兽企业' if i["_source"]["unicorn"] == "1" else '',
# "isfive": '500强企业' if i["_source"]["isfive"] == '1' else '',
# })
# except Exception as e:
# current_app.logger.error(e)
# return jsonify(code=RET.DBERR, msg="es数据库错误")
# data = {
# "data": data_list, "size": size
# }
# return jsonify(code=RET.OK, msg="查找成功", data=data)
\ No newline at end of file
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