支持实时查询当天运行时长,提交前一天的运行时长到平台

This commit is contained in:
刘金华 2023-11-17 15:09:43 +08:00
parent 8cbb511dd6
commit 0f9e99fb8c
34 changed files with 492 additions and 32 deletions

View File

@ -13,6 +13,9 @@
<root url="jar://$USER_HOME$/.gradle/caches/transforms-2/files-2.1/f63e4fd5225727d5c297261b711d695d/jetified-debug-db-base-1.0.6/jars/classes.jar!/" /> <root url="jar://$USER_HOME$/.gradle/caches/transforms-2/files-2.1/f63e4fd5225727d5c297261b711d695d/jetified-debug-db-base-1.0.6/jars/classes.jar!/" />
<root url="file://$USER_HOME$/.gradle/caches/transforms-2/files-2.1/f63e4fd5225727d5c297261b711d695d/jetified-debug-db-base-1.0.6/res" /> <root url="file://$USER_HOME$/.gradle/caches/transforms-2/files-2.1/f63e4fd5225727d5c297261b711d695d/jetified-debug-db-base-1.0.6/res" />
<root url="file://$USER_HOME$/.gradle/caches/transforms-2/files-2.1/f63e4fd5225727d5c297261b711d695d/jetified-debug-db-base-1.0.6/AndroidManifest.xml" /> <root url="file://$USER_HOME$/.gradle/caches/transforms-2/files-2.1/f63e4fd5225727d5c297261b711d695d/jetified-debug-db-base-1.0.6/AndroidManifest.xml" />
<root url="file://$USER_HOME$/.gradle/caches/transforms-2/files-2.1/ad67766727e8b516aa8b11db6408390f/jetified-debug-db-base-1.0.6/res" />
<root url="file://$USER_HOME$/.gradle/caches/transforms-2/files-2.1/ad67766727e8b516aa8b11db6408390f/jetified-debug-db-base-1.0.6/AndroidManifest.xml" />
<root url="jar://$USER_HOME$/.gradle/caches/transforms-2/files-2.1/ad67766727e8b516aa8b11db6408390f/jetified-debug-db-base-1.0.6/jars/classes.jar!/" />
</CLASSES> </CLASSES>
<JAVADOC> <JAVADOC>
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.amitshekhar.android/debug-db-base/1.0.6/43c6abb777258b8e02b7a4f4aef44f5996ddf30f/debug-db-base-1.0.6-javadoc.jar!/" /> <root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.amitshekhar.android/debug-db-base/1.0.6/43c6abb777258b8e02b7a4f4aef44f5996ddf30f/debug-db-base-1.0.6-javadoc.jar!/" />

View File

@ -5,6 +5,7 @@
<root url="jar://$USER_HOME$/.gradle/caches/transforms-2/files-2.1/fce90db6a21dd6386ea645855f8dd306/jetified-stetho-1.5.1/annotations.zip!/" /> <root url="jar://$USER_HOME$/.gradle/caches/transforms-2/files-2.1/fce90db6a21dd6386ea645855f8dd306/jetified-stetho-1.5.1/annotations.zip!/" />
<root url="jar://$USER_HOME$/.gradle/caches/transforms-2/files-2.1/62035fcaa1eb865fcb157c3556d5e2c8/jetified-stetho-1.5.1/annotations.zip!/" /> <root url="jar://$USER_HOME$/.gradle/caches/transforms-2/files-2.1/62035fcaa1eb865fcb157c3556d5e2c8/jetified-stetho-1.5.1/annotations.zip!/" />
<root url="jar://$USER_HOME$/.gradle/caches/transforms-2/files-2.1/ad36d5a34233c7fa29ad3770971d35c6/jetified-stetho-1.5.1/annotations.zip!/" /> <root url="jar://$USER_HOME$/.gradle/caches/transforms-2/files-2.1/ad36d5a34233c7fa29ad3770971d35c6/jetified-stetho-1.5.1/annotations.zip!/" />
<root url="jar://$USER_HOME$/.gradle/caches/transforms-2/files-2.1/4d8a2b6516214c37dd58d58e9a7f5172/jetified-stetho-1.5.1/annotations.zip!/" />
</ANNOTATIONS> </ANNOTATIONS>
<CLASSES> <CLASSES>
<root url="jar://$USER_HOME$/.gradle/caches/transforms-2/files-2.1/d20b09848ce936fd0a38f787548625fb/jetified-stetho-1.5.1/jars/classes.jar!/" /> <root url="jar://$USER_HOME$/.gradle/caches/transforms-2/files-2.1/d20b09848ce936fd0a38f787548625fb/jetified-stetho-1.5.1/jars/classes.jar!/" />
@ -19,6 +20,9 @@
<root url="file://$USER_HOME$/.gradle/caches/transforms-2/files-2.1/ad36d5a34233c7fa29ad3770971d35c6/jetified-stetho-1.5.1/res" /> <root url="file://$USER_HOME$/.gradle/caches/transforms-2/files-2.1/ad36d5a34233c7fa29ad3770971d35c6/jetified-stetho-1.5.1/res" />
<root url="file://$USER_HOME$/.gradle/caches/transforms-2/files-2.1/ad36d5a34233c7fa29ad3770971d35c6/jetified-stetho-1.5.1/AndroidManifest.xml" /> <root url="file://$USER_HOME$/.gradle/caches/transforms-2/files-2.1/ad36d5a34233c7fa29ad3770971d35c6/jetified-stetho-1.5.1/AndroidManifest.xml" />
<root url="jar://$USER_HOME$/.gradle/caches/transforms-2/files-2.1/ad36d5a34233c7fa29ad3770971d35c6/jetified-stetho-1.5.1/jars/classes.jar!/" /> <root url="jar://$USER_HOME$/.gradle/caches/transforms-2/files-2.1/ad36d5a34233c7fa29ad3770971d35c6/jetified-stetho-1.5.1/jars/classes.jar!/" />
<root url="file://$USER_HOME$/.gradle/caches/transforms-2/files-2.1/4d8a2b6516214c37dd58d58e9a7f5172/jetified-stetho-1.5.1/AndroidManifest.xml" />
<root url="file://$USER_HOME$/.gradle/caches/transforms-2/files-2.1/4d8a2b6516214c37dd58d58e9a7f5172/jetified-stetho-1.5.1/res" />
<root url="jar://$USER_HOME$/.gradle/caches/transforms-2/files-2.1/4d8a2b6516214c37dd58d58e9a7f5172/jetified-stetho-1.5.1/jars/classes.jar!/" />
</CLASSES> </CLASSES>
<JAVADOC> <JAVADOC>
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.facebook.stetho/stetho/1.5.1/b71856fcb682e807ccec3a276e47c94944b6c6ea/stetho-1.5.1-javadoc.jar!/" /> <root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.facebook.stetho/stetho/1.5.1/b71856fcb682e807ccec3a276e47c94944b6c6ea/stetho-1.5.1-javadoc.jar!/" />

