Commit a27ca066 authored by zhangwanglin's avatar zhangwanglin

定时任务补发

parent 34a023c7
......@@ -2,8 +2,6 @@ package com.hungraim.ltc.governance.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hungraim.ltc.governance.service.SrvTaskService;
import com.hungraim.ltc.pojo.vo.account.SrvTaskReqVO;
import com.hungraim.ltc.pojo.vo.account.SrvTaskRespVO;
import com.hungraim.ltc.pojo.vo.governance.*;
import com.hungraim.ltc.util.Result;
import com.hungraim.ltc.util.ResultCode;
......@@ -11,7 +9,6 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.*;
import java.util.Date;
......@@ -149,8 +146,12 @@ public class SrvTaskController {
* 根据计划开始时间每天执行当天计划
**/
@GetMapping("timeAllocationSrvTask")
public void timeAllocationSrvTask() {
srvTaskService.timeAllocationSrvTask();
public Result timeAllocationSrvTask(String dateStr) {
if (StringUtils.isEmpty(dateStr)) {
return Result.failed(ResultCode.REQUEST_PARAM_ERROR);
}
srvTaskService.timeAllocationSrvTask(dateStr);
return Result.success();
}
}
package com.hungraim.ltc.governance.controller;
import com.hungraim.ltc.governance.service.SrvTaskService;
import com.hungraim.ltc.util.DateUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableAsync;
......@@ -24,7 +25,8 @@ public class SrvTaskScheduledController {
@Scheduled(cron = "0 50 20 * * ?")
public void timeAllocationSrvTask() {
log.info("timeAllocationSrvTask========start");
srvTaskService.timeAllocationSrvTask();
String nextDay = DateUtils.getNextDay();
srvTaskService.timeAllocationSrvTask(nextDay);
log.info("timeAllocationSrvTask========end:{}");
}
......
......@@ -33,6 +33,6 @@ public interface SrvTaskService {
void addOrUpdateSrvTask(SrvTaskInfoListVO param);
void timeAllocationSrvTask();
void timeAllocationSrvTask(String dateStr);
}
......@@ -23,11 +23,9 @@ import com.hungraim.ltc.util.AttachType;
import com.hungraim.ltc.util.DateUtils;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
......@@ -211,7 +209,7 @@ public class SrvTaskServiceImpl implements SrvTaskService {
@Override
public void timeAllocationSrvTask() {
public void timeAllocationSrvTask(String dateStr) {
List<ChSrvProgram> programEndProgram = chSrvProgramMapper.getProgramEndProgram();
if (CollectionUtil.isNotEmpty(programEndProgram)) {
for (ChSrvProgram chSrvProgram : programEndProgram) {
......@@ -227,28 +225,28 @@ public class SrvTaskServiceImpl implements SrvTaskService {
chSrvSendMapper.updateSrvSendInfo(disabInfoId);
}
}
// 查询需要执行的计划
List<AllocationSrvTaskVO> chSrvTasks = srvTaskMapper.getAllocationSrvTask();
// 生成计划任务 CH_SRV_TASK_DETAIL
for (AllocationSrvTaskVO chSrvTask : chSrvTasks) {
Long srvTaskId = chSrvTask.getSrvTaskId();
String nextDay = DateUtils.getNextDay();
// 根据任务id和服务时间查询是否已经生成过计划,已经生成了就不需要再生成了,已退出
int chSrvTaskDetailCount = chSrvTaskDetailMapper
.getSrvTaskDetail(String.valueOf(srvTaskId), nextDay);
.getSrvTaskDetail(String.valueOf(srvTaskId), dateStr);
if (chSrvTaskDetailCount > 0) {
log.info("{},已经有计划任务了",nextDay);
return;
log.info("{},已经有计划任务了",dateStr);
continue;
}
ChSrvTaskDetail chSrvTaskDetail = new ChSrvTaskDetail();
chSrvTaskDetail.setSrvTaskId(srvTaskId);//taskId
chSrvTaskDetail.setSrvDate(DateUtils.strToDate(nextDay));//服务开始时间
chSrvTaskDetail.setSrvDate(DateUtils.strToDate(dateStr));//服务开始时间
chSrvTaskDetail.setStatus((short) 0);//状态 未执行:0;执行中:1;已执行:2;已失效:3已完成4
chSrvTaskDetailMapper.insert(chSrvTaskDetail);
// ch_srv_plan
String programId = chSrvTask.getProgramId();
saveSrvPlan(programId,nextDay);
saveSrvPlan(programId,dateStr);
}
}
......
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