提交修改

This commit is contained in:
quyixiao 2020-12-09 19:07:21 +08:00
parent f95c279483
commit 1adb43448b

View File

@ -21,7 +21,6 @@ import com.lz.modules.app.model.RoleModel;
import com.lz.modules.app.model.TaskModel;
import com.lz.modules.app.service.DepartmentsService;
import com.lz.modules.app.service.DepartmentsStaffRelateService;
import com.lz.modules.equipment.entity.model.FindEmployeeResModel;
import com.lz.modules.flow.dao.RecordRoleMapper;
import com.lz.modules.flow.dao.StaffRoleDepartmentMapper;
import com.lz.modules.flow.dao.StaffRoleMapper;
@ -43,7 +42,6 @@ import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import sun.jvm.hotspot.oops.TypeArrayKlass;
import java.util.*;
import java.util.stream.Collectors;
@ -426,10 +424,10 @@ public class StaffRoleServiceImpl extends ServiceImpl<StaffRoleMapper, StaffRole
staffRole.setStaffName(staffEntity.getName());
//如果当前子管理员修改成主管理员
if (RoleEnums.MASTER_PM.getName().equals(roleModel.getDepartmentLevel())) {
StaffRole data = staffRoleMapper.selectStaffRolesByStaffIdDepartmentLevelList(roleModel.getStaffId(), Arrays.asList(new String[]{RoleEnums.CHILD_PM.getName()}));
if(data !=null){
staffRoleMapper.deleteStaffRoleById(data.getId()); //删除子管理员
}
StaffRole data = staffRoleMapper.selectStaffRolesByStaffIdDepartmentLevelList(roleModel.getStaffId(), Arrays.asList(new String[]{RoleEnums.CHILD_PM.getName()}));
if (data != null) {
staffRoleMapper.deleteStaffRoleById(data.getId()); //删除子管理员
}
}
staffRoleMapper.updateStaffRoleById(staffRole);
if (RoleEnums.BOSS.getName().equals(staffRole.getDepartmentLevel()) ||
@ -437,11 +435,11 @@ public class StaffRoleServiceImpl extends ServiceImpl<StaffRoleMapper, StaffRole
return R.ok("更新成功");
}
} else if (roleModel.getStaffId() != null) { // 员工不为空,表示是新增数据
StaffRole data = null;
if(RoleEnums.CHILD_PM.getName().equals(roleModel.getDepartmentLevel()) //如果是主管理员或者是子管理员主管理员和子管理员不能同时存在
|| RoleEnums.MASTER_PM.getName().equals(roleModel.getDepartmentLevel())){
StaffRole data = null;
if (RoleEnums.CHILD_PM.getName().equals(roleModel.getDepartmentLevel()) //如果是主管理员或者是子管理员主管理员和子管理员不能同时存在
|| RoleEnums.MASTER_PM.getName().equals(roleModel.getDepartmentLevel())) {
data = staffRoleMapper.selectStaffRolesByStaffIdDepartmentLevelList(roleModel.getStaffId(),
Arrays.asList(new String[]{RoleEnums.CHILD_PM.getName(),RoleEnums.MASTER_PM.getName()}));
Arrays.asList(new String[]{RoleEnums.CHILD_PM.getName(), RoleEnums.MASTER_PM.getName()}));
} else {
data = staffRoleMapper.selectStaffRolesByStaffIdDepartmentLevel(roleModel.getStaffId(), roleModel.getDepartmentLevel());
}
@ -466,11 +464,11 @@ public class StaffRoleServiceImpl extends ServiceImpl<StaffRoleMapper, StaffRole
} else if (RoleEnums.MASTER_PM.getName().equals(staffRole.getDepartmentLevel())) {
insertPM(staffRole, RoleMenuEnums.MASTER_PM.getType(), staffEntity);
} else if (RoleEnums.CHILD_PM.getName().equals(staffRole.getDepartmentLevel())) { //如果是子管理员
if(new Long(0).equals(roleModel.getEvaluationGroupId())){//全部考评组
insertStaffRoleEvaluationGroup(staffRole.getId(),0l);
}else{///部分考评组
if (new Long(0).equals(roleModel.getEvaluationGroupId())) {//全部考评组
insertStaffRoleEvaluationGroup(staffRole.getId(), 0l);
} else {///部分考评组
for (Long evaluationGroupId : evaluationGroupInfoIds) {
insertStaffRoleEvaluationGroup(staffRole.getId(),evaluationGroupId);
insertStaffRoleEvaluationGroup(staffRole.getId(), evaluationGroupId);
}
}
if (roleModel.getDepartmentId().equals(DepartmentPMEnums.SELF_DEPARTMENT.getType().toString())) {//如果是自己所在部门
@ -511,44 +509,44 @@ public class StaffRoleServiceImpl extends ServiceImpl<StaffRoleMapper, StaffRole
@Override
public Map<String, Integer> getRoleByUserId(Long userId) {
Map<String ,Integer> map = new HashMap<>();
Map<String, Integer> map = new HashMap<>();
List<StaffRole> staffRoleList = staffRoleMapper.selectAllByStaffId(userId);
List<StaffMenu> staffMenus = new ArrayList<>();
List<StaffMenu> commonStaffList= staffMenuService.selectByParentId( RoleMenuEnums.COMMON_STAFF.getType());
if(CollectionUtils.isNotEmpty(commonStaffList)){
List<StaffMenu> commonStaffList = staffMenuService.selectByParentId(RoleMenuEnums.COMMON_STAFF.getType());
if (CollectionUtils.isNotEmpty(commonStaffList)) {
staffMenus.addAll(commonStaffList);
}
DepartmentsStaffRelateEntity departmentsStaffRelateEntity = departmentsStaffRelateService.selectLastDepartmentByStaffId(userId);
if(departmentsStaffRelateEntity !=null && new Integer(1).equals(departmentsStaffRelateEntity.getIsLeader())){
List<StaffMenu> staffMenuDepartmentList= staffMenuService.selectByParentId( RoleMenuEnums.DEPARTMENT_PM.getType());
if(CollectionUtils.isNotEmpty(staffMenuDepartmentList)){
if (departmentsStaffRelateEntity != null && new Integer(1).equals(departmentsStaffRelateEntity.getIsLeader())) {
List<StaffMenu> staffMenuDepartmentList = staffMenuService.selectByParentId(RoleMenuEnums.DEPARTMENT_PM.getType());
if (CollectionUtils.isNotEmpty(staffMenuDepartmentList)) {
staffMenus.addAll(staffMenuDepartmentList);
}
}
if(CollectionUtils.isNotEmpty(staffRoleList)){
for(StaffRole staffRole: staffRoleList){
if(staffRole.getDepartmentLevel().equals(RoleEnums.MASTER_PM.getName())){ //如果是主管理员
List<StaffMenu> staffMenuList= staffMenuService.selectByParentId( RoleMenuEnums.MASTER_PM.getType());
if(CollectionUtils.isNotEmpty(staffMenuList)){
staffMenus.addAll(staffMenuList);
}
}else{
List<StaffMenu> staffMenuList = staffRoleMapper.selectAllMenus(staffRole.getStaffId());
if(CollectionUtils.isNotEmpty(staffMenuList)){
staffMenus.addAll(staffMenuList);
}
}
}
if (CollectionUtils.isNotEmpty(staffRoleList)) {
for (StaffRole staffRole : staffRoleList) {
if (staffRole.getDepartmentLevel().equals(RoleEnums.MASTER_PM.getName())) { //如果是主管理员
List<StaffMenu> staffMenuList = staffMenuService.selectByParentId(RoleMenuEnums.MASTER_PM.getType());
if (CollectionUtils.isNotEmpty(staffMenuList)) {
staffMenus.addAll(staffMenuList);
}
} else {
List<StaffMenu> staffMenuList = staffRoleMapper.selectAllMenus(staffRole.getStaffId());
if (CollectionUtils.isNotEmpty(staffMenuList)) {
staffMenus.addAll(staffMenuList);
}
}
}
}
if(CollectionUtils.isNotEmpty(staffMenus) && staffMenus.size() > 0 ){
if (CollectionUtils.isNotEmpty(staffMenus) && staffMenus.size() > 0) {
List<Long> authIds = new ArrayList<>();
for(StaffMenu staffMenu:staffMenus){
List<Long> ids = StringUtil.splitToLongList(staffMenu.getAuthIds(),",");
for (StaffMenu staffMenu : staffMenus) {
List<Long> ids = StringUtil.splitToLongList(staffMenu.getAuthIds(), ",");
authIds.addAll(ids);
}
if(authIds.size() > 0){
if (authIds.size() > 0) {
map = recordAuthService.selectAuthByIds(authIds);
}
}
@ -573,11 +571,11 @@ public class StaffRoleServiceImpl extends ServiceImpl<StaffRoleMapper, StaffRole
staffRoleMenuService.insertStaffRoleMenu(staffRoleMenu);
}
if (parentId.equals(RoleMenuEnums.MASTER_PM.getType())) { //如果是绩效管理员
insertStaffRoleEvaluationGroup(staffRole.getId(),0l);
insertStaffRoleEvaluationGroup(staffRole.getId(), 0l);
}
}
public void insertStaffRoleEvaluationGroup(Long roleId,Long evaluationGroupId){
public void insertStaffRoleEvaluationGroup(Long roleId, Long evaluationGroupId) {
StaffRoleEvaluationGroup staffRoleEvaluationGroup = new StaffRoleEvaluationGroup();
staffRoleEvaluationGroup.setRoleId(roleId);
staffRoleEvaluationGroup.setEvaluationGroupId(evaluationGroupId);
@ -598,52 +596,52 @@ public class StaffRoleServiceImpl extends ServiceImpl<StaffRoleMapper, StaffRole
}
@Override
public List<StaffRole> selectMastRoles(){
public List<StaffRole> selectMastRoles() {
return staffRoleMapper.selectMastRoles();
}
@Override
public List<StaffRole> selectAllGroupManageRoles(){
public List<StaffRole> selectAllGroupManageRoles() {
return staffRoleMapper.selectAllGroupManageRoles();
}
@Override
public List<StaffRole> selectByEvaluationGroupId(Long groupId){
public List<StaffRole> selectByEvaluationGroupId(Long groupId) {
return staffRoleMapper.selectByEvaluationGroupId(groupId);
}
@Override
public StaffRole selectStaffRolesByStaffIdDepartmentLevelList(Long staffId, List<String> departmentLevels) {
public StaffRole selectStaffRolesByStaffIdDepartmentLevelList(Long staffId, List<String> departmentLevels) {
return staffRoleMapper.selectStaffRolesByStaffIdDepartmentLevelList(staffId,departmentLevels);
return staffRoleMapper.selectStaffRolesByStaffIdDepartmentLevelList(staffId, departmentLevels);
}
@Override
public R taskComment(TaskModel roleModel){
if(roleModel.getDetailId() == null && roleModel.getTaskId() == null){
public R taskComment(TaskModel roleModel) {
if (roleModel.getDetailId() == null && roleModel.getTaskId() == null) {
return R.error("detailId和taskId不能同时为空");
}
TaskComment taskComment = new TaskComment();
taskComment.setContent(roleModel.getContent());
taskComment.setTaskId(roleModel.getTaskId());
if(roleModel.getTaskId() !=null){
if (roleModel.getTaskId() != null) {
ResultTask resultTask = resultTaskService.selectResultTaskById(roleModel.getTaskId());
taskComment.setDetailId(resultTask.getDetailId());
taskComment.setType(1);
}else{
} else {
taskComment.setDetailId(roleModel.getDetailId());
taskComment.setType(0);//
}
ResultDetail resultDetail =resultDetailService.selectResultDetailById(taskComment.getDetailId());
ResultDetail resultDetail = resultDetailService.selectResultDetailById(taskComment.getDetailId());
taskComment.setResultRecordId(resultDetail.getRecordId());
StaffEntity staffEntity = staffDao.selectStaffById(roleModel.getStaffId());
if(staffEntity !=null){
if (staffEntity != null) {
taskComment.setStaffId(staffEntity.getId());
taskComment.setStaffName(staffEntity.getName());
}
taskCommentService.insertTaskComment(taskComment);
dingtalkBusiness.sendTaskNoticeMsg(taskComment.getDetailId(),taskComment.getTaskId());
dingtalkBusiness.sendTaskNoticeMsg(taskComment.getDetailId(), taskComment.getTaskId());
return R.ok();
}
@ -654,9 +652,9 @@ public class StaffRoleServiceImpl extends ServiceImpl<StaffRoleMapper, StaffRole
);
List<TaskComment> taskComments = pageUtils.getList();
List<TaskCommentDto> taskCommentDtoList = new ArrayList<>();
for(TaskComment taskComment :taskComments){
for (TaskComment taskComment : taskComments) {
TaskCommentDto taskCommentDto = new TaskCommentDto();
BeanUtils.copyProperties(taskComment,taskCommentDto);
BeanUtils.copyProperties(taskComment, taskCommentDto);
taskCommentDtoList.add(taskCommentDto);
}
pageUtils.setList(taskCommentDtoList);