| | |
| | | |
| | | @Override |
| | | public R importStockInventory(MultipartFile file) { |
| | | try { |
| | | final StringBuffer[] errorMsg = {new StringBuffer()}; |
| | | //查询所有的产品 |
| | | List<SalesLedgerProduct> salesLedgerProducts =salesLedgerProductMapper.selectProduct(); |
| | | |
| | | ExcelUtil<StockInventoryExportData> util = new ExcelUtil<StockInventoryExportData>(StockInventoryExportData.class); |
| | | List<StockInventoryExportData> list = util.importExcel(file.getInputStream()); |
| | | list.stream().forEach(dto -> { |
| | | salesLedgerProducts.stream().forEach(item->{ |
| | | if (item.getProductCategory().equals(dto.getProductName())&&item.getSpecificationModel().equals(dto.getModel())) { |
| | | //更新库存 |
| | | StockInventoryDto stockInventoryDto = new StockInventoryDto(); |
| | | stockInventoryDto.setRecordId(0L); |
| | | stockInventoryDto.setRecordType(StockQualifiedRecordTypeEnum.CUSTOMIZATION_STOCK_IN.getCode()); |
| | | stockInventoryDto.setQualitity(dto.getQualitity()); |
| | | stockInventoryDto.setProductModelId(item.getProductModelId()); |
| | | this.addstockInventory(stockInventoryDto); }else { |
| | | errorMsg[0] = errorMsg[0].append("产品名称:"+dto.getProductName()+"规格:"+dto.getModel()+"不存在").append("\n"); |
| | | } |
| | | }); |
| | | }); |
| | | return R.ok(errorMsg[0]); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | return R.fail(); |
| | | } |
| | | |