Commit bfe78449 by 徐高华

每分钟取消超时定时任务

parent dc9f2636
......@@ -79,4 +79,12 @@ public interface QwMomentApiService {
*/
ServiceResponse<Void> qwDataTimer(String params) ;
/**
* 每分钟取消超时定时任务
* @param params
* @return
*/
ServiceResponse<Void> cancelTimeOutTimer(String params) ;
}
......@@ -40,4 +40,8 @@ public interface QwMomentPlanMapper {
List<Long> listForData(@Param("type")int type);
List<TabQwMomentPlan> listForStop(@Param("time")Date time);
List<TabQwMomentPlan> cancelTimeOutTimer(@Param("time")Date end);
void updateCancelFlag(@Param("planIdList") List<Long> planIdList) ;
}
......@@ -54,4 +54,6 @@ public interface QwMomentPlanService {
void qwDataTimer(String params);
void sendRetry(Long qwPlanId);
void cancelTimeOutTimer(String params);
}
......@@ -706,23 +706,12 @@ public class QwMomentPlanServiceImpl implements QwMomentPlanService {
}
}
}
// 到期停止
if(params.equals("3")) {
Date end = DateUtil.addDay(new Date(),-1) ;
end = DateUtil.getEndTimeOfDay(end) ;
List<TabQwMomentPlan> planList = this.qwMomentPlanMapper.listForStop(end) ;
if(CollectionUtils.isNotEmpty(planList)) {
for(TabQwMomentPlan plan : planList) {
String wxEnterpriseId = plan.getWxEnterpriseId() ;
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId) ;
logger.info("取消发送={},{}",plan.getPlanId(),plan.getMomentId());
if(StringUtils.isNotBlank(plan.getMomentId())) {
this.qywxExternalUserService.cancelMomentTask(qwDTO.getThirdCorpid(),
qwDTO.getSelf3thSecret(), plan.getMomentId(), qwDTO.isSelf(), qwDTO.getUrlHost());
}
}
}
this.cancel(planList);
}
}
......@@ -732,4 +721,28 @@ public class QwMomentPlanServiceImpl implements QwMomentPlanService {
TabQwMomentPlan plan = this.qwMomentPlanMapper.getById(qwPlanId) ;
this.sendToQiwei(plan);
}
@Override
public void cancelTimeOutTimer(String params) {
logger.info("朋友圈-取消超时-{}",params);
Date end = new Date() ;
List<TabQwMomentPlan> planList = this.qwMomentPlanMapper.cancelTimeOutTimer(end) ;
this.cancel(planList);
}
private void cancel(List<TabQwMomentPlan> planList) {
if(CollectionUtils.isNotEmpty(planList)) {
this.qwMomentPlanMapper.updateCancelFlag(planList.stream().map(TabQwMomentPlan::getPlanId).collect(Collectors.toList()));
for(TabQwMomentPlan plan : planList) {
String wxEnterpriseId = plan.getWxEnterpriseId() ;
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId) ;
logger.info("取消发送={},{}",plan.getPlanId(),plan.getMomentId());
if(StringUtils.isNotBlank(plan.getMomentId())) {
this.qywxExternalUserService.cancelMomentTask(qwDTO.getThirdCorpid(),
qwDTO.getSelf3thSecret(), plan.getMomentId(), qwDTO.isSelf(), qwDTO.getUrlHost());
}
}
}
}
}
......@@ -95,4 +95,10 @@ public class QwMomentApiServiceImpl implements QwMomentApiService {
this.qwMomentPlanService.qwDataTimer(params) ;
return null;
}
@Override
public ServiceResponse<Void> cancelTimeOutTimer(String params) {
this.qwMomentPlanService.cancelTimeOutTimer(params) ;
return null;
}
}
......@@ -275,6 +275,10 @@
select <include refid="Base_Column_List" /> from tab_haoban_qw_moment_plan where end_date =#{time} and delete_flag =0 and status_flag = 1 and exec_type = 0
</select>
<select id="cancelTimeOutTimer" resultMap="result-map-tabHaobanQwMomentPlan">
select <include refid="Base_Column_List" /> from tab_haoban_qw_moment_plan where end_date <![CDATA[ <= ]]> #{time} and delete_flag =0 and status_flag = 1 and exec_type = 0 and cancel_time_flag = 0
</select>
<update id="del" parameterType="java.lang.Long">
update tab_haoban_qw_moment_plan set delete_flag = 1 where plan_id = #{planId}
</update>
......@@ -309,4 +313,11 @@
<update id="updateQwData">
update tab_haoban_qw_moment_plan set total_like_count = #{like} , total_comment_count = #{comment} where plan_id = #{planId}
</update>
<update id="updateCancelFlag">
update tab_haoban_qw_moment_plan set cancel_time_flag = 1 where plan_id in
<foreach collection="planIdList" item="item" separator="," open="(" close=")" index="index">
#{item}
</foreach>
</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