From 02ea9a0c984639cd09479871d15781aedcdd0de8 Mon Sep 17 00:00:00 2001 From: wulin Date: Tue, 3 Nov 2020 13:44:25 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=8A=E4=BF=9D=E5=AD=98=E6=B5=81=E7=A8=8B?= =?UTF-8?q?=E6=98=AF=E7=9A=84=E5=BF=85=E5=A4=87=E6=9D=83=E9=99=90=E6=94=BE?= =?UTF-8?q?=E5=88=B0=E5=8F=91=E8=B5=B7=E8=80=83=E6=A0=B8=E6=97=B6=E8=B5=8B?= =?UTF-8?q?=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/FlowStartServiceImpl.java | 73 +++++++++++++++++-- .../controller/FlowChartController.java | 36 +-------- 2 files changed, 68 insertions(+), 41 deletions(-) diff --git a/src/main/java/com/lz/modules/flow/service/impl/FlowStartServiceImpl.java b/src/main/java/com/lz/modules/flow/service/impl/FlowStartServiceImpl.java index bb59aaed..a69cb6e9 100644 --- a/src/main/java/com/lz/modules/flow/service/impl/FlowStartServiceImpl.java +++ b/src/main/java/com/lz/modules/flow/service/impl/FlowStartServiceImpl.java @@ -24,10 +24,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.interceptor.TransactionAspectSupport; import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.function.Function; import java.util.stream.Collectors; @@ -80,6 +77,9 @@ public class FlowStartServiceImpl extends ServiceImpl evaluationGroups = evaluationGroupService.selectEvaluationGroupByIds(ids); + Map> mustRole = new HashMap<>(); + Map> selfMustRole = new HashMap<>(); + for (int n = 0; n < evaluationGroups.size(); n++ ) { EvaluationGroup evaluationGroup = evaluationGroups.get(n); @@ -202,7 +205,7 @@ public class FlowStartServiceImpl extends ServiceImpl> staffManages, List staffIds){ + Map> staffManages, List staffIds, + Map> mustRole, Map> selfMustRole){ List resultModelDtos = resultModelService.selectResultDtoByGroupId(evaluationGroup.getId()); @@ -317,8 +321,24 @@ public class FlowStartServiceImpl extends ServiceImpl flowChartRoles = null; + //获取必备权限 + if(mustRole.containsKey(flow.getChartId())){ + flowChartRoles = mustRole.get(flow.getChartId()); + }else{ + flowChartRoles = + flowChartRoleService.selectFlowChartRolesByChartIdAndType(flow.getChartId(), 1); + mustRole.put(flow.getChartId(), flowChartRoles); + } + + + if(flowChartDetailRecord.getOptType().intValue() == ChartOptType.APPOINT.getCode()){//指定人员的 + + String[] optIds = flowChartDetailRecord.getOptIds().split(","); + + for (String id:optIds ) { @@ -334,6 +354,20 @@ public class FlowStartServiceImpl extends ServiceImpl 0){//设置必备权限 + String roles = flowChartRoles.stream().map(new Function() { + @Override + public String apply(FlowChartRole flowChartRole) { + return flowChartRole.getRoleId().toString(); + } + }).collect(Collectors.joining(",")); + if(flowApprovalRole.getRoleId() == null || flowApprovalRole.getRoleId().length() == 0){ + flowApprovalRole.setRoleId(roles); + }else{ + flowApprovalRole.setRoleId(flowChartDetailRecord.getRoleIds() + "," + roles); + } + } } //stepIndex++; if(flowApprovalRole != null){ @@ -341,6 +375,17 @@ public class FlowStartServiceImpl extends ServiceImpl flowChartRoles1 = + flowChartRoleService.selectFlowChartRolesByChartIdAndType(flow.getChartId(), 2); + selfMustRole.put(flow.getChartId(), flowChartRoles1); + flowChartRoles.addAll(flowChartRoles1); + } + } flowApprovalRole = new FlowApprovalRole(); flowApprovalRole.setFlowId(flow.getId()); flowApprovalRole.setStepType(flowChartDetailRecord.getStepType()); @@ -349,9 +394,25 @@ public class FlowStartServiceImpl extends ServiceImpl 0){//设置必备权限 + String roles = flowChartRoles.stream().map(new Function() { + @Override + public String apply(FlowChartRole flowChartRole) { + return flowChartRole.getRoleId().toString(); + } + }).collect(Collectors.joining(",")); + if(flowApprovalRole.getRoleId() == null || flowApprovalRole.getRoleId().length() == 0){ + flowApprovalRole.setRoleId(roles); + }else{ + flowApprovalRole.setRoleId(flowChartDetailRecord.getRoleIds() + "," + roles); + } + } + stepIndex++; } + + } //插入记录/flowChart/saveDetailProcs if(flowApprovalRoles.size() > 0){ diff --git a/src/main/java/com/lz/modules/performance/controller/FlowChartController.java b/src/main/java/com/lz/modules/performance/controller/FlowChartController.java index e0a016a7..394fa38c 100644 --- a/src/main/java/com/lz/modules/performance/controller/FlowChartController.java +++ b/src/main/java/com/lz/modules/performance/controller/FlowChartController.java @@ -145,49 +145,15 @@ public class FlowChartController { if(flowChartDetailRecordListReq.getRecordSimpleDtos() != null && flowChartDetailRecordListReq.getRecordSimpleDtos().size() > 0){ List inserts = new ArrayList<>(); List updaes = new ArrayList<>(); - Map> mustRole = new HashMap<>(); - Map> selfMustRole = new HashMap<>(); + int index = 0; for (FlowChartDetailRecordSimpleReq req:flowChartDetailRecordListReq.getRecordSimpleDtos() ) { FlowChartDetailRecord flowChartDetailRecord = new FlowChartDetailRecord(); BeanUtils.copyProperties(req, flowChartDetailRecord); flowChartDetailRecord.setChartId(flowChartDetailRecordListReq.getId()); - List flowChartRoles = null; - if(mustRole.containsKey(flowChartDetailRecordListReq.getId())){ - flowChartRoles = mustRole.get(flowChartDetailRecordListReq.getId()); - }else{ - flowChartRoles = - flowChartRoleService.selectFlowChartRolesByChartIdAndType(flowChartDetailRecordListReq.getId(), 1); - mustRole.put(flowChartDetailRecordListReq.getId(), flowChartRoles); - } - if(flowChartDetailRecord.getOptType().intValue() == -1){//考核人是自己的 - //获取被考核人的必备权限 - if(selfMustRole.containsKey(flowChartDetailRecordListReq.getId())){ - flowChartRoles.addAll(selfMustRole.get(flowChartDetailRecordListReq.getId())); - }else{ - List flowChartRoles1 = - flowChartRoleService.selectFlowChartRolesByChartIdAndType(flowChartDetailRecordListReq.getId(), 2); - selfMustRole.put(flowChartDetailRecordListReq.getId(), flowChartRoles1); - flowChartRoles.addAll(flowChartRoles1); - } - } - - if(flowChartRoles != null && flowChartRoles.size() > 0){//设置必备权限 - String roles = flowChartRoles.stream().map(new Function() { - @Override - public String apply(FlowChartRole flowChartRole) { - return flowChartRole.getRoleId().toString(); - } - }).collect(Collectors.joining(",")); - if(flowChartDetailRecord.getRoleIds() == null || flowChartDetailRecord.getRoleIds().length() == 0){ - flowChartDetailRecord.setRoleIds(roles); - }else{ - flowChartDetailRecord.setRoleIds(flowChartDetailRecord.getRoleIds() + "," + roles); - } - } flowChartDetailRecord.setEvaluationGroupId(flowChartDetailRecordListReq.getEvaluationGroupId()); flowChartDetailRecord.setStepIndex(index);