餐盘柜优化-不绑定用户可多次取盘
This commit is contained in:
@@ -113,24 +113,14 @@ abstract class BaseActivity<VB : ViewBinding> : AppCompatActivity() {
|
||||
if (scanInfo.length > 6) {
|
||||
plateNumber = scanInfo.take(6)
|
||||
}
|
||||
// ToastUtils.showToast(plateNumber)
|
||||
var item = MyApp.plateList?.firstOrNull { it.plateNumber == plateNumber }
|
||||
//柜子未关联该餐盘,直接找空位置放入盘子
|
||||
val item = MyApp.plateList?.firstOrNull { it.plateNumber.isNullOrBlank() }
|
||||
if (item == null) {
|
||||
//柜子未关联该餐盘,直接找空位置放入盘子
|
||||
item = MyApp.plateList?.firstOrNull { it.plateNumber.isNullOrBlank() }
|
||||
if (item ==null) {
|
||||
//柜子已满
|
||||
MainActivity.start(context = context, pageType = PageType.PLATE_CABINET_FULL)
|
||||
return
|
||||
}
|
||||
//找到位置,放入餐盘,清除已有id和时间
|
||||
item.plateNumber = plateNumber
|
||||
item.faceId = null
|
||||
item.updateTime = null
|
||||
PlateUtils.open(this, item.equipmentBoxCode, true)
|
||||
//柜子已满
|
||||
MainActivity.start(context = context, pageType = PageType.PLATE_CABINET_FULL)
|
||||
return
|
||||
}
|
||||
//放入餐盘,清除已有id和时间
|
||||
//找到位置,放入餐盘,清除已有id和时间
|
||||
item.plateNumber = plateNumber
|
||||
item.faceId = null
|
||||
item.updateTime = null
|
||||
@@ -270,7 +260,9 @@ abstract class BaseActivity<VB : ViewBinding> : AppCompatActivity() {
|
||||
runOnUiThread {
|
||||
hideWaitingDialog()
|
||||
val view = View.inflate(this, R.layout.dialog_waiting, null)
|
||||
if (!TextUtils.isEmpty(tip)) (view.findViewById<View?>(R.id.tvTip) as TextView).setText(tip)
|
||||
if (!TextUtils.isEmpty(tip)) (view.findViewById<View?>(R.id.tvTip) as TextView).setText(
|
||||
tip
|
||||
)
|
||||
mDialogWaiting = CustomLoadingDialog(this, view, R.style.MyDialog)
|
||||
mDialogWaiting!!.show()
|
||||
mDialogWaiting!!.setCancelable(true)
|
||||
|
||||
@@ -210,14 +210,14 @@ class LoginByFaceActivity : BaseActivity<ActivityLoginFaceBinding>(),
|
||||
Timber.i("recognizeUserId observe userId = ${result?.faceEntity?.userName}")
|
||||
currentUserId = result?.faceEntity?.userName
|
||||
// viewModel.getUserInfoById(memberId = userId)
|
||||
//ToastUtils.showToast(userId)
|
||||
// ToastUtils.showToast(currentUserId)
|
||||
// if (!currentUserId.isNullOrBlank()) {
|
||||
//// ToastUtils.showToast("您已采集过人脸信息")
|
||||
// return@Observer
|
||||
// }
|
||||
if (currentPlateInfo?.faceId == currentUserId) {
|
||||
return@Observer
|
||||
}
|
||||
// if (currentPlateInfo?.faceId == currentUserId) {
|
||||
// return@Observer
|
||||
// }
|
||||
openPlate(currentUserId)
|
||||
})
|
||||
|
||||
@@ -249,17 +249,8 @@ class LoginByFaceActivity : BaseActivity<ActivityLoginFaceBinding>(),
|
||||
Log.d(TAG, "openPlate: userId=$userId")
|
||||
getPlateData { items ->
|
||||
Log.d(TAG, "openPlate: items:${Gson().toJson(items)}")
|
||||
var item = items.firstOrNull { it.faceId == userId }
|
||||
Log.d(TAG, "openPlate: item1:${item}")
|
||||
if (item != null) {
|
||||
//餐盘已取
|
||||
ToastUtils.showToast("您已拿过餐盘!")
|
||||
return@getPlateData
|
||||
}
|
||||
// 未查询到当前用户,查询第一个未绑定的餐盘
|
||||
item = items.firstOrNull {
|
||||
it.plateNumber.isNullOrEmpty().not() && it.faceId.isNullOrBlank()
|
||||
}
|
||||
val item = items.firstOrNull { it.plateNumber.isNullOrEmpty().not() }
|
||||
Log.d(TAG, "openPlate: item2:${item}")
|
||||
if (item == null) {
|
||||
//暂无餐盘
|
||||
@@ -269,6 +260,7 @@ class LoginByFaceActivity : BaseActivity<ActivityLoginFaceBinding>(),
|
||||
Log.d(TAG, "openPlate: item3:${item}")
|
||||
item.faceId = userId
|
||||
item.updateTime = DateTimeUtils.getDateTimeString()
|
||||
item.plateNumber = null
|
||||
//打开柜子
|
||||
PlateUtils.open(this, item.equipmentBoxCode, false)
|
||||
|
||||
@@ -548,7 +540,6 @@ class LoginByFaceActivity : BaseActivity<ActivityLoginFaceBinding>(),
|
||||
|
||||
private fun pauseCamera() {
|
||||
isRecognition = false
|
||||
|
||||
recognizeViewModel.onPreviewFrame(ByteArray(1382400), true)
|
||||
}
|
||||
|
||||
|
||||
@@ -126,24 +126,24 @@ class SettingListFragment :
|
||||
item: EquipmentUserInfo,
|
||||
position: Int
|
||||
) {
|
||||
if (item.isPlaceholder()) {
|
||||
this.llRoot.isVisible = false
|
||||
return
|
||||
}
|
||||
// if (item.isPlaceholder()) {
|
||||
// this.llRoot.isVisible = false
|
||||
// return
|
||||
// }
|
||||
this.llRoot.isVisible = true
|
||||
this.tvNum.text = formatNumber(item.equipmentBoxCode ?: "")
|
||||
if (item.isBound()) {
|
||||
val date = DateTimeUtils.parseDateTime(item.updateTime)
|
||||
val timeInMillis = date?.time ?: 0L
|
||||
val isOldTime = DateTimeUtils.isMoreThanHoursFromNow(timeInMillis)
|
||||
if (item.plateNumber.isNullOrBlank().not()) {
|
||||
// val date = DateTimeUtils.parseDateTime(item.updateTime)
|
||||
// val timeInMillis = date?.time ?: 0L
|
||||
// val isOldTime = DateTimeUtils.isMoreThanHoursFromNow(timeInMillis)
|
||||
|
||||
this.llRoot.setBackgroundResource(R.drawable.grid_item_bind)
|
||||
this.tvNum.setTextColor(resources.getColor(R.color.bind_4E535D))
|
||||
this.tvLastTime.setTextColor(
|
||||
if (isOldTime) resources.getColor(R.color.bind_time_old) else resources.getColor(
|
||||
R.color.bind_585868
|
||||
)
|
||||
)
|
||||
// this.tvLastTime.setTextColor(
|
||||
// if (isOldTime) resources.getColor(R.color.bind_time_old) else resources.getColor(
|
||||
// R.color.bind_585868
|
||||
// )
|
||||
// )
|
||||
this.llOpen.setBackgroundResource(R.drawable.grid_button_bind)
|
||||
this.tvOpen.setTextColor(resources.getColor(R.color.bind_FFCC99))
|
||||
this.llBindInfo.visibility = View.VISIBLE
|
||||
@@ -152,7 +152,7 @@ class SettingListFragment :
|
||||
// this.tvName.text = item.name.maskName()
|
||||
this.tvName.text = item.plateNumber
|
||||
|
||||
this.tvLastTime.text = DateTimeUtils.getTimeAgo(date)
|
||||
// this.tvLastTime.text = DateTimeUtils.getTimeAgo(date)
|
||||
} else {
|
||||
this.llRoot.setBackgroundResource(R.drawable.grid_item_unbind)
|
||||
this.tvNum.setTextColor(resources.getColor(R.color.bind_FFCC99))
|
||||
@@ -160,7 +160,7 @@ class SettingListFragment :
|
||||
this.tvOpen.setTextColor(resources.getColor(R.color.unbind_32283C))
|
||||
this.llBindInfo.visibility = View.GONE
|
||||
this.tvUnbind.visibility = View.VISIBLE
|
||||
this.tvUnbind.text = if (item.plateNumber.isNullOrBlank()) "未绑定" else "未绑定(${item.plateNumber})"
|
||||
// this.tvUnbind.text = "未绑定"
|
||||
}
|
||||
// this.llRoot.setOnClickListener {
|
||||
//// Timber.d("itemClick llRoot ${item.name}, position = $position")
|
||||
|
||||
@@ -66,12 +66,12 @@ data class EquipmentUserInfo(
|
||||
// var isIntercept: Boolean = false
|
||||
) : Parcelable {
|
||||
|
||||
/**
|
||||
* 是否已绑定
|
||||
*/
|
||||
fun isBound(): Boolean {
|
||||
return faceId.isNullOrBlank().not()
|
||||
}
|
||||
// /**
|
||||
// * 是否已绑定
|
||||
// */
|
||||
// fun isBound(): Boolean {
|
||||
// return faceId.isNullOrBlank().not()
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * 是否是其他设备
|
||||
@@ -80,11 +80,11 @@ data class EquipmentUserInfo(
|
||||
// return equipmentCode != null && equipmentCode != "" && GlobalData.globalEquipmentCode != equipmentCode
|
||||
// }
|
||||
|
||||
fun hasEquipmentBox(): Boolean {
|
||||
return !TextUtils.isEmpty(equipmentBoxCode)
|
||||
}
|
||||
|
||||
fun isPlaceholder(): Boolean {
|
||||
return equipmentBoxCode.isNullOrBlank()
|
||||
}
|
||||
// fun hasEquipmentBox(): Boolean {
|
||||
// return !TextUtils.isEmpty(equipmentBoxCode)
|
||||
// }
|
||||
//
|
||||
// fun isPlaceholder(): Boolean {
|
||||
// return equipmentBoxCode.isNullOrBlank()
|
||||
// }
|
||||
}
|
||||
Reference in New Issue
Block a user