| | |
| | | package com.ruoyi.warehouse.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | import com.ruoyi.warehouse.mapper.WarehouseMapper; |
| | | import com.ruoyi.warehouse.pojo.Warehouse; |
| | | import com.ruoyi.warehouse.pojo.WarehouseGoodsShelves; |
| | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.sql.Array; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @author 86151 |
| | |
| | | private WarehouseGoodsShelvesService warehouseGoodsShelvesService; |
| | | |
| | | @Override |
| | | public IPage<Warehouse> listPage(Page page, Warehouse warehouse) { |
| | | return warehouseMapper.listPage(page, warehouse); |
| | | public List<Warehouse> listPage(Warehouse warehouse) { |
| | | return warehouseMapper.listPage( warehouse); |
| | | } |
| | | |
| | | // @Override |
| | | // public boolean deleteByIds(List<Long> ids) { |
| | | // |
| | | // for (Long id : ids) { |
| | | // List<WarehouseGoodsShelves> list = warehouseGoodsShelvesService.list(new QueryWrapper<WarehouseGoodsShelves>().lambda() |
| | | // .eq(WarehouseGoodsShelves::getWarehouseId, id)); |
| | | // if(list.size()>0){ |
| | | // log.error("仓库下有货架,不能删除 重新选择"); |
| | | // return false; |
| | | // } |
| | | // } |
| | | // return removeByIds(ids); |
| | | // } |
| | | @Override |
| | | public boolean deleteByIds(List<Long> ids) { |
| | | for (Long id : ids) { |
| | | WarehouseGoodsShelves shelves = new WarehouseGoodsShelves(); |
| | | shelves.setWarehouseId(id); |
| | | IPage<WarehouseGoodsShelves> page = warehouseGoodsShelvesService.listPage(new Page<>(), shelves); |
| | | if(page.getRecords().size()>0){ |
| | | log.error("仓库下有货架,不能删除"); |
| | | return false; |
| | | } |
| | | // 1. 检查是否有货架 |
| | | Wrapper<WarehouseGoodsShelves> queryWrapper = new LambdaQueryWrapper<WarehouseGoodsShelves>() |
| | | .in(WarehouseGoodsShelves::getWarehouseId, ids); |
| | | List<WarehouseGoodsShelves> shelvesList = warehouseGoodsShelvesService.list(queryWrapper); |
| | | //获得shelvesList中所有的Id |
| | | List<Long> shelvesIds = shelvesList.stream().map(WarehouseGoodsShelves::getId).collect(Collectors.toList()); |
| | | // 2. 删除货架 |
| | | if (!shelvesIds.isEmpty()) { |
| | | warehouseGoodsShelvesService.deleteByIds(shelvesIds); |
| | | } |
| | | return true; |
| | | return removeByIds(ids); |
| | | } |
| | | |
| | | } |
| | | |
| | | |