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
06d7e2c3
Commit
06d7e2c3
authored
Oct 28, 2020
by
wanghuiyun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
王辉云 添加公司名称分页功能
parent
91518678
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
18 additions
and
16 deletions
+18
-16
alioss-java/src/main/java/com/example/aliossjava/companyName.java
+15
-15
alioss-java/src/main/java/com/example/aliossjava/uploadossapi.java
+3
-1
alioss-java/target/classes/com/example/aliossjava/companyName$1.class
+0
-0
alioss-java/target/classes/com/example/aliossjava/companyName.class
+0
-0
alioss-java/target/classes/com/example/aliossjava/uploadossapi.class
+0
-0
No files found.
alioss-java/src/main/java/com/example/aliossjava/companyName.java
View file @
06d7e2c3
...
...
@@ -18,6 +18,7 @@ import org.elasticsearch.search.SearchHits;
import
org.elasticsearch.search.builder.SearchSourceBuilder
;
import
com.alibaba.fastjson.JSONObject
;
import
org.springframework.stereotype.Service
;
import
java.util.*
;
/**
...
...
@@ -27,10 +28,10 @@ import java.util.*;
@Service
public
class
companyName
{
public
List
<
String
>
nameList
(
String
region
,
String
type
,
String
modality
,
String
nameNum
,
String
goodName
)
throws
Exception
{
List
<
String
>
querycompanyNanme
=
querycompanyNanme
(
goodName
,
nameNum
);
public
List
<
String
>
nameList
(
String
region
,
String
type
,
String
modality
,
String
nameNum
,
String
goodName
,
Integer
from
,
Integer
size
)
throws
Exception
{
List
<
String
>
querycompanyNanme
=
querycompanyNanme
(
goodName
,
nameNum
,
from
,
size
);
List
<
String
>
nameList
=
new
ArrayList
<>();
for
(
String
str
:
querycompanyNanme
){
for
(
String
str
:
querycompanyNanme
)
{
JSONObject
responseObj
=
JSONObject
.
parseObject
(
str
);
nameList
.
add
(
region
+
responseObj
.
getString
(
"company_name"
)
+
type
+
modality
);
}
...
...
@@ -39,9 +40,10 @@ public class companyName {
/**
* 根据条件查询公司名称
*
* @return
*/
public
static
List
<
String
>
querycompanyNanme
(
String
fieldKey
,
String
fieldnum
)
throws
Exception
{
public
static
List
<
String
>
querycompanyNanme
(
String
fieldKey
,
String
fieldnum
,
Integer
from
,
Integer
size
)
throws
Exception
{
CredentialsProvider
credentialsProvider
=
new
BasicCredentialsProvider
();
credentialsProvider
.
setCredentials
(
AuthScope
.
ANY
,
new
UsernamePasswordCredentials
(
"elastic"
,
"w3OL+51eo*)c=^7"
));
...
...
@@ -52,32 +54,30 @@ public class companyName {
return
httpClientBuilder
.
setDefaultCredentialsProvider
(
credentialsProvider
);
}
});
RestHighLevelClient
restClient
=
new
RestHighLevelClient
(
client
);
RestHighLevelClient
restClient
=
new
RestHighLevelClient
(
client
);
SearchRequest
searchRequest
=
new
SearchRequest
(
"treasure_name"
);
searchRequest
.
types
(
"_doc"
);
SearchSourceBuilder
searchSourceBuilder
=
new
SearchSourceBuilder
();
if
(
fieldnum
.
equals
(
"不限"
)
&&
fieldKey
.
equals
(
""
)){
if
(
fieldnum
.
equals
(
"不限"
)
&&
fieldKey
.
equals
(
""
))
{
searchSourceBuilder
.
query
(
QueryBuilders
.
boolQuery
());
}
else
if
(
fieldKey
.
equals
(
""
)){
}
else
if
(
fieldKey
.
equals
(
""
))
{
searchSourceBuilder
.
query
(
QueryBuilders
.
boolQuery
()
.
must
(
QueryBuilders
.
termQuery
(
"name_size"
,
Integer
.
valueOf
(
fieldnum
))));
}
else
if
(
fieldnum
.
equals
(
"不限"
)){
}
else
if
(
fieldnum
.
equals
(
"不限"
))
{
searchSourceBuilder
.
query
(
QueryBuilders
.
boolQuery
().
must
(
QueryBuilders
.
termsQuery
(
"company_name"
,
fieldKey
)));
}
else
{
}
else
{
searchSourceBuilder
.
query
(
QueryBuilders
.
boolQuery
().
must
(
QueryBuilders
.
termsQuery
(
"company_name"
,
fieldKey
))
.
must
(
QueryBuilders
.
termQuery
(
"name_size"
,
Integer
.
valueOf
(
fieldnum
))));
}
searchSourceBuilder
.
from
(
from
);
searchSourceBuilder
.
size
(
size
);
searchRequest
.
source
(
searchSourceBuilder
);
SearchResponse
searchResponse
=
restClient
.
search
(
searchRequest
,
RequestOptions
.
DEFAULT
);
List
<
String
>
result
=
new
LinkedList
<>();
SearchHits
searchHits
=
searchResponse
.
getHits
();
searchHits
.
forEach
(
i
->
{
SearchHits
searchHits
=
searchResponse
.
getHits
();
searchHits
.
forEach
(
i
->
{
result
.
add
(
i
.
getSourceAsString
());
});
return
result
;
...
...
alioss-java/src/main/java/com/example/aliossjava/uploadossapi.java
View file @
06d7e2c3
...
...
@@ -60,7 +60,9 @@ public class uploadossapi {
String
modality
=
jsonObject
.
getString
(
"modality"
);
String
nameNum
=
jsonObject
.
getString
(
"nameNum"
);
String
goodName
=
jsonObject
.
getString
(
"goodName"
);
return
companyName
.
nameList
(
region
,
type
,
modality
,
nameNum
,
goodName
);
Integer
from
=
jsonObject
.
getInteger
(
"from"
);
Integer
size
=
jsonObject
.
getInteger
(
"size"
);
return
companyName
.
nameList
(
region
,
type
,
modality
,
nameNum
,
goodName
,
from
,
size
);
}
catch
(
Exception
e
)
{
return
null
;
}
...
...
alioss-java/target/classes/com/example/aliossjava/companyName$1.class
View file @
06d7e2c3
No preview for this file type
alioss-java/target/classes/com/example/aliossjava/companyName.class
View file @
06d7e2c3
No preview for this file type
alioss-java/target/classes/com/example/aliossjava/uploadossapi.class
View file @
06d7e2c3
No preview for this file type
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