Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Q
qk_backend
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
quanku
qk_backend
Commits
030b657c
Commit
030b657c
authored
Aug 25, 2023
by
shiyu
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
3e6aaa81
6a340eb7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
28 deletions
+16
-28
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/ItemServiceImpl.java
...pi/src/main/java/com/wwdz/ch/wx/impl/ItemServiceImpl.java
+16
-28
No files found.
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/ItemServiceImpl.java
View file @
030b657c
...
...
@@ -37,8 +37,10 @@ import java.io.ByteArrayInputStream;
import
java.io.ByteArrayOutputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.lang.System
;
import
java.net.URL
;
import
java.util.*
;
import
java.util.stream.Collectors
;
@Service
public
class
ItemServiceImpl
implements
ItemService
{
...
...
@@ -70,39 +72,25 @@ public class ItemServiceImpl implements ItemService {
List
<
String
>
names
=
new
ArrayList
<>();
if
(
StringUtils
.
isNotBlank
(
dto
.
getName
()))
{
EsSearchRequestDto
esSearchRequestDto
=
new
EsSearchRequestDto
();
esSearchRequestDto
.
setPage
(
1
);
esSearchRequestDto
.
setSize
(
10000
);
esSearchRequestDto
.
setContent
(
dto
.
getName
());
EsPageInfo
esPageInfo
=
itemEsDao
.
findList
(
esSearchRequestDto
);
if
(
Objects
.
nonNull
(
esPageInfo
)
&&
CollectionUtils
.
isNotEmpty
(
esPageInfo
.
getDataList
()))
{
Set
<
String
>
set
=
new
HashSet
<>();
esPageInfo
.
getDataList
().
forEach
(
s
->
{
ItemOfEs
es
=
(
ItemOfEs
)
s
;
String
name
=
es
.
getName
();
esSearchRequestDto
.
setSize
(
16
);
List
<
ItemOfEs
>
list
=
itemEsDao
.
getCuewords
(
esSearchRequestDto
);
if
(
CollectionUtils
.
isNotEmpty
(
list
))
{
names
=
list
.
stream
()
.
map
(
ItemOfEs:
:
getName
).
collect
(
Collectors
.
toList
())
;
for
(
String
name
:
names
)
{
// 处理特殊字符
name
=
name
.
replaceAll
(
"\\s*|\r|\n|\t"
,
""
);
name
=
name
.
replaceAll
(
"/P"
,
""
);
if
(
name
.
contains
(
","
))
{
int
index
=
name
.
indexOf
(
","
);
name
=
name
.
substring
(
0
,
index
);
}
// 超过15个字的截取前15个字符
name
=
name
.
replaceAll
(
","
,
""
);
// 超过15个字的15个字符
if
(
name
.
length
()
>
15
)
{
name
=
name
.
substring
(
0
,
15
);
}
if
(
name
.
contains
(
dto
.
getName
()))
{
set
.
add
(
name
);
}
});
// 取16个名称
if
(
set
.
size
()
<=
16
)
{
names
=
new
ArrayList
<>(
set
);
}
else
{
int
i
=
1
;
Iterator
<
String
>
iterator
=
set
.
iterator
();
while
(
i
<=
16
)
{
names
.
add
(
iterator
.
next
());
i
++;
int
index
=
name
.
indexOf
(
dto
.
getName
());
if
(
index
+
dto
.
getName
().
length
()
>
15
)
{
name
=
name
.
substring
(
index
+
dto
.
getName
().
length
()
-
15
,
index
+
dto
.
getName
().
length
());
}
else
{
name
=
name
.
substring
(
0
,
15
);
}
}
}
}
...
...
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