flowable流程节点状态构造

java 复制代码
    public Result<List<TaskDetailVO>> record(@PathVariable("processInstanceId") String processInstanceId){
        List<Comment> processInstanceComments = taskService.getProcessInstanceComments(processInstanceId);
        Map<String, List<Comment>> commentsMap = processInstanceComments.stream()
                .collect(Collectors.groupingBy(Comment::getTaskId));
        List<Attachment> processInstanceAttachments = taskService.getProcessInstanceAttachments(processInstanceId);
        Map<String, List<Attachment>> attachmentMap = processInstanceAttachments.stream()
                .collect(Collectors.groupingBy(Attachment::getTaskId));
        List<HistoricActivityInstance> list = historyService.createHistoricActivityInstanceQuery().processInstanceId(processInstanceId).orderByHistoricActivityInstanceStartTime().asc().list();
        List<TaskDetailVO> taskDetailVOS= new ArrayList<>();
        for (HistoricActivityInstance historicActivityInstance : list) {
            if("userTask".equals(historicActivityInstance.getActivityType())){
                List<Comment> comments = commentsMap.get(historicActivityInstance.getTaskId());
                if(CollUtil.isNotEmpty(comments)){
                    for (Comment comment : comments) {
                        if(OPINION_COMMENT.equals(comment.getType())){
                            TaskDetailVO taskDetailVO= new TaskDetailVO();
                            taskDetailVO.setTaskId(historicActivityInstance.getTaskId());
                            taskDetailVO.setActivityId(historicActivityInstance.getActivityId());
                            taskDetailVO.setName(historicActivityInstance.getActivityName());
                            taskDetailVO.setCreateTime(historicActivityInstance.getStartTime());
                            taskDetailVO.setEndTime(historicActivityInstance.getEndTime());
                            taskDetailVO.setComment(comment.getFullMessage());
                            taskDetailVO.setUser(getUserInfoVo(historicActivityInstance.getAssignee()));
                            taskDetailVO.setStatus(Objects.equals(historicActivityInstance.getDeleteReason(), "拒绝")?2:1);
                            List<Attachment> attachments = attachmentMap.get(historicActivityInstance.getTaskId());
                            List<AttachmentVO> attachmentVOList = new ArrayList<>();
                            if(attachments!=null){
                                for (Attachment attachment : attachments) {
                                    AttachmentVO attachmentVO = new AttachmentVO();
                                    attachmentVO.setId(attachment.getId());
                                    attachmentVO.setName(attachment.getName());
                                    attachmentVO.setUrl(attachment.getUrl());
                                    attachmentVOList.add(attachmentVO);
                                }
                            }
                            for (Comment comment1 : comments) {
                                if(SIGN_COMMENT.equals(comment1.getType())){
                                    taskDetailVO.setSignImage(comment1.getFullMessage());
                                }
                            }

                            taskDetailVO.setAttachmentVOList(attachmentVOList);
                            taskDetailVOS.add(taskDetailVO);
                        }
                    }
                }else{
                    TaskDetailVO taskDetailVO= new TaskDetailVO();
                    taskDetailVO.setTaskId(historicActivityInstance.getTaskId());
                    taskDetailVO.setActivityId(historicActivityInstance.getActivityId());
                    taskDetailVO.setName(historicActivityInstance.getActivityName());
                    taskDetailVO.setCreateTime(historicActivityInstance.getStartTime());
                    taskDetailVO.setEndTime(historicActivityInstance.getEndTime());
                    if(Objects.equals(historicActivityInstance.getActivityName(), "发起人")){
                        // 查发起人的信息
                        HistoricProcessInstance historyProcessInstance  = historyService.createHistoricProcessInstanceQuery().processInstanceId(historicActivityInstance.getProcessInstanceId()).singleResult();
                        taskDetailVO.setUser(getUserInfoVo(historyProcessInstance.getStartUserId()));
                        taskDetailVO.setStatus(-1);
                    }else{
                        taskDetailVO.setUser(getUserInfoVo(historicActivityInstance.getAssignee()));
                        taskDetailVO.setStatus(0);
                    }
                    taskDetailVO.setComment("");
                    taskDetailVOS.add(taskDetailVO);
                }
            }
        }
        return Result.OK(taskDetailVOS);
    }

