Browse Source

增加无证登记身份证信息输入界面
首页点击底部菜单后界面支持返回到首页

ifengouy 2 years ago
parent
commit
fc45994992

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

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

+ 49 - 10
app/src/main/java/com/sunwin/visitorapp/activity/HomeAc.java

@@ -3,6 +3,8 @@ package com.sunwin.visitorapp.activity;
 import android.content.Intent;
 import android.os.Bundle;
 import android.view.View;
+import android.widget.RelativeLayout;
+import android.widget.TextView;
 
 import androidx.fragment.app.Fragment;
 import androidx.fragment.app.FragmentManager;
@@ -13,17 +15,21 @@ import com.sunwin.visitorapp.R;
 import com.sunwin.visitorapp.fragment.HomeFr;
 import com.sunwin.visitorapp.fragment.VisitSignFragment;
 import com.sunwin.visitorapp.utils.Constant;
+import com.sunwin.visitorapp.utils.ToastUtils;
+import com.sunwin.visitorapp.view.UINav;
 
 public class HomeAc extends BaseActivity implements View.OnClickListener {
 
+    private UINav mUINav;
+    private RelativeLayout mLlHomeTitle;
+    private TextView mTextTitle;
+
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.activity_home);
 
 
-        findViewById(R.id.ImageSetting).setOnClickListener(v -> startActivity(new Intent(mContext, SettingAc.class)));
-
         FragmentManager fragmentManager = getSupportFragmentManager();
         FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
         //添加fragment
@@ -32,15 +38,8 @@ public class HomeAc extends BaseActivity implements View.OnClickListener {
         fragmentTransaction.commit();
         fragmentManager.executePendingTransactions();
 
-        findViewById(R.id.MenuItemRecord).setOnClickListener(this);
-        findViewById(R.id.MenuItemSign).setOnClickListener(this);
-        findViewById(R.id.MenuItemRegister).setOnClickListener(this);
-        findViewById(R.id.MenuItemLeave).setOnClickListener(this);
-        findViewById(R.id.MenuItemCheck).setOnClickListener(this);
-
-
-
 
+        initView();
     }
 
     @Override
@@ -48,6 +47,7 @@ public class HomeAc extends BaseActivity implements View.OnClickListener {
         super.onResume();
 
     }
+
     @Override
     public void onBackPressed() {
         moveTaskToBack(true);
@@ -66,6 +66,8 @@ public class HomeAc extends BaseActivity implements View.OnClickListener {
                 replaceFragment(new HomeFr());
                 break;
             case R.id.MenuItemSign://签到
+                showHome(false);
+                updateTitle("访客签到");
                 replaceFragment(VisitSignFragment.newInstance(1));
                 break;
             case R.id.MenuItemRegister://登记
@@ -74,10 +76,47 @@ public class HomeAc extends BaseActivity implements View.OnClickListener {
                 startActivity(intent);
                 break;
             case R.id.MenuItemLeave://签离
+                showHome(false);
+                updateTitle("访客签离");
                 replaceFragment(VisitSignFragment.newInstance(2));
                 break;
             case R.id.MenuItemCheck://核验
+                ToastUtils.showToast("开发中...");
+                break;
+            case R.id.ImageSetting:
+                startActivity(new Intent(mContext, SettingAc.class));
                 break;
         }
     }
+
+    private void initView() {
+        mUINav = (UINav) findViewById(R.id.UINav);
+        mLlHomeTitle = (RelativeLayout) findViewById(R.id.ll_home_title);
+        mTextTitle =  findViewById(R.id.TextTitle);
+
+        findViewById(R.id.MenuItemRecord).setOnClickListener(this);
+        findViewById(R.id.MenuItemSign).setOnClickListener(this);
+        findViewById(R.id.MenuItemRegister).setOnClickListener(this);
+        findViewById(R.id.MenuItemLeave).setOnClickListener(this);
+        findViewById(R.id.MenuItemCheck).setOnClickListener(this);
+        findViewById(R.id.ImageSetting).setOnClickListener(this);
+        showHome(true);
+
+
+    }
+
+    private void showHome(boolean showHome) {
+        mLlHomeTitle.setVisibility(showHome ? View.VISIBLE : View.GONE);
+        mUINav.setVisibility(showHome ? View.GONE : View.VISIBLE);
+    }
+
+    private void updateTitle(String title){
+        mUINav.setMainData(new View.OnClickListener() {
+            @Override
+            public void onClick(View view) {
+                showHome(true);
+                replaceFragment(new HomeFr());
+            }
+        }, title);
+    }
 }

