| | |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.math.BigDecimal; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | |
| | | newStockInventory.setQualitity(stockInventoryDto.getQualitity()); |
| | | newStockInventory.setVersion(1); |
| | | newStockInventory.setRemark(stockInventoryDto.getRemark()); |
| | | newStockInventory.setLockedQuantity(stockInventoryDto.getLockedQuantity()); |
| | | newStockInventory.setWarnNum(stockInventoryDto.getWarnNum()); |
| | | stockInventoryMapper.insert(newStockInventory); |
| | | }else { |
| | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Boolean subtractStockInventory(StockInventoryDto stockInventoryDto) { |
| | | // 新增出库记录 |
| | | // 新增出库记录 |
| | | StockOutRecordDto stockOutRecordDto = new StockOutRecordDto(); |
| | | stockOutRecordDto.setRecordId(stockInventoryDto.getRecordId()); |
| | | stockOutRecordDto.setRecordType(stockInventoryDto.getRecordType()); |
| | |
| | | stockOutRecordDto.setType("0"); |
| | | stockOutRecordService.add(stockOutRecordDto); |
| | | StockInventory oldStockInventory = stockInventoryMapper.selectOne(new QueryWrapper<StockInventory>().lambda().eq(StockInventory::getProductModelId, stockInventoryDto.getProductModelId())); |
| | | if (stockInventoryDto.getQualitity().compareTo( oldStockInventory.getQualitity().subtract(oldStockInventory.getLockedQuantity()))>0) { |
| | | throw new RuntimeException("库存不足无法出库"); |
| | | } |
| | | if (ObjectUtils.isEmpty(oldStockInventory)) { |
| | | throw new RuntimeException("产品库存不存在"); |
| | | }else { |
| | | stockInventoryMapper.updateSubtractStockInventory(stockInventoryDto); |
| | | } |
| | | BigDecimal lockedQty = oldStockInventory.getLockedQuantity(); |
| | | if (lockedQty == null) { |
| | | lockedQty = BigDecimal.ZERO; |
| | | } |
| | | if (stockInventoryDto.getQualitity().compareTo(oldStockInventory.getQualitity().subtract(lockedQty)) > 0) { |
| | | throw new RuntimeException("库存不足无法出库"); |
| | | } |
| | | |
| | | stockInventoryMapper.updateSubtractStockInventory(stockInventoryDto); |
| | | return true; |
| | | } |
| | | |
| | |
| | | stockInventoryDto.setRecordType(StockQualifiedRecordTypeEnum.CUSTOMIZATION_STOCK_IN.getCode()); |
| | | stockInventoryDto.setQualitity(dto.getQualitity()); |
| | | stockInventoryDto.setRemark(dto.getRemark()); |
| | | stockInventoryDto.setWarnNum(dto.getWarnNum()); |
| | | if (ObjectUtils.isNotEmpty(dto.getLockedQuantity())&&dto.getLockedQuantity().compareTo(dto.getQualitity())>0) { |
| | | throw new RuntimeException("冻结数量不能超过本次导入的库存数量"); |
| | | } |
| | | stockInventoryDto.setLockedQuantity(dto.getLockedQuantity()); |
| | | stockInventoryDto.setProductModelId(item.getProductModelId()); |
| | | this.addstockInventory(stockInventoryDto); |
| | | matched = true; |