package dell_suanfa;
|
|
import databases.DBConnector;
|
import dell_system.GeneralAlgorithm;
|
|
import java.sql.ResultSet;
|
import java.sql.SQLException;
|
import java.util.ArrayList;
|
import java.util.List;
|
|
// ͨÓÃËã·¨ÅäÖÃÊý¾Ý²Ù×÷Àà
|
public class Dell_GeneralAlgorithm {
|
|
// »ñÈ¡ËùÓÐͨÓÃËã·¨ÅäÖÃ
|
public static List<GeneralAlgorithm> getAllGeneralAlgorithms() throws SQLException {
|
List<GeneralAlgorithm> algorithms = new ArrayList<>(); // ´´½¨Ëã·¨ÅäÖÃÁбí
|
// ²éѯͨÓÃËã·¨ÅäÖñíÊý¾Ý
|
ResultSet rs = DBConnector.queryTableData("general_algorithm");
|
|
while (rs.next()) { // ±éÀú½á¹û¼¯
|
GeneralAlgorithm algorithm = new GeneralAlgorithm(); // ´´½¨Ëã·¨ÅäÖöÔÏó
|
// ÉèÖÃËã·¨ÊôÐÔ
|
algorithm.setId(rs.getString("id"));
|
algorithm.setGnssToXy(rs.getString("gnss_to_xy"));
|
algorithm.setAreaJudgeIndoor(rs.getString("area_judge_indoor"));
|
algorithm.setDistanceJudgeIndoor(rs.getString("distance_judge_indoor"));
|
algorithm.setSatelliteSignalJudgeIndoor(rs.getString("satellite_signal_judge_indoor"));
|
algorithm.setBlurPositionCalculation(rs.getString("blur_position_calculation"));
|
algorithm.setTimeSlotAllocation(rs.getString("time_slot_allocation"));
|
algorithm.setFilterAlgorithm(rs.getString("filter_algorithm"));
|
algorithm.setSatelliteSignalFilterValue(rs.getString("satellite_signal_filter_value"));
|
algorithm.setPositionFilterValue(rs.getString("position_filter_value"));
|
algorithm.setCloseUwbCondition(rs.getString("close_uwb_condition"));
|
algorithm.setStaticFilterValue(rs.getString("static_filter_value"));
|
algorithm.setSystemMaxSpeed(rs.getString("system_max_speed"));
|
algorithm.setMaxRepeatRanging(rs.getString("max_repeat_ranging"));
|
algorithm.setFilterLevel(rs.getString("filter_level"));
|
algorithm.setJudge0dByPosition(rs.getString("judge_0d_by_position"));
|
algorithm.setCompany(rs.getString("company"));
|
algorithm.setReserved1(rs.getString("reserved1"));
|
algorithm.setReserved2(rs.getString("reserved2"));
|
algorithm.setReserved3(rs.getString("reserved3"));
|
algorithm.setReserved4(rs.getString("reserved4"));
|
algorithm.setReserved5(rs.getString("reserved5"));
|
algorithm.setReserved6(rs.getString("reserved6"));
|
algorithm.setModifyTime(rs.getString("modify_time"));
|
|
algorithms.add(algorithm); // Ìí¼Óµ½Áбí
|
}
|
return algorithms; // ·µ»ØËã·¨ÅäÖÃÁбí
|
}
|
|
// Ìí¼ÓÐÂËã·¨ÅäÖÃ
|
public static void insertGeneralAlgorithm(GeneralAlgorithm algorithm) throws SQLException {
|
// ²åÈëSQLÓï¾ä
|
String sql = "INSERT INTO general_algorithm ("
|
+ "gnss_to_xy, area_judge_indoor, distance_judge_indoor, "
|
+ "satellite_signal_judge_indoor, blur_position_calculation, "
|
+ "time_slot_allocation, filter_algorithm, satellite_signal_filter_value, "
|
+ "position_filter_value, close_uwb_condition, static_filter_value, "
|
+ "system_max_speed, max_repeat_ranging, filter_level, "
|
+ "judge_0d_by_position, company, modify_time, "
|
+ "reserved1, reserved2, reserved3, reserved4, reserved5, reserved6) "
|
+ "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
|
// Ö´ÐиüвÙ×÷
|
DBConnector.executeUpdate(sql,
|
algorithm.getGnssToXy(),
|
algorithm.getAreaJudgeIndoor(),
|
algorithm.getDistanceJudgeIndoor(),
|
algorithm.getSatelliteSignalJudgeIndoor(),
|
algorithm.getBlurPositionCalculation(),
|
algorithm.getTimeSlotAllocation(),
|
algorithm.getFilterAlgorithm(),
|
algorithm.getSatelliteSignalFilterValue(),
|
algorithm.getPositionFilterValue(),
|
algorithm.getCloseUwbCondition(),
|
algorithm.getStaticFilterValue(),
|
algorithm.getSystemMaxSpeed(),
|
algorithm.getMaxRepeatRanging(),
|
algorithm.getFilterLevel(),
|
algorithm.getJudge0dByPosition(),
|
algorithm.getCompany(),
|
algorithm.getModifyTime(),
|
algorithm.getReserved1(),
|
algorithm.getReserved2(),
|
algorithm.getReserved3(),
|
algorithm.getReserved4(),
|
algorithm.getReserved5(),
|
algorithm.getReserved6());
|
}
|
|
// ¸üÐÂËã·¨ÅäÖÃ
|
public static void updateGeneralAlgorithm(GeneralAlgorithm algorithm) throws SQLException {
|
// ¸üÐÂSQLÓï¾ä
|
String sql = "UPDATE general_algorithm SET "
|
+ "gnss_to_xy = ?, area_judge_indoor = ?, distance_judge_indoor = ?, "
|
+ "satellite_signal_judge_indoor = ?, blur_position_calculation = ?, "
|
+ "time_slot_allocation = ?, filter_algorithm = ?, satellite_signal_filter_value = ?, "
|
+ "position_filter_value = ?, close_uwb_condition = ?, static_filter_value = ?, "
|
+ "system_max_speed = ?, max_repeat_ranging = ?, filter_level = ?, "
|
+ "judge_0d_by_position = ?, company = ?, modify_time = ?, "
|
+ "reserved1 = ?, reserved2 = ?, reserved3 = ?, reserved4 = ?, reserved5 = ?, reserved6 = ? "
|
+ "WHERE id = ?";
|
|
// Ö´ÐиüвÙ×÷
|
DBConnector.executeUpdate(sql,
|
algorithm.getGnssToXy(),
|
algorithm.getAreaJudgeIndoor(),
|
algorithm.getDistanceJudgeIndoor(),
|
algorithm.getSatelliteSignalJudgeIndoor(),
|
algorithm.getBlurPositionCalculation(),
|
algorithm.getTimeSlotAllocation(),
|
algorithm.getFilterAlgorithm(),
|
algorithm.getSatelliteSignalFilterValue(),
|
algorithm.getPositionFilterValue(),
|
algorithm.getCloseUwbCondition(),
|
algorithm.getStaticFilterValue(),
|
algorithm.getSystemMaxSpeed(),
|
algorithm.getMaxRepeatRanging(),
|
algorithm.getFilterLevel(),
|
algorithm.getJudge0dByPosition(),
|
algorithm.getCompany(),
|
algorithm.getModifyTime(),
|
algorithm.getReserved1(),
|
algorithm.getReserved2(),
|
algorithm.getReserved3(),
|
algorithm.getReserved4(),
|
algorithm.getReserved5(),
|
algorithm.getReserved6(),
|
algorithm.getId());
|
}
|
|
// ɾ³ýËã·¨ÅäÖÃ
|
public static void deleteGeneralAlgorithm(int algorithmId) throws SQLException {
|
// ɾ³ýSQLÓï¾ä
|
String sql = "DELETE FROM general_algorithm WHERE id = ?";
|
// Ö´ÐÐɾ³ý²Ù×÷
|
DBConnector.executeUpdate(sql, algorithmId);
|
}
|
|
// »ñȡͨÓÃËã·¨ÅäÖã¨ÏµÍ³Í¨³£Ö»ÓÐÒ»ÌõÅäÖã©
|
public static GeneralAlgorithm getSystemGeneralAlgorithm() throws SQLException {
|
List<GeneralAlgorithm> algorithms = getAllGeneralAlgorithms();
|
if (!algorithms.isEmpty()) {
|
return algorithms.get(0); // ·µ»ØµÚÒ»ÌõÅäÖÃ
|
}
|
return null; // ûÓÐÅäÖÃʱ·µ»Ønull
|
}
|
|
// ¸üÐÂϵͳͨÓÃËã·¨ÅäÖ㨸üеÚÒ»Ìõ¼Ç¼£©
|
public static void updateSystemGeneralAlgorithm(GeneralAlgorithm algorithm) throws SQLException {
|
// È·±£ÓÐID£¨Í¨³£Îª1£©
|
if (algorithm.getId() == null || algorithm.getId().isEmpty()) {
|
GeneralAlgorithm existing = getSystemGeneralAlgorithm();
|
if (existing != null) {
|
algorithm.setId(existing.getId());
|
} else {
|
algorithm.setId("1");
|
}
|
}
|
updateGeneralAlgorithm(algorithm);
|
}
|
}
|