完善开始训练(道路)选择线路、发送消息等;开始采集后输入线路名称,检查有无重名;重名提示;
4个文件已修改
1个文件已添加
266 ■■■■ 已修改文件
app/src/main/assets/routeline.json 51 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/safeluck/drive/evaluation/DB/route/RouteBean.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/safeluck/drive/evaluation/customview/MyInputDialog.kt 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/safeluck/drive/evaluation/customview/SelectMutliDialog.java 27 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/safeluck/drive/evaluation/fragment/TrainFragment.java 171 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/assets/routeline.json
New file
@@ -0,0 +1,51 @@
[
  {
    "name":"线路一",
    "crossing_active":[
      {
        "road":2,
        "idx":0,
        "active":1
      },
      {
        "road":2,
        "idx":1,
        "active":1
      }
    ],
    "trigger_line":[
      {
        "x_y":[
          333.365,
          696.3354
        ],
        "road":2,
        "type":2
      },
      {
        "x_y":[
          333.365,
          696.3354
        ],
        "road":5,
        "type":4
      },
      {
        "x_y":[
          333.365,
          696.3354
        ],
        "road":3,
        "type":3
      },
      {
        "x_y":[
          333.365,
          696.3354
        ],
        "road":6,
        "type":1
      }
    ]
  }
]
app/src/main/java/safeluck/drive/evaluation/DB/route/RouteBean.java
@@ -1,5 +1,8 @@
package safeluck.drive.evaluation.DB.route;
import android.os.Parcel;
import android.os.Parcelable;
import androidx.room.Entity;
import androidx.room.PrimaryKey;
@@ -10,7 +13,7 @@
 * All Rights Saved! Chongqing AnYun Tech co. LTD
 */
