dengzedong
2024-12-19 85b2001c0ec2f1adc598db3bf47ad457dcca7074
提交 | 用户 | 时间
149dd0 1 package com.iailab.netsdk.demo.frame.TargetRecognition;
H 2
3 import java.awt.BorderLayout;
4 import java.awt.Dimension;
5 import java.awt.FlowLayout;
6 import java.awt.GridLayout;
7 import java.awt.event.ActionEvent;
8 import java.awt.event.ActionListener;
9 import java.awt.event.WindowAdapter;
10 import java.awt.event.WindowEvent;
11 import java.io.IOException;
12 import java.io.UnsupportedEncodingException;
13 import java.util.HashMap;
14 import java.util.concurrent.ExecutionException;
15
16 import javax.swing.JButton;
17 import javax.swing.JCheckBox;
18 import javax.swing.JComboBox;
19 import javax.swing.JDialog;
20 import javax.swing.JLabel;
21 import javax.swing.JOptionPane;
22 import javax.swing.JPanel;
23 import javax.swing.JScrollPane;
24 import javax.swing.JTable;
25 import javax.swing.JTextField;
26 import javax.swing.ListSelectionModel;
27 import javax.swing.SwingUtilities;
28 import javax.swing.SwingWorker;
29 import javax.swing.event.ChangeEvent;
30 import javax.swing.event.ChangeListener;
31 import javax.swing.table.DefaultTableCellRenderer;
32 import javax.swing.table.DefaultTableModel;
33
34 import com.iailab.netsdk.demo.module.TargetRecognitionModule;
35 import com.sun.jna.Memory;
36
37 import com.iailab.netsdk.common.*;
38 import com.iailab.netsdk.lib.ToolKits;
39 import com.iailab.netsdk.lib.NetSDKLib.*;
40
41 public class PersonOperateDialog extends JDialog{
42     /**
43      * 
44      */
45     private static final long serialVersionUID = 1L;
46     
47     private String groupId = "";
48     private String groupName = "";
49     
50     // 添加人员界面
51     public AddPersonDialog addPersonDialog = null;
52     
53     // 修改人员界面
54     public ModifyPersonDialog modifyPersonDialog = null;
55     
56     // 查询起始索引
57     private int nBeginNum = 0;
58     
59     // 页数
60     private int nPagesNumber = 0;
61     
62     // 查询人员总数
63     private int nTotalCount = 0;
64     
65     private HashMap<String, CANDIDATE_INFOEX> cadidateHashMap = new HashMap<String, CANDIDATE_INFOEX>();
66     
67     public PersonOperateDialog(String groupId, String groupName) {
68         setTitle(Res.string().getPersonOperate());
69         setLayout(new BorderLayout());
70         setModal(true);  
71         pack();
72         setSize(680, 520);
73         setResizable(false);
74         setLocationRelativeTo(null);
75         setDefaultCloseOperation(DISPOSE_ON_CLOSE);   // 释放窗体
76         
77         this.groupId = groupId;
78         this.groupName = groupName;
79         
80         PersonInfoPanel personInfoPanel = new PersonInfoPanel();
81         PersonInfoListPanel personInfoListPanel = new PersonInfoListPanel();
82         
83         add(personInfoPanel, BorderLayout.NORTH);
84         add(personInfoListPanel, BorderLayout.CENTER);
85         
86         addWindowListener(new WindowAdapter() {
87             public void windowClosing(WindowEvent e) {
88                 nBeginNum = 0;            
89                 nPagesNumber = 0;            
90                 nTotalCount = 0;            
91                 cadidateHashMap.clear();
92
93                 dispose();
94             }
95         });
96     }
97     
98     
99     /*
100      * 查找条件信息
101      */
102     private class SearchInfoPanel extends JPanel {
103         private static final long serialVersionUID = 1L;
104         public SearchInfoPanel() {
105             BorderEx.set(this, Res.string().getFindCondition(), 1);
106             setLayout(new FlowLayout());
107             
108             JLabel goroupIdLabel = new JLabel(Res.string().getFaceGroupId(), JLabel.CENTER);
109             JLabel goroupNameLabel = new JLabel(Res.string().getFaceGroupName(), JLabel.CENTER);
110             JLabel nameLabel = new JLabel(Res.string().getName(), JLabel.CENTER);
111             JLabel sexLabel = new JLabel(Res.string().getSex(), JLabel.CENTER);
112             JLabel IdTypeLabel = new JLabel(Res.string().getIdType(), JLabel.CENTER);
113             JLabel IdLabel = new JLabel(Res.string().getIdNo(), JLabel.CENTER);
114             JLabel birthdayLabel = new JLabel(Res.string().getBirthday(), JLabel.CENTER);
115             JLabel lineLabel = new JLabel("-", JLabel.CENTER);
116             startBirthdayCheckBox = new JCheckBox();
117             endBirthdayCheckBox = new JCheckBox();
118             JLabel nullLabel = new JLabel();
119             
120             Dimension dimension1 = new Dimension();
121             dimension1.height = 20;
122             dimension1.width = 80;
123             goroupIdLabel.setPreferredSize(dimension1);
124             goroupNameLabel.setPreferredSize(dimension1);
125             nameLabel.setPreferredSize(dimension1);
126             sexLabel.setPreferredSize(dimension1);
127             IdTypeLabel.setPreferredSize(dimension1);
128             IdLabel.setPreferredSize(dimension1);
129             birthdayLabel.setPreferredSize(dimension1);
130             lineLabel.setPreferredSize(new Dimension(50, 20));
131             nullLabel.setPreferredSize(new Dimension(180, 20));
132             
133             goroupIdTextField = new JTextField();
134             goroupNameTextField = new JTextField();
135             nameTextField = new JTextField();
136             sexComboBox = new JComboBox(Res.string().getSexStringsFind());
137             idTypeComboBox = new JComboBox(Res.string().getIdStringsFind());
138             idTextField = new JTextField();
139             
140             startTimeBtn = new DateChooserJButtonEx("2018-07-01");
141             endTimeBtn = new DateChooserJButtonEx();
142             
143             startTimeBtn.setStartYear(1900);
144             endTimeBtn.setStartYear(1900);
145     
146             Dimension dimension2 = new Dimension();
147             dimension2.height = 20;
148             goroupIdTextField.setPreferredSize(dimension2);
149             goroupNameTextField.setPreferredSize(dimension2);
150             nameTextField.setPreferredSize(dimension2);        
151             idTextField.setPreferredSize(dimension2);
152             
153             goroupIdTextField.setPreferredSize(new Dimension(120, 20));
154             goroupNameTextField.setPreferredSize(new Dimension(120, 20));
155             nameTextField.setPreferredSize(new Dimension(120, 20));
156             idTextField.setPreferredSize(new Dimension(120, 20));    
157             sexComboBox.setPreferredSize(new Dimension(120, 20));
158             startTimeBtn.setPreferredSize(new Dimension(125, 20));
159             endTimeBtn.setPreferredSize(new Dimension(125, 20));    
160             idTypeComboBox.setPreferredSize(new Dimension(120, 20));
161             startBirthdayCheckBox.setPreferredSize(new Dimension(20, 20));
162             endBirthdayCheckBox.setPreferredSize(new Dimension(20, 20));
163         
164             add(goroupIdLabel);
165             add(goroupIdTextField);
166             add(goroupNameLabel);
167             add(goroupNameTextField);
168             add(nameLabel);
169             add(nameTextField);
170             add(sexLabel);
171             add(sexComboBox);
172             add(IdTypeLabel);
173             add(idTypeComboBox);
174             add(IdLabel);
175             add(idTextField);
176             add(birthdayLabel);
177             add(startTimeBtn);
178             add(startBirthdayCheckBox);
179             add(lineLabel);
180             add(endTimeBtn);
181             add(endBirthdayCheckBox);
182             add(nullLabel);
183             
184             goroupIdTextField.setEditable(false);
185             goroupNameTextField.setEditable(false);
186             startBirthdayCheckBox.setSelected(false);
187             endBirthdayCheckBox.setSelected(false);
188             startTimeBtn.setEnabled(false);
189             endTimeBtn.setEnabled(false);
190         }
191     }
192     /*
193      * 人员信息以及操作面板
194      */
195     private class PersonInfoPanel extends JPanel {
196         private static final long serialVersionUID = 1L;
197         public PersonInfoPanel() {
198             BorderEx.set(this, "", 2);
199             setLayout(new BorderLayout());
200             
201             Dimension dimension = new Dimension();
202             dimension.height = 150;
203             setPreferredSize(dimension);
204             
205             SearchInfoPanel searchInfoPanel = new SearchInfoPanel();
206             JPanel operatePanel = new JPanel();
207             
208             add(searchInfoPanel, BorderLayout.CENTER);
209             add(operatePanel, BorderLayout.SOUTH);
210             
211             /*
212              * 操作
213              */
214             searchPersonBtn = new JButton(Res.string().getFindPerson());
215             JButton addPersonBtn = new JButton(Res.string().getAddPerson());
216             JButton modifyPersonBtn = new JButton(Res.string().getModifyPerson());
217             JButton deletePersonBtn = new JButton(Res.string().getDelPerson());
218             
219             operatePanel.setLayout(new GridLayout(1, 4));
220             
221             operatePanel.add(searchPersonBtn);
222             operatePanel.add(addPersonBtn);
223             operatePanel.add(modifyPersonBtn);
224             operatePanel.add(deletePersonBtn);
225             
226             goroupIdTextField.setText(groupId);
227             goroupNameTextField.setText(groupName);
228             
229             startBirthdayCheckBox.addChangeListener(new ChangeListener() {        
230                 @Override
231                 public void stateChanged(ChangeEvent arg0) {
232                     if(startBirthdayCheckBox.isSelected()) {
233                         startTimeBtn.setEnabled(true);
234                     } else {
235                         startTimeBtn.setEnabled(false);
236                     }
237                 }
238             });
239             
240             endBirthdayCheckBox.addChangeListener(new ChangeListener() {        
241                 @Override
242                 public void stateChanged(ChangeEvent arg0) {
243                     if(endBirthdayCheckBox.isSelected()) {
244                         endTimeBtn.setEnabled(true);
245                     } else {
246                         endTimeBtn.setEnabled(false);
247                     }
248                 }
249             });
250             
251             // 查找人员
252             searchPersonBtn.addActionListener(new ActionListener() {                
253                 @Override
254                 public void actionPerformed(ActionEvent arg0) {
255                     SwingUtilities.invokeLater(new Runnable() {                    
256                         @Override
257                         public void run() {
258                             searchPersonBtn.setEnabled(false);
259                         }
260                     });    
261                     
262                     new SwingWorker<CANDIDATE_INFOEX[], String>() {                    
263                         @Override
264                         protected CANDIDATE_INFOEX[] doInBackground() {
265                             nTotalCount = 0;
266                             nBeginNum = 0;
267                             cleanList();
268                             cadidateHashMap.clear();
269                             
270                             nTotalCount = TargetRecognitionModule.startFindPerson(goroupIdTextField.getText(),
271                                                                                 startBirthdayCheckBox.isSelected(), startTimeBtn.getText().toString(), 
272                                                                                 endBirthdayCheckBox.isSelected(), endTimeBtn.getText().toString(), 
273                                                                                 nameTextField.getText(), sexComboBox.getSelectedIndex(), 
274                                                                                 idTypeComboBox.getSelectedIndex(), idTextField.getText());
275                                 
276                             if(nTotalCount <= 0) {
277                                 searchPersonBtn.setEnabled(true);
278                                 previousPageBtn.setEnabled(false);
279                                 lastPageBtn.setEnabled(false);
280                                 numTextField.setText("");
281                                 return null;
282                             }
283                             
284                             CANDIDATE_INFOEX[] stuCandidatesEx = TargetRecognitionModule.doFindPerson(nBeginNum, 17);
285                             return stuCandidatesEx;
286                         }
287                         
288                         @Override
289                         protected void done() {                            
290                             try {
291                                 CANDIDATE_INFOEX[] stuCandidatesEx = get();
292                                 findPersonInfo(stuCandidatesEx);
293                             } catch (InterruptedException e) {
294                                 e.printStackTrace();
295                             } catch (ExecutionException e) {
296                                 e.printStackTrace();
297                             }                        
298                         }
299                     }.execute();
300                 }
301             });
302                         
303             // 添加人员
304             addPersonBtn.addActionListener(new ActionListener() {                
305                 @Override
306                 public void actionPerformed(ActionEvent arg0) {
307                     addPersonDialog = new AddPersonDialog(groupId, groupName);
308             
309                     addPersonDialog.addWindowCloseListener(new WindowCloseListener() {                            
310                         @Override
311                         public void windowClosing() {
312                             new SwingWorker<CANDIDATE_INFOEX[], String>() {                    
313                                 @Override
314                                 protected CANDIDATE_INFOEX[] doInBackground() {
315                                     nTotalCount = 0;
316                                     nBeginNum = 0;
317                                     cleanList();
318                                     cadidateHashMap.clear();
319                                     
320                                     nTotalCount = TargetRecognitionModule.startFindPerson(goroupIdTextField.getText(),
321                                                                                         startBirthdayCheckBox.isSelected(), startTimeBtn.getText().toString(), 
322                                                                                         endBirthdayCheckBox.isSelected(), endTimeBtn.getText().toString(), 
323                                                                                         nameTextField.getText(), sexComboBox.getSelectedIndex(), 
324                                                                                         idTypeComboBox.getSelectedIndex(), idTextField.getText());
325                                         
326                                     if(nTotalCount <= 0) {
327                                         searchPersonBtn.setEnabled(true);
328                                         previousPageBtn.setEnabled(false);
329                                         lastPageBtn.setEnabled(false);
330                                         numTextField.setText("");
331                                         return null;
332                                     }
333                                     
334                                     CANDIDATE_INFOEX[] stuCandidatesEx = TargetRecognitionModule.doFindPerson(nBeginNum, 17);
335                                     return stuCandidatesEx;
336                                 }
337                                 
338                                 @Override
339                                 protected void done() {                
340                                     try {
341                                         CANDIDATE_INFOEX[] stuCandidatesEx = get();
342                                         findPersonInfo(stuCandidatesEx);
343                                     } catch (InterruptedException e) {
344                                         e.printStackTrace();
345                                     } catch (ExecutionException e) {
346                                         e.printStackTrace();
347                                     }                        
348                                 }
349                             }.execute();
350                         }
351                     });
352                     
353                     addPersonDialog.setVisible(true);                            
354                 }
355             });
356             
357             // 修改人员
358             modifyPersonBtn.addActionListener(new ActionListener() {                
359                 @Override
360                 public void actionPerformed(ActionEvent arg0) {
361                     int row = -1;
362                     row = table.getSelectedRow(); //获得所选的单行
363                     
364                     if(row < 0) {
365                         JOptionPane.showMessageDialog(null, Res.string().getSelectPerson(), Res.string().getErrorMessage(), JOptionPane.ERROR_MESSAGE);
366                         return;
367                     }
368                     
369                     if(defaultTableModel.getValueAt(row, 0) == null || String.valueOf(defaultTableModel.getValueAt(row, 0)).trim().equals("")) {
370                         JOptionPane.showMessageDialog(null, Res.string().getSelectPerson(), Res.string().getErrorMessage(), JOptionPane.ERROR_MESSAGE);
371                         return;
372                     }
373                     
374                     // 人员信息
375                     CANDIDATE_INFOEX stuCandidate = cadidateHashMap.get(String.valueOf(defaultTableModel.getValueAt(row, 0)).trim());
376                     
377                     // URL地址
378                     String szFilePath = stuCandidate.stPersonInfo.szFacePicInfo[0].pszFilePath.getString(0);
379
380                     // 存放图片的本地路径
381                     String pszFileDst = "./person.jpg";
382                             
383                     // 下载图片, 下载到本地, 图片路径  "./person.jpg"
384                     boolean bRet = TargetRecognitionModule.downloadPersonPic(szFilePath, pszFileDst);
385                     
386                     Memory memory = null;
387                     if(bRet) {
388                         try {
389                             memory = ToolKits.readPictureFile(pszFileDst);
390                         } catch (IOException e) {
391                             // TODO Auto-generated catch block
392                             e.printStackTrace();
393                         }
394                     } else {
395                         pszFileDst = "";
396                     }
397                     
398                     // 人员标识符
399                     String uid = String.valueOf(defaultTableModel.getValueAt(row, 0)).trim();
400                     
401                     modifyPersonDialog = new ModifyPersonDialog(groupId, groupName, uid, pszFileDst, memory, stuCandidate);
402
403                     modifyPersonDialog.addWindowCloseListener(new WindowCloseListener() {                            
404                         @Override
405                         public void windowClosing() {
406                             new SwingWorker<CANDIDATE_INFOEX[], String>() {                    
407                         @Override
408                         protected CANDIDATE_INFOEX[] doInBackground() {
409                             nTotalCount = 0;
410                             nBeginNum = 0;
411                             cleanList();
412                             cadidateHashMap.clear();
413                             
414                             nTotalCount = TargetRecognitionModule.startFindPerson(goroupIdTextField.getText(),
415                                                                                 startBirthdayCheckBox.isSelected(), startTimeBtn.getText().toString(), 
416                                                                                 endBirthdayCheckBox.isSelected(), endTimeBtn.getText().toString(), 
417                                                                                 nameTextField.getText(), sexComboBox.getSelectedIndex(), 
418                                                                                 idTypeComboBox.getSelectedIndex(), idTextField.getText());
419                                 
420                             if(nTotalCount <= 0) {
421                                 searchPersonBtn.setEnabled(true);
422                                 previousPageBtn.setEnabled(false);
423                                 lastPageBtn.setEnabled(false);
424                                 numTextField.setText("");
425                                 return null;
426                             }
427                             
428                             CANDIDATE_INFOEX[] stuCandidatesEx = TargetRecognitionModule.doFindPerson(nBeginNum, 17);
429                             return stuCandidatesEx;
430                         }
431                         
432                         @Override
433                         protected void done() {                
434                             try {
435                                 CANDIDATE_INFOEX[] stuCandidatesEx = get();
436                                 findPersonInfo(stuCandidatesEx);
437                             } catch (InterruptedException e) {
438                                 e.printStackTrace();
439                             } catch (ExecutionException e) {
440                                 e.printStackTrace();
441                             }                        
442                         }
443                     }.execute();
444                         }
445                     });
446                     
447                     modifyPersonDialog.setVisible(true);                            
448                 }
449             });
450             
451             // 删除人员
452             deletePersonBtn.addActionListener(new ActionListener() {                
453                 @Override
454                 public void actionPerformed(ActionEvent arg0) {
455                     int row = -1;
456                     row = table.getSelectedRow(); //获得所选的单行
457                     
458                     if(row < 0) {
459                         JOptionPane.showMessageDialog(null, Res.string().getSelectPerson(), Res.string().getErrorMessage(), JOptionPane.ERROR_MESSAGE);
460                         return;
461                     }
462                     
463                     if(defaultTableModel.getValueAt(row, 0) == null || String.valueOf(defaultTableModel.getValueAt(row, 0)).trim().equals("")) {
464                         JOptionPane.showMessageDialog(null, Res.string().getSelectPerson(), Res.string().getErrorMessage(), JOptionPane.ERROR_MESSAGE);
465                         return;
466                     }
467                     
468                     if(!TargetRecognitionModule.delPerson(goroupIdTextField.getText(), String.valueOf(defaultTableModel.getValueAt(row, 0)).trim())) {
469                         JOptionPane.showMessageDialog(null, Res.string().getFailed() + "," + ToolKits.getErrorCodeShow(), Res.string().getErrorMessage(), JOptionPane.ERROR_MESSAGE);
470                     } else {
471                         JOptionPane.showMessageDialog(null, Res.string().getSucceed(), Res.string().getPromptMessage(), JOptionPane.INFORMATION_MESSAGE);
472                     }
473                     
474                     new SwingWorker<CANDIDATE_INFOEX[], String>() {                    
475                         @Override
476                         protected CANDIDATE_INFOEX[] doInBackground() {
477                             nTotalCount = 0;
478                             nBeginNum = 0;
479                             cleanList();
480                             cadidateHashMap.clear();
481                             
482                             nTotalCount = TargetRecognitionModule.startFindPerson(goroupIdTextField.getText(),
483                                                                                 startBirthdayCheckBox.isSelected(), startTimeBtn.getText().toString(), 
484                                                                                 endBirthdayCheckBox.isSelected(), endTimeBtn.getText().toString(), 
485                                                                                 nameTextField.getText(), sexComboBox.getSelectedIndex(), 
486                                                                                 idTypeComboBox.getSelectedIndex(), idTextField.getText());
487                                 
488                             if(nTotalCount <= 0) {
489                                 searchPersonBtn.setEnabled(true);
490                                 previousPageBtn.setEnabled(false);
491                                 lastPageBtn.setEnabled(false);
492                                 numTextField.setText("");
493                                 return null;
494                             }
495                             
496                             CANDIDATE_INFOEX[] stuCandidatesEx = TargetRecognitionModule.doFindPerson(nBeginNum, 17);
497                             return stuCandidatesEx;
498                         }
499                         
500                         @Override
501                         protected void done() {
502                             
503                             try {
504                                 CANDIDATE_INFOEX[] stuCandidatesEx = get();
505                                 findPersonInfo(stuCandidatesEx);
506                             } catch (InterruptedException e) {
507                                 e.printStackTrace();
508                             } catch (ExecutionException e) {
509                                 e.printStackTrace();
510                             }                        
511                         }
512                     }.execute();
513                 }
514             });
515         }
516     }
517     
518     /*
519      * 人员信息显示列表
520      */
521     private class PersonInfoListPanel extends JPanel {
522         private static final long serialVersionUID = 1L;
523         public PersonInfoListPanel() {
524             BorderEx.set(this, "", 2);
525             setLayout(new BorderLayout());
526             
527             data = new Object[17][6];
528             defaultTableModel = new DefaultTableModel(data, Res.string().getPersonTable());
529             table = new JTable(defaultTableModel) {   // 列表不可编辑
530                 private static final long serialVersionUID = 1L;
531                 @Override
532                 public boolean isCellEditable(int row, int column) {
533                     return false;
534                 }
535             };
536             
537             table.getColumnModel().getColumn(0).setPreferredWidth(120);
538             table.getColumnModel().getColumn(1).setPreferredWidth(150);
539             table.getColumnModel().getColumn(2).setPreferredWidth(100);
540             table.getColumnModel().getColumn(3).setPreferredWidth(200);
541             table.getColumnModel().getColumn(4).setPreferredWidth(150);
542             table.getColumnModel().getColumn(5).setPreferredWidth(250);
543             
544             table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);  // 只能选中一行
545             
546             DefaultTableCellRenderer dCellRenderer = new DefaultTableCellRenderer();
547             dCellRenderer.setHorizontalAlignment(JLabel.CENTER);
548             table.setDefaultRenderer(Object.class, dCellRenderer);
549             
550             JPanel panel = new JPanel();
551             previousPageBtn = new JButton(Res.string().getPreviousPage());
552             lastPageBtn = new JButton(Res.string().getLastPage());
553             JLabel numLabel = new JLabel(Res.string().getPagesNumber(), JLabel.CENTER);
554             numTextField = new JTextField();
555             
556             numTextField.setHorizontalAlignment(JTextField.CENTER);
557             numTextField.setPreferredSize(new Dimension(80, 20));
558             
559             Dimension dimension = new Dimension();
560             dimension.height = 25;
561             panel.setPreferredSize(dimension);
562             
563             numLabel.setPreferredSize(new Dimension(80, 20));
564             numTextField.setPreferredSize(new Dimension(120, 20));
565             previousPageBtn.setPreferredSize(new Dimension(120, 20));
566             lastPageBtn.setPreferredSize(new Dimension(120, 20));
567             
568             panel.setLayout(new FlowLayout());
569             panel.add(previousPageBtn);
570             panel.add(numLabel);
571             panel.add(numTextField);
572             panel.add(lastPageBtn);
573             
574             previousPageBtn.setEnabled(false);
575             lastPageBtn.setEnabled(false);
576             numTextField.setEnabled(false);
577             
578             add(new JScrollPane(table), BorderLayout.CENTER);
579             add(panel, BorderLayout.SOUTH);
580             
581             // 前一页
582             previousPageBtn.addActionListener(new ActionListener() {        
583                 @Override
584                 public void actionPerformed(ActionEvent arg0) {                            
585                     SwingUtilities.invokeLater(new Runnable() {                    
586                         @Override
587                         public void run() {
588                             previousPageBtn.setEnabled(false);        
589                         }
590                     });    
591                     
592                     new SwingWorker<CANDIDATE_INFOEX[], String>() {                    
593                         @Override
594                         protected CANDIDATE_INFOEX[] doInBackground() {
595                             nBeginNum -= 17;                        
596                             
597                             CANDIDATE_INFOEX[] stuCandidatesEx = TargetRecognitionModule.doFindPerson(nBeginNum, 17);
598                             return stuCandidatesEx;
599                         }
600                         
601                         @Override
602                         protected void done() {
603                             
604                             try {
605                                 CANDIDATE_INFOEX[] stuCandidatesEx = get();
606                                 findPreviousPage(stuCandidatesEx);
607                             } catch (InterruptedException e) {
608                                 e.printStackTrace();
609                             } catch (ExecutionException e) {
610                                 e.printStackTrace();
611                             }                
612                         }
613                     }.execute();
614                 }
615             });
616             
617             // 下一页
618             lastPageBtn.addActionListener(new ActionListener() {        
619                 @Override
620                 public void actionPerformed(ActionEvent arg0) {    
621                     SwingUtilities.invokeLater(new Runnable() {                    
622                         @Override
623                         public void run() {
624                             lastPageBtn.setEnabled(false);
625                         }
626                     });    
627                     
628                     new SwingWorker<CANDIDATE_INFOEX[], String>() {                    
629                         @Override
630                         protected CANDIDATE_INFOEX[] doInBackground() {
631                             nBeginNum += 17;                        
632                             
633                             CANDIDATE_INFOEX[] stuCandidatesEx = TargetRecognitionModule.doFindPerson(nBeginNum, 17);
634                             return stuCandidatesEx;
635                         }
636                         
637                         @Override
638                         protected void done() {
639                             
640                             try {
641                                 CANDIDATE_INFOEX[] stuCandidatesEx = get();
642                                 findLastPage(stuCandidatesEx);
643                             } catch (InterruptedException e) {
644                                 e.printStackTrace();
645                             } catch (ExecutionException e) {
646                                 e.printStackTrace();
647                             }                        
648                         }
649                     }.execute();
650                 }
651             });
652         }
653     }    
654     
655     
656     
657     /*
658      * 查找前17个
659      */
660     public void findPersonInfo(CANDIDATE_INFOEX[] stuCandidatesEx) {
661         if(stuCandidatesEx != null) {
662             searchPersonBtn.setEnabled(true);
663             previousPageBtn.setEnabled(false);
664             nPagesNumber = 1;
665             numTextField.setText(String.valueOf(nPagesNumber));            
666             
667             for(int i = 0; i < stuCandidatesEx.length; i++) {
668                 if(!cadidateHashMap.containsKey(new String(stuCandidatesEx[i].stPersonInfo.szUID).trim())) {
669                     cadidateHashMap.put(new String(stuCandidatesEx[i].stPersonInfo.szUID).trim(), stuCandidatesEx[i]);
670                 }
671                 
672                 // UID
673                 defaultTableModel.setValueAt(new String(stuCandidatesEx[i].stPersonInfo.szUID).trim(), i, 0);
674                 
675                 // 姓名
676                 try {
677                     defaultTableModel.setValueAt(new String(stuCandidatesEx[i].stPersonInfo.szPersonName, "GBK").trim(), i, 1);
678                 } catch (UnsupportedEncodingException e) {
679                     e.printStackTrace();
680                 }
681                 
682                 // 性别
683                 defaultTableModel.setValueAt(Res.string().getSex(stuCandidatesEx[i].stPersonInfo.bySex & 0xff), i, 2);
684                 
685                 // 生日
686                 defaultTableModel.setValueAt(String.valueOf((int)stuCandidatesEx[i].stPersonInfo.wYear) + "-" + 
687                                              String.valueOf( stuCandidatesEx[i].stPersonInfo.byMonth & 0xff) + "-" + 
688                                              String.valueOf(stuCandidatesEx[i].stPersonInfo.byDay & 0xff), i, 3);
689                 
690                 // 证件类型
691                 defaultTableModel.setValueAt(Res.string().getIdType(stuCandidatesEx[i].stPersonInfo.byIDType & 0xff), i, 4);
692                 
693                 // 证件号
694                 try {
695                     defaultTableModel.setValueAt(new String(stuCandidatesEx[i].stPersonInfo.szID, "GBK").trim(), i, 5);
696                 } catch (UnsupportedEncodingException e) {
697                     e.printStackTrace();
698                 }    
699             }
700             
701             if(nTotalCount > nBeginNum + stuCandidatesEx.length) {
702                 lastPageBtn.setEnabled(true);
703             }
704         } else {
705             searchPersonBtn.setEnabled(true);
706             previousPageBtn.setEnabled(false);
707             lastPageBtn.setEnabled(false);
708             numTextField.setText("");
709         }
710     }
711     
712     /*
713      * 上一页查找
714      */
715     private void findPreviousPage(CANDIDATE_INFOEX[] stuCandidatesEx) {
716         if(stuCandidatesEx != null) {
717             nPagesNumber -= 1;
718             numTextField.setText(String.valueOf(nPagesNumber));
719             cadidateHashMap.clear();
720             cleanList();
721             lastPageBtn.setEnabled(true);
722             
723             for(int i = 0; i < stuCandidatesEx.length; i++) {
724                 if(!cadidateHashMap.containsKey(new String(stuCandidatesEx[i].stPersonInfo.szUID).trim())) {
725                     cadidateHashMap.put(new String(stuCandidatesEx[i].stPersonInfo.szUID).trim(), stuCandidatesEx[i]);
726                 }
727                     
728                 // UID
729                 defaultTableModel.setValueAt(new String(stuCandidatesEx[i].stPersonInfo.szUID).trim(), i, 0);
730                 
731                 // 姓名
732                 try {
733                     defaultTableModel.setValueAt(new String(stuCandidatesEx[i].stPersonInfo.szPersonName, "GBK").trim(), i, 1);
734                 } catch (UnsupportedEncodingException e) {
735                     e.printStackTrace();
736                 }
737                 
738                 // 性别
739                 defaultTableModel.setValueAt(Res.string().getSex(stuCandidatesEx[i].stPersonInfo.bySex & 0xff), i, 2);
740                 
741                 // 生日
742                 defaultTableModel.setValueAt(String.valueOf((int)stuCandidatesEx[i].stPersonInfo.wYear) + "-" + 
743                                              String.valueOf( stuCandidatesEx[i].stPersonInfo.byMonth & 0xff) + "-" + 
744                                              String.valueOf(stuCandidatesEx[i].stPersonInfo.byDay & 0xff), i, 3);
745                 
746                 // 证件类型
747                 defaultTableModel.setValueAt(Res.string().getIdType(stuCandidatesEx[i].stPersonInfo.byIDType & 0xff), i, 4);
748                 
749                 // 证件号
750                 try {
751                     defaultTableModel.setValueAt(new String(stuCandidatesEx[i].stPersonInfo.szID, "GBK").trim(), i, 5);
752                 } catch (UnsupportedEncodingException e) {
753                     e.printStackTrace();
754                 }    
755             }    
756             
757             if(nBeginNum >= 17) {        
758                 previousPageBtn.setEnabled(true);
759             } else {
760                 previousPageBtn.setEnabled(false);
761             }
762         } else{
763             JOptionPane.showMessageDialog(null, ToolKits.getErrorCodeShow(), Res.string().getErrorMessage(), JOptionPane.ERROR_MESSAGE);
764             previousPageBtn.setEnabled(true);
765             nBeginNum += 17;
766         }
767     }
768     
769     /*
770      * 下一页查找
771      */
772     private void findLastPage(CANDIDATE_INFOEX[] stuCandidatesEx) {    
773         if(stuCandidatesEx != null) {
774             nPagesNumber += 1;
775             numTextField.setText(String.valueOf(nPagesNumber));
776             cadidateHashMap.clear();
777             cleanList();
778             previousPageBtn.setEnabled(true);
779             
780             for(int i = 0; i < stuCandidatesEx.length; i++) {
781                 if(!cadidateHashMap.containsKey(new String(stuCandidatesEx[i].stPersonInfo.szUID).trim())) {
782                     cadidateHashMap.put(new String(stuCandidatesEx[i].stPersonInfo.szUID).trim(), stuCandidatesEx[i]);
783                 }
784                 
785                 // UID
786                 defaultTableModel.setValueAt(new String(stuCandidatesEx[i].stPersonInfo.szUID).trim(), i, 0);
787                 
788                 // 姓名
789                 try {
790                     defaultTableModel.setValueAt(new String(stuCandidatesEx[i].stPersonInfo.szPersonName, "GBK").trim(), i, 1);
791                 } catch (UnsupportedEncodingException e) {
792                     e.printStackTrace();
793                 }
794                 
795                 // 性别
796                 defaultTableModel.setValueAt(Res.string().getSex(stuCandidatesEx[i].stPersonInfo.bySex & 0xff), i, 2);
797                 
798                 // 生日
799                 defaultTableModel.setValueAt(String.valueOf((int)stuCandidatesEx[i].stPersonInfo.wYear) + "-" + 
800                                              String.valueOf( stuCandidatesEx[i].stPersonInfo.byMonth & 0xff) + "-" + 
801                                              String.valueOf(stuCandidatesEx[i].stPersonInfo.byDay & 0xff), i, 3);
802                 
803                 // 证件类型
804                 defaultTableModel.setValueAt(Res.string().getIdType(stuCandidatesEx[i].stPersonInfo.byIDType & 0xff), i, 4);
805                 
806                 // 证件号
807                 try {
808                     defaultTableModel.setValueAt(new String(stuCandidatesEx[i].stPersonInfo.szID, "GBK").trim(), i, 5);
809                 } catch (UnsupportedEncodingException e) {
810                     e.printStackTrace();
811                 }        
812             }                
813             
814             if(nTotalCount > nBeginNum + stuCandidatesEx.length) {
815                 lastPageBtn.setEnabled(true);            
816             } else {
817                 lastPageBtn.setEnabled(false);
818             }
819         } else {
820             JOptionPane.showMessageDialog(null, ToolKits.getErrorCodeShow(), Res.string().getErrorMessage(), JOptionPane.ERROR_MESSAGE);
821             lastPageBtn.setEnabled(true);    
822             nBeginNum -= 17;    
823         }
824     }
825     
826     /*
827      * 清空列表
828      */
829     private void cleanList() {
830         for(int i = 0; i < 17; i++) {
831             for(int j = 0; j < 6; j++) {
832                 defaultTableModel.setValueAt("", i, j);
833             }
834         }
835     }
836     
837     private Object[][] data;
838     private DefaultTableModel defaultTableModel;
839     private JTable table;
840     
841     private JButton previousPageBtn;
842     private JButton lastPageBtn;
843     private JTextField goroupIdTextField;
844     private JTextField goroupNameTextField;
845     private JTextField nameTextField;
846     private JComboBox sexComboBox;
847     private JComboBox idTypeComboBox;
848     private JTextField idTextField;
849     private JCheckBox startBirthdayCheckBox;
850     private JCheckBox endBirthdayCheckBox;
851     private DateChooserJButtonEx startTimeBtn;
852     private DateChooserJButtonEx endTimeBtn;
853     private JTextField numTextField;
854     private JButton searchPersonBtn;
855     
856 }