|
|
@@ -1,6 +1,5 @@
|
|
|
package com.grkj.iscs.features.main.fragment.hardware_manage
|
|
|
|
|
|
-import android.view.Gravity
|
|
|
import android.view.View
|
|
|
import androidx.core.view.isVisible
|
|
|
import androidx.fragment.app.viewModels
|
|
|
@@ -8,13 +7,13 @@ import com.drake.brv.BindingAdapter
|
|
|
import com.drake.brv.annotaion.DividerOrientation
|
|
|
import com.drake.brv.utils.dividerSpace
|
|
|
import com.drake.brv.utils.linear
|
|
|
-import com.drake.brv.utils.models
|
|
|
import com.drake.brv.utils.setup
|
|
|
import com.google.android.flexbox.AlignItems
|
|
|
import com.google.android.flexbox.FlexDirection
|
|
|
import com.google.android.flexbox.FlexboxLayoutManager
|
|
|
import com.google.android.flexbox.JustifyContent
|
|
|
import com.grkj.data.data.MainDomainData
|
|
|
+import com.grkj.data.enums.CommonDictDataEnum
|
|
|
import com.grkj.data.enums.RoleEnum
|
|
|
import com.grkj.iscs.R
|
|
|
import com.grkj.iscs.databinding.FragmentSlotsManageBinding
|
|
|
@@ -23,14 +22,17 @@ import com.grkj.iscs.databinding.ItemDeviceRegistrationLockLayoutBinding
|
|
|
import com.grkj.iscs.databinding.ItemDeviceSlotManageKeyBinding
|
|
|
import com.grkj.iscs.databinding.ItemDeviceSlotManageLockBinding
|
|
|
import com.grkj.iscs.features.init.model.DockData
|
|
|
+import com.grkj.iscs.features.main.dialog.hardware_manage.SlotsExceptionReportDialog
|
|
|
import com.grkj.iscs.features.main.viewmodel.hardware_manage.SlotsManageViewModel
|
|
|
import com.grkj.ui_base.base.BaseFragment
|
|
|
+import com.grkj.ui_base.config.ISCSConfig
|
|
|
import com.grkj.ui_base.dialog.TipDialog
|
|
|
+import com.grkj.ui_base.utils.event.LoadingEvent
|
|
|
import com.grkj.ui_base.utils.modbus.DeviceConst
|
|
|
import com.grkj.ui_base.utils.modbus.DockBean
|
|
|
import com.grkj.ui_base.utils.modbus.ModBusController
|
|
|
-import com.kongzue.dialogx.dialogs.PopMenu
|
|
|
import com.sik.sikcore.extension.setDebouncedClickListener
|
|
|
+import com.sik.sikcore.thread.ThreadUtils
|
|
|
import dagger.hilt.android.AndroidEntryPoint
|
|
|
|
|
|
/**
|
|
|
@@ -39,20 +41,7 @@ import dagger.hilt.android.AndroidEntryPoint
|
|
|
@AndroidEntryPoint
|
|
|
class SlotsManageFragment : BaseFragment<FragmentSlotsManageBinding>() {
|
|
|
private val viewModel: SlotsManageViewModel by viewModels()
|
|
|
- private val slotsLongClickMenu: List<String> by lazy {
|
|
|
- if (MainDomainData.roleKeys?.contains(RoleEnum.ADMIN.roleKey) == true ||
|
|
|
- MainDomainData.roleKeys?.contains(RoleEnum.SYSCONFIG.roleKey) == true
|
|
|
- ) {
|
|
|
- listOf(
|
|
|
- getString(com.grkj.ui_base.R.string.exception_report),
|
|
|
- getString(com.grkj.ui_base.R.string.turn_on),
|
|
|
- getString(com.grkj.ui_base.R.string.turn_off),
|
|
|
- getString(R.string.detect_slot)
|
|
|
- )
|
|
|
- } else {
|
|
|
- listOf(getString(com.grkj.ui_base.R.string.exception_report))
|
|
|
- }
|
|
|
- }
|
|
|
+ private val dockDataList = mutableListOf<DockData>()
|
|
|
|
|
|
override fun getLayoutId(): Int {
|
|
|
return R.layout.fragment_slots_manage
|
|
|
@@ -85,67 +74,122 @@ class SlotsManageFragment : BaseFragment<FragmentSlotsManageBinding>() {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
+ }.models = dockDataList
|
|
|
+ ModBusController.controlAllKeyChargeDown()
|
|
|
+ viewModel.isDestroy = false
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 显示长按菜单
|
|
|
*/
|
|
|
- private fun showLongClickMenu(v: View, deviceBean: DockBean.DeviceBean) {
|
|
|
- PopMenu.show(v, slotsLongClickMenu)
|
|
|
- .setAlignGravity(Gravity.BOTTOM or Gravity.CENTER_HORIZONTAL)
|
|
|
- .setOverlayBaseView(false)
|
|
|
- .setOnMenuItemClickListener { dialog, str, index ->
|
|
|
- when {
|
|
|
- //异常上报
|
|
|
- str.toString() == getString(com.grkj.ui_base.R.string.exception_report) -> {}
|
|
|
- //开
|
|
|
- str.toString() == getString(com.grkj.ui_base.R.string.turn_on) -> {
|
|
|
- when (deviceBean) {
|
|
|
- is DockBean.KeyBean -> {
|
|
|
- ModBusController.controlKeyCharge(
|
|
|
- true, deviceBean.idx,
|
|
|
- ModBusController.dockList.find { it.row == deviceBean.row }?.addr
|
|
|
- )
|
|
|
- }
|
|
|
+ private fun showLongClickMenu(v: View, deviceBean: DockBean.DeviceBean, modelPosition: Int) {
|
|
|
+ SlotsExceptionReportDialog.show(
|
|
|
+ requireContext(),
|
|
|
+ deviceBean.row,
|
|
|
+ modelPosition + 1,
|
|
|
+ deviceBean.type
|
|
|
+ ) {
|
|
|
+ viewModel.tagSlotsException(deviceBean.row, modelPosition + 1, it)
|
|
|
+ .observe(this) {
|
|
|
+ TipDialog.showSuccess(
|
|
|
+ msg = getString(R.string.exception_report_success),
|
|
|
+ onConfirmClick = {
|
|
|
+ binding.dockRv.adapter?.notifyDataSetChanged()
|
|
|
+ },
|
|
|
+ onCancelClick = {
|
|
|
+ binding.dockRv.adapter?.notifyDataSetChanged()
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- is DockBean.LockBean -> {
|
|
|
- ModBusController.controlLockBuckle(
|
|
|
- true,
|
|
|
- ModBusController.dockList.find { it.row == deviceBean.row }?.addr,
|
|
|
- deviceBean.idx,
|
|
|
- )
|
|
|
+ /**
|
|
|
+ * 仓位检测
|
|
|
+ */
|
|
|
+ private fun detectSlot(deviceBean: DockBean.DeviceBean) {
|
|
|
+ when (deviceBean) {
|
|
|
+ is DockBean.KeyBean -> {
|
|
|
+ LoadingEvent.sendLoadingEvent(getString(R.string.start_detect_key_slot))
|
|
|
+ ModBusController.readKeyRfidStr(deviceBean.addr, deviceBean.idx) { idx, keyRfid ->
|
|
|
+ ThreadUtils.runOnMain {
|
|
|
+ viewModel.checkKeyRfidIsNewDevice(keyRfid)
|
|
|
+ .observe(this@SlotsManageFragment) {
|
|
|
+ LoadingEvent.sendLoadingEvent(getString(R.string.check_key_is_new_device))
|
|
|
+ LoadingEvent.sendLoadingEvent(getString(R.string.start_scan_key_mac))
|
|
|
+ viewModel.detectKeyMac(deviceBean)
|
|
|
+ .observe(this@SlotsManageFragment) { keyMac ->
|
|
|
+ LoadingEvent.sendLoadingEvent()
|
|
|
+ TipDialog.showInfo(
|
|
|
+ msg = getString(R.string.check_new_lock_need_register),
|
|
|
+ onConfirmClick = {
|
|
|
+ viewModel.registerKeyInfo(keyRfid, keyMac)
|
|
|
+ .observe(this@SlotsManageFragment) {
|
|
|
+ if (it) {
|
|
|
+ TipDialog.showSuccess(getString(R.string.register_success))
|
|
|
+ } else {
|
|
|
+ TipDialog.showError(getString(R.string.register_failed))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
- else -> {}
|
|
|
- }
|
|
|
}
|
|
|
- //关
|
|
|
- str.toString() == getString(com.grkj.ui_base.R.string.turn_off) -> {
|
|
|
- when (deviceBean) {
|
|
|
- is DockBean.KeyBean -> {
|
|
|
- ModBusController.controlKeyCharge(
|
|
|
- false, deviceBean.idx,
|
|
|
- ModBusController.dockList.find { it.row == deviceBean.row }?.addr
|
|
|
- )
|
|
|
- }
|
|
|
|
|
|
- is DockBean.LockBean -> {
|
|
|
- ModBusController.controlLockBuckle(
|
|
|
- false,
|
|
|
- ModBusController.dockList.find { it.row == deviceBean.row }?.addr,
|
|
|
- deviceBean.idx,
|
|
|
- )
|
|
|
- }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- else -> {}
|
|
|
- }
|
|
|
+ is DockBean.LockBean -> {
|
|
|
+ LoadingEvent.sendLoadingEvent(getString(R.string.start_detect_lock_slot))
|
|
|
+ ModBusController.readLockRfidStr(deviceBean.addr, deviceBean.idx) { lockRfid ->
|
|
|
+ ThreadUtils.runOnMain {
|
|
|
+ LoadingEvent.sendLoadingEvent(getString(R.string.check_lock_is_new_device))
|
|
|
+ viewModel.checkLockRfidIsNewDevice(lockRfid)
|
|
|
+ .observe(this@SlotsManageFragment) {
|
|
|
+ LoadingEvent.sendLoadingEvent()
|
|
|
+ TipDialog.showInfo(
|
|
|
+ msg = getString(R.string.check_new_lock_need_register),
|
|
|
+ onConfirmClick = {
|
|
|
+ viewModel.registerLockInfo(lockRfid)
|
|
|
+ .observe(this@SlotsManageFragment) {
|
|
|
+ if (it) {
|
|
|
+ TipDialog.showSuccess(getString(R.string.register_success))
|
|
|
+ } else {
|
|
|
+ TipDialog.showError(getString(R.string.register_failed))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
}
|
|
|
- //检查仓位
|
|
|
- str.toString() == getString(R.string.detect_slot) -> {}
|
|
|
}
|
|
|
- false
|
|
|
}
|
|
|
+
|
|
|
+ else -> {}
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 仓位开关
|
|
|
+ */
|
|
|
+ private fun slotSwitch(isOpen: Boolean, deviceBean: DockBean.DeviceBean) {
|
|
|
+ when (deviceBean) {
|
|
|
+ is DockBean.KeyBean -> {
|
|
|
+ ModBusController.controlKeyBuckle(isOpen, deviceBean.idx, deviceBean.addr)
|
|
|
+ ModBusController.controlKeyCharge(
|
|
|
+ isOpen, deviceBean.idx,
|
|
|
+ deviceBean.addr
|
|
|
+ )
|
|
|
+ }
|
|
|
+
|
|
|
+ is DockBean.LockBean -> {
|
|
|
+ ModBusController.controlLockBuckle(
|
|
|
+ isOpen,
|
|
|
+ deviceBean.addr,
|
|
|
+ deviceBean.idx,
|
|
|
+ )
|
|
|
+ }
|
|
|
+
|
|
|
+ else -> {}
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private fun BindingAdapter.BindingViewHolder.onKeyDockRVListBinding(
|
|
|
@@ -163,24 +207,61 @@ class SlotsManageFragment : BaseFragment<FragmentSlotsManageBinding>() {
|
|
|
val itemKeyBinding = getBinding<ItemDeviceSlotManageKeyBinding>()
|
|
|
val itemKey = getModel<DockBean.KeyBean>()
|
|
|
itemKeyBinding.exceptionIv.isVisible =
|
|
|
- viewModel.exceptionKeyData.find { it.keyNfc == itemKey.rfid } != null
|
|
|
+ viewModel.exceptionKeyData.find { it.keyNfc == itemKey.rfid } != null ||
|
|
|
+ viewModel.exceptionSlotsData.find {
|
|
|
+ it.row?.toInt() == itemKey.row && it.col?.toInt() == (modelPosition + 1)
|
|
|
+ }?.status == CommonDictDataEnum.SLOT_STATUS.commonDictRes.find { it.dictLabel == "异常" }?.dictValue
|
|
|
itemKeyBinding.ivKey.isSelected = itemKey.isExist
|
|
|
+ itemKeyBinding.switchLayout.isVisible =
|
|
|
+ MainDomainData.roleKeys?.contains(RoleEnum.ADMIN.roleKey) == true ||
|
|
|
+ MainDomainData.roleKeys?.contains(RoleEnum.SYSCONFIG.roleKey) == true
|
|
|
+ itemKeyBinding.detect.isVisible =
|
|
|
+ MainDomainData.roleKeys?.contains(RoleEnum.ADMIN.roleKey) == true ||
|
|
|
+ MainDomainData.roleKeys?.contains(RoleEnum.SYSCONFIG.roleKey) == true
|
|
|
+ itemKeyBinding.tvTurnOn.setDebouncedClickListener {
|
|
|
+ slotSwitch(true, itemKey)
|
|
|
+ }
|
|
|
+ itemKeyBinding.tvTurnOff.setDebouncedClickListener {
|
|
|
+ slotSwitch(false, itemKey)
|
|
|
+ }
|
|
|
+ itemKeyBinding.detect.setDebouncedClickListener {
|
|
|
+ detectSlot(itemKey)
|
|
|
+ }
|
|
|
itemKeyBinding.ivKey.setOnLongClickListener { v ->
|
|
|
- showLongClickMenu(v, itemKey)
|
|
|
- false
|
|
|
+ showLongClickMenu(v, itemKey, modelPosition)
|
|
|
+ true
|
|
|
}
|
|
|
itemKeyBinding.exceptionIv.setOnClickListener {
|
|
|
TipDialog.showError(
|
|
|
msg = viewModel.exceptionKeyData.find { it.keyNfc == itemKey.rfid }?.remark
|
|
|
- ?: ""
|
|
|
+ ?: viewModel.exceptionSlotsData.find {
|
|
|
+ it.row?.toInt() == itemKey.row && it.col?.toInt() == (modelPosition + 1)
|
|
|
+ }?.remark ?: ""
|
|
|
)
|
|
|
}
|
|
|
itemKeyBinding.exceptionIv.setOnLongClickListener {
|
|
|
- viewModel.removeSlotsException(itemKey.row, itemKey.idx)
|
|
|
- .observe(this@SlotsManageFragment) {
|
|
|
- adapter?.notifyDataSetChanged()
|
|
|
- }
|
|
|
- false
|
|
|
+ if (MainDomainData.roleKeys?.contains(RoleEnum.ADMIN.roleKey) == true ||
|
|
|
+ MainDomainData.roleKeys?.contains(RoleEnum.SYSCONFIG.roleKey) == true
|
|
|
+ ) {
|
|
|
+ TipDialog.showInfo(
|
|
|
+ getString(R.string.do_you_want_to_remove_exception),
|
|
|
+ onConfirmClick = {
|
|
|
+ if (viewModel.exceptionSlotsData.any {
|
|
|
+ it.row?.toInt() == itemKey.row && it.col?.toInt() == (modelPosition + 1)
|
|
|
+ }) {
|
|
|
+ viewModel.removeSlotsException(itemKey.row, modelPosition + 1)
|
|
|
+ .observe(this@SlotsManageFragment) {
|
|
|
+ binding.dockRv.adapter?.notifyDataSetChanged()
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ viewModel.removeDeviceException(itemKey.type, itemKey.rfid)
|
|
|
+ .observe(this@SlotsManageFragment) {
|
|
|
+ binding.dockRv.adapter?.notifyDataSetChanged()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ true
|
|
|
}
|
|
|
}
|
|
|
}.models = keyDock.keyData
|
|
|
@@ -202,24 +283,61 @@ class SlotsManageFragment : BaseFragment<FragmentSlotsManageBinding>() {
|
|
|
val itemLockBinding = getBinding<ItemDeviceSlotManageLockBinding>()
|
|
|
val itemLock = getModel<DockBean.LockBean>()
|
|
|
itemLockBinding.exceptionIv.isVisible =
|
|
|
- viewModel.exceptionLockData.find { it.lockNfc == itemLock.rfid } != null
|
|
|
+ viewModel.exceptionLockData.find { it.lockNfc == itemLock.rfid } != null ||
|
|
|
+ viewModel.exceptionSlotsData.find {
|
|
|
+ it.row?.toInt() == itemLock.row && it.col?.toInt() == (modelPosition + 1)
|
|
|
+ }?.status == CommonDictDataEnum.SLOT_STATUS.commonDictRes.find { it.dictLabel == "异常" }?.dictValue
|
|
|
itemLockBinding.root.isSelected = itemLock.isExist
|
|
|
+ itemLockBinding.switchLayout.isVisible =
|
|
|
+ MainDomainData.roleKeys?.contains(RoleEnum.ADMIN.roleKey) == true ||
|
|
|
+ MainDomainData.roleKeys?.contains(RoleEnum.SYSCONFIG.roleKey) == true
|
|
|
+ itemLockBinding.detect.isVisible =
|
|
|
+ MainDomainData.roleKeys?.contains(RoleEnum.ADMIN.roleKey) == true ||
|
|
|
+ MainDomainData.roleKeys?.contains(RoleEnum.SYSCONFIG.roleKey) == true
|
|
|
+ itemLockBinding.tvTurnOn.setDebouncedClickListener {
|
|
|
+ slotSwitch(true, itemLock)
|
|
|
+ }
|
|
|
+ itemLockBinding.tvTurnOff.setDebouncedClickListener {
|
|
|
+ slotSwitch(false, itemLock)
|
|
|
+ }
|
|
|
+ itemLockBinding.detect.setDebouncedClickListener {
|
|
|
+ detectSlot(itemLock)
|
|
|
+ }
|
|
|
itemLockBinding.root.setOnLongClickListener { v ->
|
|
|
- showLongClickMenu(v, itemLock)
|
|
|
- false
|
|
|
+ showLongClickMenu(v, itemLock, modelPosition)
|
|
|
+ true
|
|
|
}
|
|
|
itemLockBinding.exceptionIv.setOnClickListener {
|
|
|
TipDialog.showError(
|
|
|
msg = viewModel.exceptionLockData.find { it.lockNfc == itemLock.rfid }?.remark
|
|
|
- ?: ""
|
|
|
+ ?: viewModel.exceptionSlotsData.find {
|
|
|
+ it.row?.toInt() == itemLock.row && it.col?.toInt() == (modelPosition + 1)
|
|
|
+ }?.remark ?: ""
|
|
|
)
|
|
|
}
|
|
|
itemLockBinding.exceptionIv.setOnLongClickListener {
|
|
|
- viewModel.removeSlotsException(itemLock.row, itemLock.idx)
|
|
|
- .observe(this@SlotsManageFragment) {
|
|
|
- adapter?.notifyDataSetChanged()
|
|
|
- }
|
|
|
- false
|
|
|
+ if (MainDomainData.roleKeys?.contains(RoleEnum.ADMIN.roleKey) == true ||
|
|
|
+ MainDomainData.roleKeys?.contains(RoleEnum.SYSCONFIG.roleKey) == true
|
|
|
+ ) {
|
|
|
+ TipDialog.showInfo(
|
|
|
+ getString(R.string.do_you_want_to_remove_exception),
|
|
|
+ onConfirmClick = {
|
|
|
+ if (viewModel.exceptionSlotsData.any {
|
|
|
+ it.row?.toInt() == itemLock.row && it.col?.toInt() == (modelPosition + 1)
|
|
|
+ }) {
|
|
|
+ viewModel.removeSlotsException(itemLock.row, modelPosition + 1)
|
|
|
+ .observe(this@SlotsManageFragment) {
|
|
|
+ binding.dockRv.adapter?.notifyDataSetChanged()
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ viewModel.removeDeviceException(itemLock.type, itemLock.rfid)
|
|
|
+ .observe(this@SlotsManageFragment) {
|
|
|
+ binding.dockRv.adapter?.notifyDataSetChanged()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ true
|
|
|
}
|
|
|
}
|
|
|
}.models = lockDock.lockData
|
|
|
@@ -242,48 +360,130 @@ class SlotsManageFragment : BaseFragment<FragmentSlotsManageBinding>() {
|
|
|
is DockBean.KeyBean -> {
|
|
|
val itemKeyBinding = getBinding<ItemDeviceSlotManageKeyBinding>()
|
|
|
itemKeyBinding.exceptionIv.isVisible =
|
|
|
- viewModel.exceptionKeyData.find { it.keyNfc == itemPortable.rfid } != null
|
|
|
+ viewModel.exceptionKeyData.find { it.keyNfc == itemPortable.rfid } != null ||
|
|
|
+ viewModel.exceptionSlotsData.find {
|
|
|
+ it.row?.toInt() == itemPortable.row && it.col?.toInt() == (modelPosition + 1)
|
|
|
+ }?.status == CommonDictDataEnum.SLOT_STATUS.commonDictRes.find { it.dictLabel == "异常" }?.dictValue
|
|
|
itemKeyBinding.ivKey.isSelected = itemPortable.isExist
|
|
|
+ itemKeyBinding.switchLayout.isVisible =
|
|
|
+ MainDomainData.roleKeys?.contains(RoleEnum.ADMIN.roleKey) == true ||
|
|
|
+ MainDomainData.roleKeys?.contains(RoleEnum.SYSCONFIG.roleKey) == true
|
|
|
+ itemKeyBinding.detect.isVisible =
|
|
|
+ MainDomainData.roleKeys?.contains(RoleEnum.ADMIN.roleKey) == true ||
|
|
|
+ MainDomainData.roleKeys?.contains(RoleEnum.SYSCONFIG.roleKey) == true
|
|
|
+ itemKeyBinding.tvTurnOn.setDebouncedClickListener {
|
|
|
+ slotSwitch(true, itemPortable)
|
|
|
+ }
|
|
|
+ itemKeyBinding.tvTurnOff.setDebouncedClickListener {
|
|
|
+ slotSwitch(false, itemPortable)
|
|
|
+ }
|
|
|
+ itemKeyBinding.detect.setDebouncedClickListener {
|
|
|
+ detectSlot(itemPortable)
|
|
|
+ }
|
|
|
itemKeyBinding.ivKey.setOnLongClickListener { v ->
|
|
|
- showLongClickMenu(v, itemPortable)
|
|
|
- false
|
|
|
+ showLongClickMenu(v, itemPortable, modelPosition)
|
|
|
+ true
|
|
|
}
|
|
|
itemKeyBinding.exceptionIv.setOnClickListener {
|
|
|
TipDialog.showError(
|
|
|
msg = viewModel.exceptionKeyData.find { it.keyNfc == itemPortable.rfid }?.remark
|
|
|
- ?: ""
|
|
|
+ ?: viewModel.exceptionSlotsData.find {
|
|
|
+ it.row?.toInt() == itemPortable.row && it.col?.toInt() == (modelPosition + 1)
|
|
|
+ }?.remark ?: ""
|
|
|
)
|
|
|
}
|
|
|
itemKeyBinding.exceptionIv.setOnLongClickListener {
|
|
|
- viewModel.removeSlotsException(itemPortable.row, itemPortable.idx)
|
|
|
- .observe(this@SlotsManageFragment) {
|
|
|
- adapter?.notifyDataSetChanged()
|
|
|
- }
|
|
|
- false
|
|
|
+ if (MainDomainData.roleKeys?.contains(RoleEnum.ADMIN.roleKey) == true ||
|
|
|
+ MainDomainData.roleKeys?.contains(RoleEnum.SYSCONFIG.roleKey) == true
|
|
|
+ ) {
|
|
|
+ TipDialog.showInfo(
|
|
|
+ getString(R.string.do_you_want_to_remove_exception),
|
|
|
+ onConfirmClick = {
|
|
|
+ if (viewModel.exceptionSlotsData.any {
|
|
|
+ it.row?.toInt() == itemPortable.row && it.col?.toInt() == (modelPosition + 1)
|
|
|
+ }) {
|
|
|
+ viewModel.removeSlotsException(
|
|
|
+ itemPortable.row,
|
|
|
+ modelPosition + 1
|
|
|
+ ).observe(this@SlotsManageFragment) {
|
|
|
+ binding.dockRv.adapter?.notifyDataSetChanged()
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ viewModel.removeDeviceException(
|
|
|
+ itemPortable.type,
|
|
|
+ itemPortable.rfid
|
|
|
+ ).observe(this@SlotsManageFragment) {
|
|
|
+ binding.dockRv.adapter?.notifyDataSetChanged()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ true
|
|
|
}
|
|
|
}
|
|
|
|
|
|
is DockBean.LockBean -> {
|
|
|
val itemLockBinding = getBinding<ItemDeviceSlotManageLockBinding>()
|
|
|
itemLockBinding.exceptionIv.isVisible =
|
|
|
- viewModel.exceptionLockData.find { it.lockNfc == itemPortable.rfid } != null
|
|
|
+ viewModel.exceptionLockData.find { it.lockNfc == itemPortable.rfid } != null ||
|
|
|
+ viewModel.exceptionSlotsData.find {
|
|
|
+ it.row?.toInt() == itemPortable.row && it.col?.toInt() == (modelPosition + 1)
|
|
|
+ }?.status == CommonDictDataEnum.SLOT_STATUS.commonDictRes.find { it.dictLabel == "异常" }?.dictValue
|
|
|
itemLockBinding.root.isSelected = itemPortable.isExist
|
|
|
+ itemLockBinding.switchLayout.isVisible =
|
|
|
+ MainDomainData.roleKeys?.contains(RoleEnum.ADMIN.roleKey) == true ||
|
|
|
+ MainDomainData.roleKeys?.contains(RoleEnum.SYSCONFIG.roleKey) == true
|
|
|
+ itemLockBinding.detect.isVisible =
|
|
|
+ MainDomainData.roleKeys?.contains(RoleEnum.ADMIN.roleKey) == true ||
|
|
|
+ MainDomainData.roleKeys?.contains(RoleEnum.SYSCONFIG.roleKey) == true
|
|
|
+ itemLockBinding.tvTurnOn.setDebouncedClickListener {
|
|
|
+ slotSwitch(true, itemPortable)
|
|
|
+ }
|
|
|
+ itemLockBinding.tvTurnOff.setDebouncedClickListener {
|
|
|
+ slotSwitch(false, itemPortable)
|
|
|
+ }
|
|
|
+ itemLockBinding.detect.setDebouncedClickListener {
|
|
|
+ detectSlot(itemPortable)
|
|
|
+ }
|
|
|
itemLockBinding.root.setOnLongClickListener { v ->
|
|
|
- showLongClickMenu(v, itemPortable)
|
|
|
- false
|
|
|
+ showLongClickMenu(v, itemPortable, modelPosition)
|
|
|
+ true
|
|
|
}
|
|
|
itemLockBinding.exceptionIv.setOnClickListener {
|
|
|
TipDialog.showError(
|
|
|
msg = viewModel.exceptionLockData.find { it.lockNfc == itemPortable.rfid }?.remark
|
|
|
- ?: ""
|
|
|
+ ?: viewModel.exceptionSlotsData.find {
|
|
|
+ it.row?.toInt() == itemPortable.row && it.col?.toInt() == (modelPosition + 1)
|
|
|
+ }?.remark ?: ""
|
|
|
)
|
|
|
}
|
|
|
itemLockBinding.exceptionIv.setOnLongClickListener {
|
|
|
- viewModel.removeSlotsException(itemPortable.row, itemPortable.idx)
|
|
|
- .observe(this@SlotsManageFragment) {
|
|
|
- adapter?.notifyDataSetChanged()
|
|
|
- }
|
|
|
- false
|
|
|
+ if (MainDomainData.roleKeys?.contains(RoleEnum.ADMIN.roleKey) == true ||
|
|
|
+ MainDomainData.roleKeys?.contains(RoleEnum.SYSCONFIG.roleKey) == true
|
|
|
+ ) {
|
|
|
+ TipDialog.showInfo(
|
|
|
+ getString(R.string.do_you_want_to_remove_exception),
|
|
|
+ onConfirmClick = {
|
|
|
+ if (viewModel.exceptionSlotsData.any {
|
|
|
+ it.row?.toInt() == itemPortable.row && it.col?.toInt() == (modelPosition + 1)
|
|
|
+ }) {
|
|
|
+ viewModel.removeSlotsException(
|
|
|
+ itemPortable.row,
|
|
|
+ modelPosition + 1
|
|
|
+ ).observe(this@SlotsManageFragment) {
|
|
|
+ binding.dockRv.adapter?.notifyDataSetChanged()
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ viewModel.removeDeviceException(
|
|
|
+ itemPortable.type,
|
|
|
+ itemPortable.rfid
|
|
|
+ ).observe(this@SlotsManageFragment) {
|
|
|
+ binding.dockRv.adapter?.notifyDataSetChanged()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ true
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -293,14 +493,26 @@ class SlotsManageFragment : BaseFragment<FragmentSlotsManageBinding>() {
|
|
|
|
|
|
override fun initData() {
|
|
|
super.initData()
|
|
|
- viewModel.getExceptionData().observe(this) {
|
|
|
- binding.dockRv.adapter?.notifyDataSetChanged()
|
|
|
- }
|
|
|
+ getExceptionData()
|
|
|
viewModel.registerStatusListener {
|
|
|
getData()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取异常数据
|
|
|
+ */
|
|
|
+ private fun getExceptionData() {
|
|
|
+ viewModel.getExceptionData().observe(this) {
|
|
|
+ binding.dockRv.adapter?.notifyDataSetChanged()
|
|
|
+ if (ISCSConfig.isNetVersion) {
|
|
|
+ binding.root.postDelayed({
|
|
|
+ getExceptionData()
|
|
|
+ }, 5000)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 获取并加载数据
|
|
|
*/
|
|
|
@@ -329,7 +541,14 @@ class SlotsManageFragment : BaseFragment<FragmentSlotsManageBinding>() {
|
|
|
deviceData.addAll(it.deviceList.toList())
|
|
|
}
|
|
|
}
|
|
|
- binding.dockRv.models = newKeyDockList + portableDock + lockDock
|
|
|
+ dockDataList.clear()
|
|
|
+ dockDataList.addAll(newKeyDockList + portableDock + lockDock)
|
|
|
+ binding.dockRv.adapter?.notifyDataSetChanged()
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun onDestroyView() {
|
|
|
+ viewModel.isDestroy = true
|
|
|
+ super.onDestroyView()
|
|
|
}
|
|
|
|
|
|
}
|