REQ-3502: 按钮排序

This commit is contained in:
yanglin 2025-01-15 15:44:12 +08:00
parent b03b7750bb
commit f5f42f06d5
3 changed files with 203 additions and 9 deletions

View File

@ -58,14 +58,176 @@ class WorkflowTodoCardButtonInterceptorFactory implements CardButtonInterceptorF
}
BpmnTaskButtonVo fetchWorkflowButtons(Todo todo) {
TodoBusiness business = todoBusinessDao.getBusinesses(todo).findBusiness(todo).orElse(null);
BizAssertions.assertNotNull(business, "todo business not found. todoIdentityCode={}", todo.getIdentityCode());
BpmnTaskButtonSearchDTO workflowRequest = new BpmnTaskButtonSearchDTO();
workflowRequest.setProcessInstanceId(todo.getBizCode());
workflowRequest.setTaskId(todo.getSubBizCode());
workflowRequest.setInitiatorPersonId(business.getPromoterPersonId());
workflowRequest.setExecutorPersonId(todo.getExecutorPersonId());
return workflowCoreService.findProcessSingleTaskButtons(workflowRequest);
String json = "{\n" +
" \"buttons\": [\n" +
" {\n" +
" \"type\": \"SYSTEM\",\n" +
" \"order\": 7,\n" +
" \"btnKey\": \"BPMN_ROLLBACK\",\n" +
" \"btnName\": \"回退\",\n" +
" \"checked\": true,\n" +
" \"disabled\": false,\n" +
" \"visibleScopes\": [\n" +
" \"EXECUTOR\"\n" +
" ]\n" +
" },\n" +
" {\n" +
" \"type\": \"SYSTEM\",\n" +
" \"order\": 6,\n" +
" \"btnKey\": \"BPMN_COMMENT\",\n" +
" \"btnName\": \"评论\",\n" +
" \"checked\": true,\n" +
" \"disabled\": false,\n" +
" \"visibleScopes\": [\n" +
" \"INITIATOR\",\n" +
" \"EXECUTOR\"\n" +
" ]\n" +
" },\n" +
" {\n" +
" \"type\": \"SYSTEM\",\n" +
" \"order\": 1,\n" +
" \"btnKey\": \"BPMN_APPROVE\",\n" +
" \"btnName\": \"同意\",\n" +
" \"checked\": true,\n" +
" \"disabled\": false,\n" +
" \"visibleScopes\": [\n" +
" \"EXECUTOR\"\n" +
" ]\n" +
" },\n" +
" {\n" +
" \"type\": \"SYSTEM\",\n" +
" \"order\": 4,\n" +
" \"btnKey\": \"BPMN_TRANSFER\",\n" +
" \"btnName\": \"转交\",\n" +
" \"checked\": true,\n" +
" \"disabled\": false,\n" +
" \"visibleScopes\": [\n" +
" \"EXECUTOR\"\n" +
" ]\n" +
" },\n" +
" {\n" +
" \"type\": \"SYSTEM\",\n" +
" \"order\": 2,\n" +
" \"btnKey\": \"BPMN_REJECT\",\n" +
" \"btnName\": \"驳回\",\n" +
" \"checked\": true,\n" +
" \"disabled\": false,\n" +
" \"visibleScopes\": [\n" +
" \"EXECUTOR\"\n" +
" ]\n" +
" },\n" +
" {\n" +
" \"type\": \"SYSTEM\",\n" +
" \"order\": 8,\n" +
" \"btnKey\": \"BPMN_COPY\",\n" +
" \"btnName\": \"抄送\",\n" +
" \"checked\": true,\n" +
" \"disabled\": false,\n" +
" \"visibleScopes\": [\n" +
" \"EXECUTOR\"\n" +
" ]\n" +
" },\n" +
" {\n" +
" \"type\": \"SYSTEM\",\n" +
" \"order\": 3,\n" +
" \"btnKey\": \"BPMN_REVOCATION\",\n" +
" \"btnName\": \"撤回\",\n" +
" \"checked\": true,\n" +
" \"disabled\": false,\n" +
" \"visibleScopes\": [\n" +
" \"INITIATOR\"\n" +
" ]\n" +
" },\n" +
" {\n" +
" \"type\": \"SYSTEM\",\n" +
" \"order\": 5,\n" +
" \"btnKey\": \"BPMN_COUNTERSIGN\",\n" +
" \"btnName\": \"加签\",\n" +
" \"checked\": true,\n" +
" \"disabled\": false,\n" +
" \"visibleScopes\": [\n" +
" \"EXECUTOR\"\n" +
" ]\n" +
" }\n" +
" ],\n" +
" \"allConfigButtons\": [\n" +
" {\n" +
" \"type\": \"SYSTEM\",\n" +
" \"order\": 1,\n" +
" \"btnKey\": \"BPMN_APPROVE\",\n" +
" \"btnName\": \"同意\",\n" +
" \"checked\": true,\n" +
" \"disabled\": false\n" +
" },\n" +
" {\n" +
" \"type\": \"SYSTEM\",\n" +
" \"order\": 2,\n" +
" \"btnKey\": \"BPMN_REJECT\",\n" +
" \"btnName\": \"驳回\",\n" +
" \"checked\": true,\n" +
" \"disabled\": false\n" +
" },\n" +
" {\n" +
" \"type\": \"SYSTEM\",\n" +
" \"order\": 3,\n" +
" \"btnKey\": \"BPMN_REVOCATION\",\n" +
" \"btnName\": \"撤回\",\n" +
" \"checked\": false,\n" +
" \"disabled\": true\n" +
" },\n" +
" {\n" +
" \"type\": \"SYSTEM\",\n" +
" \"order\": 4,\n" +
" \"btnKey\": \"BPMN_TRANSFER\",\n" +
" \"btnName\": \"转交\",\n" +
" \"checked\": true,\n" +
" \"disabled\": false\n" +
" },\n" +
" {\n" +
" \"type\": \"SYSTEM\",\n" +
" \"order\": 5,\n" +
" \"btnKey\": \"BPMN_COUNTERSIGN\",\n" +
" \"btnName\": \"加签\",\n" +
" \"checked\": true,\n" +
" \"disabled\": false\n" +
" },\n" +
" {\n" +
" \"type\": \"SYSTEM\",\n" +
" \"order\": 6,\n" +
" \"btnKey\": \"BPMN_COMMENT\",\n" +
" \"btnName\": \"评论\",\n" +
" \"checked\": true,\n" +
" \"disabled\": false\n" +
" },\n" +
" {\n" +
" \"type\": \"SYSTEM\",\n" +
" \"order\": 7,\n" +
" \"btnKey\": \"BPMN_ROLLBACK\",\n" +
" \"btnName\": \"回退\",\n" +
" \"checked\": true,\n" +
" \"disabled\": false\n" +
" },\n" +
" {\n" +
" \"type\": \"SYSTEM\",\n" +
" \"order\": 8,\n" +
" \"btnKey\": \"BPMN_COPY\",\n" +
" \"btnName\": \"抄送\",\n" +
" \"checked\": true,\n" +
" \"disabled\": false\n" +
" }\n" +
" ],\n" +
" \"executorTaskResult\": \"PROCESSING\",\n" +
" \"customHiddenButtons\": []\n" +
" }";
return JSON.parseObject(json, BpmnTaskButtonVo.class);
//TodoBusiness business = todoBusinessDao.getBusinesses(todo).findBusiness(todo).orElse(null);
//BizAssertions.assertNotNull(business, "todo business not found. todoIdentityCode={}", todo.getIdentityCode());
//BpmnTaskButtonSearchDTO workflowRequest = new BpmnTaskButtonSearchDTO();
//workflowRequest.setProcessInstanceId(todo.getBizCode());
//workflowRequest.setTaskId(todo.getSubBizCode());
//workflowRequest.setInitiatorPersonId(business.getPromoterPersonId());
//workflowRequest.setExecutorPersonId(todo.getExecutorPersonId());
//return workflowCoreService.findProcessSingleTaskButtons(workflowRequest);
}
}

