feat(match): 添加烹饪开始时间和调料首次使用时间功能
- 在CookCompleteRequest中新增cookStart字段记录烹饪开始时间 - 在CookCompleteItem中新增putTime字段记录调料首次使用时间 - SubmitFoodActivity中初始化cookStartTime为进入页面时刻 - 记录调料首次拿取时间,存入seasoningFirstUseMap - 提交接口时按调料名称匹配首次使用时间填充putTime字段
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
|
||||
plugins {
|
||||
// alias(libs.plugins.android.application)
|
||||
// alias(libs.plugins.kotlin.android)
|
||||
@@ -25,7 +24,7 @@ android {
|
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
ndk {
|
||||
//设置支持的SO库架构;x86_64 仅用于在 Windows 模拟器上调试(秤功能不可用)
|
||||
abiFilters.addAll(listOf("armeabi-v7a", "x86_64"))
|
||||
abiFilters.addAll(listOf("armeabi-v7a"))
|
||||
}
|
||||
|
||||
// 设置输出APK文件名格式
|
||||
@@ -139,8 +138,8 @@ dependencies {
|
||||
implementation(libs.androidx.camera.extensions)
|
||||
|
||||
//pytorch
|
||||
implementation (libs.pytorch.android)
|
||||
implementation (libs.pytorch.android.torchvision)
|
||||
implementation(libs.pytorch.android)
|
||||
implementation(libs.pytorch.android.torchvision)
|
||||
|
||||
// objectbox
|
||||
if (isDebug) {
|
||||
|
||||
@@ -123,7 +123,9 @@ data class CookCompleteItem(
|
||||
/** 食材id */
|
||||
val materId: String = "",
|
||||
/** 实际用量(g) */
|
||||
val actualQty: Double = 0.0
|
||||
val actualQty: Double = 0.0,
|
||||
/** 调料首次使用时间 yyyy-MM-dd HH:mm:ss,仅调料需要,主辅材留空 */
|
||||
val putTime: String? = null
|
||||
)
|
||||
|
||||
/**
|
||||
@@ -133,6 +135,8 @@ data class CookCompleteItem(
|
||||
data class CookCompleteRequest(
|
||||
/** 烹制单id */
|
||||
val cookOrderId: String = "",
|
||||
/** 烹饪开始时间 yyyy-MM-dd HH:mm:ss,进入提交页面时刻 */
|
||||
val cookStart: String? = null,
|
||||
/** 主辅材实际用量列表,至少1条 */
|
||||
val items: List<CookCompleteItem> = emptyList(),
|
||||
/** 熟重(kg) */
|
||||
|
||||
@@ -29,6 +29,7 @@ import com.shuwei.dish.match.net.UiState
|
||||
import com.shuwei.dish.match.scale.ScaleDeviceConfig
|
||||
import com.shuwei.dish.match.scale.ScaleServiceManager
|
||||
import com.shuwei.dish.match.utils.AddressUtil
|
||||
import com.shuwei.dish.match.utils.DateTimeUtil
|
||||
import com.shuwei.dish.match.utils.WeightUtil
|
||||
import com.shuwei.dish.match.utils.ext.appendText
|
||||
import com.shuwei.dish.match.utils.ext.buildSpannableString
|
||||
@@ -40,6 +41,7 @@ import com.shuwei.dish.match.utils.ext.toJsonString
|
||||
import com.shuwei.dish.match.utils.ext.toast
|
||||
import com.shuwei.dish.match.utils.ext.visible
|
||||
import kotlinx.coroutines.launch
|
||||
import java.time.LocalDateTime
|
||||
|
||||
@SuppressLint("UseSparseArrays")
|
||||
class SubmitFoodActivity : BaseActivity() {
|
||||
@@ -111,6 +113,15 @@ class SubmitFoodActivity : BaseActivity() {
|
||||
/** 主设备 2格秤的初始重量,首次收到数据时赋值;调用清零后重置为 0.0 */
|
||||
private var initWeight: Double = 0.0
|
||||
|
||||
/** 烹饪开始时间(进入本页面的时刻),提交烹饪完成接口时上报 */
|
||||
private var cookStartTime: String = ""
|
||||
|
||||
/**
|
||||
* 调料首次使用时间,key = goodsName,value = 首次拿取时间 yyyy-MM-dd HH:mm:ss
|
||||
* 秤首次检测到拿取(用量超阈值)时记录,提交时按 goodsName 匹配填入 putTime
|
||||
*/
|
||||
private val seasoningFirstUseMap = mutableMapOf<String, String>()
|
||||
|
||||
/** initWeight 是否已完成初始化 */
|
||||
// private var initWeightSet: Boolean = false
|
||||
|
||||
@@ -119,6 +130,8 @@ class SubmitFoodActivity : BaseActivity() {
|
||||
super.onCreate(savedInstanceState)
|
||||
binding = ActivitySubmitFoodBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
// 以进入本页面的时刻作为烹饪开始时间
|
||||
cookStartTime = DateTimeUtil.formatDateTime(LocalDateTime.now())
|
||||
setHeaderBackground()
|
||||
intent.extras?.apply {
|
||||
food = getSerializable(FOOD_ITEM) as FoodRecord?
|
||||
@@ -280,6 +293,11 @@ class SubmitFoodActivity : BaseActivity() {
|
||||
// 拿取场景:实时响应,无需等待稳定
|
||||
val newTriple = Triple(goodsId, goodsName, useWeight)
|
||||
if (rawWeightMap[key] != newTriple) {
|
||||
// 该调料首次检测到拿取时,记录首次使用时间(同名调料只记最早一次)
|
||||
if (!seasoningFirstUseMap.containsKey(goodsName)) {
|
||||
seasoningFirstUseMap[goodsName] =
|
||||
DateTimeUtil.formatDateTime(LocalDateTime.now())
|
||||
}
|
||||
Log.d(TAG, "observeScaleData,新增:$newTriple")
|
||||
rawWeightMap[key] = newTriple
|
||||
refreshAdapterByName(goodsName)
|
||||
@@ -480,12 +498,13 @@ class SubmitFoodActivity : BaseActivity() {
|
||||
return
|
||||
}
|
||||
|
||||
// 调料:materialType 3
|
||||
// 调料:materialType 3,按 goodsName 匹配首次使用时间填入 putTime
|
||||
val seasonings = allGoods
|
||||
.filter { it.materialType == 3 }
|
||||
.map { CookCompleteItem(
|
||||
materId = it.materId?.takeIf { mid -> mid.isNotEmpty() } ?: it.goodsId,
|
||||
actualQty = it.useWeight ?: 0.0
|
||||
actualQty = it.useWeight ?: 0.0,
|
||||
putTime = it.goodsName?.let { name -> seasoningFirstUseMap[name] }
|
||||
) }
|
||||
.takeIf { it.isNotEmpty() }
|
||||
|
||||
@@ -494,6 +513,7 @@ class SubmitFoodActivity : BaseActivity() {
|
||||
|
||||
val request = CookCompleteRequest(
|
||||
cookOrderId = cookOrderId ?: "",
|
||||
cookStart = cookStartTime,
|
||||
items = items,
|
||||
cookedWeight = cookedWeightKg,
|
||||
seasonings = seasonings
|
||||
|
||||
Reference in New Issue
Block a user