| | |
| | | package com.vincent.rsf.server.manager.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.vincent.rsf.framework.exception.CoolException; |
| | | import com.vincent.rsf.server.manager.entity.WarehouseAreas; |
| | | import com.vincent.rsf.server.manager.mapper.WarehouseMapper; |
| | | import com.vincent.rsf.server.manager.entity.Warehouse; |
| | | import com.vincent.rsf.server.manager.service.WarehouseAreasService; |
| | | import com.vincent.rsf.server.manager.service.WarehouseService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | @Service("warehouseService") |
| | | public class WarehouseServiceImpl extends ServiceImpl<WarehouseMapper, Warehouse> implements WarehouseService { |
| | | |
| | | @Autowired |
| | | private WarehouseAreasService warehouseAreasService; |
| | | |
| | | @Override |
| | | public List<Warehouse> getAllWarehouseAreas() { |
| | | List<Warehouse> warehouses = this.list(new LambdaQueryWrapper<>()); |
| | | if (warehouses.isEmpty()) { |
| | | throw new CoolException("仓库为空,请添加仓库后再操作!!"); |
| | | } |
| | | List<WarehouseAreas> warehouseAreas = warehouseAreasService.list(new LambdaQueryWrapper<>()); |
| | | if (warehouseAreas.isEmpty()) { |
| | | return warehouses; |
| | | } |
| | | warehouses.forEach(warehouse -> { |
| | | List<WarehouseAreas> areas = new ArrayList<>(); |
| | | warehouseAreas.forEach(warehouseAreas1 -> { |
| | | if (warehouse.getId().equals(warehouseAreas1.getWarehouseId())) { |
| | | areas.add(warehouseAreas1); |
| | | } |
| | | }); |
| | | warehouse.setChildren(areas); |
| | | }); |
| | | return warehouses; |
| | | } |
| | | } |