联调优化
This commit is contained in:
@@ -77,7 +77,7 @@ class HomeActivity : BaseActivity() {
|
||||
|
||||
const val DEVICE_INFO_CMD = "${HEADER}0301000000000000000000000000${FOOTER}"
|
||||
//const val START_CMD= "${HEADER}0F01360000${FOOTER}"
|
||||
const val START_CMD= "${HEADER}0F01050020${FOOTER}"
|
||||
//const val START_CMD= "${HEADER}0F01050020${FOOTER}"
|
||||
const val ACTIVE_CMD =
|
||||
"${HEADER}000281C5D70A7D428948AD7254FADBB1516738938B4B9CBD73673E9D8E7F2E15062D${FOOTER}"
|
||||
|
||||
@@ -112,7 +112,7 @@ class HomeActivity : BaseActivity() {
|
||||
setBackground()
|
||||
setContentView(binding.root)
|
||||
|
||||
updateLeftStatus("1-1冷藏柜 -°C / -%")
|
||||
updateLeftStatus("-°C / -%")
|
||||
|
||||
initRecyclerView()
|
||||
|
||||
@@ -226,6 +226,7 @@ class HomeActivity : BaseActivity() {
|
||||
loadEmptyView()
|
||||
return
|
||||
}
|
||||
deviceName = data.data.deviceName
|
||||
App.canteenId = data.data.placeId
|
||||
val tempList = data.data.containerGoodsList
|
||||
if (tempList.isNullOrEmpty()) {
|
||||
@@ -301,8 +302,12 @@ class HomeActivity : BaseActivity() {
|
||||
//获取设备状态
|
||||
getDeviceInfo(data)
|
||||
}
|
||||
"1001","1002" -> {
|
||||
"1001" -> {
|
||||
Log.d(TAG, "receiveSerialPortData,温控信息上报数据:${data}")
|
||||
runOnUiThread { toast("温控信息上报数据:${data}") }
|
||||
}
|
||||
"1002" -> {
|
||||
Log.d(TAG, "receiveSerialPortData,温控信息上报1002数据:${data}")
|
||||
}
|
||||
"0F02" -> {
|
||||
Log.d(TAG, "receiveSerialPortData,温控信息应答数据:${data}")
|
||||
@@ -358,14 +363,16 @@ class HomeActivity : BaseActivity() {
|
||||
val tempC = f2C(temperature.toDouble())
|
||||
showTemperatureC = "%.1f".format(tempC)
|
||||
|
||||
val percent = 10 * list.count { it.goodsName.isNullOrBlank().not() }
|
||||
//val percent = 10 * list.count { it.goodsName.isNullOrBlank().not() }
|
||||
|
||||
updateLeftStatus("1-1冷藏柜 [$temperatureHex] ${showTemperatureC}°C / ${percent}%")
|
||||
updateLeftStatus("${deviceName} [$temperatureHex] ${showTemperatureC}°C / -%")
|
||||
}.onFailure {
|
||||
it.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
private var deviceName = ""
|
||||
|
||||
private fun getWeightInfo(start: Int, end: Int, data: String) {
|
||||
var index = 1
|
||||
var count = start
|
||||
@@ -416,14 +423,19 @@ class HomeActivity : BaseActivity() {
|
||||
val weightStartIndex = HEADER.length + 14
|
||||
val temperatureStartIndex = weightStartIndex + 12 * 8
|
||||
val temperatureEndIndex = temperatureStartIndex + 2
|
||||
val temperatureHex = data.substring(temperatureStartIndex, temperatureEndIndex)
|
||||
val temperatureHex = try {
|
||||
data.substring(temperatureStartIndex, temperatureEndIndex)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
return
|
||||
}
|
||||
val temperature = hexToDec(temperatureHex)
|
||||
val tempC = f2C(temperature.toDouble())
|
||||
showTemperatureC = "%.1f".format(tempC)
|
||||
|
||||
val percent = 10 * list.count { it.goodsName.isNullOrBlank().not() }
|
||||
//val percent = 10 * list.count { it.goodsName.isNullOrBlank().not() }
|
||||
|
||||
updateLeftStatus("1-1冷藏柜 ${showTemperatureC}°C / ${percent}%")
|
||||
updateLeftStatus("${deviceName} ${showTemperatureC}°C / -%")
|
||||
|
||||
getWeightInfo(
|
||||
start = weightStartIndex,
|
||||
@@ -467,8 +479,8 @@ class HomeActivity : BaseActivity() {
|
||||
goodsId = model.goodsId
|
||||
goodsName = model.goodsName
|
||||
weight = model.weight
|
||||
if (model.createTime.isNullOrBlank().not()) {
|
||||
createTime = model.createTime
|
||||
if (model.putCabinetDay.isNullOrBlank().not()) {
|
||||
putCabinetDay = model.putCabinetDay
|
||||
}
|
||||
}
|
||||
notifyItemChanged(position)
|
||||
@@ -545,7 +557,8 @@ class HomeActivity : BaseActivity() {
|
||||
binding.include?.let {
|
||||
it.root.visible()
|
||||
it.root.setOnClickListener {
|
||||
viewModel.getAccessToken(App.deviceId)
|
||||
//viewModel.getAccessToken(App.deviceId)
|
||||
viewModel.getShelfList(deviceId = App.deviceId)
|
||||
}
|
||||
it.ivEmptyIcon.setImageResource(R.drawable.ic_empty_white)
|
||||
it.tvEmptyContent.setTextColor(Color.WHITE)
|
||||
|
||||
@@ -26,6 +26,9 @@ class SettingActivity: BaseActivity() {
|
||||
if (cmd.isBlank()) {
|
||||
return@setOnClickListener
|
||||
}
|
||||
var record = binding.tvCmdRecord.text.toString().trim()
|
||||
record = cmd+"\n"+record
|
||||
binding.tvCmdRecord.text = record
|
||||
val realCmd = "${HomeActivity.HEADER}0F01${cmd}${HomeActivity.FOOTER}"
|
||||
lifecycleScope.launch {
|
||||
SerialPortManager.send(realCmd)
|
||||
|
||||
@@ -128,7 +128,7 @@ class ShelfActivity : BaseActivity() {
|
||||
weight = realWeight.toDouble(),
|
||||
overdueDay = list[clickIndex].overdueDay,
|
||||
// createTime = if (shelfModel?.goodsId == currentGoodsId) null else DateTimeUtil.formatDateTime(dateTime = Date())
|
||||
createTime = DateTimeUtil.formatDateTime(dateTime = Date())
|
||||
putCabinetDay = DateTimeUtil.formatDateTime(dateTime = Date())
|
||||
)
|
||||
val intent = Intent().apply {
|
||||
putExtra(SHELF_MODEL, data)
|
||||
@@ -364,7 +364,7 @@ class ShelfActivity : BaseActivity() {
|
||||
val weight = event.weight
|
||||
binding.tvFoodWeight.text = if(weight < 1000) "${weight}克" else "%.3f千克".format(weight/1000.0)
|
||||
startTime = System.currentTimeMillis()
|
||||
window.decorView.postDelayed({ Loading.dismiss() }, 1000)
|
||||
window.decorView.postDelayed({ Loading.dismiss() }, 2000)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -35,14 +35,15 @@ class ShelfAdapter(list: MutableList<ShelfModel>) :
|
||||
|
||||
override fun onBindViewHolder(holder: VH, position: Int, item: ShelfModel?) {
|
||||
val shelfNo = item!!.deviceNo
|
||||
item.shelfName = "货架-${if (shelfNo < 10) "0${shelfNo}" else "$shelfNo"}"
|
||||
//货架-
|
||||
item.shelfName = "${if (shelfNo < 10) "0${shelfNo}" else "$shelfNo"}"
|
||||
val weight = item.weight ?: 0.0
|
||||
val binding = holder.binding
|
||||
if (item.overdueDay.isNullOrBlank()) {
|
||||
binding.ivStaleFood.gone()
|
||||
} else {
|
||||
runCatching {
|
||||
val shelfDate = stringToDate(item.createTime)
|
||||
val shelfDate = stringToDate(item.putCabinetDay)
|
||||
if (shelfDate == null) {
|
||||
binding.ivStaleFood.gone()
|
||||
} else {
|
||||
@@ -103,7 +104,7 @@ class ShelfAdapter(list: MutableList<ShelfModel>) :
|
||||
// }
|
||||
binding.tvStoreDate.run {
|
||||
setTextColor(getColor(R.color.black999))
|
||||
text = item.createTime
|
||||
text = item.putCabinetDay
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,8 @@ data class ShelfModel(
|
||||
var weight: Double? = null,
|
||||
var weightBak: Double? = null,
|
||||
var createTime: String? = null,
|
||||
var putCabinetDay: String? = null,
|
||||
var updateTime: String? = null,
|
||||
var overdueDay: String? = null,
|
||||
var temperature: String? = null,
|
||||
var humidity: String = "0",
|
||||
|
||||
@@ -3,5 +3,6 @@ package com.shuwei.intelligent.shelves.model
|
||||
data class ShelfResult(
|
||||
val placeId: String = "",
|
||||
val canteenName: String = "",
|
||||
val deviceName: String = "",
|
||||
val containerGoodsList: List<ShelfModel>? = null
|
||||
)
|
||||
|
||||
@@ -49,11 +49,20 @@
|
||||
</FrameLayout>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/etInputCmd"
|
||||
android:id="@+id/etInputCmdPrefix"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="60dp"
|
||||
android:hint="请输入命令"
|
||||
android:maxLines="1"
|
||||
android:text=""
|
||||
android:textSize="22sp" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/etInputCmd"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="60dp"
|
||||
android:hint="请输入命令内容"
|
||||
android:maxLines="1"
|
||||
android:textSize="22sp" />
|
||||
|
||||
<Button
|
||||
@@ -66,6 +75,37 @@
|
||||
android:text="发送命令" />
|
||||
</LinearLayout>
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_marginStart="12dp"
|
||||
android:layout_marginTop="12dp"
|
||||
android:layout_marginEnd="12dp"
|
||||
android:layout_marginBottom="12dp"
|
||||
app:cardBackgroundColor="@color/white"
|
||||
app:cardCornerRadius="6dp"
|
||||
app:cardElevation="0dp">
|
||||
|
||||
<ScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:padding="10dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvCmdRecord"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:textSize="20sp"
|
||||
android:text=""/>
|
||||
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
||||
</LinearLayout>
|
||||
Reference in New Issue
Block a user