Commit 8d26d422 by 裴大威

feat 1001092

parent ed4929c3
......@@ -26,6 +26,8 @@ public interface BookKeywordBiz {
*/
void insertKeyword(SetKeywordVO setKeywordVO);
void insertKeywords(List<SetKeywordVO> setKeywordVOs, Long partyId);
/**
* @Author:lili
* @Desr:更新关键词
......
......@@ -55,6 +55,7 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.math.BigDecimal;
import java.util.ArrayList;
......@@ -159,6 +160,20 @@ public class BookKeywordBizImpl implements BookKeywordBiz {
bookKeywordDao.insert(bookKeyword);
}
@Override
@ParamLog("批量新增关键词")
@Transactional(rollbackFor = {Exception.class})
public void insertKeywords(List<SetKeywordVO> setKeywordVOs, Long partyId) {
if (CollectionUtils.isEmpty(setKeywordVOs) || null == partyId) {
log.info("[insertKeywords] : setKeywordVOs:{}, partyId:{}", setKeywordVOs, partyId);
return;
}
for (SetKeywordVO vo : setKeywordVOs) {
vo.setUserId(partyId);
this.insertKeyword(vo);
}
}
@ParamLog("校验关键词是否重复")
private void checkKeyword(String keywords, Long classifyId, Long bookGroupId, Long keywordId) {
Boolean isHaveKeyword = bookKeywordDao.checkKeyword(keywords, classifyId, bookGroupId, keywordId);
......@@ -242,6 +257,43 @@ public class BookKeywordBizImpl implements BookKeywordBiz {
if (keywords == null) {
return new PageBeanNew<>(listKeywordParam.getCurrentPage(), listKeywordParam.getNumPerPage(), new ArrayList<>());
}
final List<Long> appIds = Lists.newArrayList();
final List<Long> productIds = Lists.newArrayList();
for (ListKeywordVO vo : keywords.getRecordList()) {
if ("APP".equalsIgnoreCase(vo.getServeType())) {
appIds.add(vo.getServeId());
}
if ("PRODUCT".equalsIgnoreCase(vo.getServeType())) {
productIds.add(vo.getServeId());
}
}
Map<Long, AppDto> app = Maps.newHashMap();
if(!CollectionUtils.isEmpty(appIds)) {
app = appConsr.mapBaseByIds(appIds);
}
Map<Long, ProductDto> proBasesByIds = Maps.newHashMap();
if(!CollectionUtils.isEmpty(productIds)) {
proBasesByIds = productConsr.getProBasesByIds(productIds);
}
final BookGroupDTO dtoById = bookGroupDao.getDTOById(listKeywordParam.getBookGroupId());
for (ListKeywordVO vo : keywords.getRecordList()) {
if ("APP".equalsIgnoreCase(vo.getServeType())) {
final AppDto appDto = app.get(vo.getServeId());
if (null == appDto) {
continue;
}
vo.setChannelId(appDto.getChannelId());
vo.setTypeCode(appDto.getTypeCode());
}
if ("PRODUCT".equalsIgnoreCase(vo.getServeType())) {
final ProductDto productDto = proBasesByIds.get(vo.getServeId());
if (null == productDto || null == productDto.getProductTypeDto()) {
continue;
}
vo.setChannelId(dtoById.getChannelId());
vo.setTypeCode(productDto.getProductTypeDto().getTypeCode());
}
}
return keywords;
}
......@@ -291,9 +343,10 @@ public class BookKeywordBizImpl implements BookKeywordBiz {
log.info("[接收用户发送文本消息] keywordDao.getByKeyword耗时:{}ms ", System.currentTimeMillis() - l1);
}
if (replyKeywordDTO == null) {
log.info("[关键词消息回复] classifyQrcodeInfo is 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());
......@@ -304,7 +357,7 @@ public class BookKeywordBizImpl implements BookKeywordBiz {
if (redisContent != null) {
final long l1 = System.currentTimeMillis();
insertBookKeywordRecord(classifyQrcodeInfo, replyKeywordDTO.getKeywordId(), userWxId, weixinGroupId, false);
log.info("[接收用户发送文本消息] redisContent != null insertBookKeywordRecord耗时:{}ms ", System.currentTimeMillis() - l1);
log.info("[关键词消息回复] redisContent:{} insertBookKeywordRecord return", redisContent);
return;
} else {
final long l1 = System.currentTimeMillis();
......@@ -318,7 +371,7 @@ public class BookKeywordBizImpl implements BookKeywordBiz {
log.info("[关键词消息回复] robotId is null content:{}, robotId:{},weixinGroupId:{}", content, robotId, weixinGroupId);
robotId = wechatGroupConsr.getRobotIdByGroupId(weixinGroupId);
}
final long l2 = System.currentTimeMillis();
log.info("[关键词回复发送数据] : sendKeywordMessage replyKeywordDTO :{}, robotId:{}, weixinGroupId:{}", replyKeywordDTO, robotId, weixinGroupId);
SendWeixinRequestTools.sendKeywordMessage(replyKeywordDTO, robotId, weixinGroupId);
log.info("[接收用户发送文本消息] SendWeixinRequestTools.sendKeywordMessage耗时:{}ms ", System.currentTimeMillis() - l2);
//新增关键词触发记录
......
......@@ -41,7 +41,7 @@ public interface BookKeywordFacade {
@ApiImplicitParam(name = "setKeywordVO", value = "设置关键词", dataType = "SetKeywordVO", paramType = "body")
})
@PostMapping("insertKeyword")
ResponseDto<?> insertKeyword(@RequestHeader("token") String token, @RequestBody SetKeywordVO setKeywordVO)
ResponseDto<?> insertKeyword(@RequestHeader("token") String token, @RequestBody List<SetKeywordVO> setKeywordVOs)
throws BizException, PermissionException;
@ApiOperation(value = "更新关键词", httpMethod = "POST")
......
......@@ -43,10 +43,9 @@ public class BookKeywordFacadeImpl implements BookKeywordFacade {
@Override
@PostMapping("insertKeyword")
public ResponseDto<?> insertKeyword(@RequestHeader("token") String token, @RequestBody SetKeywordVO setKeywordVO) throws BizException, PermissionException {
public ResponseDto<?> insertKeyword(@RequestHeader("token") String token, @RequestBody List<SetKeywordVO> setKeywordVOs) throws BizException, PermissionException {
Long partyId = (Long) SessionUtil.getVlaue(token, SessionUtil.PARTY_ID);
setKeywordVO.setUserId(partyId);
bookKeywordBiz.insertKeyword(setKeywordVO);
bookKeywordBiz.insertKeywords(setKeywordVOs, partyId);
return new ResponseDto<>();
}
......
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