设备联调优化
This commit is contained in:
@@ -54,7 +54,7 @@ class ShelfActivity : BaseActivity() {
|
||||
companion object {
|
||||
private const val TAG = "ShelfActivity"
|
||||
|
||||
private const val YYYY_MM_DD__EEEE_HH_MM_SS = "yyyy年MM月dd日 EEEE***HH:mm:ss"
|
||||
const val YYYY_MM_DD__EEEE_HH_MM_SS = "yyyy年MM月dd日 EEEE***HH:mm:ss"
|
||||
const val SHELF_MODEL = "shelfModel"
|
||||
const val RECEIVER_DEVICE_INFO = "receiverDeviceInfo"
|
||||
const val SHELF_WEIGHT = "shelfWeight"
|
||||
@@ -90,9 +90,9 @@ class ShelfActivity : BaseActivity() {
|
||||
shelfModel?.let {
|
||||
binding.tvShelfName.text = it.shelfName
|
||||
binding.tvFoodName.text = if (it.goodsName.isNullOrBlank()) "-" else it.goodsName
|
||||
realWeight = ((it.weight ?: 0.0) * 1000).toInt()
|
||||
// realWeight = (HomeActivity.getRealWeight() * 1000).toInt()
|
||||
binding.tvFoodWeight.text = "${realWeight}克"
|
||||
realWeight = it.weight?.toInt()?:0
|
||||
binding.tvFoodWeight.text = if(realWeight < 1000) "${realWeight}克" else "%.3f千克".format(realWeight/1000.0)
|
||||
startTime = System.currentTimeMillis()
|
||||
}
|
||||
|
||||
initRecyclerView()
|
||||
@@ -125,7 +125,7 @@ class ShelfActivity : BaseActivity() {
|
||||
shelfName = shelfModel?.shelfName,
|
||||
goodsId = currentGoodsId,
|
||||
goodsName = list[clickIndex].goodsName,
|
||||
weight = realWeight / 1000.0,
|
||||
weight = realWeight.toDouble(),
|
||||
overdueDay = list[clickIndex].overdueDay,
|
||||
// createTime = if (shelfModel?.goodsId == currentGoodsId) null else DateTimeUtil.formatDateTime(dateTime = Date())
|
||||
createTime = DateTimeUtil.formatDateTime(dateTime = Date())
|
||||
@@ -142,11 +142,12 @@ class ShelfActivity : BaseActivity() {
|
||||
binding.btnClearZero.setOnClickListener {
|
||||
clearZero()
|
||||
}
|
||||
binding.btnClearEmpty?.setOnClickListener {
|
||||
binding.btnClearEmpty.setOnClickListener {
|
||||
val tempWeight = shelfModel?.weight?.toInt()?:0
|
||||
clearZero()
|
||||
binding.tvFoodName.text = "-"
|
||||
binding.tvFoodWeight.text = "0克"
|
||||
EventBus.getDefault().post(ClearShelfEvent(shelfModel!!.deviceNo))
|
||||
//binding.tvFoodWeight.text = "0克"
|
||||
EventBus.getDefault().post(ClearShelfEvent(shelfModel!!.deviceNo, tempWeight))
|
||||
}
|
||||
lifecycleScope.launch {
|
||||
SerialPortManager.send(DEVICE_INFO_CMD)
|
||||
@@ -358,7 +359,12 @@ class ShelfActivity : BaseActivity() {
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public fun receiveWeightEvent(event: SendWeightEvent) {
|
||||
if (event.shelfNo == (shelfModel?.deviceNo ?: 0)) {
|
||||
binding.tvFoodWeight.text = "${event.weight}克"
|
||||
val intervalTime = System.currentTimeMillis() - startTime
|
||||
Log.d(TAG, "receiveWeightEvent: ${event.shelfNo}号货架重量数据获取间隔时间为:$intervalTime")
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -375,10 +381,11 @@ class ShelfActivity : BaseActivity() {
|
||||
// binding.tvFoodWeight.text = "${realWeight}克"
|
||||
|
||||
SerialPortManager.send(DEVICE_INFO_CMD)
|
||||
startTime = System.currentTimeMillis()
|
||||
Loading.show(this@ShelfActivity)
|
||||
window.decorView.postDelayed({ Loading.dismiss() }, 5000)
|
||||
// window.decorView.postDelayed({ Loading.dismiss() }, 5000)
|
||||
}
|
||||
KeyboardUtil.hideKeyboard(window.decorView)
|
||||
}
|
||||
|
||||
private var startTime = 0L
|
||||
}
|
||||
Reference in New Issue
Block a user