From 286581ef6495f7bb18135bb66affcb2f51488ecd Mon Sep 17 00:00:00 2001
From: huminmin <mac@MacBook-Pro.local>
Date: 星期一, 08 六月 2026 10:37:05 +0800
Subject: [PATCH] 修改采购台账审批
---
src/main/java/com/ruoyi/purchase/service/impl/PurchaseLedgerServiceImpl.java | 90 ++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 89 insertions(+), 1 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..8c1fe41 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;
@@ -60,6 +62,7 @@
import com.ruoyi.sales.pojo.SalesLedger;
import com.ruoyi.sales.pojo.SalesLedgerProduct;
import com.ruoyi.sales.service.impl.CommonFileServiceImpl;
+import com.ruoyi.stock.dto.StockInRecordDto;
import com.ruoyi.stock.pojo.StockInRecord;
import com.ruoyi.stock.service.StockInRecordService;
import lombok.RequiredArgsConstructor;
@@ -609,7 +612,14 @@
.filter(Objects::nonNull)
.collect(Collectors.toList());
if (!pendingIds.isEmpty()) {
- stockInRecordService.batchApprove(pendingIds, ReviewStatusEnum.APPROVED.getCode());
+ List<StockInRecordDto.StockInRecordApproveItemDto> approveItems = pendingIds.stream()
+ .map(id -> {
+ StockInRecordDto.StockInRecordApproveItemDto item = new StockInRecordDto.StockInRecordApproveItemDto();
+ item.setId(id);
+ return item;
+ })
+ .collect(Collectors.toList());
+ stockInRecordService.batchApprove(ReviewStatusEnum.APPROVED.getCode(), approveItems);
}
}
@@ -1051,6 +1061,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