| | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.enums.StockInQualifiedRecordTypeEnum; |
| | | import com.ruoyi.common.enums.StockOutQualifiedRecordTypeEnum; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.framework.web.domain.R; |
| | | import com.ruoyi.sales.mapper.SalesLedgerProductMapper; |
| | |
| | | private StockInRecordService stockInRecordService; |
| | | private StockOutRecordService stockOutRecordService; |
| | | private SalesLedgerProductMapper salesLedgerProductMapper; |
| | | |
| | | @Override |
| | | public IPage<StockInventoryDto> pagestockInventory(Page page, StockInventoryDto stockInventoryDto) { |
| | | return stockInventoryMapper.pagestockInventory(page, stockInventoryDto); |
| | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Boolean addstockInventory(StockInventoryDto stockInventoryDto) { |
| | | //新增入库记录再添加库存 |
| | | // 更新产品入库状态 |
| | | SalesLedgerProduct salesLedgerProduct = salesLedgerProductMapper.selectById(stockInventoryDto.getSalesLedgerProductId()); |
| | | if (salesLedgerProduct == null) { |
| | | throw new ServiceException("入库失败,销售产品不存在"); |
| | | } |
| | | salesLedgerProduct.setProductStockStatus(1); |
| | | salesLedgerProductMapper.updateById(salesLedgerProduct); |
| | | |
| | | StockInRecordDto stockInRecordDto = new StockInRecordDto(); |
| | | stockInRecordDto.setRecordId(stockInventoryDto.getRecordId()); |
| | | stockInRecordDto.setRecordType(stockInventoryDto.getRecordType()); |
| | | stockInRecordDto.setStockInNum(stockInventoryDto.getQualitity()); |
| | | stockInRecordDto.setProductModelId(stockInventoryDto.getProductModelId()); |
| | | stockInRecordDto.setType("0"); |
| | | stockInRecordDto.setSalesLedgerId(stockInventoryDto.getSalesLedgerId()); |
| | | stockInRecordDto.setSalesLedgerProductId(stockInventoryDto.getSalesLedgerProductId()); |
| | | stockInRecordService.add(stockInRecordDto); |
| | | //再进行新增库存数量库存 |
| | | //先查询库存表中的产品是否存在,不存在新增,存在更新 |
| | |
| | | stockOutRecordDto.setStockOutNum(stockInventoryDto.getQualitity()); |
| | | stockOutRecordDto.setProductModelId(stockInventoryDto.getProductModelId()); |
| | | stockOutRecordDto.setType("0"); |
| | | stockOutRecordDto.setSalesLedgerId(stockInventoryDto.getSalesLedgerId()); |
| | | stockOutRecordDto.setSalesLedgerProductId(stockInventoryDto.getSalesLedgerProductId()); |
| | | stockOutRecordService.add(stockOutRecordDto); |
| | | StockInventory oldStockInventory = stockInventoryMapper.selectOne(new QueryWrapper<StockInventory>().lambda().eq(StockInventory::getProductModelId, stockInventoryDto.getProductModelId())); |
| | | if (ObjectUtils.isEmpty(oldStockInventory)) { |