Commit ceae1218 by 郑永强

【1002440】方案进度展示H5页面平台端设置

parent 4d40144e
......@@ -51,7 +51,7 @@ public interface PersonalStageBiz {
void sendNotKeywordReply(String robotId, String userWxId, String ip, Long personalStageId, Long personalStageUserId);
void sendNotKeywordFusingReply(String robotId, String userWxId, String ip, Long personalStageId);
void sendNotKeywordFusingReply(String robotId, String userWxId, String ip, Long personalStageId,Long personalStageUserId);
void dealDelayFusingFinish(DelayQueueDTO dto);
......
package com.pcloud.book.personalstage.biz;
import com.pcloud.book.personalstage.entity.PersonalStageProgressMessage;
import com.pcloud.common.page.PageBeanNew;
import java.util.List;
/**
* (PersonalStageProgressMessage)表服务接口
*
* @author zyq
* @since 2020-02-25 09:56:00
*/
public interface PersonalStageProgressMessageBiz {
/**
* 通过ID查询单条数据
*
* @param id 主键
* @return 实例对象
*/
PersonalStageProgressMessage getById(Long id);
/**
* 分页查询
*/
List<PersonalStageProgressMessage> getProgressMessageList();
/**
* 新增数据
*
* @param personalStageProgressMessage 实例对象
* @return 主键
*/
Long save(List<PersonalStageProgressMessage> personalStageProgressMessage);
/**
* 通过主键删除数据
*
* @param id 主键
* @return 是否成功
*/
void deleteById(Long id);
}
\ No newline at end of file
......@@ -289,8 +289,19 @@ public class PersonalStageBizImpl implements PersonalStageBiz {
//是关键词且有记录
if (iskeyword){
LOGGER.info("是关键词且有记录");
//调关键词处理逻辑
personalStageJumpBiz.handlePersonalStageJump(userWxId,robotId,content,JumpTypeEnum.READER_TRIGGER);
String key = "PERSONAL_STAGE_JUMP_KEYWORD_LOCK".concat(userWxId).concat(robotId);
try {
// 加锁,一条一条数据进行处理
while (!CacheUtils.lock(key)) {
Thread.sleep(100);
}
//调关键词处理逻辑
personalStageJumpBiz.handlePersonalStageJump(userWxId,robotId,content,JumpTypeEnum.READER_TRIGGER);
} catch (Exception e){
LOGGER.info("缓存加锁失败,userWxId=" + userWxId +" robotId="+robotId);
} finally {
CacheUtils.unlock(key);
}
}
//不是关键词且有记录
if (!iskeyword&&hasRecord){
......@@ -432,7 +443,7 @@ public class PersonalStageBizImpl implements PersonalStageBiz {
String robotId=wakeupDelayDTO.getRobotId();
String userWxId=wakeupDelayDTO.getWxId();
String ip=wakeupDelayDTO.getIp();
sendReplyItems(replyItems,robotId,userWxId,ip);
sendReplyItems(replyItems,robotId,userWxId,ip,wakeupDelayDTO.getPersonalStageUserId());
//下一个延时
List<PersonalStageWakeup> wakeups = personalStageWakeupDao.getListByPersonalStageId(personalStageId);
int i=0;
......@@ -453,6 +464,7 @@ public class PersonalStageBizImpl implements PersonalStageBiz {
wakeupDelayDTONew.setWxId(userWxId);
wakeupDelayDTONew.setIp(ip);
wakeupDelayDTONew.setPersonalStageId(personalStageId);
wakeupDelayDTONew.setPersonalStageUserId(wakeupDelayDTO.getPersonalStageUserId());
DelayQueueDTO delayQueueDTONew = DelayQueueDTO.builder().key(userWxId).type(PersonalStageConstant.PERSONALSTAGE_DELAY_WAKEUP).msg(wakeupDelayDTONew).timeout(time).build();
delayMessageSender.send(delayQueueDTONew);
LOGGER.info("下一个延时发送delayQueueDTONew="+delayQueueDTONew.toString());
......@@ -494,6 +506,7 @@ public class PersonalStageBizImpl implements PersonalStageBiz {
wakeupDelayDTO.setWxId(userWxId);
wakeupDelayDTO.setIp(ip);
wakeupDelayDTO.setPersonalStageId(personalStageId);
wakeupDelayDTO.setPersonalStageUserId(personalStageUser.getId());
DelayQueueDTO delayQueueDTO = DelayQueueDTO.builder().key(userWxId).type(PersonalStageConstant.PERSONALSTAGE_DELAY_WAKEUP).msg(wakeupDelayDTO).timeout(toStageStartTime*60*1000).build();
delayMessageSender.send(delayQueueDTO);
}
......@@ -511,9 +524,7 @@ public class PersonalStageBizImpl implements PersonalStageBiz {
if (ListUtils.isEmpty(items)){
return;
}
// 替换进度链接
replaceProjectProgressUrl(items,robotId,userWxId,personalStageUserId);
sendReplyItems(items,robotId,userWxId,ip);
sendReplyItems(items,robotId,userWxId,ip,personalStageUserId);
}
@ParamLog("尝试插入单号")
......@@ -541,7 +552,7 @@ public class PersonalStageBizImpl implements PersonalStageBiz {
@ParamLog("非关键词熔断回复")
@Override
public void sendNotKeywordFusingReply(String robotId, String userWxId, String ip, Long personalStageId) {
public void sendNotKeywordFusingReply(String robotId, String userWxId, String ip, Long personalStageId, Long personalStageUserId) {
List<Long> ids = personalStageReplyDao.getIdsByRelevance(StageReplyRelevEnum.FUSING_NOT_KEYWORD.value, personalStageId);
if (ListUtils.isEmpty(ids)) {
return;
......@@ -552,11 +563,13 @@ public class PersonalStageBizImpl implements PersonalStageBiz {
if (ListUtils.isEmpty(items)){
return;
}
sendReplyItems(items,robotId,userWxId,ip);
sendReplyItems(items,robotId,userWxId,ip,personalStageUserId);
}
@ParamLog("发送回复")
private void sendReplyItems(List<PersonalStageReplyItem> replyItems,String robotId, String userWxId, String ip){
private void sendReplyItems(List<PersonalStageReplyItem> replyItems,String robotId, String userWxId, String ip,Long personalStageUserId){
// 替换进度链接
replaceProjectProgressUrl(replyItems,robotId,userWxId,personalStageUserId);
for (PersonalStageReplyItem item:replyItems){
Integer type=item.getReplyType();
if (ReplyTypeEnum.TEXT.value.equals(type)) {
......@@ -604,7 +617,7 @@ public class PersonalStageBizImpl implements PersonalStageBiz {
if (!JedisClusterUtils.exists(key)) {
// 发送熔断回复消息
JedisClusterUtils.set(key, "true", 60);
sendNotKeywordFusingReply(robotId, userWxId, ip, personalStage.getId());
sendNotKeywordFusingReply(robotId, userWxId, ip, personalStage.getId(), last.getId());
}
}
......
......@@ -54,6 +54,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
......@@ -298,7 +299,7 @@ public class PersonalStageJumpBizImpl implements PersonalStageJumpBiz {
*/
@Override
@ParamLog("处理用户阶段跳转逻辑")
@Transactional(rollbackFor = Exception.class)
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRES_NEW)
public Boolean handlePersonalStageJump(String userWxId, String robotWxId, String content, JumpTypeEnum jumpTypeEnum) {
// 查询用户的当前状态信息
PersonalStageUser currentStageUser = personalStageUserDao.getLast(userWxId, robotWxId, null);
......
package com.pcloud.book.personalstage.biz.impl;
import com.google.common.collect.Lists;
import com.pcloud.book.personalstage.entity.PersonalStageProgressMessage;
import com.pcloud.book.personalstage.dao.PersonalStageProgressMessageDao;
import com.pcloud.book.personalstage.biz.PersonalStageProgressMessageBiz;
import com.pcloud.common.core.aspect.ParamLog;
import com.pcloud.common.page.PageBeanNew;
import com.pcloud.common.page.PageParam;
import com.pcloud.common.exceptions.BizException;
import com.pcloud.common.utils.ListUtils;
import com.pcloud.common.utils.NumberUtil;
import com.pcloud.common.utils.string.StringUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/**
* (PersonalStageProgressMessage)表服务实现类
*
* @author zyq
* @since 2020-02-25 09:56:00
*/
@Service("personalStageProgressMessageBiz")
public class PersonalStageProgressMessageBizImpl implements PersonalStageProgressMessageBiz {
private static final Logger LOGGER = LoggerFactory.getLogger(PersonalStageProgressMessageBizImpl.class);
@Autowired
private PersonalStageProgressMessageDao personalStageProgressMessageDao;
@Override
@ParamLog("通过ID查询单条数据")
public PersonalStageProgressMessage getById(Long id) {
return personalStageProgressMessageDao.getById(id);
}
@Override
@ParamLog("查询多条数据")
public List<PersonalStageProgressMessage> getProgressMessageList() {
List<PersonalStageProgressMessage> progressMessageList = personalStageProgressMessageDao.getProgressMessageList();
if (ListUtils.isEmpty(progressMessageList)){
return Lists.newArrayList();
}
return progressMessageList;
}
@Override
@ParamLog("保存")
@Transactional(rollbackFor = Exception.class)
public Long save(List<PersonalStageProgressMessage> personalStageProgressMessage) {
if(ListUtils.isEmpty(personalStageProgressMessage)){
throw BizException.PARAM_IS_NULL;
}
if(personalStageProgressMessage.stream().filter(x-> StringUtil.isEmpty(x.getContent())).count() > 0){
throw BizException.PARAM_IS_NULL;
}
// 删除所有旧数据
personalStageProgressMessageDao.deleteAll();
// 重新插入
return personalStageProgressMessageDao.insert(personalStageProgressMessage);
}
@Override
@ParamLog("删除")
public void deleteById(Long id) {
personalStageProgressMessageDao.deleteById(id);
}
}
\ No newline at end of file
......@@ -15,4 +15,8 @@ import java.util.List;
public interface PersonalStageProgressMessageDao extends BaseDao<PersonalStageProgressMessage> {
List<PersonalStageProgressMessage> getPersonalProgress(Date startTime);
List<PersonalStageProgressMessage> getProgressMessageList();
void deleteAll();
}
\ No newline at end of file
......@@ -22,4 +22,14 @@ public class PersonalStageProgressMessageDaoImpl extends BaseDaoImpl<PersonalSta
public List<PersonalStageProgressMessage> getPersonalProgress(Date startTime) {
return getSessionTemplate().selectList(getStatement("getPersonalProgress"),startTime);
}
@Override
public List<PersonalStageProgressMessage> getProgressMessageList() {
return getSessionTemplate().selectList(getStatement("getProgressMessageList"));
}
@Override
public void deleteAll() {
super.getSessionTemplate().delete(getStatement("deleteAll"));
}
}
\ No newline at end of file
......@@ -34,6 +34,9 @@ public class PersonalStageDTO extends BaseDto {
@ApiModelProperty("排序值")
private Integer seqNum;
@ApiModelProperty("显示进度链接")
private Integer showProgress;
@ApiModelProperty("非关键词回复条数")
private Integer notKeywordReplyCount;
......
......@@ -20,4 +20,6 @@ public class WakeupDelayDTO implements Serializable {
private String wxId;
@ApiModelProperty("ip地址")
private String ip;
@ApiModelProperty("用户阶段记录id")
private Long personalStageUserId;
}
......@@ -27,6 +27,9 @@ public class PersonalStage extends BaseEntity {
@ApiModelProperty("排序值")
private Integer seqNum;
@ApiModelProperty("显示进度链接")
private Integer showProgress;
@ApiModelProperty("阶段非关键词回复集合")
private List<PersonalStageReply> stageNotKeywordReplies;
......
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.PersonalStageProgressDTO;
import com.pcloud.book.personalstage.entity.PersonalStage;
import com.pcloud.book.personalstage.entity.PersonalStageProgressMessage;
......@@ -29,6 +30,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Optional;
@Api("定制化阶段")
......@@ -40,6 +42,8 @@ public class PersonalStageFacade {
private PersonalStageBiz personalStageBiz;
@Autowired
private PersonalStageJumpBiz personalStageJumpBiz;
@Autowired
private PersonalStageProgressMessageBiz personalStageProgressMessageBiz;
@ApiOperation("新增定制化阶段")
@PostMapping("/createPersonalStage")
......@@ -194,4 +198,18 @@ public class PersonalStageFacade {
return new ResponseDto<>(personalStageProgressDTO);
}
@ApiOperation("查询所有的进度消息")
@GetMapping("getProgressMessageList")
public ResponseDto<?> getProgressMessageList()
throws BizException, PermissionException {
return new ResponseDto<>(personalStageProgressMessageBiz.getProgressMessageList());
}
@ApiOperation("保存进度消息")
@PostMapping("saveProgressMessage")
public ResponseDto<?> saveProgressMessage(@RequestBody List<PersonalStageProgressMessage> personalStageProgressMessage)
throws BizException, PermissionException {
return new ResponseDto<>(personalStageProgressMessageBiz.save(personalStageProgressMessage));
}
}
......@@ -9,11 +9,12 @@
<result property="notKeywordFusingTime" column="not_keyword_fusing_time" jdbcType="BIGINT"/>
<result property="robotClassifyId" column="robot_classify_id" jdbcType="BIGINT"/>
<result property="seqNum" column="seq_num" jdbcType="INTEGER"/>
<result property="showProgress" column="show_progress" jdbcType="INTEGER"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id, name, not_keyword_fusing_count, not_keyword_fusing_time, robot_classify_id, seq_num, create_time
id, name, not_keyword_fusing_count, not_keyword_fusing_time, robot_classify_id, seq_num, show_progress, create_time
</sql>
<select id="getById" resultMap="BaseResultMap" parameterType="java.lang.Long">
......@@ -36,6 +37,7 @@
not_keyword_fusing_time,
robot_classify_id,
seq_num,
show_progress,
create_time
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
......@@ -44,6 +46,7 @@
#{notKeywordFusingTime,jdbcType=BIGINT},
#{robotClassifyId,jdbcType=BIGINT},
#{seqNum,jdbcType=INTEGER},
#{showProgress,jdbcType=INTEGER},
NOW()
</trim>
</insert>
......@@ -66,6 +69,9 @@
<if test="seqNum != null">
seq_num = #{seqNum,jdbcType=INTEGER},
</if>
<if test="showProgress != null">
show_progress = #{showProgress,jdbcType=INTEGER},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
......
......@@ -3,7 +3,7 @@
<mapper namespace="com.pcloud.book.personalstage.dao.impl.PersonalStageProgressMessageDaoImpl">
<resultMap id="BaseResultMap" type="com.pcloud.book.personalstage.entity.PersonalStageProgressMessage">
<id column="id" property="id" jdbcType="INTEGER"/>
<id column="id" property="id" jdbcType="BIGINT"/>
<result column="content" property="content" jdbcType="VARCHAR"/>
<result column="minutes" property="minutes" jdbcType="INTEGER"/>
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
......@@ -21,7 +21,7 @@
WHERE id = #{id}
</select>
<select id="getList" resultMap="BaseResultMap">
<select id="getProgressMessageList" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List"/>
FROM personal_stage_progress_message
......@@ -36,8 +36,8 @@
) VALUES (
#{content, jdbcType=VARCHAR},
#{minutes, jdbcType=INTEGER},
#{createTime, jdbcType=TIMESTAMP},
#{updateTime, jdbcType=TIMESTAMP}
NOW(),
NOW()
)
</insert>
......@@ -50,10 +50,10 @@
) VALUES
<foreach collection="list" item="item" separator=",">
(
#{content, jdbcType=VARCHAR},
#{minutes, jdbcType=INTEGER},
#{createTime, jdbcType=TIMESTAMP},
#{updateTime, jdbcType=TIMESTAMP}
#{item.content, jdbcType=VARCHAR},
#{item.minutes, jdbcType=INTEGER},
NOW(),
NOW()
)
</foreach>
</insert>
......@@ -83,6 +83,10 @@
DELETE FROM personal_stage_progress_message where id = #{id}
</delete>
<delete id="deleteAll">
DELETE FROM personal_stage_progress_message
</delete>
<select id="getPersonalProgress" parameterType="date" 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