Browse Source

结构调整

zhoutg 4 years ago
parent
commit
6f285dab87

+ 4 - 4
src/main/java/com/diagbot/config/CacheDeleteInit.java

@@ -26,10 +26,10 @@ public class CacheDeleteInit implements CommandLineRunner {
     @Override
     public void run(String... args) throws Exception {
         // 服务启动清除redis缓存
-        cacheFacade.clear();
+        cacheFacade.clearLoadCache();
         log.info("CDSS-CORE服务启动清除redis缓存成功!");
-        //
-         neoFacade.getDrugCache();
-         log.info("CDSS-CORE服务启动加载药品缓存成功!");
+
+        neoFacade.getDrugCache();
+        log.info("CDSS-CORE服务启动加载药品缓存成功!");
     }
 }

+ 52 - 0
src/main/java/com/diagbot/enums/RedisEnum.java

@@ -0,0 +1,52 @@
+package com.diagbot.enums;
+
+import com.diagbot.core.KeyedNamed;
+import lombok.Setter;
+
+/**
+ * @author zhoutg
+ * @Description: 标准词转换
+ * @date 2018年10月11日 下午3:33:22
+ */
+
+public enum RedisEnum implements KeyedNamed {
+
+    drugType(1, "药品分类_");
+
+    @Setter
+    private int key;
+
+    @Setter
+    private String name;
+
+    RedisEnum(int key, String name) {
+        this.key = key;
+        this.name = name;
+    }
+
+    public static RedisEnum getEnum(int key) {
+        for (RedisEnum item : RedisEnum.values()) {
+            if (item.key == key) {
+                return item;
+            }
+        }
+        return null;
+    }
+
+    public static String getName(int key) {
+        RedisEnum item = getEnum(key);
+        return item != null ? item.name : null;
+    }
+
+    @Override
+    public int getKey() {
+        return key;
+    }
+
+    @Override
+    public String getName() {
+        return name;
+    }
+
+
+}

+ 20 - 11
src/main/java/com/diagbot/facade/CacheFacade.java

@@ -1,10 +1,10 @@
 package com.diagbot.facade;
 
+import com.diagbot.enums.RedisEnum;
 import com.diagbot.enums.StandConvertEnum;
+import com.diagbot.util.RedisUtil;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.cache.annotation.CacheEvict;
-import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.stereotype.Component;
 
 /**
@@ -16,8 +16,7 @@ import org.springframework.stereotype.Component;
 public class CacheFacade {
 
     @Autowired
-    @Qualifier("redisTemplateForSimilar")
-    RedisTemplate redisTemplate;
+    RedisUtil redisUtil;
 
     /**
      * 清除缓存信息
@@ -35,12 +34,22 @@ public class CacheFacade {
      * @return
      */
     public void clearStandConvert() {
-        redisTemplate.delete(StandConvertEnum.disease.getName());
-        redisTemplate.delete(StandConvertEnum.drug.getName());
-        redisTemplate.delete(StandConvertEnum.lis.getName());
-        redisTemplate.delete(StandConvertEnum.operation.getName());
-        redisTemplate.delete(StandConvertEnum.pacs.getName());
-        redisTemplate.delete(StandConvertEnum.symptom.getName());
-        redisTemplate.delete(StandConvertEnum.vital.getName());
+        redisUtil.delete(StandConvertEnum.disease.getName());
+        redisUtil.delete(StandConvertEnum.drug.getName());
+        redisUtil.delete(StandConvertEnum.lis.getName());
+        redisUtil.delete(StandConvertEnum.operation.getName());
+        redisUtil.delete(StandConvertEnum.pacs.getName());
+        redisUtil.delete(StandConvertEnum.symptom.getName());
+        redisUtil.delete(StandConvertEnum.vital.getName());
+        redisUtil.delete(StandConvertEnum.transfusion.getName());
+    }
+
+    /**
+     * 清除启动加载类缓存
+     *
+     * @return
+     */
+    public void clearLoadCache() {
+        redisUtil.deleteByPrex(RedisEnum.drugType.getName());
     }
 }

+ 48 - 10
src/main/java/com/diagbot/facade/NeoFacade.java

@@ -3,27 +3,62 @@ package com.diagbot.facade;
 import com.alibaba.fastjson.JSONArray;
 import com.diagbot.client.ChiefPresentSimilarityServiceClient;
 import com.diagbot.client.StandConvertServiceClient;
