wu98hay 1 year ago
parent
commit
2b9eb37841
1 changed files with 52 additions and 58 deletions
  1. 52 58
      app/src/main/java/com/qy/agv/activity/MainActivity.java

+ 52 - 58
app/src/main/java/com/qy/agv/activity/MainActivity.java

@@ -363,52 +363,54 @@ public class MainActivity extends BaseActivity {
     @Override
     public void receiverTask(String barcode) {
         System.out.println("扫码:" + barcode);
-        if(barcode.startsWith("05-")){
-            String loginName = barcode.split("-")[1];
-            String[] login_password = loginName.split(",");
-            checkToken(login_password[0], login_password[1]);
-            return;
-        }
-        if(user == null){
-            ToastUtils.showToast(context, "该设备没有登录");
-            return;
-        }
-        if(barcode.startsWith("01-")){
-            sendMsg = new String[4];
-            if(tv_robot!=null)tv_robot.setText("");
-            if(tv_shelf!=null)tv_shelf.setText("");
-            if(tv_target!=null)tv_target.setText("");
-            barcode = barcode.split("-")[1];
-        }
-        else if(barcode.startsWith("02-")){
-            sendMsg[1] = barcode.split("-")[1];
-            if(tv_robot!=null)tv_robot.setText(sendMsg[1]);
-            return;
-        }
-        else if(barcode.startsWith("03-")){
-            sendMsg[2] = barcode.split("-")[1];
-            if(tv_shelf!=null)tv_shelf.setText(sendMsg[2]);
-            return;
-        }
-        else if(barcode.startsWith("04-")){
-            sendMsg[3] = barcode.split("-")[1];
-            if(tv_target!=null)tv_target.setText(sendMsg[3]);
-            return;
-        }else{
-            ToastUtils.showToast(context, "无效码");
-            return;
-        }
-        if(popupWindow!=null && popupWindow.isShowing()){
-            popupWindow.dismiss();
-            popupWindow = null;
-        }
-        int rs = checkBarcode(barcode);
-        if(rs == 0){
-            ToastUtils.showToast(context, "无效功能码");
-        }else if(rs == 2) {
-            showNavigateView();
-        }else {
-            pushTask();
+        try {
+            if (barcode.startsWith("05-")) {
+                String loginName = barcode.split("-")[1];
+                String[] login_password = loginName.split(",");
+                checkToken(login_password[0], login_password[1]);
+                return;
+            }
+            if (user == null) {
+                ToastUtils.showToast(context, "该设备没有登录");
+                return;
+            }
+            if (barcode.startsWith("01-")) {
+                sendMsg = new String[4];
+                if (tv_robot != null) tv_robot.setText("");
+                if (tv_shelf != null) tv_shelf.setText("");
+                if (tv_target != null) tv_target.setText("");
+                barcode = barcode.split("-")[1];
+            } else if (barcode.startsWith("02-")) {
+                sendMsg[1] = barcode.split("-")[1];
+                if (tv_robot != null) tv_robot.setText(sendMsg[1]);
+                return;
+            } else if (barcode.startsWith("03-")) {
+                sendMsg[2] = barcode.split("-")[1];
+                if (tv_shelf != null) tv_shelf.setText(sendMsg[2]);
+                return;
+            } else if (barcode.startsWith("04-")) {
+                sendMsg[3] = barcode.split("-")[1];
+                if (tv_target != null) tv_target.setText(sendMsg[3]);
+                return;
+            } else {
+                ToastUtils.showToast(context, "无效码");
+                return;
+            }
+            if (popupWindow != null && popupWindow.isShowing()) {
+                popupWindow.dismiss();
+                popupWindow = null;
+            }
+            int rs = checkBarcode(barcode);
+            if (rs == 0) {
+                ToastUtils.showToast(context, "无效功能码");
+            } else if (rs == 2) {
+                showNavigateView();
+            } else {
+                pushTask();
+            }
+        }catch (Exception ex){
+            mylog.error("任务发送异常:", ex);
+            ToastUtils.showToast(context, "发送异常");
         }
     }
 
@@ -437,26 +439,18 @@ public class MainActivity extends BaseActivity {
         if(shelf==null)shelf="";
         if(target==null)target="";
         String qrcode = title+","+robot+","+shelf+","+target;
-        String target_name = "";
-        String shelf_name = "";
         String show_title = "";
-        if(!StringUtils.isEmpty(target)){
-            target_name = tv_target.getText().toString();
-        }
-        if(!StringUtils.isEmpty(shelf)){
-            shelf_name = tv_shelf.getText().toString();
-        }
         if(!StringUtils.isEmpty(target)&&!StringUtils.isEmpty(shelf)){
-            show_title = "将"+shelf_name+"货架搬到"+target_name;
+            show_title = "将"+shelf+"货架搬到"+target;
         }
         else if(!StringUtils.isEmpty(target)){
-            show_title = "到"+target_name;
+            show_title = "到"+target;
         }
         else if(!StringUtils.isEmpty(shelf)){
             show_title = "到"+shelf;
         }
-        if(!StringUtils.isEmpty(target_name)
-                ||!StringUtils.isEmpty(shelf_name)) {
+        if(!StringUtils.isEmpty(target)
+                ||!StringUtils.isEmpty(shelf)) {
             AlertDialog alert = new AlertDialog.Builder(MainActivity.this)
                     .setTitle("提示")
                     .setMessage("确定"+show_title+"吗?")