Commit 3acb56f880a8f305461d55956d4a34b868c56263
1 parent
a3d8e872
1. 流程定义列表,增加任务分配规则的展示
2. 流程定义列表,按照 version 倒序
Showing
5 changed files
with
38 additions
and
17 deletions
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 | 52 | * 主要进行 Activiti {@link Model} 的维护 |
| 53 | 53 | * |
| 54 | 54 | * @author yunlongn |
| 55 | + * @author 芋道源码 | |
| 55 | 56 | */ |
| 56 | 57 | @Service |
| 57 | 58 | @Validated |
| ... | ... | @@ -189,12 +190,7 @@ public class BpmModelServiceImpl implements BpmModelService { |
| 189 | 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 | 195 | // 更新 model 的 deploymentId,进行关联 |
| 200 | 196 | ProcessDefinition definition = processDefinitionService.getProcessDefinition(definitionId); |
| ... | ... | @@ -226,6 +222,7 @@ public class BpmModelServiceImpl implements BpmModelService { |
| 226 | 222 | } |
| 227 | 223 | |
| 228 | 224 | @Override |
| 225 | + @Transactional(rollbackFor = Exception.class) | |
| 229 | 226 | public void deleteModel(String id) { |
| 230 | 227 | // 校验流程模型存在 |
| 231 | 228 | Model model = repositoryService.getModel(id); |
| ... | ... | @@ -234,6 +231,19 @@ public class BpmModelServiceImpl implements BpmModelService { |
| 234 | 231 | } |
| 235 | 232 | // 执行删除 |
| 236 | 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 | 249 | @Override |
| ... | ... | @@ -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 | 67 | definitionQuery.processDefinitionKey(pageVO.getKey()); |
| 68 | 68 | } |
| 69 | 69 | // 执行查询 |
| 70 | - List<ProcessDefinition> processDefinitions = definitionQuery.orderByProcessDefinitionId().desc() | |
| 70 | + List<ProcessDefinition> processDefinitions = definitionQuery.orderByProcessDefinitionVersion().desc() | |
| 71 | 71 | .listPage(PageUtils.getStart(pageVO), pageVO.getPageSize()); |
| 72 | 72 | if (CollUtil.isEmpty(processDefinitions)) { |
| 73 | 73 | return new PageResult<>(Collections.emptyList(), definitionQuery.count()); | ... | ... |
yudao-admin-ui/src/views/bpm/definition/index.vue
| ... | ... | @@ -41,6 +41,13 @@ |
| 41 | 41 | </template> |
| 42 | 42 | </el-table-column> |
| 43 | 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 | 51 | </el-table> |
| 45 | 52 | |
| 46 | 53 | <!-- 流程表单配置详情 --> |
| ... | ... | @@ -56,6 +63,9 @@ |
| 56 | 63 | <!-- 分页组件 --> |
| 57 | 64 | <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize" |
| 58 | 65 | @pagination="getList"/> |
| 66 | + | |
| 67 | + <!-- ========== 流程任务分配规则 ========== --> | |
| 68 | + <taskAssignRuleDialog ref="taskAssignRuleDialog" /> | |
| 59 | 69 | </div> |
| 60 | 70 | </template> |
| 61 | 71 | |
| ... | ... | @@ -65,11 +75,13 @@ import {DICT_TYPE, getDictDatas} from "@/utils/dict"; |
| 65 | 75 | import {getForm} from "@/api/bpm/form"; |
| 66 | 76 | import {decodeFields} from "@/utils/formGenerator"; |
| 67 | 77 | import Parser from '@/components/parser/Parser' |
| 78 | +import taskAssignRuleDialog from "../taskAssignRule/taskAssignRuleDialog"; | |
| 68 | 79 | |
| 69 | 80 | export default { |
| 70 | 81 | name: "processDefinition", |
| 71 | 82 | components: { |
| 72 | - Parser | |
| 83 | + Parser, | |
| 84 | + taskAssignRuleDialog | |
| 73 | 85 | }, |
| 74 | 86 | data() { |
| 75 | 87 | return { |
| ... | ... | @@ -141,6 +153,10 @@ export default { |
| 141 | 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 | 162 | </script> | ... | ... |
yudao-admin-ui/src/views/bpm/task/done.vue
yudao-admin-ui/src/views/bpm/taskAssignRule/taskAssignRuleDialog.vue
| ... | ... | @@ -10,14 +10,14 @@ |
| 10 | 10 | <span>{{ getDictDataLabel(DICT_TYPE.BPM_TASK_ASSIGN_RULE_TYPE, scope.row.type) }}</span> |
| 11 | 11 | </template> |
| 12 | 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 | 14 | <template slot-scope="scope"> |
| 15 | 15 | <el-tag size="medium" v-if="scope.row.options" v-for="option in scope.row.options"> |
| 16 | 16 | {{ getAssignRuleOptionName(scope.row.type, option) }} |
| 17 | 17 | </el-tag> |
| 18 | 18 | </template> |
| 19 | 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 | 21 | <template slot-scope="scope"> |
| 22 | 22 | <!-- TODO 权限 --> |
| 23 | 23 | <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdateTaskAssignRule(scope.row)" |
| ... | ... | @@ -188,6 +188,7 @@ export default { |
| 188 | 188 | this.loading = true; |
| 189 | 189 | getTaskAssignRuleList({ |
| 190 | 190 | modelId: this.modelId, |
| 191 | + processDefinitionId: this.processDefinitionId, | |
| 191 | 192 | }).then(response => { |
| 192 | 193 | this.loading = false; |
| 193 | 194 | this.list = response.data; | ... | ... |