代码提交 部门主管
This commit is contained in:
parent
10d13946fb
commit
76c07eb049
@ -297,4 +297,16 @@ public class SysUserController extends BaseController {
|
||||
return R.ok(userService.selectUserListByDept(deptId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置部门主管
|
||||
*
|
||||
* @param userIds 角色ID串
|
||||
*/
|
||||
@SaCheckPermission("system:user:setDeptAdmin")
|
||||
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
||||
@GetMapping("/setDeptAdmin/{userIds}")
|
||||
public R<Void> setDeptAdmin(@PathVariable Long[] userIds) {
|
||||
return toAjax(userService.setDeptAdmin(userIds));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -124,6 +124,11 @@ public class SysUser extends TenantEntity {
|
||||
*/
|
||||
private LocalDate employeeLeaveDate;
|
||||
|
||||
/**
|
||||
* 是否部门主管
|
||||
*/
|
||||
private String deptAdminFlag;
|
||||
|
||||
|
||||
public SysUser(Long userId) {
|
||||
this.userId = userId;
|
||||
|
@ -45,9 +45,9 @@ public class SysUserBo extends BaseEntity {
|
||||
/**
|
||||
* 用户昵称
|
||||
*/
|
||||
@Xss(message = "用户昵称不能包含脚本字符")
|
||||
@NotBlank(message = "用户昵称不能为空")
|
||||
@Size(min = 0, max = 30, message = "用户昵称长度不能超过{max}个字符")
|
||||
// @Xss(message = "用户昵称不能包含脚本字符")
|
||||
// @NotBlank(message = "用户昵称不能为空")
|
||||
// @Size(min = 0, max = 30, message = "用户昵称长度不能超过{max}个字符")
|
||||
private String nickName;
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,6 @@
|
||||
package org.dromara.system.domain.vo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
@ -160,4 +161,10 @@ public class SysUserVo implements Serializable {
|
||||
*/
|
||||
private LocalDate employeeLeaveDate;
|
||||
|
||||
/**
|
||||
* 部门主管
|
||||
*/
|
||||
@TableField("dept_admin_flag")
|
||||
private String deptAdminFlag;
|
||||
|
||||
}
|
||||
|
@ -120,4 +120,11 @@ public interface SysUserMapper extends BaseMapperPlus<SysUser, SysUserVo> {
|
||||
})
|
||||
int updateById(@Param(Constants.ENTITY) SysUser user);
|
||||
|
||||
/**
|
||||
* 根据部门id获取部门主管
|
||||
*
|
||||
* @param deptId 部门id
|
||||
* @return 更新操作影响的行数
|
||||
*/
|
||||
Long getDeptAdminByDeptId(@Param("deptId") Long deptId);
|
||||
}
|
||||
|
@ -134,4 +134,12 @@ public interface ISysDeptService {
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteDeptById(Long deptId);
|
||||
|
||||
/**
|
||||
* 根据角色ID查询部门主管
|
||||
*
|
||||
* @param userId 角色ID
|
||||
* @return 选中部门列表
|
||||
*/
|
||||
public Long selectDeptAdminByUserId(Long userId);
|
||||
}
|
||||
|
@ -228,4 +228,11 @@ public interface ISysUserService {
|
||||
* @return 结果
|
||||
*/
|
||||
List<SysUserVo> selectUserListByDept(Long deptId);
|
||||
|
||||
/**
|
||||
* 设置部门主管
|
||||
*
|
||||
* @param userIds 角色ID串
|
||||
*/
|
||||
int setDeptAdmin(Long[] userIds);
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ import org.dromara.system.domain.SysRole;
|
||||
import org.dromara.system.domain.SysUser;
|
||||
import org.dromara.system.domain.bo.SysDeptBo;
|
||||
import org.dromara.system.domain.vo.SysDeptVo;
|
||||
import org.dromara.system.domain.vo.SysUserVo;
|
||||
import org.dromara.system.mapper.SysDeptMapper;
|
||||
import org.dromara.system.mapper.SysRoleMapper;
|
||||
import org.dromara.system.mapper.SysUserMapper;
|
||||
@ -411,4 +412,20 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
|
||||
return baseMapper.deleteById(deptId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据角色ID查询部门主管
|
||||
*
|
||||
* @param userId 角色ID
|
||||
* @return 选中部门列表
|
||||
*/
|
||||
@Override
|
||||
public Long selectDeptAdminByUserId(Long userId) {
|
||||
// 查询用户所在部门
|
||||
SysUserVo sysUserVo = userMapper.selectVoById(userId);
|
||||
Long deptId = sysUserVo.getDeptId();
|
||||
// 查询部门主管
|
||||
Long deptAdminId = userMapper.getDeptAdminByDeptId(deptId);
|
||||
return deptAdminId;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
@ -391,6 +392,7 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
|
||||
.set(SysUser::getPhonenumber, user.getPhonenumber())
|
||||
.set(SysUser::getEmail, user.getEmail())
|
||||
.set(SysUser::getSex, user.getSex())
|
||||
.set(SysUser::getEmployeeName, user.getEmployeeName())
|
||||
.eq(SysUser::getUserId, user.getUserId()));
|
||||
}
|
||||
|
||||
@ -553,6 +555,37 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
|
||||
return baseMapper.selectVoList(lqw);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置部门主管
|
||||
*
|
||||
* @param userIds 角色ID串
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public int setDeptAdmin(Long[] userIds) {
|
||||
if (ArrayUtil.isNotEmpty(userIds)) {
|
||||
for (Long userId : userIds) {
|
||||
// 获取所属部门
|
||||
SysUserVo sysUserVo = baseMapper.selectVoById(userId);
|
||||
String deptAdminFlag = sysUserVo.getDeptAdminFlag();
|
||||
Long deptId = sysUserVo.getDeptId();
|
||||
if (StrUtil.equals("0", deptAdminFlag)) {
|
||||
// 将原先的部门主管设为0
|
||||
Long deptAdminId = baseMapper.getDeptAdminByDeptId(deptId);
|
||||
SysUser userVo = new SysUser();
|
||||
userVo.setUserId(deptAdminId);
|
||||
userVo.setDeptAdminFlag("0");
|
||||
baseMapper.updateById(userVo);
|
||||
SysUser userVoNow = new SysUser();
|
||||
userVoNow.setUserId(userId);
|
||||
userVoNow.setDeptAdminFlag("1");
|
||||
baseMapper.updateById(userVoNow);
|
||||
}
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过用户ID查询用户账户
|
||||
*
|
||||
|
@ -18,7 +18,7 @@
|
||||
</if>
|
||||
<if test="ew.getSqlSelect == null">
|
||||
u.user_id, u.dept_id, u.nick_name, u.user_name, u.email, u.avatar, u.phonenumber, u.sex, u.employee_name,
|
||||
u.employee_hire_date, u.employee_leave_date, u.employee_status,
|
||||
u.employee_hire_date, u.employee_leave_date, u.employee_status,u.dept_admin_flag,
|
||||
u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark
|
||||
</if>
|
||||
from sys_user u
|
||||
@ -101,6 +101,13 @@
|
||||
where del_flag = '0'
|
||||
and user_id = #{userId}
|
||||
</select>
|
||||
<select id="getDeptAdminByDeptId" resultType="java.lang.Long">
|
||||
select user_id
|
||||
from sys_user
|
||||
where del_flag = '0'
|
||||
and dept_id = #{deptId}
|
||||
and dept_admin_flag = 1
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
|
@ -49,7 +49,7 @@ public class TestController extends BaseController {
|
||||
@GetMapping("/list1")
|
||||
public void list(Long userId) {
|
||||
userId = 1L;
|
||||
String deptAdmin = lxOaLeaveService.getDeptAdmin(userId);
|
||||
// String deptAdmin = lxOaLeaveService.getDeptAdmin(userId);
|
||||
// return null;
|
||||
}
|
||||
|
||||
|
@ -73,4 +73,10 @@ public interface IFlwCommonService {
|
||||
* @param taskIds 任务id
|
||||
*/
|
||||
void deleteRunTask(List<Long> taskIds);
|
||||
|
||||
|
||||
/**
|
||||
* 校验并批量删除请假信息
|
||||
*/
|
||||
Long getDeptAdmin(Long userId);
|
||||
}
|
||||
|
@ -45,8 +45,4 @@ public interface ILxOaLeaveService {
|
||||
*/
|
||||
Boolean deleteWithValidByIds(List<Long> ids);
|
||||
|
||||
/**
|
||||
* 校验并批量删除请假信息
|
||||
*/
|
||||
String getDeptAdmin(Long userId);
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.mail.utils.MailUtils;
|
||||
import org.dromara.common.sse.dto.SseMessageDto;
|
||||
import org.dromara.common.sse.utils.SseMessageUtils;
|
||||
import org.dromara.system.service.ISysDeptService;
|
||||
import org.dromara.warm.flow.core.constant.ExceptionCons;
|
||||
import org.dromara.warm.flow.core.dto.FlowParams;
|
||||
import org.dromara.warm.flow.core.entity.Node;
|
||||
@ -59,6 +60,7 @@ public class FlwCommonServiceImpl implements IFlwCommonService {
|
||||
private final UserService userService;
|
||||
private final TaskService taskService;
|
||||
private final NodeService nodeService;
|
||||
private final ISysDeptService iSysDeptService;
|
||||
|
||||
/**
|
||||
* 获取工作流用户service
|
||||
@ -244,4 +246,15 @@ public class FlwCommonServiceImpl implements IFlwCommonService {
|
||||
userService.deleteByTaskIds(taskIds);
|
||||
flowTaskMapper.deleteByIds(taskIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取部门主管
|
||||
*
|
||||
* @param userId 用户id
|
||||
*/
|
||||
@Override
|
||||
public Long getDeptAdmin(Long userId) {
|
||||
Long deptAdmin = iSysDeptService.selectDeptAdminByUserId(userId);
|
||||
return deptAdmin;
|
||||
}
|
||||
}
|
||||
|
@ -102,9 +102,17 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
|
||||
// 启动流程实例(提交申请)
|
||||
Map<String, Object> variables = startProcessBo.getVariables();
|
||||
// 流程发起人
|
||||
variables.put(INITIATOR, LoginHelper.getUserIdStr());
|
||||
String userIdStr = LoginHelper.getUserIdStr();
|
||||
variables.put(INITIATOR, userIdStr);
|
||||
// 业务id
|
||||
variables.put(BUSINESS_ID, businessId);
|
||||
// 变量赋值
|
||||
Long userIdLong = Long.valueOf(userIdStr);
|
||||
Long deptAdmin = flwCommonService.getDeptAdmin(userIdLong);
|
||||
if (ObjectUtil.isNull(deptAdmin)) {
|
||||
throw new ServiceException("流程失败,未指定部门主管!");
|
||||
}
|
||||
variables.put("handler1", deptAdmin);
|
||||
FlowInstance flowInstance = flowInstanceMapper.selectOne(new LambdaQueryWrapper<>(FlowInstance.class)
|
||||
.eq(FlowInstance::getBusinessId, businessId));
|
||||
if (ObjectUtil.isNotNull(flowInstance)) {
|
||||
@ -166,12 +174,13 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
|
||||
}
|
||||
// 设置弹窗处理人
|
||||
Map<String, Object> assigneeMap = setPopAssigneeMap(completeTaskBo.getAssigneeMap(), ins.getVariableMap());
|
||||
Map<String, Object> variables = completeTaskBo.getVariables();
|
||||
if (CollUtil.isNotEmpty(assigneeMap)) {
|
||||
completeTaskBo.getVariables().putAll(assigneeMap);
|
||||
variables.putAll(assigneeMap);
|
||||
}
|
||||
// 构建流程参数,包括变量、跳转类型、消息、处理人、权限等信息
|
||||
FlowParams flowParams = new FlowParams();
|
||||
flowParams.variable(completeTaskBo.getVariables());
|
||||
flowParams.variable(variables);
|
||||
flowParams.skipType(SkipType.PASS.getKey());
|
||||
flowParams.message(completeTaskBo.getMessage());
|
||||
flowParams.flowStatus(BusinessStatusEnum.WAITING.getStatus()).hisStatus(TaskStatusEnum.PASS.getStatus());
|
||||
|
@ -20,7 +20,6 @@ import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.system.service.ISysDeptService;
|
||||
import org.dromara.workflow.common.ConditionalOnEnable;
|
||||
import org.dromara.workflow.domain.LxOaLeave;
|
||||
import org.dromara.workflow.domain.bo.LxOaLeaveBo;
|
||||
@ -50,8 +49,6 @@ public class LxOaLeaveServiceImpl implements ILxOaLeaveService {
|
||||
private final LxOaLeaveMapper baseMapper;
|
||||
private final WorkflowService workflowService;
|
||||
|
||||
private final ISysDeptService iSysDeptService;
|
||||
|
||||
/**
|
||||
* spel条件表达:判断小于2
|
||||
*
|
||||
@ -146,12 +143,6 @@ public class LxOaLeaveServiceImpl implements ILxOaLeaveService {
|
||||
return baseMapper.deleteByIds(ids) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDeptAdmin(Long userId) {
|
||||
iSysDeptService.selectDeptListByRoleId(userId);
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 总体流程监听(例如: 草稿,撤销,退回,作废,终止,已完成,单任务完成等)
|
||||
* 正常使用只需#processEvent.flowCode=='leave1'
|
||||
|
Loading…
x
Reference in New Issue
Block a user