替换菜品识别模型,暂时取消相似的判断,查询全部数据测试新模型效果,暂时取消查询前后数据量不一致的判断避免查不出数据

This commit is contained in:
mazengfei
2026-02-11 18:05:40 +08:00
parent 655e9cd56e
commit f562abc12f
9 changed files with 274 additions and 125 deletions
@@ -140,6 +140,7 @@ object ObjectBox {
dbMutex.withLock { operation() }
} catch (e: FileCorruptException) {
// 操作中触发损坏,尝试重建数据库
e.printStackTrace()
//val context = boxStore.context
//deleteDbFiles(context)
init(MyApp.instance!!)
@@ -173,19 +174,20 @@ object ObjectBox {
}
suspend fun putAll(entities: List<Food>) = safeDbOp {
getBox<Food>()?.put(entities)
val box = getBox<Food>()
box?.put(entities)
}
suspend fun filter(name:String?) = safeDbOp {
suspend fun filter(name: String?) = safeDbOp {
val list = getBox<Food>()?.all?.distinctBy { it.name }
if (name.isNullOrBlank().not()) {
list?.filter { it.name?.contains(name) == true }
} else {
list
}?:emptyList()
} ?: emptyList()
}
suspend fun remove(name:String) = safeDbOp {
suspend fun remove(name: String) = safeDbOp {
getBox<Food>()?.run {
val filterIdList = all.filter { it.name == name }.map { it.id }
removeByIds(filterIdList)