|
|
@@ -131,6 +131,10 @@ object BusinessManager {
|
|
|
if (keyBean.isExist) {
|
|
|
// 放回钥匙,读取rfid
|
|
|
ModBusController.readKeyRfid(dockBean.addr.toInt() - 1, if (keyBean.isLeft) 0 else 1) { isLeft, res ->
|
|
|
+ if (res.size < 11) {
|
|
|
+ LogUtil.e("Key rfid error")
|
|
|
+ return@readKeyRfid
|
|
|
+ }
|
|
|
val rfid = res.copyOfRange(3, 11).toHexStrings(false).removeLeadingZeros()
|
|
|
ModBusController.updateKeyRfid(dockBean.addr.toInt(), keyBean.isLeft, rfid)
|
|
|
NetApi.getKeyInfo(rfid) {
|
|
|
@@ -158,6 +162,10 @@ object BusinessManager {
|
|
|
dockBean.getLockList().forEach { lockBean ->
|
|
|
if (lockBean.isExist) {
|
|
|
ModBusController.readLockRfid(dockBean.addr.toInt() - 1, lockBean.idx) { res ->
|
|
|
+ if (res.size < 11) {
|
|
|
+ LogUtil.e("Lock rfid error")
|
|
|
+ return@readLockRfid
|
|
|
+ }
|
|
|
val rfid = res.copyOfRange(3, 11).toHexStrings(false).removeLeadingZeros()
|
|
|
ModBusController.updateLockRfid(dockBean.addr.toInt(), lockBean.idx, rfid)
|
|
|
NetApi.getLockInfo(rfid) {
|
|
|
@@ -185,6 +193,10 @@ object BusinessManager {
|
|
|
when (deviceBean.type) {
|
|
|
DEVICE_TYPE_KEY -> {
|
|
|
ModBusController.readKeyRfid(dockBean.addr.toInt() - 1, deviceBean.idx) { isLeft, res ->
|
|
|
+ if (res.size < 11) {
|
|
|
+ LogUtil.e("Key rfid error")
|
|
|
+ return@readKeyRfid
|
|
|
+ }
|
|
|
val rfid = res.copyOfRange(3, 11).toHexStrings(false).removeLeadingZeros()
|
|
|
ModBusController.updateKeyRfid(dockBean.addr.toInt(), true, rfid)
|
|
|
NetApi.getKeyInfo(rfid) {
|
|
|
@@ -201,6 +213,10 @@ object BusinessManager {
|
|
|
}
|
|
|
DEVICE_TYPE_LOCK -> {
|
|
|
ModBusController.readLockRfid(dockBean.addr.toInt() - 1, deviceBean.idx) { res ->
|
|
|
+ if (res.size < 11) {
|
|
|
+ LogUtil.e("Lock rfid error")
|
|
|
+ return@readLockRfid
|
|
|
+ }
|
|
|
val rfid = res.copyOfRange(3, 11).toHexStrings(false).removeLeadingZeros()
|
|
|
ModBusController.updateLockRfid(dockBean.addr.toInt(), deviceBean.idx, rfid)
|
|
|
|
|
|
@@ -219,6 +235,10 @@ object BusinessManager {
|
|
|
}
|
|
|
DEVICE_TYPE_CARD -> {
|
|
|
ModBusController.readPortalCaseCardRfid(dockBean.addr.toInt() - 1) { res ->
|
|
|
+ if (res.size < 11) {
|
|
|
+ LogUtil.e("Portal Case card rfid error")
|
|
|
+ return@readPortalCaseCardRfid
|
|
|
+ }
|
|
|
val rfid = res.copyOfRange(3, 11).toHexStrings(false).removeLeadingZeros()
|
|
|
println("卡片RFID : $rfid")
|
|
|
}
|