Merge branch 'master' of https://gitlab.navinfo.com/CollectVehicle/OneMapQS
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
package com.navinfo.omqs.bean
|
||||
|
||||
import android.os.Parcelable
|
||||
import com.google.gson.annotations.SerializedName
|
||||
import kotlinx.android.parcel.Parcelize
|
||||
|
||||
@Parcelize
|
||||
data class EvaluationInfo(
|
||||
@SerializedName("evaluationTaskId")
|
||||
val evaluationTaskId: String = "",//测评任务id
|
||||
@@ -46,5 +49,5 @@ data class EvaluationInfo(
|
||||
|
||||
@SerializedName("evaluationWay")
|
||||
val evaluationWay: String = ""//测评方式
|
||||
)
|
||||
) : Parcelable
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ import io.realm.Realm
|
||||
import kotlinx.coroutines.*
|
||||
import okhttp3.OkHttpClient
|
||||
import okhttp3.logging.HttpLoggingInterceptor
|
||||
import retrofit2.Call
|
||||
import retrofit2.Retrofit
|
||||
import retrofit2.converter.gson.GsonConverterFactory
|
||||
import java.util.concurrent.TimeUnit
|
||||
@@ -66,7 +67,7 @@ class GlobalModule {
|
||||
}.apply {
|
||||
level = if (Constant.DEBUG) {
|
||||
//坑 !!!! 下载文件时打印log 内存不足
|
||||
HttpLoggingInterceptor.Level.BASIC
|
||||
HttpLoggingInterceptor.Level.BODY
|
||||
} else {
|
||||
HttpLoggingInterceptor.Level.NONE
|
||||
}
|
||||
@@ -92,9 +93,12 @@ class GlobalModule {
|
||||
@Singleton
|
||||
fun provideGson(): Gson = GsonBuilder()
|
||||
// 解决解析Json时将int类型自动转换为Double的问题
|
||||
.registerTypeAdapter(object : TypeToken<Map<String, Any?>>() {}.getType(), IntTypeAdapter())
|
||||
.registerTypeAdapter(object : TypeToken<Map<String, Any>>() {}.getType(), IntTypeAdapter())
|
||||
.registerTypeAdapter(object : TypeToken<Map<Any, Any>>() {}.getType(), IntTypeAdapter())
|
||||
.registerTypeAdapter(object : TypeToken<Map<String, Any?>>() {}.type, IntTypeAdapter())
|
||||
.registerTypeAdapter(object : TypeToken<Map<String, Any>>() {}.type, IntTypeAdapter())
|
||||
.registerTypeAdapter(object : TypeToken<Map<Any, Any>>() {}.type, IntTypeAdapter())
|
||||
// .registerTypeAdapter(Call::class.java, object : TypeToken<Call<*>>(){
|
||||
//
|
||||
// })
|
||||
.create()
|
||||
|
||||
@Provides
|
||||
|
||||
@@ -58,7 +58,7 @@ interface RetrofitNetworkServiceAPI {
|
||||
|
||||
@Headers("Content-Type: application/json")
|
||||
@POST("/devcp/upload")
|
||||
suspend fun postRequest(@Body listEvaluationInfo: List<EvaluationInfo>?): Call<ResponseBody>
|
||||
suspend fun postRequest(@Body listEvaluationInfo: List<EvaluationInfo>?): Response<ResponseBody>
|
||||
|
||||
/**
|
||||
* @FormUrlEncoded 请求格式注解,请求实体是一个From表单,每个键值对需要使用@Field注解
|
||||
|
||||
@@ -9,6 +9,7 @@ import androidx.lifecycle.Observer
|
||||
import com.navinfo.collect.library.data.entity.QsRecordBean
|
||||
import com.navinfo.omqs.bean.EvaluationInfo
|
||||
import com.navinfo.omqs.bean.TaskBean
|
||||
import com.navinfo.omqs.http.NetResult
|
||||
import com.navinfo.omqs.tools.FileManager
|
||||
import com.navinfo.omqs.tools.FileManager.Companion.FileUploadStatus
|
||||
import io.realm.Realm
|
||||
@@ -114,9 +115,16 @@ class TaskUploadScope(
|
||||
taskBean.hadLinkDvoList.forEach { hadLinkDvoBean ->
|
||||
val objects = realm.where(QsRecordBean::class.java)
|
||||
.equalTo("linkId", /*"84207223282277331"*/hadLinkDvoBean.linkPid).findAll()
|
||||
if(objects.size == 0){
|
||||
// change(FileUploadStatus.NONE)
|
||||
return
|
||||
}
|
||||
|
||||
val bodyList: MutableList<EvaluationInfo> = ArrayList()
|
||||
|
||||
if (objects != null) {
|
||||
objects.forEach{
|
||||
val copyList =realm.copyFromRealm(objects)
|
||||
copyList.forEach {
|
||||
val evaluationInfo = EvaluationInfo(
|
||||
taskBean.id.toString(),
|
||||
hadLinkDvoBean.linkPid,//"84207223282277331"
|
||||
@@ -137,26 +145,20 @@ class TaskUploadScope(
|
||||
bodyList.add(evaluationInfo)
|
||||
}
|
||||
|
||||
uploadManager.netApi.postRequest(bodyList).enqueue(object :
|
||||
Callback<ResponseBody> {
|
||||
override fun onResponse(
|
||||
call: Call<ResponseBody>,
|
||||
response: Response<ResponseBody>
|
||||
) {
|
||||
if (response.code() == 200) {
|
||||
taskBean.syncStatus = FileUploadStatus.DONE
|
||||
// handle the response
|
||||
Log.e("qj", "")
|
||||
change(FileUploadStatus.DONE)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onFailure(call: Call<ResponseBody>, t: Throwable) {
|
||||
val result = uploadManager.netApi.postRequest(bodyList)// .enqueue(object :
|
||||
// Callback<ResponseBody> {
|
||||
if (result.isSuccessful) {
|
||||
if (result.code() == 200) {
|
||||
taskBean.syncStatus = FileUploadStatus.DONE
|
||||
// handle the response
|
||||
change(FileUploadStatus.DONE)
|
||||
} else {
|
||||
// handle the failure
|
||||
Log.e("qj", "")
|
||||
change(FileUploadStatus.ERROR)
|
||||
}
|
||||
})
|
||||
} else {
|
||||
change(FileUploadStatus.ERROR)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,8 +17,9 @@ class LayerConfigUtils {
|
||||
fun getLayerConfigList(): List<ImportConfig> {
|
||||
// 首先读取Shared文件,如果存在则直接返回,否则读取config文件
|
||||
return SPStaticUtils.getString(Constant.EVENT_LAYER_MANAGER_CHANGE, null).let {
|
||||
if (it!=null) {
|
||||
val result: List<ImportConfig> = gson.fromJson(it, object : TypeToken<List<ImportConfig>>(){}.type)
|
||||
if (it != null) {
|
||||
val result: List<ImportConfig> =
|
||||
gson.fromJson(it, object : TypeToken<List<ImportConfig>>() {}.type)
|
||||
result
|
||||
} else {
|
||||
LayerConfigUtils.getLayerConfigListFromAssetsFile()
|
||||
@@ -30,12 +31,13 @@ class LayerConfigUtils {
|
||||
val resultList = mutableListOf<ImportConfig>()
|
||||
if (omdbConfigFile.exists()) {
|
||||
val omdbConfiStr = FileIOUtils.readFile2String(omdbConfigFile)
|
||||
val omdbConfig = gson.fromJson<ImportConfig>(omdbConfiStr, ImportConfig::class.java)
|
||||
val omdbConfig = gson.fromJson<ImportConfig>(omdbConfiStr, ImportConfig::class.java)
|
||||
resultList.add(omdbConfig)
|
||||
}
|
||||
if (otherConfigFile.exists()) {
|
||||
val otherConfiStr = FileIOUtils.readFile2String(otherConfigFile)
|
||||
val otherConfig = gson.fromJson<ImportConfig>(otherConfiStr, ImportConfig::class.java)
|
||||
val otherConfig =
|
||||
gson.fromJson<ImportConfig>(otherConfiStr, ImportConfig::class.java)
|
||||
resultList.add(otherConfig)
|
||||
}
|
||||
return resultList
|
||||
|
||||
@@ -91,6 +91,8 @@ class EvaluationResultViewModel @Inject constructor(
|
||||
|
||||
var mSoundMeter: SoundMeter? = null
|
||||
|
||||
var classTypeTemp: String = ""
|
||||
|
||||
init {
|
||||
liveDataQsRecordBean.value = QsRecordBean(id = UUID.randomUUID().toString())
|
||||
Log.e("jingo", "EvaluationResultViewModel 创建了 ${hashCode()}")
|
||||
@@ -118,7 +120,7 @@ class EvaluationResultViewModel @Inject constructor(
|
||||
/**
|
||||
* 查询数据库,获取问题分类
|
||||
*/
|
||||
fun initNewData(bean: SignBean?,filePath: String) {
|
||||
fun initNewData(bean: SignBean?, filePath: String) {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
getClassTypeList()
|
||||
getProblemLinkList()
|
||||
@@ -128,6 +130,7 @@ class EvaluationResultViewModel @Inject constructor(
|
||||
geoPoint?.let {
|
||||
liveDataQsRecordBean.value!!.geometry = GeometryTools.createGeometry(it).toText()
|
||||
mapController.markerHandle.addMarker(geoPoint, markerTitle)
|
||||
mapController.animationHandler.animationByLonLat(geoPoint.latitude,geoPoint.longitude)
|
||||
viewModelScope.launch {
|
||||
captureLink(geoPoint.longitude, geoPoint.latitude)
|
||||
}
|
||||
@@ -148,6 +151,8 @@ class EvaluationResultViewModel @Inject constructor(
|
||||
}
|
||||
}
|
||||
val point = GeometryTools.createGeoPoint(bean.geometry)
|
||||
liveDataQsRecordBean.value!!.geometry = GeometryTools.createGeometry(point).toText()
|
||||
mapController.animationHandler.animationByLonLat(point.latitude,point.longitude)
|
||||
mapController.markerHandle.addMarker(point, markerTitle)
|
||||
}
|
||||
|
||||
@@ -171,6 +176,7 @@ class EvaluationResultViewModel @Inject constructor(
|
||||
it.linkId =
|
||||
linkList[0].properties[LinkTable.linkPid] ?: ""
|
||||
mapController.lineHandler.showLine(linkList[0].geometry)
|
||||
Log.e("jingo", "捕捉到的linkId = ${it.linkId}")
|
||||
} else {
|
||||
it.linkId = ""
|
||||
mapController.lineHandler.removeLine()
|
||||
@@ -195,6 +201,7 @@ class EvaluationResultViewModel @Inject constructor(
|
||||
if (liveDataQsRecordBean.value!!.classType.isEmpty()) {
|
||||
Log.e("jingo", "getClassTypeList $classType")
|
||||
liveDataQsRecordBean.value!!.classType = classType
|
||||
classTypeTemp = classType
|
||||
}
|
||||
getProblemList(classType)
|
||||
}
|
||||
@@ -284,12 +291,14 @@ class EvaluationResultViewModel @Inject constructor(
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
getProblemList(classType)
|
||||
}
|
||||
classTypeTemp = classType
|
||||
}
|
||||
|
||||
/**
|
||||
* 监听右侧栏的点击事件,修改数据
|
||||
*/
|
||||
fun setPhenomenonMiddleBean(adapterBean: RightBean) {
|
||||
liveDataQsRecordBean.value!!.classType = classTypeTemp
|
||||
liveDataQsRecordBean.value!!.phenomenon = adapterBean.text
|
||||
liveDataQsRecordBean.value!!.problemType = adapterBean.title
|
||||
liveDataQsRecordBean.postValue(liveDataQsRecordBean.value)
|
||||
@@ -304,7 +313,6 @@ class EvaluationResultViewModel @Inject constructor(
|
||||
fun saveData() {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
val realm = Realm.getDefaultInstance()
|
||||
Log.e("jingo", "realm hashCOde ${realm.hashCode()}")
|
||||
realm.executeTransaction {
|
||||
it.copyToRealmOrUpdate(liveDataQsRecordBean.value)
|
||||
}
|
||||
@@ -385,13 +393,13 @@ class EvaluationResultViewModel @Inject constructor(
|
||||
|
||||
fun addChatMsgEntity(filePath: String) {
|
||||
|
||||
if(filePath.isNotEmpty()){
|
||||
if (filePath.isNotEmpty()) {
|
||||
var chatMsgEntityList: MutableList<ChatMsgEntity> = ArrayList()
|
||||
if(listDataChatMsgEntityList.value?.isEmpty() == false){
|
||||
if (listDataChatMsgEntityList.value?.isEmpty() == false) {
|
||||
chatMsgEntityList = listDataChatMsgEntityList.value!!
|
||||
}
|
||||
val chatMsgEntity = ChatMsgEntity()
|
||||
chatMsgEntity.name = filePath.replace(Constant.USER_DATA_ATTACHEMNT_PATH,"").toString()
|
||||
chatMsgEntity.name = filePath.replace(Constant.USER_DATA_ATTACHEMNT_PATH, "").toString()
|
||||
chatMsgEntity.voiceUri = Constant.USER_DATA_ATTACHEMNT_PATH
|
||||
chatMsgEntityList.add(chatMsgEntity)
|
||||
|
||||
@@ -399,7 +407,7 @@ class EvaluationResultViewModel @Inject constructor(
|
||||
var attachmentList: RealmList<AttachmentBean> = RealmList()
|
||||
|
||||
//赋值处理
|
||||
if(liveDataQsRecordBean.value?.attachmentBeanList?.isEmpty() == false){
|
||||
if (liveDataQsRecordBean.value?.attachmentBeanList?.isEmpty() == false) {
|
||||
attachmentList = liveDataQsRecordBean.value?.attachmentBeanList!!
|
||||
}
|
||||
|
||||
@@ -415,7 +423,7 @@ class EvaluationResultViewModel @Inject constructor(
|
||||
|
||||
fun startSoundMetter(activity: Activity, v: View) {
|
||||
|
||||
if(mSpeakMode==null){
|
||||
if (mSpeakMode == null) {
|
||||
mSpeakMode = SpeakMode(activity)
|
||||
}
|
||||
|
||||
@@ -425,7 +433,8 @@ class EvaluationResultViewModel @Inject constructor(
|
||||
pop!!.width = ViewGroup.LayoutParams.MATCH_PARENT
|
||||
pop!!.height = ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
pop!!.setBackgroundDrawable(BitmapDrawable())
|
||||
val view = View.inflate(activity as Context, R.layout.cv_card_voice_rcd_hint_window, null)
|
||||
val view =
|
||||
View.inflate(activity as Context, R.layout.cv_card_voice_rcd_hint_window, null)
|
||||
pop!!.contentView = view
|
||||
volume = view.findViewById(R.id.volume)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user