fix(order): 解决订单生成后餐品未拿走的检测逻辑

- 添加abs函数导入用于计算重量绝对值
- 在订单生成成功后增加重量检测逻辑
- 当称重绝对值大于10克时认为餐品未被拿走
- 添加详细的调试日志记录重量信息
- 集成FileUtil工具类用于保存操作日志
- 在人脸数据获取流程中添加日志记录时间戳变化
This commit is contained in:
2026-04-14 15:19:09 +08:00
parent 7f455f2d8f
commit 45562a9fc1
2 changed files with 12 additions and 0 deletions
@@ -65,6 +65,7 @@ import kotlinx.coroutines.flow.drop
import kotlinx.coroutines.launch
import timber.log.Timber
import java.text.DecimalFormat
import kotlin.math.abs
import kotlin.math.max
import kotlin.math.roundToInt
@@ -1340,6 +1341,13 @@ class MainScreenPresentation(
setTopInfoVisible()
}
} else {
Timber.tag(TAG).d("drawPreviewInfo,successBlock,订单已生成,称重为:${activity.currentWeight}")
//即放即取未拿走餐品,不用重置为默认识别中状态
if (abs(activity.currentWeight) > 10) {
//提交订单后秤重量绝对值大于10克,都认为餐品还没拿走
Timber.tag(TAG).d("drawPreviewInfo,successBlock,订单已生成,未拿走餐品")
return@createOrder
}
Timber.tag(TAG).d("drawPreviewInfo,successBlock,订单已生成,step1FoodRecognizing")
Timber.tag(TAG).e("切回step1,------2000000000002")
activity.isAnalyzing = false
@@ -18,6 +18,7 @@ import com.sw.dualscreen.model.response.UserFaceModel2
import com.sw.dualscreen.model.response.UserNutrition
import com.sw.dualscreen.objbox.CollectedFoodInfo
import com.sw.dualscreen.utils.Debouncer
import com.sw.dualscreen.utils.FileUtil
import com.sw.dualscreen.utils.SPUtil
import com.sw.dualscreen.utils.SpTool
import com.sw.plate.App
@@ -107,6 +108,7 @@ class UserViewModel : BaseViewModel() {
_loadFaceResult.value = false
//获取全量数据时,时间戳改为0
SpTool.lastFaceTimestamp = 0
FileUtil.saveLog("获取人脸全量数据开始,重置时间戳为0")
val response = repository.getUserFaceCache(currentPageNo)
val check = parseResponse(response)
if (!check) {
@@ -144,6 +146,7 @@ class UserViewModel : BaseViewModel() {
lastFaceTimestamp = list.last().faceUpdateTimestamp ?: 0L
}
SpTool.lastFaceTimestamp = lastFaceTimestamp
FileUtil.saveLog("获取人脸[全量]数据结束,时间戳为:$lastFaceTimestamp")
_loadFaceResult.value = true
onSuccess()
}
@@ -221,6 +224,7 @@ class UserViewModel : BaseViewModel() {
lastFaceTimestamp = list.last().faceUpdateTimestamp ?: 0L
}
SpTool.lastFaceTimestamp = lastFaceTimestamp
FileUtil.saveLog("获取人脸[增量]数据结束,时间戳为:$lastFaceTimestamp")
onAllQueryFinished()
}
}