Browse Source

树形结构移到mysql数据库

gaodm 5 years ago
parent
commit
3931b30b95

File diff suppressed because it is too large
+ 4 - 3
docs/034.20200330官网知识平台二期/init_ltkg.sql


+ 23 - 14
ltkg-service/src/main/java/com/diagbot/facade/KgFacade.java

@@ -1,6 +1,6 @@
 package com.diagbot.facade;
 
-import com.diagbot.dto.BaseNodeDTO;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.diagbot.dto.BaseNodeRSDTO;
 import com.diagbot.dto.CategorieDTO;
 import com.diagbot.dto.Categories;
@@ -16,6 +16,8 @@ import com.diagbot.dto.Tree;
 import com.diagbot.dto.TreeDTO;
 import com.diagbot.dto.TreeNodeDTO;
 import com.diagbot.dto.Tu;
+import com.diagbot.entity.PresetInfo;
+import com.diagbot.enums.IsDeleteEnum;
 import com.diagbot.exception.CommonErrorCode;
 import com.diagbot.exception.CommonException;
 import com.diagbot.service.impl.KgServiceImpl;
@@ -25,6 +27,7 @@ import com.diagbot.util.ListUtil;
 import com.diagbot.util.StringUtil;
 import com.diagbot.vo.KgQueryVO;
 import com.diagbot.vo.KgTreeVO;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
 import java.util.ArrayList;
@@ -40,6 +43,8 @@ import java.util.Map;
  */
 @Component
 public class KgFacade extends KgServiceImpl {
+    @Autowired
+    private PresetInfoFacade presetInfoFacade;
 
     public GraphLabelDTO getGraphFac(KgQueryVO kgQueryVO) {
         GraphLabelDTO graphLabelDTO = new GraphLabelDTO();
@@ -78,7 +83,7 @@ public class KgFacade extends KgServiceImpl {
                     if (ListUtil.isNotEmpty(baseNodeRSDTO.getENodeDTOS())) {
                         for (NextNodeDTO baseNodeDTO : baseNodeRSDTO.getENodeDTOS()) {
                             String symbol = "diamond";
-                            if (baseNodeDTO.getPCount() > 0){
+                            if (baseNodeDTO.getPCount() > 0) {
                                 symbol = "circle";
                             }
                             GNodeDTO eNodeDTO
@@ -99,23 +104,27 @@ public class KgFacade extends KgServiceImpl {
         return graphLabelDTO;
     }
 
-//    private String random() {
-//        //先随机产生一个下标再获取元素
-//        String random = "";
-//        String[] doc = { "circle", "diamond" };
-//        int index = (int) (Math.random() * doc.length);
-//        random = doc[index];
-//        return random;
-//    }
+    //    private String random() {
+    //        //先随机产生一个下标再获取元素
+    //        String random = "";
+    //        String[] doc = { "circle", "diamond" };
+    //        int index = (int) (Math.random() * doc.length);
+    //        random = doc[index];
+    //        return random;
+    //    }
 
     public TreeDTO getTreeFac(KgTreeVO kgTreeVO) {
         TreeDTO treeDTO = new TreeDTO();
         if (kgTreeVO.getType() == 1
                 && kgTreeVO.getSubType() == 1) {
-            KgQueryVO kgQueryVO = new KgQueryVO();
-            kgQueryVO.setLabelName("诊断依据");
-            kgQueryVO.setInputStr("诊断依据");
-            String tree = this.getTree(kgQueryVO);
+            // KgQueryVO kgQueryVO = new KgQueryVO();
+            // kgQueryVO.setLabelName("诊断依据");
+            // kgQueryVO.setInputStr("诊断依据");
+            // String tree = this.getTree(kgQueryVO);
+            PresetInfo presetInfo = presetInfoFacade.getOne(new QueryWrapper<PresetInfo>()
+                    .eq("is_deleted", IsDeleteEnum.N.getKey())
+                    .eq("type", (kgTreeVO.getType() * 10 + kgTreeVO.getSubType())), false);
+            String tree = presetInfo.getContent();
             if (StringUtil.isBlank(tree)) {
                 throw new CommonException(CommonErrorCode.NOT_EXISTS);
             } else {