Commit 8585e05772dcf43aec30e4604689ac83bf01ccad

Authored by jason
1 parent d7e1b87b

仿钉钉流程设计- 会签按比例通过bug 修复

yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/custom/expression/CompleteByRejectCountExpression.java
... ... @@ -49,35 +49,23 @@ public class CompleteByRejectCountExpression {
49 49 Integer rejectCount = CollectionUtils.getSumValue(execution.getExecutions(),
50 50 item -> Objects.equals(BpmTaskStatusEnum.REJECT.getStatus(), item.getVariableLocal(BpmConstants.TASK_VARIABLE_STATUS, Integer.class)) ? 1 : 0,
51 51 Integer::sum, 0);
52   - // 同意人数: 完成人数 - 拒绝人数
  52 + // 同意人数: 完成人数 - 拒绝人数
53 53 int agreeCount = nrOfCompletedInstances - rejectCount;
54 54 // 多人会签(按通过比例)
55 55 Integer approveRatio = NumberUtils.parseInt(BpmnModelUtils.parseExtensionElement(flowElement, USER_TASK_APPROVE_RATIO));
56 56 Assert.notNull(approveRatio, "通过比例不能空");
57   - if (Objects.equals(100, approveRatio)) {
58   - // 所有人都同意
59   - if (agreeCount == nrOfInstances) {
60   - return true;
61   - }
62   - // 一个人拒绝了
63   - if (rejectCount > 0) {
64   - execution.setVariable(String.format("%s_reject", flowElement.getId()), Boolean.TRUE);
65   - return true;
66   - }
67   - } else {
68   - // 判断通过比例
69   - double approvePct = approveRatio / (double) 100;
70   - double realApprovePct = (double) agreeCount / nrOfInstances;
71   - if (realApprovePct >= approvePct) {
72   - return true;
73   - }
74   - double rejectPct = (100 - approveRatio) / (double) 100;
75   - double realRejectPct = (double) rejectCount / nrOfInstances;
76   - // 判断拒绝比例
77   - if (realRejectPct >= rejectPct) {
78   - execution.setVariable(String.format("%s_reject", flowElement.getId()), Boolean.TRUE);
79   - return true;
80   - }
  57 + // 判断通过比例
  58 + double approvePct = approveRatio / (double) 100;
  59 + double realApprovePct = (double) agreeCount / nrOfInstances;
  60 + if (realApprovePct >= approvePct) {
  61 + return true;
  62 + }
  63 + double rejectPct = (100 - approveRatio) / (double) 100;
  64 + double realRejectPct = (double) rejectCount / nrOfInstances;
  65 + // 判断拒绝比例
  66 + if (realRejectPct > rejectPct) {
  67 + execution.setVariable(String.format("%s_reject", flowElement.getId()), Boolean.TRUE);
  68 + return true;
81 69 }
82 70 return false;
83 71 }
... ...