定时任务逻辑调整

This commit is contained in:
zhangchenbiao
2023-08-22 15:03:01 +08:00
parent 8946e73112
commit 47627a1945
5 changed files with 40 additions and 18 deletions

View File

@@ -178,11 +178,12 @@ public class HyFollowTaskDAO {
* @param followUserIds
* @return
*/
public List<FollowTaskNumDTO> getUserTaskNum(List<String> followUserIds){
if(CollectionUtils.isEmpty(followUserIds)){
public List<FollowTaskNumDTO> getUserTaskNum(List<String> followUserIds, Date date){
if(CollectionUtils.isEmpty(followUserIds) || Objects.isNull(date)){
return Lists.newArrayList();
}
return hyFollowTaskMapper.getUserTaskNum(followUserIds);
String endTime = DateUtil.format(date, CoolDateUtils.DATE_FORMAT_DAY) + CommonConstants.DAY_END_TIME_SUFFIX;
return hyFollowTaskMapper.getUserTaskNum(followUserIds, endTime);
}
/**

View File

@@ -78,7 +78,7 @@ public interface HyFollowTaskMapper {
* @param followUserIds
* @return
*/
List<FollowTaskNumDTO> getUserTaskNum(@Param("followUserIds") List<String> followUserIds);
List<FollowTaskNumDTO> getUserTaskNum(@Param("followUserIds") List<String> followUserIds, @Param("endTime")String endTime);
/**
* 获取待完成任务

View File

@@ -191,32 +191,46 @@
<select id="getRemindFollowUserIds" resultType="string">
select
follow_user_id
a.follow_user_id
from
hy_follow_task
hy_follow_task a
inner join hy_partner_line_info b on a.partner_line_id = b.id and b.deleted = '0'
where
deleted = '0' and (task_status in ('2') or (task_status in ('0') and deadline >= #{startTime} and #{endTime} >= deadline))
a.deleted = '0' and (a.task_status in ('2') or (a.task_status in ('0') and a.deadline >= #{startTime} and #{endTime} >= a.deadline))
</select>
<select id="getUserTaskNum" resultType="com.cool.store.dto.follow.FollowTaskNumDTO">
select
follow_user_id,
sum(if(task_status=2 or (task_status in ('0') and now() >= deadline), 1,0)) as overdueNum,
sum(if(task_status=0, 1, 0)) as todoNum
a.follow_user_id,
sum(if(a.task_status=2 or (a.task_status in ('0') and now() >= a.deadline), 1,0)) as overdueNum,
sum(if(a.task_status=0 and #{endTime} > a.deadline, 1, 0)) as todoNum
from
hy_follow_task
hy_follow_task a
inner join hy_partner_line_info b on a.partner_line_id = b.id and b.deleted = '0'
where
follow_user_id in <foreach collection="followUserIds" item="followUserId" separator="," open="(" close=")">#{followUserId}</foreach>
group by follow_user_id
a.follow_user_id in <foreach collection="followUserIds" item="followUserId" separator="," open="(" close=")">#{followUserId}</foreach>
group by a.follow_user_id
</select>
<select id="getUndoTaskPage" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
a.id,
a.partner_line_id,
a.follow_user_id,
a.task_title,
a.communication_type,
a.deadline,
a.communication_content,
a.task_status,
a.finish_time,
a.deleted,
a.create_time,
a.update_time
from
hy_follow_task
hy_follow_task a
inner join hy_partner_line_info b on a.partner_line_id = b.id and b.deleted = '0'
where
deleted = '0' and task_status in ('0') and deadline > #{startTime} and #{endTime} > deadline
a.deleted = '0' and a.task_status in ('0') and a.deadline > #{startTime} and #{endTime} > a.deadline
</select>
<update id="updateUndoTaskStatusToOverdue">

View File

@@ -227,8 +227,9 @@ public class FollowTaskServiceImpl implements FollowTaskService {
//获取已逾期的 以及截止时间为当天的任务 的招商经理
Boolean hasNext = true;
int pageNum = CommonConstants.ONE, pageSize = CommonConstants.HUNDRED;
Date today = new Date();
while (hasNext){
Page<String> remindFollowUserIds = hyFollowTaskDAO.getRemindFollowUserIds(new Date(), pageNum, pageSize);
Page<String> remindFollowUserIds = hyFollowTaskDAO.getRemindFollowUserIds(today, pageNum, pageSize);
if(CollectionUtils.isEmpty(remindFollowUserIds)){
break;
}
@@ -236,7 +237,7 @@ public class FollowTaskServiceImpl implements FollowTaskService {
hasNext = false;
}
pageNum++;
List<FollowTaskNumDTO> followTaskList = hyFollowTaskDAO.getUserTaskNum(remindFollowUserIds);
List<FollowTaskNumDTO> followTaskList = hyFollowTaskDAO.getUserTaskNum(remindFollowUserIds, today);
for (FollowTaskNumDTO followTask : followTaskList) {
noticeService.sendFeiShuNotice(FeiShuNoticeMsgEnum.FOLLOW_TASK, Arrays.asList(followTask.getFollowUserId()), FollowTaskNumDTO.getMessageContent(followTask));
}

View File

@@ -274,4 +274,10 @@ public class TestController {
followTaskService.followTaskDailyRemind();
return ResponseResult.success();
}
@GetMapping("/followTaskAnHourAgoRemind")
public ResponseResult followTaskAnHourAgoRemind() {
followTaskService.followTaskAnHourAgoRemind();
return ResponseResult.success();
}
}