Browse Source

阀控定时任务

wangli 4 years ago
parent
commit
4945b16cef

+ 1 - 31
smart-city-platform/src/main/java/com/bz/smart_city/quartz/job/DeviceValveCommondSync.java

@@ -2,7 +2,6 @@ package com.bz.smart_city.quartz.job;
 
 import com.bz.smart_city.dao.pay.PayControlRecordMapper;
 import com.bz.smart_city.dao.pay.PayFeeMapper;
-import com.bz.smart_city.dto.pay.payfee.PayValveStateInfoDto;
 import com.bz.smart_city.quartz.entity.QuartzEntity;
 import com.bz.smart_city.quartz.service.JobAndTriggerService;
 import com.bz.smart_city.service.pay.PayFeeService;
@@ -16,9 +15,6 @@ import org.springframework.stereotype.Component;
 
 import javax.annotation.Resource;
 import java.io.Serializable;
-import java.math.BigInteger;
-import java.util.List;
-import java.util.stream.Collectors;
 
 /**
  * @description
@@ -27,40 +23,14 @@ import java.util.stream.Collectors;
  */
 @Slf4j
 @Component
-public class DeviceValveCommondSync implements InitializingBean, Job, Serializable {
+public class DeviceValveCommondSync implements  Job, Serializable {
 
     private static final long serialVersionUID = -5732782747738726245L;
 
-    @Resource
-    private PayFeeMapper payFeeMapper;
-    @Resource
-    private JobAndTriggerService jobAndTriggerService;
-
-    @Autowired
-    private PayFeeService payFeeService;
 
     @Resource
     private PayControlRecordMapper payControlRecordMapper;
 
-    @Override
-    public void afterPropertiesSet() {
-
-        QuartzEntity entity = new QuartzEntity();
-        entity.setJobGroup("巡检阀门操作有效期");
-        entity.setJobName("DeviceValveSyncByJob" );
-        entity.setDescription("DeviceValveSyncByJob" );
-        // modify by pengdi ,判断定时任务是否存在,不存在才进行新增
-
-        boolean exists = jobAndTriggerService.isExists(entity);
-        if(!exists) {
-            String cron = "0 */30 * * * ?";
-            log.info("巡检阀门操作有效期:" + cron);
-            entity.setCronExpression(cron);
-            entity.setJobClassName(DeviceValveCommondSync.class.getName());
-            jobAndTriggerService.save(entity);
-        }
-
-    }
 
     @Override
     public void execute(JobExecutionContext context) throws JobExecutionException {

+ 2 - 19
smart-city-platform/src/main/java/com/bz/smart_city/quartz/job/OpenAccountValveInspection.java

@@ -1,6 +1,5 @@
 package com.bz.smart_city.quartz.job;
 
-import com.bz.smart_city.dao.pay.PayControlRecordMapper;
 import com.bz.smart_city.dao.pay.PayFeeMapper;
 import com.bz.smart_city.dto.pay.payfee.PayValveStateInfoDto;
 import com.bz.smart_city.quartz.entity.QuartzEntity;
@@ -28,15 +27,14 @@ import java.util.stream.Collectors;
  */
 @Slf4j
 @Component
-public class OpenAccountValveInspection  implements InitializingBean, Job, Serializable {
+public class OpenAccountValveInspection  implements Job, Serializable {
 
     private static final long serialVersionUID = 485856043987682652L;
 
 
     @Resource
     private PayFeeMapper payFeeMapper;
-    @Resource
-    private JobAndTriggerService jobAndTriggerService;
+
 
     @Autowired
     private PayFeeService payFeeService;
@@ -59,19 +57,4 @@ public class OpenAccountValveInspection  implements InitializingBean, Job, Seria
             }
         log.info("巡检开户开阀操作结束:"+ LocalDateTime.now());
     }
-
-    //巡检中间表下发开关阀操作(开户开阀)
-    @Override
-    public void afterPropertiesSet() throws Exception {
-        QuartzEntity entity = new QuartzEntity();
-        entity.setJobGroup("巡检开户开阀操作");
-        entity.setJobName("OpenAccountValveInspectionSyncByJob" );
-        entity.setDescription("OpenAccountValveInspectionSyncByJob" );
-        // modify by pengdi ,判断定时任务是否存在,不存在才进行新增
-        String cron = "0 */2 * * * ?";
-        log.info("巡检开户开阀操作:" + cron);
-        entity.setCronExpression(cron);
-        entity.setJobClassName(OpenAccountValveInspection.class.getName());
-        jobAndTriggerService.save(entity);
-    }
 }

+ 32 - 0
smart-city-platform/src/main/java/com/bz/smart_city/service/impl/pay/PayMessagesendrecordServiceImp.java

@@ -20,7 +20,9 @@ import com.bz.smart_city.entity.pay.PayBaseAccount;
 import com.bz.smart_city.entity.pay.PayControlRule;
 import com.bz.smart_city.quartz.entity.QuartzEntity;
 import com.bz.smart_city.quartz.job.ControlByDayJob;
+import com.bz.smart_city.quartz.job.DeviceValveCommondSync;
 import com.bz.smart_city.quartz.job.MessageSendJob;
+import com.bz.smart_city.quartz.job.OpenAccountValveInspection;
 import com.bz.smart_city.quartz.service.JobAndTriggerService;
 import com.bz.smart_city.service.pay.PayFeeService;
 import com.bz.smart_city.service.pay.PayMessagesendrecordService;
@@ -28,6 +30,7 @@ import com.bz.smart_city.service.pay.PayMessagetemplateService;
 import com.github.pagehelper.Page;
 import com.github.pagehelper.PageHelper;
 import io.swagger.annotations.ApiModelProperty;
+import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.jexl3.JexlException;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.InitializingBean;
@@ -53,6 +56,7 @@ import static com.google.common.collect.Lists.newArrayList;
  * @Description 短信记录
  * @Version 1.0
  */
+@Slf4j
 @Service
 public class PayMessagesendrecordServiceImp implements PayMessagesendrecordService,InitializingBean {
 
@@ -470,6 +474,34 @@ public class PayMessagesendrecordServiceImp implements PayMessagesendrecordServi
         }
         jobAndTriggerService.save(entity2);
 
+        QuartzEntity entity3 = new QuartzEntity();
+        entity3.setJobGroup("巡检开户开阀操作");
+        entity3.setJobName("OpenAccountValveInspectionSyncByJob" );
+        entity3.setDescription("OpenAccountValveInspectionSyncByJob" );
+        // modify by pengdi ,判断定时任务是否存在,不存在才进行新增
+        log.info("巡检开户开阀操作:" + "0 0/2 * * * ?");
+        entity3.setCronExpression("0 0/2 * * * ?");
+        entity3.setJobClassName(OpenAccountValveInspection.class.getName());
+        boolean exists3 = jobAndTriggerService.isExists(entity3);
+        if(!exists3) {
+         jobAndTriggerService.save(entity3);
+        }
+
+
+
+        QuartzEntity entity4 = new QuartzEntity();
+        entity4.setJobGroup("巡检阀门操作有效期");
+        entity4.setJobName("DeviceValveSyncByJob" );
+        entity4.setDescription("DeviceValveSyncByJob" );
+        // modify by pengdi ,判断定时任务是否存在,不存在才进行新增
+        boolean exists4 = jobAndTriggerService.isExists(entity4);
+        if(!exists4) {
+            log.info("巡检阀门操作有效期:" + "0 */30 * * * ?");
+            entity4.setCronExpression("0 */30 * * * ?");
+            entity4.setJobClassName(DeviceValveCommondSync.class.getName());
+            jobAndTriggerService.save(entity4);
+        }
+
 
     }