|
@@ -1,5 +1,6 @@
|
|
|
package com.jihengbel.intelligent.applicationtask.init;
|
|
|
|
|
|
+import com.jihengbel.intelligent.applicationtask.service.FirstTaskService;
|
|
|
import com.jihengbel.intelligent.applicationtask.service.OnsiteTaskService;
|
|
|
import org.quartz.Scheduler;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -22,9 +23,17 @@ public class TimerTaskInit implements CommandLineRunner {
|
|
|
@Value("${onsite.remind.work.cron}")
|
|
|
private String cron_2;
|
|
|
|
|
|
+ @Value("${first.task.cron}")
|
|
|
+ private String cron_3;
|
|
|
+ @Value("${first.remind.work.cron}")
|
|
|
+ private String cron_4;
|
|
|
+
|
|
|
@Autowired
|
|
|
OnsiteTaskService onsiteTaskService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ FirstTaskService firstTaskService;
|
|
|
+
|
|
|
@Autowired
|
|
|
SchedulerFactoryBean schedulerFactoryBean;
|
|
|
|
|
@@ -32,18 +41,21 @@ public class TimerTaskInit implements CommandLineRunner {
|
|
|
public void run(String... args) throws Exception {
|
|
|
ConcurrentMap<String, Object> param = new ConcurrentHashMap<String, Object>();
|
|
|
param.put("onsiteTaskService", onsiteTaskService);
|
|
|
+ param.put("firstTaskService", firstTaskService);
|
|
|
Scheduler sche = schedulerFactoryBean.getScheduler();
|
|
|
- // addOnsiteTask(param, sche);
|
|
|
- addOnsiteRemindWork( param, sche);
|
|
|
+// addOnsiteTask(param, sche);
|
|
|
+// addOnsiteRemindWork( param, sche);
|
|
|
+ addFirstTask(param, sche);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 添加onsit任务的定时器
|
|
|
+ * 添加onsit任务的定时器
|
|
|
+ *
|
|
|
* @param param
|
|
|
* @param sche
|
|
|
*/
|
|
|
private void addOnsiteTask(ConcurrentMap<String, Object> param, Scheduler sche) {
|
|
|
- JobFactoryParam onsite =new JobFactoryParam();
|
|
|
+ JobFactoryParam onsite = new JobFactoryParam();
|
|
|
onsite.setJobGroupName(QuartzManager.JOB_GROUP_NAME);
|
|
|
onsite.setJobName("onsiteTask");
|
|
|
onsite.setParamMap(param);
|
|
@@ -52,14 +64,25 @@ public class TimerTaskInit implements CommandLineRunner {
|
|
|
QuartzManager.addJob(sche, onsite);
|
|
|
}
|
|
|
|
|
|
+ private void addFirstTask(ConcurrentMap<String, Object> param, Scheduler sche) {
|
|
|
+ JobFactoryParam onsite = new JobFactoryParam();
|
|
|
+ onsite.setJobGroupName(QuartzManager.JOB_GROUP_NAME);
|
|
|
+ onsite.setJobName("firstTask");
|
|
|
+ onsite.setParamMap(param);
|
|
|
+ onsite.setTriggerRule(cron_3);//"0 */1 * * * ?" 这个用于测试一分钟一次
|
|
|
+ onsite.setClazz(FirstTaskJob.class);
|
|
|
+ QuartzManager.addJob(sche, onsite);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
- * 添加onsit工作提醒
|
|
|
+ * 添加onsit工作提醒
|
|
|
+ *
|
|
|
* @param param
|
|
|
* @param sche
|
|
|
*/
|
|
|
private void addOnsiteRemindWork(ConcurrentMap<String, Object> param, Scheduler sche) {
|
|
|
- JobFactoryParam onsite =new JobFactoryParam();
|
|
|
+ JobFactoryParam onsite = new JobFactoryParam();
|
|
|
onsite.setJobGroupName(QuartzManager.JOB_GROUP_NAME);
|
|
|
onsite.setJobName("onsiteRemindWork");
|
|
|
onsite.setParamMap(param);
|
|
@@ -69,4 +92,7 @@ public class TimerTaskInit implements CommandLineRunner {
|
|
|
}
|
|
|
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|