Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mancheng
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
mancheng
Commits
d7ac019a
Commit
d7ac019a
authored
Dec 30, 2022
by
dong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix20221230
parent
09f02e13
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
160 additions
and
160 deletions
+160
-160
apps/view_360company/view.py
+160
-160
No files found.
apps/view_360company/view.py
View file @
d7ac019a
...
...
@@ -136,166 +136,166 @@ def open_dists():
# 搜索接口
#
@api_portraits.route("/EsSearch", methods=["POST"])
#
#
@login_required
#
def search():
#
"""
#
获取用户信息
#
"""
#
# token = request.headers["token"]
#
# user = verify_token(token)
#
# user_id = user.id
#
# user_id = 5
#
# 参数获取
#
req_dict = request.get_json()
#
company = req_dict.get("company_name") # 搜索企业名称
#
f_name = req_dict.get("industry") # 所属行业
#
qualificat = req_dict.get("qualificat") # 企业资质
#
capital_id = req_dict.get("capital_id") # 注册资本
#
public_id = req_dict.get("public_id") # 上市状态
#
# area = req_dict.get("area") # 所在地区
#
province = req_dict.get("province")
#
city = req_dict.get("city")
#
district = req_dict.get("district")
#
yearid = req_dict.get("yearid") # 成立时间
#
roundid = req_dict.get("financ_id") # 融资轮次
#
status = req_dict.get("status") # 企业状态
#
scale_range = req_dict.get("scale_range") # 企业规模
#
entypeid = req_dict.get("entypeid") # 企业类型
#
#
page = req_dict.get("page") # 页码
#
per_page = req_dict.get("per_page") # 每页大小
#
#
# if area == []:
#
# area = ["", "", ""]
#
# province = area[0]
#
# city = area[1]
#
# district = area[2]
#
# 页数
#
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_202202221626_29780d68", 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"]["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"]["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)
@api_portraits.route
(
"/EsSearch"
,
methods
=
[
"POST"
])
# @login_required
def
search
():
"""
获取用户信息
"""
# token = request.headers["token"]
# user = verify_token(token)
# user_id = user.id
# user_id = 5
# 参数获取
req_dict
=
request
.
get_json
()
company
=
req_dict
.
get
(
"company_name"
)
# 搜索企业名称
f_name
=
req_dict
.
get
(
"industry"
)
# 所属行业
qualificat
=
req_dict
.
get
(
"qualificat"
)
# 企业资质
capital_id
=
req_dict
.
get
(
"capital_id"
)
# 注册资本
public_id
=
req_dict
.
get
(
"public_id"
)
# 上市状态
# area = req_dict.get("area") # 所在地区
province
=
req_dict
.
get
(
"province"
)
city
=
req_dict
.
get
(
"city"
)
district
=
req_dict
.
get
(
"district"
)
yearid
=
req_dict
.
get
(
"yearid"
)
# 成立时间
roundid
=
req_dict
.
get
(
"financ_id"
)
# 融资轮次
status
=
req_dict
.
get
(
"status"
)
# 企业状态
scale_range
=
req_dict
.
get
(
"scale_range"
)
# 企业规模
entypeid
=
req_dict
.
get
(
"entypeid"
)
# 企业类型
page
=
req_dict
.
get
(
"page"
)
# 页码
per_page
=
req_dict
.
get
(
"per_page"
)
# 每页大小
# if area == []:
# area = ["", "", ""]
# province = area[0]
# city = area[1]
# district = area[2]
# 页数
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_202202221626_29780d68"
,
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"
][
"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"
][
"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
)
def
body_qualificat
(
s
,
j
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment