Merge branch 'master' of gitlab.navinfo.com:CollectVehicle/OneMapQS
Conflicts: app/src/main/java/com/navinfo/omqs/db/ImportOMDBHelper.kt
This commit is contained in:
commit
fbff312f41
@ -2,6 +2,7 @@ package com.navinfo.omqs.db
|
||||
|
||||
import android.content.Context
|
||||
import android.database.Cursor.*
|
||||
import android.util.Log
|
||||
import androidx.core.database.getBlobOrNull
|
||||
import androidx.core.database.getFloatOrNull
|
||||
import androidx.core.database.getIntOrNull
|
||||
@ -129,51 +130,58 @@ class ImportOMDBHelper @AssistedInject constructor(
|
||||
// 开始解压zip文件
|
||||
val unZipFiles = ZipUtils.unzipFile(omdbZipFile, unZipFolder)
|
||||
// 将listResult数据插入到Realm数据库中
|
||||
val realm = Realm.getDefaultInstance()
|
||||
// 遍历解压后的文件,读取该数据返回
|
||||
for ((index, currentConfig) in importConfig.tables.withIndex()) {
|
||||
val txtFile = unZipFiles.find {
|
||||
it.name == currentConfig.table
|
||||
}
|
||||
try {
|
||||
Realm.getDefaultInstance().beginTransaction()
|
||||
// 遍历解压后的文件,读取该数据返回
|
||||
for ((index, currentConfig) in importConfig.tables.withIndex()) {
|
||||
val txtFile = unZipFiles.find {
|
||||
it.name == currentConfig.table
|
||||
}
|
||||
|
||||
val listResult = mutableListOf<Map<String, Any>>()
|
||||
currentConfig?.let {
|
||||
val list = FileIOUtils.readFile2List(txtFile, "UTF-8")
|
||||
if (list != null) {
|
||||
// 将list数据转换为map
|
||||
for (line in list) {
|
||||
val map = gson.fromJson<Map<String, Any>>(line, object:TypeToken<Map<String, Any>>(){}.getType())
|
||||
.toMutableMap()
|
||||
map["qi_table"] = currentConfig.table
|
||||
map["qi_name"] = currentConfig.name
|
||||
map["qi_code"] = currentConfig.code
|
||||
listResult.add(map)
|
||||
val listResult = mutableListOf<Map<String, Any>>()
|
||||
currentConfig?.let {
|
||||
val list = FileIOUtils.readFile2List(txtFile, "UTF-8")
|
||||
Log.d("ImportOMDBHelper", "开始解析:${txtFile?.name}")
|
||||
if (list != null) {
|
||||
// 将list数据转换为map
|
||||
for ((index, line) in list.withIndex()) {
|
||||
Log.d("ImportOMDBHelper", "解析第:${index+1}行")
|
||||
val map = gson.fromJson<Map<String, Any>>(line, object:TypeToken<Map<String, Any>>(){}.getType())
|
||||
.toMutableMap()
|
||||
map["qi_table"] = currentConfig.table
|
||||
map["qi_name"] = currentConfig.name
|
||||
map["qi_code"] = currentConfig.code
|
||||
listResult.add(map)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (map in listResult) { // 每一个map就是Realm的一条数据
|
||||
// 先查询这个mesh下有没有数据,如果有则跳过即可
|
||||
for (map in listResult) { // 每一个map就是Realm的一条数据
|
||||
// 先查询这个mesh下有没有数据,如果有则跳过即可
|
||||
// val meshEntity = Realm.getDefaultInstance().where(RenderEntity::class.java).equalTo("properties['mesh']", map["mesh"].toString()).findFirst()
|
||||
val renderEntity = RenderEntity()
|
||||
renderEntity.code = map["qi_code"].toString().toInt()
|
||||
renderEntity.name = map["qi_name"].toString()
|
||||
renderEntity.table = map["qi_table"].toString()
|
||||
// 其他数据插入到Properties中
|
||||
renderEntity.geometry = map["geometry"].toString()
|
||||
for ((key, value) in map) {
|
||||
when (value) {
|
||||
is String -> renderEntity.properties.put(key, value)
|
||||
is Int -> renderEntity.properties.put(key, value.toInt().toString())
|
||||
is Double -> renderEntity.properties.put(key, value.toDouble().toString())
|
||||
else -> renderEntity.properties.put(key, value.toString())
|
||||
val renderEntity = RenderEntity()
|
||||
renderEntity.code = map["qi_code"].toString().toInt()
|
||||
renderEntity.name = map["qi_name"].toString()
|
||||
renderEntity.table = map["qi_table"].toString()
|
||||
// 其他数据插入到Properties中
|
||||
renderEntity.geometry = map["geometry"].toString()
|
||||
for ((key, value) in map) {
|
||||
when (value) {
|
||||
is String -> renderEntity.properties.put(key, value)
|
||||
is Int -> renderEntity.properties.put(key, value.toInt().toString())
|
||||
is Double -> renderEntity.properties.put(key, value.toDouble().toString())
|
||||
else -> renderEntity.properties.put(key, value.toString())
|
||||
}
|
||||
}
|
||||
Realm.getDefaultInstance().copyToRealm(renderEntity)
|
||||
}
|
||||
Realm.getDefaultInstance().copyToRealm(renderEntity)
|
||||
// 1个文件发送一次flow流
|
||||
emit("${index + 1}/${importConfig.tables.size}")
|
||||
}
|
||||
// 1个文件发送一次flow流
|
||||
emit("${index + 1}/${importConfig.tables.size}")
|
||||
Realm.getDefaultInstance().commitTransaction()
|
||||
} catch (e: Exception) {
|
||||
Realm.getDefaultInstance().cancelTransaction()
|
||||
throw e
|
||||
}
|
||||
Realm.getDefaultInstance().commitTransaction()
|
||||
emit("finish")
|
||||
}
|
||||
}
|
||||
|
@ -56,6 +56,10 @@ class QsRecordListFragment : BaseFragment(){
|
||||
findNavController().popBackStack()
|
||||
}
|
||||
})
|
||||
|
||||
binding.recordBack.setOnClickListener{
|
||||
findNavController().navigateUp()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
|
5
app/src/main/res/drawable/ic_baseline_search_24.xml
Normal file
5
app/src/main/res/drawable/ic_baseline_search_24.xml
Normal file
@ -0,0 +1,5 @@
|
||||
<vector android:height="24dp" android:tint="#2C2C2C"
|
||||
android:viewportHeight="24" android:viewportWidth="24"
|
||||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="@android:color/white" android:pathData="M15.5,14h-0.79l-0.28,-0.27C15.41,12.59 16,11.11 16,9.5 16,5.91 13.09,3 9.5,3S3,5.91 3,9.5 5.91,16 9.5,16c1.61,0 3.09,-0.59 4.23,-1.57l0.27,0.28v0.79l5,4.99L20.49,19l-4.99,-5zM9.5,14C7.01,14 5,11.99 5,9.5S7.01,5 9.5,5 14,7.01 14,9.5 11.99,14 9.5,14z"/>
|
||||
</vector>
|
@ -3,6 +3,6 @@
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<solid android:color="@color/colorSurface"></solid>
|
||||
<stroke android:color="@color/gray_121" android:width="0.1dp"></stroke>
|
||||
<stroke android:color="@color/cv_gray_153" android:width="0.1dp"></stroke>
|
||||
<corners android:radius="30dp" />
|
||||
</shape>
|
@ -26,6 +26,7 @@
|
||||
android:layout_below="@id/offline_map_city_name"
|
||||
android:drawableLeft="@mipmap/point_blue"
|
||||
android:layout_marginTop="5dp"
|
||||
android:textColor="@color/gray_121"
|
||||
android:text="文件大小" />
|
||||
|
||||
|
||||
|
@ -48,7 +48,6 @@
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingVertical="@dimen/default_widget_padding"
|
||||
android:orientation="vertical">
|
||||
<com.google.android.material.tabs.TabLayout
|
||||
android:id="@+id/offline_map_tab_layout"
|
||||
|
@ -4,23 +4,41 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:padding="@dimen/default_widget_padding"
|
||||
tools:context=".ui.fragment.offlinemap.OfflineMapCityListFragment">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/offline_map_search"
|
||||
style="@style/input_blue_type"
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/offline_map_search_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="搜索"
|
||||
app:startIconDrawable="@drawable/ic_baseline_search_24"
|
||||
app:startIconTint="@color/gray_121"
|
||||
app:endIconMode="clear_text"
|
||||
android:layout_marginHorizontal="@dimen/default_widget_padding"
|
||||
app:endIconDrawable="@drawable/baseline_delete_forever_24"
|
||||
app:endIconTint="@color/gray_121"
|
||||
android:scrollbarAlwaysDrawHorizontalTrack="true"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/offline_map_search"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="搜索"
|
||||
android:lines="1"
|
||||
android:background="@drawable/login_inputlayout_bg"
|
||||
tools:ignore="TouchTargetSizeCheck" />
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/offline_map_city_list_recyclerview"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginTop="@dimen/default_widget_padding"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/offline_map_search"
|
||||
app:layout_constraintTop_toBottomOf="@id/offline_map_search_layout"
|
||||
app:layout_constraintVertical_bias="0.0"
|
||||
tools:layout_editor_absoluteX="0dp" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
@ -4,24 +4,82 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/white"
|
||||
android:background="@color/bg_left_pannel"
|
||||
tools:context=".ui.fragment.qsrecordlist.QsRecordListFragment">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/task_search"
|
||||
style="@style/input_blue_type"
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/title_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="搜索"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
style="@style/left_pannel_title_layout">
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/record_back"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
android:layout_marginTop="5dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
android:background="@drawable/selector_bg_round_button"
|
||||
android:foreground="@drawable/ripple_btn_press"
|
||||
style="@style/btn_round"
|
||||
android:src="@drawable/ic_baseline_keyboard_arrow_left_24"></androidx.appcompat.widget.AppCompatImageView>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/qs_recyclerview"
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/record_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="@dimen/left_pannel_title_font"
|
||||
android:textStyle="bold"
|
||||
android:text="我的数据"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"></androidx.appcompat.widget.AppCompatTextView>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintTop_toBottomOf="@id/title_layout"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/task_search"
|
||||
app:layout_constraintVertical_bias="0.0"
|
||||
tools:layout_editor_absoluteX="0dp" />
|
||||
style="@style/default_card_view">
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/task_search_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:startIconDrawable="@drawable/ic_baseline_search_24"
|
||||
app:startIconTint="@color/gray_121"
|
||||
app:endIconMode="clear_text"
|
||||
android:layout_marginHorizontal="@dimen/default_widget_padding"
|
||||
app:endIconDrawable="@drawable/baseline_delete_forever_24"
|
||||
app:endIconTint="@color/gray_121"
|
||||
android:scrollbarAlwaysDrawHorizontalTrack="true"
|
||||
app:layout_constraintTop_toBottomOf="@id/title_layout"
|
||||
app:layout_constraintVertical_bias="0.4">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/task_search"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="输入LinkPid"
|
||||
android:lines="1"
|
||||
android:background="@drawable/login_inputlayout_bg"
|
||||
tools:ignore="TouchTargetSizeCheck" />
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/qs_recyclerview"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/task_search_layout" />
|
||||
</LinearLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
@ -4,46 +4,83 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/white"
|
||||
android:background="@color/bg_left_pannel"
|
||||
tools:context=".ui.fragment.tasklist.TaskListFragment">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/task_title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp"
|
||||
android:text="任务列表"
|
||||
android:gravity="center"
|
||||
android:textSize="18sp"
|
||||
android:textColor="@color/white"
|
||||
android:background="@color/default_blue"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
<ImageView
|
||||
android:id="@+id/task_back"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="0dp"
|
||||
android:src="@drawable/btn_back_xml"
|
||||
android:paddingLeft="15dp"
|
||||
android:paddingRight="10dp"
|
||||
app:layout_constraintLeft_toLeftOf="@id/task_title"
|
||||
app:layout_constraintTop_toTopOf="@id/task_title"
|
||||
app:layout_constraintBottom_toBottomOf="@id/task_title"
|
||||
/>
|
||||
<EditText
|
||||
android:id="@+id/task_search"
|
||||
style="@style/input_blue_type"
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/title_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="搜索"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/task_title" />
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
style="@style/left_pannel_title_layout">
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/task_back"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
android:layout_marginTop="5dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
android:background="@drawable/selector_bg_round_button"
|
||||
android:foreground="@drawable/ripple_btn_press"
|
||||
style="@style/btn_round"
|
||||
android:src="@drawable/ic_baseline_keyboard_arrow_left_24"></androidx.appcompat.widget.AppCompatImageView>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/task_recyclerview"
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/task_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="@dimen/left_pannel_title_font"
|
||||
android:textStyle="bold"
|
||||
android:text="任务列表"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"></androidx.appcompat.widget.AppCompatTextView>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintTop_toBottomOf="@id/title_layout"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/task_search"
|
||||
app:layout_constraintVertical_bias="0.0"
|
||||
tools:layout_editor_absoluteX="0dp" />
|
||||
style="@style/default_card_view">
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/task_search_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:startIconDrawable="@drawable/ic_baseline_search_24"
|
||||
app:startIconTint="@color/gray_121"
|
||||
app:endIconMode="clear_text"
|
||||
android:layout_marginHorizontal="@dimen/default_widget_padding"
|
||||
app:endIconDrawable="@drawable/baseline_delete_forever_24"
|
||||
app:endIconTint="@color/gray_121"
|
||||
android:scrollbarAlwaysDrawHorizontalTrack="true"
|
||||
app:layout_constraintTop_toBottomOf="@id/title_layout"
|
||||
app:layout_constraintVertical_bias="0.4">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/task_search"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="输入LinkPid"
|
||||
android:lines="1"
|
||||
android:background="@drawable/login_inputlayout_bg"
|
||||
tools:ignore="TouchTargetSizeCheck" />
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/task_recyclerview"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/task_search_layout" />
|
||||
</LinearLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
@ -160,5 +160,6 @@
|
||||
<item name="background">@drawable/shape_card_bg_default</item>
|
||||
<item name="android:layout_margin">@dimen/default_widget_padding</item>
|
||||
<item name="cardCornerRadius">@dimen/default_widget_padding</item>
|
||||
<item name="android:padding">@dimen/default_widget_padding</item>
|
||||
</style>
|
||||
</resources>
|
||||
|
Loading…
x
Reference in New Issue
Block a user