Merge branch 'master' of https://gitlab.navinfo.com/CollectVehicle/OneMapQS
Conflicts: app/src/main/java/com/navinfo/omqs/ui/activity/map/MainActivity.kt
This commit is contained in:
commit
331380905d
@ -99,8 +99,13 @@ dependencies {
|
||||
kapt "androidx.room:room-ktx:2.5.1"
|
||||
|
||||
//读取excel word等文件
|
||||
implementation 'org.apache.poi:poi:4.0.0'
|
||||
implementation 'org.apache.poi:poi-ooxml:4.0.0'
|
||||
// implementation 'org.apache.poi:poi:4.0.0'
|
||||
// implementation 'org.apache.poi:poi-ooxml:4.0.0'
|
||||
// implementation 'org.apache.poi:poi-ooxml-schemas:4.0.0'
|
||||
// implementation 'org.apache.xmlbeans:xmlbeans:3.0.2'
|
||||
// implementation 'javax.xml.stream:stax-api:1.0-2'
|
||||
// implementation 'com.bea.xml.stream:com.bea.xml.stream:1.0.0'
|
||||
implementation 'commons-io:commons-io:2.11.0'
|
||||
|
||||
// 读取spatialite文件
|
||||
implementation 'com.github.sevar83:android-spatialite:2.0.1'
|
||||
|
@ -79,4 +79,5 @@ class Constant {
|
||||
const val OMDB_CONFIG = "omdb.config"
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -174,7 +174,7 @@ class ImportOMDBHelper @AssistedInject constructor(
|
||||
emit("${index + 1}/${importConfig.tables.size}")
|
||||
}
|
||||
Realm.getDefaultInstance().commitTransaction()
|
||||
emit("OK")
|
||||
emit("finish")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,15 +1,12 @@
|
||||
package com.navinfo.omqs.http.taskdownload
|
||||
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import androidx.core.content.ContentProviderCompat.requireContext
|
||||
import androidx.lifecycle.LifecycleOwner
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.Observer
|
||||
import com.navinfo.omqs.Constant
|
||||
import com.navinfo.omqs.bean.TaskBean
|
||||
import com.navinfo.omqs.db.ImportOMDBHelper
|
||||
import com.navinfo.omqs.hilt.ImportOMDBHiltFactory
|
||||
import com.navinfo.omqs.tools.FileManager
|
||||
import com.navinfo.omqs.tools.FileManager.Companion.FileDownloadStatus
|
||||
import io.realm.Realm
|
||||
@ -18,7 +15,6 @@ import java.io.File
|
||||
import java.io.IOException
|
||||
import java.io.InputStream
|
||||
import java.io.RandomAccessFile
|
||||
import javax.inject.Inject
|
||||
|
||||
class TaskDownloadScope(
|
||||
private val downloadManager: TaskDownloadManager,
|
||||
@ -26,9 +22,6 @@ class TaskDownloadScope(
|
||||
) :
|
||||
CoroutineScope by CoroutineScope(Dispatchers.IO + CoroutineName("OfflineMapDownLoad")) {
|
||||
|
||||
@Inject
|
||||
lateinit var importOMDBHiltFactory: ImportOMDBHiltFactory
|
||||
|
||||
/**
|
||||
*下载任务,用来取消的
|
||||
*/
|
||||
@ -131,7 +124,7 @@ class TaskDownloadScope(
|
||||
)
|
||||
importOMDBHelper.importOmdbZipFile(importOMDBHelper.omdbFile).collect {
|
||||
Log.e("jingo", "数据安装 $it")
|
||||
if (it == "OK") {
|
||||
if (it == "finish") {
|
||||
change(FileDownloadStatus.DONE)
|
||||
} else {
|
||||
change(FileDownloadStatus.IMPORTING, it)
|
||||
|
19
app/src/main/java/com/navinfo/omqs/tools/MetadataUtils.kt
Normal file
19
app/src/main/java/com/navinfo/omqs/tools/MetadataUtils.kt
Normal file
@ -0,0 +1,19 @@
|
||||
package com.navinfo.omqs.tools
|
||||
|
||||
class MetadataUtils {
|
||||
companion object {
|
||||
object ScProblemTypeTitle {
|
||||
|
||||
const val TITLE_ELEMENT_TYPE = "类型"
|
||||
const val TITLE_ELEMENT_CODE = "要素代码"
|
||||
const val TITLE_CLASS_TYPE = "要素分类"
|
||||
const val TITLE_PROBLEM_TYPE = "问题类型·"
|
||||
const val TITLE_PHENOMENON = "问题现象"
|
||||
}
|
||||
|
||||
object ScRootCauseAnalysisTitle {
|
||||
const val TITLE_PROBLEM_LINK = "问题环节"
|
||||
const val TITLE_PROBLEM_CAUSE = "初步问题原因"
|
||||
}
|
||||
}
|
||||
}
|
@ -164,7 +164,7 @@ class EvaluationResultFragment : BaseFragment(), View.OnClickListener {
|
||||
|
||||
|
||||
override fun onDestroyView() {
|
||||
activity?.apply {
|
||||
activity?.run {
|
||||
findNavController(R.id.main_activity_middle_fragment).navigateUp()
|
||||
}
|
||||
super.onDestroyView()
|
||||
@ -178,7 +178,7 @@ class EvaluationResultFragment : BaseFragment(), View.OnClickListener {
|
||||
when (v.id) {
|
||||
//上三项,打开面板
|
||||
R.id.evaluation_class_type, R.id.evaluation_problem_type, R.id.evaluation_phenomenon -> {
|
||||
activity?.apply {
|
||||
activity?.run {
|
||||
val controller = findNavController(R.id.main_activity_middle_fragment)
|
||||
controller.currentDestination?.let {
|
||||
//如果之前页面是空fragment,直接打开面板
|
||||
@ -201,7 +201,7 @@ class EvaluationResultFragment : BaseFragment(), View.OnClickListener {
|
||||
}
|
||||
//下两项,打开面板
|
||||
R.id.evaluation_link, R.id.evaluation_cause -> {
|
||||
activity?.apply {
|
||||
activity?.run {
|
||||
val controller = findNavController(R.id.main_activity_middle_fragment)
|
||||
controller.currentDestination?.let {
|
||||
//如果之前页面是空fragment,直接打开面板
|
||||
|
@ -6,6 +6,7 @@ import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.navinfo.collect.library.data.entity.QsRecordBean
|
||||
import com.navinfo.collect.library.map.NIMapController
|
||||
import com.navinfo.omqs.db.RealmOperateHelper
|
||||
import com.navinfo.omqs.db.RoomAppDatabase
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
import io.realm.Realm
|
||||
@ -17,7 +18,9 @@ import javax.inject.Inject
|
||||
|
||||
@HiltViewModel
|
||||
class EvaluationResultViewModel @Inject constructor(
|
||||
private val roomAppDatabase: RoomAppDatabase, private val mapController: NIMapController
|
||||
private val roomAppDatabase: RoomAppDatabase,
|
||||
private val mapController: NIMapController,
|
||||
private val realmOperateHelper: RealmOperateHelper,
|
||||
) : ViewModel() {
|
||||
|
||||
private val markerTitle = "点选marker"
|
||||
@ -50,7 +53,7 @@ class EvaluationResultViewModel @Inject constructor(
|
||||
init {
|
||||
liveDataQsRecordBean.value = QsRecordBean(id = UUID.randomUUID().toString())
|
||||
Log.e("jingo", "EvaluationResultViewModel 创建了 ${hashCode()}")
|
||||
mapController.markerHandle.apply {
|
||||
mapController.markerHandle.run {
|
||||
setOnMapClickListener {
|
||||
liveDataQsRecordBean.value!!.geometry = it.toGeometry()
|
||||
addMarker(it, markerTitle)
|
||||
@ -207,7 +210,7 @@ class EvaluationResultViewModel @Inject constructor(
|
||||
fun saveData() {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
val realm = Realm.getDefaultInstance()
|
||||
Log.e("jingo","realm hashCOde ${realm.hashCode()}")
|
||||
Log.e("jingo", "realm hashCOde ${realm.hashCode()}")
|
||||
realm.executeTransaction {
|
||||
it.copyToRealmOrUpdate(liveDataQsRecordBean.value)
|
||||
}
|
||||
@ -221,7 +224,7 @@ class EvaluationResultViewModel @Inject constructor(
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
|
||||
val realm = Realm.getDefaultInstance()
|
||||
Log.e("jingo","realm hashCOde ${realm.hashCode()}")
|
||||
Log.e("jingo", "realm hashCOde ${realm.hashCode()}")
|
||||
realm.executeTransaction {
|
||||
val objects = it.where(QsRecordBean::class.java)
|
||||
.equalTo("id", liveDataQsRecordBean.value?.id).findFirst()
|
||||
|
@ -7,7 +7,9 @@ import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.fragment.app.viewModels
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import com.blankj.utilcode.util.ToastUtils
|
||||
import com.blankj.utilcode.util.UriUtils
|
||||
import com.github.k1rakishou.fsaf.FileChooser
|
||||
import com.github.k1rakishou.fsaf.callback.FSAFActivityCallbacks
|
||||
@ -36,6 +38,7 @@ class PersonalCenterFragment : BaseFragment(), FSAFActivityCallbacks {
|
||||
|
||||
@Inject
|
||||
lateinit var importOMDBHiltFactory: ImportOMDBHiltFactory
|
||||
|
||||
@Inject
|
||||
lateinit var niMapController: NIMapController
|
||||
|
||||
@ -106,7 +109,8 @@ class PersonalCenterFragment : BaseFragment(), FSAFActivityCallbacks {
|
||||
R.id.personal_center_menu_test -> {
|
||||
viewModel.readRealmData()
|
||||
// 定位到指定位置
|
||||
niMapController.mMapView.vtmMap.animator().animateTo(GeoPoint(30.270367985798032, 113.83513667119433))
|
||||
niMapController.mMapView.vtmMap.animator()
|
||||
.animateTo(GeoPoint(30.270367985798032, 113.83513667119433))
|
||||
}
|
||||
R.id.personal_center_menu_task_list -> {
|
||||
findNavController().navigate(R.id.TaskListFragment)
|
||||
@ -118,6 +122,10 @@ class PersonalCenterFragment : BaseFragment(), FSAFActivityCallbacks {
|
||||
true
|
||||
}
|
||||
|
||||
viewModel.liveDataMessage.observe(viewLifecycleOwner) {
|
||||
ToastUtils.showShort(it)
|
||||
}
|
||||
|
||||
fileChooser.setCallbacks(this@PersonalCenterFragment)
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,9 @@
|
||||
package com.navinfo.omqs.ui.fragment.personalcenter
|
||||
|
||||
import android.content.Context
|
||||
import android.net.Uri
|
||||
import android.util.Log
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.blankj.utilcode.util.FileIOUtils
|
||||
@ -10,35 +11,35 @@ import com.blankj.utilcode.util.UriUtils
|
||||
import com.blankj.utilcode.util.ZipUtils
|
||||
import com.google.gson.Gson
|
||||
import com.navinfo.collect.library.data.entity.*
|
||||
import com.navinfo.collect.library.map.NIMapController
|
||||
import com.navinfo.collect.library.utils.GeometryTools
|
||||
import com.navinfo.omqs.bean.ScProblemTypeBean
|
||||
import com.navinfo.omqs.bean.ScRootCauseAnalysisBean
|
||||
import com.navinfo.omqs.db.ImportOMDBHelper
|
||||
import com.navinfo.omqs.db.RealmOperateHelper
|
||||
import com.navinfo.omqs.db.RoomAppDatabase
|
||||
import com.navinfo.omqs.tools.MetadataUtils
|
||||
import com.navinfo.omqs.tools.MetadataUtils.Companion.ScProblemTypeTitle
|
||||
import com.navinfo.omqs.tools.MetadataUtils.Companion.ScRootCauseAnalysisTitle
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
import dagger.hilt.android.scopes.ViewModelScoped
|
||||
import io.realm.Realm
|
||||
import io.realm.RealmDictionary
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import org.apache.poi.ss.usermodel.Row
|
||||
import org.apache.poi.ss.usermodel.WorkbookFactory
|
||||
import org.locationtech.jts.geom.Point
|
||||
import java.io.File
|
||||
import java.io.FileInputStream
|
||||
import java.io.IOException
|
||||
import java.io.InputStream
|
||||
import kotlinx.coroutines.withContext
|
||||
import org.apache.commons.io.input.BOMInputStream
|
||||
import java.io.*
|
||||
import java.nio.charset.Charset
|
||||
import java.text.Normalizer
|
||||
import java.util.*
|
||||
import javax.inject.Inject
|
||||
|
||||
|
||||
@HiltViewModel
|
||||
class PersonalCenterViewModel @Inject constructor(
|
||||
private val roomAppDatabase: RoomAppDatabase
|
||||
) : ViewModel() {
|
||||
@Inject
|
||||
lateinit var realmOperateHelper: RealmOperateHelper
|
||||
|
||||
val liveDataMessage = MutableLiveData<String>()
|
||||
|
||||
/**
|
||||
* 导入OMDB数据
|
||||
* */
|
||||
@ -50,10 +51,14 @@ class PersonalCenterViewModel @Inject constructor(
|
||||
val hadLinkKindFile = File(importOMDBHelper.omdbFile.parentFile, "HAD_LINK_KIND.txt")
|
||||
val hadLinkDirectFile = File(importOMDBHelper.omdbFile.parentFile, "HAD_LINK_DIRECT.txt")
|
||||
val hadSpeedLimitFile = File(importOMDBHelper.omdbFile.parentFile, "HAD_SPEEDLIMIT.txt")
|
||||
val hadSpeedLimitCondFile = File(importOMDBHelper.omdbFile.parentFile, "HAD_SPEEDLIMIT_COND.txt")
|
||||
val hadSpeedLimitVarFile = File(importOMDBHelper.omdbFile.parentFile, "HAD_SPEEDLIMIT_VAR.txt")
|
||||
val hadSpeedLimitCondFile =
|
||||
File(importOMDBHelper.omdbFile.parentFile, "HAD_SPEEDLIMIT_COND.txt")
|
||||
val hadSpeedLimitVarFile =
|
||||
File(importOMDBHelper.omdbFile.parentFile, "HAD_SPEEDLIMIT_VAR.txt")
|
||||
|
||||
for (tableName in listOf<String>("HAD_LINK", "HAD_SPEEDLIMIT", "HAD_SPEEDLIMIT_COND", "HAD_SPEEDLIMIT_VAR")/*listOf<String>("HAD_LINK")*/) {
|
||||
for (tableName in listOf<String>(
|
||||
"HAD_LINK", "HAD_SPEEDLIMIT", "HAD_SPEEDLIMIT_COND", "HAD_SPEEDLIMIT_VAR"
|
||||
)/*listOf<String>("HAD_LINK")*/) {
|
||||
importOMDBHelper.getOMDBTableData(tableName).collect {
|
||||
for (map in it) {
|
||||
if ("HAD_LINK" == tableName) {
|
||||
@ -65,25 +70,31 @@ class PersonalCenterViewModel @Inject constructor(
|
||||
hadLink.E_NODE_PID = map["E_NODE_PID"].toString()
|
||||
hadLink.GEOMETRY = map["GEOMETRY"].toString()
|
||||
// 将该数据写入到对应的txt文件
|
||||
FileIOUtils.writeFileFromString(hadLinkFile, gson.toJson(hadLink)+"\r", true)
|
||||
FileIOUtils.writeFileFromString(
|
||||
hadLinkFile, gson.toJson(hadLink) + "\r", true
|
||||
)
|
||||
|
||||
val hadLinkDirect = HAD_LINK_DIRECT()
|
||||
val hadLinkDirect = HAD_LINK_DIRECT()
|
||||
hadLinkDirect.LINK_PID = map["LINK_PID"].toString()
|
||||
hadLinkDirect.MESH = map["MESH"].toString()
|
||||
hadLinkDirect.DIRECT = map["DIRECT"].toString().toInt()
|
||||
hadLinkDirect.GEOMETRY = map["GEOMETRY"].toString()
|
||||
// 将该数据写入到对应的txt文件
|
||||
FileIOUtils.writeFileFromString(hadLinkDirectFile, gson.toJson(hadLinkDirect)+"\r", true)
|
||||
FileIOUtils.writeFileFromString(
|
||||
hadLinkDirectFile, gson.toJson(hadLinkDirect) + "\r", true
|
||||
)
|
||||
|
||||
val hadLinkKind = HAD_LINK_KIND()
|
||||
val hadLinkKind = HAD_LINK_KIND()
|
||||
hadLinkKind.LINK_PID = map["LINK_PID"].toString()
|
||||
hadLinkKind.MESH = map["MESH"].toString()
|
||||
hadLinkKind.KIND = map["KIND"].toString().toInt()
|
||||
hadLinkKind.GEOMETRY = map["GEOMETRY"].toString()
|
||||
// 将该数据写入到对应的txt文件
|
||||
FileIOUtils.writeFileFromString(hadLinkKindFile, gson.toJson(hadLinkKind)+"\r", true)
|
||||
FileIOUtils.writeFileFromString(
|
||||
hadLinkKindFile, gson.toJson(hadLinkKind) + "\r", true
|
||||
)
|
||||
} else if ("HAD_SPEEDLIMIT" == tableName) {
|
||||
val hadSpeedlimit = HAD_SPEEDLIMIT()
|
||||
val hadSpeedlimit = HAD_SPEEDLIMIT()
|
||||
hadSpeedlimit.SPEED_ID = map["SPEED_ID"].toString()
|
||||
hadSpeedlimit.MESH = map["MESH"].toString()
|
||||
hadSpeedlimit.LINK_PID = map["LINK_PID"].toString()
|
||||
@ -93,9 +104,11 @@ class PersonalCenterViewModel @Inject constructor(
|
||||
hadSpeedlimit.MAX_SPEED = map["MAX_SPEED"].toString().toInt()
|
||||
hadSpeedlimit.MIN_SPEED = map["MIN_SPEED"].toString().toInt()
|
||||
// 将该数据写入到对应的txt文件
|
||||
FileIOUtils.writeFileFromString(hadSpeedLimitFile, gson.toJson(hadSpeedlimit)+"\r", true)
|
||||
FileIOUtils.writeFileFromString(
|
||||
hadSpeedLimitFile, gson.toJson(hadSpeedlimit) + "\r", true
|
||||
)
|
||||
} else if ("HAD_SPEEDLIMIT_COND" == tableName) {
|
||||
val hadSpeedlimitCond = HAD_SPEEDLIMIT_COND()
|
||||
val hadSpeedlimitCond = HAD_SPEEDLIMIT_COND()
|
||||
hadSpeedlimitCond.SPEED_COND_ID = map["SPEED_COND_ID"].toString()
|
||||
hadSpeedlimitCond.MESH = map["MESH"].toString()
|
||||
hadSpeedlimitCond.LINK_PID = map["LINK_PID"].toString()
|
||||
@ -103,13 +116,16 @@ class PersonalCenterViewModel @Inject constructor(
|
||||
hadSpeedlimitCond.DIRECT = map["DIRECT"].toString().toInt()
|
||||
hadSpeedlimitCond.SPEED_FLAG = map["SPEED_FLAG"].toString().toInt()
|
||||
hadSpeedlimitCond.MAX_SPEED = map["MAX_SPEED"].toString().toInt()
|
||||
hadSpeedlimitCond.SPEED_DEPENDENT = map["SPEED_DEPENDENT"].toString().toInt()
|
||||
hadSpeedlimitCond.SPEED_DEPENDENT =
|
||||
map["SPEED_DEPENDENT"].toString().toInt()
|
||||
hadSpeedlimitCond.VEHICLE_TYPE = map["VEHICLE_TYPE"].toString().toInt()
|
||||
hadSpeedlimitCond.VALID_PERIOD = map["VALID_PERIOD"].toString()
|
||||
// 将该数据写入到对应的txt文件
|
||||
FileIOUtils.writeFileFromString(hadSpeedLimitCondFile, gson.toJson(hadSpeedlimitCond)+"\r", true)
|
||||
FileIOUtils.writeFileFromString(
|
||||
hadSpeedLimitCondFile, gson.toJson(hadSpeedlimitCond) + "\r", true
|
||||
)
|
||||
} else if ("HAD_SPEEDLIMIT_VAR" == tableName) {
|
||||
val hadSpeedlimitVar = HAD_SPEEDLIMIT_VAR()
|
||||
val hadSpeedlimitVar = HAD_SPEEDLIMIT_VAR()
|
||||
hadSpeedlimitVar.SPEED_VAR_ID = map["SPEED_ID"].toString()
|
||||
hadSpeedlimitVar.MESH = map["MESH"].toString()
|
||||
hadSpeedlimitVar.LINK_PID = map["LINK_PID"].toString()
|
||||
@ -117,7 +133,9 @@ class PersonalCenterViewModel @Inject constructor(
|
||||
hadSpeedlimitVar.DIRECT = map["DIRECT"].toString().toInt()
|
||||
hadSpeedlimitVar.LOCATION = map["LOCATION"].toString()
|
||||
// 将该数据写入到对应的txt文件
|
||||
FileIOUtils.writeFileFromString(hadSpeedLimitVarFile, gson.toJson(hadSpeedlimitVar)+"\r", true)
|
||||
FileIOUtils.writeFileFromString(
|
||||
hadSpeedLimitVarFile, gson.toJson(hadSpeedlimitVar) + "\r", true
|
||||
)
|
||||
}
|
||||
// val properties = RealmDictionary<String?>()
|
||||
// for (entry in map.entries) {
|
||||
@ -129,10 +147,20 @@ class PersonalCenterViewModel @Inject constructor(
|
||||
}
|
||||
}
|
||||
}
|
||||
ZipUtils.zipFiles(mutableListOf(hadLinkFile, hadLinkKindFile, hadLinkDirectFile, hadSpeedLimitFile, hadSpeedLimitCondFile, hadSpeedLimitVarFile), File(importOMDBHelper.omdbFile.parentFile, "output.zip"))
|
||||
ZipUtils.zipFiles(
|
||||
mutableListOf(
|
||||
hadLinkFile,
|
||||
hadLinkKindFile,
|
||||
hadLinkDirectFile,
|
||||
hadSpeedLimitFile,
|
||||
hadSpeedLimitCondFile,
|
||||
hadSpeedLimitVarFile
|
||||
), File(importOMDBHelper.omdbFile.parentFile, "output.zip")
|
||||
)
|
||||
|
||||
Log.d("OMQSApplication", "生成数据完成")
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入OMDB数据
|
||||
* */
|
||||
@ -153,51 +181,136 @@ class PersonalCenterViewModel @Inject constructor(
|
||||
val file = UriUtils.uri2File(uri)
|
||||
val inputStream: InputStream =
|
||||
FileInputStream(file) //getAssets().open("sample.xlsx")
|
||||
val workbook = WorkbookFactory.create(inputStream)
|
||||
//获取所有sheet
|
||||
val sheet1 = workbook.getSheet("SC_PROBLEM_TYPE")
|
||||
sheet1?.let {
|
||||
val rowCount: Int = it.physicalNumberOfRows // 获取行数
|
||||
val list = mutableListOf<ScProblemTypeBean>()
|
||||
for (i in 1 until rowCount) {
|
||||
val row: Row = it.getRow(i) // 获取行
|
||||
// val cellCount: Int = row.physicalNumberOfCells // 获取列数
|
||||
val bean = ScProblemTypeBean(
|
||||
elementType = row.getCell(0).stringCellValue,
|
||||
elementCode = row.getCell(1).numericCellValue.toString(),
|
||||
classType = row.getCell(2).stringCellValue,
|
||||
problemType = row.getCell(3).stringCellValue,
|
||||
phenomenon = row.getCell(4).stringCellValue
|
||||
)
|
||||
list.add(bean)
|
||||
Log.e("jingo", bean.toString())
|
||||
}
|
||||
roomAppDatabase.getScProblemTypeDao().insertOrUpdateList(list)
|
||||
}
|
||||
val sheet2 = workbook.getSheet("SC_ROOT_CAUSE_ANALYSIS")
|
||||
sheet2?.let {
|
||||
val rowCount: Int = it.physicalNumberOfRows // 获取行数
|
||||
val list = mutableListOf<ScRootCauseAnalysisBean>()
|
||||
for (i in 1 until rowCount) {
|
||||
val row: Row = it.getRow(i) // 获取行
|
||||
val cellCount: Int = row.physicalNumberOfCells // 获取列数
|
||||
if (cellCount == 2) {
|
||||
val bean = ScRootCauseAnalysisBean()
|
||||
bean.problemLink = row.getCell(0).stringCellValue
|
||||
bean.problemCause = row.getCell(1).stringCellValue
|
||||
val bomInputStreamReader = BOMInputStream(inputStream)
|
||||
val inputStreamReader = InputStreamReader(bomInputStreamReader, "UTF-8")
|
||||
|
||||
val bufferedReader = BufferedReader(inputStreamReader)
|
||||
var line: String? = null
|
||||
var index = 0
|
||||
var elementTypeIndex = -1
|
||||
var elementCodeIndex = -1
|
||||
var classTypeIndex = -1
|
||||
var problemTypeIndex = -1
|
||||
var phenomenonIndex = -1
|
||||
var problemLinkIndex = -1
|
||||
var problemCauseIndex = -1
|
||||
val list = mutableListOf<ScProblemTypeBean>()
|
||||
val list2 = mutableListOf<ScRootCauseAnalysisBean>()
|
||||
while (bufferedReader.readLine()?.also { line = it } != null) { // 处理 CSV 文件中的每一行数据
|
||||
val data =
|
||||
line!!.split(",".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
|
||||
if (index == 0) {
|
||||
for (i in data.indices) {
|
||||
when (data[i]) {
|
||||
ScProblemTypeTitle.TITLE_ELEMENT_TYPE -> {
|
||||
elementTypeIndex = i
|
||||
}
|
||||
ScProblemTypeTitle.TITLE_ELEMENT_CODE -> {
|
||||
elementCodeIndex = i
|
||||
}
|
||||
ScProblemTypeTitle.TITLE_CLASS_TYPE -> {
|
||||
classTypeIndex = i
|
||||
}
|
||||
ScProblemTypeTitle.TITLE_PROBLEM_TYPE -> {
|
||||
problemTypeIndex = i
|
||||
}
|
||||
ScProblemTypeTitle.TITLE_PHENOMENON -> {
|
||||
phenomenonIndex = i
|
||||
}
|
||||
ScRootCauseAnalysisTitle.TITLE_PROBLEM_LINK -> {
|
||||
problemLinkIndex = i
|
||||
}
|
||||
ScRootCauseAnalysisTitle.TITLE_PROBLEM_CAUSE -> {
|
||||
problemCauseIndex = i
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (elementTypeIndex > -1
|
||||
&& elementCodeIndex > -1
|
||||
&& classTypeIndex > -1
|
||||
&& problemTypeIndex > -1
|
||||
&& phenomenonIndex > -1
|
||||
) {
|
||||
val bean = ScProblemTypeBean(
|
||||
elementType = data[elementTypeIndex],
|
||||
elementCode = data[elementCodeIndex],
|
||||
classType = data[classTypeIndex],
|
||||
problemType = data[problemTypeIndex],
|
||||
phenomenon = data[phenomenonIndex],
|
||||
)
|
||||
list.add(bean)
|
||||
Log.e("jingo", bean.toString())
|
||||
} else if (problemLinkIndex > -1 && problemCauseIndex > -1) {
|
||||
val bean = ScRootCauseAnalysisBean(
|
||||
problemLink = data[problemLinkIndex],
|
||||
problemCause = data[problemCauseIndex],
|
||||
)
|
||||
list2.add(bean)
|
||||
} else {
|
||||
liveDataMessage.postValue("元数据表规格不正确,请仔细核对")
|
||||
break
|
||||
}
|
||||
}
|
||||
roomAppDatabase.getScRootCauseAnalysisDao().insertOrUpdateList(list)
|
||||
index++
|
||||
}
|
||||
workbook.close()
|
||||
if (list.isNotEmpty()) {
|
||||
liveDataMessage.postValue("元数据表导入成功")
|
||||
roomAppDatabase.getScProblemTypeDao().insertOrUpdateList(list)
|
||||
}
|
||||
if (list2.isNotEmpty()) {
|
||||
liveDataMessage.postValue("元数据表导入成功")
|
||||
roomAppDatabase.getScRootCauseAnalysisDao().insertOrUpdateList(list2)
|
||||
}
|
||||
|
||||
bufferedReader.close()
|
||||
inputStreamReader.close()
|
||||
inputStream.close()
|
||||
// val workbook = WorkbookFactory.create(inputStream)
|
||||
// //获取所有sheet
|
||||
// val sheet1 = workbook.getSheet("SC_PROBLEM_TYPE")
|
||||
// sheet1?.let {
|
||||
// val rowCount: Int = it.physicalNumberOfRows // 获取行数
|
||||
// val list = mutableListOf<ScProblemTypeBean>()
|
||||
// for (i in 1 until rowCount) {
|
||||
// val row: Row = it.getRow(i) // 获取行
|
||||
//// val cellCount: Int = row.physicalNumberOfCells // 获取列数
|
||||
// val bean = ScProblemTypeBean(
|
||||
// elementType = row.getCell(0).stringCellValue,
|
||||
// elementCode = row.getCell(1).numericCellValue.toString(),
|
||||
// classType = row.getCell(2).stringCellValue,
|
||||
// problemType = row.getCell(3).stringCellValue,
|
||||
// phenomenon = row.getCell(4).stringCellValue
|
||||
// )
|
||||
// list.add(bean)
|
||||
// Log.e("jingo", bean.toString())
|
||||
// }
|
||||
// roomAppDatabase.getScProblemTypeDao().insertOrUpdateList(list)
|
||||
// }
|
||||
// val sheet2 = workbook.getSheet("SC_ROOT_CAUSE_ANALYSIS")
|
||||
// sheet2?.let {
|
||||
// val rowCount: Int = it.physicalNumberOfRows // 获取行数
|
||||
// val list = mutableListOf<ScRootCauseAnalysisBean>()
|
||||
// for (i in 1 until rowCount) {
|
||||
// val row: Row = it.getRow(i) // 获取行
|
||||
// val cellCount: Int = row.physicalNumberOfCells // 获取列数
|
||||
// if (cellCount == 2) {
|
||||
// val bean = ScRootCauseAnalysisBean()
|
||||
// bean.problemLink = row.getCell(0).stringCellValue
|
||||
// bean.problemCause = row.getCell(1).stringCellValue
|
||||
// list.add(bean)
|
||||
// Log.e("jingo", bean.toString())
|
||||
// }
|
||||
// }
|
||||
// roomAppDatabase.getScRootCauseAnalysisDao().insertOrUpdateList(list)
|
||||
// }
|
||||
// workbook.close()
|
||||
|
||||
} catch (e: IOException) {
|
||||
e.printStackTrace()
|
||||
Log.e("jingo", e.toString())
|
||||
liveDataMessage.postValue("元数据表导入失败!$e")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fun readRealmData() {
|
||||
|
@ -8,18 +8,12 @@ import androidx.fragment.app.viewModels
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import androidx.recyclerview.widget.DividerItemDecoration
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView.VERTICAL
|
||||
import com.blankj.utilcode.util.ToastUtils
|
||||
import com.navinfo.omqs.R
|
||||
import com.navinfo.omqs.databinding.FragmentQsRecordListBinding
|
||||
import com.navinfo.omqs.ui.activity.map.MainActivity
|
||||
import com.navinfo.omqs.ui.fragment.BaseFragment
|
||||
import com.navinfo.omqs.ui.fragment.tasklist.QsRecordListAdapter
|
||||
import com.navinfo.omqs.ui.other.BaseToast.makeText
|
||||
import com.navinfo.omqs.ui.widget.RecycleViewDivider
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import org.apache.poi.xwpf.usermodel.VerticalAlign
|
||||
import javax.inject.Inject
|
||||
|
||||
@AndroidEntryPoint
|
||||
class QsRecordListFragment : BaseFragment(){
|
||||
|
@ -65,7 +65,6 @@ class TaskListViewModel @Inject constructor(
|
||||
}
|
||||
}
|
||||
is NetResult.Loading -> {}
|
||||
else -> {}
|
||||
}
|
||||
|
||||
for (item in taskList) {
|
||||
|
@ -45,7 +45,7 @@ abstract class BaseRecyclerViewAdapter<T>(var data: List<T> = listOf()) :
|
||||
|
||||
override fun onViewDetachedFromWindow(holder: BaseViewHolder) {
|
||||
super.onViewDetachedFromWindow(holder)
|
||||
holder.apply {
|
||||
holder.run {
|
||||
onStop()
|
||||
}
|
||||
}
|
||||
|
@ -64,7 +64,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
android:background="@drawable/fm_card_map_down_status_bg"
|
||||
android:onClick="@{fragment.onClick}"
|
||||
android:onClick="@{fragment::onClick}"
|
||||
android:text="@{viewModel.liveDataQsRecordBean.classType}" />
|
||||
|
||||
<TextView
|
||||
@ -73,7 +73,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
android:background="@drawable/fm_card_map_down_status_bg"
|
||||
android:onClick="@{fragment.onClick}"
|
||||
android:onClick="@{fragment::onClick}"
|
||||
android:text="@{viewModel.liveDataQsRecordBean.problemType}" />
|
||||
|
||||
<TextView
|
||||
|
Loading…
x
Reference in New Issue
Block a user