فهرست منبع

'新增定时同步巡检系统漏检数据到巡检异常记录表中接口RPC调用,使用service-job模块服务调用执行'

james 8 ماه پیش
والد
کامیت
0c365dd4c2

+ 19 - 0
service-fire/service-fire-api/src/main/java/com/usky/fire/RemoteFireService.java

@@ -0,0 +1,19 @@
+package com.usky.fire;
+
+
+import com.usky.common.core.bean.ApiResult;
+import com.usky.fire.domain.SysUserVO;
+import com.usky.fire.factory.RemoteFireFallbackFactory;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.http.MediaType;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.util.List;
+
+@FeignClient(contextId = "remoteFireService", value = "usky-fire" , fallbackFactory = RemoteFireFallbackFactory.class)
+public interface RemoteFireService {
+
+    @PostMapping("addPatrolInspectionAbnormalData")
+    ApiResult<Void> addPatrolInspectionAbnormalData();
+}

+ 47 - 0
service-fire/service-fire-api/src/main/java/com/usky/fire/factory/RemoteFireFallbackFactory.java

@@ -0,0 +1,47 @@
+package com.usky.fire.factory;
+
+import com.usky.common.core.bean.ApiResult;
+import com.usky.common.core.exception.BusinessException;
+import com.usky.fire.RemoteUserService;
+import com.usky.fire.domain.SysUserVO;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.cloud.openfeign.FallbackFactory;
+import org.springframework.stereotype.Component;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.util.List;
+
+
+/**
+ * 用户服务降级处理
+ *
+ * @author ruoyi
+ */
+@Component
+public class RemoteFireFallbackFactory implements FallbackFactory<RemoteUserService>
+{
+    private static final Logger log = LoggerFactory.getLogger(RemoteFireFallbackFactory.class);
+
+    @Override
+    public RemoteUserService create(Throwable throwable)
+    {
+        log.error("用户服务调用失败:{}", throwable.getMessage());
+        return new RemoteUserService() {
+            @Override
+            public ApiResult<List<SysUserVO>> getByUserName(String userName) {
+                throw new BusinessException(throwable.getMessage());
+            }
+
+            @Override
+            public ApiResult<List<SysUserVO>> add(SysUserVO sysUserVO) {
+                throw new BusinessException(throwable.getMessage());
+            }
+
+            @Override
+            public ApiResult<String> upload(MultipartFile file) {
+                throw new BusinessException(throwable.getMessage());
+            }
+        };
+    }
+}

+ 6 - 0
service-fire/service-fire-biz/pom.xml

@@ -115,6 +115,12 @@
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-amqp</artifactId>
         </dependency>
+        <dependency>
+            <groupId>com.usky</groupId>
+            <artifactId>service-fire-api</artifactId>
+            <version>0.0.1</version>
+            <scope>compile</scope>
+        </dependency>
 
     </dependencies>
 

+ 33 - 0
service-fire/service-fire-biz/src/main/java/com/usky/fire/controller/api/patrolInspectionDataApi.java

@@ -0,0 +1,33 @@
+package com.usky.fire.controller.api;
+
+import com.usky.common.core.bean.ApiResult;
+import com.usky.fire.RemoteFireService;
+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 patrolInspectionDataApi implements RemoteFireService {
+
+    @Autowired
+    private PatrolInspectionPlanSonService patrolInspectionPlanSonService;
+
+    public ApiResult<Void> addPatrolInspectionAbnormalData(){
+        patrolInspectionPlanSonService.addPatrolInspectionAbnormalData();
+        return ApiResult.success();
+    }
+
+
+}

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

@@ -84,11 +84,11 @@ public class TaskController {
         patrolInspectionPlanService.addPatrolInspectionPlanSon();
     }
 
-    @Scheduled(cron = "0 5 * * * ?") //每个小时第五分钟执行
-    public void task6(){
-        System.out.println(Thread.currentThread().getName() + "巡检漏检数据同步到巡检异常记录表");
-        patrolInspectionPlanSonService.addPatrolInspectionAbnormalData();
-    }
+//    @Scheduled(cron = "0 5 * * * ?") //每个小时第五分钟执行
+//    public void task6(){
+//        System.out.println(Thread.currentThread().getName() + "巡检漏检数据同步到巡检异常记录表");
+//        patrolInspectionPlanSonService.addPatrolInspectionAbnormalData();
+//    }
 
 }