Browse Source

添加首件处理

guozx 3 years ago
parent
commit
6082857200

+ 32 - 6
application-task/src/main/java/com/jihengbel/intelligent/applicationtask/init/TimerTaskInit.java

@@ -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 {
     }
 
 
+
+
+
 }

+ 2 - 2
application-task/src/main/resources/mappers/OnsiteTaskMapper.xml

@@ -33,7 +33,7 @@
     <select id="getCalenderOnsitesForType" resultMap="calendarOnsite">  <!-- todo  这个还需要状态 -->
         SELECT b.* FROM  benteler_plan a,onsite_calendar b
         WHERE
-        a.id=b.benteler_plan_id and a.pause_flag=1
+        a.id=b.benteler_plan_id and a.pause_flag=0 and a.deleted=0 and a.updated_time &lt;= now()
         and b.type_flag=${type_flag}
         <if test="week_day != null and week_day != ''">
             and  b.week_day = ${week_day}
@@ -73,4 +73,4 @@
 
 
 
-</mapper>
+</mapper>