From 6d3a76f894052209cad136ec9bff6ddcd43fc4e7 Mon Sep 17 00:00:00 2001
From: gongchunyi <deslre0381@gmail.com>
Date: 星期一, 20 四月 2026 17:55:48 +0800
Subject: [PATCH] feat: 扫码时做限制,若采购台账已全部质检入库,APP扫码 入库时提示已入库。并且联动质检

---
 src/main/java/com/ruoyi/sales/service/impl/ShippingInfoServiceImpl.java |   44 ++++++++++++++++++++++++--------------------
 1 files changed, 24 insertions(+), 20 deletions(-)

diff --git a/src/main/java/com/ruoyi/sales/service/impl/ShippingInfoServiceImpl.java b/src/main/java/com/ruoyi/sales/service/impl/ShippingInfoServiceImpl.java
index 5394ded..c062391 100644
--- a/src/main/java/com/ruoyi/sales/service/impl/ShippingInfoServiceImpl.java
+++ b/src/main/java/com/ruoyi/sales/service/impl/ShippingInfoServiceImpl.java
@@ -19,14 +19,10 @@
 import com.ruoyi.sales.pojo.ShippingInfo;
 import com.ruoyi.sales.service.ShippingInfoService;
 import com.ruoyi.sales.mapper.SalesLedgerMapper;
-import com.ruoyi.stock.mapper.StockInventoryMapper;
-import com.ruoyi.stock.pojo.StockInventory;
-import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
-import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import org.springframework.transaction.annotation.Transactional;
+
 import java.math.BigDecimal;
-import java.util.HashMap;
-import java.util.Map;
+
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -62,13 +58,10 @@
     @Autowired
     private SalesLedgerMapper salesLedgerMapper;
 
-    @Autowired
-    private StockInventoryMapper stockInventoryMapper;
-
     @Override
     public IPage<ShippingInfoDto> listPage(Page page, ShippingInfo req) {
         IPage<ShippingInfoDto> listPage = shippingInfoMapper.listPage(page, req);
-        listPage.getRecords().forEach(item ->{
+        listPage.getRecords().forEach(item -> {
             item.setCommonFileList(commonFileService.getFileListByBusinessId(item.getId(), FileNameType.SHIP.getValue()));
         });
         return listPage;
@@ -81,11 +74,22 @@
         if (byId == null) {
             throw new RuntimeException("鍙戣揣淇℃伅涓嶅瓨鍦�");
         }
+        //  鍙戣揣鎵e簱瀛樺墠蹇呴』淇濊瘉璇ヨ鍗曟墍鏈変骇鍝佸凡鍏ュ簱
+        List<SalesLedgerProduct> notStocked = salesLedgerProductMapper.selectList(new LambdaQueryWrapper<SalesLedgerProduct>()
+                .eq(SalesLedgerProduct::getSalesLedgerId, byId.getSalesLedgerId())
+                .eq(SalesLedgerProduct::getType, 1)
+                .ne(SalesLedgerProduct::getProductStockStatus, 2));
+        if (CollectionUtils.isNotEmpty(notStocked)) {
+            throw new RuntimeException("鍙戣揣澶辫触,璇ラ攢鍞鍗曞瓨鍦ㄦ湭鍏ュ簱浜у搧,璇峰厛瀹屾垚鍏ㄩ儴鍏ュ簱鍚庡啀鍙戣揣");
+        }
         //鎵e噺搴撳瓨
-        if(!"宸插彂璐�".equals(byId.getStatus())){
+        if (!"宸插彂璐�".equals(byId.getStatus())) {
             SalesLedgerProduct salesLedgerProduct = salesLedgerProductMapper.selectById(byId.getSalesLedgerProductId());
             if (salesLedgerProduct != null) {
-                stockUtils.substractStock(salesLedgerProduct.getProductModelId(), salesLedgerProduct.getQuantity(), StockOutQualifiedRecordTypeEnum.SALE_SHIP_STOCK_OUT.getCode(), req.getId());
+                stockUtils.substractStock(salesLedgerProduct.getSalesLedgerId(), salesLedgerProduct.getId(), salesLedgerProduct.getProductModelId(), salesLedgerProduct.getQuantity(), StockOutQualifiedRecordTypeEnum.SALE_SHIP_STOCK_OUT.getCode(), req.getId());
+                BigDecimal shipped = salesLedgerProduct.getShippedQuantity() == null ? BigDecimal.ZERO : salesLedgerProduct.getShippedQuantity();
+                salesLedgerProduct.setShippedQuantity(shipped.add(salesLedgerProduct.getQuantity() == null ? BigDecimal.ZERO : salesLedgerProduct.getQuantity()));
+                salesLedgerProductMapper.updateById(salesLedgerProduct);
             }
         }
         byId.setExpressNumber(req.getExpressNumber());
@@ -108,10 +112,10 @@
         }
 
         // 杩佺Щ鏂囦欢
-        if(CollectionUtils.isNotEmpty(req.getTempFileIds())){
+        if (CollectionUtils.isNotEmpty(req.getTempFileIds())) {
             tempFileService.migrateTempFilesToFormal(req.getId(), req.getTempFileIds(), FileNameType.SHIP.getValue());
         }
-        return update ;
+        return update;
     }
 
 
@@ -119,21 +123,21 @@
     public boolean delete(List<Long> ids) {
         List<ShippingInfo> shippingInfos = shippingInfoMapper.selectList(new LambdaQueryWrapper<ShippingInfo>()
                 .in(ShippingInfo::getId, ids));
-        if(CollectionUtils.isEmpty(shippingInfos)) return false;
+        if (CollectionUtils.isEmpty(shippingInfos)) return false;
         // 鍒犻櫎闄勪欢
         commonFileService.deleteByBusinessIds(ids, FileNameType.SHIP.getValue());
         // 鎵e凡鍙戣揣搴撳瓨
         for (ShippingInfo shippingInfo : shippingInfos) {
-            if("宸插彂璐�".equals(shippingInfo.getStatus())) {
+            if ("宸插彂璐�".equals(shippingInfo.getStatus())) {
                 stockUtils.deleteStockOutRecord(shippingInfo.getId(), StockOutQualifiedRecordTypeEnum.SALE_SHIP_STOCK_OUT.getCode());
             }
         }
         // 鍒犻櫎鍙戣揣瀹℃壒
-        if(CollectionUtils.isNotEmpty(shippingInfos)){
-            for (ShippingInfo shippingInfo : shippingInfos){
+        if (CollectionUtils.isNotEmpty(shippingInfos)) {
+            for (ShippingInfo shippingInfo : shippingInfos) {
                 ApproveProcess one = approveProcessService.getOne(new LambdaQueryWrapper<ApproveProcess>()
                         .like(ApproveProcess::getApproveReason, shippingInfo.getShippingNo()));
-                if(one != null){
+                if (one != null) {
                     approveProcessService.delByIds(Collections.singletonList(one.getId()));
                 }
             }
@@ -144,7 +148,7 @@
 
     @Override
     public List<SalesLedgerProductDto> getReturnManagementDtoById(Long shippingId) {
-        return shippingInfoMapper.getReturnManagementDtoById(shippingId );
+        return shippingInfoMapper.getReturnManagementDtoById(shippingId);
 
     }
 

--
Gitblit v1.9.3