From e9f2adb9ddc511c62e1628fbd527ba7cda8294d4 Mon Sep 17 00:00:00 2001
From: chenrui <1187576398@qq.com>
Date: 星期五, 09 五月 2025 14:29:29 +0800
Subject: [PATCH] Merge branch 'master' of http://114.132.189.42:9002/r/product-inventory-management-after
---
src/main/java/com/ruoyi/sales/dto/SalesLedgerDto.java | 22 ++
src/main/java/com/ruoyi/basic/pojo/Customer.java | 3
src/main/java/com/ruoyi/sales/pojo/SalesLedgerProduct.java | 87 ++++++++++
src/main/java/com/ruoyi/basic/service/ICustomerService.java | 7
src/main/java/com/ruoyi/sales/pojo/SalesLedger.java | 12 +
src/main/java/com/ruoyi/sales/service/ISalesLedgerService.java | 5
src/main/java/com/ruoyi/sales/dto/SalesLedgerProductDTO.java | 4
src/main/java/com/ruoyi/basic/service/impl/CustomerServiceImpl.java | 20 ++
src/main/java/com/ruoyi/sales/service/impl/SalesLedgerProductServiceImpl.java | 50 ++++++
src/main/java/com/ruoyi/sales/controller/SalesLedgerController.java | 37 ++--
src/main/java/com/ruoyi/sales/service/ISalesLedgerProductService.java | 23 ++
src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java | 60 ++++++-
src/main/java/com/ruoyi/basic/controller/CustomerController.java | 16 +
src/main/java/com/ruoyi/sales/controller/SalesLedgerProductController.java | 91 +++++++++++
src/main/java/com/ruoyi/sales/mapper/SalesLedgerProductMapper.java | 13 +
15 files changed, 415 insertions(+), 35 deletions(-)
diff --git a/src/main/java/com/ruoyi/basic/controller/CustomerController.java b/src/main/java/com/ruoyi/basic/controller/CustomerController.java
index 33e229c..cc94893 100644
--- a/src/main/java/com/ruoyi/basic/controller/CustomerController.java
+++ b/src/main/java/com/ruoyi/basic/controller/CustomerController.java
@@ -8,7 +8,6 @@
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
@@ -91,8 +90,19 @@
* 鍒犻櫎瀹㈡埛妗f
*/
@Log(title = "瀹㈡埛妗f", businessType = BusinessType.DELETE)
- @DeleteMapping("/{ids}")
- public AjaxResult remove(@PathVariable Long[] ids) {
+ @DeleteMapping("/delCustomer")
+ public AjaxResult remove(@RequestBody Long[] ids) {
+ if (ids == null || ids.length == 0) {
+ return AjaxResult.error("璇蜂紶鍏ヨ鍒犻櫎鐨処D");
+ }
return toAjax(customerService.deleteCustomerByIds(ids));
}
+
+ /**
+ * 鏌ヨ瀹㈡埛
+ */
+ @GetMapping("/customerList")
+ public List customerList(Customer customer) {
+ return customerService.customerList(customer);
+ }
}
diff --git a/src/main/java/com/ruoyi/basic/pojo/Customer.java b/src/main/java/com/ruoyi/basic/pojo/Customer.java
index ebfd63f..47901ec 100644
--- a/src/main/java/com/ruoyi/basic/pojo/Customer.java
+++ b/src/main/java/com/ruoyi/basic/pojo/Customer.java
@@ -79,4 +79,7 @@
@TableField(exist = false)
private Long[] ids;
+
+ @TableField(exist = false)
+ private String addressPhone;
}
diff --git a/src/main/java/com/ruoyi/basic/service/ICustomerService.java b/src/main/java/com/ruoyi/basic/service/ICustomerService.java
index b1c7ec5..790c975 100644
--- a/src/main/java/com/ruoyi/basic/service/ICustomerService.java
+++ b/src/main/java/com/ruoyi/basic/service/ICustomerService.java
@@ -53,4 +53,11 @@
int deleteCustomerByIds(Long[] ids);
List<Customer> selectCustomerListByIds(Long[] ids);
+
+ /**
+ * 鏌ヨ瀹㈡埛淇℃伅
+ *
+ * @return 缁撴灉
+ */
+ List customerList(Customer customer);
}
diff --git a/src/main/java/com/ruoyi/basic/service/impl/CustomerServiceImpl.java b/src/main/java/com/ruoyi/basic/service/impl/CustomerServiceImpl.java
index f522929..3dd42a9 100644
--- a/src/main/java/com/ruoyi/basic/service/impl/CustomerServiceImpl.java
+++ b/src/main/java/com/ruoyi/basic/service/impl/CustomerServiceImpl.java
@@ -2,12 +2,14 @@
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.basic.mapper.CustomerMapper;
import com.ruoyi.basic.pojo.Customer;
import com.ruoyi.basic.service.ICustomerService;
import com.ruoyi.common.utils.SecurityUtils;
+import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.framework.security.LoginUser;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@@ -15,6 +17,7 @@
import java.util.Arrays;
import java.util.List;
+import java.util.stream.Collectors;
/**
@@ -49,11 +52,17 @@
@Override
public List<Customer> selectCustomerList(Customer customer) {
LambdaQueryWrapper<Customer> queryWrapper = new LambdaQueryWrapper<>();
- if (customer.getCustomerName() != null && !customer.getCustomerName().isEmpty()) {
+
+ if (StringUtils.isNotBlank(customer.getCustomerName())) {
queryWrapper.eq(Customer::getCustomerName, customer.getCustomerName());
}
+
List<Customer> customerList = customerMapper.selectList(queryWrapper);
- return customerList;
+
+ // 浣跨敤 Stream 淇敼姣忎釜 Customer 鐨� addressPhone 瀛楁
+ return customerList.stream().peek(c ->
+ c.setAddressPhone(c.getCompanyAddress() + "( " + c.getCompanyPhone() + " )")
+ ).collect(Collectors.toList());
}
/**
@@ -102,4 +111,11 @@
queryWrapper.in(Customer::getId, Arrays.asList(ids));
return customerMapper.selectList(queryWrapper);
}
+
+ @Override
+ public List customerList(Customer customer) {
+ LambdaQueryWrapper<Customer> queryWrapper = Wrappers.lambdaQuery();
+ queryWrapper.select(Customer::getId, Customer::getCustomerName);
+ return customerMapper.selectMaps(queryWrapper);
+ }
}
diff --git a/src/main/java/com/ruoyi/sales/controller/SalesLedgerController.java b/src/main/java/com/ruoyi/sales/controller/SalesLedgerController.java
index 1f871d6..3c93788 100644
--- a/src/main/java/com/ruoyi/sales/controller/SalesLedgerController.java
+++ b/src/main/java/com/ruoyi/sales/controller/SalesLedgerController.java
@@ -4,13 +4,12 @@
import javax.servlet.http.HttpServletResponse;
import com.ruoyi.common.utils.poi.ExcelUtil;
+import com.ruoyi.sales.dto.SalesLedgerDto;
import com.ruoyi.sales.pojo.SalesLedger;
import com.ruoyi.sales.service.ISalesLedgerService;
-import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
@@ -47,6 +46,17 @@
}
/**
+ * 鏌ヨ閿�鍞彴璐﹀拰浜у搧鐖跺瓙鍒楄〃
+ */
+ @GetMapping("/getSalesLedgerWithProducts")
+ public TableDataInfo getSalesLedgerWithProducts()
+ {
+ startPage();
+ List<SalesLedgerDto> list = salesLedgerService.getSalesLedgerWithProducts();
+ return getDataTable(list);
+ }
+
+ /**
* 瀵煎嚭閿�鍞彴璐﹀垪琛�
*/
@Log(title = "閿�鍞彴璐�", businessType = BusinessType.EXPORT)
@@ -68,32 +78,25 @@
}
/**
- * 鏂板閿�鍞彴璐�
+ * 鏂板淇敼閿�鍞彴璐�
*/
@Log(title = "閿�鍞彴璐�", businessType = BusinessType.INSERT)
- @PostMapping ("/insertSalesLedger")
+ @PostMapping ("/addOrUpdateSalesLedger")
public AjaxResult add(@RequestBody SalesLedger salesLedger)
{
- return toAjax(salesLedgerService.insertSalesLedger(salesLedger));
- }
-
- /**
- * 淇敼閿�鍞彴璐�
- */
- @Log(title = "閿�鍞彴璐�", businessType = BusinessType.UPDATE)
- @PostMapping ("/updateSalesLedger")
- public AjaxResult edit(@RequestBody SalesLedger salesLedger)
- {
- return toAjax(salesLedgerService.updateSalesLedger(salesLedger));
+ return toAjax(salesLedgerService.addOrUpdateSalesLedger(salesLedger));
}
/**
* 鍒犻櫎閿�鍞彴璐�
*/
@Log(title = "閿�鍞彴璐�", businessType = BusinessType.DELETE)
- @DeleteMapping("/{ids}")
- public AjaxResult remove(@PathVariable Long[] ids)
+ @DeleteMapping("/delLedger")
+ public AjaxResult remove(@RequestBody Long[] ids)
{
+ if (ids == null || ids.length == 0) {
+ return AjaxResult.error("璇蜂紶鍏ヨ鍒犻櫎鐨処D");
+ }
return toAjax(salesLedgerService.deleteSalesLedgerByIds(ids));
}
}
diff --git a/src/main/java/com/ruoyi/sales/controller/SalesLedgerProductController.java b/src/main/java/com/ruoyi/sales/controller/SalesLedgerProductController.java
new file mode 100644
index 0000000..a42f2b4
--- /dev/null
+++ b/src/main/java/com/ruoyi/sales/controller/SalesLedgerProductController.java
@@ -0,0 +1,91 @@
+package com.ruoyi.sales.controller;
+
+import javax.servlet.http.HttpServletResponse;
+
+import com.ruoyi.common.utils.poi.ExcelUtil;
+import com.ruoyi.sales.pojo.SalesLedgerProduct;
+import com.ruoyi.sales.service.ISalesLedgerProductService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import com.ruoyi.framework.aspectj.lang.annotation.Log;
+import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
+import com.ruoyi.framework.web.controller.BaseController;
+import com.ruoyi.framework.web.domain.AjaxResult;
+import com.ruoyi.framework.web.page.TableDataInfo;
+
+import java.util.List;
+
+/**
+ * 浜у搧淇℃伅Controller
+ *
+ * @author ruoyi
+ * @date 2025-05-08
+ */
+@RestController
+@RequestMapping("/sales/product")
+public class SalesLedgerProductController extends BaseController
+{
+ @Autowired
+ private ISalesLedgerProductService salesLedgerProductService;
+
+ /**
+ * 鏌ヨ浜у搧淇℃伅鍒楄〃
+ */
+ @GetMapping("/list")
+ public TableDataInfo list(SalesLedgerProduct salesLedgerProduct)
+ {
+ startPage();
+ List<SalesLedgerProduct> list = salesLedgerProductService.selectSalesLedgerProductList(salesLedgerProduct);
+ return getDataTable(list);
+ }
+
+ /**
+ * 瀵煎嚭浜у搧淇℃伅鍒楄〃
+ */
+ @Log(title = "浜у搧淇℃伅", businessType = BusinessType.EXPORT)
+ @PostMapping("/export")
+ public void export(HttpServletResponse response, SalesLedgerProduct salesLedgerProduct)
+ {
+ List<SalesLedgerProduct> list = salesLedgerProductService.selectSalesLedgerProductList(salesLedgerProduct);
+ ExcelUtil<SalesLedgerProduct> util = new ExcelUtil<SalesLedgerProduct>(SalesLedgerProduct.class);
+ util.exportExcel(response, list, "浜у搧淇℃伅鏁版嵁");
+ }
+
+ /**
+ * 鑾峰彇浜у搧淇℃伅璇︾粏淇℃伅
+ */
+ @GetMapping(value = "/{id}")
+ public AjaxResult getInfo(@PathVariable("id") Long id)
+ {
+ return success(salesLedgerProductService.selectSalesLedgerProductById(id));
+ }
+
+ /**
+ * 鏂板淇敼浜у搧淇℃伅
+ */
+ @Log(title = "浜у搧淇℃伅", businessType = BusinessType.INSERT)
+ @PostMapping ("/addOrUpdateSalesLedgerProduct")
+ public AjaxResult add(@RequestBody SalesLedgerProduct salesLedgerProduct)
+ {
+ return toAjax(salesLedgerProductService.addOrUpdateSalesLedgerProduct(salesLedgerProduct));
+ }
+
+ /**
+ * 鍒犻櫎浜у搧淇℃伅
+ */
+ @Log(title = "浜у搧淇℃伅", businessType = BusinessType.DELETE)
+ @DeleteMapping("/delProduct")
+ public AjaxResult remove(@RequestBody Long[] ids)
+ {
+ if (ids == null || ids.length == 0) {
+ return AjaxResult.error("璇蜂紶鍏ヨ鍒犻櫎鐨処D");
+ }
+ return toAjax(salesLedgerProductService.deleteSalesLedgerProductByIds(ids));
+ }
+}
diff --git a/src/main/java/com/ruoyi/sales/dto/SalesLedgerDto.java b/src/main/java/com/ruoyi/sales/dto/SalesLedgerDto.java
index 49fda54..cc2bcf4 100644
--- a/src/main/java/com/ruoyi/sales/dto/SalesLedgerDto.java
+++ b/src/main/java/com/ruoyi/sales/dto/SalesLedgerDto.java
@@ -1,4 +1,26 @@
package com.ruoyi.sales.dto;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.ruoyi.sales.pojo.SalesLedgerProduct;
+import lombok.Data;
+
+import java.util.Date;
+import java.util.List;
+
+@Data
public class SalesLedgerDto {
+ private Long id;
+ private String salesContractNo;
+ private String customerContractNo;
+ private String projectName;
+ @JsonFormat(pattern = "yyyy-MM-dd")
+ private Date entryDate;
+ private String salesman;
+ private Long customerId;
+ private String customerName;
+ private String entryPerson;
+ private String remarks;
+ private String attachmentMaterials;
+ private Boolean hasChildren = false;
+ private List<SalesLedgerProduct> children;
}
diff --git a/src/main/java/com/ruoyi/sales/dto/SalesLedgerProductDTO.java b/src/main/java/com/ruoyi/sales/dto/SalesLedgerProductDTO.java
new file mode 100644
index 0000000..bf920e9
--- /dev/null
+++ b/src/main/java/com/ruoyi/sales/dto/SalesLedgerProductDTO.java
@@ -0,0 +1,4 @@
+package com.ruoyi.sales.dto;
+
+public class SalesLedgerProductDTO {
+}
diff --git a/src/main/java/com/ruoyi/sales/mapper/SalesLedgerProductMapper.java b/src/main/java/com/ruoyi/sales/mapper/SalesLedgerProductMapper.java
new file mode 100644
index 0000000..145bf38
--- /dev/null
+++ b/src/main/java/com/ruoyi/sales/mapper/SalesLedgerProductMapper.java
@@ -0,0 +1,13 @@
+package com.ruoyi.sales.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.ruoyi.sales.pojo.SalesLedgerProduct;
+
+/**
+ * 浜у搧淇℃伅Mapper鎺ュ彛
+ *
+ * @author ruoyi
+ * @date 2025-05-08
+ */
+public interface SalesLedgerProductMapper extends BaseMapper<SalesLedgerProduct> {
+}
diff --git a/src/main/java/com/ruoyi/sales/pojo/SalesLedger.java b/src/main/java/com/ruoyi/sales/pojo/SalesLedger.java
index 5f35293..bb4f237 100644
--- a/src/main/java/com/ruoyi/sales/pojo/SalesLedger.java
+++ b/src/main/java/com/ruoyi/sales/pojo/SalesLedger.java
@@ -2,10 +2,8 @@
import java.util.Date;
+import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
-import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.annotation.TableId;
-import com.baomidou.mybatisplus.annotation.TableName;
import com.ruoyi.framework.aspectj.lang.annotation.Excel;
import lombok.Data;
@@ -60,6 +58,11 @@
/**
* 瀹㈡埛鍚嶇О
*/
+ private Long customerId;
+
+ /**
+ * 瀹㈡埛鍚嶇О
+ */
@Excel(name = "瀹㈡埛鍚嶇О")
private String customerName;
@@ -81,5 +84,8 @@
@Excel(name = "闄勪欢鏉愭枡锛屽瓨鍌ㄦ枃浠跺悕绛夌浉鍏充俊鎭�")
private String attachmentMaterials;
+ @TableField(fill = FieldFill.INSERT)
+ private Long tenantId;
+
}
diff --git a/src/main/java/com/ruoyi/sales/pojo/SalesLedgerProduct.java b/src/main/java/com/ruoyi/sales/pojo/SalesLedgerProduct.java
new file mode 100644
index 0000000..79c397e
--- /dev/null
+++ b/src/main/java/com/ruoyi/sales/pojo/SalesLedgerProduct.java
@@ -0,0 +1,87 @@
+package com.ruoyi.sales.pojo;
+
+import java.math.BigDecimal;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.ruoyi.framework.aspectj.lang.annotation.Excel;
+import lombok.Data;
+
+/**
+ * 浜у搧淇℃伅瀵硅薄 sales_ledger_product
+ *
+ * @author ruoyi
+ * @date 2025-05-08
+ */
+@TableName("sales_ledger_product")
+@Data
+public class SalesLedgerProduct {
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * 浜у搧淇℃伅涓婚敭
+ */
+ @TableId(value = "id", type = IdType.AUTO)
+ private Long id;
+
+ /**
+ * 鍏宠仈閿�鍞彴璐︿富琛ㄤ富閿�
+ */
+ @Excel(name = "鍏宠仈閿�鍞彴璐︿富琛ㄤ富閿�")
+ private Long salesLedgerId;
+
+ /**
+ * 浜у搧澶х被
+ */
+ @Excel(name = "浜у搧澶х被")
+ private String productCategory;
+
+ /**
+ * 瑙勬牸鍨嬪彿
+ */
+ @Excel(name = "瑙勬牸鍨嬪彿")
+ private String specificationModel;
+
+ /**
+ * 鍗曚綅
+ */
+ @Excel(name = "鍗曚綅")
+ private String unit;
+
+ /**
+ * 鏁伴噺
+ */
+ @Excel(name = "鏁伴噺")
+ private BigDecimal quantity;
+
+ /**
+ * 绋庣巼
+ */
+ @Excel(name = "绋庣巼")
+ private BigDecimal taxRate;
+
+ /**
+ * 鍚◣鍗曚环
+ */
+ @Excel(name = "鍚◣鍗曚环")
+ private BigDecimal taxInclusiveUnitPrice;
+
+ /**
+ * 鍚◣鎬讳环
+ */
+ @Excel(name = "鍚◣鎬讳环")
+ private BigDecimal taxInclusiveTotalPrice;
+
+ /**
+ * 涓嶅惈绋庢�讳环
+ */
+ @Excel(name = "涓嶅惈绋庢�讳环")
+ private BigDecimal taxExclusiveTotalPrice;
+
+ /**
+ * 鍙戠エ绫诲瀷
+ */
+ @Excel(name = "鍙戠エ绫诲瀷")
+ private String invoiceType;
+}
diff --git a/src/main/java/com/ruoyi/sales/service/ISalesLedgerProductService.java b/src/main/java/com/ruoyi/sales/service/ISalesLedgerProductService.java
new file mode 100644
index 0000000..ccc28a7
--- /dev/null
+++ b/src/main/java/com/ruoyi/sales/service/ISalesLedgerProductService.java
@@ -0,0 +1,23 @@
+package com.ruoyi.sales.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.ruoyi.sales.pojo.SalesLedgerProduct;
+
+import java.util.List;
+
+/**
+ * 浜у搧淇℃伅Service鎺ュ彛
+ *
+ * @author ruoyi
+ * @date 2025-05-08
+ */
+public interface ISalesLedgerProductService extends IService<SalesLedgerProduct> {
+
+ SalesLedgerProduct selectSalesLedgerProductById(Long id);
+
+ List<SalesLedgerProduct> selectSalesLedgerProductList(SalesLedgerProduct salesLedgerProduct);
+
+ int deleteSalesLedgerProductByIds(Long[] ids);
+
+ int addOrUpdateSalesLedgerProduct(SalesLedgerProduct salesLedgerProduct);
+}
diff --git a/src/main/java/com/ruoyi/sales/service/ISalesLedgerService.java b/src/main/java/com/ruoyi/sales/service/ISalesLedgerService.java
index 7e28e93..7ee8c1f 100644
--- a/src/main/java/com/ruoyi/sales/service/ISalesLedgerService.java
+++ b/src/main/java/com/ruoyi/sales/service/ISalesLedgerService.java
@@ -3,6 +3,7 @@
import java.util.List;
import com.baomidou.mybatisplus.extension.service.IService;
+import com.ruoyi.sales.dto.SalesLedgerDto;
import com.ruoyi.sales.pojo.SalesLedger;
/**
@@ -19,7 +20,7 @@
int deleteSalesLedgerByIds(Long[] ids);
- int insertSalesLedger(SalesLedger salesLedger);
+ int addOrUpdateSalesLedger(SalesLedger salesLedger);
- int updateSalesLedger(SalesLedger salesLedger);
+ List<SalesLedgerDto> getSalesLedgerWithProducts();
}
diff --git a/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerProductServiceImpl.java b/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerProductServiceImpl.java
new file mode 100644
index 0000000..793722e
--- /dev/null
+++ b/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerProductServiceImpl.java
@@ -0,0 +1,50 @@
+package com.ruoyi.sales.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ruoyi.sales.mapper.SalesLedgerProductMapper;
+import com.ruoyi.sales.pojo.SalesLedgerProduct;
+import com.ruoyi.sales.service.ISalesLedgerProductService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * 浜у搧淇℃伅Service涓氬姟灞傚鐞�
+ *
+ * @author ruoyi
+ * @date 2025-05-08
+ */
+@Service
+public class SalesLedgerProductServiceImpl extends ServiceImpl<SalesLedgerProductMapper, SalesLedgerProduct> implements ISalesLedgerProductService {
+ @Autowired
+ private SalesLedgerProductMapper salesLedgerProductMapper;
+
+ @Override
+ public SalesLedgerProduct selectSalesLedgerProductById(Long id) {
+ return salesLedgerProductMapper.selectById(id);
+ }
+
+ @Override
+ public List<SalesLedgerProduct> selectSalesLedgerProductList(SalesLedgerProduct salesLedgerProduct) {
+ LambdaQueryWrapper<SalesLedgerProduct> queryWrapper = new LambdaQueryWrapper<>();
+ queryWrapper.eq(SalesLedgerProduct::getSalesLedgerId,salesLedgerProduct.getSalesLedgerId());
+ return salesLedgerProductMapper.selectList(queryWrapper);
+ }
+
+ @Override
+ public int deleteSalesLedgerProductByIds(Long[] ids) {
+ return salesLedgerProductMapper.deleteBatchIds(Arrays.asList(ids));
+ }
+
+ @Override
+ public int addOrUpdateSalesLedgerProduct(SalesLedgerProduct salesLedgerProduct) {
+ if (salesLedgerProduct.getId() == null){
+ return salesLedgerProductMapper.insert(salesLedgerProduct);
+ }else {
+ return salesLedgerProductMapper.updateById(salesLedgerProduct);
+ }
+ }
+}
diff --git a/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java b/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java
index 769cfe9..5048386 100644
--- a/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java
+++ b/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java
@@ -2,14 +2,23 @@
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ruoyi.basic.mapper.CustomerMapper;
+import com.ruoyi.basic.pojo.Customer;
+import com.ruoyi.common.exception.base.BaseException;
+import com.ruoyi.sales.dto.SalesLedgerDto;
import com.ruoyi.sales.mapper.SalesLedgerMapper;
+import com.ruoyi.sales.mapper.SalesLedgerProductMapper;
import com.ruoyi.sales.pojo.SalesLedger;
+import com.ruoyi.sales.pojo.SalesLedgerProduct;
import com.ruoyi.sales.service.ISalesLedgerService;
-import org.springframework.beans.factory.annotation.Autowired;
+import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.Arrays;
+import java.util.Collections;
import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
/**
* 閿�鍞彴璐ervice涓氬姟灞傚鐞�
@@ -18,13 +27,38 @@
* @date 2025-05-08
*/
@Service
+@AllArgsConstructor
public class SalesLedgerServiceImpl extends ServiceImpl<SalesLedgerMapper, SalesLedger> implements ISalesLedgerService {
- @Autowired
+
private SalesLedgerMapper salesLedgerMapper;
+
+ private CustomerMapper customerMapper;
+
+ private SalesLedgerProductMapper salesLedgerProductMapper;
@Override
public List<SalesLedger> selectSalesLedgerList(SalesLedger salesLedger) {
return salesLedgerMapper.selectList(new LambdaQueryWrapper<>());
+ }
+
+ public List<SalesLedgerDto> getSalesLedgerWithProducts() {
+ List<SalesLedger> ledgers = salesLedgerMapper.selectList(new LambdaQueryWrapper<>());
+ List<SalesLedgerProduct> products = salesLedgerProductMapper.selectList(new LambdaQueryWrapper<>());
+
+ Map<Long, List<SalesLedgerProduct>> productMap = products.stream()
+ .collect(Collectors.groupingBy(SalesLedgerProduct::getSalesLedgerId));
+
+ return ledgers.stream().map(ledger -> {
+ SalesLedgerDto dto = new SalesLedgerDto();
+ org.springframework.beans.BeanUtils.copyProperties(ledger, dto);
+
+ List<SalesLedgerProduct> ledgerProducts = productMap.getOrDefault(ledger.getId(), Collections.emptyList());
+ if (!ledgerProducts.isEmpty()) {
+ dto.setHasChildren(true);
+ dto.setChildren(ledgerProducts);
+ }
+ return dto;
+ }).collect(Collectors.toList());
}
@Override
@@ -37,13 +71,23 @@
return salesLedgerMapper.deleteBatchIds(Arrays.asList(ids));
}
- @Override
- public int insertSalesLedger(SalesLedger salesLedger) {
- return salesLedgerMapper.insert(salesLedger);
+ public int addOrUpdateSalesLedger(SalesLedger salesLedger) {
+ LambdaQueryWrapper<Customer> queryWrapper = new LambdaQueryWrapper<>();
+ queryWrapper.eq(Customer::getId, salesLedger.getCustomerId());
+ Customer customer = customerMapper.selectOne(queryWrapper);
+ if (customer == null) {
+ throw new BaseException("鏈煡璇㈠埌瀵瑰簲鐨� Customer 淇℃伅");
+ }
+ salesLedger.setCustomerName(customer.getCustomerName());
+ salesLedger.setTenantId(customer.getTenantId());
+ return saveOrUpdates(salesLedger);
}
- @Override
- public int updateSalesLedger(SalesLedger salesLedger) {
- return salesLedgerMapper.updateById(salesLedger);
+ private int saveOrUpdates(SalesLedger salesLedger) {
+ if (salesLedger.getId() == null) {
+ return salesLedgerMapper.insert(salesLedger);
+ } else {
+ return salesLedgerMapper.updateById(salesLedger);
+ }
}
}
--
Gitblit v1.9.3