保存节点的时候增加必备权限的复制

This commit is contained in:
wulin 2020-10-29 15:07:16 +08:00
parent a1ea501c07
commit b92dfdb974
7 changed files with 79 additions and 6 deletions

View File

@ -11,6 +11,9 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lz.modules.flow.entity.FlowChartRole;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface FlowChartRoleMapper extends BaseMapper<FlowChartRole> {
@ -30,4 +33,5 @@ public interface FlowChartRoleMapper extends BaseMapper<FlowChartRole> {
int deleteFlowChartRoleById(@Param("id")Long id);
List<FlowChartRole> selectFlowChartRolesByChartIdAndType(@Param("id") Long id, @Param("type") int type);
}

View File

@ -3,6 +3,8 @@ package com.lz.modules.flow.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.lz.modules.flow.entity.FlowChartRole;
import java.util.List;
/**
* <p>
* 流程节点权限对应关系表 服务类
@ -30,4 +32,5 @@ public interface FlowChartRoleService extends IService<FlowChartRole> {
int deleteFlowChartRoleById(Long id);
List<FlowChartRole> selectFlowChartRolesByChartIdAndType(Long id, int type);
}

View File

@ -7,6 +7,8 @@ import com.lz.modules.flow.service.FlowChartRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* <p>
* 流程节点权限对应关系表 服务类
@ -58,6 +60,11 @@ public class FlowChartRoleServiceImpl extends ServiceImpl<FlowChartRoleMapper, F
return flowChartRoleMapper.deleteFlowChartRoleById(id);
}
@Override
public List<FlowChartRole> selectFlowChartRolesByChartIdAndType(Long id, int type){
return flowChartRoleMapper.selectFlowChartRolesByChartIdAndType(id, type);
}
}

View File

@ -308,7 +308,7 @@ public class FlowStartServiceImpl extends ServiceImpl<FlowStartMapper, FlowStart
}
}
//插入记录
//插入记录/flowChart/saveDetailProcs
if(flowApprovalRoles.size() > 0){
flowApprovalRoleService.insertFlowApprovalRoles(flowApprovalRoles);
@ -375,7 +375,7 @@ public class FlowStartServiceImpl extends ServiceImpl<FlowStartMapper, FlowStart
} else if(approvalRole.getType().intValue() > 0){//当设置为几级领导时
///查找领导如果不存在那么设置管理人员
List<StaffEntity> staffLeader;
String key = staffInfo.getDepartmentId() + approvalRole.getType();
String key = staffInfo.getDepartmentId() + "_" + approvalRole.getType();
if(staffManages.containsKey(key)){
staffLeader = staffManages.get(staffInfo.getDepartmentId());
}else{

View File

@ -7,11 +7,13 @@ import com.lz.modules.app.dto.StaffSimpleDto;
import com.lz.modules.app.service.StaffService;
import com.lz.modules.flow.entity.FlowChart;
import com.lz.modules.flow.entity.FlowChartDetailRecord;
import com.lz.modules.flow.entity.FlowChartRole;
import com.lz.modules.flow.entity.FlowManager;
import com.lz.modules.flow.model.*;
import com.lz.modules.flow.req.FlowChartDetailRecordListReq;
import com.lz.modules.flow.req.FlowChartDetailRecordSimpleReq;
import com.lz.modules.flow.service.FlowChartDetailRecordService;
import com.lz.modules.flow.service.FlowChartRoleService;
import com.lz.modules.flow.service.FlowChartService;
import com.lz.modules.flow.service.FlowManagerService;
import io.swagger.annotations.*;
@ -19,9 +21,7 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.*;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.stream.Collectors;
@ -45,6 +45,9 @@ public class FlowChartController {
@Autowired
private StaffService staffService;
@Autowired
private FlowChartRoleService flowChartRoleService;
@GetMapping("/getByFlowManagerId")
@ApiOperation("获取大流程节点")
@ApiResponses({@ApiResponse(code = 200,message = "成功",response = FlowChartDto.class)})
@ -142,12 +145,50 @@ 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);
flowChartDetailRecord.setStatus(flowChartDetailRecordListReq.getStatus());

View File

@ -79,5 +79,9 @@
update lz_flow_chart_role set is_delete = 1 where id=#{id} limit 1
</update>
<select id="selectFlowChartRolesByChartIdAndType" resultType="FlowChartRole" >
select * from lz_flow_chart_role where chart_id=#{id} and is_delete = 0 and type = #{type}
</select>
</mapper>

View File

@ -1,12 +1,15 @@
package com.lz.mysql;
import com.lz.common.utils.StringUtil;
import com.lz.modules.flow.entity.FlowChartRole;
import org.springframework.util.ResourceUtils;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
public class MysqlMain {
@ -62,7 +65,18 @@ public class MysqlMain {
test.setMobile("18969093321");
testMaps.add(test);
Map<String, TestMap> t = testMaps.stream().collect(Collectors.toMap(TestMap::getName, testMap -> testMap));*/
Map<String, TestMap> t = testMaps.stream().collect(Collectors.toMap(TestMap::getName, testMap -> testMap));
List<Long> flowChartRoles = new ArrayList<>();
flowChartRoles.add(1L);
flowChartRoles.add(2L);
flowChartRoles.add(3L);
flowChartRoles.add(4L);
String roles = flowChartRoles.stream().map(new Function<Long, String>() {
@Override
public String apply(Long flowChartRole) {
return flowChartRole.toString();
}
}).collect(Collectors.joining(","));*/
String path = ResourceUtils.getURL("classpath:").getPath();