Search in sources :

Example 1 with WfFormVo

use of com.ruoyi.workflow.domain.vo.WfFormVo 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 2 with WfFormVo

use of com.ruoyi.workflow.domain.vo.WfFormVo in project RuoYi-Flowable-Plus by KonBAI-Q.

the class WfDefinitionServiceImpl method list.

/**
 * 流程定义列表
 *
 * @param pageQuery 分页参数
 * @return 流程定义分页列表数据
 */
@Override
public TableDataInfo<WfDefinitionVo> list(PageQuery pageQuery) {
    Page<WfDefinitionVo> page = new Page<>();
    // 流程定义列表数据查询
    ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery().latestVersion().orderByProcessDefinitionKey().asc();
    long pageTotal = processDefinitionQuery.count();
    if (pageTotal <= 0) {
        return TableDataInfo.build();
    }
    int offset = pageQuery.getPageSize() * (pageQuery.getPageNum() - 1);
    List<ProcessDefinition> definitionList = processDefinitionQuery.listPage(offset, pageQuery.getPageSize());
    List<WfDefinitionVo> definitionVoList = new ArrayList<>();
    for (ProcessDefinition processDefinition : definitionList) {
        String deploymentId = processDefinition.getDeploymentId();
        Deployment deployment = repositoryService.createDeploymentQuery().deploymentId(deploymentId).singleResult();
        WfDefinitionVo vo = new WfDefinitionVo();
        vo.setDefinitionId(processDefinition.getId());
        vo.setProcessKey(processDefinition.getKey());
        vo.setProcessName(processDefinition.getName());
        vo.setVersion(processDefinition.getVersion());
        vo.setCategory(processDefinition.getCategory());
        vo.setDeploymentId(processDefinition.getDeploymentId());
        vo.setSuspended(processDefinition.isSuspended());
        WfFormVo formVo = deployFormService.selectDeployFormByDeployId(deploymentId);
        if (Objects.nonNull(formVo)) {
            vo.setFormId(formVo.getFormId());
            vo.setFormName(formVo.getFormName());
        }
        // 流程定义时间
        vo.setCategory(deployment.getCategory());
        vo.setDeploymentTime(deployment.getDeploymentTime());
        definitionVoList.add(vo);
    }
    page.setRecords(definitionVoList);
    page.setTotal(pageTotal);
    return TableDataInfo.build(page);
}
Also used : Deployment(org.flowable.engine.repository.Deployment) Page(com.baomidou.mybatisplus.extension.plugins.pagination.Page) ProcessDefinitionQuery(org.flowable.engine.repository.ProcessDefinitionQuery) ProcessDefinition(org.flowable.engine.repository.ProcessDefinition) WfFormVo(com.ruoyi.workflow.domain.vo.WfFormVo) WfDefinitionVo(com.ruoyi.workflow.domain.vo.WfDefinitionVo)

Aggregations

WfFormVo (com.ruoyi.workflow.domain.vo.WfFormVo)2 Page (com.baomidou.mybatisplus.extension.plugins.pagination.Page)1 SysRole (com.ruoyi.common.core.domain.entity.SysRole)1 SysUser (com.ruoyi.common.core.domain.entity.SysUser)1 ServiceException (com.ruoyi.common.exception.ServiceException)1 FlowComment (com.ruoyi.flowable.common.enums.FlowComment)1 WfDefinitionVo (com.ruoyi.workflow.domain.vo.WfDefinitionVo)1 WfTaskVo (com.ruoyi.workflow.domain.vo.WfTaskVo)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 HistoricActivityInstance (org.flowable.engine.history.HistoricActivityInstance)1 Deployment (org.flowable.engine.repository.Deployment)1 ProcessDefinition (org.flowable.engine.repository.ProcessDefinition)1 ProcessDefinitionQuery (org.flowable.engine.repository.ProcessDefinitionQuery)1 Comment (org.flowable.engine.task.Comment)1 HistoricIdentityLink (org.flowable.identitylink.api.history.HistoricIdentityLink)1