Commit 9e67e954 by zhuyajie

需求单延迟

parent c4e9a581
......@@ -191,6 +191,11 @@
<artifactId>pcloud-facade-wechat</artifactId>
<version>${pcloud-facade.version}</version>
</dependency>
<dependency>
<groupId>com.pcloud.facade</groupId>
<artifactId>pcloud-facade-feedback</artifactId>
<version>${pcloud-facade.version}</version>
</dependency>
<dependency>
<groupId>com.pcloud.facade</groupId>
......
package com.pcloud.book.consumer.feedback;
import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.common.core.aspect.ParamLog;
import com.pcloud.common.exceptions.BizException;
import com.pcloud.common.utils.ListUtils;
import com.pcloud.common.utils.ResponseHandleUtil;
import com.pcloud.contentcenter.resource.dto.ResourceDTO;
import com.pcloud.contentcenter.resource.service.ResourceService;
import com.pcloud.feedback.feedback.service.FeedBackService;
import com.pcloud.feedback.paper.dto.PaperAndQuestionDto;
import com.pcloud.feedback.paper.dto.PaperDto;
import com.pcloud.feedback.paper.service.PaperService;
import org.slf4j.Logger;
......@@ -27,6 +29,8 @@ public class FeedbackConsr {
@Autowired
private PaperService paperService;
@Autowired
private FeedBackService feedBackService;
/**
......@@ -71,5 +75,17 @@ public class FeedbackConsr {
return paperIds;
}
@ParamLog("根据问卷id获取问卷基本信息")
public PaperAndQuestionDto getPaperByPaperId(Long paperId){
PaperAndQuestionDto questionDto = new PaperAndQuestionDto();
try {
questionDto=ResponseHandleUtil.parseResponse(feedBackService.getPaperByPaperId(paperId), PaperAndQuestionDto.class);
}catch (Exception e){
LOGGER.error("【feedBackService.getPaperByPaperId】调用失败"+e.getMessage(),e);
}
return questionDto;
}
}
......@@ -287,6 +287,8 @@ public class BookGuideBizImpl implements BookGuideBiz {
//清空缓存中该阶段的非关键词数量
//刪除发送非关键词次数緩存
JedisClusterUtils.del(PersonalStageConstant.USER_SEND_KEYWORD_COUNT_LOCK + personalStageId + "_" + agreeAddUserDTO.getUserWxId());
//删除进度单点击记录缓存
JedisClusterUtils.del("BOOK:LINK_PROGRESS:"+ agreeAddUserDTO.getUserWxId() + "-" +agreeAddUserDTO.getRobotWxId());
}
return;
}
......
......@@ -48,6 +48,10 @@ public class DelayReceiver {
personalStageBiz.dealDelayFusingFinish(dto);
} else if (PersonalStageConstant.PERSONALSTAGE_DELAY_LINKUP.equals(dto.getType())) {
personalStageJumpBiz.dealDelayLinkup(dto);
} else if (PersonalStageConstant.PERSONALSTAGE_DELAY_PROGRESS.equalsIgnoreCase(dto.getType())) {
personalStageJumpBiz.delayProgress(dto);
} else if (PersonalStageConstant.PERSONALSTAGE_DELAY_PAPER.equalsIgnoreCase(dto.getType())) {
personalStageJumpBiz.delayPaper(dto);
}
}
}
......@@ -55,7 +55,7 @@ public interface PersonalStageBiz {
void sendNotKeywordFusingReply(String robotId, String userWxId, String ip, Long personalStageId,Long personalStageUserId, Long paperId);
String replaceProjectProgressUrl(String content, String robotId, String userWxId, Long personalStageUserId);
String replaceProjectProgressUrl(String content, String robotId, String userWxId, Long personalStageUserId, String ip);
void dealDelayFusingFinish(DelayQueueDTO dto);
......
package com.pcloud.book.personalstage.biz;
import com.pcloud.book.personalstage.dto.LinkClickRecordDTO;
import com.pcloud.book.personalstage.dto.PersonalStageJumpDto;
import com.pcloud.book.personalstage.enums.JumpTypeEnum;
import com.pcloud.book.personalstage.vo.request.CreateStageJumpRequestVO;
......@@ -59,4 +60,36 @@ public interface PersonalStageJumpBiz {
* @return
*/
Map<String, Object> getUserInputPaperInfo(String robotWxId, String userWxId);
/**
* 进度单发送时添加未点链接回复延迟
*/
public void addProgressDelay(String userWxId, String robotWxId, String ip);
/**
* 添加点击记录
* @param linkClickRecordDTO
*/
public void addLinkClickRecord(LinkClickRecordDTO linkClickRecordDTO);
/**
* 处理进度单延迟
* @param dto
*/
void delayProgress(DelayQueueDTO dto);
/**
* 添加需求定制单延迟
* @param userWxId
* @param robotWxId
* @param ip
* @param paperId
*/
public void addPaperDelay(String userWxId, String robotWxId, String ip, Long paperId);
/**
* 处理需求单延迟
* @param dto
*/
void delayPaper(DelayQueueDTO dto);
}
......@@ -68,8 +68,6 @@ import java.util.Map;
import java.util.Random;
import java.util.stream.Collectors;
import io.swagger.models.auth.In;
@Component("personalStageBiz")
public class PersonalStageBizImpl implements PersonalStageBiz {
......@@ -501,7 +499,7 @@ public class PersonalStageBizImpl implements PersonalStageBiz {
String robotId=wakeupDelayDTO.getRobotId();
String userWxId=wakeupDelayDTO.getWxId();
String ip=wakeupDelayDTO.getIp();
this.replacePaperUrl(replyItems, robotId, userWxId, personalStage.getPaperId());
this.replacePaperUrl(replyItems, robotId, userWxId, personalStage.getPaperId(),ip);
sendReplyItems(replyItems,robotId,userWxId,ip,wakeupDelayDTO.getPersonalStageUserId());
//下一个延时
List<PersonalStageWakeup> wakeups = personalStageWakeupDao.getListByPersonalStageId(personalStageId);
......@@ -614,7 +612,7 @@ public class PersonalStageBizImpl implements PersonalStageBiz {
return;
}
//替换需求定制单链接
this.replacePaperUrl(items, robotId, userWxId, personalStageReply.getPaperId());
this.replacePaperUrl(items, robotId, userWxId, personalStageReply.getPaperId(),ip);
sendReplyItems(items,robotId,userWxId,ip,personalStageUserId);
}
......@@ -687,11 +685,13 @@ public class PersonalStageBizImpl implements PersonalStageBiz {
@Override
@ParamLog("替换进度链接")
public String replaceProjectProgressUrl(String content, String robotId, String userWxId, Long personalStageUserId) {
public String replaceProjectProgressUrl(String content, String robotId, String userWxId, Long personalStageUserId, String ip) {
if(content.indexOf(PersonalStageConstant.PERSONAL_STAGE_PROJECT_PROGRESS_TEMPLATE) > -1){
tryInsertNumber(personalStageUserId);
String longUrl = wechatLinkPrefix.concat(PersonalStageConstant.PERSONAL_STAGE_PROJECT_PROGRESS).concat("?wxUserId=" + userWxId + "&robotId=" + robotId + "&personalStageUserId=" + personalStageUserId);
content = content.replace(PersonalStageConstant.PERSONAL_STAGE_PROJECT_PROGRESS_TEMPLATE, UrlUtils.getShortUrl4Own(longUrl));
//添加进度单回复延迟队列
personalStageJumpBiz.addProgressDelay(userWxId, robotId, ip);
}
content = replaceUserSendContent(content, robotId, userWxId);
content = replaceReadingStyle(content, robotId, userWxId);
......@@ -734,20 +734,25 @@ public class PersonalStageBizImpl implements PersonalStageBiz {
}
@ParamLog("替换需求定制单链接")
private void replacePaperUrl(List<PersonalStageReplyItem> items, String robotId, String userWxId, Long paperId){
private void replacePaperUrl(List<PersonalStageReplyItem> items, String robotId, String userWxId, Long paperId, String ip){
for (PersonalStageReplyItem item : items){
if(ReplyTypeEnum.TEXT.value.equals(item.getReplyType())){
if (null == paperId){
item.setContent(item.getContent().replace(PERSONAL_STAGE_PAPER_TEMPLATE, ""));
item.setContent(item.getContent().replace(PERSONAL_STAGE_PAPER_TEMPLATE1, ""));
return;
if (item.getContent().indexOf(PERSONAL_STAGE_PAPER_TEMPLATE) > -1 ||
item.getContent().indexOf(PERSONAL_STAGE_PAPER_TEMPLATE1) > -1) {//包含链接
if (null == paperId) {
item.setContent(item.getContent().replace(PERSONAL_STAGE_PAPER_TEMPLATE, ""));
item.setContent(item.getContent().replace(PERSONAL_STAGE_PAPER_TEMPLATE1, ""));
return;
}
String longUrl = wechatLinkPrefix.concat(PERSONAL_STAGE_PAPER).concat(paperId.toString()).concat("&wxId=" + userWxId + "&robotWxId=" + robotId);
//由于前端给的替换符中的“&”可能会是“&amp;”,所以两种替换符都要换掉
String shortLink = UrlUtils.getShortUrl4Own(longUrl);
item.setContent(item.getContent().replace(PERSONAL_STAGE_PAPER_TEMPLATE, shortLink));
item.setContent(item.getContent().replace(PERSONAL_STAGE_PAPER_TEMPLATE1, shortLink));
//添加需求单延迟发送队列
personalStageJumpBiz.addPaperDelay(userWxId, robotId, ip, paperId);
}
String longUrl = wechatLinkPrefix.concat(PERSONAL_STAGE_PAPER).concat(paperId.toString()).concat("&wxId=" + userWxId + "&robotWxId=" + robotId);
//由于前端给的替换符中的“&”可能会是“&amp;”,所以两种替换符都要换掉
String shortLink = UrlUtils.getShortUrl4Own(longUrl);
item.setContent(item.getContent().replace(PERSONAL_STAGE_PAPER_TEMPLATE, shortLink));
item.setContent(item.getContent().replace(PERSONAL_STAGE_PAPER_TEMPLATE1, shortLink));
}
}
}
......@@ -765,7 +770,7 @@ public class PersonalStageBizImpl implements PersonalStageBiz {
if (ListUtils.isEmpty(items)){
return;
}
this.replacePaperUrl(items, robotId, userWxId, paperId);
this.replacePaperUrl(items, robotId, userWxId, paperId,ip);
sendReplyItems(items,robotId,userWxId,ip,personalStageUserId);
}
......@@ -775,7 +780,7 @@ public class PersonalStageBizImpl implements PersonalStageBiz {
Integer type=item.getReplyType();
if (ReplyTypeEnum.TEXT.value.equals(type)) {
SendTextMessageVO sendTextMessageVO = new SendTextMessageVO();
sendTextMessageVO.setContent(replaceProjectProgressUrl(item.getContent(),robotId,userWxId,personalStageUserId));
sendTextMessageVO.setContent(replaceProjectProgressUrl(item.getContent(),robotId,userWxId,personalStageUserId,ip));
sendTextMessageVO.setAltId(robotId);
sendTextMessageVO.setWxGroupId(userWxId);
sendTextMessageVO.setIp(ip);
......
......@@ -56,11 +56,22 @@ public class PersonalStageProgressMessageBizImpl implements PersonalStageProgres
if(ListUtils.isEmpty(personalStageProgressMessage)){
throw BizException.PARAM_IS_NULL;
}
for(int i = personalStageProgressMessage.size()-1; i>=0; i--){
if(personalStageProgressMessage.get(i).getType() == 2 && StringUtil.isEmpty(personalStageProgressMessage.get(i).getContent())){
personalStageProgressMessage.remove(i);
}
}
if(personalStageProgressMessage.stream().filter(x-> StringUtil.isEmpty(x.getContent())).count() > 0){
throw BizException.PARAM_IS_NULL;
}
// 删除所有旧数据
personalStageProgressMessageDao.deleteAll();
personalStageProgressMessage.stream().forEach(x->{
if(x.getType() == null || x.getType() == 0){
x.setType(1);
}
});
// 重新插入
return personalStageProgressMessageDao.insert(personalStageProgressMessage);
}
......
......@@ -17,6 +17,13 @@ public class PersonalStageConstant {
public static final String PERSONAL_STAGE_SEND_TIME = "PERSONAL_STAGE_SEND_TIME";
/**
* 进度单未点链接延迟
*/
public static final String PERSONALSTAGE_DELAY_PROGRESS="PERSONALSTAGE_DELAY_PROGRESS";
/**
* 需求定制单延迟
*/
public static final String PERSONALSTAGE_DELAY_PAPER="PERSONALSTAGE_DELAY_PAPER";
}
......@@ -27,4 +27,6 @@ public interface PersonalStageProgressMessageDao extends BaseDao<PersonalStagePr
* @return
*/
Integer countProgressMessage();
PersonalStageProgressMessage getWaitClickProgress();
}
\ No newline at end of file
......@@ -41,4 +41,9 @@ public class PersonalStageProgressMessageDaoImpl extends BaseDaoImpl<PersonalSta
public Integer countProgressMessage() {
return super.sqlSessionTemplate.selectOne(getStatement("countProgressMessage"));
}
@Override
public PersonalStageProgressMessage getWaitClickProgress() {
return getSessionTemplate().selectOne(getStatement("getWaitClickProgress"));
}
}
\ No newline at end of file
package com.pcloud.book.personalstage.dto;
import com.pcloud.common.dto.BaseDto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel("点链接dto")
public class LinkClickRecordDTO extends BaseDto {
@ApiModelProperty("链接类型(1进度单2需求单)")
private Integer linkType;
@ApiModelProperty("机器人id")
private String robotId;
@ApiModelProperty("用户wxId")
private String wxId;
@ApiModelProperty("需求定制单id")
private Long paperId;
}
package com.pcloud.book.personalstage.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
@Data
@ApiModel("需求定制单未点链接延时dto")
public class PaperDelayDTO implements Serializable {
@ApiModelProperty("定制化阶段id")
private Long personalStageId;
@ApiModelProperty("机器人id")
private String robotId;
@ApiModelProperty("用户wxId")
private String wxId;
@ApiModelProperty("ip地址")
private String ip;
@ApiModelProperty("需求单id")
private Long paperId;
}
package com.pcloud.book.personalstage.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
@Data
@ApiModel("进度单未点链接延时dto")
public class ProgressDelayDTO implements Serializable {
@ApiModelProperty("定制化阶段id")
private Long personalStageId;
@ApiModelProperty("机器人id")
private String robotId;
@ApiModelProperty("用户wxId")
private String wxId;
@ApiModelProperty("ip地址")
private String ip;
}
......@@ -32,4 +32,6 @@ public class PersonalStageProgressMessage extends BaseEntity {
* 状态(0-未完成,1-已完成)
*/
private Integer state;
private Integer type;
}
\ No newline at end of file
......@@ -2,6 +2,7 @@ package com.pcloud.book.personalstage.facade;
import com.pcloud.book.personalstage.biz.PersonalStageBiz;
import com.pcloud.book.personalstage.biz.PersonalStageProgressMessageBiz;
import com.pcloud.book.personalstage.dto.LinkClickRecordDTO;
import com.pcloud.book.personalstage.dto.PersonalStageProgressDTO;
import com.pcloud.book.personalstage.entity.PersonalStage;
import com.pcloud.book.personalstage.entity.PersonalStageProgressMessage;
......@@ -253,4 +254,17 @@ public class PersonalStageFacade {
return new ResponseDto<>(map);
}
@ApiOperation("保存进度单/需求单链接点击记录")
@PostMapping("addLinkClickRecord")
public ResponseDto<?> addLinkClickRecord(@RequestBody @ApiParam("链接点击记录") LinkClickRecordDTO linkClickRecordDTO){
if (null == linkClickRecordDTO || StringUtil.isEmpty(linkClickRecordDTO.getRobotId()) || StringUtil.isEmpty(linkClickRecordDTO.getWxId())
||null==linkClickRecordDTO.getLinkType()){
throw new BookBizException(BookBizException.PARAM_IS_NULL,"参数缺失");
}
if (linkClickRecordDTO.getLinkType()==2&&null==linkClickRecordDTO.getPaperId()){
throw new BookBizException(BookBizException.PARAM_IS_NULL,"缺失需求单id");
}
personalStageJumpBiz.addLinkClickRecord(linkClickRecordDTO);
return new ResponseDto<>();
}
}
......@@ -6,12 +6,13 @@
<id column="id" property="id" jdbcType="BIGINT"/>
<result column="content" property="content" jdbcType="VARCHAR"/>
<result column="minutes" property="minutes" jdbcType="INTEGER"/>
<result column="type" property="type" jdbcType="INTEGER"/>
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id, content, minutes, create_time, update_time
id, content, minutes, type, create_time, update_time
</sql>
<select id="getById" resultMap="BaseResultMap">
......@@ -25,17 +26,20 @@
SELECT
<include refid="Base_Column_List"/>
FROM personal_stage_progress_message
ORDER BY type
</select>
<insert id="insert" keyProperty="id" useGeneratedKeys="true">
INSERT INTO personal_stage_progress_message(
content,
minutes,
minutes,
type,
create_time,
update_time
) VALUES (
#{content, jdbcType=VARCHAR},
#{minutes, jdbcType=INTEGER},
#{type, jdbcType=INTEGER},
NOW(),
NOW()
)
......@@ -44,7 +48,8 @@
<insert id="batchInsert" keyProperty="id" useGeneratedKeys="true">
INSERT INTO personal_stage_progress_message (
content,
minutes,
minutes,
type,
create_time,
update_time
) VALUES
......@@ -52,6 +57,7 @@
(
#{item.content, jdbcType=VARCHAR},
#{item.minutes, jdbcType=INTEGER},
#{item.type, jdbcType=INTEGER},
NOW(),
NOW()
)
......@@ -68,6 +74,9 @@
<if test="minutes != null">
minutes = #{minutes},
</if>
<if test="type != null">
type = #{type},
</if>
<if test="createTime != null">
create_time = #{createTime},
</if>
......@@ -91,14 +100,25 @@
select
id,
content,
minutes
minutes,
type
from
personal_stage_progress_message
where
TIMESTAMPDIFF(MINUTE,#{startTime}, now()) &gt;= minutes
and type = 1
order by id asc
</select>
<select id="getWaitClickProgress" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from
personal_stage_progress_message
where type = 2
limit 1
</select>
<select id="selectAllProgressMessage" resultType="com.pcloud.book.personalstage.entity.PersonalStageProgressMessage">
select
id,
......
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