优化
This commit is contained in:
@@ -5,6 +5,7 @@ import android.content.Context
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.text.TextUtils
|
||||
import android.util.Log
|
||||
import android.view.KeyEvent
|
||||
import android.view.View
|
||||
import android.view.WindowInsetsController
|
||||
@@ -16,6 +17,7 @@ import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.view.WindowCompat
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.viewbinding.ViewBinding
|
||||
import com.google.gson.Gson
|
||||
import com.sw.inbound.utils.DateTimeUtils
|
||||
import com.sw.plate.utils.Base64
|
||||
import com.sw.plate.utils.ScanGunKeyEventHelper
|
||||
@@ -113,6 +115,10 @@ abstract class BaseActivity<VB : ViewBinding> : AppCompatActivity() {
|
||||
if (scanInfo.length > 6) {
|
||||
plateNumber = scanInfo.take(6)
|
||||
}
|
||||
Log.d("TAG", "handleScanKeyInfo: "+ Gson().toJson(MyApp.plateList))
|
||||
if (MyApp.plateList == null) {
|
||||
initPlateList()
|
||||
}
|
||||
//柜子未关联该餐盘,直接找空位置放入盘子
|
||||
val item = MyApp.plateList?.firstOrNull { it.plateNumber.isNullOrBlank() }
|
||||
if (item == null) {
|
||||
@@ -486,12 +492,24 @@ abstract class BaseActivity<VB : ViewBinding> : AppCompatActivity() {
|
||||
try {
|
||||
if (faceList.isNotEmpty()) {
|
||||
FaceDatabase.getInstance(this).faceDao().insert(faceList)
|
||||
recognizeViewModel.refreshFaceList()
|
||||
}
|
||||
recognizeViewModel.refreshFaceList()
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}.start()
|
||||
}
|
||||
|
||||
fun initPlateList() {
|
||||
// SpTool.putString(SpTool.PLATE_BOX_DATA, "")
|
||||
// var list = SpTool.getPlateData()
|
||||
val list: MutableList<EquipmentUserInfo> = mutableListOf()
|
||||
repeat(22) { index ->
|
||||
list.add(
|
||||
EquipmentUserInfo(equipmentBoxCode = "${index + 1}")
|
||||
)
|
||||
}
|
||||
MyApp.plateList = list
|
||||
}
|
||||
|
||||
}
|
||||
@@ -63,7 +63,7 @@ class DeviceInitActivity : BaseActivity<ActivityDeviceInitBinding>() {
|
||||
// }
|
||||
// }
|
||||
}.start()
|
||||
// viewModel.getUserFaceCache()
|
||||
viewModel.getUserFaceCache()
|
||||
viewModel.getDeviceConfig { deviceConfig ->
|
||||
runOnUiThread {
|
||||
if (deviceConfig == null) {
|
||||
@@ -107,38 +107,4 @@ class DeviceInitActivity : BaseActivity<ActivityDeviceInitBinding>() {
|
||||
|
||||
}
|
||||
|
||||
private fun initPlateList() {
|
||||
// SpTool.putString(SpTool.PLATE_BOX_DATA, "")
|
||||
// var list = SpTool.getPlateData()
|
||||
var list:List<EquipmentUserInfo>? = null;
|
||||
// if (list.isNullOrEmpty()) {
|
||||
list = mutableListOf()
|
||||
repeat(22) { index ->
|
||||
list.add(
|
||||
EquipmentUserInfo(
|
||||
equipmentBoxCode = "${index + 1}",
|
||||
// faceId = null,
|
||||
// plateNumber = null,
|
||||
// updateTime = null
|
||||
)
|
||||
)
|
||||
}
|
||||
// }
|
||||
// TODO: 测试数据----------------------------⬇️
|
||||
// else {
|
||||
// list[0].let {
|
||||
// it.plateNumber = "013748"
|
||||
// it.faceId = "111111111"
|
||||
// it.updateTime = DateTimeUtils.getDateTimeString()
|
||||
// }
|
||||
// list[1].let {
|
||||
// it.plateNumber = "013749"
|
||||
// it.faceId = "222222222"
|
||||
// it.updateTime = DateTimeUtils.getDateTimeString()
|
||||
// }
|
||||
// }
|
||||
// TODO: 测试数据----------------------------⬆️
|
||||
MyApp.plateList = list
|
||||
}
|
||||
|
||||
}
|
||||
@@ -271,41 +271,43 @@ class LoginByFaceActivity : BaseActivity<ActivityLoginFaceBinding>(),
|
||||
}
|
||||
|
||||
private var currentPlateInfo: EquipmentUserInfo? = null
|
||||
private var debouncer = Debouncer(5000)
|
||||
|
||||
// private var debouncer = Debouncer(5000)
|
||||
private var plateEnable = true
|
||||
|
||||
/**
|
||||
* 打开餐盘柜
|
||||
*/
|
||||
private fun openPlate(userId: String?) {
|
||||
if (plateEnable.not()) return
|
||||
debouncer.debounce {
|
||||
Log.d(TAG, "openPlate: userId=$userId")
|
||||
getPlateData { items ->
|
||||
Log.d(TAG, "openPlate: items:${Gson().toJson(items)}")
|
||||
// 未查询到当前用户,查询第一个未绑定的餐盘
|
||||
val item = items.firstOrNull { it.plateNumber.isNullOrEmpty().not() }
|
||||
Log.d(TAG, "openPlate: item2:${item}")
|
||||
if (item == null) {
|
||||
//暂无餐盘
|
||||
ToastUtils.showToast("暂无餐盘,请联系管理人员!")
|
||||
goInitActivity()
|
||||
return@getPlateData
|
||||
}
|
||||
Log.d(TAG, "openPlate: item3:${item}")
|
||||
item.faceId = userId
|
||||
item.updateTime = DateTimeUtils.getDateTimeString()
|
||||
item.plateNumber = null
|
||||
//打开柜子
|
||||
PlateUtils.open(this, item.equipmentBoxCode, false)
|
||||
plateEnable = false
|
||||
currentPlateInfo = item
|
||||
MyApp.plateList = items
|
||||
SpTool.savePlateData(items)
|
||||
|
||||
debouncer.reset()
|
||||
//recognizeViewModel.recognizeUserId.postValue(CompareResult(null,0f))
|
||||
// debouncer.debounce {
|
||||
Log.d(TAG, "openPlate: userId=$userId")
|
||||
getPlateData { items ->
|
||||
Log.d(TAG, "openPlate: items:${Gson().toJson(items)}")
|
||||
// 未查询到当前用户,查询第一个未绑定的餐盘
|
||||
val item = items.firstOrNull { it.plateNumber.isNullOrEmpty().not() }
|
||||
Log.d(TAG, "openPlate: item2:${item}")
|
||||
if (item == null) {
|
||||
//暂无餐盘
|
||||
ToastUtils.showToast("暂无餐盘,请联系管理人员!")
|
||||
goInitActivity()
|
||||
return@getPlateData
|
||||
}
|
||||
Log.d(TAG, "openPlate: item3:${item}")
|
||||
item.faceId = userId
|
||||
item.updateTime = DateTimeUtils.getDateTimeString()
|
||||
item.plateNumber = null
|
||||
//打开柜子
|
||||
PlateUtils.open(this, item.equipmentBoxCode, false)
|
||||
plateEnable = false
|
||||
currentPlateInfo = item
|
||||
MyApp.plateList = items
|
||||
SpTool.savePlateData(items)
|
||||
|
||||
// debouncer.reset()
|
||||
//recognizeViewModel.recognizeUserId.postValue(CompareResult(null,0f))
|
||||
}
|
||||
// }
|
||||
}
|
||||
|
||||
// /**
|
||||
@@ -732,8 +734,8 @@ class LoginByFaceActivity : BaseActivity<ActivityLoginFaceBinding>(),
|
||||
// if (collectCount <= 5) {
|
||||
// collectFace()
|
||||
// } else {
|
||||
loadLogInfo("collectFace,saveFaceInfo: ----------14,${collectCount}次人脸采集异常:${e.message}-----------")
|
||||
ToastUtils.showToast("人脸采集异常:${e.message}")
|
||||
loadLogInfo("collectFace,saveFaceInfo: ----------14,${collectCount}次人脸采集异常:${e.message}-----------")
|
||||
ToastUtils.showToast("人脸采集异常:${e.message}")
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user