Search in sources :

Example 1 with SysRole

use of com.ruoyi.common.core.domain.entity.SysRole in project RuoYi-Flowable-Plus by KonBAI-Q.

the class SysUserController method getInfo.

/**
 * 根据用户编号获取详细信息
 */
@ApiOperation("根据用户编号获取详细信息")
@SaCheckPermission("system:user:query")
@GetMapping(value = { "/", "/{userId}" })
public R<Map<String, Object>> getInfo(@ApiParam("用户ID") @PathVariable(value = "userId", required = false) Long userId) {
    userService.checkUserDataScope(userId);
    Map<String, Object> ajax = new HashMap<>();
    List<SysRole> roles = roleService.selectRoleAll();
    ajax.put("roles", LoginHelper.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
    ajax.put("posts", postService.selectPostAll());
    if (ObjectUtil.isNotNull(userId)) {
        SysUser sysUser = userService.selectUserById(userId);
        ajax.put("user", sysUser);
        ajax.put("postIds", postService.selectPostListByUserId(userId));
        ajax.put("roleIds", sysUser.getRoles().stream().map(SysRole::getRoleId).collect(Collectors.toList()));
    }
    return R.ok(ajax);
}
Also used : R(com.ruoyi.common.core.domain.R) SysDept(com.ruoyi.common.core.domain.entity.SysDept) SysUser(com.ruoyi.common.core.domain.entity.SysUser) TableDataInfo(com.ruoyi.common.core.page.TableDataInfo) SysUserImportListener(com.ruoyi.system.listener.SysUserImportListener) BCrypt(cn.dev33.satoken.secure.BCrypt) ObjectUtil(cn.hutool.core.util.ObjectUtil) RequiredArgsConstructor(lombok.RequiredArgsConstructor) HashMap(java.util.HashMap) BeanUtil(cn.hutool.core.bean.BeanUtil) PageQuery(com.ruoyi.common.core.domain.PageQuery) ArrayList(java.util.ArrayList) SysUserExportVo(com.ruoyi.system.domain.vo.SysUserExportVo) StringUtils(com.ruoyi.common.utils.StringUtils) Map(java.util.Map) ISysRoleService(com.ruoyi.system.service.ISysRoleService) io.swagger.annotations(io.swagger.annotations) BaseController(com.ruoyi.common.core.controller.BaseController) SysUserImportVo(com.ruoyi.system.domain.vo.SysUserImportVo) Validated(org.springframework.validation.annotation.Validated) HttpServletResponse(javax.servlet.http.HttpServletResponse) LoginHelper(com.ruoyi.common.helper.LoginHelper) Collectors(java.util.stream.Collectors) BusinessType(com.ruoyi.common.enums.BusinessType) ISysUserService(com.ruoyi.system.service.ISysUserService) List(java.util.List) UserConstants(com.ruoyi.common.constant.UserConstants) Log(com.ruoyi.common.annotation.Log) ExcelUtil(com.ruoyi.common.utils.poi.ExcelUtil) ArrayUtil(cn.hutool.core.util.ArrayUtil) org.springframework.web.bind.annotation(org.springframework.web.bind.annotation) MultipartFile(org.springframework.web.multipart.MultipartFile) SysRole(com.ruoyi.common.core.domain.entity.SysRole) ISysPostService(com.ruoyi.system.service.ISysPostService) SaCheckPermission(cn.dev33.satoken.annotation.SaCheckPermission) ExcelResult(com.ruoyi.common.excel.ExcelResult) SysUser(com.ruoyi.common.core.domain.entity.SysUser) HashMap(java.util.HashMap) SysRole(com.ruoyi.common.core.domain.entity.SysRole) SaCheckPermission(cn.dev33.satoken.annotation.SaCheckPermission)

Example 2 with SysRole

use of com.ruoyi.common.core.domain.entity.SysRole in project RuoYi-Flowable-Plus by KonBAI-Q.

the class SysUserController method authRole.

/**
 * 根据用户编号获取授权角色
 */
@ApiOperation("根据用户编号获取授权角色")
@SaCheckPermission("system:user:query")
@GetMapping("/authRole/{userId}")
public R<Map<String, Object>> authRole(@ApiParam("用户ID") @PathVariable("userId") Long userId) {
    SysUser user = userService.selectUserById(userId);
    List<SysRole> roles = roleService.selectRolesByUserId(userId);
    Map<String, Object> ajax = new HashMap<>();
    ajax.put("user", user);
    ajax.put("roles", LoginHelper.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
    return R.ok(ajax);
}
Also used : R(com.ruoyi.common.core.domain.R) SysDept(com.ruoyi.common.core.domain.entity.SysDept) SysUser(com.ruoyi.common.core.domain.entity.SysUser) TableDataInfo(com.ruoyi.common.core.page.TableDataInfo) SysUserImportListener(com.ruoyi.system.listener.SysUserImportListener) BCrypt(cn.dev33.satoken.secure.BCrypt) ObjectUtil(cn.hutool.core.util.ObjectUtil) RequiredArgsConstructor(lombok.RequiredArgsConstructor) HashMap(java.util.HashMap) BeanUtil(cn.hutool.core.bean.BeanUtil) PageQuery(com.ruoyi.common.core.domain.PageQuery) ArrayList(java.util.ArrayList) SysUserExportVo(com.ruoyi.system.domain.vo.SysUserExportVo) StringUtils(com.ruoyi.common.utils.StringUtils) Map(java.util.Map) ISysRoleService(com.ruoyi.system.service.ISysRoleService) io.swagger.annotations(io.swagger.annotations) BaseController(com.ruoyi.common.core.controller.BaseController) SysUserImportVo(com.ruoyi.system.domain.vo.SysUserImportVo) Validated(org.springframework.validation.annotation.Validated) HttpServletResponse(javax.servlet.http.HttpServletResponse) LoginHelper(com.ruoyi.common.helper.LoginHelper) Collectors(java.util.stream.Collectors) BusinessType(com.ruoyi.common.enums.BusinessType) ISysUserService(com.ruoyi.system.service.ISysUserService) List(java.util.List) UserConstants(com.ruoyi.common.constant.UserConstants) Log(com.ruoyi.common.annotation.Log) ExcelUtil(com.ruoyi.common.utils.poi.ExcelUtil) ArrayUtil(cn.hutool.core.util.ArrayUtil) org.springframework.web.bind.annotation(org.springframework.web.bind.annotation) MultipartFile(org.springframework.web.multipart.MultipartFile) SysRole(com.ruoyi.common.core.domain.entity.SysRole) ISysPostService(com.ruoyi.system.service.ISysPostService) SaCheckPermission(cn.dev33.satoken.annotation.SaCheckPermission) ExcelResult(com.ruoyi.common.excel.ExcelResult) SysUser(com.ruoyi.common.core.domain.entity.SysUser) HashMap(java.util.HashMap) SysRole(com.ruoyi.common.core.domain.entity.SysRole) SaCheckPermission(cn.dev33.satoken.annotation.SaCheckPermission)

Example 3 with SysRole

use of com.ruoyi.common.core.domain.entity.SysRole in project RuoYi-Flowable-Plus by KonBAI-Q.

the class WfTaskServiceImpl method flowRecord.

/**
 * 流程历史流转记录
 *
 * @param procInsId 流程实例Id
 * @return
 */
@Override
public Map<String, Object> flowRecord(String procInsId, String deployId) {
    Map<String, Object> map = new HashMap<>();
    if (StringUtils.isNotBlank(procInsId)) {
        List<HistoricActivityInstance> list = historyService.createHistoricActivityInstanceQuery().processInstanceId(procInsId).orderByHistoricActivityInstanceStartTime().desc().list();
        List<WfTaskVo> hisFlowList = new ArrayList<>();
        for (HistoricActivityInstance histIns : list) {
            if (StringUtils.isNotBlank(histIns.getTaskId())) {
                WfTaskVo flowTask = new WfTaskVo();
                flowTask.setProcDefId(histIns.getProcessDefinitionId());
                flowTask.setTaskId(histIns.getTaskId());
                flowTask.setTaskName(histIns.getActivityName());
                flowTask.setCreateTime(histIns.getStartTime());
                flowTask.setFinishTime(histIns.getEndTime());
                if (StringUtils.isNotBlank(histIns.getAssignee())) {
                    SysUser sysUser = sysUserService.selectUserById(Long.parseLong(histIns.getAssignee()));
                    flowTask.setAssigneeId(sysUser.getUserId());
                    flowTask.setAssigneeName(sysUser.getNickName());
                    flowTask.setDeptName(sysUser.getDept().getDeptName());
                }
                // 展示审批人员
                List<HistoricIdentityLink> linksForTask = historyService.getHistoricIdentityLinksForTask(histIns.getTaskId());
                StringBuilder stringBuilder = new StringBuilder();
                for (HistoricIdentityLink identityLink : linksForTask) {
                    if ("candidate".equals(identityLink.getType())) {
                        if (StringUtils.isNotBlank(identityLink.getUserId())) {
                            SysUser sysUser = sysUserService.selectUserById(Long.parseLong(identityLink.getUserId()));
                            stringBuilder.append(sysUser.getNickName()).append(",");
                        }
                        if (StringUtils.isNotBlank(identityLink.getGroupId())) {
                            SysRole sysRole = sysRoleService.selectRoleById(Long.parseLong(identityLink.getGroupId()));
                            stringBuilder.append(sysRole.getRoleName()).append(",");
                        }
                    }
                }
                if (StringUtils.isNotBlank(stringBuilder)) {
                    flowTask.setCandidate(stringBuilder.substring(0, stringBuilder.length() - 1));
                }
                flowTask.setDuration(histIns.getDurationInMillis() == null || histIns.getDurationInMillis() == 0 ? null : getDate(histIns.getDurationInMillis()));
                // 获取意见评论内容
                List<Comment> commentList = taskService.getProcessInstanceComments(histIns.getProcessInstanceId());
                commentList.forEach(comment -> {
                    if (histIns.getTaskId().equals(comment.getTaskId())) {
                        flowTask.setComment(WfCommentDto.builder().type(comment.getType()).comment(comment.getFullMessage()).build());
                    }
                });
                hisFlowList.add(flowTask);
            }
        }
        map.put("flowList", hisFlowList);
    // // 查询当前任务是否完成
    // List<Task> taskList = taskService.createTaskQuery().processInstanceId(procInsId).list();
    // if (CollectionUtils.isNotEmpty(taskList)) {
    // map.put("finished", true);
    // } else {
    // map.put("finished", false);
    // }
    }
    // 第一次申请获取初始化表单
    if (StringUtils.isNotBlank(deployId)) {
        WfFormVo formVo = deployFormService.selectDeployFormByDeployId(deployId);
        if (Objects.isNull(formVo)) {
            throw new ServiceException("请先配置流程表单");
        }
        map.put("formData", JsonUtils.parseObject(formVo.getContent(), Map.class));
    }
    return map;
}
Also used : Comment(org.flowable.engine.task.Comment) FlowComment(com.ruoyi.flowable.common.enums.FlowComment) HistoricIdentityLink(org.flowable.identitylink.api.history.HistoricIdentityLink) SysUser(com.ruoyi.common.core.domain.entity.SysUser) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) WfTaskVo(com.ruoyi.workflow.domain.vo.WfTaskVo) WfFormVo(com.ruoyi.workflow.domain.vo.WfFormVo) ServiceException(com.ruoyi.common.exception.ServiceException) SysRole(com.ruoyi.common.core.domain.entity.SysRole) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HistoricActivityInstance(org.flowable.engine.history.HistoricActivityInstance)

Example 4 with SysRole

use of com.ruoyi.common.core.domain.entity.SysRole in project RuoYi-Flowable-Plus by KonBAI-Q.

the class WfTaskServiceImpl method getNextFlowNode.

/**
 * 获取下一节点
 *
 * @param bo 任务
 * @return
 */
@Override
public R getNextFlowNode(WfTaskBo bo) {
    Task task = taskService.createTaskQuery().taskId(bo.getTaskId()).singleResult();
    WfNextDto nextDto = new WfNextDto();
    if (Objects.nonNull(task)) {
        List<UserTask> nextUserTask = FindNextNodeUtil.getNextUserTasks(repositoryService, task, new HashMap<>());
        if (CollectionUtils.isNotEmpty(nextUserTask)) {
            for (UserTask userTask : nextUserTask) {
                MultiInstanceLoopCharacteristics multiInstance = userTask.getLoopCharacteristics();
                // 会签节点
                if (Objects.nonNull(multiInstance)) {
                    List<SysUser> list = sysUserService.selectUserList(new SysUser());
                    nextDto.setVars(ProcessConstants.PROCESS_MULTI_INSTANCE_USER);
                    nextDto.setType(ProcessConstants.PROCESS_MULTI_INSTANCE);
                    nextDto.setUserList(list);
                } else {
                    // 读取自定义节点属性 判断是否是否需要动态指定任务接收人员、组
                    String dataType = userTask.getAttributeValue(ProcessConstants.NAMASPASE, ProcessConstants.PROCESS_CUSTOM_DATA_TYPE);
                    String userType = userTask.getAttributeValue(ProcessConstants.NAMASPASE, ProcessConstants.PROCESS_CUSTOM_USER_TYPE);
                    if (ProcessConstants.DATA_TYPE.equals(dataType)) {
                        // 指定单个人员
                        if (ProcessConstants.USER_TYPE_ASSIGNEE.equals(userType)) {
                            List<SysUser> list = sysUserService.selectUserList(new SysUser());
                            nextDto.setVars(ProcessConstants.PROCESS_APPROVAL);
                            nextDto.setType(ProcessConstants.USER_TYPE_ASSIGNEE);
                            nextDto.setUserList(list);
                        }
                        // 候选人员(多个)
                        if (ProcessConstants.USER_TYPE_USERS.equals(userType)) {
                            List<SysUser> list = sysUserService.selectUserList(new SysUser());
                            nextDto.setVars(ProcessConstants.PROCESS_APPROVAL);
                            nextDto.setType(ProcessConstants.USER_TYPE_USERS);
                            nextDto.setUserList(list);
                        }
                        // 候选组
                        if (ProcessConstants.USER_TYPE_ROUPS.equals(userType)) {
                            List<SysRole> sysRoles = sysRoleService.selectRoleAll();
                            nextDto.setVars(ProcessConstants.PROCESS_APPROVAL);
                            nextDto.setType(ProcessConstants.USER_TYPE_ROUPS);
                            nextDto.setRoleList(sysRoles);
                        }
                    }
                }
            }
        } else {
            return R.ok("流程已完结", null);
        }
    }
    return R.ok(nextDto);
}
Also used : Task(org.flowable.task.api.Task) WfNextDto(com.ruoyi.workflow.domain.dto.WfNextDto) SysUser(com.ruoyi.common.core.domain.entity.SysUser) SysRole(com.ruoyi.common.core.domain.entity.SysRole)

Example 5 with SysRole

use of com.ruoyi.common.core.domain.entity.SysRole in project RuoYi-Flowable-Plus by KonBAI-Q.

the class SysRoleServiceImpl method selectRolePermissionByUserId.

/**
 * 根据用户ID查询权限
 *
 * @param userId 用户ID
 * @return 权限列表
 */
@Override
public Set<String> selectRolePermissionByUserId(Long userId) {
    List<SysRole> perms = baseMapper.selectRolePermissionByUserId(userId);
    Set<String> permsSet = new HashSet<>();
    for (SysRole perm : perms) {
        if (ObjectUtil.isNotNull(perm)) {
            permsSet.addAll(Arrays.asList(perm.getRoleKey().trim().split(",")));
        }
    }
    return permsSet;
}
Also used : SysRole(com.ruoyi.common.core.domain.entity.SysRole)

Aggregations

SysRole (com.ruoyi.common.core.domain.entity.SysRole)44 SysUser (com.ruoyi.common.core.domain.entity.SysUser)15 Log (com.ruoyi.common.annotation.Log)9 UserConstants (com.ruoyi.common.constant.UserConstants)9 BaseController (com.ruoyi.common.core.controller.BaseController)9 TableDataInfo (com.ruoyi.common.core.page.TableDataInfo)9 BusinessType (com.ruoyi.common.enums.BusinessType)9 ServiceException (com.ruoyi.common.exception.ServiceException)9 StringUtils (com.ruoyi.common.utils.StringUtils)9 ExcelUtil (com.ruoyi.common.utils.poi.ExcelUtil)9 ISysPostService (com.ruoyi.system.service.ISysPostService)9 ISysRoleService (com.ruoyi.system.service.ISysRoleService)9 ISysUserService (com.ruoyi.system.service.ISysUserService)9 List (java.util.List)9 Collectors (java.util.stream.Collectors)9 Validated (org.springframework.validation.annotation.Validated)9 MultipartFile (org.springframework.web.multipart.MultipartFile)9 HttpServletResponse (javax.servlet.http.HttpServletResponse)8 SaCheckPermission (cn.dev33.satoken.annotation.SaCheckPermission)4 BCrypt (cn.dev33.satoken.secure.BCrypt)4