diff --git a/src/main/java/com/lz/modules/app/controller/ResultRecordController.java b/src/main/java/com/lz/modules/app/controller/ResultRecordController.java index 0b23aaa7..5a2e87c6 100644 --- a/src/main/java/com/lz/modules/app/controller/ResultRecordController.java +++ b/src/main/java/com/lz/modules/app/controller/ResultRecordController.java @@ -712,6 +712,7 @@ public class ResultRecordController extends AbstractController { resultDetail.setStaffId(resultRecord.getStaffId()); resultDetail.setRecordId(resultRecord.getId()); resultDetail.setType(model.getType()); + resultDetail.setModelId(model.getId()); inserts.add(resultDetail); } if(resultDetail.getIsDelete() == null || resultDetail.getIsDelete().intValue() == 0){ diff --git a/src/main/java/com/lz/modules/flow/service/impl/EvaluationGroupServiceImpl.java b/src/main/java/com/lz/modules/flow/service/impl/EvaluationGroupServiceImpl.java index d8966a2f..941867bb 100644 --- a/src/main/java/com/lz/modules/flow/service/impl/EvaluationGroupServiceImpl.java +++ b/src/main/java/com/lz/modules/flow/service/impl/EvaluationGroupServiceImpl.java @@ -138,28 +138,32 @@ public class EvaluationGroupServiceImpl extends ServiceImpl staffRoles = staffRoleService.selectAllByStaffId(sysUserEntity.getUserId()); + List staffRoles = staffRoleService.selectAllByStaffId(sysUserEntity.getUserId());//一个人只会有一个 if(staffRoles.size() == 0){ log.info("非绩效管理员登录查询"); return null; } - List staffRoleEvaluationGroups = - staffRoleEvaluationGroupService.selectStaffRoleEvaluationsGroupByStaffRoles(staffRoles); - if(staffRoleEvaluationGroups.size() == 0){ - log.info("查询的管理组为空"); - return null; - } - gIds = new ArrayList<>(); - for (StaffRoleEvaluationGroup staffRoleEvaluationGroup:staffRoleEvaluationGroups - ) { - if(staffRoleEvaluationGroup.getEvaluationGroupId().longValue() == 0l){//管理所有组 - gIds = null; - log.info("管理所有组"); - break; + if(staffRoles.get(0).getEvaluationGroupId().longValue() != 0L){//管理指定考评组的 + List staffRoleEvaluationGroups = + staffRoleEvaluationGroupService.selectStaffRoleEvaluationsGroupByStaffRoles(staffRoles); + if(staffRoleEvaluationGroups.size() == 0){ + log.info("查询的管理组为空"); + return null; } - gIds.add(staffRoleEvaluationGroup.getEvaluationGroupId());//管理特定组 + gIds = new ArrayList<>(); + for (StaffRoleEvaluationGroup staffRoleEvaluationGroup:staffRoleEvaluationGroups + ) { + if(staffRoleEvaluationGroup.getEvaluationGroupId().longValue() == 0l){//管理所有组 + gIds = null; + log.info("管理所有组"); + break; + } + gIds.add(staffRoleEvaluationGroup.getEvaluationGroupId());//管理特定组 + + } } + } List finalGIds = gIds; PageUtils pageUtils = PageUtils.startPage(req.getCurrPage(), req.getPageSize()) 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 70a38a8c..0a2bc155 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 @@ -1,13 +1,20 @@ package com.lz.modules.flow.service.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.google.common.collect.Lists; import com.lz.common.emun.ChartOptType; import com.lz.common.emun.CheckStaffType; import com.lz.common.emun.WorkMsgTypeEnum; import com.lz.common.utils.R; import com.lz.common.utils.StringUtil; +import com.lz.modules.app.entity.DepartmentsStaffRelateEntity; import com.lz.modules.app.entity.StaffEntity; import com.lz.modules.app.entity.StaffSimpleInfo; +import com.lz.modules.app.enums.FlowApprovalRoleTypeEnums; +import com.lz.modules.app.enums.FlowRecordStatusEnums; +import com.lz.modules.app.enums.RoleEnums; +import com.lz.modules.app.service.DepartmentsService; +import com.lz.modules.app.service.DepartmentsStaffRelateService; import com.lz.modules.app.service.StaffService; import com.lz.modules.flow.dao.EvaluationStartStaffMapper; import com.lz.modules.flow.dao.FlowStartMapper; @@ -21,6 +28,7 @@ import com.lz.modules.sys.entity.app.ResultRecord; import com.lz.modules.sys.service.app.ResultDetailService; import com.lz.modules.sys.service.app.ResultRecordService; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.map.HashedMap; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -29,6 +37,9 @@ import org.springframework.transaction.interceptor.TransactionAspectSupport; import java.text.SimpleDateFormat; import java.util.*; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; import java.util.function.Function; import java.util.stream.Collectors; @@ -88,6 +99,20 @@ public class FlowStartServiceImpl extends ServiceImpl> mustRole = new HashMap<>(); Map> selfMustRole = new HashMap<>(); - + List noticeStaff = new ArrayList<>(); for (int n = 0; n < evaluationGroups.size(); n++ ) { EvaluationGroup evaluationGroup = evaluationGroups.get(n); @@ -293,9 +318,12 @@ public class FlowStartServiceImpl extends ServiceImpl libDtos = resultTagetLibService.selectResultTagetLibDtoByModelId(dto.getId()); dto.setTagetLibs(libDtos); for (ResultTagetLibDto libDto: libDtos @@ -374,6 +402,7 @@ public class FlowStartServiceImpl extends ServiceImpl 0){ //插入备份的考评组指标信息 @@ -410,6 +439,7 @@ public class FlowStartServiceImpl extends ServiceImpl evaluationStartStaffs = new ArrayList<>(); List resultDetails = new ArrayList(); + //下面初始化参与人员 for (StaffSimpleInfo staffInfo:staffIds ) { @@ -443,8 +473,11 @@ public class FlowStartServiceImpl extends ServiceImpl 0){ // resultDetailService.insertResultDetails(resultDetails); - } - - } evaluationStartStaffService.insertEvaluationStartStaffs(evaluationStartStaffs); return 0; @@ -506,7 +536,6 @@ public class FlowStartServiceImpl extends ServiceImpl resultDetails = new ArrayList<>(); List evaluationStartStaffs = new ArrayList<>(); - + List resultRecords = new ArrayList<>(); //下面初始化参与人员 for (StaffSimpleInfo staffInfo:staffIds ) { @@ -612,7 +639,6 @@ public class FlowStartServiceImpl extends ServiceImpl flows = flowService.selectByFlowId(resultRecord.getEvaluationId(),resultRecord.getStartId()); + List flowIds = new ArrayList<>(); + for(Flow flow:flows){ + flowIds.add(flow.getId()); + } + + int i = 0; + for (FlowApprovalRole flowApprovalRole : flowApprovalRoles) { + FlowRecord flowRecord = new FlowRecord(); + flowRecord.setRecordId(resultRecord.getId()); + StaffEntity approvalStaff = new StaffEntity(); + if (FlowApprovalRoleTypeEnums.ME.getType().equals(flowApprovalRole.getType())) { + approvalStaff = staffService.selectStaffById(resultRecord.getStaffId()); + } else if (FlowApprovalRoleTypeEnums.STAFF.getType().equals(flowApprovalRole.getType())) { + approvalStaff = staffService.selectStaffById(flowApprovalRole.getApprovalId()); + } else if (FlowApprovalRoleTypeEnums.ONE_SUPPER.getType().equals(flowApprovalRole.getType())) { + approvalStaff = getDepartmentStaff(resultRecord.getStaffId(), 1); + } else if (FlowApprovalRoleTypeEnums.TWO_SUPPER.getType().equals(flowApprovalRole.getType())) { + approvalStaff = getDepartmentStaff(resultRecord.getStaffId(), 2); + } else if (FlowApprovalRoleTypeEnums.THREE_SUPPER.getType().equals(flowApprovalRole.getType())) { + approvalStaff = getDepartmentStaff(resultRecord.getStaffId(), 3); + } else if (FlowApprovalRoleTypeEnums.FOUR_SUPPER.getType().equals(flowApprovalRole.getType())) { + approvalStaff = getDepartmentStaff(resultRecord.getStaffId(), 4); + } else if (FlowApprovalRoleTypeEnums.FOUR_SUPPER.getType().equals(flowApprovalRole.getType())) { + approvalStaff = getDepartmentStaff(resultRecord.getStaffId(), 5); + } + if(approvalStaff !=null && StringUtil.isNotBlank(approvalStaff.getName())){ + insertFlowRecord(flowRecord,approvalStaff,flows,flowApprovalRole,resultRecord,i,null); + }else{ + List staffRoles= staffRoleService.selectAllStaffRoleByDepartmentLevel(Arrays.asList(new String[]{RoleEnums.MASTER_PM.getName(),RoleEnums.CHILD_PM.getName()})); + for(StaffRole staffRole:staffRoles){ + approvalStaff = staffService.selectStaffById(staffRole.getStaffId()); + if(staffRole.getDepartmentId() ==0){ //如果是管理所有部门 + insertFlowRecord(flowRecord,approvalStaff,flows,flowApprovalRole,resultRecord,i,1); + }else{ + DepartmentsStaffRelateEntity relateEntity = departmentsStaffRelateService.selectLastDepartmentByStaffId(resultRecord.getStaffId()); + Map map = departmentsService.selectUserAllDepartmentIds(relateEntity.getDepartmentId()); + List staffRoleDepartments = staffRoleDepartmentService.selectStaffRoleDepartmentByStaffRoleId(staffRole.getId()); + boolean flag = false; + for(StaffRoleDepartment staffRoleDepartment: staffRoleDepartments){ + String departmentName = map.get(staffRoleDepartment.getDepartmentId()); + if(StringUtil.isNotBlank(departmentName)){ + flag = true; + break; + } + } + if(flag){ //如果管理员是管理特定部门 + insertFlowRecord(flowRecord,approvalStaff,flows,flowApprovalRole,resultRecord,i,1); + } + } + } + } + i++; + } + resultRecordService.updateResultRecordById(resultRecord); + + /*ExecutorService executor = Executors.newFixedThreadPool(10); + List resultRecords = Lists.newArrayList(); + CompletableFuture> listCompletableFuture = CompletableFuture.supplyAsync(() -> resultRecordService.list(), executor); + try { + resultRecords = listCompletableFuture.get(); + } catch (Exception e) { + e.printStackTrace(); + }*/ + + //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.setStaffId(resultRecord.getId()); resultDetail.setPriority(libDto.getOrderBy()); resultDetail.setModelId(modelDto.getId()); resultDetails.add(resultDetail); @@ -734,12 +827,8 @@ public class FlowStartServiceImpl extends ServiceImpl 0){ // resultDetailService.insertResultDetails(resultDetails); - } evaluationStartStaffService.insertEvaluationStartStaffs(evaluationStartStaffs); - //下面通知所有参与考核人员 - - //如果有下面通知所有管理人员 }else{ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();//事务回滚 log.info("初始化考核流程失败"); @@ -748,6 +837,57 @@ public class FlowStartServiceImpl extends ServiceImpl flows,FlowApprovalRole flowApprovalRole ,ResultRecord resultRecord,int i,Integer stepType ){ + flowRecord.setApprovalStaffName(approvalStaff.getName()); + flowRecord.setApprovalStaffId(approvalStaff.getId()); + flowRecord.setFlowName(getFlow(flows, flowApprovalRole.getFlowId()).getOptDesc()); + flowRecord.setRecordStaffId(resultRecord.getStaffId()); + flowRecord.setFlowId(flowApprovalRole.getFlowId()); + FlowChart flowChart = flowService.selectFlowChartByChartId(flowApprovalRole.getFlowId()); + flowRecord.setProcessId(flowChart.getProcessId()); + flowRecord.setFlowProcess(flowChart.getFlowProcess()); + String staffRole = StaffRoles.getStaffRole(approvalStaff.getId(), StringUtil.strToLongs(flowApprovalRole.getRoleId())); + if (i == 0) { + flowRecord.setStatus(FlowRecordStatusEnums.CURRENT_FLOW_STATUS.getStatus()); + resultRecord.setFlowStaffIdRole(staffRole); + resultRecord.setFlowProcess(flowChart.getFlowProcess()); + } else { + flowRecord.setStatus(FlowRecordStatusEnums.UN_TO_STATUS.getStatus()); + if(new Integer(4).equals(flowChart.getFlowProcess())){ + EvaluationStartStaff evaluationStartStaff = evaluationStartStaffService.selectEvaluationStartById(resultRecord.getEvaluationId(),resultRecord.getStartId()); + if(evaluationStartStaff !=null && new Integer(1).equals(evaluationStartStaff.getScore())){ + flowRecord.setStatus(FlowRecordStatusEnums.SKIP_STATUS.getStatus()); + }else{ + log.info("evaluationStartStaff is null evaluationId :" + resultRecord.getEvaluationId() + ", startId : " + resultRecord.getStartId()); + } + } + } + flowRecord.setFlowStaffIdRole(staffRole); + flowRecord.setFlowIndex(flowApprovalRole.getStepIndex()); + flowRecord.setType(stepType !=null ? stepType :flowApprovalRole.getStepType()); //步骤类型0:依次,1:或签(同时通知,一人通过或拒绝即可),2会签(同时通知,所有人同意才可) + flowRecordService.insertFlowRecord(flowRecord); + + } + + public Flow getFlow(List flows,Long flowId){ + for(Flow flow : flows){ + if(flow.getId().equals(flowId)){ + return flow; + } + } + return new Flow(); + } + + public StaffEntity getDepartmentStaff(Long staffId, int level) { + DepartManagers departManagers = staffService.findLeader( staffId, level); + List staffEntities = departManagers.getManagers(); + if(CollectionUtils.isNotEmpty(staffEntities)){ + return staffEntities.get(0); + } + return new StaffEntity(); + + } + @Override public R getModelById(Long id, int type){ /*EvaluationGroup evaluationGroup = evaluationGroupService.selectEvaluationGroupById(id); diff --git a/src/main/java/com/lz/modules/job/business/DingtalkBusiness.java b/src/main/java/com/lz/modules/job/business/DingtalkBusiness.java index 593d8ae1..01b724e6 100644 --- a/src/main/java/com/lz/modules/job/business/DingtalkBusiness.java +++ b/src/main/java/com/lz/modules/job/business/DingtalkBusiness.java @@ -237,29 +237,31 @@ public class DingtalkBusiness { public String sendWorkMSGWithAsyn(StaffSimpleInfo fromStaff, List toStaffids, int type) { - - if (toStaffids.get(0).getEmployeeId() == null || toStaffids.get(0).getEmployeeId().length() == 0) { - //查询第三方id - List ids = toStaffids.stream().map(new Function() { - @Override - public Long apply(StaffSimpleInfo staffSimpleInfo) { - return staffSimpleInfo.getId(); + if(toStaffids.size() > 0){ + if (toStaffids.get(0).getEmployeeId() == null || toStaffids.get(0).getEmployeeId().length() == 0) { + //查询第三方id + List ids = toStaffids.stream().map(new Function() { + @Override + public Long apply(StaffSimpleInfo staffSimpleInfo) { + return staffSimpleInfo.getId(); + } + }).collect(Collectors.toList()); + List staffSimpleInfos = staffService.selectStaffSimpleInfos(ids); + Map map = toStaffids.stream().collect(Collectors.toMap(StaffSimpleInfo::getId, e -> e)); + for (StaffSimpleInfo staff : staffSimpleInfos + ) { + StaffSimpleInfo staff1 = map.get(staff.getId()); + staff1.setEmployeeId(staff1.getEmployeeId()); } - }).collect(Collectors.toList()); - List staffSimpleInfos = staffService.selectStaffSimpleInfos(ids); - Map map = toStaffids.stream().collect(Collectors.toMap(StaffSimpleInfo::getId, e -> e)); - for (StaffSimpleInfo staff : staffSimpleInfos - ) { - StaffSimpleInfo staff1 = map.get(staff.getId()); - staff1.setEmployeeId(staff1.getEmployeeId()); } - } - WorkMsgTypeEnum workMsgTypeEnum = WorkMsgTypeEnum.findRoleTypeByCode(type); + WorkMsgTypeEnum workMsgTypeEnum = WorkMsgTypeEnum.findRoleTypeByCode(type); - ThreadSendMessage threadSendMessage = new ThreadSendMessage(fromStaff, toStaffids, workMsgTypeEnum, appid); - Thread thread = new Thread(threadSendMessage); - thread.start(); - return "OK"; + ThreadSendMessage threadSendMessage = new ThreadSendMessage(fromStaff, toStaffids, workMsgTypeEnum, appid); + Thread thread = new Thread(threadSendMessage); + thread.start(); + return "OK"; + } + return "error"; }