diff --git a/OCH/mogo-och-bus-passenger/README.md b/OCH/mogo-och-bus-passenger/README.md new file mode 100644 index 0000000000..6175119b78 --- /dev/null +++ b/OCH/mogo-och-bus-passenger/README.md @@ -0,0 +1,15 @@ + + + + + +src + - androidTest Android 测试代码 + - basecommon 金旅开沃、接驳车 公用代码部分 + - jinlvvan 金旅开沃 独立代码部分 + - m1 金旅m1 独立代码部分 + - m2 金旅m2 独立代码部分 + - main 所有车型公用代码部分 + - shuttle 接驳车独立代码 因为接驳车和金旅开沃代码耦合厉害暂时放入到mogo-och-bus-passenger里面 + 后期会创建独立module和mogo-och-bus-passenger平级 + - test 普通代码测试 \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/build.gradle b/OCH/mogo-och-bus-passenger/build.gradle index f9be5b07ca..0818ec952e 100644 --- a/OCH/mogo-och-bus-passenger/build.gradle +++ b/OCH/mogo-och-bus-passenger/build.gradle @@ -2,6 +2,7 @@ apply plugin: 'com.android.library' apply plugin: 'com.alibaba.arouter' apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' +apply plugin: 'kotlin-kapt' android { compileSdkVersion rootProject.ext.android.compileSdkVersion @@ -16,9 +17,10 @@ android { testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" consumerProguardFiles "consumer-rules.pro" - javaCompileOptions { - annotationProcessorOptions { - arguments = [AROUTER_MODULE_NAME: project.getName()] + kapt { + useBuildCache = false + arguments { + arg("AROUTER_MODULE_NAME", project.getName()) } } } @@ -38,6 +40,26 @@ android { proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } + + flavorDimensions "vehicle" + productFlavors { + // 车型:金旅星辰、开沃 小巴业务 + jinlvvan { + dimension "vehicle" + buildConfigField 'int', 'NEW_TEST', '0' + } + // 车型:金旅m1 小巴业务 + m1 { + dimension "vehicle" + buildConfigField 'int', 'NEW_TEST', '1' + } + + // 车型:金旅m1 小巴业务 + m2 { + dimension "vehicle" + buildConfigField 'int', 'NEW_TEST', '1' + } + } } dependencies { @@ -47,28 +69,15 @@ dependencies { implementation rootProject.ext.dependencies.arouter implementation rootProject.ext.dependencies.androidxrecyclerview implementation rootProject.ext.dependencies.material - annotationProcessor rootProject.ext.dependencies.aroutercompiler + kapt rootProject.ext.dependencies.aroutercompiler implementation rootProject.ext.dependencies.rxandroid implementation rootProject.ext.dependencies.androidxconstraintlayout implementation rootProject.ext.dependencies.amapnavi3dmap implementation project(":OCH:mogo-och-common-module") - if (Boolean.valueOf(USE_MAVEN_PACKAGE)) { - implementation rootProject.ext.dependencies.mogoutils - implementation rootProject.ext.dependencies.mogocommons - implementation rootProject.ext.dependencies.modulecommon - implementation rootProject.ext.dependencies.mogo_core_data - implementation rootProject.ext.dependencies.mogo_core_function_call - implementation rootProject.ext.dependencies.mogo_core_function_v2x - implementation rootProject.ext.dependencies.mogo_core_function_hmi - }else { - implementation project(":core:mogo-core-utils") - implementation project(":foudations:mogo-commons") - implementation project(':modules:mogo-module-common') - implementation project(':core:mogo-core-data') - implementation project(':core:mogo-core-function-call') - implementation project(':core:function-impl:mogo-core-function-v2x') - implementation project(':core:function-impl:mogo-core-function-hmi') - } + compileOnly project(":libraries:mogo-map") + implementation project(':core:mogo-core-res') + testImplementation 'junit:junit:4.12' + } apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString() \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/MogoOCHBusPassenger.java b/OCH/mogo-och-bus-passenger/src/jinlvvan/java/com/mogo/och/bus/passenger/MogoOCHBusPassenger.java similarity index 76% rename from OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/MogoOCHBusPassenger.java rename to OCH/mogo-och-bus-passenger/src/jinlvvan/java/com/mogo/och/bus/passenger/MogoOCHBusPassenger.java index f4d202ef6c..3bf45d5f18 100644 --- a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/MogoOCHBusPassenger.java +++ b/OCH/mogo-och-bus-passenger/src/jinlvvan/java/com/mogo/och/bus/passenger/MogoOCHBusPassenger.java @@ -1,32 +1,32 @@ package com.mogo.och.bus.passenger; +import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_TAXI_P; + import android.content.Context; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentActivity; 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.data.config.FunctionBuildConfig; import com.mogo.eagle.core.function.call.setting.CallerMoGoUiSettingManager; +import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils; import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger; -import com.mogo.map.MogoMapUIController; +import com.mogo.eagle.core.utilcode.util.MultiDisplayUtils; import com.mogo.och.bus.passenger.constant.BusPassengerConst; import com.mogo.och.bus.passenger.ui.BusPassengerRouteFragment; +import com.mogo.och.common.module.wigets.video.VideoPlayerActivity; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_TAXI_P; - /** * 网约车-Bus-乘客端 * * Created on 2022/3/29 */ @Route(path = BusPassengerConst.PATH) -public class MogoOCHBusPassenger implements IMogoOCH, IMogoStatusChangedListener { +public class MogoOCHBusPassenger implements IMogoOCH { private static final String TAG = MogoOCHBusPassenger.class.getSimpleName(); private FragmentActivity mActivity; @@ -43,8 +43,11 @@ public class MogoOCHBusPassenger implements IMogoOCH, IMogoStatusChangedListener public Fragment createCoverage(@Nullable FragmentActivity activity, @Nullable Integer containerId) { this.mActivity = activity; this.mContainerId = containerId; + showFragment(); -// UiThreadHandler.post(() -> stepIntoVrMode()); + if (AppIdentityModeUtils.isJL(FunctionBuildConfig.appIdentityMode)) { + MultiDisplayUtils.INSTANCE.startActWithSecond(activity, VideoPlayerActivity.class); + } return null; } @@ -63,18 +66,6 @@ public class MogoOCHBusPassenger implements IMogoOCH, IMogoStatusChangedListener @Override public void init(Context context) { - MogoStatusManager.getInstance().registerStatusChangedListener("OchBus",StatusDescriptor.VR_MODE, this); - } - - @Override - public void onStatusChanged(StatusDescriptor descriptor, boolean isTrue) { - if (descriptor == StatusDescriptor.VR_MODE) { - if (isTrue){ - showFragment(); - }else { - hideFragment(); - } - } } /** @@ -82,9 +73,6 @@ public class MogoOCHBusPassenger implements IMogoOCH, IMogoStatusChangedListener */ private void stepIntoVrMode() { CallerLogger.INSTANCE.d( M_TAXI_P + TAG, "进入vr模式" ); - MogoMapUIController.getInstance() - .stepInVrMode( true ); // 白天模式 - CallerMoGoUiSettingManager.INSTANCE.stepInDayMode();//白天模式 状态栏字体颜色变黑 } diff --git a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/adapter/BusPassengerLineStationsAdapter.java b/OCH/mogo-och-bus-passenger/src/jinlvvan/java/com/mogo/och/bus/passenger/adapter/BusPassengerLineStationsAdapter.java similarity index 100% rename from OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/adapter/BusPassengerLineStationsAdapter.java rename to OCH/mogo-och-bus-passenger/src/jinlvvan/java/com/mogo/och/bus/passenger/adapter/BusPassengerLineStationsAdapter.java diff --git a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/bean/BusPassengerOperationStatusResponse.java b/OCH/mogo-och-bus-passenger/src/jinlvvan/java/com/mogo/och/bus/passenger/bean/BusPassengerOperationStatusResponse.java similarity index 100% rename from OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/bean/BusPassengerOperationStatusResponse.java rename to OCH/mogo-och-bus-passenger/src/jinlvvan/java/com/mogo/och/bus/passenger/bean/BusPassengerOperationStatusResponse.java diff --git a/OCH/mogo-och-bus-passenger/src/jinlvvan/java/com/mogo/och/bus/passenger/bean/BusPassengerQueryLineRequest.java b/OCH/mogo-och-bus-passenger/src/jinlvvan/java/com/mogo/och/bus/passenger/bean/BusPassengerQueryLineRequest.java new file mode 100644 index 0000000000..35ba94ce3a --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/jinlvvan/java/com/mogo/och/bus/passenger/bean/BusPassengerQueryLineRequest.java @@ -0,0 +1,16 @@ +package com.mogo.och.bus.passenger.bean; + +public +/** + * @author congtaowang + * @since 2021/3/22 + * + * 根据车机行驶线路站点信息 + */ +class BusPassengerQueryLineRequest { + + private String sn; + public BusPassengerQueryLineRequest(String sn) { + this.sn = sn; + } +} diff --git a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/bean/BusPassengerRoutesResponse.java b/OCH/mogo-och-bus-passenger/src/jinlvvan/java/com/mogo/och/bus/passenger/bean/BusPassengerRoutesResponse.java similarity index 100% rename from OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/bean/BusPassengerRoutesResponse.java rename to OCH/mogo-och-bus-passenger/src/jinlvvan/java/com/mogo/och/bus/passenger/bean/BusPassengerRoutesResponse.java diff --git a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/bean/BusPassengerRoutesResult.java b/OCH/mogo-och-bus-passenger/src/jinlvvan/java/com/mogo/och/bus/passenger/bean/BusPassengerRoutesResult.java similarity index 100% rename from OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/bean/BusPassengerRoutesResult.java rename to OCH/mogo-och-bus-passenger/src/jinlvvan/java/com/mogo/och/bus/passenger/bean/BusPassengerRoutesResult.java diff --git a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/bean/BusPassengerStation.java b/OCH/mogo-och-bus-passenger/src/jinlvvan/java/com/mogo/och/bus/passenger/bean/BusPassengerStation.java similarity index 100% rename from OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/bean/BusPassengerStation.java rename to OCH/mogo-och-bus-passenger/src/jinlvvan/java/com/mogo/och/bus/passenger/bean/BusPassengerStation.java diff --git a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/callback/IBusPassegerDriverStatusCallback.java b/OCH/mogo-och-bus-passenger/src/jinlvvan/java/com/mogo/och/bus/passenger/callback/IBusPassegerDriverStatusCallback.java similarity index 100% rename from OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/callback/IBusPassegerDriverStatusCallback.java rename to OCH/mogo-och-bus-passenger/src/jinlvvan/java/com/mogo/och/bus/passenger/callback/IBusPassegerDriverStatusCallback.java diff --git a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/callback/IBusPassengerADASStatusCallback.java b/OCH/mogo-och-bus-passenger/src/jinlvvan/java/com/mogo/och/bus/passenger/callback/IBusPassengerADASStatusCallback.java similarity index 100% rename from OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/callback/IBusPassengerADASStatusCallback.java rename to OCH/mogo-och-bus-passenger/src/jinlvvan/java/com/mogo/och/bus/passenger/callback/IBusPassengerADASStatusCallback.java diff --git a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/callback/IBusPassengerAutopilotPlanningCallback.java b/OCH/mogo-och-bus-passenger/src/jinlvvan/java/com/mogo/och/bus/passenger/callback/IBusPassengerAutopilotPlanningCallback.java similarity index 89% rename from OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/callback/IBusPassengerAutopilotPlanningCallback.java rename to OCH/mogo-och-bus-passenger/src/jinlvvan/java/com/mogo/och/bus/passenger/callback/IBusPassengerAutopilotPlanningCallback.java index b4c97ccd35..786264650f 100644 --- a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/callback/IBusPassengerAutopilotPlanningCallback.java +++ b/OCH/mogo-och-bus-passenger/src/jinlvvan/java/com/mogo/och/bus/passenger/callback/IBusPassengerAutopilotPlanningCallback.java @@ -1,7 +1,6 @@ package com.mogo.och.bus.passenger.callback; import com.amap.api.maps.model.LatLng; -import com.mogo.eagle.core.data.map.MogoLatLng; import java.util.List; diff --git a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/callback/IBusPassengerControllerStatusCallback.java b/OCH/mogo-och-bus-passenger/src/jinlvvan/java/com/mogo/och/bus/passenger/callback/IBusPassengerControllerStatusCallback.java similarity index 100% rename from OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/callback/IBusPassengerControllerStatusCallback.java rename to OCH/mogo-och-bus-passenger/src/jinlvvan/java/com/mogo/och/bus/passenger/callback/IBusPassengerControllerStatusCallback.java diff --git a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/callback/IBusPassengerMapViewCallback.java b/OCH/mogo-och-bus-passenger/src/jinlvvan/java/com/mogo/och/bus/passenger/callback/IBusPassengerMapViewCallback.java similarity index 100% rename from OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/callback/IBusPassengerMapViewCallback.java rename to OCH/mogo-och-bus-passenger/src/jinlvvan/java/com/mogo/och/bus/passenger/callback/IBusPassengerMapViewCallback.java diff --git a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/callback/IBusPassengerRouteLineInfoCallback.java b/OCH/mogo-och-bus-passenger/src/jinlvvan/java/com/mogo/och/bus/passenger/callback/IBusPassengerRouteLineInfoCallback.java similarity index 76% rename from OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/callback/IBusPassengerRouteLineInfoCallback.java rename to OCH/mogo-och-bus-passenger/src/jinlvvan/java/com/mogo/och/bus/passenger/callback/IBusPassengerRouteLineInfoCallback.java index 7d7c95d9a7..b7d348a2b2 100644 --- a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/callback/IBusPassengerRouteLineInfoCallback.java +++ b/OCH/mogo-och-bus-passenger/src/jinlvvan/java/com/mogo/och/bus/passenger/callback/IBusPassengerRouteLineInfoCallback.java @@ -10,7 +10,7 @@ import java.util.List; */ public interface IBusPassengerRouteLineInfoCallback { void updateLineInfo(String lineName, String lineDurTime); - void updateStationsInfo(List stations,int currentStationIndex,boolean isArrived); + void updateStationsInfo(List stations, int currentStationIndex, boolean isArrived); void showNoTaskView(); void hideNoTaskView(); } diff --git a/OCH/mogo-och-bus-passenger/src/jinlvvan/java/com/mogo/och/bus/passenger/constant/URLConst.kt b/OCH/mogo-och-bus-passenger/src/jinlvvan/java/com/mogo/och/bus/passenger/constant/URLConst.kt new file mode 100644 index 0000000000..c0ef94ad99 --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/jinlvvan/java/com/mogo/och/bus/passenger/constant/URLConst.kt @@ -0,0 +1,24 @@ +package com.mogo.och.bus.passenger.constant + +import com.mogo.commons.debug.DebugConfig +import com.mogo.eagle.core.data.config.FunctionBuildConfig +import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils +import com.mogo.och.common.module.biz.constant.OchCommonConst + +/** + * Created on 2021/12/6 + */ +class URLConst { + companion object { + + @JvmStatic + fun getBaseUrl(): String { + return if(AppIdentityModeUtils.isShuttle(FunctionBuildConfig.appIdentityMode)){ + OchCommonConst.getShuttleUrl() + }else{ + OchCommonConst.getBaseUrl() + } + + } + } +} \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/model/BusPassengerModel.java b/OCH/mogo-och-bus-passenger/src/jinlvvan/java/com/mogo/och/bus/passenger/model/BusPassengerModel.java similarity index 87% rename from OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/model/BusPassengerModel.java rename to OCH/mogo-och-bus-passenger/src/jinlvvan/java/com/mogo/och/bus/passenger/model/BusPassengerModel.java index 46dd3a6b50..1dc6d54e50 100644 --- a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/model/BusPassengerModel.java +++ b/OCH/mogo-och-bus-passenger/src/jinlvvan/java/com/mogo/och/bus/passenger/model/BusPassengerModel.java @@ -1,5 +1,9 @@ package com.mogo.och.bus.passenger.model; +import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_BUS_P; +import static com.mogo.och.bus.passenger.constant.BusPassengerConst.QUERY_BUS_P_STATION_DELAY; +import static com.mogo.och.bus.passenger.constant.BusPassengerConst.STATION_STATUS_STOPPED; + import android.content.Context; import android.content.Intent; import android.net.ConnectivityManager; @@ -11,7 +15,6 @@ import androidx.annotation.Nullable; import com.amap.api.maps.model.LatLng; import com.mogo.aicloud.services.socket.MogoAiCloudSocketManager; -import com.mogo.cloud.commons.utils.CoordinateUtils; import com.mogo.commons.debug.DebugConfig; import com.mogo.commons.module.intent.IMogoIntentListener; import com.mogo.commons.module.intent.IntentManager; @@ -21,16 +24,17 @@ import com.mogo.commons.module.status.StatusDescriptor; import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo; import com.mogo.eagle.core.data.config.FunctionBuildConfig; import com.mogo.eagle.core.data.map.MogoLocation; -import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotPlanningListener; import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener; -import com.mogo.eagle.core.function.api.map.listener.IMoGoMapLocationListener; +import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationGCJ02Listener; +import com.mogo.eagle.core.function.api.autopilot.IMoGoPlanningRottingListener; import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager; -import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotPlanningListenerManager; -import com.mogo.eagle.core.function.call.map.CallerMapLocationListenerManager; +import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ02ListenerManager; +import com.mogo.eagle.core.function.call.autopilot.CallerPlanningRottingListenerManager; import com.mogo.eagle.core.network.utils.GsonUtil; import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils; import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger; import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr; +import com.mogo.eagle.core.utilcode.util.CoordinateUtils; import com.mogo.eagle.core.utilcode.util.NetworkUtils; import com.mogo.eagle.core.utilcode.util.ToastUtils; import com.mogo.och.bus.passenger.R; @@ -49,6 +53,7 @@ import com.mogo.och.bus.passenger.network.BusPassengerServiceManager; import com.mogo.och.common.module.biz.network.OchCommonServiceCallback; import com.mogo.och.common.module.manager.AbnormalFactorsLoopManager; import com.mogo.och.common.module.utils.CoordinateCalculateRouteUtil; + import org.jetbrains.annotations.NotNull; import java.util.ArrayList; @@ -60,10 +65,6 @@ import mogo.telematics.pad.MessagePad; import mogo_msg.MogoReportMsg; import system_master.SystemStatusInfo; -import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_BUS_P; -import static com.mogo.och.bus.passenger.constant.BusPassengerConst.QUERY_BUS_P_STATION_DELAY; -import static com.mogo.och.bus.passenger.constant.BusPassengerConst.STATION_STATUS_STOPPED; - /** * Created on 2022/3/31 */ @@ -88,7 +89,7 @@ public class BusPassengerModel { private IBusPassegerDriverStatusCallback mDriverStatusCallback; //出车收车状态 private IBusPassengerRouteLineInfoCallback mRouteLineInfoCallback; // bus路线信息更新 - private MogoLocation mLocation = null; + private MogoLocation mLocation = null; private BusPassengerRoutesResult routesResult = null; @@ -140,6 +141,7 @@ public class BusPassengerModel { public void onSuccess(BusPassengerOperationStatusResponse data) { if (data == null || data.data == null) return; if (mDriverStatusCallback != null) { + CallerLogger.INSTANCE.d( M_BUS_P + TAG, "queryDriverOperationStatus = %s", data.data.plateNumber ); mDriverStatusCallback.changeOperationStatus(data.data.driverStatus == 1); mDriverStatusCallback.updatePlateNumber(data.data.plateNumber); } @@ -168,38 +170,43 @@ public class BusPassengerModel { , new OchCommonServiceCallback() { @Override public void onSuccess(BusPassengerRoutesResponse data) { - if ( data == null - || data.getResult() == null - || data.getResult().getSites() == null) { - routesResult = null; - mNextStationIndex = 0; - startOrStopCalculateRouteInfo(false); - if (mRouteLineInfoCallback != null){ - mRouteLineInfoCallback.showNoTaskView(); + if ( data == null || data.getResult() == null) { + CallerLogger.INSTANCE.d( M_BUS_P + TAG, "queryDriverSiteByCoordinate = null"); + if (routesResult != null) { + routesResult = null; + mNextStationIndex = 0; + startOrStopCalculateRouteInfo(false); + if (mRouteLineInfoCallback != null){ + mRouteLineInfoCallback.showNoTaskView(); + } } + return; } - if (routesResult != null && routesResult.equals(data.getResult())){ + if (routesResult != null && data.getResult().equals(routesResult)){ + CallerLogger.INSTANCE.d( M_BUS_P + TAG, "queryDriverSiteByCoordinate = not update"); return; } routesResult = data.getResult(); updatePassengerRouteInfo(data.getResult()); } - @Override - public void onError() { - - } - @Override public void onFail(int code, String msg) { + CallerLogger.INSTANCE.d( M_BUS_P + TAG, "queryDriverSiteByCoordinate = %s", msg + + ", sn = " +BusPassengerServiceManager.INSTANCE.getDriverAppSn()); + if (code == 1003){ + queryDriverOperationDelay(); + } + if (BusPassengerServiceManager.INSTANCE.getDriverAppSn().isEmpty()){ + //此处拦截是为了防止过程中乘客屏和司机端断连,拿不到司机端sn, 造成请求失败去刷新了界面 + return; + } if (code == 1003){ routesResult = null; startOrStopCalculateRouteInfo(false); - queryDriverOperationDelay(); return; } - CallerLogger.INSTANCE.d( M_BUS_P + TAG, "queryDriverSiteByCoordinate = %s", msg ); } }); } @@ -271,10 +278,10 @@ public class BusPassengerModel { IntentManager.getInstance().registerIntentListener(ConnectivityManager.CONNECTIVITY_ACTION, mNetWorkIntentListener ); MogoStatusManager.getInstance().registerStatusChangedListener(TAG, StatusDescriptor.VR_MODE, mMogoStatusChangedListener ); // 定位监听 - CallerMapLocationListenerManager.INSTANCE.addListener(TAG, mMapLocationListener,false); + CallerChassisLocationGCJ02ListenerManager.INSTANCE.addListener(TAG, mMapLocationListener); //2021.11.1 自动驾驶路线规划接口 - CallerAutopilotPlanningListenerManager.INSTANCE.addListener(TAG,moGoAutopilotPlanningListener); + CallerPlanningRottingListenerManager.INSTANCE.addListener(TAG,moGoAutopilotPlanningListener); AbnormalFactorsLoopManager.INSTANCE.startLoopAbnormalFactors(mContext); } @@ -283,13 +290,13 @@ public class BusPassengerModel { MogoStatusManager.getInstance().unregisterStatusChangedListener(TAG, StatusDescriptor.VR_MODE, mMogoStatusChangedListener); // 注销定位监听 - CallerMapLocationListenerManager.INSTANCE.removeListener(TAG,false); + CallerChassisLocationGCJ02ListenerManager.INSTANCE.removeListener(TAG); MogoAiCloudSocketManager.getInstance(mContext) .unregisterLifecycleListener(10010); CallerAutoPilotStatusListenerManager.INSTANCE.removeListener(mGoAutopilotStatusListener); - CallerAutopilotPlanningListenerManager.INSTANCE.removeListener(moGoAutopilotPlanningListener); + CallerPlanningRottingListenerManager.INSTANCE.removeListener(moGoAutopilotPlanningListener); AbnormalFactorsLoopManager.INSTANCE.stopLoopAbnormalFactors(); } @@ -318,13 +325,13 @@ public class BusPassengerModel { } }; - private final IMoGoMapLocationListener mMapLocationListener = new IMoGoMapLocationListener() { + private final IMoGoChassisLocationGCJ02Listener mMapLocationListener = new IMoGoChassisLocationGCJ02Listener() { @Override - public void onLocationChanged(@Nullable MogoLocation location, int from, boolean isGps) { - if (null == location) return; - mLocation = location; + public void onChassisLocationGCJ02(@Nullable MogoLocation gnssInfo) { + if (null == gnssInfo) return; + mLocation = gnssInfo; for (IBusPassengerControllerStatusCallback callback :mControllerStatusCallbackMap.values()){ - callback.onCarLocationChanged(location); + callback.onCarLocationChanged(gnssInfo); } } }; @@ -401,11 +408,7 @@ public class BusPassengerModel { } }; - private final IMoGoAutopilotPlanningListener moGoAutopilotPlanningListener = new IMoGoAutopilotPlanningListener(){ - - @Override - public void onAutopilotTrajectory(@NonNull List trajectoryInfos) { - } + private final IMoGoPlanningRottingListener moGoAutopilotPlanningListener = new IMoGoPlanningRottingListener(){ @Override public void onAutopilotRotting(@Nullable MessagePad.GlobalPathResp routeList) { @@ -431,7 +434,7 @@ public class BusPassengerModel { //找出前往站对应的轨迹点,拿出两站点的集合 CallerLogger.INSTANCE.d(M_BUS_P + TAG, "mRoutePoints.size() = " + mRoutePoints.size()); if (mRoutePoints.size() > 0) { - if (mStations.size() > 1){ //改为两个站点及以上计算两个站点间的估计路线 + if (mStations.size() > 1){ //两个站点及以上要计算两个站点间的轨迹路线 if (mNextStationIndex <= mStations.size()-1 && mNextStationIndex - 1 >=0){ mTwoStationsRouts.clear(); BusPassengerStation stationNext = mStations.get(mNextStationIndex); @@ -451,6 +454,10 @@ public class BusPassengerModel { } } } +// else { //只有两个站点的时候整个路线就是两个站点之间的轨迹 +// mTwoStationsRouts.clear(); +// mTwoStationsRouts.addAll(mRoutePoints); +// } if (mTwoStationsRouts.size() > 0){ float sumLength = CoordinateCalculateRouteUtil.calculateRouteSumLength(mTwoStationsRouts); SharedPrefsMgr.getInstance(mContext).putInt(BusPassengerConst.BUS_SP_KEY_ORDER_SUM_DIS,(int) sumLength); @@ -493,7 +500,8 @@ public class BusPassengerModel { }else { lastSumLength = CoordinateCalculateRouteUtil.calculateRouteSumLength(lastPoints); } - double lastTime = lastSumLength / BusPassengerConst.BUS_AVERAGE_SPEED * 3.6 ; //秒 + + double lastTime = lastSumLength / getAverageSpeed() * 3.6 ; //秒 CallerLogger.INSTANCE.d(M_BUS_P + TAG, "轨迹排查==lastSumLength = " + lastSumLength); if (mAutopilotPlanningCallback != null){ mAutopilotPlanningCallback.routePlanningToNextStationChanged((long)lastSumLength,(long) lastTime); @@ -502,6 +510,14 @@ public class BusPassengerModel { } } + public int getAverageSpeed(){ + if (AppIdentityModeUtils.isShuttle(FunctionBuildConfig.appIdentityMode)){ + return BusPassengerConst.SHUTTLE_AVERAGE_SPEED; + }else { + return BusPassengerConst.BUS_AVERAGE_SPEED; + } + } + public void startRemainRouteInfo() { //开启实时计算剩余距离,剩余时间,预计时间 startOrStopCalculateRouteInfo(true); diff --git a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/network/BusPassengerModelLoopManager.java b/OCH/mogo-och-bus-passenger/src/jinlvvan/java/com/mogo/och/bus/passenger/network/BusPassengerModelLoopManager.java similarity index 100% rename from OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/network/BusPassengerModelLoopManager.java rename to OCH/mogo-och-bus-passenger/src/jinlvvan/java/com/mogo/och/bus/passenger/network/BusPassengerModelLoopManager.java diff --git a/OCH/mogo-och-bus-passenger/src/jinlvvan/java/com/mogo/och/bus/passenger/network/BusPassengerServiceManager.kt b/OCH/mogo-och-bus-passenger/src/jinlvvan/java/com/mogo/och/bus/passenger/network/BusPassengerServiceManager.kt new file mode 100644 index 0000000000..39a85aa57f --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/jinlvvan/java/com/mogo/och/bus/passenger/network/BusPassengerServiceManager.kt @@ -0,0 +1,101 @@ +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.cloud.passport.MoGoAiCloudClientConfig +import com.mogo.eagle.core.data.config.FunctionBuildConfig +import com.mogo.eagle.core.function.call.telematic.CallerTelematicManager +import com.mogo.och.bus.passenger.bean.BusPassengerQueryLineRequest +import com.mogo.och.bus.passenger.bean.BusPassengerOperationStatusResponse +import com.mogo.eagle.core.network.MoGoRetrofitFactory +import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils +import com.mogo.och.bus.passenger.constant.URLConst.Companion.getBaseUrl +import com.mogo.och.common.module.biz.network.OchCommonServiceCallback +import com.mogo.och.common.module.biz.network.OchCommonSubscribeImpl +import com.mogo.och.common.module.biz.network.interceptor.transformTry + +/** + * Created on 2022/3/31 + */ +object BusPassengerServiceManager { + + private var driverSnCache = "" + + private var mShuttleBusPassengerServiceApi = + MoGoRetrofitFactory.getInstance(getBaseUrl()).create(ShettlePassengerServiceApi::class.java) + private var mBusPassengerServiceApi = + MoGoRetrofitFactory.getInstance(getBaseUrl()).create(PassengerServiceApi::class.java) + + /** + * 获取Bus司机端的sn + * @return + */ + 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? + ) { + if (AppIdentityModeUtils.isShuttle(FunctionBuildConfig.appIdentityMode)) { + mShuttleBusPassengerServiceApi.queryDriverSiteByCoordinate( + MoGoAiCloudClientConfig.getInstance().serviceAppId, + MoGoAiCloudClientConfig.getInstance().token, + BusPassengerQueryLineRequest( + driverAppSn + ) + ).transformTry() + .subscribe(OchCommonSubscribeImpl(context, callback, "queryDriverSiteByCoordinate")) + } else { + mBusPassengerServiceApi.queryDriverSiteByCoordinate( + MoGoAiCloudClientConfig.getInstance().serviceAppId, + MoGoAiCloudClientConfig.getInstance().token, + BusPassengerQueryLineRequest( + driverAppSn + ) + ).transformTry() + .subscribe(OchCommonSubscribeImpl(context, callback, "queryDriverSiteByCoordinate")) + } + } + + /** + * 查询司机端出车收车状态,以及车牌号 + * @param context + * @param callback + */ + @JvmStatic + fun queryDriverOperationStatus( + context: Context, + callback: OchCommonServiceCallback? + ) { + if (AppIdentityModeUtils.isShuttle(FunctionBuildConfig.appIdentityMode)) { + mShuttleBusPassengerServiceApi.queryDriverOperationStatus( + MoGoAiCloudClientConfig.getInstance().serviceAppId, + MoGoAiCloudClientConfig.getInstance().token, + driverAppSn + ) + .transformTry() + .subscribe(OchCommonSubscribeImpl(context, callback, "queryDriverOperationStatus")) + } else { + mBusPassengerServiceApi.queryDriverOperationStatus( + MoGoAiCloudClientConfig.getInstance().serviceAppId, + MoGoAiCloudClientConfig.getInstance().token, + driverAppSn + ) + .transformTry() + .subscribe(OchCommonSubscribeImpl(context, callback, "queryDriverOperationStatus")) + } + } +} \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/jinlvvan/java/com/mogo/och/bus/passenger/network/PassengerServiceApi.java b/OCH/mogo-och-bus-passenger/src/jinlvvan/java/com/mogo/och/bus/passenger/network/PassengerServiceApi.java new file mode 100644 index 0000000000..b1c16037d0 --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/jinlvvan/java/com/mogo/och/bus/passenger/network/PassengerServiceApi.java @@ -0,0 +1,40 @@ +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 io.reactivex.Observable; +import retrofit2.http.Body; +import retrofit2.http.GET; +import retrofit2.http.Header; +import retrofit2.http.Headers; +import retrofit2.http.POST; +import retrofit2.http.Query; + +/** + * Created on 2022/3/31 + * + * Bus乘客端接口定义 + */ +interface PassengerServiceApi { + /** + * 查询bus司机端绑定路线 + * @return 接口返回数据 + */ + @Headers( {"Content-Type:application/json;charset=UTF-8"} ) + @POST( "/autopilot-car-hailing/line/v2/driver/bus/passenger/lineDataWithDriver/query" ) + Observable 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 queryDriverOperationStatus(@Header ("appId") String appId, @Header("ticket") String ticket, @Query("sn") String sn); + + +} diff --git a/OCH/mogo-och-bus-passenger/src/jinlvvan/java/com/mogo/och/bus/passenger/network/ShettlePassengerServiceApi.java b/OCH/mogo-och-bus-passenger/src/jinlvvan/java/com/mogo/och/bus/passenger/network/ShettlePassengerServiceApi.java new file mode 100644 index 0000000000..c780786bf2 --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/jinlvvan/java/com/mogo/och/bus/passenger/network/ShettlePassengerServiceApi.java @@ -0,0 +1,40 @@ +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 io.reactivex.Observable; +import retrofit2.http.Body; +import retrofit2.http.GET; +import retrofit2.http.Header; +import retrofit2.http.Headers; +import retrofit2.http.POST; +import retrofit2.http.Query; + +/** + * Created on 2022/3/31 + * + * Bus乘客端接口定义 + */ +interface ShettlePassengerServiceApi { + /** + * 查询bus司机端绑定路线 + * @return 接口返回数据 + */ + @Headers( {"Content-Type:application/json;charset=UTF-8"} ) + @POST( "/och-shuttle-cabin/api/business/v1/passenger/lineDataWithDriver/query" ) + Observable 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("/och-shuttle-cabin/api/business/v1/passenger/loginStatus") + Observable queryDriverOperationStatus(@Header ("appId") String appId, @Header("ticket") String ticket, @Query("sn") String sn); + + +} diff --git a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/presenter/BaseBusPassengerPresenter.java b/OCH/mogo-och-bus-passenger/src/jinlvvan/java/com/mogo/och/bus/passenger/presenter/BaseBusPassengerPresenter.java similarity index 99% rename from OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/presenter/BaseBusPassengerPresenter.java rename to OCH/mogo-och-bus-passenger/src/jinlvvan/java/com/mogo/och/bus/passenger/presenter/BaseBusPassengerPresenter.java index b87abc0736..0373dbc61b 100644 --- a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/presenter/BaseBusPassengerPresenter.java +++ b/OCH/mogo-och-bus-passenger/src/jinlvvan/java/com/mogo/och/bus/passenger/presenter/BaseBusPassengerPresenter.java @@ -1,6 +1,7 @@ package com.mogo.och.bus.passenger.presenter; -import android.location.Location; +import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_BUS_P; + import android.os.Looper; import androidx.annotation.NonNull; @@ -24,8 +25,6 @@ import com.mogo.och.bus.passenger.ui.BusPassengerRouteFragment; import java.util.List; -import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_BUS_P; - /** * Created on 2022/3/31 */ diff --git a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/ui/BusPassengerBaseFragment.java b/OCH/mogo-och-bus-passenger/src/jinlvvan/java/com/mogo/och/bus/passenger/ui/BusPassengerBaseFragment.java similarity index 88% rename from OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/ui/BusPassengerBaseFragment.java rename to OCH/mogo-och-bus-passenger/src/jinlvvan/java/com/mogo/och/bus/passenger/ui/BusPassengerBaseFragment.java index c9abd42c76..fa686d846f 100644 --- a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/ui/BusPassengerBaseFragment.java +++ b/OCH/mogo-och-bus-passenger/src/jinlvvan/java/com/mogo/och/bus/passenger/ui/BusPassengerBaseFragment.java @@ -8,6 +8,7 @@ import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.TextView; +import androidx.annotation.NonNull; import androidx.core.widget.ContentLoadingProgressBar; import com.mogo.commons.mvp.IView; @@ -15,14 +16,12 @@ import com.mogo.commons.mvp.MvpFragment; import com.mogo.commons.mvp.Presenter; import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener; -import com.mogo.eagle.core.function.call.hmi.CallerHmiManager; -import com.mogo.eagle.core.function.call.map.CallerSmpManager; +import com.mogo.eagle.core.function.view.MapBizView; import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr; import com.mogo.eagle.core.utilcode.util.UiThreadHandler; import com.mogo.och.bus.passenger.R; import com.mogo.och.bus.passenger.constant.BusPassengerConst; import com.mogo.och.common.module.utils.NumberFormatUtil; -import com.mogo.och.common.module.wigets.OCHBorderShadowLayout; /** * Created on 2022/3/31 @@ -32,6 +31,7 @@ import com.mogo.och.common.module.wigets.OCHBorderShadowLayout; public abstract class BusPassengerBaseFragment> extends MvpFragment { private static final String TAG = BusPassengerBaseFragment.class.getSimpleName(); + private MapBizView mapBizView; private TextView mCurrentArriveStation; private TextView mCurrentArriveStationTitle; private TextView mCurrentArriveTip; @@ -56,12 +56,9 @@ public abstract class BusPassengerBaseFragment mStationsList = new ArrayList<>(); + private final List mStationsList = new ArrayList<>(); private TextView mSpeedTv; private ConstraintLayout mNoLineInfoView; @@ -74,8 +72,6 @@ public class BusPassengerRouteFragment extends @Override protected void initViews() { super.initViews(); - mTrafficLightView = findViewById(R.id.bus_p_traffic_light_view); - CallerHmiManager.INSTANCE.setProxyTrafficLightView(mTrafficLightView); mSpeedTv = findViewById(R.id.bus_p_speed_tv); @@ -302,7 +298,7 @@ public class BusPassengerRouteFragment extends } public void onCarLocationChanged(MogoLocation location) { - updateSpeedView(location.getSpeed()); + updateSpeedView((float) location.getGnssSpeed()); } public void updateSpeedView(float speed){ diff --git a/OCH/mogo-och-bus-passenger/src/jinlvvan/java/com/mogo/och/bus/passenger/ui/BusPassengerTrafficLightView.kt b/OCH/mogo-och-bus-passenger/src/jinlvvan/java/com/mogo/och/bus/passenger/ui/BusPassengerTrafficLightView.kt new file mode 100644 index 0000000000..67fbc4b554 --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/jinlvvan/java/com/mogo/och/bus/passenger/ui/BusPassengerTrafficLightView.kt @@ -0,0 +1,179 @@ +package com.mogo.och.bus.passenger.ui + +import android.content.Context +import android.util.AttributeSet +import android.view.LayoutInflater +import android.widget.LinearLayout +import com.mogo.eagle.core.data.enums.DataSourceType +import com.mogo.eagle.core.data.enums.TrafficLightEnum +import com.mogo.eagle.core.function.api.datacenter.union.IMoGoTrafficLightListener +import com.mogo.eagle.core.function.call.v2x.CallerTrafficLightListenerManager +import com.mogo.eagle.core.utilcode.util.UiThreadHandler +import com.mogo.och.bus.passenger.R +import kotlinx.android.synthetic.jinlvvan.bus_p_traffic_light_view.view.* + +/** + * bus乘客端:红绿灯view + * + * Created on 2022/3/14 + */ +class BusPassengerTrafficLightView @JvmOverloads constructor( + context: Context?, + attrs: AttributeSet? = null, + defStyleAttr: Int = 0 +) : LinearLayout(context, attrs, defStyleAttr), IMoGoTrafficLightListener { + + companion object { + private const val TAG = "BusPassengerTrafficLightView" + } + + private var mCurrentLightId = TrafficLightEnum.BLACK + + init { + init(context) + } + + private fun init(context: Context?) { + LayoutInflater.from(context).inflate(R.layout.bus_p_traffic_light_view, this, true) + } + + override fun onAttachedToWindow() { + super.onAttachedToWindow() + CallerTrafficLightListenerManager.addListener(TAG, this) + } + + override fun onDetachedFromWindow() { + super.onDetachedFromWindow() + CallerTrafficLightListenerManager.removeListener(TAG) + } + + /** + * 展示红绿灯预警 + * + * @param checkLightId 0-都是默认,1-红,2-黄,3-绿 + * @param lightSource 1:云端下发;2:自车感知 + */ + override fun showTrafficLight(checkLightId: TrafficLightEnum, lightSource: DataSourceType) { + super.showTrafficLight(checkLightId, lightSource) + mCurrentLightId = checkLightId + updateTrafficLightIcon(checkLightId) + } + + /** + * 关闭红绿灯预警展示,并重制灯态 + */ + override fun disableTrafficLight() { + super.disableTrafficLight() + UiThreadHandler.post { + mCurrentLightId = TrafficLightEnum.BLACK + this@BusPassengerTrafficLightView.visibility = GONE + } + } + + /** + * @param redNum 红灯倒计时 + * @param yellowNum 黄灯倒计时 + * @param greenNum 绿灯倒计时 + */ + override fun changeCountdownTrafficLightNum(redNum: Int, yellowNum: Int, greenNum: Int) { + super.changeCountdownTrafficLightNum(redNum, yellowNum, greenNum) + resetView() + when (mCurrentLightId) { + TrafficLightEnum.RED -> changeCountdownRed(redNum) + TrafficLightEnum.YELLOW -> changeCountdownYellow(yellowNum) + TrafficLightEnum.GREEN -> changeCountdownGreen(greenNum) + else -> UiThreadHandler.post { bus_p_traffic_light_time_tv.text = "" } + } + } + + override fun changeCountdownRed(redNum: Int) { + super.changeCountdownRed(redNum) + UiThreadHandler.post { + if (redNum > 0) { + resetView() + bus_p_traffic_light_time_tv.text = redNum.toString() + } else { + disableTrafficLightCountDown() + bus_p_traffic_light_time_tv.text = "" + } + } + } + + override fun changeCountdownGreen(greenNum: Int) { + super.changeCountdownGreen(greenNum) + UiThreadHandler.post { + if (greenNum > 0) { + resetView() + bus_p_traffic_light_time_tv.text = greenNum.toString() + } else { + disableTrafficLightCountDown() + bus_p_traffic_light_time_tv.text = "" + } + } + } + + override fun changeCountdownYellow(yellowNum: Int) { + super.changeCountdownYellow(yellowNum) + UiThreadHandler.post { + if (yellowNum > 0) { + resetView() + bus_p_traffic_light_time_tv.text = yellowNum.toString() + } else { + disableTrafficLightCountDown() + bus_p_traffic_light_time_tv.text = "" + } + } + } + + /** + * 更新红绿灯icon + * + * @param lightId 0-都是默认,1-红,2-黄,3-绿 + */ + private fun updateTrafficLightIcon(lightId: TrafficLightEnum) { + UiThreadHandler.post { + when (lightId) { + TrafficLightEnum.RED -> { + bus_p_traffic_light_iv.setBackgroundResource(R.drawable.bus_p_light_red_nor) + this@BusPassengerTrafficLightView.visibility = VISIBLE + } + TrafficLightEnum.YELLOW -> { + bus_p_traffic_light_iv.setBackgroundResource(R.drawable.bus_p_light_yellow_nor) + this@BusPassengerTrafficLightView.visibility = VISIBLE + } + TrafficLightEnum.GREEN -> { + bus_p_traffic_light_iv.setBackgroundResource(R.drawable.bus_p_light_green_nor) + this@BusPassengerTrafficLightView.visibility = VISIBLE + } + else -> this@BusPassengerTrafficLightView.visibility = GONE + } + } + } + + override fun disableTrafficLightCountDown() { + super.disableTrafficLightCountDown() + UiThreadHandler.post { + val layoutParams = layoutParams + if (layoutParams is MarginLayoutParams) { + val lp = layoutParams + lp.width = resources.getDimension(R.dimen.bus_p_traffic_light_icon_size).toInt() + setLayoutParams(lp) + bus_p_traffic_light_time_tv.visibility = GONE + bus_p_traffic_light_bg.layoutParams.width = + resources.getDimension(R.dimen.dp_90).toInt() + } + } + } + + private fun resetView() { + val layoutParams = layoutParams + if (layoutParams is MarginLayoutParams) { + val lp = layoutParams + lp.width = resources.getDimension(R.dimen.bus_p_route_traffic_light_view_width).toInt() + setLayoutParams(lp) + bus_p_traffic_light_time_tv.visibility = VISIBLE + bus_p_traffic_light_bg.layoutParams.width = + resources.getDimension(R.dimen.bus_p_traffic_light_bg_width).toInt() + } + } +} \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/ui/IBusPassengerMapDirectionView.java b/OCH/mogo-och-bus-passenger/src/jinlvvan/java/com/mogo/och/bus/passenger/ui/IBusPassengerMapDirectionView.java similarity index 100% rename from OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/ui/IBusPassengerMapDirectionView.java rename to OCH/mogo-och-bus-passenger/src/jinlvvan/java/com/mogo/och/bus/passenger/ui/IBusPassengerMapDirectionView.java diff --git a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/ui/layoutmanager/CenterLayoutManager.java b/OCH/mogo-och-bus-passenger/src/jinlvvan/java/com/mogo/och/bus/passenger/ui/layoutmanager/CenterLayoutManager.java similarity index 100% rename from OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/ui/layoutmanager/CenterLayoutManager.java rename to OCH/mogo-och-bus-passenger/src/jinlvvan/java/com/mogo/och/bus/passenger/ui/layoutmanager/CenterLayoutManager.java diff --git a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/utils/BPRouteDataTestUtils.java b/OCH/mogo-och-bus-passenger/src/jinlvvan/java/com/mogo/och/bus/passenger/utils/BPRouteDataTestUtils.java similarity index 100% rename from OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/utils/BPRouteDataTestUtils.java rename to OCH/mogo-och-bus-passenger/src/jinlvvan/java/com/mogo/och/bus/passenger/utils/BPRouteDataTestUtils.java diff --git a/OCH/mogo-och-bus-passenger/src/main/res/drawable-xhdpi/bg_bus_p_arrived_station.png b/OCH/mogo-och-bus-passenger/src/jinlvvan/res/drawable-nodpi/bg_bus_p_arrived_station.png similarity index 100% rename from OCH/mogo-och-bus-passenger/src/main/res/drawable-xhdpi/bg_bus_p_arrived_station.png rename to OCH/mogo-och-bus-passenger/src/jinlvvan/res/drawable-nodpi/bg_bus_p_arrived_station.png diff --git a/OCH/mogo-och-bus-passenger/src/main/res/drawable-xhdpi/bus_p_arrow_nor.png b/OCH/mogo-och-bus-passenger/src/jinlvvan/res/drawable-nodpi/bus_p_arrow_nor.png similarity index 100% rename from OCH/mogo-och-bus-passenger/src/main/res/drawable-xhdpi/bus_p_arrow_nor.png rename to OCH/mogo-och-bus-passenger/src/jinlvvan/res/drawable-nodpi/bus_p_arrow_nor.png diff --git a/OCH/mogo-och-bus-passenger/src/main/res/drawable-xhdpi/bus_p_auto_nor.png b/OCH/mogo-och-bus-passenger/src/jinlvvan/res/drawable-nodpi/bus_p_auto_nor.png similarity index 100% rename from OCH/mogo-och-bus-passenger/src/main/res/drawable-xhdpi/bus_p_auto_nor.png rename to OCH/mogo-och-bus-passenger/src/jinlvvan/res/drawable-nodpi/bus_p_auto_nor.png diff --git a/OCH/mogo-och-bus-passenger/src/main/res/drawable-xhdpi/bus_p_light_green_nor.png b/OCH/mogo-och-bus-passenger/src/jinlvvan/res/drawable-nodpi/bus_p_light_green_nor.png similarity index 100% rename from OCH/mogo-och-bus-passenger/src/main/res/drawable-xhdpi/bus_p_light_green_nor.png rename to OCH/mogo-och-bus-passenger/src/jinlvvan/res/drawable-nodpi/bus_p_light_green_nor.png diff --git a/OCH/mogo-och-bus-passenger/src/main/res/drawable-xhdpi/bus_p_light_red_nor.png b/OCH/mogo-och-bus-passenger/src/jinlvvan/res/drawable-nodpi/bus_p_light_red_nor.png similarity index 100% rename from OCH/mogo-och-bus-passenger/src/main/res/drawable-xhdpi/bus_p_light_red_nor.png rename to OCH/mogo-och-bus-passenger/src/jinlvvan/res/drawable-nodpi/bus_p_light_red_nor.png diff --git a/OCH/mogo-och-bus-passenger/src/main/res/drawable-xhdpi/bus_p_light_yellow_nor.png b/OCH/mogo-och-bus-passenger/src/jinlvvan/res/drawable-nodpi/bus_p_light_yellow_nor.png similarity index 100% rename from OCH/mogo-och-bus-passenger/src/main/res/drawable-xhdpi/bus_p_light_yellow_nor.png rename to OCH/mogo-och-bus-passenger/src/jinlvvan/res/drawable-nodpi/bus_p_light_yellow_nor.png diff --git a/OCH/mogo-och-bus-passenger/src/main/res/drawable-xhdpi/bus_p_line_blue.png b/OCH/mogo-och-bus-passenger/src/jinlvvan/res/drawable-nodpi/bus_p_line_blue.png similarity index 100% rename from OCH/mogo-och-bus-passenger/src/main/res/drawable-xhdpi/bus_p_line_blue.png rename to OCH/mogo-och-bus-passenger/src/jinlvvan/res/drawable-nodpi/bus_p_line_blue.png diff --git a/OCH/mogo-och-bus-passenger/src/main/res/drawable-xhdpi/bus_p_line_green.png b/OCH/mogo-och-bus-passenger/src/jinlvvan/res/drawable-nodpi/bus_p_line_green.png similarity index 100% rename from OCH/mogo-och-bus-passenger/src/main/res/drawable-xhdpi/bus_p_line_green.png rename to OCH/mogo-och-bus-passenger/src/jinlvvan/res/drawable-nodpi/bus_p_line_green.png diff --git a/OCH/mogo-och-bus-passenger/src/main/res/drawable-xhdpi/bus_p_line_grey.png b/OCH/mogo-och-bus-passenger/src/jinlvvan/res/drawable-nodpi/bus_p_line_grey.png similarity index 100% rename from OCH/mogo-och-bus-passenger/src/main/res/drawable-xhdpi/bus_p_line_grey.png rename to OCH/mogo-och-bus-passenger/src/jinlvvan/res/drawable-nodpi/bus_p_line_grey.png diff --git a/OCH/mogo-och-bus-passenger/src/main/res/drawable-xhdpi/bus_p_map_arrow_arrived.png b/OCH/mogo-och-bus-passenger/src/jinlvvan/res/drawable-nodpi/bus_p_map_arrow_arrived.png similarity index 100% rename from OCH/mogo-och-bus-passenger/src/main/res/drawable-xhdpi/bus_p_map_arrow_arrived.png rename to OCH/mogo-och-bus-passenger/src/jinlvvan/res/drawable-nodpi/bus_p_map_arrow_arrived.png diff --git a/OCH/mogo-och-bus-passenger/src/main/res/drawable-xhdpi/bus_p_map_arrow_un_arrive.png b/OCH/mogo-och-bus-passenger/src/jinlvvan/res/drawable-nodpi/bus_p_map_arrow_un_arrive.png similarity index 100% rename from OCH/mogo-och-bus-passenger/src/main/res/drawable-xhdpi/bus_p_map_arrow_un_arrive.png rename to OCH/mogo-och-bus-passenger/src/jinlvvan/res/drawable-nodpi/bus_p_map_arrow_un_arrive.png diff --git a/OCH/mogo-och-bus-passenger/src/main/res/drawable-xhdpi/bus_p_map_car.png b/OCH/mogo-och-bus-passenger/src/jinlvvan/res/drawable-nodpi/bus_p_map_car.png similarity index 100% rename from OCH/mogo-och-bus-passenger/src/main/res/drawable-xhdpi/bus_p_map_car.png rename to OCH/mogo-och-bus-passenger/src/jinlvvan/res/drawable-nodpi/bus_p_map_car.png diff --git a/OCH/mogo-och-bus-passenger/src/main/res/drawable-xhdpi/bus_p_map_view_dir_end_point.png b/OCH/mogo-och-bus-passenger/src/jinlvvan/res/drawable-nodpi/bus_p_map_view_dir_end_point.png similarity index 100% rename from OCH/mogo-och-bus-passenger/src/main/res/drawable-xhdpi/bus_p_map_view_dir_end_point.png rename to OCH/mogo-och-bus-passenger/src/jinlvvan/res/drawable-nodpi/bus_p_map_view_dir_end_point.png diff --git a/OCH/mogo-och-bus-passenger/src/main/res/drawable-xhdpi/bus_p_map_view_dir_way_point.png b/OCH/mogo-och-bus-passenger/src/jinlvvan/res/drawable-nodpi/bus_p_map_view_dir_way_point.png similarity index 100% rename from OCH/mogo-och-bus-passenger/src/main/res/drawable-xhdpi/bus_p_map_view_dir_way_point.png rename to OCH/mogo-och-bus-passenger/src/jinlvvan/res/drawable-nodpi/bus_p_map_view_dir_way_point.png diff --git a/OCH/mogo-och-bus-passenger/src/main/res/drawable-xhdpi/bus_p_mogo_nor.png b/OCH/mogo-och-bus-passenger/src/jinlvvan/res/drawable-nodpi/bus_p_mogo_nor.png similarity index 100% rename from OCH/mogo-och-bus-passenger/src/main/res/drawable-xhdpi/bus_p_mogo_nor.png rename to OCH/mogo-och-bus-passenger/src/jinlvvan/res/drawable-nodpi/bus_p_mogo_nor.png diff --git a/OCH/mogo-och-bus-passenger/src/main/res/drawable-xhdpi/bus_p_no_order_data.png b/OCH/mogo-och-bus-passenger/src/jinlvvan/res/drawable-nodpi/bus_p_no_order_data.png similarity index 100% rename from OCH/mogo-och-bus-passenger/src/main/res/drawable-xhdpi/bus_p_no_order_data.png rename to OCH/mogo-och-bus-passenger/src/jinlvvan/res/drawable-nodpi/bus_p_no_order_data.png diff --git a/OCH/mogo-och-bus-passenger/src/main/res/drawable-xhdpi/bus_p_point_blue.png b/OCH/mogo-och-bus-passenger/src/jinlvvan/res/drawable-nodpi/bus_p_point_blue.png similarity index 100% rename from OCH/mogo-och-bus-passenger/src/main/res/drawable-xhdpi/bus_p_point_blue.png rename to OCH/mogo-och-bus-passenger/src/jinlvvan/res/drawable-nodpi/bus_p_point_blue.png diff --git a/OCH/mogo-och-bus-passenger/src/main/res/drawable-xhdpi/bus_p_point_gray.png b/OCH/mogo-och-bus-passenger/src/jinlvvan/res/drawable-nodpi/bus_p_point_gray.png similarity index 100% rename from OCH/mogo-och-bus-passenger/src/main/res/drawable-xhdpi/bus_p_point_gray.png rename to OCH/mogo-och-bus-passenger/src/jinlvvan/res/drawable-nodpi/bus_p_point_gray.png diff --git a/OCH/mogo-och-bus-passenger/src/main/res/drawable-xhdpi/bus_p_point_green.png b/OCH/mogo-och-bus-passenger/src/jinlvvan/res/drawable-nodpi/bus_p_point_green.png similarity index 100% rename from OCH/mogo-och-bus-passenger/src/main/res/drawable-xhdpi/bus_p_point_green.png rename to OCH/mogo-och-bus-passenger/src/jinlvvan/res/drawable-nodpi/bus_p_point_green.png diff --git a/OCH/mogo-och-bus-passenger/src/main/res/drawable-xhdpi/bus_p_un_auto_nor.png b/OCH/mogo-och-bus-passenger/src/jinlvvan/res/drawable-nodpi/bus_p_un_auto_nor.png similarity index 100% rename from OCH/mogo-och-bus-passenger/src/main/res/drawable-xhdpi/bus_p_un_auto_nor.png rename to OCH/mogo-och-bus-passenger/src/jinlvvan/res/drawable-nodpi/bus_p_un_auto_nor.png diff --git a/OCH/mogo-och-bus-passenger/src/main/res/drawable-xhdpi/station_arrow.png b/OCH/mogo-och-bus-passenger/src/jinlvvan/res/drawable-nodpi/station_arrow.png similarity index 100% rename from OCH/mogo-och-bus-passenger/src/main/res/drawable-xhdpi/station_arrow.png rename to OCH/mogo-och-bus-passenger/src/jinlvvan/res/drawable-nodpi/station_arrow.png diff --git a/OCH/mogo-och-bus-passenger/src/main/res/drawable/bg_bus_p_end_station_circle.xml b/OCH/mogo-och-bus-passenger/src/jinlvvan/res/drawable/bg_bus_p_end_station_circle.xml similarity index 100% rename from OCH/mogo-och-bus-passenger/src/main/res/drawable/bg_bus_p_end_station_circle.xml rename to OCH/mogo-och-bus-passenger/src/jinlvvan/res/drawable/bg_bus_p_end_station_circle.xml diff --git a/OCH/mogo-och-bus-passenger/src/main/res/drawable/bg_bus_p_end_tag_bg.xml b/OCH/mogo-och-bus-passenger/src/jinlvvan/res/drawable/bg_bus_p_end_tag_bg.xml similarity index 100% rename from OCH/mogo-och-bus-passenger/src/main/res/drawable/bg_bus_p_end_tag_bg.xml rename to OCH/mogo-och-bus-passenger/src/jinlvvan/res/drawable/bg_bus_p_end_tag_bg.xml diff --git a/OCH/mogo-och-bus-passenger/src/main/res/drawable/bg_bus_p_middle_station_circle.xml b/OCH/mogo-och-bus-passenger/src/jinlvvan/res/drawable/bg_bus_p_middle_station_circle.xml similarity index 100% rename from OCH/mogo-och-bus-passenger/src/main/res/drawable/bg_bus_p_middle_station_circle.xml rename to OCH/mogo-och-bus-passenger/src/jinlvvan/res/drawable/bg_bus_p_middle_station_circle.xml diff --git a/OCH/mogo-och-bus-passenger/src/main/res/drawable/bg_bus_p_start_station_circle.xml b/OCH/mogo-och-bus-passenger/src/jinlvvan/res/drawable/bg_bus_p_start_station_circle.xml similarity index 100% rename from OCH/mogo-och-bus-passenger/src/main/res/drawable/bg_bus_p_start_station_circle.xml rename to OCH/mogo-och-bus-passenger/src/jinlvvan/res/drawable/bg_bus_p_start_station_circle.xml diff --git a/OCH/mogo-och-bus-passenger/src/main/res/drawable/bg_bus_p_start_tag_bg.xml b/OCH/mogo-och-bus-passenger/src/jinlvvan/res/drawable/bg_bus_p_start_tag_bg.xml similarity index 100% rename from OCH/mogo-och-bus-passenger/src/main/res/drawable/bg_bus_p_start_tag_bg.xml rename to OCH/mogo-och-bus-passenger/src/jinlvvan/res/drawable/bg_bus_p_start_tag_bg.xml diff --git a/OCH/mogo-och-bus-passenger/src/main/res/drawable/bg_bus_p_traffic_light_background.xml b/OCH/mogo-och-bus-passenger/src/jinlvvan/res/drawable/bg_bus_p_traffic_light_background.xml similarity index 100% rename from OCH/mogo-och-bus-passenger/src/main/res/drawable/bg_bus_p_traffic_light_background.xml rename to OCH/mogo-och-bus-passenger/src/jinlvvan/res/drawable/bg_bus_p_traffic_light_background.xml diff --git a/OCH/mogo-och-bus-passenger/src/main/res/drawable/bus_p_dividing_line_bg.xml b/OCH/mogo-och-bus-passenger/src/jinlvvan/res/drawable/bus_p_dividing_line_bg.xml similarity index 100% rename from OCH/mogo-och-bus-passenger/src/main/res/drawable/bus_p_dividing_line_bg.xml rename to OCH/mogo-och-bus-passenger/src/jinlvvan/res/drawable/bus_p_dividing_line_bg.xml diff --git a/OCH/mogo-och-bus-passenger/src/main/res/drawable/bus_p_panel_cur_station_panel.xml b/OCH/mogo-och-bus-passenger/src/jinlvvan/res/drawable/bus_p_panel_cur_station_panel.xml similarity index 100% rename from OCH/mogo-och-bus-passenger/src/main/res/drawable/bus_p_panel_cur_station_panel.xml rename to OCH/mogo-och-bus-passenger/src/jinlvvan/res/drawable/bus_p_panel_cur_station_panel.xml diff --git a/OCH/mogo-och-bus-passenger/src/main/res/drawable/bus_p_route_bg.xml b/OCH/mogo-och-bus-passenger/src/jinlvvan/res/drawable/bus_p_route_bg.xml similarity index 100% rename from OCH/mogo-och-bus-passenger/src/main/res/drawable/bus_p_route_bg.xml rename to OCH/mogo-och-bus-passenger/src/jinlvvan/res/drawable/bus_p_route_bg.xml diff --git a/OCH/mogo-och-bus-passenger/src/main/res/drawable/bus_progress_bar_bg.xml b/OCH/mogo-och-bus-passenger/src/jinlvvan/res/drawable/bus_progress_bar_bg.xml similarity index 100% rename from OCH/mogo-och-bus-passenger/src/main/res/drawable/bus_progress_bar_bg.xml rename to OCH/mogo-och-bus-passenger/src/jinlvvan/res/drawable/bus_progress_bar_bg.xml diff --git a/OCH/mogo-och-bus-passenger/src/main/res/drawable/progress_item_round.xml b/OCH/mogo-och-bus-passenger/src/jinlvvan/res/drawable/progress_item_round.xml similarity index 100% rename from OCH/mogo-och-bus-passenger/src/main/res/drawable/progress_item_round.xml rename to OCH/mogo-och-bus-passenger/src/jinlvvan/res/drawable/progress_item_round.xml diff --git a/OCH/mogo-och-bus-passenger/src/main/res/layout/bus_p_base_fragment.xml b/OCH/mogo-och-bus-passenger/src/jinlvvan/res/layout/bus_p_base_fragment.xml similarity index 83% rename from OCH/mogo-och-bus-passenger/src/main/res/layout/bus_p_base_fragment.xml rename to OCH/mogo-och-bus-passenger/src/jinlvvan/res/layout/bus_p_base_fragment.xml index be1ab181c1..608ac59429 100644 --- a/OCH/mogo-och-bus-passenger/src/main/res/layout/bus_p_base_fragment.xml +++ b/OCH/mogo-och-bus-passenger/src/jinlvvan/res/layout/bus_p_base_fragment.xml @@ -4,6 +4,22 @@ android:layout_width="match_parent" android:layout_height="match_parent"> + + + + + + + + + + + + KM/H + 您已收车 + 暂无班次 + + + 到达站: + 下一站: + 始发站: + 请携带好随身物品下车。 + 欢迎乘坐蘑菇车联自动驾驶车。 + \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/m2/AndroidManifest.xml b/OCH/mogo-och-bus-passenger/src/m2/AndroidManifest.xml new file mode 100644 index 0000000000..c3b74bd86a --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/m2/AndroidManifest.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/m2/assets/m2_map_style.data b/OCH/mogo-och-bus-passenger/src/m2/assets/m2_map_style.data new file mode 100644 index 0000000000..76641add90 Binary files /dev/null and b/OCH/mogo-och-bus-passenger/src/m2/assets/m2_map_style.data differ diff --git a/OCH/mogo-och-bus-passenger/src/m2/assets/m2_map_style_extra.data b/OCH/mogo-och-bus-passenger/src/m2/assets/m2_map_style_extra.data new file mode 100644 index 0000000000..4bed4023d5 Binary files /dev/null and b/OCH/mogo-och-bus-passenger/src/m2/assets/m2_map_style_extra.data differ diff --git a/OCH/mogo-och-bus-passenger/src/m2/java/BPRouteDataTestUtils.java b/OCH/mogo-och-bus-passenger/src/m2/java/BPRouteDataTestUtils.java new file mode 100644 index 0000000000..6af58e3bb1 --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/m2/java/BPRouteDataTestUtils.java @@ -0,0 +1,56 @@ +import com.mogo.och.bus.passenger.model.PM2DrivingModel; + +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +import java.util.ArrayList; +import java.util.List; + +import mogo.telematics.pad.MessagePad; + +/** + * @author: wangmingjun + * @date: 2022/4/13 + */ +public class BPRouteDataTestUtils { + + //13号路口起-13号路口终 +// static String jsonStr ="{\n" + +// " \"models\": [\n" + +// " {\n" + +// " \"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19927760268911,\"lon\":116.73512607061035,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19927736555187,\"lon\":116.73498243020299,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19927135941599,\"lon\":116.73482951462647,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.199260672670036,\"lon\":116.73468429259535,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.199251260349946,\"lon\":116.73453933465,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19924691997577,\"lon\":116.7343756435551,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.199247953493625,\"lon\":116.73421240809087,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19924986849947,\"lon\":116.73400425509712,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.199249431152175,\"lon\":116.73378579041055,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.199248921305724,\"lon\":116.73357811807278,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19925012387371,\"lon\":116.73337650020184,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.199252270195075,\"lon\":116.73318223781153,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.1992521615169,\"lon\":116.73298632625203,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19925202633083,\"lon\":116.73279582043983,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.199261230205735,\"lon\":116.73263403473568,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.199327991681926,\"lon\":116.73251962434813,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19944850496711,\"lon\":116.73249661840195,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.199582026896415,\"lon\":116.73251038561487,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.199743326352014,\"lon\":116.73253087453938,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.199908347167394,\"lon\":116.73255070500186,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.200065950595445,\"lon\":116.7325720694418,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20022747460407,\"lon\":116.73259461416663,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.200384057310536,\"lon\":116.73261575018056,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20053849777916,\"lon\":116.73263451936387,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.200696919444624,\"lon\":116.7326540541723,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.2008524952796,\"lon\":116.7326743511824,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20101429705625,\"lon\":116.73269393580199,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20118279997041,\"lon\":116.73271564378308,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.201342388452076,\"lon\":116.73273653366076,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.201476063822355,\"lon\":116.73275292393079,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20163479199852,\"lon\":116.73277440686762,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20181243476041,\"lon\":116.7328052766508,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.201991767093304,\"lon\":116.7328453845644,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20215573733484,\"lon\":116.73287624009339,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.202313648759784,\"lon\":116.73289887933315,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.202434745374454,\"lon\":116.7329182210956,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20253164952098,\"lon\":116.73297539811277,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20258043275509,\"lon\":116.73312335324984,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20258233576585,\"lon\":116.73331077089557,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20257107560234,\"lon\":116.73351244039137,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.202561578580514,\"lon\":116.73370176209845,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20256256788661,\"lon\":116.73391325024126,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20255633158834,\"lon\":116.73413195000244,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.202543311179575,\"lon\":116.73436614303907,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20253067346457,\"lon\":116.73458032609663,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20251776111356,\"lon\":116.73477082198242,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.202503997557805,\"lon\":116.73498624001282,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20249129260376,\"lon\":116.73518976336872,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20247877796589,\"lon\":116.73537786253135,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20246651610268,\"lon\":116.73559239130266,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20245754388014,\"lon\":116.73574239922202,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20244749208,\"lon\":116.73589674090469,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20243806550113,\"lon\":116.73607057284322,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20243550556816,\"lon\":116.73628106525871,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20243654127756,\"lon\":116.7364949950665,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20243738221016,\"lon\":116.7367061649993,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20243672476754,\"lon\":116.73691115930336,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20243590788176,\"lon\":116.73710722104272,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.202436434375336,\"lon\":116.73730688607075,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20243749821501,\"lon\":116.73750140347998,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20243625962803,\"lon\":116.73771330926793,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.202434515480725,\"lon\":116.73791895606205,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.2024326561388,\"lon\":116.73815206945737,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20243092086137,\"lon\":116.73838655528765,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.202430876006126,\"lon\":116.73861890759498,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20242914053177,\"lon\":116.73882029918758,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20242843336561,\"lon\":116.73904465495175,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20242661219026,\"lon\":116.73922453252953,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.202426462811076,\"lon\":116.7393708046956,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20242687134937,\"lon\":116.73954685547025,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20242694967377,\"lon\":116.73975021183773,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.202424630601236,\"lon\":116.73999740812975,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.202422502184625,\"lon\":116.74028266774337,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.202419634158936,\"lon\":116.7405942561498,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20241975959762,\"lon\":116.7409069557092,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20241920524113,\"lon\":116.74120156191647,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20241765540262,\"lon\":116.74149288504978,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20241569149764,\"lon\":116.7418080096762,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.202414529497084,\"lon\":116.74210262897205,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20241419532155,\"lon\":116.74241767661879,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.202413879360954,\"lon\":116.7427571218185,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20241287045245,\"lon\":116.7431284691325,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20241214965105,\"lon\":116.74343354359334,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20241141271715,\"lon\":116.7437220210538,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.2024080520075,\"lon\":116.74399113498052,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.202391714280026,\"lon\":116.74427625698272,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20238163805639,\"lon\":116.74452083315958,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.202379293010274,\"lon\":116.74475703837204,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.202379007817086,\"lon\":116.7449961645494,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20237814181231,\"lon\":116.7452036063558,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.202375477619896,\"lon\":116.74539567654291,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.2023632396621,\"lon\":116.74555457589031,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20229396554444,\"lon\":116.7456716047369,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20217800547467,\"lon\":116.74574081942625,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.202047498095304,\"lon\":116.74573659255675,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20188573786706,\"lon\":116.74571018281719,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.201738240263026,\"lon\":116.74568463148606,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20157507049073,\"lon\":116.74565525041498,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20137985142042,\"lon\":116.745619970576,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.201187335613575,\"lon\":116.74558631350607,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20098251429043,\"lon\":116.74555055587679,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.2007748533628,\"lon\":116.74551426934663,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20057082986032,\"lon\":116.74547749663195,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20036944224329,\"lon\":116.74544156175533,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20016365229035,\"lon\":116.74540577510051,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.1999958572445,\"lon\":116.74537505807076,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19984100521566,\"lon\":116.7453433678602,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.1996863960282,\"lon\":116.74529675648621,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19953919567943,\"lon\":116.74525916493474,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19940587189373,\"lon\":116.74523402869453,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19929047792381,\"lon\":116.74518617038383,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19922141745155,\"lon\":116.74506912884067,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19920798885308,\"lon\":116.744896716334,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19920912644279,\"lon\":116.74467216715483,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.199209186509314,\"lon\":116.74448257515108,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19920910709997,\"lon\":116.74430613406223,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.1992100786082,\"lon\":116.74410888316238,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19921081961254,\"lon\":116.74391968819582,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19921040855518,\"lon\":116.7437082083402,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19921085053439,\"lon\":116.74346931155634,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19921197237373,\"lon\":116.74325149697013,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19921248248983,\"lon\":116.74301103786591,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.1992139724646,\"lon\":116.74277237066539,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.199215818352386,\"lon\":116.74253219408898,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.199216175018876,\"lon\":116.74228853120842,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.199215970354246,\"lon\":116.74204663206451,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.199216627492966,\"lon\":116.74183871233049,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19921789170398,\"lon\":116.74165788334192,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19922000138535,\"lon\":116.74144512197054,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.199221559127494,\"lon\":116.741249370491,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19922287231889,\"lon\":116.7410525810756,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19922229019589,\"lon\":116.74085266662037,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.1992216995901,\"lon\":116.74061957723823,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19922263073874,\"lon\":116.74041638149129,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19922478093337,\"lon\":116.7402123910757,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.199227066091595,\"lon\":116.74003419421553,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.199228634241756,\"lon\":116.73985841944678,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19922951636012,\"lon\":116.7397079274105,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.199252095329484,\"lon\":116.73956265582487,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.199346162997905,\"lon\":116.73944690416265,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.199470799628024,\"lon\":116.73941941053417,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19962513314346,\"lon\":116.7394280706812,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.199780626058924,\"lon\":116.73944255215424,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.199961525343376,\"lon\":116.73945856750177,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20016196947193,\"lon\":116.73947572081121,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.200384479551936,\"lon\":116.7394949225795,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.200595083817475,\"lon\":116.73951027963179,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.200792203321086,\"lon\":116.73952526850614,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.200985930701684,\"lon\":116.73954125209579,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20115978977055,\"lon\":116.73955610094161,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.201321019536124,\"lon\":116.7395695239138,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20147117943043,\"lon\":116.7395823299481,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20163699848565,\"lon\":116.73959633422596,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20178484338371,\"lon\":116.7396085776486,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.201962185646316,\"lon\":116.73962351991214,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.2021018923927,\"lon\":116.7396354059821,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.2022137620686,\"lon\":116.73964348380458,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20232600820075,\"lon\":116.73961190446633,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20241090270993,\"lon\":116.73951649703137,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20245777783807,\"lon\":116.73937664238166,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20246906634823,\"lon\":116.73920146119093,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.202470916682884,\"lon\":116.73898763065634,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20247034830421,\"lon\":116.73878158418357,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20246978204673,\"lon\":116.73857680142473,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20247082638905,\"lon\":116.73834517890637,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.202471943178196,\"lon\":116.7381047689514,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20247131648035,\"lon\":116.73787761484981,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.202470799473765,\"lon\":116.73766230702478,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20247013054322,\"lon\":116.73743619407796,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20246999515433,\"lon\":116.73724916823292,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20247199652478,\"lon\":116.73704888970806,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.202473960263525,\"lon\":116.73684083235807,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.202474504753205,\"lon\":116.73665462440796,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20247501354581,\"lon\":116.73650710371837,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20246541231906,\"lon\":116.73635807696789,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.202426768984274,\"lon\":116.73622283382787,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20236638788854,\"lon\":116.73610589402243,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20227106919894,\"lon\":116.73600895001849,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.2021428343084,\"lon\":116.73596816020945,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20197815580698,\"lon\":116.73594623645097,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20181789535303,\"lon\":116.73593148707488,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.201667906886954,\"lon\":116.73591743008926,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.201505897730755,\"lon\":116.7359002912543,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20135083580946,\"lon\":116.73588579696379,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20118617904595,\"lon\":116.73586970398149,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20102374028594,\"lon\":116.73585314703226,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20085554043743,\"lon\":116.73583763953049,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20069451888229,\"lon\":116.73582073901778,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.200530837344964,\"lon\":116.73580314359012,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.2003608457064,\"lon\":116.73578183888779,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20021770046798,\"lon\":116.73575292592922,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20003454701824,\"lon\":116.7357174959358,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19986125116602,\"lon\":116.73569499961796,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19969408518737,\"lon\":116.73567725223492,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19955533048882,\"lon\":116.73566375985422,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19943174810538,\"lon\":116.73564927714162,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19933167546824,\"lon\":116.735595995086,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.199280357603875,\"lon\":116.73546293260645,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19927848361656,\"lon\":116.73531579486274,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19928127892504,\"lon\":116.73505848474375,\"speed\": 0.0\n" + +// " }\n" + +// " ]\n" + +// "}"; + + //洱海轨迹 + static String jsonStr ="{\n" + + " \"models\": [\n" + + " {\n" + + "\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.87506159122434,\"longitude_\":100.13463113454593,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.874963432017065,\"longitude_\":100.13431083742782,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.87481475105022,\"longitude_\":100.13402921175965,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.874646001578594,\"longitude_\":100.13381071517328,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.874280379177108,\"longitude_\":100.13344505101841,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.87422474353087,\"longitude_\":100.13336522063217,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.8741846037573,\"longitude_\":100.13326081770579,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.874169301193604,\"longitude_\":100.133157732712,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.87417865388365,\"longitude_\":100.13305383003687,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.87424355168725,\"longitude_\":100.13288988207758,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.87441186213399,\"longitude_\":100.1326293335985,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.874490698935094,\"longitude_\":100.13247594955229,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.874551609777672,\"longitude_\":100.13227787460397,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.874574232444672,\"longitude_\":100.1320943662068,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.874574936235152,\"longitude_\":100.13109176087639,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.874553271326842,\"longitude_\":100.13095333429315,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.874468877309848,\"longitude_\":100.1307193884582,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.874449652750723,\"longitude_\":100.1306199898516,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.874449487671647,\"longitude_\":100.13046154976821,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.87448439242463,\"longitude_\":100.13030173580755,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.874554236422213,\"longitude_\":100.13013644761386,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.874657614202334,\"longitude_\":100.1299792051648,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.874777620037,\"longitude_\":100.12985830283493,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.8749211786138,\"longitude_\":100.12975642056448,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.875123187810807,\"longitude_\":100.12965486650492,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.875282658783302,\"longitude_\":100.12960819854966,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.87555277290776,\"longitude_\":100.12954493830546,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.875686392944456,\"longitude_\":100.12948797177033,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.87609150201856,\"longitude_\":100.12914349760804,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.87645852877848,\"longitude_\":100.1289124421148,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.87667085149294,\"longitude_\":100.1288070141346,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.877063427631544,\"longitude_\":100.12866094818,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.87751767381502,\"longitude_\":100.1286538378911,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.87776644058061,\"longitude_\":100.12861180318971,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.87866240134362,\"longitude_\":100.12843614360035,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.879103098247672,\"longitude_\":100.12837521690956,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.879326467139197,\"longitude_\":100.12832846342278,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.8800083487784,\"longitude_\":100.12811951944514,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.88019070137511,\"longitude_\":100.12802255167708,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.880357426115513,\"longitude_\":100.12787083439976,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.880481954487596,\"longitude_\":100.1276940858994,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.880653097994426,\"longitude_\":100.12740127585158,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.880758517533007,\"longitude_\":100.12730743064938,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.880799507331627,\"longitude_\":100.12724835914499,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.88098572681533,\"longitude_\":100.12658255210448,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.881039332211476,\"longitude_\":100.1263847771375,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.881100185621683,\"longitude_\":100.12625820340021,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.881198711287677,\"longitude_\":100.12611952057267,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.88133930457031,\"longitude_\":100.12599337741426,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.881467122690022,\"longitude_\":100.12592180492642,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.88159423650277,\"longitude_\":100.12588048516646,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.882012210316635,\"longitude_\":100.12584119198453,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.88240347787595,\"longitude_\":100.12581569076075,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.882530989675523,\"longitude_\":100.1258417579907,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.88266718412272,\"longitude_\":100.1258996456634,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.882846062879587,\"longitude_\":100.12604302069693,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.883143169798704,\"longitude_\":100.12643363872347,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.883316147374213,\"longitude_\":100.12660436351877,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.883516631635977,\"longitude_\":100.12670006660859,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.884412161186358,\"longitude_\":100.12681096840119,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.88456077756699,\"longitude_\":100.12680626559008,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.88490956874977,\"longitude_\":100.12672087342608,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.885302490381278,\"longitude_\":100.12667304829165,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.885521440240353,\"longitude_\":100.1266801970379,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.885748782438256,\"longitude_\":100.12673442989593,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.886184311775366,\"longitude_\":100.12689928223388,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.886371044711435,\"longitude_\":100.12693222015717,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.886556923046193,\"longitude_\":100.12691593845197,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.887058969863556,\"longitude_\":100.1267783886852,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.887547354704896,\"longitude_\":100.12664214250168,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.887745630547965,\"longitude_\":100.12661296296805,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.887952855908765,\"longitude_\":100.12663469253742,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.88838254724211,\"longitude_\":100.1267432660041,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.88867177268486,\"longitude_\":100.12674878070436,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.888948154040733,\"longitude_\":100.12668867979535,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.889119678251383,\"longitude_\":100.12661519197152,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.88965548111457,\"longitude_\":100.12632103004057,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.890440398289833,\"longitude_\":100.12572932612804,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.890595726487316,\"longitude_\":100.12569393173928,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.89083685708941,\"longitude_\":100.12572825271758,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.89092017694698,\"longitude_\":100.12571880871474,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.891037856897587,\"longitude_\":100.12567497177714,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.891761687561317,\"longitude_\":100.12513259535619,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.891885118463794,\"longitude_\":100.1250643533811,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.89201181287785,\"longitude_\":100.1250211908644,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.892633993404484,\"longitude_\":100.12487357365991,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.892723272763575,\"longitude_\":100.12483263537747,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.892820100842155,\"longitude_\":100.12471361851891,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.89291347694438,\"longitude_\":100.12434808103623,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.892985029043015,\"longitude_\":100.12422953782732,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.89308490178189,\"longitude_\":100.12416612695728,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.893360731467585,\"longitude_\":100.12410368114618,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.894308353220502,\"longitude_\":100.12396602611501,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.895020251951685,\"longitude_\":100.12387330229565,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0},{\"altitude_\":0.0,\"heading_\":0.0,\"latitude_\":25.895317877980734,\"longitude_\":100.12387135197324,\"memoizedIsInitialized\":-1,\"unknownFields\":{\"fields\":{},\"fieldsDescending\":{}},\"memoizedSize\":-1,\"memoizedHashCode\":0" + + + " }\n" + + " ]\n" + + "}"; + + public static void converToRouteData(){ + List list = new ArrayList<>(); + + try { + JSONObject jsonObject = new JSONObject(jsonStr); + JSONArray jsonElements = jsonObject.getJSONArray("models"); + for (int i = 0; i < jsonElements.length(); i++) { + JSONObject s = jsonElements.getJSONObject(i); + MessagePad.Location.Builder builder = MessagePad.Location.newBuilder(); + builder.setLatitude(s.getDouble("latitude_")); + builder.setLongitude(s.getDouble("longitude_")); + list.add(builder.build()); + } + PM2DrivingModel.Companion.getINSTANCE().updateRoutePoints(list); + + } catch (JSONException e) { + e.printStackTrace(); + } + } +} diff --git a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/BusPassengerM2.kt b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/BusPassengerM2.kt new file mode 100644 index 0000000000..de9937f0c7 --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/BusPassengerM2.kt @@ -0,0 +1,92 @@ +package com.mogo.och.bus.passenger + +import android.content.Context +import androidx.fragment.app.Fragment +import androidx.fragment.app.FragmentActivity +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.call.map.CallerMapUIServiceManager.getMapUIController +import com.mogo.eagle.core.function.call.setting.CallerMoGoUiSettingManager.stepInDayMode +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d +import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant +import com.mogo.och.bus.passenger.constant.BusPassengerConst +import com.mogo.och.bus.passenger.ui.PM2BaseFragment + +/** + * 网约车-Bus-乘客端 + * + * Created on 2022/3/29 + */ +@Route(path = BusPassengerConst.PATH) +class MogoOCHBusPassenger : IMogoOCH, IMogoStatusChangedListener { + private var mActivity: FragmentActivity? = null + private var mContainerId = 0 + private var mPM2Fragment: PM2BaseFragment? = null + override fun createCoverage(activity: FragmentActivity, containerId: Int) {} + override fun createCoverage(activity: FragmentActivity?, containerId: Int?): Fragment? { + mActivity = activity + mContainerId = containerId!! +// if (MogoStatusManager.getInstance().isScreenCoverDismiss){ + showFragment() +// }else{ +// MogoStatusManager.getInstance() +// .registerStatusChangedListener("ochM2Passenger", StatusDescriptor.SCREEN_COVER, this) +// } + return null + } + + override val functionName: String + get() = "och-bus-passenger-m2" + + override fun onDestroy() { + // 若不调用finish, 设置中打开关闭UITouch,会造成och fragment 重叠 + mActivity?.finish() + } + + override fun init(context: Context) { + } + + /** + * 进入鹰眼模式,设置手势缩放地图失效 + */ + private fun stepIntoVrMode() { + d(SceneConstant.M_TAXI_P + TAG, "进入vr模式") + getMapUIController()?.stepInVrMode(true) // 白天模式 + stepInDayMode() //白天模式 状态栏字体颜色变黑 + } + + private fun showFragment() { + if (mPM2Fragment == null) { + d(SceneConstant.M_TAXI_P + TAG, "准备add fragment======") + mPM2Fragment = PM2BaseFragment() + mActivity?.supportFragmentManager?.beginTransaction() + ?.add(mContainerId, mPM2Fragment!!)?.commitAllowingStateLoss() + } + d(SceneConstant.M_TAXI_P + TAG, "准备show fragment") + mActivity?.supportFragmentManager?.beginTransaction()?.show(mPM2Fragment!!) + ?.commitAllowingStateLoss() + } + + private fun hideFragment() { + if (mPM2Fragment != null) { + mActivity?.supportFragmentManager?.beginTransaction()?.hide(mPM2Fragment!!) + ?.commitAllowingStateLoss() + } + } + + companion object { + private val TAG = MogoOCHBusPassenger::class.java.simpleName + } + + override fun onStatusChanged(descriptor: StatusDescriptor?, isTrue: Boolean) { + if (descriptor == StatusDescriptor.SCREEN_COVER){ + if (isTrue){ + showFragment() + }else{ + hideFragment() + } + } + } +} \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/bean/PM2OperationStatusResponse.java b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/bean/PM2OperationStatusResponse.java new file mode 100644 index 0000000000..9869a9e135 --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/bean/PM2OperationStatusResponse.java @@ -0,0 +1,21 @@ +package com.mogo.och.bus.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:已出车 + } +} diff --git a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/bean/PM2QueryLineRequest.java b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/bean/PM2QueryLineRequest.java new file mode 100644 index 0000000000..5569730773 --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/bean/PM2QueryLineRequest.java @@ -0,0 +1,16 @@ +package com.mogo.och.bus.passenger.bean; + +public +/** + * @author congtaowang + * @since 2021/3/22 + * + * 根据车机行驶线路站点信息 + */ +class PM2QueryLineRequest { + + private String sn; + public PM2QueryLineRequest(String sn) { + this.sn = sn; + } +} diff --git a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/bean/PM2RoutesResponse.java b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/bean/PM2RoutesResponse.java new file mode 100644 index 0000000000..207b2d7e7d --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/bean/PM2RoutesResponse.java @@ -0,0 +1,28 @@ +package com.mogo.och.bus.passenger.bean; + +import com.mogo.eagle.core.data.BaseData; + +/** + * 网约车小巴路线接口请求响应结果 返回的是对应司机屏的线路信息 + * + * @author tongchenfei + */ +public class PM2RoutesResponse extends BaseData { + private PM2RoutesResult data; + + public PM2RoutesResult getResult() { + return data; + } + + public void setResult(PM2RoutesResult data) { + this.data = data; + } + + @Override + public String toString() { + return "OchBusRoutesResponse{" + + "data=" + data + + '}'; + } + +} diff --git a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/bean/PM2RoutesResult.java b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/bean/PM2RoutesResult.java new file mode 100644 index 0000000000..1f26b5346d --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/bean/PM2RoutesResult.java @@ -0,0 +1,79 @@ +package com.mogo.och.bus.passenger.bean; + +import java.util.List; +import java.util.Objects; + +/** + * 网约车小巴路线接口返回接口数据封装 + * + * @author tongchenfei + */ +public class PM2RoutesResult { + private List 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 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); + } +} diff --git a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/bean/PM2Station.java b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/bean/PM2Station.java new file mode 100644 index 0000000000..ec903b7e93 --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/bean/PM2Station.java @@ -0,0 +1,173 @@ +package com.mogo.och.bus.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:taxi,10: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); + } +} diff --git a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/callback/ADASCallback.kt b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/callback/ADASCallback.kt new file mode 100644 index 0000000000..217f03740f --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/callback/ADASCallback.kt @@ -0,0 +1,10 @@ +package com.mogo.och.bus.passenger.callback + +/** + * @author: wangmingjun + * @date: 2023/2/15 + */ +interface ADASCallback { + fun updateHDMapStations(stations: MutableList>) + fun removeHDMapStations() +} \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/callback/AutoPilotStatusCallback.kt b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/callback/AutoPilotStatusCallback.kt new file mode 100644 index 0000000000..efb7410ba2 --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/callback/AutoPilotStatusCallback.kt @@ -0,0 +1,14 @@ +package com.mogo.och.bus.passenger.callback + +/** + * @author: wangmingjun + * @date: 2023/2/13 + */ +interface AutoPilotStatusCallback { + /** + * false: 未开启自驾, true : 开启自驾 + */ + fun updateAutoStatus(isOpen: Boolean) + + fun updateAutoStatus(status: Int) +} \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/callback/DrivingInfoCallback.kt b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/callback/DrivingInfoCallback.kt new file mode 100644 index 0000000000..452ffb685a --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/callback/DrivingInfoCallback.kt @@ -0,0 +1,18 @@ +package com.mogo.och.bus.passenger.callback + +import com.mogo.och.bus.passenger.bean.PM2Station + +/** + * @author: wangmingjun + * @date: 2023/2/2 + */ +interface DrivingInfoCallback { + fun updateSpeed(speed: Int) + fun updatePlateNumber(carNum: String) + fun updateLine(lineName: String, lineDuring: String) + fun updateRemainMT(meters : Long, timeInSecond : Long) // 米,秒 + fun changeOperationStatus(loginStatus : Boolean) + fun showNoTaskView(isTrue : Boolean) + fun updateLineStations(stations: MutableList) + fun updateStationsInfo(stations: MutableList, i: Int, isArrived: Boolean) +} \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/constant/M2Const.kt b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/constant/M2Const.kt new file mode 100644 index 0000000000..65d482b5fd --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/constant/M2Const.kt @@ -0,0 +1,16 @@ +package com.mogo.och.bus.passenger.constant + +/** + * Created on 2021/12/6 + */ +class M2Const { + companion object { + //站点UUID + const val M2_MAP_STATION_MAKER = "m2_map_station_maker" + + /** + * Marker类型 + */ + const val TYPE_MARKER_M2_LINE = "TYPE_MARKER_M2_LINE" + } +} \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/model/PM2ADASModel.kt b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/model/PM2ADASModel.kt new file mode 100644 index 0000000000..a21f2fd938 --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/model/PM2ADASModel.kt @@ -0,0 +1,46 @@ +package com.mogo.och.bus.passenger.model + +import android.content.Context +import com.amap.api.maps.model.LatLng +import com.mogo.och.bus.passenger.bean.PM2Station +import com.mogo.och.bus.passenger.callback.ADASCallback + +/** + * @author: wangmingjun + * @date: 2023/2/2 + */ +class PM2ADASModel private constructor() { + + private var mContext: Context? = null + private var mAdasCallback: ADASCallback? = null + + companion object { + val TAG = PM2ADASModel::class.java.simpleName + val INSTANCE: PM2ADASModel by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) { + PM2ADASModel() + } + } + + fun init(context : Context){ + this.mContext = context + } + + fun setAdasCallback(adasCallback: ADASCallback?){ + this.mAdasCallback = adasCallback + } + + fun updateHDMapStations(stations: MutableList){ + var stationsList = mutableListOf>() + for (i in stations.indices){ + var listLatLng = mutableListOf() // 0: long 1:lat + listLatLng.add(stations[i].lon) + listLatLng.add(stations[i].lat) + stationsList.add(listLatLng) + } + mAdasCallback?.updateHDMapStations(stationsList) + } + + fun removeHDMapStations(){ + mAdasCallback?.removeHDMapStations() + } +} \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/model/PM2DrivingModel.kt b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/model/PM2DrivingModel.kt new file mode 100644 index 0000000000..60f012ba68 --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/model/PM2DrivingModel.kt @@ -0,0 +1,530 @@ +package com.mogo.och.bus.passenger.model + +import android.content.Context +import android.media.AudioAttributes +import android.media.AudioFocusRequest +import android.media.AudioManager +import android.net.ConnectivityManager +import android.os.Build +import android.os.Handler +import androidx.annotation.RequiresApi +import com.mogo.commons.module.intent.IMogoIntentListener +import com.mogo.commons.module.intent.IntentManager +import com.mogo.commons.voice.AIAssist +import com.mogo.commons.voice.IMogoVoiceCmdCallBack +import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo +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.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.ToastUtils +import com.mogo.och.bus.passenger.R +import com.mogo.och.bus.passenger.bean.PM2OperationStatusResponse +import com.mogo.och.bus.passenger.bean.PM2RoutesResponse +import com.mogo.och.bus.passenger.bean.PM2RoutesResult +import com.mogo.och.bus.passenger.bean.PM2Station +import com.mogo.och.bus.passenger.callback.AutoPilotStatusCallback +import com.mogo.och.bus.passenger.callback.DrivingInfoCallback +import com.mogo.och.bus.passenger.constant.BusPassengerConst +import com.mogo.och.bus.passenger.network.PM2ModelLoopManager +import com.mogo.och.common.module.bean.AppConnectMsg +import com.mogo.och.common.module.biz.common.socketmessage.OCHSocketMessageManager +import com.mogo.och.common.module.biz.network.OchCommonServiceCallback +import com.mogo.och.common.module.biz.constant.OchCommonConst +import com.mogo.och.common.module.utils.CoordinateCalculateRouteUtil +import com.mogo.och.common.module.utils.DateTimeUtil +import mogo.telematics.pad.MessagePad +import kotlin.math.abs + +/** + * @author: wangmingjun + * @date: 2023/1/31 + */ +class PM2DrivingModel private constructor() { + + private var mContext: Context? = null + private var mLocation: MogoLocation? = null + + private var mRoutePoints = mutableListOf() + private var routesResult: PM2RoutesResult? = null + + private var mCurrentAutoStatus = -1 + + var mStations = mutableListOf() + private var mNextStationIndex = 0 // A-B要到达站的index + private var isGoingToNextStation = false //是否前往下一站过程中 + + private var mTwoStationsRouts = mutableListOf() + private var mPreRouteIndex = 0 + private var mWipePreIndex = 0 + + private var mDrivingInfoCallback: DrivingInfoCallback? = null //行程信息 + private var mAutoStatusCallback: AutoPilotStatusCallback? = null //自动驾驶状态 + + private var operationStatus: PM2OperationStatusResponse.Result? = null + + private val handler = Handler(Handler.Callback { msg -> + if (msg.what == MSG_QUERY_BUS_P_STATION) { + queryDriverOperationStatus() + return@Callback true + } + false + }) + + companion object { + val TAG = PM2DrivingModel::class.java.simpleName + const val MSG_QUERY_BUS_P_STATION = 1001 + val INSTANCE: PM2DrivingModel by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) { + PM2DrivingModel() + } + } + + fun init(context : Context){ + mContext = context + initListener() + // TODO: 2022/3/31 + queryDriverOperationStatus() + startOrStopOrderLoop(true) + } + + private fun initListener() { + //自动驾驶状态监听 + CallerAutoPilotStatusListenerManager.addListener(TAG, mAutoPilotStatusListener) + + // 定位监听 + CallerChassisLocationGCJ02ListenerManager.addListener(TAG, mMapLocationListener) +// CallerChassisLocationGCJ02ListenerManager.setListenerHz(TAG,2)//设置2hz, 1s返回2次 + + //司乘屏通信监听 + CallerTelematicListenerManager.addListener(TAG,mReceivedMsgListener) + + //自动驾驶轨迹监听 + CallerPlanningRottingListenerManager.addListener(TAG, moGoAutopilotPlanningListener) + + //网络监听 + IntentManager.getInstance().registerIntentListener(ConnectivityManager.CONNECTIVITY_ACTION, mNetWorkIntentListener) + + } + + fun releaseListener(){ + //自动驾驶状态监听 + CallerAutoPilotStatusListenerManager.removeListener(TAG) + + // 定位监听 + CallerChassisLocationGCJ02ListenerManager.removeListener(TAG) + + CallerTelematicListenerManager.removeListener(TAG) + + //自动驾驶轨迹监听 + CallerPlanningRottingListenerManager.removeListener(TAG) + } + + fun setDrivingInfoCallback(drivingInfoCallback : DrivingInfoCallback?){ + mDrivingInfoCallback = drivingInfoCallback + } + + fun setAutoStatusCallback(autoPilotStatusCallback: AutoPilotStatusCallback?){ + mAutoStatusCallback = autoPilotStatusCallback + } + + private val mNetWorkIntentListener = IMogoIntentListener { intentStr, _ -> + if (ConnectivityManager.CONNECTIVITY_ACTION == intentStr) { + if (NetworkUtils.isConnected(mContext)) { + queryDriverOperationStatus() + } + } + } + + private val mReceivedMsgListener: IReceivedMsgListener = + object : IReceivedMsgListener{ + @RequiresApi(Build.VERSION_CODES.O) + override fun onReceivedMsg(type: Int, byteArray: ByteArray) {//接收司机端发来的信息 + if (OchCommonConst.BUSINESS_STRING == type){ + val msg = GsonUtils.fromJson(String(byteArray),AppConnectMsg::class.java) as AppConnectMsg + Logger.d(SceneConstant.M_BUS_P+TAG,"onReceivedMsg = "+GsonUtils.toJson(msg)) + if (msg.isPlay){ //播报 + speakTTS(msg.msg) + } + if (msg.isViewShow){ //消息盒子显示内容 + OCHSocketMessageManager.pushAppOperationalMsgBox( + DateTimeUtil.getCurrentTimeStamp(),msg.msg) + } + } + } + } + + @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来监听焦点的获取 + .build() + mAudioManager.requestAudioFocus(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 onSpeakSelectTimeOut(speakText: String?) { + mAudioManager.abandonAudioFocusRequest(mAudioFocusRequest) + } + }) + } + + private val mMapLocationListener: IMoGoChassisLocationGCJ02Listener = + object : IMoGoChassisLocationGCJ02Listener{ + override fun onChassisLocationGCJ02(mogoLocation: MogoLocation?) { + if (null == mogoLocation) return + mLocation = mogoLocation + updateSpeed(mogoLocation) + } + } + + private val moGoAutopilotPlanningListener = object : IMoGoPlanningRottingListener{ + 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) + updateRoutePoints(it.wayPointsList) + } + } + + } + + fun updateRoutePoints(routePoints: List?) { + mRoutePoints.clear() + val latLngModels = CoordinateCalculateRouteUtil + .coordinateConverterWgsToGcjLocations(mContext, routePoints) + d(SceneConstant.M_BUS_P + TAG, "och-rotting==latLngModels = " + latLngModels.size) + mRoutePoints.addAll(latLngModels) + calculateTwoStationsRoute() + } + + private fun updateSpeed(mogoLocation: MogoLocation) { + // km/h + val speedKM = (abs(mogoLocation.gnssSpeed) * 3.6f).toInt() + + mDrivingInfoCallback?.updateSpeed(speedKM) + } + + private val mAutoPilotStatusListener: IMoGoAutopilotStatusListener = + object : IMoGoAutopilotStatusListener { + + override fun onAutopilotArriveAtStation(arrivalNotification: MessagePad.ArrivalNotification?) { + super.onAutopilotArriveAtStation(arrivalNotification) + } + + override fun onAutopilotStatusResponse(autoPilotStatusInfo: AutopilotStatusInfo) { + super.onAutopilotStatusResponse(autoPilotStatusInfo) + val status = autoPilotStatusInfo.state + if (mCurrentAutoStatus == status) return + d(SceneConstant.M_BUS_P+TAG, "onAutopilotStatusResponse ===== $status") + if (IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING != status){ + //美化模式下且行程中 + if (FunctionBuildConfig.isDemoMode && + mNextStationIndex>= 0 && mNextStationIndex <= mStations.size - 1 + && isGoingToNextStation){ + mAutoStatusCallback?.updateAutoStatus(true) + }else{//非美化模式下 + mAutoStatusCallback?.updateAutoStatus(false) + } + + }else{//自驾状态 2 + mAutoStatusCallback?.updateAutoStatus(true) + } + mCurrentAutoStatus = status + } + + } + + private fun queryDriverOperationDelay() { + handler.sendEmptyMessageDelayed(MSG_QUERY_BUS_P_STATION, + BusPassengerConst.QUERY_BUS_P_STATION_DELAY + ) + } + + private fun queryDriverOperationStatus() { + mContext?.let { + PM2ServiceManager.queryDriverOperationStatus( + it, + object : OchCommonServiceCallback { + override fun onSuccess(data: PM2OperationStatusResponse?) { + if (data?.data == null) return + if (data.data.driverStatus != operationStatus?.driverStatus + || data.data.plateNumber != operationStatus?.plateNumber){ + d(SceneConstant.M_BUS_P+TAG, "queryDriverOperationStatus ===== 车牌或者登陆状态有变更") + mDrivingInfoCallback?.changeOperationStatus(data.data.driverStatus == 1) + } + operationStatus = data.data as PM2OperationStatusResponse.Result +// mDrivingInfoCallback?.updatePlateNumber(data.data.plateNumber) + } + + override fun onError() { + if (!NetworkUtils.isConnected(mContext)) { + ToastUtils.showShort(mContext!!.getString(R.string.network_error_tip)) + } else { + ToastUtils.showShort(mContext!!.getString(R.string.request_error_tip)) + } + queryDriverOperationDelay() + } + + override fun onFail(code: Int, msg: String) { + //延迟3s再次查询 + queryDriverOperationDelay() + } + }) + } + } + + fun queryDriverSiteByCoordinate(){ + mContext?.let { + PM2ServiceManager.queryDriverSiteByCoordinate(it, + object : OchCommonServiceCallback{ + override fun onSuccess(data: PM2RoutesResponse?) { + + if (data == null || data.result == null){ + if (routesResult != null) { + routesResult == null + updateLocalOrder() + d(SceneConstant.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") + return + } + + routesResult = data.result + updatePassengerRouteInfo(data.result) + } + + override fun onFail(code: Int, msg: String?) { + d(SceneConstant.M_BUS_P+TAG, "queryDriverSiteByCoordinate = %s", msg) + if (code == 1003){ + queryDriverOperationDelay() + } + if (PM2ServiceManager.driverAppSn.isEmpty()){ + return + } + if (code == 1003) { + routesResult = null + isGoingToNextStation = false + startOrStopCalculateRouteInfo(false) + return + } + } + + }) + } + } + + private fun updateLocalOrder(){ + routesResult = null + mNextStationIndex = 0 + isGoingToNextStation = false + startOrStopCalculateRouteInfo(false) + mDrivingInfoCallback?.showNoTaskView(true) + } + + private fun updatePassengerRouteInfo(result: PM2RoutesResult) { + mDrivingInfoCallback?.updateLine(result.name, result.runningDur) + if (result.sites != null) { + mDrivingInfoCallback?.showNoTaskView(false) + val stations: List = result.sites + mStations.clear() + mStations.addAll(stations) + mDrivingInfoCallback?.updateLineStations(mStations) + for (i in stations.indices) { + val station: PM2Station = stations[i] + if (station.drivingStatus == BusPassengerConst.STATION_STATUS_STOPPED + && station.isLeaving && i + 1 < stations.size) { + mDrivingInfoCallback?.updateStationsInfo(stations as MutableList, i + 1, false) + 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) { + mPreRouteIndex = 0 + isGoingToNextStation = false + startOrStopCalculateRouteInfo(false) + mDrivingInfoCallback?.updateStationsInfo(stations as MutableList, i, true) + return + } + } + } + + } + + 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(){ + //计算当前位置和下一站的剩余点集合 + //计算剩余点总里程和时间 + + //计算当前位置和下一站的剩余点集合 + //计算剩余点总里程和时间 + 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: PM2Station = 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") + 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: PM2Station = mStations[mNextStationIndex] + val stationCur: PM2Station = 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() + } + } +} \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/model/PM2ServiceManager.kt b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/model/PM2ServiceManager.kt new file mode 100644 index 0000000000..f23b75ea3f --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/model/PM2ServiceManager.kt @@ -0,0 +1,77 @@ +package com.mogo.och.bus.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.eagle.core.network.MoGoRetrofitFactory +import com.mogo.och.bus.passenger.bean.PM2OperationStatusResponse +import com.mogo.och.bus.passenger.bean.PM2QueryLineRequest +import com.mogo.och.bus.passenger.bean.PM2RoutesResponse +import com.mogo.och.bus.passenger.network.PM2ServiceApi +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 mBusPassengerServiceApi = + MoGoRetrofitFactory.getInstance(OchCommonConst.getShuttleUrl()).create(PM2ServiceApi::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? + ) { + mBusPassengerServiceApi.queryDriverSiteByCoordinate( + MoGoAiCloudClientConfig.getInstance().serviceAppId, + MoGoAiCloudClientConfig.getInstance().token, + PM2QueryLineRequest( + driverAppSn + ) + ).transformTry() + .subscribe(OchCommonSubscribeImpl(context, callback, "queryDriverSiteByCoordinate=sn =$driverAppSn")) + + } + + /** + * 查询司机端出车收车状态,以及车牌号 + * @param context + * @param callback + */ + @JvmStatic + fun queryDriverOperationStatus( + context: Context, + callback: OchCommonServiceCallback? + ) { + mBusPassengerServiceApi.queryDriverOperationStatus( + MoGoAiCloudClientConfig.getInstance().serviceAppId, + MoGoAiCloudClientConfig.getInstance().token, + driverAppSn + ) + .transformTry() + .subscribe(OchCommonSubscribeImpl(context, callback, "queryDriverOperationStatus=sn =$driverAppSn")) + + } +} \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/network/PM2ModelLoopManager.kt b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/network/PM2ModelLoopManager.kt new file mode 100644 index 0000000000..b430a966a1 --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/network/PM2ModelLoopManager.kt @@ -0,0 +1,127 @@ +package com.mogo.och.bus.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.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 { + return Observable.create(ObservableOnSubscribe { emitter -> + if (emitter.isDisposed) return@ObservableOnSubscribe + PM2DrivingModel.INSTANCE.loopRouteAndWipe() + emitter.onComplete() + }) + } + + private fun startLoopCalculateRouteInfo(): Observable { + return Observable.create(ObservableOnSubscribe { emitter -> + if (emitter.isDisposed) return@ObservableOnSubscribe + PM2DrivingModel.INSTANCE.dynamicCalculateRouteInfo() + emitter.onComplete() + }) + } +} \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/network/PM2ServiceApi.java b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/network/PM2ServiceApi.java new file mode 100644 index 0000000000..9a0f63e23e --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/network/PM2ServiceApi.java @@ -0,0 +1,40 @@ +package com.mogo.och.bus.passenger.network; + +import com.mogo.och.bus.passenger.bean.PM2OperationStatusResponse; +import com.mogo.och.bus.passenger.bean.PM2QueryLineRequest; +import com.mogo.och.bus.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 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 queryDriverOperationStatus(@Header ("appId") String appId, @Header("ticket") String ticket, @Query("sn") String sn); + + +} diff --git a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/presenter/PM2ADASPresenter.kt b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/presenter/PM2ADASPresenter.kt new file mode 100644 index 0000000000..de47518d3b --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/presenter/PM2ADASPresenter.kt @@ -0,0 +1,41 @@ +package com.mogo.och.bus.passenger.presenter + +import androidx.lifecycle.LifecycleOwner +import com.mogo.commons.mvp.Presenter +import com.mogo.och.bus.passenger.callback.ADASCallback +import com.mogo.och.bus.passenger.constant.M2Const.Companion.M2_MAP_STATION_MAKER +import com.mogo.och.bus.passenger.model.PM2ADASModel +import com.mogo.och.bus.passenger.ui.PM2HPMapFragment + +class PM2ADASPresenter(view: PM2HPMapFragment?) : + Presenter(view), ADASCallback { + + init { + PM2ADASModel.INSTANCE.init(context) + initListener() + } + + private fun initListener() { + PM2ADASModel.INSTANCE.setAdasCallback(this) + } + + private fun removeListener() { + PM2ADASModel.INSTANCE.setAdasCallback(null) + } + + override fun onDestroy(owner: LifecycleOwner) { + super.onDestroy(owner) + removeListener() + } + + override fun updateHDMapStations(stations: MutableList>) { + for (i in stations.indices){ + mView?.setMapMaker(M2_MAP_STATION_MAKER,stations[i]) + } + + } + + override fun removeHDMapStations() { + mView?.removeMapMaker(M2_MAP_STATION_MAKER) + } +} \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/presenter/PM2DrivingPresenter.kt b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/presenter/PM2DrivingPresenter.kt new file mode 100644 index 0000000000..b1cba39ddd --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/presenter/PM2DrivingPresenter.kt @@ -0,0 +1,105 @@ +package com.mogo.och.bus.passenger.presenter + +import androidx.lifecycle.LifecycleOwner +import com.mogo.commons.mvp.Presenter +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger +import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant +import com.mogo.eagle.core.utilcode.util.ThreadUtils +import com.mogo.och.bus.passenger.bean.PM2Station +import com.mogo.och.bus.passenger.callback.AutoPilotStatusCallback +import com.mogo.och.bus.passenger.callback.DrivingInfoCallback +import com.mogo.och.bus.passenger.model.PM2ADASModel +import com.mogo.och.bus.passenger.model.PM2DrivingModel +import com.mogo.och.bus.passenger.ui.PM2DrivingInfoFragment + +class PM2DrivingPresenter(view: PM2DrivingInfoFragment?) : + Presenter(view), DrivingInfoCallback, AutoPilotStatusCallback { + + init { + PM2DrivingModel.INSTANCE.init(context) + PM2ADASModel.INSTANCE.init(context) + initListener() + } + + override fun onDestroy(owner: LifecycleOwner) { + super.onDestroy(owner) + destroyListener() + PM2DrivingModel.INSTANCE.releaseListener() + } + + private fun initListener(){ + PM2DrivingModel.INSTANCE.setDrivingInfoCallback(this) + PM2DrivingModel.INSTANCE.setAutoStatusCallback(this) + } + + private fun destroyListener(){ + PM2DrivingModel.INSTANCE.setDrivingInfoCallback(null) + PM2DrivingModel.INSTANCE.setAutoStatusCallback(null) + } + + override fun updateSpeed(speed: Int) { +// CallerLogger.d( +// SceneConstant.M_BUS_P + "speed = ",speed.toString() +// ) + ThreadUtils.runOnUiThread { + mView?.updateSpeed(speed) + } + } + + override fun updatePlateNumber(carNum: String) { + ThreadUtils.runOnUiThread { + mView?.updateCarPlateNum(carNum) + } + } + + override fun updateLine(lineName: String, lineDuring: String) { + ThreadUtils.runOnUiThread { + mView?.updateTaskName(lineName) + mView?.updateTaskDuringTime(lineDuring) + } + } + + override fun updateRemainMT(meters: Long, timeInSecond: Long) { + ThreadUtils.runOnUiThread { + mView?.updateRemainMT(meters, timeInSecond) //米,秒 + } + } + + override fun changeOperationStatus(loginStatus: Boolean) { + ThreadUtils.runOnUiThread { + mView?.changeOperationStatus(loginStatus) + } + } + + override fun showNoTaskView(isTrue: Boolean) { + ThreadUtils.runOnUiThread { + mView?.showNoTaskView(!isTrue) + } + if (isTrue){ + PM2ADASModel.INSTANCE.removeHDMapStations() + } + } + + override fun updateLineStations(stations: MutableList) { + ThreadUtils.runOnUiThread { + mView?.updateLineStations(stations) + } + PM2ADASModel.INSTANCE.updateHDMapStations(stations) + } + + override fun updateStationsInfo(stations: MutableList, i: Int, isArrived: Boolean) { + ThreadUtils.runOnUiThread { + mView?.updateStationsInfo(stations,i,isArrived) + } + } + + override fun updateAutoStatus(isOpen: Boolean) { + ThreadUtils.runOnUiThread { + mView?.updateAutoStatus(isOpen) + } + } + + override fun updateAutoStatus(status: Int) { + + } +} \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/presenter/PM2Presenter.kt b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/presenter/PM2Presenter.kt new file mode 100644 index 0000000000..e55cc469d1 --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/presenter/PM2Presenter.kt @@ -0,0 +1,7 @@ +package com.mogo.och.bus.passenger.presenter + +import com.mogo.commons.mvp.Presenter +import com.mogo.och.bus.passenger.ui.PM2BaseFragment + +class PM2Presenter(view: PM2BaseFragment?) : + Presenter(view) \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/presenter/PM2VideoPresenter.kt b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/presenter/PM2VideoPresenter.kt new file mode 100644 index 0000000000..b62879bf4b --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/presenter/PM2VideoPresenter.kt @@ -0,0 +1,7 @@ +package com.mogo.och.bus.passenger.presenter + +import com.mogo.commons.mvp.Presenter +import com.mogo.och.bus.passenger.ui.video.PM2VideoFragment + +class PM2VideoPresenter(view: PM2VideoFragment?) : + Presenter(view) \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/provider/M2StatusViewManager.java b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/provider/M2StatusViewManager.java new file mode 100644 index 0000000000..8966090d91 --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/provider/M2StatusViewManager.java @@ -0,0 +1,33 @@ +package com.mogo.och.bus.passenger.provider; + +import android.content.Context; +import android.view.View; + +import com.mogo.och.bus.passenger.ui.widget.M2StatusBarView; +import androidx.annotation.NonNull; + +import com.alibaba.android.arouter.facade.annotation.Route; +import com.mogo.eagle.core.data.constants.MogoServicePaths; +import com.mogo.eagle.core.function.api.hmi.view.IStatusViewLayout; + +/** + * @author congtaowang + * @since 2020-01-06 + *

+ * 根据优先级控制显示 window view. + */ +@Route( path = MogoServicePaths.PATH_STATUS_VIEW_MANAGER ) +public class M2StatusViewManager implements IStatusViewLayout { + + + @NonNull + @Override + public View getStatusView(Context context) { + return new M2StatusBarView(context); + } + + @Override + public void init(Context context) { + + } +} diff --git a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/PM2BaseFragment.kt b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/PM2BaseFragment.kt new file mode 100644 index 0000000000..a90221bd15 --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/PM2BaseFragment.kt @@ -0,0 +1,72 @@ +package com.mogo.och.bus.passenger.ui + +import android.provider.Settings +import android.view.Surface +import com.mogo.commons.mvp.MvpFragment +import com.mogo.och.bus.passenger.R +import com.mogo.och.bus.passenger.presenter.PM2Presenter +import com.mogo.och.bus.passenger.ui.video.PM2VideoFragment + +/** + * @author: wangmingjun + * @date: 2022/4/12 + */ +class PM2BaseFragment : + MvpFragment() { + + private var drivingFragment : PM2DrivingInfoFragment? = null + private var hdMapFragment : PM2HPMapFragment? = null + private var videoFragment : PM2VideoFragment? = null + + override fun getLayoutId(): Int { + return R.layout.p_m2_fragment + } + + override fun getTagName(): String { + return TAG + } + + override fun initViews() { + //横竖屏 +// setScreenDirection() + + //隐藏小地图 + initFragment() + } + +// private fun setScreenDirection() { +// var ro = Settings.System.getInt(context?.contentResolver, +// Settings.System.USER_ROTATION,Surface.ROTATION_270) +// if (ro != Surface.ROTATION_270){ +// ro = Surface.ROTATION_270 +// } +// Settings.System.putInt(context?.contentResolver, +// Settings.System.USER_ROTATION,ro) +// } + + /** + * 初始化行程信息,高静地图,宣传 三个fragment + */ + private fun initFragment() { + + if (drivingFragment == null) drivingFragment = PM2DrivingInfoFragment() + childFragmentManager.beginTransaction().add(R.id.driving_fragment, drivingFragment!!) + .show(drivingFragment!!).commitAllowingStateLoss() + + if (hdMapFragment == null) hdMapFragment = PM2HPMapFragment() + childFragmentManager.beginTransaction().add(R.id.hd_map_fragment, hdMapFragment!!) + .show(hdMapFragment!!).commitAllowingStateLoss() + + if (videoFragment == null) videoFragment = PM2VideoFragment() + childFragmentManager.beginTransaction().add(R.id.video_fragment, videoFragment!!) + .show(videoFragment!!).commitAllowingStateLoss() + } + + override fun createPresenter(): PM2Presenter { + return PM2Presenter(this) + } + + companion object { + private val TAG = PM2BaseFragment::class.java.simpleName + } +} \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/PM2DrivingInfoFragment.kt b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/PM2DrivingInfoFragment.kt new file mode 100644 index 0000000000..a9abc4ee54 --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/PM2DrivingInfoFragment.kt @@ -0,0 +1,253 @@ +package com.mogo.och.bus.passenger.ui + +import android.graphics.BitmapFactory +import android.os.Bundle +import android.os.Handler +import android.os.Looper +import android.os.Message +import android.view.View +import androidx.core.content.ContextCompat +import com.amap.api.maps.model.LatLng +import com.mogo.commons.mvp.MvpFragment +import com.mogo.eagle.core.function.hmi.ui.setting.ToggleDebugView +import com.mogo.eagle.core.utilcode.kotlin.onClick +import com.mogo.eagle.core.utilcode.util.DateTimeUtils +import com.mogo.eagle.core.utilcode.util.UiThreadHandler +import com.mogo.och.bus.passenger.R +import com.mogo.och.bus.passenger.bean.PM2Station +import com.mogo.och.bus.passenger.presenter.PM2DrivingPresenter +import com.mogo.och.common.module.utils.DateTimeUtil.* +import com.mogo.och.common.module.utils.NumberFormatUtil +import kotlinx.android.synthetic.m2.p_m2_driving_info_fragment.* +import java.lang.ref.WeakReference +import kotlin.math.ceil +import kotlin.math.roundToInt + +/** + * @author: wangmingjun + * @date: 2022/4/12 + */ +class PM2DrivingInfoFragment : + MvpFragment() { + +// private var timeHandler: TimeHandler? = null + + /** + * 改变自动驾驶状态 + * + * @param status 2 - running 1 - enable 2 - disable + */ + override fun getLayoutId(): Int { + return R.layout.p_m2_driving_info_fragment + } + + override fun getTagName(): String { + return TAG + } + + override fun initViews() { + speed_tv.setOnLongClickListener { + context?.let { ToggleDebugView.toggleDebugView.toggle(it) } + true + } + + line_name_tv.setTextColor(resources.getColor(R.color.m2_line_name_tv_color)) + station_name_tv.setTextColor(resources.getColor(R.color.m2_line_name_tv_color)) + +// current_time_tv.onClick { + +// //测试V2X消息 +// CallerMsgBoxManager.saveMsgBox( +// MsgBoxBean( +// MsgBoxType.V2X, +// V2XMsg( +// "6666", +// "超速行驶", +// "" +// ) +// ) +// ) +// +// val noticeTrafficStylePushData = NoticeTrafficStylePushData() +// noticeTrafficStylePushData.content= "测试公告布局" +// val noticeFromCloudMsg = NoticeFrCloudMsg(null, noticeTrafficStylePushData, 1) +// CallerMsgBoxManager.saveMsgBox( +// MsgBoxBean( +// MsgBoxType.NOTICE, noticeFromCloudMsg) +// ) +// BPRouteDataTestUtils.converToRouteData() +// } + updateCurrentTime() + } + + override fun initViews(savedInstanceState: Bundle?) { + super.initViews(savedInstanceState) + overMapView?.let { + it.onCreateView(savedInstanceState) + } + } + + override fun onResume() { + super.onResume() + overMapView?.let{ + it.onResume() + } + } + + override fun onPause() { + super.onPause() + overMapView?.let{ + it.onPause() + } + } + + override fun onDestroy() { +// timeHandler?.removeCallbacksAndMessages(null) + super.onDestroy() + overMapView?.let{ + it.onDestroy() + } + } + + fun updateSpeed(speed: Int){ + speed_tv.text = speed.toString() + } + + fun updateCarPlateNum(plateNum : String){ + + } + + fun updateTaskName(name: String){ + line_name_tv.text = name + } + + fun updateTaskDuringTime(time : String){ + line_during_tv.text = time + } + + private fun updateCurrentTime(){ + current_time_tv.text = formatCalendarToString( + DateTimeUtils.getCurrentDateTime(),HH_mm) + + val date = formatCalendarToString( + DateTimeUtils.getCurrentDateTime(), yy_MM_dd) + val weekDay = DateTimeUtils.getWeekDayFromCalendar1(DateTimeUtils.getCurrentDateTime()) + "$date $weekDay".also { current_weekday_tv.text = it } + + sendUpdateTimeTask() // 每10s更新一次 + } + + fun changeOperationStatus(status:Boolean){ + if (!status){ + updateNoOrderUI() + } + } + + fun showNoTaskView(haveTask: Boolean){ + setLineInfoView(haveTask) + } + + private fun setLineInfoView(isShow: Boolean){ + if (isShow){ + line_name_tv.visibility = View.VISIBLE + line_during_tv.visibility = View.VISIBLE + no_line_tv.visibility = View.GONE + }else{ + updateNoOrderUI() + } + } + + private fun updateNoOrderUI() { + line_name_tv.visibility = View.GONE + line_during_tv.visibility = View.GONE + no_line_tv.visibility = View.VISIBLE + updateNoStationView() + overMapView?.let { + it.clearSiteMarkers() + } + overMapView?.let { + it.clearCustomPolyline() + } + } + + private fun updateNoStationView(){ + station_name_tv.setTextColor(resources.getColor(R.color.m2_next_tv_color)) + station_name_title_tv.text = resources.getString(R.string.m2_p_station_title_tv) + station_name_tv.text = resources.getString(R.string.m2_p_empty_tv) + remain_mt.text = resources.getString(R.string.m2_p_empty_remain_km_minute) + } + + override fun createPresenter(): PM2DrivingPresenter { + return PM2DrivingPresenter(this) + } + + fun updateAutoStatus(isAutoPilot: Boolean) { + if (isAutoPilot){ + context?.let { auto_tv.setTextColor(ContextCompat.getColor(it,R.color.m2_p_white_color)) } + context?.let { auto_tv.background = ContextCompat.getDrawable(it,R.drawable.auto_button_bg) } + }else{ + context?.let { auto_tv.setTextColor(ContextCompat.getColor(it,R.color.m2_button_auto_tv_color)) } + context?.let { auto_tv.background = ContextCompat.getDrawable(it,R.drawable.bg_p_m2_auto) } + } + } + + fun updateLineStations(stations: MutableList){ + var stationsList = mutableListOf() + for (i in stations.indices){ + val station = stations[i] + var latLng = LatLng(station.gcjLat,station.gcjLon) + stationsList.add(latLng) + } + overMapView?.let { + it.drawSiteMarkers(stationsList, + BitmapFactory.decodeResource(resources,R.drawable.m2_map_staton_icon),0.5f,0.9f) + } + } + + fun updateStationsInfo(stations: MutableList, i: Int, isArrived: Boolean){ + if (stations.size == 0) return + if (0<= i && i 0) { + if (meters / 1000 < 1) { + disUnit = "米" + remainDis = meters.toFloat().roundToInt().toString() + } else { + disUnit = "公里" + remainDis = NumberFormatUtil.formatLong(meters.toDouble() / 1000) + } + } + + val time = ceil(timeInSecond / 60f).toInt() + + "$remainDis$disUnit | $time 分钟".also { remain_mt.text = it } + } + + private fun sendUpdateTimeTask() { + UiThreadHandler.postDelayed({ + updateCurrentTime() + },LOOP_TIME_TEXT) + } + + companion object { + private val TAG = PM2DrivingInfoFragment::class.java.simpleName + const val LOOP_TIME_TEXT = 10 * 1000L + } +} \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/PM2HPMapFragment.kt b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/PM2HPMapFragment.kt new file mode 100644 index 0000000000..05b1101cfd --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/PM2HPMapFragment.kt @@ -0,0 +1,122 @@ +package com.mogo.och.bus.passenger.ui + +import android.os.Bundle +import com.mogo.commons.AbsMogoApplication +import com.mogo.commons.mvp.MvpFragment +import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager.getMapUIController +import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager.getMarkerManager +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d +import com.mogo.map.marker.MogoMarkerOptions +import com.mogo.och.bus.passenger.R +import com.mogo.och.bus.passenger.constant.M2Const.Companion.TYPE_MARKER_M2_LINE +import com.mogo.och.bus.passenger.presenter.PM2ADASPresenter +import com.mogo.och.common.module.utils.OCHThreadPoolManager +import kotlinx.android.synthetic.m2.p_m2_hpmap_fragment.* +import java.util.* + +/** + * @author: wangmingjun + * @date: 2022/4/12 + */ +class PM2HPMapFragment : + MvpFragment() { + /** + * 改变自动驾驶状态 + * + * @param status 2 - running 1 - enable 2 - disable + */ + override fun getLayoutId(): Int { + return R.layout.p_m2_hpmap_fragment + } + + override fun getTagName(): String { + return TAG + } + + override fun initViews() { + } + + override fun initViews(savedInstanceState: Bundle?) { + super.initViews(savedInstanceState) + mapBizView.onCreate(savedInstanceState) + } + + override fun onResume() { + super.onResume() + mapBizView.onResume() + } + + override fun onLowMemory() { + super.onLowMemory() + mapBizView.onLowMemory() + } + + override fun onSaveInstanceState(outState: Bundle) { + super.onSaveInstanceState(outState) + mapBizView.onSaveInstanceState(outState) + } + + override fun onPause() { + super.onPause() + mapBizView.onPause() + } + + override fun onDestroyView() { + mapBizView.onDestroy() + super.onDestroyView() + } + + override fun createPresenter(): PM2ADASPresenter { + return PM2ADASPresenter(this) + } + + companion object { + private val TAG = PM2HPMapFragment::class.java.simpleName + } + + fun setMapMaker( + uuid: String, + station: MutableList, + ) { + //开启线程执行起终点marker设置 + val setMapMarkerRunnable = Runnable { + d("setMapMaker= " + Thread.currentThread().name, + uuid + "=latitude=" + station[1] + ",longitude=" + station[0]) + val options = MogoMarkerOptions() + .owner(TYPE_MARKER_M2_LINE) + .anchor(0.5f, 0.5f) + .set3DMode(true) + .gps(true) + .controlAngle(true) + .icon3DRes(R.raw.star_marker) + .longitude(station[0]) + .latitude(station[1]) + val marker = Objects.requireNonNull( + getMarkerManager(AbsMogoApplication.getApp()) + )?.addMarker(uuid, options) + val centerLine = + getMapUIController()!! + .getCenterLineInfo( + station[0], station[1], -1f + ) + if (null != centerLine && marker != null) { // 有可能鹰眼map为空没有角度。判空使用后可能造成maker角度跟道路角度不一致 + marker.setRotateAngle(centerLine.angle!!.toFloat()) + } + } + OCHThreadPoolManager.getsInstance().execute(setMapMarkerRunnable) + } + + fun removeMapMaker( + uuid: String, + ) { + //开启线程移除起终点marker设置 + val removeMapMarkerRunnable = Runnable { + d("RemoveMapMaker=" + Thread.currentThread().name, uuid) + Objects.requireNonNull( + getMarkerManager(AbsMogoApplication.getApp()) + )?.removeMarkers(uuid) + } + OCHThreadPoolManager.getsInstance().execute(removeMapMarkerRunnable) + } + +} \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/video/PM2VideoFragment.kt b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/video/PM2VideoFragment.kt new file mode 100644 index 0000000000..6eee9039d4 --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/video/PM2VideoFragment.kt @@ -0,0 +1,234 @@ +package com.mogo.och.bus.passenger.ui.video + +import com.mogo.commons.mvp.MvpFragment +import com.mogo.och.bus.passenger.R +import com.mogo.och.bus.passenger.presenter.PM2VideoPresenter +import com.mogo.och.bus.passenger.ui.widget.video.RotationItem +import kotlinx.android.synthetic.m2.p_m2_video_fragment.* + +/** + * @author: wangmingjun + * @date: 2022/4/12 + */ +class PM2VideoFragment : + MvpFragment() { + + private var arrayListOf = mutableListOf() + + override fun getLayoutId(): Int { + return R.layout.p_m2_video_fragment + } + + + override fun createPresenter(): PM2VideoPresenter { + return PM2VideoPresenter(this) + } + + companion object { + private val TAG = PM2VideoFragment::class.java.simpleName + } + + override fun getTagName(): String { + return TAG + } + + override fun initViews() { + initResourceData() + imageVideoRotationView.setData(arrayListOf) + } + + override fun onPause() { + super.onPause() + imageVideoRotationView.setPause() + } + + override fun onResume() { + super.onResume() + imageVideoRotationView.setResume() + } + + private fun initResourceData() { + arrayListOf.clear() + arrayListOf.add( + RotationItem( + "https://img.zhidaohulian.com/fileServer/online_car_hailing/1678946244305/dalim2.mp4", + 1, + "", + "1" + ) + ) +// if (BuildConfig.FLAVOR.contains("dali")){ //大理 目前还都使用的mogo 的cos https://img.zhidaohulian.com/fileServer/online_car_hailing/1678932482045/1080%2A565%20.mp4 +// arrayListOf.add( +// RotationItem( +// "https://img.zhidaohulian.com/fileServer/online_car_hailing/1678932482045/1080%2A565%20.mp4", +// 1, +// "", +// "1" +// ) +// ) +// }else if (BuildConfig.FLAVOR.contains("yantai")){ //烟台 +// arrayListOf.add( +// RotationItem( +// "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357256102/1.jpg", +// 0, +// "", +// "1" +// ) +// ) +// arrayListOf.add( +// RotationItem( +// "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357382357/2.png", +// 0, +// "", +// "2" +// ) +// ) +// arrayListOf.add( +// RotationItem( +// "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357557335/3.mp4", +// 1, +// "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357382357/2.png", +// "3" +// ) +// ) +// arrayListOf.add( +// RotationItem( +// "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357598483/4.jpg", +// 0, +// "", +// "4" +// ) +// ) +// arrayListOf.add( +// RotationItem( +// "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357834634/5.m4v", +// 1, +// "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357598483/4.jpg", +// "5" +// ) +// ) +// arrayListOf.add( +// RotationItem( +// "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676358660379/6.m4v", +// 1, +// "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357598483/4.jpg", +// "6" +// ) +// ) +// arrayListOf.add( +// RotationItem( +// "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360154589/7.jpg", +// 0, +// "", +// "7" +// ) +// ) +// arrayListOf.add( +// RotationItem( +// "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360185500/8.jpg", +// 0, +// "", +// "8" +// ) +// ) +// arrayListOf.add( +// RotationItem( +// "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360224773/9.png", +// 0, +// "", +// "9" +// ) +// ) +// arrayListOf.add( +// RotationItem( +// "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360274126/10.mp4", +// 1, +// "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360224773/9.png", +// "10" +// ) +// ) +// }else{ // mogo +// arrayListOf.add( +// RotationItem( +// "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357256102/1.jpg", +// 0, +// "", +// "1" +// ) +// ) +// arrayListOf.add( +// RotationItem( +// "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357382357/2.png", +// 0, +// "", +// "2" +// ) +// ) +// arrayListOf.add( +// RotationItem( +// "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357557335/3.mp4", +// 1, +// "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357382357/2.png", +// "3" +// ) +// ) +// arrayListOf.add( +// RotationItem( +// "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357598483/4.jpg", +// 0, +// "", +// "4" +// ) +// ) +// arrayListOf.add( +// RotationItem( +// "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357834634/5.m4v", +// 1, +// "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357598483/4.jpg", +// "5" +// ) +// ) +// arrayListOf.add( +// RotationItem( +// "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676358660379/6.m4v", +// 1, +// "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357598483/4.jpg", +// "6" +// ) +// ) +// arrayListOf.add( +// RotationItem( +// "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360154589/7.jpg", +// 0, +// "", +// "7" +// ) +// ) +// arrayListOf.add( +// RotationItem( +// "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360185500/8.jpg", +// 0, +// "", +// "8" +// ) +// ) +// arrayListOf.add( +// RotationItem( +// "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360224773/9.png", +// 0, +// "", +// "9" +// ) +// ) +// arrayListOf.add( +// RotationItem( +// "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360274126/10.mp4", +// 1, +// "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360224773/9.png", +// "10" +// ) +// ) +// } +// + } +} \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/M2BlueToothView.kt b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/M2BlueToothView.kt new file mode 100644 index 0000000000..f11882f70d --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/M2BlueToothView.kt @@ -0,0 +1,37 @@ +package com.mogo.och.bus.passenger.ui.widget + +import android.content.Context +import android.util.AttributeSet +import android.view.LayoutInflater +import com.mogo.eagle.core.function.api.devatools.IMoGoDevaToolsListener +import com.mogo.eagle.core.function.hmi.ui.widget.BlueToothView +import com.mogo.eagle.core.utilcode.util.ThreadUtils +import com.mogo.och.bus.passenger.R +import kotlinx.android.synthetic.m2.p_m2_view_blue_tooth.view.* + +/** + * 魔戒蓝牙控件 + * 放置于StatusBar右侧位置 + * todo arrow + */ +class M2BlueToothView @JvmOverloads constructor( + context: Context, + attrs: AttributeSet? = null, + defStyleAttr: Int = 0 +) : BlueToothView(context, attrs, defStyleAttr),IMoGoDevaToolsListener { + + init { + LayoutInflater.from(context).inflate(R.layout.p_m2_view_blue_tooth, this, true) + } + + override fun mofangStatus(status: Boolean) { + ThreadUtils.runOnUiThread { + if (status) { + blueView.setImageResource(R.drawable.m2_blue_tooth_close) + } else { + blueView.setImageResource(R.drawable.m2_blue_tooth_open) + } + } + } + +} \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/M2PTrafficLightView.kt b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/M2PTrafficLightView.kt new file mode 100644 index 0000000000..8560ce030b --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/M2PTrafficLightView.kt @@ -0,0 +1,179 @@ +package com.mogo.och.bus.passenger.ui.widget + +import android.content.Context +import android.util.AttributeSet +import android.view.LayoutInflater +import android.widget.LinearLayout +import com.mogo.eagle.core.data.enums.DataSourceType +import com.mogo.eagle.core.data.enums.TrafficLightEnum +import com.mogo.eagle.core.function.api.datacenter.union.IMoGoTrafficLightListener +import com.mogo.eagle.core.function.call.v2x.CallerTrafficLightListenerManager +import com.mogo.eagle.core.utilcode.util.UiThreadHandler +import com.mogo.och.bus.passenger.R +import kotlinx.android.synthetic.m2.m2_p_traffic_light_view.view.* + +/** + * bus乘客端:红绿灯view + * + * Created on 2022/3/14 + */ +class M2PTrafficLightView @JvmOverloads constructor( + context: Context?, + attrs: AttributeSet? = null, + defStyleAttr: Int = 0 +) : LinearLayout(context, attrs, defStyleAttr), IMoGoTrafficLightListener { + + companion object { + private const val TAG = "M2PTrafficLightView" + } + + private var mCurrentLightId = TrafficLightEnum.BLACK + + init { + init(context) + } + + private fun init(context: Context?) { + LayoutInflater.from(context).inflate(R.layout.m2_p_traffic_light_view, this, true) + } + + override fun onAttachedToWindow() { + super.onAttachedToWindow() + CallerTrafficLightListenerManager.addListener(TAG, this) + } + + override fun onDetachedFromWindow() { + super.onDetachedFromWindow() + CallerTrafficLightListenerManager.removeListener(TAG) + } + + /** + * 展示红绿灯预警 + * + * @param checkLightId 0-都是默认,1-红,2-黄,3-绿 + * @param lightSource 1:云端下发;2:自车感知 + */ + override fun showTrafficLight(checkLightId: TrafficLightEnum, lightSource: DataSourceType) { + super.showTrafficLight(checkLightId, lightSource) + mCurrentLightId = checkLightId + updateTrafficLightIcon(checkLightId) + } + + /** + * 关闭红绿灯预警展示,并重制灯态 + */ + override fun disableTrafficLight() { + super.disableTrafficLight() + UiThreadHandler.post { + mCurrentLightId = TrafficLightEnum.BLACK + this@M2PTrafficLightView.visibility = GONE + } + } + + /** + * @param redNum 红灯倒计时 + * @param yellowNum 黄灯倒计时 + * @param greenNum 绿灯倒计时 + */ + override fun changeCountdownTrafficLightNum(redNum: Int, yellowNum: Int, greenNum: Int) { + super.changeCountdownTrafficLightNum(redNum, yellowNum, greenNum) + resetView() + when (mCurrentLightId) { + TrafficLightEnum.RED -> changeCountdownRed(redNum) + TrafficLightEnum.YELLOW -> changeCountdownYellow(yellowNum) + TrafficLightEnum.GREEN -> changeCountdownGreen(greenNum) + else -> UiThreadHandler.post { m2_p_traffic_light_time_tv.text = "" } + } + } + + override fun changeCountdownRed(redNum: Int) { + super.changeCountdownRed(redNum) + UiThreadHandler.post { + if (redNum > 0) { + resetView() + m2_p_traffic_light_time_tv.text = redNum.toString() + } else { + disableTrafficLightCountDown() + m2_p_traffic_light_time_tv.text = "" + } + } + } + + override fun changeCountdownGreen(greenNum: Int) { + super.changeCountdownGreen(greenNum) + UiThreadHandler.post { + if (greenNum > 0) { + resetView() + m2_p_traffic_light_time_tv.text = greenNum.toString() + } else { + disableTrafficLightCountDown() + m2_p_traffic_light_time_tv.text = "" + } + } + } + + override fun changeCountdownYellow(yellowNum: Int) { + super.changeCountdownYellow(yellowNum) + UiThreadHandler.post { + if (yellowNum > 0) { + resetView() + m2_p_traffic_light_time_tv.text = yellowNum.toString() + } else { + disableTrafficLightCountDown() + m2_p_traffic_light_time_tv.text = "" + } + } + } + + /** + * 更新红绿灯icon + * + * @param lightId 0-都是默认,1-红,2-黄,3-绿 + */ + private fun updateTrafficLightIcon(lightId: TrafficLightEnum) { + UiThreadHandler.post { + when (lightId) { + TrafficLightEnum.RED -> { + m2_p_traffic_light_iv.setBackgroundResource(R.drawable.m2_light_red_nor) + this@M2PTrafficLightView.visibility = VISIBLE + } + TrafficLightEnum.YELLOW -> { + m2_p_traffic_light_iv.setBackgroundResource(R.drawable.m2_light_yellow_nor) + this@M2PTrafficLightView.visibility = VISIBLE + } + TrafficLightEnum.GREEN -> { + m2_p_traffic_light_iv.setBackgroundResource(R.drawable.m2_light_green_nor) + this@M2PTrafficLightView.visibility = VISIBLE + } + else -> this@M2PTrafficLightView.visibility = GONE + } + } + } + + override fun disableTrafficLightCountDown() { + super.disableTrafficLightCountDown() + UiThreadHandler.post { + val layoutParams = layoutParams + if (layoutParams is MarginLayoutParams) { + val lp = layoutParams + lp.width = resources.getDimension(R.dimen.dp_40).toInt() + setLayoutParams(lp) + m2_p_traffic_light_time_tv.visibility = GONE + m2_p_traffic_light_bg.layoutParams.width = + resources.getDimension(R.dimen.dp_40).toInt() + } + } + } + + private fun resetView() { + val layoutParams = layoutParams + if (layoutParams is MarginLayoutParams) { + val lp = layoutParams + lp.width = resources.getDimension(R.dimen.m2_p_light_width).toInt() + setLayoutParams(lp) + m2_p_traffic_light_time_tv.visibility = VISIBLE + m2_p_traffic_light_bg.layoutParams.width = + resources.getDimension(R.dimen.m2_p_light_width).toInt() + } + } +} \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/M2StatusBarView.kt b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/M2StatusBarView.kt new file mode 100644 index 0000000000..932bd2f659 --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/M2StatusBarView.kt @@ -0,0 +1,109 @@ +package com.mogo.och.bus.passenger.ui.widget + +import android.annotation.* +import android.content.Context +import android.graphics.Color +import android.util.AttributeSet +import android.view.LayoutInflater +import android.view.ViewGroup +import androidx.constraintlayout.widget.ConstraintLayout +import chassis.ChassisStatesOuterClass +import com.mogo.eagle.core.function.api.autopilot.IMoGoBatteryManagementSystemListener +import com.mogo.eagle.core.function.api.hmi.view.IViewControlListener +import com.mogo.eagle.core.function.api.setting.IMoGoSkinModeChangeListener +import com.mogo.eagle.core.function.call.autopilot.CallerBatteryManagementSystemListenerManager +import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsManager +import com.mogo.eagle.core.function.call.hmi.CallerHmiViewControlListenerManager +import com.mogo.eagle.core.function.call.setting.CallerSkinModeListenerManager +import com.mogo.eagle.core.utilcode.kotlin.* +import com.mogo.eagle.core.utilcode.util.ClickUtils +import com.mogo.och.bus.passenger.R +import kotlinx.android.synthetic.m2.p_m2_view_status_bar.view.* +import kotlinx.coroutines.* +import me.jessyan.autosize.utils.AutoSizeUtils + +/** + * @author: wangmingjun + * @date: 2023/2/14 + */ +class M2StatusBarView @JvmOverloads constructor( + context: Context, attrs: AttributeSet? = null +) : ConstraintLayout(context, attrs), IViewControlListener, IMoGoSkinModeChangeListener, + IMoGoBatteryManagementSystemListener { + + companion object { + const val TAG = "M2StatusBarView" + } + + @Volatile + private var oldBmsSoc: Float = -1.0f + + init { + LayoutInflater.from(context).inflate(R.layout.p_m2_view_status_bar, this, true) + setBackgroundColor(Color.parseColor("#80FFFFFF")) + isClickable = true + isFocusable = true + } + + + @SuppressLint("ClickableViewAccessibility") + override fun onAttachedToWindow() { + super.onAttachedToWindow() + post { + val params: ViewGroup.LayoutParams = getLayoutParams() + params.height = AutoSizeUtils.dp2px(context,40f) + layoutParams = params + } + //添加view控制 + CallerHmiViewControlListenerManager.addListener(TAG,this) + // 添加换肤监听 + CallerSkinModeListenerManager.addListener(TAG, this) + //电量 + CallerBatteryManagementSystemListenerManager.addListener(TAG,this) + + progress?.also { + it.progress = 50 + } + tv_power_cos?.also { + it.text = "50%" + } + } + + override fun onSkinModeChange(skinMode: Int) { + when (skinMode) { + 0 -> setStatusBarDarkOrLight(false) + 1 -> setStatusBarDarkOrLight(true) + } + } + + override fun onDetachedFromWindow() { + super.onDetachedFromWindow() + CallerHmiViewControlListenerManager.removeListener(TAG) + CallerSkinModeListenerManager.removeListener(TAG) + CallerDevaToolsManager.hideStatusBar() + } + + @SuppressLint("SetTextI18n") + override fun onBatteryManagementSystemStates(states: ChassisStatesOuterClass.BMSSystemStates) { + if (ClickUtils.isClickTooFrequent(this,1000)) { + return + } + val bmsSoc = states.bmsSoc + try { + if (oldBmsSoc != bmsSoc ) { + scope.launch { + if(bmsSoc >1){ + progress?.also { it.progress = bmsSoc.toInt() } + tv_power_cos?.also { it.text = "${bmsSoc.toInt()}%" } + }else{ + val power = (bmsSoc * 100).toInt() + progress?.also { it.progress = power } + tv_power_cos?.also {it.text = "$power%" } + } + } + } + } finally { + oldBmsSoc = bmsSoc + } + } +} \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/M2TurnLightView.kt b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/M2TurnLightView.kt new file mode 100644 index 0000000000..17d5780835 --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/M2TurnLightView.kt @@ -0,0 +1,16 @@ +package com.mogo.och.bus.passenger.ui.widget + +import android.content.Context +import android.util.AttributeSet +import com.mogo.eagle.core.function.hmi.ui.vehicle.TurnLightViewStatus + +/** + * @author: wangmingjun + * @date: 2023/2/13 + */ +class M2TurnLightView @JvmOverloads constructor( + context: Context, attrs: AttributeSet? = null +) : TurnLightViewStatus(context, attrs) { + + +} \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/video/AdvanceGSYVideoPlayer.kt b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/video/AdvanceGSYVideoPlayer.kt new file mode 100644 index 0000000000..d3244e8f7b --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/video/AdvanceGSYVideoPlayer.kt @@ -0,0 +1,127 @@ +package com.mogo.och.bus.passenger.ui.widget.video + +import android.content.Context +import android.media.AudioManager +import android.util.AttributeSet +import com.mogo.eagle.core.utilcode.mogo.logger.Logger +import com.shuyu.gsyvideoplayer.utils.Debuger +import com.shuyu.gsyvideoplayer.utils.GSYVideoType +import com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer + +/** + * @author: wangmingjun + * @date: 2023/2/17 + * 隐藏所有控件的player + */ +class AdvanceGSYVideoPlayer: StandardGSYVideoPlayer { + constructor(context: Context?) : super(context) + constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs) + + init { + hideWidget() + GSYVideoType.setShowType(GSYVideoType.SCREEN_MATCH_FULL) + GSYVideoType.setRenderType(GSYVideoType.GLSURFACE) + } + + override fun hideAllWidget() { + Logger.d(ImageAndVideoRotation.TAG, "hideAllWidget") +// hideWidget() + } + + override fun changeUiToNormal() { + Logger.d(ImageAndVideoRotation.TAG, "changeUiToNormal-hide") + hideWidget() + } + + override fun changeUiToPreparingShow() { + Logger.d(ImageAndVideoRotation.TAG, "changeUiToPreparingShow-hide") + hideWidget() + } + + override fun changeUiToPlayingShow() { + Logger.d(ImageAndVideoRotation.TAG, "changeUiToPlayingShow") + setCacheImageViewGone() + } + + override fun changeUiToPauseShow() { + Logger.d(ImageAndVideoRotation.TAG, "changeUiToPauseShow-hide") + startPlayLogic() +// hideWidget() + } + + override fun changeUiToCompleteShow() { + Logger.d(ImageAndVideoRotation.TAG, "changeUiToCompleteShow") + setCacheImageViewGone() + } + + override fun changeUiToPlayingBufferingShow() { + Logger.d(ImageAndVideoRotation.TAG, "changeUiToPlayingBufferingShow -hide") + hideWidget() + } + + override fun changeUiToError() { + Logger.d(ImageAndVideoRotation.TAG, "changeUiToError-hide") + hideWidget() + } + + private fun hideWidget(){ + setViewShowState(mBottomContainer, INVISIBLE) + setViewShowState(mProgressBar, INVISIBLE) + setViewShowState(mCurrentTimeTextView, INVISIBLE) + setViewShowState(mTotalTimeTextView, INVISIBLE) + setViewShowState(mBottomProgressBar, INVISIBLE) + setViewShowState(mBackButton, INVISIBLE) + setViewShowState(mStartButton, INVISIBLE) + + setViewShowState(mThumbImageViewLayout, VISIBLE) + setViewShowState(mThumbImageView, VISIBLE) + + setViewShowState(mTopContainer, INVISIBLE) + + setViewShowState(mLoadingProgressBar, INVISIBLE) + setViewShowState( + mLockScreen, INVISIBLE + ) + + setIsTouchWiget(false) + isFocusableInTouchMode = false + } + + fun setCacheImageViewVisible() { + Logger.d(ImageAndVideoRotation.TAG, "CacheImageViewVISIBLE") + setViewShowState(mThumbImageViewLayout, VISIBLE) +// setViewShowState(mThumbImageView, VISIBLE) + } + + fun setCacheImageViewGone() { + Logger.d(ImageAndVideoRotation.TAG, "CacheImageViewGONE") + setViewShowState(mThumbImageViewLayout, INVISIBLE) +// setViewShowState(mThumbImageView, INVISIBLE) + } + + //失去焦点声音压低 + override fun onLossTransientCanDuck() { +// setStreamVolume(0.2f) + setNeedMute(true) + } + + //获取焦点声音恢复 + override fun onGankAudio() { +// setStreamVolume(5.0f) + setNeedMute(false) + } + + private fun setStreamVolume(percent: Float){ + var mAudioManager = mContext?.getSystemService(Context.AUDIO_SERVICE) as AudioManager + var maxVolume = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC) + var volume = (percent * maxVolume).toInt() + if (volume < 0 ){ + volume = 0 + } + mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC,volume,0) + } + + private fun setNeedMute(isMute: Boolean){ + gsyVideoManager?.player?.setNeedMute(isMute) + } +} \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/video/AdvanceImageView.kt b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/video/AdvanceImageView.kt new file mode 100644 index 0000000000..cf0d030989 --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/video/AdvanceImageView.kt @@ -0,0 +1,45 @@ +package com.mogo.och.bus.passenger.ui.widget.video + +import android.annotation.SuppressLint +import android.content.Context +import android.util.AttributeSet +import android.widget.ImageView +import android.widget.RelativeLayout +import com.bumptech.glide.Glide +import com.bumptech.glide.request.RequestOptions +import com.mogo.och.bus.passenger.R + +/** + * @author: wangmingjun + * @date: 2023/2/6 + */ +class AdvanceImageView @JvmOverloads constructor( + context: Context, attrs: AttributeSet? = null +) : RelativeLayout(context, attrs) { + + private var imageView: ImageView? = null + + init { + initView() + } + + private fun initView() { + imageView = ImageView(context) + imageView?.scaleType = ImageView.ScaleType.FIT_XY + addView(imageView, LayoutParams(-1, -1)) + } + + @SuppressLint("CheckResult") + fun setImagePath(path: String){ + imageView?.setImageResource(R.drawable.m2_p_video_holder) + imageView?.let { Glide.with(context).asBitmap().load(path) + .apply( + RequestOptions().useUnlimitedSourceGeneratorsPool(true) + .placeholder(R.drawable.m2_p_video_holder) + .error(R.drawable.m2_p_video_holder) + .fallback(R.drawable.m2_p_video_holder) + .centerCrop() + ) + .into(it) } + } +} \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/video/AdvancePagerAdapter.kt b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/video/AdvancePagerAdapter.kt new file mode 100644 index 0000000000..db42808e75 --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/video/AdvancePagerAdapter.kt @@ -0,0 +1,211 @@ +package com.mogo.och.bus.passenger.ui.widget.video + +import android.content.Context +import android.view.View +import android.view.ViewGroup +import androidx.viewpager.widget.PagerAdapter +import androidx.viewpager.widget.ViewPager +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.CountDownTimer +import com.mogo.eagle.core.utilcode.util.UiThreadHandler +import com.shuyu.gsyvideoplayer.listener.GSYSampleCallBack + +/** + * @author: wangmingjun + * @date: 2023/2/6 + */ +class AdvancePagerAdapter(context: Context, viewPager: ViewPager) : PagerAdapter(), + ViewPager.OnPageChangeListener { + + private val mContext: Context = context + private val mViewPager: ViewPager = viewPager + + private var dataList = mutableListOf() + private var viewList = mutableListOf() + + private var lastPosition = -1 + + private var current = 0 + private val time = 5000 + private var pause = false + private var countDownTimer: CountDownTimer? = null + + fun setData(list: MutableList) { + if (list.isEmpty()) return + dataList.addAll(list) + + viewList.clear() + + list.forEach { + addView(it) + } + + mViewPager.addOnPageChangeListener(this) + + notifyDataSetChanged() + + mViewPager.currentItem = 0 + + if (viewList.size > 0) { + if (viewList[mViewPager.currentItem] is AdvanceVideoView) {//有人反应第一个是视频不播放这边优化了一下 + Logger.d(ImageAndVideoRotation.TAG, "第一个是视频") + val video = viewList[mViewPager.currentItem] as AdvanceVideoView + video.setVideo(gsySampleCallBack) + + } else if (viewList[mViewPager.currentItem] is AdvanceImageView) { + Logger.d(ImageAndVideoRotation.TAG, "startTimer()_1") + current = 0//换页重新计算时间 + startTimer() + } + } + } + + override fun getCount(): Int { + return dataList.size + } + + override fun isViewFromObject(view: View, `object`: Any): Boolean { + return view === `object` + } + + override fun destroyItem(container: ViewGroup, position: Int, `object`: Any) { + container.removeView(viewList[position]) + } + + override fun instantiateItem(container: ViewGroup, position: Int): Any { + val view: View = viewList[position] + container.addView(view) + return view + + } + + override fun getItemPosition(`object`: Any): Int { + return POSITION_NONE + } + + private fun addView(item: RotationItem) { + if (item.type == 1) { // 表示视频 + val videoView = AdvanceVideoView(mContext) + videoView.setVideoPath(item.path,item.cacheImgPath) + viewList.add(videoView) + } else { // 表示图片 + val imageView = AdvanceImageView(mContext) + imageView.setImagePath(item.path) + viewList.add(imageView) + } + } + + fun setPause() { + pause = true + if (viewList.size > 0 && viewList[mViewPager.currentItem] is AdvanceVideoView) { + val videoView = viewList[mViewPager.currentItem] as AdvanceVideoView + videoView.setPause() + } + } + + fun setResume() { + pause = false + if (viewList.size > 0 && viewList[mViewPager.currentItem] is AdvanceVideoView) { + val videoView = viewList[mViewPager.currentItem] as AdvanceVideoView + videoView.setResume() + } + } + + override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) { + } + + override fun onPageSelected(position: Int) { + } + + override fun onPageScrollStateChanged(state: Int) { + // 由于viewpager的预加载机制onPageSelected这里面加载videoview 放的跟玩一样 等操作完成后再播放videoview就香了 很丝滑 + if (state == 0) { //静止,什么都没做 + val currentItem = mViewPager.currentItem + Logger.d(ImageAndVideoRotation.TAG, + "state = $state currentItem = $currentItem lastPosition = $lastPosition") + + if (viewList.size > 1) { //多于1,才会循环跳转 + + if (viewList[mViewPager.currentItem] is AdvanceVideoView) { + + val videoView = (viewList[mViewPager.currentItem] as AdvanceVideoView) + videoView.setCacheImageViewVisible() + videoView.setVideo(gsySampleCallBack) + + } else if (viewList[mViewPager.currentItem] is AdvanceImageView) { + Logger.d(ImageAndVideoRotation.TAG, "startTimer()") + current = 0//换页重新计算时间 + startTimer() + } + lastPosition = mViewPager.currentItem + } + } + } + + private var gsySampleCallBack = object : GSYSampleCallBack() { + + override fun onPrepared(url: String?, vararg objects: Any?) { + Logger.d(ImageAndVideoRotation.TAG, "onPrepared--$url") + } + + override fun onAutoComplete(url: String?, vararg objects: Any?) { + Logger.d(ImageAndVideoRotation.TAG, "onAutoComplete()-$url") + if (viewList[mViewPager.currentItem] is AdvanceVideoView){ + val videoView = (viewList[mViewPager.currentItem] as AdvanceVideoView) + if (viewList.size == 1){ + videoView.startPlay(url) + }else{ + videoView.onVideoReset() + goNextItemView() + } + } + } + + override fun onPlayError(url: String?, vararg objects: Any?) { + super.onPlayError(url, *objects) + Logger.d(ImageAndVideoRotation.TAG, "onPlayError()-$url") + if (viewList[mViewPager.currentItem] is AdvanceVideoView){ + val videoView = (viewList[mViewPager.currentItem] as AdvanceVideoView) + videoView.onVideoReset() +// videoView.setCacheImageViewVisible() + videoView.clearLocalErrorVideo() + goNextItemView() + } + } + } + + private fun startTimer() { + if (countDownTimer != null){ + countDownTimer?.cancel() + countDownTimer = null + } + countDownTimer = object : CountDownTimer(5000,1000){ + override fun onTick(millisUntilFinished: Long) { + d(SceneConstant.M_BUS_P + "startTimer", "倒计时秒 = ${millisUntilFinished/1000}" ) + } + + override fun onFinish() { + d(ImageAndVideoRotation.TAG+ "startTimer", "5s到,跳转") + goNextItemView() + } + + }.start() + } + + /** + * view 跳转 + */ + private fun goNextItemView() { + if (mViewPager.currentItem == viewList.size - 1) {//已经到最后一个 + mViewPager.post { + mViewPager.setCurrentItem(0, true) + } + } else { + mViewPager.post { + mViewPager.setCurrentItem(mViewPager.currentItem + 1, true) + } + } + } +} \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/video/AdvanceVideoView.kt b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/video/AdvanceVideoView.kt new file mode 100644 index 0000000000..29a678e59a --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/video/AdvanceVideoView.kt @@ -0,0 +1,248 @@ +package com.mogo.och.bus.passenger.ui.widget.video + +import android.annotation.SuppressLint +import android.content.Context +import android.net.Uri +import android.util.AttributeSet +import android.widget.ImageView +import android.widget.RelativeLayout +import com.mogo.eagle.core.utilcode.breakpoint.bean.ThreadBean +import com.mogo.eagle.core.utilcode.breakpoint.callback.IDownload +import com.mogo.eagle.core.utilcode.breakpoint.utils.DownloadUtils +import com.mogo.eagle.core.utilcode.mogo.logger.Logger +import com.mogo.eagle.core.utilcode.util.FileUtils +import com.mogo.eagle.core.utilcode.util.ThreadUtils +import com.mogo.eagle.core.utilcode.util.UiThreadHandler +import com.mogo.och.bus.passenger.R +import com.shuyu.gsyvideoplayer.builder.GSYVideoOptionBuilder +import com.shuyu.gsyvideoplayer.listener.GSYSampleCallBack +import java.io.File + +/** + * @author: wangmingjun + * @date: 2023/2/8 + */ +class AdvanceVideoView @JvmOverloads constructor( + context: Context, attrs: AttributeSet? = null +) : RelativeLayout(context, attrs) { + + private var videoRelativeLayout: RelativeLayout? = null + private var cacheImage: ImageView? = null + private var videoViewPlayer: AdvanceGSYVideoPlayer? = null + private var gsyVideoOptionBuilder: GSYVideoOptionBuilder? = null + private var mOnCompletionListener: GSYSampleCallBack? = null + private var downloadVideoName = "" + private var fileNetPath: String? = "" + private var cacheImageUrl: String? = "" + private var mVideoDirPath: String? = "" + + init { + mVideoDirPath = context.filesDir.absolutePath+ File.separator + "video" + File.separator +// mVideoDirPath = Config.downLoadPath + initView() + } + + private fun initView() { + initVideoView() + initCacheImgView() + } + + private fun initCacheImgView() { + cacheImage = ImageView(context) + cacheImage?.scaleType = ImageView.ScaleType.FIT_XY +// addView(cacheImage, LayoutParams(-1, -1)) + } + + private fun initVideoView() { + videoRelativeLayout = RelativeLayout(context) + addView(videoRelativeLayout, LayoutParams(-1, -1)) + + if (videoViewPlayer === null) { + //视频播放控件 + videoViewPlayer = AdvanceGSYVideoPlayer(context) + } + + var layoutParams = LayoutParams(-1, -1) + //设置videoview占满父view播放 + layoutParams.addRule(ALIGN_PARENT_LEFT) + layoutParams.addRule(ALIGN_PARENT_RIGHT) + layoutParams.addRule(ALIGN_PARENT_TOP) + layoutParams.addRule(ALIGN_PARENT_BOTTOM) + + videoRelativeLayout?.addView(videoViewPlayer, layoutParams) + } + + fun setVideoPath(path: String,cacheImageUrl: String) { + // https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357834634/5.m4v + // https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360274126/10.mp4 + this.fileNetPath = path + this.cacheImageUrl = cacheImageUrl + val pathList = path.split("/") + if (pathList.isNotEmpty()){ + this.downloadVideoName = pathList[pathList.size - 1] + } + } + + private fun loadCacheImg() { + // BitmapHelper.getVideoThumbnail(path) /*获取第一帧图* +// OCHThreadPoolManager.getsInstance().execute { +// var bitmap = BitmapHelper.getVideoThumbnail(fileNetPath) + Logger.d(ImageAndVideoRotation.TAG, "setVideoPath") +// ThreadUtils.runOnUiThread { +// Logger.d(ImageAndVideoRotation.TAG, "bitmap加载") + cacheImage?.setImageResource(R.drawable.m2_p_video_holder) +// cacheImage?.let { //暂时去掉加载首帧图,加载视频时,用本地默认图 +// Glide.with(context).asBitmap().load(cacheImageUrl) +// .apply( +// RequestOptions().useUnlimitedSourceGeneratorsPool(true) +// .placeholder(R.drawable.m2_p_video_holder) +// .error(R.drawable.m2_p_video_holder) +// .fallback(R.drawable.m2_p_video_holder) +// .centerCrop() +// ) +// .into(it) +// } + videoViewPlayer?.thumbImageView = cacheImage +// setCacheImageViewVisible() +// } +// } + } + + fun clearLocalErrorVideo(){ + if (downloadVideoName.isNotEmpty() + && FileUtils.isFileExists(mVideoDirPath + downloadVideoName)){ + FileUtils.delete(mVideoDirPath + downloadVideoName) + } + } + + @SuppressLint("CheckResult") + fun setCacheImageViewVisible() { + UiThreadHandler.post { +// cacheImage?.visibility = VISIBLE + videoViewPlayer?.setCacheImageViewVisible() + } + } + + fun setCacheImageViewGone() { + UiThreadHandler.post { +// cacheImage?.visibility = GONE + videoViewPlayer?.setCacheImageViewGone() + } + + } + + fun setVideo(onCompletionListener: GSYSampleCallBack) { + loadCacheImg() + Logger.d(ImageAndVideoRotation.TAG, "setVideo") + mOnCompletionListener = onCompletionListener + //判断是否已经下载 + if (downloadVideoName.isNotEmpty()){ + Logger.d(ImageAndVideoRotation.TAG, + "video local url = $mVideoDirPath$downloadVideoName" + ) + if (FileUtils.isFileExists(mVideoDirPath+downloadVideoName)){ + Logger.d(ImageAndVideoRotation.TAG, "have cache startPlay") + startPlay(Uri.fromFile(File(mVideoDirPath+downloadVideoName)).toString()) + return + } + startDownLoadVideo() + } + } + + private fun startDownLoadVideo(){ + //下载视频, 下载成功后再播放 + Logger.d(ImageAndVideoRotation.TAG, "startDownLoadVideo") + FileUtils.createFileDir(mVideoDirPath) + DownloadUtils.downLoad(context,fileNetPath,mVideoDirPath + ,downloadVideoName,5,downListener) + } + + fun startPlay(localVideoPath: String?){ + if (localVideoPath === "") return + try { + Logger.d(ImageAndVideoRotation.TAG, "startPlay") + gsyVideoOptionBuilder = GSYVideoOptionBuilder() + gsyVideoOptionBuilder +// ?.setUrl("file:///mnt/sdcard/downloads/$downloadVideoName") + ?.setUrl(localVideoPath) // "/data/user/0/com.mogo.launcher.f/files/video/" + ?.setPlayTag(downloadVideoName) + ?.setCacheWithPlay(false) + ?.setThumbPlay(false) + ?.build(videoViewPlayer) + + videoViewPlayer?.isFocusableInTouchMode = false + videoViewPlayer?.setVideoAllCallBack(mOnCompletionListener) + videoViewPlayer?.startPlayLogic() + }catch (e: Exception){ + Logger.d(ImageAndVideoRotation.TAG, "startPlay e = ${e.message}") + } + } + + fun onVideoReset(){ + videoViewPlayer?.onVideoReset() + mOnCompletionListener = null + } + + fun setPause() { + if (videoViewPlayer !== null) { + videoViewPlayer?.onVideoPause() + } + } + + fun setResume() { + if (videoViewPlayer !== null) { + videoViewPlayer?.onVideoResume() + } + } + + private val downListener = object : IDownload{ + override fun onStart(url: String?) { + setCacheImageViewVisible() + Logger.d(ImageAndVideoRotation.TAG, "download-onStart") + } + + override fun onPause(url: String?, threadBean: ThreadBean?) { + Logger.d(ImageAndVideoRotation.TAG, "download-onPause") +// UiThreadHandler.postDelayed(Runnable { +// startDownLoadVideo() +// },DOWNLOAD_DELAY) + // todo 测试下网络断掉是否会走onpause,且网络回复也不会继续下载 + } + + override fun onProgress(url: String?, length: Int) { + Logger.d(ImageAndVideoRotation.TAG, "download-onProgress== $length") + } + + override fun onFinished(url: String?, threadBean: ThreadBean?) { + Logger.d(ImageAndVideoRotation.TAG, "download-onFinished = $url") + if (url.equals(fileNetPath)){ //发现下载工具在断网又连网后,已完成的任务又都下载,跳转播放出现问题 + //下载完成 + ThreadUtils.runOnUiThread { + startPlay(Uri.fromFile(File(mVideoDirPath+downloadVideoName)).toString()) + } + }else{//如果当前文件不存在再次去下载当前的 + Logger.d(ImageAndVideoRotation.TAG, "download-onFinished = not current" + + ",currentUrl = $fileNetPath ") + if (FileUtils.isFileExists(mVideoDirPath+downloadVideoName)){ + Logger.d(ImageAndVideoRotation.TAG, "have download startPlay") + ThreadUtils.runOnUiThread { + startPlay(Uri.fromFile(File(mVideoDirPath+downloadVideoName)).toString()) + } + return + }else{ + startDownLoadVideo() + } + } + } + + override fun onError(url: String?, errorMsg: String?) { + Logger.d(ImageAndVideoRotation.TAG, "download-onError-$errorMsg") + //出错再次下载 + if (errorMsg != null) { + if (errorMsg.startsWith("initFailed")){ + startDownLoadVideo() + } + } + } + } +} \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/video/AdvanceViewPager.kt b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/video/AdvanceViewPager.kt new file mode 100644 index 0000000000..1ec09195c3 --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/video/AdvanceViewPager.kt @@ -0,0 +1,24 @@ +package com.mogo.och.bus.passenger.ui.widget.video + +import android.content.Context +import android.util.AttributeSet +import android.view.MotionEvent +import androidx.viewpager.widget.ViewPager + +/** + * @author: wangmingjun + * @date: 2023/2/21 + */ +class AdvanceViewPager: ViewPager{ + + constructor(context: Context) : super(context) + constructor(context: Context,attrs: AttributeSet?) : super(context,attrs) + + override fun onTouchEvent(ev: MotionEvent?): Boolean { + return false + } + + override fun onInterceptTouchEvent(ev: MotionEvent?): Boolean { + return false + } +} \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/video/ImageAndVideoRotation.kt b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/video/ImageAndVideoRotation.kt new file mode 100644 index 0000000000..92d3b3dbda --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/video/ImageAndVideoRotation.kt @@ -0,0 +1,47 @@ +package com.mogo.och.bus.passenger.ui.widget.video + +import android.annotation.SuppressLint +import android.content.Context +import android.util.AttributeSet +import android.widget.RelativeLayout +import androidx.viewpager.widget.ViewPager +/** + * @author: wangmingjun + * @date: 2023/2/6 + */ +class ImageAndVideoRotation @JvmOverloads constructor( + context: Context, attrs: AttributeSet? = null +) : RelativeLayout(context, attrs) { + + private var viewPager: AdvanceViewPager? = null + private var pagerAdapter: AdvancePagerAdapter? = null + + companion object { + const val TAG = "ImageAndVideoRotation" + } + + init { + initView() + } + + @SuppressLint("ClickableViewAccessibility") + private fun initView() { + viewPager = AdvanceViewPager(context) + pagerAdapter = AdvancePagerAdapter(context, viewPager!!) + viewPager?.adapter = pagerAdapter + + addView(viewPager, LayoutParams(-1, -1)) + } + + fun setData(list: MutableList){ + pagerAdapter?.setData(list) + } + + fun setPause(){ + pagerAdapter?.setPause() + } + + fun setResume(){ + pagerAdapter?.setResume() + } +} \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/video/RotationItem.kt b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/video/RotationItem.kt new file mode 100644 index 0000000000..ed788c6179 --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/video/RotationItem.kt @@ -0,0 +1,12 @@ +package com.mogo.och.bus.passenger.ui.widget.video + +/** + * @author: wangmingjun + * @date: 2023/2/6 + * type:0 图片 + * type:1 视频 + */ +data class RotationItem(var path: String, + var type: Int, + var cacheImgPath: String, + var title: String) \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/auto_button_bg.png b/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/auto_button_bg.png new file mode 100644 index 0000000000..fb4ddc5279 Binary files /dev/null and b/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/auto_button_bg.png differ diff --git a/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/bus_light_green_nor.png b/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/bus_light_green_nor.png new file mode 100644 index 0000000000..bc9fed952d Binary files /dev/null and b/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/bus_light_green_nor.png differ diff --git a/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/bus_light_red_nor.png b/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/bus_light_red_nor.png new file mode 100644 index 0000000000..8732508ded Binary files /dev/null and b/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/bus_light_red_nor.png differ diff --git a/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/bus_lightyellow_nor.png b/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/bus_lightyellow_nor.png new file mode 100644 index 0000000000..bae01408fd Binary files /dev/null and b/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/bus_lightyellow_nor.png differ diff --git a/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/clock_bg.png b/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/clock_bg.png new file mode 100644 index 0000000000..a380c3f3b7 Binary files /dev/null and b/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/clock_bg.png differ diff --git a/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/img_drive_bg.png b/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/img_drive_bg.png new file mode 100644 index 0000000000..7412ab3c90 Binary files /dev/null and b/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/img_drive_bg.png differ diff --git a/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/img_line_bg.png b/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/img_line_bg.png new file mode 100644 index 0000000000..dd78f6fc9e Binary files /dev/null and b/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/img_line_bg.png differ diff --git a/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/img_time_bg.png b/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/img_time_bg.png new file mode 100644 index 0000000000..ba735834b6 Binary files /dev/null and b/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/img_time_bg.png differ diff --git a/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/m2_blue_tooth_close.png b/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/m2_blue_tooth_close.png new file mode 100644 index 0000000000..0c292d2cf3 Binary files /dev/null and b/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/m2_blue_tooth_close.png differ diff --git a/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/m2_blue_tooth_open.png b/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/m2_blue_tooth_open.png new file mode 100644 index 0000000000..cccf9e10fa Binary files /dev/null and b/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/m2_blue_tooth_open.png differ diff --git a/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/m2_light_green_nor.png b/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/m2_light_green_nor.png new file mode 100644 index 0000000000..3135524a79 Binary files /dev/null and b/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/m2_light_green_nor.png differ diff --git a/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/m2_light_red_nor.png b/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/m2_light_red_nor.png new file mode 100644 index 0000000000..e873c2b85e Binary files /dev/null and b/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/m2_light_red_nor.png differ diff --git a/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/m2_light_yellow_nor.png b/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/m2_light_yellow_nor.png new file mode 100644 index 0000000000..8046782601 Binary files /dev/null and b/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/m2_light_yellow_nor.png differ diff --git a/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/m2_line_location_bg.png b/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/m2_line_location_bg.png new file mode 100644 index 0000000000..593db1abc5 Binary files /dev/null and b/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/m2_line_location_bg.png differ diff --git a/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/m2_map_car_icon.png b/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/m2_map_car_icon.png new file mode 100644 index 0000000000..2520ae1c9e Binary files /dev/null and b/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/m2_map_car_icon.png differ diff --git a/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/m2_map_end_icon.png b/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/m2_map_end_icon.png new file mode 100644 index 0000000000..2efd3a52eb Binary files /dev/null and b/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/m2_map_end_icon.png differ diff --git a/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/m2_map_start_icon.png b/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/m2_map_start_icon.png new file mode 100644 index 0000000000..d7ab9231d9 Binary files /dev/null and b/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/m2_map_start_icon.png differ diff --git a/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/m2_map_staton_icon.png b/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/m2_map_staton_icon.png new file mode 100644 index 0000000000..1314028434 Binary files /dev/null and b/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/m2_map_staton_icon.png differ diff --git a/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/m2_p_video_holder.png b/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/m2_p_video_holder.png new file mode 100644 index 0000000000..d8c5951e43 Binary files /dev/null and b/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/m2_p_video_holder.png differ diff --git a/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/m2_status_bar_logo.png b/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/m2_status_bar_logo.png new file mode 100644 index 0000000000..ad3bd7fda7 Binary files /dev/null and b/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/m2_status_bar_logo.png differ diff --git a/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/m2_youzhuan_open.png b/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/m2_youzhuan_open.png new file mode 100644 index 0000000000..bbd2c12d90 Binary files /dev/null and b/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/m2_youzhuan_open.png differ diff --git a/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/m2_youzhuan_un_open.png b/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/m2_youzhuan_un_open.png new file mode 100644 index 0000000000..7c0dcaabe1 Binary files /dev/null and b/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/m2_youzhuan_un_open.png differ diff --git a/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/m2_zuozhuan_open.png b/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/m2_zuozhuan_open.png new file mode 100644 index 0000000000..9bbda22cb7 Binary files /dev/null and b/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/m2_zuozhuan_open.png differ diff --git a/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/m2_zuozhuan_un_open.png b/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/m2_zuozhuan_un_open.png new file mode 100644 index 0000000000..7c33fddbd9 Binary files /dev/null and b/OCH/mogo-och-bus-passenger/src/m2/res/drawable-nodpi/m2_zuozhuan_un_open.png differ diff --git a/OCH/mogo-och-bus-passenger/src/m2/res/drawable/bg_dashed_line.xml b/OCH/mogo-och-bus-passenger/src/m2/res/drawable/bg_dashed_line.xml new file mode 100644 index 0000000000..f6917017e5 --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/m2/res/drawable/bg_dashed_line.xml @@ -0,0 +1,7 @@ + + + + + \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/m2/res/drawable/bg_driving_selector.xml b/OCH/mogo-och-bus-passenger/src/m2/res/drawable/bg_driving_selector.xml new file mode 100644 index 0000000000..21a6524032 --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/m2/res/drawable/bg_driving_selector.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/m2/res/drawable/bg_p_m2_auto.xml b/OCH/mogo-och-bus-passenger/src/m2/res/drawable/bg_p_m2_auto.xml new file mode 100644 index 0000000000..0497ff212e --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/m2/res/drawable/bg_p_m2_auto.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/m2/res/drawable/bg_p_m2_traffic_light.xml b/OCH/mogo-och-bus-passenger/src/m2/res/drawable/bg_p_m2_traffic_light.xml new file mode 100644 index 0000000000..5a27da20e0 --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/m2/res/drawable/bg_p_m2_traffic_light.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/m2/res/drawable/bg_pnc.xml b/OCH/mogo-och-bus-passenger/src/m2/res/drawable/bg_pnc.xml new file mode 100644 index 0000000000..0357ebb192 --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/m2/res/drawable/bg_pnc.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/m2/res/drawable/brakelight_background_daytime.xml b/OCH/mogo-och-bus-passenger/src/m2/res/drawable/brakelight_background_daytime.xml new file mode 100644 index 0000000000..b6cbdbd569 --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/m2/res/drawable/brakelight_background_daytime.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/m2/res/drawable/bus_light_green_nor.png b/OCH/mogo-och-bus-passenger/src/m2/res/drawable/bus_light_green_nor.png new file mode 100644 index 0000000000..bc9fed952d Binary files /dev/null and b/OCH/mogo-och-bus-passenger/src/m2/res/drawable/bus_light_green_nor.png differ diff --git a/OCH/mogo-och-bus-passenger/src/m2/res/drawable/bus_light_red_nor.png b/OCH/mogo-och-bus-passenger/src/m2/res/drawable/bus_light_red_nor.png new file mode 100644 index 0000000000..8732508ded Binary files /dev/null and b/OCH/mogo-och-bus-passenger/src/m2/res/drawable/bus_light_red_nor.png differ diff --git a/OCH/mogo-och-bus-passenger/src/m2/res/drawable/bus_lightyellow_nor.png b/OCH/mogo-och-bus-passenger/src/m2/res/drawable/bus_lightyellow_nor.png new file mode 100644 index 0000000000..bae01408fd Binary files /dev/null and b/OCH/mogo-och-bus-passenger/src/m2/res/drawable/bus_lightyellow_nor.png differ diff --git a/OCH/mogo-och-bus-passenger/src/m2/res/drawable/m2_power_seekbar_style.xml b/OCH/mogo-och-bus-passenger/src/m2/res/drawable/m2_power_seekbar_style.xml new file mode 100644 index 0000000000..3ac0c761ba --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/m2/res/drawable/m2_power_seekbar_style.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/m2/res/layout/m2_p_traffic_light_view.xml b/OCH/mogo-och-bus-passenger/src/m2/res/layout/m2_p_traffic_light_view.xml new file mode 100644 index 0000000000..360a67883b --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/m2/res/layout/m2_p_traffic_light_view.xml @@ -0,0 +1,36 @@ + + + + + + + + + + \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/m2/res/layout/p_m2_driving_info_fragment.xml b/OCH/mogo-och-bus-passenger/src/m2/res/layout/p_m2_driving_info_fragment.xml new file mode 100644 index 0000000000..eb8eed4b1f --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/m2/res/layout/p_m2_driving_info_fragment.xml @@ -0,0 +1,235 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/m2/res/layout/p_m2_fragment.xml b/OCH/mogo-och-bus-passenger/src/m2/res/layout/p_m2_fragment.xml new file mode 100644 index 0000000000..c4a848c6bd --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/m2/res/layout/p_m2_fragment.xml @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/m2/res/layout/p_m2_hpmap_fragment.xml b/OCH/mogo-och-bus-passenger/src/m2/res/layout/p_m2_hpmap_fragment.xml new file mode 100644 index 0000000000..851d3a25bb --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/m2/res/layout/p_m2_hpmap_fragment.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/m2/res/layout/p_m2_video_fragment.xml b/OCH/mogo-och-bus-passenger/src/m2/res/layout/p_m2_video_fragment.xml new file mode 100644 index 0000000000..6c82b8c9dc --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/m2/res/layout/p_m2_video_fragment.xml @@ -0,0 +1,13 @@ + + + + + + + + \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/m2/res/layout/p_m2_video_view.xml b/OCH/mogo-och-bus-passenger/src/m2/res/layout/p_m2_video_view.xml new file mode 100644 index 0000000000..9d75478ee1 --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/m2/res/layout/p_m2_video_view.xml @@ -0,0 +1,8 @@ + + + + \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/m2/res/layout/p_m2_view_blue_tooth.xml b/OCH/mogo-och-bus-passenger/src/m2/res/layout/p_m2_view_blue_tooth.xml new file mode 100644 index 0000000000..69ae14c394 --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/m2/res/layout/p_m2_view_blue_tooth.xml @@ -0,0 +1,15 @@ + + + + + + \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/m2/res/layout/p_m2_view_status_bar.xml b/OCH/mogo-och-bus-passenger/src/m2/res/layout/p_m2_view_status_bar.xml new file mode 100644 index 0000000000..20461e6c5a --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/m2/res/layout/p_m2_view_status_bar.xml @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/m2/res/layout/view_turn_light_status_daytime.xml b/OCH/mogo-och-bus-passenger/src/m2/res/layout/view_turn_light_status_daytime.xml new file mode 100644 index 0000000000..3ba54be149 --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/m2/res/layout/view_turn_light_status_daytime.xml @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/m2/res/raw/station_marker.nt3d b/OCH/mogo-och-bus-passenger/src/m2/res/raw/station_marker.nt3d new file mode 100644 index 0000000000..a00207ba3f Binary files /dev/null and b/OCH/mogo-och-bus-passenger/src/m2/res/raw/station_marker.nt3d differ diff --git a/OCH/mogo-och-bus-passenger/src/m2/res/values/colors.xml b/OCH/mogo-och-bus-passenger/src/m2/res/values/colors.xml new file mode 100644 index 0000000000..c752b78caf --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/m2/res/values/colors.xml @@ -0,0 +1,26 @@ + + + #FFFFFF + #0B1E38 + #2D3E5F + + #BBDAFB + #0B1E38 + #5D7199 + #0B1E38 + #6B7EA6 + #2D3E5F + #A5D8FF + #1B2546 + #23355D + #374E7F + + #FFFFA28B + #FFDA1100 + #FF60FFD3 + #FF006D43 + #FFFFE198 + #FFFF9B00 + #59FFFFFF + #8895B7 + \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/m2/res/values/dimens.xml b/OCH/mogo-och-bus-passenger/src/m2/res/values/dimens.xml new file mode 100644 index 0000000000..ca8e0dcfc1 --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/m2/res/values/dimens.xml @@ -0,0 +1,5 @@ + + + 60dp + 40dp + \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/m2/res/values/strings.xml b/OCH/mogo-och-bus-passenger/src/m2/res/values/strings.xml new file mode 100644 index 0000000000..e113235a28 --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/m2/res/values/strings.xml @@ -0,0 +1,23 @@ + + + KM/H + 您已收车 + 暂无路线 + + + 到达站: + 下一站: + 始发站: + 请携带好随身物品下车。 + 欢迎乘坐蘑菇车联自动驾驶车。 + + m2_map_style.data + m2_map_style_extra.data + Auto + 下一站: + 已到站: + 暂无站点 + —公里 | —分钟 + + + \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/bean/BusPassengerQueryLineRequest.java b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/bean/BusPassengerQueryLineRequest.java deleted file mode 100644 index c4e4e428a7..0000000000 --- a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/bean/BusPassengerQueryLineRequest.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.mogo.och.bus.passenger.bean; - -import com.mogo.cloud.passport.MoGoAiCloudClientConfig; - -public -/** - * @author congtaowang - * @since 2021/3/22 - * - * 根据车机行驶线路站点信息 - */ -class BusPassengerQueryLineRequest { - - private String sn; - public BusPassengerQueryLineRequest(String sn) { - this.sn = sn; - } -} diff --git a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/constant/BusPassengerConst.kt b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/constant/BusPassengerConst.kt index c7b0368acd..88fbdc0127 100644 --- a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/constant/BusPassengerConst.kt +++ b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/constant/BusPassengerConst.kt @@ -8,22 +8,8 @@ import com.mogo.commons.debug.DebugConfig class BusPassengerConst { companion object { - private const val BASE_URL_OCH_DEV = "http://tech-dev.zhidaohulian.com" - private const val BASE_URL_OCH_QA = "https://tech-qa.zhidaohulian.com" - private const val BASE_URL_OCH_RELEASE = "https://tech.zhidaohulian.com" - - @JvmStatic - fun getBaseUrl(): String { - return when (DebugConfig.getNetMode()) { - DebugConfig.NET_MODE_DEV, DebugConfig.NET_MODE_DEMO -> BASE_URL_OCH_DEV - DebugConfig.NET_MODE_QA -> BASE_URL_OCH_QA - DebugConfig.NET_MODE_RELEASE -> BASE_URL_OCH_RELEASE - else -> BASE_URL_OCH_RELEASE - } - } - // OCH arouter 路由path - const val PATH = "/och/api" + const val PATH = "/passenger/api" // 轮询line const val LOOP_LINE_2S = 2 * 1000L @@ -41,6 +27,8 @@ class BusPassengerConst { //bus平均速度 bus的平均里程:25km/h const val BUS_AVERAGE_SPEED = 25 + //接驳/B2平均速度 bus的平均里程:10km/h + const val SHUTTLE_AVERAGE_SPEED = 10 // 订单总里程 const val BUS_SP_KEY_ORDER_SUM_DIS = "BUS_SP_KEY_ORDER_SUM_DIS" diff --git a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/network/BusPassengerServiceApi.java b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/network/BusPassengerServiceApi.java deleted file mode 100644 index a7512971dc..0000000000 --- a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/network/BusPassengerServiceApi.java +++ /dev/null @@ -1,40 +0,0 @@ -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 io.reactivex.Observable; -import retrofit2.http.Body; -import retrofit2.http.GET; -import retrofit2.http.Header; -import retrofit2.http.Headers; -import retrofit2.http.POST; -import retrofit2.http.Query; - -/** - * Created on 2022/3/31 - * - * Bus乘客端接口定义 - */ -interface BusPassengerServiceApi { - /** - * 查询bus司机端绑定路线 - * @return 接口返回数据 - */ - @Headers( {"Content-Type:application/json;charset=UTF-8"} ) - @POST( "/autopilot-car-hailing/line/v2/driver/bus/passenger/lineDataWithDriver/query" ) - Observable 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 queryDriverOperationStatus(@Header ("appId") String appId, @Header("ticket") String ticket, @Query("sn") String sn); - - -} diff --git a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/network/BusPassengerServiceManager.kt b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/network/BusPassengerServiceManager.kt deleted file mode 100644 index 0e70161643..0000000000 --- a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/network/BusPassengerServiceManager.kt +++ /dev/null @@ -1,62 +0,0 @@ -package com.mogo.och.bus.passenger.network - -import android.content.Context -import com.mogo.och.bus.passenger.constant.BusPassengerConst.Companion.getBaseUrl -import com.mogo.eagle.core.function.call.telematic.CallerTelematicManager.getServerToken -import com.mogo.och.bus.passenger.bean.BusPassengerRoutesResponse -import com.mogo.cloud.passport.MoGoAiCloudClientConfig -import com.mogo.och.bus.passenger.bean.BusPassengerQueryLineRequest -import com.mogo.och.bus.passenger.bean.BusPassengerOperationStatusResponse -import com.mogo.eagle.core.network.MoGoRetrofitFactory -import com.mogo.och.common.module.biz.network.OchCommonServiceCallback -import com.mogo.och.common.module.biz.network.OchCommonSubscribeImpl -import com.mogo.och.common.module.biz.network.interceptor.transformTry - -/** - * Created on 2022/3/31 - */ -object BusPassengerServiceManager { - - private var mBusPassengerServiceApi = MoGoRetrofitFactory.getInstance(getBaseUrl()) - .create(BusPassengerServiceApi::class.java) - - /** - * 获取Bus司机端的sn - * @return - */ - private val driverAppSn: String - get() = getServerToken() - /** - * 查询绑定行驶的小巴车路线 - * @param context - * @param callback - */ - @JvmStatic - fun queryDriverSiteByCoordinate( - context: Context, callback: OchCommonServiceCallback? - ) { - mBusPassengerServiceApi.queryDriverSiteByCoordinate( - MoGoAiCloudClientConfig.getInstance().serviceAppId, - MoGoAiCloudClientConfig.getInstance().token, - BusPassengerQueryLineRequest(driverAppSn)) - .transformTry() - .subscribe(OchCommonSubscribeImpl(context, callback, "queryDriverSiteByCoordinate")) - } - - /** - * 查询司机端出车收车状态,以及车牌号 - * @param context - * @param callback - */ - @JvmStatic - fun queryDriverOperationStatus( - context: Context, - callback: OchCommonServiceCallback?) { - mBusPassengerServiceApi.queryDriverOperationStatus( - MoGoAiCloudClientConfig.getInstance().serviceAppId, - MoGoAiCloudClientConfig.getInstance().token, - driverAppSn) - .transformTry() - .subscribe(OchCommonSubscribeImpl(context, callback, "queryDriverOperationStatus")) - } -} \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/ui/BusPassengerTrafficLightView.java b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/ui/BusPassengerTrafficLightView.java deleted file mode 100644 index e021a8675b..0000000000 --- a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/ui/BusPassengerTrafficLightView.java +++ /dev/null @@ -1,194 +0,0 @@ -package com.mogo.och.bus.passenger.ui; - -import android.content.Context; -import android.util.AttributeSet; -import android.view.LayoutInflater; -import android.view.ViewGroup; -import android.widget.ImageView; -import android.widget.TextView; - -import com.mogo.eagle.core.function.api.hmi.view.IViewTrafficLight; -import com.mogo.eagle.core.utilcode.util.UiThreadHandler; -import com.mogo.och.bus.passenger.R; - -import org.jetbrains.annotations.Nullable; - -/** - * bus乘客端:红绿灯view - * - * Created on 2022/3/14 - */ -public class BusPassengerTrafficLightView extends IViewTrafficLight { - - private ImageView mLightIconIV; - private TextView mLightTimeTV; - private int mCurrentLightId; - private ImageView mLightIconBG; - - public BusPassengerTrafficLightView(@Nullable Context context) { - this(context, null, 0); - } - - public BusPassengerTrafficLightView(@Nullable Context context, @Nullable AttributeSet attrs) { - this(context, attrs, 0); - } - - public BusPassengerTrafficLightView(@Nullable Context context, @Nullable AttributeSet attrs, int defStyleAttr) { - super(context, attrs, defStyleAttr); - init(context); - } - - private void init(Context context) { - LayoutInflater.from(context).inflate(R.layout.bus_p_traffic_light_view, this, true); - mLightIconIV = findViewById(R.id.bus_p_traffic_light_iv); - mLightTimeTV = findViewById(R.id.bus_p_traffic_light_time_tv); - mLightIconBG = findViewById(R.id.bus_p_traffic_light_bg); - } - - /** - * 展示红绿灯预警 - * - * @param checkLightId 0-都是默认,1-红,2-黄,3-绿 - * @param lightSource 1:云端下发;2:自车感知 - */ - @Override - public void showWarningTrafficLight(int checkLightId,int lightSource) { - super.showWarningTrafficLight(checkLightId,lightSource); - mCurrentLightId = checkLightId; - updateTrafficLightIcon(checkLightId); - } - - /** - * 关闭红绿灯预警展示,并重制灯态 - */ - @Override - public void disableWarningTrafficLight() { - super.disableWarningTrafficLight(); - UiThreadHandler.post(() -> { - mCurrentLightId = 0; - BusPassengerTrafficLightView.this.setVisibility(GONE); - }); - } - - /** - * @param redNum 红灯倒计时 - * @param yellowNum 黄灯倒计时 - * @param greenNum 绿灯倒计时 - */ - @Override - public void changeCountdownTrafficLightNum(int redNum, int yellowNum, int greenNum) { - super.changeCountdownTrafficLightNum(redNum, yellowNum, greenNum); - resetView(); - switch (mCurrentLightId) { - case 1: - changeCountdownRed(redNum); - break; - case 2: - changeCountdownYellow(yellowNum); - break; - case 3: - changeCountdownGreen(greenNum); - break; - default: - UiThreadHandler.post(() -> { - mLightTimeTV.setText(""); - }); - break; - } - } - - @Override - public void changeCountdownRed(int redNum) { - super.changeCountdownRed(redNum); - UiThreadHandler.post(() -> { - if (redNum > 0) { - resetView(); - mLightTimeTV.setText(String.valueOf(redNum)); - } else { - disableCountdown(); - mLightTimeTV.setText(""); - } - }); - } - - @Override - public void changeCountdownGreen(int greenNum) { - super.changeCountdownGreen(greenNum); - UiThreadHandler.post(() -> { - if (greenNum > 0) { - resetView(); - mLightTimeTV.setText(String.valueOf(greenNum)); - } else { - disableCountdown(); - mLightTimeTV.setText(""); - } - }); - } - - @Override - public void changeCountdownYellow(int yellowNum) { - super.changeCountdownYellow(yellowNum); - UiThreadHandler.post(() -> { - if (yellowNum > 0) { - resetView(); - mLightTimeTV.setText(String.valueOf(yellowNum)); - } else { - disableCountdown(); - mLightTimeTV.setText(""); - } - }); - } - - /** - * 更新红绿灯icon - * - * @param lightId 0-都是默认,1-红,2-黄,3-绿 - */ - private void updateTrafficLightIcon(int lightId) { - UiThreadHandler.post(() -> { - switch (lightId) { - case 1: - mLightIconIV.setBackgroundResource(R.drawable.bus_p_light_red_nor); - BusPassengerTrafficLightView.this.setVisibility(VISIBLE); - break; - case 2: - mLightIconIV.setBackgroundResource(R.drawable.bus_p_light_yellow_nor); - BusPassengerTrafficLightView.this.setVisibility(VISIBLE); - break; - case 3: - mLightIconIV.setBackgroundResource(R.drawable.bus_p_light_green_nor); - BusPassengerTrafficLightView.this.setVisibility(VISIBLE); - break; - default: - BusPassengerTrafficLightView.this.setVisibility(GONE); - break; - } - }); - } - - @Override - public void disableCountdown() { - super.disableCountdown(); - UiThreadHandler.post(() ->{ - ViewGroup.LayoutParams layoutParams = getLayoutParams(); - if (layoutParams instanceof MarginLayoutParams){ - MarginLayoutParams lp = (MarginLayoutParams) layoutParams; - lp.width = (int) getResources().getDimension(R.dimen.bus_p_traffic_light_icon_size); - setLayoutParams(lp); - mLightTimeTV.setVisibility(GONE); - mLightIconBG.getLayoutParams().width = (int)getResources().getDimension(R.dimen.dp_90); - } - }); - } - - private void resetView(){ - ViewGroup.LayoutParams layoutParams = getLayoutParams(); - if (layoutParams instanceof MarginLayoutParams) { - MarginLayoutParams lp = (MarginLayoutParams) layoutParams; - lp.width = (int) getResources().getDimension(R.dimen.bus_p_route_traffic_light_view_width); - setLayoutParams(lp); - mLightTimeTV.setVisibility(VISIBLE); - mLightIconBG.getLayoutParams().width = (int) getResources().getDimension(R.dimen.bus_p_traffic_light_bg_width); - } - } -} diff --git a/OCH/mogo-och-bus-passenger/src/main/res/raw/bus_di.mp3 b/OCH/mogo-och-bus-passenger/src/main/res/raw/bus_di.mp3 new file mode 100644 index 0000000000..15b31ed247 Binary files /dev/null and b/OCH/mogo-och-bus-passenger/src/main/res/raw/bus_di.mp3 differ diff --git a/OCH/mogo-och-bus-passenger/src/main/res/values/strings.xml b/OCH/mogo-och-bus-passenger/src/main/res/values/strings.xml deleted file mode 100644 index 0f4dc17854..0000000000 --- a/OCH/mogo-och-bus-passenger/src/main/res/values/strings.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - KM/H - 您已收车 - 暂无班次 - - - 到达站: - 下一站: - 始发站: - 请携带好随身物品下车。 - 欢迎乘坐蘑菇车联无人驾驶车。 - \ No newline at end of file diff --git a/OCH/mogo-och-bus-passenger/src/test/java/com/mogo/och/bus/passenger/ExampleUnitTest.java b/OCH/mogo-och-bus-passenger/src/test/java/com/mogo/och/bus/passenger/ExampleUnitTest.java index a0652d588f..d940b2948f 100644 --- a/OCH/mogo-och-bus-passenger/src/test/java/com/mogo/och/bus/passenger/ExampleUnitTest.java +++ b/OCH/mogo-och-bus-passenger/src/test/java/com/mogo/och/bus/passenger/ExampleUnitTest.java @@ -2,8 +2,6 @@ package com.mogo.och.bus.passenger; import org.junit.Test; -import static org.junit.Assert.*; - /** * Example local unit test, which will execute on the development machine (host). * @@ -12,6 +10,6 @@ import static org.junit.Assert.*; public class ExampleUnitTest { @Test public void addition_isCorrect() { - assertEquals(4, 2 + 2); + } } \ No newline at end of file diff --git a/OCH/mogo-och-bus/build.gradle b/OCH/mogo-och-bus/build.gradle index 4de0719cb7..8bc610baf1 100644 --- a/OCH/mogo-och-bus/build.gradle +++ b/OCH/mogo-och-bus/build.gradle @@ -38,6 +38,24 @@ android { proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } + + + flavorDimensions "vehicle" + productFlavors { + + jinlvvan { + dimension "vehicle" + buildConfigField 'int', 'NEW_TEST', '0' + } + + // 小巴车 接驳车 这个维度应该放入的最外层 但是和小巴的代码耦合的太严重放到了这个地方 + // 乘客端删除了这个flavors 是因为乘客端这个地方比较简单 + shuttle { + dimension "vehicle" + buildConfigField 'int', 'NEW_TEST', '1' + } + } + } dependencies { @@ -51,26 +69,12 @@ dependencies { implementation rootProject.ext.dependencies.rxjava implementation rootProject.ext.dependencies.rxandroid + implementation rootProject.ext.dependencies.androidxrecyclerview compileOnly rootProject.ext.dependencies.recyclerviewadapterhelper implementation project(":OCH:mogo-och-common-module") + compileOnly project(":libraries:mogo-map") - implementation rootProject.ext.dependencies.androidxrecyclerview - if (Boolean.valueOf(USE_MAVEN_PACKAGE)) { - implementation rootProject.ext.dependencies.mogoutils - implementation rootProject.ext.dependencies.mogocommons - implementation rootProject.ext.dependencies.modulecommon - implementation rootProject.ext.dependencies.mogo_core_data - implementation rootProject.ext.dependencies.mogo_core_function_call - implementation rootProject.ext.dependencies.mogo_core_function_hmi - }else { - implementation project(":core:mogo-core-utils") - implementation project(":foudations:mogo-commons") - implementation project(':modules:mogo-module-common') - implementation project(':core:mogo-core-data') - implementation project(':core:mogo-core-function-call') - implementation project(':core:function-impl:mogo-core-function-hmi') - } } apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString() \ No newline at end of file diff --git a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/bean/BusOrdersResponse.java b/OCH/mogo-och-bus/src/jinlvvan/java/com/mogo/och/bus/bean/BusOrdersResponse.java similarity index 100% rename from OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/bean/BusOrdersResponse.java rename to OCH/mogo-och-bus/src/jinlvvan/java/com/mogo/och/bus/bean/BusOrdersResponse.java diff --git a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/bean/BusRoutesResponse.java b/OCH/mogo-och-bus/src/jinlvvan/java/com/mogo/och/bus/bean/BusRoutesResponse.java similarity index 100% rename from OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/bean/BusRoutesResponse.java rename to OCH/mogo-och-bus/src/jinlvvan/java/com/mogo/och/bus/bean/BusRoutesResponse.java diff --git a/OCH/mogo-och-bus/src/jinlvvan/java/com/mogo/och/bus/bean/BusStationBean.java b/OCH/mogo-och-bus/src/jinlvvan/java/com/mogo/och/bus/bean/BusStationBean.java new file mode 100644 index 0000000000..33afb10366 --- /dev/null +++ b/OCH/mogo-och-bus/src/jinlvvan/java/com/mogo/och/bus/bean/BusStationBean.java @@ -0,0 +1,146 @@ +package com.mogo.och.bus.bean; + +/** + * 单个网约车小巴车站信息 + * + * @author tongchenfei + */ +public class BusStationBean { + private int siteId; + private String name; + private int seq; + private double gcjLon; //高德 + private double gcjLat; //高德 + private double lon; //高精坐标 + private double lat; //高精坐标 + private int drivingStatus;//行驶信息,0初始值;1已经过;2当前站;3未到站 + private boolean leaving; + private String description; + private String cityCode; + private int businessType; //站点类型,9:taxi,10:bus + private int status; + private int ifStop = 1; // 是否需要停靠、1需要、0不需要 // TODO: 2021/10/19 原来站点里有设计是否需要停靠字段,现设计暂无,默认都需要停靠 + + public double getGcjLon() { + return gcjLon; + } + + public double getGcjLat() { + return gcjLat; + } + + 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 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 "BusStationBean{" + + "name='" + name + '\'' + + ", description='" + description + '\'' + + ", cityCode='" + cityCode + '\'' + + ", lon=" + lon + + ", lat=" + lat + + ", businessType=" + businessType + + ", status=" + status + + ", siteId=" + siteId + + ", seq=" + seq + + ", drivingStatus=" + drivingStatus + + ", ifStop=" + ifStop + + ", leaving=" + leaving + + '}'; + } +} diff --git a/OCH/mogo-och-bus/src/jinlvvan/java/com/mogo/och/bus/constant/URLConst.kt b/OCH/mogo-och-bus/src/jinlvvan/java/com/mogo/och/bus/constant/URLConst.kt new file mode 100644 index 0000000000..fe41ef967a --- /dev/null +++ b/OCH/mogo-och-bus/src/jinlvvan/java/com/mogo/och/bus/constant/URLConst.kt @@ -0,0 +1,12 @@ +package com.mogo.och.bus.constant + +import com.mogo.commons.debug.DebugConfig + +/** + * Created on 2021/12/6 + */ +class URLConst { + companion object { + + } +} \ No newline at end of file diff --git a/OCH/mogo-och-bus/src/jinlvvan/java/com/mogo/och/bus/model/OrderModel.java b/OCH/mogo-och-bus/src/jinlvvan/java/com/mogo/och/bus/model/OrderModel.java new file mode 100644 index 0000000000..fedea9b825 --- /dev/null +++ b/OCH/mogo-och-bus/src/jinlvvan/java/com/mogo/och/bus/model/OrderModel.java @@ -0,0 +1,1212 @@ +package com.mogo.och.bus.model; + +import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_BUS; +import static com.mogo.och.bus.constant.BusConst.DELAY_10S; +import static com.mogo.och.bus.constant.BusConst.STATION_STATUS_ARRIVING; +import static com.mogo.och.bus.constant.BusConst.STATION_STATUS_STOPPED; + +import android.content.Context; +import android.os.Handler; +import android.os.Message; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + +import com.alibaba.android.arouter.launcher.ARouter; +import com.amap.api.maps.model.LatLng; +import com.elegant.network.utils.GsonUtil; +import com.mogo.aicloud.services.socket.IMogoOnMessageListener; +import com.mogo.commons.AbsMogoApplication; +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.data.BaseData; +import com.mogo.eagle.core.data.autopilot.AutopilotControlParameters; +import com.mogo.eagle.core.data.config.FunctionBuildConfig; +import com.mogo.eagle.core.data.map.MogoLocation; +import com.mogo.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.call.autopilot.CallerAutoPilotControlManager; +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.utilcode.mogo.logger.CallerLogger; +import com.mogo.eagle.core.utilcode.util.CoordinateUtils; +import com.mogo.eagle.core.utilcode.util.NetworkUtils; +import com.mogo.eagle.core.utilcode.util.ToastUtils; +import com.mogo.eagle.core.utilcode.util.UiThreadHandler; +import com.mogo.och.bus.R; +import com.mogo.och.bus.bean.BusRoutePlanningUpdateReqBean; +import com.mogo.och.bus.bean.BusRoutesResponse; +import com.mogo.och.bus.bean.BusRoutesResult; +import com.mogo.och.bus.bean.BusStationBean; +import com.mogo.och.bus.bean.WriteOffPassenger; +import com.mogo.och.bus.callback.IBusADASStatusCallback; +import com.mogo.och.bus.callback.IBusControllerStatusCallback; +import com.mogo.och.bus.callback.IPassengerCallback; +import com.mogo.och.bus.callback.IRefreshBusStationsCallback; +import com.mogo.och.bus.callback.ISlidePannelHideCallback; +import com.mogo.och.bus.constant.BusConst; +import com.mogo.och.bus.net.OrderServiceManager; +import com.mogo.och.bus.presenter.BusModelLoopManager; +import com.mogo.och.bus.util.BusAnalyticsManager; +import com.mogo.och.bus.util.BusSendTripInfoManager; +import com.mogo.och.bus.util.BusTrajectoryManager; +import com.mogo.och.common.module.biz.common.socketmessage.OCHSocketMessageManager; +import com.mogo.och.common.module.biz.common.socketmessage.data.OCHOperationalMessage; +import com.mogo.och.common.module.biz.constant.OchCommonConst; +import com.mogo.och.common.module.biz.network.OchCommonServiceCallback; +import com.mogo.och.common.module.biz.provider.LoginService; +import com.mogo.och.common.module.callback.OchAdasStartFailureCallback; +import com.mogo.och.common.module.manager.AbnormalFactorsLoopManager; +import com.mogo.och.common.module.manager.OCHAdasAbilityManager; +import com.mogo.och.common.module.utils.CoordinateCalculateRouteUtil; +import com.mogo.och.common.module.utils.DateTimeUtil; +import com.mogo.och.common.module.utils.NumberFormatUtil; +import com.mogo.och.common.module.utils.PinYinUtil; +import com.mogo.och.common.module.utils.ToastUtilsOch; +import com.mogo.och.common.module.voice.VoiceManager; +import com.mogo.och.common.module.voice.VoiceNotice; + +import org.jetbrains.annotations.NotNull; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import io.reactivex.exceptions.UndeliverableException; +import io.reactivex.functions.Consumer; +import io.reactivex.plugins.RxJavaPlugins; +import mogo.telematics.pad.MessagePad; + +/** + * @author congtaowang + * @since 2021/3/23 + *

+ * 小巴订单管理 + */ +public class OrderModel { + private final String TAG = OrderModel.class.getSimpleName(); + private int currentLineId = -1; + private int currentTaskId = -1; + private int backgroundCurrentStationIndex = 0;//A->B 此处值是A站点索引 + + private static volatile OrderModel sInstance; + public double mLongitude = 0; + public double mLatitude = 0; + private Context mContext; + private final List stationList = new ArrayList<>(); + private BusRoutesResult busRoutesResult = null; + /** + * 用来表示是否正在开往下一站 + */ + private boolean isGoingToNextStation = false; + // 运营类型 + private static final int VEHICLE_TYPE = 10; + private static final int MSG_QUERY_BUS_STATION = 1001; + private static final long QUERY_BUS_STATION_DELAY = 5000; + + private IRefreshBusStationsCallback refreshBusStationsCallback; + private ISlidePannelHideCallback slidePanelHideCallback; + private IBusControllerStatusCallback mControllerStatusCallback; //Model->Presenter:VR mode等 + private IPassengerCallback mPassengerCallback; //乘客核销回调 + private IBusADASStatusCallback mADASStatusCallback; + + List points = new ArrayList<>();//全路径信息 + + private volatile boolean isArrivedStation = false; + + //0: 代表没有启动过 1代表是启动第一次,当>=1 代表是重试 每次到站/路线结束清空置为0 + private volatile int firstStartAutopilot = 0; + + private LoginService loginService; + + private final Handler handler = new Handler(new Handler.Callback() { + @Override + public boolean handleMessage(Message msg) { + if (msg.what == MSG_QUERY_BUS_STATION) { + queryBusRoutes(); + return true; + } + return false; + } + }); + + public static OrderModel getInstance() { + if (sInstance == null) { + synchronized (OrderModel.class) { + if (sInstance == null) { + sInstance = new OrderModel(); + } + } + } + return sInstance; + } + + private OrderModel() { + + } + + public void init() { + mContext = AbsMogoApplication.getApp(); + loginService = (LoginService) ARouter.getInstance().build(OchCommonConst.LOGINSERVICE).navigation(); + // 定位监听 + CallerChassisLocationGCJ02ListenerManager.INSTANCE.addListener(TAG, mMapLocationListener); + + MogoStatusManager.getInstance().registerStatusChangedListener(TAG, StatusDescriptor.VR_MODE, mMogoStatusChangedListener); + + //自动驾驶路线规划接口 + CallerPlanningRottingListenerManager.INSTANCE.addListener(TAG, moGoAutopilotPlanningListener); + + //开启自驾后 异常信息返回 + OCHAdasAbilityManager.getInstance().setAdasStartFailureCallback(mAdasStartFailureListener); + + OCHSocketMessageManager.INSTANCE.registerSocketMessageListener(//监听运营消息 + OCHSocketMessageManager.msgMonitorType, + mMogoOnMessageListener); + + OCHSocketMessageManager.INSTANCE.registerSocketMessageListener(//监听核销乘客 + OCHSocketMessageManager.msgWriteOffPassengerType, + mWriteOffPassengeOnMessageListener); + + AbnormalFactorsLoopManager.INSTANCE.startLoopAbnormalFactors(mContext); + + //2022.1.28 + // 调用Disposable.dispose() 时候会出现InterruptedException 导致出现崩溃 + // The exception could not be delivered to the consumer because it has already canceled/disposed + // the flow or the excTeption has nowhere to go to begin with + RxJavaPlugins.setErrorHandler(new Consumer() { + @Override + public void accept(Throwable e) { + if (e instanceof UndeliverableException) { + e = e.getCause(); + CallerLogger.INSTANCE.d(M_BUS + TAG, "UndeliverableException"); + } + if ((e instanceof IOException)) {// + // fine, irrelevant network problem or API that throws on cancellation + CallerLogger.INSTANCE.d(M_BUS + TAG, "IOException"); + return; + } + if (e instanceof InterruptedException) { + // fine, some blocking code was interrupted by a dispose call + CallerLogger.INSTANCE.d(M_BUS + TAG, "InterruptedException"); + return; + } + if ((e instanceof NullPointerException) || (e instanceof IllegalArgumentException)) { + // that's likely a bug in the application + CallerLogger.INSTANCE.d(M_BUS + TAG, "NullPointerException or IllegalArgumentException"); + Thread.currentThread().getUncaughtExceptionHandler().uncaughtException(Thread.currentThread(), e); + return; + } + if (e instanceof IllegalStateException) { + // that's a bug in RxJava or in a custom operator + CallerLogger.INSTANCE.d(M_BUS + TAG, "IllegalStateException"); + Thread.currentThread().getUncaughtExceptionHandler().uncaughtException(Thread.currentThread(), e); + return; + } + CallerLogger.INSTANCE.d(M_BUS + TAG, "Undeliverable exception"); + } + }); + } + + private final IMogoOnMessageListener mMogoOnMessageListener = + new IMogoOnMessageListener() { + @Override + public Class target() { + return OCHOperationalMessage.class; + } + + @Override + public void onMsgReceived(OCHOperationalMessage obj) { + if (obj == null){ + CallerLogger.INSTANCE.d(M_BUS + TAG, "onMsgReceived = null"); + return; + } + CallerLogger.INSTANCE.i(M_BUS + TAG,"onMsgReceived = "+obj.getMessage()); + OCHSocketMessageManager.INSTANCE.pushAppOperationalMsgBox(DateTimeUtil.getCurrentTimeStamp(), + obj.getMessage(),OCHSocketMessageManager.OPERATION_SYSTEM); + } + }; + + private final IMogoOnMessageListener mWriteOffPassengeOnMessageListener = + new IMogoOnMessageListener() { + @Override + public Class target() { + return WriteOffPassenger.class; + } + + @Override + public void onMsgReceived(WriteOffPassenger passenger) { + //进行播报 + CallerLogger.INSTANCE.i(M_BUS + TAG,"passenger = "+ GsonUtil.jsonFromObject(passenger)); + if (passenger != null && passenger.passengerSize == 0) return; + if (mPassengerCallback != null){ + mPassengerCallback.playPassenger(passenger); + } + } + }; + + public void setAdasStatusCallback(IBusADASStatusCallback callback){ + this.mADASStatusCallback = callback; + } + + public void setRefreshBusStationsCallback(IRefreshBusStationsCallback callback){ + this.refreshBusStationsCallback = callback; + } + + public void setPassengerCallback(IPassengerCallback callback) { + this.mPassengerCallback = callback; + } + + public void setSlidePanelHideCallback(ISlidePannelHideCallback callback) { + this.slidePanelHideCallback = callback; + } + + public void setControllerStatusCallback(IBusControllerStatusCallback callback) { + this.mControllerStatusCallback = callback; + } + + private final IMoGoPlanningRottingListener moGoAutopilotPlanningListener = new IMoGoPlanningRottingListener() { + + @Override + public void onAutopilotRotting(MessagePad.GlobalPathResp routeList) { + if (null != routeList && routeList.getWayPointsList().size() > 0) { + points.clear(); + points.addAll(coordinateConverterWgsToGcjList(mContext, routeList.getWayPointsList())); + updateOrderRoute(); + } + } + + }; + + public static List coordinateConverterWgsToGcjList(Context mContext, List mogoLatLngList) { + List points = new ArrayList<>(); + for (MessagePad.Location m : mogoLatLngList) { + LatLng mogoLatLng = CoordinateCalculateRouteUtil.coordinateConverterWgsToGcj(mContext, m); + BusRoutePlanningUpdateReqBean.Result result = new BusRoutePlanningUpdateReqBean.Result(); + result.latitude = mogoLatLng.latitude; + result.longitude = mogoLatLng.longitude; + points.add(result); + } + return points; + } + + /** + * 上报订单全路径规划数据 + */ + public void updateOrderRoute() { + if (!isGoingToNextStation || backgroundCurrentStationIndex + 1 >= stationList.size() || points.size() == 0) { + return; + } + + BusStationBean currentStation = stationList.get(backgroundCurrentStationIndex); + BusStationBean nextStation = stationList.get(backgroundCurrentStationIndex + 1); + + OrderServiceManager.updateOrderRoute(mContext, currentLineId, currentStation.getSiteId() + , nextStation.getSiteId(), points, new OchCommonServiceCallback() { + @Override + public void onSuccess(BaseData o) { + + } + + @Override + public void onFail(int code, String failMsg) { + if (isGoingToNextStation) {//重试 + updateOrderRoute(); + } + } + }); + } + + public void debugUpdateOrderRoute(List list) { + points.clear(); + points.addAll(coordinateConverterWgsToGcjList(mContext, list)); + updateOrderRoute(); + } + + public void release() { + + startOrStopOrderLoop(false); + //startOrStopQueryPassengerWriteOff(false); + MogoStatusManager.getInstance().unregisterStatusChangedListener(TAG, StatusDescriptor.VR_MODE, mMogoStatusChangedListener); + + // 注销定位监听 + CallerChassisLocationGCJ02ListenerManager.INSTANCE.removeListener(TAG); + + //自动驾驶路线规划接口 + CallerPlanningRottingListenerManager.INSTANCE.removeListener(moGoAutopilotPlanningListener); + loginService = null; + + OCHAdasAbilityManager.getInstance().setAdasStartFailureCallback(null); + + OCHSocketMessageManager.INSTANCE.releaseSocketMessageListener( + OCHSocketMessageManager.msgMonitorType); + OCHSocketMessageManager.INSTANCE.releaseSocketMessageListener( + OCHSocketMessageManager.msgWriteOffPassengerType); + + AbnormalFactorsLoopManager.INSTANCE.stopLoopAbnormalFactors(); + } + + private Object readResolve() { + // 阻止反序列化,必须实现 Serializable 接口 + return sInstance; + } + + private final IMogoStatusChangedListener mMogoStatusChangedListener = new IMogoStatusChangedListener() { + // VR mode变更回调 + @Override + public void onStatusChanged(StatusDescriptor descriptor, boolean isTrue) { + if (StatusDescriptor.VR_MODE == descriptor) { + if (mControllerStatusCallback != null) { + mControllerStatusCallback.onVRModeChanged(isTrue); + } + } + } + }; + + private final OchAdasStartFailureCallback mAdasStartFailureListener = new OchAdasStartFailureCallback() { + @Override + public void onStartAutopilotFailure(@NotNull String startFailedCode, @NonNull String startFailedMessage) { + BusAnalyticsManager.getInstance().triggerStartAutopilotFailureEventByAdas(startFailedCode, startFailedMessage); + if (mADASStatusCallback != null && !FunctionBuildConfig.isDemoMode){ + CallerLogger.INSTANCE.e( M_BUS + TAG, "mAdasStartFailureListener = "+startFailedMessage ); + mADASStatusCallback.onStartAdasFailure(); + } + } + }; + + // 自车定位 + private final IMoGoChassisLocationGCJ02Listener mMapLocationListener = new IMoGoChassisLocationGCJ02Listener() { + @Override + public void onChassisLocationGCJ02(@Nullable MogoLocation gnssInfo) { + if (null == gnssInfo) return; + mLongitude = gnssInfo.getLongitude(); + mLatitude = gnssInfo.getLatitude(); + if (mControllerStatusCallback != null) { + mControllerStatusCallback.onCarLocationChanged(gnssInfo); + } + + //是否到站的围栏判断 离站状态并且自动驾驶还未触发到站 + if (isGoingToNextStation && !isArrivedStation) { + judgeArrivedStation(gnssInfo); + } + } + }; + + //根据围栏判断,是否到达站点 + private void judgeArrivedStation(MogoLocation location) { + + if (backgroundCurrentStationIndex + 1 > stationList.size() - 1) { + CallerLogger.INSTANCE.e(M_BUS + TAG, "到站数组越界"); + return; + } + BusStationBean upcomingStation = stationList.get(backgroundCurrentStationIndex + 1); + + double startLon = upcomingStation.getGcjLon(); + double startLat = upcomingStation.getGcjLat(); + double distance = CoordinateUtils.calculateLineDistance( + startLon, startLat, + location.getLongitude(), location.getLatitude()); + + if (distance <= BusConst.ARRIVE_AT_END_STATION_DISTANCE) { + CallerLogger.INSTANCE.d(M_BUS + TAG, "行程日志-judgeArrivedStation() distance = " + distance + + " to " + upcomingStation.getName()); + onArriveAt(null); //无自动驾驶到站信息传null + return; + } + } + + /** + * 查询小巴路线 + */ + public void queryBusRoutes() { + CallerLogger.INSTANCE.d(M_BUS + TAG, "查询小巴路线"); + OrderServiceManager.queryBusRoutes(mContext, new OchCommonServiceCallback() { + @Override + public void onSuccess(BusRoutesResponse data) { + if (data == null + || data.getResult() == null + || data.getResult().getSites() == null + || data.getResult().getSites().isEmpty()) { + //当为空时,显示无绑定路线图 + CallerLogger.INSTANCE.d(M_BUS + TAG, "获取到小巴路线数据:空 "); + if (refreshBusStationsCallback != null) { + refreshBusStationsCallback.updateEmptyUi(); + } + clearAutopilotControlParameters(); + closeBeautificationMode(); + clearStartAutopilotTag(); + removeTipRunnables(); + return; + } + CallerLogger.INSTANCE.d(M_BUS + TAG, "获取到小巴路线数据: " + data); + updateBusStatus(data.getResult()); + } + + + @Override + public void onError() { + if (!NetworkUtils.isConnected(mContext)) { + ToastUtils.showShort(mContext.getString(R.string.network_error_tip)); + } else { + ToastUtils.showShort(mContext.getString(R.string.request_error_tip)); + } + } + + @Override + public void onFail(int code, String failMsg) { + if (!NetworkUtils.isConnected(mContext)) { + ToastUtils.showShort("网络异常,请稍后重试"); + }else { + ToastUtils.showShort(failMsg); + } + } + }); + + } + + /** + * 更新正在运行的任务UI + * + * @param stations + */ + private void updateBusTaskStatus(List stations) { + + int arrivingOrArrivedStationIndex = 0;//已经到站或者即将到站的索引呢 + + for (int i = 0; i < stations.size(); i++) { + BusStationBean station = stations.get(i); + + if (i == 0) { // 首发站 显示在最上面 + if (station.getDrivingStatus() == STATION_STATUS_STOPPED + && !station.isLeaving()) { //到达第一站 + arrivingOrArrivedStationIndex = i; + break; + } + } else { + BusStationBean preStation = stations.get(i - 1); + if ((station.getDrivingStatus() == STATION_STATUS_STOPPED && !station.isLeaving()) + || (station.getDrivingStatus() == STATION_STATUS_ARRIVING + && preStation.isLeaving())) { + //到站未离开 | 即将到站 显示在最中间 + arrivingOrArrivedStationIndex = i; + break; + } + } + } + + BusStationBean arrivingOrArrivedStation = stations.get(arrivingOrArrivedStationIndex); + + String lineTime = DateTimeUtil.formatLongToString( + busRoutesResult.getTaskTime(), + DateTimeUtil.HH_mm); + + if (arrivingOrArrivedStationIndex == 0 || + arrivingOrArrivedStation.getDrivingStatus() == STATION_STATUS_STOPPED + && !arrivingOrArrivedStation.isLeaving()) { + if (refreshBusStationsCallback != null) { + refreshBusStationsCallback.updateBusTaskStatus(busRoutesResult.getName(), lineTime, + stationList, arrivingOrArrivedStationIndex, true); + } + clearAutopilotControlParameters(); + } else { + if (refreshBusStationsCallback != null) { + refreshBusStationsCallback.updateBusTaskStatus(busRoutesResult.getName(), lineTime, + stationList, arrivingOrArrivedStationIndex, false); + } + updateAutopilotControlParameters(); + } + } + + /** + * 重置路线站点状态--结束路线,当前路线恢复到始发站 + */ + public void abortTask() { + CallerLogger.INSTANCE.d(M_BUS + TAG, "结束当前路线abortTask"); + OrderServiceManager.abortTask(mContext, currentTaskId + , new OchCommonServiceCallback() { + @Override + public void onSuccess(BaseData o) { + CallerLogger.INSTANCE.d(M_BUS + TAG, "abortTask success: " + o); + if (o.code == 0) { // 重置成功 + endOrAbortTaskSuccess(); + clearBusStationDatas(); + queryBusRoutes(); + removeTipRunnables(); + // startOrStopQueryPassengerWriteOff(false); + } + } + + @Override + public void onError() { + if (!NetworkUtils.isConnected(mContext)) { + ToastUtils.showShort(mContext.getString(R.string.network_error_tip)); + } else { + ToastUtils.showShort(mContext.getString(R.string.request_error_tip)); + } + } + + @Override + public void onFail(int code, String failMsg) { + if (!NetworkUtils.isConnected(mContext)) { + ToastUtils.showShort("网络异常,请稍后重试"); + }else { + ToastUtils.showShort(failMsg); + } + } + }); + + } + + /** + * 中断或者正常结束任务后的处理 + */ + private void endOrAbortTaskSuccess() { + + isGoingToNextStation = false; + backgroundCurrentStationIndex = 0; + + if (busRoutesResult != null) { + BusSendTripInfoManager.INSTANCE.sendBusTripInfo(BusSendTripInfoManager.END_TRIP + , busRoutesResult.getName() + , "" + , "" + , false); + } + } + + /** + * 离站上报成功后渲染站点 + * 服务端返回的OchBusRoutesResult逻辑, 离开站为当前站, 到达下一站后才会将下一站置为当前站, + * 车机端展示是离开当前站,下一站设置为当前站, 所以服务端数据回来要做处理,不能直接渲染 + */ + private void leaveStationSuccess(int leaveIndex, String leaveStation, String nextStation) { + + onStartAutopilot(leaveIndex); + + leaveTTSTips(nextStation); + + if (busRoutesResult != null) { + boolean isLastStop = false; + if (leaveIndex + 1 == stationList.size() - 1) { + isLastStop = true; + } + //给bus外屏发送 + BusSendTripInfoManager.INSTANCE.sendBusTripInfo(BusSendTripInfoManager.LEAVE_STATION + , busRoutesResult.getName() + , leaveStation + , nextStation + , isLastStop); + } + } + + private void onStartAutopilot(int leaveIndex) { + //开启自动驾驶 2.10.0: 如果自动驾驶状态下开启, 非自动驾驶状态下不开启,需手动点击自动驾驶按钮开启 + isGoingToNextStation = true; + if (CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState() + == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING) { + startAutopilot(false, leaveIndex); + } else { + firstStartAutopilot = 0; + } + } + + /** + * 开启自动驾驶 + * + * @param isRestart + */ + private void startAutopilot(boolean isRestart, int leaveIndex) { + + if (!FunctionBuildConfig.isDemoMode && !OCHAdasAbilityManager.getInstance().getAutopilotAbilityStatus()) { + ToastUtils.showLong(OCHAdasAbilityManager.getInstance().getAutopilotUnAbilityReason() + + ", 请稍候重试"); + triggerUnableStartAPReasonEvent(); + return; + } + + firstStartAutopilot++; + + triggerStartServiceEvent(isRestart, false); + + AutopilotControlParameters parameters = initAutopilotControlParameters(leaveIndex); + if (null == parameters) { + CallerLogger.INSTANCE.e(M_BUS + TAG, "行程日志-AutopilotControlParameters is empty."); + return; + } + + CallerAutoPilotControlManager.INSTANCE.startAutoPilot(parameters); + + CallerLogger.INSTANCE.d(M_BUS + TAG, "行程日志-开启自动驾驶====" + GsonUtil.jsonFromObject(parameters) + + " startLatLon=" + parameters.startName + ",endLatLon=" + parameters.endName + + "isRestart = " + isRestart); + + if (mControllerStatusCallback != null) { + mControllerStatusCallback.startOpenAutopilot(); + } + } + + /** + * 到站后重置站点状态 + */ + private void arriveSiteStation() { + if ( backgroundCurrentStationIndex +1 > stationList.size() - 1 ) { //到站短时间内调用多次 + CallerLogger.INSTANCE.e( M_BUS + TAG, "数组越界" ); + return; + } + int arrivedStationIndex = backgroundCurrentStationIndex + 1; + String arriveStation = stationList.get(arrivedStationIndex).getName(); + String departureStopName = stationList.get(backgroundCurrentStationIndex).getName(); + CallerLogger.INSTANCE.d(M_BUS + TAG, "arriveSiteStation-currentStationIndex = " + arrivedStationIndex); + + OrderServiceManager.arriveSiteStation(mContext, + stationList.get(arrivedStationIndex).getSeq(), + stationList.get(arrivedStationIndex).getSiteId(), + currentTaskId, + new OchCommonServiceCallback() { + @Override + public void onSuccess(BaseData o) { + CallerLogger.INSTANCE.d(M_BUS + TAG, "行程日志-arriveSiteStation success"); + if (o != null && o.code == 0){ + queryBusRoutes(); + isArrivedStation = true; + isGoingToNextStation = false; + arriveStationSuccess(arrivedStationIndex, departureStopName, arriveStation); + } + //5s轮询核销乘客 +// startOrStopQueryPassengerWriteOff(true); + } + + @Override + public void onError() { + if (!NetworkUtils.isConnected(mContext)) { + ToastUtils.showShort(mContext.getString(R.string.network_error_tip)); + } else { + ToastUtils.showShort(mContext.getString(R.string.request_error_tip)); + } + } + + @Override + public void onFail(int code, String failMsg) { + if (ToastUtilsOch.isCustomFastClick(5000)) { + if (!NetworkUtils.isConnected(mContext)) { + ToastUtils.showShort("网络异常,请稍后重试"); + } else { + if (isArrivedStation) return; + ToastUtils.showShort(failMsg); + } + } + } + }); + } + + private void arriveStationSuccess(int arrivedStationIndex, String departureStopName, String arriveStation) { + if (busRoutesResult != null) { + boolean isLastStop = false; + if (arrivedStationIndex == busRoutesResult.getSites().size() - 1) { + isLastStop = true; + } + //给bus外屏发送 + BusSendTripInfoManager.INSTANCE.sendBusTripInfo(BusSendTripInfoManager.ARRIVE_STATION + , busRoutesResult.getName() + , departureStopName + , arriveStation + , isLastStop); + } + VoiceManager.INSTANCE.arrivedStation(arriveStation); + } + + /** + * 离站上报 + */ + public void leaveStation() { + CallerLogger.INSTANCE.d(M_BUS + TAG, "leaveStation-backgroundCurrentStationIndex = " + backgroundCurrentStationIndex); + String nextStationName = ""; + if (backgroundCurrentStationIndex < stationList.size() - 1) { + nextStationName = stationList.get(backgroundCurrentStationIndex + 1).getName(); + } + final String currentStationName = stationList.get(backgroundCurrentStationIndex).getName(); + String finalNextStationName = nextStationName; + OrderServiceManager.leaveStation(mContext, + stationList.get(backgroundCurrentStationIndex).getSeq(), + stationList.get(backgroundCurrentStationIndex).getSiteId(), + currentTaskId, + new OchCommonServiceCallback() { + @Override + public void onSuccess(BaseData o) { + isArrivedStation = false; + CallerLogger.INSTANCE.d(M_BUS + TAG, "行程日志-离站成功开往下一站===="); + //需要更改当前站和下一站的状态 然后渲染 + //startOrStopQueryPassengerWriteOff(false); + queryBusRoutes(); + leaveStationSuccess(backgroundCurrentStationIndex, currentStationName, finalNextStationName); + } + + + @Override + public void onError() { + if (!NetworkUtils.isConnected(mContext)) { + ToastUtils.showShort(mContext.getString(R.string.network_error_tip)); + } else { + ToastUtils.showShort(mContext.getString(R.string.request_error_tip)); + } + } + + @Override + public void onFail(int code, String failMsg) { + if (!NetworkUtils.isConnected(mContext)) { + ToastUtils.showShort("网络异常,请稍后重试"); + } else { + ToastUtils.showShort("离站上报失败:" + failMsg); + } + } + }); + } + + //车站10s后播报 + private void leaveTTSTips(String nextStation) { + + UiThreadHandler.postDelayed(new Runnable() { + @Override + public void run() { + VoiceManager.INSTANCE.leaveStation(nextStation); + } + },DELAY_10S); + } + + /** + * 关闭美化模式 + */ + public void closeBeautificationMode() { + if (FunctionBuildConfig.isDemoMode) {//收车结束美化 + FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData = false; //是否强制绘制引导线 + CallerAutoPilotControlManager.INSTANCE.setIgnoreConditionDraw(false);// 同步给乘客屏 + CallerAutoPilotControlManager.INSTANCE.setIPCDemoMode(false);//是否自动启动自驾 + CallerLogger.INSTANCE.d(M_BUS + TAG, "美化模式-ignore:置为false"); + } + } + + /** + * 开启自动驾驶到下一站 + */ + public void autoDriveToNextStation() { + if (backgroundCurrentStationIndex >= stationList.size() - 1) { + // 当前站是最后一站,结束当前行程 + travelOver(); + return; + } + leaveStation(); + } + + /** + * 渲染站点信息 + * 服务端返回的OchBusRoutesResult逻辑, 离开站为当前站, 到达下一站后才会将下一站置为当前站, + * 车机端展示 三站: 中间为即将到到达或者刚到达的站 + * + * @param result + */ + private void updateBusStatus(BusRoutesResult result) { + if (result == null) return; + busRoutesResult = result; + List site = result.getSites(); + currentTaskId = result.getTaskId(); + currentLineId = result.getLineId(); + stationList.clear(); + stationList.addAll(site); + + for (int i = 0; i < stationList.size(); i++) { + BusStationBean s = stationList.get(i); + + CallerLogger.INSTANCE.d(M_BUS + "updateBusStationsStatus--", + "Index=" + i + " ,name = " + s.getName() + " ," + s.isLeaving() + "," + s.getDrivingStatus()); + + // 是否正在开往下一站 + if (s.isLeaving()) { + isGoingToNextStation = true; + } + // 当前站点信息 + if (s.getDrivingStatus() == STATION_STATUS_STOPPED) { + backgroundCurrentStationIndex = i; + break; + } + } + + if (backgroundCurrentStationIndex == 0 && + stationList.get(0).getDrivingStatus() == STATION_STATUS_STOPPED + && !stationList.get(0).isLeaving()) { //默认是第一站到站查询 + if (busRoutesResult != null) { // 第一站到站也是行程开始的时候 + BusSendTripInfoManager.INSTANCE.sendBusTripInfo(BusSendTripInfoManager.START_TRIP + , busRoutesResult.getName(), "", "", false); + } + + //任务选择后首发前给司机提示任务 + if (busRoutesResult != null){ + beforeTaskTips(); + } +// startOrStopQueryPassengerWriteOff(true); + }else { + removeTipRunnables(); + } + + BusStationBean currentStation = stationList.get(backgroundCurrentStationIndex); + + CallerLogger.INSTANCE.d(M_BUS + TAG, + "行程日志-STATION_STATUS_STOPPED-backgroundCurrentStationIndex=" + + backgroundCurrentStationIndex + + " isLeaving()=" + currentStation.isLeaving()); + + // 美化是否开始 + if (FunctionBuildConfig.isDemoMode && (backgroundCurrentStationIndex >= 0 + && backgroundCurrentStationIndex <= stationList.size() - 1)) {//行驶过程中设置美化 + if (stationList.get(backgroundCurrentStationIndex).isLeaving()) { + startBeautificationMode(); + CallerLogger.INSTANCE.d(M_BUS + TAG, "美化模式-ignore:置为true(每次滑动出发)"); + } else if (backgroundCurrentStationIndex > 0 && backgroundCurrentStationIndex < stationList.size() - 1) { + //美化模式下 中间站点到站 引导线要一直绘制,所以此处不出强制绘制不传false + CallerAutoPilotControlManager.INSTANCE.setIPCDemoMode(false); + CallerLogger.INSTANCE.d(M_BUS + TAG, "美化模式-ignore:false(到达中间站)"); + clearStartAutopilotTag(); + } else { + closeBeautificationMode(); + clearStartAutopilotTag(); + } + } + + + if (currentStation.isLeaving() && slidePanelHideCallback != null) { + slidePanelHideCallback.hideSlidePanel(); + } + + //更新bus路线面板 + updateBusTaskStatus(stationList); + + //需放在currentStationIndex赋值之后 + BusTrajectoryManager.getInstance().syncTrajectoryInfo(); + } + + private void beforeTaskTips() { + if (busRoutesResult == null) return; + + removeTipRunnables(); + + long taskTime = busRoutesResult.getTaskTime(); + long tip3Time = taskTime- 3*60*1000 - DateTimeUtil.getCurrentTimeStamp(); // 首站离开前3分钟提示 + long tip1Time = taskTime-60*1000 - DateTimeUtil.getCurrentTimeStamp(); // 首站离开前1分钟提示 + + if (tip3Time > 0){ + UiThreadHandler.postDelayed(tip3Runnable,tip3Time); + } + + if (tip1Time > 0){ + UiThreadHandler.postDelayed(tip1Runnable,tip1Time); + } + } + + Runnable tip3Runnable = new Runnable() { + @Override + public void run() { + + if (backgroundCurrentStationIndex == 0 && stationList.get(0).getDrivingStatus() == STATION_STATUS_STOPPED + && !stationList.get(0).isLeaving()){ + tipStartTask("3"); + }else { + removeTipRunnables(); + } + } + }; + + private void tipStartTask(String s) { + String tips = String.format(mContext + .getString(R.string.bus_before_tips_s), s); + //展示在运营消息 + OCHSocketMessageManager.INSTANCE.pushAppOperationalMsgBox( + DateTimeUtil.getCurrentTimeStamp(), + tips,OCHSocketMessageManager.OPERATION_SYSTEM); + //语音提示 + VoiceNotice.showNotice(tips); + } + + Runnable tip1Runnable = new Runnable() { + @Override + public void run() { + if (backgroundCurrentStationIndex == 0 && stationList != null && + stationList.get(0).getDrivingStatus() == STATION_STATUS_STOPPED + && !stationList.get(0).isLeaving()){ + tipStartTask("1"); + }else { + removeTipRunnables(); + } + } + }; + + public void removeTipRunnables(){ + if (tip3Runnable != null){ + UiThreadHandler.removeCallbacks(tip3Runnable); + } + if (tip1Runnable != null){ + UiThreadHandler.removeCallbacks(tip1Runnable); + } + } + + private void clearStartAutopilotTag() { + firstStartAutopilot = 0; + } + + private void startBeautificationMode() { + FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData = true; + CallerAutoPilotControlManager.INSTANCE.setIgnoreConditionDraw(true); + CallerAutoPilotControlManager.INSTANCE.setIPCDemoMode(true); + } + + public void clearBusStationDatas() { + if (refreshBusStationsCallback != null) { + refreshBusStationsCallback.clearBusStationsMarkers(); + } + } + + /** + * 延时查询站点信心 + */ + private void queryBusStationDelay() { + handler.sendEmptyMessageDelayed(MSG_QUERY_BUS_STATION, QUERY_BUS_STATION_DELAY); + } + + /** + * 在踩刹车、控制方向盘等操作后,会停止自动驾驶,重启自动驾驶的话相当于重新设置自动驾驶目的地 + */ + public void restartAutopilot() { + CallerLogger.INSTANCE.d(M_BUS + TAG, "行程日志-重启自动驾驶===" + isGoingToNextStation); + //只去启动自动驾驶,不再去上报离站 + startAutopilot(firstStartAutopilot >= 1, -1); + } + + public boolean isRestartAutopilot() { + return firstStartAutopilot > 1; + } + + /** + * 行程结束 + */ + private void travelOver() { + + if (backgroundCurrentStationIndex >= stationList.size()) { + CallerLogger.INSTANCE.e(M_BUS + TAG, "travel over index out of station list"); + return; + } + CallerLogger.INSTANCE.d(M_BUS + TAG, "单程结束===="); + CallerAutoPilotControlManager.INSTANCE.cancelAutoPilot(); + + endTask(); + } + + /** + * task正常结束 + */ + private void endTask() { + CallerLogger.INSTANCE.d(M_BUS + TAG, "任务正常走完endTask()"); + OrderServiceManager.endTask(mContext, currentTaskId + , new OchCommonServiceCallback() { + @Override + public void onSuccess(BaseData o) { + CallerLogger.INSTANCE.d(M_BUS + TAG, "endTask success: " + o); + if (o.code == 0) { + endOrAbortTaskSuccess(); + clearBusStationDatas(); + queryBusRoutes();// 重新获取任务 + removeTipRunnables(); +// startOrStopQueryPassengerWriteOff(false); + ttsEndTask(); + } + } + + @Override + public void onError() { + if (!NetworkUtils.isConnected(mContext)) { + ToastUtils.showShort(mContext.getString(R.string.network_error_tip)); + } else { + ToastUtils.showShort(mContext.getString(R.string.request_error_tip)); + } + } + + @Override + public void onFail(int code, String failMsg) { + if (!NetworkUtils.isConnected(mContext)) { + ToastUtils.showShort("网络异常,请稍后重试"); + }else { + ToastUtils.showShort(failMsg); + } + } + }); + } + + private void ttsEndTask() { + VoiceManager.INSTANCE.endOrder(); + } + + /** + * 到站 + * + * @param data + */ + public void onArriveAt(MessagePad.ArrivalNotification data) { + if (backgroundCurrentStationIndex + 1 > stationList.size() - 1) { + CallerLogger.INSTANCE.e(M_BUS + TAG, "行程日志-到站异常,取消后续操作结束"); + return; + } + + //MAP 280 每隔100ms左右返回一次到站, 导致在到达中间站后再次滑动出发后会有时间差,收到一次到站,出现问题 + //此处比对 自驾告诉的到站站点坐标和本地应到站站点坐标, 一致时才能到站 + if (data != null && data.getEndLocation() != null) { + + String latitude = NumberFormatUtil.cutOutNumber(data.getEndLocation().getLatitude(), 5); //wgs + String longitude = NumberFormatUtil.cutOutNumber(data.getEndLocation().getLongitude(), 5); + + int arrivedStationIndex = backgroundCurrentStationIndex + 1; + BusStationBean arriveStation = stationList.get(arrivedStationIndex); + String arriveLat = NumberFormatUtil.cutOutNumber(arriveStation.getLat(), 5); + String arriveLon = NumberFormatUtil.cutOutNumber(arriveStation.getLon(), 5); + + if (!latitude.equals(arriveLat) || !longitude.equals(arriveLon)) { + CallerLogger.INSTANCE.e(M_BUS + TAG, "行程日志-到站拦截,到站坐标不一致"); + return; + } + } + + if (isArrivedStation) return; + + CallerLogger.INSTANCE.d(M_BUS + TAG, "行程日志-当前==backgroundCurrentStationIndex=" + + backgroundCurrentStationIndex); + + arriveSiteStation(); + } + + public boolean isGoingToNextStation() { + return isGoingToNextStation; + } + + public void sendWriteOffNumToClient(String msg){ + } + + // 车机端上传心跳数据(只在出车状态时上传) + public void runCarHeartbeat() { + OrderServiceManager.runCarHeartbeat(mContext, mLongitude, mLatitude, + new OchCommonServiceCallback() { + @Override + public void onSuccess(BaseData data) { + + } + + @Override + public void onFail(int code, String failMsg) { + + } + }); + } + + public void startOrStopOrderLoop(boolean start) { + CallerLogger.INSTANCE.d(M_BUS + TAG, "startOrStopOrderLoop() " + start); + if (start) { + BusModelLoopManager.getInstance().startHeartbeatLoop(); + } else { + BusModelLoopManager.getInstance().stopHeartbeatLoop(); + } + } + + // 登出 + public void logout() { + loginService.loginOut(mLatitude, mLongitude); + } + + public void triggerStartServiceEvent(boolean isRestart, boolean send) { + if (stationList == null || backgroundCurrentStationIndex >= stationList.size() - 1) { + return; + } + BusStationBean currentStation = stationList.get(backgroundCurrentStationIndex); + BusStationBean nextStation = stationList.get(backgroundCurrentStationIndex + 1); + BusAnalyticsManager.getInstance().triggerStartAutopilotEvent(isRestart, send, + currentStation.getName(), nextStation.getName(), currentLineId); + } + + public void triggerUnableStartAPReasonEvent() { + if (stationList == null || backgroundCurrentStationIndex >= stationList.size() - 1) { + return; + } + BusStationBean currentStation = stationList.get(backgroundCurrentStationIndex); + BusStationBean nextStation = stationList.get(backgroundCurrentStationIndex + 1); + BusAnalyticsManager.getInstance().triggerUnableStartAPReasonEvent( + currentStation.getName(), nextStation.getName(), currentLineId, + OCHAdasAbilityManager.getInstance().getAutopilotUnAbilityReason()); + } + + public BusRoutesResult getBusRoutesResult() { + return busRoutesResult; + } + + public int getCurrentStationIndex() { + return backgroundCurrentStationIndex; + } + + /** + * 将业务订单信息保存,鹰眼可取用 + */ + private void updateAutopilotControlParameters() { + + AutopilotControlParameters parameters = initAutopilotControlParameters(-1); + if (null == parameters) { + CallerLogger.INSTANCE.e(M_BUS + TAG, "AutopilotControlParameters is empty."); + return; + } + CallerLogger.INSTANCE.d(M_BUS + TAG, "AutopilotControlParameters is update."); + CallerAutoPilotStatusListenerManager.INSTANCE.updateAutopilotControlParameters(parameters); + } + + private void clearAutopilotControlParameters() { + CallerLogger.INSTANCE.d(M_BUS + TAG, "AutopilotControlParameters is clear."); + CallerAutoPilotStatusListenerManager.INSTANCE.updateAutopilotControlParameters(null); + } + + private AutopilotControlParameters initAutopilotControlParameters(int leaveIndex) { + BusStationBean currentStation = null; + BusStationBean nextStation = null; + + if (leaveIndex < 0) { + if (backgroundCurrentStationIndex + 1 > stationList.size() - 1 || !isGoingToNextStation) { + CallerLogger.INSTANCE.e(M_BUS + TAG, "行程日志-mismatch condition1."); + return null; + } + currentStation = stationList.get(backgroundCurrentStationIndex); + nextStation = stationList.get(backgroundCurrentStationIndex + 1); + } else { + if (leaveIndex + 1 > stationList.size() - 1 || !isGoingToNextStation) { + CallerLogger.INSTANCE.e(M_BUS + TAG, "行程日志-mismatch condition2."); + return null; + } + currentStation = stationList.get(leaveIndex); + nextStation = stationList.get(leaveIndex + 1); + } + + AutopilotControlParameters parameters = new AutopilotControlParameters(); + parameters.routeID = busRoutesResult.getLineId(); + parameters.routeName = busRoutesResult.getName(); + parameters.startName = PinYinUtil.getPinYinHeadChar(currentStation.getName()); + parameters.endName = PinYinUtil.getPinYinHeadChar(nextStation.getName()); + parameters.startLatLon = new AutopilotControlParameters + .AutoPilotLonLat(currentStation.getLat(), currentStation.getLon()); + parameters.endLatLon = new AutopilotControlParameters + .AutoPilotLonLat(nextStation.getLat(), nextStation.getLon()); + parameters.vehicleType = VEHICLE_TYPE; + if (parameters.autoPilotLine == null) { + parameters.autoPilotLine = new AutopilotControlParameters.AutoPilotLine( + busRoutesResult.getLineId(), + busRoutesResult.csvFileUrl, busRoutesResult.csvFileMd5, + busRoutesResult.txtFileUrl, busRoutesResult.txtFileMd5, + busRoutesResult.contrailSaveTime, busRoutesResult.carModel, + busRoutesResult.csvFileUrlDPQP, busRoutesResult.csvFileMd5DPQP, + busRoutesResult.txtFileUrlDPQP, busRoutesResult.txtFileMd5DPQP, + busRoutesResult.contrailSaveTimeDPQP); + } + + return parameters; + } +} diff --git a/OCH/mogo-och-bus/src/jinlvvan/java/com/mogo/och/bus/net/IBascApiService.java b/OCH/mogo-och-bus/src/jinlvvan/java/com/mogo/och/bus/net/IBascApiService.java new file mode 100644 index 0000000000..de33669f49 --- /dev/null +++ b/OCH/mogo-och-bus/src/jinlvvan/java/com/mogo/och/bus/net/IBascApiService.java @@ -0,0 +1,164 @@ +package com.mogo.och.bus.net; +import com.mogo.eagle.core.data.BaseData; +import com.mogo.och.bus.bean.BusCloseTaskRequest; +import com.mogo.och.bus.bean.BusOrdersResponse; +import com.mogo.och.bus.bean.BusQueryWriteOffPassengersResponse; +import com.mogo.och.bus.bean.BusWriteOffPassengersQueryRequest; +import com.mogo.och.bus.bean.BusQueryLineTaskResponse; +import com.mogo.och.bus.bean.BusQueryLinesResponse; +import com.mogo.och.bus.bean.BusRoutePlanningUpdateReqBean; +import com.mogo.och.bus.bean.BusRoutesResponse; +import com.mogo.och.bus.bean.CarHeartbeatReqBean; +import com.mogo.och.bus.bean.BusQueryLineStationsRequest; +import com.mogo.och.bus.bean.QueryLeaveAwayPassengersRequest; +import com.mogo.och.bus.bean.QueryLeaveAwayPassengersResponse; +import com.mogo.och.bus.bean.BusResetDrivingLineRequest; +import com.mogo.och.bus.bean.BusUpdateSiteStatusRequest; + +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; + +/** + * 小巴车相关接口 + * + * @author tongchenfei + *

+ * wiki: http://wiki.zhidaohulian.com/pages/viewpage.action?pageId=48970072 + */ +public interface IBascApiService { + /** + * 根据车机坐标获取所在区域全部站点信息 + * + * @param request 请求参数 + * @return 接口返回数据 + */ + @Headers( {"Content-Type:application/json;charset=UTF-8"} ) +// @POST( "/autopilot-car-hailing/line/v2/lineDataWithDriver/query" ) + @POST( "/autopilot-car-hailing/line/v2/driver/bus/lineDataWithDriver/query" ) +// @POST( "/mock/268/autopilot-car-hailing/bus/api/lineDataWithDriver/query" ) + Observable queryBusRoutes(@Header ("appId") String appId, @Header("ticket") String ticket, @Body BusQueryLineStationsRequest request); + + /** + * @param request 请求参数{"destLine":1,"sn":"F803EB2046PZD00229"} 这个接口是重置bus线路的, 不是重置线路中站点的 + * @return 返回值是重置后的车站列表 + * 开始路线 + */ + @Headers( {"Content-Type:application/json;charset=UTF-8"} ) + @POST( "/autopilot-car-hailing/cab/flow/v1/bus/driver/bus/startTask" ) + Observable switchLine(@Header ("appId") String appId, @Header("ticket") String ticket, @Body BusResetDrivingLineRequest request); + + /** + * 离站,通知服务器 + * @param request + * @return + */ + @Headers({"Content-Type:application/json;charset=UTF-8"}) +// @POST("/autopilot-car-hailing/car/v2/bus/driving/away") +// @POST("/autopilot-car-hailing/car/v2/driver/bus/driving/away") + @POST("/autopilot-car-hailing/cab/flow/v1/bus/driver/bus/leave") +// @POST("/mock/268/autopilot-car-hailing/bus/api/driving/away") + Observable leaveStation(@Header ("appId") String appId, @Header("ticket") String ticket, @Body BusUpdateSiteStatusRequest request); + + /** + * 到站 更新到站信息 + * @param request + * @return + */ + @Headers({"Content-type:application/json;charset=UTF-8"}) +// @POST("/autopilot-car-hailing/order/v2/bus/driving/attachSite") +// @POST("/autopilot-car-hailing/order/v2/driver/bus/driving/attachSite") + @POST("/autopilot-car-hailing/cab/flow/v1/bus/driver/bus/arrive") +// @POST("/mock/268/autopilot-car-hailing/bus/api/driving/attachSite") + Observable< BaseData > arriveSiteStation(@Header ("appId") String appId,@Header("ticket") String ticket,@Body BusUpdateSiteStatusRequest request); + + + /** + * 到站查询下车乘客 + * @param request + * @return + */ + @Headers({"Content-type:application/json;charset=UTF-8"}) +// @POST("/autopilot-car-hailing/order/v2/bus/driving/siteArrivedOrders") + @POST("/autopilot-car-hailing/order/v2/driver/bus/driving/siteArrivedOrders") +// @POST("/mock/268/autopilot-car-hailing/bus/api/driving/siteArrivedOrders") + Observable< QueryLeaveAwayPassengersResponse > queryStationLeaveAwayPassengers(@Header ("appId") String appId,@Header("ticket") String ticket,@Body QueryLeaveAwayPassengersRequest request); + + @Headers({"Content-type:application/json;charset=UTF-8"}) +// @GET("/autopilot-car-hailing/order/v2/bus/servicingOrders/query") + @GET("/autopilot-car-hailing/order/v2/driver/bus/servicingOrders/query") +// @GET("/mock/268/autopilot-car-hailing/bus/api/servicingOrders/query") + Observable queryBusOrders(@Header ("appId") String appId, @Header("ticket") String ticket, @Query("sn") String sn); + + /** + * 车机端上传心跳数据(只在出车状态时上传):包含高德坐标系经纬度 + * @param data + * @return + */ + @Headers( {"Content-type:application/json;charset=UTF-8"} ) +// @POST( "/autopilot-car-hailing/location/v2/driver/heartbeat" ) + @POST( "/autopilot-car-hailing/location/v2/driver/bus/heartbeat" ) + Observable runCarHeartbeat(@Header ("appId") String appId,@Header("ticket") String ticket,@Body CarHeartbeatReqBean data); + + /** + * 查询车辆配置的所有路线 + * @param appId + * @param ticket + * @param sn + * @return + */ + @GET("/autopilot-car-hailing/line/v2/driver/bus/bindLine/query") + Observable queryBusLines(@Header ("appId") String appId, @Header("ticket") String ticket, @Query("sn") String sn); + + /** + * 查询路线当天的任务 + * @param appId + * @param ticket + * @param lineId 线路id + * @return + */ + @GET("/autopilot-car-hailing/line/v2/driver/bus/task/query") + Observable queryBusTaskByLineId(@Header ("appId") String appId, @Header("ticket") String ticket, @Query("lineId") String lineId); + + + @Headers( {"Content-type:application/json;charset=UTF-8"} ) + @POST( "/autopilot-car-hailing/location/v2/driver/bus/saveLineCoordinate" ) + Observable updateOrderRoute(@Header ("appId") String appId, @Header("ticket") String ticket, @Body BusRoutePlanningUpdateReqBean data); + + /** + * 中止任务 + * @param appId + * @param ticket + * @param data + * @return + */ + @POST("/autopilot-car-hailing/cab/flow/v1/bus/driver/bus/abortTask") + Observable abortTask(@Header ("appId") String appId, @Header("ticket") String ticket, @Body BusCloseTaskRequest data); + + /** + * 任务正常跑完结束 + * @param appId + * @param ticket + * @param data + * @return + */ + @Headers( {"Content-type:application/json;charset=UTF-8"} ) + @POST("/autopilot-car-hailing/cab/flow/v1/bus/driver/bus/endTask") + Observable endTask(@Header ("appId") String appId, @Header("ticket") String ticket, @Body BusCloseTaskRequest data); + + /** + * 查询核销乘客,目前不再使用,改为后台下发核销的乘客 + * @param appId + * @param ticket + * @param data + * @return + */ + @Headers( {"Content-type:application/json;charset=UTF-8"} ) + @POST("/autopilot-car-hailing/operation/v1/driver/order/verificationResult") + Observable queryWriteOffPassengers(@Header ("appId") String appId, @Header("ticket") String ticket, @Body BusWriteOffPassengersQueryRequest data); +} + diff --git a/OCH/mogo-och-bus/src/jinlvvan/java/com/mogo/och/bus/net/OrderServiceManager.kt b/OCH/mogo-och-bus/src/jinlvvan/java/com/mogo/och/bus/net/OrderServiceManager.kt new file mode 100644 index 0000000000..9002603bb5 --- /dev/null +++ b/OCH/mogo-och-bus/src/jinlvvan/java/com/mogo/och/bus/net/OrderServiceManager.kt @@ -0,0 +1,268 @@ +package com.mogo.och.bus.net + +import android.content.Context +import com.mogo.cloud.passport.MoGoAiCloudClientConfig +import com.mogo.eagle.core.data.BaseData +import com.mogo.eagle.core.network.MoGoRetrofitFactory +import com.mogo.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.transformTry + +/** + * @author: wangmingjun + * @date: 2021/10/20 + */ +object OrderServiceManager { + + private val M_SERVICE: IBascApiService = MoGoRetrofitFactory.getInstance(OchCommonConst.getBaseUrl()).create( + IBascApiService::class.java + ) + + /** + * 查询小巴车当前任务 + * @param context + * @param callback + */ + @JvmStatic + fun queryBusRoutes(context: Context, callback: OchCommonServiceCallback?) { + //获取当前高德坐标 + M_SERVICE.queryBusRoutes( + MoGoAiCloudClientConfig.getInstance().serviceAppId, + MoGoAiCloudClientConfig.getInstance().token, + BusQueryLineStationsRequest() + ) + .transformTry() + .subscribe(OchCommonSubscribeImpl(context, callback, "queryBusRoutes")) + } + + /** + * 重置线路站点 + * @param context + * @param taskId + * @param callback + */ + @JvmStatic + fun switchLine( + context: Context, + taskId: Int, + callback: OchCommonServiceCallback? + ) { + M_SERVICE.switchLine( + MoGoAiCloudClientConfig.getInstance().serviceAppId, + MoGoAiCloudClientConfig.getInstance().token, + BusResetDrivingLineRequest(taskId) + ) + .transformTry() + .subscribe(OchCommonSubscribeImpl(context, callback, "switchLine")) + } + + /** + * 中断当前任务 + * @param context + * @param taskId + * @param callback + */ + @JvmStatic + fun abortTask(context: Context, taskId: Int, callback: OchCommonServiceCallback?) { + M_SERVICE.abortTask( + MoGoAiCloudClientConfig.getInstance().serviceAppId, + MoGoAiCloudClientConfig.getInstance().token, + BusCloseTaskRequest(taskId) + ) + .transformTry() + .subscribe(OchCommonSubscribeImpl(context, callback, "abortTask")) + } + + /** + * 正常结束任务 + * @param context + * @param taskId + * @param callback + */ + @JvmStatic + fun endTask(context: Context, taskId: Int, callback: OchCommonServiceCallback?) { + M_SERVICE.endTask( + MoGoAiCloudClientConfig.getInstance().serviceAppId, + MoGoAiCloudClientConfig.getInstance().token, + BusCloseTaskRequest(taskId) + ) + .transformTry() + .subscribe(OchCommonSubscribeImpl(context, callback, "endTask")) + } + + /** + * 离站上报 + * @param context + * @param seq + * @param siteId + * @param callback + */ + @JvmStatic + fun leaveStation( + context: Context, + seq: Int, + siteId: Int, + taskId: Int, + callback: OchCommonServiceCallback? + ) { + M_SERVICE.leaveStation( + MoGoAiCloudClientConfig.getInstance().serviceAppId, + MoGoAiCloudClientConfig.getInstance().token, + BusUpdateSiteStatusRequest(taskId, siteId, seq) + ) + .transformTry() + .subscribe(OchCommonSubscribeImpl(context, callback, "leaveStation")) + } + + /** + * 到站更新站点状态 + * @param context + * @param seq + * @param siteId + * @param callback + */ + @JvmStatic + fun arriveSiteStation( + context: Context, seq: Int, siteId: Int, taskId: Int, + callback: OchCommonServiceCallback? + ) { + M_SERVICE.arriveSiteStation( + MoGoAiCloudClientConfig.getInstance().serviceAppId, + MoGoAiCloudClientConfig.getInstance().token, + BusUpdateSiteStatusRequest(taskId, siteId, seq) + ) + .transformTry() + .subscribe(OchCommonSubscribeImpl(context, callback, "arriveSiteStation")) + } + + /** + * 查询下车乘客 + * @param context + * @param seq + * @param siteId + * @param callback + */ + @JvmStatic + fun queryStationLeaveAwayPassengers( + context: Context, + seq: Int, + siteId: Int, + callback: OchCommonServiceCallback? + ) { + M_SERVICE.queryStationLeaveAwayPassengers( + MoGoAiCloudClientConfig.getInstance().serviceAppId, + MoGoAiCloudClientConfig.getInstance().token, + QueryLeaveAwayPassengersRequest(seq, siteId) + ) + .transformTry() + .subscribe(OchCommonSubscribeImpl(context, callback, "queryStationLeaveAwayPassengers")) + } + + /** + * 查询当前到站点核销乘客 + * @param context + * @param siteId + * @param callback + */ + @JvmStatic + fun queryStationWriteOffPassengers( + context: Context, + taskId: Int, + siteId: Int, + prePassengerTime: Long, + callback: OchCommonServiceCallback? + ) { + M_SERVICE.queryWriteOffPassengers( + MoGoAiCloudClientConfig.getInstance().serviceAppId, + MoGoAiCloudClientConfig.getInstance().token, + BusWriteOffPassengersQueryRequest(taskId, siteId, prePassengerTime) + ) + .transformTry() + .subscribe(OchCommonSubscribeImpl(context, callback, "queryStationWriteOffPassengers")) + } + + /** + * 查询小巴车订单 + * @param context + * @param callback + */ + @JvmStatic + fun queryBusOrders(context: Context, callback: OchCommonServiceCallback?) { + M_SERVICE.queryBusOrders( + MoGoAiCloudClientConfig.getInstance().serviceAppId, + MoGoAiCloudClientConfig.getInstance().token, + MoGoAiCloudClientConfig.getInstance().sn + ) + .transformTry() + .subscribe(OchCommonSubscribeImpl(context, callback, "queryBusOrders")) + } + @JvmStatic + fun queryBusLines(context: Context, callback: OchCommonServiceCallback?) { + M_SERVICE.queryBusLines( + MoGoAiCloudClientConfig.getInstance().serviceAppId, + MoGoAiCloudClientConfig.getInstance().token, + MoGoAiCloudClientConfig.getInstance().sn + ) + .transformTry() + .subscribe(OchCommonSubscribeImpl(context, callback, "queryBusLines")) + } + @JvmStatic + fun queryBusTaskByLineId( + context: Context, + lineId: String?, + callback: OchCommonServiceCallback? + ) { + M_SERVICE.queryBusTaskByLineId( + MoGoAiCloudClientConfig.getInstance().serviceAppId, + MoGoAiCloudClientConfig.getInstance().token, + lineId + ) + .transformTry() + .subscribe(OchCommonSubscribeImpl(context, callback, "queryBusLines")) + } + @JvmStatic + fun updateOrderRoute( + context: Context, + lineId: Int, + startSiteId: Int, + endSiteId: Int, + points: List?, + callback: OchCommonServiceCallback? + ) { + M_SERVICE.updateOrderRoute( + MoGoAiCloudClientConfig.getInstance().serviceAppId, + MoGoAiCloudClientConfig.getInstance().token, + BusRoutePlanningUpdateReqBean( + MoGoAiCloudClientConfig.getInstance().sn, lineId, startSiteId, endSiteId, points + ) + ) + .transformTry() + .subscribe(OchCommonSubscribeImpl(context, callback, "updateOrderRoute")) + } + + /** + * 车机端上传心跳数据(只在出车状态时上传):包含高德坐标系经纬度 + * @param context + * @param lon + * @param lat + * @param callback + */ + @JvmStatic + fun runCarHeartbeat( + context: Context, lon: Double, lat: Double, + callback: OchCommonServiceCallback? + ) { + M_SERVICE.runCarHeartbeat( + MoGoAiCloudClientConfig.getInstance().serviceAppId, + MoGoAiCloudClientConfig.getInstance().token, + CarHeartbeatReqBean( + MoGoAiCloudClientConfig.getInstance().sn, lon, lat + ) + ) + .transformTry() + .subscribe(OchCommonSubscribeImpl(context, callback, "runCarHeartbeat")) + } + +} \ No newline at end of file diff --git a/OCH/mogo-och-bus/src/jinlvvan/java/com/mogo/och/bus/net/login/OchCommonServiceManager.kt b/OCH/mogo-och-bus/src/jinlvvan/java/com/mogo/och/bus/net/login/OchCommonServiceManager.kt new file mode 100644 index 0000000000..83f8dec4ee --- /dev/null +++ b/OCH/mogo-och-bus/src/jinlvvan/java/com/mogo/och/bus/net/login/OchCommonServiceManager.kt @@ -0,0 +1,107 @@ +package com.mogo.och.bus.net.login + +import android.content.Context +import com.mogo.cloud.passport.MoGoAiCloudClientConfig +import com.mogo.och.common.module.biz.bean.TaxiLoginSmsReqBean +import com.mogo.och.common.module.biz.bean.TaxiLoginReqBean +import com.mogo.och.common.module.biz.bean.TaxiLoginRespBean +import com.mogo.och.common.module.biz.bean.TaxiLogoutReqBean +import com.mogo.och.common.module.biz.bean.DriverStatusQueryRespBean +import com.mogo.och.common.module.biz.constant.OchCommonConst +import com.mogo.cloud.passport.MoGoAiCloudClient +import com.mogo.eagle.core.data.BaseData +import com.mogo.eagle.core.network.MoGoRetrofitFactory +import com.mogo.och.common.module.biz.network.OchCommonServiceCallback +import com.mogo.och.common.module.biz.network.OchCommonSubscribeImpl +import com.mogo.och.common.module.biz.network.interceptor.transformTry + +/** + * Created by pangfan on 2021/8/19 + */ +object OchCommonServiceManager { + + private const val TAG = "OchCommonServiceManager" + + private val mLoginServiceApi: OchLoginServiceApi = + MoGoRetrofitFactory.getInstance(OchCommonConst.getBaseUrl()).create( + OchLoginServiceApi::class.java + ) + + /** + * 获取手机验证码 + * @param context + * @param callback + */ + @JvmStatic + fun getPhoneCode( + context: Context, phone: String?, + callback: OchCommonServiceCallback? + ) { + mLoginServiceApi.getPhoneCode( + MoGoAiCloudClientConfig.getInstance().serviceAppId, + MoGoAiCloudClientConfig.getInstance().token, + TaxiLoginSmsReqBean(phone) + ).transformTry() + .subscribe(OchCommonSubscribeImpl(context, callback, "getPhoneCode")) + } + + /** + * 通过验证码登录 + * @param context + * @param callback + */ + @JvmStatic + fun gotoLoginBycode( + context: Context, phone: String?, code: String?, + location4Login: TaxiLoginReqBean.Location4Login?, + callback: OchCommonServiceCallback? + ) { + val sn = MoGoAiCloudClientConfig.getInstance().sn + mLoginServiceApi.gotoLoginBycode4Bus( + MoGoAiCloudClientConfig.getInstance().serviceAppId, + MoGoAiCloudClientConfig.getInstance().token, + TaxiLoginReqBean(phone, code, sn, location4Login) + ).transformTry().subscribe(OchCommonSubscribeImpl(context, callback, "gotoLoginBycode")) + } + + /** + * 登出 + */ + @JvmStatic + fun logout( + context: Context, + location4Login: TaxiLogoutReqBean.Location4Login?, + callback: OchCommonServiceCallback? + ) { + mLoginServiceApi.logout4Bus( + MoGoAiCloudClientConfig.getInstance().serviceAppId, + MoGoAiCloudClientConfig.getInstance().token, + TaxiLogoutReqBean(MoGoAiCloudClientConfig.getInstance().sn, location4Login) + ).transformTry().subscribe(OchCommonSubscribeImpl(context, callback, "logout")) + } + + /** + * 接单状态和登录状态查询 + * + * @param context + * @param callback + */ + @JvmStatic + fun queryDriverServiceStatus( + context: Context, + callback: OchCommonServiceCallback? + ) { + if (MoGoAiCloudClientConfig.getInstance().token.isEmpty()) { + callback?.onFail(OchCommonConst.WAIT_TAKEN, "等待令牌中请稍等") + MoGoAiCloudClient.getInstance().refreshToken() + return + } + mLoginServiceApi.queryDriverServiceStatusAndLoginStatus( + MoGoAiCloudClientConfig.getInstance().serviceAppId, + MoGoAiCloudClientConfig.getInstance().token, + MoGoAiCloudClientConfig.getInstance().sn + ).transformTry() + .subscribe(OchCommonSubscribeImpl(context, callback, "queryDriverServiceStatus")) + } + +} \ No newline at end of file diff --git a/OCH/mogo-och-bus/src/jinlvvan/java/com/mogo/och/bus/net/login/OchLoginServiceApi.java b/OCH/mogo-och-bus/src/jinlvvan/java/com/mogo/och/bus/net/login/OchLoginServiceApi.java new file mode 100644 index 0000000000..fed3c8e1bc --- /dev/null +++ b/OCH/mogo-och-bus/src/jinlvvan/java/com/mogo/och/bus/net/login/OchLoginServiceApi.java @@ -0,0 +1,67 @@ +package com.mogo.och.bus.net.login; + +import com.mogo.eagle.core.data.BaseData; +import com.mogo.och.common.module.biz.bean.DriverStatusQueryRespBean; +import com.mogo.och.common.module.biz.bean.TaxiLoginReqBean; +import com.mogo.och.common.module.biz.bean.TaxiLoginRespBean; +import com.mogo.och.common.module.biz.bean.TaxiLoginSmsReqBean; +import com.mogo.och.common.module.biz.bean.TaxiLogoutReqBean; + +import 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.Path; +import retrofit2.http.Query; + +/** + * Created by pangfan on 2021/8/19 + *

+ * 网约车-出租车接口定义 + */ +interface OchLoginServiceApi { + /** + * 获取手机验证码 + * + * @return + */ + @Headers({"Content-type:application/json;charset=UTF-8"}) + @POST("/autopilot-car-hailing/driver/v2/driver/taxi/sendSms") + Observable getPhoneCode(@Header("appId") String appId + , @Header("ticket") String ticket, @Body TaxiLoginSmsReqBean data); + + /** + * 通过验证码登录 + * + * @param appId + * @param ticket + * @param data + * @return + */ + @Headers({"Content-type:application/json;charset=UTF-8"}) + @POST("/autopilot-car-hailing/cab/flow/v1/bus/driver/bus/startOperation") + Observable gotoLoginBycode4Bus(@Header("appId") String appId + , @Header("ticket") String ticket, @Body TaxiLoginReqBean data); + + /** + * 登出接口 + */ + @Headers({"Content-type:application/json;charset=UTF-8"}) + @POST("/autopilot-car-hailing/cab/flow/v1/bus/driver/bus/endOperation") + Observable logout4Bus(@Header("appId") String appId, @Header("ticket") String ticket, + @Body TaxiLogoutReqBean data); + + /** + * 接单状态和登录状态查询 出租车司机端、小巴车司机端、小巴车乘客端 + * + * @param sn + * @return + */ + @Headers({"Content-type:application/json;charset=UTF-8"}) + @GET("/autopilot-car-hailing/operation/v1/driver/bus/loginStatus") + Observable queryDriverServiceStatusAndLoginStatus(@Header("appId") String appId + , @Header("ticket") String ticket, @Query("sn") String sn); + +} diff --git a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/BusProvider.java b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/BusProvider.java index 7e04f66bd0..e8f3e0f280 100644 --- a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/BusProvider.java +++ b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/BusProvider.java @@ -10,11 +10,9 @@ 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.call.map.CallerMapUIServiceManager; +import com.mogo.eagle.core.function.call.setting.CallerMoGoUiSettingManager; import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger; -import com.mogo.map.MogoMapUIController; import com.mogo.och.bus.constant.BusConst; import com.mogo.och.bus.fragment.BusFragment; @@ -40,14 +38,11 @@ public class BusProvider implements IMogoOCH { */ private void stepIntoVrMode() { CallerLogger.INSTANCE.d(M_BUS + TAG, "进入vr模式"); - MogoMapUIController.getInstance() - .stepInVrMode(false); + CallerMoGoUiSettingManager.INSTANCE.stepInNightMode();//夜间模式 状态栏字体颜色变黑 } @Override public void init(Context context) { - MogoStatusManager.getInstance().registerStatusChangedListener("OchBus" - , StatusDescriptor.VR_MODE, statusChangedListener); } private void showFragment() { @@ -77,22 +72,6 @@ public class BusProvider implements IMogoOCH { } - private final IMogoStatusChangedListener statusChangedListener = (descriptor, isTrue) -> { - if (descriptor == StatusDescriptor.VR_MODE) { - // 进入vr模式默认显示网约车小巴fragment - if (isTrue) { - showFragment(); - } else { - hideFragment(); - } - } else if (MogoStatusManager.getInstance().isVrMode()) { - // topView进行展示时推出网约车界面,但是不隐藏整个fragment - if (busFragment != null && isTrue) { - busFragment.hideOchBus(); - } - } - }; - @Override public void createCoverage(FragmentActivity activity, int containerId) { @@ -107,19 +86,15 @@ public class BusProvider implements IMogoOCH { @Nullable @Override public Fragment createCoverage(@Nullable FragmentActivity fragmentActivity, @Nullable Integer integer) { - this.containerId = integer; this.activity = fragmentActivity; - -// UiThreadHandler.postDelayed(this::stepIntoVrMode, 5_000L ); + showFragment(); return null; } @Override public void onDestroy() { //若不调用finish, 设置中打开关闭UITouch,会造成och fragment 重叠 - MogoStatusManager.getInstance().unregisterStatusChangedListener("OchBus" - , StatusDescriptor.VR_MODE, statusChangedListener); if (activity == null) return; activity.finish(); } diff --git a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/bean/BusOperationStatusRequest.java b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/bean/BusOperationStatusRequest.java index 0ab375e2d4..96d4435ef4 100644 --- a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/bean/BusOperationStatusRequest.java +++ b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/bean/BusOperationStatusRequest.java @@ -1,7 +1,6 @@ package com.mogo.och.bus.bean; import com.mogo.cloud.passport.MoGoAiCloudClientConfig; -import com.mogo.commons.network.Utils; public /** diff --git a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/bean/BusQueryLineStationsRequest.java b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/bean/BusQueryLineStationsRequest.java index 6c90d9f7e2..adf7878ec5 100644 --- a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/bean/BusQueryLineStationsRequest.java +++ b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/bean/BusQueryLineStationsRequest.java @@ -11,55 +11,7 @@ import com.mogo.cloud.passport.MoGoAiCloudClientConfig; public class BusQueryLineStationsRequest { private String sn; -// private double lat; -// private double lon; -// private boolean markDrivingStatus; // 默认false;true:是否需要返回站点的行驶状态,对应返回的drivingStatus - // 0 - 关闭、1 - 启动 -// public String status; -// public BusQueryLineStationsRequest(double lon, double lat, boolean markDrivingStatus) { -// this.sn = MoGoAiCloudClientConfig.getInstance().getSn(); -// this.lat = lat; -// this.lon = lon; -// this.markDrivingStatus = markDrivingStatus; -// } public BusQueryLineStationsRequest() { this.sn = MoGoAiCloudClientConfig.getInstance().getSn(); } - -// public boolean isMarkDrivingStatus() { -// return markDrivingStatus; -// } -// -// public void setMarkDrivingStatus(boolean markDrivingStatus) { -// this.markDrivingStatus = markDrivingStatus; -// } -// -// public void setLat(double lat) { -// this.lat = lat; -// } -// -// public void setLon(double lon) { -// this.lon = lon; -// } -// -// public String getSn() { -// return sn; -// } -// -// public double getLat() { -// return lat; -// } -// -// public double getLon() { -// return lon; -// } - // public BusOperationStatusRequest shutdown() { -// status = "0"; -// return this; -// } -// -// public BusOperationStatusRequest launch() { -// status = "1"; -// return this; -// } } diff --git a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/bean/BusResetDrivingLineRequest.java b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/bean/BusResetDrivingLineRequest.java index 6ab70768f9..7de15dae2c 100644 --- a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/bean/BusResetDrivingLineRequest.java +++ b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/bean/BusResetDrivingLineRequest.java @@ -1,7 +1,6 @@ package com.mogo.och.bus.bean; import com.mogo.cloud.passport.MoGoAiCloudClientConfig; -import com.mogo.commons.network.Utils; /** * @author: wangmingjun diff --git a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/bean/BusStationBean.java b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/bean/BusStationBean.java deleted file mode 100644 index ce62d497e5..0000000000 --- a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/bean/BusStationBean.java +++ /dev/null @@ -1,162 +0,0 @@ -package com.mogo.och.bus.bean; - -/** - * 单个网约车小巴车站信息 - * - * @author tongchenfei - */ -public class BusStationBean { -// private int lineId; -// private int siteId; -// private String siteName; -// private String cityCode; -// private String areaCode; -// private String areaName; -// private double lat; -// private double lon; -// private String siteDesc; -// private int siteState; -// private int isCurrentSite;// @see OchBusConst 是否是当前站 1:是 2:下一站 0:普通站 -// private int siteColor; -// private String peoples; -// private int ifStop; // 是否需要停靠、1需要、0不需要 - - - private String name; - private String description; - private String cityCode; - private double lon; //高精坐标 - private double lat; //高精坐标 - private int businessType; //站点类型,9:taxi,10:bus - private double gcjLon; //高德 - private double gcjLat; //高德 - 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 double getGcjLon() { - return gcjLon; - } - - public double getGcjLat() { - return gcjLat; - } - - 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 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 "BusStationBean{" + - "name='" + name + '\'' + - ", description='" + description + '\'' + - ", cityCode='" + cityCode + '\'' + - ", lon=" + lon + - ", lat=" + lat + - ", businessType=" + businessType + - ", status=" + status + - ", siteId=" + siteId + - ", seq=" + seq + - ", drivingStatus=" + drivingStatus + - ", ifStop=" + ifStop + - ", leaving=" + leaving + - '}'; - } -} diff --git a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/bean/BusUpdateSiteStatusRequest.java b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/bean/BusUpdateSiteStatusRequest.java index c25bccb128..93ff4b5457 100644 --- a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/bean/BusUpdateSiteStatusRequest.java +++ b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/bean/BusUpdateSiteStatusRequest.java @@ -1,7 +1,6 @@ package com.mogo.och.bus.bean; import com.mogo.cloud.passport.MoGoAiCloudClientConfig; -import com.mogo.commons.network.Utils; /** * @author congtaowang diff --git a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/bean/QueryLeaveAwayPassengersRequest.java b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/bean/QueryLeaveAwayPassengersRequest.java index 9c50552d11..443fd76211 100644 --- a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/bean/QueryLeaveAwayPassengersRequest.java +++ b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/bean/QueryLeaveAwayPassengersRequest.java @@ -1,7 +1,6 @@ package com.mogo.och.bus.bean; import com.mogo.cloud.passport.MoGoAiCloudClientConfig; -import com.mogo.commons.network.Utils; /** * 查询下车乘客请求参数 diff --git a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/constant/BusConst.kt b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/constant/BusConst.kt index e98439b8f1..7eadb3d41f 100644 --- a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/constant/BusConst.kt +++ b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/constant/BusConst.kt @@ -7,23 +7,8 @@ import com.mogo.commons.debug.DebugConfig */ class BusConst { companion object { - - private const val BASE_URL_OCH_DEV = "http://tech-dev.zhidaohulian.com" - private const val BASE_URL_OCH_QA = "https://tech-qa.zhidaohulian.com" - private const val BASE_URL_OCH_RELEASE = "https://tech.zhidaohulian.com" - - @JvmStatic - fun getBaseUrl(): String { - return when (DebugConfig.getNetMode()) { - DebugConfig.NET_MODE_DEV, DebugConfig.NET_MODE_DEMO -> BASE_URL_OCH_DEV - DebugConfig.NET_MODE_QA -> BASE_URL_OCH_QA - DebugConfig.NET_MODE_RELEASE -> BASE_URL_OCH_RELEASE - else -> BASE_URL_OCH_RELEASE - } - } - // OCH arouter 路由path - const val PATH = "/och/api" + const val PATH = "/driver/api" // 测试用的广播 const val BROADCAST_TEST_BUS_CONTROL_TYPE_EXTRA_KEY = "sceneType" diff --git a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/fragment/BaseBusTabFragment.java b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/fragment/BaseBusTabFragment.java index 150b401a24..59820ddffe 100644 --- a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/fragment/BaseBusTabFragment.java +++ b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/fragment/BaseBusTabFragment.java @@ -1,6 +1,5 @@ package com.mogo.och.bus.fragment; -import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_BUS; import static com.mogo.och.bus.constant.BusConst.TIMER_START_AUTOPILOT_INTERVAL; import android.animation.ObjectAnimator; @@ -23,7 +22,6 @@ import com.mogo.commons.mvp.IView; import com.mogo.commons.mvp.MvpFragment; import com.mogo.commons.mvp.Presenter; import com.mogo.eagle.core.data.config.FunctionBuildConfig; -import com.mogo.eagle.core.data.config.HmiBuildConfig; import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotRecordListener; import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener; import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager; @@ -32,17 +30,23 @@ import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsManager; import com.mogo.eagle.core.function.call.hmi.CallerHmiManager; import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager; import com.mogo.eagle.core.function.call.map.CallerVisualAngleManager; +import com.mogo.eagle.core.function.hmi.ui.msgbox.DriverMsgBoxBubbleView; +import com.mogo.eagle.core.function.hmi.ui.msgbox.DriverMsgBoxButtonView; +import com.mogo.eagle.core.function.hmi.ui.msgbox.DriverMsgBoxListView; import com.mogo.eagle.core.function.hmi.ui.widget.TrafficDataView; +import com.mogo.eagle.core.function.smp.view.SmallMapView; +import com.mogo.eagle.core.function.view.MapBizView; import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger; +import com.mogo.eagle.core.utilcode.mogo.view.OnPreventFastClickListener; import com.mogo.eagle.core.utilcode.util.UiThreadHandler; import com.mogo.map.MogoMapUIController; import com.mogo.map.listener.IMogoMapListener; +import com.mogo.map.listener.MogoMapListenerHandler; +import com.mogo.map.uicontroller.IMogoMapUIController; import com.mogo.map.uicontroller.VisualAngleMode; -import com.mogo.module.common.MogoApisHandler; -import com.mogo.eagle.core.utilcode.mogo.view.OnPreventFastClickListener; import com.mogo.och.bus.R; import com.mogo.och.bus.bean.BusRoutesResult; -import com.mogo.och.bus.model.BusOrderModel; +import com.mogo.och.bus.model.OrderModel; import com.mogo.och.bus.util.BDRouteDataTestUtils; import com.mogo.och.bus.view.SlidePanelView; import com.mogo.och.common.module.utils.SoundPoolHelper; @@ -51,6 +55,7 @@ import org.greenrobot.eventbus.EventBus; import java.util.Objects; +import bag_manager.BagManagerOuterClass; import mogo.telematics.pad.MessagePad; import record_cache.RecordPanelOuterClass; @@ -63,7 +68,7 @@ import record_cache.RecordPanelOuterClass; */ public abstract class BaseBusTabFragment> extends MvpFragment implements IMogoMapListener, IMoGoAutopilotRecordListener { - private static final String TAG = "BaseOchFragment"; + private static final String TAG = "BaseBusTabFragment"; protected SlidePanelView slidePanelView; private RelativeLayout ctvAutopilotStatus; @@ -74,16 +79,22 @@ public abstract class BaseBusTabFragment protected RelativeLayout mBadcaseBtn; protected RelativeLayout mAICollectBtn; private FrameLayout flStationPanelContainer; + private MapBizView mapBizView; private Group groupTestPanel; private TrafficDataView mTrafficDataView; // private BusTrafficLightView mTrafficLightView; - public static final String TYPE_ENTRANCE = "entrance"; - //远景和中景的切换 private ImageView mSwitchMapModeImage; private LinearLayout mSwitchMapModeLayout; + protected SmallMapView smallMapView; + + //消息盒子 + private DriverMsgBoxButtonView viewDriverMsgBoxButton; + private DriverMsgBoxListView viewDriverMsgBoxList; + private DriverMsgBoxBubbleView viewDriverMsgBoxBubble; + private ObjectAnimator autopilotLoadingAnimator; public boolean isAnimateRunning = false; @@ -105,6 +116,7 @@ public abstract class BaseBusTabFragment @Override protected void initViews() { + mapBizView = findViewById(R.id.mapBizView); groupTestPanel = findViewById(R.id.groupTestPanel); slidePanelView = findViewById(R.id.module_mogo_och_slide_panel); ctvAutopilotStatus = findViewById(R.id.module_mogo_och_autopilot_status); @@ -128,30 +140,30 @@ public abstract class BaseBusTabFragment updateSwitchMapIcon(); mSwitchMapModeLayout.setOnClickListener(new OnPreventFastClickListener() { - @Override public void onClickImpl(View v) { - //切换地图的远近视图 - if (MogoMapUIController.getInstance().getCurrentMapVisualAngle().isLongSight() - || MogoMapUIController.getInstance().getCurrentMapVisualAngle().isRoma()) { - if(FunctionBuildConfig.isRomaMode){ + + IMogoMapUIController controller = CallerMapUIServiceManager.INSTANCE.getMapUIController(); + if (controller != null) { + //切换地图的远近视图 + if (controller.getCurrentMapVisualAngle().isLongSight()) { CallerVisualAngleManager.INSTANCE.updateLongSightLevel(false); - } - Objects.requireNonNull(CallerMapUIServiceManager.INSTANCE.getMapUIController()).setLockMode(true); - MogoMapUIController.getInstance().changeMapVisualAngle(VisualAngleMode.MODE_MEDIUM_SIGHT, null); - mSwitchMapModeImage.setImageResource(R.drawable.bus_switch_map_medium); - } else if (MogoMapUIController.getInstance().getCurrentMapVisualAngle().isMediumSight()) { - if (FunctionBuildConfig.isRomaMode) { + Objects.requireNonNull(CallerMapUIServiceManager.INSTANCE.getMapUIController()).setLockMode(true); + controller.changeMapVisualAngle(VisualAngleMode.MODE_MEDIUM_SIGHT, null); + mSwitchMapModeImage.setImageResource(R.drawable.bus_switch_map_medium); + } else if (controller.getCurrentMapVisualAngle().isMediumSight()) { CallerVisualAngleManager.INSTANCE.updateLongSightLevel(true); - MogoMapUIController.getInstance().setRomaMode(FunctionBuildConfig.romaModeStyle); + if (FunctionBuildConfig.isRomaMode) { + controller.setRomaMode(1); + } else { + Objects.requireNonNull(CallerMapUIServiceManager.INSTANCE.getMapUIController()).setLockMode(false); + controller.changeMapVisualAngle(VisualAngleMode.MODE_LONG_SIGHT, null); + } + mSwitchMapModeImage.setImageResource(R.drawable.bus_switch_map_long); } else { - Objects.requireNonNull(CallerMapUIServiceManager.INSTANCE.getMapUIController()).setLockMode(false); - MogoMapUIController.getInstance().changeMapVisualAngle(VisualAngleMode.MODE_LONG_SIGHT, null); + controller.changeMapVisualAngle(VisualAngleMode.MODE_MEDIUM_SIGHT, null); + mSwitchMapModeImage.setImageResource(R.drawable.bus_switch_map_medium); } - mSwitchMapModeImage.setImageResource(R.drawable.bus_switch_map_long); - } else { - MogoMapUIController.getInstance().changeMapVisualAngle(VisualAngleMode.MODE_MEDIUM_SIGHT, null); - mSwitchMapModeImage.setImageResource(R.drawable.bus_switch_map_medium); } } }); @@ -181,13 +193,17 @@ public abstract class BaseBusTabFragment debugAutoPilotStatus(IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING) ); + findViewById(R.id.btnAutopilotPingxing).setOnClickListener(view -> + debugAutoPilotStatus(IMoGoAutopilotStatusListener.STATUS_PARALLEL_DRIVING) + ); + // 模拟 自动驾驶网约车回调数据 findViewById(R.id.btnAutopilotArrive).setOnClickListener(view -> debugArrivedStation() ); findViewById(R.id.btnAutopilotRoute).setOnClickListener(view -> debugArrivedRoute()); - + tvArrived.setOnClickListener(view -> { onArriveStation(); }); @@ -203,15 +219,45 @@ public abstract class BaseBusTabFragment if (mBadcaseBtn != null) { CallerDevaToolsManager.INSTANCE.initBadCase(mBadcaseBtn); - if (!HmiBuildConfig.isShowBadCaseView) { - CallerAutopilotRecordListenerManager.INSTANCE.addListener(TAG, this); - } + CallerAutopilotRecordListenerManager.INSTANCE.addListener(TAG, this); } mAICollectBtn = findViewById(R.id.module_mogo_och_ai_collet_rl); if (mAICollectBtn != null) { CallerDevaToolsManager.INSTANCE.initAiCollect(mAICollectBtn); } + //消息盒子 + viewDriverMsgBoxButton = findViewById(R.id.viewDriverMsgBoxButton); + viewDriverMsgBoxList = findViewById(R.id.viewDriverMsgBoxList); + viewDriverMsgBoxBubble = findViewById(R.id.viewDriverMsgBoxBubble); + viewDriverMsgBoxButton.setClickListener(show -> { + if(show){ + viewDriverMsgBoxList.setVisibility(View.VISIBLE); + viewDriverMsgBoxList.notifyData(); + viewDriverMsgBoxBubble.setVisibility(View.GONE); + viewDriverMsgBoxBubble.isShowData(false); + }else{ + viewDriverMsgBoxList.setVisibility(View.GONE); + viewDriverMsgBoxBubble.setVisibility(View.VISIBLE); + viewDriverMsgBoxBubble.isShowData(true); + } + }); + + smallMapView = findViewById(R.id.smallMapView); + } + + @Override + protected void initViews(Bundle savedInstanceState) { + super.initViews(savedInstanceState); + mapBizView.onCreate(savedInstanceState); + smallMapView.onCreateView(savedInstanceState); + } + + @Override + public void onResume() { + super.onResume(); + mapBizView.onResume(); + smallMapView.onResume(); } @Nullable @@ -225,12 +271,15 @@ public abstract class BaseBusTabFragment protected abstract void onArriveStation(); private void updateSwitchMapIcon() { - if (MogoMapUIController.getInstance().getCurrentMapVisualAngle().isLongSight()) { - mSwitchMapModeImage.setImageResource(R.drawable.bus_switch_map_long); - } else if (MogoMapUIController.getInstance().getCurrentMapVisualAngle().isMediumSight()) { - mSwitchMapModeImage.setImageResource(R.drawable.bus_switch_map_medium); - } else { - mSwitchMapModeImage.setImageResource(R.drawable.bus_switch_map_medium); + IMogoMapUIController controller = CallerMapUIServiceManager.INSTANCE.getMapUIController(); + if (controller != null) { + if (controller.getCurrentMapVisualAngle().isLongSight()) { + mSwitchMapModeImage.setImageResource(R.drawable.bus_switch_map_long); + } else if (controller.getCurrentMapVisualAngle().isMediumSight()) { + mSwitchMapModeImage.setImageResource(R.drawable.bus_switch_map_medium); + } else { + mSwitchMapModeImage.setImageResource(R.drawable.bus_switch_map_medium); + } } } @@ -239,14 +288,31 @@ public abstract class BaseBusTabFragment } @Override - public void onDestroyView() { - super.onDestroyView(); - if (!HmiBuildConfig.isShowBadCaseView) { - CallerAutopilotRecordListenerManager.INSTANCE.removeListener(TAG); - } - EventBus.getDefault().unregister(this); + public void onSaveInstanceState(@NonNull Bundle outState) { + super.onSaveInstanceState(outState); + mapBizView.onSaveInstanceState(outState); } + @Override + public void onLowMemory() { + super.onLowMemory(); + mapBizView.onLowMemory(); + } + + @Override + public void onPause() { + super.onPause(); + mapBizView.onPause(); + smallMapView.onPause(); + } + + @Override + public void onDestroyView() { + mapBizView.onDestroy(); + super.onDestroyView(); + CallerAutopilotRecordListenerManager.INSTANCE.removeListener(TAG); + EventBus.getDefault().unregister(this); + } @Override public void onAutopilotRecordResult(@Nullable RecordPanelOuterClass.RecordPanel recordPanel) { @@ -259,6 +325,9 @@ public abstract class BaseBusTabFragment public void onAutopilotRecordConfig(@NonNull MessagePad.RecordDataConfig config) { } + @Override + public void onBagManagerResult(@NonNull BagManagerOuterClass.BagManager bagManager) { + } /** * 测试到站 @@ -266,7 +335,7 @@ public abstract class BaseBusTabFragment protected abstract void debugArrivedStation(); private void initListener() { - MogoApisHandler.getInstance().getApis().getRegisterCenterApi().registerMogoMapListener(TYPE_ENTRANCE, this); + MogoMapListenerHandler.Companion.getMogoMapListenerHandler().registerHostMapListener(TAG, this); } /** @@ -328,19 +397,30 @@ public abstract class BaseBusTabFragment ctvAutopilotStatusTv.setTextColor(getResources().getColor(R.color.bus_autopilot_text_color_disable)); ctvAutopilotStatusTv.setText(getResources().getString(R.string.bus_loading_autopilot_runnig_tv)); ctvAutopilotStatusIv.setImageResource(R.drawable.bus_disable_autopilot_icon); - ctvAutopilotStatus.setSelected(false); +// ctvAutopilotStatus.setSelected(false); ctvAutopilotStatus.setClickable(true); + ctvAutopilotStatus.setBackground(getContext().getDrawable(R.drawable.bus_autopilot_0_1_status_bg)); } else { ctvAutopilotStatusTv.setTextColor(getResources().getColor(R.color.bus_autopilot_text_color_normal)); - ctvAutopilotStatusTv.setText(getResources().getString(R.string.bus_loading_autopilot_runnig_tv)); ctvAutopilotStatusIv.setImageResource(R.drawable.bus_ic_autopilot); - ctvAutopilotStatus.setClickable(true); - if (IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE == autopilotStatus) {//1可用 - ctvAutopilotStatus.setSelected(false); + if (IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE == autopilotStatus) { //1可用 +// ctvAutopilotStatus.setSelected(false); + ctvAutopilotStatus.setClickable(true); + ctvAutopilotStatusTv.setText(getResources().getString(R.string.bus_loading_autopilot_runnig_tv)); + ctvAutopilotStatus.setBackground(getContext().getDrawable(R.drawable.bus_autopilot_0_1_status_bg)); } else if (IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING == autopilotStatus) { - ctvAutopilotStatus.setSelected(true); + ctvAutopilotStatusTv.setText(R.string.bus_loading_autopilot_runnig_tv); + ctvAutopilotStatus.setClickable(true); + ctvAutopilotStatus.setBackground(getContext().getDrawable(R.drawable.bus_autopilot_2_status_bg)); +// ctvAutopilotStatus.setSelected(true); + } else if (IMoGoAutopilotStatusListener.STATUS_PARALLEL_DRIVING + == autopilotStatus){ + ctvAutopilotStatusTv.setText(R.string.bus_pingxing_driver); + ctvAutopilotStatus.setClickable(false); + ctvAutopilotStatus.setBackground(getContext().getDrawable(R.drawable.pingxingjiashi)); } + } } @@ -350,14 +430,14 @@ public abstract class BaseBusTabFragment ctvAutopilotStatusIv.setImageResource(R.drawable.bus_right_autopilot_icon); ctvAutopilotStatusTv.setTextColor(getResources().getColor(R.color.bus_autopilot_text_color_normal)); ctvAutopilotStatusTv.setText(getResources().getString(R.string.bus_loading_autopilot_success_tv)); - ctvAutopilotStatus.setSelected(false); +// ctvAutopilotStatus.setSelected(false); ctvAutopilotStatus.setClickable(false); } else { ctvAutopilotStatusIv.setImageResource(R.drawable.bus_wrong_autopilot_icon); ctvAutopilotStatusTv.setTextColor(getResources().getColor(R.color.bus_autopilot_text_color_normal)); ctvAutopilotStatusTv.setText(getResources().getString(R.string.bus_loading_autopilot_failure_tv)); ctvAutopilotStatus.setClickable(false); - ctvAutopilotStatus.setSelected(false); +// ctvAutopilotStatus.setSelected(false); } UiThreadHandler.postDelayed(new Runnable() { @Override @@ -368,22 +448,20 @@ public abstract class BaseBusTabFragment } private void changeAutopilotBtnView(int autopilotStatus, boolean isAnimateRunning) { - CallerLogger.INSTANCE.d(M_BUS + TAG, "onStateChangeChangeAutopilotBtnView: " - + autopilotStatus + "isAnimateRunning = " + isAnimateRunning); if (isAnimateRunning && IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING != autopilotStatus) { // 主动开启自动驾驶中,不为2(为0、1)则继续loading return; } - if (isAnimateRunning){ + if (isAnimateRunning) { stopAnimAndUpdateBtnStatus(); - }else { + } else { setAutopilotBtnStatus(autopilotStatus); } } - public void stopAnimAndUpdateBtnStatus(){ + public void stopAnimAndUpdateBtnStatus() { stopAutopilotAnimation(); updateAutopilotStatus(CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState()); } @@ -437,7 +515,7 @@ public abstract class BaseBusTabFragment isAnimateRunning = true; ctvAutopilotStatusTv.setText(getResources().getString(R.string.bus_loading_autopilot_tv)); ctvAutopilotStatusTv.setTextColor(getResources().getColor(R.color.bus_autopilot_text_color_normal)); - ctvAutopilotStatus.setSelected(false); +// ctvAutopilotStatus.setSelected(false); ctvAutopilotStatus.setClickable(true); ctvAutopilotStatusIv.setImageResource(R.drawable.bus_loading_autopilot_icon); if (autopilotLoadingAnimator == null) { @@ -493,7 +571,8 @@ public abstract class BaseBusTabFragment @Override public void onDestroy() { super.onDestroy(); - MogoApisHandler.getInstance().getApis().getRegisterCenterApi().unregisterMogoMapListener(TYPE_ENTRANCE); + smallMapView.onDestroy(); + MogoMapListenerHandler.Companion.getMogoMapListenerHandler().unregisterHostMapListener(TAG); } @Override @@ -543,7 +622,7 @@ public abstract class BaseBusTabFragment if (busTestBar.getVisibility() == View.VISIBLE) { busTestBar.setVisibility(View.GONE); } else { - BusRoutesResult routesResult = BusOrderModel.getInstance().getBusRoutesResult(); + BusRoutesResult routesResult = OrderModel.getInstance().getBusRoutesResult(); lineIdTV.setText("lineId:" + (routesResult == null ? "" : String.valueOf(routesResult.getLineId()))); trajMd5TV.setText("TMd5:" + (routesResult == null ? "" : routesResult.csvFileMd5)); stopMd5TV.setText("SMd5:" + (routesResult == null ? "" : routesResult.txtFileMd5)); @@ -555,7 +634,7 @@ public abstract class BaseBusTabFragment public void updateBusTestBarInfo() { if (busTestBar != null && busTestBar.getVisibility() == View.VISIBLE) { - BusRoutesResult routesResult = BusOrderModel.getInstance().getBusRoutesResult(); + BusRoutesResult routesResult = OrderModel.getInstance().getBusRoutesResult(); lineIdTV.setText("lineId:" + (routesResult == null ? "" : String.valueOf(routesResult.getLineId()))); trajMd5TV.setText("TMd5:" + (routesResult == null ? "" : routesResult.csvFileMd5)); stopMd5TV.setText("SMd5:" + (routesResult == null ? "" : routesResult.txtFileMd5)); diff --git a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/fragment/BusFragment.java b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/fragment/BusFragment.java index b8deed7471..9ac79c1bcb 100644 --- a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/fragment/BusFragment.java +++ b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/fragment/BusFragment.java @@ -4,6 +4,7 @@ import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_BUS import android.content.Intent; import android.os.Bundle; +import android.util.Log; import android.view.View; import android.widget.TextView; @@ -18,16 +19,16 @@ import com.mogo.eagle.core.data.map.CenterLine; import com.mogo.eagle.core.data.temp.EventLogout; import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener; import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager; -import com.mogo.eagle.core.function.call.map.CallerHDMapManager; -import com.mogo.eagle.core.function.call.map.CallerSmpManager; +import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager; import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger; +import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant; import com.mogo.eagle.core.utilcode.util.ToastUtils; -import com.mogo.map.MogoMarkerManager; import com.mogo.map.marker.IMogoMarker; import com.mogo.map.marker.MogoMarkerOptions; import com.mogo.och.bus.R; import com.mogo.och.bus.bean.BusStationBean; import com.mogo.och.bus.constant.BusConst; +import com.mogo.och.bus.net.login.LoginBusImpl; import com.mogo.och.bus.presenter.BusPresenter; import com.mogo.och.bus.ui.BusStationCommonItem; import com.mogo.och.bus.ui.BusSwitchLineActivity; @@ -43,6 +44,7 @@ import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; import java.util.List; +import java.util.Objects; import bag_manager.BagManagerOuterClass; @@ -80,7 +82,7 @@ public class BusFragment extends BaseBusTabFragment super.onActivityCreated(savedInstanceState); loginService = (LoginService) ARouter.getInstance().build(OchCommonConst.LOGINSERVICE).navigation(); if(loginService!=null){ - loginService.registerFragment(this, getPresenter()); + loginService.registerFragment(this, getPresenter(),new LoginBusImpl()); } } @Override @@ -436,7 +438,8 @@ public class BusFragment extends BaseBusTabFragment } //清除鹰眼右下角小地图轨迹 - CallerSmpManager.clearPolyline(); + CallerLogger.INSTANCE.d(SceneConstant.M_MAP, "clearBusStationsMarkers --------->"); + smallMapView.clearPolyline(); } /** @@ -458,42 +461,35 @@ public class BusFragment extends BaseBusTabFragment */ private void setOrRemoveMapMaker(boolean isAdd, String uuid, double lat, double longi,int resourceId) { if (isAdd) { - Runnable setMapMarkerRunnable = new Runnable() { - @Override - public void run() { - CallerLogger.INSTANCE.d(M_BUS + "setMapMaker= "+Thread.currentThread().getName(), - uuid + "=latitude=" + lat + ",longitude=" + longi); + Runnable setMapMarkerRunnable = () -> { + CallerLogger.INSTANCE.d(M_BUS + "setMapMaker= "+Thread.currentThread().getName(), + uuid + "=latitude=" + lat + ",longitude=" + longi); - MogoMarkerOptions options = new MogoMarkerOptions() - .owner(BusConst.TYPE_MARKER_BUS_ORDER) - .anchor(0.5f, 0.5f) - .set3DMode(true) - .gps(true) - .controlAngle(true) - .icon3DRes(resourceId) - .latitude(lat) - .longitude(longi); - IMogoMarker marker = MogoMarkerManager.getInstance(AbsMogoApplication.getApp()) .addMarker(uuid, options); - CenterLine centerLine = CallerHDMapManager.INSTANCE.getCenterLineInfo( - longi,lat,-1); - if (null != centerLine && marker != null) { // 有可能鹰眼map为空没有角度。判空使用后可能造成maker角度跟道路角度不一致 地图未初始化会返回空 - marker.setRotateAngle(centerLine.getAngle().floatValue()); - } + MogoMarkerOptions options = new MogoMarkerOptions() + .owner(BusConst.TYPE_MARKER_BUS_ORDER) + .anchor(0.5f, 0.5f) + .set3DMode(true) + .gps(true) + .controlAngle(true) + .icon3DRes(resourceId) + .latitude(lat) + .longitude(longi); + IMogoMarker marker = Objects.requireNonNull(CallerMapUIServiceManager.INSTANCE.getMarkerManager(AbsMogoApplication.getApp())).addMarker(uuid, options); + CenterLine centerLine = CallerMapUIServiceManager.INSTANCE.getMapUIController().getCenterLineInfo( + longi,lat,-1); + if (null != centerLine && marker != null) { // 有可能鹰眼map为空没有角度。判空使用后可能造成maker角度跟道路角度不一致 地图未初始化会返回空 + marker.setRotateAngle(centerLine.getAngle().floatValue()); } }; OCHThreadPoolManager.getsInstance().execute(setMapMarkerRunnable); }else { - Runnable removeMapMarkerRunnable = new Runnable() { - @Override - public void run() { - CallerLogger.INSTANCE.d(M_BUS + "RemoveMapMaker="+Thread.currentThread().getName(), - uuid+"=latitude="+lat+",longitude="+longi); - MogoMarkerManager.getInstance(AbsMogoApplication.getApp()).removeMarkers(uuid); - } + Runnable removeMapMarkerRunnable = () -> { + CallerLogger.INSTANCE.d(M_BUS + "RemoveMapMaker="+Thread.currentThread().getName(), + uuid+"=latitude="+lat+",longitude="+longi); + Objects.requireNonNull(CallerMapUIServiceManager.INSTANCE.getMarkerManager(AbsMogoApplication.getApp())).removeMarkers(uuid); }; - OCHThreadPoolManager.getsInstance().execute(removeMapMarkerRunnable); } } diff --git a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/model/BusLineModel.java b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/model/BusLineModel.java index a0323b8b0f..b116e97940 100644 --- a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/model/BusLineModel.java +++ b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/model/BusLineModel.java @@ -1,6 +1,7 @@ package com.mogo.och.bus.model; import android.content.Context; +import android.util.Log; import com.mogo.commons.AbsMogoApplication; import com.mogo.eagle.core.utilcode.util.NetworkUtils; @@ -11,9 +12,8 @@ import com.mogo.och.bus.bean.BusQueryLineTaskResponse; import com.mogo.och.bus.bean.BusQueryLinesResponse; import com.mogo.och.bus.bean.BusRoutesResponse; import com.mogo.och.bus.callback.IBusLinesCallback; -import com.mogo.och.bus.net.BusServiceManager; +import com.mogo.och.bus.net.OrderServiceManager; import com.mogo.och.bus.ui.BusSwitchLineActivity; -import com.mogo.och.bus.util.BusSendTripInfoManager; import com.mogo.och.common.module.biz.network.OchCommonServiceCallback; /** @@ -44,7 +44,7 @@ public class BusLineModel { mBusLinesCallback = callback; } public void queryBusLines(){ - BusServiceManager.queryBusLines(mContext, new OchCommonServiceCallback() { + OrderServiceManager.queryBusLines(mContext, new OchCommonServiceCallback() { @Override public void onSuccess(BusQueryLinesResponse data) { if (null == data && mBusLinesCallback != null) { @@ -83,7 +83,7 @@ public class BusLineModel { * @param position 位置 */ public void queryBusLineTasksById(int lineId, int position,boolean autoRefresh){ - BusServiceManager.queryBusTaskByLineId(mContext, String.valueOf(lineId),new OchCommonServiceCallback() { + OrderServiceManager.queryBusTaskByLineId(mContext, String.valueOf(lineId),new OchCommonServiceCallback() { @Override public void onSuccess(BusQueryLineTaskResponse data) { if (null == data && mBusLinesCallback != null) { @@ -117,7 +117,7 @@ public class BusLineModel { } public void commitSwitchLineId(int taskId,int lineId){ - BusServiceManager.switchLine(mContext,taskId, new OchCommonServiceCallback() { + OrderServiceManager.switchLine(mContext,taskId, new OchCommonServiceCallback() { @Override public void onSuccess(BusRoutesResponse o) { SharedPrefs.getInstance(mContext).putInt(BusSwitchLineActivity.LASTCOMMITLINEID,lineId); diff --git a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/model/BusOrderModel.java b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/model/BusOrderModel.java deleted file mode 100644 index 5116a5d4d2..0000000000 --- a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/model/BusOrderModel.java +++ /dev/null @@ -1,1211 +0,0 @@ -package com.mogo.och.bus.model; - -import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_BUS; -import static com.mogo.och.bus.constant.BusConst.DELAY_10S; -import static com.mogo.och.bus.constant.BusConst.STATION_STATUS_ARRIVING; -import static com.mogo.och.bus.constant.BusConst.STATION_STATUS_STOPPED; - -import android.content.Context; -import android.os.Handler; -import android.os.Message; - -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; - -import com.alibaba.android.arouter.launcher.ARouter; -import com.amap.api.maps.model.LatLng; -import com.elegant.network.utils.GsonUtil; -import com.mogo.aicloud.services.socket.IMogoOnMessageListener; -import com.mogo.cloud.commons.utils.CoordinateUtils; -import com.mogo.commons.AbsMogoApplication; -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.data.BaseData; -import com.mogo.eagle.core.data.autopilot.AutopilotControlParameters; -import com.mogo.eagle.core.data.config.FunctionBuildConfig; -import com.mogo.eagle.core.data.map.MogoLocation; -import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotPlanningListener; -import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener; -import com.mogo.eagle.core.function.api.map.listener.IMoGoMapLocationListener; -import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotManager; -import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager; -import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotPlanningListenerManager; -import com.mogo.eagle.core.function.call.map.CallerMapLocationListenerManager; -import com.mogo.eagle.core.function.call.map.CallerSmpManager; -import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger; -import com.mogo.eagle.core.utilcode.util.NetworkUtils; -import com.mogo.eagle.core.utilcode.util.ToastUtils; -import com.mogo.eagle.core.utilcode.util.UiThreadHandler; -import com.mogo.och.bus.R; -import com.mogo.och.bus.bean.BusRoutePlanningUpdateReqBean; -import com.mogo.och.bus.bean.BusRoutesResponse; -import com.mogo.och.bus.bean.BusRoutesResult; -import com.mogo.och.bus.bean.BusStationBean; -import com.mogo.och.bus.bean.WriteOffPassenger; -import com.mogo.och.bus.callback.IBusADASStatusCallback; -import com.mogo.och.bus.callback.IBusControllerStatusCallback; -import com.mogo.och.bus.callback.IPassengerCallback; -import com.mogo.och.bus.callback.IRefreshBusStationsCallback; -import com.mogo.och.bus.callback.ISlidePannelHideCallback; -import com.mogo.och.bus.constant.BusConst; -import com.mogo.och.bus.net.BusServiceManager; -import com.mogo.och.bus.presenter.BusModelLoopManager; -import com.mogo.och.bus.util.BusAnalyticsManager; -import com.mogo.och.bus.util.BusSendTripInfoManager; -import com.mogo.och.bus.util.BusTrajectoryManager; -import com.mogo.och.common.module.biz.common.socketmessage.OCHSocketMessageManager; -import com.mogo.och.common.module.biz.common.socketmessage.data.OCHOperationalMessage; -import com.mogo.och.common.module.biz.constant.OchCommonConst; -import com.mogo.och.common.module.biz.network.OchCommonServiceCallback; -import com.mogo.och.common.module.biz.provider.LoginService; -import com.mogo.och.common.module.callback.OchAdasStartFailureCallback; -import com.mogo.och.common.module.manager.AbnormalFactorsLoopManager; -import com.mogo.och.common.module.manager.OCHAdasAbilityManager; -import com.mogo.och.common.module.utils.CoordinateCalculateRouteUtil; -import com.mogo.och.common.module.utils.DateTimeUtil; -import com.mogo.och.common.module.utils.NumberFormatUtil; -import com.mogo.och.common.module.utils.PinYinUtil; -import com.mogo.och.common.module.utils.ToastUtilsOch; -import com.mogo.och.common.module.voice.VoiceNotice; - -import org.jetbrains.annotations.NotNull; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -import io.reactivex.exceptions.UndeliverableException; -import io.reactivex.functions.Consumer; -import io.reactivex.plugins.RxJavaPlugins; -import mogo.telematics.pad.MessagePad; - -/** - * @author congtaowang - * @since 2021/3/23 - *

- * 小巴订单管理 - */ -public class BusOrderModel { - private final String TAG = BusOrderModel.class.getSimpleName(); - private int currentLineId = -1; - private int currentTaskId = -1; - private int backgroundCurrentStationIndex = 0;//A->B 此处值是A站点索引 - - private static volatile BusOrderModel sInstance; - public double mLongitude = 0; - public double mLatitude = 0; - private Context mContext; - private final List stationList = new ArrayList<>(); - private BusRoutesResult busRoutesResult = null; - /** - * 用来表示是否正在开往下一站 - */ - private boolean isGoingToNextStation = false; - // 运营类型 - private static final int VEHICLE_TYPE = 10; - private static final int MSG_QUERY_BUS_STATION = 1001; - private static final long QUERY_BUS_STATION_DELAY = 5000; - - private IRefreshBusStationsCallback refreshBusStationsCallback; - private ISlidePannelHideCallback slidePanelHideCallback; - private IBusControllerStatusCallback mControllerStatusCallback; //Model->Presenter:VR mode等 - private IPassengerCallback mPassengerCallback; //乘客核销回调 - private IBusADASStatusCallback mADASStatusCallback; - - List points = new ArrayList<>();//全路径信息 - - private volatile boolean isArrivedStation = false; - - //0: 代表没有启动过 1代表是启动第一次,当>=1 代表是重试 每次到站/路线结束清空置为0 - private volatile int firstStartAutopilot = 0; - - private LoginService loginService; - - private final Handler handler = new Handler(new Handler.Callback() { - @Override - public boolean handleMessage(Message msg) { - if (msg.what == MSG_QUERY_BUS_STATION) { - queryBusRoutes(); - return true; - } - return false; - } - }); - - public static BusOrderModel getInstance() { - if (sInstance == null) { - synchronized (BusOrderModel.class) { - if (sInstance == null) { - sInstance = new BusOrderModel(); - } - } - } - return sInstance; - } - - private BusOrderModel() { - - } - - public void init() { - mContext = AbsMogoApplication.getApp(); - loginService = (LoginService) ARouter.getInstance().build(OchCommonConst.LOGINSERVICE).navigation(); - // 定位监听 - CallerMapLocationListenerManager.INSTANCE.addListener(TAG, mMapLocationListener, false); - - MogoStatusManager.getInstance().registerStatusChangedListener(TAG, StatusDescriptor.VR_MODE, mMogoStatusChangedListener); - - //自动驾驶路线规划接口 - CallerAutopilotPlanningListenerManager.INSTANCE.addListener(TAG, moGoAutopilotPlanningListener); - - //开启自驾后 异常信息返回 - OCHAdasAbilityManager.getInstance().setAdasStartFailureCallback(mAdasStartFailureListener); - - OCHSocketMessageManager.INSTANCE.registerSocketMessageListener(//监听运营消息 - OCHSocketMessageManager.msgMonitorType, - mMogoOnMessageListener); - - OCHSocketMessageManager.INSTANCE.registerSocketMessageListener(//监听核销乘客 - OCHSocketMessageManager.msgWriteOffPassengerType, - mWriteOffPassengeOnMessageListener); - - AbnormalFactorsLoopManager.INSTANCE.startLoopAbnormalFactors(mContext); - - //2022.1.28 - // 调用Disposable.dispose() 时候会出现InterruptedException 导致出现崩溃 - // The exception could not be delivered to the consumer because it has already canceled/disposed - // the flow or the excTeption has nowhere to go to begin with - RxJavaPlugins.setErrorHandler(new Consumer() { - @Override - public void accept(Throwable e) { - if (e instanceof UndeliverableException) { - e = e.getCause(); - CallerLogger.INSTANCE.d(M_BUS + TAG, "UndeliverableException"); - } - if ((e instanceof IOException)) {// - // fine, irrelevant network problem or API that throws on cancellation - CallerLogger.INSTANCE.d(M_BUS + TAG, "IOException"); - return; - } - if (e instanceof InterruptedException) { - // fine, some blocking code was interrupted by a dispose call - CallerLogger.INSTANCE.d(M_BUS + TAG, "InterruptedException"); - return; - } - if ((e instanceof NullPointerException) || (e instanceof IllegalArgumentException)) { - // that's likely a bug in the application - CallerLogger.INSTANCE.d(M_BUS + TAG, "NullPointerException or IllegalArgumentException"); - Thread.currentThread().getUncaughtExceptionHandler().uncaughtException(Thread.currentThread(), e); - return; - } - if (e instanceof IllegalStateException) { - // that's a bug in RxJava or in a custom operator - CallerLogger.INSTANCE.d(M_BUS + TAG, "IllegalStateException"); - Thread.currentThread().getUncaughtExceptionHandler().uncaughtException(Thread.currentThread(), e); - return; - } - CallerLogger.INSTANCE.d(M_BUS + TAG, "Undeliverable exception"); - } - }); - } - - private final IMogoOnMessageListener mMogoOnMessageListener = - new IMogoOnMessageListener() { - @Override - public Class target() { - return OCHOperationalMessage.class; - } - - @Override - public void onMsgReceived(OCHOperationalMessage obj) { - if (obj == null){ - CallerLogger.INSTANCE.d(M_BUS + TAG, "onMsgReceived = null"); - return; - } - CallerLogger.INSTANCE.i(M_BUS + TAG,"onMsgReceived = "+obj.getMessage()); - OCHSocketMessageManager.INSTANCE.pushAppOperationalMsgBox(obj.getPushTimeStamp(), - obj.getMessage()); - } - }; - - private final IMogoOnMessageListener mWriteOffPassengeOnMessageListener = - new IMogoOnMessageListener() { - @Override - public Class target() { - return WriteOffPassenger.class; - } - - @Override - public void onMsgReceived(WriteOffPassenger passenger) { - //进行播报 - CallerLogger.INSTANCE.i(M_BUS + TAG,"passenger = "+ GsonUtil.jsonFromObject(passenger)); - if (passenger != null && passenger.passengerSize == 0) return; - if (mPassengerCallback != null){ - mPassengerCallback.playPassenger(passenger); - } - } - }; - - public void setAdasStatusCallback(IBusADASStatusCallback callback){ - this.mADASStatusCallback = callback; - } - - public void setRefreshBusStationsCallback(IRefreshBusStationsCallback callback){ - this.refreshBusStationsCallback = callback; - } - - public void setPassengerCallback(IPassengerCallback callback) { - this.mPassengerCallback = callback; - } - - public void setSlidePanelHideCallback(ISlidePannelHideCallback callback) { - this.slidePanelHideCallback = callback; - } - - public void setControllerStatusCallback(IBusControllerStatusCallback callback) { - this.mControllerStatusCallback = callback; - } - - private final IMoGoAutopilotPlanningListener moGoAutopilotPlanningListener = new IMoGoAutopilotPlanningListener() { - - @Override - public void onAutopilotTrajectory(@NonNull List trajectoryInfos) { - - } - - @Override - public void onAutopilotRotting(MessagePad.GlobalPathResp routeList) { - if (null != routeList && routeList.getWayPointsList().size() > 0) { - points.clear(); - points.addAll(coordinateConverterWgsToGcjList(mContext, routeList.getWayPointsList())); - updateOrderRoute(); - } - } - - }; - - public static List coordinateConverterWgsToGcjList(Context mContext, List mogoLatLngList) { - List points = new ArrayList<>(); - for (MessagePad.Location m : mogoLatLngList) { - LatLng mogoLatLng = CoordinateCalculateRouteUtil.coordinateConverterWgsToGcj(mContext, m); - BusRoutePlanningUpdateReqBean.Result result = new BusRoutePlanningUpdateReqBean.Result(); - result.latitude = mogoLatLng.latitude; - result.longitude = mogoLatLng.longitude; - points.add(result); - } - return points; - } - - /** - * 上报订单全路径规划数据 - */ - public void updateOrderRoute() { - if (!isGoingToNextStation || backgroundCurrentStationIndex + 1 >= stationList.size() || points.size() == 0) { - return; - } - - BusStationBean currentStation = stationList.get(backgroundCurrentStationIndex); - BusStationBean nextStation = stationList.get(backgroundCurrentStationIndex + 1); - - BusServiceManager.updateOrderRoute(mContext, currentLineId, currentStation.getSiteId() - , nextStation.getSiteId(), points, new OchCommonServiceCallback() { - @Override - public void onSuccess(BaseData o) { - - } - - @Override - public void onFail(int code, String failMsg) { - if (isGoingToNextStation) {//重试 - updateOrderRoute(); - } - } - }); - } - - public void debugUpdateOrderRoute(List list) { - points.clear(); - points.addAll(coordinateConverterWgsToGcjList(mContext, list)); - updateOrderRoute(); - } - - public void release() { - - startOrStopOrderLoop(false); - //startOrStopQueryPassengerWriteOff(false); - MogoStatusManager.getInstance().unregisterStatusChangedListener(TAG, StatusDescriptor.VR_MODE, mMogoStatusChangedListener); - - // 注销定位监听 - CallerMapLocationListenerManager.INSTANCE.removeListener(TAG,false); - - //自动驾驶路线规划接口 - CallerAutopilotPlanningListenerManager.INSTANCE.removeListener(moGoAutopilotPlanningListener); - loginService = null; - - OCHAdasAbilityManager.getInstance().setAdasStartFailureCallback(null); - - OCHSocketMessageManager.INSTANCE.releaseSocketMessageListener( - OCHSocketMessageManager.msgMonitorType); - OCHSocketMessageManager.INSTANCE.releaseSocketMessageListener( - OCHSocketMessageManager.msgWriteOffPassengerType); - - AbnormalFactorsLoopManager.INSTANCE.stopLoopAbnormalFactors(); - } - - private Object readResolve() { - // 阻止反序列化,必须实现 Serializable 接口 - return sInstance; - } - - private final IMogoStatusChangedListener mMogoStatusChangedListener = new IMogoStatusChangedListener() { - // VR mode变更回调 - @Override - public void onStatusChanged(StatusDescriptor descriptor, boolean isTrue) { - if (StatusDescriptor.VR_MODE == descriptor) { - if (mControllerStatusCallback != null) { - mControllerStatusCallback.onVRModeChanged(isTrue); - } - } - } - }; - - private final OchAdasStartFailureCallback mAdasStartFailureListener = new OchAdasStartFailureCallback() { - @Override - public void onStartAutopilotFailure(@NotNull String startFailedCode, @NonNull String startFailedMessage) { - BusAnalyticsManager.getInstance().triggerStartAutopilotFailureEventByAdas(startFailedCode, startFailedMessage); - if (mADASStatusCallback != null && !FunctionBuildConfig.isDemoMode){ - CallerLogger.INSTANCE.e( M_BUS + TAG, "mAdasStartFailureListener = "+startFailedMessage ); - mADASStatusCallback.onStartAdasFailure(); - } - } - }; - - // 自车定位 - private final IMoGoMapLocationListener mMapLocationListener = new IMoGoMapLocationListener() { - @Override - public void onLocationChanged(@Nullable MogoLocation location, int from, boolean isGps) { - if (null == location) return; - mLongitude = location.getLongitude(); - mLatitude = location.getLatitude(); - if (mControllerStatusCallback != null) { - mControllerStatusCallback.onCarLocationChanged(location); - } - - //是否到站的围栏判断 离站状态并且自动驾驶还未触发到站 - if (isGoingToNextStation && !isArrivedStation) { - judgeArrivedStation(location); - } - } - }; - - //根据围栏判断,是否到达站点 - private void judgeArrivedStation(MogoLocation location) { - - if (backgroundCurrentStationIndex + 1 > stationList.size() - 1) { - CallerLogger.INSTANCE.e(M_BUS + TAG, "到站数组越界"); - return; - } - BusStationBean upcomingStation = stationList.get(backgroundCurrentStationIndex + 1); - - double startLon = upcomingStation.getGcjLon(); - double startLat = upcomingStation.getGcjLat(); - double distance = CoordinateUtils.calculateLineDistance( - startLon, startLat, - location.getLongitude(), location.getLatitude()); - - if (distance <= BusConst.ARRIVE_AT_END_STATION_DISTANCE) { - CallerLogger.INSTANCE.d(M_BUS + TAG, "行程日志-judgeArrivedStation() distance = " + distance - + " to " + upcomingStation.getName()); - onArriveAt(null); //无自动驾驶到站信息传null - return; - } - } - - /** - * 查询小巴路线 - */ - public void queryBusRoutes() { - CallerLogger.INSTANCE.d(M_BUS + TAG, "查询小巴路线"); - BusServiceManager.queryBusRoutes(mContext, new OchCommonServiceCallback() { - @Override - public void onSuccess(BusRoutesResponse data) { - if (data == null - || data.getResult() == null - || data.getResult().getSites() == null - || data.getResult().getSites().isEmpty()) { - //当为空时,显示无绑定路线图 - CallerLogger.INSTANCE.d(M_BUS + TAG, "获取到小巴路线数据:空 "); - if (refreshBusStationsCallback != null) { - refreshBusStationsCallback.updateEmptyUi(); - } - clearAutopilotControlParameters(); - closeBeautificationMode(); - clearStartAutopilotTag(); - removeTipRunnables(); - return; - } - CallerLogger.INSTANCE.d(M_BUS + TAG, "获取到小巴路线数据: " + data); - updateBusStatus(data.getResult()); - } - - - @Override - public void onError() { - if (!NetworkUtils.isConnected(mContext)) { - ToastUtils.showShort(mContext.getString(R.string.network_error_tip)); - } else { - ToastUtils.showShort(mContext.getString(R.string.request_error_tip)); - } - } - - @Override - public void onFail(int code, String failMsg) { - if (!NetworkUtils.isConnected(mContext)) { - ToastUtils.showShort("网络异常,请稍后重试"); - }else { - ToastUtils.showShort(failMsg); - } - } - }); - - } - - /** - * 更新正在运行的任务UI - * - * @param stations - */ - private void updateBusTaskStatus(List stations) { - - int arrivingOrArrivedStationIndex = 0;//已经到站或者即将到站的索引呢 - - for (int i = 0; i < stations.size(); i++) { - BusStationBean station = stations.get(i); - - if (i == 0) { // 首发站 显示在最上面 - if (station.getDrivingStatus() == STATION_STATUS_STOPPED - && !station.isLeaving()) { //到达第一站 - arrivingOrArrivedStationIndex = i; - break; - } - } else { - BusStationBean preStation = stations.get(i - 1); - if ((station.getDrivingStatus() == STATION_STATUS_STOPPED && !station.isLeaving()) - || (station.getDrivingStatus() == STATION_STATUS_ARRIVING - && preStation.isLeaving())) { - //到站未离开 | 即将到站 显示在最中间 - arrivingOrArrivedStationIndex = i; - break; - } - } - } - - BusStationBean arrivingOrArrivedStation = stations.get(arrivingOrArrivedStationIndex); - - String lineTime = DateTimeUtil.formatLongToString( - busRoutesResult.getTaskTime(), - DateTimeUtil.TAXI_HH_mm); - - if (arrivingOrArrivedStationIndex == 0 || - arrivingOrArrivedStation.getDrivingStatus() == STATION_STATUS_STOPPED - && !arrivingOrArrivedStation.isLeaving()) { - if (refreshBusStationsCallback != null) { - refreshBusStationsCallback.updateBusTaskStatus(busRoutesResult.getName(), lineTime, - stationList, arrivingOrArrivedStationIndex, true); - } - clearAutopilotControlParameters(); - } else { - if (refreshBusStationsCallback != null) { - refreshBusStationsCallback.updateBusTaskStatus(busRoutesResult.getName(), lineTime, - stationList, arrivingOrArrivedStationIndex, false); - } - updateAutopilotControlParameters(); - - CallerSmpManager.startQueryV2XEvents(); //选择路线后开启 - } - } - - /** - * 重置路线站点状态--结束路线,当前路线恢复到始发站 - */ - public void abortTask() { - CallerLogger.INSTANCE.d(M_BUS + TAG, "结束当前路线abortTask"); - BusServiceManager.abortTask(mContext, currentTaskId - , new OchCommonServiceCallback() { - @Override - public void onSuccess(BaseData o) { - CallerLogger.INSTANCE.d(M_BUS + TAG, "abortTask success: " + o); - if (o.code == 0) { // 重置成功 - endOrAbortTaskSuccess(); - clearBusStationDatas(); - queryBusRoutes(); - removeTipRunnables(); - // startOrStopQueryPassengerWriteOff(false); - } - } - - @Override - public void onError() { - if (!NetworkUtils.isConnected(mContext)) { - ToastUtils.showShort(mContext.getString(R.string.network_error_tip)); - } else { - ToastUtils.showShort(mContext.getString(R.string.request_error_tip)); - } - } - - @Override - public void onFail(int code, String failMsg) { - if (!NetworkUtils.isConnected(mContext)) { - ToastUtils.showShort("网络异常,请稍后重试"); - }else { - ToastUtils.showShort(failMsg); - } - } - }); - - } - - /** - * 中断或者正常结束任务后的处理 - */ - private void endOrAbortTaskSuccess() { - - isGoingToNextStation = false; - backgroundCurrentStationIndex = 0; - - if (busRoutesResult != null) { - BusSendTripInfoManager.INSTANCE.sendBusTripInfo(BusSendTripInfoManager.END_TRIP - , busRoutesResult.getName() - , "" - , "" - , false); - } - } - - /** - * 离站上报成功后渲染站点 - * 服务端返回的OchBusRoutesResult逻辑, 离开站为当前站, 到达下一站后才会将下一站置为当前站, - * 车机端展示是离开当前站,下一站设置为当前站, 所以服务端数据回来要做处理,不能直接渲染 - */ - private void leaveStationSuccess(int leaveIndex, String leaveStation, String nextStation) { - - onStartAutopilot(leaveIndex); - - leaveTTSTips(nextStation); - - if (busRoutesResult != null) { - boolean isLastStop = false; - if (leaveIndex + 1 == stationList.size() - 1) { - isLastStop = true; - } - //给bus外屏发送 - BusSendTripInfoManager.INSTANCE.sendBusTripInfo(BusSendTripInfoManager.LEAVE_STATION - , busRoutesResult.getName() - , leaveStation - , nextStation - , isLastStop); - } - } - - private void onStartAutopilot(int leaveIndex) { - //开启自动驾驶 2.10.0: 如果自动驾驶状态下开启, 非自动驾驶状态下不开启,需手动点击自动驾驶按钮开启 - isGoingToNextStation = true; - if (CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState() - == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING) { - startAutopilot(false, leaveIndex); - } else { - firstStartAutopilot = 0; - } - } - - /** - * 开启自动驾驶 - * - * @param isRestart - */ - private void startAutopilot(boolean isRestart, int leaveIndex) { - - if (!FunctionBuildConfig.isDemoMode && !OCHAdasAbilityManager.getInstance().getAutopilotAbilityStatus()) { - ToastUtils.showLong(OCHAdasAbilityManager.getInstance().getAutopilotUnAbilityReason() + - ", 请稍候重试"); - triggerUnableStartAPReasonEvent(); - return; - } - - firstStartAutopilot++; - - triggerStartServiceEvent(isRestart, false); - - AutopilotControlParameters parameters = initAutopilotControlParameters(leaveIndex); - if (null == parameters) { - CallerLogger.INSTANCE.e(M_BUS + TAG, "行程日志-AutopilotControlParameters is empty."); - return; - } - - CallerAutoPilotManager.INSTANCE.startAutoPilot(parameters); - - CallerLogger.INSTANCE.d(M_BUS + TAG, "行程日志-开启自动驾驶====" + GsonUtil.jsonFromObject(parameters) - + " startLatLon=" + parameters.startName + ",endLatLon=" + parameters.endName + - "isRestart = " + isRestart); - - if (mControllerStatusCallback != null) { - mControllerStatusCallback.startOpenAutopilot(); - } - } - - /** - * 到站后重置站点状态 - */ - private void arriveSiteStation() { - if ( backgroundCurrentStationIndex +1 > stationList.size() - 1 ) { //到站短时间内调用多次 - CallerLogger.INSTANCE.e( M_BUS + TAG, "数组越界" ); - return; - } - int arrivedStationIndex = backgroundCurrentStationIndex + 1; - String arriveStation = stationList.get(arrivedStationIndex).getName(); - String departureStopName = stationList.get(backgroundCurrentStationIndex).getName(); - CallerLogger.INSTANCE.d(M_BUS + TAG, "arriveSiteStation-currentStationIndex = " + arrivedStationIndex); - - BusServiceManager.arriveSiteStation(mContext, - stationList.get(arrivedStationIndex).getSeq(), - stationList.get(arrivedStationIndex).getSiteId(), - currentTaskId, - new OchCommonServiceCallback() { - @Override - public void onSuccess(BaseData o) { - CallerLogger.INSTANCE.d(M_BUS + TAG, "行程日志-arriveSiteStation success"); - if (o != null && o.code == 0){ - queryBusRoutes(); - isArrivedStation = true; - isGoingToNextStation = false; - arriveStationSuccess(arrivedStationIndex, departureStopName, arriveStation); - } - //5s轮询核销乘客 -// startOrStopQueryPassengerWriteOff(true); - } - - @Override - public void onError() { - if (!NetworkUtils.isConnected(mContext)) { - ToastUtils.showShort(mContext.getString(R.string.network_error_tip)); - } else { - ToastUtils.showShort(mContext.getString(R.string.request_error_tip)); - } - } - - @Override - public void onFail(int code, String failMsg) { - if (ToastUtilsOch.isCustomFastClick(5000)) { - if (!NetworkUtils.isConnected(mContext)) { - ToastUtils.showShort("网络异常,请稍后重试"); - } else { - if (isArrivedStation) return; - ToastUtils.showShort(failMsg); - } - } - } - }); - } - - private void arriveStationSuccess(int arrivedStationIndex, String departureStopName, String arriveStation) { - if (busRoutesResult != null) { - boolean isLastStop = false; - if (arrivedStationIndex == busRoutesResult.getSites().size() - 1) { - isLastStop = true; - } - //给bus外屏发送 - BusSendTripInfoManager.INSTANCE.sendBusTripInfo(BusSendTripInfoManager.ARRIVE_STATION - , busRoutesResult.getName() - , departureStopName - , arriveStation - , isLastStop); - } - - VoiceNotice.showNotice(String.format(mContext - .getString(R.string.bus_arrived_station_tip), - arriveStation)); - } - - /** - * 离站上报 - */ - public void leaveStation() { - CallerLogger.INSTANCE.d(M_BUS + TAG, "leaveStation-backgroundCurrentStationIndex = " + backgroundCurrentStationIndex); - String nextStationName = ""; - if (backgroundCurrentStationIndex < stationList.size() - 1) { - nextStationName = stationList.get(backgroundCurrentStationIndex + 1).getName(); - } - final String currentStationName = stationList.get(backgroundCurrentStationIndex).getName(); - String finalNextStationName = nextStationName; - BusServiceManager.leaveStation(mContext, - stationList.get(backgroundCurrentStationIndex).getSeq(), - stationList.get(backgroundCurrentStationIndex).getSiteId(), - currentTaskId, - new OchCommonServiceCallback() { - @Override - public void onSuccess(BaseData o) { - isArrivedStation = false; - CallerLogger.INSTANCE.d(M_BUS + TAG, "行程日志-离站成功开往下一站===="); - //需要更改当前站和下一站的状态 然后渲染 - //startOrStopQueryPassengerWriteOff(false); - queryBusRoutes(); - leaveStationSuccess(backgroundCurrentStationIndex, currentStationName, finalNextStationName); - } - - - @Override - public void onError() { - if (!NetworkUtils.isConnected(mContext)) { - ToastUtils.showShort(mContext.getString(R.string.network_error_tip)); - } else { - ToastUtils.showShort(mContext.getString(R.string.request_error_tip)); - } - } - - @Override - public void onFail(int code, String failMsg) { - if (!NetworkUtils.isConnected(mContext)) { - ToastUtils.showShort("网络异常,请稍后重试"); - } else { - ToastUtils.showShort("离站上报失败:" + failMsg); - } - } - }); - } - - //车站10s后播报 - private void leaveTTSTips(String nextStation) { - VoiceNotice.showNotice(String.format(mContext - .getString(R.string.bus_leave_station_tip), - nextStation), DELAY_10S); - } - - /** - * 关闭美化模式 - */ - public void closeBeautificationMode() { - if (FunctionBuildConfig.isDemoMode) {//收车结束美化 - FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData = false; //是否强制绘制引导线 - CallerAutoPilotManager.INSTANCE.setIgnoreConditionDraw(false);// 同步给乘客屏 - CallerAutoPilotManager.INSTANCE.setIPCDemoMode(false);//是否自动启动自驾 - CallerLogger.INSTANCE.d(M_BUS + TAG, "美化模式-ignore:置为false"); - } - } - - /** - * 开启自动驾驶到下一站 - */ - public void autoDriveToNextStation() { - if (backgroundCurrentStationIndex >= stationList.size() - 1) { - // 当前站是最后一站,结束当前行程 - travelOver(); - return; - } - leaveStation(); - } - - /** - * 渲染站点信息 - * 服务端返回的OchBusRoutesResult逻辑, 离开站为当前站, 到达下一站后才会将下一站置为当前站, - * 车机端展示 三站: 中间为即将到到达或者刚到达的站 - * - * @param result - */ - private void updateBusStatus(BusRoutesResult result) { - if (result == null) return; - busRoutesResult = result; - List site = result.getSites(); - currentTaskId = result.getTaskId(); - currentLineId = result.getLineId(); - stationList.clear(); - stationList.addAll(site); - - for (int i = 0; i < stationList.size(); i++) { - BusStationBean s = stationList.get(i); - - CallerLogger.INSTANCE.d(M_BUS + "updateBusStationsStatus--", - "Index=" + i + " ,name = " + s.getName() + " ," + s.isLeaving() + "," + s.getDrivingStatus()); - - // 是否正在开往下一站 - if (s.isLeaving()) { - isGoingToNextStation = true; - } - // 当前站点信息 - if (s.getDrivingStatus() == STATION_STATUS_STOPPED) { - backgroundCurrentStationIndex = i; - break; - } - } - - if (backgroundCurrentStationIndex == 0 && - stationList.get(0).getDrivingStatus() == STATION_STATUS_STOPPED - && !stationList.get(0).isLeaving()) { //默认是第一站到站查询 - if (busRoutesResult != null) { // 第一站到站也是行程开始的时候 - BusSendTripInfoManager.INSTANCE.sendBusTripInfo(BusSendTripInfoManager.START_TRIP - , busRoutesResult.getName(), "", "", false); - } - - //任务选择后首发前给司机提示任务 - if (busRoutesResult != null){ - beforeTaskTips(); - } -// startOrStopQueryPassengerWriteOff(true); - }else { - removeTipRunnables(); - } - - BusStationBean currentStation = stationList.get(backgroundCurrentStationIndex); - - CallerLogger.INSTANCE.d(M_BUS + TAG, - "行程日志-STATION_STATUS_STOPPED-backgroundCurrentStationIndex=" - + backgroundCurrentStationIndex - + " isLeaving()=" + currentStation.isLeaving()); - - // 美化是否开始 - if (FunctionBuildConfig.isDemoMode && (backgroundCurrentStationIndex >= 0 - && backgroundCurrentStationIndex <= stationList.size() - 1)) {//行驶过程中设置美化 - if (stationList.get(backgroundCurrentStationIndex).isLeaving()) { - startBeautificationMode(); - CallerLogger.INSTANCE.d(M_BUS + TAG, "美化模式-ignore:置为true(每次滑动出发)"); - } else if (backgroundCurrentStationIndex > 0 && backgroundCurrentStationIndex < stationList.size() - 1) { - //美化模式下 中间站点到站 引导线要一直绘制,所以此处不出强制绘制不传false - CallerAutoPilotManager.INSTANCE.setIPCDemoMode(false); - CallerLogger.INSTANCE.d(M_BUS + TAG, "美化模式-ignore:false(到达中间站)"); - clearStartAutopilotTag(); - } else { - closeBeautificationMode(); - clearStartAutopilotTag(); - } - } - - - if (currentStation.isLeaving() && slidePanelHideCallback != null) { - slidePanelHideCallback.hideSlidePanel(); - } - - //更新bus路线面板 - updateBusTaskStatus(stationList); - - //需放在currentStationIndex赋值之后 - BusTrajectoryManager.getInstance().syncTrajectoryInfo(); - } - - private void beforeTaskTips() { - if (busRoutesResult == null) return; - - removeTipRunnables(); - - long taskTime = busRoutesResult.getTaskTime(); - long tip3Time = taskTime- 3*60*1000 - DateTimeUtil.getCurrentTimeStamp(); // 首站离开前3分钟提示 - long tip1Time = taskTime-60*1000 - DateTimeUtil.getCurrentTimeStamp(); // 首站离开前1分钟提示 - - if (tip3Time > 0){ - UiThreadHandler.postDelayed(tip3Runnable,tip3Time); - } - - if (tip1Time > 0){ - UiThreadHandler.postDelayed(tip1Runnable,tip1Time); - } - } - - Runnable tip3Runnable = new Runnable() { - @Override - public void run() { - - if (backgroundCurrentStationIndex == 0 && stationList.get(0).getDrivingStatus() == STATION_STATUS_STOPPED - && !stationList.get(0).isLeaving()){ - tipStartTask("3"); - }else { - removeTipRunnables(); - } - } - }; - - private void tipStartTask(String s) { - String tips = String.format(mContext - .getString(R.string.bus_before_tips_s), s); - //展示在运营消息 - OCHSocketMessageManager.INSTANCE.pushAppOperationalMsgBox( - DateTimeUtil.getCurrentTimeStamp(), - tips); - //语音提示 - VoiceNotice.showNotice(tips); - } - - Runnable tip1Runnable = new Runnable() { - @Override - public void run() { - if (backgroundCurrentStationIndex == 0 && stationList != null && - stationList.get(0).getDrivingStatus() == STATION_STATUS_STOPPED - && !stationList.get(0).isLeaving()){ - tipStartTask("1"); - }else { - removeTipRunnables(); - } - } - }; - - public void removeTipRunnables(){ - if (tip3Runnable != null){ - UiThreadHandler.removeCallbacks(tip3Runnable); - } - if (tip1Runnable != null){ - UiThreadHandler.removeCallbacks(tip1Runnable); - } - } - - private void clearStartAutopilotTag() { - firstStartAutopilot = 0; - } - - private void startBeautificationMode() { - FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData = true; - CallerAutoPilotManager.INSTANCE.setIgnoreConditionDraw(true); - CallerAutoPilotManager.INSTANCE.setIPCDemoMode(true); - } - - public void clearBusStationDatas() { - if (refreshBusStationsCallback != null) { - refreshBusStationsCallback.clearBusStationsMarkers(); - } - } - - /** - * 延时查询站点信心 - */ - private void queryBusStationDelay() { - handler.sendEmptyMessageDelayed(MSG_QUERY_BUS_STATION, QUERY_BUS_STATION_DELAY); - } - - /** - * 在踩刹车、控制方向盘等操作后,会停止自动驾驶,重启自动驾驶的话相当于重新设置自动驾驶目的地 - */ - public void restartAutopilot() { - CallerLogger.INSTANCE.d(M_BUS + TAG, "行程日志-重启自动驾驶===" + isGoingToNextStation); - //只去启动自动驾驶,不再去上报离站 - startAutopilot(firstStartAutopilot >= 1, -1); - } - - public boolean isRestartAutopilot() { - return firstStartAutopilot > 1; - } - - /** - * 行程结束 - */ - private void travelOver() { - - if (backgroundCurrentStationIndex >= stationList.size()) { - CallerLogger.INSTANCE.e(M_BUS + TAG, "travel over index out of station list"); - return; - } - CallerLogger.INSTANCE.d(M_BUS + TAG, "单程结束===="); - CallerAutoPilotManager.INSTANCE.cancelAutoPilot(); - - endTask(); - } - - /** - * task正常结束 - */ - private void endTask() { - CallerLogger.INSTANCE.d(M_BUS + TAG, "任务正常走完endTask()"); - BusServiceManager.endTask(mContext, currentTaskId - , new OchCommonServiceCallback() { - @Override - public void onSuccess(BaseData o) { - CallerLogger.INSTANCE.d(M_BUS + TAG, "endTask success: " + o); - if (o.code == 0) { - endOrAbortTaskSuccess(); - clearBusStationDatas(); - queryBusRoutes();// 重新获取任务 - removeTipRunnables(); -// startOrStopQueryPassengerWriteOff(false); - VoiceNotice.showNotice(mContext.getString(R.string.bus_end_task_tip)); - } - } - - @Override - public void onError() { - if (!NetworkUtils.isConnected(mContext)) { - ToastUtils.showShort(mContext.getString(R.string.network_error_tip)); - } else { - ToastUtils.showShort(mContext.getString(R.string.request_error_tip)); - } - } - - @Override - public void onFail(int code, String failMsg) { - if (!NetworkUtils.isConnected(mContext)) { - ToastUtils.showShort("网络异常,请稍后重试"); - }else { - ToastUtils.showShort(failMsg); - } - } - }); - } - - /** - * 到站 - * - * @param data - */ - public void onArriveAt(MessagePad.ArrivalNotification data) { - if (backgroundCurrentStationIndex + 1 > stationList.size() - 1) { - CallerLogger.INSTANCE.e(M_BUS + TAG, "行程日志-到站异常,取消后续操作结束"); - return; - } - - //MAP 280 每隔100ms左右返回一次到站, 导致在到达中间站后再次滑动出发后会有时间差,收到一次到站,出现问题 - //此处比对 自驾告诉的到站站点坐标和本地应到站站点坐标, 一致时才能到站 - if (data != null && data.getEndLocation() != null) { - - String latitude = NumberFormatUtil.cutOutNumber(data.getEndLocation().getLatitude(), 5); //wgs - String longitude = NumberFormatUtil.cutOutNumber(data.getEndLocation().getLongitude(), 5); - - int arrivedStationIndex = backgroundCurrentStationIndex + 1; - BusStationBean arriveStation = stationList.get(arrivedStationIndex); - String arriveLat = NumberFormatUtil.cutOutNumber(arriveStation.getLat(), 5); - String arriveLon = NumberFormatUtil.cutOutNumber(arriveStation.getLon(), 5); - - if (!latitude.equals(arriveLat) || !longitude.equals(arriveLon)) { - CallerLogger.INSTANCE.e(M_BUS + TAG, "行程日志-到站拦截,到站坐标不一致"); - return; - } - } - - if (isArrivedStation) return; - - CallerLogger.INSTANCE.d(M_BUS + TAG, "行程日志-当前==backgroundCurrentStationIndex=" - + backgroundCurrentStationIndex); - - arriveSiteStation(); - } - - public boolean isGoingToNextStation() { - return isGoingToNextStation; - } - - // 车机端上传心跳数据(只在出车状态时上传) - public void runCarHeartbeat() { - BusServiceManager.runCarHeartbeat(mContext, mLongitude, mLatitude, - new OchCommonServiceCallback() { - @Override - public void onSuccess(BaseData data) { - - } - - @Override - public void onFail(int code, String failMsg) { - - } - }); - } - - public void startOrStopOrderLoop(boolean start) { - CallerLogger.INSTANCE.d(M_BUS + TAG, "startOrStopOrderLoop() " + start); - if (start) { - BusModelLoopManager.getInstance().startHeartbeatLoop(); - } else { - BusModelLoopManager.getInstance().stopHeartbeatLoop(); - } - } - - // 登出 - public void logout() { - loginService.loginOut(mLatitude, mLongitude); - } - - public void triggerStartServiceEvent(boolean isRestart, boolean send) { - if (stationList == null || backgroundCurrentStationIndex >= stationList.size() - 1) { - return; - } - BusStationBean currentStation = stationList.get(backgroundCurrentStationIndex); - BusStationBean nextStation = stationList.get(backgroundCurrentStationIndex + 1); - BusAnalyticsManager.getInstance().triggerStartAutopilotEvent(isRestart, send, - currentStation.getName(), nextStation.getName(), currentLineId); - } - - public void triggerUnableStartAPReasonEvent() { - if (stationList == null || backgroundCurrentStationIndex >= stationList.size() - 1) { - return; - } - BusStationBean currentStation = stationList.get(backgroundCurrentStationIndex); - BusStationBean nextStation = stationList.get(backgroundCurrentStationIndex + 1); - BusAnalyticsManager.getInstance().triggerUnableStartAPReasonEvent( - currentStation.getName(), nextStation.getName(), currentLineId, - OCHAdasAbilityManager.getInstance().getAutopilotUnAbilityReason()); - } - - public BusRoutesResult getBusRoutesResult() { - return busRoutesResult; - } - - public int getCurrentStationIndex() { - return backgroundCurrentStationIndex; - } - - /** - * 将业务订单信息保存,鹰眼可取用 - */ - private void updateAutopilotControlParameters() { - - AutopilotControlParameters parameters = initAutopilotControlParameters(-1); - if (null == parameters) { - CallerLogger.INSTANCE.e(M_BUS + TAG, "AutopilotControlParameters is empty."); - return; - } - CallerLogger.INSTANCE.d(M_BUS + TAG, "AutopilotControlParameters is update."); - CallerAutoPilotStatusListenerManager.INSTANCE.updateAutopilotControlParameters(parameters); - } - - private void clearAutopilotControlParameters() { - CallerLogger.INSTANCE.d(M_BUS + TAG, "AutopilotControlParameters is clear."); - CallerAutoPilotStatusListenerManager.INSTANCE.updateAutopilotControlParameters(null); - } - - private AutopilotControlParameters initAutopilotControlParameters(int leaveIndex) { - BusStationBean currentStation = null; - BusStationBean nextStation = null; - - if (leaveIndex < 0) { - if (backgroundCurrentStationIndex + 1 > stationList.size() - 1 || !isGoingToNextStation) { - CallerLogger.INSTANCE.e(M_BUS + TAG, "行程日志-mismatch condition1."); - return null; - } - currentStation = stationList.get(backgroundCurrentStationIndex); - nextStation = stationList.get(backgroundCurrentStationIndex + 1); - } else { - if (leaveIndex + 1 > stationList.size() - 1 || !isGoingToNextStation) { - CallerLogger.INSTANCE.e(M_BUS + TAG, "行程日志-mismatch condition2."); - return null; - } - currentStation = stationList.get(leaveIndex); - nextStation = stationList.get(leaveIndex + 1); - } - - AutopilotControlParameters parameters = new AutopilotControlParameters(); - parameters.routeID = busRoutesResult.getLineId(); - parameters.routeName = busRoutesResult.getName(); - parameters.startName = PinYinUtil.getPinYinHeadChar(currentStation.getName()); - parameters.endName = PinYinUtil.getPinYinHeadChar(nextStation.getName()); - parameters.startLatLon = new AutopilotControlParameters - .AutoPilotLonLat(currentStation.getLat(), currentStation.getLon()); - parameters.endLatLon = new AutopilotControlParameters - .AutoPilotLonLat(nextStation.getLat(), nextStation.getLon()); - parameters.vehicleType = VEHICLE_TYPE; - if (parameters.autoPilotLine == null) { - parameters.autoPilotLine = new AutopilotControlParameters.AutoPilotLine( - busRoutesResult.getLineId(), - busRoutesResult.csvFileUrl, busRoutesResult.csvFileMd5, - busRoutesResult.txtFileUrl, busRoutesResult.txtFileMd5, - busRoutesResult.contrailSaveTime, busRoutesResult.carModel, - busRoutesResult.csvFileUrlDPQP, busRoutesResult.csvFileMd5DPQP, - busRoutesResult.txtFileUrlDPQP, busRoutesResult.txtFileMd5DPQP, - busRoutesResult.contrailSaveTimeDPQP); - } - - return parameters; - } -} diff --git a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/net/BusServiceManager.kt b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/net/BusServiceManager.kt deleted file mode 100644 index 126932adbc..0000000000 --- a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/net/BusServiceManager.kt +++ /dev/null @@ -1,268 +0,0 @@ -package com.mogo.och.bus.net - -import android.content.Context -import com.mogo.och.bus.constant.BusConst.Companion.getBaseUrl -import com.mogo.cloud.passport.MoGoAiCloudClientConfig -import com.mogo.eagle.core.data.BaseData -import com.mogo.eagle.core.network.MoGoRetrofitFactory -import com.mogo.och.bus.bean.* -import com.mogo.och.common.module.biz.network.OchCommonServiceCallback -import com.mogo.och.common.module.biz.network.OchCommonSubscribeImpl -import com.mogo.och.common.module.biz.network.interceptor.transformTry - -/** - * @author: wangmingjun - * @date: 2021/10/20 - */ -object BusServiceManager { - - private val mService: IBusApiService = MoGoRetrofitFactory.getInstance(getBaseUrl()).create( - IBusApiService::class.java - ) - - /** - * 查询小巴车当前任务 - * @param context - * @param callback - */ - @JvmStatic - fun queryBusRoutes(context: Context, callback: OchCommonServiceCallback?) { - //获取当前高德坐标 - mService.queryBusRoutes( - MoGoAiCloudClientConfig.getInstance().serviceAppId, - MoGoAiCloudClientConfig.getInstance().token, - BusQueryLineStationsRequest() - ) - .transformTry() - .subscribe(OchCommonSubscribeImpl(context, callback, "queryBusRoutes")) - } - - /** - * 重置线路站点 - * @param context - * @param taskId - * @param callback - */ - @JvmStatic - fun switchLine( - context: Context, - taskId: Int, - callback: OchCommonServiceCallback? - ) { - mService.switchLine( - MoGoAiCloudClientConfig.getInstance().serviceAppId, - MoGoAiCloudClientConfig.getInstance().token, - BusResetDrivingLineRequest(taskId) - ) - .transformTry() - .subscribe(OchCommonSubscribeImpl(context, callback, "switchLine")) - } - - /** - * 中断当前任务 - * @param context - * @param taskId - * @param callback - */ - @JvmStatic - fun abortTask(context: Context, taskId: Int, callback: OchCommonServiceCallback?) { - mService.abortTask( - MoGoAiCloudClientConfig.getInstance().serviceAppId, - MoGoAiCloudClientConfig.getInstance().token, - BusCloseTaskRequest(taskId) - ) - .transformTry() - .subscribe(OchCommonSubscribeImpl(context, callback, "abortTask")) - } - - /** - * 正常结束任务 - * @param context - * @param taskId - * @param callback - */ - @JvmStatic - fun endTask(context: Context, taskId: Int, callback: OchCommonServiceCallback?) { - mService.endTask( - MoGoAiCloudClientConfig.getInstance().serviceAppId, - MoGoAiCloudClientConfig.getInstance().token, - BusCloseTaskRequest(taskId) - ) - .transformTry() - .subscribe(OchCommonSubscribeImpl(context, callback, "endTask")) - } - - /** - * 离站上报 - * @param context - * @param seq - * @param siteId - * @param callback - */ - @JvmStatic - fun leaveStation( - context: Context, - seq: Int, - siteId: Int, - taskId: Int, - callback: OchCommonServiceCallback? - ) { - mService.leaveStation( - MoGoAiCloudClientConfig.getInstance().serviceAppId, - MoGoAiCloudClientConfig.getInstance().token, - BusUpdateSiteStatusRequest(taskId, siteId, seq) - ) - .transformTry() - .subscribe(OchCommonSubscribeImpl(context, callback, "leaveStation")) - } - - /** - * 到站更新站点状态 - * @param context - * @param seq - * @param siteId - * @param callback - */ - @JvmStatic - fun arriveSiteStation( - context: Context, seq: Int, siteId: Int, taskId: Int, - callback: OchCommonServiceCallback? - ) { - mService.arriveSiteStation( - MoGoAiCloudClientConfig.getInstance().serviceAppId, - MoGoAiCloudClientConfig.getInstance().token, - BusUpdateSiteStatusRequest(taskId, siteId, seq) - ) - .transformTry() - .subscribe(OchCommonSubscribeImpl(context, callback, "arriveSiteStation")) - } - - /** - * 查询下车乘客 - * @param context - * @param seq - * @param siteId - * @param callback - */ - @JvmStatic - fun queryStationLeaveAwayPassengers( - context: Context, - seq: Int, - siteId: Int, - callback: OchCommonServiceCallback? - ) { - mService.queryStationLeaveAwayPassengers( - MoGoAiCloudClientConfig.getInstance().serviceAppId, - MoGoAiCloudClientConfig.getInstance().token, - QueryLeaveAwayPassengersRequest(seq, siteId) - ) - .transformTry() - .subscribe(OchCommonSubscribeImpl(context, callback, "queryStationLeaveAwayPassengers")) - } - - /** - * 查询当前到站点核销乘客 - * @param context - * @param siteId - * @param callback - */ - @JvmStatic - fun queryStationWriteOffPassengers( - context: Context, - taskId: Int, - siteId: Int, - prePassengerTime: Long, - callback: OchCommonServiceCallback? - ) { - mService.queryWriteOffPassengers( - MoGoAiCloudClientConfig.getInstance().serviceAppId, - MoGoAiCloudClientConfig.getInstance().token, - BusWriteOffPassengersQueryRequest(taskId, siteId, prePassengerTime) - ) - .transformTry() - .subscribe(OchCommonSubscribeImpl(context, callback, "queryStationWriteOffPassengers")) - } - - /** - * 查询小巴车订单 - * @param context - * @param callback - */ - @JvmStatic - fun queryBusOrders(context: Context, callback: OchCommonServiceCallback?) { - mService.queryBusOrders( - MoGoAiCloudClientConfig.getInstance().serviceAppId, - MoGoAiCloudClientConfig.getInstance().token, - MoGoAiCloudClientConfig.getInstance().sn - ) - .transformTry() - .subscribe(OchCommonSubscribeImpl(context, callback, "queryBusOrders")) - } - @JvmStatic - fun queryBusLines(context: Context, callback: OchCommonServiceCallback?) { - mService.queryBusLines( - MoGoAiCloudClientConfig.getInstance().serviceAppId, - MoGoAiCloudClientConfig.getInstance().token, - MoGoAiCloudClientConfig.getInstance().sn - ) - .transformTry() - .subscribe(OchCommonSubscribeImpl(context, callback, "queryBusLines")) - } - @JvmStatic - fun queryBusTaskByLineId( - context: Context, - lineId: String?, - callback: OchCommonServiceCallback? - ) { - mService.queryBusTaskByLineId( - MoGoAiCloudClientConfig.getInstance().serviceAppId, - MoGoAiCloudClientConfig.getInstance().token, - lineId - ) - .transformTry() - .subscribe(OchCommonSubscribeImpl(context, callback, "queryBusLines")) - } - @JvmStatic - fun updateOrderRoute( - context: Context, - lineId: Int, - startSiteId: Int, - endSiteId: Int, - points: List?, - callback: OchCommonServiceCallback? - ) { - mService.updateOrderRoute( - MoGoAiCloudClientConfig.getInstance().serviceAppId, - MoGoAiCloudClientConfig.getInstance().token, - BusRoutePlanningUpdateReqBean( - MoGoAiCloudClientConfig.getInstance().sn, lineId, startSiteId, endSiteId, points - ) - ) - .transformTry() - .subscribe(OchCommonSubscribeImpl(context, callback, "updateOrderRoute")) - } - - /** - * 车机端上传心跳数据(只在出车状态时上传):包含高德坐标系经纬度 - * @param context - * @param lon - * @param lat - * @param callback - */ - @JvmStatic - fun runCarHeartbeat( - context: Context, lon: Double, lat: Double, - callback: OchCommonServiceCallback? - ) { - mService.runCarHeartbeat( - MoGoAiCloudClientConfig.getInstance().serviceAppId, - MoGoAiCloudClientConfig.getInstance().token, - CarHeartbeatReqBean( - MoGoAiCloudClientConfig.getInstance().sn, lon, lat - ) - ) - .transformTry() - .subscribe(OchCommonSubscribeImpl(context, callback, "runCarHeartbeat")) - } - -} \ No newline at end of file diff --git a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/net/IBusApiService.java b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/net/IBusApiService.java deleted file mode 100644 index 32e8e7d1d0..0000000000 --- a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/net/IBusApiService.java +++ /dev/null @@ -1,164 +0,0 @@ -package com.mogo.och.bus.net; -import com.mogo.eagle.core.data.BaseData; -import com.mogo.och.bus.bean.BusCloseTaskRequest; -import com.mogo.och.bus.bean.BusOrdersResponse; -import com.mogo.och.bus.bean.BusQueryWriteOffPassengersResponse; -import com.mogo.och.bus.bean.BusWriteOffPassengersQueryRequest; -import com.mogo.och.bus.bean.BusQueryLineTaskResponse; -import com.mogo.och.bus.bean.BusQueryLinesResponse; -import com.mogo.och.bus.bean.BusRoutePlanningUpdateReqBean; -import com.mogo.och.bus.bean.BusRoutesResponse; -import com.mogo.och.bus.bean.CarHeartbeatReqBean; -import com.mogo.och.bus.bean.BusQueryLineStationsRequest; -import com.mogo.och.bus.bean.QueryLeaveAwayPassengersRequest; -import com.mogo.och.bus.bean.QueryLeaveAwayPassengersResponse; -import com.mogo.och.bus.bean.BusResetDrivingLineRequest; -import com.mogo.och.bus.bean.BusUpdateSiteStatusRequest; - -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; - -/** - * 小巴车相关接口 - * - * @author tongchenfei - *

- * wiki: http://wiki.zhidaohulian.com/pages/viewpage.action?pageId=48970072 - */ -public interface IBusApiService { - /** - * 根据车机坐标获取所在区域全部站点信息 - * - * @param request 请求参数 - * @return 接口返回数据 - */ - @Headers( {"Content-Type:application/json;charset=UTF-8"} ) -// @POST( "/autopilot-car-hailing/line/v2/lineDataWithDriver/query" ) - @POST( "/autopilot-car-hailing/line/v2/driver/bus/lineDataWithDriver/query" ) -// @POST( "/mock/268/autopilot-car-hailing/bus/api/lineDataWithDriver/query" ) - Observable queryBusRoutes(@Header ("appId") String appId, @Header("ticket") String ticket, @Body BusQueryLineStationsRequest request); - - /** - * @param request 请求参数{"destLine":1,"sn":"F803EB2046PZD00229"} 这个接口是重置bus线路的, 不是重置线路中站点的 - * @return 返回值是重置后的车站列表 - * 开始路线 - */ - @Headers( {"Content-Type:application/json;charset=UTF-8"} ) - @POST( "/autopilot-car-hailing/cab/flow/v1/bus/driver/bus/startTask" ) - Observable switchLine(@Header ("appId") String appId, @Header("ticket") String ticket, @Body BusResetDrivingLineRequest request); - - /** - * 离站,通知服务器 - * @param request - * @return - */ - @Headers({"Content-Type:application/json;charset=UTF-8"}) -// @POST("/autopilot-car-hailing/car/v2/bus/driving/away") -// @POST("/autopilot-car-hailing/car/v2/driver/bus/driving/away") - @POST("/autopilot-car-hailing/cab/flow/v1/bus/driver/bus/leave") -// @POST("/mock/268/autopilot-car-hailing/bus/api/driving/away") - Observable leaveStation(@Header ("appId") String appId, @Header("ticket") String ticket, @Body BusUpdateSiteStatusRequest request); - - /** - * 到站 更新到站信息 - * @param request - * @return - */ - @Headers({"Content-type:application/json;charset=UTF-8"}) -// @POST("/autopilot-car-hailing/order/v2/bus/driving/attachSite") -// @POST("/autopilot-car-hailing/order/v2/driver/bus/driving/attachSite") - @POST("/autopilot-car-hailing/cab/flow/v1/bus/driver/bus/arrive") -// @POST("/mock/268/autopilot-car-hailing/bus/api/driving/attachSite") - Observable< BaseData > arriveSiteStation(@Header ("appId") String appId,@Header("ticket") String ticket,@Body BusUpdateSiteStatusRequest request); - - - /** - * 到站查询下车乘客 - * @param request - * @return - */ - @Headers({"Content-type:application/json;charset=UTF-8"}) -// @POST("/autopilot-car-hailing/order/v2/bus/driving/siteArrivedOrders") - @POST("/autopilot-car-hailing/order/v2/driver/bus/driving/siteArrivedOrders") -// @POST("/mock/268/autopilot-car-hailing/bus/api/driving/siteArrivedOrders") - Observable< QueryLeaveAwayPassengersResponse > queryStationLeaveAwayPassengers(@Header ("appId") String appId,@Header("ticket") String ticket,@Body QueryLeaveAwayPassengersRequest request); - - @Headers({"Content-type:application/json;charset=UTF-8"}) -// @GET("/autopilot-car-hailing/order/v2/bus/servicingOrders/query") - @GET("/autopilot-car-hailing/order/v2/driver/bus/servicingOrders/query") -// @GET("/mock/268/autopilot-car-hailing/bus/api/servicingOrders/query") - Observable queryBusOrders(@Header ("appId") String appId, @Header("ticket") String ticket, @Query("sn") String sn); - - /** - * 车机端上传心跳数据(只在出车状态时上传):包含高德坐标系经纬度 - * @param data - * @return - */ - @Headers( {"Content-type:application/json;charset=UTF-8"} ) -// @POST( "/autopilot-car-hailing/location/v2/driver/heartbeat" ) - @POST( "/autopilot-car-hailing/location/v2/driver/bus/heartbeat" ) - Observable runCarHeartbeat(@Header ("appId") String appId,@Header("ticket") String ticket,@Body CarHeartbeatReqBean data); - - /** - * 查询车辆配置的所有路线 - * @param appId - * @param ticket - * @param sn - * @return - */ - @GET("/autopilot-car-hailing/line/v2/driver/bus/bindLine/query") - Observable queryBusLines(@Header ("appId") String appId, @Header("ticket") String ticket, @Query("sn") String sn); - - /** - * 查询路线当天的任务 - * @param appId - * @param ticket - * @param lineId 线路id - * @return - */ - @GET("/autopilot-car-hailing/line/v2/driver/bus/task/query") - Observable queryBusTaskByLineId(@Header ("appId") String appId, @Header("ticket") String ticket, @Query("lineId") String lineId); - - - @Headers( {"Content-type:application/json;charset=UTF-8"} ) - @POST( "/autopilot-car-hailing/location/v2/driver/bus/saveLineCoordinate" ) - Observable updateOrderRoute(@Header ("appId") String appId, @Header("ticket") String ticket, @Body BusRoutePlanningUpdateReqBean data); - - /** - * 中止任务 - * @param appId - * @param ticket - * @param data - * @return - */ - @POST("/autopilot-car-hailing/cab/flow/v1/bus/driver/bus/abortTask") - Observable abortTask(@Header ("appId") String appId, @Header("ticket") String ticket, @Body BusCloseTaskRequest data); - - /** - * 任务正常跑完结束 - * @param appId - * @param ticket - * @param data - * @return - */ - @Headers( {"Content-type:application/json;charset=UTF-8"} ) - @POST("/autopilot-car-hailing/cab/flow/v1/bus/driver/bus/endTask") - Observable endTask(@Header ("appId") String appId, @Header("ticket") String ticket, @Body BusCloseTaskRequest data); - - /** - * 查询核销乘客,目前不再使用,改为后台下发核销的乘客 - * @param appId - * @param ticket - * @param data - * @return - */ - @Headers( {"Content-type:application/json;charset=UTF-8"} ) - @POST("/autopilot-car-hailing/operation/v1/driver/order/verificationResult") - Observable queryWriteOffPassengers(@Header ("appId") String appId, @Header("ticket") String ticket, @Body BusWriteOffPassengersQueryRequest data); -} - diff --git a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/net/login/LoginBusImpl.kt b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/net/login/LoginBusImpl.kt new file mode 100644 index 0000000000..0f3c2d294f --- /dev/null +++ b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/net/login/LoginBusImpl.kt @@ -0,0 +1,47 @@ +package com.mogo.och.bus.net.login + +import android.content.Context +import com.mogo.eagle.core.data.BaseData +import com.mogo.och.common.module.biz.bean.DriverStatusQueryRespBean +import com.mogo.och.common.module.biz.bean.TaxiLoginReqBean +import com.mogo.och.common.module.biz.bean.TaxiLoginRespBean +import com.mogo.och.common.module.biz.bean.TaxiLogoutReqBean +import com.mogo.och.common.module.biz.network.LoginDefaultManage +import com.mogo.och.common.module.biz.network.OchCommonServiceCallback + +class LoginBusImpl: LoginDefaultManage { + + override fun getPhoneCode( + context: Context, phone: String?, + callback: OchCommonServiceCallback? + ) { + OchCommonServiceManager.getPhoneCode(context,phone,callback) + } + + override fun gotoLoginBycode( + context: Context, + phone: String?, + code: String?, + location4Login: TaxiLoginReqBean.Location4Login?, + callback: OchCommonServiceCallback? + ) { + OchCommonServiceManager.gotoLoginBycode(context,phone,code,location4Login,callback) + } + + override fun logout( + context: Context, + location4Login: TaxiLogoutReqBean.Location4Login?, + callback: OchCommonServiceCallback? + ) { + OchCommonServiceManager.logout(context,location4Login,callback) + } + + override fun queryDriverServiceStatus( + context: Context, + callback: OchCommonServiceCallback? + ) { + OchCommonServiceManager.queryDriverServiceStatus(context,callback) + } + + +} \ No newline at end of file diff --git a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/presenter/BusLinePresenter.java b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/presenter/BusLinePresenter.java index 512346c064..9411be65fd 100644 --- a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/presenter/BusLinePresenter.java +++ b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/presenter/BusLinePresenter.java @@ -11,7 +11,7 @@ import com.mogo.och.bus.bean.BusQueryLineTaskResponse; import com.mogo.och.bus.bean.BusQueryLinesResponse; import com.mogo.och.bus.callback.IBusLinesCallback; import com.mogo.och.bus.model.BusLineModel; -import com.mogo.och.bus.model.BusOrderModel; +import com.mogo.och.bus.model.OrderModel; import com.mogo.och.bus.ui.BusSwitchLineView; import java.util.concurrent.TimeUnit; @@ -30,7 +30,7 @@ public class BusLinePresenter extends Presenter implements IB public BusLinePresenter(BusSwitchLineView view) { super(view); BusLineModel.getInstance().init(); - BusOrderModel.getInstance().init(); + OrderModel.getInstance().init(); } @Override @@ -61,7 +61,7 @@ public class BusLinePresenter extends Presenter implements IB @Override public void onChangeLineIdSuccess() { - BusOrderModel.getInstance().clearBusStationDatas(); + OrderModel.getInstance().clearBusStationDatas(); runOnUIThread(() -> mView.onChangeLineIdSuccess()); } @@ -91,7 +91,7 @@ public class BusLinePresenter extends Presenter implements IB } public void queryBusRoutes(){ - BusOrderModel.getInstance().queryBusRoutes(); + OrderModel.getInstance().queryBusRoutes(); } @Override diff --git a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/presenter/BusModelLoopManager.java b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/presenter/BusModelLoopManager.java index 9baa585f9f..3c8415d86c 100644 --- a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/presenter/BusModelLoopManager.java +++ b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/presenter/BusModelLoopManager.java @@ -1,12 +1,10 @@ package com.mogo.och.bus.presenter; import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_BUS; -import static com.mogo.och.bus.constant.BusConst.LOOP_DELAY_500; -import static com.mogo.och.bus.constant.BusConst.LOOP_PASSENGER_5S; import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger; import com.mogo.och.bus.constant.BusConst; -import com.mogo.och.bus.model.BusOrderModel; +import com.mogo.och.bus.model.OrderModel; import java.util.concurrent.TimeUnit; @@ -66,7 +64,7 @@ public class BusModelLoopManager { .map((aLong -> aLong + 1)) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) - .subscribe(aLong -> BusOrderModel.getInstance().runCarHeartbeat()); + .subscribe(aLong -> OrderModel.getInstance().runCarHeartbeat()); } public void stopHeartbeatLoop() { diff --git a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/presenter/BusPresenter.java b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/presenter/BusPresenter.java index f657813645..3e97df4a91 100644 --- a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/presenter/BusPresenter.java +++ b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/presenter/BusPresenter.java @@ -26,7 +26,7 @@ import com.mogo.och.bus.callback.IPassengerCallback; import com.mogo.och.bus.callback.IRefreshBusStationsCallback; import com.mogo.och.bus.callback.ISlidePannelHideCallback; import com.mogo.och.bus.fragment.BusFragment; -import com.mogo.och.bus.model.BusOrderModel; +import com.mogo.och.bus.model.OrderModel; import com.mogo.och.bus.util.BusTrajectoryManager; import com.mogo.och.common.module.biz.bean.DriverStatusQueryRespBean; import com.mogo.och.common.module.biz.callback.ILoginCallback; @@ -62,7 +62,7 @@ public class BusPresenter extends Presenter super(view); //2021.11.1 鹰眼架构整合,由IMoGoAutopilotStatusListener逐步替代IMogoAdasOCHCallback接口 CallerAutoPilotStatusListenerManager.INSTANCE.addListener(TAG, this); - BusOrderModel.getInstance().init(); + OrderModel.getInstance().init(); OCHAdasAbilityManager.getInstance().init(AbsMogoApplication.getApp()); } @@ -75,48 +75,48 @@ public class BusPresenter extends Presenter @Override public void onDestroy(@NonNull LifecycleOwner owner) { super.onDestroy(owner); - BusOrderModel.getInstance().release(); + OrderModel.getInstance().release(); releaseListener(); } public void initModelListener() { - BusOrderModel.getInstance().setRefreshBusStationsCallback(this); - BusOrderModel.getInstance().setSlidePanelHideCallback(this); - BusOrderModel.getInstance().setControllerStatusCallback(this); - BusOrderModel.getInstance().setPassengerCallback(this); - BusOrderModel.getInstance().setAdasStatusCallback(this); + OrderModel.getInstance().setRefreshBusStationsCallback(this); + OrderModel.getInstance().setSlidePanelHideCallback(this); + OrderModel.getInstance().setControllerStatusCallback(this); + OrderModel.getInstance().setPassengerCallback(this); + OrderModel.getInstance().setAdasStatusCallback(this); } public void releaseListener() { - BusOrderModel.getInstance().setRefreshBusStationsCallback(null); - BusOrderModel.getInstance().setSlidePanelHideCallback(null); - BusOrderModel.getInstance().setControllerStatusCallback(null); - BusOrderModel.getInstance().setPassengerCallback(null); - BusOrderModel.getInstance().setAdasStatusCallback(null); + OrderModel.getInstance().setRefreshBusStationsCallback(null); + OrderModel.getInstance().setSlidePanelHideCallback(null); + OrderModel.getInstance().setControllerStatusCallback(null); + OrderModel.getInstance().setPassengerCallback(null); + OrderModel.getInstance().setAdasStatusCallback(null); OCHAdasAbilityManager.getInstance().release(); } public void abortTask() { - BusOrderModel.getInstance().abortTask(); + OrderModel.getInstance().abortTask(); } public void autoDriveToNextStation() { currentAutopilotStatus = -1; - BusOrderModel.getInstance().autoDriveToNextStation(); + OrderModel.getInstance().autoDriveToNextStation(); // isRestartAutopilot = false; } public void restartAutopilot() { - if (BusOrderModel.getInstance().isGoingToNextStation()){ + if (OrderModel.getInstance().isGoingToNextStation()){ currentAutopilotStatus = -1; - BusOrderModel.getInstance().restartAutopilot(); + OrderModel.getInstance().restartAutopilot(); // isRestartAutopilot = true; } } // 登出 public void logout() { - BusOrderModel.getInstance().logout(); + OrderModel.getInstance().logout(); } @Override @@ -151,15 +151,15 @@ public class BusPresenter extends Presenter @Override public void hideSlidePanel() { if (mView != null) { - runOnUIThread(() -> mView.hideSlidePanel()); - runOnUIThread(()-> mView.setArrivedClikable(true)); + mView.hideSlidePanel(); + mView.setArrivedClikable(true); } } @Override public void onAutopilotArriveAtStation(MessagePad.ArrivalNotification arrivalNotification) { CallerLogger.INSTANCE.e( M_BUS + TAG, "行程日志-onAutopilotArriveAtStation arrive"); - BusOrderModel.getInstance().onArriveAt(arrivalNotification); + OrderModel.getInstance().onArriveAt(arrivalNotification); } @Override @@ -181,7 +181,7 @@ public class BusPresenter extends Presenter if (FunctionBuildConfig.isDemoMode && ( (mCurrentStation >= 0 && mCurrentStation <= mStationList.size() - 1) - && BusOrderModel.getInstance().isGoingToNextStation() + && OrderModel.getInstance().isGoingToNextStation() ) ) { CallerLogger.INSTANCE.d(M_BUS + "BusOrderModel=", "有美化功能"); @@ -196,8 +196,8 @@ public class BusPresenter extends Presenter case IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING: if (currentAutopilotStatus != IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING) { currentAutopilotStatus = IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING; - BusOrderModel.getInstance().triggerStartServiceEvent( - BusOrderModel.getInstance().isRestartAutopilot(), true); + OrderModel.getInstance().triggerStartServiceEvent( + OrderModel.getInstance().isRestartAutopilot(), true); } // 改变UI自动驾驶状态 runOnUIThread(() -> mView.onAutopilotStatusChanged(currentAutopilotStatus)); @@ -206,7 +206,7 @@ public class BusPresenter extends Presenter if (FunctionBuildConfig.isDemoMode && ( (mCurrentStation >= 0 && mCurrentStation <= mStationList.size() - 1) - && BusOrderModel.getInstance().isGoingToNextStation() + && OrderModel.getInstance().isGoingToNextStation() ) ) { @@ -221,6 +221,24 @@ public class BusPresenter extends Presenter mView.onAutopilotStatusChanged(currentAutopilotStatus); }); break; + case IMoGoAutopilotStatusListener.STATUS_PARALLEL_DRIVING: + if (FunctionBuildConfig.isDemoMode + && ( + (mCurrentStation >= 0 && mCurrentStation <= mStationList.size() - 1) + && OrderModel.getInstance().isGoingToNextStation() + + ) + ) { + CallerLogger.INSTANCE.d(M_BUS + "BusOrderModel=", "有美化功能"); + return; + } + if (currentAutopilotStatus != IMoGoAutopilotStatusListener.STATUS_PARALLEL_DRIVING) { + currentAutopilotStatus = IMoGoAutopilotStatusListener.STATUS_PARALLEL_DRIVING; + } + runOnUIThread(() -> { + mView.onAutopilotStatusChanged(currentAutopilotStatus); + }); + break; default: runOnUIThread(() -> mView.onAutopilotEnableChange(false)); break; @@ -235,7 +253,7 @@ public class BusPresenter extends Presenter @Override public void onCarLocationChanged(MogoLocation location) { if (null != location) { - runOnUIThread(() -> mView.updateSpeedView(location.getSpeed())); + runOnUIThread(() -> mView.updateSpeedView((float) location.getGnssSpeed())); } } @@ -289,15 +307,15 @@ public class BusPresenter extends Presenter public void loginSuccess(DriverStatusQueryRespBean data) { CallerLogger.INSTANCE.d(M_BUS + TAG, " loginStatus =" + LoginStatusManager.isLogin()); if(LoginStatusManager.isLogin()){ - BusOrderModel.getInstance().startOrStopOrderLoop(true); - BusOrderModel.getInstance().queryBusRoutes(); + OrderModel.getInstance().startOrStopOrderLoop(true); + OrderModel.getInstance().queryBusRoutes(); }else { BusTrajectoryManager.getInstance().stopTrajReqLoop(); - BusOrderModel.getInstance().startOrStopOrderLoop(false); + OrderModel.getInstance().startOrStopOrderLoop(false); BusTrajectoryManager.getInstance().stopTrajReqLoop(); clearBusStationsMarkers(); mView.hideSlidePanel(); - BusOrderModel.getInstance().closeBeautificationMode(); + OrderModel.getInstance().closeBeautificationMode(); } } @@ -311,9 +329,11 @@ public class BusPresenter extends Presenter int passengerNum = passenger.passengerSize; if (passengerNum > 1){ //多人播报 "x人" ---》x人核验通过 VoiceNotice.showNotice(passengerNum+"人核验通过", AIAssist.LEVEL3); + OrderModel.getInstance().sendWriteOffNumToClient(passengerNum+"人核验通过"); }else { //是 1 播放 "滴" 2022.11.09 改为: "核验通过" // mView.playDI(); VoiceNotice.showNotice("核验通过", AIAssist.LEVEL3); + OrderModel.getInstance().sendWriteOffNumToClient("核验通过"); } } diff --git a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/ui/BusTrafficLightView.java b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/ui/BusTrafficLightView.java deleted file mode 100644 index 4b25021821..0000000000 --- a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/ui/BusTrafficLightView.java +++ /dev/null @@ -1,167 +0,0 @@ -package com.mogo.och.bus.ui; - -import android.content.Context; -import android.util.AttributeSet; -import android.view.LayoutInflater; -import android.widget.ImageView; - -import com.mogo.eagle.core.function.api.hmi.view.IViewTrafficLight; -import com.mogo.eagle.core.utilcode.util.UiThreadHandler; -import com.mogo.och.bus.R; -import com.mogo.och.common.module.wigets.OCHGradientTextView; - -import org.jetbrains.annotations.Nullable; - -/** - * Bus司机端:红绿灯view - * - * Created on 2022/3/29 - */ -public class BusTrafficLightView extends IViewTrafficLight { - - private ImageView mLightIconIV; - private OCHGradientTextView mLightTimeTV; - private int mCurrentLightId; - - public BusTrafficLightView(@Nullable Context context) { - this(context, null, 0); - } - - public BusTrafficLightView(@Nullable Context context, @Nullable AttributeSet attrs) { - this(context, attrs, 0); - } - - public BusTrafficLightView(@Nullable Context context, @Nullable AttributeSet attrs, int defStyleAttr) { - super(context, attrs, defStyleAttr); - init(context); - } - - private void init(Context context) { - LayoutInflater.from(context).inflate(R.layout.bus_traffic_light_view, this, true); - mLightIconIV = findViewById(R.id.bus_traffic_light_iv); - mLightTimeTV = findViewById(R.id.bus_traffic_light_time_tv); - } - - /** - * 展示红绿灯预警 - * - * @param checkLightId 0-都是默认,1-红,2-黄,3-绿 - * @param lightSource 1:云端下发;2:自车感知 - */ - @Override - public void showWarningTrafficLight(int checkLightId,int lightSource) { - super.showWarningTrafficLight(checkLightId,lightSource); - mCurrentLightId = checkLightId; - updateTrafficLightIcon(checkLightId); - } - - /** - * 关闭红绿灯预警展示,并重制灯态 - */ - @Override - public void disableWarningTrafficLight() { - super.disableWarningTrafficLight(); - UiThreadHandler.post(() -> { - mCurrentLightId = 0; - BusTrafficLightView.this.setVisibility(GONE); - }); - } - - /** - * @param redNum 红灯倒计时 - * @param yellowNum 黄灯倒计时 - * @param greenNum 绿灯倒计时 - */ - @Override - public void changeCountdownTrafficLightNum(int redNum, int yellowNum, int greenNum) { - super.changeCountdownTrafficLightNum(redNum, yellowNum, greenNum); - switch (mCurrentLightId) { - case 1: - changeCountdownRed(redNum); - break; - case 2: - changeCountdownYellow(yellowNum); - break; - case 3: - changeCountdownGreen(greenNum); - break; - default: - UiThreadHandler.post(() -> { - mLightTimeTV.setText(""); - }); - break; - } - } - - @Override - public void changeCountdownRed(int redNum) { - super.changeCountdownRed(redNum); - UiThreadHandler.post(() -> { - if (redNum > 0) { - mLightTimeTV.setVertrial(true); - mLightTimeTV.setmColorList(new int[]{getResources().getColor(R.color.bus_traffic_light_red_color_up), - getResources().getColor(R.color.bus_traffic_light_red_color_down)}); - mLightTimeTV.setText(String.valueOf(redNum)); - } else { - mLightTimeTV.setText(""); - } - }); - } - - @Override - public void changeCountdownGreen(int greenNum) { - super.changeCountdownGreen(greenNum); - UiThreadHandler.post(() -> { - if (greenNum > 0) { - mLightTimeTV.setVertrial(true); - mLightTimeTV.setmColorList(new int[]{getResources().getColor(R.color.bus_traffic_light_green_color_up), - getResources().getColor(R.color.bus_traffic_light_green_color_down)}); - mLightTimeTV.setText(String.valueOf(greenNum)); - } else { - mLightTimeTV.setText(""); - } - }); - } - - @Override - public void changeCountdownYellow(int yellowNum) { - super.changeCountdownYellow(yellowNum); - UiThreadHandler.post(() -> { - if (yellowNum > 0) { - mLightTimeTV.setVertrial(true); - mLightTimeTV.setmColorList(new int[]{getResources().getColor(R.color.bus_traffic_light_yellow_color_up), - getResources().getColor(R.color.bus_traffic_light_yellow_color_down)}); - mLightTimeTV.setText(String.valueOf(yellowNum)); - } else { - mLightTimeTV.setText(""); - } - }); - } - - /** - * 更新红绿灯icon - * - * @param lightId 0-都是默认,1-红,2-黄,3-绿 - */ - private void updateTrafficLightIcon(int lightId) { - UiThreadHandler.post(() -> { - switch (lightId) { - case 1: - mLightIconIV.setBackgroundResource(R.drawable.bus_light_red_nor); - BusTrafficLightView.this.setVisibility(VISIBLE); - break; - case 2: - mLightIconIV.setBackgroundResource(R.drawable.bus_lightyellow_nor); - BusTrafficLightView.this.setVisibility(VISIBLE); - break; - case 3: - mLightIconIV.setBackgroundResource(R.drawable.bus_light_green_nor); - BusTrafficLightView.this.setVisibility(VISIBLE); - break; - default: - BusTrafficLightView.this.setVisibility(GONE); - break; - } - }); - } -} diff --git a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/util/BDRouteDataTestUtils.java b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/util/BDRouteDataTestUtils.java index 76d61a56cf..a9ff4aad99 100644 --- a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/util/BDRouteDataTestUtils.java +++ b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/util/BDRouteDataTestUtils.java @@ -1,6 +1,6 @@ package com.mogo.och.bus.util; -import com.mogo.och.bus.model.BusOrderModel; +import com.mogo.och.bus.model.OrderModel; import org.json.JSONArray; import org.json.JSONException; @@ -37,7 +37,7 @@ public class BDRouteDataTestUtils { builder.setLongitude(s.getDouble("lon")); list.add(builder.build()); } - BusOrderModel.getInstance().debugUpdateOrderRoute(list); + OrderModel.getInstance().debugUpdateOrderRoute(list); } catch (JSONException e) { e.printStackTrace(); } diff --git a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/util/BusAnalyticsManager.java b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/util/BusAnalyticsManager.java index eaefe8db87..b37e399e18 100644 --- a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/util/BusAnalyticsManager.java +++ b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/util/BusAnalyticsManager.java @@ -2,14 +2,13 @@ package com.mogo.och.bus.util; import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_BUS; -import android.annotation.SuppressLint; import android.text.TextUtils; import com.mogo.cloud.passport.MoGoAiCloudClientConfig; import com.mogo.commons.debug.DebugConfig; import com.mogo.eagle.core.data.app.AppConfigInfo; import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener; -import com.mogo.eagle.core.function.call.analytics.AnalyticsManager; +import com.mogo.commons.utils.MogoAnalyticUtils; import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager; import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger; import com.mogo.eagle.core.utilcode.util.DateTimeUtils; @@ -60,14 +59,13 @@ public class BusAnalyticsManager { , CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState() == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING); - AnalyticsManager.INSTANCE.track(mStartAutopilotKey, mStartAutopilotParams); + MogoAnalyticUtils.INSTANCE.track(mStartAutopilotKey, mStartAutopilotParams); clearStartAutopilotParams();//清空参数数据,防止误传 } private void removeWaitingCallback() { - if (startAutopilotRunnable != null && - UiThreadHandler.getsUiHandler().hasCallbacks(startAutopilotRunnable)) { + if (startAutopilotRunnable != null) { UiThreadHandler.removeCallbacks(startAutopilotRunnable); } } @@ -111,7 +109,7 @@ public class BusAnalyticsManager { clearStartAutopilotFailureMSG(); removeWaitingCallback(); mStartAutopilotParams.put(BusConst.EVENT_PARAM_START_RESULT, true); - AnalyticsManager.INSTANCE.track(mStartAutopilotKey, mStartAutopilotParams); + MogoAnalyticUtils.INSTANCE.track(mStartAutopilotKey, mStartAutopilotParams); clearStartAutopilotParams();//清空参数数据,防止误传 } else { @@ -143,6 +141,6 @@ public class BusAnalyticsManager { params.put(BusConst.EVENT_PARAM_END_NAME, endName); params.put(BusConst.EVENT_PARAM_LINE_ID, lineId); params.put(BusConst.EVENT_PARAM_UNABLE_START_REASON, reason); - AnalyticsManager.INSTANCE.track(BusConst.EVENT_KEY_AP_UNABLE_START_REASON, params); + MogoAnalyticUtils.INSTANCE.track(BusConst.EVENT_KEY_AP_UNABLE_START_REASON, params); } } diff --git a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/util/BusSendTripInfoManager.kt b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/util/BusSendTripInfoManager.kt index 9d0073363a..b4da61f56f 100644 --- a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/util/BusSendTripInfoManager.kt +++ b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/util/BusSendTripInfoManager.kt @@ -1,6 +1,6 @@ package com.mogo.och.bus.util -import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotManager +import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant @@ -31,6 +31,6 @@ object BusSendTripInfoManager{ d(SceneConstant.M_BUS + "BusSendTripInfoManager", "type: "+ type +", lineName: "+ lineName +", departureStopName: "+ departureStopName + ", arrivalStopName: "+arrivalStopName+", isLastStop: "+isLastStop) - CallerAutoPilotManager.sendTripInfo(type,lineName,departureStopName, arrivalStopName, isLastStop) + CallerAutoPilotControlManager.sendTripInfo(type,lineName,departureStopName, arrivalStopName, isLastStop) } } diff --git a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/util/BusTrajectoryManager.java b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/util/BusTrajectoryManager.java index 94ad2be2d1..6cf6eb90c4 100644 --- a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/util/BusTrajectoryManager.java +++ b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/util/BusTrajectoryManager.java @@ -3,12 +3,13 @@ package com.mogo.och.bus.util; import androidx.annotation.Nullable; import com.mogo.eagle.core.data.autopilot.AutopilotControlParameters; -import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotManager; +import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager; import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger; import com.mogo.eagle.core.utilcode.util.GsonUtils; import com.mogo.och.bus.bean.BusRoutesResult; import com.mogo.och.bus.constant.BusConst; -import com.mogo.och.bus.model.BusOrderModel; +import com.mogo.och.bus.model.OrderModel; +import com.mogo.och.common.module.biz.constant.LoginStatusManager; import com.zhidao.socket.utils.LoginStatusUtil; import java.util.concurrent.TimeUnit; @@ -49,10 +50,10 @@ public class BusTrajectoryManager { * 同步Bus路线信息 */ public void syncTrajectoryInfo() { - BusRoutesResult routesResult = BusOrderModel.getInstance().getBusRoutesResult(); - if (LoginStatusUtil.isLogin() && routesResult != null - && BusOrderModel.getInstance().getCurrentStationIndex() == 0 - && !BusOrderModel.getInstance().isGoingToNextStation()) { + BusRoutesResult routesResult = OrderModel.getInstance().getBusRoutesResult(); + if (LoginStatusManager.isLogin() && routesResult != null + && OrderModel.getInstance().getCurrentStationIndex() == 0 + && !OrderModel.getInstance().isGoingToNextStation()) { CallerLogger.INSTANCE.d(M_BUS + TAG, "syncTrajectoryInfo() start."); startTrajReqLoop(); } else { @@ -96,7 +97,7 @@ public class BusTrajectoryManager { } private void setupAutoPilotLine() { - BusRoutesResult routesResult = BusOrderModel.getInstance().getBusRoutesResult(); + BusRoutesResult routesResult = OrderModel.getInstance().getBusRoutesResult(); if (routesResult == null) { CallerLogger.INSTANCE.e(M_BUS + TAG, "setupAutoPilotLine(): routesResult is null."); @@ -198,7 +199,7 @@ public class BusTrajectoryManager { // mAutoPilotLine.setTimestamp(1654761600000L); //20220609 16:00 // mAutoPilotLine.setVehicleModel("红旗H9"); - CallerAutoPilotManager.INSTANCE.sendTrajectoryDownloadReq(mAutoPilotLine); + CallerAutoPilotControlManager.INSTANCE.sendTrajectoryDownloadReq(mAutoPilotLine); CallerLogger.INSTANCE.d(M_BUS + TAG, "sendTrajectoryReq(): " + GsonUtils.toJson(mAutoPilotLine)); } diff --git a/OCH/mogo-och-bus/src/main/res/drawable-xhdpi/bus_operation_status_bg.png b/OCH/mogo-och-bus/src/main/res/drawable-xhdpi/bus_operation_status_bg.png new file mode 100644 index 0000000000..3c339efde4 Binary files /dev/null and b/OCH/mogo-och-bus/src/main/res/drawable-xhdpi/bus_operation_status_bg.png differ diff --git a/OCH/mogo-och-bus/src/main/res/drawable-xhdpi/bus_operation_status_select_bg.png b/OCH/mogo-och-bus/src/main/res/drawable-xhdpi/bus_operation_status_select_bg.png new file mode 100644 index 0000000000..c6717d2518 Binary files /dev/null and b/OCH/mogo-och-bus/src/main/res/drawable-xhdpi/bus_operation_status_select_bg.png differ diff --git a/OCH/mogo-och-bus/src/main/res/drawable-xhdpi/icon_ai_collect.png b/OCH/mogo-och-bus/src/main/res/drawable-xhdpi/icon_ai_collect.png new file mode 100755 index 0000000000..6da7b81fe4 Binary files /dev/null and b/OCH/mogo-och-bus/src/main/res/drawable-xhdpi/icon_ai_collect.png differ diff --git a/OCH/mogo-och-bus/src/main/res/drawable-xhdpi/icon_bad_case.png b/OCH/mogo-och-bus/src/main/res/drawable-xhdpi/icon_bad_case.png new file mode 100755 index 0000000000..22f88301f9 Binary files /dev/null and b/OCH/mogo-och-bus/src/main/res/drawable-xhdpi/icon_bad_case.png differ diff --git a/OCH/mogo-och-bus/src/main/res/drawable-xhdpi/pingxingjiashi.png b/OCH/mogo-och-bus/src/main/res/drawable-xhdpi/pingxingjiashi.png new file mode 100644 index 0000000000..78bfa2687f Binary files /dev/null and b/OCH/mogo-och-bus/src/main/res/drawable-xhdpi/pingxingjiashi.png differ diff --git a/OCH/mogo-och-bus/src/main/res/drawable/bus_autopilot_0_1_status_bg.xml b/OCH/mogo-och-bus/src/main/res/drawable/bus_autopilot_0_1_status_bg.xml new file mode 100644 index 0000000000..21c3611ffe --- /dev/null +++ b/OCH/mogo-och-bus/src/main/res/drawable/bus_autopilot_0_1_status_bg.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/OCH/mogo-och-bus/src/main/res/drawable/bus_autopilot_2_status_bg.xml b/OCH/mogo-och-bus/src/main/res/drawable/bus_autopilot_2_status_bg.xml new file mode 100644 index 0000000000..1b95919363 --- /dev/null +++ b/OCH/mogo-och-bus/src/main/res/drawable/bus_autopilot_2_status_bg.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/OCH/mogo-och-bus/src/main/res/drawable/bus_autopilot_status_bg.xml b/OCH/mogo-och-bus/src/main/res/drawable/bus_autopilot_status_bg.xml deleted file mode 100644 index ad57da1c3a..0000000000 --- a/OCH/mogo-och-bus/src/main/res/drawable/bus_autopilot_status_bg.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/OCH/mogo-och-bus/src/main/res/drawable/bus_operation_status_select_bg.xml b/OCH/mogo-och-bus/src/main/res/drawable/bus_operation_status_select_bg.xml deleted file mode 100644 index f617cd9fce..0000000000 --- a/OCH/mogo-och-bus/src/main/res/drawable/bus_operation_status_select_bg.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/OCH/mogo-och-bus/src/main/res/layout/bus_base_fragment.xml b/OCH/mogo-och-bus/src/main/res/layout/bus_base_fragment.xml index af192612df..04f8739e01 100644 --- a/OCH/mogo-och-bus/src/main/res/layout/bus_base_fragment.xml +++ b/OCH/mogo-och-bus/src/main/res/layout/bus_base_fragment.xml @@ -5,32 +5,177 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginTop="@dimen/dp_72"> - + + + + + + + android:layout_height="match_parent" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + app:layout_constraintLeft_toLeftOf="parent" + app:layout_constraintTop_toBottomOf="@+id/fl_speed" + tools:visibility="visible"> + app:layout_constraintTop_toBottomOf="@id/module_mogo_och_station_panel_container" + tools:visibility="visible" /> - + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + app:layout_constraintLeft_toLeftOf="parent" /> + @@ -160,16 +296,13 @@ android:layout_height="@dimen/dp_80" android:layout_centerInParent="true" android:layout_gravity="center" - android:src="@drawable/bad_case_selector" /> + android:src="@drawable/icon_bad_case" /> @@ -179,7 +312,7 @@ android:layout_height="@dimen/dp_80" android:layout_centerInParent="true" android:layout_gravity="center" - android:src="@drawable/ai_collect_selector" /> + android:src="@drawable/icon_ai_collect" /> +