优化
This commit is contained in:
@@ -5,6 +5,7 @@ import android.content.Context
|
|||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.text.TextUtils
|
import android.text.TextUtils
|
||||||
|
import android.util.Log
|
||||||
import android.view.KeyEvent
|
import android.view.KeyEvent
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.WindowInsetsController
|
import android.view.WindowInsetsController
|
||||||
@@ -16,6 +17,7 @@ import androidx.appcompat.app.AppCompatActivity
|
|||||||
import androidx.core.view.WindowCompat
|
import androidx.core.view.WindowCompat
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import androidx.viewbinding.ViewBinding
|
import androidx.viewbinding.ViewBinding
|
||||||
|
import com.google.gson.Gson
|
||||||
import com.sw.inbound.utils.DateTimeUtils
|
import com.sw.inbound.utils.DateTimeUtils
|
||||||
import com.sw.plate.utils.Base64
|
import com.sw.plate.utils.Base64
|
||||||
import com.sw.plate.utils.ScanGunKeyEventHelper
|
import com.sw.plate.utils.ScanGunKeyEventHelper
|
||||||
@@ -113,6 +115,10 @@ abstract class BaseActivity<VB : ViewBinding> : AppCompatActivity() {
|
|||||||
if (scanInfo.length > 6) {
|
if (scanInfo.length > 6) {
|
||||||
plateNumber = scanInfo.take(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() }
|
val item = MyApp.plateList?.firstOrNull { it.plateNumber.isNullOrBlank() }
|
||||||
if (item == null) {
|
if (item == null) {
|
||||||
@@ -486,12 +492,24 @@ abstract class BaseActivity<VB : ViewBinding> : AppCompatActivity() {
|
|||||||
try {
|
try {
|
||||||
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()
|
||||||
}
|
}
|
||||||
}.start()
|
}.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()
|
}.start()
|
||||||
// viewModel.getUserFaceCache()
|
viewModel.getUserFaceCache()
|
||||||
viewModel.getDeviceConfig { deviceConfig ->
|
viewModel.getDeviceConfig { deviceConfig ->
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
if (deviceConfig == null) {
|
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,14 +271,16 @@ class LoginByFaceActivity : BaseActivity<ActivityLoginFaceBinding>(),
|
|||||||
}
|
}
|
||||||
|
|
||||||
private var currentPlateInfo: EquipmentUserInfo? = null
|
private var currentPlateInfo: EquipmentUserInfo? = null
|
||||||
private var debouncer = Debouncer(5000)
|
|
||||||
|
// private var debouncer = Debouncer(5000)
|
||||||
private var plateEnable = true
|
private var plateEnable = true
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 打开餐盘柜
|
* 打开餐盘柜
|
||||||
*/
|
*/
|
||||||
private fun openPlate(userId: String?) {
|
private fun openPlate(userId: String?) {
|
||||||
if (plateEnable.not()) return
|
if (plateEnable.not()) return
|
||||||
debouncer.debounce {
|
// debouncer.debounce {
|
||||||
Log.d(TAG, "openPlate: userId=$userId")
|
Log.d(TAG, "openPlate: userId=$userId")
|
||||||
getPlateData { items ->
|
getPlateData { items ->
|
||||||
Log.d(TAG, "openPlate: items:${Gson().toJson(items)}")
|
Log.d(TAG, "openPlate: items:${Gson().toJson(items)}")
|
||||||
@@ -302,10 +304,10 @@ class LoginByFaceActivity : BaseActivity<ActivityLoginFaceBinding>(),
|
|||||||
MyApp.plateList = items
|
MyApp.plateList = items
|
||||||
SpTool.savePlateData(items)
|
SpTool.savePlateData(items)
|
||||||
|
|
||||||
debouncer.reset()
|
// debouncer.reset()
|
||||||
//recognizeViewModel.recognizeUserId.postValue(CompareResult(null,0f))
|
//recognizeViewModel.recognizeUserId.postValue(CompareResult(null,0f))
|
||||||
}
|
}
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
// /**
|
// /**
|
||||||
|
|||||||
Reference in New Issue
Block a user