更多nbcio-boot功能请看演示系统
gitee源代码地址
后端代码: https://gitee.com/nbacheng/nbcio-boot
前端代码:https://gitee.com/nbacheng/nbcio-vue.git
在线演示(包括H5) : http://122.227.135.243:9888
历史记录增加开始与结束的显示,以方便用户查看。
1、前端修改,代码如下:
{{item.taskName}}
{{ item.assigneeName }} 在 {{ item.createTime }} 发起流程
{{commentitem.comment}}
{{"退回: "+ commentitem.comment}}
{{"驳回: "+commentitem.comment}}
{{commentitem.comment}}
{{commentitem.comment}}
{{"撤回: "+commentitem.comment}}
{{commentitem.comment}}
{{commentitem.comment}}
{{commentitem.comment}}
{{commentitem.comment}}
{{commentitem.comment}}
{{commentitem.comment}}
{{ item.createTime }} 流程结束
2、后端修改
/**
* 流程历史流转记录
* add by nbacheng
* @param procInsId 流程实例Id, 流程发布id, 任务id
* @return
*/
@Override
public Result flowRecord(String procInsId,String deployId, String businessKey, String taskId, String category) {
Map map = new HashMap();
if (StringUtils.isNotBlank(procInsId)) {
List list = historyService
.createHistoricActivityInstanceQuery()
.processInstanceId(procInsId)
.activityTypes(CollUtil.newHashSet(BpmnXMLConstants.ELEMENT_EVENT_START, BpmnXMLConstants.ELEMENT_EVENT_END, BpmnXMLConstants.ELEMENT_TASK_USER))
.orderByHistoricActivityInstanceStartTime().desc()
.orderByHistoricActivityInstanceEndTime().desc()
.list();
List hisFlowList = new ArrayList<>();
// 获取流程实例
HistoricProcessInstance historicProcIns = historyService.createHistoricProcessInstanceQuery()
.processInstanceId(procInsId)
.includeProcessVariables()
.singleResult();
String startUserId = historicProcIns.getStartUserId();
for (HistoricActivityInstance histIns : list) {
FlowTaskDto flowTask = new FlowTaskDto();
if (BpmnXMLConstants.ELEMENT_EVENT_START.equals(histIns.getActivityType())) {
SysUser startUser = iFlowThirdService.getUserByUsername(startUserId);
flowTask.setAssigneeId(startUser.getUsername());
flowTask.setAssigneeName(startUser.getRealname());
flowTask.setCreateTime(histIns.getStartTime());
flowTask.setFinishTime(histIns.getEndTime());
flowTask.setActivityType(histIns.getActivityType());
}
if (BpmnXMLConstants.ELEMENT_EVENT_END.equals(histIns.getActivityType())) {
flowTask.setCreateTime(histIns.getStartTime());
flowTask.setFinishTime(histIns.getEndTime());
flowTask.setActivityType(histIns.getActivityType());
}
if (StringUtils.isNotBlank(histIns.getTaskId())) {
flowTask.setTaskId(histIns.getTaskId());
flowTask.setTaskName(histIns.getActivityName());
flowTask.setCreateTime(histIns.getStartTime());
flowTask.setFinishTime(histIns.getEndTime());
flowTask.setActivityType(histIns.getActivityType());
if (StringUtils.isNotBlank(histIns.getAssignee())) {
SysUser sysUser = iFlowThirdService.getUserByUsername(histIns.getAssignee());
if(sysUser !=null) {
flowTask.setAssigneeId(sysUser.getUsername());
flowTask.setAssigneeName(sysUser.getRealname());
List departNamesByUsername = iFlowThirdService.getDepartNamesByUsername(histIns.getAssignee());
flowTask.setDeptName(CollUtil.join(departNamesByUsername,","));
}
}
// 展示审批人员
List 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 = iFlowThirdService.getUserByUsername(identityLink.getUserId());
stringBuilder.append(sysUser.getRealname()).append(",");
}
if (StringUtils.isNotBlank(identityLink.getGroupId())) {
List allRole = iFlowThirdService.getAllRole();
SysRole sysRole = allRole.stream().filter(o -> StringUtils.equals(identityLink.getGroupId(), o.getId())).findAny().orElse(new SysRole());
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 commentList = taskService.getProcessInstanceComments(histIns.getProcessInstanceId());
List listFlowCommentDto = new ArrayList();
commentList.forEach(comment -> {
if (histIns.getTaskId().equals(comment.getTaskId())) {
//flowTask.setComment(FlowCommentDto.builder().type(comment.getType()).comment(comment.getFullMessage()).build());
//FlowCommentDto flowcommentDto = FlowCommentDto.builder().type(comment.getType()).comment(comment.getFullMessage()).build();
FlowCommentDto flowcommentDto = new FlowCommentDto();
flowcommentDto.setType(comment.getType());
flowcommentDto.setComment(comment.getFullMessage());
listFlowCommentDto.add(flowcommentDto);
}
});
flowTask.setListFlowCommentDto(listFlowCommentDto);
//获取附件
List commentfileList = taskService.getProcessInstanceAttachments(histIns.getProcessInstanceId());
List listcommentFileDto = new ArrayList();
commentfileList.forEach(commentfile -> {
if (histIns.getTaskId().equals(commentfile.getTaskId())) {
FlowCommentFileDto flowcommenfiletDto = new FlowCommentFileDto();
flowcommenfiletDto.setType(commentfile.getType());
flowcommenfiletDto.setFileurl(commentfile.getUrl());
listcommentFileDto.add(flowcommenfiletDto);
}
});
flowTask.setListcommentFileDto(listcommentFileDto);
// 获取历史任务节点表单数据值
List listHistoricVariableInstance = historyService.createHistoricVariableInstanceQuery()
.processInstanceId(procInsId)
.taskId(histIns.getTaskId())
.list();
Map variables = new HashedMap();
Map formconf = new HashedMap();
for(HistoricVariableInstance historicVariableInstance:listHistoricVariableInstance) {
variables.put(historicVariableInstance.getVariableName(), historicVariableInstance.getValue());
}
formconf.put("formValue", variables);
// 获取历史任务节点表单参数
if(Objects.nonNull(histIns.getTaskId())) {
HistoricTaskInstance taskIns = historyService.createHistoricTaskInstanceQuery()
.taskId(histIns.getTaskId())
.includeIdentityLinks()
.includeProcessVariables()
.includeTaskLocalVariables()
.finished()
.singleResult();
if (Objects.nonNull(taskIns)) {
{
String formId = taskIns.getFormKey();
SysForm sysForm = sysDeployFormService.selectCurSysDeployForm(formId, deployId, taskIns.getTaskDefinitionKey());
if (Objects.nonNull(sysForm)) {
formconf.put("config", JSONObject.parseObject(sysForm.getFormContent()).get("config"));
formconf.put("list", JSONObject.parseObject(sysForm.getFormContent()).get("list"));
}
}
}
}
flowTask.setTaskFormValues(formconf);
}
hisFlowList.add(flowTask);
}
map.put("flowList", hisFlowList);
}
if (Objects.nonNull(category) && category.equalsIgnoreCase("online") && StringUtils.isNotBlank(businessKey)) {// 获取online数据表单配置
LambdaQueryWrapper flowMyOnlineLambdaQueryWrapper = new LambdaQueryWrapper<>();
flowMyOnlineLambdaQueryWrapper.eq(FlowMyOnline::getDataId, businessKey);//以后这里还要加上onlineId
FlowMyOnline online = flowMyOnlineService.getOne(flowMyOnlineLambdaQueryWrapper);
if (Objects.nonNull(online)) {
Map onlCgformHeadMap = flowOnlCgformHeadService.getOnlCgformHeadByFormId(online.getOnlineId());
map.put("onlineConfig", onlCgformHeadMap.get("formData"));
map.put("onlineId", online.getOnlineId());
}
}
else if (Objects.nonNull(category) && StringUtils.isNotBlank(businessKey) && !Objects.equals(businessKey, "null") && (category != "online")) { // 获取初始化自定义表单
FlowMyBusiness business = flowMyBusinessService.getByDataId(businessKey);
String serviceImplName = business.getServiceImplName();
FlowCallBackServiceI flowCallBackService = (FlowCallBackServiceI) SpringContextUtils.getBean(serviceImplName);
// 流程处理完后,进行回调业务层
if (flowCallBackService!=null){
Object businessDataById = flowCallBackService.getBusinessDataById(businessKey);
map.put("formData",businessDataById);
map.put("routeName", business.getRouteName());
}
}
else {
if (StringUtils.isNotBlank(deployId)) {
//获取当前节点的初始化表单
if(Objects.nonNull(taskId)) {
HistoricTaskInstance taskIns = historyService.createHistoricTaskInstanceQuery()
.taskId(taskId)
.includeIdentityLinks()
.includeProcessVariables()
.includeTaskLocalVariables()
.singleResult();
if (Objects.nonNull(taskIns)) {
String formId = taskIns.getFormKey();
SysForm sysForm = sysDeployFormService.selectCurSysDeployForm(formId, deployId, taskIns.getTaskDefinitionKey());
if (Objects.nonNull(sysForm)) {
map.put("taskFormData", JSONObject.parseObject(sysForm.getFormContent()));
}
}
}
else {
SysForm sysForm = sysDeployFormService.selectSysDeployFormByDeployId(deployId);
if (Objects.isNull(sysForm)) {
return Result.error("请先配置流程表单");
}
map.put("formData", JSONObject.parseObject(sysForm.getFormContent()));
}
}
}
if(isStartUserNode(taskId)) {
map.put("isStartUserNode", true);
}
return Result.OK(map);
}
3、效果图