提匀修

This commit is contained in:
quyixiao 2020-11-11 14:43:26 +08:00
commit c843474fee
21 changed files with 295 additions and 107 deletions

View File

@ -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月绩效考核的目标需要您确认点击前往确认
;

View File

@ -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<ResultScore> scores =
resultScoreService.selectResultScoresByDetailIdAndOrderByStaffIds(dto.getId(), scoreDtos);
if(scores.size() > 0){
//
List<ResultScoreDto> scoreDtos1 = new ArrayList<>();
for (ResultScoreDto scoreDto: scoreDtos
) {//
if(scoreDtos.size() > 0){
//获取评分详细
List<ResultScore> 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<ResultScoreDto> 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);
}

View File

@ -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<StaffRoleEval
void deleteStaffRoleEvaluationGroupByRoleId(@Param("roleId") Long roleId);
List<StaffRoleEvaluationGroup> selectStaffRoleEvaluationsGroupByStaffRoles(@Param("list") List<StaffRole> staffRoles);
StaffRoleEvaluationGroup selectEvaluationGroupIdsByRoleIdGroupId(@Param("roleId") Long roleId, @Param("groupId") Long groupId);
}

View File

@ -59,7 +59,11 @@ public interface StaffRoleMapper extends BaseMapper<StaffRole> {
List<StaffMenu> selectAllMenus(@Param("userId") Long userId);
List<StaffRole> selectMastRoles();
List<StaffRole> selectAllGroupManageRoles();
List<StaffRole> selectAllStaffRoleByDepartmentLevel(@Param("departmentLevels") List<String> departmentLevels);
StaffRole selectStaffRolesByStaffIdDepartmentLevelList(@Param("staffId") Long staffId, @Param("departmentLevels") List<String> departmentLevels);
}

View File

@ -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<EvaluationGroup> {
List<String> selectAllStaffIdsByGroupId(Long id);
PageUtils selectEvaluationGroupByReq(EvaluationGroupReq req);
PageUtils selectEvaluationGroupByReq(EvaluationGroupReq req, SysUserEntity sysUserEntity);
List<EvaluationGroup> selectEvaluationGroupByIds(List<Long> ids);

View File

@ -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<StaffRoleEvalu
void deleteStaffRoleEvaluationGroupByRoleId(Long roleId);
List<StaffRoleEvaluationGroup> selectStaffRoleEvaluationsGroupByStaffRoles(List<StaffRole> staffRoles);
StaffRoleEvaluationGroup selectEvaluationGroupIdsByRoleIdGroupId(Long roleId, Long groupId);
}

View File

@ -65,6 +65,11 @@ public interface StaffRoleService extends IService<StaffRole> {
List<StaffRole> selectAllByStaffId(Long userId);
Map<String, Integer> getRoleByUserId(Long userId);
//获取主管理员
List<StaffRole> selectMastRoles();
//获取管理全部考评组
List<StaffRole> selectAllGroupManageRoles();
List<StaffRole> selectAllStaffRoleByDepartmentLevel(List<String> asList);
List<StaffRole> selectByEvaluationGroupId(Long id);
}

View File

