[2.13.0] bus 开始任务任务前提醒

This commit is contained in:
wangmingjun
2022-11-28 18:35:13 +08:00
parent 636b29b127
commit f070106fe0
3 changed files with 85 additions and 3 deletions

View File

@@ -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;
}

View File

@@ -47,4 +47,6 @@
<string name="bus_end_task_tip">感谢您体验\'蘑菇车联\'自动驾驶小巴车,我们下次再见。</string>
<!-- endregion -->
<string name="bus_before_tips_s">距离发车时间还有%1$s分钟</string>
</resources>

View File

@@ -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();
}
}