zsh_root
2024-01-02 7b595546af704983dbafcd0d385c8768ddacefc2
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
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
package Frame;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.util.Iterator;
import java.util.List;
import java.util.Vector;
import javax.swing.Box;
import javax.swing.ImageIcon;
import javax.swing.JComboBox;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.table.DefaultTableModel;
import BaoWen.Dell_GNGGA;
import ColorAndFont.English;
import ColorAndFont.UIColor;
import ColorAndFont.buttonTitle;
import DataBase.DatabaseManagement;
import PbuliClass.JButtonModel;
import PbuliClass.JlableModel;
import PbuliClass.ShowMessage;
import PbuliClass.Systems;
import PbuliClass.greateTables;
import PbuliClass.jinternalFrame;
import tbDataModel.Tb_gps;
import urt.Dell_gps;
import urt.Urt_read;
@SuppressWarnings("rawtypes")
public class Gps_Manage extends jinternalFrame {
    /**
     * 
     */
    private static final long serialVersionUID = 1L;
 
 
    JPanel inJpanel=null;//ÄÚ²¿Ãæ°å
    JPanel northJpanel=null;//±±²¿Ãæ°å
    JPanel centerJpanel=null;//Öв¿Ãæ°å
    JTextField searchFileld=null;//ËÑË÷Îı¾¿ò
 
    JTextField jf_jingdu=null;//¾­¶ÈÎı¾¿ò
    JTextField jf_weidu=null;//γ¶ÈÎı¾¿ò
    JTextField jf_th=null;//¼Ð½ÇÎı¾¿ò
    
    JlableModel jl_ck=new JlableModel("Ô­µã»ùÕ¾:");
    JTextField jf_yanchor=new JTextField(Dell_gps.getUrtcankao());//Ö¸¶¨Ô­µã²Î¿¼»ùÕ¾
    
 
    JButtonModel search=null;//ËÑË÷°´Å¥
    JButtonModel shuaxin=null;//ˢа´Å¥
    JButtonModel delete=null;//ɾ³ý°´Å¥
    JButtonModel deleteAll=null;//È«²¿É¾³ý°´Å¥
    JButtonModel jbt_readpeizhi=null;//¶ÁÈ¡ÅäÖÃ
    JButtonModel jbt_alljie=null;//²ÉÓÃËùÓеĽâURTģʽ
    JButtonModel jbt_saveac=null;//±£´æÔ­µã»ùÕ¾
    JComboBox<String> comboBox;
 
    JButtonModel but_urtstop=null;//Ëø¶¨URTģʽ²»ÔÚ»ùÕ¾½ÓÊÕÊý¾Ý
 
    JButtonModel but_save=null;
    JTable table=null;//ÉêÃ÷±í¸ñ    
    DefaultTableModel tableModel=null;//±í¸ñÄ£ÐÍ
    List list=null;
    JScrollPane gd;
    Vector rowData=null;
    //URTģʽֹͣ½ÓÊÕ´¦Àí»ùÕ¾GPSÊý¾Ý
    static boolean urt_stop=false;
    boolean urtopen=Systems.sys().getUrt().equals("1");
 
    public Gps_Manage() {        
        rowData=new Vector();        
        this.setTitle(English.name("URTÊý¾Ý", "Gas Data"));
        this.setFrameIcon(new ImageIcon("image/icon/gpsm.png"));//ÉèÖô°Ìåͼ±ê    
        this.add(getInJpanel());
    }
 
    /**»ñÈ¡ÄÚ²¿´°ÌåµÄÄÚ²¿Ãæ°å*/
    public JPanel getInJpanel() {
        if(inJpanel==null) {
            inJpanel=new JPanel();
            inJpanel.setLayout(new BorderLayout());//ÉèÖÃÃæ°åΪ±ß½ç²¼¾Ö
            inJpanel.setBackground(Color.WHITE);//ÉèÖÃÃæ°å±³¾°Îª°×É«
            inJpanel.add(getNorthJpanel(),BorderLayout.NORTH);
            inJpanel.add(getGd(),BorderLayout.CENTER);
        }        
        return inJpanel;
    }
 
