| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.zy.acs.common.utils.GsonUtils; |
| | | import com.zy.acs.common.utils.Utils; |
| | | import com.zy.acs.framework.exception.CoolException; |
| | | import com.zy.acs.manager.manager.entity.Code; |
| | | import com.zy.acs.manager.manager.entity.Route; |
| | |
| | | return null; |
| | | } |
| | | Route route = this.findByCodeOfBoth(startCode.getId(), endCode.getId()); |
| | | boolean created = false; |
| | | direction = Optional.ofNullable(direction).orElse(0); |
| | | if (null == route) { |
| | | Date now = new Date(); |
| | |
| | | if (!this.save(route)) { |
| | | throw new CoolException(route.getCodeArr()+" save fail![Route]"); |
| | | } |
| | | created = true; |
| | | } |
| | | if (created) { |
| | | List<Long> codes = Utils.singletonList(startCode.getId()); |
| | | codes.add(endCode.getId()); |
| | | codeService.refreshCornerByCodeIds(codes); |
| | | } |
| | | return route; |
| | | } |
| | |
| | | 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; |