Commit ba297766 by 赵剑炜

Merge branch 'develop' of http://gitlab.sothing.top/843502640/jyzb_platformV2 into develop

parents 92c51063 438cce9b
...@@ -5,6 +5,7 @@ import com.junmp.jyzb.utils.HttpStatus; ...@@ -5,6 +5,7 @@ import com.junmp.jyzb.utils.HttpStatus;
import com.junmp.jyzb.utils.RedisUtils; import com.junmp.jyzb.utils.RedisUtils;
import com.junmp.jyzb.utils.ResponseResult; import com.junmp.jyzb.utils.ResponseResult;
import com.junmp.jyzb.utils.ReturnMsg; import com.junmp.jyzb.utils.ReturnMsg;
import com.sun.javafx.collections.MappingChange;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
...@@ -99,52 +100,59 @@ public class PubOrgServiceImpl implements PubOrgService{ ...@@ -99,52 +100,59 @@ public class PubOrgServiceImpl implements PubOrgService{
} }
if (orgInfo == -1) { if (orgInfo == -1) {
modifyList(resultList);
// 如果输入的是浙江省公安厅,就将下级的组织机构进行排序 // 如果输入的是浙江省公安厅,就将下级的组织机构进行排序
for (Map<String, Object> orgMsg : resultList) { for (Map<String, Object> orgMsg : resultList) {
List<Map<String, Object>> children = (List<Map<String, Object>>) orgMsg.get("children"); List<Map<String, Object>> children = (List<Map<String, Object>>) orgMsg.get("children");
// 根据findCode从小到大排序 // 根据findCode从小到大排序
children.sort(Comparator.comparing(m -> m.get("findCode").toString())); children.sort(Comparator.comparing(m -> m.get("findCode").toString()));
} }
return new ResponseResult(HttpStatus.SUCCESS, "操作成功", resultList);
}
if (orgInfo.equals(1369509498032808905L)){ //排序 return new ResponseResult(HttpStatus.SUCCESS, "操作成功", resultList);
// 根据findCode从小到大排序
resultList.sort(Comparator.comparing(m -> m.get("findCode").toString()));
} }
//将resultList的内容放在顶级菜单的resultList中
for (Map<String,Object> oneMap:topList){ for (Map<String,Object> oneMap:topList){
oneMap.put("children",resultList); oneMap.put("children",resultList);
} }
//topList = setParentMsg(topList);
// 遍历并添加父类的相关信息到children的第一个位置 // 遍历并添加父类的相关信息到children的第一个位置
traverseList(topList); modifyList(topList);
// 返回结果 if (orgInfo.equals(1369509498032808905L)) {
// 如果输入的是浙江省公安厅,就将下级的组织机构进行排序
for (Map<String, Object> orgMsg : topList) {
List<Map<String, Object>> children = (List<Map<String, Object>>) orgMsg.get("children");
// 根据findCode从小到大排序
children.sort(Comparator.comparing(m -> m.get("findCode").toString()));
}
return new ResponseResult(HttpStatus.SUCCESS, "操作成功", topList); return new ResponseResult(HttpStatus.SUCCESS, "操作成功", topList);
} }
//将父类信息放在children的第一个位置 // 返回结果
public static List<Map<String,Object>> setParentMsg(List<Map<String,Object>> resultList){ return new ResponseResult(HttpStatus.SUCCESS, "操作成功", topList);
// 遍历并添加父类的相关信息到children的第一个位置
for (Map<String, Object> data : resultList) {
List<Map<String, Object>> children = (List<Map<String, Object>>) data.get("children");
if (!children.isEmpty()) {
Map<String, Object> parentInfo = new HashMap<>(data);
children.add(0, parentInfo);
}
}
return resultList;
} }
public static void traverseList(List<Map<String, Object>> list) { //将父类信息放在children的第一个位置
for (Map<String, Object> data : list) { private static void modifyList(List<Map<String, Object>> list) {
List<Map<String, Object>> children = (List<Map<String, Object>>) data.get("children"); for (Map<String, Object> item : list) {
if (!children.isEmpty()) { // 获取当前节点的ID
Map<String, Object> parentInfo = new HashMap<>(data); Map<String,Object> setMsg = new HashMap<>();
children.add(0, parentInfo); setMsg.put("id", Long.valueOf(item.get("id").toString()));
traverseList(children); setMsg.put("parentId", item.get("parentId").toString());
setMsg.put("findCode", item.get("findCode").toString());
setMsg.put("orgName", item.get("orgName").toString());
// 将当前节点的ID添加到子节点的第一个位置
@SuppressWarnings("unchecked")
List<Map<String, Object>> children = (List<Map<String, Object>>) item.get("children");
if (children != null && children.size() > 0) {
//将父类的相关信息放在children的第一个位置
children.set(0,setMsg);
// 递归处理子节点
modifyList(children);
} }
} }
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论