Commit aa135c99 by 裴大威

feat 1001903

parent 60c1d3f2
...@@ -30,7 +30,6 @@ import com.pcloud.book.group.entity.BookGroupCipherUser; ...@@ -30,7 +30,6 @@ import com.pcloud.book.group.entity.BookGroupCipherUser;
import com.pcloud.book.group.entity.BookGroupClassify; import com.pcloud.book.group.entity.BookGroupClassify;
import com.pcloud.book.group.entity.BookGroupServe; import com.pcloud.book.group.entity.BookGroupServe;
import com.pcloud.book.group.entity.GroupQrcode; import com.pcloud.book.group.entity.GroupQrcode;
import com.pcloud.book.group.entity.JoinGroupCipher;
import com.pcloud.book.group.enums.QrcodeStatusEnum; import com.pcloud.book.group.enums.QrcodeStatusEnum;
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;
...@@ -809,9 +808,6 @@ public class BookKeywordBizImpl implements BookKeywordBiz { ...@@ -809,9 +808,6 @@ public class BookKeywordBizImpl implements BookKeywordBiz {
} }
final String content = sendTextDTO.getTextContent().trim(); final String content = sendTextDTO.getTextContent().trim();
final String weixinGroupId = sendTextDTO.getWechatGroupId(); final String weixinGroupId = sendTextDTO.getWechatGroupId();
final String userWxId = sendTextDTO.getWechatUserId();
final String ip = sendTextDTO.getIp();
final Integer code = sendTextDTO.getCode();
String robotId = sendTextDTO.getWxId(); String robotId = sendTextDTO.getWxId();
// 若非之前的机器人则不回复普通关键词 // 若非之前的机器人则不回复普通关键词
final Boolean groupRobot = wechatGroupConsr.isGroupRobot(robotId); final Boolean groupRobot = wechatGroupConsr.isGroupRobot(robotId);
...@@ -829,18 +825,38 @@ public class BookKeywordBizImpl implements BookKeywordBiz { ...@@ -829,18 +825,38 @@ public class BookKeywordBizImpl implements BookKeywordBiz {
if (StringUtil.isEmpty(content) || content.length() > 20) { if (StringUtil.isEmpty(content) || content.length() > 20) {
return; return;
} }
ReplyKeywordDTO replyKeywordDTO; List<ReplyKeywordDTO> keywordDTOS = Lists.newArrayList();
final boolean equals = "群主,来个抽奖".equals(content); final boolean equals = "群主,来个抽奖".equals(content);
if (equals) { if (equals) {
replyKeywordDTO = keywordDao.getByKeyword("群主,来个抽奖"); ReplyKeywordDTO replyKeywordDTO = keywordDao.getByKeyword("群主,来个抽奖");
keywordDTOS.add(replyKeywordDTO);
} else { } else {
//获取匹配关键词 //获取匹配关键词 需求(1001903)by 20191023
replyKeywordDTO = bookKeywordDao.getKeywordId(classifyQrcodeInfo.getClassifyId(), classifyQrcodeInfo.getBookGroupId(), content); List<ReplyKeywordDTO> replyKeywordDTO = bookKeywordDao.listAllKeywordByClassifyIdAndBookGroupId(classifyQrcodeInfo.getClassifyId(), classifyQrcodeInfo.getBookGroupId());
keywordDTOS.addAll(replyKeywordDTO);
} }
if (replyKeywordDTO == null) { if (CollectionUtils.isEmpty(keywordDTOS)) {
log.info("[关键词消息回复] replyKeywordDTO is null"); log.info("[关键词消息回复] replyKeywordDTO is null");
return; return;
} }
// 去除被发送内容完整包含的关键词
List<ReplyKeywordDTO> collect = keywordDTOS.stream().filter(x -> content.contains(x.getKeywords())).collect(Collectors.toList());
// 组装发送关键词
for (ReplyKeywordDTO dto : collect) {
sendKeyword(sendTextDTO, dto, classifyQrcodeInfo);
}
}
/**
* 发送关键词
*/
private void sendKeyword(SendTextDTO sendTextDTO, ReplyKeywordDTO replyKeywordDTO, GroupClassifyQrcodeDTO classifyQrcodeInfo) {
final String content = sendTextDTO.getTextContent().trim();
final String weixinGroupId = sendTextDTO.getWechatGroupId();
final String userWxId = sendTextDTO.getWechatUserId();
final String ip = sendTextDTO.getIp();
final Integer code = sendTextDTO.getCode();
String robotId = sendTextDTO.getWxId();
log.info("[关键词回复原始数据] : sendKeywordMessage replyKeywordDTO :{}, robotId:{}, weixinGroupId:{}", replyKeywordDTO, robotId, weixinGroupId); log.info("[关键词回复原始数据] : sendKeywordMessage replyKeywordDTO :{}, robotId:{}, weixinGroupId:{}", replyKeywordDTO, robotId, weixinGroupId);
// 处理链接地址 // 处理链接地址
final boolean isApp = ReplyTypeEnum.APP.value.equals(replyKeywordDTO.getReplyType()); final boolean isApp = ReplyTypeEnum.APP.value.equals(replyKeywordDTO.getReplyType());
......
...@@ -52,6 +52,11 @@ public interface BookKeywordDao extends BaseDao<BookKeyword> { ...@@ -52,6 +52,11 @@ public interface BookKeywordDao extends BaseDao<BookKeyword> {
ReplyKeywordDTO getKeywordId(Long classifyId, Long bookGroupId, String content); ReplyKeywordDTO getKeywordId(Long classifyId, Long bookGroupId, String content);
/** /**
* 获取分类下所有关键词
*/
List<ReplyKeywordDTO> listAllKeywordByClassifyIdAndBookGroupId(Long classifyId, Long bookGroupId);
/**
* 根据分类ids和群ids批量获取关键词 * 根据分类ids和群ids批量获取关键词
*/ */
List<ReplyKeywordDTO> getKeywordIds(List<Long> classifyIds, List<Long> bookGroupIds, String content); List<ReplyKeywordDTO> getKeywordIds(List<Long> classifyIds, List<Long> bookGroupIds, String content);
......
...@@ -19,7 +19,6 @@ import org.springframework.util.StringUtils; ...@@ -19,7 +19,6 @@ import org.springframework.util.StringUtils;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collector;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
...@@ -67,6 +66,14 @@ public class BookKeywordDaoImpl extends BaseDaoImpl<BookKeyword> implements Book ...@@ -67,6 +66,14 @@ public class BookKeywordDaoImpl extends BaseDaoImpl<BookKeyword> implements Book
} }
@Override @Override
public List<ReplyKeywordDTO> listAllKeywordByClassifyIdAndBookGroupId(Long classifyId, Long bookGroupId) {
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("classifyId", classifyId);
paramMap.put("bookGroupId", bookGroupId);
return this.getSqlSession().selectList(this.getStatement("listAllKeywordByClassifyIdAndBookGroupId"), paramMap);
}
@Override
public List<ReplyKeywordDTO> getKeywordIds(List<Long> classifyIds, List<Long> bookGroupIds, String content) { public List<ReplyKeywordDTO> getKeywordIds(List<Long> classifyIds, List<Long> bookGroupIds, String content) {
if (CollectionUtils.isEmpty(classifyIds) || CollectionUtils.isEmpty(bookGroupIds) || StringUtils.isEmpty(content)) { if (CollectionUtils.isEmpty(classifyIds) || CollectionUtils.isEmpty(bookGroupIds) || StringUtils.isEmpty(content)) {
return Lists.newArrayList(); return Lists.newArrayList();
......
...@@ -206,6 +206,31 @@ ...@@ -206,6 +206,31 @@
order by set_type desc, matching_rule desc, bk.id desc limit 1 order by set_type desc, matching_rule desc, bk.id desc limit 1
</select> </select>
<select id="listAllKeywordByClassifyIdAndBookGroupId" 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,
k.reply_type replyType,
k.serve_id as serveId,
k.serve_type as serveType
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 = #{bookGroupId}
order by set_type desc, matching_rule desc, bk.id desc
</select>
<select id="getKeywordIds" resultType="ReplyKeywordDTO" parameterType="map"> <select id="getKeywordIds" resultType="ReplyKeywordDTO" parameterType="map">
SELECT SELECT
k.id keywordId, k.id keywordId,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment