Browse Source

Merge branch 'develop' into dev/dateValue20210805

zhoutg 3 years ago
parent
commit
d1116c6768

+ 23 - 0
doc/015.20210805提示类信息规则维护支持集合分类维护/med2021_init.sql

@@ -0,0 +1,23 @@
+USE `med_2021`;
+
+INSERT INTO `kl_lexicon` (`id`, `is_deleted`, `gmt_create`, `gmt_modified`, `creator`, `modifier`, `name`, `code`, `is_has_common`, `only_one`, `can_change`, `remark`) VALUES ('52', 'N', '1970-01-01 12:00:00', '1970-01-01 12:00:00', '0', '0', '疾病集合', '308', '0', '0', '0', '');
+INSERT INTO `kl_lexicon` (`id`, `is_deleted`, `gmt_create`, `gmt_modified`, `creator`, `modifier`, `name`, `code`, `is_has_common`, `only_one`, `can_change`, `remark`) VALUES ('53', 'N', '1970-01-01 12:00:00', '1970-01-01 12:00:00', '0', '0', '药品通用名集合', '309', '0', '0', '0', '');
+INSERT INTO `kl_lexicon` (`id`, `is_deleted`, `gmt_create`, `gmt_modified`, `creator`, `modifier`, `name`, `code`, `is_has_common`, `only_one`, `can_change`, `remark`) VALUES ('54', 'N', '1970-01-01 12:00:00', '1970-01-01 12:00:00', '0', '0', '药品剂型集合', '310', '0', '0', '0', '');
+INSERT INTO `kl_lexicon` (`id`, `is_deleted`, `gmt_create`, `gmt_modified`, `creator`, `modifier`, `name`, `code`, `is_has_common`, `only_one`, `can_change`, `remark`) VALUES ('55', 'N', '1970-01-01 12:00:00', '1970-01-01 12:00:00', '0', '0', '症状集合', '311', '0', '0', '0', '');
+INSERT INTO `kl_lexicon` (`id`, `is_deleted`, `gmt_create`, `gmt_modified`, `creator`, `modifier`, `name`, `code`, `is_has_common`, `only_one`, `can_change`, `remark`) VALUES ('56', 'N', '1970-01-01 12:00:00', '1970-01-01 12:00:00', '0', '0', '体格检查项目集合', '312', '0', '0', '0', '');
+INSERT INTO `kl_lexicon` (`id`, `is_deleted`, `gmt_create`, `gmt_modified`, `creator`, `modifier`, `name`, `code`, `is_has_common`, `only_one`, `can_change`, `remark`) VALUES ('57', 'N', '1970-01-01 12:00:00', '1970-01-01 12:00:00', '0', '0', '体格检查结果集合', '313', '0', '0', '0', '');
+INSERT INTO `kl_lexicon` (`id`, `is_deleted`, `gmt_create`, `gmt_modified`, `creator`, `modifier`, `name`, `code`, `is_has_common`, `only_one`, `can_change`, `remark`) VALUES ('58', 'N', '1970-01-01 12:00:00', '1970-01-01 12:00:00', '0', '0', '手术和操作集合', '314', '0', '0', '0', '');
+INSERT INTO `kl_lexicon` (`id`, `is_deleted`, `gmt_create`, `gmt_modified`, `creator`, `modifier`, `name`, `code`, `is_has_common`, `only_one`, `can_change`, `remark`) VALUES ('59', 'N', '1970-01-01 12:00:00', '1970-01-01 12:00:00', '0', '0', '实验室检查套餐集合', '315', '0', '0', '0', '');
+INSERT INTO `kl_lexicon` (`id`, `is_deleted`, `gmt_create`, `gmt_modified`, `creator`, `modifier`, `name`, `code`, `is_has_common`, `only_one`, `can_change`, `remark`) VALUES ('60', 'N', '1970-01-01 12:00:00', '1970-01-01 12:00:00', '0', '0', '辅助检查项目集合', '316', '0', '0', '0', '');
+INSERT INTO `kl_lexicon` (`id`, `is_deleted`, `gmt_create`, `gmt_modified`, `creator`, `modifier`, `name`, `code`, `is_has_common`, `only_one`, `can_change`, `remark`) VALUES ('61', 'N', '1970-01-01 12:00:00', '1970-01-01 12:00:00', '0', '0', '辅助检查子项目集合', '317', '0', '0', '0', '');
+INSERT INTO `kl_lexicon` (`id`, `is_deleted`, `gmt_create`, `gmt_modified`, `creator`, `modifier`, `name`, `code`, `is_has_common`, `only_one`, `can_change`, `remark`) VALUES ('62', 'N', '1970-01-01 12:00:00', '1970-01-01 12:00:00', '0', '0', '辅助检查描述集合', '318', '0', '0', '0', '');
+INSERT INTO `kl_lexicon` (`id`, `is_deleted`, `gmt_create`, `gmt_modified`, `creator`, `modifier`, `name`, `code`, `is_has_common`, `only_one`, `can_change`, `remark`) VALUES ('63', 'N', '1970-01-01 12:00:00', '1970-01-01 12:00:00', '0', '0', '辅助检查结果集合', '319', '0', '0', '0', '');
+INSERT INTO `kl_lexicon` (`id`, `is_deleted`, `gmt_create`, `gmt_modified`, `creator`, `modifier`, `name`, `code`, `is_has_common`, `only_one`, `can_change`, `remark`) VALUES ('64', 'N', '1970-01-01 12:00:00', '1970-01-01 12:00:00', '0', '0', '麻醉集合', '320', '0', '0', '0', '');
+INSERT INTO `kl_lexicon` (`id`, `is_deleted`, `gmt_create`, `gmt_modified`, `creator`, `modifier`, `name`, `code`, `is_has_common`, `only_one`, `can_change`, `remark`) VALUES ('65', 'N', '1970-01-01 12:00:00', '1970-01-01 12:00:00', '0', '0', '科室集合', '321', '0', '0', '0', '');
+INSERT INTO `kl_lexicon` (`id`, `is_deleted`, `gmt_create`, `gmt_modified`, `creator`, `modifier`, `name`, `code`, `is_has_common`, `only_one`, `can_change`, `remark`) VALUES ('66', 'N', '1970-01-01 12:00:00', '1970-01-01 12:00:00', '0', '0', '食物集合', '322', '0', '0', '0', '');
+INSERT INTO `kl_lexicon` (`id`, `is_deleted`, `gmt_create`, `gmt_modified`, `creator`, `modifier`, `name`, `code`, `is_has_common`, `only_one`, `can_change`, `remark`) VALUES ('67', 'N', '1970-01-01 12:00:00', '1970-01-01 12:00:00', '0', '0', '其他过敏原集合', '323', '0', '0', '0', '');
+INSERT INTO `kl_lexicon` (`id`, `is_deleted`, `gmt_create`, `gmt_modified`, `creator`, `modifier`, `name`, `code`, `is_has_common`, `only_one`, `can_change`, `remark`) VALUES ('68', 'N', '1970-01-01 12:00:00', '1970-01-01 12:00:00', '0', '0', '医疗器械及物品集合', '324', '0', '0', '0', '');
+INSERT INTO `kl_lexicon` (`id`, `is_deleted`, `gmt_create`, `gmt_modified`, `creator`, `modifier`, `name`, `code`, `is_has_common`, `only_one`, `can_change`, `remark`) VALUES ('69', 'N', '1970-01-01 12:00:00', '1970-01-01 12:00:00', '0', '0', '部位集合', '325', '0', '0', '0', '');
+INSERT INTO `kl_lexicon` (`id`, `is_deleted`, `gmt_create`, `gmt_modified`, `creator`, `modifier`, `name`, `code`, `is_has_common`, `only_one`, `can_change`, `remark`) VALUES ('70', 'N', '1970-01-01 12:00:00', '1970-01-01 12:00:00', '0', '0', '中医疾病集合', '326', '0', '0', '0', '');
+INSERT INTO `kl_lexicon` (`id`, `is_deleted`, `gmt_create`, `gmt_modified`, `creator`, `modifier`, `name`, `code`, `is_has_common`, `only_one`, `can_change`, `remark`) VALUES ('71', 'N', '1970-01-01 12:00:00', '1970-01-01 12:00:00', '0', '0', '中医证候集合', '327', '0', '0', '0', '');
+INSERT INTO `kl_lexicon` (`id`, `is_deleted`, `gmt_create`, `gmt_modified`, `creator`, `modifier`, `name`, `code`, `is_has_common`, `only_one`, `can_change`, `remark`) VALUES ('72', 'N', '1970-01-01 12:00:00', '1970-01-01 12:00:00', '0', '0', '诱因集合', '328', '0', '0', '0', '');

