|
@@ -1,8 +1,18 @@
|
|
|
package com.diagbot.facade;
|
|
|
|
|
|
+import com.diagbot.dto.RelationDTO;
|
|
|
+import com.diagbot.dto.TreeDTO;
|
|
|
import com.diagbot.service.impl.KlRelationServiceImpl;
|
|
|
+import com.diagbot.util.EntityUtil;
|
|
|
+import com.diagbot.util.ListUtil;
|
|
|
+import com.diagbot.vo.RelationVO;
|
|
|
+import com.diagbot.vo.TreeVO;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
/**
|
|
|
* @Description:
|
|
|
* @Author:zhaops
|
|
@@ -10,4 +20,43 @@ import org.springframework.stereotype.Component;
|
|
|
*/
|
|
|
@Component
|
|
|
public class KlRelationFacade extends KlRelationServiceImpl {
|
|
|
+ public TreeDTO getTree(TreeVO treeVO) {
|
|
|
+ TreeDTO treeDTO = new TreeDTO();
|
|
|
+ List<Long[]> pList = new ArrayList<>();
|
|
|
+ pList.add(new Long[] { 402L, 600L, 301L, 600L, 101L });
|
|
|
+
|
|
|
+
|
|
|
+ RelationVO relationVO = new RelationVO();
|
|
|
+ Integer index = treeVO.getType() - 1;
|
|
|
+ relationVO.setSType(pList.get(index)[0]);
|
|
|
+ relationVO.setRId(pList.get(index)[1]);
|
|
|
+ relationVO.setEType(pList.get(index)[2]);
|
|
|
+ List<RelationDTO> root = this.getRelations(relationVO);
|
|
|
+
|
|
|
+ RelationVO relationVO2 = new RelationVO();
|
|
|
+ relationVO2.setSType(pList.get(index)[2]);
|
|
|
+ relationVO2.setRId(pList.get(index)[3]);
|
|
|
+ relationVO2.setEType(pList.get(index)[4]);
|
|
|
+ List<RelationDTO> sub = this.getRelations(relationVO2);
|
|
|
+ Map<Long, List<RelationDTO>> map = EntityUtil.makeEntityListMap(sub, "sId");
|
|
|
+
|
|
|
+ treeDTO.setId(root.get(0).getSId());
|
|
|
+ treeDTO.setName(root.get(0).getSName());
|
|
|
+ for (RelationDTO relationDTO : root) {
|
|
|
+ TreeDTO treeDTO2 = new TreeDTO();
|
|
|
+ treeDTO2.setId(relationDTO.getEId());
|
|
|
+ treeDTO2.setName(relationDTO.getEName());
|
|
|
+ List<RelationDTO> e = map.get(relationDTO.getEId());
|
|
|
+ if (ListUtil.isNotEmpty(e)) {
|
|
|
+ for (RelationDTO relationDTO1 : e) {
|
|
|
+ TreeDTO treeDTO3 = new TreeDTO();
|
|
|
+ treeDTO3.setId(relationDTO1.getEId());
|
|
|
+ treeDTO3.setName(relationDTO1.getEName());
|
|
|
+ treeDTO2.getNextTree().add(treeDTO3);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ treeDTO.getNextTree().add(treeDTO2);
|
|
|
+ }
|
|
|
+ return treeDTO;
|
|
|
+ }
|
|
|
}
|