فهرست منبع

refactor(更新) :
- 增加接口通过NFC编号获取挂锁状态
- 归还挂锁时,判断作业票是否完成,未完成则禁止归还

周文健 3 ماه پیش
والد
کامیت
ac1ff0a359

+ 14 - 9
app/src/main/java/com/grkj/iscs_mars/BusinessManager.kt

@@ -506,15 +506,20 @@ object BusinessManager {
                         } else {
                             NetApi.getLockInfo(rfid) {
                                 if (it != null) {
-                                    // TODO 考虑快速拿取
-                                    ModBusController.controlLockBuckle(
-                                        false, dockBean.addr, lockBean.idx
-                                    ) { itRst ->
-                                        if (itRst.isNotEmpty()) {
-                                            // 上报锁具信息
-                                            NetApi.updateLockReturn(
-                                                rfid, MyApplication.instance!!.serialNo()
-                                            ) {}
+                                    NetApi.getLockStateByNfc(rfid) {
+                                        if (it != 1) {
+                                            ModBusController.controlLockBuckle(
+                                                false, dockBean.addr, lockBean.idx
+                                            ) { itRst ->
+                                                if (itRst.isNotEmpty()) {
+                                                    // 上报锁具信息
+                                                    NetApi.updateLockReturn(
+                                                        rfid, MyApplication.instance!!.serialNo()
+                                                    ) {}
+                                                }
+                                            }
+                                        } else {
+                                            ToastUtils.tip(CommonUtils.getStr(R.string.ticket_not_finish_can_not_return_lock))
                                         }
                                     }
                                 }

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

@@ -107,6 +107,11 @@ object UrlConsts {
      */
     const val LOCK_RETURN_UPDATE = "/iscs/hardware-api/updateTicketLockReturn"
 
+    /**
+     * 通过NFC编号获取挂锁状态
+     */
+    const val GET_LOCK_STATE_BY_NFC = "/iscs/hardware-api/getLockStateByNfc"
+
     /**
      * 取出挂锁时更新数据
      */

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

@@ -402,6 +402,25 @@ object NetApi {
         )
     }
 
+    /**
+     * 通过NFC编号获取挂锁状态
+     */
+    fun getLockStateByNfc(lockNfc: String, callBack: (Int?) -> Unit) {
+        NetHttpManager.getInstance().doRequestNet(
+            UrlConsts.GET_LOCK_STATE_BY_NFC,
+            false,
+            mapOf(
+                "nfc" to lockNfc
+            ),
+            { res, _, _ ->
+                res?.let {
+                    callBack.invoke(getRefBean(it))
+                }
+                // TODO isAuth需要配置
+            }, isGet = true, isAuth = BusinessManager.NEED_AUTH
+        )
+    }
+
     /**
      * 取出挂锁时更新数据
      */

+ 1 - 0
app/src/main/res/values-en/strings.xml

@@ -399,4 +399,5 @@
     <string name="positioning">Positioning</string>
     <string name="operation">Operation</string>
     <string name="ticket_get_failed">Ticket get failed,Please reposition the key</string>
+    <string name="ticket_not_finish_can_not_return_lock">The padlock is not allowed to be returned if the work ticket is not completed</string>
 </resources>

+ 1 - 0
app/src/main/res/values-zh/strings.xml

@@ -399,4 +399,5 @@
     <string name="positioning">定位</string>
     <string name="operation">操作</string>
     <string name="ticket_get_failed">作业票获取失败,请重新放置钥匙</string>
+    <string name="ticket_not_finish_can_not_return_lock">作业票未完成,禁止归还挂锁</string>
 </resources>

+ 1 - 0
app/src/main/res/values/strings.xml

@@ -399,4 +399,5 @@
     <string name="positioning">定位</string>
     <string name="operation">操作</string>
     <string name="ticket_get_failed">作业票获取失败,请重新放置钥匙</string>
+    <string name="ticket_not_finish_can_not_return_lock">作业票未完成,禁止归还挂锁</string>
 </resources>