[1.0.0]
[订单、速度]
This commit is contained in:
yangyakun
2023-02-11 12:57:09 +08:00
parent 5054974152
commit 0c046cbe76
11 changed files with 654 additions and 5 deletions

View File

@@ -0,0 +1,16 @@
package com.mogo.och.bus.passenger.bean.request;
public
/**
* @author congtaowang
* @since 2021/3/22
*
* 根据车机行驶线路站点信息
*/
class BusPassengerQueryLineRequest {
private String sn;
public BusPassengerQueryLineRequest(String sn) {
this.sn = sn;
}
}

View File

@@ -0,0 +1,21 @@
package com.mogo.och.bus.passenger.bean.response;
import com.mogo.eagle.core.data.BaseData;
/**
* @author congtaowang
* @since 2021/3/22
*
* 小巴车运营状态返回参数
*/
public class BusPassengerOperationStatusResponse extends BaseData {
public Result data;
public static class Result {
private String sn; //司机屏sn
private String phone; //司机手机号
public String plateNumber; //车牌号
public int driverStatus;//0:已收车1:已出车
}
}

View File

@@ -0,0 +1,28 @@
package com.mogo.och.bus.passenger.bean.response;
import com.mogo.eagle.core.data.BaseData;
/**
* 网约车小巴路线接口请求响应结果 返回的是对应司机屏的线路信息
*
* @author tongchenfei
*/
public class BusPassengerRoutesResponse extends BaseData {
private BusPassengerRoutesResult data;
public BusPassengerRoutesResult getResult() {
return data;
}
public void setResult(BusPassengerRoutesResult data) {
this.data = data;
}
@Override
public String toString() {
return "OchBusRoutesResponse{" +
"data=" + data +
'}';
}
}

View File

@@ -0,0 +1,79 @@
package com.mogo.och.bus.passenger.bean.response;
import java.util.List;
import java.util.Objects;
/**
* 网约车小巴路线接口返回接口数据封装
*
* @author tongchenfei
*/
public class BusPassengerRoutesResult {
private List<BusPassengerStation> sites;
private int lineId;
private String name; //线路名称
private int lineType; //线路类型0:环形
private String description;
private int status;
private String runningDur; //运营时间
private long taskTime; //线路时间班次
public List<BusPassengerStation> getSites() {
return sites;
}
public int getLineId() {
return lineId;
}
public String getName() {
return name;
}
public int getLineType() {
return lineType;
}
public String getDescription() {
return description;
}
public int getStatus() {
return status;
}
public String getRunningDur() {
return runningDur;
}
@Override
public String toString() {
return "BusPassengerRoutesResult{" +
"sites=" + sites +
", lineId=" + lineId +
", name='" + name + '\'' +
", lineType=" + lineType +
", description='" + description + '\'' +
", status=" + status +
", runningDur='" + runningDur + '\'' +
'}';
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
BusPassengerRoutesResult that = (BusPassengerRoutesResult) o;
return lineId == that.lineId
&& lineType == that.lineType
&& status == that.status
&& sites.equals(that.sites)
&& name.equals(that.name)
&& runningDur.equals(that.runningDur);
}
@Override
public int hashCode() {
return Objects.hash(sites, lineId, name, lineType, description, status, runningDur);
}
}

View File

