| | |
| | | //权限排除,不能引用自己上下级部件 |
| | | LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | String productIds = loginUser.getProductionIds(); |
| | | ComponentInfo oldComponentInfo = super.getById(componentInfo.getComponentId()); |
| | | IPage<ComponentInfo> page = new Page<>(pageNo, pageSize); |
| | | if (productIds != null && !productIds.isEmpty()) { |
| | | List<String> productIdList = Arrays.asList(productIds.split(",")); |
| | | List<ProductMix> productMixList = permissionStreamNewService. |
| | | loadProductMixByBusinessIdAndBusinessType(loginUser.getId(),productIdList,componentInfo.getComponentId(),"2"); |
| | | List<Long> ids = productMixList.stream().map(ProductMix::getId).collect(Collectors.toList()); |
| | | //获取已经被借用的部件 |
| | | //获取已经自身被借用的部件 |
| | | LambdaQueryWrapper<ComponentInfo> borrowQueryWrapper = new LambdaQueryWrapper<>(); |
| | | borrowQueryWrapper.in(ComponentInfo::getBorrowId,ids); |
| | | borrowQueryWrapper.eq(ComponentInfo::getParentId,componentInfo.getComponentId()); |
| | |
| | | queryWrapper.like(StrUtil.isNotEmpty(componentInfo.getComponentCode()),ComponentInfo::getComponentCode, componentInfo.getComponentCode()); |
| | | queryWrapper.isNull(ComponentInfo::getBorrowId); |
| | | queryWrapper.in(ComponentInfo::getComponentId,ids); |
| | | queryWrapper.ne(StrUtil.isNotEmpty(oldComponentInfo.getBorrowId()),ComponentInfo::getComponentId,oldComponentInfo.getBorrowId()); |
| | | if (!borrowIds.isEmpty()) { |
| | | queryWrapper.notIn(ComponentInfo::getComponentId,borrowIds); |
| | | } |
| | |
| | | newComponentInfo.setProductId(componentInfo.getProductId()); |
| | | newComponentInfo.setParentId(componentInfo.getComponentId()); |
| | | newComponentInfo.setBorrowId(item.getComponentId()); |
| | | newComponentInfo.setCreateTime(null); |
| | | newComponentInfo.setCreateBy(null); |
| | | newComponentInfo.setUpdateTime(null); |
| | | newComponentInfo.setUpdateBy(null); |
| | | addComponentInfo(newComponentInfo); |
| | | }); |
| | | return Result.ok("部件借用成功"); |