whycxzp
2023-03-01 93a16e3707b870856594e89b950174b64bb7d6cd
src/main/java/com/whyc/service/ProductService.java
@@ -293,7 +293,8 @@
        }
        //产品bom对比
        Map<String,List> compareMap = pbhService.parseCompare(baseProduct,product);
        return response.setIII(1, true, product,compareMap, filePath);
        //return response.setIII(1, true, product,compareMap, filePath);
        return response.setIII(1, true, product,compareMap, zipFile.toString());
    }
@@ -310,13 +311,20 @@
        return list;
    }
    /**
     * 这个接口是进行产品新增,产品bom新增的接口.
     * 新增方式有很多,有直接从zip解析新增产品,也可以基于原有产品复制进行定制等.需要注意兼容!
     * @param product 产品新增,bom新增,产品版本更新
     * @return
     * @throws IOException
     */
    @Transactional
    public Response add(Product product) throws IOException {
        String parentCode = product.getParentCode();
        String customCode = product.getCustomCode();
        String parentModel = product.getParentModel();
        List<ProductBom> bomList = product.getBomList();
        String fileUrl = product.getFileUrl();
        String zipFilePath = product.getFileUrl();
        Date date = new Date();
        boolean isCopyCustom = false;
        Product relatedProduct = null;
@@ -328,6 +336,11 @@
            if(product.getId() != null){ //关联关系从产品id继承
                relatedProduct = getById(product.getId());
            }
        }
        //不是基于产品复制,则必定存在zip包,必然存在路径
        String fileUrl = null;
        if(!isCopyCustom) {
            fileUrl = zipFilePath.substring(0, zipFilePath.lastIndexOf(File.separator));
        }
        //查询新增产品最新的版本号
        ProductHistory latestProduct = phService.getLatestVersion(parentCode, customCode);
@@ -557,6 +570,10 @@
            if (!materialFile.exists()) {
                materialFile.mkdirs();
            }
            //之前上传的产品bom压缩包,转移到正式版本下留存
            File zipFileNew = new File(productDir + File.separator + zipFilePath.substring(zipFilePath.lastIndexOf(File.separator) + 1));
            FileCopyUtils.copy(new File(zipFilePath), zipFileNew);
            productUrlList.forEach(productUrl -> {
                String fileName = productUrl.substring(productUrl.lastIndexOf(File.separator) + 1);
@@ -753,4 +770,18 @@
        List listProduct=mapper.selectListProduct(productId);
        return new Response().setIII(1,listMaterial.size()>0||listProduct.size()>0,listMaterial,listProduct,"");
    }
    //反馈管理-查询当前使用的所有的产品
    public Response getFkProduct() {
        QueryWrapper wrapper=new QueryWrapper();
        wrapper.ne("version",-1);
        List list=mapper.selectList(wrapper);
        return new Response().setII(1,list.size()>0,list,"反馈管理-查询当前使用的所有的产品");
    }
    //产品对比下拉选中
    public Response getCompareProduct() {
        List list=mapper.selectList(null);
        return new Response().setII(1,list.size()>0,list,"产品对比下拉选中-查询当前使用的所有的产品");
    }
}