This commit is contained in:
qiji4215 2023-05-05 14:48:00 +08:00
commit af79ae4146
15 changed files with 158 additions and 82 deletions

View File

@ -7,9 +7,16 @@ import kotlinx.parcelize.Parcelize
data class SignBean(
//图标ID
val iconId: Int,
//定位点到目标距离
val distance: Int = 0,
//图表中的问题
val iconText: String = "",
//绑定的要素id
val elementId: String = "",
//绑定的linkid
val linkId: String,
//坐标
val geometry: String,
//底部文字
val bottomText: String,
) : Parcelable

View File

@ -64,9 +64,11 @@ open class TaskBean @JvmOverloads constructor(
var syncStatus: Int = FileManager.Companion.FileUploadStatus.NONE,
@Ignore
var message: String = ""
var message: String = "",
var color: Int = 0xFF00AA
) : RealmObject() {
fun getDownLoadUrl(): String {
return "${Constant.SERVER_ADDRESS}devcp/download?fileStr=$id"
}
}

View File

@ -66,7 +66,7 @@ class GlobalModule {
}.apply {
level = if (Constant.DEBUG) {
//坑 下载文件时打印log 内存不足
HttpLoggingInterceptor.Level.HEADERS
HttpLoggingInterceptor.Level.BASIC
} else {
HttpLoggingInterceptor.Level.NONE
}

View File

@ -58,7 +58,7 @@ interface RetrofitNetworkServiceAPI {
@Headers("Content-Type: application/json")
@POST("/devcp/upload")
fun postRequest(@Body listEvaluationInfo: List<EvaluationInfo>?): Call<ResponseBody>
suspend fun postRequest(@Body listEvaluationInfo: List<EvaluationInfo>?): Call<ResponseBody>
/**
* @FormUrlEncoded 请求格式注解请求实体是一个From表单每个键值对需要使用@Field注解

View File

@ -91,7 +91,6 @@ class TaskDownloadScope(
* @param status [OfflineMapCityBean.Status]
*/
private suspend fun change(status: Int, message: String = "") {
Log.e("jingo", "我被挂起 S")
if (taskBean.status != status || status == FileDownloadStatus.LOADING || status == FileDownloadStatus.IMPORTING) {
taskBean.status = status
taskBean.message = message
@ -103,7 +102,6 @@ class TaskDownloadScope(
}
}
}
Log.e("jingo", "我被挂起 E")
}
/**

View File

@ -10,7 +10,7 @@ import com.navinfo.collect.library.data.entity.QsRecordBean
import com.navinfo.omqs.bean.EvaluationInfo
import com.navinfo.omqs.bean.TaskBean
import com.navinfo.omqs.tools.FileManager
import com.navinfo.omqs.tools.FileManager.Companion.FileDownloadStatus
import com.navinfo.omqs.tools.FileManager.Companion.FileUploadStatus
import io.realm.Realm
import kotlinx.coroutines.*
import okhttp3.ResponseBody
@ -48,7 +48,7 @@ class TaskUploadScope(
//改进的代码
fun start() {
change(FileDownloadStatus.WAITING)
change(FileUploadStatus.WAITING)
uploadManager.launchScope(this@TaskUploadScope)
}
@ -59,7 +59,9 @@ class TaskUploadScope(
*/
fun launch() {
uploadJob = launch() {
upload()
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
upload()
}
uploadManager.launchNext(taskBean.id)
}
}
@ -86,7 +88,7 @@ class TaskUploadScope(
* 是否未上传
*/
fun isWaiting(): Boolean {
return taskBean.syncStatus == FileManager.Companion.FileUploadStatus.WAITING
return taskBean.syncStatus == FileUploadStatus.WAITING
}
/**
@ -104,70 +106,62 @@ class TaskUploadScope(
private suspend fun upload() {
try {
//如果已上传则返回
if (taskBean.syncStatus == FileManager.Companion.FileUploadStatus.DONE) {
if (taskBean.syncStatus == FileUploadStatus.DONE) {
return
}
val realm = Realm.getDefaultInstance()
taskBean.hadLinkDvoList.forEach {
val hadLinkDvoBean = it
val liveDataQSList = MutableLiveData<List<QsRecordBean>>()
taskBean.hadLinkDvoList.forEach { hadLinkDvoBean ->
val objects = realm.where(QsRecordBean::class.java)
.equalTo("linkId", /*"84207223282277331"*/hadLinkDvoBean.linkPid).findAll()
val bodyList: MutableList<EvaluationInfo> = ArrayList()
if (objects != null) {
objects.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
)
liveDataQSList.postValue(realm.copyFromRealm(objects))
bodyList.add(evaluationInfo)
}
if (liveDataQSList.value!!.isNotEmpty()) {
liveDataQSList.value?.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
)
bodyList.add(evaluationInfo)
uploadManager.netApi.postRequest(bodyList).enqueue(object :
Callback<ResponseBody> {
override fun onResponse(
call: Call<ResponseBody>,
response: Response<ResponseBody>
) {
if (response.code() == 200) {
taskBean.syncStatus = FileUploadStatus.DONE
// handle the response
Log.e("qj", "")
change(FileUploadStatus.DONE)
}
}
uploadManager.netApi.postRequest(bodyList).enqueue(object :
Callback<ResponseBody> {
override fun onResponse(
call: Call<ResponseBody>,
response: Response<ResponseBody>
) {
if(response.code()==200){
taskBean.syncStatus = FileManager.Companion.FileUploadStatus.DONE
// handle the response
Log.e("qj", "")
change(FileManager.Companion.FileUploadStatus.DONE)
}
}
override fun onFailure(call: Call<ResponseBody>, t: Throwable) {
// handle the failure
Log.e("qj", "")
change(FileManager.Companion.FileUploadStatus.ERROR)
}
})
}
override fun onFailure(call: Call<ResponseBody>, t: Throwable) {
// handle the failure
Log.e("qj", "")
change(FileUploadStatus.ERROR)
}
})
}
}
} catch (e: Throwable) {
change(FileManager.Companion.FileUploadStatus.ERROR)
change(FileUploadStatus.ERROR)
Log.e("jingo", "数据上传出错 ${e.message}")
} finally {

View File

@ -3,6 +3,7 @@ package com.navinfo.omqs.ui.activity.map
import android.app.Activity
import android.content.Context
import android.content.DialogInterface
import android.graphics.Color
import android.graphics.drawable.AnimationDrawable
import android.graphics.drawable.BitmapDrawable
import android.os.Build
@ -30,6 +31,7 @@ import com.navinfo.omqs.Constant
import com.navinfo.omqs.R
import com.navinfo.omqs.bean.ImportConfig
import com.navinfo.omqs.bean.SignBean
import com.navinfo.omqs.bean.TaskBean
import com.navinfo.omqs.db.RealmOperateHelper
import com.navinfo.omqs.ui.dialog.CommonDialog
import com.navinfo.omqs.ui.manager.TakePhotoManager
@ -39,6 +41,7 @@ import com.navinfo.omqs.util.FlowEventBus
import com.navinfo.omqs.util.SoundMeter
import com.navinfo.omqs.util.SpeakMode
import dagger.hilt.android.lifecycle.HiltViewModel
import io.realm.Realm
import io.realm.RealmSet
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.collect
@ -97,6 +100,36 @@ class MainViewModel @Inject constructor(
testPoint = it
}
}
initTaskData()
}
/**
* 初始话任务高亮高亮
*/
private fun initTaskData() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
viewModelScope.launch {
val realm = Realm.getDefaultInstance()
val results = realm.where(TaskBean::class.java).findAll()
val list = realm.copyFromRealm(results)
results.addChangeListener { changes ->
val list2 = realm.copyFromRealm(changes)
mapController.lineHandler.omdbTaskLinkLayer.removeAll()
for (item in list2) {
mapController.lineHandler.omdbTaskLinkLayer.addLineList(item.hadLinkDvoList)
}
}
mapController.lineHandler.omdbTaskLinkLayer.removeAll()
for (item in list) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
mapController.lineHandler.omdbTaskLinkLayer.setLineColor(Color.valueOf(item.color))
}
mapController.lineHandler.omdbTaskLinkLayer.addLineList(item.hadLinkDvoList)
}
}
// realm.close()
}
}
private fun initLocation() {
@ -163,11 +196,12 @@ class MainViewModel @Inject constructor(
signList.add(
SignBean(
iconId = SignUtil.getSignIcon(element),
iconText = SignUtil.getSignText(element),
iconText = SignUtil.getSignIconText(element),
distance = distance.toInt(),
elementId = element.id,
linkId = linkId,
geometry = element.geometry
geometry = element.geometry,
bottomText = SignUtil.getSignBottomText(element)
)
)
}

View File

@ -1,6 +1,7 @@
package com.navinfo.omqs.ui.fragment.tasklist
import android.content.Context
import android.graphics.Color
import android.util.Log
import android.view.LayoutInflater
import android.view.View
@ -13,9 +14,11 @@ import com.navinfo.omqs.http.taskdownload.TaskDownloadManager
import com.navinfo.omqs.http.taskupload.TaskUploadManager
import com.navinfo.omqs.tools.FileManager
import com.navinfo.omqs.tools.FileManager.Companion.FileDownloadStatus
import com.navinfo.omqs.tools.FileManager.Companion.FileUploadStatus
import com.navinfo.omqs.ui.other.BaseRecyclerViewAdapter
import com.navinfo.omqs.ui.other.BaseViewHolder
import java.io.File
import java.util.*
import javax.inject.Inject
/**
@ -56,7 +59,7 @@ class TaskListAdapter(
val taskBean = data[it.tag as Int]
Log.e("jingo", "开始上传 ${taskBean.syncStatus}")
when (taskBean.syncStatus) {
FileManager.Companion.FileUploadStatus.NONE->{
FileUploadStatus.NONE, FileUploadStatus.ERROR -> {
uploadManager.start(taskBean.id)
}
}
@ -93,6 +96,7 @@ class TaskListAdapter(
binding.taskName.text = taskBean.evaluationTaskName
binding.taskCityName.text = taskBean.cityName
binding.taskDataVersion.text = "版本号:${taskBean.dataVersion}"
binding.taskColor.setTextColor(taskBean.color)
// binding.offlineMapCitySize.text = cityBean.getFileSizeText()
}
@ -114,16 +118,16 @@ class TaskListAdapter(
private fun changeUploadTxtViews(binding: AdapterTaskListBinding, taskBean: TaskBean) {
when (taskBean.syncStatus) {
FileManager.Companion.FileUploadStatus.DONE -> {
FileUploadStatus.DONE -> {
binding.taskUploadBtn.text = "已上传"
}
FileManager.Companion.FileUploadStatus.ERROR -> {
FileUploadStatus.ERROR -> {
binding.taskUploadBtn.text = "重新同步"
}
FileManager.Companion.FileUploadStatus.NONE -> {
FileUploadStatus.NONE -> {
binding.taskUploadBtn.text = "同步"
}
FileManager.Companion.FileUploadStatus.WAITING -> {
FileUploadStatus.WAITING -> {
binding.taskUploadBtn.text = "等待同步"
}
}

View File

@ -2,11 +2,8 @@ package com.navinfo.omqs.ui.fragment.tasklist
import android.content.Context
import android.graphics.Color
import android.os.Build
import android.util.Log
import android.widget.Toast
import androidx.annotation.RequiresApi
import androidx.core.graphics.toColor
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
@ -20,6 +17,7 @@ import io.realm.Realm
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import java.util.*
import javax.inject.Inject
@HiltViewModel
@ -30,6 +28,9 @@ class TaskListViewModel @Inject constructor(
val liveDataTaskList = MutableLiveData<List<TaskBean>>()
/**
* 下载任务列表
*/
fun getTaskList(context: Context) {
viewModelScope.launch(Dispatchers.IO) {
@ -49,6 +50,16 @@ class TaskListViewModel @Inject constructor(
Log.e("jingo", "当前文件大小 ${task.fileSize}")
task.status = item.status
task.currentSize = item.currentSize
task.color = item.color
} else {
val random = Random()
task.color = Color.argb(
255,
random.nextInt(256),
random.nextInt(256),
random.nextInt(256)
)
Log.e("jingo", "任务颜色 ${task.color}")
}
realm.copyToRealmOrUpdate(task)
}
@ -76,7 +87,9 @@ class TaskListViewModel @Inject constructor(
for (item in taskList) {
FileManager.checkOMDBFileInfo(item)
}
// niMapController.lineHandler.omdbTaskLinkLayer.setLineColor(Color.rgb(0, 255, 0).toColor())
// niMapController.lineHandler.omdbTaskLinkLayer.setLineColor(
// Color.rgb(0, 255, 0).toColor()
// )
// taskList.forEach {
// niMapController.lineHandler.omdbTaskLinkLayer.addLineList(it.hadLinkDvoList)
// }

View File

@ -10,7 +10,7 @@ class SignUtil {
/**
* 获取面板上的文字
*/
fun getSignText(data: RenderEntity): String {
fun getSignIconText(data: RenderEntity): String {
return when (data.code) {
//常规点限速
4002 -> getSpeedLimitText(data)
@ -24,14 +24,28 @@ class SignUtil {
}
}
fun getSignBottomText(data: RenderEntity): String {
return when (data.code) {
//常规点限速
4002 -> "常规点限速"
//道路种别
2008 -> "道路种别"
//道路方向
2010 -> "道路方向"
//车道数
2041 -> "车道数"
else -> ""
}
}
/**
* 获取限速值文字
*/
private fun getSpeedLimitText(data: RenderEntity): String {
try {
//限速标志 0 限速开始 1 限速解除
val maxSpeed = data.properties["max_speed"]
val minSpeed = data.properties["min_speed"]
val maxSpeed = data.properties["maxSpeed"]
val minSpeed = data.properties["minSpeed"]
return if (maxSpeed != "0")
maxSpeed.toString()
else
@ -48,8 +62,7 @@ class SignUtil {
fun getSpeedLimitIcon(data: RenderEntity): Int {
try {
//限速标志 0 限速开始 1 限速解除
val speedFlag = data.properties["speed_flag"]
return when (speedFlag) {
return when (data.properties["speed_flag"]) {
"1" -> return R.drawable.icon_speed_limit_off
else -> return R.drawable.icon_speed_limit
}

View File

@ -106,7 +106,7 @@ public class FileUtils {
while ((byteread = inStream.read(buffer)) != -1) {
bytesum += byteread; // 字节数 文件大小
System.out.println(bytesum);
// System.out.println(bytesum);
fs.write(buffer, 0, byteread);
}
@ -398,7 +398,7 @@ public class FileUtils {
for (String str : suffix) {
if (fileName.endsWith(str)) { // 判断文件名是否以
String strFileName = files[i].getAbsolutePath();
System.out.println("---" + strFileName);
// System.out.println("---" + strFileName);
filelist.add(files[i]);
}
}

View File

@ -50,7 +50,7 @@
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/main_activity_sign_recyclerview"
android:layout_width="150dp"
android:layout_width="wrap_content"
android:layout_height="350dp"
android:layout_marginTop="10dp"
app:layout_constraintLeft_toLeftOf="@id/main_activity_person_center"

View File

@ -42,14 +42,14 @@
android:textSize="@dimen/card_title_font_3size" />
<TextView
android:id="@+id/task_size"
android:id="@+id/task_color"
style="@style/map_size_font_style"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/task_city_name"
android:layout_marginTop="5dp"
android:drawableLeft="@mipmap/point_blue"
android:text="文件大小"
android:text="路线颜色"
android:textSize="@dimen/card_title_font_3size" />
@ -68,7 +68,8 @@
<TextView
android:id="@+id/task_upload_btn"
style="@style/map_download_style_btn"
android:layout_width="60dp"
android:layout_width="wrap_content"
android:minWidth="60dp"
android:layout_centerVertical="true"
android:layout_marginRight="5dp"
android:layout_toLeftOf="@id/task_download_btn"
@ -96,7 +97,7 @@
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="16dp"
android:layout_below="@id/task_size"
android:layout_below="@id/task_color"
android:paddingTop="10dp"
android:progressDrawable="@drawable/progress_bg"
android:visibility="invisible" />

View File

@ -1,6 +1,8 @@
package com.navinfo.collect.library.map.layers
import android.graphics.Color
import android.os.Build
import androidx.annotation.RequiresApi
import com.navinfo.collect.library.R
import com.navinfo.collect.library.data.entity.HadLinkDvoBean
import com.navinfo.collect.library.utils.GeometryTools
@ -31,7 +33,7 @@ class OmdbTaskLinkLayer(map: Map, private var style: Style) : VectorLayer(map) {
}
}
fun removeLine(linkPid: String):Boolean {
fun removeLine(linkPid: String): Boolean {
if (lineMap.containsKey(linkPid)) {
super.remove(lineMap[linkPid])
lineMap.remove(linkPid)
@ -43,6 +45,7 @@ class OmdbTaskLinkLayer(map: Map, private var style: Style) : VectorLayer(map) {
super.remove(geometry)
}
@RequiresApi(Build.VERSION_CODES.O)
fun setLineColor(color: Color) {
this.style = Style.builder()
.fillColor(color.toArgb())
@ -51,4 +54,11 @@ class OmdbTaskLinkLayer(map: Map, private var style: Style) : VectorLayer(map) {
.strokeWidth(4f)
.fixed(true).build()
}
fun removeAll() {
for ((key, value) in lineMap) {
super.remove(value)
}
lineMap.clear()
}
}

View File

@ -57,7 +57,7 @@ public class MapLifeNiLocationTileDataSource implements ITileDataSource {
list = TraceDataBase.getDatabase(mCon, dbName).getNiLocationDao().findAll();
}
Log.e("qj","query"+(list==null?0:list.size())+"==="+xStart+"==="+xEnd+"==="+yStart+"==="+yEnd);
// Log.e("qj","query"+(list==null?0:list.size())+"==="+xStart+"==="+xEnd+"==="+yStart+"==="+yEnd);
mThreadLocalDecoders.get().decode(tile, mapDataSink, "MapLifeNiLocationTile", list);
mapDataSink.completed(QueryResult.SUCCESS);