Merge branch 'version_performance_2.0' of http://gitlab.ldxinyong.com/enterpriseManagement/lz_management into version_performance_2.0

This commit is contained in:
杜建超 2020-10-30 10:56:08 +08:00
commit ff4316d3c5
2 changed files with 278 additions and 257 deletions

View File

@ -3,6 +3,7 @@ package com.lz.modules.flow.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.lz.common.utils.R; import com.lz.common.utils.R;
import com.lz.modules.flow.entity.FlowStart; import com.lz.modules.flow.entity.FlowStart;
import com.lz.modules.flow.model.StartGroups;
import java.util.List; import java.util.List;
@ -35,6 +36,8 @@ public interface FlowStartService extends IService<FlowStart> {
FlowStart selectFlowStartByName(String name); FlowStart selectFlowStartByName(String name);
R startStaffs(StartGroups startGroupStaffIds);
R saveStart(FlowStart flowStart); R saveStart(FlowStart flowStart);
R getModelById(Long id, int type); R getModelById(Long id, int type);

View File

@ -180,158 +180,178 @@ public class FlowStartServiceImpl extends ServiceImpl<FlowStartMapper, FlowStart
for (int n = 0; n < evaluationGroups.size(); n++ for (int n = 0; n < evaluationGroups.size(); n++
) { ) {
EvaluationGroup evaluationGroup = evaluationGroups.get(n); EvaluationGroup evaluationGroup = evaluationGroups.get(n);
//下面初始化员工考核流程 switch (start(evaluationGroup, flowStart, staffManages)){
List<StaffSimpleInfo> staffIds = evaluationGroupService.selectAllStaffSimpleInfoByGroupId(evaluationGroup); case 1:
return R.error(evaluationGroup.getName() + "——无有效考核人员");
if(staffIds.size() == 0){ case 2:
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();//事务回滚 return R.error(evaluationGroup.getName() + "——没有设置考核模板");
case 3:
return R.error(evaluationGroup.getName() + "——无有效考核人员"); return R.error(evaluationGroup.getName() + "——没有绩效流程节点");
} case 4:
List<ResultModelDto> resultModelDtos = resultModelService.selectResultDtoByGroupId(evaluationGroup.getId()); return R.error(evaluationGroup.getName() + "——没有设置考核流程");
if(resultModelDtos.size() == 0){ case 5:
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();//事务回滚 return R.error(evaluationGroup.getName() + "——没有设置绩效管理人员");
return R.error(evaluationGroup.getName() + "——没有设置考核模板"); case 6:
return R.error(evaluationGroup.getName() + "——初始化考核流程失败");
} }
}
return R.ok("发起成功").put("data", flowStart);
}
List<FlowChart> flowCharts = flowChartService.selectFlowChartsByGroupId(evaluationGroup.getId()); private int start(EvaluationGroup evaluationGroup, FlowStart flowStart, Map<String, List<StaffEntity>> staffManages){
if(flowCharts.size() == 0){
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();//事务回滚
return R.error(evaluationGroup.getName() + "——没有绩效流程节点");
}
List<FlowChartDetailRecord> flowChartDetailRecords = new ArrayList<>();
for (FlowChart chart:flowCharts
) {//按照节点顺序获取正确的流程
List<FlowChartDetailRecord> flowChartDetailRecords1
= flowChartDetailRecordService.selectFlowChartDetailRecordByGroupIdAndChartId(evaluationGroup.getId(), chart.getId());
flowChartDetailRecords.addAll(flowChartDetailRecords1);
}
if(flowChartDetailRecords.size() == 0){ //下面初始化员工考核流程
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();//事务回滚 List<StaffSimpleInfo> staffIds = evaluationGroupService.selectAllStaffSimpleInfoByGroupId(evaluationGroup);
return R.error(evaluationGroup.getName() + "——没有设置考核流程");
}
Map<Long, String> chartNameMaps =
flowCharts.stream().collect(Collectors.toMap(FlowChart::getId, FlowChart::getName));//流程节点与流程名称对应map下面多次循环减少数据库查找
List<StaffEntity> staffManagers = null; if(staffIds.size() == 0){
if(!StringUtil.isEmpty(evaluationGroup.getManagerIds())){ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();//事务回滚
List<Long> mIds = Arrays.stream(evaluationGroup.getManagerIds().split(","))
.map(new Function<String, Long>() {
@Override
public Long apply(String s) {
return Long.parseLong(s);
}
}).collect(Collectors.toList());
//查找在职的管理人员
staffManagers = staffService.selectOnJobByIds(mIds);
} return 1;
if(staffManagers == null || staffManagers.size() == 0){ }
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();//事务回滚 List<ResultModelDto> resultModelDtos = resultModelService.selectResultDtoByGroupId(evaluationGroup.getId());
return R.error(evaluationGroup.getName() + "——没有设置绩效管理人员"); if(resultModelDtos.size() == 0){
} TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();//事务回滚
return 2;
}
//下面拷贝一份考评组信息发起后所使用的考评组id为复制后的id List<FlowChart> flowCharts = flowChartService.selectFlowChartsByGroupId(evaluationGroup.getId());
evaluationGroup.setCopyId(evaluationGroup.getId()); if(flowCharts.size() == 0){
evaluationGroup.setId(null); TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();//事务回滚
evaluationGroup.setGmtCreate(null); return 3;
evaluationGroup.setGmtModified(null); }
evaluationGroupService.insertEvaluationGroup(evaluationGroup); List<FlowChartDetailRecord> flowChartDetailRecords = new ArrayList<>();
for (FlowChart chart:flowCharts
) {//按照节点顺序获取正确的流程
List<FlowChartDetailRecord> flowChartDetailRecords1
= flowChartDetailRecordService.selectFlowChartDetailRecordByGroupIdAndChartId(evaluationGroup.getId(), chart.getId());
flowChartDetailRecords.addAll(flowChartDetailRecords1);
}
//拷贝考评组的指标信息 if(flowChartDetailRecords.size() == 0){
List<ResultTagetLib> resultTagetLibs = new ArrayList<>(); TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();//事务回滚
return 4;
}
Map<Long, String> chartNameMaps =
flowCharts.stream().collect(Collectors.toMap(FlowChart::getId, FlowChart::getName));//流程节点与流程名称对应map下面多次循环减少数据库查找
for (ResultModelDto dto:resultModelDtos List<StaffEntity> staffManagers = null;
) { if(!StringUtil.isEmpty(evaluationGroup.getManagerIds())){
List<Long> mIds = Arrays.stream(evaluationGroup.getManagerIds().split(","))
.map(new Function<String, Long>() {
dto.setEvaluationGroupId(evaluationGroup.getId());//设置拷贝组的id @Override
//下面拷贝一份考评组信息的维度信息 public Long apply(String s) {
ResultModel resultModel = new ResultModel(); return Long.parseLong(s);
BeanUtils.copyProperties(dto, resultModel);
resultModel.setId(null);
resultModelService.insertResultModel(resultModel);
List<ResultTagetLibDto> libDtos = resultTagetLibService.selectResultTagetLibDtoByModelId(dto.getId());
dto.setTagetLibs(libDtos);
for (ResultTagetLibDto libDto: libDtos
) {
//下面拷贝考评组里面的指标信息
ResultTagetLib resultTagetLib = new ResultTagetLib();
BeanUtils.copyProperties(libDto, resultTagetLib);
resultTagetLib.setModelId(resultModel.getId());//设置新的维度id
resultTagetLib.setId(null);
resultTagetLibs.add(resultTagetLib);
}
}
if(resultTagetLibs.size() > 0){
//插入备份的考评组指标信息
resultTagetLibService.insertResultTagetLibs(resultTagetLibs);
}
//下面初始化lz_flow流程表 lz_flow_approval_role流程审批表
List<FlowApprovalRole> flowApprovalRoles = new ArrayList<>();
int stepIndex = 0;
for (FlowChartDetailRecord flowChartDetailRecord:flowChartDetailRecords
) {
Flow flow = new Flow();
flow.setFlowId(evaluationGroup.getId());
flow.setOpt("+");
flow.setStartId(flowStart.getId());
flow.setChartId(flowChartDetailRecord.getChartId());
flow.setOptDesc(chartNameMaps.get(flowChartDetailRecord.getChartId()));
flowService.insertFlow(flow);
FlowApprovalRole flowApprovalRole = null;
if(flowChartDetailRecord.getOptType().intValue() == ChartOptType.APPOINT.getCode()){//指定人员的
String[] optIds = flowChartDetailRecord.getOptIds().split(",");
for (String id:optIds
) {
flowApprovalRole = new FlowApprovalRole();
flowApprovalRole.setFlowId(flow.getId());
flowApprovalRole.setApprovalId(Long.parseLong(id));
flowApprovalRole.setStepType(flowChartDetailRecord.getStepType());
flowApprovalRole.setRoleId(flowChartDetailRecord.getRoleIds());
flowApprovalRole.setType(flowChartDetailRecord.getOptType());
flowApprovalRoles.add(flowApprovalRole);
flowApprovalRole.setStepIndex(stepIndex);
if(flowChartDetailRecord.getStepType().intValue() == 0){
//依次
stepIndex++;
} }
} }).collect(Collectors.toList());
//stepIndex++; //查找在职的管理人员
if(flowApprovalRole != null){ staffManagers = staffService.selectOnJobByIds(mIds);
stepIndex = flowApprovalRole.getStepIndex() + 1;
} }
if(staffManagers == null || staffManagers.size() == 0){
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();//事务回滚
return 5;
}
//下面拷贝一份考评组信息发起后所使用的考评组id为复制后的id
evaluationGroup.setCopyId(evaluationGroup.getId());
evaluationGroup.setId(null);
evaluationGroup.setGmtCreate(null);
evaluationGroup.setGmtModified(null);
evaluationGroupService.insertEvaluationGroup(evaluationGroup);
//拷贝考评组的指标信息
List<ResultTagetLib> resultTagetLibs = new ArrayList<>();
for (ResultModelDto dto:resultModelDtos
) {
dto.setEvaluationGroupId(evaluationGroup.getId());//设置拷贝组的id
//下面拷贝一份考评组信息的维度信息
ResultModel resultModel = new ResultModel();
BeanUtils.copyProperties(dto, resultModel);
resultModel.setId(null);
resultModelService.insertResultModel(resultModel);
List<ResultTagetLibDto> libDtos = resultTagetLibService.selectResultTagetLibDtoByModelId(dto.getId());
dto.setTagetLibs(libDtos);
for (ResultTagetLibDto libDto: libDtos
) {
//下面拷贝考评组里面的指标信息
ResultTagetLib resultTagetLib = new ResultTagetLib();
BeanUtils.copyProperties(libDto, resultTagetLib);
resultTagetLib.setModelId(resultModel.getId());//设置新的维度id
resultTagetLib.setId(null);
resultTagetLibs.add(resultTagetLib);
}
}
if(resultTagetLibs.size() > 0){
//插入备份的考评组指标信息
resultTagetLibService.insertResultTagetLibs(resultTagetLibs);
}
//下面初始化lz_flow流程表 lz_flow_approval_role流程审批表
List<FlowApprovalRole> flowApprovalRoles = new ArrayList<>();
int stepIndex = 0;
for (FlowChartDetailRecord flowChartDetailRecord:flowChartDetailRecords
) {
Flow flow = new Flow();
flow.setFlowId(evaluationGroup.getId());
flow.setOpt("+");
flow.setStartId(flowStart.getId());
flow.setChartId(flowChartDetailRecord.getChartId());
flow.setOptDesc(chartNameMaps.get(flowChartDetailRecord.getChartId()));
flowService.insertFlow(flow);
FlowApprovalRole flowApprovalRole = null;
if(flowChartDetailRecord.getOptType().intValue() == ChartOptType.APPOINT.getCode()){//指定人员的
String[] optIds = flowChartDetailRecord.getOptIds().split(",");
for (String id:optIds
) {
}else{
flowApprovalRole = new FlowApprovalRole(); flowApprovalRole = new FlowApprovalRole();
flowApprovalRole.setFlowId(flow.getId()); flowApprovalRole.setFlowId(flow.getId());
flowApprovalRole.setApprovalId(Long.parseLong(id));
flowApprovalRole.setStepType(flowChartDetailRecord.getStepType()); flowApprovalRole.setStepType(flowChartDetailRecord.getStepType());
flowApprovalRole.setRoleId(flowChartDetailRecord.getRoleIds()); flowApprovalRole.setRoleId(flowChartDetailRecord.getRoleIds());
flowApprovalRole.setType(flowChartDetailRecord.getOptType()); flowApprovalRole.setType(flowChartDetailRecord.getOptType());
flowApprovalRoles.add(flowApprovalRole); flowApprovalRoles.add(flowApprovalRole);
flowApprovalRole.setStepIndex(stepIndex); flowApprovalRole.setStepIndex(stepIndex);
if(flowChartDetailRecord.getStepType().intValue() == 0){
stepIndex++; //依次
stepIndex++;
}
}
//stepIndex++;
if(flowApprovalRole != null){
stepIndex = flowApprovalRole.getStepIndex() + 1;
} }
}else{
flowApprovalRole = new FlowApprovalRole();
flowApprovalRole.setFlowId(flow.getId());
flowApprovalRole.setStepType(flowChartDetailRecord.getStepType());
flowApprovalRole.setRoleId(flowChartDetailRecord.getRoleIds());
flowApprovalRole.setType(flowChartDetailRecord.getOptType());
flowApprovalRoles.add(flowApprovalRole);
flowApprovalRole.setStepIndex(stepIndex);
stepIndex++;
} }
//插入记录/flowChart/saveDetailProcs
if(flowApprovalRoles.size() > 0){
flowApprovalRoleService.insertFlowApprovalRoles(flowApprovalRoles);
//初始化lz_result_details数据 }
List<ResultDetail> resultDetails = new ArrayList<>(); //插入记录/flowChart/saveDetailProcs
if(flowApprovalRoles.size() > 0){
flowApprovalRoleService.insertFlowApprovalRoles(flowApprovalRoles);
//初始化lz_result_details数据
List<ResultDetail> resultDetails = new ArrayList<>();
List<EvaluationStartStaff> evaluationStartStaffs = new ArrayList<>(); List<EvaluationStartStaff> evaluationStartStaffs = new ArrayList<>();
/*//下面初始化管理人员对应关系 /*//下面初始化管理人员对应关系
for (StaffEntity entity:staffManagers for (StaffEntity entity:staffManagers
@ -347,156 +367,154 @@ public class FlowStartServiceImpl extends ServiceImpl<FlowStartMapper, FlowStart
}*/ }*/
//下面初始化参与人员 //下面初始化参与人员
for (StaffSimpleInfo staffInfo:staffIds for (StaffSimpleInfo staffInfo:staffIds
) { ) {
EvaluationStartStaff evaluationStartStaff = new EvaluationStartStaff(); EvaluationStartStaff evaluationStartStaff = new EvaluationStartStaff();
evaluationStartStaff.setEvaluationId(evaluationGroup.getId()); evaluationStartStaff.setEvaluationId(evaluationGroup.getId());
evaluationStartStaff.setEvaluationName(evaluationGroup.getName()); evaluationStartStaff.setEvaluationName(evaluationGroup.getName());
evaluationStartStaff.setStaffId(staffInfo.getId()); evaluationStartStaff.setStaffId(staffInfo.getId());
evaluationStartStaff.setStartId(flowStart.getId()); evaluationStartStaff.setStartId(flowStart.getId());
evaluationStartStaff.setDepartmentId(staffInfo.getDepartmentId()); evaluationStartStaff.setDepartmentId(staffInfo.getDepartmentId());
evaluationStartStaff.setType(CheckStaffType.STAFF.getCode()); evaluationStartStaff.setType(CheckStaffType.STAFF.getCode());
evaluationStartStaffs.add(evaluationStartStaff); evaluationStartStaffs.add(evaluationStartStaff);
//初始化lz_result_records数据 //初始化lz_result_records数据
ResultRecord resultRecord = new ResultRecord(); ResultRecord resultRecord = new ResultRecord();
resultRecord.setDepartmentId(staffInfo.getDepartmentId()); resultRecord.setDepartmentId(staffInfo.getDepartmentId());
resultRecord.setDepartmentName(staffInfo.getDepartmentName()); resultRecord.setDepartmentName(staffInfo.getDepartmentName());
resultRecord.setStaffId(staffInfo.getId()); resultRecord.setStaffId(staffInfo.getId());
resultRecord.setStaffName(staffInfo.getName()); resultRecord.setStaffName(staffInfo.getName());
resultRecord.setType(1);//设置为提交目标 resultRecord.setType(1);//设置为提交目标
resultRecord.setStatus(0);//设置为新建 resultRecord.setStatus(0);//设置为新建
resultRecord.setStartId(flowStart.getId()); resultRecord.setStartId(flowStart.getId());
resultRecord.setEvaluationId(evaluationGroup.getId()); resultRecord.setEvaluationId(evaluationGroup.getId());
resultRecord.setFlowProcess(0);//设置为目标制定 resultRecord.setFlowProcess(0);//设置为目标制定
//下面初始化flow_staff_id_role字段步骤为0的 //下面初始化flow_staff_id_role字段步骤为0的
String roleJSON = "["; String roleJSON = "[";
for (int i = 0; i < flowApprovalRoles.size() ;i++){ for (int i = 0; i < flowApprovalRoles.size() ;i++){
FlowApprovalRole approvalRole = flowApprovalRoles.get(i); FlowApprovalRole approvalRole = flowApprovalRoles.get(i);
if(approvalRole.getStepIndex().intValue() == 0){//找到所有步骤为0的人员 if(approvalRole.getStepIndex().intValue() == 0){//找到所有步骤为0的人员
Long staffId = approvalRole.getApprovalId();//默认为指定人员 Long staffId = approvalRole.getApprovalId();//默认为指定人员
if(approvalRole.getType().intValue() == ChartOptType.SELF.getCode()){ if(approvalRole.getType().intValue() == ChartOptType.SELF.getCode()){
//制定人员为自己的 //制定人员为自己的
staffId = staffInfo.getId(); staffId = staffInfo.getId();
if(i == 0){//目前只设置一个多个不明确是否支持roleJSON是支持多个的 if(i == 0){//目前只设置一个多个不明确是否支持roleJSON是支持多个的
//设置当前审批员工id current_approval_staff_id //设置当前审批员工id current_approval_staff_id
resultRecord.setCurrentApprovalStaffId(staffInfo.getId()); resultRecord.setCurrentApprovalStaffId(staffInfo.getId());
//设置当前审批员工姓名 current_approval_staff_name //设置当前审批员工姓名 current_approval_staff_name
resultRecord.setCurrentApprovalStaffName(staffInfo.getName()); resultRecord.setCurrentApprovalStaffName(staffInfo.getName());
} }
} else if(approvalRole.getType().intValue() > 0){//当设置为几级领导时 } else if(approvalRole.getType().intValue() > 0){//当设置为几级领导时
///查找领导如果不存在那么设置管理人员 ///查找领导如果不存在那么设置管理人员
List<StaffEntity> staffLeader; List<StaffEntity> staffLeader;
String key = staffInfo.getDepartmentId() + "_" + approvalRole.getType(); String key = staffInfo.getDepartmentId() + "_" + approvalRole.getType();
if(staffManages.containsKey(key)){ if(staffManages.containsKey(key)){
staffLeader = staffManages.get(staffInfo.getDepartmentId()); staffLeader = staffManages.get(staffInfo.getDepartmentId());
}else{
DepartManagers departManagers =
staffService.findLeader(staffInfo.getId(), approvalRole.getType());
staffLeader = departManagers.getManagers();
staffManages.put(key, departManagers.getManagers());
}
if(staffLeader.size() == 0){
//没有领导通知到组设置的绩效管理人员
for (StaffEntity entity:staffManagers
) {
roleJSON += ("{\"roleId\":0,\"staffId\":" + entity.getId() + "},");//这里写死了权限为0的即为找不到领导
}
if(i == 0){//目前只设置一个多个不明确是否支持roleJSON是支持多个的
//设置当前审批员工id current_approval_staff_id
resultRecord.setCurrentApprovalStaffId(staffManagers.get(0).getId());
//设置当前审批员工姓名 current_approval_staff_name
resultRecord.setCurrentApprovalStaffName(staffManagers.get(0).getName());
}
}else{
for(int j = 0; j <staffLeader.size(); j++ ){
StaffEntity staff = staffLeader.get(j);
roleJSON += ("{\"roleId\":"+ approvalRole.getRoleId() +
",\"staffId\":" + staff.getId() + "},");
}
if(i == 0){//目前只设置一个多个不明确是否支持roleJSON是支持多个的
//设置当前审批员工id current_approval_staff_id
resultRecord.setCurrentApprovalStaffId(staffLeader.get(0).getId());
//设置当前审批员工姓名 current_approval_staff_name
resultRecord.setCurrentApprovalStaffName(staffLeader.get(0).getName());
}
}
continue;
}else{ }else{
DepartManagers departManagers =
staffService.findLeader(staffInfo.getId(), approvalRole.getType());
staffLeader = departManagers.getManagers();
staffManages.put(key, departManagers.getManagers());
}
if(staffLeader.size() == 0){
//没有领导通知到组设置的绩效管理人员
for (StaffEntity entity:staffManagers
) {
roleJSON += ("{\"roleId\":0,\"staffId\":" + entity.getId() + "},");//这里写死了权限为0的即为找不到领导
}
if(i == 0){//目前只设置一个多个不明确是否支持roleJSON是支持多个的 if(i == 0){//目前只设置一个多个不明确是否支持roleJSON是支持多个的
//设置当前审批员工id current_approval_staff_id //设置当前审批员工id current_approval_staff_id
resultRecord.setCurrentApprovalStaffId(approvalRole.getApprovalId()); resultRecord.setCurrentApprovalStaffId(staffManagers.get(0).getId());
//设置当前审批员工姓名 current_approval_staff_name //设置当前审批员工姓名 current_approval_staff_name
resultRecord.setCurrentApprovalStaffName(""); resultRecord.setCurrentApprovalStaffName(staffManagers.get(0).getName());
}
}else{
for(int j = 0; j <staffLeader.size(); j++ ){
StaffEntity staff = staffLeader.get(j);
roleJSON += ("{\"roleId\":"+ approvalRole.getRoleId() +
",\"staffId\":" + staff.getId() + "},");
}
if(i == 0){//目前只设置一个多个不明确是否支持roleJSON是支持多个的
//设置当前审批员工id current_approval_staff_id
resultRecord.setCurrentApprovalStaffId(staffLeader.get(0).getId());
//设置当前审批员工姓名 current_approval_staff_name
resultRecord.setCurrentApprovalStaffName(staffLeader.get(0).getName());
} }
} }
roleJSON += ("{\"roleId\":"+ approvalRole.getRoleId() +
",\"staffId\":" + staffId + "},");
continue; continue;
} }else{
break; if(i == 0){//目前只设置一个多个不明确是否支持roleJSON是支持多个的
} //设置当前审批员工id current_approval_staff_id
roleJSON += "]"; resultRecord.setCurrentApprovalStaffId(approvalRole.getApprovalId());
roleJSON = roleJSON.replace(",]", "]"); //设置当前审批员工姓名 current_approval_staff_name
resultRecord.setFlowStaffIdRole(roleJSON); resultRecord.setCurrentApprovalStaffName("");
resultRecordService.insertResultRecord(resultRecord);
//下面生成实际的考核流程
resultRecordService.initFlowRecord(resultRecord.getId());
//下面生成ResultDetail对象
for (ResultModelDto modelDto:resultModelDtos
) {
if(modelDto.getTagetLibs() != null && modelDto.getTagetLibs().size() > 0){//模板里面有添加指标
for (ResultTagetLibDto libDto:
modelDto.getTagetLibs()) {
ResultDetail resultDetail = new ResultDetail();
resultDetail.setRecordId(resultRecord.getId());
resultDetail.setTarget(libDto.getName());
resultDetail.setType(modelDto.getType());
resultDetail.setKeyResult(libDto.getKeyResult());
resultDetail.setCheckWeight(libDto.getWeight());
resultDetail.setStaffId(staffInfo.getId());
resultDetail.setPriority(libDto.getOrderBy());
resultDetails.add(resultDetail);
} }
} }
roleJSON += ("{\"roleId\":"+ approvalRole.getRoleId() +
",\"staffId\":" + staffId + "},");
continue;
}
break;
}
roleJSON += "]";
roleJSON = roleJSON.replace(",]", "]");
resultRecord.setFlowStaffIdRole(roleJSON);
resultRecordService.insertResultRecord(resultRecord);
//下面生成实际的考核流程
resultRecordService.initFlowRecord(resultRecord.getId());
//下面生成ResultDetail对象
for (ResultModelDto modelDto:resultModelDtos
) {
if(modelDto.getTagetLibs() != null && modelDto.getTagetLibs().size() > 0){//模板里面有添加指标
for (ResultTagetLibDto libDto:
modelDto.getTagetLibs()) {
ResultDetail resultDetail = new ResultDetail();
resultDetail.setRecordId(resultRecord.getId());
resultDetail.setTarget(libDto.getName());
resultDetail.setType(modelDto.getType());
resultDetail.setKeyResult(libDto.getKeyResult());
resultDetail.setCheckWeight(libDto.getWeight());
resultDetail.setStaffId(staffInfo.getId());
resultDetail.setPriority(libDto.getOrderBy());
resultDetails.add(resultDetail);
}
} }
} }
//如果有数据插入lz_result_detail表 }
if(resultDetails.size() > 0){ //如果有数据插入lz_result_detail表
// if(resultDetails.size() > 0){
resultDetailService.insertResultDetails(resultDetails); //
resultDetailService.insertResultDetails(resultDetails);
}
evaluationStartStaffService.insertEvaluationStartStaffs(evaluationStartStaffs);
//下面通知所有参与考核人员
//如果有下面通知所有管理人员
}else{
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();//事务回滚
return R.error(evaluationGroup.getName() + "——初始化考核流程失败");
} }
evaluationStartStaffService.insertEvaluationStartStaffs(evaluationStartStaffs);
//下面通知所有参与考核人员
//如果有下面通知所有管理人员
}else{
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();//事务回滚
return 6;
} }
return R.ok("发起成功").put("data", flowStart); return 0;
} }
@Override @Override