Blame view

src/com/ectrip/cyt/ui/ScanHeadActivity.java 25.9 KB
90601e4f   黄灿宏   标准版本 1.扩展设备10 增...
1
2
3
  package com.ectrip.cyt.ui;
  
  import android.annotation.SuppressLint;
c05c7a9b   黄灿宏   标准版本 1.扩展设备8 2....
4
  import android.content.Context;
90601e4f   黄灿宏   标准版本 1.扩展设备10 增...
5
6
7
8
9
10
11
12
13
14
15
16
  import android.content.Intent;
  import android.os.Bundle;
  import android.os.Handler;
  import android.os.Message;
  import android.text.TextUtils;
  import android.util.Log;
  import android.view.View;
  import android.widget.Button;
  import android.widget.LinearLayout;
  import android.widget.TextView;
  import android.widget.Toast;
  
c05c7a9b   黄灿宏   标准版本 1.扩展设备8 2....
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
  //import com.ectrip.scanbarcode_jp.NETutils.WebserviceHelper;
  //import com.ectrip.scanbarcode_jp.R;
  //import com.ectrip.scanbarcode_jp.bean.IdBean;
  //import com.ectrip.scanbarcode_jp.callBack.CheckCallBack;
  //import com.ectrip.scanbarcode_jp.callBack.CheckCallBack_ZJ;
  //import com.ectrip.scanbarcode_jp.callBack.CountCallBack;
  //import com.ectrip.scanbarcode_jp.constens.ParamContants;
  //import com.ectrip.scanbarcode_jp.constens.ParameterContens;
  //import com.ectrip.scanbarcode_jp.utils.LogUtil;
  //import com.ectrip.scanbarcode_jp.utils.PreferenceUtils;
  //import com.ectrip.scanbarcode_jp.utils.SoundUtil;
  //import com.ectrip.scanbarcode_jp.utils.TimesUtils;
  //import com.ectrip.scanbarcode_jp.zxing.MyMap;
  import com.ectrip.cyt.bean.IdBean;
  import com.ectrip.cyt.utils.CountDownTimer;
  import com.ectrip.cyt.utils.LogUtil;
  import com.ectrip.cyt.utils.SoundUtil;
  import com.ectrip.trips.check.R;
90601e4f   黄灿宏   标准版本 1.扩展设备10 增...
35
36
37
38
39
40
41
42
43
44
  import com.google.gson.Gson;
  import com.zkteco.android.biometric.core.device.ParameterHelper;
  import com.zkteco.android.biometric.core.device.TransportType;
  import com.zkteco.android.biometric.core.utils.LogHelper;
  import com.zkteco.android.biometric.module.idcard.IDCardReader;
  import com.zkteco.android.biometric.module.idcard.IDCardReaderFactory;
  import com.zkteco.android.biometric.module.idcard.exception.IDCardReaderException;
  import com.zkteco.android.biometric.module.idcard.meta.IDCardInfo;
  import com.znht.iodev2.PowerCtl;
  
c05c7a9b   黄灿宏   标准版本 1.扩展设备8 2....
45
  import java.util.Date;
