修改离线地图下载,数据下载安装
This commit is contained in:
parent
94ce90b680
commit
840bd24b7c
@ -48,6 +48,6 @@ data class EvaluationInfo(
|
||||
val evaluationDate: String = "",//测评日期(yyyy-mm-dd)
|
||||
|
||||
@SerializedName("evaluationWay")
|
||||
val evaluationWay: String = ""//测评方式
|
||||
val evaluationWay: String = "现场测评"//测评方式
|
||||
) : Parcelable
|
||||
|
||||
|
@ -112,57 +112,54 @@ class TaskUploadScope(
|
||||
}
|
||||
|
||||
val realm = Realm.getDefaultInstance()
|
||||
val bodyList: MutableList<EvaluationInfo> = ArrayList()
|
||||
taskBean.hadLinkDvoList.forEach { hadLinkDvoBean ->
|
||||
val objects = realm.where(QsRecordBean::class.java)
|
||||
.equalTo("linkId", /*"84207223282277331"*/hadLinkDvoBean.linkPid).findAll()
|
||||
if (objects.size == 0) {
|
||||
if (taskBean.syncStatus == FileUploadStatus.WAITING)
|
||||
change(FileUploadStatus.NONE)
|
||||
return
|
||||
}
|
||||
|
||||
val bodyList: MutableList<EvaluationInfo> = ArrayList()
|
||||
|
||||
if (objects != null) {
|
||||
val copyList = realm.copyFromRealm(objects)
|
||||
copyList.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
|
||||
evaluationTaskId = taskBean.id.toString(),
|
||||
linkPid = hadLinkDvoBean.linkPid,//"84207223282277331"
|
||||
linkStatus = "已测评",
|
||||
markId = hadLinkDvoBean.mesh,//"20065597"
|
||||
trackPhotoNumber = "",
|
||||
markGeometry = it.geometry,
|
||||
featureName = it.classType,
|
||||
problemType = it.problemType,
|
||||
problemPhenomenon = it.phenomenon,
|
||||
problemDesc = it.description,
|
||||
problemLink = it.problemLink,
|
||||
problemReason = it.cause,
|
||||
evaluatorName = it.checkUserId,
|
||||
evaluationDate = it.checkTime,
|
||||
evaluationWay = "现场测评"
|
||||
)
|
||||
|
||||
bodyList.add(evaluationInfo)
|
||||
}
|
||||
|
||||
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)
|
||||
} else {
|
||||
// handle the failure
|
||||
change(FileUploadStatus.ERROR)
|
||||
}
|
||||
} else {
|
||||
change(FileUploadStatus.ERROR)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (bodyList.size == 0) {
|
||||
if (taskBean.syncStatus == FileUploadStatus.WAITING)
|
||||
change(FileUploadStatus.NONE)
|
||||
return
|
||||
}
|
||||
val result = uploadManager.netApi.postRequest(bodyList)// .enqueue(object :
|
||||
// Callback<ResponseBody> {
|
||||
if (result.isSuccessful) {
|
||||
if (result.code() == 200) {
|
||||
// handle the response
|
||||
change(FileUploadStatus.DONE)
|
||||
} else {
|
||||
// handle the failure
|
||||
change(FileUploadStatus.ERROR)
|
||||
}
|
||||
} else {
|
||||
change(FileUploadStatus.ERROR)
|
||||
}
|
||||
} catch (e: Throwable) {
|
||||
change(FileUploadStatus.ERROR)
|
||||
Log.e("jingo", "数据上传出错 ${e.message}")
|
||||
|
@ -68,25 +68,34 @@ class OfflineMapCityListAdapter(
|
||||
val cityBean = data[position]
|
||||
//tag 方便onclick里拿到数据
|
||||
holder.tag = cityBean.id
|
||||
|
||||
changeViews(binding, cityBean)
|
||||
downloadManager.addTask(cityBean)
|
||||
downloadManager.observer(cityBean.id, holder, DownloadObserver(cityBean.id, binding))
|
||||
downloadManager.observer(cityBean.id, holder, DownloadObserver(cityBean.id, holder))
|
||||
binding.offlineMapDownloadBtn.tag = position
|
||||
binding.offlineMapDownloadBtn.setOnClickListener(downloadBtnClick)
|
||||
binding.offlineMapCityName.text = cityBean.name
|
||||
binding.offlineMapCitySize.text = cityBean.getFileSizeText()
|
||||
}
|
||||
|
||||
inner class DownloadObserver(val id: String, val binding: AdapterOfflineMapCityBinding) :
|
||||
inner class DownloadObserver(val id: String, val holder: BaseViewHolder) :
|
||||
Observer<OfflineMapCityBean> {
|
||||
override fun onChanged(t: OfflineMapCityBean?) {
|
||||
if (id == t?.id)
|
||||
changeViews(binding, t)
|
||||
override fun onChanged(offlineMapCityBean: OfflineMapCityBean?) {
|
||||
offlineMapCityBean?.let { bean ->
|
||||
if (id == holder.tag) {
|
||||
val binding: AdapterOfflineMapCityBinding =
|
||||
holder.viewBinding as AdapterOfflineMapCityBinding
|
||||
Log.e("jingo", "进度条更新 $id ${bean.id} ${holder.tag} ")
|
||||
changeViews(binding, bean)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private fun changeViews(binding: AdapterOfflineMapCityBinding, cityBean: OfflineMapCityBean) {
|
||||
Log.e("jingo", "changeViews ${cityBean.status}")
|
||||
binding.offlineMapProgress.progress =
|
||||
(cityBean.currentSize * 100 / cityBean.fileSize).toInt()
|
||||
when (cityBean.status) {
|
||||
|
@ -59,7 +59,7 @@ class TaskListAdapter(
|
||||
val taskBean = data[it.tag as Int]
|
||||
Log.e("jingo", "开始上传 ${taskBean.syncStatus}")
|
||||
when (taskBean.syncStatus) {
|
||||
FileUploadStatus.NONE, FileUploadStatus.ERROR -> {
|
||||
FileUploadStatus.NONE, FileUploadStatus.ERROR,FileUploadStatus.WAITING -> {
|
||||
uploadManager.start(taskBean.id)
|
||||
}
|
||||
}
|
||||
|
@ -74,8 +74,6 @@ class TaskListViewModel @Inject constructor(
|
||||
realm.copyToRealmOrUpdate(task)
|
||||
}
|
||||
}
|
||||
val objects = realm.where(TaskBean::class.java).findAll()
|
||||
taskList = realm.copyFromRealm(objects)
|
||||
|
||||
}
|
||||
}
|
||||
@ -94,7 +92,9 @@ class TaskListViewModel @Inject constructor(
|
||||
}
|
||||
is NetResult.Loading -> {}
|
||||
}
|
||||
|
||||
val realm = Realm.getDefaultInstance()
|
||||
val objects = realm.where(TaskBean::class.java).findAll()
|
||||
taskList = realm.copyFromRealm(objects)
|
||||
for (item in taskList) {
|
||||
FileManager.checkOMDBFileInfo(item)
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ open class QsRecordBean @JvmOverloads constructor(
|
||||
/**
|
||||
* 质检员ID
|
||||
*/
|
||||
var checkUserId: String = "",
|
||||
var checkUserId: String = "张海球",
|
||||
/**
|
||||
* 质检日期
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user