增加登录接口和问题回传接口变更
This commit is contained in:
parent
c42045ba45
commit
2807b2f689
@ -12,7 +12,7 @@ data class EvaluationInfo(
|
||||
val linkPid: String = "",//Link号
|
||||
|
||||
@SerializedName("linkStatus")
|
||||
val linkStatus: String = "",//Link状态
|
||||
val linkStatus: Int = 0,//Link状态
|
||||
|
||||
@SerializedName("markId")
|
||||
val markId: String = "",//Link状态
|
||||
@ -27,7 +27,7 @@ data class EvaluationInfo(
|
||||
val featureName: String = "",//问题类型
|
||||
|
||||
@SerializedName("problemType")
|
||||
val problemType: String = "",//问题现象
|
||||
val problemType: String = "",//问题现象 0错误 1多余 2遗漏 服务字段定义为Integer,使用包装类,对应无值情况为空
|
||||
|
||||
@SerializedName("problemPhenomenon")
|
||||
val problemPhenomenon: String = "",//问题现象
|
||||
@ -48,6 +48,24 @@ data class EvaluationInfo(
|
||||
val evaluationDate: String = "",//测评日期(yyyy-mm-dd)
|
||||
|
||||
@SerializedName("evaluationWay")
|
||||
val evaluationWay: String = "现场测评"//测评方式
|
||||
val evaluationWay: String = "2",//测评方式 1生产测评 2现场测评 服务字段定义为Integer,使用包装类,对应无值情况为空
|
||||
|
||||
@SerializedName("roadClassfcation")
|
||||
val roadClassfcation: String = "",//道路种别
|
||||
|
||||
@SerializedName("roadFunctionGrade")
|
||||
val roadFunctionGrade: String = "",//道路功能等级
|
||||
|
||||
@SerializedName("noEvaluationreason")
|
||||
val noEvaluationreason: String = "",//未测评原因
|
||||
|
||||
@SerializedName("linkLength")
|
||||
val linkLength: Double = 0.0,//link长度(m 保留3位小数)
|
||||
|
||||
@SerializedName("dataLevel")
|
||||
val dataLevel: String = "",//数据级别
|
||||
|
||||
@SerializedName("linstringLength")
|
||||
val linstringLength: Double = 0.0,//错误要素长度(m)
|
||||
) : Parcelable
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.navinfo.omqs.bean
|
||||
|
||||
data class LoginUserBean(
|
||||
var username: String = "",
|
||||
var password: String = ""
|
||||
var userCode: String = "",
|
||||
var passWord: String = ""
|
||||
)
|
8
app/src/main/java/com/navinfo/omqs/bean/SysUserBean.kt
Normal file
8
app/src/main/java/com/navinfo/omqs/bean/SysUserBean.kt
Normal file
@ -0,0 +1,8 @@
|
||||
package com.navinfo.omqs.bean
|
||||
|
||||
data class SysUserBean(
|
||||
var userName: String = "",
|
||||
var passWord: String = "",
|
||||
var userCode: String = "",
|
||||
var roleId: Int = 0,
|
||||
)
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,6 @@ import androidx.lifecycle.viewModelScope
|
||||
import com.blankj.utilcode.util.ResourceUtils
|
||||
import com.navinfo.omqs.Constant
|
||||
import com.navinfo.omqs.bean.LoginUserBean
|
||||
import com.navinfo.omqs.db.MyRealmModule
|
||||
import com.navinfo.omqs.db.RoomAppDatabase
|
||||
import com.navinfo.omqs.http.NetResult
|
||||
import com.navinfo.omqs.http.NetworkService
|
||||
@ -19,6 +18,7 @@ import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
import io.realm.Realm
|
||||
import io.realm.RealmConfiguration
|
||||
import kotlinx.coroutines.*
|
||||
import retrofit2.Response
|
||||
import java.io.File
|
||||
import java.io.IOException
|
||||
import javax.inject.Inject
|
||||
@ -74,7 +74,7 @@ class LoginViewModel @Inject constructor(
|
||||
var jobLogin: Job? = null;
|
||||
|
||||
init {
|
||||
loginUser.value = LoginUserBean(username = "admin", password = "123456")
|
||||
loginUser.value = LoginUserBean(userCode = "02911", passWord = "123456")
|
||||
}
|
||||
|
||||
|
||||
@ -82,7 +82,7 @@ class LoginViewModel @Inject constructor(
|
||||
* 处理注册按钮
|
||||
*/
|
||||
fun onClick(view: View) {
|
||||
loginUser.value!!.username = "admin2"
|
||||
loginUser.value!!.userCode = "admin2"
|
||||
loginUser.value = loginUser.value
|
||||
}
|
||||
|
||||
@ -111,12 +111,36 @@ class LoginViewModel @Inject constructor(
|
||||
// withContext(Dispatchers.IO) {
|
||||
//网络访问
|
||||
loginStatus.postValue(LoginStatus.LOGIN_STATUS_NET_LOADING)
|
||||
//假装网络访问,等待2秒
|
||||
delay(1000)
|
||||
//登录访问
|
||||
when (val result = networkService.loginUser(LoginUserBean(userName,password))) {
|
||||
is NetResult.Success<*> ->{
|
||||
if (result.data!=null) {
|
||||
try {
|
||||
|
||||
} catch (e: IOException) {
|
||||
loginStatus.postValue(LoginStatus.LOGIN_STATUS_FOLDER_FAILURE)
|
||||
}
|
||||
}
|
||||
}
|
||||
is NetResult.Error<*> ->{
|
||||
withContext(Dispatchers.Main) {
|
||||
Toast.makeText(context, "${result.exception.message}", Toast.LENGTH_SHORT)
|
||||
.show()
|
||||
}
|
||||
}
|
||||
is NetResult.Failure<*> ->{
|
||||
withContext(Dispatchers.Main) {
|
||||
Toast.makeText(context, "${result.code}:${result.msg}", Toast.LENGTH_SHORT)
|
||||
.show()
|
||||
}
|
||||
}
|
||||
else -> {}
|
||||
}
|
||||
|
||||
//文件夹初始化
|
||||
try {
|
||||
loginStatus.postValue(LoginStatus.LOGIN_STATUS_FOLDER_INIT)
|
||||
createUserFolder(context, "02911")
|
||||
createUserFolder(context, userName)
|
||||
} catch (e: IOException) {
|
||||
loginStatus.postValue(LoginStatus.LOGIN_STATUS_FOLDER_FAILURE)
|
||||
}
|
||||
@ -134,13 +158,13 @@ class LoginViewModel @Inject constructor(
|
||||
roomAppDatabase.getOfflineMapDao().insertOrUpdate(result.data)
|
||||
}
|
||||
}
|
||||
is NetResult.Error -> {
|
||||
is NetResult.Error<*> -> {
|
||||
withContext(Dispatchers.Main) {
|
||||
Toast.makeText(context, "${result.exception.message}", Toast.LENGTH_SHORT)
|
||||
.show()
|
||||
}
|
||||
}
|
||||
is NetResult.Failure -> {
|
||||
is NetResult.Failure<*> -> {
|
||||
withContext(Dispatchers.Main) {
|
||||
Toast.makeText(context, "${result.code}:${result.msg}", Toast.LENGTH_SHORT)
|
||||
.show()
|
||||
|
@ -91,13 +91,13 @@ class TaskViewModel @Inject constructor(
|
||||
}
|
||||
}
|
||||
}
|
||||
is NetResult.Error -> {
|
||||
is NetResult.Error<*> -> {
|
||||
withContext(Dispatchers.Main) {
|
||||
Toast.makeText(context, "${result.exception.message}", Toast.LENGTH_SHORT)
|
||||
.show()
|
||||
}
|
||||
}
|
||||
is NetResult.Failure -> {
|
||||
is NetResult.Failure<*> -> {
|
||||
withContext(Dispatchers.Main) {
|
||||
Toast.makeText(context, "${result.code}:${result.msg}", Toast.LENGTH_SHORT)
|
||||
.show()
|
||||
|
@ -92,7 +92,7 @@
|
||||
android:hint="@string/input_user_name"
|
||||
android:lines="1"
|
||||
android:background="@drawable/shape_login_inputlayout_bg"
|
||||
android:text="@{loginUserModel.loginUser.username}"
|
||||
android:text="@{loginUserModel.loginUser.userCode}"
|
||||
tools:ignore="TouchTargetSizeCheck" />
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
@ -113,7 +113,7 @@
|
||||
android:lines="1"
|
||||
android:inputType="textPassword"
|
||||
android:background="@drawable/shape_login_inputlayout_bg"
|
||||
android:text="@{loginUserModel.loginUser.password}"
|
||||
android:text="@{loginUserModel.loginUser.passWord}"
|
||||
tools:ignore="TouchTargetSizeCheck" />
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
|
@ -72,7 +72,8 @@
|
||||
style="@style/btn_default_stroke_horizontal_round"
|
||||
android:layout_width="72dp"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_below="@id/task_data_version"
|
||||
android:layout_marginTop="5dp"
|
||||
android:gravity="center"
|
||||
android:text="下载"
|
||||
android:textSize="@dimen/card_title_font_2size" />
|
||||
@ -108,7 +109,7 @@
|
||||
style="?android:attr/progressBarStyleHorizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="16dp"
|
||||
android:layout_below="@id/task_color"
|
||||
android:layout_below="@id/task_download_btn"
|
||||
android:paddingTop="10dp"
|
||||
android:progressDrawable="@drawable/progress_bg"
|
||||
android:visibility="invisible" />
|
||||
|
Loading…
x
Reference in New Issue
Block a user