From 19e5ccb1aee7c0e0d308386e03cad72bf4997d0d Mon Sep 17 00:00:00 2001
From: whycxzp <perryhsu@163.com>
Date: 星期日, 25 六月 2023 17:24:02 +0800
Subject: [PATCH] 问题修复

---
 src/main/java/com/whyc/service/SOPService.java |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/main/java/com/whyc/service/SOPService.java b/src/main/java/com/whyc/service/SOPService.java
index 4c9df96..930cd46 100644
--- a/src/main/java/com/whyc/service/SOPService.java
+++ b/src/main/java/com/whyc/service/SOPService.java
@@ -18,9 +18,11 @@
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.FileCopyUtils;
 import org.springframework.web.multipart.MultipartFile;
 
 import javax.annotation.Resource;
+import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
 import java.text.ParseException;
@@ -306,10 +308,12 @@
         fileUrlTemp = fileUrlTemp.replace("sop_submit", "sop");
         sop.setFileUrl(fileUrlTemp);
         mapper.insert(sop);
-        sopProductList.forEach(product -> product.setSopId(sop.getId()));
-        productService.insertBatch(sopProductList);
+        if(sopProductList.size()>0) {
+            sopProductList.forEach(product -> product.setSopId(sop.getId()));
+            productService.insertBatch(sopProductList);
+        }
         //鏂囦欢杞Щ
-        /*String fileUrl = sop.getFileUrl();
+        String fileUrl = sop.getFileUrl();
         String projectDir = CommonUtil.getProjectDir();
         String filePathFrom = projectDir + File.separator + fileUrl.replace("sop","sop_submit");
         File fileFrom = new File(filePathFrom);
@@ -318,7 +322,7 @@
         if(!fileTo.getParentFile().exists()){
             fileTo.getParentFile().mkdirs();
         }
-        FileCopyUtils.copy(fileFrom,fileTo);*/
+        FileCopyUtils.copy(fileFrom,fileTo);
 
         //鏂板鐨勬枃浠剁被鍨�,杩藉姞鍒拌〃涓�
         List<SOPFileType> typeList = new LinkedList<>();

--
Gitblit v1.9.1