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
c63ce39d
Commit
c63ce39d
authored
Aug 08, 2019
by
裴大威
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix 处理多个分类加一个机器人时关键词回复和暗号消息识别
parent
ae1652f2
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
201 additions
and
66 deletions
+201
-66
BookGroupBiz.java
...src/main/java/com/pcloud/book/group/biz/BookGroupBiz.java
+1
-1
BookGroupClassifyBiz.java
.../java/com/pcloud/book/group/biz/BookGroupClassifyBiz.java
+5
-0
BookGroupBizImpl.java
...java/com/pcloud/book/group/biz/impl/BookGroupBizImpl.java
+6
-6
BookGroupClassifyBizImpl.java
.../pcloud/book/group/biz/impl/BookGroupClassifyBizImpl.java
+6
-0
BookGroupClassifyDao.java
.../java/com/pcloud/book/group/dao/BookGroupClassifyDao.java
+5
-0
JoinGroupCipherDao.java
...in/java/com/pcloud/book/group/dao/JoinGroupCipherDao.java
+3
-3
BookGroupClassifyDaoImpl.java
.../pcloud/book/group/dao/impl/BookGroupClassifyDaoImpl.java
+5
-0
JoinGroupCipherDaoImpl.java
...om/pcloud/book/group/dao/impl/JoinGroupCipherDaoImpl.java
+3
-3
JoinGroupCipherDTO.java
...in/java/com/pcloud/book/group/dto/JoinGroupCipherDTO.java
+1
-1
SendWeixinRequestTools.java
...a/com/pcloud/book/group/tools/SendWeixinRequestTools.java
+3
-2
BookGuideBizImpl.java
...a/com/pcloud/book/keywords/biz/impl/BookGuideBizImpl.java
+4
-7
BookKeywordBizImpl.java
...com/pcloud/book/keywords/biz/impl/BookKeywordBizImpl.java
+77
-36
BookKeywordDao.java
...ain/java/com/pcloud/book/keywords/dao/BookKeywordDao.java
+5
-0
BookKeywordDaoImpl.java
...com/pcloud/book/keywords/dao/impl/BookKeywordDaoImpl.java
+17
-0
ReplyKeywordDTO.java
...in/java/com/pcloud/book/keywords/dto/ReplyKeywordDTO.java
+6
-0
WxGroupSendTextListener.java
...ava/com/pcloud/book/mq/topic/WxGroupSendTextListener.java
+1
-1
BookGroupClassify.Mapper.xml
.../main/resources/mapper/group/BookGroupClassify.Mapper.xml
+18
-0
JoinGroupCipher.xml
...-book/src/main/resources/mapper/group/JoinGroupCipher.xml
+8
-6
BookKeyword.Mapper.xml
...src/main/resources/mapper/keywords/BookKeyword.Mapper.xml
+27
-0
No files found.
pcloud-service-book/src/main/java/com/pcloud/book/group/biz/BookGroupBiz.java
View file @
c63ce39d
...
...
@@ -271,5 +271,5 @@ public interface BookGroupBiz {
/**
* 根据微信id和机器人id获取分类集合
*/
List
<
Long
>
getClassifyIdsByWxIdAndAltId
(
String
wxId
,
String
altId
);
List
<
JoinGroupCipherDTO
>
getClassifyIdsByWxIdAndAltId
(
String
wxId
,
String
altId
);
}
pcloud-service-book/src/main/java/com/pcloud/book/group/biz/BookGroupClassifyBiz.java
View file @
c63ce39d
...
...
@@ -106,6 +106,11 @@ public interface BookGroupClassifyBiz {
List
<
ListClassify4WechatVO
>
listClassify4Wechat
(
Long
bookGroupId
,
Long
wechatUserId
);
/**
* 批量获取分类信息
*/
List
<
GroupClassifyQrcodeDTO
>
listClassifyQrcodeInfo
(
List
<
Long
>
classifyIds
);
/**
* @Author:lili
* @Desr:客户端根据群分类获取二维码
* @Date:2019/4/29 17:21
...
...
pcloud-service-book/src/main/java/com/pcloud/book/group/biz/impl/BookGroupBizImpl.java
View file @
c63ce39d
package
com
.
pcloud
.
book
.
group
.
biz
.
impl
;
import
com.alibaba.fastjson.JSONObject
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Maps
;
import
com.pcloud.appcenter.app.dto.AppDto
;
import
com.pcloud.appcenter.base.dto.AppPriceCacheDTO
;
...
...
@@ -75,6 +77,7 @@ import org.springframework.beans.factory.annotation.Value;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.stereotype.Component
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.util.CollectionUtils
;
import
java.math.BigDecimal
;
import
java.util.ArrayList
;
...
...
@@ -1177,15 +1180,12 @@ public class BookGroupBizImpl implements BookGroupBiz {
@ParamLog
(
"根据微信id和机器人id获取分类集合"
)
@Override
public
List
<
Long
>
getClassifyIdsByWxIdAndAltId
(
String
wxId
,
String
altId
)
{
public
List
<
JoinGroupCipherDTO
>
getClassifyIdsByWxIdAndAltId
(
String
wxId
,
String
altId
)
{
if
(
StringUtil
.
isEmpty
(
wxId
)
||
StringUtil
.
isEmpty
(
altId
))
{
return
new
ArrayList
<>();
}
List
<
Long
>
list
=
joinGroupCipherDao
.
getClassifyIdsByWxIdAndAltId
(
wxId
,
altId
);
if
(
list
==
null
)
{
return
new
ArrayList
<>();
}
return
list
;
List
<
JoinGroupCipherDTO
>
list
=
joinGroupCipherDao
.
getClassifyIdsByWxIdAndAltId
(
wxId
,
altId
);
return
CollectionUtils
.
isEmpty
(
list
)
?
Lists
.
newArrayList
()
:
list
;
}
}
pcloud-service-book/src/main/java/com/pcloud/book/group/biz/impl/BookGroupClassifyBizImpl.java
View file @
c63ce39d
...
...
@@ -430,6 +430,12 @@ public class BookGroupClassifyBizImpl implements BookGroupClassifyBiz {
}
@Override
@ParamLog
(
"获取分类二维码相关标识"
)
public
List
<
GroupClassifyQrcodeDTO
>
listClassifyQrcodeInfo
(
List
<
Long
>
classifyIds
)
{
return
bookGroupClassifyDao
.
listClassifyQrcodeInfo
(
classifyIds
);
}
@Override
@ParamLog
(
"客户端获取分类信息"
)
public
List
<
ListClassify4WechatVO
>
listClassify4Wechat
(
Long
bookGroupId
,
Long
wechatUserId
)
{
//获取排序方式
...
...
pcloud-service-book/src/main/java/com/pcloud/book/group/dao/BookGroupClassifyDao.java
View file @
c63ce39d
...
...
@@ -132,6 +132,11 @@ public interface BookGroupClassifyDao extends BaseDao<BookGroupClassify> {
GroupClassifyQrcodeDTO
getClassifyQrcodeInfo
(
String
weixinGroupId
);
/**
* 批量获取分类信息
*/
List
<
GroupClassifyQrcodeDTO
>
listClassifyQrcodeInfo
(
List
<
Long
>
classifyIds
);
/**
* @Author:lili
* @Desr:获取所有的分类
* @Date:2019/4/29 11:23
...
...
pcloud-service-book/src/main/java/com/pcloud/book/group/dao/JoinGroupCipherDao.java
View file @
c63ce39d
package
com
.
pcloud
.
book
.
group
.
dao
;
import
com.pcloud.book.group.dto.JoinGroupCiperDTO
;
import
com.pcloud.book.group.dto.JoinGroupCip
h
erDTO
;
import
com.pcloud.book.group.entity.JoinGroupCipher
;
import
com.pcloud.common.core.dao.BaseDao
;
...
...
@@ -11,9 +11,9 @@ public interface JoinGroupCipherDao extends BaseDao<JoinGroupCipher> {
JoinGroupCipher
getByCipher
(
String
cipher
);
JoinGroupCiperDTO
getDTOByCipher
(
String
cipher
);
JoinGroupCip
h
erDTO
getDTOByCipher
(
String
cipher
);
void
updateCipherStateToUsed
(
String
cipher
,
String
wxId
);
List
<
Long
>
getClassifyIdsByWxIdAndAltId
(
String
wxId
,
String
altId
);
List
<
JoinGroupCipherDTO
>
getClassifyIdsByWxIdAndAltId
(
String
wxId
,
String
altId
);
}
pcloud-service-book/src/main/java/com/pcloud/book/group/dao/impl/BookGroupClassifyDaoImpl.java
View file @
c63ce39d
...
...
@@ -110,6 +110,11 @@ public class BookGroupClassifyDaoImpl extends BaseDaoImpl<BookGroupClassify> imp
}
@Override
public
List
<
GroupClassifyQrcodeDTO
>
listClassifyQrcodeInfo
(
List
<
Long
>
classifyIds
)
{
return
this
.
getSqlSession
().
selectList
(
this
.
getStatement
(
"listClassifyQrcodeInfo"
),
classifyIds
);
}
@Override
public
List
<
ListClassify4WechatVO
>
listClassify4Wechat
(
Long
bookGroupId
,
Integer
rankType
)
{
Map
<
String
,
Object
>
paramMap
=
new
HashMap
();
paramMap
.
put
(
"bookGroupId"
,
bookGroupId
);
...
...
pcloud-service-book/src/main/java/com/pcloud/book/group/dao/impl/JoinGroupCipherDaoImpl.java
View file @
c63ce39d
package
com
.
pcloud
.
book
.
group
.
dao
.
impl
;
import
com.pcloud.book.group.dao.JoinGroupCipherDao
;
import
com.pcloud.book.group.dto.JoinGroupCiperDTO
;
import
com.pcloud.book.group.dto.JoinGroupCip
h
erDTO
;
import
com.pcloud.book.group.entity.JoinGroupCipher
;
import
com.pcloud.common.core.dao.BaseDaoImpl
;
import
org.springframework.stereotype.Component
;
...
...
@@ -31,7 +31,7 @@ public class JoinGroupCipherDaoImpl extends BaseDaoImpl<JoinGroupCipher> impleme
}
@Override
public
JoinGroupCiperDTO
getDTOByCipher
(
String
cipher
)
{
public
JoinGroupCip
h
erDTO
getDTOByCipher
(
String
cipher
)
{
return
this
.
getSqlSession
().
selectOne
(
this
.
getStatement
(
"getDTOByCipher"
),
cipher
);
}
...
...
@@ -44,7 +44,7 @@ public class JoinGroupCipherDaoImpl extends BaseDaoImpl<JoinGroupCipher> impleme
}
@Override
public
List
<
Long
>
getClassifyIdsByWxIdAndAltId
(
String
wxId
,
String
altId
)
{
public
List
<
JoinGroupCipherDTO
>
getClassifyIdsByWxIdAndAltId
(
String
wxId
,
String
altId
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"wxId"
,
wxId
);
map
.
put
(
"altId"
,
altId
);
...
...
pcloud-service-book/src/main/java/com/pcloud/book/group/dto/JoinGroupCiperDTO.java
→
pcloud-service-book/src/main/java/com/pcloud/book/group/dto/JoinGroupCip
h
erDTO.java
View file @
c63ce39d
...
...
@@ -3,7 +3,7 @@ package com.pcloud.book.group.dto;
import
lombok.Data
;
@Data
public
class
JoinGroupCiperDTO
{
public
class
JoinGroupCip
h
erDTO
{
private
String
cipher
;
...
...
pcloud-service-book/src/main/java/com/pcloud/book/group/tools/SendWeixinRequestTools.java
View file @
c63ce39d
...
...
@@ -202,10 +202,11 @@ public class SendWeixinRequestTools {
if
(
StringUtil
.
isEmpty
(
url
))
{
return
url
;
}
final
String
s
=
"qrcode_id="
+
groupQrcodeId
+
"&classify_id="
+
classifyId
+
(
null
==
bookGroupId
?
""
:
"&book_group_id="
+
bookGroupId
);
if
(
url
.
contains
(
"?"
))
{
url
=
url
+
"&
qrcode_id="
+
groupQrcodeId
+
"&classify_id="
+
classifyId
+
"&book_group_id="
+
bookGroupId
;
url
=
url
+
"&
"
+
s
;
}
else
{
url
=
url
+
"?
qrcode_id="
+
groupQrcodeId
+
"&classify_id="
+
classifyId
+
"&book_group_id="
+
bookGroupId
;
url
=
url
+
"?
"
+
s
;
}
return
url
;
}
...
...
pcloud-service-book/src/main/java/com/pcloud/book/keywords/biz/impl/BookGuideBizImpl.java
View file @
c63ce39d
...
...
@@ -16,13 +16,12 @@ import com.pcloud.book.group.dao.GroupQrcodeDao;
import
com.pcloud.book.group.dao.JoinGroupCipherDao
;
import
com.pcloud.book.group.dto.BookGroupDTO
;
import
com.pcloud.book.group.dto.GroupClassifyQrcodeDTO
;
import
com.pcloud.book.group.dto.JoinGroupCiperDTO
;
import
com.pcloud.book.group.dto.JoinGroupCip
h
erDTO
;
import
com.pcloud.book.group.dto.PushAddUserMessageDTO
;
import
com.pcloud.book.group.entity.AppTouchRecord
;
import
com.pcloud.book.group.entity.GroupQrcode
;
import
com.pcloud.book.group.enums.TouchTypeEnum
;
import
com.pcloud.book.group.tools.SendWeixinRequestTools
;
import
com.pcloud.book.group.vo.GroupQrcode4ClassifyVO
;
import
com.pcloud.book.group.vo.GroupQrcodeBaseInfoVO
;
import
com.pcloud.book.keywords.biz.BookGuideBiz
;
import
com.pcloud.book.keywords.biz.BookKeywordBiz
;
...
...
@@ -40,8 +39,6 @@ import com.pcloud.book.keywords.vo.UpdateGuideVO;
import
com.pcloud.channelcenter.wechat.dto.AccountSettingDto
;
import
com.pcloud.common.core.aspect.ParamLog
;
import
com.pcloud.common.utils.ListUtils
;
import
com.pcloud.common.utils.UUIDUitl
;
import
com.pcloud.common.utils.rsa.AESCodec
;
import
com.pcloud.common.utils.string.StringUtil
;
import
com.pcloud.wechatgroup.message.dto.AgreeAddUserDTO
;
import
com.sdk.wxgroup.AddToGroupVO
;
...
...
@@ -122,13 +119,13 @@ public class BookGuideBizImpl implements BookGuideBiz {
log
.
info
(
"[同意加好友发送欢迎语] : {}"
,
vo
);
WxGroupSDK
.
sendTextMessage
(
vo
);
// 根据暗号获取分类id和bookGroupId推送关键词欢迎语
final
JoinGroupCiperDTO
dto
=
joinGroupCipherDao
.
getDTOByCipher
(
cipher
);
final
JoinGroupCip
h
erDTO
dto
=
joinGroupCipherDao
.
getDTOByCipher
(
cipher
);
List
<
KeywordDTO
>
keywords
=
bookKeywordBiz
.
listFiveKeyword
(
dto
.
getClassifyId
(),
dto
.
getBookGroupId
());
SendWeixinRequestTools
.
sendKeywordsInfo
(
keywords
,
agreeAddUserDTO
.
getRobotWxId
(),
agreeAddUserDTO
.
getUserWxId
(),
agreeAddUserDTO
.
getIp
());
// 拉群
final
String
wxGroupId
=
bookGroupClassifyBiz
.
getWxGroupIdByClassifyIdAndWechatId
(
dto
.
getClassifyId
(),
dto
.
getWechatUserId
());
if
(
StringUtil
.
isBlank
(
wxGroupId
))
{
log
.
info
(
"[同意加好友发送欢迎语] 拉群 没有找到群 bookGroupClassifyBiz.getGroupQrcode4ClassifyWechat JoinGroupCiperDTO :{}"
,
dto
);
log
.
info
(
"[同意加好友发送欢迎语] 拉群 没有找到群 bookGroupClassifyBiz.getGroupQrcode4ClassifyWechat JoinGroupCip
h
erDTO :{}"
,
dto
);
return
;
}
AddToGroupVO
vo1
=
new
AddToGroupVO
();
...
...
@@ -280,7 +277,7 @@ public class BookGuideBizImpl implements BookGuideBiz {
log
.
info
(
"[推送欢迎语消息]:pushAddUserMessageDTO:{},kickUser:{}"
,
pushAddUserMessageDTO
,
kickUser
);
// 在群,且非黑名单
// canSend = canSend && !kickUser;
if
(
kickUser
)
{
if
(
null
!=
kickUser
&&
kickUser
)
{
log
.
info
(
"[推送欢迎语消息]:不推送"
);
return
;
}
...
...
pcloud-service-book/src/main/java/com/pcloud/book/keywords/biz/impl/BookKeywordBizImpl.java
View file @
c63ce39d
...
...
@@ -2,6 +2,7 @@ package com.pcloud.book.keywords.biz.impl;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Maps
;
import
com.google.common.collect.Sets
;
import
com.pcloud.appcenter.app.dto.AppDto
;
import
com.pcloud.book.base.exception.BookBizException
;
...
...
@@ -10,6 +11,7 @@ import com.pcloud.book.consumer.app.AppConsr;
import
com.pcloud.book.consumer.channel.QrcodeSceneConsr
;
import
com.pcloud.book.consumer.resource.ProductConsr
;
import
com.pcloud.book.consumer.wechatgroup.WechatGroupConsr
;
import
com.pcloud.book.group.biz.BookGroupBiz
;
import
com.pcloud.book.group.biz.BookGroupClassifyBiz
;
import
com.pcloud.book.group.dao.AppTouchRecordDao
;
import
com.pcloud.book.group.dao.BookGroupClassifyDao
;
...
...
@@ -17,6 +19,7 @@ import com.pcloud.book.group.dao.BookGroupDao;
import
com.pcloud.book.group.dao.GroupQrcodeDao
;
import
com.pcloud.book.group.dto.BookGroupDTO
;
import
com.pcloud.book.group.dto.GroupClassifyQrcodeDTO
;
import
com.pcloud.book.group.dto.JoinGroupCipherDTO
;
import
com.pcloud.book.group.entity.AppTouchRecord
;
import
com.pcloud.book.group.entity.GroupQrcode
;
import
com.pcloud.book.group.enums.TouchTypeEnum
;
...
...
@@ -67,8 +70,10 @@ import java.util.ArrayList;
import
java.util.Comparator
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.TreeSet
;
import
java.util.stream.Collectors
;
...
...
@@ -111,6 +116,8 @@ public class BookKeywordBizImpl implements BookKeywordBiz {
private
BookGroupClassifyDao
bookGroupClassifyDao
;
@Autowired
private
QrcodeSceneService
qrcodeSceneService
;
@Autowired
private
BookGroupBiz
bookGroupBiz
;
@Override
@ParamLog
(
"新增关键词"
)
...
...
@@ -422,46 +429,85 @@ public class BookKeywordBizImpl implements BookKeywordBiz {
if
(
StringUtil
.
isEmpty
(
content
)
||
content
.
length
()
>
20
)
{
return
;
}
//
通过群id获取对应基本信息
GroupClassifyQrcodeDTO
classifyQrcodeInfo
=
bookGroupClassifyBiz
.
getClassifyQrcodeInfo
(
weixinGroup
Id
);
if
(
classifyQrcodeInfo
==
null
)
{
log
.
info
(
"[关键词消息回复] classify
QrcodeInfo
is null"
);
//
TODO 根据小号和用户id获取所有相关的分类id,若该关键词存在多本书,则组装成文本加链接一次发送
final
List
<
JoinGroupCipherDTO
>
dtos
=
bookGroupBiz
.
getClassifyIdsByWxIdAndAltId
(
weixinGroupId
,
robot
Id
);
if
(
CollectionUtils
.
isEmpty
(
dtos
)
)
{
log
.
info
(
"[关键词消息回复] classify
Ids
is null"
);
return
;
}
ReplyKeywordDTO
replyKeywordDTO
;
//获取匹配关键词
replyKeywordDTO
=
bookKeywordDao
.
getKeywordId
(
classifyQrcodeInfo
.
getClassifyId
(),
classifyQrcodeInfo
.
getBookGroupId
(),
content
);
if
(
replyKeywordDTO
==
null
)
{
log
.
info
(
"[关键词消息回复] replyKeywordDTO is null"
);
final
Set
<
Long
>
cIds
=
Sets
.
newHashSet
();
final
Set
<
Long
>
bIds
=
Sets
.
newHashSet
();
for
(
JoinGroupCipherDTO
dto
:
dtos
)
{
cIds
.
add
(
dto
.
getClassifyId
());
bIds
.
add
(
dto
.
getBookGroupId
());
}
final
List
<
Long
>
classifyIds
=
Lists
.
newArrayList
(
cIds
);
final
List
<
ReplyKeywordDTO
>
replyKeywordDTOs
=
bookKeywordDao
.
getKeywordIds
(
classifyIds
,
Lists
.
newArrayList
(
bIds
),
content
);
final
List
<
GroupClassifyQrcodeDTO
>
qrcodeDTOS
=
bookGroupClassifyBiz
.
listClassifyQrcodeInfo
(
classifyIds
);
if
(
CollectionUtils
.
isEmpty
(
replyKeywordDTOs
))
{
log
.
info
(
"[关键词消息回复] keywordIds 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
);
if
(
CollectionUtils
.
isEmpty
(
qrcodeDTOS
))
{
log
.
info
(
"[关键词消息回复] qrcodeDTOS is null"
);
return
;
}
String
redisContent
=
JedisClusterUtils
.
getJson
(
"BOOK:KEYWORD:"
+
weixinGroupId
+
"-"
+
replyKeywordDTO
.
getKeywordId
(),
String
.
class
);
// 同一群10秒内不回复同一关键词
final
Map
<
Long
,
GroupClassifyQrcodeDTO
>
classifyMap
=
qrcodeDTOS
.
stream
().
collect
(
Collectors
.
toMap
(
GroupClassifyQrcodeDTO:
:
getClassifyId
,
p
->
p
,
(
v1
,
v2
)
->
v2
));
// 记录循环插入,消息一条发送
for
(
ReplyKeywordDTO
replyKeywordDTO
:
replyKeywordDTOs
)
{
log
.
info
(
"[关键词回复原始数据] : sendKeywordMessage replyKeywordDTO :{}, robotId:{}, weixinGroupId:{}"
,
replyKeywordDTO
,
robotId
,
weixinGroupId
);
// 处理链接地址
final
GroupClassifyQrcodeDTO
dto
=
classifyMap
.
get
(
replyKeywordDTO
.
getClassifyId
());
if
(
ReplyTypeEnum
.
APP
.
value
.
equals
(
replyKeywordDTO
.
getReplyType
())
||
ReplyTypeEnum
.
LINK
.
value
.
equals
(
replyKeywordDTO
.
getReplyType
()))
{
if
(
null
==
dto
)
{
log
.
info
(
"[关键词消息回复] 分类信息为空 replyKeywordDTO:{}; classifyMap:{}"
,
replyKeywordDTO
,
classifyMap
);
continue
;
}
AccountSettingDto
accountSettingDto
=
qrcodeSceneConsr
.
getWechatInfo
(
dto
.
getChannelId
());
String
linkUrl
=
SendWeixinRequestTools
.
splitUrlNew
(
accountSettingDto
,
replyKeywordDTO
.
getLinkUrl
(),
replyKeywordDTO
.
getBookGroupId
(),
replyKeywordDTO
.
getClassifyId
(),
null
);
replyKeywordDTO
.
setLinkUrl
(
linkUrl
);
}
String
redisContent
=
JedisClusterUtils
.
getJson
(
"BOOK:KEYWORD:"
+
weixinGroupId
+
"-"
+
replyKeywordDTO
.
getKeywordId
(),
String
.
class
);
// 同一群10秒内不回复同一关键词
if
(
insertBookKeywordRecord
(
weixinGroupId
,
userWxId
,
replyKeywordDTO
,
dto
,
redisContent
))
{
return
;
}
//获取推送消息机器人
// 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
);
//新增关键词触发记录
addKeywordAppTouchRecord
(
replyKeywordDTO
,
weixinGroupId
,
dto
.
getClassifyId
(),
dto
.
getBookGroupId
());
}
// 单条还是按原来的发送
if
(
replyKeywordDTOs
.
size
()
<=
1
)
{
SendWeixinRequestTools
.
sendKeywordMessage
(
replyKeywordDTOs
.
get
(
0
),
robotId
,
weixinGroupId
,
ip
,
code
);
}
else
{
// 多条时组装成一条发送
ReplyKeywordDTO
d
=
new
ReplyKeywordDTO
();
final
StringBuilder
sb
=
new
StringBuilder
();
for
(
ReplyKeywordDTO
dto
:
replyKeywordDTOs
)
{
sb
.
append
(
dto
.
getContent
()).
append
(
":"
).
append
(
dto
.
getShortLinkUrl
()).
append
(
"\n"
);
}
d
.
setContent
(
sb
.
toString
());
d
.
setReplyType
(
1
);
SendWeixinRequestTools
.
sendKeywordMessage
(
d
,
robotId
,
weixinGroupId
,
ip
,
code
);
}
}
private
boolean
insertBookKeywordRecord
(
String
weixinGroupId
,
String
userWxId
,
ReplyKeywordDTO
replyKeywordDTO
,
GroupClassifyQrcodeDTO
dto
,
String
redisContent
)
{
if
(
redisContent
!=
null
)
{
insertBookKeywordRecord
(
classifyQrcodeInf
o
,
replyKeywordDTO
.
getKeywordId
(),
userWxId
,
weixinGroupId
,
false
);
insertBookKeywordRecord
(
dt
o
,
replyKeywordDTO
.
getKeywordId
(),
userWxId
,
weixinGroupId
,
false
);
log
.
info
(
"[关键词消息回复] redisContent:{} insertBookKeywordRecord return"
,
redisContent
);
return
;
return
true
;
}
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
);
insertBookKeywordRecord
(
dto
,
replyKeywordDTO
.
getKeywordId
(),
userWxId
,
weixinGroupId
,
true
);
}
log
.
info
(
"[关键词回复发送数据] : sendKeywordMessage replyKeywordDTO :{}, robotId:{}, weixinGroupId:{}"
,
replyKeywordDTO
,
robotId
,
weixinGroupId
);
SendWeixinRequestTools
.
sendKeywordMessage
(
replyKeywordDTO
,
robotId
,
weixinGroupId
,
ip
,
code
);
//新增关键词触发记录
addKeywordAppTouchRecord
(
replyKeywordDTO
,
weixinGroupId
,
classifyQrcodeInfo
.
getClassifyId
(),
classifyQrcodeInfo
.
getBookGroupId
());
return
false
;
}
/**
...
...
@@ -506,13 +552,8 @@ public class BookKeywordBizImpl implements BookKeywordBiz {
}
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
);
if
(
insertBookKeywordRecord
(
weixinGroupId
,
userWxId
,
replyKeywordDTO
,
classifyQrcodeInfo
,
redisContent
))
{
return
;
}
else
{
JedisClusterUtils
.
setJson
(
"BOOK:KEYWORD:"
+
weixinGroupId
+
"-"
+
replyKeywordDTO
.
getKeywordId
(),
replyKeywordDTO
.
getKeywordId
(),
10
);
insertBookKeywordRecord
(
classifyQrcodeInfo
,
replyKeywordDTO
.
getKeywordId
(),
userWxId
,
weixinGroupId
,
true
);
}
//获取推送消息机器人
// 20190704改为收发一体
...
...
pcloud-service-book/src/main/java/com/pcloud/book/keywords/dao/BookKeywordDao.java
View file @
c63ce39d
...
...
@@ -52,6 +52,11 @@ public interface BookKeywordDao extends BaseDao<BookKeyword> {
ReplyKeywordDTO
getKeywordId
(
Long
classifyId
,
Long
bookGroupId
,
String
content
);
/**
* 根据分类ids和群ids批量获取关键词
*/
List
<
ReplyKeywordDTO
>
getKeywordIds
(
List
<
Long
>
classifyIds
,
List
<
Long
>
bookGroupIds
,
String
content
);
/**
* @Author:lili
* @Desr:校验关键词
* @Date:2019/5/6 14:47
...
...
pcloud-service-book/src/main/java/com/pcloud/book/keywords/dao/impl/BookKeywordDaoImpl.java
View file @
c63ce39d
package
com
.
pcloud
.
book
.
keywords
.
dao
.
impl
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Maps
;
import
com.pcloud.book.group.vo.SyncKeyworsVO
;
...
...
@@ -12,10 +13,14 @@ import com.pcloud.book.keywords.vo.ListKeywordVO;
import
com.pcloud.common.core.dao.BaseDaoImpl
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.StringUtils
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collector
;
import
java.util.stream.Collectors
;
/**
* @author lily
...
...
@@ -62,6 +67,18 @@ public class BookKeywordDaoImpl extends BaseDaoImpl<BookKeyword> implements Book
}
@Override
public
List
<
ReplyKeywordDTO
>
getKeywordIds
(
List
<
Long
>
classifyIds
,
List
<
Long
>
bookGroupIds
,
String
content
)
{
if
(
CollectionUtils
.
isEmpty
(
classifyIds
)
||
CollectionUtils
.
isEmpty
(
bookGroupIds
)
||
StringUtils
.
isEmpty
(
content
))
{
return
Lists
.
newArrayList
();
}
Map
<
String
,
Object
>
paramMap
=
Maps
.
newHashMap
();
paramMap
.
put
(
"classifyId"
,
classifyIds
.
stream
().
map
(
Object:
:
toString
).
collect
(
Collectors
.
joining
(
","
)));
paramMap
.
put
(
"bookGroupId"
,
bookGroupIds
.
stream
().
map
(
Object:
:
toString
).
collect
(
Collectors
.
joining
(
","
)));
paramMap
.
put
(
"content"
,
content
);
return
this
.
getSqlSession
().
selectList
(
this
.
getStatement
(
"getKeywordIds"
),
paramMap
);
}
@Override
public
Boolean
checkKeyword
(
String
keywords
,
Long
classifyId
,
Long
bookGroupId
,
Long
keywordId
)
{
Map
<
String
,
Object
>
paramMap
=
new
HashMap
<>();
paramMap
.
put
(
"classifyId"
,
classifyId
);
...
...
pcloud-service-book/src/main/java/com/pcloud/book/keywords/dto/ReplyKeywordDTO.java
View file @
c63ce39d
...
...
@@ -27,6 +27,12 @@ public class ReplyKeywordDTO implements Serializable {
@ApiModelProperty
(
"仓库关键词id"
)
private
Long
warehouseId
;
@ApiModelProperty
(
"分类id"
)
private
Long
classifyId
;
@ApiModelProperty
(
"群id"
)
private
Long
bookGroupId
;
@ApiModelProperty
(
"内容"
)
private
String
content
;
...
...
pcloud-service-book/src/main/java/com/pcloud/book/mq/topic/WxGroupSendTextListener.java
View file @
c63ce39d
...
...
@@ -58,7 +58,7 @@ public class WxGroupSendTextListener {
List
<
String
>
allRobotWxIds
=
wechatGroupConsr
.
listAllRobotWxId
();
if
(!
ListUtils
.
isEmpty
(
allRobotWxIds
)
&&
!
allRobotWxIds
.
contains
(
wechatUserId
)
&&
!
StringUtil
.
isEmpty
(
sendTextDTO
.
getTextContent
()))
{
BookClockInfoDTO
bookClockInfoDTO
=
bookClockCheck
.
checkKeywordIsClock
(
sendTextDTO
.
getTextContent
().
trim
(),
sendTextDTO
.
getWechatGroupId
());
if
(
null
!=
bookClockInfoDTO
){
if
(
null
!=
bookClockInfoDTO
&&
SendMessageTypeEnum
.
GROUP
.
getCode
().
equals
(
sendTextDTO
.
getCode
())
){
bookClockKeywordBiz
.
sendKeywordMessage
(
bookClockInfoDTO
,
wechatUserId
,
sendTextDTO
.
getWechatGroupId
(),
sendTextDTO
.
getWxId
(),
sendTextDTO
.
getIp
());
}
else
{
final
long
l
=
System
.
currentTimeMillis
();
...
...
pcloud-service-book/src/main/resources/mapper/group/BookGroupClassify.Mapper.xml
View file @
c63ce39d
...
...
@@ -316,6 +316,24 @@
and q.weixin_group_id = #{_parameter} limit 1
</select>
<select
id=
"listClassifyQrcodeInfo"
resultType=
"GroupClassifyQrcodeDTO"
parameterType=
"list"
>
select
c.id classifyId,
c.create_user adviserId,
c.book_id bookId,
c.channel_id channelId,
c.book_group_id bookGroupId,
c.price price,
c.has_open_learning_report hasOpenLearningReport
from
book_group_classify c
and c.id in
<foreach
collection=
"classifyIds"
open=
"("
separator=
","
close=
")"
item=
"item"
>
#{item}
</foreach>
limit 1
</select>
<select
id=
"listClassify4Wechat"
resultType=
"ListClassify4WechatVO"
parameterType=
"map"
>
SELECT
...
...
pcloud-service-book/src/main/resources/mapper/group/JoinGroupCipher.xml
View file @
c63ce39d
...
...
@@ -52,7 +52,7 @@
</select>
<!--根据暗号获取包含bookGroupId-->
<select
id=
"getDTOByCipher"
parameterType=
"String"
resultType=
"com.pcloud.book.group.dto.JoinGroupCiperDTO"
>
<select
id=
"getDTOByCipher"
parameterType=
"String"
resultType=
"com.pcloud.book.group.dto.JoinGroupCip
h
erDTO"
>
select
a.id, cipher, a.classify_id as classifyId, a.wechat_user_id as wechatUserId, a.wx_id as wxId,
a.has_used as hasUsed, b.book_group_id as bookGroupId
...
...
@@ -70,10 +70,11 @@
</update>
<!--根据微信id和机器人id获取分类集合-->
<select
id=
"getClassifyIdsByWxIdAndAltId"
parameterType=
"map"
resultType=
"long"
>
select classify_id from join_group_cipher where
has_used=1
and alt_id=#{altId}
and wx_id=#{wxId}
<select
id=
"getClassifyIdsByWxIdAndAltId"
parameterType=
"map"
resultType=
"com.pcloud.book.group.dto.JoinGroupCipherDTO"
>
select a.classify_id as classifyId, b.book_group_id as bookGroupId from join_group_cipher a
left join book_group_classify b on a.classify_id = b.id where
a.has_used=1
and a.alt_id=#{altId}
and a.wx_id=#{wxId}
</select>
</mapper>
\ No newline at end of file
pcloud-service-book/src/main/resources/mapper/keywords/BookKeyword.Mapper.xml
View file @
c63ce39d
...
...
@@ -177,6 +177,33 @@
order by set_type desc, matching_rule desc, bk.id desc limit 1
</select>
<select
id=
"getKeywordIds"
resultType=
"ReplyKeywordDTO"
parameterType=
"map"
>
SELECT
k.id keywordId,
k.keywords,
k.reply_type replyType,
k.content,
k.description,
k.link_url linkUrl,
k.pic_url picUrl,
bk.is_warehouse as isWarehouse,
bk.warehouse_id as warehouseId,
bk.classify_id as classifyId,
bk.book_group_id as bookGroupId,
k.reply_type replyType
FROM
book_keyword bk
JOIN
keyword k ON bk.keyword_id = k.id
WHERE
bk.is_delete = 0 AND k.is_delete = 0
AND classify_id in (0, ${classifyId})
AND book_group_id in (${bookGroupId})
AND ((k.keywords = #{content} and matching_rule = 1 ) or (k.keywords like
concat('%',#{content},'%') and matching_rule = 0))
order by set_type desc, matching_rule desc, bk.id desc
</select>
<select
id=
"checkKeyword"
resultType=
"Boolean"
parameterType=
"map"
>
SELECT
count(1)
...
...
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