826220679@qq.com
2025-08-07 4d6cd980c5c69e4d9d150669c89734642297e0cd
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
package dell_targets;
import databases.DBConnector;
import targets.DifferentialBaseStation;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
 
public class Dell_differentialBaseStation {
    // »ñÈ¡ËùÓлùÕ¾
    public static List<DifferentialBaseStation> getAllBaseStations() throws SQLException {
        List<DifferentialBaseStation> stations = new ArrayList<>();
        ResultSet rs = DBConnector.queryTableData("differential_base_station");
        while (rs.next()) {
            DifferentialBaseStation station = new DifferentialBaseStation();
            station.setId(rs.getInt("id"));
            station.setDeviceNumber(rs.getString("device_number"));
            station.setIpAddress(rs.getString("ip_address"));
            station.setCommunicationPort(rs.getString("communication_port"));
            station.setCoverageDistance(rs.getString("coverage_distance"));
            station.setSendAddress(rs.getString("send_address"));
            station.setSendPort(rs.getString("send_port"));
            station.setXCoordinate(rs.getString("x_coordinate"));
            station.setYCoordinate(rs.getString("y_coordinate"));
            station.setZCoordinate(rs.getString("z_coordinate"));
            station.setLayer(rs.getString("layer"));
            station.setLongitude(rs.getString("longitude"));
            station.setLatitude(rs.getString("latitude"));
            station.setElevation(rs.getString("elevation"));
            station.setVersion(rs.getString("versions")); // ×¢ÒâÊý¾Ý¿â×Ö¶ÎÃûÊÇversions
            station.setDeviceStatus(rs.getString("device_status"));
            station.setAddTime(rs.getString("add_time"));
            station.setLastHeartbeatTime(rs.getString("last_heartbeat_time"));
            station.setIotCardNumber(rs.getString("iot_card_number"));
            station.setCompany(rs.getString("company"));
            stations.add(station);
        }
        return stations;
    }
 
    // É¾³ý»ùÕ¾
    public static void deleteBaseStation(String device_number) throws SQLException {
        String sql = "DELETE FROM differential_base_station WHERE device_number = ?";
        DBConnector.executeUpdate(sql, device_number);
    }
 
    // ÐÂÔö»ùÕ¾
    public static void insertBaseStation(DifferentialBaseStation station) throws SQLException {
        String sql = "INSERT INTO differential_base_station (device_number, ip_address, communication_port, "
                + "coverage_distance, send_address, send_port, x_coordinate, y_coordinate, "
                + "z_coordinate, layer, longitude, latitude, elevation, versions, "
                + "device_status, add_time, last_heartbeat_time, iot_card_number, company) " +
                     "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
        DBConnector.executeUpdate(sql,
            station.getDeviceNumber(),
            station.getIpAddress(),
            station.getCommunicationPort(),
            station.getCoverageDistance(),
            station.getSendAddress(),
            station.getSendPort(),
            station.getXCoordinate(),
            station.getYCoordinate(),
            station.getZCoordinate(),
            station.getLayer(),
            station.getLongitude(),
            station.getLatitude(),
            station.getElevation(),
            station.getVersion(),
            station.getDeviceStatus(),
            station.getAddTime(),
            station.getLastHeartbeatTime(),
            station.getIotCardNumber(),
            station.getCompany());
    }
 
    // ¸üлùÕ¾
    public static void updateBaseStation(DifferentialBaseStation station) throws SQLException {
        String sql = "UPDATE differential_base_station SET device_number=?, ip_address=?, "
                + "communication_port=?, coverage_distance=?, send_address=?, "
                + "send_port=?, x_coordinate=?, y_coordinate=?, z_coordinate=?, "
                + "layer=?, longitude=?, latitude=?, elevation=?, versions=?, "
                + "device_status=?, add_time=?, last_heartbeat_time=?, "
                + "iot_card_number=?, company=? WHERE id=?";
        DBConnector.executeUpdate(sql,
            station.getDeviceNumber(),
            station.getIpAddress(),
            station.getCommunicationPort(),
            station.getCoverageDistance(),
            station.getSendAddress(),
            station.getSendPort(),
            station.getXCoordinate(),
            station.getYCoordinate(),
            station.getZCoordinate(),
            station.getLayer(),
            station.getLongitude(),
            station.getLatitude(),
            station.getElevation(),
            station.getVersion(),
            station.getDeviceStatus(),
            station.getAddTime(),
            station.getLastHeartbeatTime(),
            station.getIotCardNumber(),
            station.getCompany(),
            station.getId());
    }
}