• 基于jeecg-boot的flowable流程自定义业务退回撤回或驳回到发起人后的再次流程提交


    更多nbcio-boot功能请看演示系统

    gitee源代码地址

    后端代码: https://gitee.com/nbacheng/nbcio-boot

    前端代码:https://gitee.com/nbacheng/nbcio-vue.git

    在线演示(包括H5) : http://122.227.135.243:9888
     

         主要用户有些需求,需要自定义业务退回或撤回或驳回到发起人后能再次进行流程的提交,所以今天就解决这个问题。

        1、前端

          前端主要提供一个可以让用户进行选择再次提交的方法,同时检测是否是退回或撤回或驳回到发起人的节点

      

    1. <template>
    2. <span>
    3. <a-button :type="btnType" @click="applySubmit()">{{text}}a-button>
    4. <a-modal :z-index="100" :title="firstInitiatorTitle" @cancel="firstInitiatorOpen = false" :visible.sync="firstInitiatorOpen"
    5. :width="'50%'" append-to-body>
    6. <a-descriptions bordered layout="vertical">
    7. <a-descriptions-item :span="3">
    8. <a-badge status="processing" text="选择提醒" />
    9. a-descriptions-item>
    10. <a-descriptions-item label="重新发起新流程按钮" labelStyle="{ color: '#fff', fontWeight: 'bold', fontSize='18px'}">
    11. 重新发起新流程会删除之前发起的任务,重新开始.
    12. a-descriptions-item>
    13. <a-descriptions-item label="继续发起老流程按钮">
    14. 继续发起流程就在原来流程基础上继续流转.
    15. a-descriptions-item>
    16. a-descriptions>
    17. <span slot="footer" class="dialog-footer">
    18. <el-button type="primary" @click="StartByDataId(true)">重新发起新流程el-button>
    19. <el-button type="primary" @click="StartByDataId(false)">继续发起老流程el-button>
    20. <el-button @click="firstInitiatorOpen = false">取 消el-button>
    21. span>
    22. a-modal>
    23. span>
    24. template>
    25. <script>
    26. import {
    27. definitionStartByDataId,
    28. isFirstInitiator,
    29. deleteActivityAndJoin
    30. } from "@views/flowable/api/definition";
    31. export default {
    32. name: 'ActApplyBtn',
    33. components: {},
    34. props: {
    35. btnType: {
    36. type: String,
    37. default: 'link',
    38. required: false
    39. },
    40. /**/
    41. dataId: {
    42. type: String,
    43. default: '',
    44. required: true
    45. },
    46. serviceName: {
    47. type: String,
    48. default: '',
    49. required: true
    50. },
    51. variables: {
    52. type: Object,
    53. default: {},
    54. },
    55. text: {
    56. type: String,
    57. default: '提交申请',
    58. required: false
    59. }
    60. },
    61. data() {
    62. return {
    63. modalVisible: false,
    64. submitLoading: false,
    65. form: {},
    66. firstInitiatorOpen: false,
    67. firstInitiatorTitle: '',
    68. };
    69. },
    70. created() {},
    71. watch: {},
    72. methods: {
    73. StartByDataId(isNewFlow) {
    74. if(isNewFlow) {
    75. this.submitLoading = true;
    76. deleteActivityAndJoin(this.dataId,this.variables)
    77. .then(res => {
    78. if (res.success && res.result) { //若删除成功
    79. var params = Object.assign({
    80. dataId: this.dataId
    81. }, this.variables);
    82. definitionStartByDataId(this.dataId, this.serviceName, params)
    83. .then(res => {
    84. if (res.success) {
    85. this.firstInitiatorOpen = false;
    86. this.$message.success(res.message);
    87. this.$emit('success');
    88. } else {
    89. this.$message.error(res.message);
    90. }
    91. })
    92. }
    93. })
    94. .finally(() => (this.submitLoading = false));
    95. }
    96. else {//继续原有流程流转,跳到流程处理界面上
    97. console.log("this.variables",this.variables);
    98. this.$router.push({ path: '/flowable/task/record/index',
    99. query: {
    100. procInsId: this.variables.processInstanceId,
    101. deployId: this.variables.deployId,
    102. taskId: this.variables.taskId,
    103. businessKey: this.dataId,
    104. nodeType: "",
    105. category: "zdyyw",
    106. finished: true
    107. }})
    108. }
    109. },
    110. applySubmit() {
    111. if (this.dataId && this.dataId.length < 1) {
    112. this.error = '必须传入参数dataId';
    113. this.$message.error(this.error);
    114. return;
    115. }
    116. if (this.serviceName && this.serviceName.length < 1) {
    117. this.error = '必须传入参数serviceName';
    118. this.$message.error(this.error);
    119. return;
    120. } else {
    121. this.error = '';
    122. }
    123. //对于自定义业务,判断是否是驳回或退回的第一个发起人节点
    124. this.submitLoading = true;
    125. isFirstInitiator(this.dataId, this.variables)
    126. .then(res => {
    127. if (res.success && res.result) { //若是,弹出窗口选择重新发起新流程还是继续老流程
    128. this.firstInitiatorTitle = "根据自己需要进行选择"
    129. this.firstInitiatorOpen = true;
    130. }
    131. else {
    132. this.submitLoading = true;
    133. var params = Object.assign({
    134. dataId: this.dataId
    135. }, this.variables);
    136. definitionStartByDataId(this.dataId, this.serviceName, params)
    137. .then(res => {
    138. if (res.success) {
    139. this.$message.success(res.message);
    140. this.$emit('success');
    141. } else {
    142. this.$message.error(res.message);
    143. }
    144. })
    145. .finally(() => (this.submitLoading = false));
    146. }
    147. })
    148. .finally(() => (this.submitLoading = false));
    149. }
    150. }
    151. };
    152. script>

    效果如下:

    2、后端代码

       

    1. /**
    2. * 判断当前节点是否是第一个发起人节点(目前只针对自定义业务的驳回、撤回和退回操作)
    3. *
    4. * @param processInstanceId, actStatusType
    5. */
    6. @Override
    7. public boolean isFirstInitiator(String processInstanceId, String actStatusType) {
    8. if(StringUtils.equalsAnyIgnoreCase(actStatusType, ActStatus.reject) ||
    9. StringUtils.equalsAnyIgnoreCase(actStatusType, ActStatus.recall) ||
    10. StringUtils.equalsAnyIgnoreCase(actStatusType, ActStatus.retrun) ) {
    11. if(StringUtils.isNotEmpty(processInstanceId)) {
    12. // 获取当前任务
    13. Task task = taskService.createTaskQuery().processInstanceId(processInstanceId).singleResult();
    14. BpmnModel bpmnModel = repositoryService.getBpmnModel(task.getProcessDefinitionId());
    15. // 获取当前活动节点
    16. FlowNode currentFlowNode = (FlowNode) bpmnModel.getMainProcess().getFlowElement(task.getTaskDefinitionKey());
    17. // 输入连线
    18. List inFlows = currentFlowNode.getIncomingFlows();
    19. for (SequenceFlow sequenceFlow : inFlows) {
    20. FlowElement sourceFlowElement = sequenceFlow.getSourceFlowElement();
    21. // 如果上个节点为开始节点
    22. if (sourceFlowElement instanceof StartEvent) {
    23. log.info("当前节点为发起人节点,上个节点为开始节点:id=" + sourceFlowElement.getId() + ",name=" + sourceFlowElement.getName());
    24. return true;
    25. }
    26. }
    27. }
    28. }
    29. return false;
    30. }

  • 相关阅读:
    DevTools 无法加载来源映射:无法加载 chrome-extension: 警告的原因以及如何去除(全网最全 最详细解决方案)
    Wpf 使用 Prism 实战开发Day21
    Flask博客实战 - 实现侧边栏文章归档及标签
    Z检验|T检验|样本标准差S代替总体标准差 σ
    Java代码审计——URL 跳转漏洞
    IIoT(智能物联网)的现状、应用及安全
    Xilinx ZYNQ 7000学习笔记四(MultiBoot多重启动)
    小米云原生文件存储平台化实践:支撑 AI 训练、大模型、容器平台多项业务
    2022年IC行业还缺人吗?
    FFmpeg开发笔记(二十四)Linux环境给FFmpeg集成AV1的编解码器
  • 原文地址:https://blog.csdn.net/qq_40032778/article/details/132693165