|
@@ -11,12 +11,17 @@ import com.diagbot.dto.GraphLabelDTO;
|
|
|
import com.diagbot.dto.Link;
|
|
|
import com.diagbot.dto.LinkDTO;
|
|
|
import com.diagbot.dto.Node;
|
|
|
+import com.diagbot.dto.Tree;
|
|
|
+import com.diagbot.dto.TreeDTO;
|
|
|
+import com.diagbot.dto.TreeNodeDTO;
|
|
|
import com.diagbot.dto.Tu;
|
|
|
import com.diagbot.exception.CommonErrorCode;
|
|
|
import com.diagbot.exception.CommonException;
|
|
|
import com.diagbot.service.impl.KgServiceImpl;
|
|
|
import com.diagbot.util.EntityUtil;
|
|
|
+import com.diagbot.util.FastJsonUtils;
|
|
|
import com.diagbot.util.ListUtil;
|
|
|
+import com.diagbot.util.StringUtil;
|
|
|
import com.diagbot.vo.KgQueryVO;
|
|
|
import com.diagbot.vo.KgTreeVO;
|
|
|
import org.springframework.stereotype.Component;
|
|
@@ -97,18 +102,92 @@ public class KgFacade extends KgServiceImpl {
|
|
|
return random;
|
|
|
}
|
|
|
|
|
|
- public String getTreeFac(KgTreeVO kgTreeVO) {
|
|
|
- String tree = "";
|
|
|
+ public TreeDTO getTreeFac(KgTreeVO kgTreeVO) {
|
|
|
+ TreeDTO treeDTO = new TreeDTO();
|
|
|
if (kgTreeVO.getType() == 1
|
|
|
&& kgTreeVO.getSubType() == 1) {
|
|
|
KgQueryVO kgQueryVO = new KgQueryVO();
|
|
|
kgQueryVO.setLabelName("国icd10");
|
|
|
kgQueryVO.setInputStr("国icd10");
|
|
|
- tree = this.getTree(kgQueryVO);
|
|
|
+ String tree = this.getTree(kgQueryVO);
|
|
|
+ if (StringUtil.isBlank(tree)) {
|
|
|
+ throw new CommonException(CommonErrorCode.NOT_EXISTS);
|
|
|
+ } else {
|
|
|
+ treeDTO = getTreeDTO(tree);
|
|
|
+ }
|
|
|
} else {
|
|
|
throw new CommonException(CommonErrorCode.PARAM_IS_ERROR);
|
|
|
}
|
|
|
- return tree;
|
|
|
+ return treeDTO;
|
|
|
+ }
|
|
|
+
|
|
|
+ private TreeDTO getTreeDTO(String tree) {
|
|
|
+ TreeDTO treeDTO = new TreeDTO();
|
|
|
+ List<TreeNodeDTO> nodes = new ArrayList<>();
|
|
|
+ Tree treeObj = FastJsonUtils.getJsonToBean("{\n" +
|
|
|
+ "\t\"name\": \"疾病\",\n" +
|
|
|
+ "\t\"sNode\": [\n" +
|
|
|
+ "\t\t{\n" +
|
|
|
+ "\t\t\t\"name\": \"A00-B99-某些传染病和寄生虫病\",\n" +
|
|
|
+ "\t\t\t\"sNode\": [\n" +
|
|
|
+ "\t\t\t\t{\n" +
|
|
|
+ "\t\t\t\t\t\"name\": \"A00\",\n" +
|
|
|
+ "\t\t\t\t\t\"sNode\": [\n" +
|
|
|
+ "\t\t\t\t\t\t{\n" +
|
|
|
+ "\t\t\t\t\t\t\t\"name\": \"A00.000 霍乱,由于O1群霍乱弧菌,霍乱生物型所致\",\n" +
|
|
|
+ "\t\t\t\t\t\t\t\"sNode\": [\n" +
|
|
|
+ "\t\t\t\t\t\t\t]\n" +
|
|
|
+ "\t\t\t\t\t\t},\n" +
|
|
|
+ "\t\t\t\t\t\t{\n" +
|
|
|
+ "\t\t\t\t\t\t\t\"name\": \"A00.000x001 古典生物型霍乱\",\n" +
|
|
|
+ "\t\t\t\t\t\t\t\"sNode\": [\n" +
|
|
|
+ "\t\t\t\t\t\t\t]\n" +
|
|
|
+ "\t\t\t\t\t\t}\n" +
|
|
|
+ "\t\t\t\t\t]\n" +
|
|
|
+ "\t\t\t\t}\n" +
|
|
|
+ "\t\t\t]\n" +
|
|
|
+ "\t\t},\n" +
|
|
|
+ "\t\t{\n" +
|
|
|
+ "\t\t\t\"name\": \"A22-B22-某些传染病和寄生虫病\",\n" +
|
|
|
+ "\t\t\t\"sNode\": [\n" +
|
|
|
+ "\t\t\t\t{\n" +
|
|
|
+ "\t\t\t\t\t\"name\": \"A22\",\n" +
|
|
|
+ "\t\t\t\t\t\"sNode\": [\n" +
|
|
|
+ "\t\t\t\t\t\t{\n" +
|
|
|
+ "\t\t\t\t\t\t\t\"name\": \"胆囊炎\",\n" +
|
|
|
+ "\t\t\t\t\t\t\t\"sNode\": [\n" +
|
|
|
+ "\t\t\t\t\t\t\t]\n" +
|
|
|
+ "\t\t\t\t\t\t}\n" +
|
|
|
+ "\t\t\t\t\t]\n" +
|
|
|
+ "\t\t\t\t}\n" +
|
|
|
+ "\t\t\t]\n" +
|
|
|
+ "\t\t}\n" +
|
|
|
+ "\t]\n" +
|
|
|
+ "}", Tree.class);
|
|
|
+ if (null != treeObj) {
|
|
|
+ Map<String, Integer> treeMap = new HashMap<>();
|
|
|
+ treeMap.put("根节点", 0);
|
|
|
+ addTree(nodes, treeObj, treeMap, "根节点");
|
|
|
+ }
|
|
|
+
|
|
|
+ treeDTO.setNodes(nodes);
|
|
|
+ return treeDTO;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void addTree(List<TreeNodeDTO> nodes, Tree treeObj, Map<String, Integer> treeMap, String pName) {
|
|
|
+ if (null == treeMap.get(treeObj.getName())) {
|
|
|
+ treeMap.put(treeObj.getName(), treeMap.size());
|
|
|
+ }
|
|
|
+
|
|
|
+ TreeNodeDTO node = new TreeNodeDTO("M", treeMap.get(treeObj.getName()), treeObj.getName(), treeMap.get(pName));
|
|
|
+ nodes.add(node);
|
|
|
+ if (ListUtil.isNotEmpty(treeObj.getSNode())) {
|
|
|
+ for (Tree tree : treeObj.getSNode()) {
|
|
|
+ addTree(nodes, tree, treeMap, treeObj.getName());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ node.setIcon("E");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public GraDTO getTuFac(KgQueryVO kgQueryVO) {
|