Commit b9d3af3c by 裴大威

feat C1001108

parent dc8e8103
......@@ -112,12 +112,16 @@ public class BookKeywordWarehouseBizImpl implements BookKeywordWarehouseBiz {
throw new BookBizException(BookBizException.ID_NOT_EXIST, "社群码不存在");
}
final KeywordWearhouseLabelVO v = new KeywordWearhouseLabelVO();
if(null == info.getProLabelId() || null == info.getDepLabelId() || null == info.getPurLabelId()) {
throw new BookBizException(BookBizException.PARAM_IS_NULL,"请先完成社群码信息");
}
v.setProfessionalLabelId(info.getProLabelId());
v.setDepthLabelId(info.getDepLabelId());
v.setPurposeLabelId(info.getPurLabelId());
labels.add(v);
final BookKeywordDetailVO v1 = new BookKeywordDetailVO();
v1.setGroupId(1);
v1.setChannelId(setKeywordVO.getChannelId());
v1.setContent(setKeywordVO.getContent());
v1.setProductId(setKeywordVO.getServeId());
v1.setProductType(setKeywordVO.getServeType());
......
......@@ -16,6 +16,7 @@ import java.util.Map;
*/
public interface WeixinQrcodeBiz {
Long countWechatGroup();
/**
* @Author:lili
* @Desr:从二维码获取一个二维码
......
......@@ -68,10 +68,13 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.stream.Collectors;
import lombok.extern.slf4j.Slf4j;
/**
* @author lily
* @date 2019/4/17 11:20
*/
@Slf4j
@Component("bookGroupClassifyBiz")
public class BookGroupClassifyBizImpl implements BookGroupClassifyBiz {
......@@ -135,6 +138,11 @@ public class BookGroupClassifyBizImpl implements BookGroupClassifyBiz {
Integer rank = bookGroupClassifyDao.getMaxRank(addClassifyVO.getBookGroupId());
bookGroupClassify.setRank(rank);
bookGroupClassifyDao.insert(bookGroupClassify);
final Long wechatGroupNum = weixinQrcodeBiz.countWechatGroup();
if(null == wechatGroupNum || wechatGroupNum <= 30) {
log.info("[新增分类] : 可用微信群数量:{}个", wechatGroupNum);
throw new BookBizException(BookBizException.PARAM_IS_NULL, "群二维码数量不足,您可以明天再创建群。");
}
WeixinQrcodeDTO oneQrcode = weixinQrcodeBiz.getOneQrcode();
if (oneQrcode == null) {
throw new BookBizException(BookBizException.PARAM_IS_NULL, "系统二维码数量不足,请联系客服人员补充二维码数量!");
......
......@@ -69,6 +69,11 @@ public class WeixinQrcodeBizImpl implements WeixinQrcodeBiz {
private static final ExecutorService EXECUTOR_SERVICE = Executors.newFixedThreadPool(5);
@Override
public Long countWechatGroup(){
return weixinQrcodeDao.countWechatGroup();
}
@Override
@ParamLog("从二维码库获取一个二维码")
@Transactional(propagation = Propagation.NOT_SUPPORTED)
public WeixinQrcodeDTO getOneQrcode() {
......
......@@ -18,6 +18,7 @@ import java.util.Map;
*/
public interface WeixinQrcodeDao extends BaseDao<WeixinQrcode> {
Long countWechatGroup();
/**
* @Author:lili
* @Desr:获取一个微信群
......
......@@ -30,6 +30,11 @@ public class WeixinQrcodeDaoImpl extends BaseDaoImpl<WeixinQrcode> implements We
}
@Override
public Long countWechatGroup() {
return this.getSqlSession().selectOne(this.getStatement("countWechatGroup"));
}
@Override
public Integer setIsUseById(Long id) {
return this.getSqlSession().update(this.getStatement("setIsUseById"), id);
}
......
......@@ -104,6 +104,10 @@ public class BookGuideBizImpl implements BookGuideBiz {
}
BookGuide bookGuide = new BookGuide();
BeanUtils.copyProperties(setGuideVO, bookGuide);
// 如果设置类型为按书设置则讲分类信息置空
if (0 == setGuideVO.getSetType()) {
setGuideVO.setClassifyId(0L);
}
bookGuide.setBookId(bookGroupDTO.getBookId());
bookGuide.setChannelId(bookGroupDTO.getChannelId());
bookGuide.setCreateUser(partyId);
......
......@@ -188,6 +188,7 @@ public class BookKeywordBizImpl implements BookKeywordBiz {
v.setTypeCode(proBaseById.getProductTypeCode());
}
v.setUserId(partyId);
v.setChannelId(bookGroupDTO.getChannelId());
final Long warehouseId = this.bookKeywordWarehouseBiz.addBookKeyword(v);
this.bookKeywordDao.updateIsWarehouse(updateKeywordVO.getBookKeywordId(), warehouseId);
}
......@@ -263,13 +264,17 @@ public class BookKeywordBizImpl implements BookKeywordBiz {
return;
}
//通过群id获取对应基本信息
final long l = System.currentTimeMillis();
GroupClassifyQrcodeDTO classifyQrcodeInfo = bookGroupClassifyBiz.getClassifyQrcodeInfo(weixinGroupId);
log.info("[接收用户发送文本消息] bookGroupClassifyBiz.getClassifyQrcodeInfo耗时:{}ms ", System.currentTimeMillis() - l);
if (classifyQrcodeInfo == null) {
log.info("[关键词消息回复] classifyQrcodeInfo is null");
return;
}
//获取匹配关键词
ReplyKeywordDTO replyKeywordDTO = bookKeywordDao.getKeywordId(classifyQrcodeInfo.getClassifyId(), classifyQrcodeInfo.getBookGroupId(), content);
if (replyKeywordDTO == null) {
log.info("[关键词消息回复] classifyQrcodeInfo is null");
return;
}
// 处理链接地址
......@@ -280,31 +285,42 @@ public class BookKeywordBizImpl implements BookKeywordBiz {
}
String redisContent = JedisClusterUtils.getJson("BOOK:KEYWORD:" + weixinGroupId + "-" + replyKeywordDTO.getKeywordId(), String.class);
if (redisContent != null) {
final long l1 = System.currentTimeMillis();
insertBookKeywordRecord(classifyQrcodeInfo, replyKeywordDTO.getKeywordId(), userWxId, weixinGroupId, false);
log.info("[接收用户发送文本消息] redisContent != null insertBookKeywordRecord耗时:{}ms ", System.currentTimeMillis() - l1);
return;
} else {
final long l1 = System.currentTimeMillis();
JedisClusterUtils.setJson("BOOK:KEYWORD:" + weixinGroupId + "-" + replyKeywordDTO.getKeywordId(), replyKeywordDTO.getKeywordId(), 10);
insertBookKeywordRecord(classifyQrcodeInfo, replyKeywordDTO.getKeywordId(), userWxId, weixinGroupId, true);
log.info("[接收用户发送文本消息] redisContent == null insertBookKeywordRecord耗时:{}ms ", System.currentTimeMillis() - l1);
}
//获取推送消息机器人
final long l1 = System.currentTimeMillis();
String robotId = wechatGroupConsr.getRobotIdByGroupId(weixinGroupId);
log.info("[接收用户发送文本消息] wechatGroupConsr.getRobotIdByGroupId耗时:{}ms ", System.currentTimeMillis() - l1);
final long l2 = System.currentTimeMillis();
SendWeixinRequestTools.sendKeywordMessage(replyKeywordDTO, robotId, weixinGroupId);
log.info("[接收用户发送文本消息] SendWeixinRequestTools.sendKeywordMessage耗时:{}ms ", System.currentTimeMillis() - l2);
//新增关键词触发记录
final long l3 = System.currentTimeMillis();
addKeywordAppTouchRecord(replyKeywordDTO, weixinGroupId, classifyQrcodeInfo.getClassifyId(), classifyQrcodeInfo.getBookGroupId());
log.info("[接收用户发送文本消息] addKeywordAppTouchRecord耗时:{}ms ", System.currentTimeMillis() - l3);
//第一推送关键词消息埋点
final long l4 = System.currentTimeMillis();
String keywordsKey = "BOOK:FIRSTKEYWORD:" + DateUtils.getShortDateStr() + "-" + weixinGroupId;
Boolean isSend = JedisClusterUtils.getJson(keywordsKey, Boolean.class);
if (isSend != null && isSend) {
return;
} else {
JedisClusterUtils.setJson(keywordsKey, true);
JedisClusterUtils.expire(keywordsKey, 86400);
RobotReplyDTO robotReplyDTO = new RobotReplyDTO();
robotReplyDTO.setKeyWord(content);
robotReplyDTO.setWxGroupId(weixinGroupId);
robotReplyDTO.setWxUserId(userWxId);
wechatGroupConsr.addFirstRobotReplyRecord(robotReplyDTO);
}
JedisClusterUtils.setJson(keywordsKey, true);
JedisClusterUtils.expire(keywordsKey, 86400);
RobotReplyDTO robotReplyDTO = new RobotReplyDTO();
robotReplyDTO.setKeyWord(content);
robotReplyDTO.setWxGroupId(weixinGroupId);
robotReplyDTO.setWxUserId(userWxId);
wechatGroupConsr.addFirstRobotReplyRecord(robotReplyDTO);
log.info("[接收用户发送文本消息] addKeywordAppTouchRecord耗时:{}ms ", System.currentTimeMillis() - l4);
}
/**
......
......@@ -64,4 +64,7 @@ public class UpdateKeywordVO implements Serializable {
@ApiModelProperty("是否加入仓库")
private Integer addWarehouse;
@ApiModelProperty("渠道id")
private Long channelId;
}
......@@ -21,10 +21,13 @@ import org.springframework.stereotype.Component;
import java.util.List;
import lombok.extern.slf4j.Slf4j;
/**
* @author lily
* @date 2019/5/6 11:01
*/
@Slf4j
@Component("wxGroupSendTextListener")
@RabbitListener(queues = MQTopicConumer.WXGROUP_SEND_TEXT)
public class WxGroupSendTextListener {
......@@ -57,7 +60,9 @@ public class WxGroupSendTextListener {
if(null != bookClockInfoDTO){
bookClockKeywordBiz.sendKeywordMessage(bookClockInfoDTO, wechatUserId,sendTextDTO.getWechatGroupId());
}else{
final long l = System.currentTimeMillis();
bookKeywordBiz.sendKeywordMessage(sendTextDTO.getTextContent().trim(), sendTextDTO.getWechatGroupId(), wechatUserId);
log.info("[接收用户发送文本消息] 总耗时:{}ms ", System.currentTimeMillis() - l);
}
}
} catch (Exception e) {
......
......@@ -38,6 +38,12 @@
LIMIT 1
</select>
<select id="countWechatGroup" resultType = "long" >
SELECT count(*)
FROM weixin_qrcode
WHERE use_state = 0 AND update_state in (0,1,3) and weixin_group_id != ''
</select>
<update id="setIsUseById" parameterType="Long">
update
......
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