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
c9cff496
Commit
c9cff496
authored
Aug 13, 2019
by
阮思源
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改个人机器人触发关键词的bug
parent
27c2119a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
12 deletions
+23
-12
BookKeywordBizImpl.java
...com/pcloud/book/keywords/biz/impl/BookKeywordBizImpl.java
+23
-12
No files found.
pcloud-service-book/src/main/java/com/pcloud/book/keywords/biz/impl/BookKeywordBizImpl.java
View file @
c9cff496
...
@@ -25,6 +25,7 @@ import com.pcloud.book.group.entity.GroupQrcode;
...
@@ -25,6 +25,7 @@ import com.pcloud.book.group.entity.GroupQrcode;
import
com.pcloud.book.group.enums.TouchTypeEnum
;
import
com.pcloud.book.group.enums.TouchTypeEnum
;
import
com.pcloud.book.group.tools.SendWeixinRequestTools
;
import
com.pcloud.book.group.tools.SendWeixinRequestTools
;
import
com.pcloud.book.group.vo.ClassifyNameVO
;
import
com.pcloud.book.group.vo.ClassifyNameVO
;
import
com.pcloud.book.group.vo.GroupQrcodeBaseInfoVO
;
import
com.pcloud.book.keywords.biz.BookKeywordBiz
;
import
com.pcloud.book.keywords.biz.BookKeywordBiz
;
import
com.pcloud.book.keywords.dao.BookKeywordDao
;
import
com.pcloud.book.keywords.dao.BookKeywordDao
;
import
com.pcloud.book.keywords.dao.BookKeywordRecordDao
;
import
com.pcloud.book.keywords.dao.BookKeywordRecordDao
;
...
@@ -425,12 +426,14 @@ public class BookKeywordBizImpl implements BookKeywordBiz {
...
@@ -425,12 +426,14 @@ public class BookKeywordBizImpl implements BookKeywordBiz {
this
.
sendKeywordMessageToGroup
(
content
,
weixinGroupId
,
userWxId
,
robotId
,
ip
,
code
);
this
.
sendKeywordMessageToGroup
(
content
,
weixinGroupId
,
userWxId
,
robotId
,
ip
,
code
);
return
;
return
;
}
}
//消息为个人机器人消息时,其实weixinGroupId是机器人id
String
altId
=
weixinGroupId
;
//简单过滤非关键词的词
//简单过滤非关键词的词
if
(
StringUtil
.
isEmpty
(
content
)
||
content
.
length
()
>
20
)
{
if
(
StringUtil
.
isEmpty
(
content
)
||
content
.
length
()
>
20
)
{
return
;
return
;
}
}
// TODO 根据小号和用户id获取所有相关的分类id,若该关键词存在多本书,则组装成文本加链接一次发送
// TODO 根据小号和用户id获取所有相关的分类id,若该关键词存在多本书,则组装成文本加链接一次发送
final
List
<
JoinGroupCipherDTO
>
dtos
=
bookGroupBiz
.
getClassifyIdsByWxIdAndAltId
(
weixinGroup
Id
,
robotId
);
final
List
<
JoinGroupCipherDTO
>
dtos
=
bookGroupBiz
.
getClassifyIdsByWxIdAndAltId
(
alt
Id
,
robotId
);
if
(
CollectionUtils
.
isEmpty
(
dtos
))
{
if
(
CollectionUtils
.
isEmpty
(
dtos
))
{
log
.
info
(
"[关键词消息回复] classifyIds is null"
);
log
.
info
(
"[关键词消息回复] classifyIds is null"
);
return
;
return
;
...
@@ -469,40 +472,42 @@ public class BookKeywordBizImpl implements BookKeywordBiz {
...
@@ -469,40 +472,42 @@ public class BookKeywordBizImpl implements BookKeywordBiz {
final
Map
<
Long
,
GroupClassifyQrcodeDTO
>
classifyMap
=
qrcodeDTOS
.
stream
().
collect
(
Collectors
.
toMap
(
GroupClassifyQrcodeDTO:
:
getClassifyId
,
p
->
p
,
(
v1
,
v2
)
->
v2
));
final
Map
<
Long
,
GroupClassifyQrcodeDTO
>
classifyMap
=
qrcodeDTOS
.
stream
().
collect
(
Collectors
.
toMap
(
GroupClassifyQrcodeDTO:
:
getClassifyId
,
p
->
p
,
(
v1
,
v2
)
->
v2
));
// 记录循环插入,消息一条发送
// 记录循环插入,消息一条发送
for
(
ReplyKeywordDTO
replyKeywordDTO
:
replyKeywordDTOs
)
{
for
(
ReplyKeywordDTO
replyKeywordDTO
:
replyKeywordDTOs
)
{
log
.
info
(
"[关键词回复原始数据] : sendKeywordMessage replyKeywordDTO :{}, robotId:{},
weixinGroupId:{}"
,
replyKeywordDTO
,
robotId
,
weixinGroup
Id
);
log
.
info
(
"[关键词回复原始数据] : sendKeywordMessage replyKeywordDTO :{}, robotId:{},
altId:{}"
,
replyKeywordDTO
,
robotId
,
alt
Id
);
// 处理链接地址
// 处理链接地址
Long
classifyId
=
keywordClassifyIdMap
.
get
(
replyKeywordDTO
.
getKeywordId
());
Long
classifyId
=
keywordClassifyIdMap
.
get
(
replyKeywordDTO
.
getKeywordId
());
final
GroupClassifyQrcodeDTO
dto
=
classifyMap
.
get
(
classifyId
);
final
GroupClassifyQrcodeDTO
dto
=
classifyMap
.
get
(
classifyId
);
Long
qrcodeId
=
classifyToQrcodeMap
.
get
(
dto
.
getClassifyId
());
GroupQrcodeBaseInfoVO
qrcodeInfo
=
groupQrcodeDao
.
getBaseById
(
qrcodeId
);
if
(
ReplyTypeEnum
.
APP
.
value
.
equals
(
replyKeywordDTO
.
getReplyType
())
||
ReplyTypeEnum
.
LINK
.
value
.
equals
(
replyKeywordDTO
.
getReplyType
()))
{
if
(
ReplyTypeEnum
.
APP
.
value
.
equals
(
replyKeywordDTO
.
getReplyType
())
||
ReplyTypeEnum
.
LINK
.
value
.
equals
(
replyKeywordDTO
.
getReplyType
()))
{
if
(
null
==
dto
)
{
if
(
null
==
dto
)
{
log
.
info
(
"[关键词消息回复] 分类信息为空 replyKeywordDTO:{}; classifyMap:{}"
,
replyKeywordDTO
,
classifyMap
);
log
.
info
(
"[关键词消息回复] 分类信息为空 replyKeywordDTO:{}; classifyMap:{}"
,
replyKeywordDTO
,
classifyMap
);
continue
;
continue
;
}
}
AccountSettingDto
accountSettingDto
=
qrcodeSceneConsr
.
getWechatInfo
(
dto
.
getChannelId
());
AccountSettingDto
accountSettingDto
=
qrcodeSceneConsr
.
getWechatInfo
(
dto
.
getChannelId
());
String
linkUrl
=
SendWeixinRequestTools
.
splitUrlNew
(
accountSettingDto
,
replyKeywordDTO
.
getLinkUrl
(),
dto
.
getBookGroupId
(),
dto
.
getClassifyId
(),
classifyToQrcodeMap
.
get
(
dto
.
getClassifyId
())
);
String
linkUrl
=
SendWeixinRequestTools
.
splitUrlNew
(
accountSettingDto
,
replyKeywordDTO
.
getLinkUrl
(),
dto
.
getBookGroupId
(),
dto
.
getClassifyId
(),
qrcodeId
);
replyKeywordDTO
.
setLinkUrl
(
linkUrl
);
replyKeywordDTO
.
setLinkUrl
(
linkUrl
);
if
(!
StringUtil
.
isEmpty
(
linkUrl
))
{
if
(!
StringUtil
.
isEmpty
(
linkUrl
))
{
replyKeywordDTO
.
setShortLinkUrl
(
UrlUtils
.
getShortUrl4Own
(
linkUrl
));
replyKeywordDTO
.
setShortLinkUrl
(
UrlUtils
.
getShortUrl4Own
(
linkUrl
));
}
}
}
}
String
redisContent
=
JedisClusterUtils
.
getJson
(
"BOOK:KEYWORD:"
+
weixinGroup
Id
+
"-"
+
replyKeywordDTO
.
getKeywordId
(),
String
.
class
);
String
redisContent
=
JedisClusterUtils
.
getJson
(
"BOOK:KEYWORD:"
+
alt
Id
+
"-"
+
replyKeywordDTO
.
getKeywordId
(),
String
.
class
);
// 同一群10秒内不回复同一关键词
// 同一群10秒内不回复同一关键词
if
(
insertBookKeywordRecord
(
weixinGroupId
,
userWxId
,
replyKeywordDTO
,
dto
,
redisContent
))
{
if
(
insertBookKeywordRecord
(
qrcodeInfo
.
getWeixinGroupId
()
,
userWxId
,
replyKeywordDTO
,
dto
,
redisContent
))
{
return
;
return
;
}
}
//获取推送消息机器人
//获取推送消息机器人
// 20190704改为收发一体
// 20190704改为收发一体
if
(
StringUtil
.
isBlank
(
robotId
))
{
if
(
StringUtil
.
isBlank
(
robotId
))
{
log
.
info
(
"[关键词消息回复] robotId is null content:{}, robotId:{},weixinGroupId:{}"
,
content
,
robotId
,
weixinGroupId
);
log
.
info
(
"[关键词消息回复] robotId is null content:{}, robotId:{},weixinGroupId:{}"
,
content
,
robotId
,
qrcodeInfo
.
getWeixinGroupId
()
);
robotId
=
wechatGroupConsr
.
getRobotIdByGroupId
(
weixinGroupId
);
robotId
=
wechatGroupConsr
.
getRobotIdByGroupId
(
qrcodeInfo
.
getWeixinGroupId
()
);
}
}
log
.
info
(
"[关键词回复发送数据] : sendKeywordMessage replyKeywordDTO :{}, robotId:{}, weixinGroupId:{}"
,
replyKeywordDTO
,
robotId
,
weixinGroupId
);
log
.
info
(
"[关键词回复发送数据] : sendKeywordMessage replyKeywordDTO :{}, robotId:{}, weixinGroupId:{}"
,
replyKeywordDTO
,
robotId
,
qrcodeInfo
.
getWeixinGroupId
()
);
//新增关键词触发记录
//新增关键词触发记录
addKeywordAppTouchRecord
(
replyKeywordDTO
,
weixinGroupId
,
dto
.
getClassifyId
(),
dto
.
getBookGroupId
());
addKeywordAppTouchRecord
(
replyKeywordDTO
,
qrcodeInfo
.
getWeixinGroupId
()
,
dto
.
getClassifyId
(),
dto
.
getBookGroupId
());
}
}
// 单条还是按原来的发送
// 单条还是按原来的发送
if
(
replyKeywordDTOs
.
size
()
<=
1
)
{
if
(
replyKeywordDTOs
.
size
()
<=
1
)
{
SendWeixinRequestTools
.
sendKeywordMessage
(
replyKeywordDTOs
.
get
(
0
),
robotId
,
weixinGroup
Id
,
ip
,
code
);
SendWeixinRequestTools
.
sendKeywordMessage
(
replyKeywordDTOs
.
get
(
0
),
robotId
,
alt
Id
,
ip
,
code
);
}
else
{
}
else
{
// 多条时文字,应用,链接组装成一条发送
// 多条时文字,应用,链接组装成一条发送
ReplyKeywordDTO
d
=
new
ReplyKeywordDTO
();
ReplyKeywordDTO
d
=
new
ReplyKeywordDTO
();
...
@@ -513,13 +518,13 @@ public class BookKeywordBizImpl implements BookKeywordBiz {
...
@@ -513,13 +518,13 @@ public class BookKeywordBizImpl implements BookKeywordBiz {
}
else
if
(
ReplyTypeEnum
.
TEXT
.
value
.
equals
(
dto
.
getReplyType
())){
}
else
if
(
ReplyTypeEnum
.
TEXT
.
value
.
equals
(
dto
.
getReplyType
())){
sb
.
append
(
dto
.
getKeywords
()).
append
(
":"
).
append
(
dto
.
getContent
()).
append
(
"\n"
);
sb
.
append
(
dto
.
getKeywords
()).
append
(
":"
).
append
(
dto
.
getContent
()).
append
(
"\n"
);
}
else
if
(
ReplyTypeEnum
.
IMAGE
.
value
.
equals
(
dto
.
getReplyType
()))
{
}
else
if
(
ReplyTypeEnum
.
IMAGE
.
value
.
equals
(
dto
.
getReplyType
()))
{
SendWeixinRequestTools
.
sendKeywordMessage
(
d
,
robotId
,
weixinGroup
Id
,
ip
,
code
);
SendWeixinRequestTools
.
sendKeywordMessage
(
d
,
robotId
,
alt
Id
,
ip
,
code
);
continue
;
continue
;
}
}
}
}
d
.
setContent
(
sb
.
toString
());
d
.
setContent
(
sb
.
toString
());
d
.
setReplyType
(
ReplyTypeEnum
.
TEXT
.
value
);
d
.
setReplyType
(
ReplyTypeEnum
.
TEXT
.
value
);
SendWeixinRequestTools
.
sendKeywordMessage
(
d
,
robotId
,
weixinGroup
Id
,
ip
,
code
);
SendWeixinRequestTools
.
sendKeywordMessage
(
d
,
robotId
,
alt
Id
,
ip
,
code
);
}
}
}
}
...
@@ -635,6 +640,12 @@ public class BookKeywordBizImpl implements BookKeywordBiz {
...
@@ -635,6 +640,12 @@ public class BookKeywordBizImpl implements BookKeywordBiz {
bookKeywordRecord
.
setUserWxId
(
userWxId
);
bookKeywordRecord
.
setUserWxId
(
userWxId
);
bookKeywordRecord
.
setWeixinGroupId
(
weixinGroupId
);
bookKeywordRecord
.
setWeixinGroupId
(
weixinGroupId
);
bookKeywordRecord
.
setSend
(
isSend
);
bookKeywordRecord
.
setSend
(
isSend
);
if
(
bookKeywordRecord
.
getGroupQrcodeId
()
==
null
)
{
GroupQrcode
groupQr
=
groupQrcodeDao
.
getGroupQrcodeByGroupId
(
weixinGroupId
);
if
(
groupQr
!=
null
){
bookKeywordRecord
.
setGroupQrcodeId
(
groupQr
.
getId
());
}
}
bookKeywordRecordDao
.
insert
(
bookKeywordRecord
);
bookKeywordRecordDao
.
insert
(
bookKeywordRecord
);
}
}
...
...
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