|
@@ -94,7 +94,7 @@ public class ActivitiFromHtmlController {
|
|
|
ClassPathResource resource = new ClassPathResource("testform1.zip");
|
|
|
ZipInputStream zip = new ZipInputStream(resource.getInputStream());
|
|
|
builder.addZipInputStream(zip);
|
|
|
- return flowStart(builder.deploy().getId());
|
|
|
+ return flowStart(builder.deploy().getId(), null, null);
|
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "获取流程部署信息")
|
|
@@ -105,66 +105,78 @@ public class ActivitiFromHtmlController {
|
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "获取流程表单属性接口")
|
|
|
- @RequestMapping(value = "/flow/formData/get", method = RequestMethod.POST)
|
|
|
+ @RequestMapping(value = "/flow/formPropertie/get", method = RequestMethod.POST)
|
|
|
@Transactional
|
|
|
@ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
|
|
|
- public Map<String, Object> flowStart(@ApiParam(value = "流程部署id", required = true) @RequestParam String flowDeploymentId) {
|
|
|
+ public Map<String, Object> flowStart(@ApiParam(value = "流程部署id") @RequestParam(required = false) String flowDeploymentId,
|
|
|
+ @ApiParam(value = "流程id") @RequestParam(required = false) Long flowId,
|
|
|
+ @ApiParam(value = "流程任务id") @RequestParam(required = false) Long taskId) {
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
- String processDefinitionId = null;
|
|
|
- TFCustomFlow tfCustomFlow = tfCustomFlowService.getOne(new QueryWrapper<TFCustomFlow>().lambda().eq(TFCustomFlow::getFlowDeploymentId, flowDeploymentId));
|
|
|
- Optional.ofNullable(tfCustomFlow.getFlowProcessVar()).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程没有部署数据!"));
|
|
|
- if (Objects.isNull(tfCustomFlow.getFlowDefinitionId())) {
|
|
|
- processDefinitionId = activitiConsumerService.findProcessDefinitionIdByDeploymentId(flowDeploymentId);
|
|
|
- tfCustomFlow.setFlowDefinitionId(processDefinitionId);
|
|
|
- tfCustomFlowService.updateById(tfCustomFlow);
|
|
|
+ FlowResult flowResult = null;
|
|
|
+ TFCustomFlow tfCustomFlow = null;
|
|
|
+ if (Objects.nonNull(flowDeploymentId)) {
|
|
|
+ String processDefinitionId = null;
|
|
|
+ tfCustomFlow = tfCustomFlowService.getOne(new QueryWrapper<TFCustomFlow>().lambda().eq(TFCustomFlow::getFlowDeploymentId, flowDeploymentId));
|
|
|
+ Optional.ofNullable(tfCustomFlow.getFlowProcessVar()).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程没有部署数据!"));
|
|
|
+ if (Objects.isNull(tfCustomFlow.getFlowDefinitionId())) {
|
|
|
+ processDefinitionId = activitiConsumerService.findProcessDefinitionIdByDeploymentId(flowDeploymentId);
|
|
|
+ tfCustomFlow.setFlowDefinitionId(processDefinitionId);
|
|
|
+ tfCustomFlowService.updateById(tfCustomFlow);
|
|
|
+ } else {
|
|
|
+ processDefinitionId = tfCustomFlow.getFlowDefinitionId();
|
|
|
+ }
|
|
|
+ flowResult = JSONObject.parseObject(tfCustomFlow.getFlowProcessVar(), FlowResult.class);
|
|
|
+ map = this.getFlowFormPropertie(flowResult, map, 1);
|
|
|
} else {
|
|
|
- processDefinitionId = tfCustomFlow.getFlowDefinitionId();
|
|
|
+ List<Task> taskList = null;
|
|
|
+ if (Objects.nonNull(flowId) && !Objects.equals(flowId, "")) {
|
|
|
+ taskList = taskService.createTaskQuery().processInstanceId(String.valueOf(flowId)).list();
|
|
|
+ } else if (Objects.nonNull(taskId) && !Objects.equals(taskId, "")) {
|
|
|
+ taskList = taskService.createTaskQuery().taskId(String.valueOf(taskId)).list();
|
|
|
+ }
|
|
|
+ if (!CollectionUtils.isEmpty(taskList)) {
|
|
|
+ if (Objects.isNull(flowId)) {
|
|
|
+ flowId = Long.parseLong(taskList.get(0).getProcessInstanceId());
|
|
|
+ }
|
|
|
+ TFCustomFlowEntity tfCustomFlowEntity = tfCustomFlowEntityService.getOne(new QueryWrapper<TFCustomFlowEntity>().lambda().eq(TFCustomFlowEntity::getFlowId, flowId));
|
|
|
+ Optional.ofNullable(tfCustomFlowEntity).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程没有实例数据!"));
|
|
|
+ tfCustomFlow = tfCustomFlowService.getById(tfCustomFlowEntity.gettFCustomFlowId());
|
|
|
+ Optional.ofNullable(tfCustomFlow.getFlowProcessVar()).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程没有部署数据!"));
|
|
|
+
|
|
|
+ flowResult = JSONObject.parseObject(tfCustomFlowEntity.getFlowProcessVar(), FlowResult.class);
|
|
|
+ LinkedHashMap<String, FlowTaskResult> setupMap = flowResult.getSetupMap();
|
|
|
+ for (Task task : taskList) {
|
|
|
+ FlowTaskResult currFlowTaskResult = GsonUtil.fromJson(GsonUtil.toJson(setupMap.get(task.getTaskDefinitionKey())), FlowTaskResult.class);
|
|
|
+ map = this.getFlowFormPropertie(flowResult, map, currFlowTaskResult.getSetup());
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- FlowResult flowResult = JSONObject.parseObject(tfCustomFlow.getFlowProcessVar(), FlowResult.class);
|
|
|
+ map.put(SystemConstant.FLOW_DEPLOYMENT_ID, tfCustomFlow.getFlowDeploymentId());
|
|
|
+ map.put(SystemConstant.ID, tfCustomFlow.getId());
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取表单属性
|
|
|
+ *
|
|
|
+ * @param flowResult
|
|
|
+ * @param map
|
|
|
+ * @param setup
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public Map<String, Object> getFlowFormPropertie(FlowResult flowResult, Map<String, Object> map, int setup) {
|
|
|
Map<String, FlowTaskResult> setupMap = flowResult.getSetupMap();
|
|
|
for (Map.Entry<String, FlowTaskResult> entry : setupMap.entrySet()) {
|
|
|
FlowTaskResult flowTaskResultTemp = GsonUtil.fromJson(GsonUtil.toJson(entry.getValue()), FlowTaskResult.class);
|
|
|
- if (flowTaskResultTemp.getSetup().intValue() == 1) {
|
|
|
+ if (flowTaskResultTemp.getSetup().intValue() == setup) {
|
|
|
map.put(SystemConstant.FORM_PROPERTIES, flowTaskResultTemp);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
- map.put(SystemConstant.FLOW_DEPLOYMENT_ID, flowDeploymentId);
|
|
|
- map.put(SystemConstant.ID, tfCustomFlow.getId());
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
-// @ApiOperation(value = "获取流程表单属性接口")
|
|
|
-// @RequestMapping(value = "/flow/formData", method = RequestMethod.POST)
|
|
|
-// @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
|
|
|
-// public Map<String, Object> getFlowFormData(@ApiParam(value = "流程id") @RequestParam(required = false) String flowId,
|
|
|
-// @ApiParam(value = "流程任务id") @RequestParam(required = false) String taskId) {
|
|
|
-//// List<Task> taskList = null;
|
|
|
-//// if (Objects.nonNull(flowId) && !Objects.equals(flowId, "")) {
|
|
|
-//// taskList = taskService.createTaskQuery().processInstanceId(flowId).list();
|
|
|
-//// } else if (Objects.nonNull(taskId) && !Objects.equals(taskId, "")) {
|
|
|
-//// taskList = taskService.createTaskQuery().taskId(taskId).list();
|
|
|
-//// }
|
|
|
-// Map<String, Object> varMap = new HashMap<>();
|
|
|
-//// if (!CollectionUtils.isEmpty(taskList)) {
|
|
|
-//// List<FormPropertyBean> formPropertyList = new LinkedList<>();
|
|
|
-//// for (Task t : taskList) {
|
|
|
-//// String flowTaskId = t.getId();
|
|
|
-//// String processInstanceId = t.getProcessInstanceId();
|
|
|
-//// Object o = formService.getRenderedTaskForm(flowTaskId);
|
|
|
-////// List<FormProperty> formProperties = taskFormData.getFormProperties();
|
|
|
-//// log.info("taskId:{},flowId:{}", flowTaskId, processInstanceId);
|
|
|
-//// if (Objects.nonNull(o)) {
|
|
|
-//// log.info("task formProperties:{}", JacksonUtil.parseJson(o));
|
|
|
-//// List<FlowFormWidgetResult> list = JSONArray.parseArray(o.toString(), FlowFormWidgetResult.class);
|
|
|
-//// formPropertyList.add(new FormPropertyBean(processInstanceId, flowTaskId, t.getAssignee(), list));
|
|
|
-//// }
|
|
|
-//// }
|
|
|
-//// varMap.put("formProperties", formPropertyList);
|
|
|
-//// }
|
|
|
-// return varMap;
|
|
|
-// }
|
|
|
-
|
|
|
@ApiOperation(value = "启动流程接口")
|
|
|
@RequestMapping(value = "/start/flow", method = RequestMethod.POST)
|
|
|
@Transactional
|
|
@@ -299,16 +311,16 @@ public class ActivitiFromHtmlController {
|
|
|
* @param map
|
|
|
* @param approvePass
|
|
|
*/
|
|
|
- protected void approvePass(FlowTaskResult currFlowTaskResult,
|
|
|
- Map<String, FlowTaskResult> setupMap,
|
|
|
- boolean multiInstance,
|
|
|
- Integer nrOfCompletedInstances,
|
|
|
- Integer nrOfInstances,
|
|
|
- TFFlowApprove tfFlowApprove,
|
|
|
- TFFlowLog tfFlowLog,
|
|
|
- FlowTaskResult nextFlowTaskResult,
|
|
|
- Map<String, Object> map,
|
|
|
- FlowApprovePassEnum approvePass) {
|
|
|
+ public void approvePass(FlowTaskResult currFlowTaskResult,
|
|
|
+ Map<String, FlowTaskResult> setupMap,
|
|
|
+ boolean multiInstance,
|
|
|
+ Integer nrOfCompletedInstances,
|
|
|
+ Integer nrOfInstances,
|
|
|
+ TFFlowApprove tfFlowApprove,
|
|
|
+ TFFlowLog tfFlowLog,
|
|
|
+ FlowTaskResult nextFlowTaskResult,
|
|
|
+ Map<String, Object> map,
|
|
|
+ FlowApprovePassEnum approvePass) {
|
|
|
if (multiInstance) {
|
|
|
map.computeIfAbsent(FlowApproveOperationEnum.REJECT.getId() + currFlowTaskResult.getSetup(), v -> 0);
|
|
|
}
|