소스 검색

巡检子计划定时任务更新

hanzhengyi 9 시간 전
부모
커밋
80ee6825a3

+ 13 - 0
service-fire/service-fire-api/src/main/java/com/usky/fire/RemotePlanSonService.java

@@ -0,0 +1,13 @@
+package com.usky.fire;
+
+
+import com.usky.fire.factory.RemoteFireFallbackFactory;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.*;
+
+@FeignClient(contextId = "remotePlanSonService", value = "service-fire" , fallbackFactory = RemoteFireFallbackFactory.class)
+public interface RemotePlanSonService {
+
+    @GetMapping("/addPlanSon")
+    void addPlanSon();
+}

+ 33 - 0
service-fire/service-fire-api/src/main/java/com/usky/fire/factory/RemotePlanSonFactory.java

@@ -0,0 +1,33 @@
+package com.usky.fire.factory;
+
+import com.usky.common.core.exception.FeignBadRequestException;
+import com.usky.fire.RemotePlanSonService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.cloud.openfeign.FallbackFactory;
+import org.springframework.stereotype.Component;
+
+
+/**
+ * 用户服务降级处理
+ *
+ * @author ruoyi
+ */
+@Component
+public class RemotePlanSonFactory implements FallbackFactory<RemotePlanSonService>
+{
+    private static final Logger log = LoggerFactory.getLogger(RemoteFireFallbackFactory.class);
+
+    @Override
+    public RemotePlanSonService create(Throwable throwable)
+    {
+        log.error("用户服务调用失败:{}", throwable.getMessage());
+        return new RemotePlanSonService()
+        {
+            @Override
+            public void addPlanSon() {
+                throw new FeignBadRequestException(500,"生成子计划数据异常"+throwable.getMessage());
+            }
+        };
+    }
+}

+ 35 - 0
service-fire/service-fire-biz/src/main/java/com/usky/fire/controller/api/planSonApi.java

@@ -0,0 +1,35 @@
+package com.usky.fire.controller.api;
+
+import com.usky.common.core.bean.ApiResult;
+import com.usky.fire.RemoteFireService;
+import com.usky.fire.RemotePlanSonService;
+import com.usky.fire.service.PatrolInspectionPlanService;
+import com.usky.fire.service.PatrolInspectionPlanSonService;
+import com.usky.system.RemoteDeptService;
+import io.swagger.annotations.Api;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.cloud.openfeign.FallbackFactory;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * <p>
+ *  数据统一查询 前端控制器
+ * </p>
+ *
+ */
+@RestController
+public class planSonApi implements RemotePlanSonService {
+
+    @Autowired
+    private PatrolInspectionPlanService patrolInspectionPlanService;
+
+    @Override
+    public void addPlanSon(){
+        patrolInspectionPlanService.addPatrolInspectionPlanSon();
+    }
+
+
+}

+ 5 - 5
service-fire/service-fire-biz/src/main/java/com/usky/fire/controller/web/TaskController.java

@@ -78,11 +78,11 @@ public class TaskController {
         demReportDataService.regularReportData();
     }
 
-    @Scheduled(cron = "0 0 23 * * ? ")//每天23点
-    public void task5(){
-        System.out.println(Thread.currentThread().getName() + "巡检计划分批次创建执行中");
-        patrolInspectionPlanService.addPatrolInspectionPlanSon();
-    }
+//    @Scheduled(cron = "0 0 23 * * ? ")//每天23点
+//    public void task5(){
+//        System.out.println(Thread.currentThread().getName() + "巡检计划分批次创建执行中");
+//        patrolInspectionPlanService.addPatrolInspectionPlanSon();
+//    }
 
 //    @Scheduled(cron = "0 5 * * * ?") //每个小时第五分钟执行
 //    public void task6(){

+ 10 - 0
service-job/src/main/java/com/ruoyi/job/task/RyTask.java

@@ -4,6 +4,7 @@ import com.usky.cdi.AlarmDataSyncTaskService;
 import com.usky.cdi.RemotecdiTaskService;
 import com.usky.common.core.utils.StringUtils;
 import com.usky.eg.RemoteEgService;
+import com.usky.fire.RemotePlanSonService;
 import com.usky.meeting.RemoteMeetingService;
 import com.usky.ems.RemoteEmsTaskService;
 import com.usky.fire.RemoteFireService;
@@ -43,6 +44,9 @@ public class RyTask {
     @Autowired
     private RemoteEgService remoteEgService;
 
+    @Autowired
+    private RemotePlanSonService remotePlanSonService;
+
     public void ryMultipleParams(String s, Boolean b, Long l, Double d, Integer i) {
         System.out.println(StringUtils.format("执行多参方法: 字符串类型{},布尔类型{},长整型{},浮点型{},整形{}", s, b, l, d, i));
     }
@@ -130,4 +134,10 @@ public class RyTask {
         remoteEgService.egDeviceStatus();
     }
 
+    // 创建巡检子计划
+    public void addPlanSon(){
+        System.out.println(Thread.currentThread().getName() + "巡检计划分批次创建执行中");
+        remotePlanSonService.addPlanSon();
+    }
+
 }