From 47a54a14c9b01d8dcf2b8a385007730a1989593b Mon Sep 17 00:00:00 2001
From: wujianwei <wjw@11.com>
Date: 星期一, 12 一月 2026 15:54:56 +0800
Subject: [PATCH] 修改发票新增

---
 tms/src/main/java/com/ruoyi/tms/service/impl/TmsQuotePlanServiceImpl.java |   56 +++++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 53 insertions(+), 3 deletions(-)

diff --git a/tms/src/main/java/com/ruoyi/tms/service/impl/TmsQuotePlanServiceImpl.java b/tms/src/main/java/com/ruoyi/tms/service/impl/TmsQuotePlanServiceImpl.java
index 0427c84..d6e256b 100644
--- a/tms/src/main/java/com/ruoyi/tms/service/impl/TmsQuotePlanServiceImpl.java
+++ b/tms/src/main/java/com/ruoyi/tms/service/impl/TmsQuotePlanServiceImpl.java
@@ -1,6 +1,7 @@
 package com.ruoyi.tms.service.impl;
 
 import java.util.List;
+import java.util.stream.Collectors;
 
 import com.ruoyi.common.enums.SystemDataNoEnum;
 import com.ruoyi.common.utils.DateUtils;
@@ -8,6 +9,8 @@
 
 import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.system.service.ISystemDataNoService;
+import com.ruoyi.tms.domain.TmsQuoteItem;
+import com.ruoyi.tms.service.ITmsQuoteItemService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.stereotype.Service;
@@ -38,6 +41,8 @@
     protected final Logger logger = LoggerFactory.getLogger(getClass());
     @Resource
     private TmsQuotePlanMapper tmsQuotePlanMapper;
+    @Autowired
+    private ITmsQuoteItemService tmsQuoteItemService;
 
     @Autowired
     ISystemDataNoService systemDataNoService;
@@ -51,7 +56,9 @@
     @Override
     public TmsQuotePlan selectTmsQuotePlanById(Integer id)
     {
-        return tmsQuotePlanMapper.selectTmsQuotePlanById(id);
+        TmsQuotePlan tmsQuotePlan = tmsQuotePlanMapper.selectTmsQuotePlanById(id);
+        tmsQuotePlan.setQuoteItems(tmsQuoteItemService.selectTmsQuoteItemList(new TmsQuoteItem(){{setQuotePlanId(id);}}));
+        return tmsQuotePlan;
     }
 
     /**
@@ -113,7 +120,16 @@
         tmsQuotePlan.setSystemCode(noByKey);
         tmsQuotePlan.setCreateBy(SecurityUtils.getUsername());
         tmsQuotePlan.setCreateTime(DateUtils.getNowDate());
-        return tmsQuotePlanMapper.insertTmsQuotePlan(tmsQuotePlan);
+        tmsQuotePlanMapper.insertTmsQuotePlan(tmsQuotePlan);
+
+        List<TmsQuoteItem> quoteItems = tmsQuotePlan.getQuoteItems();
+        if (quoteItems != null && !quoteItems.isEmpty()){
+            quoteItems.forEach(tmsQuoteItem -> {
+                tmsQuoteItem.setQuotePlanId(tmsQuotePlan.getId());
+            });
+            tmsQuoteItemService.insertTmsQuoteItemBatch(quoteItems);
+        }
+        return 1;
     }
 
     /**
@@ -140,7 +156,41 @@
     {
         tmsQuotePlan.setUpdateBy(SecurityUtils.getUsername());
         tmsQuotePlan.setUpdateTime(DateUtils.getNowDate());
-        return tmsQuotePlanMapper.updateTmsQuotePlan(tmsQuotePlan);
+        int i = tmsQuotePlanMapper.updateTmsQuotePlan(tmsQuotePlan);
+
+
+
+            List<TmsQuoteItem> quoteItems = tmsQuotePlan.getQuoteItems();
+            if (quoteItems != null && !quoteItems.isEmpty()){
+                List<TmsQuoteItem> tmsQuoteItems = tmsQuoteItemService.selectTmsQuoteItemList(new TmsQuoteItem() {{
+                    setQuotePlanId(tmsQuotePlan.getId());
+                }});
+
+                // 1銆佸垹闄ゆ湰娆℃彁浜ゆ病鏈夌殑鏁版嵁
+                List<Integer> collect = quoteItems.stream().map(TmsQuoteItem::getId).collect(Collectors.toList());
+                tmsQuoteItems.removeIf(tmsQuoteItem -> collect.contains(tmsQuoteItem.getId()));
+                List<Integer> collect1 = tmsQuoteItems.stream().map(TmsQuoteItem::getId).collect(Collectors.toList());
+                if (!collect1.isEmpty()){
+                    tmsQuoteItemService.getBaseMapper().deleteBatchIds(collect1);
+                }
+
+                // 2銆佹洿鏂版湰娆℃彁浜ゆ湁鐨勬暟鎹�
+                List<TmsQuoteItem> collect2 = quoteItems.stream().filter(tmsQuoteItem -> tmsQuoteItem.getId() != null).collect(Collectors.toList());
+                if (!collect2.isEmpty()){
+                    tmsQuoteItemService.updateTmsQuoteItemBatch(collect2);
+                }
+                // 3銆佹柊澧炴湰娆℃彁浜ゆ病鏈夌殑鏁版嵁
+                List<TmsQuoteItem> collect3 = quoteItems.stream().
+                        filter(tmsQuoteItem -> tmsQuoteItem.getId() == null).collect(Collectors.toList());
+
+                if (!collect3.isEmpty()){
+                    collect3.forEach(tmsQuoteItem -> tmsQuoteItem.setQuotePlanId(tmsQuotePlan.getId()));
+                    tmsQuoteItemService.insertTmsQuoteItemBatch(collect3);
+                }
+
+
+            }
+        return i;
     }
 
     /**

--
Gitblit v1.8.0