Commit 3acb56f880a8f305461d55956d4a34b868c56263

Authored by YunaiV
1 parent a3d8e872

1. 流程定义列表,增加任务分配规则的展示

2. 流程定义列表,按照 version 倒序
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. @@ -52,6 +52,7 @@ import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.
52 * 主要进行 Activiti {@link Model} 的维护 52 * 主要进行 Activiti {@link Model} 的维护
53 * 53 *
54 * @author yunlongn 54 * @author yunlongn
  55 + * @author 芋道源码
55 */ 56 */
56 @Service 57 @Service
57 @Validated 58 @Validated
@@ -189,12 +190,7 @@ public class BpmModelServiceImpl implements BpmModelService { @@ -189,12 +190,7 @@ public class BpmModelServiceImpl implements BpmModelService {
189 String definitionId = processDefinitionService.createProcessDefinition(definitionCreateReqDTO); 190 String definitionId = processDefinitionService.createProcessDefinition(definitionCreateReqDTO);
190 191
191 // 将老的流程定义进行挂起。也就是说,只有最新部署的流程定义,才可以发起任务。 192 // 将老的流程定义进行挂起。也就是说,只有最新部署的流程定义,才可以发起任务。
192 - if (StrUtil.isNotEmpty(model.getDeploymentId())) {  
193 - ProcessDefinition oldDefinition = processDefinitionService.getProcessDefinitionByDeploymentId(model.getDeploymentId());  
194 - if (oldDefinition != null) {  
195 - processDefinitionService.updateProcessDefinitionState(oldDefinition.getId(), SuspensionState.SUSPENDED.getStateCode());  
196 - }  
197 - } 193 + updateProcessDefinitionSuspended(model.getDeploymentId());
198 194
199 // 更新 model 的 deploymentId,进行关联 195 // 更新 model 的 deploymentId,进行关联
200 ProcessDefinition definition = processDefinitionService.getProcessDefinition(definitionId); 196 ProcessDefinition definition = processDefinitionService.getProcessDefinition(definitionId);
@@ -226,6 +222,7 @@ public class BpmModelServiceImpl implements BpmModelService { @@ -226,6 +222,7 @@ public class BpmModelServiceImpl implements BpmModelService {
226 } 222 }
227 223
228 @Override 224 @Override
  225 + @Transactional(rollbackFor = Exception.class)
229 public void deleteModel(String id) { 226 public void deleteModel(String id) {
230 // 校验流程模型存在 227 // 校验流程模型存在
231 Model model = repositoryService.getModel(id); 228 Model model = repositoryService.getModel(id);
@@ -234,6 +231,19 @@ public class BpmModelServiceImpl implements BpmModelService { @@ -234,6 +231,19 @@ public class BpmModelServiceImpl implements BpmModelService {
234 } 231 }
235 // 执行删除 232 // 执行删除
236 repositoryService.deleteModel(id); 233 repositoryService.deleteModel(id);
  234 + // 禁用流程实例
  235 + updateProcessDefinitionSuspended(model.getDeploymentId());
  236 + }
  237 +
  238 + private void updateProcessDefinitionSuspended(String deploymentId) {
  239 + if (StrUtil.isEmpty(deploymentId)) {
  240 + return;
  241 + }
  242 + ProcessDefinition oldDefinition = processDefinitionService.getProcessDefinitionByDeploymentId(deploymentId);
  243 + if (oldDefinition == null) {
  244 + return;
  245 + }
  246 + processDefinitionService.updateProcessDefinitionState(oldDefinition.getId(), SuspensionState.SUSPENDED.getStateCode());
237 } 247 }
238 248
239 @Override 249 @Override
@@ -272,10 +282,4 @@ public class BpmModelServiceImpl implements BpmModelService { @@ -272,10 +282,4 @@ public class BpmModelServiceImpl implements BpmModelService {
272 } 282 }
273 } 283 }
274 284
275 - public static void main(String[] args) {  
276 - // 创建转换对象  
277 - BpmnXMLConverter converter = new BpmnXMLConverter();  
278 - BpmnModel bpmnModel = converter.convertToBpmnModel(new StringStreamSource(""), true, true);  
279 - }  
280 -  
281 } 285 }
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 @@ -67,7 +67,7 @@ public class BpmProcessDefinitionServiceImpl implements BpmProcessDefinitionServ
67 definitionQuery.processDefinitionKey(pageVO.getKey()); 67 definitionQuery.processDefinitionKey(pageVO.getKey());
68 } 68 }
69 // 执行查询 69 // 执行查询
70 - List<ProcessDefinition> processDefinitions = definitionQuery.orderByProcessDefinitionId().desc() 70 + List<ProcessDefinition> processDefinitions = definitionQuery.orderByProcessDefinitionVersion().desc()
71 .listPage(PageUtils.getStart(pageVO), pageVO.getPageSize()); 71 .listPage(PageUtils.getStart(pageVO), pageVO.getPageSize());
72 if (CollUtil.isEmpty(processDefinitions)) { 72 if (CollUtil.isEmpty(processDefinitions)) {
73 return new PageResult<>(Collections.emptyList(), definitionQuery.count()); 73 return new PageResult<>(Collections.emptyList(), definitionQuery.count());
yudao-admin-ui/src/views/bpm/definition/index.vue
@@ -41,6 +41,13 @@ @@ -41,6 +41,13 @@
41 </template> 41 </template>
42 </el-table-column> 42 </el-table-column>
43 <el-table-column label="定义描述" align="center" prop="description" width="300" show-overflow-tooltip /> 43 <el-table-column label="定义描述" align="center" prop="description" width="300" show-overflow-tooltip />
  44 + <el-table-column label="操作" align="center" width="150" fixed="right">
  45 + <template slot-scope="scope">
  46 + <!-- TODO 权限 -->
  47 + <el-button size="mini" type="text" icon="el-icon-s-custom" @click="handleAssignRule(scope.row)"
  48 + v-hasPermi="['bpm:model:update']">分配规则</el-button>
  49 + </template>
  50 + </el-table-column>
44 </el-table> 51 </el-table>
45 52
46 <!-- 流程表单配置详情 --> 53 <!-- 流程表单配置详情 -->
@@ -56,6 +63,9 @@ @@ -56,6 +63,9 @@
56 <!-- 分页组件 --> 63 <!-- 分页组件 -->
57 <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize" 64 <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
58 @pagination="getList"/> 65 @pagination="getList"/>
  66 +
  67 + <!-- ========== 流程任务分配规则 ========== -->
  68 + <taskAssignRuleDialog ref="taskAssignRuleDialog" />
59 </div> 69 </div>
60 </template> 70 </template>
61 71
@@ -65,11 +75,13 @@ import {DICT_TYPE, getDictDatas} from &quot;@/utils/dict&quot;; @@ -65,11 +75,13 @@ import {DICT_TYPE, getDictDatas} from &quot;@/utils/dict&quot;;
65 import {getForm} from "@/api/bpm/form"; 75 import {getForm} from "@/api/bpm/form";
66 import {decodeFields} from "@/utils/formGenerator"; 76 import {decodeFields} from "@/utils/formGenerator";
67 import Parser from '@/components/parser/Parser' 77 import Parser from '@/components/parser/Parser'
  78 +import taskAssignRuleDialog from "../taskAssignRule/taskAssignRuleDialog";
68 79
69 export default { 80 export default {
70 name: "processDefinition", 81 name: "processDefinition",
71 components: { 82 components: {
72 - Parser 83 + Parser,
  84 + taskAssignRuleDialog
73 }, 85 },
74 data() { 86 data() {
75 return { 87 return {
@@ -141,6 +153,10 @@ export default { @@ -141,6 +153,10 @@ export default {
141 this.showBpmnOpen = true 153 this.showBpmnOpen = true
142 }) 154 })
143 }, 155 },
  156 + /** 处理任务分配规则列表的按钮操作 */
  157 + handleAssignRule(row) {
  158 + this.$refs['taskAssignRuleDialog'].initProcessDefinition(row.id);
  159 + },
144 } 160 }
145 }; 161 };
146 </script> 162 </script>
yudao-admin-ui/src/views/bpm/task/done.vue
@@ -87,7 +87,7 @@ export default { @@ -87,7 +87,7 @@ export default {
87 showSearch: true, 87 showSearch: true,
88 // 总条数 88 // 总条数
89 total: 0, 89 total: 0,
90 - // 待办任务列表 90 + // 已办任务列表
91 list: [], 91 list: [],
92 // 查询参数 92 // 查询参数
93 dateRangeCreateTime: [], 93 dateRangeCreateTime: [],
yudao-admin-ui/src/views/bpm/taskAssignRule/taskAssignRuleDialog.vue
@@ -10,14 +10,14 @@ @@ -10,14 +10,14 @@
10 <span>{{ getDictDataLabel(DICT_TYPE.BPM_TASK_ASSIGN_RULE_TYPE, scope.row.type) }}</span> 10 <span>{{ getDictDataLabel(DICT_TYPE.BPM_TASK_ASSIGN_RULE_TYPE, scope.row.type) }}</span>
11 </template> 11 </template>
12 </el-table-column> 12 </el-table-column>
13 - <el-table-column label="规则范围" align="center" prop="options" width="300px"> 13 + <el-table-column label="规则范围" align="center" prop="options" width="440px">
14 <template slot-scope="scope"> 14 <template slot-scope="scope">
15 <el-tag size="medium" v-if="scope.row.options" v-for="option in scope.row.options"> 15 <el-tag size="medium" v-if="scope.row.options" v-for="option in scope.row.options">
16 {{ getAssignRuleOptionName(scope.row.type, option) }} 16 {{ getAssignRuleOptionName(scope.row.type, option) }}
17 </el-tag> 17 </el-tag>
18 </template> 18 </template>
19 </el-table-column> 19 </el-table-column>
20 - <el-table-column label="操作" align="center" width="80" fixed="right"> 20 + <el-table-column v-if="modelId" label="操作" align="center" width="80" fixed="right">
21 <template slot-scope="scope"> 21 <template slot-scope="scope">
22 <!-- TODO 权限 --> 22 <!-- TODO 权限 -->
23 <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdateTaskAssignRule(scope.row)" 23 <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdateTaskAssignRule(scope.row)"
@@ -188,6 +188,7 @@ export default { @@ -188,6 +188,7 @@ export default {
188 this.loading = true; 188 this.loading = true;
189 getTaskAssignRuleList({ 189 getTaskAssignRuleList({
190 modelId: this.modelId, 190 modelId: this.modelId,
  191 + processDefinitionId: this.processDefinitionId,
191 }).then(response => { 192 }).then(response => {
192 this.loading = false; 193 this.loading = false;
193 this.list = response.data; 194 this.list = response.data;