From cf9a5039e6db9d1d5963e3fe1a37d00169ec2ef7 Mon Sep 17 00:00:00 2001
From: whyclxw <810412026@qq.com>
Date: 星期三, 25 六月 2025 11:18:22 +0800
Subject: [PATCH] 验收报告修改

---
 src/main/java/com/whyc/service/DefectiveProductsHistoryService.java |   58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 56 insertions(+), 2 deletions(-)

diff --git a/src/main/java/com/whyc/service/DefectiveProductsHistoryService.java b/src/main/java/com/whyc/service/DefectiveProductsHistoryService.java
index 092a78c..9b0d6ac 100644
--- a/src/main/java/com/whyc/service/DefectiveProductsHistoryService.java
+++ b/src/main/java/com/whyc/service/DefectiveProductsHistoryService.java
@@ -4,8 +4,17 @@
 import com.whyc.mapper.DefectiveProductsHistoryMapper;
 import com.whyc.pojo.DefectiveProducts;
 import com.whyc.pojo.DefectiveProductsHistory;
+import com.whyc.util.ActionUtil;
+import com.whyc.util.CommonUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.xml.crypto.Data;
+import java.io.File;
+import java.io.IOException;
+import java.util.Date;
+import java.util.List;
 
 @Service
 public class DefectiveProductsHistoryService {
@@ -17,12 +26,57 @@
     public void addHis(DefectiveProducts defective) {
         DefectiveProductsHistory his=new DefectiveProductsHistory();
         his.setDeftId(defective.getId());
-        his.setRecordTime(defective.getStartTime());
-        his.setBadProduct(defective.getBadProduct());
+        his.setRecordTime(defective.getRecordTime());
         his.setConfirmStatus(defective.getConfirmStatus());
         his.setNote(defective.getNote());
         his.setReceiverIds(defective.getReceiverIds());
         his.setReceiverNames(defective.getReceiverNames());
+        his.setDelProduct(0);
+        his.setDelId(defective.getSenderId());
+        his.setDelName(defective.getSenderName());
+        his.setRestProduct(defective.getRestProduct());
         mapper.insert(his);
     }
+    //璁板綍澶勭悊璁板綍
+    public void updateDefective( DefectiveProducts defective,DefectiveProductsHistory defectiveHis, List<MultipartFile> multipartFileList) {
+        Date date=new Date();
+        defectiveHis.setRecordTime(date);
+        String recordTime=ActionUtil.sdfwithFTP.format(date);
+        String delName = ActionUtil.getUser().getName();
+        Integer delId =ActionUtil.getUser().getId().intValue();
+        defectiveHis.setDelId(delId);
+        defectiveHis.setDelName(delName);
+        String record = ActionUtil.sdfwithFTP.format(defective.getRecordTime());
+        String rootFile = CommonUtil.getRootFile();
+        if(multipartFileList!=null && multipartFileList.size()!=0){
+            String defectiveDirSuffix = "defective" + File.separator + defective.getSenderName() + File.separator+ record + File.separator
+                    +delName+File.separator+recordTime+File.separator;
+            String feedbackDir = rootFile + defectiveDirSuffix;
+            File fileDir = new File(feedbackDir);
+            if (!fileDir.exists()) {
+                fileDir.mkdirs();
+            }
+            for (int i = 0; i < multipartFileList.size(); i++) {
+                MultipartFile multipartFile = multipartFileList.get(i);
+                //瀛樺偍鏂囦欢
+                String originalFilename = multipartFile.getOriginalFilename();
+                String fileName = originalFilename.substring(0, originalFilename.lastIndexOf("."));
+                String suffix = originalFilename.substring(originalFilename.lastIndexOf("."));
+                String feedbackPath = feedbackDir + fileName + suffix;
+                File file = new File(feedbackPath);
+                try {
+                    multipartFile.transferTo(file);
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+            defectiveHis.setDelUrl(defectiveDirSuffix);
+        }
+        mapper.insert(defectiveHis);
+    }
+    //褰掓。涓嶈壇鍝�
+    public void stopDefective(DefectiveProductsHistory defectiveHis) {
+        defectiveHis.setRecordTime(new Date());
+        mapper.insert(defectiveHis);
+    }
 }
\ No newline at end of file

--
Gitblit v1.9.1