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
f45d1464
Commit
f45d1464
authored
Feb 11, 2020
by
裴大威
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'fix-pcloudAgentRecord' into 'master'
bug 1020214 解决小睿出版社收录无响应的问题 See merge request rays/pcloud-book!381
parents
7394cd54
de3cc30f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
76 additions
and
69 deletions
+76
-69
BookKeywordBizImpl.java
...com/pcloud/book/keywords/biz/impl/BookKeywordBizImpl.java
+76
-69
No files found.
pcloud-service-book/src/main/java/com/pcloud/book/keywords/biz/impl/BookKeywordBizImpl.java
View file @
f45d1464
...
@@ -547,44 +547,46 @@ public class BookKeywordBizImpl implements BookKeywordBiz {
...
@@ -547,44 +547,46 @@ public class BookKeywordBizImpl implements BookKeywordBiz {
//判断是否是平台端配置的小号,如果是,走平台端
//判断是否是平台端配置的小号,如果是,走平台端
PcloudRobot
pcloudRobot
=
pcloudRobotDao
.
getByWxId
(
sendTextDTO
.
getWxId
());
PcloudRobot
pcloudRobot
=
pcloudRobotDao
.
getByWxId
(
sendTextDTO
.
getWxId
());
if
(
pcloudRobot
!=
null
){
if
(
pcloudRobot
!=
null
){
// 小睿对话索要出版社信息
boolean
_continue
=
replySelfKeywordTemplate
(
sendTextDTO
);
// 判断是否需要继续走下去
if
(!
_continue
)
{
return
;
}
sendPcloudKeyword
(
sendTextDTO
,
pcloudRobot
);
sendPcloudKeyword
(
sendTextDTO
,
pcloudRobot
);
return
;
return
;
}
}
if
(
SendMessageTypeEnum
.
SELF
.
getCode
().
equals
(
sendTextDTO
.
getCode
()))
{
if
(
SendMessageTypeEnum
.
SELF
.
getCode
().
equals
(
sendTextDTO
.
getCode
()))
{
// 小睿对话索要出版社信息
dealBookGroupCipher
(
sendTextDTO
);
boolean
_continue
=
replySelfKeywordTemplate
(
sendTextDTO
);
//判断是否为某个群分类名称
if
(
_continue
)
{
inviteToGroupByKeyword
(
sendTextDTO
);
dealBookGroupCipher
(
sendTextDTO
);
//智能机器人新版个人号回复
//判断是否为某个群分类名称
dealSelfShortBookName
(
sendTextDTO
);
inviteToGroupByKeyword
(
sendTextDTO
);
//回复关键词
//智能机器人新版个人号回复
replySelfKeyword
(
sendTextDTO
);
dealSelfShortBookName
(
sendTextDTO
);
//回复关键词
replySelfKeyword
(
sendTextDTO
);
}
}
}
}
}
@ParamLog
(
"小睿根据书名推送匹配的资源"
)
@ParamLog
(
"小睿根据书名推送匹配的资源"
)
private
boolean
replySelfKeywordTemplate
(
SendTextDTO
sendTextDTO
)
{
private
boolean
replySelfKeywordTemplate
(
SendTextDTO
sendTextDTO
)
{
String
content
=
sendTextDTO
.
getTextContent
();
try
{
String
redisKey
=
"replySelfKeywordTemplate:"
+
sendTextDTO
.
getWxId
()+
":"
+
sendTextDTO
.
getWechatUserId
();
String
content
=
sendTextDTO
.
getTextContent
();
List
<
SelfRobotKeywordReplyTemplate
>
replyTemplateList
=
selfRobotKeywordReplyTemplateDao
.
getList
();
String
redisKey
=
"replySelfKeywordTemplate:"
+
sendTextDTO
.
getWxId
()+
":"
+
sendTextDTO
.
getWechatUserId
();
// 解析出《》的书名
List
<
SelfRobotKeywordReplyTemplate
>
replyTemplateList
=
selfRobotKeywordReplyTemplateDao
.
getList
();
Pattern
pattern
=
Pattern
.
compile
(
"《(.*?)》"
);
// 解析出《》的书名
Matcher
matcher
=
pattern
.
matcher
(
content
);
Pattern
pattern
=
Pattern
.
compile
(
"《(.*?)》"
);
// 如果匹配不到,在匹配出版社
Matcher
matcher
=
pattern
.
matcher
(
content
);
if
(!
matcher
.
find
()
||
matcher
.
group
(
1
).
trim
().
isEmpty
())
{
// 如果匹配不到,在匹配出版社
// 解析出版社 出版社:
if
(!
matcher
.
find
()
||
matcher
.
group
(
1
).
trim
().
isEmpty
())
{
int
index
=
content
.
indexOf
(
"出版社:"
);
// 解析出版社 出版社:
// 再匹配不到,直接返回,并走接下来的逻辑
int
index
=
content
.
indexOf
(
"出版社:"
);
if
(
index
==
-
1
)
{
// 再匹配不到,直接返回,并走接下来的逻辑
index
=
content
.
indexOf
(
"出版社:"
);
if
(
index
==
-
1
)
{
if
(
index
==
-
1
)
index
=
content
.
indexOf
(
"出版社:"
);
return
true
;
if
(
index
==
-
1
)
}
return
true
;
String
agentName
=
content
.
substring
(
index
+
4
);
}
if
(
StringUtil
.
isNotNull
(
agentName
)){
String
agentName
=
content
.
substring
(
index
+
4
);
// 如果出版社名称为空,则直接return走非关键逻辑
if
(
StringUtil
.
isEmpty
(
agentName
)){
return
true
;
}
// 从redis取出书名
// 从redis取出书名
String
bookName
=
JedisClusterUtils
.
get
(
redisKey
);
String
bookName
=
JedisClusterUtils
.
get
(
redisKey
);
// 删掉书名
// 删掉书名
...
@@ -601,51 +603,56 @@ public class BookKeywordBizImpl implements BookKeywordBiz {
...
@@ -601,51 +603,56 @@ public class BookKeywordBizImpl implements BookKeywordBiz {
}
}
Optional
<
SelfRobotKeywordReplyTemplate
>
replyTemplate
=
replyTemplateList
.
stream
().
filter
(
x
->
x
.
getStatus
().
equals
(
2
)).
findFirst
();
Optional
<
SelfRobotKeywordReplyTemplate
>
replyTemplate
=
replyTemplateList
.
stream
().
filter
(
x
->
x
.
getStatus
().
equals
(
2
)).
findFirst
();
sendText
(
sendTextDTO
,
replyTemplate
.
get
().
getReplyContentTemplate
());
sendText
(
sendTextDTO
,
replyTemplate
.
get
().
getReplyContentTemplate
());
return
false
;
}
}
}
String
bookName
=
matcher
.
group
(
1
).
trim
();
String
bookName
=
matcher
.
group
(
1
).
trim
();
// 根据书名查询到 bookIds
// 根据书名查询到 bookIds
List
<
Long
>
bookIds
=
bookDao
.
getBookIdsByBookName
(
bookName
);
List
<
Long
>
bookIds
=
bookDao
.
getBookIdsByBookName
(
bookName
);
if
(
ListUtils
.
isEmpty
(
bookIds
)){
if
(
ListUtils
.
isEmpty
(
bookIds
)){
// 将书名写入redis暂存
// 将书名写入redis暂存
JedisClusterUtils
.
set
(
redisKey
,
bookName
);
JedisClusterUtils
.
set
(
redisKey
,
bookName
);
// 如果bookIds没有值,则回复模板状态3
// 如果bookIds没有值,则回复模板状态3
// 呃,小睿刚才仔细的找了下,发现书刊的配套资源我这边还没有呢,要不等小睿看完整理好后再给你吧
// 呃,小睿刚才仔细的找了下,发现书刊的配套资源我这边还没有呢,要不等小睿看完整理好后再给你吧
Optional
<
SelfRobotKeywordReplyTemplate
>
replyTemplate
=
replyTemplateList
.
stream
().
filter
(
x
->
x
.
getStatus
().
equals
(
3
)).
findFirst
();
Optional
<
SelfRobotKeywordReplyTemplate
>
replyTemplate
=
replyTemplateList
.
stream
().
filter
(
x
->
x
.
getStatus
().
equals
(
3
)).
findFirst
();
sendText
(
sendTextDTO
,
replyTemplate
.
get
().
getReplyContentTemplate
().
replace
(
"${bookName}"
,
bookName
));
}
else
{
// 根据bookIds查询资源数;
Integer
totalCount
=
channelConsr
.
getMessageCountByBookIds
(
bookIds
);
if
(
totalCount
>
0
){
// 信息录入
SelfRobotBookRecord
selfRobotBookRecord
=
new
SelfRobotBookRecord
();
selfRobotBookRecord
.
setWxUserId
(
sendTextDTO
.
getWechatUserId
());
selfRobotBookRecord
.
setAltId
(
sendTextDTO
.
getWxId
());
selfRobotBookRecord
.
setBookName
(
bookName
);
selfRobotBookRecord
.
setStatus
(
3
);
selfRobotBookRecordDao
.
insert
(
selfRobotBookRecord
);
// 如果有书有资源,则转换链接,并推送链接给用户
Map
<
String
,
String
>
paramMap
=
new
HashMap
<>();
paramMap
.
put
(
"wxId"
,
sendTextDTO
.
getWechatUserId
());
paramMap
.
put
(
"robotWxId"
,
sendTextDTO
.
getWxId
());
paramMap
.
put
(
"bookName"
,
URLEncoder
.
encode
(
bookName
));
Optional
<
SelfRobotKeywordReplyTemplate
>
replyTemplate
=
replyTemplateList
.
stream
().
filter
(
x
->
x
.
getStatus
().
equals
(
4
)).
findFirst
();
sendText
(
sendTextDTO
,
appendUrlParams
(
replyTemplate
.
get
().
getReplyContentTemplate
(),
paramMap
));
}
else
{
// 信息录入
SelfRobotBookRecord
selfRobotBookRecord
=
new
SelfRobotBookRecord
();
selfRobotBookRecord
.
setWxUserId
(
sendTextDTO
.
getWechatUserId
());
selfRobotBookRecord
.
setAltId
(
sendTextDTO
.
getWxId
());
selfRobotBookRecord
.
setBookName
(
bookName
);
selfRobotBookRecord
.
setStatus
(
1
);
selfRobotBookRecordDao
.
insert
(
selfRobotBookRecord
);
// 如果有书但没有资源,则回复模板状态1
Optional
<
SelfRobotKeywordReplyTemplate
>
replyTemplate
=
replyTemplateList
.
stream
().
filter
(
x
->
x
.
getStatus
().
equals
(
1
)).
findFirst
();
sendText
(
sendTextDTO
,
replyTemplate
.
get
().
getReplyContentTemplate
().
replace
(
"${bookName}"
,
bookName
));
sendText
(
sendTextDTO
,
replyTemplate
.
get
().
getReplyContentTemplate
().
replace
(
"${bookName}"
,
bookName
));
return
false
;
}
else
{
// 根据bookIds查询资源数;
Integer
totalCount
=
channelConsr
.
getMessageCountByBookIds
(
bookIds
);
if
(
totalCount
>
0
){
// 信息录入
SelfRobotBookRecord
selfRobotBookRecord
=
new
SelfRobotBookRecord
();
selfRobotBookRecord
.
setWxUserId
(
sendTextDTO
.
getWechatUserId
());
selfRobotBookRecord
.
setAltId
(
sendTextDTO
.
getWxId
());
selfRobotBookRecord
.
setBookName
(
bookName
);
selfRobotBookRecord
.
setStatus
(
3
);
selfRobotBookRecordDao
.
insert
(
selfRobotBookRecord
);
// 如果有书有资源,则转换链接,并推送链接给用户
Map
<
String
,
String
>
paramMap
=
new
HashMap
<>();
paramMap
.
put
(
"wxId"
,
sendTextDTO
.
getWechatUserId
());
paramMap
.
put
(
"robotWxId"
,
sendTextDTO
.
getWxId
());
paramMap
.
put
(
"bookName"
,
URLEncoder
.
encode
(
bookName
));
Optional
<
SelfRobotKeywordReplyTemplate
>
replyTemplate
=
replyTemplateList
.
stream
().
filter
(
x
->
x
.
getStatus
().
equals
(
4
)).
findFirst
();
sendText
(
sendTextDTO
,
appendUrlParams
(
replyTemplate
.
get
().
getReplyContentTemplate
(),
paramMap
));
}
else
{
// 信息录入
SelfRobotBookRecord
selfRobotBookRecord
=
new
SelfRobotBookRecord
();
selfRobotBookRecord
.
setWxUserId
(
sendTextDTO
.
getWechatUserId
());
selfRobotBookRecord
.
setAltId
(
sendTextDTO
.
getWxId
());
selfRobotBookRecord
.
setBookName
(
bookName
);
selfRobotBookRecord
.
setStatus
(
1
);
selfRobotBookRecordDao
.
insert
(
selfRobotBookRecord
);
// 如果有书但没有资源,则回复模板状态1
Optional
<
SelfRobotKeywordReplyTemplate
>
replyTemplate
=
replyTemplateList
.
stream
().
filter
(
x
->
x
.
getStatus
().
equals
(
1
)).
findFirst
();
sendText
(
sendTextDTO
,
replyTemplate
.
get
().
getReplyContentTemplate
().
replace
(
"${bookName}"
,
bookName
));
}
return
false
;
}
}
}
catch
(
Exception
e
)
{
log
.
info
(
"小睿收集出版社信息异常;异常信息:"
+
e
.
getMessage
());
return
true
;
}
}
return
false
;
}
}
@ParamLog
(
"发送平台端小号的"
)
@ParamLog
(
"发送平台端小号的"
)
...
...
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