+ 64 - 0
app/src/main/java/com/sunwin/visitorapp/activity/VisitInputActivity.java

@@ -0,0 +1,64 @@
+package com.sunwin.visitorapp.activity;
+
+import android.content.Intent;
+import android.os.Bundle;
+import android.text.TextUtils;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+
+import com.sunwin.visitorapp.BaseActivity;
+import com.sunwin.visitorapp.R;
+import com.sunwin.visitorapp.model.OpenDoorByFaceNetResultInfo;
+import com.sunwin.visitorapp.utils.Constant;
+import com.sunwin.visitorapp.utils.ToastUtils;
+import com.sunwin.visitorapp.view.UINav;
+
+public class VisitInputActivity extends BaseActivity implements View.OnClickListener {
+    private UINav mUINav;
+    private EditText mEditName;
+    private EditText mEditICCode;
+    private Button mBtnNext;
+    private String currentFacePath;
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.activity_visit_input);
+        currentFacePath = getIntent().getStringExtra(Constant.IIntentValue.CURRENTFACEPATH);
+        initView();
+    }
+
+    private void initView() {
+        mUINav = findViewById(R.id.UINav);
+        mEditName = findViewById(R.id.EditName);
+        mEditICCode = findViewById(R.id.EditICCode);
+        mBtnNext = findViewById(R.id.btn_next);
+        mBtnNext.setOnClickListener(this);
+
+        mUINav.setData(this, "无证登记-输入身份证信息");
+    }
+
+    @Override
+    public void onClick(View view) {
+        submit();
+    }
+
+    private void submit() {
+        String name = mEditName.getText().toString().trim();
+        String idNum = mEditICCode.getText().toString().trim();
+        if (TextUtils.isEmpty(name)) {
+            ToastUtils.showToast("请输入姓名");
+            return;
+        }
+        if (TextUtils.isEmpty(idNum)) {
+            ToastUtils.showToast("请输入身份证");
+            return;
+        }
+        OpenDoorByFaceNetResultInfo info = new OpenDoorByFaceNetResultInfo();
+        Intent intent = new Intent(mContext, VisitorRegisterAc.class);
+        intent.putExtra(Constant.IIntentValue.CURRENTFACEPATH,currentFacePath);
+        intent.putExtra(Constant.IIntentValue.RECOGNIZE_INFO,info);
+        startActivity(intent);
+    }
+}

+ 2 - 4
app/src/main/java/com/sunwin/visitorapp/activity/VisitSignActivity.java

@@ -101,10 +101,8 @@ public class VisitSignActivity extends BaseActivity implements IdCardReadCallbac
     public void detectedUser(OpenDoorByFaceNetResultInfo openDoorByFaceNetResultInfo) {
         LogUtil.e(TAG, "-------------detectedUser--------------");
         BaseApplication.getSystemTTS().playText("识别成功");
-        String person_code = openDoorByFaceNetResultInfo.getPerson_code();
-        List<UserInfoModel> userInfoModels = DatabaseManager.getInstance().query(UserInfoModel.class, "personId", person_code);
-
-        updateUserInfo(userInfoModels);
+        String idNum = openDoorByFaceNetResultInfo.getIdNum();
+        updataUserInfoByIdNum(idNum);
     }
 
     @Override

+ 10 - 0
app/src/main/java/com/sunwin/visitorapp/activity/VisitorRegisterAc.java

