#
Junjie
2024-10-17 cab87dcfaa7b1e2bc1298572b775026bb17ef38b
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/model/NavigateNode.java
@@ -2,15 +2,21 @@
import lombok.Data;
import java.io.Serializable;
import java.util.Optional;
/**
 * A*寻路算法Node节点
 */
@Data
public class NavigateNode implements Comparable<NavigateNode>{
public class NavigateNode implements Comparable<NavigateNode>, Cloneable, Serializable {
    private static final long serialVersionUID = 1L;
    private int x;//坐标x
    private int y;//坐标y
    private int z;//坐标z(高度)
    private Integer lastDistance;//步数
    private int F;//综合花费的步数
    private int G;//已经花费的步数
    private int H;//将要花费的步数
@@ -29,8 +35,8 @@
    public void init_node(NavigateNode father, NavigateNode end) {
        this.Father = father;
        if (this.Father != null) {
            //走过的步数等于父节点走过的步数加一
            this.G = father.G + 1;
            //走过的步数等于父节点走过的步数加最新步数
            this.G = father.G + Optional.ofNullable(this.lastDistance).orElse(0);
        } else { //父节点为空代表它是第一个结点
            this.G = 0;
        }
@@ -46,4 +52,13 @@
        return Integer.compare(this.F, o.F);
    }
    @Override
    public NavigateNode clone() {
        try {
            return (NavigateNode) super.clone();
        } catch (CloneNotSupportedException e) {
            e.printStackTrace();
        }
        return null;
    }
}