优化运行日志上传
This commit is contained in:
parent
37924fa2b5
commit
421517c248
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,2 +1,2 @@
|
||||||
#Mon Mar 04 15:33:52 GMT+08:00 2024
|
#Tue Jun 25 17:25:11 GMT+08:00 2024
|
||||||
gradle.version=5.6.4
|
gradle.version=5.6.4
|
||||||
|
|
Binary file not shown.
|
@ -21,8 +21,8 @@ android {
|
||||||
applicationId "net.sysolution.taxiapp"
|
applicationId "net.sysolution.taxiapp"
|
||||||
minSdkVersion 21
|
minSdkVersion 21
|
||||||
targetSdkVersion 29
|
targetSdkVersion 29
|
||||||
versionCode 256
|
versionCode 257
|
||||||
versionName "3.3.3-beta26.4.1.5-release"
|
versionName "3.3.3-beta26.4.1.4-release"
|
||||||
|
|
||||||
//alphaxx - 预览版本,不会对外发布,由测试人员测试,会有很多bug
|
//alphaxx - 预览版本,不会对外发布,由测试人员测试,会有很多bug
|
||||||
//Betaxx - 公开测试版本,会发给其他工作人员,会有较多版本
|
//Betaxx - 公开测试版本,会发给其他工作人员,会有较多版本
|
||||||
|
|
|
@ -256,11 +256,13 @@ object ProcessingCommands {
|
||||||
// val endRuntime = Configurations.config(TaxiApp.instance()).endRunTime()
|
// val endRuntime = Configurations.config(TaxiApp.instance()).endRunTime()
|
||||||
val todaySumRunTime = Configurations.config(TaxiApp.instance()).todaySumRunTime()
|
val todaySumRunTime = Configurations.config(TaxiApp.instance()).todaySumRunTime()
|
||||||
"getTodayRuntime-->当天taxiApp运行时间:$todaySumRunTime".logd()
|
"getTodayRuntime-->当天taxiApp运行时间:$todaySumRunTime".logd()
|
||||||
|
// val sumTimeList = DaoUtil.getRunTimeDao().queryBuilder().where(
|
||||||
|
// RunTimeDataDao.Properties.IsUpload.eq(0)).list()
|
||||||
sanleResponse.type = type
|
sanleResponse.type = type
|
||||||
sanleResponse.id = baseResponse.id
|
sanleResponse.id = baseResponse.id
|
||||||
sanleResponse.task_id = baseResponse.task_id
|
sanleResponse.task_id = baseResponse.task_id
|
||||||
sanleResponse.runtime = todaySumRunTime
|
sanleResponse.runtime = todaySumRunTime
|
||||||
|
// sanleResponse.runtime = sumTimeList.size.toLong()
|
||||||
val response = gson.toJson(sanleResponse)
|
val response = gson.toJson(sanleResponse)
|
||||||
send(response)
|
send(response)
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,32 +69,36 @@ object EasyHttpTool {
|
||||||
if (!sumTimeList.isNullOrEmpty()){
|
if (!sumTimeList.isNullOrEmpty()){
|
||||||
|
|
||||||
for (runTimeData in sumTimeList) {
|
for (runTimeData in sumTimeList) {
|
||||||
val runtimeJson = RuntimeJson(runTimeData.cardId,runTimeData.sumRuntime,runTimeData.startRuntime)
|
|
||||||
val runtimeJsonStr = Gson().toJson(runtimeJson)
|
|
||||||
"提交运行时长sendRunTimeToServer:$runtimeJsonStr".logd()
|
|
||||||
val parse = ("application/json;charset=UTF-8").toMediaTypeOrNull()
|
|
||||||
val body = RequestBody.create(parse, runtimeJsonStr)
|
|
||||||
EasyHttp.post(Configurations.config(TaxiApp.instance()).logServiceUrl() + "postRunningTimeLog")
|
|
||||||
.readTimeOut(80*1000)
|
|
||||||
.writeTimeOut(80*1000)
|
|
||||||
.connectTimeout(80*1000)
|
|
||||||
.headers("Authorization", "Bearer ${Configurations.config(TaxiApp.instance()).appToken()}")
|
|
||||||
.headers("Accept-Encoding", "gzip")
|
|
||||||
.requestBody(body)
|
|
||||||
.retryCount(1)//本次请求重试次数
|
|
||||||
.retryDelay(1000)//本次请求重试延迟时间1000ms
|
|
||||||
.execute(object :SimpleCallBack<String>(){
|
|
||||||
override fun onError(e: ApiException?) {
|
|
||||||
"上传运行时长失败:${e?.message}".loge()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onSuccess(t: String?) {
|
sendRunLogToServer(runTimeData)
|
||||||
"上传运行时长成功:${t}".loge()
|
|
||||||
runTimeData.isUpload = 1
|
// val runtimeJson = RuntimeJson(runTimeData.cardId,runTimeData.sumRuntime,runTimeData.startRuntime)
|
||||||
DaoUtil.getRunTimeDao().update(runTimeData)
|
// val runtimeJsonStr = Gson().toJson(runtimeJson)
|
||||||
"将提交的runTimeData标记成已上传".logd()
|
// "提交运行时长sendRunTimeToServer:$runtimeJsonStr".logd()
|
||||||
}
|
// val parse = ("application/json;charset=UTF-8").toMediaTypeOrNull()
|
||||||
})
|
// val body = RequestBody.create(parse, runtimeJsonStr)
|
||||||
|
|
||||||
|
// EasyHttp.post(Configurations.config(TaxiApp.instance()).logServiceUrl() + "postRunningTimeLog")
|
||||||
|
// .readTimeOut(80*1000)
|
||||||
|
// .writeTimeOut(80*1000)
|
||||||
|
// .connectTimeout(80*1000)
|
||||||
|
// .headers("Authorization", "Bearer ${Configurations.config(TaxiApp.instance()).appToken()}")
|
||||||
|
// .headers("Accept-Encoding", "gzip")
|
||||||
|
// .requestBody(body)
|
||||||
|
// .retryCount(1)//本次请求重试次数
|
||||||
|
// .retryDelay(1000)//本次请求重试延迟时间1000ms
|
||||||
|
// .execute(object :SimpleCallBack<String>(){
|
||||||
|
// override fun onError(e: ApiException?) {
|
||||||
|
// "上传运行时长失败:${e?.message}".loge()
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// override fun onSuccess(t: String?) {
|
||||||
|
// "上传运行时长成功:${t}".loge()
|
||||||
|
// runTimeData.isUpload = 1
|
||||||
|
// DaoUtil.getRunTimeDao().update(runTimeData)
|
||||||
|
// "将提交的runTimeData标记成已上传".logd()
|
||||||
|
// }
|
||||||
|
// })
|
||||||
}
|
}
|
||||||
|
|
||||||
// val lists:List<RuntimeJson> = sumTimeList.map {
|
// val lists:List<RuntimeJson> = sumTimeList.map {
|
||||||
|
@ -108,6 +112,42 @@ object EasyHttpTool {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 上传1条运行日志
|
||||||
|
*/
|
||||||
|
fun sendRunLogToServer(runTimeData:RunTimeData){
|
||||||
|
// val logJson = ProcessingCommands.gson.toJson(dbPlayerLogs)
|
||||||
|
val runtimeJson = RuntimeJson(runTimeData.cardId,runTimeData.sumRuntime,runTimeData.startRuntime)
|
||||||
|
val runtimeJsonStr = Gson().toJson(runtimeJson)
|
||||||
|
"提交运行时长sendRunTimeToServer:$runtimeJsonStr".logd()
|
||||||
|
val parse = ("application/json;charset=UTF-8").toMediaTypeOrNull()
|
||||||
|
val body = RequestBody.create(parse, runtimeJsonStr)
|
||||||
|
val url = Configurations.config(TaxiApp.instance()).logServiceUrl() + "postRunningTimeLog"
|
||||||
|
|
||||||
|
try {
|
||||||
|
val request = Request.Builder()
|
||||||
|
.url(url)
|
||||||
|
.addHeader("Authorization","Bearer ${Configurations.config(TaxiApp.instance()).appToken()}")
|
||||||
|
.addHeader("Accept-Encoding","gzip")
|
||||||
|
.post(body)
|
||||||
|
.build()
|
||||||
|
val response = OkHttpTool.getInstance().client.newCall(request).execute()
|
||||||
|
"response code:${response?.code}".logd()
|
||||||
|
"response body:${response?.body?.string().toString()}".logd()
|
||||||
|
if (response.isSuccessful){
|
||||||
|
"上传运行时长成功".loge()
|
||||||
|
runTimeData.isUpload = 1
|
||||||
|
DaoUtil.getRunTimeDao().update(runTimeData)
|
||||||
|
"将提交的runTimeData标记成已上传".logd()
|
||||||
|
} else {
|
||||||
|
"上传运行时长失败".loge()
|
||||||
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
"上传运行时长失败:${e?.message}".loge()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 提交日志摘要
|
* 提交日志摘要
|
||||||
|
@ -229,4 +269,5 @@ object EasyHttpTool {
|
||||||
// })
|
// })
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -236,14 +236,16 @@ class PlayActivity : AppCompatActivity(), NetworkCallback, BusCallback, OnScreen
|
||||||
DaoUtil.getRunTimeDao().insert(runTimeData)
|
DaoUtil.getRunTimeDao().insert(runTimeData)
|
||||||
}
|
}
|
||||||
|
|
||||||
//提交未上传的运行时长数据
|
|
||||||
EasyHttpTool.sendRunTimeToServer()
|
|
||||||
|
|
||||||
//重新初始化startRunTime为当前启动时间,sumRuntime为0
|
//重新初始化startRunTime为当前启动时间,sumRuntime为0
|
||||||
configurations.startRunTimeSave(currentTime)
|
configurations.startRunTimeSave(currentTime)
|
||||||
configurations.sumRunTimeSave(0)
|
configurations.sumRunTimeSave(0)
|
||||||
//开启定时器,让sumRunTime累加
|
//开启定时器,让sumRunTime累加
|
||||||
startSaveSumTimer()
|
startSaveSumTimer()
|
||||||
|
|
||||||
|
//提交未上传的运行时长数据
|
||||||
|
EasyHttpTool.sendRunTimeToServer()
|
||||||
//跳出循环
|
//跳出循环
|
||||||
break
|
break
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -4,5 +4,5 @@
|
||||||
# Location of the SDK. This is only used by Gradle.
|
# Location of the SDK. This is only used by Gradle.
|
||||||
# For customization when using a Version Control System, please read the
|
# For customization when using a Version Control System, please read the
|
||||||
# header note.
|
# header note.
|
||||||
#Tue May 21 14:20:34 GMT+08:00 2024
|
#Tue Jun 25 17:11:45 GMT+08:00 2024
|
||||||
sdk.dir=D\:\\Android\\sdk
|
sdk.dir=D\:\\Android\\sdk
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":256,"versionName":"3.3.3-beta26.4.1.5-release","enabled":true,"outputFile":"TaxiApp_v3.3.3-beta26.4.1.5-release{256}.apk","fullName":"release","baseName":"release","dirName":""},"path":"TaxiApp_v3.3.3-beta26.4.1.5-release{256}.apk","properties":{}}]
|
[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":257,"versionName":"3.3.3-beta26.4.1.4-release","enabled":true,"outputFile":"TaxiApp_v3.3.3-beta26.4.1.4-release{257}.apk","fullName":"release","baseName":"release","dirName":""},"path":"TaxiApp_v3.3.3-beta26.4.1.4-release{257}.apk","properties":{}}]
|
Loading…
Reference in New Issue
Block a user