View File

@ -13,6 +13,9 @@
<root url="jar://$USER_HOME$/.gradle/caches/transforms-2/files-2.1/504fa6dae581171f07ee211f50cf11a5/jetified-GreenDaoUpgradeHelper-v2.2.1/jars/classes.jar!/" /> <root url="jar://$USER_HOME$/.gradle/caches/transforms-2/files-2.1/504fa6dae581171f07ee211f50cf11a5/jetified-GreenDaoUpgradeHelper-v2.2.1/jars/classes.jar!/" />
<root url="file://$USER_HOME$/.gradle/caches/transforms-2/files-2.1/504fa6dae581171f07ee211f50cf11a5/jetified-GreenDaoUpgradeHelper-v2.2.1/res" /> <root url="file://$USER_HOME$/.gradle/caches/transforms-2/files-2.1/504fa6dae581171f07ee211f50cf11a5/jetified-GreenDaoUpgradeHelper-v2.2.1/res" />
<root url="file://$USER_HOME$/.gradle/caches/transforms-2/files-2.1/504fa6dae581171f07ee211f50cf11a5/jetified-GreenDaoUpgradeHelper-v2.2.1/AndroidManifest.xml" /> <root url="file://$USER_HOME$/.gradle/caches/transforms-2/files-2.1/504fa6dae581171f07ee211f50cf11a5/jetified-GreenDaoUpgradeHelper-v2.2.1/AndroidManifest.xml" />
<root url="file://$USER_HOME$/.gradle/caches/transforms-2/files-2.1/34c9268e89b7e26ed7d2a6d2fbc7372d/jetified-GreenDaoUpgradeHelper-v2.2.1/res" />
<root url="jar://$USER_HOME$/.gradle/caches/transforms-2/files-2.1/34c9268e89b7e26ed7d2a6d2fbc7372d/jetified-GreenDaoUpgradeHelper-v2.2.1/jars/classes.jar!/" />
<root url="file://$USER_HOME$/.gradle/caches/transforms-2/files-2.1/34c9268e89b7e26ed7d2a6d2fbc7372d/jetified-GreenDaoUpgradeHelper-v2.2.1/AndroidManifest.xml" />
</CLASSES> </CLASSES>
<JAVADOC> <JAVADOC>
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.github.yuweiguocn/GreenDaoUpgradeHelper/v2.2.1/7aef2e7b4c18afb240f0e17af5d045f176d2b8ef/GreenDaoUpgradeHelper-v2.2.1-javadoc.jar!/" /> <root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.github.yuweiguocn/GreenDaoUpgradeHelper/v2.2.1/7aef2e7b4c18afb240f0e17af5d045f176d2b8ef/GreenDaoUpgradeHelper-v2.2.1-javadoc.jar!/" />

View File

@ -13,6 +13,9 @@
<root url="file://$USER_HOME$/.gradle/caches/transforms-2/files-2.1/8bd9b60bcd5ac4680cd2109e7a86c760/jetified-logger-2.2.0/AndroidManifest.xml" /> <root url="file://$USER_HOME$/.gradle/caches/transforms-2/files-2.1/8bd9b60bcd5ac4680cd2109e7a86c760/jetified-logger-2.2.0/AndroidManifest.xml" />
<root url="file://$USER_HOME$/.gradle/caches/transforms-2/files-2.1/8bd9b60bcd5ac4680cd2109e7a86c760/jetified-logger-2.2.0/res" /> <root url="file://$USER_HOME$/.gradle/caches/transforms-2/files-2.1/8bd9b60bcd5ac4680cd2109e7a86c760/jetified-logger-2.2.0/res" />
<root url="jar://$USER_HOME$/.gradle/caches/transforms-2/files-2.1/8bd9b60bcd5ac4680cd2109e7a86c760/jetified-logger-2.2.0/jars/classes.jar!/" /> <root url="jar://$USER_HOME$/.gradle/caches/transforms-2/files-2.1/8bd9b60bcd5ac4680cd2109e7a86c760/jetified-logger-2.2.0/jars/classes.jar!/" />
<root url="jar://$USER_HOME$/.gradle/caches/transforms-2/files-2.1/8acd84ed04507b25ad4ab1f092095a58/jetified-logger-2.2.0/jars/classes.jar!/" />
<root url="file://$USER_HOME$/.gradle/caches/transforms-2/files-2.1/8acd84ed04507b25ad4ab1f092095a58/jetified-logger-2.2.0/res" />
<root url="file://$USER_HOME$/.gradle/caches/transforms-2/files-2.1/8acd84ed04507b25ad4ab1f092095a58/jetified-logger-2.2.0/AndroidManifest.xml" />
</CLASSES> </CLASSES>
<JAVADOC> <JAVADOC>
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.orhanobut/logger/2.2.0/98e69754ab23f7179137d8d2a0e3eea79200d746/logger-2.2.0-javadoc.jar!/" /> <root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.orhanobut/logger/2.2.0/98e69754ab23f7179137d8d2a0e3eea79200d746/logger-2.2.0-javadoc.jar!/" />

File diff suppressed because one or more lines are too long

View File

@ -87,11 +87,11 @@
<orderEntry type="module-library"> <orderEntry type="module-library">
<library name="Gradle: kaptGeneratedClasses"> <library name="Gradle: kaptGeneratedClasses">
<CLASSES> <CLASSES>
<root url="file://$MODULE_DIR$/../../../kurolibrary/build/tmp/kapt3/classes/release" /> <root url="file://$MODULE_DIR$/../../../kurolibrary/build/tmp/kapt3/classes/debug" />
<root url="file://$MODULE_DIR$/../../../kurolibrary/build/tmp/kapt3/classes/debugUnitTest" />
<root url="file://$MODULE_DIR$/../../../kurolibrary/build/tmp/kapt3/classes/releaseUnitTest" /> <root url="file://$MODULE_DIR$/../../../kurolibrary/build/tmp/kapt3/classes/releaseUnitTest" />
<root url="file://$MODULE_DIR$/../../../kurolibrary/build/tmp/kapt3/classes/debugAndroidTest" /> <root url="file://$MODULE_DIR$/../../../kurolibrary/build/tmp/kapt3/classes/debugAndroidTest" />
<root url="file://$MODULE_DIR$/../../../kurolibrary/build/tmp/kapt3/classes/debug" /> <root url="file://$MODULE_DIR$/../../../kurolibrary/build/tmp/kapt3/classes/debugUnitTest" />
<root url="file://$MODULE_DIR$/../../../kurolibrary/build/tmp/kapt3/classes/release" />
</CLASSES> </CLASSES>
<JAVADOC /> <JAVADOC />
<SOURCES /> <SOURCES />

View File

@ -90,10 +90,10 @@
<library name="Gradle: kaptGeneratedClasses"> <library name="Gradle: kaptGeneratedClasses">
<CLASSES> <CLASSES>
<root url="file://$MODULE_DIR$/../../../kurotool/build/tmp/kapt3/classes/debug" /> <root url="file://$MODULE_DIR$/../../../kurotool/build/tmp/kapt3/classes/debug" />
<root url="file://$MODULE_DIR$/../../../kurotool/build/tmp/kapt3/classes/debugUnitTest" />
<root url="file://$MODULE_DIR$/../../../kurotool/build/tmp/kapt3/classes/debugAndroidTest" />
<root url="file://$MODULE_DIR$/../../../kurotool/build/tmp/kapt3/classes/release" /> <root url="file://$MODULE_DIR$/../../../kurotool/build/tmp/kapt3/classes/release" />
<root url="file://$MODULE_DIR$/../../../kurotool/build/tmp/kapt3/classes/debugAndroidTest" />
<root url="file://$MODULE_DIR$/../../../kurotool/build/tmp/kapt3/classes/releaseUnitTest" /> <root url="file://$MODULE_DIR$/../../../kurotool/build/tmp/kapt3/classes/releaseUnitTest" />
<root url="file://$MODULE_DIR$/../../../kurotool/build/tmp/kapt3/classes/debugUnitTest" />
</CLASSES> </CLASSES>
<JAVADOC /> <JAVADOC />
<SOURCES /> <SOURCES />

View File

@ -21,8 +21,8 @@ android {
applicationId "net.sysolution.taxiapp" applicationId "net.sysolution.taxiapp"
minSdkVersion 21 minSdkVersion 21
targetSdkVersion 29 targetSdkVersion 29
versionCode 238 versionCode 240
versionName "3.3.3-beta26.3.9.3.95-release" versionName "3.3.3-beta26.3.9.97-debug"
//alphaxx - ,bug //alphaxx - ,bug
//Betaxx - //Betaxx -
@ -56,6 +56,9 @@ android {
26.3.8.6.9 38s 26.3.8.6.9 38s
26.3.9 webSocket的连接保活代码gps坐标记录两个点的距离由原来的50米记录一次改为20米记录一次 26.3.9 webSocket的连接保活代码gps坐标记录两个点的距离由原来的50米记录一次改为20米记录一次
3.3.3-beta26.3.9.3.94 gps开关查询广 3.3.3-beta26.3.9.3.94 gps开关查询广
3.3.3-beta26.3.9.3.95
26.3.9.96 广
26.3.9.97 taxiApp当天的运行时间
**/ **/
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

View File

@ -351,6 +351,51 @@ public class Configurations {
context.getSharedPreferences("config", Context.MODE_PRIVATE).edit().putBoolean("isCustomLogo", b).apply(); context.getSharedPreferences("config", Context.MODE_PRIVATE).edit().putBoolean("isCustomLogo", b).apply();
} }
/**
* taxiApp开始运行时间
* @return
*/
public long startRunTime(){
return context.getSharedPreferences("config", Context.MODE_PRIVATE).getLong("startRunTime",0L);
}
public void startRunTimeSave(Long startTime){
context.getSharedPreferences("config", Context.MODE_PRIVATE).edit().putLong("startRunTime", startTime).apply();
}
/**
* taxiApp结束运行时间
* @return
*/
public long endRunTime(){
return context.getSharedPreferences("config", Context.MODE_PRIVATE).getLong("endRunTime",0L);
}
public void endRunTimeSave(Long startTime){
context.getSharedPreferences("config", Context.MODE_PRIVATE).edit().putLong("endRunTime", startTime).apply();
}
/**
* taxiApp当天总的运行时间
* @return
*/
public long sumRunTime(){
return context.getSharedPreferences("config", Context.MODE_PRIVATE).getLong("sumRunTime",0L);
}
public void sumRunTimeSave(Long startTime){
context.getSharedPreferences("config", Context.MODE_PRIVATE).edit().putLong("sumRunTime", startTime).apply();
}
public String runtimeJsonString(){
return context.getSharedPreferences("config", Context.MODE_PRIVATE).getString("runtimeJsonString", "");
}
public void runtimeJsonStringSave(String s){
context.getSharedPreferences("config", Context.MODE_PRIVATE).edit().putString("runtimeJsonString", s).apply();
}
} }

