增加问题回传业务
This commit is contained in:
parent
ad1156a4fc
commit
977b4b54da
@ -15,7 +15,7 @@ open class TaskBean @JvmOverloads constructor(
|
|||||||
/**
|
/**
|
||||||
* 测评任务id
|
* 测评任务id
|
||||||
*/
|
*/
|
||||||
// @PrimaryKey
|
@PrimaryKey
|
||||||
var id: Int = 0,
|
var id: Int = 0,
|
||||||
/**
|
/**
|
||||||
* 测评任务名称
|
* 测评任务名称
|
||||||
|
@ -64,7 +64,7 @@ class TaskUploadManager constructor(
|
|||||||
taskScopeMap.remove(id)
|
taskScopeMap.remove(id)
|
||||||
for (entrySet in scopeMap) {
|
for (entrySet in scopeMap) {
|
||||||
val uploadScope = entrySet.value
|
val uploadScope = entrySet.value
|
||||||
if (uploadScope.isNotSync()) {
|
if (uploadScope.isWaiting()) {
|
||||||
launchScope(uploadScope)
|
launchScope(uploadScope)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package com.navinfo.omqs.http.taskupload
|
package com.navinfo.omqs.http.taskupload
|
||||||
|
|
||||||
|
import android.os.Build
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
|
import androidx.annotation.RequiresApi
|
||||||
import androidx.lifecycle.LifecycleOwner
|
import androidx.lifecycle.LifecycleOwner
|
||||||
import androidx.lifecycle.MutableLiveData
|
import androidx.lifecycle.MutableLiveData
|
||||||
import androidx.lifecycle.Observer
|
import androidx.lifecycle.Observer
|
||||||
@ -25,7 +27,7 @@ class TaskUploadScope(
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*下载任务,用来取消的
|
* 用来取消的
|
||||||
*/
|
*/
|
||||||
private var uploadJob: Job? = null
|
private var uploadJob: Job? = null
|
||||||
|
|
||||||
@ -68,7 +70,8 @@ class TaskUploadScope(
|
|||||||
* @param status [OfflineMapCityBean.Status]
|
* @param status [OfflineMapCityBean.Status]
|
||||||
*/
|
*/
|
||||||
private fun change(status: Int, message: String = "") {
|
private fun change(status: Int, message: String = "") {
|
||||||
if (taskBean.syncStatus != status ) {
|
if (taskBean.syncStatus != status) {
|
||||||
|
taskBean.syncStatus = status
|
||||||
uploadData.postValue(taskBean)
|
uploadData.postValue(taskBean)
|
||||||
launch {
|
launch {
|
||||||
val realm = Realm.getDefaultInstance()
|
val realm = Realm.getDefaultInstance()
|
||||||
@ -82,8 +85,8 @@ class TaskUploadScope(
|
|||||||
/**
|
/**
|
||||||
* 是否未上传
|
* 是否未上传
|
||||||
*/
|
*/
|
||||||
fun isNotSync(): Boolean {
|
fun isWaiting(): Boolean {
|
||||||
return taskBean.syncStatus == FileManager.Companion.FileUploadStatus.NONE
|
return taskBean.syncStatus == FileManager.Companion.FileUploadStatus.WAITING
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -97,6 +100,7 @@ class TaskUploadScope(
|
|||||||
/**
|
/**
|
||||||
* 上传文件
|
* 上传文件
|
||||||
*/
|
*/
|
||||||
|
@RequiresApi(Build.VERSION_CODES.N)
|
||||||
private suspend fun upload() {
|
private suspend fun upload() {
|
||||||
try {
|
try {
|
||||||
//如果已上传则返回
|
//如果已上传则返回
|
||||||
@ -106,46 +110,65 @@ class TaskUploadScope(
|
|||||||
|
|
||||||
val realm = Realm.getDefaultInstance()
|
val realm = Realm.getDefaultInstance()
|
||||||
taskBean.hadLinkDvoList.forEach {
|
taskBean.hadLinkDvoList.forEach {
|
||||||
val list = realm.where(QsRecordBean::class.java).equalTo("linkId", "123"/*it.linkPid*/).findAll()
|
val hadLinkDvoBean = it
|
||||||
|
val liveDataQSList = MutableLiveData<List<QsRecordBean>>()
|
||||||
|
val objects = realm.where(QsRecordBean::class.java)
|
||||||
|
.equalTo("linkId", /*"84207223282277331"*/hadLinkDvoBean.linkPid).findAll()
|
||||||
|
val bodyList: MutableList<EvaluationInfo> = ArrayList()
|
||||||
|
if (objects != null) {
|
||||||
|
|
||||||
|
liveDataQSList.postValue(realm.copyFromRealm(objects))
|
||||||
|
|
||||||
|
if (liveDataQSList.value!!.isNotEmpty()) {
|
||||||
|
|
||||||
|
liveDataQSList.value?.forEach {
|
||||||
|
val evaluationInfo = EvaluationInfo(
|
||||||
|
taskBean.id.toString(),
|
||||||
|
hadLinkDvoBean.linkPid,//"84207223282277331"
|
||||||
|
"已测评",
|
||||||
|
hadLinkDvoBean.mesh,//"20065597"
|
||||||
|
"",
|
||||||
|
it.geometry,
|
||||||
|
it.classType,
|
||||||
|
it.problemType,
|
||||||
|
it.phenomenon,
|
||||||
|
it.description,
|
||||||
|
it.problemLink,
|
||||||
|
it.cause,
|
||||||
|
it.checkUserId,
|
||||||
|
it.checkTime
|
||||||
|
)
|
||||||
|
|
||||||
|
bodyList.add(evaluationInfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
val list: MutableList<EvaluationInfo> = ArrayList()
|
uploadManager.netApi.postRequest(bodyList).enqueue(object :
|
||||||
val evaluationInfo = EvaluationInfo(taskBean.id.toString(),
|
|
||||||
"123123",
|
|
||||||
"原库",
|
|
||||||
"123123",
|
|
||||||
"",
|
|
||||||
"POINT (116.252097 40.00752)",
|
|
||||||
"点限速",
|
|
||||||
"多余",
|
|
||||||
"多余",
|
|
||||||
"多余",
|
|
||||||
"多余",
|
|
||||||
"多余",
|
|
||||||
"张三",
|
|
||||||
"20230426")
|
|
||||||
|
|
||||||
list.add(evaluationInfo)
|
|
||||||
|
|
||||||
//3. Create an instance of the interface:
|
|
||||||
val apiService = uploadManager.netApi.postRequest(list).enqueue(object :
|
|
||||||
Callback<ResponseBody> {
|
Callback<ResponseBody> {
|
||||||
override fun onResponse(call: Call<ResponseBody>, response: Response<ResponseBody>) {
|
override fun onResponse(
|
||||||
|
call: Call<ResponseBody>,
|
||||||
|
response: Response<ResponseBody>
|
||||||
|
) {
|
||||||
|
if(response.code()==200){
|
||||||
|
taskBean.syncStatus = FileManager.Companion.FileUploadStatus.DONE
|
||||||
// handle the response
|
// handle the response
|
||||||
Log.e("qj","")
|
Log.e("qj", "")
|
||||||
change(FileManager.Companion.FileUploadStatus.NONE)
|
change(FileManager.Companion.FileUploadStatus.DONE)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onFailure(call: Call<ResponseBody>, t: Throwable) {
|
override fun onFailure(call: Call<ResponseBody>, t: Throwable) {
|
||||||
// handle the failure
|
// handle the failure
|
||||||
Log.e("qj","")
|
Log.e("qj", "")
|
||||||
change(FileManager.Companion.FileUploadStatus.ERROR)
|
change(FileManager.Companion.FileUploadStatus.ERROR)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} catch (e: Throwable) {
|
} catch (e: Throwable) {
|
||||||
change(FileManager.Companion.FileUploadStatus.ERROR)
|
change(FileManager.Companion.FileUploadStatus.ERROR)
|
||||||
Log.e("jingo","数据上传出错 ${e.message}")
|
Log.e("jingo", "数据上传出错 ${e.message}")
|
||||||
} finally {
|
} finally {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@ class FileManager {
|
|||||||
const val NONE = 0 //无状态
|
const val NONE = 0 //无状态
|
||||||
const val DONE = 1 //完成
|
const val DONE = 1 //完成
|
||||||
const val ERROR = 2 //错误
|
const val ERROR = 2 //错误
|
||||||
|
const val WAITING = 3 //等待中
|
||||||
}
|
}
|
||||||
|
|
||||||
//初始化数据文件夹
|
//初始化数据文件夹
|
||||||
|
@ -114,9 +114,18 @@ class TaskListAdapter(
|
|||||||
|
|
||||||
private fun changeUploadTxtViews(binding: AdapterTaskListBinding, taskBean: TaskBean) {
|
private fun changeUploadTxtViews(binding: AdapterTaskListBinding, taskBean: TaskBean) {
|
||||||
when (taskBean.syncStatus) {
|
when (taskBean.syncStatus) {
|
||||||
FileManager.Companion.FileUploadStatus.NONE -> {
|
FileManager.Companion.FileUploadStatus.DONE -> {
|
||||||
binding.taskUploadBtn.text = "已上传"
|
binding.taskUploadBtn.text = "已上传"
|
||||||
}
|
}
|
||||||
|
FileManager.Companion.FileUploadStatus.ERROR -> {
|
||||||
|
binding.taskUploadBtn.text = "重新同步"
|
||||||
|
}
|
||||||
|
FileManager.Companion.FileUploadStatus.NONE -> {
|
||||||
|
binding.taskUploadBtn.text = "同步"
|
||||||
|
}
|
||||||
|
FileManager.Companion.FileUploadStatus.WAITING -> {
|
||||||
|
binding.taskUploadBtn.text = "等待同步"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ open class QsRecordBean @JvmOverloads constructor(
|
|||||||
/**
|
/**
|
||||||
* linkPid 绑定的道路ID
|
* linkPid 绑定的道路ID
|
||||||
*/
|
*/
|
||||||
var linkId: String = "123",
|
var linkId: String = "84207223282277331",
|
||||||
/**
|
/**
|
||||||
*问题分类
|
*问题分类
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user