From ba1a364ee8502c6a44b0538285f2e9a33daf8970 Mon Sep 17 00:00:00 2001 From: mazengfei <331023091@qq.com> Date: Tue, 14 Apr 2026 11:50:39 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=B4=E6=97=B6=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../activity/LoginByFaceActivity.kt | 77 ++++++++++--------- 1 file changed, 39 insertions(+), 38 deletions(-) diff --git a/app/src/main/java/com/sw/platecabinet/activity/LoginByFaceActivity.kt b/app/src/main/java/com/sw/platecabinet/activity/LoginByFaceActivity.kt index f994ef0..cd5a3b5 100644 --- a/app/src/main/java/com/sw/platecabinet/activity/LoginByFaceActivity.kt +++ b/app/src/main/java/com/sw/platecabinet/activity/LoginByFaceActivity.kt @@ -412,45 +412,54 @@ class LoginByFaceActivity : BaseActivity(), private fun openPlate(userId: String?) { loadLogInfo("collectFace,openPlate: userId=$userId,plateEnable=$plateEnable") if (plateEnable.not()) return -// showWaitingDialog("检测餐盘中,请稍候……") - PlcHelper.getInstance(this).getStatus(object : PlcCallback { - 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 + + PlcHelper.getInstance(this@LoginByFaceActivity) + .outPlate(object : PlcCallback { + override fun onSuccess(result: String) { + + if(result.equals("true")){ + SoundPoolUtil.getInstance().play(RECOGNIZE_SUCCESS, 0) } - // 有餐盘,播放识别成功音效并调用出盘 - loadLogInfo("collectFace,openPlate: 检测到餐盘,开始出盘") - SoundPoolUtil.getInstance().play(RECOGNIZE_SUCCESS, 0) plateEnable = false recognizeCountDownUtil.cancelCountDown() - PlcHelper.getInstance(this@LoginByFaceActivity) - .outPlate(object : PlcCallback { - override fun onSuccess(result: String) { - loadLogInfo("collectFace,openPlate: 出盘成功,result=$result") - goInitActivity() - } - override fun onError(message: String) { - ToastUtils.showToast("出盘失败,message=$message") - loadLogInfo("collectFace,openPlate: 出盘失败,message=$message") - goInitActivity() - } - }) + + loadLogInfo("collectFace,openPlate: 出盘成功,result=$result") + goInitActivity() } override fun onError(message: String) { - hideWaitingDialog() - // 状态获取失败,保底播放无盘提示 - loadLogInfo("collectFace,openPlate: 获取PLC状态失败,message=$message") - SoundPoolUtil.getInstance().play(NO_PLATE_REMIND, 0) + ToastUtils.showToast("出盘失败,message=$message") + loadLogInfo("collectFace,openPlate: 出盘失败,message=$message") goInitActivity() } }) + +// showWaitingDialog("检测餐盘中,请稍候……") +// PlcHelper.getInstance(this).getStatus(object : PlcCallback { +// 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 val openDebouncer by lazy { Debouncer(5000) } @@ -734,15 +743,7 @@ class LoginByFaceActivity : BaseActivity(), goInitActivity() return } - // 每次回到识别界面时重新打开串口,防止 PLC SDK 内部连接超时导致出盘失败 - PlcHelper.getInstance(this).openSerialPort(object : PlcCallback { - override fun onSuccess(result: String) { - loadLogInfo("onResume openSerialPort 成功: $result") - } - override fun onError(message: String) { - loadLogInfo("onResume openSerialPort 失败: $message") - } - }) + lifecycleScope.launch { try { val faceDao = FaceDatabase.getInstance(this@LoginByFaceActivity).faceDao()