|
|
@@ -2,6 +2,7 @@ package com.grkj.iscs.presentation
|
|
|
|
|
|
import android.content.Intent
|
|
|
import android.os.Environment
|
|
|
+import android.view.View
|
|
|
import com.google.gson.Gson
|
|
|
import com.google.gson.reflect.TypeToken
|
|
|
import com.grkj.iscs.BusinessManager
|
|
|
@@ -12,6 +13,7 @@ import com.grkj.iscs.extentions.toHexStrings
|
|
|
import com.grkj.iscs.modbus.ModBusController
|
|
|
import com.grkj.iscs.model.DeviceConst.DEVICE_TYPE_CARD
|
|
|
import com.grkj.iscs.model.DeviceConst.DOCK_TYPE_PORTABLE
|
|
|
+import com.grkj.iscs.util.ActivityUtils
|
|
|
import com.grkj.iscs.util.Executor
|
|
|
import com.grkj.iscs.util.FileUtil
|
|
|
import com.grkj.iscs.util.ToastUtils
|
|
|
@@ -35,7 +37,7 @@ class PresentationLoginActivity : BaseActivity<ActivityPresentationLoginBinding>
|
|
|
Gson().fromJson(str, object : TypeToken<List<PresentationManager.PCardInfoBean>>() {}.type)
|
|
|
val lockerList = PresentationManager.cardList.filter { it.isLocker }
|
|
|
for (i in lockerList.indices) {
|
|
|
- PresentationManager.mLockerList.add(PresentationManager.PLockerBean("上锁人${i + 1}", lockerList[i].rfid))
|
|
|
+ PresentationManager.mLockerList.add(PresentationManager.PLockerBean("上锁人${i + 1}", lockerList[i].rfid, 0))
|
|
|
}
|
|
|
val togetherList = PresentationManager.cardList.filter { !it.isLocker }
|
|
|
for (i in togetherList.indices) {
|
|
|
@@ -43,7 +45,8 @@ class PresentationLoginActivity : BaseActivity<ActivityPresentationLoginBinding>
|
|
|
PresentationManager.PLockerTogetherBean(
|
|
|
"共锁人${i + 1}",
|
|
|
false,
|
|
|
- togetherList[i].rfid
|
|
|
+ togetherList[i].rfid,
|
|
|
+ 0
|
|
|
)
|
|
|
)
|
|
|
}
|
|
|
@@ -62,22 +65,39 @@ class PresentationLoginActivity : BaseActivity<ActivityPresentationLoginBinding>
|
|
|
when (deviceBean.type) {
|
|
|
DEVICE_TYPE_CARD -> {
|
|
|
ModBusController.readPortalCaseCardRfid(dockBean.addr.toInt() - 1) { res ->
|
|
|
- val rfid = res.copyOfRange(3, 11).toHexStrings(false).removeLeadingZeros()
|
|
|
- println("卡片RFID : $rfid")
|
|
|
- if (PresentationManager.cardList.any { it.rfid == rfid && it.isLocker}) {
|
|
|
- ToastUtils.tip("登录成功,欢迎 $rfid")
|
|
|
- val intent = Intent(this, LockerActivity::class.java)
|
|
|
- intent.putExtra("card", rfid)
|
|
|
- startActivity(intent)
|
|
|
- return@readPortalCaseCardRfid
|
|
|
- } else if (PresentationManager.cardList.any { it.rfid == rfid && !it.isLocker}) {
|
|
|
- ToastUtils.tip("登录成功,欢迎 $rfid")
|
|
|
- val intent = Intent(this, LockerTogetherActivity::class.java)
|
|
|
- intent.putExtra("card", rfid)
|
|
|
- startActivity(intent)
|
|
|
- return@readPortalCaseCardRfid
|
|
|
+ if (res.size >= 11) {
|
|
|
+ val rfid = res.copyOfRange(3, 11).toHexStrings(false).removeLeadingZeros()
|
|
|
+ println("卡片RFID : $rfid")
|
|
|
+ if(window.decorView.visibility != View.VISIBLE) {
|
|
|
+// ToastUtils.tip("当前页面不可见")
|
|
|
+ val current = ActivityUtils.currentActivity()
|
|
|
+ if (current is LockerActivity) {
|
|
|
+ val rst = PresentationManager.checkLocker(rfid)
|
|
|
+ if (rst != null) {
|
|
|
+ current.showDlg(rst)
|
|
|
+ }
|
|
|
+ } else if (current is LockerTogetherActivity) {
|
|
|
+ val rst = PresentationManager.checkTogetherLocker(rfid)
|
|
|
+ if (rst != null) {
|
|
|
+ current.showDlg(rst)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (PresentationManager.cardList.any { it.rfid == rfid && it.isLocker}) {
|
|
|
+ ToastUtils.tip("登录成功,欢迎 $rfid")
|
|
|
+ val intent = Intent(this, LockerActivity::class.java)
|
|
|
+ intent.putExtra("card", rfid)
|
|
|
+ startActivity(intent)
|
|
|
+ } else if (PresentationManager.cardList.any { it.rfid == rfid && !it.isLocker}) {
|
|
|
+ ToastUtils.tip("登录成功,欢迎 $rfid")
|
|
|
+ val intent = Intent(this, LockerTogetherActivity::class.java)
|
|
|
+ intent.putExtra("card", rfid)
|
|
|
+ startActivity(intent)
|
|
|
+ } else {
|
|
|
+ ToastUtils.tip("登录失败,$rfid 没有权限")
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- ToastUtils.tip("登录失败,$rfid 没有权限")
|
|
|
}
|
|
|
}
|
|
|
}
|