feat(ratio-scale): 新增烹饪时长采集及调料放置时间支持

- 配比秤采样提交接口新增字段 cookStart,传递烹饪开始时间
- 食材构成中调料项新增 putTime 字段,记录调料首次使用时间
- 设备端提交采样时食材构造调整,调料按名称匹配 putTime 填充
- 新增对烹饪时长的后端计算功能,时长单位为分钟自动向上取整
- 采样列表接口响应新增 cookStart 与 cookDuration 字段,用于显示烹饪时长
- 配比秤采样模式相关API文档同步更新,废弃制作模式接口及字段
- 烹饪完成接口要求强化传递 cookStart,后端基于此计算并更新烹饪时长
- 关联数据库迁移支持烹饪时长字段持久化及历史记录完善
This commit is contained in:
mazengfei
2026-09-21 14:21:17 +08:00
parent 7b66652c0b
commit 94bcdb3d9b
4 changed files with 295 additions and 426 deletions
@@ -130,7 +130,9 @@ data class ConstituteSaveItem(
/** 食材称量用量(g),必须 > 0 */
val useWeight: Double = 0.0,
/** 食材分类: 1=主材 / 2=辅材 / 3=调料 */
val isMain: Int = 0
val isMain: Int = 0,
/** 调料首次使用时间 yyyy-MM-dd HH:mm:ss,仅调料需要,主辅材留空;字段与制作模式 CookCompleteItem 对齐 */
val putTime: String? = null
)
/**
@@ -141,6 +143,8 @@ data class ConstituteSaveItem(
data class ConstituteSaveRequest(
/** 菜品名称 */
val foodName: String? = null,
/** 烹饪开始时间 yyyy-MM-dd HH:mm:ss,进入提交页面时刻;字段与制作模式 CookCompleteRequest 对齐 */
val cookStart: String? = null,
/** 熟重(g),必须 > 0 */
val foodWeight: Double = 0.0,
/** 食材构成列表,至少 1 条 */
@@ -174,6 +178,10 @@ data class SampleHistoryItem(
val foodName: String = "",
/** 熟重(g) */
val foodWeight: Double = 0.0,
/** 烹饪开始时间,提交时未传则为 null */
val cookStart: String? = null,
/** 烹饪时长(分钟),后端按 提交时间-烹饪开始时间 向上取整计算;未传 cookStart 则为 null */
val cookDuration: Int? = null,
/** 状态: 1=实验中 / 2=已评测 / 9=已转化 */
val status: Int = 0,
/** 状态中文 */
@@ -563,13 +563,17 @@ class SubmitFoodActivity : BaseActivity() {
}
// 仅保留用量 > 0 的食材;materId 优先取 materId,为空时回退 goodsId
// 调料(isMain=3)按 goodsName 匹配首次使用时间填入 putTime,主辅材留空
val items = allGoods
.filter { (it.useWeight ?: 0.0) > 0.0 }
.map {
ConstituteSaveItem(
materId = it.materId?.takeIf { mid -> mid.isNotEmpty() } ?: it.goodsId,
useWeight = it.useWeight ?: 0.0,
isMain = it.materialType
isMain = it.materialType,
putTime = if (it.materialType == 3) {
it.goodsName?.let { name -> seasoningFirstUseMap[name] }
} else null
)
}
if (items.isEmpty()) {
@@ -591,6 +595,7 @@ class SubmitFoodActivity : BaseActivity() {
val request = ConstituteSaveRequest(
foodName = foodName,
cookStart = cookStartTime,
foodWeight = foodWeight,
items = items
)