update - 在发送待办时,透传用于查询能用按钮的前置数据

This commit is contained in:
wangli 2024-04-22 16:59:50 +08:00
parent a85126357d
commit 98e3292257
6 changed files with 69 additions and 8 deletions

View File

@ -86,9 +86,13 @@ public class CustomTaskHelper {
} }
private static void setParentTaskId(TaskEntity originTask, Execution subExecution) { private static void setParentTaskId(TaskEntity originTask, Execution subExecution) {
CommandContextUtil.getEntityCache().findInCache(TaskEntity.class).stream().filter(i -> Objects.equals(i.getExecutionId(), subExecution.getId())).findAny().ifPresent(i -> i.setParentTaskId(originTask.getId())); CommandContextUtil.getEntityCache().findInCache(TaskEntity.class).stream()
.filter(i -> Objects.equals(i.getExecutionId(), subExecution.getId()))
.findAny().ifPresent(i -> i.setParentTaskId(originTask.getId()));
CommandContextUtil.getEntityCache().findInCache(HistoricTaskInstanceEntity.class).stream().filter(i -> Objects.equals(i.getExecutionId(), subExecution.getId())).findAny().ifPresent(i -> i.setParentTaskId(originTask.getId())); CommandContextUtil.getEntityCache().findInCache(HistoricTaskInstanceEntity.class).stream()
.filter(i -> Objects.equals(i.getExecutionId(), subExecution.getId()))
.findAny().ifPresent(i -> i.setParentTaskId(originTask.getId()));
} }
/** /**

View File

@ -20,6 +20,10 @@ public interface MessagePushEvent extends FlowableEvent {
String getProcessInstanceId(); String getProcessInstanceId();
String getProcessDefinitionKey();
String getCurrentTaskDefinitionKey();
String getTenantId(); String getTenantId();
String getTaskId(); String getTaskId();

View File

@ -53,9 +53,10 @@ public class MessagePushEventBuilder {
public static MessagePushEventImpl createPendingPushEvent(List<BpmnTaskDelegateAssigner> assigners, public static MessagePushEventImpl createPendingPushEvent(List<BpmnTaskDelegateAssigner> assigners,
BpmnNoticeConf noticeConf, String processInstanceId, BpmnNoticeConf noticeConf, String processInstanceId,
String processDefinitionId, String currentTaskDefinitionKey,
String tenantId, String taskId) { String tenantId, String taskId) {
MessagePushEventImpl newEvent = new MessagePushEventImpl(PENDING_PUSH, assigners, noticeConf, processInstanceId, MessagePushEventImpl newEvent = new MessagePushEventImpl(PENDING_PUSH, assigners, noticeConf, processInstanceId,
tenantId, taskId); processDefinitionId, currentTaskDefinitionKey, tenantId, taskId);
return newEvent; return newEvent;
} }

View File

@ -19,6 +19,8 @@ public class MessagePushEventImpl implements MessagePushEvent {
private List<BpmnTaskDelegateAssigner> assigners; private List<BpmnTaskDelegateAssigner> assigners;
private BpmnNoticeConf noticeConfig; private BpmnNoticeConf noticeConfig;
private String processInstanceId; private String processInstanceId;
private String processDefinitionId;
private String currentTaskDefinitionKey;
private String tenantId; private String tenantId;
private String taskId; private String taskId;
@ -35,14 +37,13 @@ public class MessagePushEventImpl implements MessagePushEvent {
* 该对象的消费场景会对 taskId 做条件判断 * 该对象的消费场景会对 taskId 做条件判断
* *
* @param type * @param type
* @param assigner * @param assigners
* @param noticeConfig * @param noticeConfig
* @param processInstanceId * @param processInstanceId
* @param tenantId * @param tenantId
* @param taskId * @param taskId
*/ */
public MessagePushEventImpl(FlowableEventType type, List<BpmnTaskDelegateAssigner> assigners, public MessagePushEventImpl(FlowableEventType type, List<BpmnTaskDelegateAssigner> assigners, BpmnNoticeConf noticeConfig, String processInstanceId, String tenantId, String taskId) {
BpmnNoticeConf noticeConfig, String processInstanceId, String tenantId, String taskId) {
this.type = type; this.type = type;
this.assigners = assigners; this.assigners = assigners;
this.noticeConfig = noticeConfig; this.noticeConfig = noticeConfig;
@ -51,6 +52,33 @@ public class MessagePushEventImpl implements MessagePushEvent {
this.taskId = taskId; this.taskId = taskId;
} }
/**
* 使用该对象时需遵守,如果是 task 级的,一定要传 taskId, 其他参数则都是必传
* <p>
* 该对象的消费场景会对 taskId 做条件判断
*
* @param type
* @param assigners
* @param noticeConfig
* @param processInstanceId
* @param processDefinitionId
* @param currentTaskDefinitionKey
* @param tenantId
* @param taskId
*/
public MessagePushEventImpl(FlowableEventType type, List<BpmnTaskDelegateAssigner> assigners,
BpmnNoticeConf noticeConfig, String processInstanceId, String processDefinitionId,
String currentTaskDefinitionKey, String tenantId, String taskId) {
this.type = type;
this.assigners = assigners;
this.noticeConfig = noticeConfig;
this.processInstanceId = processInstanceId;
this.processDefinitionId = processDefinitionId;
this.currentTaskDefinitionKey = currentTaskDefinitionKey;
this.tenantId = tenantId;
this.taskId = taskId;
}
@Override @Override
public FlowableEventType getType() { public FlowableEventType getType() {
return type; return type;
@ -83,10 +111,32 @@ public class MessagePushEventImpl implements MessagePushEvent {
return processInstanceId; return processInstanceId;
} }
@Override
public String getProcessDefinitionKey() {
return "";
}
public void setProcessInstanceId(String processInstanceId) { public void setProcessInstanceId(String processInstanceId) {
this.processInstanceId = processInstanceId; this.processInstanceId = processInstanceId;
} }
public String getProcessDefinitionId() {
return processDefinitionId;
}
public void setProcessDefinitionId(String processDefinitionId) {
this.processDefinitionId = processDefinitionId;
}
@Override
public String getCurrentTaskDefinitionKey() {
return currentTaskDefinitionKey;
}
public void setCurrentTaskDefinitionKey(String currentTaskDefinitionKey) {
this.currentTaskDefinitionKey = currentTaskDefinitionKey;
}
@Override @Override
public String getTenantId() { public String getTenantId() {
return tenantId; return tenantId;

View File

@ -144,6 +144,7 @@ public class RocketMqMessagePushEventListener extends AbstractBpmnEventListener<
JSONUtil.toJsonStr(event.getAssigners())); JSONUtil.toJsonStr(event.getAssigners()));
} }
if (Objects.nonNull(event.getNoticeConfig().getPending())) { if (Objects.nonNull(event.getNoticeConfig().getPending())) {
// TODO 发送待办时, 计算当前人能操作的按钮有哪些?
MessagePushDTO dto = build(event.getNoticeConfig().getPending().getPendingMessageId(), MessagePushDTO dto = build(event.getNoticeConfig().getPending().getPendingMessageId(),
PROCESS_PUSH_PENDING, event, collectionVariable(event)); PROCESS_PUSH_PENDING, event, collectionVariable(event));
sendMessageQueue(dto, PROCESS_PUSH_PENDING); sendMessageQueue(dto, PROCESS_PUSH_PENDING);

View File

@ -152,8 +152,9 @@ public class MessagePushTaskEvent_103_Listener extends AbstractBpmnEventListener
assigners.stream().filter(i -> Objects.equals(delegateTask.getAssignee(), i.buildAssigneeId())).findAny() assigners.stream().filter(i -> Objects.equals(delegateTask.getAssignee(), i.buildAssigneeId())).findAny()
.ifPresent(i -> { .ifPresent(i -> {
MessagePushEventImpl event = MessagePushEventImpl event =
MessagePushEventBuilder.createEvent(MessagePushEventType.PENDING_PUSH, MessagePushEventBuilder.createPendingPushEvent(Lists.newArrayList(i),
Lists.newArrayList(i), noticeConf, processInstance.getProcessInstanceId(), noticeConf, processInstance.getProcessInstanceId(),
processInstance.getProcessDefinitionId(), userTask.getId(),
processInstance.getTenantId(), delegateTask.getId()); processInstance.getTenantId(), delegateTask.getId());
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("发送推送待办的消息: {}", JSONUtil.toJsonStr(event)); log.debug("发送推送待办的消息: {}", JSONUtil.toJsonStr(event));