| | |
| | | package cn.com.basic.face.fragment;
|
| | |
|
| | | import android.app.Activity;
|
| | | import android.content.BroadcastReceiver;
|
| | | import android.content.Context;
|
| | | import android.content.Intent;
|
| | | import android.graphics.Bitmap;
|
| | |
| | |
|
| | | import com.alibaba.fastjson.JSON;
|
| | | import com.alibaba.fastjson.JSONArray;
|
| | | import com.bit.rfid.RFIDReader;
|
| | | import com.bit.rfid.ReaderExtra;
|
| | | import com.bsk.zhangbo.demoforbsk.R;
|
| | |
|
| | | import cn.com.basic.face.adapter.SurveillanceFragment;
|
| | |
| | | import cn.com.basic.face.widget.register.RegisterRightFieldTextView;
|
| | | import cn.com.basic.face.dialog.SelectDialog;
|
| | |
|
| | | import com.ivsign.android.IDCReader.IDCReaderSDK;
|
| | | import com.lidroid.xutils.view.annotation.ViewInject;
|
| | | import com.lidroid.xutils.view.annotation.event.OnClick;
|
| | |
|
| | |
| | | import org.xutils.http.RequestParams;
|
| | |
|
| | | import java.io.BufferedOutputStream;
|
| | | import java.io.ByteArrayInputStream;
|
| | | import java.io.ByteArrayOutputStream;
|
| | | import java.io.File;
|
| | | import java.io.FileOutputStream;
|
| | | import java.io.Reader;
|
| | | import java.text.SimpleDateFormat;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
| | |
| | | @Override
|
| | | protected void initData() {
|
| | | resetForm();
|
| | | readIdCard();
|
| | | }
|
| | |
|
| | | public void readIdCard() {
|
| | | try {
|
| | | Thread.sleep(100);
|
| | |
|
| | | RFIDReader idCardReader = null; //RFIDReader.getInstance(MainActivity.getInstance(), "com");
|
| | | ByteArrayInputStream type = new ByteArrayInputStream("uart".getBytes());
|
| | | idCardReader.control(ReaderExtra.CONNECT, type);
|
| | | idCardReader.setUartDeviceName("/dev/S0");
|
| | |
|
| | | idCardReader.open("id_card");
|
| | | String cardId = byteArrayToHexString(idCardReader.getUid());
|
| | |
|
| | | idCardReader.open("id_sam");
|
| | | ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
| | | idCardReader.control(ReaderExtra.ID_READ_TEXT_PHOTO, baos);
|
| | | String textPhoto = byteArrayToHexString(baos.toByteArray());
|
| | | if (textPhoto != null) {
|
| | | String[] decodeInfo = new String[10];
|
| | | StringBuilder imagePath = new StringBuilder();
|
| | | String path = MainActivity.getInstance().getFilesDir().getAbsolutePath();
|
| | | IDCReaderSDK.initialize(path);
|
| | | IDCReaderSDK.decodeSamAck(textPhoto, decodeInfo, imagePath);
|
| | | String name = decodeInfo[0];
|
| | | String sex = decodeInfo[1];
|
| | | String nation = decodeInfo[2];
|
| | | String birth = decodeInfo[3];
|
| | | String address = decodeInfo[4];
|
| | | String idNumber = decodeInfo[5];
|
| | | String office = decodeInfo[6];
|
| | | String validDate = decodeInfo[7] + "-" + decodeInfo[8];
|
| | | String photo = imagePath.toString();
|
| | |
|
| | | comparePictures();
|
| | | }
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | private void comparePictures() {
|
| | |
|
| | | RequestParams params = new RequestParams();
|
| | |
|
| | | if (fragment_register_surveillance_photo_img != null) {
|
| | | ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
| | | fragment_register_surveillance_photo_img.compress(Bitmap.CompressFormat.JPEG, 100, byteArrayOutputStream);
|
| | | byte[] imageBytes = byteArrayOutputStream.toByteArray();
|
| | |
|
| | | params.addBodyParameter("surveillancePhoto", writeToFile("surveillancePhoto", imageBytes));
|
| | | } else {
|
| | | params.addBodyParameter("surveillancePhoto", writeToFile("surveillancePhoto", new byte[]{}));
|
| | | }
|
| | |
|
| | |
|
| | | if (fragment_register_id_card_photo_img != null) {
|
| | | ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
| | | fragment_register_id_card_photo_img.compress(Bitmap.CompressFormat.JPEG, 100, byteArrayOutputStream);
|
| | | byte[] imageBytes = byteArrayOutputStream.toByteArray();
|
| | |
|
| | | params.addBodyParameter("idCardPhoto", writeToFile("idCardPhoto", imageBytes));
|
| | | } else {
|
| | | params.addBodyParameter("idCardPhoto", writeToFile("idCardPhoto", new byte[]{}));
|
| | | }
|
| | |
|
| | | RegisterMng.getInstance().compareSurveillancePhotoAndIdCardPhoto(params);
|
| | | }
|
| | |
|
| | | protected static final char[] a = new char[]{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
|
| | | public static String byteArrayToHexString(byte[] bytes) {
|
| | | if(bytes == null) {
|
| | | return null;
|
| | | } else {
|
| | | char[] hexChars = new char[bytes.length * 2];
|
| | |
|
| | | for(int j = 0; j < bytes.length; ++j) {
|
| | | int v = bytes[j] & 255;
|
| | | hexChars[j * 2] = a[v >>> 4];
|
| | | hexChars[j * 2 + 1] = a[v & 15];
|
| | | }
|
| | |
|
| | | return new String(hexChars);
|
| | | }
|
| | | }
|
| | |
|
| | |
|
| | |
|
| | | }
|