fix(main): 优化重量识别逻辑与日志;防抖时间调整为2s;从版本控制中移除.idea和objectbox-models
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
dbe3753821
commit
0127697560
@@ -152,7 +152,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
||||
private var bottomSheetDialog: CustomBottomSheetDialog? = null
|
||||
private var lastWeight: Int = 0
|
||||
private var lastPhotoUri: Uri? = null // 最后拍照的图片
|
||||
private var debouncer = Debouncer(5000)
|
||||
private var debouncer = Debouncer(2000)
|
||||
private var isRecognitionFood = true
|
||||
private var isFirstOpen = true
|
||||
|
||||
@@ -290,26 +290,33 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
||||
* 联合支付-即放即取模式
|
||||
*/
|
||||
private fun loadJFJQBySettlement(weight: Int) {
|
||||
log("registerDataChange weight 联合支付-即放即取")
|
||||
//即放即取+联合支付人脸查询订单完成
|
||||
if (presentation!!.jointPaymentQueryFinish) {
|
||||
log("registerDataChange weight 联合支付-即放即取,人脸查询订单完成")
|
||||
if (weight > WEIGHT_RESET_RECOGNIZE) {
|
||||
//已识别完成人脸并查询到订单数据,增加重量不再重新识别
|
||||
log("registerDataChange weight 联合支付-即放即取,不再重新识别")
|
||||
return
|
||||
}
|
||||
//重量小于等于5克时改为识别中页面
|
||||
log("registerDataChange weight 联合支付-即放即取,step1FoodRecognizing")
|
||||
//重量小于等于10克时改为识别中页面
|
||||
isAnalyzing = false
|
||||
presentation?.step1FoodRecognizing()
|
||||
return
|
||||
}
|
||||
log("registerDataChange weight 联合支付-即放即取,人脸查询订单没有完成")
|
||||
if (weight <= WEIGHT_RESET_RECOGNIZE) {
|
||||
//秤上重量过下,显示识别中页面
|
||||
//秤上重量过小,显示识别中页面
|
||||
log("registerDataChange weight 联合支付-即放即取,重量小于${WEIGHT_RESET_RECOGNIZE}g,step1FoodRecognizing")
|
||||
presentation?.step1FoodRecognizing()
|
||||
return
|
||||
}
|
||||
log("registerDataChange weight 联合支付-即放即取,recognizeByWeight")
|
||||
// val isWeightChange = abs(weight - lastWeight) > 0.02
|
||||
val isWeightChange = weight - lastWeight > WEIGHT_CHANGE_VALUE
|
||||
if (weight != lastWeight) {
|
||||
log("recognizeByWeight---00001,weight=$weight,lastWeight=$lastWeight,isWeightChange=$isWeightChange")
|
||||
log("registerDataChange weight 联合支付-即放即取,recognizeByWeight---00001,weight=$weight,lastWeight=$lastWeight,isWeightChange=$isWeightChange")
|
||||
}
|
||||
recognizeByWeight(weight, isWeightChange)
|
||||
}
|
||||
@@ -318,14 +325,18 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
||||
* 联合支付-余量计量模式
|
||||
*/
|
||||
private fun loadYLJLBySettlement(weight: Int) {
|
||||
log("registerDataChange weight 联合支付-余量计量")
|
||||
if (weight <= WEIGHT_RESET_RECOGNIZE) {
|
||||
log("registerDataChange weight 联合支付-余量计量,重量小于${WEIGHT_RESET_RECOGNIZE}g,step1FoodRecognizing")
|
||||
//秤上重量过小,显示识别中页面
|
||||
presentation?.step1FoodRecognizing()
|
||||
lastWeight = weight
|
||||
return
|
||||
}
|
||||
log("registerDataChange weight 联合支付-余量计量,订单完成状态:${presentation!!.jointPaymentQueryFinish}")
|
||||
//余量计量+联合支付人脸查询订单完成
|
||||
if (presentation!!.jointPaymentQueryFinish) {
|
||||
log("registerDataChange weight 联合支付-余量计量,updateWeight")
|
||||
presentation?.updateWeight(weight)
|
||||
lastWeight = weight
|
||||
return
|
||||
@@ -342,10 +353,12 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
||||
}
|
||||
}
|
||||
if (weight <= WEIGHT_RESET_RECOGNIZE) {
|
||||
log("registerDataChange weight 秤重量小于${WEIGHT_RESET_RECOGNIZE}g")
|
||||
//检测到秤上没有东西,重新启动识别菜品 && presentation?.mealPickupMode == 1
|
||||
checkedItem = null
|
||||
}
|
||||
if (settlementMode == 0) {
|
||||
log("registerDataChange weight 联合支付模式")
|
||||
//联合支付-------------------------------------------
|
||||
//0-即放即取,1-余量计量
|
||||
val mealPickupMode = SPUtil.getInstance().get(GlobalKey.KEY_PICKUP_MODE, 0) ?: 0
|
||||
@@ -387,36 +400,46 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
||||
}
|
||||
|
||||
private fun recognizeByWeight(weight: Int, isWeightChange: Boolean, block: () -> Unit = {}) {
|
||||
log("registerDataChange weight 开始识别")
|
||||
if (weight != lastWeight) {
|
||||
val payTypeDesc = if (settlementMode == 0) "联合支付" else "独立支付"
|
||||
log("readWeight-${payTypeDesc},weight=$weight,lastWeight=$lastWeight,isWeightChange=$isWeightChange")
|
||||
log("registerDataChange weight readWeight-${payTypeDesc},weight=$weight,lastWeight=$lastWeight,isWeightChange=$isWeightChange")
|
||||
}
|
||||
presentation?.updateWeight(weight)
|
||||
|
||||
if (weight <= WEIGHT_RESET_RECOGNIZE) {
|
||||
log("recognizeByWeight---00002,秤重未超过${WEIGHT_RESET_RECOGNIZE}克")
|
||||
log("registerDataChange weight recognizeByWeight---00002,秤重未超过${WEIGHT_RESET_RECOGNIZE}克")
|
||||
//检测到秤上没有东西,重新启动识别菜品 && presentation?.mealPickupMode == 1
|
||||
isRecognitionFood = true
|
||||
return
|
||||
}
|
||||
|
||||
if (isWeightChange && isRecognitionFood) {
|
||||
log("recognizeByWeight---00003,mealPickupMode=${presentation?.mealPickupMode}")
|
||||
log("registerDataChange weight recognizeByWeight---00003,mealPickupMode=${presentation?.mealPickupMode}")
|
||||
if (presentation?.mealPickupMode == 1 && checkedItem != null) {
|
||||
isRecognitionFood = false
|
||||
return
|
||||
}
|
||||
debouncer.debounce {
|
||||
log("recognizeByWeight---00004")
|
||||
log("registerDataChange weight recognizeByWeight---00004--recognizeFood")
|
||||
recognizeFood()
|
||||
if (presentation?.mealPickupMode == 0) {
|
||||
log("registerDataChange weight recognizeByWeight---00004--recognizeFood,mealPickupMode == 0")
|
||||
lastWeight = weight
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log("registerDataChange weight recognizeByWeight---block")
|
||||
block()
|
||||
}
|
||||
if (presentation?.mealPickupMode == 1 || settlementMode == 0) {
|
||||
log("registerDataChange weight recognizeByWeight---lastWeight=${lastWeight}, weight=${weight}, checkedItem=${checkedItem}")
|
||||
if (weight - lastWeight > WEIGHT_CHANGE_VALUE && checkedItem == null) {
|
||||
debouncer.debounce {
|
||||
log("registerDataChange weight重新进行菜品识别 ")
|
||||
recognizeFood()
|
||||
}
|
||||
}
|
||||
lastWeight = weight
|
||||
}
|
||||
}
|
||||
@@ -679,6 +702,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
||||
|
||||
binding.previewView.visible()
|
||||
binding.ivImg.gone()
|
||||
checkedItem = null
|
||||
}
|
||||
|
||||
private fun updateDateTime() {
|
||||
|
||||
Reference in New Issue
Block a user