diff --git a/OCH/mogo-och-sweeper/build.gradle b/OCH/mogo-och-sweeper/build.gradle index 51769361c2..a1aa90420b 100644 --- a/OCH/mogo-och-sweeper/build.gradle +++ b/OCH/mogo-och-sweeper/build.gradle @@ -18,7 +18,7 @@ android { javaCompileOptions { annotationProcessorOptions { - arguments = [AROUTER_MODULE_NAME: project.getName()] + arguments = [AROUTER_MODULE_NAME: project.getName(),"room.schemaLocation": "$projectDir/schemas".toString()] } } } @@ -53,6 +53,8 @@ dependencies { implementation rootProject.ext.dependencies.rxandroid implementation rootProject.ext.dependencies.androidxrecyclerview implementation rootProject.ext.dependencies.androidxcardview + implementation rootProject.ext.dependencies.androidxroomruntime + annotationProcessor rootProject.ext.dependencies.androidxroomcompiler implementation project(":OCH:mogo-och-common-module") compileOnly project(":libraries:mogo-map") diff --git a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/bean/WeltDataBean.kt b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/bean/WeltDataBean.kt deleted file mode 100644 index c0f6809f37..0000000000 --- a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/bean/WeltDataBean.kt +++ /dev/null @@ -1,10 +0,0 @@ -package com.mogo.och.sweeper.bean - -data class WeltDataBean( - var locLon: Double,//经度 - var locLat: Double,//纬度 - var weltDistance: Double,//贴边距离 - var cleanMode: Int,//清扫模式 - var cleanDirection: Int,//清扫方向 - var cleanIntensity: Int,//作业强度 -) \ No newline at end of file diff --git a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/constant/SweeperConst.kt b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/constant/SweeperConst.kt index ec51cbe709..9dbf2304af 100644 --- a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/constant/SweeperConst.kt +++ b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/constant/SweeperConst.kt @@ -9,7 +9,8 @@ class SweeperConst { companion object { private const val BASE_URL_OCH_DEV = "http://tech-dev.zhidaohulian.com" - private const val BASE_URL_OCH_QA = "https://tech-qa.zhidaohulian.com" + //private const val BASE_URL_OCH_QA = "https://tech-qa.zhidaohulian.com" + private const val BASE_URL_OCH_QA = "http://sweep-dev.svc.zhidaoauto.com" private const val BASE_URL_OCH_RELEASE = "https://tech.zhidaohulian.com" @JvmStatic diff --git a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/database/MyDataBase.java b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/database/MyDataBase.java new file mode 100644 index 0000000000..69b363a9b8 --- /dev/null +++ b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/database/MyDataBase.java @@ -0,0 +1,29 @@ +package com.mogo.och.sweeper.database; + +import com.mogo.commons.AbsMogoApplication; +import com.mogo.och.sweeper.database.bean.WeltDataBean; +import com.mogo.och.sweeper.database.dao.WeltDataDao; + +import androidx.room.Database; +import androidx.room.Room; +import androidx.room.RoomDatabase; + +//注解Database告诉系统这是Room数据库对象 +//entities指定该数据库有哪些表,多张表就逗号分隔 +//version指定数据库版本号,升级时需要用到 +//数据库继承自RoomDatabase +@Database(entities = {WeltDataBean.class}, version = 1) +public abstract class MyDataBase extends RoomDatabase { + private static final String DATABASE_NAME = "weltData_db"; + + //结合单例模式完成数据库实例创建 + public static MyDataBase getInstance() { + return SingleTon.instance; + } + + private static class SingleTon { + private static final MyDataBase instance = + Room.databaseBuilder(AbsMogoApplication.getApp().getApplicationContext(), MyDataBase.class, DATABASE_NAME).build(); + } + public abstract WeltDataDao getWeltDataDao(); +} diff --git a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/database/bean/WeltDataBean.java b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/database/bean/WeltDataBean.java new file mode 100644 index 0000000000..8ca4a6d676 --- /dev/null +++ b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/database/bean/WeltDataBean.java @@ -0,0 +1,125 @@ +package com.mogo.och.sweeper.database.bean; + +import androidx.room.ColumnInfo; +import androidx.room.Entity; +import androidx.room.Index; +import androidx.room.PrimaryKey; + +@Entity(tableName = WeltDataBean.WeltDataTable, indices = {@Index(value = "id", unique = true)}) +public class WeltDataBean { + + public static final String WeltDataTable = "welt_data_table"; + //ColumnInfo用于指定该字段存储在表中的名字,并指定类型 + + @PrimaryKey(autoGenerate = true) + + @ColumnInfo(name = "id", typeAffinity = ColumnInfo.INTEGER) + + private int id; + + @ColumnInfo(name = "subTaskId", typeAffinity = ColumnInfo.INTEGER)//子任务id + + private int subTaskId; + + @ColumnInfo(name = "locLon", typeAffinity = ColumnInfo.REAL) + + private double locLon;//自车RTK定位经度 + + @ColumnInfo(name = "locLat", typeAffinity = ColumnInfo.REAL) + + private double locLat;//自车RTK定位纬度 + + @ColumnInfo(name = "weltDistance", typeAffinity = ColumnInfo.REAL) + + private double weltDistance;//贴边距离 + + @ColumnInfo(name = "cleanMode", typeAffinity = ColumnInfo.INTEGER) + + private int cleanMode;//清扫作业模式 1–纯扫 2--洗扫, 3--纯洗, 4--纯吸 + + @ColumnInfo(name = "cleanDirection", typeAffinity = ColumnInfo.INTEGER) + + private int cleanDirection;//清扫方向 1--两侧, 2--左侧, 3--右侧 + + @ColumnInfo(name = "cleanIntensity", typeAffinity = ColumnInfo.INTEGER) + + private int cleanIntensity;//清扫强度 1--两侧, 2--左侧, 3--右侧 + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public int getSubTaskId() { + return subTaskId; + } + + public void setSubTaskId(int subTaskId) { + this.subTaskId = subTaskId; + } + + public double getLocLon() { + return locLon; + } + + public void setLocLon(double locLon) { + this.locLon = locLon; + } + + public double getLocLat() { + return locLat; + } + + public void setLocLat(double locLat) { + this.locLat = locLat; + } + + public double getWeltDistance() { + return weltDistance; + } + + public void setWeltDistance(double weltDistance) { + this.weltDistance = weltDistance; + } + + public int getCleanMode() { + return cleanMode; + } + + public void setCleanMode(int cleanMode) { + this.cleanMode = cleanMode; + } + + public int getCleanDirection() { + return cleanDirection; + } + + public void setCleanDirection(int cleanDirection) { + this.cleanDirection = cleanDirection; + } + + public int getCleanIntensity() { + return cleanIntensity; + } + + public void setCleanIntensity(int cleanIntensity) { + this.cleanIntensity = cleanIntensity; + } + + @Override + public String toString() { + return "WeltDataBean{" + + "id=" + id + + ", subTaskId='" + subTaskId + '\'' + + ", locLon=" + locLon + + ", locLat=" + locLat + + ", weltDistance=" + weltDistance + + ", cleanMode=" + cleanMode + + ", cleanDirection=" + cleanDirection + + ", cleanIntensity=" + cleanIntensity + + '}'; + } +} diff --git a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/database/dao/WeltDataDao.java b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/database/dao/WeltDataDao.java new file mode 100644 index 0000000000..097be3af3e --- /dev/null +++ b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/database/dao/WeltDataDao.java @@ -0,0 +1,27 @@ +package com.mogo.och.sweeper.database.dao; + +import com.mogo.och.sweeper.database.bean.WeltDataBean; + +import java.util.List; + +import androidx.room.Dao; +import androidx.room.Insert; +import androidx.room.OnConflictStrategy; +import androidx.room.Query; + +import static com.mogo.och.sweeper.database.bean.WeltDataBean.WeltDataTable; + +@Dao +public interface WeltDataDao { + //插入数据 + @Insert(onConflict = OnConflictStrategy.REPLACE) + void insert(WeltDataBean fileInfo); + + //删除所有数据 + @Query("DELETE FROM " + WeltDataTable) + int deleteAllWeltData(); + + //查询所有数据 + @Query("SELECT * FROM " + WeltDataTable) + List loadAllWeltDataInfo(); +} diff --git a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/fragment/BaseSweeperTabFragment.java b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/fragment/BaseSweeperTabFragment.java index 1ca537c04e..87c5911065 100644 --- a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/fragment/BaseSweeperTabFragment.java +++ b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/fragment/BaseSweeperTabFragment.java @@ -1,12 +1,14 @@ package com.mogo.och.sweeper.fragment; import android.os.Bundle; +import android.os.Looper; import android.view.LayoutInflater; import android.view.View; import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.LinearLayout; +import com.amap.api.maps.model.LatLng; import com.mogo.commons.AbsMogoApplication; import com.mogo.commons.mvp.IView; import com.mogo.commons.mvp.MvpFragment; @@ -18,6 +20,7 @@ import com.mogo.eagle.core.function.call.hmi.CallerHmiManager; import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager; import com.mogo.eagle.core.function.view.MapBizView; import com.mogo.eagle.core.utilcode.mogo.view.OnPreventFastClickListener; +import com.mogo.eagle.core.utilcode.util.UiThreadHandler; import com.mogo.map.listener.IMogoMapListener; import com.mogo.map.listener.MogoMapListenerHandler; import com.mogo.map.marker.IMogoMarkerManager; @@ -26,7 +29,7 @@ import com.mogo.map.uicontroller.VisualAngleMode; import com.mogo.och.common.module.map.AmapNaviToDestinationModel; import com.mogo.och.common.module.utils.CoordinateCalculateRouteUtil; import com.mogo.och.sweeper.R; -import com.mogo.och.sweeper.bean.WeltDataBean; +import com.mogo.och.sweeper.database.bean.WeltDataBean; import com.mogo.och.sweeper.callback.IWeltMapSwitchToSmallCallback; import com.mogo.och.sweeper.view.SweeperTrafficDataView; import com.mogo.och.sweeper.view.WeltSmallMapView; @@ -332,6 +335,7 @@ public abstract class BaseSweeperTabFragment weltDataBeans) { + if (mMapWeltView != null) { + mMapWeltView.setWeltData(weltDataBeans); + runOnUIThread(() -> { + mMapWeltView.drawablePolyline(); + }); + } + if (mWeltMapOverViewFragment != null && mWeltMapOverViewFragment.isVisible()) { + mWeltMapOverViewFragment.setWeltData(weltDataBeans); + runOnUIThread(() -> { + mWeltMapOverViewFragment.drawablePolyline(); + }); + } + } + + /** + * 添加起点和终点 + */ + public void addStartAndEndMarker(LatLng startPoint, LatLng endPoint) { + if (mMapWeltView != null) { + mMapWeltView.addStartAndEndMarker(startPoint, endPoint); + } + if (mWeltMapOverViewFragment != null && mWeltMapOverViewFragment.isVisible()) { + mWeltMapOverViewFragment.addStartAndEndMarker(startPoint, endPoint); + } + } + + /** + * 清除marker标记和任务路线数据 + */ + public void clearAllMarkerAndPolyline() { + if (mMapWeltView != null) { + mMapWeltView.clearAllMarkerAndPolyline(); + } + if (mWeltMapOverViewFragment != null) { + mWeltMapOverViewFragment.clearAllMarkerAndPolyline(); + } + } + + private void runOnUIThread(Runnable executor) { + if (executor == null) { + return; + } + if (Looper.myLooper() != Looper.getMainLooper()) { + UiThreadHandler.post(executor); + } else { + executor.run(); + } + } + /** * mock 贴边假数据 */ private void setWeltData() { List weltDataBean = new ArrayList<>(); - weltDataBean.add(new WeltDataBean(116.38851540542558, 39.97419244219622, -10, 1, 1, 1)); - weltDataBean.add(new WeltDataBean(116.38777443467706, 39.96694323029558, 8, 1, 1, 1)); - weltDataBean.add(new WeltDataBean(116.39311478161825, 39.967085313029074, 16, 1, 1, 1)); - weltDataBean.add(new WeltDataBean(116.40963237692603, 39.975055860562826, 30, 1, 1, 1)); - weltDataBean.add(new WeltDataBean(116.41146331146084, 39.97513910337909, -9999.0, 1, 1, 1)); - weltDataBean.add(new WeltDataBean(116.40748849300006, 39.96752223478818, -10000.0, 1, 1, 1)); - weltDataBean.add(new WeltDataBean(116.42670283855335, 39.97526250389533, 1000, 1, 1, 1)); - mMapWeltView.setWeltData(weltDataBean); - mMapWeltView.drawablePolyline(); + weltDataBean.add(getWeltDataBean(116.38851540542558, 39.97419244219622, -10.0)); + weltDataBean.add(getWeltDataBean(116.38777443467706, 39.96694323029558, 8.0)); + weltDataBean.add(getWeltDataBean(116.39311478161825, 39.967085313029074, 16.0)); + weltDataBean.add(getWeltDataBean(116.40963237692603, 39.975055860562826, 30.0)); + weltDataBean.add(getWeltDataBean(116.41146331146084, 39.97513910337909, -9999.0)); + weltDataBean.add(getWeltDataBean(116.40748849300006, 39.96752223478818, -10000.0)); + weltDataBean.add(getWeltDataBean(116.42670283855335, 39.97526250389533, 1000.0)); + setWeltDataToMap(weltDataBean); + addStartAndEndMarker(CoordinateCalculateRouteUtil.coordinateConverterWgsToGcj(AbsMogoApplication.getApp(),116.38851540542558,39.97419244219622), + CoordinateCalculateRouteUtil.coordinateConverterWgsToGcj(AbsMogoApplication.getApp(),116.42670283855335,39.97526250389533)); + } + + private WeltDataBean getWeltDataBean(Double locLon, Double locLat, Double weltDistance) { + //把wgs坐标系坐标转换成gcj坐标 + LatLng latLng= CoordinateCalculateRouteUtil.coordinateConverterWgsToGcj(AbsMogoApplication.getApp(),locLon,locLat); + WeltDataBean weltDataBean = new WeltDataBean(); + weltDataBean.setLocLon(latLng.longitude); + weltDataBean.setLocLat(latLng.latitude); + weltDataBean.setWeltDistance(weltDistance); + return weltDataBean; } } diff --git a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/fragment/SweeperFragment.kt b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/fragment/SweeperFragment.kt index 06aa396ffa..6bc5c66ae4 100644 --- a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/fragment/SweeperFragment.kt +++ b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/fragment/SweeperFragment.kt @@ -2,6 +2,8 @@ package com.mogo.och.sweeper.fragment import android.os.Bundle import android.view.View +import androidx.annotation.MainThread +import androidx.annotation.UiThread import androidx.recyclerview.widget.LinearLayoutManager import chassis.ChassisStatesOuterClass import com.mogo.eagle.core.data.map.MogoLocation @@ -186,7 +188,7 @@ class SweeperFragment : BaseSweeperTabFragment = ArrayList() - weltDataBean.add(WeltDataBean(116.38851540542558, 39.97419244219622, -10.0, 1, 1, 1)) - weltDataBean.add(WeltDataBean(116.38777443467706, 39.96694323029558, 8.0, 1, 1, 1)) - weltDataBean.add(WeltDataBean(116.39311478161825, 39.967085313029074, 16.0, 1, 1, 1)) - weltDataBean.add(WeltDataBean(116.40963237692603, 39.975055860562826, 30.0, 1, 1, 1)) - weltDataBean.add(WeltDataBean(116.41146331146084, 39.97513910337909, -9999.0, 1, 1, 1)) - weltDataBean.add(WeltDataBean(116.40748849300006, 39.96752223478818, -10000.0, 1, 1, 1)) - weltDataBean.add(WeltDataBean(116.42670283855335, 39.97526250389533, 1000.0, 1, 1, 1)) - weltMapOverView.setWeltData(weltDataBean) - weltMapOverView.drawablePolyline() - weltMapOverView.addStartAndEndMarker( - CoordinateCalculateRouteUtil.coordinateConverterWgsToGcj(context, 116.38851540542558, 39.97419244219622), - CoordinateCalculateRouteUtil.coordinateConverterWgsToGcj( - context, 116.42670283855335, 39.97526250389533 - ) - ) + fun setWeltData(weltDatas:MutableList) { + weltMapOverView.setWeltData(weltDatas) } + /** + * 绘制任务路线数据 + */ + fun drawablePolyline(){ + weltMapOverView.drawablePolyline() + } + /** + * 添加起点和终点marker + */ + fun addStartAndEndMarker(startPoint: LatLng, endPoint: LatLng){ + weltMapOverView.drawStartAndEndMarker(startPoint,endPoint) + } + + fun clearAllMarkerAndPolyline(){ + weltMapOverView.clearAllMarkerAndPolyline() + } /** * 设置图例数据 */ diff --git a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/presenter/SweeperPresenter.java b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/presenter/SweeperPresenter.java index 36508c47a5..ff44ca41a0 100644 --- a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/presenter/SweeperPresenter.java +++ b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/presenter/SweeperPresenter.java @@ -2,6 +2,7 @@ package com.mogo.och.sweeper.presenter; import android.os.Looper; +import com.amap.api.maps.model.LatLng; import com.amap.api.navi.model.NaviLatLng; import com.mogo.commons.AbsMogoApplication; import com.mogo.commons.mvp.Presenter; @@ -17,6 +18,7 @@ import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger; import com.mogo.eagle.core.utilcode.util.UiThreadHandler; import com.mogo.och.common.module.manager.OCHAdasAbilityManager; import com.mogo.och.common.module.map.AmapNaviToDestinationModel; +import com.mogo.och.common.module.utils.CoordinateCalculateRouteUtil; import com.mogo.och.sweeper.bean.SweeperMainTaskBean; import com.mogo.och.sweeper.bean.SweeperSubTaskBean; import com.mogo.och.sweeper.bean.SweeperSubTaskDetailBean; @@ -25,6 +27,8 @@ import com.mogo.och.sweeper.callback.ISweeperControllerStatusCallback; import com.mogo.och.sweeper.callback.ISweeperTaskCallback; import com.mogo.och.sweeper.constant.SubTaskTypeEnum; import com.mogo.och.sweeper.constant.TaskStatusEnum; +import com.mogo.och.sweeper.database.MyDataBase; +import com.mogo.och.sweeper.database.bean.WeltDataBean; import com.mogo.och.sweeper.fragment.SweeperFragment; import com.mogo.och.sweeper.model.SweeperTaskModel; import com.mogo.och.sweeper.util.SweeperFutianCmdUtil; @@ -59,10 +63,15 @@ public class SweeperPresenter extends Presenter private int mSubTaskId = 0; //当前是否最后一个子任务 private boolean mIsLastSubtask = false; - // 底盘数据回调时间间隔 + // 清扫模式回调时间间隔 private static final long VEHICLE_STATE_INTERVAL_MILLIS = 500L; - // 当前时间戳 - private long mCurrentTimeMillis; + // 清扫模式当前时间戳 + private long mVehicleStateCurrentTimeMillis; + + // 贴边数据回调时间间隔 + private static final long WELT_DATA_INTERVAL_MILLIS = 2000L; + // 贴边数据当前时间戳 + private long mWeltDataCurrentTimeMillis; public SweeperPresenter(SweeperFragment view) { super(view); @@ -172,6 +181,10 @@ public class SweeperPresenter extends Presenter } + /** + * 当前子任务id + * @param mSubTaskId + */ public void setSubTaskId(int mSubTaskId) { this.mSubTaskId = mSubTaskId; SweeperTaskModel.getInstance().setSubTaskId(mSubTaskId); @@ -235,11 +248,14 @@ public class SweeperPresenter extends Presenter @Override public void onSweeperFutianCleanSystemState(@NonNull ChassisStatesOuterClass.SweeperFuTianTaskSystemStates cleanSystemState) { - long current = System.currentTimeMillis(); - if (current - mCurrentTimeMillis <= VEHICLE_STATE_INTERVAL_MILLIS) { + if (cleanSystemState==null){ return; } - mCurrentTimeMillis = current; + long current = System.currentTimeMillis(); + if (current - mVehicleStateCurrentTimeMillis <= VEHICLE_STATE_INTERVAL_MILLIS) { + return; + } + mVehicleStateCurrentTimeMillis = current; boolean clean_open_requirement = cleanSystemState.getSecuMotWorkSts(); // 洗扫 boolean clean_mode_wash_sweep = cleanSystemState.getSecuModWashSweepSts(); @@ -286,13 +302,46 @@ public class SweeperPresenter extends Presenter .append(clean_intensity_strong); CallerLogger.INSTANCE.d(M_SWEEPER + TAG, "onSweeperFutianCleanSystemState:"+stringBuilder); - runOnUIThread(() -> mView.onSweeperFutianCleanSystemState(cleanSystemState)); + mView.onSweeperFutianCleanSystemState(cleanSystemState); } @Override public void onSweeperFutianTaskIndexData(@NonNull RoboSweeperTaskIndexOuterClass.RoboSweeperTaskIndex roboSweeperTaskIndex) { - - + long current = System.currentTimeMillis(); + if (current - mWeltDataCurrentTimeMillis <= WELT_DATA_INTERVAL_MILLIS) { + return; + } + mWeltDataCurrentTimeMillis = current; + if (roboSweeperTaskIndex==null){ + return; + } + StringBuilder stringBuilder = new StringBuilder(); + stringBuilder.append("清扫模式:") + .append(roboSweeperTaskIndex.getCleanMode()) + .append("清扫方向:") + .append(roboSweeperTaskIndex.getCleanDirection()) + .append("清扫强度:") + .append(roboSweeperTaskIndex.getCleanIntensity()) + .append("贴边距离:") + .append(roboSweeperTaskIndex.getDistToRefEdgePoint()) + .append("经度:") + .append(roboSweeperTaskIndex.getLocLon()) + .append("纬度:") + .append(roboSweeperTaskIndex.getLocLat()); + CallerLogger.INSTANCE.d(M_SWEEPER + TAG, "onSweeperFutianTaskIndexData:"+stringBuilder); + //保存贴边数据到数据库中 + WeltDataBean weltDataBean=new WeltDataBean(); + //把wgs坐标系坐标转换成gcj坐标 + LatLng latLng=CoordinateCalculateRouteUtil.coordinateConverterWgsToGcj(AbsMogoApplication.getApp(),roboSweeperTaskIndex.getLocLon(),roboSweeperTaskIndex.getLocLat()); + weltDataBean.setLocLon(latLng.longitude); + weltDataBean.setLocLat(latLng.latitude); + weltDataBean.setWeltDistance(roboSweeperTaskIndex.getDistToRefEdgePoint()); + weltDataBean.setCleanMode(roboSweeperTaskIndex.getCleanMode()); + weltDataBean.setCleanDirection(roboSweeperTaskIndex.getCleanDirection()); + weltDataBean.setCleanIntensity(roboSweeperTaskIndex.getCleanIntensity()); + weltDataBean.setSubTaskId(mSubTaskId); + MyDataBase.getInstance().getWeltDataDao().insert(weltDataBean); + mView.setWeltDataToMap(MyDataBase.getInstance().getWeltDataDao().loadAllWeltDataInfo()); } /** diff --git a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/view/WeltMapOverView.kt b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/view/WeltMapOverView.kt index 749767df93..5d28df4ec5 100644 --- a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/view/WeltMapOverView.kt +++ b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/view/WeltMapOverView.kt @@ -15,9 +15,8 @@ import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationGCJ02Liste import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ02ListenerManager import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant -import com.mogo.och.common.module.utils.CoordinateCalculateRouteUtil import com.mogo.och.sweeper.R -import com.mogo.och.sweeper.bean.WeltDataBean +import com.mogo.och.sweeper.database.bean.WeltDataBean import kotlinx.android.synthetic.main.sweeper_welt_map_overview.view.* /** @@ -31,8 +30,10 @@ class WeltMapOverView : ConstraintLayout, IMoGoChassisLocationGCJ02Listener { private var mPolyline: Polyline? = null private var colorList: MutableList = mutableListOf() private val mLineMarkers: MutableList = mutableListOf() + //清扫车任务地图 private val TAG = "WeltMapOverView" + constructor(context: Context) : super(context) {} constructor(context: Context, attrs: AttributeSet?) : super(context, attrs) { initView(context) @@ -49,6 +50,7 @@ class WeltMapOverView : ConstraintLayout, IMoGoChassisLocationGCJ02Listener { CallerChassisLocationGCJ02ListenerManager.addListener(TAG, this) setLegendData() } + private fun initAMapView() { mAMap = sweeperTextureMapView.map // 地图文字标注 @@ -62,7 +64,7 @@ class WeltMapOverView : ConstraintLayout, IMoGoChassisLocationGCJ02Listener { // 设置 锚点 图标 mCarMarker = mAMap?.addMarker( MarkerOptions() - .icon(BitmapDescriptorFactory.fromResource(R.drawable.sweeper_car_small)) + .icon(BitmapDescriptorFactory.fromResource(R.drawable.sweeper_car_big)) .anchor(0.5f, 0.5f) ) // 设置地图的样式 @@ -99,6 +101,7 @@ class WeltMapOverView : ConstraintLayout, IMoGoChassisLocationGCJ02Listener { } } } + override fun onChassisLocationGCJ02(mogoLocation: MogoLocation?) { mogoLocation?.let { gnssInfo -> val currentLatLng = LatLng(gnssInfo.latitude, gnssInfo.longitude) @@ -118,6 +121,7 @@ class WeltMapOverView : ConstraintLayout, IMoGoChassisLocationGCJ02Listener { } } } + /** * 根据贴边数据绘制任务路线 */ @@ -140,9 +144,9 @@ class WeltMapOverView : ConstraintLayout, IMoGoChassisLocationGCJ02Listener { } /** - * 添加起点和终点的marker + * 绘制起点和终点的marker */ - fun addStartAndEndMarker(startPoint: LatLng, endPoint: LatLng) { + fun drawStartAndEndMarker(startPoint: LatLng, endPoint: LatLng) { val startMarker = mAMap?.addMarker(MarkerOptions().icon(BitmapDescriptorFactory.fromResource(R.drawable.start_maker_icon))) startMarker?.position = startPoint mLineMarkers.add(startMarker) @@ -152,32 +156,26 @@ class WeltMapOverView : ConstraintLayout, IMoGoChassisLocationGCJ02Listener { } /** - * 清除maker + * 清除所有标记和路线 */ - private fun clearMarkers() { + public fun clearAllMarkerAndPolyline() { + mPolyline?.remove() for (i in mLineMarkers.indices) { mLineMarkers[i]?.isVisible = false mLineMarkers[i]?.remove() } mLineMarkers.clear() } - - /** - * 清除任务路线 - */ - fun clearPolyline() { - mPolyline?.remove() - } - /** * 设置贴边数据 */ fun setWeltData(weltData: MutableList) { this.mWeltData = weltData for (i in mWeltData.indices) { - mCoordinatesLatLng.add(CoordinateCalculateRouteUtil.coordinateConverterWgsToGcj(context, mWeltData[i].locLon, mWeltData[i].locLat)) + mCoordinatesLatLng.add(LatLng(mWeltData[i].locLat, mWeltData[i].locLon)) } } + /** * 设置图例数据 */ diff --git a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/view/WeltSmallMapView.kt b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/view/WeltSmallMapView.kt index 0f0829095e..be0c79afc6 100644 --- a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/view/WeltSmallMapView.kt +++ b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/view/WeltSmallMapView.kt @@ -16,7 +16,7 @@ import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant import com.mogo.och.common.module.utils.CoordinateCalculateRouteUtil import com.mogo.och.sweeper.R -import com.mogo.och.sweeper.bean.WeltDataBean +import com.mogo.och.sweeper.database.bean.WeltDataBean import kotlinx.android.synthetic.main.sweeper_welt_small_map_view.view.* /** @@ -104,7 +104,7 @@ class WeltSmallMapView : ConstraintLayout, IMoGoChassisLocationGCJ02Listener { uiSettings?.setLogoBottomMargin(-150) //设置Logo下边界距离屏幕底部的边距,设置为负值即可 mAMap?.setOnMapLoadedListener(AMap.OnMapLoadedListener { d(SceneConstant.M_SWEEPER + TAG, "WeltView---onMapLoaded") - //mAMap?.setPointToCenter(mAMapNaviView?.width?.div(2) ?: 0, mAMapNaviView?.height?.div(2) ?: 0) + mAMap?.setPointToCenter(sweeperSmallTextureMapView.width / 2, sweeperSmallTextureMapView.height / 2) }) } @@ -145,7 +145,6 @@ class WeltSmallMapView : ConstraintLayout, IMoGoChassisLocationGCJ02Listener { polylineOptions.colorValues(colorList) // 绘制线 mPolyline = mAMap?.addPolyline(polylineOptions) - addStartAndEndMarker(mCoordinatesLatLng[0], mCoordinatesLatLng[mCoordinatesLatLng.size - 1]) } } } @@ -153,7 +152,7 @@ class WeltSmallMapView : ConstraintLayout, IMoGoChassisLocationGCJ02Listener { /** * 添加起点和终点的marker */ - private fun addStartAndEndMarker(startPoint: LatLng, endPoint: LatLng) { + fun addStartAndEndMarker(startPoint: LatLng, endPoint: LatLng) { val startMarker = mAMap?.addMarker(MarkerOptions().icon(BitmapDescriptorFactory.fromResource(R.drawable.start_maker_icon))) startMarker?.position = startPoint mLineMarkers.add(startMarker) @@ -163,23 +162,16 @@ class WeltSmallMapView : ConstraintLayout, IMoGoChassisLocationGCJ02Listener { } /** - * 清除数据 + * 清除所有标记和路线 */ - private fun clearMarkers() { + fun clearAllMarkerAndPolyline() { + mPolyline?.remove() for (i in mLineMarkers.indices) { mLineMarkers[i]?.isVisible = false mLineMarkers[i]?.remove() } mLineMarkers.clear() } - - /** - * 清除任务路线 - */ - fun clearPolyline() { - mPolyline?.remove() - } - /** * 设置贴边数据 */ diff --git a/OCH/mogo-och-sweeper/src/main/res/drawable-xhdpi/sweeper_car_big.png b/OCH/mogo-och-sweeper/src/main/res/drawable-xhdpi/sweeper_car_big.png new file mode 100644 index 0000000000..b30095f4c9 Binary files /dev/null and b/OCH/mogo-och-sweeper/src/main/res/drawable-xhdpi/sweeper_car_big.png differ