REQ-3502: 过滤流程按钮

This commit is contained in:
yanglin 2025-01-14 17:34:06 +08:00
parent 8399113a5f
commit 4d7cb395da
2 changed files with 25 additions and 13 deletions

View File

@ -7,6 +7,7 @@ import cn.axzo.msg.center.service.enums.BizFinalStateEnum;
import cn.axzo.msg.center.service.enums.PendingMessageStateEnum;
import cn.axzo.msg.center.service.enums.RouterButtonSourceEnum;
import cn.axzo.msg.center.utils.desision.DecisionValue;
import cn.axzo.workflow.common.enums.BpmnProcessTaskResultEnum;
import cn.axzo.workflow.common.enums.ButtonVisibleScopeEnum;
import cn.axzo.workflow.common.model.request.bpmn.BpmnButtonMetaInfo;
import cn.axzo.workflow.common.model.response.bpmn.task.BpmnTaskButtonVo;
@ -30,7 +31,7 @@ import static java.util.stream.Collectors.toSet;
class WorkflowTodoCardButtonInterceptor implements CardButtonInterceptor {
private final Todo todo;
private final BpmnTaskButtonVo workflowButtons;
private final BpmnTaskButtonVo taskInfo;
@Override
public DecisionValue<Boolean> isPerformActionAvailable(ButtonV3 button) {
@ -43,7 +44,18 @@ class WorkflowTodoCardButtonInterceptor implements CardButtonInterceptor {
BizFinalStateEnum state = findButtonClickState(button).orElse(null);
if (state == null)
return DecisionValue.decide(false);
return DecisionValue.decide(todo.getState() == PendingMessageStateEnum.COMPLETED);
if (todo.getState() != PendingMessageStateEnum.COMPLETED)
return DecisionValue.decide(false);
if (taskInfo.getTaskResult() == BpmnProcessTaskResultEnum.APPROVED
&& state == BizFinalStateEnum.PASSED)
return DecisionValue.decide(true);
if (taskInfo.getTaskResult() == BpmnProcessTaskResultEnum.REJECTED
&& state == BizFinalStateEnum.REJECTED)
return DecisionValue.decide(true);
if (taskInfo.getTaskResult() == BpmnProcessTaskResultEnum.DELETED
&& state == BizFinalStateEnum.RETRACT)
return DecisionValue.decide(true);
return DecisionValue.decide(false);
}
@Override
@ -100,7 +112,7 @@ class WorkflowTodoCardButtonInterceptor implements CardButtonInterceptor {
}
private Optional<BpmnButtonMetaInfoWithVisibleScope> findWorkflowButton(ButtonV3 button) {
List<BpmnButtonMetaInfoWithVisibleScope> workflowButtons = this.workflowButtons.getButtons();
List<BpmnButtonMetaInfoWithVisibleScope> workflowButtons = this.taskInfo.getButtons();
if (workflowButtons == null)
workflowButtons = Collections.emptyList();
return workflowButtons.stream()
@ -109,11 +121,11 @@ class WorkflowTodoCardButtonInterceptor implements CardButtonInterceptor {
}
private Set<String> getWorkflowHideButtonKeys() {
return getWorkflowHideButtonKeys(workflowButtons);
return getWorkflowHideButtonKeys(taskInfo);
}
static Set<String> getWorkflowHideButtonKeys(BpmnTaskButtonVo workflowButtons) {
List<BpmnButtonMetaInfo> workflowHiddenButtons = workflowButtons.getCustomHiddenButtons();
static Set<String> getWorkflowHideButtonKeys(BpmnTaskButtonVo taskInfo) {
List<BpmnButtonMetaInfo> workflowHiddenButtons = taskInfo.getCustomHiddenButtons();
if (workflowHiddenButtons == null)
workflowHiddenButtons = Collections.emptyList();
return workflowHiddenButtons.stream()
@ -121,8 +133,8 @@ class WorkflowTodoCardButtonInterceptor implements CardButtonInterceptor {
.collect(toSet());
}
static Set<WorkflowButtonInfo> getWorkflowButtons(BpmnTaskButtonVo workflowButtons) {
List<BpmnButtonMetaInfoWithVisibleScope> workflowHiddenButtons = workflowButtons.getButtons();
static Set<WorkflowButtonInfo> getTaskInfo(BpmnTaskButtonVo taskInfo) {
List<BpmnButtonMetaInfoWithVisibleScope> workflowHiddenButtons = taskInfo.getButtons();
if (workflowHiddenButtons == null)
workflowHiddenButtons = Collections.emptyList();
return workflowHiddenButtons.stream()

View File

@ -46,17 +46,17 @@ class WorkflowTodoCardButtonInterceptorFactory implements CardButtonInterceptorF
log.warn("todo not found. identityCode={}", card.getBizParam());
return null;
}
BpmnTaskButtonVo workflowButtons = fetchWorkflowButtons(todo);
BizAssertions.assertNotNull(workflowButtons,
BpmnTaskButtonVo taskInfo = fetchWorkflowButtons(todo);
BizAssertions.assertNotNull(taskInfo,
"workflow buttons not found. todoIdentityCode={}", todo.getIdentityCode());
HashMap<String, Object> workflowButtonInfo = new HashMap<>();
workflowButtonInfo.put("workflowHideButtonKeys", WorkflowTodoCardButtonInterceptor
.getWorkflowHideButtonKeys(workflowButtons));
.getWorkflowHideButtonKeys(taskInfo));
workflowButtonInfo.put("workflowButtons", WorkflowTodoCardButtonInterceptor
.getWorkflowButtons(workflowButtons));
.getTaskInfo(taskInfo));
log.info("fetchWorkflowButtons, todoIdentityCode={}, workflowButtonInfo: {}",
todo.getIdentityCode(), JSON.toJSONString(workflowButtonInfo));
return new WorkflowTodoCardButtonInterceptor(todo, workflowButtons);
return new WorkflowTodoCardButtonInterceptor(todo, taskInfo);
}
BpmnTaskButtonVo fetchWorkflowButtons(Todo todo) {