Parcourir la source

修复逻辑错误

Frankensteinly il y a 10 mois
Parent
commit
aa13d87df3

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

@@ -711,7 +711,7 @@ object BusinessManager {
                     println("switch mode 1 fail")}
             })
             // 打开钥匙卡扣
-            val keyBean = ModBusController.getKeyByRfid(bleBean.bleDevice.mac)
+            val keyBean = ModBusController.getKeyByMac(bleBean.bleDevice.mac)
             if (keyBean == null) {
                 loadingCallBack.invoke(false, ctx.getString(R.string.simple_key_not_found), false)
                 ToastUtils.tip(R.string.simple_key_not_exists)

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

@@ -368,21 +368,21 @@ object ModBusController {
      * 根据RFID找钥匙
      */
     fun getKeyByRfid(rfid: String): DockBean.KeyBean? {
-        return dockList.find { it.type == DOCK_TYPE_KEY || it.type == DOCK_TYPE_PORTABLE }?.getKeyList()?.find { it.rfid == rfid }
+        return dockList.filter { it.type == DOCK_TYPE_KEY || it.type == DOCK_TYPE_PORTABLE }.flatMap { it.getKeyList() }.find { it.rfid == rfid }
     }
 
     /**
      * 根据Mac找钥匙
      */
     fun getKeyByMac(mac: String): DockBean.KeyBean? {
-        return dockList.find { it.type == DOCK_TYPE_KEY || it.type == DOCK_TYPE_PORTABLE }?.getKeyList()?.find { it.mac == mac }
+        return dockList.filter { it.type == DOCK_TYPE_KEY || it.type == DOCK_TYPE_PORTABLE }.flatMap { it.getKeyList() }.find { it.mac == mac }
     }
 
     /**
      * 根据RFID找锁具
      */
     fun getLockByRfid(rfid: String): DockBean.LockBean? {
-        return dockList.find { it.type == DOCK_TYPE_LOCK || it.type == DOCK_TYPE_PORTABLE }?.getLockList()?.find { it.rfid == rfid }
+        return dockList.filter { it.type == DOCK_TYPE_LOCK || it.type == DOCK_TYPE_PORTABLE }.flatMap { it.getLockList() }.find { it.rfid == rfid }
     }
 
     /**

+ 1 - 0
app/src/main/res/values-zh/strings.xml

@@ -169,4 +169,5 @@
     <string name="simple_tip_process6">流程提示\n等待主锁人解锁后,归还钥匙和挂锁,结束作业票。</string>
     <string name="simple_tip_complete">作业票流程已技术,请返回首页</string>
     <string name="simple_please_wait_for_colocker_to_finish">请等待维修人员完成操作</string>
+    <string name="simple_key_is_not_connected">钥匙未连接</string>
 </resources>

+ 1 - 0
app/src/main/res/values/strings.xml

@@ -169,4 +169,5 @@
     <string name="simple_tip_process6">Process Instructions:\nWait for the primary lock owner to unlock and returnthe key and lock to complete the work permit.</string>
     <string name="simple_tip_complete">The work permit process has been completed.\nPlease return to the homepage.</string>
     <string name="simple_please_wait_for_colocker_to_finish">Waiting for maintenance workers to finish</string>
+    <string name="simple_key_is_not_connected">Key is not connected</string>
 </resources>