feat(model): 更新货柜初始化结果和净菜包选项数据结构
- 在 CabinetInitResult 中添加 horizontalRows 和 verticalCount 字段 - 为 CleanPackageOption 和 MealPackageOption 添加 orderNo、foodId、needCount、needQtyKg 等字段 - 修改 CleanPackageOption 的 itemType 为 1,MealPackageOption 的 itemType 为 2 - 在 ShelfModelV2 中添加 cleanOrderNo 字段用于关联净菜订单号 - 更新 SyncItem 数据结构,添加 cleanOrderNo 字段 - 移除 HomeV2Activity 中的测试代码和硬编码逻辑 - 修改格口编号显示格式,补零显示两位数 - 调整定时任务执行频率,缩短同步间隔时间
This commit is contained in:
@@ -301,6 +301,7 @@ class HomeV2Activity : BaseActivity() {
|
||||
it.itemType = model.itemType
|
||||
it.itemName = model.itemName
|
||||
it.traceCode = model.traceCode
|
||||
it.cleanOrderNo = model.cleanOrderNo
|
||||
it.spec = model.spec
|
||||
it.foodId = model.foodId
|
||||
it.storeTime = model.storeTime
|
||||
@@ -350,7 +351,7 @@ class HomeV2Activity : BaseActivity() {
|
||||
it.tvEmptyContent.setTextColor(Color.WHITE)
|
||||
}
|
||||
|
||||
loadTestData()
|
||||
// loadTestData()
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
@@ -384,7 +385,8 @@ class HomeV2Activity : BaseActivity() {
|
||||
*/
|
||||
private fun saveGoodsTask() {
|
||||
saveTaskJob =
|
||||
taskExecutor.startIntervalTaskWithInitialDelay(1 * 60 * 1000L, 5 * 60 * 1000L) {
|
||||
// taskExecutor.startIntervalTaskWithInitialDelay(1 * 60 * 1000L, 5 * 60 * 1000L) {
|
||||
taskExecutor.startIntervalTaskWithInitialDelay(10 * 1000L, 5 * 1000L) {
|
||||
syncShelfGoodsToServer()
|
||||
}
|
||||
}
|
||||
@@ -425,10 +427,11 @@ class HomeV2Activity : BaseActivity() {
|
||||
return
|
||||
}
|
||||
viewModelV2.syncCabinetData(SyncBody().apply {
|
||||
cabinetId = list[0].cabinetId
|
||||
// cabinetId = list[0].cabinetId
|
||||
cabinetId = App.deviceId
|
||||
temperature = null
|
||||
humidity = null
|
||||
goodsList = cabinetInitResult!!.containerGoodsList
|
||||
goodsList = list
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ class ShelfV2Adapter(list: MutableList<ShelfModelV2>) :
|
||||
val binding = holder.binding
|
||||
|
||||
// 格口编号
|
||||
binding.tvShelfName.text = item.slotNo
|
||||
binding.tvShelfName.text = item.slotNo?.padStart(2,'0')
|
||||
|
||||
// 临期预警(slotStatus=2)显示过期图标
|
||||
if (item.slotStatus.toInt() == 2) binding.ivStaleFood.visible()
|
||||
|
||||
@@ -8,5 +8,7 @@ data class CabinetInitResult(
|
||||
val canteenName: String = "",
|
||||
val deviceName: String = "",
|
||||
val area: String = "",
|
||||
val horizontalRows:Int = 0,
|
||||
val verticalCount:Int = 0,
|
||||
val containerGoodsList: List<ShelfModelV2>? = null,
|
||||
)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.shuwei.intelligent.shelves.model
|
||||
|
||||
import com.shuwei.intelligent.shelves.utils.DateTimeUtil
|
||||
import java.math.BigDecimal
|
||||
import java.util.Date
|
||||
|
||||
/**
|
||||
@@ -8,20 +9,27 @@ import java.util.Date
|
||||
*/
|
||||
data class CleanPackageOption(
|
||||
val id: Long = 0,
|
||||
val batchNo: String = "",
|
||||
val itemName: String = "",
|
||||
/** 净菜订单号,sync 时作为 cleanOrderNo 回传 */
|
||||
val orderNo: String = "",
|
||||
val packageSpec: String? = null,
|
||||
val traceCode: String? = null,
|
||||
val spec: String? = null,
|
||||
/** 关联菜品 id */
|
||||
val foodId: Long? = null,
|
||||
/** 需求份数 */
|
||||
val needCount: Int? = null,
|
||||
/** 需求计量(kg) */
|
||||
val needQtyKg: BigDecimal? = null,
|
||||
/** 保质期至,格式 yyyy-MM-dd */
|
||||
val expiryDate: String? = null,
|
||||
var isSelected: Boolean = false
|
||||
) {
|
||||
/** 将净菜包选项转换为格口记录 */
|
||||
fun toShelfModelV2(model: ShelfModelV2? = null) = (model ?: ShelfModelV2()).also {
|
||||
it.itemType = 2
|
||||
it.itemType = 1
|
||||
it.itemName = itemName
|
||||
it.traceCode = traceCode
|
||||
it.cleanOrderNo = orderNo
|
||||
it.spec = packageSpec
|
||||
it.foodId = foodId
|
||||
it.storeTime = DateTimeUtil.formatDateTime(dateTime = Date())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.shuwei.intelligent.shelves.model
|
||||
|
||||
import com.shuwei.intelligent.shelves.utils.DateTimeUtil
|
||||
import java.math.BigDecimal
|
||||
import java.util.Date
|
||||
|
||||
/**
|
||||
@@ -8,21 +9,25 @@ import java.util.Date
|
||||
*/
|
||||
data class MealPackageOption(
|
||||
val id: Long = 0,
|
||||
val batchNo: String = "",
|
||||
val itemName: String = "",
|
||||
/** 净菜订单号,sync 时作为 cleanOrderNo 回传 */
|
||||
val orderNo: String = "",
|
||||
val packageSpec: String? = null,
|
||||
val traceCode: String? = null,
|
||||
//格式 `yyyy-MM-dd`(包装完成后有值)
|
||||
val expiryDate: String? = null,
|
||||
/** 关联菜品 id */
|
||||
val foodId: Long? = null,
|
||||
/** 需求份数 */
|
||||
val needCount: Int? = null,
|
||||
/** 需求计量(kg) */
|
||||
val needQtyKg: BigDecimal? = null,
|
||||
/** 保质期至,格式 yyyy-MM-dd(包装完成后有值) */
|
||||
val expiryDate: String? = null,
|
||||
var isSelected: Boolean = false
|
||||
) {
|
||||
/** 将餐品净菜包选项转换为格口记录 */
|
||||
fun toShelfModelV2(model: ShelfModelV2? = null) = (model ?: ShelfModelV2()).also {
|
||||
it.itemType = 1
|
||||
it.itemType = 2
|
||||
it.itemName = itemName
|
||||
it.traceCode = traceCode
|
||||
it.cleanOrderNo = orderNo
|
||||
it.spec = packageSpec
|
||||
it.foodId = foodId
|
||||
it.storeTime = DateTimeUtil.formatDateTime(dateTime = Date())
|
||||
|
||||
@@ -19,6 +19,8 @@ data class ShelfModelV2(
|
||||
var area: String = "",
|
||||
/** 溯源码 */
|
||||
var traceCode: String? = "",
|
||||
/** 关联净菜订单号 */
|
||||
var cleanOrderNo: String? = "",
|
||||
/** 物料名称 */
|
||||
var itemName: String? = "",
|
||||
/** 订单量 kg(itemType=1) */
|
||||
|
||||
@@ -1,34 +1,35 @@
|
||||
//package com.shuwei.intelligent.shelves.model
|
||||
//
|
||||
//import java.math.BigDecimal
|
||||
//
|
||||
///**
|
||||
// * 全量同步单格口数据,对应接口 4.3 goodsList 元素
|
||||
// */
|
||||
//data class SyncItem(
|
||||
// val slotNo: String,
|
||||
// /** 类型:1-食材净菜 / 2-餐品净菜包 */
|
||||
// val itemType: Short? = null,
|
||||
// val itemName: String? = null,
|
||||
// val traceCode: String? = null,
|
||||
// /** 绑定菜品 id(itemType=2) */
|
||||
// val foodId: Long? = null,
|
||||
// /** 订单量 kg(itemType=1) */
|
||||
// val orderQty: BigDecimal? = null,
|
||||
// /** 实收量 kg(itemType=1,与 totalWeightG 二选一) */
|
||||
// val actualQty: BigDecimal? = null,
|
||||
// /** 总重量 g(itemType=2,后端自动换算为 kg 存储) */
|
||||
// val totalWeightG: BigDecimal? = null,
|
||||
// /** 规格:1-标准份 / 2-大份 / 3-小份(itemType=2) */
|
||||
// val spec: Int? = null,
|
||||
// val pkgCount: Int? = null,
|
||||
// /** 验收结果:1-合格 / 2-轻微差异 / 3-不合格 / 4-待验 */
|
||||
// val checkResult: Short? = null,
|
||||
// /** 格口状态:1-存放中 / 2-临期预警 / 3-温度超标 / 4-空置 / 5-异常 */
|
||||
// val slotStatus: Short? = null,
|
||||
// /** 剩余保质期(小时) */
|
||||
// val shelfLifeRemain: Int? = null,
|
||||
// /** 存入时间,仅新增时生效,不传则取当前时间 */
|
||||
// val storeTime: String? = null,
|
||||
// val remark: String? = null,
|
||||
//)
|
||||
package com.shuwei.intelligent.shelves.model
|
||||
|
||||
import java.math.BigDecimal
|
||||
|
||||
/**
|
||||
* 全量同步单格口数据,对应接口 4.3 goodsList 元素
|
||||
*/
|
||||
data class SyncItem(
|
||||
val slotNo: String,
|
||||
/** 类型:1-食材净菜 / 2-餐品净菜包 */
|
||||
val itemType: Short? = null,
|
||||
val itemName: String? = null,
|
||||
/** 关联净菜订单号(从下拉选项 orderNo 取值回传) */
|
||||
val cleanOrderNo: String? = null,
|
||||
/** 绑定菜品 id(itemType=2) */
|
||||
val foodId: Long? = null,
|
||||
/** 订单量 kg(itemType=1) */
|
||||
val orderQty: BigDecimal? = null,
|
||||
/** 实收量 kg(itemType=1,与 totalWeightG 二选一) */
|
||||
val actualQty: BigDecimal? = null,
|
||||
/** 总重量 g(itemType=2,后端自动换算为 kg 存储) */
|
||||
val totalWeightG: BigDecimal? = null,
|
||||
/** 规格:1-标准份 / 2-大份 / 3-小份(itemType=2) */
|
||||
val spec: Int? = null,
|
||||
val pkgCount: Int? = null,
|
||||
/** 验收结果:1-合格 / 2-轻微差异 / 3-不合格 / 4-待验 */
|
||||
val checkResult: Short? = null,
|
||||
/** 格口状态:1-存放中 / 2-临期预警 / 3-温度超标 / 4-空置 / 5-异常 */
|
||||
val slotStatus: Short? = null,
|
||||
/** 剩余保质期(小时) */
|
||||
val shelfLifeRemain: Int? = null,
|
||||
/** 存入时间,仅新增时生效,不传则取当前时间 */
|
||||
val storeTime: String? = null,
|
||||
val remark: String? = null,
|
||||
)
|
||||
|
||||
@@ -144,7 +144,9 @@ object ProtocolConstants {
|
||||
//原410货柜
|
||||
"7a991439-3a12-3ef7-809b-c0258b839473",
|
||||
//原1楼餐厅货柜
|
||||
"4787e213-90ab-3e32-88e0-ac271a937751"
|
||||
"4787e213-90ab-3e32-88e0-ac271a937751",
|
||||
// TODO: 测试设备----------
|
||||
"2987f0c5-5754-33e9-b00a-251db5e2e55f"
|
||||
)
|
||||
|
||||
/**
|
||||
|
||||
@@ -47,10 +47,6 @@ object GridLayoutTool {
|
||||
|
||||
fun initListSortV2(source: List<ShelfModelV2>): List<ShelfModelV2> {
|
||||
val map = source.associateBy { it.slotNo?.toIntOrNull()?:0 }
|
||||
// TODO: 测试 ------------
|
||||
if ("2987f0c5-5754-33e9-b00a-251db5e2e55f" == App.deviceId) {
|
||||
return ProtocolConstants.device2ColumnsOrder.mapNotNull { map[it] }
|
||||
}
|
||||
return if (device3Columns.contains(App.deviceId)) {
|
||||
// 按全局定义的显示顺序取对应数据,找不到则跳过
|
||||
ProtocolConstants.device3ColumnsOrder.mapNotNull { map[it] }
|
||||
|
||||
Reference in New Issue
Block a user