[清扫车]贴边数据精确到厘米,保存二位小数处理

This commit is contained in:
bxb
2023-03-01 19:56:28 +08:00
parent 0e75ce4cc8
commit e00fb594ae
7 changed files with 20 additions and 39 deletions

View File

@@ -7,5 +7,5 @@ data class WeltDataEvent(
var type:Int, //1.添加起点和终点 2.实时添加贴边数据 3.清除数据
var weltDataBeanList: MutableList<WeltDataBean>?,
var markers:MutableList<LatLng>?,
var distance:Double//贴边数据
var distance:String//贴边数据
)

View File

@@ -1,7 +1,6 @@
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;
@@ -32,8 +31,8 @@ import com.mogo.map.uicontroller.IMogoMapUIController;
import com.mogo.map.uicontroller.VisualAngleMode;
import com.mogo.och.common.module.map.AmapNaviToDestinationModel;
import com.mogo.och.sweeper.R;
import com.mogo.och.sweeper.database.bean.WeltDataBean;
import com.mogo.och.sweeper.callback.IWeltMapSwitchToSmallCallback;
import com.mogo.och.sweeper.database.bean.WeltDataBean;
import com.mogo.och.sweeper.event.WeltDataEvent;
import com.mogo.och.sweeper.view.SweeperTrafficDataView;
import com.mogo.och.sweeper.view.WeltSmallMapView;
@@ -41,14 +40,10 @@ import com.mogo.och.sweeper.view.WeltSmallMapView;
import org.greenrobot.eventbus.EventBus;
import java.util.ArrayList;
import java.util.List;
import androidx.annotation.NonNull;
import androidx.constraintlayout.widget.Group;
import androidx.fragment.app.FragmentTransaction;
import bag_manager.BagManagerOuterClass;
import mogo.telematics.pad.MessagePad;
import record_cache.RecordPanelOuterClass;
/**
* 网约车基础Fragment主要负责布局通用界面处理站点面板和通话面板互斥情况
@@ -224,27 +219,6 @@ public abstract class BaseSweeperTabFragment<V extends IView, P extends Presente
super.onDestroyView();
CallerAutopilotRecordListenerManager.INSTANCE.removeListener(TAG);
}
@Override
public void onAutopilotRecordResult(@Nullable RecordPanelOuterClass.RecordPanel recordPanel) {
// if (!HmiBuildConfig.isShowBadCaseView && recordPanel != null && recordPanel.getType() == 1 && recordPanel.getStat() == 100) {
// CallerDevaToolsManager.INSTANCE.onReceiveBadCaseRecord(recordPanel);
// }
}
@Override
public void onAutopilotRecordConfig(@NonNull MessagePad.RecordDataConfig config) {
}
@Override
public void onBagManagerResult(@NonNull BagManagerOuterClass.BagManager bagManager) {
}
/**
* 测试到站
*/
protected abstract void debugArrivedStation();
private void initListener() {
MogoMapListenerHandler.Companion.getMogoMapListenerHandler().registerHostMapListener(TAG, this);
mCloseNavIcon.setOnClickListener(this);
@@ -448,7 +422,7 @@ public abstract class BaseSweeperTabFragment<V extends IView, P extends Presente
*
* @param weltDataBeans
*/
public void setWeltDataToMap(ArrayList<WeltDataBean> weltDataBeans,Boolean isWeltData,double distance) {
public void setWeltDataToMap(ArrayList<WeltDataBean> weltDataBeans,Boolean isWeltData,String distance) {
if (mMapWeltView != null) {
UiThreadHandler.post(()->{
mMapWeltView.setWeltData(weltDataBeans,isWeltData,distance);
@@ -470,7 +444,7 @@ public abstract class BaseSweeperTabFragment<V extends IView, P extends Presente
latLngs.add(0, startPoint);
latLngs.add(1, endPoint);
this.latLngList = latLngs;
EventBus.getDefault().postSticky(new WeltDataEvent(1, null, latLngs,0));
EventBus.getDefault().postSticky(new WeltDataEvent(1, null, latLngs,""));
}
/**
@@ -480,7 +454,7 @@ public abstract class BaseSweeperTabFragment<V extends IView, P extends Presente
if (mMapWeltView != null) {
mMapWeltView.clearAllMarkerAndPolyline();
}
EventBus.getDefault().postSticky(new WeltDataEvent(3, null, null,0));
EventBus.getDefault().postSticky(new WeltDataEvent(3, null, null,""));
}
/**
* 导航去目的地

View File

@@ -446,7 +446,7 @@ class SweeperFragment : BaseSweeperTabFragment<SweeperFragment?, SweeperPresente
endWeltData.weltDistance=-9999.0
dataList.add(endWeltData)
}
setWeltDataToMap(dataList,false,0.0)
setWeltDataToMap(dataList,false,"0")
}
}

View File

@@ -53,7 +53,7 @@ class WeltMapOverViewFragment(var mIWeltMapSwitchToSmallCallBack: IWeltMapSwitch
}
}
weltDataList?.let {
setWeltData(it,false,0.0)
setWeltData(it,false,"")
drawablePolyline()
}
}
@@ -119,7 +119,7 @@ class WeltMapOverViewFragment(var mIWeltMapSwitchToSmallCallBack: IWeltMapSwitch
/**
* 设置任务路线数据
*/
private fun setWeltData(weltDatas: MutableList<WeltDataBean>?,isWeltData:Boolean,distance:Double) {
private fun setWeltData(weltDatas: MutableList<WeltDataBean>?,isWeltData:Boolean,distance:String) {
weltMapOverView.setWeltData(weltDatas,isWeltData,distance)
}

View File

@@ -33,6 +33,8 @@ import com.mogo.och.sweeper.util.SweeperTrajectoryManager;
import org.jetbrains.annotations.NotNull;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.List;
@@ -327,9 +329,14 @@ public class SweeperPresenter extends Presenter<SweeperFragment>
weltDataBean.setCleanIntensity(roboSweeperTaskIndex.getCleanIntensity());
weltDataBean.setSubTaskId(mSubTaskId);
MyDataBase.getInstance().getWeltDataDao().insert(weltDataBean);
mView.setWeltDataToMap((ArrayList<WeltDataBean>) MyDataBase.getInstance().getWeltDataDao().loadAllWeltDataInfo(), true,roboSweeperTaskIndex.getDistToRefEdgePoint());
String distance=format(roboSweeperTaskIndex.getDistToRefEdgePoint()*100);
mView.setWeltDataToMap((ArrayList<WeltDataBean>) MyDataBase.getInstance().getWeltDataDao().loadAllWeltDataInfo(), true,distance);
}
public static String format(double value) {
BigDecimal bd = new BigDecimal(value);
bd = bd.setScale(2, RoundingMode.HALF_UP);
return bd.toString();
}
/**
* 获取当前正在执行的任务
*/

View File

@@ -173,7 +173,7 @@ class WeltMapOverView : ConstraintLayout, IMoGoChassisLocationGCJ02Listener {
/**
* 设置贴边数据
*/
fun setWeltData(weltData: MutableList<WeltDataBean>?, isWeltData: Boolean, distance: Double) {
fun setWeltData(weltData: MutableList<WeltDataBean>?, isWeltData: Boolean, distance: String) {
if (weltData != null) {
this.mWeltData.addAll(weltData)
for (i in mWeltData.indices) {
@@ -200,7 +200,7 @@ class WeltMapOverView : ConstraintLayout, IMoGoChassisLocationGCJ02Listener {
sweeperLegend6.setData(R.drawable.sweeper_legend6, "未经过")
}
private fun setDistance(distance: Double) {
private fun setDistance(distance: String) {
taskWeltDistanceTv.text = "贴边:${distance}cm"
}

View File

@@ -209,7 +209,7 @@ class WeltSmallMapView : ConstraintLayout, IMoGoChassisLocationGCJ02Listener {
/**
* 设置贴边数据
*/
fun setWeltData(weltData: MutableList<WeltDataBean>,isWeltData: Boolean,distance:Double) {
fun setWeltData(weltData: MutableList<WeltDataBean>,isWeltData: Boolean,distance:String) {
this.mWeltData = weltData
for (i in mWeltData.indices) {
mCoordinatesLatLng.add(CoordinateCalculateRouteUtil.coordinateConverterWgsToGcj(context, mWeltData[i].locLon, mWeltData[i].locLat))