|
@@ -34,7 +34,6 @@ import com.ruoyi.common.utils.SecurityUtils;
|
|
|
import com.ruoyi.system.service.ISysDeptService;
|
|
|
import com.ruoyi.system.service.ISysUserIdentityService;
|
|
|
import com.ruoyi.system.service.ISysUserService;
|
|
|
-import com.ruoyi.system.utils.UserUtil;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -81,7 +80,7 @@ public class FlowProcessServiceImpl implements FlowProcessService {
|
|
|
@DSTransactional
|
|
|
@Override
|
|
|
public FlowResult initiate(InitiateDto dto) {
|
|
|
- dto.getData().put("createUser",SecurityUtils.getUserId());
|
|
|
+ dto.getData().put("createUser", SecurityUtils.getUserId());
|
|
|
|
|
|
// 获取流程委托对象
|
|
|
FlowDelegate flowDelegate = FlowBean.getBean(dto.getFlowKey());
|
|
@@ -981,13 +980,56 @@ public class FlowProcessServiceImpl implements FlowProcessService {
|
|
|
flowResult.setUserId(dynamicUserIdsStr);
|
|
|
return flowResult;
|
|
|
case DEPT_MANAGER:
|
|
|
- SysUser createUser = sysUserService.getById(FlowThreadLocalUtil.getFlowCreateUser());
|
|
|
+ Long deptId ;
|
|
|
+ if(ObjectUtil.isEmpty(node.getJumpCondition())){
|
|
|
+ //没表达式取发起人部门
|
|
|
+ SysUser createUser = sysUserService.getById(FlowThreadLocalUtil.getFlowCreateUser());
|
|
|
+ deptId = createUser.getDeptId();
|
|
|
+ }else {
|
|
|
+ //有表达式取表达式部门
|
|
|
+ Expression exp = AviatorEvaluator.compile(node.getJumpCondition());
|
|
|
+ Object execute = exp.execute(FlowThreadLocalUtil.getTemplateData());
|
|
|
+ if (ObjectUtil.isEmpty(execute)) {
|
|
|
+ throw new ServiceException("节点用户表达式结果为空!");
|
|
|
+ }
|
|
|
+ deptId = Long.valueOf(execute.toString());
|
|
|
+ }
|
|
|
+ //递归查询部门
|
|
|
+ SysDept sysDept1 = sysDeptService.getById(deptId);
|
|
|
+ while (sysDept1 != null && ObjectUtil.notEqual(sysDept1.getType(), 2)) {
|
|
|
+ Long deptParentId = sysDept1.getParentId();
|
|
|
+ if (ObjectUtil.isEmpty(deptParentId)) {
|
|
|
+ sysDept1 = null;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ sysDept1 = sysDeptService.getById(deptParentId);
|
|
|
+ }
|
|
|
+ if (sysDept1 == null) {
|
|
|
+ throw new ServiceException("无法找到节点部门信息!");
|
|
|
+ }
|
|
|
List<SysUserIdentity> identityList = sysUserIdentityService.list(Wrappers.<SysUserIdentity>lambdaQuery()
|
|
|
- .eq(SysUserIdentity::getDeptId, createUser.getDeptId())
|
|
|
- .eq(SysUserIdentity::getIdentity, 20)
|
|
|
+ .eq(SysUserIdentity::getDeptId, sysDept1.getDeptId())
|
|
|
+ .eq(SysUserIdentity::getIdentity, node.getHandleObjectId())
|
|
|
);
|
|
|
+ String identityName ;
|
|
|
+ switch (node.getHandleObjectId()){
|
|
|
+ case "10":
|
|
|
+ identityName = "员工";
|
|
|
+ break;
|
|
|
+ case "20":
|
|
|
+ identityName = "主管";
|
|
|
+ break;
|
|
|
+ case "30":
|
|
|
+ identityName = "经理";
|
|
|
+ break;
|
|
|
+ case "40":
|
|
|
+ identityName = "总监";
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ identityName = "未知职级";
|
|
|
+ }
|
|
|
if (identityList.size() == 0) {
|
|
|
- throw new ServiceException("流程节点处理人异常:当前所在部门无部门主管!");
|
|
|
+ throw new ServiceException(StrUtil.format("流程节点处理人异常:部门无部门{}!",identityName));
|
|
|
}
|
|
|
List<Long> userIds = identityList.stream().map(SysUserIdentity::getUserId).collect(Collectors.toList());
|
|
|
List<SysUser> identityUserList = sysUserService.list(Wrappers.<SysUser>lambdaQuery().in(SysUser::getUserId, userIds));
|
|
@@ -1003,7 +1045,7 @@ public class FlowProcessServiceImpl implements FlowProcessService {
|
|
|
Expression exp = AviatorEvaluator.compile(node.getJumpCondition());
|
|
|
Object execute = exp.execute(FlowThreadLocalUtil.getTemplateData());
|
|
|
if (ObjectUtil.isEmpty(execute)) {
|
|
|
- throw new ServiceException("节点用户表达式结果不能为空!");
|
|
|
+ throw new ServiceException("节点用户表达式结果为空!");
|
|
|
}
|
|
|
String userId = String.valueOf(execute);
|
|
|
SysUser sysUser = sysUserService.getById(Long.valueOf(userId));
|