|
@@ -33,6 +33,7 @@ import com.google.gson.JsonElement;
|
|
|
import com.google.gson.reflect.TypeToken;
|
|
import com.google.gson.reflect.TypeToken;
|
|
|
import com.qy.agv.R;
|
|
import com.qy.agv.R;
|
|
|
import com.qy.agv.activity.adapter.MainListViewAdapter;
|
|
import com.qy.agv.activity.adapter.MainListViewAdapter;
|
|
|
|
|
+import com.qy.agv.activity.model.RobotModel;
|
|
|
import com.qy.agv.activity.model.TaskModel;
|
|
import com.qy.agv.activity.model.TaskModel;
|
|
|
import com.qy.agv.activity.model.UserModel;
|
|
import com.qy.agv.activity.model.UserModel;
|
|
|
import com.qy.agv.comm.BaseActivity;
|
|
import com.qy.agv.comm.BaseActivity;
|
|
@@ -59,6 +60,7 @@ import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
|
+import java.util.concurrent.atomic.AtomicReference;
|
|
|
|
|
|
|
|
public class MainActivity extends BaseActivity {
|
|
public class MainActivity extends BaseActivity {
|
|
|
public static Logger mylog =Logger.getLogger(MainActivity.class);
|
|
public static Logger mylog =Logger.getLogger(MainActivity.class);
|
|
@@ -90,7 +92,6 @@ public class MainActivity extends BaseActivity {
|
|
|
initView();
|
|
initView();
|
|
|
initData();
|
|
initData();
|
|
|
Permission.checkPermission(this);
|
|
Permission.checkPermission(this);
|
|
|
-// checkToken(getMac(), getMac());
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void initData(){
|
|
private void initData(){
|
|
@@ -131,6 +132,10 @@ public class MainActivity extends BaseActivity {
|
|
|
logout();
|
|
logout();
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
|
|
+ submit.setOnLongClickListener(v -> {
|
|
|
|
|
+ checkToken(getMac(), getMac());
|
|
|
|
|
+ return false;
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void registerReceiver() {
|
|
private void registerReceiver() {
|
|
@@ -472,16 +477,15 @@ public class MainActivity extends BaseActivity {
|
|
|
private void selParam(int sel){
|
|
private void selParam(int sel){
|
|
|
View view = binding.getRoot().getRootView();
|
|
View view = binding.getRoot().getRootView();
|
|
|
List<Map<String,String>> params = new ArrayList<>();
|
|
List<Map<String,String>> params = new ArrayList<>();
|
|
|
- Map<String, String> map = new HashMap<>();
|
|
|
|
|
-// map.put("name", "qyzl001");
|
|
|
|
|
-// map.put("value", "1739897084274606082");
|
|
|
|
|
-// for (int i=0;i<30;i++) {
|
|
|
|
|
-// params.add(map);
|
|
|
|
|
-// map = new HashMap<>();
|
|
|
|
|
-// map.put("name", "R30201"+i);
|
|
|
|
|
-// map.put("value", "1"+i);
|
|
|
|
|
-// params.add(map);
|
|
|
|
|
-// }
|
|
|
|
|
|
|
+ if(sel == 1){
|
|
|
|
|
+ List<RobotModel> robotModels = searchRobot();
|
|
|
|
|
+ for (RobotModel robotModel : robotModels) {
|
|
|
|
|
+ Map<String, String> map = new HashMap<>();
|
|
|
|
|
+ map.put("name", robotModel.getRobotId());
|
|
|
|
|
+ map.put("value", robotModel.getRobotId());
|
|
|
|
|
+ params.add(map);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
if(params.size() == 0){
|
|
if(params.size() == 0){
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
@@ -544,12 +548,6 @@ public class MainActivity extends BaseActivity {
|
|
|
popupWindow1.setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
|
|
popupWindow1.setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
|
|
|
setBackgroundAlpha(0.5f);
|
|
setBackgroundAlpha(0.5f);
|
|
|
popup_view.setVisibility(View.GONE);
|
|
popup_view.setVisibility(View.GONE);
|
|
|
- popupWindow1.setOnDismissListener(new PopupWindow.OnDismissListener() {
|
|
|
|
|
- @Override
|
|
|
|
|
- public void onDismiss() {
|
|
|
|
|
- setBackgroundAlpha(1.0f);
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
popupWindow1.showAtLocation(view, Gravity.CENTER, 0, 0);
|
|
popupWindow1.showAtLocation(view, Gravity.CENTER, 0, 0);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -675,4 +673,47 @@ public class MainActivity extends BaseActivity {
|
|
|
setBackgroundAlpha(0.5f);
|
|
setBackgroundAlpha(0.5f);
|
|
|
popupWindow2.showAtLocation(view, Gravity.CENTER, 0, 0);
|
|
popupWindow2.showAtLocation(view, Gravity.CENTER, 0, 0);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ private List<RobotModel> searchRobot() {
|
|
|
|
|
+ List<RobotModel> robotModels = new ArrayList<>();
|
|
|
|
|
+ RequestParams params = httParams(Constant.ROBOT_LIST);
|
|
|
|
|
+ params.addBodyParameter("current", "1");
|
|
|
|
|
+ params.addBodyParameter("size", "100");
|
|
|
|
|
+ try {
|
|
|
|
|
+ AtomicReference<JSONObject> rsAtm = new AtomicReference<>(new JSONObject());
|
|
|
|
|
+ Thread s1 = new Thread(()->{
|
|
|
|
|
+ try {
|
|
|
|
|
+ rsAtm.set(x.http().getSync(params, JSONObject.class));
|
|
|
|
|
+ }catch (Throwable e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ try{
|
|
|
|
|
+ s1.start();
|
|
|
|
|
+ s1.join();
|
|
|
|
|
+ }catch (Exception e){
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+ JSONObject rs = rsAtm.get();
|
|
|
|
|
+ if (rs.has("code") && rs.getInt("code") != 200) {
|
|
|
|
|
+ ToastUtils.showToast(context, "请求失败");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (rs.has("success")) {
|
|
|
|
|
+ System.out.println(rs.get("data"));
|
|
|
|
|
+ Type rds = new TypeToken<Map<String, JsonElement>>() {
|
|
|
|
|
+ }.getType();
|
|
|
|
|
+ Map<String, JsonElement> records = new Gson().fromJson(rs.get("data").toString(), rds);
|
|
|
|
|
+ System.out.println(records.get("records"));
|
|
|
|
|
+ Type lt = new TypeToken<ArrayList<RobotModel>>() {}.getType();
|
|
|
|
|
+ Object rs_record = records.get("records");
|
|
|
|
|
+ if(rs_record!=null) {
|
|
|
|
|
+ robotModels = new Gson().<List<RobotModel>>fromJson(rs_record.toString(), lt);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }catch (Throwable e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ mylog.error("加载机器人列表异常:", e);
|
|
|
|
|
+ }
|
|
|
|
|
+ return robotModels;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|