From 3849263b31a16a91ff08acaa42786ecfde76f33c Mon Sep 17 00:00:00 2001
From: zhangback <zhangback@163.com>
Date: 星期四, 27 十一月 2025 20:18:08 +0800
Subject: [PATCH] 提交
---
tms/src/main/java/com/ruoyi/tms/service/impl/TmsQuotePlanServiceImpl.java | 65 +++++++++++++++++++++++++++++++-
1 files changed, 62 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..6074947 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,22 @@
tmsQuotePlan.setSystemCode(noByKey);
tmsQuotePlan.setCreateBy(SecurityUtils.getUsername());
tmsQuotePlan.setCreateTime(DateUtils.getNowDate());
- return tmsQuotePlanMapper.insertTmsQuotePlan(tmsQuotePlan);
+ tmsQuotePlanMapper.insertTmsQuotePlan(tmsQuotePlan);
+ if (tmsQuotePlan.getPlanType() == 0){
+
+ List<TmsQuoteItem> quoteItems = tmsQuotePlan.getQuoteItems();
+ if (quoteItems != null && !quoteItems.isEmpty()){
+ quoteItems.forEach(tmsQuoteItem -> {
+ tmsQuoteItem.setQuotePlanId(tmsQuotePlan.getId());
+ });
+ tmsQuoteItemService.insertTmsQuoteItemBatch(quoteItems);
+ }else{
+ throw new RuntimeException("璇疯嚦灏戦�夋嫨涓�涓姤浠锋柟妗�");
+ }
+
+ }
+
+ return 1;
}
/**
@@ -140,7 +162,44 @@
{
tmsQuotePlan.setUpdateBy(SecurityUtils.getUsername());
tmsQuotePlan.setUpdateTime(DateUtils.getNowDate());
- return tmsQuotePlanMapper.updateTmsQuotePlan(tmsQuotePlan);
+ int i = tmsQuotePlanMapper.updateTmsQuotePlan(tmsQuotePlan);
+
+
+ if (tmsQuotePlan.getPlanType() == 0){
+ 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);
+ }
+
+
+ }else{
+ throw new RuntimeException("璇疯嚦灏戦�夋嫨涓�涓姤浠锋柟妗�");
+ }
+ }
+ return i;
}
/**
--
Gitblit v1.8.0