| | |
| | | import com.zy.acs.manager.common.utils.MapDataUtils; |
| | | import com.zy.acs.manager.core.constant.MapDataConstant; |
| | | import com.zy.acs.manager.core.domain.BlockVehicleDto; |
| | | import com.zy.acs.manager.core.domain.PathDto; |
| | | import com.zy.acs.manager.core.domain.TaskPosDto; |
| | | import com.zy.acs.manager.core.domain.type.BlockSeverityType; |
| | | import com.zy.acs.manager.core.service.astart.MapDataDispatcher; |
| | |
| | | } |
| | | } |
| | | |
| | | mapService.lockPath(null, pathList, agv.getUuid()); |
| | | |
| | | // startTime = System.currentTimeMillis(); |
| | | mainService.generateAction(segment.getAgvId(), segmentList, pathList, now); |
| | | List<PathDto> pathDtoList = mainService.generateAction(segment.getAgvId(), segmentList, pathList, now); |
| | | // System.out.println("generateAction: " + (System.currentTimeMillis() - startTime)); |
| | | |
| | | mapService.lockPath(null, pathDtoList, agv.getUuid()); |
| | | |
| | | } catch (Exception e) { |
| | | log.error("TrafficService.trigger", e); |
| | |
| | | BlockSeverityType blockSeverity = BlockSeverityType.query(null == jam ? null : jam.getDuration()); |
| | | // judge avoid of jam 如果已经在避让点(因为当前车执行了避让任务),那么则不能再去检索之前的阻塞路径 |
| | | List<Jam> unfinishedOriginJamByCurrAgv = jamService.getUnfinishedOriginJamByAvo(agv.getId(), startCode.getId(), segment.getId()); |
| | | List<String> blackPath = this.getBlackPathList(unfinishedOriginJamByCurrAgv); |
| | | List<String> blackPath = this.getBlackPathList(agvNo, unfinishedOriginJamByCurrAgv); |
| | | |
| | | // 结果集 |
| | | List<String> pathList = new ArrayList<>(); |
| | |
| | | } |
| | | } |
| | | |
| | | private List<String> getBlackPathList(List<Jam> unfinishedOriginJamByCurrAgv) { |
| | | private List<String> getBlackPathList(String agvNo, List<Jam> unfinishedOriginJamByCurrAgv) { |
| | | List<String> blackPathList = new ArrayList<>(); |
| | | Integer lev = MapDataDispatcher.MAP_DEFAULT_LEV; |
| | | if (!Cools.isEmpty(unfinishedOriginJamByCurrAgv)) { |
| | | for (Jam jam : unfinishedOriginJamByCurrAgv) { |
| | | if (!Cools.isEmpty(jam.getJamPath())) { |
| | | if (Cools.isEmpty(unfinishedOriginJamByCurrAgv)) { |
| | | return blackPathList; |
| | | } |
| | | |
| | | List<String> list = GsonUtils.fromJsonToList(jam.getJamPath(), String.class); |
| | | AgvModel agvModel = agvModelService.getByAgvNo(agvNo); |
| | | double bufferRadius = MapDataUtils.buildFootprint(agvModel).maxExtent(); |
| | | |
| | | Agv jamAgv = agvService.getById(jam.getJamAgv()); |
| | | List<String> jamDynamicNodes = mapService.queryCodeListFromDynamicNode(lev, jamAgv.getUuid()); |
| | | // jamDynamicNodes has sorted |
| | | String firstCodeNode = jamDynamicNodes.stream().findFirst().orElse(null); |
| | | for (Jam jam : unfinishedOriginJamByCurrAgv) { |
| | | if (!Cools.isEmpty(jam.getJamPath())) { |
| | | |
| | | if (!Cools.isEmpty(firstCodeNode)) { |
| | | int idx = list.indexOf(firstCodeNode); |
| | | if (idx != -1) { |
| | | list = new ArrayList<>(list.subList(idx, list.size())); |
| | | List<String> list = GsonUtils.fromJsonToList(jam.getJamPath(), String.class); |
| | | |
| | | // the wave of first node |
| | | Double avoidDistance = MapDataUtils.getVehicleWaveSafeDistance( |
| | | agvModelService.getByAgvId(jamAgv.getId()).getDiameter(), |
| | | MapDataConstant.MAX_DISTANCE_BETWEEN_ADJACENT_AGV_FACTOR |
| | | ); |
| | | List<String> waveCodeList = mapService.getWaveScopeByCode(lev, firstCodeNode, avoidDistance) |
| | | .stream().map(NavigateNode::getCodeData).distinct().collect(Collectors.toList()); |
| | | list.addAll(waveCodeList); |
| | | } else { |
| | | // 如果被阻塞车辆已经不在原来的阻塞路径中,考虑避让车走行时不需要把之前的阻塞路径加入黑名单 |
| | | list = new ArrayList<>(); |
| | | } |
| | | String jamAgvNo = agvService.getAgvNo(jam.getJamAgv()); |
| | | List<String> jamDynamicNodes = mapService.queryCodeListFromDynamicNode(lev, jamAgvNo); |
| | | // jamDynamicNodes has sorted |
| | | String firstCodeNode = jamDynamicNodes.stream().findFirst().orElse(null); |
| | | |
| | | if (!Cools.isEmpty(firstCodeNode)) { |
| | | int idx = list.indexOf(firstCodeNode); |
| | | if (idx != -1) { |
| | | list = new ArrayList<>(list.subList(idx, list.size())); |
| | | |
| | | // the wave of first node |
| | | AgvModel jamAgvModel = agvModelService.getByAgvNo(jamAgvNo); |
| | | Double avoidDistance = MapDataUtils.buildFootprint(jamAgvModel).maxExtent() + bufferRadius; |
| | | List<String> waveCodeList = mapService.getWaveScopeByCode(lev, firstCodeNode, avoidDistance) |
| | | .stream().map(NavigateNode::getCodeData).distinct().collect(Collectors.toList()); |
| | | list.addAll(waveCodeList); |
| | | } else { |
| | | // 如果被阻塞车辆已经不在原来的阻塞路径中,考虑避让车走行时不需要把之前的阻塞路径加入黑名单 |
| | | list = new ArrayList<>(); |
| | | } |
| | | |
| | | blackPathList.addAll(list); |
| | | } |
| | | |
| | | blackPathList.addAll(list); |
| | | } |
| | | } |
| | | |
| | | return blackPathList.stream().distinct().collect(Collectors.toList()); |
| | | } |
| | | |