refactor(login): 优化餐盘出盘及剩余状态提示逻辑
- 出盘后改为直接查询剩余餐盘状态以决定提示音播放 - result为false时播放无盘提示音并跳转首页 - result为true时播放出盘成功音效,继续查询剩余餐盘 - 新增checkRemainingPlate方法,查询餐盘状态并播放相应提示音 - 错误时跳过播放,确保流程顺畅跳转首页 - 删除之前注释的旧版餐盘检测逻辑代码
This commit is contained in:
@@ -407,7 +407,7 @@ class LoginByFaceActivity : BaseActivity<ActivityLoginFaceBinding>(),
|
||||
private var plateEnable = false
|
||||
|
||||
/**
|
||||
* 打开餐盘柜:先获取 PLC 状态,有盘则出盘,无盘则播放提示音
|
||||
* 打开餐盘柜:执行出盘,出盘后查询剩余餐盘状态并播放对应提示音
|
||||
*/
|
||||
private fun openPlate(userId: String?) {
|
||||
loadLogInfo("collectFace,openPlate: userId=$userId,plateEnable=$plateEnable")
|
||||
@@ -416,16 +416,19 @@ class LoginByFaceActivity : BaseActivity<ActivityLoginFaceBinding>(),
|
||||
PlcHelper.getInstance(this@LoginByFaceActivity)
|
||||
.outPlate(object : PlcCallback<String> {
|
||||
override fun onSuccess(result: String) {
|
||||
|
||||
if(result.equals("true")){
|
||||
SoundPoolUtil.getInstance().play(RECOGNIZE_SUCCESS, 0)
|
||||
}
|
||||
plateEnable = false
|
||||
recognizeCountDownUtil.cancelCountDown()
|
||||
|
||||
|
||||
loadLogInfo("collectFace,openPlate: 出盘成功,result=$result")
|
||||
goInitActivity()
|
||||
loadLogInfo("collectFace,openPlate: 出盘完成,result=$result,开始查询剩余餐盘")
|
||||
// result 为 false 时表示出盘后无餐盘,直接播放无盘提示音
|
||||
if (result.equals("false", ignoreCase = true)) {
|
||||
loadLogInfo("collectFace,openPlate: result=false,餐盘已空")
|
||||
SoundPoolUtil.getInstance().play(NO_PLATE_REMIND, 0)
|
||||
goInitActivity()
|
||||
return
|
||||
}
|
||||
// result 为 true,出盘成功,再查询是否还有剩余餐盘
|
||||
SoundPoolUtil.getInstance().play(RECOGNIZE_SUCCESS, 0)
|
||||
checkRemainingPlate()
|
||||
}
|
||||
|
||||
override fun onError(message: String) {
|
||||
@@ -434,32 +437,31 @@ class LoginByFaceActivity : BaseActivity<ActivityLoginFaceBinding>(),
|
||||
goInitActivity()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// showWaitingDialog("检测餐盘中,请稍候……")
|
||||
// PlcHelper.getInstance(this).getStatus(object : PlcCallback<PlcStatus> {
|
||||
// override fun onSuccess(result: PlcStatus) {
|
||||
// hideWaitingDialog()
|
||||
// if (result.isEmptyPlate) {
|
||||
// // 无餐盘,播放提示音并返回首页
|
||||
// loadLogInfo("collectFace,openPlate: 暂无餐盘,isEmptyPlate=true,isCollectFace=$isCollectFace")
|
||||
// SoundPoolUtil.getInstance().play(NO_PLATE_REMIND, 0)
|
||||
// goInitActivity()
|
||||
// return
|
||||
// }
|
||||
// // 有餐盘,播放识别成功音效并调用出盘
|
||||
// loadLogInfo("collectFace,openPlate: 检测到餐盘,开始出盘")
|
||||
//
|
||||
//
|
||||
// }
|
||||
//
|
||||
// override fun onError(message: String) {
|
||||
// hideWaitingDialog()
|
||||
// // 状态获取失败,保底播放无盘提示
|
||||
// loadLogInfo("collectFace,openPlate: 获取PLC状态失败,message=$message")
|
||||
// SoundPoolUtil.getInstance().play(NO_PLATE_REMIND, 0)
|
||||
// goInitActivity()
|
||||
// }
|
||||
// })
|
||||
/**
|
||||
* 出盘成功后查询剩余餐盘状态,无盘则播放提示音
|
||||
*/
|
||||
private fun checkRemainingPlate() {
|
||||
PlcHelper.getInstance(this@LoginByFaceActivity)
|
||||
.getStatus(object : PlcCallback<PlcStatus> {
|
||||
override fun onSuccess(result: PlcStatus) {
|
||||
if (isFinishing || isDestroyed) return
|
||||
loadLogInfo("collectFace,checkRemainingPlate: isEmptyPlate=${result.isEmptyPlate}")
|
||||
if (result.isEmptyPlate) {
|
||||
// 餐盘已空,播放无盘提示音
|
||||
SoundPoolUtil.getInstance().play(NO_PLATE_REMIND, 0)
|
||||
}
|
||||
goInitActivity()
|
||||
}
|
||||
|
||||
override fun onError(message: String) {
|
||||
if (isFinishing || isDestroyed) return
|
||||
// 状态查询失败,不影响主流程,直接跳转
|
||||
loadLogInfo("collectFace,checkRemainingPlate: 获取PLC状态失败,message=$message")
|
||||
goInitActivity()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private val openDebouncer by lazy { Debouncer(5000) }
|
||||
|
||||
Reference in New Issue
Block a user