dev
parent
9dcbb9e3ee
commit
3472cd4a8f
@ -0,0 +1,81 @@
|
||||
package org.dromara.workflow.listener;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.lang.TypeReference;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.dromara.common.core.enums.BusinessStatusEnum;
|
||||
import org.dromara.common.core.exception.ServiceException;
|
||||
import org.dromara.common.core.utils.StreamUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.satoken.utils.LoginHelper;
|
||||
import org.dromara.system.api.RemoteDeptService;
|
||||
import org.dromara.system.api.RemoteUserService;
|
||||
import org.dromara.warm.flow.core.FlowEngine;
|
||||
import org.dromara.warm.flow.core.dto.FlowParams;
|
||||
import org.dromara.warm.flow.core.entity.Definition;
|
||||
import org.dromara.warm.flow.core.entity.Instance;
|
||||
import org.dromara.warm.flow.core.entity.Task;
|
||||
import org.dromara.warm.flow.core.listener.GlobalListener;
|
||||
import org.dromara.warm.flow.core.listener.Listener;
|
||||
import org.dromara.warm.flow.core.listener.ListenerVariable;
|
||||
import org.dromara.workflow.common.ConditionalOnEnable;
|
||||
import org.dromara.workflow.common.constant.FlowConstant;
|
||||
import org.dromara.workflow.common.enums.TaskStatusEnum;
|
||||
import org.dromara.workflow.domain.bo.FlowCopyBo;
|
||||
import org.dromara.workflow.domain.vo.NodeExtVo;
|
||||
import org.dromara.workflow.handler.FlowProcessEventHandler;
|
||||
import org.dromara.workflow.service.IFlwCommonService;
|
||||
import org.dromara.workflow.service.IFlwInstanceService;
|
||||
import org.dromara.workflow.service.IFlwNodeExtService;
|
||||
import org.dromara.workflow.service.IFlwTaskService;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 全局任务办理监听
|
||||
*
|
||||
* @author may
|
||||
*/
|
||||
@ConditionalOnEnable
|
||||
@Component
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
public class CrmFlightBookingListener implements Listener {
|
||||
|
||||
private final IFlwNodeExtService nodeExtService;
|
||||
private final FlowProcessEventHandler flowProcessEventHandler;
|
||||
|
||||
@DubboReference
|
||||
private RemoteUserService userService;
|
||||
|
||||
@DubboReference
|
||||
private final RemoteDeptService deptService;
|
||||
|
||||
@Override
|
||||
public void notify(ListenerVariable listenerVariable) {
|
||||
Map<String, Object> variable = listenerVariable.getVariable();
|
||||
Instance instance = listenerVariable.getInstance();
|
||||
Set<String> newList = new HashSet<>();
|
||||
Long createById = Long.valueOf(instance.getCreateBy());
|
||||
Long deptId = userService.getUserInfo(createById, LoginHelper.getTenantId()).getDeptId();
|
||||
Long leaderId = deptService.selectDeptLeaderById(deptId);
|
||||
if (ObjectUtil.isNull(leaderId)) {
|
||||
throw new ServiceException("当前部门未设置负责人,请联系管理员操作。");
|
||||
}
|
||||
newList.add(leaderId.toString());
|
||||
List<FlowCopyBo> list = StreamUtils.toList(newList, x -> {
|
||||
FlowCopyBo bo = new FlowCopyBo();
|
||||
Long id = Convert.toLong(x);
|
||||
bo.setUserId(id);
|
||||
bo.setUserName(userService.selectUserNameById(id));
|
||||
return bo;
|
||||
});
|
||||
variable.put(FlowConstant.FLOW_COPY_LIST, list);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue