优化
This commit is contained in:
@@ -22,6 +22,7 @@ import com.sw.plate.utils.ScanGunKeyEventHelper
|
|||||||
import com.sw.plate.utils.ToastUtils
|
import com.sw.plate.utils.ToastUtils
|
||||||
import com.sw.plate.utils.arcface.facedb.FaceDatabase
|
import com.sw.plate.utils.arcface.facedb.FaceDatabase
|
||||||
import com.sw.plate.utils.arcface.facedb.entity.FaceEntity
|
import com.sw.plate.utils.arcface.facedb.entity.FaceEntity
|
||||||
|
import com.sw.plate.utils.arcface.viewmodel.RecognizeViewModel
|
||||||
import com.sw.plate.utils.comn.SerialApi
|
import com.sw.plate.utils.comn.SerialApi
|
||||||
import com.sw.plate.utils.comn.SerialPortManager
|
import com.sw.plate.utils.comn.SerialPortManager
|
||||||
import com.sw.platecabinet.R
|
import com.sw.platecabinet.R
|
||||||
@@ -397,9 +398,13 @@ abstract class BaseActivity<VB : ViewBinding> : AppCompatActivity() {
|
|||||||
fun startFaceTask() {
|
fun startFaceTask() {
|
||||||
faceTaskJob =
|
faceTaskJob =
|
||||||
intervalExecutor.startIntervalTaskWithInitialDelay(initialDelay, dealyMillis) {
|
intervalExecutor.startIntervalTaskWithInitialDelay(initialDelay, dealyMillis) {
|
||||||
|
val timestamp = SpTool.getLastFaceTimestamp()
|
||||||
|
if (timestamp == 0L) {
|
||||||
|
return@startIntervalTaskWithInitialDelay
|
||||||
|
}
|
||||||
settingViewModel.getFaceIncrementList(
|
settingViewModel.getFaceIncrementList(
|
||||||
pageNo = taskPageNo,
|
pageNo = taskPageNo,
|
||||||
timestamp = SpTool.getLastFaceTimestamp()
|
timestamp = timestamp
|
||||||
) { list ->
|
) { list ->
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
if (list.isEmpty()) {
|
if (list.isEmpty()) {
|
||||||
@@ -412,6 +417,7 @@ abstract class BaseActivity<VB : ViewBinding> : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val recognizeViewModel by viewModels<RecognizeViewModel>()
|
||||||
private fun updateFaceData(list: List<UserFaceModel>) {
|
private fun updateFaceData(list: List<UserFaceModel>) {
|
||||||
Thread {
|
Thread {
|
||||||
val faceList = mutableListOf<FaceEntity>()
|
val faceList = mutableListOf<FaceEntity>()
|
||||||
@@ -439,7 +445,7 @@ abstract class BaseActivity<VB : ViewBinding> : AppCompatActivity() {
|
|||||||
if (faceList.isNotEmpty()) {
|
if (faceList.isNotEmpty()) {
|
||||||
FaceDatabase.getInstance(this).faceDao().insert(faceList)
|
FaceDatabase.getInstance(this).faceDao().insert(faceList)
|
||||||
}
|
}
|
||||||
recognizeViewModel.refreshFaceList();
|
recognizeViewModel.refreshFaceList()
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,11 @@ package com.sw.plate.utils.arcface.facedb.entity;
|
|||||||
|
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
|
||||||
import androidx.room.ColumnInfo;
|
import androidx.room.ColumnInfo;
|
||||||
import androidx.room.Entity;
|
import androidx.room.Entity;
|
||||||
|
import androidx.room.Ignore;
|
||||||
import androidx.room.PrimaryKey;
|
import androidx.room.PrimaryKey;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@@ -42,6 +44,14 @@ public class FaceEntity implements Parcelable {
|
|||||||
*/
|
*/
|
||||||
@ColumnInfo(name = "register_time")
|
@ColumnInfo(name = "register_time")
|
||||||
private long registerTime;
|
private long registerTime;
|
||||||
|
/**
|
||||||
|
* 用户类型:1-普通会员、2-临时用户、3-内部员工、或者其它待定类型
|
||||||
|
*/
|
||||||
|
@ColumnInfo(name = "user_type")
|
||||||
|
private String userType;
|
||||||
|
|
||||||
|
@Ignore
|
||||||
|
private int trackId;//人脸追踪ID
|
||||||
|
|
||||||
public FaceEntity(String userName, String imagePath, byte[] featureData) {
|
public FaceEntity(String userName, String imagePath, byte[] featureData) {
|
||||||
this.userName = userName;
|
this.userName = userName;
|
||||||
@@ -119,6 +129,22 @@ public class FaceEntity implements Parcelable {
|
|||||||
this.registerTime = registerTime;
|
this.registerTime = registerTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getTrackId() {
|
||||||
|
return trackId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTrackId(int trackId) {
|
||||||
|
this.trackId = trackId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUserType() {
|
||||||
|
return userType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUserType(String userType) {
|
||||||
|
this.userType = userType;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int describeContents() {
|
public int describeContents() {
|
||||||
return 0;
|
return 0;
|
||||||
@@ -131,8 +157,11 @@ public class FaceEntity implements Parcelable {
|
|||||||
dest.writeString(userName);
|
dest.writeString(userName);
|
||||||
dest.writeString(imagePath);
|
dest.writeString(imagePath);
|
||||||
dest.writeByteArray(featureData);
|
dest.writeByteArray(featureData);
|
||||||
|
dest.writeString(userType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (this == o) {
|
if (this == o) {
|
||||||
@@ -142,16 +171,17 @@ public class FaceEntity implements Parcelable {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
FaceEntity that = (FaceEntity) o;
|
FaceEntity that = (FaceEntity) o;
|
||||||
return faceId == that.faceId &&
|
return this.faceId == that.faceId &&
|
||||||
registerTime == that.registerTime &&
|
this.registerTime == that.registerTime &&
|
||||||
userName.equals(that.userName) &&
|
TextUtils.equals(this.userName, that.userName) &&
|
||||||
imagePath.equals(that.imagePath) &&
|
TextUtils.equals(this.imagePath, that.imagePath) &&
|
||||||
Arrays.equals(featureData, that.featureData);
|
Arrays.equals(featureData, that.featureData) &&
|
||||||
|
TextUtils.equals(this.userType, that.userType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
int result = Objects.hash(faceId, registerTime, userName, imagePath);
|
int result = Objects.hash(faceId, registerTime, userName, imagePath, userType);
|
||||||
result = 31 * result + Arrays.hashCode(featureData);
|
result = 31 * result + Arrays.hashCode(featureData);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user