Browse Source

refactor(更新) :
- 流程调整

周文健 5 months ago
parent
commit
20ac8e5412

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

@@ -167,6 +167,7 @@ object BusinessManager {
                                     sendLoadingEventMsg(CommonUtils.getStr(R.string.take_out_key_tip))
                                     val dock =
                                         ModBusController.getDockByKeyMac(it.data.bleBean.bleDevice.mac)
+                                    keyBean.isReady = false
                                     ModBusController.controlKeyBuckle(
                                         true,
                                         keyBean.isLeft,
@@ -349,28 +350,28 @@ object BusinessManager {
                 DOCK_TYPE_KEY -> {
                     dockBean.getKeyList().forEach { keyBean ->
                         if (keyBean.isExist) {
-                            // 放回钥匙,上锁
-                            ModBusController.controlKeyBuckle(
-                                false,
-                                keyBean.isLeft,
-                                dockBean.addr
-                            ) {
-                                // 放回钥匙,读取rfid
-                                ModBusController.readKeyRfid(
+                            // 放回钥匙,读取rfid
+                            ModBusController.readKeyRfid(
+                                dockBean.addr,
+                                if (keyBean.isLeft) 0 else 1
+                            ) { isLeft, res ->
+                                if (res.size < 11) {
+                                    LogUtil.e("Key rfid error")
+                                    return@readKeyRfid
+                                }
+                                val rfid = res.copyOfRange(3, 11).toHexStrings(false)
+                                    .removeLeadingZeros()
+                                ModBusController.updateKeyRfid(
                                     dockBean.addr,
-                                    if (keyBean.isLeft) 0 else 1
-                                ) { isLeft, res ->
-                                    if (res.size < 11) {
-                                        LogUtil.e("Key rfid error")
-                                        return@readKeyRfid
-                                    }
-                                    val rfid = res.copyOfRange(3, 11).toHexStrings(false)
-                                        .removeLeadingZeros()
-                                    ModBusController.updateKeyRfid(
-                                        dockBean.addr,
-                                        keyBean.isLeft,
-                                        rfid
-                                    )
+                                    keyBean.isLeft,
+                                    rfid
+                                )
+                                // 放回钥匙,上锁
+                                ModBusController.controlKeyBuckle(
+                                    false,
+                                    keyBean.isLeft,
+                                    dockBean.addr
+                                ) {
                                     NetApi.getKeyInfo(rfid) {
                                         if (it != null && !it.macAddress.isNullOrEmpty()) {
                                             ModBusController.updateKeyMac(
@@ -950,11 +951,6 @@ object BusinessManager {
         isLock: Boolean, vo: TicketDetailRespVO, lockList: MutableList<String?>?
     ): String {
         LogUtil.i("generateTicketSendJson : $lockList")
-        // 用ticketStatus的"待上锁"进行判断
-//        var isLock = true
-//        vo.ticketStatus?.let {
-//            isLock = it.toInt() < Constants.TICKET_STATUS_READY_TO_UNLOCK.toInt()
-//        }
         val bo = WorkTicketSendBO(
             cardNo = SPUtils.getLoginUser(MyApplication.instance!!.applicationContext)?.userCardList?.get(
                 0
@@ -1615,7 +1611,7 @@ object BusinessManager {
     /**
      * 根据当前模式进行处理
      */
-    private fun     handleCurrentMode(currentModeMsg: CurrentModeMsg) {
+    private fun handleCurrentMode(currentModeMsg: CurrentModeMsg) {
         when (currentModeMsg.mode) {
             // 工作模式
             0x01.toByte() -> {

+ 2 - 4
app/src/main/java/com/grkj/iscs/modbus/DockBean.kt

@@ -67,11 +67,10 @@ class DockBean(
                                 keyBean.isCharging = isLeftCharging
 
                                 // 拿走钥匙,移除钥匙信息
-                                if (!leftHasKey) {
+                                if (!leftHasKey && !keyBean.isReady) {
                                     changeList.add(keyBean.clone())
                                     keyBean.rfid = null
                                     keyBean.mac = null
-                                    keyBean.isReady = false
                                 } else {
                                     changeList.add(keyBean)
                                 }
@@ -81,11 +80,10 @@ class DockBean(
                                 keyBean.isExist = rightHasKey
                                 keyBean.isCharging = isRightCharging
                                 // 拿走钥匙,移除钥匙信息
-                                if (!rightHasKey) {
+                                if (!rightHasKey && !keyBean.isReady) {
                                     changeList.add(keyBean.clone())
                                     keyBean.rfid = null
                                     keyBean.mac = null
-                                    keyBean.isReady = false
                                 } else {
                                     changeList.add(keyBean)
                                 }

+ 2 - 2
app/src/main/java/com/grkj/iscs/model/UrlConsts.kt

@@ -4,8 +4,8 @@ object UrlConsts {
     //    const val BASE_URL = "http://192.168.28.82:9190"  // 本地
 //    const val BASE_URL = "http://192.168.28.97:9190"    // 车
 //    const val BASE_URL = "http://36.133.174.236:9190"    // 外
-//    const val BASE_URL = "http://192.168.0.10:9190"    // 外
-    const val BASE_URL = "http://192.168.1.121:9190"    // 外
+    const val BASE_URL = "http://192.168.0.10:9190"    // 外
+//    const val BASE_URL = "http://192.168.1.121:9190"    // 外
 
     //    const val BASE_URL = "http://120.27.232.27:9190"    // 外
     const val WEB_SOCKET = "ws://192.168.1.127:9090/websocket/iot/127"

+ 2 - 1
app/src/main/res/layout/item_rv_dock_test_child.xml

@@ -29,13 +29,14 @@
         <TextView
             android:id="@+id/tv_turn_off"
             style="@style/CommonTextView"
-            android:layout_marginRight="@dimen/common_spacing_small"
             android:background="@color/main_color_dark"
             android:padding="2dp"
             android:text="@string/turn_off" />
         <TextView
             android:id="@+id/tv_read"
             style="@style/CommonTextView"
+            android:layout_marginLeft="@dimen/common_spacing_small"
+            android:visibility="gone"
             android:background="@color/main_color_dark"
             android:padding="2dp"
             android:text="@string/turn_read" />