Merge branch 'dev_robotaxi-d_240912_6.7.0' of gitlab.zhidaoauto.com:SCA/L4HA/AndroidApp/MoGoEagleEye into dev_robotaxi-d_240912_6.7.0

This commit is contained in:
aibingbing
2024-09-27 19:40:57 +08:00
10 changed files with 143 additions and 139 deletions

View File

@@ -10,9 +10,7 @@ import java.util.List;
* @date: 2022/2/9
*/
public interface IBusLinesCallback {
default void onBusLinesChange(List<LineDataBean> data){}
default void onChangeLineIdSuccess(){}
default void onBusLineTasks(List<TaskDataBean> o){}
default void onRefreshSuccess(long currentTimeStamp){}
@@ -29,6 +27,4 @@ public interface IBusLinesCallback {
default void onArriveStationSuccess(){}
default void onCompleteTask(){}
default void onBusLineTasksError(){}
}

View File

@@ -64,11 +64,7 @@ object LineModel {
private val isRequesting = AtomicBoolean(false)
private val loopQueryInfo = Runnable { queryCarExecutableTaskList(true) }
private var searchTaskBylineIdDisposable:Disposable?=null
private var searchLineDisposable:Disposable?=null
private var startTaskDisposable:Disposable?=null
private var endTaskDisposable:Disposable?=null
// 当前站点
@JvmStatic
@@ -113,65 +109,60 @@ object LineModel {
return
}
isRequesting.set(true)
mContext?.let {
ShuttleSaasServiceManager.queryCarExecutableTaskList(
it,
object : OchCommonServiceCallback<CarExecutableTaskResponse> {
override fun onSuccess(data: CarExecutableTaskResponse) {
isRequesting.set(false)
BizLoopManager.postDelayed(loopQueryInfo,60_000)
// 第一次过滤 请求返回值的md5
val currentRequest = DigestUtils.md5Hex(data.data.toString())
val lastChangeMd5 =
SharedPrefsMgr.getInstance().getString(EXECUTABLECHANGEMD5)
val lastUpdateTime = SharedPrefsMgr.getInstance().getLong(EXECUTABLECHANGETIME, 0)
val currentTimeStamp = DateTimeUtil.getCurrentTimeStamp()
RepositoryManager.queryCarExecutableTaskList(
object : OchCommonServiceCallback<CarExecutableTaskResponse> {
override fun onSuccess(data: CarExecutableTaskResponse) {
isRequesting.set(false)
BizLoopManager.postDelayed(loopQueryInfo, 60_000)
// 第一次过滤 请求返回值的md5
val currentRequest = DigestUtils.md5Hex(data.data.toString())
val lastChangeMd5 = SharedPrefsMgr.getInstance().getString(EXECUTABLECHANGEMD5)
val lastUpdateTime = SharedPrefsMgr.getInstance().getLong(EXECUTABLECHANGETIME, 0)
val currentTimeStamp = DateTimeUtil.getCurrentTimeStamp()
SharedPrefsMgr.getInstance().putLong(EXECUTABLECHANGETIME, currentTimeStamp)
val sameDay = DateTimeUtil.isSameDay(currentTimeStamp, lastUpdateTime)
mBusLinesCallbackMap.forEach {callback->
callback.value.onRefreshSuccess(currentTimeStamp)
}
if(isBackground){
if (currentRequest == lastChangeMd5 && sameDay) {
return
}
}
SharedPrefsMgr.getInstance().putString(EXECUTABLECHANGEMD5, currentRequest)
OchChainLogManager.writeChainLog(
"数据发生变化",
"接口信息发生变化 $lastChangeMd5 new md5${currentRequest}"
)
CarExecutableTaskResponse.save2Db(data)
SharedPrefsMgr.getInstance().putLong(EXECUTABLECHANGETIME, currentTimeStamp)
val sameDay = DateTimeUtil.isSameDay(currentTimeStamp, lastUpdateTime)
mBusLinesCallbackMap.forEach { callback ->
callback.value.onRefreshSuccess(currentTimeStamp)
}
if (isBackground) {
if (currentRequest == lastChangeMd5 && sameDay) {
return
}
}
SharedPrefsMgr.getInstance().putString(EXECUTABLECHANGEMD5, currentRequest)
OchChainLogManager.writeChainLog(
"数据发生变化",
"接口信息发生变化 $lastChangeMd5 new md5${currentRequest}"
)
CarExecutableTaskResponse.save2Db(data)
}
override fun onError() {
isRequesting.set(false)
BizLoopManager.postDelayed(loopQueryInfo,60_000)
if(!isBackground){
if (!NetworkUtils.isConnected(mContext)) {
ToastUtils.showShort(ResourcesUtils.getString(R.string.network_error_tip))
} else {
ToastUtils.showShort(ResourcesUtils.getString(R.string.request_error_tip))
}
override fun onError() {
isRequesting.set(false)
BizLoopManager.postDelayed(loopQueryInfo, 60_000)
if (!isBackground) {
if (!NetworkUtils.isConnected(mContext)) {
ToastUtils.showShort(ResourcesUtils.getString(R.string.network_error_tip))
} else {
ToastUtils.showShort(ResourcesUtils.getString(R.string.request_error_tip))
}
}
}
override fun onFail(code: Int, failMsg: String) {
isRequesting.set(false)
BizLoopManager.postDelayed(loopQueryInfo, 60_000)
if (!isBackground) {
if (!NetworkUtils.isConnected(mContext)) {
ToastUtils.showShort("网络异常,请稍后重试")
} else {
ToastUtils.showShort(failMsg)
}
}
override fun onFail(code: Int, failMsg: String) {
isRequesting.set(false)
BizLoopManager.postDelayed(loopQueryInfo,60_000)
if(!isBackground){
if (!NetworkUtils.isConnected(mContext)) {
ToastUtils.showShort("网络异常,请稍后重试")
}else {
ToastUtils.showShort(failMsg)
}
}
}
})
}
}
})
}
/**
@@ -179,33 +170,7 @@ object LineModel {
*/
@JvmStatic
fun queryBusLines() {
RxUtils.disposeSubscribe(endTaskDisposable)
RepositoryManager.queryCanUseLine()
?.subscribeOn(Schedulers.io())
?.observeOn(AndroidSchedulers.mainThread())
?.subscribe(object : Observer<List<LineDataBean>?> {
override fun onSubscribe(d: Disposable) {
endTaskDisposable = d
d(TAG, "queryBusLines onSubscribe")
}
override fun onError(e: Throwable) {
d(TAG, "queryBusLines onError${e.printStackTrace()}")
}
override fun onComplete() {
d(TAG, "queryBusLines onComplete")
}
override fun onNext(data: List<LineDataBean>) {
d(TAG, "queryBusLines onNext ${data}")
mBusLinesCallbackMap.forEach {
it.value.onBusLinesChange(data)
}
RxUtils.disposeSubscribe(endTaskDisposable)
}
})
}
/**
@@ -214,36 +179,7 @@ object LineModel {
*/
@JvmStatic
fun queryBusLineTasksById(lineId: Long) {
RxUtils.disposeSubscribe(searchTaskBylineIdDisposable)
d(TAG, "queryBusLineTasksById 查询线路的任务线路id:${lineId}")
RepositoryManager.queryCanUserTask(lineId)
?.subscribeOn(Schedulers.io())
?.observeOn(AndroidSchedulers.mainThread())
?.subscribe(object : Observer<List<TaskDataBean?>?> {
override fun onSubscribe(d: Disposable) {
searchTaskBylineIdDisposable = d
d(TAG, "queryBusLineTasksById onSubscribe")
}
override fun onError(e: Throwable) {
d(TAG, "queryBusLineTasksById onError${e.printStackTrace()}")
mBusLinesCallbackMap.forEach {
it.value.onBusLineTasksError()
}
}
override fun onComplete() {
d(TAG, "queryBusLineTasksById onComplete")
}
override fun onNext(data: List<TaskDataBean?>) {
d(TAG, "queryBusLineTasksById onNext ${data}")
mBusLinesCallbackMap.forEach {
it.value.onBusLineTasks(data)
}
RxUtils.disposeSubscribe(searchTaskBylineIdDisposable)
}
})
}
/**

View File

@@ -1,5 +1,7 @@
package com.mogo.och.weaknet.repository
import com.mogo.och.common.module.network.OchCommonServiceCallback
import com.mogo.och.weaknet.bean.response.CarExecutableTaskResponse
import com.mogo.och.weaknet.repository.db.bean.LineDataBean
import com.mogo.och.weaknet.repository.db.bean.TaskDataBean
import io.reactivex.Observable
@@ -19,4 +21,8 @@ interface IRepository {
fun arriveStation( seq: Int, siteId: Long, taskId: Long): Observable<Boolean>?
fun endTask( taskId: Long): Observable<Boolean>?
fun queryCarExecutableTaskList(
ochCommonServiceCallback: OchCommonServiceCallback<CarExecutableTaskResponse>
){}
}

View File

@@ -3,6 +3,8 @@ package com.mogo.och.weaknet.repository
import com.mogo.commons.env.ProjectUtils
import com.mogo.eagle.core.data.config.FunctionBuildConfig
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils
import com.mogo.och.common.module.network.OchCommonServiceCallback
import com.mogo.och.weaknet.bean.response.CarExecutableTaskResponse
import com.mogo.och.weaknet.repository.db.bean.LineDataBean
import com.mogo.och.weaknet.repository.db.bean.TaskDataBean
import com.mogo.och.weaknet.repository.db.repository.EventDb
@@ -79,4 +81,12 @@ object RepositoryManager {
return false
}
fun queryCarExecutableTaskList(
ochCommonServiceCallback: OchCommonServiceCallback<CarExecutableTaskResponse>
) {
if (repository is ShuttleSaasRepository) {
repository.queryCarExecutableTaskList(ochCommonServiceCallback)
}
}
}

View File

@@ -88,7 +88,7 @@ class BusRepository: IRepository {
return BusServiceManager.queryBusLines()
}
override fun queryCanUserTask(lineId: Long): Observable<List<TaskDataBean>?>? {
override fun queryCanUserTask(lineId: Long): Observable<List<TaskDataBean>?> {
return BusServiceManager.queryBusTaskByLineId(lineId)
}

View File

@@ -4,7 +4,9 @@ import com.mogo.commons.AbsMogoApplication
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
import com.mogo.och.common.module.manager.autopilot.line.LineManager
import com.mogo.och.common.module.manager.logchainanalytic.OchChainLogManager
import com.mogo.och.common.module.network.OchCommonServiceCallback
import com.mogo.och.weaknet.bean.response.BusRoutesResponse
import com.mogo.och.weaknet.bean.response.CarExecutableTaskResponse
import com.mogo.och.weaknet.model.LineModel
import com.mogo.och.weaknet.model.LineModel.currentTask
import com.mogo.och.weaknet.repository.db.bean.ContrailDataBean
@@ -270,4 +272,9 @@ class ShuttleSaasRepository : IRepository {
}
}
override fun queryCarExecutableTaskList(
ochCommonServiceCallback: OchCommonServiceCallback<CarExecutableTaskResponse>
) {
ShuttleSaasServiceManager.queryCarExecutableTaskList(context,ochCommonServiceCallback)
}
}

View File

@@ -155,8 +155,7 @@ object BusServiceManager {
}
@JvmStatic
fun queryBusTaskByLineId(
lineId: Long?) :Observable<List<TaskDataBean>?> {
fun queryBusTaskByLineId(lineId: Long?) :Observable<List<TaskDataBean>?> {
return mService.queryBusTaskByLineId(
MoGoAiCloudClientConfig.getInstance().serviceAppId,
SharedPrefsMgr.getInstance().token,

View File

@@ -2,11 +2,18 @@ package com.mogo.och.weaknet.ui.switchline
import androidx.lifecycle.ViewModel
import com.mogo.commons.storage.SharedPrefsMgr
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d
import com.mogo.och.common.module.utils.DateTimeUtil
import com.mogo.och.common.module.utils.RxUtils
import com.mogo.och.weaknet.callback.IBusLinesCallback
import com.mogo.och.weaknet.model.LineModel
import com.mogo.och.weaknet.model.LineModel.EXECUTABLECHANGETIME
import com.mogo.och.weaknet.repository.RepositoryManager
import com.mogo.och.weaknet.repository.db.bean.LineDataBean
import io.reactivex.Observer
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.Disposable
import io.reactivex.schedulers.Schedulers
/**
* @author XuXinChao
@@ -19,6 +26,8 @@ class SwtichLineModel : ViewModel(), IBusLinesCallback {
private var viewCallback:SwtichLineViewCallback?=null
private var endTaskDisposable:Disposable?=null
override fun onCleared() {
LineModel.setBusLinesCallback(TAG,null)
@@ -31,6 +40,31 @@ class SwtichLineModel : ViewModel(), IBusLinesCallback {
fun queryBusLines() {
LineModel.queryBusLines()
RxUtils.disposeSubscribe(endTaskDisposable)
RepositoryManager.queryCanUseLine()
?.subscribeOn(Schedulers.io())
?.observeOn(AndroidSchedulers.mainThread())
?.subscribe(object : Observer<List<LineDataBean>?> {
override fun onSubscribe(d: Disposable) {
endTaskDisposable = d
d(LineModel.TAG, "queryBusLines onSubscribe")
}
override fun onError(e: Throwable) {
d(LineModel.TAG, "queryBusLines onError${e.printStackTrace()}")
}
override fun onComplete() {
d(LineModel.TAG, "queryBusLines onComplete")
}
override fun onNext(data: List<LineDataBean>) {
d(LineModel.TAG, "queryBusLines onNext ${data}")
viewCallback?.onBusLinesChange(data.toMutableList())
RxUtils.disposeSubscribe(endTaskDisposable)
}
})
}
fun setRefreshTime() {
@@ -50,10 +84,6 @@ class SwtichLineModel : ViewModel(), IBusLinesCallback {
fun refreshDate(formatLongToString: String?)
}
override fun onBusLinesChange(data: MutableList<LineDataBean>?) {
viewCallback?.onBusLinesChange(data)
}
override fun onRefreshSuccess(currentTimeStamp: Long) {
viewCallback?.refreshDate(
DateTimeUtil.formatLongToString(currentTimeStamp, DateTimeUtil.HH_mm_ss)

View File

@@ -1,15 +1,20 @@
package com.mogo.och.weaknet.ui.switchtask
import androidx.lifecycle.ViewModel
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d
import com.mogo.eagle.core.utilcode.util.ThreadUtils
import com.mogo.eagle.core.utilcode.util.ToastUtils
import com.mogo.och.common.module.manager.loop.BizLoopManager
import com.mogo.och.common.module.utils.RxUtils
import com.mogo.och.weaknet.callback.IBusLinesCallback
import com.mogo.och.weaknet.model.LineModel
import com.mogo.och.weaknet.repository.RepositoryManager
import com.mogo.och.weaknet.repository.db.bean.LineDataBean
import com.mogo.och.weaknet.repository.db.bean.TaskDataBean
import io.reactivex.Observer
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.Disposable
import io.reactivex.schedulers.Schedulers
/**
* @author XuXinChao
@@ -24,10 +29,10 @@ class SwtichTaskModel : ViewModel(), IBusLinesCallback {
var tasksBelongLine: LineDataBean? = null
private var subscribe: Disposable? = null
private var searchTaskBylineIdDisposable:Disposable?=null
override fun onCleared() {
RxUtils.disposeSubscribe(subscribe)
LineModel.setBusLinesCallback(TAG,null)
}
@@ -38,7 +43,32 @@ class SwtichTaskModel : ViewModel(), IBusLinesCallback {
fun queryBusLineTasksById(lineInfo: LineDataBean) {
tasksBelongLine = lineInfo
LineModel.queryBusLineTasksById(lineInfo.lineId?:-1L)
RxUtils.disposeSubscribe(searchTaskBylineIdDisposable)
d(LineModel.TAG, "queryBusLineTasksById 查询线路的任务线路id:${tasksBelongLine}")
RepositoryManager.queryCanUserTask(lineInfo.lineId?:-1L)
?.subscribeOn(Schedulers.io())
?.observeOn(AndroidSchedulers.mainThread())
?.subscribe(object : Observer<List<TaskDataBean>?> {
override fun onSubscribe(d: Disposable) {
searchTaskBylineIdDisposable = d
d(LineModel.TAG, "queryBusLineTasksById onSubscribe")
}
override fun onError(e: Throwable) {
d(LineModel.TAG, "queryBusLineTasksById onError${e.printStackTrace()}")
onBusLineTasksError()
}
override fun onComplete() {
d(LineModel.TAG, "queryBusLineTasksById onComplete")
}
override fun onNext(data: List<TaskDataBean>) {
d(LineModel.TAG, "queryBusLineTasksById onNext ${data}")
onBusLineTasks(data.toMutableList())
RxUtils.disposeSubscribe(searchTaskBylineIdDisposable)
}
})
}
interface SwtichLineViewCallback{
@@ -49,11 +79,11 @@ class SwtichTaskModel : ViewModel(), IBusLinesCallback {
fun showErrorInfo()
}
override fun onBusLineTasks(o: MutableList<TaskDataBean>?) {
fun onBusLineTasks(o: MutableList<TaskDataBean>?) {
viewCallback?.showTaskByLineIdResult(o)
}
override fun onBusLineTasksError() {
fun onBusLineTasksError() {
viewCallback?.showErrorInfo()
}

View File

@@ -52,7 +52,7 @@ class ReportTypeView @JvmOverloads constructor(
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
) : ConstraintLayout(context, attrs, defStyleAttr),
IMoGoDevaToolsListener, IMoGoTakeoverListener {
IMoGoDevaToolsListener {
private val TAG = "ReportTypeView"
@@ -82,7 +82,6 @@ class ReportTypeView @JvmOverloads constructor(
private fun initView(){
CallerDevaToolsListenerManager.addListener(TAG, this)
CallerTakeoverListenerManager.addListener(TAG,this)
if(isOneClickType){
showOneCLickReportView()
}else{
@@ -268,13 +267,4 @@ class ReportTypeView @JvmOverloads constructor(
this.clickListener = clickListener
}
/**
* 人工接管
*/
override fun onTakeoverState(state: Int) {
ThreadUtils.runOnUiThread {
showOneCLickReportView()
}
}
}