diff --git a/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/constant/Const.kt b/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/constant/Const.kt index b7628fd94b..889aedacc7 100644 --- a/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/constant/Const.kt +++ b/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/constant/Const.kt @@ -50,23 +50,23 @@ const val TANLU_ROAD_CURRENT = "10015" //实时路况 /** * 用户手点上报 */ -const val UPLOAD_FROM_USER = 1 +const val UPLOAD_FROM_USER = "1" /** * 用户语音上报 */ -const val UPLOAD_FROM_VOICE = 2 +const val UPLOAD_FROM_VOICE = "2" /** * 数据策略:拥堵自动上报 */ -const val UPLOAD_FROM_STRATEGY_BLOCK_AUTO = 3 +const val UPLOAD_FROM_STRATEGY_BLOCK_AUTO = "3" /** * 数据策略:已有事件云端校验 */ -const val UPLOAD_FROM_STRATEGY_CLOUD_CHECK = 4 +const val UPLOAD_FROM_STRATEGY_CLOUD_CHECK = "4" /** * 数据策略:交通事故上报 */ -const val UPLOAD_FROM_STRATEGY_ACCIDENT_AUTO = 5 +const val UPLOAD_FROM_STRATEGY_ACCIDENT_AUTO = "5" /** * 默认视频抓取时长,单位是秒 diff --git a/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/model/InformationBody.kt b/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/model/InformationBody.kt index a57e134a26..1d4c23725f 100644 --- a/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/model/InformationBody.kt +++ b/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/model/InformationBody.kt @@ -20,5 +20,6 @@ data class InformationBody( val trafficInfoType:String, // 上报情报类型 val isShare: Boolean, // 是否分享给附近车机 val direction: Float, - val poiType: String //类型分类 + val poiType: String, //类型分类 + val mainInfoId: Long //事件id ) \ No newline at end of file diff --git a/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/service/CarCorderController.kt b/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/service/CarCorderController.kt index bf664f0cf5..24002c1042 100644 --- a/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/service/CarCorderController.kt +++ b/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/service/CarCorderController.kt @@ -1,13 +1,11 @@ package com.zhidao.roadcondition.service -import android.content.Intent import android.text.TextUtils import android.util.Log import com.hw.videoprocessor.VideoProcessor import com.mogo.commons.AbsMogoApplication import com.mogo.commons.debug.DebugConfig import com.mogo.utils.NetworkUtils -import com.mogo.utils.TipToast import com.zhidao.auto.carcorder.callback.TakePhotoCallback import com.zhidao.auto.carcorder.callback.TakeVideoCallback import com.zhidao.auto.carcorder.controller.ZdCarCoderController @@ -34,6 +32,8 @@ object CarCorderController : TakePhotoCallback, TakeVideoCallback { val TAG: String = this.javaClass.simpleName var outputVideoPath: String = "" var mType: String = "" //1 上报拥堵, 2 封路和查车 + var mainInfoId: Long = 0 + var mFromType: String = "" private var getVideoFailed: (() -> Unit)? = null private var interceptors: ArrayList = ArrayList(1) @@ -56,24 +56,28 @@ object CarCorderController : TakePhotoCallback, TakeVideoCallback { fun initCarCorderController() { zdCarCoderController = - ZdCarCoderController.getInstance(AbsMogoApplication.getApp().applicationContext) + ZdCarCoderController.getInstance(AbsMogoApplication.getApp().applicationContext) zdCarCoderController.addCallback(this) zdCarCoderController.addVideoCallback(this) zdCarCoderController.init() } fun takePhoto( - photoType: Int, - cameraId: Int, - haveVoice: Boolean, - isCustom: Boolean = false, - type: String + photoType: Int, + cameraId: Int, + haveVoice: Boolean, + isCustom: Boolean = false, + type: String, + mainInfoId: Long, + fromType: String ) { - Log.d(TAG, "takePhoto ---------- type = $type" + " >>>mType =" + mType) + Log.d(TAG, "takePhoto ---------- type = $type --- mType = $mType ---fromType = $fromType") + this.mType = type + this.mainInfoId = mainInfoId + this.mFromType = fromType CustomStatusHandler.offerPhotoStatus(isCustom) zdCarCoderController.takePhoto(photoType, cameraId, haveVoice) trackGetPhoto(1) - this.mType = type } /** @@ -81,15 +85,19 @@ object CarCorderController : TakePhotoCallback, TakeVideoCallback { * @param id: 标志是哪一个上传 */ fun takeVideo( - cameraId: Int, - duration: Int, - isCustom: Boolean = false, - id: Long = 0L, - type: String + cameraId: Int, + duration: Int, + isCustom: Boolean = false, + id: Long = 0L, + type: String, + mainInfoId: Long, + fromType: String ) { Log.d(TAG, "takeVideo -------- type = $type") - Log.d(TAG, "takeVideo -------- isCustom = $isCustom") + Log.d(TAG, "takeVideo -------- isCustom = $isCustom ---mFromType = $mFromType") this.mType = type + this.mainInfoId = mainInfoId + this.mFromType = fromType if (DebugConfig.getCarMachineType() == 0) { //自研车机 outputVideoPath = getCompressVideoPath() CustomStatusHandler.offerVideoStatus(TakeEntity(isCustom, id)) @@ -100,27 +108,28 @@ object CarCorderController : TakePhotoCallback, TakeVideoCallback { // if (!NetworkUtils.isConnected(AbsMogoApplication.getApp().applicationContext)) { // TipToast.shortTip("分享失败,请检查网络") // } else { - //失败了,传空地址,发起请求 - val entity = TakeEntity(isCustom, id) - videoAndThumbMap["video"] = "" - videoAndThumbMap["thumb"] = "" + //失败了,传空地址,发起请求 + val entity = TakeEntity(isCustom, id) + videoAndThumbMap["video"] = "" + videoAndThumbMap["thumb"] = "" - CosStatusController().sendInformationDirectly( + CosStatusController().sendInformationDirectly( INFO_TYPE_VIDEO, videoAndThumbMap, mType, - entity - ) + entity, + mainInfoId + ) - //地图上打点 - taskAsync(3_000) { - try { - LatLngStickyEventBus.getInstance() + //地图上打点 + taskAsync(3_000) { + try { + LatLngStickyEventBus.getInstance() .postSticky(GetImageSuccessEvent("", mType)) - } catch (e: java.lang.Exception) { - e.printStackTrace() - } + } catch (e: java.lang.Exception) { + e.printStackTrace() } + } // } } } @@ -138,18 +147,17 @@ object CarCorderController : TakePhotoCallback, TakeVideoCallback { } val isCustom = CustomStatusHandler.pollPhotoStatus() val entity = TakeEntity(isCustom, 0L) - Log.e(TAG, "onTakePhotoFail -----mType = $mType ") - Log.e(TAG, "onTakePhotoFail -----isCustom = $isCustom ") + Log.e(TAG, "onTakePhotoFail -----mType = $mType --- isCustom = $isCustom") //语音播报 1:上报路况,2:交通检查,3:封路 默认 mType 应该为null if (mType.equals(TANLU_ROAD_CONGESTION) || mType.equals(TANLU_TRAFFIC_CHECK) || mType.equals( - TANLU_ROAD_CLOSURE - ) - || mType.equals(TANLU_ROAD_CURRENT) || mType.equals(TANLU_ROAD_PONDING) || mType.equals( - TANLU_ROAD_ICING - ) - || mType.equals(TANLU_ROAD_HEAVY_FOG) || mType.equals(TANLU_ROAD_ACCIDENT) || mType.equals( - TANLU_ROAD_WORK - ) + TANLU_ROAD_CLOSURE + ) + || mType.equals(TANLU_ROAD_CURRENT) || mType.equals(TANLU_ROAD_PONDING) || mType.equals( + TANLU_ROAD_ICING + ) + || mType.equals(TANLU_ROAD_HEAVY_FOG) || mType.equals(TANLU_ROAD_ACCIDENT) || mType.equals( + TANLU_ROAD_WORK + ) ) { taskAsync(1_500) { try { @@ -165,28 +173,20 @@ object CarCorderController : TakePhotoCallback, TakeVideoCallback { //获取图片失败也上报,图片不打点 if (isCustom) { CosStatusController().sendInformationDirectly( - INFO_TYPE_IMG, - mutableMapOf("pic" to "" as String), - mType, - entity + INFO_TYPE_IMG, + mutableMapOf("pic" to "" as String), + mType, + entity, + mainInfoId ); } } } - private fun sendGetInfoFailedReceiver(type: String) { - Log.e(TAG, "sendGetInfoFailedReceiver ------>") - var intent = Intent() - intent.action = "com.zhidao.roadcondition.getinfo.failed" - intent.putExtra("type", type) - AbsMogoApplication.getApp().applicationContext.sendBroadcast(intent) - } - - //拍照成功回调返回图片本地路径 override fun onTakePhotoSuccess(photoType: Int, camera: Int, photoPath: String?) { trackGetPhoto(2) - Log.d(TAG, "onTakePhotoSuccess -----mType = $mType") + Log.d(TAG, "onTakePhotoSuccess -----mType = $mType --- mainInfoId = $mainInfoId") val isCustom = CustomStatusHandler.pollPhotoStatus() val entity = TakeEntity(isCustom, 0L) @@ -204,35 +204,37 @@ object CarCorderController : TakePhotoCallback, TakeVideoCallback { } var minSpeedPic = - getStrategyMinSpeed( - AbsMogoApplication.getApp().applicationContext, - "pic", - getStrategyType("pic") - ) + getStrategyMinSpeed( + AbsMogoApplication.getApp().applicationContext, + "pic", + getStrategyType("pic") + ) var maxSpeedPic = - getStrategyMaxSpeed( - AbsMogoApplication.getApp().applicationContext, - "pic", - getStrategyType("pic") - ) + getStrategyMaxSpeed( + AbsMogoApplication.getApp().applicationContext, + "pic", + getStrategyType("pic") + ) var speed = LocationUtil.getInstance().getSpeed() if (!TextUtils.isEmpty(mType)) { Log.d(TAG, "onTakePhotoSuccess mType != null") - CosStatusController().uploadFile(mutableListOf(photoPath as String), entity, mType) + CosStatusController().uploadFile(mutableListOf(photoPath as String), entity, mType, mainInfoId, mFromType) } else { Log.d(TAG, "onTakePhotoSuccess mType == null") Log.d( - TAG, - "onTakePhotoSuccess maxSpeedPic = $maxSpeedPic ---> speed = $speed ---->minSpeedPic= $minSpeedPic" + TAG, + "onTakePhotoSuccess maxSpeedPic = $maxSpeedPic ---> speed = $speed ---->minSpeedPic= $minSpeedPic" ) if (maxSpeedPic == -1) { if (speed >= (Math.abs(minSpeedPic) / 3.6f)) { Log.d(TAG, "onTakePhotoSuccess abs =" + (Math.abs(minSpeedPic) / 3.6f)) CosStatusController().uploadFile( - mutableListOf(photoPath as String), - entity, - mType + mutableListOf(photoPath as String), + entity, + mType, + mainInfoId, + mFromType ) } } @@ -241,9 +243,11 @@ object CarCorderController : TakePhotoCallback, TakeVideoCallback { Log.d(TAG, "onTakePhotoSuccess minSpeedPic > 0 -- speed = $speed") if ((speed >= (minSpeedPic / 3.6f)) && speed <= (maxSpeedPic / 3.6f)) { CosStatusController().uploadFile( - mutableListOf(photoPath as String), - entity, - mType + mutableListOf(photoPath as String), + entity, + mType, + mainInfoId, + mFromType ) } } @@ -253,11 +257,11 @@ object CarCorderController : TakePhotoCallback, TakeVideoCallback { //获取视频成功 override fun onTakeVideoSuccess(camera: Int, videoPath: String?) { var thumbnailPath = - AbsMogoApplication.getApp().applicationContext.filesDir.parent + File.separator + "Thumbnail${System.currentTimeMillis()}.jpg" + AbsMogoApplication.getApp().applicationContext.filesDir.parent + File.separator + "Thumbnail${System.currentTimeMillis()}.jpg" var isSuccess = getVideoThumbnail(videoPath!!, thumbnailPath) Log.d( - TAG, - "getVideo onTakeVideoSuccess===$videoPath -----> isSuccess= $isSuccess ----> mType = $mType " + TAG, + "getVideo onTakeVideoSuccess===$videoPath -----> isSuccess= $isSuccess ----> mType = $mType --- mainInfoId = $mainInfoId" ) val entity = CustomStatusHandler.pollVideoStatus() @@ -267,12 +271,12 @@ object CarCorderController : TakePhotoCallback, TakeVideoCallback { if (isSuccess) { var minSpeedVideo = getStrategyMinSpeed( - AbsMogoApplication.getApp().applicationContext, "video", - getStrategyType("video") + AbsMogoApplication.getApp().applicationContext, "video", + getStrategyType("video") ) var maxSpeedVideo = getStrategyMaxSpeed( - AbsMogoApplication.getApp().applicationContext, "video", - getStrategyType("video") + AbsMogoApplication.getApp().applicationContext, "video", + getStrategyType("video") ) var speed = LocationUtil.getInstance().getSpeed() //TODO @@ -286,8 +290,8 @@ object CarCorderController : TakePhotoCallback, TakeVideoCallback { compressVideo(videoPath, thumbnailPath, entity) } else { Log.d( - TAG, - "onTakeVideoSuccess maxSpeedVideo = $maxSpeedVideo --->speed= $speed + minSpeedVideo = $minSpeedVideo" + TAG, + "onTakeVideoSuccess maxSpeedVideo = $maxSpeedVideo --->speed= $speed + minSpeedVideo = $minSpeedVideo" ) if (maxSpeedVideo == -1) { Log.d(TAG, "onTakeVideoSuccess 111 abs =" + (Math.abs(minSpeedVideo) / 3.6f)) @@ -328,10 +332,11 @@ object CarCorderController : TakePhotoCallback, TakeVideoCallback { videoAndThumbMap["thumb"] = "" CosStatusController().sendInformationDirectly( - INFO_TYPE_VIDEO, - videoAndThumbMap, - mType, - entity + INFO_TYPE_VIDEO, + videoAndThumbMap, + mType, + entity, + mainInfoId ) //地图上打点 @@ -349,26 +354,28 @@ object CarCorderController : TakePhotoCallback, TakeVideoCallback { */ fun compressVideo(videoPath: String, thumbnailPath: String, entity: TakeEntity) { Log.d( - TAG, - "outputVideoPath = " + outputVideoPath + ">> videoPath=" + videoPath + " isCustom = ${entity?.isCustom}" + TAG, + "outputVideoPath = " + outputVideoPath + ">> videoPath=" + videoPath + " isCustom = ${entity?.isCustom}" ) var startTime = System.currentTimeMillis() Thread(Runnable { try { VideoProcessor.processor(AbsMogoApplication.getApp().applicationContext) - .input(videoPath) - .output(outputVideoPath) - .removeAudio(true) - .outWidth(1920) - .outHeight(1080) - .bitrate(2000 * 1024) - .frameRate(25) - .process() + .input(videoPath) + .output(outputVideoPath) + .removeAudio(true) + .outWidth(1920) + .outHeight(1080) + .bitrate(2000 * 1024) + .frameRate(25) + .process() Log.d(TAG, "compress cost time =" + (System.currentTimeMillis() - startTime)) CosStatusController().uploadFile( - mutableListOf(outputVideoPath, thumbnailPath), - entity, - mType + mutableListOf(outputVideoPath, thumbnailPath), + entity, + mType, + mainInfoId, + mFromType ) //删除压缩前的视频 deletePicFile(videoPath) @@ -392,16 +399,16 @@ object CarCorderController : TakePhotoCallback, TakeVideoCallback { //获取图片 private fun trackGetPhoto(type: Int) { trackNormalEvent( - CarNet_Get_Picture, mutableMapOf("type" to type), - AbsMogoApplication.getApp().applicationContext + CarNet_Get_Picture, mutableMapOf("type" to type), + AbsMogoApplication.getApp().applicationContext ) } //获取视频 private fun trackGetVideo(type: Int) { trackNormalEvent( - CarNet_Get_Video, mutableMapOf("type" to type), - AbsMogoApplication.getApp().applicationContext + CarNet_Get_Video, mutableMapOf("type" to type), + AbsMogoApplication.getApp().applicationContext ) } diff --git a/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/service/CosCallbackMapController.kt b/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/service/CosCallbackMapController.kt index 4ea6399cdf..a7f80df795 100644 --- a/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/service/CosCallbackMapController.kt +++ b/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/service/CosCallbackMapController.kt @@ -41,7 +41,6 @@ object CosCallbackMapController : CosStatusCallback { path?.let { map.remove(path) } - Log.d(TAG, "size: ${map.size}") } fun unregisterCallbacks(paths: Map?) { diff --git a/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/service/CosStatusController.kt b/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/service/CosStatusController.kt index cddc661ccd..464744387b 100644 --- a/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/service/CosStatusController.kt +++ b/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/service/CosStatusController.kt @@ -36,22 +36,26 @@ class CosStatusController : CosStatusCallback { private lateinit var entity: TakeEntity private var mType: String = "" + private var mainInfoId: Long = 0 + private var mFromType: String = "" //上传文件 - fun uploadFile(picPath: MutableList, entity: TakeEntity, type: String) { + fun uploadFile(picPath: MutableList, entity: TakeEntity, type: String, mainInfoId: Long, fromType: String) { CosCallbackMapController.registerCallback(picPath, this) // CosLogger.setLogStatus(true) this.entity = entity this.mType = type - Log.d(TAG, "uploadFile type===$type ---- picPath = $picPath ") + this.mainInfoId = mainInfoId + this.mFromType = fromType; + Log.d(TAG, "uploadFile type===$type ---- mainInfoId =$mainInfoId ----mFromType = $mFromType ---- picPath = $picPath ") trackUploadCos(3) if (picPath.contains("backPic")) return //参数说明: paths:本地文件路径;(注:上传的本地路径不要重复);config:文件上传的优先级 mPicEventId = - CosUploadManagerImpl.getInstance(AbsMogoApplication.getApp().applicationContext).eventId + CosUploadManagerImpl.getInstance(AbsMogoApplication.getApp().applicationContext).eventId CosUploadManagerImpl.getInstance(AbsMogoApplication.getApp().applicationContext) - .upload(picPath, mPicEventId, DbPriorityConfig.PRIORITY_HIGH) + .upload(picPath, mPicEventId, DbPriorityConfig.PRIORITY_HIGH) } @@ -68,22 +72,21 @@ class CosStatusController : CosStatusCallback { override fun uploadCosFailed(cosPath: String?, eventId: String?, localPath: String?) { Log.d(TAG, "uploadCosFailed = $localPath") - Log.d(TAG, "uploadCosFailed CarCorderController.mType = " + CarCorderController.mType) trackUploadCos(2) //语音播报 1:上报路况,2:交通检查,3:封路 默认 mType 应该为null if (CarCorderController.mType.equals(TANLU_ROAD_CONGESTION) || CarCorderController.mType.equals( - TANLU_TRAFFIC_CHECK - ) || CarCorderController.mType.equals(TANLU_ROAD_CLOSURE) - || CarCorderController.mType.equals(TANLU_ROAD_CURRENT) || CarCorderController.mType.equals( - TANLU_ROAD_PONDING - ) || CarCorderController.mType.equals(TANLU_ROAD_ICING) - || CarCorderController.mType.equals(TANLU_ROAD_HEAVY_FOG) || CarCorderController.mType.equals( - TANLU_ROAD_ACCIDENT - ) || CarCorderController.mType.equals(TANLU_ROAD_WORK) + TANLU_TRAFFIC_CHECK + ) || CarCorderController.mType.equals(TANLU_ROAD_CLOSURE) + || CarCorderController.mType.equals(TANLU_ROAD_CURRENT) || CarCorderController.mType.equals( + TANLU_ROAD_PONDING + ) || CarCorderController.mType.equals(TANLU_ROAD_ICING) + || CarCorderController.mType.equals(TANLU_ROAD_HEAVY_FOG) || CarCorderController.mType.equals( + TANLU_ROAD_ACCIDENT + ) || CarCorderController.mType.equals(TANLU_ROAD_WORK) ) { // VoiceController.speakVoice("cos上报失败") Log.d(TAG, "uploadCosFailed mType = $mType") - if (entity?.isCustom) { + if (entity?.isCustom && mFromType != UPLOAD_FROM_STRATEGY_ACCIDENT_AUTO) { sendGetInfoFailedReceiver("100") } } @@ -108,10 +111,10 @@ class CosStatusController : CosStatusCallback { } override fun uploadCosCompleted( - cosPath: String?, - eventId: String?, - downloadUrl: String?, - localPath: String? + cosPath: String?, + eventId: String?, + downloadUrl: String?, + localPath: String? ) { Log.d(TAG, "uploadFile mType= $mType") Log.d(TAG, "uploadCosCompleted localPath = $localPath") @@ -130,22 +133,21 @@ class CosStatusController : CosStatusCallback { Log.d(TAG, "videoAndThumbMap ${videoAndThumbMap}") if (videoAndThumbMap.size == 2) { Log.d(TAG, "videoAndThumbMap.size == 2 ") - var locationInfo = LocationUtil.getInstance().getLocationInfo() val locationStr: String = Gson().toJson(locationInfo) Log.d(TAG, "locationStr = " + locationStr) //如果失败,需要提示失败弹框 if (locationInfo.address.isNullOrEmpty() || locationInfo.cityName.isNullOrEmpty() || locationInfo.cityCode.isNullOrEmpty() - || locationInfo.latitude == 0.0 || locationInfo.areaName.isNullOrEmpty() || locationInfo.street.isNullOrEmpty() - || locationInfo.areaCode.isNullOrEmpty() || locationInfo.provinceName.isNullOrEmpty() + || locationInfo.latitude == 0.0 || locationInfo.areaName.isNullOrEmpty() || locationInfo.street.isNullOrEmpty() + || locationInfo.areaCode.isNullOrEmpty() || locationInfo.provinceName.isNullOrEmpty() ) { - if (entity?.isCustom) { + if (entity?.isCustom && mFromType != UPLOAD_FROM_STRATEGY_ACCIDENT_AUTO) { sendGetInfoFailedReceiver("100") } } else { //分享成功,并打点,如果是上报拥堵,需要takeVideo LatLngStickyEventBus.getInstance() - .postSticky(GetImageSuccessEvent(downloadUrl, mType)) + .postSticky(GetImageSuccessEvent(downloadUrl, mType)) //上传录像以及缩略图成功 sendInformation(INFO_TYPE_VIDEO, videoAndThumbMap) } @@ -155,10 +157,11 @@ class CosStatusController : CosStatusCallback { Log.d(TAG, "uploadCosCompleted 分享成功 ----mType = $mType") // if (mType.equals("1") || mType.equals("-1")) { sendInformationDirectly( - INFO_TYPE_IMG, - mutableMapOf("pic" to downloadUrl as String), - mType, - entity + INFO_TYPE_IMG, + mutableMapOf("pic" to downloadUrl as String), + mType, + entity, + mainInfoId ) // } } @@ -174,7 +177,7 @@ class CosStatusController : CosStatusCallback { // CosCallbackMapController.mainService?.sendCustomResult(it) // } // } else { - sendInformationDirectly(type, map, mType, entity) + sendInformationDirectly(type, map, mType, entity, mainInfoId) // } } @@ -182,18 +185,20 @@ class CosStatusController : CosStatusCallback { * 被动上报时直接上报,不用等待、选择情报类型 */ fun sendInformationDirectly( - type: Int, - map: Map, - poiType: String, - entity: TakeEntity + type: Int, + map: Map, + poiType: String, + entity: TakeEntity, + mainInfoId: Long ) { Log.d(TAG, "sendInformationDirectly isCustomSend = ${entity?.isCustom}") - Log.d(TAG, "sendInformationDirectly poiType= $poiType") + Log.d(TAG, "sendInformationDirectly poiType= $poiType ---- mainInfoId= $mainInfoId") mainServiceHttpModel.sendInformationMessage( - type = type, - url = map, - isCustom = entity?.isCustom, - poiType = poiType + type = type, + url = map, + isCustom = entity?.isCustom, + poiType = poiType, + mainInfoId = mainInfoId ) { success -> CosCallbackMapController.unregisterCallbacks(map) CosCallbackMapController.mainService?.let { @@ -208,8 +213,8 @@ class CosStatusController : CosStatusCallback { //上传COS private fun trackUploadCos(type: Int) { trackNormalEvent( - CarNet_Cos_Upload, mutableMapOf("type" to type), - AbsMogoApplication.getApp().applicationContext + CarNet_Cos_Upload, mutableMapOf("type" to type), + AbsMogoApplication.getApp().applicationContext ) } diff --git a/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/service/MainService.kt b/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/service/MainService.kt index 6b1d364db3..91700ea1cc 100644 --- a/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/service/MainService.kt +++ b/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/service/MainService.kt @@ -61,7 +61,7 @@ class MainService : Service() { var isCustom: Boolean = false var params: UploadParams? = null - + var mainInfoId: Long = 0 //发送主动上报结果广播给外部 fun sendCustomResult(result: Boolean) { @@ -73,12 +73,9 @@ class MainService : Service() { override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int { Log.d(TAG, "onStartCommand -----------> ") //清理多媒体资源和sp策略数据 -// DelayService.launchService(this) clearStrategyType(this) //初始化埋点 Analytics.getInstance().start(this) - //初始化定位 -// LocationUtil.getInstance().initLocation() //参数说明:appKey: app唯一标识(比如:包名) CosUploadManagerImpl.getInstance(AbsMogoApplication.getApp().applicationContext) .init(BuildConfig.APPLICATION_ID, 2) @@ -90,13 +87,14 @@ class MainService : Service() { params?.let { shareType = it.eventType fromType = it.fromType + mainInfoId = 0 //TODO Log.d(TAG, "onStartCommand shareType = $shareType") if (shareType == TANLU_ROAD_CONGESTION || shareType == TANLU_TRAFFIC_CHECK || shareType == TANLU_ROAD_CLOSURE || shareType == TANLU_ROAD_CURRENT || shareType == TANLU_ROAD_PONDING || shareType == TANLU_ROAD_ICING || shareType == TANLU_ROAD_HEAVY_FOG || shareType == TANLU_ROAD_ACCIDENT || shareType == TANLU_ROAD_WORK ) { // takePhoto(1, false, true) - if (!fromType.equals("5")) { // 是策略触发,不提示 + if (!fromType.equals(UPLOAD_FROM_STRATEGY_ACCIDENT_AUTO)) { // 是策略触发,不提示 takeVideo(it.duration, isCustom = true, id = id) } else { takeVideo(it.duration) @@ -124,12 +122,6 @@ class MainService : Service() { var duration = p1.getIntExtra("duration", 3) takeVideo(duration, true) } - } else if (p1.action == "com.zhidao.takevideo.test") { - //视频 - takeVideo(p1.getIntExtra("duration", 10)) - } else if (p1.action == "com.zhidao.takepic.test") { - //视频 - takePhoto(1) } } } @@ -144,14 +136,6 @@ class MainService : Service() { } } - /** - * 发送获取图片 - */ - fun startUploadInformation() { - var customIntent = Intent(sendInformationAction) - sendBroadcast(customIntent) - } - override fun onBind(intent: Intent?): IBinder? { return null } @@ -159,7 +143,6 @@ class MainService : Service() { override fun onCreate() { super.onCreate() - Log.d(TAG, "onCreate ------> 1") init() //初始化定位 LocationUtil.getInstance().initLocation() @@ -295,7 +278,7 @@ class MainService : Service() { Observable.intervalRange(0, 1, 0, 2_000, TimeUnit.MILLISECONDS) .observeOn(AndroidSchedulers.mainThread()) .subscribe(Consumer { - CarCorderController.takePhoto(1, 1, false, isCustom, TANLU_ROAD_CURRENT) + CarCorderController.takePhoto(1, 1, false, isCustom, TANLU_ROAD_CURRENT, mainInfoId, fromType) }) // } @@ -314,7 +297,7 @@ class MainService : Service() { Log.d("MainService", "takeVideo --------1---->") // if (isAuthorization(BaseApplication.getAppContext())) { // log(TAG, "takeVideo --------2---->") - CarCorderController.takeVideo(1, duration, isCustom, id, if (isCustom) shareType else TANLU_ROAD_CURRENT) + CarCorderController.takeVideo(1, duration, isCustom, id, if (isCustom) shareType else TANLU_ROAD_CURRENT, mainInfoId, fromType) // } postVideoAlarmTask(isInterval) diff --git a/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/service/MainServiceController.kt b/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/service/MainServiceController.kt index a2dcfde83e..9fb7e4ee51 100644 --- a/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/service/MainServiceController.kt +++ b/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/service/MainServiceController.kt @@ -226,16 +226,17 @@ class MainServiceController { trafficInfoType:String = "", isShare:Boolean = false, poiType:String, + mainInfoId:Long, customSend: ((Boolean) -> Unit)? = null ) { Log.d(TAG, " sendInformationMessage poiType = $poiType"); //删除测试数据 var locationInfo = LocationUtil.getInstance().getLocationInfo(); if (locationInfo.address.isNullOrEmpty()) { - geoLocation(type, url, locationInfo, isCustom,trafficInfoType, isShare, customSend,poiType) + geoLocation(type, url, locationInfo, isCustom,trafficInfoType, isShare, customSend,poiType,mainInfoId) } else { postInformationMessage( - getInformationBody(type, url, locationInfo, isCustom, trafficInfoType, isShare,poiType), + getInformationBody(type, url, locationInfo, isCustom, trafficInfoType, isShare,poiType,mainInfoId), customSend ) } @@ -251,19 +252,20 @@ class MainServiceController { trafficInfoType:String, isShare: Boolean, customSend: ((Boolean) -> Unit)? = null, - poiType: String + poiType: String, + mainInfoId: Long ) { Log.d(TAG, " geoLocation -- poiType = $poiType"); LocationUtil.getInstance() .geoCodeLocation(locationInfo.toLatLngPoint(), { locInfo: LocationInfo -> postInformationMessage( - getInformationBody(type, url, locationInfo, isCustom, trafficInfoType, isShare, poiType), + getInformationBody(type, url, locationInfo, isCustom, trafficInfoType, isShare, poiType,mainInfoId), customSend ) }, { //转换失败的情况下再重试一次 geoRetryed = if (!geoRetryed) { - geoLocation(type, url, locationInfo, isCustom, trafficInfoType, isShare, customSend, poiType) + geoLocation(type, url, locationInfo, isCustom, trafficInfoType, isShare, customSend, poiType,mainInfoId) true } else { false diff --git a/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/util/PdUtil.kt b/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/util/PdUtil.kt index 951c4aceec..60d97f3871 100644 --- a/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/util/PdUtil.kt +++ b/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/util/PdUtil.kt @@ -28,7 +28,8 @@ fun getInformationBody( isCustom: Boolean, trafficInfoType:String = "", isShare:Boolean, - poiType: String + poiType: String, + mainInfoId: Long ): InformationBody { var jsonArray = JsonArray() var type: Int @@ -65,7 +66,8 @@ fun getInformationBody( trafficInfoType, isShare, locationInfo.direction, - poiType + poiType, + mainInfoId ) }