From da4f30082415316a4b844d08ad54287082a9aa35 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sat, 28 May 2022 22:39:56 +0800 Subject: [PATCH] =?UTF-8?q?code=20review=20=E5=B7=A5=E4=BD=9C=E6=B5=81?= =?UTF-8?q?=E7=9A=84=E9=A9=B3=E5=9B=9E=E9=80=BB=E8=BE=91=E5=AE=9E=E7=8E=B0?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bpm/controller/admin/task/vo/task/BpmTaskBackReqVO.java | 4 +++- .../yudao/module/bpm/dal/mysql/task/BpmActivityMapper.java | 4 +++- .../yudao/module/bpm/dal/mysql/task/BpmTaskExtMapper.java | 2 ++ .../framework/flowable/config/BpmFlowableConfiguration.java | 2 +- .../flowable/core/behavior/BpmActivityBehaviorFactory.java | 2 ++ .../module/bpm/service/task/BpmActivityServiceImpl.java | 5 +++-- .../yudao/module/bpm/service/task/BpmTaskServiceImpl.java | 3 +++ 7 files changed, 17 insertions(+), 5 deletions(-) diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskBackReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskBackReqVO.java index 386b38294..f618781f2 100644 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskBackReqVO.java +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskBackReqVO.java @@ -10,17 +10,19 @@ import javax.validation.constraints.NotNull; /** * @author kemengkai - * @create 2022-05-07 08:05 + * @create 2022-05-07 08:05 TODO ke:vo 类,使用 swagger 注解即可 */ @Data @AllArgsConstructor @NoArgsConstructor public class BpmTaskBackReqVO { + // TODO ke:userId 应该使用后端的,不能前端传递,不然就越权了 @ApiModelProperty(value = "用户id", required = true, example = "1") @NotEmpty(message = "用户id不能为空") private String userId; + // TODO ke:procInstId、taskId、oldTaskDefKey 三个,是不是只要传递一个 taskId?字段不要存在推导关系 @ApiModelProperty(value = "流程编号id", required = true, example = "730da750-cc4f-11ec-b58e-1e429355e4a0") @NotEmpty(message = "流程编号id不能为空") private String procInstId; diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/task/BpmActivityMapper.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/task/BpmActivityMapper.java index 84b5befb8..9041248ff 100644 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/task/BpmActivityMapper.java +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/task/BpmActivityMapper.java @@ -9,11 +9,12 @@ import java.util.List; /** * @author kemengkai - * @create 2022-05-09 09:26 + * @create 2022-05-09 09:26 TODO @ke:@date 哈。ps:一般这种类,可以不用谢类注释和方法注释。因为是 dao 是通用操作,所以都是通过方法名,可以指导它的用途 */ @Mapper public interface BpmActivityMapper extends BaseMapperX { + // TODO @ke:这个方法,是不是暂时用不到呀。如果是的话,可以删除哈 /** * 获取所有历史任务 * @@ -21,6 +22,7 @@ public interface BpmActivityMapper extends BaseMapperX { */ List listAll(); + // TODO @ke:可以试试,把 activiti 的表,映射成对应的实体,然后读取下。我们尽量避免 xml 操作,因为要做多 db 类型的支持,例如说 oracle 等。通过 mybatis plus 帮助我们生成不同数据库的表操作 /** * 获取指定流程的历史任务 * diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/task/BpmTaskExtMapper.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/task/BpmTaskExtMapper.java index cd174d902..d855f6066 100644 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/task/BpmTaskExtMapper.java +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/task/BpmTaskExtMapper.java @@ -28,6 +28,7 @@ public interface BpmTaskExtMapper extends BaseMapperX { return selectList(BpmTaskExtDO::getProcessInstanceId, processInstanceId); } + // TODO @ke:可以使用类上上面的 default 方法实现。然后,方法的命名上,要保持和 db 一样。因为 mapper 是数据层,不关注业务。例如说,这里,其实复用 updateByTaskId 方法即可 /** * 任务驳回 * @@ -38,6 +39,7 @@ public interface BpmTaskExtMapper extends BaseMapperX { */ Boolean backByTaskId(@Param("taskId") String taskId, @Param("reason") String reason); + // TODO @ke:tong上哈 /** * 逻辑删除任务 * diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/config/BpmFlowableConfiguration.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/config/BpmFlowableConfiguration.java index dd2b8a68e..cb2b52e61 100644 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/config/BpmFlowableConfiguration.java +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/config/BpmFlowableConfiguration.java @@ -29,7 +29,7 @@ public class BpmFlowableConfiguration { ObjectProvider listeners, BpmActivityBehaviorFactory bpmActivityBehaviorFactory) { return configuration -> { - // 注册监听器,例如说 BpmActivitiEventListener + // 注册监听器,例如说 BpmActivityEventListener configuration.setEventListeners(ListUtil.toList(listeners.iterator())); // 设置 ActivityBehaviorFactory 实现类,用于流程任务的审核人的自定义 configuration.setActivityBehaviorFactory(bpmActivityBehaviorFactory); diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/BpmActivityBehaviorFactory.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/BpmActivityBehaviorFactory.java index 0de96c6e9..dced1c5bd 100644 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/BpmActivityBehaviorFactory.java +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/BpmActivityBehaviorFactory.java @@ -39,4 +39,6 @@ public class BpmActivityBehaviorFactory extends DefaultActivityBehaviorFactory { .setBpmTaskRuleService(bpmTaskRuleService); } + // TODO @ke:SequentialMultiInstanceBehavior 这个抽空也可以看看 + } diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmActivityServiceImpl.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmActivityServiceImpl.java index 9c5f86982..0921f7204 100644 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmActivityServiceImpl.java +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmActivityServiceImpl.java @@ -34,8 +34,9 @@ public class BpmActivityServiceImpl implements BpmActivityService { @Override @TenantIgnore public List getActivityListByProcessInstanceId(String procInstId) { -// List activityList = historyService.createHistoricActivityInstanceQuery() -// .processInstanceId(procInstId).list(); +// List activityList = historyService.createHistoricActivityInstanceQuery() +// .processInstanceId(procInstId).list(); + // TODO @ke:这个是想要过滤掉 aha.act_type_ != 'sequenceFlow' 类型么? List bpmActivityDOList = bpmActivityMapper.listAllByProcInstIdAndDelete(procInstId); return BpmActivityConvert.INSTANCE.convertList(bpmActivityDOList); } diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskServiceImpl.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskServiceImpl.java index ef94eac90..7367594b2 100644 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskServiceImpl.java +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskServiceImpl.java @@ -188,6 +188,7 @@ public class BpmTaskServiceImpl implements BpmTaskService { // 拼接数据 // List tmpBpmTaskExtDOList = taskExtMapper.listByProcInstId(processInstanceId); + // TODO @ke:这个钉钉是咋处理的?得讨论下流程预测的需要程度哈。 List tmpBpmTaskExtDOList = taskExtMapper.selectListByProcessInstanceId(processInstanceId); tmpBpmTaskExtDOList.sort(Comparator.comparing(BpmTaskExtDO::getCreateTime)); return hiTaskInstService.taskGetComment(tmpBpmTaskExtDOList, ""); @@ -247,9 +248,11 @@ public class BpmTaskServiceImpl implements BpmTaskService { // List hisActInstList = // historyService.createHistoricActivityInstanceQuery().processInstanceId(reqVO.getProcInstId()).list(); + // TODO @ke:使用 historyService.createHistoricActivityInstanceQuery().processInstanceId(reqVO.getProcInstId()).list() 读取,会存在啥问题呀? List bpmActivityDOList = bpmActivityMapper.listAllByProcInstIdAndDelete(reqVO.getProcInstId()); // List bpmActivityDOList = BpmTaskConvert.INSTANCE.copyList(hisActInstList, BpmActivityDO.class); // bpmActivityDOList.forEach(bpmActivityDO -> log.info("bpmActivityDO = " + bpmActivityDO)); + // TODO @ke:如果 开始->a->b->c->d->结束,从 d 驳回到 b 的话,这样会不会导致 a 也被删除呀?http://blog.wya1.com/article/636697030/details/7296 可以看看这篇文章哈。 List taskIdList = bpmActivityDOList.stream().filter( bpmActivityDO -> bpmActivityDO.getActivityId().equals(reqVO.getOldTaskDefKey()) && !bpmActivityDO.getTaskId().equals(reqVO.getTaskId())).map(BpmActivityDO::getTaskId)