把保存流程是的必备权限放到发起考核时赋值
This commit is contained in:
parent
3f87608dcb
commit
02ea9a0c98
@ -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<FlowStartMapper, FlowStart
|
||||
@Autowired
|
||||
private EvaluationGroupService evaluationGroupService;
|
||||
|
||||
@Autowired
|
||||
private FlowChartRoleService flowChartRoleService;
|
||||
|
||||
|
||||
|
||||
|
||||
@ -191,6 +191,9 @@ public class FlowStartServiceImpl extends ServiceImpl<FlowStartMapper, FlowStart
|
||||
}).collect(Collectors.toList());
|
||||
List<EvaluationGroup> evaluationGroups = evaluationGroupService.selectEvaluationGroupByIds(ids);
|
||||
|
||||
Map<Long, List<FlowChartRole>> mustRole = new HashMap<>();
|
||||
Map<Long, List<FlowChartRole>> 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<FlowStartMapper, FlowStart
|
||||
|
||||
return R.error(evaluationGroup.getName() + "——无有效考核人员");
|
||||
}
|
||||
switch (start(evaluationGroup, flowStart, staffManages, staffIds)){
|
||||
switch (start(evaluationGroup, flowStart, staffManages, staffIds, mustRole, selfMustRole)){
|
||||
|
||||
case 1:
|
||||
return R.error(evaluationGroup.getName() + "——没有设置考核模板");
|
||||
@ -220,7 +223,8 @@ public class FlowStartServiceImpl extends ServiceImpl<FlowStartMapper, FlowStart
|
||||
}
|
||||
|
||||
private int start(EvaluationGroup evaluationGroup, FlowStart flowStart,
|
||||
Map<String, List<StaffEntity>> staffManages, List<StaffSimpleInfo> staffIds){
|
||||
Map<String, List<StaffEntity>> staffManages, List<StaffSimpleInfo> staffIds,
|
||||
Map<Long, List<FlowChartRole>> mustRole, Map<Long, List<FlowChartRole>> selfMustRole){
|
||||
|
||||
|
||||
List<ResultModelDto> resultModelDtos = resultModelService.selectResultDtoByGroupId(evaluationGroup.getId());
|
||||
@ -317,8 +321,24 @@ public class FlowStartServiceImpl extends ServiceImpl<FlowStartMapper, FlowStart
|
||||
|
||||
flowService.insertFlow(flow);
|
||||
FlowApprovalRole flowApprovalRole = null;
|
||||
List<FlowChartRole> 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<FlowStartMapper, FlowStart
|
||||
//依次
|
||||
stepIndex++;
|
||||
}
|
||||
|
||||
if(flowChartRoles != null && flowChartRoles.size() > 0){//设置必备权限
|
||||
String roles = flowChartRoles.stream().map(new Function<FlowChartRole, String>() {
|
||||
@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<FlowStartMapper, FlowStart
|
||||
}
|
||||
|
||||
}else{
|
||||
if(flowChartDetailRecord.getOptType().intValue() == ChartOptType.SELF.getCode()) {//指定人员的
|
||||
//获取被考核人的必备权限
|
||||
if (selfMustRole.containsKey(flow.getChartId())) {
|
||||
flowChartRoles.addAll(selfMustRole.get(flow.getChartId()));
|
||||
} else {
|
||||
List<FlowChartRole> 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<FlowStartMapper, FlowStart
|
||||
flowApprovalRoles.add(flowApprovalRole);
|
||||
flowApprovalRole.setStepIndex(stepIndex);
|
||||
|
||||
if(flowChartRoles != null && flowChartRoles.size() > 0){//设置必备权限
|
||||
String roles = flowChartRoles.stream().map(new Function<FlowChartRole, String>() {
|
||||
@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){
|
||||
|
||||
@ -145,49 +145,15 @@ public class FlowChartController {
|
||||
if(flowChartDetailRecordListReq.getRecordSimpleDtos() != null && flowChartDetailRecordListReq.getRecordSimpleDtos().size() > 0){
|
||||
List<FlowChartDetailRecord> inserts = new ArrayList<>();
|
||||
List<FlowChartDetailRecord> updaes = new ArrayList<>();
|
||||
Map<Long, List<FlowChartRole>> mustRole = new HashMap<>();
|
||||
Map<Long, List<FlowChartRole>> selfMustRole = new HashMap<>();
|
||||
|
||||
int index = 0;
|
||||
for (FlowChartDetailRecordSimpleReq req:flowChartDetailRecordListReq.getRecordSimpleDtos()
|
||||
) {
|
||||
FlowChartDetailRecord flowChartDetailRecord = new FlowChartDetailRecord();
|
||||
BeanUtils.copyProperties(req, flowChartDetailRecord);
|
||||
flowChartDetailRecord.setChartId(flowChartDetailRecordListReq.getId());
|
||||
List<FlowChartRole> 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<FlowChartRole> 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<FlowChartRole, String>() {
|
||||
@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);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user