Browse Source

预算及成本重构

master
陈裕财 4 years ago
parent
commit
2f35e32466
  1. 18
      xm-core/src/main/java/com/xm/core/PubTool.java
  2. 27
      xm-core/src/main/java/com/xm/core/ctrl/XmMenuController.java
  3. 11
      xm-core/src/main/java/com/xm/core/ctrl/XmTaskController.java

18
xm-core/src/main/java/com/xm/core/PubTool.java

@ -2,6 +2,9 @@ package com.xm.core;
import org.springframework.util.StringUtils;
import java.util.HashSet;
import java.util.Set;
public class PubTool {
public static String getPidPaths(String pidPahts, String trimId){
@ -16,5 +19,20 @@ public class PubTool {
}
}
public static Set<String> getPidSet(String pidPahts, String trimId){
if(!StringUtils.hasText(pidPahts)){
return new HashSet<>();
}
Set<String> sets=new HashSet<>();
String[] pids=pidPahts.split(",");
for (String pid : pids) {
if("0".equals(pid)||pid.equals(trimId)){
continue;
}
sets.add(pid);
}
return sets;
}
}

27
xm-core/src/main/java/com/xm/core/ctrl/XmMenuController.java

@ -117,21 +117,19 @@ public class XmMenuController {
PageUtils.responePage(m, xmMenuList);
if("1".equals(xmMenu.get("withParents")) && !"1".equals(xmMenu.get("isTop"))&& xmMenuList.size()>0){
Set<String> pidPathsSet=new HashSet<>();
Set<String> idSet=new HashSet<>();
Set<String> originIdSet=new HashSet<>();
for (Map<String, Object> map : xmMenuList) {
String id= (String) map.get("menuId");
idSet.add(id);
originIdSet.add(id);
String pidPaths= (String) map.get("pidPaths");
pidPaths=PubTool.getPidPaths(pidPaths,id);
if(pidPaths==null || pidPaths.length()<=2){
continue;
}
pidPathsSet.add(pidPaths);
pidPathsSet.addAll(PubTool.getPidSet(pidPaths,id));
}
if(pidPathsSet!=null && pidPathsSet.size()>0){
List<Map<String,Object>> parentList=xmMenuService.selectListMapByWhere(map("pidPathsList",pidPathsSet.stream().collect(Collectors.toList())));
parentList=parentList.stream().filter(i->!idSet.contains(i.get("menuId"))).collect(Collectors.toList());
List<String> menusIds=pidPathsSet.stream().filter(i->!originIdSet.contains(i)).collect(Collectors.toList());
if(menusIds!=null && menusIds.size()>0){
List<Map<String,Object>> parentList=xmMenuService.selectListMapByWhere(map("menuIds",menusIds));
if(parentList!=null && parentList.size()>0){
xmMenuList.addAll(parentList);
m.put("total", NumberUtil.getInteger(m.get("total"),0)+parentList.size());
@ -172,20 +170,19 @@ public class XmMenuController {
PageUtils.responePage(m, xmMenuList);
if("1".equals(xmMenu.get("withParents")) && !"1".equals(xmMenu.get("isTop"))&& xmMenuList.size()>0){
Set<String> pidPathsSet=new HashSet<>();
Set<String> idSet=new HashSet<>();
Set<String> originIdSet=new HashSet<>();
for (Map<String, Object> map : xmMenuList) {
String id= (String) map.get("menuId");
idSet.add(id);
originIdSet.add(id);
String pidPaths= (String) map.get("pidPaths");
pidPaths=PubTool.getPidPaths(pidPaths,id);
if(pidPaths==null || pidPaths.length()<=2){
continue;
}
pidPathsSet.add(pidPaths);
pidPathsSet.addAll(PubTool.getPidSet(pidPaths,id));
}
if(pidPathsSet!=null && pidPathsSet.size()>0){
List<Map<String,Object>> parentList=xmMenuService.selectListMapByWhereWithState(map("pidPathsList",pidPathsSet.stream().collect(Collectors.toList())));
parentList=parentList.stream().filter(i->!idSet.contains(i.get("menuId"))).collect(Collectors.toList());
List<String> menusIds=pidPathsSet.stream().filter(i->!originIdSet.contains(i)).collect(Collectors.toList());
if(menusIds!=null && menusIds.size()>0){
List<Map<String,Object>> parentList=xmMenuService.selectListMapByWhereWithState(map("menuIds",menusIds));
if(parentList!=null && parentList.size()>0){
xmMenuList.addAll(parentList);
m.put("total", NumberUtil.getInteger(m.get("total"),0)+parentList.size());

11
xm-core/src/main/java/com/xm/core/ctrl/XmTaskController.java

@ -133,16 +133,15 @@ public class XmTaskController {
String id= (String) map.get("id");
idSet.add(id);
String pidPaths= (String) map.get("pidPaths");
pidPaths=PubTool.getPidPaths(pidPaths,id);
if(pidPaths==null || pidPaths.length()<=2){
continue;
}
pidPathsSet.add(pidPaths);
pidPathsSet.addAll(PubTool.getPidSet(pidPaths,id));
}
if(pidPathsSet!=null && pidPathsSet.size()>0){
List<Map<String,Object>> parentList=xmTaskService.getTask(map("pidPathsList",pidPathsSet.stream().collect(Collectors.toList())));
parentList=parentList.stream().filter(i->!idSet.contains(i.get("id"))).collect(Collectors.toList());
if(parentList!=null && parentList.size()>0){
List<String> ids=pidPathsSet.stream().filter(i->!idSet.contains(i)).collect(Collectors.toList());
if(ids!=null && ids.size()>0){
List<Map<String,Object>> parentList=xmTaskService.getTask(map("ids",ids));
if(parentList!=null && parentList.size()>0){
xmTaskVoList.addAll(parentList);
m.put("total", NumberUtil.getInteger(m.get("total"),0)+parentList.size());
}

Loading…
Cancel
Save