|
|
@@ -450,17 +450,19 @@ object ModBusController {
|
|
|
|
|
|
/**
|
|
|
* 获取一个钥匙(基于钥匙柜和便携柜不存在接一起的情况)
|
|
|
- *
|
|
|
- * @return 获取的钥匙RFID,如果数量不足,返回null
|
|
|
*/
|
|
|
- fun getOneKey(): String? {
|
|
|
+ fun getOneKey(): Pair<Byte, Pair<Boolean, String>>? {
|
|
|
val keyDockList = dockList.filter { it.type == DOCK_TYPE_KEY || it.type == DOCK_TYPE_PORTABLE }
|
|
|
val keyList = keyDockList.flatMap { it.getKeyList() }.filter { it.isExist }
|
|
|
if (keyList.isEmpty()) {
|
|
|
ToastUtils.tip(R.string.key_is_not_enough)
|
|
|
return null
|
|
|
}
|
|
|
- return keyList[0].rfid
|
|
|
+ val key = getKeyByRfid(keyList[0].rfid!!)
|
|
|
+
|
|
|
+ val addr = keyDockList.find { it.getKeyList().contains(key) }?.addr
|
|
|
+
|
|
|
+ return Pair(addr!!, Pair(key!!.isLeft, key.rfid!!))
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -470,18 +472,18 @@ object ModBusController {
|
|
|
*
|
|
|
* @return key: dock地址,value: 锁具RFID列表
|
|
|
*/
|
|
|
- fun getLocks(needLockCount: Int): MutableMap<Byte, MutableList<String>> {
|
|
|
- val map = mutableMapOf<Byte, MutableList<String>>()
|
|
|
+ fun getLocks(needLockCount: Int): MutableMap<Byte, MutableList<DockBean.LockBean>> {
|
|
|
+ val map = mutableMapOf<Byte, MutableList<DockBean.LockBean>>()
|
|
|
val lockDockList = dockList.filter { it.type == DOCK_TYPE_LOCK || it.type == DOCK_TYPE_PORTABLE }
|
|
|
|
|
|
var provideCount = 0
|
|
|
lockDockList.forEach loop@ { lockDock ->
|
|
|
- val lockList = lockDock.getLockList().filter { it.isExist }
|
|
|
+ val lockList = lockDock.getLockList().filter { it.isExist }.toMutableList()
|
|
|
if (lockList.size < (needLockCount - provideCount)) {
|
|
|
provideCount += lockList.size
|
|
|
- map[lockDock.addr] = lockList.mapNotNull { it.rfid }.toMutableList()
|
|
|
+ map[lockDock.addr] = lockList
|
|
|
} else {
|
|
|
- val rfidList = lockList.subList(0, needLockCount - provideCount).mapNotNull { it.rfid }.toMutableList()
|
|
|
+ val rfidList = lockList.subList(0, needLockCount - provideCount)
|
|
|
map[lockDock.addr] = rfidList
|
|
|
return@loop
|
|
|
}
|