Bladeren bron

1. 流程定义列表,增加任务分配规则的展示
2. 流程定义列表,按照 version 倒序

YunaiV 3 jaren geleden
bovenliggende
commit
3acb56f880

+ 16 - 12
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/impl/BpmModelServiceImpl.java

@@ -52,6 +52,7 @@ import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.
  * 主要进行 Activiti {@link Model} 的维护
  *
  * @author yunlongn
+ * @author 芋道源码
  */
 @Service
 @Validated
@@ -189,12 +190,7 @@ public class BpmModelServiceImpl implements BpmModelService {
         String definitionId = processDefinitionService.createProcessDefinition(definitionCreateReqDTO);
 
         // 将老的流程定义进行挂起。也就是说,只有最新部署的流程定义,才可以发起任务。
-        if (StrUtil.isNotEmpty(model.getDeploymentId())) {
-            ProcessDefinition oldDefinition = processDefinitionService.getProcessDefinitionByDeploymentId(model.getDeploymentId());
-            if (oldDefinition != null) {
-                processDefinitionService.updateProcessDefinitionState(oldDefinition.getId(), SuspensionState.SUSPENDED.getStateCode());
-            }
-        }
+        updateProcessDefinitionSuspended(model.getDeploymentId());
 
         // 更新 model 的 deploymentId,进行关联
         ProcessDefinition definition = processDefinitionService.getProcessDefinition(definitionId);
@@ -226,6 +222,7 @@ public class BpmModelServiceImpl implements BpmModelService {
     }
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public void deleteModel(String id) {
         // 校验流程模型存在
         Model model = repositoryService.getModel(id);
@@ -234,6 +231,19 @@ public class BpmModelServiceImpl implements BpmModelService {
         }
         // 执行删除
         repositoryService.deleteModel(id);
+        // 禁用流程实例
+        updateProcessDefinitionSuspended(model.getDeploymentId());
+    }
+
+    private void updateProcessDefinitionSuspended(String deploymentId) {
+        if (StrUtil.isEmpty(deploymentId)) {
+            return;
+        }
+        ProcessDefinition oldDefinition = processDefinitionService.getProcessDefinitionByDeploymentId(deploymentId);
+        if (oldDefinition == null) {
+            return;
+        }
+        processDefinitionService.updateProcessDefinitionState(oldDefinition.getId(), SuspensionState.SUSPENDED.getStateCode());
     }
 
     @Override
@@ -272,10 +282,4 @@ public class BpmModelServiceImpl implements BpmModelService {
         }
     }
 
-    public static void main(String[] args) {
-        // 创建转换对象
-        BpmnXMLConverter converter = new BpmnXMLConverter();
-        BpmnModel bpmnModel = converter.convertToBpmnModel(new StringStreamSource(""), true, true);
-    }
-
 }

+ 1 - 1
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/impl/BpmProcessDefinitionServiceImpl.java

@@ -67,7 +67,7 @@ public class BpmProcessDefinitionServiceImpl implements BpmProcessDefinitionServ
             definitionQuery.processDefinitionKey(pageVO.getKey());
         }
         // 执行查询
-        List<ProcessDefinition> processDefinitions = definitionQuery.orderByProcessDefinitionId().desc()
+        List<ProcessDefinition> processDefinitions = definitionQuery.orderByProcessDefinitionVersion().desc()
                 .listPage(PageUtils.getStart(pageVO), pageVO.getPageSize());
         if (CollUtil.isEmpty(processDefinitions)) {
             return new PageResult<>(Collections.emptyList(), definitionQuery.count());

+ 17 - 1
yudao-admin-ui/src/views/bpm/definition/index.vue

@@ -41,6 +41,13 @@
         </template>
       </el-table-column>
       <el-table-column label="定义描述" align="center" prop="description" width="300" show-overflow-tooltip />
+      <el-table-column label="操作" align="center" width="150" fixed="right">
+        <template slot-scope="scope">
+          <!-- TODO 权限 -->
+          <el-button size="mini" type="text" icon="el-icon-s-custom" @click="handleAssignRule(scope.row)"
+                     v-hasPermi="['bpm:model:update']">分配规则</el-button>
+        </template>
+      </el-table-column>
     </el-table>
 
     <!-- 流程表单配置详情 -->
@@ -56,6 +63,9 @@
     <!-- 分页组件 -->
     <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
                 @pagination="getList"/>
+
+    <!-- ========== 流程任务分配规则 ========== -->
+    <taskAssignRuleDialog ref="taskAssignRuleDialog" />
   </div>
 </template>
 
@@ -65,11 +75,13 @@ import {DICT_TYPE, getDictDatas} from "@/utils/dict";
 import {getForm} from "@/api/bpm/form";
 import {decodeFields} from "@/utils/formGenerator";
 import Parser from '@/components/parser/Parser'
+import taskAssignRuleDialog from "../taskAssignRule/taskAssignRuleDialog";
 
 export default {
   name: "processDefinition",
   components: {
-    Parser
+    Parser,
+    taskAssignRuleDialog
   },
   data() {
     return {
@@ -141,6 +153,10 @@ export default {
         this.showBpmnOpen = true
       })
     },
+    /** 处理任务分配规则列表的按钮操作 */
+    handleAssignRule(row) {
+      this.$refs['taskAssignRuleDialog'].initProcessDefinition(row.id);
+    },
   }
 };
 </script>

+ 1 - 1
yudao-admin-ui/src/views/bpm/task/done.vue

@@ -87,7 +87,7 @@ export default {
       showSearch: true,
       // 总条数
       total: 0,
-      // 办任务列表
+      // 办任务列表
       list: [],
       // 查询参数
       dateRangeCreateTime: [],

+ 3 - 2
yudao-admin-ui/src/views/bpm/taskAssignRule/taskAssignRuleDialog.vue

@@ -10,14 +10,14 @@
             <span>{{ getDictDataLabel(DICT_TYPE.BPM_TASK_ASSIGN_RULE_TYPE, scope.row.type) }}</span>
           </template>
         </el-table-column>
-        <el-table-column label="规则范围" align="center" prop="options" width="300px">
+        <el-table-column label="规则范围" align="center" prop="options" width="440px">
           <template slot-scope="scope">
             <el-tag size="medium" v-if="scope.row.options" v-for="option in scope.row.options">
               {{ getAssignRuleOptionName(scope.row.type, option) }}
             </el-tag>
           </template>
         </el-table-column>
-        <el-table-column label="操作" align="center" width="80" fixed="right">
+        <el-table-column v-if="modelId" label="操作" align="center" width="80" fixed="right">
           <template slot-scope="scope">
             <!-- TODO 权限 -->
             <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdateTaskAssignRule(scope.row)"
@@ -188,6 +188,7 @@ export default {
       this.loading = true;
       getTaskAssignRuleList({
         modelId: this.modelId,
+        processDefinitionId: this.processDefinitionId,
       }).then(response => {
         this.loading = false;
         this.list = response.data;