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);
}
接口返回示例文章来源:https://www.toymoban.com/news/detail-809304.html
{
"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
}
前端展示效果
文章来源地址https://www.toymoban.com/news/detail-809304.html
到了这里,关于flowable流程节点状态构造的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!