Merge remote-tracking branch 'origin/dev_robobus-m1-p-app-module_1.1.0_230112_1.1.0' into dev_robobus-m1-p-app-module_1.1.0_230112_1.1.0
This commit is contained in:
@@ -18,6 +18,7 @@ data class SiteInfoResponse(val data: List<SiteInfo>?) : BaseData(){
|
||||
val GcjLat: Double?,//高德坐标
|
||||
val seq: Double?,
|
||||
val type: Int?,
|
||||
var isNear:Boolean=false
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,9 @@ import com.mogo.eagle.core.function.call.autopilot.CallerPlanningRottingListener
|
||||
import com.mogo.eagle.core.network.utils.GsonUtil
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_BUS_P
|
||||
import com.mogo.eagle.core.utilcode.util.CoordinateUtils
|
||||
import com.mogo.eagle.core.utilcode.util.NetworkUtils
|
||||
import com.mogo.eagle.core.utilcode.util.ToastUtils
|
||||
import com.mogo.och.bus.passenger.bean.LoopInfo
|
||||
import com.mogo.och.bus.passenger.bean.response.*
|
||||
import com.mogo.och.bus.passenger.callback.IBusPassengerADASStatusCallback
|
||||
@@ -30,6 +32,7 @@ import com.mogo.och.common.module.biz.network.OchCommonServiceCallback
|
||||
import mogo.telematics.pad.MessagePad
|
||||
import mogo_msg.MogoReportMsg
|
||||
import system_master.SystemStatusInfo
|
||||
import java.util.*
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
/**
|
||||
@@ -187,7 +190,6 @@ object CharterPassengerModel {
|
||||
"onAutopilotRotting = ${GsonUtil.jsonFromObject(globalPathResp)}"
|
||||
)
|
||||
globalPathResp?.wayPointsList?.let {
|
||||
// todo 启动路距计算
|
||||
startCalculateDistanceLoop()
|
||||
}
|
||||
}
|
||||
@@ -257,7 +259,9 @@ object CharterPassengerModel {
|
||||
ordrLagic(data?.data)
|
||||
}
|
||||
|
||||
override fun onFail(code: Int, msg: String) {}
|
||||
override fun onFail(code: Int, msg: String) {
|
||||
ToastUtils.showShort("$code:$msg")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -339,7 +343,9 @@ object CharterPassengerModel {
|
||||
carStatusLogic(data.data)
|
||||
}
|
||||
|
||||
override fun onFail(code: Int, msg: String) {}
|
||||
override fun onFail(code: Int, msg: String) {
|
||||
ToastUtils.showShort("$code:$msg")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -355,7 +361,6 @@ object CharterPassengerModel {
|
||||
orderInfo = null
|
||||
locusInfo = null
|
||||
if (data.businessStatus == 2) {// 订单结束 没有还车
|
||||
// todo 还车中 需要显示 @com.mogo.och.bus.passenger.ui.view.EndOrderView 页面
|
||||
setOrderStatus(OrderStatusEnum.NoOrderUse)
|
||||
} else {
|
||||
// 车辆空闲 订单结束已经还车
|
||||
@@ -395,7 +400,9 @@ object CharterPassengerModel {
|
||||
// todo 轮训时间校准
|
||||
}
|
||||
|
||||
override fun onFail(code: Int, msg: String) {}
|
||||
override fun onFail(code: Int, msg: String) {
|
||||
ToastUtils.showShort("$code:$msg")
|
||||
}
|
||||
})
|
||||
}
|
||||
// endregion
|
||||
@@ -410,7 +417,9 @@ object CharterPassengerModel {
|
||||
locusInfo = data.data
|
||||
}
|
||||
|
||||
override fun onFail(code: Int, msg: String) {}
|
||||
override fun onFail(code: Int, msg: String) {
|
||||
ToastUtils.showShort("$code:$msg")
|
||||
}
|
||||
})
|
||||
}
|
||||
// endregion
|
||||
@@ -434,7 +443,7 @@ object CharterPassengerModel {
|
||||
* 查询车辆状态 判断订单是否结束、是否显示结束业务
|
||||
*/
|
||||
private fun calculateDistance() {
|
||||
|
||||
// TODO: 启动轨迹计算
|
||||
}
|
||||
// endregion
|
||||
|
||||
@@ -446,4 +455,42 @@ object CharterPassengerModel {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算需要禁用的站点
|
||||
*/
|
||||
fun calculateCurrentSite(data: List<SiteInfoResponse.SiteInfo>): Pair<Int,Boolean> {
|
||||
var distanceMap:MutableMap<Float, Int> = TreeMap()
|
||||
// 计算所有点的距离
|
||||
data.forEachIndexed { index, siteInfo ->
|
||||
mLocation?.let { currentInfo ->
|
||||
// 两点之间的距离
|
||||
val calculateLineDistance = CoordinateUtils.calculateLineDistance(
|
||||
currentInfo.longitude,
|
||||
currentInfo.latitude,
|
||||
siteInfo.GcjLon!!,
|
||||
siteInfo.GcjLat!!
|
||||
)
|
||||
if (calculateLineDistance < 30) {
|
||||
return if (index + 1 <= data.size - 1) {
|
||||
Pair(index+1,true)
|
||||
} else {
|
||||
Pair(index,true)// 距离最后一个站点小于30m
|
||||
}
|
||||
}
|
||||
distanceMap.put(calculateLineDistance,index)
|
||||
}
|
||||
}
|
||||
var first = -1
|
||||
if(distanceMap.size>=2){
|
||||
for (mutableEntry in distanceMap) {
|
||||
if(first>0){
|
||||
return Pair(Math.max(first,mutableEntry.value),false)
|
||||
}
|
||||
first = mutableEntry.value
|
||||
}
|
||||
}
|
||||
|
||||
return Pair(0,false)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -27,16 +27,11 @@ class BusPassengerFunctionDevicePresenter(view: M1DeviceFragment?) :
|
||||
override fun onCreate(owner: LifecycleOwner) {
|
||||
super.onCreate(owner)
|
||||
OCHM1LightAirconditionDoorStatusManager.addListener(TAG, this)
|
||||
CharterPassengerModel.setControllerStatusCallback(TAG,object :
|
||||
IBusPassengerControllerStatusCallback{
|
||||
|
||||
override fun onCarLocationChanged(location: MogoLocation?) {
|
||||
location?.let {
|
||||
gnssSpeed = it.gnssInfo.vehicleSpeed
|
||||
}
|
||||
CharterPassengerModel.setControllerStatusCallback(TAG) { location ->
|
||||
location?.let {
|
||||
gnssSpeed = it.gnssInfo.vehicleSpeed
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDestroy(owner: LifecycleOwner) {
|
||||
|
||||
@@ -64,7 +64,11 @@ class OrderSiteItemAdapter(private val context: Context, private val dataList: M
|
||||
notifyItemChanged(checkIndex)
|
||||
checkChangeListener?.onCheckListener(siteInfo)
|
||||
}else{
|
||||
ToastUtils.showShort("请选择可选站点")
|
||||
if(siteInfo.isNear){
|
||||
ToastUtils.showShort("您已在此站点附近")
|
||||
}else{
|
||||
ToastUtils.showShort("请选择返程路线")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,12 +15,16 @@ import com.mogo.eagle.core.function.call.telematic.CallerTelematicManager
|
||||
import com.mogo.eagle.core.utilcode.kotlin.onClick
|
||||
import com.mogo.eagle.core.utilcode.util.GsonUtils
|
||||
import com.mogo.eagle.core.utilcode.util.ToastUtils
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
|
||||
import com.mogo.och.bus.passenger.R
|
||||
import com.mogo.och.bus.passenger.bean.LoopInfo
|
||||
import com.mogo.och.bus.passenger.bean.response.LineInfoListResponse
|
||||
import com.mogo.och.bus.passenger.bean.response.LineInfoResponse
|
||||
import com.mogo.och.bus.passenger.bean.response.SiteInfoResponse
|
||||
import com.mogo.och.bus.passenger.model.CharterPassengerModel
|
||||
import com.mogo.och.bus.passenger.net.BusPassengerModelLoopManager
|
||||
import com.mogo.och.bus.passenger.net.BusPassengerServiceManager
|
||||
import com.mogo.och.bus.passenger.presenter.BusPassengerFunctionDevicePresenter
|
||||
import com.mogo.och.bus.passenger.ui.adapter.OrderLineItemAdapter
|
||||
import com.mogo.och.bus.passenger.ui.adapter.OrderSiteItemAdapter
|
||||
import com.mogo.och.bus.passenger.view.BottomDecoration
|
||||
@@ -38,6 +42,8 @@ class LineSiteView @JvmOverloads constructor(
|
||||
|
||||
companion object{
|
||||
const val TAG = "LineSiteView"
|
||||
const val TAGLINELOOP = "LineSiteViewLineLoop"
|
||||
const val TAGSITELOOP = "LineSiteViewSiteLoop"
|
||||
}
|
||||
|
||||
private var checkLine: LineInfoResponse.LineInfo?=null
|
||||
@@ -54,6 +60,8 @@ class LineSiteView @JvmOverloads constructor(
|
||||
private var lineAdapter: OrderLineItemAdapter
|
||||
private var siteAdapter: OrderSiteItemAdapter
|
||||
|
||||
private var gnssSpeed =0.0
|
||||
|
||||
private val loadingAni = ObjectAnimator.ofFloat(iv_loading_wait_driver, "rotation", 0f, 90f ,180f, 270f, 360f).apply {
|
||||
repeatCount = -1
|
||||
interpolator = LinearInterpolator()
|
||||
@@ -86,21 +94,34 @@ class LineSiteView @JvmOverloads constructor(
|
||||
checkLine?.let {
|
||||
querySitesByLineId(it.lineId.toString())
|
||||
}
|
||||
setViewOrdeWithLine(true)
|
||||
}else{
|
||||
queryLineList()
|
||||
setViewOrdeWithLine(false)
|
||||
}
|
||||
|
||||
initListener()
|
||||
|
||||
}
|
||||
|
||||
private fun setViewOrdeWithLine(enable:Boolean) {
|
||||
tv_switch_line.isEnabled = enable
|
||||
if(enable) {
|
||||
gl_line_cancle_submit_guide.visibility = View.GONE
|
||||
g_side_cancle_submit_group.visibility = View.GONE
|
||||
}else{
|
||||
gl_line_cancle_submit_guide.visibility = View.VISIBLE
|
||||
g_side_cancle_submit_group.visibility = GONE
|
||||
}
|
||||
}
|
||||
|
||||
private fun initListener() {
|
||||
lineAdapter.checkChangeListener = object :OrderLineItemAdapter.CheckListener{
|
||||
override fun onCheckListener(lineInfo: LineInfoResponse.LineInfo) {
|
||||
ToastUtils.showLong("选中线路${lineInfo} 对比当前坐标计算需要禁用的站点")
|
||||
tempCheckLine = lineInfo
|
||||
querySitesByLineId(lineInfo.lineId.toString())
|
||||
siteAdapter.clearCheck()
|
||||
siteAdapter.setEnableIndex(3)
|
||||
}
|
||||
}
|
||||
siteAdapter.checkChangeListener = object :OrderSiteItemAdapter.CheckListener{
|
||||
@@ -118,6 +139,10 @@ class LineSiteView @JvmOverloads constructor(
|
||||
ToastUtils.showLong("请选择线路")
|
||||
return@onClick
|
||||
}
|
||||
if(!CallerTelematicManager.getClientConnStatus()){
|
||||
ToastUtils.showLong("乘客屏无法连接司机屏请联系安全员")
|
||||
return@onClick
|
||||
}
|
||||
tempCheckLine?.let {
|
||||
val msg = ChangeDestMsg(
|
||||
it.lineId!!.toInt(),
|
||||
@@ -132,8 +157,10 @@ class LineSiteView @JvmOverloads constructor(
|
||||
TelematicConstant.BUSINESS_STRING,
|
||||
GsonUtils.toJson(msg).toByteArray()
|
||||
)
|
||||
startAni()
|
||||
// 启动查看和司机端链接
|
||||
BusPassengerModelLoopManager.setLoopFunction(TAGLINELOOP, LoopInfo(3,::checkServerStatus))
|
||||
}
|
||||
startAni()
|
||||
}
|
||||
tv_site_cancle.onClick {
|
||||
ToastUtils.showLong("取消切换")
|
||||
@@ -143,6 +170,10 @@ class LineSiteView @JvmOverloads constructor(
|
||||
ToastUtils.showLong("请选择站点")
|
||||
return@onClick
|
||||
}
|
||||
if(!CallerTelematicManager.getClientConnStatus()){
|
||||
ToastUtils.showLong("乘客屏无法连接司机屏请联系安全员")
|
||||
return@onClick
|
||||
}
|
||||
checkLine?.let {lineInfo->
|
||||
tempCheckSite?.let {siteInfo->
|
||||
val msg = ChangeDestMsg(
|
||||
@@ -159,8 +190,10 @@ class LineSiteView @JvmOverloads constructor(
|
||||
GsonUtils.toJson(msg).toByteArray()
|
||||
)
|
||||
}
|
||||
startAni()
|
||||
// 启动查看和司机端链接
|
||||
BusPassengerModelLoopManager.setLoopFunction(TAGLINELOOP, LoopInfo(3,::checkServerStatus))
|
||||
}
|
||||
startAni()
|
||||
}
|
||||
tv_switch_line.onClick {
|
||||
ToastUtils.showLong("判断速度是否为0,开始查询线路信息")
|
||||
@@ -169,24 +202,53 @@ class LineSiteView @JvmOverloads constructor(
|
||||
endAni()
|
||||
}
|
||||
|
||||
CallerTelematicListenerManager.addListener(TAG,object : IReceivedMsgListener{
|
||||
override fun onReceivedMsg(type: Int, byteArray: ByteArray) {
|
||||
CallerTelematicListenerManager.addListener(TAG,msgReceived)
|
||||
CharterPassengerModel.setControllerStatusCallback(TAG) { location ->
|
||||
location?.let {
|
||||
gnssSpeed = it.gnssInfo.vehicleSpeed
|
||||
}
|
||||
}
|
||||
tv_switch_line.onClick {
|
||||
if(gnssSpeed<0.01){
|
||||
// 可以切换路径
|
||||
gl_line_cancle_submit_guide.visibility = View.VISIBLE
|
||||
}else{
|
||||
ToastUtils.showShort("请停车后再修改目的地~")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 接收司机屏反馈信息
|
||||
*/
|
||||
val msgReceived = object : IReceivedMsgListener{
|
||||
override fun onReceivedMsg(type: Int, byteArray: ByteArray) {
|
||||
UiThreadHandler.post {
|
||||
if(type==TelematicConstant.BUSINESS_STRING){
|
||||
val msg = GsonUtils.fromJson(String(byteArray),
|
||||
ChangeDestMsg::class.java) as ChangeDestMsg
|
||||
if(msg.type==DPMsgType.TYPE_CHANGE_DEST.type){
|
||||
if(msg.destSiteId==0){
|
||||
// TODO: 选择线路结束
|
||||
checkLine = tempCheckLine
|
||||
ToastUtils.showShort("线路确定")
|
||||
gl_line_cancle_submit_guide.visibility = View.GONE
|
||||
g_side_cancle_submit_group.visibility = View.VISIBLE
|
||||
if(checkLine!=null) {
|
||||
lineList.clear()
|
||||
lineList.add(checkLine!!)
|
||||
lineAdapter.notifyDataSetChanged()
|
||||
}
|
||||
BusPassengerModelLoopManager.removeLoopFunction(TAGLINELOOP)
|
||||
}else{
|
||||
// TODO: 选择站点结束
|
||||
ToastUtils.showShort("站点确定")
|
||||
g_side_cancle_submit_group.visibility = View.GONE
|
||||
gl_line_cancle_submit_guide.visibility = View.GONE
|
||||
}
|
||||
endAni()
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
private fun startAni(){
|
||||
@@ -205,6 +267,10 @@ class LineSiteView @JvmOverloads constructor(
|
||||
override fun onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow()
|
||||
loadingAni.cancel()
|
||||
CallerTelematicListenerManager.removeListener(TAG)
|
||||
BusPassengerModelLoopManager.removeLoopFunction(TAGLINELOOP)
|
||||
CharterPassengerModel.setControllerStatusCallback(TAG,null)
|
||||
|
||||
}
|
||||
|
||||
private fun queryLineList() {
|
||||
@@ -221,14 +287,30 @@ class LineSiteView @JvmOverloads constructor(
|
||||
})
|
||||
}
|
||||
|
||||
private fun checkServerStatus(){
|
||||
if (!CallerTelematicManager.getClientConnStatus()) {
|
||||
ToastUtils.showShort("断开和司机端连接、请联系安全员")
|
||||
BusPassengerModelLoopManager.removeLoopFunction(TAGLINELOOP)
|
||||
endAni()
|
||||
}
|
||||
}
|
||||
|
||||
private fun querySitesByLineId(lineId:String) {
|
||||
BusPassengerServiceManager.queryLineSiteList(context,lineId,object :OchCommonServiceCallback<SiteInfoResponse>{
|
||||
override fun onSuccess(data: SiteInfoResponse?) {
|
||||
if (data?.data == null) return
|
||||
siteAdapter.setDataList(data.data)
|
||||
if(data.data.isNotEmpty()) {
|
||||
// TODO: 计算当前站点是那个
|
||||
currentSite = data.data[0]
|
||||
// 计算当前站点是那个
|
||||
val calculateCurrentSite = CharterPassengerModel.calculateCurrentSite(data.data)
|
||||
val index = if(calculateCurrentSite.first<=data.data.size){
|
||||
calculateCurrentSite.first
|
||||
}else{
|
||||
data.data.size-1
|
||||
}
|
||||
currentSite = data.data[index]
|
||||
currentSite!!.isNear = calculateCurrentSite.second
|
||||
siteAdapter.setEnableIndex(index)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user