From 3720a648d78dc0bbc70f826eb4ec003058e54cb2 Mon Sep 17 00:00:00 2001 From: kyle <573984425@qq.com> Date: Wed, 17 Jan 2024 09:29:14 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E6=B7=BB=E5=8A=A0=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E7=BC=BA=E5=B0=91=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BpmProcessInstanceCCMyPageReqVO.java | 2 +- .../BpmProcessInstanceCCPageItemRespVO.java | 20 +++++++------------ .../cc/BpmProcessInstanceCopyConvert.java | 12 +++++------ .../cc/BpmProcessInstanceCopyDO.java | 13 +++++++++++- .../cc/BpmProcessInstanceCopyMapper.java | 3 +-- .../cc/BpmProcessInstanceCopyServiceImpl.java | 7 +++++-- .../service/cc/BpmProcessInstanceCopyVO.java | 14 ++++++++----- .../yudao/module/bpm/util/FlowableUtils.java | 7 ++++++- 8 files changed, 47 insertions(+), 31 deletions(-) diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstanceCCMyPageReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstanceCCMyPageReqVO.java index 803616bcb..44de17d38 100644 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstanceCCMyPageReqVO.java +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstanceCCMyPageReqVO.java @@ -18,7 +18,7 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ public class BpmProcessInstanceCCMyPageReqVO extends PageParam { @Schema(description = "流程名称", example = "芋道") - private String name; + private String processInstanceName; @Schema(description = "流程编号", example = "123456768") private String processInstanceId; diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstanceCCPageItemRespVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstanceCCPageItemRespVO.java index 5b2a12e2d..2315730ff 100644 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstanceCCPageItemRespVO.java +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstanceCCPageItemRespVO.java @@ -23,11 +23,7 @@ public class BpmProcessInstanceCCPageItemRespVO { @Schema(description = "发起人别名") private String startUserNickname; - /** - * 表单名 - */ - @Schema(description = "流程实例的名字") - private String name; + /** * 流程主键 */ @@ -44,18 +40,16 @@ public class BpmProcessInstanceCCPageItemRespVO { @Schema(description = "发起抄送的任务名称") private String taskName; - /** - * 用户主键 - */ - @Schema(description = "用户编号") - private Long userId; - - @Schema(description = "用户别名") - private String userNickname; @Schema(description = "抄送原因") private String reason; + @Schema(description = "抄送人") + private String creator; + + @Schema(description = "抄送人别名") + private String creatorNickname; + @Schema(description = "抄送时间") private LocalDateTime createTime; } diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/cc/BpmProcessInstanceCopyConvert.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/cc/BpmProcessInstanceCopyConvert.java index 07fc0864b..49327a134 100644 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/cc/BpmProcessInstanceCopyConvert.java +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/cc/BpmProcessInstanceCopyConvert.java @@ -35,15 +35,15 @@ public interface BpmProcessInstanceCopyConvert { , Map userMap ) { List list = convertList(page.getList()); - for (BpmProcessInstanceCCPageItemRespVO vo:list){ - MapUtils.findAndThen(userMap, vo.getUserId(), - userName -> vo.setUserNickname(userName)); + for (BpmProcessInstanceCCPageItemRespVO vo : list) { + MapUtils.findAndThen(userMap, Long.valueOf(vo.getCreator()), + vo::setCreatorNickname); MapUtils.findAndThen(userMap, vo.getStartUserId(), - userName -> vo.setStartUserNickname(userName)); + vo::setStartUserNickname); MapUtils.findAndThen(taskMap, vo.getTaskId(), - name -> vo.setTaskName(name)); + vo::setTaskName); MapUtils.findAndThen(processInstaneMap, vo.getProcessInstanceId(), - name -> vo.setProcessInstanceName(name)); + vo::setProcessInstanceName); } return new PageResult<>(list, page.getTotal()); } diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/cc/BpmProcessInstanceCopyDO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/cc/BpmProcessInstanceCopyDO.java index b8e45e30a..1735f021e 100644 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/cc/BpmProcessInstanceCopyDO.java +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/cc/BpmProcessInstanceCopyDO.java @@ -33,7 +33,7 @@ public class BpmProcessInstanceCopyDO extends BaseDO { /** * 流程名 */ - private String name; + private String processInstanceName; /** * 流程主键 */ @@ -43,6 +43,12 @@ public class BpmProcessInstanceCopyDO extends BaseDO { * 任务主键 */ private String taskId; + + /** + * 任务名称 + */ + private String taskName; + /** * 用户主键 */ @@ -53,4 +59,9 @@ public class BpmProcessInstanceCopyDO extends BaseDO { */ private String reason; + /** + * 流程分类 + */ + private String processDefinitionCategory; + } diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/cc/BpmProcessInstanceCopyMapper.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/cc/BpmProcessInstanceCopyMapper.java index ba5a4d94a..af697f4e7 100644 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/cc/BpmProcessInstanceCopyMapper.java +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/cc/BpmProcessInstanceCopyMapper.java @@ -5,7 +5,6 @@ import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstanceCCMyPageReqVO; import cn.iocoder.yudao.module.bpm.dal.dataobject.cc.BpmProcessInstanceCopyDO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.task.BpmProcessInstanceExtDO; import org.apache.ibatis.annotations.Mapper; @Mapper @@ -14,7 +13,7 @@ public interface BpmProcessInstanceCopyMapper extends BaseMapperX() .eqIfPresent(BpmProcessInstanceCopyDO::getUserId, loginUserId) .eqIfPresent(BpmProcessInstanceCopyDO::getProcessInstanceId, reqVO.getProcessInstanceId()) - .likeIfPresent(BpmProcessInstanceCopyDO::getName, reqVO.getName()) + .likeIfPresent(BpmProcessInstanceCopyDO::getProcessInstanceName, reqVO.getProcessInstanceName()) .betweenIfPresent(BpmProcessInstanceCopyDO::getCreateTime, reqVO.getCreateTime()) .orderByDesc(BpmProcessInstanceCopyDO::getId)); } diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/cc/BpmProcessInstanceCopyServiceImpl.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/cc/BpmProcessInstanceCopyServiceImpl.java index 42cd570bf..865a6f699 100644 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/cc/BpmProcessInstanceCopyServiceImpl.java +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/cc/BpmProcessInstanceCopyServiceImpl.java @@ -18,6 +18,7 @@ import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; import lombok.extern.slf4j.Slf4j; import org.flowable.engine.RuntimeService; import org.flowable.engine.delegate.DelegateExecution; +import org.flowable.engine.repository.ProcessDefinition; import org.flowable.engine.runtime.ProcessInstance; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; @@ -75,6 +76,7 @@ public class BpmProcessInstanceCopyServiceImpl implements BpmProcessInstanceCopy // 调用 // 设置任务id copyDO.setTaskId(sourceInfo.getTaskId()); + copyDO.setTaskName(FlowableUtils.getTaskNameByTaskId(sourceInfo.getTaskId())); copyDO.setProcessInstanceId(sourceInfo.getProcessInstanceId()); ProcessInstance processInstance = runtimeService.createProcessInstanceQuery() .processInstanceId(sourceInfo.getProcessInstanceId()) @@ -84,7 +86,9 @@ public class BpmProcessInstanceCopyServiceImpl implements BpmProcessInstanceCopy return false; } copyDO.setStartUserId(FlowableUtils.getStartUserIdFromProcessInstance(processInstance)); - copyDO.setName(FlowableUtils.getFlowName(processInstance.getProcessDefinitionId())); + copyDO.setProcessInstanceName(processInstance.getName()); + ProcessDefinition processDefinition = FlowableUtils.getProcessDefinition(processInstance.getProcessDefinitionId()); + copyDO.setProcessDefinitionCategory(processDefinition.getCategory()); copyDO.setReason(sourceInfo.getReason()); copyDO.setCreator(sourceInfo.getCreator()); copyDO.setCreateTime(LocalDateTime.now()); @@ -131,7 +135,6 @@ public class BpmProcessInstanceCopyServiceImpl implements BpmProcessInstanceCopy userIds.add(doItem.getStartUserId()); Long userId = Long.valueOf(doItem.getCreator()); userIds.add(userId); - doItem.setUserId(userId); } Map taskNameByTaskIds = FlowableUtils.getTaskNameByTaskIds(taskIds); diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/cc/BpmProcessInstanceCopyVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/cc/BpmProcessInstanceCopyVO.java index 1cf0bc6b4..773335837 100644 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/cc/BpmProcessInstanceCopyVO.java +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/cc/BpmProcessInstanceCopyVO.java @@ -31,11 +31,7 @@ public class BpmProcessInstanceCopyVO { @Schema(description = "发起人别名") private String startUserNickname; - /** - * 表单名 - */ - @Schema(description = "流程实例的名字") - private String name; + /** * 流程主键 */ @@ -51,6 +47,8 @@ public class BpmProcessInstanceCopyVO { @Schema(description = "发起抄送的任务编号") private String taskId; + @Schema(description = "发起抄送的任务名称") + private String taskName; /** * 用户主键 */ @@ -60,6 +58,12 @@ public class BpmProcessInstanceCopyVO { @Schema(description = "用户别名") private Long userNickname; + @Schema(description = "抄送原因") + private String reason; + + @Schema(description = "抄送人") + private String creator; + @Schema(description = "抄送时间") private LocalDateTime createTime; } diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/util/FlowableUtils.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/util/FlowableUtils.java index 99f2a3761..94dabcd8e 100644 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/util/FlowableUtils.java +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/util/FlowableUtils.java @@ -31,12 +31,17 @@ public class FlowableUtils { * @param processDefinitionId * @return */ - public static String getFlowName(String processDefinitionId) { + public static String getProcessDefinitionName(String processDefinitionId) { RepositoryService repositoryService = SpringUtil.getBean(RepositoryService.class); ProcessDefinition processDefinition = repositoryService.getProcessDefinition(processDefinitionId); return processDefinition.getName(); } + public static ProcessDefinition getProcessDefinition(String processDefinitionId) { + RepositoryService repositoryService = SpringUtil.getBean(RepositoryService.class); + return repositoryService.getProcessDefinition(processDefinitionId); + } + /** * 获取节点数据 *