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
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
package com.iailab.netsdk.demo.frame.TargetRecognition;
 
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.Vector;
import java.util.concurrent.ExecutionException;
 
 
 
import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JProgressBar;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
import javax.swing.SwingWorker;
 
import com.sun.jna.Memory;
import com.sun.jna.Pointer;
 
import com.iailab.netsdk.common.DateChooserJButtonEx;
import com.iailab.netsdk.common.PaintPanel;
import com.iailab.netsdk.common.Res;
import com.iailab.netsdk.demo.module.LoginModule;
import com.iailab.netsdk.demo.module.SearchByPictureModule;
import com.iailab.netsdk.lib.NetSDKLib;
import com.iailab.netsdk.lib.ToolKits;
import com.iailab.netsdk.lib.NetSDKLib.*;
 
public class SearchByPicDialog extends JDialog {
    /**
     * 
     */
    private static final long serialVersionUID = 1L;
 
    private Vector<String> chnList = new Vector<String>(); 
    private Memory memory = null;
    private static volatile int nProgress = 0;             // 设备处理进度
    private static volatile int nCount = 0;
    
    public SearchByPicDialog() {
        setTitle(Res.string().getSearchByPic());
        setLayout(new BorderLayout());
        setModal(true);  
        pack();
        setSize(780, 550);
        setResizable(false);
        setLocationRelativeTo(null);
        setDefaultCloseOperation(DISPOSE_ON_CLOSE);   // 释放窗体
            
        JPanel panel = new JPanel();
        progressBar = new JProgressBar(0, 100);
        Dimension dimension = new Dimension();
        dimension.height = 18;
        progressBar.setPreferredSize(dimension);
        progressBar.setStringPainted(true);
        
        add(panel, BorderLayout.CENTER);
        add(progressBar, BorderLayout.SOUTH);
        
        ////////
        panel.setLayout(new BorderLayout());
        SearchPicConditionPanel searchPicConditionPanel = new SearchPicConditionPanel();
        searchPicInfoTextArea = new JTextArea();
        
        Dimension dimension1 = new Dimension();
        dimension1.width = 220;    
        searchPicConditionPanel.setPreferredSize(dimension1);
        
        panel.add(searchPicConditionPanel, BorderLayout.WEST);
        panel.add(new JScrollPane(searchPicInfoTextArea), BorderLayout.CENTER);
        
        addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                dispose();
            }
        });
    }
    
    private class SearchPicConditionPanel extends JPanel {
 
        /**
         * 
         */
        private static final long serialVersionUID = 1L;
        
        public SearchPicConditionPanel() {
            setLayout(new BorderLayout());
            
            JPanel panelNorth = new JPanel();
            JPanel panelSouth = new JPanel();
            
            add(panelNorth, BorderLayout.NORTH);
            add(panelSouth, BorderLayout.SOUTH);
            
            ////////
            searchPicPanel = new PaintPanel();
            JButton selectPicBtn = new JButton(Res.string().getSelectPicture());
            JButton downloadBtn = new JButton(Res.string().getDownloadQueryPicture());
            
            searchPicPanel.setPreferredSize(new Dimension(210, 270));
            selectPicBtn.setPreferredSize(new Dimension(210, 20));
            downloadBtn.setPreferredSize(new Dimension(210, 20));
        
            panelNorth.setLayout(new FlowLayout());
            panelNorth.setPreferredSize(new Dimension(210, 330));
            panelNorth.add(searchPicPanel);
            panelNorth.add(selectPicBtn);
            panelNorth.add(downloadBtn);
            
            /////
            faceCheckBox = new JCheckBox(Res.string().getFaceLibrary());
            historyCheckBox = new JCheckBox(Res.string().getHistoryLibrary());
            faceCheckBox.setPreferredSize(new Dimension(100, 20));
            historyCheckBox.setPreferredSize(new Dimension(100, 20));
 
            startTimeLabel = new JLabel(Res.string().getStartTime(), JLabel.CENTER);
            endTimeLabel = new JLabel(Res.string().getEndTime(), JLabel.CENTER);
            chnLabel = new JLabel(Res.string().getChannel(), JLabel.CENTER);
            JLabel similaryLabel = new JLabel(Res.string().getSimilarity(), JLabel.CENTER);
        
            Dimension dimension1 = new Dimension();
            dimension1.width = 80;
            dimension1.height = 20;
            
            startTimeLabel.setPreferredSize(dimension1);
            endTimeLabel.setPreferredSize(dimension1);
            chnLabel.setPreferredSize(dimension1);
            similaryLabel.setPreferredSize(dimension1);
            
            startTimeBtn = new DateChooserJButtonEx("2018-11-07");
            endTimeBtn = new DateChooserJButtonEx();
            
            chnComboBox = new JComboBox(); 
            for(int i = 1; i < LoginModule.m_stDeviceInfo.byChanNum + 1; i++) {
                chnList.add(Res.string().getChannel() + " " + String.valueOf(i));
            }
            
            // 登陆成功,将通道添加到控件
            chnComboBox.setModel(new DefaultComboBoxModel(chnList));
            
            similaryTextField = new JTextField("60", JTextField.CENTER);
            
            Dimension dimension2 = new Dimension();
            dimension2.width = 120;
            dimension2.height = 20;
            
            startTimeBtn.setPreferredSize(dimension2);
            endTimeBtn.setPreferredSize(dimension2);
            chnComboBox.setPreferredSize(dimension2);
            similaryTextField.setPreferredSize(dimension2);
            
            searchPicBtn = new JButton(Res.string().getSearch());
            searchPicBtn.setPreferredSize(new Dimension(210, 20));
            
            panelSouth.setLayout(new FlowLayout());
            panelSouth.setPreferredSize(new Dimension(210, 160));
            panelSouth.add(faceCheckBox);
            panelSouth.add(historyCheckBox);
            panelSouth.add(startTimeLabel);
            panelSouth.add(startTimeBtn);
            panelSouth.add(endTimeLabel);
            panelSouth.add(endTimeBtn);
            panelSouth.add(chnLabel);
            panelSouth.add(chnComboBox);
            panelSouth.add(similaryLabel);
            panelSouth.add(similaryTextField);
            panelSouth.add(searchPicBtn);
            
            historyCheckBox.setSelected(true);
            faceCheckBox.setSelected(false);
            
            // 选择图片,获取图片的信息
            selectPicBtn.addActionListener(new ActionListener() {                
                @Override
                public void actionPerformed(ActionEvent arg0) {
                    String picPath = "";
                    
                    // 选择图片,获取图片路径,并在界面显示
                    picPath = ToolKits.openPictureFile(searchPicPanel);
                            
                    if(!picPath.equals("")) {
                        try {
                            memory = ToolKits.readPictureFile(picPath);
                        } catch (IOException e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        }
                    }
            
                }
            });
            
            downloadBtn.addActionListener(new ActionListener() {                
                @Override
                public void actionPerformed(ActionEvent arg0) {
                    DownloadPictureDialog dialog = new DownloadPictureDialog();
                    dialog.setVisible(true);        
                }
            });
            
            searchPicBtn.addActionListener(new ActionListener() {                
                @Override
                public void actionPerformed(ActionEvent arg0) {
                    SwingUtilities.invokeLater(new Runnable() {                
                        @Override
                        public void run() {
                            searchPicBtn.setEnabled(false);
                            progressBar.setValue(0);
                            searchPicInfoTextArea.setText("");
                        }
                    });
                    
                    searchByPicture();
                }
            });
            
            faceCheckBox.addActionListener(new ActionListener() {                
                @Override
                public void actionPerformed(ActionEvent arg0) {
                    if(faceCheckBox.isSelected()) {
                        historyCheckBox.setSelected(false);
                        chnLabel.setVisible(false);
                        chnComboBox.setVisible(false);
                        startTimeLabel.setVisible(false);
                        endTimeLabel.setVisible(false);
                        startTimeBtn.setVisible(false);
                        endTimeBtn.setVisible(false);
                    } else {
                        historyCheckBox.setSelected(true);
                        chnLabel.setVisible(true);
                        chnComboBox.setVisible(true);
                        startTimeLabel.setVisible(true);
                        endTimeLabel.setVisible(true);
                        startTimeBtn.setVisible(true);
                        endTimeBtn.setVisible(true);
                    }                    
                }
            });
            
            historyCheckBox.addActionListener(new ActionListener() {                
                @Override
                public void actionPerformed(ActionEvent arg0) {
                    if(historyCheckBox.isSelected()) {
                        faceCheckBox.setSelected(false);
                        chnLabel.setVisible(true);
                        chnComboBox.setVisible(true);
                        startTimeLabel.setVisible(true);
                        endTimeLabel.setVisible(true);
                        startTimeBtn.setVisible(true);
                        endTimeBtn.setVisible(true);
                    } else {
                        faceCheckBox.setSelected(true);
                        chnLabel.setVisible(false);
                        chnComboBox.setVisible(false);
                        startTimeLabel.setVisible(false);
                        endTimeLabel.setVisible(false);
                        startTimeBtn.setVisible(false);
                        endTimeBtn.setVisible(false);
                    }                    
                }
            });
        }
    }
    
    private void searchByPicture() {
        new SwingWorker<Boolean, StringBuffer>() {
            int nTotalCount = 0;      // 查询到的总个数
            
            @Override
            protected Boolean doInBackground() {                            
                int beginNum = 0;     // 偏移量
                int nCount = 0;          // 循环查询了几次    
                int index = 0;           // index + 1 为查询到的总个数    
                int nFindCount = 10;  // 每次查询的个数
                
                StringBuffer message = null;
                
                if(memory == null) {
                    JOptionPane.showMessageDialog(null, Res.string().getChooseFacePic(), Res.string().getErrorMessage(), JOptionPane.ERROR_MESSAGE);
                    return false;
                }
                
                // 获取查询句柄
                nTotalCount = SearchByPictureModule.startFindPerson(memory, 
                                                                   startTimeBtn.getText(), 
                                                                   endTimeBtn.getText(), 
                                                                   historyCheckBox.isSelected(),
                                                                   chnComboBox.getSelectedIndex(), 
                                                                   similaryTextField.getText());
                if(nTotalCount == 0) {   // 查询失败                
                    // 查询失败,关闭查询
                    SearchByPictureModule.doFindClosePerson();             
                    return false;
                } else if(nTotalCount == -1) {  // 设备正在处理,通过订阅来查询处理进度
                    nProgress = 0;
                    nCount = 0;
                    SearchByPictureModule.attachFaceFindState(fFaceFindStateCb.getInstance());        
                } else {                
                    while(true) {
                        CANDIDATE_INFOEX[] caInfoexs = SearchByPictureModule.doFindNextPerson(beginNum, nFindCount);
                        if(caInfoexs == null) {
                            break;
                        }
                        
                        for(int i = 0; i < caInfoexs.length; i++) {
                            index = i + nFindCount * nCount + 1;
                            
                            // 清空
                            message = new StringBuffer();
                            
                            if(historyCheckBox.isSelected()) {    // 历史库显示
                                message.append("[" + index + "]"+Res.string().getTime()+":" + caInfoexs[i].stTime.toStringTimeEx() + "\n");
                            
                                message.append("[" + index + "]"+Res.string().getUid()+":" + new String(caInfoexs[i].stPersonInfo.szUID).trim() + "\n");
                                message.append("[" + index + "]"+Res.string().getSex()+":" + Res.string().getSex(caInfoexs[i].stPersonInfo.bySex) + "\n");
                                message.append("[" + index + "]"+Res.string().getAge()+":" + caInfoexs[i].stPersonInfo.byAge + "\n");
                                message.append("[" + index + "]"+Res.string().getColor()+":" + Res.string().getColor(0) + "\n");
                                message.append("[" + index + "]"+Res.string().getEye()+":" + Res.string().getEyeState(caInfoexs[i].stPersonInfo.emEye) + "\n");
                                message.append("[" + index + "]"+Res.string().getMouth()+":" + Res.string().getMouthState(caInfoexs[i].stPersonInfo.emMouth) + "\n");
                                message.append("[" + index + "]"+Res.string().getMask()+":" + Res.string().getMaskState(caInfoexs[i].stPersonInfo.emMask) + "\n");
                                message.append("[" + index + "]"+Res.string().getBeard()+":" + Res.string().getBeardState(caInfoexs[i].stPersonInfo.emBeard) + "\n");
                                message.append("[" + index + "]"+Res.string().getGlasses()+":" + Res.string().getGlasses(caInfoexs[i].stPersonInfo.byGlasses) + "\n");
                                message.append("[" + index + "]"+Res.string().getSimilarity()+":" + caInfoexs[i].bySimilarity + "\n");
                                message.append("[" + index + "]"+Res.string().getPicturePath()+":" + caInfoexs[i].stPersonInfo.szFacePicInfo[0].pszFilePath.getString(0) + "\n");
            
                            } else {                              // 人脸库显示
                                message.append("[" + index + "]"+Res.string().getFaceLibraryID()+":" + new String(caInfoexs[i].stPersonInfo.szGroupID).trim() + "\n");
                                try {
                                    message.append("[" + index + "]"+Res.string().getFaceLibraryName()+":" + new String(caInfoexs[i].stPersonInfo.szGroupName, "GBK").trim() + "\n");                    
                                    message.append("[" + index + "]"+Res.string().getName()+":" + new String(caInfoexs[i].stPersonInfo.szPersonName, "GBK").trim() + "\n");
                                } catch (UnsupportedEncodingException e) {
                                    e.printStackTrace();
                                }
                                message.append("[" + index + "]"+Res.string().getUid()+":" + new String(caInfoexs[i].stPersonInfo.szUID).trim() + "\n");
                                message.append("[" + index + "]"+Res.string().getBirthday()+":" + (caInfoexs[i].stPersonInfo.wYear) + "-" + 
                                                                        (0xff & caInfoexs[i].stPersonInfo.byMonth) + "-" +
                                                                        (0xff & caInfoexs[i].stPersonInfo.byDay) + "\n");
                                message.append("[" + index + "]"+Res.string().getSex()+":" + Res.string().getSex(caInfoexs[i].stPersonInfo.bySex) + "\n");
                                message.append("[" + index + "]"+Res.string().getCardType()+":" + Res.string().getIdType(caInfoexs[i].stPersonInfo.byIDType) + "\n");
                                message.append("[" + index + "]"+Res.string().getCardNum()+":" + new String(caInfoexs[i].stPersonInfo.szID).trim() + "\n");
                                message.append("[" + index + "]"+Res.string().getSimilarity()+":" + caInfoexs[i].bySimilarity + "\n");
                                message.append("[" + index + "]"+Res.string().getPicturePath()+":" + caInfoexs[i].stPersonInfo.szFacePicInfo[0].pszFilePath.getString(0) + "\n");
                            }
                            
                            message.append("\n");
                            publish(message);
                        }
                        
                        if(caInfoexs.length < nFindCount) {
                            System.out.printf("No More Record, Find End!\n");
                            break;
                        } else {
                            beginNum += nFindCount;
                            nCount++;
                        }
                    }    
                    
                    // 关闭查询
                    SearchByPictureModule.doFindClosePerson(); 
                }
 
                return true;
            }
            
            @Override
            protected void process(java.util.List<StringBuffer> chunks) {
                for(StringBuffer data : chunks) {
                    searchPicInfoTextArea.append(data.toString());
                    searchPicInfoTextArea.updateUI();
                }
                
                super.process(chunks);
            }
            
            @Override
            protected void done() {
                if(nTotalCount == 0) {           // 查询总个数失败
                    searchPicBtn.setEnabled(true);
                    progressBar.setValue(100);
                    searchPicInfoTextArea.append("未查询到相关信息... \n");
                    searchPicInfoTextArea.updateUI();
                } else if(nTotalCount == -1){    // 设备在处理中
                    searchPicInfoTextArea.append(Res.string().getLoading()+"... \n");
                    searchPicInfoTextArea.updateUI();
                } else {
                    try {
                        if(get()) {             // 其他情况,查询信息结束
                            searchPicBtn.setEnabled(true);
                            progressBar.setValue(100);
                            searchPicInfoTextArea.append("查询结束... \n");
                            searchPicInfoTextArea.updateUI();
                        }
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    } catch (ExecutionException e) {
                        e.printStackTrace();
                    }
                }        
            }
        }.execute();
    }
    
    /**
     * 订阅人脸回调函数
     */
    private static class fFaceFindStateCb implements NetSDKLib.fFaceFindState {    
        private fFaceFindStateCb() {}
        
        private static class fFaceFindStateCbHolder {
            private static final fFaceFindStateCb instance = new fFaceFindStateCb();
        }
        
        public static fFaceFindStateCb getInstance() {
            return fFaceFindStateCbHolder.instance;
        }
        
        @Override
        public void invoke(LLong lLoginID, LLong lAttachHandle,
                Pointer pstStates, int nStateNum, Pointer dwUser) {
            if(nStateNum < 1) {
                return;
            }
            NET_CB_FACE_FIND_STATE[] msg = new NET_CB_FACE_FIND_STATE[nStateNum];
            for(int i = 0; i < nStateNum; i++) {
                msg[i] = new NET_CB_FACE_FIND_STATE();
            }
            ToolKits.GetPointerDataToStructArr(pstStates, msg);
            
            for(int i = 0; i < nStateNum; i++) {
                if(SearchByPictureModule.nToken == msg[i].nToken) {            
                    nProgress = msg[i].nProgress;    
                    nCount = msg[i].nCurrentCount; // 返回的总个数
                                
                    // 刷新设备处理进度
                    // UI线程
                    EventQueue.invokeLater(new Runnable() {                            
                        @Override
                        public void run() {
                            progressBar.setValue(nProgress);    
                            
                            if(nProgress == 100) {                        // 进度等于100,设备处理完毕,开始查询
                                // 异步线程处理
                                new SearchPictureWoker(nCount).execute();                        
                            }
                        }
                    });             
                }
            }
        }    
    }
    
    /**
     * 用于订阅人脸状态后的查询
     * 以图搜图与查询人员信息的接口是一样的,只是逻辑不一样,doFindNextPerson接口时,都是指定每次查询的个数,最大20,然后根据偏移量循环查询
     * SwingWorker为异步线程,回调属于子线程,不能做耗时操作和刷新UI
     */
    private static class SearchPictureWoker extends SwingWorker<Boolean, StringBuffer> {        
        private int nTotalCount;  // 查询到的总个数
        public SearchPictureWoker(int nTotalCount) {
            this.nTotalCount = nTotalCount;
        }
        
        @Override
        protected Boolean doInBackground() {
            int beginNum = 0;     // 偏移量
            int nCount = 0;          // 循环查询了几次    
            int index = 0;           // index + 1 为查询到的总个数    
            int nFindCount = 10;  // 每次查询的个数
            
            StringBuffer message = null;
            
            // 进度达到100%,关闭订阅
            SearchByPictureModule.detachFaceFindState();
            System.out.println("nTotalCount = " + nTotalCount);
            if(nTotalCount == 0) {
                // 关闭查询
                SearchByPictureModule.doFindClosePerson();
                return false;
            }
                            
            while(true) {
                CANDIDATE_INFOEX[] caInfoexs = SearchByPictureModule.doFindNextPerson(beginNum, nFindCount);
                if(caInfoexs == null) {
                    break;
                }
 
                for(int i = 0; i < caInfoexs.length; i++) {
                    index = i + nFindCount * nCount + 1;
                    
                    // 清空
                    message = new StringBuffer();
                    
                    if(historyCheckBox.isSelected()) {    // 历史库显示
                        message.append("[" + index + "]"+Res.string().getTime()+":" + caInfoexs[i].stTime.toStringTimeEx() + "\n");
                        
                        message.append("[" + index + "]"+Res.string().getUid()+":" + new String(caInfoexs[i].stPersonInfo.szUID).trim() + "\n");
                        message.append("[" + index + "]"+Res.string().getSex()+":" + Res.string().getSex(caInfoexs[i].stPersonInfo.bySex) + "\n");
                        message.append("[" + index + "]"+Res.string().getAge()+":" + caInfoexs[i].stPersonInfo.byAge + "\n");
                        message.append("[" + index + "]"+Res.string().getColor()+":" + Res.string().getColor(0) + "\n");
                        message.append("[" + index + "]"+Res.string().getEye()+":" + Res.string().getEyeState(caInfoexs[i].stPersonInfo.emEye) + "\n");
                        message.append("[" + index + "]"+Res.string().getMouth()+":" + Res.string().getMouthState(caInfoexs[i].stPersonInfo.emMouth) + "\n");
                        message.append("[" + index + "]"+Res.string().getMask()+":" + Res.string().getMaskState(caInfoexs[i].stPersonInfo.emMask) + "\n");
                        message.append("[" + index + "]"+Res.string().getBeard()+":" + Res.string().getBeardState(caInfoexs[i].stPersonInfo.emBeard) + "\n");
                        message.append("[" + index + "]"+Res.string().getGlasses()+":" + Res.string().getGlasses(caInfoexs[i].stPersonInfo.byGlasses) + "\n");
                        message.append("[" + index + "]"+Res.string().getSimilarity()+":" + caInfoexs[i].bySimilarity + "\n");
                        message.append("[" + index + "]"+Res.string().getPicturePath()+":" + caInfoexs[i].stPersonInfo.szFacePicInfo[0].pszFilePath.getString(0) + "\n");
                    
                    } else {                             // 人脸库显示
                        message.append("[" + index + "]"+Res.string().getFaceLibraryID()+":" + new String(caInfoexs[i].stPersonInfo.szGroupID).trim() + "\n");
                        try {
                            message.append("[" + index + "]"+Res.string().getFaceLibraryName()+":" + new String(caInfoexs[i].stPersonInfo.szGroupName, "GBK").trim() + "\n");                    
                            message.append("[" + index + "]"+Res.string().getName()+":" + new String(caInfoexs[i].stPersonInfo.szPersonName, "GBK").trim() + "\n");
                        } catch (UnsupportedEncodingException e) {
                            e.printStackTrace();
                        }
                        message.append("[" + index + "]"+Res.string().getUid()+":" + new String(caInfoexs[i].stPersonInfo.szUID).trim() + "\n");
                        message.append("[" + index + "]"+Res.string().getBirthday()+":" + (caInfoexs[i].stPersonInfo.wYear) + "-" + 
                                                                (0xff & caInfoexs[i].stPersonInfo.byMonth) + "-" +
                                                                (0xff & caInfoexs[i].stPersonInfo.byDay) + "\n");
                        message.append("[" + index + "]"+Res.string().getSex()+":" + Res.string().getSex(caInfoexs[i].stPersonInfo.bySex) + "\n");
                        message.append("[" + index + "]"+Res.string().getCardType()+":" + Res.string().getIdType(caInfoexs[i].stPersonInfo.byIDType) + "\n");
                        message.append("[" + index + "]"+Res.string().getCardNum()+":" + new String(caInfoexs[i].stPersonInfo.szID).trim() + "\n");
                        message.append("[" + index + "]"+Res.string().getSimilarity()+":" + caInfoexs[i].bySimilarity + "\n");
                        message.append("[" + index + "]"+Res.string().getPicturePath()+":" + caInfoexs[i].stPersonInfo.szFacePicInfo[0].pszFilePath.getString(0) + "\n");
                    }
                    
                    message.append("\n");
                    publish(message);
                }
                
                if(caInfoexs.length < nFindCount) {
                    System.out.printf("No More Record, Find End!\n");
                    break;
                } else {
                    beginNum += nFindCount;
                    nCount++;
                }
            }    
            
            // 关闭查询
            SearchByPictureModule.doFindClosePerson(); 
 
            return true;
        }
        
        @Override
        protected void process(java.util.List<StringBuffer> chunks) {
            for(StringBuffer data : chunks) {
                searchPicInfoTextArea.append(data.toString());
                searchPicInfoTextArea.updateUI();
            }
            
            super.process(chunks);
        }
        
        @Override
        protected void done() {    
            searchPicBtn.setEnabled(true);
            searchPicInfoTextArea.append(Res.string().getEndSearch()+"... \n");
            searchPicInfoTextArea.updateUI();
        }
    }
 
    
    private static JTextArea searchPicInfoTextArea;
    private static JProgressBar progressBar;
    private static JButton searchPicBtn;
    
    private PaintPanel searchPicPanel;
    private JComboBox chnComboBox;
    private JTextField similaryTextField;
    private DateChooserJButtonEx startTimeBtn;
    private DateChooserJButtonEx endTimeBtn;
    private JLabel chnLabel;
    private JLabel startTimeLabel;
    private JLabel endTimeLabel;
    
    private JCheckBox faceCheckBox;
    private static JCheckBox historyCheckBox;
}