[清扫车]接口联调相关问题修改
This commit is contained in:
@@ -3,11 +3,14 @@ package com.mogo.och.sweeper.bean
|
||||
/**
|
||||
* 子任务信息
|
||||
*/
|
||||
data class SweeperSubTaskBean(var taskId:Int=0,
|
||||
var taskName:String?,
|
||||
var taskStartTime:Long=0,
|
||||
var sort:Int=1,
|
||||
var subList:MutableList<SubInfo>?)
|
||||
data class SweeperSubTaskBean(
|
||||
var taskId: Int = 0,
|
||||
var taskName: String?,
|
||||
var taskStartTime: Long = 0,
|
||||
var sort: Int = 1,
|
||||
var subList: MutableList<SubInfo>?
|
||||
)
|
||||
|
||||
data class SubInfo(
|
||||
var taskId: Int = 0,
|
||||
var taskName: String?,
|
||||
@@ -15,9 +18,11 @@ data class SubInfo(
|
||||
var taskStatus: Int,// 状态1未执行 2执行中 3结束 4跳过
|
||||
var taskType: Int,//1自动驾驶 2人工驾驶
|
||||
var timeSpent: String,
|
||||
var startWgs84Lon:Double,//起点经度
|
||||
var startWgs84Lat:Double,//起点纬度
|
||||
var endWgs84Lon:Double,//终点经度
|
||||
var endWgs84Lat:Double,//终点纬度
|
||||
var startSiteName: String,//起点名称
|
||||
var startWgs84Lon: Double,//起点经度
|
||||
var startWgs84Lat: Double,//起点纬度
|
||||
var endSiteName: String,//终点名称
|
||||
var endWgs84Lon: Double,//终点经度
|
||||
var endWgs84Lat: Double,//终点纬度
|
||||
var sort: Int = 0,
|
||||
)
|
||||
@@ -8,5 +8,5 @@ enum class TaskStatusEnum(val code: Int) {
|
||||
END_TASK( 2),//结束主任务
|
||||
CANCEL_TASK( 3),//取消
|
||||
START_SUBTASK(4),//开始子任务
|
||||
END_SUBTASK(4),//结束子任务
|
||||
END_SUBTASK(5),//结束子任务
|
||||
}
|
||||
@@ -1,12 +1,14 @@
|
||||
package com.mogo.och.sweeper.database.bean;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
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 class WeltDataBean implements Serializable {
|
||||
|
||||
public static final String WeltDataTable = "welt_data_table";
|
||||
//ColumnInfo用于指定该字段存储在表中的名字,并指定类型
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.mogo.och.sweeper.database.dao;
|
||||
|
||||
import com.mogo.och.sweeper.database.bean.WeltDataBean;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import androidx.room.Dao;
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.mogo.och.sweeper.event
|
||||
|
||||
import com.amap.api.maps.model.LatLng
|
||||
import com.mogo.och.sweeper.database.bean.WeltDataBean
|
||||
|
||||
data class WeltDataEvent(
|
||||
var type:Int, //1.添加起点和终点 2.实时添加贴边数据 3.清除数据
|
||||
var weltDataBeanList: MutableList<WeltDataBean>?,
|
||||
var markers:MutableList<LatLng>?
|
||||
)
|
||||
@@ -9,6 +9,7 @@ import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import com.amap.api.maps.model.LatLng;
|
||||
import com.amap.api.navi.model.NaviLatLng;
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.commons.mvp.IView;
|
||||
import com.mogo.commons.mvp.MvpFragment;
|
||||
@@ -30,7 +31,6 @@ import com.mogo.map.marker.IMogoMarkerManager;
|
||||
import com.mogo.map.uicontroller.IMogoMapUIController;
|
||||
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.database.bean.WeltDataBean;
|
||||
import com.mogo.och.sweeper.callback.IWeltMapSwitchToSmallCallback;
|
||||
@@ -89,6 +89,8 @@ public abstract class BaseSweeperTabFragment<V extends IView, P extends Presente
|
||||
private DriverMsgBoxButtonView mViewDriverMsgBoxButton;
|
||||
private DriverMsgBoxListView mViewDriverMsgBoxList;
|
||||
private DriverMsgBoxBubbleView mViewDriverMsgBoxBubble;
|
||||
private ArrayList<WeltDataBean> weltDataBeanList;//存储贴边数据
|
||||
private ArrayList<LatLng> latLngList;//存储任务起点和终点
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
@@ -133,7 +135,17 @@ public abstract class BaseSweeperTabFragment<V extends IView, P extends Presente
|
||||
findViewById(R.id.btnAutopilotRunning).setOnClickListener(view ->
|
||||
debugAutoPilotStatus(IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING)
|
||||
);
|
||||
|
||||
// 模拟 结束子任务
|
||||
findViewById(R.id.btnEndTask).setOnClickListener(view ->
|
||||
debugEndSubTask()
|
||||
);
|
||||
mTrafficDataView.setOnLongClickListener(new View.OnLongClickListener() {
|
||||
@Override
|
||||
public boolean onLongClick(View v) {
|
||||
debugTestBar();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void updateSwitchMapIcon() {
|
||||
@@ -154,8 +166,6 @@ public abstract class BaseSweeperTabFragment<V extends IView, P extends Presente
|
||||
super.initViews(savedInstanceState);
|
||||
mapBizView.onCreate(savedInstanceState);
|
||||
mMapWeltView.onCreateView(savedInstanceState);
|
||||
//mock 贴边数据
|
||||
setWeltData();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -218,7 +228,6 @@ public abstract class BaseSweeperTabFragment<V extends IView, P extends Presente
|
||||
mRefreshNavi.setOnClickListener(this);
|
||||
mMapWeltView.getSwitchToBig().setOnClickListener((v) -> {
|
||||
showOrHideOverMapViewFragment(true);
|
||||
setWeltData();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -276,7 +285,7 @@ public abstract class BaseSweeperTabFragment<V extends IView, P extends Presente
|
||||
}
|
||||
|
||||
/**
|
||||
* bus调试面板打开关闭
|
||||
* sweeper调试面板打开关闭
|
||||
*/
|
||||
public void debugTestBar() {
|
||||
if (groupTestPanel.getVisibility() == View.VISIBLE) {
|
||||
@@ -381,7 +390,7 @@ public abstract class BaseSweeperTabFragment<V extends IView, P extends Presente
|
||||
if (isShow) {
|
||||
mFlWeltMapOverView.setVisibility(View.VISIBLE);
|
||||
if (mWeltMapOverViewFragment == null) {
|
||||
mWeltMapOverViewFragment = mWeltMapOverViewFragment.newInstance(this);
|
||||
mWeltMapOverViewFragment = mWeltMapOverViewFragment.newInstance(this,weltDataBeanList,latLngList);
|
||||
}
|
||||
if (mWeltMapOverViewFragment.isHidden()) {
|
||||
transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
|
||||
@@ -416,14 +425,15 @@ public abstract class BaseSweeperTabFragment<V extends IView, P extends Presente
|
||||
*
|
||||
* @param weltDataBeans
|
||||
*/
|
||||
public void setWeltDataToMap(List<WeltDataBean> weltDataBeans) {
|
||||
public void setWeltDataToMap(ArrayList<WeltDataBean> weltDataBeans,Boolean isWeltData) {
|
||||
if (mMapWeltView != null) {
|
||||
mMapWeltView.setWeltData(weltDataBeans);
|
||||
mMapWeltView.setWeltData(weltDataBeans,isWeltData);
|
||||
runOnUIThread(() -> {
|
||||
mMapWeltView.drawablePolyline();
|
||||
});
|
||||
}
|
||||
EventBus.getDefault().post(new WeltDataEvent(2, weltDataBeans, null));
|
||||
this.weltDataBeanList = weltDataBeans;
|
||||
EventBus.getDefault().postSticky(new WeltDataEvent(2, weltDataBeans, null));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -433,10 +443,11 @@ public abstract class BaseSweeperTabFragment<V extends IView, P extends Presente
|
||||
if (mMapWeltView != null) {
|
||||
mMapWeltView.addStartAndEndMarker(startPoint, endPoint);
|
||||
}
|
||||
List<LatLng> latLngs = new ArrayList<>(2);
|
||||
ArrayList<LatLng> latLngs = new ArrayList<>(2);
|
||||
latLngs.add(0, startPoint);
|
||||
latLngs.add(1, endPoint);
|
||||
EventBus.getDefault().post(new WeltDataEvent(1, null, latLngs));
|
||||
this.latLngList = latLngs;
|
||||
EventBus.getDefault().postSticky(new WeltDataEvent(1, null, latLngs));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -446,7 +457,7 @@ public abstract class BaseSweeperTabFragment<V extends IView, P extends Presente
|
||||
if (mMapWeltView != null) {
|
||||
mMapWeltView.clearAllMarkerAndPolyline();
|
||||
}
|
||||
EventBus.getDefault().post(new WeltDataEvent(3, null, null));
|
||||
EventBus.getDefault().postSticky(new WeltDataEvent(3, null, null));
|
||||
}
|
||||
|
||||
private void runOnUIThread(Runnable executor) {
|
||||
@@ -461,30 +472,20 @@ public abstract class BaseSweeperTabFragment<V extends IView, P extends Presente
|
||||
}
|
||||
|
||||
/**
|
||||
* mock 贴边假数据
|
||||
* 导航去目的地
|
||||
*/
|
||||
private void setWeltData() {
|
||||
List<WeltDataBean> weltDataBean = new ArrayList<>();
|
||||
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));
|
||||
public void startNaviToStation(Boolean isVoicePlay, double startLat, double startLng, double endLat, double endLng) {
|
||||
AmapNaviToDestinationModel.getInstance(getContext()).destroyAmaNavi();
|
||||
NaviLatLng startNaviLatLng = new NaviLatLng(startLat, startLng);
|
||||
NaviLatLng endNaviLatLng = new NaviLatLng(endLat, endLng);
|
||||
AmapNaviToDestinationModel.getInstance(getContext()).initAMapNavi(startNaviLatLng, endNaviLatLng);
|
||||
AmapNaviToDestinationModel.getInstance(getContext()).setVoiceIsMute(isVoicePlay);
|
||||
}
|
||||
|
||||
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;
|
||||
/**
|
||||
* 结束子任务
|
||||
*/
|
||||
public void debugEndSubTask() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,8 @@ import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import chassis.ChassisStatesOuterClass
|
||||
import com.mogo.commons.AbsMogoApplication
|
||||
import com.mogo.eagle.core.data.map.MogoLocation
|
||||
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.SubInfo
|
||||
@@ -15,6 +17,7 @@ import com.mogo.och.sweeper.bean.SweeperSubTaskBean
|
||||
import com.mogo.och.sweeper.bean.SweeperSubTaskDetailBean
|
||||
import com.mogo.och.sweeper.constant.SubTaskTypeEnum
|
||||
import com.mogo.och.sweeper.constant.TaskStatusEnum
|
||||
import com.mogo.och.sweeper.database.bean.WeltDataBean
|
||||
import com.mogo.och.sweeper.presenter.SweeperPresenter
|
||||
import com.mogo.och.sweeper.ui.adapter.TaskListAdapter
|
||||
import com.mogo.och.sweeper.ui.dialog.SweeperManualDrivingDialog
|
||||
@@ -27,17 +30,16 @@ import kotlinx.android.synthetic.main.sweeper_no_data_common_view.*
|
||||
* 清扫车主界面
|
||||
*/
|
||||
class SweeperFragment : BaseSweeperTabFragment<SweeperFragment?, SweeperPresenter?>(), MenuPopWindow.OnMenuItemOnClickListener {
|
||||
private val TAG = "SweeperFragment"
|
||||
private var mAdapter: TaskListAdapter? = null
|
||||
private var mCurrentSubPosition: Int = 0 //子任务下标
|
||||
private var mSubMutableList: MutableList<SubInfo>? = null
|
||||
private var mSubTaskBean: SweeperSubTaskBean? = null
|
||||
private var mSubTaskType: SubTaskTypeEnum = SubTaskTypeEnum.AUTOPILOT_SUBTYPE //1:自动驾驶子任务 2:人工驾驶子任务
|
||||
private var mCleanSystemState: ChassisStatesOuterClass.SweeperFuTianTaskSystemStates? = null
|
||||
private var mSubTaskId: Int = -1//子任务id
|
||||
private var mSubTaskName: String? = null
|
||||
private var mMainTask: SweeperMainTaskBean? = null
|
||||
private var mLocation: MogoLocation? = null
|
||||
private var mSubTaskDetailBean: SweeperSubTaskDetailBean? = null
|
||||
private var mSubInfo: SubInfo? = null
|
||||
|
||||
//当前经纬度
|
||||
override fun getTagName(): String {
|
||||
@@ -128,6 +130,7 @@ class SweeperFragment : BaseSweeperTabFragment<SweeperFragment?, SweeperPresente
|
||||
mSubTaskBean = SweeperSubTaskBean(task.mainTaskId, task.mainTaskName, task.mainTaskStartTime, 1, mSubMutableList)
|
||||
//获取当前子任务列表
|
||||
presenter?.getSubTaskList(task.mainTaskId, mSubTaskBean)
|
||||
mAdapter?.selectPosition(-1)
|
||||
}
|
||||
}
|
||||
//列表任务刷新
|
||||
@@ -152,7 +155,10 @@ class SweeperFragment : BaseSweeperTabFragment<SweeperFragment?, SweeperPresente
|
||||
override fun onMenuItemClick(itemType: TaskStatusEnum) {
|
||||
when (itemType.code) {
|
||||
TaskStatusEnum.JUMP_OVER_SUBTASK.code -> {//跳过任务
|
||||
presenter?.subTaskSkip(isFirstSubTask(), isLastSubTask(), mSubTaskId)
|
||||
mSubInfo?.let {
|
||||
//如果当前只有一个子任务,则isFirst设置为false
|
||||
presenter?.subTaskSkip(if (mSubMutableList?.size == 1) false else isFirstSubTask(), isLastSubTask(), it.taskId)
|
||||
}
|
||||
}
|
||||
TaskStatusEnum.END_TASK.code -> {//结束主任务
|
||||
endMainTask()
|
||||
@@ -197,20 +203,20 @@ class SweeperFragment : BaseSweeperTabFragment<SweeperFragment?, SweeperPresente
|
||||
} else {
|
||||
0
|
||||
}
|
||||
d(SceneConstant.M_SWEEPER + TAG, "setSubTaskBean mCurrentSubPosition:$mCurrentSubPosition")
|
||||
sweeper_current_task_view.setData(sweeper_cl_work_mode, it, mCurrentSubPosition, this, presenter)
|
||||
mSubMutableList=it.subList
|
||||
mSubMutableList = it.subList
|
||||
setSubTaskData()
|
||||
presenter?.getSubTaskDetail(mSubTaskId, mSubTaskType)//加载子任务详情包括轨迹信息
|
||||
mMainTask = SweeperMainTaskBean(it.taskId, it.taskName, 0, it.taskStartTime)
|
||||
mSubMutableList?.let {subList->
|
||||
if (subList.size<=0){
|
||||
return
|
||||
if (mSubTaskType.code == SubTaskTypeEnum.AUTOPILOT_SUBTYPE.code) {//自动驾驶子任务需要调用详情
|
||||
mSubInfo?.let { subInfo ->
|
||||
presenter?.getSubTaskDetail(subInfo.taskId, mSubTaskType)//加载子任务详情包括轨迹信息
|
||||
}
|
||||
addStartAndEndMarker(
|
||||
CoordinateCalculateRouteUtil.coordinateConverterWgsToGcj(AbsMogoApplication.getApp(), subList[0].startWgs84Lon, subList[0].startWgs84Lat),
|
||||
CoordinateCalculateRouteUtil.coordinateConverterWgsToGcj(AbsMogoApplication.getApp(), subList[subList.size-1].endWgs84Lon, subList[subList.size-1].endWgs84Lat)
|
||||
)
|
||||
} else {
|
||||
manualDriving(mSubInfo)
|
||||
}
|
||||
mMainTask = SweeperMainTaskBean(it.taskId, it.taskName, 0, it.taskStartTime)
|
||||
clearAllMarkerAndPolyline()
|
||||
addWeltData()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -219,30 +225,38 @@ class SweeperFragment : BaseSweeperTabFragment<SweeperFragment?, SweeperPresente
|
||||
*/
|
||||
fun updateSubTaskStatus(typeEnum: TaskStatusEnum, isLastSubTask: Boolean) {
|
||||
if (isLastSubTask) {
|
||||
setShowCurrentTaskPanelView(false)
|
||||
setShowTaskListPanelView(true)
|
||||
sweeper_cl_work_mode.visibility = View.GONE
|
||||
mPresenter?.getMainTaskList()
|
||||
clearAllMarkerAndPolyline()
|
||||
return
|
||||
}
|
||||
when (typeEnum.code) {
|
||||
TaskStatusEnum.END_SUBTASK.code -> {//子任务结束
|
||||
//是否是最后一个子任务结束
|
||||
if (isLastSubTask()){
|
||||
mPresenter?.getMainTaskList()
|
||||
clearAllMarkerAndPolyline()
|
||||
}else{
|
||||
mCurrentSubPosition++
|
||||
setSubTaskData()
|
||||
presenter?.getSubTaskDetail(mSubTaskId, mSubTaskType)
|
||||
if (mSubTaskType.code == SubTaskTypeEnum.AUTOPILOT_SUBTYPE.code) {//自动驾驶子任务
|
||||
presenter?.startTask(isFirstSubTask(), isLastSubTask(), mSubTaskId, mSubTaskType)
|
||||
mCurrentSubPosition++
|
||||
setSubTaskData()
|
||||
d(SceneConstant.M_SWEEPER + TAG, "END_SUBTASK mCurrentSubPosition:$mCurrentSubPosition")
|
||||
if (mSubTaskType.code == SubTaskTypeEnum.AUTOPILOT_SUBTYPE.code) {//自动驾驶子任务
|
||||
mSubInfo?.apply {
|
||||
presenter?.getSubTaskDetail(taskId, mSubTaskType)
|
||||
presenter?.startTask(isFirstSubTask(), isLastSubTask(), taskId, mSubTaskType, taskStatus)
|
||||
}
|
||||
} else {
|
||||
manualDriving(mSubInfo)
|
||||
}
|
||||
}
|
||||
TaskStatusEnum.JUMP_OVER_SUBTASK.code -> { //子任务跳过
|
||||
presenter?.subTaskEnd(isFirstSubTask(), isLastSubTask(), mSubTaskId)
|
||||
if (mSubTaskType.code == SubTaskTypeEnum.MANUAL_DRIVING_SUBTYPE.code) {//人工驾驶子任务
|
||||
//是否是最后一个子任务结束
|
||||
mCurrentSubPosition++
|
||||
setSubTaskData()
|
||||
d(SceneConstant.M_SWEEPER + TAG, "JUMP_OVER_SUBTASK mCurrentSubPosition:$mCurrentSubPosition")
|
||||
showAmapNaviToStationFragment(false)
|
||||
if (mSubTaskType.code == SubTaskTypeEnum.AUTOPILOT_SUBTYPE.code) {//自动驾驶子任务
|
||||
mSubInfo?.apply {
|
||||
presenter?.getSubTaskDetail(taskId, mSubTaskType)
|
||||
presenter?.startTask(isFirstSubTask(), isLastSubTask(), taskId, mSubTaskType, taskStatus)
|
||||
}
|
||||
} else {
|
||||
showAmapNaviToStationFragment(false)
|
||||
manualDriving(mSubInfo)
|
||||
}
|
||||
}
|
||||
TaskStatusEnum.START_SUBTASK.code -> { //子任务开始
|
||||
@@ -264,10 +278,10 @@ class SweeperFragment : BaseSweeperTabFragment<SweeperFragment?, SweeperPresente
|
||||
* 子任务信息详情,包括轨迹文件
|
||||
*/
|
||||
fun setSubTakDetail(subTaskDetailBean: SweeperSubTaskDetailBean, subTaskTypeEnum: SubTaskTypeEnum) {
|
||||
if (subTaskTypeEnum.code == SubTaskTypeEnum.MANUAL_DRIVING_SUBTYPE.code) {//人工驾驶子任务
|
||||
this.mSubTaskDetailBean = subTaskDetailBean
|
||||
manualDriving(subTaskDetailBean)
|
||||
}
|
||||
// if (subTaskTypeEnum.code == SubTaskTypeEnum.MANUAL_DRIVING_SUBTYPE.code) {//人工驾驶子任务
|
||||
// this.mSubTaskDetailBean = subTaskDetailBean
|
||||
// manualDriving(subTaskDetailBean)
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -279,6 +293,7 @@ class SweeperFragment : BaseSweeperTabFragment<SweeperFragment?, SweeperPresente
|
||||
mPresenter?.getMainTaskList()
|
||||
//清除任务全览图的marker和路线
|
||||
clearAllMarkerAndPolyline()
|
||||
showOrHideOverMapViewFragment(false)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -287,12 +302,11 @@ class SweeperFragment : BaseSweeperTabFragment<SweeperFragment?, SweeperPresente
|
||||
*/
|
||||
private fun setSubTaskData() {
|
||||
mSubMutableList?.let {
|
||||
mSubTaskId = it[mCurrentSubPosition].taskId
|
||||
mSubTaskName = it[mCurrentSubPosition].taskName
|
||||
mSubInfo = it[mCurrentSubPosition]
|
||||
mSubTaskType = if (it[mCurrentSubPosition].taskType == SubTaskTypeEnum.AUTOPILOT_SUBTYPE.code)
|
||||
SubTaskTypeEnum.AUTOPILOT_SUBTYPE else SubTaskTypeEnum.MANUAL_DRIVING_SUBTYPE
|
||||
//设置当前子任务信息
|
||||
presenter?.setSubtask(isFirstSubTask(), isLastSubTask(), mSubTaskId)
|
||||
presenter?.setSubtask(isFirstSubTask(), isLastSubTask(), it[mCurrentSubPosition].taskId)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -324,27 +338,32 @@ class SweeperFragment : BaseSweeperTabFragment<SweeperFragment?, SweeperPresente
|
||||
/**
|
||||
* 人工驾驶子任务
|
||||
*/
|
||||
private fun manualDriving(subTaskDetailBean: SweeperSubTaskDetailBean) {
|
||||
val builder = SweeperManualDrivingDialog.Builder()
|
||||
val endConfirmDialog = builder
|
||||
.tips("前方子任务${mSubTaskName}手动驾驶至${subTaskDetailBean?.endSiteName}")
|
||||
.confirmStr("确认")
|
||||
.build(requireContext())
|
||||
endConfirmDialog?.setClickListener(object : SweeperManualDrivingDialog.ClickListener {
|
||||
override fun confirm() {
|
||||
presenter?.startTask(isFirstSubTask(), isLastSubTask(), mSubTaskId, mSubTaskType)
|
||||
showAmapNaviToStationFragment(true)
|
||||
presenter?.startNaviToStation(
|
||||
true,
|
||||
subTaskDetailBean.startSiteLat,
|
||||
subTaskDetailBean.startSiteLon,
|
||||
subTaskDetailBean.endSiteLat,
|
||||
subTaskDetailBean.endSiteLon
|
||||
)
|
||||
private fun manualDriving(subInfo: SubInfo?) {
|
||||
subInfo?.apply {
|
||||
val builder = SweeperManualDrivingDialog.Builder()
|
||||
val endConfirmDialog = builder
|
||||
.tips("前方子任务${taskName}手动驾驶至${endSiteName}")
|
||||
.confirmStr("确认")
|
||||
.build(requireContext())
|
||||
endConfirmDialog?.setClickListener(object : SweeperManualDrivingDialog.ClickListener {
|
||||
override fun confirm() {
|
||||
presenter?.startTask(isFirstSubTask(), isLastSubTask(), taskId, mSubTaskType, taskStatus)
|
||||
showAmapNaviToStationFragment(true)
|
||||
val startPoint =
|
||||
CoordinateCalculateRouteUtil.coordinateConverterWgsToGcj(AbsMogoApplication.getApp(), startWgs84Lon, startWgs84Lat)
|
||||
val endPoint = CoordinateCalculateRouteUtil.coordinateConverterWgsToGcj(AbsMogoApplication.getApp(), endWgs84Lon, endWgs84Lat)
|
||||
startNaviToStation(
|
||||
true,
|
||||
startPoint.latitude,
|
||||
startPoint.longitude,
|
||||
endPoint.latitude,
|
||||
endPoint.longitude
|
||||
)
|
||||
|
||||
}
|
||||
})
|
||||
endConfirmDialog?.show()
|
||||
}
|
||||
})
|
||||
endConfirmDialog?.show()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -358,7 +377,7 @@ class SweeperFragment : BaseSweeperTabFragment<SweeperFragment?, SweeperPresente
|
||||
* 是否第一个子任务
|
||||
*/
|
||||
fun isLastSubTask(): Boolean {
|
||||
return mCurrentSubPosition == (mSubMutableList?.size ?: 0)
|
||||
return mCurrentSubPosition == (mSubMutableList?.size?.minus(1))
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -369,10 +388,63 @@ class SweeperFragment : BaseSweeperTabFragment<SweeperFragment?, SweeperPresente
|
||||
}
|
||||
|
||||
override fun refreshNavi() {
|
||||
mSubTaskDetailBean?.apply {
|
||||
mSubInfo?.apply {
|
||||
mLocation?.let {
|
||||
presenter?.startNaviToStation(true, it.longitude, it.latitude, endSiteLon, endSiteLat)
|
||||
val endPoint = CoordinateCalculateRouteUtil.coordinateConverterWgsToGcj(AbsMogoApplication.getApp(), endWgs84Lon, endWgs84Lat)
|
||||
startNaviToStation(true, it.longitude, it.latitude, endPoint.longitude, endPoint.latitude)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun addWeltData() {
|
||||
mSubMutableList?.let { subList ->
|
||||
if (subList.size <= 0) {
|
||||
return
|
||||
}
|
||||
//添加贴边数据绘制
|
||||
addStartAndEndMarker(
|
||||
CoordinateCalculateRouteUtil.coordinateConverterWgsToGcj(
|
||||
AbsMogoApplication.getApp(),
|
||||
subList[0].startWgs84Lon,
|
||||
subList[0].startWgs84Lat
|
||||
),
|
||||
CoordinateCalculateRouteUtil.coordinateConverterWgsToGcj(
|
||||
AbsMogoApplication.getApp(),
|
||||
subList[subList.size - 1].endWgs84Lon,
|
||||
subList[subList.size - 1].endWgs84Lat
|
||||
)
|
||||
)
|
||||
val dataList = ArrayList<WeltDataBean>()
|
||||
for (index in subList.indices) {
|
||||
val startPoint = CoordinateCalculateRouteUtil.coordinateConverterWgsToGcj(
|
||||
AbsMogoApplication.getApp(),
|
||||
subList[index].startWgs84Lon,
|
||||
subList[index].startWgs84Lat
|
||||
)
|
||||
val startWeltData = WeltDataBean()
|
||||
startWeltData.locLat = startPoint.latitude
|
||||
startWeltData.locLon = startPoint.longitude
|
||||
startWeltData.weltDistance=-9999.0
|
||||
dataList.add(startWeltData)
|
||||
val endPoint = CoordinateCalculateRouteUtil.coordinateConverterWgsToGcj(
|
||||
AbsMogoApplication.getApp(),
|
||||
subList[index].endWgs84Lon,
|
||||
subList[index].endWgs84Lat
|
||||
)
|
||||
val endWeltData = WeltDataBean()
|
||||
endWeltData.locLat = endPoint.latitude
|
||||
endWeltData.locLon = endPoint.longitude
|
||||
endWeltData.weltDistance=-9999.0
|
||||
dataList.add(endWeltData)
|
||||
}
|
||||
setWeltDataToMap(dataList,false)
|
||||
}
|
||||
}
|
||||
|
||||
//模拟结束子任务
|
||||
override fun debugEndSubTask() {
|
||||
mSubInfo?.let {
|
||||
mPresenter?.onArriveTaskEnd(null)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,27 @@
|
||||
package com.mogo.och.sweeper.fragment
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import com.amap.api.maps.model.LatLng
|
||||
import com.mogo.commons.mvp.BaseFragment
|
||||
import com.mogo.och.sweeper.R
|
||||
import com.mogo.och.sweeper.callback.IWeltMapSwitchToSmallCallback
|
||||
import com.mogo.och.sweeper.database.bean.WeltDataBean
|
||||
import com.mogo.och.sweeper.event.WeltDataEvent
|
||||
import kotlinx.android.synthetic.main.fragment_welt_map_overview.*
|
||||
import kotlinx.android.synthetic.main.sweeper_welt_map_overview.*
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.greenrobot.eventbus.Subscribe
|
||||
import org.greenrobot.eventbus.ThreadMode
|
||||
|
||||
/**
|
||||
* 作业任务全览图
|
||||
*/
|
||||
class WeltMapOverViewFragment(var mIWeltMapSwitchToSmallCallBack: IWeltMapSwitchToSmallCallback?) : BaseFragment() {
|
||||
override fun getLayoutId(): Int = R.layout.fragment_welt_map_overview
|
||||
override fun getTagName(): String {
|
||||
@@ -19,23 +32,44 @@ class WeltMapOverViewFragment(var mIWeltMapSwitchToSmallCallBack: IWeltMapSwitch
|
||||
|
||||
}
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
EventBus.getDefault().register(this)
|
||||
return super.onCreateView(inflater, container, savedInstanceState)
|
||||
}
|
||||
|
||||
override fun initViews(savedInstanceState: Bundle?) {
|
||||
super.initViews(savedInstanceState)
|
||||
weltMapOverView.onCreateView(savedInstanceState)
|
||||
}
|
||||
|
||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
||||
super.onActivityCreated(savedInstanceState)
|
||||
setLegendData()
|
||||
sweeperSwitchToSmall.setOnClickListener {
|
||||
mIWeltMapSwitchToSmallCallBack?.onWeltMapSwitchToSmall()
|
||||
}
|
||||
val bundle = arguments
|
||||
if (bundle != null) {
|
||||
val latLngs = bundle.getSerializable("startAndEndPoint") as? ArrayList<LatLng>
|
||||
val weltDataList = bundle.getSerializable("weltDataList") as? ArrayList<WeltDataBean>
|
||||
latLngs?.let {
|
||||
if (it.size >= 2) {
|
||||
addStartAndEndMarker(it[0], it[1])
|
||||
}
|
||||
}
|
||||
weltDataList?.let {
|
||||
setWeltData(it,false)
|
||||
drawablePolyline()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun newInstance(mIWeltMapSwitchToSmallCallBack: IWeltMapSwitchToSmallCallback): WeltMapOverViewFragment {
|
||||
fun newInstance(
|
||||
mIWeltMapSwitchToSmallCallBack: IWeltMapSwitchToSmallCallback,
|
||||
weltDataList: ArrayList<WeltDataBean>,
|
||||
latLngs: ArrayList<LatLng>
|
||||
): WeltMapOverViewFragment {
|
||||
val args = Bundle()
|
||||
args.putSerializable("weltDataList", weltDataList)
|
||||
args.putSerializable("startAndEndPoint", latLngs)
|
||||
val fragment = WeltMapOverViewFragment(mIWeltMapSwitchToSmallCallBack)
|
||||
fragment.arguments = args
|
||||
return fragment
|
||||
@@ -56,38 +90,54 @@ class WeltMapOverViewFragment(var mIWeltMapSwitchToSmallCallBack: IWeltMapSwitch
|
||||
super.onDestroy()
|
||||
weltMapOverView.onDestroy()
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
EventBus.getDefault().unregister(this)
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.BACKGROUND)
|
||||
fun changeWeltData(weltDataEvent: WeltDataEvent) {
|
||||
if (weltDataEvent.type == 1) {
|
||||
lifecycleScope.launch(Dispatchers.Main) {
|
||||
weltDataEvent.markers?.let {
|
||||
addStartAndEndMarker(it[0], it[1])
|
||||
}
|
||||
}
|
||||
} else if (weltDataEvent.type == 2) {
|
||||
setWeltData(weltDataEvent.weltDataBeanList,true)
|
||||
lifecycleScope.launch(Dispatchers.Main) {
|
||||
drawablePolyline()
|
||||
}
|
||||
} else if (weltDataEvent.type == 3) {
|
||||
lifecycleScope.launch(Dispatchers.Main) {
|
||||
clearAllMarkerAndPolyline()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置任务路线数据
|
||||
*/
|
||||
fun setWeltData(weltDatas:MutableList<WeltDataBean>) {
|
||||
weltMapOverView.setWeltData(weltDatas)
|
||||
private fun setWeltData(weltDatas: MutableList<WeltDataBean>?,isWeltData:Boolean) {
|
||||
weltMapOverView.setWeltData(weltDatas,isWeltData)
|
||||
}
|
||||
|
||||
/**
|
||||
* 绘制任务路线数据
|
||||
*/
|
||||
fun drawablePolyline(){
|
||||
private fun drawablePolyline() {
|
||||
weltMapOverView.drawablePolyline()
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加起点和终点marker
|
||||
*/
|
||||
fun addStartAndEndMarker(startPoint: LatLng, endPoint: LatLng){
|
||||
weltMapOverView.drawStartAndEndMarker(startPoint,endPoint)
|
||||
private fun addStartAndEndMarker(startPoint: LatLng, endPoint: LatLng) {
|
||||
weltMapOverView.drawStartAndEndMarker(startPoint, endPoint)
|
||||
}
|
||||
|
||||
fun clearAllMarkerAndPolyline(){
|
||||
private fun clearAllMarkerAndPolyline() {
|
||||
weltMapOverView.clearAllMarkerAndPolyline()
|
||||
}
|
||||
/**
|
||||
* 设置图例数据
|
||||
*/
|
||||
private fun setLegendData() {
|
||||
sweeperLegend1.setData(R.drawable.sweeper_legend1, "a<10")
|
||||
sweeperLegend2.setData(R.drawable.sweeper_legend2, "0≤a<10")
|
||||
sweeperLegend3.setData(R.drawable.sweeper_legend3, "10≤a<20")
|
||||
sweeperLegend4.setData(R.drawable.sweeper_legend4, "a≥20")
|
||||
sweeperLegend5.setData(R.drawable.sweeper_legend5, "非贴边")
|
||||
sweeperLegend6.setData(R.drawable.sweeper_legend6, "未经过")
|
||||
}
|
||||
}
|
||||
@@ -342,7 +342,7 @@ public class SweeperTaskModel {
|
||||
public void onArriveTaskEnd(MessagePad.ArrivalNotification data) {
|
||||
//MAP 280 每隔100ms左右返回一次到站, 导致在到达中间站后再次滑动出发后会有时间差,收到一次到站,出现问题
|
||||
//此处比对 自驾告诉的子任务终点坐标和本地应到子任务终点坐标, 一致时才表示子任务完成
|
||||
if (data != null && data.getEndLocation() != null) {
|
||||
if (data != null && data.getEndLocation() != null&¤tSubTaskDetail!=null) {
|
||||
String latitude = NumberFormatUtil.cutOutNumber(data.getEndLocation().getLatitude(), 5); //wgs
|
||||
String longitude = NumberFormatUtil.cutOutNumber(data.getEndLocation().getLongitude(), 5);
|
||||
String arriveLat = NumberFormatUtil.cutOutNumber(currentSubTaskDetail.getEndSiteWgs64Lat(), 5);
|
||||
@@ -354,7 +354,7 @@ public class SweeperTaskModel {
|
||||
}
|
||||
if (isArriveSubTaskEndSite)return;
|
||||
CallerLogger.INSTANCE.d(M_SWEEPER + TAG, "行程日志-当前==subTaskId="
|
||||
+ currentSubTaskDetail.getId());
|
||||
+ mSubTaskId);
|
||||
//到达子任务终点 结束子任务
|
||||
subTaskEnd(mIsFirstSubtask,mIsLastSubtask,mSubTaskId);
|
||||
}
|
||||
@@ -426,6 +426,7 @@ public class SweeperTaskModel {
|
||||
SweeperServiceManager.getCurrentTask(mContext, new OchCommonServiceCallback<BaseResponse<SweeperSubTaskBean>>() {
|
||||
@Override
|
||||
public void onSuccess(BaseResponse<SweeperSubTaskBean> data) {
|
||||
CallerLogger.INSTANCE.d(M_SWEEPER + TAG, "getCurrentTask:"+GsonUtil.jsonFromObject(data));
|
||||
if (mSweeperTaskCallback != null && data != null) {
|
||||
SweeperSubTaskBean sweeperSubTaskBean = data.getData();
|
||||
if (sweeperSubTaskBean != null && sweeperSubTaskBean.getSubList() != null && sweeperSubTaskBean.getSubList().size() > 0) {
|
||||
@@ -465,6 +466,7 @@ public class SweeperTaskModel {
|
||||
SweeperServiceManager.getMainTaskList(mContext, new OchCommonServiceCallback<BaseResponse<List<SweeperMainTaskBean>>>() {
|
||||
@Override
|
||||
public void onSuccess(BaseResponse<List<SweeperMainTaskBean>> data) {
|
||||
CallerLogger.INSTANCE.d(M_SWEEPER + TAG, "getMainTaskList:"+GsonUtil.jsonFromObject(data));
|
||||
if (mSweeperTaskCallback != null && data != null && data.getCode() == 0) {
|
||||
List<SweeperMainTaskBean> list = data.getData();
|
||||
mSweeperTaskCallback.setMainTaskList(list);
|
||||
@@ -500,6 +502,7 @@ public class SweeperTaskModel {
|
||||
SweeperServiceManager.getSubTaskList(taskId, mContext, new OchCommonServiceCallback<BaseResponse<List<SubInfo>>>() {
|
||||
@Override
|
||||
public void onSuccess(BaseResponse<List<SubInfo>> data) {
|
||||
CallerLogger.INSTANCE.d(M_SWEEPER + TAG, "getSubTaskList:"+GsonUtil.jsonFromObject(data));
|
||||
if (mSweeperTaskCallback != null && data != null && data.getCode() == 0) {
|
||||
List<SubInfo> list = data.getData();
|
||||
if (list != null && list.size() > 0) {
|
||||
@@ -540,6 +543,7 @@ public class SweeperTaskModel {
|
||||
SweeperServiceManager.getSubTaskDetail(subTaskId, mContext, new OchCommonServiceCallback<BaseResponse<SweeperSubTaskDetailBean>>() {
|
||||
@Override
|
||||
public void onSuccess(BaseResponse<SweeperSubTaskDetailBean> data) {
|
||||
CallerLogger.INSTANCE.d(M_SWEEPER + TAG, "getSubTaskDetail:"+GsonUtil.jsonFromObject(data));
|
||||
if (data != null) {
|
||||
currentSubTaskDetail = data.getData();
|
||||
if (currentSubTaskDetail != null) {
|
||||
@@ -582,6 +586,7 @@ public class SweeperTaskModel {
|
||||
SweeperServiceManager.subTaskStart(isFirst,isEnd,subTaskId, mContext, new OchCommonServiceCallback<BaseResponse<Boolean>>() {
|
||||
@Override
|
||||
public void onSuccess(BaseResponse<Boolean> data) {
|
||||
CallerLogger.INSTANCE.d(M_SWEEPER + TAG, "subTaskStart:"+GsonUtil.jsonFromObject(data));
|
||||
if (mSweeperTaskCallback != null && data != null) {
|
||||
if (data.getData()) {
|
||||
isSubTaskWorking = true;
|
||||
@@ -631,6 +636,7 @@ public class SweeperTaskModel {
|
||||
SweeperServiceManager.subTaskEnd(isFirst,isEnd,subTaskId, mContext, new OchCommonServiceCallback<BaseResponse<Boolean>>() {
|
||||
@Override
|
||||
public void onSuccess(BaseResponse<Boolean> data) {
|
||||
CallerLogger.INSTANCE.d(M_SWEEPER + TAG, "subTaskEnd:"+GsonUtil.jsonFromObject(data));
|
||||
if (mSweeperTaskCallback != null && data != null) {
|
||||
if (data.getData()) {
|
||||
isSubTaskWorking = false;
|
||||
@@ -678,12 +684,11 @@ public class SweeperTaskModel {
|
||||
SweeperServiceManager.subTaskSkip(isFirst,isEnd,subTaskId, mContext, new OchCommonServiceCallback<BaseResponse<Boolean>>() {
|
||||
@Override
|
||||
public void onSuccess(BaseResponse<Boolean> data) {
|
||||
CallerLogger.INSTANCE.d(M_SWEEPER + TAG, "subTaskSkip:"+GsonUtil.jsonFromObject(data));
|
||||
if (mSweeperTaskCallback != null && data != null) {
|
||||
if (data.getData()) {
|
||||
isSubTaskWorking=false;
|
||||
mSweeperTaskCallback.updateSubTaskStatus(TaskStatusEnum.JUMP_OVER_SUBTASK, isEnd);
|
||||
if (isEnd) {//如果是最后一个子任务,则跳过完成后,调用结束子任务接口,这样后端可以才可以把整个大任务结束掉
|
||||
subTaskEnd(isFirst,isEnd,subTaskId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -717,6 +722,7 @@ public class SweeperTaskModel {
|
||||
SweeperServiceManager.mainTaskReset(taskId, mContext, new OchCommonServiceCallback<BaseResponse<Boolean>>() {
|
||||
@Override
|
||||
public void onSuccess(BaseResponse<Boolean> data) {
|
||||
CallerLogger.INSTANCE.d(M_SWEEPER + TAG, "mainTaskReset:"+GsonUtil.jsonFromObject(data));
|
||||
if (mSweeperTaskCallback != null && data != null) {
|
||||
mSweeperTaskCallback.setMainTaskReset(data.getData());
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ public interface ISweeperApiService {
|
||||
* @return
|
||||
*/
|
||||
@Headers({"Content-type:application/json;charset=UTF-8"})
|
||||
@POST("/och-sweep/api/task/v1/sutTaskEnd")
|
||||
@POST("/och-sweep/api/task/v1/subTaskEnd")
|
||||
Observable<BaseResponse<Boolean>> subTaskEnd(@Header ("appId") String appId, @Header("ticket") String ticket, @Body SubStartRequest subStartRequest);
|
||||
/**
|
||||
* 子任务跳过
|
||||
|
||||
@@ -1,15 +1,20 @@
|
||||
package com.mogo.och.sweeper.net
|
||||
|
||||
import android.content.Context
|
||||
import com.elegant.network.utils.GsonUtil
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig
|
||||
import com.mogo.eagle.core.network.MoGoRetrofitFactory
|
||||
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.biz.network.OchCommonServiceCallback
|
||||
import com.mogo.och.common.module.biz.network.OchCommonSubscribeImpl
|
||||
import com.mogo.och.common.module.biz.network.interceptor.transformTry
|
||||
import com.mogo.och.sweeper.bean.*
|
||||
import com.mogo.och.sweeper.constant.SweeperConst.Companion.getBaseUrl
|
||||
import com.mogo.och.sweeper.model.SweeperTaskModel
|
||||
|
||||
object SweeperServiceManager {
|
||||
private val TAG = SweeperTaskModel::class.java.simpleName
|
||||
private val mService: ISweeperApiService = MoGoRetrofitFactory.getInstance(getBaseUrl()).create(
|
||||
ISweeperApiService::class.java
|
||||
)
|
||||
@@ -77,6 +82,7 @@ object SweeperServiceManager {
|
||||
@JvmStatic
|
||||
fun subTaskStart(isFirst:Boolean,isEnd:Boolean,subTaskId: Int,context: Context, callback: OchCommonServiceCallback<BaseResponse<Boolean>>?) {
|
||||
val subStartRequest = SubStartRequest(MoGoAiCloudClientConfig.getInstance().sn, subTaskId, System.currentTimeMillis(),isFirst,isEnd)
|
||||
d(SceneConstant.M_SWEEPER + TAG, "subTaskStart:" + GsonUtil.jsonFromObject(subStartRequest))
|
||||
mService.subTaskStart(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
MoGoAiCloudClientConfig.getInstance().token,
|
||||
@@ -92,6 +98,7 @@ object SweeperServiceManager {
|
||||
@JvmStatic
|
||||
fun subTaskEnd(isFirst:Boolean,isEnd:Boolean,subTaskId: Int,context: Context, callback: OchCommonServiceCallback<BaseResponse<Boolean>>?) {
|
||||
val subStartRequest = SubStartRequest(MoGoAiCloudClientConfig.getInstance().sn, subTaskId, System.currentTimeMillis(),isFirst,isEnd)
|
||||
d(SceneConstant.M_SWEEPER + TAG, "subTaskEnd:" + GsonUtil.jsonFromObject(subStartRequest))
|
||||
mService.subTaskEnd(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
MoGoAiCloudClientConfig.getInstance().token,
|
||||
@@ -107,6 +114,7 @@ object SweeperServiceManager {
|
||||
@JvmStatic
|
||||
fun subTaskSkip(isFirst:Boolean,isEnd:Boolean,subTaskId: Int,context: Context, callback: OchCommonServiceCallback<BaseResponse<Boolean>>?) {
|
||||
val subStartRequest = SubStartRequest(MoGoAiCloudClientConfig.getInstance().sn, subTaskId, System.currentTimeMillis(),isFirst,isEnd)
|
||||
d(SceneConstant.M_SWEEPER + TAG, "subTaskSkip:" + GsonUtil.jsonFromObject(subStartRequest))
|
||||
mService.subTaskSkip(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
MoGoAiCloudClientConfig.getInstance().token,
|
||||
|
||||
@@ -36,6 +36,7 @@ import com.mogo.och.sweeper.util.SweeperTrajectoryManager;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
@@ -238,7 +239,9 @@ public class SweeperPresenter extends Presenter<SweeperFragment>
|
||||
public void onStartAdasFailure() {
|
||||
|
||||
}
|
||||
|
||||
public void onArriveTaskEnd(@Nullable MessagePad.ArrivalNotification arrivalNotification){
|
||||
SweeperTaskModel.getInstance().onArriveTaskEnd(arrivalNotification);
|
||||
}
|
||||
@Override
|
||||
public void onSweeperFutianCleanSystemState(@NonNull ChassisStatesOuterClass.SweeperFuTianTaskSystemStates cleanSystemState) {
|
||||
if (cleanSystemState==null){
|
||||
@@ -334,7 +337,7 @@ public class SweeperPresenter extends Presenter<SweeperFragment>
|
||||
weltDataBean.setCleanIntensity(roboSweeperTaskIndex.getCleanIntensity());
|
||||
weltDataBean.setSubTaskId(mSubTaskId);
|
||||
MyDataBase.getInstance().getWeltDataDao().insert(weltDataBean);
|
||||
mView.setWeltDataToMap(MyDataBase.getInstance().getWeltDataDao().loadAllWeltDataInfo());
|
||||
mView.setWeltDataToMap((ArrayList<WeltDataBean>) MyDataBase.getInstance().getWeltDataDao().loadAllWeltDataInfo(),true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -368,13 +371,15 @@ public class SweeperPresenter extends Presenter<SweeperFragment>
|
||||
/**
|
||||
* 开始任务
|
||||
*/
|
||||
public void startTask(boolean isFirst,boolean isEnd,int subTaskId, SubTaskTypeEnum subTaskType) {
|
||||
public void startTask(boolean isFirst,boolean isEnd,int subTaskId, SubTaskTypeEnum subTaskType,int subTaskStatus) {
|
||||
if (SweeperTaskModel.getInstance().getSubWorking()) {//如果任务正在执行中,被人工接管后掉出自驾,则只重启自动驾驶
|
||||
if (subTaskType == SubTaskTypeEnum.AUTOPILOT_SUBTYPE) {
|
||||
SweeperTaskModel.getInstance().startAutopilot();
|
||||
}
|
||||
} else {
|
||||
SweeperTaskModel.getInstance().subTaskStart(isFirst,isEnd,subTaskId, subTaskType);
|
||||
if (subTaskStatus==1){//子任务未执行,则开始执行
|
||||
SweeperTaskModel.getInstance().subTaskStart(isFirst,isEnd,subTaskId, subTaskType);
|
||||
}
|
||||
}
|
||||
// AutopilotControlParameters parameters = new AutopilotControlParameters();
|
||||
// parameters.isSpeakVoice = true;
|
||||
@@ -453,15 +458,4 @@ public class SweeperPresenter extends Presenter<SweeperFragment>
|
||||
public void setSubTakDetail(@NonNull SweeperSubTaskDetailBean subTaskDetailBean, SubTaskTypeEnum subTaskTypeEnum) {
|
||||
mView.setSubTakDetail(subTaskDetailBean, subTaskTypeEnum);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导航去目的地
|
||||
*/
|
||||
public void startNaviToStation(Boolean isVoicePlay, double startLat, double startLng, double endLat, double endLng) {
|
||||
AmapNaviToDestinationModel.getInstance(getContext()).destroyAmaNavi();
|
||||
NaviLatLng startNaviLatLng = new NaviLatLng(startLat, startLng);
|
||||
NaviLatLng endNaviLatLng = new NaviLatLng(endLat, endLng);
|
||||
AmapNaviToDestinationModel.getInstance(getContext()).initAMapNavi(startNaviLatLng, endNaviLatLng);
|
||||
AmapNaviToDestinationModel.getInstance(getContext()).setVoiceIsMute(isVoicePlay);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,10 +6,8 @@ import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import com.mogo.och.common.module.utils.DateTimeUtil
|
||||
import com.mogo.och.sweeper.R
|
||||
import com.mogo.och.sweeper.bean.SubInfo
|
||||
import com.mogo.och.sweeper.bean.SweeperSubTaskBean
|
||||
import kotlinx.android.synthetic.main.sweeper_subtask_view.view.*
|
||||
|
||||
/**
|
||||
@@ -43,7 +41,7 @@ class SubTaskView : ConstraintLayout {
|
||||
// }else{
|
||||
// "${DateTimeUtil.secondsToMinuteStr(taskInfo.timeSpent/1000)}分钟"
|
||||
// }
|
||||
tvSubTaskDesc.text = "全程约${mileage},预计耗时${taskInfo.timeSpent}"
|
||||
tvSubTaskDesc.text = "全程约${mileage},预计耗时${taskInfo.timeSpent}分钟"
|
||||
tvSubTaskName.setTextColor(if (isSelect) Color.parseColor("#3BD2FF") else Color.parseColor("#FFFFFF"))
|
||||
if (isSelect) {
|
||||
ivSubTaskSelect.visibility = View.VISIBLE
|
||||
|
||||
@@ -120,7 +120,8 @@ class SweeperCurrentTaskInfoView : ConstraintLayout {
|
||||
isFirstSubTask(),
|
||||
isLastSubTask(),
|
||||
it[mCurrentPosition].taskId,
|
||||
if (it[mCurrentPosition].taskType == SubTaskTypeEnum.AUTOPILOT_SUBTYPE.code) SubTaskTypeEnum.AUTOPILOT_SUBTYPE else SubTaskTypeEnum.MANUAL_DRIVING_SUBTYPE
|
||||
if (it[mCurrentPosition].taskType == SubTaskTypeEnum.AUTOPILOT_SUBTYPE.code) SubTaskTypeEnum.AUTOPILOT_SUBTYPE else SubTaskTypeEnum.MANUAL_DRIVING_SUBTYPE,
|
||||
it[mCurrentPosition].taskStatus
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -134,7 +135,7 @@ class SweeperCurrentTaskInfoView : ConstraintLayout {
|
||||
* 是否第一个子任务
|
||||
*/
|
||||
private fun isLastSubTask():Boolean{
|
||||
return mCurrentPosition == (listTask?.size ?: 0)
|
||||
return mCurrentPosition == (listTask?.size?.minus(1))
|
||||
}
|
||||
/**
|
||||
* 填充数据
|
||||
|
||||
@@ -5,6 +5,7 @@ import android.graphics.Color
|
||||
import android.os.Bundle
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import com.amap.api.maps.AMap
|
||||
@@ -30,6 +31,7 @@ class WeltMapOverView : ConstraintLayout, IMoGoChassisLocationGCJ02Listener {
|
||||
private var mPolyline: Polyline? = null
|
||||
private var colorList: MutableList<Int> = mutableListOf()
|
||||
private val mLineMarkers: MutableList<Marker?> = mutableListOf()
|
||||
private var mFirst: Boolean = false
|
||||
|
||||
//清扫车任务地图
|
||||
private val TAG = "WeltMapOverView"
|
||||
@@ -48,7 +50,6 @@ class WeltMapOverView : ConstraintLayout, IMoGoChassisLocationGCJ02Listener {
|
||||
initAMapView()
|
||||
// 注册定位监听
|
||||
CallerChassisLocationGCJ02ListenerManager.addListener(TAG, this)
|
||||
setLegendData()
|
||||
}
|
||||
|
||||
private fun initAMapView() {
|
||||
@@ -158,28 +159,38 @@ class WeltMapOverView : ConstraintLayout, IMoGoChassisLocationGCJ02Listener {
|
||||
/**
|
||||
* 清除所有标记和路线
|
||||
*/
|
||||
public fun clearAllMarkerAndPolyline() {
|
||||
fun clearAllMarkerAndPolyline() {
|
||||
mPolyline?.remove()
|
||||
for (i in mLineMarkers.indices) {
|
||||
mLineMarkers[i]?.isVisible = false
|
||||
mLineMarkers[i]?.remove()
|
||||
}
|
||||
mLineMarkers.clear()
|
||||
mFirst = false
|
||||
showOrHiddenLegendData(false)
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置贴边数据
|
||||
*/
|
||||
fun setWeltData(weltData: MutableList<WeltDataBean>) {
|
||||
this.mWeltData = weltData
|
||||
for (i in mWeltData.indices) {
|
||||
mCoordinatesLatLng.add(LatLng(mWeltData[i].locLat, mWeltData[i].locLon))
|
||||
fun setWeltData(weltData: MutableList<WeltDataBean>?,isWeltData: Boolean) {
|
||||
if (weltData != null) {
|
||||
this.mWeltData.addAll(weltData)
|
||||
for (i in mWeltData.indices) {
|
||||
mCoordinatesLatLng.add(LatLng(mWeltData[i].locLat, mWeltData[i].locLon))
|
||||
}
|
||||
}
|
||||
if (!mFirst&&isWeltData) {
|
||||
mFirst = true
|
||||
showOrHiddenLegendData(true)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置图例数据
|
||||
*/
|
||||
private fun setLegendData() {
|
||||
private fun showOrHiddenLegendData(isShow: Boolean) {
|
||||
groupLegend.visibility = if (isShow) View.VISIBLE else View.GONE
|
||||
sweeperLegend1.setData(R.drawable.sweeper_legend1, "a<10")
|
||||
sweeperLegend2.setData(R.drawable.sweeper_legend2, "0≤a<10")
|
||||
sweeperLegend3.setData(R.drawable.sweeper_legend3, "10≤a<20")
|
||||
|
||||
@@ -3,8 +3,11 @@ package com.mogo.och.sweeper.view
|
||||
import android.content.Context
|
||||
import android.graphics.Color
|
||||
import android.os.Bundle
|
||||
import android.os.Looper
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import com.amap.api.maps.AMap
|
||||
import com.amap.api.maps.CameraUpdateFactory
|
||||
@@ -14,6 +17,7 @@ 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.d
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
|
||||
import com.mogo.och.common.module.utils.CoordinateCalculateRouteUtil
|
||||
import com.mogo.och.sweeper.R
|
||||
import com.mogo.och.sweeper.database.bean.WeltDataBean
|
||||
@@ -30,6 +34,7 @@ class WeltSmallMapView : ConstraintLayout, IMoGoChassisLocationGCJ02Listener {
|
||||
private var mPolyline: Polyline? = null
|
||||
private var colorList: MutableList<Int> = mutableListOf()
|
||||
private val mLineMarkers: MutableList<Marker?> = mutableListOf()
|
||||
private var mFirst: Boolean = false
|
||||
|
||||
//清扫车任务地图
|
||||
private val TAG = "WeltMapView"
|
||||
@@ -153,6 +158,11 @@ class WeltSmallMapView : ConstraintLayout, IMoGoChassisLocationGCJ02Listener {
|
||||
* 添加起点和终点的marker
|
||||
*/
|
||||
fun addStartAndEndMarker(startPoint: LatLng, endPoint: LatLng) {
|
||||
for (i in mLineMarkers.indices) {
|
||||
mLineMarkers[i]?.isVisible = false
|
||||
mLineMarkers[i]?.remove()
|
||||
}
|
||||
mLineMarkers.clear()
|
||||
val startMarker = mAMap?.addMarker(MarkerOptions().icon(BitmapDescriptorFactory.fromResource(R.drawable.start_maker_icon)))
|
||||
startMarker?.position = startPoint
|
||||
mLineMarkers.add(startMarker)
|
||||
@@ -161,6 +171,17 @@ class WeltSmallMapView : ConstraintLayout, IMoGoChassisLocationGCJ02Listener {
|
||||
mLineMarkers.add(endMarker)
|
||||
}
|
||||
|
||||
private fun runOnUIThread(executor: Runnable?) {
|
||||
if (executor == null) {
|
||||
return
|
||||
}
|
||||
if (Looper.myLooper() != Looper.getMainLooper()) {
|
||||
UiThreadHandler.post(executor)
|
||||
} else {
|
||||
executor.run()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除所有标记和路线
|
||||
*/
|
||||
@@ -171,15 +192,32 @@ class WeltSmallMapView : ConstraintLayout, IMoGoChassisLocationGCJ02Listener {
|
||||
mLineMarkers[i]?.remove()
|
||||
}
|
||||
mLineMarkers.clear()
|
||||
mFirst = false
|
||||
showOrHiddenWelt(false)
|
||||
}
|
||||
|
||||
fun getSwitchToBig(): ImageView = sweeperSwitchToBig
|
||||
|
||||
/**
|
||||
* 显示或隐藏贴边
|
||||
*/
|
||||
private fun showOrHiddenWelt(isShow: Boolean) {
|
||||
taskProgressTv.visibility = if (isShow) View.VISIBLE else View.GONE
|
||||
taskWeltDistanceTv.visibility = if (isShow) View.VISIBLE else View.GONE
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置贴边数据
|
||||
*/
|
||||
fun setWeltData(weltData: MutableList<WeltDataBean>) {
|
||||
fun setWeltData(weltData: MutableList<WeltDataBean>,isWeltData: Boolean) {
|
||||
this.mWeltData = weltData
|
||||
for (i in mWeltData.indices) {
|
||||
mCoordinatesLatLng.add(CoordinateCalculateRouteUtil.coordinateConverterWgsToGcj(context, mWeltData[i].locLon, mWeltData[i].locLat))
|
||||
}
|
||||
if (!mFirst&&isWeltData) {
|
||||
showOrHiddenWelt(true)
|
||||
mFirst = true
|
||||
}
|
||||
}
|
||||
|
||||
fun onCreateView(savedInstanceState: Bundle?) {
|
||||
|
||||
@@ -287,6 +287,15 @@
|
||||
android:textSize="30sp"
|
||||
app:layout_constraintRight_toRightOf="@id/btnAutopilotDisable"
|
||||
app:layout_constraintTop_toBottomOf="@id/btnAutopilotEnable" />
|
||||
<Button
|
||||
android:id="@+id/btnEndTask"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="#ffffff"
|
||||
android:text="结束子任务"
|
||||
android:textSize="30sp"
|
||||
app:layout_constraintRight_toRightOf="@id/btnAutopilotRunning"
|
||||
app:layout_constraintTop_toBottomOf="@id/btnAutopilotRunning" />
|
||||
|
||||
<androidx.constraintlayout.widget.Group
|
||||
android:id="@+id/groupTestPanel"
|
||||
@@ -294,7 +303,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"
|
||||
app:constraint_referenced_ids="btnAutopilotDisable,btnAutopilotEnable
|
||||
,btnAutopilotRunning"
|
||||
,btnAutopilotRunning,btnEndTask"
|
||||
tools:visibility="visible" />
|
||||
|
||||
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
<com.amap.api.maps.TextureMapView
|
||||
android:id="@+id/sweeperTextureMapView"
|
||||
android:layout_width="match_parent"
|
||||
@@ -17,6 +18,7 @@
|
||||
android:layout_marginEnd="@dimen/dp_50"
|
||||
android:layout_marginTop="@dimen/dp_50"/>
|
||||
<com.mogo.och.common.module.wigets.OCHRoundConstraintLayout
|
||||
android:id="@+id/groupLegend"
|
||||
android:layout_width="@dimen/dp_366"
|
||||
android:layout_height="@dimen/dp_573"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
@@ -24,7 +26,8 @@
|
||||
android:layout_marginBottom="@dimen/dp_80"
|
||||
android:layout_marginEnd="@dimen/dp_80"
|
||||
app:roundLayoutRadius="@dimen/dp_16"
|
||||
android:background="#0E1D38">
|
||||
android:background="#0E1D38"
|
||||
android:visibility="gone">
|
||||
<TextView
|
||||
android:id="@+id/taskProgressTv"
|
||||
android:layout_width="0dp"
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
<com.amap.api.maps.TextureMapView
|
||||
android:id="@+id/sweeperSmallTextureMapView"
|
||||
android:layout_width="match_parent"
|
||||
@@ -12,7 +13,7 @@
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"/>
|
||||
<ImageView
|
||||
android:id="@+id/sweeper_switch_to_big"
|
||||
android:id="@+id/sweeperSwitchToBig"
|
||||
android:layout_width="@dimen/dp_45"
|
||||
android:layout_height="@dimen/dp_45"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
@@ -33,6 +34,7 @@
|
||||
android:paddingBottom="4dp"
|
||||
android:paddingLeft="6dp"
|
||||
android:paddingRight="6dp"
|
||||
android:visibility="gone"
|
||||
/>
|
||||
<TextView
|
||||
android:id="@+id/taskWeltDistanceTv"
|
||||
@@ -46,5 +48,6 @@
|
||||
android:paddingTop="4dp"
|
||||
android:paddingBottom="4dp"
|
||||
android:paddingLeft="6dp"
|
||||
android:paddingRight="6dp"/>
|
||||
android:paddingRight="6dp"
|
||||
android:visibility="gone"/>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
Reference in New Issue
Block a user