| | |
| | | package com.zy.acs.manager.core.service; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.zy.acs.common.constant.RedisConstant; |
| | | import com.zy.acs.common.utils.RedisSupport; |
| | | import com.zy.acs.framework.common.Cools; |
| | | import com.zy.acs.framework.common.SnowflakeIdWorker; |
| | | import com.zy.acs.framework.exception.CoolException; |
| | | import com.zy.acs.manager.common.utils.MapDataUtils; |
| | | import com.zy.acs.manager.core.domain.TaskPosDto; |
| | | import com.zy.acs.manager.core.domain.TrafficJamDto; |
| | | import com.zy.acs.manager.core.service.astart.DynamicNodeType; |
| | | import com.zy.acs.manager.core.service.astart.MapDataDispatcher; |
| | | import com.zy.acs.manager.core.service.astart.RetreatNavigateNode; |
| | |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.transaction.interceptor.TransactionAspectSupport; |
| | | |
| | | import java.util.*; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * Wavefront |
| | |
| | | } |
| | | } |
| | | |
| | | public void callback(List<Segment> segmentList) { |
| | | Date now = new Date(); |
| | | |
| | | segmentList.stream().max(Comparator.comparingInt(Segment::getSerial)).ifPresent(segment -> { |
| | | Segment nextSegment = segmentService.getNextStepOfInit(segment.getTravelId(), segment.getSerial()); |
| | | |
| | | if (null != nextSegment) { |
| | | |
| | | nextSegment.setState(SegmentStateType.WAITING.toString()); |
| | | nextSegment.setUpdateTime(now); |
| | | if (!segmentService.updateById(nextSegment)) { |
| | | log.error("Segment [{}] 更新失败 !!!", nextSegment.getGroupId() + " - " + nextSegment.getSerial()); |
| | | } |
| | | |
| | | } else { |
| | | |
| | | travelService.checkFinish(segment.getTravelId()); |
| | | } |
| | | }); |
| | | |
| | | } |
| | | |
| | | private List<String> checkoutPath(Agv agv, Code startCode, Code endCode, Segment segment) { |
| | | Integer lev = null; |
| | | String agvNo = agv.getUuid(); |
| | |
| | | List<String> unlockPathList = mapService.checkoutPath(agvNo, startCode, endCode, false); |
| | | // 避让解 |
| | | List<String> lockPathList = mapService.checkoutPath(agvNo, startCode, endCode, true); |
| | | |
| | | if (Cools.isEmpty(lockPathList)) { |
| | | return pathList; |
| | | } |
| | | |
| | | pathList = lockPathList; |
| | | |
| | | |
| | | long currentTime = System.currentTimeMillis(); |
| | | long estimatedTime = currentTime; |
| | | |
| | | for (int i = 0; i < pathList.size() - 1; i++) { |
| | | String fromCode = pathList.get(i); |
| | | String toCode = pathList.get(i + 1); |
| | | String key = fromCode + "_" + toCode; |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | if (!Cools.isEmpty(lockPathList) && // 存在避让解 |
| | | Math.abs(lockPathList.size() - unlockPathList.size()) <= Arrays.stream(mapDataDispatcher.getCodeMatrix(lev)).mapToInt(row -> row.length).sum() / 10 |
| | |
| | | } |
| | | |
| | | return jamVehicleList; |
| | | } |
| | | |
| | | private String hasEvent(String agvNo) { |
| | | List<Agv> agvList = agvService.list(new LambdaQueryWrapper<>()); |
| | | for (Agv agv : agvList) { |
| | | if (agvNo.equals(agv.getUuid())) { |
| | | continue; |
| | | } |
| | | String jamStr = redis.getValue(RedisConstant.AGV_TRAFFIC_JAM_FLAG, agv.getUuid()); |
| | | if (!Cools.isEmpty(jamStr)) { |
| | | |
| | | TrafficJamDto jamDto = JSON.parseObject(jamStr, TrafficJamDto.class); |
| | | |
| | | |
| | | |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |