This commit is contained in:
lixiaopeng
2020-10-21 15:10:14 +08:00
parent 1d80b8145e
commit eedede61d1
7 changed files with 41 additions and 23 deletions

View File

@@ -58,7 +58,7 @@ class StrategyServiceModel : BaseRepository() {
// }
// }
suspend fun uploadInformation(informationBody: InformationBody): BaseResponse<Any> {
suspend fun uploadInformation(informationBody: InformationBody): BaseResponse<UploadResult> {
return apiCall {
var informationBodyStr = Gson().toJson(informationBody)
Log.d("MainServiceController", "uploadInformation informationBody = " + informationBodyStr)

View File

@@ -0,0 +1,8 @@
package com.zhidao.roadcondition.model
/**
* 上报成功返回
*/
class UploadResult(var id: Long) {
}

View File

@@ -3,6 +3,7 @@ package com.zhidao.roadcondition.net
import com.zhidao.roadcondition.model.BaseResponse
import com.zhidao.roadcondition.model.CommonConfig
import com.zhidao.roadcondition.model.Results
import com.zhidao.roadcondition.model.UploadResult
import okhttp3.MultipartBody
import okhttp3.ResponseBody
import retrofit2.http.*
@@ -19,7 +20,7 @@ interface HttpApi {
//上报情报数据
@FormUrlEncoded
@POST("/deva/car/path/no/addInfomation/v2")
suspend fun uploadInformation(@FieldMap information: Map<String, String>): BaseResponse<Any>
suspend fun uploadInformation(@FieldMap information: Map<String, String>): BaseResponse<UploadResult>
//获取所有配置
@GET("dataService/car/customConfig/no/getAll/v1")

View File

@@ -203,6 +203,7 @@ class CosStatusController : CosStatusCallback {
//开始上传
entity?.isCustom?.let {
mainServiceHttpModel.sendInformationMessage(
fromType = mFromType,
type = type,
url = map,
isCustom = it,
@@ -227,15 +228,14 @@ class CosStatusController : CosStatusCallback {
}
}
} else {
// if (type == INFO_TYPE_VIDEO) {
// TipToast.shortTip("分享失败,请检查网络")
// }
}
}
}
}
override fun onProgress(localPath: String?, progress: Float) {
}

View File

@@ -218,16 +218,6 @@ class MainService : Service() {
// sendBroadcast(intent)
}
private fun sendUgcStatusReceiver(id: String?, type: String?, fromType: String?) {
Log.e("MainService", "sendUgcStatusReceiver ----> id = $id ---type = $type --fromType = $fromType ")
var intent = Intent()
intent.action = "com.zhidao.roadcondition.marker.info"
intent.putExtra("id", id)
intent.putExtra("type", type)
intent.putExtra("fromType", fromType)
sendBroadcast(intent)
}
/**
* 初始化定位监听
*/

View File

@@ -1,11 +1,9 @@
package com.zhidao.roadcondition.service
import android.content.Intent
import android.util.Log
import com.mogo.commons.AbsMogoApplication
import com.zhidao.roadcondition.event.GetImageSuccessEvent
import com.zhidao.roadcondition.event.LatLngStickyEventBus
import com.zhidao.roadcondition.model.*
import com.zhidao.roadcondition.model.proxy.INFO_TYPE_VIDEO
import com.zhidao.roadcondition.net.request
import com.zhidao.roadcondition.util.*
import com.zhidao.roadcondition.util.StrategyPreferenceUtil.Companion.setStrategyFrequency
@@ -25,6 +23,8 @@ class MainServiceController {
//逆地理编码是否重试
private var geoRetryed = false
private var mFromType: String = ""
private var mPoiType: String = ""
private val strategyeModel by lazy { StrategyServiceModel() }
@@ -224,6 +224,7 @@ class MainServiceController {
//上传情报数据
fun sendInformationMessage(
type: Int,
fromType: String,
url: Map<String, String>,
isCustom: Boolean = false,
trafficInfoType:String = "",
@@ -234,7 +235,10 @@ class MainServiceController {
latitude: Double,
customSend: ((Boolean) -> Unit)? = null
) {
Log.d(TAG, " sendInformationMessage poiType = $poiType")
Log.d(TAG, " sendInformationMessage poiType = $poiType -- fromType = $fromType")
mFromType = fromType
mPoiType = poiType
//删除测试数据
var locationInfo = LocationUtil.getInstance().getLocationInfo()
if (locationInfo.address.isNullOrEmpty()) {
@@ -297,12 +301,16 @@ class MainServiceController {
customSend: ((Boolean) -> Unit)? = null
) {
trackUploadServer(3)
request<BaseResponse<Any>> {
request<BaseResponse<UploadResult>> {
loader {
strategyeModel.uploadInformation(informationBody)
}
onSuccess {
Log.i(TAG, "upload message success ")
if (it.result != null) {
Log.i(TAG, "upload message success id" + it.result.id)
sendUgcStatusReceiver(it.result.id, mPoiType, mFromType)
}
trackUploadServer(1)
// CosStatusController().videoAndThumbMap.clear()
customSend?.invoke(true)
@@ -310,12 +318,23 @@ class MainServiceController {
onError {
Log.i(TAG, "$it upload message ${it.message}")
trackUploadServer(2)
sendUgcStatusReceiver(0, mPoiType, mFromType)
// CosStatusController().videoAndThumbMap.clear()
customSend?.invoke(false)
}
}
}
private fun sendUgcStatusReceiver(id: Long, type: String?, fromType: String?) {
Log.e(TAG, "sendUgcStatusReceiver ----> id = $id ---type = $type --fromType = $fromType ")
var intent = Intent()
intent.action = "com.v2x.ugc.upload.status"
intent.putExtra("id", id)
intent.putExtra("type", type)
intent.putExtra("fromType", fromType)
AbsMogoApplication.getApp().applicationContext.sendBroadcast(intent)
}
//上传服务器
private fun trackUploadServer(type: Int) {
trackNormalEvent(

View File

@@ -3,6 +3,7 @@ package com.mogo.module.v2x.receiver
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.util.Log
/**
* ugc上报反馈
@@ -10,11 +11,10 @@ import android.content.Intent
class UgcUploadStatusReceiver : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
if (intent.action == "com.v2x.ugc.upload.status"){
var id = intent.getStringExtra("id")
var id = intent.getLongExtra("id", 0)
var type = intent.getStringExtra("type")
var fromType = intent.getStringExtra("fromType")
}
}
}