whycxzp
2022-09-29 99d4a5f03f5c6dbb9db1117a8d2f37585d67b83b
excel内物料图片重命名
1个文件已修改
24 ■■■■ 已修改文件
src/main/java/com/whyc/service/ProductService.java 24 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/service/ProductService.java
@@ -270,7 +270,7 @@
                                    }
                                    String suffix = pictureData.suggestFileExtension();
                                    String picturePath = approvingPath + File.separator + bom.getSubModel() + "." + suffix;
                                    String picturePathFront = "doc_file" + File.separator + "product_submit" + File.separator + user.getName() + File.separator + dateFormat + File.separator + timeStamp + File.separator + bom.getSubModel() + "." + suffix;
                                    String picturePathFront = "doc_file" + File.separator + "product_submit" + File.separator + user.getName() + File.separator + dateFormat + File.separator + timeStamp + File.separator + bom.getSubModel() + "-bom." + suffix;
                                    byte[] data = pictureData.getData();
                                    FileOutputStream fileOutputStream = null;
                                    File pictureFile = new File(picturePath);
@@ -470,7 +470,7 @@
            File file = new File(fileUrl);
            List<String> fileUrlList = new LinkedList<>();
            List<String> excelExcludeUrlList = null;
            List<String> picUrlList = null;
            List<String> picUrlList = new LinkedList<>();
            //存于物料下,bom内有对应
            List<String> materialUrlList = new LinkedList<>();
            //存于产品下,bom内没对应
@@ -481,13 +481,13 @@
            fileUrlList = FileUtil.getStaticFilePath(file, fileUrlList);
            //图纸dwg 子件/产品
            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());
            //picUrlList = fileUrlList.stream().filter(url -> url.contains(".png") || url.contains(".jpeg")).collect(Collectors.toList());
            List<ProductBom> finalBomList = bomList;
            excelExcludeUrlList.forEach(excelExcludeUr -> {
                boolean existFlag = false;
                for (ProductBom bom : finalBomList) {
                    String filename = excelExcludeUr.substring(excelExcludeUr.lastIndexOf(File.separator) + 1, excelExcludeUr.length() - 4);
                    String filename = excelExcludeUr.substring(excelExcludeUr.lastIndexOf(File.separator) + 1, excelExcludeUr.lastIndexOf("."));
                    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);
@@ -498,24 +498,34 @@
                                + File.separator + fileFullName);
                        break;
                    }
                    else if((bom.getSubModel().toUpperCase()+"-BOM").equals(filename.toUpperCase()) && (excelExcludeUr.substring(excelExcludeUr.lastIndexOf(".")+1).equals("png") ||excelExcludeUr.substring(excelExcludeUr.lastIndexOf(".")+1).equals("jpeg"))
                    ){
                        picUrlList.add(excelExcludeUr);
                        existFlag = true;
                        bom.setPictureUrl("doc_file" + File.separator + "material"
                                + File.separator + fileFullName);
                        break;
                    }
                }
                if (!existFlag) {
                    productUrlList.add(excelExcludeUr);
                }
            });
            //一定是有对应物料的,从bom内剥离的
            /*//一定是有对应物料的,包含从bom内剥离的(删除掉:上面已经处理)
            picUrlList.forEach(picUrl -> {
                for (ProductBom bom : finalBomList) {
                    String filename = picUrl.substring(picUrl.lastIndexOf(File.separator) + 1, picUrl.lastIndexOf("."));
                    String fileFullName = picUrl.substring(picUrl.lastIndexOf(File.separator) + 1);
                    if (bom.getSubModel().toUpperCase().equals(filename.toUpperCase())) {
                    if ((bom.getSubModel().toUpperCase()+"-BOM").equals(filename.toUpperCase())) {
                        bom.setPictureUrl("doc_file" + File.separator + "material"
                                + File.separator + fileFullName);
                        break;
                    }
                }
            });
            });*/
            //转移路径
            String projectDir = CommonUtil.getProjectDir();