重构网络返回对象2.对应服务上报问题接口变更
This commit is contained in:
parent
0d3b16503a
commit
999052507a
@ -12,7 +12,7 @@ data class EvaluationInfo(
|
||||
val linkPid: String = "",//Link号
|
||||
|
||||
@SerializedName("linkStatus")
|
||||
val linkStatus: Int = 0,//Link状态
|
||||
val linkStatus: Int = 0,//Link状态 ;0未测评 1已测评 2原库新增 3现场新增
|
||||
|
||||
@SerializedName("markId")
|
||||
val markId: String = "",//Link状态
|
||||
@ -27,7 +27,7 @@ data class EvaluationInfo(
|
||||
val featureName: String = "",//问题类型
|
||||
|
||||
@SerializedName("problemType")
|
||||
val problemType: String = "",//问题现象 0错误 1多余 2遗漏 服务字段定义为Integer,使用包装类,对应无值情况为空
|
||||
val problemType: Int = 0,//问题现象 0错误 1多余 2遗漏 服务字段定义为Integer,使用包装类,对应无值情况为空
|
||||
|
||||
@SerializedName("problemPhenomenon")
|
||||
val problemPhenomenon: String = "",//问题现象
|
||||
@ -48,7 +48,7 @@ data class EvaluationInfo(
|
||||
val evaluationDate: String = "",//测评日期(yyyy-mm-dd)
|
||||
|
||||
@SerializedName("evaluationWay")
|
||||
val evaluationWay: String = "2",//测评方式 1生产测评 2现场测评 服务字段定义为Integer,使用包装类,对应无值情况为空
|
||||
val evaluationWay: Int = 2,//测评方式 1生产测评 2现场测评 服务字段定义为Integer,使用包装类,对应无值情况为空
|
||||
|
||||
@SerializedName("roadClassfcation")
|
||||
val roadClassfcation: String = "",//道路种别
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.navinfo.omqs.http
|
||||
|
||||
class DefaultTaskResponse<T> {
|
||||
class DefaultResponse<T> {
|
||||
var success: Boolean = false
|
||||
var msg: String = ""
|
||||
var obj: T? = null
|
@ -1,7 +0,0 @@
|
||||
package com.navinfo.omqs.http
|
||||
|
||||
class DefaultUserResponse<T> {
|
||||
var success: Boolean = false
|
||||
var msg: String = ""
|
||||
var obj: T? = null
|
||||
}
|
@ -19,10 +19,10 @@ interface NetworkService {
|
||||
/**
|
||||
* 获取任务列表
|
||||
*/
|
||||
suspend fun getTaskList(evaluatorNo:String): NetResult<DefaultTaskResponse<List<TaskBean>>>
|
||||
suspend fun getTaskList(evaluatorNo:String): NetResult<DefaultResponse<List<TaskBean>>>
|
||||
|
||||
/**
|
||||
* 登录接口
|
||||
*/
|
||||
suspend fun loginUser(loginUserBean: LoginUserBean): NetResult<DefaultUserResponse<SysUserBean>>
|
||||
suspend fun loginUser(loginUserBean: LoginUserBean): NetResult<DefaultResponse<SysUserBean>>
|
||||
}
|
@ -38,7 +38,7 @@ class NetworkServiceImpl @Inject constructor(
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun getTaskList(evaluatorNo: String): NetResult<DefaultTaskResponse<List<TaskBean>>> =
|
||||
override suspend fun getTaskList(evaluatorNo: String): NetResult<DefaultResponse<List<TaskBean>>> =
|
||||
//在IO线程中运行
|
||||
withContext(Dispatchers.IO) {
|
||||
return@withContext try {
|
||||
@ -57,7 +57,7 @@ class NetworkServiceImpl @Inject constructor(
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun loginUser(loginUserBean: LoginUserBean): NetResult<DefaultUserResponse<SysUserBean>> =
|
||||
override suspend fun loginUser(loginUserBean: LoginUserBean): NetResult<DefaultResponse<SysUserBean>> =
|
||||
//在IO线程中运行
|
||||
withContext(Dispatchers.IO) {
|
||||
return@withContext try {
|
||||
|
@ -47,7 +47,7 @@ interface RetrofitNetworkServiceAPI {
|
||||
*/
|
||||
@Headers("Content-Type: application/json")
|
||||
@POST("/devcp/loginUser")
|
||||
suspend fun retrofitLoginUser(@Body loginUserBean: LoginUserBean): Response<DefaultUserResponse<SysUserBean>>
|
||||
suspend fun retrofitLoginUser(@Body loginUserBean: LoginUserBean): Response<DefaultResponse<SysUserBean>>
|
||||
|
||||
/**
|
||||
* 下载文件
|
||||
@ -62,11 +62,11 @@ interface RetrofitNetworkServiceAPI {
|
||||
@GET("/devcp/getEvaluationTask?evaluatType=2")
|
||||
suspend fun retrofitGetTaskList(
|
||||
@Query("evaluatorNo") evaluatorNo: String,
|
||||
): Response<DefaultTaskResponse<List<TaskBean>>>
|
||||
): Response<DefaultResponse<List<TaskBean>>>
|
||||
|
||||
@Headers("Content-Type: application/json")
|
||||
@POST("/devcp/uploadSceneProblem")
|
||||
suspend fun postRequest(@Body listEvaluationInfo: List<EvaluationInfo>?): Response<ResponseBody>
|
||||
suspend fun postRequest(@Body listEvaluationInfo: List<EvaluationInfo>?): Response<DefaultResponse<*>>
|
||||
|
||||
/**
|
||||
* @FormUrlEncoded 请求格式注解,请求实体是一个From表单,每个键值对需要使用@Field注解
|
||||
|
@ -2,6 +2,7 @@ package com.navinfo.omqs.http.taskupload
|
||||
|
||||
import android.os.Build
|
||||
import android.util.Log
|
||||
import android.widget.Toast
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.lifecycle.LifecycleOwner
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
@ -9,6 +10,8 @@ import androidx.lifecycle.Observer
|
||||
import com.navinfo.collect.library.data.entity.QsRecordBean
|
||||
import com.navinfo.omqs.bean.EvaluationInfo
|
||||
import com.navinfo.collect.library.data.entity.TaskBean
|
||||
import com.navinfo.omqs.bean.SysUserBean
|
||||
import com.navinfo.omqs.http.DefaultResponse
|
||||
import com.navinfo.omqs.tools.FileManager.Companion.FileUploadStatus
|
||||
import io.realm.Realm
|
||||
import kotlinx.coroutines.*
|
||||
@ -68,6 +71,7 @@ class TaskUploadScope(
|
||||
private fun change(status: Int, message: String = "") {
|
||||
if (taskBean.syncStatus != status) {
|
||||
taskBean.syncStatus = status
|
||||
taskBean.errMsg = message
|
||||
uploadData.postValue(taskBean)
|
||||
//同步中不进行状态记录,只做界面变更显示
|
||||
if(status!=FileUploadStatus.UPLOADING){
|
||||
@ -121,15 +125,15 @@ class TaskUploadScope(
|
||||
if (objects != null&&objects.size>0) {
|
||||
val copyList = realm.copyFromRealm(objects)
|
||||
copyList.forEach {
|
||||
var problemType = "0"
|
||||
var problemType = 0
|
||||
if(it.problemType=="错误"){
|
||||
problemType = "0"
|
||||
problemType = 0
|
||||
}else if(it.problemType=="多余"){
|
||||
problemType = "1"
|
||||
problemType = 1
|
||||
}else if(it.problemType=="遗漏"){
|
||||
problemType = "2"
|
||||
problemType = 2
|
||||
}
|
||||
var evaluationWay = "2";
|
||||
var evaluationWay = 2
|
||||
/* if(it.evaluationWay=="生产测评"){
|
||||
evaluationWay = "1"
|
||||
}else if(it.evaluationWay=="现场测评"){
|
||||
@ -170,14 +174,14 @@ class TaskUploadScope(
|
||||
trackPhotoNumber = "",
|
||||
markGeometry = "",
|
||||
featureName = "",
|
||||
problemType = "",
|
||||
problemType = 0,
|
||||
problemPhenomenon = "",
|
||||
problemDesc = "",
|
||||
problemLink = "",
|
||||
problemReason = "",
|
||||
evaluatorName = "",
|
||||
evaluationDate = "",
|
||||
evaluationWay = "",
|
||||
evaluationWay = 2,
|
||||
roadClassfcation = "",
|
||||
roadFunctionGrade = "",
|
||||
noEvaluationreason = "",
|
||||
@ -193,10 +197,13 @@ class TaskUploadScope(
|
||||
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)
|
||||
if (result.code() == 200&&result.body()!=null) {
|
||||
val defaultUserResponse = result.body() as DefaultResponse<*>
|
||||
if(defaultUserResponse.success){
|
||||
change(FileUploadStatus.DONE)
|
||||
}else{
|
||||
change(FileUploadStatus.ERROR,"${defaultUserResponse.msg}")
|
||||
}
|
||||
} else {
|
||||
// handle the failure
|
||||
change(FileUploadStatus.ERROR)
|
||||
|
@ -12,7 +12,7 @@ import com.navinfo.omqs.Constant
|
||||
import com.navinfo.omqs.bean.LoginUserBean
|
||||
import com.navinfo.omqs.bean.SysUserBean
|
||||
import com.navinfo.omqs.db.RoomAppDatabase
|
||||
import com.navinfo.omqs.http.DefaultUserResponse
|
||||
import com.navinfo.omqs.http.DefaultResponse
|
||||
import com.navinfo.omqs.http.NetResult
|
||||
import com.navinfo.omqs.http.NetworkService
|
||||
import com.navinfo.omqs.tools.FileManager
|
||||
@ -119,7 +119,7 @@ class LoginViewModel @Inject constructor(
|
||||
is NetResult.Success<*> ->{
|
||||
if (result.data!=null) {
|
||||
try {
|
||||
val defaultUserResponse = result.data as DefaultUserResponse<SysUserBean>
|
||||
val defaultUserResponse = result.data as DefaultResponse<SysUserBean>
|
||||
if(defaultUserResponse.success){
|
||||
if(defaultUserResponse.obj==null|| defaultUserResponse.obj!!.userCode==null){
|
||||
withContext(Dispatchers.Main) {
|
||||
|
@ -292,9 +292,10 @@ class MainViewModel @Inject constructor(
|
||||
}
|
||||
linkIdCache = linkId ?: ""
|
||||
Log.e("jingo", "自动捕捉数据 共${signList.size}条")
|
||||
} else {
|
||||
mapController.lineHandler.removeLine()
|
||||
}
|
||||
}else{
|
||||
mapController.lineHandler.removeLine()
|
||||
linkIdCache = ""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import android.util.Log
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.Toast
|
||||
import androidx.lifecycle.Observer
|
||||
import com.navinfo.collect.library.data.entity.TaskBean
|
||||
import com.navinfo.omqs.R
|
||||
@ -56,7 +57,7 @@ class TaskListAdapter(
|
||||
val taskBean = data[it.tag as Int]
|
||||
Log.e("jingo", "开始上传 ${taskBean.syncStatus}")
|
||||
when (taskBean.syncStatus) {
|
||||
FileUploadStatus.NONE, FileUploadStatus.ERROR, FileUploadStatus.WAITING -> {
|
||||
FileUploadStatus.NONE, FileUploadStatus.UPLOADING,FileUploadStatus.ERROR, FileUploadStatus.WAITING -> {
|
||||
uploadManager.start(taskBean.id)
|
||||
}
|
||||
}
|
||||
@ -251,6 +252,10 @@ class TaskListAdapter(
|
||||
} else {
|
||||
binding.taskProgressText.text = "0%"
|
||||
}
|
||||
val errMsg = taskBean.errMsg
|
||||
if(errMsg!=null&&errMsg.isNotEmpty()){
|
||||
Toast.makeText(binding.taskProgressText.context,errMsg,Toast.LENGTH_LONG)
|
||||
}
|
||||
}
|
||||
FileDownloadStatus.IMPORT -> {
|
||||
if (binding.taskProgressText.visibility != View.VISIBLE) binding.taskProgressText.visibility =
|
||||
|
@ -65,9 +65,8 @@
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/sign_main_fast_error"
|
||||
android:layout_marginRight="4dp"
|
||||
android:layout_marginLeft="172dp"
|
||||
android:layout_marginTop="4dp"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentTop="true"
|
||||
android:background="@drawable/icon_evaluation"
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -62,6 +62,8 @@ open class TaskBean @JvmOverloads constructor(
|
||||
|
||||
@Ignore
|
||||
var message: String = "",
|
||||
@Ignore
|
||||
var errMsg: String = "",
|
||||
var color: Int = 0xFF00AA
|
||||
) : RealmObject() {
|
||||
fun getDownLoadUrl(): String {
|
||||
|
Loading…
x
Reference in New Issue
Block a user