在流程流转过程中增加节点表单的后端修改
8、complete的修改
主要增加下面方法,就是有任务节点表单的时候,complete需要取出这个值来,之后要进行下面的complete,特别是需要true参数,否则会有问题,所以对原先多实例approval处理进行另外处理,不在这里进行处理了
/** * 任务节点有表单的操作 * * @param taskVo */ private void taskFormCompete(FlowTaskVo taskVo) { if(taskVo.getValues().containsKey("taskformvalues")) {//有任务节点表单 @SuppressWarnings("unchecked") Map<String , Object> taskformvalues = (Map<String, Object>) taskVo.getValues().get("taskformvalues"); taskService.complete(taskVo.getTaskId(),taskformvalues, true);//保存taskid到变量表里 } else { taskService.complete(taskVo.getTaskId()); } }
9、flowrecord的修改,主要增加下面部分,就是历史表单参数与历史表单数据
// 获取历史任务节点表单数据值 List<HistoricVariableInstance> listHistoricVariableInstance = historyService.createHistoricVariableInstanceQuery() .processInstanceId(procInsId) .taskId(histIns.getTaskId()) .list(); Map<String, Object> variables = new HashedMap<String, Object>(); Map<String, Object> formconf = new HashedMap<String, Object>(); 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(StringUtils.isNotBlank(businessKey)) { 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())); } }