2026-06-08 29ccd9919082e0157f57989ae83b303f314bad6b
src/main/java/com/ruoyi/stock/service/impl/StockInventoryServiceImpl.java
@@ -14,6 +14,7 @@
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.domain.R;
import com.ruoyi.project.system.service.ISysDictDataService;
import com.ruoyi.sales.mapper.SalesLedgerProductMapper;
import com.ruoyi.sales.pojo.SalesLedgerProduct;
import com.ruoyi.stock.dto.StockInRecordDto;
@@ -60,6 +61,7 @@
    private final StockUninventoryService stockUninventoryService;
    private final SalesLedgerProductMapper salesLedgerProductMapper;
    private final ProductModelMapper productModelMapper;
    private final ISysDictDataService sysDictDataService;
    @Override
    public IPage<StockInventoryDto> pagestockInventory(Page page, StockInventoryDto stockInventoryDto) {
@@ -132,6 +134,7 @@
        stockOutRecordDto.setStockOutNum(stockInventoryDto.getQualitity());
        stockOutRecordDto.setBatchNo(stockInventoryDto.getBatchNo());
        stockOutRecordDto.setProductModelId(stockInventoryDto.getProductModelId());
        stockOutRecordDto.setOutboundBatches(stockInventoryDto.getOutboundBatches());
        stockOutRecordDto.setType("0");
        stockOutRecordService.add(stockOutRecordDto);
@@ -171,6 +174,7 @@
        stockInRecordDto.setRemark(stockInventoryDto.getRemark());
        stockInRecordDto.setWarnNum(stockInventoryDto.getWarnNum());
        stockInRecordDto.setCreateTime(stockInventoryDto.getCreateTime());
        stockInRecordDto.setWarehouse(stockInventoryDto.getWarehouse());
        stockInRecordService.add(stockInRecordDto);
        return true;
    }
@@ -289,6 +293,7 @@
        stockOutRecordDto.setProductModelId(stockInventoryDto.getProductModelId());
        stockOutRecordDto.setType("0");
        stockOutRecordDto.setRemark(stockInventoryDto.getRemark());
        stockOutRecordDto.setOutboundBatches(stockInventoryDto.getOutboundBatches());
        stockOutRecordService.add(stockOutRecordDto);
        return true;
    }
@@ -315,6 +320,14 @@
            int successCount = 0;
            for (StockInventoryExportData dto : list) {
                // 验证仓库是否存在于字典中
                if (StringUtils.isNotEmpty(dto.getWarehouse())) {
                    String warehouseLabel = sysDictDataService.selectDictLabel("warehouse", dto.getWarehouse());
                    if (StringUtils.isEmpty(warehouseLabel)) {
                        throw new RuntimeException("仓库值 " + dto.getWarehouse() + " 不存在于字典中");
                    }
                }
                // 构建查找键
                String key = dto.getProductName() + "|" + dto.getModel();
                SalesLedgerProduct matchedProduct = productMap.get(key);
@@ -328,6 +341,7 @@
                        stockInventoryDto.setQualitity(dto.getQualifiedQuantity());
                        stockInventoryDto.setRemark(dto.getRemark());
                        stockInventoryDto.setWarnNum(dto.getWarnNum());
                        stockInventoryDto.setWarehouse(dto.getWarehouse());
                        // 验证合格冻结数量
                        if (ObjectUtils.isNotEmpty(dto.getQualifiedLockedQuantity())) {
@@ -351,6 +365,7 @@
                        stockUninventoryDto.setRecordType(StockInQualifiedRecordTypeEnum.CUSTOMIZATION_UNSTOCK_IN.getCode());
                        stockUninventoryDto.setQualitity(dto.getUnQualifiedQuantity());
                        stockUninventoryDto.setRemark(dto.getRemark());
                        stockUninventoryDto.setWarehouse(dto.getWarehouse());
                        // 验证不合格冻结数量
                        if (ObjectUtils.isNotEmpty(dto.getUnQualifiedLockedQuantity())) {