| | |
| | | for (Segment segment : segments) { |
| | | long startTime = System.currentTimeMillis(); |
| | | trafficService.trigger(segment); |
| | | long algoTime = System.currentTimeMillis() - startTime; |
| | | log.info("traffic calculation spend {} ms", algoTime); |
| | | if (segment.getState().equals(SegmentStateType.RUNNING.toString())) { |
| | | segment.setAlgoTime((int) algoTime); |
| | | segmentService.updateById(segment); |
| | | } |
| | | log.info("traffic calculation spend {} ms", System.currentTimeMillis() - startTime); |
| | | } |
| | | |
| | | } catch (Exception e) { |
| | |
| | | * 根据分片生成动作 ( 车辆可能已经做过一些任务了,正在等待下一段任务 ) |
| | | */ |
| | | @Transactional |
| | | public synchronized void generateAction(Long agvId, List<Segment> segmentList, List<String> pathList) { |
| | | public synchronized void generateAction(Long agvId, List<Segment> segmentList, List<String> pathList, Date algoStartTime) { |
| | | try { |
| | | if (Cools.isEmpty(agvId, segmentList)) { return; } |
| | | Date now = new Date(); |
| | |
| | | item.setGroupId(groupId); |
| | | item.setState(SegmentStateType.RUNNING.toString()); |
| | | item.setUpdateTime(now); |
| | | if (null != algoStartTime) { |
| | | item.setAlgoTime((int) (now.getTime() - algoStartTime.getTime())); |
| | | } |
| | | if (!segmentService.updateById(item)) { |
| | | throw new CoolException("更新Segment失败"); |
| | | } |
| | |
| | | |
| | | mapService.lockPath(null, pathList, agv.getUuid()); |
| | | |
| | | mainService.generateAction(segment.getAgvId(), segmentList, pathList); |
| | | mainService.generateAction(segment.getAgvId(), segmentList, pathList, now); |
| | | |
| | | } catch (Exception e) { |
| | | log.error("TrafficService.trigger", e); |