View File

@ -0,0 +1,13 @@
package cn.trans88.taxiappkotlin.logic.model
/**
*
* @Author LJH
* @Time 2023/11/16
* @description
*/
data class LogSummary(
val ad_id: String,
val play_num:Int,
val duration:Long
)

View File

@ -0,0 +1,9 @@
package cn.trans88.taxiappkotlin.logic.model
/**
*
* @Author LJH
* @Time 2023/11/16
* @description
*/
data class LogSummaryJson(val begin_play_ts:Long,val end_play_ts:Long,val summary:List<LogSummary>)

View File

@ -0,0 +1,13 @@
package cn.trans88.taxiappkotlin.logic.model
/**
*
* @Author LJH
* @Time 2023/11/16
* @description上报运行时长的Json Model
*/
data class RuntimeJson(
val device_id:String,
val runtime:Long,
val create_at:Long
)

View File

@ -0,0 +1,18 @@
package cn.trans88.taxiappkotlin.logic.model;
/**
* @Author LJH
* @Time 2023/10/11
* @description
*/
public class TodayRunTime extends SanleResponse{
private long runtime = 0L;
public long getRuntime() {
return runtime;
}
public void setRuntime(long runtime) {
this.runtime = runtime;
}
}

View File

@ -40,6 +40,7 @@ import java.io.File
import java.io.IOException import java.io.IOException
import java.util.* import java.util.*
import java.util.concurrent.ThreadPoolExecutor import java.util.concurrent.ThreadPoolExecutor
import java.util.stream.Collectors
/** /**
* @author TRS * @author TRS
@ -447,6 +448,7 @@ object ConnManger {
YoungUtil.YoungLog("准备上传坐标") YoungUtil.YoungLog("准备上传坐标")
YoungUtil.YoungLog("sendLocation:${requestJson}") YoungUtil.YoungLog("sendLocation:${requestJson}")
val request: Request = Request.Builder() val request: Request = Request.Builder()
// .url("http://192.168.1.127:2346/postGpsLocationLog") //要访问的链接
.url(Configurations.config(TaxiApp.instance()).logServiceUrl() + "postGpsLocationLog") //要访问的链接 .url(Configurations.config(TaxiApp.instance()).logServiceUrl() + "postGpsLocationLog") //要访问的链接
.addHeader("Authorization", "Bearer ${Configurations.config(TaxiApp.instance()).appToken()}") .addHeader("Authorization", "Bearer ${Configurations.config(TaxiApp.instance()).appToken()}")
.post(body) .post(body)
@ -584,6 +586,7 @@ object ConnManger {
YoungUtil.YoungLog("准备获取播放的总次数") YoungUtil.YoungLog("准备获取播放的总次数")
val request: Request = Request.Builder() val request: Request = Request.Builder()
// .url("http://avhipxml.beesnat.com/v1/cms/groupAd/${advertise.ad_id}/AdCount") //要访问的链接 // .url("http://avhipxml.beesnat.com/v1/cms/groupAd/${advertise.ad_id}/AdCount") //要访问的链接
// .url("http://192.168.1.141/v1/cms/groupAd/AdCount") //要访问的链接
.url("${baseUrl}/v1/cms/groupAd/${advertise.ad_id}/AdCount") //要访问的链接 .url("${baseUrl}/v1/cms/groupAd/${advertise.ad_id}/AdCount") //要访问的链接
.addHeader("Authorization", "Bearer ${Configurations.config(TaxiApp.instance()).registerToken()}") .addHeader("Authorization", "Bearer ${Configurations.config(TaxiApp.instance()).registerToken()}")
.build() .build()
@ -676,6 +679,110 @@ object ConnManger {
} }
/**
* 优化方案上传日志概要
*/
fun sendLogsSummary(){
YoungUtil.YoungLog("sendLogger in Thread is ${Looper.getMainLooper().thread === Thread.currentThread()}")
val playLoggers = DaoUtil.getPlayLoggers()
if (playLoggers.isNotEmpty()) {
//#edit by ljh @2023/6/5 改成大批量看是否能减小流量消耗
val requestJson = ProcessingCommands.gson.toJson(playLoggers)
for (playLogger in playLoggers) {
DaoUtil.getPlayLogger().delete(playLogger)
}
val okHttpClient = OkHttpClient()
YoungUtil.YoungLog("准备上传日志")
val parse = ("application/json;charset=UTF-8").toMediaTypeOrNull()
val body = RequestBody.create(parse, requestJson)
YoungUtil.YoungLog("sendLogger:${requestJson}")
val request: Request = Request.Builder()
.url(Configurations.config(TaxiApp.instance()).logServiceUrl() + "postPlayerLog") //要访问的链接
.addHeader("Authorization", "Bearer ${Configurations.config(TaxiApp.instance()).appToken()}")
.addHeader("Accept-Encoding", "gzip")
.post(body)
.build()
val call = okHttpClient.newCall(request)
call.enqueue(object : Callback {
override fun onFailure(call: Call, e: IOException) {
YoungUtil.YoungLog("上传日志失败:${e.message}")
}
override fun onResponse(call: Call, response: Response) {
YoungUtil.YoungLog("上传日志成功:${response.message},response isSuccessful ${response.isSuccessful}${response.code}")
// if (response.code == 200) {
// //#edit by ljh @2023/6/5 删除批量上传的日志
// DaoUtil.getPlayLogger().deleteAll()
// }
"删除已上传的日志".logd()
}
})
}
}
private fun getLogSummaryJson(){
val playLoggers = DaoUtil.getPlayLoggers()
val maxEndPlayTs = playLoggers.map {
it.end_play_ts
}.max()
val minBeginPlayTs = playLoggers.map {
it.begin_play_ts
}.min()
"开始播放时间:$minBeginPlayTs,最后一条日志的播放时间:$maxEndPlayTs".loge()
if (playLoggers.isNotEmpty()) {
for (playLogger in playLoggers) {
DaoUtil.getPlayLogger().delete(playLogger)
}
}
}
/**
* 上报运行时长
*/
fun sendRuntimeToWeb(){
val jsonStr = Configurations.config(taxiApp).runtimeJsonString() ?: ""
val okHttpClient = OkHttpClient()
YoungUtil.YoungLog("准备上报运行时长")
val parse = ("application/json;charset=UTF-8").toMediaTypeOrNull()
val body = RequestBody.create(parse, jsonStr)
YoungUtil.YoungLog("runtimeJsonString:${jsonStr}")
val request: Request = Request.Builder()
.url(Configurations.config(TaxiApp.instance()).logServiceUrl() + "postRunningTimeLog") //要访问的链接
.addHeader("Authorization", "Bearer ${Configurations.config(TaxiApp.instance()).appToken()}")
.addHeader("Accept-Encoding", "gzip")
.post(body)
.build()
val call = okHttpClient.newCall(request)
call.enqueue(object : Callback {
override fun onFailure(call: Call, e: IOException) {
YoungUtil.YoungLog("上传运行时长失败:${e.message}")
Timer().schedule(object :TimerTask(){
override fun run() {
"重新上报运行时长".loge()
sendRuntimeToWeb()
}
},5000)
}
override fun onResponse(call: Call, response: Response) {
YoungUtil.YoungLog("上传运行时长成功:${response.message},response isSuccessful ${response.isSuccessful}${response.code}")
if (response.code == 200) {
"清除上传成功的运行时长数据".loge()
Configurations.config(taxiApp).runtimeJsonStringSave("")
}
}
})
}
/** /**
* 发送播放日志 * 发送播放日志
*/ */
@ -725,6 +832,7 @@ object ConnManger {
}) })
} }
/** /**
* 发送异常 * 发送异常
*/ */

View File

@ -39,7 +39,7 @@ public class JoeyDownloadManager {
private static BusCallback busCallback; private static BusCallback busCallback;
private static IPlay iPlay; private static IPlay iPlay;
//edit by ljh 2022/11/29 //edit by ljh 2022/11/29
private static final int RETRY_TIMES = 120; private static final int RETRY_TIMES = 600;
private static int downloadCount =100;//重试的次数 private static int downloadCount =100;//重试的次数
private static Application app; private static Application app;

View File

@ -86,6 +86,7 @@ object ProcessingCommands {
"get_player_log_state" -> getLoggerSwitch(task,baseTask.type) "get_player_log_state" -> getLoggerSwitch(task,baseTask.type)
//获取gps日志开关状态 //获取gps日志开关状态
"get_gps_state" -> getGpsSwitch(task,baseTask.type) "get_gps_state" -> getGpsSwitch(task,baseTask.type)
"get_today_runtime" -> getTodayRuntime(task,baseTask.type)
//直接清空所有广告 //直接清空所有广告
"clear_ads" -> clearAdvertises(task,baseTask.type) "clear_ads" -> clearAdvertises(task,baseTask.type)
"get_log_file_list" -> getLogFilesAllName(task,baseTask.type) "get_log_file_list" -> getLogFilesAllName(task,baseTask.type)
@ -194,6 +195,26 @@ object ProcessingCommands {
send(response) send(response)
} }
/**
* 实时获取当天taixApp运行时间
*/
private fun getTodayRuntime(task: String, type: String) {
val baseResponse = gson.fromJson<BaseResponse>(task)
val sanleResponse = TodayRunTime()
val startRuntime = Configurations.config(TaxiApp.instance()).startRunTime()
val endRuntime = Configurations.config(TaxiApp.instance()).endRunTime()
val sumRuntime = Configurations.config(TaxiApp.instance()).sumRunTime()
val todayRuntime = endRuntime - startRuntime + sumRuntime
"getTodayRuntime-->当前taxiApp运行时间$todayRuntime".logd()
sanleResponse.type = type
sanleResponse.id = baseResponse.id
sanleResponse.task_id = baseResponse.task_id
sanleResponse.runtime = todayRuntime
val response = gson.toJson(sanleResponse)
send(response)
}
/** /**
* 设置是否上传播放日志 * 设置是否上传播放日志

View File

@ -33,12 +33,15 @@ import cn.trans88.taxiappkotlin.logic.dao.PlayLoggerDao
import cn.trans88.taxiappkotlin.logic.gps.GpsReceiver import cn.trans88.taxiappkotlin.logic.gps.GpsReceiver
import cn.trans88.taxiappkotlin.logic.model.Advertise import cn.trans88.taxiappkotlin.logic.model.Advertise
import cn.trans88.taxiappkotlin.logic.model.Location import cn.trans88.taxiappkotlin.logic.model.Location
import cn.trans88.taxiappkotlin.logic.model.RuntimeJson
import cn.trans88.taxiappkotlin.logic.network.* import cn.trans88.taxiappkotlin.logic.network.*
import cn.trans88.taxiappkotlin.play.RefreshPlayer import cn.trans88.taxiappkotlin.play.RefreshPlayer
import cn.trans88.taxiappkotlin.ui.advertise.AdvertiseType import cn.trans88.taxiappkotlin.ui.advertise.AdvertiseType
import cn.trans88.taxiappkotlin.ui.broadcaskReceiver.BusCallback import cn.trans88.taxiappkotlin.ui.broadcaskReceiver.BusCallback
import cn.trans88.taxiappkotlin.ui.broadcaskReceiver.BusReceiver import cn.trans88.taxiappkotlin.ui.broadcaskReceiver.BusReceiver
import cn.trans88.taxiappkotlin.ui.broadcaskReceiver.SubScreenType import cn.trans88.taxiappkotlin.ui.broadcaskReceiver.SubScreenType
import cn.trans88.taxiappkotlin.util.DateUtil
import cn.trans88.taxiappkotlin.util.DayType
import cn.trans88.taxiappkotlin.util.YoungUtil import cn.trans88.taxiappkotlin.util.YoungUtil
import cn.trans88.taxiappkotlin.xixunUtil.OnScreenSizeListener import cn.trans88.taxiappkotlin.xixunUtil.OnScreenSizeListener
import cn.trans88.taxiappkotlin.xixunUtil.Xixun.getCardWidthHeight import cn.trans88.taxiappkotlin.xixunUtil.Xixun.getCardWidthHeight
@ -46,6 +49,7 @@ import cn.trans88.taxiappkotlin.xixunUtil.Xixun.setOnScreenListener
import com.bumptech.glide.Glide import com.bumptech.glide.Glide
import com.bumptech.glide.load.engine.DiskCacheStrategy import com.bumptech.glide.load.engine.DiskCacheStrategy
import com.bumptech.glide.request.RequestOptions import com.bumptech.glide.request.RequestOptions
import com.google.gson.Gson
import com.permissionx.guolindev.PermissionX import com.permissionx.guolindev.PermissionX
import com.trs88.kurolibrary.execute.KuroExecutor import com.trs88.kurolibrary.execute.KuroExecutor
import com.trs88.kurolibrary.util.MainHandler import com.trs88.kurolibrary.util.MainHandler
@ -67,8 +71,13 @@ class PlayActivity : AppCompatActivity(), NetworkCallback, BusCallback, OnScreen
private val busReceiver = BusReceiver()//豪胜公交Receiver private val busReceiver = BusReceiver()//豪胜公交Receiver
private val gpsReceiver = GpsReceiver()//Gps信息Receiver private val gpsReceiver = GpsReceiver()//Gps信息Receiver
private lateinit var configurations: Configurations
private lateinit var playViewModel: PlayViewModel private lateinit var playViewModel: PlayViewModel
private var saveRuntimeTimer:Timer? = null
private var startSaveRunTimer:Timer? = null
val handler = MyHandler(this) val handler = MyHandler(this)
val mainHandler = Handler(Looper.getMainLooper()) val mainHandler = Handler(Looper.getMainLooper())
@ -95,6 +104,8 @@ class PlayActivity : AppCompatActivity(), NetworkCallback, BusCallback, OnScreen
// Advertise().toString().loge() // Advertise().toString().loge()
setContentView(R.layout.activity_main) setContentView(R.layout.activity_main)
configurations = Configurations.config(this)
//读取保留的配置文件 //读取保留的配置文件
// readConfiguration() // readConfiguration()
@ -176,10 +187,132 @@ class PlayActivity : AppCompatActivity(), NetworkCallback, BusCallback, OnScreen
} }
mLocationManager?.removeUpdates(getLocationListener()) mLocationManager?.removeUpdates(getLocationListener())
} }
saveStartTime()
},30 * 1000) },30 * 1000)
// testLocation() // testLocation()
} }
/**
* 保存开始运行时间
*/
fun saveStartTime(){
var cacheStartTime:Long = configurations.startRunTime()
var currentTime = System.currentTimeMillis()
"saveStartTime ---> currentTime:$currentTime".loge()
if (currentTime>23646086L){
startSaveRunTimer?.let {
it.purge()
it.cancel()
}
startSaveRunTimer = null
var dayType = DateUtil.getDaysDiff(currentTime,cacheStartTime)
when(dayType){
DayType.IS_OTHER_DAY.ordinal -> { //如果缓存的启动时间是三天前(或更久)了,或者为零,直接覆盖
"startRunTimeendRunTime初始化为$currentTime".loge()
configurations.startRunTimeSave(currentTime)
configurations.endRunTimeSave(currentTime)
configurations.sumRunTimeSave(0L)
startRuntimeTimer()
}
DayType.IS_SAME_DAY.ordinal -> {//同一天重启
//先计算上次重启前的运行时间
val lastSumTime = configurations.sumRunTime()
val lastStartRuntime = configurations.startRunTime()
val lastEndRuntime = configurations.endRunTime()
val lastRunTime = lastEndRuntime - lastStartRuntime
"当前时间:$currentTime,lastStartRuntime:$lastStartRuntime,lastEndRuntime:$lastEndRuntime".loge()
"lastSumTime:$lastSumTime,lastRuntime:$lastRunTime".loge()
val todaySumRuntime = lastRunTime + lastSumTime
configurations.sumRunTimeSave(todaySumRuntime)
"程序启动,目前运行时间(毫秒):${todaySumRuntime}".loge()
//测试上报接口
// val runtimeJson = RuntimeJson(configurations.cardId(),todaySumRuntime,System.currentTimeMillis())
// configurations.runtimeJsonStringSave(Gson().toJson(runtimeJson))
if (!configurations.runtimeJsonString().isNullOrEmpty()){
ConnManger.sendRuntimeToWeb()
}
//保存新的开始运行时间,和结束时间
configurations.startRunTimeSave(currentTime)
configurations.endRunTimeSave(currentTime)
startRuntimeTimer()
}
DayType.IS_SECOND_DAY.ordinal -> {
//先计算上次重启前的运行时间
val lastSumTime = configurations.sumRunTime()
val lastStartRuntime = configurations.startRunTime()
val lastEndRuntime = configurations.endRunTime()
val lastRunTime = lastEndRuntime - lastStartRuntime
"当前时间:$currentTime,lastStartRuntime:$lastStartRuntime,lastEndRuntime:$lastEndRuntime".loge()
"lastSumTime:$lastSumTime,lastRuntime:$lastRunTime".loge()
val yesterdaySumTime = lastRunTime + lastSumTime
"程序启动,昨天运行时间(毫秒):${yesterdaySumTime}".loge()
//提交昨天一整天的运行时间
val runtimeJson = RuntimeJson(configurations.cardId(),yesterdaySumTime,System.currentTimeMillis())
configurations.runtimeJsonStringSave(Gson().toJson(runtimeJson))
ConnManger.sendRuntimeToWeb()
//保存新的开始运行时间,和结束时间
configurations.startRunTimeSave(currentTime)
configurations.endRunTimeSave(currentTime)
configurations.sumRunTimeSave(0L)
startRuntimeTimer()
}
else -> {
configurations.startRunTimeSave(currentTime)
configurations.endRunTimeSave(currentTime)
configurations.sumRunTimeSave(0L)
}
}
} else {
if (startSaveRunTimer == null){
startSaveRunTimer = Timer()
startSaveRunTimer?.schedule(object :TimerTask(){
override fun run() {
saveStartTime()
}
},30*1000L,30*1000L)
}
}
}
/**
* 启动计算运行时长的计时器
*/
private fun startRuntimeTimer(){
"startRuntimeTimer()".loge()
saveRuntimeTimer?.purge()
saveRuntimeTimer?.cancel()
if (saveRuntimeTimer == null){
saveRuntimeTimer = Timer()
saveRuntimeTimer?.schedule(object : TimerTask(){
override fun run() {
val endRuntime = configurations.endRunTime()
val startRuntime = configurations.startRunTime()
"RuntimeTimer --> currentEndRuntime:$endRuntime".loge()
val type = DateUtil.getDaysDiff(endRuntime,startRuntime)
if (DayType.IS_SECOND_DAY.ordinal == type) {
val lastRunTime = endRuntime - startRuntime
val yesterdayRuntime = configurations.sumRunTime() + lastRunTime
//提交昨天一整天的运行时间
val runtimeJson = RuntimeJson(configurations.cardId(),yesterdayRuntime,System.currentTimeMillis())
configurations.runtimeJsonStringSave(Gson().toJson(runtimeJson))
ConnManger.sendRuntimeToWeb()
//保存新的开始运行时间,和结束时间
configurations.startRunTimeSave(endRuntime)
configurations.sumRunTimeSave(0L)
}
configurations.endRunTimeSave(endRuntime+30*1000L)
}
},30*1000L,30*1000L)
}
}
//#edit by ljh 2023/2/16 //#edit by ljh 2023/2/16
fun getViewModel():PlayViewModel{ fun getViewModel():PlayViewModel{
return playViewModel return playViewModel
@ -564,6 +697,15 @@ class PlayActivity : AppCompatActivity(), NetworkCallback, BusCallback, OnScreen
override fun onAvailable() { override fun onAvailable() {
YoungUtil.YoungLog("网络可用") YoungUtil.YoungLog("网络可用")
// RefreshPlayer.refresh() // RefreshPlayer.refresh()
// val currentStartTime = configurations.startRunTime()
// if (currentStartTime>23646086L && !isStartedSaveRuntime && !isFirstSaveRuntime){
// Timer().schedule(object :TimerTask(){
// override fun run() {
// "上一次开始运行时间:${currentStartTime},重置".loge()
// saveStartTime()
// }
// },5000L)
// }
} }
override fun onLost() { override fun onLost() {

View File

@ -463,19 +463,19 @@ class PlayViewModel(val lifecycle: Lifecycle, private val fl_play: FrameLayout,
YoungUtil.YoungLog( "Advertise id:" + advertise.ad_id + " " + advertise.pathName) YoungUtil.YoungLog( "Advertise id:" + advertise.ad_id + " " + advertise.pathName)
//记录上一个广告日志的duration //记录上一个广告日志的duration
if (curLogger != null && Configurations.config(TaxiApp.instance()).loggerSwitch()) { // if (curLogger != null && Configurations.config(TaxiApp.instance()).loggerSwitch()) {
var duration: Long = System.currentTimeMillis() - curLogger!!.created_at // var duration: Long = System.currentTimeMillis() - curLogger!!.created_at
//
if (curAdvertise != null) { // if (curAdvertise != null) {
if (duration >= (curAdvertise!!.duration.toLong() - 200) && duration <= (curAdvertise!!.duration.toLong() + 200)) { // if (duration >= (curAdvertise!!.duration.toLong() - 200) && duration <= (curAdvertise!!.duration.toLong() + 200)) {
duration = curAdvertise!!.duration.toLong() // duration = curAdvertise!!.duration.toLong()
} // }
} // }
if (!advertise.isCount){ // if (!advertise.isCount){
curLogger!!.duration = duration // curLogger!!.duration = duration
} // }
"日志durarion:${curLogger!!.duration}".loge() // "日志durarion:${duration}".loge()
} // }
val createView = fl_play.createView(fl_play.context, advertise, 0) val createView = fl_play.createView(fl_play.context, advertise, 0)
@ -794,8 +794,8 @@ class PlayViewModel(val lifecycle: Lifecycle, private val fl_play: FrameLayout,
if (curLogger != null) { if (curLogger != null) {
YoungUtil.YoungLog("TID: " + Thread.currentThread().id + ", insert normal play logger") YoungUtil.YoungLog("TID: " + Thread.currentThread().id + ", insert normal play logger")
curLogger!!.end_play_ts = System.currentTimeMillis() curLogger!!.end_play_ts = System.currentTimeMillis()
val roundingDuration = Math.ceil((curLogger!!.duration.toDouble() / 1000)) * 1000 // val roundingDuration = Math.ceil((curLogger!!.duration.toDouble() / 1000)) * 1000
curLogger!!.duration = roundingDuration.toLong() // curLogger!!.duration = roundingDuration.toLong()
DaoUtil.getPlayLoggerDao().insert(curLogger) DaoUtil.getPlayLoggerDao().insert(curLogger)
"存储日志:${curLogger?.begin_play_ts}".loge() "存储日志:${curLogger?.begin_play_ts}".loge()
@ -836,9 +836,10 @@ class PlayViewModel(val lifecycle: Lifecycle, private val fl_play: FrameLayout,
latitude = curlatitude latitude = curlatitude
// YoungUtil.YoungLog("advertise adid :${advertise.ad_id}, 经纬度 ${longitude},${latitude}") // YoungUtil.YoungLog("advertise adid :${advertise.ad_id}, 经纬度 ${longitude},${latitude}")
//#edit by ljh //#edit by ljh
if (advertise.isCount){ // if (advertise.isCount){
duration = advertise.duration.toLong() // duration = advertise.duration.toLong()
} // }
duration = advertise.duration.toLong()
} }
YoungUtil.YoungLog("初始化curLogger$curLogger") YoungUtil.YoungLog("初始化curLogger$curLogger")

View File

@ -1,8 +1,15 @@
package cn.trans88.taxiappkotlin.util; package cn.trans88.taxiappkotlin.util;
import android.os.Build;
import android.util.Log; import android.util.Log;
import androidx.annotation.RequiresApi;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
@ -96,4 +103,59 @@ public class DateUtil {
String now = dateTimeFormat.format(new Date()); String now = dateTimeFormat.format(new Date());
return now; return now;
} }
/**
* 判断当前系统时间跟缓存的 应用开始运行时间对比是不是第二天的时间
* 获取时间差当前时间与缓存时间相差的天数
* @param currentTime
* @param cacheTime
* @return
*/
public static int getDaysDiff(long currentTime, long cacheTime){
Log.d("yzd_t", "currentTime: " + currentTime + ", cacheTime: " + cacheTime);
int dayType = DayType.IS_OTHER_DAY.ordinal();
// long currentTimeStamp = 1699723270L; // 替换为currentTimeStamp的值 2023/11/12
// long lastTimeStamp = 1699690270L; // 替换为lastTimeStamp的值 2023/11/11
// 将时间戳转换为Date对象
// Date currentDate = new Date(currentTimeStamp * 1000L);
// Date lastDate = new Date(lastTimeStamp * 1000L);
Date currentDate = new Date(currentTime);
Date lastDate = new Date(cacheTime);
// 创建Calendar对象并设置时间
Calendar currentCalendar = Calendar.getInstance();
currentCalendar.setTime(currentDate);
Calendar lastCalendar = Calendar.getInstance();
lastCalendar.setTime(lastDate);
// 设置时间为午夜
currentCalendar.set(Calendar.HOUR_OF_DAY, 0);
currentCalendar.set(Calendar.MINUTE, 0);
currentCalendar.set(Calendar.SECOND, 0);
currentCalendar.set(Calendar.MILLISECOND, 0);
lastCalendar.set(Calendar.HOUR_OF_DAY, 0);
lastCalendar.set(Calendar.MINUTE, 0);
lastCalendar.set(Calendar.SECOND, 0);
lastCalendar.set(Calendar.MILLISECOND, 0);
// 判断日期差异
long diff = currentCalendar.getTimeInMillis() - lastCalendar.getTimeInMillis();
int daysDiff = (int) (diff / (24 * 60 * 60 * 1000));
Log.d("yzd_t", "daysDiff: " + daysDiff);
if (daysDiff == 1) {
Log.d("yzd_t","currentTimeStamp对应的时间是lastTimeStamp的后一天的时间。");
dayType = DayType.IS_SECOND_DAY.ordinal();
} else if (daysDiff == 0) {
Log.d("yzd_t","currentTimeStamp对应的时间不是lastTimeStamp的后一天的时间。");
dayType = DayType.IS_SAME_DAY.ordinal();
}
return dayType;
}
} }

View File

@ -0,0 +1,12 @@
package cn.trans88.taxiappkotlin.util;
/**
* @Author LJH
* @Time 2023/11/14
* @description
*/
public enum DayType {
IS_SAME_DAY,
IS_SECOND_DAY,
IS_OTHER_DAY,
}

View File

@ -1 +1 @@
[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":237,"versionName":"3.3.3-beta26.3.9.3.94-debug","enabled":true,"outputFile":"TaxiApp_v3.3.3-beta26.3.9.3.94-debug{237}.apk","fullName":"debug","baseName":"debug","dirName":""},"path":"TaxiApp_v3.3.3-beta26.3.9.3.94-debug{237}.apk","properties":{}}] [{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":240,"versionName":"3.3.3-beta26.3.9.97-debug","enabled":true,"outputFile":"TaxiApp_v3.3.3-beta26.3.9.97-debug{240}.apk","fullName":"debug","baseName":"debug","dirName":""},"path":"TaxiApp_v3.3.3-beta26.3.9.97-debug{240}.apk","properties":{}}]

View File

@ -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.
#Thu Sep 07 10:09:52 GMT+08:00 2023 #Mon Nov 06 09:42:57 GMT+08:00 2023
sdk.dir=D\:\\Android\\sdk sdk.dir=D\:\\Android\\sdk

View File

@ -1 +1 @@
[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":238,"versionName":"3.3.3-beta26.3.9.3.95-release","enabled":true,"outputFile":"TaxiApp_v3.3.3-beta26.3.9.3.95-release{238}.apk","fullName":"release","baseName":"release","dirName":""},"path":"TaxiApp_v3.3.3-beta26.3.9.3.95-release{238}.apk","properties":{}}] [{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":239,"versionName":"3.3.3-beta26.3.9.96-release","enabled":true,"outputFile":"TaxiApp_v3.3.3-beta26.3.9.96-release{239}.apk","fullName":"release","baseName":"release","dirName":""},"path":"TaxiApp_v3.3.3-beta26.3.9.96-release{239}.apk","properties":{}}]