Compare commits

...

7 Commits

21 changed files with 203 additions and 288 deletions

View File

@ -19,8 +19,9 @@ public class MqLogEvent extends ApplicationEvent {
private String messageBody; private String messageBody;
private String traceId; private String traceId;
private MqLogEventType eventType; private MqLogEventType eventType;
private String targetType;
public MqLogEvent(String uniqueId, String messageId, String mqTag, String mqKey, String messageBody, String traceId, MqLogEventType eventType) { public MqLogEvent(String uniqueId, String messageId, String mqTag, String mqKey, String messageBody, String traceId, MqLogEventType eventType, String targetType) {
super(uniqueId); super(uniqueId);
this.uniqueId = uniqueId; this.uniqueId = uniqueId;
this.messageId = messageId; this.messageId = messageId;
@ -29,6 +30,7 @@ public class MqLogEvent extends ApplicationEvent {
this.messageBody = messageBody; this.messageBody = messageBody;
this.traceId = traceId; this.traceId = traceId;
this.eventType = eventType; this.eventType = eventType;
this.targetType = targetType;
} }
public String getUniqueId() { public String getUniqueId() {
@ -86,4 +88,12 @@ public class MqLogEvent extends ApplicationEvent {
public void setEventType(MqLogEventType eventType) { public void setEventType(MqLogEventType eventType) {
this.eventType = eventType; this.eventType = eventType;
} }
public String getTargetType() {
return targetType;
}
public void setTargetType(String targetType) {
this.targetType = targetType;
}
} }

View File

@ -6,6 +6,7 @@ import cn.axzo.workflow.core.service.ExtAxMqLogService;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import lombok.SneakyThrows; import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.ListUtils;
import org.springframework.context.ApplicationListener; import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -34,6 +35,10 @@ public class MqLogListener implements ApplicationListener<MqLogEvent> {
if (!refreshProperties.getMqLogEnable()) { if (!refreshProperties.getMqLogEnable()) {
return; return;
} }
if (!ListUtils.emptyIfNull(refreshProperties.getSupportedMqLogProcessDefinitionKeys()).contains(event.getTargetType())) {
log.info("mq_log_process_definition_not_found: {}", event.getTargetType());
return;
}
switch (event.getEventType()) { switch (event.getEventType()) {
case INSERT: case INSERT:
insert(buildMqLogEntity(event)); insert(buildMqLogEntity(event));

View File

@ -86,7 +86,7 @@ public class RocketMqEventConfiguration {
MqLogEvent mqLogEvent = new MqLogEvent(event.getEventId(), null, MqLogEvent mqLogEvent = new MqLogEvent(event.getEventId(), null,
event.getEventName(), event.getShardingKey(), event.getEventName(), event.getShardingKey(),
event.toPrettyJsonString(), TraceUtils.getOrCreateTraceId(), event.toPrettyJsonString(), TraceUtils.getOrCreateTraceId(),
MqLogEventType.INSERT); MqLogEventType.INSERT, event.getTargetType());
log.info("mq_send_Before: {}, uniqueId: {}", event.getShardingKey(), event.getEventId()); log.info("mq_send_Before: {}, uniqueId: {}", event.getShardingKey(), event.getEventId());
applicationEventPublisher.publishEvent(mqLogEvent); applicationEventPublisher.publishEvent(mqLogEvent);
}; };
@ -105,7 +105,7 @@ public class RocketMqEventConfiguration {
MqLogEvent mqLogEvent = new MqLogEvent(event.getEventId(), messageId, MqLogEvent mqLogEvent = new MqLogEvent(event.getEventId(), messageId,
event.getEventName(), event.getShardingKey(), event.getEventName(), event.getShardingKey(),
event.toPrettyJsonString(), TraceUtils.getOrCreateTraceId(), event.toPrettyJsonString(), TraceUtils.getOrCreateTraceId(),
MqLogEventType.UPDATE); MqLogEventType.UPDATE, event.getTargetType());
log.info("mq_send_after: {}, uniqueId: {}, messageId: {}", event.getShardingKey(), event.getEventId(), messageId); log.info("mq_send_after: {}, uniqueId: {}, messageId: {}", event.getShardingKey(), event.getEventId(), messageId);
applicationEventPublisher.publishEvent(mqLogEvent); applicationEventPublisher.publishEvent(mqLogEvent);
}; };
@ -122,7 +122,7 @@ public class RocketMqEventConfiguration {
return (event, context) -> { return (event, context) -> {
MqLogEvent mqLog = new MqLogEvent(event.getEventId(), null, event.getEventName(), MqLogEvent mqLog = new MqLogEvent(event.getEventId(), null, event.getEventName(),
event.getShardingKey(), event.toPrettyJsonString(), TraceUtils.getOrCreateTraceId(), event.getShardingKey(), event.toPrettyJsonString(), TraceUtils.getOrCreateTraceId(),
MqLogEventType.DELETE); MqLogEventType.DELETE, event.getTargetType());
log.info("mq_transaction_rollback: {}, uniqueId: {}", event.getShardingKey(), event.getEventId()); log.info("mq_transaction_rollback: {}, uniqueId: {}", event.getShardingKey(), event.getEventId());
applicationEventPublisher.publishEvent(mqLog); applicationEventPublisher.publishEvent(mqLog);
}; };

View File

@ -26,6 +26,8 @@ public class SupportRefreshProperties {
@Value("${workflow.mqLog.enable: false}") @Value("${workflow.mqLog.enable: false}")
private Boolean mqLogEnable; private Boolean mqLogEnable;
@Value("${workflow.mqLog.supportedProcessDefinitionKeys:}")
private List<String> supportedMqLogProcessDefinitionKeys;
@Value("${workflow.apiLog.filterApiType:}") @Value("${workflow.apiLog.filterApiType:}")
private String filterApiType; private String filterApiType;
@ -110,4 +112,10 @@ public class SupportRefreshProperties {
@Value("${workflow.processLogHtmlUrl:https://taskflow-web.axzo.cn/#/document/log?processInstanceId=%s&personId=%s}") @Value("${workflow.processLogHtmlUrl:https://taskflow-web.axzo.cn/#/document/log?processInstanceId=%s&personId=%s}")
private String processLogHtmlUrl; private String processLogHtmlUrl;
/**
* 需要过滤表单字段的业务 ID
*/
@Value("${workflow.filterFormFieldProcessDefinitionKeys:}")
private List<String> filterFormFieldProcessDefinitionKeys;
} }

View File

@ -2,7 +2,12 @@ package cn.axzo.workflow.core.listener;
import cn.axzo.workflow.common.constant.BpmnConstants; import cn.axzo.workflow.common.constant.BpmnConstants;
import cn.axzo.workflow.core.common.context.OperationContext; import cn.axzo.workflow.core.common.context.OperationContext;
import cn.axzo.workflow.core.conf.SupportRefreshProperties;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import lombok.extern.slf4j.Slf4j;
import org.flowable.form.api.FormInfo;
import org.flowable.form.api.FormRepositoryService;
import org.flowable.form.model.SimpleFormModel;
import org.slf4j.MDC; import org.slf4j.MDC;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
@ -11,6 +16,7 @@ import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects;
import java.util.Set; import java.util.Set;
import static cn.azxo.framework.common.constatns.Constants.CTX_LOG_ID_MDC; import static cn.azxo.framework.common.constatns.Constants.CTX_LOG_ID_MDC;
@ -21,9 +27,17 @@ import static cn.azxo.framework.common.constatns.Constants.CTX_LOG_ID_MDC;
* @author wangli * @author wangli
* @since 2024/4/9 14:21 * @since 2024/4/9 14:21
*/ */
@Slf4j
public abstract class AbstractBpmnEventListener<T extends OperationContext> implements OperationContext { public abstract class AbstractBpmnEventListener<T extends OperationContext> implements OperationContext {
private T context; private T context;
protected final FormRepositoryService formRepositoryService;
private final SupportRefreshProperties refreshProperties;
protected AbstractBpmnEventListener(FormRepositoryService formRepositoryService, SupportRefreshProperties refreshProperties) {
this.formRepositoryService = formRepositoryService;
this.refreshProperties = refreshProperties;
}
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
@ -52,6 +66,29 @@ public abstract class AbstractBpmnEventListener<T extends OperationContext> impl
return processDefinitionId.split(":")[0]; return processDefinitionId.split(":")[0];
} }
protected SimpleFormModel getSimpleFormModel(String processDefinitionKey, String tenantId) {
try {
if (!refreshProperties.getFilterFormFieldProcessDefinitionKeys().contains(processDefinitionKey)) {
return new SimpleFormModel();
}
FormInfo formInfo = formRepositoryService.getFormModelByKey(processDefinitionKey, tenantId, true);
if (Objects.isNull(formInfo)) {
return new SimpleFormModel();
} else {
return (SimpleFormModel) formInfo.getFormModel();
}
} catch (Exception e) {
log.warn("没有找到对应业务 ID 的表单模型: {}", e.getMessage());
return new SimpleFormModel();
}
}
public Map<String, Object> removeBpmnConstantsVariables(Map<String, Object> originVariables, String processDefinitionKey, String tenantId) {
SimpleFormModel simpleFormModel = getSimpleFormModel(processDefinitionKey, tenantId);
return removeBpmnConstantsVariables(originVariables, simpleFormModel.allFieldsAsMap().keySet());
}
/** /**
* 移除一些业务不需要关心的变量 * 移除一些业务不需要关心的变量
* *
@ -66,7 +103,27 @@ public abstract class AbstractBpmnEventListener<T extends OperationContext> impl
BpmnConstants.INTERNAL_TASK_RELATION_ASSIGNEE_INFO, BpmnConstants.INTERNAL_TASK_RELATION_ASSIGNEE_INFO,
BpmnConstants.INTERNAL_ACTIVITY_RELATION_ASSIGNEE_LIST_INFO_SNAPSHOT, BpmnConstants.INTERNAL_ACTIVITY_RELATION_ASSIGNEE_LIST_INFO_SNAPSHOT,
BpmnConstants.TASK_COMPLETE_OPERATION_TYPE, BpmnConstants.TASK_COMPLETE_OPERATION_TYPE,
BpmnConstants.INTERNAL_TASK_RELATION_ASSIGNEE_LIST_INFO BpmnConstants.INTERNAL_TASK_RELATION_ASSIGNEE_LIST_INFO,
BpmnConstants.BIZ_NODE_ALTER,
BpmnConstants.INITIATOR_SPECIFY,
BpmnConstants.INTERNAL_PROCESS_BIZ_TYPE,
BpmnConstants.INTERNAL_PROCESS_AGENT,
BpmnConstants.PROCESS_OWNERSHIP_APPLICATION,
BpmnConstants.SIGNATURE_COLLECTION,
BpmnConstants.INTERNAL_PROCESS_WORKSPACE_TYPE,
BpmnConstants.WORKFLOW_ENGINE_VERSION,
BpmnConstants.BIZ_ORG_RELATION,
BpmnConstants.TASK_LOG_NODE_HAS_BEEN_HIDDEN,
BpmnConstants.INTERNAL_END_USER_ID,
BpmnConstants.INTERNAL_END_TENANT_ID,
BpmnConstants.INTERNAL_END_USER_NAME,
BpmnConstants.INTERNAL_DELETE_PROCESS_FLAG,
BpmnConstants.INTERNAL_PROCESS_TYPE_CANCEL,
BpmnConstants.INTERNAL_PROCESS_TYPE_REJECT,
BpmnConstants.INTERNAL_SPECIFY_NEXT_APPROVER,
BpmnConstants.NUMBER_OF_INSTANCES,
BpmnConstants.MULTI_INSTANCE_LOOP_COUNTER,
BpmnConstants.CLOSE_PROCESS_ASSIGNER
); );
if (!CollectionUtils.isEmpty(removeVariableKey)) { if (!CollectionUtils.isEmpty(removeVariableKey)) {
removeVariableKey.forEach(originVariables::remove); removeVariableKey.forEach(originVariables::remove);
@ -79,4 +136,6 @@ public abstract class AbstractBpmnEventListener<T extends OperationContext> impl
.noneMatch(prefix -> entry.getKey().startsWith(prefix))) .noneMatch(prefix -> entry.getKey().startsWith(prefix)))
.collect(HashMap::new, (m, e) -> m.put(e.getKey(), e.getValue()), HashMap::putAll); .collect(HashMap::new, (m, e) -> m.put(e.getKey(), e.getValue()), HashMap::putAll);
} }
} }

View File

@ -9,7 +9,6 @@ import cn.axzo.workflow.core.conf.SupportRefreshProperties;
import cn.axzo.workflow.core.engine.tx.listener.AddTimerJobTransactionListener; import cn.axzo.workflow.core.engine.tx.listener.AddTimerJobTransactionListener;
import cn.axzo.workflow.core.listener.AbstractBpmnEventListener; import cn.axzo.workflow.core.listener.AbstractBpmnEventListener;
import cn.axzo.workflow.core.listener.BpmnActivityEventListener; import cn.axzo.workflow.core.listener.BpmnActivityEventListener;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.ListUtils; import org.apache.commons.collections4.ListUtils;
import org.flowable.bpmn.model.BpmnModel; import org.flowable.bpmn.model.BpmnModel;
@ -21,10 +20,12 @@ import org.flowable.engine.delegate.DelegateExecution;
import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl; import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl;
import org.flowable.engine.impl.util.CommandContextUtil; import org.flowable.engine.impl.util.CommandContextUtil;
import org.flowable.engine.impl.util.ProcessDefinitionUtil; import org.flowable.engine.impl.util.ProcessDefinitionUtil;
import org.flowable.form.api.FormRepositoryService;
import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.Scope;
import org.springframework.core.Ordered; import org.springframework.core.Ordered;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.Objects; import java.util.Objects;
import static cn.axzo.workflow.common.constant.BpmnConstants.BIZ_NODE_ALTER; import static cn.axzo.workflow.common.constant.BpmnConstants.BIZ_NODE_ALTER;
@ -40,9 +41,13 @@ import static cn.axzo.workflow.common.constant.BpmnConstants.BIZ_NODE_ALTER;
@Slf4j @Slf4j
@Component @Component
@Scope("prototype") @Scope("prototype")
@AllArgsConstructor
public class InternalBpmnActivityEventListener_lo_Listener extends AbstractBpmnEventListener<ActivityOperationContext> implements BpmnActivityEventListener, Ordered { public class InternalBpmnActivityEventListener_lo_Listener extends AbstractBpmnEventListener<ActivityOperationContext> implements BpmnActivityEventListener, Ordered {
private final SupportRefreshProperties refreshProperties; @Resource
private SupportRefreshProperties refreshProperties;
public InternalBpmnActivityEventListener_lo_Listener(FormRepositoryService formRepositoryService, SupportRefreshProperties refreshProperties) {
super(formRepositoryService, refreshProperties);
}
@Override @Override
public int getOrder() { public int getOrder() {

View File

@ -3,20 +3,22 @@ package cn.axzo.workflow.core.listener.impl;
import cn.axzo.workflow.common.enums.BpmnProcessInstanceResultEnum; import cn.axzo.workflow.common.enums.BpmnProcessInstanceResultEnum;
import cn.axzo.workflow.common.model.request.bpmn.task.BpmnTaskDelegateAssigner; import cn.axzo.workflow.common.model.request.bpmn.task.BpmnTaskDelegateAssigner;
import cn.axzo.workflow.core.common.context.TaskOperationContext; import cn.axzo.workflow.core.common.context.TaskOperationContext;
import cn.axzo.workflow.core.conf.SupportRefreshProperties;
import cn.axzo.workflow.core.engine.event.ExtTaskInstCreateEvent; import cn.axzo.workflow.core.engine.event.ExtTaskInstCreateEvent;
import cn.axzo.workflow.core.engine.event.ExtTaskInstUpdateEvent; import cn.axzo.workflow.core.engine.event.ExtTaskInstUpdateEvent;
import cn.axzo.workflow.core.listener.AbstractBpmnEventListener; import cn.axzo.workflow.core.listener.AbstractBpmnEventListener;
import cn.axzo.workflow.core.listener.BpmnTaskEventListener; import cn.axzo.workflow.core.listener.BpmnTaskEventListener;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.flowable.common.engine.api.delegate.event.FlowableEventDispatcher; import org.flowable.common.engine.api.delegate.event.FlowableEventDispatcher;
import org.flowable.engine.RuntimeService; import org.flowable.engine.RuntimeService;
import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl; import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl;
import org.flowable.engine.impl.util.CommandContextUtil; import org.flowable.engine.impl.util.CommandContextUtil;
import org.flowable.form.api.FormRepositoryService;
import org.flowable.task.service.delegate.DelegateTask; import org.flowable.task.service.delegate.DelegateTask;
import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.Objects; import java.util.Objects;
import static cn.axzo.workflow.common.constant.BpmnConstants.INTERNAL_INITIATOR; import static cn.axzo.workflow.common.constant.BpmnConstants.INTERNAL_INITIATOR;
@ -35,9 +37,13 @@ import static cn.axzo.workflow.common.enums.BpmnProcessInstanceResultEnum.PROCES
@Slf4j @Slf4j
@Component @Component
@Scope("prototype") @Scope("prototype")
@AllArgsConstructor
public class InternalExtAxTaskInstEvent_lo_Listener extends AbstractBpmnEventListener<TaskOperationContext> implements BpmnTaskEventListener { public class InternalExtAxTaskInstEvent_lo_Listener extends AbstractBpmnEventListener<TaskOperationContext> implements BpmnTaskEventListener {
private final RuntimeService runtimeService; @Resource
private RuntimeService runtimeService;
public InternalExtAxTaskInstEvent_lo_Listener(FormRepositoryService formRepositoryService, SupportRefreshProperties refreshProperties) {
super(formRepositoryService, refreshProperties);
}
@Override @Override
public int getOrder() { public int getOrder() {

View File

@ -6,6 +6,7 @@ import cn.axzo.workflow.common.model.dto.VariableObjectDTO;
import cn.axzo.workflow.common.model.request.bpmn.BpmnSignConf; import cn.axzo.workflow.common.model.request.bpmn.BpmnSignConf;
import cn.axzo.workflow.core.common.context.ActivityOperationContext; import cn.axzo.workflow.core.common.context.ActivityOperationContext;
import cn.axzo.workflow.core.common.utils.BpmnMetaParserHelper; import cn.axzo.workflow.core.common.utils.BpmnMetaParserHelper;
import cn.axzo.workflow.core.conf.SupportRefreshProperties;
import cn.axzo.workflow.core.listener.AbstractBpmnEventListener; import cn.axzo.workflow.core.listener.AbstractBpmnEventListener;
import cn.axzo.workflow.core.listener.BpmnActivityEventListener; import cn.axzo.workflow.core.listener.BpmnActivityEventListener;
import cn.axzo.workflow.core.repository.entity.ExtAxProcessSign; import cn.axzo.workflow.core.repository.entity.ExtAxProcessSign;
@ -17,6 +18,7 @@ import org.flowable.engine.delegate.DelegateExecution;
import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl; import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl;
import org.flowable.engine.impl.util.CommandContextUtil; import org.flowable.engine.impl.util.CommandContextUtil;
import org.flowable.engine.impl.util.ProcessDefinitionUtil; import org.flowable.engine.impl.util.ProcessDefinitionUtil;
import org.flowable.form.api.FormRepositoryService;
import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.Scope;
import org.springframework.core.Ordered; import org.springframework.core.Ordered;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -43,6 +45,10 @@ public class OperationFileArchiveActivityEvent_101_Listener extends AbstractBpmn
@Resource @Resource
private WpsUtil wpsUtil; private WpsUtil wpsUtil;
public OperationFileArchiveActivityEvent_101_Listener(FormRepositoryService formRepositoryService, SupportRefreshProperties refreshProperties) {
super(formRepositoryService, refreshProperties);
}
@Override @Override
public int getOrder() { public int getOrder() {
return Integer.MIN_VALUE + 101; return Integer.MIN_VALUE + 101;

View File

@ -8,6 +8,7 @@ import cn.axzo.workflow.common.model.request.bpmn.task.ExtHiTaskSearchDTO;
import cn.axzo.workflow.common.model.response.mq.ProcessActivityDTO; import cn.axzo.workflow.common.model.response.mq.ProcessActivityDTO;
import cn.axzo.workflow.core.common.context.ActivityOperationContext; import cn.axzo.workflow.core.common.context.ActivityOperationContext;
import cn.axzo.workflow.core.common.utils.BpmnMetaParserHelper; import cn.axzo.workflow.core.common.utils.BpmnMetaParserHelper;
import cn.axzo.workflow.core.conf.SupportRefreshProperties;
import cn.axzo.workflow.core.engine.event.BizCallbackEvent; import cn.axzo.workflow.core.engine.event.BizCallbackEvent;
import cn.axzo.workflow.core.engine.event.BizSpecifyAssigneeEvent; import cn.axzo.workflow.core.engine.event.BizSpecifyAssigneeEvent;
import cn.axzo.workflow.core.listener.AbstractBpmnEventListener; import cn.axzo.workflow.core.listener.AbstractBpmnEventListener;
@ -20,9 +21,7 @@ import org.flowable.engine.RepositoryService;
import org.flowable.engine.RuntimeService; import org.flowable.engine.RuntimeService;
import org.flowable.engine.delegate.DelegateExecution; import org.flowable.engine.delegate.DelegateExecution;
import org.flowable.engine.runtime.ProcessInstance; import org.flowable.engine.runtime.ProcessInstance;
import org.flowable.form.api.FormInfo;
import org.flowable.form.api.FormRepositoryService; import org.flowable.form.api.FormRepositoryService;
import org.flowable.form.model.SimpleFormModel;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.Scope;
import org.springframework.core.Ordered; import org.springframework.core.Ordered;
@ -73,8 +72,10 @@ public class RocketMqBpmActivityEvent_100_Listener extends AbstractBpmnEventList
private EventProducer<?> eventProducer; private EventProducer<?> eventProducer;
@Value("${sendMq:true}") @Value("${sendMq:true}")
private Boolean sendMQ; private Boolean sendMQ;
@Resource
private FormRepositoryService formRepositoryService; public RocketMqBpmActivityEvent_100_Listener(FormRepositoryService formRepositoryService, SupportRefreshProperties refreshProperties) {
super(formRepositoryService, refreshProperties);
}
@Override @Override
public void onStart(DelegateExecution execution) { public void onStart(DelegateExecution execution) {
@ -180,29 +181,11 @@ public class RocketMqBpmActivityEvent_100_Listener extends AbstractBpmnEventList
ProcessInstance processInstance = getContext().getProcessInstance(() -> ProcessInstance processInstance = getContext().getProcessInstance(() ->
runtimeService.createProcessInstanceQuery().processInstanceId(execution.getProcessInstanceId()) runtimeService.createProcessInstanceQuery().processInstanceId(execution.getProcessInstanceId())
.includeProcessVariables().singleResult()); .includeProcessVariables().singleResult());
SimpleFormModel formModel = getContext().getFormModel(() -> {
try {
if (!Objects.equals("gongrendanganqianshu", processInstance.getProcessDefinitionKey()) &&
!Objects.equals("jinengpeixun", processInstance.getProcessDefinitionKey()) &&
!Objects.equals("anquanjiaoyu", processInstance.getProcessDefinitionKey())) {
return new SimpleFormModel();
}
FormInfo formInfo = formRepositoryService.getFormModelByKey(processInstance.getProcessDefinitionKey(), processInstance.getTenantId(), true);
if (Objects.isNull(formInfo)) {
return new SimpleFormModel();
} else {
return (SimpleFormModel) formInfo.getFormModel();
}
} catch (Exception e) {
log.warn("没有找到对应业务 ID 的表单模型: {}", e.getMessage());
return new SimpleFormModel();
}
});
if (Objects.nonNull(processInstance)) { if (Objects.nonNull(processInstance)) {
dto.setProcessDefinitionKey(processInstance.getProcessDefinitionKey()); dto.setProcessDefinitionKey(processInstance.getProcessDefinitionKey());
dto.setBusinessKey(processInstance.getBusinessKey()); dto.setBusinessKey(processInstance.getBusinessKey());
dto.setVariables(removeBpmnConstantsVariables(processInstance.getProcessVariables(), formModel.allFieldsAsMap().keySet())); dto.setVariables(removeBpmnConstantsVariables(processInstance.getProcessVariables(), processInstance.getProcessDefinitionKey(), processInstance.getTenantId()));
dto.setWorkflowEngineVersion(String.valueOf(processInstance.getProcessVariables() dto.setWorkflowEngineVersion(String.valueOf(processInstance.getProcessVariables()
.getOrDefault(WORKFLOW_ENGINE_VERSION, FLOW_SERVER_VERSION_121))); .getOrDefault(WORKFLOW_ENGINE_VERSION, FLOW_SERVER_VERSION_121)));
} else { } else {

View File

@ -11,6 +11,7 @@ import cn.axzo.workflow.common.model.response.bpmn.process.BpmnProcessInstanceVO
import cn.axzo.workflow.common.model.response.mq.MessagePushDTO; import cn.axzo.workflow.common.model.response.mq.MessagePushDTO;
import cn.axzo.workflow.core.common.context.NoticeOperationContext; import cn.axzo.workflow.core.common.context.NoticeOperationContext;
import cn.axzo.workflow.core.common.utils.BpmnMetaParserHelper; import cn.axzo.workflow.core.common.utils.BpmnMetaParserHelper;
import cn.axzo.workflow.core.conf.SupportRefreshProperties;
import cn.axzo.workflow.core.engine.cmd.helper.CustomTaskHelper; import cn.axzo.workflow.core.engine.cmd.helper.CustomTaskHelper;
import cn.axzo.workflow.core.engine.event.MessagePushEvent; import cn.axzo.workflow.core.engine.event.MessagePushEvent;
import cn.axzo.workflow.core.engine.event.MessagePushEventImpl; import cn.axzo.workflow.core.engine.event.MessagePushEventImpl;
@ -19,7 +20,6 @@ import cn.axzo.workflow.core.listener.BpmnMessagePushEventListener;
import cn.axzo.workflow.core.service.BpmnProcessInstanceService; import cn.axzo.workflow.core.service.BpmnProcessInstanceService;
import cn.axzo.workflow.core.service.converter.BpmnHistoricTaskInstanceConverter; import cn.axzo.workflow.core.service.converter.BpmnHistoricTaskInstanceConverter;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.flowable.bpmn.model.Process; import org.flowable.bpmn.model.Process;
import org.flowable.engine.HistoryService; import org.flowable.engine.HistoryService;
@ -27,9 +27,7 @@ import org.flowable.engine.RuntimeService;
import org.flowable.engine.TaskService; import org.flowable.engine.TaskService;
import org.flowable.engine.impl.util.CommandContextUtil; import org.flowable.engine.impl.util.CommandContextUtil;
import org.flowable.engine.impl.util.ProcessDefinitionUtil; import org.flowable.engine.impl.util.ProcessDefinitionUtil;
import org.flowable.form.api.FormInfo;
import org.flowable.form.api.FormRepositoryService; import org.flowable.form.api.FormRepositoryService;
import org.flowable.form.model.SimpleFormModel;
import org.flowable.task.api.history.HistoricTaskInstance; import org.flowable.task.api.history.HistoricTaskInstance;
import org.flowable.task.service.impl.persistence.entity.TaskEntity; import org.flowable.task.service.impl.persistence.entity.TaskEntity;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
@ -44,31 +42,17 @@ import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
import static cn.axzo.workflow.common.constant.BpmnConstants.BIZ_ORG_RELATION;
import static cn.axzo.workflow.common.constant.BpmnConstants.INTERNAL_ACTIVITY_RELATION_ASSIGNEE_LIST_INFO_SNAPSHOT; import static cn.axzo.workflow.common.constant.BpmnConstants.INTERNAL_ACTIVITY_RELATION_ASSIGNEE_LIST_INFO_SNAPSHOT;
import static cn.axzo.workflow.common.constant.BpmnConstants.INTERNAL_DELETE_PROCESS_FLAG;
import static cn.axzo.workflow.common.constant.BpmnConstants.INTERNAL_END_TENANT_ID;
import static cn.axzo.workflow.common.constant.BpmnConstants.INTERNAL_END_USER_ID;
import static cn.axzo.workflow.common.constant.BpmnConstants.INTERNAL_END_USER_NAME;
import static cn.axzo.workflow.common.constant.BpmnConstants.INTERNAL_INITIATOR; import static cn.axzo.workflow.common.constant.BpmnConstants.INTERNAL_INITIATOR;
import static cn.axzo.workflow.common.constant.BpmnConstants.INTERNAL_PROCESS_TYPE_CANCEL;
import static cn.axzo.workflow.common.constant.BpmnConstants.INTERNAL_PROCESS_TYPE_REJECT;
import static cn.axzo.workflow.common.constant.BpmnConstants.INTERNAL_SPECIFY_NEXT_APPROVER;
import static cn.axzo.workflow.common.constant.BpmnConstants.INTERNAL_TASK_RELATION_ASSIGNEE_INFO;
import static cn.axzo.workflow.common.constant.BpmnConstants.INTERNAL_TASK_RELATION_ASSIGNEE_LIST_INFO;
import static cn.axzo.workflow.common.constant.BpmnConstants.MQ_ASSIGNER_BATCH_SIZE; import static cn.axzo.workflow.common.constant.BpmnConstants.MQ_ASSIGNER_BATCH_SIZE;
import static cn.axzo.workflow.common.constant.BpmnConstants.MQ_OWNERSHIP_APPLICATION; import static cn.axzo.workflow.common.constant.BpmnConstants.MQ_OWNERSHIP_APPLICATION;
import static cn.axzo.workflow.common.constant.BpmnConstants.MQ_OWNERSHIP_PROCESS_DEFINITION_KEY; import static cn.axzo.workflow.common.constant.BpmnConstants.MQ_OWNERSHIP_PROCESS_DEFINITION_KEY;
import static cn.axzo.workflow.common.constant.BpmnConstants.MULTI_INSTANCE_LOOP_COUNTER;
import static cn.axzo.workflow.common.constant.BpmnConstants.NUMBER_OF_INSTANCES;
import static cn.axzo.workflow.common.constant.BpmnConstants.PROCESS_OWNERSHIP_APPLICATION; import static cn.axzo.workflow.common.constant.BpmnConstants.PROCESS_OWNERSHIP_APPLICATION;
import static cn.axzo.workflow.common.constant.BpmnConstants.SUPPORT_UPGRADE_VARIABLE; import static cn.axzo.workflow.common.constant.BpmnConstants.SUPPORT_UPGRADE_VARIABLE;
import static cn.axzo.workflow.common.constant.BpmnConstants.TASK_COMPLETE_OPERATION_TYPE;
import static cn.axzo.workflow.common.constant.VariableConstants.VAR_ACTIVITY_ID; import static cn.axzo.workflow.common.constant.VariableConstants.VAR_ACTIVITY_ID;
import static cn.axzo.workflow.common.constant.VariableConstants.VAR_ACTIVITY_NAME; import static cn.axzo.workflow.common.constant.VariableConstants.VAR_ACTIVITY_NAME;
import static cn.axzo.workflow.common.constant.VariableConstants.VAR_BUSINESS_KEY; import static cn.axzo.workflow.common.constant.VariableConstants.VAR_BUSINESS_KEY;
@ -122,26 +106,11 @@ public class RocketMqMessagePushEventListener extends AbstractBpmnEventListener<
private String serviceVersion; private String serviceVersion;
@Value("${workflow.noticeTemplateCode}") @Value("${workflow.noticeTemplateCode}")
private String noticeTemplateCode; private String noticeTemplateCode;
@Resource
private FormRepositoryService formRepositoryService;
private static final List<String> REMOVE_KEYS = Lists.newArrayList(
INTERNAL_INITIATOR, public RocketMqMessagePushEventListener(FormRepositoryService formRepositoryService, SupportRefreshProperties refreshProperties) {
INTERNAL_END_USER_ID, super(formRepositoryService, refreshProperties);
INTERNAL_END_TENANT_ID, }
INTERNAL_END_USER_NAME,
INTERNAL_DELETE_PROCESS_FLAG,
INTERNAL_PROCESS_TYPE_CANCEL,
INTERNAL_PROCESS_TYPE_REJECT,
INTERNAL_SPECIFY_NEXT_APPROVER,
BIZ_ORG_RELATION,
INTERNAL_TASK_RELATION_ASSIGNEE_LIST_INFO,
INTERNAL_TASK_RELATION_ASSIGNEE_INFO,
INTERNAL_ACTIVITY_RELATION_ASSIGNEE_LIST_INFO_SNAPSHOT,
NUMBER_OF_INSTANCES,
MULTI_INSTANCE_LOOP_COUNTER,
TASK_COMPLETE_OPERATION_TYPE
);
@Override @Override
public void onNotice(MessagePushEvent event) { public void onNotice(MessagePushEvent event) {
@ -411,43 +380,8 @@ public class RocketMqMessagePushEventListener extends AbstractBpmnEventListener<
} }
} }
// 传递业务的参数 variables.putAll(removeBpmnConstantsVariables(originVariables, processInstance.getProcessDefinitionKey(), processInstance.getTenantId()));
REMOVE_KEYS.forEach(originVariables::remove);
log.info("流程实例的参数: {}", JSONUtil.toJsonStr(originVariables));
if (CollectionUtils.isEmpty(originVariables)) {
return variables;
}
Iterator<Map.Entry<String, Object>> iterator = originVariables.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry<String, Object> entry = iterator.next();
REMOVE_KEYS.forEach(key -> {
if (entry.getKey().contains(key)) {
iterator.remove();
}
});
}
SimpleFormModel formModel = getContext().getFormModel(() -> {
try {
if (!Objects.equals("gongrendanganqianshu", processInstance.getProcessDefinitionKey()) &&
!Objects.equals("jinengpeixun", processInstance.getProcessDefinitionKey()) &&
!Objects.equals("anquanjiaoyu", processInstance.getProcessDefinitionKey())) {
return new SimpleFormModel();
}
FormInfo formInfo = formRepositoryService.getFormModelByKey(processInstance.getProcessDefinitionKey(), processInstance.getTenantId(), true);
if (Objects.isNull(formInfo)) {
return new SimpleFormModel();
} else {
return (SimpleFormModel) formInfo.getFormModel();
}
} catch (Exception e) {
log.warn("没有找到对应业务 ID 的表单模型: {}", e.getMessage());
return new SimpleFormModel();
}
});
formModel.allFieldsAsMap().keySet().forEach(originVariables::remove);
variables.putAll(originVariables);
return variables; return variables;
} }

View File

@ -7,6 +7,7 @@ import cn.axzo.workflow.common.model.request.bpmn.BpmnSignConf;
import cn.axzo.workflow.common.model.response.category.CategoryItemVO; import cn.axzo.workflow.common.model.response.category.CategoryItemVO;
import cn.axzo.workflow.core.common.context.ProcessOperationContext; import cn.axzo.workflow.core.common.context.ProcessOperationContext;
import cn.axzo.workflow.core.common.utils.BpmnMetaParserHelper; import cn.axzo.workflow.core.common.utils.BpmnMetaParserHelper;
import cn.axzo.workflow.core.conf.SupportRefreshProperties;
import cn.axzo.workflow.core.listener.AbstractBpmnEventListener; import cn.axzo.workflow.core.listener.AbstractBpmnEventListener;
import cn.axzo.workflow.core.listener.BpmnProcessEventListener; import cn.axzo.workflow.core.listener.BpmnProcessEventListener;
import cn.axzo.workflow.core.repository.entity.ExtAxDocContent; import cn.axzo.workflow.core.repository.entity.ExtAxDocContent;
@ -26,7 +27,7 @@ import org.flowable.engine.history.HistoricProcessInstance;
import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl; import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl;
import org.flowable.engine.impl.util.CommandContextUtil; import org.flowable.engine.impl.util.CommandContextUtil;
import org.flowable.engine.impl.util.ProcessDefinitionUtil; import org.flowable.engine.impl.util.ProcessDefinitionUtil;
import org.springframework.cloud.context.config.annotation.RefreshScope; import org.flowable.form.api.FormRepositoryService;
import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.Scope;
import org.springframework.core.Ordered; import org.springframework.core.Ordered;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -49,7 +50,6 @@ import static cn.axzo.workflow.common.constant.BpmnConstants.BPM_MODEL_CATEGORY;
@Slf4j @Slf4j
@Component @Component
@Scope("prototype") @Scope("prototype")
@RefreshScope
public class FileArchiveProcessEventListener extends AbstractBpmnEventListener<ProcessOperationContext> implements BpmnProcessEventListener, Ordered { public class FileArchiveProcessEventListener extends AbstractBpmnEventListener<ProcessOperationContext> implements BpmnProcessEventListener, Ordered {
@Resource @Resource
private HistoryService historyService; private HistoryService historyService;
@ -64,6 +64,10 @@ public class FileArchiveProcessEventListener extends AbstractBpmnEventListener<P
@Resource @Resource
private WpsUtil wpsUtil; private WpsUtil wpsUtil;
public FileArchiveProcessEventListener(FormRepositoryService formRepositoryService, SupportRefreshProperties refreshProperties) {
super(formRepositoryService, refreshProperties);
}
@Override @Override
public void onCompleted(FlowableEngineEntityEvent event) { public void onCompleted(FlowableEngineEntityEvent event) {

View File

@ -3,6 +3,7 @@ package cn.axzo.workflow.server.controller.listener.process;
import cn.axzo.workflow.common.model.request.bpmn.BpmnNoticeConf; import cn.axzo.workflow.common.model.request.bpmn.BpmnNoticeConf;
import cn.axzo.workflow.core.common.context.ProcessOperationContext; import cn.axzo.workflow.core.common.context.ProcessOperationContext;
import cn.axzo.workflow.core.common.utils.BpmnMetaParserHelper; import cn.axzo.workflow.core.common.utils.BpmnMetaParserHelper;
import cn.axzo.workflow.core.conf.SupportRefreshProperties;
import cn.axzo.workflow.core.engine.event.MessagePushEventBuilder; import cn.axzo.workflow.core.engine.event.MessagePushEventBuilder;
import cn.axzo.workflow.core.engine.event.MessagePushEventImpl; import cn.axzo.workflow.core.engine.event.MessagePushEventImpl;
import cn.axzo.workflow.core.engine.event.MessagePushEventType; import cn.axzo.workflow.core.engine.event.MessagePushEventType;
@ -17,8 +18,8 @@ import org.flowable.engine.delegate.event.FlowableCancelledEvent;
import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl; import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl;
import org.flowable.engine.impl.util.CommandContextUtil; import org.flowable.engine.impl.util.CommandContextUtil;
import org.flowable.engine.impl.util.ProcessDefinitionUtil; import org.flowable.engine.impl.util.ProcessDefinitionUtil;
import org.flowable.form.api.FormRepositoryService;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.Scope;
import org.springframework.core.Ordered; import org.springframework.core.Ordered;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -36,10 +37,14 @@ import java.util.Optional;
@Slf4j @Slf4j
@Component @Component
@Scope("prototype") @Scope("prototype")
@RefreshScope
public class MessagePushProcessEventListener extends AbstractBpmnEventListener<ProcessOperationContext> implements BpmnProcessEventListener, Ordered { public class MessagePushProcessEventListener extends AbstractBpmnEventListener<ProcessOperationContext> implements BpmnProcessEventListener, Ordered {
@Value("${workflow.carbonCopyTemplateCode}") @Value("${workflow.carbonCopyTemplateCode}")
private String carbonCopyTemplateCode; private String carbonCopyTemplateCode;
public MessagePushProcessEventListener(FormRepositoryService formRepositoryService, SupportRefreshProperties refreshProperties) {
super(formRepositoryService, refreshProperties);
}
@Override @Override
public void onCancelled(FlowableCancelledEvent event) { public void onCancelled(FlowableCancelledEvent event) {
log.info("MessagePushProcessEventListener#onCancelled...processInstanceId:{}", event.getProcessInstanceId()); log.info("MessagePushProcessEventListener#onCancelled...processInstanceId:{}", event.getProcessInstanceId());

View File

@ -7,6 +7,7 @@ import cn.axzo.workflow.common.model.request.bpmn.task.BpmnTaskDelegateAssigner;
import cn.axzo.workflow.common.model.response.mq.ProcessInstanceDTO; import cn.axzo.workflow.common.model.response.mq.ProcessInstanceDTO;
import cn.axzo.workflow.core.common.context.ProcessOperationContext; import cn.axzo.workflow.core.common.context.ProcessOperationContext;
import cn.axzo.workflow.core.common.utils.BpmnMetaParserHelper; import cn.axzo.workflow.core.common.utils.BpmnMetaParserHelper;
import cn.axzo.workflow.core.conf.SupportRefreshProperties;
import cn.axzo.workflow.core.listener.AbstractBpmnEventListener; import cn.axzo.workflow.core.listener.AbstractBpmnEventListener;
import cn.axzo.workflow.core.listener.BpmnProcessEventListener; import cn.axzo.workflow.core.listener.BpmnProcessEventListener;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -19,9 +20,7 @@ import org.flowable.engine.delegate.event.FlowableProcessStartedEvent;
import org.flowable.engine.delegate.event.impl.FlowableProcessCancelledEventImpl; import org.flowable.engine.delegate.event.impl.FlowableProcessCancelledEventImpl;
import org.flowable.engine.impl.persistence.entity.ExecutionEntityImpl; import org.flowable.engine.impl.persistence.entity.ExecutionEntityImpl;
import org.flowable.engine.repository.Deployment; import org.flowable.engine.repository.Deployment;
import org.flowable.form.api.FormInfo;
import org.flowable.form.api.FormRepositoryService; import org.flowable.form.api.FormRepositoryService;
import org.flowable.form.model.SimpleFormModel;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.Scope;
import org.springframework.core.Ordered; import org.springframework.core.Ordered;
@ -67,8 +66,10 @@ public class RocketMqBpmnProcessEventListener extends AbstractBpmnEventListener<
private RepositoryService repositoryService; private RepositoryService repositoryService;
@Value("${sendMq:true}") @Value("${sendMq:true}")
private Boolean sendMQ; private Boolean sendMQ;
@Resource
private FormRepositoryService formRepositoryService; public RocketMqBpmnProcessEventListener(FormRepositoryService formRepositoryService, SupportRefreshProperties refreshProperties) {
super(formRepositoryService, refreshProperties);
}
@Override @Override
public void onCreated(FlowableEngineEntityEvent event) { public void onCreated(FlowableEngineEntityEvent event) {
@ -77,26 +78,6 @@ public class RocketMqBpmnProcessEventListener extends AbstractBpmnEventListener<
.deploymentId(((ExecutionEntityImpl) event.getEntity()).getDeploymentId()).singleResult()); .deploymentId(((ExecutionEntityImpl) event.getEntity()).getDeploymentId()).singleResult());
Process mainProcess = getContext().getProcess(() -> repositoryService.getBpmnModel(event.getProcessDefinitionId()).getMainProcess()); Process mainProcess = getContext().getProcess(() -> repositoryService.getBpmnModel(event.getProcessDefinitionId()).getMainProcess());
BpmnTaskDelegateAssigner initiator = getContext().getInitiator(() -> BpmnTaskDelegateAssigner.toObjectCompatible(((ExecutionEntityImpl) event.getEntity()).getVariable(INTERNAL_INITIATOR))); BpmnTaskDelegateAssigner initiator = getContext().getInitiator(() -> BpmnTaskDelegateAssigner.toObjectCompatible(((ExecutionEntityImpl) event.getEntity()).getVariable(INTERNAL_INITIATOR)));
SimpleFormModel formModel = getContext().getFormModel(() -> {
try {
String processDefinitionKey = ((ExecutionEntityImpl) event.getEntity()).getProcessDefinitionKey();
if (!Objects.equals("gongrendanganqianshu", processDefinitionKey) &&
!Objects.equals("jinengpeixun", processDefinitionKey) &&
!Objects.equals("anquanjiaoyu", processDefinitionKey)) {
return new SimpleFormModel();
}
FormInfo formInfo = formRepositoryService.getFormModelByKey(processDefinitionKey,
((ExecutionEntityImpl) event.getEntity()).getTenantId(), true);
if (Objects.isNull(formInfo)) {
return new SimpleFormModel();
} else {
return (SimpleFormModel) formInfo.getFormModel();
}
} catch (Exception e) {
log.warn("没有找到对应业务 ID 的表单模型: {}", e.getMessage());
return new SimpleFormModel();
}
});
ProcessInstanceDTO dto = new ProcessInstanceDTO() ProcessInstanceDTO dto = new ProcessInstanceDTO()
.setType(PROCESS_INSTANCE_CREATED) .setType(PROCESS_INSTANCE_CREATED)
.setCategory(deployment.getKey()) .setCategory(deployment.getKey())
@ -106,7 +87,7 @@ public class RocketMqBpmnProcessEventListener extends AbstractBpmnEventListener<
.setProcessDefinitionKey(((ExecutionEntityImpl) event.getEntity()).getProcessDefinitionKey()) .setProcessDefinitionKey(((ExecutionEntityImpl) event.getEntity()).getProcessDefinitionKey())
.setProcessDefinitionVersion(((ExecutionEntityImpl) event.getEntity()).getProcessDefinitionVersion()) .setProcessDefinitionVersion(((ExecutionEntityImpl) event.getEntity()).getProcessDefinitionVersion())
.setInitiator(initiator) .setInitiator(initiator)
.setVariables(removeBpmnConstantsVariables(((ExecutionEntityImpl) event.getEntity()).getVariables(), formModel.allFieldsAsMap().keySet())) .setVariables(removeBpmnConstantsVariables(((ExecutionEntityImpl) event.getEntity()).getVariables(), ((ExecutionEntityImpl) event.getEntity()).getProcessDefinitionKey(), ((ExecutionEntityImpl) event.getEntity()).getTenantId()))
.setStartTime(((ExecutionEntityImpl) event.getEntity()).getStartTime()) .setStartTime(((ExecutionEntityImpl) event.getEntity()).getStartTime())
.setTenantId(((ExecutionEntityImpl) event.getEntity()).getTenantId()) .setTenantId(((ExecutionEntityImpl) event.getEntity()).getTenantId())
.setBusinessKey(((ExecutionEntityImpl) event.getEntity()).getBusinessKey()) .setBusinessKey(((ExecutionEntityImpl) event.getEntity()).getBusinessKey())
@ -133,26 +114,6 @@ public class RocketMqBpmnProcessEventListener extends AbstractBpmnEventListener<
BpmnTaskDelegateAssigner initiator = getContext().getInitiator(() -> BpmnTaskDelegateAssigner.toObjectCompatible(((ExecutionEntityImpl) event.getEntity()) BpmnTaskDelegateAssigner initiator = getContext().getInitiator(() -> BpmnTaskDelegateAssigner.toObjectCompatible(((ExecutionEntityImpl) event.getEntity())
.getVariable(INTERNAL_INITIATOR))); .getVariable(INTERNAL_INITIATOR)));
SimpleFormModel formModel = getContext().getFormModel(() -> {
try {
String processDefinitionKey = ((ExecutionEntityImpl) event.getEntity()).getProcessDefinitionKey();
if (!Objects.equals("gongrendanganqianshu", processDefinitionKey) &&
!Objects.equals("jinengpeixun", processDefinitionKey) &&
!Objects.equals("anquanjiaoyu", processDefinitionKey)) {
return new SimpleFormModel();
}
FormInfo formInfo = formRepositoryService.getFormModelByKey(processDefinitionKey,
((ExecutionEntityImpl) event.getEntity()).getTenantId(), true);
if (Objects.isNull(formInfo)) {
return new SimpleFormModel();
} else {
return (SimpleFormModel) formInfo.getFormModel();
}
} catch (Exception e) {
log.warn("没有找到对应业务 ID 的表单模型: {}", e.getMessage());
return new SimpleFormModel();
}
});
ProcessInstanceDTO dto = new ProcessInstanceDTO() ProcessInstanceDTO dto = new ProcessInstanceDTO()
.setType(PROCESS_INSTANCE_STARTED) .setType(PROCESS_INSTANCE_STARTED)
.setCategory(deployment.getKey()) .setCategory(deployment.getKey())
@ -162,7 +123,7 @@ public class RocketMqBpmnProcessEventListener extends AbstractBpmnEventListener<
.setProcessDefinitionKey(((ExecutionEntityImpl) event.getEntity()).getProcessDefinitionKey()) .setProcessDefinitionKey(((ExecutionEntityImpl) event.getEntity()).getProcessDefinitionKey())
.setProcessDefinitionVersion(((ExecutionEntityImpl) event.getEntity()).getProcessDefinitionVersion()) .setProcessDefinitionVersion(((ExecutionEntityImpl) event.getEntity()).getProcessDefinitionVersion())
.setInitiator(initiator) .setInitiator(initiator)
.setVariables(removeBpmnConstantsVariables(((ExecutionEntityImpl) event.getEntity()).getVariables(), formModel.allFieldsAsMap().keySet())) .setVariables(removeBpmnConstantsVariables(((ExecutionEntityImpl) event.getEntity()).getVariables(), ((ExecutionEntityImpl) event.getEntity()).getProcessDefinitionKey(), ((ExecutionEntityImpl) event.getEntity()).getTenantId()))
.setStartTime(((ExecutionEntityImpl) event.getEntity()).getStartTime()) .setStartTime(((ExecutionEntityImpl) event.getEntity()).getStartTime())
.setTenantId(((ExecutionEntityImpl) event.getEntity()).getTenantId()) .setTenantId(((ExecutionEntityImpl) event.getEntity()).getTenantId())
.setBusinessKey(((ExecutionEntityImpl) event.getEntity()).getProcessInstance().getBusinessKey()) .setBusinessKey(((ExecutionEntityImpl) event.getEntity()).getProcessInstance().getBusinessKey())
@ -184,26 +145,6 @@ public class RocketMqBpmnProcessEventListener extends AbstractBpmnEventListener<
Process mainProcess = getContext().getProcess(() -> repositoryService.getBpmnModel(event.getProcessDefinitionId()).getMainProcess()); Process mainProcess = getContext().getProcess(() -> repositoryService.getBpmnModel(event.getProcessDefinitionId()).getMainProcess());
BpmnTaskDelegateAssigner initiator = getContext().getInitiator(() -> BpmnTaskDelegateAssigner.toObjectCompatible(((FlowableProcessCancelledEventImpl) event) BpmnTaskDelegateAssigner initiator = getContext().getInitiator(() -> BpmnTaskDelegateAssigner.toObjectCompatible(((FlowableProcessCancelledEventImpl) event)
.getExecution().getVariable(INTERNAL_INITIATOR))); .getExecution().getVariable(INTERNAL_INITIATOR)));
SimpleFormModel formModel = getContext().getFormModel(() -> {
try {
String processDefinitionKey = ((ExecutionEntityImpl) ((FlowableProcessCancelledEventImpl) event).getExecution()).getProcessDefinitionKey();
if (!Objects.equals("gongrendanganqianshu", processDefinitionKey) &&
!Objects.equals("jinengpeixun", processDefinitionKey) &&
!Objects.equals("anquanjiaoyu", processDefinitionKey)) {
return new SimpleFormModel();
}
FormInfo formInfo = formRepositoryService.getFormModelByKey(processDefinitionKey,
((FlowableProcessCancelledEventImpl) event).getExecution().getTenantId(), true);
if (Objects.isNull(formInfo)) {
return new SimpleFormModel();
} else {
return (SimpleFormModel) formInfo.getFormModel();
}
} catch (Exception e) {
log.warn("没有找到对应业务 ID 的表单模型: {}", e.getMessage());
return new SimpleFormModel();
}
});
ProcessInstanceDTO dto = new ProcessInstanceDTO() ProcessInstanceDTO dto = new ProcessInstanceDTO()
.setType(PROCESS_INSTANCE_CANCELLED) .setType(PROCESS_INSTANCE_CANCELLED)
@ -216,7 +157,7 @@ public class RocketMqBpmnProcessEventListener extends AbstractBpmnEventListener<
.setInitiator(initiator) .setInitiator(initiator)
.setLastOperationAssigner(getContext().getLastOperationAssigner(() -> BpmnTaskDelegateAssigner.toObjectCompatible( .setLastOperationAssigner(getContext().getLastOperationAssigner(() -> BpmnTaskDelegateAssigner.toObjectCompatible(
runtimeService.getVariable(event.getProcessInstanceId(), CLOSE_PROCESS_ASSIGNER, BpmnTaskDelegateAssigner.class)))) runtimeService.getVariable(event.getProcessInstanceId(), CLOSE_PROCESS_ASSIGNER, BpmnTaskDelegateAssigner.class))))
.setVariables(removeBpmnConstantsVariables(((FlowableProcessCancelledEventImpl) event).getExecution().getVariables(), formModel.allFieldsAsMap().keySet())) .setVariables(removeBpmnConstantsVariables(((FlowableProcessCancelledEventImpl) event).getExecution().getVariables(), ((ExecutionEntityImpl) ((FlowableProcessCancelledEventImpl) event).getExecution()).getProcessDefinitionKey(), ((ExecutionEntityImpl) ((FlowableProcessCancelledEventImpl) event).getExecution()).getTenantId()))
.setStartTime(((ExecutionEntityImpl) ((FlowableProcessCancelledEventImpl) event).getExecution()).getStartTime()) .setStartTime(((ExecutionEntityImpl) ((FlowableProcessCancelledEventImpl) event).getExecution()).getStartTime())
.setTenantId(((FlowableProcessCancelledEventImpl) event).getExecution().getTenantId()) .setTenantId(((FlowableProcessCancelledEventImpl) event).getExecution().getTenantId())
.setBusinessKey(((FlowableProcessCancelledEventImpl) event).getExecution().getProcessInstanceBusinessKey()) .setBusinessKey(((FlowableProcessCancelledEventImpl) event).getExecution().getProcessInstanceBusinessKey())
@ -246,26 +187,6 @@ public class RocketMqBpmnProcessEventListener extends AbstractBpmnEventListener<
BpmnTaskDelegateAssigner initiator = getContext().getInitiator(() -> BpmnTaskDelegateAssigner.toObjectCompatible(((FlowableProcessCancelledEventImpl) event) BpmnTaskDelegateAssigner initiator = getContext().getInitiator(() -> BpmnTaskDelegateAssigner.toObjectCompatible(((FlowableProcessCancelledEventImpl) event)
.getExecution().getVariable(INTERNAL_INITIATOR))); .getExecution().getVariable(INTERNAL_INITIATOR)));
SimpleFormModel formModel = getContext().getFormModel(() -> {
try {
String processDefinitionKey = ((ExecutionEntityImpl) ((FlowableProcessCancelledEventImpl) event).getExecution()).getProcessDefinitionKey();
if (!Objects.equals("gongrendanganqianshu", processDefinitionKey) &&
!Objects.equals("jinengpeixun", processDefinitionKey) &&
!Objects.equals("anquanjiaoyu", processDefinitionKey)) {
return new SimpleFormModel();
}
FormInfo formInfo = formRepositoryService.getFormModelByKey(processDefinitionKey,
((FlowableProcessCancelledEventImpl) event).getExecution().getTenantId(), true);
if (Objects.isNull(formInfo)) {
return new SimpleFormModel();
} else {
return (SimpleFormModel) formInfo.getFormModel();
}
} catch (Exception e) {
log.warn("没有找到对应业务 ID 的表单模型: {}", e.getMessage());
return new SimpleFormModel();
}
});
ProcessInstanceDTO dto = new ProcessInstanceDTO() ProcessInstanceDTO dto = new ProcessInstanceDTO()
.setType(PROCESS_INSTANCE_REJECTED) .setType(PROCESS_INSTANCE_REJECTED)
.setCategory(deployment.getKey()) .setCategory(deployment.getKey())
@ -277,7 +198,7 @@ public class RocketMqBpmnProcessEventListener extends AbstractBpmnEventListener<
.setInitiator(initiator) .setInitiator(initiator)
.setLastOperationAssigner(getContext().getLastOperationAssigner(() -> BpmnTaskDelegateAssigner.toObjectCompatible( .setLastOperationAssigner(getContext().getLastOperationAssigner(() -> BpmnTaskDelegateAssigner.toObjectCompatible(
runtimeService.getVariable(event.getProcessInstanceId(), CLOSE_PROCESS_ASSIGNER, BpmnTaskDelegateAssigner.class)))) runtimeService.getVariable(event.getProcessInstanceId(), CLOSE_PROCESS_ASSIGNER, BpmnTaskDelegateAssigner.class))))
.setVariables(removeBpmnConstantsVariables(((FlowableProcessCancelledEventImpl) event).getExecution().getVariables(), formModel.allFieldsAsMap().keySet())) .setVariables(removeBpmnConstantsVariables(((FlowableProcessCancelledEventImpl) event).getExecution().getVariables(), ((ExecutionEntityImpl) ((FlowableProcessCancelledEventImpl) event).getExecution()).getProcessDefinitionKey(), ((ExecutionEntityImpl) ((FlowableProcessCancelledEventImpl) event).getExecution()).getTenantId()))
.setStartTime(((ExecutionEntityImpl) ((FlowableProcessCancelledEventImpl) event).getExecution()).getStartTime()) .setStartTime(((ExecutionEntityImpl) ((FlowableProcessCancelledEventImpl) event).getExecution()).getStartTime())
.setTenantId(((FlowableProcessCancelledEventImpl) event).getExecution().getTenantId()) .setTenantId(((FlowableProcessCancelledEventImpl) event).getExecution().getTenantId())
.setBusinessKey(((FlowableProcessCancelledEventImpl) event).getExecution().getProcessInstanceBusinessKey()) .setBusinessKey(((FlowableProcessCancelledEventImpl) event).getExecution().getProcessInstanceBusinessKey())
@ -302,26 +223,6 @@ public class RocketMqBpmnProcessEventListener extends AbstractBpmnEventListener<
BpmnTaskDelegateAssigner initiator = getContext().getInitiator(() -> BpmnTaskDelegateAssigner.toObjectCompatible(((FlowableProcessCancelledEventImpl) event) BpmnTaskDelegateAssigner initiator = getContext().getInitiator(() -> BpmnTaskDelegateAssigner.toObjectCompatible(((FlowableProcessCancelledEventImpl) event)
.getExecution().getVariable(INTERNAL_INITIATOR))); .getExecution().getVariable(INTERNAL_INITIATOR)));
SimpleFormModel formModel = getContext().getFormModel(() -> {
try {
String processDefinitionKey = ((ExecutionEntityImpl) ((FlowableProcessCancelledEventImpl) event).getExecution()).getProcessDefinitionKey();
if (!Objects.equals("gongrendanganqianshu", processDefinitionKey) &&
!Objects.equals("jinengpeixun", processDefinitionKey) &&
!Objects.equals("anquanjiaoyu", processDefinitionKey)) {
return new SimpleFormModel();
}
FormInfo formInfo = formRepositoryService.getFormModelByKey(processDefinitionKey,
((FlowableProcessCancelledEventImpl) event).getExecution().getTenantId(), true);
if (Objects.isNull(formInfo)) {
return new SimpleFormModel();
} else {
return (SimpleFormModel) formInfo.getFormModel();
}
} catch (Exception e) {
log.warn("没有找到对应业务 ID 的表单模型: {}", e.getMessage());
return new SimpleFormModel();
}
});
ProcessInstanceDTO dto = new ProcessInstanceDTO() ProcessInstanceDTO dto = new ProcessInstanceDTO()
.setType(PROCESS_INSTANCE_ABORTED) .setType(PROCESS_INSTANCE_ABORTED)
.setCategory(deployment.getKey()) .setCategory(deployment.getKey())
@ -333,7 +234,7 @@ public class RocketMqBpmnProcessEventListener extends AbstractBpmnEventListener<
.setInitiator(initiator) .setInitiator(initiator)
.setLastOperationAssigner(getContext().getLastOperationAssigner(() -> BpmnTaskDelegateAssigner.toObjectCompatible( .setLastOperationAssigner(getContext().getLastOperationAssigner(() -> BpmnTaskDelegateAssigner.toObjectCompatible(
runtimeService.getVariable(event.getProcessInstanceId(), CLOSE_PROCESS_ASSIGNER, BpmnTaskDelegateAssigner.class)))) runtimeService.getVariable(event.getProcessInstanceId(), CLOSE_PROCESS_ASSIGNER, BpmnTaskDelegateAssigner.class))))
.setVariables(removeBpmnConstantsVariables(((FlowableProcessCancelledEventImpl) event).getExecution().getVariables(), formModel.allFieldsAsMap().keySet())) .setVariables(removeBpmnConstantsVariables(((FlowableProcessCancelledEventImpl) event).getExecution().getVariables(), ((ExecutionEntityImpl) ((FlowableProcessCancelledEventImpl) event).getExecution()).getProcessDefinitionKey(), ((ExecutionEntityImpl) ((FlowableProcessCancelledEventImpl) event).getExecution()).getTenantId()))
.setStartTime(((ExecutionEntityImpl) ((FlowableProcessCancelledEventImpl) event).getExecution()).getStartTime()) .setStartTime(((ExecutionEntityImpl) ((FlowableProcessCancelledEventImpl) event).getExecution()).getStartTime())
.setTenantId(((FlowableProcessCancelledEventImpl) event).getExecution().getTenantId()) .setTenantId(((FlowableProcessCancelledEventImpl) event).getExecution().getTenantId())
.setBusinessKey(((FlowableProcessCancelledEventImpl) event).getExecution().getProcessInstanceBusinessKey()) .setBusinessKey(((FlowableProcessCancelledEventImpl) event).getExecution().getProcessInstanceBusinessKey())
@ -358,26 +259,6 @@ public class RocketMqBpmnProcessEventListener extends AbstractBpmnEventListener<
BpmnTaskDelegateAssigner initiator = getContext().getInitiator(() -> BpmnTaskDelegateAssigner.toObjectCompatible(((ExecutionEntityImpl) event.getEntity()) BpmnTaskDelegateAssigner initiator = getContext().getInitiator(() -> BpmnTaskDelegateAssigner.toObjectCompatible(((ExecutionEntityImpl) event.getEntity())
.getVariable(INTERNAL_INITIATOR))); .getVariable(INTERNAL_INITIATOR)));
SimpleFormModel formModel = getContext().getFormModel(() -> {
try {
String processDefinitionKey = ((ExecutionEntityImpl) event.getEntity()).getProcessDefinitionKey();
if (!Objects.equals("gongrendanganqianshu", processDefinitionKey) &&
!Objects.equals("jinengpeixun", processDefinitionKey) &&
!Objects.equals("anquanjiaoyu", processDefinitionKey)) {
return new SimpleFormModel();
}
FormInfo formInfo = formRepositoryService.getFormModelByKey(processDefinitionKey,
((ExecutionEntityImpl) event.getEntity()).getTenantId(), true);
if (Objects.isNull(formInfo)) {
return new SimpleFormModel();
} else {
return (SimpleFormModel) formInfo.getFormModel();
}
} catch (Exception e) {
log.warn("没有找到对应业务 ID 的表单模型: {}", e.getMessage());
return new SimpleFormModel();
}
});
ProcessInstanceDTO dto = new ProcessInstanceDTO() ProcessInstanceDTO dto = new ProcessInstanceDTO()
.setType(PROCESS_INSTANCE_COMPLETED) .setType(PROCESS_INSTANCE_COMPLETED)
.setCategory(deployment.getKey()) .setCategory(deployment.getKey())
@ -389,7 +270,7 @@ public class RocketMqBpmnProcessEventListener extends AbstractBpmnEventListener<
.setInitiator(initiator) .setInitiator(initiator)
.setLastOperationAssigner(getContext().getLastOperationAssigner(() -> BpmnTaskDelegateAssigner.toObjectCompatible( .setLastOperationAssigner(getContext().getLastOperationAssigner(() -> BpmnTaskDelegateAssigner.toObjectCompatible(
runtimeService.getVariable(event.getProcessInstanceId(), CLOSE_PROCESS_ASSIGNER, BpmnTaskDelegateAssigner.class)))) runtimeService.getVariable(event.getProcessInstanceId(), CLOSE_PROCESS_ASSIGNER, BpmnTaskDelegateAssigner.class))))
.setVariables(removeBpmnConstantsVariables(((ExecutionEntityImpl) event.getEntity()).getVariables(), formModel.allFieldsAsMap().keySet())) .setVariables(removeBpmnConstantsVariables(((ExecutionEntityImpl) event.getEntity()).getVariables(), ((ExecutionEntityImpl) event.getEntity()).getProcessDefinitionKey(), ((ExecutionEntityImpl) event.getEntity()).getTenantId()))
.setStartTime(((ExecutionEntityImpl) event.getEntity()).getStartTime()) .setStartTime(((ExecutionEntityImpl) event.getEntity()).getStartTime())
.setTenantId(((ExecutionEntityImpl) event.getEntity()).getTenantId()) .setTenantId(((ExecutionEntityImpl) event.getEntity()).getTenantId())
.setBusinessKey(((ExecutionEntityImpl) event.getEntity()).getProcessInstanceBusinessKey()) .setBusinessKey(((ExecutionEntityImpl) event.getEntity()).getProcessInstanceBusinessKey())

View File

@ -4,11 +4,13 @@ import cn.axzo.framework.rocketmq.Event;
import cn.axzo.framework.rocketmq.EventProducer; import cn.axzo.framework.rocketmq.EventProducer;
import cn.axzo.workflow.common.enums.ElasticSearchEventEnum; import cn.axzo.workflow.common.enums.ElasticSearchEventEnum;
import cn.axzo.workflow.core.common.context.ProcessOperationContext; import cn.axzo.workflow.core.common.context.ProcessOperationContext;
import cn.axzo.workflow.core.conf.SupportRefreshProperties;
import cn.axzo.workflow.core.listener.AbstractBpmnEventListener; import cn.axzo.workflow.core.listener.AbstractBpmnEventListener;
import cn.axzo.workflow.core.listener.BpmnProcessEventListener; import cn.axzo.workflow.core.listener.BpmnProcessEventListener;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.flowable.common.engine.api.delegate.event.FlowableEngineEntityEvent; import org.flowable.common.engine.api.delegate.event.FlowableEngineEntityEvent;
import org.flowable.engine.delegate.event.FlowableCancelledEvent; import org.flowable.engine.delegate.event.FlowableCancelledEvent;
import org.flowable.form.api.FormRepositoryService;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.Scope;
import org.springframework.core.Ordered; import org.springframework.core.Ordered;
@ -31,6 +33,10 @@ public class SyncToEsProcessEventListener extends AbstractBpmnEventListener<Proc
@Value("${sendMq:true}") @Value("${sendMq:true}")
private Boolean sendMQ; private Boolean sendMQ;
public SyncToEsProcessEventListener(FormRepositoryService formRepositoryService, SupportRefreshProperties refreshProperties) {
super(formRepositoryService, refreshProperties);
}
@Override @Override
public int getOrder() { public int getOrder() {
return Integer.MIN_VALUE + 2; return Integer.MIN_VALUE + 2;

View File

@ -6,6 +6,7 @@ import cn.axzo.workflow.common.model.request.bpmn.task.BpmnTaskAuditDTO;
import cn.axzo.workflow.common.model.request.bpmn.task.BpmnTaskDelegateAssigner; import cn.axzo.workflow.common.model.request.bpmn.task.BpmnTaskDelegateAssigner;
import cn.axzo.workflow.core.common.context.TaskOperationContext; import cn.axzo.workflow.core.common.context.TaskOperationContext;
import cn.axzo.workflow.core.common.utils.BpmnMetaParserHelper; import cn.axzo.workflow.core.common.utils.BpmnMetaParserHelper;
import cn.axzo.workflow.core.conf.SupportRefreshProperties;
import cn.axzo.workflow.core.engine.job.AsyncApproveTaskJobHandler; import cn.axzo.workflow.core.engine.job.AsyncApproveTaskJobHandler;
import cn.axzo.workflow.core.engine.tx.listener.AutoPassTransactionListener; import cn.axzo.workflow.core.engine.tx.listener.AutoPassTransactionListener;
import cn.axzo.workflow.core.engine.tx.listener.AutoRejectTransactionListener; import cn.axzo.workflow.core.engine.tx.listener.AutoRejectTransactionListener;
@ -14,7 +15,6 @@ import cn.axzo.workflow.core.listener.BpmnTaskEventListener;
import cn.axzo.workflow.core.version.MultiVersionBeanUtils; import cn.axzo.workflow.core.version.MultiVersionBeanUtils;
import cn.axzo.workflow.server.controller.listener.task.service.CheckApproverService; import cn.axzo.workflow.server.controller.listener.task.service.CheckApproverService;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.flowable.bpmn.model.Process; import org.flowable.bpmn.model.Process;
import org.flowable.bpmn.model.UserTask; import org.flowable.bpmn.model.UserTask;
@ -23,6 +23,7 @@ import org.flowable.common.engine.impl.context.Context;
import org.flowable.engine.RepositoryService; import org.flowable.engine.RepositoryService;
import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl; import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl;
import org.flowable.engine.impl.util.CommandContextUtil; import org.flowable.engine.impl.util.CommandContextUtil;
import org.flowable.form.api.FormRepositoryService;
import org.flowable.job.service.JobService; import org.flowable.job.service.JobService;
import org.flowable.job.service.impl.persistence.entity.JobEntity; import org.flowable.job.service.impl.persistence.entity.JobEntity;
import org.flowable.task.service.delegate.DelegateTask; import org.flowable.task.service.delegate.DelegateTask;
@ -32,6 +33,7 @@ import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import javax.annotation.Resource;
import java.util.Objects; import java.util.Objects;
import java.util.Optional; import java.util.Optional;
@ -50,15 +52,19 @@ import static cn.axzo.workflow.common.enums.BpmnFlowNodeType.NODE_STARTER;
@Slf4j @Slf4j
@Component @Component
@Scope("prototype") @Scope("prototype")
@AllArgsConstructor
public class AutoOperatorEvent_101_Listener extends AbstractBpmnEventListener<TaskOperationContext> implements BpmnTaskEventListener, Ordered { public class AutoOperatorEvent_101_Listener extends AbstractBpmnEventListener<TaskOperationContext> implements BpmnTaskEventListener, Ordered {
@Resource
private RepositoryService repositoryService;
public AutoOperatorEvent_101_Listener(FormRepositoryService formRepositoryService, SupportRefreshProperties refreshProperties) {
super(formRepositoryService, refreshProperties);
}
@Override @Override
public int getOrder() { public int getOrder() {
return Integer.MIN_VALUE + 101; return Integer.MIN_VALUE + 101;
} }
private final RepositoryService repositoryService;
@Override @Override
public void onCreated(DelegateTask delegateTask) { public void onCreated(DelegateTask delegateTask) {
log.info("AutoOperatorEventListener#onCreated...{}, processInstanceId:{}", delegateTask.getTaskDefinitionKey(), delegateTask.getProcessInstanceId()); log.info("AutoOperatorEventListener#onCreated...{}, processInstanceId:{}", delegateTask.getTaskDefinitionKey(), delegateTask.getProcessInstanceId());

View File

@ -11,6 +11,7 @@ import cn.axzo.workflow.common.model.request.bpmn.model.doc.DocCloneDTO;
import cn.axzo.workflow.common.model.response.bpmn.model.doc.DocBaseVO; import cn.axzo.workflow.common.model.response.bpmn.model.doc.DocBaseVO;
import cn.axzo.workflow.core.common.context.TaskOperationContext; import cn.axzo.workflow.core.common.context.TaskOperationContext;
import cn.axzo.workflow.core.common.utils.BpmnMetaParserHelper; import cn.axzo.workflow.core.common.utils.BpmnMetaParserHelper;
import cn.axzo.workflow.core.conf.SupportRefreshProperties;
import cn.axzo.workflow.core.engine.cmd.CustomGetModelDocsCmd; import cn.axzo.workflow.core.engine.cmd.CustomGetModelDocsCmd;
import cn.axzo.workflow.core.listener.AbstractBpmnEventListener; import cn.axzo.workflow.core.listener.AbstractBpmnEventListener;
import cn.axzo.workflow.core.listener.BpmnTaskEventListener; import cn.axzo.workflow.core.listener.BpmnTaskEventListener;
@ -28,6 +29,7 @@ import org.flowable.engine.RuntimeService;
import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl; import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl;
import org.flowable.engine.impl.util.CommandContextUtil; import org.flowable.engine.impl.util.CommandContextUtil;
import org.flowable.engine.impl.util.ProcessDefinitionUtil; import org.flowable.engine.impl.util.ProcessDefinitionUtil;
import org.flowable.form.api.FormRepositoryService;
import org.flowable.task.service.delegate.DelegateTask; import org.flowable.task.service.delegate.DelegateTask;
import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.Scope;
import org.springframework.core.Ordered; import org.springframework.core.Ordered;
@ -79,6 +81,10 @@ public class FirstCopyTemplateFileTaskEvent_105_Listener extends AbstractBpmnEve
@Resource @Resource
private WpsUtil wpsUtil; private WpsUtil wpsUtil;
public FirstCopyTemplateFileTaskEvent_105_Listener(FormRepositoryService formRepositoryService, SupportRefreshProperties refreshProperties) {
super(formRepositoryService, refreshProperties);
}
@Override @Override
public void onCompleted(DelegateTask delegateTask) { public void onCompleted(DelegateTask delegateTask) {
if (!Objects.equals(NODE_STARTER.getType(), delegateTask.getTaskDefinitionKey())) { if (!Objects.equals(NODE_STARTER.getType(), delegateTask.getTaskDefinitionKey())) {

View File

@ -5,6 +5,7 @@ import cn.axzo.workflow.common.model.request.bpmn.BpmnNoticeConf;
import cn.axzo.workflow.common.model.request.bpmn.task.BpmnTaskDelegateAssigner; import cn.axzo.workflow.common.model.request.bpmn.task.BpmnTaskDelegateAssigner;
import cn.axzo.workflow.core.common.context.TaskOperationContext; import cn.axzo.workflow.core.common.context.TaskOperationContext;
import cn.axzo.workflow.core.common.utils.BpmnMetaParserHelper; import cn.axzo.workflow.core.common.utils.BpmnMetaParserHelper;
import cn.axzo.workflow.core.conf.SupportRefreshProperties;
import cn.axzo.workflow.core.engine.event.BizSpecifyAssigneeEventImpl; import cn.axzo.workflow.core.engine.event.BizSpecifyAssigneeEventImpl;
import cn.axzo.workflow.core.engine.event.MessagePushEventBuilder; import cn.axzo.workflow.core.engine.event.MessagePushEventBuilder;
import cn.axzo.workflow.core.engine.event.MessagePushEventImpl; import cn.axzo.workflow.core.engine.event.MessagePushEventImpl;
@ -13,7 +14,6 @@ import cn.axzo.workflow.core.listener.AbstractBpmnEventListener;
import cn.axzo.workflow.core.listener.BpmnTaskEventListener; import cn.axzo.workflow.core.listener.BpmnTaskEventListener;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.flowable.bpmn.model.Process; import org.flowable.bpmn.model.Process;
import org.flowable.bpmn.model.UserTask; import org.flowable.bpmn.model.UserTask;
@ -23,6 +23,7 @@ import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl;
import org.flowable.engine.impl.util.CommandContextUtil; import org.flowable.engine.impl.util.CommandContextUtil;
import org.flowable.engine.impl.util.ProcessDefinitionUtil; import org.flowable.engine.impl.util.ProcessDefinitionUtil;
import org.flowable.engine.runtime.ProcessInstance; import org.flowable.engine.runtime.ProcessInstance;
import org.flowable.form.api.FormRepositoryService;
import org.flowable.task.service.delegate.DelegateTask; import org.flowable.task.service.delegate.DelegateTask;
import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.Scope;
import org.springframework.core.Ordered; import org.springframework.core.Ordered;
@ -30,6 +31,7 @@ import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import javax.annotation.Resource;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
@ -52,22 +54,23 @@ import static cn.axzo.workflow.core.engine.event.BizSpecifyAssigneeEventType.ADD
@Slf4j @Slf4j
@Component @Component
@Scope("prototype") @Scope("prototype")
@AllArgsConstructor
public class MessagePushTaskEvent_103_Listener extends AbstractBpmnEventListener<TaskOperationContext> implements BpmnTaskEventListener, Ordered { public class MessagePushTaskEvent_103_Listener extends AbstractBpmnEventListener<TaskOperationContext> implements BpmnTaskEventListener, Ordered {
@Override @Override
public int getOrder() { public int getOrder() {
return Integer.MIN_VALUE + 103; return Integer.MIN_VALUE + 103;
} }
private final RuntimeService runtimeService; @Resource
private RuntimeService runtimeService;
public MessagePushTaskEvent_103_Listener(FormRepositoryService formRepositoryService, SupportRefreshProperties refreshProperties) {
super(formRepositoryService, refreshProperties);
}
@Override @Override
public void onAssigned(DelegateTask delegateTask) { public void onAssigned(DelegateTask delegateTask) {
log.info("MessagePushTaskEventListener#onAssigned...{}, assignee: {}, taskId: {}, processInstanceId:{}", log.info("MessagePushTaskEventListener#onAssigned...{}, assignee: {}, taskId: {}, processInstanceId:{}",
delegateTask.getTaskDefinitionKey(), delegateTask.getAssignee(), delegateTask.getId(), delegateTask.getProcessInstanceId()); delegateTask.getTaskDefinitionKey(), delegateTask.getAssignee(), delegateTask.getId(), delegateTask.getProcessInstanceId());
// if (Objects.equals(NODE_STARTER.getType(), delegateTask.getTaskDefinitionKey())) {
// return;
// }
if (StringUtils.hasLength(delegateTask.getAssignee()) && delegateTask.getAssignee().contains(TASK_ASSIGNEE_SKIP_FLAT)) { if (StringUtils.hasLength(delegateTask.getAssignee()) && delegateTask.getAssignee().contains(TASK_ASSIGNEE_SKIP_FLAT)) {
// 转交功能原审批人完成待办, 由于在流程引擎侧, 任务是不会在转交时立即结束, 但待办消息需要立即完成, // 转交功能原审批人完成待办, 由于在流程引擎侧, 任务是不会在转交时立即结束, 但待办消息需要立即完成,
// 下面的 onDelete 事件根据测试情况,看是否需要过滤掉这种任务的"完成待办"事件的推送 // 下面的 onDelete 事件根据测试情况,看是否需要过滤掉这种任务的"完成待办"事件的推送
@ -95,9 +98,6 @@ public class MessagePushTaskEvent_103_Listener extends AbstractBpmnEventListener
@Override @Override
public void onDeleted(DelegateTask delegateTask) { public void onDeleted(DelegateTask delegateTask) {
log.info("MessagePushTaskEventListener#onDeleted...{}, processInstanceId:{}", delegateTask.getTaskDefinitionKey(), delegateTask.getProcessInstanceId()); log.info("MessagePushTaskEventListener#onDeleted...{}, processInstanceId:{}", delegateTask.getTaskDefinitionKey(), delegateTask.getProcessInstanceId());
// if (Objects.equals(NODE_STARTER.getType(), delegateTask.getTaskDefinitionKey())) {
// return;
// }
pendingCompleteEvent(delegateTask); pendingCompleteEvent(delegateTask);
log.info("MessagePushTaskEventListener#onDeleted...end: {}, processInstanceId:{}", delegateTask.getTaskDefinitionKey(), delegateTask.getProcessInstanceId()); log.info("MessagePushTaskEventListener#onDeleted...end: {}, processInstanceId:{}", delegateTask.getTaskDefinitionKey(), delegateTask.getProcessInstanceId());
} }

View File

@ -8,19 +8,16 @@ import cn.axzo.workflow.common.model.request.bpmn.task.BpmnTaskDelegateAssigner;
import cn.axzo.workflow.common.model.response.mq.ProcessTaskDTO; import cn.axzo.workflow.common.model.response.mq.ProcessTaskDTO;
import cn.axzo.workflow.core.common.context.TaskOperationContext; import cn.axzo.workflow.core.common.context.TaskOperationContext;
import cn.axzo.workflow.core.common.utils.BpmnMetaParserHelper; import cn.axzo.workflow.core.common.utils.BpmnMetaParserHelper;
import cn.axzo.workflow.core.conf.SupportRefreshProperties;
import cn.axzo.workflow.core.listener.AbstractBpmnEventListener; import cn.axzo.workflow.core.listener.AbstractBpmnEventListener;
import cn.axzo.workflow.core.listener.BpmnTaskEventListener; import cn.axzo.workflow.core.listener.BpmnTaskEventListener;
import cn.axzo.workflow.core.service.converter.BpmnHistoricAttachmentConverter;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.flowable.bpmn.model.Process; import org.flowable.bpmn.model.Process;
import org.flowable.engine.RepositoryService; import org.flowable.engine.RepositoryService;
import org.flowable.engine.RuntimeService; import org.flowable.engine.RuntimeService;
import org.flowable.engine.TaskService;
import org.flowable.engine.repository.Deployment; import org.flowable.engine.repository.Deployment;
import org.flowable.engine.runtime.ProcessInstance; import org.flowable.engine.runtime.ProcessInstance;
import org.flowable.form.api.FormInfo;
import org.flowable.form.api.FormRepositoryService; import org.flowable.form.api.FormRepositoryService;
import org.flowable.form.model.SimpleFormModel;
import org.flowable.task.service.delegate.DelegateTask; import org.flowable.task.service.delegate.DelegateTask;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.Scope;
@ -64,6 +61,10 @@ import static cn.axzo.workflow.common.enums.ProcessTaskEventEnum.PROCESS_TASK_TR
@Component @Component
@Scope("prototype") @Scope("prototype")
public class RocketMqBpmnTaskEvent_102_Listener extends AbstractBpmnEventListener<TaskOperationContext> implements BpmnTaskEventListener, Ordered { public class RocketMqBpmnTaskEvent_102_Listener extends AbstractBpmnEventListener<TaskOperationContext> implements BpmnTaskEventListener, Ordered {
public RocketMqBpmnTaskEvent_102_Listener(FormRepositoryService formRepositoryService, SupportRefreshProperties refreshProperties) {
super(formRepositoryService, refreshProperties);
}
@Override @Override
public int getOrder() { public int getOrder() {
return Integer.MIN_VALUE + 102; return Integer.MIN_VALUE + 102;
@ -74,15 +75,9 @@ public class RocketMqBpmnTaskEvent_102_Listener extends AbstractBpmnEventListene
@Resource @Resource
private RuntimeService runtimeService; private RuntimeService runtimeService;
@Resource @Resource
private TaskService taskService;
@Resource
private BpmnHistoricAttachmentConverter attachmentConverter;
@Resource
private RepositoryService repositoryService; private RepositoryService repositoryService;
@Value("${sendMq:true}") @Value("${sendMq:true}")
private Boolean sendMQ; private Boolean sendMQ;
@Resource
private FormRepositoryService formRepositoryService;
@Override @Override
public void onAssigned(DelegateTask delegateTask) { public void onAssigned(DelegateTask delegateTask) {
@ -148,25 +143,6 @@ public class RocketMqBpmnTaskEvent_102_Listener extends AbstractBpmnEventListene
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(delegateTask.getProcessInstanceId()).singleResult(); ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(delegateTask.getProcessInstanceId()).singleResult();
String category = getDeployment(delegateTask.getProcessInstanceId()).getKey(); String category = getDeployment(delegateTask.getProcessInstanceId()).getKey();
SimpleFormModel formModel = getContext().getFormModel(() -> {
try {
if (!Objects.equals("gongrendanganqianshu", processInstance.getProcessDefinitionKey()) &&
!Objects.equals("jinengpeixun", processInstance.getProcessDefinitionKey()) &&
!Objects.equals("anquanjiaoyu", processInstance.getProcessDefinitionKey())) {
return new SimpleFormModel();
}
FormInfo formInfo = formRepositoryService.getFormModelByKey(processInstance.getProcessDefinitionKey(), processInstance.getTenantId(), true);
if (Objects.isNull(formInfo)) {
return new SimpleFormModel();
} else {
return (SimpleFormModel) formInfo.getFormModel();
}
} catch (Exception e) {
log.warn("没有找到对应业务 ID 的表单模型: {}", e.getMessage());
return new SimpleFormModel();
}
});
ProcessTaskDTO dto = new ProcessTaskDTO() ProcessTaskDTO dto = new ProcessTaskDTO()
.setType(type) .setType(type)
.setCategory(category) .setCategory(category)
@ -179,7 +155,7 @@ public class RocketMqBpmnTaskEvent_102_Listener extends AbstractBpmnEventListene
.setInitiator(BpmnTaskDelegateAssigner.toObjectCompatible(delegateTask.getVariable(INTERNAL_INITIATOR))) .setInitiator(BpmnTaskDelegateAssigner.toObjectCompatible(delegateTask.getVariable(INTERNAL_INITIATOR)))
.setApprover(BpmnTaskDelegateAssigner.toObjectCompatible( .setApprover(BpmnTaskDelegateAssigner.toObjectCompatible(
delegateTask.getVariable(INTERNAL_TASK_RELATION_ASSIGNEE_INFO + delegateTask.getId()))) delegateTask.getVariable(INTERNAL_TASK_RELATION_ASSIGNEE_INFO + delegateTask.getId())))
.setVariables(removeBpmnConstantsVariables(delegateTask.getVariables(), formModel.allFieldsAsMap().keySet())) .setVariables(removeBpmnConstantsVariables(delegateTask.getVariables(), processInstance.getProcessDefinitionKey(), processInstance.getTenantId()))
.setStartTime(delegateTask.getCreateTime()) .setStartTime(delegateTask.getCreateTime())
.setTenantId(delegateTask.getTenantId()) .setTenantId(delegateTask.getTenantId())
.setBusinessKey(processInstance.getBusinessKey()) .setBusinessKey(processInstance.getBusinessKey())

View File

@ -2,18 +2,20 @@ package cn.axzo.workflow.server.controller.listener.task;
import cn.axzo.workflow.common.model.request.bpmn.task.BpmnTaskDelegateAssigner; import cn.axzo.workflow.common.model.request.bpmn.task.BpmnTaskDelegateAssigner;
import cn.axzo.workflow.core.common.context.TaskOperationContext; import cn.axzo.workflow.core.common.context.TaskOperationContext;
import cn.axzo.workflow.core.conf.SupportRefreshProperties;
import cn.axzo.workflow.core.listener.AbstractBpmnEventListener; import cn.axzo.workflow.core.listener.AbstractBpmnEventListener;
import cn.axzo.workflow.core.listener.BpmnTaskEventListener; import cn.axzo.workflow.core.listener.BpmnTaskEventListener;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.ListUtils; import org.apache.commons.collections4.ListUtils;
import org.flowable.engine.RuntimeService; import org.flowable.engine.RuntimeService;
import org.flowable.engine.TaskService; import org.flowable.engine.TaskService;
import org.flowable.form.api.FormRepositoryService;
import org.flowable.task.service.delegate.DelegateTask; import org.flowable.task.service.delegate.DelegateTask;
import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.Scope;
import org.springframework.core.Ordered; import org.springframework.core.Ordered;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
@ -33,15 +35,20 @@ import static cn.axzo.workflow.common.constant.BpmnConstants.INTERNAL_TASK_RELAT
@Slf4j @Slf4j
@Component @Component
@Scope("prototype") @Scope("prototype")
@AllArgsConstructor
public class SnapshotBpmnTaskEvent_100_Listener extends AbstractBpmnEventListener<TaskOperationContext> implements BpmnTaskEventListener, Ordered { public class SnapshotBpmnTaskEvent_100_Listener extends AbstractBpmnEventListener<TaskOperationContext> implements BpmnTaskEventListener, Ordered {
@Resource
private RuntimeService runtimeService;
@Resource
private TaskService taskService;
@Override @Override
public int getOrder() { public int getOrder() {
return Integer.MIN_VALUE + 100; return Integer.MIN_VALUE + 100;
} }
private final RuntimeService runtimeService; public SnapshotBpmnTaskEvent_100_Listener(FormRepositoryService formRepositoryService, SupportRefreshProperties refreshProperties) {
private final TaskService taskService; super(formRepositoryService, refreshProperties);
}
@Override @Override
public void onAssigned(DelegateTask delegateTask) { public void onAssigned(DelegateTask delegateTask) {

View File

@ -4,9 +4,11 @@ import cn.axzo.framework.rocketmq.Event;
import cn.axzo.framework.rocketmq.EventProducer; import cn.axzo.framework.rocketmq.EventProducer;
import cn.axzo.workflow.common.enums.ElasticSearchEventEnum; import cn.axzo.workflow.common.enums.ElasticSearchEventEnum;
import cn.axzo.workflow.core.common.context.TaskOperationContext; import cn.axzo.workflow.core.common.context.TaskOperationContext;
import cn.axzo.workflow.core.conf.SupportRefreshProperties;
import cn.axzo.workflow.core.listener.AbstractBpmnEventListener; import cn.axzo.workflow.core.listener.AbstractBpmnEventListener;
import cn.axzo.workflow.core.listener.BpmnTaskEventListener; import cn.axzo.workflow.core.listener.BpmnTaskEventListener;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.flowable.form.api.FormRepositoryService;
import org.flowable.task.service.delegate.DelegateTask; import org.flowable.task.service.delegate.DelegateTask;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.Scope;
@ -30,6 +32,10 @@ public class SyncToEsTaskEvent_104_Listener extends AbstractBpmnEventListener<Ta
@Value("${sendMq:true}") @Value("${sendMq:true}")
private Boolean sendMQ; private Boolean sendMQ;
public SyncToEsTaskEvent_104_Listener(FormRepositoryService formRepositoryService, SupportRefreshProperties refreshProperties) {
super(formRepositoryService, refreshProperties);
}
@Override @Override
public int getOrder() { public int getOrder() {
return Integer.MIN_VALUE + 104; return Integer.MIN_VALUE + 104;

View File

@ -50,6 +50,7 @@ import cn.axzo.workflow.common.model.response.bpmn.task.BpmnTaskInstanceLogVO;
import cn.axzo.workflow.common.valid.group.ValidGroup; import cn.axzo.workflow.common.valid.group.ValidGroup;
import cn.axzo.workflow.core.engine.cmd.CustomGetModelDocsCmd; import cn.axzo.workflow.core.engine.cmd.CustomGetModelDocsCmd;
import cn.axzo.workflow.core.repository.entity.ExtAxProcessLog; import cn.axzo.workflow.core.repository.entity.ExtAxProcessLog;
import cn.axzo.workflow.core.repository.entity.ExtAxProcessSign;
import cn.axzo.workflow.core.repository.mapper.ExtAxModelDocMapper; import cn.axzo.workflow.core.repository.mapper.ExtAxModelDocMapper;
import cn.axzo.workflow.core.service.BpmnProcessInstanceService; import cn.axzo.workflow.core.service.BpmnProcessInstanceService;
import cn.axzo.workflow.core.service.BpmnProcessTaskService; import cn.axzo.workflow.core.service.BpmnProcessTaskService;
@ -568,7 +569,8 @@ public class BpmnProcessInstanceController extends BasicPopulateAvatarController
@Operation(summary = "获取签署业务流程最后替换的文档 fileKey 集合") @Operation(summary = "获取签署业务流程最后替换的文档 fileKey 集合")
@GetMapping("/final/docs") @GetMapping("/final/docs")
public CommonResponse<List<SignFileDTO>> getProcessInstanceFinalDocs(@NotBlank(message = "流程实例 ID 不能为空") @RequestParam(required = false) String processInstanceId) { public CommonResponse<List<SignFileDTO>> getProcessInstanceFinalDocs(@NotBlank(message = "流程实例 ID 不能为空") @RequestParam(required = false) String processInstanceId) {
return success(extAxProcessSignService.findByProcessInstanceId(processInstanceId).getFileArchive()); ExtAxProcessSign sign = extAxProcessSignService.findByProcessInstanceId(processInstanceId);
return success(Objects.nonNull(sign) ? sign.getFileArchive() : null);
} }
/** /**