Browse Source

添加节点类型、标签等

master
陈裕财 4 years ago
parent
commit
1ebf56eee1
  1. 82
      xm-core/src/main/java/com/xm/core/service/XmMenuService.java
  2. 10
      xm-core/src/main/resources/mybatis/mapper/xm/core/dao/XmMenuMapper.xml

82
xm-core/src/main/java/com/xm/core/service/XmMenuService.java

@ -324,5 +324,87 @@ public class XmMenuService extends BaseService {
menuIds=menuIds.stream().collect(Collectors.toSet()).stream().collect(Collectors.toList()); menuIds=menuIds.stream().collect(Collectors.toSet()).stream().collect(Collectors.toList());
super.update("calcWorkloadByRecord",menuIds); super.update("calcWorkloadByRecord",menuIds);
} }
@Transactional
public void sumParents(XmMenu node){
String id=node.getMenuId();
String pidPaths=node.getPidPaths();
if(!StringUtils.hasText(pidPaths)){
return;
}
if(!pidPaths.startsWith("0,")){
return;
}
if("0".equals(node.getNtype())&&pidPaths.endsWith(id+",")){
pidPaths=pidPaths.substring(2,pidPaths.indexOf(id));
}else{
pidPaths=pidPaths.substring(2);
}
if(!StringUtils.hasText(pidPaths)){
return;
}
String[] pidPathss=pidPaths.split(",");
List<String> pidPathsList=new ArrayList<>();
for (int i = pidPathss.length-1; i >=0; i--) {
pidPathsList.add(pidPathss[i]);
}
if(pidPathsList.size()>0){
super.update("sumParents",pidPathsList );
}
}
@Transactional
public void batchSumParents(List<XmMenu> xmMenus) {
List<Set<String>> list=new ArrayList<>();
for (XmMenu node : xmMenus) {
String id=node.getMenuId();
String pidPaths=node.getPidPaths();
if(!StringUtils.hasText(pidPaths)){
continue;
}
if(!pidPaths.startsWith("0,")){
continue;
}
if("0".equals(node.getNtype())){
pidPaths=pidPaths.substring(2,pidPaths.indexOf(id));
}else{
pidPaths=pidPaths.substring(2);
}
if(!StringUtils.hasText(pidPaths)){
continue;
}
String[] pidPathss=pidPaths.split(",");
for (int i = 0; i <pidPathss.length; i++) {
if(list.size()<=i){
list.add(new HashSet<>());
}
Set<String> set=list.get(i);
set.add(pidPathss[i]);
}
if(list.size()<=0){
return;
}
Set<String> allSet=new HashSet<>();
for (int i = list.size() - 1; i >= 0; i--) {
Set<String> set=list.get(i);
if(set.size()>0){
List<String> ids=set.stream().filter(k->!allSet.contains(k)).collect(Collectors.toList());
if(ids.size()>0){
allSet.addAll(ids.stream().collect(Collectors.toSet()));
super.update("batchSumParents", ids);
}
}
}
}
}
} }

10
xm-core/src/main/resources/mybatis/mapper/xm/core/dao/XmMenuMapper.xml

@ -222,11 +222,11 @@
group by q.menu_id group by q.menu_id
) as q on q.menu_id=res.menu_id ) as q on q.menu_id=res.menu_id
set res.budget_workload=ifnull(t.budget_workload,0)+ifnull(q.budget_workload,0), set res.budget_workload=ifnull(t.budget_workload,0)+ifnull(q.budget_workload,0),
set res.budget_cost=ifnull(t.budget_cost,0)+ifnull(q.budget_cost,0),
set res.mact_workload=ifnull(t.act_workload,0)+ifnull(q.act_workload,0),
set res.mact_cost=ifnull(t.act_cost,0)+ifnull(q.act_cost,0),
set res.rworkload=ifnull(t.rworkload,0)+ifnull(q.rworkload,0),
set res.mact_rate=case when (ifnull(t.rworkload,0)+ifnull(q.rworkload,0)+ifnull(t.act_workload,0)+ifnull(q.act_workload,0))!=0 then (ifnull(t.act_workload,0)+ifnull(q.act_workload,0))*100/(ifnull(t.rworkload,0)+ifnull(q.rworkload,0)+ifnull(t.act_workload,0)+ifnull(q.act_workload,0))
res.budget_cost=ifnull(t.budget_cost,0)+ifnull(q.budget_cost,0),
res.mact_workload=ifnull(t.act_workload,0)+ifnull(q.act_workload,0),
res.mact_cost=ifnull(t.act_cost,0)+ifnull(q.act_cost,0),
res.rworkload=ifnull(t.rworkload,0)+ifnull(q.rworkload,0),
res.mact_rate=case when (ifnull(t.rworkload,0)+ifnull(q.rworkload,0)+ifnull(t.act_workload,0)+ifnull(q.act_workload,0))!=0 then (ifnull(t.act_workload,0)+ifnull(q.act_workload,0))*100/(ifnull(t.rworkload,0)+ifnull(q.rworkload,0)+ifnull(t.act_workload,0)+ifnull(q.act_workload,0))
else 0 end else 0 end
where (res.menu_id) in where (res.menu_id) in
<foreach collection="list" item="item" index="index" open="(" separator="," close=")" > <foreach collection="list" item="item" index="index" open="(" separator="," close=")" >

Loading…
Cancel
Save