From bc2a3cd756e53c25f3c5b8db1bca35b3b81880bc Mon Sep 17 00:00:00 2001 From: wangmingjun Date: Mon, 10 Oct 2022 18:18:54 +0800 Subject: [PATCH] =?UTF-8?q?[2.11.0]=20taxi/bus=E5=8F=B8=E6=9C=BA=E7=AB=AF?= =?UTF-8?q?=20=E5=B0=86=E4=B8=9A=E5=8A=A1=E8=AE=A2=E5=8D=95=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E4=BF=9D=E5=AD=98=EF=BC=8C=E9=B9=B0=E7=9C=BC=E5=8F=AF?= =?UTF-8?q?=E5=8F=96=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/mogo/och/bus/model/BusOrderModel.java | 83 +++++++++--- .../com/mogo/och/taxi/model/TaxiModel.java | 128 ++++++++++-------- 2 files changed, 132 insertions(+), 79 deletions(-) diff --git a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/model/BusOrderModel.java b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/model/BusOrderModel.java index df6a0d1ea0..ed7e86d8f7 100644 --- a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/model/BusOrderModel.java +++ b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/model/BusOrderModel.java @@ -372,6 +372,7 @@ public class BusOrderModel { if (refreshBusStationsCallback != null){ refreshBusStationsCallback.updateEmptyUi(); } + clearAutopilotControlParameters(); return; } CallerLogger.INSTANCE.d(M_BUS + TAG, "获取到小巴路线数据: " + data ); @@ -429,11 +430,13 @@ public class BusOrderModel { refreshBusStationsCallback.updateBusTaskStatus(busRoutesResult.getName(),lineTime, stationList,arrivingOrArrivedStationIndex,true); } + clearAutopilotControlParameters(); }else { if (refreshBusStationsCallback != null){ refreshBusStationsCallback.updateBusTaskStatus(busRoutesResult.getName(),lineTime, stationList,arrivingOrArrivedStationIndex,false); } + updateAutopilotControlParameters(); } } @@ -490,6 +493,7 @@ public class BusOrderModel { private void startAutopilot(boolean isRestart) { if (backgroundCurrentStationIndex +1 > stationList.size() - 1 || !isGoingToNextStation){ + CallerLogger.INSTANCE.e(M_BUS + TAG, "mismatch condition."); return; } @@ -498,30 +502,16 @@ public class BusOrderModel { BusStationBean currentStation = stationList.get( backgroundCurrentStationIndex); BusStationBean nextStation = stationList.get( backgroundCurrentStationIndex + 1); - AutopilotControlParameters parameters = new AutopilotControlParameters(); - parameters.isSpeakVoice = !isRestart; - parameters.routeID = busRoutesResult.getLineId(); - parameters.routeName = busRoutesResult.getName(); - parameters.startName = PinYinUtil.getPinYinHeadChar(currentStation.getName()); - parameters.endName = PinYinUtil.getPinYinHeadChar(nextStation.getName()); - parameters.startLatLon = new AutopilotControlParameters - .AutoPilotLonLat( currentStation.getLat(), currentStation.getLon() ); - parameters.endLatLon = new AutopilotControlParameters - .AutoPilotLonLat( nextStation.getLat(), nextStation.getLon() ); - parameters.vehicleType = VEHICLE_TYPE; - if (parameters.autoPilotLine == null) { - parameters.autoPilotLine = new AutopilotControlParameters.AutoPilotLine( - busRoutesResult.getLineId(), - busRoutesResult.csvFileUrl, busRoutesResult.csvFileMd5, - busRoutesResult.txtFileUrl, busRoutesResult.txtFileMd5, - busRoutesResult.contrailSaveTime, busRoutesResult.carModel, - busRoutesResult.csvFileUrlDPQP, busRoutesResult.csvFileMd5DPQP, - busRoutesResult.txtFileUrlDPQP, busRoutesResult.txtFileMd5DPQP, - busRoutesResult.contrailSaveTimeDPQP); + AutopilotControlParameters parameters = initAutopilotControlParameters(); + if (null == parameters) { + CallerLogger.INSTANCE.e(M_BUS + TAG, "AutopilotControlParameters is empty."); + return; } + + CallerAutoPilotManager.INSTANCE.startAutoPilot(parameters); + CallerLogger.INSTANCE.d( M_BUS + TAG, "开启自动驾驶====" + GsonUtil.jsonFromObject(parameters) +" startLatLon="+currentStation.getName()+",endLatLon="+nextStation.getName()); - CallerAutoPilotManager.INSTANCE.startAutoPilot(parameters); if (mControllerStatusCallback != null) { mControllerStatusCallback.startOpenAutopilot(); @@ -905,4 +895,55 @@ public class BusOrderModel { public int getCurrentStationIndex() { return backgroundCurrentStationIndex; } + + /** + * 将业务订单信息保存,鹰眼可取用 + */ + private void updateAutopilotControlParameters() { + + AutopilotControlParameters parameters = initAutopilotControlParameters(); + if (null == parameters){ + CallerLogger.INSTANCE.e(M_BUS + TAG, "AutopilotControlParameters is empty."); + return; + } + CallerLogger.INSTANCE.d(M_BUS + TAG, "AutopilotControlParameters is update."); + CallerAutoPilotStatusListenerManager.INSTANCE.updateAutopilotControlParameters(parameters); + } + + private void clearAutopilotControlParameters(){ + CallerLogger.INSTANCE.d(M_BUS + TAG, "AutopilotControlParameters is clear."); + CallerAutoPilotStatusListenerManager.INSTANCE.updateAutopilotControlParameters(null); + } + + private AutopilotControlParameters initAutopilotControlParameters() { + if (backgroundCurrentStationIndex +1 > stationList.size() - 1 || !isGoingToNextStation){ + CallerLogger.INSTANCE.e(M_BUS + TAG, "mismatch condition."); + return null; + } + + BusStationBean currentStation = stationList.get( backgroundCurrentStationIndex); + BusStationBean nextStation = stationList.get( backgroundCurrentStationIndex + 1); + + AutopilotControlParameters parameters = new AutopilotControlParameters(); + parameters.routeID = busRoutesResult.getLineId(); + parameters.routeName = busRoutesResult.getName(); + parameters.startName = PinYinUtil.getPinYinHeadChar(currentStation.getName()); + parameters.endName = PinYinUtil.getPinYinHeadChar(nextStation.getName()); + parameters.startLatLon = new AutopilotControlParameters + .AutoPilotLonLat( currentStation.getLat(), currentStation.getLon() ); + parameters.endLatLon = new AutopilotControlParameters + .AutoPilotLonLat( nextStation.getLat(), nextStation.getLon() ); + parameters.vehicleType = VEHICLE_TYPE; + if (parameters.autoPilotLine == null) { + parameters.autoPilotLine = new AutopilotControlParameters.AutoPilotLine( + busRoutesResult.getLineId(), + busRoutesResult.csvFileUrl, busRoutesResult.csvFileMd5, + busRoutesResult.txtFileUrl, busRoutesResult.txtFileMd5, + busRoutesResult.contrailSaveTime, busRoutesResult.carModel, + busRoutesResult.csvFileUrlDPQP, busRoutesResult.csvFileMd5DPQP, + busRoutesResult.txtFileUrlDPQP, busRoutesResult.txtFileMd5DPQP, + busRoutesResult.contrailSaveTimeDPQP); + } + return parameters; + } } diff --git a/OCH/mogo-och-taxi/src/main/java/com/mogo/och/taxi/model/TaxiModel.java b/OCH/mogo-och-taxi/src/main/java/com/mogo/och/taxi/model/TaxiModel.java index b651855d3f..755dc34a0d 100644 --- a/OCH/mogo-och-taxi/src/main/java/com/mogo/och/taxi/model/TaxiModel.java +++ b/OCH/mogo-och-taxi/src/main/java/com/mogo/och/taxi/model/TaxiModel.java @@ -18,7 +18,6 @@ import com.amap.api.maps.model.LatLng; import com.elegant.network.utils.GsonUtil; import com.mogo.aicloud.services.socket.MogoAiCloudSocketManager; import com.mogo.cloud.commons.utils.CoordinateUtils; -import com.mogo.commons.debug.DebugConfig; import com.mogo.eagle.core.data.BaseData; import com.mogo.eagle.core.data.autopilot.AutopilotControlParameters; import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo; @@ -29,6 +28,7 @@ import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotManager; import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager; import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotPlanningListenerManager; import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger; +import com.mogo.eagle.core.utilcode.mogo.logger.Logger; import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr; import com.mogo.eagle.core.utilcode.util.NetworkUtils; import com.mogo.eagle.core.utilcode.util.ToastUtils; @@ -318,6 +318,8 @@ public class TaxiModel { //1.1.2. 当本地有currentOrder: //orderId不一致时:通过currentOrder.orderId查询订单状态,并通知ui更新 //orderId一致且orderStatus不一致时:则更新currentOrder,并通知ui更新 + Logger.d(TAG,"AutopilotControl-mCurrentOCHOrder = "+mCurrentOCHOrder.orderStatus + + ", orderStatus = " +data.data.servicing.get(0).orderStatus); if (!mCurrentOCHOrder.orderNo.equals(data.data.servicing.get(0).orderNo)) { queryCurOrderStatus(); } else if (mCurrentOCHOrder.orderStatus != data.data.servicing.get(0).orderStatus) { @@ -787,24 +789,52 @@ public class TaxiModel { TaxiTrajectoryManager.getInstance().syncTrajectoryInfo(); SharedPrefsMgr.getInstance(mContext).putString(TaxiConst.SP_KEY_OCH_TAXI_ORDER, GsonUtil.jsonFromObject(data)); - if (FunctionBuildConfig.isDemoMode) { - if (mCurrentOCHOrder.orderStatus == TaxiOrderStatusEnum.OnTheWayToEnd.getCode()){ + + if (mCurrentOCHOrder.orderStatus == TaxiOrderStatusEnum.OnTheWayToEnd.getCode()){ + + if (FunctionBuildConfig.isDemoMode) { // 当美化模式(演示模式)开启时: 订单对应自动驾驶开启后,置true FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData = true; CallerAutoPilotManager.INSTANCE.setIgnoreConditionDraw(true); CallerAutoPilotManager.INSTANCE.setIPCDemoMode(true); CallerLogger.INSTANCE.d(M_TAXI + TAG, "美化模式-ignore:置为true(更新本地order信息)"); } - if (mCurrentOCHOrder.orderStatus == TaxiOrderStatusEnum.ArriveAtEnd.getCode()){ + + updateAutopilotControlParameters(); + } + if (mCurrentOCHOrder.orderStatus == TaxiOrderStatusEnum.ArriveAtEnd.getCode()){ + if (FunctionBuildConfig.isDemoMode) { CallerAutoPilotManager.INSTANCE.setIPCDemoMode(false); } + + clearAutopilotControlParameters(); } } + /** + * 将业务订单信息保存,鹰眼可取用 + */ + private void updateAutopilotControlParameters() { + + AutopilotControlParameters parameters = initAutopilotControlParameters(); + if (null == parameters){ + CallerLogger.INSTANCE.e(M_TAXI + TAG, "AutopilotControlParameters is empty."); + return; + } + CallerLogger.INSTANCE.d(M_TAXI + TAG, "AutopilotControlParameters is update."); + CallerAutoPilotStatusListenerManager.INSTANCE.updateAutopilotControlParameters(parameters); + } + + private void clearAutopilotControlParameters(){ + CallerLogger.INSTANCE.d(M_TAXI + TAG, "AutopilotControlParameters is clear."); + CallerAutoPilotStatusListenerManager.INSTANCE.updateAutopilotControlParameters(null); + } + //清除订单信息 public void clearCurrentOCHOrder() { startOrStopCalculateRouteInfo(false); mCurrentOCHOrder = null; + clearAutopilotControlParameters(); TaxiTrajectoryManager.getInstance().syncTrajectoryInfo(); SharedPrefsMgr.getInstance(mContext).remove(TaxiConst.SP_KEY_OCH_TAXI_ORDER); isRestartAutopilot = false; @@ -859,12 +889,38 @@ public class TaxiModel { isRestartAutopilot = true; } + AutopilotControlParameters parameters = initAutopilotControlParameters(); + + if (null == parameters) { + CallerLogger.INSTANCE.e(M_TAXI + TAG, "AutopilotControlParameters is empty."); + return; + } + + CallerAutoPilotManager.INSTANCE.startAutoPilot(parameters); + CallerLogger.INSTANCE.d(M_TAXI + TAG, "start autopilot with parameter: %s", GsonUtil.jsonFromObject(parameters) + + " ,startSiteName=" + mCurrentOCHOrder.startSiteAddr + " ,endSiteName=" + mCurrentOCHOrder.endSiteAddr); + + TaxiAnalyticsManager.getInstance().triggerStartAutopilotEvent(isRestartAutopilot, false, + mCurrentOCHOrder.startSiteAddr, mCurrentOCHOrder.endSiteAddr, mCurrentOCHOrder.orderNo); + + // TODO: 2021/8/20 无工控机环境, 手动调起自动驾驶开启返回结果,有工控机环境要删除 +// OCHTaxiUiController.getInstance().onAutoPilotStatusChanged( IMogoAdasOCHCallback.STATUS_AUTOPILOT_RUNNING, "开启自动驾驶" ); + } + + private AutopilotControlParameters initAutopilotControlParameters() { + + if (!checkCurrentOCHOrder()) { + CallerLogger.INSTANCE.e(M_TAXI + TAG, "no order or order is empty."); + return null; + } + + AutopilotControlParameters parameters = new AutopilotControlParameters(); + double startWgsLon = mCurrentOCHOrder.startSitePoint.get(0); double startWgsLat = mCurrentOCHOrder.startSitePoint.get(1); double endWgsLon = mCurrentOCHOrder.endSitePoint.get(0); double endWgsLat = mCurrentOCHOrder.endSitePoint.get(1); - AutopilotControlParameters parameters = new AutopilotControlParameters(); parameters.vehicleType = mCurrentOCHOrder.businessType; parameters.startName = PinYinUtil.getPinYinHeadChar(mCurrentOCHOrder.startSiteAddr); // 起点名称拼音首字母大写:科学城B区2号门(KXCBQ2HM) parameters.endName = PinYinUtil.getPinYinHeadChar(mCurrentOCHOrder.endSiteAddr); // 终点名称拼音首字母大写:科学城C区三号门(KXCCQSHM) @@ -880,15 +936,7 @@ public class TaxiModel { mCurrentOCHOrder.txtFileUrlDPQP, mCurrentOCHOrder.txtFileMd5DPQP, mCurrentOCHOrder.contrailSaveTimeDPQP); } - CallerAutoPilotManager.INSTANCE.startAutoPilot(parameters); - CallerLogger.INSTANCE.d(M_TAXI + TAG, "start autopilot with parameter: %s", GsonUtil.jsonFromObject(parameters) - + " ,startSiteName=" + mCurrentOCHOrder.startSiteAddr + " ,endSiteName=" + mCurrentOCHOrder.endSiteAddr); - - TaxiAnalyticsManager.getInstance().triggerStartAutopilotEvent(isRestartAutopilot, false, - mCurrentOCHOrder.startSiteAddr, mCurrentOCHOrder.endSiteAddr, mCurrentOCHOrder.orderNo); - - // TODO: 2021/8/20 无工控机环境, 手动调起自动驾驶开启返回结果,有工控机环境要删除 -// OCHTaxiUiController.getInstance().onAutoPilotStatusChanged( IMogoAdasOCHCallback.STATUS_AUTOPILOT_RUNNING, "开启自动驾驶" ); + return parameters; } //结束自动驾驶 @@ -913,18 +961,8 @@ public class TaxiModel { startLon, startLat, location.getLongitude(), location.getLatitude()); -// if (DebugConfig.isDebug() && mCurrentOCHOrder.orderStatus == TaxiOrderStatusEnum.OnTheWayToStart.getCode()) { -// // ToastUtils.showShort("距离上车点:" + Double.valueOf(distance).intValue()); -// } - CallerLogger.INSTANCE.i(M_TAXI + TAG, "judgeStartStation() distance = " + distance); -// if (distance > TaxiConst.ARRIVE_AT_START_STATION_DISTANCE) { -// distance = CoordinateUtils.calculateLineDistance(startLon, startLat, -// CallerAutoPilotStatusListenerManager.INSTANCE.getCurWgs84Lon(), -// CallerAutoPilotStatusListenerManager.INSTANCE.getCurWgs84Lat()); -// } - if (distance <= TaxiConst.ARRIVE_AT_START_STATION_DISTANCE) { arrivedStartPoint(); return; @@ -1011,12 +1049,6 @@ public class TaxiModel { CallerLogger.INSTANCE.i(M_TAXI + TAG, "judgeEndStation() distance = " + distance); -// if (distance > TaxiConst.ARRIVE_AT_START_STATION_DISTANCE) { -// distance = CoordinateUtils.calculateLineDistance(startLon, startLat, -// CallerAutoPilotStatusListenerManager.INSTANCE.getCurWgs84Lon(), -// CallerAutoPilotStatusListenerManager.INSTANCE.getCurWgs84Lat()); -// } - if (distance <= TaxiConst.ARRIVE_AT_START_STATION_DISTANCE) { if (!checkCurrentOCHOrder() || (getCurOrderStatus() == TaxiOrderStatusEnum.ArriveAtEnd)) { @@ -1277,9 +1309,7 @@ public class TaxiModel { private void reportTotalDisAndTime() { float lastSumLength = CoordinateCalculateRouteUtil.calculateRouteSumLength(mRoutePoints); double lastTime = lastSumLength / TaxiConst.TAXI_AVERAGE_SPEED * 3.6; //秒 -// if (mOrderStatusCallback != null) { -// mOrderStatusCallback.onCurrentOrderDistToEndChanged((long) lastSumLength, (long) lastTime); -// } + reportOrderRemain((long) lastSumLength, (long) lastTime); } @@ -1401,9 +1431,7 @@ public class TaxiModel { , new TaxiServiceCallback() { @Override public void onSuccess(TaxiDataBaseRespBean data) { - if (null != data && 0 == data.code){ - updateOrderStatus(TaxiOrderStatusEnum.UserArriveAtStart); - } + } @Override @@ -1425,9 +1453,7 @@ public class TaxiModel { , new TaxiServiceCallback() { @Override public void onSuccess(TaxiDataBaseRespBean data) { - if (null != data && 0 == data.code){ - updateOrderStatus(TaxiOrderStatusEnum.OnTheWayToEnd); - } + } @Override @@ -1447,9 +1473,7 @@ public class TaxiModel { , new TaxiServiceCallback() { @Override public void onSuccess(TaxiDataBaseRespBean data) { - if (null != data && 0 == data.code){ - updateOrderStatus(TaxiOrderStatusEnum.ArriveAtStart); - } + } @Override @@ -1470,9 +1494,7 @@ public class TaxiModel { , new TaxiServiceCallback() { @Override public void onSuccess(TaxiDataBaseRespBean data) { - if (null != data && 0 == data.code){ - updateOrderStatus(TaxiOrderStatusEnum.ArriveAtEnd); - } + } @Override @@ -1493,9 +1515,9 @@ public class TaxiModel { , new TaxiServiceCallback() { @Override public void onSuccess(TaxiDataBaseRespBean data) { - if (null != data && 0 == data.code){ - updateOrderStatus(TaxiOrderStatusEnum.JourneyCompleted); - } +// if (null != data && 0 == data.code){ +// updateOrderStatus(TaxiOrderStatusEnum.JourneyCompleted); +// } } @Override @@ -1504,16 +1526,6 @@ public class TaxiModel { } }); } - //更新当前订单状态 - public void updateOrderStatus(final TaxiOrderStatusEnum orderStatus) { - if (mCurrentOCHOrder == null) { - return; - } - mCurrentOCHOrder.orderStatus = orderStatus.getCode(); - if (mOrderStatusCallback != null) { - mOrderStatusCallback.onCurrentOrderStatusChanged(mCurrentOCHOrder); - } - } // 登出 public void logout() {