1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package com.mes.interaction.vehicle.model;
 
import lombok.Data;
 
/**
 * 车辆位置信息
 * 
 * @author huang
 * @since 2025-11-21
 */
@Data
public class VehiclePosition {
    /**
     * X坐标
     */
    private Double x;
    
    /**
     * Y坐标
     */
    private Double y;
    
    /**
     * Z坐标(如果需要)
     */
    private Double z;
    
    /**
     * 位置编码(如:POS1, POS2)
     */
    private String positionCode;
    
    /**
     * 位置值(PLC中的位置值)
     */
    private Integer positionValue;
    
    public VehiclePosition() {
    }
    
    public VehiclePosition(Double x, Double y) {
        this.x = x;
        this.y = y;
    }
    
    public VehiclePosition(String positionCode, Integer positionValue) {
        this.positionCode = positionCode;
        this.positionValue = positionValue;
    }
    
    /**
     * 计算到目标位置的距离
     */
    public double distanceTo(VehiclePosition target) {
        if (x == null || y == null || target.x == null || target.y == null) {
            return 0.0;
        }
        double dx = target.x - x;
        double dy = target.y - y;
        return Math.sqrt(dx * dx + dy * dy);
    }
}