增加登录接口和问题回传接口变更
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
package com.navinfo.omqs.http
|
||||
|
||||
class DefaultUserResponse<T> {
|
||||
var success: Boolean = false
|
||||
var msg: String = ""
|
||||
var obj: T? = null
|
||||
}
|
||||
@@ -31,8 +31,8 @@ package com.navinfo.omqs.http
|
||||
sealed class NetResult<out R> {
|
||||
|
||||
data class Success<out T>(val data: T?) : NetResult<T>()
|
||||
data class Failure(val code: Int, val msg: String) : NetResult<Nothing>()
|
||||
data class Error(val exception: Exception) : NetResult<Nothing>()
|
||||
data class Failure<T>(val code: Int, val msg: String) : NetResult<Nothing>()
|
||||
data class Error<T>(val exception: Exception) : NetResult<Nothing>()
|
||||
object Loading : NetResult<Nothing>()
|
||||
|
||||
/**
|
||||
@@ -42,8 +42,8 @@ sealed class NetResult<out R> {
|
||||
override fun toString(): String {
|
||||
return when (this) {
|
||||
is Success<*> -> "网络访问成功,返回正确结果Success[data=$data]"
|
||||
is Failure -> "网络访问成功,返回错误结果Failure[$msg]"
|
||||
is Error -> "网络访问出错 Error[exception=$exception]"
|
||||
is Failure<*> -> "网络访问成功,返回错误结果Failure[$msg]"
|
||||
is Error<*> -> "网络访问出错 Error[exception=$exception]"
|
||||
is Loading -> "网络访问中 Loading"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,10 @@ package com.navinfo.omqs.http
|
||||
|
||||
import com.navinfo.omqs.bean.OfflineMapCityBean
|
||||
import com.navinfo.collect.library.data.entity.TaskBean
|
||||
import com.navinfo.omqs.bean.LoginUserBean
|
||||
import com.navinfo.omqs.bean.SysUserBean
|
||||
import okhttp3.ResponseBody
|
||||
import retrofit2.Response
|
||||
|
||||
|
||||
/**
|
||||
@@ -16,4 +20,9 @@ interface NetworkService {
|
||||
* 获取任务列表
|
||||
*/
|
||||
suspend fun getTaskList(evaluatorNo:String): NetResult<DefaultTaskResponse<List<TaskBean>>>
|
||||
|
||||
/**
|
||||
* 登录接口
|
||||
*/
|
||||
suspend fun loginUser(loginUserBean: LoginUserBean): NetResult<DefaultUserResponse<SysUserBean>>
|
||||
}
|
||||
@@ -2,8 +2,12 @@ package com.navinfo.omqs.http
|
||||
|
||||
import com.navinfo.omqs.bean.OfflineMapCityBean
|
||||
import com.navinfo.collect.library.data.entity.TaskBean
|
||||
import com.navinfo.omqs.bean.LoginUserBean
|
||||
import com.navinfo.omqs.bean.SysUserBean
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
import okhttp3.ResponseBody
|
||||
import retrofit2.Response
|
||||
import javax.inject.Inject
|
||||
|
||||
/**
|
||||
@@ -24,13 +28,13 @@ class NetworkServiceImpl @Inject constructor(
|
||||
if (result.code() == 200) {
|
||||
NetResult.Success(result.body())
|
||||
} else {
|
||||
NetResult.Failure(result.code(), result.message())
|
||||
NetResult.Failure<Any>(result.code(), result.message())
|
||||
}
|
||||
} else {
|
||||
NetResult.Failure(result.code(), result.message())
|
||||
NetResult.Failure<Any>(result.code(), result.message())
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
NetResult.Error(e)
|
||||
NetResult.Error<Any>(e)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,13 +47,32 @@ class NetworkServiceImpl @Inject constructor(
|
||||
if (result.code() == 200) {
|
||||
NetResult.Success(result.body())
|
||||
} else {
|
||||
NetResult.Failure(result.code(), result.message())
|
||||
NetResult.Failure<Any>(result.code(), result.message())
|
||||
}
|
||||
} else {
|
||||
NetResult.Failure(result.code(), result.message())
|
||||
NetResult.Failure<Any>(result.code(), result.message())
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
NetResult.Error(e)
|
||||
NetResult.Error<Any>(e)
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun loginUser(loginUserBean: LoginUserBean): NetResult<DefaultUserResponse<SysUserBean>> =
|
||||
//在IO线程中运行
|
||||
withContext(Dispatchers.IO) {
|
||||
return@withContext try {
|
||||
val result = netApi.retrofitLoginUser(loginUserBean)
|
||||
if (result.isSuccessful) {
|
||||
if (result.code() == 200) {
|
||||
NetResult.Success(result.body())
|
||||
} else {
|
||||
NetResult.Failure<Any>(result.code(), result.message())
|
||||
}
|
||||
} else {
|
||||
NetResult.Failure<Any>(result.code(), result.message())
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
NetResult.Error<Any>(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,8 @@ package com.navinfo.omqs.http
|
||||
import com.navinfo.omqs.bean.EvaluationInfo
|
||||
import com.navinfo.omqs.bean.OfflineMapCityBean
|
||||
import com.navinfo.collect.library.data.entity.TaskBean
|
||||
import com.navinfo.omqs.bean.LoginUserBean
|
||||
import com.navinfo.omqs.bean.SysUserBean
|
||||
import okhttp3.ResponseBody
|
||||
import retrofit2.Response
|
||||
import retrofit2.http.*
|
||||
@@ -40,6 +42,13 @@ interface RetrofitNetworkServiceAPI {
|
||||
@GET("/drdc/MapDownload/maplist")
|
||||
suspend fun retrofitGetOfflineMapCityList(): Response<List<OfflineMapCityBean>>
|
||||
|
||||
/**
|
||||
* 登录接口
|
||||
*/
|
||||
@Headers("Content-Type: application/json")
|
||||
@POST("/devcp/loginUser")
|
||||
suspend fun retrofitLoginUser(@Body loginUserBean: LoginUserBean): Response<DefaultUserResponse<SysUserBean>>
|
||||
|
||||
/**
|
||||
* 下载文件
|
||||
*/
|
||||
|
||||
@@ -121,26 +121,71 @@ class TaskUploadScope(
|
||||
if (objects != null&&objects.size>0) {
|
||||
val copyList = realm.copyFromRealm(objects)
|
||||
copyList.forEach {
|
||||
var problemType = "0"
|
||||
if(it.problemType=="错误"){
|
||||
problemType = "0"
|
||||
}else if(it.problemType=="多余"){
|
||||
problemType = "1"
|
||||
}else if(it.problemType=="遗漏"){
|
||||
problemType = "2"
|
||||
}
|
||||
var evaluationWay = "2";
|
||||
/* if(it.evaluationWay=="生产测评"){
|
||||
evaluationWay = "1"
|
||||
}else if(it.evaluationWay=="现场测评"){
|
||||
evaluationWay = "2"
|
||||
}*/
|
||||
val evaluationInfo = EvaluationInfo(
|
||||
evaluationTaskId = taskBean.id.toString(),
|
||||
linkPid = hadLinkDvoBean.linkPid,//"84207223282277331"
|
||||
linkStatus = "已测评",
|
||||
linkStatus = 1,
|
||||
markId = hadLinkDvoBean.mesh,//"20065597"
|
||||
trackPhotoNumber = "",
|
||||
markGeometry = it.geometry,
|
||||
featureName = it.classType,
|
||||
problemType = it.problemType,
|
||||
problemType = problemType,
|
||||
problemPhenomenon = it.phenomenon,
|
||||
problemDesc = it.description,
|
||||
problemLink = it.problemLink,
|
||||
problemReason = it.cause,
|
||||
evaluatorName = it.checkUserId,
|
||||
evaluationDate = it.checkTime,
|
||||
evaluationWay = "现场测评"
|
||||
evaluationWay = evaluationWay,
|
||||
roadClassfcation = "",
|
||||
roadFunctionGrade = "",
|
||||
noEvaluationreason = "",
|
||||
linkLength = 0.0,
|
||||
dataLevel = "",
|
||||
linstringLength = 0.0,
|
||||
)
|
||||
|
||||
bodyList.add(evaluationInfo)
|
||||
}
|
||||
}else{
|
||||
val evaluationInfo = EvaluationInfo(
|
||||
evaluationTaskId = taskBean.id.toString(),
|
||||
linkPid = hadLinkDvoBean.linkPid,//"84207223282277331"
|
||||
linkStatus = 0,
|
||||
markId = hadLinkDvoBean.mesh,//"20065597"
|
||||
trackPhotoNumber = "",
|
||||
markGeometry = "",
|
||||
featureName = "",
|
||||
problemType = "",
|
||||
problemPhenomenon = "",
|
||||
problemDesc = "",
|
||||
problemLink = "",
|
||||
problemReason = "",
|
||||
evaluatorName = "",
|
||||
evaluationDate = "",
|
||||
evaluationWay = "",
|
||||
roadClassfcation = "",
|
||||
roadFunctionGrade = "",
|
||||
noEvaluationreason = "",
|
||||
linkLength = 0.0,
|
||||
dataLevel = "",
|
||||
linstringLength = 0.0,
|
||||
)
|
||||
bodyList.add(evaluationInfo)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user