[6.7.0]
[fea] [数据源切换]
This commit is contained in:
@@ -105,12 +105,12 @@ abstract class FacadeProvider : IMoGoFunctionProvider, ILoginCallback {
|
||||
}
|
||||
}
|
||||
if (AppIdentityModeUtils.isBusDriver(FunctionBuildConfig.appIdentityMode)) {
|
||||
return getFragmentByServeName(OchCommonConst.BUS_DRIVER)
|
||||
return getFragmentByServeName(OchCommonConst.SHUTTLE_DRIVER_WEAKNET)
|
||||
} else if (AppIdentityModeUtils.isShuttleDriver(FunctionBuildConfig.appIdentityMode)) {
|
||||
return if (ProjectUtils.isSaas()) {
|
||||
getFragmentByServeName(OchCommonConst.SHUTTLE_DRIVER_WEAKNET)
|
||||
} else {
|
||||
getFragmentByServeName(OchCommonConst.SHUTTLE_DRIVER)
|
||||
getFragmentByServeName(OchCommonConst.SHUTTLE_DRIVER_WEAKNET)
|
||||
}
|
||||
} else if (AppIdentityModeUtils.isCharterDriver(FunctionBuildConfig.appIdentityMode)) {
|
||||
return getFragmentByServeName(OchCommonConst.CHARTER_DRIVER)
|
||||
|
||||
@@ -9,9 +9,10 @@ import com.mogo.och.common.module.network.OchCommonServiceCallback
|
||||
import com.mogo.och.weaknet.bean.request.ShuttleEventRequest
|
||||
import com.mogo.och.weaknet.bean.WaitUploadLine
|
||||
import com.mogo.och.weaknet.bean.WaitUploadTask
|
||||
import com.mogo.och.weaknet.repository.net.impl.shuttlesaas.OrderServiceManager
|
||||
import com.mogo.och.weaknet.repository.net.shuttlesaas.ShuttleSaasServiceManager
|
||||
import com.mogo.och.weaknet.repository.db.bean.EventDataBean
|
||||
import com.mogo.och.weaknet.repository.db.repository.EventDb
|
||||
import com.mogo.och.weaknet.repository.RepositoryManager
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
@@ -20,18 +21,21 @@ import java.util.concurrent.atomic.AtomicBoolean
|
||||
|
||||
object EventModel : EventDb.EventCallback {
|
||||
|
||||
|
||||
private val isUpdating by lazy { AtomicBoolean(false) }
|
||||
|
||||
private val createDefault = BehaviorSubject.createDefault(isUpdating.get())
|
||||
|
||||
fun load(){
|
||||
EventDb.eventCallback = this
|
||||
BizLoopManager.postDelayed(loopUpdateInfo,2*60*1000)
|
||||
if (RepositoryManager.supportDb()) {
|
||||
EventDb.eventCallback = this
|
||||
BizLoopManager.postDelayed(loopUpdateInfo,2*60*1000)
|
||||
}
|
||||
}
|
||||
|
||||
fun release(){
|
||||
EventDb.eventCallback = null
|
||||
if (RepositoryManager.supportDb()) {
|
||||
EventDb.eventCallback = null
|
||||
}
|
||||
}
|
||||
|
||||
private val loopUpdateInfo = Runnable { updateEvent() }
|
||||
@@ -56,7 +60,7 @@ object EventModel : EventDb.EventCallback {
|
||||
}
|
||||
OchChainLogManager.writeChainLogDb("上报event","开始上报:${Thread.currentThread().name}")
|
||||
val transformDb2Net = ShuttleEventRequest.transformDb2Net(waitUpdateEvent)
|
||||
OrderServiceManager.reportCabinEvent(AbsMogoApplication.getApp()!!,transformDb2Net,object :OchCommonServiceCallback<BaseData>{
|
||||
ShuttleSaasServiceManager.reportCabinEvent(AbsMogoApplication.getApp()!!,transformDb2Net,object :OchCommonServiceCallback<BaseData>{
|
||||
override fun onSuccess(data: BaseData?) {
|
||||
waitUpdateEvent.forEach {
|
||||
it.updateStatus = EventDataBean.updated
|
||||
@@ -92,13 +96,6 @@ object EventModel : EventDb.EventCallback {
|
||||
|
||||
}
|
||||
|
||||
fun haveDataWaitSyn(): Boolean {
|
||||
EventDb.queryWaitUpdateEvent()?.let {
|
||||
return it.isNotEmpty()
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
fun queryWaitUploadInfo(): Observable<MutableList<WaitUploadLine>>? {
|
||||
return EventDb.queryWaitUploadData()
|
||||
?.flatMap { waitUploadList->
|
||||
|
||||
@@ -25,9 +25,9 @@ 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.bean.TaskSiteDataBean
|
||||
import com.mogo.och.weaknet.repository.db.repository.EventDb
|
||||
import com.mogo.och.weaknet.repository.net.RepositoryManager
|
||||
import com.mogo.och.weaknet.repository.net.exception.DataException
|
||||
import com.mogo.och.weaknet.repository.net.impl.shuttlesaas.OrderServiceManager
|
||||
import com.mogo.och.weaknet.repository.RepositoryManager
|
||||
import com.mogo.och.weaknet.repository.exception.DataException
|
||||
import com.mogo.och.weaknet.repository.net.shuttlesaas.ShuttleSaasServiceManager
|
||||
import io.reactivex.Observer
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.Disposable
|
||||
@@ -108,7 +108,7 @@ object LineModel {
|
||||
}
|
||||
isRequesting.set(true)
|
||||
mContext?.let {
|
||||
OrderServiceManager.queryCarExecutableTaskList(
|
||||
ShuttleSaasServiceManager.queryCarExecutableTaskList(
|
||||
it,
|
||||
object : OchCommonServiceCallback<CarExecutableTaskResponse> {
|
||||
override fun onSuccess(data: CarExecutableTaskResponse) {
|
||||
|
||||
@@ -4,15 +4,12 @@ import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import com.mogo.commons.AbsMogoApplication
|
||||
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.call.autopilot.CallerAutoPilotControlManager
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.e
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_BUS
|
||||
import com.mogo.eagle.core.utilcode.util.CoordinateUtils
|
||||
import com.mogo.eagle.core.utilcode.util.ThreadUtils
|
||||
import com.mogo.eagle.core.utilcode.util.ToastUtils
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
|
||||
@@ -20,7 +17,6 @@ import com.mogo.och.common.module.biz.login.LoginStatusManager
|
||||
import com.mogo.och.common.module.manager.autopilot.autopilot.bean.ArrivedStation
|
||||
import com.mogo.och.common.module.manager.autopilot.line.ILineCallback
|
||||
import com.mogo.och.common.module.manager.autopilot.line.LineManager
|
||||
import com.mogo.och.common.module.manager.autopilot.location.OchLocationManager
|
||||
import com.mogo.och.common.module.manager.logchainanalytic.OchChainLogManager
|
||||
import com.mogo.och.common.module.manager.socket.cloud.OCHSocketMessageManager
|
||||
import com.mogo.och.common.module.manager.socket.lan.LedScreenManager
|
||||
@@ -32,10 +28,9 @@ import com.mogo.och.common.module.utils.OCHThreadPoolManager
|
||||
import com.mogo.och.common.module.utils.ResourcesUtils
|
||||
import com.mogo.och.common.module.utils.RxUtils
|
||||
import com.mogo.och.shuttle.weaknet.R
|
||||
import com.mogo.och.weaknet.constant.BusConst
|
||||
import com.mogo.och.weaknet.repository.db.bean.TaskSiteDataBean
|
||||
import com.mogo.och.weaknet.repository.net.RepositoryManager
|
||||
import com.mogo.och.weaknet.repository.net.exception.DataException
|
||||
import com.mogo.och.weaknet.repository.RepositoryManager
|
||||
import com.mogo.och.weaknet.repository.exception.DataException
|
||||
import com.mogo.och.weaknet.util.BusTrajectoryManager
|
||||
import com.mogo.och.weaknet.util.ShuttleVoiceManager
|
||||
import io.reactivex.Observer
|
||||
@@ -96,13 +91,7 @@ object OrderModel {
|
||||
|
||||
private val ochTransform = object : OchTransformDispatch {
|
||||
override fun logout() {
|
||||
ThreadUtils.getIoPool().execute {
|
||||
if(EventModel.haveDataWaitSyn()){
|
||||
ToastUtils.showShort(ResourcesUtils.getString(R.string.shuttle_logout_error))
|
||||
return@execute
|
||||
}
|
||||
LoginStatusManager.loginOut()
|
||||
}
|
||||
logoutInner()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -445,9 +434,9 @@ object OrderModel {
|
||||
|
||||
// 登出
|
||||
@JvmStatic
|
||||
fun logout() {
|
||||
fun logoutInner() {
|
||||
ThreadUtils.getIoPool().execute {
|
||||
if(EventModel.haveDataWaitSyn()){
|
||||
if(RepositoryManager.haveDataWaitSyn()){
|
||||
ToastUtils.showShort(ResourcesUtils.getString(R.string.shuttle_logout_error))
|
||||
return@execute
|
||||
}
|
||||
|
||||
@@ -105,7 +105,9 @@ object ThirdDeviceData {
|
||||
|
||||
//结束任务
|
||||
fun endTask() {
|
||||
UiThreadHandler.removeCallbacks(delayedTts)
|
||||
delayedTts?.let {
|
||||
UiThreadHandler.removeCallbacks(delayedTts)
|
||||
}
|
||||
LineManager.getLineInfo {lineInfo ->
|
||||
LedScreenManager.sendTripInfo2Led(
|
||||
LedScreenManager.END_TRIP,
|
||||
|
||||
@@ -24,7 +24,7 @@ import com.mogo.och.common.module.manager.socket.lan.bean.WriteOffMsg
|
||||
import com.mogo.och.common.module.network.OchCommonServiceCallback
|
||||
import com.mogo.och.weaknet.bean.response.WriteOffCountResponse
|
||||
import com.mogo.och.weaknet.bean.WriteOffPassenger
|
||||
import com.mogo.och.weaknet.repository.net.impl.shuttlesaas.OrderServiceManager
|
||||
import com.mogo.och.weaknet.repository.net.shuttlesaas.ShuttleSaasServiceManager
|
||||
import com.mogo.och.weaknet.util.ShuttleVoiceManager
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.ObservableEmitter
|
||||
@@ -99,7 +99,7 @@ object TicketModel : IOchOnMessageListener<WriteOffPassenger>{
|
||||
private fun selectWriteOffCount(){
|
||||
LineManager.getStations().second?.let { endStation->
|
||||
LineModel.currentTask?.let { currentTask->
|
||||
OrderServiceManager.queryBusTaskByLineId(AbsMogoApplication.getApp(),
|
||||
ShuttleSaasServiceManager.queryBusTaskByLineId(AbsMogoApplication.getApp(),
|
||||
"${currentTask.taskId}",
|
||||
"${endStation.siteId}",
|
||||
object : OchCommonServiceCallback<WriteOffCountResponse> {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mogo.och.weaknet.repository.net
|
||||
package com.mogo.och.weaknet.repository
|
||||
|
||||
import com.mogo.och.weaknet.repository.db.bean.LineDataBean
|
||||
import com.mogo.och.weaknet.repository.db.bean.TaskDataBean
|
||||
@@ -1,24 +1,26 @@
|
||||
package com.mogo.och.weaknet.repository.net
|
||||
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.weaknet.repository.db.bean.LineDataBean
|
||||
import com.mogo.och.weaknet.repository.db.bean.TaskDataBean
|
||||
import com.mogo.och.weaknet.repository.net.impl.bus.BusRepository
|
||||
import com.mogo.och.weaknet.repository.net.impl.bussaas.BusSaasRepository
|
||||
import com.mogo.och.weaknet.repository.net.impl.shuttle.ShuttleRepository
|
||||
import com.mogo.och.weaknet.repository.db.repository.EventDb
|
||||
import com.mogo.och.weaknet.repository.impl.BusRepository
|
||||
import com.mogo.och.weaknet.repository.impl.BusSaasRepository
|
||||
import com.mogo.och.weaknet.repository.impl.ShuttleRepository
|
||||
import com.mogo.och.weaknet.repository.impl.ShuttleSaasRepository
|
||||
import io.reactivex.Observable
|
||||
|
||||
object RepositoryManager {
|
||||
|
||||
|
||||
private lateinit var repository:IRepository
|
||||
private lateinit var repository: IRepository
|
||||
|
||||
init {
|
||||
if(ProjectUtils.isSaas()){
|
||||
if(AppIdentityModeUtils.isShuttle(FunctionBuildConfig.appIdentityMode)) {
|
||||
repository = ShuttleRepository()
|
||||
repository = ShuttleSaasRepository()
|
||||
}else if(AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode)) {
|
||||
repository = BusSaasRepository()
|
||||
}
|
||||
@@ -61,4 +63,20 @@ object RepositoryManager {
|
||||
}
|
||||
|
||||
|
||||
fun haveDataWaitSyn(): Boolean {
|
||||
if(ProjectUtils.isSaas()&&AppIdentityModeUtils.isShuttle(FunctionBuildConfig.appIdentityMode)) {
|
||||
EventDb.queryWaitUpdateEvent()?.let {
|
||||
return it.isNotEmpty()
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
fun supportDb():Boolean{
|
||||
if(ProjectUtils.isSaas()&&AppIdentityModeUtils.isShuttle(FunctionBuildConfig.appIdentityMode)) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,7 +10,7 @@ import com.mogo.och.weaknet.repository.db.MyDataBase
|
||||
import com.mogo.och.weaknet.repository.db.bean.TaskDataBean
|
||||
import com.mogo.och.weaknet.repository.db.dao.TaskDataDao
|
||||
import com.mogo.och.weaknet.repository.db.exception.DbException
|
||||
import com.mogo.och.weaknet.repository.net.exception.DataException
|
||||
import com.mogo.och.weaknet.repository.exception.DataException
|
||||
import io.reactivex.Observable
|
||||
|
||||
object TaskDb {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mogo.och.weaknet.repository.net.exception
|
||||
package com.mogo.och.weaknet.repository.exception
|
||||
|
||||
class DataException: RuntimeException {
|
||||
constructor() : super()
|
||||
@@ -0,0 +1,128 @@
|
||||
package com.mogo.och.weaknet.repository.impl
|
||||
|
||||
import com.mogo.och.common.module.manager.autopilot.line.LineManager
|
||||
import com.mogo.och.common.module.manager.logchainanalytic.OchChainLogManager
|
||||
import com.mogo.och.data.bean.BusStationBean
|
||||
import com.mogo.och.data.bean.ContraiInfo
|
||||
import com.mogo.och.data.bean.LineInfo
|
||||
import com.mogo.och.weaknet.model.LineModel
|
||||
import com.mogo.och.weaknet.repository.db.bean.LineDataBean
|
||||
import com.mogo.och.weaknet.repository.db.bean.TaskDataBean
|
||||
import com.mogo.och.weaknet.repository.IRepository
|
||||
import com.mogo.och.weaknet.repository.db.bean.TaskSiteDataBean
|
||||
import com.mogo.och.weaknet.repository.net.bus.BusServiceManager
|
||||
import com.mogo.och.weaknet.repository.net.shuttle.ShuttleServiceManager
|
||||
import io.reactivex.Observable
|
||||
|
||||
class BusRepository: IRepository {
|
||||
|
||||
override fun loadCurrentTaskInfo(): Observable<Boolean>? {
|
||||
return BusServiceManager.queryBusRoutes()
|
||||
?.flatMap { busRoutesResult ->
|
||||
if (!busRoutesResult.sites.isNullOrEmpty() && busRoutesResult.sites.size > 1) {
|
||||
OchChainLogManager.writeChainLogDb(
|
||||
"业务数据",
|
||||
"本地没有正在运行的数据,服务器端有${busRoutesResult}"
|
||||
)
|
||||
val result = mutableListOf<BusStationBean>()
|
||||
var temp: BusStationBean? = null
|
||||
var currentStationIndex = -1
|
||||
var lineInfo: LineInfo?=null
|
||||
busRoutesResult.sites.forEachIndexed { index, taskAndsite ->
|
||||
temp = BusStationBean()
|
||||
temp?.drivingStatus = (taskAndsite.drivingStatus ?: 0)
|
||||
temp?.lat = (taskAndsite.lat ?: 0.0)
|
||||
temp?.lon = (taskAndsite.lon ?: 0.0)
|
||||
temp?.gcjLat = (taskAndsite.gcjLat ?: 0.0)
|
||||
temp?.gcjLon = (taskAndsite.gcjLon ?: 0.0)
|
||||
temp?.introduction = taskAndsite.introduction
|
||||
temp?.isLeaving = taskAndsite.isLeaving
|
||||
temp?.name = taskAndsite.name
|
||||
temp?.nameKr = taskAndsite.nameKr
|
||||
temp?.isPlayTts = java.lang.Boolean.TRUE == taskAndsite.isPlayTts
|
||||
temp?.seq = (taskAndsite.seq ?: 0)
|
||||
temp?.siteId = if (taskAndsite.siteId == null) 0 else taskAndsite.siteId!!.toInt()
|
||||
result.add(temp!!)
|
||||
// 正在进行中的任务
|
||||
if (temp!!.drivingStatus == TaskSiteDataBean.drivingStatusCurrent) {
|
||||
currentStationIndex = index
|
||||
}
|
||||
// 线路信息
|
||||
if (lineInfo == null && busRoutesResult.name != null) {
|
||||
lineInfo = LineInfo(busRoutesResult.lineId.toLong(), taskAndsite.name)
|
||||
}
|
||||
lineInfo?.multiMap?.put("taskInfo", LineModel.getTaskTime())
|
||||
}
|
||||
LineManager.setLineInfo(lineInfo)
|
||||
|
||||
LineManager.setContraiInfo(
|
||||
ContraiInfo(busRoutesResult.lineId.toLong()
|
||||
,busRoutesResult.csvFileUrl,busRoutesResult.csvFileMd5,
|
||||
busRoutesResult.txtFileUrl,busRoutesResult.txtFileMd5,
|
||||
busRoutesResult.contrailSaveTime)
|
||||
)
|
||||
|
||||
|
||||
val tempTask =TaskDataBean()
|
||||
tempTask.taskId = busRoutesResult.taskId.toLong()
|
||||
tempTask.taskStartTime = busRoutesResult.taskTime
|
||||
tempTask.lineId = busRoutesResult.lineId.toLong()
|
||||
LineModel.currentTask = tempTask
|
||||
|
||||
LineModel.stationList = result
|
||||
LineModel.startStationIndex = currentStationIndex
|
||||
LineModel.stationList?.let { stationlist->
|
||||
val startStation = stationlist[LineModel.startStationIndex]
|
||||
if (LineModel.startStationIndex < stationlist.size-1) {
|
||||
val endStation = stationlist[LineModel.startStationIndex + 1]
|
||||
LineManager.setStartAndEndStation(startStation,endStation)
|
||||
}
|
||||
}
|
||||
return@flatMap Observable.just(true)
|
||||
}
|
||||
return@flatMap Observable.just(false)
|
||||
}
|
||||
}
|
||||
|
||||
override fun queryCanUseLine(): Observable<List<LineDataBean>?>? {
|
||||
return BusServiceManager.queryBusLines()
|
||||
}
|
||||
|
||||
override fun queryCanUserTask(lineId: Long): Observable<List<TaskDataBean>?>? {
|
||||
return BusServiceManager.queryBusTaskByLineId(lineId)
|
||||
}
|
||||
|
||||
override fun startTask(
|
||||
taskId: Long,
|
||||
lineId: Long,
|
||||
taskTime: Long,
|
||||
lineName: String
|
||||
): Observable<Boolean>? {
|
||||
return BusServiceManager.switchLine(taskId)
|
||||
}
|
||||
|
||||
override fun leaveStation(
|
||||
seq: Int,
|
||||
siteId: Long,
|
||||
taskId: Long,
|
||||
lineId: Long,
|
||||
taskStartTime: Long
|
||||
): Observable<Boolean>? {
|
||||
return BusServiceManager.leaveStation(seq, siteId, taskId, System.currentTimeMillis())
|
||||
}
|
||||
|
||||
override fun arriveStation(seq: Int, siteId: Long, taskId: Long): Observable<Boolean>? {
|
||||
return BusServiceManager.arriveSiteStation(
|
||||
seq,
|
||||
siteId,
|
||||
taskId,
|
||||
System.currentTimeMillis()
|
||||
)
|
||||
}
|
||||
|
||||
override fun endTask(taskId: Long): Observable<Boolean>? {
|
||||
return ShuttleServiceManager.endTask(taskId)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
package com.mogo.och.weaknet.repository.impl
|
||||
|
||||
import com.mogo.commons.AbsMogoApplication
|
||||
import com.mogo.och.common.module.manager.autopilot.line.LineManager
|
||||
import com.mogo.och.common.module.manager.logchainanalytic.OchChainLogManager
|
||||
import com.mogo.och.data.bean.BusStationBean
|
||||
import com.mogo.och.data.bean.ContraiInfo
|
||||
import com.mogo.och.data.bean.LineInfo
|
||||
import com.mogo.och.weaknet.model.LineModel
|
||||
import com.mogo.och.weaknet.repository.db.bean.LineDataBean
|
||||
import com.mogo.och.weaknet.repository.db.bean.TaskDataBean
|
||||
import com.mogo.och.weaknet.repository.IRepository
|
||||
import com.mogo.och.weaknet.repository.db.bean.TaskSiteDataBean
|
||||
import com.mogo.och.weaknet.repository.net.bussaas.BusShuttleServiceManager
|
||||
import com.mogo.och.weaknet.repository.net.shuttle.ShuttleServiceManager
|
||||
import io.reactivex.Observable
|
||||
|
||||
class BusSaasRepository: IRepository {
|
||||
|
||||
override fun loadCurrentTaskInfo(): Observable<Boolean>? {
|
||||
return BusShuttleServiceManager.queryBusRoutes()
|
||||
?.flatMap { busRoutesResult ->
|
||||
if (!busRoutesResult.sites.isNullOrEmpty() && busRoutesResult.sites.size > 1) {
|
||||
OchChainLogManager.writeChainLogDb(
|
||||
"业务数据",
|
||||
"本地没有正在运行的数据,服务器端有${busRoutesResult}"
|
||||
)
|
||||
val result = mutableListOf<BusStationBean>()
|
||||
var temp: BusStationBean? = null
|
||||
var currentStationIndex = -1
|
||||
var lineInfo: LineInfo?=null
|
||||
busRoutesResult.sites.forEachIndexed { index, taskAndsite ->
|
||||
temp = BusStationBean()
|
||||
temp?.drivingStatus = (taskAndsite.drivingStatus ?: 0)
|
||||
temp?.lat = (taskAndsite.lat ?: 0.0)
|
||||
temp?.lon = (taskAndsite.lon ?: 0.0)
|
||||
temp?.gcjLat = (taskAndsite.gcjLat ?: 0.0)
|
||||
temp?.gcjLon = (taskAndsite.gcjLon ?: 0.0)
|
||||
temp?.introduction = taskAndsite.introduction
|
||||
temp?.isLeaving = taskAndsite.isLeaving
|
||||
temp?.name = taskAndsite.name
|
||||
temp?.nameKr = taskAndsite.nameKr
|
||||
temp?.isPlayTts = java.lang.Boolean.TRUE == taskAndsite.isPlayTts
|
||||
temp?.seq = (taskAndsite.seq ?: 0)
|
||||
temp?.siteId = if (taskAndsite.siteId == null) 0 else taskAndsite.siteId!!.toInt()
|
||||
result.add(temp!!)
|
||||
// 正在进行中的任务
|
||||
if (temp!!.drivingStatus == TaskSiteDataBean.drivingStatusCurrent) {
|
||||
currentStationIndex = index
|
||||
}
|
||||
// 线路信息
|
||||
if (lineInfo == null && busRoutesResult.name != null) {
|
||||
lineInfo = LineInfo(busRoutesResult.lineId.toLong(), taskAndsite.name)
|
||||
}
|
||||
lineInfo?.multiMap?.put("taskInfo", LineModel.getTaskTime())
|
||||
}
|
||||
LineManager.setLineInfo(lineInfo)
|
||||
|
||||
LineManager.setContraiInfo(
|
||||
ContraiInfo(busRoutesResult.lineId.toLong()
|
||||
,busRoutesResult.csvFileUrl,busRoutesResult.csvFileMd5,
|
||||
busRoutesResult.txtFileUrl,busRoutesResult.txtFileMd5,
|
||||
busRoutesResult.contrailSaveTime)
|
||||
)
|
||||
|
||||
|
||||
val tempTask =TaskDataBean()
|
||||
tempTask.taskId = busRoutesResult.taskId.toLong()
|
||||
tempTask.taskStartTime = busRoutesResult.taskTime
|
||||
tempTask.lineId = busRoutesResult.lineId.toLong()
|
||||
LineModel.currentTask = tempTask
|
||||
|
||||
LineModel.stationList = result
|
||||
LineModel.startStationIndex = currentStationIndex
|
||||
LineModel.stationList?.let { stationlist->
|
||||
val startStation = stationlist[LineModel.startStationIndex]
|
||||
if (LineModel.startStationIndex < stationlist.size-1) {
|
||||
val endStation = stationlist[LineModel.startStationIndex + 1]
|
||||
LineManager.setStartAndEndStation(startStation,endStation)
|
||||
}
|
||||
}
|
||||
return@flatMap Observable.just(true)
|
||||
}
|
||||
return@flatMap Observable.just(false)
|
||||
}
|
||||
}
|
||||
|
||||
override fun queryCanUseLine(): Observable<List<LineDataBean>?>? {
|
||||
return BusShuttleServiceManager.queryBusLines()
|
||||
}
|
||||
|
||||
override fun queryCanUserTask(lineId: Long): Observable<List<TaskDataBean>?>? {
|
||||
return BusShuttleServiceManager.queryBusTaskByLineId(lineId)
|
||||
}
|
||||
|
||||
override fun startTask(
|
||||
taskId: Long,
|
||||
lineId: Long,
|
||||
taskTime: Long,
|
||||
lineName: String
|
||||
): Observable<Boolean>? {
|
||||
return BusShuttleServiceManager.switchLine(taskId)
|
||||
}
|
||||
|
||||
override fun leaveStation(
|
||||
seq: Int,
|
||||
siteId: Long,
|
||||
taskId: Long,
|
||||
lineId: Long,
|
||||
taskStartTime: Long
|
||||
): Observable<Boolean>? {
|
||||
return BusShuttleServiceManager.leaveStation(seq, siteId, taskId, System.currentTimeMillis())
|
||||
}
|
||||
|
||||
override fun arriveStation(seq: Int, siteId: Long, taskId: Long): Observable<Boolean>? {
|
||||
return BusShuttleServiceManager.arriveSiteStation(
|
||||
seq,
|
||||
siteId,
|
||||
taskId,
|
||||
System.currentTimeMillis()
|
||||
)
|
||||
}
|
||||
|
||||
override fun endTask(taskId: Long): Observable<Boolean>? {
|
||||
return ShuttleServiceManager.endTask(taskId)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,19 +1,21 @@
|
||||
package com.mogo.och.weaknet.repository.net.impl.shuttle
|
||||
package com.mogo.och.weaknet.repository.impl
|
||||
|
||||
import com.mogo.och.common.module.manager.autopilot.line.LineManager
|
||||
import com.mogo.och.common.module.manager.logchainanalytic.OchChainLogManager
|
||||
import com.mogo.och.data.bean.BusStationBean
|
||||
import com.mogo.och.data.bean.ContraiInfo
|
||||
import com.mogo.och.data.bean.LineInfo
|
||||
import com.mogo.och.weaknet.model.LineModel
|
||||
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.bean.TaskSiteDataBean
|
||||
import com.mogo.och.weaknet.repository.net.IRepository
|
||||
import com.mogo.och.weaknet.repository.IRepository
|
||||
import com.mogo.och.weaknet.repository.net.shuttle.ShuttleServiceManager
|
||||
import io.reactivex.Observable
|
||||
|
||||
class ShuttleRepository: IRepository {
|
||||
override fun loadCurrentTaskInfo(): Observable<Boolean>? {
|
||||
return OrderServiceManager.queryBusRoutes()
|
||||
return ShuttleServiceManager.queryBusRoutes()
|
||||
?.flatMap { busRoutesResult ->
|
||||
if (!busRoutesResult.sites.isNullOrEmpty() && busRoutesResult.sites.size > 1) {
|
||||
OchChainLogManager.writeChainLogDb(
|
||||
@@ -51,6 +53,11 @@ class ShuttleRepository: IRepository {
|
||||
}
|
||||
LineManager.setLineInfo(lineInfo)
|
||||
|
||||
LineManager.setContraiInfo(ContraiInfo(busRoutesResult.lineId.toLong()
|
||||
,busRoutesResult.csvFileUrl,busRoutesResult.csvFileMd5,
|
||||
busRoutesResult.txtFileUrl,busRoutesResult.txtFileMd5,
|
||||
busRoutesResult.contrailSaveTime))
|
||||
|
||||
|
||||
val tempTask =TaskDataBean()
|
||||
tempTask.taskId = busRoutesResult.taskId.toLong()
|
||||
@@ -74,15 +81,15 @@ class ShuttleRepository: IRepository {
|
||||
}
|
||||
|
||||
override fun queryCanUseLine(): Observable<List<LineDataBean>?> {
|
||||
return OrderServiceManager.queryBusLines()
|
||||
return ShuttleServiceManager.queryBusLines()
|
||||
}
|
||||
|
||||
override fun queryCanUserTask(lineId: Long): Observable<List<TaskDataBean>?> {
|
||||
return OrderServiceManager.queryBusTaskByLineId(lineId)
|
||||
return ShuttleServiceManager.queryBusTaskByLineId(lineId)
|
||||
}
|
||||
|
||||
override fun startTask(taskId: Long, lineId: Long, taskTime: Long, lineName: String): Observable<Boolean>? {
|
||||
return OrderServiceManager.switchLine(taskId)
|
||||
return ShuttleServiceManager.switchLine(taskId)
|
||||
}
|
||||
|
||||
override fun leaveStation(
|
||||
@@ -92,15 +99,20 @@ class ShuttleRepository: IRepository {
|
||||
lineId: Long,
|
||||
taskStartTime: Long
|
||||
): Observable<Boolean>? {
|
||||
return OrderServiceManager.leaveStation(seq,siteId,taskId,System.currentTimeMillis())
|
||||
return ShuttleServiceManager.leaveStation(seq, siteId, taskId, System.currentTimeMillis())
|
||||
}
|
||||
|
||||
override fun arriveStation(seq: Int, siteId: Long, taskId: Long, ): Observable<Boolean>? {
|
||||
return OrderServiceManager.arriveSiteStation(seq,siteId,taskId,System.currentTimeMillis())
|
||||
return ShuttleServiceManager.arriveSiteStation(
|
||||
seq,
|
||||
siteId,
|
||||
taskId,
|
||||
System.currentTimeMillis()
|
||||
)
|
||||
}
|
||||
|
||||
override fun endTask(taskId: Long): Observable<Boolean>? {
|
||||
return OrderServiceManager.endTask(taskId)
|
||||
return ShuttleServiceManager.endTask(taskId)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mogo.och.weaknet.repository.net.impl.shuttlesaas
|
||||
package com.mogo.och.weaknet.repository.impl
|
||||
|
||||
import com.mogo.commons.AbsMogoApplication
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
@@ -16,7 +16,8 @@ import com.mogo.och.weaknet.repository.db.repository.EventDb
|
||||
import com.mogo.och.weaknet.repository.db.repository.LineDb
|
||||
import com.mogo.och.weaknet.repository.db.repository.TaskDb
|
||||
import com.mogo.och.weaknet.repository.db.repository.TaskSiteDb
|
||||
import com.mogo.och.weaknet.repository.net.IRepository
|
||||
import com.mogo.och.weaknet.repository.IRepository
|
||||
import com.mogo.och.weaknet.repository.net.shuttlesaas.ShuttleSaasServiceManager
|
||||
import io.reactivex.Observable
|
||||
|
||||
class ShuttleSaasRepository : IRepository {
|
||||
@@ -105,7 +106,7 @@ class ShuttleSaasRepository : IRepository {
|
||||
}
|
||||
|
||||
private fun loadServerRuningTask(): Observable<Boolean>? {
|
||||
return OrderServiceManager.queryBusRoutes()?.flatMap {busRoutesResult->
|
||||
return ShuttleSaasServiceManager.queryBusRoutes()?.flatMap { busRoutesResult->
|
||||
if (!busRoutesResult.sites.isNullOrEmpty() && busRoutesResult.sites.size > 1) {
|
||||
val queryTaskById = TaskDb.queryTaskById(busRoutesResult.taskId.toLong())
|
||||
if (queryTaskById == null || queryTaskById.status != TaskDataBean.used) {
|
||||
@@ -0,0 +1,170 @@
|
||||
package com.mogo.och.weaknet.repository.net.bus
|
||||
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig
|
||||
import com.mogo.eagle.core.network.MoGoRetrofitFactory
|
||||
import com.mogo.commons.storage.SharedPrefsMgr
|
||||
import com.mogo.och.common.module.constant.OchCommonConst
|
||||
import com.mogo.och.common.module.network.OchCommonNet
|
||||
import com.mogo.och.common.module.network.interceptor.transformTry
|
||||
import com.mogo.och.data.bean.BusRoutesResult
|
||||
import com.mogo.och.weaknet.bean.request.BusQueryLineStationsRequest
|
||||
import com.mogo.och.weaknet.repository.db.bean.LineDataBean
|
||||
import com.mogo.och.weaknet.repository.db.bean.TaskDataBean
|
||||
import com.mogo.och.weaknet.repository.net.bean.request.BusCloseTaskRequest
|
||||
import com.mogo.och.weaknet.repository.net.bean.request.BusResetDrivingLineRequest
|
||||
import com.mogo.och.weaknet.repository.net.bean.request.BusUpdateSiteStatusRequest
|
||||
import io.reactivex.Observable
|
||||
|
||||
/**
|
||||
* @author: wangmingjun
|
||||
* @date: 2021/10/20
|
||||
*/
|
||||
object BusServiceManager {
|
||||
|
||||
private val mService: IBusApiService =
|
||||
MoGoRetrofitFactory.getInstance(OchCommonConst.getBaseUrl()).create(
|
||||
IBusApiService::class.java
|
||||
)
|
||||
|
||||
|
||||
/**
|
||||
* 查询小巴车当前任务
|
||||
*/
|
||||
@JvmStatic
|
||||
fun queryBusRoutes(): Observable<BusRoutesResult>? {
|
||||
return mService.queryBusRoutes(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
SharedPrefsMgr.getInstance().token,
|
||||
BusQueryLineStationsRequest()
|
||||
) .transformTry()
|
||||
.flatMap(OchCommonNet("queryBusRoutes",false))
|
||||
.flatMap {
|
||||
Observable.just(it.data?: BusRoutesResult())
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置线路站点
|
||||
* @param taskId
|
||||
*/
|
||||
@JvmStatic
|
||||
fun switchLine(
|
||||
taskId: Long,
|
||||
): Observable<Boolean>? {
|
||||
return mService.switchLine(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
SharedPrefsMgr.getInstance().token,
|
||||
BusResetDrivingLineRequest(taskId)
|
||||
) .transformTry()
|
||||
.flatMap(OchCommonNet("switchLine",false))
|
||||
.flatMap {
|
||||
Observable.just(true)
|
||||
}
|
||||
}
|
||||
|
||||
// /**
|
||||
// * 中断当前任务
|
||||
// * @param context
|
||||
// * @param taskId
|
||||
// * @param callback
|
||||
// */
|
||||
// @JvmStatic
|
||||
// fun abortTask(context: Context, taskId: Long, callback: OchCommonServiceCallback<BaseData>?) {
|
||||
// M_SERVICE.abortTask(
|
||||
// MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
// SharedPrefsMgr.getInstance().token,
|
||||
// BusCloseTaskRequest(taskId)
|
||||
// )
|
||||
// .transformTry()
|
||||
// .subscribe(OchCommonSubscribeImpl(context, callback, "abortTask"))
|
||||
// }
|
||||
|
||||
/**
|
||||
* 正常结束任务
|
||||
* @param taskId
|
||||
*/
|
||||
@JvmStatic
|
||||
fun endTask(taskId: Long): Observable<Boolean>? {
|
||||
return mService.endTask(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
SharedPrefsMgr.getInstance().token,
|
||||
BusCloseTaskRequest(taskId)
|
||||
) .transformTry()
|
||||
.flatMap(OchCommonNet("endTask",true))
|
||||
.flatMap {
|
||||
Observable.just(true)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 离站上报
|
||||
* @param seq
|
||||
* @param siteId
|
||||
*/
|
||||
@JvmStatic
|
||||
fun leaveStation(
|
||||
seq: Int,
|
||||
siteId: Long,
|
||||
taskId: Long,
|
||||
writeVersion: Long,
|
||||
): Observable<Boolean>? {
|
||||
return mService.leaveStation(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
SharedPrefsMgr.getInstance().token,
|
||||
BusUpdateSiteStatusRequest(taskId, siteId, seq,writeVersion)
|
||||
).transformTry()
|
||||
.flatMap(OchCommonNet("leaveStation",false))
|
||||
.flatMap {
|
||||
Observable.just(true)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 到站更新站点状态
|
||||
* @param seq
|
||||
* @param siteId
|
||||
*/
|
||||
@JvmStatic
|
||||
fun arriveSiteStation(
|
||||
seq: Int, siteId: Long, taskId: Long, writeVersion: Long,
|
||||
): Observable<Boolean>? {
|
||||
return mService.arriveSiteStation(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
SharedPrefsMgr.getInstance().token,
|
||||
BusUpdateSiteStatusRequest(taskId, siteId, seq, writeVersion)
|
||||
)
|
||||
.transformTry()
|
||||
.flatMap(OchCommonNet("arriveSiteStation",false))
|
||||
.flatMap {
|
||||
Observable.just(true)
|
||||
}
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun queryBusLines(): Observable<List<LineDataBean>?> {
|
||||
return mService.queryBusLines(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
SharedPrefsMgr.getInstance().token,
|
||||
SharedPrefsMgr.getInstance().sn
|
||||
) .transformTry()
|
||||
.flatMap(OchCommonNet("queryBusLines",false))
|
||||
.flatMap {
|
||||
Observable.just(it.data)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun queryBusTaskByLineId(
|
||||
lineId: Long?) :Observable<List<TaskDataBean>?> {
|
||||
return mService.queryBusTaskByLineId(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
SharedPrefsMgr.getInstance().token,
|
||||
lineId
|
||||
) .transformTry()
|
||||
.flatMap(OchCommonNet("queryBusLines",false))
|
||||
.flatMap {
|
||||
Observable.just(it.data)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mogo.och.weaknet.repository.net.impl.bus
|
||||
package com.mogo.och.weaknet.repository.net.bus
|
||||
|
||||
import com.mogo.eagle.core.data.BaseData
|
||||
import com.mogo.och.weaknet.bean.request.BusQueryLineStationsRequest
|
||||
@@ -26,7 +26,7 @@ import retrofit2.http.Query
|
||||
*
|
||||
* wiki: http://wiki.zhidaohulian.com/pages/viewpage.action?pageId=48970072
|
||||
*/
|
||||
interface IBascApiService {
|
||||
interface IBusApiService {
|
||||
/**
|
||||
* 根据车机坐标获取所在区域全部站点信息
|
||||
*
|
||||
@@ -35,11 +35,7 @@ interface IBascApiService {
|
||||
*/
|
||||
@Headers("Content-Type:application/json;charset=UTF-8")
|
||||
@POST("/autopilot-car-hailing/line/v2/driver/bus/lineDataWithDriver/query")
|
||||
fun queryBusRoutes(
|
||||
@Header("appId") appId: String?,
|
||||
@Header("ticket") ticket: String?,
|
||||
@Body request: BusQueryLineStationsRequest?
|
||||
): Observable<BusRoutesResponse>
|
||||
fun queryBusRoutes(@Header("appId") appId: String?, @Header("ticket") ticket: String?, @Body request: BusQueryLineStationsRequest?): Observable<BusRoutesResponse>
|
||||
|
||||
/**
|
||||
* @param request 请求参数{"destLine":1,"sn":"F803EB2046PZD00229"} 这个接口是重置bus线路的, 不是重置线路中站点的
|
||||
@@ -48,11 +44,7 @@ interface IBascApiService {
|
||||
*/
|
||||
@Headers("Content-Type:application/json;charset=UTF-8")
|
||||
@POST("/autopilot-car-hailing/cab/flow/v1/bus/driver/bus/startTask")
|
||||
fun switchLine(
|
||||
@Header("appId") appId: String?,
|
||||
@Header("ticket") ticket: String?,
|
||||
@Body request: BusResetDrivingLineRequest?
|
||||
): Observable<BusRoutesResponse>
|
||||
fun switchLine(@Header("appId") appId: String?, @Header("ticket") ticket: String?, @Body request: BusResetDrivingLineRequest?): Observable<BaseData>
|
||||
|
||||
/**
|
||||
* 离站,通知服务器
|
||||
@@ -61,11 +53,7 @@ interface IBascApiService {
|
||||
*/
|
||||
@Headers("Content-Type:application/json;charset=UTF-8")
|
||||
@POST("/autopilot-car-hailing/cab/flow/v1/bus/driver/bus/leave")
|
||||
fun leaveStation(
|
||||
@Header("appId") appId: String?,
|
||||
@Header("ticket") ticket: String?,
|
||||
@Body request: BusUpdateSiteStatusRequest?
|
||||
): Observable<BaseData>
|
||||
fun leaveStation(@Header("appId") appId: String?, @Header("ticket") ticket: String?, @Body request: BusUpdateSiteStatusRequest?): Observable<BaseData>
|
||||
|
||||
/**
|
||||
* 到站 更新到站信息
|
||||
@@ -74,11 +62,7 @@ interface IBascApiService {
|
||||
*/
|
||||
@Headers("Content-type:application/json;charset=UTF-8")
|
||||
@POST("/autopilot-car-hailing/cab/flow/v1/bus/driver/bus/arrive")
|
||||
fun arriveSiteStation(
|
||||
@Header("appId") appId: String?,
|
||||
@Header("ticket") ticket: String?,
|
||||
@Body request: BusUpdateSiteStatusRequest?
|
||||
): Observable<BaseData>
|
||||
fun arriveSiteStation(@Header("appId") appId: String?, @Header("ticket") ticket: String?, @Body request: BusUpdateSiteStatusRequest?): Observable<BaseData>
|
||||
|
||||
|
||||
/**
|
||||
@@ -102,11 +86,7 @@ interface IBascApiService {
|
||||
* @return
|
||||
*/
|
||||
@GET("/autopilot-car-hailing/line/v2/driver/bus/bindLine/query")
|
||||
fun queryBusLines(
|
||||
@Header("appId") appId: String?,
|
||||
@Header("ticket") ticket: String?,
|
||||
@Query("sn") sn: String?
|
||||
): Observable<BusQueryLinesResponse>
|
||||
fun queryBusLines(@Header("appId") appId: String?, @Header("ticket") ticket: String?, @Query("sn") sn: String?): Observable<BusQueryLinesResponse>
|
||||
|
||||
/**
|
||||
* 查询路线当天的任务
|
||||
@@ -116,7 +96,7 @@ interface IBascApiService {
|
||||
* @return
|
||||
*/
|
||||
@GET("/autopilot-car-hailing/line/v2/driver/bus/task/query")
|
||||
fun queryBusTaskByLineId(@Header("appId") appId: String?, @Header("ticket") ticket: String?, @Query("lineId") lineId: String?): Observable<BusQueryLineTaskResponse>
|
||||
fun queryBusTaskByLineId(@Header("appId") appId: String?, @Header("ticket") ticket: String?, @Query("lineId") lineId: Long?): Observable<BusQueryLineTaskResponse>
|
||||
|
||||
|
||||
/**
|
||||
@@ -157,10 +137,6 @@ interface IBascApiService {
|
||||
*/
|
||||
@Headers("Content-type:application/json;charset=UTF-8")
|
||||
@POST("/autopilot-car-hailing/cab/flow/v1/bus/driver/bus/endTask")
|
||||
fun endTask(
|
||||
@Header("appId") appId: String?,
|
||||
@Header("ticket") ticket: String?,
|
||||
@Body data: BusCloseTaskRequest?
|
||||
): Observable<BaseData>
|
||||
fun endTask(@Header("appId") appId: String?, @Header("ticket") ticket: String?, @Body data: BusCloseTaskRequest?): Observable<BaseData>
|
||||
}
|
||||
|
||||
@@ -0,0 +1,181 @@
|
||||
package com.mogo.och.weaknet.repository.net.bussaas
|
||||
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig
|
||||
import com.mogo.eagle.core.network.MoGoRetrofitFactory
|
||||
import com.mogo.commons.storage.SharedPrefsMgr
|
||||
import com.mogo.och.common.module.constant.OchCommonConst
|
||||
import com.mogo.och.common.module.network.OchCommonNet
|
||||
import com.mogo.och.common.module.network.interceptor.transformTry
|
||||
import com.mogo.och.data.bean.BusRoutesResult
|
||||
import com.mogo.och.weaknet.repository.db.bean.LineDataBean
|
||||
import com.mogo.och.weaknet.repository.db.bean.TaskDataBean
|
||||
import com.mogo.och.weaknet.repository.net.bean.request.BusCloseTaskRequest
|
||||
import com.mogo.och.weaknet.repository.net.bean.request.BusResetDrivingLineRequest
|
||||
import com.mogo.och.weaknet.repository.net.bean.request.BusUpdateSiteStatusRequest
|
||||
import io.reactivex.Observable
|
||||
|
||||
/**
|
||||
* @author: wangmingjun
|
||||
* @date: 2021/10/20
|
||||
*/
|
||||
object BusShuttleServiceManager {
|
||||
|
||||
private val M_SAAS_SERVICE: IBusSaasApiService =
|
||||
MoGoRetrofitFactory.getInstance(OchCommonConst.getBaseUrl()).create(
|
||||
IBusSaasApiService::class.java
|
||||
)
|
||||
|
||||
/**
|
||||
* 查询小巴车当前任务
|
||||
* @param context
|
||||
* @param callback
|
||||
*/
|
||||
@JvmStatic
|
||||
fun queryBusRoutes(): Observable<BusRoutesResult>? {
|
||||
return M_SAAS_SERVICE.queryBusRoutes(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
SharedPrefsMgr.getInstance().token,
|
||||
SharedPrefsMgr.getInstance().getSn(),
|
||||
) .transformTry()
|
||||
.flatMap(OchCommonNet("queryBusRoutes",false))
|
||||
.flatMap {
|
||||
Observable.just(it.data?: BusRoutesResult())
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置线路站点
|
||||
* @param context
|
||||
* @param taskId
|
||||
* @param callback
|
||||
*/
|
||||
@JvmStatic
|
||||
fun switchLine(
|
||||
taskId: Long,
|
||||
): Observable<Boolean>? {
|
||||
return M_SAAS_SERVICE.switchLine(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
SharedPrefsMgr.getInstance().token,
|
||||
BusResetDrivingLineRequest(taskId)
|
||||
) .transformTry()
|
||||
.flatMap(OchCommonNet("switchLine",false))
|
||||
.flatMap {
|
||||
Observable.just(true)
|
||||
}
|
||||
}
|
||||
|
||||
// /**
|
||||
// * 中断当前任务
|
||||
// * @param context
|
||||
// * @param taskId
|
||||
// * @param callback
|
||||
// */
|
||||
// @JvmStatic
|
||||
// fun abortTask(context: Context, taskId: Long, callback: OchCommonServiceCallback<BaseData>?) {
|
||||
//
|
||||
// M_SAAS_SERVICE.abortTask(
|
||||
// MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
// SharedPrefsMgr.getInstance().token,
|
||||
// BusCloseTaskRequest(taskId)
|
||||
// )
|
||||
// .transformTry()
|
||||
// .subscribe(OchCommonSubscribeImpl(context, callback, "abortTask"))
|
||||
//
|
||||
// }
|
||||
|
||||
/**
|
||||
* 正常结束任务
|
||||
* @param context
|
||||
* @param taskId
|
||||
* @param callback
|
||||
*/
|
||||
@JvmStatic
|
||||
fun endTask(taskId: Long): Observable<Boolean>? {
|
||||
return M_SAAS_SERVICE.endTask(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
SharedPrefsMgr.getInstance().token,
|
||||
BusCloseTaskRequest(taskId)
|
||||
) .transformTry()
|
||||
.flatMap(OchCommonNet("endTask",true))
|
||||
.flatMap {
|
||||
Observable.just(true)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 离站上报
|
||||
* @param context
|
||||
* @param seq
|
||||
* @param siteId
|
||||
* @param callback
|
||||
*/
|
||||
@JvmStatic
|
||||
fun leaveStation(
|
||||
seq: Int,
|
||||
siteId: Long,
|
||||
taskId: Long,
|
||||
writeVersion: Long,
|
||||
): Observable<Boolean>? {
|
||||
return M_SAAS_SERVICE.leaveStation(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
SharedPrefsMgr.getInstance().token,
|
||||
BusUpdateSiteStatusRequest(taskId, siteId, seq,writeVersion)
|
||||
).transformTry()
|
||||
.flatMap(OchCommonNet("leaveStation",false))
|
||||
.flatMap {
|
||||
Observable.just(true)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 到站更新站点状态
|
||||
* @param context
|
||||
* @param seq
|
||||
* @param siteId
|
||||
* @param callback
|
||||
*/
|
||||
@JvmStatic
|
||||
fun arriveSiteStation(
|
||||
seq: Int, siteId: Long, taskId: Long, writeVersion: Long,
|
||||
): Observable<Boolean>? {
|
||||
return M_SAAS_SERVICE.arriveSiteStation(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
SharedPrefsMgr.getInstance().token,
|
||||
BusUpdateSiteStatusRequest(taskId, siteId, seq, writeVersion)
|
||||
)
|
||||
.transformTry()
|
||||
.flatMap(OchCommonNet("arriveSiteStation",false))
|
||||
.flatMap {
|
||||
Observable.just(true)
|
||||
}
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun queryBusLines(): Observable<List<LineDataBean>?> {
|
||||
return M_SAAS_SERVICE.queryBusLines(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
SharedPrefsMgr.getInstance().token,
|
||||
SharedPrefsMgr.getInstance().sn
|
||||
) .transformTry()
|
||||
.flatMap(OchCommonNet("queryBusLines",false))
|
||||
.flatMap {
|
||||
Observable.just(it.data)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun queryBusTaskByLineId(
|
||||
lineId: Long?) :Observable<List<TaskDataBean>?> {
|
||||
return M_SAAS_SERVICE.queryBusTaskByLineId(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
SharedPrefsMgr.getInstance().token,
|
||||
lineId
|
||||
) .transformTry()
|
||||
.flatMap(OchCommonNet("queryBusLines",false))
|
||||
.flatMap {
|
||||
Observable.just(it.data)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mogo.och.weaknet.repository.net.impl.bussaas
|
||||
package com.mogo.och.weaknet.repository.net.bussaas
|
||||
|
||||
import com.mogo.eagle.core.data.BaseData
|
||||
import com.mogo.och.weaknet.bean.response.BusRoutesResponse
|
||||
@@ -24,17 +24,13 @@ import retrofit2.http.Query
|
||||
*
|
||||
* wiki: http://wiki.zhidaohulian.com/pages/viewpage.action?pageId=48970072
|
||||
*/
|
||||
interface ISAASApiService {
|
||||
interface IBusSaasApiService {
|
||||
/**
|
||||
* 根据车机坐标获取所在区域全部站点信息
|
||||
*/
|
||||
@Headers("Content-Type:application/json;charset=UTF-8")
|
||||
@GET("/och-bus-cabin/api/business/v1/driver/bus/lineDataWithDriver/query")
|
||||
fun queryBusRoutes(
|
||||
@Header("appId") appId: String?,
|
||||
@Header("ticket") ticket: String?,
|
||||
@Query("sn") sn: String?
|
||||
): Observable<BusRoutesResponse>
|
||||
fun queryBusRoutes(@Header("appId") appId: String?, @Header("ticket") ticket: String?, @Query("sn") sn: String?): Observable<BusRoutesResponse>
|
||||
|
||||
/**
|
||||
* @param request 请求参数{"destLine":1,"sn":"F803EB2046PZD00229"} 这个接口是重置bus线路的, 不是重置线路中站点的
|
||||
@@ -43,33 +39,21 @@ interface ISAASApiService {
|
||||
*/
|
||||
@Headers("Content-Type:application/json;charset=UTF-8")
|
||||
@POST("/och-bus-cabin/cab/flow/v1/bus/driver/startTask")
|
||||
fun switchLine(
|
||||
@Header("appId") appId: String?,
|
||||
@Header("ticket") ticket: String?,
|
||||
@Body request: BusResetDrivingLineRequest?
|
||||
): Observable<BusRoutesResponse>
|
||||
fun switchLine(@Header("appId") appId: String?, @Header("ticket") ticket: String?, @Body request: BusResetDrivingLineRequest?): Observable<BaseData>
|
||||
|
||||
/**
|
||||
* 离站,通知服务器
|
||||
*/
|
||||
@Headers("Content-Type:application/json;charset=UTF-8")
|
||||
@POST("/och-bus-cabin/cab/flow/v1/bus/driver/leave")
|
||||
fun leaveStation(
|
||||
@Header("appId") appId: String?,
|
||||
@Header("ticket") ticket: String?,
|
||||
@Body request: BusUpdateSiteStatusRequest?
|
||||
): Observable<BaseData>
|
||||
fun leaveStation(@Header("appId") appId: String?, @Header("ticket") ticket: String?, @Body request: BusUpdateSiteStatusRequest?): Observable<BaseData>
|
||||
|
||||
/**
|
||||
* 到站 更新到站信息
|
||||
*/
|
||||
@Headers("Content-type:application/json;charset=UTF-8")
|
||||
@POST("/och-bus-cabin/cab/flow/v1/bus/driver/arrive")
|
||||
fun arriveSiteStation(
|
||||
@Header("appId") appId: String?,
|
||||
@Header("ticket") ticket: String?,
|
||||
@Body request: BusUpdateSiteStatusRequest?
|
||||
): Observable<BaseData>
|
||||
fun arriveSiteStation(@Header("appId") appId: String?, @Header("ticket") ticket: String?, @Body request: BusUpdateSiteStatusRequest?): Observable<BaseData>
|
||||
|
||||
|
||||
/**
|
||||
@@ -77,11 +61,7 @@ interface ISAASApiService {
|
||||
*/
|
||||
@Headers("Content-type:application/json;charset=UTF-8")
|
||||
@GET("/och-bus-cabin/api/business/v1/driver/BusBindLine")
|
||||
fun queryBusLines(
|
||||
@Header("appId") appId: String?,
|
||||
@Header("ticket") ticket: String?,
|
||||
@Query("sn") sn: String?
|
||||
): Observable<BusQueryLinesResponse>
|
||||
fun queryBusLines(@Header("appId") appId: String?, @Header("ticket") ticket: String?, @Query("sn") sn: String?): Observable<BusQueryLinesResponse>
|
||||
|
||||
/**
|
||||
* 查询路线当天的任务
|
||||
@@ -92,11 +72,7 @@ interface ISAASApiService {
|
||||
*/
|
||||
@Headers("Content-type:application/json;charset=UTF-8")
|
||||
@GET("/och-bus-cabin/api/business/v1/driver/bus/task/query")
|
||||
fun queryBusTaskByLineId(
|
||||
@Header("appId") appId: String?,
|
||||
@Header("ticket") ticket: String?,
|
||||
@Query("lineId") lineId: String?
|
||||
): Observable<BusQueryLineTaskResponse>
|
||||
fun queryBusTaskByLineId(@Header("appId") appId: String?, @Header("ticket") ticket: String?, @Query("lineId") lineId: Long?): Observable<BusQueryLineTaskResponse>
|
||||
|
||||
|
||||
/**
|
||||
@@ -134,10 +110,6 @@ interface ISAASApiService {
|
||||
*/
|
||||
@Headers("Content-type:application/json;charset=UTF-8")
|
||||
@POST("/och-bus-cabin/cab/flow/v1/bus/driver/endTask")
|
||||
fun endTask(
|
||||
@Header("appId") appId: String?,
|
||||
@Header("ticket") ticket: String?,
|
||||
@Body data: BusCloseTaskRequest?
|
||||
): Observable<BaseData>
|
||||
fun endTask(@Header("appId") appId: String?, @Header("ticket") ticket: String?, @Body data: BusCloseTaskRequest?): Observable<BaseData>
|
||||
}
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
package com.mogo.och.weaknet.repository.net.impl.bus
|
||||
|
||||
import com.mogo.commons.AbsMogoApplication
|
||||
import com.mogo.och.weaknet.repository.db.bean.LineDataBean
|
||||
import com.mogo.och.weaknet.repository.db.bean.TaskDataBean
|
||||
import com.mogo.och.weaknet.repository.net.IRepository
|
||||
import io.reactivex.Observable
|
||||
|
||||
class BusRepository: IRepository {
|
||||
|
||||
private val content = AbsMogoApplication.getApp()
|
||||
|
||||
init {
|
||||
|
||||
}
|
||||
|
||||
override fun loadCurrentTaskInfo(): Observable<Boolean>? {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
override fun queryCanUseLine(): Observable<List<LineDataBean>?>? {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
override fun queryCanUserTask(lineId: Long): Observable<List<TaskDataBean>?>? {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
override fun startTask(
|
||||
taskId: Long,
|
||||
lineId: Long,
|
||||
taskTime: Long,
|
||||
lineName: String
|
||||
): Observable<Boolean>? {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
override fun leaveStation(
|
||||
seq: Int,
|
||||
siteId: Long,
|
||||
taskId: Long,
|
||||
lineId: Long,
|
||||
taskStartTime: Long
|
||||
): Observable<Boolean>? {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
override fun arriveStation(seq: Int, siteId: Long, taskId: Long): Observable<Boolean>? {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
override fun endTask(taskId: Long): Observable<Boolean>? {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,234 +0,0 @@
|
||||
package com.mogo.och.weaknet.repository.net.impl.bus
|
||||
|
||||
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.commons.storage.SharedPrefsMgr
|
||||
import com.mogo.eagle.core.data.map.MogoLocation
|
||||
import com.mogo.och.common.module.constant.OchCommonConst
|
||||
import com.mogo.och.common.module.network.OchCommonServiceCallback
|
||||
import com.mogo.och.common.module.network.OchCommonSubscribeImpl
|
||||
import com.mogo.och.common.module.network.interceptor.transformTry
|
||||
import com.mogo.och.weaknet.bean.request.BusQueryLineStationsRequest
|
||||
import com.mogo.och.weaknet.bean.response.BusRoutesResponse
|
||||
import com.mogo.och.weaknet.repository.net.bean.request.BusCloseTaskRequest
|
||||
import com.mogo.och.weaknet.repository.net.bean.request.BusResetDrivingLineRequest
|
||||
import com.mogo.och.weaknet.repository.net.bean.request.BusRoutePlanningUpdateReqBean
|
||||
import com.mogo.och.weaknet.repository.net.bean.request.CarHeartbeatReqBean
|
||||
import com.mogo.och.weaknet.repository.net.bean.response.BusQueryLineTaskResponse
|
||||
import com.mogo.och.weaknet.repository.net.bean.response.BusQueryLinesResponse
|
||||
|
||||
/**
|
||||
* @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<BusRoutesResponse>?) {
|
||||
//获取当前高德坐标
|
||||
M_SERVICE.queryBusRoutes(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
SharedPrefsMgr.getInstance().token,
|
||||
BusQueryLineStationsRequest()
|
||||
)
|
||||
.transformTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "queryBusRoutes"))
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置线路站点
|
||||
* @param context
|
||||
* @param taskId
|
||||
* @param callback
|
||||
*/
|
||||
@JvmStatic
|
||||
fun switchLine(
|
||||
context: Context,
|
||||
taskId: Long,
|
||||
callback: OchCommonServiceCallback<BusRoutesResponse>?
|
||||
) {
|
||||
M_SERVICE.switchLine(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
SharedPrefsMgr.getInstance().token,
|
||||
BusResetDrivingLineRequest(taskId)
|
||||
)
|
||||
.transformTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "switchLine"))
|
||||
}
|
||||
|
||||
/**
|
||||
* 中断当前任务
|
||||
* @param context
|
||||
* @param taskId
|
||||
* @param callback
|
||||
*/
|
||||
@JvmStatic
|
||||
fun abortTask(context: Context, taskId: Long, callback: OchCommonServiceCallback<BaseData>?) {
|
||||
M_SERVICE.abortTask(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
SharedPrefsMgr.getInstance().token,
|
||||
BusCloseTaskRequest(taskId)
|
||||
)
|
||||
.transformTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "abortTask"))
|
||||
}
|
||||
|
||||
/**
|
||||
* 正常结束任务
|
||||
* @param context
|
||||
* @param taskId
|
||||
* @param callback
|
||||
*/
|
||||
@JvmStatic
|
||||
fun endTask(context: Context, taskId: Long, callback: OchCommonServiceCallback<BaseData>?) {
|
||||
M_SERVICE.endTask(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
SharedPrefsMgr.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<BaseData>?
|
||||
) {
|
||||
// M_SERVICE.leaveStation(
|
||||
// MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
// SharedPrefsMgr.getInstance().token,
|
||||
// BusUpdateSiteStatusRequest(taskId, siteId, seq, System.currentTimeMillis())
|
||||
// )
|
||||
// .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<BaseData>?
|
||||
) {
|
||||
// M_SERVICE.arriveSiteStation(
|
||||
// MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
// SharedPrefsMgr.getInstance().token,
|
||||
// BusUpdateSiteStatusRequest(taskId, siteId, seq, System.currentTimeMillis())
|
||||
// )
|
||||
// .transformTry()
|
||||
// .subscribe(OchCommonSubscribeImpl(context, callback, "arriveSiteStation"))
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun queryBusLines(
|
||||
context: Context,
|
||||
callback: OchCommonServiceCallback<BusQueryLinesResponse>?
|
||||
) {
|
||||
M_SERVICE.queryBusLines(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
SharedPrefsMgr.getInstance().token,
|
||||
SharedPrefsMgr.getInstance().sn
|
||||
)
|
||||
.transformTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "queryBusLines"))
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun queryBusTaskByLineId(
|
||||
context: Context,
|
||||
lineId: String?,
|
||||
callback: OchCommonServiceCallback<BusQueryLineTaskResponse>?
|
||||
) {
|
||||
M_SERVICE.queryBusTaskByLineId(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
SharedPrefsMgr.getInstance().token,
|
||||
lineId
|
||||
)
|
||||
.transformTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "queryBusLines"))
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun updateOrderRoute(
|
||||
context: Context,
|
||||
lineId: Int,
|
||||
startSiteId: Int,
|
||||
endSiteId: Int,
|
||||
points: List<MogoLocation>,
|
||||
callback: OchCommonServiceCallback<BaseData>?
|
||||
) {
|
||||
val pointsResult = mutableListOf<BusRoutePlanningUpdateReqBean.Result>()
|
||||
points.forEach {
|
||||
val result = BusRoutePlanningUpdateReqBean.Result()
|
||||
result.latitude = it.latitude;
|
||||
result.longitude = it.longitude;
|
||||
pointsResult.add(result);
|
||||
}
|
||||
|
||||
M_SERVICE.updateOrderRoute(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
SharedPrefsMgr.getInstance().token,
|
||||
BusRoutePlanningUpdateReqBean(
|
||||
SharedPrefsMgr.getInstance().sn, lineId, startSiteId, endSiteId, pointsResult
|
||||
)
|
||||
)
|
||||
.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<BaseData>?
|
||||
) {
|
||||
M_SERVICE.runCarHeartbeat(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
SharedPrefsMgr.getInstance().token,
|
||||
CarHeartbeatReqBean(
|
||||
SharedPrefsMgr.getInstance().sn, lon, lat
|
||||
)
|
||||
)
|
||||
.transformTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "runCarHeartbeat", false))
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
package com.mogo.och.weaknet.repository.net.impl.bussaas
|
||||
|
||||
import com.mogo.commons.AbsMogoApplication
|
||||
import com.mogo.och.weaknet.repository.db.bean.LineDataBean
|
||||
import com.mogo.och.weaknet.repository.db.bean.TaskDataBean
|
||||
import com.mogo.och.weaknet.repository.net.IRepository
|
||||
import io.reactivex.Observable
|
||||
|
||||
class BusSaasRepository: IRepository {
|
||||
|
||||
private val content = AbsMogoApplication.getApp()
|
||||
|
||||
init {
|
||||
|
||||
}
|
||||
|
||||
override fun loadCurrentTaskInfo(): Observable<Boolean>? {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
override fun queryCanUseLine(): Observable<List<LineDataBean>?>? {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
override fun queryCanUserTask(lineId: Long): Observable<List<TaskDataBean>?>? {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
override fun startTask(
|
||||
taskId: Long,
|
||||
lineId: Long,
|
||||
taskTime: Long,
|
||||
lineName: String
|
||||
): Observable<Boolean>? {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
override fun leaveStation(
|
||||
seq: Int,
|
||||
siteId: Long,
|
||||
taskId: Long,
|
||||
lineId: Long,
|
||||
taskStartTime: Long
|
||||
): Observable<Boolean>? {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
override fun arriveStation(seq: Int, siteId: Long, taskId: Long): Observable<Boolean>? {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
override fun endTask(taskId: Long): Observable<Boolean>? {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,232 +0,0 @@
|
||||
package com.mogo.och.weaknet.repository.net.impl.bussaas
|
||||
|
||||
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.commons.storage.SharedPrefsMgr
|
||||
import com.mogo.eagle.core.data.map.MogoLocation
|
||||
import com.mogo.och.common.module.constant.OchCommonConst
|
||||
import com.mogo.och.common.module.network.OchCommonServiceCallback
|
||||
import com.mogo.och.common.module.network.OchCommonSubscribeImpl
|
||||
import com.mogo.och.common.module.network.interceptor.transformTry
|
||||
import com.mogo.och.weaknet.bean.response.BusRoutesResponse
|
||||
import com.mogo.och.weaknet.repository.net.bean.request.BusCloseTaskRequest
|
||||
import com.mogo.och.weaknet.repository.net.bean.request.BusResetDrivingLineRequest
|
||||
import com.mogo.och.weaknet.repository.net.bean.request.BusRoutePlanningUpdateReqBean
|
||||
import com.mogo.och.weaknet.repository.net.bean.response.BusQueryLineTaskResponse
|
||||
import com.mogo.och.weaknet.repository.net.bean.response.BusQueryLinesResponse
|
||||
|
||||
/**
|
||||
* @author: wangmingjun
|
||||
* @date: 2021/10/20
|
||||
*/
|
||||
object OrderServiceManager {
|
||||
|
||||
private val M_SAAS_SERVICE: ISAASApiService =
|
||||
MoGoRetrofitFactory.getInstance(OchCommonConst.getBaseUrl()).create(
|
||||
ISAASApiService::class.java
|
||||
)
|
||||
|
||||
/**
|
||||
* 查询小巴车当前任务
|
||||
* @param context
|
||||
* @param callback
|
||||
*/
|
||||
@JvmStatic
|
||||
fun queryBusRoutes(context: Context, callback: OchCommonServiceCallback<BusRoutesResponse>?) {
|
||||
//获取当前高德坐标
|
||||
|
||||
M_SAAS_SERVICE.queryBusRoutes(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
SharedPrefsMgr.getInstance().token,
|
||||
SharedPrefsMgr.getInstance().sn
|
||||
)
|
||||
.transformTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "queryBusRoutes"))
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置线路站点
|
||||
* @param context
|
||||
* @param taskId
|
||||
* @param callback
|
||||
*/
|
||||
@JvmStatic
|
||||
fun switchLine(
|
||||
context: Context,
|
||||
taskId: Long,
|
||||
callback: OchCommonServiceCallback<BusRoutesResponse>?
|
||||
) {
|
||||
M_SAAS_SERVICE.switchLine(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
SharedPrefsMgr.getInstance().token,
|
||||
BusResetDrivingLineRequest(taskId)
|
||||
)
|
||||
.transformTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "switchLine"))
|
||||
}
|
||||
|
||||
/**
|
||||
* 中断当前任务
|
||||
* @param context
|
||||
* @param taskId
|
||||
* @param callback
|
||||
*/
|
||||
@JvmStatic
|
||||
fun abortTask(context: Context, taskId: Long, callback: OchCommonServiceCallback<BaseData>?) {
|
||||
|
||||
M_SAAS_SERVICE.abortTask(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
SharedPrefsMgr.getInstance().token,
|
||||
BusCloseTaskRequest(taskId)
|
||||
)
|
||||
.transformTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "abortTask"))
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 正常结束任务
|
||||
* @param context
|
||||
* @param taskId
|
||||
* @param callback
|
||||
*/
|
||||
@JvmStatic
|
||||
fun endTask(context: Context, taskId: Long, callback: OchCommonServiceCallback<BaseData>?) {
|
||||
|
||||
M_SAAS_SERVICE.endTask(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
SharedPrefsMgr.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<BaseData>?
|
||||
) {
|
||||
// M_SAAS_SERVICE.leaveStation(
|
||||
// MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
// SharedPrefsMgr.getInstance().token,
|
||||
// BusUpdateSiteStatusRequest(taskId, siteId, seq, System.currentTimeMillis())
|
||||
// )
|
||||
// .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<BaseData>?
|
||||
) {
|
||||
// M_SAAS_SERVICE.arriveSiteStation(
|
||||
// MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
// SharedPrefsMgr.getInstance().token,
|
||||
// BusUpdateSiteStatusRequest(taskId, siteId, seq, System.currentTimeMillis())
|
||||
// )
|
||||
// .transformTry()
|
||||
// .subscribe(OchCommonSubscribeImpl(context, callback, "arriveSiteStation"))
|
||||
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun queryBusLines(
|
||||
context: Context,
|
||||
callback: OchCommonServiceCallback<BusQueryLinesResponse>?
|
||||
) {
|
||||
|
||||
M_SAAS_SERVICE.queryBusLines(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
SharedPrefsMgr.getInstance().token,
|
||||
SharedPrefsMgr.getInstance().sn
|
||||
)
|
||||
.transformTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "queryBusLines"))
|
||||
|
||||
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun queryBusTaskByLineId(
|
||||
context: Context,
|
||||
lineId: String?,
|
||||
callback: OchCommonServiceCallback<BusQueryLineTaskResponse>?
|
||||
) {
|
||||
M_SAAS_SERVICE.queryBusTaskByLineId(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
SharedPrefsMgr.getInstance().token,
|
||||
lineId
|
||||
)
|
||||
.transformTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "queryBusLines"))
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun updateOrderRoute(
|
||||
context: Context,
|
||||
lineId: Int,
|
||||
startSiteId: Int,
|
||||
endSiteId: Int,
|
||||
points: List<MogoLocation>,
|
||||
callback: OchCommonServiceCallback<BaseData>?
|
||||
) {
|
||||
val pointsResult = mutableListOf<BusRoutePlanningUpdateReqBean.Result>()
|
||||
points.forEach {
|
||||
val result = BusRoutePlanningUpdateReqBean.Result()
|
||||
result.latitude = it.latitude;
|
||||
result.longitude = it.longitude;
|
||||
pointsResult.add(result);
|
||||
}
|
||||
|
||||
M_SAAS_SERVICE.updateOrderRoute(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
SharedPrefsMgr.getInstance().token,
|
||||
BusRoutePlanningUpdateReqBean(
|
||||
SharedPrefsMgr.getInstance().sn, lineId, startSiteId, endSiteId, pointsResult
|
||||
)
|
||||
)
|
||||
.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<BaseData>?
|
||||
) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mogo.och.weaknet.repository.net.impl.shuttle;
|
||||
package com.mogo.och.weaknet.repository.net.shuttle;
|
||||
|
||||
import com.mogo.eagle.core.data.BaseData;
|
||||
import com.mogo.och.weaknet.bean.request.BusQueryLineStationsRequest;
|
||||
@@ -24,7 +24,7 @@ import retrofit2.http.Query;
|
||||
* @author tongchenfei
|
||||
* <p>
|
||||
*/
|
||||
public interface IBascApiService {
|
||||
public interface IShuttleApiService {
|
||||
/**
|
||||
* 查询当前运行任务
|
||||
*
|
||||
@@ -1,8 +1,7 @@
|
||||
package com.mogo.och.weaknet.repository.net.impl.shuttle
|
||||
package com.mogo.och.weaknet.repository.net.shuttle
|
||||
|
||||
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.commons.storage.SharedPrefsMgr
|
||||
import com.mogo.och.common.module.constant.OchCommonConst
|
||||
@@ -19,17 +18,16 @@ import com.mogo.och.weaknet.repository.db.bean.TaskDataBean
|
||||
import com.mogo.och.weaknet.repository.net.bean.request.BusCloseTaskRequest
|
||||
import com.mogo.och.weaknet.repository.net.bean.request.BusResetDrivingLineRequest
|
||||
import com.mogo.och.weaknet.repository.net.bean.request.BusUpdateSiteStatusRequest
|
||||
import com.mogo.och.weaknet.repository.net.bean.response.BusQueryLinesResponse
|
||||
import io.reactivex.Observable
|
||||
|
||||
/**
|
||||
* @author: wangmingjun
|
||||
* @date: 2021/10/20
|
||||
*/
|
||||
object OrderServiceManager {
|
||||
object ShuttleServiceManager {
|
||||
|
||||
private val mService: IBascApiService = MoGoRetrofitFactory.getInstance(OchCommonConst.getShuttleUrl()).create(
|
||||
IBascApiService::class.java
|
||||
private val mService: IShuttleApiService = MoGoRetrofitFactory.getInstance(OchCommonConst.getShuttleUrl()).create(
|
||||
IShuttleApiService::class.java
|
||||
)
|
||||
|
||||
|
||||
@@ -72,22 +70,22 @@ object OrderServiceManager {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 中断当前任务
|
||||
* @param context
|
||||
* @param taskId
|
||||
* @param callback
|
||||
*/
|
||||
@JvmStatic
|
||||
fun abortTask(context: Context, taskId: Long, callback: OchCommonServiceCallback<BaseData>?) {
|
||||
mService.abortTask(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
SharedPrefsMgr.getInstance().token,
|
||||
BusCloseTaskRequest(taskId)
|
||||
)
|
||||
.transformTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "abortTask"))
|
||||
}
|
||||
// /**
|
||||
// * 中断当前任务
|
||||
// * @param context
|
||||
// * @param taskId
|
||||
// * @param callback
|
||||
// */
|
||||
// @JvmStatic
|
||||
// fun abortTask(context: Context, taskId: Long, callback: OchCommonServiceCallback<BaseData>?) {
|
||||
// mService.abortTask(
|
||||
// MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
// SharedPrefsMgr.getInstance().token,
|
||||
// BusCloseTaskRequest(taskId)
|
||||
// )
|
||||
// .transformTry()
|
||||
// .subscribe(OchCommonSubscribeImpl(context, callback, "abortTask"))
|
||||
// }
|
||||
|
||||
/**
|
||||
* 正常结束任务
|
||||
@@ -156,16 +154,6 @@ object OrderServiceManager {
|
||||
}
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun queryBusLines(context: Context, callback: OchCommonServiceCallback<BusQueryLinesResponse>?) {
|
||||
mService.queryBusLines(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
SharedPrefsMgr.getInstance().token,
|
||||
SharedPrefsMgr.getInstance().sn
|
||||
)
|
||||
.transformTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "queryBusLines"))
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun queryBusLines(): Observable<List<LineDataBean>?> {
|
||||
@@ -193,21 +181,4 @@ object OrderServiceManager {
|
||||
Observable.just(it.data)
|
||||
}
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun queryWriteOffCountByLineIdAndSiteId(
|
||||
context: Context,
|
||||
taskId: String?,
|
||||
siteId: String?,
|
||||
callback: OchCommonServiceCallback<WriteOffCountResponse>?
|
||||
) {
|
||||
mService.writeOffCount(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
SharedPrefsMgr.getInstance().token,
|
||||
taskId,
|
||||
siteId
|
||||
)
|
||||
.transformIoTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "writeOffCount"))
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mogo.och.weaknet.repository.net.impl.shuttlesaas;
|
||||
package com.mogo.och.weaknet.repository.net.shuttlesaas;
|
||||
|
||||
import com.mogo.eagle.core.data.BaseData;
|
||||
import com.mogo.och.weaknet.bean.request.BusQueryLineStationsRequest;
|
||||
@@ -22,7 +22,7 @@ import retrofit2.http.Query;
|
||||
* <p>
|
||||
* wiki: http://wiki.zhidaohulian.com/pages/viewpage.action?pageId=48970072
|
||||
*/
|
||||
public interface IBascApiService {
|
||||
public interface IShuttleSaasApiService {
|
||||
|
||||
/**
|
||||
* 查询当前运行任务
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mogo.och.weaknet.repository.net.impl.shuttlesaas
|
||||
package com.mogo.och.weaknet.repository.net.shuttlesaas
|
||||
|
||||
import android.content.Context
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig
|
||||
@@ -21,10 +21,10 @@ import io.reactivex.Observable
|
||||
* @author: wangmingjun
|
||||
* @date: 2021/10/20
|
||||
*/
|
||||
object OrderServiceManager {
|
||||
object ShuttleSaasServiceManager {
|
||||
|
||||
private val mService: IBascApiService = MoGoRetrofitFactory.getInstance(OchCommonConst.getShuttleUrl()).create(
|
||||
IBascApiService::class.java
|
||||
private val mService: IShuttleSaasApiService = MoGoRetrofitFactory.getInstance(OchCommonConst.getShuttleUrl()).create(
|
||||
IShuttleSaasApiService::class.java
|
||||
)
|
||||
|
||||
|
||||
@@ -54,11 +54,6 @@ class BusPresenter(view: ShuttleFragment?) : Presenter<ShuttleFragment?>(view),
|
||||
LoginStatusManager.removeListener(TAG)
|
||||
}
|
||||
|
||||
// 登出
|
||||
fun logout() {
|
||||
OrderModel.logout()
|
||||
}
|
||||
|
||||
override fun onAutopilotArriveAtStation(arrivedStation: ArrivedStation?) {
|
||||
e(SceneConstant.M_BUS + TAG, "行程日志-onAutopilotArriveAtStation arrive")
|
||||
OrderModel.onArriveAt(arrivedStation, "底盘触发进站")
|
||||
|
||||
@@ -130,10 +130,6 @@ class ShuttleFragment : MvpFragment<ShuttleFragment?, BusPresenter?>() {
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
fun changeOverview(eventLogout: EventLogout) {
|
||||
when (eventLogout.messgae) {
|
||||
EventLogout.LOGOUT_TYPE-> {
|
||||
d(SceneConstant.M_BUS + TAG, "changeOverview Event消息去登出")
|
||||
mPresenter!!.logout()
|
||||
}
|
||||
EventLogout.SHOW_QR_TYPE-> { //显示二维码
|
||||
d(
|
||||
SceneConstant.M_BUS + TAG, "changeOverview Event qrcode,sn = "
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
|
||||
<string name="bus_no_task_tip">暂无任务</string>
|
||||
<string name="shuttle_write_off_count">核销%1$d人</string>
|
||||
<string name="shuttle_write_off_count_default">本站核销成功:0人</string>
|
||||
<string name="shuttle_write_off_count_default">核销:0人</string>
|
||||
|
||||
<string name="bus_no_running_task">暂无待上传任务</string>
|
||||
<string name="bus_running_task_upload">一键上传</string>
|
||||
|
||||
Reference in New Issue
Block a user