diff --git a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/consumer/StandardWorkTicketConsumer.java b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/consumer/StandardWorkTicketConsumer.java index 30bfd68..71055ea 100644 --- a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/consumer/StandardWorkTicketConsumer.java +++ b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/consumer/StandardWorkTicketConsumer.java @@ -45,7 +45,7 @@ public class StandardWorkTicketConsumer implements IQueueConsume { //记录操作日志 WorkflowOperationLog regularWorkflowOperationLog = new WorkflowOperationLog(); - BeanUtils.copyProperties(response,regularWorkflowOperationLog); + BeanUtils.copyProperties(response, regularWorkflowOperationLog); if (ObjectUtils.isNotEmpty(regularWorkflowOperationLog)) { regularWorkflowOperationLog.setVariables(JSON.toJSONString(response.getVariables())); regularWorkflowOperationLog.setTakeId(response.getTaskId()); @@ -53,40 +53,29 @@ public class StandardWorkTicketConsumer implements IQueueConsume { regularWorkflowOperationLog.setIsOperationLog(true); regularWorkflowOperationLog.setProcessInstanceKey(response.getProcessInstanceId()); log.info("正在记录操作日志WorkflowOperationLog.... :{}", regularWorkflowOperationLog); - workflowOperationLogService.save(regularWorkflowOperationLog); } + try { + WorkflowQueue ticker = new WorkflowQueue(); + ticker.setProcessDefinitionKey(taskDefinitionKey); + //判断执行具体的实现类 + ProcessService processService = + ticketServiceList.stream().filter(item -> item.isWorkflowProcess(ticker)).findFirst().orElse(null); + if (ObjectUtils.isNotEmpty(processService)) { + //执行业务方法 + try { + processService.calculate(response); + } catch (Exception e) { + e.printStackTrace(); + //todo 业务出错误 做补偿 + log.error("业务出错,StandardWorkTicketConsumer: {}", e.getMessage()); + log.error("业务出错,StandardWorkTicketConsumer: {} ", response); + regularWorkflowOperationLog.setIsOperationLog(false);//调用消费方抛出异常 - - WorkflowQueue ticker = new WorkflowQueue(); - ticker.setProcessDefinitionKey(taskDefinitionKey); - //判断执行具体的实现类 - ProcessService processService = - ticketServiceList.stream().filter(item -> item.isWorkflowProcess(ticker)).findFirst().orElse(null); - if (ObjectUtils.isNotEmpty(processService)) { - //执行业务方法 - try { - processService.calculate(response); - } catch (Exception e) { - e.printStackTrace(); - //todo 业务出错误 做补偿 - log.error("业务出错,StandardWorkTicketConsumer: {}", e.getMessage()); - log.error("业务出错,StandardWorkTicketConsumer: {} ", response); - WorkflowOperationLog workflowOperationLog = new WorkflowOperationLog(); - BeanUtils.copyProperties(response,workflowOperationLog); - if (ObjectUtils.isNotEmpty(workflowOperationLog)) { - workflowOperationLog.setVariables(JSON.toJSONString(response.getVariables())); - workflowOperationLog.setTakeId(response.getTaskId()); - workflowOperationLog.setTakeName(response.getTaskName()); - workflowOperationLog.setIsOperationLog(false);//没保存成功 - workflowOperationLog.setProcessInstanceKey(response.getProcessInstanceId()); - log.info("正在保存到hzims_workflow_operation_log.... :{}", workflowOperationLog); - workflowOperationLogService.save(workflowOperationLog); } - } + } finally { + workflowOperationLogService.save(regularWorkflowOperationLog); } - - } }