[6.4.5]
[fea] [清理]
This commit is contained in:
@@ -44,6 +44,10 @@ public class BusRoutesResult {
|
||||
return lineId;
|
||||
}
|
||||
|
||||
public void setLineId(int lineId) {
|
||||
this.lineId = lineId;
|
||||
}
|
||||
|
||||
public int getTaskId() {
|
||||
return taskId;
|
||||
}
|
||||
@@ -52,6 +56,10 @@ public class BusRoutesResult {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public List<BusStationBean> getSites() {
|
||||
return sites;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.mogo.och.offline.bean
|
||||
|
||||
import com.mogo.eagle.core.data.BaseData
|
||||
import com.mogo.och.data.bean.BusRoutesResult
|
||||
import com.mogo.och.data.bean.BusStationBean
|
||||
import java.util.*
|
||||
|
||||
@@ -10,8 +11,8 @@ import java.util.*
|
||||
data class BindLineListResponse(val data: List<Result>?) : BaseData(){
|
||||
|
||||
data class Result(
|
||||
val line:LineInfo?,
|
||||
val siteList: List<BusStationBean>?,//站点名称
|
||||
var line: LineInfo?,
|
||||
var siteList: List<BusStationBean>?,//站点名称
|
||||
val contrail: Contrail?,//站点名称
|
||||
)
|
||||
|
||||
@@ -27,5 +28,20 @@ data class BindLineListResponse(val data: List<Result>?) : BaseData(){
|
||||
val txtFileMd5:String?,
|
||||
val contrailSaveTime:Long?,
|
||||
)
|
||||
companion object{
|
||||
@JvmStatic
|
||||
fun getCommonLineInfo(dataItem:Result):BusRoutesResult?{
|
||||
val result = BusRoutesResult()
|
||||
result.setSite(dataItem.siteList)
|
||||
result.csvFileUrl = dataItem.contrail?.csvFileUrl
|
||||
result.csvFileMd5 = dataItem.contrail?.csvFileMd5
|
||||
result.txtFileUrl = dataItem.contrail?.txtFileUrl
|
||||
result.txtFileMd5 = dataItem.contrail?.txtFileMd5
|
||||
result.contrailSaveTime = dataItem.contrail?.contrailSaveTime?:0
|
||||
result.name = dataItem.line?.lineName?:""
|
||||
result.lineId = dataItem.line?.lineId?.toInt()?:0
|
||||
return result
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,6 @@ import com.mogo.eagle.core.function.api.telematic.IReceivedMsgListener;
|
||||
import com.mogo.eagle.core.function.call.telematic.CallerTelematicListenerManager;
|
||||
import com.mogo.eagle.core.utilcode.util.CoordinateUtils;
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.eagle.core.data.BaseData;
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotControlParameters;
|
||||
import com.mogo.eagle.core.data.config.FunctionBuildConfig;
|
||||
import com.mogo.eagle.core.data.map.MogoLocation;
|
||||
@@ -28,10 +27,7 @@ import com.mogo.och.common.module.manager.socket.lan.LanSocketManager;
|
||||
import com.mogo.och.common.module.manager.socket.lan.bean.BusinessType;
|
||||
import com.mogo.och.common.module.voice.VoiceNotice;
|
||||
import com.mogo.och.offline.R;
|
||||
import com.mogo.och.offline.bean.BindLineListResponse;
|
||||
import com.mogo.och.offline.bean.BusRoutesResponse;
|
||||
import com.mogo.och.offline.callback.IBusADASStatusCallback;
|
||||
import com.mogo.och.offline.net.OrderServiceManager;
|
||||
import com.mogo.och.offline.util.ShuttleVoiceManager;
|
||||
import com.mogo.och.common.module.manager.socket.lan.bean.AppConnectMsg;
|
||||
import com.mogo.och.common.module.manager.socket.lan.bean.BaseDPMsg;
|
||||
@@ -64,7 +60,6 @@ import com.mogo.och.offline.util.BusAnalyticsManager;
|
||||
import com.mogo.och.offline.util.BusSendTripInfoManager;
|
||||
import com.mogo.och.offline.util.BusTrajectoryManager;
|
||||
import com.mogo.och.common.module.manager.socket.cloud.OCHSocketMessageManager;
|
||||
import com.mogo.och.common.module.network.OchCommonServiceCallback;
|
||||
import com.mogo.och.common.module.callback.OchAdasStartFailureCallback;
|
||||
import com.mogo.och.common.module.manager.socket.cloud.AbnormalFactorsLoopManager;
|
||||
import com.mogo.och.common.module.manager.autopilot.OCHAdasAbilityManager;
|
||||
@@ -142,8 +137,6 @@ public class OrderModel {
|
||||
OCHSocketMessageManager.msgMonitorType,
|
||||
mMogoOnMessageListener);
|
||||
|
||||
TicketModel.INSTANCE.load();
|
||||
|
||||
AbnormalFactorsLoopManager.INSTANCE.startLoopAbnormalFactors(mContext);
|
||||
|
||||
//监听乘客屏发来的消息
|
||||
@@ -348,15 +341,22 @@ public class OrderModel {
|
||||
if (!StringUtils.isEmpty(cacheData)) {
|
||||
BusTransferData data = GsonUtils.fromJson(cacheData, BusTransferData.class);
|
||||
getCacheRouteSuccess(data.getRoutesResult());
|
||||
}else {
|
||||
if (refreshBusStationsCallback != null) {
|
||||
refreshBusStationsCallback.updateEmptyUi();
|
||||
}
|
||||
clearAutopilotControlParameters();
|
||||
closeBeautificationMode();
|
||||
clearStartAutopilotTag();
|
||||
removeTipRunnables();
|
||||
CacheDataManager.Companion.getInstance().clearCacheData(mContext, BusCacheKey.BUS_LINE_CACHE);
|
||||
}
|
||||
}
|
||||
|
||||
private void getCacheRouteSuccess(BusRoutesResult data) {
|
||||
if (data == null || data.getSites() == null
|
||||
|| data.getSites().isEmpty()
|
||||
|| data.getWriteVersion() < DateTimeUtil.getTodayStartTime()) {
|
||||
|| data.getSites().isEmpty()) {
|
||||
//当为空时,显示无绑定路线图
|
||||
queryBusRoutes();
|
||||
CacheDataManager.Companion.getInstance().clearCacheData(mContext, BusCacheKey.BUS_LINE_CACHE);
|
||||
return;
|
||||
}
|
||||
@@ -368,54 +368,7 @@ public class OrderModel {
|
||||
* 查询小巴路线
|
||||
*/
|
||||
public void queryBusRoutes() {
|
||||
CallerLogger.d(M_BUS + TAG, "查询小巴路线");
|
||||
OrderServiceManager.queryBusRoutes(mContext, new OchCommonServiceCallback<BusRoutesResponse>() {
|
||||
@Override
|
||||
public void onSuccess(BusRoutesResponse data) {
|
||||
if (data == null
|
||||
|| data.getResult() == null
|
||||
|| data.getResult().getSites() == null
|
||||
|| data.getResult().getSites().isEmpty()) {
|
||||
// //当为空时,显示无绑定路线图
|
||||
CallerLogger.d(M_BUS + TAG, "获取到小巴路线数据:空 ");
|
||||
if (refreshBusStationsCallback != null) {
|
||||
refreshBusStationsCallback.updateEmptyUi();
|
||||
}
|
||||
clearAutopilotControlParameters();
|
||||
closeBeautificationMode();
|
||||
clearStartAutopilotTag();
|
||||
removeTipRunnables();
|
||||
CacheDataManager.Companion.getInstance().clearCacheData(mContext, BusCacheKey.BUS_LINE_CACHE);
|
||||
return;
|
||||
}
|
||||
|
||||
if (busRoutesResult == null || busRoutesResult.getWriteVersion() < data.getResult().getWriteVersion()) {
|
||||
CallerLogger.d(M_BUS + TAG, "更新小巴路线数据: " + data);
|
||||
updateBusStatus(data.getResult());
|
||||
pushCacheTransferData(data.getResult());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
if (!NetworkUtils.isConnected(mContext)) {
|
||||
ToastUtils.showShort(mContext.getString(R.string.network_error_tip));
|
||||
} else {
|
||||
ToastUtils.showShort(mContext.getString(R.string.request_error_tip));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFail(int code, String failMsg) {
|
||||
if (!NetworkUtils.isConnected(mContext)) {
|
||||
ToastUtils.showShort("网络异常,请稍后重试");
|
||||
} else {
|
||||
ToastUtils.showShort(failMsg);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
queryBusCacheRoutes();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -480,41 +433,13 @@ public class OrderModel {
|
||||
ToastUtils.showLong("数据异常、请稍后再试");
|
||||
return;
|
||||
}
|
||||
OrderServiceManager.abortTask(mContext, busRoutesResult.getTaskId()
|
||||
, new OchCommonServiceCallback<BaseData>() {
|
||||
@Override
|
||||
public void onSuccess(BaseData o) {
|
||||
CallerLogger.d(M_BUS + TAG, "abortTask success: " + o);
|
||||
if (o.code == 0) { // 重置成功
|
||||
endOrAbortTaskSuccess();
|
||||
clearBusStationDatas();
|
||||
queryBusRoutes();
|
||||
removeTipRunnables();
|
||||
// 取消自驾
|
||||
CallerAutoPilotControlManager.INSTANCE.cancelAutoPilot();
|
||||
setTrajectoryStation(null, null, -1L);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
if (!NetworkUtils.isConnected(mContext)) {
|
||||
ToastUtils.showShort(mContext.getString(R.string.network_error_tip));
|
||||
} else {
|
||||
ToastUtils.showShort(mContext.getString(R.string.request_error_tip));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFail(int code, String failMsg) {
|
||||
if (!NetworkUtils.isConnected(mContext)) {
|
||||
ToastUtils.showShort("网络异常,请稍后重试");
|
||||
} else {
|
||||
ToastUtils.showShort(failMsg);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
endOrAbortTaskSuccess();
|
||||
clearBusStationDatas();
|
||||
queryBusRoutes();
|
||||
removeTipRunnables();
|
||||
// 取消自驾
|
||||
CallerAutoPilotControlManager.INSTANCE.cancelAutoPilot();
|
||||
setTrajectoryStation(null, null, -1L);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -545,8 +470,7 @@ public class OrderModel {
|
||||
* 车机端展示是离开当前站,下一站设置为当前站, 所以服务端数据回来要做处理,不能直接渲染
|
||||
*/
|
||||
private void leaveStationSuccess(int leaveIndex, String leaveStation,
|
||||
String nextStation, String nextStationKr,
|
||||
long writeVersion) {
|
||||
String nextStation, String nextStationKr) {
|
||||
|
||||
onStartAutopilot(leaveIndex);
|
||||
|
||||
@@ -567,13 +491,11 @@ public class OrderModel {
|
||||
, isLastStop);
|
||||
}
|
||||
|
||||
reBuildCacheRouteData(leaveIndex, BusConst.STATION_STATUS_STOPPED, true, writeVersion);
|
||||
reBuildCacheRouteData(leaveIndex, BusConst.STATION_STATUS_STOPPED, true);
|
||||
}
|
||||
|
||||
private void reBuildCacheRouteData(int currentIndex, int currentDrivingStatus, boolean isLeaving
|
||||
, long writeVersion) {
|
||||
private void reBuildCacheRouteData(int currentIndex, int currentDrivingStatus, boolean isLeaving) {
|
||||
if (busRoutesResult != null) {
|
||||
busRoutesResult.setWriteVersion(writeVersion);
|
||||
List<BusStationBean> sites = busRoutesResult.getSites();
|
||||
BusStationBean bean = sites.get(currentIndex);
|
||||
bean.setDrivingStatus(currentDrivingStatus);
|
||||
@@ -702,9 +624,8 @@ public class OrderModel {
|
||||
isArrivedStation = true;
|
||||
isGoingToNextStation = false;
|
||||
|
||||
long writeVersion = DateTimeUtil.getCurrentTimeStamp();
|
||||
arriveStationSuccess(arrivedStationIndex, departureStopName,
|
||||
arriveStation, arriveStationKr, writeVersion);
|
||||
arriveStation, arriveStationKr);
|
||||
|
||||
String requestId = MultiRequestLimitChecker.Companion.generateRequestId(TAG + "-arriveSiteStation"
|
||||
, String.valueOf(stationList.get(arrivedStationIndex).getSiteId())
|
||||
@@ -713,32 +634,10 @@ public class OrderModel {
|
||||
CallerLogger.d(M_BUS + TAG, "arriveSiteStation-MultiRequestLimitChecker: 超过最大请求数,本次请求return");
|
||||
return;
|
||||
}
|
||||
OrderServiceManager.arriveSiteStation(mContext,
|
||||
stationList.get(arrivedStationIndex).getSeq(),
|
||||
stationList.get(arrivedStationIndex).getSiteId(),
|
||||
busRoutesResult.getTaskId(), writeVersion,
|
||||
new OchCommonServiceCallback<BaseData>() {
|
||||
@Override
|
||||
public void onSuccess(BaseData o) {
|
||||
CallerLogger.d(M_BUS + TAG, "行程日志-arriveSiteStation success");
|
||||
MultiRequestLimitChecker.Companion.getInstance().decreaseRequestCount(requestId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
MultiRequestLimitChecker.Companion.getInstance().decreaseRequestCount(requestId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFail(int code, String failMsg) {
|
||||
MultiRequestLimitChecker.Companion.getInstance().decreaseRequestCount(requestId);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void arriveStationSuccess(int arrivedStationIndex, String departureStopName,
|
||||
String arriveStation, String arriveStationKr,
|
||||
long writeVersion) {
|
||||
String arriveStation, String arriveStationKr) {
|
||||
if (busRoutesResult != null) {
|
||||
boolean isLastStop = false;
|
||||
if (arrivedStationIndex == busRoutesResult.getSites().size() - 1) {
|
||||
@@ -756,7 +655,7 @@ public class OrderModel {
|
||||
|
||||
sendArrivedStationToClient(arriveStation);
|
||||
|
||||
reBuildCacheRouteData(arrivedStationIndex, BusConst.STATION_STATUS_STOPPED, false, writeVersion);
|
||||
reBuildCacheRouteData(arrivedStationIndex, BusConst.STATION_STATUS_STOPPED, false);
|
||||
}
|
||||
|
||||
private void sendTaskDetailsToClients() {
|
||||
@@ -767,7 +666,7 @@ public class OrderModel {
|
||||
LanSocketManager.sendMsgToClient(msg);
|
||||
}
|
||||
|
||||
private void pushCacheTransferData(BusRoutesResult result) {
|
||||
public void pushCacheTransferData(BusRoutesResult result) {
|
||||
BusTransferData data = new BusTransferData(LoginStatusManager.isLogin() ? 1 : 0, result);
|
||||
CallerLogger.d(M_BUS + TAG, "pushCacheTransferData = " + GsonUtils.toJson(data));
|
||||
CacheDataManager.Companion.getInstance().putCacheData(mContext,
|
||||
@@ -827,9 +726,8 @@ public class OrderModel {
|
||||
isArrivedStation = false;
|
||||
CallerLogger.d(M_BUS + TAG, "行程日志-离站成功开往下一站====");
|
||||
|
||||
long writeVersion = DateTimeUtil.getCurrentTimeStamp();
|
||||
leaveStationSuccess(backgroundCurrentStationIndex, currentStationName,
|
||||
finalNextStationName, finalNextStationNameKr, writeVersion);
|
||||
finalNextStationName, finalNextStationNameKr);
|
||||
|
||||
BusStationBean busStationBean = stationList.get(backgroundCurrentStationIndex);
|
||||
MogoLocation currentStationPoint = new MogoLocation();
|
||||
@@ -841,26 +739,6 @@ public class OrderModel {
|
||||
"--currentStationName:" + currentStationName + "--finalNextStationName:" + finalNextStationName;
|
||||
OchChainLogManager.writeChainLog("滑动出发", changeInfo,
|
||||
true, OchChainLogManager.EVENT_KEY_INFE_WITH_BUS);
|
||||
OrderServiceManager.leaveStation(mContext,
|
||||
stationList.get(backgroundCurrentStationIndex).getSeq(),
|
||||
stationList.get(backgroundCurrentStationIndex).getSiteId(),
|
||||
busRoutesResult.getTaskId(), writeVersion,
|
||||
new OchCommonServiceCallback<BaseData>() {
|
||||
@Override
|
||||
public void onSuccess(BaseData o) {
|
||||
OchChainLogManager.writeChainLog("滑动出发成功", changeInfo,
|
||||
true, OchChainLogManager.EVENT_KEY_INFE_WITH_BUS);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFail(int code, String failMsg) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//车站10s后播报
|
||||
@@ -1093,39 +971,12 @@ public class OrderModel {
|
||||
*/
|
||||
private void endTask() {
|
||||
CallerLogger.d(M_BUS + TAG, "任务正常走完endTask()");
|
||||
OrderServiceManager.endTask(mContext, busRoutesResult.getTaskId()
|
||||
, new OchCommonServiceCallback<BaseData>() {
|
||||
@Override
|
||||
public void onSuccess(BaseData o) {
|
||||
CallerLogger.d(M_BUS + TAG, "endTask success: " + o);
|
||||
if (o.code == 0) {
|
||||
endOrAbortTaskSuccess();
|
||||
clearBusStationDatas();
|
||||
queryBusRoutes();// 重新获取任务
|
||||
removeTipRunnables();
|
||||
ShuttleVoiceManager.INSTANCE.endOrderBus();
|
||||
sendEndTaskToClient();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
if (!NetworkUtils.isConnected(mContext)) {
|
||||
ToastUtils.showShort(mContext.getString(R.string.network_error_tip));
|
||||
} else {
|
||||
ToastUtils.showShort(mContext.getString(R.string.request_error_tip));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFail(int code, String failMsg) {
|
||||
if (!NetworkUtils.isConnected(mContext)) {
|
||||
ToastUtils.showShort("网络异常,请稍后重试");
|
||||
} else {
|
||||
ToastUtils.showShort(failMsg);
|
||||
}
|
||||
}
|
||||
});
|
||||
endOrAbortTaskSuccess();
|
||||
clearBusStationDatas();
|
||||
queryBusRoutes();// 重新获取任务
|
||||
removeTipRunnables();
|
||||
ShuttleVoiceManager.INSTANCE.endOrderBus();
|
||||
sendEndTaskToClient();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,218 +0,0 @@
|
||||
package com.mogo.och.offline.model
|
||||
|
||||
import com.elegant.network.utils.GsonUtil
|
||||
import com.mogo.aicloud.services.socket.IMogoOnMessageListener
|
||||
import com.mogo.commons.AbsMogoApplication
|
||||
import com.mogo.eagle.core.data.enums.EventTypeEnumNew
|
||||
import com.mogo.eagle.core.data.msgbox.MsgBoxBean
|
||||
import com.mogo.eagle.core.data.msgbox.MsgBoxType
|
||||
import com.mogo.eagle.core.data.msgbox.V2XMsg
|
||||
import com.mogo.eagle.core.function.api.telematic.IReceivedMsgListener
|
||||
import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxManager.saveMsgBox
|
||||
import com.mogo.eagle.core.function.call.telematic.CallerTelematicListenerManager
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.i
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
|
||||
import com.mogo.eagle.core.utilcode.util.GsonUtils
|
||||
import com.mogo.och.offline.bean.WriteOffCountResponse
|
||||
import com.mogo.och.offline.bean.WriteOffPassenger
|
||||
import com.mogo.och.offline.net.OrderServiceManager
|
||||
import com.mogo.och.offline.util.ShuttleVoiceManager
|
||||
import com.mogo.och.common.module.manager.socket.lan.bean.BaseDPMsg
|
||||
import com.mogo.och.common.module.manager.socket.lan.bean.DPMsgType
|
||||
import com.mogo.och.common.module.manager.socket.lan.bean.WriteOffDevicesMsg
|
||||
import com.mogo.och.common.module.manager.socket.lan.bean.WriteOffMsg
|
||||
import com.mogo.och.common.module.manager.socket.cloud.OCHSocketMessageManager
|
||||
import com.mogo.och.common.module.constant.OchCommonConst
|
||||
import com.mogo.och.common.module.network.OchCommonServiceCallback
|
||||
import com.mogo.och.common.module.manager.loop.BizLoopManager
|
||||
import com.mogo.och.common.module.manager.loop.LoopInfo
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.ObservableEmitter
|
||||
import io.reactivex.ObservableOnSubscribe
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
|
||||
object TicketModel : IReceivedMsgListener, IMogoOnMessageListener<WriteOffPassenger> {
|
||||
|
||||
private val TAG = "TicketModel"
|
||||
|
||||
private val SELECTWRITEOFFCOUNT = "SELECTWRITEOFFCOUNT"
|
||||
|
||||
private var emitterMain: ObservableEmitter<Int>?=null
|
||||
|
||||
private val observable = Observable.create(ObservableOnSubscribe<Int> { emitter -> emitterMain = emitter })
|
||||
|
||||
init {
|
||||
|
||||
//监听乘客屏发来的消息
|
||||
CallerTelematicListenerManager.addListener(TAG, this)
|
||||
OCHSocketMessageManager.registerSocketMessageListener( //监听核销乘客
|
||||
OCHSocketMessageManager.msgWriteOffPassengerType,
|
||||
this
|
||||
)
|
||||
}
|
||||
|
||||
fun load(){
|
||||
BizLoopManager.setLoopFunction(
|
||||
SELECTWRITEOFFCOUNT, LoopInfo(3,
|
||||
TicketModel::selectWriteOffCount,scheduler = Schedulers.io()))
|
||||
}
|
||||
|
||||
// 收到局域网的核验信息
|
||||
override fun onReceivedMsg(type: Int, byteArray: ByteArray) {
|
||||
if (OchCommonConst.BUSINESS_STRING == type) {
|
||||
d(SceneConstant.M_BUS + TAG, "局域网核验"+String(byteArray))
|
||||
val msg = GsonUtils.fromJson(String(byteArray), BaseDPMsg::class.java)
|
||||
if (msg != null) {
|
||||
if (msg.type == DPMsgType.TYPE_WRITEOFF_INFO.type) {
|
||||
val writeOffMsg = GsonUtils.fromJson(String(byteArray), WriteOffMsg::class.java)
|
||||
receiveWrteOffInfo(writeOffMsg)
|
||||
} else if (msg.type == DPMsgType.TYPE_WRITEOFF_DEVICES_INFO.type) {
|
||||
val writeOffMsg = GsonUtils.fromJson(String(byteArray), WriteOffDevicesMsg::class.java)
|
||||
receiveWrteOffDevicesInfo(writeOffMsg)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun target(): Class<WriteOffPassenger> {
|
||||
return WriteOffPassenger::class.java
|
||||
}
|
||||
|
||||
// 收到服务器的核验信息
|
||||
override fun onMsgReceived(passenger: WriteOffPassenger?) {
|
||||
//进行播报
|
||||
i(SceneConstant.M_BUS + TAG, "后台socket 核验:passenger = " + GsonUtil.jsonFromObject(passenger))
|
||||
if(passenger==null||passenger.passengerSize==0){
|
||||
return
|
||||
}
|
||||
playPassenger(
|
||||
passenger.passengerSize,
|
||||
passenger.phone ?: "",
|
||||
passenger.ticketName?:"",
|
||||
passenger.orderNo?:""
|
||||
)
|
||||
selectWriteOffCount()
|
||||
}
|
||||
|
||||
private fun selectWriteOffCount(){
|
||||
val busRoutesResult = OrderModel.getInstance().busRoutesResult
|
||||
val busNextStation = OrderModel.getInstance().busNextStation
|
||||
if(busRoutesResult==null||busNextStation==null){
|
||||
emitterMain?.onNext(0)
|
||||
d(SceneConstant.M_BUS + TAG, "线路或者站点未空:${busRoutesResult}----${busNextStation}")
|
||||
return
|
||||
}
|
||||
OrderServiceManager.queryBusTaskByLineId(AbsMogoApplication.getApp(),
|
||||
"${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?) {
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fun getWriteOffCountObservable():Observable<Int>{
|
||||
return observable
|
||||
}
|
||||
|
||||
private fun receiveWrteOffInfo(writeOffMsg: WriteOffMsg?) {
|
||||
if(writeOffMsg!=null) {
|
||||
if (writeOffMsg.isScuccess != null) {
|
||||
if (writeOffMsg.isScuccess == true) { // 核验成功
|
||||
if(writeOffMsg.ticketSize==null||writeOffMsg.ticketSize==0){
|
||||
return
|
||||
}
|
||||
// playPassenger(
|
||||
// writeOffMsg.ticketSize?:0,
|
||||
// writeOffMsg.phone ?: "",
|
||||
// writeOffMsg.ticketName ?: "",
|
||||
// writeOffMsg.orderNo?:""
|
||||
// )
|
||||
} else { // 核验失败
|
||||
ShuttleVoiceManager.writeOffFaile("验票失败,${writeOffMsg.failedReason ?: ""}")
|
||||
saveMsgBox(
|
||||
MsgBoxBean(
|
||||
MsgBoxType.V2X, V2XMsg(
|
||||
EventTypeEnumNew.TYPE_ABNORMAL_VERIFICATION.poiType,
|
||||
writeOffMsg.failedReason ?: "",
|
||||
EventTypeEnumNew.TYPE_ABNORMAL_VERIFICATION.tts,
|
||||
""
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun receiveWrteOffDevicesInfo(writeOffMsg: WriteOffDevicesMsg) {
|
||||
if (writeOffMsg.isConnectScanner != null) {
|
||||
val reason = if (writeOffMsg.reason == null) "" else writeOffMsg.reason!!
|
||||
if (writeOffMsg.isConnectScanner==true) { // 链接成功
|
||||
saveMsgBox(
|
||||
MsgBoxBean(
|
||||
MsgBoxType.V2X,
|
||||
V2XMsg(
|
||||
EventTypeEnumNew.TYPE_DEVICE_STATUS_NORMAL.poiType,
|
||||
reason,
|
||||
EventTypeEnumNew.TYPE_DEVICE_STATUS_NORMAL.tts,
|
||||
""
|
||||
)
|
||||
)
|
||||
)
|
||||
} else { // 核验失败
|
||||
saveMsgBox(
|
||||
MsgBoxBean(
|
||||
MsgBoxType.V2X,
|
||||
V2XMsg(
|
||||
EventTypeEnumNew.TYPE_DEVICE_STATUS_ABNORMAL.poiType,
|
||||
reason,
|
||||
EventTypeEnumNew.TYPE_DEVICE_STATUS_ABNORMAL.tts,
|
||||
""
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun playPassenger(ticketSize: Int,phone:String,ticketName:String,orderNo:String) {
|
||||
|
||||
if (ticketSize > 1) { //多人播报 "x人" ---》x人核验通过
|
||||
OrderModel.getInstance().sendWriteOffNumToClient(ticketSize.toString() + "人核验通过")
|
||||
} else { //是 1 播放 "滴" 2022.11.09 改为: "核验通过"
|
||||
OrderModel.getInstance().sendWriteOffNumToClient("核验通过")
|
||||
}
|
||||
ShuttleVoiceManager.writeOffCount(ticketSize)
|
||||
|
||||
var tempPhone = phone
|
||||
if (tempPhone.length > 8) {
|
||||
//截取电话号码前三位
|
||||
val phoneNumPre = tempPhone.substring(0, 3)
|
||||
//截取电话号码后四位
|
||||
val phoneNumFix = tempPhone.substring(7)
|
||||
tempPhone = "$phoneNumPre****$phoneNumFix"
|
||||
}
|
||||
val content = "${ticketSize}张 $ticketName $tempPhone"
|
||||
saveMsgBox(MsgBoxBean(
|
||||
MsgBoxType.V2X,
|
||||
V2XMsg(
|
||||
EventTypeEnumNew.TYPE_VERIFICATION_SUCCESSFUL.poiType,
|
||||
content,
|
||||
EventTypeEnumNew.TYPE_VERIFICATION_SUCCESSFUL.tts,
|
||||
""
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -31,168 +31,6 @@ object OrderServiceManager {
|
||||
IBascApiService::class.java
|
||||
)
|
||||
|
||||
|
||||
/**
|
||||
* 查询小巴车当前任务
|
||||
* @param context
|
||||
* @param callback
|
||||
*/
|
||||
@JvmStatic
|
||||
fun queryBusRoutes(context: Context, callback: OchCommonServiceCallback<BusRoutesResponse>?) {
|
||||
//获取当前高德坐标
|
||||
mService.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: Int,
|
||||
callback: OchCommonServiceCallback<BusRoutesResponse>?
|
||||
) {
|
||||
mService.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: Int, 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 endTask(context: Context, taskId: Int, callback: OchCommonServiceCallback<BaseData>?) {
|
||||
mService.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,
|
||||
writeVersion: Long,
|
||||
callback: OchCommonServiceCallback<BaseData>?
|
||||
) {
|
||||
mService.leaveStation(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
SharedPrefsMgr.getInstance().token,
|
||||
BusUpdateSiteStatusRequest(taskId, siteId, seq,writeVersion)
|
||||
)
|
||||
.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, writeVersion: Long,
|
||||
callback: OchCommonServiceCallback<BaseData>?
|
||||
) {
|
||||
mService.arriveSiteStation(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
SharedPrefsMgr.getInstance().token,
|
||||
BusUpdateSiteStatusRequest(taskId, siteId, seq, writeVersion)
|
||||
)
|
||||
.transformTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "arriveSiteStation"))
|
||||
}
|
||||
|
||||
@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 queryBusTaskByLineId(
|
||||
context: Context,
|
||||
lineId: String?,
|
||||
callback: OchCommonServiceCallback<BusQueryLineTaskResponse>?
|
||||
) {
|
||||
mService.queryBusTaskByLineId(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
SharedPrefsMgr.getInstance().token,
|
||||
lineId
|
||||
)
|
||||
.transformTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "queryBusLines"))
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun queryBusTaskByLineId(
|
||||
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"))
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun queryBindLineListBySn(
|
||||
callback: OchCommonServiceCallback<BindLineListResponse>?
|
||||
|
||||
@@ -47,6 +47,7 @@ public class BusLinePresenter extends Presenter<BusSwitchLineView> implements IB
|
||||
|
||||
@Override
|
||||
public void onChangeLineIdSuccess(BindLineListResponse.Result checkLineInfo) {
|
||||
OrderModel.getInstance().pushCacheTransferData(BindLineListResponse.getCommonLineInfo(checkLineInfo));
|
||||
OrderModel.getInstance().clearBusStationDatas();
|
||||
UiThreadHandler.post(new Runnable() {
|
||||
@Override
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
package com.mogo.och.offline.ui.writeoff
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.util.Log
|
||||
import android.view.LayoutInflater
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.lifecycle.findViewTreeViewModelStoreOwner
|
||||
import com.mogo.och.offline.R
|
||||
import kotlinx.android.synthetic.main.shuttle_wirte_off_view.view.tv_write_off_count
|
||||
|
||||
class WriteOffView : ConstraintLayout, WriteOffViewModel.IwriteOffViewCallback {
|
||||
|
||||
private val TAG = "ItineraryView"
|
||||
|
||||
constructor(context: Context) : super(context)
|
||||
|
||||
constructor(context: Context, attributeSet: AttributeSet) : super(context, attributeSet)
|
||||
|
||||
constructor(context: Context, attributeSet: AttributeSet, defStyleAttr: Int) : super(context, attributeSet, defStyleAttr)
|
||||
|
||||
constructor(context: Context, attributeSet: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super(context, attributeSet, defStyleAttr, defStyleRes)
|
||||
|
||||
private fun initView() {
|
||||
LayoutInflater.from(context).inflate(R.layout.shuttle_wirte_off_view, this, true)
|
||||
}
|
||||
|
||||
|
||||
|
||||
override fun onAttachedToWindow() {
|
||||
super.onAttachedToWindow()
|
||||
|
||||
val viewModel = findViewTreeViewModelStoreOwner()?.let {
|
||||
ViewModelProvider(it).get(WriteOffViewModel::class.java)
|
||||
}
|
||||
|
||||
viewModel?.setWriteOffCallback(this)
|
||||
}
|
||||
|
||||
|
||||
init {
|
||||
try {
|
||||
initView()
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
override fun setWriteOffCount(showText: String) {
|
||||
tv_write_off_count.text = showText
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
package com.mogo.och.offline.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.offline.model.TicketModel
|
||||
import com.mogo.och.common.module.utils.RxUtils
|
||||
import com.mogo.och.offline.R
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.Observer
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.Disposable
|
||||
|
||||
class WriteOffViewModel : ViewModel() {
|
||||
|
||||
private val TAG = WriteOffViewModel::class.java.simpleName
|
||||
|
||||
private var viewCallback: IwriteOffViewCallback? = null
|
||||
|
||||
init {
|
||||
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(observer)
|
||||
}
|
||||
|
||||
override fun onCleared() {
|
||||
super.onCleared()
|
||||
this.viewCallback = null
|
||||
RxUtils.disposeSubscribe(disposable)
|
||||
}
|
||||
|
||||
interface IwriteOffViewCallback {
|
||||
fun setWriteOffCount(count:String)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -208,16 +208,6 @@
|
||||
app:layout_constraintTop_toBottomOf="@id/module_mogo_och_station_panel_container"
|
||||
tools:visibility="visible" />
|
||||
|
||||
|
||||
<com.mogo.och.offline.ui.writeoff.WriteOffView
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintBottom_toTopOf="@+id/module_mogo_och_arrived_tv"
|
||||
android:layout_marginStart="@dimen/dp_12"
|
||||
android:layout_marginBottom="@dimen/dp_5"
|
||||
android:background="@drawable/shuttle_write_off_bg"
|
||||
android:layout_width="@dimen/dp_618"
|
||||
android:layout_height="@dimen/dp_177"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/module_mogo_och_arrived_tv"
|
||||
android:layout_width="@dimen/dp_142"
|
||||
|
||||
Reference in New Issue
Block a user