From 0bc2c552b180afa16e4aae3c8c12746b15ba6fc8 Mon Sep 17 00:00:00 2001
From: yuan <123@>
Date: 星期四, 02 四月 2026 17:35:42 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/dev_长治_健齿齿科器材' into dev_长治_健齿齿科器材

---
 src/main/java/com/ruoyi/quality/service/impl/QualityInspectServiceImpl.java           |    7 
 src/main/java/com/ruoyi/stock/pojo/StockInventory.java                                |    5 
 src/main/java/com/ruoyi/purchase/service/impl/PurchaseLedgerServiceImpl.java          |  146 +++++++++------
 src/main/resources/mapper/quality/QualityUnqualifiedMapper.xml                        |    3 
 src/main/resources/mapper/sales/SalesQuotationMapper.xml                              |    3 
 src/main/java/com/ruoyi/procurementrecord/utils/StockUtils.java                       |    8 
 src/main/java/com/ruoyi/sales/service/impl/SalesLedgerProductServiceImpl.java         |    2 
 src/main/java/com/ruoyi/sales/service/impl/ShippingInfoServiceImpl.java               |    2 
 src/main/resources/mapper/sales/SalesLedgerProductMapper.xml                          |   21 +
 src/main/java/com/ruoyi/purchase/dto/PurchaseLedgerProductImportDto.java              |   41 ++-
 src/main/resources/mapper/sales/InvoiceLedgerMapper.xml                               |    4 
 src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java                |   56 ++---
 src/main/java/com/ruoyi/sales/service/impl/SalesQuotationServiceImpl.java             |   25 --
 src/main/java/com/ruoyi/sales/dto/SalesLedgerProductImportDto.java                    |   15 +
 src/main/java/com/ruoyi/sales/controller/ShippingInfoController.java                  |   27 --
 src/main/java/com/ruoyi/stock/service/impl/StockInventoryServiceImpl.java             |   21 +
 src/main/resources/static/销售台账导入模板.xlsx                                               |    0 
 src/main/java/com/ruoyi/production/service/impl/ProductOrderServiceImpl.java          |    4 
 src/main/java/com/ruoyi/quality/pojo/QualityUnqualified.java                          |    7 
 src/main/java/com/ruoyi/stock/dto/StockInventoryDto.java                              |    1 
 src/main/java/com/ruoyi/production/service/impl/ProductionProductMainServiceImpl.java |    3 
 src/main/java/com/ruoyi/production/dto/DrawMaterialDto.java                           |    4 
 src/main/resources/mapper/stock/StockInventoryMapper.xml                              |   87 +++++++--
 src/main/resources/static/return-record.docx                                          |    0 
 src/main/java/com/ruoyi/quality/pojo/QualityInspect.java                              |    2 
 src/main/java/com/ruoyi/sales/controller/ShipmentApprovalController.java              |    3 
 src/main/java/com/ruoyi/approve/service/impl/ApproveNodeServiceImpl.java              |    5 
 src/main/java/com/ruoyi/quality/service/impl/QualityUnqualifiedServiceImpl.java       |    8 
 src/main/resources/static/采购台账导入模板.xlsx                                               |    0 
 src/main/java/com/ruoyi/stock/execl/StockInventoryExportData.java                     |   14 +
 src/main/resources/mapper/purchase/PaymentRegistrationMapper.xml                      |    8 
 31 files changed, 315 insertions(+), 217 deletions(-)

diff --git a/src/main/java/com/ruoyi/approve/service/impl/ApproveNodeServiceImpl.java b/src/main/java/com/ruoyi/approve/service/impl/ApproveNodeServiceImpl.java
index 22ba5ac..5780754 100644
--- a/src/main/java/com/ruoyi/approve/service/impl/ApproveNodeServiceImpl.java
+++ b/src/main/java/com/ruoyi/approve/service/impl/ApproveNodeServiceImpl.java
@@ -12,7 +12,6 @@
 import com.ruoyi.approve.pojo.ApproveProcess;
 import com.ruoyi.approve.service.IApproveNodeService;
 import com.ruoyi.common.enums.FileNameType;
-import com.ruoyi.common.enums.StockInQualifiedRecordTypeEnum;
 import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.device.mapper.DeviceRepairMapper;
 import com.ruoyi.device.pojo.DeviceRepair;
@@ -206,8 +205,8 @@
                             purchaseLedgerServiceImpl.addQualityInspect(purchaseLedger, salesLedgerProduct);
                         }else {
                             //鐩存帴鍏ュ簱
-                            stockUtils.addStock(salesLedgerProduct.getProductModelId(), salesLedgerProduct.getQuantity(), StockInQualifiedRecordTypeEnum.PURCHASE_STOCK_IN.getCode(),
-                                    purchaseLedger.getId(),salesLedgerProduct.getBatchNo(),salesLedgerProduct.getCustomer());
+//                            stockUtils.addStock(salesLedgerProduct.getProductModelId(), salesLedgerProduct.getQuantity(), StockInQualifiedRecordTypeEnum.PURCHASE_STOCK_IN.getCode(),
+//                                    purchaseLedger.getId(),salesLedgerProduct.getBatchNo(),salesLedgerProduct.getCustomer());
                         }
                     }
                 } else if (status.equals(3)) {
diff --git a/src/main/java/com/ruoyi/procurementrecord/utils/StockUtils.java b/src/main/java/com/ruoyi/procurementrecord/utils/StockUtils.java
index 4f20fb0..81125ad 100644
--- a/src/main/java/com/ruoyi/procurementrecord/utils/StockUtils.java
+++ b/src/main/java/com/ruoyi/procurementrecord/utils/StockUtils.java
@@ -16,6 +16,7 @@
 import org.springframework.stereotype.Component;
 
 import java.math.BigDecimal;
+import java.time.LocalDate;
 import java.util.Collections;
 
 @Component
@@ -67,7 +68,7 @@
      * @param recordType
      * @param recordId
      */
-    public void addStock(Long productModelId, BigDecimal quantity, String recordType, Long recordId,String batchNo,String customer) {
+    public void addStock(Long productModelId, BigDecimal quantity, String recordType, Long recordId, String batchNo, String customer, LocalDate productionDate) {
         StockInventoryDto stockInventoryDto = new StockInventoryDto();
         stockInventoryDto.setRecordId(recordId);
         if (recordType != null) {
@@ -77,6 +78,11 @@
         stockInventoryDto.setProductModelId(productModelId);
         stockInventoryDto.setBatchNo(batchNo);
         stockInventoryDto.setCustomer(customer);
+        if (stockInventoryDto.getProductionDate() == null) {
+            stockInventoryDto.setProductionDate(LocalDate.now());
+        }else {
+            stockInventoryDto.setProductionDate(productionDate);
+        }
         stockInventoryService.addstockInventory(stockInventoryDto);
     }
 
diff --git a/src/main/java/com/ruoyi/production/dto/DrawMaterialDto.java b/src/main/java/com/ruoyi/production/dto/DrawMaterialDto.java
index 7cab486..05416e1 100644
--- a/src/main/java/com/ruoyi/production/dto/DrawMaterialDto.java
+++ b/src/main/java/com/ruoyi/production/dto/DrawMaterialDto.java
@@ -4,6 +4,7 @@
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import java.math.BigDecimal;
+import java.time.LocalDate;
 
 @Data
 @ApiModel("棰嗘枡鍗旸TO")
@@ -41,4 +42,7 @@
 
     @ApiModelProperty("渚涘簲鍟嗗悕绉�")
     private String customer;
+
+    @ApiModelProperty("鏈夋晥鏈�")
+    private LocalDate productionDate;
 }
\ No newline at end of file
diff --git a/src/main/java/com/ruoyi/production/service/impl/ProductOrderServiceImpl.java b/src/main/java/com/ruoyi/production/service/impl/ProductOrderServiceImpl.java
index f479a16..0efd3f0 100644
--- a/src/main/java/com/ruoyi/production/service/impl/ProductOrderServiceImpl.java
+++ b/src/main/java/com/ruoyi/production/service/impl/ProductOrderServiceImpl.java
@@ -277,11 +277,11 @@
         }
         // 濡傛灉鏈夋暟鎹厛鍔犲簱瀛�
         ProductOrder productOrder = productOrderMapper.selectById(productOrderDto.getId());
-        if (productOrder != null) {
+        if (productOrder.getDrawMaterials() != null) {
             List<DrawMaterialDto> materialDtoList = JSON.parseArray(productOrder.getDrawMaterials(), DrawMaterialDto.class);
             for (DrawMaterialDto drawMaterialDto : materialDtoList) {
                 stockUtils.addStock(drawMaterialDto.getProductModelId(), drawMaterialDto.getRequisitionQty(), null, productOrderDto.getId(),
-                        drawMaterialDto.getBatchNo(), drawMaterialDto.getCustomer()
+                        drawMaterialDto.getBatchNo(), drawMaterialDto.getCustomer(),drawMaterialDto.getProductionDate()
                 );
             }
         }
diff --git a/src/main/java/com/ruoyi/production/service/impl/ProductionProductMainServiceImpl.java b/src/main/java/com/ruoyi/production/service/impl/ProductionProductMainServiceImpl.java
index 7175825..f46baa1 100644
--- a/src/main/java/com/ruoyi/production/service/impl/ProductionProductMainServiceImpl.java
+++ b/src/main/java/com/ruoyi/production/service/impl/ProductionProductMainServiceImpl.java
@@ -246,7 +246,6 @@
                     throw new RuntimeException("鐢熶骇璁㈠崟涓嶅瓨鍦�");
                 }
 
-
                 Product product = productMapper.selectById(productModel.getProductId());
                 QualityInspect qualityInspect = new QualityInspect();
                 qualityInspect.setProductId(product.getId());
@@ -280,7 +279,7 @@
                 //鐩存帴鍏ュ簱
                 String customer = "闀挎不甯傝酱鎵垮埗閫犳湁闄愬叕鍙�";
                 stockUtils.addStock(productProcessRouteItem.getProductModelId(), productionProductOutput.getQuantity().subtract(productionProductOutput.getScrapQty()),
-                        StockInQualifiedRecordTypeEnum.PRODUCTION_REPORT_STOCK_IN.getCode(), productionProductMain.getId(),order.getBatchNo(),customer
+                        StockInQualifiedRecordTypeEnum.PRODUCTION_REPORT_STOCK_IN.getCode(), productionProductMain.getId(),order.getBatchNo(),customer,null
                 );
             }
             /*鏇存柊宸ュ崟鍜岀敓浜ц鍗�*/
