Browse Source

还原巡检计算统计调度任务

linzhiwei 2 years ago
parent
commit
1b0806be06

+ 13 - 4
snws-gps/snws-gps-boot/src/main/java/com/tofly/gpsboot/config/ScheduledTask.java

@@ -1,10 +1,7 @@
 package com.tofly.gpsboot.config;
 
 
-import com.tofly.gpsboot.handler.plan.AutomaticallySignBackHandler;
-import com.tofly.gpsboot.handler.plan.PlanExecuteStateHandler;
-import com.tofly.gpsboot.handler.plan.PlanTimeoutHandler;
-import com.tofly.gpsboot.handler.plan.PlanTimeoutRemindHandler;
+import com.tofly.gpsboot.handler.plan.*;
 import lombok.AllArgsConstructor;
 import lombok.SneakyThrows;
 import lombok.extern.slf4j.Slf4j;
@@ -24,6 +21,7 @@ public class ScheduledTask {
     private final PlanExecuteStateHandler planExecuteStateHandler;
     private final PlanTimeoutHandler planTimeoutHandler;
     private final PlanTimeoutRemindHandler planTimeoutRemindHandler;
+    private final CalculationGpsHandler calculationGpsHandler;
 
     /**
      * 自动签退
@@ -68,4 +66,15 @@ public class ScheduledTask {
 
     }
 
+    /**
+     * 巡检超时提醒
+     */
+    @Async
+    @Scheduled(cron = "0 0/10 * * * ?")  //
+    @SneakyThrows
+    public void calculationGpsHandler() {
+        calculationGpsHandler.calculationGpsHandler("");
+
+    }
+
 }

+ 13 - 12
snws-gps/snws-gps-boot/src/main/java/com/tofly/gpsboot/handler/plan/CalculationGpsHandler.java

@@ -1,9 +1,12 @@
 package com.tofly.gpsboot.handler.plan;
 
 
+import com.tofly.gpsboot.service.calculate.ICalculateGpsService;
 import lombok.extern.slf4j.Slf4j;
 
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
+import org.springframework.transaction.annotation.Transactional;
 
 /**
  * 计算gps数据统计
@@ -13,16 +16,14 @@ import org.springframework.stereotype.Component;
 @Slf4j
 public class CalculationGpsHandler {
 
-//    @Autowired
-//    private ICalculateGpsService iCalculateGpsService;
-//
-//    @XxlJob("calculationGpsHandler")
-//    public ReturnT<String> calculationGpsHandler(String param) {
-//        log.info("执行gps巡检相关数据统计....");
-//        long l = System.currentTimeMillis();
-//        iCalculateGpsService.CalculateGps();
-//        long l1 = System.currentTimeMillis();
-//        log.info("耗时 :"+(l1-l)+" ms");
-//        return ReturnT.SUCCESS;
-//    }
+    @Autowired
+    private ICalculateGpsService iCalculateGpsService;
+    @Transactional(rollbackFor = Exception.class)
+    public void calculationGpsHandler(String param) {
+        log.info("执行gps巡检相关数据统计....");
+        long l = System.currentTimeMillis();
+        iCalculateGpsService.CalculateGps();
+        long l1 = System.currentTimeMillis();
+        log.info("耗时 :"+(l1-l)+" ms");
+    }
 }