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 getAllBaseStations() throws SQLException { List 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()); } }