whycxzp
2022-09-21 386249a71cdfab885ece64c0442fe366ac661392
src/main/java/com/whyc/service/ProductService.java
@@ -3,7 +3,6 @@
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.whyc.dto.FileUrlDTO;
import com.whyc.dto.Response;
@@ -444,7 +443,7 @@
        }else {
            File file = new File(fileUrl);
            List<String> fileUrlList = new LinkedList<>();
            List<String> dwgUrlList = null;
            List<String> excelExcludeUrlList = null;
            List<String> picUrlList = null;
            //存于物料下,bom内有对应
            List<String> materialUrlList = new LinkedList<>();
@@ -455,17 +454,17 @@
            fileUrlList = FileUtil.getStaticFilePath(file, fileUrlList);
            //图纸dwg 子件/产品
            dwgUrlList = fileUrlList.stream().filter(url -> url.contains(".dwg")).collect(Collectors.toList());
            excelExcludeUrlList = fileUrlList.stream().filter(url -> !(url.contains(".xls") || url.contains(".xlsx"))).collect(Collectors.toList());
            picUrlList = fileUrlList.stream().filter(url -> url.contains(".png") || url.contains(".jpeg")).collect(Collectors.toList());
            List<ProductBom> finalBomList = bomList;
            dwgUrlList.forEach(dwgUrl -> {
            excelExcludeUrlList.forEach(excelExcludeUr -> {
                boolean existFlag = false;
                for (ProductBom bom : finalBomList) {
                    String filename = dwgUrl.substring(dwgUrl.lastIndexOf(File.separator) + 1, dwgUrl.length() - 4);
                    String fileFullName = dwgUrl.substring(dwgUrl.lastIndexOf(File.separator) + 1);
                    if (bom.getSubModel().toUpperCase().equals(filename.toUpperCase())) {
                        materialUrlList.add(dwgUrl);
                    String filename = excelExcludeUr.substring(excelExcludeUr.lastIndexOf(File.separator) + 1, excelExcludeUr.length() - 4);
                    String fileFullName = excelExcludeUr.substring(excelExcludeUr.lastIndexOf(File.separator) + 1);
                    if (bom.getSubModel().toUpperCase().equals(filename.toUpperCase()) && excelExcludeUr.substring(excelExcludeUr.lastIndexOf(".")+1).equals("dwg")) {
                        materialUrlList.add(excelExcludeUr);
                        existFlag = true;
@@ -475,7 +474,7 @@
                    }
                }
                if (!existFlag) {
                    productUrlList.add(dwgUrl);
                    productUrlList.add(excelExcludeUr);
                }
            });
@@ -514,10 +513,10 @@
                materialFile.mkdirs();
            }
            productUrlList.forEach(productUrl -> {
                String dwgName = productUrl.substring(productUrl.lastIndexOf(File.separator) + 1, productUrl.length() - 4);
                String fileName = productUrl.substring(productUrl.lastIndexOf(File.separator) + 1);
                try {
                    FileCopyUtils.copy(new File(productUrl), new File(productDir + File.separator + dwgName + ".dwg"));
                    FileCopyUtils.copy(new File(productUrl), new File(productDir + File.separator + fileName));
                } catch (IOException e) {
                    e.printStackTrace();
                }