@ -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<EvaluationGroupMappe
@Autowired
private EvaluationStartStaffMapper evaluationStartStaffMapper;
@Autowired
private StaffRoleService staffRoleService;
@Autowired
private StaffRoleEvaluationGroupService staffRoleEvaluationGroupService;
@Override
@ -108,9 +121,9 @@ public class EvaluationGroupServiceImpl extends ServiceImpl<EvaluationGroupMappe
}
@Override
public PageUtils selectEvaluationGroupByReq(EvaluationGroupReq req){
public PageUtils selectEvaluationGroupByReq(EvaluationGroupReq req, SysUserEntity sysUserEntity){
List<Long> 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<EvaluationGroupMappe
}
})
.collect(Collectors.toList());
}else{
//考评组管理
List<StaffRole> staffRoles = staffRoleService.selectAllByStaffId(sysUserEntity.getUserId());
if(staffRoles.size() == 0){
log.info("非绩效管理员登录查询");
return null;
}
List<StaffRoleEvaluationGroup> 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<Long> finalGIds = gIds;
PageUtils pageUtils = PageUtils.startPage(req.getCurrPage(), req.getPageSize())
@ -308,8 +345,8 @@ public class EvaluationGroupServiceImpl extends ServiceImpl<EvaluationGroupMappe
//是否存在其他组成员
staffIdsByGroup.retainAll(allStaffIdsByGroup);
if(CollectionUtils.isNotEmpty(staffIdsByGroup)){
List<Long> collect = staffIdsByGroup.stream().map(s -> Long.valueOf(s)).distinct().collect(toList());
List<StaffSimpleDto> staffSimpleDtos = staffService.selectStaffSimpleInfoByIds(collect);
List<Long> longCollect = staffIdsByGroup.stream().distinct().map(s -> Long.valueOf(s)).collect(toList());
List<StaffSimpleDto> 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<EvaluationGroupMappe
if(evaluationGroup.getConfirm()==0){
return R.error(504,notInGroupNames + "已在其他类型为月度的考评组中,是否改为到此考评组中进行考核");
}
List<String> stringCollect = staffIdsByGroup.stream().distinct().collect(toList());
evaluationGroups.forEach(evaluationGroup12 -> {
List<String> 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<EvaluationGroupMappe
return R.ok();
}
private int removeStaffsToAssessGroup(List<Long> ids,EvaluationGroup group) {
private int removeStaffsToAssessGroup(List<String> ids,EvaluationGroup group) {
String staffIds = group.getStaffIds();
if(StringUtil.isNotBlank(staffIds)){
String[] split = staffIds.split(",");

View File

@ -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<FlowStartMapper, FlowStart> implements FlowStartService {
@ -130,8 +132,10 @@ public class FlowStartServiceImpl extends ServiceImpl<FlowStartMapper, FlowStart
//发起指定用户的绩效中途添加的时候
public R startStaffs(StartGroups startGroupStaffIds){
log.info("发起指定用户的绩效,中途添加的时候{}", startGroupStaffIds);
FlowStart flowStart = flowStartMapper.selectFlowStartById(startGroupStaffIds.getStartId());
if(flowStart == null){
log.info("发起任务不存在");
return R.error("发起任务不存在");
}
@ -142,6 +146,7 @@ public class FlowStartServiceImpl extends ServiceImpl<FlowStartMapper, FlowStart
) {
List<StaffSimpleInfo> 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<FlowStartMapper, FlowStart
return R.error(groupStaffs.getEvaluationGroup().getName() + "——初始化考核流程失败");
}
dingtalkBusiness.sendWorkMSGWithAsyn(staffSimpleInfos, WorkMsgTypeEnum.START_WORK.getType());
}
return R.ok("发起成功").put("data", flowStart);
@ -165,8 +171,10 @@ public class FlowStartServiceImpl extends ServiceImpl<FlowStartMapper, FlowStart
@Override
public R saveStart(FlowStart flowStart){
log.info("发起考核{}", flowStart);
//下面生成或者合并发起绩效
if(flowStart.getStartTime() == null){
log.info("未设置有效考核月份");
return R.error("未设置有效考核月份");
}
SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月");
@ -175,6 +183,7 @@ public class FlowStartServiceImpl extends ServiceImpl<FlowStartMapper, FlowStart
if(flowStart.getCycleType().intValue() != 0){
//月份
if(flowStart.getEndTime() == null){
log.info("未设置有效考核结束月份");
return R.error("未设置有效考核结束月份");
}
String endDate = sdf.format(flowStart.getStartTime());
@ -244,7 +253,7 @@ public class FlowStartServiceImpl extends ServiceImpl<FlowStartMapper, FlowStart
List<StaffSimpleInfo> 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<FlowStartMapper, FlowStart
staffIds = map.values().stream().collect(Collectors.toList());
if(staffIds.size() == 0){
log.info("本次发起参与人员为0");
return R.error(evaluationGroup.getName() + "——本次发起参与人员为0");
}
}
@ -294,12 +304,14 @@ public class FlowStartServiceImpl extends ServiceImpl<FlowStartMapper, FlowStart
List<ResultModelDto> resultModelDtos = resultModelService.selectResultDtoByGroupId(evaluationGroup.getId());
if(resultModelDtos.size() == 0){
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();//事务回滚
log.info("没有设置考核模板");
return 1;
}
List<FlowChart> flowCharts = flowChartService.selectFlowChartsByGroupId(evaluationGroup.getId());
if(flowCharts.size() == 0){
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();//事务回滚
log.info("无有效绩效流程节点");
return 2;
}
List<FlowChartDetailRecord> flowChartDetailRecords = new ArrayList<>();
@ -312,6 +324,7 @@ public class FlowStartServiceImpl extends ServiceImpl<FlowStartMapper, FlowStart
if(flowChartDetailRecords.size() == 0){
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();//事务回滚
log.info("没有设置考核流程");
return 3;
}
Map<Long, String> chartNameMaps =
@ -322,6 +335,7 @@ public class FlowStartServiceImpl extends ServiceImpl<FlowStartMapper, FlowStart
if(staffManagers == null || staffManagers.size() == 0){
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();//事务回滚
log.info("没有设置绩效管理人员");
return 4;
}
@ -646,6 +660,7 @@ public class FlowStartServiceImpl extends ServiceImpl<FlowStartMapper, FlowStart
//如果有下面通知所有管理人员
}else{
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();//事务回滚
log.info("初始化考核流程失败");
return 5;
}
return 0;

View File

@ -3,6 +3,7 @@ package com.lz.modules.flow.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lz.modules.app.dto.EvaluationGroupInfo;
import com.lz.modules.flow.dao.StaffRoleEvaluationGroupMapper;
import com.lz.modules.flow.entity.StaffRole;
import com.lz.modules.flow.entity.StaffRoleEvaluationGroup;
import com.lz.modules.flow.service.StaffRoleEvaluationGroupService;
import org.springframework.beans.factory.annotation.Autowired;
@ -81,4 +82,9 @@ public class StaffRoleEvaluationGroupServiceImpl extends ServiceImpl<StaffRoleEv
public List<Long> selectEvaluationGroupIdsByRoleId(Long roleId) {
return staffRoleEvaluationGroupMapper.selectEvaluationGroupIdsByRoleId(roleId);
}
@Override
public List<StaffRoleEvaluationGroup> selectStaffRoleEvaluationsGroupByStaffRoles(List<StaffRole> staffRoles){
return staffRoleEvaluationGroupMapper.selectStaffRoleEvaluationsGroupByStaffRoles(staffRoles);
}
}

View File

@ -550,4 +550,19 @@ public class StaffRoleServiceImpl extends ServiceImpl<StaffRoleMapper, StaffRole
}
parent.setChilds(childs);
}
@Override
public List<StaffRole> selectMastRoles(){
return staffRoleMapper.selectMastRoles();
}
@Override
public List<StaffRole> selectAllGroupManageRoles(){
return staffRoleMapper.selectAllGroupManageRoles();
}
@Override
public List<StaffRole> selectByEvaluationGroupId(Long groupId){
return staffRoleMapper.selectByEvaluationGroupId(groupId);
}
}

View File

@ -193,6 +193,31 @@ public class DingtalkBusiness {
return sendWorkMSGByEntity(appid, fromStaffEntity, toStaffEntity, workMsgTypeEnum, "https://www.baidu.com");
}
public String sendWorkMSGWithAsyn(StaffSimpleInfo fromStaff, List<StaffSimpleInfo> toStaffids, int type) {
if(toStaffids.get(0).getEmployeeId() == null || toStaffids.get(0).getEmployeeId().length() == 0){
//查询第三方id
List<Long> ids = toStaffids.stream().map(new Function<StaffSimpleInfo, Long>() {
@Override
public Long apply(StaffSimpleInfo staffSimpleInfo) {
return staffSimpleInfo.getId();
}
}).collect(Collectors.toList());
List<StaffSimpleInfo> staffSimpleInfos = staffService.selectStaffSimpleInfos(ids);
Map<Long, StaffSimpleInfo> 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<StaffSimpleInfo> 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<StaffSimpleInfo> toStaffids;
StaffSimpleInfo fromStaff = null;
WorkMsgTypeEnum workMsgTypeEnum;
String appid;
String hostUrl = "https://lzmanagement.ldxinyong.com/digitization/dingTalkLogin";
public ThreadSendMessage(List<StaffSimpleInfo> toStaffids, WorkMsgTypeEnum typeEnum, String appid){
public ThreadSendMessage(StaffSimpleInfo fromStaff, List<StaffSimpleInfo> 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());

View File

@ -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();
}

View File

@ -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<StaffRole> 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<Long> mIds = Arrays.stream(evaluationGroup.getManagerIds().split(",")).map(new Function<String, Long>() {
Map<Long, Long> mapIds = Arrays.stream(evaluationGroup.getManagerIds().split(",")).map(new Function<String, Long>() {
@Override
public Long apply(String s) {
return Long.parseLong(s);
}
}).collect(Collectors.toList());
}).collect(Collectors.toMap(Long::longValue, Function.identity(), (e, replace) -> e));
List<StaffRole> staffRoles = staffRoleService.selectByGroupId(evaluationGroup.getId());
if(staffRoles.size() > 0){
Map<Long, StaffRole> 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<Long> ids = mapIds.values().stream().collect(Collectors.toList());
staffRoles = staffRoleService.selectStaffRolesByStaffId(ids);
if(staffRoles.size() > 0){
List<StaffRoleEvaluationGroup> 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);
}

View File

@ -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<String> strings = Arrays.asList(split);
List<Long> ids = strings.stream().map(s -> Long.valueOf(s)).collect(toList());
List<EvaluationGroup> otheEvaluationGroups = evaluationGroupService.selectEvaluationGroupByNotIds(ids);
List<EvaluationGroup> evaluationGroups = evaluationGroupService.selectEvaluationGroupByIds(ids);
//获取变更人员
String[] changeStaffIds = req.getStaffIds().split(",");
@ -200,7 +200,7 @@ public class AssessManagerServiceImpl implements AssessManagerService {
//根据组id成员分组
Map<Long,List<String>> map = Maps.newHashMap();
for(EvaluationGroup group:otheEvaluationGroups){
for(EvaluationGroup group:evaluationGroups){
List<String> staff = evaluationGroupService.selectAllStaffIdsByGroupId(group.getId());
all.addAll(staff);
map.put(group.getId(),staff);
@ -227,31 +227,30 @@ public class AssessManagerServiceImpl implements AssessManagerService {
//排除已发起过的
List<Long> longs = evaluationStartStaffMapper.selectStaffIdsByStart(req.getStartId());
for(EvaluationGroup group:otheEvaluationGroups){
for(EvaluationGroup group:evaluationGroups){
GroupStaffs groupStaffs = new GroupStaffs();
groupStaffs.setEvaluationGroup(group);
List<String> staffs = map.get(group.getId());
staffs.retainAll(change);
List<Long> collect = staffs.stream().map(s -> Long.valueOf(s)).collect(toList());
List<Long> 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){

View File

@ -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<StaffRoleDepartment> staffRoleDepartments = staffRoleDepartmentService.selectStaffRoleDepartmentByStaffRoleId(staffRole.getId());
if (CollectionUtils.isNotEmpty(staffRoleDepartments)) {
List<String> allDepart = new ArrayList<>();
staffRoleDepartments.forEach(staffRoleDepartment -> {
List<String> strings = staffService.selectAllDeparmentIdsByDepartmentParentId(staffRoleDepartment.getDepartmentId());
allDepart.addAll(strings);
});
List<String> collect = allDepart.stream().distinct().collect(Collectors.toList());
log.info("获取到权限对应的部门 " + JSON.toJSONString(collect));
return collect;
if (staffRole.getDepartmentId() == 1) {
DepartmentsStaffRelateEntity entity = departmentsStaffRelateService.selectByStaffId(staffId);
List<String> 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<StaffRoleDepartment> staffRoleDepartments = staffRoleDepartmentService.selectStaffRoleDepartmentByStaffRoleId(staffRole.getId());
if (CollectionUtils.isNotEmpty(staffRoleDepartments)) {
List<String> allDepart = new ArrayList<>();
staffRoleDepartments.forEach(staffRoleDepartment -> {
List<String> strings = staffService.selectAllDeparmentIdsByDepartmentParentId(staffRoleDepartment.getDepartmentId());
allDepart.addAll(strings);
});
List<String> collect = allDepart.stream().distinct().collect(Collectors.toList());
log.info("获取到权限对应的部门 " + JSON.toJSONString(collect));
return collect;
}
}
}
log.info("未获取到用户权限对应的部门 roleID: " + staffRole.getId());
return Collections.EMPTY_LIST;
}
}

View File

@ -85,7 +85,7 @@ public interface ResultRecordMapper extends BaseMapper<ResultRecord> {
int countStartAndGroupNum(@Param("startId")Long startId,@Param("departmentIds")List<String> departmentIds);
ResultRecord selectOneByStartId(@Param("startId")Long startId);
ResultRecord selectOneByStartId(@Param("startId")Long startId,@Param("departmentIds")List<String> departmentIds);
List<AssessManagerDetailRes> selectAssessListByStartId(@Param("page") IPage page, @Param("req")AssessDetailReq req);

View File

@ -436,7 +436,15 @@
</select>
<select id="selectOneByStartId" resultType="com.lz.modules.sys.entity.app.ResultRecord">
select * from lz_result_record where is_delete = 0 and start_id = #{startId} limit 1
select * from lz_result_record where is_delete = 0 and start_id = #{startId}
<if test="departmentIds !=null and departmentIds.size()!=0">
and department_id in (
<foreach collection="departmentIds" item="department_id" separator=",">
#{department_id}
</foreach>
)
</if>
limit 1
</select>
<select id="selectAssessListByStartId" resultType="com.lz.modules.performance.res.AssessManagerDetailRes">
@ -447,7 +455,7 @@
and r.start_id = #{req.startId}
<if test="req.copyEvaluationIds !=null and req.copyEvaluationIds !=''">
and r.evaluation_id in(
<foreach collection="req.copyEvaluationIds.split(',')" item="evaluation_id" open="(" separator="," close=")">
<foreach collection="req.copyEvaluationIds.split(',')" item="evaluation_id" separator=",">
#{evaluation_id}
</foreach>
)
@ -460,7 +468,7 @@
</if>
<if test="req.staffIds !=null and req.staffIds !=''">
and r.staff_id in(
<foreach collection="req.staffIds.split(',')" item="staff_id" open="(" separator="," close=")">
<foreach collection="req.staffIds.split(',')" item="staff_id" separator=",">
#{staff_id}
</foreach>
)
@ -483,7 +491,7 @@
and r.start_id =#{req.startId}
<if test="req.copyEvaluationIds !=null and req.copyEvaluationIds !=''">
and r.evaluation_id in(
<foreach collection="req.copyEvaluationIds.split(',')" item="evaluation_id" open="(" separator="," close=")">
<foreach collection="req.copyEvaluationIds.split(',')" item="evaluation_id" separator=",">
#{evaluation_id}
</foreach>
)
@ -496,7 +504,7 @@
</if>
<if test="req.staffIds !=null and req.staffIds !=''">
and r.staff_id in(
<foreach collection="req.staffIds.split(',')" item="staff_id" open="(" separator="," close=")">
<foreach collection="req.staffIds.split(',')" item="staff_id" separator=",">
#{staff_id}
</foreach>
)
@ -520,7 +528,7 @@
and r.start_id =#{req.startId}
<if test="req.copyEvaluationIds !=null and req.copyEvaluationIds !=''">
and r.evaluation_id in(
<foreach collection="req.copyEvaluationIds.split(',')" item="evaluation_id" open="(" separator="," close=")">
<foreach collection="req.copyEvaluationIds.split(',')" item="evaluation_id" separator=",">
#{evaluation_id}
</foreach>
)
@ -533,7 +541,7 @@
</if>
<if test="req.staffIds !=null and req.staffIds !=''">
and r.staff_id in(
<foreach collection="req.staffIds.split(',')" item="staff_id" open="(" separator="," close=")">
<foreach collection="req.staffIds.split(',')" item="staff_id" separator="," >
#{staff_id}
</foreach>
)

View File

@ -96,6 +96,7 @@
<if test="name !=null and name !=''">
and name LIKE CONCAT('%',#{name},'%')
</if>
order by id desc
</select>
<select id="selectFlowStartByName" resultType="FlowStart" >

View File

@ -97,6 +97,14 @@
select evaluation_group_id from lz_staff_role_evaluation_group where is_delete = 0 and role_id = #{roleId} and is_select = 1
</select>
<select id="selectStaffRoleEvaluationsGroupByStaffRoles" resultType="StaffRoleEvaluationGroup" >
select * from lz_staff_role_evaluation_group where is_delete = 0 and
role_id in (
<foreach collection="list" item="item" separator=",">
#{item.id}
</foreach>
)
</select>
<select id="selectEvaluationGroupIdsByRoleIdGroupId"
resultType="com.lz.modules.flow.entity.StaffRoleEvaluationGroup">
select * from lz_staff_role_evaluation_group where is_delete = 0 and role_id = #{roleId} and evaluation_group_id = #{groupId}

View File

@ -183,6 +183,14 @@
</foreach>
</select>
<select id="selectMastRoles" resultType="StaffRole" >
select * from lz_staff_role where department_level='MASTER_PM' and is_delete = 0
</select>
<select id="selectAllGroupManageRoles" resultType="StaffRole" >
select * from lz_staff_role where evaluation_group_id=0 and is_delete=0 and is_delete=0
</select>
</mapper>