Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
midjourney-proxy
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
徐少华
midjourney-proxy
Commits
3089b311
Commit
3089b311
authored
Feb 28, 2020
by
阮思源
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改,特殊字符优先
parent
02d91d38
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
24 deletions
+34
-24
PersonalStageBizImpl.java
...oud/book/personalstage/biz/impl/PersonalStageBizImpl.java
+34
-24
No files found.
pcloud-service-book/src/main/java/com/pcloud/book/personalstage/biz/impl/PersonalStageBizImpl.java
View file @
3089b311
...
@@ -546,28 +546,31 @@ public class PersonalStageBizImpl implements PersonalStageBiz {
...
@@ -546,28 +546,31 @@ public class PersonalStageBizImpl implements PersonalStageBiz {
@ParamLog
(
"替换用户输入内容"
)
@ParamLog
(
"替换用户输入内容"
)
private
List
<
PersonalStageReplyItem
>
replaceUserSendContent
(
List
<
PersonalStageReplyItem
>
items
,
List
<
Long
>
ids
,
String
userSendContent
,
String
robotId
,
String
userWxId
,
String
ip
)
{
private
List
<
PersonalStageReplyItem
>
replaceUserSendContent
(
List
<
PersonalStageReplyItem
>
items
,
List
<
Long
>
ids
,
String
userSendContent
,
String
robotId
,
String
userWxId
,
String
ip
)
{
//如果用户没有输入文本
List
<
PersonalStageReplyItem
>
replyItems
=
personalStageReplyItemDao
.
getListByReplyIds
(
ids
);
if
(
StringUtil
.
isEmpty
(
userSendContent
)){
Map
<
Long
,
List
<
PersonalStageReplyItem
>>
map
=
replyItems
.
stream
().
collect
(
Collectors
.
groupingBy
(
PersonalStageReplyItem:
:
getPersonalStageReplyId
));
List
<
PersonalStageReplyItem
>
itemNew
=
new
ArrayList
<>();
List
<
Long
>
idsNotHasSpe
=
new
ArrayList
<>();
//找一个不带占位符的
List
<
Long
>
idsHasSpe
=
new
ArrayList
<>();
List
<
PersonalStageReplyItem
>
replyItems
=
personalStageReplyItemDao
.
getListByReplyIds
(
ids
);
for
(
Long
id:
ids
){
Map
<
Long
,
List
<
PersonalStageReplyItem
>>
map
=
replyItems
.
stream
().
collect
(
Collectors
.
groupingBy
(
PersonalStageReplyItem:
:
getPersonalStageReplyId
));
List
<
PersonalStageReplyItem
>
ins
=
map
.
get
(
id
);
List
<
Long
>
idsNew
=
new
ArrayList
<>();
if
(!
ListUtils
.
isEmpty
(
ins
)){
for
(
Long
id:
ids
){
Boolean
normal
=
true
;
List
<
PersonalStageReplyItem
>
ins
=
map
.
get
(
id
);
for
(
PersonalStageReplyItem
replyItem:
ins
){
if
(!
ListUtils
.
isEmpty
(
ins
)){
if
(!
StringUtil
.
isEmpty
(
replyItem
.
getContent
())&&
replyItem
.
getContent
().
contains
(
USER_SEND_CONTENT
)){
Boolean
flag
=
true
;
normal
=
false
;
for
(
PersonalStageReplyItem
replyItem:
ins
){
if
(!
StringUtil
.
isEmpty
(
replyItem
.
getContent
())&&
replyItem
.
getContent
().
contains
(
USER_SEND_CONTENT
)){
flag
=
false
;
}
}
if
(
flag
){
idsNew
.
add
(
id
);
}
}
}
}
if
(
normal
){
idsNotHasSpe
.
add
(
id
);
}
else
{
idsHasSpe
.
add
(
id
);
}
}
}
if
(
ListUtils
.
isEmpty
(
idsNew
)){
}
List
<
PersonalStageReplyItem
>
itemNew
=
new
ArrayList
<>();
//如果用户没有输入文本
if
(
StringUtil
.
isEmpty
(
userSendContent
)){
//找一个不带占位符的
if
(
ListUtils
.
isEmpty
(
idsNotHasSpe
)){
SendTextMessageVO
sendTextMessageVO
=
new
SendTextMessageVO
();
SendTextMessageVO
sendTextMessageVO
=
new
SendTextMessageVO
();
sendTextMessageVO
.
setContent
(
"哎哟 ~小主,你给我的不是书名啊。输入一本正在读或者感兴趣的书名,小睿就可以给你秀一下我的独家绝技哦"
);
sendTextMessageVO
.
setContent
(
"哎哟 ~小主,你给我的不是书名啊。输入一本正在读或者感兴趣的书名,小睿就可以给你秀一下我的独家绝技哦"
);
sendTextMessageVO
.
setAltId
(
robotId
);
sendTextMessageVO
.
setAltId
(
robotId
);
...
@@ -577,16 +580,23 @@ public class PersonalStageBizImpl implements PersonalStageBiz {
...
@@ -577,16 +580,23 @@ public class PersonalStageBizImpl implements PersonalStageBiz {
WxGroupSDK
.
sendTextMessage
(
sendTextMessageVO
);
WxGroupSDK
.
sendTextMessage
(
sendTextMessageVO
);
}
else
{
}
else
{
Random
random
=
new
Random
();
Random
random
=
new
Random
();
Long
replyId
=
idsN
ew
.
get
(
random
.
nextInt
(
idsNew
.
size
()));
Long
replyId
=
idsN
otHasSpe
.
get
(
random
.
nextInt
(
idsNotHasSpe
.
size
()));
itemNew
=
personalStageReplyItemDao
.
getListByReplyIds
(
Arrays
.
asList
(
replyId
));
itemNew
=
personalStageReplyItemDao
.
getListByReplyIds
(
Arrays
.
asList
(
replyId
));
}
}
return
itemNew
;
return
itemNew
;
}
else
{
}
else
{
for
(
PersonalStageReplyItem
item:
items
){
//用户输入文本优先给带特殊符号的
Integer
type
=
item
.
getReplyType
();
if
(!
ListUtils
.
isEmpty
(
idsHasSpe
)){
if
(
ReplyTypeEnum
.
TEXT
.
value
.
equals
(
type
)&&
item
.
getContent
().
contains
(
USER_SEND_CONTENT
))
{
Random
random
=
new
Random
();
item
.
setContent
(
item
.
getContent
().
replace
(
USER_SEND_CONTENT
,
userSendContent
));
Long
replyId
=
idsHasSpe
.
get
(
random
.
nextInt
(
idsHasSpe
.
size
()));
itemNew
=
personalStageReplyItemDao
.
getListByReplyIds
(
Arrays
.
asList
(
replyId
));
for
(
PersonalStageReplyItem
item:
itemNew
){
Integer
type
=
item
.
getReplyType
();
if
(
ReplyTypeEnum
.
TEXT
.
value
.
equals
(
type
)&&
item
.
getContent
().
contains
(
USER_SEND_CONTENT
))
{
item
.
setContent
(
item
.
getContent
().
replace
(
USER_SEND_CONTENT
,
userSendContent
));
}
}
}
return
itemNew
;
}
}
}
}
return
items
;
return
items
;
...
...
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