[fea]
This commit is contained in:
yangyakun
2024-09-18 16:00:30 +08:00
parent dbf2f160a1
commit d159d9f975
5 changed files with 45 additions and 79 deletions

View File

@@ -7,7 +7,6 @@ import com.mogo.commons.storage.SharedPrefsMgr
import com.mogo.eagle.core.data.config.FunctionBuildConfig
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager
import com.mogo.eagle.core.network.utils.digest.DigestUtils
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_BUS
import com.mogo.eagle.core.utilcode.util.NetworkUtils
@@ -55,10 +54,10 @@ object BusLineModel {
private const val TAG = "BusLineModel"
// 判断接口是否变化
private const val executableChangeMd5 = "EXECUTABLECHANGEMD5"
private const val EXECUTABLECHANGEMD5 = "EXECUTABLECHANGEMD5"
// 展示上一次刷新时间
const val executableChangeTime = "executablechangetime"
const val EXECUTABLECHANGETIME = "executablechangetime"
var currentTask: TaskDataBean?=null
@@ -67,11 +66,7 @@ object BusLineModel {
private val isRequesting = AtomicBoolean(false)
private val loopQueryInfo = object :Runnable{
override fun run() {
queryCarExecutableTaskList(true)
}
}
private val loopQueryInfo = Runnable { queryCarExecutableTaskList(true) }
// 当前站点
@JvmStatic
@@ -126,24 +121,24 @@ object BusLineModel {
// 第一次过滤 请求返回值的md5
val currentRequest = DigestUtils.md5Hex(data.data.toString())
val lastChangeMd5 =
SharedPrefsMgr.getInstance().getString(executableChangeMd5)
val lastUpdateTime = SharedPrefsMgr.getInstance().getLong(executableChangeTime, 0)
SharedPrefsMgr.getInstance().getString(EXECUTABLECHANGEMD5)
val lastUpdateTime = SharedPrefsMgr.getInstance().getLong(EXECUTABLECHANGETIME, 0)
val currentTimeStamp = DateTimeUtil.getCurrentTimeStamp()
SharedPrefsMgr.getInstance().putLong(executableChangeTime, currentTimeStamp)
SharedPrefsMgr.getInstance().putLong(EXECUTABLECHANGETIME, currentTimeStamp)
val sameDay = DateTimeUtil.isSameDay(currentTimeStamp, lastUpdateTime)
mBusLinesCallbackMap.forEach {
it.value.onRefreshSuccess(currentTimeStamp)
mBusLinesCallbackMap.forEach {callback->
callback.value.onRefreshSuccess(currentTimeStamp)
}
if(isBackground){
if (currentRequest == lastChangeMd5 && sameDay) {
return
}
}
SharedPrefsMgr.getInstance().putString(executableChangeMd5, currentRequest)
SharedPrefsMgr.getInstance().putString(EXECUTABLECHANGEMD5, currentRequest)
OchChainLogManager.writeChainLog(
"数据发生变化",
"接口信息发生变化 ${lastChangeMd5} new md5${currentRequest}"
"接口信息发生变化 $lastChangeMd5 new md5${currentRequest}"
)
CarExecutableTaskResponse.save2Db(data)
}
@@ -153,9 +148,9 @@ object BusLineModel {
BizLoopManager.postDelayed(loopQueryInfo,60_000)
if(!isBackground){
if (!NetworkUtils.isConnected(mContext)) {
ToastUtils.showShort(ResourcesUtils.getString(R.string.network_error_tip));
ToastUtils.showShort(ResourcesUtils.getString(R.string.network_error_tip))
} else {
ToastUtils.showShort(ResourcesUtils.getString(R.string.request_error_tip));
ToastUtils.showShort(ResourcesUtils.getString(R.string.request_error_tip))
}
}
}
@@ -165,9 +160,9 @@ object BusLineModel {
BizLoopManager.postDelayed(loopQueryInfo,60_000)
if(!isBackground){
if (!NetworkUtils.isConnected(mContext)) {
ToastUtils.showShort("网络异常,请稍后重试");
ToastUtils.showShort("网络异常,请稍后重试")
}else {
ToastUtils.showShort(failMsg);
ToastUtils.showShort(failMsg)
}
}
@@ -186,15 +181,15 @@ object BusLineModel {
?.transform4DataBase(FRetryWithTime11())
?.subscribe(object : Observer<List<BusQueryLinesResponse.Result>> {
override fun onSubscribe(d: Disposable) {
CallerLogger.d(TAG, "onSubscribe")
d(TAG, "onSubscribe")
}
override fun onError(e: Throwable) {
CallerLogger.d(TAG, "onError${e.printStackTrace()}")
d(TAG, "onError${e.printStackTrace()}")
}
override fun onComplete() {
CallerLogger.d(TAG, "onComplete")
d(TAG, "onComplete")
}
override fun onNext(data: List<BusQueryLinesResponse.Result>) {
@@ -209,7 +204,6 @@ object BusLineModel {
/**
* 通过线路id 查询线路排班表
* @param lineId 线路ID
* @param position 位置
*/
@JvmStatic
fun queryBusLineTasksById(lineId: Long) {
@@ -217,15 +211,15 @@ object BusLineModel {
?.transform4DataBase(TransformTask())
?.subscribe(object : Observer<List<BusQueryLineTaskResponse.Result>> {
override fun onSubscribe(d: Disposable) {
CallerLogger.d(TAG, "onSubscribe")
d(TAG, "onSubscribe")
}
override fun onError(e: Throwable) {
CallerLogger.d(TAG, "onError${e.printStackTrace()}")
d(TAG, "onError${e.printStackTrace()}")
}
override fun onComplete() {
CallerLogger.d(TAG, "onComplete")
d(TAG, "onComplete")
}
override fun onNext(data: List<BusQueryLineTaskResponse.Result>) {
@@ -273,7 +267,7 @@ object BusLineModel {
if (runningTaskInfo.isNullOrEmpty()) {
// 本地没有进行中的任务
CallerLogger.d(TAG,"没有查询到正在运行的任务")
d(TAG,"没有查询到正在运行的任务")
loadServerRuningTask()
} else if (runningTaskInfo.size > 1) {
// 本地有多条正在进行的任务 需要check event
@@ -391,17 +385,17 @@ object BusLineModel {
override fun onError() {
if (!NetworkUtils.isConnected(mContext)) {
ToastUtils.showShort(ResourcesUtils.getString(R.string.network_error_tip));
ToastUtils.showShort(ResourcesUtils.getString(R.string.network_error_tip))
} else {
ToastUtils.showShort(ResourcesUtils.getString(R.string.request_error_tip));
ToastUtils.showShort(ResourcesUtils.getString(R.string.request_error_tip))
}
}
override fun onFail(code: Int, msg: String?) {
if (!NetworkUtils.isConnected(mContext)) {
ToastUtils.showShort("网络异常,请稍后重试");
ToastUtils.showShort("网络异常,请稍后重试")
}else {
ToastUtils.showShort(msg);
ToastUtils.showShort(msg)
}
}
})
@@ -484,8 +478,8 @@ object BusLineModel {
stationList?.let {
startStationIndex+=1
mBusLinesCallbackMap.forEach {
it.value.onArriveStationSuccess()
mBusLinesCallbackMap.forEach {callback->
callback.value.onArriveStationSuccess()
}
val startStation = LineManager.endStation
if(startStationIndex+1< it.size){
@@ -496,10 +490,10 @@ object BusLineModel {
}
fun isLastStation():Boolean?{
if (stationList.isNullOrEmpty()) {
return null
return if (stationList.isNullOrEmpty()) {
null
}else{
return startStationIndex == stationList!!.size - 1
startStationIndex == stationList!!.size - 1
}
}

View File

@@ -34,11 +34,7 @@ object EventModel : EventRepository.EventCallback {
EventRepository.eventCallback = null
}
private val loopUpdateInfo = object :Runnable{
override fun run() {
updateEvent()
}
}
private val loopUpdateInfo = Runnable { updateEvent() }
override fun notifySyn() {
BizLoopManager.removeCallback(loopUpdateInfo)
@@ -114,7 +110,7 @@ object EventModel : EventRepository.EventCallback {
val haveSave = result.filter {
it.lineId==tempLine.lineId
}
if(haveSave.isNullOrEmpty()){
if(haveSave.isEmpty()){
result.add(tempLine)
}else{
haveSave.first().task.add(tempTask)

View File

@@ -5,9 +5,6 @@ import android.content.Context
import android.text.TextUtils
import com.elegant.network.utils.GsonUtil
import com.mogo.commons.AbsMogoApplication
import com.mogo.eagle.core.data.autopilot.AutopilotControlParameters
import com.mogo.eagle.core.data.autopilot.AutopilotControlParameters.AutoPilotLine
import com.mogo.eagle.core.data.autopilot.AutopilotControlParameters.AutoPilotLonLat
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
@@ -53,7 +50,6 @@ import com.mogo.och.common.module.voice.VoiceNotice.showNotice
import com.mogo.och.shuttle.weaknet.R
import com.mogo.och.weaknet.callback.IBusADASStatusCallback
import com.mogo.och.weaknet.constant.BusConst
import com.mogo.och.weaknet.util.BusAnalyticsManager
import com.mogo.och.weaknet.util.BusTrajectoryManager
import com.mogo.och.weaknet.util.ShuttleVoiceManager
@@ -211,7 +207,7 @@ object OrderModel {
BusLineModel.loadStartedTaskAndDefaultInfo()
if(BusLineModel.stationList.isNullOrEmpty()){
d(M_BUS + TAG, "获取到小巴路线数据:空 ")
LineManager.setLineInfo(null);
LineManager.setLineInfo(null)
updateBusStatus()
closeBeautificationMode()
clearStartAutopilotTag()
@@ -239,7 +235,7 @@ object OrderModel {
if (station.drivingStatus == BusConst.STATION_STATUS_STOPPED
&& !station.isLeaving
) { //到达第一站
arrivingOrArrivedStationIndex = i
arrivingOrArrivedStationIndex = 0
break
}
} else {
@@ -319,7 +315,7 @@ object OrderModel {
* 存在Session
*/
if (!OchAutoPilotManager.canStartAutopilotBySessionId()) {
return;
return
}
OchAutopilotAnalytics.triggerClickStartAutopilotTime(System.currentTimeMillis())
@@ -371,7 +367,7 @@ object OrderModel {
val parameters = LineManager.initAutopilotControlParameters()
if (null == parameters) {
e(SceneConstant.M_BUS + TAG, "行程日志-AutopilotControlParameters is empty.")
e(M_BUS + TAG, "行程日志-AutopilotControlParameters is empty.")
return
}
@@ -379,7 +375,7 @@ object OrderModel {
triggerUpdateStartAutoPilotSessionId(sessionId)
d(
SceneConstant.M_BUS + TAG,
M_BUS + TAG,
"行程日志-开启自动驾驶====" + GsonUtil.jsonFromObject(parameters)
+ " startLatLon=" + parameters.startName + "endLatLon=" + parameters.endName +
"isRestart = " + isRestart
@@ -405,7 +401,7 @@ object OrderModel {
FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData = false //是否强制绘制引导线
CallerAutoPilotControlManager.setIgnoreConditionDraw(false) // 同步给乘客屏
CallerAutoPilotControlManager.setIPCDemoMode(false) //是否自动启动自驾
d(SceneConstant.M_BUS + TAG, "美化模式-ignore置为false")
d(M_BUS + TAG, "美化模式-ignore置为false")
}
}
@@ -437,8 +433,6 @@ object OrderModel {
* 渲染站点信息
* 服务端返回的OchBusRoutesResult逻辑 离开站为当前站, 到达下一站后才会将下一站置为当前站,
* 车机端展示 三站: 中间为即将到到达或者刚到达的站
*
* @param result
*/
private fun updateBusStatus() {
BusLineModel.stationList?.let {
@@ -459,11 +453,7 @@ object OrderModel {
BusLineModel.setDemoMode()
LineManager.getStartStation {
if (it.isLeaving) {
isGoingToNextStation = true
}else{
isGoingToNextStation = false
}
isGoingToNextStation = it.isLeaving
}
ThirdDeviceData.sendTaskDetailsToClients()
@@ -523,7 +513,7 @@ object OrderModel {
fun removeTipRunnables() {
private fun removeTipRunnables() {
UiThreadHandler.removeCallbacks(tip3Runnable)
UiThreadHandler.removeCallbacks(tip1Runnable)
}
@@ -614,11 +604,11 @@ object OrderModel {
}
}
fun triggerUpdateStartAutoPilotSessionId(sessionId: Long) {
private fun triggerUpdateStartAutoPilotSessionId(sessionId: Long) {
OchAutopilotAnalytics.triggerUpdateStartAutoPilotSessionId(sessionId)
}
fun triggerUnableStartAPReasonEvent() {
private fun triggerUnableStartAPReasonEvent() {
LineManager.getStationsWithLine { start, end, line ->
OchAutopilotAnalytics.triggerUnableStartAPReasonEvent(
start.name, end.name,line.lineId.toString() , "",
@@ -627,14 +617,8 @@ object OrderModel {
}
}
private fun clearAutopilotControlParameters() {
d(M_BUS + TAG, "AutopilotControlParameters is clear.")
CallerAutoPilotStatusListenerManager.updateAutopilotControlParameters(null)
}
fun setTrajectoryStation(isClean:Boolean) {
private fun setTrajectoryStation(isClean:Boolean) {
if(isClean){
TrajectoryAndDistanceManager.setStationPoint(null, null, null)
return

View File

@@ -2,14 +2,11 @@ package com.mogo.och.weaknet.ui.switchline
import androidx.lifecycle.ViewModel
import com.mogo.commons.storage.SharedPrefsMgr
import com.mogo.eagle.core.utilcode.util.ThreadUtils
import com.mogo.och.common.module.utils.DateTimeUtil
import com.mogo.och.weaknet.bean.BusQueryLineTaskResponse
import com.mogo.och.weaknet.bean.BusQueryLinesResponse
import com.mogo.och.weaknet.callback.IBusLinesCallback
import com.mogo.och.weaknet.model.BusLineModel
import com.mogo.och.weaknet.model.BusLineModel.executableChangeTime
import com.mogo.och.weaknet.model.OrderModel
import com.mogo.och.weaknet.model.BusLineModel.EXECUTABLECHANGETIME
/**
* @author XuXinChao
@@ -37,7 +34,7 @@ class SwtichLineModel : ViewModel(), IBusLinesCallback {
}
fun setRefreshTime() {
val lastUpdateTime = SharedPrefsMgr.getInstance().getLong(executableChangeTime, -1)
val lastUpdateTime = SharedPrefsMgr.getInstance().getLong(EXECUTABLECHANGETIME, -1)
if(lastUpdateTime>0){
this.onRefreshSuccess(lastUpdateTime)
}

View File

@@ -1,14 +1,9 @@
package com.mogo.och.weaknet.ui.taskrunning
import androidx.lifecycle.ViewModel
import com.mogo.commons.storage.SharedPrefsMgr
import com.mogo.eagle.core.utilcode.util.ThreadUtils
import com.mogo.och.common.module.manager.loop.BizLoopManager
import com.mogo.och.common.module.utils.DateTimeUtil
import com.mogo.och.weaknet.bean.BusQueryLinesResponse
import com.mogo.och.weaknet.callback.IBusLinesCallback
import com.mogo.och.weaknet.model.BusLineModel
import com.mogo.och.weaknet.model.BusLineModel.executableChangeTime
import com.mogo.och.weaknet.model.OrderModel
/**