ソースを参照

Merge branch 'master' into his/yiwufubao

liuqq 3 年 前
コミット
58ae3f2dc8

+ 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;

+ 3 - 3
src/main/java/com/diagbot/facade/CommonFacade.java

@@ -833,7 +833,7 @@ public class CommonFacade {
 
         try {
             for (T item : list) {
-                String name = item.getClass().getMethod("getName").invoke(item).toString();
+                String name = ReflectUtil.getProperty(item, "name");
                 if (StringUtil.isBlank(name)) {
                     retList.add(item);
                     continue;
@@ -841,7 +841,7 @@ public class CommonFacade {
 
 //                String uniqueName = item.getClass().getMethod("getUniqueName").invoke(item).toString();
 
-                String uniqueName = item.getClass().getMethod("get"+propertyName).invoke(item).toString();
+                String uniqueName = ReflectUtil.getProperty(item, "uniqueName");
                 if (StringUtil.isNotBlank(uniqueName) && !"StandName".equals(propertyName)) {
                     retList.add(item);
                     continue;
@@ -849,7 +849,7 @@ public class CommonFacade {
 
                 String hisDetailName = "";
                 if(type.equals(ConceptTypeEnum.LisPack.getKey())) {
-                    hisDetailName = item.getClass().getMethod("getDetailName").invoke(item).toString();
+                    hisDetailName = ReflectUtil.getProperty(item, "detailName");
                     if (StringUtil.isBlank(hisDetailName)) {
                         hisDetailName = "";
                     }

+ 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();
 }

+ 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();
+    }
 }

+ 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>