Commit 1ad9cfa2 by 1244575290@qq.com

熔断回复限制

parent 9f635dba
......@@ -775,6 +775,14 @@ public class PersonalStageBizImpl implements PersonalStageBiz {
@ParamLog("非关键词熔断回复")
@Override
public void sendNotKeywordFusingReply(String robotId, String userWxId, String ip, Long personalStageId, Long personalStageUserId, Long paperId) {
PersonalStage personalStage = personalStageDao.getById(personalStageId);
PersonalStageUser personalStageUser = personalStageUserDao.getById(personalStageUserId);
if(personalStage != null && personalStageUser != null) {
Integer notReplyFusingCount = personalStage.getNotReplyFusingCount();
if (notReplyFusingCount != null && personalStageUser.getFusingReplyCount() >= personalStage.getNotReplyFusingCount()) {
return;
}
}
//判断人工客服服务状态
Integer serviceState = wechatGroupConsr.getServiceStateByRobotUser(robotId, userWxId);
if (serviceState == 1){
......@@ -793,6 +801,7 @@ public class PersonalStageBizImpl implements PersonalStageBiz {
}
this.replacePaperUrl(items, robotId, userWxId, paperId,ip);
sendReplyItems(items,robotId,userWxId,ip,personalStageUserId);
personalStageUserDao.updateFusingReplyCount(personalStageUserId);
}
@ParamLog("发送回复")
......@@ -889,6 +898,7 @@ public class PersonalStageBizImpl implements PersonalStageBiz {
user.setId(personalStageUserId);
user.setState(PersonalStageUserStateEnum.NORMAL.value);
user.setNotKeywordSendCount(0);
user.setFusingReplyCount(0);
personalStageUserDao.update(user);
//刪除发送非关键词次数緩存
JedisClusterUtils.del(PersonalStageConstant.USER_SEND_KEYWORD_COUNT_LOCK + personalStageId + "_" + wxId);
......
......@@ -12,4 +12,6 @@ public interface PersonalStageUserDao extends BaseDao<PersonalStageUser> {
void updateRequireNumber(Long personalStageUserId, String requireNumber);
void updateScore(Long id, Integer score);
void updateFusingReplyCount(Long id);
}
\ No newline at end of file
......@@ -44,4 +44,9 @@ public class PersonalStageUserDaoImpl extends BaseDaoImpl<PersonalStageUser> imp
map.put("score", score);
super.getSessionTemplate().update(getStatement("updateScore"), map);
}
@Override
public void updateFusingReplyCount(Long id) {
super.getSessionTemplate().update(getStatement("updateFusingReplyCount"), id);
}
}
......@@ -45,4 +45,7 @@ public class PersonalStage extends BaseEntity {
@ApiModelProperty("回复方式 1 随机,2顺序")
private Integer sendMode;
@ApiModelProperty("熔断回复的次数 将不再回复任何熔断消息")
private Integer notReplyFusingCount;
}
\ No newline at end of file
......@@ -40,4 +40,7 @@ public class PersonalStageUser extends BaseEntity {
@ApiModelProperty("进度开始时间")
private Date progressStartTime;
@ApiModelProperty("熔断回复次数")
private Integer fusingReplyCount;
}
\ No newline at end of file
......@@ -13,10 +13,11 @@
<result property="showProgress" column="show_progress" jdbcType="INTEGER"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="sendMode" column="send_mode" jdbcType="INTEGER"/>
<result property="notReplyFusingCount" column="not_reply_fusing_count" jdbcType="INTEGER"/>
</resultMap>
<sql id="Base_Column_List">
id, name, not_keyword_fusing_count, not_keyword_fusing_time, robot_classify_id, paper_id, seq_num, show_progress, create_time,send_mode
id, name, not_keyword_fusing_count, not_keyword_fusing_time, robot_classify_id, paper_id, seq_num, show_progress, create_time,send_mode,not_reply_fusing_count
</sql>
<select id="getById" resultMap="BaseResultMap" parameterType="java.lang.Long">
......@@ -42,7 +43,8 @@
seq_num,
show_progress,
create_time,
send_mode
send_mode,
not_reply_fusing_count
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
#{name,jdbcType=VARCHAR},
......@@ -53,7 +55,8 @@
#{seqNum,jdbcType=INTEGER},
#{showProgress,jdbcType=INTEGER},
NOW(),
#{sendMode}
#{sendMode},
#{notReplyFusingCount}
</trim>
</insert>
......@@ -82,6 +85,7 @@
<if test="sendMode != null">
send_mode = #{sendMode,jdbcType=INTEGER},
</if>
not_reply_fusing_count = #{notReplyFusingCount,jdbcType=INTEGER},
</set>
where id = #{id,jdbcType=BIGINT}
</update>
......
......@@ -15,10 +15,11 @@
<result property="requireNumber" column="require_number" jdbcType="VARCHAR"/>
<result property="score" column="score" jdbcType="INTEGER"/>
<result property="progressStartTime" column="progress_start_time" jdbcType="TIMESTAMP"/>
<result property="fusingReplyCount" column="fusing_reply_count" jdbcType="INTEGER"/>
</resultMap>
<sql id="Base_Column_List">
id, personal_stage_id, wx_id, robot_id, robot_classify_id, state, not_keyword_send_count, create_time,update_time,require_number,score,progress_start_time
id, personal_stage_id, wx_id, robot_id, robot_classify_id, state, not_keyword_send_count, create_time,update_time,require_number,score,progress_start_time,fusing_reply_count
</sql>
<select id="getById" resultMap="BaseResultMap" parameterType="java.lang.Long">
......@@ -81,6 +82,9 @@
<if test="progressStartTime != null">
progress_start_time = #{progressStartTime},
</if>
<if test="fusingReplyCount != null">
fusing_reply_count = #{fusingReplyCount},
</if>
update_time=now()
</set>
where id = #{id,jdbcType=BIGINT}
......@@ -131,4 +135,9 @@
score = score + #{score} where id = #{id}
</update>
<update id="updateFusingReplyCount" parameterType="java.lang.Long">
update personal_stage_user set
fusing_reply_count = fusing_reply_count + 1 where id = #{id}
</update>
</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