diff --git a/src/main/java/com/lz/common/emun/WorkMsgTypeEnum.java b/src/main/java/com/lz/common/emun/WorkMsgTypeEnum.java index 5222cd33..7d8f2b6f 100644 --- a/src/main/java/com/lz/common/emun/WorkMsgTypeEnum.java +++ b/src/main/java/com/lz/common/emun/WorkMsgTypeEnum.java @@ -18,6 +18,7 @@ public enum WorkMsgTypeEnum { END(5, "绩效终止", "去查看", "# 绩效终止\n ## @,你的绩效终止"), START_WORK(6, "绩效考评待办事项", "去查看", "# 绩效目标制定\n ## @,你的绩效需要制定目标"), START_SCORE(7, "绩效考评待办事项", "去查看", "# 绩效结果输入\n ## @,你的绩效需要输入结果"), + PROCESS(8, "绩效考评待办事项", "去查看", "# @的绩效\n ## 需您去处理"), // 您的2020年10月绩效考核已经开始,请尽快制定绩效目标 // 吴林的2020年12月绩效考核的目标需要您确认,点击前往确认 ; 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 3887a486..03a80800 100644 --- a/src/main/java/com/lz/modules/app/controller/ResultRecordController.java +++ b/src/main/java/com/lz/modules/app/controller/ResultRecordController.java @@ -387,6 +387,9 @@ public class ResultRecordController extends AbstractController { staffs.addAll(departManagers.getManagers()); } } + /*if(staffs.size() == 0){ + return R.error("找不到有效的评分人,设置的评分人不存在"); + }*/ for (StaffEntity staff:staffs ) { @@ -423,45 +426,48 @@ public class ResultRecordController extends AbstractController { //下面设置计算公式 dto.setCalculate(setCalculateValue(calculateModels, dto)) ; weight = weight.add(dto.getCheckWeight()); - //获取评分详细 - List scores = - resultScoreService.selectResultScoresByDetailIdAndOrderByStaffIds(dto.getId(), scoreDtos); - if(scores.size() > 0){ - // - List scoreDtos1 = new ArrayList<>(); - for (ResultScoreDto scoreDto: scoreDtos - ) {// + if(scoreDtos.size() > 0){ + //获取评分详细 + List scores = + resultScoreService.selectResultScoresByDetailIdAndOrderByStaffIds(dto.getId(), scoreDtos); + if(scores.size() > 0){ // - boolean isAdd = false; - for (ResultScore score: - scores) { - if(scoreDto.getApprovalId().longValue() == score.getApprovalId().longValue()){ + List scoreDtos1 = new ArrayList<>(); + for (ResultScoreDto scoreDto: scoreDtos + ) {// + // + boolean isAdd = false; + for (ResultScore score: + scores) { + if(scoreDto.getApprovalId().longValue() == score.getApprovalId().longValue()){ + ResultScoreDto scoreDto1 = new ResultScoreDto(); + BeanUtils.copyProperties(score, scoreDto1); + scoreDto1.setApprovalId(scoreDto.getApprovalId()); + scoreDto1.setApprovalName(scoreDto.getApprovalName()); + scoreDto1.setWeight(scoreDto.getWeight()); + scoreDtos1.add(scoreDto1); + scores.remove(score); + isAdd = true; + break; + } + } + if(!isAdd){ ResultScoreDto scoreDto1 = new ResultScoreDto(); - BeanUtils.copyProperties(score, scoreDto1); scoreDto1.setApprovalId(scoreDto.getApprovalId()); scoreDto1.setApprovalName(scoreDto.getApprovalName()); scoreDto1.setWeight(scoreDto.getWeight()); scoreDtos1.add(scoreDto1); - scores.remove(score); - isAdd = true; - break; } } - if(!isAdd){ - ResultScoreDto scoreDto1 = new ResultScoreDto(); - scoreDto1.setApprovalId(scoreDto.getApprovalId()); - scoreDto1.setApprovalName(scoreDto.getApprovalName()); - scoreDto1.setWeight(scoreDto.getWeight()); - scoreDtos1.add(scoreDto1); - } + dto.setScoreDtos(scoreDtos1); + }else{ + dto.setScoreDtos(scoreDtos); } - dto.setScoreDtos(scoreDtos1); - }else{ - dto.setScoreDtos(scoreDtos); } } + resultRecortModelDto.setDetailDtos(detailDtos); resultRecortModelDtos.add(resultRecortModelDto); } diff --git a/src/main/java/com/lz/modules/flow/dao/StaffRoleEvaluationGroupMapper.java b/src/main/java/com/lz/modules/flow/dao/StaffRoleEvaluationGroupMapper.java index 66a1a3a4..da7e356c 100644 --- a/src/main/java/com/lz/modules/flow/dao/StaffRoleEvaluationGroupMapper.java +++ b/src/main/java/com/lz/modules/flow/dao/StaffRoleEvaluationGroupMapper.java @@ -9,6 +9,7 @@ package com.lz.modules.flow.dao; */ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.lz.modules.app.dto.EvaluationGroupInfo; +import com.lz.modules.flow.entity.StaffRole; import com.lz.modules.flow.entity.StaffRoleEvaluationGroup; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -40,5 +41,9 @@ public interface StaffRoleEvaluationGroupMapper extends BaseMapper selectStaffRoleEvaluationsGroupByStaffRoles(@Param("list") List staffRoles); + StaffRoleEvaluationGroup selectEvaluationGroupIdsByRoleIdGroupId(@Param("roleId") Long roleId, @Param("groupId") Long groupId); + } \ No newline at end of file diff --git a/src/main/java/com/lz/modules/flow/dao/StaffRoleMapper.java b/src/main/java/com/lz/modules/flow/dao/StaffRoleMapper.java index f98b77b8..6ef6647d 100644 --- a/src/main/java/com/lz/modules/flow/dao/StaffRoleMapper.java +++ b/src/main/java/com/lz/modules/flow/dao/StaffRoleMapper.java @@ -59,7 +59,11 @@ public interface StaffRoleMapper extends BaseMapper { List selectAllMenus(@Param("userId") Long userId); + List selectMastRoles(); + + List selectAllGroupManageRoles(); List selectAllStaffRoleByDepartmentLevel(@Param("departmentLevels") List departmentLevels); StaffRole selectStaffRolesByStaffIdDepartmentLevelList(@Param("staffId") Long staffId, @Param("departmentLevels") List departmentLevels); + } \ No newline at end of file diff --git a/src/main/java/com/lz/modules/flow/service/EvaluationGroupService.java b/src/main/java/com/lz/modules/flow/service/EvaluationGroupService.java index 543168f9..3e3a4513 100644 --- a/src/main/java/com/lz/modules/flow/service/EvaluationGroupService.java +++ b/src/main/java/com/lz/modules/flow/service/EvaluationGroupService.java @@ -8,6 +8,7 @@ import com.lz.modules.flow.entity.EvaluationGroup; import com.lz.modules.flow.req.EvaluationGroupReq; import com.lz.modules.performance.dto.CheckStaffDto; import com.lz.modules.performance.req.CheckStaffReq; +import com.lz.modules.sys.entity.SysUserEntity; import java.util.List; @@ -41,7 +42,7 @@ public interface EvaluationGroupService extends IService { List selectAllStaffIdsByGroupId(Long id); - PageUtils selectEvaluationGroupByReq(EvaluationGroupReq req); + PageUtils selectEvaluationGroupByReq(EvaluationGroupReq req, SysUserEntity sysUserEntity); List selectEvaluationGroupByIds(List ids); diff --git a/src/main/java/com/lz/modules/flow/service/StaffRoleEvaluationGroupService.java b/src/main/java/com/lz/modules/flow/service/StaffRoleEvaluationGroupService.java index 6f4ba810..ee78e93d 100644 --- a/src/main/java/com/lz/modules/flow/service/StaffRoleEvaluationGroupService.java +++ b/src/main/java/com/lz/modules/flow/service/StaffRoleEvaluationGroupService.java @@ -2,6 +2,7 @@ package com.lz.modules.flow.service; import com.baomidou.mybatisplus.extension.service.IService; import com.lz.modules.app.dto.EvaluationGroupInfo; +import com.lz.modules.flow.entity.StaffRole; import com.lz.modules.flow.entity.StaffRoleEvaluationGroup; import java.util.List; @@ -39,5 +40,9 @@ public interface StaffRoleEvaluationGroupService extends IService selectStaffRoleEvaluationsGroupByStaffRoles(List staffRoles); + StaffRoleEvaluationGroup selectEvaluationGroupIdsByRoleIdGroupId(Long roleId, Long groupId); + } \ No newline at end of file diff --git a/src/main/java/com/lz/modules/flow/service/StaffRoleService.java b/src/main/java/com/lz/modules/flow/service/StaffRoleService.java index 60f3f864..2f7481bf 100644 --- a/src/main/java/com/lz/modules/flow/service/StaffRoleService.java +++ b/src/main/java/com/lz/modules/flow/service/StaffRoleService.java @@ -65,6 +65,11 @@ public interface StaffRoleService extends IService { List selectAllByStaffId(Long userId); Map getRoleByUserId(Long userId); - + //获取主管理员 + List selectMastRoles(); + //获取管理全部考评组 + List selectAllGroupManageRoles(); List selectAllStaffRoleByDepartmentLevel(List asList); + + List selectByEvaluationGroupId(Long id); } \ No newline at end of file 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 b3468410..7dd6d7ee 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 @@ -19,11 +19,16 @@ import com.lz.modules.flow.dao.EvaluationGroupMapper; import com.lz.modules.flow.dao.EvaluationStartStaffMapper; import com.lz.modules.flow.entity.EvaluationGroup; import com.lz.modules.flow.entity.FlowStart; +import com.lz.modules.flow.entity.StaffRole; +import com.lz.modules.flow.entity.StaffRoleEvaluationGroup; import com.lz.modules.flow.req.EvaluationGroupReq; import com.lz.modules.flow.service.EvaluationGroupService; import com.lz.modules.flow.service.FlowStartService; +import com.lz.modules.flow.service.StaffRoleEvaluationGroupService; +import com.lz.modules.flow.service.StaffRoleService; import com.lz.modules.performance.dto.CheckStaffDto; import com.lz.modules.performance.req.CheckStaffReq; +import com.lz.modules.sys.entity.SysUserEntity; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang.StringUtils; @@ -35,7 +40,9 @@ import java.util.*; import java.util.function.Consumer; import java.util.function.Function; import java.util.function.Supplier; +import java.util.function.ToLongFunction; import java.util.stream.Collectors; +import java.util.stream.Stream; import static java.util.stream.Collectors.toList; @@ -71,6 +78,12 @@ public class EvaluationGroupServiceImpl extends ServiceImpl gIds = null; - if(req.getStartId() != null){ + if(req.getStartId() != null){//发起评分时调用,传发起的id FlowStart flowStart = flowStartService.selectFlowStartById(req.getStartId()); if(flowStart == null){ return null; @@ -123,6 +136,30 @@ public class EvaluationGroupServiceImpl extends ServiceImpl 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; + } + gIds.add(staffRoleEvaluationGroup.getEvaluationGroupId());//管理特定组 + + } } List finalGIds = gIds; PageUtils pageUtils = PageUtils.startPage(req.getCurrPage(), req.getPageSize()) @@ -308,8 +345,8 @@ public class EvaluationGroupServiceImpl extends ServiceImpl collect = staffIdsByGroup.stream().map(s -> Long.valueOf(s)).distinct().collect(toList()); - List staffSimpleDtos = staffService.selectStaffSimpleInfoByIds(collect); + List longCollect = staffIdsByGroup.stream().distinct().map(s -> Long.valueOf(s)).collect(toList()); + List staffSimpleDtos = staffService.selectStaffSimpleInfoByIds(longCollect); String notInGroupNames = StringUtil.EMPTY; for(StaffSimpleDto dto:staffSimpleDtos){ notInGroupNames = notInGroupNames + dto.getName() + " "; @@ -318,14 +355,17 @@ public class EvaluationGroupServiceImpl extends ServiceImpl stringCollect = staffIdsByGroup.stream().distinct().collect(toList()); evaluationGroups.forEach(evaluationGroup12 -> { List staffs = map.get(evaluationGroup12.getId()); - staffs.retainAll(collect); + //如果组里面有他,删除掉 + staffs.retainAll(stringCollect); if(CollectionUtils.isNotEmpty(staffs)){ //添加到保存时添加 //删除存在得 log.info("需删除其他组信息,staffs:" + JSON.toJSONString(staffs)); - removeStaffsToAssessGroup(collect,evaluationGroup12); + removeStaffsToAssessGroup(stringCollect,evaluationGroup12); } }); @@ -336,7 +376,7 @@ public class EvaluationGroupServiceImpl extends ServiceImpl ids,EvaluationGroup group) { + private int removeStaffsToAssessGroup(List ids,EvaluationGroup group) { String staffIds = group.getStaffIds(); if(StringUtil.isNotBlank(staffIds)){ String[] split = staffIds.split(","); 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 ed7e347d..d4abcd7e 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 @@ -20,6 +20,7 @@ import com.lz.modules.sys.entity.app.ResultDetail; 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.map.HashedMap; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -41,6 +42,7 @@ import java.util.stream.Collectors; */ @Service +@Slf4j public class FlowStartServiceImpl extends ServiceImpl implements FlowStartService { @@ -130,8 +132,10 @@ public class FlowStartServiceImpl extends ServiceImpl staffSimpleInfos = staffService.selectStaffSimpleInfos(groupStaffs.getStaffIds()); if(staffSimpleInfos.size() == 0){ + log.info("无有效考核人员"); R.error(groupStaffs.getEvaluationGroup().getName() + "——无有效考核人员"); } switch (start(groupStaffs.getEvaluationGroup(), flowStart, staffManages, staffSimpleInfos, mustRole, selfMustRole)){ @@ -158,6 +163,7 @@ public class FlowStartServiceImpl extends ServiceImpl staffIds = evaluationGroupService.selectAllStaffSimpleInfoByGroupId(evaluationGroup); if(staffIds.size() == 0){ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();//事务回滚 - + log.info("无有效考核人员"); return R.error(evaluationGroup.getName() + "——无有效考核人员"); } if(flowStart.getIsDelete() != null){//已经发起过的 @@ -260,6 +269,7 @@ public class FlowStartServiceImpl extends ServiceImpl resultModelDtos = resultModelService.selectResultDtoByGroupId(evaluationGroup.getId()); if(resultModelDtos.size() == 0){ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();//事务回滚 + log.info("没有设置考核模板"); return 1; } List flowCharts = flowChartService.selectFlowChartsByGroupId(evaluationGroup.getId()); if(flowCharts.size() == 0){ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();//事务回滚 + log.info("无有效绩效流程节点"); return 2; } List flowChartDetailRecords = new ArrayList<>(); @@ -312,6 +324,7 @@ public class FlowStartServiceImpl extends ServiceImpl chartNameMaps = @@ -322,6 +335,7 @@ public class FlowStartServiceImpl extends ServiceImpl selectEvaluationGroupIdsByRoleId(Long roleId) { return staffRoleEvaluationGroupMapper.selectEvaluationGroupIdsByRoleId(roleId); } + + @Override + public List selectStaffRoleEvaluationsGroupByStaffRoles(List staffRoles){ + return staffRoleEvaluationGroupMapper.selectStaffRoleEvaluationsGroupByStaffRoles(staffRoles); + } } diff --git a/src/main/java/com/lz/modules/flow/service/impl/StaffRoleServiceImpl.java b/src/main/java/com/lz/modules/flow/service/impl/StaffRoleServiceImpl.java index be77aa8a..ad9a69b3 100644 --- a/src/main/java/com/lz/modules/flow/service/impl/StaffRoleServiceImpl.java +++ b/src/main/java/com/lz/modules/flow/service/impl/StaffRoleServiceImpl.java @@ -550,4 +550,19 @@ public class StaffRoleServiceImpl extends ServiceImpl selectMastRoles(){ + return staffRoleMapper.selectMastRoles(); + } + + @Override + public List selectAllGroupManageRoles(){ + return staffRoleMapper.selectAllGroupManageRoles(); + } + + @Override + public List selectByEvaluationGroupId(Long groupId){ + return staffRoleMapper.selectByEvaluationGroupId(groupId); + } } 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 ca6900fb..73be5359 100644 --- a/src/main/java/com/lz/modules/job/business/DingtalkBusiness.java +++ b/src/main/java/com/lz/modules/job/business/DingtalkBusiness.java @@ -193,6 +193,31 @@ public class DingtalkBusiness { return sendWorkMSGByEntity(appid, fromStaffEntity, toStaffEntity, workMsgTypeEnum, "https://www.baidu.com"); } + 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(); + } + }).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); + + ThreadSendMessage threadSendMessage = new ThreadSendMessage(fromStaff, toStaffids, workMsgTypeEnum, appid); + Thread thread = new Thread(threadSendMessage); + thread.start(); + return "OK"; + } public String sendWorkMSGWithAsyn(List toStaffids, int type) { @@ -215,7 +240,7 @@ public class DingtalkBusiness { } WorkMsgTypeEnum workMsgTypeEnum = WorkMsgTypeEnum.findRoleTypeByCode(type); - ThreadSendMessage threadSendMessage = new ThreadSendMessage(toStaffids, workMsgTypeEnum, appid); + ThreadSendMessage threadSendMessage = new ThreadSendMessage(null, toStaffids, workMsgTypeEnum, appid); Thread thread = new Thread(threadSendMessage); thread.start(); return "OK"; @@ -287,12 +312,14 @@ public class DingtalkBusiness { public class ThreadSendMessage implements Runnable{ List toStaffids; + StaffSimpleInfo fromStaff = null; WorkMsgTypeEnum workMsgTypeEnum; String appid; String hostUrl = "https://lzmanagement.ldxinyong.com/digitization/dingTalkLogin"; - public ThreadSendMessage(List toStaffids, WorkMsgTypeEnum typeEnum, String appid){ + public ThreadSendMessage(StaffSimpleInfo fromStaff, List toStaffids, WorkMsgTypeEnum typeEnum, String appid){ this.toStaffids = toStaffids; workMsgTypeEnum = typeEnum; + this.fromStaff = fromStaff; this.appid = appid; } @@ -315,9 +342,16 @@ public class DingtalkBusiness { url = URLEncoder.encode(url); - url = "dingtalk://dingtalkclient/page/link?pc_slide=true&url=" + url; + url = "dingtalk://dingtalkclient/action/openapp?corpid=" + thirdAppConfig.getCorpId() + + "&container_type=work_platform&app_id=0_" + + appid + "&redirect_type=jump&redirect_url=" + url; + String content = null; + if(fromStaff == null){ + content = workMsgTypeEnum.getContent().replace("@", info.getName()); + }else{ + content = workMsgTypeEnum.getContent().replace("@", fromStaff.getName()); + } - String content = workMsgTypeEnum.getContent().replace("@", info.getName()); StaffEntity entity = new StaffEntity(); entity.setId(info.getId()); entity.setEmployeeId(info.getEmployeeId()); diff --git a/src/main/java/com/lz/modules/performance/controller/AssessManagerController.java b/src/main/java/com/lz/modules/performance/controller/AssessManagerController.java index 7329fb9e..53e9105c 100644 --- a/src/main/java/com/lz/modules/performance/controller/AssessManagerController.java +++ b/src/main/java/com/lz/modules/performance/controller/AssessManagerController.java @@ -117,13 +117,11 @@ public class AssessManagerController extends AbstractController{ return R.error("变动人员不能为空"); } try { - assessManagerService.assessChange(req); + return assessManagerService.assessChange(req); } catch (Exception e) { log.error("考核管理变更异常" ,e); return R.error(e.getMessage()); } - return R.ok(); - } diff --git a/src/main/java/com/lz/modules/performance/controller/EvaluationGroupController.java b/src/main/java/com/lz/modules/performance/controller/EvaluationGroupController.java index 062646c4..6412221e 100644 --- a/src/main/java/com/lz/modules/performance/controller/EvaluationGroupController.java +++ b/src/main/java/com/lz/modules/performance/controller/EvaluationGroupController.java @@ -8,14 +8,13 @@ import com.lz.common.utils.StringUtil; import com.lz.modules.app.dto.DepartmentsSimpleDto; import com.lz.modules.app.dto.StaffSimpleDto; import com.lz.modules.app.service.StaffService; -import com.lz.modules.flow.entity.EvaluationGroup; -import com.lz.modules.flow.entity.FlowManager; -import com.lz.modules.flow.entity.ResultModel; -import com.lz.modules.flow.entity.StaffRole; +import com.lz.modules.flow.entity.*; import com.lz.modules.flow.model.EvaluationGroupDto; import com.lz.modules.flow.req.EvaluationGroupReq; import com.lz.modules.flow.service.*; import com.lz.modules.performance.req.CheckStaffReq; +import com.lz.modules.sys.controller.AbstractController; +import com.lz.modules.sys.entity.SysUserEntity; import io.swagger.annotations.*; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -28,7 +27,7 @@ import java.util.stream.Collectors; @RestController @RequestMapping("/evaluationGroup") @Api(tags="考评组") -public class EvaluationGroupController { +public class EvaluationGroupController extends AbstractController { @Autowired @@ -47,6 +46,8 @@ public class EvaluationGroupController { @Autowired private StaffRoleService staffRoleService; + @Autowired + private StaffRoleEvaluationGroupService staffRoleEvaluationGroupService; @@ -115,7 +116,8 @@ public class EvaluationGroupController { @ApiOperation("获取考评组列表") @ApiResponses({@ApiResponse(code=200,message = "成功", response=EvaluationGroup.class)}) public R getGroups(@RequestBody @ApiParam EvaluationGroupReq req) { - PageUtils pageUtils = evaluationGroupService.selectEvaluationGroupByReq(req); + SysUserEntity sysUserEntity = getUser(); + PageUtils pageUtils = evaluationGroupService.selectEvaluationGroupByReq(req, sysUserEntity); return R.ok().put("data",pageUtils); } @@ -133,6 +135,7 @@ public class EvaluationGroupController { @ApiResponses({@ApiResponse(code = 200, message = "成功", response = EvaluationGroup.class)}) public R save(@RequestBody @ApiParam EvaluationGroup evaluationGroup) { EvaluationGroup evaluationGroup1 = evaluationGroupService.selectEvaluationGroupByName(evaluationGroup.getName()); + List staffRoles = null; if(evaluationGroup.getId() != null && evaluationGroup.getId().intValue() > 0){ if(evaluationGroup1 == null || evaluationGroup1.getId().equals(evaluationGroup.getId())){ if(evaluationGroup.getDepIds() == null){ @@ -148,6 +151,8 @@ public class EvaluationGroupController { evaluationGroup.setOutIds(""); } evaluationGroupService.updateEvaluationGroupById(evaluationGroup); + + staffRoles = staffRoleService.selectByEvaluationGroupId(evaluationGroup.getId());//查询已经管理改组的管理员 }else { return R.error("已经存在相同名称考核组"); } @@ -160,37 +165,49 @@ public class EvaluationGroupController { } //更新组管理员信息 if(evaluationGroup.getManagerIds() != null && evaluationGroup.getManagerIds().length() > 0){ - List mIds = Arrays.stream(evaluationGroup.getManagerIds().split(",")).map(new Function() { + Map mapIds = Arrays.stream(evaluationGroup.getManagerIds().split(",")).map(new Function() { @Override public Long apply(String s) { return Long.parseLong(s); } - }).collect(Collectors.toList()); + }).collect(Collectors.toMap(Long::longValue, Function.identity(), (e, replace) -> e)); - List staffRoles = staffRoleService.selectByGroupId(evaluationGroup.getId()); - if(staffRoles.size() > 0){ - Map staffRoleMap = - staffRoles.stream().collect(Collectors.toMap(StaffRole::getStaffId, Function.identity(), (e, repace) -> e)); - for(int i = 0; i < mIds.size();){ - Long l = mIds.get(i); - if(staffRoleMap.containsKey(l)){ - mIds.remove(l); - continue; + for (StaffRole staffRole:staffRoles + ) {//去掉已经在管理本组的管理员 + if(mapIds.containsKey(staffRole.getStaffId())){ + mapIds.remove(staffRole.getStaffId()); + }else{//删除管理的组信息 + staffRoleEvaluationGroupService.deleteStaffRoleEvaluationGroupByRoleId(staffRole.getId()); + } + } + + //去掉管理全考评组 + staffRoles = staffRoleService.selectAllGroupManageRoles(); + for (StaffRole staffRole:staffRoles + ) { + if(mapIds.containsKey(staffRole.getStaffId())){ + mapIds.remove(staffRole.getStaffId()); + } + } + + + if(mapIds.size() > 0){ + List ids = mapIds.values().stream().collect(Collectors.toList()); + staffRoles = staffRoleService.selectStaffRolesByStaffId(ids); + + if(staffRoles.size() > 0){ + List staffRoleEvaluationGroups = new ArrayList<>(); + for (StaffRole staffRole:staffRoles + ) { + StaffRoleEvaluationGroup staffRoleEvaluationGroup = new StaffRoleEvaluationGroup(); + staffRoleEvaluationGroup.setRoleId(staffRole.getId()); + staffRoleEvaluationGroup.setEvaluationGroupId(evaluationGroup.getId()); + staffRoleEvaluationGroups.add(staffRoleEvaluationGroup); } - i++; + staffRoleEvaluationGroupService.saveBatch(staffRoleEvaluationGroups); } } - if(mIds.size() > 0){ - staffRoles = new ArrayList<>(); - for (Long id:mIds - ) { - StaffRole staffRole = new StaffRole(); - staffRole.setStaffId(id); - staffRole.setEvaluationGroupId(evaluationGroup.getId()); - staffRoles.add(staffRole); - } - staffRoleService.saveBatch(staffRoles); - } + } return R.ok().put("data", evaluationGroup); } diff --git a/src/main/java/com/lz/modules/performance/service/impl/AssessManagerServiceImpl.java b/src/main/java/com/lz/modules/performance/service/impl/AssessManagerServiceImpl.java index c8a901a2..475f164d 100644 --- a/src/main/java/com/lz/modules/performance/service/impl/AssessManagerServiceImpl.java +++ b/src/main/java/com/lz/modules/performance/service/impl/AssessManagerServiceImpl.java @@ -116,11 +116,11 @@ public class AssessManagerServiceImpl implements AssessManagerService { res.setCycleTime(name.substring(0,name.lastIndexOf("绩效考核"))); } //过滤非自己管理的人员 - ResultRecord resultRecord = resultRecordMapper.selectOneByStartId(flowStart.getId()); //没有管理的部门 if(mandepartmentIds!=null && mandepartmentIds.size()==0){ res.setJoinNum("0人"); }else { + ResultRecord resultRecord = resultRecordMapper.selectOneByStartId(flowStart.getId(),mandepartmentIds); int i = resultRecordMapper.countStartAndGroupNum(flowStart.getId(),mandepartmentIds); res.setJoinNum(resultRecord == null? StringUtil.EMPTY : resultRecord.getStaffName() + i + "等人"); } @@ -188,7 +188,7 @@ public class AssessManagerServiceImpl implements AssessManagerService { String[] split = flowStart.getGroupIds().split(","); List strings = Arrays.asList(split); List ids = strings.stream().map(s -> Long.valueOf(s)).collect(toList()); - List otheEvaluationGroups = evaluationGroupService.selectEvaluationGroupByNotIds(ids); + List evaluationGroups = evaluationGroupService.selectEvaluationGroupByIds(ids); //获取变更人员 String[] changeStaffIds = req.getStaffIds().split(","); @@ -200,7 +200,7 @@ public class AssessManagerServiceImpl implements AssessManagerService { //根据组id成员分组 Map> map = Maps.newHashMap(); - for(EvaluationGroup group:otheEvaluationGroups){ + for(EvaluationGroup group:evaluationGroups){ List staff = evaluationGroupService.selectAllStaffIdsByGroupId(group.getId()); all.addAll(staff); map.put(group.getId(),staff); @@ -227,31 +227,30 @@ public class AssessManagerServiceImpl implements AssessManagerService { //排除已发起过的 List longs = evaluationStartStaffMapper.selectStaffIdsByStart(req.getStartId()); - for(EvaluationGroup group:otheEvaluationGroups){ + for(EvaluationGroup group:evaluationGroups){ GroupStaffs groupStaffs = new GroupStaffs(); groupStaffs.setEvaluationGroup(group); List staffs = map.get(group.getId()); staffs.retainAll(change); - List collect = staffs.stream().map(s -> Long.valueOf(s)).collect(toList()); + List collect = staffs.stream().distinct().map(s -> Long.valueOf(s)).collect(toList()); collect.removeAll(longs); if(CollectionUtils.isNotEmpty(collect)){ groupStaffs.setStaffIds(collect); groupS.add(groupStaffs); } } + if(CollectionUtils.isEmpty(groupS)){ + log.info("暂无人员需要添加"); + return R.ok("暂无人员需要添加"); + } StartGroups startGroups = new StartGroups(); startGroups.setStartId(req.getStartId()); startGroups.setGroups(groupS); - try { - flowStartService.startStaffs(startGroups); - } catch (Exception e) { - log.error("调用初始化失败"); - return R.error("初始化失败"); - } - return R.ok(); - + R r = flowStartService.startStaffs(startGroups); + log.info("添加人员初始化返回:" + JSON.toJSONString(r)); + return r; } if(req.getChangeType() == 1){ diff --git a/src/main/java/com/lz/modules/performance/service/impl/AssessServiceImpl.java b/src/main/java/com/lz/modules/performance/service/impl/AssessServiceImpl.java index 7ee3b094..bc991250 100644 --- a/src/main/java/com/lz/modules/performance/service/impl/AssessServiceImpl.java +++ b/src/main/java/com/lz/modules/performance/service/impl/AssessServiceImpl.java @@ -5,7 +5,9 @@ import com.google.common.collect.Lists; import com.lz.common.utils.DateUtils; import com.lz.common.utils.PageUtils; 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.service.DepartmentsStaffRelateService; import com.lz.modules.app.service.StaffService; import com.lz.modules.flow.entity.FlowStart; import com.lz.modules.flow.entity.StaffRole; @@ -52,6 +54,8 @@ public class AssessServiceImpl implements AssessService { private StaffRoleService staffRoleService; @Autowired private FlowStartService flowStartService; + @Autowired + private DepartmentsStaffRelateService departmentsStaffRelateService; @Override public PageUtils userTaskList(AssessTaskReq req,Long userId) { @@ -101,21 +105,29 @@ public class AssessServiceImpl implements AssessService { return null; } else { - List staffRoleDepartments = staffRoleDepartmentService.selectStaffRoleDepartmentByStaffRoleId(staffRole.getId()); - if (CollectionUtils.isNotEmpty(staffRoleDepartments)) { - List allDepart = new ArrayList<>(); - staffRoleDepartments.forEach(staffRoleDepartment -> { - List strings = staffService.selectAllDeparmentIdsByDepartmentParentId(staffRoleDepartment.getDepartmentId()); - allDepart.addAll(strings); - }); - - List collect = allDepart.stream().distinct().collect(Collectors.toList()); - log.info("获取到权限对应的部门 " + JSON.toJSONString(collect)); - return collect; + if (staffRole.getDepartmentId() == 1) { + DepartmentsStaffRelateEntity entity = departmentsStaffRelateService.selectByStaffId(staffId); + List strings = staffService.selectAllDeparmentIdsByDepartmentParentId(entity.getDepartmentId()); + log.info("获取到权限对应的部门 " + JSON.toJSONString(strings)); + return strings; } - log.info("未获取到用户权限对应的部门 roleID: " + staffRole.getId()); - return Collections.EMPTY_LIST; - } + else if(staffRole.getDepartmentId() == 2){ + List staffRoleDepartments = staffRoleDepartmentService.selectStaffRoleDepartmentByStaffRoleId(staffRole.getId()); + if (CollectionUtils.isNotEmpty(staffRoleDepartments)) { + List allDepart = new ArrayList<>(); + staffRoleDepartments.forEach(staffRoleDepartment -> { + List strings = staffService.selectAllDeparmentIdsByDepartmentParentId(staffRoleDepartment.getDepartmentId()); + allDepart.addAll(strings); + }); + List collect = allDepart.stream().distinct().collect(Collectors.toList()); + log.info("获取到权限对应的部门 " + JSON.toJSONString(collect)); + return collect; + } + + } + } + log.info("未获取到用户权限对应的部门 roleID: " + staffRole.getId()); + return Collections.EMPTY_LIST; } } diff --git a/src/main/java/com/lz/modules/sys/dao/app/ResultRecordMapper.java b/src/main/java/com/lz/modules/sys/dao/app/ResultRecordMapper.java index 8ecb0c30..1afbbdd5 100644 --- a/src/main/java/com/lz/modules/sys/dao/app/ResultRecordMapper.java +++ b/src/main/java/com/lz/modules/sys/dao/app/ResultRecordMapper.java @@ -85,7 +85,7 @@ public interface ResultRecordMapper extends BaseMapper { int countStartAndGroupNum(@Param("startId")Long startId,@Param("departmentIds")List departmentIds); - ResultRecord selectOneByStartId(@Param("startId")Long startId); + ResultRecord selectOneByStartId(@Param("startId")Long startId,@Param("departmentIds")List departmentIds); List selectAssessListByStartId(@Param("page") IPage page, @Param("req")AssessDetailReq req); diff --git a/src/main/resources/mapper/app/ResultRecordMapper.xml b/src/main/resources/mapper/app/ResultRecordMapper.xml index c0c48620..3d71425c 100644 --- a/src/main/resources/mapper/app/ResultRecordMapper.xml +++ b/src/main/resources/mapper/app/ResultRecordMapper.xml @@ -436,7 +436,15 @@ + + + + +