[shuttle]
[核销人数]
This commit is contained in:
yangyakun
2024-01-24 11:16:17 +08:00
parent 86b24dd742
commit ca40240658
6 changed files with 74 additions and 15 deletions

View File

@@ -28,6 +28,9 @@ import com.mogo.och.common.module.biz.network.OchCommonServiceCallback
import com.mogo.och.common.module.manager.loopmanager.BizLoopManager
import com.mogo.och.common.module.manager.loopmanager.LoopInfo
import com.mogo.och.common.module.voice.VoiceNotice.showNotice
import io.reactivex.Observable
import io.reactivex.ObservableEmitter
import io.reactivex.ObservableOnSubscribe
import io.reactivex.schedulers.Schedulers
object TicketModel : IReceivedMsgListener, IMogoOnMessageListener<WriteOffPassenger> {
@@ -36,6 +39,10 @@ object TicketModel : IReceivedMsgListener, IMogoOnMessageListener<WriteOffPassen
private val SELECTWRITEOFFCOUNT = "SELECTWRITEOFFCOUNT"
private var emitterMain: ObservableEmitter<Int>?=null
private val observable = Observable.create(ObservableOnSubscribe<Int> { emitter -> emitterMain = emitter })
init {
//监听乘客屏发来的消息
@@ -91,11 +98,14 @@ object TicketModel : IReceivedMsgListener, IMogoOnMessageListener<WriteOffPassen
val busRoutesResult = OrderModel.getInstance().busRoutesResult?:return
val busNextStation = OrderModel.getInstance().busNextStation?:return
OrderServiceManager.queryBusTaskByLineId(AbsMogoApplication.getApp(),
"${busRoutesResult.lineId}",
"${busRoutesResult.taskId}",
"${busNextStation.siteId}",
object :OchCommonServiceCallback<WriteOffCountResponse>{
override fun onSuccess(data: WriteOffCountResponse?) {
data?.data?.let {
emitterMain?.onNext(it)
d(SceneConstant.M_BUS + TAG, "${busNextStation.name}核销人数:${it}")
}
}
override fun onFail(code: Int, msg: String?) {
@@ -104,6 +114,10 @@ object TicketModel : IReceivedMsgListener, IMogoOnMessageListener<WriteOffPassen
})
}
fun getWriteOffCountObservable():Observable<Int>{
return observable
}
private fun receiveWrteOffInfo(writeOffMsg: WriteOffMsg?) {
if(writeOffMsg!=null) {
if (writeOffMsg.isScuccess != null) {

View File

@@ -206,14 +206,14 @@ object OrderServiceManager {
@JvmStatic
fun queryBusTaskByLineId(
context: Context,
lineId: String?,
taskId: String?,
siteId: String?,
callback: OchCommonServiceCallback<WriteOffCountResponse>?
) {
mService.writeOffCount(
MoGoAiCloudClientConfig.getInstance().serviceAppId,
SharedPrefsMgr.getInstance().token,
lineId,
taskId,
siteId
)
.transformTry()

View File

@@ -7,6 +7,7 @@ import androidx.constraintlayout.widget.ConstraintLayout
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.findViewTreeViewModelStoreOwner
import com.mogo.och.bus.R
import kotlinx.android.synthetic.main.shuttle_wirte_off_view.view.tv_write_off_count
class WriteOffView : ConstraintLayout, WriteOffViewModel.IwriteOffViewCallback {
@@ -45,5 +46,9 @@ class WriteOffView : ConstraintLayout, WriteOffViewModel.IwriteOffViewCallback {
}
}
override fun setWriteOffCount(showText: String) {
tv_write_off_count.text = showText
}
}

View File

@@ -1,29 +1,68 @@
package com.mogo.och.bus.ui.writeoff
import androidx.lifecycle.ViewModel
import com.mogo.commons.AbsMogoApplication
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
import com.mogo.och.bus.R
import com.mogo.och.bus.model.TicketModel
import com.mogo.och.common.module.utils.RxUtils
import io.reactivex.Observable
import io.reactivex.Observer
import io.reactivex.disposables.Disposable
class WriteOffViewModel: ViewModel() {
class WriteOffViewModel : ViewModel() {
private val TAG = WriteOffViewModel::class.java.simpleName
private var viewCallback:IwriteOffViewCallback?=null
private var viewCallback: IwriteOffViewCallback? = null
init {
}
fun setWriteOffCallback(viewCallback:IwriteOffViewCallback){
this.viewCallback = viewCallback
}
private var disposable: Disposable? = null
private val observer = object : Observer<String> {
override fun onSubscribe(d: Disposable) {
disposable = d
}
override fun onError(e: Throwable) {
}
override fun onComplete() {
}
override fun onNext(countInfo: String) {
viewCallback?.setWriteOffCount(countInfo)
}
}
fun setWriteOffCallback(viewCallback: IwriteOffViewCallback) {
this.viewCallback = viewCallback
TicketModel
.getWriteOffCountObservable()
.flatMap { t ->
val showText =
AbsMogoApplication.getApp().getString(R.string.shuttle_write_off_count, t)
CallerLogger.d(SceneConstant.M_BUS + TAG, "显示文案:${showText}")
Observable.just(showText)
}
.subscribe(observer)
}
override fun onCleared() {
super.onCleared()
this.viewCallback = null
RxUtils.disposeSubscribe(disposable)
}
interface IwriteOffViewCallback{
interface IwriteOffViewCallback {
fun setWriteOffCount(count:String)
}
}

View File

@@ -8,7 +8,7 @@
android:id="@+id/no_line_data_view">
<TextView
android:id="@+id/no_order_data_tv"
android:id="@+id/tv_write_off_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/shuttle_driver_cad6ff"
@@ -17,5 +17,5 @@
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:text="@string/shuttle_write_off_count"/>
android:text="@string/shuttle_write_off_count_default"/>
</merge>

View File

@@ -39,7 +39,8 @@
<string name="bus_dialog_cancel">取消</string>
<string name="bus_no_task_tip">暂无任务</string>
<string name="shuttle_write_off_count">本站核销成功:%1$s</string>
<string name="shuttle_write_off_count">本站核销成功:%1$d</string>
<string name="shuttle_write_off_count_default">本站核销成功0人</string>
<!-- region tts -->