@@ -0,0 +1,173 @@
package com.mogo.och.bus.passenger.bean.response;
import java.util.Objects;
/**
* 单个网约车小巴车站信息
*
* @author wangmingjun
*/
public class BusPassengerStation {
private String name;
private String description;
private String cityCode;
private double lon; //高精坐标
private double lat; //高精坐标
private double gcjLon; //高德坐标
private double gcjLat; //高德坐标
private int businessType; //站点类型9:taxi10:bus
private int status;
private int siteId;
private int seq;
private int drivingStatus;//行驶信息0初始值1已经过2当前站3未到站
private int ifStop = 1; // 是否需要停靠、1需要、0不需要 // TODO: 2021/10/19 原来站点里有设计是否需要停靠字段,现设计暂无,默认都需要停靠
private boolean leaving;
public void setName(String name) {
this.name = name;
}
public void setDescription(String description) {
this.description = description;
}
public void setCityCode(String cityCode) {
this.cityCode = cityCode;
}
public void setLon(double lon) {
this.lon = lon;
}
public void setLat(double lat) {
this.lat = lat;
}
public void setBusinessType(int businessType) {
this.businessType = businessType;
}
public void setStatus(int status) {
this.status = status;
}
public void setSiteId(int siteId) {
this.siteId = siteId;
}
public void setSeq(int seq) {
this.seq = seq;
}
public void setDrivingStatus(int drivingStatus) {
this.drivingStatus = drivingStatus;
}
public String getName() {
return name;
}
public String getDescription() {
return description;
}
public String getCityCode() {
return cityCode;
}
public double getGcjLon() {
return gcjLon;
}
public double getGcjLat() {
return gcjLat;
}
public int getBusinessType() {
return businessType;
}
public int getStatus() {
return status;
}
public int getSiteId() {
return siteId;
}
public int getSeq() {
return seq;
}
public int getDrivingStatus() {
return drivingStatus;
}
public double getLon() {
return lon;
}
public double getLat() {
return lat;
}
public void setIfStop(int ifStop) {
this.ifStop = ifStop;
}
public int getIfStop() {
return ifStop;
}
public void setLeaving(boolean leaving) {
this.leaving = leaving;
}
public boolean isLeaving() {
return leaving;
}
@Override
public String toString() {
return "OchBusStation{" +
"name='" + name + '\'' +
", description='" + description + '\'' +
", cityCode='" + cityCode + '\'' +
", lon=" + lon +
", lat=" + lat +
", businessType=" + businessType +
", status=" + status +
", siteId=" + siteId +
", seq=" + seq +
", drivingStatus=" + drivingStatus +
", ifStop=" + ifStop +
", leaving=" + leaving +
'}';
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
BusPassengerStation that = (BusPassengerStation) o;
return Double.compare(that.lon, lon) == 0
&& Double.compare(that.lat, lat) == 0
&& Double.compare(that.gcjLon, gcjLon) == 0
&& Double.compare(that.gcjLat, gcjLat) == 0
&& businessType == that.businessType
&& status == that.status
&& siteId == that.siteId
&& seq == that.seq
&& drivingStatus == that.drivingStatus
&& ifStop == that.ifStop
&& leaving == that.leaving
&& Objects.equals(name, that.name)
&& Objects.equals(cityCode, that.cityCode);
}
@Override
public int hashCode() {
return Objects.hash(name, description, cityCode, lon, lat, gcjLon, gcjLat, businessType, status, siteId, seq, drivingStatus, ifStop, leaving);
}
}

View File

