[feature] 添加网络连接 token失效后获取3s 1s 2s 三次重试
This commit is contained in:
@@ -39,8 +39,8 @@ import com.mogo.och.bus.passenger.callback.IBusPassengerControllerStatusCallback
|
||||
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.BusPassengerServiceCallback;
|
||||
import com.mogo.och.bus.passenger.network.BusPassengerServiceManager;
|
||||
import com.mogo.och.common.module.biz.network.OchCommonServiceCallback;
|
||||
import com.mogo.och.common.module.utils.CoordinateCalculateRouteUtil;
|
||||
import com.mogo.service.intent.IMogoIntentListener;
|
||||
import com.mogo.service.statusmanager.IMogoStatusChangedListener;
|
||||
@@ -129,8 +129,8 @@ public class BusPassengerModel {
|
||||
}
|
||||
|
||||
private void queryDriverOperationStatus() {
|
||||
BusPassengerServiceManager.getInstance().queryDriverOperationStatus(mContext
|
||||
, new BusPassengerServiceCallback<BusPassengerOperationStatusResponse>() {
|
||||
BusPassengerServiceManager.queryDriverOperationStatus(mContext
|
||||
, new OchCommonServiceCallback<BusPassengerOperationStatusResponse>() {
|
||||
@Override
|
||||
public void onSuccess(BusPassengerOperationStatusResponse data) {
|
||||
if (data == null || data.data == null) return;
|
||||
@@ -149,8 +149,8 @@ public class BusPassengerModel {
|
||||
}
|
||||
|
||||
public void queryDriverSiteByCoordinate(){
|
||||
BusPassengerServiceManager.getInstance().queryDriverSiteByCoordinate(mContext
|
||||
, new BusPassengerServiceCallback<BusPassengerRoutesResponse>() {
|
||||
BusPassengerServiceManager.queryDriverSiteByCoordinate(mContext
|
||||
, new OchCommonServiceCallback<BusPassengerRoutesResponse>() {
|
||||
@Override
|
||||
public void onSuccess(BusPassengerRoutesResponse data) {
|
||||
if ( data == null
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
package com.mogo.och.bus.passenger.network;
|
||||
|
||||
/**
|
||||
* Created on 2022/3/31
|
||||
*/
|
||||
public interface BusPassengerServiceCallback<T> {
|
||||
|
||||
void onSuccess(T data);
|
||||
|
||||
void onFail(int code, String msg);
|
||||
|
||||
default void onError() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,118 +0,0 @@
|
||||
package com.mogo.och.bus.passenger.network;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
|
||||
import com.mogo.eagle.core.data.BaseData;
|
||||
import com.mogo.eagle.core.function.call.telematic.CallerTelematicManager;
|
||||
import com.mogo.eagle.core.network.MoGoRetrofitFactory;
|
||||
import com.mogo.eagle.core.network.RequestOptions;
|
||||
import com.mogo.eagle.core.network.SubscribeImpl;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.och.bus.passenger.bean.BusPassengerOperationStatusResponse;
|
||||
import com.mogo.och.bus.passenger.bean.BusPassengerQueryLineRequest;
|
||||
import com.mogo.och.bus.passenger.bean.BusPassengerRoutesResponse;
|
||||
import com.mogo.och.bus.passenger.constant.BusPassengerConst;
|
||||
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_BUS_P;
|
||||
|
||||
/**
|
||||
* Created on 2022/3/31
|
||||
*/
|
||||
public class BusPassengerServiceManager {
|
||||
private static final String TAG = BusPassengerServiceManager.class.getSimpleName();
|
||||
|
||||
private static final class SingletonHolder {
|
||||
private static final BusPassengerServiceManager INSTANCE = new BusPassengerServiceManager();
|
||||
}
|
||||
|
||||
public static BusPassengerServiceManager getInstance() {
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private BusPassengerServiceApi mBusPassengerServiceApi;
|
||||
|
||||
private BusPassengerServiceManager() {
|
||||
if (mBusPassengerServiceApi == null){
|
||||
mBusPassengerServiceApi = MoGoRetrofitFactory.getInstance(
|
||||
BusPassengerConst.getBaseUrl()).create(BusPassengerServiceApi.class);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取Bus司机端的sn
|
||||
* @return
|
||||
*/
|
||||
private String getDriverAppSn(){
|
||||
return CallerTelematicManager.INSTANCE.getServerToken();
|
||||
// return "X2020211111NG0XNFK";
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询绑定行驶的小巴车路线
|
||||
* @param context
|
||||
* @param callback
|
||||
*/
|
||||
public void queryDriverSiteByCoordinate(Context context
|
||||
,BusPassengerServiceCallback<BusPassengerRoutesResponse> callback){
|
||||
mBusPassengerServiceApi.queryDriverSiteByCoordinate(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
|
||||
,MoGoAiCloudClientConfig.getInstance().getToken()
|
||||
,new BusPassengerQueryLineRequest(getDriverAppSn()))
|
||||
.subscribeOn( Schedulers.io() )
|
||||
.observeOn( AndroidSchedulers.mainThread() )
|
||||
.subscribe(getSubscribeImpl(context,callback,"queryDriverSiteByCoordinate"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询司机端出车收车状态,以及车牌号
|
||||
* @param context
|
||||
* @param callback
|
||||
*/
|
||||
public void queryDriverOperationStatus(Context context, BusPassengerServiceCallback<BusPassengerOperationStatusResponse> callback){
|
||||
mBusPassengerServiceApi.queryDriverOperationStatus(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
|
||||
,MoGoAiCloudClientConfig.getInstance().getToken()
|
||||
,getDriverAppSn())
|
||||
.subscribeOn( Schedulers.io() )
|
||||
.observeOn( AndroidSchedulers.mainThread() )
|
||||
.subscribe(getSubscribeImpl(context,callback,"queryDriverOperationStatus"));
|
||||
}
|
||||
|
||||
|
||||
private <T extends BaseData> SubscribeImpl getSubscribeImpl(
|
||||
Context context, BusPassengerServiceCallback<T> callback, String apiName) {
|
||||
return new SubscribeImpl<T>(RequestOptions.create(context)) {
|
||||
@Override
|
||||
public void onSuccess(T o) {
|
||||
super.onSuccess(o);
|
||||
CallerLogger.INSTANCE.e(M_BUS_P + TAG,apiName +
|
||||
": onSuccess() " + o.msg);
|
||||
if (callback != null) {
|
||||
callback.onSuccess(o);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
super.onError(e);
|
||||
CallerLogger.INSTANCE.e(M_BUS_P + TAG,apiName +
|
||||
": onError() " + e.getMessage());
|
||||
if (callback != null) {
|
||||
callback.onError();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String message, int code) {
|
||||
super.onError(message, code);
|
||||
CallerLogger.INSTANCE.e(M_BUS_P + TAG,String.format(apiName +
|
||||
": onError() code = %d; message = %s;", code, message));
|
||||
if (callback != null) {
|
||||
callback.onFail(code, message);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.mogo.och.bus.passenger.network
|
||||
|
||||
import android.content.Context
|
||||
import com.mogo.och.bus.passenger.constant.BusPassengerConst.Companion.getBaseUrl
|
||||
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.och.bus.passenger.bean.BusPassengerQueryLineRequest
|
||||
import com.mogo.och.bus.passenger.bean.BusPassengerOperationStatusResponse
|
||||
import com.mogo.eagle.core.network.MoGoRetrofitFactory
|
||||
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
|
||||
|
||||
/**
|
||||
* Created on 2022/3/31
|
||||
*/
|
||||
object BusPassengerServiceManager {
|
||||
|
||||
private var mBusPassengerServiceApi = MoGoRetrofitFactory.getInstance(getBaseUrl())
|
||||
.create(BusPassengerServiceApi::class.java)
|
||||
|
||||
/**
|
||||
* 获取Bus司机端的sn
|
||||
* @return
|
||||
*/
|
||||
private val driverAppSn: String
|
||||
get() = getServerToken()
|
||||
/**
|
||||
* 查询绑定行驶的小巴车路线
|
||||
* @param context
|
||||
* @param callback
|
||||
*/
|
||||
@JvmStatic
|
||||
fun queryDriverSiteByCoordinate(
|
||||
context: Context, callback: OchCommonServiceCallback<BusPassengerRoutesResponse>?
|
||||
) {
|
||||
mBusPassengerServiceApi.queryDriverSiteByCoordinate(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
MoGoAiCloudClientConfig.getInstance().token,
|
||||
BusPassengerQueryLineRequest(driverAppSn))
|
||||
.transformTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "queryDriverSiteByCoordinate"))
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询司机端出车收车状态,以及车牌号
|
||||
* @param context
|
||||
* @param callback
|
||||
*/
|
||||
@JvmStatic
|
||||
fun queryDriverOperationStatus(
|
||||
context: Context,
|
||||
callback: OchCommonServiceCallback<BusPassengerOperationStatusResponse>?) {
|
||||
mBusPassengerServiceApi.queryDriverOperationStatus(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
MoGoAiCloudClientConfig.getInstance().token,
|
||||
driverAppSn)
|
||||
.transformTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "queryDriverOperationStatus"))
|
||||
}
|
||||
}
|
||||
@@ -11,8 +11,8 @@ import com.mogo.och.bus.bean.BusQueryLinesResponse;
|
||||
import com.mogo.och.bus.bean.BusRoutesResponse;
|
||||
import com.mogo.och.bus.callback.IBusLinesCallback;
|
||||
import com.mogo.och.bus.net.BusServiceManager;
|
||||
import com.mogo.och.bus.net.IBusServiceCallback;
|
||||
import com.mogo.och.bus.ui.BusSwitchLineActivity;
|
||||
import com.mogo.och.common.module.biz.network.OchCommonServiceCallback;
|
||||
|
||||
/**
|
||||
* @author: wangmingjun
|
||||
@@ -42,7 +42,7 @@ public class BusLineModel {
|
||||
mBusLinesCallback = callback;
|
||||
}
|
||||
public void queryBusLines(){
|
||||
BusServiceManager.getInstance().queryBusLines(mContext, new IBusServiceCallback<BusQueryLinesResponse>() {
|
||||
BusServiceManager.queryBusLines(mContext, new OchCommonServiceCallback<BusQueryLinesResponse>() {
|
||||
@Override
|
||||
public void onSuccess(BusQueryLinesResponse data) {
|
||||
if (null == data && mBusLinesCallback != null) {
|
||||
@@ -56,7 +56,7 @@ public class BusLineModel {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFail(String failMsg) {
|
||||
public void onFail(int code, String failMsg) {
|
||||
if (!NetworkUtils.isConnected(mContext)) {
|
||||
ToastUtils.showShort("网络异常,请稍后重试");
|
||||
}else {
|
||||
@@ -72,7 +72,7 @@ public class BusLineModel {
|
||||
* @param position 位置
|
||||
*/
|
||||
public void queryBusLineTasksById(int lineId, int position,boolean autoRefresh){
|
||||
BusServiceManager.getInstance().queryBusTaskByLineId(mContext, String.valueOf(lineId),new IBusServiceCallback<BusQueryLineTaskResponse>() {
|
||||
BusServiceManager.queryBusTaskByLineId(mContext, String.valueOf(lineId),new OchCommonServiceCallback<BusQueryLineTaskResponse>() {
|
||||
@Override
|
||||
public void onSuccess(BusQueryLineTaskResponse data) {
|
||||
if (null == data && mBusLinesCallback != null) {
|
||||
@@ -86,7 +86,7 @@ public class BusLineModel {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFail(String failMsg) {
|
||||
public void onFail(int code, String failMsg) {
|
||||
if (!NetworkUtils.isConnected(mContext)) {
|
||||
ToastUtils.showShort("网络异常,请稍后重试");
|
||||
}else {
|
||||
@@ -97,7 +97,7 @@ public class BusLineModel {
|
||||
}
|
||||
|
||||
public void commitSwitchLineId(int taskId,int lineId){
|
||||
BusServiceManager.getInstance().switchLine(mContext,taskId, new IBusServiceCallback<BusRoutesResponse>() {
|
||||
BusServiceManager.switchLine(mContext,taskId, new OchCommonServiceCallback<BusRoutesResponse>() {
|
||||
@Override
|
||||
public void onSuccess(BusRoutesResponse o) {
|
||||
SharedPrefs.getInstance(mContext).putInt(BusSwitchLineActivity.LASTCOMMITLINEID,lineId);
|
||||
@@ -107,7 +107,7 @@ public class BusLineModel {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFail(String failMsg) {
|
||||
public void onFail(int code, String failMsg) {
|
||||
if (!NetworkUtils.isConnected(mContext)) {
|
||||
ToastUtils.showShort("网络异常,请稍后重试");
|
||||
}else {
|
||||
|
||||
@@ -47,11 +47,11 @@ import com.mogo.och.bus.callback.IRefreshBusStationsCallback;
|
||||
import com.mogo.och.bus.callback.ISlidePannelHideCallback;
|
||||
import com.mogo.och.bus.constant.BusConst;
|
||||
import com.mogo.och.bus.net.BusServiceManager;
|
||||
import com.mogo.och.bus.net.IBusServiceCallback;
|
||||
import com.mogo.och.bus.presenter.BusModelLoopManager;
|
||||
import com.mogo.och.bus.util.BusAnalyticsManager;
|
||||
import com.mogo.och.bus.util.BusTrajectoryManager;
|
||||
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.provider.LoginService;
|
||||
import com.mogo.och.common.module.manager.OCHAdasAbilityManager;
|
||||
import com.mogo.och.common.module.utils.CoordinateCalculateRouteUtil;
|
||||
@@ -254,15 +254,15 @@ public class BusOrderModel {
|
||||
BusStationBean currentStation = stationList.get( backgroundCurrentStationIndex);
|
||||
BusStationBean nextStation = stationList.get( backgroundCurrentStationIndex +1);
|
||||
|
||||
BusServiceManager.getInstance().updateOrderRoute(mContext, currentLineId, currentStation.getSiteId()
|
||||
, nextStation.getSiteId(), points, new IBusServiceCallback<BaseData>() {
|
||||
BusServiceManager.updateOrderRoute(mContext, currentLineId, currentStation.getSiteId()
|
||||
, nextStation.getSiteId(), points, new OchCommonServiceCallback<BaseData>() {
|
||||
@Override
|
||||
public void onSuccess(BaseData o) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFail(String failMsg) {
|
||||
public void onFail(int code, String failMsg) {
|
||||
if (isGoingToNextStation){//重试
|
||||
updateOrderRoute();
|
||||
}
|
||||
@@ -361,7 +361,7 @@ public class BusOrderModel {
|
||||
*/
|
||||
public void queryBusRoutes() {
|
||||
CallerLogger.INSTANCE.d(M_BUS + TAG, "查询小巴路线");
|
||||
BusServiceManager.getInstance().queryBusRoutes(mContext, new IBusServiceCallback<BusRoutesResponse>() {
|
||||
BusServiceManager.queryBusRoutes(mContext, new OchCommonServiceCallback<BusRoutesResponse>() {
|
||||
@Override
|
||||
public void onSuccess(BusRoutesResponse data) {
|
||||
if ( data == null
|
||||
@@ -382,7 +382,7 @@ public class BusOrderModel {
|
||||
updateBusStatus( data.getResult());
|
||||
}
|
||||
@Override
|
||||
public void onFail(String failMsg) {
|
||||
public void onFail(int code, String failMsg) {
|
||||
// 重复请求小巴路线,直至成功
|
||||
//改为任务,为空不再去一直取
|
||||
// queryBusStationDelay();
|
||||
@@ -448,8 +448,8 @@ public class BusOrderModel {
|
||||
*/
|
||||
public void abortTask() {
|
||||
CallerLogger.INSTANCE.d( M_BUS + TAG, "结束当前路线abortTask");
|
||||
BusServiceManager.getInstance().abortTask(mContext, currentTaskId
|
||||
, new IBusServiceCallback<BaseData>() {
|
||||
BusServiceManager.abortTask(mContext, currentTaskId
|
||||
, new OchCommonServiceCallback<BaseData>() {
|
||||
@Override
|
||||
public void onSuccess(BaseData o) {
|
||||
CallerLogger.INSTANCE.d(M_BUS + TAG, "abortTask success: " + o);
|
||||
@@ -461,7 +461,7 @@ public class BusOrderModel {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFail(String failMsg) {
|
||||
public void onFail(int code, String failMsg) {
|
||||
ToastUtils.showShort(failMsg);
|
||||
}
|
||||
});
|
||||
@@ -540,11 +540,11 @@ public class BusOrderModel {
|
||||
CallerLogger.INSTANCE.e( M_BUS + TAG, "数组越界" );
|
||||
return;
|
||||
}
|
||||
BusServiceManager.getInstance().queryStationWriteOffPassengers(mContext,
|
||||
BusServiceManager.queryStationWriteOffPassengers(mContext,
|
||||
currentTaskId,
|
||||
stationList.get(backgroundCurrentStationIndex).getSiteId(),
|
||||
prePassengerWriteOffTime,
|
||||
new IBusServiceCallback<BusQueryWriteOffPassengersResponse>(){
|
||||
new OchCommonServiceCallback<BusQueryWriteOffPassengersResponse>(){
|
||||
|
||||
@Override
|
||||
public void onSuccess(BusQueryWriteOffPassengersResponse o) {
|
||||
@@ -556,7 +556,7 @@ public class BusOrderModel {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFail(String failMsg) {
|
||||
public void onFail(int code, String failMsg) {
|
||||
|
||||
}
|
||||
});
|
||||
@@ -596,11 +596,11 @@ public class BusOrderModel {
|
||||
String arriveStation = stationList.get(arrivedStationIndex).getName();
|
||||
CallerLogger.INSTANCE.d(M_BUS + TAG,"arriveSiteStation-currentStationIndex = "+ arrivedStationIndex);
|
||||
|
||||
BusServiceManager.getInstance().arriveSiteStation(mContext ,
|
||||
BusServiceManager.arriveSiteStation(mContext ,
|
||||
stationList.get(arrivedStationIndex).getSeq(),
|
||||
stationList.get(arrivedStationIndex).getSiteId(),
|
||||
currentTaskId ,
|
||||
new IBusServiceCallback<BaseData>() {
|
||||
new OchCommonServiceCallback<BaseData>() {
|
||||
@Override
|
||||
public void onSuccess(BaseData o) {
|
||||
CallerLogger.INSTANCE.d(M_BUS + TAG,"arriveSiteStation success");
|
||||
@@ -615,7 +615,7 @@ public class BusOrderModel {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFail(String failMsg) {
|
||||
public void onFail(int code, String failMsg) {
|
||||
if (!NetworkUtils.isConnected(mContext)) {
|
||||
ToastUtils.showShort("网络异常,请稍后重试");
|
||||
}else {
|
||||
@@ -635,11 +635,11 @@ public class BusOrderModel {
|
||||
nextStationName = stationList.get(backgroundCurrentStationIndex + 1).getName();
|
||||
}
|
||||
String finalNextStationName = nextStationName;
|
||||
BusServiceManager.getInstance().leaveStation(mContext,
|
||||
BusServiceManager.leaveStation(mContext,
|
||||
stationList.get(backgroundCurrentStationIndex).getSeq(),
|
||||
stationList.get(backgroundCurrentStationIndex).getSiteId(),
|
||||
currentTaskId,
|
||||
new IBusServiceCallback<BaseData>() {
|
||||
new OchCommonServiceCallback<BaseData>() {
|
||||
@Override
|
||||
public void onSuccess(BaseData o) {
|
||||
isArrivedStation = false;
|
||||
@@ -651,7 +651,7 @@ public class BusOrderModel {
|
||||
queryBusRoutes();
|
||||
}
|
||||
@Override
|
||||
public void onFail(String failMsg) {
|
||||
public void onFail(int code, String failMsg) {
|
||||
if (!NetworkUtils.isConnected(mContext)) {
|
||||
ToastUtils.showShort("网络异常,请稍后重试");
|
||||
}else{
|
||||
@@ -831,8 +831,8 @@ public class BusOrderModel {
|
||||
*/
|
||||
private void endTask() {
|
||||
CallerLogger.INSTANCE.d( M_BUS + TAG, "任务正常走完endTask()");
|
||||
BusServiceManager.getInstance().endTask(mContext, currentTaskId
|
||||
, new IBusServiceCallback<BaseData>() {
|
||||
BusServiceManager.endTask(mContext, currentTaskId
|
||||
, new OchCommonServiceCallback<BaseData>() {
|
||||
@Override
|
||||
public void onSuccess(BaseData o) {
|
||||
CallerLogger.INSTANCE.d(M_BUS + TAG, "endTask success: " + o);
|
||||
@@ -846,7 +846,7 @@ public class BusOrderModel {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFail(String failMsg) {
|
||||
public void onFail(int code, String failMsg) {
|
||||
ToastUtils.showShort(failMsg);
|
||||
}
|
||||
});
|
||||
@@ -883,15 +883,15 @@ public class BusOrderModel {
|
||||
|
||||
// 车机端上传心跳数据(只在出车状态时上传)
|
||||
public void runCarHeartbeat() {
|
||||
BusServiceManager.getInstance().runCarHeartbeat(mContext, mLongitude, mLatitude,
|
||||
new IBusServiceCallback<BaseData>() {
|
||||
BusServiceManager.runCarHeartbeat(mContext, mLongitude, mLatitude,
|
||||
new OchCommonServiceCallback<BaseData>() {
|
||||
@Override
|
||||
public void onSuccess(BaseData data) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFail(String failMsg) {
|
||||
public void onFail(int code, String failMsg) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,270 +0,0 @@
|
||||
package com.mogo.och.bus.net;
|
||||
|
||||
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_BUS;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
|
||||
import com.mogo.eagle.core.data.BaseData;
|
||||
import com.mogo.eagle.core.network.MoGoRetrofitFactory;
|
||||
import com.mogo.eagle.core.network.RequestOptions;
|
||||
import com.mogo.eagle.core.network.SubscribeImpl;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.och.bus.bean.BusCloseTaskRequest;
|
||||
import com.mogo.och.bus.bean.BusQueryLineTaskResponse;
|
||||
import com.mogo.och.bus.bean.BusQueryLinesResponse;
|
||||
import com.mogo.och.bus.bean.BusQueryWriteOffPassengersResponse;
|
||||
import com.mogo.och.bus.bean.BusRoutePlanningUpdateReqBean;
|
||||
import com.mogo.och.bus.bean.BusRoutesResponse;
|
||||
import com.mogo.och.bus.bean.BusWriteOffPassengersQueryRequest;
|
||||
import com.mogo.och.bus.bean.CarHeartbeatReqBean;
|
||||
import com.mogo.och.bus.bean.BusOrdersResponse;
|
||||
import com.mogo.och.bus.bean.BusQueryLineStationsRequest;
|
||||
import com.mogo.och.bus.bean.BusResetDrivingLineRequest;
|
||||
import com.mogo.och.bus.bean.BusUpdateSiteStatusRequest;
|
||||
import com.mogo.och.bus.bean.QueryLeaveAwayPassengersRequest;
|
||||
import com.mogo.och.bus.bean.QueryLeaveAwayPassengersResponse;
|
||||
import com.mogo.och.bus.constant.BusConst;
|
||||
import com.mogo.och.bus.model.BusOrderModel;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
/**
|
||||
* @author: wangmingjun
|
||||
* @date: 2021/10/20
|
||||
*/
|
||||
public class BusServiceManager {
|
||||
|
||||
private static final String TAG = BusServiceManager.class.getSimpleName();
|
||||
|
||||
private final IBusApiService mService;
|
||||
|
||||
private static final class SingletonHolder {
|
||||
private static final BusServiceManager INSTANCE = new BusServiceManager();
|
||||
}
|
||||
|
||||
public static BusServiceManager getInstance(){
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private BusServiceManager(){
|
||||
mService = MoGoRetrofitFactory.getInstance(BusConst.getBaseUrl()).create(IBusApiService.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询小巴车当前任务
|
||||
* @param context
|
||||
* @param callback
|
||||
*/
|
||||
public void queryBusRoutes(Context context, IBusServiceCallback<BusRoutesResponse> callback) {
|
||||
//获取当前高德坐标
|
||||
|
||||
mService.queryBusRoutes(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
|
||||
,MoGoAiCloudClientConfig.getInstance().getToken()
|
||||
, new BusQueryLineStationsRequest())
|
||||
.subscribeOn( Schedulers.io() ).observeOn( AndroidSchedulers.mainThread() )
|
||||
.subscribe( getSubscribeImpl(context,callback,"queryBusRoutes"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置线路站点
|
||||
* @param context
|
||||
* @param taskId
|
||||
* @param callback
|
||||
*/
|
||||
public void switchLine(Context context, int taskId, IBusServiceCallback<BusRoutesResponse> callback){
|
||||
mService.switchLine(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
|
||||
,MoGoAiCloudClientConfig.getInstance().getToken(),new BusResetDrivingLineRequest(taskId))
|
||||
.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(getSubscribeImpl(context,callback,"switchLine"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 中断当前任务
|
||||
* @param context
|
||||
* @param taskId
|
||||
* @param callback
|
||||
*/
|
||||
public void abortTask(Context context, int taskId, IBusServiceCallback<BaseData> callback){
|
||||
mService.abortTask(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
|
||||
,MoGoAiCloudClientConfig.getInstance().getToken()
|
||||
,new BusCloseTaskRequest(taskId))
|
||||
.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(getSubscribeImpl(context,callback,"abortTask"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 正常结束任务
|
||||
* @param context
|
||||
* @param taskId
|
||||
* @param callback
|
||||
*/
|
||||
public void endTask(Context context, int taskId, IBusServiceCallback<BaseData> callback){
|
||||
mService.endTask(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
|
||||
,MoGoAiCloudClientConfig.getInstance().getToken()
|
||||
,new BusCloseTaskRequest(taskId))
|
||||
.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(getSubscribeImpl(context,callback,"endTask"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 离站上报
|
||||
* @param context
|
||||
* @param seq
|
||||
* @param siteId
|
||||
* @param callback
|
||||
*/
|
||||
public void leaveStation(Context context, int seq, int siteId,int taskId, IBusServiceCallback<BaseData> callback){
|
||||
mService.leaveStation(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
|
||||
,MoGoAiCloudClientConfig.getInstance().getToken()
|
||||
,new BusUpdateSiteStatusRequest(taskId,siteId,seq))
|
||||
.subscribeOn( Schedulers.io() )
|
||||
.observeOn( AndroidSchedulers.mainThread() )
|
||||
.subscribe(getSubscribeImpl(context,callback,"leaveStation"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 到站更新站点状态
|
||||
* @param context
|
||||
* @param seq
|
||||
* @param siteId
|
||||
* @param callback
|
||||
*/
|
||||
public void arriveSiteStation(Context context, int seq, int siteId,int taskId,
|
||||
IBusServiceCallback<BaseData> callback){
|
||||
mService.arriveSiteStation(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
|
||||
,MoGoAiCloudClientConfig.getInstance().getToken()
|
||||
,new BusUpdateSiteStatusRequest(taskId,siteId,seq))
|
||||
.subscribeOn( Schedulers.io() )
|
||||
.observeOn( AndroidSchedulers.mainThread() )
|
||||
.subscribe(getSubscribeImpl(context,callback,"arriveSiteStation"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询下车乘客
|
||||
* @param context
|
||||
* @param seq
|
||||
* @param siteId
|
||||
* @param callback
|
||||
*/
|
||||
public void queryStationLeaveAwayPassengers(Context context, int seq, int siteId
|
||||
, IBusServiceCallback<QueryLeaveAwayPassengersResponse> callback){
|
||||
mService.queryStationLeaveAwayPassengers( MoGoAiCloudClientConfig.getInstance().getServiceAppId()
|
||||
,MoGoAiCloudClientConfig.getInstance().getToken(),new QueryLeaveAwayPassengersRequest(seq,siteId))
|
||||
.subscribeOn( Schedulers.io() )
|
||||
.observeOn( AndroidSchedulers.mainThread() )
|
||||
.subscribe(getSubscribeImpl(context,callback,"queryStationLeaveAwayPassengers"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询当前到站点核销乘客
|
||||
* @param context
|
||||
* @param siteId
|
||||
* @param callback
|
||||
*/
|
||||
public void queryStationWriteOffPassengers(Context context,int taskId,int siteId,long prePassengerTime
|
||||
, IBusServiceCallback<BusQueryWriteOffPassengersResponse> callback){
|
||||
mService.queryWriteOffPassengers( MoGoAiCloudClientConfig.getInstance().getServiceAppId()
|
||||
,MoGoAiCloudClientConfig.getInstance().getToken()
|
||||
,new BusWriteOffPassengersQueryRequest(taskId,siteId,prePassengerTime))
|
||||
.subscribeOn( Schedulers.io() )
|
||||
.observeOn( AndroidSchedulers.mainThread() )
|
||||
.subscribe(getSubscribeImpl(context,callback,"queryStationWriteOffPassengers"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 查询小巴车订单
|
||||
* @param context
|
||||
* @param callback
|
||||
*/
|
||||
public void queryBusOrders(Context context, IBusServiceCallback<BusOrdersResponse> callback){
|
||||
mService.queryBusOrders(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
|
||||
,MoGoAiCloudClientConfig.getInstance().getToken(),MoGoAiCloudClientConfig.getInstance().getSn())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(getSubscribeImpl(context,callback,"queryBusOrders"));
|
||||
}
|
||||
|
||||
public void queryBusLines(Context context, IBusServiceCallback<BusQueryLinesResponse> callback){
|
||||
mService.queryBusLines(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
|
||||
,MoGoAiCloudClientConfig.getInstance().getToken()
|
||||
,MoGoAiCloudClientConfig.getInstance().getSn())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(getSubscribeImpl(context,callback,"queryBusLines"));
|
||||
}
|
||||
|
||||
public void queryBusTaskByLineId(Context context,String lineId,IBusServiceCallback<BusQueryLineTaskResponse> callback){
|
||||
mService.queryBusTaskByLineId(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
|
||||
,MoGoAiCloudClientConfig.getInstance().getToken()
|
||||
,lineId)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(getSubscribeImpl(context,callback,"queryBusLines"));
|
||||
}
|
||||
|
||||
public void updateOrderRoute(Context context,int lineId, int startSiteId, int endSiteId
|
||||
, List< BusRoutePlanningUpdateReqBean.Result > points
|
||||
, IBusServiceCallback<BaseData> callback){
|
||||
mService.updateOrderRoute(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
|
||||
,MoGoAiCloudClientConfig.getInstance().getToken()
|
||||
,new BusRoutePlanningUpdateReqBean(MoGoAiCloudClientConfig.getInstance().getSn()
|
||||
,lineId,startSiteId,endSiteId, points))
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(getSubscribeImpl(context,callback,"updateOrderRoute"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 车机端上传心跳数据(只在出车状态时上传):包含高德坐标系经纬度
|
||||
* @param context
|
||||
* @param lon
|
||||
* @param lat
|
||||
* @param callback
|
||||
*/
|
||||
public void runCarHeartbeat(Context context, double lon, double lat,
|
||||
IBusServiceCallback<BaseData> callback) {
|
||||
mService.runCarHeartbeat(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
|
||||
,MoGoAiCloudClientConfig.getInstance().getToken(),new CarHeartbeatReqBean(
|
||||
MoGoAiCloudClientConfig.getInstance().getSn(), lon, lat))
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(getSubscribeImpl(context, callback, "runCarHeartbeat"));
|
||||
}
|
||||
|
||||
private <T extends BaseData> SubscribeImpl getSubscribeImpl(Context context, IBusServiceCallback<T> callback, String apiName){
|
||||
return new SubscribeImpl<T>(RequestOptions.create(context)){
|
||||
@Override
|
||||
public void onSuccess(T o) {
|
||||
super.onSuccess(o);
|
||||
CallerLogger.INSTANCE.e(M_BUS + TAG,apiName + ": onSuccess() " + o.msg);
|
||||
if (callback != null) {
|
||||
callback.onSuccess(o);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String message, int code) {
|
||||
super.onError(message, code);
|
||||
CallerLogger.INSTANCE.e(M_BUS + TAG,apiName + ": onError() " +"msg="+ message+" code="+code);
|
||||
if (callback != null) {
|
||||
callback.onFail("msg="+ message+" code="+code);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
super.onError(e);
|
||||
CallerLogger.INSTANCE.e(M_BUS + TAG,apiName + ": onError() " +" e="+e.getMessage());
|
||||
if (callback != null) {
|
||||
callback.onFail(e.getMessage());
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,268 @@
|
||||
package com.mogo.och.bus.net
|
||||
|
||||
import android.content.Context
|
||||
import com.mogo.och.bus.constant.BusConst.Companion.getBaseUrl
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig
|
||||
import com.mogo.eagle.core.data.BaseData
|
||||
import com.mogo.eagle.core.network.MoGoRetrofitFactory
|
||||
import com.mogo.och.bus.bean.*
|
||||
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
|
||||
|
||||
/**
|
||||
* @author: wangmingjun
|
||||
* @date: 2021/10/20
|
||||
*/
|
||||
object BusServiceManager {
|
||||
|
||||
private val mService: IBusApiService = MoGoRetrofitFactory.getInstance(getBaseUrl()).create(
|
||||
IBusApiService::class.java
|
||||
)
|
||||
|
||||
/**
|
||||
* 查询小巴车当前任务
|
||||
* @param context
|
||||
* @param callback
|
||||
*/
|
||||
@JvmStatic
|
||||
fun queryBusRoutes(context: Context, callback: OchCommonServiceCallback<BusRoutesResponse>?) {
|
||||
//获取当前高德坐标
|
||||
mService.queryBusRoutes(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
MoGoAiCloudClientConfig.getInstance().token,
|
||||
BusQueryLineStationsRequest()
|
||||
)
|
||||
.transformTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "queryBusRoutes"))
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置线路站点
|
||||
* @param context
|
||||
* @param taskId
|
||||
* @param callback
|
||||
*/
|
||||
@JvmStatic
|
||||
fun switchLine(
|
||||
context: Context,
|
||||
taskId: Int,
|
||||
callback: OchCommonServiceCallback<BusRoutesResponse>?
|
||||
) {
|
||||
mService.switchLine(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
MoGoAiCloudClientConfig.getInstance().token,
|
||||
BusResetDrivingLineRequest(taskId)
|
||||
)
|
||||
.transformTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "switchLine"))
|
||||
}
|
||||
|
||||
/**
|
||||
* 中断当前任务
|
||||
* @param context
|
||||
* @param taskId
|
||||
* @param callback
|
||||
*/
|
||||
@JvmStatic
|
||||
fun abortTask(context: Context, taskId: Int, callback: OchCommonServiceCallback<BaseData>?) {
|
||||
mService.abortTask(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
MoGoAiCloudClientConfig.getInstance().token,
|
||||
BusCloseTaskRequest(taskId)
|
||||
)
|
||||
.transformTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "abortTask"))
|
||||
}
|
||||
|
||||
/**
|
||||
* 正常结束任务
|
||||
* @param context
|
||||
* @param taskId
|
||||
* @param callback
|
||||
*/
|
||||
@JvmStatic
|
||||
fun endTask(context: Context, taskId: Int, callback: OchCommonServiceCallback<BaseData>?) {
|
||||
mService.endTask(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
MoGoAiCloudClientConfig.getInstance().token,
|
||||
BusCloseTaskRequest(taskId)
|
||||
)
|
||||
.transformTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "endTask"))
|
||||
}
|
||||
|
||||
/**
|
||||
* 离站上报
|
||||
* @param context
|
||||
* @param seq
|
||||
* @param siteId
|
||||
* @param callback
|
||||
*/
|
||||
@JvmStatic
|
||||
fun leaveStation(
|
||||
context: Context,
|
||||
seq: Int,
|
||||
siteId: Int,
|
||||
taskId: Int,
|
||||
callback: OchCommonServiceCallback<BaseData>?
|
||||
) {
|
||||
mService.leaveStation(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
MoGoAiCloudClientConfig.getInstance().token,
|
||||
BusUpdateSiteStatusRequest(taskId, siteId, seq)
|
||||
)
|
||||
.transformTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "leaveStation"))
|
||||
}
|
||||
|
||||
/**
|
||||
* 到站更新站点状态
|
||||
* @param context
|
||||
* @param seq
|
||||
* @param siteId
|
||||
* @param callback
|
||||
*/
|
||||
@JvmStatic
|
||||
fun arriveSiteStation(
|
||||
context: Context, seq: Int, siteId: Int, taskId: Int,
|
||||
callback: OchCommonServiceCallback<BaseData>?
|
||||
) {
|
||||
mService.arriveSiteStation(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
MoGoAiCloudClientConfig.getInstance().token,
|
||||
BusUpdateSiteStatusRequest(taskId, siteId, seq)
|
||||
)
|
||||
.transformTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "arriveSiteStation"))
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询下车乘客
|
||||
* @param context
|
||||
* @param seq
|
||||
* @param siteId
|
||||
* @param callback
|
||||
*/
|
||||
@JvmStatic
|
||||
fun queryStationLeaveAwayPassengers(
|
||||
context: Context,
|
||||
seq: Int,
|
||||
siteId: Int,
|
||||
callback: OchCommonServiceCallback<QueryLeaveAwayPassengersResponse>?
|
||||
) {
|
||||
mService.queryStationLeaveAwayPassengers(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
MoGoAiCloudClientConfig.getInstance().token,
|
||||
QueryLeaveAwayPassengersRequest(seq, siteId)
|
||||
)
|
||||
.transformTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "queryStationLeaveAwayPassengers"))
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询当前到站点核销乘客
|
||||
* @param context
|
||||
* @param siteId
|
||||
* @param callback
|
||||
*/
|
||||
@JvmStatic
|
||||
fun queryStationWriteOffPassengers(
|
||||
context: Context,
|
||||
taskId: Int,
|
||||
siteId: Int,
|
||||
prePassengerTime: Long,
|
||||
callback: OchCommonServiceCallback<BusQueryWriteOffPassengersResponse>?
|
||||
) {
|
||||
mService.queryWriteOffPassengers(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
MoGoAiCloudClientConfig.getInstance().token,
|
||||
BusWriteOffPassengersQueryRequest(taskId, siteId, prePassengerTime)
|
||||
)
|
||||
.transformTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "queryStationWriteOffPassengers"))
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询小巴车订单
|
||||
* @param context
|
||||
* @param callback
|
||||
*/
|
||||
@JvmStatic
|
||||
fun queryBusOrders(context: Context, callback: OchCommonServiceCallback<BusOrdersResponse>?) {
|
||||
mService.queryBusOrders(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
MoGoAiCloudClientConfig.getInstance().token,
|
||||
MoGoAiCloudClientConfig.getInstance().sn
|
||||
)
|
||||
.transformTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "queryBusOrders"))
|
||||
}
|
||||
@JvmStatic
|
||||
fun queryBusLines(context: Context, callback: OchCommonServiceCallback<BusQueryLinesResponse>?) {
|
||||
mService.queryBusLines(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
MoGoAiCloudClientConfig.getInstance().token,
|
||||
MoGoAiCloudClientConfig.getInstance().sn
|
||||
)
|
||||
.transformTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "queryBusLines"))
|
||||
}
|
||||
@JvmStatic
|
||||
fun queryBusTaskByLineId(
|
||||
context: Context,
|
||||
lineId: String?,
|
||||
callback: OchCommonServiceCallback<BusQueryLineTaskResponse>?
|
||||
) {
|
||||
mService.queryBusTaskByLineId(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
MoGoAiCloudClientConfig.getInstance().token,
|
||||
lineId
|
||||
)
|
||||
.transformTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "queryBusLines"))
|
||||
}
|
||||
@JvmStatic
|
||||
fun updateOrderRoute(
|
||||
context: Context,
|
||||
lineId: Int,
|
||||
startSiteId: Int,
|
||||
endSiteId: Int,
|
||||
points: List<BusRoutePlanningUpdateReqBean.Result?>?,
|
||||
callback: OchCommonServiceCallback<BaseData>?
|
||||
) {
|
||||
mService.updateOrderRoute(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
MoGoAiCloudClientConfig.getInstance().token,
|
||||
BusRoutePlanningUpdateReqBean(
|
||||
MoGoAiCloudClientConfig.getInstance().sn, lineId, startSiteId, endSiteId, points
|
||||
)
|
||||
)
|
||||
.transformTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "updateOrderRoute"))
|
||||
}
|
||||
|
||||
/**
|
||||
* 车机端上传心跳数据(只在出车状态时上传):包含高德坐标系经纬度
|
||||
* @param context
|
||||
* @param lon
|
||||
* @param lat
|
||||
* @param callback
|
||||
*/
|
||||
@JvmStatic
|
||||
fun runCarHeartbeat(
|
||||
context: Context, lon: Double, lat: Double,
|
||||
callback: OchCommonServiceCallback<BaseData>?
|
||||
) {
|
||||
mService.runCarHeartbeat(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
MoGoAiCloudClientConfig.getInstance().token,
|
||||
CarHeartbeatReqBean(
|
||||
MoGoAiCloudClientConfig.getInstance().sn, lon, lat
|
||||
)
|
||||
)
|
||||
.transformTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "runCarHeartbeat"))
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package com.mogo.och.bus.net;
|
||||
|
||||
/**
|
||||
* @author: wangmingjun
|
||||
* @date: 2021/10/20
|
||||
*/
|
||||
public interface IBusServiceCallback< T >{
|
||||
void onSuccess(T o);
|
||||
|
||||
void onFail(String failMsg);
|
||||
|
||||
default void onError() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -10,58 +10,9 @@ class SimpleInterceptor: Interceptor {
|
||||
val encodedPath = original.url().encodedPath()
|
||||
Log.e("SimpleInterceptor",original.method()+ encodedPath+original.url().encodedQuery())
|
||||
when (encodedPath) {
|
||||
"/autopilot-car-hailing/operation/v1/driver/bus/loginStatus" -> {
|
||||
val builder = Response.Builder()
|
||||
val create:ResponseBody
|
||||
if(first) {
|
||||
create = ResponseBody.create(
|
||||
MediaType.parse("application/json"),
|
||||
"{\"code\":0,\"msg\":\"\",\"data\":{\"servingStatus\":0,\"driverStatus\":1,\"orderNo\":\"12111\",\"purpose\":1,\"sn\":\"fjsdlfjslf\",\"plateNumber\":\"车牌号\",\"phone\":\"18811539480\",\"lineId\":\"线路id\",\"taskId\":\"任务id\"}}"
|
||||
)
|
||||
first = false
|
||||
}else{
|
||||
create = ResponseBody.create(
|
||||
MediaType.parse("application/json"),
|
||||
"{\"code\":0,\"msg\":\"\",\"data\":{\"servingStatus\":0,\"driverStatus\":0,\"orderNo\":\"12111\",\"purpose\":1,\"sn\":\"fjsdlfjslf\",\"plateNumber\":\"车牌号\",\"phone\":\"18811539480\",\"lineId\":\"线路id\",\"taskId\":\"任务id\"}}"
|
||||
)
|
||||
first = true
|
||||
}
|
||||
builder.code(200)
|
||||
builder.request(original)
|
||||
builder.protocol(Protocol.HTTP_1_1)
|
||||
builder.message("")
|
||||
return builder.body(create).build()
|
||||
}
|
||||
"/autopilot-car-hailing/line/v2/driver/bus/task/query" -> {
|
||||
val builder = Response.Builder()
|
||||
val create = ResponseBody.create(MediaType.parse("application/json"), "{\"code\":0,\"msg\":\"\",\"data\":[{\"id\":1,\"taskStartTime\":1663722000000},{\"id\":2,\"taskStartTime\":1663725600000},{\"id\":3,\"taskStartTime\":1663729200000},{\"id\":4,\"taskStartTime\":1663732800000},{\"id\":5,\"taskStartTime\":1663736400000},{\"id\":6,\"taskStartTime\":1663740000000},{\"id\":7,\"taskStartTime\":1663743600000},{\"id\":8,\"taskStartTime\":1663747200000},{\"id\":9,\"taskStartTime\":1663750800000},{\"id\":10,\"taskStartTime\":1663754400000}]}")
|
||||
builder.code(200)
|
||||
builder.request(original)
|
||||
builder.protocol(Protocol.HTTP_1_1)
|
||||
builder.message("")
|
||||
return builder.body(create).build()
|
||||
}
|
||||
"/autopilot-car-hailing/cab/flow/v1/bus/driver/bus/startTask" -> {
|
||||
val builder = Response.Builder()
|
||||
val create = ResponseBody.create(MediaType.parse("application/json"), "{\"code\":0,\"msg\":\"\",\"data\":null}")
|
||||
builder.code(200)
|
||||
builder.request(original)
|
||||
builder.protocol(Protocol.HTTP_1_1)
|
||||
builder.message("")
|
||||
return builder.body(create).build()
|
||||
}
|
||||
"/autopilot-car-hailing/cab/flow/v1/bus/driver/bus/endOperation" -> {
|
||||
val builder = Response.Builder()
|
||||
val create = ResponseBody.create(MediaType.parse("application/json"), "{\"code\":0,\"msg\":\"\",\"data\":null}")
|
||||
builder.code(200)
|
||||
builder.request(original)
|
||||
builder.protocol(Protocol.HTTP_1_1)
|
||||
builder.message("")
|
||||
return builder.body(create).build()
|
||||
}
|
||||
"/autopilot-car-hailing/cab/flow/v1/bus/driver/bus/startOperation" -> {
|
||||
val builder = Response.Builder()
|
||||
val create = ResponseBody.create(MediaType.parse("application/json"), "{\"code\":0,\"msg\":\"\",\"data\":null}")
|
||||
val create = ResponseBody.create(MediaType.parse("application/json"), "{\"code\":100006,\"msg\":\"\",\"data\":null}")
|
||||
builder.code(200)
|
||||
builder.request(original)
|
||||
builder.protocol(Protocol.HTTP_1_1)
|
||||
|
||||
@@ -71,66 +71,70 @@ object OchCommonLoginModel{
|
||||
* 获取手机验证码
|
||||
*/
|
||||
fun getPhoneCode(phone: String?) {
|
||||
OchCommonServiceManager.getInstance().getPhoneCode(mContext, phone,
|
||||
object : OchCommonServiceCallback<BaseData?> {
|
||||
override fun onSuccess(data: BaseData?) {
|
||||
if (null != data && 0 == data.code) {
|
||||
// 获取验证码成功
|
||||
ToastUtils.showShort(mContext?.getString(R.string.module_och_taxi_login_get_code_success))
|
||||
iTaxiLoginCallback?.getPhoneCodeSuccess()
|
||||
} else {
|
||||
if (data != null) {
|
||||
ToastUtils.showShort(data.code)
|
||||
mContext?.let {
|
||||
OchCommonServiceManager.getPhoneCode(it, phone,
|
||||
object : OchCommonServiceCallback<BaseData> {
|
||||
override fun onSuccess(data: BaseData?) {
|
||||
if (null != data && 0 == data.code) {
|
||||
// 获取验证码成功
|
||||
ToastUtils.showShort(mContext?.getString(R.string.module_och_taxi_login_get_code_success))
|
||||
iTaxiLoginCallback?.getPhoneCodeSuccess()
|
||||
} else {
|
||||
if (data != null) {
|
||||
ToastUtils.showShort(data.code)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onError() {
|
||||
if (!NetworkUtils.isConnected(mContext)) {
|
||||
ToastUtils.showShort(mContext?.getString(R.string.network_error_tip))
|
||||
} else {
|
||||
ToastUtils.showShort(mContext?.getString(R.string.request_error_tip))
|
||||
override fun onError() {
|
||||
if (!NetworkUtils.isConnected(mContext)) {
|
||||
ToastUtils.showShort(mContext?.getString(R.string.network_error_tip))
|
||||
} else {
|
||||
ToastUtils.showShort(mContext?.getString(R.string.request_error_tip))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onFail(code: Int, msg: String) {
|
||||
ToastUtilsOch.showWithCodeMessage(code,msg)
|
||||
}
|
||||
})
|
||||
override fun onFail(code: Int, msg: String) {
|
||||
ToastUtilsOch.showWithCodeMessage(code,msg)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fun gotoLogin(phone: String, code: String) {
|
||||
val location4Login = TaxiLoginReqBean.Location4Login(mLatitude, mLongitude)
|
||||
OchCommonServiceManager.getInstance().gotoLoginBycode(mContext, phone, code, location4Login,
|
||||
object : OchCommonServiceCallback<TaxiLoginRespBean?> {
|
||||
override fun onSuccess(data: TaxiLoginRespBean?) {
|
||||
if (null != data && 0 == data.code) {
|
||||
// 获取验证码成功
|
||||
ToastUtils.showShort(mContext?.getString(R.string.module_och_taxi_login_login_success))
|
||||
LoginStatusManager.setLoginStatus(TaxiLoginStatusEnum.Login)
|
||||
mContext?.let {
|
||||
SharedPrefs.getInstance(it).putString("och_account",phone)
|
||||
}
|
||||
iTaxiLoginCallback?.loginSuccess()
|
||||
} else {
|
||||
if (data != null) {
|
||||
ToastUtils.showShort(data.code)
|
||||
mContext?.let {
|
||||
val location4Login = TaxiLoginReqBean.Location4Login(mLatitude, mLongitude)
|
||||
OchCommonServiceManager.gotoLoginBycode(it, phone, code, location4Login,
|
||||
object : OchCommonServiceCallback<TaxiLoginRespBean> {
|
||||
override fun onSuccess(data: TaxiLoginRespBean?) {
|
||||
if (null != data && 0 == data.code) {
|
||||
// 获取验证码成功
|
||||
ToastUtils.showShort(mContext?.getString(R.string.module_och_taxi_login_login_success))
|
||||
LoginStatusManager.setLoginStatus(TaxiLoginStatusEnum.Login)
|
||||
mContext?.let {
|
||||
SharedPrefs.getInstance(it).putString("och_account",phone)
|
||||
}
|
||||
iTaxiLoginCallback?.loginSuccess()
|
||||
} else {
|
||||
if (data != null) {
|
||||
ToastUtils.showShort(data.code)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onError() {
|
||||
if (!NetworkUtils.isConnected(mContext)) {
|
||||
ToastUtils.showShort(mContext?.getString(R.string.network_error_tip))
|
||||
} else {
|
||||
ToastUtils.showShort(mContext?.getString(R.string.request_error_tip))
|
||||
override fun onError() {
|
||||
if (!NetworkUtils.isConnected(mContext)) {
|
||||
ToastUtils.showShort(mContext?.getString(R.string.network_error_tip))
|
||||
} else {
|
||||
ToastUtils.showShort(mContext?.getString(R.string.request_error_tip))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onFail(code: Int, msg: String) {
|
||||
ToastUtilsOch.showWithCodeMessage(code,msg)
|
||||
}
|
||||
})
|
||||
override fun onFail(code: Int, msg: String) {
|
||||
ToastUtilsOch.showWithCodeMessage(code,msg)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -53,7 +53,7 @@ public abstract class OchCommonLoginStatusModel {
|
||||
* 8、登录页面关闭后查下状态
|
||||
*/
|
||||
public void queryCarStatus() {
|
||||
OchCommonServiceManager.getInstance().queryDriverServiceStatus(mContext,
|
||||
OchCommonServiceManager.queryDriverServiceStatus(mContext,
|
||||
new OchCommonServiceCallback<DriverStatusQueryRespBean>() {
|
||||
@Override
|
||||
public void onSuccess(DriverStatusQueryRespBean data) {
|
||||
@@ -93,7 +93,7 @@ public abstract class OchCommonLoginStatusModel {
|
||||
// 登出
|
||||
public void logout(double mLatitude,double mLongitude) {
|
||||
TaxiLogoutReqBean.Location4Login location4Login = new TaxiLogoutReqBean.Location4Login(mLatitude, mLongitude);
|
||||
OchCommonServiceManager.getInstance().logout(mContext,location4Login,
|
||||
OchCommonServiceManager.logout(mContext,location4Login,
|
||||
new OchCommonServiceCallback<BaseData>() {
|
||||
@Override
|
||||
public void onSuccess(BaseData data) {
|
||||
|
||||
@@ -1,187 +0,0 @@
|
||||
package com.mogo.och.common.module.biz.network;
|
||||
|
||||
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_TAXI;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClient;
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.eagle.core.data.BaseData;
|
||||
import com.mogo.eagle.core.network.MoGoRetrofitFactory;
|
||||
import com.mogo.eagle.core.network.RequestOptions;
|
||||
import com.mogo.eagle.core.network.SubscribeImpl;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.och.common.module.biz.bean.DriverStatusQueryRespBean;
|
||||
import com.mogo.och.common.module.biz.bean.TaxiLoginReqBean;
|
||||
import com.mogo.och.common.module.biz.bean.TaxiLoginRespBean;
|
||||
import com.mogo.och.common.module.biz.bean.TaxiLoginSmsReqBean;
|
||||
import com.mogo.och.common.module.biz.bean.TaxiLogoutReqBean;
|
||||
import com.mogo.och.common.module.biz.constant.OchCommonConst;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
/**
|
||||
* Created by pangfan on 2021/8/19
|
||||
*/
|
||||
public class OchCommonServiceManager {
|
||||
private static final String TAG = OchCommonServiceManager.class.getSimpleName();
|
||||
|
||||
private static final class SingletonHolder {
|
||||
private static final OchCommonServiceManager INSTANCE = new OchCommonServiceManager();
|
||||
}
|
||||
|
||||
public static OchCommonServiceManager getInstance() {
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private OchCommonServiceApiNew mOCHTaxiServiceApi;
|
||||
|
||||
private OchCommonServiceManager() {
|
||||
if (mOCHTaxiServiceApi == null){
|
||||
mOCHTaxiServiceApi = MoGoRetrofitFactory.getInstance(OchCommonConst.getBaseUrl()).create(OchCommonServiceApiNew.class);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取手机验证码
|
||||
* @param context
|
||||
* @param callback
|
||||
*/
|
||||
public void getPhoneCode(Context context, String phone,
|
||||
OchCommonServiceCallback<BaseData> callback) {
|
||||
mOCHTaxiServiceApi.getPhoneCode(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
|
||||
, MoGoAiCloudClientConfig.getInstance().getToken()
|
||||
, new TaxiLoginSmsReqBean(phone))
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(getSubscribeImpl(context, callback, "getPhoneCode"));
|
||||
}
|
||||
/**
|
||||
* 通过验证码登录
|
||||
* @param context
|
||||
* @param callback
|
||||
*/
|
||||
public void gotoLoginBycode(Context context, String phone, String code,
|
||||
TaxiLoginReqBean.Location4Login location4Login,
|
||||
OchCommonServiceCallback<TaxiLoginRespBean> callback) {
|
||||
String sn = MoGoAiCloudClientConfig.getInstance().getSn();
|
||||
Observable<TaxiLoginRespBean> taxiLoginRespBeanObservable = null;
|
||||
switch (DebugConfig.getProductFlavor()) {
|
||||
case "fPadLenovoOchTaxi": {//出租车司机
|
||||
taxiLoginRespBeanObservable = mOCHTaxiServiceApi.gotoLoginBycode4Taxi(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
|
||||
, MoGoAiCloudClientConfig.getInstance().getToken()
|
||||
, new TaxiLoginReqBean(phone, code, sn, location4Login));
|
||||
break;
|
||||
}
|
||||
case "fPadLenovoOchBus": {//小巴车司机
|
||||
taxiLoginRespBeanObservable = mOCHTaxiServiceApi.gotoLoginBycode4Bus(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
|
||||
, MoGoAiCloudClientConfig.getInstance().getToken()
|
||||
, new TaxiLoginReqBean(phone, code, sn, location4Login));
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (taxiLoginRespBeanObservable != null) {
|
||||
taxiLoginRespBeanObservable.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(getSubscribeImpl(context, callback, "gotoLoginBycode"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 登出
|
||||
*/
|
||||
public void logout(Context context, TaxiLogoutReqBean.Location4Login location4Login, OchCommonServiceCallback<BaseData> callback) {
|
||||
Observable<BaseData> logout = null;
|
||||
switch (DebugConfig.getProductFlavor()) {
|
||||
case "fPadLenovoOchTaxi": {//出租车司机
|
||||
logout = mOCHTaxiServiceApi.logout4Taxi(
|
||||
MoGoAiCloudClientConfig.getInstance().getServiceAppId(),
|
||||
MoGoAiCloudClientConfig.getInstance().getToken(),
|
||||
new TaxiLogoutReqBean(MoGoAiCloudClientConfig.getInstance().getSn(), location4Login));
|
||||
break;
|
||||
}
|
||||
case "fPadLenovoOchBus": {//小巴车司机
|
||||
logout = mOCHTaxiServiceApi.logout4Bus(
|
||||
MoGoAiCloudClientConfig.getInstance().getServiceAppId(),
|
||||
MoGoAiCloudClientConfig.getInstance().getToken(),
|
||||
new TaxiLogoutReqBean(MoGoAiCloudClientConfig.getInstance().getSn(), location4Login));
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (logout != null) {
|
||||
logout.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(getSubscribeImpl(context, callback, "logout"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 接单状态和登录状态查询
|
||||
*
|
||||
* @param context
|
||||
* @param callback
|
||||
*/
|
||||
public void queryDriverServiceStatus(Context context,
|
||||
OchCommonServiceCallback<DriverStatusQueryRespBean> callback) {
|
||||
if (MoGoAiCloudClientConfig.getInstance().getToken().isEmpty()) {
|
||||
callback.onFail(OchCommonConst.WAIT_TAKEN, "等待令牌中请稍等");
|
||||
MoGoAiCloudClient.getInstance().refreshToken();
|
||||
return;
|
||||
}
|
||||
String flavor = "";
|
||||
switch (DebugConfig.getProductFlavor()) {
|
||||
case "fPadLenovoOchTaxi": {//出租车司机
|
||||
flavor = "taxi";
|
||||
break;
|
||||
}
|
||||
case "fPadLenovoOchBus": {//小巴车司机
|
||||
flavor = "bus";
|
||||
break;
|
||||
}
|
||||
case "fPadLenovoOchBusPassenger": {//小巴车乘客
|
||||
flavor = "bus/passenger";
|
||||
break;
|
||||
}
|
||||
}
|
||||
mOCHTaxiServiceApi.queryDriverServiceStatusAndLoginStatus(flavor, MoGoAiCloudClientConfig.getInstance().getServiceAppId()
|
||||
, MoGoAiCloudClientConfig.getInstance().getToken()
|
||||
, MoGoAiCloudClientConfig.getInstance().getSn())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(getSubscribeImpl(context, callback, "queryDriverServiceStatus"));
|
||||
}
|
||||
|
||||
|
||||
private <T extends BaseData> SubscribeImpl getSubscribeImpl(
|
||||
Context context, OchCommonServiceCallback<T> callback, String apiName) {
|
||||
return new SubscribeImpl<T>(RequestOptions.create(context)) {
|
||||
@Override
|
||||
public void onSuccess(T o) {
|
||||
super.onSuccess(o);
|
||||
CallerLogger.INSTANCE.d(M_TAXI + TAG, apiName + ": onSuccess() " + o.msg);
|
||||
if (callback != null) {
|
||||
callback.onSuccess(o);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
super.onError(e);
|
||||
CallerLogger.INSTANCE.e(M_TAXI + TAG, apiName + ": onError() " + e.getMessage());
|
||||
if (callback != null) {
|
||||
callback.onError();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String message, int code) {
|
||||
super.onError(message, code);
|
||||
CallerLogger.INSTANCE.e(M_TAXI + TAG, String.format(apiName + ": onError() code = %d; message = %s;", code, message));
|
||||
if (callback != null) {
|
||||
callback.onFail(code, message);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
package com.mogo.och.common.module.biz.network
|
||||
|
||||
import android.content.Context
|
||||
import com.mogo.och.common.module.biz.constant.OchCommonConst.Companion.getBaseUrl
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig
|
||||
import com.mogo.och.common.module.biz.bean.TaxiLoginSmsReqBean
|
||||
import com.mogo.och.common.module.biz.bean.TaxiLoginReqBean
|
||||
import com.mogo.och.common.module.biz.bean.TaxiLoginRespBean
|
||||
import com.mogo.och.common.module.biz.bean.TaxiLogoutReqBean
|
||||
import com.mogo.och.common.module.biz.bean.DriverStatusQueryRespBean
|
||||
import com.mogo.och.common.module.biz.constant.OchCommonConst
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClient
|
||||
import com.mogo.commons.debug.DebugConfig
|
||||
import com.mogo.eagle.core.data.BaseData
|
||||
import com.mogo.eagle.core.network.MoGoRetrofitFactory
|
||||
import com.mogo.och.common.module.biz.network.interceptor.transformTry
|
||||
import io.reactivex.Observable
|
||||
|
||||
/**
|
||||
* Created by pangfan on 2021/8/19
|
||||
*/
|
||||
object OchCommonServiceManager {
|
||||
|
||||
private const val TAG = "OchCommonServiceManager"
|
||||
|
||||
private val mOCHTaxiServiceApi: OchCommonServiceApiNew =
|
||||
MoGoRetrofitFactory.getInstance(getBaseUrl()).create(
|
||||
OchCommonServiceApiNew::class.java
|
||||
)
|
||||
|
||||
/**
|
||||
* 获取手机验证码
|
||||
* @param context
|
||||
* @param callback
|
||||
*/
|
||||
@JvmStatic
|
||||
fun getPhoneCode(
|
||||
context: Context, phone: String?,
|
||||
callback: OchCommonServiceCallback<BaseData>?
|
||||
) {
|
||||
mOCHTaxiServiceApi.getPhoneCode(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
MoGoAiCloudClientConfig.getInstance().token,
|
||||
TaxiLoginSmsReqBean(phone)
|
||||
).transformTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "getPhoneCode"))
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过验证码登录
|
||||
* @param context
|
||||
* @param callback
|
||||
*/
|
||||
@JvmStatic
|
||||
fun gotoLoginBycode(
|
||||
context: Context, phone: String?, code: String?,
|
||||
location4Login: TaxiLoginReqBean.Location4Login?,
|
||||
callback: OchCommonServiceCallback<TaxiLoginRespBean>?
|
||||
) {
|
||||
val sn = MoGoAiCloudClientConfig.getInstance().sn
|
||||
var taxiLoginRespBeanObservable: Observable<TaxiLoginRespBean>? = null
|
||||
when (DebugConfig.getProductFlavor()) {
|
||||
"fPadLenovoOchTaxi" -> {
|
||||
//出租车司机
|
||||
taxiLoginRespBeanObservable = mOCHTaxiServiceApi.gotoLoginBycode4Taxi(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
MoGoAiCloudClientConfig.getInstance().token,
|
||||
TaxiLoginReqBean(phone, code, sn, location4Login)
|
||||
).transformTry()
|
||||
}
|
||||
"fPadLenovoOchBus" -> {
|
||||
//小巴车司机
|
||||
taxiLoginRespBeanObservable = mOCHTaxiServiceApi.gotoLoginBycode4Bus(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
MoGoAiCloudClientConfig.getInstance().token,
|
||||
TaxiLoginReqBean(phone, code, sn, location4Login)
|
||||
).transformTry()
|
||||
}
|
||||
}
|
||||
taxiLoginRespBeanObservable?.subscribe(OchCommonSubscribeImpl(context, callback, "gotoLoginBycode"))
|
||||
}
|
||||
|
||||
/**
|
||||
* 登出
|
||||
*/
|
||||
@JvmStatic
|
||||
fun logout(
|
||||
context: Context,
|
||||
location4Login: TaxiLogoutReqBean.Location4Login?,
|
||||
callback: OchCommonServiceCallback<BaseData>?
|
||||
) {
|
||||
var logout: Observable<BaseData>? = null
|
||||
when (DebugConfig.getProductFlavor()) {
|
||||
"fPadLenovoOchTaxi" -> {
|
||||
//出租车司机
|
||||
logout = mOCHTaxiServiceApi.logout4Taxi(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
MoGoAiCloudClientConfig.getInstance().token,
|
||||
TaxiLogoutReqBean(MoGoAiCloudClientConfig.getInstance().sn, location4Login)
|
||||
).transformTry()
|
||||
}
|
||||
"fPadLenovoOchBus" -> {
|
||||
//小巴车司机
|
||||
logout = mOCHTaxiServiceApi.logout4Bus(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
MoGoAiCloudClientConfig.getInstance().token,
|
||||
TaxiLogoutReqBean(MoGoAiCloudClientConfig.getInstance().sn, location4Login)
|
||||
).transformTry()
|
||||
}
|
||||
}
|
||||
logout?.subscribe(OchCommonSubscribeImpl(context, callback, "logout"))
|
||||
}
|
||||
|
||||
/**
|
||||
* 接单状态和登录状态查询
|
||||
*
|
||||
* @param context
|
||||
* @param callback
|
||||
*/
|
||||
@JvmStatic
|
||||
fun queryDriverServiceStatus(
|
||||
context: Context,
|
||||
callback: OchCommonServiceCallback<DriverStatusQueryRespBean>?
|
||||
) {
|
||||
if (MoGoAiCloudClientConfig.getInstance().token.isEmpty()) {
|
||||
callback?.onFail(OchCommonConst.WAIT_TAKEN, "等待令牌中请稍等")
|
||||
MoGoAiCloudClient.getInstance().refreshToken()
|
||||
return
|
||||
}
|
||||
var flavor = ""
|
||||
when (DebugConfig.getProductFlavor()) {
|
||||
"fPadLenovoOchTaxi" -> {
|
||||
//出租车司机
|
||||
flavor = "taxi"
|
||||
}
|
||||
"fPadLenovoOchBus" -> {
|
||||
//小巴车司机
|
||||
flavor = "bus"
|
||||
}
|
||||
"fPadLenovoOchBusPassenger" -> {
|
||||
//小巴车乘客
|
||||
flavor = "bus/passenger"
|
||||
}
|
||||
}
|
||||
mOCHTaxiServiceApi.queryDriverServiceStatusAndLoginStatus(
|
||||
flavor,
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
MoGoAiCloudClientConfig.getInstance().token,
|
||||
MoGoAiCloudClientConfig.getInstance().sn
|
||||
).transformTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "queryDriverServiceStatus"))
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.mogo.och.common.module.biz.network
|
||||
|
||||
import com.mogo.eagle.core.data.BaseData
|
||||
import com.mogo.eagle.core.network.RequestOptions
|
||||
import com.mogo.eagle.core.network.SubscribeImpl
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
import com.mogo.och.common.module.utils.CallerLoggerUtils.flavorTag
|
||||
|
||||
class OchCommonSubscribeImpl<T : BaseData>(
|
||||
val context: Any,
|
||||
val callback: OchCommonServiceCallback<T>?,
|
||||
val apiName: String
|
||||
) : SubscribeImpl<T>(RequestOptions.create(context)) {
|
||||
|
||||
companion object {
|
||||
const val TAG = "OchCommonSubscribeImpl"
|
||||
}
|
||||
|
||||
override fun onSuccess(o: T) {
|
||||
super.onSuccess(o)
|
||||
CallerLogger.d("$flavorTag$TAG", "$apiName: onSuccess() ${o.msg}")
|
||||
callback?.onSuccess(o)
|
||||
}
|
||||
|
||||
override fun onError(e: Throwable) {
|
||||
super.onError(e)
|
||||
CallerLogger.e("$flavorTag$TAG", "$apiName: onError() ${e.message}")
|
||||
callback?.onError()
|
||||
}
|
||||
|
||||
override fun onError(message: String, code: Int) {
|
||||
super.onError(message, code)
|
||||
CallerLogger.e("$flavorTag$TAG", "$apiName: onError() code = $code; message = $message")
|
||||
callback?.onFail(code, message)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.mogo.och.common.module.biz.network.interceptor
|
||||
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClient
|
||||
import com.mogo.eagle.core.data.BaseData
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.ObservableSource
|
||||
import io.reactivex.functions.Function
|
||||
|
||||
class FRetryWithTime<T : BaseData> : Function<T, ObservableSource<T>> {
|
||||
|
||||
override fun apply(baseData: T): ObservableSource<T> {
|
||||
baseData.let {
|
||||
if (it.code == 100046 || it.code == 100045 || it.code == 100005 || it.code == 100006 || it.code == 520003) {
|
||||
MoGoAiCloudClient.getInstance().refreshToken()
|
||||
return Observable.error(OchCommonRetryException())
|
||||
}
|
||||
}
|
||||
return Observable.just(baseData)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.mogo.och.common.module.biz.network.interceptor
|
||||
|
||||
import io.reactivex.Observable
|
||||
import com.mogo.eagle.core.data.BaseData
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
|
||||
fun <T : BaseData> Observable<T>.transformTry():Observable<T> {
|
||||
return flatMap(FRetryWithTime<T>())
|
||||
.retryWhen(RetryWithTime())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.mogo.och.common.module.biz.network.interceptor;
|
||||
|
||||
public class OchCommonRetryException extends RuntimeException{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.mogo.och.common.module.biz.network.interceptor
|
||||
|
||||
import com.mogo.eagle.core.utilcode.constant.TimeConstants
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
import com.mogo.eagle.core.utilcode.util.TimeUtils
|
||||
import com.mogo.och.common.module.utils.CallerLoggerUtils.flavorTag
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.ObservableSource
|
||||
import io.reactivex.functions.Function
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
|
||||
class RetryWithTime : Function<Observable<Throwable?>, ObservableSource<Any?>> {
|
||||
companion object {
|
||||
private const val TAG = "RetryWithTime"
|
||||
}
|
||||
var current = -1
|
||||
private var timeDelys = intArrayOf(3, 1, 2)
|
||||
override fun apply(throwableObservable: Observable<Throwable?>): ObservableSource<Any?>? {
|
||||
return throwableObservable.flatMap {
|
||||
++current
|
||||
CallerLogger.e("${flavorTag}${TAG}", " 时间:${TimeUtils.getStringByNow(0, TimeConstants.SEC)}")
|
||||
if (it is OchCommonRetryException && current < timeDelys.size) {
|
||||
Observable.timer(timeDelys[current].toLong(), TimeUnit.SECONDS)
|
||||
} else {
|
||||
Observable.error(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.mogo.och.common.module.utils
|
||||
|
||||
import com.mogo.commons.debug.DebugConfig
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_BUS
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_BUS_P
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_TAXI
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_TAXI_P
|
||||
|
||||
object CallerLoggerUtils {
|
||||
var flavorTag = when (DebugConfig.getProductFlavor()) {
|
||||
"fPadLenovoOchTaxi" -> {
|
||||
//出租车司机
|
||||
M_TAXI
|
||||
}
|
||||
"fPadLenovoOchBus" -> {
|
||||
//小巴车司机
|
||||
M_BUS
|
||||
}
|
||||
"fPadLenovoOchTaxiPassenger" -> {
|
||||
//出租车乘客
|
||||
M_TAXI_P
|
||||
}
|
||||
"fPadLenovoOchBusPassenger" -> {
|
||||
//小巴车乘客
|
||||
M_BUS_P
|
||||
}
|
||||
else -> {
|
||||
""
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -32,6 +32,7 @@ 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.common.module.biz.network.OchCommonServiceCallback;
|
||||
import com.mogo.och.common.module.utils.CoordinateCalculateRouteUtil;
|
||||
import com.mogo.och.common.module.utils.PinYinUtil;
|
||||
import com.mogo.och.taxi.passenger.bean.TaxiPassengerBaseRespBean;
|
||||
@@ -51,7 +52,6 @@ import com.mogo.och.taxi.passenger.callback.ITaxiPassengerCommonValueCallback;
|
||||
import com.mogo.och.taxi.passenger.callback.ITaxiPassengerVeloctityCallback;
|
||||
import com.mogo.och.taxi.passenger.constant.TaxiPassengerConst;
|
||||
import com.mogo.och.taxi.passenger.constant.TaxiPassengerOrderStatusEnum;
|
||||
import com.mogo.och.taxi.passenger.network.TaxiPassengerServiceCallback;
|
||||
import com.mogo.och.taxi.passenger.network.TaxiPassengerServiceManager;
|
||||
import com.mogo.aicloud.services.socket.IMogoLifecycleListener;
|
||||
import com.mogo.och.taxi.passenger.utils.TaxiPassengerAnalyticsManager;
|
||||
@@ -288,8 +288,8 @@ public class TaxiPassengerModel implements IOCHTaxiPassengerNaviChangedCallback
|
||||
* 才更新最新进行中单到本地
|
||||
*/
|
||||
public void queryInAndWaitOrders() {
|
||||
TaxiPassengerServiceManager.getInstance().queryOrdersInAndWaitService(mContext,
|
||||
new TaxiPassengerServiceCallback<TaxiPassengerOrdersInServiceQueryRespBean>() {
|
||||
TaxiPassengerServiceManager.queryOrdersInAndWaitService(mContext,
|
||||
new OchCommonServiceCallback<TaxiPassengerOrdersInServiceQueryRespBean>() {
|
||||
@Override
|
||||
public void onSuccess(TaxiPassengerOrdersInServiceQueryRespBean data) {
|
||||
if (data == null || data.data == null) {
|
||||
@@ -346,8 +346,8 @@ public class TaxiPassengerModel implements IOCHTaxiPassengerNaviChangedCallback
|
||||
return;
|
||||
}
|
||||
final String orderNo = mCurrentOCHOrder.orderNo;
|
||||
TaxiPassengerServiceManager.getInstance().queryOrderById(mContext, orderNo,
|
||||
new TaxiPassengerServiceCallback<TaxiPassengerOrderQueryRespBean>() {
|
||||
TaxiPassengerServiceManager.queryOrderById(mContext, orderNo,
|
||||
new OchCommonServiceCallback<TaxiPassengerOrderQueryRespBean>() {
|
||||
@Override
|
||||
public void onSuccess(TaxiPassengerOrderQueryRespBean data) {
|
||||
if (data != null && data.data != null
|
||||
@@ -693,7 +693,7 @@ public class TaxiPassengerModel implements IOCHTaxiPassengerNaviChangedCallback
|
||||
*/
|
||||
public void queryOrderRemaining(){
|
||||
if (mCurrentOCHOrder == null) return;
|
||||
TaxiPassengerServiceManager.getInstance().queryOrderRemaining(mContext, mCurrentOCHOrder.orderNo, new TaxiPassengerServiceCallback<TaxiPassengerOrderQueryRemainingResp>() {
|
||||
TaxiPassengerServiceManager.queryOrderRemaining(mContext, mCurrentOCHOrder.orderNo, new OchCommonServiceCallback<TaxiPassengerOrderQueryRemainingResp>() {
|
||||
@Override
|
||||
public void onSuccess(TaxiPassengerOrderQueryRemainingResp data) {
|
||||
if (data != null && data.data!=null){
|
||||
@@ -714,7 +714,7 @@ public class TaxiPassengerModel implements IOCHTaxiPassengerNaviChangedCallback
|
||||
public void queryOrderRouteList() {
|
||||
if (mCurrentOCHOrder == null) return;
|
||||
CallerLogger.INSTANCE.d(M_TAXI_P + TAG, "--route--- queryOrderRouteList");
|
||||
TaxiPassengerServiceManager.getInstance().queryOrderRouteList(mContext, mCurrentOCHOrder.orderNo, new TaxiPassengerServiceCallback<TaxiPassengerQueryOrderRouteResp>() {
|
||||
TaxiPassengerServiceManager.queryOrderRouteList(mContext, mCurrentOCHOrder.orderNo, new OchCommonServiceCallback<TaxiPassengerQueryOrderRouteResp>() {
|
||||
@Override
|
||||
public void onSuccess(TaxiPassengerQueryOrderRouteResp data) {
|
||||
CallerLogger.INSTANCE.d(M_TAXI_P + TAG, "--route---"+GsonUtil.jsonFromObject(data));
|
||||
@@ -765,8 +765,8 @@ public class TaxiPassengerModel implements IOCHTaxiPassengerNaviChangedCallback
|
||||
|
||||
public void checkPhoneAndUpdateStatus(String phoneTail,ITaxiPassengerCommonCallback commonCallback) {
|
||||
if (mCurrentOCHOrder == null) return;
|
||||
TaxiPassengerServiceManager.getInstance().checkPhoneAndUpdateOrderStatus(mContext, mCurrentOCHOrder.orderNo,
|
||||
phoneTail, new TaxiPassengerServiceCallback<TaxiPassengerBaseRespBean>() {
|
||||
TaxiPassengerServiceManager.checkPhoneAndUpdateOrderStatus(mContext, mCurrentOCHOrder.orderNo,
|
||||
phoneTail, new OchCommonServiceCallback<TaxiPassengerBaseRespBean>() {
|
||||
@Override
|
||||
public void onSuccess(TaxiPassengerBaseRespBean data) {
|
||||
if (data != null && data.code == 0 && mCurrentOCHOrder != null){
|
||||
@@ -799,8 +799,8 @@ public class TaxiPassengerModel implements IOCHTaxiPassengerNaviChangedCallback
|
||||
|
||||
public void arrivedAndScore(TaxiPassengerScoreUpdateOrderReqBean taxiPassengerScoreUpdateOrderReqBean , ITaxiPassengerCommonValueCallback<Boolean> commonCallback) {
|
||||
if (taxiPassengerScoreUpdateOrderReqBean.orderNo == null) return;
|
||||
TaxiPassengerServiceManager.getInstance().arrivedAndScore(mContext,taxiPassengerScoreUpdateOrderReqBean,
|
||||
new TaxiPassengerServiceCallback<TaxiPassengerBaseRespBean>() {
|
||||
TaxiPassengerServiceManager.arrivedAndScore(mContext,taxiPassengerScoreUpdateOrderReqBean,
|
||||
new OchCommonServiceCallback<TaxiPassengerBaseRespBean>() {
|
||||
@Override
|
||||
public void onSuccess(TaxiPassengerBaseRespBean data) {
|
||||
if(commonCallback!=null) {
|
||||
@@ -829,8 +829,8 @@ public class TaxiPassengerModel implements IOCHTaxiPassengerNaviChangedCallback
|
||||
|
||||
public void loopQueryPilotStatus(){
|
||||
if (mCurrentOCHOrder == null) return;
|
||||
TaxiPassengerServiceManager.getInstance().queryPilotStatus(mContext, mCurrentOCHOrder.orderNo,
|
||||
new TaxiPassengerServiceCallback<TaxiPassengerBaseRespBean>() {
|
||||
TaxiPassengerServiceManager.queryPilotStatus(mContext, mCurrentOCHOrder.orderNo,
|
||||
new OchCommonServiceCallback<TaxiPassengerBaseRespBean>() {
|
||||
@Override
|
||||
public void onSuccess(TaxiPassengerBaseRespBean data) {
|
||||
if (data != null && data.code == 0 && data.data.equals(true)) {
|
||||
@@ -873,9 +873,9 @@ public class TaxiPassengerModel implements IOCHTaxiPassengerNaviChangedCallback
|
||||
TaxiPassengerStartReqBean.Result result = new TaxiPassengerStartReqBean.Result();
|
||||
result.lat = mLatitude;
|
||||
result.lon = mLongitude;
|
||||
TaxiPassengerServiceManager.getInstance().startServicePilotDone(mContext,
|
||||
TaxiPassengerServiceManager.startServicePilotDone(mContext,
|
||||
mCurrentOCHOrder.orderNo, result,
|
||||
new TaxiPassengerServiceCallback<TaxiPassengerBaseRespBean>(){
|
||||
new OchCommonServiceCallback<TaxiPassengerBaseRespBean>(){
|
||||
|
||||
@Override
|
||||
public void onSuccess(TaxiPassengerBaseRespBean data) {
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
package com.mogo.och.taxi.passenger.network;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2021/1/15
|
||||
*
|
||||
* 修改订单状态回调接口
|
||||
*/
|
||||
public interface TaxiPassengerServiceCallback< T > {
|
||||
|
||||
void onSuccess(T data);
|
||||
|
||||
void onFail(int code, String msg);
|
||||
|
||||
default void onError() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,208 +0,0 @@
|
||||
package com.mogo.och.taxi.passenger.network;
|
||||
|
||||
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_TAXI_P;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
|
||||
import com.mogo.eagle.core.data.BaseData;
|
||||
import com.mogo.eagle.core.function.call.telematic.CallerTelematicManager;
|
||||
import com.mogo.eagle.core.network.MoGoRetrofitFactory;
|
||||
import com.mogo.eagle.core.network.RequestOptions;
|
||||
import com.mogo.eagle.core.network.SubscribeImpl;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.och.taxi.passenger.bean.TaxiPassengerAllStarWorld;
|
||||
import com.mogo.och.taxi.passenger.bean.TaxiPassengerBaseRespBean;
|
||||
import com.mogo.och.taxi.passenger.bean.TaxiPassengerCheckPhoneUpdateOrderReqBean;
|
||||
import com.mogo.och.taxi.passenger.bean.TaxiPassengerOrderQueryRemainingResp;
|
||||
import com.mogo.och.taxi.passenger.bean.TaxiPassengerOrderQueryReqBean;
|
||||
import com.mogo.och.taxi.passenger.bean.TaxiPassengerOrderQueryRespBean;
|
||||
import com.mogo.och.taxi.passenger.bean.TaxiPassengerOrdersInServiceQueryRespBean;
|
||||
import com.mogo.och.taxi.passenger.bean.TaxiPassengerQueryOrderRouteResp;
|
||||
import com.mogo.och.taxi.passenger.bean.TaxiPassengerScoreUpdateOrderReqBean;
|
||||
import com.mogo.och.taxi.passenger.bean.TaxiPassengerStartReqBean;
|
||||
import com.mogo.och.taxi.passenger.constant.TaxiPassengerConst;
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
/**
|
||||
* Created by pangfan on 2021/8/19
|
||||
*/
|
||||
public class TaxiPassengerServiceManager {
|
||||
private static final String TAG = TaxiPassengerServiceManager.class.getSimpleName();
|
||||
|
||||
private static final class SingletonHolder {
|
||||
private static final TaxiPassengerServiceManager INSTANCE = new TaxiPassengerServiceManager();
|
||||
}
|
||||
|
||||
public static TaxiPassengerServiceManager getInstance() {
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private TaxiPassengerServiceApi mOCHTaxiServiceApi;
|
||||
|
||||
private TaxiPassengerServiceManager() {
|
||||
if (mOCHTaxiServiceApi == null){
|
||||
mOCHTaxiServiceApi = MoGoRetrofitFactory.getInstance(TaxiPassengerConst.getBaseUrl()).create(TaxiPassengerServiceApi.class);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取司机端的sn
|
||||
* @return
|
||||
*/
|
||||
private String getDriverAppSn(){
|
||||
return CallerTelematicManager.INSTANCE.getServerToken();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询全部服务中/待服务订单列表
|
||||
* @param context
|
||||
* @param callback
|
||||
*/
|
||||
public void queryOrdersInAndWaitService(Context context,
|
||||
TaxiPassengerServiceCallback<TaxiPassengerOrdersInServiceQueryRespBean> callback) {
|
||||
mOCHTaxiServiceApi.queryOrdersInAndWaitService(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
|
||||
,MoGoAiCloudClientConfig.getInstance().getToken()
|
||||
,getDriverAppSn()) //获取到司机端的sn
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(getSubscribeImpl(context, callback, "queryOrdersInAndWaitService"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询订单剩余里程和时间
|
||||
* @param context
|
||||
* @param orderNo
|
||||
* @param callback
|
||||
*/
|
||||
public void queryOrderRemaining(Context context, String orderNo, TaxiPassengerServiceCallback<TaxiPassengerOrderQueryRemainingResp> callback){
|
||||
mOCHTaxiServiceApi.queryOrderRemaining(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
|
||||
,MoGoAiCloudClientConfig.getInstance().getToken()
|
||||
,orderNo)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(getSubscribeImpl(context, callback, "queryOrderRemaining"));
|
||||
}
|
||||
|
||||
public void queryOrderRouteList(Context context, String orderNo, TaxiPassengerServiceCallback<TaxiPassengerQueryOrderRouteResp> callback){
|
||||
|
||||
mOCHTaxiServiceApi.queryOrderRoute(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
|
||||
,MoGoAiCloudClientConfig.getInstance().getToken()
|
||||
,orderNo)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(getSubscribeImpl(context, callback, "queryOrderRouteList"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过orderId查询订单信息(用于本地已经有orderId时)
|
||||
* @param context
|
||||
* @param orderNo
|
||||
* @param callback
|
||||
* @deprecated v2.1_0930需求中暂不再使用此接口
|
||||
*/
|
||||
public void queryOrderById(Context context, String orderNo,
|
||||
TaxiPassengerServiceCallback<TaxiPassengerOrderQueryRespBean> callback) {
|
||||
mOCHTaxiServiceApi.queryOrderById(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
|
||||
,MoGoAiCloudClientConfig.getInstance().getToken()
|
||||
,new TaxiPassengerOrderQueryReqBean(getDriverAppSn(), orderNo))
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(getSubscribeImpl(context, callback, "queryOrderById"));
|
||||
}
|
||||
|
||||
private <T extends BaseData> SubscribeImpl getSubscribeImpl(
|
||||
Context context, TaxiPassengerServiceCallback<T> callback, String apiName) {
|
||||
return new SubscribeImpl<T>(RequestOptions.create(context)) {
|
||||
@Override
|
||||
public void onSuccess(T o) {
|
||||
super.onSuccess(o);
|
||||
CallerLogger.INSTANCE.e(M_TAXI_P + TAG,apiName + ": onSuccess() " + o.msg);
|
||||
if (callback != null) {
|
||||
callback.onSuccess(o);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
super.onError(e);
|
||||
CallerLogger.INSTANCE.e(M_TAXI_P + TAG,apiName + ": onError() " + e.getMessage());
|
||||
if (callback != null) {
|
||||
callback.onError();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String message, int code) {
|
||||
super.onError(message, code);
|
||||
CallerLogger.INSTANCE.e(M_TAXI_P + TAG,String.format(apiName + ": onError() code = %d; message = %s;", code, message));
|
||||
if (callback != null) {
|
||||
callback.onFail(code, message);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public void checkPhoneAndUpdateOrderStatus(Context context, String orderNo,String phone ,TaxiPassengerServiceCallback<TaxiPassengerBaseRespBean> callback){
|
||||
|
||||
mOCHTaxiServiceApi.checkPhoneAndUpdateOrderStatus(
|
||||
MoGoAiCloudClientConfig.getInstance().getServiceAppId()
|
||||
,MoGoAiCloudClientConfig.getInstance().getToken()
|
||||
,new TaxiPassengerCheckPhoneUpdateOrderReqBean(orderNo,phone))
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(getSubscribeImpl(context, callback, "checkPhoneAndUpdateOrderStatus"));
|
||||
}
|
||||
public void arrivedAndScore(Context context,TaxiPassengerScoreUpdateOrderReqBean taxiPassengerScoreUpdateOrderReqBean, TaxiPassengerServiceCallback<TaxiPassengerBaseRespBean> callback){
|
||||
mOCHTaxiServiceApi.arrivedAndScore(
|
||||
MoGoAiCloudClientConfig.getInstance().getServiceAppId()
|
||||
,MoGoAiCloudClientConfig.getInstance().getToken()
|
||||
,taxiPassengerScoreUpdateOrderReqBean)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(getSubscribeImpl(context, callback, "checkPhoneAndUpdateOrderStatus"));
|
||||
}
|
||||
|
||||
public void getAllScoreWorld(Context context,TaxiPassengerServiceCallback<TaxiPassengerAllStarWorld> callback){
|
||||
mOCHTaxiServiceApi.getWorldAllStar(
|
||||
MoGoAiCloudClientConfig.getInstance().getServiceAppId()
|
||||
,MoGoAiCloudClientConfig.getInstance().getToken())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(getSubscribeImpl(context, callback, "arrivedAndScore"));
|
||||
}
|
||||
|
||||
public void queryPilotStatus(Context context, String orderNo
|
||||
,TaxiPassengerServiceCallback<TaxiPassengerBaseRespBean> callback){
|
||||
mOCHTaxiServiceApi.queryPilotStatus(
|
||||
MoGoAiCloudClientConfig.getInstance().getServiceAppId()
|
||||
,MoGoAiCloudClientConfig.getInstance().getToken()
|
||||
,orderNo)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(getSubscribeImpl(context, callback, "queryPilotStatus"));
|
||||
}
|
||||
|
||||
public void startServicePilotDone(Context context,String orderNo,TaxiPassengerStartReqBean.Result loc
|
||||
,TaxiPassengerServiceCallback<TaxiPassengerBaseRespBean> callback){
|
||||
mOCHTaxiServiceApi.startServicePilotDone(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
|
||||
,MoGoAiCloudClientConfig.getInstance().getToken()
|
||||
,new TaxiPassengerStartReqBean(getDriverAppSn()
|
||||
,orderNo,loc))
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(getSubscribeImpl(context,callback,"startServicePilotDone"));
|
||||
}
|
||||
public void getWorldByStar(Context context,String start,TaxiPassengerServiceCallback<TaxiPassengerAllStarWorld> callback){
|
||||
mOCHTaxiServiceApi.getWorldByStar(
|
||||
MoGoAiCloudClientConfig.getInstance().getServiceAppId()
|
||||
,MoGoAiCloudClientConfig.getInstance().getToken(),start)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(getSubscribeImpl(context, callback, "checkPhoneAndUpdateOrderStatus"));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,199 @@
|
||||
package com.mogo.och.taxi.passenger.network
|
||||
|
||||
import android.content.Context
|
||||
import com.mogo.och.taxi.passenger.constant.TaxiPassengerConst.Companion.getBaseUrl
|
||||
import com.mogo.eagle.core.function.call.telematic.CallerTelematicManager.getServerToken
|
||||
import com.mogo.och.taxi.passenger.bean.TaxiPassengerOrdersInServiceQueryRespBean
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig
|
||||
import com.mogo.och.taxi.passenger.bean.TaxiPassengerOrderQueryRemainingResp
|
||||
import com.mogo.och.taxi.passenger.bean.TaxiPassengerQueryOrderRouteResp
|
||||
import com.mogo.och.taxi.passenger.bean.TaxiPassengerOrderQueryRespBean
|
||||
import com.mogo.och.taxi.passenger.bean.TaxiPassengerOrderQueryReqBean
|
||||
import com.mogo.och.taxi.passenger.bean.TaxiPassengerBaseRespBean
|
||||
import com.mogo.och.taxi.passenger.bean.TaxiPassengerCheckPhoneUpdateOrderReqBean
|
||||
import com.mogo.och.taxi.passenger.bean.TaxiPassengerScoreUpdateOrderReqBean
|
||||
import com.mogo.och.taxi.passenger.bean.TaxiPassengerAllStarWorld
|
||||
import com.mogo.och.taxi.passenger.bean.TaxiPassengerStartReqBean
|
||||
import com.mogo.eagle.core.network.MoGoRetrofitFactory
|
||||
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
|
||||
|
||||
/**
|
||||
* Created by pangfan on 2021/8/19
|
||||
*/
|
||||
object TaxiPassengerServiceManager {
|
||||
|
||||
private val mOCHTaxiServiceApi: TaxiPassengerServiceApi = MoGoRetrofitFactory.getInstance(getBaseUrl()).create(
|
||||
TaxiPassengerServiceApi::class.java
|
||||
)
|
||||
|
||||
/**
|
||||
* 获取司机端的sn
|
||||
* @return
|
||||
*/
|
||||
private val driverAppSn: String
|
||||
get() = getServerToken()
|
||||
|
||||
/**
|
||||
* 查询全部服务中/待服务订单列表
|
||||
* @param context
|
||||
* @param callback
|
||||
*/
|
||||
@JvmStatic
|
||||
fun queryOrdersInAndWaitService(
|
||||
context: Context,
|
||||
callback: OchCommonServiceCallback<TaxiPassengerOrdersInServiceQueryRespBean>?
|
||||
) {
|
||||
mOCHTaxiServiceApi.queryOrdersInAndWaitService(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
MoGoAiCloudClientConfig.getInstance().token,
|
||||
driverAppSn
|
||||
) //获取到司机端的sn
|
||||
.transformTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "queryOrdersInAndWaitService"))
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询订单剩余里程和时间
|
||||
* @param context
|
||||
* @param orderNo
|
||||
* @param callback
|
||||
*/
|
||||
@JvmStatic
|
||||
fun queryOrderRemaining(
|
||||
context: Context,
|
||||
orderNo: String?,
|
||||
callback: OchCommonServiceCallback<TaxiPassengerOrderQueryRemainingResp>?
|
||||
) {
|
||||
mOCHTaxiServiceApi.queryOrderRemaining(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
MoGoAiCloudClientConfig.getInstance().token,
|
||||
orderNo
|
||||
)
|
||||
.transformTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "queryOrderRemaining"))
|
||||
}
|
||||
@JvmStatic
|
||||
fun queryOrderRouteList(
|
||||
context: Context,
|
||||
orderNo: String?,
|
||||
callback: OchCommonServiceCallback<TaxiPassengerQueryOrderRouteResp>?
|
||||
) {
|
||||
mOCHTaxiServiceApi.queryOrderRoute(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
MoGoAiCloudClientConfig.getInstance().token,
|
||||
orderNo
|
||||
)
|
||||
.transformTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "queryOrderRouteList"))
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过orderId查询订单信息(用于本地已经有orderId时)
|
||||
* @param context
|
||||
* @param orderNo
|
||||
* @param callback
|
||||
*/
|
||||
@JvmStatic
|
||||
@Deprecated("v2.1_0930需求中暂不再使用此接口")
|
||||
fun queryOrderById(
|
||||
context: Context, orderNo: String?,
|
||||
callback: OchCommonServiceCallback<TaxiPassengerOrderQueryRespBean>?
|
||||
) {
|
||||
mOCHTaxiServiceApi.queryOrderById(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
MoGoAiCloudClientConfig.getInstance().token,
|
||||
TaxiPassengerOrderQueryReqBean(driverAppSn, orderNo)
|
||||
)
|
||||
.transformTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "queryOrderById"))
|
||||
}
|
||||
@JvmStatic
|
||||
fun checkPhoneAndUpdateOrderStatus(
|
||||
context: Context,
|
||||
orderNo: String?,
|
||||
phone: String?,
|
||||
callback: OchCommonServiceCallback<TaxiPassengerBaseRespBean>?
|
||||
) {
|
||||
mOCHTaxiServiceApi.checkPhoneAndUpdateOrderStatus(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
MoGoAiCloudClientConfig.getInstance().token,
|
||||
TaxiPassengerCheckPhoneUpdateOrderReqBean(orderNo, phone)
|
||||
)
|
||||
.transformTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "checkPhoneAndUpdateOrderStatus"))
|
||||
}
|
||||
@JvmStatic
|
||||
fun arrivedAndScore(
|
||||
context: Context,
|
||||
taxiPassengerScoreUpdateOrderReqBean: TaxiPassengerScoreUpdateOrderReqBean?,
|
||||
callback: OchCommonServiceCallback<TaxiPassengerBaseRespBean>?
|
||||
) {
|
||||
mOCHTaxiServiceApi.arrivedAndScore(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
MoGoAiCloudClientConfig.getInstance().token,
|
||||
taxiPassengerScoreUpdateOrderReqBean
|
||||
)
|
||||
.transformTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "checkPhoneAndUpdateOrderStatus"))
|
||||
}
|
||||
@JvmStatic
|
||||
fun getAllScoreWorld(
|
||||
context: Context,
|
||||
callback: OchCommonServiceCallback<TaxiPassengerAllStarWorld>?
|
||||
) {
|
||||
mOCHTaxiServiceApi.getWorldAllStar(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
MoGoAiCloudClientConfig.getInstance().token
|
||||
)
|
||||
.transformTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "arrivedAndScore"))
|
||||
}
|
||||
@JvmStatic
|
||||
fun queryPilotStatus(
|
||||
context: Context,
|
||||
orderNo: String?,
|
||||
callback: OchCommonServiceCallback<TaxiPassengerBaseRespBean>?
|
||||
) {
|
||||
mOCHTaxiServiceApi.queryPilotStatus(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
MoGoAiCloudClientConfig.getInstance().token,
|
||||
orderNo
|
||||
)
|
||||
.transformTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "queryPilotStatus"))
|
||||
}
|
||||
@JvmStatic
|
||||
fun startServicePilotDone(
|
||||
context: Context,
|
||||
orderNo: String?,
|
||||
loc: TaxiPassengerStartReqBean.Result?,
|
||||
callback: OchCommonServiceCallback<TaxiPassengerBaseRespBean>?
|
||||
) {
|
||||
mOCHTaxiServiceApi.startServicePilotDone(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
MoGoAiCloudClientConfig.getInstance().token,
|
||||
TaxiPassengerStartReqBean(
|
||||
driverAppSn, orderNo, loc
|
||||
)
|
||||
)
|
||||
.transformTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "startServicePilotDone"))
|
||||
}
|
||||
@JvmStatic
|
||||
fun getWorldByStar(
|
||||
context: Context,
|
||||
start: String?,
|
||||
callback: OchCommonServiceCallback<TaxiPassengerAllStarWorld>?
|
||||
) {
|
||||
mOCHTaxiServiceApi.getWorldByStar(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
MoGoAiCloudClientConfig.getInstance().token,
|
||||
start
|
||||
)
|
||||
.transformTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "checkPhoneAndUpdateOrderStatus"))
|
||||
}
|
||||
|
||||
}
|
||||
@@ -25,13 +25,13 @@ import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
|
||||
import com.mogo.eagle.core.utilcode.util.OverlayViewUtils
|
||||
import com.mogo.eagle.core.utilcode.util.ToastUtils
|
||||
import com.mogo.eagle.core.widget.media.video.SimpleVideoPlayer
|
||||
import com.mogo.och.common.module.biz.network.OchCommonServiceCallback
|
||||
import com.mogo.och.common.module.wigets.OCHBorderShadowLayout
|
||||
import com.mogo.och.taxi.passenger.R
|
||||
import com.mogo.och.taxi.passenger.bean.TaxiPassengerAllStarWorld
|
||||
import com.mogo.och.taxi.passenger.bean.TaxiPassengerScoreUpdateOrderReqBean
|
||||
import com.mogo.och.taxi.passenger.callback.ITaxiPassengerCommonCallback
|
||||
import com.mogo.och.taxi.passenger.callback.ITaxiPassengerScoreCallback
|
||||
import com.mogo.och.taxi.passenger.network.TaxiPassengerServiceCallback
|
||||
import com.mogo.och.taxi.passenger.network.TaxiPassengerServiceManager
|
||||
import com.mogo.och.taxi.passenger.ui.comment.adapter.CommentAdapter
|
||||
import com.mogo.och.taxi.passenger.widget.ResizeAnimation
|
||||
@@ -412,8 +412,8 @@ class TaxiPassengerArrivedView :RelativeLayout, View.OnClickListener {
|
||||
}
|
||||
|
||||
private fun requestStarWord() {
|
||||
TaxiPassengerServiceManager.getInstance().getAllScoreWorld(context,
|
||||
object : TaxiPassengerServiceCallback<TaxiPassengerAllStarWorld?> {
|
||||
TaxiPassengerServiceManager.getAllScoreWorld(context,
|
||||
object : OchCommonServiceCallback<TaxiPassengerAllStarWorld> {
|
||||
override fun onError() {
|
||||
CallerLogger.e(
|
||||
SceneConstant.M_TAXI_P + TAG,
|
||||
@@ -436,8 +436,8 @@ class TaxiPassengerArrivedView :RelativeLayout, View.OnClickListener {
|
||||
}
|
||||
|
||||
private fun requestStarWordByStar(start:Int) {
|
||||
TaxiPassengerServiceManager.getInstance().getWorldByStar(context,start.toString(),
|
||||
object : TaxiPassengerServiceCallback<TaxiPassengerAllStarWorld?> {
|
||||
TaxiPassengerServiceManager.getWorldByStar(context,start.toString(),
|
||||
object : OchCommonServiceCallback<TaxiPassengerAllStarWorld> {
|
||||
override fun onError() {
|
||||
CallerLogger.e(
|
||||
SceneConstant.M_TAXI_P + TAG,
|
||||
|
||||
@@ -36,6 +36,7 @@ import com.mogo.map.navi.IMogoCarLocationChangedListener2;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.och.common.module.biz.constant.LoginStatusManager;
|
||||
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.provider.LoginService;
|
||||
import com.mogo.och.common.module.manager.OCHAdasAbilityManager;
|
||||
import com.mogo.och.common.module.utils.CoordinateCalculateRouteUtil;
|
||||
@@ -62,7 +63,6 @@ import com.mogo.och.taxi.constant.TaxiConst;
|
||||
import com.mogo.och.taxi.constant.TaxiOrderStatusEnum;
|
||||
import com.mogo.och.taxi.constant.TaxiOrderTypeEnum;
|
||||
import com.mogo.och.taxi.constant.TaxtServingStatusManager;
|
||||
import com.mogo.och.taxi.network.TaxiServiceCallback;
|
||||
import com.mogo.och.taxi.network.TaxiServiceManager;
|
||||
import com.mogo.och.taxi.utils.TaxiAnalyticsManager;
|
||||
import com.mogo.och.taxi.utils.OrderUtil;
|
||||
@@ -264,8 +264,8 @@ public class TaxiModel {
|
||||
loginService.queryLoginStatusByNet();
|
||||
return;
|
||||
}
|
||||
TaxiServiceManager.getInstance().changeOrderServing(mContext,TaxtServingStatusManager.isOpeningOrderStatus(),
|
||||
new TaxiServiceCallback<BaseData>() {
|
||||
TaxiServiceManager.changeOrderServing(mContext,TaxtServingStatusManager.isOpeningOrderStatus(),
|
||||
new OchCommonServiceCallback<BaseData>() {
|
||||
@Override
|
||||
public void onSuccess(BaseData data) {
|
||||
if (null != data && 0 == data.code) {
|
||||
@@ -297,8 +297,8 @@ public class TaxiModel {
|
||||
* 才更新最新进行中单到本地
|
||||
*/
|
||||
public void queryInAndWaitOrders() {
|
||||
TaxiServiceManager.getInstance().queryOrdersInAndWaitService(mContext,
|
||||
new TaxiServiceCallback<OrdersInServiceQueryRespBean>() {
|
||||
TaxiServiceManager.queryOrdersInAndWaitService(mContext,
|
||||
new OchCommonServiceCallback<OrdersInServiceQueryRespBean>() {
|
||||
@Override
|
||||
public void onSuccess(OrdersInServiceQueryRespBean data) {
|
||||
if (data == null || data.data == null) {
|
||||
@@ -373,8 +373,8 @@ public class TaxiModel {
|
||||
return;
|
||||
}
|
||||
final String orderNo = mCurrentOCHOrder.orderNo;
|
||||
TaxiServiceManager.getInstance().queryOrderById(mContext, orderNo,
|
||||
new TaxiServiceCallback<OrderQueryRespBean>() {
|
||||
TaxiServiceManager.queryOrderById(mContext, orderNo,
|
||||
new OchCommonServiceCallback<OrderQueryRespBean>() {
|
||||
@Override
|
||||
public void onSuccess(OrderQueryRespBean data) {
|
||||
if (data != null && data.data != null
|
||||
@@ -407,8 +407,8 @@ public class TaxiModel {
|
||||
return;
|
||||
}
|
||||
final String orderNo = mCurrentOCHOrder.orderNo;
|
||||
TaxiServiceManager.getInstance().cancelOrder(mContext, orderNo, reasonType, reason,
|
||||
new TaxiServiceCallback<BaseData>() {
|
||||
TaxiServiceManager.cancelOrder(mContext, orderNo, reasonType, reason,
|
||||
new OchCommonServiceCallback<BaseData>() {
|
||||
@Override
|
||||
public void onSuccess(BaseData data) {
|
||||
if (null != data && 0 == data.code
|
||||
@@ -439,8 +439,8 @@ public class TaxiModel {
|
||||
|
||||
// 取消待服务中订单
|
||||
public void cancelOrderById(final String orderNo, int reasonType, String reason) {
|
||||
TaxiServiceManager.getInstance().cancelOrder(mContext, orderNo, reasonType, reason,
|
||||
new TaxiServiceCallback<BaseData>() {
|
||||
TaxiServiceManager.cancelOrder(mContext, orderNo, reasonType, reason,
|
||||
new OchCommonServiceCallback<BaseData>() {
|
||||
@Override
|
||||
public void onSuccess(BaseData data) {
|
||||
if (null != data && 0 == data.code) {
|
||||
@@ -472,8 +472,8 @@ public class TaxiModel {
|
||||
return;
|
||||
}
|
||||
final String orderNo = mCurrentOCHOrder.orderNo;
|
||||
TaxiServiceManager.getInstance().queryOrderRouteInfo(mContext, orderNo,
|
||||
new TaxiServiceCallback<OrderQueryRouteInfoRespBean>() {
|
||||
TaxiServiceManager.queryOrderRouteInfo(mContext, orderNo,
|
||||
new OchCommonServiceCallback<OrderQueryRouteInfoRespBean>() {
|
||||
@Override
|
||||
public void onSuccess(OrderQueryRouteInfoRespBean data) {
|
||||
if (null != data && 0 == data.code
|
||||
@@ -493,8 +493,8 @@ public class TaxiModel {
|
||||
|
||||
// 获取全部订单列表
|
||||
public void queryOrdersList(int page, int size) {
|
||||
TaxiServiceManager.getInstance().queryOrdersList(mContext, page, size,
|
||||
new TaxiServiceCallback<OrdersListQueryRespBean>() {
|
||||
TaxiServiceManager.queryOrdersList(mContext, page, size,
|
||||
new OchCommonServiceCallback<OrdersListQueryRespBean>() {
|
||||
@Override
|
||||
public void onSuccess(OrdersListQueryRespBean data) {
|
||||
if (null != data && 0 == data.code) {
|
||||
@@ -526,8 +526,8 @@ public class TaxiModel {
|
||||
* 注:只有在本地缓存mNewBookingOrder为null时(执行完抢单or司机关闭改单),才更新新到待抢单
|
||||
*/
|
||||
public void queryNewBookingOrder() {
|
||||
TaxiServiceManager.getInstance().queryNewBookingOrder(mContext,
|
||||
new TaxiServiceCallback<OrdersNewBookingQueryRespBean>() {
|
||||
TaxiServiceManager.queryNewBookingOrder(mContext,
|
||||
new OchCommonServiceCallback<OrdersNewBookingQueryRespBean>() {
|
||||
@Override
|
||||
public void onSuccess(OrdersNewBookingQueryRespBean data) {
|
||||
if (data != null && data.code == 0
|
||||
@@ -554,8 +554,8 @@ public class TaxiModel {
|
||||
|
||||
// 仅限于获取到新待抢单且需要展示时查询该单信息:(queryOrderById接口可以查询属于该车的单、未派的单)
|
||||
private void queryNewBookingContent(final String orderNo) {
|
||||
TaxiServiceManager.getInstance().queryOrderById(mContext, orderNo,
|
||||
new TaxiServiceCallback<OrderQueryRespBean>() {
|
||||
TaxiServiceManager.queryOrderById(mContext, orderNo,
|
||||
new OchCommonServiceCallback<OrderQueryRespBean>() {
|
||||
@Override
|
||||
public void onSuccess(OrderQueryRespBean data) {
|
||||
if (data != null && data.code == 0
|
||||
@@ -585,8 +585,8 @@ public class TaxiModel {
|
||||
return;
|
||||
}
|
||||
final String orderNo = mNewBookingOrder.orderNo;
|
||||
TaxiServiceManager.getInstance().grabOrder(mContext, orderNo,
|
||||
new TaxiServiceCallback<OrderGrabRespBean>() {
|
||||
TaxiServiceManager.grabOrder(mContext, orderNo,
|
||||
new OchCommonServiceCallback<OrderGrabRespBean>() {
|
||||
@Override
|
||||
public void onSuccess(OrderGrabRespBean data) {
|
||||
if (data != null && data.code == 0
|
||||
@@ -624,8 +624,8 @@ public class TaxiModel {
|
||||
return;
|
||||
}
|
||||
final String orderNo = mNewBookingOrder.orderNo;
|
||||
TaxiServiceManager.getInstance().queryOrderGrabStatus(mContext, orderNo,
|
||||
new TaxiServiceCallback<OrderGrabStatusQueryRespBean>() {
|
||||
TaxiServiceManager.queryOrderGrabStatus(mContext, orderNo,
|
||||
new OchCommonServiceCallback<OrderGrabStatusQueryRespBean>() {
|
||||
@Override
|
||||
public void onSuccess(OrderGrabStatusQueryRespBean data) {
|
||||
//TaxiModelLoopManager.getInstance().stopGrabResultLoop();
|
||||
@@ -663,8 +663,8 @@ public class TaxiModel {
|
||||
|
||||
// 车机端上传心跳数据(只在出车状态时上传)
|
||||
public void runCarHeartbeat() {
|
||||
TaxiServiceManager.getInstance().runCarHeartbeat(mContext, mLongitude, mLatitude,
|
||||
new TaxiServiceCallback<BaseData>() {
|
||||
TaxiServiceManager.runCarHeartbeat(mContext, mLongitude, mLatitude,
|
||||
new OchCommonServiceCallback<BaseData>() {
|
||||
@Override
|
||||
public void onSuccess(BaseData data) {
|
||||
|
||||
@@ -679,8 +679,8 @@ public class TaxiModel {
|
||||
|
||||
// 查询司机服务数据
|
||||
public void queryDriverServiceData() {
|
||||
TaxiServiceManager.getInstance().queryDriverServiceData(mContext,
|
||||
new TaxiServiceCallback<DriverServiceDataRespBean>() {
|
||||
TaxiServiceManager.queryDriverServiceData(mContext,
|
||||
new OchCommonServiceCallback<DriverServiceDataRespBean>() {
|
||||
@Override
|
||||
public void onSuccess(DriverServiceDataRespBean data) {
|
||||
if (data != null && data.code == 0
|
||||
@@ -716,10 +716,10 @@ public class TaxiModel {
|
||||
TaxiOrPassengerReadyReqBean.Result result = new TaxiOrPassengerReadyReqBean.Result();
|
||||
result.lat = mLatitude;
|
||||
result.lon = mLongitude;
|
||||
TaxiServiceManager.getInstance().confirmAutopilotConditionByDriver(mContext,
|
||||
TaxiServiceManager.confirmAutopilotConditionByDriver(mContext,
|
||||
mCurrentOCHOrder.orderNo,
|
||||
result,
|
||||
new TaxiServiceCallback<TaxiDataBaseRespBean>(){
|
||||
new OchCommonServiceCallback<TaxiDataBaseRespBean>(){
|
||||
|
||||
@Override
|
||||
public void onSuccess(TaxiDataBaseRespBean data) {
|
||||
@@ -747,8 +747,8 @@ public class TaxiModel {
|
||||
|
||||
public void queryAutopilotStatus(){
|
||||
if (mCurrentOCHOrder == null) return;
|
||||
TaxiServiceManager.getInstance().queryAutopilotStatus(mContext, mCurrentOCHOrder.orderNo,
|
||||
new TaxiServiceCallback<TaxiDataBaseRespBean>() {
|
||||
TaxiServiceManager.queryAutopilotStatus(mContext, mCurrentOCHOrder.orderNo,
|
||||
new OchCommonServiceCallback<TaxiDataBaseRespBean>() {
|
||||
@Override
|
||||
public void onSuccess(TaxiDataBaseRespBean data) {
|
||||
if (data != null && data.code == 0)
|
||||
@@ -1257,8 +1257,8 @@ public class TaxiModel {
|
||||
public void updateOrderRoute(List<MessagePad.Location> models) {
|
||||
if (null == mCurrentOCHOrder) return;
|
||||
List<OrderRouteUpdateReqBean.Result> points = coordinateConverterWgsToGcjList(mContext, models);
|
||||
TaxiServiceManager.getInstance().updateOrderRoute(mContext, mCurrentOCHOrder.orderNo
|
||||
, points, new TaxiServiceCallback<BaseData>() {
|
||||
TaxiServiceManager.updateOrderRoute(mContext, mCurrentOCHOrder.orderNo
|
||||
, points, new OchCommonServiceCallback<BaseData>() {
|
||||
@Override
|
||||
public void onSuccess(BaseData data) {
|
||||
|
||||
@@ -1368,8 +1368,8 @@ public class TaxiModel {
|
||||
*/
|
||||
private void queryOrderRouteList(String orderNo) {
|
||||
if (mCurrentOCHOrder != null) {
|
||||
TaxiServiceManager.getInstance().queryOrderRoute(mContext, orderNo,
|
||||
new TaxiServiceCallback<QueryOrderRouteResp>() {
|
||||
TaxiServiceManager.queryOrderRoute(mContext, orderNo,
|
||||
new OchCommonServiceCallback<QueryOrderRouteResp>() {
|
||||
@Override
|
||||
public void onSuccess(QueryOrderRouteResp data) {
|
||||
if (data != null && data.data != null && mRoutePoints.size() == 0) {
|
||||
@@ -1414,8 +1414,8 @@ public class TaxiModel {
|
||||
*/
|
||||
private void reportOrderRemain(long lastSumLength, long duration) {// 米/分钟
|
||||
if (mCurrentOCHOrder == null) return;
|
||||
TaxiServiceManager.getInstance().reportOrderRemain(mContext, mCurrentOCHOrder.orderNo
|
||||
, lastSumLength, duration, new TaxiServiceCallback<BaseData>() {
|
||||
TaxiServiceManager.reportOrderRemain(mContext, mCurrentOCHOrder.orderNo
|
||||
, lastSumLength, duration, new OchCommonServiceCallback<BaseData>() {
|
||||
@Override
|
||||
public void onSuccess(BaseData data) {
|
||||
|
||||
@@ -1440,10 +1440,10 @@ public class TaxiModel {
|
||||
TaxiOrPassengerReadyReqBean.Result result = new TaxiOrPassengerReadyReqBean.Result();
|
||||
result.lat = mLatitude;
|
||||
result.lon = mLongitude;
|
||||
TaxiServiceManager.getInstance().updatePassengerHasBoardedStatus(mContext
|
||||
TaxiServiceManager.updatePassengerHasBoardedStatus(mContext
|
||||
, mCurrentOCHOrder.orderNo
|
||||
, result
|
||||
, new TaxiServiceCallback<TaxiDataBaseRespBean>() {
|
||||
, new OchCommonServiceCallback<TaxiDataBaseRespBean>() {
|
||||
@Override
|
||||
public void onSuccess(TaxiDataBaseRespBean data) {
|
||||
|
||||
@@ -1462,10 +1462,10 @@ public class TaxiModel {
|
||||
TaxiOrPassengerReadyReqBean.Result result = new TaxiOrPassengerReadyReqBean.Result();
|
||||
result.lat = mLatitude;
|
||||
result.lon = mLongitude;
|
||||
TaxiServiceManager.getInstance().startServicePilotDone(mContext
|
||||
TaxiServiceManager.startServicePilotDone(mContext
|
||||
, mCurrentOCHOrder.orderNo
|
||||
, result
|
||||
, new TaxiServiceCallback<TaxiDataBaseRespBean>() {
|
||||
, new OchCommonServiceCallback<TaxiDataBaseRespBean>() {
|
||||
@Override
|
||||
public void onSuccess(TaxiDataBaseRespBean data) {
|
||||
|
||||
@@ -1482,10 +1482,10 @@ public class TaxiModel {
|
||||
TaxiOrPassengerReadyReqBean.Result result = new TaxiOrPassengerReadyReqBean.Result();
|
||||
result.lat = mLatitude;
|
||||
result.lon = mLongitude;
|
||||
TaxiServiceManager.getInstance().arrivedStartPoint(mContext
|
||||
TaxiServiceManager.arrivedStartPoint(mContext
|
||||
, mCurrentOCHOrder.orderNo
|
||||
, result
|
||||
, new TaxiServiceCallback<TaxiDataBaseRespBean>() {
|
||||
, new OchCommonServiceCallback<TaxiDataBaseRespBean>() {
|
||||
@Override
|
||||
public void onSuccess(TaxiDataBaseRespBean data) {
|
||||
|
||||
@@ -1503,10 +1503,10 @@ public class TaxiModel {
|
||||
TaxiOrPassengerReadyReqBean.Result result = new TaxiOrPassengerReadyReqBean.Result();
|
||||
result.lat = mLatitude;
|
||||
result.lon = mLongitude;
|
||||
TaxiServiceManager.getInstance().arriveTerminal(mContext
|
||||
TaxiServiceManager.arriveTerminal(mContext
|
||||
, mCurrentOCHOrder.orderNo
|
||||
, result
|
||||
, new TaxiServiceCallback<TaxiDataBaseRespBean>() {
|
||||
, new OchCommonServiceCallback<TaxiDataBaseRespBean>() {
|
||||
@Override
|
||||
public void onSuccess(TaxiDataBaseRespBean data) {
|
||||
|
||||
@@ -1524,10 +1524,10 @@ public class TaxiModel {
|
||||
TaxiOrPassengerReadyReqBean.Result result = new TaxiOrPassengerReadyReqBean.Result();
|
||||
result.lat = mLatitude;
|
||||
result.lon = mLongitude;
|
||||
TaxiServiceManager.getInstance().orderCompleted(mContext
|
||||
TaxiServiceManager.orderCompleted(mContext
|
||||
, mCurrentOCHOrder.orderNo
|
||||
, result
|
||||
, new TaxiServiceCallback<TaxiDataBaseRespBean>() {
|
||||
, new OchCommonServiceCallback<TaxiDataBaseRespBean>() {
|
||||
@Override
|
||||
public void onSuccess(TaxiDataBaseRespBean data) {
|
||||
// if (null != data && 0 == data.code){
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
package com.mogo.och.taxi.network;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2021/1/15
|
||||
*
|
||||
* 修改订单状态回调接口
|
||||
*/
|
||||
public interface TaxiServiceCallback< T > {
|
||||
|
||||
void onSuccess(T data);
|
||||
|
||||
void onFail(int code, String msg);
|
||||
|
||||
default void onError() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,463 +0,0 @@
|
||||
package com.mogo.och.taxi.network;
|
||||
|
||||
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_TAXI;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
|
||||
import com.mogo.eagle.core.data.BaseData;
|
||||
import com.mogo.eagle.core.network.MoGoRetrofitFactory;
|
||||
import com.mogo.eagle.core.network.RequestOptions;
|
||||
import com.mogo.eagle.core.network.SubscribeImpl;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.och.taxi.bean.CarHeartbeatReqBean;
|
||||
import com.mogo.och.taxi.bean.DriverServiceDataRespBean;
|
||||
import com.mogo.och.taxi.bean.DriverStatusUpdateReqBean;
|
||||
import com.mogo.och.taxi.bean.OrderCancelReqBean;
|
||||
import com.mogo.och.taxi.bean.OrderGrabReqBean;
|
||||
import com.mogo.och.taxi.bean.OrderGrabRespBean;
|
||||
import com.mogo.och.taxi.bean.OrderGrabStatusQueryRespBean;
|
||||
import com.mogo.och.taxi.bean.OrderQueryReqBean;
|
||||
import com.mogo.och.taxi.bean.OrderQueryRespBean;
|
||||
import com.mogo.och.taxi.bean.OrderQueryRouteInfoReqBean;
|
||||
import com.mogo.och.taxi.bean.OrderQueryRouteInfoRespBean;
|
||||
import com.mogo.och.taxi.bean.OrderRouteUpdateReqBean;
|
||||
import com.mogo.och.taxi.bean.OrderStatusUpdateReqBean;
|
||||
import com.mogo.och.taxi.bean.OrdersInServiceQueryRespBean;
|
||||
import com.mogo.och.taxi.bean.OrdersListQueryReqBean;
|
||||
import com.mogo.och.taxi.bean.OrdersListQueryRespBean;
|
||||
import com.mogo.och.taxi.bean.OrdersNewBookingQueryRespBean;
|
||||
import com.mogo.och.taxi.bean.QueryOrderRouteResp;
|
||||
import com.mogo.och.taxi.bean.TaxiDataBaseRespBean;
|
||||
import com.mogo.och.taxi.bean.TaxiOrPassengerReadyReqBean;
|
||||
import com.mogo.och.taxi.bean.UpdateOrderDisAndTimeReqBean;
|
||||
import com.mogo.och.taxi.constant.TaxiConst;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
/**
|
||||
* Created by pangfan on 2021/8/19
|
||||
*/
|
||||
public class TaxiServiceManager {
|
||||
private static final String TAG = TaxiServiceManager.class.getSimpleName();
|
||||
|
||||
private static final class SingletonHolder {
|
||||
private static final TaxiServiceManager INSTANCE = new TaxiServiceManager();
|
||||
}
|
||||
|
||||
public static TaxiServiceManager getInstance() {
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private TaxiServiceApiNew mOCHTaxiServiceApi;
|
||||
|
||||
private TaxiServiceManager() {
|
||||
if (mOCHTaxiServiceApi == null){
|
||||
mOCHTaxiServiceApi = MoGoRetrofitFactory.getInstance(TaxiConst.getBaseUrl()).create(TaxiServiceApiNew.class);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询全部服务中/待服务订单列表
|
||||
* @param context
|
||||
* @param callback
|
||||
*/
|
||||
public void queryOrdersInAndWaitService(Context context,
|
||||
TaxiServiceCallback<OrdersInServiceQueryRespBean> callback) {
|
||||
mOCHTaxiServiceApi.queryOrdersInAndWaitService(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
|
||||
,MoGoAiCloudClientConfig.getInstance().getToken()
|
||||
,MoGoAiCloudClientConfig.getInstance().getSn())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(getSubscribeImpl(context, callback, "queryOrdersInAndWaitService"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询新到的预约单
|
||||
* @param context
|
||||
* @param callback
|
||||
*/
|
||||
public void queryNewBookingOrder(Context context,
|
||||
TaxiServiceCallback<OrdersNewBookingQueryRespBean> callback) {
|
||||
mOCHTaxiServiceApi.queryNewBookingOrder(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
|
||||
,MoGoAiCloudClientConfig.getInstance().getToken()
|
||||
,MoGoAiCloudClientConfig.getInstance().getSn())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(getSubscribeImpl(context, callback, "queryNewBookingOrder"));
|
||||
}
|
||||
|
||||
/**
|
||||
* (预约单)执行抢单动作
|
||||
* @param context
|
||||
* @param orderNo
|
||||
* @param callback
|
||||
*/
|
||||
public void grabOrder(Context context, String orderNo,
|
||||
TaxiServiceCallback<OrderGrabRespBean> callback) {
|
||||
mOCHTaxiServiceApi.grabOrder(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
|
||||
,MoGoAiCloudClientConfig.getInstance().getToken()
|
||||
,new OrderGrabReqBean(
|
||||
MoGoAiCloudClientConfig.getInstance().getSn(), orderNo))
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(getSubscribeImpl(context, callback, "grabOrder"));
|
||||
}
|
||||
|
||||
/**
|
||||
* (预约单)查询抢单结果
|
||||
* @param context
|
||||
* @param orderNo
|
||||
* @param callback
|
||||
*/
|
||||
public void queryOrderGrabStatus(Context context, String orderNo,
|
||||
TaxiServiceCallback<OrderGrabStatusQueryRespBean> callback) {
|
||||
mOCHTaxiServiceApi.queryOrderGrabStatus(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
|
||||
,MoGoAiCloudClientConfig.getInstance().getToken()
|
||||
,new OrderGrabReqBean(
|
||||
MoGoAiCloudClientConfig.getInstance().getSn(), orderNo))
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(getSubscribeImpl(context, callback, "queryOrderGrabStatus"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询订单路径规划信息(到上车点、起始点间的距离和预估时间)
|
||||
* @param context
|
||||
* @param orderNo
|
||||
* @param callback
|
||||
*/
|
||||
public void queryOrderRouteInfo(Context context, String orderNo,
|
||||
TaxiServiceCallback<OrderQueryRouteInfoRespBean> callback) {
|
||||
mOCHTaxiServiceApi.queryOrderRouteInfo(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
|
||||
,MoGoAiCloudClientConfig.getInstance().getToken()
|
||||
,new OrderQueryRouteInfoReqBean(
|
||||
MoGoAiCloudClientConfig.getInstance().getSn(), orderNo))
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(getSubscribeImpl(context, callback, "queryOrderRouteInfo"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过orderId查询订单信息(用于本地已经有orderId时)
|
||||
* @param context
|
||||
* @param orderNo
|
||||
* @param callback
|
||||
* @deprecated v2.1_0930需求中暂不再使用此接口
|
||||
*/
|
||||
public void queryOrderById(Context context, String orderNo,
|
||||
TaxiServiceCallback<OrderQueryRespBean> callback) {
|
||||
mOCHTaxiServiceApi.queryOrderById(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
|
||||
,MoGoAiCloudClientConfig.getInstance().getToken()
|
||||
,new OrderQueryReqBean(
|
||||
MoGoAiCloudClientConfig.getInstance().getSn(), orderNo))
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(getSubscribeImpl(context, callback, "queryOrderById"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询未完成态订单信息(用于本地无orderId时)
|
||||
* 如果有多条,只会返回时间最近的一条
|
||||
* @param context
|
||||
* @param callback
|
||||
* @deprecated v2.1_0930需求中暂不再使用此接口
|
||||
*/
|
||||
public void queryOrderInService(Context context,
|
||||
TaxiServiceCallback<OrderQueryRespBean> callback) {
|
||||
mOCHTaxiServiceApi.queryOrderInService(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
|
||||
,MoGoAiCloudClientConfig.getInstance().getToken()
|
||||
,MoGoAiCloudClientConfig.getInstance().getSn())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(getSubscribeImpl(context, callback, "queryOrderInService"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 司机取消订单
|
||||
* @param context
|
||||
* @param orderNo
|
||||
* @param cancelType
|
||||
* @param cancelReason
|
||||
* @param callback
|
||||
*/
|
||||
public void cancelOrder(Context context, String orderNo, int cancelType, String cancelReason,
|
||||
TaxiServiceCallback<BaseData> callback) {
|
||||
mOCHTaxiServiceApi.cancelOrder(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
|
||||
,MoGoAiCloudClientConfig.getInstance().getToken()
|
||||
,new OrderCancelReqBean(
|
||||
MoGoAiCloudClientConfig.getInstance().getSn(), orderNo, cancelType, cancelReason))
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(getSubscribeImpl(context, callback, "cancelOrder"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单列表获取
|
||||
* @param context
|
||||
* @param page
|
||||
* @param size
|
||||
* @param callback
|
||||
*/
|
||||
public void queryOrdersList(Context context, int page, int size,
|
||||
TaxiServiceCallback<OrdersListQueryRespBean> callback) {
|
||||
mOCHTaxiServiceApi.queryOrdersList(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
|
||||
,MoGoAiCloudClientConfig.getInstance().getToken()
|
||||
,new OrdersListQueryReqBean(
|
||||
MoGoAiCloudClientConfig.getInstance().getSn(), page, size))
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(getSubscribeImpl(context, callback, "queryOrdersList"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单状态更新
|
||||
* @param context
|
||||
* @param orderNo
|
||||
* @param orderStatus
|
||||
* @param callback
|
||||
*/
|
||||
public void updateOrderStatus(Context context, String orderNo, int orderStatus,
|
||||
TaxiServiceCallback<BaseData> callback) {
|
||||
mOCHTaxiServiceApi.updateOrderStatus(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
|
||||
,MoGoAiCloudClientConfig.getInstance().getToken()
|
||||
,new OrderStatusUpdateReqBean(
|
||||
MoGoAiCloudClientConfig.getInstance().getSn(), orderNo, orderStatus))
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(getSubscribeImpl(context, callback, "updateOrderStatus"));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 暂停接单
|
||||
* @param context
|
||||
* @param callback
|
||||
*/
|
||||
public void changeOrderServing(Context context,boolean isOrdering,
|
||||
TaxiServiceCallback<BaseData> callback) {
|
||||
Observable<BaseData> baseDataObservable = null;
|
||||
if(isOrdering) {// 正在接单去暂停
|
||||
baseDataObservable = mOCHTaxiServiceApi.stopOrderServing(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
|
||||
, MoGoAiCloudClientConfig.getInstance().getToken()
|
||||
, new DriverStatusUpdateReqBean(
|
||||
MoGoAiCloudClientConfig.getInstance().getSn()));
|
||||
}else {// 没有接单去接单
|
||||
baseDataObservable = mOCHTaxiServiceApi.resetOrderServing(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
|
||||
, MoGoAiCloudClientConfig.getInstance().getToken()
|
||||
, new DriverStatusUpdateReqBean(
|
||||
MoGoAiCloudClientConfig.getInstance().getSn()));
|
||||
}
|
||||
baseDataObservable.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(getSubscribeImpl(context, callback, "updateDriverServiceStatus"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 车机端上传心跳数据(只在出车状态时上传):包含高德坐标系经纬度
|
||||
* @param context
|
||||
* @param lon
|
||||
* @param lat
|
||||
* @param callback
|
||||
*/
|
||||
public void runCarHeartbeat(Context context, double lon, double lat,
|
||||
TaxiServiceCallback<BaseData> callback) {
|
||||
mOCHTaxiServiceApi.runCarHeartbeat(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
|
||||
,MoGoAiCloudClientConfig.getInstance().getToken()
|
||||
,new CarHeartbeatReqBean(
|
||||
MoGoAiCloudClientConfig.getInstance().getSn(), lon, lat))
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(getSubscribeImpl(context, callback, "runCarHeartbeat"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询司机服务数据
|
||||
* @param context
|
||||
* @param callback
|
||||
*/
|
||||
public void queryDriverServiceData(Context context,
|
||||
TaxiServiceCallback<DriverServiceDataRespBean> callback) {
|
||||
mOCHTaxiServiceApi.queryServiceData(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
|
||||
,MoGoAiCloudClientConfig.getInstance().getToken()
|
||||
,MoGoAiCloudClientConfig.getInstance().getSn())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(getSubscribeImpl(context, callback, "queryDriverServiceData"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据订单上传工控机返回的全路径规划数据
|
||||
* @param context
|
||||
* @param orderNo
|
||||
* @param callback
|
||||
*/
|
||||
public void updateOrderRoute(Context context, String orderNo, List<OrderRouteUpdateReqBean.Result> points,
|
||||
TaxiServiceCallback<BaseData> callback){
|
||||
mOCHTaxiServiceApi.updateOrderRoute(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
|
||||
,MoGoAiCloudClientConfig.getInstance().getToken()
|
||||
,new OrderRouteUpdateReqBean(orderNo,points))
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(getSubscribeImpl(context,callback,"updateOrderRoute"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 上报剩余里程,时间
|
||||
* @param context
|
||||
* @param orderNo
|
||||
* @param distance
|
||||
* @param duration
|
||||
* @param callback
|
||||
*/
|
||||
public void reportOrderRemain(Context context, String orderNo, long distance, long duration
|
||||
, TaxiServiceCallback<BaseData> callback){
|
||||
|
||||
mOCHTaxiServiceApi.reportOrderRemain(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
|
||||
,MoGoAiCloudClientConfig.getInstance().getToken()
|
||||
,new UpdateOrderDisAndTimeReqBean(orderNo,distance,duration))
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(getSubscribeImpl(context,callback,"reportOrderRemain"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询订单全路径
|
||||
* @param context
|
||||
* @param orderNo
|
||||
* @param callback
|
||||
*/
|
||||
public void queryOrderRoute(Context context, String orderNo, TaxiServiceCallback<QueryOrderRouteResp> callback) {
|
||||
mOCHTaxiServiceApi.queryOrderRoute(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
|
||||
,MoGoAiCloudClientConfig.getInstance().getToken()
|
||||
,orderNo)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(getSubscribeImpl(context,callback,"queryOrderRoute"));
|
||||
}
|
||||
|
||||
public void confirmAutopilotConditionByDriver(Context context, String orderNo
|
||||
, TaxiOrPassengerReadyReqBean.Result loc
|
||||
, TaxiServiceCallback<TaxiDataBaseRespBean> callback){
|
||||
mOCHTaxiServiceApi.confirmAutopilotConditionByDriver(
|
||||
MoGoAiCloudClientConfig.getInstance().getServiceAppId()
|
||||
,MoGoAiCloudClientConfig.getInstance().getToken()
|
||||
,new TaxiOrPassengerReadyReqBean(MoGoAiCloudClientConfig.getInstance().getSn()
|
||||
,orderNo,loc))
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(getSubscribeImpl(context,callback,"confirmAutopilotConditionByDriver"));
|
||||
}
|
||||
|
||||
public void queryAutopilotStatus(Context context, String orderNo,
|
||||
TaxiServiceCallback<TaxiDataBaseRespBean> callback){
|
||||
mOCHTaxiServiceApi.queryPilotStatus(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
|
||||
,MoGoAiCloudClientConfig.getInstance().getToken()
|
||||
,orderNo)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(getSubscribeImpl(context,callback,"queryAutopilotStatus"));
|
||||
}
|
||||
|
||||
public void updatePassengerHasBoardedStatus(Context context, String orderNo
|
||||
, TaxiOrPassengerReadyReqBean.Result loc
|
||||
, TaxiServiceCallback<TaxiDataBaseRespBean> callback){
|
||||
|
||||
mOCHTaxiServiceApi.updatePassengerHasBoardedStatus(
|
||||
MoGoAiCloudClientConfig.getInstance().getServiceAppId()
|
||||
,MoGoAiCloudClientConfig.getInstance().getToken()
|
||||
,new TaxiOrPassengerReadyReqBean(MoGoAiCloudClientConfig.getInstance().getSn()
|
||||
,orderNo,loc))
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(getSubscribeImpl(context, callback, "updatePassengerHasBoardedStatus"));
|
||||
}
|
||||
|
||||
public void startServicePilotDone(Context context, String orderNo
|
||||
, TaxiOrPassengerReadyReqBean.Result loc
|
||||
, TaxiServiceCallback<TaxiDataBaseRespBean> callback){
|
||||
mOCHTaxiServiceApi.startServicePilotDone(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
|
||||
,MoGoAiCloudClientConfig.getInstance().getToken()
|
||||
,new TaxiOrPassengerReadyReqBean(MoGoAiCloudClientConfig.getInstance().getSn()
|
||||
,orderNo,loc))
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(getSubscribeImpl(context, callback, "startServicePilotDone"));
|
||||
}
|
||||
|
||||
public void arrivedStartPoint(Context context, String orderNo
|
||||
, TaxiOrPassengerReadyReqBean.Result loc
|
||||
, TaxiServiceCallback<TaxiDataBaseRespBean> callback){
|
||||
mOCHTaxiServiceApi.arrivedStartPoint(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
|
||||
,MoGoAiCloudClientConfig.getInstance().getToken()
|
||||
,new TaxiOrPassengerReadyReqBean(MoGoAiCloudClientConfig.getInstance().getSn()
|
||||
,orderNo,loc))
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(getSubscribeImpl(context, callback, "arrivedStartPoint"));
|
||||
|
||||
}
|
||||
|
||||
public void arriveTerminal(Context context, String orderNo
|
||||
, TaxiOrPassengerReadyReqBean.Result loc
|
||||
, TaxiServiceCallback<TaxiDataBaseRespBean> callback){
|
||||
mOCHTaxiServiceApi.arriveTerminal(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
|
||||
,MoGoAiCloudClientConfig.getInstance().getToken()
|
||||
,new TaxiOrPassengerReadyReqBean(MoGoAiCloudClientConfig.getInstance().getSn()
|
||||
,orderNo,loc))
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(getSubscribeImpl(context, callback, "arriveTerminal"));
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void orderCompleted(Context context, String orderNo
|
||||
, TaxiOrPassengerReadyReqBean.Result loc
|
||||
, TaxiServiceCallback<TaxiDataBaseRespBean> callback){
|
||||
mOCHTaxiServiceApi.orderCompleted(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
|
||||
,MoGoAiCloudClientConfig.getInstance().getToken()
|
||||
,new TaxiOrPassengerReadyReqBean(MoGoAiCloudClientConfig.getInstance().getSn()
|
||||
,orderNo,loc))
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(getSubscribeImpl(context, callback, "orderCompleted"));
|
||||
|
||||
}
|
||||
|
||||
private <T extends BaseData> SubscribeImpl getSubscribeImpl(
|
||||
Context context, TaxiServiceCallback<T> callback, String apiName) {
|
||||
return new SubscribeImpl<T>(RequestOptions.create(context)) {
|
||||
@Override
|
||||
public void onSuccess(T o) {
|
||||
super.onSuccess(o);
|
||||
CallerLogger.INSTANCE.d(M_TAXI + TAG,apiName + ": onSuccess() " + o.msg);
|
||||
if (callback != null) {
|
||||
callback.onSuccess(o);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
super.onError(e);
|
||||
CallerLogger.INSTANCE.e(M_TAXI + TAG,apiName + ": onError() " + e.getMessage());
|
||||
if (callback != null) {
|
||||
callback.onError();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String message, int code) {
|
||||
super.onError(message, code);
|
||||
CallerLogger.INSTANCE.e(M_TAXI + TAG,String.format(apiName + ": onError() code = %d; message = %s;", code, message));
|
||||
if (callback != null) {
|
||||
callback.onFail(code, message);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,497 @@
|
||||
package com.mogo.och.taxi.network
|
||||
|
||||
import android.content.Context
|
||||
import com.mogo.och.taxi.constant.TaxiConst.Companion.getBaseUrl
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig
|
||||
import com.mogo.eagle.core.data.BaseData
|
||||
import com.mogo.eagle.core.network.MoGoRetrofitFactory
|
||||
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.taxi.bean.*
|
||||
import io.reactivex.Observable
|
||||
|
||||
/**
|
||||
* Created by pangfan on 2021/8/19
|
||||
*/
|
||||
object TaxiServiceManager {
|
||||
|
||||
|
||||
private var mOCHTaxiServiceApi: TaxiServiceApiNew =
|
||||
MoGoRetrofitFactory.getInstance(getBaseUrl()).create(
|
||||
TaxiServiceApiNew::class.java
|
||||
)
|
||||
|
||||
/**
|
||||
* 查询全部服务中/待服务订单列表
|
||||
* @param context
|
||||
* @param callback
|
||||
*/
|
||||
@JvmStatic
|
||||
fun queryOrdersInAndWaitService(
|
||||
context: Context,
|
||||
callback: OchCommonServiceCallback<OrdersInServiceQueryRespBean>?
|
||||
) {
|
||||
mOCHTaxiServiceApi.queryOrdersInAndWaitService(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
MoGoAiCloudClientConfig.getInstance().token,
|
||||
MoGoAiCloudClientConfig.getInstance().sn
|
||||
)
|
||||
.transformTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "queryOrdersInAndWaitService"))
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询新到的预约单
|
||||
* @param context
|
||||
* @param callback
|
||||
*/
|
||||
@JvmStatic
|
||||
fun queryNewBookingOrder(
|
||||
context: Context,
|
||||
callback: OchCommonServiceCallback<OrdersNewBookingQueryRespBean>?
|
||||
) {
|
||||
mOCHTaxiServiceApi.queryNewBookingOrder(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
MoGoAiCloudClientConfig.getInstance().token,
|
||||
MoGoAiCloudClientConfig.getInstance().sn
|
||||
)
|
||||
.transformTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "queryNewBookingOrder"))
|
||||
}
|
||||
|
||||
/**
|
||||
* (预约单)执行抢单动作
|
||||
* @param context
|
||||
* @param orderNo
|
||||
* @param callback
|
||||
*/
|
||||
@JvmStatic
|
||||
fun grabOrder(
|
||||
context: Context, orderNo: String?,
|
||||
callback: OchCommonServiceCallback<OrderGrabRespBean>?
|
||||
) {
|
||||
mOCHTaxiServiceApi.grabOrder(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
MoGoAiCloudClientConfig.getInstance().token,
|
||||
OrderGrabReqBean(
|
||||
MoGoAiCloudClientConfig.getInstance().sn, orderNo
|
||||
)
|
||||
)
|
||||
.transformTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "grabOrder"))
|
||||
}
|
||||
|
||||
/**
|
||||
* (预约单)查询抢单结果
|
||||
* @param context
|
||||
* @param orderNo
|
||||
* @param callback
|
||||
*/
|
||||
@JvmStatic
|
||||
fun queryOrderGrabStatus(
|
||||
context: Context, orderNo: String?,
|
||||
callback: OchCommonServiceCallback<OrderGrabStatusQueryRespBean>?
|
||||
) {
|
||||
mOCHTaxiServiceApi.queryOrderGrabStatus(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
MoGoAiCloudClientConfig.getInstance().token,
|
||||
OrderGrabReqBean(
|
||||
MoGoAiCloudClientConfig.getInstance().sn, orderNo
|
||||
)
|
||||
)
|
||||
.transformTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "queryOrderGrabStatus"))
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询订单路径规划信息(到上车点、起始点间的距离和预估时间)
|
||||
* @param context
|
||||
* @param orderNo
|
||||
* @param callback
|
||||
*/
|
||||
@JvmStatic
|
||||
fun queryOrderRouteInfo(
|
||||
context: Context, orderNo: String?,
|
||||
callback: OchCommonServiceCallback<OrderQueryRouteInfoRespBean>?
|
||||
) {
|
||||
mOCHTaxiServiceApi.queryOrderRouteInfo(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
MoGoAiCloudClientConfig.getInstance().token,
|
||||
OrderQueryRouteInfoReqBean(
|
||||
MoGoAiCloudClientConfig.getInstance().sn, orderNo
|
||||
)
|
||||
)
|
||||
.transformTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "queryOrderRouteInfo"))
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过orderId查询订单信息(用于本地已经有orderId时)
|
||||
* @param context
|
||||
* @param orderNo
|
||||
* @param callback
|
||||
*/
|
||||
@JvmStatic
|
||||
@Deprecated("v2.1_0930需求中暂不再使用此接口")
|
||||
fun queryOrderById(
|
||||
context: Context, orderNo: String?,
|
||||
callback: OchCommonServiceCallback<OrderQueryRespBean>?
|
||||
) {
|
||||
mOCHTaxiServiceApi.queryOrderById(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
MoGoAiCloudClientConfig.getInstance().token,
|
||||
OrderQueryReqBean(
|
||||
MoGoAiCloudClientConfig.getInstance().sn, orderNo
|
||||
)
|
||||
)
|
||||
.transformTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "queryOrderById"))
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询未完成态订单信息(用于本地无orderId时)
|
||||
* 如果有多条,只会返回时间最近的一条
|
||||
* @param context
|
||||
* @param callback
|
||||
*/
|
||||
@JvmStatic
|
||||
@Deprecated("v2.1_0930需求中暂不再使用此接口")
|
||||
fun queryOrderInService(
|
||||
context: Context,
|
||||
callback: OchCommonServiceCallback<OrderQueryRespBean>?
|
||||
) {
|
||||
mOCHTaxiServiceApi.queryOrderInService(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
MoGoAiCloudClientConfig.getInstance().token,
|
||||
MoGoAiCloudClientConfig.getInstance().sn
|
||||
)
|
||||
.transformTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "queryOrderInService"))
|
||||
}
|
||||
|
||||
/**
|
||||
* 司机取消订单
|
||||
* @param context
|
||||
* @param orderNo
|
||||
* @param cancelType
|
||||
* @param cancelReason
|
||||
* @param callback
|
||||
*/
|
||||
@JvmStatic
|
||||
fun cancelOrder(
|
||||
context: Context, orderNo: String?, cancelType: Int, cancelReason: String?,
|
||||
callback: OchCommonServiceCallback<BaseData>?
|
||||
) {
|
||||
mOCHTaxiServiceApi.cancelOrder(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
MoGoAiCloudClientConfig.getInstance().token,
|
||||
OrderCancelReqBean(
|
||||
MoGoAiCloudClientConfig.getInstance().sn, orderNo, cancelType, cancelReason
|
||||
)
|
||||
)
|
||||
.transformTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "cancelOrder"))
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单列表获取
|
||||
* @param context
|
||||
* @param page
|
||||
* @param size
|
||||
* @param callback
|
||||
*/
|
||||
@JvmStatic
|
||||
fun queryOrdersList(
|
||||
context: Context, page: Int, size: Int,
|
||||
callback: OchCommonServiceCallback<OrdersListQueryRespBean>?
|
||||
) {
|
||||
mOCHTaxiServiceApi.queryOrdersList(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
MoGoAiCloudClientConfig.getInstance().token,
|
||||
OrdersListQueryReqBean(
|
||||
MoGoAiCloudClientConfig.getInstance().sn, page, size
|
||||
)
|
||||
)
|
||||
.transformTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "queryOrdersList"))
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单状态更新
|
||||
* @param context
|
||||
* @param orderNo
|
||||
* @param orderStatus
|
||||
* @param callback
|
||||
*/
|
||||
@JvmStatic
|
||||
fun updateOrderStatus(
|
||||
context: Context, orderNo: String?, orderStatus: Int,
|
||||
callback: OchCommonServiceCallback<BaseData>?
|
||||
) {
|
||||
mOCHTaxiServiceApi.updateOrderStatus(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
MoGoAiCloudClientConfig.getInstance().token,
|
||||
OrderStatusUpdateReqBean(
|
||||
MoGoAiCloudClientConfig.getInstance().sn, orderNo, orderStatus
|
||||
)
|
||||
)
|
||||
.transformTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "updateOrderStatus"))
|
||||
}
|
||||
|
||||
/**
|
||||
* 暂停接单
|
||||
* @param context
|
||||
* @param callback
|
||||
*/
|
||||
@JvmStatic
|
||||
fun changeOrderServing(
|
||||
context: Context, isOrdering: Boolean,
|
||||
callback: OchCommonServiceCallback<BaseData>?
|
||||
) {
|
||||
val baseDataObservable: Observable<BaseData> = if (isOrdering) { // 正在接单去暂停
|
||||
mOCHTaxiServiceApi.stopOrderServing(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
MoGoAiCloudClientConfig.getInstance().token,
|
||||
DriverStatusUpdateReqBean(
|
||||
MoGoAiCloudClientConfig.getInstance().sn
|
||||
)
|
||||
).transformTry()
|
||||
} else { // 没有接单去接单
|
||||
mOCHTaxiServiceApi.resetOrderServing(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
MoGoAiCloudClientConfig.getInstance().token,
|
||||
DriverStatusUpdateReqBean(
|
||||
MoGoAiCloudClientConfig.getInstance().sn
|
||||
)
|
||||
).transformTry()
|
||||
}
|
||||
baseDataObservable
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "updateDriverServiceStatus"))
|
||||
}
|
||||
|
||||
/**
|
||||
* 车机端上传心跳数据(只在出车状态时上传):包含高德坐标系经纬度
|
||||
* @param context
|
||||
* @param lon
|
||||
* @param lat
|
||||
* @param callback
|
||||
*/
|
||||
@JvmStatic
|
||||
fun runCarHeartbeat(
|
||||
context: Context, lon: Double, lat: Double,
|
||||
callback: OchCommonServiceCallback<BaseData>?
|
||||
) {
|
||||
mOCHTaxiServiceApi.runCarHeartbeat(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
MoGoAiCloudClientConfig.getInstance().token,
|
||||
CarHeartbeatReqBean(
|
||||
MoGoAiCloudClientConfig.getInstance().sn, lon, lat
|
||||
)
|
||||
)
|
||||
.transformTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "runCarHeartbeat"))
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询司机服务数据
|
||||
* @param context
|
||||
* @param callback
|
||||
*/
|
||||
@JvmStatic
|
||||
fun queryDriverServiceData(
|
||||
context: Context,
|
||||
callback: OchCommonServiceCallback<DriverServiceDataRespBean>?
|
||||
) {
|
||||
mOCHTaxiServiceApi.queryServiceData(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
MoGoAiCloudClientConfig.getInstance().token,
|
||||
MoGoAiCloudClientConfig.getInstance().sn
|
||||
)
|
||||
.transformTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "queryDriverServiceData"))
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据订单上传工控机返回的全路径规划数据
|
||||
* @param context
|
||||
* @param orderNo
|
||||
* @param callback
|
||||
*/
|
||||
@JvmStatic
|
||||
fun updateOrderRoute(
|
||||
context: Context, orderNo: String?, points: List<OrderRouteUpdateReqBean.Result?>?,
|
||||
callback: OchCommonServiceCallback<BaseData>?
|
||||
) {
|
||||
mOCHTaxiServiceApi.updateOrderRoute(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
MoGoAiCloudClientConfig.getInstance().token,
|
||||
OrderRouteUpdateReqBean(orderNo, points)
|
||||
)
|
||||
.transformTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "updateOrderRoute"))
|
||||
}
|
||||
|
||||
/**
|
||||
* 上报剩余里程,时间
|
||||
* @param context
|
||||
* @param orderNo
|
||||
* @param distance
|
||||
* @param duration
|
||||
* @param callback
|
||||
*/
|
||||
@JvmStatic
|
||||
fun reportOrderRemain(
|
||||
context: Context,
|
||||
orderNo: String?,
|
||||
distance: Long,
|
||||
duration: Long,
|
||||
callback: OchCommonServiceCallback<BaseData>?
|
||||
) {
|
||||
mOCHTaxiServiceApi.reportOrderRemain(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
MoGoAiCloudClientConfig.getInstance().token,
|
||||
UpdateOrderDisAndTimeReqBean(orderNo, distance, duration)
|
||||
)
|
||||
.transformTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "reportOrderRemain"))
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询订单全路径
|
||||
* @param context
|
||||
* @param orderNo
|
||||
* @param callback
|
||||
*/
|
||||
@JvmStatic
|
||||
fun queryOrderRoute(
|
||||
context: Context,
|
||||
orderNo: String?,
|
||||
callback: OchCommonServiceCallback<QueryOrderRouteResp>?
|
||||
) {
|
||||
mOCHTaxiServiceApi.queryOrderRoute(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
MoGoAiCloudClientConfig.getInstance().token,
|
||||
orderNo
|
||||
)
|
||||
.transformTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "queryOrderRoute"))
|
||||
}
|
||||
@JvmStatic
|
||||
fun confirmAutopilotConditionByDriver(
|
||||
context: Context,
|
||||
orderNo: String?,
|
||||
loc: TaxiOrPassengerReadyReqBean.Result?,
|
||||
callback: OchCommonServiceCallback<TaxiDataBaseRespBean>?
|
||||
) {
|
||||
mOCHTaxiServiceApi.confirmAutopilotConditionByDriver(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
MoGoAiCloudClientConfig.getInstance().token,
|
||||
TaxiOrPassengerReadyReqBean(
|
||||
MoGoAiCloudClientConfig.getInstance().sn, orderNo, loc
|
||||
)
|
||||
)
|
||||
.transformTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "confirmAutopilotConditionByDriver"))
|
||||
}
|
||||
@JvmStatic
|
||||
fun queryAutopilotStatus(
|
||||
context: Context, orderNo: String?,
|
||||
callback: OchCommonServiceCallback<TaxiDataBaseRespBean>?
|
||||
) {
|
||||
mOCHTaxiServiceApi.queryPilotStatus(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
MoGoAiCloudClientConfig.getInstance().token,
|
||||
orderNo
|
||||
)
|
||||
.transformTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "queryAutopilotStatus"))
|
||||
}
|
||||
@JvmStatic
|
||||
fun updatePassengerHasBoardedStatus(
|
||||
context: Context,
|
||||
orderNo: String?,
|
||||
loc: TaxiOrPassengerReadyReqBean.Result?,
|
||||
callback: OchCommonServiceCallback<TaxiDataBaseRespBean>?
|
||||
) {
|
||||
mOCHTaxiServiceApi.updatePassengerHasBoardedStatus(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
MoGoAiCloudClientConfig.getInstance().token,
|
||||
TaxiOrPassengerReadyReqBean(
|
||||
MoGoAiCloudClientConfig.getInstance().sn, orderNo, loc
|
||||
)
|
||||
)
|
||||
.transformTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "updatePassengerHasBoardedStatus"))
|
||||
}
|
||||
@JvmStatic
|
||||
fun startServicePilotDone(
|
||||
context: Context,
|
||||
orderNo: String?,
|
||||
loc: TaxiOrPassengerReadyReqBean.Result?,
|
||||
callback: OchCommonServiceCallback<TaxiDataBaseRespBean>?
|
||||
) {
|
||||
mOCHTaxiServiceApi.startServicePilotDone(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
MoGoAiCloudClientConfig.getInstance().token,
|
||||
TaxiOrPassengerReadyReqBean(
|
||||
MoGoAiCloudClientConfig.getInstance().sn, orderNo, loc
|
||||
)
|
||||
)
|
||||
.transformTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "startServicePilotDone"))
|
||||
}
|
||||
@JvmStatic
|
||||
fun arrivedStartPoint(
|
||||
context: Context,
|
||||
orderNo: String?,
|
||||
loc: TaxiOrPassengerReadyReqBean.Result?,
|
||||
callback: OchCommonServiceCallback<TaxiDataBaseRespBean>?
|
||||
) {
|
||||
mOCHTaxiServiceApi.arrivedStartPoint(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
MoGoAiCloudClientConfig.getInstance().token,
|
||||
TaxiOrPassengerReadyReqBean(
|
||||
MoGoAiCloudClientConfig.getInstance().sn, orderNo, loc
|
||||
)
|
||||
)
|
||||
.transformTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "arrivedStartPoint"))
|
||||
}
|
||||
@JvmStatic
|
||||
fun arriveTerminal(
|
||||
context: Context,
|
||||
orderNo: String?,
|
||||
loc: TaxiOrPassengerReadyReqBean.Result?,
|
||||
callback: OchCommonServiceCallback<TaxiDataBaseRespBean>
|
||||
) {
|
||||
mOCHTaxiServiceApi.arriveTerminal(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
MoGoAiCloudClientConfig.getInstance().token,
|
||||
TaxiOrPassengerReadyReqBean(
|
||||
MoGoAiCloudClientConfig.getInstance().sn, orderNo, loc
|
||||
)
|
||||
)
|
||||
.transformTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "arriveTerminal"))
|
||||
}
|
||||
@JvmStatic
|
||||
fun orderCompleted(
|
||||
context: Context,
|
||||
orderNo: String?,
|
||||
loc: TaxiOrPassengerReadyReqBean.Result?,
|
||||
callback: OchCommonServiceCallback<TaxiDataBaseRespBean>
|
||||
) {
|
||||
mOCHTaxiServiceApi.orderCompleted(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
MoGoAiCloudClientConfig.getInstance().token,
|
||||
TaxiOrPassengerReadyReqBean(
|
||||
MoGoAiCloudClientConfig.getInstance().sn, orderNo, loc
|
||||
)
|
||||
)
|
||||
.transformTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "orderCompleted"))
|
||||
}
|
||||
|
||||
}
|
||||
@@ -24,7 +24,7 @@ class BusOperationView @JvmOverloads constructor(
|
||||
init {
|
||||
LayoutInflater.from(context).inflate(R.layout.view_och_bus_operation,this,true)
|
||||
context?.let {
|
||||
actvAccountPhone.text = SharedPrefs.getInstance(it).getString("account","")
|
||||
actvAccountPhone.text = phoneMask(SharedPrefs.getInstance(it).getString("och_account",""))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user