-import com.diagbot.dto.*;
+import com.diagbot.dto.BillNeoDTO;
+import com.diagbot.dto.CriticalNeoDTO;
+import com.diagbot.dto.HighRiskNeoDTO;
+import com.diagbot.dto.NeoPushDTO;
+import com.diagbot.dto.StandConvertCrfBatchDTO;
+import com.diagbot.dto.StandConvertCrfDTO;
 import com.diagbot.entity.node.Symptom;
 import com.diagbot.entity.node.YiBaoDiseaseName;
 import com.diagbot.enums.StandConvertEnum;
 import com.diagbot.exception.CommonErrorCode;
 import com.diagbot.exception.CommonException;
-import com.diagbot.repository.*;
+import com.diagbot.repository.BaseNodeRepository;
+import com.diagbot.repository.CombiOperationNode;
+import com.diagbot.repository.CombiOperationRepository;
+import com.diagbot.repository.LisNameNode;
+import com.diagbot.repository.LisNameRepository;
+import com.diagbot.repository.LisSetNode;
+import com.diagbot.repository.LisSetRepository;
+import com.diagbot.repository.MedJiePouClassRepository;
+import com.diagbot.repository.MedRegNameNode;
+import com.diagbot.repository.MedicineCodeNode;
+import com.diagbot.repository.MedicineCodeRepository;
+import com.diagbot.repository.MedicineRepository;
+import com.diagbot.repository.PacsNameNode;
+import com.diagbot.repository.PacsNameRepository;
+import com.diagbot.repository.SymptomNameRepository;
+import com.diagbot.repository.YiBaoDiseaseNode;
+import com.diagbot.repository.YiBaoDiseaseRepository;
+import com.diagbot.repository.YiBaoOperationNameNode;
+import com.diagbot.repository.YiBaoOperationNameRepository;
 import com.diagbot.util.ListUtil;
 import com.diagbot.util.RedisUtil;
 import com.diagbot.util.StringUtil;
-import com.diagbot.vo.*;
+import com.diagbot.vo.BillNeoVO;
+import com.diagbot.vo.CriticalNeoVO;
+import com.diagbot.vo.Drug;
+import com.diagbot.vo.HighRiskNeoVO;
+import com.diagbot.vo.NeoPushVO;
+import com.diagbot.vo.StandConvert;
+import com.diagbot.vo.StandConvertCrfVO;
 import com.diagbot.vo.neoPushEntity.ChiefPushVo;
 import com.diagbot.vo.neoPushEntity.Diag;
 import com.diagbot.vo.neoPushEntity.PresentPushVo;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.beans.factory.annotation.Value;
-import org.springframework.cache.annotation.Cacheable;
+import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.stereotype.Component;
 
 import java.math.BigDecimal;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
 import java.util.function.Function;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
