| | |
| | | import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.warehouse.dto.WarehouseGoodsShelvesDto; |
| | | import com.ruoyi.warehouse.mapper.DocumentationMapper; |
| | | import com.ruoyi.warehouse.mapper.WarehouseGoodsShelvesMapper; |
| | | import com.ruoyi.warehouse.mapper.WarehouseGoodsShelvesRowcolMapper; |
| | |
| | | private DocumentationService documentationService; |
| | | @Autowired |
| | | private DocumentationMapper documentationMapper; |
| | | @Override |
| | | public IPage<WarehouseGoodsShelves> listPage(Page page, WarehouseGoodsShelves warehouseGoodsShelves) { |
| | | return warehouseGoodsShelvesMapper.listPage(page,warehouseGoodsShelves); |
| | | } |
| | | |
| | | @Override |
| | | public boolean add(WarehouseGoodsShelves warehouseGoodsShelves) { |
| | | WarehouseGoodsShelves one = warehouseGoodsShelvesMapper.selectOne(new LambdaQueryWrapper<WarehouseGoodsShelves>().eq(WarehouseGoodsShelves::getId, warehouseGoodsShelves.getId())); |
| | | // 1. 检查货架名称是否已存在 |
| | | if (one == null) { |
| | | if(warehouseGoodsShelves.getRow() == null || warehouseGoodsShelves.getRow() == 0 && warehouseGoodsShelves.getCol() == null || warehouseGoodsShelves.getCol() == 0){ |
| | | throw new IllegalArgumentException("层数和列数不能为空"); |
| | | } |
| | | int insert = warehouseGoodsShelvesMapper.insert(warehouseGoodsShelves); |
| | | if (insert <= 0) return false; |
| | | } |
| | |
| | | Long warehouseId = warehouseGoodsShelves.getWarehouseId(); |
| | | // 3. 批量创建行列记录 |
| | | List<WarehouseGoodsShelvesRowcol> rowcolList = new ArrayList<>(); |
| | | for (long i = 1; i <= warehouseGoodsShelves.getStorey(); i++) { |
| | | for (long j = 1; j <= warehouseGoodsShelves.getArrange(); j++) { |
| | | for (long i = 1; i <= warehouseGoodsShelves.getRow(); i++) { |
| | | for (long j = 1; j <= warehouseGoodsShelves.getCol(); j++) { |
| | | WarehouseGoodsShelvesRowcol rowcol = new WarehouseGoodsShelvesRowcol(); |
| | | rowcol.setStorey(i); |
| | | rowcol.setArrange(j); |
| | | rowcol.setRow(i); |
| | | rowcol.setCol(j); |
| | | rowcol.setWarehouseGoodsShelvesId(shelvesId); |
| | | rowcolList.add(rowcol); |
| | | } |
| | |
| | | Wrapper<Documentation> queryWrapper1 = new LambdaQueryWrapper<Documentation>() |
| | | .in(Documentation::getWarehouseGoodsShelvesRowcolId, rowcolIds); |
| | | List<Documentation> documentations = documentationMapper.selectList(queryWrapper1); |
| | | if (!documentations.isEmpty()) return false; |
| | | if (!documentations.isEmpty()) throw new RuntimeException("货架下有商品,不能删除"); |
| | | |
| | | // 先更新货架主信息 |
| | | updateById(warehouseGoodsShelves); |
| | |
| | | Wrapper<Documentation> queryWrapper1 = new LambdaQueryWrapper<Documentation>() |
| | | .in(Documentation::getWarehouseGoodsShelvesRowcolId, rowcolIds); |
| | | List<Documentation> documentations = documentationMapper.selectList(queryWrapper1); |
| | | if (!documentations.isEmpty()) return false; // 任一货架有商品则终止删除 |
| | | if (!documentations.isEmpty()) throw new RuntimeException("货架下有商品,不能删除"); // 任一货架有商品则终止删除 |
| | | } |
| | | |
| | | // 3. 先删除货架主记录 |
| | |
| | | return true; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public List<WarehouseGoodsShelves> list(WarehouseGoodsShelves warehouseGoodsShelves) { |
| | | return warehouseGoodsShelvesMapper.list(warehouseGoodsShelves); |
| | | public List<WarehouseGoodsShelvesDto> findList(WarehouseGoodsShelves warehouseGoodsShelves) { |
| | | return warehouseGoodsShelvesMapper.listAll(warehouseGoodsShelves); |
| | | } |
| | | |
| | | } |