@@ -0,0 +1,5 @@
|
||||
package com.zhidao.roadcondition.model
|
||||
|
||||
class BaseRequest<T>(var sn: String, var data: T?) {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.zhidao.roadcondition.model
|
||||
|
||||
import com.zhidao.roadcondition.constant.HttpConstants
|
||||
|
||||
class BaseResponse<out T>(val code: Int, val msg: String, val result: T) {
|
||||
fun isSuccess(baseUrl: String): Boolean {
|
||||
return when (baseUrl) {
|
||||
HttpConstants.getBaseUrl() -> true
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package com.zhidao.roadcondition.model
|
||||
|
||||
class CityStrategy(video: Video, pic: Pic) {
|
||||
var video: Video? = video
|
||||
var pic: Pic? = pic
|
||||
}
|
||||
|
||||
fun Video.getMaxSpeed(): Int {
|
||||
return if (maxSpeed == 0) {
|
||||
-1
|
||||
} else {
|
||||
maxSpeed
|
||||
}
|
||||
}
|
||||
|
||||
class Video {
|
||||
var strategyId: String //策略ID
|
||||
var reportType: Int //一次性、周期性
|
||||
var reportTimeInterval: Int //上传时间间隔 单位:分钟
|
||||
var infoTimeout: Int //情报失效时间 单位:分钟
|
||||
var minSpeed: Int = -1//最小速度
|
||||
var maxSpeed: Int = -1//最大速度
|
||||
var strategyType: Int //策略类型:城市、热门区域、非上报区域等
|
||||
|
||||
constructor(
|
||||
strategyId: String,
|
||||
reportType: Int,
|
||||
reportTimeInterval: Int,
|
||||
infoTimeout: Int,
|
||||
minSpeed: Int,
|
||||
maxSpeed: Int,
|
||||
strategyType: Int
|
||||
) {
|
||||
this.strategyId = strategyId
|
||||
this.reportType = reportType
|
||||
this.reportTimeInterval = reportTimeInterval
|
||||
this.infoTimeout = infoTimeout
|
||||
this.minSpeed = minSpeed
|
||||
this.maxSpeed = maxSpeed
|
||||
this.strategyType = strategyType
|
||||
}
|
||||
}
|
||||
|
||||
fun Pic.getMaxSpeed(): Int {
|
||||
return if (maxSpeed == 0) {
|
||||
-1
|
||||
} else {
|
||||
maxSpeed
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class Pic {
|
||||
var strategyId: String //策略ID
|
||||
var reportType: Int //一次性、周期性
|
||||
var reportTimeInterval: Int //上传时间间隔 单位:分钟
|
||||
var infoTimeout: Int //情报失效时间 单位:分钟
|
||||
var minSpeed: Int = -1 //最小速度
|
||||
var maxSpeed: Int = -1 //最大速度
|
||||
var strategyType: Int //策略类型:城市、热门区域、非上报区域等
|
||||
|
||||
constructor(
|
||||
strategyId: String,
|
||||
reportType: Int,
|
||||
reportTimeInterval: Int,
|
||||
infoTimeout: Int,
|
||||
minSpeed: Int,
|
||||
maxSpeed: Int,
|
||||
strategyType: Int
|
||||
) {
|
||||
this.strategyId = strategyId
|
||||
this.reportType = reportType
|
||||
this.reportTimeInterval = reportTimeInterval
|
||||
this.infoTimeout = infoTimeout
|
||||
this.minSpeed = minSpeed
|
||||
this.maxSpeed = maxSpeed
|
||||
this.strategyType = strategyType
|
||||
}
|
||||
}
|
||||
|
||||
class StrategyRequest {
|
||||
var lon: Double
|
||||
var lat: Double
|
||||
var cityCode: String
|
||||
|
||||
constructor(lon: Double, lat: Double, cityCode: String) {
|
||||
this.lon = lon
|
||||
this.lat = lat
|
||||
this.cityCode = cityCode
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.zhidao.roadcondition.model
|
||||
|
||||
|
||||
class CommonConfig {
|
||||
|
||||
var active:Active //活动配置
|
||||
// var promotion:Promotion //Splash页面图片以及语音推广配置
|
||||
var auth:Auth //授权配置
|
||||
|
||||
constructor(active: Active, auth: Auth) {
|
||||
this.active = active
|
||||
// this.promotion = promotion
|
||||
this.auth = auth
|
||||
}
|
||||
}
|
||||
|
||||
class Active{
|
||||
var imageUrl:String
|
||||
var webUrl:String
|
||||
var status:Int
|
||||
|
||||
constructor(imageUrl: String, webUrl: String, status: Int) {
|
||||
this.imageUrl = imageUrl
|
||||
this.webUrl = webUrl
|
||||
this.status = status
|
||||
}
|
||||
}
|
||||
|
||||
class Promotion{
|
||||
var imageUrl:String
|
||||
var voiceContent:String
|
||||
var status:Int
|
||||
|
||||
constructor(imageUrl: String, voiceContent: String, status: Int) {
|
||||
this.imageUrl = imageUrl
|
||||
this.voiceContent = voiceContent
|
||||
this.status = status
|
||||
}
|
||||
}
|
||||
|
||||
class Auth{
|
||||
var isNeedAuth:Int
|
||||
|
||||
constructor(isNeedAuth: Int) {
|
||||
this.isNeedAuth = isNeedAuth
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.zhidao.roadcondition.model
|
||||
|
||||
data class InformationBody(
|
||||
val data: String,
|
||||
val addr: String,
|
||||
val areaCode: String,
|
||||
val areaName: String,
|
||||
val cityCode: String,
|
||||
val cityName: String,
|
||||
val generateTime: Long,
|
||||
val lat: Double,
|
||||
val lon: Double,
|
||||
val provinceName: String,
|
||||
val sn: String,
|
||||
val street: String,
|
||||
val type: Int,
|
||||
val uid: Int,
|
||||
val infoType: Int,
|
||||
val infoTimeout:Int,
|
||||
val trafficInfoType:String, // 上报情报类型
|
||||
val isShare: Boolean, // 是否分享给附近车机
|
||||
val direction: Float,
|
||||
val poiType: String, //类型分类
|
||||
val mainInfoId: Long, //事件id
|
||||
val speed: Float, //车速
|
||||
val fromType: String //上报触发来源
|
||||
)
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.zhidao.roadcondition.model
|
||||
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-11-22
|
||||
*
|
||||
* 一次情报的数据
|
||||
*/
|
||||
class InformationResource {
|
||||
|
||||
var id: Long
|
||||
var isCosResourceReady: Boolean = false
|
||||
var isInformationSelected: Boolean = false
|
||||
|
||||
var sourceType: Int = 0 // 情报载体类型:图片、视频
|
||||
var cosParameter: Map<String, String>? = null // 情报参数
|
||||
var informationType: InformationType? = null //情报类型
|
||||
var isCustomSend: Boolean = false // 自动上传
|
||||
|
||||
var callback: ((customSend: Boolean) -> Unit)? = null
|
||||
|
||||
lateinit var newsType: String // 埋点:情报类型
|
||||
lateinit var operType: String // 埋点:操作类型
|
||||
|
||||
constructor(id: Long) {
|
||||
this.id = id
|
||||
}
|
||||
|
||||
fun isReady() = isCosResourceReady and isInformationSelected
|
||||
|
||||
fun release() {
|
||||
cosParameter = null
|
||||
informationType = null
|
||||
callback = null
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
return "upload information: sourceType=${sourceType}, informationType={${informationType?.dictLabel}, ${informationType?.dictValue}}"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.zhidao.roadcondition.model
|
||||
|
||||
import com.google.gson.Gson
|
||||
import com.zhidao.roadcondition.constant.DEF_NEWS_LABEL
|
||||
import com.zhidao.roadcondition.constant.DEF_NEWS_TYPE
|
||||
import com.zhidao.roadcondition.constant.DEF_NEWS_VALUE
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-11-18
|
||||
*
|
||||
* 情报类型
|
||||
*/
|
||||
data class InformationType(var dictLabel: String, var dictValue: String, var remark: String) {
|
||||
companion object {
|
||||
val def = InformationType(DEF_NEWS_LABEL, DEF_NEWS_VALUE, DEF_NEWS_TYPE)
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
when (other) {
|
||||
is InformationType -> return other.dictValue.compareTo(dictValue) == 0
|
||||
}
|
||||
return super.equals(other)
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
return Gson().toJson(this)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.zhidao.roadcondition.model
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-11-18
|
||||
*
|
||||
* 描述
|
||||
*/
|
||||
data class InformationTypeResult(var types: List<InformationType>)
|
||||
@@ -0,0 +1,63 @@
|
||||
package com.zhidao.roadcondition.model
|
||||
|
||||
import android.os.Parcel
|
||||
import android.os.Parcelable
|
||||
|
||||
class Informations(
|
||||
var type: Int,
|
||||
var lon: Double,
|
||||
var lat: Double,
|
||||
var addr: String?,
|
||||
var generateTime: Long,
|
||||
var cityName: String?,
|
||||
// var items: ArrayList<Items>,
|
||||
var distance: Int,
|
||||
var nickName: String?,
|
||||
var headImgUrl: String?
|
||||
) :
|
||||
Parcelable {
|
||||
|
||||
var position = 0
|
||||
|
||||
constructor(parcel: Parcel) : this(
|
||||
parcel.readInt(),
|
||||
parcel.readDouble(),
|
||||
parcel.readDouble(),
|
||||
parcel.readString(),
|
||||
parcel.readLong(),
|
||||
parcel.readString(),
|
||||
// parcel.readArrayList(Items::class.java.classLoader) as ArrayList<Items>,
|
||||
parcel.readInt(),
|
||||
parcel.readString(),
|
||||
parcel.readString()
|
||||
)
|
||||
|
||||
override fun writeToParcel(parcel: Parcel, flags: Int) {
|
||||
parcel.writeInt(type)
|
||||
parcel.writeDouble(lon)
|
||||
parcel.writeDouble(lat)
|
||||
parcel.writeString(addr)
|
||||
parcel.writeLong(generateTime)
|
||||
parcel.writeString(cityName)
|
||||
// parcel.writeList(items)
|
||||
parcel.writeInt(distance)
|
||||
parcel.writeString(nickName)
|
||||
parcel.writeString(headImgUrl)
|
||||
}
|
||||
|
||||
override fun describeContents(): Int {
|
||||
return 0
|
||||
}
|
||||
|
||||
companion object CREATOR : Parcelable.Creator<Informations> {
|
||||
override fun createFromParcel(parcel: Parcel): Informations {
|
||||
return Informations(parcel)
|
||||
}
|
||||
|
||||
override fun newArray(size: Int): Array<Informations?> {
|
||||
return arrayOfNulls(size)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.zhidao.roadcondition.model
|
||||
|
||||
import android.os.Parcel
|
||||
import android.os.Parcelable
|
||||
|
||||
class Items(var url: String?, var thumbnail: String? = null) : Parcelable {
|
||||
constructor(parcel: Parcel) : this(
|
||||
parcel.readString(),
|
||||
parcel.readString()
|
||||
) {
|
||||
}
|
||||
|
||||
override fun writeToParcel(parcel: Parcel, flags: Int) {
|
||||
parcel.writeString(url)
|
||||
parcel.writeString(thumbnail)
|
||||
}
|
||||
|
||||
override fun describeContents(): Int {
|
||||
return 0
|
||||
}
|
||||
|
||||
companion object CREATOR : Parcelable.Creator<Items> {
|
||||
override fun createFromParcel(parcel: Parcel): Items {
|
||||
return Items(parcel)
|
||||
}
|
||||
|
||||
override fun newArray(size: Int): Array<Items?> {
|
||||
return arrayOfNulls(size)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.zhidao.roadcondition.model
|
||||
|
||||
import com.mogo.map.MogoLatLng
|
||||
|
||||
fun LocationInfo.toLatLngPoint():MogoLatLng{
|
||||
return MogoLatLng(latitude,longitude)
|
||||
}
|
||||
|
||||
class LocationInfo {
|
||||
var provinceName: String = "" //省的名称
|
||||
var cityName: String = "" //城市的名称
|
||||
var cityCode :String = "" //城市编码
|
||||
var areaName :String = "" //区县名称
|
||||
var areaCode :String = "" //区县编码
|
||||
var street :String = "" //街道名称
|
||||
var longitude: Double = 0.0
|
||||
var latitude: Double = 0.0
|
||||
var address: String = ""
|
||||
var time: Long = 0L
|
||||
var direction: Float = 0.0f
|
||||
constructor()
|
||||
|
||||
constructor(longitude: Double, latitude: Double, address: String, time: Long) {
|
||||
this.longitude = longitude
|
||||
this.latitude = latitude
|
||||
this.address = address
|
||||
this.time = time
|
||||
}
|
||||
|
||||
constructor(
|
||||
provinceName: String,
|
||||
cityName: String,
|
||||
cityCode: String,
|
||||
areaName: String,
|
||||
areaCode: String,
|
||||
street: String,
|
||||
longitude: Double,
|
||||
latitude: Double,
|
||||
address: String,
|
||||
time: Long,
|
||||
direction: Float = 0.0f
|
||||
) {
|
||||
this.provinceName = provinceName
|
||||
this.cityName = cityName
|
||||
this.cityCode = cityCode
|
||||
this.areaName = areaName
|
||||
this.areaCode = areaCode
|
||||
this.street = street
|
||||
this.longitude = longitude
|
||||
this.latitude = latitude
|
||||
this.address = address
|
||||
this.time = time
|
||||
this.direction = direction
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.zhidao.roadcondition.model
|
||||
|
||||
/**
|
||||
* 城市策略实体
|
||||
*/
|
||||
class Results(var cityStrategy: CityStrategy)
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.zhidao.roadcondition.model
|
||||
|
||||
import android.util.Log
|
||||
import com.google.gson.Gson
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig
|
||||
import com.mogo.module.common.constants.HostConst
|
||||
import com.zhidao.roadcondition.base.BaseRepository
|
||||
import com.zhidao.roadcondition.net.HttpClient
|
||||
import com.zhidao.roadcondition.util.LocationUtil
|
||||
|
||||
class StrategyServiceModel : BaseRepository() {
|
||||
|
||||
suspend fun getCityStrategy(): BaseResponse<Results> {
|
||||
return apiCall {
|
||||
val map = hashMapOf<String, String>()
|
||||
map["sn"] = MoGoAiCloudClientConfig.getInstance().getSn()
|
||||
val locInfo = LocationUtil.getInstance().getLocationInfo()
|
||||
map["data"] = Gson().toJson(
|
||||
StrategyRequest(
|
||||
locInfo.longitude,
|
||||
locInfo.latitude,
|
||||
locInfo.cityCode
|
||||
)
|
||||
)
|
||||
HttpClient.getInstance(HostConst.GEOFENCE_HOST).getHttpApi().getCityStrategy(map)
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun uploadInformation(informationBody: InformationBody): BaseResponse<UploadResult> {
|
||||
return apiCall {
|
||||
val informationBodyStr = Gson().toJson(informationBody)
|
||||
Log.d("MainServiceController", "uploadInformation informationBody = $informationBodyStr")
|
||||
HttpClient.getInstance(HostConst.DEVA_HOST).getHttpApi()
|
||||
.uploadInformation(mapOf("sn" to MoGoAiCloudClientConfig.getInstance().getSn(), "data" to informationBodyStr))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.zhidao.roadcondition.model
|
||||
|
||||
/**
|
||||
* 上报成功返回
|
||||
*/
|
||||
class UploadResult(var id: Long) {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.zhidao.roadcondition.model.proxy
|
||||
|
||||
import androidx.annotation.IntDef
|
||||
|
||||
const val INFO_TYPE_GONE = 0
|
||||
const val INFO_TYPE_SHOW = 1
|
||||
|
||||
|
||||
@IntDef(INFO_TYPE_GONE, INFO_TYPE_SHOW)
|
||||
@Retention(AnnotationRetention.SOURCE)
|
||||
annotation class ActiveInfoType
|
||||
|
||||
fun isActiveShow(@ActiveInfoType type: Int): Boolean {
|
||||
return when (type) {
|
||||
INFO_TYPE_GONE -> false
|
||||
INFO_TYPE_SHOW -> true
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.zhidao.roadcondition.model.proxy
|
||||
|
||||
import androidx.annotation.IntDef
|
||||
|
||||
|
||||
const val INFO_TYPE_IMG = 0 //图片
|
||||
const val INFO_TYPE_VIDEO = 1
|
||||
const val INFO_TYPE_VOICE = 2
|
||||
const val INFO_TYPE_WORD = 3
|
||||
|
||||
|
||||
@IntDef(INFO_TYPE_IMG, INFO_TYPE_VIDEO, INFO_TYPE_VOICE, INFO_TYPE_WORD)
|
||||
@Retention(AnnotationRetention.SOURCE)
|
||||
annotation class InformationsType
|
||||
Reference in New Issue
Block a user