Browse Source

限制显示【撤销】按钮

huanglc 1 month ago
parent
commit
0c647cc542

+ 60 - 10
bpm-core/src/main/java/com/srm/bpm/logic/service/impl/BillBtnLogicImpl.java

@@ -36,12 +36,11 @@ import org.activiti.bpmn.model.UserTask;
36 36
 import org.activiti.engine.RepositoryService;
37 37
 import org.activiti.engine.repository.ProcessDefinition;
38 38
 import org.apache.commons.lang3.StringUtils;
39
+import org.springframework.beans.factory.annotation.Value;
39 40
 import org.springframework.stereotype.Service;
40 41
 import org.springframework.transaction.annotation.Transactional;
41 42
 
42
-import java.util.Collections;
43
-import java.util.List;
44
-import java.util.Objects;
43
+import java.util.*;
45 44
 import java.util.stream.Collectors;
46 45
 
47 46
 import cn.hutool.core.collection.CollectionUtil;
@@ -49,6 +48,8 @@ import cn.hutool.core.util.StrUtil;
49 48
 import lombok.RequiredArgsConstructor;
50 49
 import lombok.extern.slf4j.Slf4j;
51 50
 
51
+import javax.annotation.PostConstruct;
52
+
52 53
 /**
53 54
  * <p> </p>
54 55
  *
@@ -67,6 +68,37 @@ public class BillBtnLogicImpl implements BillBtnLogic {
67 68
     private final BillCcPersonService billCcPersonService;
68 69
     private final FormSettingService formSettingService;
69 70
 
71
+    @Value("${activiti.cancel.disable:}")
72
+    private  String disableCancel;
73
+
74
+    private  Set<Long> DISABLED_RECALL_PROCESS_IDS;
75
+
76
+
77
+    @PostConstruct
78
+    public void initDisabledProcessIds() {
79
+        if(!StringUtils.isBlank(disableCancel)){
80
+            DISABLED_RECALL_PROCESS_IDS = Arrays.stream(disableCancel.split(","))
81
+                    .map(Long::valueOf).collect(Collectors.toSet());
82
+        }else {
83
+            DISABLED_RECALL_PROCESS_IDS = new HashSet<>();
84
+        }
85
+    }
86
+
87
+    /**
88
+     * 检查指定流程是否允许显示撤销按钮
89
+     * @param processId 流程ID
90
+     * @return true-允许显示撤销按钮,false-不允许
91
+     */
92
+    private boolean isRecallButtonEnabled(long processId) {
93
+//        if(!StringUtils.isBlank(disableCancel)){
94
+//            DISABLED_RECALL_PROCESS_IDS = Arrays.stream(disableCancel.split(","))
95
+//                    .map(Long::valueOf).collect(Collectors.toSet());
96
+//        }else {
97
+//            DISABLED_RECALL_PROCESS_IDS = new HashSet<>();
98
+//        }
99
+        return !DISABLED_RECALL_PROCESS_IDS.contains(processId);
100
+    }
101
+
70 102
     /**
71 103
      * 根据业务流程 获取 在创建 业务审批单的时候的按钮权限
72 104
      *
@@ -319,8 +351,11 @@ public class BillBtnLogicImpl implements BillBtnLogic {
319 351
                 // 填写, 如果是我发起的并且当前的任务状态是发起,则可以提交
320 352
                 switch (billStatus) {
321 353
                     case APPROVAL:
322
-                        // 如果单子还在审批中,则显示撤销按钮
323
-                        btns = Lists.newArrayList(BillBtnConst.BTN_CANCEL, BillBtnConst.BTN_TRACK);
354
+                        // 如果单子还在审批中,根据流程ID决定是否显示撤销按钮
355
+                        btns = Lists.newArrayList(BillBtnConst.BTN_TRACK);
356
+                        if (isRecallButtonEnabled(processId)) {
357
+                            btns.add(BillBtnConst.BTN_CANCEL);
358
+                        }
324 359
                         break;
325 360
                     case DRAFTS:
326 361
                         btns = Lists.newArrayList(BillBtnConst.BTN_SUBMIT, BillBtnConst.BTN_SAVE, BillBtnConst.BTN_TRACK);
@@ -345,7 +380,10 @@ public class BillBtnLogicImpl implements BillBtnLogic {
345 380
                         btns = Lists.newArrayList(BillBtnConst.BTN_SUBMIT, BillBtnConst.BTN_TRACK);
346 381
                         break;
347 382
                     case APPROVAL:
348
-                        btns = Lists.newArrayList(BillBtnConst.BTN_CANCEL, BillBtnConst.BTN_TRACK);
383
+                        btns = Lists.newArrayList(BillBtnConst.BTN_TRACK);
384
+                        if (isRecallButtonEnabled(processId)) {
385
+                            btns.add(BillBtnConst.BTN_CANCEL);
386
+                        }
349 387
                         break;
350 388
                     case REFUSE:
351 389
                         // 重新填写
@@ -381,8 +419,11 @@ public class BillBtnLogicImpl implements BillBtnLogic {
381 419
                 // 已同意或者已拒绝,因为是我自己发其的
382 420
                 switch (billStatus) {
383 421
                     case APPROVAL:
384
-                        // 如果单子还在审批中, 则可以显示撤销
385
-                        btns = Lists.newArrayList(BillBtnConst.BTN_CANCEL, BillBtnConst.BTN_TRACK);
422
+                        // 如果单子还在审批中,根据流程ID决定是否显示撤销按钮
423
+                        btns = Lists.newArrayList(BillBtnConst.BTN_TRACK);
424
+                        if (isRecallButtonEnabled(processId)) {
425
+                            btns.add(BillBtnConst.BTN_CANCEL);
426
+                        }
386 427
                         break;
387 428
                     default:
388 429
                         btns = Lists.newArrayList(BillBtnConst.BTN_TRACK);
@@ -447,7 +488,13 @@ public class BillBtnLogicImpl implements BillBtnLogic {
447 488
                     return Lists.newArrayList(BillBtnConst.BTN_ARCHIVED, BillBtnConst.BTN_TRACK);
448 489
                 case approvl:
449 490
                     final boolean hasRefuse = nextNodeHasRefuse(processId, nodeExtend);
450
-                    final List<String> btns = Lists.newArrayList(BillBtnConst.BTN_CANCEL, BillBtnConst.BTN_AGREE, BillBtnConst.BTN_BACK);
491
+                    final List<String> btns = Lists.newArrayList(BillBtnConst.BTN_AGREE, BillBtnConst.BTN_BACK);
492
+                    
493
+                    // 根据流程ID决定是否添加撤销按钮
494
+                    if (isRecallButtonEnabled(processId)) {
495
+                        btns.add(0, BillBtnConst.BTN_CANCEL);  // 在同意按钮前添加撤销按钮
496
+                    }
497
+                    
451 498
                     if (hasRefuse) {
452 499
                         // 正式自己的待我审批,则显示,审批同意等按钮
453 500
                         btns.add(2, BillBtnConst.BTN_REFUSE);
@@ -552,7 +599,10 @@ public class BillBtnLogicImpl implements BillBtnLogic {
552 599
                     btns = Lists.newArrayList(BillBtnConst.BTN_SUBMIT, BillBtnConst.BTN_SAVE);
553 600
                     break;
554 601
                 case APPROVAL:
555
-                    btns = Lists.newArrayList(BillBtnConst.BTN_CANCEL, BillBtnConst.BTN_TRACK);
602
+                    btns = Lists.newArrayList(BillBtnConst.BTN_TRACK);
603
+                    if (isRecallButtonEnabled(processId)) {
604
+                        btns.add(BillBtnConst.BTN_CANCEL);
605
+                    }
556 606
                     break;
557 607
                 case ARCHIVE:
558 608
                 case COMPLETE:

+ 4 - 0
bpm-server/src/main/resources/application.yml

@@ -172,3 +172,7 @@ seata:
172 172
       data-validation: true
173 173
   log:
174 174
     exception-rate: 100
175
+
176
+activiti:
177
+  cancel:
178
+    disable: 1582934275231764481,1582221019420737538