ソースを参照

refactor(修改):
- 归还钥匙如果作业票丢失当归还了

周文健 5 ヶ月 前
コミット
80d5740516

+ 19 - 6
app/src/main/java/com/grkj/iscs/BusinessManager.kt

@@ -1587,8 +1587,11 @@ object BusinessManager {
                     data.taskCode?.toLong()!!,
                     keyNfc!!,
                     MyApplication.instance!!.serialNo()
-                ) { isSuccess ->
-                    if (!isSuccess) {
+                ) { isSuccess, msg ->
+                    if (!isSuccess && msg != MyApplication.instance?.applicationContext!!.getString(
+                            R.string.ticket_lost
+                        )
+                    ) {
                         SPUtils.saveUpdateKeyReturn(
                             MyApplication.instance!!,
                             UpdateKeyReturnBO(data.taskCode?.toLong()!!, keyNfc!!)
@@ -1624,8 +1627,15 @@ object BusinessManager {
      */
     fun handleVirtualKeyReturn(taskCode: Long, keyNfc: String, done: () -> Unit) {
         // 上报钥匙归还
-        NetApi.updateKeyReturn(taskCode, keyNfc, MyApplication.instance!!.serialNo()) { isSuccess ->
-            if (!isSuccess) {
+        NetApi.updateKeyReturn(
+            taskCode,
+            keyNfc,
+            MyApplication.instance!!.serialNo()
+        ) { isSuccess, msg ->
+            if (!isSuccess && msg != MyApplication.instance?.applicationContext!!.getString(
+                    R.string.ticket_lost
+                )
+            ) {
                 SPUtils.saveUpdateKeyReturn(
                     MyApplication.instance!!,
                     UpdateKeyReturnBO(taskCode, keyNfc)
@@ -1931,9 +1941,12 @@ object BusinessManager {
         itemsToRemove.forEach { itData ->
             NetApi.updateKeyReturn(
                 itData.ticketId, itData.keyNfc, context.serialNo()
-            ) { isSuccess ->
+            ) { isSuccess, msg ->
                 count++
-                if (isSuccess) {
+                if (isSuccess || msg == MyApplication.instance?.applicationContext!!.getString(
+                        R.string.ticket_lost
+                    )
+                ) {
                     returnList.remove(itData)
                     getBleBeanByRfid(itData.keyNfc)?.bleDevice?.let {
                         switchReadyMode(it)

+ 4 - 4
app/src/main/java/com/grkj/iscs/util/NetApi.kt

@@ -479,7 +479,7 @@ object NetApi {
         keyNfc: String,
         serialNumber: String,
         retryCount: Int = 3,
-        callBack: (Boolean) -> Unit
+        callBack: (Boolean, String) -> Unit
     ) {
         NetHttpManager.getInstance().doRequestNet(
             UrlConsts.KEY_RETURN_UPDATE,
@@ -489,9 +489,9 @@ object NetApi {
                 "keyNfc" to keyNfc,
                 "serialNumber" to serialNumber
             ),
-            { res, _, _ ->
+            { res, msg, _ ->
                 res?.let {
-                    callBack(true)
+                    callBack(true, msg?:"")
                 } ?: let {
                     if (retryCount > 0) {
                         Executor.delayOnIO(500) {
@@ -504,7 +504,7 @@ object NetApi {
                             )
                         }
                     } else {
-                        callBack.invoke(false)
+                        callBack.invoke(false, msg?:"")
                     }
                 }
                 // TODO isAuth需要配置

+ 1 - 3
app/src/main/java/com/grkj/iscs/util/NetHttpManager.kt

@@ -159,10 +159,8 @@ class NetHttpManager {
                             }
                             val bobyStr = it.body.toString()
                             callback(
-                                null, if (bobyStr.isEmpty()) {
+                                null, bobyStr.ifEmpty {
                                     it.toString()
-                                } else {
-                                    bobyStr
                                 }, it.status
                             )
                         }

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

@@ -333,4 +333,5 @@
     <string name="current_user_does_not_have_the_authority_to_unlock_colock">The current user does not have the authority to unlock colock</string>
     <string name="all_point_have_other_job_not_finish">all point have other job not finish,do you want to continue?</string>
     <string name="lock_is_not_enough_stop_issue_ticket">lock is not enough, stop issue ticket</string>
+    <string name="ticket_lost">{"msg":"作业票数据丢失啦!","code":500}</string>
 </resources>

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

@@ -333,4 +333,5 @@
     <string name="current_user_does_not_have_the_authority_to_unlock_colock">当前用户无权解除共锁</string>
     <string name="all_point_have_other_job_not_finish">所有隔离点存在其他作业未完成,是否继续拆锁恢复?</string>
     <string name="lock_is_not_enough_stop_issue_ticket">锁具数量不足,停止下发作业票</string>
+    <string name="ticket_lost">{"msg":"作业票数据丢失啦!","code":500}</string>
 </resources>

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

@@ -333,4 +333,5 @@
     <string name="current_user_does_not_have_the_authority_to_unlock_colock">当前用户无权解除共锁</string>
     <string name="all_point_have_other_job_not_finish">所有隔离点存在其他作业未完成,是否继续拆锁恢复?</string>
     <string name="lock_is_not_enough_stop_issue_ticket">锁具数量不足,停止下发作业票</string>
+    <string name="ticket_lost">{"msg":"作业票数据丢失啦!","code":500}</string>
 </resources>