@@ -66,6 +101,9 @@ public class NeoFacade {
     StandConvertServiceClient standConvertServiceClient;
     @Autowired
     RedisUtil redisUtil;
+    @Autowired
+    @Qualifier("redisTemplateForSimilar")
+    RedisTemplate redisTemplate;
     @Value("${StandConvert.rate}")
     String standConvertRate;
     @Autowired
@@ -76,7 +114,7 @@ public class NeoFacade {
      *
      * @return
      */
-    @Cacheable(value = "cache", key = "'drugCache'")
+    // @Cacheable(value = "cache", key = "'drugCache'")
     public Map<String, List<String>> getDrugCache() {
         Map<String, List<String>> res = new HashMap<>();
 
@@ -99,10 +137,10 @@ public class NeoFacade {
             }
         }
 
-
-        // TODO 测试数据
-        res.put("泰舒达类", Arrays.asList("泰舒达"));
-        res.put("青霉素类", Arrays.asList("青霉素"));
+        // 加载药品缓存
+        for (String key : res.keySet()) {
+            redisUtil.updateValueByType("药品分类_" + key, res.get(key));
+        }
         return res;
     }
 

+ 48 - 20
src/main/java/com/diagbot/process/BillProcess.java

@@ -1,22 +1,35 @@
 package com.diagbot.process;
 
 import com.diagbot.biz.push.entity.Item;
-import com.diagbot.dto.*;
+import com.diagbot.dto.BillMsg;
+import com.diagbot.dto.BillNeoDTO;
+import com.diagbot.dto.BillNeoMaxDTO;
+import com.diagbot.dto.IndicationDTO;
+import com.diagbot.dto.WordCrfDTO;
 import com.diagbot.enums.NeoEnum;
 import com.diagbot.facade.NeoFacade;
 import com.diagbot.model.entity.Clinical;
 import com.diagbot.model.entity.Operation;
-import com.diagbot.model.label.*;
-import com.diagbot.rule.*;
+import com.diagbot.model.label.ChiefLabel;
+import com.diagbot.model.label.DiagLabel;
+import com.diagbot.model.label.PacsLabel;
+import com.diagbot.model.label.PastLabel;
+import com.diagbot.model.label.PresentLabel;
+import com.diagbot.rule.AgeRule;
+import com.diagbot.rule.CommonRule;
+import com.diagbot.rule.DrugRule;
+import com.diagbot.rule.GroupRule;
+import com.diagbot.rule.LisRule;
+import com.diagbot.rule.PacsRule;
+import com.diagbot.rule.SexRule;
+import com.diagbot.rule.VitalRule;
 import com.diagbot.util.BeanUtil;
 import com.diagbot.util.ListUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
 import java.util.ArrayList;
-import java.util.LinkedHashMap;
 import java.util.List;
-import java.util.Map;
 import java.util.stream.Collectors;
 
 /**
@@ -29,6 +42,23 @@ public class BillProcess {
 
     @Autowired
     NeoFacade neoFacade;
+    @Autowired
+    DrugRule drugRule;
+    @Autowired
+    SexRule sexRule;
+    @Autowired
+    AgeRule ageRule;
+    @Autowired
+    CommonRule commonRule;
+    @Autowired
+    LisRule lisRule;
+    @Autowired
+    PacsRule pacsRule;
+    @Autowired
+    VitalRule vitalRule;
+    @Autowired
+    GroupRule groupRule;
+
 
     public void process(List<BillNeoDTO> billNeoDTOList, WordCrfDTO wordCrfDTO, IndicationDTO res) {
         // 合并图谱数据到同一个对象中
@@ -109,8 +139,6 @@ public class BillProcess {
 
     // 规则处理
     public void processRule(List<BillNeoMaxDTO> billNeoMaxDTOList, WordCrfDTO wordCrfDTO, IndicationDTO indicationDTO) {
-        // 获取药品缓存
-        Map<String, List<String>> drugMap = new LinkedHashMap<>();
         DiagLabel diagLabel = wordCrfDTO.getDiagLabel();
         ChiefLabel chiefLabel = wordCrfDTO.getChiefLabel();
         PresentLabel presentLabel = wordCrfDTO.getPresentLabel();
@@ -154,44 +182,44 @@ public class BillProcess {
         List<BillMsg> billMsgList = new ArrayList<>();
         for (BillNeoMaxDTO bill : billNeoMaxDTOList) {
             // 性别
-            SexRule.compareSexWithBill(wordCrfDTO, bill, billMsgList, NeoEnum.gender.getName());
+            sexRule.compareSexWithBill(wordCrfDTO, bill, billMsgList, NeoEnum.gender.getName());
 
             // 年龄
-            AgeRule.compareAgeWithBill(wordCrfDTO, bill, billMsgList, NeoEnum.ageNeoDTO.getName());
+            ageRule.compareAgeWithBill(wordCrfDTO, bill, billMsgList, NeoEnum.ageNeoDTO.getName());
 
             // 诊断
-            CommonRule.compareItemWithBill(bill.getDisease(), diags, bill, billMsgList, NeoEnum.disease.getName());
+            commonRule.compareItemWithBill(bill.getDisease(), diags, bill, billMsgList, NeoEnum.disease.getName());
 
             // 化验
-            LisRule.compareLisWithBill(wordCrfDTO.getLis(), bill, billMsgList, NeoEnum.lis.getName());
+            lisRule.compareLisWithBill(wordCrfDTO.getLis(), bill, billMsgList, NeoEnum.lis.getName());
 
             // 体征
-            VitalRule.compareVitalWithBill(wordCrfDTO.getVitalLabel(), bill, billMsgList, NeoEnum.vitals.getName());
+            vitalRule.compareVitalWithBill(wordCrfDTO.getVitalLabel(), bill, billMsgList, NeoEnum.vitals.getName());
 
             // 辅检
-            PacsRule.comparePacsWithBill(bill.getPacs(), wordCrfDTO.getPacs(), bill, billMsgList, NeoEnum.pacs.getName());
+            pacsRule.comparePacsWithBill(bill.getPacs(), wordCrfDTO.getPacs(), bill, billMsgList, NeoEnum.pacs.getName());
 
             // 临床表现
-            CommonRule.compareNameWithBill(bill.getClinicfindings(), clinicals, bill, billMsgList, NeoEnum.clinicfindings.getName());
+            commonRule.compareNameWithBill(bill.getClinicfindings(), clinicals, bill, billMsgList, NeoEnum.clinicfindings.getName());
 
             // 手术(既往史、现病史)
-            CommonRule.compareNameWithBill(bill.getOperations(), operations_present, bill, billMsgList, NeoEnum.operations.getName());
+            commonRule.compareNameWithBill(bill.getOperations(), operations_present, bill, billMsgList, NeoEnum.operations.getName());
 
             // 禁忌过敏药品(既往史)
-            DrugRule.compareDrugWithBill(bill.getAllergicmeds(), pastLabel.getAllergyMedicines(), bill, billMsgList, drugMap, NeoEnum.allergicmeds.getName());
+            drugRule.compareDrugWithBill(bill.getAllergicmeds(), pastLabel.getAllergyMedicines(), bill, billMsgList, NeoEnum.allergicmeds.getName());
 
             // 服用药品(现病史一般情况后的药品)
-            DrugRule.compareDrugWithBill(bill.getOralmeds(), presentLabel.getTakeMedicine(), bill, billMsgList, drugMap, NeoEnum.oralmeds.getName());
+            drugRule.compareDrugWithBill(bill.getOralmeds(), presentLabel.getTakeMedicine(), bill, billMsgList, NeoEnum.oralmeds.getName());
 
             // 禁用人群
-            GroupRule.compareGroupWithBill(wordCrfDTO, bill, billMsgList, NeoEnum.group.getName());
+            groupRule.compareGroupWithBill(wordCrfDTO, bill, billMsgList, NeoEnum.group.getName());
 
             // 禁用辅助检查描述
-            CommonRule.compareItemWithBill(bill.getPacsDesc(), pacsDescList, bill, billMsgList, NeoEnum.pacsDesc.getName());
+            commonRule.compareItemWithBill(bill.getPacsDesc(), pacsDescList, bill, billMsgList, NeoEnum.pacsDesc.getName());
         }
 
         // 24小时重复开单项
-        CommonRule.repeat24Bill(wordCrfDTO, billMsgList);
+        commonRule.repeat24Bill(wordCrfDTO, billMsgList);
         indicationDTO.setBillMsgList(billMsgList);
     }
 

+ 3 - 1
src/main/java/com/diagbot/rule/AgeRule.java

@@ -5,6 +5,7 @@ import com.diagbot.dto.BillNeoMaxDTO;
 import com.diagbot.dto.NodeNeoDTO;
 import com.diagbot.dto.WordCrfDTO;
 import com.diagbot.util.CoreUtil;
+import org.springframework.stereotype.Component;
 
 import java.util.List;
 
@@ -13,6 +14,7 @@ import java.util.List;
  * @author: zhoutg
  * @time: 2020/8/3 14:47
  */
+@Component
 public class AgeRule {
 
     /**
@@ -22,7 +24,7 @@ public class AgeRule {
      * @param billNeoMaxDTO
      * @return
      */
-    public static void compareAgeWithBill(WordCrfDTO wordCrfDTO, BillNeoMaxDTO billNeoMaxDTO, List<BillMsg> billMsgList, String type) {
+    public void compareAgeWithBill(WordCrfDTO wordCrfDTO, BillNeoMaxDTO billNeoMaxDTO, List<BillMsg> billMsgList, String type) {
         NodeNeoDTO ageNeoDTO = billNeoMaxDTO.getAgeNeoDTO();
         Boolean flag = false;
         if (ageNeoDTO != null && wordCrfDTO.getAge() != null) {

+ 6 - 4
src/main/java/com/diagbot/rule/CommonRule.java

@@ -12,6 +12,7 @@ import com.diagbot.util.EntityUtil;
 import com.diagbot.util.ListUtil;
 import com.diagbot.util.StringUtil;
 import org.apache.commons.lang3.StringUtils;
+import org.springframework.stereotype.Component;
 
 import java.util.ArrayList;
 import java.util.Collections;
@@ -27,6 +28,7 @@ import java.util.stream.Collectors;
  * @author: kwz
  * @time: 2020/8/3 14:47
  */
+@Component
 public class CommonRule {
 
     /**
@@ -37,7 +39,7 @@ public class CommonRule {
      * @param billNeoMaxDTO 开单项名称,开单项标准名称
      * @return
      */
-    public static <T> void compareNameWithBill(List<NodeNeoDTO> neoList, List<T> inputLises, BillNeoMaxDTO billNeoMaxDTO, List<BillMsg> billMsgList, String type) {
+    public <T> void compareNameWithBill(List<NodeNeoDTO> neoList, List<T> inputLises, BillNeoMaxDTO billNeoMaxDTO, List<BillMsg> billMsgList, String type) {
         Map<String, String> old_stand = new HashMap<>();
         if (ListUtil.isNotEmpty(neoList) && ListUtil.isNotEmpty(inputLises)) {
             List<String> dl = neoList.stream().map(x -> x.getName()).collect(Collectors.toList());
@@ -70,7 +72,7 @@ public class CommonRule {
      * @param billNeoMaxDTO 开单项名称,开单项标准名称
      * @return
      */
-    public static <T> void compareItemWithBill(List<NodeNeoDTO> neoList, List<T> input, BillNeoMaxDTO billNeoMaxDTO, List<BillMsg> billMsgList, String type) {
+    public <T> void compareItemWithBill(List<NodeNeoDTO> neoList, List<T> input, BillNeoMaxDTO billNeoMaxDTO, List<BillMsg> billMsgList, String type) {
         Map<String, String> old_stand = new HashMap<>();
         if (ListUtil.isNotEmpty(neoList) && ListUtil.isNotEmpty(input)) {
             List<String> neoName = neoList.stream().map(x -> x.getName()).collect(Collectors.toList());
@@ -98,7 +100,7 @@ public class CommonRule {
      * @param wordCrfDTO
      * @param billMsgList
      */
-    public static void repeat24Bill(WordCrfDTO wordCrfDTO, List<BillMsg> billMsgList) {
+    public void repeat24Bill(WordCrfDTO wordCrfDTO, List<BillMsg> billMsgList) {
         repeat24BillWithType(billMsgList, wordCrfDTO.getLisOrder(), TypeEnum.lis.getName()); // 化验重复开单
         repeat24BillWithType(billMsgList, wordCrfDTO.getPacsOrder(), TypeEnum.pacs.getName()); // 辅检重复开单
         repeat24BillWithType(billMsgList, wordCrfDTO.getDrugOrder(), TypeEnum.drug.getName()); // 药品重复开单
@@ -113,7 +115,7 @@ public class CommonRule {
      * @param itemList
      * @param type
      */
-    public static <T> void repeat24BillWithType(List<BillMsg> billMsgList, List<T> itemList, String type) {
+    public <T> void repeat24BillWithType(List<BillMsg> billMsgList, List<T> itemList, String type) {
         if (ListUtil.isEmpty(itemList)) {
             return ;
         }

+ 13 - 4
src/main/java/com/diagbot/rule/DrugRule.java

@@ -3,10 +3,14 @@ package com.diagbot.rule;
 import com.diagbot.dto.BillMsg;
 import com.diagbot.dto.BillNeoMaxDTO;
 import com.diagbot.dto.NodeNeoDTO;
+import com.diagbot.enums.RedisEnum;
 import com.diagbot.model.entity.Negative;
 import com.diagbot.util.CoreUtil;
 import com.diagbot.util.ListUtil;
+import com.diagbot.util.RedisUtil;
 import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
 
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -18,8 +22,12 @@ import java.util.Map;
  * @author: kwz
  * @time: 2020/8/3 14:47
  */
+@Component
 public class DrugRule {
 
+    @Autowired
+    RedisUtil redisUtil;
+
     /**
      * 比较药品是否存在(图谱返回药品通用名或者药品分类,如果返回的是药品分类,再从redis获取药品通用名)
      *
@@ -27,8 +35,8 @@ public class DrugRule {
      * @param inputList
      * @return
      */
-    public static <T> void compareDrugWithBill(List<NodeNeoDTO> drugList, List<T> inputList, BillNeoMaxDTO billNeoMaxDTO,
-                                               List<BillMsg> billMsgList, Map<String, List<String>> drugMap, String type) {
+    public <T> void compareDrugWithBill(List<NodeNeoDTO> drugList, List<T> inputList, BillNeoMaxDTO billNeoMaxDTO,
+                                               List<BillMsg> billMsgList, String type) {
         Map<String, String> old_stand = new HashMap<>();
         if (ListUtil.isNotEmpty(drugList) && ListUtil.isNotEmpty(inputList)) {
             List<String> allDrug = new ArrayList<>();
@@ -37,8 +45,9 @@ public class DrugRule {
                     allDrug.add(nodeNeoDTO.getName());
                 } else if ("药品解剖学类别".equals(nodeNeoDTO.getTermtype())){
                     String drugType = nodeNeoDTO.getName();
-                    if (drugMap.get(drugType) != null) {
-                        allDrug.addAll(drugMap.get(drugType));
+                    List<String> drugRedis = (List<String>)redisUtil.get(RedisEnum.drugType.getName() + drugType);
+                    if (ListUtil.isNotEmpty(drugRedis)) {
+                        allDrug.addAll(drugRedis);
                     }
                 }
             }

+ 3 - 1
src/main/java/com/diagbot/rule/GroupRule.java

@@ -6,6 +6,7 @@ import com.diagbot.dto.BillNeoMaxDTO;
 import com.diagbot.dto.NodeNeoDTO;
 import com.diagbot.dto.WordCrfDTO;
 import com.diagbot.util.CoreUtil;
+import org.springframework.stereotype.Component;
 
 import java.util.List;
 
@@ -14,6 +15,7 @@ import java.util.List;
  * @author: zhoutg
  * @time: 2020/8/3 14:47
  */
+@Component
 public class GroupRule {
 
     /**
@@ -23,7 +25,7 @@ public class GroupRule {
      * @param billNeoMaxDTO
      * @return
      */
-    public static void compareGroupWithBill(WordCrfDTO wordCrfDTO, BillNeoMaxDTO billNeoMaxDTO, List<BillMsg> billMsgList, String type) {
+    public void compareGroupWithBill(WordCrfDTO wordCrfDTO, BillNeoMaxDTO billNeoMaxDTO, List<BillMsg> billMsgList, String type) {
         List<NodeNeoDTO> group = billNeoMaxDTO.getGroup();
         for (NodeNeoDTO node : group) {
             // 妊娠目前从诊断里判断,包含“妊娠”

+ 3 - 1
src/main/java/com/diagbot/rule/LisRule.java

@@ -7,6 +7,7 @@ import com.diagbot.dto.NodeNeoDTO;
 import com.diagbot.util.CoreUtil;
 import com.diagbot.util.ListUtil;
 import com.diagbot.util.StringUtil;
+import org.springframework.stereotype.Component;
 
 import java.util.List;
 import java.util.Map;
@@ -16,6 +17,7 @@ import java.util.Map;
  * @author: kwz
  * @time: 2020/8/3 14:47
  */
+@Component
 public class LisRule {
 
     /**
@@ -25,7 +27,7 @@ public class LisRule {
      * @param billNeoMaxDTO
      * @return
      */
-    public static void compareLisWithBill(List<Lis> inputLis, BillNeoMaxDTO billNeoMaxDTO, List<BillMsg> billMsgList, String type) {
+    public void compareLisWithBill(List<Lis> inputLis, BillNeoMaxDTO billNeoMaxDTO, List<BillMsg> billMsgList, String type) {
         List<NodeNeoDTO> neoList = billNeoMaxDTO.getLis();
         if(ListUtil.isNotEmpty(neoList) && ListUtil.isNotEmpty(inputLis)){
             for (NodeNeoDTO neo : neoList) {

+ 3 - 1
src/main/java/com/diagbot/rule/PacsRule.java

@@ -6,6 +6,7 @@ import com.diagbot.dto.NodeNeoDTO;
 import com.diagbot.util.CoreUtil;
 import com.diagbot.util.ListUtil;
 import org.apache.commons.lang3.StringUtils;
+import org.springframework.stereotype.Component;
 
 import java.util.HashMap;
 import java.util.List;
@@ -17,6 +18,7 @@ import java.util.stream.Collectors;
  * @author: kwz
  * @time: 2020/8/3 14:47
  */
+@Component
 public class PacsRule {
     /**
      * 比较辅检
@@ -25,7 +27,7 @@ public class PacsRule {
      * @param inputLis
      * @return
      */
-    public static <T> void comparePacsWithBill(List<NodeNeoDTO> drugLis, List<T> inputLis, BillNeoMaxDTO billNeoMaxDTO, List<BillMsg> billMsgList, String type) {
+    public <T> void comparePacsWithBill(List<NodeNeoDTO> drugLis, List<T> inputLis, BillNeoMaxDTO billNeoMaxDTO, List<BillMsg> billMsgList, String type) {
         Map<String,String> old_stand = new HashMap<>();
         if(ListUtil.isNotEmpty(drugLis) && ListUtil.isNotEmpty(inputLis)){
             List<String> dl = drugLis.stream().map(x -> x.getName()).collect(Collectors.toList());

+ 3 - 1
src/main/java/com/diagbot/rule/SexRule.java

@@ -6,6 +6,7 @@ import com.diagbot.dto.NodeNeoDTO;
 import com.diagbot.dto.WordCrfDTO;
 import com.diagbot.util.CoreUtil;
 import com.diagbot.util.StringUtil;
+import org.springframework.stereotype.Component;
 
 import java.util.List;
 
@@ -14,6 +15,7 @@ import java.util.List;
  * @author: zhoutg
  * @time: 2020/8/3 14:47
  */
+@Component
 public class SexRule {
 
     /**
@@ -23,7 +25,7 @@ public class SexRule {
      * @param billNeoMaxDTO
      * @return
      */
-    public static void compareSexWithBill(WordCrfDTO wordCrfDTO, BillNeoMaxDTO billNeoMaxDTO, List<BillMsg> billMsgList, String type) {
+    public void compareSexWithBill(WordCrfDTO wordCrfDTO, BillNeoMaxDTO billNeoMaxDTO, List<BillMsg> billMsgList, String type) {
         NodeNeoDTO nodeNeoDTO = billNeoMaxDTO.getGender();
         if (nodeNeoDTO != null && StringUtil.isNotBlank(nodeNeoDTO.getName()) && wordCrfDTO.getSex() != null) {
             String sex = nodeNeoDTO.getName();

+ 3 - 1
src/main/java/com/diagbot/rule/VitalRule.java

@@ -6,6 +6,7 @@ import com.diagbot.dto.NodeNeoDTO;
 import com.diagbot.model.label.VitalLabel;
 import com.diagbot.util.CoreUtil;
 import com.diagbot.util.ListUtil;
+import org.springframework.stereotype.Component;
 
 import java.util.List;
 import java.util.Map;
@@ -15,6 +16,7 @@ import java.util.Map;
  * @author: kwz
  * @time: 2020/8/3 14:47
  */
+@Component
 public class VitalRule {
 
     /**
@@ -26,7 +28,7 @@ public class VitalRule {
      * @param type 类型
      * @return
      */
-    public static void compareVitalWithBill(VitalLabel vitalLabel, BillNeoMaxDTO billNeoMaxDTO, List<BillMsg> billMsgList, String type) {
+    public void compareVitalWithBill(VitalLabel vitalLabel, BillNeoMaxDTO billNeoMaxDTO, List<BillMsg> billMsgList, String type) {
         List<NodeNeoDTO> neoList = billNeoMaxDTO.getVitals();
         if(ListUtil.isNotEmpty(neoList)){
             for (NodeNeoDTO neo : neoList) {

+ 208 - 0
src/main/java/com/diagbot/util/RedisUtil.java

@@ -1,11 +1,17 @@
 package com.diagbot.util;
 
+import org.apache.commons.collections4.CollectionUtils;
 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.Collection;
+import java.util.Date;
+import java.util.List;
 import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.TimeUnit;
 
 /**
  * @description:
@@ -40,4 +46,206 @@ public class RedisUtil {
     public void updateValueByType(Map<String, String> map, String type) {
         redisTemplate.opsForValue().set(type, map);
     }
+
+    /**
+     * 更新指定类型下的数据
+     *
+     * @param key
+     * @param list
+     */
+    public void updateValueByType(String key, List<String> list) {
+        redisTemplate.opsForValue().set(key, list);
+    }
+
+    /**
+     * 根据前缀删除key
+     *
+     * @param prex
+     */
+    public void deleteByPrex(String prex) {
+        prex = prex + "**";
+        Set<String> keys = redisTemplate.keys(prex);
+        if (CollectionUtils.isNotEmpty(keys)) {
+            redisTemplate.delete(keys);
+        }
+    }
+
+    /**
+     * 根据指定key获取value
+     *
+     * @param key 键
+     */
+    public Object get(String key) {
+        return redisTemplate.opsForValue().get(key);
+    }
+
+    /**
+     * 删除key
+     *
+     * @param key
+     */
+    public void delete(String key) {
+        redisTemplate.delete(key);
+    }
+
+    /**
+     * 批量删除key
+     *
+     * @param keys
+     */
+    public void delete(Collection<String> keys) {
+        redisTemplate.delete(keys);
+    }
+
+    /**
+     * 序列化key
+     *
+     * @param key
+     * @return
+     */
+    public byte[] dump(String key) {
+        return redisTemplate.dump(key);
+    }
+
+    /**
+     * 是否存在key
+     *
+     * @param key
+     * @return
+     */
+    public Boolean hasKey(String key) {
+        return redisTemplate.hasKey(key);
+    }
+
+    /**
+     * 设置过期时间
+     *
+     * @param key
+     * @param timeout
+     * @param unit
+     * @return
+     */
+    public Boolean expire(String key, long timeout, TimeUnit unit) {
+        return redisTemplate.expire(key, timeout, unit);
+    }
+
+    /**
+     * 设置过期时间
+     *
+     * @param key
+     * @param date
+     * @return
+     */
+    public Boolean expireAt(String key, Date date) {
+        return redisTemplate.expireAt(key, date);
+    }
+
+    /**
+     * 查找匹配的key
+     *
+     * @param pattern
+     * @return
+     */
+    public Set<String> keys(String pattern) {
+        return redisTemplate.keys(pattern);
+    }
+
+    /**
+     * 移除 key 的过期时间,key 将持久保持
+     *
+     * @param key
+     * @return
+     */
+    public Boolean persist(String key) {
+        return redisTemplate.persist(key);
+    }
+
+    /**
+     * 返回 key 的剩余的过期时间
+     *
+     * @param key
+     * @param unit
+     * @return
+     */
+    public Long getExpire(String key, TimeUnit unit) {
+        return redisTemplate.getExpire(key, unit);
+    }
+
+    /**
+     * 返回 key 的剩余的过期时间
+     *
+     * @param key
+     * @return
+     */
+    public Long getExpire(String key) {
+        return redisTemplate.getExpire(key);
+    }
+
+    /**
+     * 修改 key 的名称
+     *
+     * @param oldKey
+     * @param newKey
+     */
+    public void rename(String oldKey, String newKey) {
+        redisTemplate.rename(oldKey, newKey);
+    }
+
+    /**
+     * 仅当 newkey 不存在时,将 oldKey 改名为 newkey
+     *
+     * @param oldKey
+     * @param newKey
+     * @return
+     */
+    public Boolean renameIfAbsent(String oldKey, String newKey) {
+        return redisTemplate.renameIfAbsent(oldKey, newKey);
+    }
+
+    /** -------------------string相关操作--------------------- */
+
+    /**
+     * 设置指定 key 的值
+     * @param key
+     * @param value
+     */
+    public void set(String key, String value) {
+        redisTemplate.opsForValue().set(key, value);
+    }
+
+    /**
+     * 批量获取
+     *
+     * @param keys
+     * @return
+     */
+    public List<String> multiGet(Collection<String> keys) {
+        return redisTemplate.opsForValue().multiGet(keys);
+    }
+
+    /**
+     * 将值 value 关联到 key ,并将 key 的过期时间设为 timeout
+     *
+     * @param key
+     * @param value
+     * @param timeout
+     *            过期时间
+     * @param unit
+     *            时间单位, 天:TimeUnit.DAYS 小时:TimeUnit.HOURS 分钟:TimeUnit.MINUTES
+     *            秒:TimeUnit.SECONDS 毫秒:TimeUnit.MILLISECONDS
+     */
+    public void setEx(String key, String value, long timeout, TimeUnit unit) {
+        redisTemplate.opsForValue().set(key, value, timeout, unit);
+    }
+
+    /**
+     * 只有在 key 不存在时设置 key 的值
+     *
+     * @param key
+     * @param value
+     * @return 之前已经存在返回false,不存在返回true
+     */
+    public boolean setIfAbsent(String key, String value) {
+        return redisTemplate.opsForValue().setIfAbsent(key, value);
+    }
 }

+ 2 - 2
src/main/java/com/diagbot/web/CacheController.java

@@ -27,12 +27,12 @@ public class CacheController {
     @Autowired
     CacheFacade cacheFacade;
 
-    @ApiOperation(value = "清除缓存[by:zhoutg]",
+    @ApiOperation(value = "清除启动加载类缓存[by:zhoutg]",
             notes = "")
     @PostMapping("/clear")
     @SysLogger("clear")
     public RespDTO<Boolean> clear() {
-        cacheFacade.clear();
+        cacheFacade.clearLoadCache();
         return RespDTO.onSuc(true);
     }