diff --git a/src/main/java/com/ruoyi/purchase/dto/PurchaseLedgerProductImportDto.java b/src/main/java/com/ruoyi/purchase/dto/PurchaseLedgerProductImportDto.java
index 3db4abe..19ccd83 100644
--- a/src/main/java/com/ruoyi/purchase/dto/PurchaseLedgerProductImportDto.java
+++ b/src/main/java/com/ruoyi/purchase/dto/PurchaseLedgerProductImportDto.java
@@ -1,7 +1,6 @@
 package com.ruoyi.purchase.dto;
 
 import com.ruoyi.framework.aspectj.lang.annotation.Excel;
-import com.ruoyi.sales.dto.SalesLedgerProductImportDto;
 import lombok.Data;
 
 import java.math.BigDecimal;
@@ -17,16 +16,6 @@
     private String purchaseContractNumber;
 
     /**
-     * 棰勮鏁伴噺
-     */
-    @Excel(name = "搴撳瓨棰勮鏁伴噺")
-    private BigDecimal warnNum;
-
-    @Excel(name = "閿�鍞崟鍙�")
-    private String salesContractNo;
-
-
-    /**
      * 浜у搧澶х被
      */
     @Excel(name = "浜у搧澶х被")
@@ -39,16 +28,22 @@
     private String specificationModel;
 
     /**
+     * UID鐮�
+     */
+    @Excel(name = "UID鐮�")
+    private String uidNo;
+
+    /**
+     * 鎵规鍙�
+     */
+    @Excel(name = "鎵规鍙�")
+    private String batchNo;
+
+    /**
      * 鍗曚綅
      */
     @Excel(name = "鍗曚綅")
     private String unit;
-
-    /**
-     * 鏁伴噺
-     */
-    @Excel(name = "鏁伴噺")
-    private BigDecimal quantity;
 
     /**
      * 绋庣巼
@@ -63,6 +58,12 @@
     private BigDecimal taxInclusiveUnitPrice;
 
     /**
+     * 鏁伴噺
+     */
+    @Excel(name = "鏁伴噺")
+    private BigDecimal quantity;
+
+    /**
      * 鍚◣鎬讳环
      */
     @Excel(name = "鍚◣鎬讳环")
@@ -75,6 +76,12 @@
     private String invoiceType;
 
     /**
+     * 棰勮鏁伴噺
+     */
+    @Excel(name = "搴撳瓨棰勮鏁伴噺")
+    private BigDecimal warnNum;
+
+    /**
      * 鏄惁璐ㄦ
      */
     @Excel(name = "鏄惁璐ㄦ", readConverterExp = "0=鍚�,1=鏄�")
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 17f1a29..7fada6a 100644
--- a/src/main/java/com/ruoyi/purchase/service/impl/PurchaseLedgerServiceImpl.java
+++ b/src/main/java/com/ruoyi/purchase/service/impl/PurchaseLedgerServiceImpl.java
@@ -17,6 +17,7 @@
 import com.ruoyi.basic.pojo.ProductModel;
 import com.ruoyi.basic.pojo.SupplierManage;
 import com.ruoyi.common.enums.FileNameType;
+import com.ruoyi.common.enums.StockInQualifiedRecordTypeEnum;
 import com.ruoyi.common.exception.base.BaseException;
 import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.common.utils.StringUtils;
@@ -27,6 +28,7 @@
 import com.ruoyi.other.pojo.TempFile;
 import com.ruoyi.procurementrecord.mapper.ProcurementRecordMapper;
 import com.ruoyi.procurementrecord.pojo.ProcurementRecordStorage;
+import com.ruoyi.procurementrecord.utils.StockUtils;
 import com.ruoyi.project.system.domain.SysUser;
 import com.ruoyi.project.system.mapper.SysUserMapper;
 import com.ruoyi.purchase.dto.PurchaseLedgerDto;
@@ -88,68 +90,70 @@
 @Slf4j
 public class PurchaseLedgerServiceImpl extends ServiceImpl<PurchaseLedgerMapper, PurchaseLedger> implements IPurchaseLedgerService {
     @Autowired
-    private  AccountExpenseService accountExpenseService;
+    private AccountExpenseService accountExpenseService;
     @Autowired
-    private  PurchaseLedgerMapper purchaseLedgerMapper;
+    private PurchaseLedgerMapper purchaseLedgerMapper;
 
     @Autowired
-    private  SalesLedgerMapper salesLedgerMapper;
+    private SalesLedgerMapper salesLedgerMapper;
     @Autowired
-    private  SalesLedgerProductMapper salesLedgerProductMapper;
+    private SalesLedgerProductMapper salesLedgerProductMapper;
 
     @Autowired
-    private  SysUserMapper userMapper;
+    private SysUserMapper userMapper;
 
     @Autowired
-    private  TempFileMapper tempFileMapper;
+    private TempFileMapper tempFileMapper;
 
     @Autowired
-    private  CommonFileMapper commonFileMapper;
+    private CommonFileMapper commonFileMapper;
 
     @Autowired
-    private  SupplierManageMapper supplierManageMapper;
+    private SupplierManageMapper supplierManageMapper;
 
     @Autowired
-    private  ProductMapper productMapper;
+    private ProductMapper productMapper;
 
     @Autowired
-    private  ProductModelMapper productModelMapper;
+    private ProductModelMapper productModelMapper;
 
     @Autowired
-    private  SysUserMapper sysUserMapper;
+    private SysUserMapper sysUserMapper;
 
     @Autowired
-    private  TicketRegistrationMapper ticketRegistrationMapper;
+    private TicketRegistrationMapper ticketRegistrationMapper;
 
     @Autowired
-    private  ProductRecordMapper productRecordMapper;
+    private ProductRecordMapper productRecordMapper;
 
     @Autowired
-    private  PaymentRegistrationMapper paymentRegistrationMapper;
+    private PaymentRegistrationMapper paymentRegistrationMapper;
     @Autowired
-    private  InvoiceRegistrationProductMapper invoiceRegistrationProductMapper;
+    private InvoiceRegistrationProductMapper invoiceRegistrationProductMapper;
     @Autowired
-    private  StringRedisTemplate redisTemplate;
+    private StringRedisTemplate redisTemplate;
     @Autowired
-    private  QualityInspectMapper qualityInspectMapper;
+    private QualityInspectMapper qualityInspectMapper;
     @Autowired
-    private  CommonFileServiceImpl commonFileService;
+    private CommonFileServiceImpl commonFileService;
     @Autowired
-    private  QualityTestStandardBindingMapper qualityTestStandardBindingMapper;
+    private QualityTestStandardBindingMapper qualityTestStandardBindingMapper;
     @Autowired
-    private  QualityTestStandardParamMapper qualityTestStandardParamMapper;
+    private QualityTestStandardParamMapper qualityTestStandardParamMapper;
     @Autowired
-    private  QualityTestStandardMapper qualityTestStandardMapper;
+    private QualityTestStandardMapper qualityTestStandardMapper;
     @Autowired
-    private  QualityInspectParamMapper qualityInspectParamMapper;
+    private QualityInspectParamMapper qualityInspectParamMapper;
     @Autowired
-    private  ApproveProcessServiceImpl approveProcessService;
+    private ApproveProcessServiceImpl approveProcessService;
     @Autowired
-    private  ProcurementRecordMapper procurementRecordStorageMapper;
+    private ProcurementRecordMapper procurementRecordStorageMapper;
     @Autowired
-    private  PurchaseLedgerTemplateMapper purchaseLedgerTemplateMapper;
+    private PurchaseLedgerTemplateMapper purchaseLedgerTemplateMapper;
     @Autowired
-    private  SalesLedgerProductTemplateMapper salesLedgerProductTemplateMapper;
+    private SalesLedgerProductTemplateMapper salesLedgerProductTemplateMapper;
+    @Autowired
+    private StockUtils stockUtils;
     @Value("${file.upload-dir}")
     private String uploadDir;
 
@@ -201,23 +205,25 @@
             }
             purchaseLedgerMapper.updateById(purchaseLedger);
         }
-        // 6.閲囪喘瀹℃牳鏂板
-        addApproveByPurchase(loginUser, purchaseLedger);
 
         // 4. 澶勭悊瀛愯〃鏁版嵁
         List<SalesLedgerProduct> productList = purchaseLedgerDto.getProductData();
         if (productList != null && !productList.isEmpty()) {
-            handleSalesLedgerProducts(purchaseLedger.getId(), productList, purchaseLedgerDto.getType(),supplierManage);
+            handleSalesLedgerProducts(purchaseLedger.getId(), productList, purchaseLedgerDto.getType(), supplierManage);
         }
