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/BOMFeedbakService.java |   55 +++++++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 43 insertions(+), 12 deletions(-)

diff --git a/src/main/java/com/whyc/service/BOMFeedbakService.java b/src/main/java/com/whyc/service/BOMFeedbakService.java
index 46caac1..b7767da 100644
--- a/src/main/java/com/whyc/service/BOMFeedbakService.java
+++ b/src/main/java/com/whyc/service/BOMFeedbakService.java
@@ -13,9 +13,11 @@
 import com.whyc.mapper.ProductHistoryMapper;
 import com.whyc.pojo.BOMFeedback;
 import com.whyc.pojo.DocUser;
+import com.whyc.pojo.Product;
 import com.whyc.pojo.ProductHistory;
 import com.whyc.util.ActionUtil;
 import com.whyc.util.CommonUtil;
+import com.whyc.util.DateUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -46,6 +48,10 @@
 
     @Resource
     private ProductHistoryMapper phisMapper;
+
+    @Autowired
+    private ProductService productService;
+
     //缁熻
     public Map<String, Integer> getFkStatistic(DocUser user,Map<String, Integer> map) {
         int sendFk=0;
@@ -89,8 +95,8 @@
         if(list!=null&&list.size()>0){
             for (int i=0;i<list.size();i++) {
                 BOMFeedback feedback=list.get(i);
-                fileDirName=fileDirName+File.separator+feedback.getFile();
-                File start = new File(fileDirName);
+                String attachFilePath=fileDirName+File.separator+feedback.getFile();
+                File start = new File(attachFilePath);
                 String[] files =new String[]{};
                 List attachList=new ArrayList();
                 if(start.exists()) {
@@ -124,8 +130,8 @@
         if(list!=null&&list.size()>0){
             for (int i=0;i<list.size();i++) {
                 BOMFeedback feedback=list.get(i);
-                fileDirName=fileDirName+File.separator+feedback.getFile();
-                File start = new File(fileDirName);
+                String attachFilePath=fileDirName+File.separator+feedback.getFile();
+                File start = new File(attachFilePath);
                 String[] files =new String[]{};
                 List attachList=new ArrayList();
                 if(start.exists()) {
@@ -149,6 +155,7 @@
      * @param feedback
      * @return
      */
+    @Transactional
     public Response confirmFeedback(BOMFeedback feedback) {
         DocUser user = ActionUtil.getUser();
         int userId = user.getId().intValue();
@@ -219,6 +226,25 @@
             int count=mapper.update(null,wrapper);
             bl=count>0;
             msg="鎺ユ敹鑰呯‘璁ゅ弽棣�";
+
+            if(confirmStatus == 2){
+                //瑙i攣浜у搧
+                Integer productId = mapper.selectById(id).getProductId();
+                Product product = productService.getById(productId);
+                //瑙i攣浜у搧鏃惰В閿侀攣瀹氭椂鐨勭増鏈彿
+                QueryWrapper<BOMFeedback> query = Wrappers.query();
+                query.eq("id",id).last(" limit 1");
+                BOMFeedback feed = mapper.selectOne(query);
+                int nowVersion=feed.getNowVersion();
+                if(product!=null){
+                    if(nowVersion!=-1){
+                        phisService.setpHistoryEnable(product.getParentCode(),product.getCustomCode(),nowVersion,1,"闂鍙嶉鍚�"+ username +"纭涓嶉渶瑕佷慨鏀筨om,绯荤粺鎵ц浜у搧瑙i攣",DateUtil.YYYY_MM_DD_HH_MM_SS.format(product.getVersionTime()));
+                    }
+                }else{
+                    ProductHistory phis = phisService.getById(productId);
+                    phisService.setpHistoryEnable(phis.getParentCode(),phis.getCustomCode(),phis.getVersion(),1,"闂鍙嶉鍚�"+ username +"纭涓嶉渶瑕佷慨鏀筨om,绯荤粺鎵ц浜у搧瑙i攣",DateUtil.YYYY_MM_DD_HH_MM_SS.format(phis.getVersionTime()));
+                }
+            }
         }
         return new Response().set(1,bl,msg);
     }
@@ -267,9 +293,16 @@
         //for (File file : fileList) {
         //    file.delete();
         //}
+
+        //鏌ヨ浜у搧鐨勪俊鎭�
+        QueryWrapper hisWrapper=new QueryWrapper();
+        hisWrapper.eq("id",feedback.getProductId());
+        hisWrapper.last("limit 1");
+        ProductHistory phis=phisMapper.selectOne(hisWrapper);
         //淇濆瓨
         feedback.setCreateTime(date);
         feedback.setConfirmStatus(0);
+        feedback.setNowVersion(phis.getVersion());
         mapper.insert(feedback);
         //鍙戦�侀偖浠�
         String receiverIds = feedback.getReceiverIds();
@@ -300,7 +333,10 @@
         }
 
         String subject = "銆怋om闂鍙嶉銆�-"+senderName;
-        String content = feedback.getContent();
+        //閭欢鍐呭,娣诲姞浜у搧鐨勭浉鍏充俊鎭�
+        Product product = productService.getById(feedback.getProductId());
+
+        String content ="浜у搧鏂欏彿:"+product.getParentCode() + "\n浜у搧鍚嶇О:"+product.getParentName() + "\n浜у搧鍨嬪彿:"+product.getParentModel() + "\n鐗堟湰鏃堕棿:"+ DateUtil.YYYY_MM_DD_HH_MM_SS.format(product.getVersionTime()) + "\n瀹氬埗鍗曞彿:"+product.getCustomCode() + "\n浜у搧鍙嶉鍐呭:"+ feedback.getContent();
 
         MailDTO mailDTO = new MailDTO();
         mailDTO.setTitle(subject);
@@ -309,11 +345,6 @@
         mailService.sendMail(mailDTO);
         //mailUtil.sendMailBatch(senderName,receiverMailList,subject,content);
         //鍙嶉鏃剁洿鎺ユ牴鎹畃roductid鐩存帴閿佸畾
-        //鏌ヨ浜у搧鐨勪俊鎭�
-        QueryWrapper hisWrapper=new QueryWrapper();
-        hisWrapper.eq("id",feedback.getProductId());
-        hisWrapper.last("limit 1");
-        ProductHistory phis=phisMapper.selectOne(hisWrapper);
         phisService.setpHistoryEnable(phis.getParentCode(),phis.getCustomCode(),phis.getVersion(),0,feedback.getContent(),ActionUtil.sdfwithALL.format(phis.getVersionTime()));
         return new Response().set(1,true,"鍙嶉瀹屾垚");
     }
@@ -399,8 +430,8 @@
         if(list!=null&&list.size()>0){
             for (int i=0;i<list.size();i++) {
                 BOMFeedback fb=list.get(i);
-                fileDirName=fileDirName+File.separator+fb.getFile();
-                File start = new File(fileDirName);
+                String attachFilePath=fileDirName+File.separator+fb.getFile();
+                File start = new File(attachFilePath);
                 String[] files =new String[]{};
                 List attachList=new ArrayList();
                 if(start.exists()) {

--
Gitblit v1.9.1