From e0e4e6fca9e6c3ea7f86a2d9e0bc3a5337f62e78 Mon Sep 17 00:00:00 2001 From: 潘志宝 <979469083@qq.com> Date: 星期二, 01 四月 2025 22:42:29 +0800 Subject: [PATCH] runScheduleDayFirstTask每天最初时刻执行 --- shasteel-biz/src/main/java/com/iailab/module/shasteel/job/task/RunScheduleDayFirstTask.java | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 54 insertions(+), 0 deletions(-) diff --git a/shasteel-biz/src/main/java/com/iailab/module/shasteel/job/task/RunScheduleDayFirstTask.java b/shasteel-biz/src/main/java/com/iailab/module/shasteel/job/task/RunScheduleDayFirstTask.java new file mode 100644 index 0000000..f80891d --- /dev/null +++ b/shasteel-biz/src/main/java/com/iailab/module/shasteel/job/task/RunScheduleDayFirstTask.java @@ -0,0 +1,54 @@ +package com.iailab.module.shasteel.job.task; + +import com.iailab.module.model.api.mdk.MdkApi; +import com.iailab.module.model.api.mdk.dto.MdkScheduleReqDTO; +import com.iailab.module.model.api.mdk.dto.MdkScheduleRespDTO; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.Calendar; + +/** + * 每天最初时刻执行 + * + * @author PanZhibao + * @Description + * @createTime 2025年04月01日 + */ +@Component("runScheduleDayFirstTask") +public class RunScheduleDayFirstTask implements ITask { + private Logger logger = LoggerFactory.getLogger(getClass()); + + @Autowired + private MdkApi mdkApi; + + @Override + public void run(String params) { + logger.info("RunScheduleDayFirstTask定时任务正在执行,参数为:{}",params ); + try { + Calendar calendar = Calendar.getInstance(); + calendar.set(Calendar.MILLISECOND,0); + calendar.set(Calendar.SECOND,0); + calendar.set(Calendar.MINUTE,0); + + MdkScheduleReqDTO dto = new MdkScheduleReqDTO(); + dto.setScheduleTime(calendar.getTime()); + dto.setScheduleCode(params); + MdkScheduleRespDTO mdkScheduleRespDTO = mdkApi.doSchedule(dto); + logger.info(params + "调度方案执行完成," + mdkScheduleRespDTO); + logger.info("调度方案结果开始下发"); + if (mdkApi.scheduleModelOut(mdkScheduleRespDTO)) { + logger.info("调度方案结果下发成功"); + }else { + logger.error("调度方案结果下发失败"); + } + + } catch (Exception ex) { + logger.error("RunScheduleDayFirstTask运行异常"); + ex.printStackTrace(); + } + logger.info("RunScheduleDayFirstTask运行完成"); + } +} \ No newline at end of file -- Gitblit v1.9.3