|
|
@@ -0,0 +1,51 @@
|
|
|
+package com.ruoyi.quartz.task;
|
|
|
+
|
|
|
+import com.ruoyi.common.utils.StringUtils;
|
|
|
+import com.ruoyi.project.domain.ProjectTask;
|
|
|
+import com.ruoyi.project.mapper.ProjectTaskMapper;
|
|
|
+import com.ruoyi.project.service.ProjectTaskService;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 定时任务调度测试
|
|
|
+ *
|
|
|
+ * @author ruoyi
|
|
|
+ */
|
|
|
+@Component("yfProjectTask")
|
|
|
+public class YfProjectTask
|
|
|
+{
|
|
|
+ @Autowired
|
|
|
+ private ProjectTaskMapper projectTaskMapper;
|
|
|
+ public void end(){
|
|
|
+ System.out.println("执行定时任务,完成项目");
|
|
|
+ List<ProjectTask> projectTasks = projectTaskMapper.selectAll();
|
|
|
+ List<Long> ids =new ArrayList<>();
|
|
|
+ long nowDate = System.currentTimeMillis();
|
|
|
+ System.out.println(projectTasks.size());
|
|
|
+ for (ProjectTask p : projectTasks) {
|
|
|
+ long taskDate = p.getEndTime().getTime();
|
|
|
+ System.out.println("newDate="+nowDate);
|
|
|
+ System.out.println("taskDate="+taskDate);
|
|
|
+ if (nowDate>taskDate){
|
|
|
+ ids.add(p.getId());
|
|
|
+ System.out.println(p.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (ids.size()>0) {
|
|
|
+ List<Long> idList =new ArrayList<>();
|
|
|
+ for (int i=0; i<ids.size(); i++) {
|
|
|
+ idList.add(ids.get(i));
|
|
|
+ if (idList.size()==50||i==ids.size()-1){
|
|
|
+ if (idList.size()>0)projectTaskMapper.batchUpdateProjectStatus(ids);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|