流程BUG修复
This commit is contained in:
parent
558e46c51f
commit
442685e8d9
@ -14,10 +14,8 @@ import org.flowable.engine.delegate.DelegateExecution;
|
||||
import org.flowable.engine.runtime.ProcessInstance;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@ -66,10 +64,11 @@ public class BpmTaskCurrentAssignLeaderScript extends BpmTaskAssignLeaderAbstrac
|
||||
}
|
||||
|
||||
int count = 0;
|
||||
Long parentId = dept.getParentId();
|
||||
for (int i = 0; i < dept.getLevel(); i++) {
|
||||
|
||||
if (i == 0) { //第一次查找 判断审批人是否为发起人部门负责人
|
||||
if (!dept.getLeaderUserId().toString().equals(assigneeUserId.toString())){ //如果发起人上级部门负责人不为当前审批人时
|
||||
if (!dept.getLeaderUserId().toString().equals(processInstance.getStartUserId())){ //如果发起人不是所在部门负责人时
|
||||
|
||||
count = 1;
|
||||
break;
|
||||
@ -77,7 +76,7 @@ public class BpmTaskCurrentAssignLeaderScript extends BpmTaskAssignLeaderAbstrac
|
||||
}
|
||||
|
||||
//获得发起人的上级部门
|
||||
DeptRespDTO parentDept = deptApi.getDept(dept.getParentId()).getCheckedData();
|
||||
DeptRespDTO parentDept = deptApi.getDept(parentId).getCheckedData();
|
||||
if (parentDept == null) { // 找不到父级部门,所以只好结束寻找。原因是:例如说,级别比较高的人,所在部门层级比较少
|
||||
return emptySet();
|
||||
}
|
||||
@ -87,6 +86,8 @@ public class BpmTaskCurrentAssignLeaderScript extends BpmTaskAssignLeaderAbstrac
|
||||
count = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
parentId = parentDept.getParentId();
|
||||
}
|
||||
|
||||
if (count == 0){// 找不到父级部门。原因是:人的所属部门配在了最高节点了
|
||||
|
@ -2,22 +2,28 @@ package cn.iocoder.yudao.module.bpm.service.message;
|
||||
|
||||
import cn.iocoder.yudao.framework.web.config.WebProperties;
|
||||
import cn.iocoder.yudao.module.bpm.convert.message.BpmMessageConvert;
|
||||
import cn.iocoder.yudao.module.bpm.dal.dataobject.task.BpmProcessInstanceExtDO;
|
||||
import cn.iocoder.yudao.module.bpm.enums.message.BpmMessageEnum;
|
||||
import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceResultEnum;
|
||||
import cn.iocoder.yudao.module.bpm.service.message.dto.BpmMessageSendWhenProcessInstanceApproveReqDTO;
|
||||
import cn.iocoder.yudao.module.bpm.service.message.dto.BpmMessageSendWhenProcessInstanceRejectReqDTO;
|
||||
import cn.iocoder.yudao.module.bpm.service.message.dto.BpmMessageSendWhenTaskCreatedReqDTO;
|
||||
import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceService;
|
||||
import cn.iocoder.yudao.module.system.api.notify.NotifyMessageSendApi;
|
||||
import cn.iocoder.yudao.module.system.api.sms.SmsSendApi;
|
||||
import cn.iocoder.yudao.module.system.api.subscribe.SubscribeMessageSendApi;
|
||||
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.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* BPM 消息 Service 实现类
|
||||
@ -41,6 +47,10 @@ public class BpmMessageServiceImpl implements BpmMessageService {
|
||||
@Resource
|
||||
private WebProperties webProperties;
|
||||
|
||||
@Resource
|
||||
@Lazy // 解决循环依赖
|
||||
private BpmProcessInstanceService bpmProcessInstanceService;
|
||||
|
||||
@Override
|
||||
public void sendMessageWhenProcessInstanceApprove(BpmMessageSendWhenProcessInstanceApproveReqDTO reqDTO) {
|
||||
//审批通过
|
||||
@ -49,10 +59,16 @@ public class BpmMessageServiceImpl implements BpmMessageService {
|
||||
templateParams.put("detailUrl", getProcessInstanceDetailUrl(reqDTO.getProcessInstanceId()));
|
||||
// smsSendApi.sendSingleSmsToAdmin(BpmMessageConvert.INSTANCE.convert(reqDTO.getStartUserId(),
|
||||
// BpmMessageEnum.PROCESS_INSTANCE_APPROVE.getSmsTemplateCode(), templateParams));
|
||||
|
||||
//当流程全部审批通过
|
||||
BpmProcessInstanceExtDO processInstance = bpmProcessInstanceService.getProcessInstanceDO(reqDTO.getProcessInstanceId());
|
||||
if (processInstance.getResult().equals(BpmProcessInstanceResultEnum.APPROVE.getResult())) {
|
||||
|
||||
//发送站内信息
|
||||
notifyMessageSendApi.sendSingleMessageToAdmin(BpmMessageConvert.INSTANCE.convert1(reqDTO.getStartUserId(),
|
||||
BpmMessageEnum.PROCESS_INSTANCE_APPROVE.getSmsTemplateCode(), templateParams));
|
||||
|
||||
//发送审批结果通知
|
||||
//发送审批结果通知至微信
|
||||
String openId = getUserOpenId(reqDTO.getStartUserId());
|
||||
if (openId != null) {
|
||||
subscribeMessageSendApi.sendApprovalResultNotification(
|
||||
@ -64,6 +80,28 @@ public class BpmMessageServiceImpl implements BpmMessageService {
|
||||
*/
|
||||
"formal"));
|
||||
}
|
||||
|
||||
//获取抄送用户ID
|
||||
String ccIDs = processInstance.getCcids();
|
||||
Pattern pattern = Pattern.compile("\\[(\\d+)]");
|
||||
Matcher matcher = pattern.matcher(ccIDs);
|
||||
while (matcher.find()) {
|
||||
String ccID = matcher.group(1);
|
||||
String ccOpenId = getUserOpenId(Long.valueOf(ccID));
|
||||
|
||||
//发送抄送信息至微信
|
||||
if (ccOpenId != null) {
|
||||
subscribeMessageSendApi.sendApprovalResultNotification(
|
||||
BpmMessageConvert.INSTANCE.convertApprovalResultNotification(
|
||||
openId, reqDTO.getProcessInstanceName(), reqDTO.getCreateTime(), "抄送", reqDTO.getReason(),
|
||||
reqDTO.getProcessInstanceId(),
|
||||
/**
|
||||
* 跳转小程序类型:developer为开发版;trial为体验版;formal为正式版;默认为正式版
|
||||
*/
|
||||
"formal"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -179,4 +179,11 @@ public interface BpmProcessInstanceService {
|
||||
*/
|
||||
List<BpmProcessFinishStatisticsRespVO> getUserProcessTpo10(BpmProcessInstanceStatisticsReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 获得流程实例
|
||||
*
|
||||
* @param id 流程实例的编号
|
||||
* @return 流程实例
|
||||
*/
|
||||
BpmProcessInstanceExtDO getProcessInstanceDO(String id);
|
||||
}
|
||||
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user