@@ -0,0 +1,159 @@
package com.mogo.och.bus.passenger.net;
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
import java.util.concurrent.TimeUnit;
import io.reactivex.Observable;
import io.reactivex.ObservableEmitter;
import io.reactivex.ObservableOnSubscribe;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Consumer;
import io.reactivex.schedulers.Schedulers;
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_BUS_P;
import static com.mogo.och.bus.passenger.constant.BusPassengerConst.LOOP_DELAY;
import static com.mogo.och.bus.passenger.constant.BusPassengerConst.LOOP_LINE_2S;
import static com.mogo.och.bus.passenger.constant.BusPassengerConst.LOOP_LINE_1S;
/**
* Created on 2021/11/22
*
* 管理轮询逻辑(订单轮询、新单轮询、新单抢单结果轮询等等)
*/
public class BusPassengerModelLoopManager {
private static final String TAG = BusPassengerModelLoopManager.class.getSimpleName();
private static final class SingletonHolder {
private static final BusPassengerModelLoopManager INSTANCE = new BusPassengerModelLoopManager();
}
public static BusPassengerModelLoopManager getInstance() {
return SingletonHolder.INSTANCE;
}
private Disposable mQueryLineDisposable; //心跳轮询
private CompositeDisposable mRouteWipeDisposable;
private CompositeDisposable mCalculateRouteDisposable; //每隔2s计算一次剩余里程和时间
public void startOrStopRouteAndWipe() {
CallerLogger.INSTANCE.i(M_BUS_P + TAG, "startOrStopRouteWipe()");
if (mRouteWipeDisposable != null) return;
if (mRouteWipeDisposable == null){
mRouteWipeDisposable = new CompositeDisposable();
}
Disposable disposable = startLoopRouteAndWipe()
.doOnSubscribe(new Consumer<Disposable>() {
@Override
public void accept(Disposable disposable) throws Exception {
}
})
.doOnError(new Consumer<Throwable>() {
@Override
public void accept(Throwable throwable) throws Exception {
}
})
.delay(LOOP_LINE_1S, TimeUnit.MILLISECONDS, true) // 设置delayError为true表示出现错误的时候也需要延迟5s进行通知达到无论是请求正常还是请求失败都是5s后重新订阅即重新请求。
.subscribeOn(Schedulers.io())
.repeat() // repeat保证请求成功后能够重新订阅。
.retry() // retry保证请求失败后能重新订阅
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Consumer<Integer>() {
@Override
public void accept(Integer integer) throws Exception {
}
});
mRouteWipeDisposable.add(disposable);
}
public void stopOrStopRouteAndWipe() {
if (mRouteWipeDisposable != null) {
mRouteWipeDisposable.dispose();
mRouteWipeDisposable = null;
}
}
public void startQueryDriverLineLoop() {
if (mQueryLineDisposable != null && !mQueryLineDisposable.isDisposed()) {
return;
}
CallerLogger.INSTANCE.i(M_BUS_P + TAG, "startQueryDriverLineLoop()");
// mQueryLineDisposable = Observable.interval(LOOP_DELAY,
// LOOP_LINE_2S, TimeUnit.MILLISECONDS)
// .map((aLong -> aLong + 1))
// .subscribeOn(Schedulers.io())
// .observeOn(AndroidSchedulers.mainThread())
// .subscribe(aLong -> BusPassengerModel.getInstance().queryDriverSiteByCoordinate());
}
public void stopQueryDriverLineLoop() {
if (mQueryLineDisposable != null) {
CallerLogger.INSTANCE.i(M_BUS_P + TAG, "stopQueryDriverLineLoop()");
mQueryLineDisposable.dispose();
mQueryLineDisposable = null;
}
}
public void startCalculateRouteInfoLoop() {
CallerLogger.INSTANCE.i(M_BUS_P + TAG, "startCalculateRouteInfoLoop()");
if (mCalculateRouteDisposable != null) return;
if (mCalculateRouteDisposable == null){
mCalculateRouteDisposable = new CompositeDisposable();
}
Disposable disposable = startLoopCalculateRouteInfo()
.doOnSubscribe(new Consumer<Disposable>() {
@Override
public void accept(Disposable disposable) throws Exception {
}
})
.doOnError(new Consumer<Throwable>() {
@Override
public void accept(Throwable throwable) throws Exception {
}
})
.delay(LOOP_LINE_2S, TimeUnit.MILLISECONDS, true) // 设置delayError为true表示出现错误的时候也需要延迟5s进行通知达到无论是请求正常还是请求失败都是5s后重新订阅即重新请求。
.subscribeOn(Schedulers.io())
.repeat() // repeat保证请求成功后能够重新订阅。
.retry() // retry保证请求失败后能重新订阅
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Consumer<Integer>() {
@Override
public void accept(Integer integer) throws Exception {
}
});
mCalculateRouteDisposable.add(disposable);
}
public void stopCalculateRouteInfLoop() {
if (mCalculateRouteDisposable != null) {
CallerLogger.INSTANCE.i(M_BUS_P + TAG, "stopCalculateRouteInfLoop()");
mCalculateRouteDisposable.dispose();
mCalculateRouteDisposable = null;
}
}
private Observable<Integer> startLoopRouteAndWipe(){
return Observable.create(new ObservableOnSubscribe<Integer>() {
@Override
public void subscribe(ObservableEmitter<Integer> emitter) throws Exception {
if (emitter.isDisposed()) return;
//BusPassengerModel.getInstance().loopRouteAndWipe();
emitter.onComplete();
}
});
}
private Observable<Integer> startLoopCalculateRouteInfo(){
return Observable.create(new ObservableOnSubscribe<Integer>() {
@Override
public void subscribe(ObservableEmitter<Integer> emitter) throws Exception {
if (emitter.isDisposed()) return;
//BusPassengerModel.getInstance().dynamicCalculateRouteInfo();
emitter.onComplete();
}
});
}
}

