Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Z
zhichan
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
蒋勇
zhichan
Commits
e471fd19
Commit
e471fd19
authored
May 20, 2020
by
黄静
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
hj
parent
7f816745
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
12 deletions
+34
-12
entprofile/service/select_es_result.py
+34
-12
No files found.
entprofile/service/select_es_result.py
View file @
e471fd19
...
...
@@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-
# @Time : 2020-05-16 17:30
# @Author : hj
# @File :
zhengce-
select_es_result.py
# @File : select_es_result.py
# @Software: PyCharm
...
...
@@ -26,8 +26,17 @@ class HX:
self
.
espassword
=
"adminGSBes."
self
.
es
=
Elasticsearch
([
self
.
esip
],
http_auth
=
(
self
.
esuser
,
self
.
espassword
),
port
=
self
.
esport
)
def
hxsearch
(
self
,
re_item
):
def
hxsearch
(
self
,
re_item
,
pagesize
,
currentpage
):
print
(
're_item'
,
re_item
)
if
currentpage
:
start
=
(
currentpage
-
1
)
*
pagesize
else
:
start
=
0
if
pagesize
:
size
=
pagesize
else
:
size
=
4
if
re_item
==
[]:
querybody
=
{
"query"
:
{
...
...
@@ -39,7 +48,8 @@ class HX:
]
}
},
"size"
:
2000
"from"
:
start
,
"size"
:
size
}
else
:
querybody
=
{
...
...
@@ -49,7 +59,8 @@ class HX:
]
}
},
"size"
:
2000
,
"from"
:
start
,
"size"
:
size
}
if
"qiyeguimo"
in
re_item
:
dsl
=
{
...
...
@@ -225,12 +236,17 @@ class HX:
print
(
'查询语法:'
,
querybody
)
searched
=
self
.
es
.
search
(
index
=
self
.
index_name
,
doc_type
=
self
.
index_type
,
body
=
querybody
)
es_company_info
=
{}
company_hx_list
=
[]
if
(
searched
[
"hits"
][
"total"
]
>
0
):
for
row
in
searched
[
"hits"
][
"hits"
]:
company_name
=
row
[
'_source'
][
"companyname"
]
company_hx_list
.
append
(
company_name
)
return
company_hx_list
total
=
searched
[
"hits"
][
"total"
]
es_company_info
[
'company_hx_list'
]
=
company_hx_list
es_company_info
[
'total'
]
=
total
return
es_company_info
def
select_url
(
self
,
company_name
):
hx_logo_address
=
'暂无logo'
...
...
@@ -276,30 +292,36 @@ def hx_company_list(server):
def
hx_select_main
():
if
request
.
method
==
'POST'
:
requestdata
=
request
.
json
print
(
'requestdata'
,
requestdata
)
total
=
""
select_filter
=
requestdata
.
get
(
'select_filter'
)
pagesize
=
requestdata
.
get
(
'pagesize'
)
currentpage
=
requestdata
.
get
(
'currentpage'
)
try
:
base_result_list
=
[]
print
(
requestdata
,
1121212
)
re_item
=
{}
if
requestdata
!=
[]:
for
item
in
requestdata
:
for
item
in
select_filter
:
name
=
item
[
'name'
]
list
=
item
[
'list'
]
re_item
[
name
]
=
list
company_hx_list
=
hx
.
hxsearch
(
re_item
)
for
company_name
in
company_hx_list
:
es_company_info
=
hx
.
hxsearch
(
re_item
,
pagesize
,
currentpage
)
for
company_name
in
es_company_info
[
'company_hx_list'
]
:
base_result
=
companybase
.
companyinfo
(
company_name
)
logo_url
=
hx
.
select_url
(
company_name
)
base_result
[
'logo'
]
=
logo_url
base_result_list
.
append
(
base_result
)
total
=
es_company_info
[
'total'
]
print
(
"len_result"
,
len
(
base_result_list
))
else
:
company_hx_list
=
hx
.
hxsearch
(
requestdata
)
for
company_name
in
company_hx_list
:
es_company_info
=
hx
.
hxsearch
(
select_filter
,
pagesize
,
currentpage
)
for
company_name
in
es_company_info
[
'company_hx_list'
]
:
base_result
=
companybase
.
companyinfo
(
company_name
)
logo_url
=
hx
.
select_url
(
company_name
)
base_result
[
'logo'
]
=
logo_url
base_result_list
.
append
(
base_result
)
total
=
es_company_info
[
'total'
]
print
(
"len_result"
,
len
(
base_result_list
))
except
:
base_result_list
=
"暂无该检索信息,请您修改条件进行检索!"
return
{
"status"
:
200
,
"msg"
:
"成功"
,
"data"
:
base_result_list
}
return
{
"status"
:
200
,
"msg"
:
"成功"
,
"data"
:
base_result_list
,
"total"
:
total
}
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