Merge branch 'dev_robobus-d_240123_6.2.9_optimize' into dev_robotaxi-d_240227_6.3.0

This commit is contained in:
yangyakun
2024-02-28 11:05:31 +08:00
78 changed files with 429 additions and 2979 deletions

View File

@@ -1,4 +1,4 @@
package com.mogo.och.bus.passenger.passenger.bean;
package com.mogo.och.bus.passenger.bean;
import com.mogo.eagle.core.data.BaseData;
import com.mogo.och.data.bean.BusRoutesResult;

View File

@@ -2,7 +2,7 @@ package com.mogo.och.bus.passenger.network
import android.content.Context
import com.mogo.eagle.core.function.call.telematic.CallerTelematicManager.getServerToken
import com.mogo.och.bus.passenger.bean.BusPassengerRoutesResponse
import com.mogo.och.bus.passenger.bean.PM2RoutesResponse
import com.mogo.cloud.passport.MoGoAiCloudClientConfig
import com.mogo.commons.debug.DebugConfig
import com.mogo.och.bus.passenger.bean.BusPassengerQueryLineRequest
@@ -31,7 +31,7 @@ object BusPassengerServiceManager {
* 获取Bus司机端的sn
* @return
*/
val driverAppSn: String
public val driverAppSn: String
get() {
val serverToken = getServerToken()
if (serverToken != driverSnCache && serverToken.isNotEmpty()) {
@@ -47,7 +47,7 @@ object BusPassengerServiceManager {
*/
@JvmStatic
fun queryDriverSiteByCoordinate(
context: Context, callback: OchCommonServiceCallback<BusPassengerRoutesResponse>?
context: Context, callback: OchCommonServiceCallback<PM2RoutesResponse>?
) {
if (DebugConfig.getProjectFlavor().contains("saas")){
mBusPassengerSaasServiceApi.queryDriverSiteByCoordinate(

View File

@@ -2,7 +2,7 @@ package com.mogo.och.bus.passenger.network;
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.bean.PM2RoutesResponse;
import io.reactivex.Observable;
import retrofit2.http.Body;
@@ -17,7 +17,7 @@ import retrofit2.http.Query;
*
* Bus乘客端接口定义
*/
interface PassengerSAASServiceApi {
public interface PassengerSAASServiceApi {
/**
* 查询bus司机端绑定路线
* @return 接口返回数据
@@ -25,7 +25,7 @@ interface PassengerSAASServiceApi {
@Headers( {"Content-Type:application/json;charset=UTF-8"} )
// @POST( "/autopilot-car-hailing/line/v2/driver/bus/passenger/lineDataWithDriver/query" )
@GET( "/och-bus-cabin/api/business/v1/driver/bus/lineDataWithDriver/query" )
Observable<BusPassengerRoutesResponse> queryDriverSiteByCoordinate(@Header("appId") String appId, @Header("ticket") String ticket, @Query("sn") String sn);
Observable<PM2RoutesResponse> queryDriverSiteByCoordinate(@Header("appId") String appId, @Header("ticket") String ticket, @Query("sn") String sn);
/**
* 查询司机端的登陆状态

View File

@@ -2,7 +2,7 @@ package com.mogo.och.bus.passenger.network;
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.bean.PM2RoutesResponse;
import io.reactivex.Observable;
import retrofit2.http.Body;
@@ -17,14 +17,14 @@ import retrofit2.http.Query;
*
* Bus乘客端接口定义
*/
interface PassengerServiceApi {
public 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);
Observable<PM2RoutesResponse> queryDriverSiteByCoordinate(@Header("appId") String appId, @Header("ticket") String ticket, @Body BusPassengerQueryLineRequest request);
/**
* 查询司机端的登陆状态

View File

@@ -1,28 +0,0 @@
package com.mogo.och.bus.passenger.bean;
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

@@ -1,103 +0,0 @@
package com.mogo.och.bus.passenger.bean;
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;
}
public String csvFileUrl = ""; //轨迹文件下载的cos url默认“”
public String csvFileMd5 = ""; //轨迹文件md5默认“”
public String txtFileUrl = ""; //打点文件下载的cos url默认“”
public String txtFileMd5 = ""; //轨迹文件md5默认“”
public long contrailSaveTime; //上传轨迹完成时间戳ms用于MEC本地手动导入轨迹验证时不会被云端轨迹覆盖
public String carModel = ""; //[optional] 车型号如红旗H9默认“”暂不加入校验逻辑、用于人工排查问题
public String csvFileUrlDPQP = ""; //轨迹文件下载的cos url默认“”
public String csvFileMd5DPQP = ""; //轨迹文件md5默认“”
public String txtFileUrlDPQP = ""; //打点文件下载的cos url默认“”
public String txtFileMd5DPQP = ""; //轨迹文件md5默认“”
public long contrailSaveTimeDPQP; //上传轨迹完成时间戳ms用于MEC本地手动导入轨迹验证时不会被云端轨迹覆盖
@Override
public String toString() {
return "BusPassengerRoutesResult{" +
"sites=" + sites +
", lineId=" + lineId +
", name='" + name + '\'' +
", lineType=" + lineType +
", description='" + description + '\'' +
", status=" + status +
", runningDur='" + runningDur + '\'' +
", taskTime=" + taskTime +
", csvFileUrl='" + csvFileUrl + '\'' +
", csvFileMd5='" + csvFileMd5 + '\'' +
", txtFileUrl='" + txtFileUrl + '\'' +
", txtFileMd5='" + txtFileMd5 + '\'' +
", contrailSaveTime=" + contrailSaveTime +
", carModel='" + carModel + '\'' +
", csvFileUrlDPQP='" + csvFileUrlDPQP + '\'' +
", csvFileMd5DPQP='" + csvFileMd5DPQP + '\'' +
", txtFileUrlDPQP='" + txtFileUrlDPQP + '\'' +
", txtFileMd5DPQP='" + txtFileMd5DPQP + '\'' +
", contrailSaveTimeDPQP=" + contrailSaveTimeDPQP +
'}';
}
@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

@@ -1,173 +0,0 @@
package com.mogo.och.bus.passenger.bean;
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

@@ -6,8 +6,6 @@ package com.mogo.och.bus.passenger.callback;
* Model->Presenter回调ADAS相关自动驾驶状态回调到达终点等等
*/
public interface IBusPassengerADASStatusCallback {
// 自动驾驶触发的已到达目的地:暂未用到
void onAutopilotArriveEnd();
// 自动驾驶可用状态
void onAutopilotEnable();

View File

@@ -11,5 +11,4 @@ import java.util.List;
public interface IBusPassengerAutopilotPlanningCallback {
void routeResult(List<LatLng> routeArrivied, List<LatLng> routeArriving, MogoLocation location);
void routePlanningToNextStationChanged(long meters, long timeInSecond);
void updateTotalDistance();
}

View File

@@ -1,6 +1,6 @@
package com.mogo.och.bus.passenger.callback;
import com.mogo.och.bus.passenger.bean.BusPassengerStation;
import com.mogo.och.data.bean.BusStationBean;
import java.util.List;
@@ -10,7 +10,7 @@ import java.util.List;
*/
public interface IBusPassengerRouteLineInfoCallback {
void updateLineInfo(String lineName, String lineDurTime);
void updateStationsInfo(List<BusPassengerStation> stations, int currentStationIndex, boolean isArrived);
void updateStationsInfo(List<BusStationBean> stations, int currentStationIndex, boolean isArrived);
void showNoTaskView();
void hideNoTaskView();
}

View File

@@ -38,12 +38,9 @@ import com.mogo.eagle.core.utilcode.util.NetworkUtils
import com.mogo.eagle.core.utilcode.util.ToastUtils
import com.mogo.och.bus.passenger.R
import com.mogo.och.bus.passenger.bean.BusPassengerOperationStatusResponse
import com.mogo.och.bus.passenger.bean.BusPassengerRoutesResponse
import com.mogo.och.bus.passenger.bean.BusPassengerRoutesResult
import com.mogo.och.bus.passenger.bean.BusPassengerStation
import com.mogo.och.bus.passenger.bean.PM2RoutesResponse
import com.mogo.och.bus.passenger.callback.*
import com.mogo.och.bus.passenger.constant.BusPassengerConst
import com.mogo.och.bus.passenger.network.BusPassengerModelLoopManager
import com.mogo.och.bus.passenger.network.BusPassengerServiceManager
import com.mogo.och.bus.passenger.network.BusPassengerServiceManager.driverAppSn
import com.mogo.och.common.module.bean.dpmsg.AppConnectMsg
@@ -61,14 +58,14 @@ import com.mogo.och.common.module.manager.distancemamager.TrajectoryAndDistanceM
import com.mogo.och.common.module.manager.distancemamager.TrajectoryAndDistanceManager.addTrajectoryListener
import com.mogo.och.common.module.manager.distancemamager.TrajectoryAndDistanceManager.setStationPoint
import com.mogo.och.common.module.manager.distancemamager.TrajectoryAndDistanceManager.suspendCalculate
import com.mogo.och.common.module.utils.CoordinateCalculateRouteUtil.calculateRouteSumLength
import com.mogo.och.common.module.utils.CoordinateCalculateRouteUtil.coordinateConverterWgsToGcjLocations
import com.mogo.och.common.module.utils.CoordinateCalculateRouteUtil.getArrivedPointIndexNew
import com.mogo.och.common.module.manager.loopmanager.BizLoopManager
import com.mogo.och.common.module.manager.loopmanager.LoopInfo
import com.mogo.och.common.module.utils.DateTimeUtil
import com.mogo.och.common.module.utils.PinYinUtil
import mogo.telematics.pad.MessagePad
import com.mogo.och.data.bean.BusRoutesResult
import com.mogo.och.data.bean.BusStationBean
import io.reactivex.schedulers.Schedulers
import mogo.telematics.pad.MessagePad.ArrivalNotification
import mogo.telematics.pad.MessagePad.GlobalPathResp
import java.util.concurrent.ConcurrentHashMap
/**
@@ -78,24 +75,21 @@ import java.util.concurrent.ConcurrentHashMap
object BusPassengerModel {
private val TAG = BusPassengerModel::class.java.simpleName
private val TAG_LOOP_QUERY_BIND_LINE = "${TAG}_TAG_LOOP_QUERY_BIND_LINE"
private const val MSG_QUERY_BUS_P_STATION = 1001
private val mRoutePoints: MutableList<MogoLocation> = ArrayList()
private var mContext: Context? = null
private var mADASStatusCallback //Model->Presenter:自动驾驶状态相关
: IBusPassengerADASStatusCallback? = null
private var mAutopilotPlanningCallback //Model->Presenter:自动驾驶线路规划
: IBusPassengerAutopilotPlanningCallback? = null
private var mADASStatusCallback: IBusPassengerADASStatusCallback? =
null//Model->Presenter:自动驾驶状态相关
private var mAutopilotPlanningCallback: IBusPassengerAutopilotPlanningCallback? =
null//Model->Presenter:自动驾驶线路规划
private val mControllerStatusCallbackMap: MutableMap<String, IBusPassengerControllerStatusCallback> =
ConcurrentHashMap()
private var mDriverStatusCallback //出车收车状态
: IBusPassegerDriverStatusCallback? = null
private var mRouteLineInfoCallback // bus路线信息更新
: IBusPassengerRouteLineInfoCallback? = null
private var mDriverStatusCallback: IBusPassegerDriverStatusCallback? = null//出车收车状态
private var mRouteLineInfoCallback: IBusPassengerRouteLineInfoCallback? = null// bus路线信息更新
private var mLocation: MogoLocation? = null
private var routesResult: BusPassengerRoutesResult? = null
var mStations: MutableList<BusPassengerStation> = ArrayList()
private var routesResult: BusRoutesResult? = null
var mStations: MutableList<BusStationBean> = ArrayList()
private var mNextStationIndex = 0 // 要到达站的index
private val mTwoStationsRouts: MutableList<MogoLocation> = ArrayList()
private val handler = Handler(Looper.getMainLooper(), Handler.Callback { msg ->
@@ -113,7 +107,10 @@ object BusPassengerModel {
mContext = context.applicationContext
initListeners()
queryDriverOperationStatus()
startOrStopOrderLoop(true)
BizLoopManager.setLoopFunction(
TAG_LOOP_QUERY_BIND_LINE,
LoopInfo(2, ::queryDriverSiteByCoordinate, scheduler = Schedulers.io())
)
}
fun setDriverStatusCallback(callback: IBusPassegerDriverStatusCallback?) {
@@ -163,10 +160,10 @@ object BusPassengerModel {
})
}
fun queryDriverSiteByCoordinate() {
private fun queryDriverSiteByCoordinate() {
BusPassengerServiceManager.queryDriverSiteByCoordinate(
mContext!!, object : OchCommonServiceCallback<BusPassengerRoutesResponse> {
override fun onSuccess(data: BusPassengerRoutesResponse) {
mContext!!, object : OchCommonServiceCallback<PM2RoutesResponse> {
override fun onSuccess(data: PM2RoutesResponse) {
if (data.result == null) {
d(M_BUS_P + TAG, "order = queryDriverSiteByCoordinate = null")
if (routesResult != null) {
@@ -175,7 +172,6 @@ object BusPassengerModel {
}
cleanStation("queryDriverSiteByCoordinate")
mRouteLineInfoCallback?.showNoTaskView()
mRoutePoints.clear()
return
}
if (routesResult != null && data.result.equals(routesResult)) {
@@ -207,7 +203,7 @@ object BusPassengerModel {
})
}
private fun updatePassengerRouteInfo(result: BusPassengerRoutesResult) {
private fun updatePassengerRouteInfo(result: BusRoutesResult) {
if (mRouteLineInfoCallback != null) {
d(
M_BUS_P + TAG,
@@ -255,7 +251,7 @@ object BusPassengerModel {
}
private fun updateAutopilotControlParameters(
busRoutesResult: BusPassengerRoutesResult,
busRoutesResult: BusRoutesResult,
leaveIndex: Int
) {
val parameters = initAutopilotControlParameters(busRoutesResult, leaveIndex)
@@ -273,7 +269,7 @@ object BusPassengerModel {
}
private fun initAutopilotControlParameters(
busRoutesResult: BusPassengerRoutesResult,
busRoutesResult: BusRoutesResult,
leaveIndex: Int
): AutopilotControlParameters? {
if (busRoutesResult.sites == null) {
@@ -311,7 +307,7 @@ object BusPassengerModel {
fun release() {
releaseListeners()
cleanStation("release")
startOrStopOrderLoop(false)
BizLoopManager.removeLoopFunction(TAG_LOOP_QUERY_BIND_LINE)
}
fun setMoGoAutopilotPlanningListener(moGoAutopilotPlanningCallback: IBusPassengerAutopilotPlanningCallback?) {
@@ -348,9 +344,6 @@ object BusPassengerModel {
// 定位监听
addListener(TAG, 10, mMapLocationListener)
//2021.11.1 自动驾驶路线规划接口
CallerPlanningRottingListenerManager.addListener(TAG, moGoAutopilotPlanningListener)
//监听司机端消息
CallerTelematicListenerManager.addListener(TAG, mReceivedMsgListener)
startLoopAbnormalFactors(mContext!!)
@@ -370,7 +363,6 @@ object BusPassengerModel {
MogoAiCloudSocketManager.getInstance(mContext)
.unregisterLifecycleListener(10010)
CallerAutoPilotStatusListenerManager.removeListener(mGoAutopilotStatusListener)
CallerPlanningRottingListenerManager.removeListener(moGoAutopilotPlanningListener)
CallerTelematicListenerManager.removeListener(TAG)
stopLoopAbnormalFactors()
}
@@ -513,86 +505,12 @@ object BusPassengerModel {
) {
arriveAtEnd = true
}
// if (DebugConfig.isDebug()) {
// ToastUtils.showShort("到达目的地")
// }
mADASStatusCallback?.onAutopilotArriveEnd()
}
}
private val moGoAutopilotPlanningListener: IMoGoPlanningRottingListener =
object : IMoGoPlanningRottingListener {
override fun onAutopilotRotting(globalPathResp: GlobalPathResp?) {
globalPathResp?.wayPointsList?.let {
if (it.size > 0) {
d(M_BUS_P + TAG, "收到轨迹:${it.size}--第一个点${it[0]}--最后一个点:${it.last()}")
updateRoutePoints(it)
}
}
}
}
fun updateRoutePoints(routePoints: List<MessagePad.Location>) {
mRoutePoints.clear()
val latLngModels: List<MogoLocation> =
coordinateConverterWgsToGcjLocations(mContext, routePoints)
mRoutePoints.addAll(latLngModels)
calculateTwoStationsRoute()
}
private fun calculateTwoStationsRoute() {
//找出前往站对应的轨迹点,拿出两站点的集合
d(M_BUS_P + TAG, "mRoutePoints.size() = " + mRoutePoints.size)
if (mRoutePoints.size > 0) {
if (mStations.size > 1) { //两个站点及以上要计算两个站点间的轨迹路线
if (mNextStationIndex <= mStations.size - 1 && mNextStationIndex - 1 >= 0) {
mTwoStationsRouts.clear()
val stationNext = mStations[mNextStationIndex]
val stationCur = mStations[mNextStationIndex - 1]
//当前站在轨迹中对应的点
val currentRouteIndex = getArrivedPointIndexNew(
0, mRoutePoints, stationCur.gcjLon, stationCur.gcjLat
)
//要前往的站在轨迹中对应的点
val nextRouteIndex = getArrivedPointIndexNew(
currentRouteIndex, mRoutePoints, stationNext.gcjLon, stationNext.gcjLat
)
d(
M_BUS_P + TAG,
"轨迹排查==currentRouteIndex = " + currentRouteIndex
+ " nextRouteIndex = " + nextRouteIndex
)
if (currentRouteIndex < nextRouteIndex) { //如果找到的next在起点的轨迹前面直接舍弃这个轨迹不显示
mTwoStationsRouts.addAll(
mRoutePoints.subList(
currentRouteIndex,
nextRouteIndex + 1
)
)
}
}
}
if (mTwoStationsRouts.size > 0) {
val sumLength = calculateRouteSumLength(mTwoStationsRouts)
SharedPrefsMgr.getInstance()
.putInt(BusPassengerConst.BUS_SP_KEY_ORDER_SUM_DIS, sumLength.toInt())
mAutopilotPlanningCallback?.updateTotalDistance()
}
}
}
private fun startOrStopOrderLoop(start: Boolean) {
d(M_BUS_P + TAG, "startOrStopOrderLoop() $start")
if (start) {
BusPassengerModelLoopManager.getInstance().startQueryDriverLineLoop()
} else {
BusPassengerModelLoopManager.getInstance().stopQueryDriverLineLoop()
}
}
private fun setTrajectoryStation(
startStationInfo: BusPassengerStation,
endStationInfo: BusPassengerStation,
startStationInfo: BusStationBean,
endStationInfo: BusStationBean,
lineId: Int
) {
val startStation = MogoLocation()

View File

@@ -1,62 +0,0 @@
package com.mogo.och.bus.passenger.network;
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
import com.mogo.och.bus.passenger.model.BusPassengerModel;
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; //心跳轮询
public void startQueryDriverLineLoop() {
if (mQueryLineDisposable != null && !mQueryLineDisposable.isDisposed()) {
return;
}
CallerLogger.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.INSTANCE.queryDriverSiteByCoordinate());
}
public void stopQueryDriverLineLoop() {
if (mQueryLineDisposable != null) {
CallerLogger.i(M_BUS_P + TAG, "stopQueryDriverLineLoop()");
mQueryLineDisposable.dispose();
mQueryLineDisposable = null;
}
}
}

View File

@@ -14,7 +14,6 @@ import com.mogo.eagle.core.data.map.MogoLocation;
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener;
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
import com.mogo.och.bus.passenger.bean.BusPassengerStation;
import com.mogo.och.bus.passenger.callback.IBusPassegerDriverStatusCallback;
import com.mogo.och.bus.passenger.callback.IBusPassengerADASStatusCallback;
import com.mogo.och.bus.passenger.callback.IBusPassengerAutopilotPlanningCallback;
@@ -80,12 +79,6 @@ public class BaseBusPassengerPresenter extends Presenter<BusPassengerRouteFragme
}
}
@Override
public void onAutopilotArriveEnd() {
// mView.showOverviewFragment();
}
@Override
public void onAutopilotEnable() {
runOnUIThread(() -> mView.onAutopilotStatusChanged(
@@ -137,7 +130,7 @@ public class BaseBusPassengerPresenter extends Presenter<BusPassengerRouteFragme
}
@Override
public void updateStationsInfo(List<BusPassengerStation> stations, int currentStationIndex, boolean isArrived) {
public void updateStationsInfo(List<BusStationBean> stations, int currentStationIndex, boolean isArrived) {
runOnUIThread(() -> mView.updateStationsInfo(stations,currentStationIndex, isArrived));
}
@@ -161,8 +154,4 @@ public class BaseBusPassengerPresenter extends Presenter<BusPassengerRouteFragme
runOnUIThread(() -> mView.updateRoutePlanningToNextStation(meters, timeInSecond));
}
@Override
public void updateTotalDistance() {
// runOnUIThread(() -> mView.setProgressBarMax());
}
}

View File

@@ -1,334 +0,0 @@
package com.mogo.och.bus.passenger.ui
import android.content.Context
import android.os.Bundle
import android.util.AttributeSet
import android.view.LayoutInflater
import android.view.View
import android.widget.RelativeLayout
import com.amap.api.maps.AMap
import com.amap.api.maps.CameraUpdateFactory
import com.amap.api.maps.TextureMapView
import com.amap.api.maps.model.BitmapDescriptor
import com.amap.api.maps.model.BitmapDescriptorFactory
import com.amap.api.maps.model.CameraPosition
import com.amap.api.maps.model.CustomMapStyleOptions
import com.amap.api.maps.model.LatLng
import com.amap.api.maps.model.LatLngBounds
import com.amap.api.maps.model.Marker
import com.amap.api.maps.model.MarkerOptions
import com.amap.api.maps.model.Polyline
import com.amap.api.maps.model.PolylineOptions
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.eagle.core.utilcode.mogo.logger.CallerLogger.d
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_BUS_P
import com.mogo.och.bus.passenger.R
import com.mogo.och.bus.passenger.utils.BusPassengerMapAssetStyleUtil
/**
* 乘客屏小地图
*/
class BusPassengerMapDirectionView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
) : RelativeLayout(context, attrs, defStyleAttr), IMoGoChassisLocationGCJ02Listener,
IBusPassengerMapDirectionView, AMap.OnCameraChangeListener {
companion object {
//小地图名称
const val TAG = "BusPassengerMapDirectionView"
}
private lateinit var mAMapNaviView: TextureMapView
private lateinit var mAMap: AMap
private var mPolyline: Polyline? = null
private val mLineMarkers: MutableList<Marker> = ArrayList()
private lateinit var mCarMarker: Marker
private val mLineStationLatLng: MutableList<LatLng> = ArrayList() //站点坐标数据
var textureList: MutableList<BitmapDescriptor?> = ArrayList()
var texIndexList: MutableList<Int> = ArrayList()
private var mArrivedRes: BitmapDescriptor? = null
private var mUnArrivedRes: BitmapDescriptor? = null
private val routeArrived: MutableList<LatLng> = ArrayList()
private val routeArriving: MutableList<LatLng> = ArrayList()
private var location: MogoLocation? = null
init {
try {
initView(context)
} catch (e: Exception) {
e.printStackTrace()
}
}
private fun initView(context: Context) {
d(M_BUS_P + TAG, "initView")
val smpView = LayoutInflater.from(context).inflate(R.layout.bus_p_map_view, this)
mAMapNaviView = smpView.findViewById<View>(R.id.bus_p_line_amap_view) as TextureMapView
initAMapView()
// 注册定位监听
CallerChassisLocationGCJ02ListenerManager.addListener(TAG, 10, this)
}
override fun onDetachedFromWindow() {
super.onDetachedFromWindow()
// 注册定位监听
CallerChassisLocationGCJ02ListenerManager.removeListener(TAG)
}
private fun initAMapView() {
mAMap = mAMapNaviView.map
// 设置导航地图模式aMap是地图控制器对象。
mAMap.mapType = AMap.MAP_TYPE_NIGHT
// 关闭显示实时路况图层aMap是地图控制器对象。
mAMap.isTrafficEnabled = false
// 设置 锚点 图标
mCarMarker = mAMap.addMarker(MarkerOptions().icon(BitmapDescriptorFactory.fromResource(R.drawable.bus_p_map_car)).anchor(0.5f, 0.5f))
mArrivedRes = BitmapDescriptorFactory.fromResource(R.drawable.bus_p_map_arrow_arrived)
mUnArrivedRes = BitmapDescriptorFactory.fromResource(R.drawable.bus_p_map_arrow_un_arrive)
// 加载自定义样式
val customMapStyleOptions = CustomMapStyleOptions()
.setEnable(true)
.setStyleData(
BusPassengerMapAssetStyleUtil.getAssetsStyle(
context, "map_style.data"
)
)
.setStyleExtraData(
BusPassengerMapAssetStyleUtil.getAssetsExtraStyle(
context, "map_style_extra.data"
)
)
// 设置自定义样式
mAMap.setCustomMapStyle(customMapStyleOptions)
// 设置地图的样式
mAMap.uiSettings.apply {
isZoomControlsEnabled = false // 地图缩放级别的交换按钮
setAllGesturesEnabled(true) // 所有手势
isMyLocationButtonEnabled = false // 显示默认的定位按钮
setLogoBottomMargin(-150) //设置Logo下边界距离屏幕底部的边距,设置为负值即可
}
mAMap.setOnMapLoadedListener {
d(M_BUS_P + TAG, "smp---onMapLoaded")
// 加载自定义样式
val options = CustomMapStyleOptions()
.setEnable(true)
.setStyleData(
BusPassengerMapAssetStyleUtil.getAssetsStyle(
context, "map_style.data"
)
)
.setStyleExtraData(
BusPassengerMapAssetStyleUtil.getAssetsExtraStyle(
context, "map_style_extra.data"
)
)
// 设置自定义样式
mAMap.setCustomMapStyle(options)
mAMapNaviView.map.setPointToCenter(
mAMapNaviView.width / 2,
mAMapNaviView.height / 2
)
}
//设置地图状态的监听接口
mAMap.setOnCameraChangeListener(this)
}
// override fun onInterceptTouchEvent(ev: MotionEvent): Boolean {
// return true
// }
override fun onChassisLocationGCJ02(mogoLocation: MogoLocation?) {
if (mogoLocation == null) {
return
}
val currentLatLng = LatLng(mogoLocation.latitude, mogoLocation.longitude)
//更新车辆位置
mCarMarker.rotateAngle = (360 - mogoLocation.heading).toFloat()
mCarMarker.position = currentLatLng
mCarMarker.setToTop()
try {
//圈定地图显示范围
val boundsBuilder = LatLngBounds.Builder()
routeArrived.forEach {
boundsBuilder.include(it)
}
routeArriving.forEach {
boundsBuilder.include(it)
}
mLineStationLatLng.forEach {
boundsBuilder.include(it)
}
boundsBuilder.include(currentLatLng)
mAMap.moveCamera(
CameraUpdateFactory.newLatLngBoundsRect(
boundsBuilder.build(),
100,
100,
100,
100
)
)
} catch (e: Exception) {
e.printStackTrace()
}
}
override fun drawablePolyline() {
if (routeArrived.isEmpty() && routeArriving.isEmpty()) {
d(SceneConstant.M_TAXI + TAG, "没有点")
return
}
try {
texIndexList.clear()
val allPoints = ArrayList(routeArrived)
for (i in routeArrived.indices) {
if (routeArrived.size > 1 && i < routeArrived.size - 1) {
texIndexList.add(0)
}
}
texIndexList.add(0)
location?.let {
allPoints.add(LatLng(it.latitude, it.longitude))
}
allPoints.addAll(routeArriving)
for (ignored in routeArrived) {
texIndexList.add(1)
}
mPolyline?.let {
it.points = allPoints
it.options.customTextureIndex = texIndexList
return
}
if(textureList.isEmpty()) {
textureList.add(mArrivedRes)
textureList.add(mUnArrivedRes)
}
//设置线段纹理
val polylineOptions = PolylineOptions().apply {
addAll(allPoints)
isUseTexture = true
width(15f)
lineCapType(PolylineOptions.LineCapType.LineCapRound)
customTextureList = textureList
customTextureIndex = texIndexList
}
// 绘制线
mPolyline = mAMap.addPolyline(polylineOptions)
} catch (e: Exception) {
e.printStackTrace()
}
}
override fun clearPolyline() {
mPolyline?.remove()
mPolyline = null
}
override fun setLineMarker() {}
fun clearCoordinatesLatLng() {
textureList.clear()
texIndexList.clear()
routeArrived.clear()
routeArriving.clear()
mLineStationLatLng.clear()
d(M_BUS_P + TAG, " mCoordinatesLatLng.clear ")
}
fun onCreateView(savedInstanceState: Bundle?) {
mAMapNaviView.onCreate(savedInstanceState)
}
fun onResume() {
mAMapNaviView.onResume()
}
fun onPause() {
mAMapNaviView.onPause()
}
fun onDestroy() {
mAMapNaviView.onDestroy()
}
fun setCoordinatesLatLng(
routeArrived: List<LatLng>,
routeArriving: List<LatLng>,
location: MogoLocation?
) {
this.routeArrived.clear()
this.routeArrived.addAll(routeArrived)
this.routeArriving.clear()
this.routeArriving.addAll(routeArriving)
this.location = location
}
fun clearLineMarkers() {
for (i in mLineMarkers.indices) {
mLineMarkers[i].isVisible = false
mLineMarkers[i].remove()
}
mLineMarkers.clear()
}
fun setLinePointMarkerAndDraw(mLineStationsList: List<LatLng>, currentIndex: Int) {
clearLineMarkers()
mLineStationLatLng.clear()
mLineStationLatLng.addAll(mLineStationsList)
if (mLineStationsList.isNotEmpty()) {
// 起点marker, 终点marker, 过站marker, 未过站marker
val size = mLineStationsList.size
val mStartMarker = mAMap.addMarker(
MarkerOptions()
.icon(BitmapDescriptorFactory.fromResource(R.drawable.bus_p_map_start_point))
)
val mEndMarker = mAMap.addMarker(
MarkerOptions()
.icon(BitmapDescriptorFactory.fromResource(R.drawable.bus_p_map_end_point))
)
mStartMarker.position = mLineStationsList[0]
mLineMarkers.add(0, mStartMarker)
for (i in mLineStationsList.indices) {
if (currentIndex <= i && i < size - 1 && i > 0) { //未到达
val unArrivedMarker = mAMap.addMarker(
MarkerOptions()
.icon(BitmapDescriptorFactory.fromResource(R.drawable.bus_p_map_unarrived_point))
)
unArrivedMarker.position = mLineStationsList[i]
mLineMarkers.add(i, unArrivedMarker)
} else if (i in 1 until currentIndex) {
val arrivedMarker = mAMap.addMarker(
MarkerOptions()
.icon(BitmapDescriptorFactory.fromResource(R.drawable.bus_p_map_arrived_point))
)
arrivedMarker.position = mLineStationsList[i]
mLineMarkers.add(i, arrivedMarker)
}
}
mEndMarker.position = mLineStationsList[size - 1]
mLineMarkers.add(size - 1, mEndMarker)
}
}
override fun onCameraChange(cameraPosition: CameraPosition) {
}
override fun onCameraChangeFinish(cameraPosition: CameraPosition) {}
}

View File

@@ -16,21 +16,20 @@ import androidx.recyclerview.widget.RecyclerView;
import com.amap.api.maps.model.LatLng;
import com.elegant.utils.UiThreadHandler;
import com.mogo.commons.debug.DebugConfig;
import com.mogo.eagle.core.data.map.MogoLocation;
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener;
import com.mogo.eagle.core.function.hmi.ui.widget.DriverMonitorView;
import com.mogo.commons.storage.SharedPrefsMgr;
import com.mogo.och.bus.passenger.R;
import com.mogo.och.bus.passenger.adapter.BusPassengerLineStationsAdapter;
import com.mogo.och.bus.passenger.bean.BusPassengerStation;
import com.mogo.och.bus.passenger.ui.adapter.BusPassengerLineStationsAdapter;
import com.mogo.och.bus.passenger.constant.BusPassengerConst;
import com.mogo.och.bus.passenger.presenter.BaseBusPassengerPresenter;
import com.mogo.och.bus.passenger.ui.layoutmanager.CenterLayoutManager;
import com.mogo.och.bus.passenger.utils.BPRouteDataTestUtils;
import com.mogo.och.common.module.utils.NumberFormatUtil;
import com.mogo.och.common.module.wigets.MarqueeTextView;
import com.mogo.och.common.module.wigets.OCHGradientTextView;
import com.mogo.och.data.bean.BusStationBean;
import com.mogo.och.common.module.wigets.mapdirectionview.MapDirectionView;
import java.util.ArrayList;
import java.util.List;
@@ -44,14 +43,14 @@ public class BusPassengerRouteFragment extends
public static final String TAG = "BusPassengerRouteFragment";
private final List<BusPassengerStation> mStationsList = new ArrayList<>();
private final List<BusStationBean> mStationsList = new ArrayList<>();
private OCHGradientTextView mSpeedTv;
private ConstraintLayout mNoLineInfoView;
private MarqueeTextView mLineName;
private Group mRouteInfoView;
private RecyclerView mStationsListRv;
private BusPassengerMapDirectionView mMapDirectionView;
private MapDirectionView mMapDirectionView;
private BusPassengerLineStationsAdapter mAdapter;
private TextView emptyTv;
private AppCompatImageView mAutopilotIv;
@@ -129,17 +128,6 @@ public class BusPassengerRouteFragment extends
}
});
//测试
if (DebugConfig.isDebug()){
mSpeedTv.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
BPRouteDataTestUtils.converToRouteData();
return false;
}
});
}
mapAndLiveVideoView = findViewById(R.id.mapAndLiveVideoView);
initLiveView();
@@ -324,7 +312,7 @@ public class BusPassengerRouteFragment extends
* @param currentStationIndex
* @param isArrived 是否到站并离开true 到达当前站 currentStationIndex 未离开, false 正在前往此站 currentStationIndex
*/
public void updateStationsInfo(List<BusPassengerStation> stations, int currentStationIndex, boolean isArrived) {
public void updateStationsInfo(List<BusStationBean> stations, int currentStationIndex, boolean isArrived) {
updateArrivedStation(stations.get(currentStationIndex).getName(),currentStationIndex,isArrived);
mStationsList.clear();
mStationsList.addAll(stations);
@@ -345,7 +333,7 @@ public class BusPassengerRouteFragment extends
}
}
private void updateWayPointList(List<BusPassengerStation> stations,int currentStationIndex) {
private void updateWayPointList(List<BusStationBean> stations,int currentStationIndex) {
List<LatLng> mLineStationsList = new ArrayList<>();
for (int i = 0; i< stations.size(); i++) {//站点集合
LatLng latLng = new LatLng(stations.get(i).getGcjLat(),stations.get(i).getGcjLon());// lat,lon

View File

@@ -1,4 +1,4 @@
package com.mogo.och.bus.passenger.adapter;
package com.mogo.och.bus.passenger.ui.adapter;
import static com.mogo.och.bus.passenger.constant.BusPassengerConst.STATION_STATUS_ARRIVING;
import static com.mogo.och.bus.passenger.constant.BusPassengerConst.STATION_STATUS_LEAVING;
@@ -16,9 +16,9 @@ import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.mogo.och.bus.passenger.R;
import com.mogo.och.bus.passenger.bean.BusPassengerStation;
import com.mogo.och.common.module.utils.BlinkAnimationUtil;
import com.mogo.och.common.module.wigets.MarqueeTextView;
import com.mogo.och.data.bean.BusStationBean;
import java.util.List;
@@ -29,9 +29,9 @@ import java.util.List;
public class BusPassengerLineStationsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private Context mContext;
private List<BusPassengerStation> mStations;
private List<BusStationBean> mStations;
public BusPassengerLineStationsAdapter(Context context, List<BusPassengerStation> stations){
public BusPassengerLineStationsAdapter(Context context, List<BusStationBean> stations){
this.mContext = context;
this.mStations = stations;
}
@@ -46,7 +46,7 @@ public class BusPassengerLineStationsAdapter extends RecyclerView.Adapter<Recycl
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
BusPassengerStation station = mStations.get(position);
BusStationBean station = mStations.get(position);
StationViewHolder viewHolder = (StationViewHolder)holder;
viewHolder.stationName.setText(station.getName());
BlinkAnimationUtil.clearAnimation(viewHolder.stationCircle);
@@ -68,7 +68,7 @@ public class BusPassengerLineStationsAdapter extends RecyclerView.Adapter<Recycl
}else{
viewHolder.curArrowBg.setVisibility(View.VISIBLE);
viewHolder.curArrowBottomBg.setVisibility(View.VISIBLE);
BusPassengerStation preStation = mStations.get(position -1);
BusStationBean preStation = mStations.get(position -1);
if (station.getDrivingStatus() == STATION_STATUS_LEAVING ||
(station.getDrivingStatus() == STATION_STATUS_STOPPED && station.isLeaving())){ //过站
viewHolder.stationName.setTextColor(mContext.getResources().getColor(R.color.bus_p_clock_992D3E5F));

View File

@@ -1,21 +0,0 @@
package com.mogo.och.bus.passenger.passenger.bean;
import com.mogo.eagle.core.data.BaseData;
/**
* @author congtaowang
* @since 2021/3/22
*
* 小巴车运营状态返回参数
*/
public class PM2OperationStatusResponse 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

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

View File

@@ -1,79 +0,0 @@
package com.mogo.och.bus.passenger.passenger.bean;
import java.util.List;
import java.util.Objects;
/**
* 网约车小巴路线接口返回接口数据封装
*
* @author tongchenfei
*/
public class PM2RoutesResult {
private List<PM2Station> 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<PM2Station> 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;
PM2RoutesResult that = (PM2RoutesResult) 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

@@ -1,173 +0,0 @@
package com.mogo.och.bus.passenger.passenger.bean;
import java.util.Objects;
/**
* 单个网约车小巴车站信息
*
* @author wangmingjun
*/
public class PM2Station {
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;
PM2Station that = (PM2Station) 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

@@ -16,40 +16,36 @@ import com.mogo.eagle.core.data.config.FunctionBuildConfig
import com.mogo.eagle.core.data.map.MogoLocation
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationGCJ02Listener
import com.mogo.eagle.core.function.api.autopilot.IMoGoPlanningRottingListener
import com.mogo.eagle.core.function.api.telematic.IReceivedMsgListener
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ02ListenerManager
import com.mogo.eagle.core.function.call.autopilot.CallerPlanningRottingListenerManager
import com.mogo.eagle.core.function.call.telematic.CallerTelematicListenerManager
import com.mogo.eagle.core.function.call.telematic.CallerTelematicManager.sendMsgToServer
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
import com.mogo.eagle.core.utilcode.util.CoordinateUtils
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_BUS_P
import com.mogo.eagle.core.utilcode.util.GsonUtils
import com.mogo.eagle.core.utilcode.util.NetworkUtils
import com.mogo.eagle.core.utilcode.util.ToastUtils
import com.mogo.och.bus.passenger.R
import com.mogo.och.bus.passenger.bean.BusPassengerOperationStatusResponse
import com.mogo.och.bus.passenger.constant.BusPassengerConst
import com.mogo.och.bus.passenger.passenger.callback.AutoPilotStatusCallback
import com.mogo.och.bus.passenger.passenger.callback.DrivingInfoCallback
import com.mogo.och.bus.passenger.passenger.model.PM2ServiceManager.driverAppSn
import com.mogo.och.bus.passenger.passenger.network.PM2ModelLoopManager
import com.mogo.och.common.module.bean.dpmsg.*
import com.mogo.och.common.module.biz.common.socketmessage.OCHSocketMessageManager.pushAppOperationalMsgBox
import com.mogo.och.common.module.biz.constant.OchCommonConst
import com.mogo.och.common.module.biz.network.OchCommonServiceCallback
import com.mogo.och.common.module.utils.CoordinateCalculateRouteUtil
import com.mogo.och.common.module.utils.DateTimeUtil
import com.mogo.och.common.module.utils.RxUtils
import com.mogo.och.data.bean.BusRoutesResult
import com.mogo.och.data.bean.BusStationBean
import com.mogo.och.data.bean.BusTransferData
import io.reactivex.disposables.Disposable
import mogo.telematics.pad.MessagePad
import com.mogo.och.bus.passenger.passenger.bean.PM2OperationStatusResponse
import com.mogo.och.bus.passenger.passenger.bean.PM2RoutesResponse
import com.mogo.och.bus.passenger.bean.PM2RoutesResponse
import com.mogo.och.bus.passenger.network.BusPassengerServiceManager
import com.mogo.och.common.module.manager.distancemamager.IDistanceListener
import com.mogo.och.common.module.manager.distancemamager.TrajectoryAndDistanceManager
import com.mogo.och.common.module.manager.loopmanager.BizLoopManager
import com.mogo.och.common.module.manager.loopmanager.LoopInfo
import kotlin.math.abs
/**
@@ -64,23 +60,14 @@ class PM2DrivingModel private constructor() {
private var mRoutePoints = mutableListOf<MogoLocation>()
private var routesResult: BusRoutesResult? = null
private var mCurrentAutoStatus = -1
var mStations = mutableListOf<BusStationBean>()
private var mNextStationIndex = 0 // A-B要到达站的index
private var isGoingToNextStation = false //是否前往下一站过程中
private var mTwoStationsRouts = mutableListOf<MogoLocation>()
private var mPreRouteIndex = 0
private var mWipePreIndex = 0
private var mDrivingInfoCallback: DrivingInfoCallback? = null //行程信息
private var mAutoStatusCallback: AutoPilotStatusCallback? = null //自动驾驶状态
private var operationStatus: PM2OperationStatusResponse.Result? = null
@Volatile
private var globalPathTruncation: Disposable? = null
private var operationStatus: BusPassengerOperationStatusResponse.Result? = null
private val handler = Handler(Handler.Callback { msg ->
if (msg.what == MSG_QUERY_BUS_P_STATION) {
@@ -92,18 +79,22 @@ class PM2DrivingModel private constructor() {
companion object {
val TAG = PM2DrivingModel::class.java.simpleName
val TAG_LOOP_QUERY_BIND_LINE = "${TAG}_TAG_LOOP_QUERY_BIND_LINE"
const val MSG_QUERY_BUS_P_STATION = 1001
val INSTANCE: PM2DrivingModel by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) {
PM2DrivingModel()
}
}
fun init(context : Context){
fun init(context: Context) {
mContext = context
initListener()
queryDriverByLocalDriver()
queryDriverOperationStatus()
startOrStopOrderLoop(true)
BizLoopManager.setLoopFunction(
TAG_LOOP_QUERY_BIND_LINE,
LoopInfo(2, ::queryDriverSiteByCoordinate)
)
}
private fun queryDriverByLocalDriver() {
@@ -117,17 +108,16 @@ class PM2DrivingModel private constructor() {
CallerAutoPilotStatusListenerManager.addListener(TAG, mAutoPilotStatusListener)
// 定位监听
CallerChassisLocationGCJ02ListenerManager.addListener(TAG, 10,mMapLocationListener)
CallerChassisLocationGCJ02ListenerManager.addListener(TAG, 10, mMapLocationListener)
//司乘屏通信监听
CallerTelematicListenerManager.addListener(TAG,mReceivedMsgListener)
//自动驾驶轨迹监听
CallerPlanningRottingListenerManager.addListener(TAG, moGoAutopilotPlanningListener)
CallerTelematicListenerManager.addListener(TAG, mReceivedMsgListener)
//网络监听
IntentManager.getInstance().registerIntentListener(ConnectivityManager.CONNECTIVITY_ACTION, mNetWorkIntentListener)
IntentManager.getInstance()
.registerIntentListener(ConnectivityManager.CONNECTIVITY_ACTION, mNetWorkIntentListener)
TrajectoryAndDistanceManager.addDistanceListener(TAG, trajectoryListener)
}
private fun sendMsgToServer(msg: String) {
@@ -137,7 +127,7 @@ class PM2DrivingModel private constructor() {
)
}
fun releaseListener(){
fun releaseListener() {
//自动驾驶状态监听
CallerAutoPilotStatusListenerManager.removeListener(TAG)
@@ -146,64 +136,67 @@ class PM2DrivingModel private constructor() {
CallerTelematicListenerManager.removeListener(TAG)
//自动驾驶轨迹监听
CallerPlanningRottingListenerManager.removeListener(TAG)
TrajectoryAndDistanceManager.removeListener(TAG)
BizLoopManager.removeLoopFunction(TAG_LOOP_QUERY_BIND_LINE)
cleanStation("release")
}
fun setDrivingInfoCallback(drivingInfoCallback : DrivingInfoCallback?){
fun setDrivingInfoCallback(drivingInfoCallback: DrivingInfoCallback?) {
mDrivingInfoCallback = drivingInfoCallback
}
fun setAutoStatusCallback(autoPilotStatusCallback: AutoPilotStatusCallback?){
fun setAutoStatusCallback(autoPilotStatusCallback: AutoPilotStatusCallback?) {
mAutoStatusCallback = autoPilotStatusCallback
}
private val mNetWorkIntentListener = IMogoIntentListener { intentStr, _ ->
if (ConnectivityManager.CONNECTIVITY_ACTION == intentStr) {
if (NetworkUtils.isConnected(mContext)) {
queryDriverOperationStatus()
}
if (ConnectivityManager.CONNECTIVITY_ACTION == intentStr) {
if (NetworkUtils.isConnected(mContext)) {
queryDriverOperationStatus()
}
}
}
private val mReceivedMsgListener: IReceivedMsgListener =
object : IReceivedMsgListener{
object : IReceivedMsgListener {
@RequiresApi(Build.VERSION_CODES.O)
override fun onReceivedMsg(type: Int, byteArray: ByteArray) {//接收司机端发来的信息
if (OchCommonConst.BUSINESS_STRING == type){
if (OchCommonConst.BUSINESS_STRING == type) {
val baseMsg = GsonUtils.fromJson(String(byteArray), BaseDPMsg::class.java)
Logger.d(
SceneConstant.M_BUS_P + TAG, "onReceivedMsg = " + GsonUtils.toJson(baseMsg)
M_BUS_P + TAG, "onReceivedMsg = " + GsonUtils.toJson(baseMsg)
)
if (baseMsg != null && baseMsg.type == DPMsgType.TYPE_COMMON.type) {
val msg = GsonUtils.fromJson(String(byteArray), AppConnectMsg::class.java)
if (msg != null && msg.isPlay){ //播报
if (msg != null && msg.isPlay) { //播报
speakTTS(msg.msg)
}
if (msg != null && msg.isViewShow) { //消息盒子显示内容
pushAppOperationalMsgBox(
DateTimeUtil.getCurrentTimeStamp(),msg.msg)
pushAppOperationalMsgBox(
DateTimeUtil.getCurrentTimeStamp(), msg.msg
)
}
}else if (baseMsg != null && baseMsg.type == DPMsgType.TYPE_TASK_DETAILS.type) {
} else if (baseMsg != null && baseMsg.type == DPMsgType.TYPE_TASK_DETAILS.type) {
val msg = GsonUtils.fromJson(String(byteArray), TaskDetailsMsg::class.java)
Logger.d(
SceneConstant.M_BUS_P + TAG, "onReceivedMsg = " + GsonUtils.toJson(msg)
)
Logger.d(M_BUS_P + TAG, "onReceivedMsg = " + GsonUtils.toJson(msg))
if (msg == null || msg.msg?.isEmpty() == true) {
updateLocalOrder()
return
}
val result = GsonUtils.fromJson(msg.msg, BusTransferData::class.java)
mDrivingInfoCallback?.changeOperationStatus(result.loginStatus == 1)
if (result != null && result.routesResult == null){
if (result != null && result.routesResult == null) {
updateLocalOrder()
}
if (routesResult == null ||
(result != null && result.routesResult?.writeVersion!! > routesResult!!.writeVersion)) {
(result != null && result.routesResult?.writeVersion!! > routesResult!!.writeVersion)
) {
routesResult = result.routesResult
updatePassengerRouteInfo(routesResult!!)
}
@@ -216,34 +209,51 @@ class PM2DrivingModel private constructor() {
@RequiresApi(Build.VERSION_CODES.O)
private fun speakTTS(msg: String) {
var mAudioManager = mContext?.getSystemService(Context.AUDIO_SERVICE) as AudioManager
var mAudioAttributes = AudioAttributes.Builder()
.setUsage(AudioAttributes.USAGE_MEDIA) //设置声音的用途
.setContentType(AudioAttributes.CONTENT_TYPE_MUSIC) //设置声音的类型
.build()
var mAudioFocusRequest = AudioFocusRequest.Builder(AudioManager.AUDIOFOCUS_GAIN_TRANSIENT_MAY_DUCK) //设置焦点类型
.setAudioAttributes(mAudioAttributes) //设置声音属性
.setAcceptsDelayedFocusGain(false) //设置接受延迟获取焦点需要设置OnAudioFocusChangeListener来监听焦点的获取
val mAudioManager = mContext?.getSystemService(Context.AUDIO_SERVICE) as AudioManager
val mAudioAttributes = AudioAttributes.Builder()
.setUsage(AudioAttributes.USAGE_MEDIA) //设置声音的用途
.setContentType(AudioAttributes.CONTENT_TYPE_MUSIC) //设置声音的类型
.build()
val mAudioFocusRequest =
AudioFocusRequest.Builder(AudioManager.AUDIOFOCUS_GAIN_TRANSIENT_MAY_DUCK) //设置焦点类型
.setAudioAttributes(mAudioAttributes) //设置声音属性
.setAcceptsDelayedFocusGain(false) //设置接受延迟获取焦点需要设置OnAudioFocusChangeListener来监听焦点的获取
.build()
mAudioManager.requestAudioFocus(mAudioFocusRequest) //抢占焦点
AIAssist.getInstance(mContext).speakTTSVoiceWithLevel(msg,AIAssist.LEVEL0,object : IMogoVoiceCmdCallBack{
override fun onSpeakEnd(speakText: String?) {
mAudioManager.abandonAudioFocusRequest(mAudioFocusRequest)
}
AIAssist.getInstance(mContext)
.speakTTSVoiceWithLevel(msg, AIAssist.LEVEL0, object : IMogoVoiceCmdCallBack {
override fun onSpeakEnd(speakText: String?) {
mAudioManager.abandonAudioFocusRequest(mAudioFocusRequest)
}
override fun onSpeakError(speakText: String?, errorMsg: String?) {
mAudioManager.abandonAudioFocusRequest(mAudioFocusRequest)
}
override fun onSpeakError(speakText: String?, errorMsg: String?) {
mAudioManager.abandonAudioFocusRequest(mAudioFocusRequest)
}
override fun onSpeakSelectTimeOut(speakText: String?) {
mAudioManager.abandonAudioFocusRequest(mAudioFocusRequest)
override fun onSpeakSelectTimeOut(speakText: String?) {
mAudioManager.abandonAudioFocusRequest(mAudioFocusRequest)
}
})
}
private val trajectoryListener: IDistanceListener = object : IDistanceListener {
override fun distanceCallback(distance: Float) {
val lastTime = distance / BusPassengerConst.BUS_AVERAGE_SPEED * 3.6 //秒
d(M_BUS_P + TAG, "轨迹排查==lastSumLength = $distance")
if (routesResult != null) {
for (site in routesResult!!.sites) {
if (site.drivingStatus == BusPassengerConst.STATION_STATUS_STOPPED && !site.isLeaving) {
return
}
}
}
})
mDrivingInfoCallback?.updateRemainMT(distance.toLong(), lastTime.toLong())
}
}
private val mMapLocationListener: IMoGoChassisLocationGCJ02Listener =
object : IMoGoChassisLocationGCJ02Listener{
object : IMoGoChassisLocationGCJ02Listener {
override fun onChassisLocationGCJ02(mogoLocation: MogoLocation?) {
if (null == mogoLocation) return
mLocation = mogoLocation
@@ -251,45 +261,6 @@ class PM2DrivingModel private constructor() {
}
}
private val moGoAutopilotPlanningListener = object : IMoGoPlanningRottingListener{
@Synchronized
override fun onAutopilotRotting(globalPathResp: MessagePad.GlobalPathResp?) {
d(SceneConstant.M_BUS_P + TAG, "och-rotting==globalPathResp = " + GsonUtils.toJson(globalPathResp))
globalPathResp?.let {
d(SceneConstant.M_BUS_P + TAG, "och-rotting==wayPointsSize = " + it.wayPointsList.size)
if (globalPathTruncation != null && !globalPathTruncation!!.isDisposed) {
d(SceneConstant.M_BUS_P + TAG, "1s内不可以接受轨迹")
return@let
}
globalPathTruncation = RxUtils.createSubscribe(1_000) {
d(SceneConstant.M_BUS_P + TAG, "可以接受轨迹")
}
d(SceneConstant.M_BUS_P + TAG, "接受轨迹中")
it.wayPointsList?.let {list->
updateRoutePoints(list)
}
}
}
}
@Synchronized
fun updateRoutePoints(routePoints: List<MessagePad.Location>) {
mRoutePoints.clear()
val latLngModels = CoordinateCalculateRouteUtil
.coordinateConverterWgsToGcjLocations(mContext, routePoints)
d(SceneConstant.M_BUS_P + TAG, "och-rotting==latLngModels = " + latLngModels.size)
mRoutePoints.addAll(latLngModels)
if (isGoingToNextStation){
mTwoStationsRouts.clear()
startRemainRouteInfo()
}
}
private fun updateSpeed(mogoLocation: MogoLocation) {
// km/h
val speedKM = (abs(mogoLocation.gnssSpeed) * 3.6f).toInt()
@@ -302,17 +273,18 @@ class PM2DrivingModel private constructor() {
override fun onAutopilotStatusResponse(state: Int) {
super.onAutopilotStatusResponse(state)
d(SceneConstant.M_BUS_P+ TAG, "onAutopilotStatusResponse ===== $state")
if (IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING != state){
d(M_BUS_P + TAG, "onAutopilotStatusResponse ===== $state")
if (IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING != state) {
//美化模式下且行程中
if (FunctionBuildConfig.isDemoMode &&
mNextStationIndex>= 0 && mNextStationIndex <= mStations.size - 1
&& isGoingToNextStation){
mNextStationIndex >= 0 && mNextStationIndex <= mStations.size - 1
&& isGoingToNextStation
) {
mAutoStatusCallback?.updateAutoStatus(true)
}else{//非美化模式下
} else {//非美化模式下
mAutoStatusCallback?.updateAutoStatus(false)
}
}else{//自驾状态 2
} else {//自驾状态 2
mAutoStatusCallback?.updateAutoStatus(true)
}
}
@@ -328,22 +300,21 @@ class PM2DrivingModel private constructor() {
private fun queryDriverOperationStatus() {
mContext?.let {
PM2ServiceManager.queryDriverOperationStatus(
BusPassengerServiceManager.queryDriverOperationStatus(
it,
object : OchCommonServiceCallback<PM2OperationStatusResponse> {
override fun onSuccess(data: PM2OperationStatusResponse?) {
object : OchCommonServiceCallback<BusPassengerOperationStatusResponse> {
override fun onSuccess(data: BusPassengerOperationStatusResponse?) {
if (data?.data == null) return
if (data.data.driverStatus != operationStatus?.driverStatus
|| data.data.plateNumber != operationStatus?.plateNumber
) {
d(
SceneConstant.M_BUS_P + TAG,
M_BUS_P + TAG,
"queryDriverOperationStatus ===== 车牌或者登陆状态有变更"
)
mDrivingInfoCallback?.changeOperationStatus(data.data.driverStatus == 1)
}
operationStatus = data.data as PM2OperationStatusResponse.Result
// mDrivingInfoCallback?.updatePlateNumber(data.data.plateNumber)
operationStatus = data.data as BusPassengerOperationStatusResponse.Result
}
override fun onError() {
@@ -352,7 +323,6 @@ class PM2DrivingModel private constructor() {
} else {
ToastUtils.showShort(mContext!!.getString(R.string.request_error_tip))
}
// queryDriverOperationDelay()
queryDriverByLocalDriver()
}
@@ -364,9 +334,9 @@ class PM2DrivingModel private constructor() {
}
}
fun queryDriverSiteByCoordinate(){
private fun queryDriverSiteByCoordinate() {
mContext?.let {
PM2ServiceManager.queryDriverSiteByCoordinate(it,
BusPassengerServiceManager.queryDriverSiteByCoordinate(it,
object : OchCommonServiceCallback<PM2RoutesResponse> {
override fun onSuccess(data: PM2RoutesResponse?) {
@@ -374,19 +344,13 @@ class PM2DrivingModel private constructor() {
if (routesResult != null) {
routesResult = null
updateLocalOrder()
d(
SceneConstant.M_BUS_P + TAG,
"queryDriverSiteByCoordinate= result is null"
)
d(M_BUS_P + TAG, "queryDriverSiteByCoordinate= result is null")
return
}
return
}
if (data.result != null && data.result.equals(routesResult)) {
d(
SceneConstant.M_BUS_P + TAG,
"queryDriverSiteByCoordinate= not update"
)
d(M_BUS_P + TAG, "queryDriverSiteByCoordinate= not update")
return
}
@@ -403,26 +367,22 @@ class PM2DrivingModel private constructor() {
}
override fun onError() {
d(
SceneConstant.M_BUS_P + TAG,
"queryDriverSiteByCoordinate = onError ="
+ ", sn = " + driverAppSn
)
d(M_BUS_P + TAG, "queryDriverSiteByCoordinate = onError = sn = " + BusPassengerServiceManager.driverAppSn)
queryDriverByLocalDriver()
}
override fun onFail(code: Int, msg: String?) {
d(SceneConstant.M_BUS_P + TAG, "queryDriverSiteByCoordinate = %s", msg)
d(M_BUS_P + TAG, "queryDriverSiteByCoordinate = %s", msg)
if (code == 1003) {
queryDriverOperationDelay()
cleanStation("queryDriverSiteByCoordinate 1003")
}
if (driverAppSn.isEmpty()) {
if (BusPassengerServiceManager.driverAppSn.isEmpty()) {
return
}
if (code == 1003) {
routesResult = null
isGoingToNextStation = false
startOrStopCalculateRouteInfo(false)
return
}
}
@@ -431,208 +391,91 @@ class PM2DrivingModel private constructor() {
}
}
private fun updateLocalOrder(){
private fun updateLocalOrder() {
mRoutePoints.clear()
routesResult = null
mNextStationIndex = 0
cleanStation("queryDriverSiteByCoordinate")
isGoingToNextStation = false
startOrStopCalculateRouteInfo(false)
mDrivingInfoCallback?.showNoTaskView(true)
}
private fun updatePassengerRouteInfo(result: BusRoutesResult) {
private fun updatePassengerRouteInfo(result: BusRoutesResult?) {
if (result == null) {
updateLocalOrder()
return
}
if (routesResult != null && routesResult!!.lineId != result.lineId){
d(SceneConstant.M_BUS_P+ TAG, "lineId change= clearCustomPolyline")
if (routesResult != null && routesResult!!.lineId != result.lineId) {
d(M_BUS_P + TAG, "lineId change= clearCustomPolyline")
mDrivingInfoCallback?.clearCustomPolyline()
}
d(SceneConstant.M_BUS_P+ TAG, "queryDriverSiteByCoordinate= update")
d(M_BUS_P + TAG, "queryDriverSiteByCoordinate= update")
routesResult = result
mDrivingInfoCallback?.updateLine(result.name, result.runningDur)
if (result.sites != null) {
mDrivingInfoCallback?.showNoTaskView(false)
val stations: List<BusStationBean> = result.sites
mStations.clear()
mStations.addAll(stations)
mDrivingInfoCallback?.updateLineStations(mStations)
for (i in stations.indices) {
val station: BusStationBean = stations[i]
if (station.drivingStatus == BusPassengerConst.STATION_STATUS_STOPPED
&& station.isLeaving && i + 1 < stations.size) {
mDrivingInfoCallback?.updateStationsInfo(stations as MutableList<BusStationBean>, i + 1, false)
d(SceneConstant.M_BUS_P+ TAG,"och-rotting--mNextStationIndex = $mNextStationIndex , i = $i")
// if (mNextStationIndex != i + 1) {
d(SceneConstant.M_BUS_P+ TAG,"och-rotting--start ")
mTwoStationsRouts.clear()
startRemainRouteInfo()
// }
isGoingToNextStation = true
mNextStationIndex = i + 1
return
} else if (station.drivingStatus == BusPassengerConst.STATION_STATUS_STOPPED && !station.isLeaving) {
d(SceneConstant.M_BUS_P+ TAG,"och-rotting--mNextStationIndex = $mNextStationIndex , i = $i")
d(SceneConstant.M_BUS_P+ TAG,"och-rotting--arrived ")
mPreRouteIndex = 0
isGoingToNextStation = false
startOrStopCalculateRouteInfo(false)
mDrivingInfoCallback?.updateStationsInfo(stations as MutableList<BusStationBean>, i, true)
return
}else{
// d(SceneConstant.M_BUS_P+TAG,"och-rotting--BusStationBean = " + GsonUtils.toJson(station))
}
}
}
}
fun loopRouteAndWipe(){
if (mRoutePoints != null && mRoutePoints.size > 0 && mLocation != null) {
val haveArrivedIndex = CoordinateCalculateRouteUtil
.getArrivedPointIndexNew(
mWipePreIndex,
mRoutePoints,
mLocation!!
)
mWipePreIndex = haveArrivedIndex
d(SceneConstant.M_BUS_P + TAG,
"thread = " + Thread.currentThread().name + " haveArrivedIndex== " + haveArrivedIndex
)
// if (mAutopilotPlanningCallback != null) {
// val routePoints = CoordinateCalculateRouteUtil
// .coordinateConverterLocationToLatLng(mContext, mRoutePoints)
// mAutopilotPlanningCallback.routeResult(routePoints, haveArrivedIndex)
// }
}
}
private fun startRemainRouteInfo() {
//开启实时计算剩余距离,剩余时间,预计时间
startOrStopCalculateRouteInfo(true)
}
fun dynamicCalculateRouteInfo(){
//计算当前位置和下一站的剩余点集合
//计算剩余点总里程和时间
d(SceneConstant.M_BUS_P + TAG, "och-rotting==mTwoStationsRouts.size() = " + mTwoStationsRouts.size)
//计算当前位置和下一站的剩余点集合
//计算剩余点总里程和时间
if (mTwoStationsRouts.size == 0) {
calculateTwoStationsRoute()
}
if (mTwoStationsRouts.size > 0 && mLocation != null) {
val lastPointsMap = CoordinateCalculateRouteUtil
.getRemainPointListByCompareNew(mPreRouteIndex, mTwoStationsRouts, mLocation!!)
for (index in lastPointsMap.keys) {
mPreRouteIndex = index
break
}
for (lastPoints in lastPointsMap.values) {
d(SceneConstant.M_BUS_P + TAG, "och-rotting==lastPoints.size() = " + lastPoints.size)
var lastSumLength = 0f
lastSumLength = if (lastPoints.size == 1) { //只是最后一个点,计算当前位置和最后一个点的距离
if (mNextStationIndex <= mStations.size - 1 && mNextStationIndex >= 0) {
val stationNext: BusStationBean = mStations[mNextStationIndex]
CoordinateUtils.calculateLineDistance(
stationNext.gcjLon, stationNext.gcjLat,
mLocation!!.longitude, mLocation!!.latitude
)
} else {
CoordinateUtils.calculateLineDistance(
lastPoints[0].longitude, lastPoints[0].latitude,
mLocation!!.longitude, mLocation!!.latitude
)
if (result.sites != null) {
mDrivingInfoCallback?.showNoTaskView(false)
val stations: List<BusStationBean> = result.sites
mStations.clear()
mStations.addAll(stations)
mDrivingInfoCallback?.updateLineStations(mStations)
for (i in stations.indices) {
val station: BusStationBean = stations[i]
if (station.drivingStatus == BusPassengerConst.STATION_STATUS_STOPPED
&& station.isLeaving && i + 1 < stations.size
) {
mDrivingInfoCallback?.updateStationsInfo(
stations as MutableList<BusStationBean>,
i + 1,
false
)
d(M_BUS_P + TAG, "och-rotting--mNextStationIndex = $mNextStationIndex , i = $i")
d(M_BUS_P + TAG, "och-rotting--start ")
isGoingToNextStation = true
mNextStationIndex = i + 1
val startStation = mStations[i]
val endStation = mStations[i + 1]
setTrajectoryStation(startStation, endStation, result.lineId)
return
} else if (station.drivingStatus == BusPassengerConst.STATION_STATUS_STOPPED && !station.isLeaving) {
d(M_BUS_P + TAG, "och-rotting--mNextStationIndex = $mNextStationIndex , i = $i")
d(M_BUS_P + TAG, "och-rotting--arrived ")
if (i == stations.size - 1) {
cleanStation("updatePassengerRouteInfo最后一个站点")
}
isGoingToNextStation = false
mDrivingInfoCallback?.updateStationsInfo(
stations as MutableList<BusStationBean>,
i,
true
)
return
} else {
CoordinateCalculateRouteUtil.calculateRouteSumLength(lastPoints)
}
val lastTime = lastSumLength / BusPassengerConst.SHUTTLE_AVERAGE_SPEED * 3.6 //秒
d(SceneConstant.M_BUS_P + TAG, "och-rotting==lastSumLength = $lastSumLength")
mDrivingInfoCallback?.updateRemainMT(
lastSumLength.toLong(),
lastTime.toLong()
)
}
}
}
private fun calculateTwoStationsRoute() {
//找出前往站对应的轨迹点,拿出两站点的集合
d(SceneConstant.M_BUS_P + TAG, "mRoutePoints.size() = " + mRoutePoints.size)
if (mRoutePoints.size > 0) {
if (mStations.size > 1) { //两个站点及以上要计算两个站点间的轨迹路线
if (mNextStationIndex <= mStations.size - 1 && mNextStationIndex - 1 >= 0) {
mTwoStationsRouts.clear()
val stationNext: BusStationBean = mStations[mNextStationIndex]
val stationCur: BusStationBean = mStations[mNextStationIndex - 1]
//当前站在轨迹中对应的点
val currentRouteIndex = CoordinateCalculateRouteUtil.getArrivedPointIndexNew(
0, mRoutePoints, stationCur.gcjLon, stationCur.gcjLat
)
//要前往的站在轨迹中对应的点
val nextRouteIndex = CoordinateCalculateRouteUtil.getArrivedPointIndexNew(
currentRouteIndex,
mRoutePoints,
stationNext.gcjLon,
stationNext.gcjLat
)
d(SceneConstant.M_BUS_P + TAG, "och-rotting==currentRouteIndex = " + currentRouteIndex
+ " nextRouteIndex = " + nextRouteIndex)
if (currentRouteIndex < nextRouteIndex) { //如果找到的next在起点的轨迹前面直接舍弃这个轨迹不显示
mTwoStationsRouts.addAll(
mRoutePoints.subList(
currentRouteIndex,
nextRouteIndex + 1
)
)
}
}
}
}
}
/**
* 开始轮询计算剩余里程和时间
* @param isStart
*/
fun startOrStopCalculateRouteInfo(isStart: Boolean) {
d(SceneConstant.M_BUS_P+ TAG, "startOrStopCalculateRouteInfo() $isStart")
if (isStart) {
PM2ModelLoopManager.startCalculateRouteInfoLoop()
} else {
mTwoStationsRouts.clear()
PM2ModelLoopManager.stopCalculateRouteInfLoop()
}
private fun setTrajectoryStation(
startStationInfo: BusStationBean,
endStationInfo: BusStationBean,
lineId: Int
) {
val startStation = MogoLocation()
startStation.longitude = startStationInfo.gcjLon
startStation.latitude = startStationInfo.gcjLat
val endStation = MogoLocation()
endStation.longitude = endStationInfo.gcjLon
endStation.latitude = endStationInfo.gcjLat
TrajectoryAndDistanceManager.setStationPoint(startStation, endStation, lineId.toLong())
}
/**
* 实时轨迹擦除
* @param isStart
*/
private fun startOrStopRouteAndWipe(isStart: Boolean) {
if (isStart) {
PM2ModelLoopManager.startOrStopRouteAndWipe()
} else {
mWipePreIndex = 0
PM2ModelLoopManager.stopOrStopRouteAndWipe()
}
}
private fun startOrStopOrderLoop(start: Boolean) {
d(SceneConstant.M_BUS_P + TAG, "startOrStopOrderLoop() $start")
if (start) {
PM2ModelLoopManager.startQueryDriverLineLoop()
} else {
PM2ModelLoopManager.stopQueryDriverLineLoop()
}
private fun cleanStation(type: String) {
d(M_BUS_P + TAG, "清理站点:$type")
TrajectoryAndDistanceManager.setStationPoint(null, null, -1L)
}
}

View File

@@ -1,108 +0,0 @@
package com.mogo.och.bus.passenger.passenger.model
import android.content.Context
import com.mogo.eagle.core.function.call.telematic.CallerTelematicManager.getServerToken
import com.mogo.cloud.passport.MoGoAiCloudClientConfig
import com.mogo.commons.debug.DebugConfig
import com.mogo.eagle.core.network.MoGoRetrofitFactory
import com.mogo.commons.storage.SharedPrefsMgr
import com.mogo.och.bus.passenger.bean.BusPassengerQueryLineRequest
import com.mogo.och.bus.passenger.passenger.bean.PM2OperationStatusResponse
import com.mogo.och.bus.passenger.passenger.bean.PM2RoutesResponse
import com.mogo.och.bus.passenger.passenger.network.PassengerSAASServiceApi
import com.mogo.och.bus.passenger.passenger.network.PassengerServiceApi
import com.mogo.och.common.module.biz.constant.OchCommonConst
import com.mogo.och.common.module.biz.network.OchCommonServiceCallback
import com.mogo.och.common.module.biz.network.OchCommonSubscribeImpl
import com.mogo.och.common.module.biz.network.interceptor.transformTry
/**
* Created on 2022/3/31
*/
object PM2ServiceManager {
private var mBusPassengerSaasServiceApi =
MoGoRetrofitFactory.getInstance(OchCommonConst.getBaseUrl()).create(PassengerSAASServiceApi::class.java)
private var mBusPassengerServiceApi =
MoGoRetrofitFactory.getInstance(OchCommonConst.getBaseUrl()).create(PassengerServiceApi::class.java)
private var driverSnCache = ""
/**
* 获取Bus司机端的sn
* @return
*/
public val driverAppSn: String
get(){
val serverToken = getServerToken()
if (serverToken != driverSnCache && serverToken.isNotEmpty()) {
driverSnCache = serverToken
}
return driverSnCache
}
/**
* 查询绑定行驶的小巴车路线
* @param context
* @param callback
*/
@JvmStatic
fun queryDriverSiteByCoordinate(
context: Context, callback: OchCommonServiceCallback<PM2RoutesResponse>?
) {
if (DebugConfig.getProjectFlavor().contains("saas")){
mBusPassengerSaasServiceApi.queryDriverSiteByCoordinate(
MoGoAiCloudClientConfig.getInstance().serviceAppId,
SharedPrefsMgr.getInstance().token,
driverAppSn
).transformTry()
.subscribe(OchCommonSubscribeImpl(context, callback, "queryDriverSiteByCoordinate"))
}else{
mBusPassengerServiceApi.queryDriverSiteByCoordinate(
MoGoAiCloudClientConfig.getInstance().serviceAppId,
SharedPrefsMgr.getInstance().token,
BusPassengerQueryLineRequest(
driverAppSn
)
).transformTry()
.subscribe(OchCommonSubscribeImpl(context, callback, "queryDriverSiteByCoordinate"))
}
}//2023-12-07 10:13:32
/**
* 查询司机端出车收车状态,以及车牌号
* @param context
* @param callback
*/
@JvmStatic
fun queryDriverOperationStatus(
context: Context,
callback: OchCommonServiceCallback<PM2OperationStatusResponse>?
) {
mBusPassengerServiceApi.queryDriverOperationStatus(
MoGoAiCloudClientConfig.getInstance().serviceAppId,
SharedPrefsMgr.getInstance().token,
driverAppSn
)
.transformTry()
.subscribe(OchCommonSubscribeImpl(context, callback, "queryDriverOperationStatus=sn =$driverAppSn"))
if (DebugConfig.getProjectFlavor().contains("saas")){
mBusPassengerSaasServiceApi.queryDriverOperationStatus(
MoGoAiCloudClientConfig.getInstance().serviceAppId,
SharedPrefsMgr.getInstance().token,
driverAppSn
)
.transformTry()
.subscribe(OchCommonSubscribeImpl(context, callback, "queryDriverOperationStatus"))
}else{
mBusPassengerServiceApi.queryDriverOperationStatus(
MoGoAiCloudClientConfig.getInstance().serviceAppId,
SharedPrefsMgr.getInstance().token,
driverAppSn
)
.transformTry()
.subscribe(OchCommonSubscribeImpl(context, callback, "queryDriverOperationStatus"))
}
}
}

View File

@@ -1,127 +0,0 @@
package com.mogo.och.bus.passenger.passenger.network
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.i
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
import com.mogo.och.bus.passenger.constant.BusPassengerConst
import com.mogo.och.bus.passenger.passenger.model.PM2DrivingModel
import io.reactivex.Observable
import io.reactivex.ObservableOnSubscribe
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.CompositeDisposable
import io.reactivex.disposables.Disposable
import io.reactivex.schedulers.Schedulers
import java.util.concurrent.TimeUnit
/**
* @author: wangmingjun
* @date: 2023/2/1
*/
object PM2ModelLoopManager {
private val TAG: String = PM2ModelLoopManager::class.java.getSimpleName()
private var mQueryLineDisposable: Disposable? = null //心跳轮询
private var mRouteWipeDisposable: CompositeDisposable? = null //估计擦除
private var mCalculateRouteDisposable: CompositeDisposable? = null //每隔2s计算一次剩余里程和时间
fun startOrStopRouteAndWipe() {
i(SceneConstant.M_BUS_P + TAG, "startOrStopRouteWipe()")
if (mRouteWipeDisposable != null) return
if (mRouteWipeDisposable == null) {
mRouteWipeDisposable = CompositeDisposable()
}
val disposable = startLoopRouteAndWipe()
.doOnSubscribe { }
.doOnError { }
.delay(
BusPassengerConst.LOOP_LINE_1S,
TimeUnit.MILLISECONDS,
true
) // 设置delayError为true表示出现错误的时候也需要延迟5s进行通知达到无论是请求正常还是请求失败都是5s后重新订阅即重新请求。
.subscribeOn(Schedulers.io())
.repeat() // repeat保证请求成功后能够重新订阅。
.retry() // retry保证请求失败后能重新订阅
.observeOn(AndroidSchedulers.mainThread())
.subscribe { }
mRouteWipeDisposable!!.add(disposable)
}
fun stopOrStopRouteAndWipe() {
if (mRouteWipeDisposable != null) {
mRouteWipeDisposable!!.dispose()
mRouteWipeDisposable = null
}
}
fun startQueryDriverLineLoop() {
if (mQueryLineDisposable != null && !mQueryLineDisposable!!.isDisposed) {
return
}
i(SceneConstant.M_BUS_P + TAG, "startQueryDriverLineLoop()")
mQueryLineDisposable = Observable.interval(
BusPassengerConst.LOOP_DELAY,
BusPassengerConst.LOOP_LINE_2S, TimeUnit.MILLISECONDS
)
.map { aLong: Long -> aLong + 1 }
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe { aLong: Long? ->
PM2DrivingModel.INSTANCE.queryDriverSiteByCoordinate()
}
}
fun stopQueryDriverLineLoop() {
if (mQueryLineDisposable != null) {
i(SceneConstant.M_BUS_P + TAG, "stopQueryDriverLineLoop()")
mQueryLineDisposable!!.dispose()
mQueryLineDisposable = null
}
}
fun startCalculateRouteInfoLoop() {
i(SceneConstant.M_BUS_P + TAG, "startCalculateRouteInfoLoop()")
if (mCalculateRouteDisposable != null) return
if (mCalculateRouteDisposable == null) {
mCalculateRouteDisposable = CompositeDisposable()
}
val disposable = startLoopCalculateRouteInfo()
.doOnSubscribe { }
.doOnError { }
.delay(
BusPassengerConst.LOOP_LINE_2S,
TimeUnit.MILLISECONDS,
true
) // 设置delayError为true表示出现错误的时候也需要延迟5s进行通知达到无论是请求正常还是请求失败都是5s后重新订阅即重新请求。
.subscribeOn(Schedulers.io())
.repeat() // repeat保证请求成功后能够重新订阅。
.retry() // retry保证请求失败后能重新订阅
.observeOn(AndroidSchedulers.mainThread())
.subscribe { }
mCalculateRouteDisposable!!.add(disposable)
}
fun stopCalculateRouteInfLoop() {
if (mCalculateRouteDisposable != null) {
i(SceneConstant.M_BUS_P + TAG, "stopCalculateRouteInfLoop()")
mCalculateRouteDisposable!!.dispose()
mCalculateRouteDisposable = null
}
}
private fun startLoopRouteAndWipe(): Observable<Int?> {
return Observable.create(ObservableOnSubscribe { emitter ->
if (emitter.isDisposed) return@ObservableOnSubscribe
PM2DrivingModel.INSTANCE.loopRouteAndWipe()
emitter.onComplete()
})
}
private fun startLoopCalculateRouteInfo(): Observable<Int?> {
return Observable.create(ObservableOnSubscribe { emitter ->
if (emitter.isDisposed) return@ObservableOnSubscribe
PM2DrivingModel.INSTANCE.dynamicCalculateRouteInfo()
emitter.onComplete()
})
}
}

View File

@@ -1,40 +0,0 @@
package com.mogo.och.bus.passenger.passenger.network;
import com.mogo.och.bus.passenger.passenger.bean.PM2OperationStatusResponse;
import com.mogo.och.bus.passenger.passenger.bean.PM2QueryLineRequest;
import com.mogo.och.bus.passenger.passenger.bean.PM2RoutesResponse;
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乘客端接口定义
*/
public interface PM2ServiceApi {
/**
* 查询bus司机端绑定路线
* @return 接口返回数据
*/
@Headers( {"Content-Type:application/json;charset=UTF-8"} )
@POST( "/och-shuttle-cabin/api/business/v1/passenger/lineDataWithDriver/query" )
Observable<PM2RoutesResponse> queryDriverSiteByCoordinate(@Header("appId") String appId, @Header("ticket") String ticket, @Body PM2QueryLineRequest request);
/**
* 查询司机端的登陆状态
* @param sn
* @return
*/
@Headers({"Content-type:application/json;charset=UTF-8"})
// @GET("/autopilot-car-hailing/car/v2/driver/bus/passenger/takeOrderStatus/query")
@GET("/och-shuttle-cabin/api/business/v1/passenger/loginStatus")
Observable<PM2OperationStatusResponse> queryDriverOperationStatus(@Header ("appId") String appId, @Header("ticket") String ticket, @Query("sn") String sn);
}

View File

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

View File

@@ -1,40 +0,0 @@
package com.mogo.och.bus.passenger.passenger.network;
import com.mogo.och.bus.passenger.bean.BusPassengerQueryLineRequest;
import com.mogo.och.bus.passenger.passenger.bean.PM2OperationStatusResponse;
import com.mogo.och.bus.passenger.passenger.bean.PM2RoutesResponse;
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乘客端接口定义
*/
public interface PassengerServiceApi {
/**
* 查询bus司机端绑定路线
* @return 接口返回数据
*/
@Headers( {"Content-Type:application/json;charset=UTF-8"} )
@POST( "/autopilot-car-hailing/line/v2/driver/bus/passenger/lineDataWithDriver/query" )
Observable<PM2RoutesResponse> 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<PM2OperationStatusResponse> queryDriverOperationStatus(@Header ("appId") String appId, @Header("ticket") String ticket, @Query("sn") String sn);
}

View File

@@ -277,7 +277,7 @@
</androidx.constraintlayout.widget.ConstraintLayout>
<com.mogo.och.bus.passenger.ui.BusPassengerMapDirectionView
<com.mogo.och.common.module.wigets.mapdirectionview.MapDirectionView
android:id="@+id/busPLineMapView"
android:layout_width="@dimen/bus_p_route_info_panel_width"
android:layout_height="@dimen/bus_p_route_line_map_view_height"

View File

@@ -1,10 +1,10 @@
package com.mogo.och.bus.passenger.ui;
package com.mogo.och.common.module.wigets.mapdirectionview;
/**
* @author xiaoyuzhou
* @date 2021/6/24 11:33 上午
*/
public interface IBusPassengerMapDirectionView {
public interface IMapDirectionView {
/**
* 绘制路径线

View File

@@ -1,4 +1,4 @@
package com.mogo.och.shuttle.passenger.ui.mapdirectionview
package com.mogo.och.common.module.wigets.mapdirectionview
import android.content.Context
import android.os.Bundle
@@ -24,46 +24,97 @@ import com.amap.api.maps.model.PolylineOptions
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.eagle.core.utilcode.mogo.MapAssetStyleUtils
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
import com.mogo.och.shuttle.passenger.R
import com.mogo.och.shuttle.passenger.ui.IBusPassengerMapDirectionView
import com.mogo.och.shuttle.passenger.utils.BusPassengerMapAssetStyleUtil
import com.mogo.och.common.module.R
import com.mogo.och.shuttle.passenger.ui.mapdirectionview.MapDirectionViewModel
import me.jessyan.autosize.utils.AutoSizeUtils
/**
* 乘客屏小地图
*/
class BusPassengerMapDirectionView @JvmOverloads constructor(
class MapDirectionView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
) : RelativeLayout(context, attrs, defStyleAttr), IMoGoChassisLocationGCJ02Listener,
IBusPassengerMapDirectionView, AMap.OnCameraChangeListener,
IMapDirectionView, AMap.OnCameraChangeListener,
MapDirectionViewModel.ItineraryViewCallback {
companion object {
//小地图名称
const val TAG = "BusPassengerMapDirectionView"
}
private var mapStylePath: String? = null
private var mapStyleExtraPath: String? = null
private var carDrawable: Int = -1
private var compassDrawable: Int = -1
private var startPointDrawable: Int = -1
private var endPointDrawable: Int = -1
private var arrivedDrawable: Int = -1
private var unArrivedDrawable: Int = -1
private var resetDrawableMarginRight: Int = -1
private var resetDrawableMarginBottom: Int = -1
private var leftPadding: Int = 100
private var topPadding: Int = 100
private var rightPadding: Int = 100
private var bottomPadding: Int = 100
private lateinit var mAMapNaviView: TextureMapView
private lateinit var mAMap: AMap
private var mPolyline: Polyline? = null
private val mLineMarkers: MutableList<Marker> = ArrayList()
private lateinit var mCarMarker: Marker
// 除了开始站点和结束站点的中间站点 用来设置图标和地图范围圈定
private val mLineStationLatLng: MutableList<LatLng> = ArrayList() //站点坐标数据
var textureList: MutableList<BitmapDescriptor?> = ArrayList()
var texIndexList: MutableList<Int> = ArrayList()
private var mArrivedRes: BitmapDescriptor? = null
private var mUnArrivedRes: BitmapDescriptor? = null
private var mStartStationPoint: BitmapDescriptor? = null
private var mEndStationPoint: BitmapDescriptor? = null
private var mArrivedStationPoint: BitmapDescriptor? = null
private var mUArrivedStationPoint: BitmapDescriptor? = null
private val routeArrived: MutableList<LatLng> = ArrayList()
private val routeArriving: MutableList<LatLng> = ArrayList()
private var location: MogoLocation? = null
init {
try {
val typedArray = context.obtainStyledAttributes(attrs, R.styleable.MapDirectionView)
mapStylePath = typedArray.getString(R.styleable.MapDirectionView_mapStylePath)
mapStyleExtraPath = typedArray.getString(R.styleable.MapDirectionView_mapStyleExtraPath)
carDrawable = typedArray.getResourceId(R.styleable.MapDirectionView_carDrawable, -1)
compassDrawable = typedArray.getResourceId(R.styleable.MapDirectionView_compassDrawable, -1)
startPointDrawable =
typedArray.getResourceId(R.styleable.MapDirectionView_startPointDrawable, -1)
endPointDrawable =
typedArray.getResourceId(R.styleable.MapDirectionView_endPointDrawable, -1)
arrivedDrawable = typedArray.getResourceId(R.styleable.MapDirectionView_arrivedDrawable, -1)
unArrivedDrawable =
typedArray.getResourceId(R.styleable.MapDirectionView_unArrivedDrawable, -1)
resetDrawableMarginRight = typedArray.getResourceId(
R.styleable.MapDirectionView_resetDrawableMarginRight,
AutoSizeUtils.dp2px(context, 40f)
)
resetDrawableMarginBottom = typedArray.getResourceId(
R.styleable.MapDirectionView_resetDrawableMarginBottom,
AutoSizeUtils.dp2px(context, 40f)
)
leftPadding = typedArray.getInt(R.styleable.MapDirectionView_leftPadding, 100)
topPadding = typedArray.getInt(R.styleable.MapDirectionView_topPadding, 100)
rightPadding = typedArray.getInt(R.styleable.MapDirectionView_rightPadding, 100)
bottomPadding = typedArray.getInt(R.styleable.MapDirectionView_bottomPadding, 100)
typedArray.recycle()
initView(context)
} catch (e: Exception) {
e.printStackTrace()
@@ -77,7 +128,7 @@ class BusPassengerMapDirectionView @JvmOverloads constructor(
initAMapView()
// 注册定位监听
CallerChassisLocationGCJ02ListenerManager.addListener(TAG, 10, this)
CallerChassisLocationGCJ02ListenerManager.addListener(TAG, 1, this)
}
override fun onDetachedFromWindow() {
@@ -96,25 +147,27 @@ class BusPassengerMapDirectionView @JvmOverloads constructor(
// 设置 锚点 图标
mCarMarker = mAMap.addMarker(
MarkerOptions().icon(BitmapDescriptorFactory.fromResource(R.drawable.shuttle_p_jl_map_car))
MarkerOptions().icon(
BitmapDescriptorFactory.fromResource(if (carDrawable != -1) carDrawable else R.drawable.common_map_car))
.anchor(0.5f, 0.5f)
)
mArrivedRes = BitmapDescriptorFactory.fromResource(R.drawable.shuttle_p_jl_map_arrow_arrived)
mUnArrivedRes = BitmapDescriptorFactory.fromResource(R.drawable.shuttle_p_jl_map_arrow_un_arrive)
mArrivedRes = BitmapDescriptorFactory.fromResource(if (arrivedDrawable != -1) arrivedDrawable else R.drawable.taxi_map_arrow_arrived)
mUnArrivedRes = BitmapDescriptorFactory.fromResource(if (unArrivedDrawable != -1) unArrivedDrawable else R.drawable.taxi_map_arrow_un_arrive)
mStartStationPoint = BitmapDescriptorFactory.fromResource(if (startPointDrawable != -1) startPointDrawable else R.drawable.common_map_start_point)
mEndStationPoint = BitmapDescriptorFactory.fromResource(if (endPointDrawable != -1) endPointDrawable else R.drawable.common_map_end_point)
mArrivedStationPoint = BitmapDescriptorFactory.fromResource(if (endPointDrawable != -1) endPointDrawable else R.drawable.common_map_arrived_point)
mUArrivedStationPoint = BitmapDescriptorFactory.fromResource(if (endPointDrawable != -1) endPointDrawable else R.drawable.common_map_unarrived_point)
// 加载自定义样式
val customMapStyleOptions = CustomMapStyleOptions()
.setEnable(true)
.setStyleData(
BusPassengerMapAssetStyleUtil.getAssetsStyle(
context, "map_style.data"
)
)
.setStyleExtraData(
BusPassengerMapAssetStyleUtil.getAssetsExtraStyle(
context, "map_style_extra.data"
)
)
val customMapStyleOptions = CustomMapStyleOptions().setEnable(true)
if (!mapStylePath.isNullOrEmpty() && !mapStyleExtraPath.isNullOrEmpty()) {
customMapStyleOptions.styleData =
MapAssetStyleUtils.getAssetsStyle(context, mapStylePath)
customMapStyleOptions.styleExtraData =
MapAssetStyleUtils.getAssetsExtraStyle(context, mapStyleExtraPath)
}
// 设置自定义样式
mAMap.setCustomMapStyle(customMapStyleOptions)
@@ -129,18 +182,13 @@ class BusPassengerMapDirectionView @JvmOverloads constructor(
mAMap.setOnMapLoadedListener {
d(SceneConstant.M_BUS_P + TAG, "smp---onMapLoaded")
// 加载自定义样式
val options = CustomMapStyleOptions()
.setEnable(true)
.setStyleData(
BusPassengerMapAssetStyleUtil.getAssetsStyle(
context, "map_style.data"
)
)
.setStyleExtraData(
BusPassengerMapAssetStyleUtil.getAssetsExtraStyle(
context, "map_style_extra.data"
)
)
val options = CustomMapStyleOptions().setEnable(true)
if (!mapStylePath.isNullOrEmpty() && !mapStyleExtraPath.isNullOrEmpty()) {
options.styleData =
MapAssetStyleUtils.getAssetsStyle(context, mapStylePath)
options.styleExtraData =
MapAssetStyleUtils.getAssetsExtraStyle(context, mapStyleExtraPath)
}
// 设置自定义样式
mAMap.setCustomMapStyle(options)
mAMapNaviView.map.setPointToCenter(
@@ -307,6 +355,7 @@ class BusPassengerMapDirectionView @JvmOverloads constructor(
mLineMarkers.clear()
}
// 设置站点
fun setLinePointMarkerAndDraw(mLineStationsList: List<LatLng>, currentIndex: Int) {
clearLineMarkers()
mLineStationLatLng.clear()
@@ -316,27 +365,18 @@ class BusPassengerMapDirectionView @JvmOverloads constructor(
val size = mLineStationsList.size
val mStartMarker = mAMap.addMarker(
MarkerOptions()
.icon(BitmapDescriptorFactory.fromResource(R.drawable.shuttle_p_jl_map_start_point))
)
val mEndMarker = mAMap.addMarker(
MarkerOptions()
.icon(BitmapDescriptorFactory.fromResource(R.drawable.shuttle_p_jl_map_end_point))
.icon(mStartStationPoint)
)
val mEndMarker = mAMap.addMarker(MarkerOptions().icon(mEndStationPoint))
mStartMarker.position = mLineStationsList[0]
mLineMarkers.add(0, mStartMarker)
for (i in mLineStationsList.indices) {
if (currentIndex <= i && i < size - 1 && i > 0) { //未到达
val unArrivedMarker = mAMap.addMarker(
MarkerOptions()
.icon(BitmapDescriptorFactory.fromResource(R.drawable.shuttle_p_jl_map_unarrived_point))
)
val unArrivedMarker = mAMap.addMarker(MarkerOptions().icon(mUArrivedStationPoint))
unArrivedMarker.position = mLineStationsList[i]
mLineMarkers.add(i, unArrivedMarker)
} else if (i in 1 until currentIndex) {
val arrivedMarker = mAMap.addMarker(
MarkerOptions()
.icon(BitmapDescriptorFactory.fromResource(R.drawable.shuttle_p_jl_map_arrived_point))
)
val arrivedMarker = mAMap.addMarker(MarkerOptions().icon(mArrivedStationPoint))
arrivedMarker.position = mLineStationsList[i]
mLineMarkers.add(i, arrivedMarker)
}

View File

@@ -32,71 +32,23 @@ class MediaPlayerActivity : AppCompatActivity() {
override fun onStart() {
super.onStart()
i(SceneConstant.M_BUS_P + TAG, "onResume")
i(SceneConstant.M_BUS_P + TAG, "onStart")
}
override fun onResume() {
super.onResume()
i(SceneConstant.M_BUS_P + TAG, "onResume")
checkPermissionSelf()
}
override fun onPause() {
super.onPause()
i(SceneConstant.M_BUS_P + TAG, "onResume")
i(SceneConstant.M_BUS_P + TAG, "onPause")
}
override fun onStop() {
super.onStop()
i(SceneConstant.M_BUS_P + TAG, "onResume")
i(SceneConstant.M_BUS_P + TAG, "onStop")
}
fun checkPermissionSelf(){
i(SceneConstant.M_BUS_P + TAG, "checkPermissionSelf")
val isAllGranted: Boolean = checkPermissionAllGranted(
arrayOf<String>(
Manifest.permission.RECORD_AUDIO, // Manifest.permission.CAMERA,
Manifest.permission.BLUETOOTH,
Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.WRITE_EXTERNAL_STORAGE,
Manifest.permission.ACCESS_LOCATION_EXTRA_COMMANDS,
Manifest.permission.ACCESS_FINE_LOCATION
)
)
if (isAllGranted&&Settings.canDrawOverlays(this)) {
restartActivity()
return
}
RxUtils.createSubscribe {
checkPermissionSelf()
}
}
fun restartActivity(){
val activityList = ActivityUtils.getActivityList()
activityList.forEach {
if (it is MainLauncherActivity) {
i(SceneConstant.M_BUS_P + TAG, "restartActivity")
val options = ActivityOptions.makeBasic()
options.launchDisplayId = Display.INVALID_DISPLAY
val intent = Intent(this, MainLauncherActivity::class.java)
startActivity(intent, options.toBundle())
}
}
}
private fun checkPermissionAllGranted(permissions: Array<String>): Boolean {
for (permission in permissions) {
if (ContextCompat.checkSelfPermission(
this,
permission
) != PackageManager.PERMISSION_GRANTED
) {
// 只要有一个权限没有被授予, 则直接返回 false
return false
}
}
return true
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_height="match_parent">
<com.amap.api.maps.TextureMapView
android:id="@+id/bus_p_line_amap_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -61,4 +61,31 @@
<attr name="customGap" format="float" />
<attr name="useCustomGap" format="boolean"/>
</declare-styleable>
<declare-styleable name="MapDirectionView">
<!-- 地图样式asset目录下的路径 -->
<attr name="mapStylePath" format="string" />
<attr name="mapStyleExtraPath" format="string" />
<!-- 自车模型图片 -->
<attr name="carDrawable" format="reference" />
<!-- 罗盘图片 -->
<attr name="compassDrawable" format="reference" />
<!-- 起点图片 -->
<attr name="startPointDrawable" format="reference" />
<!-- 终点图片 -->
<attr name="endPointDrawable" format="reference" />
<!-- 已走过路线的图片 -->
<attr name="arrivedDrawable" format="reference" />
<!-- 未走过路线的图片 -->
<attr name="unArrivedDrawable" format="reference" />
<!-- 重置位置图片右面margin -->
<attr name="resetDrawableMarginRight" format="dimension" />
<!-- 重置位置图片下面margin -->
<attr name="resetDrawableMarginBottom" format="dimension" />
<!-- 规定屏幕范围的padding -->
<attr name="leftPadding" format="integer" />
<attr name="topPadding" format="integer" />
<attr name="rightPadding" format="integer" />
<attr name="bottomPadding" format="integer" />
</declare-styleable>
</resources>

View File

@@ -97,7 +97,7 @@ public interface IBascApiService {
Observable<BusQueryLinesResponse> queryBusLines(@Header ("appId") String appId, @Header("ticket") String ticket, @Query("sn") String sn);
/**
* 查询路线当天的任务
* 查询线路的任务
* @param appId
* @param ticket
* @param lineId 线路id

View File

@@ -9,6 +9,7 @@ import com.mogo.och.bus.bean.*
import com.mogo.och.common.module.biz.constant.OchCommonConst
import com.mogo.och.common.module.biz.network.OchCommonServiceCallback
import com.mogo.och.common.module.biz.network.OchCommonSubscribeImpl
import com.mogo.och.common.module.biz.network.interceptor.transformIoTry
import com.mogo.och.common.module.biz.network.interceptor.transformTry
/**
@@ -216,7 +217,7 @@ object OrderServiceManager {
taskId,
siteId
)
.transformTry()
.transformIoTry()
.subscribe(OchCommonSubscribeImpl(context, callback, "writeOffCount"))
}
}

View File

@@ -2,6 +2,7 @@ package com.mogo.och.bus.ui.writeoff
import android.content.Context
import android.util.AttributeSet
import android.util.Log
import android.view.LayoutInflater
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.lifecycle.ViewModelProvider

View File

@@ -9,6 +9,7 @@ import com.mogo.och.bus.model.TicketModel
import com.mogo.och.common.module.utils.RxUtils
import io.reactivex.Observable
import io.reactivex.Observer
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.Disposable
class WriteOffViewModel : ViewModel() {
@@ -52,6 +53,7 @@ class WriteOffViewModel : ViewModel() {
CallerLogger.d(SceneConstant.M_BUS + TAG, "显示文案:${showText}")
Observable.just(showText)
}
.observeOn(AndroidSchedulers.mainThread())
.subscribe(observer)
}

View File

@@ -23,7 +23,7 @@ import com.mogo.och.shuttle.passenger.ui.adapter.BusPassengerLineStationsAdapter
import com.mogo.och.shuttle.passenger.constant.BusPassengerConst;
import com.mogo.och.shuttle.passenger.presenter.BaseBusPassengerPresenter;
import com.mogo.och.shuttle.passenger.ui.layoutmanager.CenterLayoutManager;
import com.mogo.och.shuttle.passenger.ui.mapdirectionview.BusPassengerMapDirectionView;
import com.mogo.och.common.module.wigets.mapdirectionview.MapDirectionView;
import com.mogo.och.common.module.utils.NumberFormatUtil;
import com.mogo.och.common.module.wigets.MarqueeTextView;
import com.mogo.och.common.module.wigets.OCHGradientTextView;
@@ -48,7 +48,7 @@ public class BusPassengerRouteFragment extends
private MarqueeTextView mLineName;
private Group mRouteInfoView;
private RecyclerView mStationsListRv;
private BusPassengerMapDirectionView mMapDirectionView;
private MapDirectionView mMapDirectionView;
private BusPassengerLineStationsAdapter mAdapter;
private TextView emptyTv;
private AppCompatImageView mAutopilotIv;
@@ -157,7 +157,6 @@ public class BusPassengerRouteFragment extends
@Override
public void run() {
mMapDirectionView.clearLineMarkers();
}
});
}

View File

@@ -16,18 +16,15 @@ import com.mogo.eagle.core.data.config.FunctionBuildConfig
import com.mogo.eagle.core.data.map.MogoLocation
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationGCJ02Listener
import com.mogo.eagle.core.function.api.autopilot.IMoGoPlanningRottingListener
import com.mogo.eagle.core.function.api.telematic.IReceivedMsgListener
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ02ListenerManager
import com.mogo.eagle.core.function.call.autopilot.CallerPlanningRottingListenerManager
import com.mogo.eagle.core.function.call.telematic.CallerTelematicListenerManager
import com.mogo.eagle.core.function.call.telematic.CallerTelematicManager.sendMsgToServer
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
import com.mogo.eagle.core.utilcode.util.CoordinateUtils
import com.mogo.eagle.core.utilcode.util.GsonUtils
import com.mogo.eagle.core.utilcode.util.NetworkUtils
import com.mogo.eagle.core.utilcode.util.StringUtils
@@ -36,9 +33,11 @@ import com.mogo.och.common.module.bean.dpmsg.*
import com.mogo.och.common.module.biz.common.socketmessage.OCHSocketMessageManager.pushAppOperationalMsgBox
import com.mogo.och.common.module.biz.constant.OchCommonConst
import com.mogo.och.common.module.biz.network.OchCommonServiceCallback
import com.mogo.och.common.module.utils.CoordinateCalculateRouteUtil
import com.mogo.och.common.module.manager.distancemamager.IDistanceListener
import com.mogo.och.common.module.manager.distancemamager.TrajectoryAndDistanceManager
import com.mogo.och.common.module.manager.loopmanager.BizLoopManager
import com.mogo.och.common.module.manager.loopmanager.LoopInfo
import com.mogo.och.common.module.utils.DateTimeUtil
import com.mogo.och.common.module.utils.RxUtils
import com.mogo.och.common.module.voice.VoiceNotice.showNotice
import com.mogo.och.data.bean.BusRoutesResult
import com.mogo.och.data.bean.BusStationBean
@@ -49,10 +48,8 @@ import com.mogo.och.shuttle.passenger.bean.response.PassengerRoutesResponse
import com.mogo.och.shuttle.passenger.callback.AutoPilotStatusCallback
import com.mogo.och.shuttle.passenger.callback.DrivingInfoCallback
import com.mogo.och.shuttle.passenger.constant.BusPassengerConst
import com.mogo.och.shuttle.passenger.network.PM2ModelLoopManager
import com.mogo.och.shuttle.passenger.network.PassengerServiceManager
import io.reactivex.disposables.Disposable
import mogo.telematics.pad.MessagePad
import io.reactivex.schedulers.Schedulers
import kotlin.math.abs
/**
@@ -62,29 +59,19 @@ import kotlin.math.abs
class PM2DrivingModel private constructor() {
private var mContext: Context? = null
private var mLocation: MogoLocation? = null
private var mRoutePoints = mutableListOf<MogoLocation>()
private var routesResult: BusRoutesResult? = null
private var mCurrentAutoStatus = -1
var mStations = mutableListOf<BusStationBean>()
private var mNextStationIndex = 0 // A-B要到达站的index
private var isGoingToNextStation = false //是否前往下一站过程中
private var mTwoStationsRouts = mutableListOf<MogoLocation>()
private var mPreRouteIndex = 0
private var mWipePreIndex = 0
private var mDrivingInfoCallback: DrivingInfoCallback? = null //行程信息
private var mAutoStatusCallback: AutoPilotStatusCallback? = null //自动驾驶状态
private var operationStatus: PassengerOperationStatusResponse.Result? = null
@Volatile
private var globalPathTruncation: Disposable? = null
private val handler = Handler(Handler.Callback { msg ->
if (msg.what == MSG_QUERY_BUS_P_STATION) {
queryDriverOperationStatus()
@@ -101,12 +88,12 @@ class PM2DrivingModel private constructor() {
}
}
fun init(context : Context){
fun init(context: Context) {
mContext = context
initListener()
queryDriverByLocalDriver()
queryDriverOperationStatus()
startOrStopOrderLoop(true)
BizLoopManager.setLoopFunction(TAG, LoopInfo(2,::queryDriverSiteByCoordinate, scheduler = Schedulers.io()))
}
private fun queryDriverByLocalDriver() {
@@ -120,16 +107,16 @@ class PM2DrivingModel private constructor() {
CallerAutoPilotStatusListenerManager.addListener(TAG, mAutoPilotStatusListener)
// 定位监听
CallerChassisLocationGCJ02ListenerManager.addListener(TAG, 10,mMapLocationListener)
CallerChassisLocationGCJ02ListenerManager.addListener(TAG, 10, mMapLocationListener)
//司乘屏通信监听
CallerTelematicListenerManager.addListener(TAG,mReceivedMsgListener)
//自动驾驶轨迹监听
CallerPlanningRottingListenerManager.addListener(TAG, moGoAutopilotPlanningListener)
CallerTelematicListenerManager.addListener(TAG, mReceivedMsgListener)
//网络监听
IntentManager.getInstance().registerIntentListener(ConnectivityManager.CONNECTIVITY_ACTION, mNetWorkIntentListener)
IntentManager.getInstance()
.registerIntentListener(ConnectivityManager.CONNECTIVITY_ACTION, mNetWorkIntentListener)
TrajectoryAndDistanceManager.addDistanceListener(TAG, trajectoryListener)
}
@@ -140,7 +127,7 @@ class PM2DrivingModel private constructor() {
)
}
fun releaseListener(){
fun releaseListener() {
//自动驾驶状态监听
CallerAutoPilotStatusListenerManager.removeListener(TAG)
@@ -149,8 +136,10 @@ class PM2DrivingModel private constructor() {
CallerTelematicListenerManager.removeListener(TAG)
//自动驾驶轨迹监听
CallerPlanningRottingListenerManager.removeListener(TAG)
cleanStation("release")
TrajectoryAndDistanceManager.removeListener(TAG)
}
fun setDrivingInfoCallback(drivingInfoCallback : DrivingInfoCallback?){
@@ -216,15 +205,43 @@ class PM2DrivingModel private constructor() {
}
}
private val trajectoryListener: IDistanceListener = object : IDistanceListener {
override fun distanceCallback(distance: Float) {
val lastTime = distance / BusPassengerConst.BUS_AVERAGE_SPEED * 3.6 //秒
d(SceneConstant.M_BUS_P + TAG, "轨迹排查==lastSumLength = $distance")
if (routesResult != null) {
for (site in routesResult!!.sites) {
if (site.drivingStatus == BusPassengerConst.STATION_STATUS_STOPPED && !site.isLeaving) {
return
}
}
}
// 小于200m 播报站点介绍
if (distance < 200) {
val stationNext = mStations[mNextStationIndex]
if (!stationNext.isPlayTts) {
if (!StringUtils.isEmpty(stationNext.introduction)) {
showNotice(stationNext.introduction)
stationNext.isPlayTts = true
}
}
}
mDrivingInfoCallback?.updateRemainMT(
distance.toLong(),
lastTime.toLong()
)
}
}
@RequiresApi(Build.VERSION_CODES.O)
private fun speakTTS(msg: String) {
var mAudioManager = mContext?.getSystemService(Context.AUDIO_SERVICE) as AudioManager
var mAudioAttributes = AudioAttributes.Builder()
val mAudioManager = mContext?.getSystemService(Context.AUDIO_SERVICE) as AudioManager
val mAudioAttributes = AudioAttributes.Builder()
.setUsage(AudioAttributes.USAGE_MEDIA) //设置声音的用途
.setContentType(AudioAttributes.CONTENT_TYPE_MUSIC) //设置声音的类型
.build()
var mAudioFocusRequest = AudioFocusRequest.Builder(AudioManager.AUDIOFOCUS_GAIN_TRANSIENT_MAY_DUCK) //设置焦点类型
val mAudioFocusRequest = AudioFocusRequest.Builder(AudioManager.AUDIOFOCUS_GAIN_TRANSIENT_MAY_DUCK) //设置焦点类型
.setAudioAttributes(mAudioAttributes) //设置声音属性
.setAcceptsDelayedFocusGain(false) //设置接受延迟获取焦点需要设置OnAudioFocusChangeListener来监听焦点的获取
.build()
@@ -249,50 +266,10 @@ class PM2DrivingModel private constructor() {
object : IMoGoChassisLocationGCJ02Listener{
override fun onChassisLocationGCJ02(mogoLocation: MogoLocation?) {
if (null == mogoLocation) return
mLocation = mogoLocation
updateSpeed(mogoLocation)
}
}
private val moGoAutopilotPlanningListener = object : IMoGoPlanningRottingListener{
@Synchronized
override fun onAutopilotRotting(globalPathResp: MessagePad.GlobalPathResp?) {
d(SceneConstant.M_BUS_P + TAG, "och-rotting==globalPathResp = " + GsonUtils.toJson(globalPathResp))
globalPathResp?.let {
d(SceneConstant.M_BUS_P + TAG, "och-rotting==wayPointsSize = " + it.wayPointsList.size)
if (globalPathTruncation != null && !globalPathTruncation!!.isDisposed) {
d(SceneConstant.M_BUS_P + TAG, "1s内不可以接受轨迹")
return@let
}
globalPathTruncation = RxUtils.createSubscribe(1_000) {
d(SceneConstant.M_BUS_P + TAG, "可以接受轨迹")
}
d(SceneConstant.M_BUS_P + TAG, "接受轨迹中")
it.wayPointsList?.let {list->
updateRoutePoints(list)
}
}
}
}
@Synchronized
fun updateRoutePoints(routePoints: List<MessagePad.Location>) {
mRoutePoints.clear()
val latLngModels = CoordinateCalculateRouteUtil
.coordinateConverterWgsToGcjLocations(mContext, routePoints)
d(SceneConstant.M_BUS_P + TAG, "och-rotting==latLngModels = " + latLngModels.size)
mRoutePoints.addAll(latLngModels)
if (isGoingToNextStation){
mTwoStationsRouts.clear()
startRemainRouteInfo()
}
}
private fun updateSpeed(mogoLocation: MogoLocation) {
// km/h
val speedKM = (abs(mogoLocation.gnssSpeed) * 3.6f).toInt()
@@ -407,6 +384,7 @@ class PM2DrivingModel private constructor() {
d(SceneConstant.M_BUS_P+TAG, "queryDriverSiteByCoordinate = %s", msg)
if (code == 1003){
queryDriverOperationDelay()
cleanStation("queryDriverSiteByCoordinate 1003")
}
if (PassengerServiceManager.driverAppSn.isEmpty()){
return
@@ -414,7 +392,6 @@ class PM2DrivingModel private constructor() {
if (code == 1003) {
routesResult = null
isGoingToNextStation = false
startOrStopCalculateRouteInfo(false)
return
}
}
@@ -424,11 +401,10 @@ class PM2DrivingModel private constructor() {
}
private fun updateLocalOrder(){
mRoutePoints.clear()
routesResult = null
mNextStationIndex = 0
cleanStation("queryDriverSiteByCoordinate")
isGoingToNextStation = false
startOrStopCalculateRouteInfo(false)
mDrivingInfoCallback?.showNoTaskView(true)
}
@@ -460,20 +436,20 @@ class PM2DrivingModel private constructor() {
&& station.isLeaving && i + 1 < stations.size) {
mDrivingInfoCallback?.updateStationsInfo(stations as MutableList<BusStationBean>, i + 1, false)
d(SceneConstant.M_BUS_P+TAG,"och-rotting--mNextStationIndex = $mNextStationIndex , i = $i")
// if (mNextStationIndex != i + 1) {
d(SceneConstant.M_BUS_P+TAG,"och-rotting--start ")
mTwoStationsRouts.clear()
startRemainRouteInfo()
// }
d(SceneConstant.M_BUS_P+TAG,"och-rotting--start ")
isGoingToNextStation = true
mNextStationIndex = i + 1
val startStation = mStations[i]
val endStation = mStations[i + 1]
setTrajectoryStation(startStation, endStation, result.lineId)
return
} else if (station.drivingStatus == BusPassengerConst.STATION_STATUS_STOPPED && !station.isLeaving) {
d(SceneConstant.M_BUS_P+TAG,"och-rotting--mNextStationIndex = $mNextStationIndex , i = $i")
d(SceneConstant.M_BUS_P+TAG,"och-rotting--arrived ")
mPreRouteIndex = 0
if (i == stations.size - 1) {
cleanStation("updatePassengerRouteInfo最后一个站点")
}
isGoingToNextStation = false
startOrStopCalculateRouteInfo(false)
mDrivingInfoCallback?.updateStationsInfo(stations as MutableList<BusStationBean>, i, true)
return
}else{
@@ -484,162 +460,22 @@ class PM2DrivingModel private constructor() {
}
fun loopRouteAndWipe(){
if (mRoutePoints != null && mRoutePoints.size > 0 && mLocation != null) {
val haveArrivedIndex = CoordinateCalculateRouteUtil
.getArrivedPointIndexNew(
mWipePreIndex,
mRoutePoints,
mLocation!!
)
mWipePreIndex = haveArrivedIndex
d(SceneConstant.M_BUS_P + TAG,
"thread = " + Thread.currentThread().name + " haveArrivedIndex== " + haveArrivedIndex
)
// if (mAutopilotPlanningCallback != null) {
// val routePoints = CoordinateCalculateRouteUtil
// .coordinateConverterLocationToLatLng(mContext, mRoutePoints)
// mAutopilotPlanningCallback.routeResult(routePoints, haveArrivedIndex)
// }
}
private fun setTrajectoryStation(
startStationInfo: BusStationBean,
endStationInfo: BusStationBean,
lineId: Int
) {
val startStation = MogoLocation()
startStation.longitude = startStationInfo.gcjLon
startStation.latitude = startStationInfo.gcjLat
val endStation = MogoLocation()
endStation.longitude = endStationInfo.gcjLon
endStation.latitude = endStationInfo.gcjLat
TrajectoryAndDistanceManager.setStationPoint(startStation, endStation, lineId.toLong())
}
private fun startRemainRouteInfo() {
//开启实时计算剩余距离,剩余时间,预计时间
startOrStopCalculateRouteInfo(true)
}
fun dynamicCalculateRouteInfo(){
//计算当前位置和下一站的剩余点集合
//计算剩余点总里程和时间
d(SceneConstant.M_BUS_P + TAG, "och-rotting==mTwoStationsRouts.size() = " + mTwoStationsRouts.size)
//计算当前位置和下一站的剩余点集合
//计算剩余点总里程和时间
if (mTwoStationsRouts.size == 0) {
calculateTwoStationsRoute()
}
if (mTwoStationsRouts.size > 0 && mLocation != null) {
val lastPointsMap = CoordinateCalculateRouteUtil
.getRemainPointListByCompareNew(mPreRouteIndex, mTwoStationsRouts, mLocation!!)
for (index in lastPointsMap.keys) {
mPreRouteIndex = index
break
}
for (lastPoints in lastPointsMap.values) {
d(SceneConstant.M_BUS_P + TAG, "och-rotting==lastPoints.size() = " + lastPoints.size)
var lastSumLength = 0f
lastSumLength = if (lastPoints.size == 1) { //只是最后一个点,计算当前位置和最后一个点的距离
if (mNextStationIndex <= mStations.size - 1 && mNextStationIndex >= 0) {
val stationNext: BusStationBean = mStations[mNextStationIndex]
CoordinateUtils.calculateLineDistance(
stationNext.gcjLon, stationNext.gcjLat,
mLocation!!.longitude, mLocation!!.latitude
)
} else {
CoordinateUtils.calculateLineDistance(
lastPoints[0].longitude, lastPoints[0].latitude,
mLocation!!.longitude, mLocation!!.latitude
)
}
} else {
CoordinateCalculateRouteUtil.calculateRouteSumLength(lastPoints)
}
val lastTime = lastSumLength / BusPassengerConst.SHUTTLE_AVERAGE_SPEED * 3.6 //秒
d(SceneConstant.M_BUS_P + TAG, "och-rotting==lastSumLength = $lastSumLength")
// 小于200m 播报站点介绍
// 小于200m 播报站点介绍
if (lastSumLength < 200) {
val stationNext = mStations[mNextStationIndex]
if (!stationNext.isPlayTts) {
if (!StringUtils.isEmpty(stationNext.introduction)) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
speakTTS(stationNext.introduction)
}
stationNext.isPlayTts = true
}
}
}
mDrivingInfoCallback?.updateRemainMT(
lastSumLength.toLong(),
lastTime.toLong()
)
}
}
}
private fun calculateTwoStationsRoute() {
//找出前往站对应的轨迹点,拿出两站点的集合
d(SceneConstant.M_BUS_P + TAG, "mRoutePoints.size() = " + mRoutePoints.size)
if (mRoutePoints.size > 0) {
if (mStations.size > 1) { //两个站点及以上要计算两个站点间的轨迹路线
if (mNextStationIndex <= mStations.size - 1 && mNextStationIndex - 1 >= 0) {
mTwoStationsRouts.clear()
val stationNext: BusStationBean = mStations[mNextStationIndex]
val stationCur: BusStationBean = mStations[mNextStationIndex - 1]
//当前站在轨迹中对应的点
val currentRouteIndex = CoordinateCalculateRouteUtil.getArrivedPointIndexNew(
0, mRoutePoints, stationCur.gcjLon, stationCur.gcjLat
)
//要前往的站在轨迹中对应的点
val nextRouteIndex = CoordinateCalculateRouteUtil.getArrivedPointIndexNew(
currentRouteIndex,
mRoutePoints,
stationNext.gcjLon,
stationNext.gcjLat
)
d(SceneConstant.M_BUS_P + TAG, "och-rotting==currentRouteIndex = " + currentRouteIndex
+ " nextRouteIndex = " + nextRouteIndex)
if (currentRouteIndex < nextRouteIndex) { //如果找到的next在起点的轨迹前面直接舍弃这个轨迹不显示
mTwoStationsRouts.addAll(
mRoutePoints.subList(
currentRouteIndex,
nextRouteIndex + 1
)
)
}
}
}
}
}
/**
* 开始轮询计算剩余里程和时间
* @param isStart
*/
fun startOrStopCalculateRouteInfo(isStart: Boolean) {
d(SceneConstant.M_BUS_P+TAG, "startOrStopCalculateRouteInfo() $isStart")
if (isStart) {
PM2ModelLoopManager.startCalculateRouteInfoLoop()
} else {
mTwoStationsRouts.clear()
PM2ModelLoopManager.stopCalculateRouteInfLoop()
}
}
/**
* 实时轨迹擦除
* @param isStart
*/
private fun startOrStopRouteAndWipe(isStart: Boolean) {
if (isStart) {
PM2ModelLoopManager.startOrStopRouteAndWipe()
} else {
mWipePreIndex = 0
PM2ModelLoopManager.stopOrStopRouteAndWipe()
}
}
private fun startOrStopOrderLoop(start: Boolean) {
d(SceneConstant.M_BUS_P + TAG, "startOrStopOrderLoop() $start")
if (start) {
PM2ModelLoopManager.startQueryDriverLineLoop()
} else {
PM2ModelLoopManager.stopQueryDriverLineLoop()
}
private fun cleanStation(type: String) {
d(SceneConstant.M_BUS_P + TAG, "清理站点:$type")
TrajectoryAndDistanceManager.setStationPoint(null, null, -1L)
}
}

View File

@@ -1,127 +0,0 @@
package com.mogo.och.shuttle.passenger.network
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.i
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
import com.mogo.och.shuttle.passenger.constant.BusPassengerConst
import com.mogo.och.shuttle.passenger.model.PM2DrivingModel
import io.reactivex.Observable
import io.reactivex.ObservableOnSubscribe
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.CompositeDisposable
import io.reactivex.disposables.Disposable
import io.reactivex.schedulers.Schedulers
import java.util.concurrent.TimeUnit
/**
* @author: wangmingjun
* @date: 2023/2/1
*/
object PM2ModelLoopManager {
private val TAG: String = PM2ModelLoopManager::class.java.getSimpleName()
private var mQueryLineDisposable: Disposable? = null //心跳轮询
private var mRouteWipeDisposable: CompositeDisposable? = null //估计擦除
private var mCalculateRouteDisposable: CompositeDisposable? = null //每隔2s计算一次剩余里程和时间
fun startOrStopRouteAndWipe() {
i(SceneConstant.M_BUS_P + TAG, "startOrStopRouteWipe()")
if (mRouteWipeDisposable != null) return
if (mRouteWipeDisposable == null) {
mRouteWipeDisposable = CompositeDisposable()
}
val disposable = startLoopRouteAndWipe()
.doOnSubscribe { }
.doOnError { }
.delay(
BusPassengerConst.LOOP_LINE_1S,
TimeUnit.MILLISECONDS,
true
) // 设置delayError为true表示出现错误的时候也需要延迟5s进行通知达到无论是请求正常还是请求失败都是5s后重新订阅即重新请求。
.subscribeOn(Schedulers.io())
.repeat() // repeat保证请求成功后能够重新订阅。
.retry() // retry保证请求失败后能重新订阅
.observeOn(AndroidSchedulers.mainThread())
.subscribe { }
mRouteWipeDisposable!!.add(disposable)
}
fun stopOrStopRouteAndWipe() {
if (mRouteWipeDisposable != null) {
mRouteWipeDisposable!!.dispose()
mRouteWipeDisposable = null
}
}
fun startQueryDriverLineLoop() {
if (mQueryLineDisposable != null && !mQueryLineDisposable!!.isDisposed) {
return
}
i(SceneConstant.M_BUS_P + TAG, "startQueryDriverLineLoop()")
mQueryLineDisposable = Observable.interval(
BusPassengerConst.LOOP_DELAY,
BusPassengerConst.LOOP_LINE_2S, TimeUnit.MILLISECONDS
)
.map { aLong: Long -> aLong + 1 }
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe { aLong: Long? ->
PM2DrivingModel.INSTANCE.queryDriverSiteByCoordinate()
}
}
fun stopQueryDriverLineLoop() {
if (mQueryLineDisposable != null) {
i(SceneConstant.M_BUS_P + TAG, "stopQueryDriverLineLoop()")
mQueryLineDisposable!!.dispose()
mQueryLineDisposable = null
}
}
fun startCalculateRouteInfoLoop() {
i(SceneConstant.M_BUS_P + TAG, "startCalculateRouteInfoLoop()")
if (mCalculateRouteDisposable != null) return
if (mCalculateRouteDisposable == null) {
mCalculateRouteDisposable = CompositeDisposable()
}
val disposable = startLoopCalculateRouteInfo()
.doOnSubscribe { }
.doOnError { }
.delay(
BusPassengerConst.LOOP_LINE_2S,
TimeUnit.MILLISECONDS,
true
) // 设置delayError为true表示出现错误的时候也需要延迟5s进行通知达到无论是请求正常还是请求失败都是5s后重新订阅即重新请求。
.subscribeOn(Schedulers.io())
.repeat() // repeat保证请求成功后能够重新订阅。
.retry() // retry保证请求失败后能重新订阅
.observeOn(AndroidSchedulers.mainThread())
.subscribe { }
mCalculateRouteDisposable!!.add(disposable)
}
fun stopCalculateRouteInfLoop() {
if (mCalculateRouteDisposable != null) {
i(SceneConstant.M_BUS_P + TAG, "stopCalculateRouteInfLoop()")
mCalculateRouteDisposable!!.dispose()
mCalculateRouteDisposable = null
}
}
private fun startLoopRouteAndWipe(): Observable<Int?> {
return Observable.create(ObservableOnSubscribe { emitter ->
if (emitter.isDisposed) return@ObservableOnSubscribe
PM2DrivingModel.INSTANCE.loopRouteAndWipe()
emitter.onComplete()
})
}
private fun startLoopCalculateRouteInfo(): Observable<Int?> {
return Observable.create(ObservableOnSubscribe { emitter ->
if (emitter.isDisposed) return@ObservableOnSubscribe
PM2DrivingModel.INSTANCE.dynamicCalculateRouteInfo()
emitter.onComplete()
})
}
}

View File

@@ -265,7 +265,7 @@
</androidx.constraintlayout.widget.ConstraintLayout>
<com.mogo.och.shuttle.passenger.ui.mapdirectionview.BusPassengerMapDirectionView
<com.mogo.och.common.module.wigets.mapdirectionview.MapDirectionView
android:id="@+id/bus_p_line_map_view"
android:layout_width="@dimen/shuttle_p_jl_route_info_panel_width"
android:layout_height="@dimen/shuttle_p_jl_route_line_map_view_height"

View File

@@ -9,11 +9,7 @@ import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentManager;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.mogo.commons.module.status.IMogoStatusChangedListener;
import com.mogo.commons.module.status.MogoStatusManager;
import com.mogo.commons.module.status.StatusDescriptor;
import com.mogo.eagle.core.function.api.base.IMoGoFunctionProvider;
import com.mogo.eagle.core.function.call.setting.CallerMoGoUiSettingManager;
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
import com.mogo.och.taxi.passenger.constant.TaxiPassengerConst;
import com.mogo.och.taxi.passenger.ui.TaxiPassengerBaseFragment;
@@ -21,7 +17,6 @@ import com.mogo.och.taxi.passenger.ui.TaxiPassengerBaseFragment;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public
/**
* @author congtaowang
* @since 2021/1/15
@@ -29,7 +24,7 @@ public
* 网约车-出租车-乘客端
*/
@Route(path = TaxiPassengerConst.PATH)
class MogoOCHTaxiPassenger implements IMoGoFunctionProvider {
public class MogoOCHTaxiPassenger implements IMoGoFunctionProvider {
private static final String TAG = "MogoOCHTaxiPassenger";
private TaxiPassengerBaseFragment ochTaxiPassengerFragment;
@@ -41,14 +36,6 @@ class MogoOCHTaxiPassenger implements IMoGoFunctionProvider {
CallerLogger.d(M_TAXI_P + TAG, "init");
}
/**
* 进入鹰眼模式,设置手势缩放地图失效
*/
private void stepIntoVrMode() {
CallerLogger.d(M_TAXI_P + TAG, "进入vr模式");
CallerMoGoUiSettingManager.INSTANCE.stepInNightMode();//夜间模式 状态栏字体颜色变黑
}
private void showFragment() {
FragmentManager supportFragmentManager = mActivity.getSupportFragmentManager();
if (ochTaxiPassengerFragment == null) {

View File

@@ -1,26 +0,0 @@
package com.mogo.och.taxi.passenger.bean;
import com.mogo.eagle.core.data.BaseData;
import java.util.List;
/**
* Created by pangfan on 2021/8/19
*
* 查询订单返回数据结构
*/
public class TaxiPassengerAllStarWorld extends BaseData {
public List<TaxiPassengerStarWorld> data;
public static class TaxiPassengerStarWorld {
public TaxiPassengerStarWorld(String labelInfo) {
this.labelInfo = labelInfo;
}
public String labelNo;
public String labelInfo;
public String star;
public String sort;
public Boolean isSelect = false;
}
}

View File

@@ -1,26 +0,0 @@
package com.mogo.och.taxi.passenger.bean;
import com.mogo.och.taxi.passenger.constant.TaxiPassengerConst;
import java.util.UUID;
/**
* Created on 2021/9/16
*
* 上传车机心跳信息请求数据
*/
public class TaxiPassengerCarHeartbeatReqBean {
public String sn;
public double lon; //经度
public double lat; //纬度
public String msgId; //心跳信息唯一标识
public int interval; //上报间隔单位秒非必传默认60秒
public TaxiPassengerCarHeartbeatReqBean(String sn, double lon, double lat) {
this.sn = sn;
this.lon = lon;
this.lat = lat;
this.msgId = UUID.randomUUID().toString();
this.interval = (int) (TaxiPassengerConst.LOOP_PERIOD_60S / 1000);
}
}

View File

@@ -1,20 +0,0 @@
package com.mogo.och.taxi.passenger.bean;
import com.mogo.eagle.core.data.BaseData;
import java.util.List;
import java.util.Objects;
/**
* Created by pangfan on 2021/8/19
*
* 查询订单返回数据结构
*/
public class TaxiPassengerOrderQueryRemainingResp extends BaseData {
public Result data;
public static class Result {
public long distance;
public long duration;
}
}

View File

@@ -1,13 +0,0 @@
package com.mogo.och.taxi.passenger.bean;
import com.amap.api.maps.model.LatLng;
import com.mogo.eagle.core.data.BaseData;
import java.util.List;
/**
* Created by pangfan on 2021/8/19
*/
public class TaxiPassengerQueryOrderRouteResp extends BaseData {
public List<LatLng> data;
}

View File

@@ -1,27 +0,0 @@
package com.mogo.och.taxi.passenger.bean;
import java.util.List;
/**
* Created by pangfan on 2021/8/19
*
* 验证手机号后四位同时流转订单状态
*/
public class TaxiPassengerScoreUpdateOrderReqBean {
public String orderNo;
public int star;
public List<TaxiPassengerAllStarWorld.TaxiPassengerStarWorld> evalLabeBasicList;
public TaxiPassengerScoreUpdateOrderReqBean(String orderNo, int star,List<TaxiPassengerAllStarWorld.TaxiPassengerStarWorld> data) {
this.orderNo = orderNo;
this.star = star;
for (TaxiPassengerAllStarWorld.TaxiPassengerStarWorld datum : data) {
datum.isSelect=null;
datum.sort = null;
datum.star = null;
}
this.evalLabeBasicList = data;
}
}

View File

@@ -1,10 +0,0 @@
package com.mogo.och.taxi.passenger.callback;
/**
* @author: wangmingjun
* @date: 2021/12/3
*/
public interface IOCHTaxiPassengerNaviChangedCallback {
// 当前位置距离上车点的距离(米)、预估时间(秒) 、当前路的名称
void onCurrentRoadName(String currentRoadName);
}

View File

@@ -1,5 +0,0 @@
package com.mogo.och.taxi.passenger.callback;
public interface ITaxiPassengerCommonCallback {
void onCommonCallback();
}

View File

@@ -1,5 +0,0 @@
package com.mogo.och.taxi.passenger.callback;
public interface ITaxiPassengerCommonValueCallback<T> {
void onCommonCallback(T t);
}

View File

@@ -1,9 +0,0 @@
package com.mogo.och.taxi.passenger.callback;
/**
* @author: wangmingjun
* @date: 2022/3/10
*/
public interface ITaxiPassengerMapViewCallback {
void onCameraChange(float bearing);
}

View File

@@ -1,10 +0,0 @@
package com.mogo.och.taxi.passenger.callback;
/**
* @author: wangmingjun
* @date: 2022/3/13
*/
public interface ITaxiPassengerVeloctityCallback {
//限速
void onLimitingVelocityChange(int limitingVelocity);
}

View File

@@ -11,17 +11,6 @@ class TaxiPassengerConst {
// OCH arouter 路由path
const val PATH = "/passenger/api"
// 上报心跳轮询ms
const val LOOP_PERIOD_60S = 60 * 1000L
// 轮询查询进行中/待服务订单的间隔时间 2秒
const val LOOP_PERIOD_2S = 2 * 1000L
// 轮询查询新到预约单 1秒
const val LOOP_PERIOD_1S = 1 * 1000L
const val LOOP_DELAY = 100L
//实时查询订单剩余时间 和 剩余里程 轮询间隔2s
const val LOOP_CALCULATEROUTE_2S = 2 * 1000L
// 开始服务启动自动驾驶等待时间(埋点上传)
const val LOOP_PERIOD_15S = 15 * 1000L

View File

@@ -1,4 +0,0 @@
package com.mogo.och.taxi.passenger.event;
public class FinishActivity {
}

View File

@@ -32,7 +32,6 @@ import com.mogo.och.taxi.passenger.bean.TaxiPassengerBaseRespBean
import com.mogo.och.taxi.passenger.bean.TaxiPassengerOrderQueryRespBean
import com.mogo.och.taxi.passenger.bean.TaxiPassengerOrdersInServiceQueryRespBean
import com.mogo.och.taxi.passenger.callback.IOCHTaxiPassengerOrderStatusCallback
import com.mogo.och.taxi.passenger.callback.ITaxiPassengerCommonCallback
import com.mogo.och.taxi.passenger.constant.TaxiPassengerConst
import com.mogo.och.taxi.passenger.constant.TaxiPassengerOrderStatusEnum
import com.mogo.och.taxi.passenger.constant.TaxiPassengerOrderStatusEnum.Companion.valueOf
@@ -54,7 +53,6 @@ object TaxiPassengerModel {
private const val STARTREADYTOAUTOPILOT = "startReadyToAutopilot"
private const val MINANDWAITSERVICE = "mInAndWaitService"
private const val MQUERYORDERREMAINING = "mQueryOrderRemaining"
// 获取当前订单
@Volatile

View File

@@ -2,14 +2,11 @@ package com.mogo.och.taxi.passenger.network
import com.mogo.cloud.passport.MoGoAiCloudClientConfig
import com.mogo.commons.storage.SharedPrefsMgr
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.TaxiPassengerScoreUpdateOrderReqBean
import com.mogo.och.taxi.passenger.bean.TaxiPassengerStartReqBean
import io.reactivex.Observable
import retrofit2.http.Body
@@ -51,21 +48,6 @@ internal interface TaxiPassengerServiceApi {
@Body data: TaxiPassengerOrderQueryReqBean
): Observable<TaxiPassengerOrderQueryRespBean>
/**
* 查询订单剩余里程和时间
* @param appId
* @param ticket
* @param orderNo
* @return
*/
@Headers("Content-type:application/json;charset=UTF-8")
@GET("/autopilot-car-hailing/order/v2/driver/taxi/queryOrderRemaining")
fun queryOrderRemaining(
@Header("appId") appId: String = MoGoAiCloudClientConfig.getInstance().serviceAppId,
@Header("ticket") ticket: String=SharedPrefsMgr.getInstance().token,
@Query("orderNo") orderNo: String
): Observable<TaxiPassengerOrderQueryRemainingResp>
/**
* 提交用户输入的手机后4位、并进行状态扭转
* @param data
@@ -79,42 +61,6 @@ internal interface TaxiPassengerServiceApi {
@Body data: TaxiPassengerCheckPhoneUpdateOrderReqBean?
): Observable<TaxiPassengerBaseRespBean>
/**
* 对订单进行打分 1-5分 加上文案评论
* @param data
* @return
*/
@Headers("Content-type:application/json;charset=UTF-8")
@POST("/autopilot-car-hailing/evaluation/info/driver/taxi/submit")
fun arrivedAndScore(
@Header("appId") appId: String = MoGoAiCloudClientConfig.getInstance().serviceAppId,
@Header("ticket") ticket: String= SharedPrefsMgr.getInstance().token,
@Body data: TaxiPassengerScoreUpdateOrderReqBean
): Observable<TaxiPassengerBaseRespBean>
/**
* 获取星星对应的文案(所有文案)
* @return
*/
@Headers("Content-type:application/json;charset=UTF-8")
@GET("/autopilot-car-hailing/evaluation/label/driver/taxi/list")
fun getWorldAllStar(
@Header("appId") appId: String = MoGoAiCloudClientConfig.getInstance().serviceAppId,
@Header("ticket") ticket: String=SharedPrefsMgr.getInstance().token,
): Observable<TaxiPassengerAllStarWorld>
/**
* 获取星星对应的文案(和星星一一对应)
* @return
*/
@Headers("Content-type:application/json;charset=UTF-8")
@GET("/autopilot-car-hailing/evaluation/label/driver/taxi/listByStar")
fun getWorldByStar(
@Header("appId") appId: String = MoGoAiCloudClientConfig.getInstance().serviceAppId,
@Header("ticket") ticket: String=SharedPrefsMgr.getInstance().token,
@Query("star") star: String
): Observable<TaxiPassengerAllStarWorld>
/**
* 查询司机是否已确认可开启自动驾驶
* @param appId

View File

@@ -4,11 +4,8 @@ import android.content.Context
import com.mogo.och.taxi.passenger.bean.TaxiPassengerOrdersInServiceQueryRespBean
import com.mogo.commons.AbsMogoApplication
import com.mogo.eagle.core.function.call.telematic.CallerTelematicManager
import com.mogo.och.taxi.passenger.bean.TaxiPassengerOrderQueryRemainingResp
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.eagle.core.utilcode.mogo.logger.CallerLogger
@@ -73,22 +70,6 @@ object TaxiPassengerServiceManager {
.subscribe(OchCommonSubscribeImpl(context, callback, "queryOrdersInAndWaitService"))
}
/**
* 查询订单剩余里程和时间
* @param context
* @param orderNo
* @param callback
*/
@JvmStatic
fun queryOrderRemaining(
orderNo: String,
callback: OchCommonServiceCallback<TaxiPassengerOrderQueryRemainingResp>?
) {
mOCHTaxiServiceApi.queryOrderRemaining(orderNo= orderNo)
.transformTry()
.subscribe(OchCommonSubscribeImpl(context, callback, "queryOrderRemaining"))
}
@JvmStatic
fun checkPhoneAndUpdateOrderStatus(
orderNo: String?,
@@ -99,23 +80,7 @@ object TaxiPassengerServiceManager {
.transformTry()
.subscribe(OchCommonSubscribeImpl(context, callback, "checkPhoneAndUpdateOrderStatus"))
}
@JvmStatic
fun arrivedAndScore(
taxiPassengerScoreUpdateOrderReqBean: TaxiPassengerScoreUpdateOrderReqBean,
callback: OchCommonServiceCallback<TaxiPassengerBaseRespBean>?
) {
mOCHTaxiServiceApi.arrivedAndScore(data = taxiPassengerScoreUpdateOrderReqBean)
.transformTry()
.subscribe(OchCommonSubscribeImpl(context, callback, "checkPhoneAndUpdateOrderStatus"))
}
@JvmStatic
fun getAllScoreWorld(
callback: OchCommonServiceCallback<TaxiPassengerAllStarWorld>?
) {
mOCHTaxiServiceApi.getWorldAllStar()
.transformTry()
.subscribe(OchCommonSubscribeImpl(context, callback, "arrivedAndScore"))
}
@JvmStatic
fun queryPilotStatus(
orderNo: String,
@@ -137,15 +102,6 @@ object TaxiPassengerServiceManager {
.transformTry()
.subscribe(OchCommonSubscribeImpl(context, callback, "startServicePilotDone"))
}
@JvmStatic
fun getWorldByStar(
start: String,
callback: OchCommonServiceCallback<TaxiPassengerAllStarWorld>?
) {
mOCHTaxiServiceApi.getWorldByStar(star=start)
.transformTry()
.subscribe(OchCommonSubscribeImpl(context, callback, "checkPhoneAndUpdateOrderStatus"))
}
/**
* 通过orderId查询订单信息用于本地已经有orderId时

View File

@@ -1,42 +0,0 @@
package com.mogo.och.taxi.passenger.utils;
import android.content.Context;
import android.view.inputmethod.InputMethodManager;
import java.lang.reflect.Field;
/**
* memory leak fix:
* <p>
* InputMethodManager#mLastSrvView reference Last Page Activity.
*/
public class FixMemoryLeak {
private static Field field;
private static boolean hasField = true;
public static void fixLeak(Context context) {
if (!hasField) {
return;
}
InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm == null) {
return;
}
try {
if (field == null) {
field = imm.getClass().getDeclaredField("mCurRootView");
}
if (field == null) {
hasField = false;
}
if (field != null) {
field.setAccessible(true);
field.set(imm, null);
}
} catch (Throwable t) {
hasField = false;
}
}
}

View File

@@ -1,22 +0,0 @@
package com.mogo.och.taxi.passenger.utils;
import com.mogo.och.taxi.passenger.bean.TaxiPassengerOrderQueryRespBean;
import java.util.Arrays;
import java.util.List;
/**
* Created on 2021/9/11
*/
public class OrderUtil {
// 判断两个list中的订单是否相同依据orderId
public static boolean haveSameOrders(List<TaxiPassengerOrderQueryRespBean.Result> list1,
List<TaxiPassengerOrderQueryRespBean.Result> list2) {
TaxiPassengerOrderQueryRespBean.Result[] arr1 = list1.toArray(new TaxiPassengerOrderQueryRespBean.Result[]{});
TaxiPassengerOrderQueryRespBean.Result[] arr2 = list2.toArray(new TaxiPassengerOrderQueryRespBean.Result[]{});
Arrays.sort(arr1);
Arrays.sort(arr1);
return Arrays.equals(arr1,arr2);
}
}

View File

@@ -1,62 +0,0 @@
package com.mogo.och.taxi.passenger.utils;
import android.app.ActivityManager;
import android.app.AppOpsManager;
import android.content.Context;
import android.content.pm.PackageManager;
import android.location.LocationManager;
import android.os.Build;
import androidx.core.content.ContextCompat;
import com.mogo.eagle.core.network.utils.Util;
import com.mogo.eagle.core.utilcode.util.Utils;
/**
* @author: wangmingjun
* @date: 2021/12/7
*/
public class PermissionUtil {
public static boolean checkPermission(Context context,String... permissons) {
for (String permisson : permissons) {
if ((ContextCompat.checkSelfPermission(context,
permisson) != PackageManager.PERMISSION_GRANTED)) {
return false;
}
}
return true;
}
public static boolean isLocServiceEnable(Context context) {
LocationManager locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
boolean gps = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
boolean network = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
if (gps || network) {
return true;
}
return false;
}
private static String processName = "";
public static String getCurProcessName() {
if(!processName.isEmpty()){
return processName;
}
// 获取此进程的标识符
int pid = android.os.Process.myPid();
// 获取活动管理器
ActivityManager activityManager = (ActivityManager)
Utils.getApp().getSystemService(Context.ACTIVITY_SERVICE);
// 从应用程序进程列表找到当前进程,是:返回当前进程名
for (ActivityManager.RunningAppProcessInfo appProcess :
activityManager.getRunningAppProcesses()) {
if (appProcess.pid == pid) {
return appProcess.processName;
}
}
return null;
}
}

View File

@@ -1,61 +0,0 @@
package com.mogo.och.taxi.passenger.utils;
import android.content.Context;
import java.io.IOException;
import java.io.InputStream;
/**
* @author donghongyu
* @date 12/18/20 5:37 PM
*/
public class TaxiPassengerMapAssetStyleUtil {
public static byte[] getAssetsStyle(Context context,String fileName) {
byte[] buffer1 = null;
InputStream is1 = null;
try {
is1 = context.getResources().getAssets().open(fileName); //eg. over_view_style.data
int lenght1 = is1.available();
buffer1 = new byte[lenght1];
is1.read(buffer1);
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (is1 != null) {
is1.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
return buffer1;
}
public static byte[] getAssetsExtraStyle(Context context, String fileName) {
byte[] buffer1 = null;
InputStream is1 = null;
try {
is1 = context.getResources().getAssets().open(fileName); //eg. over_view_style_extra.data
int lenght1 = is1.available();
buffer1 = new byte[lenght1];
is1.read(buffer1);
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (is1 != null) {
is1.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
return buffer1;
}
}

View File

@@ -1,55 +0,0 @@
package com.mogo.och.taxi.passenger.utils.windowdispatch;
import android.graphics.Region;
import android.inputmethodservice.InputMethodService;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
public class OnComputeInternalInsetsListener implements InvocationHandler {
private Region touchRegion = null;
public Object getListener() {
Object target = null;
try {
Class class1 = Class.forName("android.view.ViewTreeObserver$OnComputeInternalInsetsListener");
target = Proxy.newProxyInstance(OnComputeInternalInsetsListener.class.getClassLoader(),
new Class[]{class1}, this);
} catch (Exception e) {
e.printStackTrace();
}
return target;
}
public Region getTouchRegion() {
return touchRegion;
}
public void setTouchRegion(Region touchRegion) {
this.touchRegion = touchRegion;
}
@Override
public Object invoke(Object proxy, Method method, Object[] args) {
try {
Field regionField = args[0].getClass()
.getDeclaredField("touchableRegion");
regionField.setAccessible(true);
Field insetField = args[0].getClass()
.getDeclaredField("mTouchableInsets");
insetField.setAccessible(true);
if (touchRegion != null) {
Region region = (Region) regionField.get(args[0]);
region.set(touchRegion);
insetField.set(args[0], InputMethodService.Insets.TOUCHABLE_INSETS_REGION);
} else {
insetField.set(args[0], InputMethodService.Insets.TOUCHABLE_INSETS_FRAME);
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
}

View File

@@ -1,51 +0,0 @@
package com.mogo.och.taxi.passenger.utils.windowdispatch;
import android.view.ViewTreeObserver;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
public class ReflectionUtils {
private ReflectionUtils() {
}
public static void removeOnComputeInternalInsetsListener(ViewTreeObserver viewTree) {
if (viewTree == null) {
return;
}
try {
Class<?> clazz = Class.forName("android.view.ViewTreeObserver");
Field field = viewTree.getClass().getDeclaredField("mOnComputeInternalInsetsListeners");
field.setAccessible(true);
Object listenerList = field.get(viewTree);
Method method = listenerList.getClass().getDeclaredMethod("getArray");
method.setAccessible(true);
ArrayList<Object> list = (ArrayList<Object>) method.invoke(listenerList);
Class<?> classes[] = {Class.forName("android.view.ViewTreeObserver$OnComputeInternalInsetsListener")};
if (list != null && list.size() > 0) {
clazz.getDeclaredMethod("removeOnComputeInternalInsetsListener", classes).invoke(viewTree,
list.get(0));
}
} catch (Exception e) {
e.printStackTrace();
}
}
public static void addOnComputeInternalInsetsListener(ViewTreeObserver viewTree, Object object) {
if (viewTree == null) {
return;
}
try {
Class<?> classes[] = {Class.forName("android.view.ViewTreeObserver$OnComputeInternalInsetsListener")};
Class<?> clazz = Class.forName("android.view.ViewTreeObserver");
clazz.getDeclaredMethod("addOnComputeInternalInsetsListener", classes).invoke(viewTree,
object);
} catch (Exception e) {
e.printStackTrace();
}
}
}

View File

@@ -1,39 +0,0 @@
package com.mogo.och.taxi.passenger.widget;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.Transformation;
public class ResizeAnimation extends Animation {
final int targetHeight;
View view;
int startHeight;
public ResizeAnimation(View view, int targetHeight, int startHeight) {
this.view = view;
this.targetHeight = targetHeight;
this.startHeight = startHeight;
}
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
int newHeight = (int) (startHeight + (targetHeight-startHeight) * interpolatedTime);
view.getLayoutParams().height = newHeight;
view.requestLayout();
}
@Override
public void initialize(int width, int height, int parentWidth, int parentHeight) {
super.initialize(width, height, parentWidth, parentHeight);
}
@Override
public boolean willChangeBounds() {
return true;
}
}

View File

@@ -10,7 +10,6 @@ import androidx.fragment.app.FragmentManager;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.mogo.eagle.core.function.api.base.IMoGoFunctionProvider;
import com.mogo.eagle.core.function.call.setting.CallerMoGoUiSettingManager;
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
import com.mogo.och.taxi.passenger.constant.TaxiPassengerConst;
import com.mogo.och.taxi.passenger.ui.TaxiPassengerBaseFragment;
@@ -37,14 +36,6 @@ public class MogoOCHTaxiPassenger implements IMoGoFunctionProvider {
CallerLogger.d(M_TAXI_P + TAG, "init");
}
/**
* 进入鹰眼模式,设置手势缩放地图失效
*/
private void stepIntoVrMode() {
CallerLogger.d(M_TAXI_P + TAG, "进入vr模式");
CallerMoGoUiSettingManager.INSTANCE.stepInNightMode();//夜间模式 状态栏字体颜色变黑
}
private void showFragment() {
FragmentManager supportFragmentManager = mActivity.getSupportFragmentManager();
if (ochTaxiPassengerFragment == null) {

View File

@@ -1,5 +0,0 @@
package com.mogo.och.taxi.passenger.callback;
public interface ITaxiPassengerCommonCallback {
void onCommonCallback();
}

View File

@@ -1,5 +0,0 @@
package com.mogo.och.taxi.passenger.callback;
public interface ITaxiPassengerCommonValueCallback<T> {
void onCommonCallback(T t);
}

View File

@@ -245,7 +245,7 @@ ext {
compileSdkVersion : 33,
buildToolsVersion : "29.0.2",
minSdkVersion : 23,
targetSdkVersion : 27,
targetSdkVersion : 29,
koomxhook : "com.kuaishou.koom:xhook-static:2.2.0",
]
}