[opt] 弱网缓存处理
This commit is contained in:
@@ -55,7 +55,10 @@ import com.mogo.och.bus.passenger.callback.IBusPassengerRouteLineInfoCallback;
|
||||
import com.mogo.och.bus.passenger.constant.BusPassengerConst;
|
||||
import com.mogo.och.bus.passenger.network.BusPassengerModelLoopManager;
|
||||
import com.mogo.och.bus.passenger.network.BusPassengerServiceManager;
|
||||
import com.mogo.och.common.module.bean.AppConnectMsg;
|
||||
import com.mogo.och.common.module.bean.dpmsg.AppConnectMsg;
|
||||
import com.mogo.och.common.module.bean.dpmsg.BaseDPMsg;
|
||||
import com.mogo.och.common.module.bean.dpmsg.DPMsgType;
|
||||
import com.mogo.och.common.module.bean.dpmsg.LoginCacheStatus;
|
||||
import com.mogo.och.common.module.biz.common.socketmessage.OCHSocketMessageManager;
|
||||
import com.mogo.och.common.module.biz.constant.OchCommonConst;
|
||||
import com.mogo.och.common.module.biz.network.OchCommonServiceCallback;
|
||||
@@ -319,12 +322,16 @@ public class BusPassengerModel {
|
||||
public void onReceivedMsg(int type, @NonNull byte[] byteArray) {
|
||||
if (OchCommonConst.BUSINESS_STRING == type){
|
||||
|
||||
AppConnectMsg msg = GsonUtils.fromJson(new String(byteArray), AppConnectMsg.class);
|
||||
Logger.d(SceneConstant.M_BUS_P+TAG,"onReceivedMsg = "+GsonUtils.toJson(msg));
|
||||
if (msg.isViewShow()){ //消息盒子显示内容
|
||||
OCHSocketMessageManager.INSTANCE.pushAppOperationalMsgBox(
|
||||
DateTimeUtil.getCurrentTimeStamp(),msg.getMsg(),
|
||||
OCHSocketMessageManager.OPERATION_SYSTEM);
|
||||
BaseDPMsg baseMsg = GsonUtils.fromJson(new String(byteArray), BaseDPMsg.class);
|
||||
Logger.d(SceneConstant.M_BUS_P+TAG,"onReceivedMsg = "+GsonUtils.toJson(baseMsg));
|
||||
|
||||
if (baseMsg != null && baseMsg.getType() == DPMsgType.TYPE_COMMON.getType()){
|
||||
AppConnectMsg msg = GsonUtils.fromJson(new String(byteArray), AppConnectMsg.class);
|
||||
if (msg.isViewShow()){ //消息盒子显示内容
|
||||
OCHSocketMessageManager.INSTANCE.pushAppOperationalMsgBox(
|
||||
DateTimeUtil.getCurrentTimeStamp(),msg.getMsg(),
|
||||
OCHSocketMessageManager.OPERATION_SYSTEM);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,9 +21,6 @@ import com.mogo.och.bus.passenger.model.CharterPassengerModel
|
||||
import com.mogo.och.bus.passenger.model.IOrderStatusChangeListener
|
||||
import com.mogo.och.bus.passenger.model.OrderStatusEnum
|
||||
import com.mogo.och.bus.passenger.ui.MainFragment
|
||||
import com.mogo.och.common.module.bean.dpmsg.BaseDPMsg
|
||||
import com.mogo.och.common.module.bean.dpmsg.ChangeDestMsg
|
||||
import com.mogo.och.common.module.bean.dpmsg.DPCommonOperationMsg
|
||||
import com.mogo.och.common.module.bean.dpmsg.DPMsgType
|
||||
import com.mogo.och.common.module.biz.common.socketmessage.OCHSocketMessageManager
|
||||
import com.mogo.och.common.module.biz.constant.OchCommonConst
|
||||
@@ -33,6 +30,8 @@ import com.mogo.och.common.module.utils.DateTimeUtil
|
||||
import com.mogo.och.common.module.utils.NumberFormatUtil
|
||||
import com.mogo.och.common.module.utils.SoundPoolHelper
|
||||
import com.mogo.och.common.module.voice.VoiceNotice
|
||||
import com.mogo.och.common.module.bean.dpmsg.BaseDPMsg
|
||||
import com.mogo.och.common.module.bean.dpmsg.DPCommonOperationMsg
|
||||
import io.reactivex.disposables.Disposable
|
||||
import java.util.*
|
||||
|
||||
|
||||
@@ -25,17 +25,16 @@ import com.mogo.och.bus.passenger.bean.response.SiteInfoResponse
|
||||
import com.mogo.och.bus.passenger.model.CharterPassengerModel
|
||||
import com.mogo.och.bus.passenger.net.BusPassengerModelLoopManager
|
||||
import com.mogo.och.bus.passenger.net.BusPassengerServiceManager
|
||||
import com.mogo.och.bus.passenger.presenter.BusPassengerFunctionDevicePresenter
|
||||
import com.mogo.och.bus.passenger.ui.M1ContainFragment
|
||||
import com.mogo.och.bus.passenger.ui.adapter.OrderLineItemAdapter
|
||||
import com.mogo.och.bus.passenger.ui.adapter.OrderSiteItemAdapter
|
||||
import com.mogo.och.bus.passenger.utils.RxUtils
|
||||
import com.mogo.och.bus.passenger.view.BottomDecoration
|
||||
import com.mogo.och.common.module.bean.dpmsg.ChangeDestMsg
|
||||
import com.mogo.och.common.module.bean.dpmsg.DPMsgType
|
||||
import com.mogo.och.common.module.biz.constant.OchCommonConst
|
||||
import com.mogo.och.common.module.biz.network.OchCommonServiceCallback
|
||||
import com.mogo.och.common.module.manager.OCHPlanningStopSideStatusManager
|
||||
import com.mogo.och.common.module.bean.dpmsg.ChangeDestMsg
|
||||
import io.reactivex.disposables.Disposable
|
||||
import kotlinx.android.synthetic.m1.m1_order_lineside.view.*
|
||||
import me.jessyan.autosize.utils.AutoSizeUtils
|
||||
|
||||
@@ -52,6 +52,7 @@ import com.mogo.och.common.module.manager.CharterSendTripInfoManager.END_TRIP
|
||||
import com.mogo.och.common.module.manager.CharterSendTripInfoManager.START_TRIP
|
||||
import com.mogo.och.common.module.manager.OCHAdasAbilityManager
|
||||
import com.mogo.och.common.module.utils.*
|
||||
import com.mogo.och.data.bean.*
|
||||
import io.reactivex.exceptions.UndeliverableException
|
||||
import io.reactivex.functions.Consumer
|
||||
import io.reactivex.plugins.RxJavaPlugins
|
||||
@@ -206,6 +207,8 @@ class DriverM1Model {
|
||||
OCHSocketMessageManager.msgWriteOffPassengerType
|
||||
)
|
||||
stopLoopAbnormalFactors()
|
||||
|
||||
CallerTelematicListenerManager.removeListener(TAG)
|
||||
}
|
||||
/**
|
||||
* 接收乘客屏发来确认信息
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
package com.mogo.och.common.module.bean
|
||||
|
||||
import com.mogo.och.common.module.bean.dpmsg.DPMsgType
|
||||
|
||||
/**
|
||||
* @author: wangmingjun
|
||||
* @date: 2023/2/14
|
||||
*/
|
||||
data class AppConnectMsg(var isViewShow: Boolean,var isPlay: Boolean,var msg: String
|
||||
,var type:Int = DPMsgType.TYPE_COMMON.type
|
||||
)
|
||||
@@ -1,7 +0,0 @@
|
||||
package com.mogo.och.common.module.bean.dpmsg
|
||||
|
||||
/**
|
||||
* @author: wangmingjun
|
||||
* @date: 2023/2/24
|
||||
*/
|
||||
open class BaseDPMsg(var type: Int) // 0: 常规 1:确认路线/站点 2:开/关车门 3:结束订单
|
||||
@@ -1,15 +0,0 @@
|
||||
package com.mogo.och.common.module.bean.dpmsg
|
||||
|
||||
/**
|
||||
* @author: wangmingjun
|
||||
* @date: 2023/2/24
|
||||
*/
|
||||
data class ChangeDestMsg(
|
||||
var lineId: Int, //线路id
|
||||
var lineName: String = "", //线路名称
|
||||
var startSiteId: Int= 0, //当前站点
|
||||
var startSiteName: String = "",
|
||||
var destSiteId: Int= 0, //目的地
|
||||
var destSiteName: String = "",
|
||||
var isConfirmed: Boolean = false //司机端是否同意
|
||||
): BaseDPMsg(DPMsgType.TYPE_CHANGE_DEST.type)
|
||||
@@ -1,9 +0,0 @@
|
||||
package com.mogo.och.common.module.bean.dpmsg
|
||||
|
||||
/**
|
||||
* @author: wangmingjun
|
||||
* @date: 2023/2/24
|
||||
*/
|
||||
data class DPCommonOperationMsg(
|
||||
var msg: String
|
||||
): BaseDPMsg(DPMsgType.TYPE_COMMON.type)
|
||||
@@ -9,5 +9,6 @@ enum class DPMsgType(val type: Int) {
|
||||
TYPE_CHANGE_DEST(1),// 变更目的地确认
|
||||
TYPE_OPEN_CLOSE_DOOR(2),//开关门
|
||||
TYPE_ORDER_CLOSED(3), // 订单结束
|
||||
TYPE_TASK_DETAILS(4) //路线任务详情
|
||||
TYPE_TASK_DETAILS(4), //路线任务详情
|
||||
TYPE_LOGIN_STATUS(5) //login status
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
package com.mogo.och.common.module.bean.dpmsg
|
||||
|
||||
/**
|
||||
* @author: wangmingjun
|
||||
* @date: 2023/2/24
|
||||
*/
|
||||
data class DPOperateDoorMsg(
|
||||
var open: Boolean = false // true: 开门, false: 关门
|
||||
): BaseDPMsg(DPMsgType.TYPE_OPEN_CLOSE_DOOR.type)
|
||||
@@ -1,9 +0,0 @@
|
||||
package com.mogo.och.common.module.bean.dpmsg
|
||||
|
||||
/**
|
||||
* @author: wangmingjun
|
||||
* @date: 2023/2/24
|
||||
*/
|
||||
data class DPOrderClosedMsg(
|
||||
var closed: Boolean = true // true: 开门, false: 关门
|
||||
): BaseDPMsg(DPMsgType.TYPE_ORDER_CLOSED.type)
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.mogo.och.common.module.bean.dpmsg
|
||||
/**
|
||||
* @author: wangmingjun
|
||||
* @date: 2023/3/27
|
||||
*/
|
||||
|
||||
object BusCacheKey{
|
||||
const val BUS_LINE_CACHE = "bus_line_cache"
|
||||
}
|
||||
|
||||
open class BaseDPMsg(open var type: Int) // 0: 常规 1:确认路线/站点 2:开/关车门 3:结束订单
|
||||
|
||||
data class LoginCacheStatus(
|
||||
var loginStatus: Int,
|
||||
var updateTime: Long
|
||||
): BaseDPMsg(DPMsgType.TYPE_LOGIN_STATUS.type)
|
||||
|
||||
data class ChangeDestMsg(
|
||||
var lineId: Int, //线路id
|
||||
var lineName: String = "", //线路名称
|
||||
var startSiteId: Int= 0, //当前站点
|
||||
var startSiteName: String = "",
|
||||
var destSiteId: Int= 0, //目的地
|
||||
var destSiteName: String = "",
|
||||
var isConfirmed: Boolean = false //司机端是否同意
|
||||
): BaseDPMsg(DPMsgType.TYPE_CHANGE_DEST.type)
|
||||
|
||||
data class DPCommonOperationMsg(
|
||||
var msg: String
|
||||
): BaseDPMsg(DPMsgType.TYPE_COMMON.type)
|
||||
|
||||
data class DPOperateDoorMsg(
|
||||
var open: Boolean = false // true: 开门, false: 关门
|
||||
): BaseDPMsg(DPMsgType.TYPE_OPEN_CLOSE_DOOR.type)
|
||||
|
||||
data class DPOrderClosedMsg(
|
||||
var closed: Boolean = true // true: 开门, false: 关门
|
||||
): BaseDPMsg(DPMsgType.TYPE_ORDER_CLOSED.type)
|
||||
|
||||
data class AppConnectMsg(var isViewShow: Boolean, var isPlay: Boolean, var msg: String,
|
||||
override var type: Int
|
||||
): BaseDPMsg(type)
|
||||
|
||||
data class TaskDetailsMsg(
|
||||
var msg: String,
|
||||
override var type: Int
|
||||
): BaseDPMsg(type)
|
||||
@@ -31,12 +31,12 @@ android {
|
||||
|
||||
dependencies {
|
||||
|
||||
implementation 'androidx.core:core-ktx:1.7.0'
|
||||
implementation 'androidx.appcompat:appcompat:1.3.0'
|
||||
implementation 'com.google.android.material:material:1.4.0'
|
||||
testImplementation 'junit:junit:4.13.2'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
|
||||
implementation fileTree(dir: "libs", include: ["*.jar"])
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||
implementation rootProject.ext.dependencies.androidxccorektx
|
||||
implementation rootProject.ext.dependencies.androidxappcompat
|
||||
implementation rootProject.ext.dependencies.material
|
||||
implementation rootProject.ext.dependencies.rxandroid
|
||||
|
||||
if (Boolean.valueOf(USE_MAVEN_PACKAGE)) {
|
||||
api rootProject.ext.dependencies.mogoutils
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
package com.mogo.och.data.bean
|
||||
|
||||
/**
|
||||
* @author: wangmingjun
|
||||
* @date: 2023/3/27
|
||||
*/
|
||||
|
||||
object BusCacheKey{
|
||||
const val BUS_LINE_CACHE = "bus_line_cache"
|
||||
}
|
||||
|
||||
data class LoginCacheStatus(var login: Boolean,var updateTime: Long)
|
||||
@@ -22,12 +22,19 @@ import com.mogo.commons.module.status.IMogoStatusChangedListener;
|
||||
import com.mogo.commons.module.status.MogoStatusManager;
|
||||
import com.mogo.eagle.core.function.api.telematic.IReceivedMsgListener;
|
||||
import com.mogo.eagle.core.function.call.telematic.CallerTelematicListenerManager;
|
||||
import com.mogo.eagle.core.function.call.telematic.CallerTelematicManager;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant;
|
||||
import com.mogo.eagle.core.utilcode.util.GsonUtils;
|
||||
import com.mogo.eagle.core.utilcode.util.ToastUtils;
|
||||
import com.mogo.och.bus.passenger.R;
|
||||
import com.mogo.och.bus.passenger.bean.BusPassengerOperationStatusResponse;
|
||||
import com.mogo.och.bus.passenger.bean.BusPassengerRoutesResponse;
|
||||
import com.mogo.och.common.module.bean.AppConnectMsg;
|
||||
import com.mogo.och.common.module.bean.dpmsg.AppConnectMsg;
|
||||
import com.mogo.och.common.module.bean.dpmsg.BaseDPMsg;
|
||||
import com.mogo.och.common.module.bean.dpmsg.DPMsgType;
|
||||
import com.mogo.och.common.module.bean.dpmsg.LoginCacheStatus;
|
||||
import com.mogo.och.common.module.bean.dpmsg.TaskDetailsMsg;
|
||||
import com.mogo.och.common.module.biz.common.socketmessage.OCHSocketMessageManager;
|
||||
import com.mogo.och.common.module.biz.constant.OchCommonConst;
|
||||
import com.mogo.och.common.module.utils.DateTimeUtil;
|
||||
@@ -47,9 +54,6 @@ import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr;
|
||||
import com.mogo.eagle.core.utilcode.util.CoordinateUtils;
|
||||
import com.mogo.eagle.core.utilcode.util.NetworkUtils;
|
||||
import com.mogo.eagle.core.utilcode.util.ToastUtils;
|
||||
import com.mogo.och.bus.passenger.R;
|
||||
import com.mogo.och.bus.passenger.bean.BusPassengerOperationStatusResponse;
|
||||
import com.mogo.och.bus.passenger.callback.IBusPassegerDriverStatusCallback;
|
||||
import com.mogo.och.bus.passenger.callback.IBusPassengerADASStatusCallback;
|
||||
import com.mogo.och.bus.passenger.callback.IBusPassengerAutopilotPlanningCallback;
|
||||
@@ -127,11 +131,19 @@ public class BusPassengerModel {
|
||||
public void init( Context context ) {
|
||||
mContext = context.getApplicationContext();
|
||||
initListeners();
|
||||
// TODO: 2022/3/31
|
||||
queryDriverOperationStatus();
|
||||
queryDriverByLocalDriver();
|
||||
startOrStopOrderLoop(true);
|
||||
}
|
||||
|
||||
private void queryDriverByLocalDriver() {
|
||||
//本地去请求司机端
|
||||
AppConnectMsg msg = new AppConnectMsg(false,false,"",
|
||||
DPMsgType.TYPE_TASK_DETAILS.getType());
|
||||
|
||||
sendMsgToServer(GsonUtils.toJson(msg));
|
||||
}
|
||||
|
||||
public void setDriverStatusCallback(IBusPassegerDriverStatusCallback callback){
|
||||
this.mDriverStatusCallback = callback;
|
||||
}
|
||||
@@ -144,6 +156,13 @@ public class BusPassengerModel {
|
||||
handler.sendEmptyMessageDelayed( MSG_QUERY_BUS_P_STATION, QUERY_BUS_P_STATION_DELAY );
|
||||
}
|
||||
|
||||
private void sendMsgToServer(String msg){
|
||||
CallerTelematicManager.INSTANCE.sendMsgToServer(
|
||||
OchCommonConst.BUSINESS_STRING,
|
||||
GsonUtils.toJson(msg).getBytes()
|
||||
);
|
||||
}
|
||||
|
||||
private void queryDriverOperationStatus() {
|
||||
BusPassengerServiceManager.queryDriverOperationStatus(mContext
|
||||
, new OchCommonServiceCallback<BusPassengerOperationStatusResponse>() {
|
||||
@@ -164,7 +183,7 @@ public class BusPassengerModel {
|
||||
} else {
|
||||
ToastUtils.showShort(mContext.getString(R.string.request_error_tip));
|
||||
}
|
||||
queryDriverOperationDelay();
|
||||
queryDriverByLocalDriver();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -194,6 +213,11 @@ public class BusPassengerModel {
|
||||
routesResult.getWriteVersion() < data.getResult().getWriteVersion()){
|
||||
routesResult = data.getResult();
|
||||
}
|
||||
|
||||
if (routesResult == null){
|
||||
routesResult = data.getResult();
|
||||
}
|
||||
|
||||
updatePassengerRouteInfo(routesResult);
|
||||
}
|
||||
|
||||
@@ -323,31 +347,41 @@ public class BusPassengerModel {
|
||||
AbnormalFactorsLoopManager.INSTANCE.stopLoopAbnormalFactors();
|
||||
|
||||
CallerTelematicListenerManager.INSTANCE.removeListener(TAG);
|
||||
CallerTelematicListenerManager.INSTANCE.removeListener(TAG);
|
||||
}
|
||||
|
||||
private final IReceivedMsgListener mReceivedMsgListener = new IReceivedMsgListener() {
|
||||
@Override
|
||||
public void onReceivedMsg(int type, @NonNull byte[] byteArray) {
|
||||
if (OchCommonConst.BUSINESS_STRING == type){
|
||||
if (OchCommonConst.BUSINESS_STRING == type) {
|
||||
|
||||
AppConnectMsg msg = GsonUtils.fromJson(new String(byteArray), AppConnectMsg.class);
|
||||
Logger.d(SceneConstant.M_BUS_P+TAG,"onReceivedMsg = "+GsonUtils.toJson(msg));
|
||||
if (msg.getType() == DPMsgType.TYPE_TASK_DETAILS.getType()){
|
||||
if (msg.getMsg().isEmpty()){
|
||||
BaseDPMsg baseMsg = GsonUtils.fromJson(new String(byteArray), BaseDPMsg.class);
|
||||
Logger.d(SceneConstant.M_BUS_P + TAG, "onReceivedMsg = " + GsonUtils.toJson(baseMsg));
|
||||
|
||||
if (baseMsg != null && baseMsg.getType() == DPMsgType.TYPE_COMMON.getType()) {
|
||||
AppConnectMsg msg = GsonUtils.fromJson(new String(byteArray), AppConnectMsg.class);
|
||||
if (msg != null && msg.isViewShow()) { //消息盒子显示内容
|
||||
OCHSocketMessageManager.INSTANCE.pushAppOperationalMsgBox(
|
||||
DateTimeUtil.getCurrentTimeStamp(), msg.getMsg(),
|
||||
OCHSocketMessageManager.OPERATION_SYSTEM);
|
||||
}
|
||||
} else if (baseMsg != null && baseMsg.getType() == DPMsgType.TYPE_LOGIN_STATUS.getType()) {
|
||||
LoginCacheStatus msg = GsonUtils.fromJson(new String(byteArray), LoginCacheStatus.class);
|
||||
if (msg != null) {
|
||||
mDriverStatusCallback.changeOperationStatus(msg.getLoginStatus() == 1);
|
||||
}
|
||||
} else if (baseMsg != null && baseMsg.getType() == DPMsgType.TYPE_TASK_DETAILS.getType()) {
|
||||
TaskDetailsMsg msg = GsonUtils.fromJson(new String(byteArray), TaskDetailsMsg.class);
|
||||
Logger.d(SceneConstant.M_BUS_P + TAG, "onReceivedMsg = " + GsonUtils.toJson(msg));
|
||||
if (msg == null || msg.getMsg().isEmpty()) {
|
||||
clearLocalRouteResult();
|
||||
return;
|
||||
}
|
||||
BusRoutesResult result = GsonUtils.fromJson(msg.getMsg(),BusRoutesResult.class);
|
||||
if (result.getWriteVersion() > routesResult.getWriteVersion()){
|
||||
BusRoutesResult result = GsonUtils.fromJson(msg.getMsg(), BusRoutesResult.class);
|
||||
if (result != null && result.getWriteVersion() > routesResult.getWriteVersion()) {
|
||||
routesResult = result;
|
||||
updatePassengerRouteInfo(routesResult);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (msg.isViewShow()){ //消息盒子显示内容
|
||||
OCHSocketMessageManager.INSTANCE.pushAppOperationalMsgBox(
|
||||
DateTimeUtil.getCurrentTimeStamp(),msg.getMsg(),
|
||||
OCHSocketMessageManager.OPERATION_SYSTEM);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,13 +4,9 @@ import android.content.Context
|
||||
import com.mogo.eagle.core.function.call.telematic.CallerTelematicManager.getServerToken
|
||||
import com.mogo.och.bus.passenger.bean.BusPassengerRoutesResponse
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig
|
||||
import com.mogo.eagle.core.data.config.FunctionBuildConfig
|
||||
import com.mogo.eagle.core.function.call.telematic.CallerTelematicManager
|
||||
import com.mogo.och.bus.passenger.bean.BusPassengerQueryLineRequest
|
||||
import com.mogo.och.bus.passenger.bean.BusPassengerOperationStatusResponse
|
||||
import com.mogo.eagle.core.network.MoGoRetrofitFactory
|
||||
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils
|
||||
import com.mogo.och.bus.passenger.constant.URLConst.Companion.getBaseUrl
|
||||
import com.mogo.och.common.module.biz.constant.OchCommonConst
|
||||
import com.mogo.och.common.module.biz.network.OchCommonServiceCallback
|
||||
import com.mogo.och.common.module.biz.network.OchCommonSubscribeImpl
|
||||
|
||||
@@ -16,6 +16,8 @@ import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.amap.api.maps.model.LatLng;
|
||||
import com.elegant.network.utils.GsonUtil;
|
||||
import com.mogo.aicloud.services.socket.IMogoOnMessageListener;
|
||||
import com.mogo.eagle.core.function.api.telematic.IReceivedMsgListener;
|
||||
import com.mogo.eagle.core.function.call.telematic.CallerTelematicListenerManager;
|
||||
import com.mogo.eagle.core.utilcode.util.CoordinateUtils;
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.commons.module.status.IMogoStatusChangedListener;
|
||||
@@ -26,7 +28,12 @@ import com.mogo.eagle.core.data.autopilot.AutopilotControlParameters;
|
||||
import com.mogo.eagle.core.data.config.FunctionBuildConfig;
|
||||
import com.mogo.eagle.core.data.map.MogoLocation;
|
||||
import com.mogo.och.bus.bean.BusRoutesResponse;
|
||||
import com.mogo.och.common.module.bean.dpmsg.AppConnectMsg;
|
||||
import com.mogo.och.common.module.bean.dpmsg.BaseDPMsg;
|
||||
import com.mogo.och.common.module.bean.dpmsg.DPMsgType;
|
||||
import com.mogo.och.common.module.bean.dpmsg.LoginCacheStatus;
|
||||
import com.mogo.och.common.module.bean.dpmsg.TaskDetailsMsg;
|
||||
import com.mogo.och.common.module.biz.constant.LoginStatusManager;
|
||||
import com.mogo.och.data.bean.BusStationBean;
|
||||
import com.mogo.och.common.module.biz.common.socketmessage.data.SystemMsg;
|
||||
import com.mogo.och.common.module.biz.constant.OchCommonConst;
|
||||
@@ -57,7 +64,6 @@ import com.mogo.och.bus.net.OrderServiceManager;
|
||||
import com.mogo.och.bus.util.BusAnalyticsManager;
|
||||
import com.mogo.och.bus.util.BusSendTripInfoManager;
|
||||
import com.mogo.och.bus.util.BusTrajectoryManager;
|
||||
import com.mogo.och.common.module.bean.AppConnectMsg;
|
||||
import com.mogo.och.common.module.biz.common.socketmessage.OCHSocketMessageManager;
|
||||
import com.mogo.och.common.module.biz.network.OchCommonServiceCallback;
|
||||
import com.mogo.och.common.module.biz.provider.LoginService;
|
||||
@@ -70,8 +76,9 @@ import com.mogo.och.common.module.utils.NumberFormatUtil;
|
||||
import com.mogo.och.common.module.utils.PinYinUtil;
|
||||
import com.mogo.och.common.module.voice.VoiceManager;
|
||||
import com.mogo.och.common.module.voice.VoiceNotice;
|
||||
import com.mogo.och.data.bean.BusCacheKey;
|
||||
import com.mogo.och.common.module.bean.dpmsg.BusCacheKey;
|
||||
import com.mogo.och.data.manager.cache.CacheDataManager;
|
||||
import com.zhidao.socket.utils.LoginStatusUtil;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -177,6 +184,9 @@ public class OrderModel {
|
||||
|
||||
AbnormalFactorsLoopManager.INSTANCE.startLoopAbnormalFactors(mContext);
|
||||
|
||||
//监听乘客屏发来的消息
|
||||
CallerTelematicListenerManager.INSTANCE.addListener(TAG,mReceivedMsgListener);
|
||||
|
||||
//2022.1.28
|
||||
// 调用Disposable.dispose() 时候会出现InterruptedException 导致出现崩溃
|
||||
// The exception could not be delivered to the consumer because it has already canceled/disposed
|
||||
@@ -215,6 +225,23 @@ public class OrderModel {
|
||||
});
|
||||
}
|
||||
|
||||
private final IReceivedMsgListener mReceivedMsgListener =
|
||||
new IReceivedMsgListener() {
|
||||
@Override
|
||||
public void onReceivedMsg(int type, @NonNull byte[] byteArray) {
|
||||
if (OchCommonConst.BUSINESS_STRING == type){
|
||||
BaseDPMsg msg = GsonUtils.fromJson(new String(byteArray),BaseDPMsg.class);
|
||||
if (msg!=null && msg.getType() == DPMsgType.TYPE_TASK_DETAILS.getType()){
|
||||
if (LoginStatusUtil.isLogin()){
|
||||
sendTaskDetailsToClients();
|
||||
}else {// 未登陆
|
||||
sendLoginStatusToClient();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private final IMogoOnMessageListener<SystemMsg> mMogoOnMessageListener =
|
||||
new IMogoOnMessageListener<SystemMsg>() {
|
||||
@Override
|
||||
@@ -332,6 +359,8 @@ public class OrderModel {
|
||||
OCHSocketMessageManager.msgWriteOffPassengerType);
|
||||
|
||||
AbnormalFactorsLoopManager.INSTANCE.stopLoopAbnormalFactors();
|
||||
//监听乘客屏发来的消息
|
||||
CallerTelematicListenerManager.INSTANCE.removeListener(TAG);
|
||||
}
|
||||
|
||||
private Object readResolve() {
|
||||
@@ -442,14 +471,14 @@ public class OrderModel {
|
||||
|| data.getResult().getSites() == null
|
||||
|| data.getResult().getSites().isEmpty()) {
|
||||
// //当为空时,显示无绑定路线图
|
||||
// CallerLogger.INSTANCE.d(M_BUS + TAG, "获取到小巴路线数据:空 ");
|
||||
// if (refreshBusStationsCallback != null) {
|
||||
// refreshBusStationsCallback.updateEmptyUi();
|
||||
// }
|
||||
// clearAutopilotControlParameters();
|
||||
// closeBeautificationMode();
|
||||
// clearStartAutopilotTag();
|
||||
// removeTipRunnables();
|
||||
CallerLogger.INSTANCE.d(M_BUS + TAG, "获取到小巴路线数据:空 ");
|
||||
if (refreshBusStationsCallback != null) {
|
||||
refreshBusStationsCallback.updateEmptyUi();
|
||||
}
|
||||
clearAutopilotControlParameters();
|
||||
closeBeautificationMode();
|
||||
clearStartAutopilotTag();
|
||||
removeTipRunnables();
|
||||
CacheDataManager.Companion.getInstance().clearCacheData(mContext,BusCacheKey.BUS_LINE_CACHE);
|
||||
return;
|
||||
}
|
||||
@@ -461,7 +490,12 @@ public class OrderModel {
|
||||
BusCacheKey.BUS_LINE_CACHE,
|
||||
GsonUtils.toJson(data.getResult()));
|
||||
}
|
||||
|
||||
if (busRoutesResult == null){
|
||||
CacheDataManager.Companion.getInstance().putCacheData(mContext,
|
||||
BusCacheKey.BUS_LINE_CACHE,
|
||||
GsonUtils.toJson(data.getResult()));
|
||||
updateBusStatus(data.getResult());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -650,6 +684,8 @@ public class OrderModel {
|
||||
GsonUtils.toJson(busRoutesResult));
|
||||
|
||||
sendTaskDetailsToClients();
|
||||
|
||||
updateBusStatus(busRoutesResult);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -782,9 +818,22 @@ public class OrderModel {
|
||||
}
|
||||
|
||||
private void sendTaskDetailsToClients() {
|
||||
AppConnectMsg arrivedMsg = new AppConnectMsg(false,false,String.format(mContext
|
||||
.getString(R.string.bus_arrived_station_tip),
|
||||
GsonUtils.toJson(busRoutesResult)), DPMsgType.TYPE_TASK_DETAILS.getType());
|
||||
TaskDetailsMsg arrivedMsg = new TaskDetailsMsg(GsonUtils.toJson(busRoutesResult),
|
||||
DPMsgType.TYPE_TASK_DETAILS.getType());
|
||||
|
||||
CallerTelematicManager.INSTANCE.sendMsgToAllClients(OchCommonConst.BUSINESS_STRING,
|
||||
GsonUtils.toJson(arrivedMsg).getBytes());
|
||||
}
|
||||
|
||||
private void sendLoginStatusToClient() {
|
||||
int status = 0;
|
||||
if (LoginStatusManager.isLogin()){
|
||||
status = 1;
|
||||
}else {
|
||||
status = 0;
|
||||
}
|
||||
LoginCacheStatus arrivedMsg = new LoginCacheStatus(status, DateTimeUtil.getCurrentTimeStamp());
|
||||
|
||||
CallerTelematicManager.INSTANCE.sendMsgToAllClients(OchCommonConst.BUSINESS_STRING,
|
||||
GsonUtils.toJson(arrivedMsg).getBytes());
|
||||
}
|
||||
@@ -798,29 +847,29 @@ public class OrderModel {
|
||||
}
|
||||
|
||||
private void sendStartStationToClient(String nextStation) {
|
||||
AppConnectMsg arrivedMsg = new AppConnectMsg(false,true,String.format(mContext
|
||||
AppConnectMsg startMsg = new AppConnectMsg(false,true,String.format(mContext
|
||||
.getString(R.string.bus_leave_station_tip),
|
||||
nextStation),DPMsgType.TYPE_COMMON.getType());
|
||||
|
||||
UiThreadHandler.postDelayed(()->
|
||||
CallerTelematicManager.INSTANCE.sendMsgToAllClients(OchCommonConst.BUSINESS_STRING,
|
||||
GsonUtils.toJson(arrivedMsg).getBytes()),DELAY_10S);
|
||||
GsonUtils.toJson(startMsg).getBytes()),DELAY_10S);
|
||||
}
|
||||
|
||||
private void sendEndTaskToClient() {
|
||||
AppConnectMsg arrivedMsg = new AppConnectMsg(false,true,mContext
|
||||
AppConnectMsg endMsg = new AppConnectMsg(false,true,mContext
|
||||
.getString(R.string.bus_end_task_tip),
|
||||
DPMsgType.TYPE_COMMON.getType());
|
||||
|
||||
CallerTelematicManager.INSTANCE.sendMsgToAllClients(OchCommonConst.BUSINESS_STRING,
|
||||
GsonUtils.toJson(arrivedMsg).getBytes());
|
||||
GsonUtils.toJson(endMsg).getBytes());
|
||||
}
|
||||
|
||||
public void sendWriteOffNumToClient(String msg){
|
||||
AppConnectMsg arrivedMsg = new AppConnectMsg(false,true,msg,DPMsgType.TYPE_COMMON.getType());
|
||||
AppConnectMsg passengerMsg = new AppConnectMsg(false,true,msg,DPMsgType.TYPE_COMMON.getType());
|
||||
|
||||
CallerTelematicManager.INSTANCE.sendMsgToAllClients(OchCommonConst.BUSINESS_STRING,
|
||||
GsonUtils.toJson(arrivedMsg).getBytes());
|
||||
GsonUtils.toJson(passengerMsg).getBytes());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -842,6 +891,7 @@ public class OrderModel {
|
||||
CallerLogger.INSTANCE.d(M_BUS + TAG, "行程日志-离站成功开往下一站====");
|
||||
leaveStationSuccess(backgroundCurrentStationIndex, currentStationName,
|
||||
finalNextStationName,finalNextStationNameKr);
|
||||
|
||||
OrderServiceManager.leaveStation(mContext,
|
||||
stationList.get(backgroundCurrentStationIndex).getSeq(),
|
||||
stationList.get(backgroundCurrentStationIndex).getSiteId(),
|
||||
|
||||
Reference in New Issue
Block a user