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