From 6ec3c54a1c57b4356490a4821a2c6a7695448e22 Mon Sep 17 00:00:00 2001 From: endian11 <Dana_Lee1016@126.com> Date: 星期三, 16 九月 2020 17:48:06 +0800 Subject: [PATCH] 数据库保存 --- app/src/main/java/safeluck/drive/evaluation/DB/route/RouteBean.java | 33 ++ app/src/main/java/safeluck/drive/evaluation/DB/route/RouteCross.java | 62 ++++ app/src/main/java/safeluck/drive/evaluation/routecollect/CollectPointResult.java | 37 ++ app/src/main/java/safeluck/drive/evaluation/routecollect/IRouteCollectInterface.java | 19 + app/src/main/java/safeluck/drive/evaluation/DB/route/RouteTriggerLineDao.java | 24 + app/src/main/java/safeluck/drive/evaluation/DB/route/RouteInitWorker.java | 83 +++++ app/src/main/java/safeluck/drive/evaluation/fragment/TrainFragment.java | 75 ++++ app/src/main/java/safeluck/drive/evaluation/DB/route/RouteLineRepository.java | 75 +++++ app/src/main/java/safeluck/drive/evaluation/DB/route/RouteLineViewModel.java | 53 +++ app/src/main/java/safeluck/drive/evaluation/routecollect/ILoadListener.java | 12 app/src/main/java/safeluck/drive/evaluation/bean/RouteCollect.java | 122 ++++++++ app/src/main/java/safeluck/drive/evaluation/routecollect/IRouteRemotePointCallback.java | 13 app/src/main/res/layout/layout_train_fragment.xml | 8 app/src/main/java/safeluck/drive/evaluation/routecollect/impl/RouteModel.java | 48 +++ app/src/main/java/safeluck/drive/evaluation/DB/route/RouteBeanDao.java | 24 + app/src/main/java/safeluck/drive/evaluation/routecollect/RouteCollectController.java | 44 ++ app/src/main/java/safeluck/drive/evaluation/DB/WorkRoomDataBase.java | 17 + app/src/main/java/safeluck/drive/evaluation/DB/route/RouteCrossDao.java | 23 + app/src/main/java/safeluck/drive/evaluation/DB/route/RouteTriggerLine.java | 74 ++++ app/src/main/java/safeluck/drive/evaluation/routecollect/ICollectView.java | 18 + 20 files changed, 846 insertions(+), 18 deletions(-) diff --git a/app/src/main/java/safeluck/drive/evaluation/DB/WorkRoomDataBase.java b/app/src/main/java/safeluck/drive/evaluation/DB/WorkRoomDataBase.java index 14ce36b..022903a 100644 --- a/app/src/main/java/safeluck/drive/evaluation/DB/WorkRoomDataBase.java +++ b/app/src/main/java/safeluck/drive/evaluation/DB/WorkRoomDataBase.java @@ -17,6 +17,7 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; +import okhttp3.Route; import safeluck.drive.evaluation.DB.appstatusdb.AppStatus; import safeluck.drive.evaluation.DB.appstatusdb.AppStatusDao; import safeluck.drive.evaluation.DB.appstatusdb.AppStatusInitWork; @@ -39,6 +40,13 @@ import safeluck.drive.evaluation.DB.failitems.LuKaoFailedProj; import safeluck.drive.evaluation.DB.gps.GPSInfo; import safeluck.drive.evaluation.DB.gps.GpsInfoDao; +import safeluck.drive.evaluation.DB.route.RouteBean; +import safeluck.drive.evaluation.DB.route.RouteBeanDao; +import safeluck.drive.evaluation.DB.route.RouteCross; +import safeluck.drive.evaluation.DB.route.RouteCrossDao; +import safeluck.drive.evaluation.DB.route.RouteInitWorker; +import safeluck.drive.evaluation.DB.route.RouteTriggerLine; +import safeluck.drive.evaluation.DB.route.RouteTriggerLineDao; import safeluck.drive.evaluation.DB.rtktb.RTKConfig; import safeluck.drive.evaluation.DB.rtktb.RTKConfigDao; import safeluck.drive.evaluation.DB.rtktb.RTKConfigWork; @@ -53,10 +61,14 @@ * 閭锛�632393724@qq.com * All Rights Saved! Chongqing AnYun Tech co. LTD */ -@Database(entities = {Student.class, CriteriaForI.class, FailedProj.class,LuKaoFailedProj.class, CriteriaForII.class, CriteriaForIII.class,RTKConfig.class, GPSInfo.class, AppStatus.class, ExamStatus.class, SingalConfig.class},version = 1,exportSchema = false) +@Database(entities = {Student.class, CriteriaForI.class, FailedProj.class,LuKaoFailedProj.class, CriteriaForII.class, CriteriaForIII.class,RTKConfig.class, GPSInfo.class, AppStatus.class, ExamStatus.class, SingalConfig.class + ,RouteBean.class, RouteCross.class, RouteTriggerLine.class},version = 1,exportSchema = false) public abstract class WorkRoomDataBase extends RoomDatabase { private static final String TAG = "WorkRoomDataBase"; public abstract StudentDao getstudentDao(); + public abstract RouteBeanDao getRouteBeanDao(); + public abstract RouteCrossDao getRouteCrooDao(); + public abstract RouteTriggerLineDao getRouteTriggerLineDao(); //绉戠洰浜� I绫昏�冨満璇勫垽琛� public abstract CriteriaIDao getCriteriaIDao(); @@ -98,6 +110,7 @@ OneTimeWorkRequest appStatusInitWork = OneTimeWorkRequest.from(AppStatusInitWork.class); OneTimeWorkRequest examStatusInitWorker = OneTimeWorkRequest.from(ExamStatusInitWorker.class); OneTimeWorkRequest signalConigInitWorker = OneTimeWorkRequest.from(SignalConfigInitWorker.class); + OneTimeWorkRequest routeInitWorker = OneTimeWorkRequest.from(RouteInitWorker.class); Log.i(TAG, "onCreate: 鍒涘缓鏁版嵁搴撳悗寤虹珛鏁版嵁琛ㄦ彃鍏ユ暟鎹�"); // WorkManager.getInstance(mContext).enqueue(oneTimeWorkRequest); // WorkManager.getInstance(mContext).enqueue(oneTimeWorkRequest1); @@ -112,7 +125,7 @@ //鍗曡矾寰勬墽琛岋紝鍙互瀹炵幇鏇村姞澶嶆潅鐨勫璺緞鎵ц鏂瑰紡 WorkContinuation chain1= WorkManager.getInstance(mContext).beginWith(Arrays.asList(oneTimeWorkRequest,oneTimeWorkRequest1)) .then(mCriteriaForIIIWorker).then(oneTimeWorkRequest3); - WorkContinuation chain2 = WorkManager.getInstance(mContext).beginWith(Arrays.asList(RTKConfigWorkRequest,appStatusInitWork,signalConigInitWorker)) + WorkContinuation chain2 = WorkManager.getInstance(mContext).beginWith(Arrays.asList(RTKConfigWorkRequest,appStatusInitWork,signalConigInitWorker,routeInitWorker)) .then(oneTimeWorkRequest2).then(examStatusInitWorker); WorkContinuation chain3 = WorkContinuation.combine(Arrays.asList(chain1,chain2)); diff --git a/app/src/main/java/safeluck/drive/evaluation/DB/route/RouteBean.java b/app/src/main/java/safeluck/drive/evaluation/DB/route/RouteBean.java new file mode 100644 index 0000000..4fd42c5 --- /dev/null +++ b/app/src/main/java/safeluck/drive/evaluation/DB/route/RouteBean.java @@ -0,0 +1,33 @@ +package safeluck.drive.evaluation.DB.route; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * DriveJudge + * Created by lzw on 2020/9/16. 15:44:19 + * 閭锛�632393724@qq.com + * All Rights Saved! Chongqing AnYun Tech co. LTD + */ +@Entity +public class RouteBean { + @PrimaryKey(autoGenerate = true) + private int id; + private String routeName; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getRouteName() { + return routeName; + } + + public void setRouteName(String routeName) { + this.routeName = routeName; + } +} diff --git a/app/src/main/java/safeluck/drive/evaluation/DB/route/RouteBeanDao.java b/app/src/main/java/safeluck/drive/evaluation/DB/route/RouteBeanDao.java new file mode 100644 index 0000000..d6d7205 --- /dev/null +++ b/app/src/main/java/safeluck/drive/evaluation/DB/route/RouteBeanDao.java @@ -0,0 +1,24 @@ +package safeluck.drive.evaluation.DB.route; + +import androidx.lifecycle.LiveData; +import androidx.room.Dao; +import androidx.room.Insert; +import androidx.room.OnConflictStrategy; +import androidx.room.Query; + +import java.util.List; + +/** + * DriveJudge + * Created by lzw on 2020/9/16. 15:49:36 + * 閭锛�632393724@qq.com + * All Rights Saved! Chongqing AnYun Tech co. LTD + */ +@Dao +public interface RouteBeanDao { + @Query("SELECT * FROM RouteBean") + LiveData<List<RouteBean>> getAllRoutes(); + + @Insert(onConflict = OnConflictStrategy.REPLACE) + void insertRouteBean(RouteBean routeBean); +} diff --git a/app/src/main/java/safeluck/drive/evaluation/DB/route/RouteCross.java b/app/src/main/java/safeluck/drive/evaluation/DB/route/RouteCross.java new file mode 100644 index 0000000..18739e9 --- /dev/null +++ b/app/src/main/java/safeluck/drive/evaluation/DB/route/RouteCross.java @@ -0,0 +1,62 @@ +package safeluck.drive.evaluation.DB.route; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * DriveJudge + * Created by lzw on 2020/9/16. 15:13:34 + * 閭锛�632393724@qq.com + * All Rights Saved! Chongqing AnYun Tech co. LTD + */ +@Entity +public class RouteCross { + //澶栭敭 璺熺嚎璺悕绉癷d 淇濇寔涓�鑷� + private int road; + private int idx; + private int active; + private int routeline_id; + + @PrimaryKey(autoGenerate = true) + private int id; + + public int getRoad() { + return road; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public void setRoad(int road) { + this.road = road; + } + + public int getIdx() { + return idx; + } + + public void setIdx(int idx) { + this.idx = idx; + } + + public int getActive() { + return active; + } + + public void setActive(int active) { + this.active = active; + } + + public int getRouteline_id() { + return routeline_id; + } + + public void setRouteline_id(int routeline_id) { + this.routeline_id = routeline_id; + } +} diff --git a/app/src/main/java/safeluck/drive/evaluation/DB/route/RouteCrossDao.java b/app/src/main/java/safeluck/drive/evaluation/DB/route/RouteCrossDao.java new file mode 100644 index 0000000..2ca893d --- /dev/null +++ b/app/src/main/java/safeluck/drive/evaluation/DB/route/RouteCrossDao.java @@ -0,0 +1,23 @@ +package safeluck.drive.evaluation.DB.route; + +import androidx.lifecycle.LiveData; +import androidx.room.Dao; +import androidx.room.Insert; +import androidx.room.OnConflictStrategy; +import androidx.room.Query; + +import java.util.List; + +/** + * DriveJudge + * Created by lzw on 2020/9/16. 15:41:55 + * 閭锛�632393724@qq.com + * All Rights Saved! Chongqing AnYun Tech co. LTD + */ +@Dao +public interface RouteCrossDao { + @Insert(onConflict = OnConflictStrategy.REPLACE) + void insertRouteCross(RouteCross routeCross); + @Query("SELECT * FROM RouteCross where routeline_id = :routeline_id") + List<RouteCross> getAllRouteCross(int routeline_id); +} diff --git a/app/src/main/java/safeluck/drive/evaluation/DB/route/RouteInitWorker.java b/app/src/main/java/safeluck/drive/evaluation/DB/route/RouteInitWorker.java new file mode 100644 index 0000000..4f6f1f9 --- /dev/null +++ b/app/src/main/java/safeluck/drive/evaluation/DB/route/RouteInitWorker.java @@ -0,0 +1,83 @@ +package safeluck.drive.evaluation.DB.route; + +import android.content.Context; +import android.util.Log; + +import androidx.annotation.NonNull; +import androidx.work.Worker; +import androidx.work.WorkerParameters; + +import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; +import com.google.gson.stream.JsonReader; + +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.lang.reflect.Type; +import java.util.List; + +import okhttp3.Route; +import safeluck.drive.evaluation.DB.Student; +import safeluck.drive.evaluation.DB.WorkRoomDataBase; +import safeluck.drive.evaluation.bean.RouteCollect; + +/** + * DriveJudge + * Created by lzw on 2020/9/16. 16:00:40 + * 閭锛�632393724@qq.com + * All Rights Saved! Chongqing AnYun Tech co. LTD + */ +public class RouteInitWorker extends Worker { + private static final String TAG = "RouteInitWorker"; + public RouteInitWorker(@NonNull Context context, @NonNull WorkerParameters workerParams) { + super(context, workerParams); + } + + @NonNull + @Override + public Result doWork() { + Log.i(TAG, "doWork: "+Thread.currentThread().getId()); + try { + InputStream inputStream = getApplicationContext().getAssets().open("routeline.json"); + InputStreamReader inputStreamReader = new InputStreamReader(inputStream); + JsonReader jsonReader = new JsonReader(inputStreamReader); + + Gson gson = new Gson(); + Type type = new TypeToken<List<RouteCollect>>(){}.getType(); + + List<RouteCollect> mstus=gson.fromJson(jsonReader, type); + for (int i = 0; i < mstus.size(); i++) { + RouteBean routeBean = new RouteBean(); + routeBean.setRouteName(mstus.get(i).getName()); + WorkRoomDataBase.getWorkRoomDataBase(getApplicationContext()).getRouteBeanDao().insertRouteBean(routeBean); + RouteCollect routeCollect = mstus.get(i); + List<RouteCollect.CrossingActiveBean>crossingActiveBeans = routeCollect.getCrossing_active(); + List<RouteCollect.TriggerLineBean> triggerLineBeans = routeCollect.getTrigger_line(); + for (RouteCollect.TriggerLineBean bean:triggerLineBeans){ + RouteTriggerLine routeTriggerLine = new RouteTriggerLine(); + routeTriggerLine.setRoad(bean.getRoad()); + routeTriggerLine.setRouteline_id(i+1); + routeTriggerLine.setType(bean.getType()); + routeTriggerLine.setX(bean.getX_y().get(0)); + routeTriggerLine.setY(bean.getX_y().get(1)); + WorkRoomDataBase.getWorkRoomDataBase(getApplicationContext()).getRouteTriggerLineDao().insertTriggerLine(routeTriggerLine); + } + for (RouteCollect.CrossingActiveBean bean:crossingActiveBeans){ + RouteCross routeCross = new RouteCross(); + routeCross.setActive(bean.getActive()); + routeCross.setIdx(bean.getIdx()); + routeCross.setRoad(bean.getRoad()); + routeCross.setRouteline_id(i+1); + WorkRoomDataBase.getWorkRoomDataBase(getApplicationContext()).getRouteCrooDao().insertRouteCross(routeCross); + } + + } + + } catch (IOException e) { + e.printStackTrace(); + return Result.failure(); + } + return Result.success(); + } +} diff --git a/app/src/main/java/safeluck/drive/evaluation/DB/route/RouteLineRepository.java b/app/src/main/java/safeluck/drive/evaluation/DB/route/RouteLineRepository.java new file mode 100644 index 0000000..37e4593 --- /dev/null +++ b/app/src/main/java/safeluck/drive/evaluation/DB/route/RouteLineRepository.java @@ -0,0 +1,75 @@ +package safeluck.drive.evaluation.DB.route; + +import android.app.Application; + +import androidx.lifecycle.LiveData; + +import java.util.List; + +import safeluck.drive.evaluation.DB.Student; +import safeluck.drive.evaluation.DB.StudentDao; +import safeluck.drive.evaluation.DB.WorkRoomDataBase; + +/** + * MyApplication2 + * Created by lzw on 2019/11/25. 11:20:26 + * 閭锛�632393724@qq.com + * All Rights Saved! Chongqing AnYun Tech co. LTD + */ +public class RouteLineRepository { + private RouteCrossDao routeCrossDao; + private RouteBeanDao routeBeanDao; + private RouteTriggerLineDao routeTriggerLineDao; + private List<RouteCross> routeCrosses; + private List<RouteTriggerLine> routeTriggerLines; + private LiveData<List<RouteBean>> routeBeans; + + public RouteLineRepository(Application application){ + WorkRoomDataBase db = WorkRoomDataBase.getWorkRoomDataBase(application); + routeCrossDao = db.getRouteCrooDao(); + routeBeanDao = db.getRouteBeanDao(); + routeTriggerLineDao = db.getRouteTriggerLineDao(); + routeBeans = routeBeanDao.getAllRoutes(); + } + + public List<RouteCross> getAllRouteCross(int routeId){ + routeCrosses = routeCrossDao.getAllRouteCross(routeId); + return routeCrosses; + } + public List<RouteTriggerLine> getAllRouteTriggerlines(int routeId){ + routeTriggerLines = routeTriggerLineDao.getAllRouteTriggerLine(routeId); + return routeTriggerLines; + } + + void insertRouteCross(final RouteCross routeCross){ + WorkRoomDataBase.dataBaseWriteExecutor.execute(new Runnable() { + @Override + public void run() { + routeCrossDao.insertRouteCross(routeCross); + } + }); + } + + void insertRouteTriggerLine(final RouteTriggerLine routeTriggerLine){ + WorkRoomDataBase.dataBaseWriteExecutor.execute(new Runnable() { + @Override + public void run() { + routeTriggerLineDao.insertTriggerLine(routeTriggerLine); + } + }); + } + + void insertRouteBean(final RouteBean routeBean){ + WorkRoomDataBase.dataBaseWriteExecutor.execute(new Runnable() { + @Override + public void run() { + routeBeanDao.insertRouteBean(routeBean); + } + }); + } + + + public LiveData<List<RouteBean>> getAllRouteBeans() { + return routeBeans; + } +} diff --git a/app/src/main/java/safeluck/drive/evaluation/DB/route/RouteLineViewModel.java b/app/src/main/java/safeluck/drive/evaluation/DB/route/RouteLineViewModel.java new file mode 100644 index 0000000..3387e3e --- /dev/null +++ b/app/src/main/java/safeluck/drive/evaluation/DB/route/RouteLineViewModel.java @@ -0,0 +1,53 @@ +package safeluck.drive.evaluation.DB.route; + +import android.app.Application; + +import androidx.annotation.NonNull; +import androidx.lifecycle.AndroidViewModel; +import androidx.lifecycle.LiveData; + +import java.util.List; + +import safeluck.drive.evaluation.DB.Student; +import safeluck.drive.evaluation.DB.WorkRepository; + +/** + * MyApplication2 + * Created by lzw on 2019/11/25. 11:34:24 + * 閭锛�632393724@qq.com + * All Rights Saved! Chongqing AnYun Tech co. LTD + */ +public class RouteLineViewModel extends AndroidViewModel { + public RouteLineViewModel(@NonNull Application application) { + super(application); + workRepository = new RouteLineRepository(application); + routeBeans = workRepository.getAllRouteBeans(); + + } + + private RouteLineRepository workRepository; +// private LiveData<List<RouteTriggerLine>> routeTriggerLines; +// private LiveData<List<RouteCross>> routeCrosses; + private LiveData<List<RouteBean>> routeBeans; + +// public LiveData<List<RouteTriggerLine>> getAllRouteTriggerlines() { +// return routeTriggerLines; +// } + public LiveData<List<RouteBean>> getRouteBeans() { + return routeBeans; + } + + public void insertRouteCross(RouteCross routeCross){ + workRepository.insertRouteCross(routeCross); + } + public void insertRouteBean(RouteBean routeBean){ + workRepository.insertRouteBean(routeBean); + } + + public void insertRouteTriggerLine(RouteTriggerLine routeTriggerLine){ + workRepository.insertRouteTriggerLine(routeTriggerLine); + } + + + +} diff --git a/app/src/main/java/safeluck/drive/evaluation/DB/route/RouteTriggerLine.java b/app/src/main/java/safeluck/drive/evaluation/DB/route/RouteTriggerLine.java new file mode 100644 index 0000000..3eedea7 --- /dev/null +++ b/app/src/main/java/safeluck/drive/evaluation/DB/route/RouteTriggerLine.java @@ -0,0 +1,74 @@ +package safeluck.drive.evaluation.DB.route; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +import java.util.List; + +/** + * DriveJudge + * Created by lzw on 2020/9/16. 15:06:32 + * 閭锛�632393724@qq.com + * All Rights Saved! Chongqing AnYun Tech co. LTD + */ +@Entity +public class RouteTriggerLine { + @PrimaryKey(autoGenerate = true) + private int id; + private int road; + private int type; + private double x; + private double y; + + //澶栭敭 璺熺嚎璺悕绉癷d 淇濇寔涓�鑷� + + private int routeline_id; + + public int getRouteline_id() { + return routeline_id; + } + + public void setRouteline_id(int routeline_id) { + this.routeline_id = routeline_id; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public int getRoad() { + return road; + } + + public void setRoad(int road) { + this.road = road; + } + + public int getType() { + return type; + } + + public void setType(int type) { + this.type = type; + } + + public double getX() { + return x; + } + + public void setX(double x) { + this.x = x; + } + + public double getY() { + return y; + } + + public void setY(double y) { + this.y = y; + } +} diff --git a/app/src/main/java/safeluck/drive/evaluation/DB/route/RouteTriggerLineDao.java b/app/src/main/java/safeluck/drive/evaluation/DB/route/RouteTriggerLineDao.java new file mode 100644 index 0000000..767cdf4 --- /dev/null +++ b/app/src/main/java/safeluck/drive/evaluation/DB/route/RouteTriggerLineDao.java @@ -0,0 +1,24 @@ +package safeluck.drive.evaluation.DB.route; + +import androidx.lifecycle.LiveData; +import androidx.room.Dao; +import androidx.room.Insert; +import androidx.room.OnConflictStrategy; +import androidx.room.Query; + +import java.util.List; + +/** + * DriveJudge + * Created by lzw on 2020/9/16. 15:09:49 + * 閭锛�632393724@qq.com + * All Rights Saved! Chongqing AnYun Tech co. LTD + */ +@Dao +public interface RouteTriggerLineDao { + @Query("Select * from RouteTriggerLine where routeline_id =:routeline_id") + List<RouteTriggerLine> getAllRouteTriggerLine(int routeline_id); + + @Insert(onConflict = OnConflictStrategy.REPLACE) + void insertTriggerLine(RouteTriggerLine routeTriggerLine); +} diff --git a/app/src/main/java/safeluck/drive/evaluation/bean/RouteCollect.java b/app/src/main/java/safeluck/drive/evaluation/bean/RouteCollect.java new file mode 100644 index 0000000..4e5b67d --- /dev/null +++ b/app/src/main/java/safeluck/drive/evaluation/bean/RouteCollect.java @@ -0,0 +1,122 @@ +package safeluck.drive.evaluation.bean; + +import java.util.List; + +/** + * DriveJudge + * + * 涓昏鐢ㄤ簬鏁欑粌韪╃偣锛� 涓�涓猂outeCollect灏辨槸涓�鏉$嚎璺� + * 鍙互鏈夊涓Е鍙戠嚎锛屽涓矾鍙� + * Created by lzw on 2020/9/16. 10:03:06 + * 閭锛�632393724@qq.com + * All Rights Saved! Chongqing AnYun Tech co. LTD + */ +public class RouteCollect { + + + /** + * 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}] + */ + + private String name; + private List<CrossingActiveBean> crossing_active; + private List<TriggerLineBean> trigger_line; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public List<CrossingActiveBean> getCrossing_active() { + return crossing_active; + } + + public void setCrossing_active(List<CrossingActiveBean> crossing_active) { + this.crossing_active = crossing_active; + } + + public List<TriggerLineBean> getTrigger_line() { + return trigger_line; + } + + public void setTrigger_line(List<TriggerLineBean> trigger_line) { + this.trigger_line = trigger_line; + } + + public static class CrossingActiveBean { + /** + * road : 2 + * idx : 0 + * active : 1 + */ + + private int road; + private int idx; + private int active; + + public int getRoad() { + return road; + } + + public void setRoad(int road) { + this.road = road; + } + + public int getIdx() { + return idx; + } + + public void setIdx(int idx) { + this.idx = idx; + } + + public int getActive() { + return active; + } + + public void setActive(int active) { + this.active = active; + } + } + + public static class TriggerLineBean { + /** + * x_y : [333.365,696.3354] + * road : 2 + * type : 2 + */ + + private int road; + private int type; + private List<Double> x_y; + + public int getRoad() { + return road; + } + + public void setRoad(int road) { + this.road = road; + } + + public int getType() { + return type; + } + + public void setType(int type) { + this.type = type; + } + + public List<Double> getX_y() { + return x_y; + } + + public void setX_y(List<Double> x_y) { + this.x_y = x_y; + } + } +} diff --git a/app/src/main/java/safeluck/drive/evaluation/fragment/TrainFragment.java b/app/src/main/java/safeluck/drive/evaluation/fragment/TrainFragment.java index 2e54272..4e9853f 100644 --- a/app/src/main/java/safeluck/drive/evaluation/fragment/TrainFragment.java +++ b/app/src/main/java/safeluck/drive/evaluation/fragment/TrainFragment.java @@ -52,10 +52,12 @@ import safeluck.drive.evaluation.Constant; import safeluck.drive.evaluation.DB.Student; import safeluck.drive.evaluation.DB.WokViewModel; +import safeluck.drive.evaluation.DB.WorkRoomDataBase; import safeluck.drive.evaluation.DB.exam_status.ExamStatus; import safeluck.drive.evaluation.DB.exam_status.ExamStatusViewModel; import safeluck.drive.evaluation.DB.failitems.FailedProjViewModel; import safeluck.drive.evaluation.DB.failitems.FailedProj_select; +import safeluck.drive.evaluation.DB.route.RouteLineViewModel; import safeluck.drive.evaluation.MainActivity; import safeluck.drive.evaluation.R; import safeluck.drive.evaluation.adapter.ScoreAdapter; @@ -75,6 +77,7 @@ import safeluck.drive.evaluation.platformMessage.JKMessage0202; import safeluck.drive.evaluation.platformMessage.JKMessage0204; import safeluck.drive.evaluation.platformMessage.PlatFormConstant; +import safeluck.drive.evaluation.util.CThreadPoolExecutor; import safeluck.drive.evaluation.util.Utils; import safeluck.drive.evaluation.widget.StatusDialog; @@ -87,19 +90,22 @@ public class TrainFragment extends SupportFragment implements View.OnClickListener { private static final String TAG = TrainFragment.class.getSimpleName(); + private static final int ROUTE_COLLECT = 5;//绾胯矾閲囬泦鏍囧織 + public static SupportFragment newInstance() { return new TrainFragment(); } - - - private int exam_type = 2;//2 鍦哄湴锛�3 閬撹矾锛屾ā鎷熷鑰冿紱4 閬撹矾锛屽疄闄呭鑰冿紱 + private View route_collect; + private View items,items_score; + private int exam_type = 2;//2 鍦哄湴锛�3 閬撹矾锛屾ā鎷熷鑰冿紱4 閬撹矾锛屽疄闄呭鑰� 5,绾胯矾閲囬泦锛� private ListView mListView; private Button btn_start_exam; private TextView tv_stop;//鍛煎彨璇锋眰锛堢粨鏉熻�冭瘯锛� private ScoreAdapter mScoreAdapter; private Button av_zhijiao, av_curve, av_park, av_podao; private Button houseView; + private RouteLineViewModel routeLineViewModel; private List<ExamStatus> examStatusList = new ArrayList<>(); private List<String> item_conents = new ArrayList<>();//鍧¢亾瀹氱偣鍋滆溅鍜岃捣姝� @@ -333,14 +339,28 @@ private void showChangKaoOrLukao(int exam_type){ - if (exam_type > ExamPlatformData.EXAM_TYPE_ChangKAO){ - //show璺�� - view.findViewById(R.id.lukao).setVisibility(View.VISIBLE); - view.findViewById(R.id.changkao).setVisibility(View.GONE); + if (exam_type >= ExamPlatformData.EXAM_TYPE_ChangKAO && exam_type<ROUTE_COLLECT){ + items_score.setVisibility(View.VISIBLE); + items.setVisibility(View.VISIBLE); + route_collect.setVisibility(View.GONE); + if(exam_type == ExamPlatformData.EXAM_TYPE_ChangKAO) { + //show鍦鸿�� + view.findViewById(R.id.lukao).setVisibility(View.GONE); + view.findViewById(R.id.changkao).setVisibility(View.VISIBLE); + }else{ + + //show璺�� + view.findViewById(R.id.lukao).setVisibility(View.VISIBLE); + view.findViewById(R.id.changkao).setVisibility(View.GONE); + } + }else{ - //show鍦鸿�� - view.findViewById(R.id.lukao).setVisibility(View.GONE); - view.findViewById(R.id.changkao).setVisibility(View.VISIBLE); + if (exam_type == ROUTE_COLLECT){ + items_score.setVisibility(View.GONE); + items.setVisibility(View.GONE); + route_collect.setVisibility(View.VISIBLE); + } + } } View view; @@ -351,7 +371,7 @@ initView(view); failedProjViewModel = ViewModelProviders.of(this).get(FailedProjViewModel.class); - + routeLineViewModel = ViewModelProviders.of(this).get(RouteLineViewModel.class); failedProjViewModel.getFailedProjectsForIII(Constant.TEST_STU_ID).observe(this, new Observer<List<FailedProj_select>>() { @Override @@ -457,7 +477,12 @@ mHandler.obtainMessage(ADD_DATA).sendToTarget(); exam_type = examStatus.get(0).getStartExam(); if (exam_type != Constant.NONE_BEEN_START_EXAM){ - btn_start_exam.setText("缁撴潫璁粌"); + if (ROUTE_COLLECT == exam_type){ + btn_start_exam.setText("缁撴潫閲囬泦"); + }else{ + + btn_start_exam.setText("缁撴潫璁粌"); + } }else{ btn_start_exam.setText("寮�濮嬭缁�"); } @@ -499,6 +524,9 @@ private void initView(View view) { + items = view.findViewById(R.id.items); + items_score=view.findViewById(R.id.items_score); + route_collect=view.findViewById(R.id.route_collect); Log.i(TAG,"currTopFragment="+getTopFragment().getClass().getSimpleName()); if (HomeFragment.class.getSimpleName().equals(getTopFragment().getClass().getSimpleName())){ ((MainActivity)_mActivity).viewtitle.setVisibility(View.GONE); @@ -588,12 +616,30 @@ sendJK0202(4); }else{ Toast.makeText(_mActivity, "绾胯矾閲囬泦", Toast.LENGTH_SHORT).show(); + ExamPlatformData.getInstance().setTrainingMode(ExamPlatformData.TRAINING_MODE); + exam_type = 5; + examStatusViewModel.updateStartExam(exam_type); + items.setVisibility(View.GONE); + items_score.setVisibility(View.GONE); + route_collect.setVisibility(View.VISIBLE); } } }); selectDialog.show(getFragmentManager(),"selectdialog"); }else{ + if (exam_type == ROUTE_COLLECT){ + Toast.makeText(_mActivity, "缁撴潫閲囬泦", Toast.LENGTH_SHORT).show(); + + ExamPlatformData.getInstance().setTrainingMode(ExamPlatformData.MODE_NONE); + exam_type = 0; + examStatusViewModel.updateStartExam(exam_type); + items.setVisibility(View.VISIBLE); + items_score.setVisibility(View.VISIBLE); + route_collect.setVisibility(View.GONE); + }else{ + stopExam(); + } } @@ -696,7 +742,10 @@ } private void sendJK0202(int type) { - + //闅愯棌閲囬泦椤圭洰 + 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); diff --git a/app/src/main/java/safeluck/drive/evaluation/routecollect/CollectPointResult.java b/app/src/main/java/safeluck/drive/evaluation/routecollect/CollectPointResult.java new file mode 100644 index 0000000..57b0647 --- /dev/null +++ b/app/src/main/java/safeluck/drive/evaluation/routecollect/CollectPointResult.java @@ -0,0 +1,37 @@ +package safeluck.drive.evaluation.routecollect; + +/** + * DriveJudge + * Created by lzw on 2020/9/16. 10:11:08 + * 閭锛�632393724@qq.com + * All Rights Saved! Chongqing AnYun Tech co. LTD + */ +public class CollectPointResult { + + private double x,y,z; + + public double getX() { + return x; + } + + public void setX(double x) { + this.x = x; + } + + public double getY() { + return y; + } + + public void setY(double y) { + this.y = y; + } + + public double getZ() { + return z; + } + + public void setZ(double z) { + this.z = z; + } + +} diff --git a/app/src/main/java/safeluck/drive/evaluation/routecollect/ICollectView.java b/app/src/main/java/safeluck/drive/evaluation/routecollect/ICollectView.java new file mode 100644 index 0000000..53c9ff4 --- /dev/null +++ b/app/src/main/java/safeluck/drive/evaluation/routecollect/ICollectView.java @@ -0,0 +1,18 @@ +package safeluck.drive.evaluation.routecollect; + +/** + * DriveJudge + * Created by lzw on 2020/9/16. 10:12:23 + * 閭锛�632393724@qq.com + * All Rights Saved! Chongqing AnYun Tech co. LTD + */ +public interface ICollectView { + void beginCollectView(); + void endCollectView(); + + /** + * 瀹屾垚涓�椤圭洰鐨勯噰闆� + * @param collectPointResult + */ + void routeItem(CollectPointResult collectPointResult ); +} diff --git a/app/src/main/java/safeluck/drive/evaluation/routecollect/ILoadListener.java b/app/src/main/java/safeluck/drive/evaluation/routecollect/ILoadListener.java new file mode 100644 index 0000000..3c79882 --- /dev/null +++ b/app/src/main/java/safeluck/drive/evaluation/routecollect/ILoadListener.java @@ -0,0 +1,12 @@ +package safeluck.drive.evaluation.routecollect; + +/** + * DriveJudge + * Created by lzw on 2020/9/16. 10:54:19 + * 閭锛�632393724@qq.com + * All Rights Saved! Chongqing AnYun Tech co. LTD + */ +public interface ILoadListener { + + void finishCollectItem(CollectPointResult collectPointResult); +} diff --git a/app/src/main/java/safeluck/drive/evaluation/routecollect/IRouteCollectInterface.java b/app/src/main/java/safeluck/drive/evaluation/routecollect/IRouteCollectInterface.java new file mode 100644 index 0000000..ccfca56 --- /dev/null +++ b/app/src/main/java/safeluck/drive/evaluation/routecollect/IRouteCollectInterface.java @@ -0,0 +1,19 @@ +package safeluck.drive.evaluation.routecollect; + +/** + * DriveJudge + * Created by lzw on 2020/9/16. 10:08:53 + * 閭锛�632393724@qq.com + * All Rights Saved! Chongqing AnYun Tech co. LTD + */ +public interface IRouteCollectInterface { + /** + * 寮�濮嬭俯鐐� 涓嶆柇鐨勮繑鍥炵偣鍧愭爣 + */ + void startCollect(ILoadListener listener); + + /** + * 鍛婅瘔杩滅▼鏈嶅姟 鍋滄閲囩偣锛屼笉瑕佷竴鐩磋繑鐐圭殑鍧愭爣浜� + */ + void endCollect(); +} diff --git a/app/src/main/java/safeluck/drive/evaluation/routecollect/IRouteRemotePointCallback.java b/app/src/main/java/safeluck/drive/evaluation/routecollect/IRouteRemotePointCallback.java new file mode 100644 index 0000000..0da552c --- /dev/null +++ b/app/src/main/java/safeluck/drive/evaluation/routecollect/IRouteRemotePointCallback.java @@ -0,0 +1,13 @@ +package safeluck.drive.evaluation.routecollect; + +/** + * 瀛樻斁c缁欑殑鍥炶皟锛� + * dge + * Created by lzw on 2020/9/16. 10:46:00 + * 閭锛�632393724@qq.com + * All Rights Saved! Chongqing AnYun Tech co. LTD + */ +public interface IRouteRemotePointCallback { + void javaPoint(final int qf, final double x, final double y, final double z,final double heading, + final double pitch,final double roll); +} diff --git a/app/src/main/java/safeluck/drive/evaluation/routecollect/RouteCollectController.java b/app/src/main/java/safeluck/drive/evaluation/routecollect/RouteCollectController.java new file mode 100644 index 0000000..a72b4ce --- /dev/null +++ b/app/src/main/java/safeluck/drive/evaluation/routecollect/RouteCollectController.java @@ -0,0 +1,44 @@ +package safeluck.drive.evaluation.routecollect; + +import safeluck.drive.evaluation.routecollect.impl.RouteModel; + +/** + * DriveJudge + * Created by lzw on 2020/9/16. 10:08:18 + * 閭锛�632393724@qq.com + * All Rights Saved! Chongqing AnYun Tech co. LTD + */ +public class RouteCollectController implements ILoadListener { + + ICollectView iCollectView; + RouteModel routeModel; + + + public void RouteCollectController(ICollectView collectView){ + this.iCollectView = collectView; + routeModel = new RouteModel(); + } + + public void startCollect() { + if (iCollectView != null){ + iCollectView.beginCollectView(); + } + if (routeModel != null){ + routeModel.startCollect(this); + } + } + + public void endCollect(){ + if (iCollectView != null){ + iCollectView.endCollectView(); + } + } + + @Override + public void finishCollectItem(CollectPointResult collectPointResult) { + if (iCollectView != null){ + iCollectView.endCollectView(); + iCollectView.routeItem(collectPointResult); + } + } +} diff --git a/app/src/main/java/safeluck/drive/evaluation/routecollect/impl/RouteModel.java b/app/src/main/java/safeluck/drive/evaluation/routecollect/impl/RouteModel.java new file mode 100644 index 0000000..fe352fa --- /dev/null +++ b/app/src/main/java/safeluck/drive/evaluation/routecollect/impl/RouteModel.java @@ -0,0 +1,48 @@ +package safeluck.drive.evaluation.routecollect.impl; + +import com.anyun.exam.lib.IRemoteInterface; + +import safeluck.drive.evaluation.routecollect.CollectPointResult; +import safeluck.drive.evaluation.routecollect.ILoadListener; +import safeluck.drive.evaluation.routecollect.IRouteCollectInterface; +import safeluck.drive.evaluation.routecollect.IRouteRemotePointCallback; + +/** + * DriveJudge + * Created by lzw on 2020/9/16. 10:38:39 + * 閭锛�632393724@qq.com + * All Rights Saved! Chongqing AnYun Tech co. LTD + */ +public class RouteModel implements IRouteCollectInterface,IRouteRemotePointCallback { + + ILoadListener iLoadListener; + private double sx=120.0,sy=10.03; + @Override + public void startCollect(ILoadListener listener) { + iLoadListener = listener; + //璋冪敤AYSdk 鏂规硶鍚姩閲囩偣 + //set IRouteRemotePointCallback + + //濡傛灉閲囩敤application鐨刢allback 锛屽彲鑳介渶瑕佹敞鍐屼竴涓狢EventLisntener + } + + /** + * 鍋滄閲囩偣 + */ + @Override + public void endCollect() { + //濡傛灉閲囩敤application鐨刢allback 锛屽彲鑳介渶瑕佸弽娉ㄥ唽涓�涓狢EventLisntener 瑙g粦 + } + + + @Override + public void javaPoint(int qf, double x, double y, double z, double heading, double pitch, double roll) { + + if (iLoadListener != null){ + CollectPointResult collectPointResult = new CollectPointResult(); + collectPointResult.setX(sx); + collectPointResult.setY(sy); + iLoadListener.finishCollectItem(collectPointResult); + } + } +} diff --git a/app/src/main/res/layout/layout_train_fragment.xml b/app/src/main/res/layout/layout_train_fragment.xml index 15d8e93..ffece7b 100644 --- a/app/src/main/res/layout/layout_train_fragment.xml +++ b/app/src/main/res/layout/layout_train_fragment.xml @@ -12,10 +12,12 @@ android:id="@+id/ll" android:orientation="vertical"> <include android:layout_marginBottom="2dp" android:layout_width="match_parent" android:layout_height="110dp" android:id="@+id/profile" layout="@layout/profile_layout"/> - <include android:layout_marginBottom="2dp" android:layout_width="match_parent" android:layout_height="140dp" layout="@layout/layout_net_train" android:visibility="gone" /> + <include android:layout_marginBottom="2dp" android:layout_width="match_parent" android:layout_height="140dp" layout="@layout/layout_net_train" android:id="@+id/items"/> - <include android:layout_marginBottom="2dp" android:layout_width="match_parent" android:layout_height="match_parent" layout="@layout/layout_stu_score" android:visibility="gone"/> - <include android:layout_marginBottom="2dp" android:layout_width="match_parent" android:layout_height="match_parent" layout="@layout/layout_project_collect"/> + <include android:layout_marginBottom="2dp" android:layout_width="match_parent" android:layout_height="match_parent" layout="@layout/layout_stu_score" android:id="@+id/items_score"/> + <include android:layout_marginBottom="2dp" android:layout_width="match_parent" android:layout_height="match_parent" layout="@layout/layout_project_collect" + android:id="@+id/route_collect" + android:visibility="gone"/> </LinearLayout> -- Gitblit v1.8.0