liyong
2026-04-15 333d209effc6574985ce5b696d36785ca50b9fcc
src/main/java/com/ruoyi/stock/service/impl/StockInventoryServiceImpl.java
@@ -9,6 +9,7 @@
import com.ruoyi.common.enums.StockOutQualifiedRecordTypeEnum;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.domain.R;
import com.ruoyi.sales.dto.SimpleProductDto;
import com.ruoyi.sales.mapper.SalesLedgerProductMapper;
import com.ruoyi.sales.pojo.SalesLedgerProduct;
import com.ruoyi.stock.dto.StockInRecordDto;
@@ -29,6 +30,7 @@
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
/**
 * <p>
@@ -117,7 +119,7 @@
    public R importStockInventory(MultipartFile file) {
        try {
            // 查询所有的产品
            List<SalesLedgerProduct> salesLedgerProducts = salesLedgerProductMapper.selectProduct();
            List<SimpleProductDto> salesLedgerProducts = salesLedgerProductMapper.selectProduct();
            ExcelUtil<StockInventoryExportData> util = new ExcelUtil<StockInventoryExportData>(StockInventoryExportData.class);
            List<StockInventoryExportData> list = util.importExcel(file.getInputStream());
@@ -127,12 +129,16 @@
            list.forEach(dto -> {
                boolean matched = false;
                for (SalesLedgerProduct item : salesLedgerProducts) {
                for (SimpleProductDto item : salesLedgerProducts) {
                    if (ObjectUtils.isEmpty(dto.getWarehouseCode())) {
                        return;
                    }
                    if (item.getProductCategory().equals(dto.getProductName()) &&
                            item.getSpecificationModel().equals(dto.getModel())) {
                            item.getSpecificationModel().equals(dto.getModel())
                            && Optional.ofNullable(item.getUnit()).orElse("").equals(dto.getUnit())
                            && Optional.ofNullable(item.getSubUnit()).orElse("").equals(dto.getSubUnit())
                    ) {
                        StockInventoryDto stockInventoryDto = new StockInventoryDto();
                        stockInventoryDto.setWarehouseCode(dto.getWarehouseCode());
                        stockInventoryDto.setWarehouseName(dto.getWarehouseName());
@@ -149,8 +155,8 @@
                }
                if (!matched) {
                    // 记录未匹配的数据
                    String unmatchedInfo = String.format("产品名称:%s,规格型号:%s",
                            dto.getProductName(), dto.getModel());
                    String unmatchedInfo = String.format("产品名称:%s,规格型号:%s 主单位:%s 辅单位:%s",
                            dto.getProductName(), dto.getModel(), dto.getUnit(), dto.getSubUnit());
                    unmatchedRecords.add(unmatchedInfo);
                }
            });