huminmin
2026-06-01 0c9ee949b6a7ea8ce2bbc42cbbd2c64fb977e509
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) {
@@ -92,6 +94,7 @@
        stockInRecordDto.setBatchNo(stockInventoryDto.getBatchNo());
        stockInRecordDto.setProductModelId(stockInventoryDto.getProductModelId());
        stockInRecordDto.setType("0");
        stockInRecordDto.setCreateTime(stockInventoryDto.getCreateTime());
        stockInRecordService.add(stockInRecordDto);
        //再进行新增库存数量库存
        //先查询库存表中的产品是否存在,不存在新增,存在更新
@@ -169,6 +172,8 @@
        stockInRecordDto.setType("0");
        stockInRecordDto.setRemark(stockInventoryDto.getRemark());
        stockInRecordDto.setWarnNum(stockInventoryDto.getWarnNum());
        stockInRecordDto.setCreateTime(stockInventoryDto.getCreateTime());
        stockInRecordDto.setWarehouse(stockInventoryDto.getWarehouse());
        stockInRecordService.add(stockInRecordDto);
        return true;
    }
@@ -287,6 +292,7 @@
        stockOutRecordDto.setProductModelId(stockInventoryDto.getProductModelId());
        stockOutRecordDto.setType("0");
        stockOutRecordDto.setRemark(stockInventoryDto.getRemark());
        stockOutRecordDto.setOutboundBatches(stockInventoryDto.getOutboundBatches());
        stockOutRecordService.add(stockOutRecordDto);
        return true;
    }
@@ -313,6 +319,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);
@@ -326,6 +340,7 @@
                        stockInventoryDto.setQualitity(dto.getQualifiedQuantity());
                        stockInventoryDto.setRemark(dto.getRemark());
                        stockInventoryDto.setWarnNum(dto.getWarnNum());
                        stockInventoryDto.setWarehouse(dto.getWarehouse());
                        // 验证合格冻结数量
                        if (ObjectUtils.isNotEmpty(dto.getQualifiedLockedQuantity())) {
@@ -349,6 +364,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())) {