|
|
|
@ -66,7 +66,7 @@ public class UserInfoAndDeptTask { |
|
|
|
|
|
|
|
|
|
|
|
public void run(){ |
|
|
|
this.testRun2(); |
|
|
|
this.userInfoAndDept(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
@ -166,44 +166,6 @@ public class UserInfoAndDeptTask { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public void testRun2() { |
|
|
|
String path = "/uploadPath/tmp.txt"; // 替换为你的JSON文件路径
|
|
|
|
|
|
|
|
try { |
|
|
|
String deptInfoJson = new String(Files.readAllBytes(Paths.get(path)), StandardCharsets.UTF_8); |
|
|
|
System.out.println(deptInfoJson); |
|
|
|
JSONArray dataArr = JSONArray.parseArray(deptInfoJson); |
|
|
|
for (int i = 0; i < dataArr.size(); i++) { |
|
|
|
JSONObject jsonObject = dataArr.getJSONObject(i); |
|
|
|
String parentId = jsonObject.getString("parent_id"); |
|
|
|
|
|
|
|
List<String> ancUrls = new ArrayList<>(); |
|
|
|
List<String> ancs = this.convertAncestors(dataArr, parentId, ancUrls); |
|
|
|
String anc = String.join(",", ancs); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} catch (IOException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private List<String> convertAncestors(JSONArray dataList, String curParentId, List<String> ancUrls) { |
|
|
|
if ("1".equals(curParentId)) { return ancUrls; } |
|
|
|
for (int i = 0; i < dataList.size(); i++) { |
|
|
|
JSONObject data = dataList.getJSONObject(i); |
|
|
|
String deptParentId = data.getString("parent_id"); |
|
|
|
if (curParentId.equals(deptParentId)) { |
|
|
|
String anc = data.getString("id"); |
|
|
|
ancUrls.add(anc); |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return convertAncestors(dataList, curParentId, ancUrls); |
|
|
|
} |
|
|
|
|
|
|
|
public void testRun() { |
|
|
|
String path = "/uploadPath/detpInfo.txt"; // 替换为你的JSON文件路径
|
|
|
|
try { |
|
|
|
|