Browse Source

middle消费日志保存修正

zhongwei
ty 12 months ago
parent
commit
c1c1e6bf0f
  1. 49
      hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/consumer/StandardWorkTicketConsumer.java

49
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(); WorkflowOperationLog regularWorkflowOperationLog = new WorkflowOperationLog();
BeanUtils.copyProperties(response,regularWorkflowOperationLog); BeanUtils.copyProperties(response, regularWorkflowOperationLog);
if (ObjectUtils.isNotEmpty(regularWorkflowOperationLog)) { if (ObjectUtils.isNotEmpty(regularWorkflowOperationLog)) {
regularWorkflowOperationLog.setVariables(JSON.toJSONString(response.getVariables())); regularWorkflowOperationLog.setVariables(JSON.toJSONString(response.getVariables()));
regularWorkflowOperationLog.setTakeId(response.getTaskId()); regularWorkflowOperationLog.setTakeId(response.getTaskId());
@ -53,40 +53,29 @@ public class StandardWorkTicketConsumer implements IQueueConsume {
regularWorkflowOperationLog.setIsOperationLog(true); regularWorkflowOperationLog.setIsOperationLog(true);
regularWorkflowOperationLog.setProcessInstanceKey(response.getProcessInstanceId()); regularWorkflowOperationLog.setProcessInstanceKey(response.getProcessInstanceId());
log.info("正在记录操作日志WorkflowOperationLog.... :{}", regularWorkflowOperationLog); 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);
} }
} }
} }

Loading…
Cancel
Save