[6.5.0] tmp

This commit is contained in:
EmArrow
2024-06-17 16:22:36 +08:00
parent dbf223c997
commit f1ff3baf52
11 changed files with 240 additions and 51 deletions

View File

@@ -20,6 +20,7 @@ import com.mogo.eagle.function.biz.v2x.trafficlight.core.TrafficLightThreadHandl
import com.mogo.eagle.function.biz.v2x.trafficlight.core.TrafficLightThreadHandler.Companion.MSG_WHAT_STOP_SEARCH_CROSS_ROAD
import com.mogo.eagle.function.biz.v2x.trafficlight.core.TrafficLightThreadHandler.Companion.MSG_WHAT_STOP_SEARCH_TRAFFIC_LIGHT
import com.mogo.eagle.function.biz.v2x.trafficlight.network.TrafficLightNetWorkModel
import com.zhidaoauto.map.data.road.RoadCross
class MogoTrafficLightManager : IMoGoChassisLocationGCJ02Listener,
CallerMapRoadListenerManager.OnRoadListener {
@@ -121,8 +122,8 @@ class MogoTrafficLightManager : IMoGoChassisLocationGCJ02Listener,
mThreadHandler?.sendEmptyMessageDelayed(MSG_WHAT_LOOP_SEARCH_CROSS_ROAD, 5_000L)
}
override fun onRoadChange(cross: Boolean) {
super.onRoadChange(cross)
override fun onRoadChange(cross: Boolean,roadCross: RoadCross?) {
super.onRoadChange(cross,roadCross)
if(!cross){
outOfCrossRange()
}

View File

@@ -10,6 +10,7 @@ import com.mogo.eagle.core.function.business.MapPointCloudSubscriber
import com.mogo.eagle.core.function.business.SpeedLimitDataManager
import com.mogo.eagle.core.function.business.ai.AiCloudIdentifyDataManager.Companion.aiCloudIdentifyDataManager
import com.mogo.eagle.core.function.business.identify.MapIdentifySubscriber
import com.mogo.eagle.core.function.business.roadcross.RoadCrossCameraManager
import com.mogo.eagle.core.function.business.routeoverlay.MogoRouteOverlayManager
import com.mogo.eagle.core.function.call.map.CallerVisualAngleManager
import com.mogo.eagle.core.utilcode.util.DeviceUtils
@@ -26,6 +27,7 @@ class MapBizProvider :IMoGoFunctionServerProvider, IMogoRoma {
MapIdentifySubscriber.instance
MogoRouteOverlayManager.getInstance().init()
MapPointCloudSubscriber.instance
RoadCrossCameraManager.instance.init()
SpeedLimitDataManager.getInstance().start()
if(DeviceUtils.isLenovoModel() || DeviceUtils.isEB5Model()){ //todo 新增稳定设备类型需要添加目的避免在nuc设备上使用此类功能
aiCloudIdentifyDataManager.initServer(AbsMogoApplication.getApp())

View File

@@ -0,0 +1,74 @@
package com.mogo.eagle.core.function.business.roadcross
import com.mogo.eagle.core.data.deva.chain.ChainConstant
import com.mogo.eagle.core.function.business.roadcross.net.NDERoadCameraNetWorkModel
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationWGS84ListenerManager
import com.mogo.eagle.core.function.call.map.CallerMapRoadListenerManager
import com.zhidaoauto.map.data.road.RoadCross
import com.zhidaoauto.map.data.road.StopLine
import com.zhjt.service.chain.ChainLog
import kotlin.properties.Delegates
class RoadCrossCameraManager : CallerMapRoadListenerManager.OnRoadListener {
companion object {
private const val TAG = "RoadCrossCameraManager"
val instance: RoadCrossCameraManager by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) {
RoadCrossCameraManager()
}
}
@Volatile
private var isCameraRequest = false
private val ndeRoadCameraNetWorkModel = NDERoadCameraNetWorkModel()
fun init() {
CallerMapRoadListenerManager.registerRoadListener(TAG, this)
}
private var distance: Double by Delegates.observable(0.0) { _, _, newV ->
if (!isCameraRequest && newV < 100) {
isCameraRequest = true
val roadCross = CallerMapRoadListenerManager.getCrossInfo()
if (roadCross != null) {
ndeRoadCameraNetWorkModel.getRoadCrossInfo(roadCross.cross_id_end)
} else {
val loc = CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84()
roadCrossTrace(
TAG,
mapOf(
"errorMsg" to "roadCross is null",
"lat" to loc.latitude,
"lon" to loc.longitude
)
)
}
}
}
override fun onStopLineInfo(info: StopLine) {
super.onStopLineInfo(info)
distance = info.distance
}
override fun onRoadChange(cross: Boolean, roadCross: RoadCross?) {
super.onRoadChange(cross, roadCross)
// 进入路口
if (cross) {
isCameraRequest = false
// 停止请求摄像头数据
}
}
@ChainLog(
linkChainLog = ChainConstant.CHAIN_TYPE_STATUS,
linkCode = ChainConstant.CHAIN_SOURCE_MAP,
nodeAliasCode = ChainConstant.CHAIN_CODE_MAP_ROAD_CROSS_ERROR,
paramIndexes = [0, 1]
)
private fun roadCrossTrace(tag: String, paramMap: Any) {
}
}

View File

@@ -0,0 +1,46 @@
package com.mogo.eagle.core.function.business.roadcross.net
import com.mogo.eagle.core.data.Response
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.Header
import retrofit2.http.Headers
import retrofit2.http.POST
import retrofit2.http.Query
const val ROAD_CAMERA = "abilitySupport/rss/"
const val SINGLE_LIVE = "abilitySupport/rss/queryLive"
const val BATCH_LIVE = "abilitySupport/rss/queryLiveAll"
interface INDERoadCameraApiService {
// 获取路口处路侧直播流设备ip地址(批量返回) todo post地址待给出
@Headers("Content-type:application/json;charset=UTF-8")
@POST(ROAD_CAMERA)
suspend fun roadCameraRequest(
@Header("MogoAuthKey") authKey: String,
@Header("MogoReqTime") time: String,
@Body map: MutableMap<String, Any>
): Response<Any>
// 单ip查询设备直播流与缩略图
@Headers("Content-type:application/json;charset=UTF-8")
@GET(SINGLE_LIVE)
suspend fun cameraLiveSingleRequest(
@Header("MogoAuthKey") authKey: String,
@Header("MogoReqTime") time: String,
@Query("ip") ip: String,
@Query("lon") lon: Double,
@Query("lat") lat: Double
): Response<Any>
// 批量ip查询设备直播流与缩略图
@Headers("Content-type:application/json;charset=UTF-8")
@POST(BATCH_LIVE)
suspend fun cameraLiveBatchRequest(
@Header("MogoAuthKey") authKey: String,
@Header("MogoReqTime") time: String,
@Body map: MutableMap<String, Any>
): Response<Any>
}

View File

@@ -0,0 +1,43 @@
package com.mogo.eagle.core.function.business.roadcross.net
import com.mogo.commons.constants.HostConst
import com.mogo.eagle.core.data.Response
import com.mogo.eagle.core.network.MoGoRetrofitFactory
import com.mogo.eagle.core.network.apiResponseCall
import com.mogo.eagle.core.network.request
import com.mogo.eagle.core.utilcode.util.Md5Util
import java.util.Locale
class NDERoadCameraNetWorkModel {
companion object {
val ndeRoadCameraNetWorkModel by lazy(LazyThreadSafetyMode.SYNCHRONIZED) {
NDERoadCameraNetWorkModel()
}
}
private fun getNetWorkApi(baseUrl: String = HostConst.getNDEHost()): INDERoadCameraApiService {
return MoGoRetrofitFactory.getInstanceNoCallAdapter(baseUrl)
.create(INDERoadCameraApiService::class.java)
}
fun getRoadCrossInfo(crossID: String) {
request<Response<Any>> {
loader {
apiResponseCall {
val map = mutableMapOf<String, Any>()
map["crossID"] = crossID
val time = System.currentTimeMillis().toString()
val md5String = "${ROAD_CAMERA.uppercase(Locale.getDefault())}$time"
getNetWorkApi().roadCameraRequest(Md5Util.getMD5Result(md5String), time, map)
}
}
onSuccess {
}
onError {
}
}
}
}

View File

@@ -135,5 +135,8 @@ class ChainConstant {
const val CHAIN_CODE_ROMA_CLOUD_PUSH = "CHAIN_CODE_ROMA_CLOUD_PUSH"
const val CHAIN_CODE_ROMA_MAP_ERROR = "CHAIN_CODE_ROMA_MAP_ERROR"
// Biz
const val CHAIN_CODE_MAP_ROAD_CROSS_ERROR = "CHAIN_CODE_MAP_ROAD_CROSS_ERROR"
}
}

View File

@@ -17,7 +17,7 @@ object CallerMapRoadListenerManager {
fun onStopLineInfo(info: StopLine) {}
fun onRoadChange(cross: Boolean) {}
fun onRoadChange(cross: Boolean, roadCross: RoadCross? = null) {}
}
private val listeners by lazy {
@@ -55,14 +55,20 @@ object CallerMapRoadListenerManager {
if (oldValue != newValue) {
CallerLogger.d("$M_MAP onRoadChange", newValue)
listeners.forEach { entry ->
when(newValue){
1,2 -> entry.value.onRoadChange(false)
else -> entry.value.onRoadChange(true)
when (newValue) {
1, 2 -> entry.value.onRoadChange(false, mRoadCross)
else -> entry.value.onRoadChange(true, mRoadCross)
}
}
}
}
private var mRoadCross: RoadCross? = null
fun getCrossInfo(): RoadCross? {
return mRoadCross
}
@ChainLog(
linkChainLog = ChainConstant.CHAIN_TYPE_STATUS,
linkCode = ChainConstant.CHAIN_SOURCE_MAP,
@@ -71,6 +77,7 @@ object CallerMapRoadListenerManager {
)
fun invokeRoadChange(cross: Int, roadCross: RoadCross) {
mCross = cross
mRoadCross = roadCross
}
}

View File

@@ -2,6 +2,8 @@ package com.mogo.eagle.core.utilcode.mogo.storage.lrucache;
import android.content.Context;
import com.mogo.eagle.core.utilcode.util.Md5Util;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
@@ -66,7 +68,7 @@ public class DiskCacheManager {
* @throws IOException
*/
private DiskLruCache.Editor edit( String key) throws IOException {
key = SecretUtil.getMD5Result(key); //存取的 key
key = Md5Util.getMD5Result(key); //存取的 key
if (mDiskLruCache != null) {
mEditor = mDiskLruCache.edit(key);
}
@@ -349,7 +351,7 @@ public class DiskCacheManager {
* @return InputStream
*/
private InputStream getCacheInputStream( String key) {
key = SecretUtil.getMD5Result(key);
key = Md5Util.getMD5Result(key);
InputStream in;
DiskLruCache.Snapshot snapshot = snapshot(key);
if (snapshot == null) {

View File

@@ -1,34 +0,0 @@
package com.mogo.eagle.core.utilcode.mogo.storage.lrucache;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public class SecretUtil {
public static String getMD5Result( String value) {
try {
MessageDigest md = MessageDigest.getInstance("MD5");
md.update(value.getBytes("UTF-8"));
byte[] result = md.digest();
return getString(result);
} catch ( NoSuchAlgorithmException e) {
e.printStackTrace();
return "";
} catch ( UnsupportedEncodingException e) {
e.printStackTrace();
return "";
}
}
private static String getString( byte[] result) {
StringBuilder sb = new StringBuilder();
for (byte b : result) {
int i = b & 0xff;
if (i <= 0xf) {
sb.append(0);
}
sb.append( Integer.toHexString(i));
}
return sb.toString().toLowerCase();
}
}

View File

@@ -1,8 +1,12 @@
package com.mogo.eagle.core.utilcode.util
import java.io.*
import java.io.File
import java.io.FileInputStream
import java.io.UnsupportedEncodingException
import java.nio.channels.FileChannel.MapMode
import java.security.*
import java.security.MessageDigest
import java.security.NoSuchAlgorithmException
import java.util.Locale
class Md5Util {
@@ -39,5 +43,34 @@ class Md5Util {
}
return stringbuffer?.toString()
}
@JvmStatic
fun getMD5Result(value: String): String {
try {
val md = MessageDigest.getInstance("MD5")
md.update(value.toByteArray(charset("UTF-8")))
val result = md.digest()
return getString(result)
} catch (e: NoSuchAlgorithmException) {
e.printStackTrace()
return ""
} catch (e: UnsupportedEncodingException) {
e.printStackTrace()
return ""
}
}
private fun getString(result: ByteArray): String {
val sb = StringBuilder()
for (b in result) {
val i = b.toInt() and 0xff
if (i <= 0xf) {
sb.append(0)
}
sb.append(Integer.toHexString(i))
}
return sb.toString().lowercase(Locale.getDefault())
}
}
}

View File

@@ -10,9 +10,12 @@ public class HostConst {
public static final String HOST_EAGLE_QA = "https://eagle-dns-qa.zhidaozhixing.com/";
public static final String HOST_EAGLE_RELEASE = "https://eagle-dns.zhidaozhixing.com/";
public static final String NED_QA = "https://nde-qa-city.zhidaozhixing.com";
public static final String NED_RELEASE = "https://nde-city.zhidaozhixing.com";
public static String getHost() {
String host = HOST_RELEASE;
if(FunctionBuildConfig.urlJson.getEagleMisUrl().isEmpty()){
if (FunctionBuildConfig.urlJson.getEagleMisUrl().isEmpty()) {
switch (DebugConfig.getNetMode()) {
case DebugConfig.NET_MODE_DEV:
case DebugConfig.NET_MODE_QA:
@@ -20,27 +23,36 @@ public class HostConst {
break;
}
return host;
}else{
} else {
return FunctionBuildConfig.urlJson.getEagleMisUrl();
}
}
public static String getEagleHost(){
public static String getEagleHost() {
String host = HOST_EAGLE_RELEASE;
if(FunctionBuildConfig.urlJson.getEagleDnsUrl().isEmpty()){
switch (DebugConfig.getNetMode()){
if (FunctionBuildConfig.urlJson.getEagleDnsUrl().isEmpty()) {
switch (DebugConfig.getNetMode()) {
case DebugConfig.NET_MODE_DEV:
case DebugConfig.NET_MODE_QA:
host = HOST_EAGLE_QA;
break;
}
return host;
}else{
} else {
return FunctionBuildConfig.urlJson.getEagleDnsUrl();
}
}
public static String getNDEHost() {
String host = NED_RELEASE;
switch (DebugConfig.getNetMode()) {
case DebugConfig.NET_MODE_DEV:
case DebugConfig.NET_MODE_QA:
host = NED_QA;
break;
}
return host;
}
}