@Entity
public class RouteBean {
public class RouteBean implements Parcelable {
    @PrimaryKey(autoGenerate = true)
    private int id;
    private String routeName;
@@ -30,4 +33,14 @@
    public void setRouteName(String routeName) {
        this.routeName = routeName;
    }
    @Override
    public int describeContents() {
        return 0;
    }
    @Override
    public void writeToParcel(Parcel dest, int flags) {
    }
}
app/src/main/java/safeluck/drive/evaluation/customview/MyInputDialog.kt
@@ -20,7 +20,7 @@
import safeluck.drive.evaluation.R
/**
 *
 *带有输入框的dialog
 * @ProjectName: DriveJudge
 * @Package: safeluck.drive.evaluation.customview
 * @ClassName: MyDialog
app/src/main/java/safeluck/drive/evaluation/customview/SelectMutliDialog.java
@@ -5,6 +5,7 @@
import android.graphics.drawable.ColorDrawable;
import android.os.Build;
import android.os.Bundle;
import android.os.Parcelable;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.LayoutInflater;
@@ -58,7 +59,7 @@
    public static final int SELECT_NONE = -1;
    private int result = SELECT_NONE;
    private ArrayList<String> stringArrayList;
    private List<RouteBean> routeBeanList;
    private RecyclerView mRecy;
    private RouteSelectAdapter mAdapter;
@@ -83,7 +84,7 @@
        View view = inflater.inflate(R.layout.layout_select_dlg_multi,container,false);
        Bundle bundle = getArguments();
        if (bundle != null){
            stringArrayList = bundle.getStringArrayList("content");
            routeBeanList = bundle.getParcelableArrayList("content");
        }
        initView(view);
        return view;
@@ -101,6 +102,7 @@
            @Override
            public void onItemClick(int position, View view) {
                Toast.makeText(getActivity(), position+"", Toast.LENGTH_SHORT).show();
                result = routeBeanList.get(position).getId();
                if (onSelectedListener != null){
                    onSelectedListener.makeYourChoice(result);
                }
@@ -112,15 +114,8 @@
            @Override
            public void run() {
                // Init Datas
                ArrayList<String> menues = new ArrayList<>(Arrays.asList(getResources().getStringArray(R.array.array_large_item_menu)));
                List<RouteBean> items = new ArrayList<>();
                for (int i = 0; i < menues.size(); i++) {
                    RouteBean item  = new RouteBean();
                    item.setRouteName(menues.get(i));
                    item.setId(i);
                    items.add(item);
                }
                mAdapter.setDatas(items);
                mAdapter.setDatas(routeBeanList);
            }
        });
//        button = view.findViewById(R.id.btn_sure_);
@@ -164,16 +159,14 @@
    public static SelectMutliDialog newInstance(String... args){
    public static SelectMutliDialog newInstance( List<RouteBean> args){
        SelectMutliDialog sle = new SelectMutliDialog();
        if (args != null && args.length>=2){
            List<String> strs = Arrays.asList(args);
            ArrayList<String> list = new ArrayList<>(strs);
            Bundle bundle = new Bundle();
            bundle.putStringArrayList("content",list);
            bundle.putParcelableArrayList("content", (ArrayList<? extends Parcelable>) args);
            sle.setArguments(bundle);
        }
        return sle;
app/src/main/java/safeluck/drive/evaluation/fragment/TrainFragment.java
@@ -40,6 +40,7 @@
import com.google.gson.Gson;
import org.jetbrains.annotations.NotNull;
import org.json.JSONException;
import org.json.JSONObject;
@@ -632,6 +633,29 @@
                            }else if (res == SelectDialogThree.THIRD){
                                sendJK0202(4);
                            }else{
                                MyInputDialog myDialog = MyInputDialog.Companion.newInstance("您将退出系统,请确认数据已保存");
                                myDialog.show(getFragmentManager(),"MyInputDialog");
                                myDialog.setOnClick(new MyInputDialog.MyOnClickListener() {
                                    @Override
                                    public void onSure(@NotNull String string) {
                                        //输入线路名称之后 点击确定才能认为是开始采集
                                        boolean flag = false;//标记是否有重名的线路,如果有则为true
                                        for (RouteBean bean:mRouteBeans){
                                            if (string.equalsIgnoreCase(bean.getRouteName())){
                                                //有重名的线路,提示用户并不开启线路采集
                                                Toast.makeText(_mActivity, "该线路名称已被使用,请更换", Toast.LENGTH_SHORT).show();
                                                flag = true;
                                                break;
                                            }
                                        }
                                        if (!flag){
                                            RouteBean routeBean = new RouteBean();
                                            routeBean.setRouteName(string);
                                            routeLineViewModel.insertRouteBean(routeBean);
                                Toast.makeText(_mActivity, "线路采集", Toast.LENGTH_SHORT).show();
                                ExamPlatformData.getInstance().setTrainingMode(ExamPlatformData.TRAINING_MODE);
                                exam_type = 5;
@@ -640,65 +664,24 @@
                                items_score.setVisibility(View.GONE);
                                route_collect.setVisibility(View.VISIBLE);
                            }
                                    }
                                    @Override
                                    public void onCancle() {
                                    }
                                });
                            }
                        }
                    });
                    selectDialog.show(getFragmentManager(),"selectdialog");
                }else{
                    if (exam_type == ROUTE_COLLECT){
                        List<RouteCollect.CrossingActiveBean> crossingActiveBeans = new ArrayList<>();
                        List<RouteCollect.TriggerLineBean> triggerLineBeans = new ArrayList<>();
                        List<Double> xy = new ArrayList<>();
                        RemoteRouteCollect remoteRouteCollect = new RemoteRouteCollect();
                        RouteCollect routeCollect = new RouteCollect();
                        List<RouteCollect> routeCollects = new ArrayList<>();
                        Toast.makeText(_mActivity, "结束采集", Toast.LENGTH_SHORT).show();
                        CThreadPoolExecutor.runInBackground(new Runnable() {
                            @Override
                            public void run() {
                                for (RouteBean routeBean:mRouteBeans){
                                    int id = routeBean.getId();
                                    routeCollect.setName(routeBean.getRouteName());
                                    List<RouteTriggerLine> routeTriggerLines = WorkRoomDataBase.getWorkRoomDataBase(getContext().getApplicationContext()).getRouteTriggerLineDao().getAllRouteTriggerLine(id);
                                    List<RouteCross> routeCrosses = WorkRoomDataBase.getWorkRoomDataBase(getContext().getApplicationContext()).getRouteCrooDao().getAllRouteCross(id);
                                    for (RouteTriggerLine line:routeTriggerLines){
                                        RouteCollect.TriggerLineBean triggerLineBean = new RouteCollect.TriggerLineBean();
                                        int road = line.getRoad();
                                        int type = line.getType();
                                        double x = line.getX();
                                        double y = line.getY();
                                        xy.clear();
                                        xy.add(x);
                                        xy.add(y);
                                        triggerLineBean.setRoad(road);
                                        triggerLineBean.setType(type);
                                        triggerLineBean.setX_y(xy);
                                        triggerLineBeans.add(triggerLineBean);
                                    }
                                    routeCollect.setTrigger_line(triggerLineBeans);
                                    for (RouteCross routeCross:routeCrosses){
                                        int idx = routeCross.getIdx();
                                        int road = routeCross.getRoad();
                                        int active = routeCross.getActive();
                                        RouteCollect.CrossingActiveBean crossingActiveBean = new RouteCollect.CrossingActiveBean();
                                        crossingActiveBean.setActive(active);
                                        crossingActiveBean.setIdx(idx);
                                        crossingActiveBean.setRoad(road);
                                        crossingActiveBeans.add(crossingActiveBean);
                                    }
                                    routeCollect.setCrossing_active(crossingActiveBeans);
                                    routeCollects.add(routeCollect);
                                }
                                remoteRouteCollect.setScheme(routeCollects);
                                String str = new Gson().toJson(remoteRouteCollect);
                                Log.i(TAG,"json====="+str);
                            }
                        });
                        ExamPlatformData.getInstance().setTrainingMode(ExamPlatformData.MODE_NONE);
                        exam_type = 0;
                        examStatusViewModel.updateStartExam(exam_type);
@@ -723,11 +706,7 @@
//                startArcGisMapFragment(url);
//                StatusDialog.with(_mActivity).setCancelable(true).setPrompt("加载中,请稍后...").setType(StatusDialog.Type.PROGRESS).show();
                SelectMutliDialog myDialog = SelectMutliDialog.newInstance("您将退出系统,请确认数据已保存");
                myDialog.show(getFragmentManager(),"mydialog");
                break;
            case R.id.iv_head:
                MyLog.i(TAG,"学员签到");
@@ -799,18 +778,27 @@
    }
    private void sendJK0202(int type) {
        if (type==3|| type==4){
            sendRouteLine();
        }
        //隐藏采集项目
        items_score.setVisibility(View.VISIBLE);
        items.setVisibility(View.VISIBLE);
    route_collect.setVisibility(View.GONE);
        final JKMessage0202 jkMessage0202 = new JKMessage0202();
        exam_type = type;
        ExamPlatformData.getInstance().setTrainingMode(ExamPlatformData.TRAINING_MODE);
        ExamPlatformData.getInstance().setExamType(exam_type);
        examStatusViewModel.updateStartExam(exam_type);
        sendExamJson(1,exam_type);
        ExamPlatformData.getInstance().getTTS().speak("开始训练");
    }
    private void sendMessage() {
        sendExamJson(1,exam_type);
        final JKMessage0202 jkMessage0202 = new JKMessage0202();
        Date date = new Date();
        wokViewModel.updateBeginTime(date.getTime());
        jkMessage0202.timeBCD = date;
@@ -818,7 +806,7 @@
        jkMessage0202.stu_id = ExamPlatformData.getInstance().getID();
        jkMessage0202.coach_id = ExamPlatformData.getInstance().getCoachID();
        jkMessage0202.exam_id = ExamPlatformData.getInstance().getExam_id();
        if (type > ExamPlatformData.EXAM_TYPE_ChangKAO){
        if (exam_type > ExamPlatformData.EXAM_TYPE_ChangKAO){
            jkMessage0202.curr_exam = 1;//  跟移动站服务定义的场考是2  ,平台是0 ;  移动站路考是3 ,平台是1
        }else{
@@ -829,6 +817,71 @@
        MessageProcessor.getInstance().sendMessage(jkMessage0202);
    }
    private void sendRouteLine() {
        SelectMutliDialog selectMutliDialog = SelectMutliDialog.newInstance(mRouteBeans);
        selectMutliDialog.show(getFragmentManager(),"multidialog");
        selectMutliDialog.setSelectedListener(new SelectMutliDialog.OnSelectedListener() {
            @Override
            public void makeYourChoice(int res) {
                List<RouteCollect.CrossingActiveBean> crossingActiveBeans = new ArrayList<>();
                List<RouteCollect.TriggerLineBean> triggerLineBeans = new ArrayList<>();
                List<Double> xy = new ArrayList<>();
                RemoteRouteCollect remoteRouteCollect = new RemoteRouteCollect();
                RouteCollect routeCollect = new RouteCollect();
                List<RouteCollect> routeCollects = new ArrayList<>();
                int id = res;
                CThreadPoolExecutor.runInBackground(new Runnable() {
                    @Override
                    public void run() {
                            routeCollect.setName(mRouteBeans.get(id).getRouteName());
                            List<RouteTriggerLine> routeTriggerLines = WorkRoomDataBase.getWorkRoomDataBase(getContext().getApplicationContext()).getRouteTriggerLineDao().getAllRouteTriggerLine(id);
                            List<RouteCross> routeCrosses = WorkRoomDataBase.getWorkRoomDataBase(getContext().getApplicationContext()).getRouteCrooDao().getAllRouteCross(id);
                            for (RouteTriggerLine line:routeTriggerLines){
                                RouteCollect.TriggerLineBean triggerLineBean = new RouteCollect.TriggerLineBean();
                                int road = line.getRoad();
                                int type = line.getType();
                                double x = line.getX();
                                double y = line.getY();
                                xy.clear();
                                xy.add(x);
                                xy.add(y);
                                triggerLineBean.setRoad(road);
                                triggerLineBean.setType(type);
                                triggerLineBean.setX_y(xy);
                                triggerLineBeans.add(triggerLineBean);
                            }
                            routeCollect.setTrigger_line(triggerLineBeans);
                            for (RouteCross routeCross:routeCrosses){
                                int idx = routeCross.getIdx();
                                int road = routeCross.getRoad();
                                int active = routeCross.getActive();
                                RouteCollect.CrossingActiveBean crossingActiveBean = new RouteCollect.CrossingActiveBean();
                                crossingActiveBean.setActive(active);
                                crossingActiveBean.setIdx(idx);
                                crossingActiveBean.setRoad(road);
                                crossingActiveBeans.add(crossingActiveBean);
                            }
                            routeCollect.setCrossing_active(crossingActiveBeans);
                            routeCollects.add(routeCollect);
                        remoteRouteCollect.setScheme(routeCollects);
                        String str = new Gson().toJson(remoteRouteCollect);
                        Log.i(TAG,"json====="+str);
                        //todo 发送线路
                        sendMessage();
                    }
                });
            }
        });
    }
    private void sendExamJson(int i,int type) {
        try {