90601e4f   黄灿宏   标准版本 1.扩展设备10 增...
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
  import java.util.HashMap;
  import java.util.List;
  import java.util.Map;
  
  public class ScanHeadActivity extends BaseActivity {
  
      private static final String TAG = "ScanHeadActivity";
  
      private final String idSerialName = "/dev/ttysWK2";  //串口路径
      private final int idBaudrate = 115200;//波特率
      private IDCardReader idCardReader;  //二代证读头
      private com.znht.iodev2.PowerCtl powerCtl; //模块供电控制
  
      private TextView noId;
      private TextView title;
c05c7a9b   黄灿宏   标准版本 1.扩展设备8 2....
61
62
  //    private TextView count_textView;
      private TextView topBack;
90601e4f   黄灿宏   标准版本 1.扩展设备10 增...
63
64
65
66
67
      private TextView tv_ship_name;
      private TextView tv_ship_check;
      private LinearLayout ll_ship,ll_bottom;
      private TextView tv_total_number;
      private TextView tv_number;
c05c7a9b   黄灿宏   标准版本 1.扩展设备8 2....
68
      private String titleName;
90601e4f   黄灿宏   标准版本 1.扩展设备10 增...
69
70
71
72
73
74
75
76
77
78
      private int type;
      private String gardenID;
      private String isIDinFree;
      private String local_age = "0";
      private String local_addr = "0";
      private String local_sex = "0";
      private String local_id = "0";
  
      private Toast toast;
      private ReadThread mThread;
c05c7a9b   黄灿宏   标准版本 1.扩展设备8 2....
79
      private Context mContext;
90601e4f   黄灿宏   标准版本 1.扩展设备10 增...
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
  
      private void showToast(String info) {
          if (toast == null) {
              toast = Toast.makeText(mContext, info, Toast.LENGTH_SHORT);
          } else {
              toast.setText(info);
          }
          toast.show();
      }
  
      private final int MSG_INIT_DEV = 0;
      private final int MSG_GET_ID = 1;
      private final int MSG_FIND_ID = 2;
      private final int MSG_SHOW_TOAST = 3;
      private final int MSG_SHOW_SHIP = 4;
      private String showCountType;
      private int checktype;
      @SuppressLint("HandlerLeak")
      private Handler mHandle = new Handler() {
          public void handleMessage(Message msg) {
              switch (msg.what) {
                  case MSG_INIT_DEV:
                      initIDCard();
                      break;
                  case MSG_GET_ID:
                      showToast("读身份证成功!");
c05c7a9b   黄灿宏   标准版本 1.扩展设备8 2....
106
                      SoundUtil.getInstents(ScanHeadActivity.this).playWavSound(R.raw.beep);
90601e4f   黄灿宏   标准版本 1.扩展设备10 增...
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
  
                      IDCardInfo idCardInfo = (IDCardInfo) msg.obj;
                      IdBean idBean = new IdBean();
                      idBean.setId(idCardInfo.getId());
                      idBean.setName(idCardInfo.getName());
                      idBean.setSex(idCardInfo.getSex());
                      idBean.setAddr(idCardInfo.getAddress());
  
                      checkByID(idBean);
                      break;
                  case MSG_FIND_ID:
                      showToast("发现身份证!");
                      break;
                  case MSG_SHOW_TOAST:
                      String content = (String) msg.obj;
                      showToast(content);
                      break;
                  case MSG_SHOW_SHIP:
c05c7a9b   黄灿宏   标准版本 1.扩展设备8 2....
125
  //                    getShowShipType();
90601e4f   黄灿宏   标准版本 1.扩展设备10 增...
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
                      mHandle.sendEmptyMessageDelayed(MSG_SHOW_SHIP, 10000);
                      break;
                  default:
                      break;
              }
          }
      };
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_scan_head);
  
          initView();
          initData();
          initListener();
  
          mHandle.sendEmptyMessageDelayed(MSG_INIT_DEV, 100);
      }
  
      @Override
      protected void onResume() {
          super.onResume();
c05c7a9b   黄灿宏   标准版本 1.扩展设备8 2....
149
150
151
  //        showCountType();
  //        int count = PreferenceUtils.getInt(mContext, "count", 0);
  //        count_textView.setText(String.valueOf(count));
90601e4f   黄灿宏   标准版本 1.扩展设备10 增...
152
153
154
155
156
157
158
          running = true;
          mThread = new ReadThread();
          mThread.start();
  
          mHandle.sendEmptyMessageDelayed(MSG_SHOW_SHIP, 100);
      }
  
c05c7a9b   黄灿宏   标准版本 1.扩展设备8 2....
159
160
161
162
163
164
165
  //    private void getShowShipType() {
  //
  //        String count = PreferenceUtils.getString(mContext, ParamContants.GET_PASS_TOTAL, "0/0");
  //        String name = PreferenceUtils.getString(mContext, ParamContants.GET_SHIP_NAME, "");
  //        tv_ship_check.setText(count);
  //        tv_ship_name.setText(name);
  //    }
