Commit 39c464bd by dong

fix

parent 618da54c
......@@ -455,7 +455,7 @@ def get_enterprise_num(product, inid):
return company, size
全国企业列表
# 全国企业列表
@api_map.route('/AttractEnterprise', methods=['POST'])
def attract_enterprise():
'''
......@@ -579,301 +579,151 @@ def attract_enterprise():
# 全国企业列表(Es)
# @api_map.route('/AttractEnterprise', methods=['POST'])
# def attract_enterprise():
# 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) * perpage
#
# args_query = dict() # 查询字段
# args_term = dict() # 条件字典
#
# args_query["company_name"] = "公司"
# # 搜索框
# if company_name:
# args_query["company_name"] = company_name
#
# if entype:
# args_term['entype'] = entype
#
# if quoted:
# args_term['public_id'] = quoted
#
# if qualificat:
# if qualificat == "中国500强":
# args_term['isfive'] = 1
# if qualificat == "上市企业":
# args_term['quoted_company'] = 1
# if qualificat == "独角兽企业":
# args_term['unicorn'] = 1
# if qualificat == "瞪羚企业":
# args_term['dengl'] = 1
# if qualificat == "规上企业":
# args_term['scale'] = 1
# if qualificat == "科技型中小企业":
# args_term['tbe'] = 1
# if qualificat == "高新技术企业":
# args_term['high_new'] = 1
# if qualificat == "专精特新企业":
# args_term['zjtx'] = 1
# if qualificat == "外资企业":
# args_term['foreign_investment'] = 1
#
# # 省
# if province:
# args_term['province'] = province
# # 市
# if city:
# args_term['city'] = city
# # 区
# if district:
# args_term['district'] = district
#
# body = create_body(page, perpage, args_query, args_term)
# if not company_name:
# del body["query"]["bool"]["must"][0]
#
# if inid in range(1, 9) and not product:
# f_c_type = {
# "multi_match": {
# "query": inid,
# "fields": ["f_type", "f_type1", "f_type2"]
# }
# }
# body["query"]["bool"]["must"].append(f_c_type)
# elif inid and not product:
# f_c_type = {
# "multi_match": {
# "query": inid,
# "fields": ["c_type", "c_type1", "c_type2"]
# }
# }
# body["query"]["bool"]["must"].append(f_c_type)
# else:
# pass
#
# if product:
# product = {
# "multi_match": {
# "query": product,
# "fields": ["product_all", "product_all1", "product_all2"]
# }
# }
# body["query"]["bool"]["must"].append(product)
#
# try:
# es = Elasticsearch([{'host': '39.100.39.50', 'port': 9200}])
#
# data = es.search(index="mancheng_enterperise", body=body)
# df = []
# size = data["hits"]['total']
#
# # 数据的列表添加进去
# for i in data["hits"]['hits']:
# if company_name:
# # 判断高亮,然后添加
# df.append({
# "id": i["_source"]["mysql_id"],
# "company_name": i["highlight"]["company_name"][0] if "company_name" in i["highlight"] else i["_source"][
# "company_name"],
# "aptitude": list(filter(None, [
# "中国500强" if i["_source"]["isfive"] == '1' else '',
# "上市企业" if i["_source"]["quoted_company"] == "1" else '',
# "独角兽企业" if i["_source"]["unicorn"] == "1" else '',
# "瞪羚企业" if i["_source"]["dengl"] == "1" else '',
# "规上企业" if i["_source"]["scale"] == "1" else '',
# "科技型中小企业" if i["_source"]["tbe"] == "1" else '',
# "高新技术企业" if i["_source"]["high_new"] == "1" else '',
# "专精特新企业" if i["_source"]["zjtx"] == "1" else '',
# "外资企业" if i["_source"]["foreign_investment"] == "1" else '']))})
#
# else:
# df.append({
# "id": i["_source"]["mysql_id"],
# "company_name": i["_source"]["company_name"],
# "aptitude": list(filter(None, [
# "中国500强" if i["_source"]["isfive"] == '1' else '',
# "上市企业" if i["_source"]["quoted_company"] == "1" else '',
# "独角兽企业" if i["_source"]["unicorn"] == "1" else '',
# "瞪羚企业" if i["_source"]["dengl"] == "1" else '',
# "规上企业" if i["_source"]["scale"] == "1" else '',
# "科技型中小企业" if i["_source"]["tbe"] == "1" else '',
# "高新技术企业" if i["_source"]["high_new"] == "1" else '',
# "专精特新企业" if i["_source"]["zjtx"] == "1" else '',
# "外资企业" if i["_source"]["foreign_investment"] == "1" else '']))})
#
# except Exception as e:
# current_app.logger.error(e)
# return jsonify(code=RET.DBERR, msg="es数据库错误")
# data = {"size": size, "df": df}
# return jsonify(code=RET.OK, msg="查找成功", data=data)
@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="参数不完整")
# # 全国企业列表(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) * perpage
#
# args_query = dict() # 查询字段
# args_term = dict() # 条件字典
#
# args_query["company_name"] = "公司"
# # 搜索框
# if company_name:
# args_query["company_name"] = company_name
#
# if inid:
# args_term['c_type'] = inid
#
# if entype:
# args_term['entype'] = entype
#
# if quoted:
# args_term['public_id'] = quoted
#
# if product:
# args_term['product'] = product
# # 公司资质
# 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 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, perpage, args_query, args_term)
# if not company_name:
# 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_202303161620_76c624b8", body=body)
# data_list = []
# # print(data_list)
# size = data["hits"]['total']
#
# # 数据的列表添加进去
# for i in data["hits"]['hits']:
# if company_name:
# # 判断高亮,然后添加
# 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
# 页数
if not page:
page = 1
page = int(page)
page = (page - 1) * perpage
args_query = dict() # 查询字段
args_term = dict() # 条件字典
args_query["company_name"] = "公司"
# 搜索框
if company_name:
args_query["company_name"] = company_name
if inid:
args_term['c_type'] = inid
if entype:
args_term['entype'] = entype
if quoted:
args_term['public_id'] = quoted
if product:
args_term['product'] = product
# 公司资质
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 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, perpage, args_query, args_term)
if not company_name:
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_202303161620_76c624b8", body=body)
data_list = []
# print(data_list)
size = data["hits"]['total']
# 数据的列表添加进去
for i in data["hits"]['hits']:
if company_name:
# 判断高亮,然后添加
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