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():
...
@@ -136,166 +136,166 @@ def open_dists():
# 搜索接口
# 搜索接口
#
@api_portraits.route("/EsSearch", methods=["POST"])
@api_portraits.route
(
"/EsSearch"
,
methods
=
[
"POST"
])
#
#
@login_required
# @login_required
#
def search():
def
search
():
#
"""
"""
#
获取用户信息
获取用户信息
#
"""
"""
#
# token = request.headers["token"]
# token = request.headers["token"]
#
# user = verify_token(token)
# user = verify_token(token)
#
# user_id = user.id
# user_id = user.id
#
# user_id = 5
# user_id = 5
#
# 参数获取
# 参数获取
#
req_dict = request.get_json()
req_dict
=
request
.
get_json
()
#
company = req_dict.get("company_name") # 搜索企业名称
company
=
req_dict
.
get
(
"company_name"
)
# 搜索企业名称
#
f_name = req_dict.get("industry") # 所属行业
f_name
=
req_dict
.
get
(
"industry"
)
# 所属行业
#
qualificat = req_dict.get("qualificat") # 企业资质
qualificat
=
req_dict
.
get
(
"qualificat"
)
# 企业资质
#
capital_id = req_dict.get("capital_id") # 注册资本
capital_id
=
req_dict
.
get
(
"capital_id"
)
# 注册资本
#
public_id = req_dict.get("public_id") # 上市状态
public_id
=
req_dict
.
get
(
"public_id"
)
# 上市状态
#
# area = req_dict.get("area") # 所在地区
# area = req_dict.get("area") # 所在地区
#
province = req_dict.get("province")
province
=
req_dict
.
get
(
"province"
)
#
city = req_dict.get("city")
city
=
req_dict
.
get
(
"city"
)
#
district = req_dict.get("district")
district
=
req_dict
.
get
(
"district"
)
#
yearid = req_dict.get("yearid") # 成立时间
yearid
=
req_dict
.
get
(
"yearid"
)
# 成立时间
#
roundid = req_dict.get("financ_id") # 融资轮次
roundid
=
req_dict
.
get
(
"financ_id"
)
# 融资轮次
#
status = req_dict.get("status") # 企业状态
status
=
req_dict
.
get
(
"status"
)
# 企业状态
#
scale_range = req_dict.get("scale_range") # 企业规模
scale_range
=
req_dict
.
get
(
"scale_range"
)
# 企业规模
#
entypeid = req_dict.get("entypeid") # 企业类型
entypeid
=
req_dict
.
get
(
"entypeid"
)
# 企业类型
#
#
page = req_dict.get("page") # 页码
page
=
req_dict
.
get
(
"page"
)
# 页码
#
per_page = req_dict.get("per_page") # 每页大小
per_page
=
req_dict
.
get
(
"per_page"
)
# 每页大小
#
#
# if area == []:
# if area == []:
#
# area = ["", "", ""]
# area = ["", "", ""]
#
# province = area[0]
# province = area[0]
#
# city = area[1]
# city = area[1]
#
# district = area[2]
# district = area[2]
#
# 页数
# 页数
#
if not page:
if
not
page
:
#
page = 1
page
=
1
#
page = int(page)
page
=
int
(
page
)
#
page = (page - 1) * per_page
page
=
(
page
-
1
)
*
per_page
#
#
args_query = dict() # 查询字段
args_query
=
dict
()
# 查询字段
#
args_term = dict() # 条件字典
args_term
=
dict
()
# 条件字典
#
#
args_query["company_name"] = "公司"
args_query
[
"company_name"
]
=
"公司"
#
# 搜索框
# 搜索框
#
if company:
if
company
:
#
args_query["company_name"] = company
args_query
[
"company_name"
]
=
company
#
#
if f_name:
if
f_name
:
#
args_term['f_name'] = f_name
args_term
[
'f_name'
]
=
f_name
#
# 公司资质
# 公司资质
#
if qualificat:
if
qualificat
:
#
if qualificat == 1:
if
qualificat
==
1
:
#
args_term['isfive'] = 1
args_term
[
'isfive'
]
=
1
#
if qualificat == 2:
if
qualificat
==
2
:
#
args_term['quoted_company'] = 1
args_term
[
'quoted_company'
]
=
1
#
if qualificat == 3:
if
qualificat
==
3
:
#
args_term['fianacing'] = 1
args_term
[
'fianacing'
]
=
1
#
if qualificat == 4:
if
qualificat
==
4
:
#
args_term['high_new'] = 1
args_term
[
'high_new'
]
=
1
#
if qualificat == 5:
if
qualificat
==
5
:
#
args_term['tbe'] = 1
args_term
[
'tbe'
]
=
1
#
if qualificat == 6:
if
qualificat
==
6
:
#
args_term['dengl'] = 1
args_term
[
'dengl'
]
=
1
#
if qualificat == 7:
if
qualificat
==
7
:
#
args_term['unicorn'] = 1
args_term
[
'unicorn'
]
=
1
#
# 注册资本
# 注册资本
#
if capital_id:
if
capital_id
:
#
args_term['capital_id'] = capital_id
args_term
[
'capital_id'
]
=
capital_id
#
# 上市状态
# 上市状态
#
if public_id:
if
public_id
:
#
args_term['public_id'] = public_id
args_term
[
'public_id'
]
=
public_id
#
# 省
# 省
#
if province:
if
province
:
#
args_term['province'] = province
args_term
[
'province'
]
=
province
#
# 市
# 市
#
if city:
if
city
:
#
args_term['city'] = city
args_term
[
'city'
]
=
city
#
# 区
# 区
#
if district:
if
district
:
#
args_term['district'] = district
args_term
[
'district'
]
=
district
#
#
# 成立时间
# 成立时间
#
if yearid:
if
yearid
:
#
args_term['yearid'] = yearid
args_term
[
'yearid'
]
=
yearid
#
# 融资轮次
# 融资轮次
#
if roundid:
if
roundid
:
#
args_term['roundid'] = roundid
args_term
[
'roundid'
]
=
roundid
#
# 企业状态
# 企业状态
#
if status:
if
status
:
#
args_term['status'] = status
args_term
[
'status'
]
=
status
#
# 企业规模
# 企业规模
#
if scale_range:
if
scale_range
:
#
args_term['scale_range'] = scale_range
args_term
[
'scale_range'
]
=
scale_range
#
# 公司类型
# 公司类型
#
if entypeid:
if
entypeid
:
#
args_term['entypeid'] = entypeid
args_term
[
'entypeid'
]
=
entypeid
#
#
body = create_body(page, per_page, args_query, args_term)
body
=
create_body
(
page
,
per_page
,
args_query
,
args_term
)
#
if not company:
if
not
company
:
#
del body["query"]["bool"]["must"][0]
del
body
[
"query"
][
"bool"
][
"must"
][
0
]
#
#
try:
try
:
#
es = Elasticsearch([{'host': '39.100.39.50', 'port': 9200}])
es
=
Elasticsearch
([{
'host'
:
'39.100.39.50'
,
'port'
:
9200
}])
#
#
data = es.search(index="jincheng_pictext_index_202202221626_29780d68", body=body)
data
=
es
.
search
(
index
=
"jincheng_pictext_index_202202221626_29780d68"
,
body
=
body
)
#
data_list = []
data_list
=
[]
#
print(data_list)
print
(
data_list
)
#
size = data["hits"]['total']
size
=
data
[
"hits"
][
'total'
]
#
#
# 数据的列表添加进去
# 数据的列表添加进去
#
for i in data["hits"]['hits']:
for
i
in
data
[
"hits"
][
'hits'
]:
#
if company:
if
company
:
#
# 判断高亮,然后添加
# 判断高亮,然后添加
#
data_list.append({
data_list
.
append
({
#
"id": i["_source"]["mysql_id"],
"id"
:
i
[
"_source"
][
"mysql_id"
],
#
"company": i["highlight"]["company_name"][0] if "company_name" in i["highlight"] else i["_source"][
"company"
:
i
[
"highlight"
][
"company_name"
][
0
]
if
"company_name"
in
i
[
"highlight"
]
else
i
[
"_source"
][
#
"company_name"],
"company_name"
],
#
"area": i["_source"]["city"] + i["_source"]["district"],
"area"
:
i
[
"_source"
][
"city"
]
+
i
[
"_source"
][
"district"
],
#
"createtime": i["_source"]["build_date"],
"createtime"
:
i
[
"_source"
][
"build_date"
],
#
"legal": i["_source"]["legal"],
"legal"
:
i
[
"_source"
][
"legal"
],
#
"capital": i["_source"]["capital"],
"capital"
:
i
[
"_source"
][
"capital"
],
#
"entype": i["_source"]["entype"],
"entype"
:
i
[
"_source"
][
"entype"
],
#
"address": i["_source"]["address"],
"address"
:
i
[
"_source"
][
"address"
],
#
"telephone": i["_source"]["telephone"],
"telephone"
:
i
[
"_source"
][
"telephone"
],
#
"high_new": '高新技术企业' if i["_source"]["high_new"] == "1" else '',
"high_new"
:
'高新技术企业'
if
i
[
"_source"
][
"high_new"
]
==
"1"
else
''
,
#
"tbe": '科技型中小企业' if i["_source"]["tbe"] == "1" else '',
"tbe"
:
'科技型中小企业'
if
i
[
"_source"
][
"tbe"
]
==
"1"
else
''
,
#
"fianacing": '融资企业' if i["_source"]["fianacing"] == "1" else '',
"fianacing"
:
'融资企业'
if
i
[
"_source"
][
"fianacing"
]
==
"1"
else
''
,
#
"quoted_company": '上市企业' if i["_source"]["quoted_company"] == "1" else '',
"quoted_company"
:
'上市企业'
if
i
[
"_source"
][
"quoted_company"
]
==
"1"
else
''
,
#
"dengl": '瞪羚企业' if i["_source"]["dengl"] == "1" else '',
"dengl"
:
'瞪羚企业'
if
i
[
"_source"
][
"dengl"
]
==
"1"
else
''
,
#
"unicorn": '独角兽企业' if i["_source"]["unicorn"] == "1" else '',
"unicorn"
:
'独角兽企业'
if
i
[
"_source"
][
"unicorn"
]
==
"1"
else
''
,
#
"isfive": '500强企业' if i["_source"]["isfive"] == '1' else '',
"isfive"
:
'500强企业'
if
i
[
"_source"
][
"isfive"
]
==
'1'
else
''
,
#
})
})
#
else:
else
:
#
data_list.append({
data_list
.
append
({
#
"id": i["_source"]["mysql_id"],
"id"
:
i
[
"_source"
][
"mysql_id"
],
#
"company": i["_source"]["company_name"],
"company"
:
i
[
"_source"
][
"company_name"
],
#
"area": i["_source"]["city"] + i["_source"]["district"],
"area"
:
i
[
"_source"
][
"city"
]
+
i
[
"_source"
][
"district"
],
#
"createtime": i["_source"]["build_date"],
"createtime"
:
i
[
"_source"
][
"build_date"
],
#
"legal": i["_source"]["legal"],
"legal"
:
i
[
"_source"
][
"legal"
],
#
"capital": i["_source"]["capital"],
"capital"
:
i
[
"_source"
][
"capital"
],
#
"entype": i["_source"]["entype"],
"entype"
:
i
[
"_source"
][
"entype"
],
#
"address": i["_source"]["address"],
"address"
:
i
[
"_source"
][
"address"
],
#
"telephone": i["_source"]["telephone"],
"telephone"
:
i
[
"_source"
][
"telephone"
],
#
"high_new": '高新技术企业' if i["_source"]["high_new"] == "1" else '',
"high_new"
:
'高新技术企业'
if
i
[
"_source"
][
"high_new"
]
==
"1"
else
''
,
#
"tbe": '科技型中小企业' if i["_source"]["tbe"] == "1" else '',
"tbe"
:
'科技型中小企业'
if
i
[
"_source"
][
"tbe"
]
==
"1"
else
''
,
#
"fianacing": '融资企业' if i["_source"]["fianacing"] == "1" else '',
"fianacing"
:
'融资企业'
if
i
[
"_source"
][
"fianacing"
]
==
"1"
else
''
,
#
"quoted_company": '上市企业' if i["_source"]["quoted_company"] == "1" else '',
"quoted_company"
:
'上市企业'
if
i
[
"_source"
][
"quoted_company"
]
==
"1"
else
''
,
#
"dengl": '瞪羚企业' if i["_source"]["dengl"] == "1" else '',
"dengl"
:
'瞪羚企业'
if
i
[
"_source"
][
"dengl"
]
==
"1"
else
''
,
#
"unicorn": '独角兽企业' if i["_source"]["unicorn"] == "1" else '',
"unicorn"
:
'独角兽企业'
if
i
[
"_source"
][
"unicorn"
]
==
"1"
else
''
,
#
"isfive": '500强企业' if i["_source"]["isfive"] == '1' else '',
"isfive"
:
'500强企业'
if
i
[
"_source"
][
"isfive"
]
==
'1'
else
''
,
#
})
})
#
except Exception as e:
except
Exception
as
e
:
#
current_app.logger.error(e)
current_app
.
logger
.
error
(
e
)
#
return jsonify(code=RET.DBERR, msg="es数据库错误")
return
jsonify
(
code
=
RET
.
DBERR
,
msg
=
"es数据库错误"
)
#
data = {
data
=
{
#
"data": data_list, "size": size
"data"
:
data_list
,
"size"
:
size
#
}
}
#
return jsonify(code=RET.OK, msg="查找成功", data=data)
return
jsonify
(
code
=
RET
.
OK
,
msg
=
"查找成功"
,
data
=
data
)
def
body_qualificat
(
s
,
j
):
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