餐盘柜优化-不绑定用户可多次取盘
This commit is contained in:
@@ -113,24 +113,14 @@ abstract class BaseActivity<VB : ViewBinding> : AppCompatActivity() {
|
||||
if (scanInfo.length > 6) {
|
||||
plateNumber = scanInfo.take(6)
|
||||
}
|
||||
// ToastUtils.showToast(plateNumber)
|
||||
var item = MyApp.plateList?.firstOrNull { it.plateNumber == plateNumber }
|
||||
//柜子未关联该餐盘,直接找空位置放入盘子
|
||||
val item = MyApp.plateList?.firstOrNull { it.plateNumber.isNullOrBlank() }
|
||||
if (item == null) {
|
||||
//柜子未关联该餐盘,直接找空位置放入盘子
|
||||
item = MyApp.plateList?.firstOrNull { it.plateNumber.isNullOrBlank() }
|
||||
if (item ==null) {
|
||||
//柜子已满
|
||||
MainActivity.start(context = context, pageType = PageType.PLATE_CABINET_FULL)
|
||||
return
|
||||
}
|
||||
//找到位置,放入餐盘,清除已有id和时间
|
||||
item.plateNumber = plateNumber
|
||||
item.faceId = null
|
||||
item.updateTime = null
|
||||
PlateUtils.open(this, item.equipmentBoxCode, true)
|
||||
//柜子已满
|
||||
MainActivity.start(context = context, pageType = PageType.PLATE_CABINET_FULL)
|
||||
return
|
||||
}
|
||||
//放入餐盘,清除已有id和时间
|
||||
//找到位置,放入餐盘,清除已有id和时间
|
||||
item.plateNumber = plateNumber
|
||||
item.faceId = null
|
||||
item.updateTime = null
|
||||
@@ -270,7 +260,9 @@ abstract class BaseActivity<VB : ViewBinding> : AppCompatActivity() {
|
||||
runOnUiThread {
|
||||
hideWaitingDialog()
|
||||
val view = View.inflate(this, R.layout.dialog_waiting, null)
|
||||
if (!TextUtils.isEmpty(tip)) (view.findViewById<View?>(R.id.tvTip) as TextView).setText(tip)
|
||||
if (!TextUtils.isEmpty(tip)) (view.findViewById<View?>(R.id.tvTip) as TextView).setText(
|
||||
tip
|
||||
)
|
||||
mDialogWaiting = CustomLoadingDialog(this, view, R.style.MyDialog)
|
||||
mDialogWaiting!!.show()
|
||||
mDialogWaiting!!.setCancelable(true)
|
||||
|
||||
@@ -210,14 +210,14 @@ class LoginByFaceActivity : BaseActivity<ActivityLoginFaceBinding>(),
|
||||
Timber.i("recognizeUserId observe userId = ${result?.faceEntity?.userName}")
|
||||
currentUserId = result?.faceEntity?.userName
|
||||
// viewModel.getUserInfoById(memberId = userId)
|
||||
//ToastUtils.showToast(userId)
|
||||
// ToastUtils.showToast(currentUserId)
|
||||
// if (!currentUserId.isNullOrBlank()) {
|
||||
//// ToastUtils.showToast("您已采集过人脸信息")
|
||||
// return@Observer
|
||||
// }
|
||||
if (currentPlateInfo?.faceId == currentUserId) {
|
||||
return@Observer
|
||||
}
|
||||
// if (currentPlateInfo?.faceId == currentUserId) {
|
||||
// return@Observer
|
||||
// }
|
||||
openPlate(currentUserId)
|
||||
})
|
||||
|
||||
@@ -249,17 +249,8 @@ class LoginByFaceActivity : BaseActivity<ActivityLoginFaceBinding>(),
|
||||
Log.d(TAG, "openPlate: userId=$userId")
|
||||
getPlateData { items ->
|
||||
Log.d(TAG, "openPlate: items:${Gson().toJson(items)}")
|
||||
var item = items.firstOrNull { it.faceId == userId }
|
||||
Log.d(TAG, "openPlate: item1:${item}")
|
||||
if (item != null) {
|
||||
//餐盘已取
|
||||
ToastUtils.showToast("您已拿过餐盘!")
|
||||
return@getPlateData
|
||||
}
|
||||
// 未查询到当前用户,查询第一个未绑定的餐盘
|
||||
item = items.firstOrNull {
|
||||
it.plateNumber.isNullOrEmpty().not() && it.faceId.isNullOrBlank()
|
||||
}
|
||||
val item = items.firstOrNull { it.plateNumber.isNullOrEmpty().not() }
|
||||
Log.d(TAG, "openPlate: item2:${item}")
|
||||
if (item == null) {
|
||||
//暂无餐盘
|
||||
@@ -269,6 +260,7 @@ class LoginByFaceActivity : BaseActivity<ActivityLoginFaceBinding>(),
|
||||
Log.d(TAG, "openPlate: item3:${item}")
|
||||
item.faceId = userId
|
||||
item.updateTime = DateTimeUtils.getDateTimeString()
|
||||
item.plateNumber = null
|
||||
//打开柜子
|
||||
PlateUtils.open(this, item.equipmentBoxCode, false)
|
||||
|
||||
@@ -548,7 +540,6 @@ class LoginByFaceActivity : BaseActivity<ActivityLoginFaceBinding>(),
|
||||
|
||||
private fun pauseCamera() {
|
||||
isRecognition = false
|
||||
|
||||
recognizeViewModel.onPreviewFrame(ByteArray(1382400), true)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user