Browse Source

完成访客记录功能
解决身份真刷卡一次后再次刷卡刷不上问题
页面调整

ifengouy 2 years ago
parent
commit
c1715b25f2
25 changed files with 1344 additions and 119 deletions
  1. 1 0
      app/src/main/AndroidManifest.xml
  2. 1 6
      app/src/main/java/com/sunwin/visitorapp/activity/HomeAc.java
  3. 254 0
      app/src/main/java/com/sunwin/visitorapp/activity/VisitLogActivity.java
  4. 94 5
      app/src/main/java/com/sunwin/visitorapp/activity/VisitSignActivity.java
  5. 14 1
      app/src/main/java/com/sunwin/visitorapp/activity/VisitorRegisterAc.java
  6. 91 0
      app/src/main/java/com/sunwin/visitorapp/adapter/VisitLogAdapter.java
  7. 36 1
      app/src/main/java/com/sunwin/visitorapp/db/DatabaseManager.java
  8. 20 0
      app/src/main/java/com/sunwin/visitorapp/db/UserInfoModel.java
  9. 2 2
      app/src/main/java/com/sunwin/visitorapp/face/IDCardReaderUtil.java
  10. 4 74
      app/src/main/java/com/sunwin/visitorapp/face/SwFaceLoop.java
  11. 7 5
      app/src/main/java/com/sunwin/visitorapp/fragment/IdcardRegFragment.java
  12. 1 1
      app/src/main/java/com/sunwin/visitorapp/model/DepartmentResult.java
  13. 348 0
      app/src/main/java/com/sunwin/visitorapp/model/UploadRecordRequsetModel.java
  14. 1 1
      app/src/main/java/com/sunwin/visitorapp/net/ApiService.java
  15. 9 5
      app/src/main/java/com/sunwin/visitorapp/utils/BitmapUtils.java
  16. 31 7
      app/src/main/java/com/sunwin/visitorapp/utils/FileUtil.java
  17. 16 0
      app/src/main/res/drawable/bg_input.xml
  18. 5 0
      app/src/main/res/drawable/ic_baseline_search_24.xml
  19. 4 0
      app/src/main/res/layout/activity_visit_input.xml
  20. 286 0
      app/src/main/res/layout/activity_visit_log.xml
  21. 7 7
      app/src/main/res/layout/activity_visit_sign.xml
  22. 3 4
      app/src/main/res/layout/activity_visitor_reg.xml
  23. 99 0
      app/src/main/res/layout/adapter_visit_log.xml
  24. 9 0
      app/src/main/res/values/arrays.xml
  25. 1 0
      app/src/main/res/values/dimens.xml

+ 1 - 0
app/src/main/AndroidManifest.xml

@@ -38,6 +38,7 @@
         <activity android:name=".activity.NoCardRegActivity" />
         <activity android:name=".activity.VisitSignActivity" />
         <activity android:name=".activity.VisitInputActivity" />
+        <activity android:name=".activity.VisitLogActivity" />
 
         <service
             android:name=".service.PullDataService"

+ 1 - 6
app/src/main/java/com/sunwin/visitorapp/activity/HomeAc.java

@@ -68,7 +68,7 @@ public class HomeAc extends BaseActivity implements View.OnClickListener, RegTyp
         Intent intent = null;
         switch (view.getId()) {
             case R.id.MenuItemRecord://记录
-                replaceFragment(new HomeFr());
+                startActivity(new Intent(mContext, VisitLogActivity.class));
                 break;
             case R.id.MenuItemSign://签到
                 showHome(false);
@@ -148,11 +148,6 @@ public class HomeAc extends BaseActivity implements View.OnClickListener, RegTyp
 
     @Override
     public void showNoCardReg() {
-//        SharePrefenceUtils.putBoolean(Constant.ISharePrefence.LOGINTAG, false);
-//        Intent intent = new Intent(this, VisitorRegActivity.class);
-//        intent.putExtra(Constant.IIntentValue.VISIT_REG_TYPE, 2);
-//        intent.putExtra(Constant.IIntentValue.ISLOGINUSER, isLogin);
-//        startActivity(intent);
         Intent intent = new Intent(this, VisitInputActivity.class);
         startActivity(intent);
     }

+ 254 - 0
app/src/main/java/com/sunwin/visitorapp/activity/VisitLogActivity.java

@@ -0,0 +1,254 @@
+package com.sunwin.visitorapp.activity;
+
+import android.os.AsyncTask;
+import android.os.Bundle;
+import android.text.TextUtils;
+import android.view.View;
+import android.widget.AdapterView;
+import android.widget.EditText;
+import android.widget.ListView;
+import android.widget.Spinner;
+import android.widget.TextView;
+
+import com.jzxiang.pickerview.TimePickerDialog;
+import com.jzxiang.pickerview.data.Type;
+import com.jzxiang.pickerview.listener.OnDateSetListener;
+import com.liaoinstan.springview.container.DefaultFooter;
+import com.liaoinstan.springview.container.DefaultHeader;
+import com.liaoinstan.springview.widget.SpringView;
+import com.sunwin.visitorapp.BaseActivity;
+import com.sunwin.visitorapp.R;
+import com.sunwin.visitorapp.adapter.DepartmentAdapter;
+import com.sunwin.visitorapp.adapter.VisitLogAdapter;
+import com.sunwin.visitorapp.db.DatabaseManager;
+import com.sunwin.visitorapp.model.DepartmentResult;
+import com.sunwin.visitorapp.model.UploadRecordRequsetModel;
+import com.sunwin.visitorapp.utils.TimeUtils;
+import com.sunwin.visitorapp.view.UINav;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class VisitLogActivity extends BaseActivity implements SpringView.OnFreshListener, View.OnClickListener, AdapterView.OnItemSelectedListener, OnDateSetListener {
+    private ListView mLv;
+    private EditText mEtIdNum;
+    private Spinner mSpInOut;
+    private TextView mTvStartTime;
+    private TextView mTvEndTime;
+    private Spinner mSpDept;
+    private SpringView mSpringView;
+    private VisitLogAdapter mAdapter;
+    private DepartmentAdapter adapter;
+    private List<UploadRecordRequsetModel> mVisitList;
+
+    private DatabaseManager manager;
+    private UINav mUINav;
+    private List<DepartmentResult> mDepartmentList;
+    private List<String> inOutList;
+    private String dept;
+    private int inOut = -1;
+    private Map<String, String> map;
+    private TimePickerDialog timePickerDialog;
+    private long tenYears = 10L * 365 * 1000 * 60 * 60 * 24L;
+    private int dateLabel;
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.activity_visit_log);
+        manager = DatabaseManager.getInstance();
+        mVisitList = new ArrayList();
+        mDepartmentList = new ArrayList();
+        map = new HashMap<>();
+        inOutList = Arrays.asList(getResources().getStringArray(R.array.inOutArray));
+        initView();
+        initData();
+    }
+
+    private void initData() {
+        getDeptInfoFromLocal();
+        getRecordFromLocal();
+    }
+
+    private void getDeptInfoFromLocal() {
+
+        List<DepartmentResult> list = DatabaseManager.getInstance().getQueryAll(DepartmentResult.class);
+        mDepartmentList.add(new DepartmentResult());
+        mDepartmentList.addAll(list);
+        adapter.notifyDataSetChanged();
+    }
+
+    private void getRecordFromLocal() {
+        new GetDataTask().execute();
+    }
+
+    @Override
+    public void onClick(View view) {
+        switch (view.getId()) {
+            case R.id.btn_search:
+                map.clear();
+
+                String idNum = mEtIdNum.getText().toString().trim();
+                String startTime = mTvStartTime.getText().toString().trim();
+                String endTime = mTvEndTime.getText().toString().trim();
+                if (!TextUtils.isEmpty(idNum)) {
+                    if (idNum.length() == 18) {
+                        map.put("idNum", idNum);
+                    } else if (idNum.length() == 11) {
+                        map.put("phone", idNum);
+                    } else {
+                        map.put("personName", idNum);
+                    }
+                }
+                if (!TextUtils.isEmpty(startTime)) {
+                    map.put("postDate", startTime);
+                }
+                if (!TextUtils.isEmpty(endTime)) {
+                    map.put("lostDate", endTime);
+                }
+                if (!TextUtils.isEmpty(dept)) {
+                    map.put("categoryName", dept);
+                }
+                if (inOut != -1) {
+                    map.put("inout_flag", inOut + "");
+                }
+                getRecordFromLocal();
+                break;
+            case R.id.tv_start_time:
+                dateLabel = view.getId();
+                showTimePickDialog();
+                break;
+            case R.id.tv_end_time:
+                dateLabel = view.getId();
+                showTimePickDialog();
+                break;
+        }
+
+    }
+
+    /**
+     * 底部弹出时间选择框
+     */
+    private void showTimePickDialog() {
+        if (timePickerDialog == null) {
+            timePickerDialog = new TimePickerDialog.Builder()
+                    .setCallBack(this)
+                    .setCancelStringId("取消")
+                    .setSureStringId("确定")
+                    .setTitleStringId("设置日期时间")
+                    .setYearText("年")
+                    .setMonthText("月")
+                    .setDayText("日")
+                    .setCyclic(false)
+                    .setMinMillseconds(System.currentTimeMillis() - tenYears)
+                    .setMaxMillseconds(System.currentTimeMillis() + tenYears)
+                    .setCurrentMillseconds(System.currentTimeMillis())
+                    .setThemeColor(getResources().getColor(R.color.timepicker_dialog_bg))
+                    .setType(Type.YEAR_MONTH_DAY)
+                    .setWheelItemTextNormalColor(getResources().getColor(R.color.timetimepicker_default_text_color))
+                    .setWheelItemTextSelectorColor(getResources().getColor(R.color.black))
+                    .setWheelItemTextSize(12)
+                    .build();
+        }
+        timePickerDialog.show(getSupportFragmentManager(), "all");
+    }
+
+    @Override
+    public void onDateSet(TimePickerDialog timePickerView, long millseconds) {
+        String dateTime = TimeUtils.stampToDate(millseconds);
+        switch (dateLabel) {
+            case R.id.tv_start_time:
+                mTvStartTime.setText(dateTime);
+                break;
+            case R.id.tv_end_time:
+                mTvEndTime.setText(dateTime);
+                break;
+        }
+    }
+
+    class GetDataTask extends AsyncTask<String, Integer, ArrayList<UploadRecordRequsetModel>> {
+        @Override
+        protected ArrayList<UploadRecordRequsetModel> doInBackground(String... strings) {
+            ArrayList<UploadRecordRequsetModel> list = manager.queryBuilderByAppendAndEqual(map, "time", UploadRecordRequsetModel.class);
+            mVisitList.clear();
+            if (list.size() > 0) {
+                mVisitList.addAll(list);
+            }
+            return list;
+        }
+
+        @Override
+        protected void onPreExecute() {
+            super.onPreExecute();
+            loadingDialog.showLoadingDialog("");
+        }
+
+        @Override
+        protected void onPostExecute(ArrayList<UploadRecordRequsetModel> uploadRecordRequsetModels) {
+            super.onPostExecute(uploadRecordRequsetModels);
+            loadingDialog.dismissLoadingDialog();
+            mSpringView.onFinishFreshAndLoad();
+            mAdapter.notifyDataSetChanged();
+        }
+    }
+
+    private void initView() {
+
+        mUINav = findViewById(R.id.UINav);
+        mLv = (ListView) findViewById(R.id.lv);
+        mEtIdNum = (EditText) findViewById(R.id.et_idNum);
+        mSpInOut = (Spinner) findViewById(R.id.sp_in_out);
+        mTvStartTime = (TextView) findViewById(R.id.tv_start_time);
+        mTvEndTime = (TextView) findViewById(R.id.tv_end_time);
+        mSpDept = (Spinner) findViewById(R.id.sp_dept);
+        mSpringView = (SpringView) findViewById(R.id.springView);
+        mUINav.setData(this, "访客记录");
+        mSpringView.setHeader(new DefaultHeader(this));
+        mSpringView.setFooter(new DefaultFooter(this));
+        mSpringView.setListener(this);
+        mSpringView.setEnableFooter(false);
+
+        findViewById(R.id.btn_search).setOnClickListener(this);
+        mSpDept.setOnItemSelectedListener(this);
+        mSpInOut.setOnItemSelectedListener(this);
+
+        mAdapter = new VisitLogAdapter(this, mVisitList);
+        mLv.setAdapter(mAdapter);
+
+        adapter = new DepartmentAdapter(this, mDepartmentList);
+        mSpDept.setAdapter(adapter);
+
+        mTvStartTime.setOnClickListener(this);
+        mTvEndTime.setOnClickListener(this);
+    }
+
+    @Override
+    public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
+        switch (adapterView.getId()) {
+            case R.id.sp_dept:
+                dept = mDepartmentList.get(i).getCategoryName();
+                break;
+            case R.id.sp_in_out:
+                inOut = i - 1;
+                break;
+        }
+    }
+
+    @Override
+    public void onNothingSelected(AdapterView<?> adapterView) {
+
+    }
+
+    @Override
+    public void onRefresh() {
+        getRecordFromLocal();
+    }
+
+    @Override
+    public void onLoadmore() {
+
+    }
+}

