use of com.ruoyi.common.core.domain.entity.SysUser 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;
}
use of com.ruoyi.common.core.domain.entity.SysUser 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);
}
use of com.ruoyi.common.core.domain.entity.SysUser in project RuoYi-Flowable-Plus by KonBAI-Q.
the class WfTaskServiceImpl method todoList.
/**
* 代办任务列表
*
* @return
*/
@Override
public TableDataInfo<WfTaskVo> todoList(PageQuery pageQuery) {
Page<WfTaskVo> page = new Page<>();
Long userId = LoginHelper.getUserId();
TaskQuery taskQuery = taskService.createTaskQuery().active().includeProcessVariables().taskCandidateOrAssigned(userId.toString()).orderByTaskCreateTime().desc();
page.setTotal(taskQuery.count());
int offset = pageQuery.getPageSize() * (pageQuery.getPageNum() - 1);
List<Task> taskList = taskQuery.listPage(offset, pageQuery.getPageSize());
List<WfTaskVo> flowList = new ArrayList<>();
for (Task task : taskList) {
WfTaskVo flowTask = new WfTaskVo();
// 当前流程信息
flowTask.setTaskId(task.getId());
flowTask.setTaskDefKey(task.getTaskDefinitionKey());
flowTask.setCreateTime(task.getCreateTime());
flowTask.setProcDefId(task.getProcessDefinitionId());
flowTask.setTaskName(task.getName());
// 流程定义信息
ProcessDefinition pd = repositoryService.createProcessDefinitionQuery().processDefinitionId(task.getProcessDefinitionId()).singleResult();
flowTask.setDeployId(pd.getDeploymentId());
flowTask.setProcDefName(pd.getName());
flowTask.setProcDefVersion(pd.getVersion());
flowTask.setProcInsId(task.getProcessInstanceId());
// 流程发起人信息
HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().processInstanceId(task.getProcessInstanceId()).singleResult();
SysUser startUser = sysUserService.selectUserById(Long.parseLong(historicProcessInstance.getStartUserId()));
// SysUser startUser = sysUserService.selectUserById(Long.parseLong(task.getAssignee()));
flowTask.setStartUserId(startUser.getNickName());
flowTask.setStartUserName(startUser.getNickName());
flowTask.setStartDeptName(startUser.getDept().getDeptName());
flowList.add(flowTask);
}
page.setRecords(flowList);
return TableDataInfo.build(page);
}
use of com.ruoyi.common.core.domain.entity.SysUser in project RuoYi-Flowable-Plus by KonBAI-Q.
the class SysRegisterService method register.
/**
* 注册
*/
public void register(RegisterBody registerBody) {
HttpServletRequest request = ServletUtils.getRequest();
String username = registerBody.getUsername();
String password = registerBody.getPassword();
// 校验用户类型是否存在
String userType = UserType.getUserType(registerBody.getUserType()).getUserType();
boolean captchaOnOff = configService.selectCaptchaOnOff();
// 验证码开关
if (captchaOnOff) {
validateCaptcha(username, registerBody.getCode(), registerBody.getUuid(), request);
}
if (UserConstants.NOT_UNIQUE.equals(userService.checkUserNameUnique(username))) {
throw new UserException("user.register.save.error", username);
}
SysUser sysUser = new SysUser();
sysUser.setUserName(username);
sysUser.setNickName(username);
sysUser.setPassword(BCrypt.hashpw(password));
sysUser.setUserType(userType);
boolean regFlag = userService.registerUser(sysUser);
if (!regFlag) {
throw new UserException("user.register.error");
}
asyncService.recordLogininfor(username, Constants.REGISTER, MessageUtils.message("user.register.success"), request);
}
use of com.ruoyi.common.core.domain.entity.SysUser in project RuoYi-Flowable-Plus by KonBAI-Q.
the class SysUserServiceImpl method checkUserDataScope.
/**
* 校验用户是否有数据权限
*
* @param userId 用户id
*/
@Override
public void checkUserDataScope(Long userId) {
if (!LoginHelper.isAdmin()) {
SysUser user = new SysUser();
user.setUserId(userId);
List<SysUser> users = this.selectUserList(user);
if (CollUtil.isEmpty(users)) {
throw new ServiceException("没有权限访问用户数据!");
}
}
}
Aggregations