[2.13.0-arch-opt] move dispatch to biz and remove gradle settings
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
package com.mogo.eagle.function.biz.push
|
||||
|
||||
import android.content.Context
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.mogo.eagle.core.data.constants.MogoServicePaths
|
||||
import com.mogo.eagle.core.function.api.biz.IMoGoFuncBizProvider
|
||||
import com.mogo.eagle.core.function.api.biz.IMoGoNoticeNetCallBack
|
||||
import com.mogo.eagle.function.biz.push.dispatch.DispatchAutoPilotManager.Companion.dispatchAutoPilotManager
|
||||
import com.mogo.eagle.function.biz.push.notice.NoticeSocketManager.Companion.noticeSocketManager
|
||||
import com.mogo.eagle.function.biz.push.notice.network.NoticeNetWorkManager
|
||||
|
||||
@Route(path = MogoServicePaths.PATH_FUNC_BIZ)
|
||||
class FuncBizProvider : IMoGoFuncBizProvider {
|
||||
override val functionName: String
|
||||
get() = "FuncBiz"
|
||||
|
||||
override fun init(context: Context) {
|
||||
noticeSocketManager.init(context)
|
||||
dispatchAutoPilotManager.init(context)
|
||||
}
|
||||
|
||||
override fun feedBackNoticeTraffic(infoId: String, sn: String, accept: Int) {
|
||||
NoticeNetWorkManager.getInstance().sendAccidentAcceptStatus(infoId, sn, accept)
|
||||
}
|
||||
|
||||
override fun requestAccidentInfo(infoId: String, sn: String, callBack: IMoGoNoticeNetCallBack) {
|
||||
NoticeNetWorkManager.getInstance().requestAccidentInfo(infoId, sn, callBack)
|
||||
}
|
||||
|
||||
override fun dispatchAffirm() {
|
||||
dispatchAutoPilotManager.affirm()
|
||||
}
|
||||
|
||||
override fun dispatchCancel(manualTrigger: Boolean) {
|
||||
dispatchAutoPilotManager.cancel(manualTrigger)
|
||||
}
|
||||
|
||||
override fun testDispatch(sceneType: Int) {
|
||||
dispatchAutoPilotManager.testDispatch(sceneType)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
noticeSocketManager.release()
|
||||
dispatchAutoPilotManager.release()
|
||||
}
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
package com.mogo.eagle.function.biz.push;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.eagle.core.data.constants.MogoServicePaths;
|
||||
import com.mogo.eagle.core.function.api.notice.IMoGoNoticeProvider;
|
||||
import com.mogo.eagle.core.function.api.notice.NoticeNetCallBack;
|
||||
import com.mogo.eagle.function.biz.push.network.NoticeNetWorkManager;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
|
||||
/**
|
||||
* @author Jing
|
||||
* @description 云公告公告
|
||||
* @since: 10/27/21
|
||||
*/
|
||||
@Route(path = MogoServicePaths.PATH_AI_NOTICE)
|
||||
public class NoticeProvider implements IMoGoNoticeProvider {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getFunctionName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
NoticeSocketManager.getInstance().unRegisterSocketMessageListener();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Context context) {
|
||||
NoticeSocketManager.getInstance().registerSocketMessageListener(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void feedBackNoticeTraffic(String infoId, String sn, int accept) {
|
||||
NoticeNetWorkManager.getInstance().sendAccidentAcceptStatus(infoId, sn, accept);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void requestAccidentInfo(String infoId, String sn, NoticeNetCallBack callBack) {
|
||||
NoticeNetWorkManager.getInstance().requestAccidentInfo(infoId, sn, callBack);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,93 +0,0 @@
|
||||
package com.mogo.eagle.function.biz.push;
|
||||
|
||||
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_NOTICE;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.mogo.aicloud.services.socket.MogoAiCloudSocketManager;
|
||||
import com.mogo.eagle.core.data.msgbox.MsgBoxBean;
|
||||
import com.mogo.eagle.core.data.msgbox.MsgBoxType;
|
||||
import com.mogo.eagle.core.data.msgbox.NoticeFrCloudMsg;
|
||||
import com.mogo.eagle.core.data.notice.NoticeNormalData;
|
||||
import com.mogo.eagle.core.data.notice.NoticeTrafficStylePushData;
|
||||
import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxManager;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.eagle.core.network.utils.GsonUtil;
|
||||
import com.mogo.aicloud.services.socket.IMogoOnMessageListener;
|
||||
|
||||
/**
|
||||
* @author Jing
|
||||
* @description 云公告注册、反注册
|
||||
* @since: 10/27/21
|
||||
*/
|
||||
class NoticeSocketManager {
|
||||
private String TAG = "AINotice";
|
||||
private static NoticeSocketManager mNoticeSocketManager;
|
||||
private Context mContext;
|
||||
|
||||
public static synchronized NoticeSocketManager getInstance() {
|
||||
synchronized (NoticeSocketManager.class) {
|
||||
if (mNoticeSocketManager == null) {
|
||||
mNoticeSocketManager = new NoticeSocketManager();
|
||||
}
|
||||
}
|
||||
return mNoticeSocketManager;
|
||||
}
|
||||
|
||||
public void registerSocketMessageListener(Context context) {
|
||||
mContext = context;
|
||||
MogoAiCloudSocketManager.getInstance(context).
|
||||
registerOnMessageListener(301001, mTrafficNoticeListener);
|
||||
MogoAiCloudSocketManager.getInstance(context).
|
||||
registerOnMessageListener(100, mNormalNoticeListener);
|
||||
}
|
||||
|
||||
public void unRegisterSocketMessageListener() {
|
||||
MogoAiCloudSocketManager.getInstance(mContext).
|
||||
unregisterOnMessageListener(301001, mTrafficNoticeListener);
|
||||
MogoAiCloudSocketManager.getInstance(mContext).
|
||||
unregisterOnMessageListener(100, mNormalNoticeListener);
|
||||
}
|
||||
|
||||
/**
|
||||
* 普通云公告
|
||||
*/
|
||||
private final IMogoOnMessageListener<NoticeNormalData> mNormalNoticeListener = new IMogoOnMessageListener<NoticeNormalData>() {
|
||||
@Override
|
||||
public Class<NoticeNormalData> target() {
|
||||
return NoticeNormalData.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMsgReceived(NoticeNormalData obj) {
|
||||
if (obj == null) {
|
||||
return;
|
||||
}
|
||||
CallerLogger.INSTANCE.d(M_NOTICE + TAG, "100-- 普通公告数据:" + GsonUtil.jsonFromObject(obj));
|
||||
NoticeFrCloudMsg noticeFromCloudMsg = new NoticeFrCloudMsg(obj, null, 0);
|
||||
CallerMsgBoxManager.INSTANCE.saveMsgBox(new MsgBoxBean(MsgBoxType.NOTICE, noticeFromCloudMsg));
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 交警类型公告弹窗
|
||||
*/
|
||||
private final IMogoOnMessageListener<NoticeTrafficStylePushData> mTrafficNoticeListener = new IMogoOnMessageListener<NoticeTrafficStylePushData>() {
|
||||
|
||||
@Override
|
||||
public Class<NoticeTrafficStylePushData> target() {
|
||||
return NoticeTrafficStylePushData.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMsgReceived(NoticeTrafficStylePushData obj) {
|
||||
if (obj == null) {
|
||||
return;
|
||||
}
|
||||
CallerLogger.INSTANCE.d(M_NOTICE + TAG, "301001-- 交警类型公告数据:" + GsonUtil.jsonFromObject(obj));
|
||||
NoticeFrCloudMsg noticeFromCloudMsg = new NoticeFrCloudMsg(null, obj, 1);
|
||||
CallerMsgBoxManager.INSTANCE.saveMsgBox(new MsgBoxBean(MsgBoxType.NOTICE, noticeFromCloudMsg));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,289 @@
|
||||
package com.mogo.eagle.function.biz.push.dispatch
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.os.Handler
|
||||
import android.os.Message
|
||||
import com.mogo.aicloud.services.socket.IMogoOnMessageListener
|
||||
import com.mogo.aicloud.services.socket.MogoAiCloudSocketManager
|
||||
import com.mogo.cloud.commons.utils.CoordinateUtils
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotControlParameters
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotRouteInfo
|
||||
import com.mogo.eagle.core.data.dispatch.DispatchAdasAutoPilotLocReceiverBean
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotPlanningListener
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener
|
||||
import com.mogo.eagle.core.function.api.hmi.autopilot.IMoGoCheckAutoPilotBtnListener
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotManager
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager.getAutoPilotStatusInfo
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotPlanningListenerManager
|
||||
import com.mogo.eagle.core.function.call.hmi.CallerHmiListenerManager
|
||||
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
|
||||
import com.mogo.eagle.function.biz.push.dispatch.network.DispatchServiceModel.Companion.DISPATCH_RESULT_AFFIRM
|
||||
import com.mogo.eagle.function.biz.push.dispatch.network.DispatchServiceModel.Companion.DISPATCH_RESULT_MANUAL_CANCEL
|
||||
import com.mogo.eagle.function.biz.push.dispatch.network.DispatchServiceModel.Companion.DISPATCH_RESULT_TIMER_CANCEL
|
||||
import com.mogo.eagle.function.biz.push.dispatch.network.DispatchServiceModel.Companion.dispatchServiceModel
|
||||
import mogo.telematics.pad.MessagePad
|
||||
|
||||
|
||||
//负责监听自动驾驶状态并进行状态上报,自动驾驶路线上报,接收调度指令展示指令弹窗
|
||||
class DispatchAutoPilotManager private constructor() :
|
||||
IMogoOnMessageListener<DispatchAdasAutoPilotLocReceiverBean>, IMoGoCheckAutoPilotBtnListener,
|
||||
IMoGoAutopilotPlanningListener, IMoGoAutopilotStatusListener {
|
||||
|
||||
companion object {
|
||||
private const val TAG = "DispatchAutoPilotManager"
|
||||
|
||||
private const val MSG_SOCKET_TYPE = 501000
|
||||
private const val MSG_TYPE_SHOW_DIALOG = 0
|
||||
private const val MSG_TYPE_UPLOAD_AUTOPILOT_STATUS = 1
|
||||
|
||||
val dispatchAutoPilotManager by lazy(LazyThreadSafetyMode.SYNCHRONIZED) {
|
||||
DispatchAutoPilotManager()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private var mContext: Context? = null
|
||||
private var receiverBean: DispatchAdasAutoPilotLocReceiverBean? = null
|
||||
private var isDispatch = false
|
||||
private var isArriveEnd = false
|
||||
|
||||
private val handler: Handler = object : Handler() {
|
||||
override fun handleMessage(msg: Message) {
|
||||
super.handleMessage(msg)
|
||||
if (msg.what == MSG_TYPE_SHOW_DIALOG) {
|
||||
isDispatch = true
|
||||
isArriveEnd = false
|
||||
val msgData: DispatchAdasAutoPilotLocReceiverBean =
|
||||
msg.obj as DispatchAdasAutoPilotLocReceiverBean
|
||||
CallerHmiManager.showDispatchDialog(msgData)
|
||||
} else if (msg.what == MSG_TYPE_UPLOAD_AUTOPILOT_STATUS) {
|
||||
dispatchServiceModel.uploadAutopilotStatus(
|
||||
getAutoPilotStatusInfo().state,
|
||||
getAutoPilotStatusInfo().reason
|
||||
)
|
||||
sendEmptyMessageDelayed(MSG_TYPE_UPLOAD_AUTOPILOT_STATUS, 1000L)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun init(context: Context) {
|
||||
mContext = context
|
||||
MogoAiCloudSocketManager.getInstance(context)
|
||||
.registerOnMessageListener(MSG_SOCKET_TYPE, this)
|
||||
// 添加自动驾驶按钮选中监听
|
||||
CallerHmiListenerManager.addCheckAutoPilotBtnListener(TAG, this)
|
||||
// 添加 规划路径相关回调 监听
|
||||
CallerAutopilotPlanningListenerManager.addListener(TAG, this)
|
||||
// 添加 ADAS状态 监听
|
||||
CallerAutoPilotStatusListenerManager.addListener(TAG, this)
|
||||
handler.sendEmptyMessageDelayed(MSG_TYPE_UPLOAD_AUTOPILOT_STATUS, 1000L)
|
||||
}
|
||||
|
||||
fun release() {
|
||||
// 添加自动驾驶按钮选中监听
|
||||
CallerHmiListenerManager.removeCheckAutoPilotBtnListener(TAG)
|
||||
// 添加 规划路径相关回调 监听
|
||||
CallerAutopilotPlanningListenerManager.removeListener(TAG)
|
||||
// 添加 ADAS状态 监听
|
||||
CallerAutoPilotStatusListenerManager.removeListener(TAG)
|
||||
}
|
||||
|
||||
override fun target(): Class<DispatchAdasAutoPilotLocReceiverBean> {
|
||||
return DispatchAdasAutoPilotLocReceiverBean::class.java
|
||||
}
|
||||
|
||||
override fun onMsgReceived(adasAutoPilotLocReceiverBean: DispatchAdasAutoPilotLocReceiverBean?) {
|
||||
if (adasAutoPilotLocReceiverBean != null && adasAutoPilotLocReceiverBean.startLat != 0.0 && adasAutoPilotLocReceiverBean.startLon != 0.0) {
|
||||
receiverBean = adasAutoPilotLocReceiverBean
|
||||
val message = Message()
|
||||
message.what = MSG_TYPE_SHOW_DIALOG
|
||||
message.obj = adasAutoPilotLocReceiverBean
|
||||
handler.sendMessage(message)
|
||||
}
|
||||
}
|
||||
|
||||
private fun startAutoPilot() {
|
||||
val currentAutopilot = AutopilotControlParameters()
|
||||
currentAutopilot.isSpeakVoice = false
|
||||
val wayLatLon: MutableList<AutopilotControlParameters.AutoPilotLonLat> = ArrayList()
|
||||
receiverBean?.let {
|
||||
if (it.stopsList != null) {
|
||||
for (mogoLatLng in receiverBean!!.stopsList) {
|
||||
wayLatLon.add(
|
||||
AutopilotControlParameters.AutoPilotLonLat(
|
||||
mogoLatLng.lat,
|
||||
mogoLatLng.lon
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
currentAutopilot.wayLatLons = wayLatLon
|
||||
currentAutopilot.startLatLon =
|
||||
AutopilotControlParameters.AutoPilotLonLat(it.startLat, it.startLon)
|
||||
currentAutopilot.endLatLon =
|
||||
AutopilotControlParameters.AutoPilotLonLat(it.endLat, it.endLon)
|
||||
currentAutopilot.vehicleType = 10
|
||||
CallerLogger.d(SceneConstant.Companion.M_DISPATCH + TAG, "开启自动驾驶====$currentAutopilot")
|
||||
CallerAutoPilotManager.startAutoPilot(currentAutopilot)
|
||||
}
|
||||
}
|
||||
|
||||
fun affirm() {
|
||||
CallerHmiManager.dismissDispatchDialog()
|
||||
dispatchServiceModel.dispatchResultUpload(DISPATCH_RESULT_AFFIRM)
|
||||
}
|
||||
|
||||
fun cancel(manualTrigger: Boolean) {
|
||||
CallerHmiManager.dismissDispatchDialog()
|
||||
dispatchServiceModel.dispatchResultUpload(
|
||||
if (manualTrigger) DISPATCH_RESULT_MANUAL_CANCEL else DISPATCH_RESULT_TIMER_CANCEL
|
||||
)
|
||||
}
|
||||
|
||||
override fun onCheck(isChecked: Boolean) {
|
||||
if (isChecked) {
|
||||
// 确保到达终点后,再次点击,不会有回馈,并且在下次调开始时,才会重置
|
||||
if (isArriveEnd) {
|
||||
return
|
||||
}
|
||||
//todo 确认是否要根据停靠时自动驾驶状态,再次开启自动驾驶
|
||||
// 确保处于调度中并且返回的自动驾驶状态为1才开启自动驾驶
|
||||
// 上述等待鄂州项目复盘后,产品输出完成方案后再进操作!!!
|
||||
if (isDispatch) {
|
||||
startAutoPilot()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onAutopilotRotting(globalPathResp: MessagePad.GlobalPathResp?) {
|
||||
if (globalPathResp == null || globalPathResp.wayPointsList.isEmpty()) {
|
||||
return
|
||||
}
|
||||
val list: MutableList<AutopilotRouteInfo.RouteModels> = ArrayList()
|
||||
for (location in globalPathResp.wayPointsList) {
|
||||
val routeModels = AutopilotRouteInfo.RouteModels()
|
||||
routeModels.lat = location.latitude
|
||||
routeModels.lon = location.longitude
|
||||
list.add(routeModels)
|
||||
}
|
||||
dispatchServiceModel.uploadAutopilotRoute(list)
|
||||
}
|
||||
|
||||
override fun onAutopilotArriveAtStation(arrivalNotification: MessagePad.ArrivalNotification?) {
|
||||
if (!isDispatch) {
|
||||
return
|
||||
}
|
||||
if (arrivalNotification == null) {
|
||||
return
|
||||
}
|
||||
if (receiverBean == null) {
|
||||
return
|
||||
}
|
||||
|
||||
CallerLogger.d(
|
||||
SceneConstant.Companion.M_DISPATCH + TAG,
|
||||
"onArriveAt data : $arrivalNotification"
|
||||
)
|
||||
|
||||
if (arrivalNotification.endLocation == null) {
|
||||
return
|
||||
}
|
||||
val endLat: Double = arrivalNotification.endLocation.latitude
|
||||
val endLon: Double = arrivalNotification.endLocation.longitude
|
||||
// 计算是不是到了终点
|
||||
val distanceFromSelf: Float = CoordinateUtils.calculateLineDistance(
|
||||
receiverBean!!.endLon, receiverBean!!.endLat, endLon, endLat
|
||||
)
|
||||
CallerLogger.d(
|
||||
SceneConstant.Companion.M_DISPATCH + TAG,
|
||||
"onArriveAt cal distance : $distanceFromSelf"
|
||||
)
|
||||
if (distanceFromSelf < 10) {
|
||||
CallerLogger.d(SceneConstant.Companion.M_DISPATCH + TAG, "onArriveAt end location")
|
||||
isDispatch = false
|
||||
isArriveEnd = true
|
||||
}
|
||||
}
|
||||
|
||||
fun testDispatch(sceneType: Int) {
|
||||
when (sceneType) {
|
||||
0 -> testEZhouStart()
|
||||
1 -> testEZhouStop()
|
||||
2 -> testHengYangStart()
|
||||
3 -> testDispatchResultUpload()//验证自动驾驶调度上报接口
|
||||
}
|
||||
}
|
||||
|
||||
private fun testEZhouStart() {
|
||||
val adasAutoPilotLocReceiverBean = DispatchAdasAutoPilotLocReceiverBean(
|
||||
DispatchAdasAutoPilotLocReceiverBean.DISPATCH_SOURCE_EZHOU,
|
||||
DispatchAdasAutoPilotLocReceiverBean.DISPATCH_TYPE_START,
|
||||
"1",
|
||||
26.825571122,
|
||||
112.5762410415,
|
||||
"起点---5号跑道",
|
||||
26.825571122,
|
||||
112.5762410415,
|
||||
"终点---鄂州机场",
|
||||
"5分钟",
|
||||
"AR453航班",
|
||||
"你车需执行编号ca1098次航班的引导任务,从A区A1到B区B1",
|
||||
System.currentTimeMillis(),
|
||||
ArrayList<MogoLatLng>()
|
||||
)
|
||||
receiverBean = adasAutoPilotLocReceiverBean
|
||||
CallerHmiManager.showDispatchDialog(adasAutoPilotLocReceiverBean)
|
||||
}
|
||||
|
||||
private fun testEZhouStop() {
|
||||
val adasAutoPilotLocReceiverBean = DispatchAdasAutoPilotLocReceiverBean(
|
||||
DispatchAdasAutoPilotLocReceiverBean.DISPATCH_SOURCE_EZHOU,
|
||||
DispatchAdasAutoPilotLocReceiverBean.DISPATCH_TYPE_STOP,
|
||||
"1",
|
||||
0.0,
|
||||
0.0,
|
||||
"",
|
||||
0.0,
|
||||
0.0,
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
System.currentTimeMillis(),
|
||||
ArrayList<MogoLatLng>()
|
||||
)
|
||||
receiverBean = adasAutoPilotLocReceiverBean
|
||||
CallerHmiManager.showDispatchDialog(adasAutoPilotLocReceiverBean)
|
||||
}
|
||||
|
||||
private fun testHengYangStart() {
|
||||
val adasAutoPilotLocReceiverBean = DispatchAdasAutoPilotLocReceiverBean(
|
||||
DispatchAdasAutoPilotLocReceiverBean.DISPATCH_SOURCE_HENGYANG,
|
||||
DispatchAdasAutoPilotLocReceiverBean.DISPATCH_TYPE_START,
|
||||
"2",
|
||||
26.825571122,
|
||||
112.5762410415,
|
||||
"衡阳科学城",
|
||||
26.825571122,
|
||||
112.5762410415,
|
||||
"衡阳首钢集团",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
System.currentTimeMillis(),
|
||||
ArrayList<MogoLatLng>()
|
||||
)
|
||||
receiverBean = adasAutoPilotLocReceiverBean
|
||||
CallerHmiManager.showDispatchDialog(adasAutoPilotLocReceiverBean)
|
||||
}
|
||||
|
||||
private fun testDispatchResultUpload() {
|
||||
dispatchServiceModel.dispatchResultUpload(DISPATCH_RESULT_AFFIRM)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
package com.mogo.eagle.function.biz.push.dispatch.network
|
||||
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig
|
||||
import com.mogo.commons.constants.HostConst
|
||||
import com.mogo.commons.context.ContextHolderUtil
|
||||
import com.mogo.eagle.core.data.BaseData
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotRouteInfo.RouteModels
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotStatus
|
||||
import com.mogo.eagle.core.data.dispatch.ReportDispatchResult
|
||||
import com.mogo.eagle.core.data.dispatch.ReportedRoute
|
||||
import com.mogo.eagle.core.network.MoGoRetrofitFactory
|
||||
import com.mogo.eagle.core.network.RequestOptions
|
||||
import com.mogo.eagle.core.network.SubscribeImpl
|
||||
import com.mogo.eagle.core.network.utils.GsonUtil
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import java.util.*
|
||||
|
||||
class DispatchServiceModel private constructor() {
|
||||
|
||||
companion object {
|
||||
|
||||
const val DISPATCH_RESULT_AFFIRM = 0
|
||||
const val DISPATCH_RESULT_MANUAL_CANCEL = 1
|
||||
const val DISPATCH_RESULT_TIMER_CANCEL = 2
|
||||
|
||||
val dispatchServiceModel by lazy(LazyThreadSafetyMode.SYNCHRONIZED) {
|
||||
DispatchServiceModel()
|
||||
}
|
||||
}
|
||||
|
||||
private var mAdasApiService: IDispatchAdasApiService =
|
||||
MoGoRetrofitFactory.getInstance(HostConst.DATA_SERVICE_HOST).create(
|
||||
IDispatchAdasApiService::class.java
|
||||
)
|
||||
|
||||
/**
|
||||
* 上报自动驾驶状态
|
||||
*/
|
||||
fun uploadAutopilotStatus(state: Int, reason: String?) {
|
||||
val autopilotStatus = AutopilotStatus()
|
||||
autopilotStatus.action = "autopilotstate"
|
||||
val valuesBean = AutopilotStatus.ValuesBean()
|
||||
valuesBean.state = state
|
||||
valuesBean.reason = reason
|
||||
autopilotStatus.values = valuesBean
|
||||
val sn = MoGoAiCloudClientConfig.getInstance().sn
|
||||
val reportedRoute = ReportedRoute(sn, autopilotStatus.values)
|
||||
val map: MutableMap<String, Any> = HashMap()
|
||||
map["sn"] = sn
|
||||
map["data"] = GsonUtil.jsonFromObject(reportedRoute)
|
||||
mAdasApiService.uploadAutopilotState(map)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(object :
|
||||
SubscribeImpl<BaseData>(RequestOptions.create(ContextHolderUtil.getContext())) {
|
||||
override fun onNext(o: BaseData) {
|
||||
super.onNext(o)
|
||||
}
|
||||
|
||||
override fun onError(e: Throwable) {
|
||||
super.onError(e)
|
||||
}
|
||||
|
||||
override fun onSuccess(o: BaseData) {
|
||||
super.onSuccess(o)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 上报自动驾驶路线
|
||||
*
|
||||
* @param list 路线集合
|
||||
*/
|
||||
fun uploadAutopilotRoute(list: List<RouteModels?>?) {
|
||||
val sn = MoGoAiCloudClientConfig.getInstance().sn
|
||||
val reportedRoute = ReportedRoute(sn, GsonUtil.jsonFromObject(list))
|
||||
val map: MutableMap<String, Any> = HashMap()
|
||||
map["sn"] = sn
|
||||
map["data"] = GsonUtil.jsonFromObject(reportedRoute)
|
||||
mAdasApiService.uploadAutopilotRoute(map)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(object :
|
||||
SubscribeImpl<BaseData>(RequestOptions.create(ContextHolderUtil.getContext())) {
|
||||
override fun onNext(o: BaseData) {
|
||||
super.onNext(o)
|
||||
}
|
||||
|
||||
override fun onError(e: Throwable) {
|
||||
super.onError(e)
|
||||
}
|
||||
|
||||
override fun onSuccess(o: BaseData) {
|
||||
super.onSuccess(o)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 上报调度处理结果
|
||||
*
|
||||
* @param dispatchResultType int
|
||||
*/
|
||||
fun dispatchResultUpload(
|
||||
dispatchResultType: Int,
|
||||
onSuccess: ((BaseData) -> Unit)? = null,
|
||||
onError: ((String) -> Unit)? = null
|
||||
) {
|
||||
val sn = MoGoAiCloudClientConfig.getInstance().sn
|
||||
val reportDispatchResult = ReportDispatchResult(sn, dispatchResultType)
|
||||
val map: MutableMap<String, Any> = HashMap()
|
||||
map["sn"] = sn
|
||||
map["data"] = GsonUtil.jsonFromObject(reportDispatchResult)
|
||||
mAdasApiService.uploadDispatchResult(map)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(object :
|
||||
SubscribeImpl<BaseData>(RequestOptions.create(ContextHolderUtil.getContext())) {
|
||||
override fun onNext(o: BaseData) {
|
||||
super.onNext(o)
|
||||
onSuccess?.invoke(o)
|
||||
}
|
||||
|
||||
override fun onError(e: Throwable) {
|
||||
super.onError(e)
|
||||
if (!e.message.isNullOrBlank()) {
|
||||
onError?.invoke(e.message!!)
|
||||
} else {
|
||||
onError?.invoke("上报失败")
|
||||
}
|
||||
}
|
||||
|
||||
override fun onSuccess(o: BaseData) {
|
||||
super.onSuccess(o)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.mogo.eagle.function.biz.push.dispatch.network
|
||||
|
||||
import com.mogo.eagle.core.data.BaseData
|
||||
import io.reactivex.Observable
|
||||
import retrofit2.http.FieldMap
|
||||
import retrofit2.http.FormUrlEncoded
|
||||
import retrofit2.http.POST
|
||||
|
||||
interface IDispatchAdasApiService {
|
||||
/**
|
||||
* 上报自动驾驶路径 服务于业务调度
|
||||
*
|
||||
* @param parameters map
|
||||
* @return [BaseData]
|
||||
*/
|
||||
@FormUrlEncoded
|
||||
@POST("/dataService/autoDriver/receiveCarPreSetPath")
|
||||
fun uploadAutopilotRoute(@FieldMap parameters: Map<String, Any>): Observable<BaseData>
|
||||
|
||||
/**
|
||||
* 上报自动驾驶调度处理结果 服务于业务调度
|
||||
*
|
||||
* @param parameters map
|
||||
* @return [BaseData]
|
||||
*/
|
||||
@FormUrlEncoded
|
||||
@POST("/dataService/autoDriver/receiverDestSiteResult")
|
||||
fun uploadDispatchResult(@FieldMap parameters: Map<String, Any>): Observable<BaseData>
|
||||
|
||||
/**
|
||||
* 上报自动驾驶状态 服务于业务调度
|
||||
*
|
||||
* @param parameters map
|
||||
* @return [BaseData]
|
||||
*/
|
||||
@FormUrlEncoded
|
||||
@POST("/dataService/autoDriver/receiveAutopilotState")
|
||||
fun uploadAutopilotState(@FieldMap parameters: Map<String, Any>): Observable<BaseData>
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
package com.mogo.eagle.function.biz.push.network;
|
||||
|
||||
/**
|
||||
* @author Jing
|
||||
* @description 描述
|
||||
* @since: 11/15/21
|
||||
*/
|
||||
public class NoticeRequest {
|
||||
private String infoId;
|
||||
|
||||
public NoticeRequest(String infoId) {
|
||||
this.infoId = infoId;
|
||||
}
|
||||
|
||||
public String getInfoId() {
|
||||
return infoId;
|
||||
}
|
||||
|
||||
public void setInfoId(String infoId) {
|
||||
this.infoId = infoId;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
package com.mogo.eagle.function.biz.push.notice
|
||||
|
||||
import android.content.Context
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d
|
||||
import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxManager.saveMsgBox
|
||||
import com.mogo.aicloud.services.socket.MogoAiCloudSocketManager
|
||||
import com.mogo.aicloud.services.socket.IMogoOnMessageListener
|
||||
import com.mogo.eagle.core.data.notice.NoticeNormalData
|
||||
import java.lang.Class
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
|
||||
import com.mogo.eagle.core.data.msgbox.NoticeFrCloudMsg
|
||||
import com.mogo.eagle.core.data.msgbox.MsgBoxBean
|
||||
import com.mogo.eagle.core.data.msgbox.MsgBoxType
|
||||
import com.mogo.eagle.core.data.notice.NoticeTrafficStylePushData
|
||||
import com.mogo.eagle.core.network.utils.GsonUtil
|
||||
|
||||
/**
|
||||
* @author Jing
|
||||
* @description 云公告注册、反注册
|
||||
* @since: 10/27/21
|
||||
*/
|
||||
internal class NoticeSocketManager {
|
||||
|
||||
private var mContext: Context? = null
|
||||
|
||||
companion object {
|
||||
private const val TAG = "NoticeSocketManager"
|
||||
|
||||
val noticeSocketManager:NoticeSocketManager by lazy(LazyThreadSafetyMode.SYNCHRONIZED){
|
||||
NoticeSocketManager()
|
||||
}
|
||||
}
|
||||
|
||||
fun init(context: Context) {
|
||||
mContext = context
|
||||
MogoAiCloudSocketManager.getInstance(context)
|
||||
.registerOnMessageListener(301001, mTrafficNoticeListener)
|
||||
MogoAiCloudSocketManager.getInstance(context)
|
||||
.registerOnMessageListener(100, mNormalNoticeListener)
|
||||
}
|
||||
|
||||
fun release() {
|
||||
MogoAiCloudSocketManager.getInstance(mContext)
|
||||
.unregisterOnMessageListener(301001, mTrafficNoticeListener)
|
||||
MogoAiCloudSocketManager.getInstance(mContext)
|
||||
.unregisterOnMessageListener(100, mNormalNoticeListener)
|
||||
}
|
||||
|
||||
/**
|
||||
* 普通云公告
|
||||
*/
|
||||
private val mNormalNoticeListener: IMogoOnMessageListener<NoticeNormalData> =
|
||||
object : IMogoOnMessageListener<NoticeNormalData> {
|
||||
override fun target(): Class<NoticeNormalData> {
|
||||
return NoticeNormalData::class.java
|
||||
}
|
||||
|
||||
override fun onMsgReceived(obj: NoticeNormalData?) {
|
||||
if (obj == null) {
|
||||
return
|
||||
}
|
||||
d(SceneConstant.M_NOTICE + TAG, "100-- 普通公告数据:" + GsonUtil.jsonFromObject(obj))
|
||||
val noticeFromCloudMsg = NoticeFrCloudMsg(obj, null, 0)
|
||||
saveMsgBox(MsgBoxBean(MsgBoxType.NOTICE, noticeFromCloudMsg))
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 交警类型公告弹窗
|
||||
*/
|
||||
private val mTrafficNoticeListener: IMogoOnMessageListener<NoticeTrafficStylePushData> =
|
||||
object : IMogoOnMessageListener<NoticeTrafficStylePushData> {
|
||||
override fun target(): Class<NoticeTrafficStylePushData> {
|
||||
return NoticeTrafficStylePushData::class.java
|
||||
}
|
||||
|
||||
override fun onMsgReceived(obj: NoticeTrafficStylePushData?) {
|
||||
if (obj == null) {
|
||||
return
|
||||
}
|
||||
d(SceneConstant.M_NOTICE + TAG, "301001-- 交警类型公告数据:" + GsonUtil.jsonFromObject(obj))
|
||||
val noticeFromCloudMsg = NoticeFrCloudMsg(null, obj, 1)
|
||||
saveMsgBox(MsgBoxBean(MsgBoxType.NOTICE, noticeFromCloudMsg))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mogo.eagle.function.biz.push.network;
|
||||
package com.mogo.eagle.function.biz.push.notice.network;
|
||||
|
||||
import com.mogo.eagle.core.data.BaseData;
|
||||
import com.mogo.eagle.core.data.notice.NoticeNormalDetail;
|
||||
@@ -19,7 +19,7 @@ import retrofit2.http.QueryMap;
|
||||
* @description 云公告相关的短链请求接口定义
|
||||
* @since: 10/28/21
|
||||
*/
|
||||
public interface NoticeApiService {
|
||||
public interface INoticeApiService {
|
||||
/**
|
||||
* 获取道路事故详情
|
||||
*
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mogo.eagle.function.biz.push.network;
|
||||
package com.mogo.eagle.function.biz.push.notice.network;
|
||||
|
||||
import android.util.ArrayMap;
|
||||
|
||||
@@ -7,9 +7,10 @@ import com.mogo.cloud.network.RetrofitFactory;
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClient;
|
||||
import com.mogo.eagle.core.data.BaseData;
|
||||
import com.mogo.eagle.core.data.notice.NoticeNormalDetail;
|
||||
import com.mogo.eagle.core.data.notice.NoticeRequest;
|
||||
import com.mogo.eagle.core.data.notice.NoticeTrafficStyleInfo;
|
||||
|
||||
import com.mogo.eagle.core.function.api.notice.NoticeNetCallBack;
|
||||
import com.mogo.eagle.core.function.api.biz.IMoGoNoticeNetCallBack;
|
||||
import com.mogo.eagle.core.network.utils.GsonUtil;
|
||||
|
||||
import java.util.HashMap;
|
||||
@@ -30,11 +31,11 @@ import okhttp3.RequestBody;
|
||||
*/
|
||||
public class NoticeNetWorkManager {
|
||||
private static volatile NoticeNetWorkManager requestNoticeManager;
|
||||
private final NoticeApiService mNoticeApiService;
|
||||
private final INoticeApiService mNoticeApiService;
|
||||
|
||||
private NoticeNetWorkManager() {
|
||||
mNoticeApiService = RetrofitFactory.INSTANCE.getInstance(NetConstants.DEVA_HOST)
|
||||
.create(NoticeApiService.class);
|
||||
.create(INoticeApiService.class);
|
||||
}
|
||||
|
||||
public static NoticeNetWorkManager getInstance() {
|
||||
@@ -54,8 +55,7 @@ public class NoticeNetWorkManager {
|
||||
* @param infoId 事故id
|
||||
* @param callBack 回调
|
||||
*/
|
||||
public void requestAccidentInfo(String infoId, String sn,NoticeNetCallBack callBack) {
|
||||
|
||||
public void requestAccidentInfo(String infoId, String sn, IMoGoNoticeNetCallBack callBack) {
|
||||
NoticeRequest request = new NoticeRequest(infoId);
|
||||
RequestBody requestBody = RequestBody.create(MediaType.get("application/json;charset=UTF-8"),
|
||||
GsonUtil.jsonFromObject(request));
|
||||
Reference in New Issue
Block a user