feat: 添加抄送人相关功能以及接口

This commit is contained in:
kyle 2024-01-15 16:31:21 +08:00
parent 1bc472b528
commit 8f171ba3d0
16 changed files with 356 additions and 27 deletions

View File

@ -2478,6 +2478,15 @@ INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_i
INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2523, '客户限制配置导出', 'crm:customer-limit-config:export', 3, 5, 2518, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-11-18 13:33:53', '', '2023-11-18 13:33:53', b'0'); INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2523, '客户限制配置导出', 'crm:customer-limit-config:export', 3, 5, 2518, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-11-18 13:33:53', '', '2023-11-18 13:33:53', b'0');
INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2524, '系统配置', '', 1, 99, 2397, 'config', 'ep:connection', '', '', 0, b'1', b'1', b'1', '1', '2023-11-18 21:58:00', '1', '2023-11-18 21:58:00', b'0'); INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2524, '系统配置', '', 1, 99, 2397, 'config', 'ep:connection', '', '', 0, b'1', b'1', b'1', '1', '2023-11-18 21:58:00', '1', '2023-11-18 21:58:00', b'0');
INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2525, 'WebSocket 测试', '', 2, 7, 2, 'websocket', 'ep:connection', 'infra/webSocket/index', 'InfraWebSocket', 0, b'1', b'1', b'1', '1', '2023-11-23 19:41:55', '1', '2023-11-24 19:22:30', b'0'); INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2525, 'WebSocket 测试', '', 2, 7, 2, 'websocket', 'ep:connection', 'infra/webSocket/index', 'InfraWebSocket', 0, b'1', b'1', b'1', '1', '2023-11-23 19:41:55', '1', '2023-11-24 19:22:30', b'0');
INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`,
`component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`,
`updater`, `update_time`, `deleted`)
VALUES (2526, '抄送流程', '', 2, 21, 1200, 'processInstanceCC', 'eye', '/bpm/task/cc/index',
'BpmCCProcessInstance', 0, true, true, true, 1, '2023-01-13 16:14:00', '1', '2023-01-13 16:14:00', false),
(2527, '抄送流程查询', 'bpm:process-instance-cc:query', 3, 1, 2526, '', '', '', NULL, 0, b'1', b'1', b'1', '1',
'2023-01-13 16:14:00', '1', '2023-01-13 16:14:00', b'0'),
(2528, '抄送流程创建', 'bpm:process-instance-cc:create', 3, 2, 2526, '', '', '', NULL, 0, b'1', b'1', b'1', '1',
'2023-01-13 16:14:00', '1', '2023-01-13 16:14:00', b'0');
COMMIT; COMMIT;
-- ---------------------------- -- ----------------------------

View File

@ -2,7 +2,9 @@ package cn.iocoder.yudao.module.bpm.controller.admin.task;
import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.*; import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.*;
import cn.iocoder.yudao.module.bpm.service.cc.BpmProcessInstanceCopyService;
import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceService; import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceService;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameter;
@ -26,6 +28,9 @@ public class BpmProcessInstanceController {
@Resource @Resource
private BpmProcessInstanceService processInstanceService; private BpmProcessInstanceService processInstanceService;
@Resource
private BpmProcessInstanceCopyService processInstanceCopyService;
@GetMapping("/my-page") @GetMapping("/my-page")
@Operation(summary = "获得我的实例分页列表", description = "在【我的流程】菜单中,进行调用") @Operation(summary = "获得我的实例分页列表", description = "在【我的流程】菜单中,进行调用")
@PreAuthorize("@ss.hasPermission('bpm:process-instance:query')") @PreAuthorize("@ss.hasPermission('bpm:process-instance:query')")
@ -56,4 +61,20 @@ public class BpmProcessInstanceController {
processInstanceService.cancelProcessInstance(getLoginUserId(), cancelReqVO); processInstanceService.cancelProcessInstance(getLoginUserId(), cancelReqVO);
return success(true); return success(true);
} }
@PostMapping("/cc/create")
@Operation(summary = "抄送流程")
@PreAuthorize("@ss.hasPermission('bpm:process-instance-cc:create')")
public CommonResult<Boolean> createProcessInstanceCC(@Valid @RequestBody BpmProcessInstanceCCReqVO createReqVO) {
return success(processInstanceCopyService.ccProcessInstance(SecurityFrameworkUtils.getLoginUserId(), createReqVO));
}
@GetMapping("/cc/my-page")
@Operation(summary = "获得抄送流程分页列表")
@PreAuthorize("@ss.hasPermission('bpm:process-instance-cc:query')")
public CommonResult<PageResult<BpmProcessInstanceCCPageItemRespVO>> getProcessInstanceCCPage(@Valid BpmProcessInstanceCCMyPageReqVO pageReqVO) {
return success(processInstanceCopyService.getMyProcessInstanceCCPage(SecurityFrameworkUtils.getLoginUserId(), pageReqVO));
}
} }

View File

@ -0,0 +1,30 @@
package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - 流程实例抄送的分页 Item Response VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class BpmProcessInstanceCCMyPageReqVO extends PageParam {
@Schema(description = "流程名称", example = "芋道")
private String name;
@Schema(description = "流程编号", example = "123456768")
private String processInstanceId;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
}

View File

@ -0,0 +1,61 @@
package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDateTime;
@Schema(description = "管理后台 - 流程实例抄送的分页 Item Response VO")
@Data
public class BpmProcessInstanceCCPageItemRespVO {
/**
* 编号
*/
@Schema(description = "抄送主键")
private Long id;
/**
* 发起人Id
*/
@Schema(description = "发起人Id")
private Long startUserId;
@Schema(description = "发起人别名")
private String startUserNickname;
/**
* 表单名
*/
@Schema(description = "流程实例的名字")
private String name;
/**
* 流程主键
*/
@Schema(description = "流程实例的主键")
private String processInstanceId;
@Schema(description = "流程实例的名称")
private String processInstanceName;
/**
* 任务主键
*/
@Schema(description = "发起抄送的任务编号")
private String taskId;
@Schema(description = "发起抄送的任务名称")
private String taskName;
/**
* 用户主键
*/
@Schema(description = "用户编号")
private Long userId;
@Schema(description = "用户别名")
private String userNickname;
@Schema(description = "抄送原因")
private String reason;
@Schema(description = "抄送时间")
private LocalDateTime createTime;
}

View File

@ -0,0 +1,44 @@
package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance;
import cn.iocoder.yudao.module.bpm.controller.admin.candidate.vo.BpmTaskCandidateRuleVO;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.Set;
@Schema(description = "管理后台 - 流程实例的抄送 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class BpmProcessInstanceCCReqVO extends BpmTaskCandidateRuleVO {
@Schema(description = "任务编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
@NotEmpty(message = "任务编号不能为空")
private String taskKey;
@Schema(description = "任务名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
@NotEmpty(message = "任务名称不能为空")
private String taskName;
@Schema(description = "流程实例的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
@NotEmpty(message = "流程实例的编号不能为空")
private String processInstanceKey;
@Schema(description = "发起流程的用户的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
@NotNull(message = "发起流程的用户的编号不能为空")
private Long startUserId;
@Schema(description = "任务实例名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
@NotEmpty(message = "任务实例名称不能为空")
private String processInstanceName;
@Schema(description = "抄送原因", requiredMode = Schema.RequiredMode.REQUIRED, example = "请帮忙审查下!")
@NotBlank(message = "抄送原因不能为空")
private String reason;
}

View File

@ -18,7 +18,4 @@ public class BpmTaskApproveReqVO {
@NotEmpty(message = "审批意见不能为空") @NotEmpty(message = "审批意见不能为空")
private String reason; private String reason;
@Schema(description = "审批时流程抄送人", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
private BpmTaskCandidateRuleVO ccCandidateRule;
} }

View File

@ -1,11 +1,15 @@
package cn.iocoder.yudao.module.bpm.convert.cc; package cn.iocoder.yudao.module.bpm.convert.cc;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstanceCCPageItemRespVO;
import cn.iocoder.yudao.module.bpm.dal.dataobject.cc.BpmProcessInstanceCopyDO; import cn.iocoder.yudao.module.bpm.dal.dataobject.cc.BpmProcessInstanceCopyDO;
import cn.iocoder.yudao.module.bpm.service.cc.BpmProcessInstanceCopyVO; import cn.iocoder.yudao.module.bpm.service.cc.BpmProcessInstanceCopyVO;
import org.mapstruct.Mapper; import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers; import org.mapstruct.factory.Mappers;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* 动态表单 Convert * 动态表单 Convert
@ -16,10 +20,32 @@ import java.util.List;
public interface BpmProcessInstanceCopyConvert { public interface BpmProcessInstanceCopyConvert {
BpmProcessInstanceCopyConvert INSTANCE = Mappers.getMapper(BpmProcessInstanceCopyConvert.class); BpmProcessInstanceCopyConvert INSTANCE = Mappers.getMapper(BpmProcessInstanceCopyConvert.class);
BpmProcessInstanceCopyDO copy(BpmProcessInstanceCopyDO bean); BpmProcessInstanceCopyDO copy(BpmProcessInstanceCopyDO bean);
BpmProcessInstanceCopyVO convert(BpmProcessInstanceCopyDO bean); BpmProcessInstanceCopyVO convert(BpmProcessInstanceCopyDO bean);
List<BpmProcessInstanceCopyVO> convertList2(List<BpmProcessInstanceCopyDO> list); List<BpmProcessInstanceCopyVO> convertList2(List<BpmProcessInstanceCopyDO> list);
List<BpmProcessInstanceCCPageItemRespVO> convertList(List<BpmProcessInstanceCopyDO> list);
default PageResult<BpmProcessInstanceCCPageItemRespVO> convertPage(PageResult<BpmProcessInstanceCopyDO> page
, Map<String/* taskId */, String/* taskName */> taskMap
, Map<String/* processInstaneId */, String/* processInstaneName */> processInstaneMap
, Map<Long/* userId */, String/* userName */> userMap
) {
List<BpmProcessInstanceCCPageItemRespVO> list = convertList(page.getList());
for (BpmProcessInstanceCCPageItemRespVO vo:list){
MapUtils.findAndThen(userMap, vo.getUserId(),
userName -> vo.setUserNickname(userName));
MapUtils.findAndThen(userMap, vo.getStartUserId(),
userName -> vo.setStartUserNickname(userName));
MapUtils.findAndThen(taskMap, vo.getTaskId(),
name -> vo.setTaskName(name));
MapUtils.findAndThen(processInstaneMap, vo.getProcessInstanceId(),
name -> vo.setProcessInstanceName(name));
}
return new PageResult<>(list, page.getTotal());
}
} }

View File

@ -31,7 +31,7 @@ public class BpmProcessInstanceCopyDO extends BaseDO {
*/ */
private Long startUserId; private Long startUserId;
/** /**
* 表单 * 流程
*/ */
private String name; private String name;
/** /**
@ -48,5 +48,9 @@ public class BpmProcessInstanceCopyDO extends BaseDO {
*/ */
private Long userId; private Long userId;
/**
* 抄送原因
*/
private String reason;
} }

View File

@ -1,9 +1,21 @@
package cn.iocoder.yudao.module.bpm.dal.mysql.cc; package cn.iocoder.yudao.module.bpm.dal.mysql.cc;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; 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.cc.BpmProcessInstanceCopyDO;
import cn.iocoder.yudao.module.bpm.dal.dataobject.task.BpmProcessInstanceExtDO;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
@Mapper @Mapper
public interface BpmProcessInstanceCopyMapper extends BaseMapperX<BpmProcessInstanceCopyDO> { public interface BpmProcessInstanceCopyMapper extends BaseMapperX<BpmProcessInstanceCopyDO> {
default PageResult<BpmProcessInstanceCopyDO> selectPage(Long loginUserId, BpmProcessInstanceCCMyPageReqVO reqVO){
return selectPage(reqVO, new LambdaQueryWrapperX<BpmProcessInstanceCopyDO>()
.eqIfPresent(BpmProcessInstanceCopyDO::getUserId, loginUserId)
.eqIfPresent(BpmProcessInstanceCopyDO::getProcessInstanceId, reqVO.getProcessInstanceId())
.likeIfPresent(BpmProcessInstanceCopyDO::getName, reqVO.getName())
.betweenIfPresent(BpmProcessInstanceCopyDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc(BpmProcessInstanceCopyDO::getId));
}
} }

View File

@ -36,6 +36,10 @@ public class BpmCandidateSourceInfo {
@Schema(description = "发起抄送的用户") @Schema(description = "发起抄送的用户")
private String creator; private String creator;
@Schema(description = "抄送原因", requiredMode = Schema.RequiredMode.REQUIRED, example = "请帮忙审查下!")
@NotEmpty(message = "抄送原因不能为空")
private String reason;
public void addRule(BpmTaskCandidateRuleVO vo) { public void addRule(BpmTaskCandidateRuleVO vo) {
assert vo != null; assert vo != null;
if (rules == null) { if (rules == null) {

View File

@ -48,8 +48,10 @@ public class BpmCandidateSourceInfoProcessorChain {
for (BpmCandidateSourceInfoProcessor processor : processorList) { for (BpmCandidateSourceInfoProcessor processor : processorList) {
try { try {
for (BpmTaskCandidateRuleVO vo : sourceInfo.getRules()) { for (BpmTaskCandidateRuleVO vo : sourceInfo.getRules()) {
if (CollUtil.contains(processor.getSupportedTypes(), vo.getType())) {
processor.validRuleOptions(vo.getType(), vo.getOptions()); processor.validRuleOptions(vo.getType(), vo.getOptions());
} }
}
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
throw e; throw e;

View File

@ -1,5 +1,9 @@
package cn.iocoder.yudao.module.bpm.service.cc; package cn.iocoder.yudao.module.bpm.service.cc;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstanceCCMyPageReqVO;
import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstanceCCPageItemRespVO;
import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstanceCCReqVO;
import cn.iocoder.yudao.module.bpm.service.candidate.BpmCandidateSourceInfo; import cn.iocoder.yudao.module.bpm.service.candidate.BpmCandidateSourceInfo;
/** /**
@ -23,4 +27,20 @@ public interface BpmProcessInstanceCopyService {
* @return * @return
*/ */
boolean makeCopy(BpmCandidateSourceInfo sourceInfo); boolean makeCopy(BpmCandidateSourceInfo sourceInfo);
/**
* 流程实例的抄送
* @param loginUserId 当前登录用户
* @param createReqVO 创建的抄送请求
* @return 是否抄送成功抄送成功则返回true
*/
boolean ccProcessInstance(Long loginUserId, BpmProcessInstanceCCReqVO createReqVO);
/**
* 抄送的流程
* @param loginUserId 登录用户id
* @param pageReqVO 分页请求
* @return 抄送的分页结果
*/
PageResult<BpmProcessInstanceCCPageItemRespVO> getMyProcessInstanceCCPage(Long loginUserId, BpmProcessInstanceCCMyPageReqVO pageReqVO);
} }

View File

@ -1,25 +1,32 @@
package cn.iocoder.yudao.module.bpm.service.cc; package cn.iocoder.yudao.module.bpm.service.cc;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstanceCCMyPageReqVO;
import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstanceCCPageItemRespVO;
import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstanceCCReqVO;
import cn.iocoder.yudao.module.bpm.convert.cc.BpmProcessInstanceCopyConvert; import cn.iocoder.yudao.module.bpm.convert.cc.BpmProcessInstanceCopyConvert;
import cn.iocoder.yudao.module.bpm.dal.dataobject.cc.BpmProcessInstanceCopyDO; import cn.iocoder.yudao.module.bpm.dal.dataobject.cc.BpmProcessInstanceCopyDO;
import cn.iocoder.yudao.module.bpm.dal.mysql.cc.BpmProcessInstanceCopyMapper; import cn.iocoder.yudao.module.bpm.dal.mysql.cc.BpmProcessInstanceCopyMapper;
import cn.iocoder.yudao.module.bpm.service.candidate.BpmCandidateSourceInfo; import cn.iocoder.yudao.module.bpm.service.candidate.BpmCandidateSourceInfo;
import cn.iocoder.yudao.module.bpm.service.candidate.BpmCandidateSourceInfoProcessorChain; import cn.iocoder.yudao.module.bpm.service.candidate.BpmCandidateSourceInfoProcessorChain;
import cn.iocoder.yudao.module.bpm.service.cc.dto.BpmDelegateExecutionDTO; import cn.iocoder.yudao.module.bpm.service.cc.dto.BpmDelegateExecutionDTO;
import cn.iocoder.yudao.module.bpm.service.task.BpmTaskService;
import cn.iocoder.yudao.module.bpm.util.FlowableUtils; import cn.iocoder.yudao.module.bpm.util.FlowableUtils;
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.flowable.engine.RuntimeService; import org.flowable.engine.RuntimeService;
import org.flowable.engine.delegate.DelegateExecution; import org.flowable.engine.delegate.DelegateExecution;
import org.flowable.engine.runtime.ProcessInstance; import org.flowable.engine.runtime.ProcessInstance;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.ArrayList; import java.util.*;
import java.util.List; import java.util.stream.Collectors;
import java.util.Set;
@Slf4j @Slf4j
@Service @Service
@ -40,6 +47,12 @@ public class BpmProcessInstanceCopyServiceImpl implements BpmProcessInstanceCopy
@Resource @Resource
private BpmCandidateSourceInfoProcessorChain processorChain; private BpmCandidateSourceInfoProcessorChain processorChain;
@Resource
@Lazy // 解决循环依赖
private BpmTaskService taskService;
@Resource
private AdminUserApi adminUserApi;
@Override @Override
public BpmProcessInstanceCopyVO queryById(Long copyId) { public BpmProcessInstanceCopyVO queryById(Long copyId) {
BpmProcessInstanceCopyDO bpmProcessInstanceCopyDO = processInstanceCopyMapper.selectById(copyId); BpmProcessInstanceCopyDO bpmProcessInstanceCopyDO = processInstanceCopyMapper.selectById(copyId);
@ -60,7 +73,7 @@ public class BpmProcessInstanceCopyServiceImpl implements BpmProcessInstanceCopy
} else { } else {
BpmProcessInstanceCopyDO copyDO = new BpmProcessInstanceCopyDO(); BpmProcessInstanceCopyDO copyDO = new BpmProcessInstanceCopyDO();
// 调用 // 调用
//设置任务id // 设置任务id
copyDO.setTaskId(sourceInfo.getTaskId()); copyDO.setTaskId(sourceInfo.getTaskId());
copyDO.setProcessInstanceId(sourceInfo.getProcessInstanceId()); copyDO.setProcessInstanceId(sourceInfo.getProcessInstanceId());
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery() ProcessInstance processInstance = runtimeService.createProcessInstanceQuery()
@ -72,6 +85,7 @@ public class BpmProcessInstanceCopyServiceImpl implements BpmProcessInstanceCopy
} }
copyDO.setStartUserId(FlowableUtils.getStartUserIdFromProcessInstance(processInstance)); copyDO.setStartUserId(FlowableUtils.getStartUserIdFromProcessInstance(processInstance));
copyDO.setName(FlowableUtils.getFlowName(processInstance.getProcessDefinitionId())); copyDO.setName(FlowableUtils.getFlowName(processInstance.getProcessDefinitionId()));
copyDO.setReason(sourceInfo.getReason());
copyDO.setCreator(sourceInfo.getCreator()); copyDO.setCreator(sourceInfo.getCreator());
copyDO.setCreateTime(LocalDateTime.now()); copyDO.setCreateTime(LocalDateTime.now());
List<BpmProcessInstanceCopyDO> copyList = new ArrayList<>(ccCandidates.size()); List<BpmProcessInstanceCopyDO> copyList = new ArrayList<>(ccCandidates.size());
@ -84,9 +98,50 @@ public class BpmProcessInstanceCopyServiceImpl implements BpmProcessInstanceCopy
} }
} }
public List<BpmProcessInstanceCopyVO> queryByProcessId() { @Override
return null; public boolean ccProcessInstance(Long loginUserId, BpmProcessInstanceCCReqVO reqVO) {
// 在能正常审批的情况下抄送流程
BpmCandidateSourceInfo sourceInfo = new BpmCandidateSourceInfo();
sourceInfo.setTaskId(reqVO.getTaskKey());
sourceInfo.setProcessInstanceId(reqVO.getProcessInstanceKey());
sourceInfo.addRule(reqVO);
sourceInfo.setCreator(String.valueOf(loginUserId));
sourceInfo.setReason(reqVO.getReason());
if (!makeCopy(sourceInfo)) {
throw new RuntimeException("抄送任务失败");
}
return false;
} }
//获取流程抄送分页
@Override
public PageResult<BpmProcessInstanceCCPageItemRespVO> getMyProcessInstanceCCPage(Long loginUserId, BpmProcessInstanceCCMyPageReqVO pageReqVO) {
// 通过 BpmProcessInstanceExtDO 先查询到对应的分页
PageResult<BpmProcessInstanceCopyDO> pageResult = processInstanceCopyMapper.selectPage(loginUserId, pageReqVO);
if (CollUtil.isEmpty(pageResult.getList())) {
return new PageResult<>(pageResult.getTotal());
}
Set<String/* taskId */> taskIds = new HashSet<>();
Set<String/* processInstaneId */> processInstaneIds = new HashSet<>();
Set<Long/* userId */> userIds = new HashSet<>();
for (BpmProcessInstanceCopyDO doItem : pageResult.getList()) {
taskIds.add(doItem.getTaskId());
processInstaneIds.add(doItem.getProcessInstanceId());
userIds.add(doItem.getStartUserId());
Long userId = Long.valueOf(doItem.getCreator());
userIds.add(userId);
doItem.setUserId(userId);
}
Map<String, String> taskNameByTaskIds = FlowableUtils.getTaskNameByTaskIds(taskIds);
Map<String, String> processInstanceNameByTaskIds = FlowableUtils.getProcessInstanceNameByTaskIds(processInstaneIds);
Map<Long, String> userMap = adminUserApi.getUserList(userIds).stream().collect(Collectors.toMap(
AdminUserRespDTO::getId, AdminUserRespDTO::getNickname));
// 转换返回
return BpmProcessInstanceCopyConvert.INSTANCE.convertPage(pageResult, taskNameByTaskIds, processInstanceNameByTaskIds, userMap);
}
} }

View File

@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import java.time.LocalDateTime;
import java.util.Date; import java.util.Date;
@ -27,6 +28,9 @@ public class BpmProcessInstanceCopyVO {
*/ */
@Schema(description = "发起人Id") @Schema(description = "发起人Id")
private Long startUserId; private Long startUserId;
@Schema(description = "发起人别名")
private String startUserNickname;
/** /**
* 表单名 * 表单名
*/ */
@ -38,14 +42,24 @@ public class BpmProcessInstanceCopyVO {
@Schema(description = "流程实例的主键") @Schema(description = "流程实例的主键")
private String processInstanceId; private String processInstanceId;
@Schema(description = "流程实例的名字")
private String processInstanceName;
/** /**
* 任务主键 * 任务主键
*/ */
@Schema(description = "发起抄送的任务编号") @Schema(description = "发起抄送的任务编号")
private String taskId; private String taskId;
/** /**
* 用户主键 * 用户主键
*/ */
@Schema(description = "用户编号") @Schema(description = "用户编号")
private Long userId; private Long userId;
@Schema(description = "用户别名")
private Long userNickname;
@Schema(description = "抄送时间")
private LocalDateTime createTime;
} }

View File

@ -242,18 +242,6 @@ public class BpmTaskServiceImpl implements BpmTaskService {
.setReason(reqVO.getReason())); .setReason(reqVO.getReason()));
// 处理加签任务 // 处理加签任务
handleParentTask(task); handleParentTask(task);
// 在能正常审批的情况下抄送流程
if (null != reqVO.getCcCandidateRule()) {
BpmCandidateSourceInfo sourceInfo = new BpmCandidateSourceInfo();
sourceInfo.setTaskId(reqVO.getId());
sourceInfo.setProcessInstanceId(instance.getId());
sourceInfo.addRule(reqVO.getCcCandidateRule());
sourceInfo.setCreator(String.valueOf(userId));
if (!processInstanceCopyService.makeCopy(sourceInfo)) {
throw new RuntimeException("抄送任务失败");
}
}
} }

View File

@ -1,6 +1,7 @@
package cn.iocoder.yudao.module.bpm.util; package cn.iocoder.yudao.module.bpm.util;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.extra.spring.SpringUtil; import cn.hutool.extra.spring.SpringUtil;
import cn.iocoder.yudao.framework.common.util.number.NumberUtils; import cn.iocoder.yudao.framework.common.util.number.NumberUtils;
import org.flowable.bpmn.model.BpmnModel; import org.flowable.bpmn.model.BpmnModel;
@ -9,11 +10,12 @@ import org.flowable.bpmn.model.FlowElement;
import org.flowable.bpmn.model.FlowNode; import org.flowable.bpmn.model.FlowNode;
import org.flowable.engine.RepositoryService; import org.flowable.engine.RepositoryService;
import org.flowable.engine.RuntimeService; import org.flowable.engine.RuntimeService;
import org.flowable.engine.TaskService;
import org.flowable.engine.repository.ProcessDefinition; import org.flowable.engine.repository.ProcessDefinition;
import org.flowable.engine.runtime.ProcessInstance; import org.flowable.engine.runtime.ProcessInstance;
import org.flowable.task.api.Task;
import java.util.List; import java.util.*;
import java.util.Map;
/** /**
* 流程引擎工具类封装 * 流程引擎工具类封装
@ -47,9 +49,9 @@ public class FlowableUtils {
RuntimeService runtimeService = SpringUtil.getBean(RuntimeService.class); RuntimeService runtimeService = SpringUtil.getBean(RuntimeService.class);
RepositoryService repositoryService = SpringUtil.getBean(RepositoryService.class); RepositoryService repositoryService = SpringUtil.getBean(RepositoryService.class);
String definitionld = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult().getProcessDefinitionId(); //获取bpm模型对象 String definitionld = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult().getProcessDefinitionId(); // 获取bpm模型对象
BpmnModel bpmnModel = repositoryService.getBpmnModel(definitionld); BpmnModel bpmnModel = repositoryService.getBpmnModel(definitionld);
//传节点定义key获取当前节点 // 传节点定义key获取当前节点
FlowNode flowNode = (FlowNode) bpmnModel.getFlowElement(nodeId); FlowNode flowNode = (FlowNode) bpmnModel.getFlowElement(nodeId);
return flowNode; return flowNode;
} }
@ -75,4 +77,44 @@ public class FlowableUtils {
return NumberUtils.parseLong(instance.getStartUserId()); return NumberUtils.parseLong(instance.getStartUserId());
} }
public static String getTaskNameByTaskId(String taskId) {
TaskService taskService = SpringUtil.getBean(TaskService.class);
Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
return task.getName();
}
public static Map<String/* taskId */, String/* taskName */> getTaskNameByTaskIds(Collection<String> taskIds) {
TaskService taskService = SpringUtil.getBean(TaskService.class);
List<Task> tasks = taskService.createTaskQuery().taskIds(taskIds).list();
if (CollUtil.isNotEmpty(tasks)) {
Map<String/* taskId */, String/* taskName */> taskMap = new HashMap<>(tasks.size());
for (Task task : tasks) {
taskMap.putIfAbsent(task.getId(), task.getName());
}
return taskMap;
}
return Collections.emptyMap();
}
public static String getProcessInstanceNameByTaskId(String processInstanceId) {
RuntimeService runtimeService = SpringUtil.getBean(RuntimeService.class);
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery()
.processInstanceId(processInstanceId)
.singleResult();
return processInstance.getName();
}
public static Map<String/* processInstaneId */, String/* processInstaneName */> getProcessInstanceNameByTaskIds(Set<String> taskIds) {
RuntimeService runtimeService = SpringUtil.getBean(RuntimeService.class);
List<ProcessInstance> processInstances = runtimeService.createProcessInstanceQuery().processInstanceIds(taskIds).list();
if (CollUtil.isNotEmpty(processInstances)) {
Map<String/* processInstaneId */, String/* processInstaneName */> processInstaneMap = new HashMap<>(processInstances.size());
for (ProcessInstance processInstance : processInstances) {
processInstaneMap.putIfAbsent(processInstance.getId(), processInstance.getName());
}
return processInstaneMap;
}
return Collections.emptyMap();
}
} }