    /**»ñÈ¡±±²¿Ãæ°å*/
    public JPanel getNorthJpanel() {
        if(northJpanel==null) {
            northJpanel=new JPanel();
            Box topicBox = Box.createHorizontalBox();// ´´½¨Ò»¸öˮƽÏäÈÝÆ÷
            topicBox.add(getSearchFileld());//Ìí¼ÓËÑË÷Îı¾¿ò
            topicBox.add(Box.createHorizontalStrut(3));// Ìí¼ÓÒ»¸ö3ÏñËØ¿íµÄˮƽ֧Öù
            topicBox.add(getSearch());//Ìí¼ÓËÑË÷°´Å¥
            topicBox.add(Box.createHorizontalStrut(20));// Ìí¼ÓÒ»¸ö5ÏñËØ¿íµÄˮƽ֧Öù
            topicBox.add(getShuaxin());//Ìí¼Óˢа´Å¥
            topicBox.add(Box.createHorizontalStrut(20));// Ìí¼ÓÒ»¸ö5ÏñËØ¿íµÄˮƽ֧Öù
            topicBox.add(getDelete() );//ɾ³ý
            topicBox.add(Box.createHorizontalStrut(20));
            topicBox.add(getJbt_readpeizhi());//¶ÁÈ¡ÅäÖÃ
            if(urtopen) {
                topicBox.add(Box.createHorizontalStrut(20));
                topicBox.add(getBut_urtstop());
                topicBox.add(Box.createHorizontalStrut(20));
                topicBox.add(getJbt_alljie());
                topicBox.add(Box.createHorizontalStrut(20));
                topicBox.add(jl_ck);
                topicBox.add(jf_yanchor);
                topicBox.add(Box.createHorizontalStrut(5));
                topicBox.add(getJbt_saveac());
            }
            northJpanel.add(topicBox );    
        }
 
        return northJpanel;
    }
 
 
    /**»ñÈ¡ËÑË÷Îı¾¿òµÄ·½·¨*/
    public JTextField getSearchFileld() {
        if(searchFileld==null){
            searchFileld=new JTextField(5);
            searchFileld.addKeyListener(new KeyListener() {    //¼üÅÌʼþ¼àÌý                
                public void keyTyped(KeyEvent e) {        
                }                    
                public void keyReleased(KeyEvent e) {
                    int keyCode=e.getKeyCode();
                    if(keyCode==KeyEvent.VK_ENTER) {
                        getSearch().doClick();//ËÑË÷°´Å¥±»µã»÷
                    }                        
                }                    
                public void keyPressed(KeyEvent e) {                
                }
            });
        }
        return searchFileld;
    }
 
 
    /**»ñÈ¡ËÑË÷°´Å¥µÄ·½·¨*/    
    public JButtonModel getSearch() {
        if(search==null){
            search=new JButtonModel(buttonTitle.getSerch());
            search.addActionListener(new ActionListener() {    
                public void actionPerformed(ActionEvent e) {
                    String so=getSearchFileld().getText();
                    if(so.length()>2) {
                        updateSerch(so);
                    }else {
                        ShowMessage.zidingyi("ÊäÈëµÄËÑË÷ÄÚÈݲ»ÕýÈ·");
                    }
                }
            });
        }
        return search;
    }
 
 
    /**»ñȡˢа´Å¥µÄ·½·¨*/    
    public JButtonModel getShuaxin() {
        if(shuaxin==null){
            shuaxin=new JButtonModel(buttonTitle.getRefresh());
            shuaxin.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    updateTable();
                }
            });
 
        }
        return shuaxin;
    }
 
 
    /**»ñȡɾ³ý°´Å¥µÄ·½·¨*/    
    public JButtonModel getDelete() {
        if(delete==null){
            delete=new JButtonModel(buttonTitle.getDelete());
            delete.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    int[] selectedRows=table.getSelectedRows();//±»Ñ¡ÖÐÐеÄË÷Òý¼¯ºÏ
                    int size=selectedRows.length;
                    if( size!=0) {
                        //ɾ³ýËùÓб»Ñ¡ÖеÄÐÐ
                        for(int j=selectedRows.length-1;j>=0;j--){//ÕâÊǹؼü´úÂë
                            String tagid=(String) table.getValueAt(selectedRows[j],0);
                            Dell_gps.delete(tagid);
                            tableModel.removeRow(selectedRows[j]);//ɾ³ýÈÎÒⱻѡÖÐÐÐ
                        }
                        table.setModel(tableModel);//¸üбí¸ñÄ£ÐÍ
                        //ɾ³ý³É¹¦ÌáʾÐÅÏ¢
                        ShowMessage.delteSuccess(size);    
                    }
                    else {
                        ShowMessage.zidingyi("ÇëÑ¡ÖÐÐèҪɾ³ýµÄÐУ¡");                
                    }
                }
            });
        }
        return delete;
    }
 
 
    /**»ñȡȫ²¿É¾³ý°´Å¥µÄ·½·¨*/    
    public JButtonModel getDeleteAll() {
        if(deleteAll==null){
            deleteAll=new JButtonModel(buttonTitle.getDeleteall());
            deleteAll.setEnabled(false);
            deleteAll.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
 
                }
            });
 
        }
        return deleteAll;
    }
 
 
 
    /**»ñÈ¡¹ö¶¯Ãæ°åµÄ·½·¨*/    
    public JScrollPane getGd() {
        gd=new JScrollPane(getTable());
        gd.getViewport().setBackground(UIColor.getNorth_color());
        return gd;
    }
 
 
    /**Ìí¼Ó±í¸ñÐÐÏòÁ¿Êý¾Ý·½·¨*/ 
    @SuppressWarnings("unchecked")
    public void getRowData(Vector<Tb_gps> list ) {
        Iterator<Tb_gps> iterator = list.iterator();//´´½¨µü´úÆ÷        
        while (iterator.hasNext()) {//µü´úÆ÷´æÔÚÔªËØ            
            Tb_gps tag = iterator.next();//½«µü´úÆ÷ÀïÃæµÄÔªËØ¸øµ½info¼¯ºÏ
            Vector row = new Vector();    
            //"ÐòºÅ","É豸±àºÅ","γ¶È","¾­¶È","GPS״̬","ÎÀÐÇÊý","º£°Î¸ß","²î·ÖÕ¾ID","µçÁ¿","¸üÐÂʱ¼ä"
            if(tag !=null) {
                String gps_state=(String)tag.getGps_state();
                row.add(tag.getTagid());
                row.add(tag.getGps_weidu());
                row.add(tag.getGsp_jingdu());
                row.add(gps_state);
                row.add(tag.getGps_num());
                row.add(tag.getGps_haiba_gao());
                row.add(tag.getFloor());
                row.add(tag.getGps_power());
                row.add(tag.getAddtime());
                row.add(tag.getCcid());
                row.add(tag.getBaoliu4());//CRMÀ´Ô´
                tableModel.addRow(row);// Ïò±í¸ñ¶ÔÏóÌí¼ÓÐÐÊý¾Ý
            }
        }    
 
    }
 
 
    /**±í¸ñ*/    
    @SuppressWarnings("serial")
    public JTable getTable() {
        if(table==null) {
            String name1="É豸±àºÅ";
            String name2="γ¶È";
            String name3="¾­¶È";
            String name4="¶¨Î»×´Ì¬";
            String name5="ÎÀÐÇÊý";
            String name6="º£°Î¸ß(Ã×)";
            String name7="ËùÔÚ²ã";
            String name8="µçÁ¿(%)";
            String name9="¸üÐÂʱ¼ä";
            String name10="Á÷Á¿¿¨ºÅ";
            String name11="CRM";
            if(Systems.sys().getLanguage().equals("English")) {
                name1="DeviceID";
                name2="Latitude";
                name3="Longitude";
                name4="GpsStatus";
                name5="GpsNum";
                name6="HighAltitude(m)";
                name7="Floor";
                name8="Power(%)";
                name9="AddTime";
                name10="CCID";
                name11="CRM";
            }
 
            String[] columnNames= {name1,name2,name3,name4,name5,name6,name7,name8,name9,name10,name11};//±í¸ñÁÐÃû
            //Ìí¼Ó±í¸ñÁÐÏòÁ¿
            Vector<String> columnName=new Vector<>();
            for(int i=0;i<columnNames.length;i++){
                columnName.add(columnNames[i]);            
            }
 
            greateTables tables=new greateTables();
            tableModel=new DefaultTableModel(rowData, columnName){ //  ÊµÏÖÈÃÕû¸ö±í¸ñ²»²»ÔÊÐí±»±à¼­ 
                public boolean isCellEditable(int row,int column){  
                    return false;  
                }  
            };
            table=tables.getTable(tableModel);
            getRowData(Dell_gps.getGps_vector());
 
        }
        return table;
    }
 
 
    /**ˢбí¸ñ·½·¨*/
    public void updateTable() {            
        if(tableModel !=null) {
            tableModel.getDataVector().clear();
            getRowData(Dell_gps.getGps_vector());
            gd.validate();
        }
    }
 
 
    /**ËÑË÷·½·¨*/
    public void updateSerch(String serch) {    
        if(Dell_gps.serch(serch).size() ==0) {
            ShowMessage.zidingyi("ÄãËÑË÷µÄ"+serch+"²»´æÔÚ£¡");
            return;
        }
        int tagnum=getTable().getRowCount();//±í¸ñ×ÜÐÐÊý
        if(tagnum !=0 ) {
            for (int i = 0; i < tagnum; i++) {            
                tableModel.removeRow(0);                            
            }
            getRowData(Dell_gps.serch(serch));
        }
    }
 
    public JButtonModel getBut_urtstop() {
        if(but_urtstop==null) {
            but_urtstop=new JButtonModel("²»¼ÆËã»ùÕ¾×ø±ê");
            but_urtstop.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    if(urt_stop) {
                        but_urtstop.setText("²»¼ÆËã»ùÕ¾×ø±ê");
                        urt_stop=false;
                    }else {
                        but_urtstop.setText("¼ÆËã»ùÕ¾×ø±ê");
                        urt_stop=true;
                    }
 
                }
            });
        }
        return but_urtstop;
    }
 
    public static boolean isUrt_stop() {
        return urt_stop;
    }
 
    public JButtonModel getJbt_readpeizhi() {
        if(jbt_readpeizhi==null) {
            jbt_readpeizhi=new JButtonModel("¶ÁÈ¡ÅäÖÃ");
            jbt_readpeizhi.setToolTipText("¶ÁÈ¡Èں϶¨Î»Öն˵ÄÉ豸²ÎÊý");
            jbt_readpeizhi.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    int[] selectedRows=table.getSelectedRows();//±»Ñ¡ÖÐÐеÄË÷Òý¼¯ºÏ
                    int size=selectedRows.length;
                    if( size!=0) {
                        //ɾ³ýËùÓб»Ñ¡ÖеÄÐÐ
                        for(int j=selectedRows.length-1;j>=0;j--){//ÕâÊǹؼü´úÂë
                            String tagid=(String) table.getValueAt(selectedRows[j],0);
                            Urt_read.read_tag(tagid,"01","33",1);
                        }                        
                    }
                    else {
                        ShowMessage.zidingyi("ÇëÑ¡ÖÐÐèÒª¶ÁÈ¡µÄÉ豸ÐУ¡");                
                    }
 
 
                }
            });
 
        }
        return jbt_readpeizhi;
    }
 
    public JButtonModel getJbt_alljie() {
        if(jbt_alljie==null) {
            jbt_alljie=new JButtonModel("²»²ÉÓõ;«¶ÈÊý¾Ý");
            jbt_alljie.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    boolean a=Dell_GNGGA.isUrtmode1();
                    if(a) {
                        Dell_GNGGA.setUrtmode1(false);
                        jbt_alljie.setText("²»²ÉÓõ;«¶ÈÊý¾Ý");
                    }else {    
                        Dell_GNGGA.setUrtmode1(true);
                        jbt_alljie.setText("²ÉÓõ;«¶ÈÊý¾Ý");
                        
                    }
                    
                    
                }
            });
        }
        return jbt_alljie;
    }
 
    public JButtonModel getJbt_saveac() {
        if(jbt_saveac==null) {
            jbt_saveac=new JButtonModel("±£´æ");
            jbt_saveac.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    String a=jf_yanchor.getText();
                    String[]  ziduan= {"baoliu1","tagid"};
                    String[] zhi= {a,a};
                    DatabaseManagement.fast_alert_dbase("tb_gps", ziduan, zhi);
                    ShowMessage.zidingyi("±£´æ³É¹¦");
                }
            });
            
        }
        return jbt_saveac;
    }
 
    
 
}