Browse Source

refactor(更新) :
- 优化软键盘显隐逻辑,修复登录弹窗无法自动隐藏软键盘问题
- 修复作业进度道岔状态显示错误的问题
- 修复人工异常类型字典接口地址错误的问题
- 优化指纹录入提示
- 修复采集板数据不上报的问题
- 修复网络请求鉴权错误问题
- 优化道岔状态列表刷新逻辑

周文健 3 months ago
parent
commit
c48fb5f815

+ 17 - 6
app/src/main/java/com/grkj/iscs_mars/BusinessManager.kt

@@ -222,12 +222,10 @@ object BusinessManager {
 
                 MSG_EVENT_SWITCH_COLLECTION_UPDATE -> {
                     ThreadUtils.runOnIO {
-                        val switchStatus =
-                            NetApi.getDictData(DictAndSystemConstants.KEY_SWITCH_STATUS)
                         val switchListReqVOS = ModBusController.getSwitchData().map {
                             SwitchListReqVO(
                                 it.idx.toString(),
-                                if (it.enabled) switchStatus?.find { it.dictLabel == "打开" }?.dictValue else switchStatus?.find { it.dictLabel == "关闭" }?.dictValue,
+                                if (it.enabled) "1" else "0",
                                 TimeUtils.nowString(TimeUtils.DEFAULT_DATE_HOUR_MIN_SEC_FORMAT)
                             )
                         }
@@ -391,17 +389,20 @@ object BusinessManager {
         res.forEachIndexed { index, bytes ->
             val dockBean = ModBusController.updateStatus(bytes) ?: return@forEachIndexed
             ModBusController.isInitReady = true
-            if (!CAN_RETURN) {
-                return@forEachIndexed
-            }
             when (dockBean.type) {
                 DOCK_TYPE_KEY -> {
+                    if (!CAN_RETURN) {
+                        return@forEachIndexed
+                    }
                     dockBean.getKeyList().forEach { keyBean ->
                         deviceKeyHandler(dockBean, keyBean)
                     }
                 }
 
                 DOCK_TYPE_LOCK -> {
+                    if (!CAN_RETURN) {
+                        return@forEachIndexed
+                    }
                     dockBean.getLockList().forEach { lockBean ->
                         deviceLockHandler(dockBean, lockBean)
                     }
@@ -417,10 +418,16 @@ object BusinessManager {
                         if (deviceBean.isExist) {
                             when (deviceBean.type) {
                                 DEVICE_TYPE_KEY -> {
+                                    if (!CAN_RETURN) {
+                                        return@forEachIndexed
+                                    }
                                     deviceKeyHandler(dockBean, deviceBean as DockBean.KeyBean)
                                 }
 
                                 DEVICE_TYPE_LOCK -> {
+                                    if (!CAN_RETURN) {
+                                        return@forEachIndexed
+                                    }
                                     deviceLockHandler(dockBean, deviceBean as DockBean.LockBean)
                                 }
 
@@ -443,6 +450,10 @@ object BusinessManager {
                         }
                     }
                 }
+
+                DeviceConst.DOCK_TYPE_COLLECT -> {
+                    ModBusController.switchStatus(bytes){}
+                }
             }
             Executor.delayOnMain(200) {
                 if (!ISCSDomainData.isDeviceRegistration) {

+ 1 - 1
app/src/main/java/com/grkj/iscs_mars/modbus/ModBusController.kt

@@ -372,7 +372,7 @@ object ModBusController {
     /**
      * 开关量更新
      */
-    private fun switchStatus(res: Any, done: () -> Unit) {
+    fun switchStatus(res: Any, done: () -> Unit) {
         LogUtil.i("开关板:${(res as ByteArray).toHexStrings()}")
         if (res.isEmpty()) {
             var tipStr = CommonUtils.getStr(R.string.no_response_board_exists) + " : "

+ 1 - 1
app/src/main/java/com/grkj/iscs_mars/model/UrlConsts.kt

@@ -251,7 +251,7 @@ object UrlConsts {
     /**
      * 查询字典 - 人工异常类型
      */
-    const val EXCEPTION_TYPE = "$DICT_PREFIX/exception_type"
+    const val EXCEPTION_TYPE = "$DICT_PREFIX/type_of_exception"
 
     /**
      * 查询字典 - 人工异常严重等级

+ 2 - 1
app/src/main/java/com/grkj/iscs_mars/model/vo/ticket/TicketDetailMonitorRespVO.kt

@@ -56,6 +56,7 @@ data class TicketDetailMonitorRespVO(
         val prePointId: Long?,
         val locksetName: String?,
         val remark: String?,
-        val switchStatus: String?   // 0:开 1:关
+        val switchStatus: String?,   // 0:开 1:关
+        val effect: String?   //作用
     )
 }

+ 18 - 2
app/src/main/java/com/grkj/iscs_mars/util/KeyboardUtils.kt

@@ -3,6 +3,7 @@ package com.grkj.iscs_mars.util
 import android.content.Context
 import android.view.View
 import android.view.inputmethod.InputMethodManager
+import com.sik.sikandroid.activity.ActivityTracker
 
 /**
  * 软键盘工具
@@ -11,8 +12,23 @@ object KeyboardUtils {
     /**
      * 隐藏软键盘
      */
-    fun hideSoftKeyboard(view: View) {
+    fun hideSoftKeyboard() {
+        val activity = ActivityTracker.getCurrentActivity()
+        val imm = activity?.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
+        val currentFocusView = activity.currentFocus
+        val windowToken = currentFocusView?.windowToken
+            ?: activity.window?.decorView?.windowToken
+
+        windowToken?.let {
+            imm.hideSoftInputFromWindow(it, InputMethodManager.HIDE_NOT_ALWAYS)
+        }
+    }
+
+    /**
+     * 显示软键盘
+     */
+    fun showSoftKeyboard(view: View) {
         val imm = view.context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
-        imm.hideSoftInputFromWindow(view.windowToken, 0)
+        imm.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT)
     }
 }

+ 1 - 1
app/src/main/java/com/grkj/iscs_mars/util/NetApi.kt

@@ -1359,7 +1359,7 @@ object NetApi {
                 } ?: run {
                     callBack.invoke(false)
                 }
-            }, isGet = false, isAuth = true
+            }, isGet = false, isAuth = false
         )
     }
 

+ 0 - 1
app/src/main/java/com/grkj/iscs_mars/view/activity/HomeActivity.kt

@@ -185,7 +185,6 @@ class HomeActivity : BaseMvpActivity<IHomeView, HomePresenter, ActivityHomeBindi
 
         BusinessManager.mEventBus.observe(this, observer)
         ModBusController.updateAllBuckleStatus {}
-        ModBusController.updateSwitchStatus {}
     }
 
     override fun dispatchKeyEvent(event: KeyEvent): Boolean {

+ 5 - 0
app/src/main/java/com/grkj/iscs_mars/view/activity/LoginActivity.kt

@@ -15,6 +15,7 @@ import com.grkj.iscs_mars.modbus.ModBusController
 import com.grkj.iscs_mars.model.vo.user.UserInfoRespVO
 import com.grkj.iscs_mars.util.AppUtils
 import com.grkj.iscs_mars.util.FingerprintUtil
+import com.grkj.iscs_mars.util.KeyboardUtils
 import com.grkj.iscs_mars.util.log.LogUtil
 import com.grkj.iscs_mars.view.base.BaseMvpActivity
 import com.grkj.iscs_mars.view.dialog.LoginDialog
@@ -82,6 +83,10 @@ class LoginActivity : BaseMvpActivity<ILoginView, LoginPresenter, ActivityLoginB
                 }
             }
         }
+        cardLoginDialog?.setOnDismissListener {
+            LogUtil.i("隐藏软键盘")
+            KeyboardUtils.hideSoftKeyboard()
+        }
         cardLoginDialog?.showByType(loginType)
     }
 

+ 2 - 4
app/src/main/java/com/grkj/iscs_mars/view/activity/SwitchStatusActivity.kt

@@ -69,10 +69,8 @@ class SwitchStatusActivity :
         initMap()
         lifecycleScope.launch {
             repeatOnLifecycle(Lifecycle.State.RESUMED) {
-                delay(1000)
-                BusinessManager.updateSwitchStatus {
-                    mBinding?.rvList?.adapter?.notifyDataSetChanged()
-                }
+                delay(2000)
+                mBinding?.rvList?.adapter?.notifyDataSetChanged()
             }
         }
     }

+ 12 - 10
app/src/main/java/com/grkj/iscs_mars/view/dialog/LoginDialog.kt

@@ -1,9 +1,14 @@
 package com.grkj.iscs_mars.view.dialog
 
+import android.content.Context
 import android.graphics.Bitmap
 import android.view.InputDevice
 import android.view.KeyEvent
+import android.view.MotionEvent
 import android.view.View
+import android.view.WindowManager
+import android.view.inputmethod.InputMethodManager
+import android.widget.EditText
 import com.grkj.iscs_mars.BusinessManager
 import com.grkj.iscs_mars.R
 import com.grkj.iscs_mars.databinding.DialogLoginBinding
@@ -18,6 +23,7 @@ import com.grkj.iscs_mars.util.log.LogUtil
 import com.grkj.iscs_mars.view.base.BaseActivity
 import com.grkj.iscs_mars.view.base.BaseDialog
 import com.grkj.iscs_mars.view.presenter.LoginPresenter
+import com.sik.sikcore.extension.setDebouncedClickListener
 import com.sik.sikcore.thread.ThreadUtils
 
 class LoginDialog(
@@ -39,6 +45,8 @@ class LoginDialog(
         get() = DialogLoginBinding.inflate(layoutInflater)
 
     override fun initView() {
+        window?.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN)
+
         mBinding?.tvLogin?.setOnClickListener {
             presenter?.login(
                 ctx,
@@ -51,11 +59,9 @@ class LoginDialog(
                 callBack?.invoke(isSuccess, userInfoRespVO)
             }
         }
-        mBinding?.tvCancel?.setOnClickListener { dismiss() }
-        setOnDismissListener {
-            mBinding?.root?.let {
-                KeyboardUtils.hideSoftKeyboard(it)
-            }
+        mBinding?.tvCancel?.setOnClickListener {
+            KeyboardUtils.hideSoftKeyboard()
+            dismiss()
         }
     }
 
@@ -126,12 +132,8 @@ class LoginDialog(
                 }
             }
             return true // 消费 HID 事件
-        } else if (isHidInput) {
-            return true
         }
-
-        // 非 HID 情况,正常让 EditText 或 Activity 处理
-        return super.dispatchKeyEvent(event)
+        return  super.dispatchKeyEvent(event)
     }
 
     private fun startFace() {

+ 6 - 2
app/src/main/java/com/grkj/iscs_mars/view/fragment/FingerprintConfigFragment.kt

@@ -62,13 +62,13 @@ class FingerprintConfigFragment :
                 ) {
                     holder.setText(
                         R.id.tv_name,
-                        "${getString(R.string.fingerprint)}${position + 1}"
+                        "${getString(R.string.fingerprint)}_${record.first?.take(6)}"
                     )
                     holder.setOnClickListener(R.id.root) {
                         showTipDialog(
                             getString(
                                 R.string.fingerprint_delete_confirm_tip,
-                                "${getString(R.string.fingerprint)}${position + 1}"
+                                "${getString(R.string.fingerprint)}_${record.first?.take(6)}"
                             ), record.second.mapNotNull { it.recordId?.toString() }
                         )
                     }
@@ -172,6 +172,10 @@ class FingerprintConfigFragment :
                 }
             }) {
                 pressTip = it
+                pressTip?.text = getString(
+                    R.string.fingerprint_scan_tip,
+                    maxPressTimes - mFingerprintPressTimes
+                )
             }
         }
         mFingerprintPressTimes = 0

+ 2 - 2
app/src/main/java/com/grkj/iscs_mars/view/fragment/JobProgressFragment.kt

@@ -59,10 +59,10 @@ class JobProgressFragment(val goBack: () -> Unit, val changePage: (PageChangeBO)
                     position: Int
                 ) {
                     holder.setText(R.id.tv_name, point.pointName)
-                    holder.setText(R.id.tv_function, point.remark)
+                    holder.setText(R.id.tv_function, point.effect)
                     holder.setVisible(R.id.iv_status, point.switchStatus != null)
                     holder.getView<ImageView>(R.id.iv_status)
-                        .setBackgroundResource(if (point.switchStatus == "1") R.mipmap.switch_off else R.mipmap.switch_on)
+                        .setImageResource(if (point.switchStatus == "0") R.mipmap.switch_off else R.mipmap.switch_on)
                     when (point.pointStatus) {
                         "1" -> {
                             holder.setVisible(R.id.ll_lock_status, true)

+ 0 - 4
app/src/main/res/layout/dialog_login.xml

@@ -53,8 +53,6 @@
             style="@style/CommonEdit"
             android:layout_width="match_parent"
             android:layout_marginBottom="10dp"
-            android:focusable="false"
-            android:focusableInTouchMode="true"
             android:hint="@string/please_input_account" />
 
         <EditText
@@ -63,8 +61,6 @@
             android:layout_width="match_parent"
             android:layout_marginBottom="10dp"
             android:inputType="textPassword"
-            android:focusable="false"
-            android:focusableInTouchMode="true"
             android:hint="@string/please_input_password" />
 
         <TextView

+ 1 - 0
app/src/main/res/layout/item_rv_point.xml

@@ -44,6 +44,7 @@
                 android:id="@+id/iv_status"
                 android:layout_width="35dp"
                 android:layout_height="15dp"
+                android:paddingVertical="@dimen/common_spacing_smallest"
                 android:layout_centerInParent="true"/>
         </RelativeLayout>