From 2c2605a1297882bf88c3c86313ee37797854689b Mon Sep 17 00:00:00 2001
From: huminmin <mac@MacBook-Pro.local>
Date: 星期一, 08 六月 2026 10:28:27 +0800
Subject: [PATCH] Merge branch 'dev_New_pro' of http://114.132.189.42:9002/r/product-inventory-management-after into dev_宁夏_万通新型
---
src/main/java/com/ruoyi/purchase/service/impl/PurchaseLedgerServiceImpl.java | 81 ++++++++++++++++++++++++++++++++++++++++
1 files changed, 81 insertions(+), 0 deletions(-)
diff --git a/src/main/java/com/ruoyi/purchase/service/impl/PurchaseLedgerServiceImpl.java b/src/main/java/com/ruoyi/purchase/service/impl/PurchaseLedgerServiceImpl.java
index 7a70435..dd4ed04 100644
--- a/src/main/java/com/ruoyi/purchase/service/impl/PurchaseLedgerServiceImpl.java
+++ b/src/main/java/com/ruoyi/purchase/service/impl/PurchaseLedgerServiceImpl.java
@@ -22,6 +22,7 @@
import com.ruoyi.basic.pojo.ProductModel;
import com.ruoyi.basic.pojo.SupplierManage;
import com.ruoyi.basic.utils.FileUtil;
+import com.ruoyi.common.enums.StockInQualifiedRecordTypeEnum;
import com.ruoyi.common.exception.base.BaseException;
import com.ruoyi.common.enums.ApprovalStatusEnum;
import com.ruoyi.common.enums.ReviewStatusEnum;
@@ -42,6 +43,7 @@
import com.ruoyi.purchase.dto.PurchaseLedgerDto;
import com.ruoyi.purchase.dto.PurchaseLedgerImportDto;
import com.ruoyi.purchase.dto.PurchaseLedgerProductImportDto;
+import com.ruoyi.purchase.dto.PurchaseStockInDto;
import com.ruoyi.purchase.mapper.PurchaseLedgerMapper;
import com.ruoyi.purchase.pojo.PurchaseLedger;
import com.ruoyi.purchase.service.IPurchaseLedgerService;
@@ -116,6 +118,7 @@
private final StockInRecordService stockInRecordService;
private final StockUtils stockUtils;
private final ApprovalTemplateMapper approvalTemplateMapper;
+ private final StockUtils stockUtils;
@Override
public List<PurchaseLedger> selectPurchaseLedgerList(PurchaseLedger purchaseLedger) {
@@ -1051,6 +1054,84 @@
}
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public int manualStockIn(PurchaseStockInDto purchaseStockInDto) {
+ if (purchaseStockInDto == null || purchaseStockInDto.getPurchaseLedgerId() == null) {
+ throw new BaseException("閲囪喘鍙拌处ID涓嶈兘涓虹┖");
+ }
+ if (CollectionUtils.isEmpty(purchaseStockInDto.getDetails())) {
+ throw new BaseException("璇烽�夋嫨鑷冲皯涓�涓骇鍝佽繘琛屽叆搴�");
+ }
+
+ // 鏌ヨ閲囪喘鍙拌处
+ PurchaseLedger purchaseLedger = purchaseLedgerMapper.selectById(purchaseStockInDto.getPurchaseLedgerId());
+ if (purchaseLedger == null) {
+ throw new BaseException("閲囪喘鍙拌处涓嶅瓨鍦�");
+ }
+
+ // 楠岃瘉閲囪喘鍙拌处鐘舵�佹槸鍚︿负宸插鎵�
+ if (!"3".equals(String.valueOf(purchaseLedger.getApprovalStatus()))) {
+ throw new BaseException("鍙湁宸插鎵归�氳繃鐨勯噰璐彴璐︽墠鑳藉叆搴�");
+ }
+
+ int count = 0;
+ for (PurchaseStockInDto.StockInProductItem item : purchaseStockInDto.getDetails()) {
+ if (item.getId() == null) {
+ continue;
+ }
+
+ // 鏌ヨ閲囪喘浜у搧
+ SalesLedgerProduct salesLedgerProduct = salesLedgerProductMapper.selectById(item.getId());
+ if (salesLedgerProduct == null) {
+ throw new BaseException("閲囪喘浜у搧涓嶅瓨鍦�");
+ }
+
+ // 鑾峰彇鐞嗚鍏ュ簱鏁伴噺锛堝墠绔紶鍏ョ殑inboundQuantity锛�
+ BigDecimal theoryStockInNum = item.getInboundQuantity();
+ if (theoryStockInNum == null) {
+ theoryStockInNum = salesLedgerProduct.getQuantity();
+ }
+ // 绌哄�煎拰闈炴鏁版牎楠�
+ if (theoryStockInNum == null || theoryStockInNum.compareTo(BigDecimal.ZERO) <= 0) {
+ throw new BaseException("鐞嗚鍏ュ簱鏁伴噺蹇呴』澶т簬0");
+ }
+
+ // 鑾峰彇瀹為檯鍏ュ簱鏁伴噺锛堝墠绔紶鍏ョ殑actualInboundQuantity锛�
+ BigDecimal actualStockInNum = item.getActualInboundQuantity();
+ if (actualStockInNum == null) {
+ actualStockInNum = theoryStockInNum;
+ }
+ // 闈炴鏁版牎楠�
+ if (actualStockInNum.compareTo(BigDecimal.ZERO) <= 0) {
+ throw new BaseException("瀹為檯鍏ュ簱鏁伴噺蹇呴』澶т簬0");
+ }
+
+ // 鑾峰彇鏄惁鍚按鍜屽惈姘撮噺
+ Boolean isContainsWater = item.getIsContainsWater();
+ BigDecimal waterContent = item.getWaterContent();
+ if (waterContent == null) {
+ waterContent = BigDecimal.ZERO;
+ }
+
+ // 璋冪敤StockUtils杩涜鍏ュ簱锛堝甫鍚按閲忎俊鎭級
+ stockUtils.addStockWithBatchNo(
+ salesLedgerProduct.getProductModelId(),
+ actualStockInNum,
+ StockInQualifiedRecordTypeEnum.PURCHASE_STOCK_IN.getCode(),
+ purchaseLedger.getId(),
+ purchaseLedger.getPurchaseContractNumber() + "-" + salesLedgerProduct.getId(),
+ isContainsWater,
+ waterContent,
+ theoryStockInNum
+ );
+
+ count++;
+ }
+
+ return count;
+ }
+
/**
* 涓嬪垝绾垮懡鍚嶈浆椹煎嘲鍛藉悕
*/
--
Gitblit v1.9.3