Merge branch 'master' into feature/REQ-7125

# Conflicts:
#	workflow-engine-spring-boot-starter/src/main/java/cn/axzo/workflow/starter/api/WorkflowCoreService.java
This commit is contained in:
wangli 2026-03-11 17:18:20 +08:00
commit 52a27deea8
23 changed files with 575 additions and 131 deletions

37
pom.xml
View File

@ -214,6 +214,43 @@
</annotationProcessorPaths>
</configuration>
</plugin>
<!-- <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.3</version>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>-->
<!-- version number -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>flatten-maven-plugin</artifactId>
<version>1.2.7</version>
<configuration>
<updatePomFile>true</updatePomFile>
<flattenMode>resolveCiFriendliesOnly</flattenMode>
</configuration>
<executions>
<execution>
<id>flatten</id>
<phase>process-resources</phase>
<goals>
<goal>flatten</goal>
</goals>
</execution>
<execution>
<id>flatten.clean</id>
<phase>clean</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

View File

@ -24,6 +24,7 @@ import cn.axzo.workflow.common.model.request.bpmn.process.doc.ChangeApproverRead
import cn.axzo.workflow.common.model.request.bpmn.process.doc.ProcessDocQueryDTO;
import cn.axzo.workflow.common.model.request.bpmn.task.BpmnTaskButtonSearchDTO;
import cn.axzo.workflow.common.model.request.form.ConditionPermissionMetaInfo;
import cn.axzo.workflow.common.model.request.form.instance.CooperationOrgUpdateDTO;
import cn.axzo.workflow.common.model.request.form.instance.FormVariablesUpdateDTO;
import cn.axzo.workflow.common.model.response.BpmPageResult;
import cn.axzo.workflow.common.model.response.bpmn.BatchOperationResultVO;
@ -322,6 +323,16 @@ public interface ProcessInstanceApi {
@InvokeMode(SYNC)
CommonResponse<Boolean> updateInstanceFormVariables(@Validated @RequestBody FormVariablesUpdateDTO dto);
/**
* 更新指定流程的CooperationOrg
*
* @param dto
* @return
*/
@Operation(summary = "更新指定流程的CooperationOrg")
@PostMapping("/api/process/instance/cooperation/update")
@InvokeMode(SYNC)
CommonResponse<Boolean> updateCooperationOrg(@Validated @RequestBody CooperationOrgUpdateDTO dto);
/**
* 签署业务流程实例在审批待办中查询使用的文档列表
*

View File

@ -6,6 +6,7 @@ import cn.axzo.workflow.common.annotation.Manageable;
import cn.axzo.workflow.common.enums.AdminDataSource;
import cn.axzo.workflow.common.enums.BpmnProcessInstanceResultEnum;
import cn.axzo.workflow.common.model.dto.CommonDingTalkDTO;
import cn.axzo.workflow.common.model.dto.ReportClientInfoDTO;
import cn.axzo.workflow.common.model.request.feature.DingTalkStarterAlterDTO;
import cn.azxo.framework.common.model.CommonResponse;
import io.swagger.v3.oas.annotations.Operation;
@ -53,4 +54,9 @@ public interface FunctionApi {
@PostMapping("/api/function/common/dingtalk/send")
@InvokeMode(SYNC)
CommonResponse<Boolean> sendCommonDingtalk(@Validated @RequestBody CommonDingTalkDTO dto);
@Operation(summary = "上报客户端信息")
@PostMapping("/api/function/report/client/info")
@InvokeMode(SYNC)
CommonResponse<Boolean> reportClientInfo(@Validated @RequestBody ReportClientInfoDTO dto);
}

View File

@ -0,0 +1,29 @@
package cn.axzo.workflow.common.model.dto;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import java.io.Serializable;
/**
* 上报客户端信息传输对象
*
* @author wangli
* @since 2026-02-24 14:16
*/
@Data
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class ReportClientInfoDTO implements Serializable {
private String clientApplicationName;
private String clientVersion;
private Boolean manageableStatus;
}

View File

@ -4,6 +4,7 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.Map;
/**
@ -14,7 +15,7 @@ import java.util.Map;
*/
@ApiModel("创建工作流实例同时携带表单的入参模型")
@Data
public class BpmnProcessInstanceCreateWithFormDTO {
public class BpmnProcessInstanceCreateWithFormDTO implements Serializable {
/**
* 审批使用了表单请一定注意传参

View File

@ -0,0 +1,25 @@
package cn.axzo.workflow.common.model.request.form.instance;
import cn.axzo.workflow.common.model.dto.CooperationOrgDTO;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
/**
* 更新流程实例中的 CooperationOrg 整个对象
*
* @author wangli
* @since 2026-02-09 11:30
*/
@ApiModel("更新流程实例中的 CooperationOrg 整个对象")
@Data
public class CooperationOrgUpdateDTO implements Serializable {
@NotBlank(message = "流程实例不能为空")
private String processInstanceId;
@NotNull(message = "组织关系数据不能为空")
private CooperationOrgDTO cooperationOrg;
}

View File

@ -7,4 +7,6 @@ package cn.axzo.workflow.core.common.context;
* @since 2024/4/12 16:43
*/
public class ActivityOperationContext extends CommonContext<ActivityOperationContext> {
}

View File

@ -6,6 +6,7 @@ import cn.axzo.workflow.common.model.response.bpmn.process.BpmnProcessInstanceVO
import org.flowable.bpmn.model.Process;
import org.flowable.engine.repository.Deployment;
import org.flowable.engine.runtime.ProcessInstance;
import org.flowable.form.model.SimpleFormModel;
import org.springframework.util.StringUtils;
import java.util.Objects;
@ -27,6 +28,7 @@ public abstract class CommonContext<T> implements OperationContext {
private BpmnProcessDefinitionVO definitionVO;
private String processInstanceVersion;
private BpmnTaskDelegateAssigner lastOperationAssigner;
private SimpleFormModel formModel;
public ProcessInstance getProcessInstance(Supplier<ProcessInstance> supplier) {
if (Objects.isNull(processInstance)) {
@ -84,6 +86,13 @@ public abstract class CommonContext<T> implements OperationContext {
return processInstanceVersion;
}
public SimpleFormModel getFormModel(Supplier<SimpleFormModel> supplier) {
if (Objects.isNull(formModel)) {
return supplier.get();
}
return formModel;
}
@Override
@SuppressWarnings("unchecked")
public void setContext(OperationContext context) {

View File

@ -0,0 +1,48 @@
package cn.axzo.workflow.core.engine.cmd;
import cn.axzo.workflow.common.constant.BpmnConstants;
import cn.axzo.workflow.common.model.dto.CooperationOrgDTO;
import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.flowable.common.engine.impl.interceptor.CommandContext;
import org.flowable.engine.RuntimeService;
import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl;
import org.flowable.engine.impl.util.CommandContextUtil;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
/**
* 更新指定流程的CooperationOrg
*
* @author wangli
* @since 2026-02-09 11:33
*/
@Slf4j
public class CustomOverrideCooperationOrgCmd extends AbstractCommand<Void> implements Serializable {
private final String processInstanceId;
private final CooperationOrgDTO cooperationOrg;
public CustomOverrideCooperationOrgCmd(String processInstanceId, CooperationOrgDTO cooperationOrg) {
this.processInstanceId = processInstanceId;
this.cooperationOrg = cooperationOrg;
}
@Override
public String paramToJsonString() {
Map<String, Object> params = new HashMap<>();
params.put("processInstanceId", processInstanceId);
params.put("cooperationOrg", cooperationOrg);
return JSON.toJSONString(params);
}
@Override
public Void executeInternal(CommandContext commandContext) {
ProcessEngineConfigurationImpl processEngineConfiguration = CommandContextUtil.getProcessEngineConfiguration(commandContext);
RuntimeService runtimeService = processEngineConfiguration.getRuntimeService();
runtimeService.setVariable(processInstanceId, BpmnConstants.BIZ_ORG_RELATION, cooperationOrg);
return null;
}
}

View File

@ -4,12 +4,14 @@ import cn.axzo.workflow.common.constant.BpmnConstants;
import cn.axzo.workflow.core.common.context.OperationContext;
import cn.hutool.json.JSONUtil;
import org.slf4j.MDC;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import static cn.azxo.framework.common.constatns.Constants.CTX_LOG_ID_MDC;
@ -56,7 +58,7 @@ public abstract class AbstractBpmnEventListener<T extends OperationContext> impl
* @param originVariables
* @return
*/
public static Map<String, Object> removeBpmnConstantsVariables(Map<String, Object> originVariables) {
public static Map<String, Object> removeBpmnConstantsVariables(Map<String, Object> originVariables, Set<String> removeVariableKey) {
if (originVariables == null) return new HashMap<>();
// 定义需要移除的前缀列表
@ -66,6 +68,9 @@ public abstract class AbstractBpmnEventListener<T extends OperationContext> impl
BpmnConstants.TASK_COMPLETE_OPERATION_TYPE,
BpmnConstants.INTERNAL_TASK_RELATION_ASSIGNEE_LIST_INFO
);
if (!CollectionUtils.isEmpty(removeVariableKey)) {
removeVariableKey.forEach(originVariables::remove);
}
return originVariables.entrySet().stream()
.filter(entry -> entry.getKey() != null)

View File

@ -16,6 +16,7 @@ import cn.axzo.workflow.common.model.request.bpmn.process.SuperBpmnProcessInstan
import cn.axzo.workflow.common.model.request.bpmn.process.doc.ProcessDocQueryDTO;
import cn.axzo.workflow.common.model.request.bpmn.task.BpmnTaskButtonSearchDTO;
import cn.axzo.workflow.common.model.request.form.ConditionPermissionMetaInfo;
import cn.axzo.workflow.common.model.request.form.instance.CooperationOrgUpdateDTO;
import cn.axzo.workflow.common.model.request.form.instance.FormVariablesUpdateDTO;
import cn.axzo.workflow.common.model.response.BpmPageResult;
import cn.axzo.workflow.common.model.response.bpmn.BatchOperationResultVO;
@ -217,4 +218,6 @@ public interface BpmnProcessInstanceService {
void overrideProcessVariables(BpmnProcessInstanceVariablesUpdateDTO dto);
List<ConditionPermissionMetaInfo> getConditions(String processInstanceId);
void overrideCooperationOrg(CooperationOrgUpdateDTO dto);
}

View File

@ -41,6 +41,7 @@ import cn.axzo.workflow.common.model.request.bpmn.task.BpmnTaskDelegateAssigner;
import cn.axzo.workflow.common.model.request.bpmn.task.ExtHiTaskSearchDTO;
import cn.axzo.workflow.common.model.request.category.CategorySearchDTO;
import cn.axzo.workflow.common.model.request.form.ConditionPermissionMetaInfo;
import cn.axzo.workflow.common.model.request.form.instance.CooperationOrgUpdateDTO;
import cn.axzo.workflow.common.model.request.form.instance.FormVariablesUpdateDTO;
import cn.axzo.workflow.common.model.response.BpmPageResult;
import cn.axzo.workflow.common.model.response.bpmn.BatchOperationItemResultVO;
@ -69,6 +70,7 @@ import cn.axzo.workflow.core.engine.cmd.CustomCarbonCopyUserSelectorCmd;
import cn.axzo.workflow.core.engine.cmd.CustomForecastUserTaskAssigneeCmd;
import cn.axzo.workflow.core.engine.cmd.CustomGetConditionPermissionsCmd;
import cn.axzo.workflow.core.engine.cmd.CustomGetModelDocsCmd;
import cn.axzo.workflow.core.engine.cmd.CustomOverrideCooperationOrgCmd;
import cn.axzo.workflow.core.engine.cmd.CustomOverrideFormVariablesByLatestInstanceCmd;
import cn.axzo.workflow.core.engine.cmd.CustomOverrideProcessVariablesCmd;
import cn.axzo.workflow.core.engine.listener.EngineExecutionStartListener;
@ -94,6 +96,7 @@ import cn.axzo.workflow.core.service.converter.BpmnProcessInstancePageItemConver
import cn.axzo.workflow.core.service.support.FlowNodeForecastService;
import cn.axzo.workflow.core.service.support.ProcessGraphicService;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.databind.node.ArrayNode;
@ -471,6 +474,7 @@ public class BpmnProcessInstanceServiceImpl implements BpmnProcessInstanceServic
// TODO 该接口有个问题如果模型没有关联表单但是传入参数中含有表单变量则不能正确创建流程
@Override
public String createProcessInstance(BpmnProcessInstanceCreateDTO dto) {
BpmnProcessInstanceCreateDTO createParamDto = ObjectUtil.cloneByStream(dto);
BpmnProcessDefinitionVO definition = null;
if (!StringUtils.hasText(dto.getProcessDefinitionId())) {
definition = processDefinitionService.getActiveProcessDefinitionByKey(dto.getProcessDefinitionKey(), dto.getTenantId());
@ -552,7 +556,7 @@ public class BpmnProcessInstanceServiceImpl implements BpmnProcessInstanceServic
instanceBuilder.outcome(dto.getOutcome());
}
}
dto.getVariables().put(CREATE_INSTANCE_PARAMS, JSONUtil.toJsonStr(dto));
dto.getVariables().put(CREATE_INSTANCE_PARAMS, JSONUtil.toJsonStr(createParamDto));
instanceBuilder.variables(dto.getVariables());
ProcessInstance instance;
if (Boolean.TRUE.equals(dto.getAsync())) {
@ -1953,6 +1957,12 @@ public class BpmnProcessInstanceServiceImpl implements BpmnProcessInstanceServic
commandExecutor.execute(new CustomOverrideFormVariablesByLatestInstanceCmd(dto.getProcessInstanceId(), dto.getFormVariables()));
}
@Override
public void overrideCooperationOrg(CooperationOrgUpdateDTO dto) {
CommandExecutor commandExecutor = springProcessEngineConfiguration.getCommandExecutor();
commandExecutor.execute(new CustomOverrideCooperationOrgCmd(dto.getProcessInstanceId(), dto.getCooperationOrg()));
}
@Override
public List<DocPendingVO> processInstanceSelectDocs(ProcessDocQueryDTO dto) {
CommandExecutor commandExecutor = springProcessEngineConfiguration.getCommandExecutor();

View File

@ -1,12 +1,7 @@
package cn.axzo.workflow.server.common.interceptor;
import cn.axzo.workflow.common.exception.WorkflowEngineException;
import cn.axzo.workflow.core.repository.entity.ExtAxProperty;
import cn.axzo.workflow.core.service.ExtAxPropertyService;
import cn.axzo.workflow.server.common.util.RedisUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import org.springframework.web.servlet.HandlerInterceptor;
@ -14,19 +9,11 @@ import org.springframework.web.servlet.HandlerInterceptor;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.time.Duration;
import java.util.Enumeration;
import java.util.Objects;
import java.util.Optional;
import static cn.axzo.workflow.client.config.WorkflowRequestInterceptor.HEADER_API_VERSION;
import static cn.axzo.workflow.client.config.WorkflowRequestInterceptor.HEADER_HTTP_CLIENT;
import static cn.axzo.workflow.client.config.WorkflowRequestInterceptor.HEADER_HTTP_CLIENT_VALUE;
import static cn.axzo.workflow.client.config.WorkflowRequestInterceptor.HEADER_SERVER_NAME;
import static cn.axzo.workflow.common.code.OtherRespCode.CLIENT_VERSION_SUPPORT;
import static cn.axzo.workflow.common.code.OtherRespCode.MICRO_SERVER_NEED_REBUILD;
import static cn.axzo.workflow.common.constant.BpmnConstants.FLOW_SERVER_VERSION_130;
import static cn.axzo.workflow.common.constant.StarterConstants.ENABLE_MANAGEABLE;
/**
* 客户端与服务端的版本比较
@ -37,39 +24,9 @@ import static cn.axzo.workflow.common.constant.StarterConstants.ENABLE_MANAGEABL
@Component
@Slf4j
public class RequestHeaderContextInterceptor implements HandlerInterceptor {
@Autowired
private String serviceVersion;
@Autowired
private ExtAxPropertyService extAxPropertyService;
private static final ThreadLocal<String> KEY_CACHE = new ThreadLocal<>();
private static final String REPEAT_KEY = "global:api_application:";
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
if (Objects.equals(HEADER_HTTP_CLIENT_VALUE, request.getHeader(HEADER_HTTP_CLIENT))) {
String headerClientVersion = request.getHeader(HEADER_API_VERSION)
.replaceAll("-SNAPSHOT", "")
.replaceAll("-RELEASE", "");
serviceVersion = serviceVersion
.replaceAll("-SNAPSHOT", "")
.replaceAll("-RELEASE", "");
DefaultArtifactVersion minimumSupportedVersion = new DefaultArtifactVersion(FLOW_SERVER_VERSION_130);
DefaultArtifactVersion clientVersion = new DefaultArtifactVersion(headerClientVersion);
DefaultArtifactVersion serverVersion = new DefaultArtifactVersion(serviceVersion);
if (clientVersion.compareTo(minimumSupportedVersion) >= 0 || clientVersion.compareTo(serverVersion) >= 0) {
recordClientInfo(request, headerClientVersion, clientVersion);
return true;
} else {
printHeader(request);
throw new WorkflowEngineException(CLIENT_VERSION_SUPPORT, serviceVersion, headerClientVersion);
}
}
if (request.getRequestURI().contains("/web/process/validate-auth")) {
return true;
}
if (request.getRequestURI().contains("/web/process/form")) {
HttpSession session = request.getSession();
// 检查session中是否有"已验证"标记
@ -97,57 +54,6 @@ public class RequestHeaderContextInterceptor implements HandlerInterceptor {
return true;
}
private void recordClientInfo(HttpServletRequest request, String headerClientVersion,
DefaultArtifactVersion clientVersion) {
String applicationName = request.getHeader(HEADER_SERVER_NAME);
log.info("HEADER_SERVER_NAME : {}", applicationName);
if (!StringUtils.hasText(applicationName)) {
return;
}
String manageableStatus = request.getHeader(ENABLE_MANAGEABLE);
Optional<ExtAxProperty> extAxProperty = extAxPropertyService.getByName(applicationName);
String cacheRepeatKey = REPEAT_KEY + applicationName;
log.info("repeatApi key: {}", cacheRepeatKey);
//success为true表示key不存在,执行成功,false表示key存在,执行失败
Boolean success = RedisUtils.trySetObject(cacheRepeatKey, "", Duration.ofSeconds(60));
if (success) {
KEY_CACHE.set(cacheRepeatKey);
insert(extAxProperty, applicationName, clientVersion, manageableStatus);
}
}
private void update(Optional<ExtAxProperty> extAxProperty, String requestApplicationName, DefaultArtifactVersion clientVersion, String manageableStatus) {
if (!extAxProperty.isPresent()) {
return;
}
ExtAxProperty property = extAxProperty.get();
if (Objects.equals(property.getValue(), clientVersion.toString())
&& Objects.equals(property.getManageable().toString(), manageableStatus)) {
return;
}
property.setName(requestApplicationName);
property.setValue(clientVersion.toString());
property.setManageable(Boolean.valueOf(manageableStatus));
extAxPropertyService.update(property);
}
private void insert(Optional<ExtAxProperty> extAxProperty, String requestApplicationName, DefaultArtifactVersion clientVersion, String manageableStatus) {
if (extAxProperty.isPresent()) {
update(extAxProperty, requestApplicationName, clientVersion, manageableStatus);
} else {
extAxPropertyService.add(extAxProperty.orElseGet(() -> {
ExtAxProperty property = new ExtAxProperty();
property.setCreated(true);
property.setName(requestApplicationName);
property.setValue(clientVersion.toString());
property.setManageable(Boolean.valueOf(manageableStatus));
return property;
}));
}
}
private void printHeader(HttpServletRequest request) {
Enumeration<String> headerNames = request.getHeaderNames();
log.info("parse header start, current uri: {}", request.getRequestURI());

View File

@ -20,6 +20,9 @@ import org.flowable.engine.RepositoryService;
import org.flowable.engine.RuntimeService;
import org.flowable.engine.delegate.DelegateExecution;
import org.flowable.engine.runtime.ProcessInstance;
import org.flowable.form.api.FormInfo;
import org.flowable.form.api.FormRepositoryService;
import org.flowable.form.model.SimpleFormModel;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Scope;
import org.springframework.core.Ordered;
@ -70,6 +73,8 @@ public class RocketMqBpmActivityEvent_100_Listener extends AbstractBpmnEventList
private EventProducer<?> eventProducer;
@Value("${sendMq:true}")
private Boolean sendMQ;
@Resource
private FormRepositoryService formRepositoryService;
@Override
public void onStart(DelegateExecution execution) {
@ -175,10 +180,29 @@ public class RocketMqBpmActivityEvent_100_Listener extends AbstractBpmnEventList
ProcessInstance processInstance = getContext().getProcessInstance(() ->
runtimeService.createProcessInstanceQuery().processInstanceId(execution.getProcessInstanceId())
.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)) {
dto.setProcessDefinitionKey(processInstance.getProcessDefinitionKey());
dto.setBusinessKey(processInstance.getBusinessKey());
dto.setVariables(removeBpmnConstantsVariables(processInstance.getProcessVariables()));
dto.setVariables(removeBpmnConstantsVariables(processInstance.getProcessVariables(), formModel.allFieldsAsMap().keySet()));
dto.setWorkflowEngineVersion(String.valueOf(processInstance.getProcessVariables()
.getOrDefault(WORKFLOW_ENGINE_VERSION, FLOW_SERVER_VERSION_121)));
} else {

View File

@ -27,6 +27,9 @@ import org.flowable.engine.RuntimeService;
import org.flowable.engine.TaskService;
import org.flowable.engine.impl.util.CommandContextUtil;
import org.flowable.engine.impl.util.ProcessDefinitionUtil;
import org.flowable.form.api.FormInfo;
import org.flowable.form.api.FormRepositoryService;
import org.flowable.form.model.SimpleFormModel;
import org.flowable.task.api.history.HistoricTaskInstance;
import org.flowable.task.service.impl.persistence.entity.TaskEntity;
import org.springframework.beans.factory.annotation.Value;
@ -121,6 +124,8 @@ public class RocketMqMessagePushEventListener extends AbstractBpmnEventListener<
private String serviceVersion;
@Value("${workflow.noticeTemplateCode}")
private String noticeTemplateCode;
@Resource
private FormRepositoryService formRepositoryService;
private static final List<String> REMOVE_KEYS = Lists.newArrayList(
INTERNAL_INITIATOR,
@ -212,7 +217,7 @@ public class RocketMqMessagePushEventListener extends AbstractBpmnEventListener<
TaskEntity task = (TaskEntity) taskService.createTaskQuery().taskId(event.getTaskId()).singleResult();
Boolean supportUpgrade = (Boolean) task.getTransientVariablesLocal().getOrDefault(SUPPORT_UPGRADE_VARIABLE, false);
if (!supportUpgrade) {
buttons.removeIf(button-> Objects.equals(button.getBtnKey(), BPMN_UPGRADE.getBtnKey()));
buttons.removeIf(button -> Objects.equals(button.getBtnKey(), BPMN_UPGRADE.getBtnKey()));
}
dto.setButtons(buttons);
sendMessageQueue(dto, PROCESS_PUSH_PENDING);
@ -435,6 +440,26 @@ public class RocketMqMessagePushEventListener extends AbstractBpmnEventListener<
}
});
}
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;
@ -463,7 +488,7 @@ public class RocketMqMessagePushEventListener extends AbstractBpmnEventListener<
.setTemplateId(templateId)
.setTaskId(event.getTaskId())
.setReceivePersons(event.getAssigners())
.setVariables(removeBpmnConstantsVariables(variables))
.setVariables(removeBpmnConstantsVariables(variables, null))
.setProcessApproveConf(event.getProcessApproveConfig())
.setActivitySignature(activitySignature)
.setTerminalType(terminalType);

View File

@ -19,6 +19,9 @@ import org.flowable.engine.delegate.event.FlowableProcessStartedEvent;
import org.flowable.engine.delegate.event.impl.FlowableProcessCancelledEventImpl;
import org.flowable.engine.impl.persistence.entity.ExecutionEntityImpl;
import org.flowable.engine.repository.Deployment;
import org.flowable.form.api.FormInfo;
import org.flowable.form.api.FormRepositoryService;
import org.flowable.form.model.SimpleFormModel;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Scope;
import org.springframework.core.Ordered;
@ -64,6 +67,8 @@ public class RocketMqBpmnProcessEventListener extends AbstractBpmnEventListener<
private RepositoryService repositoryService;
@Value("${sendMq:true}")
private Boolean sendMQ;
@Resource
private FormRepositoryService formRepositoryService;
@Override
public void onCreated(FlowableEngineEntityEvent event) {
@ -72,6 +77,26 @@ public class RocketMqBpmnProcessEventListener extends AbstractBpmnEventListener<
.deploymentId(((ExecutionEntityImpl) event.getEntity()).getDeploymentId()).singleResult());
Process mainProcess = getContext().getProcess(() -> repositoryService.getBpmnModel(event.getProcessDefinitionId()).getMainProcess());
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()
.setType(PROCESS_INSTANCE_CREATED)
.setCategory(deployment.getKey())
@ -81,7 +106,7 @@ public class RocketMqBpmnProcessEventListener extends AbstractBpmnEventListener<
.setProcessDefinitionKey(((ExecutionEntityImpl) event.getEntity()).getProcessDefinitionKey())
.setProcessDefinitionVersion(((ExecutionEntityImpl) event.getEntity()).getProcessDefinitionVersion())
.setInitiator(initiator)
.setVariables(removeBpmnConstantsVariables(((ExecutionEntityImpl) event.getEntity()).getVariables()))
.setVariables(removeBpmnConstantsVariables(((ExecutionEntityImpl) event.getEntity()).getVariables(), formModel.allFieldsAsMap().keySet()))
.setStartTime(((ExecutionEntityImpl) event.getEntity()).getStartTime())
.setTenantId(((ExecutionEntityImpl) event.getEntity()).getTenantId())
.setBusinessKey(((ExecutionEntityImpl) event.getEntity()).getBusinessKey())
@ -108,6 +133,26 @@ public class RocketMqBpmnProcessEventListener extends AbstractBpmnEventListener<
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()
.setType(PROCESS_INSTANCE_STARTED)
.setCategory(deployment.getKey())
@ -117,7 +162,7 @@ public class RocketMqBpmnProcessEventListener extends AbstractBpmnEventListener<
.setProcessDefinitionKey(((ExecutionEntityImpl) event.getEntity()).getProcessDefinitionKey())
.setProcessDefinitionVersion(((ExecutionEntityImpl) event.getEntity()).getProcessDefinitionVersion())
.setInitiator(initiator)
.setVariables(removeBpmnConstantsVariables(((ExecutionEntityImpl) event.getEntity()).getVariables()))
.setVariables(removeBpmnConstantsVariables(((ExecutionEntityImpl) event.getEntity()).getVariables(), formModel.allFieldsAsMap().keySet()))
.setStartTime(((ExecutionEntityImpl) event.getEntity()).getStartTime())
.setTenantId(((ExecutionEntityImpl) event.getEntity()).getTenantId())
.setBusinessKey(((ExecutionEntityImpl) event.getEntity()).getProcessInstance().getBusinessKey())
@ -139,6 +184,26 @@ public class RocketMqBpmnProcessEventListener extends AbstractBpmnEventListener<
Process mainProcess = getContext().getProcess(() -> repositoryService.getBpmnModel(event.getProcessDefinitionId()).getMainProcess());
BpmnTaskDelegateAssigner initiator = getContext().getInitiator(() -> BpmnTaskDelegateAssigner.toObjectCompatible(((FlowableProcessCancelledEventImpl) event)
.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()
.setType(PROCESS_INSTANCE_CANCELLED)
@ -151,7 +216,7 @@ public class RocketMqBpmnProcessEventListener extends AbstractBpmnEventListener<
.setInitiator(initiator)
.setLastOperationAssigner(getContext().getLastOperationAssigner(() -> BpmnTaskDelegateAssigner.toObjectCompatible(
runtimeService.getVariable(event.getProcessInstanceId(), CLOSE_PROCESS_ASSIGNER, BpmnTaskDelegateAssigner.class))))
.setVariables(removeBpmnConstantsVariables(((FlowableProcessCancelledEventImpl) event).getExecution().getVariables()))
.setVariables(removeBpmnConstantsVariables(((FlowableProcessCancelledEventImpl) event).getExecution().getVariables(), formModel.allFieldsAsMap().keySet()))
.setStartTime(((ExecutionEntityImpl) ((FlowableProcessCancelledEventImpl) event).getExecution()).getStartTime())
.setTenantId(((FlowableProcessCancelledEventImpl) event).getExecution().getTenantId())
.setBusinessKey(((FlowableProcessCancelledEventImpl) event).getExecution().getProcessInstanceBusinessKey())
@ -181,6 +246,26 @@ public class RocketMqBpmnProcessEventListener extends AbstractBpmnEventListener<
BpmnTaskDelegateAssigner initiator = getContext().getInitiator(() -> BpmnTaskDelegateAssigner.toObjectCompatible(((FlowableProcessCancelledEventImpl) event)
.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()
.setType(PROCESS_INSTANCE_REJECTED)
.setCategory(deployment.getKey())
@ -192,7 +277,7 @@ public class RocketMqBpmnProcessEventListener extends AbstractBpmnEventListener<
.setInitiator(initiator)
.setLastOperationAssigner(getContext().getLastOperationAssigner(() -> BpmnTaskDelegateAssigner.toObjectCompatible(
runtimeService.getVariable(event.getProcessInstanceId(), CLOSE_PROCESS_ASSIGNER, BpmnTaskDelegateAssigner.class))))
.setVariables(removeBpmnConstantsVariables(((FlowableProcessCancelledEventImpl) event).getExecution().getVariables()))
.setVariables(removeBpmnConstantsVariables(((FlowableProcessCancelledEventImpl) event).getExecution().getVariables(), formModel.allFieldsAsMap().keySet()))
.setStartTime(((ExecutionEntityImpl) ((FlowableProcessCancelledEventImpl) event).getExecution()).getStartTime())
.setTenantId(((FlowableProcessCancelledEventImpl) event).getExecution().getTenantId())
.setBusinessKey(((FlowableProcessCancelledEventImpl) event).getExecution().getProcessInstanceBusinessKey())
@ -217,6 +302,26 @@ public class RocketMqBpmnProcessEventListener extends AbstractBpmnEventListener<
BpmnTaskDelegateAssigner initiator = getContext().getInitiator(() -> BpmnTaskDelegateAssigner.toObjectCompatible(((FlowableProcessCancelledEventImpl) event)
.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()
.setType(PROCESS_INSTANCE_ABORTED)
.setCategory(deployment.getKey())
@ -228,7 +333,7 @@ public class RocketMqBpmnProcessEventListener extends AbstractBpmnEventListener<
.setInitiator(initiator)
.setLastOperationAssigner(getContext().getLastOperationAssigner(() -> BpmnTaskDelegateAssigner.toObjectCompatible(
runtimeService.getVariable(event.getProcessInstanceId(), CLOSE_PROCESS_ASSIGNER, BpmnTaskDelegateAssigner.class))))
.setVariables(removeBpmnConstantsVariables(((FlowableProcessCancelledEventImpl) event).getExecution().getVariables()))
.setVariables(removeBpmnConstantsVariables(((FlowableProcessCancelledEventImpl) event).getExecution().getVariables(), formModel.allFieldsAsMap().keySet()))
.setStartTime(((ExecutionEntityImpl) ((FlowableProcessCancelledEventImpl) event).getExecution()).getStartTime())
.setTenantId(((FlowableProcessCancelledEventImpl) event).getExecution().getTenantId())
.setBusinessKey(((FlowableProcessCancelledEventImpl) event).getExecution().getProcessInstanceBusinessKey())
@ -253,6 +358,26 @@ public class RocketMqBpmnProcessEventListener extends AbstractBpmnEventListener<
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()
.setType(PROCESS_INSTANCE_COMPLETED)
.setCategory(deployment.getKey())
@ -264,7 +389,7 @@ public class RocketMqBpmnProcessEventListener extends AbstractBpmnEventListener<
.setInitiator(initiator)
.setLastOperationAssigner(getContext().getLastOperationAssigner(() -> BpmnTaskDelegateAssigner.toObjectCompatible(
runtimeService.getVariable(event.getProcessInstanceId(), CLOSE_PROCESS_ASSIGNER, BpmnTaskDelegateAssigner.class))))
.setVariables(removeBpmnConstantsVariables(((ExecutionEntityImpl) event.getEntity()).getVariables()))
.setVariables(removeBpmnConstantsVariables(((ExecutionEntityImpl) event.getEntity()).getVariables(), formModel.allFieldsAsMap().keySet()))
.setStartTime(((ExecutionEntityImpl) event.getEntity()).getStartTime())
.setTenantId(((ExecutionEntityImpl) event.getEntity()).getTenantId())
.setBusinessKey(((ExecutionEntityImpl) event.getEntity()).getProcessInstanceBusinessKey())

View File

@ -18,6 +18,9 @@ import org.flowable.engine.RuntimeService;
import org.flowable.engine.TaskService;
import org.flowable.engine.repository.Deployment;
import org.flowable.engine.runtime.ProcessInstance;
import org.flowable.form.api.FormInfo;
import org.flowable.form.api.FormRepositoryService;
import org.flowable.form.model.SimpleFormModel;
import org.flowable.task.service.delegate.DelegateTask;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Scope;
@ -78,6 +81,8 @@ public class RocketMqBpmnTaskEvent_102_Listener extends AbstractBpmnEventListene
private RepositoryService repositoryService;
@Value("${sendMq:true}")
private Boolean sendMQ;
@Resource
private FormRepositoryService formRepositoryService;
@Override
public void onAssigned(DelegateTask delegateTask) {
@ -133,7 +138,7 @@ public class RocketMqBpmnTaskEvent_102_Listener extends AbstractBpmnEventListene
private Deployment getDeployment(String processInstanceId) {
ProcessInstance processInstance =
runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
return repositoryService.createDeploymentQuery().deploymentId(processInstance.getDeploymentId()).singleResult();
}
@ -142,26 +147,46 @@ public class RocketMqBpmnTaskEvent_102_Listener extends AbstractBpmnEventListene
//1.获取当前的流程实例
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(delegateTask.getProcessInstanceId()).singleResult();
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()
.setType(type)
.setCategory(category)
.setProcessDefinitionKey(category)
.setProcessTaskId(delegateTask.getId())
.setProcessInstanceId(delegateTask.getProcessInstanceId())
.setCurrentElementKey(delegateTask.getTaskDefinitionKey())
.setCurrentElementName(delegateTask.getName())
.setProcessDefinitionId(delegateTask.getProcessDefinitionId())
.setInitiator(BpmnTaskDelegateAssigner.toObjectCompatible(delegateTask.getVariable(INTERNAL_INITIATOR)))
.setApprover(BpmnTaskDelegateAssigner.toObjectCompatible(
delegateTask.getVariable(INTERNAL_TASK_RELATION_ASSIGNEE_INFO + delegateTask.getId())))
.setVariables(removeBpmnConstantsVariables(delegateTask.getVariables()))
.setStartTime(delegateTask.getCreateTime())
.setTenantId(delegateTask.getTenantId())
.setBusinessKey(processInstance.getBusinessKey())
.setAdvice(delegateTask.getTransientVariableLocal(COMMENT_TYPE_ADVICE) == null ? null : (String) delegateTask.getTransientVariableLocal(COMMENT_TYPE_ADVICE));
.setType(type)
.setCategory(category)
.setProcessDefinitionKey(category)
.setProcessTaskId(delegateTask.getId())
.setProcessInstanceId(delegateTask.getProcessInstanceId())
.setCurrentElementKey(delegateTask.getTaskDefinitionKey())
.setCurrentElementName(delegateTask.getName())
.setProcessDefinitionId(delegateTask.getProcessDefinitionId())
.setInitiator(BpmnTaskDelegateAssigner.toObjectCompatible(delegateTask.getVariable(INTERNAL_INITIATOR)))
.setApprover(BpmnTaskDelegateAssigner.toObjectCompatible(
delegateTask.getVariable(INTERNAL_TASK_RELATION_ASSIGNEE_INFO + delegateTask.getId())))
.setVariables(removeBpmnConstantsVariables(delegateTask.getVariables(), formModel.allFieldsAsMap().keySet()))
.setStartTime(delegateTask.getCreateTime())
.setTenantId(delegateTask.getTenantId())
.setBusinessKey(processInstance.getBusinessKey())
.setAdvice(delegateTask.getTransientVariableLocal(COMMENT_TYPE_ADVICE) == null ? null : (String) delegateTask.getTransientVariableLocal(COMMENT_TYPE_ADVICE));
BpmnMetaParserHelper.getNoticeConfig(mainProcess).ifPresent(dto::setNoticeConf);
String version = (String) runtimeService.getVariable(delegateTask.getProcessInstanceId(),
WORKFLOW_ENGINE_VERSION);
WORKFLOW_ENGINE_VERSION);
if (Objects.isNull(version)) {
version = FLOW_SERVER_VERSION_121;
}
@ -192,12 +217,12 @@ public class RocketMqBpmnTaskEvent_102_Listener extends AbstractBpmnEventListene
}
}
eventProducer.send(Event.builder()
.shardingKey(dto.getProcessInstanceId())
.eventCode(eventEnum.getEventCode())
.targetId(dto.getProcessInstanceId())
.targetType(dto.getProcessDefinitionKey())
.data(dto)
.build(), header);
.shardingKey(dto.getProcessInstanceId())
.eventCode(eventEnum.getEventCode())
.targetId(dto.getProcessInstanceId())
.targetType(dto.getProcessDefinitionKey())
.data(dto)
.build(), header);
}

View File

@ -31,6 +31,7 @@ import cn.axzo.workflow.common.model.request.bpmn.process.doc.ProcessDocQueryDTO
import cn.axzo.workflow.common.model.request.bpmn.task.BpmnTaskButtonSearchDTO;
import cn.axzo.workflow.common.model.request.bpmn.task.BpmnTaskDelegateAssigner;
import cn.axzo.workflow.common.model.request.form.ConditionPermissionMetaInfo;
import cn.axzo.workflow.common.model.request.form.instance.CooperationOrgUpdateDTO;
import cn.axzo.workflow.common.model.request.form.instance.FormVariablesUpdateDTO;
import cn.axzo.workflow.common.model.response.BpmPageResult;
import cn.axzo.workflow.common.model.response.bpmn.BatchOperationResultVO;
@ -549,6 +550,14 @@ public class BpmnProcessInstanceController extends BasicPopulateAvatarController
return CommonResponse.success(true);
}
@Operation(summary = "更新指定流程的CooperationOrg")
@PostMapping("/cooperation/update")
@Override
public CommonResponse<Boolean> updateCooperationOrg(@Validated @RequestBody CooperationOrgUpdateDTO dto) {
bpmnProcessInstanceService.overrideCooperationOrg(dto);
return CommonResponse.success(true);
}
@Override
@Operation(summary = "签署业务流程实例在审批待办中查询使用的文档列表")
@PostMapping("/select/doc/list")

View File

@ -5,8 +5,11 @@ import cn.axzo.workflow.client.feign.manage.FunctionApi;
import cn.axzo.workflow.common.enums.AdminDataSource;
import cn.axzo.workflow.common.enums.BpmnProcessInstanceResultEnum;
import cn.axzo.workflow.common.model.dto.CommonDingTalkDTO;
import cn.axzo.workflow.common.model.dto.ReportClientInfoDTO;
import cn.axzo.workflow.common.model.request.feature.DingTalkStarterAlterDTO;
import cn.axzo.workflow.core.conf.SupportRefreshProperties;
import cn.axzo.workflow.core.repository.entity.ExtAxProperty;
import cn.axzo.workflow.core.service.ExtAxPropertyService;
import cn.axzo.workflow.core.util.RivenDingTalkHelper;
import cn.axzo.workflow.server.common.annotation.ErrorReporter;
import cn.azxo.framework.common.model.CommonResponse;
@ -21,6 +24,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.Optional;
/**
* 功能性 API 控制器
@ -38,6 +42,8 @@ public class FunctionController implements FunctionApi {
private RivenDingTalkHelper rivenDingTalkHelper;
@Autowired
private SupportRefreshProperties supportRefreshProperties;
@Autowired
private ExtAxPropertyService extAxPropertyService;
/**
* 获取指定枚举类型的枚举值信息
@ -84,4 +90,28 @@ public class FunctionController implements FunctionApi {
rivenDingTalkHelper.sendMarkdownMessage(dto.getTitle(), dto.getContext(), dto.getTargetIsMaster(), dto.getAt(), dto.getMobiles());
return CommonResponse.success(true);
}
@Operation(summary = "上报客户端信息")
@PostMapping("/report/client/info")
@Override
public CommonResponse<Boolean> reportClientInfo(@Validated @RequestBody ReportClientInfoDTO dto) {
log.info("report client info : {}", JSON.toJSONString(dto));
Optional<ExtAxProperty> extAxProperty = extAxPropertyService.getByName(dto.getClientApplicationName());
if (extAxProperty.isPresent()) {
ExtAxProperty property = extAxProperty.get();
property.setValue(dto.getClientVersion());
property.setManageable(dto.getManageableStatus());
extAxPropertyService.update(property);
} else {
extAxPropertyService.add(extAxProperty.orElseGet(() -> {
ExtAxProperty property = new ExtAxProperty();
property.setCreated(true);
property.setName(dto.getClientApplicationName());
property.setValue(dto.getClientVersion());
property.setManageable(dto.getManageableStatus());
return property;
}));
}
return CommonResponse.success(true);
}
}

View File

@ -27,10 +27,12 @@ import cn.axzo.workflow.starter.mq.broadcast.consumer.InnerInstanceEventListener
import cn.axzo.workflow.starter.mq.broadcast.consumer.InnerNotificationEventListener;
import cn.axzo.workflow.starter.mq.broadcast.consumer.InnerTaskEventListener;
import cn.axzo.workflow.starter.mq.broadcast.consumer.InnerWorkflowListener;
import cn.axzo.workflow.starter.mq.check.ClientInfoReporter;
import cn.axzo.workflow.starter.mq.check.ImplementationReadyChecker;
import cn.axzo.workflow.starter.mq.monitor.WorkflowEngineStarterDefaultMQMonitor;
import cn.axzo.workflow.starter.mq.monitor.console.WorkflowEngineStarterMQMonitorController;
import cn.axzo.workflow.starter.selector.MetaFeignClientEnableSelector;
import cn.axzo.workflow.starter.util.LOGOPrinter;
import org.apache.commons.lang3.StringUtils;
import org.apache.rocketmq.client.exception.MQClientException;
import org.apache.rocketmq.common.MixAll;
@ -40,6 +42,7 @@ import org.apache.rocketmq.tools.admin.DefaultMQAdminExt;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
@ -48,6 +51,7 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.core.env.Environment;
import javax.annotation.PostConstruct;
import java.util.ArrayList;
import java.util.List;
@ -64,6 +68,11 @@ public class WorkflowEngineStarterAutoConfiguration {
private final Logger log = LoggerFactory.getLogger(WorkflowEngineStarterAutoConfiguration.class);
@PostConstruct
public void printLogo() {
LOGOPrinter.print();
}
@Bean
public ListenerExecutor listenerExecutor(WorkflowEngineStarterProperties starterProperties,
List<ExecuteInterceptor> additionalInterceptors) {
@ -173,4 +182,13 @@ public class WorkflowEngineStarterAutoConfiguration {
return new ImplementationReadyChecker(workflowCoreService);
}
@Bean
public ClientInfoReporter clientInfoReporter(WorkflowCoreService workflowCoreService,
Environment environment,
@Qualifier("serviceVersion") String serviceVersion) {
String applicationName = environment.getProperty("spring.application.name");
Boolean manageableStatus = Boolean.parseBoolean(environment.getProperty("workflow.manageable", "false"));
return new ClientInfoReporter(workflowCoreService, applicationName, serviceVersion, manageableStatus);
}
}

View File

@ -0,0 +1,45 @@
package cn.axzo.workflow.starter.mq.check;
import cn.axzo.workflow.common.model.dto.ReportClientInfoDTO;
import cn.axzo.workflow.starter.api.WorkflowCoreService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.ApplicationListener;
/**
* TODO
*
* @author wangli
* @since 2026-02-24 14:34
*/
@Slf4j
public class ClientInfoReporter implements ApplicationListener<ApplicationReadyEvent> {
private final WorkflowCoreService workflowCoreService;
private final String applicationName;
private final String clientVersion;
private final Boolean manageableStatus;
public ClientInfoReporter(WorkflowCoreService workflowCoreService,
String applicationName,
String clientVersion,
Boolean manageableStatus) {
this.workflowCoreService = workflowCoreService;
this.applicationName = applicationName;
this.clientVersion = clientVersion;
this.manageableStatus = manageableStatus;
}
@Override
public void onApplicationEvent(ApplicationReadyEvent event) {
log.info("application start success, reporting client info...");
try {
workflowCoreService.reportClientInfo(ReportClientInfoDTO.builder()
.clientApplicationName(applicationName)
.clientVersion(clientVersion)
.manageableStatus(manageableStatus)
.build());
} catch (Exception e) {
log.warn("error executing report client info : {}", e.getMessage(), e);
}
}
}

View File

@ -116,7 +116,11 @@ public class ImplementationReadyChecker implements ApplicationListener<Applicati
dto.setApplicationName(environment.getProperty("spring.application.name"));
dto.setProfile(environment.getProperty("spring.profiles.active"));
dto.setAlterContent("必接事件实现类检查未通过,未实现的方法: " + String.join(", ", unImplementedMethods) + "。请确保至少有一个实现类覆盖这些方法以处理相应的事件。");
workflowCoreService.sendDingtalk(dto);
try {
workflowCoreService.sendDingtalk(dto);
} catch (Exception e) {
log.warn("send dingtalk error: {}", e.getMessage(), e);
}
}
private static boolean[] checkUnImplementedMethodsWithInterface(ApplicationContext context) {

View File

@ -0,0 +1,47 @@
package cn.axzo.workflow.starter.util;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.ansi.AnsiColor;
import org.springframework.boot.ansi.AnsiOutput;
import java.util.Optional;
/**
* TODO
*
* @author wangli
* @since 2026-02-25 11:58
*/
@Slf4j
public class LOGOPrinter {
/**
* WorkflowEngine 当前版本号
*/
private static final String VERSION_NO = getVersion();
public static void print() {
StringBuilder str = new StringBuilder("\n");
str.append(
"================================================================================================\n");
str.append(" _ _ _ __ _ _____ _ \n");
str.append("| | | | | | / _| | | ___| (_)\n");
str.append("| | | | ___ _ __| | _| |_| | _____ _| |__ _ __ __ _ _ _ __ ___\n");
str.append("| |/\\| |/ _ \\| '__| |/ / _| |/ _ \\ \\ /\\ / / __| '_ \\ / _` | | '_ \\ / _ \\\n");
str.append("\\ /\\ / (_) | | | <| | | | (_) \\ V V /| |__| | | | (_| | | | | | __/\n");
str.append(" \\/ \\/ \\___/|_| |_|\\_\\_| |_|\\___/ \\_/\\_/ \\____/_| |_|\\__, |_|_| |_|\\___|\n");
str.append(" __/ |\n");
str.append(" |___/\n");
str.append(" Version: ");
str.append(AnsiOutput.toString(AnsiColor.GREEN, VERSION_NO, AnsiColor.DEFAULT));
str.append("\n");
str.append(" Document: https://alidocs.dingtalk.com/i/nodes/QOG9lyrgJPR71pQqI9ZqnM7XWzN67Mw4\n");
str.append(
"================================================================================================\n");
log.info(str.toString());
}
private static String getVersion() {
return Optional.ofNullable(LOGOPrinter.class.getPackage()).map(Package::getImplementationVersion).orElse("DEV");
}
}