Sfoglia il codice sorgente

修复钥匙准备状态更新失败的问题;优化钥匙数量不足时导致的loading一直显示;优化待共锁状态显示异常

Frankensteinly 7 mesi fa
parent
commit
1e48802b13

+ 5 - 4
app/src/main/java/com/grkj/iscs/BusinessManager.kt

@@ -147,7 +147,7 @@ object BusinessManager {
                                     sendLoadingEventMsg(MyApplication.instance?.applicationContext?.getString(R.string.take_out_key_tip))
                                     val dock = ModBusController.getDockByKeyMac(it.data.bleBean.bleDevice.mac)
                                     ModBusController.controlKeyBuckle(true, keyBean.isLeft, dock?.addr)
-                                    keyBean.isReady = false
+                                    ModBusController.updateKeyReadyStatus(it.data.bleBean.bleDevice.mac, false)
                                     ToastUtils.tip(R.string.take_out_key)
                                 }
                             } else {
@@ -160,7 +160,7 @@ object BusinessManager {
                         // 待机模式
                         2 -> {
                             if (it.data.res == 1) {
-                                ModBusController.getKeyByMac(it.data.bleBean.bleDevice.mac)?.isReady = true
+                                ModBusController.updateKeyReadyStatus(it.data.bleBean.bleDevice.mac, true)
                                 // 延时再次获取当前状态,触发handleCurrentMode里工作票下发状态检查
                                 Executor.delayOnMain(500) {
                                     getCurrentStatus(1, it.data.bleBean.bleDevice)
@@ -709,7 +709,7 @@ object BusinessManager {
                     bleDevice.mac?.let { itMac ->
                         unregisterConnectListener(itMac)
                     }
-                    ModBusController.getKeyByMac(bleDevice.mac)?.isReady = false
+                    ModBusController.updateKeyReadyStatus(bleDevice.mac, false)
                     if (!isActiveDisConnected) {
                         // 测试模式下不重连
                         if (isTestMode) {
@@ -1317,7 +1317,8 @@ object BusinessManager {
                             }
                         }
                     } ?: let {
-                        key.isReady = true
+                        ModBusController.updateKeyReadyStatus(currentModeMsg.bleBean.bleDevice.mac, true)
+                        sendLoadingEventMsg(null, false)
                     }
                 }
             }

+ 10 - 1
app/src/main/java/com/grkj/iscs/modbus/ModBusController.kt

@@ -436,6 +436,13 @@ object ModBusController {
         return dockList.filter { it.type == DOCK_TYPE_LOCK || it.type == DOCK_TYPE_PORTABLE }.flatMap { it.getLockList() }.find { it.rfid == rfid }
     }
 
+    /**
+     * 更新钥匙的准备状态
+     */
+    fun updateKeyReadyStatus(mac: String, isReady: Boolean) {
+        dockList.find { it.type == DOCK_TYPE_KEY || it.type == DOCK_TYPE_PORTABLE }?.getKeyList()?.find { it.mac == mac }?.isReady = isReady
+    }
+
     /**
      * 根据钥匙Mac获取底座
      */
@@ -531,7 +538,9 @@ object ModBusController {
         }
 
         keyList.forEach {
-            LogUtil.i("keyStatus : ${it.isExist} - ${it.rfid} - ${it.mac} - ${BusinessManager.getBleDeviceByMac(it.mac!!)?.bleDevice} - ${BleManager.getInstance().isConnected(BusinessManager.getBleDeviceByMac(it.mac!!)?.bleDevice)}")
+            LogUtil.i("keyStatus : ${it.isExist} - ${it.rfid} - ${it.mac} - ${it.isReady} - " +
+                    "${BusinessManager.getBleDeviceByMac(it.mac!!)?.bleDevice == null} - " +
+                    "${BleManager.getInstance().isConnected(BusinessManager.getBleDeviceByMac(it.mac!!)?.bleDevice)}")
         }
         val key = keyList.find { it.isExist && it.rfid != null && it.mac != null && it.isReady &&
                 BleManager.getInstance().isConnected(BusinessManager.getBleDeviceByMac(it.mac!!)?.bleDevice) }

+ 13 - 11
app/src/main/java/com/grkj/iscs/view/fragment/JobProgressFragment.kt

@@ -114,21 +114,23 @@ class JobProgressFragment(val goBack: () -> Unit) :
 
     override fun refreshPage(pageChangeBO: PageChangeBO) {
         mPageChangeBO = pageChangeBO
-        presenter?.getTicketDetailMonitor(pageChangeBO.ticketId!!) {
-            mPointList.clear()
-            mUserList.clear()
-            mPointList.addAll(it?.ticketPointsList!!)
-            mUserList.addAll(it.colockUserList!!)
-            mBinding?.rvPoint?.adapter?.notifyDataSetChanged()
-            mBinding?.rvColocker?.adapter?.notifyDataSetChanged()
-            handleActionBtnVisibility()
-            handleBottomTip(pageChangeBO.ticketId)
-        }
+
         presenter?.getTicketDetail(pageChangeBO.ticketId) {
             mBinding?.tvTitle?.text = it?.ticketName
         }
 
-        getStepDetail(pageChangeBO.ticketId!!)
+        getStepDetail(pageChangeBO.ticketId!!) {
+            presenter?.getTicketDetailMonitor(pageChangeBO.ticketId!!) {
+                mPointList.clear()
+                mUserList.clear()
+                mPointList.addAll(it?.ticketPointsList!!)
+                mUserList.addAll(it.colockUserList!!)
+                mBinding?.rvPoint?.adapter?.notifyDataSetChanged()
+                mBinding?.rvColocker?.adapter?.notifyDataSetChanged()
+                handleActionBtnVisibility()
+                handleBottomTip(pageChangeBO.ticketId)
+            }
+        }
     }
 
     fun getCardNo(cardNo: String) {

+ 9 - 3
app/src/main/java/com/grkj/iscs/view/presenter/JobProgressPresenter.kt

@@ -129,7 +129,11 @@ class JobProgressPresenter : BasePresenter<IJobProgressView>() {
                             BusinessManager.sendLoadingEventMsg(mContext?.getString(R.string.take_out_lock_tip, lockList.size))
                         }
                         // null表示锁具数量不够,不给钥匙
-                        if (keyPair != null) {
+                        if (keyPair == null) {
+                            if (BusinessManager.mDeviceTakeList.none { it.ticketId == ticketId }) {
+                                BusinessManager.sendLoadingEventMsg(null, false)
+                            }
+                        } else {
                             BusinessManager.addDeviceTake(DEVICE_TYPE_KEY, ticketId, keyPair.second?.rfid!!)
                         }
                     }
@@ -154,9 +158,11 @@ class JobProgressPresenter : BasePresenter<IJobProgressView>() {
             }
             BusinessManager.checkEquipCount(0, true) { keyPair, _ ->
                 // null表示锁具数量不够,不给钥匙
-                if (keyPair != null) {
+                if (keyPair == null) {
+                    BusinessManager.sendLoadingEventMsg(null, false)
+                } else {
                     BusinessManager.addDeviceTake(DEVICE_TYPE_KEY, ticketId, keyPair.second?.rfid!!)
-                    
+
                     BusinessManager.getCurrentStatus(5, BusinessManager.getBleDeviceByMac(keyPair.second?.mac)!!.bleDevice)
                 }
             }