View File

@ -15,6 +15,7 @@ import cn.axzo.msg.center.service.pending.response.v3.model.ParsedTemplateV3;
import org.apache.commons.collections4.CollectionUtils;
import java.util.ArrayList;
import java.util.Comparator;
/**
* @author yanglin
@ -40,7 +41,9 @@ public class ParsedModelV3Walker {
}
for (ParsedGroupV3 group : new ArrayList<>(model.determineGroups()))
visitGroup(visitor, group);
for (ParsedButtonV3 button : new ArrayList<>(model.determineButtons()))
ArrayList<ParsedButtonV3> buttons = new ArrayList<>(model.determineButtons());
buttons.sort(Comparator.comparingInt(ParsedButtonV3::determinePriority));
for (ParsedButtonV3 button : buttons)
visitButton(visitor, button);
if (template != null)
visitor.exitTemplate(template);

View File

@ -0,0 +1,29 @@
package cn.axzo.msg.center.message.service.todo.card;
import cn.axzo.framework.rocketmq.Event;
import cn.axzo.msg.center.MsgCenterApplication;
import cn.axzo.msg.center.api.mq.TodoUpdateMessage;
import com.alibaba.fastjson.JSON;
import lombok.RequiredArgsConstructor;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import static org.junit.jupiter.api.Assertions.*;
/**
* @author yanglin
*/
@SpringBootTest(classes = MsgCenterApplication.class)
@RequiredArgsConstructor(onConstructor_ = @Autowired)
class TodoSyncCardServiceTest {
private final TodoSyncCardService todoSyncCardService;
@Test
void exec() {
String json = "{\"messageId\": \"d6b3b687-6ab9-416e-9836-6245d9043125\", \"messageSendTime\": 1736926166387, \"messageSendTimeStr\": \"2025-01-15 15:29:26\", \"operation\": \"send\", \"updateCard\": true, \"updatedTodo\": {\"bizCategory\": \"FLOW\", \"bizCode\": \"202501151529100000000\", \"bizDesc\": \"审批节点\", \"bizExtParam\": {\"[_BIZ_NODE_ALTER_]node_065414499288\": {\"activityId\": \"node_065414499288\", \"processInstanceId\": \"202501151529100000000\", \"retries\": 2}, \"[_INTERNAL_INITIATOR_]\": {\"assignerName\": \"杨期成\", \"ouId\": \"10401\", \"tenantId\": \"4949\", \"personId\": \"9000400630\", \"assignee\": \"1229802\", \"assigneeType\": \"3\", \"avatar\": \"https://axzo-public.oss-cn-chengdu.aliyuncs.com/oms/oms/cac12b80cac342b5b9fcef5f470b189e.jpg\"}, \"businessName\": \"工作流开发测试项目业务\", \"initiatorUserName\": \"杨期成\", \"[_INTERNAL_PROCESS_AGENT]\": true, \"activityId\": \"node_065414499288\", \"processStartTime\": \"2025-01-15 15:29:25\", \"assigneeName\": \"10400|9000400630\", \"processInstanceId\": \"202501151529100000000\", \"nrOfActiveInstances\": 1, \"[_INTERNAL_PROCESS_WORKSPACE_TYPE]\": 2, \"activityName\": \"审批节点\", \"processResult\": \"审批中\", \"[_CREATE_INSTANCE_PARAMS]\": \"{\\\"processDefinitionKey\\\":\\\"wfTestProj\\\",\\\"tenantId\\\":\\\"4949\\\",\\\"variables\\\":{\\\"[_INTERNAL_PROCESS_WORKSPACE_TYPE]\\\":2,\\\"[_INTERNAL_INITIATOR_]\\\":\\\"{\\\\\\\"assignee\\\\\\\":\\\\\\\"1229802\\\\\\\",\\\\\\\"assigneeType\\\\\\\":\\\\\\\"3\\\\\\\",\\\\\\\"assignerName\\\\\\\":\\\\\\\"杨期成\\\\\\\",\\\\\\\"avatar\\\\\\\":\\\\\\\"https://axzo-public.oss-cn-chengdu.aliyuncs.com/oms/oms/cac12b80cac342b5b9fcef5f470b189e.jpg\\\\\\\",\\\\\\\"ouId\\\\\\\":\\\\\\\"10401\\\\\\\",\\\\\\\"personId\\\\\\\":\\\\\\\"9000400630\\\\\\\",\\\\\\\"tenantId\\\\\\\":\\\\\\\"4949\\\\\\\"}\\\",\\\"[_BIZ_ORG_RELATION_]\\\":{\\\"orgScopes\\\":[{\\\"workspaceType\\\":2,\\\"workspaceId\\\":4949,\\\"ouId\\\":10401,\\\"nodeId\\\":21335}]},\\\"[_WORKFLOW_ENGINE_VERSION_]\\\":\\\"1.5.1\\\",\\\"[_PENDING_VARIABLES]\\\":{},\\\"[_INTERNAL_PROCESS_AGENT]\\\":true},\\\"pendingVariables\\\":{},\\\"cooperationOrg\\\":{\\\"orgScopes\\\":[{\\\"workspaceType\\\":2,\\\"workspaceId\\\":4949,\\\"ouId\\\":10401,\\\"nodeId\\\":21335}]},\\\"businessKey\\\":\\\"40\\\",\\\"initiator\\\":{\\\"assignee\\\":\\\"1229802\\\",\\\"assigneeType\\\":\\\"3\\\",\\\"assignerName\\\":\\\"杨期成\\\",\\\"personId\\\":\\\"9000400630\\\",\\\"tenantId\\\":\\\"4949\\\",\\\"ouId\\\":\\\"10401\\\",\\\"avatar\\\":\\\"https://axzo-public.oss-cn-chengdu.aliyuncs.com/oms/oms/cac12b80cac342b5b9fcef5f470b189e.jpg\\\"},\\\"async\\\":false,\\\"startFormVariables\\\":{}}\", \"taskStartTime\": \"2025-01-15 15:29:25\", \"taskUserName\": \"杨期成\", \"[_WORKFLOW_ENGINE_VERSION_]\": \"1.5.1\", \"tenantId\": \"4949\", \"businessKey\": \"40\", \"operatorType\": \"\", \"taskId\": \"202501151529100000049\", \"[_PENDING_VARIABLES]\": {}, \"processInstanceName\": \"工作流业务测试项目流程\", \"nrOfCompletedInstances\": 0}, \"bizFinalState\": null, \"bizFlag\": \"\", \"content\": \"你好\", \"deadline\": null, \"executorId\": 0, \"executorName\": \"杨期成\", \"executorOuId\": 10400, \"executorPersonId\": 9000400630, \"executorType\": \"NOT_SUPPORT\", \"executorWorkspaceId\": 4946, \"executorWorkspaceName\": \"成都建工第七建筑工程有限公司\", \"identityCode\": \"fccb21474a4645edb907e9a9828c3d46\", \"orgType\": \"ENT\", \"promoterId\": 0, \"promoterName\": \"杨期成\", \"promoterOuId\": 10401, \"promoterPersonId\": 9000400630, \"promoterType\": \"NOT_SUPPORT\", \"promoterWorkspaceId\": 4949, \"promoterWorkspaceName\": \"核西南院设计有限公司\", \"requestNo\": \"1a9c93f122824f648763bd311c2f3118\", \"routerParams\": {\"processNodeCode\": \"node_065414499288\", \"processInstanceId\": \"202501151529100000000\", \"creator\": \"杨期成\", \"userAgreeSignature\": true, \"businessTypeName\": \"审批节点\", \"businessKey\": \"40\", \"tenantId\": \"4946\", \"startTime\": \"2025-01-15 15:29:25\", \"title\": \"工作流业务测试项目流程\", \"taskId\": \"202501151529100000049\", \"processNodeName\": \"审批节点\"}, \"srcTemplateCode\": \"a7c79c432efc4ecba71790677d35cc59\", \"state\": \"HAS_BEEN_SENT\", \"subBizCode\": \"202501151529100000049\", \"templateCode\": \"a7c79c432efc4ecba71790677d35cc59\", \"title\": \"你好\", \"todoBusinessId\": 146907, \"todoId\": 843354, \"type\": \"EXECUTABLE\"}}";
TodoUpdateMessage message = JSON.parseObject(json, TodoUpdateMessage.class);
todoSyncCardService.onMessage(new Event(), message);
}
}