瀏覽代碼

加载大数据缓存

zhoutg 4 年之前
父節點
當前提交
d0a0e8cea3

+ 4 - 0
src/main/java/com/diagbot/client/PushNewServiceClient.java

@@ -2,6 +2,7 @@ package com.diagbot.client;
 
 import com.diagbot.client.hystrix.PushNewServiceHystrix;
 import com.diagbot.dto.PushNewDTO;
+import com.diagbot.dto.PushReloadDTO;
 import com.diagbot.vo.PushNewVO;
 import org.springframework.cloud.openfeign.FeignClient;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -17,6 +18,9 @@ public interface PushNewServiceClient {
 
     @PostMapping(value = "/api/disease")
     PushNewDTO pushNew(@RequestBody PushNewVO pushNewVO);
+
+    @PostMapping(value = "/api/reloadPushDB")
+    PushReloadDTO reloadPushDB();
 }
 
 

+ 7 - 0
src/main/java/com/diagbot/client/hystrix/PushNewServiceHystrix.java

@@ -2,6 +2,7 @@ package com.diagbot.client.hystrix;
 
 import com.diagbot.client.PushNewServiceClient;
 import com.diagbot.dto.PushNewDTO;
+import com.diagbot.dto.PushReloadDTO;
 import com.diagbot.vo.PushNewVO;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Component;
@@ -15,4 +16,10 @@ public class PushNewServiceHystrix implements PushNewServiceClient {
         log.error("【hystrix】调用{}异常", "pushNew");
         return null;
     }
+
+    @Override
+    public PushReloadDTO reloadPushDB() {
+        log.error("【hystrix】调用{}异常", "reloadDB");
+        return null;
+    }
 }

+ 14 - 0
src/main/java/com/diagbot/dto/PushReloadDTO.java

@@ -0,0 +1,14 @@
+package com.diagbot.dto;
+
+import lombok.Data;
+
+/**
+ * @Description: 加载推理数据出参
+ * @author: zhoutg
+ * @time: 2020/8/6 9:54
+ */
+@Data
+public class PushReloadDTO {
+    // 返回状态
+    private Integer status;
+}

+ 17 - 0
src/main/java/com/diagbot/facade/CacheFacade.java

@@ -1,6 +1,8 @@
 package com.diagbot.facade;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.diagbot.client.PushNewServiceClient;
+import com.diagbot.dto.PushReloadDTO;
 import com.diagbot.entity.TranHospitalInfo;
 import com.diagbot.enums.IsDeleteEnum;
 import com.diagbot.enums.RedisEnum;
@@ -35,6 +37,8 @@ public class CacheFacade {
     KlDictionaryInfoFacade klDictionaryInfoFacade;
     @Autowired
     TranHospitalInfoFacade tranHospitalInfoFacade;
+    @Autowired
+    PushNewServiceClient pushNewServiceClient;
 
     /**
      * 清除缓存信息
@@ -113,6 +117,19 @@ public class CacheFacade {
         neoFacade.allRuleCache();
     }
 
+    /**
+     * 重新加载大数据缓存
+     *
+     * @return
+     */
+    public Boolean reloadPushDB(){
+        PushReloadDTO pushReloadDTO = pushNewServiceClient.reloadPushDB();
+        if (pushReloadDTO == null || !pushReloadDTO.getStatus().equals(0)) {
+            return false;
+        }
+        return true;
+    }
+
     /**
      * 缓存医学知识库中的所有去重的基础诊断依据
      *

+ 20 - 1
src/main/java/com/diagbot/web/CacheController.java

@@ -84,6 +84,19 @@ public class CacheController {
         return RespDTO.onSuc(true);
     }
 
+    @ApiOperation(value = "重新加载大数据缓存[by:zhoutg]",
+            notes = "")
+    @PostMapping("/reloadPushDB")
+    @SysLogger("reloadPushDB")
+    public RespDTO<Boolean> reloadPushDB() {
+        boolean flag = cacheFacade.reloadPushDB();
+        if (flag) {
+            return RespDTO.onSuc(flag);
+        } else {
+            return RespDTO.onError("加载大数据缓存失败");
+        }
+    }
+
     @ApiOperation(value = "重新加载标准词及规则、药物缓存、基础诊断依据[by:wangfeng]",
             notes = "")
     @PostMapping("/clearStandRuleDrug")
@@ -93,7 +106,13 @@ public class CacheController {
         cacheFacade.loadAllRuleCache();
         cacheFacade.loadDrugTypeCache();
         cacheFacade.loadAllBaseDiagnoseCache();
-        return RespDTO.onSuc(true);
+        // 加载大数据缓存
+        boolean flag = cacheFacade.reloadPushDB();
+        if (flag) {
+            return RespDTO.onSuc(flag);
+        } else {
+            return RespDTO.onError("加载知识库缓存成功,加载大数据缓存失败");
+        }
     }
 
     @ApiOperation(value = "加载大数据推送类型【字段:push_mode】和推送版本【字段:remark】[by:zhoutg]",