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
a02a2f45
Commit
a02a2f45
authored
Aug 07, 2019
by
裴大威
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
revert keyword
parent
84344081
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
200 additions
and
51 deletions
+200
-51
BookApplication.java
...e-book/src/main/java/com/pcloud/book/BookApplication.java
+10
-0
SendWeixinRequestTools.java
...a/com/pcloud/book/group/tools/SendWeixinRequestTools.java
+29
-13
BookGuideBiz.java
.../main/java/com/pcloud/book/keywords/biz/BookGuideBiz.java
+6
-0
BookKeywordBiz.java
...ain/java/com/pcloud/book/keywords/biz/BookKeywordBiz.java
+2
-1
BookGuideBizImpl.java
...a/com/pcloud/book/keywords/biz/impl/BookGuideBizImpl.java
+27
-33
BookKeywordBizImpl.java
...com/pcloud/book/keywords/biz/impl/BookKeywordBizImpl.java
+72
-2
MQTopicConumer.java
...c/main/java/com/pcloud/book/mq/config/MQTopicConumer.java
+5
-0
WxAgreeAddUserListener.java
...java/com/pcloud/book/mq/topic/WxAgreeAddUserListener.java
+45
-0
WxGroupSendTextListener.java
...ava/com/pcloud/book/mq/topic/WxGroupSendTextListener.java
+3
-2
BookGroupMapper.xml
...-book/src/main/resources/mapper/group/BookGroupMapper.xml
+1
-0
No files found.
pcloud-service-book/src/main/java/com/pcloud/book/BookApplication.java
View file @
a02a2f45
...
@@ -198,4 +198,14 @@ public class BookApplication {
...
@@ -198,4 +198,14 @@ public class BookApplication {
public
Binding
wxGroupLearningReportBind
()
{
public
Binding
wxGroupLearningReportBind
()
{
return
RabbitMQFactory
.
bindingExchange
(
wxGroupLearningReportQueue
(),
MQTopicProducer
.
WXGROUP_LEARNING_REPORT
);
return
RabbitMQFactory
.
bindingExchange
(
wxGroupLearningReportQueue
(),
MQTopicProducer
.
WXGROUP_LEARNING_REPORT
);
}
}
@Bean
public
Queue
wxGroupAgreeAddUserQueue
()
{
return
RabbitMQFactory
.
queueBuilder
(
MQTopicConumer
.
WXGROUP_AGREE_ADD_USER
);
}
@Bean
public
Binding
wxGroupAgreeAddUserBind
()
{
return
RabbitMQFactory
.
bindingExchange
(
wxGroupAgreeAddUserQueue
(),
MQTopicProducer
.
WX_AGREE_ADD_USER
);
}
}
}
pcloud-service-book/src/main/java/com/pcloud/book/group/tools/SendWeixinRequestTools.java
View file @
a02a2f45
...
@@ -18,6 +18,7 @@ import com.pcloud.common.utils.string.StringUtil;
...
@@ -18,6 +18,7 @@ import com.pcloud.common.utils.string.StringUtil;
import
com.sdk.wxgroup.ChangeNameVO
;
import
com.sdk.wxgroup.ChangeNameVO
;
import
com.sdk.wxgroup.QrcodeVO
;
import
com.sdk.wxgroup.QrcodeVO
;
import
com.sdk.wxgroup.SendArticleMessageVO
;
import
com.sdk.wxgroup.SendArticleMessageVO
;
import
com.sdk.wxgroup.SendMessageTypeEnum
;
import
com.sdk.wxgroup.SendPicMessageVO
;
import
com.sdk.wxgroup.SendPicMessageVO
;
import
com.sdk.wxgroup.SendTextMessageVO
;
import
com.sdk.wxgroup.SendTextMessageVO
;
import
com.sdk.wxgroup.WxGroupSDK
;
import
com.sdk.wxgroup.WxGroupSDK
;
...
@@ -127,8 +128,8 @@ public class SendWeixinRequestTools {
...
@@ -127,8 +128,8 @@ public class SendWeixinRequestTools {
}*/
}*/
}
}
@ParamLog
(
"
修改微信群名称
"
)
@ParamLog
(
"
发送欢迎语消息
"
)
public
static
void
sendGuideMessage
(
List
<
ReplyMessageVO
>
replyMessages
,
String
robotId
,
String
weixinGroupId
,
String
ip
)
{
public
static
void
sendGuideMessage
(
List
<
ReplyMessageVO
>
replyMessages
,
String
robotId
,
String
weixinGroupId
,
String
ip
,
Integer
code
)
{
//JedisClusterUtils.del("BOOK:WEIXINGROUP:GUIDEUSER" + weixinGroupId);
//JedisClusterUtils.del("BOOK:WEIXINGROUP:GUIDEUSER" + weixinGroupId);
if
(
ListUtils
.
isEmpty
(
replyMessages
))
{
if
(
ListUtils
.
isEmpty
(
replyMessages
))
{
return
;
return
;
...
@@ -148,20 +149,21 @@ public class SendWeixinRequestTools {
...
@@ -148,20 +149,21 @@ public class SendWeixinRequestTools {
}
}
}
}
}
}
sendMessage
(
sendMessageDTO
,
robotId
,
weixinGroupId
,
ip
);
sendMessage
(
sendMessageDTO
,
robotId
,
weixinGroupId
,
ip
,
code
);
i
++;
i
++;
}
}
}
}
@ParamLog
(
"推送消息"
)
@ParamLog
(
"推送消息"
)
private
static
void
sendMessage
(
SendMessageDTO
sendMessageDTO
,
String
robotId
,
String
weixinGroupId
,
String
ip
)
{
private
static
void
sendMessage
(
SendMessageDTO
sendMessageDTO
,
String
robotId
,
String
weixinGroupId
,
String
ip
,
Integer
code
)
{
if
(
ReplyTypeEnum
.
TEXT
.
value
.
equals
(
sendMessageDTO
.
getReplyType
()))
{
if
(
ReplyTypeEnum
.
TEXT
.
value
.
equals
(
sendMessageDTO
.
getReplyType
()))
{
SendTextMessageVO
sendTextMessageVO
=
new
SendTextMessageVO
();
SendTextMessageVO
sendTextMessageVO
=
new
SendTextMessageVO
();
sendTextMessageVO
.
setContent
(
sendMessageDTO
.
getContent
());
sendTextMessageVO
.
setContent
(
sendMessageDTO
.
getContent
());
sendTextMessageVO
.
setAltId
(
robotId
);
sendTextMessageVO
.
setAltId
(
robotId
);
sendTextMessageVO
.
setGroupId
(
weixinGroupId
);
sendTextMessageVO
.
setGroupId
(
weixinGroupId
);
sendTextMessageVO
.
setIp
(
ip
);
sendTextMessageVO
.
setIp
(
ip
);
sendTextMessageVO
.
setCode
(
code
);
WxGroupSDK
.
sendTextMessage
(
sendTextMessageVO
);
WxGroupSDK
.
sendTextMessage
(
sendTextMessageVO
);
}
else
if
(
ReplyTypeEnum
.
IMAGE
.
value
.
equals
(
sendMessageDTO
.
getReplyType
()))
{
}
else
if
(
ReplyTypeEnum
.
IMAGE
.
value
.
equals
(
sendMessageDTO
.
getReplyType
()))
{
SendPicMessageVO
sendPicMessageVO
=
new
SendPicMessageVO
();
SendPicMessageVO
sendPicMessageVO
=
new
SendPicMessageVO
();
...
@@ -169,6 +171,7 @@ public class SendWeixinRequestTools {
...
@@ -169,6 +171,7 @@ public class SendWeixinRequestTools {
sendPicMessageVO
.
setAltId
(
robotId
);
sendPicMessageVO
.
setAltId
(
robotId
);
sendPicMessageVO
.
setPicUrl
(
sendMessageDTO
.
getPicUrl
());
sendPicMessageVO
.
setPicUrl
(
sendMessageDTO
.
getPicUrl
());
sendPicMessageVO
.
setIp
(
ip
);
sendPicMessageVO
.
setIp
(
ip
);
sendPicMessageVO
.
setCode
(
code
);
WxGroupSDK
.
sendPicMessage
(
sendPicMessageVO
);
WxGroupSDK
.
sendPicMessage
(
sendPicMessageVO
);
}
else
if
(
ReplyTypeEnum
.
APP
.
value
.
equals
(
sendMessageDTO
.
getReplyType
())
||
ReplyTypeEnum
.
LINK
.
value
.
equals
(
sendMessageDTO
.
getReplyType
()))
{
}
else
if
(
ReplyTypeEnum
.
APP
.
value
.
equals
(
sendMessageDTO
.
getReplyType
())
||
ReplyTypeEnum
.
LINK
.
value
.
equals
(
sendMessageDTO
.
getReplyType
()))
{
SendArticleMessageVO
sendArticleMessageVO
=
new
SendArticleMessageVO
();
SendArticleMessageVO
sendArticleMessageVO
=
new
SendArticleMessageVO
();
...
@@ -179,6 +182,7 @@ public class SendWeixinRequestTools {
...
@@ -179,6 +182,7 @@ public class SendWeixinRequestTools {
sendArticleMessageVO
.
setPicUrl
(
sendMessageDTO
.
getPicUrl
());
sendArticleMessageVO
.
setPicUrl
(
sendMessageDTO
.
getPicUrl
());
sendArticleMessageVO
.
setTitle
(
sendMessageDTO
.
getContent
());
sendArticleMessageVO
.
setTitle
(
sendMessageDTO
.
getContent
());
sendArticleMessageVO
.
setIp
(
ip
);
sendArticleMessageVO
.
setIp
(
ip
);
sendArticleMessageVO
.
setCode
(
code
);
WxGroupSDK
.
sendArticleMessage
(
sendArticleMessageVO
);
WxGroupSDK
.
sendArticleMessage
(
sendArticleMessageVO
);
}
}
}
}
...
@@ -228,10 +232,10 @@ public class SendWeixinRequestTools {
...
@@ -228,10 +232,10 @@ public class SendWeixinRequestTools {
}
}
@ParamLog
(
"推送关键词回复消息"
)
@ParamLog
(
"推送关键词回复消息"
)
public
static
void
sendKeywordMessage
(
ReplyKeywordDTO
replyKeywordDTO
,
String
robotId
,
String
weixinGroupId
,
String
ip
)
{
public
static
void
sendKeywordMessage
(
ReplyKeywordDTO
replyKeywordDTO
,
String
robotId
,
String
weixinGroupId
,
String
ip
,
Integer
code
)
{
SendMessageDTO
sendMessageDTO
=
new
SendMessageDTO
();
SendMessageDTO
sendMessageDTO
=
new
SendMessageDTO
();
BeanUtils
.
copyProperties
(
replyKeywordDTO
,
sendMessageDTO
);
BeanUtils
.
copyProperties
(
replyKeywordDTO
,
sendMessageDTO
);
sendMessage
(
sendMessageDTO
,
robotId
,
weixinGroupId
,
ip
);
sendMessage
(
sendMessageDTO
,
robotId
,
weixinGroupId
,
ip
,
code
);
}
}
@ParamLog
(
"补充域名"
)
@ParamLog
(
"补充域名"
)
...
@@ -269,25 +273,37 @@ public class SendWeixinRequestTools {
...
@@ -269,25 +273,37 @@ public class SendWeixinRequestTools {
}
}
@ParamLog
(
"欢迎语中推送关键词信息"
)
@ParamLog
(
"欢迎语中推送关键词信息"
)
public
static
void
sendKeywordsInfo
(
List
<
KeywordDTO
>
keywords
,
String
robotId
,
String
weixinGroup
Id
,
String
ip
){
public
static
void
sendKeywordsInfo
(
List
<
KeywordDTO
>
keywords
,
String
robotId
,
String
toWx
Id
,
String
ip
){
if
(
ListUtils
.
isEmpty
(
keywords
))
{
if
(
ListUtils
.
isEmpty
(
keywords
))
{
return
;
return
;
}
}
String
content
=
""
;
String
Builder
content
=
new
StringBuilder
()
;
for
(
int
i
=
0
;
i
<
keywords
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
keywords
.
size
();
i
++)
{
KeywordDTO
keywordDTO
=
keywords
.
get
(
i
);
KeywordDTO
keywordDTO
=
keywords
.
get
(
i
);
String
keyword
=
"关键词【"
+
keywordDTO
.
getKeywords
()
+
"】\n"
+
" "
+
keywordDTO
.
getGuide
();
String
keyword
=
"关键词【"
+
keywordDTO
.
getKeywords
()
+
"】\n"
+
" "
+
keywordDTO
.
getGuide
();
if
(
content
.
length
()
+
keyword
.
length
()
>
300
)
{
if
(
content
.
length
()
+
keyword
.
length
()
>
300
)
{
sendTextMessage
(
content
,
robotId
,
weixinGroup
Id
,
ip
);
sendTextMessage
ToSelf
(
content
.
toString
(),
robotId
,
toWx
Id
,
ip
);
content
=
keyword
;
content
=
new
StringBuilder
(
keyword
)
;
}
else
{
}
else
{
content
=
content
+
keyword
;
content
.
append
(
keyword
)
;
}
}
if
(
i
!=
keywords
.
size
()
-
1
)
{
if
(
i
!=
keywords
.
size
()
-
1
)
{
content
=
content
+
"\n"
;
content
.
append
(
"\n"
)
;
}
}
}
}
sendTextMessage
(
content
,
robotId
,
weixinGroupId
,
ip
);
// 1001282-施总需求,群不推送关键词,个人欢迎语推送关键词
// sendTextMessage(content, robotId, weixinGroupId, ip);
sendTextMessageToSelf
(
content
.
toString
(),
robotId
,
toWxId
,
ip
);
}
private
static
void
sendTextMessageToSelf
(
String
content
,
String
robotId
,
String
toWxId
,
String
ip
){
SendTextMessageVO
sendTextMessageVO
=
new
SendTextMessageVO
();
sendTextMessageVO
.
setCode
(
SendMessageTypeEnum
.
SELF
.
getCode
());
sendTextMessageVO
.
setGroupId
(
toWxId
);
sendTextMessageVO
.
setContent
(
content
);
sendTextMessageVO
.
setAltId
(
robotId
);
sendTextMessageVO
.
setIp
(
ip
);
WxGroupSDK
.
sendTextMessage
(
sendTextMessageVO
);
}
}
public
static
void
sendTextMessage
(
String
content
,
String
robotId
,
String
weixinGroupId
,
String
ip
){
public
static
void
sendTextMessage
(
String
content
,
String
robotId
,
String
weixinGroupId
,
String
ip
){
...
...
pcloud-service-book/src/main/java/com/pcloud/book/keywords/biz/BookGuideBiz.java
View file @
a02a2f45
...
@@ -5,6 +5,7 @@ import com.pcloud.book.keywords.vo.GuideVO;
...
@@ -5,6 +5,7 @@ import com.pcloud.book.keywords.vo.GuideVO;
import
com.pcloud.book.keywords.vo.ReplyMessageVO
;
import
com.pcloud.book.keywords.vo.ReplyMessageVO
;
import
com.pcloud.book.keywords.vo.SetGuideVO
;
import
com.pcloud.book.keywords.vo.SetGuideVO
;
import
com.pcloud.book.keywords.vo.UpdateGuideVO
;
import
com.pcloud.book.keywords.vo.UpdateGuideVO
;
import
com.pcloud.wechatgroup.message.dto.AgreeAddUserDTO
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -14,6 +15,11 @@ import java.util.Map;
...
@@ -14,6 +15,11 @@ import java.util.Map;
* @date 2019/4/23 15:46
* @date 2019/4/23 15:46
*/
*/
public
interface
BookGuideBiz
{
public
interface
BookGuideBiz
{
/**
* 同意加好友发送欢迎语
*/
void
sendGuide
(
AgreeAddUserDTO
agreeAddUserDTO
);
/**
/**
* @Author:lili
* @Author:lili
* @Desr:新增欢迎语
* @Desr:新增欢迎语
...
...
pcloud-service-book/src/main/java/com/pcloud/book/keywords/biz/BookKeywordBiz.java
View file @
a02a2f45
...
@@ -6,6 +6,7 @@ import com.pcloud.book.keywords.dto.ReplyKeywordDTO;
...
@@ -6,6 +6,7 @@ import com.pcloud.book.keywords.dto.ReplyKeywordDTO;
import
com.pcloud.book.keywords.dto.ServiceResourceDTO
;
import
com.pcloud.book.keywords.dto.ServiceResourceDTO
;
import
com.pcloud.book.keywords.vo.*
;
import
com.pcloud.book.keywords.vo.*
;
import
com.pcloud.common.page.PageBeanNew
;
import
com.pcloud.common.page.PageBeanNew
;
import
com.sdk.wxgroup.SendMessageTypeEnum
;
import
java.util.List
;
import
java.util.List
;
...
@@ -70,7 +71,7 @@ public interface BookKeywordBiz {
...
@@ -70,7 +71,7 @@ public interface BookKeywordBiz {
* @Desr: 回复关键词消息
* @Desr: 回复关键词消息
* @Date:2019/5/5 16:28
* @Date:2019/5/5 16:28
*/
*/
void
sendKeywordMessage
(
String
content
,
String
weixinGroupId
,
String
userWxId
,
String
robotId
,
String
ip
);
void
sendKeywordMessage
(
String
content
,
String
weixinGroupId
,
String
userWxId
,
String
robotId
,
String
ip
,
Integer
code
);
/**
/**
* 关键词统计
* 关键词统计
...
...
pcloud-service-book/src/main/java/com/pcloud/book/keywords/biz/impl/BookGuideBizImpl.java
View file @
a02a2f45
...
@@ -38,6 +38,10 @@ import com.pcloud.channelcenter.wechat.dto.AccountSettingDto;
...
@@ -38,6 +38,10 @@ import com.pcloud.channelcenter.wechat.dto.AccountSettingDto;
import
com.pcloud.common.core.aspect.ParamLog
;
import
com.pcloud.common.core.aspect.ParamLog
;
import
com.pcloud.common.utils.ListUtils
;
import
com.pcloud.common.utils.ListUtils
;
import
com.pcloud.common.utils.string.StringUtil
;
import
com.pcloud.common.utils.string.StringUtil
;
import
com.pcloud.wechatgroup.message.dto.AgreeAddUserDTO
;
import
com.sdk.wxgroup.SendMessageTypeEnum
;
import
com.sdk.wxgroup.SendTextMessageVO
;
import
com.sdk.wxgroup.WxGroupSDK
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -88,6 +92,20 @@ public class BookGuideBizImpl implements BookGuideBiz {
...
@@ -88,6 +92,20 @@ public class BookGuideBizImpl implements BookGuideBiz {
@Autowired
@Autowired
private
BookGroupClassifyDao
bookGroupClassifyDao
;
private
BookGroupClassifyDao
bookGroupClassifyDao
;
@ParamLog
(
"同意加好友发送欢迎语"
)
@Override
public
void
sendGuide
(
AgreeAddUserDTO
agreeAddUserDTO
)
{
SendTextMessageVO
vo
=
new
SendTextMessageVO
();
vo
.
setContent
(
"你好,我是本书智能小助手,请回复你的进群暗号,获取本书资源服务,以及入群链接如果忘了进群暗号,请重新扫描书上的二维码,点击入群即可获取"
);
vo
.
setCode
(
SendMessageTypeEnum
.
SELF
.
getCode
());
vo
.
setWxId
(
agreeAddUserDTO
.
getRobotWxId
());
vo
.
setGroupId
(
agreeAddUserDTO
.
getUserWxId
());
WxGroupSDK
.
sendTextMessage
(
vo
);
// TODO 推送关键词欢迎语
// List<KeywordDTO> keywords = bookKeywordBiz.listFiveKeyword(classifyQrcodeInfo.getClassifyId(), classifyQrcodeInfo.getBookGroupId());
// SendWeixinRequestTools.sendKeywordsInfo(keywords, agreeAddUserDTO.getRobotWxId(), agreeAddUserDTO.getUserWxId(), agreeAddUserDTO.getIp());
}
@Override
@Override
@ParamLog
(
"新增欢迎语"
)
@ParamLog
(
"新增欢迎语"
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
...
@@ -223,33 +241,8 @@ public class BookGuideBizImpl implements BookGuideBiz {
...
@@ -223,33 +241,8 @@ public class BookGuideBizImpl implements BookGuideBiz {
log
.
info
(
"[关键词消息回复] robotId is null robotId:{},weixinGroupId:{}"
,
robotId
,
weixinGroupId
);
log
.
info
(
"[关键词消息回复] robotId is null robotId:{},weixinGroupId:{}"
,
robotId
,
weixinGroupId
);
robotId
=
wechatGroupConsr
.
getRobotIdByGroupId
(
weixinGroupId
);
robotId
=
wechatGroupConsr
.
getRobotIdByGroupId
(
weixinGroupId
);
}
}
//String robotId = "wxid_e6zsl8oohcnl22";
// 判断是否需要发送
// boolean canSend = false;
// // 查看群成员
// GroupInfoVO groupInfoVO = WxGroupSDK.getGroupInfo(weixinGroupId, robotId);
// log.info("[查看群成员] : groupInfoVO:{}",groupInfoVO);
// if (!CollectionUtils.isEmpty(groupInfoVO.getIdList())) {
// // 查看该用户weixinid
// final List<String> nickName = wechatGroupConsr.getWxUserIdsByNickName(pushAddUserMessageDTO.getNickName());
// log.info("[查看该用户weixinid] : nickName:{}",nickName);
// if(!CollectionUtils.isEmpty(nickName)) {
// final Map<String, Boolean> map = Maps.newHashMap();
// for (String s : groupInfoVO.getIdList()) {
// map.put(s, true);
// }
// for (String s : nickName) {
// if (null != map.get(s) && map.get(s)) {
// // 若在群设置true
// canSend = true;
// break;
// }
// }
// }
// }
// 判断是否黑名单
// 判断是否黑名单
final
Boolean
kickUser
=
wechatGroupConsr
.
isKickUser
(
pushAddUserMessageDTO
.
getNickName
(),
weixinGroupId
);
final
Boolean
kickUser
=
wechatGroupConsr
.
isKickUser
(
pushAddUserMessageDTO
.
getNickName
(),
weixinGroupId
);
// log.info("[推送欢迎语消息]:pushAddUserMessageDTO:{},kickUser:{},canSend:{}", pushAddUserMessageDTO, kickUser,canSend);
log
.
info
(
"[推送欢迎语消息]:pushAddUserMessageDTO:{},kickUser:{}"
,
pushAddUserMessageDTO
,
kickUser
);
log
.
info
(
"[推送欢迎语消息]:pushAddUserMessageDTO:{},kickUser:{}"
,
pushAddUserMessageDTO
,
kickUser
);
// 在群,且非黑名单
// 在群,且非黑名单
// canSend = canSend && !kickUser;
// canSend = canSend && !kickUser;
...
@@ -265,24 +258,25 @@ public class BookGuideBizImpl implements BookGuideBiz {
...
@@ -265,24 +258,25 @@ public class BookGuideBizImpl implements BookGuideBiz {
}
}
//获取公众号基本信息
//获取公众号基本信息
AccountSettingDto
wechatInfo
=
qrcodeSceneConsr
.
getWechatInfo
(
classifyQrcodeInfo
.
getChannelId
());
AccountSettingDto
wechatInfo
=
qrcodeSceneConsr
.
getWechatInfo
(
classifyQrcodeInfo
.
getChannelId
());
//获取关键词信息(改成10个了)
//获取关键词信息(改成10个了)
刘娜需求 1001282 群不推送关键词
List
<
KeywordDTO
>
keywords
=
bookKeywordBiz
.
listFiveKeyword
(
classifyQrcodeInfo
.
getClassifyId
(),
classifyQrcodeInfo
.
getBookGroupId
());
//
List<KeywordDTO> keywords = bookKeywordBiz.listFiveKeyword(classifyQrcodeInfo.getClassifyId(), classifyQrcodeInfo.getBookGroupId());
Boolean
isHaveKeywords
=
!
ListUtils
.
isEmpty
(
keywords
);
//
Boolean isHaveKeywords = !ListUtils.isEmpty(keywords);
if
(
ListUtils
.
isEmpty
(
replyMessages
))
{
if
(
ListUtils
.
isEmpty
(
replyMessages
))
{
//获取群名称
//获取群名称
GroupQrcodeBaseInfoVO
groupInfo
=
groupQrcodeBiz
.
getBaseById
(
classifyQrcodeInfo
.
getGroupQrcodeId
());
GroupQrcodeBaseInfoVO
groupInfo
=
groupQrcodeBiz
.
getBaseById
(
classifyQrcodeInfo
.
getGroupQrcodeId
());
//推送消息
//推送消息 刘娜需求 1001282 群不推送关键词
SendWeixinRequestTools
.
sendDefaultMessage
(
groupInfo
==
null
?
""
:
groupInfo
.
getGroupName
(),
robotId
,
weixinGroupId
,
isHaveKeywords
,
pushAddUserMessageDTO
.
getIp
());
// SendWeixinRequestTools.sendDefaultMessage(groupInfo == null ? "" : groupInfo.getGroupName(), robotId, weixinGroupId, isHaveKeywords, pushAddUserMessageDTO.getIp());
SendWeixinRequestTools
.
sendDefaultMessage
(
groupInfo
==
null
?
""
:
groupInfo
.
getGroupName
(),
robotId
,
weixinGroupId
,
false
,
pushAddUserMessageDTO
.
getIp
());
}
else
{
}
else
{
//处理链接
//处理链接
handleUrl
(
replyMessages
,
wechatInfo
,
classifyQrcodeInfo
);
handleUrl
(
replyMessages
,
wechatInfo
,
classifyQrcodeInfo
);
//推送消息
//推送消息
SendWeixinRequestTools
.
sendGuideMessage
(
replyMessages
,
robotId
,
weixinGroupId
,
pushAddUserMessageDTO
.
getIp
());
SendWeixinRequestTools
.
sendGuideMessage
(
replyMessages
,
robotId
,
weixinGroupId
,
pushAddUserMessageDTO
.
getIp
()
,
SendMessageTypeEnum
.
GROUP
.
getCode
()
);
//新增欢迎语应用触发记录
//新增欢迎语应用触发记录
addGuideAppTouchRecord
(
replyMessages
,
weixinGroupId
,
classifyQrcodeInfo
.
getBookGroupId
(),
classifyQrcodeInfo
.
getClassifyId
());
addGuideAppTouchRecord
(
replyMessages
,
weixinGroupId
,
classifyQrcodeInfo
.
getBookGroupId
(),
classifyQrcodeInfo
.
getClassifyId
());
}
}
//获取关键词信息(改成10个了)
//获取关键词信息(改成10个了)
刘娜需求 1001282 群不推送关键词
SendWeixinRequestTools
.
sendKeywordsInfo
(
keywords
,
robotId
,
weixinGroupId
,
pushAddUserMessageDTO
.
getIp
());
//
SendWeixinRequestTools.sendKeywordsInfo(keywords, robotId, weixinGroupId, pushAddUserMessageDTO.getIp());
//如果设置了群学习报告,加一个群学习报告的关键词
//如果设置了群学习报告,加一个群学习报告的关键词
pushLearningReport
(
classifyQrcodeInfo
,
robotId
,
weixinGroupId
,
pushAddUserMessageDTO
.
getIp
());
pushLearningReport
(
classifyQrcodeInfo
,
robotId
,
weixinGroupId
,
pushAddUserMessageDTO
.
getIp
());
if
(
bookGuide
!=
null
&&
bookGuide
.
getIsRecommend
()
!=
null
&&
bookGuide
.
getIsRecommend
()
==
1
)
{
if
(
bookGuide
!=
null
&&
bookGuide
.
getIsRecommend
()
!=
null
&&
bookGuide
.
getIsRecommend
()
==
1
)
{
...
...
pcloud-service-book/src/main/java/com/pcloud/book/keywords/biz/impl/BookKeywordBizImpl.java
View file @
a02a2f45
...
@@ -53,6 +53,7 @@ import com.pcloud.common.utils.string.StringUtil;
...
@@ -53,6 +53,7 @@ import com.pcloud.common.utils.string.StringUtil;
import
com.pcloud.resourcecenter.product.dto.ProductDto
;
import
com.pcloud.resourcecenter.product.dto.ProductDto
;
import
com.pcloud.resourcecenter.product.dto.ProductTypeDto
;
import
com.pcloud.resourcecenter.product.dto.ProductTypeDto
;
import
com.pcloud.wechatgroup.group.dto.RobotReplyDTO
;
import
com.pcloud.wechatgroup.group.dto.RobotReplyDTO
;
import
com.sdk.wxgroup.SendMessageTypeEnum
;
import
org.apache.commons.collections.MapUtils
;
import
org.apache.commons.collections.MapUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.BeanUtils
;
...
@@ -411,7 +412,76 @@ public class BookKeywordBizImpl implements BookKeywordBiz {
...
@@ -411,7 +412,76 @@ public class BookKeywordBizImpl implements BookKeywordBiz {
@Override
@Override
@ParamLog
(
"关键词消息回复"
)
@ParamLog
(
"关键词消息回复"
)
public
void
sendKeywordMessage
(
String
content
,
String
weixinGroupId
,
String
userWxId
,
String
robotId
,
String
ip
)
{
public
void
sendKeywordMessage
(
String
content
,
String
weixinGroupId
,
String
userWxId
,
String
robotId
,
String
ip
,
Integer
code
)
{
// 刘娜需求 1001282 群不推送关键词
if
(
SendMessageTypeEnum
.
GROUP
.
getCode
().
equals
(
code
))
{
this
.
sendKeywordMessageToGroup
(
content
,
weixinGroupId
,
userWxId
,
robotId
,
ip
,
code
);
return
;
}
//简单过滤非关键词的词
if
(
StringUtil
.
isEmpty
(
content
)
||
content
.
length
()
>
20
)
{
return
;
}
//通过群id获取对应基本信息
GroupClassifyQrcodeDTO
classifyQrcodeInfo
=
bookGroupClassifyBiz
.
getClassifyQrcodeInfo
(
weixinGroupId
);
if
(
classifyQrcodeInfo
==
null
)
{
log
.
info
(
"[关键词消息回复] classifyQrcodeInfo is null"
);
return
;
}
ReplyKeywordDTO
replyKeywordDTO
;
//获取匹配关键词
replyKeywordDTO
=
bookKeywordDao
.
getKeywordId
(
classifyQrcodeInfo
.
getClassifyId
(),
classifyQrcodeInfo
.
getBookGroupId
(),
content
);
if
(
replyKeywordDTO
==
null
)
{
log
.
info
(
"[关键词消息回复] replyKeywordDTO is null"
);
return
;
}
log
.
info
(
"[关键词回复原始数据] : sendKeywordMessage replyKeywordDTO :{}, robotId:{}, weixinGroupId:{}"
,
replyKeywordDTO
,
robotId
,
weixinGroupId
);
// 处理链接地址
if
(
ReplyTypeEnum
.
APP
.
value
.
equals
(
replyKeywordDTO
.
getReplyType
())
||
ReplyTypeEnum
.
LINK
.
value
.
equals
(
replyKeywordDTO
.
getReplyType
()))
{
AccountSettingDto
accountSettingDto
=
qrcodeSceneConsr
.
getWechatInfo
(
classifyQrcodeInfo
.
getChannelId
());
String
linkUrl
=
SendWeixinRequestTools
.
splitUrlNew
(
accountSettingDto
,
replyKeywordDTO
.
getLinkUrl
(),
classifyQrcodeInfo
.
getBookGroupId
(),
classifyQrcodeInfo
.
getClassifyId
(),
classifyQrcodeInfo
.
getGroupQrcodeId
());
replyKeywordDTO
.
setLinkUrl
(
linkUrl
);
}
String
redisContent
=
JedisClusterUtils
.
getJson
(
"BOOK:KEYWORD:"
+
weixinGroupId
+
"-"
+
replyKeywordDTO
.
getKeywordId
(),
String
.
class
);
// 同一群10秒内不回复同一关键词
if
(
redisContent
!=
null
)
{
insertBookKeywordRecord
(
classifyQrcodeInfo
,
replyKeywordDTO
.
getKeywordId
(),
userWxId
,
weixinGroupId
,
false
);
log
.
info
(
"[关键词消息回复] redisContent:{} insertBookKeywordRecord return"
,
redisContent
);
return
;
}
else
{
JedisClusterUtils
.
setJson
(
"BOOK:KEYWORD:"
+
weixinGroupId
+
"-"
+
replyKeywordDTO
.
getKeywordId
(),
replyKeywordDTO
.
getKeywordId
(),
10
);
insertBookKeywordRecord
(
classifyQrcodeInfo
,
replyKeywordDTO
.
getKeywordId
(),
userWxId
,
weixinGroupId
,
true
);
}
//获取推送消息机器人
// 20190704改为收发一体
if
(
StringUtil
.
isBlank
(
robotId
))
{
log
.
info
(
"[关键词消息回复] robotId is null content:{}, robotId:{},weixinGroupId:{}"
,
content
,
robotId
,
weixinGroupId
);
robotId
=
wechatGroupConsr
.
getRobotIdByGroupId
(
weixinGroupId
);
}
log
.
info
(
"[关键词回复发送数据] : sendKeywordMessage replyKeywordDTO :{}, robotId:{}, weixinGroupId:{}"
,
replyKeywordDTO
,
robotId
,
weixinGroupId
);
SendWeixinRequestTools
.
sendKeywordMessage
(
replyKeywordDTO
,
robotId
,
weixinGroupId
,
ip
,
code
);
//新增关键词触发记录
addKeywordAppTouchRecord
(
replyKeywordDTO
,
weixinGroupId
,
classifyQrcodeInfo
.
getClassifyId
(),
classifyQrcodeInfo
.
getBookGroupId
());
//第一推送关键词消息埋点
String
keywordsKey
=
"BOOK:FIRSTKEYWORD:"
+
DateUtils
.
getShortDateStr
()
+
"-"
+
weixinGroupId
;
Boolean
isSend
=
JedisClusterUtils
.
getJson
(
keywordsKey
,
Boolean
.
class
);
if
(
isSend
!=
null
&&
isSend
)
{
return
;
}
JedisClusterUtils
.
setJson
(
keywordsKey
,
true
);
JedisClusterUtils
.
expire
(
keywordsKey
,
86400
);
RobotReplyDTO
robotReplyDTO
=
new
RobotReplyDTO
();
robotReplyDTO
.
setKeyWord
(
content
);
robotReplyDTO
.
setWxGroupId
(
weixinGroupId
);
robotReplyDTO
.
setWxUserId
(
userWxId
);
wechatGroupConsr
.
addFirstRobotReplyRecord
(
robotReplyDTO
);
}
/**
* 原有的推送群关键词改为推送个人关键词
*/
@ParamLog
(
"群关键词消息回复"
)
private
void
sendKeywordMessageToGroup
(
String
content
,
String
weixinGroupId
,
String
userWxId
,
String
robotId
,
String
ip
,
Integer
code
)
{
//简单过滤非关键词的词
//简单过滤非关键词的词
if
(
StringUtil
.
isEmpty
(
content
)
||
content
.
length
()
>
20
)
{
if
(
StringUtil
.
isEmpty
(
content
)
||
content
.
length
()
>
20
)
{
return
;
return
;
...
@@ -458,7 +528,7 @@ public class BookKeywordBizImpl implements BookKeywordBiz {
...
@@ -458,7 +528,7 @@ public class BookKeywordBizImpl implements BookKeywordBiz {
robotId
=
wechatGroupConsr
.
getRobotIdByGroupId
(
weixinGroupId
);
robotId
=
wechatGroupConsr
.
getRobotIdByGroupId
(
weixinGroupId
);
}
}
log
.
info
(
"[关键词回复发送数据] : sendKeywordMessage replyKeywordDTO :{}, robotId:{}, weixinGroupId:{}"
,
replyKeywordDTO
,
robotId
,
weixinGroupId
);
log
.
info
(
"[关键词回复发送数据] : sendKeywordMessage replyKeywordDTO :{}, robotId:{}, weixinGroupId:{}"
,
replyKeywordDTO
,
robotId
,
weixinGroupId
);
SendWeixinRequestTools
.
sendKeywordMessage
(
replyKeywordDTO
,
robotId
,
weixinGroupId
,
ip
);
SendWeixinRequestTools
.
sendKeywordMessage
(
replyKeywordDTO
,
robotId
,
weixinGroupId
,
ip
,
code
);
//新增关键词触发记录
//新增关键词触发记录
addKeywordAppTouchRecord
(
replyKeywordDTO
,
weixinGroupId
,
classifyQrcodeInfo
.
getClassifyId
(),
classifyQrcodeInfo
.
getBookGroupId
());
addKeywordAppTouchRecord
(
replyKeywordDTO
,
weixinGroupId
,
classifyQrcodeInfo
.
getClassifyId
(),
classifyQrcodeInfo
.
getBookGroupId
());
//第一推送关键词消息埋点
//第一推送关键词消息埋点
...
...
pcloud-service-book/src/main/java/com/pcloud/book/mq/config/MQTopicConumer.java
View file @
a02a2f45
...
@@ -70,4 +70,9 @@ public class MQTopicConumer {
...
@@ -70,4 +70,9 @@ public class MQTopicConumer {
*/
*/
public
static
final
String
WXGROUP_LEARNING_REPORT
=
PREFIX
+
MQTopicProducer
.
WXGROUP_LEARNING_REPORT
;
public
static
final
String
WXGROUP_LEARNING_REPORT
=
PREFIX
+
MQTopicProducer
.
WXGROUP_LEARNING_REPORT
;
/**
* 微信群同意添加好友成功
*/
public
static
final
String
WXGROUP_AGREE_ADD_USER
=
PREFIX
+
MQTopicProducer
.
WX_AGREE_ADD_USER
;
}
}
pcloud-service-book/src/main/java/com/pcloud/book/mq/topic/WxAgreeAddUserListener.java
0 → 100644
View file @
a02a2f45
package
com
.
pcloud
.
book
.
mq
.
topic
;
import
com.pcloud.book.keywords.biz.BookGuideBiz
;
import
com.pcloud.book.keywords.biz.BookKeywordBiz
;
import
com.pcloud.book.mq.config.MQTopicConumer
;
import
com.pcloud.common.core.aspect.ParamLog
;
import
com.pcloud.common.exceptions.BizException
;
import
com.pcloud.wechatgroup.message.dto.AgreeAddUserDTO
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.amqp.rabbit.annotation.RabbitHandler
;
import
org.springframework.amqp.rabbit.annotation.RabbitListener
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.Resource
;
import
lombok.extern.slf4j.Slf4j
;
/**
* @author lily
* @date 2019/5/6 11:01
*/
@Slf4j
@Component
@RabbitListener
(
queues
=
MQTopicConumer
.
WXGROUP_AGREE_ADD_USER
)
public
class
WxAgreeAddUserListener
{
@Resource
private
BookGuideBiz
bookGuideBiz
;
/**
* 接收微信用户进群消息
*/
@ParamLog
(
"同意加好友发送欢迎语"
)
@RabbitHandler
public
void
onMessage
(
AgreeAddUserDTO
agreeAddUserDTO
)
throws
BizException
{
try
{
bookGuideBiz
.
sendGuide
(
agreeAddUserDTO
);
}
catch
(
Exception
e
)
{
log
.
error
(
"同意加好友发送欢迎语"
+
e
.
getMessage
(),
e
);
}
}
}
pcloud-service-book/src/main/java/com/pcloud/book/mq/topic/WxGroupSendTextListener.java
View file @
a02a2f45
...
@@ -11,6 +11,7 @@ import com.pcloud.common.exceptions.BizException;
...
@@ -11,6 +11,7 @@ import com.pcloud.common.exceptions.BizException;
import
com.pcloud.common.utils.ListUtils
;
import
com.pcloud.common.utils.ListUtils
;
import
com.pcloud.common.utils.string.StringUtil
;
import
com.pcloud.common.utils.string.StringUtil
;
import
com.pcloud.wechatgroup.message.dto.SendTextDTO
;
import
com.pcloud.wechatgroup.message.dto.SendTextDTO
;
import
com.sdk.wxgroup.SendMessageTypeEnum
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
...
@@ -59,9 +60,9 @@ public class WxGroupSendTextListener {
...
@@ -59,9 +60,9 @@ public class WxGroupSendTextListener {
BookClockInfoDTO
bookClockInfoDTO
=
bookClockCheck
.
checkKeywordIsClock
(
sendTextDTO
.
getTextContent
().
trim
(),
sendTextDTO
.
getWechatGroupId
());
BookClockInfoDTO
bookClockInfoDTO
=
bookClockCheck
.
checkKeywordIsClock
(
sendTextDTO
.
getTextContent
().
trim
(),
sendTextDTO
.
getWechatGroupId
());
if
(
null
!=
bookClockInfoDTO
){
if
(
null
!=
bookClockInfoDTO
){
bookClockKeywordBiz
.
sendKeywordMessage
(
bookClockInfoDTO
,
wechatUserId
,
sendTextDTO
.
getWechatGroupId
(),
sendTextDTO
.
getWxId
(),
sendTextDTO
.
getIp
());
bookClockKeywordBiz
.
sendKeywordMessage
(
bookClockInfoDTO
,
wechatUserId
,
sendTextDTO
.
getWechatGroupId
(),
sendTextDTO
.
getWxId
(),
sendTextDTO
.
getIp
());
}
else
{
}
else
{
final
long
l
=
System
.
currentTimeMillis
();
final
long
l
=
System
.
currentTimeMillis
();
bookKeywordBiz
.
sendKeywordMessage
(
sendTextDTO
.
getTextContent
().
trim
(),
sendTextDTO
.
getWechatGroupId
(),
wechatUserId
,
sendTextDTO
.
getWxId
(),
sendTextDTO
.
getIp
());
bookKeywordBiz
.
sendKeywordMessage
(
sendTextDTO
.
getTextContent
().
trim
(),
sendTextDTO
.
getWechatGroupId
(),
wechatUserId
,
sendTextDTO
.
getWxId
(),
sendTextDTO
.
getIp
()
,
sendTextDTO
.
getCode
()
);
log
.
info
(
"[接收用户发送文本消息] 总耗时:{}ms "
,
System
.
currentTimeMillis
()
-
l
);
log
.
info
(
"[接收用户发送文本消息] 总耗时:{}ms "
,
System
.
currentTimeMillis
()
-
l
);
}
}
}
}
...
...
pcloud-service-book/src/main/resources/mapper/group/BookGroupMapper.xml
View file @
a02a2f45
...
@@ -86,6 +86,7 @@
...
@@ -86,6 +86,7 @@
and book_id = #{bookId,jdbcType=BIGINT}
and book_id = #{bookId,jdbcType=BIGINT}
and channel_id = #{channelId,jdbcType=BIGINT}
and channel_id = #{channelId,jdbcType=BIGINT}
and create_user = #{adviserId,jdbcType=BIGINT}
and create_user = #{adviserId,jdbcType=BIGINT}
ORDER BY create_time ASC limit 1
</select>
</select>
<select
id=
"getBookGroupCount"
resultType=
"Integer"
parameterType=
"Long"
>
<select
id=
"getBookGroupCount"
resultType=
"Integer"
parameterType=
"Long"
>
...
...
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