From c1c1e6bf0f925bac818e4987d56a2aae50ab67e5 Mon Sep 17 00:00:00 2001 From: ty <1577900710@qq.com> Date: Fri, 15 Dec 2023 17:31:09 +0800 Subject: [PATCH] =?UTF-8?q?middle=E6=B6=88=E8=B4=B9=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E4=BF=9D=E5=AD=98=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../consumer/StandardWorkTicketConsumer.java | 49 +++++++++------------- 1 file changed, 19 insertions(+), 30 deletions(-) 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); } - - } }