From 9f3a45da6d1dc9c71187f15131665eb9806f5588 Mon Sep 17 00:00:00 2001
From: maven <2163098428@qq.com>
Date: 星期二, 28 十月 2025 15:58:03 +0800
Subject: [PATCH] yys 1.修改配置文件 2.增加模板
---
 src/main/java/com/ruoyi/sales/service/impl/SalesQuotationServiceImpl.java |   96 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 96 insertions(+), 0 deletions(-)
diff --git a/src/main/java/com/ruoyi/sales/service/impl/SalesQuotationServiceImpl.java b/src/main/java/com/ruoyi/sales/service/impl/SalesQuotationServiceImpl.java
new file mode 100644
index 0000000..104a712
--- /dev/null
+++ b/src/main/java/com/ruoyi/sales/service/impl/SalesQuotationServiceImpl.java
@@ -0,0 +1,96 @@
+package com.ruoyi.sales.service.impl;
+
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+
+import com.ruoyi.common.utils.bean.BeanUtils;
+import com.ruoyi.sales.dto.SalesQuotationDto;
+import com.ruoyi.sales.mapper.SalesQuotationMapper;
+import com.ruoyi.sales.mapper.SalesQuotationProductMapper;
+import com.ruoyi.sales.pojo.SalesQuotation;
+import com.ruoyi.sales.pojo.SalesQuotationProduct;
+import com.ruoyi.sales.service.SalesQuotationProductService;
+import com.ruoyi.sales.service.SalesQuotationService;
+import org.springframework.beans.factory.annotation.Autowired;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+@Service
+@Transactional(rollbackFor = Exception.class)
+public class SalesQuotationServiceImpl extends ServiceImpl<SalesQuotationMapper, SalesQuotation> implements SalesQuotationService {
+    @Autowired
+    private SalesQuotationMapper salesQuotationMapper;
+    @Autowired
+    private SalesQuotationProductMapper salesQuotationProductMapper;
+    @Autowired
+    private SalesQuotationProductService salesQuotationProductService;
+    @Override
+    public IPage<SalesQuotationDto> listPage(Page page, SalesQuotationDto salesQuotationDto) {
+        IPage<SalesQuotationDto> salesQuotationDtoIPage = salesQuotationMapper.listPage(page, salesQuotationDto);
+        if(CollectionUtils.isEmpty(salesQuotationDtoIPage.getRecords())){
+            return salesQuotationDtoIPage;
+        }
+        salesQuotationDtoIPage.getRecords().forEach(record -> {
+            List<SalesQuotationProduct> products = salesQuotationProductMapper.selectBySalesQuotationId(record.getId());
+            record.setProducts(products);
+        });
+        return salesQuotationDtoIPage;
+    }
+
+    @Override
+    public boolean add(SalesQuotationDto salesQuotationDto) {
+        SalesQuotation salesQuotation = new SalesQuotation();
+        BeanUtils.copyProperties(salesQuotationDto, salesQuotation);
+        String quotationNo = salesQuotation.getQuotationNo();
+        salesQuotationMapper.insert(salesQuotation);
+//        if(salesQuotationMapper.insert(salesQuotation)!=1){
+//            return false;
+//        }
+        if(CollectionUtils.isEmpty(salesQuotationDto.getProducts())){
+            return true;
+        }
+        List<SalesQuotationProduct> products = salesQuotationDto.getProducts().stream().map(product -> {
+            SalesQuotationProduct salesQuotationProduct = new SalesQuotationProduct();
+            BeanUtils.copyProperties(product, salesQuotationProduct);
+            salesQuotationProduct.setSalesQuotationId(salesQuotationMapper.selectOne(new LambdaQueryWrapper<SalesQuotation>().eq(SalesQuotation::getQuotationNo, quotationNo)).getId());
+            return salesQuotationProduct;
+        }).collect(Collectors.toList());
+        salesQuotationProductService.saveBatch(products);
+        return true;
+    }
+    @Override
+    public boolean edit(SalesQuotationDto salesQuotationDto) {
+        SalesQuotation salesQuotation = new SalesQuotation();
+        BeanUtils.copyProperties(salesQuotationDto, salesQuotation);
+        if(salesQuotationMapper.updateById(salesQuotation)!=1){
+            return false;
+        }
+        salesQuotationProductMapper.delete(new LambdaQueryWrapper<SalesQuotationProduct>().eq(SalesQuotationProduct::getSalesQuotationId, salesQuotationDto.getId()));
+        if(CollectionUtils.isEmpty(salesQuotationDto.getProducts())){
+            return true;
+        }
+        List<SalesQuotationProduct> products = salesQuotationDto.getProducts().stream().map(product -> {
+            SalesQuotationProduct salesQuotationProduct = new SalesQuotationProduct();
+            BeanUtils.copyProperties(product, salesQuotationProduct);
+            salesQuotationProduct.setSalesQuotationId(salesQuotation.getId());
+            return salesQuotationProduct;
+        }).collect(Collectors.toList());
+        salesQuotationProductService.saveBatch(products);
+        return true;
+    }
+    @Override
+    public boolean delete(Long id) {
+        salesQuotationMapper.deleteById(id);
+        salesQuotationProductMapper.delete(new LambdaQueryWrapper<SalesQuotationProduct>().eq(SalesQuotationProduct::getSalesQuotationId, id));
+        return true;
+    }
+
+
+}
--
Gitblit v1.9.3