Explorar el Código

过敏原自身过敏

zhoutg hace 3 años
padre
commit
3118875a21

+ 25 - 12
src/main/java/com/diagbot/facade/NeoFacade.java

@@ -38,8 +38,6 @@ import io.github.lvyahui8.spring.facade.DataFacade;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections.MapUtils;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.stereotype.Component;
 
 import java.util.ArrayList;
@@ -67,9 +65,6 @@ public class NeoFacade {
     @Autowired
     RedisUtil redisUtil;
     @Autowired
-    @Qualifier("redisTemplateForSimilar")
-    RedisTemplate redisTemplate;
-    @Autowired
     SymptomFeatureService symptomFeatureService;
     @Autowired
     KlDiseaseCorrespondingService klDiseaseCorrespondingService;
@@ -102,7 +97,7 @@ public class NeoFacade {
                 Collectors.toMap(k -> RedisEnum.drugType.getName() + k.getDrugType(),
                         v -> v.getDrugs(), (v1, v2) -> (v2)));
         if (redisMap != null && redisMap.size() > 0) {
-            redisTemplate.opsForValue().multiSet(redisMap);
+            redisUtil.multiSet(redisMap);
         }
     }
 
@@ -120,7 +115,7 @@ public class NeoFacade {
                     },
                     (v1, v2) -> (v2)
             ));
-            redisTemplate.opsForValue().multiSet(map);
+            redisUtil.multiSet(map);
         }
     }
 
@@ -135,7 +130,7 @@ public class NeoFacade {
                 Map<String, Long> collect = y.stream().collect(Collectors.toMap(TranHospitalFilter::getUniqueName, TranHospitalFilter::getDocNum, (existing, replacement) -> replacement));
                 data.put(RedisEnum.diseaseFilter.getName() + x.toString(), collect);
             });
-            redisTemplate.opsForValue().multiSet(data);
+            redisUtil.multiSet(data);
         }
     }
 
@@ -159,7 +154,7 @@ public class NeoFacade {
                     },
                     (v1, v2) -> (v2)
             ));
-            redisTemplate.opsForValue().multiSet(map);
+            redisUtil.multiSet(map);
         }
     }
 
@@ -499,7 +494,25 @@ public class NeoFacade {
         try {
             Map<String, Object> invokeParams = new HashMap<>();
             Map<String, RuleDTO> map = DataFacade.get("getAllRules", invokeParams, Map.class);
-            redisTemplate.opsForValue().multiSet(map);
+            // // TODO 过敏原添加自身过敏
+            // for (String key : map.keySet()) {
+            //     if (key.startsWith(RedisEnum.allRule.getName() + LexiconEnum.Medicine.getKey()) && key.endsWith("_1")) {
+            //         RuleDTO ruleDTO = map.get(key);
+            //         List<RuleConditionDTO> ruleConditionDTOList = ruleDTO.getRuleConditionDTOList();
+            //         RuleConditionDTO ruleConditionDTO = new RuleConditionDTO();
+            //         ruleConditionDTO.setHasSubCond(1);
+            //         ruleConditionDTO.setRuleGroup("11");
+            //         List<RuleBaseDTO> ruleBaseDTOList = new ArrayList<>();
+            //         RuleBaseDTO ruleBaseDTO = new RuleBaseDTO();
+            //         ruleBaseDTO.setBaseLibName(ruleDTO.getLibName());
+            //         ruleBaseDTO.setBaseLibType(ruleDTO.getLibType());
+            //         ruleBaseDTO.setBaseType(BaseTypeEnum.B1.getKey());
+            //         ruleBaseDTOList.add(ruleBaseDTO);
+            //         ruleConditionDTO.setRuleBaseDTOList(ruleBaseDTOList);
+            //         ruleConditionDTOList.add(ruleConditionDTO);
+            //     }
+            // }
+            redisUtil.multiSet(map);
         } catch (Exception e) {
             throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "获取所有规则失败" + e.getMessage());
         }
@@ -508,14 +521,14 @@ public class NeoFacade {
     public void allBaseDiagnose() {
         List<BaseDiagnoseDTO> list = klDiagnoseBaseFacade.getAllBaseDiagnose();
         if (ListUtil.isNotEmpty(list)) {
-            redisTemplate.opsForValue().set(RedisEnum.allBaseDiagnose.getName(), list);
+            redisUtil.set(RedisEnum.allBaseDiagnose.getName(), list);
         }
     }
 
     public void allBaseRegulation() {
         List<BaseRegulationDTO> list = klRegulationBaseFacade.getSelectBase(new ArrayList<>());
         if (ListUtil.isNotEmpty(list)) {
-            redisTemplate.opsForValue().set(RedisEnum.allBaseRegulation.getName(), list);
+            redisUtil.set(RedisEnum.allBaseRegulation.getName(), list);
         }
     }
 }

+ 4 - 14
src/main/java/com/diagbot/util/RedisUtil.java

@@ -67,10 +67,10 @@ public class RedisUtil {
      * 根据指定key设置obj
      *
      * @param key
-     * @param obj
+     * @param t
      */
-    public void set(String key, Object obj) {
-        redisTemplate.opsForValue().set(key, obj);
+    public <T> void set(String key, T t) {
+        redisTemplate.opsForValue().set(key, t);
     }
 
     /**
@@ -89,7 +89,7 @@ public class RedisUtil {
      * @param map
      * @return
      */
-    public void multiSet(Map<String, Object> map) {
+    public <T> void multiSet(Map<String, T> map) {
         redisTemplate.opsForValue().multiSet(map);
     }
 
@@ -264,16 +264,6 @@ public class RedisUtil {
 
     /** -------------------string相关操作--------------------- */
 
-    /**
-     * 设置指定 key 的值
-     *
-     * @param key
-     * @param value
-     */
-    public void set(String key, String value) {
-        redisTemplate.opsForValue().set(key, value);
-    }
-
     /**
      * 将值 value 关联到 key ,并将 key 的过期时间设为 timeout
      *