|
@@ -6,9 +6,11 @@ import com.grkj.iscs.BusinessManager
|
|
|
import com.grkj.iscs.R
|
|
import com.grkj.iscs.R
|
|
|
import com.grkj.iscs.databinding.FragmentSettingBinding
|
|
import com.grkj.iscs.databinding.FragmentSettingBinding
|
|
|
import com.grkj.iscs.extentions.setSelected
|
|
import com.grkj.iscs.extentions.setSelected
|
|
|
|
|
+import com.grkj.iscs.modbus.ModBusController
|
|
|
import com.grkj.iscs.modbus.ModBusController.controlKeyBuckle
|
|
import com.grkj.iscs.modbus.ModBusController.controlKeyBuckle
|
|
|
import com.grkj.iscs.modbus.ModBusController.controlLockBuckle
|
|
import com.grkj.iscs.modbus.ModBusController.controlLockBuckle
|
|
|
import com.grkj.iscs.modbus.ModBusController.dockList
|
|
import com.grkj.iscs.modbus.ModBusController.dockList
|
|
|
|
|
+import com.grkj.iscs.model.DeviceConst
|
|
|
import com.grkj.iscs.model.DeviceConst.DOCK_TYPE_KEY
|
|
import com.grkj.iscs.model.DeviceConst.DOCK_TYPE_KEY
|
|
|
import com.grkj.iscs.model.DeviceConst.DOCK_TYPE_LOCK
|
|
import com.grkj.iscs.model.DeviceConst.DOCK_TYPE_LOCK
|
|
|
import com.grkj.iscs.model.DeviceConst.DOCK_TYPE_PORTABLE
|
|
import com.grkj.iscs.model.DeviceConst.DOCK_TYPE_PORTABLE
|
|
@@ -46,8 +48,7 @@ class SettingFragment : BaseFragment<FragmentSettingBinding>() {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- // 不拿的设备不归你,下次登录重新按需分配
|
|
|
|
|
- BusinessManager.mDeviceTakeList.clear()
|
|
|
|
|
|
|
+ reConnectKey()
|
|
|
BusinessManager.sendLoadingEventMsg(null, false)
|
|
BusinessManager.sendLoadingEventMsg(null, false)
|
|
|
startActivity(Intent(context, LoginActivity::class.java))
|
|
startActivity(Intent(context, LoginActivity::class.java))
|
|
|
}
|
|
}
|
|
@@ -77,4 +78,35 @@ class SettingFragment : BaseFragment<FragmentSettingBinding>() {
|
|
|
mBinding?.vp?.offscreenPageLimit = 2
|
|
mBinding?.vp?.offscreenPageLimit = 2
|
|
|
mBinding?.vp?.adapter = pageAdapter
|
|
mBinding?.vp?.adapter = pageAdapter
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 钥匙重新连接,清除内部作业票,清除所有代取设备重新分配
|
|
|
|
|
+ */
|
|
|
|
|
+ private fun reConnectKey() {
|
|
|
|
|
+ val keyList = BusinessManager.mDeviceTakeList.filter { it.deviceType == DeviceConst.DEVICE_TYPE_KEY }
|
|
|
|
|
+ // 不拿的设备不归你,下次登录重新按需分配
|
|
|
|
|
+ // 尽早clear,防止触发handleCurrentMode导致重新下发作业票
|
|
|
|
|
+ BusinessManager.mDeviceTakeList.clear()
|
|
|
|
|
+ // 连接后直接切换待机模式,让钥匙作业票失效并且重新准备完毕
|
|
|
|
|
+ keyList.forEach {
|
|
|
|
|
+ val mac = ModBusController.getKeyByRfid(it.nfc)?.mac
|
|
|
|
|
+ if (mac == null) {
|
|
|
|
|
+ NetApi.getKeyInfo(it.nfc) { keyInfo ->
|
|
|
|
|
+ keyInfo?.macAddress?.let { itMac ->
|
|
|
|
|
+ BusinessManager.registerConnectListener(itMac) { isDone, bleBean ->
|
|
|
|
|
+ if (isDone && bleBean != null) {
|
|
|
|
|
+ BusinessManager.switchReadyMode(bleBean.bleDevice)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ BusinessManager.registerConnectListener(mac) { isDone, bleBean ->
|
|
|
|
|
+ if (isDone && bleBean != null) {
|
|
|
|
|
+ BusinessManager.switchReadyMode(bleBean.bleDevice)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|