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) {
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 getProcessDefinitionKey();
String getCurrentTaskDefinitionKey();
String getTenantId();
String getTaskId();

View File

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

View File

@ -19,6 +19,8 @@ public class MessagePushEventImpl implements MessagePushEvent {
private List<BpmnTaskDelegateAssigner> assigners;
private BpmnNoticeConf noticeConfig;
private String processInstanceId;
private String processDefinitionId;
private String currentTaskDefinitionKey;
private String tenantId;
private String taskId;
@ -35,14 +37,13 @@ public class MessagePushEventImpl implements MessagePushEvent {
* 该对象的消费场景会对 taskId 做条件判断
*
* @param type
* @param assigner
* @param assigners
* @param noticeConfig
* @param processInstanceId
* @param tenantId
* @param taskId
*/
public MessagePushEventImpl(FlowableEventType type, List<BpmnTaskDelegateAssigner> assigners,
BpmnNoticeConf noticeConfig, String processInstanceId, String tenantId, String taskId) {
public MessagePushEventImpl(FlowableEventType type, List<BpmnTaskDelegateAssigner> assigners, BpmnNoticeConf noticeConfig, String processInstanceId, String tenantId, String taskId) {
this.type = type;
this.assigners = assigners;
this.noticeConfig = noticeConfig;
@ -51,6 +52,33 @@ public class MessagePushEventImpl implements MessagePushEvent {
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
public FlowableEventType getType() {
return type;
@ -83,10 +111,32 @@ public class MessagePushEventImpl implements MessagePushEvent {
return processInstanceId;
}
@Override
public String getProcessDefinitionKey() {
return "";
}
public void setProcessInstanceId(String 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
public String getTenantId() {
return tenantId;

View File

@ -144,6 +144,7 @@ public class RocketMqMessagePushEventListener extends AbstractBpmnEventListener<
JSONUtil.toJsonStr(event.getAssigners()));
}
if (Objects.nonNull(event.getNoticeConfig().getPending())) {
// TODO 发送待办时, 计算当前人能操作的按钮有哪些?
MessagePushDTO dto = build(event.getNoticeConfig().getPending().getPendingMessageId(),
PROCESS_PUSH_PENDING, event, collectionVariable(event));
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()
.ifPresent(i -> {
MessagePushEventImpl event =
MessagePushEventBuilder.createEvent(MessagePushEventType.PENDING_PUSH,
Lists.newArrayList(i), noticeConf, processInstance.getProcessInstanceId(),
MessagePushEventBuilder.createPendingPushEvent(Lists.newArrayList(i),
noticeConf, processInstance.getProcessInstanceId(),
processInstance.getProcessDefinitionId(), userTask.getId(),
processInstance.getTenantId(), delegateTask.getId());
if (log.isDebugEnabled()) {
log.debug("发送推送待办的消息: {}", JSONUtil.toJsonStr(event));