add roadtrafic upload

This commit is contained in:
lixiaopeng
2020-08-14 14:22:51 +08:00
parent dce7f5e68c
commit d9b1ef9acd
8 changed files with 177 additions and 178 deletions

View File

@@ -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"
/** /**
* 默认视频抓取时长,单位是秒 * 默认视频抓取时长,单位是秒

View File

@@ -20,5 +20,6 @@ data class InformationBody(
val trafficInfoType:String, // 上报情报类型 val trafficInfoType:String, // 上报情报类型
val isShare: Boolean, // 是否分享给附近车机 val isShare: Boolean, // 是否分享给附近车机
val direction: Float, val direction: Float,
val poiType: String //类型分类 val poiType: String, //类型分类
val mainInfoId: Long //事件id
) )

View File

@@ -1,13 +1,11 @@
package com.zhidao.roadcondition.service package com.zhidao.roadcondition.service
import android.content.Intent
import android.text.TextUtils import android.text.TextUtils
import android.util.Log import android.util.Log
import com.hw.videoprocessor.VideoProcessor import com.hw.videoprocessor.VideoProcessor
import com.mogo.commons.AbsMogoApplication import com.mogo.commons.AbsMogoApplication
import com.mogo.commons.debug.DebugConfig import com.mogo.commons.debug.DebugConfig
import com.mogo.utils.NetworkUtils import com.mogo.utils.NetworkUtils
import com.mogo.utils.TipToast
import com.zhidao.auto.carcorder.callback.TakePhotoCallback import com.zhidao.auto.carcorder.callback.TakePhotoCallback
import com.zhidao.auto.carcorder.callback.TakeVideoCallback import com.zhidao.auto.carcorder.callback.TakeVideoCallback
import com.zhidao.auto.carcorder.controller.ZdCarCoderController import com.zhidao.auto.carcorder.controller.ZdCarCoderController
@@ -34,6 +32,8 @@ object CarCorderController : TakePhotoCallback, TakeVideoCallback {
val TAG: String = this.javaClass.simpleName val TAG: String = this.javaClass.simpleName
var outputVideoPath: String = "" var outputVideoPath: String = ""
var mType: String = "" //1 上报拥堵, 2 封路和查车 var mType: String = "" //1 上报拥堵, 2 封路和查车
var mainInfoId: Long = 0
var mFromType: String = ""
private var getVideoFailed: (() -> Unit)? = null private var getVideoFailed: (() -> Unit)? = null
private var interceptors: ArrayList<TakePhotoInterceptor> = ArrayList(1) private var interceptors: ArrayList<TakePhotoInterceptor> = ArrayList(1)
@@ -56,24 +56,28 @@ object CarCorderController : TakePhotoCallback, TakeVideoCallback {
fun initCarCorderController() { fun initCarCorderController() {
zdCarCoderController = zdCarCoderController =
ZdCarCoderController.getInstance(AbsMogoApplication.getApp().applicationContext) ZdCarCoderController.getInstance(AbsMogoApplication.getApp().applicationContext)
zdCarCoderController.addCallback(this) zdCarCoderController.addCallback(this)
zdCarCoderController.addVideoCallback(this) zdCarCoderController.addVideoCallback(this)
zdCarCoderController.init() zdCarCoderController.init()
} }
fun takePhoto( fun takePhoto(
photoType: Int, photoType: Int,
cameraId: Int, cameraId: Int,
haveVoice: Boolean, haveVoice: Boolean,
isCustom: Boolean = false, isCustom: Boolean = false,
type: String 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) CustomStatusHandler.offerPhotoStatus(isCustom)
zdCarCoderController.takePhoto(photoType, cameraId, haveVoice) zdCarCoderController.takePhoto(photoType, cameraId, haveVoice)
trackGetPhoto(1) trackGetPhoto(1)
this.mType = type
} }
/** /**
@@ -81,15 +85,19 @@ object CarCorderController : TakePhotoCallback, TakeVideoCallback {
* @param id: 标志是哪一个上传 * @param id: 标志是哪一个上传
*/ */
fun takeVideo( fun takeVideo(
cameraId: Int, cameraId: Int,
duration: Int, duration: Int,
isCustom: Boolean = false, isCustom: Boolean = false,
id: Long = 0L, id: Long = 0L,
type: String type: String,
mainInfoId: Long,
fromType: String
) { ) {
Log.d(TAG, "takeVideo -------- type = $type") Log.d(TAG, "takeVideo -------- type = $type")
Log.d(TAG, "takeVideo -------- isCustom = $isCustom") Log.d(TAG, "takeVideo -------- isCustom = $isCustom ---mFromType = $mFromType")
this.mType = type this.mType = type
this.mainInfoId = mainInfoId
this.mFromType = fromType
if (DebugConfig.getCarMachineType() == 0) { //自研车机 if (DebugConfig.getCarMachineType() == 0) { //自研车机
outputVideoPath = getCompressVideoPath() outputVideoPath = getCompressVideoPath()
CustomStatusHandler.offerVideoStatus(TakeEntity(isCustom, id)) CustomStatusHandler.offerVideoStatus(TakeEntity(isCustom, id))
@@ -100,27 +108,28 @@ object CarCorderController : TakePhotoCallback, TakeVideoCallback {
// if (!NetworkUtils.isConnected(AbsMogoApplication.getApp().applicationContext)) { // if (!NetworkUtils.isConnected(AbsMogoApplication.getApp().applicationContext)) {
// TipToast.shortTip("分享失败,请检查网络") // TipToast.shortTip("分享失败,请检查网络")
// } else { // } else {
//失败了,传空地址,发起请求 //失败了,传空地址,发起请求
val entity = TakeEntity(isCustom, id) val entity = TakeEntity(isCustom, id)
videoAndThumbMap["video"] = "" videoAndThumbMap["video"] = ""
videoAndThumbMap["thumb"] = "" videoAndThumbMap["thumb"] = ""
CosStatusController().sendInformationDirectly( CosStatusController().sendInformationDirectly(
INFO_TYPE_VIDEO, INFO_TYPE_VIDEO,
videoAndThumbMap, videoAndThumbMap,
mType, mType,
entity entity,
) mainInfoId
)
//地图上打点 //地图上打点
taskAsync(3_000) { taskAsync(3_000) {
try { try {
LatLngStickyEventBus.getInstance() LatLngStickyEventBus.getInstance()
.postSticky(GetImageSuccessEvent("", mType)) .postSticky(GetImageSuccessEvent("", mType))
} catch (e: java.lang.Exception) { } catch (e: java.lang.Exception) {
e.printStackTrace() e.printStackTrace()
}
} }
}
// } // }
} }
} }
@@ -138,18 +147,17 @@ object CarCorderController : TakePhotoCallback, TakeVideoCallback {
} }
val isCustom = CustomStatusHandler.pollPhotoStatus() val isCustom = CustomStatusHandler.pollPhotoStatus()
val entity = TakeEntity(isCustom, 0L) val entity = TakeEntity(isCustom, 0L)
Log.e(TAG, "onTakePhotoFail -----mType = $mType ") Log.e(TAG, "onTakePhotoFail -----mType = $mType --- isCustom = $isCustom")
Log.e(TAG, "onTakePhotoFail -----isCustom = $isCustom ")
//语音播报 1上报路况2交通检查3封路 默认 mType 应该为null //语音播报 1上报路况2交通检查3封路 默认 mType 应该为null
if (mType.equals(TANLU_ROAD_CONGESTION) || mType.equals(TANLU_TRAFFIC_CHECK) || mType.equals( if (mType.equals(TANLU_ROAD_CONGESTION) || mType.equals(TANLU_TRAFFIC_CHECK) || mType.equals(
TANLU_ROAD_CLOSURE TANLU_ROAD_CLOSURE
) )
|| mType.equals(TANLU_ROAD_CURRENT) || mType.equals(TANLU_ROAD_PONDING) || mType.equals( || mType.equals(TANLU_ROAD_CURRENT) || mType.equals(TANLU_ROAD_PONDING) || mType.equals(
TANLU_ROAD_ICING TANLU_ROAD_ICING
) )
|| mType.equals(TANLU_ROAD_HEAVY_FOG) || mType.equals(TANLU_ROAD_ACCIDENT) || mType.equals( || mType.equals(TANLU_ROAD_HEAVY_FOG) || mType.equals(TANLU_ROAD_ACCIDENT) || mType.equals(
TANLU_ROAD_WORK TANLU_ROAD_WORK
) )
) { ) {
taskAsync(1_500) { taskAsync(1_500) {
try { try {
@@ -165,28 +173,20 @@ object CarCorderController : TakePhotoCallback, TakeVideoCallback {
//获取图片失败也上报,图片不打点 //获取图片失败也上报,图片不打点
if (isCustom) { if (isCustom) {
CosStatusController().sendInformationDirectly( CosStatusController().sendInformationDirectly(
INFO_TYPE_IMG, INFO_TYPE_IMG,
mutableMapOf("pic" to "" as String), mutableMapOf("pic" to "" as String),
mType, mType,
entity 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?) { override fun onTakePhotoSuccess(photoType: Int, camera: Int, photoPath: String?) {
trackGetPhoto(2) trackGetPhoto(2)
Log.d(TAG, "onTakePhotoSuccess -----mType = $mType") Log.d(TAG, "onTakePhotoSuccess -----mType = $mType --- mainInfoId = $mainInfoId")
val isCustom = CustomStatusHandler.pollPhotoStatus() val isCustom = CustomStatusHandler.pollPhotoStatus()
val entity = TakeEntity(isCustom, 0L) val entity = TakeEntity(isCustom, 0L)
@@ -204,35 +204,37 @@ object CarCorderController : TakePhotoCallback, TakeVideoCallback {
} }
var minSpeedPic = var minSpeedPic =
getStrategyMinSpeed( getStrategyMinSpeed(
AbsMogoApplication.getApp().applicationContext, AbsMogoApplication.getApp().applicationContext,
"pic", "pic",
getStrategyType("pic") getStrategyType("pic")
) )
var maxSpeedPic = var maxSpeedPic =
getStrategyMaxSpeed( getStrategyMaxSpeed(
AbsMogoApplication.getApp().applicationContext, AbsMogoApplication.getApp().applicationContext,
"pic", "pic",
getStrategyType("pic") getStrategyType("pic")
) )
var speed = LocationUtil.getInstance().getSpeed() var speed = LocationUtil.getInstance().getSpeed()
if (!TextUtils.isEmpty(mType)) { if (!TextUtils.isEmpty(mType)) {
Log.d(TAG, "onTakePhotoSuccess mType != null") 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 { } else {
Log.d(TAG, "onTakePhotoSuccess mType == null") Log.d(TAG, "onTakePhotoSuccess mType == null")
Log.d( Log.d(
TAG, TAG,
"onTakePhotoSuccess maxSpeedPic = $maxSpeedPic ---> speed = $speed ---->minSpeedPic= $minSpeedPic" "onTakePhotoSuccess maxSpeedPic = $maxSpeedPic ---> speed = $speed ---->minSpeedPic= $minSpeedPic"
) )
if (maxSpeedPic == -1) { if (maxSpeedPic == -1) {
if (speed >= (Math.abs(minSpeedPic) / 3.6f)) { if (speed >= (Math.abs(minSpeedPic) / 3.6f)) {
Log.d(TAG, "onTakePhotoSuccess abs =" + (Math.abs(minSpeedPic) / 3.6f)) Log.d(TAG, "onTakePhotoSuccess abs =" + (Math.abs(minSpeedPic) / 3.6f))
CosStatusController().uploadFile( CosStatusController().uploadFile(
mutableListOf(photoPath as String), mutableListOf(photoPath as String),
entity, entity,
mType mType,
mainInfoId,
mFromType
) )
} }
} }
@@ -241,9 +243,11 @@ object CarCorderController : TakePhotoCallback, TakeVideoCallback {
Log.d(TAG, "onTakePhotoSuccess minSpeedPic > 0 -- speed = $speed") Log.d(TAG, "onTakePhotoSuccess minSpeedPic > 0 -- speed = $speed")
if ((speed >= (minSpeedPic / 3.6f)) && speed <= (maxSpeedPic / 3.6f)) { if ((speed >= (minSpeedPic / 3.6f)) && speed <= (maxSpeedPic / 3.6f)) {
CosStatusController().uploadFile( CosStatusController().uploadFile(
mutableListOf(photoPath as String), mutableListOf(photoPath as String),
entity, entity,
mType mType,
mainInfoId,
mFromType
) )
} }
} }
@@ -253,11 +257,11 @@ object CarCorderController : TakePhotoCallback, TakeVideoCallback {
//获取视频成功 //获取视频成功
override fun onTakeVideoSuccess(camera: Int, videoPath: String?) { override fun onTakeVideoSuccess(camera: Int, videoPath: String?) {
var thumbnailPath = 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) var isSuccess = getVideoThumbnail(videoPath!!, thumbnailPath)
Log.d( Log.d(
TAG, TAG,
"getVideo onTakeVideoSuccess===$videoPath -----> isSuccess= $isSuccess ----> mType = $mType " "getVideo onTakeVideoSuccess===$videoPath -----> isSuccess= $isSuccess ----> mType = $mType --- mainInfoId = $mainInfoId"
) )
val entity = CustomStatusHandler.pollVideoStatus() val entity = CustomStatusHandler.pollVideoStatus()
@@ -267,12 +271,12 @@ object CarCorderController : TakePhotoCallback, TakeVideoCallback {
if (isSuccess) { if (isSuccess) {
var minSpeedVideo = getStrategyMinSpeed( var minSpeedVideo = getStrategyMinSpeed(
AbsMogoApplication.getApp().applicationContext, "video", AbsMogoApplication.getApp().applicationContext, "video",
getStrategyType("video") getStrategyType("video")
) )
var maxSpeedVideo = getStrategyMaxSpeed( var maxSpeedVideo = getStrategyMaxSpeed(
AbsMogoApplication.getApp().applicationContext, "video", AbsMogoApplication.getApp().applicationContext, "video",
getStrategyType("video") getStrategyType("video")
) )
var speed = LocationUtil.getInstance().getSpeed() var speed = LocationUtil.getInstance().getSpeed()
//TODO //TODO
@@ -286,8 +290,8 @@ object CarCorderController : TakePhotoCallback, TakeVideoCallback {
compressVideo(videoPath, thumbnailPath, entity) compressVideo(videoPath, thumbnailPath, entity)
} else { } else {
Log.d( Log.d(
TAG, TAG,
"onTakeVideoSuccess maxSpeedVideo = $maxSpeedVideo --->speed= $speed + minSpeedVideo = $minSpeedVideo" "onTakeVideoSuccess maxSpeedVideo = $maxSpeedVideo --->speed= $speed + minSpeedVideo = $minSpeedVideo"
) )
if (maxSpeedVideo == -1) { if (maxSpeedVideo == -1) {
Log.d(TAG, "onTakeVideoSuccess 111 abs =" + (Math.abs(minSpeedVideo) / 3.6f)) Log.d(TAG, "onTakeVideoSuccess 111 abs =" + (Math.abs(minSpeedVideo) / 3.6f))
@@ -328,10 +332,11 @@ object CarCorderController : TakePhotoCallback, TakeVideoCallback {
videoAndThumbMap["thumb"] = "" videoAndThumbMap["thumb"] = ""
CosStatusController().sendInformationDirectly( CosStatusController().sendInformationDirectly(
INFO_TYPE_VIDEO, INFO_TYPE_VIDEO,
videoAndThumbMap, videoAndThumbMap,
mType, mType,
entity entity,
mainInfoId
) )
//地图上打点 //地图上打点
@@ -349,26 +354,28 @@ object CarCorderController : TakePhotoCallback, TakeVideoCallback {
*/ */
fun compressVideo(videoPath: String, thumbnailPath: String, entity: TakeEntity) { fun compressVideo(videoPath: String, thumbnailPath: String, entity: TakeEntity) {
Log.d( Log.d(
TAG, TAG,
"outputVideoPath = " + outputVideoPath + ">> videoPath=" + videoPath + " isCustom = ${entity?.isCustom}" "outputVideoPath = " + outputVideoPath + ">> videoPath=" + videoPath + " isCustom = ${entity?.isCustom}"
) )
var startTime = System.currentTimeMillis() var startTime = System.currentTimeMillis()
Thread(Runnable { Thread(Runnable {
try { try {
VideoProcessor.processor(AbsMogoApplication.getApp().applicationContext) VideoProcessor.processor(AbsMogoApplication.getApp().applicationContext)
.input(videoPath) .input(videoPath)
.output(outputVideoPath) .output(outputVideoPath)
.removeAudio(true) .removeAudio(true)
.outWidth(1920) .outWidth(1920)
.outHeight(1080) .outHeight(1080)
.bitrate(2000 * 1024) .bitrate(2000 * 1024)
.frameRate(25) .frameRate(25)
.process() .process()
Log.d(TAG, "compress cost time =" + (System.currentTimeMillis() - startTime)) Log.d(TAG, "compress cost time =" + (System.currentTimeMillis() - startTime))
CosStatusController().uploadFile( CosStatusController().uploadFile(
mutableListOf(outputVideoPath, thumbnailPath), mutableListOf(outputVideoPath, thumbnailPath),
entity, entity,
mType mType,
mainInfoId,
mFromType
) )
//删除压缩前的视频 //删除压缩前的视频
deletePicFile(videoPath) deletePicFile(videoPath)
@@ -392,16 +399,16 @@ object CarCorderController : TakePhotoCallback, TakeVideoCallback {
//获取图片 //获取图片
private fun trackGetPhoto(type: Int) { private fun trackGetPhoto(type: Int) {
trackNormalEvent( trackNormalEvent(
CarNet_Get_Picture, mutableMapOf("type" to type), CarNet_Get_Picture, mutableMapOf("type" to type),
AbsMogoApplication.getApp().applicationContext AbsMogoApplication.getApp().applicationContext
) )
} }
//获取视频 //获取视频
private fun trackGetVideo(type: Int) { private fun trackGetVideo(type: Int) {
trackNormalEvent( trackNormalEvent(
CarNet_Get_Video, mutableMapOf("type" to type), CarNet_Get_Video, mutableMapOf("type" to type),
AbsMogoApplication.getApp().applicationContext AbsMogoApplication.getApp().applicationContext
) )
} }

View File

@@ -41,7 +41,6 @@ object CosCallbackMapController : CosStatusCallback {
path?.let { path?.let {
map.remove(path) map.remove(path)
} }
Log.d(TAG, "size: ${map.size}")
} }
fun unregisterCallbacks(paths: Map<String, String>?) { fun unregisterCallbacks(paths: Map<String, String>?) {

View File

@@ -36,22 +36,26 @@ class CosStatusController : CosStatusCallback {
private lateinit var entity: TakeEntity private lateinit var entity: TakeEntity
private var mType: String = "" private var mType: String = ""
private var mainInfoId: Long = 0
private var mFromType: String = ""
//上传文件 //上传文件
fun uploadFile(picPath: MutableList<String>, entity: TakeEntity, type: String) { fun uploadFile(picPath: MutableList<String>, entity: TakeEntity, type: String, mainInfoId: Long, fromType: String) {
CosCallbackMapController.registerCallback(picPath, this) CosCallbackMapController.registerCallback(picPath, this)
// CosLogger.setLogStatus(true) // CosLogger.setLogStatus(true)
this.entity = entity this.entity = entity
this.mType = type 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) trackUploadCos(3)
if (picPath.contains("backPic")) return if (picPath.contains("backPic")) return
//参数说明: paths本地文件路径上传的本地路径不要重复config文件上传的优先级 //参数说明: paths本地文件路径上传的本地路径不要重复config文件上传的优先级
mPicEventId = mPicEventId =
CosUploadManagerImpl.getInstance(AbsMogoApplication.getApp().applicationContext).eventId CosUploadManagerImpl.getInstance(AbsMogoApplication.getApp().applicationContext).eventId
CosUploadManagerImpl.getInstance(AbsMogoApplication.getApp().applicationContext) 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?) { override fun uploadCosFailed(cosPath: String?, eventId: String?, localPath: String?) {
Log.d(TAG, "uploadCosFailed = $localPath") Log.d(TAG, "uploadCosFailed = $localPath")
Log.d(TAG, "uploadCosFailed CarCorderController.mType = " + CarCorderController.mType)
trackUploadCos(2) trackUploadCos(2)
//语音播报 1上报路况2交通检查3封路 默认 mType 应该为null //语音播报 1上报路况2交通检查3封路 默认 mType 应该为null
if (CarCorderController.mType.equals(TANLU_ROAD_CONGESTION) || CarCorderController.mType.equals( if (CarCorderController.mType.equals(TANLU_ROAD_CONGESTION) || CarCorderController.mType.equals(
TANLU_TRAFFIC_CHECK TANLU_TRAFFIC_CHECK
) || CarCorderController.mType.equals(TANLU_ROAD_CLOSURE) ) || CarCorderController.mType.equals(TANLU_ROAD_CLOSURE)
|| CarCorderController.mType.equals(TANLU_ROAD_CURRENT) || CarCorderController.mType.equals( || CarCorderController.mType.equals(TANLU_ROAD_CURRENT) || CarCorderController.mType.equals(
TANLU_ROAD_PONDING TANLU_ROAD_PONDING
) || CarCorderController.mType.equals(TANLU_ROAD_ICING) ) || CarCorderController.mType.equals(TANLU_ROAD_ICING)
|| CarCorderController.mType.equals(TANLU_ROAD_HEAVY_FOG) || CarCorderController.mType.equals( || CarCorderController.mType.equals(TANLU_ROAD_HEAVY_FOG) || CarCorderController.mType.equals(
TANLU_ROAD_ACCIDENT TANLU_ROAD_ACCIDENT
) || CarCorderController.mType.equals(TANLU_ROAD_WORK) ) || CarCorderController.mType.equals(TANLU_ROAD_WORK)
) { ) {
// VoiceController.speakVoice("cos上报失败") // VoiceController.speakVoice("cos上报失败")
Log.d(TAG, "uploadCosFailed mType = $mType") Log.d(TAG, "uploadCosFailed mType = $mType")
if (entity?.isCustom) { if (entity?.isCustom && mFromType != UPLOAD_FROM_STRATEGY_ACCIDENT_AUTO) {
sendGetInfoFailedReceiver("100") sendGetInfoFailedReceiver("100")
} }
} }
@@ -108,10 +111,10 @@ class CosStatusController : CosStatusCallback {
} }
override fun uploadCosCompleted( override fun uploadCosCompleted(
cosPath: String?, cosPath: String?,
eventId: String?, eventId: String?,
downloadUrl: String?, downloadUrl: String?,
localPath: String? localPath: String?
) { ) {
Log.d(TAG, "uploadFile mType= $mType") Log.d(TAG, "uploadFile mType= $mType")
Log.d(TAG, "uploadCosCompleted localPath = $localPath") Log.d(TAG, "uploadCosCompleted localPath = $localPath")
@@ -130,22 +133,21 @@ class CosStatusController : CosStatusCallback {
Log.d(TAG, "videoAndThumbMap ${videoAndThumbMap}") Log.d(TAG, "videoAndThumbMap ${videoAndThumbMap}")
if (videoAndThumbMap.size == 2) { if (videoAndThumbMap.size == 2) {
Log.d(TAG, "videoAndThumbMap.size == 2 ") Log.d(TAG, "videoAndThumbMap.size == 2 ")
var locationInfo = LocationUtil.getInstance().getLocationInfo() var locationInfo = LocationUtil.getInstance().getLocationInfo()
val locationStr: String = Gson().toJson(locationInfo) val locationStr: String = Gson().toJson(locationInfo)
Log.d(TAG, "locationStr = " + locationStr) Log.d(TAG, "locationStr = " + locationStr)
//如果失败,需要提示失败弹框 //如果失败,需要提示失败弹框
if (locationInfo.address.isNullOrEmpty() || locationInfo.cityName.isNullOrEmpty() || locationInfo.cityCode.isNullOrEmpty() if (locationInfo.address.isNullOrEmpty() || locationInfo.cityName.isNullOrEmpty() || locationInfo.cityCode.isNullOrEmpty()
|| locationInfo.latitude == 0.0 || locationInfo.areaName.isNullOrEmpty() || locationInfo.street.isNullOrEmpty() || locationInfo.latitude == 0.0 || locationInfo.areaName.isNullOrEmpty() || locationInfo.street.isNullOrEmpty()
|| locationInfo.areaCode.isNullOrEmpty() || locationInfo.provinceName.isNullOrEmpty() || locationInfo.areaCode.isNullOrEmpty() || locationInfo.provinceName.isNullOrEmpty()
) { ) {
if (entity?.isCustom) { if (entity?.isCustom && mFromType != UPLOAD_FROM_STRATEGY_ACCIDENT_AUTO) {
sendGetInfoFailedReceiver("100") sendGetInfoFailedReceiver("100")
} }
} else { } else {
//分享成功并打点如果是上报拥堵需要takeVideo //分享成功并打点如果是上报拥堵需要takeVideo
LatLngStickyEventBus.getInstance() LatLngStickyEventBus.getInstance()
.postSticky(GetImageSuccessEvent(downloadUrl, mType)) .postSticky(GetImageSuccessEvent(downloadUrl, mType))
//上传录像以及缩略图成功 //上传录像以及缩略图成功
sendInformation(INFO_TYPE_VIDEO, videoAndThumbMap) sendInformation(INFO_TYPE_VIDEO, videoAndThumbMap)
} }
@@ -155,10 +157,11 @@ class CosStatusController : CosStatusCallback {
Log.d(TAG, "uploadCosCompleted 分享成功 ----mType = $mType") Log.d(TAG, "uploadCosCompleted 分享成功 ----mType = $mType")
// if (mType.equals("1") || mType.equals("-1")) { // if (mType.equals("1") || mType.equals("-1")) {
sendInformationDirectly( sendInformationDirectly(
INFO_TYPE_IMG, INFO_TYPE_IMG,
mutableMapOf("pic" to downloadUrl as String), mutableMapOf("pic" to downloadUrl as String),
mType, mType,
entity entity,
mainInfoId
) )
// } // }
} }
@@ -174,7 +177,7 @@ class CosStatusController : CosStatusCallback {
// CosCallbackMapController.mainService?.sendCustomResult(it) // CosCallbackMapController.mainService?.sendCustomResult(it)
// } // }
// } else { // } else {
sendInformationDirectly(type, map, mType, entity) sendInformationDirectly(type, map, mType, entity, mainInfoId)
// } // }
} }
@@ -182,18 +185,20 @@ class CosStatusController : CosStatusCallback {
* 被动上报时直接上报,不用等待、选择情报类型 * 被动上报时直接上报,不用等待、选择情报类型
*/ */
fun sendInformationDirectly( fun sendInformationDirectly(
type: Int, type: Int,
map: Map<String, String>, map: Map<String, String>,
poiType: String, poiType: String,
entity: TakeEntity entity: TakeEntity,
mainInfoId: Long
) { ) {
Log.d(TAG, "sendInformationDirectly isCustomSend = ${entity?.isCustom}") Log.d(TAG, "sendInformationDirectly isCustomSend = ${entity?.isCustom}")
Log.d(TAG, "sendInformationDirectly poiType= $poiType") Log.d(TAG, "sendInformationDirectly poiType= $poiType ---- mainInfoId= $mainInfoId")
mainServiceHttpModel.sendInformationMessage( mainServiceHttpModel.sendInformationMessage(
type = type, type = type,
url = map, url = map,
isCustom = entity?.isCustom, isCustom = entity?.isCustom,
poiType = poiType poiType = poiType,
mainInfoId = mainInfoId
) { success -> ) { success ->
CosCallbackMapController.unregisterCallbacks(map) CosCallbackMapController.unregisterCallbacks(map)
CosCallbackMapController.mainService?.let { CosCallbackMapController.mainService?.let {
@@ -208,8 +213,8 @@ class CosStatusController : CosStatusCallback {
//上传COS //上传COS
private fun trackUploadCos(type: Int) { private fun trackUploadCos(type: Int) {
trackNormalEvent( trackNormalEvent(
CarNet_Cos_Upload, mutableMapOf("type" to type), CarNet_Cos_Upload, mutableMapOf("type" to type),
AbsMogoApplication.getApp().applicationContext AbsMogoApplication.getApp().applicationContext
) )
} }

View File

@@ -61,7 +61,7 @@ class MainService : Service() {
var isCustom: Boolean = false var isCustom: Boolean = false
var params: UploadParams? = null var params: UploadParams? = null
var mainInfoId: Long = 0
//发送主动上报结果广播给外部 //发送主动上报结果广播给外部
fun sendCustomResult(result: Boolean) { fun sendCustomResult(result: Boolean) {
@@ -73,12 +73,9 @@ class MainService : Service() {
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int { override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
Log.d(TAG, "onStartCommand -----------> ") Log.d(TAG, "onStartCommand -----------> ")
//清理多媒体资源和sp策略数据 //清理多媒体资源和sp策略数据
// DelayService.launchService(this)
clearStrategyType(this) clearStrategyType(this)
//初始化埋点 //初始化埋点
Analytics.getInstance().start(this) Analytics.getInstance().start(this)
//初始化定位
// LocationUtil.getInstance().initLocation()
//参数说明appKey: app唯一标识比如包名 //参数说明appKey: app唯一标识比如包名
CosUploadManagerImpl.getInstance(AbsMogoApplication.getApp().applicationContext) CosUploadManagerImpl.getInstance(AbsMogoApplication.getApp().applicationContext)
.init(BuildConfig.APPLICATION_ID, 2) .init(BuildConfig.APPLICATION_ID, 2)
@@ -90,13 +87,14 @@ class MainService : Service() {
params?.let { params?.let {
shareType = it.eventType shareType = it.eventType
fromType = it.fromType fromType = it.fromType
mainInfoId = 0 //TODO
Log.d(TAG, "onStartCommand shareType = $shareType") Log.d(TAG, "onStartCommand shareType = $shareType")
if (shareType == TANLU_ROAD_CONGESTION || shareType == TANLU_TRAFFIC_CHECK || shareType == TANLU_ROAD_CLOSURE || shareType == TANLU_ROAD_CURRENT 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_PONDING || shareType == TANLU_ROAD_ICING || shareType == TANLU_ROAD_HEAVY_FOG
|| shareType == TANLU_ROAD_ACCIDENT || shareType == TANLU_ROAD_WORK || shareType == TANLU_ROAD_ACCIDENT || shareType == TANLU_ROAD_WORK
) { ) {
// takePhoto(1, false, true) // takePhoto(1, false, true)
if (!fromType.equals("5")) { // 是策略触发,不提示 if (!fromType.equals(UPLOAD_FROM_STRATEGY_ACCIDENT_AUTO)) { // 是策略触发,不提示
takeVideo(it.duration, isCustom = true, id = id) takeVideo(it.duration, isCustom = true, id = id)
} else { } else {
takeVideo(it.duration) takeVideo(it.duration)
@@ -124,12 +122,6 @@ class MainService : Service() {
var duration = p1.getIntExtra("duration", 3) var duration = p1.getIntExtra("duration", 3)
takeVideo(duration, true) 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? { override fun onBind(intent: Intent?): IBinder? {
return null return null
} }
@@ -159,7 +143,6 @@ class MainService : Service() {
override fun onCreate() { override fun onCreate() {
super.onCreate() super.onCreate()
Log.d(TAG, "onCreate ------> 1")
init() init()
//初始化定位 //初始化定位
LocationUtil.getInstance().initLocation() LocationUtil.getInstance().initLocation()
@@ -295,7 +278,7 @@ class MainService : Service() {
Observable.intervalRange(0, 1, 0, 2_000, TimeUnit.MILLISECONDS) Observable.intervalRange(0, 1, 0, 2_000, TimeUnit.MILLISECONDS)
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribe(Consumer { .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---->") Log.d("MainService", "takeVideo --------1---->")
// if (isAuthorization(BaseApplication.getAppContext())) { // if (isAuthorization(BaseApplication.getAppContext())) {
// log(TAG, "takeVideo --------2---->") // 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) postVideoAlarmTask(isInterval)

View File

@@ -226,16 +226,17 @@ class MainServiceController {
trafficInfoType:String = "", trafficInfoType:String = "",
isShare:Boolean = false, isShare:Boolean = false,
poiType:String, poiType:String,
mainInfoId:Long,
customSend: ((Boolean) -> Unit)? = null customSend: ((Boolean) -> Unit)? = null
) { ) {
Log.d(TAG, " sendInformationMessage poiType = $poiType"); Log.d(TAG, " sendInformationMessage poiType = $poiType");
//删除测试数据 //删除测试数据
var locationInfo = LocationUtil.getInstance().getLocationInfo(); var locationInfo = LocationUtil.getInstance().getLocationInfo();
if (locationInfo.address.isNullOrEmpty()) { if (locationInfo.address.isNullOrEmpty()) {
geoLocation(type, url, locationInfo, isCustom,trafficInfoType, isShare, customSend,poiType) geoLocation(type, url, locationInfo, isCustom,trafficInfoType, isShare, customSend,poiType,mainInfoId)
} else { } else {
postInformationMessage( postInformationMessage(
getInformationBody(type, url, locationInfo, isCustom, trafficInfoType, isShare,poiType), getInformationBody(type, url, locationInfo, isCustom, trafficInfoType, isShare,poiType,mainInfoId),
customSend customSend
) )
} }
@@ -251,19 +252,20 @@ class MainServiceController {
trafficInfoType:String, trafficInfoType:String,
isShare: Boolean, isShare: Boolean,
customSend: ((Boolean) -> Unit)? = null, customSend: ((Boolean) -> Unit)? = null,
poiType: String poiType: String,
mainInfoId: Long
) { ) {
Log.d(TAG, " geoLocation -- poiType = $poiType"); Log.d(TAG, " geoLocation -- poiType = $poiType");
LocationUtil.getInstance() LocationUtil.getInstance()
.geoCodeLocation(locationInfo.toLatLngPoint(), { locInfo: LocationInfo -> .geoCodeLocation(locationInfo.toLatLngPoint(), { locInfo: LocationInfo ->
postInformationMessage( postInformationMessage(
getInformationBody(type, url, locationInfo, isCustom, trafficInfoType, isShare, poiType), getInformationBody(type, url, locationInfo, isCustom, trafficInfoType, isShare, poiType,mainInfoId),
customSend customSend
) )
}, { }, {
//转换失败的情况下再重试一次 //转换失败的情况下再重试一次
geoRetryed = if (!geoRetryed) { geoRetryed = if (!geoRetryed) {
geoLocation(type, url, locationInfo, isCustom, trafficInfoType, isShare, customSend, poiType) geoLocation(type, url, locationInfo, isCustom, trafficInfoType, isShare, customSend, poiType,mainInfoId)
true true
} else { } else {
false false

View File

@@ -28,7 +28,8 @@ fun getInformationBody(
isCustom: Boolean, isCustom: Boolean,
trafficInfoType:String = "", trafficInfoType:String = "",
isShare:Boolean, isShare:Boolean,
poiType: String poiType: String,
mainInfoId: Long
): InformationBody { ): InformationBody {
var jsonArray = JsonArray() var jsonArray = JsonArray()
var type: Int var type: Int
@@ -65,7 +66,8 @@ fun getInformationBody(
trafficInfoType, trafficInfoType,
isShare, isShare,
locationInfo.direction, locationInfo.direction,
poiType poiType,
mainInfoId
) )
} }