接口返回示例

xml 复制代码
{
    "success": true,
    "message": "操作成功!",
    "code": 200,
    "result": [
        {
            "taskId": "1747191729082482688",
            "activityId": "root",
            "name": "发起人",
            "createTime": "2024-01-16T17:39:04.117+08:00",
            "endTime": "2024-01-16T17:39:04.385+08:00",
            "signImage": null,
            "attachmentVOList": null,
            "optionVOList": null,
            "commentVOList": null,
            "comment": "",
            "user": {
                "id": "1",
                "name": "张三",
                "type": "user",
                "sex": "1",
                "selected": true
            },
            "status": null
        },
        {
            "taskId": "1747191730344968192",
            "activityId": "node_417233798091",
            "name": "审批人",
            "createTime": "2024-01-16T17:39:04.422+08:00",
            "endTime": "2024-01-16T19:31:09.651+08:00",
            "signImage": null,
            "attachmentVOList": [],
            "optionVOList": null,
            "commentVOList": null,
            "comment": "同意",
            "user": {
                "id": "2",
                "name": "张四",
                "type": "user",
                "sex": "1",
                "selected": true
            },
            "status": true
        },
        {
            "taskId": "1747219938314448896",
            "activityId": "node_223911503301",
            "name": "审批人",
            "createTime": "2024-01-16T19:31:09.725+08:00",
            "endTime": null,
            "signImage": null,
            "attachmentVOList": null,
            "optionVOList": null,
            "commentVOList": null,
            "comment": "待审批",
            "user": {
                "id": "5",
                "name": "晓华",
                "type": "user",
                "sex": "1",
                "selected": true
            },
            "status": null
        }
    ],
    "data": null,
    "timestamp": 1705406600461
}

前端展示效果

相关推荐
RuoyiOffice3 天前
UniApp企业办公:把审批、客户和项目装进手机,能做些什么?
spring boot·vue3·uniapp·crm·flowable·移动办公·企业应用
RuoyiOffice4 天前
SpringBoot OA推荐:面向信创选型,看看这套企业协同平台
spring boot·vue3·信创·flowable·企业协同·ruoyi office·oa选型
RuoyiOffice6 天前
Flowable 状态通知设计:单体用本地事件,微服务如何回写业务状态?
spring boot·微服务·vue3·flowable·ruoyi office·redis stream·流程状态通知
RuoyiOffice7 天前
项目预算和交付日期变了,为什么不能直接改台账?
spring boot·项目管理·vue3·flowable·业务建模·ruoyi office·项目变更
RuoyiOffice8 天前
SpringBoot+Vue3 单据校验设计:保存草稿、提交审批、退回重填,各该检查什么?
spring boot·vue3·flowable·表单设计·ruoyi office·草稿保存·单据校验
RuoyiOffice1 个月前
SpringBoot3+Vue3 低代码业务表单:从拖拽设计、独立建表到审批与数据查询
spring boot·vue3·数据建模·flowable·版本管理·低代码表单·ruoyi office
大龄码农有梦想1 个月前
企业工作流系统如何设计用户、部门、角色、岗位、动态关系五类流程办理人?
工作流引擎·flowable·流程引擎·oa·工作流系统·选人规则·bpm平台
RuoyiOffice1 个月前
SpringBoot3+Vue3 流程抄送已读:打开详情消红点,待办与知会怎么分开
spring boot·vue3·flowable·spring boot 3·ruoyi office·流程抄送·已读回执
RuoyiOffice1 个月前
SpringBoot3+Vue3+Flowable 企业审批平台全链路:从表单设计、节点权限到移动审批怎么落地
spring boot·vue3·uniapp·springboot3·flowable·审批系统·ruoyi office
凤山老林2 个月前
Spring Boot 整合 Flowable 的企业级落地指南
数据库·spring boot·后端·flowable·工作流