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/TmsQuoteDetailServiceImpl.java | 43 +++++++++++++++++++++++++++++++++++++++----
1 files changed, 39 insertions(+), 4 deletions(-)
diff --git a/tms/src/main/java/com/ruoyi/tms/service/impl/TmsQuoteDetailServiceImpl.java b/tms/src/main/java/com/ruoyi/tms/service/impl/TmsQuoteDetailServiceImpl.java
index 580ef51..aa27ac6 100644
--- a/tms/src/main/java/com/ruoyi/tms/service/impl/TmsQuoteDetailServiceImpl.java
+++ b/tms/src/main/java/com/ruoyi/tms/service/impl/TmsQuoteDetailServiceImpl.java
@@ -2,6 +2,7 @@
import java.util.List;
+import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ruoyi.common.enums.SystemDataNoEnum;
import com.ruoyi.common.utils.DateUtils;
@@ -10,6 +11,7 @@
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.system.service.ISystemDataNoService;
import com.ruoyi.tms.domain.TmsQuotePlan;
+import com.ruoyi.tms.domain.vo.QuoteDetailItem;
import com.ruoyi.tms.mapper.TmsQuotePlanMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
@@ -111,16 +113,46 @@
* @return 缁撴灉
*/
@Override
- public int insertTmsQuoteDetail(TmsQuoteDetail tmsQuoteDetail)
- {
+ public int insertTmsQuoteDetail(TmsQuoteDetail tmsQuoteDetail) {
+
Integer quotePlanId = tmsQuoteDetail.getQuotePlanId();
- if (quotePlanId == null){
+ if (quotePlanId == null) {
throw new RuntimeException("璇峰厛閫夋嫨鎶ヤ环鏂规涓嶈兘涓虹┖");
}
+
TmsQuotePlan tmsQuotePlan = tmsQuotePlanMapper.selectTmsQuotePlanById(quotePlanId);
- if (tmsQuotePlan == null){
+ if (tmsQuotePlan == null) {
throw new RuntimeException("鎶ヤ环鏂规涓嶅瓨鍦�");
}
+
+ // 杞﹀瀷鎶ヤ环绫诲瀷
+ if (tmsQuotePlan.getPlanType() == 0) {
+ List<QuoteDetailItem> quoteItems = tmsQuoteDetail.getQuoteItems();
+ if (quoteItems == null || quoteItems.isEmpty()) {
+ throw new RuntimeException("璇峰~鍐欒溅鍨嬫姤浠�");
+ }
+
+ int count = 0;
+ for (QuoteDetailItem item : quoteItems) {
+
+ // 鎷疯礉涓诲璞″浐瀹氬睘鎬�
+ TmsQuoteDetail newDetail = BeanUtil.copyProperties(tmsQuoteDetail, TmsQuoteDetail.class);
+
+ // 鎷疯礉 item 灞炴��
+ BeanUtil.copyProperties(item ,newDetail);
+
+ // 鎻掑叆
+ addDetail(quotePlanId, tmsQuotePlan, newDetail);
+ count++;
+ }
+ return count;
+ }
+
+ // 鏅�氱被鍨�
+ return addDetail(quotePlanId, tmsQuotePlan, tmsQuoteDetail);
+ }
+
+ public int addDetail(Integer quotePlanId, TmsQuotePlan tmsQuotePlan, TmsQuoteDetail tmsQuoteDetail){
// 1銆佸悓涓�鎶ヤ环娓呭崟锛屼笉鑳芥坊鍔犵浉鍚屻�愯矾绾�-杞﹀瀷銆戞暟鎹�
Long l = tmsQuoteDetailMapper.selectCount(new LambdaQueryWrapper<TmsQuoteDetail>()
.eq(TmsQuoteDetail::getQuotePlanId, quotePlanId)
@@ -155,8 +187,11 @@
tmsQuoteDetail.setPlanType(tmsQuotePlan.getPlanType());
tmsQuoteDetail.setCustomerId(tmsQuotePlan.getCustomerId());
return tmsQuoteDetailMapper.insertTmsQuoteDetail(tmsQuoteDetail);
+
}
+
+
/**
* 鏂板鎶ヤ环鏄庣粏[鎵归噺]
*
--
Gitblit v1.8.0