+ 94 - 5
app/src/main/java/com/sunwin/visitorapp/activity/VisitSignActivity.java

@@ -2,6 +2,7 @@ package com.sunwin.visitorapp.activity;
 
 import android.content.Intent;
 import android.os.Bundle;
+import android.text.TextUtils;
 import android.view.View;
 import android.widget.LinearLayout;
 import android.widget.TextView;
@@ -15,14 +16,27 @@ import com.sunwin.visitorapp.face.CameraPreviewData;
 import com.sunwin.visitorapp.face.IDCardReaderUtil;
 import com.sunwin.visitorapp.face.IdCardReadCallback;
 import com.sunwin.visitorapp.model.OpenDoorByFaceNetResultInfo;
+import com.sunwin.visitorapp.model.UploadRecordRequsetModel;
+import com.sunwin.visitorapp.net.ApiService;
+import com.sunwin.visitorapp.net.BaseRsult;
+import com.sunwin.visitorapp.net.RetrofitUtil;
 import com.sunwin.visitorapp.service.PullDataService;
+import com.sunwin.visitorapp.utils.BitmapUtils;
 import com.sunwin.visitorapp.utils.Constant;
+import com.sunwin.visitorapp.utils.FileUtil;
 import com.sunwin.visitorapp.utils.LogUtil;
+import com.sunwin.visitorapp.utils.TimeUtils;
 import com.sunwin.visitorapp.utils.ToastUtils;
 import com.sunwin.visitorapp.view.FaceDetecterView;
 
 import java.util.List;
 
+import okhttp3.MediaType;
+import okhttp3.RequestBody;
+import retrofit2.Call;
+import retrofit2.Callback;
+import retrofit2.Response;
+
 /**
  * 访客签到/签离
  */
@@ -32,7 +46,7 @@ public class VisitSignActivity extends BaseActivity implements IdCardReadCallbac
     private FaceDetecterView mFaceDetecterView;
 
     private int visitSignType;
-    private int visitType;
+    private int visitType;//1,签到,2 签离
     private IDCardReaderUtil idCardReaderUtil;
 
     @Override
@@ -80,13 +94,82 @@ public class VisitSignActivity extends BaseActivity implements IdCardReadCallbac
     @Override
     public void onIdNumRead(String idNum) {
         LogUtil.e(TAG, "idNum = " + idNum);
-        updataUserInfoByIdNum(idNum);
-
+        updataUserInfoByIdNum(idNum, 5);
     }
 