View File

@@ -0,0 +1,89 @@
package com.mogo.och.bus.passenger.net
import android.content.Context
import com.mogo.eagle.core.function.call.telematic.CallerTelematicManager.getServerToken
import com.mogo.och.bus.passenger.bean.response.BusPassengerRoutesResponse
import com.mogo.cloud.passport.MoGoAiCloudClientConfig
import com.mogo.eagle.core.data.config.FunctionBuildConfig
import com.mogo.eagle.core.network.MoGoRetrofitFactory
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils
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 mShuttleBusPassengerServiceApi =
MoGoRetrofitFactory.getInstance(getBaseUrl()).create(ShettlePassengerServiceApi::class.java)
private var mBusPassengerServiceApi =
MoGoRetrofitFactory.getInstance(getBaseUrl()).create(PassengerServiceApi::class.java)
/**
* 获取Bus司机端的sn
* @return
*/
private val driverAppSn: String
get() = getServerToken()
/**
* 查询绑定行驶的小巴车路线
* @param context
* @param callback
*/
@JvmStatic
fun queryDriverSiteByCoordinate(
context: Context, callback: OchCommonServiceCallback<BusPassengerRoutesResponse>?
) {
if (AppIdentityModeUtils.isShuttle(FunctionBuildConfig.appIdentityMode)) {
mShuttleBusPassengerServiceApi.queryDriverSiteByCoordinate(
MoGoAiCloudClientConfig.getInstance().serviceAppId,
MoGoAiCloudClientConfig.getInstance().token,
BusPassengerQueryLineRequest(
driverAppSn
)
).transformTry()
.subscribe(OchCommonSubscribeImpl(context, callback, "queryDriverSiteByCoordinate"))
} else {
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>?
) {
if (AppIdentityModeUtils.isShuttle(FunctionBuildConfig.appIdentityMode)) {
mShuttleBusPassengerServiceApi.queryDriverOperationStatus(
MoGoAiCloudClientConfig.getInstance().serviceAppId,
MoGoAiCloudClientConfig.getInstance().token,
driverAppSn
)
.transformTry()
.subscribe(OchCommonSubscribeImpl(context, callback, "queryDriverOperationStatus"))
} else {
mBusPassengerServiceApi.queryDriverOperationStatus(
MoGoAiCloudClientConfig.getInstance().serviceAppId,
MoGoAiCloudClientConfig.getInstance().token,
driverAppSn
)
.transformTry()
.subscribe(OchCommonSubscribeImpl(context, callback, "queryDriverOperationStatus"))
}
}
}

View File

@@ -0,0 +1,39 @@
package com.mogo.och.bus.passenger.net;
import com.mogo.och.bus.passenger.bean.request.BusPassengerQueryLineRequest;
import com.mogo.och.bus.passenger.bean.response.BusPassengerOperationStatusResponse;
import com.mogo.och.bus.passenger.bean.response.BusPassengerRoutesResponse;
import io.reactivex.Observable;
import retrofit2.http.Body;
import retrofit2.http.GET;
import retrofit2.http.Header;
import retrofit2.http.Headers;
import retrofit2.http.POST;
import retrofit2.http.Query;
/**
* Created on 2022/3/31
*
* Bus乘客端接口定义
*/
interface PassengerServiceApi {
/**
* 查询bus司机端绑定路线
* @return 接口返回数据
*/
@Headers( {"Content-Type:application/json;charset=UTF-8"} )
@POST( "/autopilot-car-hailing/line/v2/driver/bus/passenger/lineDataWithDriver/query" )
Observable<BusPassengerRoutesResponse> queryDriverSiteByCoordinate(@Header("appId") String appId, @Header("ticket") String ticket, @Body BusPassengerQueryLineRequest request);
/**
* 查询司机端的登陆状态
* @param sn
* @return
*/
@Headers({"Content-type:application/json;charset=UTF-8"})
// @GET("/autopilot-car-hailing/car/v2/driver/bus/passenger/takeOrderStatus/query")
@GET("/autopilot-car-hailing/operation/v1/driver/bus/passenger/loginStatus")
Observable<BusPassengerOperationStatusResponse> queryDriverOperationStatus(@Header ("appId") String appId, @Header("ticket") String ticket, @Query("sn") String sn);
}

