zhoutg 4 роки тому
батько
коміт
c62f9d4dde

+ 4 - 1
cdssman-service/src/main/java/com/diagbot/enums/RelationLibTypeEnum.java

@@ -20,7 +20,10 @@ public enum RelationLibTypeEnum implements KeyedNamed {
     disOperator(507, "106"),
     disDifferentDis(508, "100"),
     disLiangbiao(509,"124"),
-    disNurse(510,"123");
+    disNurse(510,"123"),
+    relationDept(511,"115"),
+    relationPart(512,"122"),
+    relationSystem(513,"411");
 
 
     @Setter

+ 2 - 3
cdssman-service/src/main/java/com/diagbot/facade/KlConceptFacade.java

@@ -88,6 +88,7 @@ public class KlConceptFacade extends KlConceptServiceImpl {
     @Autowired
     KlDrugFacade klDrugFacade;
 
+
     /**
      * @param klConceptInfoVO
      * @return
@@ -292,9 +293,7 @@ public class KlConceptFacade extends KlConceptServiceImpl {
             if (ListUtil.isNotEmpty(klConceptSub)) {
                 for (KlConceptSaveSubVO subVO : klConceptSub) {
                     if (subVO.getLibId() == null) {
-
                         klLibraryInfoFacade.checkLibraryInfoData(subVO);
-
                         res = klLibraryInfoFacade.savekLibraryInfoData(klConceptPare.getId(), subVO);
                     }
                 }
@@ -304,9 +303,9 @@ public class KlConceptFacade extends KlConceptServiceImpl {
         // 更新疾病扩展表 kl_disease
         if (LexiconEnum.Disease.getKey() == klConceptSaveVO.getLibType().intValue()) {
             res = klDiseaseFacade.saveAll(commonParam, klConceptSaveVO.getKlDiseaseVO());
+            klRelationFacade.saveKlDisease(commonParam, klConceptSaveVO.getKlDiseaseVO());
         }
 
-
         return res;
     }
 

+ 107 - 0
cdssman-service/src/main/java/com/diagbot/facade/KlRelationFacade.java

@@ -1,18 +1,30 @@
 package com.diagbot.facade;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.diagbot.dto.RelationDTO;
 import com.diagbot.dto.TreeAllDTO;
 import com.diagbot.dto.TreeDTO;
+import com.diagbot.entity.CommonParam;
+import com.diagbot.entity.KlRelation;
+import com.diagbot.entity.KlRelationOrder;
+import com.diagbot.enums.RelationLibTypeEnum;
+import com.diagbot.service.KlRelationOrderService;
+import com.diagbot.service.KlRelationService;
 import com.diagbot.service.impl.KlRelationServiceImpl;
 import com.diagbot.util.EntityUtil;
 import com.diagbot.util.ListUtil;
+import com.diagbot.vo.KlDiseaseVO;
 import com.diagbot.vo.RelationVO;
 import com.diagbot.vo.TreeVO;
+import com.google.common.collect.Lists;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.stereotype.Component;
 
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
+import java.util.stream.Collectors;
 
 /**
  * @Description:
@@ -21,6 +33,15 @@ import java.util.Map;
  */
 @Component
 public class KlRelationFacade extends KlRelationServiceImpl {
+
+    @Autowired
+    @Qualifier("klRelationOrderServiceImpl")
+    KlRelationOrderService klRelationOrderService;
+
+    @Autowired
+    @Qualifier("klRelationServiceImpl")
+    KlRelationService klRelationService;
+
     public TreeAllDTO getTree(TreeVO treeVO) {
         List<Long[]> pList = new ArrayList<>();
         pList.add(new Long[] { 402L, 600L, 301L, 600L, 101L });//药品化学物质类别
@@ -78,4 +99,90 @@ public class KlRelationFacade extends KlRelationServiceImpl {
         }
         return treeAllDTO;
     }
+
+    /**
+     * 疾病扩展
+     *
+     * @param commonParam
+     * @param klDiseaseVO
+     */
+    public void saveKlDisease(CommonParam commonParam, KlDiseaseVO klDiseaseVO) {
+        // 疾病关联科室,部位,关联系统统一处理。先查找全部数据,删除关联排序表,再删除关联表
+        List<Integer> relationIdList = Lists.newArrayList(
+                RelationLibTypeEnum.relationDept.getKey(),
+                RelationLibTypeEnum.relationPart.getKey(),
+                RelationLibTypeEnum.relationSystem.getKey()
+        );
+        klRelationRemove(commonParam, relationIdList);
+
+        if (klDiseaseVO != null) {
+            // 【科室关联】
+            klRelationSave(commonParam, klDiseaseVO.getDeptList(), RelationLibTypeEnum.relationDept.getKey());
+            // 【部位关联】
+            klRelationSave(commonParam, klDiseaseVO.getPartList(), RelationLibTypeEnum.relationPart.getKey());
+            // 【疾病系统分类关联】
+            klRelationSave(commonParam, klDiseaseVO.getSystemTypeList(), RelationLibTypeEnum.relationSystem.getKey());
+        }
+    }
+
+    /**
+     * 删除关联表和关联排序表
+     *
+     * @param commonParam 通用参数
+     * @param relationList 关联类型列表
+     */
+    public void klRelationRemove(CommonParam commonParam, List<Integer> relationList) {
+        List<KlRelation> klRelationList = this.list(new QueryWrapper<KlRelation>()
+                .eq("start_id", commonParam.getConceptId())
+                .in("relation_id", relationList)
+        );
+        if (ListUtil.isNotEmpty(klRelationList)) {
+            List<Long> idList = klRelationList.stream().map(r -> r.getId()).collect(Collectors.toList());
+            // 删除关联排序表
+            klRelationOrderService.remove(new QueryWrapper<KlRelationOrder>().in("t_relation_id", idList));
+            // 删除关联表
+            this.remove(new QueryWrapper<KlRelation>().in("id", idList));
+        }
+    }
+
+    /**
+     * 保存关联表和关联排序表
+     *
+     * @param commonParam
+     * @param idList
+     * @param relationId
+     */
+    public void klRelationSave(CommonParam commonParam, List<Long> idList, Integer relationId) {
+        if (ListUtil.isEmpty(idList)) {
+            return;
+        }
+        List<KlRelation> relationSaveList = Lists.newArrayList();
+        for (Long endId : idList) {
+            KlRelation klRelation = new KlRelation();
+            klRelation.setStartId(commonParam.getConceptId());
+            klRelation.setRelationId(relationId);
+            klRelation.setEndId(endId);
+            klRelation.setGmtModified(commonParam.getNow());
+            klRelation.setGmtCreate(commonParam.getNow());
+            klRelation.setCreator(commonParam.getPerson());
+            klRelation.setModifier(commonParam.getPerson());
+            relationSaveList.add(klRelation);
+        }
+        klRelationService.saveBatch(relationSaveList);
+
+        // 【科室关联排序】
+        List<KlRelationOrder> OrderSaveList = Lists.newArrayList();
+        int i = 1;
+        for (KlRelation klRelation : relationSaveList) {
+            KlRelationOrder klRelationOrder = new KlRelationOrder();
+            klRelationOrder.settRelationId(klRelation.getId());
+            klRelationOrder.setOrderNo(i++);
+            klRelation.setGmtModified(commonParam.getNow());
+            klRelation.setGmtCreate(commonParam.getNow());
+            klRelation.setCreator(commonParam.getPerson());
+            klRelation.setModifier(commonParam.getPerson());
+            OrderSaveList.add(klRelationOrder);
+        }
+        klRelationOrderService.saveBatch(OrderSaveList);
+    }
 }

+ 11 - 0
cdssman-service/src/main/java/com/diagbot/vo/KlDiseaseVO.java

@@ -1,8 +1,10 @@
 package com.diagbot.vo;
 
+import com.google.common.collect.Lists;
 import lombok.Data;
 
 import java.io.Serializable;
+import java.util.List;
 
 /**
  * <p>
@@ -137,4 +139,13 @@ public class KlDiseaseVO implements Serializable {
      */
     private String remark;
 
+    // 科室列表
+    private List<Long> deptList = Lists.newLinkedList();
+
+    // 部位列表
+    private List<Long> partList = Lists.newLinkedList();
+
+    // 疾病系统分类列表
+    private List<Long> systemTypeList = Lists.newLinkedList();
+
 }

+ 2 - 2
cdssman-service/src/test/java/com/diagbot/CodeGeneration.java

@@ -33,7 +33,7 @@ public class CodeGeneration {
         gc.setEnableCache(false);// XML 二级缓存
         gc.setBaseResultMap(true);// XML ResultMap
         gc.setBaseColumnList(false);// XML columList
-        gc.setAuthor("wangfeng");// 作者
+        gc.setAuthor("zhoutg");// 作者
 
         // 自定义文件命名,注意 %s 会自动填充表实体属性!
         gc.setControllerName("%sController");
@@ -56,7 +56,7 @@ public class CodeGeneration {
         StrategyConfig strategy = new StrategyConfig();
         //strategy.setTablePrefix(new String[] { "test" });// 此处可以修改为您的表前缀
         strategy.setNaming(NamingStrategy.underline_to_camel);// 表名生成策略
-        strategy.setInclude(new String[] { "kl_dictionary_info","kl_disease","kl_disease_corresponding","kl_lexicon","kl_lexicon_relationship" ,"kl_library_info","kl_lis","kl_relation","kl_relation_order"}); // 需要生成的表
+        strategy.setInclude(new String[] { "kl_disease","kl_drug_mapping","kl_drug_register"}); // 需要生成的表
 
         strategy.setSuperServiceClass(null);
         strategy.setSuperServiceImplClass(null);

+ 4 - 0
docs/041.20210511知识库扩展/knowledgeExt_init.sql

@@ -95,6 +95,10 @@ CREATE TABLE `kl_symptom` (
 INSERT INTO `kl_lexicon` (`id`, `is_deleted`, `gmt_create`, `gmt_modified`, `creator`, `modifier`, `name`, `code`, `is_has_common`, `only_one`, `can_change`, `remark`) VALUES ('45', 'N', '1970-01-01 12:00:00', '1970-01-01 12:00:00', '0', '0', '疾病系统分类', '411', '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 ('46', 'N', '1970-01-01 12:00:00', '1970-01-01 12:00:00', '0', '0', '性质', '412', '0', '0', '0', '');
 
+INSERT INTO `kl_lexicon_relationship` (`id`, `is_deleted`, `gmt_create`, `gmt_modified`, `creator`, `modifier`, `name`, `code`, `remark`) VALUES ('12', 'N', '1970-01-01 12:00:00', '1970-01-01 12:00:00', '0', '0', '关联科室', '511', '');
+INSERT INTO `kl_lexicon_relationship` (`id`, `is_deleted`, `gmt_create`, `gmt_modified`, `creator`, `modifier`, `name`, `code`, `remark`) VALUES ('13', 'N', '1970-01-01 12:00:00', '1970-01-01 12:00:00', '0', '0', '关联部位', '512', '');
+INSERT INTO `kl_lexicon_relationship` (`id`, `is_deleted`, `gmt_create`, `gmt_modified`, `creator`, `modifier`, `name`, `code`, `remark`) VALUES ('14', 'N', '1970-01-01 12:00:00', '1970-01-01 12:00:00', '0', '0', '关联系统分类', '513', '');
+
 -- ----------------------------
 -- Alter Table structure for kl_lis
 -- ----------------------------