From dc9010b9fc4ca6929992bfc3cc4fa110ebc24b2c Mon Sep 17 00:00:00 2001
From: liding <756868258@qq.com>
Date: 星期四, 12 六月 2025 17:45:39 +0800
Subject: [PATCH] 采购优化
---
main-business/src/main/java/com/ruoyi/business/service/impl/PurchaseRegistrationServiceImpl.java | 24 +++++++++++++++++++++++-
1 files changed, 23 insertions(+), 1 deletions(-)
diff --git a/main-business/src/main/java/com/ruoyi/business/service/impl/PurchaseRegistrationServiceImpl.java b/main-business/src/main/java/com/ruoyi/business/service/impl/PurchaseRegistrationServiceImpl.java
index de2bec4..ff4252d 100644
--- a/main-business/src/main/java/com/ruoyi/business/service/impl/PurchaseRegistrationServiceImpl.java
+++ b/main-business/src/main/java/com/ruoyi/business/service/impl/PurchaseRegistrationServiceImpl.java
@@ -5,12 +5,17 @@
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ruoyi.basic.entity.CoalInfo;
+import com.ruoyi.basic.entity.Supply;
+import com.ruoyi.basic.mapper.CoalInfoMapper;
+import com.ruoyi.basic.mapper.SupplyMapper;
import com.ruoyi.business.dto.PurchaseRegistrationDto;
import com.ruoyi.business.entity.PendingInventory;
import com.ruoyi.business.entity.PurchaseRegistration;
import com.ruoyi.business.mapper.PendingInventoryMapper;
import com.ruoyi.business.mapper.PurchaseRegistrationMapper;
import com.ruoyi.business.service.PurchaseRegistrationService;
+import com.ruoyi.common.exception.base.BaseException;
import com.ruoyi.common.utils.bean.BeanUtils;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
@@ -37,6 +42,10 @@
private final PendingInventoryMapper pendingInventoryMapper;
+ private final CoalInfoMapper coalInfoMapper;
+
+ private final SupplyMapper supplyMapper;
+
@Override
public IPage<PurchaseRegistration> selectPurchaseRegistrationList(Page page, PurchaseRegistrationDto purchaseRegistrationDto) {
LambdaQueryWrapper<PurchaseRegistration> queryWrapper = new LambdaQueryWrapper<>();
@@ -53,6 +62,16 @@
// 鍒涘缓閲囪喘鐧昏瀹炰綋骞跺鍒跺睘鎬�
PurchaseRegistration purchaseRegistration = new PurchaseRegistration();
BeanUtils.copyProperties(purchaseRegistrationDto, purchaseRegistration);
+ CoalInfo coalInfo = coalInfoMapper.selectById(purchaseRegistrationDto.getCoalId());
+ if (coalInfo == null) {
+ throw new BaseException("鐓ょ淇℃伅涓嶅瓨鍦�");
+ }
+ purchaseRegistration.setCoal(coalInfo.getCoal());
+ Supply supply = supplyMapper.selectById(purchaseRegistrationDto.getSupplierId());
+ if (supply == null) {
+ throw new BaseException("渚涘簲鍟嗕俊鎭笉瀛樺湪");
+ }
+ purchaseRegistration.setSupplierName(supply.getSupplierName());
if (Objects.isNull(purchaseRegistrationDto.getId())) {
// 鏂板閲囪喘鐧昏
purchaseRegistration.setRegistrationDate(LocalDate.now());
@@ -60,6 +79,8 @@
if (insertCount > 0) {
// 閲囪喘鐧昏鎴愬姛锛屽悓姝ュ垱寤哄緟鍏ュ簱璁板綍
PendingInventory pendingInventory = createPendingInventory(purchaseRegistration);
+ pendingInventory.setSupplierName(supply.getSupplierName());
+ pendingInventory.setCoal(coalInfo.getCoal());
return pendingInventoryMapper.insert(pendingInventory);
}
return insertCount;
@@ -71,6 +92,7 @@
/**
* 鏍规嵁閲囪喘鐧昏淇℃伅鍒涘缓寰呭叆搴撹褰�
+ *
* @param purchaseRegistration 閲囪喘鐧昏瀹炰綋
* @return 寰呭叆搴撳疄浣�
*/
@@ -80,7 +102,7 @@
BeanUtils.copyProperties(purchaseRegistration, pendingInventory);
// 璁剧疆寰呭叆搴撹褰曠壒鏈夌殑灞炴�э紙濡傛灉鏈夛級
- pendingInventory.setInventoryQuantity(purchaseRegistration.getPurchaseQuantity());
+ pendingInventory.setInventoryQuantity(purchaseRegistration.getPurchaseQuantity());
return pendingInventory;
}
--
Gitblit v1.9.3