View File

@@ -1,7 +1,34 @@
package com.mogo.och.bus.passenger.presenter
import com.mogo.commons.mvp.Presenter
import androidx.lifecycle.LifecycleOwner
import com.mogo.eagle.core.data.map.MogoLocation
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationGCJ02Listener
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ02ListenerManager
import com.mogo.och.bus.passenger.ui.BusPassengerRouteFragment
class BusPassengerPresenter(view: BusPassengerRouteFragment?) :
BusBasePassengerFunctionDevicePresenter<BusPassengerRouteFragment?>(view)
BusBasePassengerFunctionDevicePresenter<BusPassengerRouteFragment?>(view),
IMoGoChassisLocationGCJ02Listener {
override fun onCreate(owner: LifecycleOwner) {
super.onCreate(owner)
// 定位监听
CallerChassisLocationGCJ02ListenerManager.addListener(TAG, this)
}
override fun onDestroy(owner: LifecycleOwner) {
super.onDestroy(owner)
CallerChassisLocationGCJ02ListenerManager.removeListener(TAG)
}
override fun onChassisLocationGCJ02(mogoLocation: MogoLocation?) {
mogoLocation?.let {
setSpeed(it.gnssSpeed)
}
}
private fun setSpeed(speed:Float){
val speedKM =(Math.abs(speed) * 3.6f).toInt()
mView?.setSpeed(speedKM.toString())
}
companion object{
private const val TAG = "BusPassengerPresenter"
}
}

View File

@@ -1,6 +1,9 @@
package com.mogo.och.bus.passenger.ui
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.DialogFragment
import androidx.fragment.app.Fragment
import com.mogo.commons.mvp.MvpFragment
@@ -28,7 +31,6 @@ class BusPassengerRouteFragment :
private var bpFunctionGroupDialogFragment: WeakReference<BusPassengerFunctionFragment>? = null
private lateinit var mapBizView: MapBizView
override fun getLayoutId(): Int {
return R.layout.bus_p_fragment
}
@@ -40,7 +42,6 @@ class BusPassengerRouteFragment :
override fun initViews() {
//隐藏小地图
hidePanel()
mapBizView = findViewById(R.id.mapBizView)!!
cb_bp_video_player.onClick {
openSettingPage(BusPassengerFunctionFragment.VIDEOTAB)
}
@@ -94,6 +95,11 @@ class BusPassengerRouteFragment :
}
}
fun setSpeed(speed:String){
tv_distance.text = speed
}
override fun createPresenter(): BusPassengerPresenter {
return BusPassengerPresenter(this)
}
@@ -101,11 +107,13 @@ class BusPassengerRouteFragment :
override fun initViews(savedInstanceState: Bundle?) {
super.initViews(savedInstanceState)
mapBizView.onCreate(savedInstanceState)
omvOverMap.onCreateView(savedInstanceState)
}
override fun onResume() {
super.onResume()
mapBizView.onResume()
omvOverMap.onResume()
}
override fun onSaveInstanceState(outState: Bundle) {
@@ -121,10 +129,12 @@ class BusPassengerRouteFragment :
override fun onPause() {
super.onPause()
mapBizView.onPause()
omvOverMap.onPause()
}
override fun onDestroyView() {
mapBizView.onDestroy()
omvOverMap.onDestroy()
super.onDestroyView()
}

View File

@@ -9,9 +9,17 @@
android:layout_width="0dp"
app:layout_constraintWidth_percent="0.662"
android:layout_height="match_parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"/>
<com.mogo.eagle.core.function.view.OverMapView
android:id="@+id/omvOverMap"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="@+id/mapBizView"
android:layout_width="0dp"
android:layout_height="match_parent"/>
<View
android:id="@+id/v_debug"