Commit 422a48fdfc9f8fb4ce562a621f7d85a39ac38830
1 parent
36dfb64e
采购-报价管理:获取某采购处下所有可分配人员(采购处内贸科业务员、区域经理、采购处主管)
Showing
2 changed files
with
31 additions
and
1 deletions
| ... | ... | @@ -16,9 +16,11 @@ import com.lframework.starter.web.core.utils.PageResultUtil; |
| 16 | 16 | import com.lframework.starter.web.inner.bo.system.user.QuerySysUserBo; |
| 17 | 17 | import com.lframework.starter.web.inner.components.oplog.OtherOpLogType; |
| 18 | 18 | import com.lframework.starter.web.inner.entity.SysDept; |
| 19 | +import com.lframework.starter.web.inner.entity.SysRole; | |
| 19 | 20 | import com.lframework.starter.web.inner.entity.SysUser; |
| 20 | 21 | import com.lframework.starter.web.inner.entity.SysUserDept; |
| 21 | 22 | import com.lframework.starter.web.inner.service.system.SysDeptService; |
| 23 | +import com.lframework.starter.web.inner.service.system.SysRoleService; | |
| 22 | 24 | import com.lframework.starter.web.inner.service.system.SysUserDeptService; |
| 23 | 25 | import com.lframework.starter.web.inner.service.system.SysUserService; |
| 24 | 26 | import com.lframework.xingyun.sc.procurement.entity.SupplierQuotationDeal; |
| ... | ... | @@ -36,6 +38,7 @@ import java.util.ArrayList; |
| 36 | 38 | import java.util.Collections; |
| 37 | 39 | import java.util.List; |
| 38 | 40 | import java.util.Map; |
| 41 | +import java.util.HashSet; | |
| 39 | 42 | import java.util.Set; |
| 40 | 43 | import java.util.stream.Collectors; |
| 41 | 44 | import java.util.stream.Stream; |
| ... | ... | @@ -48,6 +51,18 @@ import org.springframework.transaction.annotation.Transactional; |
| 48 | 51 | public class SupplierQuotationDealServiceImpl |
| 49 | 52 | extends BaseMpServiceImpl<SupplierQuotationDealMapper, SupplierQuotationDeal> |
| 50 | 53 | implements SupplierQuotationDealService { |
| 54 | + | |
| 55 | + private static final Set<String> ALLOWED_ASSIGN_ROLE_CODES = new HashSet<>(); | |
| 56 | + | |
| 57 | + static { | |
| 58 | + ALLOWED_ASSIGN_ROLE_CODES.add("htcgeczg"); | |
| 59 | + ALLOWED_ASSIGN_ROLE_CODES.add("htcgyczg"); | |
| 60 | + ALLOWED_ASSIGN_ROLE_CODES.add("ltcgczg"); | |
| 61 | + ALLOWED_ASSIGN_ROLE_CODES.add("nmcgkywy"); | |
| 62 | + ALLOWED_ASSIGN_ROLE_CODES.add("qyjl"); | |
| 63 | + ALLOWED_ASSIGN_ROLE_CODES.add("ztcgczg"); | |
| 64 | + } | |
| 65 | + | |
| 51 | 66 | @Resource |
| 52 | 67 | private SupplierQuotationProjectMapper supplierQuotationProjectMapper; |
| 53 | 68 | @Resource |
| ... | ... | @@ -58,6 +73,8 @@ public class SupplierQuotationDealServiceImpl |
| 58 | 73 | private SysUserDeptService sysUserDeptService; |
| 59 | 74 | @Resource |
| 60 | 75 | private SysUserService sysUserService; |
| 76 | + @Resource | |
| 77 | + private SysRoleService sysRoleService; | |
| 61 | 78 | |
| 62 | 79 | @Transactional(rollbackFor = Exception.class) |
| 63 | 80 | @Override |
| ... | ... | @@ -180,6 +197,8 @@ public class SupplierQuotationDealServiceImpl |
| 180 | 197 | return Collections.emptyList(); |
| 181 | 198 | } |
| 182 | 199 | return userList.stream() |
| 200 | + .filter(user -> matchAllowedAssignRole(user.getId())) | |
| 201 | + .sorted((o1, o2) -> StringUtils.defaultString(o1.getName()).compareTo(StringUtils.defaultString(o2.getName()))) | |
| 183 | 202 | .map(QuerySysUserBo::new) |
| 184 | 203 | .collect(Collectors.toList()); |
| 185 | 204 | } |
| ... | ... | @@ -213,4 +232,15 @@ public class SupplierQuotationDealServiceImpl |
| 213 | 232 | .distinct() |
| 214 | 233 | .collect(Collectors.toList()); |
| 215 | 234 | } |
| 235 | + | |
| 236 | + private boolean matchAllowedAssignRole(String userId) { | |
| 237 | + List<SysRole> sysRoleList = sysRoleService.getByUserId(userId); | |
| 238 | + if (CollectionUtil.isEmpty(sysRoleList)) { | |
| 239 | + return false; | |
| 240 | + } | |
| 241 | + return sysRoleList.stream() | |
| 242 | + .map(SysRole::getCode) | |
| 243 | + .filter(StringUtils::isNotBlank) | |
| 244 | + .anyMatch(ALLOWED_ASSIGN_ROLE_CODES::contains); | |
| 245 | + } | |
| 216 | 246 | } | ... | ... |
| ... | ... | @@ -30,7 +30,7 @@ public interface SupplierQuotationDealService extends BaseMpService<SupplierQuot |
| 30 | 30 | void assign(AssignSupplierQuotationDealVo vo); |
| 31 | 31 | |
| 32 | 32 | /** |
| 33 | - * 获取当前部门及其子部门下人员 | |
| 33 | + * 获取当前部门及其子部门下人员(采购处主管、区域经理、采购处业务员) | |
| 34 | 34 | * |
| 35 | 35 | * @param purchaseDepartment 部门主键 |
| 36 | 36 | */ | ... | ... |