|
|
@@ -356,7 +356,7 @@ object HardwareBusinessManager {
|
|
|
* 5、蓝牙数据通讯
|
|
|
*/
|
|
|
private fun canDeviceStatusHandle(res: List<DeviceModel>) {
|
|
|
- logger.debug("硬件状态:{}", res)
|
|
|
+// logger.debug("硬件状态:{}", res)
|
|
|
if (res.isEmpty()) {
|
|
|
return@canDeviceStatusHandle
|
|
|
}
|
|
|
@@ -588,7 +588,8 @@ object HardwareBusinessManager {
|
|
|
val rfid = rfidData.toHexFromLe()
|
|
|
lockBean.rfid = rfid
|
|
|
ThreadUtils.runOnIO {
|
|
|
- val lockStatusReq = async { DataBusiness.fetchDict(DictConstants.KEY_PAD_LOCK_STATUS) }
|
|
|
+ val lockStatusReq =
|
|
|
+ async { DataBusiness.fetchDict(DictConstants.KEY_PAD_LOCK_STATUS) }
|
|
|
val slotStatus = async { DataBusiness.fetchDict(DictConstants.KEY_SLOT_STATUS) }
|
|
|
val slotType = async { DataBusiness.fetchDict(DictConstants.KEY_SLOT_TYPE) }
|
|
|
val slotsPageReq = async { DataBusiness.getSlotsPage() }
|
|
|
@@ -600,12 +601,24 @@ object HardwareBusinessManager {
|
|
|
|
|
|
LogicManager.hardwareLogic.getIsLockPage { lockData ->
|
|
|
val isLockAbnormal = rfid in (lockData?.records?.filter {
|
|
|
- it.exStatus == lockStatus.find { d -> I18nManager.t(d.dictLabel) == I18nManager.t("abnormal") }?.dictValue
|
|
|
+ it.exStatus == lockStatus.find { d ->
|
|
|
+ I18nManager.t(d.dictLabel) == I18nManager.t(
|
|
|
+ "abnormal"
|
|
|
+ )
|
|
|
+ }?.dictValue
|
|
|
}?.map { it.lockNfc } ?: emptyList())
|
|
|
|
|
|
val isSlotAbnormal = slotsPage?.records?.any {
|
|
|
- it.slotType == slotTypeList.find { d -> I18nManager.t(d.dictLabel) == I18nManager.t("lock") }?.dictValue &&
|
|
|
- it.status == slotStatusList.find { d -> I18nManager.t(d.dictLabel) == I18nManager.t("abnormal") }?.dictValue &&
|
|
|
+ it.slotType == slotTypeList.find { d ->
|
|
|
+ I18nManager.t(d.dictLabel) == I18nManager.t(
|
|
|
+ "lock"
|
|
|
+ )
|
|
|
+ }?.dictValue &&
|
|
|
+ it.status == slotStatusList.find { d ->
|
|
|
+ I18nManager.t(d.dictLabel) == I18nManager.t(
|
|
|
+ "abnormal"
|
|
|
+ )
|
|
|
+ }?.dictValue &&
|
|
|
it.row?.toInt() == lockBean.nodeId && lockBean.id == it.col?.toInt()
|
|
|
} == true
|
|
|
|
|
|
@@ -624,7 +637,8 @@ object HardwareBusinessManager {
|
|
|
LogicManager.hardwareLogic.getLockInfo(rfid) {
|
|
|
logger.info("挂锁信息:${it}")
|
|
|
if (it != null && it.lockNfc?.isNotEmpty() == true) {
|
|
|
- val ctrl = CanCommands.forDevice(lockBean.nodeId).controlOne_1to5(lockBean.id, true)
|
|
|
+ val ctrl = CanCommands.forDevice(lockBean.nodeId)
|
|
|
+ .controlOne_1to5(lockBean.id, true)
|
|
|
CanHelper.writeTo(ctrl) {
|
|
|
LogicManager.jobTicketLogic.updateLockReturn(
|
|
|
rfid, SIKCore.getApplication().serialNo()
|
|
|
@@ -632,8 +646,11 @@ object HardwareBusinessManager {
|
|
|
}
|
|
|
}
|
|
|
Executor.delayOnMain(200) {
|
|
|
- try { canListeners.forEach { it.callBack(listOf(lockBean)) } }
|
|
|
- finally { lockBean.deviceChange = false } // ✅ 最后归零
|
|
|
+ try {
|
|
|
+ canListeners.forEach { it.callBack(listOf(lockBean)) }
|
|
|
+ } finally {
|
|
|
+ lockBean.deviceChange = false
|
|
|
+ } // ✅ 最后归零
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -641,7 +658,10 @@ object HardwareBusinessManager {
|
|
|
}
|
|
|
} else {
|
|
|
logger.info("挂锁取出-:${lockBean.rfid}")
|
|
|
- handleDeviceTake(DeviceTakeUpdateEvent(DeviceConst.DEVICE_TYPE_LOCK, lockBean.rfid), lockBean.rfid)
|
|
|
+ handleDeviceTake(
|
|
|
+ DeviceTakeUpdateEvent(DeviceConst.DEVICE_TYPE_LOCK, lockBean.rfid),
|
|
|
+ lockBean.rfid
|
|
|
+ )
|
|
|
lockBean.deviceChange = false // 取出分支可在同步处理后立即归零
|
|
|
}
|
|
|
}
|
|
|
@@ -656,11 +676,15 @@ object HardwareBusinessManager {
|
|
|
logger.info("钥匙状态变化canDeviceKeyHandler:$keyBean")
|
|
|
|
|
|
if (keyBean.isExist) {
|
|
|
- val req = CanCommands.forDevice(keyBean.nodeId).let { if (keyBean.id == 0) it.getLeftRfid() else it.getRightRfid() }
|
|
|
+ val req = CanCommands.forDevice(keyBean.nodeId)
|
|
|
+ .let { if (keyBean.id == 0) it.getLeftRfid() else it.getRightRfid() }
|
|
|
CanHelper.readFrom(req) { res ->
|
|
|
val rfidData = res?.payload ?: byteArrayOf()
|
|
|
if (ISCSConfig.isInit) {
|
|
|
- CanHelper.writeTo(CanCommands.forDevice(keyBean.nodeId).setCharge(keyBean.id == 0, keyBean.id == 1)){}
|
|
|
+ CanHelper.writeTo(
|
|
|
+ CanCommands.forDevice(keyBean.nodeId)
|
|
|
+ .setCharge(keyBean.id == 0, keyBean.id == 1)
|
|
|
+ ) {}
|
|
|
}
|
|
|
if (rfidData.size < 4) {
|
|
|
logger.error("Key rfid error")
|
|
|
@@ -676,7 +700,8 @@ object HardwareBusinessManager {
|
|
|
val slotStatus = async { DataBusiness.fetchDict(DictConstants.KEY_SLOT_STATUS) }
|
|
|
val slotType = async { DataBusiness.fetchDict(DictConstants.KEY_SLOT_TYPE) }
|
|
|
val slotsPageReq = async { DataBusiness.getSlotsPage() }
|
|
|
- val keyStatusReq = async { DataBusiness.fetchDict(DictConstants.KEY_KEY_STATUS) }
|
|
|
+ val keyStatusReq =
|
|
|
+ async { DataBusiness.fetchDict(DictConstants.KEY_KEY_STATUS) }
|
|
|
val keyPageReq = async { DataBusiness.getKeyPage() }
|
|
|
|
|
|
val keyStatus = keyStatusReq.await()
|
|
|
@@ -686,12 +711,24 @@ object HardwareBusinessManager {
|
|
|
val slotTypeList = slotType.await()
|
|
|
|
|
|
val isKeyAbnormal = rfid in (keyData?.records?.filter {
|
|
|
- it.exStatus == keyStatus.find { d -> I18nManager.t(d.dictLabel) == I18nManager.t("abnormal") }?.dictValue
|
|
|
+ it.exStatus == keyStatus.find { d ->
|
|
|
+ I18nManager.t(d.dictLabel) == I18nManager.t(
|
|
|
+ "abnormal"
|
|
|
+ )
|
|
|
+ }?.dictValue
|
|
|
}?.map { it.keyNfc } ?: emptyList())
|
|
|
|
|
|
val isSlotAbnormal = slotsPage?.records?.any {
|
|
|
- it.slotType == slotTypeList.find { d -> I18nManager.t(d.dictLabel) == I18nManager.t("key") }?.dictValue &&
|
|
|
- it.status == slotStatusList.find { d -> I18nManager.t(d.dictLabel) == I18nManager.t("abnormal") }?.dictValue &&
|
|
|
+ it.slotType == slotTypeList.find { d ->
|
|
|
+ I18nManager.t(d.dictLabel) == I18nManager.t(
|
|
|
+ "key"
|
|
|
+ )
|
|
|
+ }?.dictValue &&
|
|
|
+ it.status == slotStatusList.find { d ->
|
|
|
+ I18nManager.t(d.dictLabel) == I18nManager.t(
|
|
|
+ "abnormal"
|
|
|
+ )
|
|
|
+ }?.dictValue &&
|
|
|
it.row?.toInt() == keyBean.nodeId &&
|
|
|
it.col?.toInt() == (keyBean.nodeId + (keyBean.id) * 2 + 1)
|
|
|
} == true
|
|
|
@@ -718,25 +755,33 @@ object HardwareBusinessManager {
|
|
|
if (ISCSConfig.isInit) {
|
|
|
PopTip.build().tip(CommonUtils.getStr("get_key_info_fail"))
|
|
|
}
|
|
|
- val unlock = CanCommands.forDevice(keyBean.nodeId).controlLatch(keyBean.id, 0)
|
|
|
- CanHelper.writeTo(unlock){}
|
|
|
+ val unlock = CanCommands.forDevice(keyBean.nodeId)
|
|
|
+ .controlLatch(keyBean.id, 0)
|
|
|
+ CanHelper.writeTo(unlock) {}
|
|
|
}
|
|
|
Executor.delayOnMain(200) {
|
|
|
- try { canListeners.forEach { l -> l.callBack(listOf(keyBean)) } }
|
|
|
- finally { keyBean.deviceChange = false } // ✅ 放最后
|
|
|
+ try {
|
|
|
+ canListeners.forEach { l -> l.callBack(listOf(keyBean)) }
|
|
|
+ } finally {
|
|
|
+ keyBean.deviceChange = false
|
|
|
+ } // ✅ 放最后
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
} else if (!keyBean.isCharging) {
|
|
|
- handleDeviceTake(DeviceTakeUpdateEvent(DeviceConst.DEVICE_TYPE_KEY, keyBean.rfid), keyBean.rfid)
|
|
|
+ handleDeviceTake(
|
|
|
+ DeviceTakeUpdateEvent(DeviceConst.DEVICE_TYPE_KEY, keyBean.rfid),
|
|
|
+ keyBean.rfid
|
|
|
+ )
|
|
|
Executor.delayOnMain(200) {
|
|
|
- try { canListeners.forEach { it.callBack(listOf(keyBean)) } }
|
|
|
- finally { keyBean.deviceChange = false } // ✅ 已有
|
|
|
+ try {
|
|
|
+ canListeners.forEach { it.callBack(listOf(keyBean)) }
|
|
|
+ } finally {
|
|
|
+ keyBean.deviceChange = false
|
|
|
+ } // ✅ 已有
|
|
|
}
|
|
|
- } else {
|
|
|
- keyBean.deviceChange = false
|
|
|
}
|
|
|
}
|
|
|
|