修改超声和影像查询诊断模版方法
Some checks failed
Java CI with Maven / build (11) (push) Has been cancelled
Java CI with Maven / build (17) (push) Has been cancelled
Java CI with Maven / build (8) (push) Has been cancelled
yudao-ui-admin CI / build (14.x) (push) Has been cancelled
yudao-ui-admin CI / build (16.x) (push) Has been cancelled
Some checks failed
Java CI with Maven / build (11) (push) Has been cancelled
Java CI with Maven / build (17) (push) Has been cancelled
Java CI with Maven / build (8) (push) Has been cancelled
yudao-ui-admin CI / build (14.x) (push) Has been cancelled
yudao-ui-admin CI / build (16.x) (push) Has been cancelled
This commit is contained in:
parent
a6fd0ef154
commit
a680fd3830
@ -13,6 +13,7 @@ public class Tree {
|
||||
public String tempname;
|
||||
public String examDescription;
|
||||
public String diagResults;
|
||||
public String dataType;
|
||||
public List<Tree> children;
|
||||
// public Tree(String id, String cname, String pid,String tempname,String examDescription,String diagResults) {
|
||||
// this.id = id;
|
||||
|
@ -118,62 +118,79 @@ public class ultrasonicController {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
String json = mapper.writeValueAsString(filteredList);
|
||||
|
||||
List<Tree> tree = convertJsonToTree(json);
|
||||
List<Tree> tree = convertJsonToTree(json,isprivate);
|
||||
|
||||
return success(tree);
|
||||
}
|
||||
|
||||
|
||||
//返回树结构
|
||||
private List<Tree> convertJsonToTree(String jsonData) {
|
||||
List<Map<String, Object>> dataList;
|
||||
//返回树结构
|
||||
private List<Tree> convertJsonToTree(String jsonData,String isprivate) {
|
||||
try {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
dataList = objectMapper.readValue(jsonData, List.class);
|
||||
List<Map<String, Object>> dataList = objectMapper.readValue(jsonData, List.class);
|
||||
Map<String, Tree> treeMap = new HashMap<>();
|
||||
List<Tree> privateTrees = new ArrayList<>(); // 私有节点列表
|
||||
List<Tree> publicTrees = new ArrayList<>(); // 公共节点列表
|
||||
|
||||
for (Map<String, Object> data : dataList) {
|
||||
String id = (String) data.get("id");
|
||||
String pid = (String) data.get("pid");
|
||||
String privateId = (String) data.get("privateDoctorId");
|
||||
|
||||
Tree tree = new Tree();
|
||||
tree.id = id;
|
||||
tree.cname = (String) data.get("examPart");
|
||||
tree.pid = pid;
|
||||
tree.tempname = (String) data.get("templateName");
|
||||
tree.examDescription = (String) data.get("examDescription");
|
||||
tree.diagResults = (String) data.get("diagResults");
|
||||
tree.dataType=(String) data.get("dataType");
|
||||
treeMap.put(id, tree);
|
||||
|
||||
if (privateId != null && !privateId.isEmpty()) {
|
||||
privateTrees.add(tree); // 添加到私有节点列表
|
||||
} else if ("0".equals(pid)) {
|
||||
publicTrees.add(tree); // 添加到公共节点列表
|
||||
}
|
||||
}
|
||||
if (isprivate.equals("1"))
|
||||
{
|
||||
// 构建公共树
|
||||
buildTree(privateTrees, "0", treeMap);
|
||||
// 将私有节点添加到结果列表
|
||||
return new ArrayList<>(privateTrees); //
|
||||
}
|
||||
else
|
||||
{
|
||||
// 构建公共树
|
||||
buildTree(publicTrees, "0", treeMap);
|
||||
// 将私有节点添加到结果列表
|
||||
return new ArrayList<>(publicTrees); //
|
||||
}
|
||||
|
||||
|
||||
|
||||
} catch (JsonProcessingException e) {
|
||||
e.printStackTrace();
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
Map<String, Tree> treeMap = new HashMap<>();
|
||||
List<Tree> treeList = new ArrayList<>();
|
||||
for (Map<String, Object> data : dataList) {
|
||||
String pid = (String) data.get("pid");
|
||||
String id = (String) data.get("id");
|
||||
String privateId = (String) data.get("privateDoctorId");
|
||||
|
||||
Tree tree = new Tree();
|
||||
tree.id = id;
|
||||
tree.cname = (String) data.get("examPart");
|
||||
tree.pid = pid;
|
||||
tree.tempname = (String) data.get("templateName");
|
||||
tree.examDescription = (String) data.get("examDescription");
|
||||
tree.diagResults = (String) data.get("diagResults");
|
||||
|
||||
treeMap.put(id, tree);
|
||||
if (pid != null && treeMap.containsKey(pid)) {
|
||||
Tree parent = treeMap.get(pid);
|
||||
if (parent.children == null) {
|
||||
parent.children = new ArrayList<>(); // 初始化 parent.children 列表
|
||||
}
|
||||
parent.children.add(tree);
|
||||
} else if (privateId != null && !privateId.isEmpty())//判断是否是私有模版 私有的直接加到树里面
|
||||
{
|
||||
treeList.add(tree);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
for (Tree tree : treeMap.values()) {
|
||||
if ("0".equals(tree.pid)) {
|
||||
treeList.add(tree);
|
||||
}
|
||||
}
|
||||
|
||||
return treeList;
|
||||
}
|
||||
|
||||
|
||||
private void buildTree(List<Tree> currentLevelTrees, String parentId, Map<String, Tree> treeMap) {
|
||||
for (Tree tree : currentLevelTrees) {
|
||||
if (treeMap.containsKey(tree.id)) {
|
||||
List<Tree> children = new ArrayList<>();
|
||||
for (Tree child : treeMap.values()) {
|
||||
if (child.pid != null && child.pid.equals(tree.id)) {
|
||||
children.add(child);
|
||||
}
|
||||
}
|
||||
tree.children = children;
|
||||
buildTree(children, tree.id, treeMap); // 递归构建子树
|
||||
}
|
||||
}
|
||||
}
|
||||
@GetMapping("/getimageslist")
|
||||
@Operation(summary = "获取图片列表")
|
||||
@Parameter(name = "orgid", description = "机构ID", required = true, example = "1024")
|
||||
|
@ -111,4 +111,7 @@ public class ultrasonicDO {
|
||||
@TableField("updateTime")
|
||||
private Date updateTime;
|
||||
|
||||
@TableField("dataType")
|
||||
private String dataType;
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user