From 386249a71cdfab885ece64c0442fe366ac661392 Mon Sep 17 00:00:00 2001
From: whycxzp <perryhsu@163.com>
Date: 星期三, 21 九月 2022 11:13:57 +0800
Subject: [PATCH] 产品附件更新和物料编码格式处理

---
 src/main/java/com/whyc/service/ProductService.java |   21 ++++++++++-----------
 1 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/src/main/java/com/whyc/service/ProductService.java b/src/main/java/com/whyc/service/ProductService.java
index 30a7429..1004216 100644
--- a/src/main/java/com/whyc/service/ProductService.java
+++ b/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();
                 }

--
Gitblit v1.9.1