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
}

前端展示效果

相关推荐
华如锦3 天前
低代码工作流平台概述-自研
java·spring boot·spring·spring cloud·ai·flowable·工作流
爱吃土豆的程序员2 个月前
flowable源码解读——内存缓存设计
缓存·flowable·源码解读
宁波阿成3 个月前
橙单后端项目下载编译遇到的问题与解决
java·前端·数据库·vue3·flowable
宁波阿成3 个月前
基于jeecgboot-vue3的Flowable流程仿钉钉流程设计器-抄送服务处理
java·钉钉·vue3·flowable·jeecg-boot
宁波阿成3 个月前
基于Jeecgboot3.6.3的vue3版本的流程ProcessViewer的修改
前端·vue3·flowable·jeecgboot
宁波阿成4 个月前
基于jeecgboot-vue3的Flowable流程仿钉钉流程设计器-不同panel兄弟之间的数据传递
前端·钉钉·vue3·flowable·jeecgboot
宁波阿成4 个月前
基于jeecgboot-vue3的Flowable流程仿钉钉流程设计器-支持VForm3表单的选择与支持
前端·vue3·flowable·仿钉钉·jeecgboot
宁波阿成4 个月前
基于jeecgboot-vue3的Flowable流程仿钉钉流程设计器-排它网关里数字比较大小的处理
java·钉钉·vue3·flowable·jeecgboot
宁波阿成4 个月前
基于jeecgboot-vue3的Flowable流程支持bpmn流程设计器与仿钉钉流程设计器-编辑多版本处理
java·钉钉·vue3·flowable·jeecg-boot
宁波阿成4 个月前
基于若依的ruoyi-nbcio流程管理系统修正自定义业务表单的回写bug
java·vue·bug·flowable·ruoyi-nbcio