|
|
@ -4,6 +4,7 @@ import com.galaxis.rcs.common.enums.LCCDirection; |
|
|
import com.galaxis.rcs.plan.PlanTaskSequence; |
|
|
import com.galaxis.rcs.plan.PlanTaskSequence; |
|
|
import com.galaxis.rcs.plan.task.*; |
|
|
import com.galaxis.rcs.plan.task.*; |
|
|
import com.google.common.base.Strings; |
|
|
import com.google.common.base.Strings; |
|
|
|
|
|
import com.google.common.collect.Lists; |
|
|
import com.yvan.logisticsModel.StaticItem; |
|
|
import com.yvan.logisticsModel.StaticItem; |
|
|
import org.clever.core.Conv; |
|
|
import org.clever.core.Conv; |
|
|
|
|
|
|
|
|
@ -76,21 +77,24 @@ public class PtrPathPlanner { |
|
|
// 取货点
|
|
|
// 取货点
|
|
|
String loadRackId = task.from().rackId(); |
|
|
String loadRackId = task.from().rackId(); |
|
|
int pickupBay = task.from().bay(); |
|
|
int pickupBay = task.from().bay(); |
|
|
NodeDirection loadNodeDirection = findNodeForStore(loadRackId, pickupBay); |
|
|
List<NodeDirection> loadNodeDirectionList = findNodeForStore(loadRackId, pickupBay); |
|
|
if (loadNodeDirection == null) { |
|
|
if (loadNodeDirectionList.isEmpty()) { |
|
|
throw new RuntimeException("Pickup node not found for rackId=" + loadRackId + ", bay=" + pickupBay); |
|
|
throw new RuntimeException("Pickup node not found for rackId=" + loadRackId + ", bay=" + pickupBay); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 放货点
|
|
|
// 放货点
|
|
|
String unloadRackId = task.to().rackId(); |
|
|
String unloadRackId = task.to().rackId(); |
|
|
int unloadBay = task.to().bay(); |
|
|
int unloadBay = task.to().bay(); |
|
|
NodeDirection unloadNodeDirection = findNodeForStore(unloadRackId, unloadBay); |
|
|
List<NodeDirection> unloadNodeDirectionList = findNodeForStore(unloadRackId, unloadBay); |
|
|
if (unloadNodeDirection == null) { |
|
|
if (unloadNodeDirectionList.isEmpty()) { |
|
|
throw new RuntimeException("Drop node not found for rackId=" + unloadRackId + ", bay=" + unloadBay); |
|
|
throw new RuntimeException("Drop node not found for rackId=" + unloadRackId + ", bay=" + unloadBay); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 规划到取货点路径
|
|
|
// 规划到取货点路径
|
|
|
List<State> toLoadPath = astar.findPath(startNodeId, startDirection, loadNodeDirection.node().id(), loadNodeDirection.direction()); |
|
|
var toLoadPathResult = astar.findPathList(startNodeId, startDirection, loadNodeDirectionList); |
|
|
|
|
|
|
|
|
|
|
|
var toLoadPath = toLoadPathResult.path(); |
|
|
|
|
|
var loadNodeDirection = toLoadPathResult.end(); |
|
|
|
|
|
|
|
|
// 检查方向是否匹配,如果不匹配则插入旋转点
|
|
|
// 检查方向是否匹配,如果不匹配则插入旋转点
|
|
|
if (!toLoadPath.isEmpty()) { |
|
|
if (!toLoadPath.isEmpty()) { |
|
|
@ -119,7 +123,8 @@ public class PtrPathPlanner { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 规划到放货点路径
|
|
|
// 规划到放货点路径
|
|
|
List<State> toUnloadPath = astar.findPath(loadNodeDirection.node().id(), loadNodeDirection.direction(), unloadNodeDirection.node().id(), unloadNodeDirection.direction()); |
|
|
var toUnloadPathResult = astar.findPathList(loadNodeDirection.node().id(), loadNodeDirection.direction(), unloadNodeDirectionList); |
|
|
|
|
|
var toUnloadPath = toUnloadPathResult.path(); |
|
|
|
|
|
|
|
|
// 生成指令序列
|
|
|
// 生成指令序列
|
|
|
generateMoves(plan, toLoadPath); |
|
|
generateMoves(plan, toLoadPath); |
|
|
@ -138,13 +143,14 @@ public class PtrPathPlanner { |
|
|
// 放货点
|
|
|
// 放货点
|
|
|
String unloadRackId = task.to().rackId(); |
|
|
String unloadRackId = task.to().rackId(); |
|
|
int unloadBay = task.to().bay(); |
|
|
int unloadBay = task.to().bay(); |
|
|
NodeDirection unloadNodeDirection = findNodeForStore(unloadRackId, unloadBay); |
|
|
var unloadNodeDirectionList = findNodeForStore(unloadRackId, unloadBay); |
|
|
if (unloadNodeDirection == null) { |
|
|
if (unloadNodeDirectionList.isEmpty()) { |
|
|
throw new RuntimeException("Drop node not found for rackId=" + unloadRackId + ", bay=" + unloadBay); |
|
|
throw new RuntimeException("Drop node not found for rackId=" + unloadRackId + ", bay=" + unloadBay); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 规划到放货点路径
|
|
|
// 规划到放货点路径
|
|
|
List<State> toUnloadPath = astar.findPath(startNodeId, startDirection, unloadNodeDirection.node().id(), unloadNodeDirection.direction()); |
|
|
var toUnloadPathList = astar.findPathList(startNodeId, startDirection, unloadNodeDirectionList); |
|
|
|
|
|
var toUnloadPath = toUnloadPathList.path(); |
|
|
|
|
|
|
|
|
// 检查方向是否匹配,如果不匹配则插入旋转点
|
|
|
// 检查方向是否匹配,如果不匹配则插入旋转点
|
|
|
// State lastState = toUnloadPath.get(toUnloadPath.size() - 1);
|
|
|
// State lastState = toUnloadPath.get(toUnloadPath.size() - 1);
|
|
|
@ -184,13 +190,14 @@ public class PtrPathPlanner { |
|
|
// 放货点
|
|
|
// 放货点
|
|
|
String loadRackId = task.to().rackId(); |
|
|
String loadRackId = task.to().rackId(); |
|
|
int unloadBay = task.to().bay(); |
|
|
int unloadBay = task.to().bay(); |
|
|
NodeDirection loadNodeDirection = findNodeForStore(loadRackId, unloadBay); |
|
|
var loadNodeDirectionList = findNodeForStore(loadRackId, unloadBay); |
|
|
if (loadNodeDirection == null) { |
|
|
if (loadNodeDirectionList.isEmpty()) { |
|
|
throw new RuntimeException("Drop node not found for rackId=" + loadRackId + ", bay=" + unloadBay); |
|
|
throw new RuntimeException("Drop node not found for rackId=" + loadRackId + ", bay=" + unloadBay); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 规划到取货点路径
|
|
|
// 规划到取货点路径
|
|
|
List<State> toLoadPath = astar.findPath(startNodeId, startDirection, loadNodeDirection.node().id(), loadNodeDirection.direction()); |
|
|
var toLoadPathList = astar.findPathList(startNodeId, startDirection, loadNodeDirectionList); |
|
|
|
|
|
var toLoadPath = toLoadPathList.path(); |
|
|
|
|
|
|
|
|
// 检查方向是否匹配,如果不匹配则插入旋转点
|
|
|
// 检查方向是否匹配,如果不匹配则插入旋转点
|
|
|
// State lastState = toLoadPath.get(toLoadPath.size() - 1);
|
|
|
// State lastState = toLoadPath.get(toLoadPath.size() - 1);
|
|
|
@ -223,17 +230,18 @@ public class PtrPathPlanner { |
|
|
plan.addFinish(); |
|
|
plan.addFinish(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private NodeDirection findNodeForStore(String storeId, int bay) { |
|
|
private List<NodeDirection> findNodeForStore(String storeId, int bay) { |
|
|
List<Node> nodes = this.graph.getNodesForStore(storeId); |
|
|
List<Node> nodes = this.graph.getNodesForStore(storeId); |
|
|
|
|
|
List<NodeDirection> results = Lists.newArrayList(); |
|
|
for (Node node : nodes) { |
|
|
for (Node node : nodes) { |
|
|
for (StoreLink link : node.storeLinks()) { |
|
|
for (StoreLink link : node.storeLinks()) { |
|
|
if (link.storeId().equals(storeId) && link.bay() == bay) { |
|
|
if (link.storeId().equals(storeId) && link.bay() == bay) { |
|
|
LCCDirection agvDirection = convertStoreDirection(link.direction()); |
|
|
LCCDirection agvDirection = convertStoreDirection(link.direction()); |
|
|
return new NodeDirection(node, agvDirection); |
|
|
results.add(new NodeDirection(node, agvDirection)); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
return null; |
|
|
return results; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
@ -273,6 +281,6 @@ public class PtrPathPlanner { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 辅助记录类
|
|
|
// 辅助记录类
|
|
|
private record NodeDirection(Node node, LCCDirection direction) { |
|
|
public record NodeDirection(Node node, LCCDirection direction) { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|