lyh
2025-05-09 58270402a93c8ad2742e00408cf6bbc54c75898c
lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ComponentInfoSeServiceImpl.java
@@ -608,13 +608,14 @@
        //权限排除,不能引用自己上下级部件
        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());
@@ -624,6 +625,7 @@
            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);
            }
@@ -678,6 +680,10 @@
            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("部件借用成功");