feat(bpm): 实现流程抄送推送待办功能
- 新增待办系统推送逻辑 - 集成 PortalRequest 和用户信息服务 - 构造并发送抄送待办请求 - 添加异常处理和日志记录- 支持创建人、接收人和发起人信息获取 - 实现待办消息的 PC 端跳转链接配置
This commit is contained in:
@@ -2,8 +2,15 @@ package com.jeelowcode.service.bpm.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.jeelowcode.framework.utils.tool.spring.SpringUtils;
|
||||
import com.jeelowcode.service.bpm.config.framework.portal.core.PortalRequest;
|
||||
import com.jeelowcode.service.bpm.config.framework.portal.core.dto.PortalTodoResponseDTO;
|
||||
import com.jeelowcode.service.bpm.config.framework.portal.core.dto.ReceiveCCRequestDTO;
|
||||
import com.jeelowcode.service.system.api.IApiAdminUserApi;
|
||||
import com.jeelowcode.service.system.dto.AdminUserRespDTO;
|
||||
import com.jeelowcode.tool.framework.common.pojo.PageResult;
|
||||
import com.jeelowcode.service.bpm.controller.vo.instance.BpmProcessInstanceCopyCreateReqVO;
|
||||
import com.jeelowcode.service.bpm.controller.vo.instance.BpmProcessInstanceCopyMyPageReqVO;
|
||||
@@ -16,6 +23,7 @@ import com.jeelowcode.service.bpm.service.IBpmProcessInstanceCopyService;
|
||||
import com.jeelowcode.service.bpm.service.IBpmProcessInstanceService;
|
||||
import com.jeelowcode.service.bpm.service.IBpmTaskService;
|
||||
import com.jeelowcode.service.bpm.dto.BpmDelegateExecutionDTO;
|
||||
import com.jeelowcode.tool.framework.common.util.object.ObjectUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.flowable.engine.RuntimeService;
|
||||
import org.flowable.engine.delegate.DelegateExecution;
|
||||
@@ -29,10 +37,12 @@ import javax.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.jeelowcode.tool.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static com.jeelowcode.tool.framework.common.util.json.JsonUtils.toJsonString;
|
||||
|
||||
/**
|
||||
* 流程抄送 Service 实现类
|
||||
@@ -59,6 +69,9 @@ public class BpmProcessInstanceCopyServiceImpl implements IBpmProcessInstanceCop
|
||||
@Resource
|
||||
@Lazy
|
||||
private IBpmProcessInstanceService bpmProcessInstanceService;
|
||||
@Lazy
|
||||
@Resource
|
||||
private IApiAdminUserApi apiAdminUserApi;
|
||||
|
||||
@Override
|
||||
public boolean makeCopy(BpmCandidateSourceInfo sourceInfo) {
|
||||
@@ -136,6 +149,37 @@ public class BpmProcessInstanceCopyServiceImpl implements IBpmProcessInstanceCop
|
||||
.setReason(reqVO.getReason())
|
||||
).collect(Collectors.toList());
|
||||
processInstanceCopyMapper.insertBatch(copyList);
|
||||
|
||||
// 3.推送给待办系统
|
||||
PortalRequest portalRequest = SpringUtils.getBean(PortalRequest.class);
|
||||
// 3.1 如果没有配置待办平台,则结束这个监听任务的执行
|
||||
if (ObjectUtil.isNull(portalRequest)) return;
|
||||
// 3.2 调用待办系统,发送待办消息
|
||||
try {
|
||||
copyList.stream().map(copy -> {
|
||||
AdminUserRespDTO creatorUser = apiAdminUserApi.getUser(Long.parseLong(copy.getCreator()));
|
||||
AdminUserRespDTO receiverUser = apiAdminUserApi.getUser(copy.getUserId());
|
||||
AdminUserRespDTO startUser = apiAdminUserApi.getUser(copy.getStartUserId());
|
||||
return new ReceiveCCRequestDTO()
|
||||
.setFlowId(copy.getProcessInstanceId())
|
||||
.setRequestName(copy.getProcessInstanceName() + "-" + startUser.getNickname() + "-" + DateUtil.formatDateTime(processInstance.getStartTime()))
|
||||
.setWorkflowName(copy.getProcessInstanceName())
|
||||
.setNodeName(copy.getTaskName())
|
||||
.setPcUrl("/process-instance/detail?id=" + copy.getProcessInstanceId())
|
||||
.setCreator(creatorUser.getUsername())
|
||||
.setCreateDateTime(copy.getCreateTime())
|
||||
.setReceiver(receiverUser.getUsername())
|
||||
.setReceiveDateTime(copy.getCreateTime())
|
||||
.setReceiveTs(System.currentTimeMillis());
|
||||
}
|
||||
).forEach(request -> {
|
||||
PortalTodoResponseDTO response = portalRequest.receiveCCRequest(request);
|
||||
log.info("[taskCompleted][推送待办成功 response({})]", toJsonString(response));
|
||||
});
|
||||
} catch (Exception e) {
|
||||
log.error("[createProcessInstanceCopy][推送待办失败]", e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user