| | |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Service("routeService") |
| | | public class RouteServiceImpl extends ServiceImpl<RouteMapper, Route> implements RouteService { |
| | |
| | | List<String> neighborCodeList = new ArrayList<>(); |
| | | |
| | | for (Route route : this.list(new LambdaQueryWrapper<Route>().eq(Route::getStartCode, code))) { |
| | | neighborCodeList.add(codeService.getById(route.getEndCode()).getData()); |
| | | neighborCodeList.add(codeService.getCacheById(route.getEndCode()).getData()); |
| | | } |
| | | for (Route route : this.list(new LambdaQueryWrapper<Route>().eq(Route::getEndCode, code))) { |
| | | neighborCodeList.add(codeService.getById(route.getStartCode()).getData()); |
| | | neighborCodeList.add(codeService.getCacheById(route.getStartCode()).getData()); |
| | | } |
| | | |
| | | return neighborCodeList; |
| | |
| | | return route; |
| | | } |
| | | |
| | | @Override |
| | | public List<Long> getAdjacencyNode(Long codeId) { |
| | | |
| | | List<Long> result = new ArrayList<>(); |
| | | |
| | | result.addAll(this.list(new LambdaQueryWrapper<Route>() |
| | | .eq(Route::getStartCode, codeId) |
| | | .in(Route::getDirection, 0, 1) |
| | | .eq(Route::getStatus, 1) |
| | | ).stream().map(Route::getEndCode).distinct().collect(Collectors.toList())); |
| | | |
| | | result.addAll(this.list(new LambdaQueryWrapper<Route>() |
| | | .eq(Route::getEndCode, codeId) |
| | | .in(Route::getDirection, 0, 2) |
| | | .eq(Route::getStatus, 1) |
| | | ).stream().map(Route::getStartCode).distinct().collect(Collectors.toList())); |
| | | |
| | | |
| | | return result.stream().distinct().collect(Collectors.toList()); |
| | | } |
| | | |
| | | } |