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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
package dell_suanfa; // ¶¨Òå°üÃû
import javax.swing.*; // µ¼ÈëSwing×é¼þ
import javax.swing.border.EmptyBorder; // µ¼Èë¿Õ±ß¿ò
import javax.swing.border.TitledBorder; // µ¼Èë´ø±êÌâ±ß¿ò
import java.awt.*; // µ¼ÈëAWT×é¼þ
import java.awt.event.ItemEvent; // µ¼ÈëÏîĿʼþ
import java.awt.event.ItemListener; // µ¼ÈëÏîÄ¿¼àÌýÆ÷
import java.sql.SQLException; // µ¼ÈëSQLÒì³£
import java.text.SimpleDateFormat; // µ¼Èë¼òµ¥ÈÕÆÚ¸ñʽ
import java.util.Date; // µ¼ÈëÈÕÆÚÀà
import java.util.HashMap; // µ¼Èë¹þÏ£Ó³Éä
import java.util.Map; // µ¼ÈëÓ³Éä½Ó¿Ú
import java.util.ResourceBundle; // µ¼Èë×ÊÔ´Êø
import dell_system.Dell_company; // µ¼È빫˾Àà
import dell_system.GeneralAlgorithm;
import databases.DBConnector; // µ¼ÈëÊý¾Ý¿âÁ¬½ÓÆ÷
 
public class GeneralAlgorithmPanel extends JPanel { // Í¨ÓÃËã·¨Ãæ°åÀà
    private static final long serialVersionUID = 1L; // ÐòÁл¯°æ±¾ID
    private ResourceBundle messages; // ¹ú¼Ê»¯ÏûÏ¢×ÊÔ´
    private GeneralAlgorithm currentAlgorithm; // µ±Ç°Ëã·¨¶ÔÏó
 
    // UI×é¼þÉùÃ÷
    private JComboBox<String> companyComboBox; // ¹«Ë¾Ñ¡ÔñÏÂÀ­¿ò
    private JTextField satelliteSignalFilterField; // ÎÀÐÇÐźŹýÂË×Ö¶Î
    private JTextField positionFilterField; // Î»ÖùýÂË×Ö¶Î
    private JTextField closeUwbConditionField; // ¹Ø±ÕUWBÌõ¼þ×Ö¶Î
    private JTextField staticFilterField; // ¾²Ì¬¹ýÂË×Ö¶Î
    private JTextField systemMaxSpeedField; // ÏµÍ³×î´óËÙ¶È×Ö¶Î
    private JTextField maxRepeatRangingField; // ×î´óÖØ¸´²â¾à×Ö¶Î
    private JTextField filterLevelField; // ¹ýÂ˼¶±ð×Ö¶Î
    private JRadioButton gnssToXyEnabled; // GNSSתXYÆôÓÃ
    private JRadioButton gnssToXyDisabled; // GNSSתXY½ûÓÃ
    private JRadioButton areaJudgeIndoorEnabled; // ÇøÓòÅжÏÊÒÄÚÆôÓÃ
    private JRadioButton areaJudgeIndoorDisabled; // ÇøÓòÅжÏÊÒÄÚ½ûÓÃ
    private JRadioButton distanceJudgeIndoorEnabled; // ¾àÀëÅжÏÊÒÄÚÆôÓÃ
    private JRadioButton distanceJudgeIndoorDisabled; // ¾àÀëÅжÏÊÒÄÚ½ûÓÃ
    private JRadioButton satelliteSignalJudgeIndoorEnabled; // ÎÀÐÇÐźÅÅжÏÊÒÄÚÆôÓÃ
    private JRadioButton satelliteSignalJudgeIndoorDisabled; // ÎÀÐÇÐźÅÅжÏÊÒÄÚ½ûÓÃ
    private JRadioButton blurPositionCalculationEnabled; // Ä£ºýλÖüÆËãÆôÓÃ
    private JRadioButton blurPositionCalculationDisabled; // Ä£ºýλÖüÆËã½ûÓÃ
    private JRadioButton timeSlotAllocationMix; // Ê±Ï¶·ÖÅä»ìºÏģʽ
    private JRadioButton timeSlotAllocationGap; // Ê±Ï¶·ÖÅä¼ä¸ôģʽ
    private JRadioButton filterAlgorithmLowPass; // µÍͨÂ˲¨Ëã·¨
    private JRadioButton filterAlgorithmSliding; // »¬¶¯Â˲¨Ëã·¨
    private JRadioButton judge0dByPositionEnabled; // Î»ÖÃÅжÏ0DÆôÓÃ
    private JRadioButton judge0dByPositionDisabled; // Î»ÖÃÅжÏ0D½ûÓÃ
    private JTextField timeField; // Ê±¼ä×Ö¶Î
    private JButton saveButton; // ±£´æ°´Å¥
    private JButton cancelButton; // È¡Ïû°´Å¥
 
