feat: 添加抄送人相关功能以及接口
This commit is contained in:
parent
1bc472b528
commit
8f171ba3d0
@ -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 (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 (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;
|
||||
|
||||
-- ----------------------------
|
||||
|
@ -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.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.service.cc.BpmProcessInstanceCopyService;
|
||||
import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceService;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
@ -26,6 +28,9 @@ public class BpmProcessInstanceController {
|
||||
@Resource
|
||||
private BpmProcessInstanceService processInstanceService;
|
||||
|
||||
@Resource
|
||||
private BpmProcessInstanceCopyService processInstanceCopyService;
|
||||
|
||||
@GetMapping("/my-page")
|
||||
@Operation(summary = "获得我的实例分页列表", description = "在【我的流程】菜单中,进行调用")
|
||||
@PreAuthorize("@ss.hasPermission('bpm:process-instance:query')")
|
||||
@ -56,4 +61,20 @@ public class BpmProcessInstanceController {
|
||||
processInstanceService.cancelProcessInstance(getLoginUserId(), cancelReqVO);
|
||||
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));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
}
|
@ -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;
|
||||
}
|
@ -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;
|
||||
}
|
@ -18,7 +18,4 @@ public class BpmTaskApproveReqVO {
|
||||
@NotEmpty(message = "审批意见不能为空")
|
||||
private String reason;
|
||||
|
||||
@Schema(description = "审批时流程抄送人", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
|
||||
private BpmTaskCandidateRuleVO ccCandidateRule;
|
||||
|
||||
}
|
||||
|
@ -1,11 +1,15 @@
|
||||
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.service.cc.BpmProcessInstanceCopyVO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 动态表单 Convert
|
||||
@ -16,10 +20,32 @@ import java.util.List;
|
||||
public interface BpmProcessInstanceCopyConvert {
|
||||
|
||||
BpmProcessInstanceCopyConvert INSTANCE = Mappers.getMapper(BpmProcessInstanceCopyConvert.class);
|
||||
|
||||
BpmProcessInstanceCopyDO copy(BpmProcessInstanceCopyDO bean);
|
||||
|
||||
BpmProcessInstanceCopyVO convert(BpmProcessInstanceCopyDO bean);
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ public class BpmProcessInstanceCopyDO extends BaseDO {
|
||||
*/
|
||||
private Long startUserId;
|
||||
/**
|
||||
* 表单名
|
||||
* 流程名
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
@ -48,5 +48,9 @@ public class BpmProcessInstanceCopyDO extends BaseDO {
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 抄送原因
|
||||
*/
|
||||
private String reason;
|
||||
|
||||
}
|
||||
|
@ -1,9 +1,21 @@
|
||||
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.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
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
@ -36,6 +36,10 @@ public class BpmCandidateSourceInfo {
|
||||
@Schema(description = "发起抄送的用户")
|
||||
private String creator;
|
||||
|
||||
@Schema(description = "抄送原因", requiredMode = Schema.RequiredMode.REQUIRED, example = "请帮忙审查下!")
|
||||
@NotEmpty(message = "抄送原因不能为空")
|
||||
private String reason;
|
||||
|
||||
public void addRule(BpmTaskCandidateRuleVO vo) {
|
||||
assert vo != null;
|
||||
if (rules == null) {
|
||||
|
@ -48,7 +48,9 @@ public class BpmCandidateSourceInfoProcessorChain {
|
||||
for (BpmCandidateSourceInfoProcessor processor : processorList) {
|
||||
try {
|
||||
for (BpmTaskCandidateRuleVO vo : sourceInfo.getRules()) {
|
||||
processor.validRuleOptions(vo.getType(), vo.getOptions());
|
||||
if (CollUtil.contains(processor.getSupportedTypes(), vo.getType())) {
|
||||
processor.validRuleOptions(vo.getType(), vo.getOptions());
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
@ -1,5 +1,9 @@
|
||||
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;
|
||||
|
||||
/**
|
||||
@ -23,4 +27,20 @@ public interface BpmProcessInstanceCopyService {
|
||||
* @return
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
@ -1,25 +1,32 @@
|
||||
package cn.iocoder.yudao.module.bpm.service.cc;
|
||||
|
||||
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.dal.dataobject.cc.BpmProcessInstanceCopyDO;
|
||||
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.BpmCandidateSourceInfoProcessorChain;
|
||||
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.system.api.user.AdminUserApi;
|
||||
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.runtime.ProcessInstance;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@ -40,6 +47,12 @@ public class BpmProcessInstanceCopyServiceImpl implements BpmProcessInstanceCopy
|
||||
@Resource
|
||||
private BpmCandidateSourceInfoProcessorChain processorChain;
|
||||
|
||||
@Resource
|
||||
@Lazy // 解决循环依赖
|
||||
private BpmTaskService taskService;
|
||||
@Resource
|
||||
private AdminUserApi adminUserApi;
|
||||
|
||||
@Override
|
||||
public BpmProcessInstanceCopyVO queryById(Long copyId) {
|
||||
BpmProcessInstanceCopyDO bpmProcessInstanceCopyDO = processInstanceCopyMapper.selectById(copyId);
|
||||
@ -60,7 +73,7 @@ public class BpmProcessInstanceCopyServiceImpl implements BpmProcessInstanceCopy
|
||||
} else {
|
||||
BpmProcessInstanceCopyDO copyDO = new BpmProcessInstanceCopyDO();
|
||||
// 调用
|
||||
//设置任务id
|
||||
// 设置任务id
|
||||
copyDO.setTaskId(sourceInfo.getTaskId());
|
||||
copyDO.setProcessInstanceId(sourceInfo.getProcessInstanceId());
|
||||
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery()
|
||||
@ -72,6 +85,7 @@ public class BpmProcessInstanceCopyServiceImpl implements BpmProcessInstanceCopy
|
||||
}
|
||||
copyDO.setStartUserId(FlowableUtils.getStartUserIdFromProcessInstance(processInstance));
|
||||
copyDO.setName(FlowableUtils.getFlowName(processInstance.getProcessDefinitionId()));
|
||||
copyDO.setReason(sourceInfo.getReason());
|
||||
copyDO.setCreator(sourceInfo.getCreator());
|
||||
copyDO.setCreateTime(LocalDateTime.now());
|
||||
List<BpmProcessInstanceCopyDO> copyList = new ArrayList<>(ccCandidates.size());
|
||||
@ -84,9 +98,50 @@ public class BpmProcessInstanceCopyServiceImpl implements BpmProcessInstanceCopy
|
||||
}
|
||||
}
|
||||
|
||||
public List<BpmProcessInstanceCopyVO> queryByProcessId() {
|
||||
return null;
|
||||
@Override
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
@ -27,6 +28,9 @@ public class BpmProcessInstanceCopyVO {
|
||||
*/
|
||||
@Schema(description = "发起人Id")
|
||||
private Long startUserId;
|
||||
|
||||
@Schema(description = "发起人别名")
|
||||
private String startUserNickname;
|
||||
/**
|
||||
* 表单名
|
||||
*/
|
||||
@ -38,14 +42,24 @@ public class BpmProcessInstanceCopyVO {
|
||||
@Schema(description = "流程实例的主键")
|
||||
private String processInstanceId;
|
||||
|
||||
@Schema(description = "流程实例的名字")
|
||||
private String processInstanceName;
|
||||
|
||||
/**
|
||||
* 任务主键
|
||||
*/
|
||||
@Schema(description = "发起抄送的任务编号")
|
||||
private String taskId;
|
||||
|
||||
/**
|
||||
* 用户主键
|
||||
*/
|
||||
@Schema(description = "用户编号")
|
||||
private Long userId;
|
||||
|
||||
@Schema(description = "用户别名")
|
||||
private Long userNickname;
|
||||
|
||||
@Schema(description = "抄送时间")
|
||||
private LocalDateTime createTime;
|
||||
}
|
||||
|
@ -242,18 +242,6 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
||||
.setReason(reqVO.getReason()));
|
||||
// 处理加签任务
|
||||
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("抄送任务失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package cn.iocoder.yudao.module.bpm.util;
|
||||
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import cn.iocoder.yudao.framework.common.util.number.NumberUtils;
|
||||
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.engine.RepositoryService;
|
||||
import org.flowable.engine.RuntimeService;
|
||||
import org.flowable.engine.TaskService;
|
||||
import org.flowable.engine.repository.ProcessDefinition;
|
||||
import org.flowable.engine.runtime.ProcessInstance;
|
||||
import org.flowable.task.api.Task;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 流程引擎工具类封装
|
||||
@ -47,9 +49,9 @@ public class FlowableUtils {
|
||||
RuntimeService runtimeService = SpringUtil.getBean(RuntimeService.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);
|
||||
//传节点定义key获取当前节点
|
||||
// 传节点定义key获取当前节点
|
||||
FlowNode flowNode = (FlowNode) bpmnModel.getFlowElement(nodeId);
|
||||
return flowNode;
|
||||
}
|
||||
@ -75,4 +77,44 @@ public class FlowableUtils {
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user