|
|
@@ -935,62 +935,74 @@ object BleBusinessManager {
|
|
|
/**
|
|
|
* 分配钥匙
|
|
|
*/
|
|
|
+ @SuppressLint("MissingPermission")
|
|
|
fun handleGiveKey(deviceTakeUpdateBO: DeviceTakeUpdate) {
|
|
|
+ val mac = HardwareMode.getCurrentHardwareMode().getKeyMacByRfid(deviceTakeUpdateBO.nfc)
|
|
|
logger.info("取完锁开始发钥匙2:${BleConnectionManager.deviceList.toJson()}")
|
|
|
- BleConnectionManager.getBleDeviceByMac(
|
|
|
- HardwareMode.getCurrentHardwareMode().getKeyMacByRfid(deviceTakeUpdateBO.nfc)
|
|
|
- )
|
|
|
- ?.let {
|
|
|
- BleConnectionManager.getCurrentStatus(
|
|
|
- 2, BleConnectionManager.getBleDeviceByMac(
|
|
|
+ mac?.let {
|
|
|
+ if (BleSendDispatcher.isConnected(it)) {
|
|
|
+ BleSendDispatcher.submit(it) {
|
|
|
+ BleConnectionManager.getBleDeviceByMac(
|
|
|
HardwareMode.getCurrentHardwareMode()
|
|
|
.getKeyMacByRfid(deviceTakeUpdateBO.nfc)
|
|
|
- )!!.bleDevice
|
|
|
- ) {
|
|
|
- if (!it) {
|
|
|
- return@getCurrentStatus
|
|
|
- }
|
|
|
- logger.warn("handleGiveKey timeout")
|
|
|
- HardwareBusinessManager.removeDeviceTake(
|
|
|
- DeviceConst.DEVICE_TYPE_KEY, deviceTakeUpdateBO.nfc
|
|
|
)
|
|
|
- HardwareBusinessManager.checkEquipCount(
|
|
|
- deviceTakeUpdateBO.ticketId,
|
|
|
- 0,
|
|
|
- true
|
|
|
- ) { keyPair, lockMap ->
|
|
|
- if (keyPair == null) {
|
|
|
- TipDialog.show(
|
|
|
- msg = CommonUtils.getStr("key_take_error_tip").toString(),
|
|
|
- onConfirmClick = {
|
|
|
- DeviceExceptionEvent.sendDeviceExceptionEvent(
|
|
|
- DeviceConst.DEVICE_TYPE_KEY, deviceTakeUpdateBO.nfc
|
|
|
- )
|
|
|
- })
|
|
|
- } else {
|
|
|
- HardwareBusinessManager.addDeviceTake(
|
|
|
- DeviceConst.DEVICE_TYPE_KEY,
|
|
|
- deviceTakeUpdateBO.ticketId,
|
|
|
- keyPair.second
|
|
|
- )
|
|
|
- handleGiveKey(
|
|
|
- DeviceTakeUpdate(
|
|
|
- DeviceConst.DEVICE_TYPE_KEY,
|
|
|
+ ?.let {
|
|
|
+ BleConnectionManager.getCurrentStatus(
|
|
|
+ 2, BleConnectionManager.getBleDeviceByMac(
|
|
|
+ HardwareMode.getCurrentHardwareMode()
|
|
|
+ .getKeyMacByRfid(deviceTakeUpdateBO.nfc)
|
|
|
+ )!!.bleDevice
|
|
|
+ ) {
|
|
|
+ if (!it) {
|
|
|
+ return@getCurrentStatus
|
|
|
+ }
|
|
|
+ logger.warn("handleGiveKey timeout")
|
|
|
+ HardwareBusinessManager.removeDeviceTake(
|
|
|
+ DeviceConst.DEVICE_TYPE_KEY, deviceTakeUpdateBO.nfc
|
|
|
+ )
|
|
|
+ HardwareBusinessManager.checkEquipCount(
|
|
|
deviceTakeUpdateBO.ticketId,
|
|
|
- keyPair.second ?: ""
|
|
|
+ 0,
|
|
|
+ true
|
|
|
+ ) { keyPair, lockMap ->
|
|
|
+ if (keyPair == null) {
|
|
|
+ TipDialog.show(
|
|
|
+ msg = CommonUtils.getStr("key_take_error_tip")
|
|
|
+ .toString(),
|
|
|
+ onConfirmClick = {
|
|
|
+ DeviceExceptionEvent.sendDeviceExceptionEvent(
|
|
|
+ DeviceConst.DEVICE_TYPE_KEY,
|
|
|
+ deviceTakeUpdateBO.nfc
|
|
|
+ )
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ HardwareBusinessManager.addDeviceTake(
|
|
|
+ DeviceConst.DEVICE_TYPE_KEY,
|
|
|
+ deviceTakeUpdateBO.ticketId,
|
|
|
+ keyPair.second
|
|
|
+ )
|
|
|
+ handleGiveKey(
|
|
|
+ DeviceTakeUpdate(
|
|
|
+ DeviceConst.DEVICE_TYPE_KEY,
|
|
|
+ deviceTakeUpdateBO.ticketId,
|
|
|
+ keyPair.second ?: ""
|
|
|
+ )
|
|
|
+ )
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } ?: run {
|
|
|
+ logger.info("根据钥匙的rfid没找到钥匙")
|
|
|
+ TipDialog.show(
|
|
|
+ msg = CommonUtils.getStr("key_take_error_tip").toString(),
|
|
|
+ onConfirmClick = {
|
|
|
+ DeviceExceptionEvent.sendDeviceExceptionEvent(
|
|
|
+ DeviceConst.DEVICE_TYPE_KEY, deviceTakeUpdateBO.nfc
|
|
|
)
|
|
|
- )
|
|
|
- }
|
|
|
+ })
|
|
|
}
|
|
|
}
|
|
|
- } ?: run {
|
|
|
- logger.info("根据钥匙的rfid没找到钥匙")
|
|
|
- TipDialog.show(
|
|
|
- msg = CommonUtils.getStr("key_take_error_tip").toString(), onConfirmClick = {
|
|
|
- DeviceExceptionEvent.sendDeviceExceptionEvent(
|
|
|
- DeviceConst.DEVICE_TYPE_KEY, deviceTakeUpdateBO.nfc
|
|
|
- )
|
|
|
- })
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|