| | |
| | | return stockOut; |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void saveStockout(StockOut stockOut) { |
| | | // 进行判断是否存在相同的产品id和供应商id,要判断product_id在表product_record中是否存在,因为stock_out表中的product_id是product_record表中的product_id关联的 |
| | | LambdaQueryWrapper<ProductRecord> queryWrapper1 = new LambdaQueryWrapper<>(); |
| | | queryWrapper1.eq(ProductRecord::getProductId, stockOut.getProductRecordid()); |
| | | ProductRecord productRecord = productRecordMapper.selectOne(queryWrapper1); |
| | | if (productRecord == null) { |
| | | throw new RuntimeException("产品不存在"); |
| | | } |
| | | LambdaQueryWrapper<SupplierManage> queryWrapper2 = new LambdaQueryWrapper<>(); |
| | | queryWrapper2.eq(SupplierManage::getId, stockOut.getSupplierId()); |
| | | SupplierManage supplierManage = supplierManageMapper.selectOne(queryWrapper2); |
| | | if (supplierManage == null) { |
| | | throw new RuntimeException("供应商不存在"); |
| | | } |
| | | LambdaQueryWrapper<StockManagement> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(StockManagement::getProductRecordid, stockOut.getProductRecordid()); |
| | | queryWrapper.eq(StockManagement::getSupplierId, stockOut.getSupplierId()); |
| | | StockManagement stockManagement = stockManagementMapper.selectOne(queryWrapper); |
| | | if (stockManagement != null) { |
| | | stockOut.setStockmanageId(stockManagement.getId()); |
| | | stockOutMapper.insert(stockOut); |
| | | }else { |
| | | throw new RuntimeException("库存中不存在该产品和供应商"); |
| | | } |
| | | } |
| | | // @Override |
| | | // @Transactional(rollbackFor = Exception.class) |
| | | // public void saveStockout(StockOut stockOut) { |
| | | // |
| | | // } |
| | | |
| | | @Override |
| | | public int updateStockOut(StockOut stockOut) { |
| | | // 修改的时候要判断是否存在相同的产品id和供应商id |
| | | LambdaQueryWrapper<ProductRecord> queryWrapper1 = new LambdaQueryWrapper<>(); |
| | | queryWrapper1.eq(ProductRecord::getProductId, stockOut.getProductRecordid()); |
| | | ProductRecord productRecord = productRecordMapper.selectOne(queryWrapper1); |
| | | if (productRecord == null) { |
| | | throw new RuntimeException("产品不存在"); |
| | | } |
| | | LambdaQueryWrapper<SupplierManage> queryWrapper2 = new LambdaQueryWrapper<>(); |
| | | queryWrapper2.eq(SupplierManage::getId, stockOut.getSupplierId()); |
| | | SupplierManage supplierManage = supplierManageMapper.selectOne(queryWrapper2); |
| | | if (supplierManage == null) { |
| | | throw new RuntimeException("供应商不存在"); |
| | | } |
| | | LambdaQueryWrapper<StockManagement> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(StockManagement::getProductRecordid, stockOut.getProductRecordid()); |
| | | queryWrapper.eq(StockManagement::getSupplierId, stockOut.getSupplierId()); |
| | | StockManagement stockManagement = stockManagementMapper.selectOne(queryWrapper); |
| | | if (stockManagement != null) { |
| | | stockOut.setStockmanageId(stockManagement.getId()); |
| | | return stockOutMapper.updateById(stockOut); |
| | | }else { |
| | | throw new RuntimeException("库存中不存在该产品和供应商"); |
| | | } |
| | | // 修改出库记录表 |
| | | return stockOutMapper.updateById(stockOut); |
| | | } |
| | | |
| | | @Override |