InquiryActivity.kt 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672
  1. package com.example.chemical.ui.inquiry
  2. import android.content.IntentFilter
  3. import android.hardware.usb.UsbManager
  4. import android.os.Bundle
  5. import android.os.CountDownTimer
  6. import android.os.Handler
  7. import android.os.Looper
  8. import android.view.KeyEvent
  9. import android.view.LayoutInflater
  10. import android.view.View
  11. import android.widget.AdapterView
  12. import androidx.recyclerview.widget.LinearLayoutManager
  13. import com.blankj.utilcode.util.LogUtils
  14. import com.bumptech.glide.Glide
  15. import com.bumptech.glide.load.engine.DiskCacheStrategy
  16. import com.bumptech.glide.request.RequestOptions
  17. import com.chad.library.adapter.base.util.getItemView
  18. import com.example.chemical.ChemicalApp
  19. import com.example.chemical.R
  20. import com.example.chemical.databinding.ActivityInquiryBinding
  21. import com.example.chemical.receiver.OnSerialScanListener
  22. import com.example.chemical.receiver.PortScanHelper
  23. import com.example.chemical.receiver.UsbReceiver
  24. import com.example.chemical.ui.SplashActivity
  25. import com.example.chemical.ui.adapter.CabinetDoorAdapter
  26. import com.example.chemical.ui.adapter.CabinetDoorRighAdapter
  27. import com.example.chemical.ui.common.BaseCountDownActivity
  28. import com.example.chemical.ui.fragments.QueryOneFragment
  29. import com.example.chemical.ui.fragments.QueryTwoFragment
  30. import com.example.chemical.ui.login.FacialCardActivity
  31. import com.example.chemical.ui.login.FacialLoginActivity
  32. import com.example.chemical.ui.login.ScanLoginActivity
  33. import com.example.chemical.ui.login.SwipeActivity
  34. import com.example.chemical.utils.*
  35. import com.example.chemical.weidith.*
  36. import com.rc.core.log.RcLog
  37. import com.rc.httpcore.HttpConfig
  38. import com.rc.httpcore.bean.*
  39. import com.rc.httpcore.client.ApiRepository
  40. import org.greenrobot.eventbus.EventBus
  41. import org.greenrobot.eventbus.Subscribe
  42. import org.greenrobot.eventbus.ThreadMode
  43. //化学品-查询 已登录-未登录 未登录-扫码弹框提示当前某一个信息 已登陆 显示所有列表
  44. class InquiryActivity : BaseCountDownActivity<ActivityInquiryBinding>() {
  45. private lateinit var timeUpdater: TimeUpdater
  46. private var logIn = 0 //未登录
  47. private var mUsbReceiver: UsbReceiver? = null // 刷卡广播注册
  48. private var mHandleScanEvent = false //当前是否已经获取过 usb返回的参数
  49. private val mAdapterLeft by lazy { CabinetDoorAdapter(this) } //左边柜子
  50. private val mAdapterRigh by lazy { CabinetDoorRighAdapter(this) } //右边柜子
  51. private lateinit var viewPager: SwipeViewPager
  52. private lateinit var pagerAdapter: TabFragmentPagerAdapter
  53. private var mLeftPosition = 0 //左边柜子信息
  54. private var mCabinetLockVoList: List<LockVoListBean>? = null //柜锁会又多个
  55. private var mLockStr = ArrayList<String>() // 需要打开得柜锁数量
  56. private val handlerUtil = HandlerUtil.getInstance()
  57. private var mCabinetId: String? = null
  58. private var mCabinetName: String? = null
  59. private var mDoorId: String? = null
  60. private var mDoorName: String? = null
  61. private lateinit var faceList: List<String>//人员区间值
  62. private var mLoginType: String? = null //登录方式
  63. override fun createViewBinding() = ActivityInquiryBinding.inflate(LayoutInflater.from(this))
  64. override fun initViews(savedInstanceState: Bundle?) {
  65. super.initViews(savedInstanceState)
  66. logIn = intent.getIntExtra("logIn", 0)
  67. val stringExtra = intent.getStringExtra("cabinetId")
  68. val stringExtra1 = intent.getStringExtra("doorId")
  69. if (!stringExtra.equals("a")) {
  70. mCabinetId = stringExtra
  71. mDoorId = stringExtra1
  72. }
  73. viewBinding.tvReturn.text = "返回${ChemicalApp.confs!!.backTime}s"
  74. //注册广播
  75. EventBus.getDefault().register(this)
  76. viewBinding.tvOutLogin.setOnClickListener {
  77. callLogoutApi {
  78. ChemicalApp.userData = null
  79. // HttpClient.token = null
  80. ChemicalApp.subjectId = null
  81. UiManager.switcherCashier(this, SplashActivity::class.java)
  82. }
  83. }
  84. if (logIn == 1) {
  85. // mHandleScanEvent = true
  86. //已登录
  87. viewBinding.loggedIn.visibility = View.VISIBLE
  88. viewBinding.tvName.text = "${ChemicalApp.userData!!.userName}"
  89. viewBinding.relOne.visibility = View.GONE
  90. getCabinet(ChemicalApp.subjectId!!)
  91. RcLog.info("=====$mCabinetId")
  92. RcLog.info("=====$mDoorId")
  93. fragmentInView()
  94. inAdapter()
  95. viewBinding.tvReturn.text = "返回${ChemicalApp.confs!!.backTime}s"
  96. } else {
  97. mLoginType = ChemicalApp.confs!!.loginType
  98. //未登录
  99. viewBinding.loggedIn.visibility = View.GONE
  100. viewBinding.tvName.visibility = View.GONE
  101. }
  102. viewBinding.logIn.setOnClickListener {
  103. getUserIds()
  104. }
  105. initTitle()
  106. viewBinding.tvReturn.setOnClickListener {
  107. finish()
  108. }
  109. //校园级管理员-柜门管理员-柜锁管理员-安全负责人-实验室负责人
  110. viewBinding.butOpen.setOnClickListener {
  111. if (ChemicalApp.administrators || ChemicalApp.responsibles) {
  112. if (mCabinetLockVoList != null && mCabinetLockVoList!!.size > 0) {
  113. mLockStr.clear()
  114. mCabinetLockVoList!!.forEach { it ->
  115. when (it.unlockingMethod) {
  116. 2 -> { //智能锁
  117. mLockStr.add("${it.lockNum}")
  118. }
  119. }
  120. }
  121. if (mLockStr != null && mLockStr.size > 0) {
  122. openLock(mLockStr)
  123. } else {
  124. //无锁
  125. customDialogView(1, "柜门已开")
  126. }
  127. } else {
  128. //无锁
  129. customDialogView(1, "柜门已开")
  130. }
  131. } else {
  132. showToast("无权限信息")
  133. }
  134. }
  135. }
  136. private fun initTitle() {
  137. if (ChemicalApp.userData != null) {
  138. viewBinding.logIn.visibility = View.GONE
  139. viewBinding.tvName.text = ChemicalApp.userData!!.userName
  140. val imageView = viewBinding.imageName
  141. // 使用 Glide 加载网络图片
  142. Glide.with(this)
  143. .load("${HttpConfig.API_BASE_IMG_URL}${ChemicalApp.userData!!.avatar}")
  144. .apply(RequestOptions.diskCacheStrategyOf(DiskCacheStrategy.AUTOMATIC))
  145. .into(imageView)
  146. }
  147. // 使用 Glide 加载网络图片
  148. viewBinding.deptName.text = "${ChemicalApp.confs!!.deptName}-${ChemicalApp.confs!!.roomNum}"
  149. Glide.with(this)
  150. .load("${HttpConfig.API_BASE_IMG_URL}${ChemicalApp.confs!!.circularLogo}")
  151. .apply(RequestOptions.diskCacheStrategyOf(DiskCacheStrategy.AUTOMATIC))
  152. .into(viewBinding.image)
  153. }
  154. private fun fragmentInView() {
  155. val tabArray = mutableListOf(
  156. QueryOneFragment.newInstance(),
  157. QueryTwoFragment.newInstance(),
  158. )
  159. pagerAdapter = TabFragmentPagerAdapter(supportFragmentManager, tabArray)
  160. viewPager = viewBinding.swipePagerView
  161. viewPager.adapter = pagerAdapter
  162. }
  163. private fun inAdapter() {
  164. viewBinding.recyclerViewListLeft?.layoutManager = LinearLayoutManager(this)
  165. viewBinding.recyclerViewListLeft?.adapter = mAdapterLeft
  166. viewBinding.recyclerViewListRight?.layoutManager = LinearLayoutManager(this)
  167. viewBinding.recyclerViewListRight?.adapter = mAdapterRigh
  168. mAdapterLeft.setOnItemClickListener { adapter, view, position ->
  169. mLeftPosition = position
  170. mAdapterLeft.data.forEach { it.isType = false }
  171. mAdapterLeft.data[position].isType = true
  172. mAdapterRigh.data.forEach { it.isType = false } //柜门初始化
  173. mAdapterLeft.notifyDataSetChanged()
  174. if (mAdapterLeft.data[mLeftPosition].cabinetDoorVoList != null) {
  175. mCabinetId = mAdapterLeft.data[mLeftPosition].cabinetId
  176. mCabinetName = mAdapterLeft.data[mLeftPosition].cabinetName
  177. mAdapterRigh.setNewInstance(mAdapterLeft.data[mLeftPosition].cabinetDoorVoList.toMutableList())
  178. }
  179. }
  180. mAdapterRigh.setOnItemClickListener { adapter, view, position ->
  181. mDoorId = mAdapterRigh.data[position].doorUniqueId
  182. mDoorName = mAdapterRigh.data[position].doorName
  183. mCabinetLockVoList = mAdapterRigh.data[position].cabinetLockVoList
  184. mAdapterRigh.data.forEach { it.isType = false }
  185. mAdapterRigh.data[position].isType = true
  186. mAdapterRigh.notifyDataSetChanged()
  187. //第一个页面
  188. goQueryTwoFragment()
  189. if (mCabinetLockVoList != null && mCabinetLockVoList!!.size > 0) {
  190. var isLock = false
  191. mCabinetLockVoList!!.forEach { it ->
  192. if (it.unlockingMethod == 2) {
  193. isLock = true
  194. return@forEach
  195. }
  196. }
  197. if (isLock) {
  198. viewBinding.butOpen.visibility = View.VISIBLE
  199. } else {
  200. viewBinding.butOpen.visibility = View.GONE
  201. }
  202. }
  203. }
  204. }
  205. override fun initData() {
  206. super.initData()
  207. val handler = Handler(Looper.getMainLooper())
  208. timeUpdater = TimeUpdater(handler) { currentTime ->
  209. viewBinding.nowTime.text = "$currentTime"
  210. }
  211. // 启动定时更新
  212. timeUpdater.startUpdating()
  213. }
  214. //查询存储位置 默认第一个
  215. private fun getCabinet(subId: String) {
  216. showLoading("查询中...")
  217. val disposable = ApiRepository.getCabinetList(subId)
  218. .subscribe({ data ->
  219. dismissLoading()
  220. mAdapterLeft.setNewInstance(data.toMutableList())
  221. mAdapterRigh.setNewInstance(data[0].cabinetDoorVoList.toMutableList())
  222. if (mCabinetId != null) {
  223. mAdapterLeft.data.forEachIndexed { index, ruleBean ->
  224. if (mCabinetId.equals(ruleBean.cabinetId)) {
  225. mAdapterLeft.data[index].isType = true
  226. mAdapterLeft.data[index].cabinetDoorVoList.forEachIndexed { index, ruleBean ->
  227. if (mDoorId.equals(ruleBean.doorUniqueId)) {
  228. mAdapterRigh.data[index].isType = true
  229. return@forEachIndexed
  230. }
  231. }
  232. return@forEachIndexed
  233. }
  234. }
  235. } else {
  236. //初始化第一把锁
  237. mCabinetId = mAdapterLeft.data[0].cabinetId
  238. mCabinetName = mAdapterLeft.data[0].cabinetName
  239. mAdapterLeft.data[0].isType = true
  240. mDoorId = mAdapterRigh.data[0].doorUniqueId
  241. mDoorName = mAdapterRigh.data[0].doorName
  242. mAdapterRigh.data[0].isType = true
  243. mCabinetLockVoList = mAdapterLeft.data[0].cabinetDoorVoList[0].cabinetLockVoList
  244. if (mCabinetLockVoList != null && mCabinetLockVoList!!.size > 0) {
  245. var isLock = false
  246. mCabinetLockVoList!!.forEach { it ->
  247. if (it.unlockingMethod == 2) {
  248. isLock = true
  249. return@forEach
  250. }
  251. }
  252. if (isLock) {
  253. viewBinding.butOpen.visibility = View.VISIBLE
  254. } else {
  255. viewBinding.butOpen.visibility = View.GONE
  256. }
  257. }
  258. }
  259. LogUtils.d()
  260. //第一个页面
  261. goQueryTwoFragment()
  262. }, { throwable ->
  263. dismissLoading()
  264. showNetError(throwable)
  265. })
  266. addDisposable(disposable)
  267. }
  268. fun goQueryTwoFragment(stockId: String, hxpStockWaitListBean: HxpStockWaitListBean) {
  269. val secondFragment = pagerAdapter.getItem(1) as QueryTwoFragment
  270. secondFragment.setData(stockId, hxpStockWaitListBean, mCabinetId, mDoorId)
  271. viewPager.currentItem = 1
  272. }
  273. private fun goQueryTwoFragment() {
  274. val secondFragment = pagerAdapter.getItem(0) as QueryOneFragment
  275. secondFragment.upDatas(mCabinetId, mDoorId)
  276. viewPager.currentItem = 0
  277. }
  278. //=========================刷卡start================
  279. //刷卡信息 调用当前化学品信息 进行归还
  280. private fun handleScanEvent(cont: String) {
  281. if (logIn == 1) {
  282. //已登录
  283. showLoading("查询中...")
  284. val disposable = ApiRepository.getStockDetailsByCode(cont)
  285. .subscribe({ data ->
  286. dismissLoading()
  287. upViewTwo(data)
  288. }, { throwable ->
  289. dismissLoading()
  290. showNetError(throwable)
  291. mHandleScanEvent = false
  292. })
  293. addDisposable(disposable)
  294. } else {
  295. //未登录
  296. showLoading("查询中...")
  297. val disposable = ApiRepository.indexDetailbyRfid(cont)
  298. .subscribe({ data ->
  299. dismissLoading()
  300. upView(data)
  301. }, { throwable ->
  302. dismissLoading()
  303. showNetError(throwable)
  304. mHandleScanEvent = false
  305. })
  306. addDisposable(disposable)
  307. }
  308. }
  309. //未登录
  310. private fun upView(data: UseNoBean) {
  311. val proDialog = PromptDialog(this, data)
  312. if (!this.isFinishing && !this.isDestroyed) {
  313. proDialog.show()
  314. }
  315. mHandleScanEvent = false
  316. }
  317. //已登录
  318. private fun upViewTwo(data: UseNoTwoBean) {
  319. val scanCodeDialog = ScanCodeDialog(this, data)
  320. if (!this.isFinishing && !this.isDestroyed) {
  321. scanCodeDialog.show()
  322. }
  323. mHandleScanEvent = false
  324. }
  325. private val mPortScanHelper by lazy {
  326. PortScanHelper(this, object : OnSerialScanListener {
  327. override fun dispatchScanEvent(type: OnSerialScanListener.ScanType, content: String) {
  328. if (!mHandleScanEvent) {
  329. if (content.isNotBlank()) {
  330. mHandleScanEvent = true
  331. //所有通过查询二维码的参数 需要先判断 http开头的 然后进行截取
  332. if (content.startsWith("http")) {
  333. try {
  334. RcLog.info("=======查询扫码 $content")
  335. val currentDateTimeString =
  336. BigDecimalUtils.extractParameterValue(content, "code")
  337. RcLog.info("=======查询扫码 $currentDateTimeString")
  338. handleScanEvent(currentDateTimeString!!)
  339. } catch (e: Exception) {
  340. mHandleScanEvent = false
  341. showToast("扫描异常,请重操作")
  342. }
  343. } else {
  344. handleScanEvent(content)
  345. }
  346. }
  347. }
  348. }
  349. })
  350. }
  351. //刷卡usb链接
  352. private fun registerUsbBroadcast() {
  353. if (null == mUsbReceiver) {
  354. val filter = IntentFilter().apply {
  355. addAction(UsbReceiver.ACTION_USB_PERMISSION)
  356. addAction(UsbManager.ACTION_USB_DEVICE_ATTACHED)
  357. addAction(UsbManager.ACTION_USB_DEVICE_DETACHED)
  358. addAction(UsbReceiver.ACTION_USB_STATE) // usb连接状态广播
  359. }
  360. mUsbReceiver = UsbReceiver()
  361. registerReceiver(mUsbReceiver, filter)
  362. }
  363. }
  364. override fun onResume() {
  365. super.onResume()
  366. mPortScanHelper.onResume()
  367. registerUsbBroadcast()
  368. }
  369. //获取刷卡信息
  370. override fun dispatchKeyEvent(event: KeyEvent?): Boolean {
  371. mPortScanHelper.dispatchKeyEvent(event)
  372. return super.dispatchKeyEvent(event)
  373. }
  374. //停止 销毁广播传递
  375. override fun onPause() {
  376. mPortScanHelper.onPause()
  377. super.onPause()
  378. }
  379. override fun onDestroy() {
  380. super.onDestroy()
  381. mPortScanHelper.onPause()
  382. try {
  383. handlerUtil.stopAllTasks()
  384. countdownTimer?.cancel()
  385. } catch (e: Exception) {
  386. }
  387. try {
  388. timeUpdater.stopUpdating()
  389. } catch (e: Exception) {
  390. }
  391. // 停止定时更新
  392. unregisterReceiver(mUsbReceiver)
  393. EventBus.getDefault().unregister(this) //关闭广播
  394. }
  395. //必须写这个方法 防止注册失败
  396. @Subscribe(threadMode = ThreadMode.MAIN)
  397. fun onUpdateEventEvent(event: KeyEvent) {
  398. }
  399. //=========================刷卡end==================
  400. override fun onBackPressed() {
  401. super.onBackPressed()
  402. finish()
  403. }
  404. //==========================开锁信息===================
  405. //=================开锁流程================
  406. private fun openLock(mLockStr: ArrayList<String>) {
  407. val map = mutableMapOf<String, Any>()
  408. map["subId"] = ChemicalApp.subjectId!!
  409. map["subName"] = ChemicalApp.subjectName!!
  410. map["cabinetId"] = "$mCabinetId"
  411. map["cabinetName"] = "$mCabinetName"
  412. map["doorId"] = "$mDoorId"
  413. map["doorName"] = "$mDoorName"
  414. map["lockNumList"] = mLockStr
  415. map["operationType"] = 6
  416. if (ChemicalApp.subRoom != null) {
  417. map["subRoom"] = ChemicalApp.subRoom!!
  418. }
  419. map["type"] = true
  420. try {// 从 SharedPreferences 中取出集合
  421. val retrievedList = SharedPreferencesHelper.getList(this)
  422. if (retrievedList != null && retrievedList.size > 0) {
  423. RcLog.info("从本地取出得双人信息${retrievedList[0].name}")
  424. map["oneUserId"] = "${retrievedList[0].userId}"
  425. map["oneUserName"] = "${retrievedList[0].name}"
  426. map["twoUserId"] = "${retrievedList[1].userId}"
  427. map["twoUserName"] = "${retrievedList[1].name}"
  428. // 清空 SharedPreferences 中的集合
  429. // SharedPreferencesHelper.clearList(this)
  430. }
  431. } catch (e: Exception) {
  432. }
  433. showLoading("加载中...")
  434. val disposable = ApiRepository.lockOperate(map)
  435. .subscribe({ data ->
  436. dismissLoading()
  437. val containsFalse =
  438. mCabinetLockVoList!!.any { it.isOk == false && it.unlockingMethod == 2 }
  439. if (containsFalse) {
  440. showLoading("查询中...")
  441. startCountdownLock()
  442. // 开始执行任务,每 1 秒执行一次
  443. handlerUtil.startTask(task, 1000)
  444. }
  445. }, { throwable ->
  446. dismissLoading()
  447. showNetError(throwable)
  448. })
  449. addDisposable(disposable)
  450. }
  451. private var countdownTimer: CountDownTimer? = null
  452. private fun startCountdownLock() {
  453. val totalTime = 30 * 1000 // 30秒
  454. val interval = 1000 // 每秒更新一次
  455. countdownTimer = object : CountDownTimer(totalTime.toLong(), interval.toLong()) {
  456. override fun onTick(millisUntilFinished: Long) {
  457. val secondsLeft = millisUntilFinished / 1000
  458. println("剩余时间: $secondsLeft 秒")
  459. }
  460. override fun onFinish() {
  461. println("倒计时结束!")
  462. mCabinetLockVoList = null
  463. mLockStr.clear()
  464. showToast("开锁超时,可重新操作")
  465. dismissLoading()
  466. handlerUtil.stopAllTasks()
  467. // 在这里执行合适的操作,比如退出应用程序
  468. }
  469. }
  470. println("倒计时开始...")
  471. countdownTimer?.start()
  472. }
  473. private val task = Runnable {
  474. //判断所有的锁开锁成功
  475. val containsFalse = mCabinetLockVoList!!.any { it.isOk == false && it.unlockingMethod == 2 }
  476. if (containsFalse) {
  477. getLocks()
  478. } else {
  479. dismissLoading()
  480. //开锁成功
  481. customDialogView(1, "柜门已开")
  482. MediaPlayerHelper.playRawMp3(this, R.raw.guimenkai)
  483. handlerUtil.stopAllTasks()
  484. countdownTimer?.cancel()
  485. }
  486. }
  487. //查询开锁信息
  488. private fun getLocks() {
  489. mCabinetLockVoList!!.forEachIndexed { index, fruit ->
  490. if (fruit.isOk == false && fruit.unlockingMethod == 2) {
  491. getLocksDate(index, fruit.lockNum)
  492. }
  493. }
  494. }
  495. //查询开锁状态
  496. private fun getLocksDate(index: Int, fruit: String) {
  497. val disposable = ApiRepository.getLocks(ChemicalApp.subjectId!!, fruit)
  498. .subscribe({ data ->
  499. if (data) {
  500. mCabinetLockVoList!![index].isOk = true
  501. }
  502. }, { throwable ->
  503. dismissLoading()
  504. showNetError(throwable)
  505. })
  506. addDisposable(disposable)
  507. }
  508. /**
  509. * 0 没有图标 1 绿色(成功) 2红色(失败)
  510. * 失败或者成功的弹框
  511. */
  512. private fun customDialogView(types: Int, msg: String) {
  513. val customDialog = CustomDialog(this, types, msg)
  514. if (!this.isFinishing && !this.isDestroyed) {
  515. customDialog.show()
  516. }
  517. }
  518. private fun getUserIds() {
  519. if (ChemicalApp.subjectId != null) {
  520. showLoading("查询中...")
  521. val disposable = ApiRepository.getUserIds(ChemicalApp.subjectId!!)
  522. .subscribe({ data ->
  523. dismissLoading()
  524. faceList = data
  525. getLogin()
  526. }, { throwable ->
  527. dismissLoading()
  528. // throwableView(throwable)
  529. })
  530. addDisposable(disposable)
  531. }
  532. }
  533. //登录方式
  534. private fun getLogin() {
  535. if (mLoginType == null) {
  536. customDialogView(2, "登录方式配置有误")
  537. } else {
  538. finish()
  539. if (mLoginType!!.contains("4")) {
  540. //需要刷卡+人脸
  541. UiManager.switcher(this, FacialCardActivity::class.java)
  542. } else {
  543. val map = mutableMapOf<String, String>()
  544. //1人脸 2刷卡 3扫码 4人脸+刷卡
  545. if (mLoginType!!.length == 1) {
  546. when (mLoginType) {
  547. "1" -> {
  548. //人脸
  549. map["faceList"] = faceList.toString()
  550. map["mtypes"] = "1"
  551. UiManager.switcher(this, map, FacialLoginActivity::class.java)
  552. }
  553. "2" -> {
  554. //刷卡
  555. map["mtypes"] = "1"
  556. UiManager.switcher(this, map, SwipeActivity::class.java)
  557. }
  558. else -> {
  559. //扫码
  560. map["mtypes"] = "1"
  561. UiManager.switcher(this, map, ScanLoginActivity::class.java)
  562. }
  563. }
  564. } else {
  565. val array = mLoginType!!.split(",").toTypedArray()
  566. when (array.size) {
  567. 2 -> {
  568. //1-2(人脸+刷卡) 1-3(人脸+扫码) 2-3(刷卡+扫码)
  569. if (mLoginType == "1,2" || mLoginType == "2,1") {
  570. //人脸+刷卡
  571. map["faceList"] = faceList.toString()
  572. map["mtypes"] = "4" //隐藏扫码
  573. UiManager.switcher(this, map, FacialLoginActivity::class.java)
  574. } else if (mLoginType == "1,3" || mLoginType == "3,1") {
  575. //人脸+扫码
  576. map["faceList"] = faceList.toString()
  577. map["mtypes"] = "5" //隐藏刷卡
  578. UiManager.switcher(this, map, FacialLoginActivity::class.java)
  579. } else if (mLoginType == "2,3" || mLoginType == "3,2") {
  580. //刷卡+扫码
  581. map["mtypes"] = "6" //隐藏人脸
  582. UiManager.switcher(this, map, SwipeActivity::class.java)
  583. } else {
  584. showToast("登录方式$mLoginType")
  585. }
  586. }
  587. else -> {
  588. //3条
  589. try {
  590. map["mtypes"] = "0"
  591. map["faceList"] = faceList.toString()
  592. UiManager.switcher(this, map, FacialLoginActivity::class.java)
  593. } catch (e: Exception) {
  594. map["mtypes"] = "0"
  595. UiManager.switcher(this, map, SwipeActivity::class.java)
  596. }
  597. }
  598. }
  599. }
  600. }
  601. }
  602. }
  603. }