-        //鏂板鍘熸潗鏂欐楠�  瀹℃壒涔嬪悗鎵嶇敓鎴愭楠�
-//        if (productList != null) {
-//            for (SalesLedgerProduct saleProduct : productList) {
-//                //鏄惁鎺ㄩ�佽川妫�锛屽鏋渢rue灏辨坊鍔�
-//                if (saleProduct.getIsChecked()) {
-//                    addQualityInspect(purchaseLedger, saleProduct);
-//                }
-//            }
-//        }
+        //涓嶅鎵�
+        if (productList != null) {
+            for (SalesLedgerProduct saleProduct : productList) {
+                //鏄惁鎺ㄩ�佽川妫�锛屽鏋渢rue灏辨坊鍔�
+                if (saleProduct.getIsChecked()) {
+                    addQualityInspect(purchaseLedger, saleProduct);
+                } else {
+                    //鐩存帴鍏ュ簱
+                    stockUtils.addStock(saleProduct.getProductModelId(), saleProduct.getQuantity(), StockInQualifiedRecordTypeEnum.PURCHASE_STOCK_IN.getCode(),
+                            purchaseLedger.getId(), saleProduct.getBatchNo(), saleProduct.getCustomer(), null);
+                }
+            }
+        }
         // 5. 杩佺Щ涓存椂鏂囦欢鍒版寮忕洰褰�
         if (purchaseLedgerDto.getTempFileIds() != null && !purchaseLedgerDto.getTempFileIds().isEmpty()) {
             migrateTempFilesToFormal(purchaseLedger.getId(), purchaseLedgerDto.getTempFileIds());
@@ -239,12 +245,12 @@
         qualityInspect.setUnit(saleProduct.getUnit());
         qualityInspect.setQuantity(saleProduct.getQuantity());
         qualityInspectMapper.insert(qualityInspect);
-        List<QualityTestStandard> qualityTestStandard = qualityTestStandardMapper.getQualityTestStandardByProductId(saleProduct.getProductId(), 0,null);
-        if (qualityTestStandard.size()>0){
+        List<QualityTestStandard> qualityTestStandard = qualityTestStandardMapper.getQualityTestStandardByProductId(saleProduct.getProductId(), 0, null);
+        if (!qualityTestStandard.isEmpty()) {
             qualityInspect.setTestStandardId(qualityTestStandard.get(0).getId());
             qualityInspectMapper.updateById(qualityInspect);
             qualityTestStandardParamMapper.selectList(Wrappers.<QualityTestStandardParam>lambdaQuery()
-                    .eq(QualityTestStandardParam::getTestStandardId,qualityTestStandard.get(0).getId()))
+                            .eq(QualityTestStandardParam::getTestStandardId, qualityTestStandard.get(0).getId()))
                     .forEach(qualityTestStandardParam -> {
                         QualityInspectParam param = new QualityInspectParam();
                         com.ruoyi.common.utils.bean.BeanUtils.copyProperties(qualityTestStandardParam, param);
@@ -255,7 +261,7 @@
         }
     }
 
-    private void handleSalesLedgerProducts(Long salesLedgerId, List<SalesLedgerProduct> products, Integer type,SupplierManage supplierManage) {
+    private void handleSalesLedgerProducts(Long salesLedgerId, List<SalesLedgerProduct> products, Integer type, SupplierManage supplierManage) {
         if (products == null || products.isEmpty()) {
             throw new BaseException("浜у搧淇℃伅涓嶅瓨鍦�");
         }
@@ -422,12 +428,12 @@
     @Transactional(rollbackFor = Exception.class)
     public int deletePurchaseLedgerByIds(Long[] ids) {
         if (ids == null || ids.length == 0) {
-           throw new BaseException("璇烽�変腑鑷冲皯涓�鏉℃暟鎹�");
+            throw new BaseException("璇烽�変腑鑷冲皯涓�鏉℃暟鎹�");
         }
         for (Long id : ids) {
             PurchaseLedger purchaseLedger = purchaseLedgerMapper.selectById(id);
             if (purchaseLedger.getApprovalStatus().equals(3)) {
-                throw new BaseException(purchaseLedger.getPurchaseContractNumber()+"宸茬粡瀹℃壒閫氳繃锛屼笉鍏佽鍒犻櫎");
+                throw new BaseException(purchaseLedger.getPurchaseContractNumber() + "宸茬粡瀹℃壒閫氳繃锛屼笉鍏佽鍒犻櫎");
             }
         }
         // 鎵归噺鍒犻櫎鍏宠仈鐨勯噰璐叆搴撹褰�
@@ -450,11 +456,11 @@
         salesLedgerProductMapper.delete(queryWrapper);
         // 鎵归噺鍒犻櫎鍏宠仈鐨勯噰璐彴璐︾殑鏉ョエ鐧昏
         LambdaQueryWrapper<TicketRegistration> ticketRegistrationLambdaQueryWrapper = new LambdaQueryWrapper<>();
-        ticketRegistrationLambdaQueryWrapper.in(TicketRegistration::getPurchaseLedgerId,ids);
+        ticketRegistrationLambdaQueryWrapper.in(TicketRegistration::getPurchaseLedgerId, ids);
         ticketRegistrationMapper.delete(ticketRegistrationLambdaQueryWrapper);
         // 鎵归噺鍒犻櫎鍏宠仈鐨勯噰璐彴璐︾殑鏉ョエ鐧昏璁板綍
         LambdaQueryWrapper<ProductRecord> productRecordLambdaQueryWrapper = new LambdaQueryWrapper<>();
-        productRecordLambdaQueryWrapper.in(ProductRecord::getPurchaseLedgerId,ids);
+        productRecordLambdaQueryWrapper.in(ProductRecord::getPurchaseLedgerId, ids);
         productRecordMapper.delete(productRecordLambdaQueryWrapper);
         // 鎵归噺鍒犻櫎浠樻鐧昏
         LambdaQueryWrapper<PaymentRegistration> paymentRegistrationLambdaQueryWrapper = new LambdaQueryWrapper<>();
@@ -466,7 +472,7 @@
 
         List<QualityInspect> qualityInspects = qualityInspectMapper.selectList(materialInspectLambdaQueryWrapper);
         qualityInspects.stream().forEach(qualityInspect -> {
-            if (ObjectUtils.isNotEmpty(qualityInspect.getInspectState())&&qualityInspect.getInspectState().equals(1)) {
+            if (ObjectUtils.isNotEmpty(qualityInspect.getInspectState()) && qualityInspect.getInspectState().equals(1)) {
                 throw new BaseException("宸叉彁浜ょ殑妫�楠屽崟涓嶈兘鍒犻櫎");
             }
         });
@@ -482,7 +488,7 @@
         // 鍒犻櫎閲囪喘瀹℃壒璁板綍
         for (Long id : ids) {
             PurchaseLedger purchaseLedger = purchaseLedgerMapper.selectById(id);
-            if(purchaseLedger != null){
+            if (purchaseLedger != null) {
                 ApproveProcess one = approveProcessService.getOne(new LambdaQueryWrapper<ApproveProcess>()
                         .eq(ApproveProcess::getApproveType, 5)
                         .eq(ApproveProcess::getApproveDelete, 0)
@@ -527,7 +533,7 @@
         // 3.鏌ヨ涓婁紶鏂囦欢
         LambdaQueryWrapper<CommonFile> salesLedgerFileWrapper = new LambdaQueryWrapper<>();
         salesLedgerFileWrapper.eq(CommonFile::getCommonId, purchaseLedger.getId())
-                .eq(CommonFile::getType,FileNameType.PURCHASE.getValue());
+                .eq(CommonFile::getType, FileNameType.PURCHASE.getValue());
         List<CommonFile> salesLedgerFiles = commonFileMapper.selectList(salesLedgerFileWrapper);
 
         // 4. 杞崲 DTO
@@ -678,7 +684,7 @@
             // 渚涘簲鍟嗘暟鎹�
             List<SupplierManage> customers = supplierManageMapper.selectList(new LambdaQueryWrapper<SupplierManage>().in(SupplierManage::getSupplierName,
                     salesLedgerImportDtoList.stream().map(PurchaseLedgerImportDto::getSupplierName).collect(Collectors.toList())));
-            List<Map<String,Object>> list = productModelMapper.getProductAndModelList();
+            List<Map<String, Object>> list = productModelMapper.getProductAndModelList();
             // 褰曞叆浜烘暟鎹�
             List<SysUser> sysUsers = sysUserMapper.selectList(new LambdaQueryWrapper<SysUser>().in(SysUser::getNickName,
                     salesLedgerImportDtoList.stream().map(PurchaseLedgerImportDto::getRecorderName).collect(Collectors.toList())));
@@ -686,7 +692,7 @@
                 PurchaseLedger purchaseLedger = purchaseLedgerMapper.selectOne(new LambdaQueryWrapper<PurchaseLedger>()
                         .eq(PurchaseLedger::getPurchaseContractNumber, salesLedgerImportDto.getPurchaseContractNumber())
                         .last("limit 1"));
-                if(purchaseLedger != null){
+                if (purchaseLedger != null) {
                     continue;
                 }
                 PurchaseLedger salesLedger = new PurchaseLedger();
@@ -713,12 +719,12 @@
                     throw new RuntimeException("閲囪喘鍗曞彿:" + salesLedgerImportDto.getPurchaseContractNumber() + ",鏃犲搴斾骇鍝佹暟鎹紒");
                 salesLedger.setContractAmount(salesLedgerProductImportDtos.stream()
                         .map(PurchaseLedgerProductImportDto::getTaxInclusiveTotalPrice)
-                        .reduce(BigDecimal.ZERO,BigDecimal::add));
+                        .reduce(BigDecimal.ZERO, BigDecimal::add));
                 // 閫氳繃閿�鍞崟鍙风粦瀹氶攢鍞�
                 SalesLedger salesLedger1 = salesLedgerMapper.selectOne(new LambdaQueryWrapper<SalesLedger>()
                         .eq(SalesLedger::getSalesContractNo, salesLedger.getSalesContractNo())
                         .last("LIMIT 1"));
-                if(salesLedger1 != null){
+                if (salesLedger1 != null) {
                     salesLedger.setSalesLedgerId(salesLedger1.getId());
                 }
                 // 閲囪喘瀹℃牳
@@ -739,6 +745,24 @@
 
                 for (PurchaseLedgerProductImportDto salesLedgerProductImportDto : salesLedgerProductImportDtos) {
                     SalesLedgerProduct salesLedgerProduct = new SalesLedgerProduct();
+                    // 鏌ヨ浜у搧
+                    Product product = productMapper.selectOne(new LambdaQueryWrapper<Product>()
+                            .eq(Product::getProductName, salesLedgerProductImportDto.getProductCategory()));
+                    if (product == null) {
+                        throw new RuntimeException("璇风淮鎶や骇鍝侊細" + salesLedgerProductImportDto.getProductCategory());
+                    }
+                    // 鏌ヨ浜у搧鍨嬪彿
+                    ProductModel productModel = productModelMapper.selectOne(new LambdaQueryWrapper<ProductModel>()
+                            .eq(ProductModel::getProductId, product.getId())
+                            .eq(ProductModel::getModel, salesLedgerProductImportDto.getSpecificationModel())
+                            .eq(ProductModel::getUidNo, salesLedgerProductImportDto.getUidNo()));
+                    if (productModel == null) {
+                        throw new RuntimeException("璇风淮鎶や骇鍝併��" + salesLedgerProductImportDto.getProductCategory() + "銆戠殑鍨嬪彿銆�"
+                                + salesLedgerProductImportDto.getSpecificationModel() + "銆戝拰UID鐮併��"
+                                + salesLedgerProductImportDto.getUidNo() + "銆�");
+                    }
+                    salesLedgerProduct.setProductModelId(productModel.getId());
+                    salesLedgerProduct.setProductId(product.getId());
                     BeanUtils.copyProperties(salesLedgerProductImportDto, salesLedgerProduct);
                     salesLedgerProduct.setSalesLedgerId(salesLedger.getId());
                     salesLedgerProduct.setType(2);
@@ -758,21 +782,25 @@
                     salesLedgerProduct.setApproveStatus(0);
                     salesLedgerProduct.setPendingTicketsTotal(salesLedgerProductImportDto.getTaxInclusiveTotalPrice());
                     // 鏄惁璐ㄦ鍒ゆ柇
+                    if (salesLedgerProductImportDto.getIsChecked() == null) {
+                        throw new RuntimeException("璇峰~鍐欐槸鍚﹁川妫�锛�");
+                    }
                     salesLedgerProduct.setIsChecked(salesLedgerProductImportDto.getIsChecked() == 1);
-                    if(salesLedgerProductImportDto.getIsChecked() == 1){
+                    if (salesLedgerProductImportDto.getIsChecked() == 1) {
                         addQualityInspect(salesLedger, salesLedgerProduct);
+                    } else {
+                        //鐩存帴鍏ュ簱
+                        stockUtils.addStock(salesLedgerProduct.getProductModelId(), salesLedgerProduct.getQuantity(), StockInQualifiedRecordTypeEnum.PURCHASE_STOCK_IN.getCode(),
+                                salesLedger.getId(), salesLedgerProduct.getBatchNo(), salesLedger.getSupplierName(), LocalDate.now());
                     }
                     salesLedgerProductMapper.insert(salesLedgerProduct);
                 }
-                // 閲囪喘瀹℃牳
-                addApproveByPurchase(loginUser,salesLedger);
             }
 
             return AjaxResult.success("瀵煎叆鎴愬姛");
         } catch (Exception e) {
-            e.printStackTrace();
+            throw new RuntimeException(e.getMessage());
         }
-        return AjaxResult.success("瀵煎叆澶辫触");
     }
 
     @Override
@@ -801,7 +829,7 @@
         return resultDto;
     }
 
-    public void addApproveByPurchase(LoginUser loginUser,PurchaseLedger purchaseLedger) throws Exception {
+    public void addApproveByPurchase(LoginUser loginUser, PurchaseLedger purchaseLedger) throws Exception {
         ApproveProcessVO approveProcessVO = new ApproveProcessVO();
         approveProcessVO.setApproveType(5);
         approveProcessVO.setApproveDeptId(loginUser.getCurrentDeptId());
diff --git a/src/main/java/com/ruoyi/quality/pojo/QualityInspect.java b/src/main/java/com/ruoyi/quality/pojo/QualityInspect.java
index 310643a..17d7893 100644
--- a/src/main/java/com/ruoyi/quality/pojo/QualityInspect.java
+++ b/src/main/java/com/ruoyi/quality/pojo/QualityInspect.java
@@ -214,7 +214,7 @@
     @TableField(exist = false)
     private String purchaseContractNo;
 
-    private String BatchNo;
+    private String batchNo;
     private String manufacturingTeam;
 
     /**
diff --git a/src/main/java/com/ruoyi/quality/pojo/QualityUnqualified.java b/src/main/java/com/ruoyi/quality/pojo/QualityUnqualified.java
index c039f69..43e2172 100644
--- a/src/main/java/com/ruoyi/quality/pojo/QualityUnqualified.java
+++ b/src/main/java/com/ruoyi/quality/pojo/QualityUnqualified.java
@@ -10,6 +10,7 @@
 import javax.validation.constraints.NotBlank;
 import java.io.Serializable;
 import java.math.BigDecimal;
+import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.util.Date;
 
@@ -144,4 +145,10 @@
     @ApiModelProperty("鏄惁涓嶅悎鏍煎鐞嗚嚜宸辨柊澧�")
     @TableField(exist = false)
     private Boolean method;
+
+    @ApiModelProperty("鐢熶骇鏃ユ湡")
+    private LocalDate productionDate;
+
+    @ApiModelProperty("鎵瑰彿")
+    private String batchNo;
 }
diff --git a/src/main/java/com/ruoyi/quality/service/impl/QualityInspectServiceImpl.java b/src/main/java/com/ruoyi/quality/service/impl/QualityInspectServiceImpl.java
index 52272ad..a128dd3 100644
--- a/src/main/java/com/ruoyi/quality/service/impl/QualityInspectServiceImpl.java
+++ b/src/main/java/com/ruoyi/quality/service/impl/QualityInspectServiceImpl.java
@@ -78,6 +78,9 @@
     public int add(QualityInspectDto qualityInspectDto) {
         QualityInspect qualityInspect = new QualityInspect();
         BeanUtils.copyProperties(qualityInspectDto, qualityInspect);
+        if (qualityInspectDto.getInspectType() != 0) {
+            qualityInspectDto.setCustomer("闀挎不甯傝酱鎵垮埗閫犳湁闄愬叕鍙�");
+        }
         qualityInspect.setInspectState(0);//榛樿鏈彁浜�
         qualityInspectMapper.insert(qualityInspect);
         for (QualityInspectParam qualityInspectParam : qualityInspectDto.getQualityInspectParams()) {
@@ -128,11 +131,13 @@
             String text = inspectParams.stream().map(QualityInspectParam::getParameterItem).collect(Collectors.joining(","));
             qualityUnqualified.setDefectivePhenomena(text + "杩欎簺鎸囨爣涓瓨鍦ㄤ笉鍚堟牸");//涓嶅悎鏍肩幇璞�
             qualityUnqualified.setInspectId(qualityInspect.getId());
+            qualityUnqualified.setProductionDate(inspect.getProductionDate());
+            qualityUnqualified.setBatchNo(inspect.getBatchNo());
             qualityUnqualifiedMapper.insert(qualityUnqualified);
         } else {
             //鍚堟牸鐩存帴鍏ュ簱
             stockUtils.addStock(qualityInspect.getProductModelId(), qualityInspect.getQuantity(), StockInQualifiedRecordTypeEnum.QUALITYINSPECT_STOCK_IN.getCode(),
-                    qualityInspect.getId(), batchNo, customer
+                    qualityInspect.getId(), batchNo, customer,inspect.getProductionDate()
             );
         }
         qualityInspect.setInspectState(1);//宸叉彁浜�
diff --git a/src/main/java/com/ruoyi/quality/service/impl/QualityUnqualifiedServiceImpl.java b/src/main/java/com/ruoyi/quality/service/impl/QualityUnqualifiedServiceImpl.java
index b8ac021..d24a1bf 100644
--- a/src/main/java/com/ruoyi/quality/service/impl/QualityUnqualifiedServiceImpl.java
+++ b/src/main/java/com/ruoyi/quality/service/impl/QualityUnqualifiedServiceImpl.java
@@ -137,7 +137,7 @@
                     //璋冪敤鎻愪氦鍚堟牸鐨勬帴鍙�
                     String customer = "闀挎不甯傝酱鎵垮埗閫犳湁闄愬叕鍙�";
                     stockUtils.addStock(qualityInspect.getProductModelId(), unqualified.getQuantity(), StockInQualifiedRecordTypeEnum.DEFECTIVE_PASS.getCode(), unqualified.getId(),
-                            orders.getBatchNo(), customer
+                            orders.getBatchNo(), customer,null
                     );
                     break;
                 case "杩斿伐":
@@ -155,7 +155,7 @@
                 case "璁╂鏀捐":
                     //璋冪敤鎻愪氦鍚堟牸鐨勬帴鍙�
                     String customer = "闀挎不甯傝酱鎵垮埗閫犳湁闄愬叕鍙�";
-                    stockUtils.addStock(modelId, unqualified.getQuantity(), StockInQualifiedRecordTypeEnum.DEFECTIVE_PASS.getCode(), unqualified.getId(), orders.getBatchNo(), customer);
+                    stockUtils.addStock(modelId, unqualified.getQuantity(), StockInQualifiedRecordTypeEnum.DEFECTIVE_PASS.getCode(), unqualified.getId(), orders.getBatchNo(), customer,null);
                     break;
                 default:
                     break;
@@ -182,6 +182,10 @@
             Map<String, Object> data = new HashMap<>();
             data.put("productName", info.getProductName());
             data.put("model", info.getModel());
+            data.put("batchNo", info.getBatchNo());
+            data.put("productionDate", info.getProductionDate());
+            data.put("defectivePhenomena", info.getDefectivePhenomena());
+            data.put("quantity", info.getQuantity());
 
             // 鍔犺浇妯℃澘
             inputStream = getClass().getResourceAsStream("/static/return-record.docx");
diff --git a/src/main/java/com/ruoyi/sales/controller/ShipmentApprovalController.java b/src/main/java/com/ruoyi/sales/controller/ShipmentApprovalController.java
index 65e3230..6851ea7 100644
--- a/src/main/java/com/ruoyi/sales/controller/ShipmentApprovalController.java
+++ b/src/main/java/com/ruoyi/sales/controller/ShipmentApprovalController.java
@@ -2,7 +2,6 @@
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.ruoyi.common.enums.StockOutQualifiedRecordTypeEnum;
 import com.ruoyi.common.exception.ServiceException;
 import com.ruoyi.common.utils.poi.ExcelUtil;
 import com.ruoyi.framework.web.controller.BaseController;
@@ -87,7 +86,7 @@
 
 
             //鍑哄簱
-            stockUtils.addStock(salesLedgerProduct.getProductModelId(), salesLedgerProduct.getQuantity(), StockOutQualifiedRecordTypeEnum.SALE_SHIP_STOCK_OUT.getCode(), req.getId(),null,null);
+//            stockUtils.addStock(salesLedgerProduct.getProductModelId(), salesLedgerProduct.getQuantity(), StockOutQualifiedRecordTypeEnum.SALE_SHIP_STOCK_OUT.getCode(), req.getId(),null,null);
         }
 
         return AjaxResult.success();
diff --git a/src/main/java/com/ruoyi/sales/controller/ShippingInfoController.java b/src/main/java/com/ruoyi/sales/controller/ShippingInfoController.java
index db3c5b9..b280d97 100644
--- a/src/main/java/com/ruoyi/sales/controller/ShippingInfoController.java
+++ b/src/main/java/com/ruoyi/sales/controller/ShippingInfoController.java
@@ -1,43 +1,28 @@
 package com.ruoyi.sales.controller;
 
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.ruoyi.approve.mapper.ApproveProcessMapper;
 import com.ruoyi.approve.service.impl.ApproveProcessServiceImpl;
-import com.ruoyi.approve.vo.ApproveProcessVO;
-import com.ruoyi.common.enums.FileNameType;
 import com.ruoyi.common.utils.OrderUtils;
-import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.common.utils.poi.ExcelUtil;
 import com.ruoyi.framework.aspectj.lang.annotation.Log;
 import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
-import com.ruoyi.framework.security.LoginUser;
 import com.ruoyi.framework.web.controller.BaseController;
 import com.ruoyi.framework.web.domain.AjaxResult;
-import com.ruoyi.other.service.impl.TempFileServiceImpl;
 import com.ruoyi.procurementrecord.utils.StockUtils;
 import com.ruoyi.sales.dto.ShippingInfoDto;
-import com.ruoyi.sales.mapper.ShipmentApprovalMapper;
 import com.ruoyi.sales.mapper.ShippingInfoMapper;
-import com.ruoyi.sales.pojo.SalesLedger;
-import com.ruoyi.sales.pojo.SalesLedgerProduct;
-import com.ruoyi.sales.pojo.ShipmentApproval;
 import com.ruoyi.sales.pojo.ShippingInfo;
-import com.ruoyi.sales.service.ISalesLedgerProductService;
-import com.ruoyi.sales.service.ISalesLedgerService;
 import com.ruoyi.sales.service.ShippingInfoService;
 import com.ruoyi.sales.service.impl.CommonFileServiceImpl;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
-import org.apache.commons.collections4.CollectionUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
-import java.time.LocalDate;
 import java.util.List;
 
 /**
@@ -73,20 +58,10 @@
     @Transactional(rollbackFor = Exception.class)
     @Log(title = "鍙戣揣淇℃伅绠$悊", businessType = BusinessType.INSERT)
     public AjaxResult add(@RequestBody ShippingInfoDto req) throws Exception {
-        LoginUser loginUser = SecurityUtils.getLoginUser();
         String sh = OrderUtils.countTodayByCreateTime(shippingInfoMapper, "SH");
-        // 鍙戣揣瀹℃壒
-        ApproveProcessVO approveProcessVO = new ApproveProcessVO();
-        approveProcessVO.setApproveType(7);
-        approveProcessVO.setApproveDeptId(loginUser.getCurrentDeptId());
-        approveProcessVO.setApproveReason(req.getType() + ":" +sh);
-        approveProcessVO.setApproveUserIds(req.getApproveUserIds());
-        approveProcessVO.setApproveUser(loginUser.getUserId());
-        approveProcessVO.setApproveTime(LocalDate.now().toString());
-        approveProcessService.addApprove(approveProcessVO);
         // 娣诲姞鍙戣揣娑堟伅
         req.setShippingNo(sh);
-        req.setStatus("寰呭鏍�");
+        req.setStatus("寰呭彂璐�");
         boolean save = shippingInfoService.save(req);
         return save ? AjaxResult.success() : AjaxResult.error();
     }
diff --git a/src/main/java/com/ruoyi/sales/dto/SalesLedgerProductImportDto.java b/src/main/java/com/ruoyi/sales/dto/SalesLedgerProductImportDto.java
index 2c95909..c9d71d7 100644
--- a/src/main/java/com/ruoyi/sales/dto/SalesLedgerProductImportDto.java
+++ b/src/main/java/com/ruoyi/sales/dto/SalesLedgerProductImportDto.java
@@ -1,12 +1,9 @@
 package com.ruoyi.sales.dto;
 
-import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.annotation.TableId;
 import com.ruoyi.framework.aspectj.lang.annotation.Excel;
 import lombok.Data;
 
 import java.math.BigDecimal;
-import java.util.Date;
 
 /**
  * @author :yys
@@ -32,6 +29,18 @@
     private String specificationModel;
 
     /**
+     * 鎵瑰彿
+     */
+    @Excel(name = "鎵瑰彿")
+    private String batchNo;
+
+    /**
+     * UID鐮�
+     */
+    @Excel(name = "UID鐮�")
+    private String uniNo;
+
+    /**
      * 鍗曚綅
      */
     @Excel(name = "鍗曚綅")
diff --git a/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerProductServiceImpl.java b/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerProductServiceImpl.java
index b0e8b50..90b74f7 100644
--- a/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerProductServiceImpl.java
+++ b/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerProductServiceImpl.java
@@ -285,7 +285,7 @@
         List<ProcessRoute> processRoutes = processRouteMapper.selectList(new QueryWrapper<ProcessRoute>().lambda()
                 .eq(ProcessRoute::getProductModelId, salesLedgerProduct.getProductModelId())
                 .orderByDesc(ProcessRoute::getCreateTime));
-        if (processRoutes.size()>0){
+        if (!processRoutes.isEmpty()){
             ProcessRoute processRoute = processRoutes.get(0);
             //鏂板鐢熶骇璁㈠崟宸ヨ壓璺嚎涓昏〃
             ProductProcessRoute productProcessRoute = new ProductProcessRoute();
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 bd71f54..78c7daa 100644
--- a/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java
+++ b/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java
@@ -31,10 +31,6 @@
 import com.ruoyi.other.mapper.TempFileMapper;
 import com.ruoyi.other.pojo.TempFile;
 import com.ruoyi.production.mapper.*;
-import com.ruoyi.production.pojo.ProductOrder;
-import com.ruoyi.production.pojo.ProductProcessRouteItem;
-import com.ruoyi.production.pojo.ProductWorkOrder;
-import com.ruoyi.production.pojo.ProductionProductMain;
 import com.ruoyi.production.service.ProductionProductMainService;
 import com.ruoyi.project.system.domain.SysDept;
 import com.ruoyi.project.system.domain.SysUser;
@@ -45,6 +41,8 @@
 import com.ruoyi.sales.mapper.*;
 import com.ruoyi.sales.pojo.*;
 import com.ruoyi.sales.service.ISalesLedgerService;
+import com.ruoyi.stock.mapper.StockInventoryMapper;
+import com.ruoyi.stock.pojo.StockInventory;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.io.FilenameUtils;
@@ -140,6 +138,8 @@
 
     private final QualityInspectMapper qualityInspectMapper;
 
+    private final StockInventoryMapper stockInventoryMapper;
+
     @Autowired
     private SysDeptMapper sysDeptMapper;
 
@@ -168,7 +168,7 @@
     }
 
 
-    public List<SalesLedgerProduct> getSalesLedgerProductListByRelateId(Long relateId, SaleEnum type){
+    public List<SalesLedgerProduct> getSalesLedgerProductListByRelateId(Long relateId, SaleEnum type) {
         LambdaQueryWrapper<SalesLedgerProduct> productWrapper = new LambdaQueryWrapper<>();
         productWrapper.eq(SalesLedgerProduct::getSalesLedgerId, relateId);
         productWrapper.eq(SalesLedgerProduct::getType, type.getCode());
@@ -429,6 +429,10 @@
 
                 for (SalesLedgerProductImportDto salesLedgerProductImportDto : salesLedgerProductImportDtos) {
                     SalesLedgerProduct salesLedgerProduct = new SalesLedgerProduct();
+                    List<StockInventory> stockInventories = stockInventoryMapper.selectList(new LambdaQueryWrapper<StockInventory>().in(StockInventory::getBatchNo, salesLedgerProductImportDto.getBatchNo()));
+                    if (CollectionUtils.isEmpty(stockInventories)) {
+                        throw new RuntimeException("浜у搧鎵瑰彿:" + salesLedgerProductImportDto.getBatchNo() + ",搴撳瓨鏃犲搴斾骇鍝佹暟鎹紒");
+                    }
                     BeanUtils.copyProperties(salesLedgerProductImportDto, salesLedgerProduct);
                     salesLedgerProduct.setSalesLedgerId(salesLedger.getId());
                     salesLedgerProduct.setType(1);
@@ -458,16 +462,13 @@
                     salesLedgerProduct.setApproveStatus(0);
                     salesLedgerProduct.setPendingInvoiceTotal(salesLedgerProductImportDto.getTaxInclusiveTotalPrice());
                     salesLedgerProductMapper.insert(salesLedgerProduct);
-                    // 娣诲姞鐢熶骇鏁版嵁
-                    salesLedgerProductServiceImpl.addProductionData(salesLedgerProduct);
                 }
             }
 
             return AjaxResult.success("瀵煎叆鎴愬姛");
         } catch (Exception e) {
-            e.printStackTrace();
+            throw new RuntimeException(e.getMessage());
         }
-        return AjaxResult.success("瀵煎叆澶辫触");
     }
 
     @Override
@@ -663,7 +664,7 @@
             // 4. 澶勭悊瀛愯〃鏁版嵁
             List<SalesLedgerProduct> productList = salesLedgerDto.getProductData();
             if (productList != null && !productList.isEmpty()) {
-                handleSalesLedgerProducts(salesLedger.getId(), productList, EnumUtil.fromCode(SaleEnum.class,salesLedgerDto.getType()));
+                handleSalesLedgerProducts(salesLedger.getId(), productList, EnumUtil.fromCode(SaleEnum.class, salesLedgerDto.getType()));
                 updateMainContractAmount(
                         salesLedger.getId(),
                         productList,
@@ -928,32 +929,20 @@
                 map.put("filingCertificateNo", productModel.getFilingCertificateNo());
             }
             amount = amount.add(product.getTaxInclusiveTotalPrice());
-            List<ProductOrder> productOrders = productOrderMapper.selectList(new LambdaQueryWrapper<ProductOrder>()
-                    .eq(ProductOrder::getBatchNo, product.getBatchNo()));
-            if (CollectionUtils.isEmpty(productOrders)) {
+            List<StockInventory> stockInventoryList = stockInventoryMapper.selectList(new LambdaQueryWrapper<StockInventory>().eq(StockInventory::getProductModelId, product.getProductModelId())
+                    .eq(StockInventory::getBatchNo, product.getBatchNo())
+                    .eq(StockInventory::getCustomer, product.getCustomer()));
+            if (CollectionUtils.isEmpty(stockInventoryList)) {
                 throw new RuntimeException("鎵瑰彿涓嶅瓨鍦�");
             }
-            List<ProductWorkOrder> productWorkOrders = productWorkOrderMapper.selectList(new LambdaQueryWrapper<ProductWorkOrder>()
-                    .eq(ProductWorkOrder::getProductOrderId, productOrders.get(0).getId()));
-            List<Long> ids = productWorkOrders.stream().map(ProductWorkOrder::getId).collect(Collectors.toList());
-            List<ProductionProductMain> productionProductMains = productionProductMainMapper.selectList(new LambdaQueryWrapper<ProductionProductMain>()
-                    .in(ProductionProductMain::getWorkOrderId, ids)
-                    .orderByDesc(ProductionProductMain::getCreateTime));
-            List<ProductProcessRouteItem> productProcessRouteItems = productProcessRouteItemMapper.selectList(new LambdaQueryWrapper<ProductProcessRouteItem>()
-                    .in(ProductProcessRouteItem::getId, productionProductMains.stream()
-                            .map(ProductionProductMain::getProductProcessRouteItemId).collect(Collectors.toList()))
-                    .eq(ProductProcessRouteItem::getProductModelId, product.getProductModelId())
-                    .orderByDesc(ProductProcessRouteItem::getCreateTime));
-            if (CollectionUtils.isEmpty(productProcessRouteItems)) {
-                throw new RuntimeException("鐢熶骇鏁版嵁涓嶅瓨鍦�");
-            }
-            String productionDate = productProcessRouteItems.get(0).getCreateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
-            if (productModel.getValidityPeriod() == null) {
-                throw new RuntimeException("鏈夋晥鏈熶笉鑳戒负绌�");
-            }
-            String expiryDate = productProcessRouteItems.get(0).getCreateTime().plusYears(productModel.getValidityPeriod().longValue()).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
+            String productionDate = stockInventoryList.get(0).getProductionDate().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
             map.put("productionDate", productionDate);
-            map.put("expiryDate", expiryDate);
+            List<ProductModel> productModelList = productModelMapper.selectList(new LambdaQueryWrapper<ProductModel>().eq(ProductModel::getId, product.getProductModelId()));
+            BigDecimal validityPeriod = productModelList.get(0).getValidityPeriod();
+            LocalDate expiryDate = stockInventoryList.get(0).getProductionDate()
+                    .plusYears(validityPeriod.longValue());
+            String expiryDateStr = expiryDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
+            map.put("expiryDate", expiryDateStr);
             products.add(map);
         }
         Map<String, Object> data = new HashMap<>();
@@ -993,6 +982,5 @@
             e.printStackTrace();
             throw new RuntimeException("瀵煎嚭澶辫触");
         }
-
     }
 }
diff --git a/src/main/java/com/ruoyi/sales/service/impl/SalesQuotationServiceImpl.java b/src/main/java/com/ruoyi/sales/service/impl/SalesQuotationServiceImpl.java
index 8e18058..b5d0fe8 100644
--- a/src/main/java/com/ruoyi/sales/service/impl/SalesQuotationServiceImpl.java
+++ b/src/main/java/com/ruoyi/sales/service/impl/SalesQuotationServiceImpl.java
@@ -4,18 +4,13 @@
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-
 import com.ruoyi.approve.pojo.ApproveProcess;
-import com.ruoyi.approve.service.IApproveProcessService;
 import com.ruoyi.approve.service.impl.ApproveProcessServiceImpl;
 import com.ruoyi.approve.vo.ApproveGetAndUpdateVo;
-import com.ruoyi.approve.vo.ApproveProcessVO;
 import com.ruoyi.common.utils.OrderUtils;
-import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.common.utils.bean.BeanUtils;
-import com.ruoyi.common.utils.uuid.UUID;
-import com.ruoyi.framework.security.LoginUser;
 import com.ruoyi.sales.dto.SalesQuotationDto;
 import com.ruoyi.sales.mapper.SalesQuotationMapper;
 import com.ruoyi.sales.mapper.SalesQuotationProductMapper;
@@ -24,11 +19,9 @@
 import com.ruoyi.sales.service.SalesQuotationProductService;
 import com.ruoyi.sales.service.SalesQuotationService;
 import org.springframework.beans.factory.annotation.Autowired;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
-import java.time.LocalDate;
 import java.util.Collections;
 import java.util.List;
 import java.util.stream.Collectors;
@@ -60,7 +53,6 @@
 
     @Override
     public boolean add(SalesQuotationDto salesQuotationDto) {
-        LoginUser loginUser = SecurityUtils.getLoginUser();
         SalesQuotation salesQuotation = new SalesQuotation();
         BeanUtils.copyProperties(salesQuotationDto, salesQuotation);
         String quotationNo = OrderUtils.countTodayByCreateTime(salesQuotationMapper, "QT");
@@ -77,21 +69,6 @@
             return salesQuotationProduct;
         }).collect(Collectors.toList());
         salesQuotationProductService.saveBatch(products);
-        // 鎶ヤ环瀹℃壒
-        ApproveProcessVO approveProcessVO = new ApproveProcessVO();
-        approveProcessVO.setApproveType(6);
-        approveProcessVO.setApproveDeptId(loginUser.getCurrentDeptId());
-        approveProcessVO.setApproveReason(quotationNo);
-        approveProcessVO.setApproveUserIds(salesQuotationDto.getApproveUserIds());
-        approveProcessVO.setApproveUser(loginUser.getUserId());
-        approveProcessVO.setApproveTime(LocalDate.now().toString());
-        approveProcessVO.setPrice(salesQuotationDto.getTotalAmount());
-        try {
-            approveProcessService.addApprove(approveProcessVO);
-        }catch (Exception e){
-            log.error("SalesQuotationServiceImpl error:{}", e);
-            throw new RuntimeException("瀹℃壒澶辫触");
-        }
         return true;
     }
     @Override
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 625e765..93be0df 100644
--- a/src/main/java/com/ruoyi/sales/service/impl/ShippingInfoServiceImpl.java
+++ b/src/main/java/com/ruoyi/sales/service/impl/ShippingInfoServiceImpl.java
@@ -68,7 +68,7 @@
         if(!"宸插彂璐�".equals(byId.getStatus())){
             SalesLedgerProduct salesLedgerProduct = salesLedgerProductMapper.selectById(byId.getSalesLedgerProductId());
             stockUtils.substractStock(salesLedgerProduct.getProductModelId(), salesLedgerProduct.getQuantity(),
-                    StockOutQualifiedRecordTypeEnum.SALE_SHIP_STOCK_OUT.getCode(), req.getId(),null,null
+                    StockOutQualifiedRecordTypeEnum.SALE_SHIP_STOCK_OUT.getCode(), req.getId(),salesLedgerProduct.getBatchNo(),salesLedgerProduct.getCustomer()
             );
         }
         byId.setExpressNumber(req.getExpressNumber());
diff --git a/src/main/java/com/ruoyi/stock/dto/StockInventoryDto.java b/src/main/java/com/ruoyi/stock/dto/StockInventoryDto.java
index f28c0eb..183f4d5 100644
--- a/src/main/java/com/ruoyi/stock/dto/StockInventoryDto.java
+++ b/src/main/java/com/ruoyi/stock/dto/StockInventoryDto.java
@@ -45,4 +45,5 @@
     private Long productId;      // 浜у搧ID
     private Long parentId;  // 鐖剁骇浜у搧ID
     private Long productModelId;   // 浜у搧鍨嬪彿ID
+    private String productScope;  //浜у搧绫诲瀷
 }
diff --git a/src/main/java/com/ruoyi/stock/execl/StockInventoryExportData.java b/src/main/java/com/ruoyi/stock/execl/StockInventoryExportData.java
index 4b7553f..88a129c 100644
--- a/src/main/java/com/ruoyi/stock/execl/StockInventoryExportData.java
+++ b/src/main/java/com/ruoyi/stock/execl/StockInventoryExportData.java
@@ -1,5 +1,6 @@
 package com.ruoyi.stock.execl;
 
+import com.fasterxml.jackson.annotation.JsonFormat;
 import com.ruoyi.framework.aspectj.lang.annotation.Excel;
 import lombok.Data;
 
@@ -16,6 +17,19 @@
     @Excel(name = "瑙勬牸")
     private String model;
 
+    @Excel(name = "UID鐮�")
+    private String uidNo;
+
+    @Excel(name = "鎵瑰彿")
+    private String batchNo;
+
+    @Excel(name = "鐢熶骇鏃ユ湡")
+    @JsonFormat(pattern = "yyyyMMdd")
+    private String productionDate;
+
+    @Excel(name = "渚涘簲鍟�")
+    private String customer;
+
     @Excel(name = "鍗曚綅")
     private String unit;
 
diff --git a/src/main/java/com/ruoyi/stock/pojo/StockInventory.java b/src/main/java/com/ruoyi/stock/pojo/StockInventory.java
index c0b379f..99f40ea 100644
--- a/src/main/java/com/ruoyi/stock/pojo/StockInventory.java
+++ b/src/main/java/com/ruoyi/stock/pojo/StockInventory.java
@@ -13,6 +13,7 @@
 import javax.validation.constraints.NotBlank;
 import java.io.Serializable;
 import java.math.BigDecimal;
+import java.time.LocalDate;
 import java.time.LocalDateTime;
 
 /**
@@ -69,4 +70,8 @@
 
     @ApiModelProperty("渚涘簲鍟嗗悕绉�")
     private String customer;
+
+    @ApiModelProperty("鐢熶骇鏃ユ湡")
+    private LocalDate productionDate;
+
 }
diff --git a/src/main/java/com/ruoyi/stock/service/impl/StockInventoryServiceImpl.java b/src/main/java/com/ruoyi/stock/service/impl/StockInventoryServiceImpl.java
index 97354b1..db3e2b3 100644
--- a/src/main/java/com/ruoyi/stock/service/impl/StockInventoryServiceImpl.java
+++ b/src/main/java/com/ruoyi/stock/service/impl/StockInventoryServiceImpl.java
@@ -34,6 +34,8 @@
 
 import javax.servlet.http.HttpServletResponse;
 import java.math.BigDecimal;
+import java.time.LocalDate;
+import java.time.format.DateTimeFormatter;
 import java.util.*;
 
 /**
@@ -59,6 +61,7 @@
     private ProductMapper productMapper;
     @Autowired
     private ProductModelMapper productModelMapper;
+    private static final DateTimeFormatter YYYYMMDD_FORMAT = DateTimeFormatter.ofPattern("yyyyMMdd");
 
 
     @Override
@@ -99,6 +102,7 @@
             newStockInventory.setWarnNum(stockInventoryDto.getWarnNum());
             newStockInventory.setBatchNo(stockInventoryDto.getBatchNo());
             newStockInventory.setCustomer(stockInventoryDto.getCustomer());
+            newStockInventory.setProductionDate(stockInventoryDto.getProductionDate());
             stockInventoryMapper.insert(newStockInventory);
         }else {
              stockInventoryMapper.updateAddStockInventory(stockInventoryDto);
@@ -148,7 +152,7 @@
             // 鏌ヨ鎵�鏈夌殑浜у搧
             List<SalesLedgerProduct> salesLedgerProducts = salesLedgerProductMapper.selectProduct();
 
-            ExcelUtil<StockInventoryExportData> util = new ExcelUtil<StockInventoryExportData>(StockInventoryExportData.class);
+            ExcelUtil<StockInventoryExportData> util = new ExcelUtil<>(StockInventoryExportData.class);
             List<StockInventoryExportData> list = util.importExcel(file.getInputStream());
 
             // 璁板綍鏈壘鍒板尮閰嶉」鐨勬暟鎹�
@@ -158,7 +162,8 @@
                 boolean matched = false;
                 for (SalesLedgerProduct item : salesLedgerProducts) {
                     if (item.getProductCategory().equals(dto.getProductName()) &&
-                            item.getSpecificationModel().equals(dto.getModel())) {
+                            item.getSpecificationModel().equals(dto.getModel()) &&
+                            item.getUidNo().equals(dto.getUidNo())) {
                         StockInventoryDto stockInventoryDto = new StockInventoryDto();
                         stockInventoryDto.setRecordId(0L);
                         stockInventoryDto.setRecordType(StockInQualifiedRecordTypeEnum.CUSTOMIZATION_STOCK_IN.getCode());
@@ -170,6 +175,14 @@
                         }
                         stockInventoryDto.setLockedQuantity(dto.getLockedQuantity());
                         stockInventoryDto.setProductModelId(item.getProductModelId());
+                        stockInventoryDto.setBatchNo(dto.getBatchNo());
+                        stockInventoryDto.setCustomer(dto.getCustomer());
+                        String productionDate = dto.getProductionDate();
+                        if (productionDate != null && productionDate.length() == 8) {
+                            stockInventoryDto.setProductionDate(LocalDate.parse(productionDate, YYYYMMDD_FORMAT));
+                        } else {
+                            stockInventoryDto.setProductionDate(null);
+                        }
                         this.addstockInventory(stockInventoryDto);
                         matched = true;
                         break; // 鎵惧埌鍖归厤椤瑰悗璺冲嚭寰幆
@@ -177,8 +190,8 @@
                 }
                 if (!matched) {
                     // 璁板綍鏈尮閰嶇殑鏁版嵁
-                    String unmatchedInfo = String.format("浜у搧鍚嶇О锛�%s锛岃鏍煎瀷鍙凤細%s",
-                            dto.getProductName(), dto.getModel());
+                    String unmatchedInfo = String.format("浜у搧鍚嶇О锛�%s锛岃鏍煎瀷鍙凤細%s锛孶ID鐮侊細%s",
+                            dto.getProductName(), dto.getModel(),dto.getUidNo());
                     unmatchedRecords.add(unmatchedInfo);
                 }
             });
diff --git a/src/main/resources/mapper/purchase/PaymentRegistrationMapper.xml b/src/main/resources/mapper/purchase/PaymentRegistrationMapper.xml
index 1446ab6..613f8ff 100644
--- a/src/main/resources/mapper/purchase/PaymentRegistrationMapper.xml
+++ b/src/main/resources/mapper/purchase/PaymentRegistrationMapper.xml
@@ -206,7 +206,7 @@
         T1.supplier_name,
         SUM(contract_amount) AS invoiceAmount,
         IFNULL( SUM(T2.current_payment_amount) , 0 ) AS paymentAmount,
-        IFNULL((IFNULL(SUM(contract_amount),0)  - IFNULL(SUM(T2.current_payment_amount),0)),0) AS payableAmount,
+        IFNULL((IFNULL(SUM(contract_amount),0) - IFNULL(SUM(T2.current_payment_amount),0)),0) AS payableAmount,
         T1.purchase_contract_number,
         T2.payment_date
         FROM purchase_ledger T1
@@ -217,7 +217,11 @@
                 T1.supplier_name LIKE CONCAT ('%',#{req.supplierName},'%')
             </if>
         </where>
-        GROUP BY  T1.purchase_contract_number,T2.payment_date
+        GROUP BY
+        T1.supplier_id,
+        T1.supplier_name,
+        T1.purchase_contract_number,
+        T2.payment_date
     </select>
 
 </mapper>
\ No newline at end of file
diff --git a/src/main/resources/mapper/quality/QualityUnqualifiedMapper.xml b/src/main/resources/mapper/quality/QualityUnqualifiedMapper.xml
index be7c7d1..d7fdb89 100644
--- a/src/main/resources/mapper/quality/QualityUnqualifiedMapper.xml
+++ b/src/main/resources/mapper/quality/QualityUnqualifiedMapper.xml
@@ -16,6 +16,7 @@
         qu.deal_result,
         qu.deal_name,
         qu.deal_time,
+        qu.production_date,
         pm.uid_no,
         CASE
         WHEN qu.model = pm.id THEN pm.model
@@ -78,6 +79,8 @@
             qu.deal_result,
             qu.deal_name,
             qu.deal_time,
+            qu.production_date,
+            qu.batch_no,
             CASE
                 WHEN qu.model = pm.id THEN pm.model
                 ELSE qu.model
diff --git a/src/main/resources/mapper/sales/InvoiceLedgerMapper.xml b/src/main/resources/mapper/sales/InvoiceLedgerMapper.xml
index 2874f48..3a03588 100644
--- a/src/main/resources/mapper/sales/InvoiceLedgerMapper.xml
+++ b/src/main/resources/mapper/sales/InvoiceLedgerMapper.xml
@@ -115,7 +115,7 @@
             T1.customer_name,
             SUM(contract_amount) AS invoice_total,
             IFNULL( SUM(T2.receipt_payment_amount) , 0 ) AS receipt_payment_amount,
-            IFNULL((IFNULL(SUM(contract_amount),0)  - IFNULL(SUM(T2.receipt_payment_amount),0)),0) AS unReceipt_payment_amount
+            IFNULL((IFNULL(SUM(contract_amount),0) - IFNULL(SUM(T2.receipt_payment_amount),0)),0) AS unReceipt_payment_amount
         FROM sales_ledger T1
         LEFT JOIN receipt_payment T2 ON T1.id = T2.sales_ledger_id
         <where>
@@ -123,7 +123,7 @@
                 T1.customer_name LIKE CONCAT ('%',#{invoiceLedgerDto.searchText},'%')
             </if>
         </where>
-        GROUP BY T1.customer_name
+        GROUP BY T1.customer_id, T1.customer_name
     </select>
 
     <select id="invoiceLedgerProductInfo" resultType="com.ruoyi.sales.dto.InvoiceRegistrationProductDto">
diff --git a/src/main/resources/mapper/sales/SalesLedgerProductMapper.xml b/src/main/resources/mapper/sales/SalesLedgerProductMapper.xml
index 73026c8..711c961 100644
--- a/src/main/resources/mapper/sales/SalesLedgerProductMapper.xml
+++ b/src/main/resources/mapper/sales/SalesLedgerProductMapper.xml
@@ -5,15 +5,22 @@
 <mapper namespace="com.ruoyi.sales.mapper.SalesLedgerProductMapper">
 
     <select id="selectSalesLedgerProductList" resultType="com.ruoyi.sales.pojo.SalesLedgerProduct">
+        WITH stock_summary AS (
+        SELECT
+        product_model_id,
+        SUM(qualitity) AS total_quantity,
+        SUM(locked_quantity) AS total_locked
+        FROM stock_inventory
+        GROUP BY product_model_id
+        )
         SELECT
         T1.*,
         CASE
-        WHEN (IFNULL(t2.qualitity, 0) - IFNULL(t2.locked_quantity, 0)) >= IFNULL(T1.quantity, 0) THEN 1
+        WHEN (IFNULL(s.total_quantity, 0) - IFNULL(s.total_locked, 0)) >= IFNULL(T1.quantity, 0) THEN 1
         ELSE 0
         END as has_sufficient_stock
-        FROM
-        sales_ledger_product T1
-        LEFT JOIN stock_inventory t2 ON T1.product_model_id = t2.product_model_id
+        FROM sales_ledger_product T1
+        LEFT JOIN stock_summary s ON T1.product_model_id = s.product_model_id
         <where>
             <if test="salesLedgerProduct.salesLedgerId != null">
                 AND T1.sales_ledger_id = #{salesLedgerProduct.salesLedgerId}
@@ -127,8 +134,10 @@
         <if test="req.productCategory != null and req.productCategory != ''">
             AND slp.product_category = #{req.productCategory}
         </if>
-        <!-- 鎸変骇鍝佸ぇ绫诲垎缁勮仛鍚� -->
-        GROUP BY slp.product_category
+        GROUP BY
+        slp.product_category,
+        slp.specification_model,
+        sl.supplier_name
         <!-- 鎸変骇鍝佸ぇ绫绘帓搴� -->
         ORDER BY slp.product_category
     </select>
diff --git a/src/main/resources/mapper/sales/SalesQuotationMapper.xml b/src/main/resources/mapper/sales/SalesQuotationMapper.xml
index 1e358ca..d4de9dd 100644
--- a/src/main/resources/mapper/sales/SalesQuotationMapper.xml
+++ b/src/main/resources/mapper/sales/SalesQuotationMapper.xml
@@ -15,8 +15,5 @@
         <if test="salesQuotationDto.customer != null and salesQuotationDto.customer != '' ">
             AND t1.customer = #{salesQuotationDto.customer}
         </if>
-        <if test="salesQuotationDto.status != null and salesQuotationDto.status != '' ">
-            AND t1.status = #{salesQuotationDto.status}
-        </if>
     </select>
 </mapper>
\ No newline at end of file
diff --git a/src/main/resources/mapper/stock/StockInventoryMapper.xml b/src/main/resources/mapper/stock/StockInventoryMapper.xml
index 21bc11e..f373f79 100644
--- a/src/main/resources/mapper/stock/StockInventoryMapper.xml
+++ b/src/main/resources/mapper/stock/StockInventoryMapper.xml
@@ -52,34 +52,79 @@
         where product_model_id = #{ew.productModelId} and qualitity >= #{ew.qualitity}
     </update>
     <select id="pagestockInventory" resultType="com.ruoyi.stock.dto.StockInventoryDto">
-        select si.id,
+        WITH RECURSIVE get_root AS (
+        SELECT
+        id,
+        parent_id,
+        id AS root_id
+        FROM product
+        WHERE parent_id IS NULL  -- 鏍硅妭鐐�
+        UNION ALL
+        SELECT
+        p.id,
+        p.parent_id,
+        gr.root_id
+        FROM product p
+        INNER JOIN get_root gr ON p.parent_id = gr.id
+        )
+        SELECT
+        si.id,
         si.qualitity,
-        COALESCE(si.locked_quantity, 0) as locked_quantity,
+        COALESCE(si.locked_quantity, 0) AS locked_quantity,
         si.product_model_id,
         si.create_time,
         si.update_time,
-        COALESCE(si.warn_num, 0) as warn_num,
+        COALESCE(si.warn_num, 0) AS warn_num,
         si.version,
-        (si.qualitity - COALESCE(si.locked_quantity, 0)) as un_locked_quantity,
+        (si.qualitity - COALESCE(si.locked_quantity, 0)) AS un_locked_quantity,
         pm.model,
         si.remark,
         pm.unit,
-        pm.uid_no as uidNo,
+        pm.uid_no AS uidNo,
         p.product_name,
         si.batch_no,
-        si.customer
-        from stock_inventory si
-        left join product_model pm on si.product_model_id = pm.id
-        left join product p on pm.product_id = p.id
-        where 1 = 1
-        <if test="ew.productName != null and ew.productName !=''">
-            and p.product_name like concat('%',#{ew.productName},'%')
-        </if>
+        si.customer,
+        rp.product_name AS root_product_name,
+        si.production_date
+        FROM
+        stock_inventory si
+        LEFT JOIN product_model pm ON si.product_model_id = pm.id
+        LEFT JOIN product p ON pm.product_id = p.id
+        LEFT JOIN get_root gr ON gr.id = p.id
+        LEFT JOIN product rp ON rp.id = gr.root_id
+        <where>
+            <if test="ew.productName != null and ew.productName != ''">
+                AND p.product_name LIKE CONCAT('%', #{ew.productName}, '%')
+            </if>
+            <if test="ew.model != null and ew.model != ''">
+                AND pm.model LIKE CONCAT('%', #{ew.model}, '%')
+            </if>
+            <if test="ew.uidNo != null and ew.uidNo != ''">
+                AND pm.uid_no LIKE CONCAT('%', #{ew.uidNo}, '%')
+            </if>
+            <if test="ew.batchNo != null and ew.batchNo != ''">
+                AND si.batch_no LIKE CONCAT('%', #{ew.batchNo}, '%')
+            </if>
+            <if test="ew.productScope != null and ew.productScope != ''">
+                <choose>
+                    <when test="ew.productScope == '鎴愬搧'">
+                        AND rp.product_name = '鎴愬搧'
+                    </when>
+                    <otherwise>
+                        AND rp.product_name != '鎴愬搧'
+                    </otherwise>
+                </choose>
+            </if>
+        </where>
     </select>
     <select id="listStockInventoryExportData" resultType="com.ruoyi.stock.execl.StockInventoryExportData">
         select si.qualitity,
         pm.model,
         pm.unit,
+        si.batchNo,
+        pm.uid_no,
+        si.production_date,
+        si.customer,
         p.product_name,
         coalesce(si.warn_num, 0) as warn_num,
         coalesce(si.locked_quantity, 0) as locked_quantity,
@@ -283,14 +328,14 @@
         LEFT JOIN product_model pm ON si.product_model_id = pm.id
         LEFT JOIN product p ON pm.product_id = p.id
         LEFT JOIN product p1 ON p1.id = p.parent_id
-        WHERE
-            p1.product_name = '鍘熸潗鏂�';
-        <if test="ew.batchNo != null and ew.batchNo !=''">
-            and si.batch_no like concat('%',#{ew.batchNo},'%')
-        </if>
-        <if test="ew.customer != null and ew.customer !=''">
-            and si.customer like concat('%',#{ew.customer},'%')
-        </if>
+        <where>
+            <if test="ew.batchNo != null and ew.batchNo !=''">
+                and si.batch_no like concat('%',#{ew.batchNo},'%')
+            </if>
+            <if test="ew.customer != null and ew.customer !=''">
+                and si.customer like concat('%',#{ew.customer},'%')
+            </if>
+        </where>
     </select>
 
     <select id="getStockInventoryAll" resultType="com.ruoyi.stock.dto.StockInventoryDto">
diff --git a/src/main/resources/static/return-record.docx b/src/main/resources/static/return-record.docx
index f6ff374..8834356 100644
--- a/src/main/resources/static/return-record.docx
+++ b/src/main/resources/static/return-record.docx
Binary files differ
diff --git "a/src/main/resources/static/\351\207\207\350\264\255\345\217\260\350\264\246\345\257\274\345\205\245\346\250\241\346\235\277.xlsx" "b/src/main/resources/static/\351\207\207\350\264\255\345\217\260\350\264\246\345\257\274\345\205\245\346\250\241\346\235\277.xlsx"
index 7c08b61..cfeb0c4 100644
--- "a/src/main/resources/static/\351\207\207\350\264\255\345\217\260\350\264\246\345\257\274\345\205\245\346\250\241\346\235\277.xlsx"
+++ "b/src/main/resources/static/\351\207\207\350\264\255\345\217\260\350\264\246\345\257\274\345\205\245\346\250\241\346\235\277.xlsx"
Binary files differ
diff --git "a/src/main/resources/static/\351\224\200\345\224\256\345\217\260\350\264\246\345\257\274\345\205\245\346\250\241\346\235\277.xlsx" "b/src/main/resources/static/\351\224\200\345\224\256\345\217\260\350\264\246\345\257\274\345\205\245\346\250\241\346\235\277.xlsx"
index 9558711..ecb0c1a 100644
--- "a/src/main/resources/static/\351\224\200\345\224\256\345\217\260\350\264\246\345\257\274\345\205\245\346\250\241\346\235\277.xlsx"
+++ "b/src/main/resources/static/\351\224\200\345\224\256\345\217\260\350\264\246\345\257\274\345\205\245\346\250\241\346\235\277.xlsx"
Binary files differ

--
Gitblit v1.9.3