90601e4f   黄灿宏   标准版本 1.扩展设备10 增...
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
  
      /**
       * 初始化身份证模块
       */
      private void initIDCard() {
          try {
              //打开二代证供电
              powerCtl = new PowerCtl();
              powerCtl.identity_uhf_power(1);
              powerCtl.identity_ctl(1);
              // Define output log level
              LogHelper.setLevel(Log.VERBOSE);
              // Start fingerprint sensor
              Map idrparams = new HashMap();
              //设置串口和波特率
              idrparams.put(ParameterHelper.PARAM_SERIAL_SERIALNAME, idSerialName);
              idrparams.put(ParameterHelper.PARAM_SERIAL_BAUDRATE, idBaudrate);
              //打开二代证模块
              idCardReader = IDCardReaderFactory.createIDCardReader(mContext, TransportType.SERIALPORT, idrparams);
              if (idCardReader != null) {
                  //打开模块
                  try {
                      Thread.sleep(500);
                  } catch (InterruptedException e) {
                      e.printStackTrace();
                  }
                  idCardReader.open(0);
              }
          } catch (IDCardReaderException e) {
              //打开模块失败给出提示
c05c7a9b   黄灿宏   标准版本 1.扩展设备8 2....
196
197
              Toast.makeText(this, "模块打开失败", Toast.LENGTH_SHORT).show();
              LogHelper.d("错误信息" + ": " + e.getMessage() + "\n" + "错误码" + e.getInternalErrorCode());
90601e4f   黄灿宏   标准版本 1.扩展设备10 增...
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
          }
      }
  
      @Override
      protected void onPause() {
          super.onPause();
  
          running = false;
  
          mHandle.removeMessages(MSG_GET_ID);
          mHandle.removeMessages(MSG_FIND_ID);
          mHandle.removeMessages(MSG_SHOW_TOAST);
          mHandle.removeMessages(MSG_SHOW_SHIP);
  
      }
  
      @Override
      protected void onStop() {
          super.onStop();
      }
  
      private void initView() {
c05c7a9b   黄灿宏   标准版本 1.扩展设备8 2....
220
221
222
223
224
  //        tv_ship_name = (TextView) findViewById(R.id.tv_ship_name);
  //        tv_ship_check = (TextView) findViewById(R.id.tv_ship_check);
  //        ll_ship = (LinearLayout) findViewById(R.id.ll_ship);
  //        ll_bottom = (LinearLayout) findViewById(R.id.ll_bottom);
          topBack = (TextView) findViewById(R.id.topBack);
90601e4f   黄灿宏   标准版本 1.扩展设备10 增...
225
          noId = (TextView) findViewById(R.id.tv_no_id);
c05c7a9b   黄灿宏   标准版本 1.扩展设备8 2....
226
227
228
229
          title = (TextView) findViewById(R.id.title);
  //        count_textView = (TextView) findViewById(R.id.top_count);
  //        tv_total_number = (TextView) findViewById(R.id.tv_total_number);
  //        tv_number = (TextView) findViewById(R.id.tv_szticketname);
90601e4f   黄灿宏   标准版本 1.扩展设备10 增...
230
          //提示读取身份证区
c05c7a9b   黄灿宏   标准版本 1.扩展设备8 2....
231
232
233
234
235
236
  //        String keepType = PreferenceUtils.getString(mContext, "keepScreenOn", "yes");
  //        if (keepType.equals("yes")) {
  //            topBack.setKeepScreenOn(true);
  //        } else {
  //            topBack.setKeepScreenOn(false);
  //        }
90601e4f   黄灿宏   标准版本 1.扩展设备10 增...
237
238
  
          type = getIntent().getIntExtra("type", -1);
c05c7a9b   黄灿宏   标准版本 1.扩展设备8 2....
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
  //        if (type == 1) {
  //            title.setText("检票—身份证");
  //        } else if (type == 2) {
  //            title.setText("监票");
  //        }
  
  //        String showShipType = PreferenceUtils.getString(mContext, "showShipType", "no");
  //        checktype = PreferenceUtils.getInt(mContext, "CHECKTYPE", 0);
  //        LogUtil.e(TAG, "showShipType = " + showShipType);
  //        if (TextUtils.equals("yes", showShipType)) {
  //            ll_ship.setVisibility(View.VISIBLE);
  //        } else {
  //            ll_ship.setVisibility(View.GONE);
  //        }
  //        showCountType = PreferenceUtils.getString(mContext, "showCountType", "no");
  //        if (TextUtils.equals("yes", showCountType) ) {
  //            ll_bottom.setVisibility(View.VISIBLE);
  //        } else {
  //            ll_bottom.setVisibility(View.GONE);
  //        }
90601e4f   黄灿宏   标准版本 1.扩展设备10 增...
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
      }
  
      private void initListener() {
          //点击头部返回键,关闭当前activity
          topBack.setOnClickListener(new View.OnClickListener() {
  
              public void onClick(View v) {
                  finish();
              }
          });
          noId.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  Intent phone = new Intent(mContext, InputIdCardActivity.class);
                  phone.putExtra("type", type);
                  startActivity(phone);
              }
          });
      }
  
      private void initData() {
c05c7a9b   黄灿宏   标准版本 1.扩展设备8 2....
280
281
282
283
284
285
          mContext = this;
          titleName=getIntent().getStringExtra("titleName");
          if(titleName!=null){
              ((TextView)findViewById(R.id.title)).setText(titleName);
          }else{
              ((TextView)findViewById(R.id.title)).setText(R.string.scan_id);
90601e4f   黄灿宏   标准版本 1.扩展设备10 增...
286
          }
c05c7a9b   黄灿宏   标准版本 1.扩展设备8 2....
287
288
289
290
291
292
293
294
295
296
297
298
  //        gardenID = PreferenceUtils.getString(mContext, ParamContants.GET_ACCID, "");
  //        isIDinFree = PreferenceUtils.getString(mContext, ParameterContens.SET_isIDinFree, "no");
  
  //        String localStr = PreferenceUtils.getString(mContext, ParameterContens.SET_isIDinFreeContent, "");
  //        LogUtil.i(TAG, "本地免票数据 2 == " + localStr);
  //        if (!TextUtils.isEmpty(localStr)) {
  //            String[] locals = localStr.split(";");
  //            local_age = locals[0];
  //            local_addr = locals[1];
  //            local_sex = locals[2];
  //            local_id = locals[3];
  //        }
90601e4f   黄灿宏   标准版本 1.扩展设备10 增...
299
300
301
302
303
      }
  
      private void checkByID(final IdBean idBean) {
          String data = "";
          String barcode = idBean.getId();
c05c7a9b   黄灿宏   标准版本 1.扩展设备8 2....
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
          LogUtil.d(TAG,"获取的身份证号:" +barcode);
  
          Intent intent = new Intent(ScanHeadActivity.this,
                  IDOrderListActivity.class);
          CountDownTimer.firstTime = new Date().getTime();// 不必要的可以删除
          intent.putExtra("mode", 0);
          intent.putExtra("idcardNumber", barcode);
          intent.putExtra("titleName", getString(R.string.order_list));
          startActivity(intent);
  //        ShowResultActivity.barcode = barcode;
  //        if (type == 1) {//检票
  //
  //            boolean isLocalPeople = checkLocalId(idBean);
  //            if (isLocalPeople) {
  //
  //                Map<String, Object> map = new HashMap();
  //                map.put("message1", "1005");
  //                map.put("message9", barcode);
  //                map.put("message5", "免票人员");
  //                map.put("message22", "1人");
  //                map.put("message23", barcode);
  //                map.put("message24", idBean.getName());
  //
  //                MyMap myMap = new MyMap();
  //                myMap.setMap(map);
  //
  //                Intent intent = new Intent(mContext, ShowResultActivity.class);
  //                Bundle bundle = new Bundle();
  //                bundle.putSerializable("resultMap", myMap);
  //                bundle.putSerializable("IdBean", idBean);
  //                bundle.putString("activityName", TAG);
  //                intent.putExtras(bundle);
  //                intent.putExtra("type", type);
  //                startActivity(intent);
  //                return;
  //            }
  //
  //            data = gardenID + "," + barcode + ",JP";
  //            String reqZJ = PreferenceUtils.getString(mContext, "reqZJ", "no");
  //            if (reqZJ.equals("yes")) {
  //                WebserviceHelper.getInstance().checkTickt(gardenID + "," + barcode, "CheckTicket", new CheckCallBack_ZJ(ScanHeadActivity.this) {
  //                    @Override
  //                    public void getMap(Map map) {
  //                        MyMap myMap = new MyMap();
  //
  //                        myMap.setMap(map);
  //                        String ticketFlag = map.get("message1").toString();
  //                        if (ticketFlag != null && !"".equals(ticketFlag)) {
  //                            int flag = Integer.parseInt(ticketFlag);
  //                            LogUtil.i(TAG, "票状态--------> " + flag);
  //                            String checkFaceType = PreferenceUtils.getString(mContext, "checkFaceType", "no");
  //                            if (TextUtils.equals(checkFaceType, "yes")) {
  //                                //传递Map到ShowResult.java 显示
  //                                myMap.getMap().put("finger", "RL");
  //                                Intent intent = new Intent(context, ShowResultActivity.class);
  //                                Bundle bundle = new Bundle();
  //                                bundle.putSerializable("resultMap", myMap);
  //                                bundle.putString("activityName", TAG);
  //                                intent.putExtras(bundle);
  //                                intent.putExtra("type", type);
  //                                startActivity(intent);
  ////                                finish();
  //                            } else {
  //                                if (flag == 1) {//登记指纹
  //                                    SoundUtil.getInstents(ScanHeadActivity.this).playSound(R.raw.dengjizhiwen, -1);
  //                                    Toast.makeText(context, "请登记指纹!", Toast.LENGTH_SHORT).show();
  //                                } else if (flag == 2) {//验证指纹
  //                                    SoundUtil.getInstents(ScanHeadActivity.this).playSound(R.raw.yanzhengzhiwen, -1);
  //                                    Toast.makeText(context, "请验证指纹!", Toast.LENGTH_SHORT).show();
  //                                } else {//直接信息显示
  //                                    //传递Map到ShowResult.java 显示
  //                                    Intent intent = new Intent(context, ShowResultActivity
  //                                            .class);
  //                                    Bundle bundle = new Bundle();
  //                                    bundle.putSerializable("resultMap", myMap);
  //                                    bundle.putString("activityName", TAG);
  //                                    intent.putExtras(bundle);
  //                                    intent.putExtra("type", type);
  //                                    startActivity(intent);
  ////                                    finish();
  //                                }
  //                            }
  //
  //                        }
  //                    }
  //
  //                    @Override
  //                    public void failureToDo() {
  //                        Toast.makeText(context, "检票失败,请重试", Toast.LENGTH_SHORT).show();
  //                    }
  //                }, 7);
  //            } else {
  //
  //                WebserviceHelper.getInstance().test(data, "CheckscTicketmebile", new CheckCallBack
  //                        (ScanHeadActivity.this) {
  //
  //                    @Override
  //                    public void failureToDo() {
  //                    }
  //
  //                    @Override
  //                    public void getMap(Map map) {
  //                        MyMap myMap = new MyMap();
  //                        myMap.setMap(map);
  //                        String ticketFlag = map.get("message1").toString();
  //                        if (ticketFlag != null && !"".equals(ticketFlag)) {
  //                            int flag = Integer.parseInt(ticketFlag);
  //                            LogUtil.i(TAG, "票状态--------> " + flag);
  //                            String checkFaceType = PreferenceUtils.getString(mContext, "checkFaceType", "no");
  //                            if (TextUtils.equals(checkFaceType, "yes")) {
  //                                //传递Map到ShowResult.java 显示
  //                                myMap.getMap().put("finger", "RL");
  //                                Intent intent = new Intent(context, ShowResultActivity.class);
  //                                Bundle bundle = new Bundle();
  //                                bundle.putSerializable("resultMap", myMap);
  //                                bundle.putString("activityName", TAG);
  //                                intent.putExtras(bundle);
  //                                intent.putExtra("type", type);
  //                                startActivity(intent);
  ////                                finish();
  //                            } else {
  //                                if (flag == 1) {//登记指纹
  //                                    SoundUtil.getInstents(ScanHeadActivity.this).playSound(R.raw.dengjizhiwen, -1);
  //                                    Toast.makeText(context, "请登记指纹!", Toast.LENGTH_SHORT).show();
  //                                } else if (flag == 2) {//验证指纹
  //                                    SoundUtil.getInstents(ScanHeadActivity.this).playSound(R.raw.yanzhengzhiwen, -1);
  //                                    Toast.makeText(context, "请验证指纹!", Toast.LENGTH_SHORT).show();
  //                                } else {//直接信息显示
  //                                    //传递Map到ShowResult.java 显示
  //                                    Intent intent = new Intent(context, ShowResultActivity.class);
  //                                    Bundle bundle = new Bundle();
  //                                    bundle.putSerializable("resultMap", myMap);
  //                                    bundle.putString("activityName", TAG);
  //                                    intent.putExtras(bundle);
  //                                    intent.putExtra("type", type);
  //                                    startActivity(intent);
  ////                                    finish();
  //                                }
  //                            }
  //
  //                        }
  //
  //                    }
  //                }, 2);
  //            }
  //        } else if (type == 2) {
  //            data = gardenID + "," + barcode + ",CX";
  //            WebserviceHelper.getInstance().test(data, "CheckscTicketmebile", new CheckCallBack(ScanHeadActivity.this) {
  //
  //                @Override
  //                public void failureToDo() {
  //                }
  //
  //                @Override
  //                public void getMap(Map map) {
  //                    MyMap myMap = new MyMap();
  //                    myMap.setMap(map);
  //                    Intent intent = new Intent(context, ShowResultActivity.class);
  //                    Bundle bundle = new Bundle();
  //                    bundle.putSerializable("resultMap", myMap);
  //                    intent.putExtras(bundle);
  //                    startActivity(intent);
  ////                    finish();
  //                }
  //            }, 2);
  //        }
90601e4f   黄灿宏   标准版本 1.扩展设备10 增...
470
471
      }
      private void showCountType() {
c05c7a9b   黄灿宏   标准版本 1.扩展设备8 2....
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
  //        if (TextUtils.equals(showCountType, "yes")) {
  //            String gardenID = PreferenceUtils.getString(mContext, ParamContants.GET_ACCID, "");
  //            Long accid = Long.parseLong(gardenID);
  //            WebserviceHelper.getInstance().request(accid, "getCheckcount", new CountCallBack(ScanHeadActivity.this) {
  //                @Override
  //                public void sucessToDo(Object json) {
  //                    List<Double> list = new Gson().fromJson(json.toString(), List.class);
  //                    double yun = list.get(1);
  //                    double yun1 = list.get(2);
  //                    int piao = (int) yun;
  //                    int ren = (int) yun1;
  //                    tv_total_number.setText(ren + "/" + piao);
  //                }
  //
  //                @Override
  //                public void failureToDo() {
  //
  //                }
  //            }, 4);
  //
  //            int count = PreferenceUtils.getInt(mContext, "count", 0);
  //            tv_number.setText(String.valueOf(count));
  //        }
90601e4f   黄灿宏   标准版本 1.扩展设备10 增...
495
      }
