Commit b231b044 by 章春雨

Merge branch 'feat-1002407' into 'master'

时间管理统一回复

See merge request rays/pcloud-book!450
parents a5b4f0d0 6cc09c88
...@@ -3,7 +3,6 @@ package com.pcloud.book.timecontrol.dto; ...@@ -3,7 +3,6 @@ package com.pcloud.book.timecontrol.dto;
import lombok.Data; import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
import java.math.BigDecimal;
/** /**
* @date: 2020年01月31日 9:50 * @date: 2020年01月31日 9:50
...@@ -13,30 +12,20 @@ import java.math.BigDecimal; ...@@ -13,30 +12,20 @@ import java.math.BigDecimal;
@Data @Data
public class CreateReplyMessageDto implements Serializable { public class CreateReplyMessageDto implements Serializable {
private String messageType; private Integer replyType;
private String text;
private Integer appId;
private Integer productId;
private String imgUrl;
private String fileName; private String content;
private String fileUrl; private String picUrl;
private String linkUrl; private String linkUrl;
/** private String description;
* 回复类型 0 普通回复 1 完成任务确认回复
*/ private Long serveId;
private Integer replyType;
private String fileId; private String serveType;
private String fileType; private Long resourceId;
private BigDecimal size;
} }
...@@ -3,7 +3,6 @@ package com.pcloud.book.timecontrol.dto; ...@@ -3,7 +3,6 @@ package com.pcloud.book.timecontrol.dto;
import lombok.Data; import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
import java.math.BigDecimal;
/** /**
* @date: 2020年01月31日 9:50 * @date: 2020年01月31日 9:50
...@@ -13,27 +12,31 @@ import java.math.BigDecimal; ...@@ -13,27 +12,31 @@ import java.math.BigDecimal;
@Data @Data
public class ReplyMessageDto implements Serializable { public class ReplyMessageDto implements Serializable {
private String messageType; private Integer replyType;
private String text; private String content;
private Integer appId; private Long serveId;
private Integer productId; private Long resourceId;
private String imgUrl; private String picUrl;
private String fileName; private String serveType;
private String fileUrl; private String description;
private String linkUrl; private String linkUrl;
private String fileId; private Integer taskItemId;
private String fileType; private String fileType;
private BigDecimal size; private String resourceName;
private Integer taskItemId; private String resourceUrl;
private Long fileSize;
private String resourceTypeCode;
} }
...@@ -9,6 +9,7 @@ import com.pcloud.book.timecontrol.dto.TaskDto; ...@@ -9,6 +9,7 @@ import com.pcloud.book.timecontrol.dto.TaskDto;
import com.pcloud.book.timecontrol.dto.TaskItemDto; import com.pcloud.book.timecontrol.dto.TaskItemDto;
import com.pcloud.book.timecontrol.dto.UpdateTaskDto; import com.pcloud.book.timecontrol.dto.UpdateTaskDto;
import com.pcloud.book.timecontrol.dto.UpdateTaskItemDto; import com.pcloud.book.timecontrol.dto.UpdateTaskItemDto;
import com.pcloud.book.timecontrol.entity.TimeControlReplyMessage;
import com.pcloud.book.timecontrol.vo.KeyWordTaskVO; import com.pcloud.book.timecontrol.vo.KeyWordTaskVO;
import com.pcloud.common.page.PageBeanNew; import com.pcloud.common.page.PageBeanNew;
...@@ -59,4 +60,6 @@ public interface TaskBiz { ...@@ -59,4 +60,6 @@ public interface TaskBiz {
void finishTaskSend(Integer taskSendId); void finishTaskSend(Integer taskSendId);
TaskDto getTaskByIdAndWxUserId(Integer relSkillId, String wxUserId); TaskDto getTaskByIdAndWxUserId(Integer relSkillId, String wxUserId);
void sendReplyMessage(List<TimeControlReplyMessage> replyMessages, String wxUserId, String robotWxId, String ip);
} }
package com.pcloud.book.timecontrol.biz.impl; package com.pcloud.book.timecontrol.biz.impl;
import com.google.common.util.concurrent.ThreadFactoryBuilder; import com.google.common.util.concurrent.ThreadFactoryBuilder;
import com.pcloud.appcenter.app.dto.AppDto;
import com.pcloud.book.consumer.app.AppConsr; import com.pcloud.book.consumer.app.AppConsr;
import com.pcloud.book.consumer.channel.QrcodeSceneConsr; import com.pcloud.book.consumer.channel.QrcodeSceneConsr;
import com.pcloud.book.consumer.content.ResourceConsr; import com.pcloud.book.consumer.content.ResourceConsr;
...@@ -19,6 +18,7 @@ import com.pcloud.book.skill.entity.PcloudSkill; ...@@ -19,6 +18,7 @@ import com.pcloud.book.skill.entity.PcloudSkill;
import com.pcloud.book.skill.entity.PcloudSubReply; import com.pcloud.book.skill.entity.PcloudSubReply;
import com.pcloud.book.skill.enums.SkillTypeEnum; import com.pcloud.book.skill.enums.SkillTypeEnum;
import com.pcloud.book.skill.enums.SubTypeEnum; import com.pcloud.book.skill.enums.SubTypeEnum;
import com.pcloud.book.timecontrol.biz.TaskBiz;
import com.pcloud.book.timecontrol.biz.TaskSubscribeBiz; import com.pcloud.book.timecontrol.biz.TaskSubscribeBiz;
import com.pcloud.book.timecontrol.dto.ReplyMessageBaseDto; import com.pcloud.book.timecontrol.dto.ReplyMessageBaseDto;
import com.pcloud.book.timecontrol.dto.TaskSendDto; import com.pcloud.book.timecontrol.dto.TaskSendDto;
...@@ -44,7 +44,6 @@ import com.pcloud.common.utils.ListUtils; ...@@ -44,7 +44,6 @@ import com.pcloud.common.utils.ListUtils;
import com.pcloud.common.utils.httpclient.UrlUtils; import com.pcloud.common.utils.httpclient.UrlUtils;
import com.pcloud.common.utils.string.StringUtil; import com.pcloud.common.utils.string.StringUtil;
import com.pcloud.contentcenter.resource.dto.ResourceDTO; import com.pcloud.contentcenter.resource.dto.ResourceDTO;
import com.pcloud.resourcecenter.product.dto.ProductDto;
import com.pcloud.wechatgroup.group.dto.GroupRobotDTO; import com.pcloud.wechatgroup.group.dto.GroupRobotDTO;
import com.sdk.wxgroup.SendArticleMessageVO; import com.sdk.wxgroup.SendArticleMessageVO;
import com.sdk.wxgroup.SendFileVO; import com.sdk.wxgroup.SendFileVO;
...@@ -122,7 +121,8 @@ public class TaskSubscribeBizImpl implements TaskSubscribeBiz { ...@@ -122,7 +121,8 @@ public class TaskSubscribeBizImpl implements TaskSubscribeBiz {
private PcloudRobotSet pcloudRobotSet; private PcloudRobotSet pcloudRobotSet;
@Autowired @Autowired
private PcloudSkillRecordDao pcloudSkillRecordDao; private PcloudSkillRecordDao pcloudSkillRecordDao;
@Autowired
private TaskBiz taskBiz;
@Override @Override
@ParamLog("任务订阅") @ParamLog("任务订阅")
...@@ -325,94 +325,7 @@ public class TaskSubscribeBizImpl implements TaskSubscribeBiz { ...@@ -325,94 +325,7 @@ public class TaskSubscribeBizImpl implements TaskSubscribeBiz {
String ip = weixinQrcodeBiz.getRobotIpByGeneration(groupRobotDTO.getVersion()); String ip = weixinQrcodeBiz.getRobotIpByGeneration(groupRobotDTO.getVersion());
Integer taskSendId = sendDto.getId(); Integer taskSendId = sendDto.getId();
TimeControlTaskSend timeControlTaskSend = timeControlTaskSendMapper.getById(taskSendId); TimeControlTaskSend timeControlTaskSend = timeControlTaskSendMapper.getById(taskSendId);
for(TimeControlReplyMessage replyMessage : replyMessages) { taskBiz.sendReplyMessage(replyMessages, wxUserId, robotWxId, ip);
if(replyMessage != null) {
switch (replyMessage.getMessageType()) {
case "text" :
// 发送文本
SendTextMessageVO sendTextMessageVO = new SendTextMessageVO();
sendTextMessageVO.setContent(replyMessage.getText());
sendTextMessageVO.setCode(SendMessageTypeEnum.SELF.getCode());
sendTextMessageVO.setWxId(robotWxId);
sendTextMessageVO.setAltId(robotWxId);
sendTextMessageVO.setWxGroupId(wxUserId);
sendTextMessageVO.setIp(ip);
WxGroupSDK.sendTextMessage(sendTextMessageVO);
break;
case "img" :
// 发送图片
SendPicMessageVO sendPicMessageVO = new SendPicMessageVO();
sendPicMessageVO.setCode(SendMessageTypeEnum.SELF.getCode());
sendPicMessageVO.setAltId(robotWxId);
sendPicMessageVO.setWxGroupId(wxUserId);
sendPicMessageVO.setPicUrl(replyMessage.getImgUrl());
sendPicMessageVO.setIp(ip);
WxGroupSDK.sendPicMessage(sendPicMessageVO);
break;
case "file" :
// 发送文件
String fileUrl= replyMessage.getFileUrl();
String fileName = replyMessage.getFileName();
String fileType = fileUrl.substring(fileUrl.lastIndexOf("."),fileUrl.length());
if (!StringUtil.isEmpty(fileType) && fileName.contains(fileType)) {//去掉后缀
fileName = fileName.substring(0, fileName.indexOf(fileType) - 1);
}
SendFileVO sendFileVO = new SendFileVO();
sendFileVO.setFileUrl(fileUrl);
sendFileVO.setFileName(fileName);
sendFileVO.setIp(ip);
sendFileVO.setAltId(robotWxId);
sendFileVO.setWxId(wxUserId);
WxGroupSDK.sendFile(sendFileVO);
break;
case "app" :
//发送应用
if(replyMessage.getAppId() != null) {
AppDto appDto = appConsr.getBaseById(replyMessage.getAppId().longValue());
if (appDto != null) {
AccountSettingDto accountSettingDto = qrcodeSceneConsr.getWechatInfo(appDto.getChannelId());
SendArticleMessageVO sendArticleMessageVO = new SendArticleMessageVO();
sendArticleMessageVO.setCode(SendMessageTypeEnum.SELF.getCode());
sendArticleMessageVO.setAltId(robotWxId);
sendArticleMessageVO.setDescription(appDto.getTypeName());
sendArticleMessageVO.setWxGroupId(wxUserId);
// 链接地址
String linkUrl = this.splitUrl(accountSettingDto, replyMessage.getLinkUrl());
sendArticleMessageVO.setLinkUrl(linkUrl);
sendArticleMessageVO.setPicUrl(appDto.getSquareImg());
sendArticleMessageVO.setTitle(appDto.getTitle());
sendArticleMessageVO.setIp(ip);
WxGroupSDK.sendArticleMessage(sendArticleMessageVO);
}
}
//发送作品
if(replyMessage.getProductId() != null) {
ProductDto productDto = productConsr.getProBaseById(replyMessage.getProductId().longValue());
Long channelId = productConsr.getOneChannelIdByProId(replyMessage.getProductId().longValue());
AccountSettingDto accountSettingDto = qrcodeSceneConsr.getWechatInfo(channelId);
if(productDto != null && accountSettingDto != null) {
SendArticleMessageVO sendArticleMessageVO = new SendArticleMessageVO();
sendArticleMessageVO.setCode(SendMessageTypeEnum.SELF.getCode());
sendArticleMessageVO.setAltId(robotWxId);
if (productDto.getProductTypeDto() != null) {
sendArticleMessageVO.setDescription(productDto.getProductTypeDto().getTypeName());
}
sendArticleMessageVO.setWxGroupId(wxUserId);
// 处理链接地址
String linkUrl = this.splitUrl(accountSettingDto, replyMessage.getLinkUrl());
sendArticleMessageVO.setLinkUrl(linkUrl);
sendArticleMessageVO.setPicUrl(productDto.getCoverImg());
sendArticleMessageVO.setTitle(productDto.getProductName());
sendArticleMessageVO.setIp(ip);
WxGroupSDK.sendArticleMessage(sendArticleMessageVO);
}
}
break;
default:
break;
}
}
}
if(YesOrNoEnums.YES.getValue().equals(timeControlTaskItem.getAddSendTime())){ if(YesOrNoEnums.YES.getValue().equals(timeControlTaskItem.getAddSendTime())){
//封装退订提醒 //封装退订提醒
SendTextMessageVO sendTextMessageVO = new SendTextMessageVO(); SendTextMessageVO sendTextMessageVO = new SendTextMessageVO();
...@@ -484,38 +397,6 @@ public class TaskSubscribeBizImpl implements TaskSubscribeBiz { ...@@ -484,38 +397,6 @@ public class TaskSubscribeBizImpl implements TaskSubscribeBiz {
} }
} }
/**
* 补充退订提示信息
*
* @param replyMessages
*/
private boolean fillUnsubscribeInfo(List<TimeControlReplyMessage> replyMessages,boolean lastOne) {
boolean tmp = false;
if (replyMessages.size() == 0) {
return tmp;
}
boolean hasText = false;
for (TimeControlReplyMessage replyMessage : replyMessages) {
if ("text".equals(replyMessage.getMessageType())) {
hasText = true;
tmp = true;
replyMessage.setText(replyMessage.getText() + "\n如需退订,请回复 TD" + replyMessage.getTaskId());
}
}
if (lastOne && !hasText) {
// 不存在文本消息 追加消息进行推送
TimeControlReplyMessage text = TimeControlReplyMessage.builder().messageType("text").text("如需退订,请回复 TD" + replyMessages.get(0).getTaskId()).build();
replyMessages.add(text);
}
return tmp;
}
@Override @Override
public TimeControlTaskSubscribe getSubscribeState(String wxUserId, Integer taskId) { public TimeControlTaskSubscribe getSubscribeState(String wxUserId, Integer taskId) {
TimeControlTaskSubscribe timeControlTaskSubscribe = taskSubscribeMapper.getSubscribe(wxUserId, null, taskId); TimeControlTaskSubscribe timeControlTaskSubscribe = taskSubscribeMapper.getSubscribe(wxUserId, null, taskId);
......
...@@ -5,7 +5,6 @@ import lombok.Builder; ...@@ -5,7 +5,6 @@ import lombok.Builder;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
@Data @Data
...@@ -19,21 +18,13 @@ public class TimeControlReplyMessage { ...@@ -19,21 +18,13 @@ public class TimeControlReplyMessage {
private Integer taskItemId; private Integer taskItemId;
private Integer replyType; private Integer type;
private String messageType;
private String text;
private Integer appId;
private Integer productId; private Integer replyType;
private String imgUrl;
private String fileName; private String content;
private String fileUrl; private String picUrl;
private Date createTime; private Date createTime;
...@@ -41,10 +32,12 @@ public class TimeControlReplyMessage { ...@@ -41,10 +32,12 @@ public class TimeControlReplyMessage {
private String linkUrl; private String linkUrl;
private String fileId; private Long serveId;
private String serveType;
private String fileType; private Long resourceId;
private BigDecimal size; private String description;
} }
\ No newline at end of file
...@@ -26,9 +26,9 @@ public interface TimeControlReplyMessageMapper { ...@@ -26,9 +26,9 @@ public interface TimeControlReplyMessageMapper {
void deleteByItemId(Integer taskItemId); void deleteByItemId(Integer taskItemId);
List<TimeControlReplyMessage> list4TaskItem(@Param("taskItemId") Integer taskItemId, @Param("replyType") Integer replyType); List<TimeControlReplyMessage> list4TaskItem(@Param("taskItemId") Integer taskItemId, @Param("type") Integer type);
List<TimeControlReplyMessage> getByTaskItemId(Integer taskItemId); List<TimeControlReplyMessage> getByTaskItemId(Integer taskItemId);
List<ReplyMessageDto> list4TaskItemList(@Param("taskItemIds") List<Integer> taskItemIds, @Param("replyType") Integer replyType); List<ReplyMessageDto> list4TaskItemList(@Param("taskItemIds") List<Integer> taskItemIds, @Param("type") Integer type);
} }
\ No newline at end of file
...@@ -5,24 +5,21 @@ ...@@ -5,24 +5,21 @@
<id column="id" property="id" jdbcType="INTEGER" /> <id column="id" property="id" jdbcType="INTEGER" />
<result column="task_item_id" property="taskItemId" jdbcType="INTEGER" /> <result column="task_item_id" property="taskItemId" jdbcType="INTEGER" />
<result column="task_id" property="taskId" jdbcType="INTEGER" /> <result column="task_id" property="taskId" jdbcType="INTEGER" />
<result column="type" property="type" jdbcType="INTEGER" />
<result column="reply_type" property="replyType" jdbcType="INTEGER" /> <result column="reply_type" property="replyType" jdbcType="INTEGER" />
<result column="message_type" property="messageType" jdbcType="VARCHAR" /> <result column="content" property="content" jdbcType="VARCHAR" />
<result column="text" property="text" jdbcType="VARCHAR" /> <result column="serve_id" property="serveId" jdbcType="INTEGER" />
<result column="app_id" property="appId" jdbcType="INTEGER" /> <result column="resource_id" property="resourceId" jdbcType="INTEGER" />
<result column="product_id" property="productId" jdbcType="INTEGER" /> <result column="pic_url" property="picUrl" jdbcType="VARCHAR" />
<result column="img_url" property="imgUrl" jdbcType="VARCHAR" /> <result column="serve_type" property="serveType" jdbcType="VARCHAR" />
<result column="file_name" property="fileName" jdbcType="VARCHAR" /> <result column="description" property="description" jdbcType="VARCHAR" />
<result column="file_url" property="fileUrl" jdbcType="VARCHAR" />
<result column="file_id" property="fileId" jdbcType="VARCHAR" />
<result column="file_type" property="fileType" jdbcType="VARCHAR" />
<result column="size" property="size" jdbcType="DECIMAL" />
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" /> <result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP" /> <result column="update_time" property="updateTime" jdbcType="TIMESTAMP" />
<result column="link_url" property="linkUrl" jdbcType="VARCHAR" /> <result column="link_url" property="linkUrl" jdbcType="VARCHAR" />
</resultMap> </resultMap>
<sql id="Base_Column_List" > <sql id="Base_Column_List" >
id, task_id, task_item_id, reply_type, message_type, text, app_id, product_id, img_url, file_name, id, task_id, task_item_id, type, reply_type, content, serve_id, resource_id, pic_url, serve_type,
file_url, create_time, update_time, link_url, file_id, file_type, size description, create_time, update_time, link_url
</sql> </sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" > <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select select
...@@ -32,10 +29,10 @@ ...@@ -32,10 +29,10 @@
</select> </select>
<select id="list4TaskItem" resultMap="BaseResultMap"> <select id="list4TaskItem" resultMap="BaseResultMap">
select task_id, task_item_id, reply_type, message_type, app_id, product_id, img_url, file_name, select task_id, task_item_id, type, reply_type, serve_id, resource_id, pic_url, serve_type,
file_url, create_time, text, link_url, file_id, file_type, size description, create_time, content, link_url
from time_control_reply_message from time_control_reply_message
where task_item_id = #{taskItemId} and reply_type = #{replyType} where task_item_id = #{taskItemId} and type = #{type}
</select> </select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" > <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
...@@ -46,26 +43,25 @@ ...@@ -46,26 +43,25 @@
delete from time_control_reply_message where task_item_id = #{taskItemId} delete from time_control_reply_message where task_item_id = #{taskItemId}
</delete> </delete>
<insert id="insert" parameterType="com.pcloud.book.timecontrol.entity.TimeControlReplyMessage" > <insert id="insert" parameterType="com.pcloud.book.timecontrol.entity.TimeControlReplyMessage" >
insert into time_control_reply_message (id, task_item_id, reply_type, insert into time_control_reply_message (id, task_item_id, type,
message_type, app_id, product_id, reply_type, serve_id, resource_id,
img_url, file_name, file_url, pic_url, serve_type, description,
create_time, update_time) create_time, update_time)
values (#{id,jdbcType=INTEGER}, #{taskItemId,jdbcType=INTEGER}, #{replyType,jdbcType=INTEGER}, values (#{id,jdbcType=INTEGER}, #{taskItemId,jdbcType=INTEGER}, #{type,jdbcType=INTEGER},
#{messageType,jdbcType=VARCHAR}, #{appId,jdbcType=INTEGER}, #{productId,jdbcType=INTEGER}, #{replyType,jdbcType=VARCHAR}, #{serveId,jdbcType=INTEGER}, #{resourceId,jdbcType=INTEGER},
#{imgUrl,jdbcType=VARCHAR}, #{fileName,jdbcType=VARCHAR}, #{fileUrl,jdbcType=VARCHAR}, #{picUrl,jdbcType=VARCHAR}, #{serveType,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR},
#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}) #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP})
</insert> </insert>
<insert id="batchInsert"> <insert id="batchInsert">
insert into time_control_reply_message (task_id, task_item_id, reply_type, insert into time_control_reply_message (task_id, task_item_id, type,
message_type, text, app_id, product_id, reply_type, content, serve_id, resource_id,
img_url, file_name, file_url, pic_url, serve_type, description,
create_time, update_time, link_url, file_id, file_type, size) create_time, update_time, link_url)
values values
<foreach collection="list" separator="," item="item"> <foreach collection="list" separator="," item="item">
(#{item.taskId}, #{item.taskItemId}, #{item.replyType}, #{item.messageType}, #{item.text}, #{item.appId}, (#{item.taskId}, #{item.taskItemId}, #{item.type}, #{item.replyType}, #{item.content}, #{item.serveId},
#{item.productId}, #{item.imgUrl}, #{item.fileName}, #{item.fileUrl}, now(), now(), #{item.linkUrl}, #{item.resourceId}, #{item.picUrl}, #{item.serveType}, #{item.description}, now(), now(), #{item.linkUrl})
#{item.fileId}, #{item.fileType}, #{item.size})
</foreach> </foreach>
</insert> </insert>
...@@ -79,16 +75,16 @@ ...@@ -79,16 +75,16 @@
<select id="list4TaskItemList" resultType="com.pcloud.book.timecontrol.dto.ReplyMessageDto"> <select id="list4TaskItemList" resultType="com.pcloud.book.timecontrol.dto.ReplyMessageDto">
select select
task_item_id taskItemId, task_item_id taskItemId,
app_id appId, serve_id serveId,
product_id productId, resource_id resourceId,
img_url imgUrl, pic_url picUrl,
file_name fileName, serve_type serveType,
file_url fileUrl, description description,
text text, content content,
link_url linkUrl, link_url linkUrl,
message_type messageType, file_type fileType, size reply_type replyType, file_type fileType, size
from time_control_reply_message from time_control_reply_message
where reply_type = #{replyType} where type = #{type}
<if test="taskItemIds !=null and taskItemIds.size()>0"> <if test="taskItemIds !=null and taskItemIds.size()>0">
AND task_item_id IN AND task_item_id IN
<foreach collection="taskItemIds" open="(" close=")" separator="," item="item"> <foreach collection="taskItemIds" open="(" close=")" separator="," item="item">
......
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