-    private void updataUserInfoByIdNum(String idNum) {
+    private void updataUserInfoByIdNum(String idNum, int type) {
         List<UserInfoModel> userInfoModels = DatabaseManager.getInstance().query(UserInfoModel.class, "idNum", idNum);
         updateUserInfo(userInfoModels);
+        updateRecord(userInfoModels, type);
+    }
+
+    private void updateRecord(List<UserInfoModel> userInfoModels, int type) {
+        UserInfoModel infoModel = userInfoModels.get(0);
+        UploadRecordRequsetModel requsetModel = new UploadRecordRequsetModel();
+        requsetModel.setIdNum(infoModel.getIdNum());
+        requsetModel.setTime(TimeUtils.stampToTime(System.currentTimeMillis()));
+        requsetModel.setPersonName(infoModel.getPersonName());
+        requsetModel.setDeptId(infoModel.getDeptId());
+        requsetModel.setDeviceId(infoModel.getDeviceId());
+        requsetModel.setPersonId(infoModel.getPersonId());
+        requsetModel.setPostDate(infoModel.getPostDate());
+        requsetModel.setDepart(infoModel.getDeptId());
+        requsetModel.setLostDate(infoModel.getLostDate());
+        requsetModel.setType(type);
+        requsetModel.setInout_flag(visitType == 1 ? 0 : 1);//进出标志 0:进;1:出;3:无
+        requsetModel.setCategoryId(infoModel.getCategoryId());
+        requsetModel.setCategoryName(infoModel.getCategoryName());
+        if (type == 1) {
+            requsetModel.setImgCode(BitmapUtils.scaleBitmap(currentFace));
+            requsetModel.setImgUrl(currentFace);
+            requsetModel.setThreshold(similarity + "");
+        }
+
+
+        ApiService apiService = RetrofitUtil.getApiService();
+        MediaType textType = MediaType.parse("text/plain");
+        final RequestBody requestBody = RequestBody.create(textType, RetrofitUtil.bean2Json(requsetModel));
+        Call<BaseRsult<String>> call = apiService.uploadRecord(requestBody);
+        call.enqueue(new Callback<BaseRsult<String>>() {
+            @Override
+            public void onResponse(Call<BaseRsult<String>> call, Response<BaseRsult<String>> response) {
+                try {
+                    if (response.body() == null) {
+                        ToastUtils.showToast("保存失败");
+                        return;
+                    }
+                    int code = response.body().getCode();
+                    LogUtil.e(TAG, "--code--" + code);
+                    if (code == 0) {
+                        //删除图片
+                        if (!TextUtils.isEmpty(currentFace)) {
+                            boolean b = FileUtil.deleteFile(currentFace);
+                            LogUtil.e(TAG, "delete File=" + b);
+                        }
+                    } else {
+                        requsetModel.setNeedUpdate(true);
+                        ToastUtils.showToast("保存失败");
+                    }
+
+
+                } catch (Exception e) {
+
+                }
+
+                requsetModel.setPhone(infoModel.getPhone());
+                long insert = DatabaseManager.getInstance().insert(requsetModel);
+                LogUtil.e(TAG, "insert sign record =" + insert);
+            }
+
+            @Override
+            public void onFailure(Call<BaseRsult<String>> call, Throwable t) {
+                ToastUtils.showToast("保存失败");
+                requsetModel.setNeedUpdate(true);
+                requsetModel.setPhone(infoModel.getPhone());
+                long insert = DatabaseManager.getInstance().insert(requsetModel);
+                LogUtil.e(TAG, "insert sign record =" + insert);
+            }
+        });
     }
 
     /**
@@ -97,12 +180,17 @@ public class VisitSignActivity extends BaseActivity implements IdCardReadCallbac
 
     }
 
+    private String currentFace;
+    private double similarity;
+
     @Override
     public void detectedUser(OpenDoorByFaceNetResultInfo openDoorByFaceNetResultInfo) {
         LogUtil.e(TAG, "-------------detectedUser--------------");
         BaseApplication.getSystemTTS().playText("识别成功");
         String idNum = openDoorByFaceNetResultInfo.getIdNum();
-        updataUserInfoByIdNum(idNum);
+        currentFace = openDoorByFaceNetResultInfo.getCurrentFace();
+        similarity = openDoorByFaceNetResultInfo.getSimilarity();
+        updataUserInfoByIdNum(idNum, 1);
     }
 
     @Override
@@ -127,6 +215,7 @@ public class VisitSignActivity extends BaseActivity implements IdCardReadCallbac
             runOnUiThread(new Runnable() {
                 @Override
                 public void run() {
+                    ToastUtils.showToast(visitType == 1 ? "签到成功!" : "签离成功!");
                     finish();
                 }
             });

+ 14 - 1
app/src/main/java/com/sunwin/visitorapp/activity/VisitorRegisterAc.java

@@ -29,6 +29,8 @@ import com.sunwin.visitorapp.net.ApiService;
 import com.sunwin.visitorapp.net.BaseRsult;
 import com.sunwin.visitorapp.net.CommonRequest;
 import com.sunwin.visitorapp.net.RetrofitUtil;
+import com.sunwin.visitorapp.utils.AppManager;
+import com.sunwin.visitorapp.utils.AppUtil;
 import com.sunwin.visitorapp.utils.BitmapUtils;
 import com.sunwin.visitorapp.utils.Constant;
 import com.sunwin.visitorapp.utils.LogUtil;
@@ -44,6 +46,9 @@ import retrofit2.Call;
 import retrofit2.Callback;
 import retrofit2.Response;
 
+/**
+ * 访客登记 人员增加处理
+ */
 public class VisitorRegisterAc extends BaseActivity implements View.OnClickListener, OnDateSetListener, AdapterView.OnItemSelectedListener {
 
     private String currentFacePath;//人脸照片
@@ -217,6 +222,7 @@ public class VisitorRegisterAc extends BaseActivity implements View.OnClickListe
         infoModel.setDeptId(deptNo + "");
         infoModel.setCategoryId(categoryId);
 
+        LogUtil.e(TAG,"categoryName ="+categoryName);
         List<UserInfoModel> userInfoModels = DatabaseManager.getInstance().query(UserInfoModel.class, "idNum", idNum);
         if (userInfoModels.size() != 0) {
             oldUserinfo = userInfoModels.get(0);
@@ -243,6 +249,8 @@ public class VisitorRegisterAc extends BaseActivity implements View.OnClickListe
                         String personId = response.body().getResult();
                         String faceToken = SwFaceLoop.getInstance().addFace(currentFacePath);
 
+                        infoModel.setCategoryName(categoryName);
+                        infoModel.setDeviceId(AppUtil.getDeviceId());
                         infoModel.setInsetTime(TimeUtils.stampToDate(System.currentTimeMillis()));
                         infoModel.setFaceToken(faceToken);
                         infoModel.setPersonId(personId);
@@ -253,6 +261,9 @@ public class VisitorRegisterAc extends BaseActivity implements View.OnClickListe
                         //存入数据库
                         long insert = DatabaseManager.getInstance().insert(infoModel);
                         LogUtil.e(TAG, "存入用户" + insert);
+                        ToastUtils.showToast("保存成功");
+                        finish();
+                        AppManager.getAppManager().finishActivity(VisitorRegActivity.class);
                     } else {
                         loadingDialog.dismissLoadingDialog();
                         ToastUtils.showToast("保存失败");
@@ -327,7 +338,7 @@ public class VisitorRegisterAc extends BaseActivity implements View.OnClickListe
                     .setDayText("日")
                     .setCyclic(false)
                     .setMinMillseconds(System.currentTimeMillis() - tenYears)
-                    .setMaxMillseconds(System.currentTimeMillis())
+                    .setMaxMillseconds(System.currentTimeMillis()+tenYears)
                     .setCurrentMillseconds(System.currentTimeMillis())
                     .setThemeColor(getResources().getColor(R.color.timepicker_dialog_bg))
                     .setType(Type.YEAR_MONTH_DAY)
@@ -353,6 +364,7 @@ public class VisitorRegisterAc extends BaseActivity implements View.OnClickListe
     }
 
     String categoryId;
+    String categoryName;
     int deptNo;
 
     @Override
@@ -361,6 +373,7 @@ public class VisitorRegisterAc extends BaseActivity implements View.OnClickListe
             case R.id.EditByVisitDepartment:
                 DepartmentResult departmentResult = mDepartmentList.get(i);
                 categoryId = departmentResult.getCategoryId();
+                categoryName = departmentResult.getCategoryName();
                 break;
             case R.id.sp_net:
                 NetInfo netInfo = mNetInfoList.get(i);

+ 91 - 0
app/src/main/java/com/sunwin/visitorapp/adapter/VisitLogAdapter.java

@@ -0,0 +1,91 @@
+package com.sunwin.visitorapp.adapter;
+
+import android.content.Context;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.BaseAdapter;
+import android.widget.TextView;
+
+import com.sunwin.visitorapp.R;
+import com.sunwin.visitorapp.model.UploadRecordRequsetModel;
+
+import java.util.List;
+
+public class VisitLogAdapter extends BaseAdapter {
+
+    private final LayoutInflater inflater;
+    private List<UploadRecordRequsetModel> mList;
+    private Context mContext;
+
+    public VisitLogAdapter(Context pContext, List<UploadRecordRequsetModel> pList) {
+        this.mContext = pContext;
+        this.mList = pList;
+        inflater = LayoutInflater.from(pContext);
+    }
+
+    @Override
+    public int getCount() {
+        return mList.size();
+    }
+
+    @Override
+    public Object getItem(int position) {
+        return mList.get(position);
+    }
+
+    @Override
+    public long getItemId(int position) {
+        return position;
+    }
+
+    @Override
+    public View getView(int i, View convertView, ViewGroup viewGroup) {
+        ViewHolder holder = null;
+        if (convertView == null) {
+            convertView = inflater.inflate(R.layout.adapter_visit_log, viewGroup, false);
+            holder = new ViewHolder(convertView);
+            convertView.setTag(holder);
+        } else {
+            holder = (ViewHolder) convertView.getTag();
+        }
+        UploadRecordRequsetModel model = mList.get(i);
+        holder.mTvIdNum.setText(model.getIdNum());
+        holder.mTvVisitTime.setText(model.getPostDate()+"\n"+model.getLostDate());
+        holder.mTvName.setText(model.getPersonName());
+        holder.mTvInOut.setText(model.getInout_flag() == 0 ? "进" : model.getInout_flag() == 1 ? "出" : "无");
+        holder.mTvDept.setText(model.getCategoryName());
+        holder.mTvTel.setText(model.getPhone());
+//        holder.mTvShenhe.setText(model.getStatus2());
+
+        return convertView;
+    }
+
+    private void initView() {
+    }
+
+    public static class ViewHolder {
+        private TextView mTvName;
+        private TextView mTvVisitTime;
+        private TextView mTvInOut;
+        private TextView mTvDept;
+        private TextView mTvIdNum;
+        private TextView mTvTel;
+        private TextView mTvShenhe;
+        private TextView mTvYuyue;
+
+        public ViewHolder(View rootView) {
+            mTvIdNum = rootView.findViewById(R.id.tv_idNum);
+            mTvInOut = rootView.findViewById(R.id.tv_in_out);
+            mTvDept = rootView.findViewById(R.id.tv_dept);
+
+
+            mTvName = rootView.findViewById(R.id.tv_name);
+            mTvTel = rootView.findViewById(R.id.tv_tel);
+            mTvVisitTime = rootView.findViewById(R.id.tv_visit_time);
+            mTvYuyue = rootView.findViewById(R.id.tv_yuyue);
+            mTvShenhe = rootView.findViewById(R.id.tv_shenhe);
+        }
+
+    }
+}

+ 36 - 1
app/src/main/java/com/sunwin/visitorapp/db/DatabaseManager.java

@@ -1,12 +1,17 @@
 package com.sunwin.visitorapp.db;
 
+import android.text.TextUtils;
+
 import com.litesuits.orm.LiteOrm;
 import com.litesuits.orm.db.assit.QueryBuilder;
+import com.litesuits.orm.db.assit.WhereBuilder;
 import com.sunwin.visitorapp.BaseApplication;
 import com.sunwin.visitorapp.model.NetInfo;
+import com.sunwin.visitorapp.model.UploadRecordRequsetModel;
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
 
 public class DatabaseManager {
     private String dbName = "visitorapp.db";
@@ -53,6 +58,10 @@ public class DatabaseManager {
         return liteOrm.query(new QueryBuilder(cla).orderBy("updateTime"));
     }
 
+    public static <T> ArrayList<T> queryAllByArgs(Class<T> cla, String arg) {
+        return liteOrm.query(new QueryBuilder(cla).orderBy(arg));
+    }
+
     public static NetInfo queryNetInfo(int departmentId) {
 
         final ArrayList<NetInfo> list = liteOrm.query(new QueryBuilder(NetInfo.class).whereEquals("id", departmentId));
@@ -65,6 +74,7 @@ public class DatabaseManager {
 
     /**
      * 查询  某字段 等于 Value的值
+     *
      * @param cla
      * @param field
      * @param value
@@ -97,7 +107,7 @@ public class DatabaseManager {
      * @param <T>
      */
     public <T> int delete(T t) {
-      return   liteOrm.delete(t);
+        return liteOrm.delete(t);
     }
 
     /**
@@ -145,6 +155,31 @@ public class DatabaseManager {
 
     public <T> List<T> queryUnion(Class<T> cla, String key, String value, String key2, String value2) {
         return liteOrm.query(new QueryBuilder<T>(cla).whereEquals(key, value).whereAppendAnd().whereEquals(key2, value2));
+    }
 
+    public ArrayList<UploadRecordRequsetModel> queryRecord( String idNum, String postDate, String lostDate) {
+        return liteOrm.query(new QueryBuilder<UploadRecordRequsetModel>(UploadRecordRequsetModel.class).
+                whereEquals("idNum", idNum).whereAppendAnd().whereEquals("postDate", postDate)
+                .whereAppendAnd().whereEquals("lostDate", lostDate).orderBy("time"));
     }
+    public <T> int deleteWhereBuilderByAndEquals(Map<String, Object> whereArgs, Class<T> clazz) {
+        LiteOrm lOrm = liteOrm.single();
+        WhereBuilder builder = new WhereBuilder(clazz);
+        for (Map.Entry<String, Object> entry : whereArgs.entrySet()) {
+            builder.andEquals(entry.getKey(), entry.getValue());
+        }
+        return lOrm.delete(builder);
+    }
+
+    public <T> ArrayList<T> queryBuilderByAppendAndEqual(Map<String, String> whereArgs, String ascKey, Class<T> clazz) {
+        LiteOrm lOrm = liteOrm.single();
+        QueryBuilder builder = new QueryBuilder(clazz);
+        for (Map.Entry<String, String> entry : whereArgs.entrySet()) {
+            builder.whereAppendAnd().whereEquals(entry.getKey(), entry.getValue());
+        }
+        if (!TextUtils.isEmpty(ascKey))
+            builder.appendOrderDescBy(ascKey);
+        return lOrm.query(builder);
+    }
+
 }

+ 20 - 0
app/src/main/java/com/sunwin/visitorapp/db/UserInfoModel.java

@@ -59,6 +59,16 @@ public class UserInfoModel {
     private String email;
 
     private String deptId;//网点ID,关联dept表
+
+    public String getDeptName() {
+        return deptName;
+    }
+
+    public void setDeptName(String deptName) {
+        this.deptName = deptName;
+    }
+
+    private String deptName;//
     private String deviceId;//设备ID,关联device表
 
     private String cardNo;    //卡号
@@ -339,6 +349,16 @@ public class UserInfoModel {
     private String composeId;   //所属分组
     private int tag;            //批量导入的部门标识
     private String categoryId;   //人员部门
+
+    public String getCategoryName() {
+        return categoryName;
+    }
+
+    public void setCategoryName(String categoryName) {
+        this.categoryName = categoryName;
+    }
+
+    private String categoryName;   //人员部门
     private String deviceIdfrom;   //申请设备,设备源
     private String inoutRuleId;   //进出的规则
 

+ 2 - 2
app/src/main/java/com/sunwin/visitorapp/face/IDCardReaderUtil.java

@@ -54,7 +54,7 @@ public class IDCardReaderUtil implements Runnable {
 
     public void startRead() {
         if (childThread == null) {
-            stopRead = false;//开始后,停止解析标签为false
+            bStoped = false;//开始后,停止解析标签为false
             childThread = new Thread(this, "decode");
             childThread.start();
         }
@@ -62,7 +62,7 @@ public class IDCardReaderUtil implements Runnable {
 
     public void stopRead() {
         if (childThread != null) {
-            stopRead = true;//子线程调用stop没法停止线程的,我们用了while循环,所以做个标志位,提示跳出while循环
+            bStoped = true;//子线程调用stop没法停止线程的,我们用了while循环,所以做个标志位,提示跳出while循环
             childThread = null;
         }
     }

+ 4 - 74
app/src/main/java/com/sunwin/visitorapp/face/SwFaceLoop.java

@@ -181,80 +181,6 @@ public class SwFaceLoop extends FRAbsLoop {
         }.start();
     }
 
-//    private void initFaceHandler() {
-//
-//        new Thread() {
-//            @Override
-//            public void run() {
-//                while (true) {
-//                    LogUtil.e(DEBUG_TAG, "FacePassHandler.isAuthorized()" + FacePassHandler.isAuthorized());
-//                    while (FacePassHandler.isAvailable()) {
-//                        LogUtil.d(DEBUG_TAG, "start to build FacePassHandler");
-//                        FacePassConfig config;
-//                        try {
-//                            /* 填入所需要的配置 */
-//                            config = new FacePassConfig();
-//                            config.poseBlurModel = FacePassModel.initModel(BaseApplication.getInstance().getAssets(), "attr.pose_blur.align.av200.190630.bin");
-//                            config.livenessModel = FacePassModel.initModel(BaseApplication.getInstance().getAssets(), "liveness.CPU.rgb.int8.E.bin");
-//                            config.searchModel = FacePassModel.initModel(BaseApplication.getInstance().getAssets(), "feat2.arm.H.v1.0_1core.bin");
-//                            config.detectModel = FacePassModel.initModel(BaseApplication.getInstance().getAssets(), "detector.arm.E.bin");
-//                            config.detectRectModel = FacePassModel.initModel(BaseApplication.getInstance().getAssets(), "detector_rect.arm.E.bin");
-//                            config.landmarkModel = FacePassModel.initModel(BaseApplication.getInstance().getAssets(), "pf.lmk.arm.D.bin");
-//
-//                            config.rcAttributeModel = FacePassModel.initModel(BaseApplication.getInstance().getAssets(), "attr.RC.gray.12M.arm.200229.bin");
-//
-//                            config.rcAttributeEnabled = true;
-//                            config.searchThreshold = Constant.COMPARSION_VALUE;
-//                            config.livenessThreshold = 60f;
-//                            if (Constant.NumerValue.cameraNums > 1) {
-//                                config.livenessEnabled = false;
-//                                //用于人脸红外活体检测的模型
-//                                config.rgbIrLivenessEnabled = true;
-//                                config.rgbIrLivenessModel = FacePassModel.initModel(BaseApplication.getInstance().getAssets(), "liveness.CPU.rgbir.int8.E.bin");
-//                            } else {
-//                                config.livenessEnabled = true;
-//                                //用于人脸红外活体检测的模型
-//                                config.rgbIrLivenessEnabled = false;
-//                            }
-//
-//                            config.faceMinThreshold = Constant.FACE_MIN_FACE_VALUE;
-//                            config.poseThreshold = new FacePassPose(30f, 30f, 30f);
-//                            config.blurThreshold = 0.8f;
-//                            config.lowBrightnessThreshold = 70f;
-//                            config.highBrightnessThreshold = 210f;
-//                            config.brightnessSTDThreshold = 80f;
-//                            config.retryCount = 1;
-//                            config.smileEnabled = false;
-//                            config.maxFaceEnabled = true;
-////                            config.rotation = carmeraRotate;
-//                            config.fileRootPath = Environment.getExternalStorageDirectory().getAbsolutePath();
-//
-//                            /* 创建SDK实例 */
-//                            mFacePassHandler = new FacePassHandler(config);
-//                            FacePassConfig addFaceConfig = mFacePassHandler.getAddFaceConfig();
-//                            addFaceConfig.blurThreshold = 0.8f;
-//                            addFaceConfig.faceMinThreshold = Constant.FACE_MIN_FACE_VALUE;
-//                            boolean is = mFacePassHandler.setAddFaceConfig(addFaceConfig);
-//                            LogUtil.d(DEBUG_TAG, "builid FacePassHandler success");
-//                            checkGroup();
-//
-//                        } catch (FacePassException e) {
-//                            e.printStackTrace();
-//                            LogUtil.d(DEBUG_TAG, "FacePassHandler is null");
-//                            return;
-//                        }
-//                        return;
-//                    }
-//                    try {
-//                        Thread.sleep(400);
-//                    } catch (InterruptedException e) {
-//                        e.printStackTrace();
-//                    }
-//                }
-//            }
-//        }.start();
-//    }
-
     private void checkGroup() {
         if (mFacePassHandler == null) {
             return;
@@ -468,11 +394,15 @@ public class SwFaceLoop extends FRAbsLoop {
                             //根据facetoken查询对应的用户
                             List<UserInfoModel> userInfoModels = DatabaseManager.getInstance().query(UserInfoModel.class, "faceToken", faceToken);
                             if (userInfoModels.size() > 0) {
+                                CameraPreviewData cameraPreviewData = detectResult.getCameraPreviewData();
+                                //生成现场照
+                                String currentFacePath = FileUtil.getFileFromCameraView(cameraPreviewData);
                                 UserInfoModel infoModel = userInfoModels.get(0);
                                 OpenDoorByFaceNetResultInfo openDoorByFaceNetResultInfo = new OpenDoorByFaceNetResultInfo();
                                 openDoorByFaceNetResultInfo.setCode(0);
                                 openDoorByFaceNetResultInfo.setSimilarity(result.detail.searchScore);
                                 openDoorByFaceNetResultInfo.setPerson_code(infoModel.getPersonId());
+                                openDoorByFaceNetResultInfo.setCurrentFace(currentFacePath);
                                 openDoorByFaceNetResultInfo.setIdNum(infoModel.getIdNum());
                                 openDoorByFaceNetResultInfo.setPerson_name(infoModel.getPersonName());
                                 EventBus.getDefault().post(new DescEvent().setDesc(DescEvent.DESC_FR_SUCC).setOpenDoorByFaceNetResultInfo(openDoorByFaceNetResultInfo));

+ 7 - 5
app/src/main/java/com/sunwin/visitorapp/fragment/IdcardRegFragment.java

@@ -13,7 +13,6 @@ import androidx.annotation.Nullable;
 import com.sunwin.visitorapp.BaseApplication;
 import com.sunwin.visitorapp.BaseFragment;
 import com.sunwin.visitorapp.R;
-import com.sunwin.visitorapp.activity.NoCardRegActivity;
 import com.sunwin.visitorapp.activity.VisitorRegisterAc;
 import com.sunwin.visitorapp.face.CameraPreviewData;
 import com.sunwin.visitorapp.face.IDCardReaderUtil;
@@ -26,6 +25,9 @@ import com.sunwin.visitorapp.view.FaceDetecterView;
 
 import org.jetbrains.annotations.NotNull;
 
+/**
+ * 身份证登记 fragment
+ */
 public class IdcardRegFragment extends BaseFragment implements IdCardReadCallback, FaceDetecterView.Listener {
     private LinearLayout mLlIdCardReg;
 
@@ -54,14 +56,14 @@ public class IdcardRegFragment extends BaseFragment implements IdCardReadCallbac
     @Override
     public void onResume() {
         super.onResume();
-        LogUtil.e(TAG, "=======onResume = " );
+        LogUtil.e(TAG, "=======onResume = ");
         mFaceDetecterView.onResume();
     }
 
     @Override
     public void onPause() {
         super.onPause();
-        LogUtil.e(TAG, "=======onPause = " );
+        LogUtil.e(TAG, "=======onPause = ");
         idCardReaderUtil.stopRead();
         mFaceDetecterView.onDestroy();
     }
@@ -99,8 +101,8 @@ public class IdcardRegFragment extends BaseFragment implements IdCardReadCallbac
     public void detectedUser(OpenDoorByFaceNetResultInfo info) {
         BaseApplication.getSystemTTS().playText("识别成功");
         Intent intent = new Intent(mContext, VisitorRegisterAc.class);
-        intent.putExtra(Constant.IIntentValue.CURRENTFACEPATH,info.getCurrentFace());
-        intent.putExtra(Constant.IIntentValue.RECOGNIZE_INFO,info);
+        intent.putExtra(Constant.IIntentValue.CURRENTFACEPATH, info.getCurrentFace());
+        intent.putExtra(Constant.IIntentValue.RECOGNIZE_INFO, info);
         startActivity(intent);
     }
 

+ 1 - 1
app/src/main/java/com/sunwin/visitorapp/model/DepartmentResult.java

@@ -18,7 +18,7 @@ public class DepartmentResult {
     private String categoryCode;
     @PrimaryKey(AssignType.BY_MYSELF)
     private String categoryId;
-    private String categoryName;
+    private String categoryName="";
     private int status;
     private long updateTime;
 

+ 348 - 0
app/src/main/java/com/sunwin/visitorapp/model/UploadRecordRequsetModel.java

@@ -0,0 +1,348 @@
+package com.sunwin.visitorapp.model;
+
+import com.litesuits.orm.db.annotation.PrimaryKey;
+import com.litesuits.orm.db.annotation.Table;
+import com.litesuits.orm.db.enums.AssignType;
+@Table("record_table")
+public class UploadRecordRequsetModel extends BaseModel {
+    @PrimaryKey(AssignType.AUTO_INCREMENT)
+    private long id;
+
+    public boolean isNeedUpdate() {
+        return needUpdate;
+    }
+
+    public void setNeedUpdate(boolean needUpdate) {
+        this.needUpdate = needUpdate;
+    }
+
+    private boolean needUpdate;//是否需要提交到服务器
+    private String time;  //记录时间
+    private String personCode; // 工号
+    private String personName; //姓名
+    private String deptId; // 网点id
+    private String deviceId; // 设备id
+    private String personId; // 人员id
+    private String personId2; // 人员id
+    private int type;     //识别部门(1:用户人脸,2:卡号,3:卡号+人脸,4:人脸+身份证,5:身份证,6:访客人脸,7:陌生人,8:白名单,9:黑名单,10:组合认证人脸,11:超级卡)
+
+    private String imgCode;  //识别的图片
+
+    private String imgCode2;  //识别的图片2(双人认证时使用)
+    private String imgUrl;  //识别的图片存储路径
+    private String imgUrl2;  //识别的图片存储路径2
+    private int inout_flag;  //进出标志 0:进;1:出;3:无
+
+    private int type1;  //终端类型(0:平板 ,1:巨龙设备,2:海清设备)
+    private String threshold;  //识别分数(双人认证,有多少分数)
+
+    private String idNum;  //身份证号(type为4,5,8,9时使用)
+    private String nation;  //民族(type为4,5,8,9时使用)
+    private String depart;  //签发单位(type为4,5,8,9时使用)
+    private String address;  //地址(type为4,5,8,9时使用)
+    private String birthday;  //出生日期(type为4,5,8,9时使用)
+    private int sex;          //性别(type为4,5,8,9时使用)
+    private String age;          //年龄(type为4,5,8,9时使用)
+    private String temperature;   //体温
+
+    private String faceCode;
+    private String cardNo;//卡号
+    private String categoryId;  //人员部门
+
+    public String getPhone() {
+        return phone;
+    }
+
+    public void setPhone(String phone) {
+        this.phone = phone;
+    }
+
+    private String phone;
+
+    public String getCategoryName() {
+        return categoryName;
+    }
+
+    public void setCategoryName(String categoryName) {
+        this.categoryName = categoryName;
+    }
+
+    private String categoryName;  //人员部门
+
+    private int type2;  //0:不需要审核的;1:需要审核的
+    private int status2; //type2等于1时使用(0:未审核;1:审核通过;-2:审核未通过)
+
+
+    private String postDate;
+
+    public String getPostDate() {
+        return postDate;
+    }
+
+    public void setPostDate(String postDate) {
+        this.postDate = postDate;
+    }
+
+    public String getLostDate() {
+        return lostDate;
+    }
+
+    public void setLostDate(String lostDate) {
+        this.lostDate = lostDate;
+    }
+
+    private String lostDate;
+    private String inLpCode;
+    // 车牌比对时候传此参数
+    private String lpCode;
+
+    private Integer lpCompareResult;
+
+    public String getTime() {
+        return time;
+    }
+
+    public void setTime(String time) {
+        this.time = time;
+    }
+
+    public String getPersonCode() {
+        return personCode;
+    }
+
+    public void setPersonCode(String personCode) {
+        this.personCode = personCode;
+    }
+
+    public String getPersonName() {
+        return personName;
+    }
+
+    public void setPersonName(String personName) {
+        this.personName = personName;
+    }
+
+    public String getDeptId() {
+        return deptId;
+    }
+
+    public void setDeptId(String deptId) {
+        this.deptId = deptId;
+    }
+
+    public String getDeviceId() {
+        return deviceId;
+    }
+
+    public void setDeviceId(String deviceId) {
+        this.deviceId = deviceId;
+    }
+
+    public String getPersonId() {
+        return personId;
+    }
+
+    public void setPersonId(String personId) {
+        this.personId = personId;
+    }
+
+    public String getPersonId2() {
+        return personId2;
+    }
+
+    public void setPersonId2(String personId2) {
+        this.personId2 = personId2;
+    }
+
+    public int getType() {
+        return type;
+    }
+
+    public void setType(int type) {
+        this.type = type;
+    }
+
+    public String getImgCode() {
+        return imgCode;
+    }
+
+    public void setImgCode(String imgCode) {
+        this.imgCode = imgCode;
+    }
+
+    public String getImgCode2() {
+        return imgCode2;
+    }
+
+    public void setImgCode2(String imgCode2) {
+        this.imgCode2 = imgCode2;
+    }
+
+    public String getImgUrl() {
+        return imgUrl;
+    }
+
+    public void setImgUrl(String imgUrl) {
+        this.imgUrl = imgUrl;
+    }
+
+    public String getImgUrl2() {
+        return imgUrl2;
+    }
+
+    public void setImgUrl2(String imgUrl2) {
+        this.imgUrl2 = imgUrl2;
+    }
+
+    public int getInout_flag() {
+        return inout_flag;
+    }
+
+    public void setInout_flag(int inout_flag) {
+        this.inout_flag = inout_flag;
+    }
+
+    public int getType1() {
+        return type1;
+    }
+
+    public void setType1(int type1) {
+        this.type1 = type1;
+    }
+
+    public String getThreshold() {
+        return threshold;
+    }
+
+    public void setThreshold(String threshold) {
+        this.threshold = threshold;
+    }
+
+    public String getIdNum() {
+        return idNum;
+    }
+
+    public void setIdNum(String idNum) {
+        this.idNum = idNum;
+    }
+
+    public String getNation() {
+        return nation;
+    }
+
+    public void setNation(String nation) {
+        this.nation = nation;
+    }
+
+    public String getDepart() {
+        return depart;
+    }
+
+    public void setDepart(String depart) {
+        this.depart = depart;
+    }
+
+    public String getAddress() {
+        return address;
+    }
+
+    public void setAddress(String address) {
+        this.address = address;
+    }
+
+    public String getBirthday() {
+        return birthday;
+    }
+
+    public void setBirthday(String birthday) {
+        this.birthday = birthday;
+    }
+
+    public int getSex() {
+        return sex;
+    }
+
+    public void setSex(int sex) {
+        this.sex = sex;
+    }
+
+    public String getAge() {
+        return age;
+    }
+
+    public void setAge(String age) {
+        this.age = age;
+    }
+
+    public String getTemperature() {
+        return temperature;
+    }
+
+    public void setTemperature(String temperature) {
+        this.temperature = temperature;
+    }
+
+    public String getFaceCode() {
+        return faceCode;
+    }
+
+    public void setFaceCode(String faceCode) {
+        this.faceCode = faceCode;
+    }
+
+    public String getCardNo() {
+        return cardNo;
+    }
+
+    public void setCardNo(String cardNo) {
+        this.cardNo = cardNo;
+    }
+
+    public String getCategoryId() {
+        return categoryId;
+    }
+
+    public void setCategoryId(String categoryId) {
+        this.categoryId = categoryId;
+    }
+
+    public int getType2() {
+        return type2;
+    }
+
+    public void setType2(int type2) {
+        this.type2 = type2;
+    }
+
+    public int getStatus2() {
+        return status2;
+    }
+
+    public void setStatus2(int status2) {
+        this.status2 = status2;
+    }
+
+    public String getInLpCode() {
+        return inLpCode;
+    }
+
+    public void setInLpCode(String inLpCode) {
+        this.inLpCode = inLpCode;
+    }
+
+    public String getLpCode() {
+        return lpCode;
+    }
+
+    public void setLpCode(String lpCode) {
+        this.lpCode = lpCode;
+    }
+
+    public Integer getLpCompareResult() {
+        return lpCompareResult;
+    }
+
+    public void setLpCompareResult(Integer lpCompareResult) {
+        this.lpCompareResult = lpCompareResult;
+    }
+}

+ 1 - 1
app/src/main/java/com/sunwin/visitorapp/net/ApiService.java

@@ -12,7 +12,7 @@ import retrofit2.http.Headers;
 import retrofit2.http.POST;
 
 public interface ApiService {
-    @POST("uploadRecord")
+    @POST("uploadRecordForHotelRenzheng")
     @Headers({"Content-Type: application/json", "Accept: application/json"})
     Call<BaseRsult<String>> uploadRecord(@Body RequestBody body);
 

+ 9 - 5
app/src/main/java/com/sunwin/visitorapp/utils/BitmapUtils.java

@@ -35,7 +35,7 @@ import android.util.Log;
 import android.view.View;
 
 import com.guo.android_extend.java.ExtByteArrayOutputStream;
-import com.nostra13.universalimageloader.core.ImageLoader;
+import com.sunwin.visitorapp.face.CameraPreviewData;
 
 import java.io.BufferedOutputStream;
 import java.io.ByteArrayInputStream;
@@ -51,8 +51,6 @@ import java.net.URL;
 import java.text.NumberFormat;
 import java.util.List;
 
-
-
 import static android.graphics.BitmapFactory.decodeResource;
 
 /**
@@ -1365,7 +1363,7 @@ public class BitmapUtils {
     }
 
 
-  /*  *//**
+    /*  *//**
      * 中控提供的将输出流转化为图片
      *
      * @param bgrbuf
@@ -1404,7 +1402,7 @@ public class BitmapUtils {
                 out.flush();
                 out.close();
             }
-            if(context!=null){
+            if (context != null) {
                 MediaScannerConnection.scanFile(context, new String[]{path}, null, null);
             }
         } catch (FileNotFoundException e) {
@@ -1489,6 +1487,7 @@ public class BitmapUtils {
 
     /**
      * 照片转byte二进制
+     *
      * @param imagepath 需要转byte的照片路径
      * @return 已经转成的byte
      * @throws Exception
@@ -1513,8 +1512,10 @@ public class BitmapUtils {
         input.close();
         return bitmap;
     }
+
     /**
      * 将base64字符串转为bitmap
+     *
      * @param base64String
      * @return bitmap
      */
@@ -1594,10 +1595,13 @@ public class BitmapUtils {
 
         return filePath;
     }
+
     public static String scaleBitmap(String screenShotPath) {
         Bitmap bitmap = decodeImage(screenShotPath);
         bitmap = BitmapUtils.scaleBitmap(bitmap, 100, 100);
         String face_image = ConvertUtil.bitmapToBase64(bitmap);
         return face_image;
     }
+
+
 }

+ 31 - 7
app/src/main/java/com/sunwin/visitorapp/utils/FileUtil.java

@@ -8,11 +8,11 @@ import android.graphics.Matrix;
 import android.graphics.Rect;
 import android.graphics.YuvImage;
 import android.net.Uri;
-import android.util.Log;
+
+import com.sunwin.visitorapp.face.CameraPreviewData;
 
 import java.io.ByteArrayOutputStream;
 import java.io.File;
-import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
@@ -22,15 +22,15 @@ public class FileUtil {
     private static final String TAG = "FileUtil";
 
 
-    public static String copyToFilesDir(Context context, Uri uri){
+    public static String copyToFilesDir(Context context, Uri uri) {
         try {
 
             InputStream inputStream = context.getContentResolver().openInputStream(uri);
             String lastSegment = uri.getLastPathSegment();
-            File outFile = new File(context.getFilesDir(),lastSegment);
+            File outFile = new File(context.getFilesDir(), lastSegment);
             OutputStream outputStream = new FileOutputStream(outFile);
             byte[] bytes = new byte[16];
-            while ((inputStream.read(bytes))!=-1){
+            while ((inputStream.read(bytes)) != -1) {
                 outputStream.write(bytes);
             }
             inputStream.close();
@@ -43,7 +43,7 @@ public class FileUtil {
     }
 
 
-    public static void copyFilesFromAssets(Context context, String assetsPath, String savePath){
+    public static void copyFilesFromAssets(Context context, String assetsPath, String savePath) {
         try {
             String fileNames[] = context.getAssets().list(assetsPath);// 获取assets目录下的所有文件及目录名
             if (fileNames.length > 0) {// 如果是目录
@@ -72,7 +72,7 @@ public class FileUtil {
         }
     }
 
-    public static void saveFile(byte[] date, int width, int height, int rotation,String saveFile) {
+    public static void saveFile(byte[] date, int width, int height, int rotation, String saveFile) {
         Bitmap bitmap = getBitmapFromYUV(date, width, height, rotation);
         double size = 100;
         ByteArrayOutputStream stream = new ByteArrayOutputStream();
@@ -122,4 +122,28 @@ public class FileUtil {
             return bml;
         }
     }
+
+    public static String getFileFromCameraView(CameraPreviewData data) {
+        String saveFilePath = Constant.RecognitionDir + "face_" + System.currentTimeMillis() + ".jpg";
+        File saveFile = new File(saveFilePath);
+        saveFile.deleteOnExit();
+        try {
+            if (saveFile.createNewFile()) {
+                FileUtil.saveFile(data.nv21Data, data.width, data.height, data.rotation, saveFilePath);
+                return saveFilePath;
+            }
+        } catch (Exception e) {
+
+        }
+        return "";
+    }
+
+    public static boolean deleteFile(String path) {
+        File file = new File(path);
+        if (file.exists()) {
+            boolean delete = file.delete();
+            return delete;
+        }
+        return false;
+    }
 }

+ 16 - 0
app/src/main/res/drawable/bg_input.xml

@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android">
+    <!--设置圆角-->
+    <!--  按顺序分别对应:左下角的角度、右下角的角度、左上角的角度、右上角的角度-->
+    <corners
+        android:bottomLeftRadius="@dimen/dp_1"
+        android:bottomRightRadius="@dimen/dp_1"
+        android:topLeftRadius="@dimen/dp_1"
+
+        android:topRightRadius="@dimen/dp_1" />
+    <!--  设置边框大小与背景色-->
+    <stroke
+        android:width="2dp"
+        android:color="@color/ColorGray" />
+    <solid android:color="@color/white" />
+</shape>

+ 5 - 0
app/src/main/res/drawable/ic_baseline_search_24.xml

@@ -0,0 +1,5 @@
+<vector android:height="24dp" android:tint="#FFFFFF"
+    android:viewportHeight="24" android:viewportWidth="24"
+    android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
+    <path android:fillColor="@android:color/white" android:pathData="M15.5,14h-0.79l-0.28,-0.27C15.41,12.59 16,11.11 16,9.5 16,5.91 13.09,3 9.5,3S3,5.91 3,9.5 5.91,16 9.5,16c1.61,0 3.09,-0.59 4.23,-1.57l0.27,0.28v0.79l5,4.99L20.49,19l-4.99,-5zM9.5,14C7.01,14 5,11.99 5,9.5S7.01,5 9.5,5 14,7.01 14,9.5 11.99,14 9.5,14z"/>
+</vector>

+ 4 - 0
app/src/main/res/layout/activity_visit_input.xml

@@ -22,6 +22,8 @@
         android:orientation="vertical">
 
         <LinearLayout
+            android:layout_marginLeft="15dp"
+            android:layout_marginRight="15dp"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:layout_marginVertical="10dp"
@@ -44,6 +46,8 @@
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:layout_marginVertical="10dp"
+            android:layout_marginLeft="15dp"
+            android:layout_marginRight="15dp"
             android:orientation="horizontal">
 
             <TextView

+ 286 - 0
app/src/main/res/layout/activity_visit_log.xml

@@ -0,0 +1,286 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:background="@mipmap/bg_app"
+    android:focusable="true"
+    android:focusableInTouchMode="true"
+    android:orientation="vertical">
+
+    <com.sunwin.visitorapp.view.UINav
+        android:id="@+id/UINav"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content" />
+
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:layout_marginStart="40dp"
+        android:layout_marginTop="10dp"
+        android:layout_marginEnd="40dp"
+        android:layout_marginBottom="30dp"
+        android:background="@drawable/card_white"
+        android:orientation="vertical">
+
+        <LinearLayout
+            android:layout_marginLeft="20dp"
+            android:layout_marginRight="20dp"
+            android:layout_width="match_parent"
+            android:layout_height="50dp"
+            android:gravity="center_vertical"
+            android:orientation="horizontal"
+            android:layout_marginTop="10dp"
+            android:layout_marginBottom="10dp">
+
+            <LinearLayout
+                android:layout_width="wrap_content"
+                android:layout_height="match_parent"
+                android:layout_gravity="center_vertical"
+                android:orientation="horizontal">
+
+                <TextView
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:text="姓名"
+                    android:textColor="@color/black"
+                    android:textSize="@dimen/sp_20" />
+
+                <EditText
+                    android:padding="2dp"
+                    android:id="@+id/et_idNum"
+                    android:layout_width="wrap_content"
+                    android:layout_height="match_parent"
+                    android:layout_marginLeft="5dp"
+                    android:background="@drawable/bg_input"
+                    android:hint="姓名身份证手机号"
+                    android:minWidth="240dp"
+                    android:textColor="@color/black"
+                    android:textSize="@dimen/sp_20" />
+            </LinearLayout>
+
+            <LinearLayout
+                android:layout_width="wrap_content"
+                android:layout_height="match_parent"
+                android:layout_gravity="center_vertical"
+                android:layout_marginLeft="15dp"
+                android:orientation="horizontal">
+
+                <TextView
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:text="进出类别"
+                    android:textColor="@color/black"
+                    android:textSize="@dimen/sp_20" />
+
+                <Spinner
+                    android:id="@+id/sp_in_out"
+                    android:layout_width="80dp"
+                    android:layout_height="match_parent"
+                    android:layout_marginLeft="5dp"
+                    android:background="@drawable/bg_input"
+                    android:entries="@array/inOutArray"
+                    android:gravity="center"
+                    android:padding="2dp"
+                    android:textColor="@color/black"
+                    android:textSize="@dimen/sp_20" />
+            </LinearLayout>
+
+            <LinearLayout
+                android:layout_width="wrap_content"
+                android:layout_height="match_parent"
+                android:layout_gravity="center_vertical"
+                android:layout_marginLeft="15dp"
+                android:orientation="horizontal">
+
+                <TextView
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:text="通行时间"
+                    android:textColor="@color/black"
+                    android:textSize="@dimen/sp_20" />
+
+                <TextView
+                    android:id="@+id/tv_start_time"
+                    android:layout_width="wrap_content"
+                    android:layout_height="match_parent"
+                    android:layout_marginLeft="2dp"
+                    android:background="@drawable/bg_input"
+                    android:entries="@array/inOutArray"
+                    android:gravity="center"
+                    android:minWidth="120dp"
+                    android:textColor="@color/black"
+                    android:textSize="@dimen/sp_20" />
+
+                <TextView
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:gravity="center_horizontal"
+                    android:text="至"
+                    android:textColor="@color/black"
+                    android:textSize="@dimen/sp_20" />
+
+                <TextView
+                    android:id="@+id/tv_end_time"
+                    android:layout_width="wrap_content"
+                    android:layout_height="match_parent"
+                    android:background="@drawable/bg_input"
+                    android:entries="@array/inOutArray"
+                    android:gravity="center"
+                    android:minWidth="120dp"
+                    android:textColor="@color/black"
+                    android:textSize="@dimen/sp_20" />
+            </LinearLayout>
+
+            <LinearLayout
+                android:layout_width="wrap_content"
+                android:layout_height="match_parent"
+                android:layout_marginLeft="15dp"
+                android:layout_gravity="center_vertical"
+                android:orientation="horizontal">
+
+                <TextView
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:text="通行区域"
+                    android:textColor="@color/black"
+                    android:textSize="@dimen/sp_20" />
+
+                <Spinner
+                    android:id="@+id/sp_dept"
+                    android:layout_width="wrap_content"
+                    android:layout_height="match_parent"
+                    android:layout_marginLeft="5dp"
+                    android:entries="@array/inOutArray"
+                    android:gravity="center"
+                    android:background="@drawable/bg_input"
+                    android:minWidth="120dp"
+                    android:textColor="@color/black"
+                    android:textSize="@dimen/sp_20" />
+            </LinearLayout>
+
+            <Button
+                android:id="@+id/btn_search"
+                android:layout_marginLeft="20dp"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:background="@color/purple_500"
+                android:drawableLeft="@drawable/ic_baseline_search_24"
+                android:text="查询"
+                android:textColor="@color/white"
+                android:textSize="@dimen/sp_20" />
+        </LinearLayout>
+        <View
+            android:layout_width="match_parent"
+            android:layout_height="5dp"
+            android:background="#dedede" />
+        <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_marginLeft="15dp"
+            android:layout_height="50dp"
+            android:gravity="center_vertical"
+            android:layout_marginTop="7dp"
+            android:layout_marginBottom="7dp"
+            android:layout_marginRight="15dp"
+            android:orientation="horizontal">
+
+            <TextView
+                android:id="@+id/tv_name"
+                android:layout_weight="1.5"
+                android:layout_width="0dp"
+                android:layout_height="wrap_content"
+                android:text="姓名"
+                android:gravity="center"
+                android:textColor="@color/black"
+                android:textSize="@dimen/sp_20" />
+
+            <TextView
+                android:id="@+id/tv_idNum"
+                android:layout_weight="2"
+                android:layout_width="0dp"
+                android:gravity="center"
+                android:layout_height="wrap_content"
+                android:text="身份证"
+                android:textColor="@color/black"
+                android:textSize="@dimen/sp_20" />
+
+            <TextView
+                android:id="@+id/tv_tel"
+
+                android:gravity="center"
+                android:layout_weight="2"
+                android:layout_width="0dp"
+                android:layout_height="wrap_content"
+                android:text="手机号码"
+                android:textColor="@color/black"
+                android:textSize="@dimen/sp_20" />
+
+            <TextView
+                android:id="@+id/tv_in_out"
+                android:layout_weight="1"
+                android:layout_width="0dp"
+                android:layout_height="wrap_content"
+                android:gravity="center"
+                android:text="进出类别"
+                android:textColor="@color/black"
+                android:textSize="@dimen/sp_20" />
+
+            <TextView
+                android:id="@+id/tv_visit_time"
+                android:layout_weight="1.5"
+                android:layout_width="0dp"
+                android:layout_height="wrap_content"
+                android:gravity="center"
+                android:text="通行时间"
+                android:textColor="@color/black"
+                android:textSize="@dimen/sp_20" />
+
+            <TextView
+                android:id="@+id/tv_dept"
+                android:layout_weight="1.5"
+                android:layout_width="0dp"
+                android:layout_height="wrap_content"
+                android:gravity="center"
+                android:text="通行区域"
+                android:textColor="@color/black"
+                android:textSize="@dimen/sp_20" />
+
+            <TextView
+                android:id="@+id/tv_yuyue"
+                android:layout_weight="1"
+                android:layout_width="0dp"
+                android:layout_height="wrap_content"
+                android:gravity="center"
+                android:visibility="gone"
+                android:text="预约状态"
+                android:textColor="@color/black"
+                android:textSize="@dimen/sp_20" />
+
+            <TextView
+                android:id="@+id/tv_shenhe"
+                android:layout_weight="1.5"
+                android:layout_width="0dp"
+                android:layout_height="wrap_content"
+                android:gravity="center"
+                android:visibility="gone"
+                android:text="审核状态"
+                android:textColor="@color/black"
+                android:textSize="@dimen/sp_20" />
+        </LinearLayout>
+
+
+        <com.liaoinstan.springview.widget.SpringView
+            android:id="@+id/springView"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent">
+
+            <ListView
+                android:id="@+id/lv"
+                android:layout_width="match_parent"
+                android:layout_height="match_parent" />
+        </com.liaoinstan.springview.widget.SpringView>
+
+
+    </LinearLayout>
+
+
+</LinearLayout>

+ 7 - 7
app/src/main/res/layout/activity_visit_sign.xml

@@ -9,23 +9,23 @@
 
     <LinearLayout
         android:layout_width="match_parent"
-        android:layout_height="wrap_content"
+        android:layout_height="match_parent"
         android:layout_gravity="center_horizontal"
-        android:layout_marginLeft="80dp"
+        android:layout_marginLeft="40dp"
         android:layout_marginTop="50dp"
-        android:layout_marginRight="80dp"
-        android:layout_marginBottom="40dp"
+        android:layout_marginRight="40dp"
+        android:layout_marginBottom="120dp"
         android:orientation="horizontal">
 
         <LinearLayout
             android:layout_width="0dp"
-            android:layout_height="wrap_content"
+            android:layout_height="match_parent"
             android:layout_weight="1"
             android:background="@color/color_efeeee"
             android:gravity="center_horizontal"
             android:orientation="vertical"
-            android:paddingTop="20dp"
-            android:paddingBottom="20dp">
+            android:paddingTop="30dp"
+            android:paddingBottom="30dp">
 
             <ImageView
                 android:layout_width="180dp"

+ 3 - 4
app/src/main/res/layout/activity_visitor_reg.xml

@@ -11,15 +11,14 @@
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         android:layout_marginStart="40dp"
-        android:layout_marginTop="10dp"
         android:layout_marginEnd="40dp"
-        android:paddingTop="30dp"
-        android:layout_marginBottom="30dp"
+        android:layout_marginTop="50dp"
+        android:layout_marginBottom="120dp"
         android:layout_gravity="center_horizontal"
         android:orientation="horizontal">
         <LinearLayout
             android:layout_width="0dp"
-            android:layout_height="wrap_content"
+            android:layout_height="match_parent"
             android:layout_weight="1"
             android:background="@color/color_efeeee"
             android:gravity="center_horizontal"

+ 99 - 0
app/src/main/res/layout/adapter_visit_log.xml

@@ -0,0 +1,99 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:paddingTop="3dp"
+    android:paddingBottom="3dp">
+
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_marginLeft="15dp"
+        android:layout_marginRight="15dp"
+        android:orientation="horizontal">
+
+        <TextView
+            android:id="@+id/tv_name"
+            android:layout_weight="1.5"
+            android:layout_width="0dp"
+            android:layout_height="wrap_content"
+            android:text="姓名"
+            android:gravity="center"
+            android:textColor="@color/black"
+            android:textSize="@dimen/sp_20" />
+
+        <TextView
+            android:id="@+id/tv_idNum"
+            android:layout_weight="2"
+            android:gravity="center"
+            android:layout_width="0dp"
+            android:layout_height="wrap_content"
+            android:text="身份证"
+            android:textColor="@color/black"
+            android:textSize="@dimen/sp_20" />
+
+        <TextView
+            android:id="@+id/tv_tel"
+
+            android:gravity="center"
+            android:layout_weight="2"
+            android:layout_width="0dp"
+            android:layout_height="wrap_content"
+            android:text="手机号码"
+            android:textColor="@color/black"
+            android:textSize="@dimen/sp_20" />
+
+        <TextView
+            android:id="@+id/tv_in_out"
+            android:layout_weight="1"
+            android:layout_width="0dp"
+            android:layout_height="wrap_content"
+            android:gravity="center"
+            android:text="进出类别"
+            android:textColor="@color/black"
+            android:textSize="@dimen/sp_20" />
+
+        <TextView
+            android:id="@+id/tv_visit_time"
+            android:layout_weight="1.5"
+            android:layout_width="0dp"
+            android:layout_height="wrap_content"
+            android:text="通行时间"
+            android:gravity="center"
+            android:textColor="@color/black"
+            android:textSize="@dimen/sp_20" />
+
+        <TextView
+            android:id="@+id/tv_dept"
+            android:layout_weight="1.5"
+            android:layout_width="0dp"
+            android:layout_height="wrap_content"
+            android:gravity="center"
+            android:text="通行区域"
+            android:textColor="@color/black"
+            android:textSize="@dimen/sp_20" />
+
+        <TextView
+            android:id="@+id/tv_yuyue"
+            android:layout_weight="1"
+            android:layout_width="0dp"
+            android:layout_height="wrap_content"
+            android:gravity="center"
+            android:visibility="gone"
+            android:text="预约状态"
+            android:textColor="@color/black"
+            android:textSize="@dimen/sp_20" />
+
+        <TextView
+            android:id="@+id/tv_shenhe"
+            android:layout_weight="1.5"
+            android:layout_width="0dp"
+            android:gravity="center"
+            android:visibility="gone"
+            android:layout_height="wrap_content"
+            android:textColor="@color/black"
+            android:textSize="@dimen/sp_20" />
+    </LinearLayout>
+
+
+</LinearLayout>

+ 9 - 0
app/src/main/res/values/arrays.xml

@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+    <string-array name="inOutArray">
+        <item></item>
+        <item>进</item>
+        <item>出</item>
+
+    </string-array>
+</resources>

+ 1 - 0
app/src/main/res/values/dimens.xml

@@ -2,4 +2,5 @@
 <resources>
     <dimen name="sp_20">20sp</dimen>
     <dimen name="sp_25">25sp</dimen>
+    <dimen name="dp_1">1dp</dimen>
 </resources>