c05c7a9b   黄灿宏   标准版本 1.扩展设备8 2....
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
  //    private boolean checkLocalId(IdBean idBean) {
  //        boolean isLocal = false;
  //
  //        if (!TextUtils.equals(isIDinFree, "yes")) {
  //            return false;
  //        }
  //
  //        if (!TextUtils.equals(local_age, "0")) {
  //            LogUtil.i(TAG, "Age == " + local_age);
  //            isLocal = checkAga(local_age, idBean.getId());
  //        }
  //        if (!isLocal && !TextUtils.equals(local_addr, "0")) {
  //            LogUtil.i(TAG, "Addr == " + local_addr);
  //            isLocal = checkAddr(local_addr, idBean.getAddr());
  //        }
  //
  //        if (!isLocal && !TextUtils.equals(local_sex, "0")) {
  //            LogUtil.i(TAG, "Sex == " + local_sex);
  //            isLocal = checkSex(local_sex, idBean.getId());
  //        }
  //
  //        if (!isLocal && !TextUtils.equals(local_id, "0")) {
  //            LogUtil.i(TAG, "Id == " + local_id);
  //            isLocal = checkId(local_id, idBean.getId());
  //        }
  //        return isLocal;
  //    }
  
  //    private boolean checkAga(String ageStr, String scanTicketId) {
  //
  //        String[] localAge;
  //        if (ageStr.contains("#") && ageStr.contains("-")) {
  //            localAge = ageStr.split("#");
  //        } else if (ageStr.contains("-")) {
  //            localAge = new String[]{ageStr};
  //        } else {
  //            return false;
  //        }
  //        int tourAge = TimesUtils.getAge(scanTicketId);
  //        LogUtil.i(TAG, "【身份证年龄:】" + tourAge);
  //        for (String local : localAge) {
  //            String[] age = local.split("-");
  //            int startAge = Integer.parseInt(age[0]);
  //            int endAge = Integer.parseInt(age[1]);
  //            if (tourAge >= startAge && tourAge < endAge) {
  //                return true;
  //            }
  //        }
  //        return false;
  //
  //    }
