| | |
| | | import com.zy.acs.manager.core.service.floyd.FloydNavigateService; |
| | | import com.zy.acs.manager.manager.entity.Code; |
| | | import com.zy.acs.manager.manager.entity.Loc; |
| | | import com.zy.acs.manager.manager.entity.Segment; |
| | | import com.zy.acs.manager.manager.service.ActionService; |
| | | import com.zy.acs.manager.manager.service.CodeService; |
| | | import com.zy.acs.manager.system.service.ConfigService; |
| | |
| | | @Autowired |
| | | private ActionService actionService; |
| | | |
| | | public List<String> checkoutPath(String agvNo, Code startCode, Code endCode, Boolean lock) { |
| | | return this.checkoutPath(agvNo, startCode, endCode, lock, null); |
| | | } |
| | | |
| | | /** |
| | | * 寻址 ===>> A Star |
| | | */ |
| | | public synchronized List<String> checkoutPath(String agvNo, Code startCode, Code endCode |
| | | , Boolean lock, List<String> blackList) { |
| | | , Boolean lock, List<String> blackList, Segment segment) { |
| | | |
| | | int[] startMapIdx = mapDataDispatcher.getCodeMatrixIdx(null, startCode.getData()); |
| | | int[] endMapIdx = mapDataDispatcher.getCodeMatrixIdx(null, endCode.getData()); |
| | |
| | | NavigateNode startNode = new NavigateNode(startMapIdx[0], startMapIdx[1], startCode.getData()); |
| | | NavigateNode endNode = new NavigateNode(endMapIdx[0], endMapIdx[1], endCode.getData()); |
| | | |
| | | NavigateNode finishNode = aStarNavigateService.execute(agvNo, startNode, endNode, lock, blackList); |
| | | NavigateNode finishNode = aStarNavigateService.execute(agvNo, startNode, endNode, lock, blackList, segment); |
| | | |
| | | if (null == finishNode) { |
| | | log.warn("{} 号AGV检索[{}] ===>> [{}]路径失败......", agvNo, startCode.getData(), endCode.getData()); |
| | |
| | | Date now = new Date(); |
| | | Jam jam = jamService.getJam(agv.getId(), startCode.getId(), segment.getId()); |
| | | // judge avoid of jam |
| | | List<Jam> unfinishedOriginJamByCurrAgv = jamService.hasUnfinishedOriginJamByAvo(agv.getId(), startCode.getId(), segment.getId()); |
| | | List<Jam> unfinishedOriginJamByCurrAgv = jamService.getUnfinishedOriginJamByAvo(agv.getId(), startCode.getId(), segment.getId()); |
| | | List<String> blackPath = this.getBlackPathList(unfinishedOriginJamByCurrAgv); |
| | | |
| | | // 结果集 |
| | | List<String> pathList = new ArrayList<>(); |
| | | |
| | | // 无障碍解 |
| | | List<String> unlockPathList = mapService.checkoutPath(agvNo, startCode, endCode, false, blackPath); |
| | | List<String> unlockPathList = mapService.checkoutPath(agvNo, startCode, endCode, false, blackPath, segment); |
| | | // 避让解 |
| | | List<String> lockPathList = mapService.checkoutPath(agvNo, startCode, endCode, true, blackPath); |
| | | List<String> lockPathList = mapService.checkoutPath(agvNo, startCode, endCode, true, blackPath, segment); |
| | | |
| | | if (!Cools.isEmpty(lockPathList) && // 存在避让解 |
| | | Math.abs(lockPathList.size() - unlockPathList.size()) <= Arrays.stream(mapDataDispatcher.getCodeMatrix(lev)).mapToInt(row -> row.length).sum() / 10 |
| | |
| | | import com.zy.acs.manager.core.service.LaneService; |
| | | import com.zy.acs.manager.core.service.astart.domain.DynamicNode; |
| | | import com.zy.acs.manager.manager.entity.Route; |
| | | import com.zy.acs.manager.manager.service.AgvService; |
| | | import com.zy.acs.manager.manager.entity.Segment; |
| | | import com.zy.acs.manager.manager.service.CodeService; |
| | | import com.zy.acs.manager.manager.service.JamService; |
| | | import com.zy.acs.manager.manager.service.RouteService; |
| | | import com.zy.acs.manager.system.service.ConfigService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | |
| | | public static final boolean OPEN_TURN_COST_WEIGHT = Boolean.FALSE; |
| | | |
| | | public static final int WEIGHT_CALC_FACTOR = 1; |
| | | |
| | | @Autowired |
| | | private CodeService codeService; |
| | | @Autowired |
| | |
| | | @Autowired |
| | | private MapDataDispatcher mapDataDispatcher; |
| | | @Autowired |
| | | private AgvService agvService; |
| | | private JamService jamService; |
| | | @Autowired |
| | | private LaneService laneService; |
| | | @Autowired |
| | | private ConfigService configService; |
| | | |
| | | public synchronized NavigateNode execute(String agvNo, NavigateNode start, NavigateNode end |
| | | , Boolean lock, List<String> blackList) { |
| | | , Boolean lock, List<String> blackList, Segment segment) { |
| | | if (start.getX() == end.getX() && start.getY() == end.getY()) { |
| | | return end; |
| | | } |
| | |
| | | ArrayList<NavigateNode> neighbourNodes = this.getNeighborNodes(currentNode, mapMatrix, existNodes); |
| | | // 对这个结点遍历,看是否有目标结点出现 |
| | | label: for (NavigateNode node : neighbourNodes) { |
| | | |
| | | int weight = 0; |
| | | // 节点存在其他车辆 |
| | | // for (VehicleDto vehicleDto : vehicleDtoList) { |
| | | // if (node.getCodeData().equals(vehicleDto.getPosCode())) { |
| | |
| | | assert !vehicle.equals(DynamicNodeType.BLOCK.val); |
| | | if (!vehicle.equals(DynamicNodeType.ACCESS.val)) { |
| | | if (!vehicle.equals(agvNo)) { |
| | | |
| | | // 存在车辆,且为已经避让的车,则权重值增加 |
| | | if (null != segment) { |
| | | if (!Cools.isEmpty(jamService.getJamFromSegmentByAvo(segment, vehicle))) { |
| | | weight += WEIGHT_CALC_FACTOR; |
| | | } |
| | | } |
| | | |
| | | if (lock) { |
| | | continue; |
| | |
| | | int gCost = calcNodeCost(currentNode, node) * (OPEN_TURN_COST_WEIGHT ? calcNodeTurnCost(currentNode, node, end) : 1); |
| | | |
| | | //进行计算对 G, F, H 等值 |
| | | node.setWeight(weight); |
| | | node.setLastDistance(gCost); |
| | | node.initNode(currentNode, end); |
| | | node.setH(calcNodeCost(node, end)); |
| | |
| | | |
| | | //计算通过现在的结点的位置和最终结点的位置计算H值(曼哈顿法:坐标分别取差值相加) |
| | | private int calcNodeCost(NavigateNode node1, NavigateNode node2) { |
| | | // Code code1 = codeService.selectByData(node1.getCodeData()); |
| | | // Code code2 = codeService.selectByData(node2.getCodeData()); |
| | | // return (int) (Math.abs(code2.getX() - code1.getX()) + Math.abs(code2.getY() - code1.getY())); |
| | | |
| | | return Math.abs(node2.getX() - node1.getX()) + Math.abs(node2.getY() - node1.getY()); |
| | | } |
| | |
| | | private String direction; //行走方向 |
| | | private Integer lastDistance; // 距离上个节点距离 |
| | | private Integer moveDistance; // 总行走距离 |
| | | private Integer weight; // G 权重 |
| | | |
| | | private String codeData; |
| | | |
| | |
| | | this.parent = father; |
| | | if (this.parent != null) { |
| | | //走过的步数等于父节点走过的步数加一 |
| | | this.G = father.G + Optional.ofNullable(this.lastDistance).orElse(0); |
| | | this.G = father.G |
| | | + Optional.ofNullable(this.lastDistance).orElse(0) |
| | | + Optional.ofNullable(this.weight).orElse(0); |
| | | } else { //父节点为空代表它是第一个结点 |
| | | this.G = 0; |
| | | } |
| | |
| | | |
| | | List<Jam> selectUnfinishedJamByAvo(@Param("avoAgv")Long avoAgv, @Param("currCode")Long currCode, @Param("currSeg")Long currSeg); |
| | | |
| | | List<Jam> selectJamFromSegmentByAvo(@Param("jamSeg")Long jamSeg, @Param("avoAgv")Long avoAgv); |
| | | |
| | | } |
| | |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.zy.acs.manager.manager.entity.Jam; |
| | | import com.zy.acs.manager.manager.entity.Segment; |
| | | import com.zy.acs.manager.manager.enums.JamStateType; |
| | | |
| | | import java.util.List; |
| | |
| | | |
| | | Jam getJam(Long agvId, Long jamCode, Long jamSeg); |
| | | |
| | | List<Jam> hasUnfinishedOriginJamByAvo(Long avoAgv, Long currCode, Long currSeg); |
| | | List<Jam> getUnfinishedOriginJamByAvo(Long avoAgv, Long currCode, Long currSeg); |
| | | |
| | | Jam getCycleJam(Long jamAgv, Long jamSeg, String avoAgvNo); |
| | | |
| | | List<Jam> getJamFromSegmentByAvo(Segment jamSeg, String avoAgvNo); |
| | | |
| | | List<Jam> queryByAvoid(Long avoAgv, JamStateType jamState); |
| | | |
| | | Boolean checkIfFinish(Long avoAgv, String currCodeData); |
| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.zy.acs.framework.common.Cools; |
| | | import com.zy.acs.manager.manager.entity.Agv; |
| | | import com.zy.acs.manager.manager.entity.Code; |
| | | import com.zy.acs.manager.manager.entity.Jam; |
| | | import com.zy.acs.manager.manager.entity.Segment; |
| | | import com.zy.acs.manager.manager.enums.JamStateType; |
| | | import com.zy.acs.manager.manager.mapper.JamMapper; |
| | | import com.zy.acs.manager.manager.service.AgvService; |
| | |
| | | * 你的下一个segment是不是又会导致阻塞 |
| | | */ |
| | | @Override |
| | | public List<Jam> hasUnfinishedOriginJamByAvo(Long avoAgv, Long currCode, Long currSeg) { |
| | | public List<Jam> getUnfinishedOriginJamByAvo(Long avoAgv, Long currCode, Long currSeg) { |
| | | return this.baseMapper.selectUnfinishedJamByAvo(avoAgv, null, null); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<Jam> getJamFromSegmentByAvo(Segment jamSeg, String avoAgvNo) { |
| | | Agv avoAgv = agvService.selectByUuid(avoAgvNo); |
| | | return this.baseMapper.selectJamFromSegmentByAvo(jamSeg.getId(), avoAgv.getId()); |
| | | } |
| | | |
| | | @Override |
| | | public List<Jam> queryByAvoid(Long avoAgv, JamStateType jamState) { |
| | | if (null == avoAgv) { |
| | | return null; |
| | |
| | | </if> |
| | | </select> |
| | | |
| | | <select id="selectJamFromSegmentByAvo" resultType="com.zy.acs.manager.manager.entity.Jam"> |
| | | SELECT |
| | | mj.* |
| | | FROM man_jam mj |
| | | LEFT JOIN man_segment jam_seg ON mj.jam_seg = jam_seg.id |
| | | LEFT JOIN man_segment avo_seg ON mj.avo_seg = avo_seg.id |
| | | WHERE 1=1 |
| | | AND avo_seg.state NOT IN ('INIT', 'WAITING') |
| | | AND mj.jam_seg = #{jamSeg} |
| | | AND mj.avo_agv = #{avoAgv} |
| | | </select> |
| | | |
| | | </mapper> |