From f070106fe0a99e538f69c8625788654187a0efb1 Mon Sep 17 00:00:00 2001 From: wangmingjun Date: Mon, 28 Nov 2022 18:35:13 +0800 Subject: [PATCH] =?UTF-8?q?[2.13.0]=20bus=20=E5=BC=80=E5=A7=8B=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E4=BB=BB=E5=8A=A1=E5=89=8D=E6=8F=90=E9=86=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/mogo/och/bus/model/BusOrderModel.java | 76 ++++++++++++++++++- .../src/main/res/values/strings.xml | 2 + .../och/common/module/utils/DateTimeUtil.java | 10 +++ 3 files changed, 85 insertions(+), 3 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 34192243a7..ed4b9da724 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 @@ -32,8 +32,10 @@ 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.toast.TipToast; import com.mogo.eagle.core.utilcode.util.NetworkUtils; import com.mogo.eagle.core.utilcode.util.ToastUtils; +import com.mogo.eagle.core.utilcode.util.UiThreadHandler; import com.mogo.map.navi.IMogoCarLocationChangedListener2; import com.mogo.module.common.MogoApisHandler; import com.mogo.och.bus.R; @@ -117,9 +119,7 @@ public class BusOrderModel { private volatile int firstStartAutopilot = 0; private LoginService loginService; - - private long prePassengerWriteOffTime = 0; //记录最后查询到乘客核销的时间 - + private final Handler handler = new Handler(new Handler.Callback() { @Override public boolean handleMessage(Message msg) { @@ -443,6 +443,7 @@ public class BusOrderModel { clearAutopilotControlParameters(); closeBeautificationMode(); clearStartAutopilotTag(); + removeTipRunnables(); return; } CallerLogger.INSTANCE.d(M_BUS + TAG, "获取到小巴路线数据: " + data); @@ -797,6 +798,11 @@ public class BusOrderModel { BusSendTripInfoManager.INSTANCE.sendBusTripInfo(BusSendTripInfoManager.START_TRIP , busRoutesResult.getName(), "", "", false); } + + //任务选择后首发前给司机提示任务 + if (busRoutesResult != null){ + beforeTaskTips(); + } // startOrStopQueryPassengerWriteOff(true); } @@ -836,6 +842,70 @@ public class BusOrderModel { BusTrajectoryManager.getInstance().syncTrajectoryInfo(); } + private void beforeTaskTips() { + if (busRoutesResult == null) return; + + removeTipRunnables(); + + long taskTime = busRoutesResult.getTaskTime(); + long tip3Time = taskTime-3000 - DateTimeUtil.getCurrentTimeStamp(); // 首站离开前3分钟提示 + long tip1Time = taskTime-1000 - DateTimeUtil.getCurrentTimeStamp(); // 首站离开前1分钟提示 + + if (tip3Time > 0){ + UiThreadHandler.postDelayed(tip3Runnable,tip3Time); + } + + if (tip1Time > 0){ + UiThreadHandler.postDelayed(tip1Runnable,tip1Time); + } + } + + Runnable tip3Runnable = new Runnable() { + @Override + public void run() { + + if (backgroundCurrentStationIndex == 0 && stationList.get(0).getDrivingStatus() == STATION_STATUS_STOPPED + && !stationList.get(0).isLeaving()){ + tipStartTask("3"); + }else { + removeTipRunnables(); + } + } + }; + + private void tipStartTask(String s) { + String tips = String.format(mContext + .getString(R.string.bus_before_tips_s), s); + //展示在运营消息 + OCHSocketMessageManager.INSTANCE.pushAppOperationalMsgBox( + DateTimeUtil.getCurrentTimeStamp(), + tips); + //语音提示 + VoiceNotice.showNotice(tips); + } + + Runnable tip1Runnable = new Runnable() { + @Override + public void run() { + if (backgroundCurrentStationIndex == 0 && stationList != null && + stationList.get(0).getDrivingStatus() == STATION_STATUS_STOPPED + && !stationList.get(0).isLeaving()){ + tipStartTask("1"); + }else { + removeTipRunnables(); + } + } + }; + + public void removeTipRunnables(){ + if (tip3Runnable != null){ + UiThreadHandler.removeCallbacks(tip3Runnable); + } + if (tip1Runnable != null){ + UiThreadHandler.removeCallbacks(tip1Runnable); + } + } + private void clearStartAutopilotTag() { firstStartAutopilot = 0; } diff --git a/OCH/mogo-och-bus/src/main/res/values/strings.xml b/OCH/mogo-och-bus/src/main/res/values/strings.xml index afe287c645..a7829fce0a 100644 --- a/OCH/mogo-och-bus/src/main/res/values/strings.xml +++ b/OCH/mogo-och-bus/src/main/res/values/strings.xml @@ -47,4 +47,6 @@ 感谢您体验\'蘑菇车联\'自动驾驶小巴车,我们下次再见。 + 距离发车时间还有%1$s分钟 + diff --git a/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/utils/DateTimeUtil.java b/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/utils/DateTimeUtil.java index 96893ef697..310b8cb3bd 100644 --- a/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/utils/DateTimeUtil.java +++ b/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/utils/DateTimeUtil.java @@ -4,6 +4,7 @@ import com.mogo.eagle.core.utilcode.util.DateTimeUtils; import java.text.SimpleDateFormat; import java.util.Calendar; +import java.util.Date; /** * @author: wangmingjun @@ -89,4 +90,13 @@ public class DateTimeUtil { int minute = (int)(seconds % 3600)/60; return String.valueOf(minute); } + + + /** + * 返回当前时间 + * @return + */ + public static long getCurrentTimeStamp(){ + return new Date().getTime(); + } }