| | |
| | | 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; |
| | |
| | | import java.math.BigDecimal; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Optional; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | 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()); |
| | |
| | | |
| | | 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()); |
| | |
| | | } |
| | | 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); |
| | | } |
| | | }); |