From 1ebf56eee1a30fc6a2a397b9c3ea89633c221f44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E8=A3=95=E8=B4=A2?= Date: Thu, 31 Mar 2022 07:07:42 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=8A=82=E7=82=B9=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E3=80=81=E6=A0=87=E7=AD=BE=E7=AD=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/xm/core/service/XmMenuService.java | 82 +++++++++++++++++++ .../mapper/xm/core/dao/XmMenuMapper.xml | 10 +-- 2 files changed, 87 insertions(+), 5 deletions(-) diff --git a/xm-core/src/main/java/com/xm/core/service/XmMenuService.java b/xm-core/src/main/java/com/xm/core/service/XmMenuService.java index 156076bf..4606dd66 100644 --- a/xm-core/src/main/java/com/xm/core/service/XmMenuService.java +++ b/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()); 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 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 xmMenus) { + List> 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 ()); + } + Set set=list.get(i); + set.add(pidPathss[i]); + } + if(list.size()<=0){ + return; + } + Set allSet=new HashSet<>(); + for (int i = list.size() - 1; i >= 0; i--) { + Set set=list.get(i); + if(set.size()>0){ + List 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); + } + + } + + } + + + } + + } } diff --git a/xm-core/src/main/resources/mybatis/mapper/xm/core/dao/XmMenuMapper.xml b/xm-core/src/main/resources/mybatis/mapper/xm/core/dao/XmMenuMapper.xml index fd4865b0..83b0beac 100644 --- a/xm-core/src/main/resources/mybatis/mapper/xm/core/dao/XmMenuMapper.xml +++ b/xm-core/src/main/resources/mybatis/mapper/xm/core/dao/XmMenuMapper.xml @@ -222,11 +222,11 @@ group by q.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_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 where (res.menu_id) in