Showing
1 changed file
with
45 additions
and
0 deletions
| @@ -3,6 +3,8 @@ package com.lframework.xingyun.sc.handlers; | @@ -3,6 +3,8 @@ package com.lframework.xingyun.sc.handlers; | ||
| 3 | import com.lframework.starter.web.core.utils.JsonUtil; | 3 | import com.lframework.starter.web.core.utils.JsonUtil; |
| 4 | import com.lframework.starter.web.inner.entity.SysDept; | 4 | import com.lframework.starter.web.inner.entity.SysDept; |
| 5 | import com.lframework.starter.web.inner.entity.SysUserDept; | 5 | import com.lframework.starter.web.inner.entity.SysUserDept; |
| 6 | +import com.lframework.starter.web.inner.enums.system.SysDeptNodeType; | ||
| 7 | +import com.lframework.starter.web.inner.service.RecursionMappingService; | ||
| 6 | import com.lframework.starter.web.inner.service.system.SysDeptService; | 8 | import com.lframework.starter.web.inner.service.system.SysDeptService; |
| 7 | import com.lframework.starter.web.inner.service.system.SysUserDeptService; | 9 | import com.lframework.starter.web.inner.service.system.SysUserDeptService; |
| 8 | import com.lframework.starter.web.inner.service.system.SysUserRoleService; | 10 | import com.lframework.starter.web.inner.service.system.SysUserRoleService; |
| @@ -27,6 +29,9 @@ public class TransactorHandler { | @@ -27,6 +29,9 @@ public class TransactorHandler { | ||
| 27 | private WorkshopService workshopService; | 29 | private WorkshopService workshopService; |
| 28 | @Resource | 30 | @Resource |
| 29 | private SysDeptService sysDeptService; | 31 | private SysDeptService sysDeptService; |
| 32 | + @Resource | ||
| 33 | + private RecursionMappingService recursionMappingService; | ||
| 34 | + | ||
| 30 | 35 | ||
| 31 | 36 | ||
| 32 | /** | 37 | /** |
| @@ -59,6 +64,46 @@ public class TransactorHandler { | @@ -59,6 +64,46 @@ public class TransactorHandler { | ||
| 59 | } | 64 | } |
| 60 | 65 | ||
| 61 | /** | 66 | /** |
| 67 | + * 根据角色code和办事处ID获取办理人 | ||
| 68 | + * | ||
| 69 | + * @param roleCode 角色编号 | ||
| 70 | + * @param deptId 部门ID | ||
| 71 | + * @return List<String> | ||
| 72 | + */ | ||
| 73 | + public List<String> listTransactorsByRoleCodeAndDeptId(String roleCode, String deptId) { | ||
| 74 | + log.info("================== listTransactorsByRoleCodeAndDeptId invoke start, roleCode:{}, deptId:{}", roleCode, deptId); | ||
| 75 | + // 获取角色下人员 | ||
| 76 | + List<String> userIdList = sysUserRoleService.listUserIdByRoleCodes(Collections.singletonList(roleCode)); | ||
| 77 | + if (CollectionUtils.isEmpty(userIdList)) { | ||
| 78 | + return new ArrayList<>(); | ||
| 79 | + } | ||
| 80 | + List<String> result = new ArrayList<>(); | ||
| 81 | + // 获取所有部门(包含子部门) | ||
| 82 | + List<String> childDeptIds = recursionMappingService.getNodeChildIds(deptId, SysDeptNodeType.class); | ||
| 83 | + if (CollectionUtils.isNotEmpty(childDeptIds)) { | ||
| 84 | + childDeptIds.add(deptId); | ||
| 85 | + } else { | ||
| 86 | + return new ArrayList<>(); | ||
| 87 | + } | ||
| 88 | + for (String id : userIdList) { | ||
| 89 | + log.info("================== listTransactorsByRoleCodeAndDeptId userId:{}", id); | ||
| 90 | + List<SysUserDept> sysUserDeptList = userDeptService.getByUserId(id); | ||
| 91 | + log.info("================== listTransactorsByRoleCodeAndDeptId sysUserDeptList size:{}", CollectionUtils.isEmpty(sysUserDeptList) ? 0 : sysUserDeptList.size()); | ||
| 92 | + if (CollectionUtils.isNotEmpty(sysUserDeptList)) { | ||
| 93 | + List<String> deptIds = sysUserDeptList.stream() | ||
| 94 | + .map(SysUserDept::getDeptId) | ||
| 95 | + .collect(Collectors.toList()); | ||
| 96 | + if (childDeptIds.stream() | ||
| 97 | + .anyMatch(deptIds::contains)) { | ||
| 98 | + result.add(id); | ||
| 99 | + } | ||
| 100 | + } | ||
| 101 | + } | ||
| 102 | + log.info("================== listTransactorsByRoleCodeAndDeptId invoke end, transactors:{}", JsonUtil.toJsonString(result)); | ||
| 103 | + return result; | ||
| 104 | + } | ||
| 105 | + | ||
| 106 | + /** | ||
| 62 | * 根据角色code和厂房类型来获取办理人数据 | 107 | * 根据角色code和厂房类型来获取办理人数据 |
| 63 | * 客户开发 | 108 | * 客户开发 |
| 64 | * | 109 | * |