@@ -182,6 +182,7 @@ public class VisitorRegisterAc extends BaseActivity implements View.OnClickListe
     }
 
     private void submit() {
+        UserInfoModel oldUserinfo = null;
         loadingDialog.showLoadingDialog("");
 
         String phone = mEditPhone.getText().toString().trim();
@@ -216,11 +217,17 @@ public class VisitorRegisterAc extends BaseActivity implements View.OnClickListe
         infoModel.setDeptId(deptNo + "");
         infoModel.setCategoryId(categoryId);
 
+        List<UserInfoModel> userInfoModels = DatabaseManager.getInstance().query(UserInfoModel.class, "idNum", idNum);
+        if (userInfoModels.size() != 0) {
+            oldUserinfo = userInfoModels.get(0);
+            infoModel.setPersonId(oldUserinfo.getPersonId());
+        }
 
         ApiService apiService = RetrofitUtil.getApiService();
         MediaType textType = MediaType.parse("text/plain");
         final RequestBody requestBody = RequestBody.create(textType, RetrofitUtil.bean2Json(infoModel));
         Call<BaseRsult<String>> call = apiService.saveOrUpdatePersonInfo(requestBody);
+        UserInfoModel finalOldUserinfo = oldUserinfo;
         call.enqueue(new Callback<BaseRsult<String>>() {
             @Override
             public void onResponse(Call<BaseRsult<String>> call, Response<BaseRsult<String>> response) {
@@ -240,6 +247,9 @@ public class VisitorRegisterAc extends BaseActivity implements View.OnClickListe
                         infoModel.setFaceToken(faceToken);
                         infoModel.setPersonId(personId);
                         addFace(currentFacePath, personId);
+                        if (finalOldUserinfo != null) {
+                            DatabaseManager.getInstance().delete(finalOldUserinfo);
+                        }
                         //存入数据库
                         long insert = DatabaseManager.getInstance().insert(infoModel);
                         LogUtil.e(TAG, "存入用户" + insert);

+ 4 - 1
app/src/main/java/com/sunwin/visitorapp/db/UserInfoModel.java

@@ -6,7 +6,11 @@ import com.litesuits.orm.db.enums.AssignType;
 
 @Table("user_table")
 public class UserInfoModel {
+
     @PrimaryKey(AssignType.BY_MYSELF)
+    private String idNum;
+
+
     private String personId;
 
     public String getFaceToken() {
@@ -49,7 +53,6 @@ public class UserInfoModel {
 
     private long updateTime;
 
-    private String idNum;
     private int sex; //0女,1男
     private String birthday;
     private String phone;

+ 2 - 1
app/src/main/java/com/sunwin/visitorapp/fragment/NoCardRegFragment.java

@@ -13,6 +13,7 @@ import androidx.annotation.Nullable;
 import com.sunwin.visitorapp.BaseApplication;
 import com.sunwin.visitorapp.BaseFragment;
 import com.sunwin.visitorapp.R;
+import com.sunwin.visitorapp.activity.VisitInputActivity;
 import com.sunwin.visitorapp.activity.VisitorRegisterAc;
 import com.sunwin.visitorapp.face.CameraPreviewData;
 import com.sunwin.visitorapp.model.OpenDoorByFaceNetResultInfo;
@@ -98,7 +99,7 @@ public class NoCardRegFragment extends BaseFragment implements FaceDetecterView.
                 new Handler().postDelayed(new Runnable() {
                     @Override
                     public void run() {
-                        Intent intent = new Intent(mContext, VisitorRegisterAc.class);
+                        Intent intent = new Intent(mContext, VisitInputActivity.class);
                         intent.putExtra(Constant.IIntentValue.CURRENTFACEPATH, saveFilePath);
                         startActivity(intent);
                     }

+ 54 - 39
app/src/main/res/layout/activity_home.xml

@@ -1,23 +1,73 @@
 <?xml version="1.0" encoding="utf-8"?>
 <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:app="http://schemas.android.com/apk/res-auto"
-    xmlns:tool="http://schemas.android.com/tools"
-    xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:background="@drawable/login_button_normal"
     android:orientation="vertical">
 
     <FrameLayout
+        android:id="@+id/fl_title"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintTop_toTopOf="parent">
+
+        <com.sunwin.visitorapp.view.UINav
+            android:id="@+id/UINav"
+            android:visibility="gone"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content" />
+
+        <RelativeLayout
+            android:id="@+id/ll_home_title"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:orientation="horizontal">
+
+            <TextView
+                android:id="@+id/TextTitle"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_centerInParent="true"
+                android:padding="15dp"
+                android:text="@string/app_name"
+                android:textColor="@color/black"
+                android:textSize="@dimen/sp_25" />
+
+            <ImageView
+                android:id="@+id/ImageStatus"
+                android:layout_width="60dp"
+                android:layout_height="60dp"
+                android:layout_toLeftOf="@+id/ImageSetting"
+                android:padding="10dp"
+                android:scaleType="fitCenter"
+                android:src="@drawable/ui_vector_status" />
+
+            <ImageView
+                android:id="@+id/ImageSetting"
+                android:layout_width="60dp"
+                android:layout_height="60dp"
+                android:layout_alignParentRight="true"
+                android:layout_marginLeft="20dp"
+                android:padding="10dp"
+                android:scaleType="fitCenter"
+                android:src="@drawable/ui_vector_setting" />
+        </RelativeLayout>
+    </FrameLayout>
+
+
+    <FrameLayout
         android:id="@+id/FragmentView"
         android:layout_width="0dp"
         android:layout_height="0dp"
         android:layout_marginStart="10dp"
         android:layout_marginEnd="40dp"
+        android:background="@drawable/card_white"
         app:layout_constraintBottom_toBottomOf="@id/ViewClock"
         app:layout_constraintEnd_toEndOf="parent"
         app:layout_constraintHorizontal_weight="5"
-        android:background="@drawable/card_white"
 
 
         app:layout_constraintStart_toEndOf="@id/ViewClock"
@@ -29,29 +79,6 @@
 
     </FrameLayout>
 
-    <ImageView
-        android:id="@+id/ImageStatus"
-        android:layout_width="0dp"
-        android:layout_height="0dp"
-        android:padding="10dp"
-        android:scaleType="fitCenter"
-        android:src="@drawable/ui_vector_status"
-        app:layout_constraintBottom_toBottomOf="@id/TextTitle"
-        app:layout_constraintDimensionRatio="1.2:1"
-        app:layout_constraintEnd_toStartOf="@id/ImageSetting"
-        app:layout_constraintTop_toTopOf="@id/TextTitle" />
-
-    <ImageView
-        android:id="@+id/ImageSetting"
-        android:layout_width="0dp"
-        android:layout_height="0dp"
-        android:padding="10dp"
-        android:scaleType="fitCenter"
-        android:src="@drawable/ui_vector_setting"
-        app:layout_constraintBottom_toBottomOf="@id/TextTitle"
-        app:layout_constraintDimensionRatio="1.2:1"
-        app:layout_constraintEnd_toEndOf="parent"
-        app:layout_constraintTop_toTopOf="@id/TextTitle" />
 
     <LinearLayout
         android:id="@+id/ViewClock"
@@ -68,7 +95,7 @@
         app:layout_constraintHorizontal_weight="2"
         app:layout_constraintStart_toStartOf="parent"
 
-        app:layout_constraintTop_toBottomOf="@id/TextTitle"
+        app:layout_constraintTop_toBottomOf="@id/fl_title"
 
         >
 
@@ -159,17 +186,5 @@
         </LinearLayout>
     </LinearLayout>
 
-    <TextView
-        android:id="@+id/TextTitle"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:padding="15dp"
-        android:text="@string/app_name"
-        android:textColor="@color/black"
-        android:textSize="@dimen/sp_25"
-        app:layout_constraintEnd_toEndOf="parent"
-        app:layout_constraintStart_toStartOf="parent"
-        app:layout_constraintTop_toTopOf="parent" />
-
 
 </androidx.constraintlayout.widget.ConstraintLayout>

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

@@ -0,0 +1,71 @@
+<?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: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:paddingTop="30dp"
+        android:layout_marginBottom="30dp"
+        android:background="@drawable/card_white"
+        android:orientation="vertical">
+
+        <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_marginVertical="10dp"
+            android:orientation="horizontal">
+
+            <TextView
+                style="@style/StyleTextContent"
+                android:layout_width="150dp"
+                android:text="人员姓名" />
+
+            <EditText
+                android:id="@+id/EditName"
+                style="@style/StyleInputContent"
+                android:layout_width="0dp"
+                android:layout_height="wrap_content"
+                android:layout_weight="1" />
+        </LinearLayout>
+
+        <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_marginVertical="10dp"
+            android:orientation="horizontal">
+
+            <TextView
+                style="@style/StyleTextContent"
+                android:layout_width="150dp"
+                android:text="身份证号" />
+
+            <EditText
+                android:id="@+id/EditICCode"
+                style="@style/StyleInputContent"
+                android:layout_width="0dp"
+                android:inputType="text"
+                android:layout_height="wrap_content"
+                android:layout_weight="1" />
+        </LinearLayout>
+
+        <Button
+            android:layout_marginTop="30dp"
+            android:layout_gravity="center_horizontal"
+            android:id="@+id/btn_next"
+            android:layout_width="150dp"
+            android:layout_height="40dp"
+            android:text="下一步" />
+    </LinearLayout>
+</LinearLayout>