90601e4f   黄灿宏   标准版本 1.扩展设备10 增...
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
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
  
      private boolean checkAddr(String local_addr, String addr) {
  
          boolean isLocal = false;
          String[] localStr;
          if (local_addr.contains("#")) {
              localStr = local_addr.split("#");
          } else {
              localStr = new String[]{local_addr};
          }
  
          for (String local : localStr) {
              if (addr.contains(local)) {
                  isLocal = true;
                  break;
              }
          }
          return isLocal;
      }
  
      private boolean checkSex(String local_sex, String scanTicketId) {
  
          String sex = "男";
          if (Integer.parseInt(scanTicketId.substring(16, 17)) % 2 == 0) {
              sex = "女";
          }
  
          if (TextUtils.equals(sex, local_sex)) {
              return true;
          } else {
              return false;
          }
      }
  
      private boolean checkId(String local_id, String scanTicketId) {
  
          boolean isLocal = false;
          String[] localStr;
          if (local_id.contains("#")) {
              localStr = local_id.split("#");
          } else {
              localStr = new String[]{local_id};
          }
  
          for (String local : localStr) {
              if (scanTicketId.startsWith(local)) {
                  isLocal = true;
                  break;
              }
          }
          return isLocal;
      }
  
      private boolean running = false;
      private int retType = -1;    //读到二代证类型,s
  
  
      private class ReadThread extends Thread {
          @Override
          public void run() {
              while (running) {
                  //说明:本程序加500ms延时只做参考,是为了二代证不拿开也能读,开发者可视自身环境而定
                  try {
                      Thread.sleep(100);
  
                      boolean isFind = idCardReader.findCard(0);
                      if (isFind) {
                          mHandle.sendEmptyMessage(MSG_FIND_ID);
                          idCardReader.selectCard(0);
                          retType = idCardReader.readCardEx(0, 0);
  
                          switch (retType) {
                              case 1: //国内居民身份证
                                  IDCardInfo idCardInfo = idCardReader.getLastIDCardInfo();
                                  Message msg = Message.obtain();
                                  msg.what = MSG_GET_ID;
                                  msg.obj = idCardInfo;
                                  mHandle.sendMessage(msg);
                                  break;
                              default:
                                  showToast("无效证件");
                                  break;
                          }
                      }
                  } catch (Exception e) {
                      e.printStackTrace();
                  }
              }
              super.run();
          }
      }
  
      /***
       * 关闭模块
       */
      public void close() {
          LogUtil.i(TAG, "powerCtl close()");
          try {
              running = false;
              //说明:300ms的延时是为防止线程操作异常,开发时视实际情况
              Thread.sleep(300);
              if (idCardReader != null) {
                  idCardReader.close(0);
              }
              if (powerCtl != null) {
                  powerCtl.identity_uhf_power(0);
                  powerCtl.identity_ctl(0);
              }
  
          } catch (Exception e) {
              LogUtil.e(TAG, e.getMessage());
              e.printStackTrace();
          }
      }
  
  
      @Override
      protected void onDestroy() {
          super.onDestroy();
          LogUtil.i(TAG, "onDestroy()");
          close();
      }
  }