|
@@ -58,7 +58,12 @@ class InitDeviceRegistrationKeyAndLockViewModel @Inject constructor(val hardware
|
|
|
}
|
|
}
|
|
|
ThreadUtils.runOnIO {
|
|
ThreadUtils.runOnIO {
|
|
|
checkNewHardwareKey(
|
|
checkNewHardwareKey(
|
|
|
- HardwareMode.getCurrentHardwareMode().getKeyDockData().toMutableList()
|
|
|
|
|
|
|
+ HardwareMode.getCurrentHardwareMode().getKeyDockData().apply {
|
|
|
|
|
+ forEach {
|
|
|
|
|
+ it.keyData = it.keyData.filter { it.isExist && it.newHardware }
|
|
|
|
|
+ .toMutableList()
|
|
|
|
|
+ }
|
|
|
|
|
+ }.toMutableList()
|
|
|
)
|
|
)
|
|
|
emit(true)
|
|
emit(true)
|
|
|
}
|
|
}
|
|
@@ -206,15 +211,15 @@ class InitDeviceRegistrationKeyAndLockViewModel @Inject constructor(val hardware
|
|
|
*/
|
|
*/
|
|
|
private fun deviceInputSlotsSuspend(
|
|
private fun deviceInputSlotsSuspend(
|
|
|
dockIndex: Int,
|
|
dockIndex: Int,
|
|
|
- dockBean: DockBean,
|
|
|
|
|
|
|
+ dockBean: DockData,
|
|
|
startIndex: Int = 0
|
|
startIndex: Int = 0
|
|
|
): Int {
|
|
): Int {
|
|
|
var lastIndex = startIndex
|
|
var lastIndex = startIndex
|
|
|
- when (dockBean.type) {
|
|
|
|
|
- DeviceConst.DOCK_TYPE_KEY -> {
|
|
|
|
|
- val slots = dockBean.deviceList.mapIndexed { index, device ->
|
|
|
|
|
|
|
+ when (dockBean) {
|
|
|
|
|
+ is DockData.KeyDock -> {
|
|
|
|
|
+ val slots = dockBean.keyData.mapIndexed { index, device ->
|
|
|
lastIndex++
|
|
lastIndex++
|
|
|
- var isLockCabinetSlots = IsLockCabinetSlots()
|
|
|
|
|
|
|
+ val isLockCabinetSlots = IsLockCabinetSlots()
|
|
|
isLockCabinetSlots.slotCode = "CABINET_SLOTS_${lastIndex}"
|
|
isLockCabinetSlots.slotCode = "CABINET_SLOTS_${lastIndex}"
|
|
|
isLockCabinetSlots.cabinetId = MMKVConstants.KEY_LOCK_CABINET_ID.getMMKVData(0)
|
|
isLockCabinetSlots.cabinetId = MMKVConstants.KEY_LOCK_CABINET_ID.getMMKVData(0)
|
|
|
isLockCabinetSlots.slotType = DeviceConst.DEVICE_TYPE_KEY.toString()
|
|
isLockCabinetSlots.slotType = DeviceConst.DEVICE_TYPE_KEY.toString()
|
|
@@ -225,8 +230,8 @@ class InitDeviceRegistrationKeyAndLockViewModel @Inject constructor(val hardware
|
|
|
hardwareRepository.saveCabinetSlots(slots)
|
|
hardwareRepository.saveCabinetSlots(slots)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- DeviceConst.DOCK_TYPE_LOCK -> {
|
|
|
|
|
- val slots = dockBean.deviceList.mapIndexed { index, device ->
|
|
|
|
|
|
|
+ is DockData.LockDock -> {
|
|
|
|
|
+ val slots = dockBean.lockData.mapIndexed { index, device ->
|
|
|
lastIndex++
|
|
lastIndex++
|
|
|
var isLockCabinetSlots = IsLockCabinetSlots()
|
|
var isLockCabinetSlots = IsLockCabinetSlots()
|
|
|
isLockCabinetSlots.slotCode = "CABINET_SLOTS_${lastIndex}"
|
|
isLockCabinetSlots.slotCode = "CABINET_SLOTS_${lastIndex}"
|
|
@@ -239,17 +244,17 @@ class InitDeviceRegistrationKeyAndLockViewModel @Inject constructor(val hardware
|
|
|
hardwareRepository.saveCabinetSlots(slots)
|
|
hardwareRepository.saveCabinetSlots(slots)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- DeviceConst.DOCK_TYPE_PORTABLE -> {
|
|
|
|
|
- val slots = dockBean.deviceList.mapIndexed { index, device ->
|
|
|
|
|
|
|
+ is DockData.PortableDock -> {
|
|
|
|
|
+ val slots = dockBean.deviceData.mapIndexed { index, device ->
|
|
|
lastIndex++
|
|
lastIndex++
|
|
|
var isLockCabinetSlots = IsLockCabinetSlots()
|
|
var isLockCabinetSlots = IsLockCabinetSlots()
|
|
|
isLockCabinetSlots.slotCode = "CABINET_SLOTS_${lastIndex}"
|
|
isLockCabinetSlots.slotCode = "CABINET_SLOTS_${lastIndex}"
|
|
|
isLockCabinetSlots.cabinetId = MMKVConstants.KEY_LOCK_CABINET_ID.getMMKVData(0)
|
|
isLockCabinetSlots.cabinetId = MMKVConstants.KEY_LOCK_CABINET_ID.getMMKVData(0)
|
|
|
isLockCabinetSlots.row = dockBean.row.toString()
|
|
isLockCabinetSlots.row = dockBean.row.toString()
|
|
|
isLockCabinetSlots.col = (index + 1).toString()
|
|
isLockCabinetSlots.col = (index + 1).toString()
|
|
|
- if (device is DockBean.KeyBean) {
|
|
|
|
|
|
|
+ if (device is DockData.KeyDock.KeyBean) {
|
|
|
isLockCabinetSlots.slotType = DeviceConst.DEVICE_TYPE_KEY.toString()
|
|
isLockCabinetSlots.slotType = DeviceConst.DEVICE_TYPE_KEY.toString()
|
|
|
- } else if (device is DockBean.LockBean) {
|
|
|
|
|
|
|
+ } else if (device is DockData.LockDock.LockBean) {
|
|
|
isLockCabinetSlots.slotType = DeviceConst.DEVICE_TYPE_LOCK.toString()
|
|
isLockCabinetSlots.slotType = DeviceConst.DEVICE_TYPE_LOCK.toString()
|
|
|
}
|
|
}
|
|
|
isLockCabinetSlots
|
|
isLockCabinetSlots
|
|
@@ -265,6 +270,11 @@ class InitDeviceRegistrationKeyAndLockViewModel @Inject constructor(val hardware
|
|
|
*/
|
|
*/
|
|
|
fun deviceRegistrationData(): LiveData<Triple<Boolean, Int, Int>> {
|
|
fun deviceRegistrationData(): LiveData<Triple<Boolean, Int, Int>> {
|
|
|
return liveData(Dispatchers.IO) {
|
|
return liveData(Dispatchers.IO) {
|
|
|
|
|
+ val dockList = HardwareMode.getCurrentHardwareMode().getDockData()
|
|
|
|
|
+ var startIndex = 0
|
|
|
|
|
+ dockList.sortedBy { it.type }.forEachIndexed { index, dock ->
|
|
|
|
|
+ startIndex = deviceInputSlotsSuspend(index, dock, startIndex)
|
|
|
|
|
+ }
|
|
|
val lockDevice = HardwareMode.getCurrentHardwareMode().getLockDockData()
|
|
val lockDevice = HardwareMode.getCurrentHardwareMode().getLockDockData()
|
|
|
.flatMap { it.lockData }
|
|
.flatMap { it.lockData }
|
|
|
.filter { it.newHardware && it.rfid.isNotEmpty() }
|
|
.filter { it.newHardware && it.rfid.isNotEmpty() }
|