+ 174 - 42
src/main/java/com/diagbot/aggregate/RuleAggregate.java

@@ -7,6 +7,8 @@ import com.diagbot.dto.RuleConditionInitDTO;
 import com.diagbot.dto.RuleDTO;
 import com.diagbot.dto.RuleInitDTO;
 import com.diagbot.enums.RedisEnum;
+import com.diagbot.exception.CommonErrorCode;
+import com.diagbot.exception.CommonException;
 import com.diagbot.facade.KlRuleFacade;
 import com.diagbot.util.BeanUtil;
 import com.diagbot.util.EntityUtil;
@@ -18,6 +20,7 @@ import org.apache.commons.collections.MapUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -37,51 +40,75 @@ public class RuleAggregate {
     public Map<String, RuleDTO> getAllRules(
             @DataConsumer("getRuleInit") Map<String, List<RuleInitDTO>> ruleInits,
             @DataConsumer("getRuleConditionInit") Map<Integer, Map<String, List<RuleConditionInitDTO>>> ruleConditionInits,
-            @DataConsumer("getRuleBaseInit") Map<Integer, RuleBaseInitDTO> ruleBaseInits) {
-        Map<String, RuleDTO> res = new HashMap();
-        //结果判空第一层规则类型
-        if (MapUtils.isNotEmpty(ruleInits)) {
-            for (String ruleKey : ruleInits.keySet()) {
-                RuleInitDTO ruleInitZeroDTO = ruleInits.get(ruleKey).get(0);
-                RuleDTO ruleDTO = new RuleDTO();
-                ruleDTO.setLibName(ruleInitZeroDTO.getLibName());
-                ruleDTO.setLibType(ruleInitZeroDTO.getLibType());
-                ruleDTO.setRuleType(ruleInitZeroDTO.getRuleType());
-                for (RuleInitDTO ruleInitDTO : ruleInits.get(ruleKey)) {
-                    if (ruleInitDTO.getHasSubCond().equals(1)) {
-                        Map<String, List<RuleConditionInitDTO>> map = ruleConditionInits.get(ruleInitDTO.getRuleId());
-                        //结果判空第二层条件组别
-                        if (MapUtils.isNotEmpty(map)) {
-                            for (String key : map.keySet()) {
-                                RuleConditionDTO ruleConditionDTO = new RuleConditionDTO();
-                                ruleConditionDTO.setHasSubCond(ruleInitDTO.getHasSubCond());
-                                ruleConditionDTO.setRuleGroup(key);
-                                //结果判空第三层条件明细
-                                if (ListUtil.isNotEmpty(map.get(key))) {
-                                    for (RuleConditionInitDTO ruleConditionInitDTO : map.get(key)) {
-                                        ruleConditionDTO.setMsg(ruleConditionInitDTO.getMsg());
-                                        RuleBaseDTO ruleBaseDTO = new RuleBaseDTO();
-                                        BeanUtil.copyProperties(ruleBaseInits.get(ruleConditionInitDTO.getRuleBaseId()), ruleBaseDTO);
-                                        ruleConditionDTO.getRuleBaseDTOList().add(ruleBaseDTO);
+            @DataConsumer("getRuleBaseInit") Map<Integer, List<RuleBaseInitDTO>> ruleBaseInits) {
+        try {
+            Map<String, RuleDTO> res = new HashMap();
+            //结果判空第一层规则类型
+            if (MapUtils.isNotEmpty(ruleInits)) {
+                for (String ruleKey : ruleInits.keySet()) {
+                    RuleInitDTO ruleInitZeroDTO = ruleInits.get(ruleKey).get(0);
+                    RuleDTO ruleDTO = new RuleDTO();
+                    ruleDTO.setLibName(ruleInitZeroDTO.getLibName());
+                    ruleDTO.setLibType(ruleInitZeroDTO.getLibType());
+                    ruleDTO.setRuleType(ruleInitZeroDTO.getRuleType());
+                    Map<String, Integer> ruleConditionMap = new HashMap<>();
+                    for (RuleInitDTO ruleInitDTO : ruleInits.get(ruleKey)) {
+                        if (ruleInitDTO.getHasSubCond().equals(1)) {
+                            Map<String, List<RuleConditionInitDTO>> map = ruleConditionInits.get(ruleInitDTO.getRuleId());
+                            //结果判空第二层条件组别
+                            if (MapUtils.isNotEmpty(map)) {
+                                for (String ruleGroup : map.keySet()) {
+                                    RuleConditionDTO ruleConditionDTO = new RuleConditionDTO();
+                                    ruleConditionDTO.setHasSubCond(ruleInitDTO.getHasSubCond());
+                                    ruleConditionDTO.setRuleGroup(ruleGroup);
+                                    //结果判空第三层条件明细
+                                    if (ListUtil.isNotEmpty(map.get(ruleGroup))) {
+                                        List<List<RuleBaseDTO>> ruleBaseList = new ArrayList<>();
+                                        for (RuleConditionInitDTO ruleConditionInitDTO : map.get(ruleGroup)) {
+                                            ruleConditionDTO.setMsg(ruleConditionInitDTO.getMsg());
+                                            List<RuleBaseInitDTO> ruleBaseInitDTOList = ruleBaseInits.get(ruleConditionInitDTO.getRuleBaseId());
+                                            if (ListUtil.isNotEmpty(ruleBaseInitDTOList)) {
+                                                List<RuleBaseDTO> ruleBaseDTOList = BeanUtil.listCopyTo(ruleBaseInitDTOList, RuleBaseDTO.class);
+                                                ruleBaseList.add(ruleBaseDTOList);
+                                            }
+                                        }
+                                        //笛卡尔积
+                                        List<List<RuleBaseDTO>> ruleBaseGroup = new ArrayList<>();
+                                        descartes(ruleBaseList, ruleBaseGroup, 0, new ArrayList<>());
+                                        for (List<RuleBaseDTO> ruleBaseDTOList : ruleBaseGroup) {
+                                            RuleConditionDTO ruleConditionDTO1 = new RuleConditionDTO();
+                                            ruleConditionDTO1.setHasSubCond(ruleConditionDTO.getHasSubCond());
+                                            ruleConditionDTO1.setRuleGroup(ruleConditionDTO.getRuleGroup());
+                                            ruleConditionDTO1.setMsg(ruleConditionDTO.getMsg());
+                                            ruleConditionDTO1.getRuleBaseDTOList().addAll(ruleBaseDTOList);
+                                            if (!ruleConditionMap.containsKey(ruleConditionDTO1.toString())) {
+                                                ruleDTO.getRuleConditionDTOList().add(ruleConditionDTO1);
+                                                ruleConditionMap.put(ruleConditionDTO1.toString(), 1);
+                                            }
+                                        }
                                     }
                                 }
+                            }
+                        } else {
+                            RuleConditionDTO ruleConditionDTO = new RuleConditionDTO();
+                            ruleConditionDTO.setHasSubCond(ruleInitDTO.getHasSubCond());
+                            ruleConditionDTO.setMsg(ruleInitDTO.getMsg());
+                            //无条件
+                            ruleConditionDTO.setRuleGroup(ruleInitDTO.getRuleId() + "-1");
+                            ruleConditionDTO.getRuleBaseDTOList().add(new RuleBaseDTO());
+                            if (!ruleConditionMap.containsKey(ruleConditionDTO.toString())) {
                                 ruleDTO.getRuleConditionDTOList().add(ruleConditionDTO);
+                                ruleConditionMap.put(ruleConditionDTO.toString(), 1);
                             }
                         }
-                    } else {
-                        RuleConditionDTO ruleConditionDTO = new RuleConditionDTO();
-                        ruleConditionDTO.setHasSubCond(ruleInitDTO.getHasSubCond());
-                        ruleConditionDTO.setMsg(ruleInitDTO.getMsg());
-                        //无条件
-                        ruleConditionDTO.setRuleGroup(ruleInitDTO.getRuleId() + "-1");
-                        ruleConditionDTO.getRuleBaseDTOList().add(new RuleBaseDTO());
-                        ruleDTO.getRuleConditionDTOList().add(ruleConditionDTO);
                     }
+                    res.put(RedisEnum.allRule.getName() + ruleDTO.getLibType() + "_" + ruleDTO.getLibName() + "_" + ruleDTO.getRuleType(), ruleDTO);
                 }
-                res.put(RedisEnum.allRule.getName() + ruleDTO.getLibType() + "_" + ruleDTO.getLibName() + "_" + ruleDTO.getRuleType(), ruleDTO);
             }
+            return res;
+        } catch (Exception e) {
+            throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "全部规则加载出错:" + e.getMessage());
         }
-        return res;
     }
 
     @DataProvider("getRuleInit")
@@ -90,21 +117,126 @@ public class RuleAggregate {
         return EntityUtil.makeEntityListMap(list, "conceptGroup");
     }
 
+    //    @DataProvider("getRuleInit")
+    //    public Map<String, List<RuleInitDTO>> getRuleInit(
+    //            @DataConsumer("getRuleInitNotHaveClass") List<RuleInitDTO> ruleNotHaveClass,
+    //            @DataConsumer("getRuleInitHaveClass") List<RuleInitDTO> ruleHaveClass) {
+    //        List<RuleInitDTO> list = new ArrayList<>();
+    //        if (ListUtil.isNotEmpty(ruleNotHaveClass)) {
+    //            list.addAll(ruleNotHaveClass);
+    //        }
+    //        if (ListUtil.isNotEmpty(ruleHaveClass)) {
+    //            list.addAll(ruleHaveClass);
+    //        }
+    //        return EntityUtil.makeEntityListMap(list, "conceptGroup");
+    //    }
+
     @DataProvider("getRuleConditionInit")
     public Map<Integer, Map<String, List<RuleConditionInitDTO>>> getRuleConditionInit() {
         List<RuleConditionInitDTO> list = klRuleFacade.getRuleConditionInitDTO();
         Map<Integer, List<RuleConditionInitDTO>> map = EntityUtil.makeEntityListMap(list, "ruleId");
         Map<Integer, Map<String, List<RuleConditionInitDTO>>> res = new HashMap<>();
-        for (Integer key : map.keySet()) {
-            res.put(key, EntityUtil.makeEntityListMap(map.get(key), "ruleGroup"));
+        for (Integer ruleId : map.keySet()) {
+            res.put(ruleId, EntityUtil.makeEntityListMap(map.get(ruleId), "ruleGroup"));
         }
         return res;
     }
 
-
     @DataProvider("getRuleBaseInit")
-    public Map<Integer, RuleBaseInitDTO> getRuleBaseInit() {
-        List<RuleBaseInitDTO> list = klRuleFacade.getRuleBaseInitDTO();
-        return EntityUtil.makeEntityMap(list, "ruleBaseId");
+    public Map<Integer, List<RuleBaseInitDTO>> getRuleBaseInit(
+            @DataConsumer("getRuleBaseInitNotHaveClass") List<RuleBaseInitDTO> ruleBaseNotHaveClass,
+            @DataConsumer("getRuleBaseInitHaveClass") List<RuleBaseInitDTO> ruleBaseHaveClass) {
+        List<RuleBaseInitDTO> list = new ArrayList<>();
+        if (ListUtil.isNotEmpty(ruleBaseNotHaveClass)) {
+            list.addAll(ruleBaseNotHaveClass);
+        }
+        if (ListUtil.isNotEmpty(ruleBaseHaveClass)) {
+            list.addAll(ruleBaseHaveClass);
+        }
+        return EntityUtil.makeEntityListMap(list, "ruleBaseId");
+    }
+
+
+    @DataProvider("getRuleInitNotHaveClass")
+    public List<RuleInitDTO> getRuleInitNotHaveClass() {
+        return klRuleFacade.getRuleInitDTONotHaveClass();
+    }
+
+    @DataProvider("getRuleInitHaveClass")
+    public List<RuleInitDTO> getRuleInitHaveClass() {
+        return klRuleFacade.getRuleInitDTOHaveClass();
+    }
+
+    @DataProvider("getRuleBaseInitNotHaveClass")
+    public List<RuleBaseInitDTO> getRuleBaseInitNotHaveClass() {
+        return klRuleFacade.getRuleBaseInitDTONotHaveClass();
     }
+
+    @DataProvider("getRuleBaseInitHaveClass")
+    public List<RuleBaseInitDTO> getRuleBaseInitHaveClass() {
+        return klRuleFacade.getRuleBaseInitDTOHaveClass();
+    }
+
+    /**
+     * Discription: 笛卡尔乘积算法
+     * 把一个List{[1,2],[A,B],[a,b]} 转化成
+     * List{[1,A,a],[1,A,b],[1,B,a],[1,B,b],[2,A,a],[2,A,b],[2,B,a],[2,B,b]} 数组输出
+     *
+     * @param dimensionValue 原List
+     * @param result         通过乘积转化后的数组
+     * @param layer          中间参数
+     * @param currentList    中间参数
+     */
+    public static <T> void descartes(List<List<T>> dimensionValue, List<List<T>> result, int layer, List<T> currentList) {
+        if (layer < dimensionValue.size() - 1) {
+            if (dimensionValue.get(layer).size() == 0) {
+                descartes(dimensionValue, result, layer + 1, currentList);
+            } else {
+                for (int i = 0; i < dimensionValue.get(layer).size(); i++) {
+                    List<T> list = new ArrayList<T>(currentList);
+                    list.add(dimensionValue.get(layer).get(i));
+                    descartes(dimensionValue, result, layer + 1, list);
+                }
+            }
+        } else if (layer == dimensionValue.size() - 1) {
+            if (dimensionValue.get(layer).size() == 0) {
+                result.add(currentList);
+            } else {
+                for (int i = 0; i < dimensionValue.get(layer).size(); i++) {
+                    List<T> list = new ArrayList<T>(currentList);
+                    list.add(dimensionValue.get(layer).get(i));
+                    result.add(list);
+                }
+            }
+        }
+    }
+
+    public static void main(String[] args) {
+        List<List<RuleBaseDTO>> ruleBaseList = new ArrayList<>();
+        List<RuleBaseDTO> ruleBaseDTOListA = new ArrayList<>();
+        RuleBaseDTO baseDTOA = new RuleBaseDTO();
+        baseDTOA.setBaseLibName("A");
+        ruleBaseDTOListA.add(baseDTOA);
+        RuleBaseDTO baseDTOB = new RuleBaseDTO();
+        baseDTOB.setBaseLibName("B");
+        ruleBaseDTOListA.add(baseDTOB);
+        List<RuleBaseDTO> ruleBaseDTOListC = BeanUtil.listCopyTo(ruleBaseDTOListA, RuleBaseDTO.class);
+        ruleBaseList.add(ruleBaseDTOListC);
+        RuleBaseDTO baseDTOC = new RuleBaseDTO();
+        baseDTOC.setBaseLibName("C");
+        ruleBaseDTOListA.add(baseDTOC);
+        ruleBaseList.add(ruleBaseDTOListA);
+        List<RuleBaseDTO> ruleBaseDTOList1 = new ArrayList<>();
+        RuleBaseDTO baseDTO1 = new RuleBaseDTO();
+        baseDTO1.setBaseLibName("1");
+        ruleBaseDTOList1.add(baseDTO1);
+        RuleBaseDTO baseDTO2 = new RuleBaseDTO();
+        baseDTO2.setBaseLibName("2");
+        ruleBaseDTOList1.add(baseDTO2);
+        ruleBaseList.add(ruleBaseDTOList1);
+        List<List<RuleBaseDTO>> ruleBaseGroup = new ArrayList<>();
+        descartes(ruleBaseList, ruleBaseGroup, 0, new ArrayList<>());
+        System.out.println();
+    }
+
 }

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

@@ -33,8 +33,8 @@ public class CacheDeleteInit implements CommandLineRunner {
         cacheFacade.clear();
         log.info("CDSS-CORE服务启动清除redis缓存成功!");
 
-        cacheFacade.loadDrugTypeCache();
-        log.info("CDSS-CORE服务启动加载药品类型对应关系缓存成功!");
+//        cacheFacade.loadDrugTypeCache();
+//        log.info("CDSS-CORE服务启动加载药品类型对应关系缓存成功!");
 
         cacheFacade.getDiseaseCorrespondCache();
         log.info("CDSS-CORE服务启动加载疾病对应ICD10缓存成功!");

+ 2 - 0
src/main/java/com/diagbot/dto/RuleBaseDTO.java

@@ -2,6 +2,7 @@ package com.diagbot.dto;
 
 import lombok.Getter;
 import lombok.Setter;
+import lombok.ToString;
 
 /**
  * @Description:
@@ -10,6 +11,7 @@ import lombok.Setter;
  */
 @Getter
 @Setter
+@ToString(includeFieldNames = false)
 public class RuleBaseDTO {
     private String baseLibName = "";
     private Integer baseLibType = 0;

+ 2 - 0
src/main/java/com/diagbot/dto/RuleConditionDTO.java

@@ -2,6 +2,7 @@ package com.diagbot.dto;
 
 import lombok.Getter;
 import lombok.Setter;
+import lombok.ToString;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -13,6 +14,7 @@ import java.util.List;
  */
 @Getter
 @Setter
+@ToString(exclude = { "ruleGroup", "msg" }, includeFieldNames = false)
 public class RuleConditionDTO {
     private Integer hasSubCond;
     private String ruleGroup;

+ 49 - 46
src/main/java/com/diagbot/facade/CommonFacade.java

@@ -406,8 +406,8 @@ public class CommonFacade {
         //        // 3、开单辅检项目
         //        CoreUtil.setPropertyList(wordCrfDTO.getPacsOrder(), "name", "uniqueName", map.get(StandConvertEnum.pacs.toString()));
 
-//        CoreUtil.setUninameFromDetail(wordCrfDTO.getLis(), "detailName");
-//        CoreUtil.setUninameFromDetail(wordCrfDTO.getLisOrder(), "name");
+        //        CoreUtil.setUninameFromDetail(wordCrfDTO.getLis(), "detailName");
+        //        CoreUtil.setUninameFromDetail(wordCrfDTO.getLisOrder(), "name");
         lisGetAndSet(wordCrfDTO);
         pacsGetAndSet(wordCrfDTO);
 
@@ -439,7 +439,7 @@ public class CommonFacade {
      * 类型,疾病: disease,症状: symptom,手术和操作:operation,药品: drug,实验室检查:lis,辅助检查:pacs, 辅助检查:vital"
      *
      * @param standConvert
-     * @return Map<String,Map<String,String>> -->Map<类型, Map<原始词, 标准词>>
+     * @return Map<String , Map < String , String>> -->Map<类型, Map<原始词, 标准词>>
      */
     public Map<String, Map<String, String>> standConvertCrf(StandConvert standConvert) {
         Map<String, Map<String, String>> map = new LinkedHashMap<>();
@@ -664,25 +664,25 @@ public class CommonFacade {
                 .distinct()
                 .collect(Collectors.toList());
 
-//        Map<String, Map<String, Long>> configMap = new LinkedHashMap<>();
+        //        Map<String, Map<String, Long>> configMap = new LinkedHashMap<>();
         if (ListUtil.isNotEmpty(operationList)) {
-//            configMap = tranOperationConfigFacade.getConfigMap(wordCrfDTO.getHospitalId(), operationList, null);
+            //            configMap = tranOperationConfigFacade.getConfigMap(wordCrfDTO.getHospitalId(), operationList, null);
             Map<String, Map<String, Map<String, List<String>>>> operstionMap = mappingConfigFacade.groupByHisNameWithName(operationList, ConceptTypeEnum.Operation.getKey(), wordCrfDTO.getHospitalId());
             // 1、主诉手术
-//            setListProperty(wordCrfDTO.getChiefLabel(), "operations", "standName", configMap);
-            setListProperty(wordCrfDTO.getChiefLabel(), "operations", ConceptTypeEnum.Operation.getKey(),"StandName",operstionMap);
+            //            setListProperty(wordCrfDTO.getChiefLabel(), "operations", "standName", configMap);
+            setListProperty(wordCrfDTO.getChiefLabel(), "operations", ConceptTypeEnum.Operation.getKey(), "StandName", operstionMap);
             // 2、现病史手术
-//            setListProperty(wordCrfDTO.getPresentLabel(), "operations", "standName", configMap);
-            setListProperty(wordCrfDTO.getPresentLabel(),"operations", ConceptTypeEnum.Operation.getKey(),"StandName",operstionMap);
+            //            setListProperty(wordCrfDTO.getPresentLabel(), "operations", "standName", configMap);
+            setListProperty(wordCrfDTO.getPresentLabel(), "operations", ConceptTypeEnum.Operation.getKey(), "StandName", operstionMap);
             // 3、既往史手术
-//            setListProperty(wordCrfDTO.getPastLabel(), "operations", "standName", configMap);
-            setListProperty(wordCrfDTO.getPastLabel(),"operations", ConceptTypeEnum.Operation.getKey(),"StandName",operstionMap);
+            //            setListProperty(wordCrfDTO.getPastLabel(), "operations", "standName", configMap);
+            setListProperty(wordCrfDTO.getPastLabel(), "operations", ConceptTypeEnum.Operation.getKey(), "StandName", operstionMap);
             // 4、结构化手术
-//            setListProperty(wordCrfDTO, "operation", "uniqueName", configMap);
-            setListProperty(wordCrfDTO, "operation", ConceptTypeEnum.Operation.getKey(),"UniqueName",operstionMap);
+            //            setListProperty(wordCrfDTO, "operation", "uniqueName", configMap);
+            setListProperty(wordCrfDTO, "operation", ConceptTypeEnum.Operation.getKey(), "UniqueName", operstionMap);
             // 5、手术
-//            setListProperty(wordCrfDTO, "operationOrder", "uniqueName", configMap);
-            setListProperty(wordCrfDTO, "operationOrder", ConceptTypeEnum.Operation.getKey(),"UniqueName",operstionMap);
+            //            setListProperty(wordCrfDTO, "operationOrder", "uniqueName", configMap);
+            setListProperty(wordCrfDTO, "operationOrder", ConceptTypeEnum.Operation.getKey(), "UniqueName", operstionMap);
             // 6、选中手术
             if (wordCrfDTO.getOperationName() != null &&
                     StringUtil.isNotBlank(wordCrfDTO.getOperationName().getName()) &&
@@ -702,10 +702,10 @@ public class CommonFacade {
         List<String> pacsList = new ArrayList<>();
         // 1、结构化
         CoreUtil.addList(pacsList, CoreUtil.filterUniqueList(wordCrfDTO.getPacs()));
-//        // 2、开单
+        //        // 2、开单
         CoreUtil.addList(pacsList, CoreUtil.filterUniqueList(wordCrfDTO.getPacsOrder()));
         PacsLabel pacsLabel = wordCrfDTO.getPacsLabel();
-        if(pacsLabel != null){
+        if (pacsLabel != null) {
             pacsList = pacsLabel.getItem().stream()
                     .map(x -> x.getName())
                     .collect(Collectors.toList());
@@ -713,9 +713,9 @@ public class CommonFacade {
 
         if (ListUtil.isNotEmpty(pacsList)) {
             Map<String, Map<String, Map<String, List<String>>>> pacsMap = mappingConfigFacade.groupByHisNameWithName(pacsList, ConceptTypeEnum.Pacs.getKey(), wordCrfDTO.getHospitalId());
-            setListProperty(wordCrfDTO, "pacs", ConceptTypeEnum.Pacs.getKey(),"UniqueName",pacsMap);
-            setListProperty(wordCrfDTO, "pacsOrder", ConceptTypeEnum.Pacs.getKey(),"UniqueName",pacsMap);
-            setListProperty(pacsLabel, "item", ConceptTypeEnum.Pacs.getKey(),"UniqueName",pacsMap);
+            setListProperty(wordCrfDTO, "pacs", ConceptTypeEnum.Pacs.getKey(), "UniqueName", pacsMap);
+            setListProperty(wordCrfDTO, "pacsOrder", ConceptTypeEnum.Pacs.getKey(), "UniqueName", pacsMap);
+            setListProperty(pacsLabel, "item", ConceptTypeEnum.Pacs.getKey(), "UniqueName", pacsMap);
         }
     }
 
@@ -729,7 +729,7 @@ public class CommonFacade {
         List<String> lisHisNameList = Lists.newArrayList();
         // 【所有化验】
         List<Lis> lisList = wordCrfDTO.getLis();
-        if(ListUtil.isNotEmpty(lisList)){
+        if (ListUtil.isNotEmpty(lisList)) {
             lisHisNameList.addAll(lisList
                     .stream()
                     .filter(i -> StringUtil.isNotBlank(i.getName()) || StringUtil.isNotBlank(i.getUniqueName()))
@@ -742,7 +742,7 @@ public class CommonFacade {
                 .collect(Collectors.toList());
         if (ListUtil.isNotEmpty(lisHisNameList)) {
             Map<String, Map<String, Map<String, List<String>>>> lisConfigMap = mappingConfigFacade.groupByHisNameWithName(lisHisNameList, ConceptTypeEnum.LisPack.getKey(), wordCrfDTO.getHospitalId());
-            setListProperty(wordCrfDTO, "lis", ConceptTypeEnum.LisPack.getKey(),"UniqueName",lisConfigMap);
+            setListProperty(wordCrfDTO, "lis", ConceptTypeEnum.LisPack.getKey(), "UniqueName", lisConfigMap);
         }
 
     }
@@ -761,9 +761,9 @@ public class CommonFacade {
         ReflectUtil.setProperty(obj, listProperty, newList);
     }
 
-    public <T> void setListProperty(Object obj, String listProperty,Integer type,String propertyName, Map<String, Map<String, Map<String, List<String>>>> configMap) {
+    public <T> void setListProperty(Object obj, String listProperty, Integer type, String propertyName, Map<String, Map<String, Map<String, List<String>>>> configMap) {
         Object tList = CoreUtil.getFieldValue(obj, listProperty);
-        List<T> newList = convertStandName((List) tList,type, propertyName,configMap);
+        List<T> newList = convertStandName((List) tList, type, propertyName, configMap);
         ReflectUtil.setProperty(obj, listProperty, newList);
     }
 
@@ -825,7 +825,7 @@ public class CommonFacade {
      * @param <T>
      * @return
      */
-    public <T> List<T> convertStandName(List<T> list,Integer type,String propertyName, Map<String, Map<String, Map<String, List<String>>>> configMap) {
+    public <T> List<T> convertStandName(List<T> list, Integer type, String propertyName, Map<String, Map<String, Map<String, List<String>>>> configMap) {
         List<T> retList = new ArrayList<>();
         if (ListUtil.isEmpty(list)) {
             return list;
@@ -839,7 +839,7 @@ public class CommonFacade {
                     continue;
                 }
 
-//                String uniqueName = item.getClass().getMethod("getUniqueName").invoke(item).toString();
+                //                String uniqueName = item.getClass().getMethod("getUniqueName").invoke(item).toString();
 
                 String uniqueName = ReflectUtil.getProperty(item, "uniqueName");
                 if (StringUtil.isNotBlank(uniqueName) && !"StandName".equals(propertyName)) {
@@ -848,7 +848,7 @@ public class CommonFacade {
                 }
 
                 String hisDetailName = "";
-                if(type.equals(ConceptTypeEnum.LisPack.getKey())) {
+                if (type.equals(ConceptTypeEnum.LisPack.getKey())) {
                     hisDetailName = ReflectUtil.getProperty(item, "detailName");
                     if (StringUtil.isBlank(hisDetailName)) {
                         hisDetailName = "";
@@ -864,7 +864,7 @@ public class CommonFacade {
                                     for (String form : thirdEntry.getValue()) {
                                         T o = (T) item.getClass().newInstance();
                                         BeanUtil.copyProperties(item, o);
-                                        Method setUniqueName = o.getClass().getMethod("set"+propertyName, String.class);
+                                        Method setUniqueName = o.getClass().getMethod("set" + propertyName, String.class);
                                         setUniqueName.invoke(o, thirdEntry.getKey());
                                         Method setForm = o.getClass().getMethod("setForm", String.class);
                                         setForm.invoke(o, form);
@@ -873,7 +873,7 @@ public class CommonFacade {
                                 } else {
                                     T o = (T) item.getClass().newInstance();
                                     BeanUtil.copyProperties(item, o);
-                                    Method setUniqueName = o.getClass().getMethod("set"+propertyName, String.class);
+                                    Method setUniqueName = o.getClass().getMethod("set" + propertyName, String.class);
                                     setUniqueName.invoke(o, thirdEntry.getKey());
                                     retList.add(o);
                                 }
@@ -884,7 +884,7 @@ public class CommonFacade {
                             for (String stdName : standNames) {
                                 T o = (T) item.getClass().newInstance();
                                 BeanUtil.copyProperties(item, o);
-                                Method setUniqueName = o.getClass().getMethod("set"+propertyName, String.class);
+                                Method setUniqueName = o.getClass().getMethod("set" + propertyName, String.class);
                                 setUniqueName.invoke(o, stdName);
                                 retList.add(o);
                             }
@@ -894,7 +894,11 @@ public class CommonFacade {
                     }
                 } else {
                     if (propertyName.equals("UniqueName")) {
-                        BeanUtils.copyProperty(item, "uniqueName", name);
+                        if (StringUtil.isNotBlank(hisDetailName)) {
+                            BeanUtils.copyProperty(item, "uniqueName", hisDetailName);
+                        } else {
+                            BeanUtils.copyProperty(item, "uniqueName", name);
+                        }
                     }
                     retList.add(item);
                 }
@@ -1082,11 +1086,11 @@ public class CommonFacade {
         getPacsStruct(pacsLabel, wordCrfDTO.getPresentLabel().getPacsLabel());
         //结构化pacs
         List<com.diagbot.biz.push.entity.Pacs> pacs = wordCrfDTO.getPacs();
-        if(ListUtil.isNotEmpty(pacs)){
-            pacs.forEach(p ->{
+        if (ListUtil.isNotEmpty(pacs)) {
+            pacs.forEach(p -> {
                 Item item = new Item();
-                item.setName(p.getName()==null?"":p.getName());
-                item.setUniqueName(p.getUniqueName()==null?"":p.getUniqueName());
+                item.setName(p.getName() == null ? "" : p.getName());
+                item.setUniqueName(p.getUniqueName() == null ? "" : p.getUniqueName());
                 pacsLabel.getItem().add(item);
             });
         }
@@ -1122,8 +1126,8 @@ public class CommonFacade {
         if (ListUtil.isNotEmpty(res.getDisease())) {
             for (Pacs pacs : res.getDisease()) {
                 Item item = new Item();
-                item.setName(pacs.getName()==null?"":pacs.getName());
-                item.setUniqueName(pacs.getStandName()==null?"":pacs.getStandName());
+                item.setName(pacs.getName() == null ? "" : pacs.getName());
+                item.setUniqueName(pacs.getStandName() == null ? "" : pacs.getStandName());
                 pacsResList.add(item);
             }
         }
@@ -1163,18 +1167,17 @@ public class CommonFacade {
      *
      * @param lises
      * @param lisList
-     *
      */
     public void getLisStruct(List<com.diagbot.model.entity.Lis> lises, List<Lis> lisList) {
         if (ListUtil.isNotEmpty(lises)) {
-                lises.stream().forEach(x -> {
-                    String bigName = x.getBigItem().getName();//大项名
-                    String detailName = x.getName();//小项名
-                    String value = x.getPd().getValue();
-                    String unit = x.getPd().getUnit();
-                    String standName = x.getStandName();
-                    lisList.add(getLis(bigName,detailName,value,unit,standName));
-                });
+            lises.stream().forEach(x -> {
+                String bigName = x.getBigItem().getName();//大项名
+                String detailName = x.getName();//小项名
+                String value = x.getPd().getValue();
+                String unit = x.getPd().getUnit();
+                String standName = x.getStandName();
+                lisList.add(getLis(bigName, detailName, value, unit, standName));
+            });
         }
     }
 

+ 1 - 1
src/main/java/com/diagbot/facade/KlDiagnoseDetailFacade.java

@@ -312,6 +312,6 @@ public class KlDiagnoseDetailFacade {
         String pateern = "([1-9]\\d*\\.?\\d*)|(0\\.\\d*[1-9])";
         String content = formulas.stream().collect(Collectors.joining(","));
         //获取公式中的编码
-        return RegexUtil.getRegexDatas(content, pateern);
+        return RegexUtil.getRegexDataAll(content, pateern);
     }
 }

+ 8 - 0
src/main/java/com/diagbot/mapper/KlRuleMapper.java

@@ -38,4 +38,12 @@ public interface KlRuleMapper extends BaseMapper<KlRule> {
     List<RuleConditionInitDTO> getRuleConditionInitDTO();
 
     List<RuleBaseInitDTO> getRuleBaseInitDTO();
+
+    List<RuleInitDTO> getRuleInitDTONotHaveClass();
+
+    List<RuleInitDTO> getRuleInitDTOHaveClass();
+
+    List<RuleBaseInitDTO> getRuleBaseInitDTONotHaveClass();
+
+    List<RuleBaseInitDTO> getRuleBaseInitDTOHaveClass();
 }

+ 32 - 12
src/main/java/com/diagbot/rule/GroupRule.java

@@ -6,9 +6,11 @@ import com.diagbot.dto.RuleBaseDTO;
 import com.diagbot.dto.RuleSimpleDTO;
 import com.diagbot.dto.WordCrfDTO;
 import com.diagbot.util.CoreUtil;
+import com.diagbot.util.ListUtil;
 import com.diagbot.util.MsgNewUtil;
 import com.diagbot.util.RegexUtil;
 import com.diagbot.util.StringUtil;
+import com.google.common.collect.Lists;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
@@ -80,9 +82,11 @@ public class GroupRule {
         String menstrual = wordCrfDTO.getMenstrual(); // 月经史
         String marriage = wordCrfDTO.getMarriage(); // 婚姻
         String marital = wordCrfDTO.getMarital();// 婚育史
+        String pasts = wordCrfDTO.getPasts(); // 既往史
         boolean flag = false;
         String regex = "";
         String regex2 = "";
+        List<String> groupList = Lists.newArrayList(); // 分组信息
         List<String> nameList = CoreUtil.getSplit(ruleBaseDTO.getBaseLibName());
         for (String name : nameList) {
             switch (name) {
@@ -135,23 +139,39 @@ public class GroupRule {
                         flag = true;
                     }
                     break;
-                case "未经产妇":
+                case "未经产妇": // 女性+(婚育史或既往史)数值累加为0
                     regex = "(\\d+)-(\\d+)-(\\d+)-(\\d+)";
-                    if (sex == 2 && StringUtil.isNotBlank(marital) && RegexUtil.getRegexRes(marital, regex)) {
-                        if (Integer.parseInt(RegexUtil.getRegexData(marital, regex, 1))
-                                + Integer.parseInt(RegexUtil.getRegexData(marital, regex, 2))
-                                + Integer.parseInt(RegexUtil.getRegexData(marital, regex, 3)) == 0) {
-                            flag = true;
+                    if (sex == 2) {
+                        if (StringUtil.isNotBlank(marital) && RegexUtil.getRegexRes(marital, regex)) {
+                            // 婚育史判断
+                            groupList = RegexUtil.getRegexDataList(marital, regex);
+                        } else if (StringUtil.isNotBlank(pasts) && RegexUtil.getRegexRes(pasts, regex)) {
+                            // 既往史判断
+                            groupList = RegexUtil.getRegexDataList(pasts, regex);
+                        }
+                        if (ListUtil.isNotEmpty(groupList) && groupList.size() == 4) {
+                            if (Integer.parseInt(groupList.get(0)) + Integer.parseInt(groupList.get(1))
+                                    + Integer.parseInt(groupList.get(2)) == 0) {
+                                flag = true;
+                            }
                         }
                     }
                     break;
-                case "经产妇":
+                case "经产妇": // 女性+(婚育史或既往史)数值累加>=1
                     regex = "(\\d+)-(\\d+)-(\\d+)-(\\d+)";
-                    if (sex == 2 && StringUtil.isNotBlank(marital) && RegexUtil.getRegexRes(marital, regex)) {
-                        if (Integer.parseInt(RegexUtil.getRegexData(marital, regex, 1))
-                                + Integer.parseInt(RegexUtil.getRegexData(marital, regex, 2))
-                                + Integer.parseInt(RegexUtil.getRegexData(marital, regex, 3)) >= 1) {
-                            flag = true;
+                    if (sex == 2) {
+                        if (StringUtil.isNotBlank(marital) && RegexUtil.getRegexRes(marital, regex)) {
+                            // 婚育史判断
+                            groupList = RegexUtil.getRegexDataList(marital, regex);
+                        } else if (StringUtil.isNotBlank(pasts) && RegexUtil.getRegexRes(pasts, regex)) {
+                            // 既往史判断
+                            groupList = RegexUtil.getRegexDataList(pasts, regex);
+                        }
+                        if (ListUtil.isNotEmpty(groupList) && groupList.size() == 4) {
+                            if (Integer.parseInt(groupList.get(0)) + Integer.parseInt(groupList.get(1))
+                                    + Integer.parseInt(groupList.get(2)) >= 1) {
+                                flag = true;
+                            }
                         }
                     }
                     break;

+ 8 - 0
src/main/java/com/diagbot/service/KlRuleService.java

@@ -34,4 +34,12 @@ public interface KlRuleService extends IService<KlRule> {
     List<RuleConditionInitDTO> getRuleConditionInitDTO();
 
     List<RuleBaseInitDTO> getRuleBaseInitDTO();
+
+    List<RuleInitDTO> getRuleInitDTONotHaveClass();
+
+    List<RuleInitDTO> getRuleInitDTOHaveClass();
+
+    List<RuleBaseInitDTO> getRuleBaseInitDTONotHaveClass();
+
+    List<RuleBaseInitDTO> getRuleBaseInitDTOHaveClass();
 }

+ 21 - 0
src/main/java/com/diagbot/service/impl/KlRuleServiceImpl.java

@@ -61,4 +61,25 @@ public class KlRuleServiceImpl extends ServiceImpl<KlRuleMapper, KlRule> impleme
     public List<RuleBaseInitDTO> getRuleBaseInitDTO(){
         return baseMapper.getRuleBaseInitDTO();
     }
+
+
+    @Override
+    public List<RuleInitDTO> getRuleInitDTONotHaveClass(){
+        return baseMapper.getRuleInitDTONotHaveClass();
+    }
+
+    @Override
+    public List<RuleInitDTO> getRuleInitDTOHaveClass(){
+        return baseMapper.getRuleInitDTOHaveClass();
+    }
+
+    @Override
+    public List<RuleBaseInitDTO> getRuleBaseInitDTONotHaveClass(){
+        return baseMapper.getRuleBaseInitDTONotHaveClass();
+    }
+
+    @Override
+    public List<RuleBaseInitDTO> getRuleBaseInitDTOHaveClass(){
+        return baseMapper.getRuleBaseInitDTOHaveClass();
+    }
 }

+ 1 - 0
src/main/java/com/diagbot/util/Content.java

@@ -311,5 +311,6 @@ public class Content {
             "yyyy-MM-ddHH:mm:ss.000",
             "yyyyMMddHH:mm",
             "yyyy-MM-dd'T'HH:mm:ss",
+            "MM/dd/yyyyHH:mm:ss"
     };
 }

+ 72 - 47
src/main/java/com/diagbot/util/RegexUtil.java

@@ -40,16 +40,12 @@ public class RegexUtil {
     /**
      * 是否有符合正则的数据(大小写敏感)
      *
-     * @param content 文本内容
-     * @param regex   表达式
-     * @param senstive 大小写是否敏感
+     * @param content  文本内容
+     * @param regex    表达式
      * @return
      */
-    public static Boolean getRegexRes(String content, String regex, boolean senstive) {
-        if (senstive) {
-            return getRegexResCommon(content, regex, true);
-        }
-        return getRegexResCommon(content, regex, false);
+    public static Boolean getRegexResSen(String content, String regex) {
+        return getRegexResCommon(content, regex, true);
     }
 
     /**
@@ -79,7 +75,7 @@ public class RegexUtil {
     /**
      * 获取pattern
      *
-     * @param regex 正则表达式
+     * @param regex     正则表达式
      * @param sensitive 大小写敏感
      * @return
      */
@@ -94,7 +90,7 @@ public class RegexUtil {
     }
 
     /**
-     * 根据正则获取指定分组数据(大小写不敏感)
+     * 根据正则获取第一个匹配的指定分组数据(大小写不敏感)
      *
      * @param content  文本内容
      * @param regex    表达式
@@ -106,22 +102,19 @@ public class RegexUtil {
     }
 
     /**
-     * 根据正则获取指定分组数据(大小写敏感)
+     * 根据正则获取第一个匹配的指定分组数据(大小写敏感)
      *
      * @param content  文本内容
      * @param regex    表达式
      * @param groupNum 获取第几个内容
      * @return
      */
-    public static String getRegexData(String content, String regex, Integer groupNum, Boolean sensitive) {
-        if (sensitive) {
-            return getRegexDataCommon(content, regex, groupNum, true);
-        }
-        return getRegexDataCommon(content, regex, groupNum, false);
+    public static String getRegexDataSen(String content, String regex, Integer groupNum) {
+        return getRegexDataCommon(content, regex, groupNum, true);
     }
 
     /**
-     * 根据正则获取指定分组数据(公共方法)
+     * 根据正则获取第一个匹配的指定分组数据(公共方法)
      *
      * @param content  文本内容
      * @param regex    表达式
@@ -148,38 +141,35 @@ public class RegexUtil {
     }
 
     /**
-     * 根据正则获取所有分组数据(大小写不敏感)
+     * 根据正则获取第一个匹配的所有分组数据(大小写不敏感)
      *
      * @param content
      * @param regex
      * @return
      */
-    public static List<String> getRegexData(String content, String regex) {
-        return getRegexDataCommon(content, regex, false);
+    public static List<String> getRegexDataList(String content, String regex) {
+        return getRegexDataListCommon(content, regex, false);
     }
 
     /**
-     * 根据正则获取所有分组数据(大小写敏感)
+     * 根据正则获取第一个匹配的所有分组数据(大小写敏感)
      *
      * @param content
      * @param regex
      * @return
      */
-    private static List<String> getRegexData(String content, String regex, Boolean sensitive) {
-        if (sensitive) {
-            getRegexDataCommon(content, regex, true);
-        }
-        return getRegexDataCommon(content, regex, false);
+    public static List<String> getRegexDataListSen(String content, String regex) {
+        return getRegexDataListCommon(content, regex, true);
     }
 
     /**
-     * 根据正则获取所有分组数据(内部方法)
+     * 根据正则获取第一个匹配的所有分组数据(内部方法)
      *
      * @param content
      * @param regex
      * @return
      */
-    private static List<String> getRegexDataCommon(String content, String regex, Boolean sensitive) {
+    private static List<String> getRegexDataListCommon(String content, String regex, Boolean sensitive) {
         List<String> list = Lists.newArrayList();
         try {
             if (StringUtil.isBlank(content)) {
@@ -198,18 +188,51 @@ public class RegexUtil {
         return list;
     }
 
-    public static List<String> getRegexDatas(String content, String pattern){
-        List<String> numbers=new ArrayList<>();
-        // 创建 Pattern 对象
-        Pattern r = Pattern.compile(pattern);
-        // 现在创建 matcher 对象
-        Matcher matcher = r.matcher(content);
-        while (matcher.find()) {
-            //获取当前匹配的值
-            numbers.add(matcher.group());
-        }
+    /**
+     * 根据正则获取所有匹配数据(大小写不敏感)
+     *
+     * @param content
+     * @param regex
+     * @return
+     */
+    public static List<String> getRegexDataAll(String content, String regex) {
+        return getRegexDataAllCommon(content, regex, false);
+    }
 
-        return numbers;
+    /**
+     * 根据正则获取所有匹配数据(大小写敏感)
+     *
+     * @param content
+     * @param regex
+     * @return
+     */
+    public static List<String> getRegexDataAllSen(String content, String regex) {
+        return getRegexDataAllCommon(content, regex, true);
+    }
+
+    /**
+     * 根据正则获取所有匹配数据(内部方法)
+     *
+     * @param content
+     * @param regex
+     * @return
+     */
+    private static List<String> getRegexDataAllCommon(String content, String regex, Boolean sensitive) {
+        List<String> list = Lists.newArrayList();
+        try {
+            if (StringUtil.isBlank(content)) {
+                return list;
+            }
+            Pattern pattern = getPattern(regex, sensitive);
+            Matcher matcher = pattern.matcher(content);
+            while (matcher.find()) {
+                //获取当前匹配的值
+                list.add(matcher.group());
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return list;
     }
 
     /**
@@ -218,19 +241,21 @@ public class RegexUtil {
      * @param args
      */
     public static void main(String[] args) {
-        String regex1 = "([1-9]\\d*\\.?\\d*)|(0\\.\\d*[1-9])";
-        // System.out.println(getRegexData("血小板计数  30.3", regex1, 2));
-        System.out.println(getRegexData("拟诊+(3.3/3.4)任一", regex1));
+        String str = "1-2-3-4, 法法,0-0-1-0";
+        String regex = "(\\d+)-(\\d+)-(\\d+)-(\\d+)";
+        System.out.println(getRegexDataList(str, regex));
 
-        String s1 = "ABC";
-        System.out.println(getRegexRes(s1, "Abc", true));
+        // String regex1 = "([1-9]\\d*\\.?\\d*)|(0\\.\\d*[1-9])";
+        // // System.out.println(getRegexData("血小板计数  30.3", regex1, 2));
+        // System.out.println(getRegexData("拟诊+(3.3/3.4)任一", regex1));
+        //
+        // String s1 = "ABC";
+        // System.out.println(getRegexRes(s1, "Abc", true));
 
-        System.out.println(getRegexDatas("拟诊+(3.3/3.4)任一","([1-9]\\d*\\.?\\d*)|(0\\.\\d*[1-9])"));
+        System.out.println(getRegexDataAll("拟诊+(3.3/3.4)任一", "([1-9]\\d*\\.?\\d*)|(0\\.\\d*[1-9])"));
 
         ArrayList<String> js = Lists.newArrayList("G.4", "G.1", "G.2", "G.3");
         List<String> collect = js.stream().sorted().collect(Collectors.toList());
         System.out.println(collect);
-
-
     }
 }

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

@@ -38,7 +38,7 @@ public class CacheController {
     @SysLogger("clear")
     public RespDTO<Boolean> clear() {
         cacheFacade.clear();
-        cacheFacade.loadDrugTypeCache();
+//        cacheFacade.loadDrugTypeCache();
         cacheFacade.getDiseaseCorrespondCache();
         cacheFacade.getdiseaseFilterCache();
         cacheFacade.loadPushModel(); // 重新加载推送类型
@@ -116,7 +116,7 @@ public class CacheController {
     public RespDTO<Boolean> clearStandRuleDrugAll() {
         cacheFacade.clearStandConvert();
         cacheFacade.loadAllRuleCache();
-        cacheFacade.loadDrugTypeCache();
+//        cacheFacade.loadDrugTypeCache();
         cacheFacade.loadAllBaseDiagnoseCache();
         // 加载大数据缓存
         boolean flag = cacheFacade.reloadPushDB();

+ 182 - 17
src/main/resources/mapper/KlRuleMapper.xml

@@ -159,7 +159,7 @@
         <if test="parStatus!=null">
             AND ru.status = #{parStatus}
         </if>
-        ORDER BY ru.status DESC ,ru.gmt_modified DESC
+        ORDER BY ru.status DESC ,ru.gmt_modified DESC,ru.id DESC
     </select>
     <select id="getByIdRuleInfo" resultType="com.diagbot.dto.KlRuleByIdDTO">
         SELECT
@@ -299,6 +299,115 @@
     </select>
 
     <select id="getRuleInitDTO" resultType="com.diagbot.dto.RuleInitDTO">
+        SELECT
+            *
+        FROM
+            (
+                SELECT
+                    t1.concept_id AS conceptId,
+                    CONCAT_WS(
+                        "_",
+                        t1.concept_id,
+                        t1.rule_type
+                    ) AS conceptGroup,
+                    t1.id AS ruleId,
+                    t4.lib_name AS libName,
+                    t4.lib_type AS libType,
+                    t1.rule_type AS ruleType,
+                    t1.has_sub_cond AS hasSubCond,
+                    t1.msg AS msg,
+                    t1.gmt_modified AS gmtModified
+                FROM
+                    kl_rule t1,
+                    kl_concept t4
+                WHERE
+                    t1.is_deleted = "N"
+                AND t4.is_deleted = "N"
+                AND t1.concept_id = t4.id
+                AND t1. STATUS = 1
+                AND t4. STATUS = 1
+                AND t4.lib_type BETWEEN 100 AND 299
+                UNION
+                    SELECT
+                        t11.id AS conceptId,
+                        CONCAT_WS("_", t11.id, t1.rule_type) AS conceptGroup,
+                        t1.id AS ruleId,
+                        t11.lib_name AS libName,
+                        t11.lib_type AS libType,
+                        t1.rule_type AS ruleType,
+                        t1.has_sub_cond AS hasSubCond,
+                        t1.msg AS msg,
+                        t1.gmt_modified AS gmtModified
+                    FROM
+                        kl_rule t1,
+                        kl_concept t4,
+                        kl_relation t10,
+                        kl_concept t11
+                    WHERE
+                        t1.is_deleted = "N"
+                    AND t4.is_deleted = "N"
+                    AND t1.concept_id = t4.id
+                    AND t1. STATUS = 1
+                    AND t4. STATUS = 1
+                    AND t4.lib_type BETWEEN 300 AND 399
+                    AND t10.start_id = t4.id
+                    AND t10.relation_id = 600
+                    AND t10.end_id = t11.id
+                    AND t11.lib_type BETWEEN 100 AND 299
+                    AND t10.is_deleted = "N"
+                    AND t11.is_deleted = "N"
+                    AND t10. STATUS = 1
+                    AND t11. STATUS = 1
+            ) t12
+        ORDER BY
+            t12.conceptId,
+            t12.ruleType,
+            t12.hasSubCond,
+            t12.gmtModified DESC,
+            t12.ruleId DESC
+    </select>
+
+    <select id="getRuleConditionInitDTO" resultType="com.diagbot.dto.RuleConditionInitDTO">
+        SELECT
+            t2.rule_id AS ruleId,
+            CONCAT_WS("-", t2.rule_id, t2.group_type) AS ruleGroup,
+            t2.rule_base_id as ruleBaseId,
+            t2.msg as msg
+        FROM
+            kl_rule_condition t2
+        WHERE
+            t2.is_deleted = "N"
+        ORDER BY
+            t2.id DESC
+    </select>
+
+    <select id="getRuleBaseInitDTO" resultType="com.diagbot.dto.RuleBaseInitDTO">
+        SELECT
+            t3.id as ruleBaseId,
+            t5.lib_name AS baseLibName,
+            t5.lib_type AS baseLibType,
+            t3.type AS baseType,
+            t3.min_operator AS baseMinOperator,
+            t3.min_value AS baseMinValue,
+            t3.min_unit AS baseMinUnit,
+            t3.max_operator AS baseMaxOperator,
+            t3.max_value AS baseMaxValue,
+            t3.max_unit AS baseMaxUnit,
+            t3.eq_operator AS baseEqOperator,
+            t3.eq_value AS baseEqValue,
+            t3.eq_unit AS baseEqUnit
+        FROM
+            kl_rule_base t3,
+            kl_concept t5
+        WHERE
+            t3.is_deleted = "N"
+        AND t5.is_deleted = "N"
+        AND t3. STATUS = 1
+        AND t5. STATUS = 1
+        AND t3.concept_id = t5.id
+    </select>
+
+    <select id="getRuleInitDTONotHaveClass" resultType="com.diagbot.dto.RuleInitDTO">
         SELECT
             CONCAT_WS("_",t1.concept_id,t1.rule_type) AS conceptGroup,
             t1.id AS ruleId,
@@ -316,29 +425,43 @@
         AND t1.concept_id = t4.id
         AND t1. STATUS = 1
         AND t4. STATUS = 1
-        ORDER BY
-            t1.concept_id,
-            t1.rule_type,
-            t1.has_sub_cond
+        AND t4.lib_type BETWEEN 100 AND 299
     </select>
 
-    <select id="getRuleConditionInitDTO" resultType="com.diagbot.dto.RuleConditionInitDTO">
+    <select id="getRuleInitDTOHaveClass" resultType="com.diagbot.dto.RuleInitDTO">
         SELECT
-            t2.rule_id AS ruleId,
-            CONCAT_WS("-", t2.rule_id, t2.group_type) AS ruleGroup,
-            t2.rule_base_id as ruleBaseId,
-            t2.msg as msg
+            CONCAT_WS("_", t11.id, t1.rule_type) AS conceptGroup,
+            t1.id AS ruleId,
+            t11.lib_name AS libName,
+            t11.lib_type AS libType,
+            t1.rule_type AS ruleType,
+            t1.msg AS msg,
+            t1.has_sub_cond AS hasSubCond
         FROM
-            kl_rule_condition t2
-        ORDER BY
-            t2.rule_id,
-            t2.group_type,
-            t2.rule_base_id
+            kl_rule t1,
+            kl_concept t4,
+            kl_relation t10,
+            kl_concept t11
+        WHERE
+            t1.is_deleted = "N"
+        AND t4.is_deleted = "N"
+        AND t1.concept_id = t4.id
+        AND t1. STATUS = 1
+        AND t4. STATUS = 1
+        AND t4.lib_type BETWEEN 300 AND 399
+        AND t10.start_id = t4.id
+        AND t10.relation_id = 600
+        AND t10.end_id = t11.id
+        AND t11.lib_type BETWEEN 100 AND 299
+        AND t10.is_deleted = "N"
+        AND t11.is_deleted = "N"
+        AND t10. STATUS = 1
+        AND t11. STATUS = 1
     </select>
 
-    <select id="getRuleBaseInitDTO" resultType="com.diagbot.dto.RuleBaseInitDTO">
+    <select id="getRuleBaseInitDTONotHaveClass" resultType="com.diagbot.dto.RuleBaseInitDTO">
         SELECT
-            t3.id as ruleBaseId,
+            t3.id AS ruleBaseId,
             t5.lib_name AS baseLibName,
             t5.lib_type AS baseLibType,
             t3.type AS baseType,
@@ -360,5 +483,47 @@
         AND t3. STATUS = 1
         AND t5. STATUS = 1
         AND t3.concept_id = t5.id
+        AND (t5.lib_type BETWEEN 100 AND 299
+		OR t5.lib_type= 410)
+        ORDER BY t5.id
+    </select>
+
+    <select id="getRuleBaseInitDTOHaveClass" resultType="com.diagbot.dto.RuleBaseInitDTO">
+        SELECT
+            t3.id AS ruleBaseId,
+            t11.lib_name AS baseLibName,
+            t11.lib_type AS baseLibType,
+            t3.type AS baseType,
+            t3.min_operator AS baseMinOperator,
+            t3.min_value AS baseMinValue,
+            t3.min_unit AS baseMinUnit,
+            t3.max_operator AS baseMaxOperator,
+            t3.max_value AS baseMaxValue,
+            t3.max_unit AS baseMaxUnit,
+            t3.eq_operator AS baseEqOperator,
+            t3.eq_value AS baseEqValue,
+            t3.eq_unit AS baseEqUnit
+        FROM
+            kl_rule_base t3,
+            kl_concept t5,
+            kl_relation t10,
+            kl_concept t11
+        WHERE
+            t3.is_deleted = "N"
+        AND t5.is_deleted = "N"
+        AND t3. STATUS = 1
+        AND t5. STATUS = 1
+        AND t3.concept_id = t5.id
+        AND t5.lib_type BETWEEN 300 AND 399
+        AND t10.start_id = t5.id
+        AND t10.relation_id = 600
+        AND t10.end_id = t11.id
+        AND (t11.lib_type BETWEEN 100 AND 299
+		OR t11.lib_type = 410)
+        AND t10.is_deleted = "N"
+        AND t11.is_deleted = "N"
+        AND t10. STATUS = 1
+        AND t11. STATUS = 1
+        ORDER BY t11.id
     </select>
 </mapper>