Procházet zdrojové kódy

优化设备分发逻辑

Frankensteinly před 8 měsíci
rodič
revize
fa7babc10b

+ 10 - 0
app/src/main/java/com/grkj/iscs/BusinessManager.kt

@@ -1067,7 +1067,17 @@ object BusinessManager {
                 mDeviceTakeList.find { it.deviceType == DEVICE_TYPE_LOCK && it.nfc == deviceTakeUpdateBO.nfc }?.let { info ->
                     NetApi.updateLockTake(mutableListOf(LockTakeUpdateReqVO(info.ticketId, info.nfc, MyApplication.instance?.serialNo()!!))) { isSuccess ->
                         if (isSuccess == true) {
+                            // 检查是不是要发钥匙了
                             mDeviceTakeList.removeIf { it.deviceType == DEVICE_TYPE_LOCK && it.nfc == info.nfc }
+                            // 检查当前工作票是否取完挂锁
+                            if (mDeviceTakeList.any { it.deviceType == DEVICE_TYPE_LOCK && it.ticketId == info.ticketId }) {
+                                LogUtil.i("等待所有挂锁取出")
+                                return@updateLockTake
+                            }
+                            // 检查有无当前工作票的钥匙
+                            mDeviceTakeList.find { it.deviceType == DEVICE_TYPE_KEY && it.ticketId == info.ticketId }?.let { itKey ->
+                                getCurrentStatus(getBleDeviceByMac(ModBusController.getKeyByRfid(itKey.nfc)?.mac)!!.bleDevice)
+                            }
                         }
                     }
                 }

+ 2 - 4
app/src/main/java/com/grkj/iscs/view/presenter/JobProgressPresenter.kt

@@ -101,7 +101,7 @@ class JobProgressPresenter : BasePresenter<IJobProgressView>() {
                     println("EquipDetail : $equipDetail")
                     // 取锁具、取钥匙
                     val needLockCount = equipDetail?.ticketLockVOList?.filter { it.lockId == null }?.size ?: 0
-                    val isNeedKey = equipDetail?.ticketKeyVOList?.filter { it.keyId == null }?.size != 1 && needLockCount == 0
+                    val isNeedKey = equipDetail?.ticketKeyVOList?.filter { it.keyId == null }?.size != 1
                     BusinessManager.checkEquipCount(needLockCount, isNeedKey) { keyPair, lockMap ->
                         val lockList = mutableListOf<LockTakeUpdateReqVO>()
                         lockMap.forEach { (addr, mLockList) ->
@@ -116,9 +116,7 @@ class JobProgressPresenter : BasePresenter<IJobProgressView>() {
                         if (keyPair != null) {
                             BusinessManager.addDeviceTake(DEVICE_TYPE_KEY, ticketId, keyPair.second?.rfid!!)
                             LogUtil.i("工作票挂锁list : $lockList")
-
-                            BusinessManager.getCurrentStatus(BusinessManager.getBleDeviceByMac(keyPair.second?.mac)!!.bleDevice)
-
+                            
 //                            // 下发工作票
 //                            BusinessManager.sendTicketBusiness(
 //                                keyPair.second?.mac!!,