    public GeneralAlgorithmPanel(ResourceBundle messages) { // ¹¹Ô캯Êý
        this.messages = messages; // ³õʼ»¯ÏûÏ¢×ÊÔ´
        setLayout(new BorderLayout()); // ÉèÖñ߽粼¾Ö
        setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); // ÉèÖÃÃæ°å±ß¾à(5ÏñËØ)
        
        // Ö÷Ãæ°å
        JPanel mainPanel = new JPanel(); // ´´½¨Ö÷Ãæ°å
        mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS)); // ÉèÖô¹Ö±ºÐ²¼¾Ö
        mainPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); // ÉèÖÃÖ÷Ãæ°å±ß¾à
        
        // ¹«Ë¾Ñ¡ÔñÃæ°å
        JPanel companyPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 2)); // ×ó¶ÔÆëÁ÷ʽ²¼¾Ö
        JLabel companyLabel = new JLabel(getMessage("BELONGING_COMPANY") + ":"); // ¹«Ë¾±êÇ©
        companyComboBox = new JComboBox<>(); // ³õʼ»¯ÏÂÀ­¿ò
        companyComboBox.setPreferredSize(new Dimension(300, 25)); // ÉèÖÃÏÂÀ­¿ò³ß´ç
        companyPanel.add(companyLabel); // Ìí¼Ó±êÇ©
        companyPanel.add(companyComboBox); // Ìí¼ÓÏÂÀ­¿ò
        mainPanel.add(companyPanel); // Ìí¼Óµ½Ö÷Ãæ°å
        
        // Îı¾¿òÃæ°å
        JPanel textFieldsPanel = new JPanel(); // ´´½¨Îı¾¿òÃæ°å
        textFieldsPanel.setLayout(new GridLayout(0, 2, 5, 5)); // Íø¸ñ²¼¾Ö(2ÁÐ)
        textFieldsPanel.setBorder(BorderFactory.createCompoundBorder( // ×éºÏ±ß¿ò
            new TitledBorder(getMessage("TEXT_FIELDS")), // ±êÌâ±ß¿ò
            new EmptyBorder(3, 5, 3, 5) // µ÷Õû±êÌâÓëÄÚÈݼä¾à(ÉÏÏÂ3ÏñËØ)
        ));
        
        // Ìí¼Ó¹Ì¶¨¿í¶È(200ÏñËØ)µÄÎı¾¿ò
        addTextField(textFieldsPanel, getMessage("SATELLITE_SIGNAL_FILTER"), satelliteSignalFilterField = createFixedTextField(200));
        addTextField(textFieldsPanel, getMessage("POSITION_FILTER"), positionFilterField = createFixedTextField(200));
        addTextField(textFieldsPanel, getMessage("CLOSE_UWB_CONDITION"), closeUwbConditionField = createFixedTextField(200));
        addTextField(textFieldsPanel, getMessage("STATIC_FILTER"), staticFilterField = createFixedTextField(200));
        addTextField(textFieldsPanel, getMessage("SYSTEM_MAX_SPEED"), systemMaxSpeedField = createFixedTextField(200));
        addTextField(textFieldsPanel, getMessage("MAX_REPEAT_RANGING"), maxRepeatRangingField = createFixedTextField(200));
        addTextField(textFieldsPanel, getMessage("FILTER_LEVEL"), filterLevelField = createFixedTextField(200));
        
        mainPanel.add(textFieldsPanel); // Ìí¼Óµ½Ö÷Ãæ°å
        
        // µ¥Ñ¡°´Å¥Ãæ°å
        JPanel radioPanel = new JPanel(); // ´´½¨µ¥Ñ¡Ãæ°å
        radioPanel.setLayout(new GridLayout(0, 2, 5, 5)); // Íø¸ñ²¼¾Ö(2ÁÐ)
        radioPanel.setBorder(BorderFactory.createCompoundBorder( // ×éºÏ±ß¿ò
            new TitledBorder(getMessage("RADIO_BUTTONS")), // ±êÌâ±ß¿ò
            new EmptyBorder(3, 5, 3, 5) // µ÷Õû±êÌâÓëÄÚÈݼä¾à(ÉÏÏÂ3ÏñËØ)
        ));
        
        // Ìí¼Óµ¥Ñ¡°´Å¥×é
        addRadioGroup(radioPanel, getMessage("GNSS_TO_XY"), 
                     gnssToXyEnabled = createRedRadioButton(getMessage("ENABLED")), 
                     gnssToXyDisabled = createRedRadioButton(getMessage("DISABLED")));
        addRadioGroup(radioPanel, getMessage("AREA_JUDGE_INDOOR"), 
                     areaJudgeIndoorEnabled = createRedRadioButton(getMessage("ENABLED")), 
                     areaJudgeIndoorDisabled = createRedRadioButton(getMessage("DISABLED")));
        addRadioGroup(radioPanel, getMessage("DISTANCE_JUDGE_INDOOR"), 
                     distanceJudgeIndoorEnabled = createRedRadioButton(getMessage("ENABLED")), 
                     distanceJudgeIndoorDisabled = createRedRadioButton(getMessage("DISABLED")));
        addRadioGroup(radioPanel, getMessage("SATELLITE_SIGNAL_JUDGE_INDOOR"), 
                     satelliteSignalJudgeIndoorEnabled = createRedRadioButton(getMessage("ENABLED")), 
                     satelliteSignalJudgeIndoorDisabled = createRedRadioButton(getMessage("DISABLED")));
        addRadioGroup(radioPanel, getMessage("BLUR_POSITION_CALCULATION"), 
                     blurPositionCalculationEnabled = createRedRadioButton(getMessage("ENABLED")), 
                     blurPositionCalculationDisabled = createRedRadioButton(getMessage("DISABLED")));
        addRadioGroup(radioPanel, getMessage("TIME_SLOT_ALLOCATION"), 
                     timeSlotAllocationMix = createRedRadioButton("MIX"), 
                     timeSlotAllocationGap = createRedRadioButton("GAP"));
        addRadioGroup(radioPanel, getMessage("FILTER_ALGORITHM"), 
                     filterAlgorithmLowPass = createRedRadioButton(getMessage("LOW_PASS_FILTER")), 
                     filterAlgorithmSliding = createRedRadioButton(getMessage("SLIDING_FILTER")));
        addRadioGroup(radioPanel, getMessage("JUDGE_0D_BY_POSITION"), 
                     judge0dByPositionEnabled = createRedRadioButton(getMessage("ENABLED")), 
                     judge0dByPositionDisabled = createRedRadioButton(getMessage("DISABLED")));
        
        mainPanel.add(radioPanel); // Ìí¼Óµ½Ö÷Ãæ°å
        
        // Ê±¼äÃæ°å
        JPanel timePanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 2)); // ×ó¶ÔÆëÁ÷ʽ²¼¾Ö
        timePanel.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0)); // ÉèÖñ߾à
        JLabel timeLabel = new JLabel(getMessage("TIME") + ":"); // Ê±¼ä±êÇ©
        timeField = createFixedTextField(200); // ´´½¨¹Ì¶¨¿í¶ÈÎı¾¿ò
        timeField.setEditable(false); // ÉèÖÃΪ²»¿É±à¼­
        timePanel.add(timeLabel); // Ìí¼Ó±êÇ©
        timePanel.add(timeField); // Ìí¼ÓÎı¾¿ò
        mainPanel.add(timePanel); // Ìí¼Óµ½Ö÷Ãæ°å
        
        // °´Å¥Ãæ°å
        JPanel buttonPanel = new JPanel(); // ´´½¨°´Å¥Ãæ°å
        buttonPanel.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0)); // ÉèÖÃÉϱ߾à
        saveButton = new JButton(getMessage("SAVE")); // ±£´æ°´Å¥
        cancelButton = new JButton(getMessage("CANCEL")); // È¡Ïû°´Å¥
        buttonPanel.add(saveButton); // Ìí¼Ó±£´æ°´Å¥
        buttonPanel.add(cancelButton); // Ìí¼ÓÈ¡Ïû°´Å¥
        mainPanel.add(buttonPanel); // Ìí¼Óµ½Ö÷Ãæ°å
        
        // Ìí¼Ó¹ö¶¯Ãæ°å
        JScrollPane scrollPane = new JScrollPane(mainPanel); // ´´½¨¹ö¶¯Ãæ°å
        scrollPane.setBorder(null); // ÒƳý±ß¿ò
        add(scrollPane, BorderLayout.CENTER); // Ìí¼Óµ½ÖÐÐÄÇøÓò
        
        // ¼ÓÔØ¹«Ë¾Êý¾Ý
        loadCompanyData(); // ³õʼ»¯¹«Ë¾ÏÂÀ­¿ò
        
        // ¼ÓÔØËã·¨Êý¾Ý
        loadAlgorithmData(); // ³õʼ»¯±íµ¥Êý¾Ý
        
        // Ìí¼Óʼþ¼àÌýÆ÷
        addEventListeners(); // ÉèÖð´Å¥Ê¼þ
    }
    
    // ´´½¨¹Ì¶¨¿í¶ÈÎı¾¿ò
    private JTextField createFixedTextField(int width) {
        JTextField textField = new JTextField(); // ´´½¨Îı¾¿ò
        textField.setPreferredSize(new Dimension(width, 25)); // ÉèÖÃÊ×Ñ¡³ß´ç
        textField.setMaximumSize(new Dimension(width, 25)); // ÉèÖÃ×î´ó³ß´ç
        return textField; // ·µ»ØÎı¾¿ò
    }
    
    // ´´½¨ºìÉ«µ¥Ñ¡°´Å¥
    private JRadioButton createRedRadioButton(String text) {
        JRadioButton radioButton = new JRadioButton(text); // ´´½¨µ¥Ñ¡°´Å¥
        
        // Ìí¼Ó״̬±ä»¯¼àÌýÆ÷
        radioButton.addItemListener(new ItemListener() {
            @Override
            public void itemStateChanged(ItemEvent e) {
                if (e.getStateChange() == ItemEvent.SELECTED) { // Ñ¡ÖÐ״̬
                    radioButton.setForeground(Color.RED); // ÉèÖúìÉ«ÎÄ×Ö
                } else { // Î´Ñ¡ÖÐ״̬
                    radioButton.setForeground(Color.BLACK); // ÉèÖúÚÉ«ÎÄ×Ö
                }
            }
        });
        
        return radioButton; // ·µ»Øµ¥Ñ¡°´Å¥
    }
    
    // Ìí¼Ó´ø±êÇ©µÄÎı¾¿òµ½Ãæ°å
    private void addTextField(JPanel panel, String label, JTextField textField) {
        panel.add(new JLabel(label + ":")); // Ìí¼Ó±êÇ©
        panel.add(textField); // Ìí¼ÓÎı¾¿ò
    }
    
    // Ìí¼Óµ¥Ñ¡°´Å¥×éµ½Ãæ°å
    private void addRadioGroup(JPanel panel, String label, JRadioButton option1, JRadioButton option2) {
        panel.add(new JLabel(label + ":")); // Ìí¼Ó±êÇ©
        JPanel radioGroupPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); // ×ó¶ÔÆëÃæ°å
        ButtonGroup group = new ButtonGroup(); // ´´½¨°´Å¥×é
        group.add(option1); // Ìí¼ÓÑ¡Ïî1
        group.add(option2); // Ìí¼ÓÑ¡Ïî2
        radioGroupPanel.add(option1); // Ìí¼Óµ½Ãæ°å
        radioGroupPanel.add(option2); // Ìí¼Óµ½Ãæ°å
        panel.add(radioGroupPanel); // Ìí¼Óµ¥Ñ¡×éÃæ°å
    }
    
    // ¼ÓÔØ¹«Ë¾Êý¾Ý
    private void loadCompanyData() {
        String[] companyNames = Dell_company.getAllCompanyNames(); // »ñÈ¡ËùÓй«Ë¾Ãû
        for (String name : companyNames) { // ±éÀú¹«Ë¾Ãû
            companyComboBox.addItem(name); // Ìí¼Óµ½ÏÂÀ­¿ò
        }
    }
    
    // ¼ÓÔØËã·¨Êý¾Ý
    private void loadAlgorithmData() {
        try {
            // »ñÈ¡µÚÒ»¸öËã·¨ÅäÖÃ
            currentAlgorithm = Dell_GeneralAlgorithm.getAllGeneralAlgorithms().get(0);
            fillFormWithData(currentAlgorithm); // Ìî³ä±íµ¥Êý¾Ý
        } catch (SQLException | IndexOutOfBoundsException ex) { // ²¶»ñÒì³£
            JOptionPane.showMessageDialog(this, getMessage("DATA_LOAD_ERROR") + ": " + ex.getMessage(), 
                                         getMessage("ERROR"), JOptionPane.ERROR_MESSAGE); // ÏÔʾ´íÎóÏûÏ¢
        }
    }
    
    // ÓÃËã·¨Êý¾ÝÌî³ä±íµ¥
    private void fillFormWithData(GeneralAlgorithm algorithm) {
        companyComboBox.setSelectedItem(algorithm.getCompany()); // ÉèÖÃÑ¡Öй«Ë¾
        satelliteSignalFilterField.setText(algorithm.getSatelliteSignalFilterValue()); // ÉèÖÃÎÀÐÇÐźŹýÂËÖµ
        positionFilterField.setText(algorithm.getPositionFilterValue()); // ÉèÖÃλÖùýÂËÖµ
        closeUwbConditionField.setText(algorithm.getCloseUwbCondition()); // ÉèÖùرÕUWBÌõ¼þ
        staticFilterField.setText(algorithm.getStaticFilterValue()); // ÉèÖþ²Ì¬¹ýÂËÖµ
        systemMaxSpeedField.setText(algorithm.getSystemMaxSpeed()); // ÉèÖÃϵͳ×î´óËÙ¶È
        maxRepeatRangingField.setText(algorithm.getMaxRepeatRanging()); // ÉèÖÃ×î´óÖØ¸´²â¾à
        filterLevelField.setText(algorithm.getFilterLevel()); // ÉèÖùýÂ˼¶±ð
        
        // ÉèÖõ¥Ñ¡°´Å¥×´Ì¬
        setRadioState(gnssToXyEnabled, gnssToXyDisabled, algorithm.getGnssToXy());
        setRadioState(areaJudgeIndoorEnabled, areaJudgeIndoorDisabled, algorithm.getAreaJudgeIndoor());
        setRadioState(distanceJudgeIndoorEnabled, distanceJudgeIndoorDisabled, algorithm.getDistanceJudgeIndoor());
        setRadioState(satelliteSignalJudgeIndoorEnabled, satelliteSignalJudgeIndoorDisabled, algorithm.getSatelliteSignalJudgeIndoor());
        setRadioState(blurPositionCalculationEnabled, blurPositionCalculationDisabled, algorithm.getBlurPositionCalculation());
        setRadioState(judge0dByPositionEnabled, judge0dByPositionDisabled, algorithm.getJudge0dByPosition());
        
        // ÉèÖÃʱ϶·ÖÅäģʽ
        if ("1".equals(algorithm.getTimeSlotAllocation())) { // »ìºÏģʽ
            timeSlotAllocationMix.setSelected(true);
        } else { // ¼ä¸ôģʽ
            timeSlotAllocationGap.setSelected(true);
        }
        
        // ÉèÖùýÂËËã·¨
        if ("1".equals(algorithm.getFilterAlgorithm())) { // µÍͨÂ˲¨
            filterAlgorithmLowPass.setSelected(true);
        } else { // »¬¶¯Â˲¨
            filterAlgorithmSliding.setSelected(true);
        }
        
        // ÉèÖÃÐÞ¸Äʱ¼ä
        timeField.setText(algorithm.getModifyTime());
    }
    
    // ÉèÖõ¥Ñ¡°´Å¥×´Ì¬ºÍÑÕÉ«
    private void setRadioState(JRadioButton enabled, JRadioButton disabled, String value) {
        if ("1".equals(value)) { // ÆôÓÃ״̬
            enabled.setSelected(true); // Ñ¡ÖÐÆôÓð´Å¥
            enabled.setForeground(Color.RED); // ÉèÖúìÉ«ÎÄ×Ö
        } else { // ½ûÓÃ״̬
            disabled.setSelected(true); // Ñ¡ÖнûÓð´Å¥
            disabled.setForeground(Color.RED); // ÉèÖúìÉ«ÎÄ×Ö
        }
    }
    
    // Ìí¼Óʼþ¼àÌýÆ÷
    private void addEventListeners() {
        saveButton.addActionListener(e -> saveAlgorithm()); // ±£´æ°´Å¥Ê¼þ
        cancelButton.addActionListener(e -> resetForm()); // È¡Ïû°´Å¥Ê¼þ
    }
    
    // ±£´æËã·¨ÅäÖÃ
    private void saveAlgorithm() {
        GeneralAlgorithm algorithm = new GeneralAlgorithm(); // ´´½¨Ëã·¨¶ÔÏó
        algorithm.setCompany((String) companyComboBox.getSelectedItem()); // ÉèÖù«Ë¾
        algorithm.setSatelliteSignalFilterValue(satelliteSignalFilterField.getText()); // ÉèÖÃÎÀÐÇÐźŹýÂË
        algorithm.setPositionFilterValue(positionFilterField.getText()); // ÉèÖÃλÖùýÂË
        algorithm.setCloseUwbCondition(closeUwbConditionField.getText()); // ÉèÖùرÕUWBÌõ¼þ
        algorithm.setStaticFilterValue(staticFilterField.getText()); // ÉèÖþ²Ì¬¹ýÂË
        algorithm.setSystemMaxSpeed(systemMaxSpeedField.getText()); // ÉèÖÃϵͳ×î´óËÙ¶È
        algorithm.setMaxRepeatRanging(maxRepeatRangingField.getText()); // ÉèÖÃ×î´óÖØ¸´²â¾à
        algorithm.setFilterLevel(filterLevelField.getText()); // ÉèÖùýÂ˼¶±ð
        
        // ÉèÖõ¥Ñ¡°´Å¥Öµ
        algorithm.setGnssToXy(getRadioValue(gnssToXyEnabled));
        algorithm.setAreaJudgeIndoor(getRadioValue(areaJudgeIndoorEnabled));
        algorithm.setDistanceJudgeIndoor(getRadioValue(distanceJudgeIndoorEnabled));
        algorithm.setSatelliteSignalJudgeIndoor(getRadioValue(satelliteSignalJudgeIndoorEnabled));
        algorithm.setBlurPositionCalculation(getRadioValue(blurPositionCalculationEnabled));
        algorithm.setJudge0dByPosition(getRadioValue(judge0dByPositionEnabled));
        
        // ÉèÖÃʱ϶·ÖÅäģʽ
        algorithm.setTimeSlotAllocation(timeSlotAllocationMix.isSelected() ? "1" : "0");
        
        // ÉèÖùýÂËËã·¨
        algorithm.setFilterAlgorithm(filterAlgorithmLowPass.isSelected() ? "1" : "2");
        
        // ÉèÖõ±Ç°Ê±¼ä
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // ÈÕÆÚ¸ñʽ
        algorithm.setModifyTime(sdf.format(new Date())); // ¸ñʽ»¯µ±Ç°Ê±¼ä
        
        // ±£´æµ½Êý¾Ý¿â
        if (saveAlgorithmToDatabase(algorithm)) { // ±£´æ³É¹¦
            currentAlgorithm = algorithm; // ¸üе±Ç°Ëã·¨
            JOptionPane.showMessageDialog(this, getMessage("SAVE_SUCCESS"),
                                        getMessage("SUCCESS"), JOptionPane.INFORMATION_MESSAGE); // ÏÔʾ³É¹¦ÏûÏ¢
        }
    }
    
    // »ñÈ¡µ¥Ñ¡°´Å¥Öµ
    private String getRadioValue(JRadioButton enabled) {
        return enabled.isSelected() ? "1" : "0"; // Ñ¡Öзµ»Ø1£¬·ñÔò·µ»Ø0
    }
    
    // ÖØÖÃ±íµ¥
    private void resetForm() {
        if (currentAlgorithm != null) { // µ±Ç°Ëã·¨´æÔÚ
            fillFormWithData(currentAlgorithm); // ÖØÐÂÌî³ä±íµ¥
        }
    }
    
    // ±£´æËã·¨µ½Êý¾Ý¿â
    private boolean saveAlgorithmToDatabase(GeneralAlgorithm algorithm) {
        try {
            // ´´½¨×Ö¶ÎÓ³Éä
            Map<String, String> fieldValues = new HashMap<>();
            fieldValues.put("company", algorithm.getCompany());
            fieldValues.put("satellite_signal_filter_value", algorithm.getSatelliteSignalFilterValue());
            fieldValues.put("position_filter_value", algorithm.getPositionFilterValue());
            fieldValues.put("close_uwb_condition", algorithm.getCloseUwbCondition());
            fieldValues.put("static_filter_value", algorithm.getStaticFilterValue());
            fieldValues.put("system_max_speed", algorithm.getSystemMaxSpeed());
            fieldValues.put("max_repeat_ranging", algorithm.getMaxRepeatRanging());
            fieldValues.put("filter_level", algorithm.getFilterLevel());
            fieldValues.put("gnss_to_xy", algorithm.getGnssToXy());
            fieldValues.put("area_judge_indoor", algorithm.getAreaJudgeIndoor());
            fieldValues.put("distance_judge_indoor", algorithm.getDistanceJudgeIndoor());
            fieldValues.put("satellite_signal_judge_indoor", algorithm.getSatelliteSignalJudgeIndoor());
            fieldValues.put("blur_position_calculation", algorithm.getBlurPositionCalculation());
            fieldValues.put("time_slot_allocation", algorithm.getTimeSlotAllocation());
            fieldValues.put("filter_algorithm", algorithm.getFilterAlgorithm());
            fieldValues.put("judge_0d_by_position", algorithm.getJudge0dByPosition());
            fieldValues.put("modify_time", algorithm.getModifyTime());
            
            // ¸üÐÂÊý¾Ý¿â
            int result = DBConnector.updateData("general_algorithm", fieldValues, 1);
            
            if (result > 0) { // ¸üгɹ¦
                return true;
            } else { // ¸üÐÂʧ°Ü
                JOptionPane.showMessageDialog(this, getMessage("SAVE_FAILED"),
                                            getMessage("ERROR"), JOptionPane.ERROR_MESSAGE);
                return false;
            }
        } catch (Exception ex) { // ²¶»ñÒì³£
            JOptionPane.showMessageDialog(this, getMessage("SAVE_FAILED") + ": " + ex.getMessage(),
                                        getMessage("ERROR"), JOptionPane.ERROR_MESSAGE);
            return false;
        }
    }
    
    // »ñÈ¡±¾µØ»¯ÏûÏ¢
    private String getMessage(String key) {
        try {
            return messages.getString(key); // ·µ»Ø¼ü¶ÔÓ¦µÄÖµ
        } catch (Exception e) { // Òì³£´¦Àí
            return "[" + key + "]"; // ·µ»Ø¼üÃû(·½À¨ºÅ°ü¹ü)
        }
    }
}