Commit da97c757 by 阮思源

Merge branch 'feat-1002348' into 'master'

关联7个分类

See merge request rays/pcloud-book!422
parents a02d31b7 bea8e465
package com.pcloud.book.guide.vo;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
@Data
public class Create4ClassifyVO implements Serializable {
private Integer pcloudClassifyId;
private List<Integer> pcloudGuideIds;
}
......@@ -9,5 +9,5 @@ public class RobotSilenceVO {
private Integer silenceDuration;
private Integer pcloudClassifyId;
}
......@@ -13,7 +13,7 @@ public interface PcloudGuideBiz {
PcloudGuideVO getPcloudGuide(Integer pcloudGuideId);
PageBeanNew<PcloudGuideVO> listPcloudGuide(Integer currentPage, Integer numPerPage, String robotWxId, String search);
PageBeanNew<PcloudGuideVO> listPcloudGuide(Integer currentPage, Integer numPerPage, String robotWxId, String search, Integer pcloudClassfyId);
void updateSeqNum(UpdateSeqNumVO updateSeqNumVO);
......@@ -22,4 +22,6 @@ public interface PcloudGuideBiz {
void setSilenceDuration(RobotSilenceVO robotSilenceVO);
void copyGuideSetting(String fromRobotWxId, String toRobotWxId);
void add4Classify(Create4ClassifyVO create4ClassifyVO);
}
......@@ -4,6 +4,7 @@ import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.book.guide.biz.PcloudGuideBiz;
import com.pcloud.book.guide.entity.PcloudGuide;
import com.pcloud.book.guide.entity.PcloudGuideMessage;
import com.pcloud.book.guide.entity.PcloudRobotSilence;
import com.pcloud.book.guide.mapper.PcloudGuideMapper;
import com.pcloud.book.guide.mapper.PcloudGuideMessageMapper;
import com.pcloud.book.guide.mapper.PcloudRobotSilenceMapper;
......@@ -43,7 +44,7 @@ public class PcloudGuideBizImpl implements PcloudGuideBiz {
throw new BookBizException(BookBizException.ERROR, "最多添加3条回复内容");
}
Integer maxSeqNum = pcloudGuideMapper.getMaxSeqNum(null);
Integer maxSeqNum = pcloudGuideMapper.getMaxSeqNum(null, null);
PcloudGuide pcloudGuide = new PcloudGuide();
pcloudGuide.setType(0);
pcloudGuide.setRobotWxId(null);
......@@ -113,13 +114,13 @@ public class PcloudGuideBizImpl implements PcloudGuideBiz {
}
@Override
public PageBeanNew<PcloudGuideVO> listPcloudGuide(Integer currentPage, Integer numPerPage, String robotWxId, String search) {
Integer count = pcloudGuideMapper.getCount(robotWxId, search);
public PageBeanNew<PcloudGuideVO> listPcloudGuide(Integer currentPage, Integer numPerPage, String robotWxId, String search, Integer pcloudClassfyId) {
Integer count = pcloudGuideMapper.getCount(robotWxId, search, pcloudClassfyId);
List<PcloudGuideVO> list = new ArrayList<>();
if (count <= 0) {
return new PageBeanNew<>(currentPage, numPerPage, list);
}
list = pcloudGuideMapper.listPcloudGuide(currentPage * numPerPage, numPerPage, robotWxId, search);
list = pcloudGuideMapper.listPcloudGuide(currentPage * numPerPage, numPerPage, robotWxId, search, pcloudClassfyId);
list.forEach(item -> {
item.setMessageVOList(pcloudGuideMessageMapper.listByGuideId(item.getPcloudGuideId()));
});
......@@ -140,10 +141,11 @@ public class PcloudGuideBizImpl implements PcloudGuideBiz {
continue;
}
String robotWxId = create4RobotVO.getRobotWxId();
Integer maxSeqNum = pcloudGuideMapper.getMaxSeqNum(robotWxId);
Integer maxSeqNum = pcloudGuideMapper.getMaxSeqNum(robotWxId, null);
pcloudGuide.setType(1);
pcloudGuide.setRobotWxId(robotWxId);
pcloudGuide.setSeqNum(maxSeqNum +1);
pcloudGuide.setTimeSpan(pcloudGuide.getTimeSpan());
pcloudGuideMapper.insert(pcloudGuide);
List<PcloudGuideMessageVO> messageVOList = pcloudGuideMessageMapper.listByGuideId(pcloudGuideId);
List<PcloudGuideMessage> list = new ArrayList<>();
......@@ -159,10 +161,20 @@ public class PcloudGuideBizImpl implements PcloudGuideBiz {
@Override
public void setSilenceDuration(RobotSilenceVO robotSilenceVO) {
if (StringUtil.isEmpty(robotSilenceVO.getRobotWxId())) {
if (StringUtil.isEmpty(robotSilenceVO.getRobotWxId()) && null == robotSilenceVO.getPcloudClassifyId()) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "参数错误!");
}
pcloudRobotSilenceMapper.setSilenceDuration(robotSilenceVO.getRobotWxId(), robotSilenceVO.getSilenceDuration());
PcloudRobotSilence pcloudRobotSilence = pcloudRobotSilenceMapper.get(robotSilenceVO.getRobotWxId(), robotSilenceVO.getPcloudClassifyId());
if (null != pcloudRobotSilence) {
pcloudRobotSilence.setSilenceDuration(robotSilenceVO.getSilenceDuration());
pcloudRobotSilenceMapper.updateByPrimaryKey(pcloudRobotSilence);
}else {
pcloudRobotSilence = new PcloudRobotSilence();
pcloudRobotSilence.setPcloudClassifyId(robotSilenceVO.getPcloudClassifyId());
pcloudRobotSilence.setRobotWxId(robotSilenceVO.getRobotWxId());
pcloudRobotSilence.setSilenceDuration(robotSilenceVO.getSilenceDuration());
pcloudRobotSilenceMapper.insert(pcloudRobotSilence);
}
}
/**
......@@ -178,9 +190,37 @@ public class PcloudGuideBizImpl implements PcloudGuideBiz {
create4Robot(create4RobotVO);
}
//设置缄默时长
Integer silenceDurationByRobotWxId = pcloudRobotSilenceMapper.getSilenceDurationByRobotWxId(fromRobotWxId);
Integer silenceDurationByRobotWxId = pcloudRobotSilenceMapper.getSilenceDurationByRobotWxId(fromRobotWxId, null);
if (null != silenceDurationByRobotWxId) {
pcloudRobotSilenceMapper.setSilenceDuration(toRobotWxId, silenceDurationByRobotWxId);
pcloudRobotSilenceMapper.setSilenceDuration(toRobotWxId, silenceDurationByRobotWxId, null);
}
}
@Override
public void add4Classify(Create4ClassifyVO create4ClassifyVO) {
List<Integer> pcloudGuideIds = create4ClassifyVO.getPcloudGuideIds();
for (Integer pcloudGuideId : pcloudGuideIds) {
PcloudGuide pcloudGuide = pcloudGuideMapper.selectByPrimaryKey(pcloudGuideId);
if (null == pcloudGuide) {
continue;
}
Integer pcloudClassifyId = create4ClassifyVO.getPcloudClassifyId();
Integer maxSeqNum = pcloudGuideMapper.getMaxSeqNum(null, pcloudClassifyId);
pcloudGuide.setType(2);
pcloudGuide.setRobotWxId(null);
pcloudGuide.setPcloudClassifyId(pcloudClassifyId);
pcloudGuide.setSeqNum(maxSeqNum +1);
pcloudGuide.setTimeSpan(pcloudGuide.getTimeSpan());
pcloudGuideMapper.insert(pcloudGuide);
List<PcloudGuideMessageVO> messageVOList = pcloudGuideMessageMapper.listByGuideId(pcloudGuideId);
List<PcloudGuideMessage> list = new ArrayList<>();
messageVOList.forEach(item -> {
PcloudGuideMessage pcloudGuideMessage = new PcloudGuideMessage();
BeanUtils.copyProperties(item, pcloudGuideMessage);
pcloudGuideMessage.setPcloudGuideId(pcloudGuide.getId());
list.add(pcloudGuideMessage);
});
pcloudGuideMessageMapper.batchInsert(list);
}
}
}
......@@ -21,4 +21,6 @@ public class PcloudGuide {
private Integer seqNum;
private Integer pcloudClassifyId;
}
\ No newline at end of file
......@@ -13,6 +13,8 @@ public class PcloudRobotSilence {
private Date updateTime;
private Integer pcloudClassifyId;
public Integer getId() {
return id;
}
......@@ -52,4 +54,12 @@ public class PcloudRobotSilence {
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public Integer getPcloudClassifyId() {
return pcloudClassifyId;
}
public void setPcloudClassifyId(Integer pcloudClassifyId) {
this.pcloudClassifyId = pcloudClassifyId;
}
}
\ No newline at end of file
......@@ -2,6 +2,8 @@ package com.pcloud.book.guide.facade.impl;
import com.pcloud.book.guide.biz.PcloudGuideBiz;
import com.pcloud.book.guide.mapper.PcloudRobotSilenceMapper;
import com.pcloud.book.guide.vo.Create4ClassifyVO;
import com.pcloud.book.guide.vo.Create4RobotVO;
import com.pcloud.book.guide.vo.CreatePcloudGuideVO;
import com.pcloud.book.guide.vo.PcloudGuideVO;
......@@ -31,6 +33,8 @@ public class PcloudGuideFacadeImpl {
@Autowired
private PcloudGuideBiz pcloudGuideBiz;
@Autowired
private PcloudRobotSilenceMapper pcloudRobotSilenceMapper;
@ApiOperation(value = "新增全平台引导语")
@PostMapping("addPcloudGuide")
......@@ -65,9 +69,10 @@ public class PcloudGuideFacadeImpl {
@ApiOperation(value = "获取引导语列表")
@GetMapping("listPcloudGuide")
ResponseDto<?> listPcloudGuide(@RequestHeader String token, @RequestParam Integer currentPage, @RequestParam Integer numPerPage,
@RequestParam(value = "robotWxId", required = false) String robotWxId, @RequestParam(value = "search", required = false) String search) throws PermissionException {
@RequestParam(value = "robotWxId", required = false) String robotWxId, @RequestParam(value = "search", required = false) String search,
@RequestParam(value = "pcloudClassfyId", required = false) Integer pcloudClassfyId) throws PermissionException {
SessionUtil.getInfoToken4Redis(token);
PageBeanNew<PcloudGuideVO> page = pcloudGuideBiz.listPcloudGuide(currentPage, numPerPage, robotWxId, search);
PageBeanNew<PcloudGuideVO> page = pcloudGuideBiz.listPcloudGuide(currentPage, numPerPage, robotWxId, search, pcloudClassfyId);
return new ResponseDto<>(page);
}
......@@ -98,4 +103,19 @@ public class PcloudGuideFacadeImpl {
return new ResponseDto<>();
}
@ApiOperation(value = "新增分类引导语", httpMethod = "POST")
@PostMapping("add4Classify")
ResponseDto<?> add4Classify(@RequestHeader String token, @RequestBody Create4ClassifyVO create4ClassifyVO) throws PermissionException {
SessionUtil.getInfoToken4Redis(token);
pcloudGuideBiz.add4Classify(create4ClassifyVO);
return new ResponseDto<>();
}
@ApiOperation(value = "获取缄默时长设置", httpMethod = "GET")
@GetMapping("getSilenceDuration")
ResponseDto<?> getSilenceDuration(@RequestHeader String token, @RequestParam Integer pcloudClassifyId) throws PermissionException {
SessionUtil.getInfoToken4Redis(token);
return new ResponseDto<>(pcloudRobotSilenceMapper.get(null, pcloudClassifyId));
}
}
......@@ -21,12 +21,12 @@ public interface PcloudGuideMapper {
int updateByPrimaryKey(PcloudGuide record);
Integer getMaxSeqNum(@Param("robotWxId") String robotWxId);
Integer getMaxSeqNum(@Param("robotWxId") String robotWxId, @Param("pcloudClassifyId") Integer pcloudClassifyId);
Integer getCount(@Param("robotWxId") String robotWxId, @Param("search") String search);
Integer getCount(@Param("robotWxId") String robotWxId, @Param("search") String search, @Param("pcloudClassifyId") Integer pcloudClassifyId);
List<PcloudGuideVO> listPcloudGuide(@Param("pageNum") Integer pageNum, @Param("numPerPage") Integer numPerPage,
@Param("robotWxId") String robotWxId, @Param("search") String search);
@Param("robotWxId") String robotWxId, @Param("search") String search, @Param("pcloudClassifyId") Integer pcloudClassifyId);
void updateSeqNum(@Param("id") Integer pcloudGuideId, @Param("seqNum") Integer seqNum);
......@@ -35,4 +35,6 @@ public interface PcloudGuideMapper {
PcloudGuide getFirstByRobotId(@Param("robotId") String robotId, @Param("num") int num);
List<Integer> listPcloudGuideIds(String robotWxId);
PcloudGuide getFirstByClassifyId(@Param("pcloudClassifyId") Integer pcloudClassifyId, @Param("num") int num);
}
\ No newline at end of file
......@@ -28,10 +28,13 @@ public interface PcloudRobotSilenceMapper {
/**
* 根据机器人wxid获取缄默时长
*/
Integer getSilenceDurationByRobotWxId(@Param("wxId") String wxId);
Integer getSilenceDurationByRobotWxId(@Param("wxId") String wxId, @Param("pcloudClassifyId") Integer pcloudClassifyId);
/**
* 设置机器人缄默时长
*/
void setSilenceDuration(@Param("robotWxId") String robotWxId, @Param("silenceDuration") Integer silenceDuration);
void setSilenceDuration(@Param("robotWxId") String robotWxId, @Param("silenceDuration") Integer silenceDuration,
@Param("pcloudClassifyId") Integer pcloudClassifyId);
PcloudRobotSilence get(@Param("wxId") String wxId, @Param("pcloudClassifyId") Integer pcloudClassifyId);
}
\ No newline at end of file
......@@ -8,6 +8,8 @@ import com.pcloud.book.guide.mapper.PcloudGuideMessageMapper;
import com.pcloud.book.guide.mapper.PcloudRobotSilenceMapper;
import com.pcloud.book.guide.vo.PcloudGuideMessageVO;
import com.pcloud.book.keywords.enums.ReplyTypeEnum;
import com.pcloud.book.pcloudKeyword.dto.RobotClassifyDTO;
import com.pcloud.book.pcloudkeyword.dao.PcloudRobotDao;
import com.pcloud.common.utils.DateUtils;
import com.pcloud.common.utils.cache.redis.JedisClusterUtils;
import com.sdk.wxgroup.SendPicMessageVO;
......@@ -40,6 +42,8 @@ public class PcloudGuideSilenceRunnerImpl implements ApplicationRunner {
private PcloudGuideMapper pcloudGuideMapper;
@Autowired
private PcloudGuideMessageMapper pcloudGuideMessageMapper;
@Autowired
private PcloudRobotDao pcloudRobotDao;
@Override
......@@ -63,9 +67,9 @@ public class PcloudGuideSilenceRunnerImpl implements ApplicationRunner {
while (true) {
try {
Thread.sleep(1000);
List<String> robots = pcloudRobotSilenceMapper.listRobots();
for (String robotWxid : robots) {
Map<String, String> friends = JedisClusterUtils.hgetAll(robotWxid + PCLOUD_GUIDE_SUFFIX);
List<RobotClassifyDTO> allPcloudRobot = pcloudRobotDao.getAllPcloudRobot();
for (RobotClassifyDTO robotClassifyDTO: allPcloudRobot) {
Map<String, String> friends = JedisClusterUtils.hgetAll(robotClassifyDTO.getWxId() + PCLOUD_GUIDE_SUFFIX);
if (friends == null) {
continue;
}
......@@ -99,7 +103,7 @@ public class PcloudGuideSilenceRunnerImpl implements ApplicationRunner {
}
// 向缓存中写入下一条
PcloudGuide pcloudGuide = pcloudGuideMapper.getFirstByRobotId(pcloudGuideDelayDto.getRobotWxId(), pcloudGuideDelayDto.getNum() + 1);
PcloudGuide pcloudGuide = pcloudGuideMapper.getFirstByClassifyId(robotClassifyDTO.getClassifyId(), pcloudGuideDelayDto.getNum() + 1);
if (pcloudGuide != null) {
List<PcloudGuideMessageVO> messageVOList = pcloudGuideMessageMapper.listByGuideId(pcloudGuide.getId());
......
......@@ -272,7 +272,7 @@ public class BookGuideBizImpl implements BookGuideBiz {
paramMap.put("robotWxId", robotId);
PcloudRobot pcloudRobot = (PcloudRobot)pcloudRobotDao.getBy(paramMap, "getByRobotWxId");
if (null != pcloudRobot) {
PcloudGuide pcloudGuide= pcloudGuideMapper.getFirstByRobotId(robotId,0);
PcloudGuide pcloudGuide= pcloudGuideMapper.getFirstByClassifyId(pcloudRobot.getRobotType(),0);
log.info("[sendFriendGuide] 新增好友,推送引导语: {}", pcloudGuide);
if (pcloudGuide != null) {
List<PcloudGuideMessageVO> messageVOList = pcloudGuideMessageMapper.listByGuideId(pcloudGuide.getId());
......
......@@ -67,12 +67,14 @@ import com.pcloud.book.pcloudkeyword.dao.PcloudKeywordClassifyDao;
import com.pcloud.book.pcloudkeyword.dao.PcloudKeywordDao;
import com.pcloud.book.pcloudkeyword.dao.PcloudKeywordReplyDao;
import com.pcloud.book.pcloudkeyword.dao.PcloudNotKeywordDao;
import com.pcloud.book.pcloudkeyword.dao.PcloudRobotClassifyDao;
import com.pcloud.book.pcloudkeyword.dao.PcloudRobotDao;
import com.pcloud.book.pcloudkeyword.entity.PcloudKeyword;
import com.pcloud.book.pcloudkeyword.entity.PcloudKeywordClassify;
import com.pcloud.book.pcloudkeyword.entity.PcloudKeywordReply;
import com.pcloud.book.pcloudkeyword.entity.PcloudNotKeyword;
import com.pcloud.book.pcloudkeyword.entity.PcloudRobot;
import com.pcloud.book.pcloudkeyword.entity.PcloudRobotClassify;
import com.pcloud.book.pcloudkeyword.enums.KeywordTypeEnum;
import com.pcloud.book.pcloudkeyword.enums.MethodEnum;
import com.pcloud.book.pcloudkeyword.enums.RelevanceTypeEnum;
......@@ -223,6 +225,8 @@ public class BookKeywordBizImpl implements BookKeywordBiz {
private String wechatGroupLinkPrefix;
@Autowired
private PcloudRobotBiz pcloudRobotBiz;
@Autowired
private PcloudRobotClassifyDao pcloudRobotClassifyDao;
/**
* 字符串切割长度
*/
......@@ -677,7 +681,13 @@ public class BookKeywordBizImpl implements BookKeywordBiz {
String ip = sendTextDTO.getIp();
Integer code = sendTextDTO.getCode();
String robotId = sendTextDTO.getWxId();
Long pcloudClassifyId=pcloudRobot.getKeywordClassifyId();
Long robotClassifyId=pcloudRobot.getRobotType().longValue();
PcloudRobotClassify robotClassify = pcloudRobotClassifyDao.getById(robotClassifyId);
if (robotClassify==null||robotClassify.getKeywordClassifyId()==null){
return;
}
Long pcloudClassifyId=robotClassify.getKeywordClassifyId();
//查询该小号对应小号分类的关键词分类
PcloudKeywordClassify pcloudKeywordClassify = pcloudKeywordClassifyDao.getById(pcloudClassifyId);
if (null == pcloudKeywordClassify || !pcloudKeywordClassify.getOpen()){//分类未启用
log.info("查询小号关键词分类为空或未启用sendTextDTO="+sendTextDTO.toString()+"pcloudRobot="+pcloudRobot.toString());
......@@ -1893,7 +1903,11 @@ public class BookKeywordBizImpl implements BookKeywordBiz {
if (SendMessageTypeEnum.SELF.getCode().equals(code) && !userWxId.equals(robotId)) {
// 从缓存中获取缄默信息
if(JedisClusterUtils.hexists(robotId+PCLOUD_GUIDE_SUFFIX,userWxId)){
Integer duration = pcloudRobotSilenceMapper.getSilenceDurationByRobotWxId(robotId);
PcloudRobot pcloudRobot = pcloudRobotDao.getByWxId(robotId);
if (pcloudRobot == null) {
return;
}
Integer duration = pcloudRobotSilenceMapper.getSilenceDurationByRobotWxId(null, pcloudRobot.getRobotType());
if (duration == null) {
duration = 0;
}
......
......@@ -2,8 +2,10 @@ package com.pcloud.book.mq.topic;
import com.pcloud.book.keywords.biz.BookKeywordBiz;
import com.pcloud.book.mq.config.MQTopicConumer;
import com.pcloud.book.pcloudkeyword.dao.PcloudRobotClassifyDao;
import com.pcloud.book.pcloudkeyword.dao.PcloudRobotDao;
import com.pcloud.book.pcloudkeyword.entity.PcloudRobot;
import com.pcloud.book.pcloudkeyword.entity.PcloudRobotClassify;
import com.pcloud.common.core.aspect.ParamLog;
import com.pcloud.common.exceptions.BizException;
import com.pcloud.common.utils.cache.redis.JedisClusterUtils;
......@@ -28,6 +30,8 @@ public class WxGroupSendNotTextListener {
private BookKeywordBiz bookKeywordBiz;
@Autowired
private PcloudRobotDao pcloudRobotDao;
@Autowired
private PcloudRobotClassifyDao pcloudRobotClassifyDao;
@ParamLog("接收用户发送非文本消息")
@RabbitHandler
......@@ -48,7 +52,13 @@ public class WxGroupSendNotTextListener {
PcloudRobot pcloudRobot = pcloudRobotDao.getByWxId(sendNotTextDTO.getWxId());
if (pcloudRobot!=null){
//发送非关键词
Long pcloudClassifyId=pcloudRobot.getKeywordClassifyId();
//查询该小号对应小号分类的关键词分类
Long robotClassifyId=pcloudRobot.getRobotType().longValue();
PcloudRobotClassify robotClassify = pcloudRobotClassifyDao.getById(robotClassifyId);
if (robotClassify==null||robotClassify.getKeywordClassifyId()==null){
return;
}
Long pcloudClassifyId=robotClassify.getKeywordClassifyId();
bookKeywordBiz.sendPcloudNotKeyWord(userWxId,ip,code,robotId,pcloudClassifyId);
}
......
......@@ -39,4 +39,11 @@ public interface PcloudKeywordClassifyBiz {
* @return
*/
List<PcloudKeywordClassifyDTO> list(String classify);
/**
* 根据小号分类获取平台端关键词分类
* @param robotClassifyId
* @return
*/
PcloudKeywordClassify getKeywordClassifyByRobotClassifyId(Long robotClassifyId);
}
......@@ -19,7 +19,9 @@ public interface PcloudRobotBiz {
void updatePcloudRobotByWxId(PcloudRobot pcloudRobot);
PageBeanNew<PcloudRobot> getPcloudRobotList(String nickName, Integer currentPage, Integer numPerPage);
void updateRobotState(Long id, Integer state);
PageBeanNew<PcloudRobot> getPcloudRobotList(Integer classifyId, String nickName, Integer currentPage, Integer numPerPage);
void batchUpdatePcloudRobotWelcome(List<PcloudRobotWelcome> robotWelcomeList);
......
package com.pcloud.book.pcloudkeyword.biz;
import com.pcloud.book.pcloudkeyword.dto.ClassifyWelcomeDTO;
import com.pcloud.book.pcloudkeyword.entity.PcloudRobotClassify;
import com.pcloud.book.pcloudkeyword.facade.response.PcloudRobotClassifyResponseVO;
import com.pcloud.common.page.PageBeanNew;
import java.util.List;
......@@ -22,4 +24,23 @@ public interface PcloudRobotClassifyBiz {
*/
void updateRobotClassify(PcloudRobotClassify classify);
/**
* 获取分类
*/
PcloudRobotClassify getClassifyById(Long id);
/**
* 分页查询所有小号分类
*/
PageBeanNew<PcloudRobotClassifyResponseVO> listClassifyByPage(Integer currentPage, Integer numPerPage);
ClassifyWelcomeDTO getClassifyWelcome(Long classifyId);
void updateClassifyWelcome(ClassifyWelcomeDTO classifyWelcomeDTO);
/**
* 更新分类的关键词分类
*/
void updateRobotClassifyKeywordClassify(PcloudRobotClassify classify);
}
......@@ -3,8 +3,10 @@ package com.pcloud.book.pcloudkeyword.biz.impl;
import com.pcloud.book.pcloudkeyword.biz.PcloudKeywordBiz;
import com.pcloud.book.pcloudkeyword.biz.PcloudKeywordClassifyBiz;
import com.pcloud.book.pcloudkeyword.dao.PcloudKeywordClassifyDao;
import com.pcloud.book.pcloudkeyword.dao.PcloudRobotClassifyDao;
import com.pcloud.book.pcloudkeyword.dto.PcloudKeywordClassifyDTO;
import com.pcloud.book.pcloudkeyword.entity.PcloudKeywordClassify;
import com.pcloud.book.pcloudkeyword.entity.PcloudRobotClassify;
import com.pcloud.common.page.PageBeanNew;
import com.pcloud.common.page.PageParam;
import com.pcloud.common.utils.ListUtils;
......@@ -23,6 +25,8 @@ public class PcloudKeywordClassifyBizImpl implements PcloudKeywordClassifyBiz {
private PcloudKeywordClassifyDao pcloudKeywordClassifyDao;
@Autowired
private PcloudKeywordBiz pcloudKeywordBiz;
@Autowired
private PcloudRobotClassifyDao pcloudRobotClassifyDao;
@Override
public Long insert(PcloudKeywordClassify pcloudKeywordClassify) {
......@@ -53,4 +57,16 @@ public class PcloudKeywordClassifyBizImpl implements PcloudKeywordClassifyBiz {
List<PcloudKeywordClassifyDTO> list = pcloudKeywordClassifyDao.list(classify);
return list;
}
@Override
public PcloudKeywordClassify getKeywordClassifyByRobotClassifyId(Long robotClassifyId) {
PcloudRobotClassify robotClassify = pcloudRobotClassifyDao.getById(robotClassifyId);
if (robotClassify==null||robotClassify.getKeywordClassifyId()==null){
return new PcloudKeywordClassify();
}
Long pcloudClassifyId=robotClassify.getKeywordClassifyId();
//查询该小号对应小号分类的关键词分类
PcloudKeywordClassify pcloudKeywordClassify = pcloudKeywordClassifyDao.getById(pcloudClassifyId);
return pcloudKeywordClassify;
}
}
package com.pcloud.book.pcloudkeyword.biz.impl;
import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.book.pcloudkeyword.biz.PcloudRobotClassifyBiz;
import com.pcloud.book.pcloudkeyword.dao.PcloudRobotClassifyDao;
import com.pcloud.book.pcloudkeyword.dao.PcloudRobotWelcomeDao;
import com.pcloud.book.pcloudkeyword.dto.ClassifyWelcomeDTO;
import com.pcloud.book.pcloudkeyword.entity.PcloudRobotClassify;
import com.pcloud.book.pcloudkeyword.entity.PcloudRobotWelcome;
import com.pcloud.book.pcloudkeyword.facade.response.PcloudRobotClassifyResponseVO;
import com.pcloud.book.pcloudkeyword.set.PcloudRobotSet;
import com.pcloud.common.page.PageBeanNew;
import com.pcloud.common.page.PageParam;
import com.pcloud.common.utils.ListUtils;
import com.pcloud.common.utils.QrcodeUtils;
import com.pcloud.common.utils.httpclient.UrlUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.HashMap;
import java.util.List;
......@@ -17,6 +30,12 @@ public class PcloudRobotClassifyBizImpl implements PcloudRobotClassifyBiz {
@Resource
private PcloudRobotClassifyDao pcloudRobotClassifyDao;
@Value("${wechat.group.link.prefix}")
private String wechatLinkPrefix;
@Resource
private PcloudRobotWelcomeDao pcloudRobotWelcomeDao;
@Autowired
private PcloudRobotSet pcloudRobotSet;
@Override
public List<PcloudRobotClassifyResponseVO> listAllRobotClassify() {
......@@ -29,6 +48,11 @@ public class PcloudRobotClassifyBizImpl implements PcloudRobotClassifyBiz {
classify.setClassifyName(classifyName);
classify.setIsDelete(0);
pcloudRobotClassifyDao.insert(classify);
String linkUrl = wechatLinkPrefix + "/group/info?classify_id=" + classify.getId();
String codeUrl = QrcodeUtils.create( UrlUtils.getShortUrl4Own(linkUrl));
classify.setLinkUrl(linkUrl);
classify.setQrcodeUrl(codeUrl);
pcloudRobotClassifyDao.update(classify);
}
@Override
......@@ -36,4 +60,45 @@ public class PcloudRobotClassifyBizImpl implements PcloudRobotClassifyBiz {
pcloudRobotClassifyDao.update(classify);
}
@Override
public PcloudRobotClassify getClassifyById(Long id) {
return pcloudRobotClassifyDao.getById(id);
}
@Override
public PageBeanNew<PcloudRobotClassifyResponseVO> listClassifyByPage(Integer currentPage, Integer numPerPage) {
return pcloudRobotClassifyDao.listPageNew(new PageParam(currentPage, numPerPage), new HashMap<>(),"listClassifyByPage");
}
@Override
public ClassifyWelcomeDTO getClassifyWelcome(Long classifyId) {
ClassifyWelcomeDTO classifyWelcomeDTO = new ClassifyWelcomeDTO();
PcloudRobotClassify robotClassify = pcloudRobotClassifyDao.getById(classifyId);
classifyWelcomeDTO.setWelcomeDuration(robotClassify.getWelcomeDuration());
List<PcloudRobotWelcome> pcloudRobotWelcomeList = pcloudRobotWelcomeDao.getRobotWelcomeListByPcloudClassifyId(classifyId);
pcloudRobotSet.fillRobotWelcome(pcloudRobotWelcomeList);
classifyWelcomeDTO.setPcloudRobotWelcomeList(pcloudRobotWelcomeList);
return classifyWelcomeDTO;
}
@Override
public void updateClassifyWelcome(ClassifyWelcomeDTO classifyWelcomeDTO) {
pcloudRobotClassifyDao.updateWelcomeDuration(classifyWelcomeDTO.getPcloudClassifyId(), classifyWelcomeDTO.getWelcomeDuration());
List<PcloudRobotWelcome> robotWelcomeList = classifyWelcomeDTO.getPcloudRobotWelcomeList();
pcloudRobotWelcomeDao.deleteByPcloudClassifyId(classifyWelcomeDTO.getPcloudClassifyId());
if (ListUtils.isEmpty(robotWelcomeList)) {
return;
}
pcloudRobotWelcomeDao.batchInsert(robotWelcomeList);
}
@Transactional(rollbackFor = Exception.class)
@Override
public void updateRobotClassifyKeywordClassify(PcloudRobotClassify classify) {
if (classify==null||classify.getId()==null||classify.getKeywordClassifyId()==null){
throw new BookBizException(BookBizException.PARAM_IS_NULL,"参数为空!");
}
pcloudRobotClassifyDao.updateRobotClassifyKeywordClassify(classify.getId(),classify.getKeywordClassifyId());
}
}
......@@ -10,4 +10,7 @@ public interface PcloudRobotClassifyDao extends BaseDao<PcloudRobotClassify> {
List<PcloudRobotClassifyResponseVO> listAllRobotClassify();
void updateRobotClassifyKeywordClassify(Long id, Long keywordClassifyId);
void updateWelcomeDuration(Long id, Integer welcomeDuration);
}
......@@ -32,4 +32,6 @@ public interface PcloudRobotDao extends BaseDao<PcloudRobot> {
List<String> getPcloudRobotByTypes(List<Integer> classifyIds);
void updateRobotState(Map<String, Object> map);
}
......@@ -12,4 +12,8 @@ public interface PcloudRobotWelcomeDao extends BaseDao<PcloudRobotWelcome> {
void deleteByPcloudRobotId(Long pcloudRobotId);
void batchInsert(List<PcloudRobotWelcome> robotWelcomeList);
List<PcloudRobotWelcome> getRobotWelcomeListByPcloudClassifyId(Long pcloudClassifyId);
void deleteByPcloudClassifyId(Long pcloudClassifyId);
}
......@@ -7,7 +7,9 @@ import com.pcloud.common.core.dao.BaseDaoImpl;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Component
public class PcloudRobotClassifyDaoImpl extends BaseDaoImpl<PcloudRobotClassify> implements PcloudRobotClassifyDao {
......@@ -16,4 +18,20 @@ public class PcloudRobotClassifyDaoImpl extends BaseDaoImpl<PcloudRobotClassify>
public List<PcloudRobotClassifyResponseVO> listAllRobotClassify() {
return this.getSqlSession().selectList("listAllRobotClassify");
}
@Override
public void updateRobotClassifyKeywordClassify(Long id, Long keywordClassifyId) {
Map<String,Object> map=new HashMap<>();
map.put("id",id);
map.put("keywordClassifyId",keywordClassifyId);
getSessionTemplate().update(getStatement("updateRobotClassifyKeywordClassify"),map);
}
@Override
public void updateWelcomeDuration(Long id, Integer welcomeDuration) {
Map<String,Object> map=new HashMap<>();
map.put("id",id);
map.put("welcomeDuration",welcomeDuration);
getSessionTemplate().update(getStatement("updateWelcomeDuration"),map);
}
}
......@@ -48,15 +48,19 @@ public class PcloudRobotDaoImpl extends BaseDaoImpl<PcloudRobot> implements Pclo
}
@Override
public void updatePcloudRobotByWxId(PcloudRobot pcloudRobot) {
this.getSessionTemplate().update(this.getStatement("updatePcloudRobotByWxId"), pcloudRobot);
}
@Override
@Override
public List<String> getPcloudRobotByTypes(List<Integer> classifyIds) {
return this.getSessionTemplate().selectList(this.getStatement("getPcloudRobotByTypes"), classifyIds);
}
}
@Override
public void updateRobotState(Map<String, Object> map) {
this.getSessionTemplate().update(this.getStatement("updateRobotState"), map);
}
}
......@@ -25,4 +25,14 @@ public class PcloudRobotWelcomeDaoImpl extends BaseDaoImpl<PcloudRobotWelcome> i
super.getSqlSession().insert(getStatement("batchInsert"), robotWelcomeList);
}
@Override
public List<PcloudRobotWelcome> getRobotWelcomeListByPcloudClassifyId(Long pcloudClassifyId) {
return super.getSqlSession().selectList(getStatement("getRobotWelcomeListByPcloudClassifyId"), pcloudClassifyId);
}
@Override
public void deleteByPcloudClassifyId(Long pcloudClassifyId) {
super.getSqlSession().delete(getStatement("deleteByPcloudClassifyId"), pcloudClassifyId);
}
}
package com.pcloud.book.pcloudkeyword.dto;
import com.pcloud.book.pcloudkeyword.entity.PcloudRobotWelcome;
import com.pcloud.wechatgroup.base.dto.BaseDTO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
@Data
@ApiModel("全平台关键词分类")
public class ClassifyWelcomeDTO extends BaseDTO {
private Long pcloudClassifyId;
@ApiModelProperty("欢迎语间隔时长")
private Integer welcomeDuration;
private List<PcloudRobotWelcome> pcloudRobotWelcomeList;
}
package com.pcloud.book.pcloudkeyword.entity;
import com.pcloud.common.entity.BaseEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class PcloudRobotClassify extends BaseEntity {
private static final long serialVersionUID = -7926050288611663469L;
private String classifyName;
private Integer isDelete;
private String linkUrl;
public String getClassifyName() {
return classifyName;
}
private String qrcodeUrl;
public void setClassifyName(String classifyName) {
this.classifyName = classifyName;
}
private Integer isDelete;
public Integer getIsDelete() {
return isDelete;
}
private Integer welcomeDuration;
public void setIsDelete(Integer isDelete) {
this.isDelete = isDelete;
}
@ApiModelProperty("关键词分类ID")
private Long keywordClassifyId;
}
......@@ -16,6 +16,9 @@ public class PcloudRobotWelcome extends BaseEntity {
@ApiModelProperty("全平台个人号id")
private Long pcloudRobotId;
@ApiModelProperty("全平台分类id")
private Long pcloudClassifyId;
@ApiModelProperty("类型 1 文字 2 图片 3音频 4PDF")
private Integer replyType;
......
......@@ -196,4 +196,12 @@ public class PcloudKeywordFacade {
SessionUtil.getVlaue(token, SessionUtil.PARTY_ID);
return new ResponseDto<>(pcloudKeywordBiz.getPcloudNotKeywordList(keywordClassifyId, currentPage,numPerPage));
}
@ApiOperation("根据小号分类获取平台端关键词分类")
@GetMapping("getKeywordClassifyByRobotClassifyId")
public ResponseDto<?> getKeywordClassifyByRobotClassifyId(@RequestHeader("token")String token, @RequestParam("robotClassifyId") Long robotClassifyId) throws PermissionException {
SessionUtil.getInfoToken4Redis(token);
PcloudKeywordClassify classify = pcloudKeywordClassifyBiz.getKeywordClassifyByRobotClassifyId(robotClassifyId);
return new ResponseDto<>(classify);
}
}
package com.pcloud.book.pcloudkeyword.facade;
import com.pcloud.book.pcloudkeyword.biz.PcloudRobotClassifyBiz;
import com.pcloud.book.pcloudkeyword.dto.ClassifyWelcomeDTO;
import com.pcloud.book.pcloudkeyword.entity.PcloudRobotClassify;
import com.pcloud.book.pcloudkeyword.facade.response.PcloudRobotClassifyResponseVO;
import com.pcloud.common.dto.ResponseDto;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.pcloud.common.exceptions.BizException;
import com.pcloud.common.permission.PermissionException;
import com.pcloud.common.utils.SessionUtil;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;
import java.util.List;
......@@ -41,4 +42,44 @@ public class PcloudRobotClassifyFacade {
return new ResponseDto<>();
}
@GetMapping("getClassifyById")
public ResponseDto<PcloudRobotClassify> getClassifyById(@RequestHeader("token") @ApiParam("token信息") String token,
@RequestParam("id") Long id) throws BizException, PermissionException {
SessionUtil.getVlaue(token, SessionUtil.PARTY_ID);
return new ResponseDto<>(pcloudRobotClassifyBiz.getClassifyById(id));
}
@GetMapping("listClassifyByPage")
public ResponseDto<?> listClassifyByPage(
@RequestHeader("token") @ApiParam("token信息") String token,
@RequestParam("currentPage") Integer currentPage,
@RequestParam("numPerPage") Integer numPerPage) throws BizException, PermissionException {
SessionUtil.getVlaue(token, SessionUtil.PARTY_ID);
return new ResponseDto<>(pcloudRobotClassifyBiz.listClassifyByPage(currentPage, numPerPage));
}
@GetMapping("getClassifyWelcome")
public ResponseDto<?> getClassifyWelcome(
@RequestHeader("token") @ApiParam("token信息") String token,
@RequestParam("classifyId") @ApiParam("分类ID") Long classifyId) throws BizException, PermissionException {
SessionUtil.getVlaue(token, SessionUtil.PARTY_ID);
return new ResponseDto<>(pcloudRobotClassifyBiz.getClassifyWelcome(classifyId));
}
@PostMapping("updateClassifyWelcome")
public ResponseDto<?> updateClassifyWelcome(
@RequestHeader("token") @ApiParam("token信息") String token,
@RequestBody ClassifyWelcomeDTO classifyWelcomeDTO) throws BizException, PermissionException {
SessionUtil.getVlaue(token, SessionUtil.PARTY_ID);
pcloudRobotClassifyBiz.updateClassifyWelcome(classifyWelcomeDTO);
return new ResponseDto<>();
}
@ApiOperation("更新小号分类关键词分类")
@PostMapping("updateRobotClassifyKeywordClassify")
public ResponseDto<?> updateRobotClassifyKeywordClassify(@RequestBody PcloudRobotClassify classify) {
pcloudRobotClassifyBiz.updateRobotClassifyKeywordClassify(classify);
return new ResponseDto<>();
}
}
......@@ -48,16 +48,29 @@ public class PcloudRobotFacade {
return new ResponseDto<>();
}
@ApiOperation("修改机器人状态")
@GetMapping("/updateRobotState")
ResponseDto<?> updateRobotState(
@RequestHeader("token") @ApiParam("token信息") String token,
@RequestParam(value = "id") @ApiParam("ID") Long id,
@RequestParam(value = "state") @ApiParam("状态") Integer state
) throws BizException, PermissionException {
SessionUtil.getVlaue(token, SessionUtil.PARTY_ID);
pcloudRobotBiz.updateRobotState(id, state);
return new ResponseDto<>();
}
@ApiOperation("获取全平台个人号列表")
@GetMapping("/getPcloudRobotList")
ResponseDto<?> getPcloudRobotList(
@RequestHeader("token") @ApiParam("token信息") String token,
@RequestParam(value = "classifyId", required = false) @ApiParam("分类") Integer classifyId,
@RequestParam(value = "nickName", required = false) @ApiParam("昵称") String nickName,
@RequestParam("currentPage") Integer currentPage,
@RequestParam("numPerPage") Integer numPerPage
) throws BizException, PermissionException{
SessionUtil.getVlaue(token, SessionUtil.PARTY_ID);
return new ResponseDto<>(pcloudRobotBiz.getPcloudRobotList(nickName,currentPage,numPerPage));
return new ResponseDto<>(pcloudRobotBiz.getPcloudRobotList(classifyId, nickName,currentPage,numPerPage));
}
......
package com.pcloud.book.pcloudkeyword.facade.response;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;
import lombok.Data;
@ApiModel
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class PcloudRobotClassifyResponseVO {
private Long id;
private String classifyName;
private String linkUrl;
private String qrcodeUrl;
private Integer robotCount;
}
package com.pcloud.book.pcloudkeyword.set;
import com.pcloud.book.consumer.content.ResourceConsr;
import com.pcloud.book.pcloudkeyword.entity.PcloudRobotWelcome;
import com.pcloud.book.pcloudkeyword.enums.WelcomeReplyTypeEnum;
import com.pcloud.common.core.aspect.ParamLog;
import com.pcloud.common.utils.ListUtils;
import com.pcloud.contentcenter.resource.dto.ResourceDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Component("pcloudRobotSet")
public class PcloudRobotSet {
@Autowired
private ResourceConsr resourceConsr;
@ParamLog("填充欢迎语回复")
public void fillRobotWelcome(List<PcloudRobotWelcome> robotWelcomeList) {
if(ListUtils.isEmpty(robotWelcomeList)){
return;
}
List<Long> resourceIds=new ArrayList<>();
for (PcloudRobotWelcome robotWelcome : robotWelcomeList){
Integer type = robotWelcome.getReplyType();
if (WelcomeReplyTypeEnum.RESOURCE.value.equals(type)){
resourceIds.add(robotWelcome.getResourceId());
}
}
Map<Long, ResourceDTO> resourceDTOMap=new HashMap<>();
if (!ListUtils.isEmpty(resourceIds)){
resourceDTOMap = resourceConsr.mapByIds(resourceIds);
}
for (PcloudRobotWelcome robotWelcome : robotWelcomeList){
Integer type = robotWelcome.getReplyType();
if (WelcomeReplyTypeEnum.RESOURCE.value.equals(type)){
ResourceDTO resourceDTO = resourceDTOMap.get(robotWelcome.getResourceId());
if (resourceDTO != null){
robotWelcome.setResourceName(resourceDTO.getResourceName());
robotWelcome.setResourceUrl(resourceDTO.getFileUrl());
robotWelcome.setResourceTypeCode(resourceDTO.getTypeCode());
robotWelcome.setResourceTypeName(resourceDTO.getTypeName());
robotWelcome.setFileType(resourceDTO.getFileType());
robotWelcome.setFileSize(resourceDTO.getFileSize());
robotWelcome.setResourcePdfItems(resourceDTO.getResourcePdfItems());
robotWelcome.setResourceOfficeItemDTOs(resourceDTO.getResourceOfficeItemDTOs());
}
}
}
}
}
......@@ -445,6 +445,9 @@ public class SelfPushBizImpl implements SelfPushBiz {
map.put("pushStatus", status);
map.put("partyId", partyId);
PageBeanNew<SelfPushRecordDTO> pageBeanNew = selfPushItemDao.listPageNew(new PageParam(currentPage, numPerPage), map, "listSelfPushRecord");
if (null == pageBeanNew || ListUtils.isEmpty(pageBeanNew.getRecordList())) {
return new PageBeanNew<>(currentPage, numPerPage, 0, new ArrayList<>());
}
for (SelfPushRecordDTO dto:pageBeanNew.getRecordList()) {
String realSendTime="";
if(dto.getPushType()!=null&&dto.getPushType()==1){
......@@ -485,9 +488,6 @@ public class SelfPushBizImpl implements SelfPushBiz {
dto.setSelfPushItemList(selfPushItemList);
}
if (null == pageBeanNew || ListUtils.isEmpty(pageBeanNew.getRecordList())) {
return new PageBeanNew<>(currentPage, numPerPage, 0, new ArrayList<>());
}
List<String> wxIds = pageBeanNew.getRecordList().stream().filter(s -> !StringUtil.isEmpty(s.getAltId())).map(SelfPushRecordDTO::getAltId).distinct().collect(Collectors.toList());
Map<String, GroupUserDTO> robotMap = new HashMap<>();
if (!ListUtils.isEmpty(wxIds)){
......
......@@ -26,10 +26,10 @@
<insert id="insert" parameterType="com.pcloud.book.guide.entity.PcloudGuide" useGeneratedKeys="true" keyProperty="id">
insert into pcloud_guide (type, create_time,
update_time, robot_wx_id, time_span,
seq_num)
seq_num, pcloud_classify_id)
values (#{type,jdbcType=VARCHAR}, now(),
now(), #{robotWxId,jdbcType=INTEGER}, #{timeSpan,jdbcType=INTEGER},
#{seqNum,jdbcType=INTEGER})
#{seqNum,jdbcType=INTEGER}, #{pcloudClassifyId})
</insert>
<insert id="insertSelective" parameterType="com.pcloud.book.guide.entity.PcloudGuide" >
insert into pcloud_guide
......@@ -118,7 +118,10 @@
<if test="robotWxId != null">
and robot_wx_id = #{robotWxId}
</if>
<if test="robotWxId == null">
<if test="pcloudClassifyId != null">
and pcloud_classify_id = #{pcloudClassifyId}
</if>
<if test="robotWxId == null and pcloudClassifyId == null">
and type = 0
</if>
</select>
......@@ -137,12 +140,15 @@
<if test="robotWxId != null">
and robot_wx_id = #{robotWxId}
</if>
<if test="robotWxId == null">
<if test="robotWxId == null and pcloudClassifyId == null">
and type = 0
</if>
<if test="search != null">
and content like concat('%', #{search}, '%')
</if>
<if test="pcloudClassifyId != null">
and pcloud_classify_id = #{pcloudClassifyId}
</if>
GROUP BY a.id
) s
</select>
......@@ -161,12 +167,15 @@
<if test="robotWxId != null">
and robot_wx_id = #{robotWxId}
</if>
<if test="robotWxId == null">
<if test="robotWxId == null and pcloudClassifyId == null">
and type = 0
</if>
<if test="search != null">
and content like concat('%', #{search}, '%')
</if>
<if test="pcloudClassifyId != null">
and pcloud_classify_id = #{pcloudClassifyId}
</if>
GROUP BY a.id
ORDER BY seq_num ASC
limit #{pageNum}, #{numPerPage}
......@@ -202,4 +211,16 @@
<select id="listPcloudGuideIds" resultType="Integer">
select id from pcloud_guide where robot_wx_id = #{robotWxId}
</select>
<select id="getFirstByClassifyId" resultMap="BaseResultMap">
SELECT
id, time_span, seq_num
FROM
pcloud_guide
WHERE
pcloud_classify_id = #{pcloudClassifyId}
ORDER BY
seq_num ASC
LIMIT #{num}, 1
</select>
</mapper>
\ No newline at end of file
......@@ -7,9 +7,10 @@
<result column="silence_duration" property="silenceDuration" jdbcType="INTEGER" />
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP" />
<result column="pcloud_classify_id" property="pcloudClassifyId" jdbcType="INTEGER" />
</resultMap>
<sql id="Base_Column_List" >
id, robot_wx_id, silence_duration, create_time, update_time
id, robot_wx_id, silence_duration, create_time, update_time, pcloud_classify_id
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
......@@ -23,9 +24,9 @@
</delete>
<insert id="insert" parameterType="com.pcloud.book.guide.entity.PcloudRobotSilence" >
insert into pcloud_robot_silence (id, robot_wx_id, silence_duration,
create_time, update_time)
create_time, update_time, pcloud_classify_id)
values (#{id,jdbcType=INTEGER}, #{robotWxId,jdbcType=VARCHAR}, #{silenceDuration,jdbcType=INTEGER},
#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP})
#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, #{pcloudClassifyId})
</insert>
<insert id="insertSelective" parameterType="com.pcloud.book.guide.entity.PcloudRobotSilence" >
insert into pcloud_robot_silence
......@@ -84,9 +85,7 @@
</update>
<update id="updateByPrimaryKey" parameterType="com.pcloud.book.guide.entity.PcloudRobotSilence" >
update pcloud_robot_silence
set robot_wx_id = #{robotWxId,jdbcType=VARCHAR},
silence_duration = #{silenceDuration,jdbcType=INTEGER},
create_time = #{createTime,jdbcType=TIMESTAMP},
set silence_duration = #{silenceDuration,jdbcType=INTEGER},
update_time = #{updateTime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=INTEGER}
</update>
......@@ -98,14 +97,30 @@
<!--根据机器人wxid获取缄默时长-->
<select id="getSilenceDurationByRobotWxId" resultType="java.lang.Integer">
SELECT silence_duration FROM pcloud_robot_silence WHERE robot_wx_id = #{wxId}
SELECT silence_duration FROM pcloud_robot_silence WHERE 1=1
<if test="wxId != null">
and robot_wx_id = #{wxId}
</if>
<if test="pcloudClassifyId != null">
and pcloud_classify_id = #{pcloudClassifyId}
</if>
</select>
<!--设置机器人缄默时长-->
<update id="setSilenceDuration">
INSERT INTO pcloud_robot_silence (robot_wx_id,silence_duration,create_time) VALUE(#{robotWxId},#{silenceDuration},NOW())
INSERT INTO pcloud_robot_silence (robot_wx_id,silence_duration,create_time, pcloud_classify_id)
VALUE(#{robotWxId},#{silenceDuration},NOW(), #{pcloudClassifyId})
ON DUPLICATE KEY UPDATE robot_wx_id=#{robotWxId},silence_duration=#{silenceDuration},update_time=NOW()
</update>
<select id="get" resultMap="BaseResultMap">
SELECT id, robot_wx_id, silence_duration, create_time, update_time, pcloud_classify_id FROM pcloud_robot_silence WHERE 1=1
<if test="wxId != null">
and robot_wx_id = #{wxId}
</if>
<if test="pcloudClassifyId != null">
and pcloud_classify_id = #{pcloudClassifyId}
</if>
</select>
</mapper>
\ No newline at end of file
......@@ -135,20 +135,18 @@
r.head head,
r.qrcode_url qrcodeUrl,
r.robot_type robotType,
r.keyword_classify_id keywordClassifyId,
r.state state,
r.unique_number uniqueNumber,
r.welcome_duration welcomeDuration,
rc.classify_name classifyName
r.unique_number uniqueNumber
FROM
pcloud_robot r
left join pcloud_robot_classify rc
on r.robot_type = rc.id
WHERE
1=1
<if test="nickName!=null">
and r.nick_name like concat('%', #{nickName}, '%')
</if>
<if test="classifyId!=null">
and r.robot_type = #{classifyId}
</if>
</select>
<select id="getPcloudKeywordRobotCount" parameterType="map" resultType="integer">
......@@ -252,4 +250,16 @@
and state = 1
</select>
<select id="getRobotCountByClassifyId" parameterType="long" resultType="int">
select COUNT(DISTINCT wx_id)
from pcloud_robot
where robot_type = #{classifyId}
</select>
<update id="updateRobotState" parameterType="map">
update pcloud_robot set
state = #{state}
where id=#{id}
</update>
</mapper>
\ No newline at end of file
......@@ -5,10 +5,21 @@
<id column="id" property="id" jdbcType="INTEGER" />
<result column="classify_name" property="classifyName" jdbcType="VARCHAR" />
<result column="is_delete" property="isDelete" jdbcType="INTEGER" />
<result column="link_url" property="linkUrl" jdbcType="VARCHAR"/>
<result column="qrcode_url" property="qrcodeUrl" jdbcType="VARCHAR" />
<result column="keyword_classify_id" property="keywordClassifyId" jdbcType="VARCHAR" />
<result column="welcome_duration" property="welcomeDuration" jdbcType="INTEGER" />
</resultMap>
<resultMap id="pageResultMap" type="com.pcloud.book.pcloudkeyword.facade.response.PcloudRobotClassifyResponseVO" >
<id column="id" property="id" jdbcType="INTEGER" />
<result column="classify_name" property="classifyName" jdbcType="VARCHAR" />
<result column="qrcode_url" property="qrcodeUrl" jdbcType="VARCHAR" />
<association property="robotCount" column="id" fetchType="eager"
select="com.pcloud.book.pcloudkeyword.dao.impl.PcloudRobotDaoImpl.getRobotCountByClassifyId" />
</resultMap>
<sql id="Base_Column_List" >
id, classify_name, is_delete
id, classify_name, link_url, qrcode_url,keyword_classify_id, is_delete, welcome_duration
</sql>
<insert id="insert" parameterType="com.pcloud.book.pcloudkeyword.entity.PcloudRobotClassify" useGeneratedKeys="true" keyProperty="id">
......@@ -23,9 +34,24 @@
</insert>
<update id="update" parameterType="com.pcloud.book.pcloudkeyword.entity.PcloudRobotClassify">
update pcloud_robot set
classify_name = #{classifyName},
is_delete = #{isDelete}
update pcloud_robot
<set>
<if test="classifyName != null">
classify_name = #{classifyName},
</if>
<if test="linkUrl != null">
link_url = #{linkUrl},
</if>
<if test="qrcodeUrl != null">
qrcode_url = #{qrcodeUrl},
</if>
<if test="isDelete != null">
is_delete = #{isDelete},
</if>
<if test="welcomeDuration != null">
welcome_duration = #{welcomeDuration},
</if>
</set>
where id=#{id}
</update>
......@@ -35,4 +61,28 @@
from pcloud_robot_classify where is_delete = 0
</select>
<select id="getById" parameterType="long" resultMap="BaseResultMap">
select <include refid="Base_Column_List"/>
from pcloud_robot_classify where id=#{id}
</select>
<select id="listClassifyByPage" resultMap="pageResultMap">
select
id, classify_name, qrcode_url
from pcloud_robot_classify
where is_delete = 0
</select>
<update id="updateRobotClassifyKeywordClassify" parameterType="map">
update pcloud_robot_classify
set keyword_classify_id=#{keywordClassifyId}
where id=#{id}
</update>
<update id="updateWelcomeDuration" parameterType="map">
update pcloud_robot_classify
set welcome_duration = #{welcomeDuration}
where id=#{id}
</update>
</mapper>
\ No newline at end of file
......@@ -4,6 +4,7 @@
<resultMap id="BaseResultMap" type="PcloudRobotWelcome" >
<id column="id" property="id" jdbcType="INTEGER" />
<result column="pcloud_robot_id" property="pcloudRobotId" jdbcType="BIGINT"/>
<result column="pcloud_classify_id" property="pcloudClassifyId" jdbcType="BIGINT"/>
<result column="reply_type" property="replyType" jdbcType="INTEGER"/>
<result column="content" property="content" jdbcType="VARCHAR"/>
<result column="pic_url" property="picUrl" jdbcType="VARCHAR"/>
......@@ -16,7 +17,7 @@
</resultMap>
<sql id="Base_Column_List" >
id, pcloud_robot_id, reply_type, content, pic_url, file_name, file_type, file_url,
id, pcloud_robot_id, pcloud_classify_id, reply_type, content, pic_url, file_name, file_type, file_url,
file_size, resource_id, create_time
</sql>
......@@ -24,6 +25,7 @@
<insert id="batchInsert" parameterType="PcloudRobotWelcome" useGeneratedKeys="true" keyProperty="id">
insert into pcloud_robot_welcome (
pcloud_robot_id,
pcloud_classify_id,
reply_type,
content,
pic_url,
......@@ -37,6 +39,7 @@
<foreach collection="list" item="item" index="index" separator=",">
(
#{item.pcloudRobotId,jdbcType=BIGINT},
#{item.pcloudClassifyId,jdbcType=BIGINT},
#{item.replyType,jdbcType=INTEGER},
#{item.content,jdbcType=VARCHAR},
#{item.picUrl,jdbcType=VARCHAR},
......@@ -55,9 +58,20 @@
where pcloud_robot_id = #{pcloudRobotId}
</delete>
<delete id="deleteByPcloudClassifyId" parameterType="long">
delete from pcloud_robot_welcome
where pcloud_classify_id = #{pcloudClassifyId}
</delete>
<select id="getRobotWelcomeListByPcloudRobotId" parameterType="long" resultMap="BaseResultMap">
select <include refid="Base_Column_List"/>
from pcloud_robot_welcome
where pcloud_robot_id = #{pcloudRobotId}
</select>
<select id="getRobotWelcomeListByPcloudClassifyId" parameterType="long" resultMap="BaseResultMap">
select <include refid="Base_Column_List"/>
from pcloud_robot_welcome
where pcloud_classify_id = #{pcloudClassifyId}
</select>
</mapper>
\ No newline at end of file
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