流程消息推送修改
This commit is contained in:
parent
442685e8d9
commit
1693bb20d0
@ -68,7 +68,8 @@ public class BpmTaskCurrentAssignLeaderScript extends BpmTaskAssignLeaderAbstrac
|
|||||||
for (int i = 0; i < dept.getLevel(); i++) {
|
for (int i = 0; i < dept.getLevel(); i++) {
|
||||||
|
|
||||||
if (i == 0) { //第一次查找 判断审批人是否为发起人部门负责人
|
if (i == 0) { //第一次查找 判断审批人是否为发起人部门负责人
|
||||||
if (!dept.getLeaderUserId().toString().equals(processInstance.getStartUserId())){ //如果发起人不是所在部门负责人时
|
if (assigneeUserId.toString().equals(processInstance.getStartUserId())
|
||||||
|
&& !dept.getLeaderUserId().toString().equals(processInstance.getStartUserId())){ //如果发起人不是所在部门负责人时
|
||||||
|
|
||||||
count = 1;
|
count = 1;
|
||||||
break;
|
break;
|
||||||
|
@ -4,7 +4,6 @@ import cn.hutool.core.collection.CollUtil;
|
|||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.iocoder.yudao.module.bpm.dal.dataobject.task.BpmTaskExtDO;
|
import cn.iocoder.yudao.module.bpm.dal.dataobject.task.BpmTaskExtDO;
|
||||||
import cn.iocoder.yudao.module.bpm.service.task.BpmActivityService;
|
import cn.iocoder.yudao.module.bpm.service.task.BpmActivityService;
|
||||||
import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceService;
|
|
||||||
import cn.iocoder.yudao.module.bpm.service.task.BpmTaskService;
|
import cn.iocoder.yudao.module.bpm.service.task.BpmTaskService;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@ -38,10 +37,6 @@ public class BpmTaskEventListener extends AbstractFlowableEngineEventListener {
|
|||||||
@Lazy // 解决循环依赖
|
@Lazy // 解决循环依赖
|
||||||
private BpmActivityService activityService;
|
private BpmActivityService activityService;
|
||||||
|
|
||||||
@Resource
|
|
||||||
@Lazy // 解决循环依赖
|
|
||||||
private BpmProcessInstanceService processInstanceService;
|
|
||||||
|
|
||||||
public static final Set<FlowableEngineEventType> TASK_EVENTS = ImmutableSet.<FlowableEngineEventType>builder()
|
public static final Set<FlowableEngineEventType> TASK_EVENTS = ImmutableSet.<FlowableEngineEventType>builder()
|
||||||
.add(FlowableEngineEventType.TASK_CREATED)
|
.add(FlowableEngineEventType.TASK_CREATED)
|
||||||
.add(FlowableEngineEventType.TASK_ASSIGNED)
|
.add(FlowableEngineEventType.TASK_ASSIGNED)
|
||||||
@ -57,9 +52,6 @@ public class BpmTaskEventListener extends AbstractFlowableEngineEventListener {
|
|||||||
protected void taskCreated(FlowableEngineEntityEvent event) {
|
protected void taskCreated(FlowableEngineEntityEvent event) {
|
||||||
Task task = (Task) event.getEntity();
|
Task task = (Task) event.getEntity();
|
||||||
taskService.createTaskExt(task);
|
taskService.createTaskExt(task);
|
||||||
|
|
||||||
//在TASK创建时, 监听审批人是否时发起人
|
|
||||||
taskService.approveAuto(task);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -93,7 +93,7 @@ public class BpmMessageServiceImpl implements BpmMessageService {
|
|||||||
if (ccOpenId != null) {
|
if (ccOpenId != null) {
|
||||||
subscribeMessageSendApi.sendApprovalResultNotification(
|
subscribeMessageSendApi.sendApprovalResultNotification(
|
||||||
BpmMessageConvert.INSTANCE.convertApprovalResultNotification(
|
BpmMessageConvert.INSTANCE.convertApprovalResultNotification(
|
||||||
openId, reqDTO.getProcessInstanceName(), reqDTO.getCreateTime(), "抄送", reqDTO.getReason(),
|
ccOpenId, reqDTO.getProcessInstanceName(), reqDTO.getCreateTime(), "抄送", reqDTO.getReason(),
|
||||||
reqDTO.getProcessInstanceId(),
|
reqDTO.getProcessInstanceId(),
|
||||||
/**
|
/**
|
||||||
* 跳转小程序类型:developer为开发版;trial为体验版;formal为正式版;默认为正式版
|
* 跳转小程序类型:developer为开发版;trial为体验版;formal为正式版;默认为正式版
|
||||||
@ -150,9 +150,10 @@ public class BpmMessageServiceImpl implements BpmMessageService {
|
|||||||
//站内信
|
//站内信
|
||||||
notifyMessageSendApi.sendSingleMessageToAdmin(BpmMessageConvert.INSTANCE.convert1(
|
notifyMessageSendApi.sendSingleMessageToAdmin(BpmMessageConvert.INSTANCE.convert1(
|
||||||
reqDTO.getAssigneeUserId(), BpmMessageEnum.TASK_ASSIGNED.getSmsTemplateCode(), templateParams));
|
reqDTO.getAssigneeUserId(), BpmMessageEnum.TASK_ASSIGNED.getSmsTemplateCode(), templateParams));
|
||||||
|
|
||||||
//微信小程序订阅消息
|
//微信小程序订阅消息
|
||||||
//发送OA流程待办提醒
|
//发送OA流程待办提醒
|
||||||
String openId = getUserOpenId(reqDTO.getStartUserId()); //只有在微信小程序登陆过用户才会有openid
|
String openId = getUserOpenId(assigneeUserId); //只有在微信小程序登陆过用户才会有openid
|
||||||
if (openId != null) {
|
if (openId != null) {
|
||||||
subscribeMessageSendApi.sendProcessToDoReminder(BpmMessageConvert.INSTANCE.convertProcessToDoReminder(
|
subscribeMessageSendApi.sendProcessToDoReminder(BpmMessageConvert.INSTANCE.convertProcessToDoReminder(
|
||||||
openId, reqDTO.getProcessInstanceName(), reqDTO.getStartUserNickname(), reqDTO.getCreateTime(), reqDTO.getSchedule(),
|
openId, reqDTO.getProcessInstanceName(), reqDTO.getStartUserNickname(), reqDTO.getCreateTime(), reqDTO.getSchedule(),
|
||||||
@ -172,7 +173,7 @@ public class BpmMessageServiceImpl implements BpmMessageService {
|
|||||||
|
|
||||||
private String getUserOpenId(Long userId) {
|
private String getUserOpenId(Long userId) {
|
||||||
AdminUserRespDTO adminUserRespDTO = adminUserApi.getUser(userId).getData();
|
AdminUserRespDTO adminUserRespDTO = adminUserApi.getUser(userId).getData();
|
||||||
String openId = adminUserRespDTO.getOpenId();
|
|
||||||
return openId;
|
return adminUserRespDTO.getOpenId();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -196,11 +196,4 @@ public interface BpmTaskService {
|
|||||||
* @return 当前任务的taskId
|
* @return 当前任务的taskId
|
||||||
*/
|
*/
|
||||||
String getCurrentTaskIdByProcessInstanceId(String processInstanceId) ;
|
String getCurrentTaskIdByProcessInstanceId(String processInstanceId) ;
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 监听 判断流程审批人是否是发起人
|
|
||||||
* @param task
|
|
||||||
*/
|
|
||||||
void approveAuto(Task task);
|
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,6 @@ import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.*;
|
|||||||
/**
|
/**
|
||||||
* 流程任务实例 Service 实现类
|
* 流程任务实例 Service 实现类
|
||||||
*
|
*
|
||||||
|
|
||||||
* @author jason
|
* @author jason
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@ -153,7 +152,6 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 执行查询
|
// 执行查询
|
||||||
List<Task> tasks = taskQuery.listPage(PageUtils.getStart(pageVO), pageVO.getPageSize());
|
List<Task> tasks = taskQuery.listPage(PageUtils.getStart(pageVO), pageVO.getPageSize());
|
||||||
if (CollUtil.isEmpty(tasks)) {
|
if (CollUtil.isEmpty(tasks)) {
|
||||||
@ -721,26 +719,60 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateTaskExtAssign(Task task) {
|
public void updateTaskExtAssign(Task task) {
|
||||||
BpmTaskExtDO taskExtDO =
|
// BpmTaskExtDO taskExtDO =
|
||||||
new BpmTaskExtDO().setAssigneeUserId(NumberUtils.parseLong(task.getAssignee())).setTaskId(task.getId());
|
// new BpmTaskExtDO().setAssigneeUserId(NumberUtils.parseLong(task.getAssignee())).setTaskId(task.getId());
|
||||||
taskExtMapper.updateByTaskId(taskExtDO);
|
// taskExtMapper.updateByTaskId(taskExtDO);
|
||||||
|
|
||||||
// 发送通知。在事务提交时,批量执行操作,所以直接查询会无法查询到 ProcessInstance,所以这里是通过监听事务的提交来实现。
|
// 发送通知。在事务提交时,批量执行操作,所以直接查询会无法查询到 ProcessInstance,所以这里是通过监听事务的提交来实现。
|
||||||
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
|
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void afterCommit() {
|
public void afterCommit() {
|
||||||
|
|
||||||
if (StrUtil.isNotEmpty(task.getAssignee())) {
|
if (StrUtil.isNotEmpty(task.getAssignee())) {
|
||||||
ProcessInstance processInstance =
|
|
||||||
processInstanceService.getProcessInstance(task.getProcessInstanceId());
|
ProcessInstance processInstance = processInstanceService.getProcessInstance(task.getProcessInstanceId());
|
||||||
if (processInstance != null) {
|
if (processInstance != null) {
|
||||||
// 获得任务列表
|
// 获得任务列表
|
||||||
List<BpmTaskRespVO> BpmTaskRespVOs = getTaskListByProcessInstanceId(processInstance.getProcessInstanceId());
|
List<BpmTaskRespVO> BpmTaskRespVOs = getTaskListByProcessInstanceId(processInstance.getProcessInstanceId());
|
||||||
AdminUserRespDTO startUser = adminUserApi.getUser(Long.valueOf(processInstance.getStartUserId())).getCheckedData();
|
AdminUserRespDTO startUser = adminUserApi.getUser(Long.valueOf(processInstance.getStartUserId())).getCheckedData();
|
||||||
|
//发送信息通知
|
||||||
messageService.sendMessageWhenTaskAssigned(
|
messageService.sendMessageWhenTaskAssigned(
|
||||||
BpmTaskConvert.INSTANCE.convert(processInstance, startUser, task, BpmTaskRespVOs));
|
BpmTaskConvert.INSTANCE.convert(processInstance, startUser, task, BpmTaskRespVOs));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterCompletion(int status) {
|
||||||
|
|
||||||
|
if(TransactionSynchronization.STATUS_COMMITTED == status){
|
||||||
|
|
||||||
|
ProcessInstance processInstance = processInstanceService.getProcessInstance(task.getProcessInstanceId());
|
||||||
|
|
||||||
|
//如果当前审批人是流程发起人,则自动通过当前审批节点
|
||||||
|
if (processInstance.getStartUserId().equals(task.getAssignee())) {
|
||||||
|
|
||||||
|
BpmTaskApproveReqVO reqVO = new BpmTaskApproveReqVO();
|
||||||
|
reqVO.setId(task.getId());
|
||||||
|
reqVO.setReason(BpmConstants.AUTO_APPRAVAL);
|
||||||
|
|
||||||
|
approveTask(Long.valueOf(task.getAssignee()), reqVO);
|
||||||
|
} else {
|
||||||
|
//判断 当前审批人是否在该流程中 已通过审批
|
||||||
|
//如果有,则自动审批通过该审批人节点
|
||||||
|
Long count = taskExtMapper.selectListCount(Long.valueOf(task.getAssignee()), task.getProcessInstanceId());
|
||||||
|
|
||||||
|
if (count > 0L) {
|
||||||
|
|
||||||
|
BpmTaskApproveReqVO reqVO = new BpmTaskApproveReqVO();
|
||||||
|
reqVO.setId(task.getId());
|
||||||
|
reqVO.setReason(BpmConstants.AUTO_APPRAVAL);
|
||||||
|
approveTask(Long.valueOf(task.getAssignee()), reqVO);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1083,6 +1115,7 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 判断当前类型是否为加签
|
* 判断当前类型是否为加签
|
||||||
|
*
|
||||||
* @param scopeType 任务的 scopeType
|
* @param scopeType 任务的 scopeType
|
||||||
* @return 当前 scopeType 为加签则返回 true
|
* @return 当前 scopeType 为加签则返回 true
|
||||||
*/
|
*/
|
||||||
@ -1185,43 +1218,4 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
|||||||
throw exception(TASK_NOT_EXISTS);
|
throw exception(TASK_NOT_EXISTS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 监听 判断流程审批人是否是发起人
|
|
||||||
* @param task
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void approveAuto(Task task) {
|
|
||||||
|
|
||||||
//在事务提交后, 进行判断
|
|
||||||
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void afterCommit() {
|
|
||||||
|
|
||||||
ProcessInstance processInstance = processInstanceService.getProcessInstance(task.getProcessInstanceId());
|
|
||||||
|
|
||||||
//如果当前审批人是流程发起人,则自动通过当前审批节点
|
|
||||||
if (processInstance.getStartUserId().equals(task.getAssignee())) {
|
|
||||||
|
|
||||||
BpmTaskApproveReqVO reqVO = new BpmTaskApproveReqVO();
|
|
||||||
reqVO.setId(task.getId());
|
|
||||||
reqVO.setReason(BpmConstants.AUTO_APPRAVAL);
|
|
||||||
approveTask(Long.valueOf(task.getAssignee()), reqVO);
|
|
||||||
}else {
|
|
||||||
//判断 当前审批人是否在该流程中 已通过审批
|
|
||||||
//如果有,则自动审批通过该审批人节点
|
|
||||||
Long count = taskExtMapper.selectListCount(Long.valueOf(task.getAssignee()), task.getProcessInstanceId());
|
|
||||||
|
|
||||||
if (count > 0L) {
|
|
||||||
|
|
||||||
BpmTaskApproveReqVO reqVO = new BpmTaskApproveReqVO();
|
|
||||||
reqVO.setId(task.getId());
|
|
||||||
reqVO.setReason(BpmConstants.AUTO_APPRAVAL);
|
|
||||||
approveTask(Long.valueOf(task.getAssignee()), reqVO);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user