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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
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);
    }
}