diff --git a/app/build.gradle b/app/build.gradle index d0cb423..921c8c8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,25 +1,20 @@ import java.text.SimpleDateFormat -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply plugin: 'org.greenrobot.greendao' +plugins { + id('com.android.application') + id('org.jetbrains.kotlin.android') +} android { - compileSdkVersion 33 + namespace 'com.casic.common.detector.gd' + compileSdk 35 defaultConfig { - applicationId "com.casic.common.detector.gd" - minSdkVersion 26 - targetSdkVersion 33 + applicationId 'com.casic.common.detector.gd' + minSdk 26 + targetSdk 35 versionCode 5092 - versionName "5.0.9.2" - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } + versionName '5.0.9.2' } signingConfigs { @@ -31,6 +26,14 @@ } } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + signingConfig signingConfigs.release + } + } + compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 @@ -47,27 +50,16 @@ } } - kotlin { - experimental { - coroutines 'enable' - } - } - buildFeatures { + buildConfig true viewBinding true } - applicationVariants.configureEach { variant -> - variant.outputs.configureEach { - outputFileName = "COM_TCY_" + getBuildDate() + "_" + defaultConfig.versionName + ".apk" + applicationVariants.configureEach { + outputs.configureEach { + outputFileName = 'COM_TCY_' + getBuildDate() + '_' + defaultConfig.versionName + '.apk' } } - - greendao { - schemaVersion 1//数据库版本号 - targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 - daoPackage "${defaultConfig.applicationId}.greendao"//设置DaoMaster、DaoSession、Dao包名 - } } static def getBuildDate() { @@ -76,27 +68,22 @@ } dependencies { - //基础依赖库 - implementation 'com.github.AndroidCoderPeng:Kotlin-lite-lib:1.1.4' - implementation 'androidx.core:core-ktx:1.9.0' - def base_version = "1.6.1" - implementation "androidx.appcompat:appcompat:${base_version}" - implementation "com.google.android.material:material:${base_version}" + implementation 'com.github.AndroidCoderPeng:Kotlin-lite-lib:1.1.5' + implementation 'androidx.core:core-ktx:1.13.1' + implementation 'androidx.appcompat:appcompat:1.7.0' + implementation 'com.google.android.material:material:1.12.0' //Google官方授权框架 implementation 'pub.devrel:easypermissions:3.0.0' - //沉浸式状态栏。基础依赖包,必须要依赖 - implementation 'com.gyf.immersionbar:immersionbar:3.0.0' - //fragment快速实现 - implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0' + //沉浸式状态栏 + implementation 'com.geyifeng.immersionbar:immersionbar:3.2.2' //官方Json解析库 implementation 'com.google.code.gson:gson:2.10.1' - def vm_version = '2.5.1' //Kotlin协程 - implementation "androidx.lifecycle:lifecycle-runtime-ktx:${vm_version}" + implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.2' //MVVM+LiveData - implementation "androidx.lifecycle:lifecycle-livedata-ktx:${vm_version}" - implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:${vm_version}" - implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.6.2' + implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2' + implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' //返回值转换器 implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' @@ -105,9 +92,10 @@ implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' //网络请求和接口封装 implementation 'com.squareup.retrofit2:retrofit:2.9.0' - implementation 'com.squareup.okhttp3:okhttp:4.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.12.0' //数据库框架 - implementation 'org.greenrobot:greendao:3.3.0' + implementation 'androidx.room:room-runtime:2.6.1' + annotationProcessor 'androidx.room:room-compiler:2.5.2' //高德导航、定位、地图三合一 implementation 'com.amap.api:navi-3dmap:latest.integration' //经纬度逆编码 @@ -115,7 +103,7 @@ //excel implementation 'net.sourceforge.jexcelapi:jxl:2.6.12' //图片加载框架 - implementation 'com.github.bumptech.glide:glide:4.9.0' + implementation 'com.github.bumptech.glide:glide:4.12.0' //图片选择框架 implementation 'io.github.lucksiege:pictureselector:v3.11.1' //大图 diff --git a/app/build.gradle b/app/build.gradle index d0cb423..921c8c8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,25 +1,20 @@ import java.text.SimpleDateFormat -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply plugin: 'org.greenrobot.greendao' +plugins { + id('com.android.application') + id('org.jetbrains.kotlin.android') +} android { - compileSdkVersion 33 + namespace 'com.casic.common.detector.gd' + compileSdk 35 defaultConfig { - applicationId "com.casic.common.detector.gd" - minSdkVersion 26 - targetSdkVersion 33 + applicationId 'com.casic.common.detector.gd' + minSdk 26 + targetSdk 35 versionCode 5092 - versionName "5.0.9.2" - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } + versionName '5.0.9.2' } signingConfigs { @@ -31,6 +26,14 @@ } } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + signingConfig signingConfigs.release + } + } + compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 @@ -47,27 +50,16 @@ } } - kotlin { - experimental { - coroutines 'enable' - } - } - buildFeatures { + buildConfig true viewBinding true } - applicationVariants.configureEach { variant -> - variant.outputs.configureEach { - outputFileName = "COM_TCY_" + getBuildDate() + "_" + defaultConfig.versionName + ".apk" + applicationVariants.configureEach { + outputs.configureEach { + outputFileName = 'COM_TCY_' + getBuildDate() + '_' + defaultConfig.versionName + '.apk' } } - - greendao { - schemaVersion 1//数据库版本号 - targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 - daoPackage "${defaultConfig.applicationId}.greendao"//设置DaoMaster、DaoSession、Dao包名 - } } static def getBuildDate() { @@ -76,27 +68,22 @@ } dependencies { - //基础依赖库 - implementation 'com.github.AndroidCoderPeng:Kotlin-lite-lib:1.1.4' - implementation 'androidx.core:core-ktx:1.9.0' - def base_version = "1.6.1" - implementation "androidx.appcompat:appcompat:${base_version}" - implementation "com.google.android.material:material:${base_version}" + implementation 'com.github.AndroidCoderPeng:Kotlin-lite-lib:1.1.5' + implementation 'androidx.core:core-ktx:1.13.1' + implementation 'androidx.appcompat:appcompat:1.7.0' + implementation 'com.google.android.material:material:1.12.0' //Google官方授权框架 implementation 'pub.devrel:easypermissions:3.0.0' - //沉浸式状态栏。基础依赖包,必须要依赖 - implementation 'com.gyf.immersionbar:immersionbar:3.0.0' - //fragment快速实现 - implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0' + //沉浸式状态栏 + implementation 'com.geyifeng.immersionbar:immersionbar:3.2.2' //官方Json解析库 implementation 'com.google.code.gson:gson:2.10.1' - def vm_version = '2.5.1' //Kotlin协程 - implementation "androidx.lifecycle:lifecycle-runtime-ktx:${vm_version}" + implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.2' //MVVM+LiveData - implementation "androidx.lifecycle:lifecycle-livedata-ktx:${vm_version}" - implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:${vm_version}" - implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.6.2' + implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2' + implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' //返回值转换器 implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' @@ -105,9 +92,10 @@ implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' //网络请求和接口封装 implementation 'com.squareup.retrofit2:retrofit:2.9.0' - implementation 'com.squareup.okhttp3:okhttp:4.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.12.0' //数据库框架 - implementation 'org.greenrobot:greendao:3.3.0' + implementation 'androidx.room:room-runtime:2.6.1' + annotationProcessor 'androidx.room:room-compiler:2.5.2' //高德导航、定位、地图三合一 implementation 'com.amap.api:navi-3dmap:latest.integration' //经纬度逆编码 @@ -115,7 +103,7 @@ //excel implementation 'net.sourceforge.jexcelapi:jxl:2.6.12' //图片加载框架 - implementation 'com.github.bumptech.glide:glide:4.9.0' + implementation 'com.github.bumptech.glide:glide:4.12.0' //图片选择框架 implementation 'io.github.lucksiege:pictureselector:v3.11.1' //大图 diff --git a/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt b/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt index 7b695ff..50ba734 100644 --- a/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt +++ b/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt @@ -4,9 +4,9 @@ import android.app.Application import android.os.Bundle import android.util.Log -import com.casic.common.detector.gd.greendao.DaoMaster -import com.casic.common.detector.gd.greendao.DaoSession +import androidx.room.Room.databaseBuilder import com.casic.common.detector.gd.uart.SerialPort +import com.casic.common.detector.gd.utils.DetectorDataBase import com.casic.common.detector.gd.utils.GpioManager import com.pengxh.kt.lite.extensions.show import com.pengxh.kt.lite.utils.SaveKeyValues @@ -43,44 +43,42 @@ private var application: BaseApplication by Delegates.notNull() fun get() = application - - private lateinit var daoSession: DaoSession } + lateinit var dataBase: DetectorDataBase + override fun onCreate() { super.onCreate() application = this SaveKeyValues.initSharedPreferences(this) CrashReport.initCrashReport(this, "01e80d3a74", true) - val devOpenHelper = DaoMaster.DevOpenHelper(this, "Detector.db", null) - val daoMaster = DaoMaster(devOpenHelper.writableDatabase) - daoSession = daoMaster.newSession() + dataBase = databaseBuilder(this, DetectorDataBase::class.java, "Detector.db") + .allowMainThreadQueries() + .build() /** * Open the serial port * */ try { serialPorts.apply { - add(SerialPort(File("/dev/ttysWK1"), 9600, 0)) - //千寻报文数据下发串口号 - add(SerialPort(File("/dev/ttyS1"), 9600, 0)) + add(SerialPort(File("/dev/ttysWK1"), 9600, 0)) //信号通讯串口 + add(SerialPort(File("/dev/ttyS1"), 9600, 0)) //千寻报文数据下发串口号 } Log.d(kTag, "onCreate: 已初始化 ${serialPorts.size} 个串口") } catch (e: SecurityException) { "您没有串口的读写权限!".show(this) + e.printStackTrace() } catch (e: IOException) { "因为不明原因,串口无法打开!".show(this) + e.printStackTrace() } catch (e: InvalidParameterException) { "请检查串口!".show(this) + e.printStackTrace() } registerActivityLifecycleCallbacks(this) } - fun getDaoSession(): DaoSession { - return daoSession - } - override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) { } diff --git a/app/build.gradle b/app/build.gradle index d0cb423..921c8c8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,25 +1,20 @@ import java.text.SimpleDateFormat -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply plugin: 'org.greenrobot.greendao' +plugins { + id('com.android.application') + id('org.jetbrains.kotlin.android') +} android { - compileSdkVersion 33 + namespace 'com.casic.common.detector.gd' + compileSdk 35 defaultConfig { - applicationId "com.casic.common.detector.gd" - minSdkVersion 26 - targetSdkVersion 33 + applicationId 'com.casic.common.detector.gd' + minSdk 26 + targetSdk 35 versionCode 5092 - versionName "5.0.9.2" - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } + versionName '5.0.9.2' } signingConfigs { @@ -31,6 +26,14 @@ } } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + signingConfig signingConfigs.release + } + } + compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 @@ -47,27 +50,16 @@ } } - kotlin { - experimental { - coroutines 'enable' - } - } - buildFeatures { + buildConfig true viewBinding true } - applicationVariants.configureEach { variant -> - variant.outputs.configureEach { - outputFileName = "COM_TCY_" + getBuildDate() + "_" + defaultConfig.versionName + ".apk" + applicationVariants.configureEach { + outputs.configureEach { + outputFileName = 'COM_TCY_' + getBuildDate() + '_' + defaultConfig.versionName + '.apk' } } - - greendao { - schemaVersion 1//数据库版本号 - targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 - daoPackage "${defaultConfig.applicationId}.greendao"//设置DaoMaster、DaoSession、Dao包名 - } } static def getBuildDate() { @@ -76,27 +68,22 @@ } dependencies { - //基础依赖库 - implementation 'com.github.AndroidCoderPeng:Kotlin-lite-lib:1.1.4' - implementation 'androidx.core:core-ktx:1.9.0' - def base_version = "1.6.1" - implementation "androidx.appcompat:appcompat:${base_version}" - implementation "com.google.android.material:material:${base_version}" + implementation 'com.github.AndroidCoderPeng:Kotlin-lite-lib:1.1.5' + implementation 'androidx.core:core-ktx:1.13.1' + implementation 'androidx.appcompat:appcompat:1.7.0' + implementation 'com.google.android.material:material:1.12.0' //Google官方授权框架 implementation 'pub.devrel:easypermissions:3.0.0' - //沉浸式状态栏。基础依赖包,必须要依赖 - implementation 'com.gyf.immersionbar:immersionbar:3.0.0' - //fragment快速实现 - implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0' + //沉浸式状态栏 + implementation 'com.geyifeng.immersionbar:immersionbar:3.2.2' //官方Json解析库 implementation 'com.google.code.gson:gson:2.10.1' - def vm_version = '2.5.1' //Kotlin协程 - implementation "androidx.lifecycle:lifecycle-runtime-ktx:${vm_version}" + implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.2' //MVVM+LiveData - implementation "androidx.lifecycle:lifecycle-livedata-ktx:${vm_version}" - implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:${vm_version}" - implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.6.2' + implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2' + implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' //返回值转换器 implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' @@ -105,9 +92,10 @@ implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' //网络请求和接口封装 implementation 'com.squareup.retrofit2:retrofit:2.9.0' - implementation 'com.squareup.okhttp3:okhttp:4.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.12.0' //数据库框架 - implementation 'org.greenrobot:greendao:3.3.0' + implementation 'androidx.room:room-runtime:2.6.1' + annotationProcessor 'androidx.room:room-compiler:2.5.2' //高德导航、定位、地图三合一 implementation 'com.amap.api:navi-3dmap:latest.integration' //经纬度逆编码 @@ -115,7 +103,7 @@ //excel implementation 'net.sourceforge.jexcelapi:jxl:2.6.12' //图片加载框架 - implementation 'com.github.bumptech.glide:glide:4.9.0' + implementation 'com.github.bumptech.glide:glide:4.12.0' //图片选择框架 implementation 'io.github.lucksiege:pictureselector:v3.11.1' //大图 diff --git a/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt b/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt index 7b695ff..50ba734 100644 --- a/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt +++ b/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt @@ -4,9 +4,9 @@ import android.app.Application import android.os.Bundle import android.util.Log -import com.casic.common.detector.gd.greendao.DaoMaster -import com.casic.common.detector.gd.greendao.DaoSession +import androidx.room.Room.databaseBuilder import com.casic.common.detector.gd.uart.SerialPort +import com.casic.common.detector.gd.utils.DetectorDataBase import com.casic.common.detector.gd.utils.GpioManager import com.pengxh.kt.lite.extensions.show import com.pengxh.kt.lite.utils.SaveKeyValues @@ -43,44 +43,42 @@ private var application: BaseApplication by Delegates.notNull() fun get() = application - - private lateinit var daoSession: DaoSession } + lateinit var dataBase: DetectorDataBase + override fun onCreate() { super.onCreate() application = this SaveKeyValues.initSharedPreferences(this) CrashReport.initCrashReport(this, "01e80d3a74", true) - val devOpenHelper = DaoMaster.DevOpenHelper(this, "Detector.db", null) - val daoMaster = DaoMaster(devOpenHelper.writableDatabase) - daoSession = daoMaster.newSession() + dataBase = databaseBuilder(this, DetectorDataBase::class.java, "Detector.db") + .allowMainThreadQueries() + .build() /** * Open the serial port * */ try { serialPorts.apply { - add(SerialPort(File("/dev/ttysWK1"), 9600, 0)) - //千寻报文数据下发串口号 - add(SerialPort(File("/dev/ttyS1"), 9600, 0)) + add(SerialPort(File("/dev/ttysWK1"), 9600, 0)) //信号通讯串口 + add(SerialPort(File("/dev/ttyS1"), 9600, 0)) //千寻报文数据下发串口号 } Log.d(kTag, "onCreate: 已初始化 ${serialPorts.size} 个串口") } catch (e: SecurityException) { "您没有串口的读写权限!".show(this) + e.printStackTrace() } catch (e: IOException) { "因为不明原因,串口无法打开!".show(this) + e.printStackTrace() } catch (e: InvalidParameterException) { "请检查串口!".show(this) + e.printStackTrace() } registerActivityLifecycleCallbacks(this) } - fun getDaoSession(): DaoSession { - return daoSession - } - override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) { } diff --git a/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt b/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt index 053b9dd..1d0c9e3 100644 --- a/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt +++ b/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt @@ -14,12 +14,10 @@ import com.casic.common.detector.gd.utils.SerialPortCommand import com.pengxh.kt.lite.utils.WeakReferenceHandler import java.io.IOException -import java.util.Timer abstract class SerialPortBaseActivity : AppCompatActivity(), Handler.Callback { private val kTag = "SerialPortBaseActivity" - private val taskTimer by lazy { Timer() } private val weakReferenceHandler by lazy { WeakReferenceHandler(this) } private val serialPorts by lazy { BaseApplication.get().getSerialPorts() } protected lateinit var binding: VB @@ -30,7 +28,6 @@ setContentView(binding.root) setupTopBarLayout() initOnCreate(savedInstanceState) - observeRequestState() initEvent() if (serialPorts.isNotEmpty()) { @@ -71,11 +68,6 @@ abstract fun initOnCreate(savedInstanceState: Bundle?) /** - * 数据请求状态监听 - */ - abstract fun observeRequestState() - - /** * 初始化业务逻辑 */ abstract fun initEvent() diff --git a/app/build.gradle b/app/build.gradle index d0cb423..921c8c8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,25 +1,20 @@ import java.text.SimpleDateFormat -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply plugin: 'org.greenrobot.greendao' +plugins { + id('com.android.application') + id('org.jetbrains.kotlin.android') +} android { - compileSdkVersion 33 + namespace 'com.casic.common.detector.gd' + compileSdk 35 defaultConfig { - applicationId "com.casic.common.detector.gd" - minSdkVersion 26 - targetSdkVersion 33 + applicationId 'com.casic.common.detector.gd' + minSdk 26 + targetSdk 35 versionCode 5092 - versionName "5.0.9.2" - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } + versionName '5.0.9.2' } signingConfigs { @@ -31,6 +26,14 @@ } } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + signingConfig signingConfigs.release + } + } + compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 @@ -47,27 +50,16 @@ } } - kotlin { - experimental { - coroutines 'enable' - } - } - buildFeatures { + buildConfig true viewBinding true } - applicationVariants.configureEach { variant -> - variant.outputs.configureEach { - outputFileName = "COM_TCY_" + getBuildDate() + "_" + defaultConfig.versionName + ".apk" + applicationVariants.configureEach { + outputs.configureEach { + outputFileName = 'COM_TCY_' + getBuildDate() + '_' + defaultConfig.versionName + '.apk' } } - - greendao { - schemaVersion 1//数据库版本号 - targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 - daoPackage "${defaultConfig.applicationId}.greendao"//设置DaoMaster、DaoSession、Dao包名 - } } static def getBuildDate() { @@ -76,27 +68,22 @@ } dependencies { - //基础依赖库 - implementation 'com.github.AndroidCoderPeng:Kotlin-lite-lib:1.1.4' - implementation 'androidx.core:core-ktx:1.9.0' - def base_version = "1.6.1" - implementation "androidx.appcompat:appcompat:${base_version}" - implementation "com.google.android.material:material:${base_version}" + implementation 'com.github.AndroidCoderPeng:Kotlin-lite-lib:1.1.5' + implementation 'androidx.core:core-ktx:1.13.1' + implementation 'androidx.appcompat:appcompat:1.7.0' + implementation 'com.google.android.material:material:1.12.0' //Google官方授权框架 implementation 'pub.devrel:easypermissions:3.0.0' - //沉浸式状态栏。基础依赖包,必须要依赖 - implementation 'com.gyf.immersionbar:immersionbar:3.0.0' - //fragment快速实现 - implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0' + //沉浸式状态栏 + implementation 'com.geyifeng.immersionbar:immersionbar:3.2.2' //官方Json解析库 implementation 'com.google.code.gson:gson:2.10.1' - def vm_version = '2.5.1' //Kotlin协程 - implementation "androidx.lifecycle:lifecycle-runtime-ktx:${vm_version}" + implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.2' //MVVM+LiveData - implementation "androidx.lifecycle:lifecycle-livedata-ktx:${vm_version}" - implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:${vm_version}" - implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.6.2' + implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2' + implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' //返回值转换器 implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' @@ -105,9 +92,10 @@ implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' //网络请求和接口封装 implementation 'com.squareup.retrofit2:retrofit:2.9.0' - implementation 'com.squareup.okhttp3:okhttp:4.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.12.0' //数据库框架 - implementation 'org.greenrobot:greendao:3.3.0' + implementation 'androidx.room:room-runtime:2.6.1' + annotationProcessor 'androidx.room:room-compiler:2.5.2' //高德导航、定位、地图三合一 implementation 'com.amap.api:navi-3dmap:latest.integration' //经纬度逆编码 @@ -115,7 +103,7 @@ //excel implementation 'net.sourceforge.jexcelapi:jxl:2.6.12' //图片加载框架 - implementation 'com.github.bumptech.glide:glide:4.9.0' + implementation 'com.github.bumptech.glide:glide:4.12.0' //图片选择框架 implementation 'io.github.lucksiege:pictureselector:v3.11.1' //大图 diff --git a/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt b/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt index 7b695ff..50ba734 100644 --- a/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt +++ b/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt @@ -4,9 +4,9 @@ import android.app.Application import android.os.Bundle import android.util.Log -import com.casic.common.detector.gd.greendao.DaoMaster -import com.casic.common.detector.gd.greendao.DaoSession +import androidx.room.Room.databaseBuilder import com.casic.common.detector.gd.uart.SerialPort +import com.casic.common.detector.gd.utils.DetectorDataBase import com.casic.common.detector.gd.utils.GpioManager import com.pengxh.kt.lite.extensions.show import com.pengxh.kt.lite.utils.SaveKeyValues @@ -43,44 +43,42 @@ private var application: BaseApplication by Delegates.notNull() fun get() = application - - private lateinit var daoSession: DaoSession } + lateinit var dataBase: DetectorDataBase + override fun onCreate() { super.onCreate() application = this SaveKeyValues.initSharedPreferences(this) CrashReport.initCrashReport(this, "01e80d3a74", true) - val devOpenHelper = DaoMaster.DevOpenHelper(this, "Detector.db", null) - val daoMaster = DaoMaster(devOpenHelper.writableDatabase) - daoSession = daoMaster.newSession() + dataBase = databaseBuilder(this, DetectorDataBase::class.java, "Detector.db") + .allowMainThreadQueries() + .build() /** * Open the serial port * */ try { serialPorts.apply { - add(SerialPort(File("/dev/ttysWK1"), 9600, 0)) - //千寻报文数据下发串口号 - add(SerialPort(File("/dev/ttyS1"), 9600, 0)) + add(SerialPort(File("/dev/ttysWK1"), 9600, 0)) //信号通讯串口 + add(SerialPort(File("/dev/ttyS1"), 9600, 0)) //千寻报文数据下发串口号 } Log.d(kTag, "onCreate: 已初始化 ${serialPorts.size} 个串口") } catch (e: SecurityException) { "您没有串口的读写权限!".show(this) + e.printStackTrace() } catch (e: IOException) { "因为不明原因,串口无法打开!".show(this) + e.printStackTrace() } catch (e: InvalidParameterException) { "请检查串口!".show(this) + e.printStackTrace() } registerActivityLifecycleCallbacks(this) } - fun getDaoSession(): DaoSession { - return daoSession - } - override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) { } diff --git a/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt b/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt index 053b9dd..1d0c9e3 100644 --- a/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt +++ b/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt @@ -14,12 +14,10 @@ import com.casic.common.detector.gd.utils.SerialPortCommand import com.pengxh.kt.lite.utils.WeakReferenceHandler import java.io.IOException -import java.util.Timer abstract class SerialPortBaseActivity : AppCompatActivity(), Handler.Callback { private val kTag = "SerialPortBaseActivity" - private val taskTimer by lazy { Timer() } private val weakReferenceHandler by lazy { WeakReferenceHandler(this) } private val serialPorts by lazy { BaseApplication.get().getSerialPorts() } protected lateinit var binding: VB @@ -30,7 +28,6 @@ setContentView(binding.root) setupTopBarLayout() initOnCreate(savedInstanceState) - observeRequestState() initEvent() if (serialPorts.isNotEmpty()) { @@ -71,11 +68,6 @@ abstract fun initOnCreate(savedInstanceState: Bundle?) /** - * 数据请求状态监听 - */ - abstract fun observeRequestState() - - /** * 初始化业务逻辑 */ abstract fun initEvent() diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java new file mode 100644 index 0000000..7a18c20 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java @@ -0,0 +1,255 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 从平台下载的标识器本地库实体类 + */ +@Entity(tableName = "marker_detail") +public class MarkerBean { + @PrimaryKey(autoGenerate = true) + private long id; //主键ID + private String pipelineType; // 管线类型 + private String pipelineDiameter; // 管线直径 + private String pipelineMaterial; // 管材 + private String buryMethod; // 埋设方式 + private String buryDepth; // 埋深 + private String area; // 所属区域 + private String line; // 所属线路 + private String road; // 所属道路 + private String constructTime; // 建设年代 + private String owner; // 权属单位 + private String objectId; // 标识对象ID,无实际用途 + private String markerId; // 标识器ID + private String markerType; // 标识器类型 + private String markerDepth; // 标识器埋深 + private String installationDept; // 安装部门 + private String lng; // 经度 + private String lat; // 纬度 + private String updateTime; // 最后修改时间,更新时间 + private String remark; // 备注信息 + private String underlyingPipelineType; // 下层管线类型 + private String underlyingPipelineDepth; // 下层埋深 + private String underlyingPipelineDiameter; // 下层管径 + private String underlyingPipelineMaterial; // 下层管材 + private String objectType; //标识对象类型 + private String color; // 颜色 + private String imagePath; // 图片路径 + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getPipelineType() { + return pipelineType; + } + + public void setPipelineType(String pipelineType) { + this.pipelineType = pipelineType; + } + + public String getPipelineDiameter() { + return pipelineDiameter; + } + + public void setPipelineDiameter(String pipelineDiameter) { + this.pipelineDiameter = pipelineDiameter; + } + + public String getPipelineMaterial() { + return pipelineMaterial; + } + + public void setPipelineMaterial(String pipelineMaterial) { + this.pipelineMaterial = pipelineMaterial; + } + + public String getBuryMethod() { + return buryMethod; + } + + public void setBuryMethod(String buryMethod) { + this.buryMethod = buryMethod; + } + + public String getBuryDepth() { + return buryDepth; + } + + public void setBuryDepth(String buryDepth) { + this.buryDepth = buryDepth; + } + + public String getArea() { + return area; + } + + public void setArea(String area) { + this.area = area; + } + + public String getLine() { + return line; + } + + public void setLine(String line) { + this.line = line; + } + + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + + public String getConstructTime() { + return constructTime; + } + + public void setConstructTime(String constructTime) { + this.constructTime = constructTime; + } + + public String getOwner() { + return owner; + } + + public void setOwner(String owner) { + this.owner = owner; + } + + public String getObjectId() { + return objectId; + } + + public void setObjectId(String objectId) { + this.objectId = objectId; + } + + public String getMarkerId() { + return markerId; + } + + public void setMarkerId(String markerId) { + this.markerId = markerId; + } + + public String getMarkerType() { + return markerType; + } + + public void setMarkerType(String markerType) { + this.markerType = markerType; + } + + public String getMarkerDepth() { + return markerDepth; + } + + public void setMarkerDepth(String markerDepth) { + this.markerDepth = markerDepth; + } + + public String getInstallationDept() { + return installationDept; + } + + public void setInstallationDept(String installationDept) { + this.installationDept = installationDept; + } + + public String getLng() { + return lng; + } + + public void setLng(String lng) { + this.lng = lng; + } + + public String getLat() { + return lat; + } + + public void setLat(String lat) { + this.lat = lat; + } + + public String getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } + + public String getUnderlyingPipelineType() { + return underlyingPipelineType; + } + + public void setUnderlyingPipelineType(String underlyingPipelineType) { + this.underlyingPipelineType = underlyingPipelineType; + } + + public String getUnderlyingPipelineDepth() { + return underlyingPipelineDepth; + } + + public void setUnderlyingPipelineDepth(String underlyingPipelineDepth) { + this.underlyingPipelineDepth = underlyingPipelineDepth; + } + + public String getUnderlyingPipelineDiameter() { + return underlyingPipelineDiameter; + } + + public void setUnderlyingPipelineDiameter(String underlyingPipelineDiameter) { + this.underlyingPipelineDiameter = underlyingPipelineDiameter; + } + + public String getUnderlyingPipelineMaterial() { + return underlyingPipelineMaterial; + } + + public void setUnderlyingPipelineMaterial(String underlyingPipelineMaterial) { + this.underlyingPipelineMaterial = underlyingPipelineMaterial; + } + + public String getObjectType() { + return objectType; + } + + public void setObjectType(String objectType) { + this.objectType = objectType; + } + + public String getColor() { + return color; + } + + public void setColor(String color) { + this.color = color; + } + + public String getImagePath() { + return imagePath; + } + + public void setImagePath(String imagePath) { + this.imagePath = imagePath; + } +} diff --git a/app/build.gradle b/app/build.gradle index d0cb423..921c8c8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,25 +1,20 @@ import java.text.SimpleDateFormat -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply plugin: 'org.greenrobot.greendao' +plugins { + id('com.android.application') + id('org.jetbrains.kotlin.android') +} android { - compileSdkVersion 33 + namespace 'com.casic.common.detector.gd' + compileSdk 35 defaultConfig { - applicationId "com.casic.common.detector.gd" - minSdkVersion 26 - targetSdkVersion 33 + applicationId 'com.casic.common.detector.gd' + minSdk 26 + targetSdk 35 versionCode 5092 - versionName "5.0.9.2" - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } + versionName '5.0.9.2' } signingConfigs { @@ -31,6 +26,14 @@ } } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + signingConfig signingConfigs.release + } + } + compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 @@ -47,27 +50,16 @@ } } - kotlin { - experimental { - coroutines 'enable' - } - } - buildFeatures { + buildConfig true viewBinding true } - applicationVariants.configureEach { variant -> - variant.outputs.configureEach { - outputFileName = "COM_TCY_" + getBuildDate() + "_" + defaultConfig.versionName + ".apk" + applicationVariants.configureEach { + outputs.configureEach { + outputFileName = 'COM_TCY_' + getBuildDate() + '_' + defaultConfig.versionName + '.apk' } } - - greendao { - schemaVersion 1//数据库版本号 - targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 - daoPackage "${defaultConfig.applicationId}.greendao"//设置DaoMaster、DaoSession、Dao包名 - } } static def getBuildDate() { @@ -76,27 +68,22 @@ } dependencies { - //基础依赖库 - implementation 'com.github.AndroidCoderPeng:Kotlin-lite-lib:1.1.4' - implementation 'androidx.core:core-ktx:1.9.0' - def base_version = "1.6.1" - implementation "androidx.appcompat:appcompat:${base_version}" - implementation "com.google.android.material:material:${base_version}" + implementation 'com.github.AndroidCoderPeng:Kotlin-lite-lib:1.1.5' + implementation 'androidx.core:core-ktx:1.13.1' + implementation 'androidx.appcompat:appcompat:1.7.0' + implementation 'com.google.android.material:material:1.12.0' //Google官方授权框架 implementation 'pub.devrel:easypermissions:3.0.0' - //沉浸式状态栏。基础依赖包,必须要依赖 - implementation 'com.gyf.immersionbar:immersionbar:3.0.0' - //fragment快速实现 - implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0' + //沉浸式状态栏 + implementation 'com.geyifeng.immersionbar:immersionbar:3.2.2' //官方Json解析库 implementation 'com.google.code.gson:gson:2.10.1' - def vm_version = '2.5.1' //Kotlin协程 - implementation "androidx.lifecycle:lifecycle-runtime-ktx:${vm_version}" + implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.2' //MVVM+LiveData - implementation "androidx.lifecycle:lifecycle-livedata-ktx:${vm_version}" - implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:${vm_version}" - implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.6.2' + implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2' + implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' //返回值转换器 implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' @@ -105,9 +92,10 @@ implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' //网络请求和接口封装 implementation 'com.squareup.retrofit2:retrofit:2.9.0' - implementation 'com.squareup.okhttp3:okhttp:4.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.12.0' //数据库框架 - implementation 'org.greenrobot:greendao:3.3.0' + implementation 'androidx.room:room-runtime:2.6.1' + annotationProcessor 'androidx.room:room-compiler:2.5.2' //高德导航、定位、地图三合一 implementation 'com.amap.api:navi-3dmap:latest.integration' //经纬度逆编码 @@ -115,7 +103,7 @@ //excel implementation 'net.sourceforge.jexcelapi:jxl:2.6.12' //图片加载框架 - implementation 'com.github.bumptech.glide:glide:4.9.0' + implementation 'com.github.bumptech.glide:glide:4.12.0' //图片选择框架 implementation 'io.github.lucksiege:pictureselector:v3.11.1' //大图 diff --git a/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt b/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt index 7b695ff..50ba734 100644 --- a/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt +++ b/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt @@ -4,9 +4,9 @@ import android.app.Application import android.os.Bundle import android.util.Log -import com.casic.common.detector.gd.greendao.DaoMaster -import com.casic.common.detector.gd.greendao.DaoSession +import androidx.room.Room.databaseBuilder import com.casic.common.detector.gd.uart.SerialPort +import com.casic.common.detector.gd.utils.DetectorDataBase import com.casic.common.detector.gd.utils.GpioManager import com.pengxh.kt.lite.extensions.show import com.pengxh.kt.lite.utils.SaveKeyValues @@ -43,44 +43,42 @@ private var application: BaseApplication by Delegates.notNull() fun get() = application - - private lateinit var daoSession: DaoSession } + lateinit var dataBase: DetectorDataBase + override fun onCreate() { super.onCreate() application = this SaveKeyValues.initSharedPreferences(this) CrashReport.initCrashReport(this, "01e80d3a74", true) - val devOpenHelper = DaoMaster.DevOpenHelper(this, "Detector.db", null) - val daoMaster = DaoMaster(devOpenHelper.writableDatabase) - daoSession = daoMaster.newSession() + dataBase = databaseBuilder(this, DetectorDataBase::class.java, "Detector.db") + .allowMainThreadQueries() + .build() /** * Open the serial port * */ try { serialPorts.apply { - add(SerialPort(File("/dev/ttysWK1"), 9600, 0)) - //千寻报文数据下发串口号 - add(SerialPort(File("/dev/ttyS1"), 9600, 0)) + add(SerialPort(File("/dev/ttysWK1"), 9600, 0)) //信号通讯串口 + add(SerialPort(File("/dev/ttyS1"), 9600, 0)) //千寻报文数据下发串口号 } Log.d(kTag, "onCreate: 已初始化 ${serialPorts.size} 个串口") } catch (e: SecurityException) { "您没有串口的读写权限!".show(this) + e.printStackTrace() } catch (e: IOException) { "因为不明原因,串口无法打开!".show(this) + e.printStackTrace() } catch (e: InvalidParameterException) { "请检查串口!".show(this) + e.printStackTrace() } registerActivityLifecycleCallbacks(this) } - fun getDaoSession(): DaoSession { - return daoSession - } - override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) { } diff --git a/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt b/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt index 053b9dd..1d0c9e3 100644 --- a/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt +++ b/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt @@ -14,12 +14,10 @@ import com.casic.common.detector.gd.utils.SerialPortCommand import com.pengxh.kt.lite.utils.WeakReferenceHandler import java.io.IOException -import java.util.Timer abstract class SerialPortBaseActivity : AppCompatActivity(), Handler.Callback { private val kTag = "SerialPortBaseActivity" - private val taskTimer by lazy { Timer() } private val weakReferenceHandler by lazy { WeakReferenceHandler(this) } private val serialPorts by lazy { BaseApplication.get().getSerialPorts() } protected lateinit var binding: VB @@ -30,7 +28,6 @@ setContentView(binding.root) setupTopBarLayout() initOnCreate(savedInstanceState) - observeRequestState() initEvent() if (serialPorts.isNotEmpty()) { @@ -71,11 +68,6 @@ abstract fun initOnCreate(savedInstanceState: Bundle?) /** - * 数据请求状态监听 - */ - abstract fun observeRequestState() - - /** * 初始化业务逻辑 */ abstract fun initEvent() diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java new file mode 100644 index 0000000..7a18c20 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java @@ -0,0 +1,255 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 从平台下载的标识器本地库实体类 + */ +@Entity(tableName = "marker_detail") +public class MarkerBean { + @PrimaryKey(autoGenerate = true) + private long id; //主键ID + private String pipelineType; // 管线类型 + private String pipelineDiameter; // 管线直径 + private String pipelineMaterial; // 管材 + private String buryMethod; // 埋设方式 + private String buryDepth; // 埋深 + private String area; // 所属区域 + private String line; // 所属线路 + private String road; // 所属道路 + private String constructTime; // 建设年代 + private String owner; // 权属单位 + private String objectId; // 标识对象ID,无实际用途 + private String markerId; // 标识器ID + private String markerType; // 标识器类型 + private String markerDepth; // 标识器埋深 + private String installationDept; // 安装部门 + private String lng; // 经度 + private String lat; // 纬度 + private String updateTime; // 最后修改时间,更新时间 + private String remark; // 备注信息 + private String underlyingPipelineType; // 下层管线类型 + private String underlyingPipelineDepth; // 下层埋深 + private String underlyingPipelineDiameter; // 下层管径 + private String underlyingPipelineMaterial; // 下层管材 + private String objectType; //标识对象类型 + private String color; // 颜色 + private String imagePath; // 图片路径 + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getPipelineType() { + return pipelineType; + } + + public void setPipelineType(String pipelineType) { + this.pipelineType = pipelineType; + } + + public String getPipelineDiameter() { + return pipelineDiameter; + } + + public void setPipelineDiameter(String pipelineDiameter) { + this.pipelineDiameter = pipelineDiameter; + } + + public String getPipelineMaterial() { + return pipelineMaterial; + } + + public void setPipelineMaterial(String pipelineMaterial) { + this.pipelineMaterial = pipelineMaterial; + } + + public String getBuryMethod() { + return buryMethod; + } + + public void setBuryMethod(String buryMethod) { + this.buryMethod = buryMethod; + } + + public String getBuryDepth() { + return buryDepth; + } + + public void setBuryDepth(String buryDepth) { + this.buryDepth = buryDepth; + } + + public String getArea() { + return area; + } + + public void setArea(String area) { + this.area = area; + } + + public String getLine() { + return line; + } + + public void setLine(String line) { + this.line = line; + } + + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + + public String getConstructTime() { + return constructTime; + } + + public void setConstructTime(String constructTime) { + this.constructTime = constructTime; + } + + public String getOwner() { + return owner; + } + + public void setOwner(String owner) { + this.owner = owner; + } + + public String getObjectId() { + return objectId; + } + + public void setObjectId(String objectId) { + this.objectId = objectId; + } + + public String getMarkerId() { + return markerId; + } + + public void setMarkerId(String markerId) { + this.markerId = markerId; + } + + public String getMarkerType() { + return markerType; + } + + public void setMarkerType(String markerType) { + this.markerType = markerType; + } + + public String getMarkerDepth() { + return markerDepth; + } + + public void setMarkerDepth(String markerDepth) { + this.markerDepth = markerDepth; + } + + public String getInstallationDept() { + return installationDept; + } + + public void setInstallationDept(String installationDept) { + this.installationDept = installationDept; + } + + public String getLng() { + return lng; + } + + public void setLng(String lng) { + this.lng = lng; + } + + public String getLat() { + return lat; + } + + public void setLat(String lat) { + this.lat = lat; + } + + public String getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } + + public String getUnderlyingPipelineType() { + return underlyingPipelineType; + } + + public void setUnderlyingPipelineType(String underlyingPipelineType) { + this.underlyingPipelineType = underlyingPipelineType; + } + + public String getUnderlyingPipelineDepth() { + return underlyingPipelineDepth; + } + + public void setUnderlyingPipelineDepth(String underlyingPipelineDepth) { + this.underlyingPipelineDepth = underlyingPipelineDepth; + } + + public String getUnderlyingPipelineDiameter() { + return underlyingPipelineDiameter; + } + + public void setUnderlyingPipelineDiameter(String underlyingPipelineDiameter) { + this.underlyingPipelineDiameter = underlyingPipelineDiameter; + } + + public String getUnderlyingPipelineMaterial() { + return underlyingPipelineMaterial; + } + + public void setUnderlyingPipelineMaterial(String underlyingPipelineMaterial) { + this.underlyingPipelineMaterial = underlyingPipelineMaterial; + } + + public String getObjectType() { + return objectType; + } + + public void setObjectType(String objectType) { + this.objectType = objectType; + } + + public String getColor() { + return color; + } + + public void setColor(String color) { + this.color = color; + } + + public String getImagePath() { + return imagePath; + } + + public void setImagePath(String imagePath) { + this.imagePath = imagePath; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java deleted file mode 100644 index 3f2fcdc..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java +++ /dev/null @@ -1,327 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 从平台下载的标识器本地库实体类 - */ -@Entity -public class MarkerLocalBean { - @Id(autoincrement = true) - private Long id;//本地库主键ID - - // 管线类型 - private String pipelineType; - // 管线直径 - private String pipelineDiameter; - // 管材 - private String pipelineMaterial; - // 埋设方式 - private String buryMethod; - // 埋深 - private String buryDepth; - // 所属区域 - private String area; - // 所属线路 - private String line; - // 所属道路 - private String road; - // 建设年代 - private String constructTime; - // 权属单位 - private String owner; - //标识对象ID,无实际用途 - @Deprecated - private String objectId; - // 标识器ID - private String markerId; - // 标识器类型 - private String markerType; - // 标识器埋深 - private String markerDepth; - // 安装部门 - private String installationDept; - // 经度 - private String lng; - // 纬度 - private String lat; - //最后修改时间,更新时间 - private String updateTime; - // 备注信息 - private String remark; - // 下层管线类型 - private String underlyingPipelineType; - // 下层埋深 - private String underlyingPipelineDepth; - // 下层管径 - private String underlyingPipelineDiameter; - // 下层管材 - private String underlyingPipelineMaterial; - //标识对象类型 - private String objectType; - // 颜色 - private String color; - // 图片路径 - private String imagePath; - - @Generated(hash = 1479045776) - public MarkerLocalBean(Long id, String pipelineType, String pipelineDiameter, - String pipelineMaterial, String buryMethod, String buryDepth, - String area, String line, String road, String constructTime, - String owner, String objectId, String markerId, String markerType, - String markerDepth, String installationDept, String lng, String lat, - String updateTime, String remark, String underlyingPipelineType, - String underlyingPipelineDepth, String underlyingPipelineDiameter, - String underlyingPipelineMaterial, String objectType, String color, - String imagePath) { - this.id = id; - this.pipelineType = pipelineType; - this.pipelineDiameter = pipelineDiameter; - this.pipelineMaterial = pipelineMaterial; - this.buryMethod = buryMethod; - this.buryDepth = buryDepth; - this.area = area; - this.line = line; - this.road = road; - this.constructTime = constructTime; - this.owner = owner; - this.objectId = objectId; - this.markerId = markerId; - this.markerType = markerType; - this.markerDepth = markerDepth; - this.installationDept = installationDept; - this.lng = lng; - this.lat = lat; - this.updateTime = updateTime; - this.remark = remark; - this.underlyingPipelineType = underlyingPipelineType; - this.underlyingPipelineDepth = underlyingPipelineDepth; - this.underlyingPipelineDiameter = underlyingPipelineDiameter; - this.underlyingPipelineMaterial = underlyingPipelineMaterial; - this.objectType = objectType; - this.color = color; - this.imagePath = imagePath; - } - - @Generated(hash = 1538606012) - public MarkerLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getPipelineType() { - return this.pipelineType; - } - - public void setPipelineType(String pipelineType) { - this.pipelineType = pipelineType; - } - - public String getPipelineDiameter() { - return this.pipelineDiameter; - } - - public void setPipelineDiameter(String pipelineDiameter) { - this.pipelineDiameter = pipelineDiameter; - } - - public String getPipelineMaterial() { - return this.pipelineMaterial; - } - - public void setPipelineMaterial(String pipelineMaterial) { - this.pipelineMaterial = pipelineMaterial; - } - - public String getBuryMethod() { - return this.buryMethod; - } - - public void setBuryMethod(String buryMethod) { - this.buryMethod = buryMethod; - } - - public String getBuryDepth() { - return this.buryDepth; - } - - public void setBuryDepth(String buryDepth) { - this.buryDepth = buryDepth; - } - - public String getArea() { - return this.area; - } - - public void setArea(String area) { - this.area = area; - } - - public String getLine() { - return this.line; - } - - public void setLine(String line) { - this.line = line; - } - - public String getRoad() { - return this.road; - } - - public void setRoad(String road) { - this.road = road; - } - - public String getConstructTime() { - return this.constructTime; - } - - public void setConstructTime(String constructTime) { - this.constructTime = constructTime; - } - - public String getOwner() { - return this.owner; - } - - public void setOwner(String owner) { - this.owner = owner; - } - - public String getObjectId() { - return this.objectId; - } - - public void setObjectId(String objectId) { - this.objectId = objectId; - } - - public String getMarkerId() { - return this.markerId; - } - - public void setMarkerId(String markerId) { - this.markerId = markerId; - } - - public String getMarkerType() { - return this.markerType; - } - - public void setMarkerType(String markerType) { - this.markerType = markerType; - } - - public String getMarkerDepth() { - return this.markerDepth; - } - - public void setMarkerDepth(String markerDepth) { - this.markerDepth = markerDepth; - } - - public String getInstallationDept() { - return this.installationDept; - } - - public void setInstallationDept(String installationDept) { - this.installationDept = installationDept; - } - - public String getLng() { - return this.lng; - } - - public void setLng(String lng) { - this.lng = lng; - } - - public String getLat() { - return this.lat; - } - - public void setLat(String lat) { - this.lat = lat; - } - - public String getUpdateTime() { - return this.updateTime; - } - - public void setUpdateTime(String updateTime) { - this.updateTime = updateTime; - } - - public String getRemark() { - return this.remark; - } - - public void setRemark(String remark) { - this.remark = remark; - } - - public String getUnderlyingPipelineType() { - return this.underlyingPipelineType; - } - - public void setUnderlyingPipelineType(String underlyingPipelineType) { - this.underlyingPipelineType = underlyingPipelineType; - } - - public String getUnderlyingPipelineDepth() { - return this.underlyingPipelineDepth; - } - - public void setUnderlyingPipelineDepth(String underlyingPipelineDepth) { - this.underlyingPipelineDepth = underlyingPipelineDepth; - } - - public String getUnderlyingPipelineDiameter() { - return this.underlyingPipelineDiameter; - } - - public void setUnderlyingPipelineDiameter(String underlyingPipelineDiameter) { - this.underlyingPipelineDiameter = underlyingPipelineDiameter; - } - - public String getUnderlyingPipelineMaterial() { - return this.underlyingPipelineMaterial; - } - - public void setUnderlyingPipelineMaterial(String underlyingPipelineMaterial) { - this.underlyingPipelineMaterial = underlyingPipelineMaterial; - } - - public String getObjectType() { - return this.objectType; - } - - public void setObjectType(String objectType) { - this.objectType = objectType; - } - - public String getColor() { - return this.color; - } - - public void setColor(String color) { - this.color = color; - } - - public String getImagePath() { - return this.imagePath; - } - - public void setImagePath(String imagePath) { - this.imagePath = imagePath; - } -} diff --git a/app/build.gradle b/app/build.gradle index d0cb423..921c8c8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,25 +1,20 @@ import java.text.SimpleDateFormat -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply plugin: 'org.greenrobot.greendao' +plugins { + id('com.android.application') + id('org.jetbrains.kotlin.android') +} android { - compileSdkVersion 33 + namespace 'com.casic.common.detector.gd' + compileSdk 35 defaultConfig { - applicationId "com.casic.common.detector.gd" - minSdkVersion 26 - targetSdkVersion 33 + applicationId 'com.casic.common.detector.gd' + minSdk 26 + targetSdk 35 versionCode 5092 - versionName "5.0.9.2" - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } + versionName '5.0.9.2' } signingConfigs { @@ -31,6 +26,14 @@ } } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + signingConfig signingConfigs.release + } + } + compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 @@ -47,27 +50,16 @@ } } - kotlin { - experimental { - coroutines 'enable' - } - } - buildFeatures { + buildConfig true viewBinding true } - applicationVariants.configureEach { variant -> - variant.outputs.configureEach { - outputFileName = "COM_TCY_" + getBuildDate() + "_" + defaultConfig.versionName + ".apk" + applicationVariants.configureEach { + outputs.configureEach { + outputFileName = 'COM_TCY_' + getBuildDate() + '_' + defaultConfig.versionName + '.apk' } } - - greendao { - schemaVersion 1//数据库版本号 - targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 - daoPackage "${defaultConfig.applicationId}.greendao"//设置DaoMaster、DaoSession、Dao包名 - } } static def getBuildDate() { @@ -76,27 +68,22 @@ } dependencies { - //基础依赖库 - implementation 'com.github.AndroidCoderPeng:Kotlin-lite-lib:1.1.4' - implementation 'androidx.core:core-ktx:1.9.0' - def base_version = "1.6.1" - implementation "androidx.appcompat:appcompat:${base_version}" - implementation "com.google.android.material:material:${base_version}" + implementation 'com.github.AndroidCoderPeng:Kotlin-lite-lib:1.1.5' + implementation 'androidx.core:core-ktx:1.13.1' + implementation 'androidx.appcompat:appcompat:1.7.0' + implementation 'com.google.android.material:material:1.12.0' //Google官方授权框架 implementation 'pub.devrel:easypermissions:3.0.0' - //沉浸式状态栏。基础依赖包,必须要依赖 - implementation 'com.gyf.immersionbar:immersionbar:3.0.0' - //fragment快速实现 - implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0' + //沉浸式状态栏 + implementation 'com.geyifeng.immersionbar:immersionbar:3.2.2' //官方Json解析库 implementation 'com.google.code.gson:gson:2.10.1' - def vm_version = '2.5.1' //Kotlin协程 - implementation "androidx.lifecycle:lifecycle-runtime-ktx:${vm_version}" + implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.2' //MVVM+LiveData - implementation "androidx.lifecycle:lifecycle-livedata-ktx:${vm_version}" - implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:${vm_version}" - implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.6.2' + implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2' + implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' //返回值转换器 implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' @@ -105,9 +92,10 @@ implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' //网络请求和接口封装 implementation 'com.squareup.retrofit2:retrofit:2.9.0' - implementation 'com.squareup.okhttp3:okhttp:4.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.12.0' //数据库框架 - implementation 'org.greenrobot:greendao:3.3.0' + implementation 'androidx.room:room-runtime:2.6.1' + annotationProcessor 'androidx.room:room-compiler:2.5.2' //高德导航、定位、地图三合一 implementation 'com.amap.api:navi-3dmap:latest.integration' //经纬度逆编码 @@ -115,7 +103,7 @@ //excel implementation 'net.sourceforge.jexcelapi:jxl:2.6.12' //图片加载框架 - implementation 'com.github.bumptech.glide:glide:4.9.0' + implementation 'com.github.bumptech.glide:glide:4.12.0' //图片选择框架 implementation 'io.github.lucksiege:pictureselector:v3.11.1' //大图 diff --git a/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt b/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt index 7b695ff..50ba734 100644 --- a/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt +++ b/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt @@ -4,9 +4,9 @@ import android.app.Application import android.os.Bundle import android.util.Log -import com.casic.common.detector.gd.greendao.DaoMaster -import com.casic.common.detector.gd.greendao.DaoSession +import androidx.room.Room.databaseBuilder import com.casic.common.detector.gd.uart.SerialPort +import com.casic.common.detector.gd.utils.DetectorDataBase import com.casic.common.detector.gd.utils.GpioManager import com.pengxh.kt.lite.extensions.show import com.pengxh.kt.lite.utils.SaveKeyValues @@ -43,44 +43,42 @@ private var application: BaseApplication by Delegates.notNull() fun get() = application - - private lateinit var daoSession: DaoSession } + lateinit var dataBase: DetectorDataBase + override fun onCreate() { super.onCreate() application = this SaveKeyValues.initSharedPreferences(this) CrashReport.initCrashReport(this, "01e80d3a74", true) - val devOpenHelper = DaoMaster.DevOpenHelper(this, "Detector.db", null) - val daoMaster = DaoMaster(devOpenHelper.writableDatabase) - daoSession = daoMaster.newSession() + dataBase = databaseBuilder(this, DetectorDataBase::class.java, "Detector.db") + .allowMainThreadQueries() + .build() /** * Open the serial port * */ try { serialPorts.apply { - add(SerialPort(File("/dev/ttysWK1"), 9600, 0)) - //千寻报文数据下发串口号 - add(SerialPort(File("/dev/ttyS1"), 9600, 0)) + add(SerialPort(File("/dev/ttysWK1"), 9600, 0)) //信号通讯串口 + add(SerialPort(File("/dev/ttyS1"), 9600, 0)) //千寻报文数据下发串口号 } Log.d(kTag, "onCreate: 已初始化 ${serialPorts.size} 个串口") } catch (e: SecurityException) { "您没有串口的读写权限!".show(this) + e.printStackTrace() } catch (e: IOException) { "因为不明原因,串口无法打开!".show(this) + e.printStackTrace() } catch (e: InvalidParameterException) { "请检查串口!".show(this) + e.printStackTrace() } registerActivityLifecycleCallbacks(this) } - fun getDaoSession(): DaoSession { - return daoSession - } - override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) { } diff --git a/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt b/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt index 053b9dd..1d0c9e3 100644 --- a/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt +++ b/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt @@ -14,12 +14,10 @@ import com.casic.common.detector.gd.utils.SerialPortCommand import com.pengxh.kt.lite.utils.WeakReferenceHandler import java.io.IOException -import java.util.Timer abstract class SerialPortBaseActivity : AppCompatActivity(), Handler.Callback { private val kTag = "SerialPortBaseActivity" - private val taskTimer by lazy { Timer() } private val weakReferenceHandler by lazy { WeakReferenceHandler(this) } private val serialPorts by lazy { BaseApplication.get().getSerialPorts() } protected lateinit var binding: VB @@ -30,7 +28,6 @@ setContentView(binding.root) setupTopBarLayout() initOnCreate(savedInstanceState) - observeRequestState() initEvent() if (serialPorts.isNotEmpty()) { @@ -71,11 +68,6 @@ abstract fun initOnCreate(savedInstanceState: Bundle?) /** - * 数据请求状态监听 - */ - abstract fun observeRequestState() - - /** * 初始化业务逻辑 */ abstract fun initEvent() diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java new file mode 100644 index 0000000..7a18c20 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java @@ -0,0 +1,255 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 从平台下载的标识器本地库实体类 + */ +@Entity(tableName = "marker_detail") +public class MarkerBean { + @PrimaryKey(autoGenerate = true) + private long id; //主键ID + private String pipelineType; // 管线类型 + private String pipelineDiameter; // 管线直径 + private String pipelineMaterial; // 管材 + private String buryMethod; // 埋设方式 + private String buryDepth; // 埋深 + private String area; // 所属区域 + private String line; // 所属线路 + private String road; // 所属道路 + private String constructTime; // 建设年代 + private String owner; // 权属单位 + private String objectId; // 标识对象ID,无实际用途 + private String markerId; // 标识器ID + private String markerType; // 标识器类型 + private String markerDepth; // 标识器埋深 + private String installationDept; // 安装部门 + private String lng; // 经度 + private String lat; // 纬度 + private String updateTime; // 最后修改时间,更新时间 + private String remark; // 备注信息 + private String underlyingPipelineType; // 下层管线类型 + private String underlyingPipelineDepth; // 下层埋深 + private String underlyingPipelineDiameter; // 下层管径 + private String underlyingPipelineMaterial; // 下层管材 + private String objectType; //标识对象类型 + private String color; // 颜色 + private String imagePath; // 图片路径 + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getPipelineType() { + return pipelineType; + } + + public void setPipelineType(String pipelineType) { + this.pipelineType = pipelineType; + } + + public String getPipelineDiameter() { + return pipelineDiameter; + } + + public void setPipelineDiameter(String pipelineDiameter) { + this.pipelineDiameter = pipelineDiameter; + } + + public String getPipelineMaterial() { + return pipelineMaterial; + } + + public void setPipelineMaterial(String pipelineMaterial) { + this.pipelineMaterial = pipelineMaterial; + } + + public String getBuryMethod() { + return buryMethod; + } + + public void setBuryMethod(String buryMethod) { + this.buryMethod = buryMethod; + } + + public String getBuryDepth() { + return buryDepth; + } + + public void setBuryDepth(String buryDepth) { + this.buryDepth = buryDepth; + } + + public String getArea() { + return area; + } + + public void setArea(String area) { + this.area = area; + } + + public String getLine() { + return line; + } + + public void setLine(String line) { + this.line = line; + } + + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + + public String getConstructTime() { + return constructTime; + } + + public void setConstructTime(String constructTime) { + this.constructTime = constructTime; + } + + public String getOwner() { + return owner; + } + + public void setOwner(String owner) { + this.owner = owner; + } + + public String getObjectId() { + return objectId; + } + + public void setObjectId(String objectId) { + this.objectId = objectId; + } + + public String getMarkerId() { + return markerId; + } + + public void setMarkerId(String markerId) { + this.markerId = markerId; + } + + public String getMarkerType() { + return markerType; + } + + public void setMarkerType(String markerType) { + this.markerType = markerType; + } + + public String getMarkerDepth() { + return markerDepth; + } + + public void setMarkerDepth(String markerDepth) { + this.markerDepth = markerDepth; + } + + public String getInstallationDept() { + return installationDept; + } + + public void setInstallationDept(String installationDept) { + this.installationDept = installationDept; + } + + public String getLng() { + return lng; + } + + public void setLng(String lng) { + this.lng = lng; + } + + public String getLat() { + return lat; + } + + public void setLat(String lat) { + this.lat = lat; + } + + public String getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } + + public String getUnderlyingPipelineType() { + return underlyingPipelineType; + } + + public void setUnderlyingPipelineType(String underlyingPipelineType) { + this.underlyingPipelineType = underlyingPipelineType; + } + + public String getUnderlyingPipelineDepth() { + return underlyingPipelineDepth; + } + + public void setUnderlyingPipelineDepth(String underlyingPipelineDepth) { + this.underlyingPipelineDepth = underlyingPipelineDepth; + } + + public String getUnderlyingPipelineDiameter() { + return underlyingPipelineDiameter; + } + + public void setUnderlyingPipelineDiameter(String underlyingPipelineDiameter) { + this.underlyingPipelineDiameter = underlyingPipelineDiameter; + } + + public String getUnderlyingPipelineMaterial() { + return underlyingPipelineMaterial; + } + + public void setUnderlyingPipelineMaterial(String underlyingPipelineMaterial) { + this.underlyingPipelineMaterial = underlyingPipelineMaterial; + } + + public String getObjectType() { + return objectType; + } + + public void setObjectType(String objectType) { + this.objectType = objectType; + } + + public String getColor() { + return color; + } + + public void setColor(String color) { + this.color = color; + } + + public String getImagePath() { + return imagePath; + } + + public void setImagePath(String imagePath) { + this.imagePath = imagePath; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java deleted file mode 100644 index 3f2fcdc..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java +++ /dev/null @@ -1,327 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 从平台下载的标识器本地库实体类 - */ -@Entity -public class MarkerLocalBean { - @Id(autoincrement = true) - private Long id;//本地库主键ID - - // 管线类型 - private String pipelineType; - // 管线直径 - private String pipelineDiameter; - // 管材 - private String pipelineMaterial; - // 埋设方式 - private String buryMethod; - // 埋深 - private String buryDepth; - // 所属区域 - private String area; - // 所属线路 - private String line; - // 所属道路 - private String road; - // 建设年代 - private String constructTime; - // 权属单位 - private String owner; - //标识对象ID,无实际用途 - @Deprecated - private String objectId; - // 标识器ID - private String markerId; - // 标识器类型 - private String markerType; - // 标识器埋深 - private String markerDepth; - // 安装部门 - private String installationDept; - // 经度 - private String lng; - // 纬度 - private String lat; - //最后修改时间,更新时间 - private String updateTime; - // 备注信息 - private String remark; - // 下层管线类型 - private String underlyingPipelineType; - // 下层埋深 - private String underlyingPipelineDepth; - // 下层管径 - private String underlyingPipelineDiameter; - // 下层管材 - private String underlyingPipelineMaterial; - //标识对象类型 - private String objectType; - // 颜色 - private String color; - // 图片路径 - private String imagePath; - - @Generated(hash = 1479045776) - public MarkerLocalBean(Long id, String pipelineType, String pipelineDiameter, - String pipelineMaterial, String buryMethod, String buryDepth, - String area, String line, String road, String constructTime, - String owner, String objectId, String markerId, String markerType, - String markerDepth, String installationDept, String lng, String lat, - String updateTime, String remark, String underlyingPipelineType, - String underlyingPipelineDepth, String underlyingPipelineDiameter, - String underlyingPipelineMaterial, String objectType, String color, - String imagePath) { - this.id = id; - this.pipelineType = pipelineType; - this.pipelineDiameter = pipelineDiameter; - this.pipelineMaterial = pipelineMaterial; - this.buryMethod = buryMethod; - this.buryDepth = buryDepth; - this.area = area; - this.line = line; - this.road = road; - this.constructTime = constructTime; - this.owner = owner; - this.objectId = objectId; - this.markerId = markerId; - this.markerType = markerType; - this.markerDepth = markerDepth; - this.installationDept = installationDept; - this.lng = lng; - this.lat = lat; - this.updateTime = updateTime; - this.remark = remark; - this.underlyingPipelineType = underlyingPipelineType; - this.underlyingPipelineDepth = underlyingPipelineDepth; - this.underlyingPipelineDiameter = underlyingPipelineDiameter; - this.underlyingPipelineMaterial = underlyingPipelineMaterial; - this.objectType = objectType; - this.color = color; - this.imagePath = imagePath; - } - - @Generated(hash = 1538606012) - public MarkerLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getPipelineType() { - return this.pipelineType; - } - - public void setPipelineType(String pipelineType) { - this.pipelineType = pipelineType; - } - - public String getPipelineDiameter() { - return this.pipelineDiameter; - } - - public void setPipelineDiameter(String pipelineDiameter) { - this.pipelineDiameter = pipelineDiameter; - } - - public String getPipelineMaterial() { - return this.pipelineMaterial; - } - - public void setPipelineMaterial(String pipelineMaterial) { - this.pipelineMaterial = pipelineMaterial; - } - - public String getBuryMethod() { - return this.buryMethod; - } - - public void setBuryMethod(String buryMethod) { - this.buryMethod = buryMethod; - } - - public String getBuryDepth() { - return this.buryDepth; - } - - public void setBuryDepth(String buryDepth) { - this.buryDepth = buryDepth; - } - - public String getArea() { - return this.area; - } - - public void setArea(String area) { - this.area = area; - } - - public String getLine() { - return this.line; - } - - public void setLine(String line) { - this.line = line; - } - - public String getRoad() { - return this.road; - } - - public void setRoad(String road) { - this.road = road; - } - - public String getConstructTime() { - return this.constructTime; - } - - public void setConstructTime(String constructTime) { - this.constructTime = constructTime; - } - - public String getOwner() { - return this.owner; - } - - public void setOwner(String owner) { - this.owner = owner; - } - - public String getObjectId() { - return this.objectId; - } - - public void setObjectId(String objectId) { - this.objectId = objectId; - } - - public String getMarkerId() { - return this.markerId; - } - - public void setMarkerId(String markerId) { - this.markerId = markerId; - } - - public String getMarkerType() { - return this.markerType; - } - - public void setMarkerType(String markerType) { - this.markerType = markerType; - } - - public String getMarkerDepth() { - return this.markerDepth; - } - - public void setMarkerDepth(String markerDepth) { - this.markerDepth = markerDepth; - } - - public String getInstallationDept() { - return this.installationDept; - } - - public void setInstallationDept(String installationDept) { - this.installationDept = installationDept; - } - - public String getLng() { - return this.lng; - } - - public void setLng(String lng) { - this.lng = lng; - } - - public String getLat() { - return this.lat; - } - - public void setLat(String lat) { - this.lat = lat; - } - - public String getUpdateTime() { - return this.updateTime; - } - - public void setUpdateTime(String updateTime) { - this.updateTime = updateTime; - } - - public String getRemark() { - return this.remark; - } - - public void setRemark(String remark) { - this.remark = remark; - } - - public String getUnderlyingPipelineType() { - return this.underlyingPipelineType; - } - - public void setUnderlyingPipelineType(String underlyingPipelineType) { - this.underlyingPipelineType = underlyingPipelineType; - } - - public String getUnderlyingPipelineDepth() { - return this.underlyingPipelineDepth; - } - - public void setUnderlyingPipelineDepth(String underlyingPipelineDepth) { - this.underlyingPipelineDepth = underlyingPipelineDepth; - } - - public String getUnderlyingPipelineDiameter() { - return this.underlyingPipelineDiameter; - } - - public void setUnderlyingPipelineDiameter(String underlyingPipelineDiameter) { - this.underlyingPipelineDiameter = underlyingPipelineDiameter; - } - - public String getUnderlyingPipelineMaterial() { - return this.underlyingPipelineMaterial; - } - - public void setUnderlyingPipelineMaterial(String underlyingPipelineMaterial) { - this.underlyingPipelineMaterial = underlyingPipelineMaterial; - } - - public String getObjectType() { - return this.objectType; - } - - public void setObjectType(String objectType) { - this.objectType = objectType; - } - - public String getColor() { - return this.color; - } - - public void setColor(String color) { - this.color = color; - } - - public String getImagePath() { - return this.imagePath; - } - - public void setImagePath(String imagePath) { - this.imagePath = imagePath; - } -} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java new file mode 100644 index 0000000..5c88fdf --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java @@ -0,0 +1,93 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 巡检任务本地库实体类,不包含任务里面需要巡检的标识器信息 + */ +@Entity(tableName = "task_detail") +public class TaskBean { + @PrimaryKey(autoGenerate = true) + private long id;//主键ID + private String taskCode; // 任务编号 + private String description; // 任务名称 + private String createTime; // 任务创建的时间 + private String status; // 任务状态 + private String createUserName; // 任务创建者名称 + private String startTime; // 任务被开始执行的时间 + private String endTime; // 任务执行结束的时间 + private String isFree; // 是否自由巡检。1-是,0-否 + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getTaskCode() { + return taskCode; + } + + public void setTaskCode(String taskCode) { + this.taskCode = taskCode; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getCreateUserName() { + return createUserName; + } + + public void setCreateUserName(String createUserName) { + this.createUserName = createUserName; + } + + public String getStartTime() { + return startTime; + } + + public void setStartTime(String startTime) { + this.startTime = startTime; + } + + public String getEndTime() { + return endTime; + } + + public void setEndTime(String endTime) { + this.endTime = endTime; + } + + public String getIsFree() { + return isFree; + } + + public void setIsFree(String isFree) { + this.isFree = isFree; + } +} diff --git a/app/build.gradle b/app/build.gradle index d0cb423..921c8c8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,25 +1,20 @@ import java.text.SimpleDateFormat -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply plugin: 'org.greenrobot.greendao' +plugins { + id('com.android.application') + id('org.jetbrains.kotlin.android') +} android { - compileSdkVersion 33 + namespace 'com.casic.common.detector.gd' + compileSdk 35 defaultConfig { - applicationId "com.casic.common.detector.gd" - minSdkVersion 26 - targetSdkVersion 33 + applicationId 'com.casic.common.detector.gd' + minSdk 26 + targetSdk 35 versionCode 5092 - versionName "5.0.9.2" - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } + versionName '5.0.9.2' } signingConfigs { @@ -31,6 +26,14 @@ } } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + signingConfig signingConfigs.release + } + } + compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 @@ -47,27 +50,16 @@ } } - kotlin { - experimental { - coroutines 'enable' - } - } - buildFeatures { + buildConfig true viewBinding true } - applicationVariants.configureEach { variant -> - variant.outputs.configureEach { - outputFileName = "COM_TCY_" + getBuildDate() + "_" + defaultConfig.versionName + ".apk" + applicationVariants.configureEach { + outputs.configureEach { + outputFileName = 'COM_TCY_' + getBuildDate() + '_' + defaultConfig.versionName + '.apk' } } - - greendao { - schemaVersion 1//数据库版本号 - targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 - daoPackage "${defaultConfig.applicationId}.greendao"//设置DaoMaster、DaoSession、Dao包名 - } } static def getBuildDate() { @@ -76,27 +68,22 @@ } dependencies { - //基础依赖库 - implementation 'com.github.AndroidCoderPeng:Kotlin-lite-lib:1.1.4' - implementation 'androidx.core:core-ktx:1.9.0' - def base_version = "1.6.1" - implementation "androidx.appcompat:appcompat:${base_version}" - implementation "com.google.android.material:material:${base_version}" + implementation 'com.github.AndroidCoderPeng:Kotlin-lite-lib:1.1.5' + implementation 'androidx.core:core-ktx:1.13.1' + implementation 'androidx.appcompat:appcompat:1.7.0' + implementation 'com.google.android.material:material:1.12.0' //Google官方授权框架 implementation 'pub.devrel:easypermissions:3.0.0' - //沉浸式状态栏。基础依赖包,必须要依赖 - implementation 'com.gyf.immersionbar:immersionbar:3.0.0' - //fragment快速实现 - implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0' + //沉浸式状态栏 + implementation 'com.geyifeng.immersionbar:immersionbar:3.2.2' //官方Json解析库 implementation 'com.google.code.gson:gson:2.10.1' - def vm_version = '2.5.1' //Kotlin协程 - implementation "androidx.lifecycle:lifecycle-runtime-ktx:${vm_version}" + implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.2' //MVVM+LiveData - implementation "androidx.lifecycle:lifecycle-livedata-ktx:${vm_version}" - implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:${vm_version}" - implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.6.2' + implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2' + implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' //返回值转换器 implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' @@ -105,9 +92,10 @@ implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' //网络请求和接口封装 implementation 'com.squareup.retrofit2:retrofit:2.9.0' - implementation 'com.squareup.okhttp3:okhttp:4.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.12.0' //数据库框架 - implementation 'org.greenrobot:greendao:3.3.0' + implementation 'androidx.room:room-runtime:2.6.1' + annotationProcessor 'androidx.room:room-compiler:2.5.2' //高德导航、定位、地图三合一 implementation 'com.amap.api:navi-3dmap:latest.integration' //经纬度逆编码 @@ -115,7 +103,7 @@ //excel implementation 'net.sourceforge.jexcelapi:jxl:2.6.12' //图片加载框架 - implementation 'com.github.bumptech.glide:glide:4.9.0' + implementation 'com.github.bumptech.glide:glide:4.12.0' //图片选择框架 implementation 'io.github.lucksiege:pictureselector:v3.11.1' //大图 diff --git a/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt b/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt index 7b695ff..50ba734 100644 --- a/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt +++ b/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt @@ -4,9 +4,9 @@ import android.app.Application import android.os.Bundle import android.util.Log -import com.casic.common.detector.gd.greendao.DaoMaster -import com.casic.common.detector.gd.greendao.DaoSession +import androidx.room.Room.databaseBuilder import com.casic.common.detector.gd.uart.SerialPort +import com.casic.common.detector.gd.utils.DetectorDataBase import com.casic.common.detector.gd.utils.GpioManager import com.pengxh.kt.lite.extensions.show import com.pengxh.kt.lite.utils.SaveKeyValues @@ -43,44 +43,42 @@ private var application: BaseApplication by Delegates.notNull() fun get() = application - - private lateinit var daoSession: DaoSession } + lateinit var dataBase: DetectorDataBase + override fun onCreate() { super.onCreate() application = this SaveKeyValues.initSharedPreferences(this) CrashReport.initCrashReport(this, "01e80d3a74", true) - val devOpenHelper = DaoMaster.DevOpenHelper(this, "Detector.db", null) - val daoMaster = DaoMaster(devOpenHelper.writableDatabase) - daoSession = daoMaster.newSession() + dataBase = databaseBuilder(this, DetectorDataBase::class.java, "Detector.db") + .allowMainThreadQueries() + .build() /** * Open the serial port * */ try { serialPorts.apply { - add(SerialPort(File("/dev/ttysWK1"), 9600, 0)) - //千寻报文数据下发串口号 - add(SerialPort(File("/dev/ttyS1"), 9600, 0)) + add(SerialPort(File("/dev/ttysWK1"), 9600, 0)) //信号通讯串口 + add(SerialPort(File("/dev/ttyS1"), 9600, 0)) //千寻报文数据下发串口号 } Log.d(kTag, "onCreate: 已初始化 ${serialPorts.size} 个串口") } catch (e: SecurityException) { "您没有串口的读写权限!".show(this) + e.printStackTrace() } catch (e: IOException) { "因为不明原因,串口无法打开!".show(this) + e.printStackTrace() } catch (e: InvalidParameterException) { "请检查串口!".show(this) + e.printStackTrace() } registerActivityLifecycleCallbacks(this) } - fun getDaoSession(): DaoSession { - return daoSession - } - override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) { } diff --git a/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt b/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt index 053b9dd..1d0c9e3 100644 --- a/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt +++ b/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt @@ -14,12 +14,10 @@ import com.casic.common.detector.gd.utils.SerialPortCommand import com.pengxh.kt.lite.utils.WeakReferenceHandler import java.io.IOException -import java.util.Timer abstract class SerialPortBaseActivity : AppCompatActivity(), Handler.Callback { private val kTag = "SerialPortBaseActivity" - private val taskTimer by lazy { Timer() } private val weakReferenceHandler by lazy { WeakReferenceHandler(this) } private val serialPorts by lazy { BaseApplication.get().getSerialPorts() } protected lateinit var binding: VB @@ -30,7 +28,6 @@ setContentView(binding.root) setupTopBarLayout() initOnCreate(savedInstanceState) - observeRequestState() initEvent() if (serialPorts.isNotEmpty()) { @@ -71,11 +68,6 @@ abstract fun initOnCreate(savedInstanceState: Bundle?) /** - * 数据请求状态监听 - */ - abstract fun observeRequestState() - - /** * 初始化业务逻辑 */ abstract fun initEvent() diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java new file mode 100644 index 0000000..7a18c20 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java @@ -0,0 +1,255 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 从平台下载的标识器本地库实体类 + */ +@Entity(tableName = "marker_detail") +public class MarkerBean { + @PrimaryKey(autoGenerate = true) + private long id; //主键ID + private String pipelineType; // 管线类型 + private String pipelineDiameter; // 管线直径 + private String pipelineMaterial; // 管材 + private String buryMethod; // 埋设方式 + private String buryDepth; // 埋深 + private String area; // 所属区域 + private String line; // 所属线路 + private String road; // 所属道路 + private String constructTime; // 建设年代 + private String owner; // 权属单位 + private String objectId; // 标识对象ID,无实际用途 + private String markerId; // 标识器ID + private String markerType; // 标识器类型 + private String markerDepth; // 标识器埋深 + private String installationDept; // 安装部门 + private String lng; // 经度 + private String lat; // 纬度 + private String updateTime; // 最后修改时间,更新时间 + private String remark; // 备注信息 + private String underlyingPipelineType; // 下层管线类型 + private String underlyingPipelineDepth; // 下层埋深 + private String underlyingPipelineDiameter; // 下层管径 + private String underlyingPipelineMaterial; // 下层管材 + private String objectType; //标识对象类型 + private String color; // 颜色 + private String imagePath; // 图片路径 + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getPipelineType() { + return pipelineType; + } + + public void setPipelineType(String pipelineType) { + this.pipelineType = pipelineType; + } + + public String getPipelineDiameter() { + return pipelineDiameter; + } + + public void setPipelineDiameter(String pipelineDiameter) { + this.pipelineDiameter = pipelineDiameter; + } + + public String getPipelineMaterial() { + return pipelineMaterial; + } + + public void setPipelineMaterial(String pipelineMaterial) { + this.pipelineMaterial = pipelineMaterial; + } + + public String getBuryMethod() { + return buryMethod; + } + + public void setBuryMethod(String buryMethod) { + this.buryMethod = buryMethod; + } + + public String getBuryDepth() { + return buryDepth; + } + + public void setBuryDepth(String buryDepth) { + this.buryDepth = buryDepth; + } + + public String getArea() { + return area; + } + + public void setArea(String area) { + this.area = area; + } + + public String getLine() { + return line; + } + + public void setLine(String line) { + this.line = line; + } + + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + + public String getConstructTime() { + return constructTime; + } + + public void setConstructTime(String constructTime) { + this.constructTime = constructTime; + } + + public String getOwner() { + return owner; + } + + public void setOwner(String owner) { + this.owner = owner; + } + + public String getObjectId() { + return objectId; + } + + public void setObjectId(String objectId) { + this.objectId = objectId; + } + + public String getMarkerId() { + return markerId; + } + + public void setMarkerId(String markerId) { + this.markerId = markerId; + } + + public String getMarkerType() { + return markerType; + } + + public void setMarkerType(String markerType) { + this.markerType = markerType; + } + + public String getMarkerDepth() { + return markerDepth; + } + + public void setMarkerDepth(String markerDepth) { + this.markerDepth = markerDepth; + } + + public String getInstallationDept() { + return installationDept; + } + + public void setInstallationDept(String installationDept) { + this.installationDept = installationDept; + } + + public String getLng() { + return lng; + } + + public void setLng(String lng) { + this.lng = lng; + } + + public String getLat() { + return lat; + } + + public void setLat(String lat) { + this.lat = lat; + } + + public String getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } + + public String getUnderlyingPipelineType() { + return underlyingPipelineType; + } + + public void setUnderlyingPipelineType(String underlyingPipelineType) { + this.underlyingPipelineType = underlyingPipelineType; + } + + public String getUnderlyingPipelineDepth() { + return underlyingPipelineDepth; + } + + public void setUnderlyingPipelineDepth(String underlyingPipelineDepth) { + this.underlyingPipelineDepth = underlyingPipelineDepth; + } + + public String getUnderlyingPipelineDiameter() { + return underlyingPipelineDiameter; + } + + public void setUnderlyingPipelineDiameter(String underlyingPipelineDiameter) { + this.underlyingPipelineDiameter = underlyingPipelineDiameter; + } + + public String getUnderlyingPipelineMaterial() { + return underlyingPipelineMaterial; + } + + public void setUnderlyingPipelineMaterial(String underlyingPipelineMaterial) { + this.underlyingPipelineMaterial = underlyingPipelineMaterial; + } + + public String getObjectType() { + return objectType; + } + + public void setObjectType(String objectType) { + this.objectType = objectType; + } + + public String getColor() { + return color; + } + + public void setColor(String color) { + this.color = color; + } + + public String getImagePath() { + return imagePath; + } + + public void setImagePath(String imagePath) { + this.imagePath = imagePath; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java deleted file mode 100644 index 3f2fcdc..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java +++ /dev/null @@ -1,327 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 从平台下载的标识器本地库实体类 - */ -@Entity -public class MarkerLocalBean { - @Id(autoincrement = true) - private Long id;//本地库主键ID - - // 管线类型 - private String pipelineType; - // 管线直径 - private String pipelineDiameter; - // 管材 - private String pipelineMaterial; - // 埋设方式 - private String buryMethod; - // 埋深 - private String buryDepth; - // 所属区域 - private String area; - // 所属线路 - private String line; - // 所属道路 - private String road; - // 建设年代 - private String constructTime; - // 权属单位 - private String owner; - //标识对象ID,无实际用途 - @Deprecated - private String objectId; - // 标识器ID - private String markerId; - // 标识器类型 - private String markerType; - // 标识器埋深 - private String markerDepth; - // 安装部门 - private String installationDept; - // 经度 - private String lng; - // 纬度 - private String lat; - //最后修改时间,更新时间 - private String updateTime; - // 备注信息 - private String remark; - // 下层管线类型 - private String underlyingPipelineType; - // 下层埋深 - private String underlyingPipelineDepth; - // 下层管径 - private String underlyingPipelineDiameter; - // 下层管材 - private String underlyingPipelineMaterial; - //标识对象类型 - private String objectType; - // 颜色 - private String color; - // 图片路径 - private String imagePath; - - @Generated(hash = 1479045776) - public MarkerLocalBean(Long id, String pipelineType, String pipelineDiameter, - String pipelineMaterial, String buryMethod, String buryDepth, - String area, String line, String road, String constructTime, - String owner, String objectId, String markerId, String markerType, - String markerDepth, String installationDept, String lng, String lat, - String updateTime, String remark, String underlyingPipelineType, - String underlyingPipelineDepth, String underlyingPipelineDiameter, - String underlyingPipelineMaterial, String objectType, String color, - String imagePath) { - this.id = id; - this.pipelineType = pipelineType; - this.pipelineDiameter = pipelineDiameter; - this.pipelineMaterial = pipelineMaterial; - this.buryMethod = buryMethod; - this.buryDepth = buryDepth; - this.area = area; - this.line = line; - this.road = road; - this.constructTime = constructTime; - this.owner = owner; - this.objectId = objectId; - this.markerId = markerId; - this.markerType = markerType; - this.markerDepth = markerDepth; - this.installationDept = installationDept; - this.lng = lng; - this.lat = lat; - this.updateTime = updateTime; - this.remark = remark; - this.underlyingPipelineType = underlyingPipelineType; - this.underlyingPipelineDepth = underlyingPipelineDepth; - this.underlyingPipelineDiameter = underlyingPipelineDiameter; - this.underlyingPipelineMaterial = underlyingPipelineMaterial; - this.objectType = objectType; - this.color = color; - this.imagePath = imagePath; - } - - @Generated(hash = 1538606012) - public MarkerLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getPipelineType() { - return this.pipelineType; - } - - public void setPipelineType(String pipelineType) { - this.pipelineType = pipelineType; - } - - public String getPipelineDiameter() { - return this.pipelineDiameter; - } - - public void setPipelineDiameter(String pipelineDiameter) { - this.pipelineDiameter = pipelineDiameter; - } - - public String getPipelineMaterial() { - return this.pipelineMaterial; - } - - public void setPipelineMaterial(String pipelineMaterial) { - this.pipelineMaterial = pipelineMaterial; - } - - public String getBuryMethod() { - return this.buryMethod; - } - - public void setBuryMethod(String buryMethod) { - this.buryMethod = buryMethod; - } - - public String getBuryDepth() { - return this.buryDepth; - } - - public void setBuryDepth(String buryDepth) { - this.buryDepth = buryDepth; - } - - public String getArea() { - return this.area; - } - - public void setArea(String area) { - this.area = area; - } - - public String getLine() { - return this.line; - } - - public void setLine(String line) { - this.line = line; - } - - public String getRoad() { - return this.road; - } - - public void setRoad(String road) { - this.road = road; - } - - public String getConstructTime() { - return this.constructTime; - } - - public void setConstructTime(String constructTime) { - this.constructTime = constructTime; - } - - public String getOwner() { - return this.owner; - } - - public void setOwner(String owner) { - this.owner = owner; - } - - public String getObjectId() { - return this.objectId; - } - - public void setObjectId(String objectId) { - this.objectId = objectId; - } - - public String getMarkerId() { - return this.markerId; - } - - public void setMarkerId(String markerId) { - this.markerId = markerId; - } - - public String getMarkerType() { - return this.markerType; - } - - public void setMarkerType(String markerType) { - this.markerType = markerType; - } - - public String getMarkerDepth() { - return this.markerDepth; - } - - public void setMarkerDepth(String markerDepth) { - this.markerDepth = markerDepth; - } - - public String getInstallationDept() { - return this.installationDept; - } - - public void setInstallationDept(String installationDept) { - this.installationDept = installationDept; - } - - public String getLng() { - return this.lng; - } - - public void setLng(String lng) { - this.lng = lng; - } - - public String getLat() { - return this.lat; - } - - public void setLat(String lat) { - this.lat = lat; - } - - public String getUpdateTime() { - return this.updateTime; - } - - public void setUpdateTime(String updateTime) { - this.updateTime = updateTime; - } - - public String getRemark() { - return this.remark; - } - - public void setRemark(String remark) { - this.remark = remark; - } - - public String getUnderlyingPipelineType() { - return this.underlyingPipelineType; - } - - public void setUnderlyingPipelineType(String underlyingPipelineType) { - this.underlyingPipelineType = underlyingPipelineType; - } - - public String getUnderlyingPipelineDepth() { - return this.underlyingPipelineDepth; - } - - public void setUnderlyingPipelineDepth(String underlyingPipelineDepth) { - this.underlyingPipelineDepth = underlyingPipelineDepth; - } - - public String getUnderlyingPipelineDiameter() { - return this.underlyingPipelineDiameter; - } - - public void setUnderlyingPipelineDiameter(String underlyingPipelineDiameter) { - this.underlyingPipelineDiameter = underlyingPipelineDiameter; - } - - public String getUnderlyingPipelineMaterial() { - return this.underlyingPipelineMaterial; - } - - public void setUnderlyingPipelineMaterial(String underlyingPipelineMaterial) { - this.underlyingPipelineMaterial = underlyingPipelineMaterial; - } - - public String getObjectType() { - return this.objectType; - } - - public void setObjectType(String objectType) { - this.objectType = objectType; - } - - public String getColor() { - return this.color; - } - - public void setColor(String color) { - this.color = color; - } - - public String getImagePath() { - return this.imagePath; - } - - public void setImagePath(String imagePath) { - this.imagePath = imagePath; - } -} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java new file mode 100644 index 0000000..5c88fdf --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java @@ -0,0 +1,93 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 巡检任务本地库实体类,不包含任务里面需要巡检的标识器信息 + */ +@Entity(tableName = "task_detail") +public class TaskBean { + @PrimaryKey(autoGenerate = true) + private long id;//主键ID + private String taskCode; // 任务编号 + private String description; // 任务名称 + private String createTime; // 任务创建的时间 + private String status; // 任务状态 + private String createUserName; // 任务创建者名称 + private String startTime; // 任务被开始执行的时间 + private String endTime; // 任务执行结束的时间 + private String isFree; // 是否自由巡检。1-是,0-否 + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getTaskCode() { + return taskCode; + } + + public void setTaskCode(String taskCode) { + this.taskCode = taskCode; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getCreateUserName() { + return createUserName; + } + + public void setCreateUserName(String createUserName) { + this.createUserName = createUserName; + } + + public String getStartTime() { + return startTime; + } + + public void setStartTime(String startTime) { + this.startTime = startTime; + } + + public String getEndTime() { + return endTime; + } + + public void setEndTime(String endTime) { + this.endTime = endTime; + } + + public String getIsFree() { + return isFree; + } + + public void setIsFree(String isFree) { + this.isFree = isFree; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java deleted file mode 100644 index 91737b3..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java +++ /dev/null @@ -1,114 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 巡检任务本地库实体类,不包含任务里面需要巡检的标识器信息 - */ -@Entity -public class TaskLocalBean { - @Id - private Long id;//任务ID - - private String taskCode;//任务编号 - private String description;//任务名称 - private String createTime;//任务创建的时间 - private String status;//任务状态 - private String createUserName;//任务创建者名称 - private String startTime;//任务被开始执行的时间 - private String endTime;//任务执行结束的时间 - private String isFreeTask;//是否自由巡检。1-是,0-否 - - @Generated(hash = 1482022528) - public TaskLocalBean(Long id, String taskCode, String description, - String createTime, String status, String createUserName, - String startTime, String endTime, String isFreeTask) { - this.id = id; - this.taskCode = taskCode; - this.description = description; - this.createTime = createTime; - this.status = status; - this.createUserName = createUserName; - this.startTime = startTime; - this.endTime = endTime; - this.isFreeTask = isFreeTask; - } - - @Generated(hash = 949704588) - public TaskLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getTaskCode() { - return this.taskCode; - } - - public void setTaskCode(String taskCode) { - this.taskCode = taskCode; - } - - public String getDescription() { - return this.description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getCreateTime() { - return this.createTime; - } - - public void setCreateTime(String createTime) { - this.createTime = createTime; - } - - public String getStatus() { - return this.status; - } - - public void setStatus(String status) { - this.status = status; - } - - public String getCreateUserName() { - return this.createUserName; - } - - public void setCreateUserName(String createUserName) { - this.createUserName = createUserName; - } - - public String getStartTime() { - return this.startTime; - } - - public void setStartTime(String startTime) { - this.startTime = startTime; - } - - public String getEndTime() { - return this.endTime; - } - - public void setEndTime(String endTime) { - this.endTime = endTime; - } - - public String getIsFreeTask() { - return this.isFreeTask; - } - - public void setIsFreeTask(String isFreeTask) { - this.isFreeTask = isFreeTask; - } -} diff --git a/app/build.gradle b/app/build.gradle index d0cb423..921c8c8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,25 +1,20 @@ import java.text.SimpleDateFormat -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply plugin: 'org.greenrobot.greendao' +plugins { + id('com.android.application') + id('org.jetbrains.kotlin.android') +} android { - compileSdkVersion 33 + namespace 'com.casic.common.detector.gd' + compileSdk 35 defaultConfig { - applicationId "com.casic.common.detector.gd" - minSdkVersion 26 - targetSdkVersion 33 + applicationId 'com.casic.common.detector.gd' + minSdk 26 + targetSdk 35 versionCode 5092 - versionName "5.0.9.2" - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } + versionName '5.0.9.2' } signingConfigs { @@ -31,6 +26,14 @@ } } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + signingConfig signingConfigs.release + } + } + compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 @@ -47,27 +50,16 @@ } } - kotlin { - experimental { - coroutines 'enable' - } - } - buildFeatures { + buildConfig true viewBinding true } - applicationVariants.configureEach { variant -> - variant.outputs.configureEach { - outputFileName = "COM_TCY_" + getBuildDate() + "_" + defaultConfig.versionName + ".apk" + applicationVariants.configureEach { + outputs.configureEach { + outputFileName = 'COM_TCY_' + getBuildDate() + '_' + defaultConfig.versionName + '.apk' } } - - greendao { - schemaVersion 1//数据库版本号 - targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 - daoPackage "${defaultConfig.applicationId}.greendao"//设置DaoMaster、DaoSession、Dao包名 - } } static def getBuildDate() { @@ -76,27 +68,22 @@ } dependencies { - //基础依赖库 - implementation 'com.github.AndroidCoderPeng:Kotlin-lite-lib:1.1.4' - implementation 'androidx.core:core-ktx:1.9.0' - def base_version = "1.6.1" - implementation "androidx.appcompat:appcompat:${base_version}" - implementation "com.google.android.material:material:${base_version}" + implementation 'com.github.AndroidCoderPeng:Kotlin-lite-lib:1.1.5' + implementation 'androidx.core:core-ktx:1.13.1' + implementation 'androidx.appcompat:appcompat:1.7.0' + implementation 'com.google.android.material:material:1.12.0' //Google官方授权框架 implementation 'pub.devrel:easypermissions:3.0.0' - //沉浸式状态栏。基础依赖包,必须要依赖 - implementation 'com.gyf.immersionbar:immersionbar:3.0.0' - //fragment快速实现 - implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0' + //沉浸式状态栏 + implementation 'com.geyifeng.immersionbar:immersionbar:3.2.2' //官方Json解析库 implementation 'com.google.code.gson:gson:2.10.1' - def vm_version = '2.5.1' //Kotlin协程 - implementation "androidx.lifecycle:lifecycle-runtime-ktx:${vm_version}" + implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.2' //MVVM+LiveData - implementation "androidx.lifecycle:lifecycle-livedata-ktx:${vm_version}" - implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:${vm_version}" - implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.6.2' + implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2' + implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' //返回值转换器 implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' @@ -105,9 +92,10 @@ implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' //网络请求和接口封装 implementation 'com.squareup.retrofit2:retrofit:2.9.0' - implementation 'com.squareup.okhttp3:okhttp:4.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.12.0' //数据库框架 - implementation 'org.greenrobot:greendao:3.3.0' + implementation 'androidx.room:room-runtime:2.6.1' + annotationProcessor 'androidx.room:room-compiler:2.5.2' //高德导航、定位、地图三合一 implementation 'com.amap.api:navi-3dmap:latest.integration' //经纬度逆编码 @@ -115,7 +103,7 @@ //excel implementation 'net.sourceforge.jexcelapi:jxl:2.6.12' //图片加载框架 - implementation 'com.github.bumptech.glide:glide:4.9.0' + implementation 'com.github.bumptech.glide:glide:4.12.0' //图片选择框架 implementation 'io.github.lucksiege:pictureselector:v3.11.1' //大图 diff --git a/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt b/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt index 7b695ff..50ba734 100644 --- a/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt +++ b/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt @@ -4,9 +4,9 @@ import android.app.Application import android.os.Bundle import android.util.Log -import com.casic.common.detector.gd.greendao.DaoMaster -import com.casic.common.detector.gd.greendao.DaoSession +import androidx.room.Room.databaseBuilder import com.casic.common.detector.gd.uart.SerialPort +import com.casic.common.detector.gd.utils.DetectorDataBase import com.casic.common.detector.gd.utils.GpioManager import com.pengxh.kt.lite.extensions.show import com.pengxh.kt.lite.utils.SaveKeyValues @@ -43,44 +43,42 @@ private var application: BaseApplication by Delegates.notNull() fun get() = application - - private lateinit var daoSession: DaoSession } + lateinit var dataBase: DetectorDataBase + override fun onCreate() { super.onCreate() application = this SaveKeyValues.initSharedPreferences(this) CrashReport.initCrashReport(this, "01e80d3a74", true) - val devOpenHelper = DaoMaster.DevOpenHelper(this, "Detector.db", null) - val daoMaster = DaoMaster(devOpenHelper.writableDatabase) - daoSession = daoMaster.newSession() + dataBase = databaseBuilder(this, DetectorDataBase::class.java, "Detector.db") + .allowMainThreadQueries() + .build() /** * Open the serial port * */ try { serialPorts.apply { - add(SerialPort(File("/dev/ttysWK1"), 9600, 0)) - //千寻报文数据下发串口号 - add(SerialPort(File("/dev/ttyS1"), 9600, 0)) + add(SerialPort(File("/dev/ttysWK1"), 9600, 0)) //信号通讯串口 + add(SerialPort(File("/dev/ttyS1"), 9600, 0)) //千寻报文数据下发串口号 } Log.d(kTag, "onCreate: 已初始化 ${serialPorts.size} 个串口") } catch (e: SecurityException) { "您没有串口的读写权限!".show(this) + e.printStackTrace() } catch (e: IOException) { "因为不明原因,串口无法打开!".show(this) + e.printStackTrace() } catch (e: InvalidParameterException) { "请检查串口!".show(this) + e.printStackTrace() } registerActivityLifecycleCallbacks(this) } - fun getDaoSession(): DaoSession { - return daoSession - } - override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) { } diff --git a/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt b/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt index 053b9dd..1d0c9e3 100644 --- a/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt +++ b/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt @@ -14,12 +14,10 @@ import com.casic.common.detector.gd.utils.SerialPortCommand import com.pengxh.kt.lite.utils.WeakReferenceHandler import java.io.IOException -import java.util.Timer abstract class SerialPortBaseActivity : AppCompatActivity(), Handler.Callback { private val kTag = "SerialPortBaseActivity" - private val taskTimer by lazy { Timer() } private val weakReferenceHandler by lazy { WeakReferenceHandler(this) } private val serialPorts by lazy { BaseApplication.get().getSerialPorts() } protected lateinit var binding: VB @@ -30,7 +28,6 @@ setContentView(binding.root) setupTopBarLayout() initOnCreate(savedInstanceState) - observeRequestState() initEvent() if (serialPorts.isNotEmpty()) { @@ -71,11 +68,6 @@ abstract fun initOnCreate(savedInstanceState: Bundle?) /** - * 数据请求状态监听 - */ - abstract fun observeRequestState() - - /** * 初始化业务逻辑 */ abstract fun initEvent() diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java new file mode 100644 index 0000000..7a18c20 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java @@ -0,0 +1,255 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 从平台下载的标识器本地库实体类 + */ +@Entity(tableName = "marker_detail") +public class MarkerBean { + @PrimaryKey(autoGenerate = true) + private long id; //主键ID + private String pipelineType; // 管线类型 + private String pipelineDiameter; // 管线直径 + private String pipelineMaterial; // 管材 + private String buryMethod; // 埋设方式 + private String buryDepth; // 埋深 + private String area; // 所属区域 + private String line; // 所属线路 + private String road; // 所属道路 + private String constructTime; // 建设年代 + private String owner; // 权属单位 + private String objectId; // 标识对象ID,无实际用途 + private String markerId; // 标识器ID + private String markerType; // 标识器类型 + private String markerDepth; // 标识器埋深 + private String installationDept; // 安装部门 + private String lng; // 经度 + private String lat; // 纬度 + private String updateTime; // 最后修改时间,更新时间 + private String remark; // 备注信息 + private String underlyingPipelineType; // 下层管线类型 + private String underlyingPipelineDepth; // 下层埋深 + private String underlyingPipelineDiameter; // 下层管径 + private String underlyingPipelineMaterial; // 下层管材 + private String objectType; //标识对象类型 + private String color; // 颜色 + private String imagePath; // 图片路径 + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getPipelineType() { + return pipelineType; + } + + public void setPipelineType(String pipelineType) { + this.pipelineType = pipelineType; + } + + public String getPipelineDiameter() { + return pipelineDiameter; + } + + public void setPipelineDiameter(String pipelineDiameter) { + this.pipelineDiameter = pipelineDiameter; + } + + public String getPipelineMaterial() { + return pipelineMaterial; + } + + public void setPipelineMaterial(String pipelineMaterial) { + this.pipelineMaterial = pipelineMaterial; + } + + public String getBuryMethod() { + return buryMethod; + } + + public void setBuryMethod(String buryMethod) { + this.buryMethod = buryMethod; + } + + public String getBuryDepth() { + return buryDepth; + } + + public void setBuryDepth(String buryDepth) { + this.buryDepth = buryDepth; + } + + public String getArea() { + return area; + } + + public void setArea(String area) { + this.area = area; + } + + public String getLine() { + return line; + } + + public void setLine(String line) { + this.line = line; + } + + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + + public String getConstructTime() { + return constructTime; + } + + public void setConstructTime(String constructTime) { + this.constructTime = constructTime; + } + + public String getOwner() { + return owner; + } + + public void setOwner(String owner) { + this.owner = owner; + } + + public String getObjectId() { + return objectId; + } + + public void setObjectId(String objectId) { + this.objectId = objectId; + } + + public String getMarkerId() { + return markerId; + } + + public void setMarkerId(String markerId) { + this.markerId = markerId; + } + + public String getMarkerType() { + return markerType; + } + + public void setMarkerType(String markerType) { + this.markerType = markerType; + } + + public String getMarkerDepth() { + return markerDepth; + } + + public void setMarkerDepth(String markerDepth) { + this.markerDepth = markerDepth; + } + + public String getInstallationDept() { + return installationDept; + } + + public void setInstallationDept(String installationDept) { + this.installationDept = installationDept; + } + + public String getLng() { + return lng; + } + + public void setLng(String lng) { + this.lng = lng; + } + + public String getLat() { + return lat; + } + + public void setLat(String lat) { + this.lat = lat; + } + + public String getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } + + public String getUnderlyingPipelineType() { + return underlyingPipelineType; + } + + public void setUnderlyingPipelineType(String underlyingPipelineType) { + this.underlyingPipelineType = underlyingPipelineType; + } + + public String getUnderlyingPipelineDepth() { + return underlyingPipelineDepth; + } + + public void setUnderlyingPipelineDepth(String underlyingPipelineDepth) { + this.underlyingPipelineDepth = underlyingPipelineDepth; + } + + public String getUnderlyingPipelineDiameter() { + return underlyingPipelineDiameter; + } + + public void setUnderlyingPipelineDiameter(String underlyingPipelineDiameter) { + this.underlyingPipelineDiameter = underlyingPipelineDiameter; + } + + public String getUnderlyingPipelineMaterial() { + return underlyingPipelineMaterial; + } + + public void setUnderlyingPipelineMaterial(String underlyingPipelineMaterial) { + this.underlyingPipelineMaterial = underlyingPipelineMaterial; + } + + public String getObjectType() { + return objectType; + } + + public void setObjectType(String objectType) { + this.objectType = objectType; + } + + public String getColor() { + return color; + } + + public void setColor(String color) { + this.color = color; + } + + public String getImagePath() { + return imagePath; + } + + public void setImagePath(String imagePath) { + this.imagePath = imagePath; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java deleted file mode 100644 index 3f2fcdc..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java +++ /dev/null @@ -1,327 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 从平台下载的标识器本地库实体类 - */ -@Entity -public class MarkerLocalBean { - @Id(autoincrement = true) - private Long id;//本地库主键ID - - // 管线类型 - private String pipelineType; - // 管线直径 - private String pipelineDiameter; - // 管材 - private String pipelineMaterial; - // 埋设方式 - private String buryMethod; - // 埋深 - private String buryDepth; - // 所属区域 - private String area; - // 所属线路 - private String line; - // 所属道路 - private String road; - // 建设年代 - private String constructTime; - // 权属单位 - private String owner; - //标识对象ID,无实际用途 - @Deprecated - private String objectId; - // 标识器ID - private String markerId; - // 标识器类型 - private String markerType; - // 标识器埋深 - private String markerDepth; - // 安装部门 - private String installationDept; - // 经度 - private String lng; - // 纬度 - private String lat; - //最后修改时间,更新时间 - private String updateTime; - // 备注信息 - private String remark; - // 下层管线类型 - private String underlyingPipelineType; - // 下层埋深 - private String underlyingPipelineDepth; - // 下层管径 - private String underlyingPipelineDiameter; - // 下层管材 - private String underlyingPipelineMaterial; - //标识对象类型 - private String objectType; - // 颜色 - private String color; - // 图片路径 - private String imagePath; - - @Generated(hash = 1479045776) - public MarkerLocalBean(Long id, String pipelineType, String pipelineDiameter, - String pipelineMaterial, String buryMethod, String buryDepth, - String area, String line, String road, String constructTime, - String owner, String objectId, String markerId, String markerType, - String markerDepth, String installationDept, String lng, String lat, - String updateTime, String remark, String underlyingPipelineType, - String underlyingPipelineDepth, String underlyingPipelineDiameter, - String underlyingPipelineMaterial, String objectType, String color, - String imagePath) { - this.id = id; - this.pipelineType = pipelineType; - this.pipelineDiameter = pipelineDiameter; - this.pipelineMaterial = pipelineMaterial; - this.buryMethod = buryMethod; - this.buryDepth = buryDepth; - this.area = area; - this.line = line; - this.road = road; - this.constructTime = constructTime; - this.owner = owner; - this.objectId = objectId; - this.markerId = markerId; - this.markerType = markerType; - this.markerDepth = markerDepth; - this.installationDept = installationDept; - this.lng = lng; - this.lat = lat; - this.updateTime = updateTime; - this.remark = remark; - this.underlyingPipelineType = underlyingPipelineType; - this.underlyingPipelineDepth = underlyingPipelineDepth; - this.underlyingPipelineDiameter = underlyingPipelineDiameter; - this.underlyingPipelineMaterial = underlyingPipelineMaterial; - this.objectType = objectType; - this.color = color; - this.imagePath = imagePath; - } - - @Generated(hash = 1538606012) - public MarkerLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getPipelineType() { - return this.pipelineType; - } - - public void setPipelineType(String pipelineType) { - this.pipelineType = pipelineType; - } - - public String getPipelineDiameter() { - return this.pipelineDiameter; - } - - public void setPipelineDiameter(String pipelineDiameter) { - this.pipelineDiameter = pipelineDiameter; - } - - public String getPipelineMaterial() { - return this.pipelineMaterial; - } - - public void setPipelineMaterial(String pipelineMaterial) { - this.pipelineMaterial = pipelineMaterial; - } - - public String getBuryMethod() { - return this.buryMethod; - } - - public void setBuryMethod(String buryMethod) { - this.buryMethod = buryMethod; - } - - public String getBuryDepth() { - return this.buryDepth; - } - - public void setBuryDepth(String buryDepth) { - this.buryDepth = buryDepth; - } - - public String getArea() { - return this.area; - } - - public void setArea(String area) { - this.area = area; - } - - public String getLine() { - return this.line; - } - - public void setLine(String line) { - this.line = line; - } - - public String getRoad() { - return this.road; - } - - public void setRoad(String road) { - this.road = road; - } - - public String getConstructTime() { - return this.constructTime; - } - - public void setConstructTime(String constructTime) { - this.constructTime = constructTime; - } - - public String getOwner() { - return this.owner; - } - - public void setOwner(String owner) { - this.owner = owner; - } - - public String getObjectId() { - return this.objectId; - } - - public void setObjectId(String objectId) { - this.objectId = objectId; - } - - public String getMarkerId() { - return this.markerId; - } - - public void setMarkerId(String markerId) { - this.markerId = markerId; - } - - public String getMarkerType() { - return this.markerType; - } - - public void setMarkerType(String markerType) { - this.markerType = markerType; - } - - public String getMarkerDepth() { - return this.markerDepth; - } - - public void setMarkerDepth(String markerDepth) { - this.markerDepth = markerDepth; - } - - public String getInstallationDept() { - return this.installationDept; - } - - public void setInstallationDept(String installationDept) { - this.installationDept = installationDept; - } - - public String getLng() { - return this.lng; - } - - public void setLng(String lng) { - this.lng = lng; - } - - public String getLat() { - return this.lat; - } - - public void setLat(String lat) { - this.lat = lat; - } - - public String getUpdateTime() { - return this.updateTime; - } - - public void setUpdateTime(String updateTime) { - this.updateTime = updateTime; - } - - public String getRemark() { - return this.remark; - } - - public void setRemark(String remark) { - this.remark = remark; - } - - public String getUnderlyingPipelineType() { - return this.underlyingPipelineType; - } - - public void setUnderlyingPipelineType(String underlyingPipelineType) { - this.underlyingPipelineType = underlyingPipelineType; - } - - public String getUnderlyingPipelineDepth() { - return this.underlyingPipelineDepth; - } - - public void setUnderlyingPipelineDepth(String underlyingPipelineDepth) { - this.underlyingPipelineDepth = underlyingPipelineDepth; - } - - public String getUnderlyingPipelineDiameter() { - return this.underlyingPipelineDiameter; - } - - public void setUnderlyingPipelineDiameter(String underlyingPipelineDiameter) { - this.underlyingPipelineDiameter = underlyingPipelineDiameter; - } - - public String getUnderlyingPipelineMaterial() { - return this.underlyingPipelineMaterial; - } - - public void setUnderlyingPipelineMaterial(String underlyingPipelineMaterial) { - this.underlyingPipelineMaterial = underlyingPipelineMaterial; - } - - public String getObjectType() { - return this.objectType; - } - - public void setObjectType(String objectType) { - this.objectType = objectType; - } - - public String getColor() { - return this.color; - } - - public void setColor(String color) { - this.color = color; - } - - public String getImagePath() { - return this.imagePath; - } - - public void setImagePath(String imagePath) { - this.imagePath = imagePath; - } -} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java new file mode 100644 index 0000000..5c88fdf --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java @@ -0,0 +1,93 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 巡检任务本地库实体类,不包含任务里面需要巡检的标识器信息 + */ +@Entity(tableName = "task_detail") +public class TaskBean { + @PrimaryKey(autoGenerate = true) + private long id;//主键ID + private String taskCode; // 任务编号 + private String description; // 任务名称 + private String createTime; // 任务创建的时间 + private String status; // 任务状态 + private String createUserName; // 任务创建者名称 + private String startTime; // 任务被开始执行的时间 + private String endTime; // 任务执行结束的时间 + private String isFree; // 是否自由巡检。1-是,0-否 + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getTaskCode() { + return taskCode; + } + + public void setTaskCode(String taskCode) { + this.taskCode = taskCode; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getCreateUserName() { + return createUserName; + } + + public void setCreateUserName(String createUserName) { + this.createUserName = createUserName; + } + + public String getStartTime() { + return startTime; + } + + public void setStartTime(String startTime) { + this.startTime = startTime; + } + + public String getEndTime() { + return endTime; + } + + public void setEndTime(String endTime) { + this.endTime = endTime; + } + + public String getIsFree() { + return isFree; + } + + public void setIsFree(String isFree) { + this.isFree = isFree; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java deleted file mode 100644 index 91737b3..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java +++ /dev/null @@ -1,114 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 巡检任务本地库实体类,不包含任务里面需要巡检的标识器信息 - */ -@Entity -public class TaskLocalBean { - @Id - private Long id;//任务ID - - private String taskCode;//任务编号 - private String description;//任务名称 - private String createTime;//任务创建的时间 - private String status;//任务状态 - private String createUserName;//任务创建者名称 - private String startTime;//任务被开始执行的时间 - private String endTime;//任务执行结束的时间 - private String isFreeTask;//是否自由巡检。1-是,0-否 - - @Generated(hash = 1482022528) - public TaskLocalBean(Long id, String taskCode, String description, - String createTime, String status, String createUserName, - String startTime, String endTime, String isFreeTask) { - this.id = id; - this.taskCode = taskCode; - this.description = description; - this.createTime = createTime; - this.status = status; - this.createUserName = createUserName; - this.startTime = startTime; - this.endTime = endTime; - this.isFreeTask = isFreeTask; - } - - @Generated(hash = 949704588) - public TaskLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getTaskCode() { - return this.taskCode; - } - - public void setTaskCode(String taskCode) { - this.taskCode = taskCode; - } - - public String getDescription() { - return this.description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getCreateTime() { - return this.createTime; - } - - public void setCreateTime(String createTime) { - this.createTime = createTime; - } - - public String getStatus() { - return this.status; - } - - public void setStatus(String status) { - this.status = status; - } - - public String getCreateUserName() { - return this.createUserName; - } - - public void setCreateUserName(String createUserName) { - this.createUserName = createUserName; - } - - public String getStartTime() { - return this.startTime; - } - - public void setStartTime(String startTime) { - this.startTime = startTime; - } - - public String getEndTime() { - return this.endTime; - } - - public void setEndTime(String endTime) { - this.endTime = endTime; - } - - public String getIsFreeTask() { - return this.isFreeTask; - } - - public void setIsFreeTask(String isFreeTask) { - this.isFreeTask = isFreeTask; - } -} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerBean.java new file mode 100644 index 0000000..c563a60 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerBean.java @@ -0,0 +1,110 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 巡检任务里面需要巡检的标识器信息本地库实体类 + */ +@Entity(tableName = "task_marker_info") +public class TaskMarkerBean { + //标识器后台库的主键ID,不是标识器实际ID + @PrimaryKey(autoGenerate = true) + private long id; + + /** + * 任务ID,通过此字段关联[TaskBean.id] + */ + private String taskId; + + /** + * 任务Code,通过此字段关联[TaskBean.taskCode] + *

+ *

+ * 双重验证,防止出现同时刻重复的情况 + */ + private String taskCode; + + /** + * 对应后台字段[TaskModel.MessageModel.TaskDetailInfosModel.markerIdReal],也就是探测仪扫描出来的ID + */ + private String markerId; + + private Double lng; + private Double lat; + + /** + * 是否已被探测到 + * 1-是,0-否 + */ + private String isDetected; + + /** + * 被探测到的时间,对应后台字段[TaskModel.MessageModel.TaskDetailInfosModel.finishTime] + */ + private String detectedTime; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getTaskId() { + return taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getTaskCode() { + return taskCode; + } + + public void setTaskCode(String taskCode) { + this.taskCode = taskCode; + } + + public String getMarkerId() { + return markerId; + } + + public void setMarkerId(String markerId) { + this.markerId = markerId; + } + + public Double getLng() { + return lng; + } + + public void setLng(Double lng) { + this.lng = lng; + } + + public Double getLat() { + return lat; + } + + public void setLat(Double lat) { + this.lat = lat; + } + + public String getIsDetected() { + return isDetected; + } + + public void setIsDetected(String isDetected) { + this.isDetected = isDetected; + } + + public String getDetectedTime() { + return detectedTime; + } + + public void setDetectedTime(String detectedTime) { + this.detectedTime = detectedTime; + } +} diff --git a/app/build.gradle b/app/build.gradle index d0cb423..921c8c8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,25 +1,20 @@ import java.text.SimpleDateFormat -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply plugin: 'org.greenrobot.greendao' +plugins { + id('com.android.application') + id('org.jetbrains.kotlin.android') +} android { - compileSdkVersion 33 + namespace 'com.casic.common.detector.gd' + compileSdk 35 defaultConfig { - applicationId "com.casic.common.detector.gd" - minSdkVersion 26 - targetSdkVersion 33 + applicationId 'com.casic.common.detector.gd' + minSdk 26 + targetSdk 35 versionCode 5092 - versionName "5.0.9.2" - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } + versionName '5.0.9.2' } signingConfigs { @@ -31,6 +26,14 @@ } } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + signingConfig signingConfigs.release + } + } + compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 @@ -47,27 +50,16 @@ } } - kotlin { - experimental { - coroutines 'enable' - } - } - buildFeatures { + buildConfig true viewBinding true } - applicationVariants.configureEach { variant -> - variant.outputs.configureEach { - outputFileName = "COM_TCY_" + getBuildDate() + "_" + defaultConfig.versionName + ".apk" + applicationVariants.configureEach { + outputs.configureEach { + outputFileName = 'COM_TCY_' + getBuildDate() + '_' + defaultConfig.versionName + '.apk' } } - - greendao { - schemaVersion 1//数据库版本号 - targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 - daoPackage "${defaultConfig.applicationId}.greendao"//设置DaoMaster、DaoSession、Dao包名 - } } static def getBuildDate() { @@ -76,27 +68,22 @@ } dependencies { - //基础依赖库 - implementation 'com.github.AndroidCoderPeng:Kotlin-lite-lib:1.1.4' - implementation 'androidx.core:core-ktx:1.9.0' - def base_version = "1.6.1" - implementation "androidx.appcompat:appcompat:${base_version}" - implementation "com.google.android.material:material:${base_version}" + implementation 'com.github.AndroidCoderPeng:Kotlin-lite-lib:1.1.5' + implementation 'androidx.core:core-ktx:1.13.1' + implementation 'androidx.appcompat:appcompat:1.7.0' + implementation 'com.google.android.material:material:1.12.0' //Google官方授权框架 implementation 'pub.devrel:easypermissions:3.0.0' - //沉浸式状态栏。基础依赖包,必须要依赖 - implementation 'com.gyf.immersionbar:immersionbar:3.0.0' - //fragment快速实现 - implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0' + //沉浸式状态栏 + implementation 'com.geyifeng.immersionbar:immersionbar:3.2.2' //官方Json解析库 implementation 'com.google.code.gson:gson:2.10.1' - def vm_version = '2.5.1' //Kotlin协程 - implementation "androidx.lifecycle:lifecycle-runtime-ktx:${vm_version}" + implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.2' //MVVM+LiveData - implementation "androidx.lifecycle:lifecycle-livedata-ktx:${vm_version}" - implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:${vm_version}" - implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.6.2' + implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2' + implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' //返回值转换器 implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' @@ -105,9 +92,10 @@ implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' //网络请求和接口封装 implementation 'com.squareup.retrofit2:retrofit:2.9.0' - implementation 'com.squareup.okhttp3:okhttp:4.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.12.0' //数据库框架 - implementation 'org.greenrobot:greendao:3.3.0' + implementation 'androidx.room:room-runtime:2.6.1' + annotationProcessor 'androidx.room:room-compiler:2.5.2' //高德导航、定位、地图三合一 implementation 'com.amap.api:navi-3dmap:latest.integration' //经纬度逆编码 @@ -115,7 +103,7 @@ //excel implementation 'net.sourceforge.jexcelapi:jxl:2.6.12' //图片加载框架 - implementation 'com.github.bumptech.glide:glide:4.9.0' + implementation 'com.github.bumptech.glide:glide:4.12.0' //图片选择框架 implementation 'io.github.lucksiege:pictureselector:v3.11.1' //大图 diff --git a/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt b/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt index 7b695ff..50ba734 100644 --- a/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt +++ b/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt @@ -4,9 +4,9 @@ import android.app.Application import android.os.Bundle import android.util.Log -import com.casic.common.detector.gd.greendao.DaoMaster -import com.casic.common.detector.gd.greendao.DaoSession +import androidx.room.Room.databaseBuilder import com.casic.common.detector.gd.uart.SerialPort +import com.casic.common.detector.gd.utils.DetectorDataBase import com.casic.common.detector.gd.utils.GpioManager import com.pengxh.kt.lite.extensions.show import com.pengxh.kt.lite.utils.SaveKeyValues @@ -43,44 +43,42 @@ private var application: BaseApplication by Delegates.notNull() fun get() = application - - private lateinit var daoSession: DaoSession } + lateinit var dataBase: DetectorDataBase + override fun onCreate() { super.onCreate() application = this SaveKeyValues.initSharedPreferences(this) CrashReport.initCrashReport(this, "01e80d3a74", true) - val devOpenHelper = DaoMaster.DevOpenHelper(this, "Detector.db", null) - val daoMaster = DaoMaster(devOpenHelper.writableDatabase) - daoSession = daoMaster.newSession() + dataBase = databaseBuilder(this, DetectorDataBase::class.java, "Detector.db") + .allowMainThreadQueries() + .build() /** * Open the serial port * */ try { serialPorts.apply { - add(SerialPort(File("/dev/ttysWK1"), 9600, 0)) - //千寻报文数据下发串口号 - add(SerialPort(File("/dev/ttyS1"), 9600, 0)) + add(SerialPort(File("/dev/ttysWK1"), 9600, 0)) //信号通讯串口 + add(SerialPort(File("/dev/ttyS1"), 9600, 0)) //千寻报文数据下发串口号 } Log.d(kTag, "onCreate: 已初始化 ${serialPorts.size} 个串口") } catch (e: SecurityException) { "您没有串口的读写权限!".show(this) + e.printStackTrace() } catch (e: IOException) { "因为不明原因,串口无法打开!".show(this) + e.printStackTrace() } catch (e: InvalidParameterException) { "请检查串口!".show(this) + e.printStackTrace() } registerActivityLifecycleCallbacks(this) } - fun getDaoSession(): DaoSession { - return daoSession - } - override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) { } diff --git a/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt b/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt index 053b9dd..1d0c9e3 100644 --- a/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt +++ b/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt @@ -14,12 +14,10 @@ import com.casic.common.detector.gd.utils.SerialPortCommand import com.pengxh.kt.lite.utils.WeakReferenceHandler import java.io.IOException -import java.util.Timer abstract class SerialPortBaseActivity : AppCompatActivity(), Handler.Callback { private val kTag = "SerialPortBaseActivity" - private val taskTimer by lazy { Timer() } private val weakReferenceHandler by lazy { WeakReferenceHandler(this) } private val serialPorts by lazy { BaseApplication.get().getSerialPorts() } protected lateinit var binding: VB @@ -30,7 +28,6 @@ setContentView(binding.root) setupTopBarLayout() initOnCreate(savedInstanceState) - observeRequestState() initEvent() if (serialPorts.isNotEmpty()) { @@ -71,11 +68,6 @@ abstract fun initOnCreate(savedInstanceState: Bundle?) /** - * 数据请求状态监听 - */ - abstract fun observeRequestState() - - /** * 初始化业务逻辑 */ abstract fun initEvent() diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java new file mode 100644 index 0000000..7a18c20 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java @@ -0,0 +1,255 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 从平台下载的标识器本地库实体类 + */ +@Entity(tableName = "marker_detail") +public class MarkerBean { + @PrimaryKey(autoGenerate = true) + private long id; //主键ID + private String pipelineType; // 管线类型 + private String pipelineDiameter; // 管线直径 + private String pipelineMaterial; // 管材 + private String buryMethod; // 埋设方式 + private String buryDepth; // 埋深 + private String area; // 所属区域 + private String line; // 所属线路 + private String road; // 所属道路 + private String constructTime; // 建设年代 + private String owner; // 权属单位 + private String objectId; // 标识对象ID,无实际用途 + private String markerId; // 标识器ID + private String markerType; // 标识器类型 + private String markerDepth; // 标识器埋深 + private String installationDept; // 安装部门 + private String lng; // 经度 + private String lat; // 纬度 + private String updateTime; // 最后修改时间,更新时间 + private String remark; // 备注信息 + private String underlyingPipelineType; // 下层管线类型 + private String underlyingPipelineDepth; // 下层埋深 + private String underlyingPipelineDiameter; // 下层管径 + private String underlyingPipelineMaterial; // 下层管材 + private String objectType; //标识对象类型 + private String color; // 颜色 + private String imagePath; // 图片路径 + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getPipelineType() { + return pipelineType; + } + + public void setPipelineType(String pipelineType) { + this.pipelineType = pipelineType; + } + + public String getPipelineDiameter() { + return pipelineDiameter; + } + + public void setPipelineDiameter(String pipelineDiameter) { + this.pipelineDiameter = pipelineDiameter; + } + + public String getPipelineMaterial() { + return pipelineMaterial; + } + + public void setPipelineMaterial(String pipelineMaterial) { + this.pipelineMaterial = pipelineMaterial; + } + + public String getBuryMethod() { + return buryMethod; + } + + public void setBuryMethod(String buryMethod) { + this.buryMethod = buryMethod; + } + + public String getBuryDepth() { + return buryDepth; + } + + public void setBuryDepth(String buryDepth) { + this.buryDepth = buryDepth; + } + + public String getArea() { + return area; + } + + public void setArea(String area) { + this.area = area; + } + + public String getLine() { + return line; + } + + public void setLine(String line) { + this.line = line; + } + + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + + public String getConstructTime() { + return constructTime; + } + + public void setConstructTime(String constructTime) { + this.constructTime = constructTime; + } + + public String getOwner() { + return owner; + } + + public void setOwner(String owner) { + this.owner = owner; + } + + public String getObjectId() { + return objectId; + } + + public void setObjectId(String objectId) { + this.objectId = objectId; + } + + public String getMarkerId() { + return markerId; + } + + public void setMarkerId(String markerId) { + this.markerId = markerId; + } + + public String getMarkerType() { + return markerType; + } + + public void setMarkerType(String markerType) { + this.markerType = markerType; + } + + public String getMarkerDepth() { + return markerDepth; + } + + public void setMarkerDepth(String markerDepth) { + this.markerDepth = markerDepth; + } + + public String getInstallationDept() { + return installationDept; + } + + public void setInstallationDept(String installationDept) { + this.installationDept = installationDept; + } + + public String getLng() { + return lng; + } + + public void setLng(String lng) { + this.lng = lng; + } + + public String getLat() { + return lat; + } + + public void setLat(String lat) { + this.lat = lat; + } + + public String getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } + + public String getUnderlyingPipelineType() { + return underlyingPipelineType; + } + + public void setUnderlyingPipelineType(String underlyingPipelineType) { + this.underlyingPipelineType = underlyingPipelineType; + } + + public String getUnderlyingPipelineDepth() { + return underlyingPipelineDepth; + } + + public void setUnderlyingPipelineDepth(String underlyingPipelineDepth) { + this.underlyingPipelineDepth = underlyingPipelineDepth; + } + + public String getUnderlyingPipelineDiameter() { + return underlyingPipelineDiameter; + } + + public void setUnderlyingPipelineDiameter(String underlyingPipelineDiameter) { + this.underlyingPipelineDiameter = underlyingPipelineDiameter; + } + + public String getUnderlyingPipelineMaterial() { + return underlyingPipelineMaterial; + } + + public void setUnderlyingPipelineMaterial(String underlyingPipelineMaterial) { + this.underlyingPipelineMaterial = underlyingPipelineMaterial; + } + + public String getObjectType() { + return objectType; + } + + public void setObjectType(String objectType) { + this.objectType = objectType; + } + + public String getColor() { + return color; + } + + public void setColor(String color) { + this.color = color; + } + + public String getImagePath() { + return imagePath; + } + + public void setImagePath(String imagePath) { + this.imagePath = imagePath; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java deleted file mode 100644 index 3f2fcdc..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java +++ /dev/null @@ -1,327 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 从平台下载的标识器本地库实体类 - */ -@Entity -public class MarkerLocalBean { - @Id(autoincrement = true) - private Long id;//本地库主键ID - - // 管线类型 - private String pipelineType; - // 管线直径 - private String pipelineDiameter; - // 管材 - private String pipelineMaterial; - // 埋设方式 - private String buryMethod; - // 埋深 - private String buryDepth; - // 所属区域 - private String area; - // 所属线路 - private String line; - // 所属道路 - private String road; - // 建设年代 - private String constructTime; - // 权属单位 - private String owner; - //标识对象ID,无实际用途 - @Deprecated - private String objectId; - // 标识器ID - private String markerId; - // 标识器类型 - private String markerType; - // 标识器埋深 - private String markerDepth; - // 安装部门 - private String installationDept; - // 经度 - private String lng; - // 纬度 - private String lat; - //最后修改时间,更新时间 - private String updateTime; - // 备注信息 - private String remark; - // 下层管线类型 - private String underlyingPipelineType; - // 下层埋深 - private String underlyingPipelineDepth; - // 下层管径 - private String underlyingPipelineDiameter; - // 下层管材 - private String underlyingPipelineMaterial; - //标识对象类型 - private String objectType; - // 颜色 - private String color; - // 图片路径 - private String imagePath; - - @Generated(hash = 1479045776) - public MarkerLocalBean(Long id, String pipelineType, String pipelineDiameter, - String pipelineMaterial, String buryMethod, String buryDepth, - String area, String line, String road, String constructTime, - String owner, String objectId, String markerId, String markerType, - String markerDepth, String installationDept, String lng, String lat, - String updateTime, String remark, String underlyingPipelineType, - String underlyingPipelineDepth, String underlyingPipelineDiameter, - String underlyingPipelineMaterial, String objectType, String color, - String imagePath) { - this.id = id; - this.pipelineType = pipelineType; - this.pipelineDiameter = pipelineDiameter; - this.pipelineMaterial = pipelineMaterial; - this.buryMethod = buryMethod; - this.buryDepth = buryDepth; - this.area = area; - this.line = line; - this.road = road; - this.constructTime = constructTime; - this.owner = owner; - this.objectId = objectId; - this.markerId = markerId; - this.markerType = markerType; - this.markerDepth = markerDepth; - this.installationDept = installationDept; - this.lng = lng; - this.lat = lat; - this.updateTime = updateTime; - this.remark = remark; - this.underlyingPipelineType = underlyingPipelineType; - this.underlyingPipelineDepth = underlyingPipelineDepth; - this.underlyingPipelineDiameter = underlyingPipelineDiameter; - this.underlyingPipelineMaterial = underlyingPipelineMaterial; - this.objectType = objectType; - this.color = color; - this.imagePath = imagePath; - } - - @Generated(hash = 1538606012) - public MarkerLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getPipelineType() { - return this.pipelineType; - } - - public void setPipelineType(String pipelineType) { - this.pipelineType = pipelineType; - } - - public String getPipelineDiameter() { - return this.pipelineDiameter; - } - - public void setPipelineDiameter(String pipelineDiameter) { - this.pipelineDiameter = pipelineDiameter; - } - - public String getPipelineMaterial() { - return this.pipelineMaterial; - } - - public void setPipelineMaterial(String pipelineMaterial) { - this.pipelineMaterial = pipelineMaterial; - } - - public String getBuryMethod() { - return this.buryMethod; - } - - public void setBuryMethod(String buryMethod) { - this.buryMethod = buryMethod; - } - - public String getBuryDepth() { - return this.buryDepth; - } - - public void setBuryDepth(String buryDepth) { - this.buryDepth = buryDepth; - } - - public String getArea() { - return this.area; - } - - public void setArea(String area) { - this.area = area; - } - - public String getLine() { - return this.line; - } - - public void setLine(String line) { - this.line = line; - } - - public String getRoad() { - return this.road; - } - - public void setRoad(String road) { - this.road = road; - } - - public String getConstructTime() { - return this.constructTime; - } - - public void setConstructTime(String constructTime) { - this.constructTime = constructTime; - } - - public String getOwner() { - return this.owner; - } - - public void setOwner(String owner) { - this.owner = owner; - } - - public String getObjectId() { - return this.objectId; - } - - public void setObjectId(String objectId) { - this.objectId = objectId; - } - - public String getMarkerId() { - return this.markerId; - } - - public void setMarkerId(String markerId) { - this.markerId = markerId; - } - - public String getMarkerType() { - return this.markerType; - } - - public void setMarkerType(String markerType) { - this.markerType = markerType; - } - - public String getMarkerDepth() { - return this.markerDepth; - } - - public void setMarkerDepth(String markerDepth) { - this.markerDepth = markerDepth; - } - - public String getInstallationDept() { - return this.installationDept; - } - - public void setInstallationDept(String installationDept) { - this.installationDept = installationDept; - } - - public String getLng() { - return this.lng; - } - - public void setLng(String lng) { - this.lng = lng; - } - - public String getLat() { - return this.lat; - } - - public void setLat(String lat) { - this.lat = lat; - } - - public String getUpdateTime() { - return this.updateTime; - } - - public void setUpdateTime(String updateTime) { - this.updateTime = updateTime; - } - - public String getRemark() { - return this.remark; - } - - public void setRemark(String remark) { - this.remark = remark; - } - - public String getUnderlyingPipelineType() { - return this.underlyingPipelineType; - } - - public void setUnderlyingPipelineType(String underlyingPipelineType) { - this.underlyingPipelineType = underlyingPipelineType; - } - - public String getUnderlyingPipelineDepth() { - return this.underlyingPipelineDepth; - } - - public void setUnderlyingPipelineDepth(String underlyingPipelineDepth) { - this.underlyingPipelineDepth = underlyingPipelineDepth; - } - - public String getUnderlyingPipelineDiameter() { - return this.underlyingPipelineDiameter; - } - - public void setUnderlyingPipelineDiameter(String underlyingPipelineDiameter) { - this.underlyingPipelineDiameter = underlyingPipelineDiameter; - } - - public String getUnderlyingPipelineMaterial() { - return this.underlyingPipelineMaterial; - } - - public void setUnderlyingPipelineMaterial(String underlyingPipelineMaterial) { - this.underlyingPipelineMaterial = underlyingPipelineMaterial; - } - - public String getObjectType() { - return this.objectType; - } - - public void setObjectType(String objectType) { - this.objectType = objectType; - } - - public String getColor() { - return this.color; - } - - public void setColor(String color) { - this.color = color; - } - - public String getImagePath() { - return this.imagePath; - } - - public void setImagePath(String imagePath) { - this.imagePath = imagePath; - } -} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java new file mode 100644 index 0000000..5c88fdf --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java @@ -0,0 +1,93 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 巡检任务本地库实体类,不包含任务里面需要巡检的标识器信息 + */ +@Entity(tableName = "task_detail") +public class TaskBean { + @PrimaryKey(autoGenerate = true) + private long id;//主键ID + private String taskCode; // 任务编号 + private String description; // 任务名称 + private String createTime; // 任务创建的时间 + private String status; // 任务状态 + private String createUserName; // 任务创建者名称 + private String startTime; // 任务被开始执行的时间 + private String endTime; // 任务执行结束的时间 + private String isFree; // 是否自由巡检。1-是,0-否 + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getTaskCode() { + return taskCode; + } + + public void setTaskCode(String taskCode) { + this.taskCode = taskCode; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getCreateUserName() { + return createUserName; + } + + public void setCreateUserName(String createUserName) { + this.createUserName = createUserName; + } + + public String getStartTime() { + return startTime; + } + + public void setStartTime(String startTime) { + this.startTime = startTime; + } + + public String getEndTime() { + return endTime; + } + + public void setEndTime(String endTime) { + this.endTime = endTime; + } + + public String getIsFree() { + return isFree; + } + + public void setIsFree(String isFree) { + this.isFree = isFree; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java deleted file mode 100644 index 91737b3..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java +++ /dev/null @@ -1,114 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 巡检任务本地库实体类,不包含任务里面需要巡检的标识器信息 - */ -@Entity -public class TaskLocalBean { - @Id - private Long id;//任务ID - - private String taskCode;//任务编号 - private String description;//任务名称 - private String createTime;//任务创建的时间 - private String status;//任务状态 - private String createUserName;//任务创建者名称 - private String startTime;//任务被开始执行的时间 - private String endTime;//任务执行结束的时间 - private String isFreeTask;//是否自由巡检。1-是,0-否 - - @Generated(hash = 1482022528) - public TaskLocalBean(Long id, String taskCode, String description, - String createTime, String status, String createUserName, - String startTime, String endTime, String isFreeTask) { - this.id = id; - this.taskCode = taskCode; - this.description = description; - this.createTime = createTime; - this.status = status; - this.createUserName = createUserName; - this.startTime = startTime; - this.endTime = endTime; - this.isFreeTask = isFreeTask; - } - - @Generated(hash = 949704588) - public TaskLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getTaskCode() { - return this.taskCode; - } - - public void setTaskCode(String taskCode) { - this.taskCode = taskCode; - } - - public String getDescription() { - return this.description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getCreateTime() { - return this.createTime; - } - - public void setCreateTime(String createTime) { - this.createTime = createTime; - } - - public String getStatus() { - return this.status; - } - - public void setStatus(String status) { - this.status = status; - } - - public String getCreateUserName() { - return this.createUserName; - } - - public void setCreateUserName(String createUserName) { - this.createUserName = createUserName; - } - - public String getStartTime() { - return this.startTime; - } - - public void setStartTime(String startTime) { - this.startTime = startTime; - } - - public String getEndTime() { - return this.endTime; - } - - public void setEndTime(String endTime) { - this.endTime = endTime; - } - - public String getIsFreeTask() { - return this.isFreeTask; - } - - public void setIsFreeTask(String isFreeTask) { - this.isFreeTask = isFreeTask; - } -} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerBean.java new file mode 100644 index 0000000..c563a60 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerBean.java @@ -0,0 +1,110 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 巡检任务里面需要巡检的标识器信息本地库实体类 + */ +@Entity(tableName = "task_marker_info") +public class TaskMarkerBean { + //标识器后台库的主键ID,不是标识器实际ID + @PrimaryKey(autoGenerate = true) + private long id; + + /** + * 任务ID,通过此字段关联[TaskBean.id] + */ + private String taskId; + + /** + * 任务Code,通过此字段关联[TaskBean.taskCode] + *

+ *

+ * 双重验证,防止出现同时刻重复的情况 + */ + private String taskCode; + + /** + * 对应后台字段[TaskModel.MessageModel.TaskDetailInfosModel.markerIdReal],也就是探测仪扫描出来的ID + */ + private String markerId; + + private Double lng; + private Double lat; + + /** + * 是否已被探测到 + * 1-是,0-否 + */ + private String isDetected; + + /** + * 被探测到的时间,对应后台字段[TaskModel.MessageModel.TaskDetailInfosModel.finishTime] + */ + private String detectedTime; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getTaskId() { + return taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getTaskCode() { + return taskCode; + } + + public void setTaskCode(String taskCode) { + this.taskCode = taskCode; + } + + public String getMarkerId() { + return markerId; + } + + public void setMarkerId(String markerId) { + this.markerId = markerId; + } + + public Double getLng() { + return lng; + } + + public void setLng(Double lng) { + this.lng = lng; + } + + public Double getLat() { + return lat; + } + + public void setLat(Double lat) { + this.lat = lat; + } + + public String getIsDetected() { + return isDetected; + } + + public void setIsDetected(String isDetected) { + this.isDetected = isDetected; + } + + public String getDetectedTime() { + return detectedTime; + } + + public void setDetectedTime(String detectedTime) { + this.detectedTime = detectedTime; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerLocalBean.java deleted file mode 100644 index de9f459..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerLocalBean.java +++ /dev/null @@ -1,128 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import com.casic.common.detector.gd.model.TaskModel; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 巡检任务里面需要巡检的标识器信息本地库实体类 - */ -@Entity -public class TaskMarkerLocalBean { - @Id - private Long id;//标识器后台库的主键ID,不是标识器实际ID - - /** - * 任务ID,通过此字段关联{@link TaskLocalBean#id} - */ - private String taskId; - - /** - * 任务Code,通过此字段关联{@link TaskLocalBean#taskCode} - *

- * 双重验证,防止出现同时刻重复的情况 - */ - private String taskCode; - - /** - * 对应后台字段{@link TaskModel.MessageModel.TaskDetailInfosModel#markerIdReal},也就是探测仪扫描出来的ID - */ - private String markerId; - - private double lng; - private double lat; - - /** - * 是否已被探测到 - * 1-是,0-否 - */ - private String isDetected; - - /** - * 被探测到的时间,对应后台字段{@link TaskModel.MessageModel.TaskDetailInfosModel#finishTime} - */ - private String detectedTime; - - @Generated(hash = 677328533) - public TaskMarkerLocalBean(Long id, String taskId, String taskCode, String markerId, - double lng, double lat, String isDetected, String detectedTime) { - this.id = id; - this.taskId = taskId; - this.taskCode = taskCode; - this.markerId = markerId; - this.lng = lng; - this.lat = lat; - this.isDetected = isDetected; - this.detectedTime = detectedTime; - } - - @Generated(hash = 1162404642) - public TaskMarkerLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getTaskId() { - return this.taskId; - } - - public void setTaskId(String taskId) { - this.taskId = taskId; - } - - public String getTaskCode() { - return this.taskCode; - } - - public void setTaskCode(String taskCode) { - this.taskCode = taskCode; - } - - public String getMarkerId() { - return this.markerId; - } - - public void setMarkerId(String markerId) { - this.markerId = markerId; - } - - public double getLng() { - return this.lng; - } - - public void setLng(double lng) { - this.lng = lng; - } - - public double getLat() { - return this.lat; - } - - public void setLat(double lat) { - this.lat = lat; - } - - public String getIsDetected() { - return this.isDetected; - } - - public void setIsDetected(String isDetected) { - this.isDetected = isDetected; - } - - public String getDetectedTime() { - return this.detectedTime; - } - - public void setDetectedTime(String detectedTime) { - this.detectedTime = detectedTime; - } -} diff --git a/app/build.gradle b/app/build.gradle index d0cb423..921c8c8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,25 +1,20 @@ import java.text.SimpleDateFormat -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply plugin: 'org.greenrobot.greendao' +plugins { + id('com.android.application') + id('org.jetbrains.kotlin.android') +} android { - compileSdkVersion 33 + namespace 'com.casic.common.detector.gd' + compileSdk 35 defaultConfig { - applicationId "com.casic.common.detector.gd" - minSdkVersion 26 - targetSdkVersion 33 + applicationId 'com.casic.common.detector.gd' + minSdk 26 + targetSdk 35 versionCode 5092 - versionName "5.0.9.2" - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } + versionName '5.0.9.2' } signingConfigs { @@ -31,6 +26,14 @@ } } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + signingConfig signingConfigs.release + } + } + compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 @@ -47,27 +50,16 @@ } } - kotlin { - experimental { - coroutines 'enable' - } - } - buildFeatures { + buildConfig true viewBinding true } - applicationVariants.configureEach { variant -> - variant.outputs.configureEach { - outputFileName = "COM_TCY_" + getBuildDate() + "_" + defaultConfig.versionName + ".apk" + applicationVariants.configureEach { + outputs.configureEach { + outputFileName = 'COM_TCY_' + getBuildDate() + '_' + defaultConfig.versionName + '.apk' } } - - greendao { - schemaVersion 1//数据库版本号 - targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 - daoPackage "${defaultConfig.applicationId}.greendao"//设置DaoMaster、DaoSession、Dao包名 - } } static def getBuildDate() { @@ -76,27 +68,22 @@ } dependencies { - //基础依赖库 - implementation 'com.github.AndroidCoderPeng:Kotlin-lite-lib:1.1.4' - implementation 'androidx.core:core-ktx:1.9.0' - def base_version = "1.6.1" - implementation "androidx.appcompat:appcompat:${base_version}" - implementation "com.google.android.material:material:${base_version}" + implementation 'com.github.AndroidCoderPeng:Kotlin-lite-lib:1.1.5' + implementation 'androidx.core:core-ktx:1.13.1' + implementation 'androidx.appcompat:appcompat:1.7.0' + implementation 'com.google.android.material:material:1.12.0' //Google官方授权框架 implementation 'pub.devrel:easypermissions:3.0.0' - //沉浸式状态栏。基础依赖包,必须要依赖 - implementation 'com.gyf.immersionbar:immersionbar:3.0.0' - //fragment快速实现 - implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0' + //沉浸式状态栏 + implementation 'com.geyifeng.immersionbar:immersionbar:3.2.2' //官方Json解析库 implementation 'com.google.code.gson:gson:2.10.1' - def vm_version = '2.5.1' //Kotlin协程 - implementation "androidx.lifecycle:lifecycle-runtime-ktx:${vm_version}" + implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.2' //MVVM+LiveData - implementation "androidx.lifecycle:lifecycle-livedata-ktx:${vm_version}" - implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:${vm_version}" - implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.6.2' + implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2' + implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' //返回值转换器 implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' @@ -105,9 +92,10 @@ implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' //网络请求和接口封装 implementation 'com.squareup.retrofit2:retrofit:2.9.0' - implementation 'com.squareup.okhttp3:okhttp:4.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.12.0' //数据库框架 - implementation 'org.greenrobot:greendao:3.3.0' + implementation 'androidx.room:room-runtime:2.6.1' + annotationProcessor 'androidx.room:room-compiler:2.5.2' //高德导航、定位、地图三合一 implementation 'com.amap.api:navi-3dmap:latest.integration' //经纬度逆编码 @@ -115,7 +103,7 @@ //excel implementation 'net.sourceforge.jexcelapi:jxl:2.6.12' //图片加载框架 - implementation 'com.github.bumptech.glide:glide:4.9.0' + implementation 'com.github.bumptech.glide:glide:4.12.0' //图片选择框架 implementation 'io.github.lucksiege:pictureselector:v3.11.1' //大图 diff --git a/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt b/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt index 7b695ff..50ba734 100644 --- a/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt +++ b/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt @@ -4,9 +4,9 @@ import android.app.Application import android.os.Bundle import android.util.Log -import com.casic.common.detector.gd.greendao.DaoMaster -import com.casic.common.detector.gd.greendao.DaoSession +import androidx.room.Room.databaseBuilder import com.casic.common.detector.gd.uart.SerialPort +import com.casic.common.detector.gd.utils.DetectorDataBase import com.casic.common.detector.gd.utils.GpioManager import com.pengxh.kt.lite.extensions.show import com.pengxh.kt.lite.utils.SaveKeyValues @@ -43,44 +43,42 @@ private var application: BaseApplication by Delegates.notNull() fun get() = application - - private lateinit var daoSession: DaoSession } + lateinit var dataBase: DetectorDataBase + override fun onCreate() { super.onCreate() application = this SaveKeyValues.initSharedPreferences(this) CrashReport.initCrashReport(this, "01e80d3a74", true) - val devOpenHelper = DaoMaster.DevOpenHelper(this, "Detector.db", null) - val daoMaster = DaoMaster(devOpenHelper.writableDatabase) - daoSession = daoMaster.newSession() + dataBase = databaseBuilder(this, DetectorDataBase::class.java, "Detector.db") + .allowMainThreadQueries() + .build() /** * Open the serial port * */ try { serialPorts.apply { - add(SerialPort(File("/dev/ttysWK1"), 9600, 0)) - //千寻报文数据下发串口号 - add(SerialPort(File("/dev/ttyS1"), 9600, 0)) + add(SerialPort(File("/dev/ttysWK1"), 9600, 0)) //信号通讯串口 + add(SerialPort(File("/dev/ttyS1"), 9600, 0)) //千寻报文数据下发串口号 } Log.d(kTag, "onCreate: 已初始化 ${serialPorts.size} 个串口") } catch (e: SecurityException) { "您没有串口的读写权限!".show(this) + e.printStackTrace() } catch (e: IOException) { "因为不明原因,串口无法打开!".show(this) + e.printStackTrace() } catch (e: InvalidParameterException) { "请检查串口!".show(this) + e.printStackTrace() } registerActivityLifecycleCallbacks(this) } - fun getDaoSession(): DaoSession { - return daoSession - } - override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) { } diff --git a/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt b/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt index 053b9dd..1d0c9e3 100644 --- a/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt +++ b/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt @@ -14,12 +14,10 @@ import com.casic.common.detector.gd.utils.SerialPortCommand import com.pengxh.kt.lite.utils.WeakReferenceHandler import java.io.IOException -import java.util.Timer abstract class SerialPortBaseActivity : AppCompatActivity(), Handler.Callback { private val kTag = "SerialPortBaseActivity" - private val taskTimer by lazy { Timer() } private val weakReferenceHandler by lazy { WeakReferenceHandler(this) } private val serialPorts by lazy { BaseApplication.get().getSerialPorts() } protected lateinit var binding: VB @@ -30,7 +28,6 @@ setContentView(binding.root) setupTopBarLayout() initOnCreate(savedInstanceState) - observeRequestState() initEvent() if (serialPorts.isNotEmpty()) { @@ -71,11 +68,6 @@ abstract fun initOnCreate(savedInstanceState: Bundle?) /** - * 数据请求状态监听 - */ - abstract fun observeRequestState() - - /** * 初始化业务逻辑 */ abstract fun initEvent() diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java new file mode 100644 index 0000000..7a18c20 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java @@ -0,0 +1,255 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 从平台下载的标识器本地库实体类 + */ +@Entity(tableName = "marker_detail") +public class MarkerBean { + @PrimaryKey(autoGenerate = true) + private long id; //主键ID + private String pipelineType; // 管线类型 + private String pipelineDiameter; // 管线直径 + private String pipelineMaterial; // 管材 + private String buryMethod; // 埋设方式 + private String buryDepth; // 埋深 + private String area; // 所属区域 + private String line; // 所属线路 + private String road; // 所属道路 + private String constructTime; // 建设年代 + private String owner; // 权属单位 + private String objectId; // 标识对象ID,无实际用途 + private String markerId; // 标识器ID + private String markerType; // 标识器类型 + private String markerDepth; // 标识器埋深 + private String installationDept; // 安装部门 + private String lng; // 经度 + private String lat; // 纬度 + private String updateTime; // 最后修改时间,更新时间 + private String remark; // 备注信息 + private String underlyingPipelineType; // 下层管线类型 + private String underlyingPipelineDepth; // 下层埋深 + private String underlyingPipelineDiameter; // 下层管径 + private String underlyingPipelineMaterial; // 下层管材 + private String objectType; //标识对象类型 + private String color; // 颜色 + private String imagePath; // 图片路径 + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getPipelineType() { + return pipelineType; + } + + public void setPipelineType(String pipelineType) { + this.pipelineType = pipelineType; + } + + public String getPipelineDiameter() { + return pipelineDiameter; + } + + public void setPipelineDiameter(String pipelineDiameter) { + this.pipelineDiameter = pipelineDiameter; + } + + public String getPipelineMaterial() { + return pipelineMaterial; + } + + public void setPipelineMaterial(String pipelineMaterial) { + this.pipelineMaterial = pipelineMaterial; + } + + public String getBuryMethod() { + return buryMethod; + } + + public void setBuryMethod(String buryMethod) { + this.buryMethod = buryMethod; + } + + public String getBuryDepth() { + return buryDepth; + } + + public void setBuryDepth(String buryDepth) { + this.buryDepth = buryDepth; + } + + public String getArea() { + return area; + } + + public void setArea(String area) { + this.area = area; + } + + public String getLine() { + return line; + } + + public void setLine(String line) { + this.line = line; + } + + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + + public String getConstructTime() { + return constructTime; + } + + public void setConstructTime(String constructTime) { + this.constructTime = constructTime; + } + + public String getOwner() { + return owner; + } + + public void setOwner(String owner) { + this.owner = owner; + } + + public String getObjectId() { + return objectId; + } + + public void setObjectId(String objectId) { + this.objectId = objectId; + } + + public String getMarkerId() { + return markerId; + } + + public void setMarkerId(String markerId) { + this.markerId = markerId; + } + + public String getMarkerType() { + return markerType; + } + + public void setMarkerType(String markerType) { + this.markerType = markerType; + } + + public String getMarkerDepth() { + return markerDepth; + } + + public void setMarkerDepth(String markerDepth) { + this.markerDepth = markerDepth; + } + + public String getInstallationDept() { + return installationDept; + } + + public void setInstallationDept(String installationDept) { + this.installationDept = installationDept; + } + + public String getLng() { + return lng; + } + + public void setLng(String lng) { + this.lng = lng; + } + + public String getLat() { + return lat; + } + + public void setLat(String lat) { + this.lat = lat; + } + + public String getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } + + public String getUnderlyingPipelineType() { + return underlyingPipelineType; + } + + public void setUnderlyingPipelineType(String underlyingPipelineType) { + this.underlyingPipelineType = underlyingPipelineType; + } + + public String getUnderlyingPipelineDepth() { + return underlyingPipelineDepth; + } + + public void setUnderlyingPipelineDepth(String underlyingPipelineDepth) { + this.underlyingPipelineDepth = underlyingPipelineDepth; + } + + public String getUnderlyingPipelineDiameter() { + return underlyingPipelineDiameter; + } + + public void setUnderlyingPipelineDiameter(String underlyingPipelineDiameter) { + this.underlyingPipelineDiameter = underlyingPipelineDiameter; + } + + public String getUnderlyingPipelineMaterial() { + return underlyingPipelineMaterial; + } + + public void setUnderlyingPipelineMaterial(String underlyingPipelineMaterial) { + this.underlyingPipelineMaterial = underlyingPipelineMaterial; + } + + public String getObjectType() { + return objectType; + } + + public void setObjectType(String objectType) { + this.objectType = objectType; + } + + public String getColor() { + return color; + } + + public void setColor(String color) { + this.color = color; + } + + public String getImagePath() { + return imagePath; + } + + public void setImagePath(String imagePath) { + this.imagePath = imagePath; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java deleted file mode 100644 index 3f2fcdc..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java +++ /dev/null @@ -1,327 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 从平台下载的标识器本地库实体类 - */ -@Entity -public class MarkerLocalBean { - @Id(autoincrement = true) - private Long id;//本地库主键ID - - // 管线类型 - private String pipelineType; - // 管线直径 - private String pipelineDiameter; - // 管材 - private String pipelineMaterial; - // 埋设方式 - private String buryMethod; - // 埋深 - private String buryDepth; - // 所属区域 - private String area; - // 所属线路 - private String line; - // 所属道路 - private String road; - // 建设年代 - private String constructTime; - // 权属单位 - private String owner; - //标识对象ID,无实际用途 - @Deprecated - private String objectId; - // 标识器ID - private String markerId; - // 标识器类型 - private String markerType; - // 标识器埋深 - private String markerDepth; - // 安装部门 - private String installationDept; - // 经度 - private String lng; - // 纬度 - private String lat; - //最后修改时间,更新时间 - private String updateTime; - // 备注信息 - private String remark; - // 下层管线类型 - private String underlyingPipelineType; - // 下层埋深 - private String underlyingPipelineDepth; - // 下层管径 - private String underlyingPipelineDiameter; - // 下层管材 - private String underlyingPipelineMaterial; - //标识对象类型 - private String objectType; - // 颜色 - private String color; - // 图片路径 - private String imagePath; - - @Generated(hash = 1479045776) - public MarkerLocalBean(Long id, String pipelineType, String pipelineDiameter, - String pipelineMaterial, String buryMethod, String buryDepth, - String area, String line, String road, String constructTime, - String owner, String objectId, String markerId, String markerType, - String markerDepth, String installationDept, String lng, String lat, - String updateTime, String remark, String underlyingPipelineType, - String underlyingPipelineDepth, String underlyingPipelineDiameter, - String underlyingPipelineMaterial, String objectType, String color, - String imagePath) { - this.id = id; - this.pipelineType = pipelineType; - this.pipelineDiameter = pipelineDiameter; - this.pipelineMaterial = pipelineMaterial; - this.buryMethod = buryMethod; - this.buryDepth = buryDepth; - this.area = area; - this.line = line; - this.road = road; - this.constructTime = constructTime; - this.owner = owner; - this.objectId = objectId; - this.markerId = markerId; - this.markerType = markerType; - this.markerDepth = markerDepth; - this.installationDept = installationDept; - this.lng = lng; - this.lat = lat; - this.updateTime = updateTime; - this.remark = remark; - this.underlyingPipelineType = underlyingPipelineType; - this.underlyingPipelineDepth = underlyingPipelineDepth; - this.underlyingPipelineDiameter = underlyingPipelineDiameter; - this.underlyingPipelineMaterial = underlyingPipelineMaterial; - this.objectType = objectType; - this.color = color; - this.imagePath = imagePath; - } - - @Generated(hash = 1538606012) - public MarkerLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getPipelineType() { - return this.pipelineType; - } - - public void setPipelineType(String pipelineType) { - this.pipelineType = pipelineType; - } - - public String getPipelineDiameter() { - return this.pipelineDiameter; - } - - public void setPipelineDiameter(String pipelineDiameter) { - this.pipelineDiameter = pipelineDiameter; - } - - public String getPipelineMaterial() { - return this.pipelineMaterial; - } - - public void setPipelineMaterial(String pipelineMaterial) { - this.pipelineMaterial = pipelineMaterial; - } - - public String getBuryMethod() { - return this.buryMethod; - } - - public void setBuryMethod(String buryMethod) { - this.buryMethod = buryMethod; - } - - public String getBuryDepth() { - return this.buryDepth; - } - - public void setBuryDepth(String buryDepth) { - this.buryDepth = buryDepth; - } - - public String getArea() { - return this.area; - } - - public void setArea(String area) { - this.area = area; - } - - public String getLine() { - return this.line; - } - - public void setLine(String line) { - this.line = line; - } - - public String getRoad() { - return this.road; - } - - public void setRoad(String road) { - this.road = road; - } - - public String getConstructTime() { - return this.constructTime; - } - - public void setConstructTime(String constructTime) { - this.constructTime = constructTime; - } - - public String getOwner() { - return this.owner; - } - - public void setOwner(String owner) { - this.owner = owner; - } - - public String getObjectId() { - return this.objectId; - } - - public void setObjectId(String objectId) { - this.objectId = objectId; - } - - public String getMarkerId() { - return this.markerId; - } - - public void setMarkerId(String markerId) { - this.markerId = markerId; - } - - public String getMarkerType() { - return this.markerType; - } - - public void setMarkerType(String markerType) { - this.markerType = markerType; - } - - public String getMarkerDepth() { - return this.markerDepth; - } - - public void setMarkerDepth(String markerDepth) { - this.markerDepth = markerDepth; - } - - public String getInstallationDept() { - return this.installationDept; - } - - public void setInstallationDept(String installationDept) { - this.installationDept = installationDept; - } - - public String getLng() { - return this.lng; - } - - public void setLng(String lng) { - this.lng = lng; - } - - public String getLat() { - return this.lat; - } - - public void setLat(String lat) { - this.lat = lat; - } - - public String getUpdateTime() { - return this.updateTime; - } - - public void setUpdateTime(String updateTime) { - this.updateTime = updateTime; - } - - public String getRemark() { - return this.remark; - } - - public void setRemark(String remark) { - this.remark = remark; - } - - public String getUnderlyingPipelineType() { - return this.underlyingPipelineType; - } - - public void setUnderlyingPipelineType(String underlyingPipelineType) { - this.underlyingPipelineType = underlyingPipelineType; - } - - public String getUnderlyingPipelineDepth() { - return this.underlyingPipelineDepth; - } - - public void setUnderlyingPipelineDepth(String underlyingPipelineDepth) { - this.underlyingPipelineDepth = underlyingPipelineDepth; - } - - public String getUnderlyingPipelineDiameter() { - return this.underlyingPipelineDiameter; - } - - public void setUnderlyingPipelineDiameter(String underlyingPipelineDiameter) { - this.underlyingPipelineDiameter = underlyingPipelineDiameter; - } - - public String getUnderlyingPipelineMaterial() { - return this.underlyingPipelineMaterial; - } - - public void setUnderlyingPipelineMaterial(String underlyingPipelineMaterial) { - this.underlyingPipelineMaterial = underlyingPipelineMaterial; - } - - public String getObjectType() { - return this.objectType; - } - - public void setObjectType(String objectType) { - this.objectType = objectType; - } - - public String getColor() { - return this.color; - } - - public void setColor(String color) { - this.color = color; - } - - public String getImagePath() { - return this.imagePath; - } - - public void setImagePath(String imagePath) { - this.imagePath = imagePath; - } -} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java new file mode 100644 index 0000000..5c88fdf --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java @@ -0,0 +1,93 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 巡检任务本地库实体类,不包含任务里面需要巡检的标识器信息 + */ +@Entity(tableName = "task_detail") +public class TaskBean { + @PrimaryKey(autoGenerate = true) + private long id;//主键ID + private String taskCode; // 任务编号 + private String description; // 任务名称 + private String createTime; // 任务创建的时间 + private String status; // 任务状态 + private String createUserName; // 任务创建者名称 + private String startTime; // 任务被开始执行的时间 + private String endTime; // 任务执行结束的时间 + private String isFree; // 是否自由巡检。1-是,0-否 + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getTaskCode() { + return taskCode; + } + + public void setTaskCode(String taskCode) { + this.taskCode = taskCode; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getCreateUserName() { + return createUserName; + } + + public void setCreateUserName(String createUserName) { + this.createUserName = createUserName; + } + + public String getStartTime() { + return startTime; + } + + public void setStartTime(String startTime) { + this.startTime = startTime; + } + + public String getEndTime() { + return endTime; + } + + public void setEndTime(String endTime) { + this.endTime = endTime; + } + + public String getIsFree() { + return isFree; + } + + public void setIsFree(String isFree) { + this.isFree = isFree; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java deleted file mode 100644 index 91737b3..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java +++ /dev/null @@ -1,114 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 巡检任务本地库实体类,不包含任务里面需要巡检的标识器信息 - */ -@Entity -public class TaskLocalBean { - @Id - private Long id;//任务ID - - private String taskCode;//任务编号 - private String description;//任务名称 - private String createTime;//任务创建的时间 - private String status;//任务状态 - private String createUserName;//任务创建者名称 - private String startTime;//任务被开始执行的时间 - private String endTime;//任务执行结束的时间 - private String isFreeTask;//是否自由巡检。1-是,0-否 - - @Generated(hash = 1482022528) - public TaskLocalBean(Long id, String taskCode, String description, - String createTime, String status, String createUserName, - String startTime, String endTime, String isFreeTask) { - this.id = id; - this.taskCode = taskCode; - this.description = description; - this.createTime = createTime; - this.status = status; - this.createUserName = createUserName; - this.startTime = startTime; - this.endTime = endTime; - this.isFreeTask = isFreeTask; - } - - @Generated(hash = 949704588) - public TaskLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getTaskCode() { - return this.taskCode; - } - - public void setTaskCode(String taskCode) { - this.taskCode = taskCode; - } - - public String getDescription() { - return this.description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getCreateTime() { - return this.createTime; - } - - public void setCreateTime(String createTime) { - this.createTime = createTime; - } - - public String getStatus() { - return this.status; - } - - public void setStatus(String status) { - this.status = status; - } - - public String getCreateUserName() { - return this.createUserName; - } - - public void setCreateUserName(String createUserName) { - this.createUserName = createUserName; - } - - public String getStartTime() { - return this.startTime; - } - - public void setStartTime(String startTime) { - this.startTime = startTime; - } - - public String getEndTime() { - return this.endTime; - } - - public void setEndTime(String endTime) { - this.endTime = endTime; - } - - public String getIsFreeTask() { - return this.isFreeTask; - } - - public void setIsFreeTask(String isFreeTask) { - this.isFreeTask = isFreeTask; - } -} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerBean.java new file mode 100644 index 0000000..c563a60 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerBean.java @@ -0,0 +1,110 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 巡检任务里面需要巡检的标识器信息本地库实体类 + */ +@Entity(tableName = "task_marker_info") +public class TaskMarkerBean { + //标识器后台库的主键ID,不是标识器实际ID + @PrimaryKey(autoGenerate = true) + private long id; + + /** + * 任务ID,通过此字段关联[TaskBean.id] + */ + private String taskId; + + /** + * 任务Code,通过此字段关联[TaskBean.taskCode] + *

+ *

+ * 双重验证,防止出现同时刻重复的情况 + */ + private String taskCode; + + /** + * 对应后台字段[TaskModel.MessageModel.TaskDetailInfosModel.markerIdReal],也就是探测仪扫描出来的ID + */ + private String markerId; + + private Double lng; + private Double lat; + + /** + * 是否已被探测到 + * 1-是,0-否 + */ + private String isDetected; + + /** + * 被探测到的时间,对应后台字段[TaskModel.MessageModel.TaskDetailInfosModel.finishTime] + */ + private String detectedTime; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getTaskId() { + return taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getTaskCode() { + return taskCode; + } + + public void setTaskCode(String taskCode) { + this.taskCode = taskCode; + } + + public String getMarkerId() { + return markerId; + } + + public void setMarkerId(String markerId) { + this.markerId = markerId; + } + + public Double getLng() { + return lng; + } + + public void setLng(Double lng) { + this.lng = lng; + } + + public Double getLat() { + return lat; + } + + public void setLat(Double lat) { + this.lat = lat; + } + + public String getIsDetected() { + return isDetected; + } + + public void setIsDetected(String isDetected) { + this.isDetected = isDetected; + } + + public String getDetectedTime() { + return detectedTime; + } + + public void setDetectedTime(String detectedTime) { + this.detectedTime = detectedTime; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerLocalBean.java deleted file mode 100644 index de9f459..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerLocalBean.java +++ /dev/null @@ -1,128 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import com.casic.common.detector.gd.model.TaskModel; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 巡检任务里面需要巡检的标识器信息本地库实体类 - */ -@Entity -public class TaskMarkerLocalBean { - @Id - private Long id;//标识器后台库的主键ID,不是标识器实际ID - - /** - * 任务ID,通过此字段关联{@link TaskLocalBean#id} - */ - private String taskId; - - /** - * 任务Code,通过此字段关联{@link TaskLocalBean#taskCode} - *

- * 双重验证,防止出现同时刻重复的情况 - */ - private String taskCode; - - /** - * 对应后台字段{@link TaskModel.MessageModel.TaskDetailInfosModel#markerIdReal},也就是探测仪扫描出来的ID - */ - private String markerId; - - private double lng; - private double lat; - - /** - * 是否已被探测到 - * 1-是,0-否 - */ - private String isDetected; - - /** - * 被探测到的时间,对应后台字段{@link TaskModel.MessageModel.TaskDetailInfosModel#finishTime} - */ - private String detectedTime; - - @Generated(hash = 677328533) - public TaskMarkerLocalBean(Long id, String taskId, String taskCode, String markerId, - double lng, double lat, String isDetected, String detectedTime) { - this.id = id; - this.taskId = taskId; - this.taskCode = taskCode; - this.markerId = markerId; - this.lng = lng; - this.lat = lat; - this.isDetected = isDetected; - this.detectedTime = detectedTime; - } - - @Generated(hash = 1162404642) - public TaskMarkerLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getTaskId() { - return this.taskId; - } - - public void setTaskId(String taskId) { - this.taskId = taskId; - } - - public String getTaskCode() { - return this.taskCode; - } - - public void setTaskCode(String taskCode) { - this.taskCode = taskCode; - } - - public String getMarkerId() { - return this.markerId; - } - - public void setMarkerId(String markerId) { - this.markerId = markerId; - } - - public double getLng() { - return this.lng; - } - - public void setLng(double lng) { - this.lng = lng; - } - - public double getLat() { - return this.lat; - } - - public void setLat(double lat) { - this.lat = lat; - } - - public String getIsDetected() { - return this.isDetected; - } - - public void setIsDetected(String isDetected) { - this.isDetected = isDetected; - } - - public String getDetectedTime() { - return this.detectedTime; - } - - public void setDetectedTime(String detectedTime) { - this.detectedTime = detectedTime; - } -} diff --git a/app/src/main/java/com/casic/common/detector/gd/dao/MarkerBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/dao/MarkerBeanDao.java new file mode 100644 index 0000000..2beb7ed --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/dao/MarkerBeanDao.java @@ -0,0 +1,29 @@ +package com.casic.common.detector.gd.dao; + +import androidx.room.Dao; +import androidx.room.Insert; +import androidx.room.Query; +import androidx.room.RawQuery; +import androidx.sqlite.db.SupportSQLiteQuery; + +import com.casic.common.detector.gd.bean.MarkerBean; + +import java.util.List; + +@Dao +public interface MarkerBeanDao { + @Query("DELETE FROM marker_detail") + void deleteAll(); + + @Insert + void insert(MarkerBean marker); + + @Query("SELECT * FROM marker_detail") + List loadAll(); + + @Query("SELECT * FROM marker_detail WHERE markerId = :markerId") + List queryMarkerById(String markerId); + + @RawQuery + List loadMarkersByCondition(SupportSQLiteQuery query); +} diff --git a/app/build.gradle b/app/build.gradle index d0cb423..921c8c8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,25 +1,20 @@ import java.text.SimpleDateFormat -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply plugin: 'org.greenrobot.greendao' +plugins { + id('com.android.application') + id('org.jetbrains.kotlin.android') +} android { - compileSdkVersion 33 + namespace 'com.casic.common.detector.gd' + compileSdk 35 defaultConfig { - applicationId "com.casic.common.detector.gd" - minSdkVersion 26 - targetSdkVersion 33 + applicationId 'com.casic.common.detector.gd' + minSdk 26 + targetSdk 35 versionCode 5092 - versionName "5.0.9.2" - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } + versionName '5.0.9.2' } signingConfigs { @@ -31,6 +26,14 @@ } } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + signingConfig signingConfigs.release + } + } + compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 @@ -47,27 +50,16 @@ } } - kotlin { - experimental { - coroutines 'enable' - } - } - buildFeatures { + buildConfig true viewBinding true } - applicationVariants.configureEach { variant -> - variant.outputs.configureEach { - outputFileName = "COM_TCY_" + getBuildDate() + "_" + defaultConfig.versionName + ".apk" + applicationVariants.configureEach { + outputs.configureEach { + outputFileName = 'COM_TCY_' + getBuildDate() + '_' + defaultConfig.versionName + '.apk' } } - - greendao { - schemaVersion 1//数据库版本号 - targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 - daoPackage "${defaultConfig.applicationId}.greendao"//设置DaoMaster、DaoSession、Dao包名 - } } static def getBuildDate() { @@ -76,27 +68,22 @@ } dependencies { - //基础依赖库 - implementation 'com.github.AndroidCoderPeng:Kotlin-lite-lib:1.1.4' - implementation 'androidx.core:core-ktx:1.9.0' - def base_version = "1.6.1" - implementation "androidx.appcompat:appcompat:${base_version}" - implementation "com.google.android.material:material:${base_version}" + implementation 'com.github.AndroidCoderPeng:Kotlin-lite-lib:1.1.5' + implementation 'androidx.core:core-ktx:1.13.1' + implementation 'androidx.appcompat:appcompat:1.7.0' + implementation 'com.google.android.material:material:1.12.0' //Google官方授权框架 implementation 'pub.devrel:easypermissions:3.0.0' - //沉浸式状态栏。基础依赖包,必须要依赖 - implementation 'com.gyf.immersionbar:immersionbar:3.0.0' - //fragment快速实现 - implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0' + //沉浸式状态栏 + implementation 'com.geyifeng.immersionbar:immersionbar:3.2.2' //官方Json解析库 implementation 'com.google.code.gson:gson:2.10.1' - def vm_version = '2.5.1' //Kotlin协程 - implementation "androidx.lifecycle:lifecycle-runtime-ktx:${vm_version}" + implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.2' //MVVM+LiveData - implementation "androidx.lifecycle:lifecycle-livedata-ktx:${vm_version}" - implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:${vm_version}" - implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.6.2' + implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2' + implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' //返回值转换器 implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' @@ -105,9 +92,10 @@ implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' //网络请求和接口封装 implementation 'com.squareup.retrofit2:retrofit:2.9.0' - implementation 'com.squareup.okhttp3:okhttp:4.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.12.0' //数据库框架 - implementation 'org.greenrobot:greendao:3.3.0' + implementation 'androidx.room:room-runtime:2.6.1' + annotationProcessor 'androidx.room:room-compiler:2.5.2' //高德导航、定位、地图三合一 implementation 'com.amap.api:navi-3dmap:latest.integration' //经纬度逆编码 @@ -115,7 +103,7 @@ //excel implementation 'net.sourceforge.jexcelapi:jxl:2.6.12' //图片加载框架 - implementation 'com.github.bumptech.glide:glide:4.9.0' + implementation 'com.github.bumptech.glide:glide:4.12.0' //图片选择框架 implementation 'io.github.lucksiege:pictureselector:v3.11.1' //大图 diff --git a/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt b/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt index 7b695ff..50ba734 100644 --- a/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt +++ b/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt @@ -4,9 +4,9 @@ import android.app.Application import android.os.Bundle import android.util.Log -import com.casic.common.detector.gd.greendao.DaoMaster -import com.casic.common.detector.gd.greendao.DaoSession +import androidx.room.Room.databaseBuilder import com.casic.common.detector.gd.uart.SerialPort +import com.casic.common.detector.gd.utils.DetectorDataBase import com.casic.common.detector.gd.utils.GpioManager import com.pengxh.kt.lite.extensions.show import com.pengxh.kt.lite.utils.SaveKeyValues @@ -43,44 +43,42 @@ private var application: BaseApplication by Delegates.notNull() fun get() = application - - private lateinit var daoSession: DaoSession } + lateinit var dataBase: DetectorDataBase + override fun onCreate() { super.onCreate() application = this SaveKeyValues.initSharedPreferences(this) CrashReport.initCrashReport(this, "01e80d3a74", true) - val devOpenHelper = DaoMaster.DevOpenHelper(this, "Detector.db", null) - val daoMaster = DaoMaster(devOpenHelper.writableDatabase) - daoSession = daoMaster.newSession() + dataBase = databaseBuilder(this, DetectorDataBase::class.java, "Detector.db") + .allowMainThreadQueries() + .build() /** * Open the serial port * */ try { serialPorts.apply { - add(SerialPort(File("/dev/ttysWK1"), 9600, 0)) - //千寻报文数据下发串口号 - add(SerialPort(File("/dev/ttyS1"), 9600, 0)) + add(SerialPort(File("/dev/ttysWK1"), 9600, 0)) //信号通讯串口 + add(SerialPort(File("/dev/ttyS1"), 9600, 0)) //千寻报文数据下发串口号 } Log.d(kTag, "onCreate: 已初始化 ${serialPorts.size} 个串口") } catch (e: SecurityException) { "您没有串口的读写权限!".show(this) + e.printStackTrace() } catch (e: IOException) { "因为不明原因,串口无法打开!".show(this) + e.printStackTrace() } catch (e: InvalidParameterException) { "请检查串口!".show(this) + e.printStackTrace() } registerActivityLifecycleCallbacks(this) } - fun getDaoSession(): DaoSession { - return daoSession - } - override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) { } diff --git a/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt b/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt index 053b9dd..1d0c9e3 100644 --- a/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt +++ b/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt @@ -14,12 +14,10 @@ import com.casic.common.detector.gd.utils.SerialPortCommand import com.pengxh.kt.lite.utils.WeakReferenceHandler import java.io.IOException -import java.util.Timer abstract class SerialPortBaseActivity : AppCompatActivity(), Handler.Callback { private val kTag = "SerialPortBaseActivity" - private val taskTimer by lazy { Timer() } private val weakReferenceHandler by lazy { WeakReferenceHandler(this) } private val serialPorts by lazy { BaseApplication.get().getSerialPorts() } protected lateinit var binding: VB @@ -30,7 +28,6 @@ setContentView(binding.root) setupTopBarLayout() initOnCreate(savedInstanceState) - observeRequestState() initEvent() if (serialPorts.isNotEmpty()) { @@ -71,11 +68,6 @@ abstract fun initOnCreate(savedInstanceState: Bundle?) /** - * 数据请求状态监听 - */ - abstract fun observeRequestState() - - /** * 初始化业务逻辑 */ abstract fun initEvent() diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java new file mode 100644 index 0000000..7a18c20 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java @@ -0,0 +1,255 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 从平台下载的标识器本地库实体类 + */ +@Entity(tableName = "marker_detail") +public class MarkerBean { + @PrimaryKey(autoGenerate = true) + private long id; //主键ID + private String pipelineType; // 管线类型 + private String pipelineDiameter; // 管线直径 + private String pipelineMaterial; // 管材 + private String buryMethod; // 埋设方式 + private String buryDepth; // 埋深 + private String area; // 所属区域 + private String line; // 所属线路 + private String road; // 所属道路 + private String constructTime; // 建设年代 + private String owner; // 权属单位 + private String objectId; // 标识对象ID,无实际用途 + private String markerId; // 标识器ID + private String markerType; // 标识器类型 + private String markerDepth; // 标识器埋深 + private String installationDept; // 安装部门 + private String lng; // 经度 + private String lat; // 纬度 + private String updateTime; // 最后修改时间,更新时间 + private String remark; // 备注信息 + private String underlyingPipelineType; // 下层管线类型 + private String underlyingPipelineDepth; // 下层埋深 + private String underlyingPipelineDiameter; // 下层管径 + private String underlyingPipelineMaterial; // 下层管材 + private String objectType; //标识对象类型 + private String color; // 颜色 + private String imagePath; // 图片路径 + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getPipelineType() { + return pipelineType; + } + + public void setPipelineType(String pipelineType) { + this.pipelineType = pipelineType; + } + + public String getPipelineDiameter() { + return pipelineDiameter; + } + + public void setPipelineDiameter(String pipelineDiameter) { + this.pipelineDiameter = pipelineDiameter; + } + + public String getPipelineMaterial() { + return pipelineMaterial; + } + + public void setPipelineMaterial(String pipelineMaterial) { + this.pipelineMaterial = pipelineMaterial; + } + + public String getBuryMethod() { + return buryMethod; + } + + public void setBuryMethod(String buryMethod) { + this.buryMethod = buryMethod; + } + + public String getBuryDepth() { + return buryDepth; + } + + public void setBuryDepth(String buryDepth) { + this.buryDepth = buryDepth; + } + + public String getArea() { + return area; + } + + public void setArea(String area) { + this.area = area; + } + + public String getLine() { + return line; + } + + public void setLine(String line) { + this.line = line; + } + + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + + public String getConstructTime() { + return constructTime; + } + + public void setConstructTime(String constructTime) { + this.constructTime = constructTime; + } + + public String getOwner() { + return owner; + } + + public void setOwner(String owner) { + this.owner = owner; + } + + public String getObjectId() { + return objectId; + } + + public void setObjectId(String objectId) { + this.objectId = objectId; + } + + public String getMarkerId() { + return markerId; + } + + public void setMarkerId(String markerId) { + this.markerId = markerId; + } + + public String getMarkerType() { + return markerType; + } + + public void setMarkerType(String markerType) { + this.markerType = markerType; + } + + public String getMarkerDepth() { + return markerDepth; + } + + public void setMarkerDepth(String markerDepth) { + this.markerDepth = markerDepth; + } + + public String getInstallationDept() { + return installationDept; + } + + public void setInstallationDept(String installationDept) { + this.installationDept = installationDept; + } + + public String getLng() { + return lng; + } + + public void setLng(String lng) { + this.lng = lng; + } + + public String getLat() { + return lat; + } + + public void setLat(String lat) { + this.lat = lat; + } + + public String getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } + + public String getUnderlyingPipelineType() { + return underlyingPipelineType; + } + + public void setUnderlyingPipelineType(String underlyingPipelineType) { + this.underlyingPipelineType = underlyingPipelineType; + } + + public String getUnderlyingPipelineDepth() { + return underlyingPipelineDepth; + } + + public void setUnderlyingPipelineDepth(String underlyingPipelineDepth) { + this.underlyingPipelineDepth = underlyingPipelineDepth; + } + + public String getUnderlyingPipelineDiameter() { + return underlyingPipelineDiameter; + } + + public void setUnderlyingPipelineDiameter(String underlyingPipelineDiameter) { + this.underlyingPipelineDiameter = underlyingPipelineDiameter; + } + + public String getUnderlyingPipelineMaterial() { + return underlyingPipelineMaterial; + } + + public void setUnderlyingPipelineMaterial(String underlyingPipelineMaterial) { + this.underlyingPipelineMaterial = underlyingPipelineMaterial; + } + + public String getObjectType() { + return objectType; + } + + public void setObjectType(String objectType) { + this.objectType = objectType; + } + + public String getColor() { + return color; + } + + public void setColor(String color) { + this.color = color; + } + + public String getImagePath() { + return imagePath; + } + + public void setImagePath(String imagePath) { + this.imagePath = imagePath; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java deleted file mode 100644 index 3f2fcdc..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java +++ /dev/null @@ -1,327 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 从平台下载的标识器本地库实体类 - */ -@Entity -public class MarkerLocalBean { - @Id(autoincrement = true) - private Long id;//本地库主键ID - - // 管线类型 - private String pipelineType; - // 管线直径 - private String pipelineDiameter; - // 管材 - private String pipelineMaterial; - // 埋设方式 - private String buryMethod; - // 埋深 - private String buryDepth; - // 所属区域 - private String area; - // 所属线路 - private String line; - // 所属道路 - private String road; - // 建设年代 - private String constructTime; - // 权属单位 - private String owner; - //标识对象ID,无实际用途 - @Deprecated - private String objectId; - // 标识器ID - private String markerId; - // 标识器类型 - private String markerType; - // 标识器埋深 - private String markerDepth; - // 安装部门 - private String installationDept; - // 经度 - private String lng; - // 纬度 - private String lat; - //最后修改时间,更新时间 - private String updateTime; - // 备注信息 - private String remark; - // 下层管线类型 - private String underlyingPipelineType; - // 下层埋深 - private String underlyingPipelineDepth; - // 下层管径 - private String underlyingPipelineDiameter; - // 下层管材 - private String underlyingPipelineMaterial; - //标识对象类型 - private String objectType; - // 颜色 - private String color; - // 图片路径 - private String imagePath; - - @Generated(hash = 1479045776) - public MarkerLocalBean(Long id, String pipelineType, String pipelineDiameter, - String pipelineMaterial, String buryMethod, String buryDepth, - String area, String line, String road, String constructTime, - String owner, String objectId, String markerId, String markerType, - String markerDepth, String installationDept, String lng, String lat, - String updateTime, String remark, String underlyingPipelineType, - String underlyingPipelineDepth, String underlyingPipelineDiameter, - String underlyingPipelineMaterial, String objectType, String color, - String imagePath) { - this.id = id; - this.pipelineType = pipelineType; - this.pipelineDiameter = pipelineDiameter; - this.pipelineMaterial = pipelineMaterial; - this.buryMethod = buryMethod; - this.buryDepth = buryDepth; - this.area = area; - this.line = line; - this.road = road; - this.constructTime = constructTime; - this.owner = owner; - this.objectId = objectId; - this.markerId = markerId; - this.markerType = markerType; - this.markerDepth = markerDepth; - this.installationDept = installationDept; - this.lng = lng; - this.lat = lat; - this.updateTime = updateTime; - this.remark = remark; - this.underlyingPipelineType = underlyingPipelineType; - this.underlyingPipelineDepth = underlyingPipelineDepth; - this.underlyingPipelineDiameter = underlyingPipelineDiameter; - this.underlyingPipelineMaterial = underlyingPipelineMaterial; - this.objectType = objectType; - this.color = color; - this.imagePath = imagePath; - } - - @Generated(hash = 1538606012) - public MarkerLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getPipelineType() { - return this.pipelineType; - } - - public void setPipelineType(String pipelineType) { - this.pipelineType = pipelineType; - } - - public String getPipelineDiameter() { - return this.pipelineDiameter; - } - - public void setPipelineDiameter(String pipelineDiameter) { - this.pipelineDiameter = pipelineDiameter; - } - - public String getPipelineMaterial() { - return this.pipelineMaterial; - } - - public void setPipelineMaterial(String pipelineMaterial) { - this.pipelineMaterial = pipelineMaterial; - } - - public String getBuryMethod() { - return this.buryMethod; - } - - public void setBuryMethod(String buryMethod) { - this.buryMethod = buryMethod; - } - - public String getBuryDepth() { - return this.buryDepth; - } - - public void setBuryDepth(String buryDepth) { - this.buryDepth = buryDepth; - } - - public String getArea() { - return this.area; - } - - public void setArea(String area) { - this.area = area; - } - - public String getLine() { - return this.line; - } - - public void setLine(String line) { - this.line = line; - } - - public String getRoad() { - return this.road; - } - - public void setRoad(String road) { - this.road = road; - } - - public String getConstructTime() { - return this.constructTime; - } - - public void setConstructTime(String constructTime) { - this.constructTime = constructTime; - } - - public String getOwner() { - return this.owner; - } - - public void setOwner(String owner) { - this.owner = owner; - } - - public String getObjectId() { - return this.objectId; - } - - public void setObjectId(String objectId) { - this.objectId = objectId; - } - - public String getMarkerId() { - return this.markerId; - } - - public void setMarkerId(String markerId) { - this.markerId = markerId; - } - - public String getMarkerType() { - return this.markerType; - } - - public void setMarkerType(String markerType) { - this.markerType = markerType; - } - - public String getMarkerDepth() { - return this.markerDepth; - } - - public void setMarkerDepth(String markerDepth) { - this.markerDepth = markerDepth; - } - - public String getInstallationDept() { - return this.installationDept; - } - - public void setInstallationDept(String installationDept) { - this.installationDept = installationDept; - } - - public String getLng() { - return this.lng; - } - - public void setLng(String lng) { - this.lng = lng; - } - - public String getLat() { - return this.lat; - } - - public void setLat(String lat) { - this.lat = lat; - } - - public String getUpdateTime() { - return this.updateTime; - } - - public void setUpdateTime(String updateTime) { - this.updateTime = updateTime; - } - - public String getRemark() { - return this.remark; - } - - public void setRemark(String remark) { - this.remark = remark; - } - - public String getUnderlyingPipelineType() { - return this.underlyingPipelineType; - } - - public void setUnderlyingPipelineType(String underlyingPipelineType) { - this.underlyingPipelineType = underlyingPipelineType; - } - - public String getUnderlyingPipelineDepth() { - return this.underlyingPipelineDepth; - } - - public void setUnderlyingPipelineDepth(String underlyingPipelineDepth) { - this.underlyingPipelineDepth = underlyingPipelineDepth; - } - - public String getUnderlyingPipelineDiameter() { - return this.underlyingPipelineDiameter; - } - - public void setUnderlyingPipelineDiameter(String underlyingPipelineDiameter) { - this.underlyingPipelineDiameter = underlyingPipelineDiameter; - } - - public String getUnderlyingPipelineMaterial() { - return this.underlyingPipelineMaterial; - } - - public void setUnderlyingPipelineMaterial(String underlyingPipelineMaterial) { - this.underlyingPipelineMaterial = underlyingPipelineMaterial; - } - - public String getObjectType() { - return this.objectType; - } - - public void setObjectType(String objectType) { - this.objectType = objectType; - } - - public String getColor() { - return this.color; - } - - public void setColor(String color) { - this.color = color; - } - - public String getImagePath() { - return this.imagePath; - } - - public void setImagePath(String imagePath) { - this.imagePath = imagePath; - } -} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java new file mode 100644 index 0000000..5c88fdf --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java @@ -0,0 +1,93 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 巡检任务本地库实体类,不包含任务里面需要巡检的标识器信息 + */ +@Entity(tableName = "task_detail") +public class TaskBean { + @PrimaryKey(autoGenerate = true) + private long id;//主键ID + private String taskCode; // 任务编号 + private String description; // 任务名称 + private String createTime; // 任务创建的时间 + private String status; // 任务状态 + private String createUserName; // 任务创建者名称 + private String startTime; // 任务被开始执行的时间 + private String endTime; // 任务执行结束的时间 + private String isFree; // 是否自由巡检。1-是,0-否 + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getTaskCode() { + return taskCode; + } + + public void setTaskCode(String taskCode) { + this.taskCode = taskCode; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getCreateUserName() { + return createUserName; + } + + public void setCreateUserName(String createUserName) { + this.createUserName = createUserName; + } + + public String getStartTime() { + return startTime; + } + + public void setStartTime(String startTime) { + this.startTime = startTime; + } + + public String getEndTime() { + return endTime; + } + + public void setEndTime(String endTime) { + this.endTime = endTime; + } + + public String getIsFree() { + return isFree; + } + + public void setIsFree(String isFree) { + this.isFree = isFree; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java deleted file mode 100644 index 91737b3..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java +++ /dev/null @@ -1,114 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 巡检任务本地库实体类,不包含任务里面需要巡检的标识器信息 - */ -@Entity -public class TaskLocalBean { - @Id - private Long id;//任务ID - - private String taskCode;//任务编号 - private String description;//任务名称 - private String createTime;//任务创建的时间 - private String status;//任务状态 - private String createUserName;//任务创建者名称 - private String startTime;//任务被开始执行的时间 - private String endTime;//任务执行结束的时间 - private String isFreeTask;//是否自由巡检。1-是,0-否 - - @Generated(hash = 1482022528) - public TaskLocalBean(Long id, String taskCode, String description, - String createTime, String status, String createUserName, - String startTime, String endTime, String isFreeTask) { - this.id = id; - this.taskCode = taskCode; - this.description = description; - this.createTime = createTime; - this.status = status; - this.createUserName = createUserName; - this.startTime = startTime; - this.endTime = endTime; - this.isFreeTask = isFreeTask; - } - - @Generated(hash = 949704588) - public TaskLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getTaskCode() { - return this.taskCode; - } - - public void setTaskCode(String taskCode) { - this.taskCode = taskCode; - } - - public String getDescription() { - return this.description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getCreateTime() { - return this.createTime; - } - - public void setCreateTime(String createTime) { - this.createTime = createTime; - } - - public String getStatus() { - return this.status; - } - - public void setStatus(String status) { - this.status = status; - } - - public String getCreateUserName() { - return this.createUserName; - } - - public void setCreateUserName(String createUserName) { - this.createUserName = createUserName; - } - - public String getStartTime() { - return this.startTime; - } - - public void setStartTime(String startTime) { - this.startTime = startTime; - } - - public String getEndTime() { - return this.endTime; - } - - public void setEndTime(String endTime) { - this.endTime = endTime; - } - - public String getIsFreeTask() { - return this.isFreeTask; - } - - public void setIsFreeTask(String isFreeTask) { - this.isFreeTask = isFreeTask; - } -} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerBean.java new file mode 100644 index 0000000..c563a60 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerBean.java @@ -0,0 +1,110 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 巡检任务里面需要巡检的标识器信息本地库实体类 + */ +@Entity(tableName = "task_marker_info") +public class TaskMarkerBean { + //标识器后台库的主键ID,不是标识器实际ID + @PrimaryKey(autoGenerate = true) + private long id; + + /** + * 任务ID,通过此字段关联[TaskBean.id] + */ + private String taskId; + + /** + * 任务Code,通过此字段关联[TaskBean.taskCode] + *

+ *

+ * 双重验证,防止出现同时刻重复的情况 + */ + private String taskCode; + + /** + * 对应后台字段[TaskModel.MessageModel.TaskDetailInfosModel.markerIdReal],也就是探测仪扫描出来的ID + */ + private String markerId; + + private Double lng; + private Double lat; + + /** + * 是否已被探测到 + * 1-是,0-否 + */ + private String isDetected; + + /** + * 被探测到的时间,对应后台字段[TaskModel.MessageModel.TaskDetailInfosModel.finishTime] + */ + private String detectedTime; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getTaskId() { + return taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getTaskCode() { + return taskCode; + } + + public void setTaskCode(String taskCode) { + this.taskCode = taskCode; + } + + public String getMarkerId() { + return markerId; + } + + public void setMarkerId(String markerId) { + this.markerId = markerId; + } + + public Double getLng() { + return lng; + } + + public void setLng(Double lng) { + this.lng = lng; + } + + public Double getLat() { + return lat; + } + + public void setLat(Double lat) { + this.lat = lat; + } + + public String getIsDetected() { + return isDetected; + } + + public void setIsDetected(String isDetected) { + this.isDetected = isDetected; + } + + public String getDetectedTime() { + return detectedTime; + } + + public void setDetectedTime(String detectedTime) { + this.detectedTime = detectedTime; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerLocalBean.java deleted file mode 100644 index de9f459..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerLocalBean.java +++ /dev/null @@ -1,128 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import com.casic.common.detector.gd.model.TaskModel; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 巡检任务里面需要巡检的标识器信息本地库实体类 - */ -@Entity -public class TaskMarkerLocalBean { - @Id - private Long id;//标识器后台库的主键ID,不是标识器实际ID - - /** - * 任务ID,通过此字段关联{@link TaskLocalBean#id} - */ - private String taskId; - - /** - * 任务Code,通过此字段关联{@link TaskLocalBean#taskCode} - *

- * 双重验证,防止出现同时刻重复的情况 - */ - private String taskCode; - - /** - * 对应后台字段{@link TaskModel.MessageModel.TaskDetailInfosModel#markerIdReal},也就是探测仪扫描出来的ID - */ - private String markerId; - - private double lng; - private double lat; - - /** - * 是否已被探测到 - * 1-是,0-否 - */ - private String isDetected; - - /** - * 被探测到的时间,对应后台字段{@link TaskModel.MessageModel.TaskDetailInfosModel#finishTime} - */ - private String detectedTime; - - @Generated(hash = 677328533) - public TaskMarkerLocalBean(Long id, String taskId, String taskCode, String markerId, - double lng, double lat, String isDetected, String detectedTime) { - this.id = id; - this.taskId = taskId; - this.taskCode = taskCode; - this.markerId = markerId; - this.lng = lng; - this.lat = lat; - this.isDetected = isDetected; - this.detectedTime = detectedTime; - } - - @Generated(hash = 1162404642) - public TaskMarkerLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getTaskId() { - return this.taskId; - } - - public void setTaskId(String taskId) { - this.taskId = taskId; - } - - public String getTaskCode() { - return this.taskCode; - } - - public void setTaskCode(String taskCode) { - this.taskCode = taskCode; - } - - public String getMarkerId() { - return this.markerId; - } - - public void setMarkerId(String markerId) { - this.markerId = markerId; - } - - public double getLng() { - return this.lng; - } - - public void setLng(double lng) { - this.lng = lng; - } - - public double getLat() { - return this.lat; - } - - public void setLat(double lat) { - this.lat = lat; - } - - public String getIsDetected() { - return this.isDetected; - } - - public void setIsDetected(String isDetected) { - this.isDetected = isDetected; - } - - public String getDetectedTime() { - return this.detectedTime; - } - - public void setDetectedTime(String detectedTime) { - this.detectedTime = detectedTime; - } -} diff --git a/app/src/main/java/com/casic/common/detector/gd/dao/MarkerBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/dao/MarkerBeanDao.java new file mode 100644 index 0000000..2beb7ed --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/dao/MarkerBeanDao.java @@ -0,0 +1,29 @@ +package com.casic.common.detector.gd.dao; + +import androidx.room.Dao; +import androidx.room.Insert; +import androidx.room.Query; +import androidx.room.RawQuery; +import androidx.sqlite.db.SupportSQLiteQuery; + +import com.casic.common.detector.gd.bean.MarkerBean; + +import java.util.List; + +@Dao +public interface MarkerBeanDao { + @Query("DELETE FROM marker_detail") + void deleteAll(); + + @Insert + void insert(MarkerBean marker); + + @Query("SELECT * FROM marker_detail") + List loadAll(); + + @Query("SELECT * FROM marker_detail WHERE markerId = :markerId") + List queryMarkerById(String markerId); + + @RawQuery + List loadMarkersByCondition(SupportSQLiteQuery query); +} diff --git a/app/src/main/java/com/casic/common/detector/gd/dao/TaskBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/dao/TaskBeanDao.java new file mode 100644 index 0000000..9c70ac2 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/dao/TaskBeanDao.java @@ -0,0 +1,120 @@ +package com.casic.common.detector.gd.dao; + +import androidx.room.Dao; +import androidx.room.Insert; +import androidx.room.Query; +import androidx.room.Transaction; + +import com.casic.common.detector.gd.bean.TaskBean; +import com.casic.common.detector.gd.bean.TaskMarkerBean; +import com.casic.common.detector.gd.model.TaskDetailLocalModel; +import com.casic.common.detector.gd.model.TaskModel; +import com.casic.common.detector.gd.utils.LocaleConstant; +import com.pengxh.kt.lite.utils.SaveKeyValues; + +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Locale; + +@Dao +public interface TaskBeanDao { + @Query("SELECT COUNT(*) FROM task_detail WHERE id = :taskId") + int isTaskExist(long taskId); + + @Insert + void insert(TaskBean task); + + default void saveTask(Long taskId, String taskName) { + if (isTaskExist(taskId) == 0) { + TaskBean task = new TaskBean(); + task.setId(taskId); + task.setTaskCode(new SimpleDateFormat("yyyyMMddHHmmss", Locale.CHINA).format(new Date())); + task.setDescription(taskName); + String time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA).format(new Date()); + task.setCreateTime(time); + task.setStatus("0"); + String userName = (String) SaveKeyValues.INSTANCE.getValue(LocaleConstant.USER_NAME, ""); + task.setCreateUserName(userName); + task.setStartTime(time); + task.setEndTime(""); + task.setIsFree("1"); + insert(task); + } + } + + default void saveTask(TaskModel.MessageModel model) { + TaskBean task = new TaskBean(); + task.setId(model.getId()); + task.setTaskCode(model.getTaskCode()); + task.setDescription(model.getDescription()); + task.setCreateTime(model.getDeployDate()); + task.setStatus(model.getStatus()); + task.setCreateUserName(model.getCreatorName()); + task.setStartTime(model.getBeginDate()); + task.setEndTime(model.getEndDate()); + task.setIsFree("0"); + if (isTaskExist(task.getId()) == 0) { + insert(task); + } + } + + @Query("SELECT * FROM task_detail") + List loadAll(); + + @Transaction + default ArrayList loadLocalTask(TaskMarkerBeanDao taskMarkerBeanDao) { + ArrayList result = new ArrayList<>(); + List tasks = loadAll(); + for (TaskBean it : tasks) { + TaskDetailLocalModel model = new TaskDetailLocalModel(); + model.setTaskId(String.valueOf(it.getId())); + model.setTaskCode(it.getTaskCode()); + model.setDescription(it.getDescription()); + model.setCreateTime(it.getCreateTime()); + model.setStatus(it.getStatus()); + model.setCreateUserName(it.getCreateUserName()); + model.setIsFreeTask(it.getIsFree()); + ArrayList results = new ArrayList<>(); + if ("0".equals(it.getIsFree())) { + // 非自由巡检才有Marker + List markers = taskMarkerBeanDao.getMarkersByIdAndCode(String.valueOf(it.getId()), it.getTaskCode()); + for (TaskMarkerBean marker : markers) { + TaskDetailLocalModel.TaskMarkerLocalModel localModel = new TaskDetailLocalModel.TaskMarkerLocalModel(); + localModel.setMarkerId(marker.getMarkerId()); + localModel.setLng(marker.getLng()); + localModel.setLat(marker.getLat()); + localModel.setIsDetected(marker.getIsDetected()); + localModel.setDetectedTime(marker.getDetectedTime()); + + results.add(localModel); + } + } + model.setMarkerModels(results); + result.add(model); + } + return result; + } + + @Query("DELETE FROM task_detail WHERE id = :taskId AND taskCode = :taskCode") + void deleteTaskById(long taskId, String taskCode); + + @Transaction + default void deleteLocalTaskById(long taskId, String taskCode, TaskMarkerBeanDao taskMarkerBeanDao) { + TaskBean task = loadAll().stream() + .filter(it -> it.getId() == taskId && taskCode.equals(it.getTaskCode())) + .findFirst() + .orElse(null); + if (task == null) return; + deleteTaskById(taskId, taskCode); + + // 删除此任务关联的Marker。非自由巡检才有Marker + if ("0".equals(task.getIsFree())) { + List markers = taskMarkerBeanDao.getMarkersByIdAndCode(String.valueOf(task.getId()), task.getTaskCode()); + for (TaskMarkerBean marker : markers) { + taskMarkerBeanDao.delete(marker); + } + } + } +} \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index d0cb423..921c8c8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,25 +1,20 @@ import java.text.SimpleDateFormat -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply plugin: 'org.greenrobot.greendao' +plugins { + id('com.android.application') + id('org.jetbrains.kotlin.android') +} android { - compileSdkVersion 33 + namespace 'com.casic.common.detector.gd' + compileSdk 35 defaultConfig { - applicationId "com.casic.common.detector.gd" - minSdkVersion 26 - targetSdkVersion 33 + applicationId 'com.casic.common.detector.gd' + minSdk 26 + targetSdk 35 versionCode 5092 - versionName "5.0.9.2" - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } + versionName '5.0.9.2' } signingConfigs { @@ -31,6 +26,14 @@ } } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + signingConfig signingConfigs.release + } + } + compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 @@ -47,27 +50,16 @@ } } - kotlin { - experimental { - coroutines 'enable' - } - } - buildFeatures { + buildConfig true viewBinding true } - applicationVariants.configureEach { variant -> - variant.outputs.configureEach { - outputFileName = "COM_TCY_" + getBuildDate() + "_" + defaultConfig.versionName + ".apk" + applicationVariants.configureEach { + outputs.configureEach { + outputFileName = 'COM_TCY_' + getBuildDate() + '_' + defaultConfig.versionName + '.apk' } } - - greendao { - schemaVersion 1//数据库版本号 - targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 - daoPackage "${defaultConfig.applicationId}.greendao"//设置DaoMaster、DaoSession、Dao包名 - } } static def getBuildDate() { @@ -76,27 +68,22 @@ } dependencies { - //基础依赖库 - implementation 'com.github.AndroidCoderPeng:Kotlin-lite-lib:1.1.4' - implementation 'androidx.core:core-ktx:1.9.0' - def base_version = "1.6.1" - implementation "androidx.appcompat:appcompat:${base_version}" - implementation "com.google.android.material:material:${base_version}" + implementation 'com.github.AndroidCoderPeng:Kotlin-lite-lib:1.1.5' + implementation 'androidx.core:core-ktx:1.13.1' + implementation 'androidx.appcompat:appcompat:1.7.0' + implementation 'com.google.android.material:material:1.12.0' //Google官方授权框架 implementation 'pub.devrel:easypermissions:3.0.0' - //沉浸式状态栏。基础依赖包,必须要依赖 - implementation 'com.gyf.immersionbar:immersionbar:3.0.0' - //fragment快速实现 - implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0' + //沉浸式状态栏 + implementation 'com.geyifeng.immersionbar:immersionbar:3.2.2' //官方Json解析库 implementation 'com.google.code.gson:gson:2.10.1' - def vm_version = '2.5.1' //Kotlin协程 - implementation "androidx.lifecycle:lifecycle-runtime-ktx:${vm_version}" + implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.2' //MVVM+LiveData - implementation "androidx.lifecycle:lifecycle-livedata-ktx:${vm_version}" - implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:${vm_version}" - implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.6.2' + implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2' + implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' //返回值转换器 implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' @@ -105,9 +92,10 @@ implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' //网络请求和接口封装 implementation 'com.squareup.retrofit2:retrofit:2.9.0' - implementation 'com.squareup.okhttp3:okhttp:4.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.12.0' //数据库框架 - implementation 'org.greenrobot:greendao:3.3.0' + implementation 'androidx.room:room-runtime:2.6.1' + annotationProcessor 'androidx.room:room-compiler:2.5.2' //高德导航、定位、地图三合一 implementation 'com.amap.api:navi-3dmap:latest.integration' //经纬度逆编码 @@ -115,7 +103,7 @@ //excel implementation 'net.sourceforge.jexcelapi:jxl:2.6.12' //图片加载框架 - implementation 'com.github.bumptech.glide:glide:4.9.0' + implementation 'com.github.bumptech.glide:glide:4.12.0' //图片选择框架 implementation 'io.github.lucksiege:pictureselector:v3.11.1' //大图 diff --git a/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt b/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt index 7b695ff..50ba734 100644 --- a/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt +++ b/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt @@ -4,9 +4,9 @@ import android.app.Application import android.os.Bundle import android.util.Log -import com.casic.common.detector.gd.greendao.DaoMaster -import com.casic.common.detector.gd.greendao.DaoSession +import androidx.room.Room.databaseBuilder import com.casic.common.detector.gd.uart.SerialPort +import com.casic.common.detector.gd.utils.DetectorDataBase import com.casic.common.detector.gd.utils.GpioManager import com.pengxh.kt.lite.extensions.show import com.pengxh.kt.lite.utils.SaveKeyValues @@ -43,44 +43,42 @@ private var application: BaseApplication by Delegates.notNull() fun get() = application - - private lateinit var daoSession: DaoSession } + lateinit var dataBase: DetectorDataBase + override fun onCreate() { super.onCreate() application = this SaveKeyValues.initSharedPreferences(this) CrashReport.initCrashReport(this, "01e80d3a74", true) - val devOpenHelper = DaoMaster.DevOpenHelper(this, "Detector.db", null) - val daoMaster = DaoMaster(devOpenHelper.writableDatabase) - daoSession = daoMaster.newSession() + dataBase = databaseBuilder(this, DetectorDataBase::class.java, "Detector.db") + .allowMainThreadQueries() + .build() /** * Open the serial port * */ try { serialPorts.apply { - add(SerialPort(File("/dev/ttysWK1"), 9600, 0)) - //千寻报文数据下发串口号 - add(SerialPort(File("/dev/ttyS1"), 9600, 0)) + add(SerialPort(File("/dev/ttysWK1"), 9600, 0)) //信号通讯串口 + add(SerialPort(File("/dev/ttyS1"), 9600, 0)) //千寻报文数据下发串口号 } Log.d(kTag, "onCreate: 已初始化 ${serialPorts.size} 个串口") } catch (e: SecurityException) { "您没有串口的读写权限!".show(this) + e.printStackTrace() } catch (e: IOException) { "因为不明原因,串口无法打开!".show(this) + e.printStackTrace() } catch (e: InvalidParameterException) { "请检查串口!".show(this) + e.printStackTrace() } registerActivityLifecycleCallbacks(this) } - fun getDaoSession(): DaoSession { - return daoSession - } - override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) { } diff --git a/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt b/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt index 053b9dd..1d0c9e3 100644 --- a/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt +++ b/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt @@ -14,12 +14,10 @@ import com.casic.common.detector.gd.utils.SerialPortCommand import com.pengxh.kt.lite.utils.WeakReferenceHandler import java.io.IOException -import java.util.Timer abstract class SerialPortBaseActivity : AppCompatActivity(), Handler.Callback { private val kTag = "SerialPortBaseActivity" - private val taskTimer by lazy { Timer() } private val weakReferenceHandler by lazy { WeakReferenceHandler(this) } private val serialPorts by lazy { BaseApplication.get().getSerialPorts() } protected lateinit var binding: VB @@ -30,7 +28,6 @@ setContentView(binding.root) setupTopBarLayout() initOnCreate(savedInstanceState) - observeRequestState() initEvent() if (serialPorts.isNotEmpty()) { @@ -71,11 +68,6 @@ abstract fun initOnCreate(savedInstanceState: Bundle?) /** - * 数据请求状态监听 - */ - abstract fun observeRequestState() - - /** * 初始化业务逻辑 */ abstract fun initEvent() diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java new file mode 100644 index 0000000..7a18c20 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java @@ -0,0 +1,255 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 从平台下载的标识器本地库实体类 + */ +@Entity(tableName = "marker_detail") +public class MarkerBean { + @PrimaryKey(autoGenerate = true) + private long id; //主键ID + private String pipelineType; // 管线类型 + private String pipelineDiameter; // 管线直径 + private String pipelineMaterial; // 管材 + private String buryMethod; // 埋设方式 + private String buryDepth; // 埋深 + private String area; // 所属区域 + private String line; // 所属线路 + private String road; // 所属道路 + private String constructTime; // 建设年代 + private String owner; // 权属单位 + private String objectId; // 标识对象ID,无实际用途 + private String markerId; // 标识器ID + private String markerType; // 标识器类型 + private String markerDepth; // 标识器埋深 + private String installationDept; // 安装部门 + private String lng; // 经度 + private String lat; // 纬度 + private String updateTime; // 最后修改时间,更新时间 + private String remark; // 备注信息 + private String underlyingPipelineType; // 下层管线类型 + private String underlyingPipelineDepth; // 下层埋深 + private String underlyingPipelineDiameter; // 下层管径 + private String underlyingPipelineMaterial; // 下层管材 + private String objectType; //标识对象类型 + private String color; // 颜色 + private String imagePath; // 图片路径 + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getPipelineType() { + return pipelineType; + } + + public void setPipelineType(String pipelineType) { + this.pipelineType = pipelineType; + } + + public String getPipelineDiameter() { + return pipelineDiameter; + } + + public void setPipelineDiameter(String pipelineDiameter) { + this.pipelineDiameter = pipelineDiameter; + } + + public String getPipelineMaterial() { + return pipelineMaterial; + } + + public void setPipelineMaterial(String pipelineMaterial) { + this.pipelineMaterial = pipelineMaterial; + } + + public String getBuryMethod() { + return buryMethod; + } + + public void setBuryMethod(String buryMethod) { + this.buryMethod = buryMethod; + } + + public String getBuryDepth() { + return buryDepth; + } + + public void setBuryDepth(String buryDepth) { + this.buryDepth = buryDepth; + } + + public String getArea() { + return area; + } + + public void setArea(String area) { + this.area = area; + } + + public String getLine() { + return line; + } + + public void setLine(String line) { + this.line = line; + } + + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + + public String getConstructTime() { + return constructTime; + } + + public void setConstructTime(String constructTime) { + this.constructTime = constructTime; + } + + public String getOwner() { + return owner; + } + + public void setOwner(String owner) { + this.owner = owner; + } + + public String getObjectId() { + return objectId; + } + + public void setObjectId(String objectId) { + this.objectId = objectId; + } + + public String getMarkerId() { + return markerId; + } + + public void setMarkerId(String markerId) { + this.markerId = markerId; + } + + public String getMarkerType() { + return markerType; + } + + public void setMarkerType(String markerType) { + this.markerType = markerType; + } + + public String getMarkerDepth() { + return markerDepth; + } + + public void setMarkerDepth(String markerDepth) { + this.markerDepth = markerDepth; + } + + public String getInstallationDept() { + return installationDept; + } + + public void setInstallationDept(String installationDept) { + this.installationDept = installationDept; + } + + public String getLng() { + return lng; + } + + public void setLng(String lng) { + this.lng = lng; + } + + public String getLat() { + return lat; + } + + public void setLat(String lat) { + this.lat = lat; + } + + public String getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } + + public String getUnderlyingPipelineType() { + return underlyingPipelineType; + } + + public void setUnderlyingPipelineType(String underlyingPipelineType) { + this.underlyingPipelineType = underlyingPipelineType; + } + + public String getUnderlyingPipelineDepth() { + return underlyingPipelineDepth; + } + + public void setUnderlyingPipelineDepth(String underlyingPipelineDepth) { + this.underlyingPipelineDepth = underlyingPipelineDepth; + } + + public String getUnderlyingPipelineDiameter() { + return underlyingPipelineDiameter; + } + + public void setUnderlyingPipelineDiameter(String underlyingPipelineDiameter) { + this.underlyingPipelineDiameter = underlyingPipelineDiameter; + } + + public String getUnderlyingPipelineMaterial() { + return underlyingPipelineMaterial; + } + + public void setUnderlyingPipelineMaterial(String underlyingPipelineMaterial) { + this.underlyingPipelineMaterial = underlyingPipelineMaterial; + } + + public String getObjectType() { + return objectType; + } + + public void setObjectType(String objectType) { + this.objectType = objectType; + } + + public String getColor() { + return color; + } + + public void setColor(String color) { + this.color = color; + } + + public String getImagePath() { + return imagePath; + } + + public void setImagePath(String imagePath) { + this.imagePath = imagePath; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java deleted file mode 100644 index 3f2fcdc..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java +++ /dev/null @@ -1,327 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 从平台下载的标识器本地库实体类 - */ -@Entity -public class MarkerLocalBean { - @Id(autoincrement = true) - private Long id;//本地库主键ID - - // 管线类型 - private String pipelineType; - // 管线直径 - private String pipelineDiameter; - // 管材 - private String pipelineMaterial; - // 埋设方式 - private String buryMethod; - // 埋深 - private String buryDepth; - // 所属区域 - private String area; - // 所属线路 - private String line; - // 所属道路 - private String road; - // 建设年代 - private String constructTime; - // 权属单位 - private String owner; - //标识对象ID,无实际用途 - @Deprecated - private String objectId; - // 标识器ID - private String markerId; - // 标识器类型 - private String markerType; - // 标识器埋深 - private String markerDepth; - // 安装部门 - private String installationDept; - // 经度 - private String lng; - // 纬度 - private String lat; - //最后修改时间,更新时间 - private String updateTime; - // 备注信息 - private String remark; - // 下层管线类型 - private String underlyingPipelineType; - // 下层埋深 - private String underlyingPipelineDepth; - // 下层管径 - private String underlyingPipelineDiameter; - // 下层管材 - private String underlyingPipelineMaterial; - //标识对象类型 - private String objectType; - // 颜色 - private String color; - // 图片路径 - private String imagePath; - - @Generated(hash = 1479045776) - public MarkerLocalBean(Long id, String pipelineType, String pipelineDiameter, - String pipelineMaterial, String buryMethod, String buryDepth, - String area, String line, String road, String constructTime, - String owner, String objectId, String markerId, String markerType, - String markerDepth, String installationDept, String lng, String lat, - String updateTime, String remark, String underlyingPipelineType, - String underlyingPipelineDepth, String underlyingPipelineDiameter, - String underlyingPipelineMaterial, String objectType, String color, - String imagePath) { - this.id = id; - this.pipelineType = pipelineType; - this.pipelineDiameter = pipelineDiameter; - this.pipelineMaterial = pipelineMaterial; - this.buryMethod = buryMethod; - this.buryDepth = buryDepth; - this.area = area; - this.line = line; - this.road = road; - this.constructTime = constructTime; - this.owner = owner; - this.objectId = objectId; - this.markerId = markerId; - this.markerType = markerType; - this.markerDepth = markerDepth; - this.installationDept = installationDept; - this.lng = lng; - this.lat = lat; - this.updateTime = updateTime; - this.remark = remark; - this.underlyingPipelineType = underlyingPipelineType; - this.underlyingPipelineDepth = underlyingPipelineDepth; - this.underlyingPipelineDiameter = underlyingPipelineDiameter; - this.underlyingPipelineMaterial = underlyingPipelineMaterial; - this.objectType = objectType; - this.color = color; - this.imagePath = imagePath; - } - - @Generated(hash = 1538606012) - public MarkerLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getPipelineType() { - return this.pipelineType; - } - - public void setPipelineType(String pipelineType) { - this.pipelineType = pipelineType; - } - - public String getPipelineDiameter() { - return this.pipelineDiameter; - } - - public void setPipelineDiameter(String pipelineDiameter) { - this.pipelineDiameter = pipelineDiameter; - } - - public String getPipelineMaterial() { - return this.pipelineMaterial; - } - - public void setPipelineMaterial(String pipelineMaterial) { - this.pipelineMaterial = pipelineMaterial; - } - - public String getBuryMethod() { - return this.buryMethod; - } - - public void setBuryMethod(String buryMethod) { - this.buryMethod = buryMethod; - } - - public String getBuryDepth() { - return this.buryDepth; - } - - public void setBuryDepth(String buryDepth) { - this.buryDepth = buryDepth; - } - - public String getArea() { - return this.area; - } - - public void setArea(String area) { - this.area = area; - } - - public String getLine() { - return this.line; - } - - public void setLine(String line) { - this.line = line; - } - - public String getRoad() { - return this.road; - } - - public void setRoad(String road) { - this.road = road; - } - - public String getConstructTime() { - return this.constructTime; - } - - public void setConstructTime(String constructTime) { - this.constructTime = constructTime; - } - - public String getOwner() { - return this.owner; - } - - public void setOwner(String owner) { - this.owner = owner; - } - - public String getObjectId() { - return this.objectId; - } - - public void setObjectId(String objectId) { - this.objectId = objectId; - } - - public String getMarkerId() { - return this.markerId; - } - - public void setMarkerId(String markerId) { - this.markerId = markerId; - } - - public String getMarkerType() { - return this.markerType; - } - - public void setMarkerType(String markerType) { - this.markerType = markerType; - } - - public String getMarkerDepth() { - return this.markerDepth; - } - - public void setMarkerDepth(String markerDepth) { - this.markerDepth = markerDepth; - } - - public String getInstallationDept() { - return this.installationDept; - } - - public void setInstallationDept(String installationDept) { - this.installationDept = installationDept; - } - - public String getLng() { - return this.lng; - } - - public void setLng(String lng) { - this.lng = lng; - } - - public String getLat() { - return this.lat; - } - - public void setLat(String lat) { - this.lat = lat; - } - - public String getUpdateTime() { - return this.updateTime; - } - - public void setUpdateTime(String updateTime) { - this.updateTime = updateTime; - } - - public String getRemark() { - return this.remark; - } - - public void setRemark(String remark) { - this.remark = remark; - } - - public String getUnderlyingPipelineType() { - return this.underlyingPipelineType; - } - - public void setUnderlyingPipelineType(String underlyingPipelineType) { - this.underlyingPipelineType = underlyingPipelineType; - } - - public String getUnderlyingPipelineDepth() { - return this.underlyingPipelineDepth; - } - - public void setUnderlyingPipelineDepth(String underlyingPipelineDepth) { - this.underlyingPipelineDepth = underlyingPipelineDepth; - } - - public String getUnderlyingPipelineDiameter() { - return this.underlyingPipelineDiameter; - } - - public void setUnderlyingPipelineDiameter(String underlyingPipelineDiameter) { - this.underlyingPipelineDiameter = underlyingPipelineDiameter; - } - - public String getUnderlyingPipelineMaterial() { - return this.underlyingPipelineMaterial; - } - - public void setUnderlyingPipelineMaterial(String underlyingPipelineMaterial) { - this.underlyingPipelineMaterial = underlyingPipelineMaterial; - } - - public String getObjectType() { - return this.objectType; - } - - public void setObjectType(String objectType) { - this.objectType = objectType; - } - - public String getColor() { - return this.color; - } - - public void setColor(String color) { - this.color = color; - } - - public String getImagePath() { - return this.imagePath; - } - - public void setImagePath(String imagePath) { - this.imagePath = imagePath; - } -} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java new file mode 100644 index 0000000..5c88fdf --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java @@ -0,0 +1,93 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 巡检任务本地库实体类,不包含任务里面需要巡检的标识器信息 + */ +@Entity(tableName = "task_detail") +public class TaskBean { + @PrimaryKey(autoGenerate = true) + private long id;//主键ID + private String taskCode; // 任务编号 + private String description; // 任务名称 + private String createTime; // 任务创建的时间 + private String status; // 任务状态 + private String createUserName; // 任务创建者名称 + private String startTime; // 任务被开始执行的时间 + private String endTime; // 任务执行结束的时间 + private String isFree; // 是否自由巡检。1-是,0-否 + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getTaskCode() { + return taskCode; + } + + public void setTaskCode(String taskCode) { + this.taskCode = taskCode; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getCreateUserName() { + return createUserName; + } + + public void setCreateUserName(String createUserName) { + this.createUserName = createUserName; + } + + public String getStartTime() { + return startTime; + } + + public void setStartTime(String startTime) { + this.startTime = startTime; + } + + public String getEndTime() { + return endTime; + } + + public void setEndTime(String endTime) { + this.endTime = endTime; + } + + public String getIsFree() { + return isFree; + } + + public void setIsFree(String isFree) { + this.isFree = isFree; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java deleted file mode 100644 index 91737b3..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java +++ /dev/null @@ -1,114 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 巡检任务本地库实体类,不包含任务里面需要巡检的标识器信息 - */ -@Entity -public class TaskLocalBean { - @Id - private Long id;//任务ID - - private String taskCode;//任务编号 - private String description;//任务名称 - private String createTime;//任务创建的时间 - private String status;//任务状态 - private String createUserName;//任务创建者名称 - private String startTime;//任务被开始执行的时间 - private String endTime;//任务执行结束的时间 - private String isFreeTask;//是否自由巡检。1-是,0-否 - - @Generated(hash = 1482022528) - public TaskLocalBean(Long id, String taskCode, String description, - String createTime, String status, String createUserName, - String startTime, String endTime, String isFreeTask) { - this.id = id; - this.taskCode = taskCode; - this.description = description; - this.createTime = createTime; - this.status = status; - this.createUserName = createUserName; - this.startTime = startTime; - this.endTime = endTime; - this.isFreeTask = isFreeTask; - } - - @Generated(hash = 949704588) - public TaskLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getTaskCode() { - return this.taskCode; - } - - public void setTaskCode(String taskCode) { - this.taskCode = taskCode; - } - - public String getDescription() { - return this.description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getCreateTime() { - return this.createTime; - } - - public void setCreateTime(String createTime) { - this.createTime = createTime; - } - - public String getStatus() { - return this.status; - } - - public void setStatus(String status) { - this.status = status; - } - - public String getCreateUserName() { - return this.createUserName; - } - - public void setCreateUserName(String createUserName) { - this.createUserName = createUserName; - } - - public String getStartTime() { - return this.startTime; - } - - public void setStartTime(String startTime) { - this.startTime = startTime; - } - - public String getEndTime() { - return this.endTime; - } - - public void setEndTime(String endTime) { - this.endTime = endTime; - } - - public String getIsFreeTask() { - return this.isFreeTask; - } - - public void setIsFreeTask(String isFreeTask) { - this.isFreeTask = isFreeTask; - } -} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerBean.java new file mode 100644 index 0000000..c563a60 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerBean.java @@ -0,0 +1,110 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 巡检任务里面需要巡检的标识器信息本地库实体类 + */ +@Entity(tableName = "task_marker_info") +public class TaskMarkerBean { + //标识器后台库的主键ID,不是标识器实际ID + @PrimaryKey(autoGenerate = true) + private long id; + + /** + * 任务ID,通过此字段关联[TaskBean.id] + */ + private String taskId; + + /** + * 任务Code,通过此字段关联[TaskBean.taskCode] + *

+ *

+ * 双重验证,防止出现同时刻重复的情况 + */ + private String taskCode; + + /** + * 对应后台字段[TaskModel.MessageModel.TaskDetailInfosModel.markerIdReal],也就是探测仪扫描出来的ID + */ + private String markerId; + + private Double lng; + private Double lat; + + /** + * 是否已被探测到 + * 1-是,0-否 + */ + private String isDetected; + + /** + * 被探测到的时间,对应后台字段[TaskModel.MessageModel.TaskDetailInfosModel.finishTime] + */ + private String detectedTime; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getTaskId() { + return taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getTaskCode() { + return taskCode; + } + + public void setTaskCode(String taskCode) { + this.taskCode = taskCode; + } + + public String getMarkerId() { + return markerId; + } + + public void setMarkerId(String markerId) { + this.markerId = markerId; + } + + public Double getLng() { + return lng; + } + + public void setLng(Double lng) { + this.lng = lng; + } + + public Double getLat() { + return lat; + } + + public void setLat(Double lat) { + this.lat = lat; + } + + public String getIsDetected() { + return isDetected; + } + + public void setIsDetected(String isDetected) { + this.isDetected = isDetected; + } + + public String getDetectedTime() { + return detectedTime; + } + + public void setDetectedTime(String detectedTime) { + this.detectedTime = detectedTime; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerLocalBean.java deleted file mode 100644 index de9f459..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerLocalBean.java +++ /dev/null @@ -1,128 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import com.casic.common.detector.gd.model.TaskModel; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 巡检任务里面需要巡检的标识器信息本地库实体类 - */ -@Entity -public class TaskMarkerLocalBean { - @Id - private Long id;//标识器后台库的主键ID,不是标识器实际ID - - /** - * 任务ID,通过此字段关联{@link TaskLocalBean#id} - */ - private String taskId; - - /** - * 任务Code,通过此字段关联{@link TaskLocalBean#taskCode} - *

- * 双重验证,防止出现同时刻重复的情况 - */ - private String taskCode; - - /** - * 对应后台字段{@link TaskModel.MessageModel.TaskDetailInfosModel#markerIdReal},也就是探测仪扫描出来的ID - */ - private String markerId; - - private double lng; - private double lat; - - /** - * 是否已被探测到 - * 1-是,0-否 - */ - private String isDetected; - - /** - * 被探测到的时间,对应后台字段{@link TaskModel.MessageModel.TaskDetailInfosModel#finishTime} - */ - private String detectedTime; - - @Generated(hash = 677328533) - public TaskMarkerLocalBean(Long id, String taskId, String taskCode, String markerId, - double lng, double lat, String isDetected, String detectedTime) { - this.id = id; - this.taskId = taskId; - this.taskCode = taskCode; - this.markerId = markerId; - this.lng = lng; - this.lat = lat; - this.isDetected = isDetected; - this.detectedTime = detectedTime; - } - - @Generated(hash = 1162404642) - public TaskMarkerLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getTaskId() { - return this.taskId; - } - - public void setTaskId(String taskId) { - this.taskId = taskId; - } - - public String getTaskCode() { - return this.taskCode; - } - - public void setTaskCode(String taskCode) { - this.taskCode = taskCode; - } - - public String getMarkerId() { - return this.markerId; - } - - public void setMarkerId(String markerId) { - this.markerId = markerId; - } - - public double getLng() { - return this.lng; - } - - public void setLng(double lng) { - this.lng = lng; - } - - public double getLat() { - return this.lat; - } - - public void setLat(double lat) { - this.lat = lat; - } - - public String getIsDetected() { - return this.isDetected; - } - - public void setIsDetected(String isDetected) { - this.isDetected = isDetected; - } - - public String getDetectedTime() { - return this.detectedTime; - } - - public void setDetectedTime(String detectedTime) { - this.detectedTime = detectedTime; - } -} diff --git a/app/src/main/java/com/casic/common/detector/gd/dao/MarkerBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/dao/MarkerBeanDao.java new file mode 100644 index 0000000..2beb7ed --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/dao/MarkerBeanDao.java @@ -0,0 +1,29 @@ +package com.casic.common.detector.gd.dao; + +import androidx.room.Dao; +import androidx.room.Insert; +import androidx.room.Query; +import androidx.room.RawQuery; +import androidx.sqlite.db.SupportSQLiteQuery; + +import com.casic.common.detector.gd.bean.MarkerBean; + +import java.util.List; + +@Dao +public interface MarkerBeanDao { + @Query("DELETE FROM marker_detail") + void deleteAll(); + + @Insert + void insert(MarkerBean marker); + + @Query("SELECT * FROM marker_detail") + List loadAll(); + + @Query("SELECT * FROM marker_detail WHERE markerId = :markerId") + List queryMarkerById(String markerId); + + @RawQuery + List loadMarkersByCondition(SupportSQLiteQuery query); +} diff --git a/app/src/main/java/com/casic/common/detector/gd/dao/TaskBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/dao/TaskBeanDao.java new file mode 100644 index 0000000..9c70ac2 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/dao/TaskBeanDao.java @@ -0,0 +1,120 @@ +package com.casic.common.detector.gd.dao; + +import androidx.room.Dao; +import androidx.room.Insert; +import androidx.room.Query; +import androidx.room.Transaction; + +import com.casic.common.detector.gd.bean.TaskBean; +import com.casic.common.detector.gd.bean.TaskMarkerBean; +import com.casic.common.detector.gd.model.TaskDetailLocalModel; +import com.casic.common.detector.gd.model.TaskModel; +import com.casic.common.detector.gd.utils.LocaleConstant; +import com.pengxh.kt.lite.utils.SaveKeyValues; + +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Locale; + +@Dao +public interface TaskBeanDao { + @Query("SELECT COUNT(*) FROM task_detail WHERE id = :taskId") + int isTaskExist(long taskId); + + @Insert + void insert(TaskBean task); + + default void saveTask(Long taskId, String taskName) { + if (isTaskExist(taskId) == 0) { + TaskBean task = new TaskBean(); + task.setId(taskId); + task.setTaskCode(new SimpleDateFormat("yyyyMMddHHmmss", Locale.CHINA).format(new Date())); + task.setDescription(taskName); + String time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA).format(new Date()); + task.setCreateTime(time); + task.setStatus("0"); + String userName = (String) SaveKeyValues.INSTANCE.getValue(LocaleConstant.USER_NAME, ""); + task.setCreateUserName(userName); + task.setStartTime(time); + task.setEndTime(""); + task.setIsFree("1"); + insert(task); + } + } + + default void saveTask(TaskModel.MessageModel model) { + TaskBean task = new TaskBean(); + task.setId(model.getId()); + task.setTaskCode(model.getTaskCode()); + task.setDescription(model.getDescription()); + task.setCreateTime(model.getDeployDate()); + task.setStatus(model.getStatus()); + task.setCreateUserName(model.getCreatorName()); + task.setStartTime(model.getBeginDate()); + task.setEndTime(model.getEndDate()); + task.setIsFree("0"); + if (isTaskExist(task.getId()) == 0) { + insert(task); + } + } + + @Query("SELECT * FROM task_detail") + List loadAll(); + + @Transaction + default ArrayList loadLocalTask(TaskMarkerBeanDao taskMarkerBeanDao) { + ArrayList result = new ArrayList<>(); + List tasks = loadAll(); + for (TaskBean it : tasks) { + TaskDetailLocalModel model = new TaskDetailLocalModel(); + model.setTaskId(String.valueOf(it.getId())); + model.setTaskCode(it.getTaskCode()); + model.setDescription(it.getDescription()); + model.setCreateTime(it.getCreateTime()); + model.setStatus(it.getStatus()); + model.setCreateUserName(it.getCreateUserName()); + model.setIsFreeTask(it.getIsFree()); + ArrayList results = new ArrayList<>(); + if ("0".equals(it.getIsFree())) { + // 非自由巡检才有Marker + List markers = taskMarkerBeanDao.getMarkersByIdAndCode(String.valueOf(it.getId()), it.getTaskCode()); + for (TaskMarkerBean marker : markers) { + TaskDetailLocalModel.TaskMarkerLocalModel localModel = new TaskDetailLocalModel.TaskMarkerLocalModel(); + localModel.setMarkerId(marker.getMarkerId()); + localModel.setLng(marker.getLng()); + localModel.setLat(marker.getLat()); + localModel.setIsDetected(marker.getIsDetected()); + localModel.setDetectedTime(marker.getDetectedTime()); + + results.add(localModel); + } + } + model.setMarkerModels(results); + result.add(model); + } + return result; + } + + @Query("DELETE FROM task_detail WHERE id = :taskId AND taskCode = :taskCode") + void deleteTaskById(long taskId, String taskCode); + + @Transaction + default void deleteLocalTaskById(long taskId, String taskCode, TaskMarkerBeanDao taskMarkerBeanDao) { + TaskBean task = loadAll().stream() + .filter(it -> it.getId() == taskId && taskCode.equals(it.getTaskCode())) + .findFirst() + .orElse(null); + if (task == null) return; + deleteTaskById(taskId, taskCode); + + // 删除此任务关联的Marker。非自由巡检才有Marker + if ("0".equals(task.getIsFree())) { + List markers = taskMarkerBeanDao.getMarkersByIdAndCode(String.valueOf(task.getId()), task.getTaskCode()); + for (TaskMarkerBean marker : markers) { + taskMarkerBeanDao.delete(marker); + } + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/dao/TaskMarkerBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/dao/TaskMarkerBeanDao.java new file mode 100644 index 0000000..cc2156a --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/dao/TaskMarkerBeanDao.java @@ -0,0 +1,52 @@ +package com.casic.common.detector.gd.dao; + +import androidx.room.Dao; +import androidx.room.Delete; +import androidx.room.Insert; +import androidx.room.Query; +import androidx.room.Update; + +import com.casic.common.detector.gd.bean.TaskMarkerBean; +import com.casic.common.detector.gd.model.TaskModel; + +import java.util.List; + +@Dao +public interface TaskMarkerBeanDao { + + @Insert + void insert(TaskMarkerBean marker); + + @Query("SELECT COUNT(*) FROM task_marker_info WHERE id = :markerId") + int isMarkerExist(String markerId); + + default void saveTaskMarker(long taskId, String taskCode, TaskModel.MessageModel.TaskDetailInfosModel marker) { + if (isMarkerExist(marker.getMarkerId()) == 0) { + TaskMarkerBean bean = new TaskMarkerBean(); + bean.setId(marker.getId()); + bean.setTaskId(String.valueOf(taskId)); + bean.setTaskCode(taskCode); + bean.setMarkerId(marker.getMarkerIdReal()); + bean.setLng(marker.getLongitude()); + bean.setLat(marker.getLatitude()); + bean.setIsDetected("0"); + bean.setDetectedTime(""); + insert(bean); + } + } + + @Query("SELECT * FROM task_marker_info WHERE taskId = :taskId AND taskCode = :taskCode AND markerId = :markerId AND isDetected = :state") + TaskMarkerBean queryTaskMarkerById(String taskId, String taskCode, String markerId, String state); + + @Update + void updateLocalTaskMarkerState(TaskMarkerBean marker); + + @Query("SELECT * FROM task_marker_info WHERE isDetected = :state") + List queryMarkerByState(String state); + + @Query("SELECT * FROM task_marker_info WHERE taskId = :taskId AND taskCode = :taskCode") + List getMarkersByIdAndCode(String taskId, String taskCode); + + @Delete + void delete(TaskMarkerBean marker); +} \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index d0cb423..921c8c8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,25 +1,20 @@ import java.text.SimpleDateFormat -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply plugin: 'org.greenrobot.greendao' +plugins { + id('com.android.application') + id('org.jetbrains.kotlin.android') +} android { - compileSdkVersion 33 + namespace 'com.casic.common.detector.gd' + compileSdk 35 defaultConfig { - applicationId "com.casic.common.detector.gd" - minSdkVersion 26 - targetSdkVersion 33 + applicationId 'com.casic.common.detector.gd' + minSdk 26 + targetSdk 35 versionCode 5092 - versionName "5.0.9.2" - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } + versionName '5.0.9.2' } signingConfigs { @@ -31,6 +26,14 @@ } } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + signingConfig signingConfigs.release + } + } + compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 @@ -47,27 +50,16 @@ } } - kotlin { - experimental { - coroutines 'enable' - } - } - buildFeatures { + buildConfig true viewBinding true } - applicationVariants.configureEach { variant -> - variant.outputs.configureEach { - outputFileName = "COM_TCY_" + getBuildDate() + "_" + defaultConfig.versionName + ".apk" + applicationVariants.configureEach { + outputs.configureEach { + outputFileName = 'COM_TCY_' + getBuildDate() + '_' + defaultConfig.versionName + '.apk' } } - - greendao { - schemaVersion 1//数据库版本号 - targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 - daoPackage "${defaultConfig.applicationId}.greendao"//设置DaoMaster、DaoSession、Dao包名 - } } static def getBuildDate() { @@ -76,27 +68,22 @@ } dependencies { - //基础依赖库 - implementation 'com.github.AndroidCoderPeng:Kotlin-lite-lib:1.1.4' - implementation 'androidx.core:core-ktx:1.9.0' - def base_version = "1.6.1" - implementation "androidx.appcompat:appcompat:${base_version}" - implementation "com.google.android.material:material:${base_version}" + implementation 'com.github.AndroidCoderPeng:Kotlin-lite-lib:1.1.5' + implementation 'androidx.core:core-ktx:1.13.1' + implementation 'androidx.appcompat:appcompat:1.7.0' + implementation 'com.google.android.material:material:1.12.0' //Google官方授权框架 implementation 'pub.devrel:easypermissions:3.0.0' - //沉浸式状态栏。基础依赖包,必须要依赖 - implementation 'com.gyf.immersionbar:immersionbar:3.0.0' - //fragment快速实现 - implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0' + //沉浸式状态栏 + implementation 'com.geyifeng.immersionbar:immersionbar:3.2.2' //官方Json解析库 implementation 'com.google.code.gson:gson:2.10.1' - def vm_version = '2.5.1' //Kotlin协程 - implementation "androidx.lifecycle:lifecycle-runtime-ktx:${vm_version}" + implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.2' //MVVM+LiveData - implementation "androidx.lifecycle:lifecycle-livedata-ktx:${vm_version}" - implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:${vm_version}" - implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.6.2' + implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2' + implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' //返回值转换器 implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' @@ -105,9 +92,10 @@ implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' //网络请求和接口封装 implementation 'com.squareup.retrofit2:retrofit:2.9.0' - implementation 'com.squareup.okhttp3:okhttp:4.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.12.0' //数据库框架 - implementation 'org.greenrobot:greendao:3.3.0' + implementation 'androidx.room:room-runtime:2.6.1' + annotationProcessor 'androidx.room:room-compiler:2.5.2' //高德导航、定位、地图三合一 implementation 'com.amap.api:navi-3dmap:latest.integration' //经纬度逆编码 @@ -115,7 +103,7 @@ //excel implementation 'net.sourceforge.jexcelapi:jxl:2.6.12' //图片加载框架 - implementation 'com.github.bumptech.glide:glide:4.9.0' + implementation 'com.github.bumptech.glide:glide:4.12.0' //图片选择框架 implementation 'io.github.lucksiege:pictureselector:v3.11.1' //大图 diff --git a/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt b/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt index 7b695ff..50ba734 100644 --- a/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt +++ b/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt @@ -4,9 +4,9 @@ import android.app.Application import android.os.Bundle import android.util.Log -import com.casic.common.detector.gd.greendao.DaoMaster -import com.casic.common.detector.gd.greendao.DaoSession +import androidx.room.Room.databaseBuilder import com.casic.common.detector.gd.uart.SerialPort +import com.casic.common.detector.gd.utils.DetectorDataBase import com.casic.common.detector.gd.utils.GpioManager import com.pengxh.kt.lite.extensions.show import com.pengxh.kt.lite.utils.SaveKeyValues @@ -43,44 +43,42 @@ private var application: BaseApplication by Delegates.notNull() fun get() = application - - private lateinit var daoSession: DaoSession } + lateinit var dataBase: DetectorDataBase + override fun onCreate() { super.onCreate() application = this SaveKeyValues.initSharedPreferences(this) CrashReport.initCrashReport(this, "01e80d3a74", true) - val devOpenHelper = DaoMaster.DevOpenHelper(this, "Detector.db", null) - val daoMaster = DaoMaster(devOpenHelper.writableDatabase) - daoSession = daoMaster.newSession() + dataBase = databaseBuilder(this, DetectorDataBase::class.java, "Detector.db") + .allowMainThreadQueries() + .build() /** * Open the serial port * */ try { serialPorts.apply { - add(SerialPort(File("/dev/ttysWK1"), 9600, 0)) - //千寻报文数据下发串口号 - add(SerialPort(File("/dev/ttyS1"), 9600, 0)) + add(SerialPort(File("/dev/ttysWK1"), 9600, 0)) //信号通讯串口 + add(SerialPort(File("/dev/ttyS1"), 9600, 0)) //千寻报文数据下发串口号 } Log.d(kTag, "onCreate: 已初始化 ${serialPorts.size} 个串口") } catch (e: SecurityException) { "您没有串口的读写权限!".show(this) + e.printStackTrace() } catch (e: IOException) { "因为不明原因,串口无法打开!".show(this) + e.printStackTrace() } catch (e: InvalidParameterException) { "请检查串口!".show(this) + e.printStackTrace() } registerActivityLifecycleCallbacks(this) } - fun getDaoSession(): DaoSession { - return daoSession - } - override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) { } diff --git a/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt b/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt index 053b9dd..1d0c9e3 100644 --- a/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt +++ b/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt @@ -14,12 +14,10 @@ import com.casic.common.detector.gd.utils.SerialPortCommand import com.pengxh.kt.lite.utils.WeakReferenceHandler import java.io.IOException -import java.util.Timer abstract class SerialPortBaseActivity : AppCompatActivity(), Handler.Callback { private val kTag = "SerialPortBaseActivity" - private val taskTimer by lazy { Timer() } private val weakReferenceHandler by lazy { WeakReferenceHandler(this) } private val serialPorts by lazy { BaseApplication.get().getSerialPorts() } protected lateinit var binding: VB @@ -30,7 +28,6 @@ setContentView(binding.root) setupTopBarLayout() initOnCreate(savedInstanceState) - observeRequestState() initEvent() if (serialPorts.isNotEmpty()) { @@ -71,11 +68,6 @@ abstract fun initOnCreate(savedInstanceState: Bundle?) /** - * 数据请求状态监听 - */ - abstract fun observeRequestState() - - /** * 初始化业务逻辑 */ abstract fun initEvent() diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java new file mode 100644 index 0000000..7a18c20 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java @@ -0,0 +1,255 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 从平台下载的标识器本地库实体类 + */ +@Entity(tableName = "marker_detail") +public class MarkerBean { + @PrimaryKey(autoGenerate = true) + private long id; //主键ID + private String pipelineType; // 管线类型 + private String pipelineDiameter; // 管线直径 + private String pipelineMaterial; // 管材 + private String buryMethod; // 埋设方式 + private String buryDepth; // 埋深 + private String area; // 所属区域 + private String line; // 所属线路 + private String road; // 所属道路 + private String constructTime; // 建设年代 + private String owner; // 权属单位 + private String objectId; // 标识对象ID,无实际用途 + private String markerId; // 标识器ID + private String markerType; // 标识器类型 + private String markerDepth; // 标识器埋深 + private String installationDept; // 安装部门 + private String lng; // 经度 + private String lat; // 纬度 + private String updateTime; // 最后修改时间,更新时间 + private String remark; // 备注信息 + private String underlyingPipelineType; // 下层管线类型 + private String underlyingPipelineDepth; // 下层埋深 + private String underlyingPipelineDiameter; // 下层管径 + private String underlyingPipelineMaterial; // 下层管材 + private String objectType; //标识对象类型 + private String color; // 颜色 + private String imagePath; // 图片路径 + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getPipelineType() { + return pipelineType; + } + + public void setPipelineType(String pipelineType) { + this.pipelineType = pipelineType; + } + + public String getPipelineDiameter() { + return pipelineDiameter; + } + + public void setPipelineDiameter(String pipelineDiameter) { + this.pipelineDiameter = pipelineDiameter; + } + + public String getPipelineMaterial() { + return pipelineMaterial; + } + + public void setPipelineMaterial(String pipelineMaterial) { + this.pipelineMaterial = pipelineMaterial; + } + + public String getBuryMethod() { + return buryMethod; + } + + public void setBuryMethod(String buryMethod) { + this.buryMethod = buryMethod; + } + + public String getBuryDepth() { + return buryDepth; + } + + public void setBuryDepth(String buryDepth) { + this.buryDepth = buryDepth; + } + + public String getArea() { + return area; + } + + public void setArea(String area) { + this.area = area; + } + + public String getLine() { + return line; + } + + public void setLine(String line) { + this.line = line; + } + + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + + public String getConstructTime() { + return constructTime; + } + + public void setConstructTime(String constructTime) { + this.constructTime = constructTime; + } + + public String getOwner() { + return owner; + } + + public void setOwner(String owner) { + this.owner = owner; + } + + public String getObjectId() { + return objectId; + } + + public void setObjectId(String objectId) { + this.objectId = objectId; + } + + public String getMarkerId() { + return markerId; + } + + public void setMarkerId(String markerId) { + this.markerId = markerId; + } + + public String getMarkerType() { + return markerType; + } + + public void setMarkerType(String markerType) { + this.markerType = markerType; + } + + public String getMarkerDepth() { + return markerDepth; + } + + public void setMarkerDepth(String markerDepth) { + this.markerDepth = markerDepth; + } + + public String getInstallationDept() { + return installationDept; + } + + public void setInstallationDept(String installationDept) { + this.installationDept = installationDept; + } + + public String getLng() { + return lng; + } + + public void setLng(String lng) { + this.lng = lng; + } + + public String getLat() { + return lat; + } + + public void setLat(String lat) { + this.lat = lat; + } + + public String getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } + + public String getUnderlyingPipelineType() { + return underlyingPipelineType; + } + + public void setUnderlyingPipelineType(String underlyingPipelineType) { + this.underlyingPipelineType = underlyingPipelineType; + } + + public String getUnderlyingPipelineDepth() { + return underlyingPipelineDepth; + } + + public void setUnderlyingPipelineDepth(String underlyingPipelineDepth) { + this.underlyingPipelineDepth = underlyingPipelineDepth; + } + + public String getUnderlyingPipelineDiameter() { + return underlyingPipelineDiameter; + } + + public void setUnderlyingPipelineDiameter(String underlyingPipelineDiameter) { + this.underlyingPipelineDiameter = underlyingPipelineDiameter; + } + + public String getUnderlyingPipelineMaterial() { + return underlyingPipelineMaterial; + } + + public void setUnderlyingPipelineMaterial(String underlyingPipelineMaterial) { + this.underlyingPipelineMaterial = underlyingPipelineMaterial; + } + + public String getObjectType() { + return objectType; + } + + public void setObjectType(String objectType) { + this.objectType = objectType; + } + + public String getColor() { + return color; + } + + public void setColor(String color) { + this.color = color; + } + + public String getImagePath() { + return imagePath; + } + + public void setImagePath(String imagePath) { + this.imagePath = imagePath; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java deleted file mode 100644 index 3f2fcdc..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java +++ /dev/null @@ -1,327 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 从平台下载的标识器本地库实体类 - */ -@Entity -public class MarkerLocalBean { - @Id(autoincrement = true) - private Long id;//本地库主键ID - - // 管线类型 - private String pipelineType; - // 管线直径 - private String pipelineDiameter; - // 管材 - private String pipelineMaterial; - // 埋设方式 - private String buryMethod; - // 埋深 - private String buryDepth; - // 所属区域 - private String area; - // 所属线路 - private String line; - // 所属道路 - private String road; - // 建设年代 - private String constructTime; - // 权属单位 - private String owner; - //标识对象ID,无实际用途 - @Deprecated - private String objectId; - // 标识器ID - private String markerId; - // 标识器类型 - private String markerType; - // 标识器埋深 - private String markerDepth; - // 安装部门 - private String installationDept; - // 经度 - private String lng; - // 纬度 - private String lat; - //最后修改时间,更新时间 - private String updateTime; - // 备注信息 - private String remark; - // 下层管线类型 - private String underlyingPipelineType; - // 下层埋深 - private String underlyingPipelineDepth; - // 下层管径 - private String underlyingPipelineDiameter; - // 下层管材 - private String underlyingPipelineMaterial; - //标识对象类型 - private String objectType; - // 颜色 - private String color; - // 图片路径 - private String imagePath; - - @Generated(hash = 1479045776) - public MarkerLocalBean(Long id, String pipelineType, String pipelineDiameter, - String pipelineMaterial, String buryMethod, String buryDepth, - String area, String line, String road, String constructTime, - String owner, String objectId, String markerId, String markerType, - String markerDepth, String installationDept, String lng, String lat, - String updateTime, String remark, String underlyingPipelineType, - String underlyingPipelineDepth, String underlyingPipelineDiameter, - String underlyingPipelineMaterial, String objectType, String color, - String imagePath) { - this.id = id; - this.pipelineType = pipelineType; - this.pipelineDiameter = pipelineDiameter; - this.pipelineMaterial = pipelineMaterial; - this.buryMethod = buryMethod; - this.buryDepth = buryDepth; - this.area = area; - this.line = line; - this.road = road; - this.constructTime = constructTime; - this.owner = owner; - this.objectId = objectId; - this.markerId = markerId; - this.markerType = markerType; - this.markerDepth = markerDepth; - this.installationDept = installationDept; - this.lng = lng; - this.lat = lat; - this.updateTime = updateTime; - this.remark = remark; - this.underlyingPipelineType = underlyingPipelineType; - this.underlyingPipelineDepth = underlyingPipelineDepth; - this.underlyingPipelineDiameter = underlyingPipelineDiameter; - this.underlyingPipelineMaterial = underlyingPipelineMaterial; - this.objectType = objectType; - this.color = color; - this.imagePath = imagePath; - } - - @Generated(hash = 1538606012) - public MarkerLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getPipelineType() { - return this.pipelineType; - } - - public void setPipelineType(String pipelineType) { - this.pipelineType = pipelineType; - } - - public String getPipelineDiameter() { - return this.pipelineDiameter; - } - - public void setPipelineDiameter(String pipelineDiameter) { - this.pipelineDiameter = pipelineDiameter; - } - - public String getPipelineMaterial() { - return this.pipelineMaterial; - } - - public void setPipelineMaterial(String pipelineMaterial) { - this.pipelineMaterial = pipelineMaterial; - } - - public String getBuryMethod() { - return this.buryMethod; - } - - public void setBuryMethod(String buryMethod) { - this.buryMethod = buryMethod; - } - - public String getBuryDepth() { - return this.buryDepth; - } - - public void setBuryDepth(String buryDepth) { - this.buryDepth = buryDepth; - } - - public String getArea() { - return this.area; - } - - public void setArea(String area) { - this.area = area; - } - - public String getLine() { - return this.line; - } - - public void setLine(String line) { - this.line = line; - } - - public String getRoad() { - return this.road; - } - - public void setRoad(String road) { - this.road = road; - } - - public String getConstructTime() { - return this.constructTime; - } - - public void setConstructTime(String constructTime) { - this.constructTime = constructTime; - } - - public String getOwner() { - return this.owner; - } - - public void setOwner(String owner) { - this.owner = owner; - } - - public String getObjectId() { - return this.objectId; - } - - public void setObjectId(String objectId) { - this.objectId = objectId; - } - - public String getMarkerId() { - return this.markerId; - } - - public void setMarkerId(String markerId) { - this.markerId = markerId; - } - - public String getMarkerType() { - return this.markerType; - } - - public void setMarkerType(String markerType) { - this.markerType = markerType; - } - - public String getMarkerDepth() { - return this.markerDepth; - } - - public void setMarkerDepth(String markerDepth) { - this.markerDepth = markerDepth; - } - - public String getInstallationDept() { - return this.installationDept; - } - - public void setInstallationDept(String installationDept) { - this.installationDept = installationDept; - } - - public String getLng() { - return this.lng; - } - - public void setLng(String lng) { - this.lng = lng; - } - - public String getLat() { - return this.lat; - } - - public void setLat(String lat) { - this.lat = lat; - } - - public String getUpdateTime() { - return this.updateTime; - } - - public void setUpdateTime(String updateTime) { - this.updateTime = updateTime; - } - - public String getRemark() { - return this.remark; - } - - public void setRemark(String remark) { - this.remark = remark; - } - - public String getUnderlyingPipelineType() { - return this.underlyingPipelineType; - } - - public void setUnderlyingPipelineType(String underlyingPipelineType) { - this.underlyingPipelineType = underlyingPipelineType; - } - - public String getUnderlyingPipelineDepth() { - return this.underlyingPipelineDepth; - } - - public void setUnderlyingPipelineDepth(String underlyingPipelineDepth) { - this.underlyingPipelineDepth = underlyingPipelineDepth; - } - - public String getUnderlyingPipelineDiameter() { - return this.underlyingPipelineDiameter; - } - - public void setUnderlyingPipelineDiameter(String underlyingPipelineDiameter) { - this.underlyingPipelineDiameter = underlyingPipelineDiameter; - } - - public String getUnderlyingPipelineMaterial() { - return this.underlyingPipelineMaterial; - } - - public void setUnderlyingPipelineMaterial(String underlyingPipelineMaterial) { - this.underlyingPipelineMaterial = underlyingPipelineMaterial; - } - - public String getObjectType() { - return this.objectType; - } - - public void setObjectType(String objectType) { - this.objectType = objectType; - } - - public String getColor() { - return this.color; - } - - public void setColor(String color) { - this.color = color; - } - - public String getImagePath() { - return this.imagePath; - } - - public void setImagePath(String imagePath) { - this.imagePath = imagePath; - } -} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java new file mode 100644 index 0000000..5c88fdf --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java @@ -0,0 +1,93 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 巡检任务本地库实体类,不包含任务里面需要巡检的标识器信息 + */ +@Entity(tableName = "task_detail") +public class TaskBean { + @PrimaryKey(autoGenerate = true) + private long id;//主键ID + private String taskCode; // 任务编号 + private String description; // 任务名称 + private String createTime; // 任务创建的时间 + private String status; // 任务状态 + private String createUserName; // 任务创建者名称 + private String startTime; // 任务被开始执行的时间 + private String endTime; // 任务执行结束的时间 + private String isFree; // 是否自由巡检。1-是,0-否 + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getTaskCode() { + return taskCode; + } + + public void setTaskCode(String taskCode) { + this.taskCode = taskCode; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getCreateUserName() { + return createUserName; + } + + public void setCreateUserName(String createUserName) { + this.createUserName = createUserName; + } + + public String getStartTime() { + return startTime; + } + + public void setStartTime(String startTime) { + this.startTime = startTime; + } + + public String getEndTime() { + return endTime; + } + + public void setEndTime(String endTime) { + this.endTime = endTime; + } + + public String getIsFree() { + return isFree; + } + + public void setIsFree(String isFree) { + this.isFree = isFree; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java deleted file mode 100644 index 91737b3..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java +++ /dev/null @@ -1,114 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 巡检任务本地库实体类,不包含任务里面需要巡检的标识器信息 - */ -@Entity -public class TaskLocalBean { - @Id - private Long id;//任务ID - - private String taskCode;//任务编号 - private String description;//任务名称 - private String createTime;//任务创建的时间 - private String status;//任务状态 - private String createUserName;//任务创建者名称 - private String startTime;//任务被开始执行的时间 - private String endTime;//任务执行结束的时间 - private String isFreeTask;//是否自由巡检。1-是,0-否 - - @Generated(hash = 1482022528) - public TaskLocalBean(Long id, String taskCode, String description, - String createTime, String status, String createUserName, - String startTime, String endTime, String isFreeTask) { - this.id = id; - this.taskCode = taskCode; - this.description = description; - this.createTime = createTime; - this.status = status; - this.createUserName = createUserName; - this.startTime = startTime; - this.endTime = endTime; - this.isFreeTask = isFreeTask; - } - - @Generated(hash = 949704588) - public TaskLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getTaskCode() { - return this.taskCode; - } - - public void setTaskCode(String taskCode) { - this.taskCode = taskCode; - } - - public String getDescription() { - return this.description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getCreateTime() { - return this.createTime; - } - - public void setCreateTime(String createTime) { - this.createTime = createTime; - } - - public String getStatus() { - return this.status; - } - - public void setStatus(String status) { - this.status = status; - } - - public String getCreateUserName() { - return this.createUserName; - } - - public void setCreateUserName(String createUserName) { - this.createUserName = createUserName; - } - - public String getStartTime() { - return this.startTime; - } - - public void setStartTime(String startTime) { - this.startTime = startTime; - } - - public String getEndTime() { - return this.endTime; - } - - public void setEndTime(String endTime) { - this.endTime = endTime; - } - - public String getIsFreeTask() { - return this.isFreeTask; - } - - public void setIsFreeTask(String isFreeTask) { - this.isFreeTask = isFreeTask; - } -} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerBean.java new file mode 100644 index 0000000..c563a60 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerBean.java @@ -0,0 +1,110 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 巡检任务里面需要巡检的标识器信息本地库实体类 + */ +@Entity(tableName = "task_marker_info") +public class TaskMarkerBean { + //标识器后台库的主键ID,不是标识器实际ID + @PrimaryKey(autoGenerate = true) + private long id; + + /** + * 任务ID,通过此字段关联[TaskBean.id] + */ + private String taskId; + + /** + * 任务Code,通过此字段关联[TaskBean.taskCode] + *

+ *

+ * 双重验证,防止出现同时刻重复的情况 + */ + private String taskCode; + + /** + * 对应后台字段[TaskModel.MessageModel.TaskDetailInfosModel.markerIdReal],也就是探测仪扫描出来的ID + */ + private String markerId; + + private Double lng; + private Double lat; + + /** + * 是否已被探测到 + * 1-是,0-否 + */ + private String isDetected; + + /** + * 被探测到的时间,对应后台字段[TaskModel.MessageModel.TaskDetailInfosModel.finishTime] + */ + private String detectedTime; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getTaskId() { + return taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getTaskCode() { + return taskCode; + } + + public void setTaskCode(String taskCode) { + this.taskCode = taskCode; + } + + public String getMarkerId() { + return markerId; + } + + public void setMarkerId(String markerId) { + this.markerId = markerId; + } + + public Double getLng() { + return lng; + } + + public void setLng(Double lng) { + this.lng = lng; + } + + public Double getLat() { + return lat; + } + + public void setLat(Double lat) { + this.lat = lat; + } + + public String getIsDetected() { + return isDetected; + } + + public void setIsDetected(String isDetected) { + this.isDetected = isDetected; + } + + public String getDetectedTime() { + return detectedTime; + } + + public void setDetectedTime(String detectedTime) { + this.detectedTime = detectedTime; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerLocalBean.java deleted file mode 100644 index de9f459..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerLocalBean.java +++ /dev/null @@ -1,128 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import com.casic.common.detector.gd.model.TaskModel; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 巡检任务里面需要巡检的标识器信息本地库实体类 - */ -@Entity -public class TaskMarkerLocalBean { - @Id - private Long id;//标识器后台库的主键ID,不是标识器实际ID - - /** - * 任务ID,通过此字段关联{@link TaskLocalBean#id} - */ - private String taskId; - - /** - * 任务Code,通过此字段关联{@link TaskLocalBean#taskCode} - *

- * 双重验证,防止出现同时刻重复的情况 - */ - private String taskCode; - - /** - * 对应后台字段{@link TaskModel.MessageModel.TaskDetailInfosModel#markerIdReal},也就是探测仪扫描出来的ID - */ - private String markerId; - - private double lng; - private double lat; - - /** - * 是否已被探测到 - * 1-是,0-否 - */ - private String isDetected; - - /** - * 被探测到的时间,对应后台字段{@link TaskModel.MessageModel.TaskDetailInfosModel#finishTime} - */ - private String detectedTime; - - @Generated(hash = 677328533) - public TaskMarkerLocalBean(Long id, String taskId, String taskCode, String markerId, - double lng, double lat, String isDetected, String detectedTime) { - this.id = id; - this.taskId = taskId; - this.taskCode = taskCode; - this.markerId = markerId; - this.lng = lng; - this.lat = lat; - this.isDetected = isDetected; - this.detectedTime = detectedTime; - } - - @Generated(hash = 1162404642) - public TaskMarkerLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getTaskId() { - return this.taskId; - } - - public void setTaskId(String taskId) { - this.taskId = taskId; - } - - public String getTaskCode() { - return this.taskCode; - } - - public void setTaskCode(String taskCode) { - this.taskCode = taskCode; - } - - public String getMarkerId() { - return this.markerId; - } - - public void setMarkerId(String markerId) { - this.markerId = markerId; - } - - public double getLng() { - return this.lng; - } - - public void setLng(double lng) { - this.lng = lng; - } - - public double getLat() { - return this.lat; - } - - public void setLat(double lat) { - this.lat = lat; - } - - public String getIsDetected() { - return this.isDetected; - } - - public void setIsDetected(String isDetected) { - this.isDetected = isDetected; - } - - public String getDetectedTime() { - return this.detectedTime; - } - - public void setDetectedTime(String detectedTime) { - this.detectedTime = detectedTime; - } -} diff --git a/app/src/main/java/com/casic/common/detector/gd/dao/MarkerBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/dao/MarkerBeanDao.java new file mode 100644 index 0000000..2beb7ed --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/dao/MarkerBeanDao.java @@ -0,0 +1,29 @@ +package com.casic.common.detector.gd.dao; + +import androidx.room.Dao; +import androidx.room.Insert; +import androidx.room.Query; +import androidx.room.RawQuery; +import androidx.sqlite.db.SupportSQLiteQuery; + +import com.casic.common.detector.gd.bean.MarkerBean; + +import java.util.List; + +@Dao +public interface MarkerBeanDao { + @Query("DELETE FROM marker_detail") + void deleteAll(); + + @Insert + void insert(MarkerBean marker); + + @Query("SELECT * FROM marker_detail") + List loadAll(); + + @Query("SELECT * FROM marker_detail WHERE markerId = :markerId") + List queryMarkerById(String markerId); + + @RawQuery + List loadMarkersByCondition(SupportSQLiteQuery query); +} diff --git a/app/src/main/java/com/casic/common/detector/gd/dao/TaskBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/dao/TaskBeanDao.java new file mode 100644 index 0000000..9c70ac2 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/dao/TaskBeanDao.java @@ -0,0 +1,120 @@ +package com.casic.common.detector.gd.dao; + +import androidx.room.Dao; +import androidx.room.Insert; +import androidx.room.Query; +import androidx.room.Transaction; + +import com.casic.common.detector.gd.bean.TaskBean; +import com.casic.common.detector.gd.bean.TaskMarkerBean; +import com.casic.common.detector.gd.model.TaskDetailLocalModel; +import com.casic.common.detector.gd.model.TaskModel; +import com.casic.common.detector.gd.utils.LocaleConstant; +import com.pengxh.kt.lite.utils.SaveKeyValues; + +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Locale; + +@Dao +public interface TaskBeanDao { + @Query("SELECT COUNT(*) FROM task_detail WHERE id = :taskId") + int isTaskExist(long taskId); + + @Insert + void insert(TaskBean task); + + default void saveTask(Long taskId, String taskName) { + if (isTaskExist(taskId) == 0) { + TaskBean task = new TaskBean(); + task.setId(taskId); + task.setTaskCode(new SimpleDateFormat("yyyyMMddHHmmss", Locale.CHINA).format(new Date())); + task.setDescription(taskName); + String time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA).format(new Date()); + task.setCreateTime(time); + task.setStatus("0"); + String userName = (String) SaveKeyValues.INSTANCE.getValue(LocaleConstant.USER_NAME, ""); + task.setCreateUserName(userName); + task.setStartTime(time); + task.setEndTime(""); + task.setIsFree("1"); + insert(task); + } + } + + default void saveTask(TaskModel.MessageModel model) { + TaskBean task = new TaskBean(); + task.setId(model.getId()); + task.setTaskCode(model.getTaskCode()); + task.setDescription(model.getDescription()); + task.setCreateTime(model.getDeployDate()); + task.setStatus(model.getStatus()); + task.setCreateUserName(model.getCreatorName()); + task.setStartTime(model.getBeginDate()); + task.setEndTime(model.getEndDate()); + task.setIsFree("0"); + if (isTaskExist(task.getId()) == 0) { + insert(task); + } + } + + @Query("SELECT * FROM task_detail") + List loadAll(); + + @Transaction + default ArrayList loadLocalTask(TaskMarkerBeanDao taskMarkerBeanDao) { + ArrayList result = new ArrayList<>(); + List tasks = loadAll(); + for (TaskBean it : tasks) { + TaskDetailLocalModel model = new TaskDetailLocalModel(); + model.setTaskId(String.valueOf(it.getId())); + model.setTaskCode(it.getTaskCode()); + model.setDescription(it.getDescription()); + model.setCreateTime(it.getCreateTime()); + model.setStatus(it.getStatus()); + model.setCreateUserName(it.getCreateUserName()); + model.setIsFreeTask(it.getIsFree()); + ArrayList results = new ArrayList<>(); + if ("0".equals(it.getIsFree())) { + // 非自由巡检才有Marker + List markers = taskMarkerBeanDao.getMarkersByIdAndCode(String.valueOf(it.getId()), it.getTaskCode()); + for (TaskMarkerBean marker : markers) { + TaskDetailLocalModel.TaskMarkerLocalModel localModel = new TaskDetailLocalModel.TaskMarkerLocalModel(); + localModel.setMarkerId(marker.getMarkerId()); + localModel.setLng(marker.getLng()); + localModel.setLat(marker.getLat()); + localModel.setIsDetected(marker.getIsDetected()); + localModel.setDetectedTime(marker.getDetectedTime()); + + results.add(localModel); + } + } + model.setMarkerModels(results); + result.add(model); + } + return result; + } + + @Query("DELETE FROM task_detail WHERE id = :taskId AND taskCode = :taskCode") + void deleteTaskById(long taskId, String taskCode); + + @Transaction + default void deleteLocalTaskById(long taskId, String taskCode, TaskMarkerBeanDao taskMarkerBeanDao) { + TaskBean task = loadAll().stream() + .filter(it -> it.getId() == taskId && taskCode.equals(it.getTaskCode())) + .findFirst() + .orElse(null); + if (task == null) return; + deleteTaskById(taskId, taskCode); + + // 删除此任务关联的Marker。非自由巡检才有Marker + if ("0".equals(task.getIsFree())) { + List markers = taskMarkerBeanDao.getMarkersByIdAndCode(String.valueOf(task.getId()), task.getTaskCode()); + for (TaskMarkerBean marker : markers) { + taskMarkerBeanDao.delete(marker); + } + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/dao/TaskMarkerBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/dao/TaskMarkerBeanDao.java new file mode 100644 index 0000000..cc2156a --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/dao/TaskMarkerBeanDao.java @@ -0,0 +1,52 @@ +package com.casic.common.detector.gd.dao; + +import androidx.room.Dao; +import androidx.room.Delete; +import androidx.room.Insert; +import androidx.room.Query; +import androidx.room.Update; + +import com.casic.common.detector.gd.bean.TaskMarkerBean; +import com.casic.common.detector.gd.model.TaskModel; + +import java.util.List; + +@Dao +public interface TaskMarkerBeanDao { + + @Insert + void insert(TaskMarkerBean marker); + + @Query("SELECT COUNT(*) FROM task_marker_info WHERE id = :markerId") + int isMarkerExist(String markerId); + + default void saveTaskMarker(long taskId, String taskCode, TaskModel.MessageModel.TaskDetailInfosModel marker) { + if (isMarkerExist(marker.getMarkerId()) == 0) { + TaskMarkerBean bean = new TaskMarkerBean(); + bean.setId(marker.getId()); + bean.setTaskId(String.valueOf(taskId)); + bean.setTaskCode(taskCode); + bean.setMarkerId(marker.getMarkerIdReal()); + bean.setLng(marker.getLongitude()); + bean.setLat(marker.getLatitude()); + bean.setIsDetected("0"); + bean.setDetectedTime(""); + insert(bean); + } + } + + @Query("SELECT * FROM task_marker_info WHERE taskId = :taskId AND taskCode = :taskCode AND markerId = :markerId AND isDetected = :state") + TaskMarkerBean queryTaskMarkerById(String taskId, String taskCode, String markerId, String state); + + @Update + void updateLocalTaskMarkerState(TaskMarkerBean marker); + + @Query("SELECT * FROM task_marker_info WHERE isDetected = :state") + List queryMarkerByState(String state); + + @Query("SELECT * FROM task_marker_info WHERE taskId = :taskId AND taskCode = :taskCode") + List getMarkersByIdAndCode(String taskId, String taskCode); + + @Delete + void delete(TaskMarkerBean marker); +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/extensions/Long.kt b/app/src/main/java/com/casic/common/detector/gd/extensions/Long.kt deleted file mode 100644 index 6713d8d..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/extensions/Long.kt +++ /dev/null @@ -1,10 +0,0 @@ -package com.casic.common.detector.gd.extensions - -import java.text.SimpleDateFormat -import java.util.Date -import java.util.Locale - -fun Long.createTaskCode(): String { - val dateFormat = SimpleDateFormat("yyyyMMddHHmmss", Locale.CHINA) - return dateFormat.format(Date(this)) -} \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index d0cb423..921c8c8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,25 +1,20 @@ import java.text.SimpleDateFormat -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply plugin: 'org.greenrobot.greendao' +plugins { + id('com.android.application') + id('org.jetbrains.kotlin.android') +} android { - compileSdkVersion 33 + namespace 'com.casic.common.detector.gd' + compileSdk 35 defaultConfig { - applicationId "com.casic.common.detector.gd" - minSdkVersion 26 - targetSdkVersion 33 + applicationId 'com.casic.common.detector.gd' + minSdk 26 + targetSdk 35 versionCode 5092 - versionName "5.0.9.2" - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } + versionName '5.0.9.2' } signingConfigs { @@ -31,6 +26,14 @@ } } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + signingConfig signingConfigs.release + } + } + compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 @@ -47,27 +50,16 @@ } } - kotlin { - experimental { - coroutines 'enable' - } - } - buildFeatures { + buildConfig true viewBinding true } - applicationVariants.configureEach { variant -> - variant.outputs.configureEach { - outputFileName = "COM_TCY_" + getBuildDate() + "_" + defaultConfig.versionName + ".apk" + applicationVariants.configureEach { + outputs.configureEach { + outputFileName = 'COM_TCY_' + getBuildDate() + '_' + defaultConfig.versionName + '.apk' } } - - greendao { - schemaVersion 1//数据库版本号 - targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 - daoPackage "${defaultConfig.applicationId}.greendao"//设置DaoMaster、DaoSession、Dao包名 - } } static def getBuildDate() { @@ -76,27 +68,22 @@ } dependencies { - //基础依赖库 - implementation 'com.github.AndroidCoderPeng:Kotlin-lite-lib:1.1.4' - implementation 'androidx.core:core-ktx:1.9.0' - def base_version = "1.6.1" - implementation "androidx.appcompat:appcompat:${base_version}" - implementation "com.google.android.material:material:${base_version}" + implementation 'com.github.AndroidCoderPeng:Kotlin-lite-lib:1.1.5' + implementation 'androidx.core:core-ktx:1.13.1' + implementation 'androidx.appcompat:appcompat:1.7.0' + implementation 'com.google.android.material:material:1.12.0' //Google官方授权框架 implementation 'pub.devrel:easypermissions:3.0.0' - //沉浸式状态栏。基础依赖包,必须要依赖 - implementation 'com.gyf.immersionbar:immersionbar:3.0.0' - //fragment快速实现 - implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0' + //沉浸式状态栏 + implementation 'com.geyifeng.immersionbar:immersionbar:3.2.2' //官方Json解析库 implementation 'com.google.code.gson:gson:2.10.1' - def vm_version = '2.5.1' //Kotlin协程 - implementation "androidx.lifecycle:lifecycle-runtime-ktx:${vm_version}" + implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.2' //MVVM+LiveData - implementation "androidx.lifecycle:lifecycle-livedata-ktx:${vm_version}" - implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:${vm_version}" - implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.6.2' + implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2' + implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' //返回值转换器 implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' @@ -105,9 +92,10 @@ implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' //网络请求和接口封装 implementation 'com.squareup.retrofit2:retrofit:2.9.0' - implementation 'com.squareup.okhttp3:okhttp:4.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.12.0' //数据库框架 - implementation 'org.greenrobot:greendao:3.3.0' + implementation 'androidx.room:room-runtime:2.6.1' + annotationProcessor 'androidx.room:room-compiler:2.5.2' //高德导航、定位、地图三合一 implementation 'com.amap.api:navi-3dmap:latest.integration' //经纬度逆编码 @@ -115,7 +103,7 @@ //excel implementation 'net.sourceforge.jexcelapi:jxl:2.6.12' //图片加载框架 - implementation 'com.github.bumptech.glide:glide:4.9.0' + implementation 'com.github.bumptech.glide:glide:4.12.0' //图片选择框架 implementation 'io.github.lucksiege:pictureselector:v3.11.1' //大图 diff --git a/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt b/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt index 7b695ff..50ba734 100644 --- a/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt +++ b/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt @@ -4,9 +4,9 @@ import android.app.Application import android.os.Bundle import android.util.Log -import com.casic.common.detector.gd.greendao.DaoMaster -import com.casic.common.detector.gd.greendao.DaoSession +import androidx.room.Room.databaseBuilder import com.casic.common.detector.gd.uart.SerialPort +import com.casic.common.detector.gd.utils.DetectorDataBase import com.casic.common.detector.gd.utils.GpioManager import com.pengxh.kt.lite.extensions.show import com.pengxh.kt.lite.utils.SaveKeyValues @@ -43,44 +43,42 @@ private var application: BaseApplication by Delegates.notNull() fun get() = application - - private lateinit var daoSession: DaoSession } + lateinit var dataBase: DetectorDataBase + override fun onCreate() { super.onCreate() application = this SaveKeyValues.initSharedPreferences(this) CrashReport.initCrashReport(this, "01e80d3a74", true) - val devOpenHelper = DaoMaster.DevOpenHelper(this, "Detector.db", null) - val daoMaster = DaoMaster(devOpenHelper.writableDatabase) - daoSession = daoMaster.newSession() + dataBase = databaseBuilder(this, DetectorDataBase::class.java, "Detector.db") + .allowMainThreadQueries() + .build() /** * Open the serial port * */ try { serialPorts.apply { - add(SerialPort(File("/dev/ttysWK1"), 9600, 0)) - //千寻报文数据下发串口号 - add(SerialPort(File("/dev/ttyS1"), 9600, 0)) + add(SerialPort(File("/dev/ttysWK1"), 9600, 0)) //信号通讯串口 + add(SerialPort(File("/dev/ttyS1"), 9600, 0)) //千寻报文数据下发串口号 } Log.d(kTag, "onCreate: 已初始化 ${serialPorts.size} 个串口") } catch (e: SecurityException) { "您没有串口的读写权限!".show(this) + e.printStackTrace() } catch (e: IOException) { "因为不明原因,串口无法打开!".show(this) + e.printStackTrace() } catch (e: InvalidParameterException) { "请检查串口!".show(this) + e.printStackTrace() } registerActivityLifecycleCallbacks(this) } - fun getDaoSession(): DaoSession { - return daoSession - } - override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) { } diff --git a/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt b/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt index 053b9dd..1d0c9e3 100644 --- a/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt +++ b/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt @@ -14,12 +14,10 @@ import com.casic.common.detector.gd.utils.SerialPortCommand import com.pengxh.kt.lite.utils.WeakReferenceHandler import java.io.IOException -import java.util.Timer abstract class SerialPortBaseActivity : AppCompatActivity(), Handler.Callback { private val kTag = "SerialPortBaseActivity" - private val taskTimer by lazy { Timer() } private val weakReferenceHandler by lazy { WeakReferenceHandler(this) } private val serialPorts by lazy { BaseApplication.get().getSerialPorts() } protected lateinit var binding: VB @@ -30,7 +28,6 @@ setContentView(binding.root) setupTopBarLayout() initOnCreate(savedInstanceState) - observeRequestState() initEvent() if (serialPorts.isNotEmpty()) { @@ -71,11 +68,6 @@ abstract fun initOnCreate(savedInstanceState: Bundle?) /** - * 数据请求状态监听 - */ - abstract fun observeRequestState() - - /** * 初始化业务逻辑 */ abstract fun initEvent() diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java new file mode 100644 index 0000000..7a18c20 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java @@ -0,0 +1,255 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 从平台下载的标识器本地库实体类 + */ +@Entity(tableName = "marker_detail") +public class MarkerBean { + @PrimaryKey(autoGenerate = true) + private long id; //主键ID + private String pipelineType; // 管线类型 + private String pipelineDiameter; // 管线直径 + private String pipelineMaterial; // 管材 + private String buryMethod; // 埋设方式 + private String buryDepth; // 埋深 + private String area; // 所属区域 + private String line; // 所属线路 + private String road; // 所属道路 + private String constructTime; // 建设年代 + private String owner; // 权属单位 + private String objectId; // 标识对象ID,无实际用途 + private String markerId; // 标识器ID + private String markerType; // 标识器类型 + private String markerDepth; // 标识器埋深 + private String installationDept; // 安装部门 + private String lng; // 经度 + private String lat; // 纬度 + private String updateTime; // 最后修改时间,更新时间 + private String remark; // 备注信息 + private String underlyingPipelineType; // 下层管线类型 + private String underlyingPipelineDepth; // 下层埋深 + private String underlyingPipelineDiameter; // 下层管径 + private String underlyingPipelineMaterial; // 下层管材 + private String objectType; //标识对象类型 + private String color; // 颜色 + private String imagePath; // 图片路径 + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getPipelineType() { + return pipelineType; + } + + public void setPipelineType(String pipelineType) { + this.pipelineType = pipelineType; + } + + public String getPipelineDiameter() { + return pipelineDiameter; + } + + public void setPipelineDiameter(String pipelineDiameter) { + this.pipelineDiameter = pipelineDiameter; + } + + public String getPipelineMaterial() { + return pipelineMaterial; + } + + public void setPipelineMaterial(String pipelineMaterial) { + this.pipelineMaterial = pipelineMaterial; + } + + public String getBuryMethod() { + return buryMethod; + } + + public void setBuryMethod(String buryMethod) { + this.buryMethod = buryMethod; + } + + public String getBuryDepth() { + return buryDepth; + } + + public void setBuryDepth(String buryDepth) { + this.buryDepth = buryDepth; + } + + public String getArea() { + return area; + } + + public void setArea(String area) { + this.area = area; + } + + public String getLine() { + return line; + } + + public void setLine(String line) { + this.line = line; + } + + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + + public String getConstructTime() { + return constructTime; + } + + public void setConstructTime(String constructTime) { + this.constructTime = constructTime; + } + + public String getOwner() { + return owner; + } + + public void setOwner(String owner) { + this.owner = owner; + } + + public String getObjectId() { + return objectId; + } + + public void setObjectId(String objectId) { + this.objectId = objectId; + } + + public String getMarkerId() { + return markerId; + } + + public void setMarkerId(String markerId) { + this.markerId = markerId; + } + + public String getMarkerType() { + return markerType; + } + + public void setMarkerType(String markerType) { + this.markerType = markerType; + } + + public String getMarkerDepth() { + return markerDepth; + } + + public void setMarkerDepth(String markerDepth) { + this.markerDepth = markerDepth; + } + + public String getInstallationDept() { + return installationDept; + } + + public void setInstallationDept(String installationDept) { + this.installationDept = installationDept; + } + + public String getLng() { + return lng; + } + + public void setLng(String lng) { + this.lng = lng; + } + + public String getLat() { + return lat; + } + + public void setLat(String lat) { + this.lat = lat; + } + + public String getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } + + public String getUnderlyingPipelineType() { + return underlyingPipelineType; + } + + public void setUnderlyingPipelineType(String underlyingPipelineType) { + this.underlyingPipelineType = underlyingPipelineType; + } + + public String getUnderlyingPipelineDepth() { + return underlyingPipelineDepth; + } + + public void setUnderlyingPipelineDepth(String underlyingPipelineDepth) { + this.underlyingPipelineDepth = underlyingPipelineDepth; + } + + public String getUnderlyingPipelineDiameter() { + return underlyingPipelineDiameter; + } + + public void setUnderlyingPipelineDiameter(String underlyingPipelineDiameter) { + this.underlyingPipelineDiameter = underlyingPipelineDiameter; + } + + public String getUnderlyingPipelineMaterial() { + return underlyingPipelineMaterial; + } + + public void setUnderlyingPipelineMaterial(String underlyingPipelineMaterial) { + this.underlyingPipelineMaterial = underlyingPipelineMaterial; + } + + public String getObjectType() { + return objectType; + } + + public void setObjectType(String objectType) { + this.objectType = objectType; + } + + public String getColor() { + return color; + } + + public void setColor(String color) { + this.color = color; + } + + public String getImagePath() { + return imagePath; + } + + public void setImagePath(String imagePath) { + this.imagePath = imagePath; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java deleted file mode 100644 index 3f2fcdc..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java +++ /dev/null @@ -1,327 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 从平台下载的标识器本地库实体类 - */ -@Entity -public class MarkerLocalBean { - @Id(autoincrement = true) - private Long id;//本地库主键ID - - // 管线类型 - private String pipelineType; - // 管线直径 - private String pipelineDiameter; - // 管材 - private String pipelineMaterial; - // 埋设方式 - private String buryMethod; - // 埋深 - private String buryDepth; - // 所属区域 - private String area; - // 所属线路 - private String line; - // 所属道路 - private String road; - // 建设年代 - private String constructTime; - // 权属单位 - private String owner; - //标识对象ID,无实际用途 - @Deprecated - private String objectId; - // 标识器ID - private String markerId; - // 标识器类型 - private String markerType; - // 标识器埋深 - private String markerDepth; - // 安装部门 - private String installationDept; - // 经度 - private String lng; - // 纬度 - private String lat; - //最后修改时间,更新时间 - private String updateTime; - // 备注信息 - private String remark; - // 下层管线类型 - private String underlyingPipelineType; - // 下层埋深 - private String underlyingPipelineDepth; - // 下层管径 - private String underlyingPipelineDiameter; - // 下层管材 - private String underlyingPipelineMaterial; - //标识对象类型 - private String objectType; - // 颜色 - private String color; - // 图片路径 - private String imagePath; - - @Generated(hash = 1479045776) - public MarkerLocalBean(Long id, String pipelineType, String pipelineDiameter, - String pipelineMaterial, String buryMethod, String buryDepth, - String area, String line, String road, String constructTime, - String owner, String objectId, String markerId, String markerType, - String markerDepth, String installationDept, String lng, String lat, - String updateTime, String remark, String underlyingPipelineType, - String underlyingPipelineDepth, String underlyingPipelineDiameter, - String underlyingPipelineMaterial, String objectType, String color, - String imagePath) { - this.id = id; - this.pipelineType = pipelineType; - this.pipelineDiameter = pipelineDiameter; - this.pipelineMaterial = pipelineMaterial; - this.buryMethod = buryMethod; - this.buryDepth = buryDepth; - this.area = area; - this.line = line; - this.road = road; - this.constructTime = constructTime; - this.owner = owner; - this.objectId = objectId; - this.markerId = markerId; - this.markerType = markerType; - this.markerDepth = markerDepth; - this.installationDept = installationDept; - this.lng = lng; - this.lat = lat; - this.updateTime = updateTime; - this.remark = remark; - this.underlyingPipelineType = underlyingPipelineType; - this.underlyingPipelineDepth = underlyingPipelineDepth; - this.underlyingPipelineDiameter = underlyingPipelineDiameter; - this.underlyingPipelineMaterial = underlyingPipelineMaterial; - this.objectType = objectType; - this.color = color; - this.imagePath = imagePath; - } - - @Generated(hash = 1538606012) - public MarkerLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getPipelineType() { - return this.pipelineType; - } - - public void setPipelineType(String pipelineType) { - this.pipelineType = pipelineType; - } - - public String getPipelineDiameter() { - return this.pipelineDiameter; - } - - public void setPipelineDiameter(String pipelineDiameter) { - this.pipelineDiameter = pipelineDiameter; - } - - public String getPipelineMaterial() { - return this.pipelineMaterial; - } - - public void setPipelineMaterial(String pipelineMaterial) { - this.pipelineMaterial = pipelineMaterial; - } - - public String getBuryMethod() { - return this.buryMethod; - } - - public void setBuryMethod(String buryMethod) { - this.buryMethod = buryMethod; - } - - public String getBuryDepth() { - return this.buryDepth; - } - - public void setBuryDepth(String buryDepth) { - this.buryDepth = buryDepth; - } - - public String getArea() { - return this.area; - } - - public void setArea(String area) { - this.area = area; - } - - public String getLine() { - return this.line; - } - - public void setLine(String line) { - this.line = line; - } - - public String getRoad() { - return this.road; - } - - public void setRoad(String road) { - this.road = road; - } - - public String getConstructTime() { - return this.constructTime; - } - - public void setConstructTime(String constructTime) { - this.constructTime = constructTime; - } - - public String getOwner() { - return this.owner; - } - - public void setOwner(String owner) { - this.owner = owner; - } - - public String getObjectId() { - return this.objectId; - } - - public void setObjectId(String objectId) { - this.objectId = objectId; - } - - public String getMarkerId() { - return this.markerId; - } - - public void setMarkerId(String markerId) { - this.markerId = markerId; - } - - public String getMarkerType() { - return this.markerType; - } - - public void setMarkerType(String markerType) { - this.markerType = markerType; - } - - public String getMarkerDepth() { - return this.markerDepth; - } - - public void setMarkerDepth(String markerDepth) { - this.markerDepth = markerDepth; - } - - public String getInstallationDept() { - return this.installationDept; - } - - public void setInstallationDept(String installationDept) { - this.installationDept = installationDept; - } - - public String getLng() { - return this.lng; - } - - public void setLng(String lng) { - this.lng = lng; - } - - public String getLat() { - return this.lat; - } - - public void setLat(String lat) { - this.lat = lat; - } - - public String getUpdateTime() { - return this.updateTime; - } - - public void setUpdateTime(String updateTime) { - this.updateTime = updateTime; - } - - public String getRemark() { - return this.remark; - } - - public void setRemark(String remark) { - this.remark = remark; - } - - public String getUnderlyingPipelineType() { - return this.underlyingPipelineType; - } - - public void setUnderlyingPipelineType(String underlyingPipelineType) { - this.underlyingPipelineType = underlyingPipelineType; - } - - public String getUnderlyingPipelineDepth() { - return this.underlyingPipelineDepth; - } - - public void setUnderlyingPipelineDepth(String underlyingPipelineDepth) { - this.underlyingPipelineDepth = underlyingPipelineDepth; - } - - public String getUnderlyingPipelineDiameter() { - return this.underlyingPipelineDiameter; - } - - public void setUnderlyingPipelineDiameter(String underlyingPipelineDiameter) { - this.underlyingPipelineDiameter = underlyingPipelineDiameter; - } - - public String getUnderlyingPipelineMaterial() { - return this.underlyingPipelineMaterial; - } - - public void setUnderlyingPipelineMaterial(String underlyingPipelineMaterial) { - this.underlyingPipelineMaterial = underlyingPipelineMaterial; - } - - public String getObjectType() { - return this.objectType; - } - - public void setObjectType(String objectType) { - this.objectType = objectType; - } - - public String getColor() { - return this.color; - } - - public void setColor(String color) { - this.color = color; - } - - public String getImagePath() { - return this.imagePath; - } - - public void setImagePath(String imagePath) { - this.imagePath = imagePath; - } -} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java new file mode 100644 index 0000000..5c88fdf --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java @@ -0,0 +1,93 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 巡检任务本地库实体类,不包含任务里面需要巡检的标识器信息 + */ +@Entity(tableName = "task_detail") +public class TaskBean { + @PrimaryKey(autoGenerate = true) + private long id;//主键ID + private String taskCode; // 任务编号 + private String description; // 任务名称 + private String createTime; // 任务创建的时间 + private String status; // 任务状态 + private String createUserName; // 任务创建者名称 + private String startTime; // 任务被开始执行的时间 + private String endTime; // 任务执行结束的时间 + private String isFree; // 是否自由巡检。1-是,0-否 + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getTaskCode() { + return taskCode; + } + + public void setTaskCode(String taskCode) { + this.taskCode = taskCode; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getCreateUserName() { + return createUserName; + } + + public void setCreateUserName(String createUserName) { + this.createUserName = createUserName; + } + + public String getStartTime() { + return startTime; + } + + public void setStartTime(String startTime) { + this.startTime = startTime; + } + + public String getEndTime() { + return endTime; + } + + public void setEndTime(String endTime) { + this.endTime = endTime; + } + + public String getIsFree() { + return isFree; + } + + public void setIsFree(String isFree) { + this.isFree = isFree; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java deleted file mode 100644 index 91737b3..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java +++ /dev/null @@ -1,114 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 巡检任务本地库实体类,不包含任务里面需要巡检的标识器信息 - */ -@Entity -public class TaskLocalBean { - @Id - private Long id;//任务ID - - private String taskCode;//任务编号 - private String description;//任务名称 - private String createTime;//任务创建的时间 - private String status;//任务状态 - private String createUserName;//任务创建者名称 - private String startTime;//任务被开始执行的时间 - private String endTime;//任务执行结束的时间 - private String isFreeTask;//是否自由巡检。1-是,0-否 - - @Generated(hash = 1482022528) - public TaskLocalBean(Long id, String taskCode, String description, - String createTime, String status, String createUserName, - String startTime, String endTime, String isFreeTask) { - this.id = id; - this.taskCode = taskCode; - this.description = description; - this.createTime = createTime; - this.status = status; - this.createUserName = createUserName; - this.startTime = startTime; - this.endTime = endTime; - this.isFreeTask = isFreeTask; - } - - @Generated(hash = 949704588) - public TaskLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getTaskCode() { - return this.taskCode; - } - - public void setTaskCode(String taskCode) { - this.taskCode = taskCode; - } - - public String getDescription() { - return this.description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getCreateTime() { - return this.createTime; - } - - public void setCreateTime(String createTime) { - this.createTime = createTime; - } - - public String getStatus() { - return this.status; - } - - public void setStatus(String status) { - this.status = status; - } - - public String getCreateUserName() { - return this.createUserName; - } - - public void setCreateUserName(String createUserName) { - this.createUserName = createUserName; - } - - public String getStartTime() { - return this.startTime; - } - - public void setStartTime(String startTime) { - this.startTime = startTime; - } - - public String getEndTime() { - return this.endTime; - } - - public void setEndTime(String endTime) { - this.endTime = endTime; - } - - public String getIsFreeTask() { - return this.isFreeTask; - } - - public void setIsFreeTask(String isFreeTask) { - this.isFreeTask = isFreeTask; - } -} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerBean.java new file mode 100644 index 0000000..c563a60 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerBean.java @@ -0,0 +1,110 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 巡检任务里面需要巡检的标识器信息本地库实体类 + */ +@Entity(tableName = "task_marker_info") +public class TaskMarkerBean { + //标识器后台库的主键ID,不是标识器实际ID + @PrimaryKey(autoGenerate = true) + private long id; + + /** + * 任务ID,通过此字段关联[TaskBean.id] + */ + private String taskId; + + /** + * 任务Code,通过此字段关联[TaskBean.taskCode] + *

+ *

+ * 双重验证,防止出现同时刻重复的情况 + */ + private String taskCode; + + /** + * 对应后台字段[TaskModel.MessageModel.TaskDetailInfosModel.markerIdReal],也就是探测仪扫描出来的ID + */ + private String markerId; + + private Double lng; + private Double lat; + + /** + * 是否已被探测到 + * 1-是,0-否 + */ + private String isDetected; + + /** + * 被探测到的时间,对应后台字段[TaskModel.MessageModel.TaskDetailInfosModel.finishTime] + */ + private String detectedTime; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getTaskId() { + return taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getTaskCode() { + return taskCode; + } + + public void setTaskCode(String taskCode) { + this.taskCode = taskCode; + } + + public String getMarkerId() { + return markerId; + } + + public void setMarkerId(String markerId) { + this.markerId = markerId; + } + + public Double getLng() { + return lng; + } + + public void setLng(Double lng) { + this.lng = lng; + } + + public Double getLat() { + return lat; + } + + public void setLat(Double lat) { + this.lat = lat; + } + + public String getIsDetected() { + return isDetected; + } + + public void setIsDetected(String isDetected) { + this.isDetected = isDetected; + } + + public String getDetectedTime() { + return detectedTime; + } + + public void setDetectedTime(String detectedTime) { + this.detectedTime = detectedTime; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerLocalBean.java deleted file mode 100644 index de9f459..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerLocalBean.java +++ /dev/null @@ -1,128 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import com.casic.common.detector.gd.model.TaskModel; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 巡检任务里面需要巡检的标识器信息本地库实体类 - */ -@Entity -public class TaskMarkerLocalBean { - @Id - private Long id;//标识器后台库的主键ID,不是标识器实际ID - - /** - * 任务ID,通过此字段关联{@link TaskLocalBean#id} - */ - private String taskId; - - /** - * 任务Code,通过此字段关联{@link TaskLocalBean#taskCode} - *

- * 双重验证,防止出现同时刻重复的情况 - */ - private String taskCode; - - /** - * 对应后台字段{@link TaskModel.MessageModel.TaskDetailInfosModel#markerIdReal},也就是探测仪扫描出来的ID - */ - private String markerId; - - private double lng; - private double lat; - - /** - * 是否已被探测到 - * 1-是,0-否 - */ - private String isDetected; - - /** - * 被探测到的时间,对应后台字段{@link TaskModel.MessageModel.TaskDetailInfosModel#finishTime} - */ - private String detectedTime; - - @Generated(hash = 677328533) - public TaskMarkerLocalBean(Long id, String taskId, String taskCode, String markerId, - double lng, double lat, String isDetected, String detectedTime) { - this.id = id; - this.taskId = taskId; - this.taskCode = taskCode; - this.markerId = markerId; - this.lng = lng; - this.lat = lat; - this.isDetected = isDetected; - this.detectedTime = detectedTime; - } - - @Generated(hash = 1162404642) - public TaskMarkerLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getTaskId() { - return this.taskId; - } - - public void setTaskId(String taskId) { - this.taskId = taskId; - } - - public String getTaskCode() { - return this.taskCode; - } - - public void setTaskCode(String taskCode) { - this.taskCode = taskCode; - } - - public String getMarkerId() { - return this.markerId; - } - - public void setMarkerId(String markerId) { - this.markerId = markerId; - } - - public double getLng() { - return this.lng; - } - - public void setLng(double lng) { - this.lng = lng; - } - - public double getLat() { - return this.lat; - } - - public void setLat(double lat) { - this.lat = lat; - } - - public String getIsDetected() { - return this.isDetected; - } - - public void setIsDetected(String isDetected) { - this.isDetected = isDetected; - } - - public String getDetectedTime() { - return this.detectedTime; - } - - public void setDetectedTime(String detectedTime) { - this.detectedTime = detectedTime; - } -} diff --git a/app/src/main/java/com/casic/common/detector/gd/dao/MarkerBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/dao/MarkerBeanDao.java new file mode 100644 index 0000000..2beb7ed --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/dao/MarkerBeanDao.java @@ -0,0 +1,29 @@ +package com.casic.common.detector.gd.dao; + +import androidx.room.Dao; +import androidx.room.Insert; +import androidx.room.Query; +import androidx.room.RawQuery; +import androidx.sqlite.db.SupportSQLiteQuery; + +import com.casic.common.detector.gd.bean.MarkerBean; + +import java.util.List; + +@Dao +public interface MarkerBeanDao { + @Query("DELETE FROM marker_detail") + void deleteAll(); + + @Insert + void insert(MarkerBean marker); + + @Query("SELECT * FROM marker_detail") + List loadAll(); + + @Query("SELECT * FROM marker_detail WHERE markerId = :markerId") + List queryMarkerById(String markerId); + + @RawQuery + List loadMarkersByCondition(SupportSQLiteQuery query); +} diff --git a/app/src/main/java/com/casic/common/detector/gd/dao/TaskBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/dao/TaskBeanDao.java new file mode 100644 index 0000000..9c70ac2 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/dao/TaskBeanDao.java @@ -0,0 +1,120 @@ +package com.casic.common.detector.gd.dao; + +import androidx.room.Dao; +import androidx.room.Insert; +import androidx.room.Query; +import androidx.room.Transaction; + +import com.casic.common.detector.gd.bean.TaskBean; +import com.casic.common.detector.gd.bean.TaskMarkerBean; +import com.casic.common.detector.gd.model.TaskDetailLocalModel; +import com.casic.common.detector.gd.model.TaskModel; +import com.casic.common.detector.gd.utils.LocaleConstant; +import com.pengxh.kt.lite.utils.SaveKeyValues; + +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Locale; + +@Dao +public interface TaskBeanDao { + @Query("SELECT COUNT(*) FROM task_detail WHERE id = :taskId") + int isTaskExist(long taskId); + + @Insert + void insert(TaskBean task); + + default void saveTask(Long taskId, String taskName) { + if (isTaskExist(taskId) == 0) { + TaskBean task = new TaskBean(); + task.setId(taskId); + task.setTaskCode(new SimpleDateFormat("yyyyMMddHHmmss", Locale.CHINA).format(new Date())); + task.setDescription(taskName); + String time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA).format(new Date()); + task.setCreateTime(time); + task.setStatus("0"); + String userName = (String) SaveKeyValues.INSTANCE.getValue(LocaleConstant.USER_NAME, ""); + task.setCreateUserName(userName); + task.setStartTime(time); + task.setEndTime(""); + task.setIsFree("1"); + insert(task); + } + } + + default void saveTask(TaskModel.MessageModel model) { + TaskBean task = new TaskBean(); + task.setId(model.getId()); + task.setTaskCode(model.getTaskCode()); + task.setDescription(model.getDescription()); + task.setCreateTime(model.getDeployDate()); + task.setStatus(model.getStatus()); + task.setCreateUserName(model.getCreatorName()); + task.setStartTime(model.getBeginDate()); + task.setEndTime(model.getEndDate()); + task.setIsFree("0"); + if (isTaskExist(task.getId()) == 0) { + insert(task); + } + } + + @Query("SELECT * FROM task_detail") + List loadAll(); + + @Transaction + default ArrayList loadLocalTask(TaskMarkerBeanDao taskMarkerBeanDao) { + ArrayList result = new ArrayList<>(); + List tasks = loadAll(); + for (TaskBean it : tasks) { + TaskDetailLocalModel model = new TaskDetailLocalModel(); + model.setTaskId(String.valueOf(it.getId())); + model.setTaskCode(it.getTaskCode()); + model.setDescription(it.getDescription()); + model.setCreateTime(it.getCreateTime()); + model.setStatus(it.getStatus()); + model.setCreateUserName(it.getCreateUserName()); + model.setIsFreeTask(it.getIsFree()); + ArrayList results = new ArrayList<>(); + if ("0".equals(it.getIsFree())) { + // 非自由巡检才有Marker + List markers = taskMarkerBeanDao.getMarkersByIdAndCode(String.valueOf(it.getId()), it.getTaskCode()); + for (TaskMarkerBean marker : markers) { + TaskDetailLocalModel.TaskMarkerLocalModel localModel = new TaskDetailLocalModel.TaskMarkerLocalModel(); + localModel.setMarkerId(marker.getMarkerId()); + localModel.setLng(marker.getLng()); + localModel.setLat(marker.getLat()); + localModel.setIsDetected(marker.getIsDetected()); + localModel.setDetectedTime(marker.getDetectedTime()); + + results.add(localModel); + } + } + model.setMarkerModels(results); + result.add(model); + } + return result; + } + + @Query("DELETE FROM task_detail WHERE id = :taskId AND taskCode = :taskCode") + void deleteTaskById(long taskId, String taskCode); + + @Transaction + default void deleteLocalTaskById(long taskId, String taskCode, TaskMarkerBeanDao taskMarkerBeanDao) { + TaskBean task = loadAll().stream() + .filter(it -> it.getId() == taskId && taskCode.equals(it.getTaskCode())) + .findFirst() + .orElse(null); + if (task == null) return; + deleteTaskById(taskId, taskCode); + + // 删除此任务关联的Marker。非自由巡检才有Marker + if ("0".equals(task.getIsFree())) { + List markers = taskMarkerBeanDao.getMarkersByIdAndCode(String.valueOf(task.getId()), task.getTaskCode()); + for (TaskMarkerBean marker : markers) { + taskMarkerBeanDao.delete(marker); + } + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/dao/TaskMarkerBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/dao/TaskMarkerBeanDao.java new file mode 100644 index 0000000..cc2156a --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/dao/TaskMarkerBeanDao.java @@ -0,0 +1,52 @@ +package com.casic.common.detector.gd.dao; + +import androidx.room.Dao; +import androidx.room.Delete; +import androidx.room.Insert; +import androidx.room.Query; +import androidx.room.Update; + +import com.casic.common.detector.gd.bean.TaskMarkerBean; +import com.casic.common.detector.gd.model.TaskModel; + +import java.util.List; + +@Dao +public interface TaskMarkerBeanDao { + + @Insert + void insert(TaskMarkerBean marker); + + @Query("SELECT COUNT(*) FROM task_marker_info WHERE id = :markerId") + int isMarkerExist(String markerId); + + default void saveTaskMarker(long taskId, String taskCode, TaskModel.MessageModel.TaskDetailInfosModel marker) { + if (isMarkerExist(marker.getMarkerId()) == 0) { + TaskMarkerBean bean = new TaskMarkerBean(); + bean.setId(marker.getId()); + bean.setTaskId(String.valueOf(taskId)); + bean.setTaskCode(taskCode); + bean.setMarkerId(marker.getMarkerIdReal()); + bean.setLng(marker.getLongitude()); + bean.setLat(marker.getLatitude()); + bean.setIsDetected("0"); + bean.setDetectedTime(""); + insert(bean); + } + } + + @Query("SELECT * FROM task_marker_info WHERE taskId = :taskId AND taskCode = :taskCode AND markerId = :markerId AND isDetected = :state") + TaskMarkerBean queryTaskMarkerById(String taskId, String taskCode, String markerId, String state); + + @Update + void updateLocalTaskMarkerState(TaskMarkerBean marker); + + @Query("SELECT * FROM task_marker_info WHERE isDetected = :state") + List queryMarkerByState(String state); + + @Query("SELECT * FROM task_marker_info WHERE taskId = :taskId AND taskCode = :taskCode") + List getMarkersByIdAndCode(String taskId, String taskCode); + + @Delete + void delete(TaskMarkerBean marker); +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/extensions/Long.kt b/app/src/main/java/com/casic/common/detector/gd/extensions/Long.kt deleted file mode 100644 index 6713d8d..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/extensions/Long.kt +++ /dev/null @@ -1,10 +0,0 @@ -package com.casic.common.detector.gd.extensions - -import java.text.SimpleDateFormat -import java.util.Date -import java.util.Locale - -fun Long.createTaskCode(): String { - val dateFormat = SimpleDateFormat("yyyyMMddHHmmss", Locale.CHINA) - return dateFormat.format(Date(this)) -} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoMaster.java b/app/src/main/java/com/casic/common/detector/gd/greendao/DaoMaster.java deleted file mode 100644 index 6ab94b3..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoMaster.java +++ /dev/null @@ -1,102 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import android.content.Context; -import android.database.sqlite.SQLiteDatabase; -import android.database.sqlite.SQLiteDatabase.CursorFactory; -import android.util.Log; - -import org.greenrobot.greendao.AbstractDaoMaster; -import org.greenrobot.greendao.database.StandardDatabase; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.database.DatabaseOpenHelper; -import org.greenrobot.greendao.identityscope.IdentityScopeType; - - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** - * Master of DAO (schema version 1): knows all DAOs. - */ -public class DaoMaster extends AbstractDaoMaster { - public static final int SCHEMA_VERSION = 1; - - /** Creates underlying database table using DAOs. */ - public static void createAllTables(Database db, boolean ifNotExists) { - MarkerLocalBeanDao.createTable(db, ifNotExists); - TaskLocalBeanDao.createTable(db, ifNotExists); - TaskMarkerLocalBeanDao.createTable(db, ifNotExists); - } - - /** Drops underlying database table using DAOs. */ - public static void dropAllTables(Database db, boolean ifExists) { - MarkerLocalBeanDao.dropTable(db, ifExists); - TaskLocalBeanDao.dropTable(db, ifExists); - TaskMarkerLocalBeanDao.dropTable(db, ifExists); - } - - /** - * WARNING: Drops all table on Upgrade! Use only during development. - * Convenience method using a {@link DevOpenHelper}. - */ - public static DaoSession newDevSession(Context context, String name) { - Database db = new DevOpenHelper(context, name).getWritableDb(); - DaoMaster daoMaster = new DaoMaster(db); - return daoMaster.newSession(); - } - - public DaoMaster(SQLiteDatabase db) { - this(new StandardDatabase(db)); - } - - public DaoMaster(Database db) { - super(db, SCHEMA_VERSION); - registerDaoClass(MarkerLocalBeanDao.class); - registerDaoClass(TaskLocalBeanDao.class); - registerDaoClass(TaskMarkerLocalBeanDao.class); - } - - public DaoSession newSession() { - return new DaoSession(db, IdentityScopeType.Session, daoConfigMap); - } - - public DaoSession newSession(IdentityScopeType type) { - return new DaoSession(db, type, daoConfigMap); - } - - /** - * Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} - - */ - public static abstract class OpenHelper extends DatabaseOpenHelper { - public OpenHelper(Context context, String name) { - super(context, name, SCHEMA_VERSION); - } - - public OpenHelper(Context context, String name, CursorFactory factory) { - super(context, name, factory, SCHEMA_VERSION); - } - - @Override - public void onCreate(Database db) { - Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION); - createAllTables(db, false); - } - } - - /** WARNING: Drops all table on Upgrade! Use only during development. */ - public static class DevOpenHelper extends OpenHelper { - public DevOpenHelper(Context context, String name) { - super(context, name); - } - - public DevOpenHelper(Context context, String name, CursorFactory factory) { - super(context, name, factory); - } - - @Override - public void onUpgrade(Database db, int oldVersion, int newVersion) { - Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables"); - dropAllTables(db, true); - onCreate(db); - } - } - -} diff --git a/app/build.gradle b/app/build.gradle index d0cb423..921c8c8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,25 +1,20 @@ import java.text.SimpleDateFormat -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply plugin: 'org.greenrobot.greendao' +plugins { + id('com.android.application') + id('org.jetbrains.kotlin.android') +} android { - compileSdkVersion 33 + namespace 'com.casic.common.detector.gd' + compileSdk 35 defaultConfig { - applicationId "com.casic.common.detector.gd" - minSdkVersion 26 - targetSdkVersion 33 + applicationId 'com.casic.common.detector.gd' + minSdk 26 + targetSdk 35 versionCode 5092 - versionName "5.0.9.2" - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } + versionName '5.0.9.2' } signingConfigs { @@ -31,6 +26,14 @@ } } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + signingConfig signingConfigs.release + } + } + compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 @@ -47,27 +50,16 @@ } } - kotlin { - experimental { - coroutines 'enable' - } - } - buildFeatures { + buildConfig true viewBinding true } - applicationVariants.configureEach { variant -> - variant.outputs.configureEach { - outputFileName = "COM_TCY_" + getBuildDate() + "_" + defaultConfig.versionName + ".apk" + applicationVariants.configureEach { + outputs.configureEach { + outputFileName = 'COM_TCY_' + getBuildDate() + '_' + defaultConfig.versionName + '.apk' } } - - greendao { - schemaVersion 1//数据库版本号 - targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 - daoPackage "${defaultConfig.applicationId}.greendao"//设置DaoMaster、DaoSession、Dao包名 - } } static def getBuildDate() { @@ -76,27 +68,22 @@ } dependencies { - //基础依赖库 - implementation 'com.github.AndroidCoderPeng:Kotlin-lite-lib:1.1.4' - implementation 'androidx.core:core-ktx:1.9.0' - def base_version = "1.6.1" - implementation "androidx.appcompat:appcompat:${base_version}" - implementation "com.google.android.material:material:${base_version}" + implementation 'com.github.AndroidCoderPeng:Kotlin-lite-lib:1.1.5' + implementation 'androidx.core:core-ktx:1.13.1' + implementation 'androidx.appcompat:appcompat:1.7.0' + implementation 'com.google.android.material:material:1.12.0' //Google官方授权框架 implementation 'pub.devrel:easypermissions:3.0.0' - //沉浸式状态栏。基础依赖包,必须要依赖 - implementation 'com.gyf.immersionbar:immersionbar:3.0.0' - //fragment快速实现 - implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0' + //沉浸式状态栏 + implementation 'com.geyifeng.immersionbar:immersionbar:3.2.2' //官方Json解析库 implementation 'com.google.code.gson:gson:2.10.1' - def vm_version = '2.5.1' //Kotlin协程 - implementation "androidx.lifecycle:lifecycle-runtime-ktx:${vm_version}" + implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.2' //MVVM+LiveData - implementation "androidx.lifecycle:lifecycle-livedata-ktx:${vm_version}" - implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:${vm_version}" - implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.6.2' + implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2' + implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' //返回值转换器 implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' @@ -105,9 +92,10 @@ implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' //网络请求和接口封装 implementation 'com.squareup.retrofit2:retrofit:2.9.0' - implementation 'com.squareup.okhttp3:okhttp:4.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.12.0' //数据库框架 - implementation 'org.greenrobot:greendao:3.3.0' + implementation 'androidx.room:room-runtime:2.6.1' + annotationProcessor 'androidx.room:room-compiler:2.5.2' //高德导航、定位、地图三合一 implementation 'com.amap.api:navi-3dmap:latest.integration' //经纬度逆编码 @@ -115,7 +103,7 @@ //excel implementation 'net.sourceforge.jexcelapi:jxl:2.6.12' //图片加载框架 - implementation 'com.github.bumptech.glide:glide:4.9.0' + implementation 'com.github.bumptech.glide:glide:4.12.0' //图片选择框架 implementation 'io.github.lucksiege:pictureselector:v3.11.1' //大图 diff --git a/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt b/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt index 7b695ff..50ba734 100644 --- a/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt +++ b/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt @@ -4,9 +4,9 @@ import android.app.Application import android.os.Bundle import android.util.Log -import com.casic.common.detector.gd.greendao.DaoMaster -import com.casic.common.detector.gd.greendao.DaoSession +import androidx.room.Room.databaseBuilder import com.casic.common.detector.gd.uart.SerialPort +import com.casic.common.detector.gd.utils.DetectorDataBase import com.casic.common.detector.gd.utils.GpioManager import com.pengxh.kt.lite.extensions.show import com.pengxh.kt.lite.utils.SaveKeyValues @@ -43,44 +43,42 @@ private var application: BaseApplication by Delegates.notNull() fun get() = application - - private lateinit var daoSession: DaoSession } + lateinit var dataBase: DetectorDataBase + override fun onCreate() { super.onCreate() application = this SaveKeyValues.initSharedPreferences(this) CrashReport.initCrashReport(this, "01e80d3a74", true) - val devOpenHelper = DaoMaster.DevOpenHelper(this, "Detector.db", null) - val daoMaster = DaoMaster(devOpenHelper.writableDatabase) - daoSession = daoMaster.newSession() + dataBase = databaseBuilder(this, DetectorDataBase::class.java, "Detector.db") + .allowMainThreadQueries() + .build() /** * Open the serial port * */ try { serialPorts.apply { - add(SerialPort(File("/dev/ttysWK1"), 9600, 0)) - //千寻报文数据下发串口号 - add(SerialPort(File("/dev/ttyS1"), 9600, 0)) + add(SerialPort(File("/dev/ttysWK1"), 9600, 0)) //信号通讯串口 + add(SerialPort(File("/dev/ttyS1"), 9600, 0)) //千寻报文数据下发串口号 } Log.d(kTag, "onCreate: 已初始化 ${serialPorts.size} 个串口") } catch (e: SecurityException) { "您没有串口的读写权限!".show(this) + e.printStackTrace() } catch (e: IOException) { "因为不明原因,串口无法打开!".show(this) + e.printStackTrace() } catch (e: InvalidParameterException) { "请检查串口!".show(this) + e.printStackTrace() } registerActivityLifecycleCallbacks(this) } - fun getDaoSession(): DaoSession { - return daoSession - } - override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) { } diff --git a/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt b/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt index 053b9dd..1d0c9e3 100644 --- a/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt +++ b/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt @@ -14,12 +14,10 @@ import com.casic.common.detector.gd.utils.SerialPortCommand import com.pengxh.kt.lite.utils.WeakReferenceHandler import java.io.IOException -import java.util.Timer abstract class SerialPortBaseActivity : AppCompatActivity(), Handler.Callback { private val kTag = "SerialPortBaseActivity" - private val taskTimer by lazy { Timer() } private val weakReferenceHandler by lazy { WeakReferenceHandler(this) } private val serialPorts by lazy { BaseApplication.get().getSerialPorts() } protected lateinit var binding: VB @@ -30,7 +28,6 @@ setContentView(binding.root) setupTopBarLayout() initOnCreate(savedInstanceState) - observeRequestState() initEvent() if (serialPorts.isNotEmpty()) { @@ -71,11 +68,6 @@ abstract fun initOnCreate(savedInstanceState: Bundle?) /** - * 数据请求状态监听 - */ - abstract fun observeRequestState() - - /** * 初始化业务逻辑 */ abstract fun initEvent() diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java new file mode 100644 index 0000000..7a18c20 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java @@ -0,0 +1,255 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 从平台下载的标识器本地库实体类 + */ +@Entity(tableName = "marker_detail") +public class MarkerBean { + @PrimaryKey(autoGenerate = true) + private long id; //主键ID + private String pipelineType; // 管线类型 + private String pipelineDiameter; // 管线直径 + private String pipelineMaterial; // 管材 + private String buryMethod; // 埋设方式 + private String buryDepth; // 埋深 + private String area; // 所属区域 + private String line; // 所属线路 + private String road; // 所属道路 + private String constructTime; // 建设年代 + private String owner; // 权属单位 + private String objectId; // 标识对象ID,无实际用途 + private String markerId; // 标识器ID + private String markerType; // 标识器类型 + private String markerDepth; // 标识器埋深 + private String installationDept; // 安装部门 + private String lng; // 经度 + private String lat; // 纬度 + private String updateTime; // 最后修改时间,更新时间 + private String remark; // 备注信息 + private String underlyingPipelineType; // 下层管线类型 + private String underlyingPipelineDepth; // 下层埋深 + private String underlyingPipelineDiameter; // 下层管径 + private String underlyingPipelineMaterial; // 下层管材 + private String objectType; //标识对象类型 + private String color; // 颜色 + private String imagePath; // 图片路径 + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getPipelineType() { + return pipelineType; + } + + public void setPipelineType(String pipelineType) { + this.pipelineType = pipelineType; + } + + public String getPipelineDiameter() { + return pipelineDiameter; + } + + public void setPipelineDiameter(String pipelineDiameter) { + this.pipelineDiameter = pipelineDiameter; + } + + public String getPipelineMaterial() { + return pipelineMaterial; + } + + public void setPipelineMaterial(String pipelineMaterial) { + this.pipelineMaterial = pipelineMaterial; + } + + public String getBuryMethod() { + return buryMethod; + } + + public void setBuryMethod(String buryMethod) { + this.buryMethod = buryMethod; + } + + public String getBuryDepth() { + return buryDepth; + } + + public void setBuryDepth(String buryDepth) { + this.buryDepth = buryDepth; + } + + public String getArea() { + return area; + } + + public void setArea(String area) { + this.area = area; + } + + public String getLine() { + return line; + } + + public void setLine(String line) { + this.line = line; + } + + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + + public String getConstructTime() { + return constructTime; + } + + public void setConstructTime(String constructTime) { + this.constructTime = constructTime; + } + + public String getOwner() { + return owner; + } + + public void setOwner(String owner) { + this.owner = owner; + } + + public String getObjectId() { + return objectId; + } + + public void setObjectId(String objectId) { + this.objectId = objectId; + } + + public String getMarkerId() { + return markerId; + } + + public void setMarkerId(String markerId) { + this.markerId = markerId; + } + + public String getMarkerType() { + return markerType; + } + + public void setMarkerType(String markerType) { + this.markerType = markerType; + } + + public String getMarkerDepth() { + return markerDepth; + } + + public void setMarkerDepth(String markerDepth) { + this.markerDepth = markerDepth; + } + + public String getInstallationDept() { + return installationDept; + } + + public void setInstallationDept(String installationDept) { + this.installationDept = installationDept; + } + + public String getLng() { + return lng; + } + + public void setLng(String lng) { + this.lng = lng; + } + + public String getLat() { + return lat; + } + + public void setLat(String lat) { + this.lat = lat; + } + + public String getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } + + public String getUnderlyingPipelineType() { + return underlyingPipelineType; + } + + public void setUnderlyingPipelineType(String underlyingPipelineType) { + this.underlyingPipelineType = underlyingPipelineType; + } + + public String getUnderlyingPipelineDepth() { + return underlyingPipelineDepth; + } + + public void setUnderlyingPipelineDepth(String underlyingPipelineDepth) { + this.underlyingPipelineDepth = underlyingPipelineDepth; + } + + public String getUnderlyingPipelineDiameter() { + return underlyingPipelineDiameter; + } + + public void setUnderlyingPipelineDiameter(String underlyingPipelineDiameter) { + this.underlyingPipelineDiameter = underlyingPipelineDiameter; + } + + public String getUnderlyingPipelineMaterial() { + return underlyingPipelineMaterial; + } + + public void setUnderlyingPipelineMaterial(String underlyingPipelineMaterial) { + this.underlyingPipelineMaterial = underlyingPipelineMaterial; + } + + public String getObjectType() { + return objectType; + } + + public void setObjectType(String objectType) { + this.objectType = objectType; + } + + public String getColor() { + return color; + } + + public void setColor(String color) { + this.color = color; + } + + public String getImagePath() { + return imagePath; + } + + public void setImagePath(String imagePath) { + this.imagePath = imagePath; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java deleted file mode 100644 index 3f2fcdc..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java +++ /dev/null @@ -1,327 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 从平台下载的标识器本地库实体类 - */ -@Entity -public class MarkerLocalBean { - @Id(autoincrement = true) - private Long id;//本地库主键ID - - // 管线类型 - private String pipelineType; - // 管线直径 - private String pipelineDiameter; - // 管材 - private String pipelineMaterial; - // 埋设方式 - private String buryMethod; - // 埋深 - private String buryDepth; - // 所属区域 - private String area; - // 所属线路 - private String line; - // 所属道路 - private String road; - // 建设年代 - private String constructTime; - // 权属单位 - private String owner; - //标识对象ID,无实际用途 - @Deprecated - private String objectId; - // 标识器ID - private String markerId; - // 标识器类型 - private String markerType; - // 标识器埋深 - private String markerDepth; - // 安装部门 - private String installationDept; - // 经度 - private String lng; - // 纬度 - private String lat; - //最后修改时间,更新时间 - private String updateTime; - // 备注信息 - private String remark; - // 下层管线类型 - private String underlyingPipelineType; - // 下层埋深 - private String underlyingPipelineDepth; - // 下层管径 - private String underlyingPipelineDiameter; - // 下层管材 - private String underlyingPipelineMaterial; - //标识对象类型 - private String objectType; - // 颜色 - private String color; - // 图片路径 - private String imagePath; - - @Generated(hash = 1479045776) - public MarkerLocalBean(Long id, String pipelineType, String pipelineDiameter, - String pipelineMaterial, String buryMethod, String buryDepth, - String area, String line, String road, String constructTime, - String owner, String objectId, String markerId, String markerType, - String markerDepth, String installationDept, String lng, String lat, - String updateTime, String remark, String underlyingPipelineType, - String underlyingPipelineDepth, String underlyingPipelineDiameter, - String underlyingPipelineMaterial, String objectType, String color, - String imagePath) { - this.id = id; - this.pipelineType = pipelineType; - this.pipelineDiameter = pipelineDiameter; - this.pipelineMaterial = pipelineMaterial; - this.buryMethod = buryMethod; - this.buryDepth = buryDepth; - this.area = area; - this.line = line; - this.road = road; - this.constructTime = constructTime; - this.owner = owner; - this.objectId = objectId; - this.markerId = markerId; - this.markerType = markerType; - this.markerDepth = markerDepth; - this.installationDept = installationDept; - this.lng = lng; - this.lat = lat; - this.updateTime = updateTime; - this.remark = remark; - this.underlyingPipelineType = underlyingPipelineType; - this.underlyingPipelineDepth = underlyingPipelineDepth; - this.underlyingPipelineDiameter = underlyingPipelineDiameter; - this.underlyingPipelineMaterial = underlyingPipelineMaterial; - this.objectType = objectType; - this.color = color; - this.imagePath = imagePath; - } - - @Generated(hash = 1538606012) - public MarkerLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getPipelineType() { - return this.pipelineType; - } - - public void setPipelineType(String pipelineType) { - this.pipelineType = pipelineType; - } - - public String getPipelineDiameter() { - return this.pipelineDiameter; - } - - public void setPipelineDiameter(String pipelineDiameter) { - this.pipelineDiameter = pipelineDiameter; - } - - public String getPipelineMaterial() { - return this.pipelineMaterial; - } - - public void setPipelineMaterial(String pipelineMaterial) { - this.pipelineMaterial = pipelineMaterial; - } - - public String getBuryMethod() { - return this.buryMethod; - } - - public void setBuryMethod(String buryMethod) { - this.buryMethod = buryMethod; - } - - public String getBuryDepth() { - return this.buryDepth; - } - - public void setBuryDepth(String buryDepth) { - this.buryDepth = buryDepth; - } - - public String getArea() { - return this.area; - } - - public void setArea(String area) { - this.area = area; - } - - public String getLine() { - return this.line; - } - - public void setLine(String line) { - this.line = line; - } - - public String getRoad() { - return this.road; - } - - public void setRoad(String road) { - this.road = road; - } - - public String getConstructTime() { - return this.constructTime; - } - - public void setConstructTime(String constructTime) { - this.constructTime = constructTime; - } - - public String getOwner() { - return this.owner; - } - - public void setOwner(String owner) { - this.owner = owner; - } - - public String getObjectId() { - return this.objectId; - } - - public void setObjectId(String objectId) { - this.objectId = objectId; - } - - public String getMarkerId() { - return this.markerId; - } - - public void setMarkerId(String markerId) { - this.markerId = markerId; - } - - public String getMarkerType() { - return this.markerType; - } - - public void setMarkerType(String markerType) { - this.markerType = markerType; - } - - public String getMarkerDepth() { - return this.markerDepth; - } - - public void setMarkerDepth(String markerDepth) { - this.markerDepth = markerDepth; - } - - public String getInstallationDept() { - return this.installationDept; - } - - public void setInstallationDept(String installationDept) { - this.installationDept = installationDept; - } - - public String getLng() { - return this.lng; - } - - public void setLng(String lng) { - this.lng = lng; - } - - public String getLat() { - return this.lat; - } - - public void setLat(String lat) { - this.lat = lat; - } - - public String getUpdateTime() { - return this.updateTime; - } - - public void setUpdateTime(String updateTime) { - this.updateTime = updateTime; - } - - public String getRemark() { - return this.remark; - } - - public void setRemark(String remark) { - this.remark = remark; - } - - public String getUnderlyingPipelineType() { - return this.underlyingPipelineType; - } - - public void setUnderlyingPipelineType(String underlyingPipelineType) { - this.underlyingPipelineType = underlyingPipelineType; - } - - public String getUnderlyingPipelineDepth() { - return this.underlyingPipelineDepth; - } - - public void setUnderlyingPipelineDepth(String underlyingPipelineDepth) { - this.underlyingPipelineDepth = underlyingPipelineDepth; - } - - public String getUnderlyingPipelineDiameter() { - return this.underlyingPipelineDiameter; - } - - public void setUnderlyingPipelineDiameter(String underlyingPipelineDiameter) { - this.underlyingPipelineDiameter = underlyingPipelineDiameter; - } - - public String getUnderlyingPipelineMaterial() { - return this.underlyingPipelineMaterial; - } - - public void setUnderlyingPipelineMaterial(String underlyingPipelineMaterial) { - this.underlyingPipelineMaterial = underlyingPipelineMaterial; - } - - public String getObjectType() { - return this.objectType; - } - - public void setObjectType(String objectType) { - this.objectType = objectType; - } - - public String getColor() { - return this.color; - } - - public void setColor(String color) { - this.color = color; - } - - public String getImagePath() { - return this.imagePath; - } - - public void setImagePath(String imagePath) { - this.imagePath = imagePath; - } -} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java new file mode 100644 index 0000000..5c88fdf --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java @@ -0,0 +1,93 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 巡检任务本地库实体类,不包含任务里面需要巡检的标识器信息 + */ +@Entity(tableName = "task_detail") +public class TaskBean { + @PrimaryKey(autoGenerate = true) + private long id;//主键ID + private String taskCode; // 任务编号 + private String description; // 任务名称 + private String createTime; // 任务创建的时间 + private String status; // 任务状态 + private String createUserName; // 任务创建者名称 + private String startTime; // 任务被开始执行的时间 + private String endTime; // 任务执行结束的时间 + private String isFree; // 是否自由巡检。1-是,0-否 + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getTaskCode() { + return taskCode; + } + + public void setTaskCode(String taskCode) { + this.taskCode = taskCode; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getCreateUserName() { + return createUserName; + } + + public void setCreateUserName(String createUserName) { + this.createUserName = createUserName; + } + + public String getStartTime() { + return startTime; + } + + public void setStartTime(String startTime) { + this.startTime = startTime; + } + + public String getEndTime() { + return endTime; + } + + public void setEndTime(String endTime) { + this.endTime = endTime; + } + + public String getIsFree() { + return isFree; + } + + public void setIsFree(String isFree) { + this.isFree = isFree; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java deleted file mode 100644 index 91737b3..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java +++ /dev/null @@ -1,114 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 巡检任务本地库实体类,不包含任务里面需要巡检的标识器信息 - */ -@Entity -public class TaskLocalBean { - @Id - private Long id;//任务ID - - private String taskCode;//任务编号 - private String description;//任务名称 - private String createTime;//任务创建的时间 - private String status;//任务状态 - private String createUserName;//任务创建者名称 - private String startTime;//任务被开始执行的时间 - private String endTime;//任务执行结束的时间 - private String isFreeTask;//是否自由巡检。1-是,0-否 - - @Generated(hash = 1482022528) - public TaskLocalBean(Long id, String taskCode, String description, - String createTime, String status, String createUserName, - String startTime, String endTime, String isFreeTask) { - this.id = id; - this.taskCode = taskCode; - this.description = description; - this.createTime = createTime; - this.status = status; - this.createUserName = createUserName; - this.startTime = startTime; - this.endTime = endTime; - this.isFreeTask = isFreeTask; - } - - @Generated(hash = 949704588) - public TaskLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getTaskCode() { - return this.taskCode; - } - - public void setTaskCode(String taskCode) { - this.taskCode = taskCode; - } - - public String getDescription() { - return this.description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getCreateTime() { - return this.createTime; - } - - public void setCreateTime(String createTime) { - this.createTime = createTime; - } - - public String getStatus() { - return this.status; - } - - public void setStatus(String status) { - this.status = status; - } - - public String getCreateUserName() { - return this.createUserName; - } - - public void setCreateUserName(String createUserName) { - this.createUserName = createUserName; - } - - public String getStartTime() { - return this.startTime; - } - - public void setStartTime(String startTime) { - this.startTime = startTime; - } - - public String getEndTime() { - return this.endTime; - } - - public void setEndTime(String endTime) { - this.endTime = endTime; - } - - public String getIsFreeTask() { - return this.isFreeTask; - } - - public void setIsFreeTask(String isFreeTask) { - this.isFreeTask = isFreeTask; - } -} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerBean.java new file mode 100644 index 0000000..c563a60 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerBean.java @@ -0,0 +1,110 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 巡检任务里面需要巡检的标识器信息本地库实体类 + */ +@Entity(tableName = "task_marker_info") +public class TaskMarkerBean { + //标识器后台库的主键ID,不是标识器实际ID + @PrimaryKey(autoGenerate = true) + private long id; + + /** + * 任务ID,通过此字段关联[TaskBean.id] + */ + private String taskId; + + /** + * 任务Code,通过此字段关联[TaskBean.taskCode] + *

+ *

+ * 双重验证,防止出现同时刻重复的情况 + */ + private String taskCode; + + /** + * 对应后台字段[TaskModel.MessageModel.TaskDetailInfosModel.markerIdReal],也就是探测仪扫描出来的ID + */ + private String markerId; + + private Double lng; + private Double lat; + + /** + * 是否已被探测到 + * 1-是,0-否 + */ + private String isDetected; + + /** + * 被探测到的时间,对应后台字段[TaskModel.MessageModel.TaskDetailInfosModel.finishTime] + */ + private String detectedTime; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getTaskId() { + return taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getTaskCode() { + return taskCode; + } + + public void setTaskCode(String taskCode) { + this.taskCode = taskCode; + } + + public String getMarkerId() { + return markerId; + } + + public void setMarkerId(String markerId) { + this.markerId = markerId; + } + + public Double getLng() { + return lng; + } + + public void setLng(Double lng) { + this.lng = lng; + } + + public Double getLat() { + return lat; + } + + public void setLat(Double lat) { + this.lat = lat; + } + + public String getIsDetected() { + return isDetected; + } + + public void setIsDetected(String isDetected) { + this.isDetected = isDetected; + } + + public String getDetectedTime() { + return detectedTime; + } + + public void setDetectedTime(String detectedTime) { + this.detectedTime = detectedTime; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerLocalBean.java deleted file mode 100644 index de9f459..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerLocalBean.java +++ /dev/null @@ -1,128 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import com.casic.common.detector.gd.model.TaskModel; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 巡检任务里面需要巡检的标识器信息本地库实体类 - */ -@Entity -public class TaskMarkerLocalBean { - @Id - private Long id;//标识器后台库的主键ID,不是标识器实际ID - - /** - * 任务ID,通过此字段关联{@link TaskLocalBean#id} - */ - private String taskId; - - /** - * 任务Code,通过此字段关联{@link TaskLocalBean#taskCode} - *

- * 双重验证,防止出现同时刻重复的情况 - */ - private String taskCode; - - /** - * 对应后台字段{@link TaskModel.MessageModel.TaskDetailInfosModel#markerIdReal},也就是探测仪扫描出来的ID - */ - private String markerId; - - private double lng; - private double lat; - - /** - * 是否已被探测到 - * 1-是,0-否 - */ - private String isDetected; - - /** - * 被探测到的时间,对应后台字段{@link TaskModel.MessageModel.TaskDetailInfosModel#finishTime} - */ - private String detectedTime; - - @Generated(hash = 677328533) - public TaskMarkerLocalBean(Long id, String taskId, String taskCode, String markerId, - double lng, double lat, String isDetected, String detectedTime) { - this.id = id; - this.taskId = taskId; - this.taskCode = taskCode; - this.markerId = markerId; - this.lng = lng; - this.lat = lat; - this.isDetected = isDetected; - this.detectedTime = detectedTime; - } - - @Generated(hash = 1162404642) - public TaskMarkerLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getTaskId() { - return this.taskId; - } - - public void setTaskId(String taskId) { - this.taskId = taskId; - } - - public String getTaskCode() { - return this.taskCode; - } - - public void setTaskCode(String taskCode) { - this.taskCode = taskCode; - } - - public String getMarkerId() { - return this.markerId; - } - - public void setMarkerId(String markerId) { - this.markerId = markerId; - } - - public double getLng() { - return this.lng; - } - - public void setLng(double lng) { - this.lng = lng; - } - - public double getLat() { - return this.lat; - } - - public void setLat(double lat) { - this.lat = lat; - } - - public String getIsDetected() { - return this.isDetected; - } - - public void setIsDetected(String isDetected) { - this.isDetected = isDetected; - } - - public String getDetectedTime() { - return this.detectedTime; - } - - public void setDetectedTime(String detectedTime) { - this.detectedTime = detectedTime; - } -} diff --git a/app/src/main/java/com/casic/common/detector/gd/dao/MarkerBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/dao/MarkerBeanDao.java new file mode 100644 index 0000000..2beb7ed --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/dao/MarkerBeanDao.java @@ -0,0 +1,29 @@ +package com.casic.common.detector.gd.dao; + +import androidx.room.Dao; +import androidx.room.Insert; +import androidx.room.Query; +import androidx.room.RawQuery; +import androidx.sqlite.db.SupportSQLiteQuery; + +import com.casic.common.detector.gd.bean.MarkerBean; + +import java.util.List; + +@Dao +public interface MarkerBeanDao { + @Query("DELETE FROM marker_detail") + void deleteAll(); + + @Insert + void insert(MarkerBean marker); + + @Query("SELECT * FROM marker_detail") + List loadAll(); + + @Query("SELECT * FROM marker_detail WHERE markerId = :markerId") + List queryMarkerById(String markerId); + + @RawQuery + List loadMarkersByCondition(SupportSQLiteQuery query); +} diff --git a/app/src/main/java/com/casic/common/detector/gd/dao/TaskBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/dao/TaskBeanDao.java new file mode 100644 index 0000000..9c70ac2 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/dao/TaskBeanDao.java @@ -0,0 +1,120 @@ +package com.casic.common.detector.gd.dao; + +import androidx.room.Dao; +import androidx.room.Insert; +import androidx.room.Query; +import androidx.room.Transaction; + +import com.casic.common.detector.gd.bean.TaskBean; +import com.casic.common.detector.gd.bean.TaskMarkerBean; +import com.casic.common.detector.gd.model.TaskDetailLocalModel; +import com.casic.common.detector.gd.model.TaskModel; +import com.casic.common.detector.gd.utils.LocaleConstant; +import com.pengxh.kt.lite.utils.SaveKeyValues; + +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Locale; + +@Dao +public interface TaskBeanDao { + @Query("SELECT COUNT(*) FROM task_detail WHERE id = :taskId") + int isTaskExist(long taskId); + + @Insert + void insert(TaskBean task); + + default void saveTask(Long taskId, String taskName) { + if (isTaskExist(taskId) == 0) { + TaskBean task = new TaskBean(); + task.setId(taskId); + task.setTaskCode(new SimpleDateFormat("yyyyMMddHHmmss", Locale.CHINA).format(new Date())); + task.setDescription(taskName); + String time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA).format(new Date()); + task.setCreateTime(time); + task.setStatus("0"); + String userName = (String) SaveKeyValues.INSTANCE.getValue(LocaleConstant.USER_NAME, ""); + task.setCreateUserName(userName); + task.setStartTime(time); + task.setEndTime(""); + task.setIsFree("1"); + insert(task); + } + } + + default void saveTask(TaskModel.MessageModel model) { + TaskBean task = new TaskBean(); + task.setId(model.getId()); + task.setTaskCode(model.getTaskCode()); + task.setDescription(model.getDescription()); + task.setCreateTime(model.getDeployDate()); + task.setStatus(model.getStatus()); + task.setCreateUserName(model.getCreatorName()); + task.setStartTime(model.getBeginDate()); + task.setEndTime(model.getEndDate()); + task.setIsFree("0"); + if (isTaskExist(task.getId()) == 0) { + insert(task); + } + } + + @Query("SELECT * FROM task_detail") + List loadAll(); + + @Transaction + default ArrayList loadLocalTask(TaskMarkerBeanDao taskMarkerBeanDao) { + ArrayList result = new ArrayList<>(); + List tasks = loadAll(); + for (TaskBean it : tasks) { + TaskDetailLocalModel model = new TaskDetailLocalModel(); + model.setTaskId(String.valueOf(it.getId())); + model.setTaskCode(it.getTaskCode()); + model.setDescription(it.getDescription()); + model.setCreateTime(it.getCreateTime()); + model.setStatus(it.getStatus()); + model.setCreateUserName(it.getCreateUserName()); + model.setIsFreeTask(it.getIsFree()); + ArrayList results = new ArrayList<>(); + if ("0".equals(it.getIsFree())) { + // 非自由巡检才有Marker + List markers = taskMarkerBeanDao.getMarkersByIdAndCode(String.valueOf(it.getId()), it.getTaskCode()); + for (TaskMarkerBean marker : markers) { + TaskDetailLocalModel.TaskMarkerLocalModel localModel = new TaskDetailLocalModel.TaskMarkerLocalModel(); + localModel.setMarkerId(marker.getMarkerId()); + localModel.setLng(marker.getLng()); + localModel.setLat(marker.getLat()); + localModel.setIsDetected(marker.getIsDetected()); + localModel.setDetectedTime(marker.getDetectedTime()); + + results.add(localModel); + } + } + model.setMarkerModels(results); + result.add(model); + } + return result; + } + + @Query("DELETE FROM task_detail WHERE id = :taskId AND taskCode = :taskCode") + void deleteTaskById(long taskId, String taskCode); + + @Transaction + default void deleteLocalTaskById(long taskId, String taskCode, TaskMarkerBeanDao taskMarkerBeanDao) { + TaskBean task = loadAll().stream() + .filter(it -> it.getId() == taskId && taskCode.equals(it.getTaskCode())) + .findFirst() + .orElse(null); + if (task == null) return; + deleteTaskById(taskId, taskCode); + + // 删除此任务关联的Marker。非自由巡检才有Marker + if ("0".equals(task.getIsFree())) { + List markers = taskMarkerBeanDao.getMarkersByIdAndCode(String.valueOf(task.getId()), task.getTaskCode()); + for (TaskMarkerBean marker : markers) { + taskMarkerBeanDao.delete(marker); + } + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/dao/TaskMarkerBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/dao/TaskMarkerBeanDao.java new file mode 100644 index 0000000..cc2156a --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/dao/TaskMarkerBeanDao.java @@ -0,0 +1,52 @@ +package com.casic.common.detector.gd.dao; + +import androidx.room.Dao; +import androidx.room.Delete; +import androidx.room.Insert; +import androidx.room.Query; +import androidx.room.Update; + +import com.casic.common.detector.gd.bean.TaskMarkerBean; +import com.casic.common.detector.gd.model.TaskModel; + +import java.util.List; + +@Dao +public interface TaskMarkerBeanDao { + + @Insert + void insert(TaskMarkerBean marker); + + @Query("SELECT COUNT(*) FROM task_marker_info WHERE id = :markerId") + int isMarkerExist(String markerId); + + default void saveTaskMarker(long taskId, String taskCode, TaskModel.MessageModel.TaskDetailInfosModel marker) { + if (isMarkerExist(marker.getMarkerId()) == 0) { + TaskMarkerBean bean = new TaskMarkerBean(); + bean.setId(marker.getId()); + bean.setTaskId(String.valueOf(taskId)); + bean.setTaskCode(taskCode); + bean.setMarkerId(marker.getMarkerIdReal()); + bean.setLng(marker.getLongitude()); + bean.setLat(marker.getLatitude()); + bean.setIsDetected("0"); + bean.setDetectedTime(""); + insert(bean); + } + } + + @Query("SELECT * FROM task_marker_info WHERE taskId = :taskId AND taskCode = :taskCode AND markerId = :markerId AND isDetected = :state") + TaskMarkerBean queryTaskMarkerById(String taskId, String taskCode, String markerId, String state); + + @Update + void updateLocalTaskMarkerState(TaskMarkerBean marker); + + @Query("SELECT * FROM task_marker_info WHERE isDetected = :state") + List queryMarkerByState(String state); + + @Query("SELECT * FROM task_marker_info WHERE taskId = :taskId AND taskCode = :taskCode") + List getMarkersByIdAndCode(String taskId, String taskCode); + + @Delete + void delete(TaskMarkerBean marker); +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/extensions/Long.kt b/app/src/main/java/com/casic/common/detector/gd/extensions/Long.kt deleted file mode 100644 index 6713d8d..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/extensions/Long.kt +++ /dev/null @@ -1,10 +0,0 @@ -package com.casic.common.detector.gd.extensions - -import java.text.SimpleDateFormat -import java.util.Date -import java.util.Locale - -fun Long.createTaskCode(): String { - val dateFormat = SimpleDateFormat("yyyyMMddHHmmss", Locale.CHINA) - return dateFormat.format(Date(this)) -} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoMaster.java b/app/src/main/java/com/casic/common/detector/gd/greendao/DaoMaster.java deleted file mode 100644 index 6ab94b3..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoMaster.java +++ /dev/null @@ -1,102 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import android.content.Context; -import android.database.sqlite.SQLiteDatabase; -import android.database.sqlite.SQLiteDatabase.CursorFactory; -import android.util.Log; - -import org.greenrobot.greendao.AbstractDaoMaster; -import org.greenrobot.greendao.database.StandardDatabase; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.database.DatabaseOpenHelper; -import org.greenrobot.greendao.identityscope.IdentityScopeType; - - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** - * Master of DAO (schema version 1): knows all DAOs. - */ -public class DaoMaster extends AbstractDaoMaster { - public static final int SCHEMA_VERSION = 1; - - /** Creates underlying database table using DAOs. */ - public static void createAllTables(Database db, boolean ifNotExists) { - MarkerLocalBeanDao.createTable(db, ifNotExists); - TaskLocalBeanDao.createTable(db, ifNotExists); - TaskMarkerLocalBeanDao.createTable(db, ifNotExists); - } - - /** Drops underlying database table using DAOs. */ - public static void dropAllTables(Database db, boolean ifExists) { - MarkerLocalBeanDao.dropTable(db, ifExists); - TaskLocalBeanDao.dropTable(db, ifExists); - TaskMarkerLocalBeanDao.dropTable(db, ifExists); - } - - /** - * WARNING: Drops all table on Upgrade! Use only during development. - * Convenience method using a {@link DevOpenHelper}. - */ - public static DaoSession newDevSession(Context context, String name) { - Database db = new DevOpenHelper(context, name).getWritableDb(); - DaoMaster daoMaster = new DaoMaster(db); - return daoMaster.newSession(); - } - - public DaoMaster(SQLiteDatabase db) { - this(new StandardDatabase(db)); - } - - public DaoMaster(Database db) { - super(db, SCHEMA_VERSION); - registerDaoClass(MarkerLocalBeanDao.class); - registerDaoClass(TaskLocalBeanDao.class); - registerDaoClass(TaskMarkerLocalBeanDao.class); - } - - public DaoSession newSession() { - return new DaoSession(db, IdentityScopeType.Session, daoConfigMap); - } - - public DaoSession newSession(IdentityScopeType type) { - return new DaoSession(db, type, daoConfigMap); - } - - /** - * Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} - - */ - public static abstract class OpenHelper extends DatabaseOpenHelper { - public OpenHelper(Context context, String name) { - super(context, name, SCHEMA_VERSION); - } - - public OpenHelper(Context context, String name, CursorFactory factory) { - super(context, name, factory, SCHEMA_VERSION); - } - - @Override - public void onCreate(Database db) { - Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION); - createAllTables(db, false); - } - } - - /** WARNING: Drops all table on Upgrade! Use only during development. */ - public static class DevOpenHelper extends OpenHelper { - public DevOpenHelper(Context context, String name) { - super(context, name); - } - - public DevOpenHelper(Context context, String name, CursorFactory factory) { - super(context, name, factory); - } - - @Override - public void onUpgrade(Database db, int oldVersion, int newVersion) { - Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables"); - dropAllTables(db, true); - onCreate(db); - } - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoSession.java b/app/src/main/java/com/casic/common/detector/gd/greendao/DaoSession.java deleted file mode 100644 index c8b1a20..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoSession.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import java.util.Map; - -import org.greenrobot.greendao.AbstractDao; -import org.greenrobot.greendao.AbstractDaoSession; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.identityscope.IdentityScopeType; -import org.greenrobot.greendao.internal.DaoConfig; - -import com.casic.common.detector.gd.bean.MarkerLocalBean; -import com.casic.common.detector.gd.bean.TaskLocalBean; -import com.casic.common.detector.gd.bean.TaskMarkerLocalBean; - -import com.casic.common.detector.gd.greendao.MarkerLocalBeanDao; -import com.casic.common.detector.gd.greendao.TaskLocalBeanDao; -import com.casic.common.detector.gd.greendao.TaskMarkerLocalBeanDao; - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. - -/** - * {@inheritDoc} - * - * @see org.greenrobot.greendao.AbstractDaoSession - */ -public class DaoSession extends AbstractDaoSession { - - private final DaoConfig markerLocalBeanDaoConfig; - private final DaoConfig taskLocalBeanDaoConfig; - private final DaoConfig taskMarkerLocalBeanDaoConfig; - - private final MarkerLocalBeanDao markerLocalBeanDao; - private final TaskLocalBeanDao taskLocalBeanDao; - private final TaskMarkerLocalBeanDao taskMarkerLocalBeanDao; - - public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> - daoConfigMap) { - super(db); - - markerLocalBeanDaoConfig = daoConfigMap.get(MarkerLocalBeanDao.class).clone(); - markerLocalBeanDaoConfig.initIdentityScope(type); - - taskLocalBeanDaoConfig = daoConfigMap.get(TaskLocalBeanDao.class).clone(); - taskLocalBeanDaoConfig.initIdentityScope(type); - - taskMarkerLocalBeanDaoConfig = daoConfigMap.get(TaskMarkerLocalBeanDao.class).clone(); - taskMarkerLocalBeanDaoConfig.initIdentityScope(type); - - markerLocalBeanDao = new MarkerLocalBeanDao(markerLocalBeanDaoConfig, this); - taskLocalBeanDao = new TaskLocalBeanDao(taskLocalBeanDaoConfig, this); - taskMarkerLocalBeanDao = new TaskMarkerLocalBeanDao(taskMarkerLocalBeanDaoConfig, this); - - registerDao(MarkerLocalBean.class, markerLocalBeanDao); - registerDao(TaskLocalBean.class, taskLocalBeanDao); - registerDao(TaskMarkerLocalBean.class, taskMarkerLocalBeanDao); - } - - public void clear() { - markerLocalBeanDaoConfig.clearIdentityScope(); - taskLocalBeanDaoConfig.clearIdentityScope(); - taskMarkerLocalBeanDaoConfig.clearIdentityScope(); - } - - public MarkerLocalBeanDao getMarkerLocalBeanDao() { - return markerLocalBeanDao; - } - - public TaskLocalBeanDao getTaskLocalBeanDao() { - return taskLocalBeanDao; - } - - public TaskMarkerLocalBeanDao getTaskMarkerLocalBeanDao() { - return taskMarkerLocalBeanDao; - } - -} diff --git a/app/build.gradle b/app/build.gradle index d0cb423..921c8c8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,25 +1,20 @@ import java.text.SimpleDateFormat -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply plugin: 'org.greenrobot.greendao' +plugins { + id('com.android.application') + id('org.jetbrains.kotlin.android') +} android { - compileSdkVersion 33 + namespace 'com.casic.common.detector.gd' + compileSdk 35 defaultConfig { - applicationId "com.casic.common.detector.gd" - minSdkVersion 26 - targetSdkVersion 33 + applicationId 'com.casic.common.detector.gd' + minSdk 26 + targetSdk 35 versionCode 5092 - versionName "5.0.9.2" - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } + versionName '5.0.9.2' } signingConfigs { @@ -31,6 +26,14 @@ } } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + signingConfig signingConfigs.release + } + } + compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 @@ -47,27 +50,16 @@ } } - kotlin { - experimental { - coroutines 'enable' - } - } - buildFeatures { + buildConfig true viewBinding true } - applicationVariants.configureEach { variant -> - variant.outputs.configureEach { - outputFileName = "COM_TCY_" + getBuildDate() + "_" + defaultConfig.versionName + ".apk" + applicationVariants.configureEach { + outputs.configureEach { + outputFileName = 'COM_TCY_' + getBuildDate() + '_' + defaultConfig.versionName + '.apk' } } - - greendao { - schemaVersion 1//数据库版本号 - targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 - daoPackage "${defaultConfig.applicationId}.greendao"//设置DaoMaster、DaoSession、Dao包名 - } } static def getBuildDate() { @@ -76,27 +68,22 @@ } dependencies { - //基础依赖库 - implementation 'com.github.AndroidCoderPeng:Kotlin-lite-lib:1.1.4' - implementation 'androidx.core:core-ktx:1.9.0' - def base_version = "1.6.1" - implementation "androidx.appcompat:appcompat:${base_version}" - implementation "com.google.android.material:material:${base_version}" + implementation 'com.github.AndroidCoderPeng:Kotlin-lite-lib:1.1.5' + implementation 'androidx.core:core-ktx:1.13.1' + implementation 'androidx.appcompat:appcompat:1.7.0' + implementation 'com.google.android.material:material:1.12.0' //Google官方授权框架 implementation 'pub.devrel:easypermissions:3.0.0' - //沉浸式状态栏。基础依赖包,必须要依赖 - implementation 'com.gyf.immersionbar:immersionbar:3.0.0' - //fragment快速实现 - implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0' + //沉浸式状态栏 + implementation 'com.geyifeng.immersionbar:immersionbar:3.2.2' //官方Json解析库 implementation 'com.google.code.gson:gson:2.10.1' - def vm_version = '2.5.1' //Kotlin协程 - implementation "androidx.lifecycle:lifecycle-runtime-ktx:${vm_version}" + implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.2' //MVVM+LiveData - implementation "androidx.lifecycle:lifecycle-livedata-ktx:${vm_version}" - implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:${vm_version}" - implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.6.2' + implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2' + implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' //返回值转换器 implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' @@ -105,9 +92,10 @@ implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' //网络请求和接口封装 implementation 'com.squareup.retrofit2:retrofit:2.9.0' - implementation 'com.squareup.okhttp3:okhttp:4.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.12.0' //数据库框架 - implementation 'org.greenrobot:greendao:3.3.0' + implementation 'androidx.room:room-runtime:2.6.1' + annotationProcessor 'androidx.room:room-compiler:2.5.2' //高德导航、定位、地图三合一 implementation 'com.amap.api:navi-3dmap:latest.integration' //经纬度逆编码 @@ -115,7 +103,7 @@ //excel implementation 'net.sourceforge.jexcelapi:jxl:2.6.12' //图片加载框架 - implementation 'com.github.bumptech.glide:glide:4.9.0' + implementation 'com.github.bumptech.glide:glide:4.12.0' //图片选择框架 implementation 'io.github.lucksiege:pictureselector:v3.11.1' //大图 diff --git a/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt b/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt index 7b695ff..50ba734 100644 --- a/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt +++ b/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt @@ -4,9 +4,9 @@ import android.app.Application import android.os.Bundle import android.util.Log -import com.casic.common.detector.gd.greendao.DaoMaster -import com.casic.common.detector.gd.greendao.DaoSession +import androidx.room.Room.databaseBuilder import com.casic.common.detector.gd.uart.SerialPort +import com.casic.common.detector.gd.utils.DetectorDataBase import com.casic.common.detector.gd.utils.GpioManager import com.pengxh.kt.lite.extensions.show import com.pengxh.kt.lite.utils.SaveKeyValues @@ -43,44 +43,42 @@ private var application: BaseApplication by Delegates.notNull() fun get() = application - - private lateinit var daoSession: DaoSession } + lateinit var dataBase: DetectorDataBase + override fun onCreate() { super.onCreate() application = this SaveKeyValues.initSharedPreferences(this) CrashReport.initCrashReport(this, "01e80d3a74", true) - val devOpenHelper = DaoMaster.DevOpenHelper(this, "Detector.db", null) - val daoMaster = DaoMaster(devOpenHelper.writableDatabase) - daoSession = daoMaster.newSession() + dataBase = databaseBuilder(this, DetectorDataBase::class.java, "Detector.db") + .allowMainThreadQueries() + .build() /** * Open the serial port * */ try { serialPorts.apply { - add(SerialPort(File("/dev/ttysWK1"), 9600, 0)) - //千寻报文数据下发串口号 - add(SerialPort(File("/dev/ttyS1"), 9600, 0)) + add(SerialPort(File("/dev/ttysWK1"), 9600, 0)) //信号通讯串口 + add(SerialPort(File("/dev/ttyS1"), 9600, 0)) //千寻报文数据下发串口号 } Log.d(kTag, "onCreate: 已初始化 ${serialPorts.size} 个串口") } catch (e: SecurityException) { "您没有串口的读写权限!".show(this) + e.printStackTrace() } catch (e: IOException) { "因为不明原因,串口无法打开!".show(this) + e.printStackTrace() } catch (e: InvalidParameterException) { "请检查串口!".show(this) + e.printStackTrace() } registerActivityLifecycleCallbacks(this) } - fun getDaoSession(): DaoSession { - return daoSession - } - override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) { } diff --git a/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt b/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt index 053b9dd..1d0c9e3 100644 --- a/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt +++ b/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt @@ -14,12 +14,10 @@ import com.casic.common.detector.gd.utils.SerialPortCommand import com.pengxh.kt.lite.utils.WeakReferenceHandler import java.io.IOException -import java.util.Timer abstract class SerialPortBaseActivity : AppCompatActivity(), Handler.Callback { private val kTag = "SerialPortBaseActivity" - private val taskTimer by lazy { Timer() } private val weakReferenceHandler by lazy { WeakReferenceHandler(this) } private val serialPorts by lazy { BaseApplication.get().getSerialPorts() } protected lateinit var binding: VB @@ -30,7 +28,6 @@ setContentView(binding.root) setupTopBarLayout() initOnCreate(savedInstanceState) - observeRequestState() initEvent() if (serialPorts.isNotEmpty()) { @@ -71,11 +68,6 @@ abstract fun initOnCreate(savedInstanceState: Bundle?) /** - * 数据请求状态监听 - */ - abstract fun observeRequestState() - - /** * 初始化业务逻辑 */ abstract fun initEvent() diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java new file mode 100644 index 0000000..7a18c20 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java @@ -0,0 +1,255 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 从平台下载的标识器本地库实体类 + */ +@Entity(tableName = "marker_detail") +public class MarkerBean { + @PrimaryKey(autoGenerate = true) + private long id; //主键ID + private String pipelineType; // 管线类型 + private String pipelineDiameter; // 管线直径 + private String pipelineMaterial; // 管材 + private String buryMethod; // 埋设方式 + private String buryDepth; // 埋深 + private String area; // 所属区域 + private String line; // 所属线路 + private String road; // 所属道路 + private String constructTime; // 建设年代 + private String owner; // 权属单位 + private String objectId; // 标识对象ID,无实际用途 + private String markerId; // 标识器ID + private String markerType; // 标识器类型 + private String markerDepth; // 标识器埋深 + private String installationDept; // 安装部门 + private String lng; // 经度 + private String lat; // 纬度 + private String updateTime; // 最后修改时间,更新时间 + private String remark; // 备注信息 + private String underlyingPipelineType; // 下层管线类型 + private String underlyingPipelineDepth; // 下层埋深 + private String underlyingPipelineDiameter; // 下层管径 + private String underlyingPipelineMaterial; // 下层管材 + private String objectType; //标识对象类型 + private String color; // 颜色 + private String imagePath; // 图片路径 + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getPipelineType() { + return pipelineType; + } + + public void setPipelineType(String pipelineType) { + this.pipelineType = pipelineType; + } + + public String getPipelineDiameter() { + return pipelineDiameter; + } + + public void setPipelineDiameter(String pipelineDiameter) { + this.pipelineDiameter = pipelineDiameter; + } + + public String getPipelineMaterial() { + return pipelineMaterial; + } + + public void setPipelineMaterial(String pipelineMaterial) { + this.pipelineMaterial = pipelineMaterial; + } + + public String getBuryMethod() { + return buryMethod; + } + + public void setBuryMethod(String buryMethod) { + this.buryMethod = buryMethod; + } + + public String getBuryDepth() { + return buryDepth; + } + + public void setBuryDepth(String buryDepth) { + this.buryDepth = buryDepth; + } + + public String getArea() { + return area; + } + + public void setArea(String area) { + this.area = area; + } + + public String getLine() { + return line; + } + + public void setLine(String line) { + this.line = line; + } + + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + + public String getConstructTime() { + return constructTime; + } + + public void setConstructTime(String constructTime) { + this.constructTime = constructTime; + } + + public String getOwner() { + return owner; + } + + public void setOwner(String owner) { + this.owner = owner; + } + + public String getObjectId() { + return objectId; + } + + public void setObjectId(String objectId) { + this.objectId = objectId; + } + + public String getMarkerId() { + return markerId; + } + + public void setMarkerId(String markerId) { + this.markerId = markerId; + } + + public String getMarkerType() { + return markerType; + } + + public void setMarkerType(String markerType) { + this.markerType = markerType; + } + + public String getMarkerDepth() { + return markerDepth; + } + + public void setMarkerDepth(String markerDepth) { + this.markerDepth = markerDepth; + } + + public String getInstallationDept() { + return installationDept; + } + + public void setInstallationDept(String installationDept) { + this.installationDept = installationDept; + } + + public String getLng() { + return lng; + } + + public void setLng(String lng) { + this.lng = lng; + } + + public String getLat() { + return lat; + } + + public void setLat(String lat) { + this.lat = lat; + } + + public String getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } + + public String getUnderlyingPipelineType() { + return underlyingPipelineType; + } + + public void setUnderlyingPipelineType(String underlyingPipelineType) { + this.underlyingPipelineType = underlyingPipelineType; + } + + public String getUnderlyingPipelineDepth() { + return underlyingPipelineDepth; + } + + public void setUnderlyingPipelineDepth(String underlyingPipelineDepth) { + this.underlyingPipelineDepth = underlyingPipelineDepth; + } + + public String getUnderlyingPipelineDiameter() { + return underlyingPipelineDiameter; + } + + public void setUnderlyingPipelineDiameter(String underlyingPipelineDiameter) { + this.underlyingPipelineDiameter = underlyingPipelineDiameter; + } + + public String getUnderlyingPipelineMaterial() { + return underlyingPipelineMaterial; + } + + public void setUnderlyingPipelineMaterial(String underlyingPipelineMaterial) { + this.underlyingPipelineMaterial = underlyingPipelineMaterial; + } + + public String getObjectType() { + return objectType; + } + + public void setObjectType(String objectType) { + this.objectType = objectType; + } + + public String getColor() { + return color; + } + + public void setColor(String color) { + this.color = color; + } + + public String getImagePath() { + return imagePath; + } + + public void setImagePath(String imagePath) { + this.imagePath = imagePath; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java deleted file mode 100644 index 3f2fcdc..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java +++ /dev/null @@ -1,327 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 从平台下载的标识器本地库实体类 - */ -@Entity -public class MarkerLocalBean { - @Id(autoincrement = true) - private Long id;//本地库主键ID - - // 管线类型 - private String pipelineType; - // 管线直径 - private String pipelineDiameter; - // 管材 - private String pipelineMaterial; - // 埋设方式 - private String buryMethod; - // 埋深 - private String buryDepth; - // 所属区域 - private String area; - // 所属线路 - private String line; - // 所属道路 - private String road; - // 建设年代 - private String constructTime; - // 权属单位 - private String owner; - //标识对象ID,无实际用途 - @Deprecated - private String objectId; - // 标识器ID - private String markerId; - // 标识器类型 - private String markerType; - // 标识器埋深 - private String markerDepth; - // 安装部门 - private String installationDept; - // 经度 - private String lng; - // 纬度 - private String lat; - //最后修改时间,更新时间 - private String updateTime; - // 备注信息 - private String remark; - // 下层管线类型 - private String underlyingPipelineType; - // 下层埋深 - private String underlyingPipelineDepth; - // 下层管径 - private String underlyingPipelineDiameter; - // 下层管材 - private String underlyingPipelineMaterial; - //标识对象类型 - private String objectType; - // 颜色 - private String color; - // 图片路径 - private String imagePath; - - @Generated(hash = 1479045776) - public MarkerLocalBean(Long id, String pipelineType, String pipelineDiameter, - String pipelineMaterial, String buryMethod, String buryDepth, - String area, String line, String road, String constructTime, - String owner, String objectId, String markerId, String markerType, - String markerDepth, String installationDept, String lng, String lat, - String updateTime, String remark, String underlyingPipelineType, - String underlyingPipelineDepth, String underlyingPipelineDiameter, - String underlyingPipelineMaterial, String objectType, String color, - String imagePath) { - this.id = id; - this.pipelineType = pipelineType; - this.pipelineDiameter = pipelineDiameter; - this.pipelineMaterial = pipelineMaterial; - this.buryMethod = buryMethod; - this.buryDepth = buryDepth; - this.area = area; - this.line = line; - this.road = road; - this.constructTime = constructTime; - this.owner = owner; - this.objectId = objectId; - this.markerId = markerId; - this.markerType = markerType; - this.markerDepth = markerDepth; - this.installationDept = installationDept; - this.lng = lng; - this.lat = lat; - this.updateTime = updateTime; - this.remark = remark; - this.underlyingPipelineType = underlyingPipelineType; - this.underlyingPipelineDepth = underlyingPipelineDepth; - this.underlyingPipelineDiameter = underlyingPipelineDiameter; - this.underlyingPipelineMaterial = underlyingPipelineMaterial; - this.objectType = objectType; - this.color = color; - this.imagePath = imagePath; - } - - @Generated(hash = 1538606012) - public MarkerLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getPipelineType() { - return this.pipelineType; - } - - public void setPipelineType(String pipelineType) { - this.pipelineType = pipelineType; - } - - public String getPipelineDiameter() { - return this.pipelineDiameter; - } - - public void setPipelineDiameter(String pipelineDiameter) { - this.pipelineDiameter = pipelineDiameter; - } - - public String getPipelineMaterial() { - return this.pipelineMaterial; - } - - public void setPipelineMaterial(String pipelineMaterial) { - this.pipelineMaterial = pipelineMaterial; - } - - public String getBuryMethod() { - return this.buryMethod; - } - - public void setBuryMethod(String buryMethod) { - this.buryMethod = buryMethod; - } - - public String getBuryDepth() { - return this.buryDepth; - } - - public void setBuryDepth(String buryDepth) { - this.buryDepth = buryDepth; - } - - public String getArea() { - return this.area; - } - - public void setArea(String area) { - this.area = area; - } - - public String getLine() { - return this.line; - } - - public void setLine(String line) { - this.line = line; - } - - public String getRoad() { - return this.road; - } - - public void setRoad(String road) { - this.road = road; - } - - public String getConstructTime() { - return this.constructTime; - } - - public void setConstructTime(String constructTime) { - this.constructTime = constructTime; - } - - public String getOwner() { - return this.owner; - } - - public void setOwner(String owner) { - this.owner = owner; - } - - public String getObjectId() { - return this.objectId; - } - - public void setObjectId(String objectId) { - this.objectId = objectId; - } - - public String getMarkerId() { - return this.markerId; - } - - public void setMarkerId(String markerId) { - this.markerId = markerId; - } - - public String getMarkerType() { - return this.markerType; - } - - public void setMarkerType(String markerType) { - this.markerType = markerType; - } - - public String getMarkerDepth() { - return this.markerDepth; - } - - public void setMarkerDepth(String markerDepth) { - this.markerDepth = markerDepth; - } - - public String getInstallationDept() { - return this.installationDept; - } - - public void setInstallationDept(String installationDept) { - this.installationDept = installationDept; - } - - public String getLng() { - return this.lng; - } - - public void setLng(String lng) { - this.lng = lng; - } - - public String getLat() { - return this.lat; - } - - public void setLat(String lat) { - this.lat = lat; - } - - public String getUpdateTime() { - return this.updateTime; - } - - public void setUpdateTime(String updateTime) { - this.updateTime = updateTime; - } - - public String getRemark() { - return this.remark; - } - - public void setRemark(String remark) { - this.remark = remark; - } - - public String getUnderlyingPipelineType() { - return this.underlyingPipelineType; - } - - public void setUnderlyingPipelineType(String underlyingPipelineType) { - this.underlyingPipelineType = underlyingPipelineType; - } - - public String getUnderlyingPipelineDepth() { - return this.underlyingPipelineDepth; - } - - public void setUnderlyingPipelineDepth(String underlyingPipelineDepth) { - this.underlyingPipelineDepth = underlyingPipelineDepth; - } - - public String getUnderlyingPipelineDiameter() { - return this.underlyingPipelineDiameter; - } - - public void setUnderlyingPipelineDiameter(String underlyingPipelineDiameter) { - this.underlyingPipelineDiameter = underlyingPipelineDiameter; - } - - public String getUnderlyingPipelineMaterial() { - return this.underlyingPipelineMaterial; - } - - public void setUnderlyingPipelineMaterial(String underlyingPipelineMaterial) { - this.underlyingPipelineMaterial = underlyingPipelineMaterial; - } - - public String getObjectType() { - return this.objectType; - } - - public void setObjectType(String objectType) { - this.objectType = objectType; - } - - public String getColor() { - return this.color; - } - - public void setColor(String color) { - this.color = color; - } - - public String getImagePath() { - return this.imagePath; - } - - public void setImagePath(String imagePath) { - this.imagePath = imagePath; - } -} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java new file mode 100644 index 0000000..5c88fdf --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java @@ -0,0 +1,93 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 巡检任务本地库实体类,不包含任务里面需要巡检的标识器信息 + */ +@Entity(tableName = "task_detail") +public class TaskBean { + @PrimaryKey(autoGenerate = true) + private long id;//主键ID + private String taskCode; // 任务编号 + private String description; // 任务名称 + private String createTime; // 任务创建的时间 + private String status; // 任务状态 + private String createUserName; // 任务创建者名称 + private String startTime; // 任务被开始执行的时间 + private String endTime; // 任务执行结束的时间 + private String isFree; // 是否自由巡检。1-是,0-否 + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getTaskCode() { + return taskCode; + } + + public void setTaskCode(String taskCode) { + this.taskCode = taskCode; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getCreateUserName() { + return createUserName; + } + + public void setCreateUserName(String createUserName) { + this.createUserName = createUserName; + } + + public String getStartTime() { + return startTime; + } + + public void setStartTime(String startTime) { + this.startTime = startTime; + } + + public String getEndTime() { + return endTime; + } + + public void setEndTime(String endTime) { + this.endTime = endTime; + } + + public String getIsFree() { + return isFree; + } + + public void setIsFree(String isFree) { + this.isFree = isFree; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java deleted file mode 100644 index 91737b3..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java +++ /dev/null @@ -1,114 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 巡检任务本地库实体类,不包含任务里面需要巡检的标识器信息 - */ -@Entity -public class TaskLocalBean { - @Id - private Long id;//任务ID - - private String taskCode;//任务编号 - private String description;//任务名称 - private String createTime;//任务创建的时间 - private String status;//任务状态 - private String createUserName;//任务创建者名称 - private String startTime;//任务被开始执行的时间 - private String endTime;//任务执行结束的时间 - private String isFreeTask;//是否自由巡检。1-是,0-否 - - @Generated(hash = 1482022528) - public TaskLocalBean(Long id, String taskCode, String description, - String createTime, String status, String createUserName, - String startTime, String endTime, String isFreeTask) { - this.id = id; - this.taskCode = taskCode; - this.description = description; - this.createTime = createTime; - this.status = status; - this.createUserName = createUserName; - this.startTime = startTime; - this.endTime = endTime; - this.isFreeTask = isFreeTask; - } - - @Generated(hash = 949704588) - public TaskLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getTaskCode() { - return this.taskCode; - } - - public void setTaskCode(String taskCode) { - this.taskCode = taskCode; - } - - public String getDescription() { - return this.description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getCreateTime() { - return this.createTime; - } - - public void setCreateTime(String createTime) { - this.createTime = createTime; - } - - public String getStatus() { - return this.status; - } - - public void setStatus(String status) { - this.status = status; - } - - public String getCreateUserName() { - return this.createUserName; - } - - public void setCreateUserName(String createUserName) { - this.createUserName = createUserName; - } - - public String getStartTime() { - return this.startTime; - } - - public void setStartTime(String startTime) { - this.startTime = startTime; - } - - public String getEndTime() { - return this.endTime; - } - - public void setEndTime(String endTime) { - this.endTime = endTime; - } - - public String getIsFreeTask() { - return this.isFreeTask; - } - - public void setIsFreeTask(String isFreeTask) { - this.isFreeTask = isFreeTask; - } -} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerBean.java new file mode 100644 index 0000000..c563a60 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerBean.java @@ -0,0 +1,110 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 巡检任务里面需要巡检的标识器信息本地库实体类 + */ +@Entity(tableName = "task_marker_info") +public class TaskMarkerBean { + //标识器后台库的主键ID,不是标识器实际ID + @PrimaryKey(autoGenerate = true) + private long id; + + /** + * 任务ID,通过此字段关联[TaskBean.id] + */ + private String taskId; + + /** + * 任务Code,通过此字段关联[TaskBean.taskCode] + *

+ *

+ * 双重验证,防止出现同时刻重复的情况 + */ + private String taskCode; + + /** + * 对应后台字段[TaskModel.MessageModel.TaskDetailInfosModel.markerIdReal],也就是探测仪扫描出来的ID + */ + private String markerId; + + private Double lng; + private Double lat; + + /** + * 是否已被探测到 + * 1-是,0-否 + */ + private String isDetected; + + /** + * 被探测到的时间,对应后台字段[TaskModel.MessageModel.TaskDetailInfosModel.finishTime] + */ + private String detectedTime; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getTaskId() { + return taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getTaskCode() { + return taskCode; + } + + public void setTaskCode(String taskCode) { + this.taskCode = taskCode; + } + + public String getMarkerId() { + return markerId; + } + + public void setMarkerId(String markerId) { + this.markerId = markerId; + } + + public Double getLng() { + return lng; + } + + public void setLng(Double lng) { + this.lng = lng; + } + + public Double getLat() { + return lat; + } + + public void setLat(Double lat) { + this.lat = lat; + } + + public String getIsDetected() { + return isDetected; + } + + public void setIsDetected(String isDetected) { + this.isDetected = isDetected; + } + + public String getDetectedTime() { + return detectedTime; + } + + public void setDetectedTime(String detectedTime) { + this.detectedTime = detectedTime; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerLocalBean.java deleted file mode 100644 index de9f459..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerLocalBean.java +++ /dev/null @@ -1,128 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import com.casic.common.detector.gd.model.TaskModel; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 巡检任务里面需要巡检的标识器信息本地库实体类 - */ -@Entity -public class TaskMarkerLocalBean { - @Id - private Long id;//标识器后台库的主键ID,不是标识器实际ID - - /** - * 任务ID,通过此字段关联{@link TaskLocalBean#id} - */ - private String taskId; - - /** - * 任务Code,通过此字段关联{@link TaskLocalBean#taskCode} - *

- * 双重验证,防止出现同时刻重复的情况 - */ - private String taskCode; - - /** - * 对应后台字段{@link TaskModel.MessageModel.TaskDetailInfosModel#markerIdReal},也就是探测仪扫描出来的ID - */ - private String markerId; - - private double lng; - private double lat; - - /** - * 是否已被探测到 - * 1-是,0-否 - */ - private String isDetected; - - /** - * 被探测到的时间,对应后台字段{@link TaskModel.MessageModel.TaskDetailInfosModel#finishTime} - */ - private String detectedTime; - - @Generated(hash = 677328533) - public TaskMarkerLocalBean(Long id, String taskId, String taskCode, String markerId, - double lng, double lat, String isDetected, String detectedTime) { - this.id = id; - this.taskId = taskId; - this.taskCode = taskCode; - this.markerId = markerId; - this.lng = lng; - this.lat = lat; - this.isDetected = isDetected; - this.detectedTime = detectedTime; - } - - @Generated(hash = 1162404642) - public TaskMarkerLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getTaskId() { - return this.taskId; - } - - public void setTaskId(String taskId) { - this.taskId = taskId; - } - - public String getTaskCode() { - return this.taskCode; - } - - public void setTaskCode(String taskCode) { - this.taskCode = taskCode; - } - - public String getMarkerId() { - return this.markerId; - } - - public void setMarkerId(String markerId) { - this.markerId = markerId; - } - - public double getLng() { - return this.lng; - } - - public void setLng(double lng) { - this.lng = lng; - } - - public double getLat() { - return this.lat; - } - - public void setLat(double lat) { - this.lat = lat; - } - - public String getIsDetected() { - return this.isDetected; - } - - public void setIsDetected(String isDetected) { - this.isDetected = isDetected; - } - - public String getDetectedTime() { - return this.detectedTime; - } - - public void setDetectedTime(String detectedTime) { - this.detectedTime = detectedTime; - } -} diff --git a/app/src/main/java/com/casic/common/detector/gd/dao/MarkerBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/dao/MarkerBeanDao.java new file mode 100644 index 0000000..2beb7ed --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/dao/MarkerBeanDao.java @@ -0,0 +1,29 @@ +package com.casic.common.detector.gd.dao; + +import androidx.room.Dao; +import androidx.room.Insert; +import androidx.room.Query; +import androidx.room.RawQuery; +import androidx.sqlite.db.SupportSQLiteQuery; + +import com.casic.common.detector.gd.bean.MarkerBean; + +import java.util.List; + +@Dao +public interface MarkerBeanDao { + @Query("DELETE FROM marker_detail") + void deleteAll(); + + @Insert + void insert(MarkerBean marker); + + @Query("SELECT * FROM marker_detail") + List loadAll(); + + @Query("SELECT * FROM marker_detail WHERE markerId = :markerId") + List queryMarkerById(String markerId); + + @RawQuery + List loadMarkersByCondition(SupportSQLiteQuery query); +} diff --git a/app/src/main/java/com/casic/common/detector/gd/dao/TaskBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/dao/TaskBeanDao.java new file mode 100644 index 0000000..9c70ac2 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/dao/TaskBeanDao.java @@ -0,0 +1,120 @@ +package com.casic.common.detector.gd.dao; + +import androidx.room.Dao; +import androidx.room.Insert; +import androidx.room.Query; +import androidx.room.Transaction; + +import com.casic.common.detector.gd.bean.TaskBean; +import com.casic.common.detector.gd.bean.TaskMarkerBean; +import com.casic.common.detector.gd.model.TaskDetailLocalModel; +import com.casic.common.detector.gd.model.TaskModel; +import com.casic.common.detector.gd.utils.LocaleConstant; +import com.pengxh.kt.lite.utils.SaveKeyValues; + +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Locale; + +@Dao +public interface TaskBeanDao { + @Query("SELECT COUNT(*) FROM task_detail WHERE id = :taskId") + int isTaskExist(long taskId); + + @Insert + void insert(TaskBean task); + + default void saveTask(Long taskId, String taskName) { + if (isTaskExist(taskId) == 0) { + TaskBean task = new TaskBean(); + task.setId(taskId); + task.setTaskCode(new SimpleDateFormat("yyyyMMddHHmmss", Locale.CHINA).format(new Date())); + task.setDescription(taskName); + String time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA).format(new Date()); + task.setCreateTime(time); + task.setStatus("0"); + String userName = (String) SaveKeyValues.INSTANCE.getValue(LocaleConstant.USER_NAME, ""); + task.setCreateUserName(userName); + task.setStartTime(time); + task.setEndTime(""); + task.setIsFree("1"); + insert(task); + } + } + + default void saveTask(TaskModel.MessageModel model) { + TaskBean task = new TaskBean(); + task.setId(model.getId()); + task.setTaskCode(model.getTaskCode()); + task.setDescription(model.getDescription()); + task.setCreateTime(model.getDeployDate()); + task.setStatus(model.getStatus()); + task.setCreateUserName(model.getCreatorName()); + task.setStartTime(model.getBeginDate()); + task.setEndTime(model.getEndDate()); + task.setIsFree("0"); + if (isTaskExist(task.getId()) == 0) { + insert(task); + } + } + + @Query("SELECT * FROM task_detail") + List loadAll(); + + @Transaction + default ArrayList loadLocalTask(TaskMarkerBeanDao taskMarkerBeanDao) { + ArrayList result = new ArrayList<>(); + List tasks = loadAll(); + for (TaskBean it : tasks) { + TaskDetailLocalModel model = new TaskDetailLocalModel(); + model.setTaskId(String.valueOf(it.getId())); + model.setTaskCode(it.getTaskCode()); + model.setDescription(it.getDescription()); + model.setCreateTime(it.getCreateTime()); + model.setStatus(it.getStatus()); + model.setCreateUserName(it.getCreateUserName()); + model.setIsFreeTask(it.getIsFree()); + ArrayList results = new ArrayList<>(); + if ("0".equals(it.getIsFree())) { + // 非自由巡检才有Marker + List markers = taskMarkerBeanDao.getMarkersByIdAndCode(String.valueOf(it.getId()), it.getTaskCode()); + for (TaskMarkerBean marker : markers) { + TaskDetailLocalModel.TaskMarkerLocalModel localModel = new TaskDetailLocalModel.TaskMarkerLocalModel(); + localModel.setMarkerId(marker.getMarkerId()); + localModel.setLng(marker.getLng()); + localModel.setLat(marker.getLat()); + localModel.setIsDetected(marker.getIsDetected()); + localModel.setDetectedTime(marker.getDetectedTime()); + + results.add(localModel); + } + } + model.setMarkerModels(results); + result.add(model); + } + return result; + } + + @Query("DELETE FROM task_detail WHERE id = :taskId AND taskCode = :taskCode") + void deleteTaskById(long taskId, String taskCode); + + @Transaction + default void deleteLocalTaskById(long taskId, String taskCode, TaskMarkerBeanDao taskMarkerBeanDao) { + TaskBean task = loadAll().stream() + .filter(it -> it.getId() == taskId && taskCode.equals(it.getTaskCode())) + .findFirst() + .orElse(null); + if (task == null) return; + deleteTaskById(taskId, taskCode); + + // 删除此任务关联的Marker。非自由巡检才有Marker + if ("0".equals(task.getIsFree())) { + List markers = taskMarkerBeanDao.getMarkersByIdAndCode(String.valueOf(task.getId()), task.getTaskCode()); + for (TaskMarkerBean marker : markers) { + taskMarkerBeanDao.delete(marker); + } + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/dao/TaskMarkerBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/dao/TaskMarkerBeanDao.java new file mode 100644 index 0000000..cc2156a --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/dao/TaskMarkerBeanDao.java @@ -0,0 +1,52 @@ +package com.casic.common.detector.gd.dao; + +import androidx.room.Dao; +import androidx.room.Delete; +import androidx.room.Insert; +import androidx.room.Query; +import androidx.room.Update; + +import com.casic.common.detector.gd.bean.TaskMarkerBean; +import com.casic.common.detector.gd.model.TaskModel; + +import java.util.List; + +@Dao +public interface TaskMarkerBeanDao { + + @Insert + void insert(TaskMarkerBean marker); + + @Query("SELECT COUNT(*) FROM task_marker_info WHERE id = :markerId") + int isMarkerExist(String markerId); + + default void saveTaskMarker(long taskId, String taskCode, TaskModel.MessageModel.TaskDetailInfosModel marker) { + if (isMarkerExist(marker.getMarkerId()) == 0) { + TaskMarkerBean bean = new TaskMarkerBean(); + bean.setId(marker.getId()); + bean.setTaskId(String.valueOf(taskId)); + bean.setTaskCode(taskCode); + bean.setMarkerId(marker.getMarkerIdReal()); + bean.setLng(marker.getLongitude()); + bean.setLat(marker.getLatitude()); + bean.setIsDetected("0"); + bean.setDetectedTime(""); + insert(bean); + } + } + + @Query("SELECT * FROM task_marker_info WHERE taskId = :taskId AND taskCode = :taskCode AND markerId = :markerId AND isDetected = :state") + TaskMarkerBean queryTaskMarkerById(String taskId, String taskCode, String markerId, String state); + + @Update + void updateLocalTaskMarkerState(TaskMarkerBean marker); + + @Query("SELECT * FROM task_marker_info WHERE isDetected = :state") + List queryMarkerByState(String state); + + @Query("SELECT * FROM task_marker_info WHERE taskId = :taskId AND taskCode = :taskCode") + List getMarkersByIdAndCode(String taskId, String taskCode); + + @Delete + void delete(TaskMarkerBean marker); +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/extensions/Long.kt b/app/src/main/java/com/casic/common/detector/gd/extensions/Long.kt deleted file mode 100644 index 6713d8d..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/extensions/Long.kt +++ /dev/null @@ -1,10 +0,0 @@ -package com.casic.common.detector.gd.extensions - -import java.text.SimpleDateFormat -import java.util.Date -import java.util.Locale - -fun Long.createTaskCode(): String { - val dateFormat = SimpleDateFormat("yyyyMMddHHmmss", Locale.CHINA) - return dateFormat.format(Date(this)) -} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoMaster.java b/app/src/main/java/com/casic/common/detector/gd/greendao/DaoMaster.java deleted file mode 100644 index 6ab94b3..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoMaster.java +++ /dev/null @@ -1,102 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import android.content.Context; -import android.database.sqlite.SQLiteDatabase; -import android.database.sqlite.SQLiteDatabase.CursorFactory; -import android.util.Log; - -import org.greenrobot.greendao.AbstractDaoMaster; -import org.greenrobot.greendao.database.StandardDatabase; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.database.DatabaseOpenHelper; -import org.greenrobot.greendao.identityscope.IdentityScopeType; - - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** - * Master of DAO (schema version 1): knows all DAOs. - */ -public class DaoMaster extends AbstractDaoMaster { - public static final int SCHEMA_VERSION = 1; - - /** Creates underlying database table using DAOs. */ - public static void createAllTables(Database db, boolean ifNotExists) { - MarkerLocalBeanDao.createTable(db, ifNotExists); - TaskLocalBeanDao.createTable(db, ifNotExists); - TaskMarkerLocalBeanDao.createTable(db, ifNotExists); - } - - /** Drops underlying database table using DAOs. */ - public static void dropAllTables(Database db, boolean ifExists) { - MarkerLocalBeanDao.dropTable(db, ifExists); - TaskLocalBeanDao.dropTable(db, ifExists); - TaskMarkerLocalBeanDao.dropTable(db, ifExists); - } - - /** - * WARNING: Drops all table on Upgrade! Use only during development. - * Convenience method using a {@link DevOpenHelper}. - */ - public static DaoSession newDevSession(Context context, String name) { - Database db = new DevOpenHelper(context, name).getWritableDb(); - DaoMaster daoMaster = new DaoMaster(db); - return daoMaster.newSession(); - } - - public DaoMaster(SQLiteDatabase db) { - this(new StandardDatabase(db)); - } - - public DaoMaster(Database db) { - super(db, SCHEMA_VERSION); - registerDaoClass(MarkerLocalBeanDao.class); - registerDaoClass(TaskLocalBeanDao.class); - registerDaoClass(TaskMarkerLocalBeanDao.class); - } - - public DaoSession newSession() { - return new DaoSession(db, IdentityScopeType.Session, daoConfigMap); - } - - public DaoSession newSession(IdentityScopeType type) { - return new DaoSession(db, type, daoConfigMap); - } - - /** - * Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} - - */ - public static abstract class OpenHelper extends DatabaseOpenHelper { - public OpenHelper(Context context, String name) { - super(context, name, SCHEMA_VERSION); - } - - public OpenHelper(Context context, String name, CursorFactory factory) { - super(context, name, factory, SCHEMA_VERSION); - } - - @Override - public void onCreate(Database db) { - Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION); - createAllTables(db, false); - } - } - - /** WARNING: Drops all table on Upgrade! Use only during development. */ - public static class DevOpenHelper extends OpenHelper { - public DevOpenHelper(Context context, String name) { - super(context, name); - } - - public DevOpenHelper(Context context, String name, CursorFactory factory) { - super(context, name, factory); - } - - @Override - public void onUpgrade(Database db, int oldVersion, int newVersion) { - Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables"); - dropAllTables(db, true); - onCreate(db); - } - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoSession.java b/app/src/main/java/com/casic/common/detector/gd/greendao/DaoSession.java deleted file mode 100644 index c8b1a20..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoSession.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import java.util.Map; - -import org.greenrobot.greendao.AbstractDao; -import org.greenrobot.greendao.AbstractDaoSession; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.identityscope.IdentityScopeType; -import org.greenrobot.greendao.internal.DaoConfig; - -import com.casic.common.detector.gd.bean.MarkerLocalBean; -import com.casic.common.detector.gd.bean.TaskLocalBean; -import com.casic.common.detector.gd.bean.TaskMarkerLocalBean; - -import com.casic.common.detector.gd.greendao.MarkerLocalBeanDao; -import com.casic.common.detector.gd.greendao.TaskLocalBeanDao; -import com.casic.common.detector.gd.greendao.TaskMarkerLocalBeanDao; - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. - -/** - * {@inheritDoc} - * - * @see org.greenrobot.greendao.AbstractDaoSession - */ -public class DaoSession extends AbstractDaoSession { - - private final DaoConfig markerLocalBeanDaoConfig; - private final DaoConfig taskLocalBeanDaoConfig; - private final DaoConfig taskMarkerLocalBeanDaoConfig; - - private final MarkerLocalBeanDao markerLocalBeanDao; - private final TaskLocalBeanDao taskLocalBeanDao; - private final TaskMarkerLocalBeanDao taskMarkerLocalBeanDao; - - public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> - daoConfigMap) { - super(db); - - markerLocalBeanDaoConfig = daoConfigMap.get(MarkerLocalBeanDao.class).clone(); - markerLocalBeanDaoConfig.initIdentityScope(type); - - taskLocalBeanDaoConfig = daoConfigMap.get(TaskLocalBeanDao.class).clone(); - taskLocalBeanDaoConfig.initIdentityScope(type); - - taskMarkerLocalBeanDaoConfig = daoConfigMap.get(TaskMarkerLocalBeanDao.class).clone(); - taskMarkerLocalBeanDaoConfig.initIdentityScope(type); - - markerLocalBeanDao = new MarkerLocalBeanDao(markerLocalBeanDaoConfig, this); - taskLocalBeanDao = new TaskLocalBeanDao(taskLocalBeanDaoConfig, this); - taskMarkerLocalBeanDao = new TaskMarkerLocalBeanDao(taskMarkerLocalBeanDaoConfig, this); - - registerDao(MarkerLocalBean.class, markerLocalBeanDao); - registerDao(TaskLocalBean.class, taskLocalBeanDao); - registerDao(TaskMarkerLocalBean.class, taskMarkerLocalBeanDao); - } - - public void clear() { - markerLocalBeanDaoConfig.clearIdentityScope(); - taskLocalBeanDaoConfig.clearIdentityScope(); - taskMarkerLocalBeanDaoConfig.clearIdentityScope(); - } - - public MarkerLocalBeanDao getMarkerLocalBeanDao() { - return markerLocalBeanDao; - } - - public TaskLocalBeanDao getTaskLocalBeanDao() { - return taskLocalBeanDao; - } - - public TaskMarkerLocalBeanDao getTaskMarkerLocalBeanDao() { - return taskMarkerLocalBeanDao; - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/MarkerLocalBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/greendao/MarkerLocalBeanDao.java deleted file mode 100644 index 2f792c3..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/MarkerLocalBeanDao.java +++ /dev/null @@ -1,479 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import android.database.Cursor; -import android.database.sqlite.SQLiteStatement; - -import org.greenrobot.greendao.AbstractDao; -import org.greenrobot.greendao.Property; -import org.greenrobot.greendao.internal.DaoConfig; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.database.DatabaseStatement; - -import com.casic.common.detector.gd.bean.MarkerLocalBean; - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** - * DAO for table "MARKER_LOCAL_BEAN". -*/ -public class MarkerLocalBeanDao extends AbstractDao { - - public static final String TABLENAME = "MARKER_LOCAL_BEAN"; - - /** - * Properties of entity MarkerLocalBean.
- * Can be used for QueryBuilder and for referencing column names. - */ - public static class Properties { - public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property PipelineType = new Property(1, String.class, "pipelineType", false, "PIPELINE_TYPE"); - public final static Property PipelineDiameter = new Property(2, String.class, "pipelineDiameter", false, "PIPELINE_DIAMETER"); - public final static Property PipelineMaterial = new Property(3, String.class, "pipelineMaterial", false, "PIPELINE_MATERIAL"); - public final static Property BuryMethod = new Property(4, String.class, "buryMethod", false, "BURY_METHOD"); - public final static Property BuryDepth = new Property(5, String.class, "buryDepth", false, "BURY_DEPTH"); - public final static Property Area = new Property(6, String.class, "area", false, "AREA"); - public final static Property Line = new Property(7, String.class, "line", false, "LINE"); - public final static Property Road = new Property(8, String.class, "road", false, "ROAD"); - public final static Property ConstructTime = new Property(9, String.class, "constructTime", false, "CONSTRUCT_TIME"); - public final static Property Owner = new Property(10, String.class, "owner", false, "OWNER"); - public final static Property ObjectId = new Property(11, String.class, "objectId", false, "OBJECT_ID"); - public final static Property MarkerId = new Property(12, String.class, "markerId", false, "MARKER_ID"); - public final static Property MarkerType = new Property(13, String.class, "markerType", false, "MARKER_TYPE"); - public final static Property MarkerDepth = new Property(14, String.class, "markerDepth", false, "MARKER_DEPTH"); - public final static Property InstallationDept = new Property(15, String.class, "installationDept", false, "INSTALLATION_DEPT"); - public final static Property Lng = new Property(16, String.class, "lng", false, "LNG"); - public final static Property Lat = new Property(17, String.class, "lat", false, "LAT"); - public final static Property UpdateTime = new Property(18, String.class, "updateTime", false, "UPDATE_TIME"); - public final static Property Remark = new Property(19, String.class, "remark", false, "REMARK"); - public final static Property UnderlyingPipelineType = new Property(20, String.class, "underlyingPipelineType", false, "UNDERLYING_PIPELINE_TYPE"); - public final static Property UnderlyingPipelineDepth = new Property(21, String.class, "underlyingPipelineDepth", false, "UNDERLYING_PIPELINE_DEPTH"); - public final static Property UnderlyingPipelineDiameter = new Property(22, String.class, "underlyingPipelineDiameter", false, "UNDERLYING_PIPELINE_DIAMETER"); - public final static Property UnderlyingPipelineMaterial = new Property(23, String.class, "underlyingPipelineMaterial", false, "UNDERLYING_PIPELINE_MATERIAL"); - public final static Property ObjectType = new Property(24, String.class, "objectType", false, "OBJECT_TYPE"); - public final static Property Color = new Property(25, String.class, "color", false, "COLOR"); - public final static Property ImagePath = new Property(26, String.class, "imagePath", false, "IMAGE_PATH"); - } - - - public MarkerLocalBeanDao(DaoConfig config) { - super(config); - } - - public MarkerLocalBeanDao(DaoConfig config, DaoSession daoSession) { - super(config, daoSession); - } - - /** Creates the underlying database table. */ - public static void createTable(Database db, boolean ifNotExists) { - String constraint = ifNotExists? "IF NOT EXISTS ": ""; - db.execSQL("CREATE TABLE " + constraint + "\"MARKER_LOCAL_BEAN\" (" + // - "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id - "\"PIPELINE_TYPE\" TEXT," + // 1: pipelineType - "\"PIPELINE_DIAMETER\" TEXT," + // 2: pipelineDiameter - "\"PIPELINE_MATERIAL\" TEXT," + // 3: pipelineMaterial - "\"BURY_METHOD\" TEXT," + // 4: buryMethod - "\"BURY_DEPTH\" TEXT," + // 5: buryDepth - "\"AREA\" TEXT," + // 6: area - "\"LINE\" TEXT," + // 7: line - "\"ROAD\" TEXT," + // 8: road - "\"CONSTRUCT_TIME\" TEXT," + // 9: constructTime - "\"OWNER\" TEXT," + // 10: owner - "\"OBJECT_ID\" TEXT," + // 11: objectId - "\"MARKER_ID\" TEXT," + // 12: markerId - "\"MARKER_TYPE\" TEXT," + // 13: markerType - "\"MARKER_DEPTH\" TEXT," + // 14: markerDepth - "\"INSTALLATION_DEPT\" TEXT," + // 15: installationDept - "\"LNG\" TEXT," + // 16: lng - "\"LAT\" TEXT," + // 17: lat - "\"UPDATE_TIME\" TEXT," + // 18: updateTime - "\"REMARK\" TEXT," + // 19: remark - "\"UNDERLYING_PIPELINE_TYPE\" TEXT," + // 20: underlyingPipelineType - "\"UNDERLYING_PIPELINE_DEPTH\" TEXT," + // 21: underlyingPipelineDepth - "\"UNDERLYING_PIPELINE_DIAMETER\" TEXT," + // 22: underlyingPipelineDiameter - "\"UNDERLYING_PIPELINE_MATERIAL\" TEXT," + // 23: underlyingPipelineMaterial - "\"OBJECT_TYPE\" TEXT," + // 24: objectType - "\"COLOR\" TEXT," + // 25: color - "\"IMAGE_PATH\" TEXT);"); // 26: imagePath - } - - /** Drops the underlying database table. */ - public static void dropTable(Database db, boolean ifExists) { - String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"MARKER_LOCAL_BEAN\""; - db.execSQL(sql); - } - - @Override - protected final void bindValues(DatabaseStatement stmt, MarkerLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String pipelineType = entity.getPipelineType(); - if (pipelineType != null) { - stmt.bindString(2, pipelineType); - } - - String pipelineDiameter = entity.getPipelineDiameter(); - if (pipelineDiameter != null) { - stmt.bindString(3, pipelineDiameter); - } - - String pipelineMaterial = entity.getPipelineMaterial(); - if (pipelineMaterial != null) { - stmt.bindString(4, pipelineMaterial); - } - - String buryMethod = entity.getBuryMethod(); - if (buryMethod != null) { - stmt.bindString(5, buryMethod); - } - - String buryDepth = entity.getBuryDepth(); - if (buryDepth != null) { - stmt.bindString(6, buryDepth); - } - - String area = entity.getArea(); - if (area != null) { - stmt.bindString(7, area); - } - - String line = entity.getLine(); - if (line != null) { - stmt.bindString(8, line); - } - - String road = entity.getRoad(); - if (road != null) { - stmt.bindString(9, road); - } - - String constructTime = entity.getConstructTime(); - if (constructTime != null) { - stmt.bindString(10, constructTime); - } - - String owner = entity.getOwner(); - if (owner != null) { - stmt.bindString(11, owner); - } - - String objectId = entity.getObjectId(); - if (objectId != null) { - stmt.bindString(12, objectId); - } - - String markerId = entity.getMarkerId(); - if (markerId != null) { - stmt.bindString(13, markerId); - } - - String markerType = entity.getMarkerType(); - if (markerType != null) { - stmt.bindString(14, markerType); - } - - String markerDepth = entity.getMarkerDepth(); - if (markerDepth != null) { - stmt.bindString(15, markerDepth); - } - - String installationDept = entity.getInstallationDept(); - if (installationDept != null) { - stmt.bindString(16, installationDept); - } - - String lng = entity.getLng(); - if (lng != null) { - stmt.bindString(17, lng); - } - - String lat = entity.getLat(); - if (lat != null) { - stmt.bindString(18, lat); - } - - String updateTime = entity.getUpdateTime(); - if (updateTime != null) { - stmt.bindString(19, updateTime); - } - - String remark = entity.getRemark(); - if (remark != null) { - stmt.bindString(20, remark); - } - - String underlyingPipelineType = entity.getUnderlyingPipelineType(); - if (underlyingPipelineType != null) { - stmt.bindString(21, underlyingPipelineType); - } - - String underlyingPipelineDepth = entity.getUnderlyingPipelineDepth(); - if (underlyingPipelineDepth != null) { - stmt.bindString(22, underlyingPipelineDepth); - } - - String underlyingPipelineDiameter = entity.getUnderlyingPipelineDiameter(); - if (underlyingPipelineDiameter != null) { - stmt.bindString(23, underlyingPipelineDiameter); - } - - String underlyingPipelineMaterial = entity.getUnderlyingPipelineMaterial(); - if (underlyingPipelineMaterial != null) { - stmt.bindString(24, underlyingPipelineMaterial); - } - - String objectType = entity.getObjectType(); - if (objectType != null) { - stmt.bindString(25, objectType); - } - - String color = entity.getColor(); - if (color != null) { - stmt.bindString(26, color); - } - - String imagePath = entity.getImagePath(); - if (imagePath != null) { - stmt.bindString(27, imagePath); - } - } - - @Override - protected final void bindValues(SQLiteStatement stmt, MarkerLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String pipelineType = entity.getPipelineType(); - if (pipelineType != null) { - stmt.bindString(2, pipelineType); - } - - String pipelineDiameter = entity.getPipelineDiameter(); - if (pipelineDiameter != null) { - stmt.bindString(3, pipelineDiameter); - } - - String pipelineMaterial = entity.getPipelineMaterial(); - if (pipelineMaterial != null) { - stmt.bindString(4, pipelineMaterial); - } - - String buryMethod = entity.getBuryMethod(); - if (buryMethod != null) { - stmt.bindString(5, buryMethod); - } - - String buryDepth = entity.getBuryDepth(); - if (buryDepth != null) { - stmt.bindString(6, buryDepth); - } - - String area = entity.getArea(); - if (area != null) { - stmt.bindString(7, area); - } - - String line = entity.getLine(); - if (line != null) { - stmt.bindString(8, line); - } - - String road = entity.getRoad(); - if (road != null) { - stmt.bindString(9, road); - } - - String constructTime = entity.getConstructTime(); - if (constructTime != null) { - stmt.bindString(10, constructTime); - } - - String owner = entity.getOwner(); - if (owner != null) { - stmt.bindString(11, owner); - } - - String objectId = entity.getObjectId(); - if (objectId != null) { - stmt.bindString(12, objectId); - } - - String markerId = entity.getMarkerId(); - if (markerId != null) { - stmt.bindString(13, markerId); - } - - String markerType = entity.getMarkerType(); - if (markerType != null) { - stmt.bindString(14, markerType); - } - - String markerDepth = entity.getMarkerDepth(); - if (markerDepth != null) { - stmt.bindString(15, markerDepth); - } - - String installationDept = entity.getInstallationDept(); - if (installationDept != null) { - stmt.bindString(16, installationDept); - } - - String lng = entity.getLng(); - if (lng != null) { - stmt.bindString(17, lng); - } - - String lat = entity.getLat(); - if (lat != null) { - stmt.bindString(18, lat); - } - - String updateTime = entity.getUpdateTime(); - if (updateTime != null) { - stmt.bindString(19, updateTime); - } - - String remark = entity.getRemark(); - if (remark != null) { - stmt.bindString(20, remark); - } - - String underlyingPipelineType = entity.getUnderlyingPipelineType(); - if (underlyingPipelineType != null) { - stmt.bindString(21, underlyingPipelineType); - } - - String underlyingPipelineDepth = entity.getUnderlyingPipelineDepth(); - if (underlyingPipelineDepth != null) { - stmt.bindString(22, underlyingPipelineDepth); - } - - String underlyingPipelineDiameter = entity.getUnderlyingPipelineDiameter(); - if (underlyingPipelineDiameter != null) { - stmt.bindString(23, underlyingPipelineDiameter); - } - - String underlyingPipelineMaterial = entity.getUnderlyingPipelineMaterial(); - if (underlyingPipelineMaterial != null) { - stmt.bindString(24, underlyingPipelineMaterial); - } - - String objectType = entity.getObjectType(); - if (objectType != null) { - stmt.bindString(25, objectType); - } - - String color = entity.getColor(); - if (color != null) { - stmt.bindString(26, color); - } - - String imagePath = entity.getImagePath(); - if (imagePath != null) { - stmt.bindString(27, imagePath); - } - } - - @Override - public Long readKey(Cursor cursor, int offset) { - return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); - } - - @Override - public MarkerLocalBean readEntity(Cursor cursor, int offset) { - MarkerLocalBean entity = new MarkerLocalBean( // - cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // pipelineType - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // pipelineDiameter - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // pipelineMaterial - cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // buryMethod - cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // buryDepth - cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // area - cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // line - cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // road - cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // constructTime - cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10), // owner - cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11), // objectId - cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12), // markerId - cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13), // markerType - cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14), // markerDepth - cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15), // installationDept - cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16), // lng - cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17), // lat - cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18), // updateTime - cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19), // remark - cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20), // underlyingPipelineType - cursor.isNull(offset + 21) ? null : cursor.getString(offset + 21), // underlyingPipelineDepth - cursor.isNull(offset + 22) ? null : cursor.getString(offset + 22), // underlyingPipelineDiameter - cursor.isNull(offset + 23) ? null : cursor.getString(offset + 23), // underlyingPipelineMaterial - cursor.isNull(offset + 24) ? null : cursor.getString(offset + 24), // objectType - cursor.isNull(offset + 25) ? null : cursor.getString(offset + 25), // color - cursor.isNull(offset + 26) ? null : cursor.getString(offset + 26) // imagePath - ); - return entity; - } - - @Override - public void readEntity(Cursor cursor, MarkerLocalBean entity, int offset) { - entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setPipelineType(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); - entity.setPipelineDiameter(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); - entity.setPipelineMaterial(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); - entity.setBuryMethod(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); - entity.setBuryDepth(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); - entity.setArea(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); - entity.setLine(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); - entity.setRoad(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); - entity.setConstructTime(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9)); - entity.setOwner(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); - entity.setObjectId(cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11)); - entity.setMarkerId(cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12)); - entity.setMarkerType(cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13)); - entity.setMarkerDepth(cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14)); - entity.setInstallationDept(cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15)); - entity.setLng(cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16)); - entity.setLat(cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17)); - entity.setUpdateTime(cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18)); - entity.setRemark(cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19)); - entity.setUnderlyingPipelineType(cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20)); - entity.setUnderlyingPipelineDepth(cursor.isNull(offset + 21) ? null : cursor.getString(offset + 21)); - entity.setUnderlyingPipelineDiameter(cursor.isNull(offset + 22) ? null : cursor.getString(offset + 22)); - entity.setUnderlyingPipelineMaterial(cursor.isNull(offset + 23) ? null : cursor.getString(offset + 23)); - entity.setObjectType(cursor.isNull(offset + 24) ? null : cursor.getString(offset + 24)); - entity.setColor(cursor.isNull(offset + 25) ? null : cursor.getString(offset + 25)); - entity.setImagePath(cursor.isNull(offset + 26) ? null : cursor.getString(offset + 26)); - } - - @Override - protected final Long updateKeyAfterInsert(MarkerLocalBean entity, long rowId) { - entity.setId(rowId); - return rowId; - } - - @Override - public Long getKey(MarkerLocalBean entity) { - if(entity != null) { - return entity.getId(); - } else { - return null; - } - } - - @Override - public boolean hasKey(MarkerLocalBean entity) { - return entity.getId() != null; - } - - @Override - protected final boolean isEntityUpdateable() { - return true; - } - -} diff --git a/app/build.gradle b/app/build.gradle index d0cb423..921c8c8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,25 +1,20 @@ import java.text.SimpleDateFormat -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply plugin: 'org.greenrobot.greendao' +plugins { + id('com.android.application') + id('org.jetbrains.kotlin.android') +} android { - compileSdkVersion 33 + namespace 'com.casic.common.detector.gd' + compileSdk 35 defaultConfig { - applicationId "com.casic.common.detector.gd" - minSdkVersion 26 - targetSdkVersion 33 + applicationId 'com.casic.common.detector.gd' + minSdk 26 + targetSdk 35 versionCode 5092 - versionName "5.0.9.2" - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } + versionName '5.0.9.2' } signingConfigs { @@ -31,6 +26,14 @@ } } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + signingConfig signingConfigs.release + } + } + compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 @@ -47,27 +50,16 @@ } } - kotlin { - experimental { - coroutines 'enable' - } - } - buildFeatures { + buildConfig true viewBinding true } - applicationVariants.configureEach { variant -> - variant.outputs.configureEach { - outputFileName = "COM_TCY_" + getBuildDate() + "_" + defaultConfig.versionName + ".apk" + applicationVariants.configureEach { + outputs.configureEach { + outputFileName = 'COM_TCY_' + getBuildDate() + '_' + defaultConfig.versionName + '.apk' } } - - greendao { - schemaVersion 1//数据库版本号 - targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 - daoPackage "${defaultConfig.applicationId}.greendao"//设置DaoMaster、DaoSession、Dao包名 - } } static def getBuildDate() { @@ -76,27 +68,22 @@ } dependencies { - //基础依赖库 - implementation 'com.github.AndroidCoderPeng:Kotlin-lite-lib:1.1.4' - implementation 'androidx.core:core-ktx:1.9.0' - def base_version = "1.6.1" - implementation "androidx.appcompat:appcompat:${base_version}" - implementation "com.google.android.material:material:${base_version}" + implementation 'com.github.AndroidCoderPeng:Kotlin-lite-lib:1.1.5' + implementation 'androidx.core:core-ktx:1.13.1' + implementation 'androidx.appcompat:appcompat:1.7.0' + implementation 'com.google.android.material:material:1.12.0' //Google官方授权框架 implementation 'pub.devrel:easypermissions:3.0.0' - //沉浸式状态栏。基础依赖包,必须要依赖 - implementation 'com.gyf.immersionbar:immersionbar:3.0.0' - //fragment快速实现 - implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0' + //沉浸式状态栏 + implementation 'com.geyifeng.immersionbar:immersionbar:3.2.2' //官方Json解析库 implementation 'com.google.code.gson:gson:2.10.1' - def vm_version = '2.5.1' //Kotlin协程 - implementation "androidx.lifecycle:lifecycle-runtime-ktx:${vm_version}" + implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.2' //MVVM+LiveData - implementation "androidx.lifecycle:lifecycle-livedata-ktx:${vm_version}" - implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:${vm_version}" - implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.6.2' + implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2' + implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' //返回值转换器 implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' @@ -105,9 +92,10 @@ implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' //网络请求和接口封装 implementation 'com.squareup.retrofit2:retrofit:2.9.0' - implementation 'com.squareup.okhttp3:okhttp:4.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.12.0' //数据库框架 - implementation 'org.greenrobot:greendao:3.3.0' + implementation 'androidx.room:room-runtime:2.6.1' + annotationProcessor 'androidx.room:room-compiler:2.5.2' //高德导航、定位、地图三合一 implementation 'com.amap.api:navi-3dmap:latest.integration' //经纬度逆编码 @@ -115,7 +103,7 @@ //excel implementation 'net.sourceforge.jexcelapi:jxl:2.6.12' //图片加载框架 - implementation 'com.github.bumptech.glide:glide:4.9.0' + implementation 'com.github.bumptech.glide:glide:4.12.0' //图片选择框架 implementation 'io.github.lucksiege:pictureselector:v3.11.1' //大图 diff --git a/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt b/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt index 7b695ff..50ba734 100644 --- a/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt +++ b/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt @@ -4,9 +4,9 @@ import android.app.Application import android.os.Bundle import android.util.Log -import com.casic.common.detector.gd.greendao.DaoMaster -import com.casic.common.detector.gd.greendao.DaoSession +import androidx.room.Room.databaseBuilder import com.casic.common.detector.gd.uart.SerialPort +import com.casic.common.detector.gd.utils.DetectorDataBase import com.casic.common.detector.gd.utils.GpioManager import com.pengxh.kt.lite.extensions.show import com.pengxh.kt.lite.utils.SaveKeyValues @@ -43,44 +43,42 @@ private var application: BaseApplication by Delegates.notNull() fun get() = application - - private lateinit var daoSession: DaoSession } + lateinit var dataBase: DetectorDataBase + override fun onCreate() { super.onCreate() application = this SaveKeyValues.initSharedPreferences(this) CrashReport.initCrashReport(this, "01e80d3a74", true) - val devOpenHelper = DaoMaster.DevOpenHelper(this, "Detector.db", null) - val daoMaster = DaoMaster(devOpenHelper.writableDatabase) - daoSession = daoMaster.newSession() + dataBase = databaseBuilder(this, DetectorDataBase::class.java, "Detector.db") + .allowMainThreadQueries() + .build() /** * Open the serial port * */ try { serialPorts.apply { - add(SerialPort(File("/dev/ttysWK1"), 9600, 0)) - //千寻报文数据下发串口号 - add(SerialPort(File("/dev/ttyS1"), 9600, 0)) + add(SerialPort(File("/dev/ttysWK1"), 9600, 0)) //信号通讯串口 + add(SerialPort(File("/dev/ttyS1"), 9600, 0)) //千寻报文数据下发串口号 } Log.d(kTag, "onCreate: 已初始化 ${serialPorts.size} 个串口") } catch (e: SecurityException) { "您没有串口的读写权限!".show(this) + e.printStackTrace() } catch (e: IOException) { "因为不明原因,串口无法打开!".show(this) + e.printStackTrace() } catch (e: InvalidParameterException) { "请检查串口!".show(this) + e.printStackTrace() } registerActivityLifecycleCallbacks(this) } - fun getDaoSession(): DaoSession { - return daoSession - } - override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) { } diff --git a/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt b/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt index 053b9dd..1d0c9e3 100644 --- a/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt +++ b/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt @@ -14,12 +14,10 @@ import com.casic.common.detector.gd.utils.SerialPortCommand import com.pengxh.kt.lite.utils.WeakReferenceHandler import java.io.IOException -import java.util.Timer abstract class SerialPortBaseActivity : AppCompatActivity(), Handler.Callback { private val kTag = "SerialPortBaseActivity" - private val taskTimer by lazy { Timer() } private val weakReferenceHandler by lazy { WeakReferenceHandler(this) } private val serialPorts by lazy { BaseApplication.get().getSerialPorts() } protected lateinit var binding: VB @@ -30,7 +28,6 @@ setContentView(binding.root) setupTopBarLayout() initOnCreate(savedInstanceState) - observeRequestState() initEvent() if (serialPorts.isNotEmpty()) { @@ -71,11 +68,6 @@ abstract fun initOnCreate(savedInstanceState: Bundle?) /** - * 数据请求状态监听 - */ - abstract fun observeRequestState() - - /** * 初始化业务逻辑 */ abstract fun initEvent() diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java new file mode 100644 index 0000000..7a18c20 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java @@ -0,0 +1,255 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 从平台下载的标识器本地库实体类 + */ +@Entity(tableName = "marker_detail") +public class MarkerBean { + @PrimaryKey(autoGenerate = true) + private long id; //主键ID + private String pipelineType; // 管线类型 + private String pipelineDiameter; // 管线直径 + private String pipelineMaterial; // 管材 + private String buryMethod; // 埋设方式 + private String buryDepth; // 埋深 + private String area; // 所属区域 + private String line; // 所属线路 + private String road; // 所属道路 + private String constructTime; // 建设年代 + private String owner; // 权属单位 + private String objectId; // 标识对象ID,无实际用途 + private String markerId; // 标识器ID + private String markerType; // 标识器类型 + private String markerDepth; // 标识器埋深 + private String installationDept; // 安装部门 + private String lng; // 经度 + private String lat; // 纬度 + private String updateTime; // 最后修改时间,更新时间 + private String remark; // 备注信息 + private String underlyingPipelineType; // 下层管线类型 + private String underlyingPipelineDepth; // 下层埋深 + private String underlyingPipelineDiameter; // 下层管径 + private String underlyingPipelineMaterial; // 下层管材 + private String objectType; //标识对象类型 + private String color; // 颜色 + private String imagePath; // 图片路径 + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getPipelineType() { + return pipelineType; + } + + public void setPipelineType(String pipelineType) { + this.pipelineType = pipelineType; + } + + public String getPipelineDiameter() { + return pipelineDiameter; + } + + public void setPipelineDiameter(String pipelineDiameter) { + this.pipelineDiameter = pipelineDiameter; + } + + public String getPipelineMaterial() { + return pipelineMaterial; + } + + public void setPipelineMaterial(String pipelineMaterial) { + this.pipelineMaterial = pipelineMaterial; + } + + public String getBuryMethod() { + return buryMethod; + } + + public void setBuryMethod(String buryMethod) { + this.buryMethod = buryMethod; + } + + public String getBuryDepth() { + return buryDepth; + } + + public void setBuryDepth(String buryDepth) { + this.buryDepth = buryDepth; + } + + public String getArea() { + return area; + } + + public void setArea(String area) { + this.area = area; + } + + public String getLine() { + return line; + } + + public void setLine(String line) { + this.line = line; + } + + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + + public String getConstructTime() { + return constructTime; + } + + public void setConstructTime(String constructTime) { + this.constructTime = constructTime; + } + + public String getOwner() { + return owner; + } + + public void setOwner(String owner) { + this.owner = owner; + } + + public String getObjectId() { + return objectId; + } + + public void setObjectId(String objectId) { + this.objectId = objectId; + } + + public String getMarkerId() { + return markerId; + } + + public void setMarkerId(String markerId) { + this.markerId = markerId; + } + + public String getMarkerType() { + return markerType; + } + + public void setMarkerType(String markerType) { + this.markerType = markerType; + } + + public String getMarkerDepth() { + return markerDepth; + } + + public void setMarkerDepth(String markerDepth) { + this.markerDepth = markerDepth; + } + + public String getInstallationDept() { + return installationDept; + } + + public void setInstallationDept(String installationDept) { + this.installationDept = installationDept; + } + + public String getLng() { + return lng; + } + + public void setLng(String lng) { + this.lng = lng; + } + + public String getLat() { + return lat; + } + + public void setLat(String lat) { + this.lat = lat; + } + + public String getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } + + public String getUnderlyingPipelineType() { + return underlyingPipelineType; + } + + public void setUnderlyingPipelineType(String underlyingPipelineType) { + this.underlyingPipelineType = underlyingPipelineType; + } + + public String getUnderlyingPipelineDepth() { + return underlyingPipelineDepth; + } + + public void setUnderlyingPipelineDepth(String underlyingPipelineDepth) { + this.underlyingPipelineDepth = underlyingPipelineDepth; + } + + public String getUnderlyingPipelineDiameter() { + return underlyingPipelineDiameter; + } + + public void setUnderlyingPipelineDiameter(String underlyingPipelineDiameter) { + this.underlyingPipelineDiameter = underlyingPipelineDiameter; + } + + public String getUnderlyingPipelineMaterial() { + return underlyingPipelineMaterial; + } + + public void setUnderlyingPipelineMaterial(String underlyingPipelineMaterial) { + this.underlyingPipelineMaterial = underlyingPipelineMaterial; + } + + public String getObjectType() { + return objectType; + } + + public void setObjectType(String objectType) { + this.objectType = objectType; + } + + public String getColor() { + return color; + } + + public void setColor(String color) { + this.color = color; + } + + public String getImagePath() { + return imagePath; + } + + public void setImagePath(String imagePath) { + this.imagePath = imagePath; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java deleted file mode 100644 index 3f2fcdc..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java +++ /dev/null @@ -1,327 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 从平台下载的标识器本地库实体类 - */ -@Entity -public class MarkerLocalBean { - @Id(autoincrement = true) - private Long id;//本地库主键ID - - // 管线类型 - private String pipelineType; - // 管线直径 - private String pipelineDiameter; - // 管材 - private String pipelineMaterial; - // 埋设方式 - private String buryMethod; - // 埋深 - private String buryDepth; - // 所属区域 - private String area; - // 所属线路 - private String line; - // 所属道路 - private String road; - // 建设年代 - private String constructTime; - // 权属单位 - private String owner; - //标识对象ID,无实际用途 - @Deprecated - private String objectId; - // 标识器ID - private String markerId; - // 标识器类型 - private String markerType; - // 标识器埋深 - private String markerDepth; - // 安装部门 - private String installationDept; - // 经度 - private String lng; - // 纬度 - private String lat; - //最后修改时间,更新时间 - private String updateTime; - // 备注信息 - private String remark; - // 下层管线类型 - private String underlyingPipelineType; - // 下层埋深 - private String underlyingPipelineDepth; - // 下层管径 - private String underlyingPipelineDiameter; - // 下层管材 - private String underlyingPipelineMaterial; - //标识对象类型 - private String objectType; - // 颜色 - private String color; - // 图片路径 - private String imagePath; - - @Generated(hash = 1479045776) - public MarkerLocalBean(Long id, String pipelineType, String pipelineDiameter, - String pipelineMaterial, String buryMethod, String buryDepth, - String area, String line, String road, String constructTime, - String owner, String objectId, String markerId, String markerType, - String markerDepth, String installationDept, String lng, String lat, - String updateTime, String remark, String underlyingPipelineType, - String underlyingPipelineDepth, String underlyingPipelineDiameter, - String underlyingPipelineMaterial, String objectType, String color, - String imagePath) { - this.id = id; - this.pipelineType = pipelineType; - this.pipelineDiameter = pipelineDiameter; - this.pipelineMaterial = pipelineMaterial; - this.buryMethod = buryMethod; - this.buryDepth = buryDepth; - this.area = area; - this.line = line; - this.road = road; - this.constructTime = constructTime; - this.owner = owner; - this.objectId = objectId; - this.markerId = markerId; - this.markerType = markerType; - this.markerDepth = markerDepth; - this.installationDept = installationDept; - this.lng = lng; - this.lat = lat; - this.updateTime = updateTime; - this.remark = remark; - this.underlyingPipelineType = underlyingPipelineType; - this.underlyingPipelineDepth = underlyingPipelineDepth; - this.underlyingPipelineDiameter = underlyingPipelineDiameter; - this.underlyingPipelineMaterial = underlyingPipelineMaterial; - this.objectType = objectType; - this.color = color; - this.imagePath = imagePath; - } - - @Generated(hash = 1538606012) - public MarkerLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getPipelineType() { - return this.pipelineType; - } - - public void setPipelineType(String pipelineType) { - this.pipelineType = pipelineType; - } - - public String getPipelineDiameter() { - return this.pipelineDiameter; - } - - public void setPipelineDiameter(String pipelineDiameter) { - this.pipelineDiameter = pipelineDiameter; - } - - public String getPipelineMaterial() { - return this.pipelineMaterial; - } - - public void setPipelineMaterial(String pipelineMaterial) { - this.pipelineMaterial = pipelineMaterial; - } - - public String getBuryMethod() { - return this.buryMethod; - } - - public void setBuryMethod(String buryMethod) { - this.buryMethod = buryMethod; - } - - public String getBuryDepth() { - return this.buryDepth; - } - - public void setBuryDepth(String buryDepth) { - this.buryDepth = buryDepth; - } - - public String getArea() { - return this.area; - } - - public void setArea(String area) { - this.area = area; - } - - public String getLine() { - return this.line; - } - - public void setLine(String line) { - this.line = line; - } - - public String getRoad() { - return this.road; - } - - public void setRoad(String road) { - this.road = road; - } - - public String getConstructTime() { - return this.constructTime; - } - - public void setConstructTime(String constructTime) { - this.constructTime = constructTime; - } - - public String getOwner() { - return this.owner; - } - - public void setOwner(String owner) { - this.owner = owner; - } - - public String getObjectId() { - return this.objectId; - } - - public void setObjectId(String objectId) { - this.objectId = objectId; - } - - public String getMarkerId() { - return this.markerId; - } - - public void setMarkerId(String markerId) { - this.markerId = markerId; - } - - public String getMarkerType() { - return this.markerType; - } - - public void setMarkerType(String markerType) { - this.markerType = markerType; - } - - public String getMarkerDepth() { - return this.markerDepth; - } - - public void setMarkerDepth(String markerDepth) { - this.markerDepth = markerDepth; - } - - public String getInstallationDept() { - return this.installationDept; - } - - public void setInstallationDept(String installationDept) { - this.installationDept = installationDept; - } - - public String getLng() { - return this.lng; - } - - public void setLng(String lng) { - this.lng = lng; - } - - public String getLat() { - return this.lat; - } - - public void setLat(String lat) { - this.lat = lat; - } - - public String getUpdateTime() { - return this.updateTime; - } - - public void setUpdateTime(String updateTime) { - this.updateTime = updateTime; - } - - public String getRemark() { - return this.remark; - } - - public void setRemark(String remark) { - this.remark = remark; - } - - public String getUnderlyingPipelineType() { - return this.underlyingPipelineType; - } - - public void setUnderlyingPipelineType(String underlyingPipelineType) { - this.underlyingPipelineType = underlyingPipelineType; - } - - public String getUnderlyingPipelineDepth() { - return this.underlyingPipelineDepth; - } - - public void setUnderlyingPipelineDepth(String underlyingPipelineDepth) { - this.underlyingPipelineDepth = underlyingPipelineDepth; - } - - public String getUnderlyingPipelineDiameter() { - return this.underlyingPipelineDiameter; - } - - public void setUnderlyingPipelineDiameter(String underlyingPipelineDiameter) { - this.underlyingPipelineDiameter = underlyingPipelineDiameter; - } - - public String getUnderlyingPipelineMaterial() { - return this.underlyingPipelineMaterial; - } - - public void setUnderlyingPipelineMaterial(String underlyingPipelineMaterial) { - this.underlyingPipelineMaterial = underlyingPipelineMaterial; - } - - public String getObjectType() { - return this.objectType; - } - - public void setObjectType(String objectType) { - this.objectType = objectType; - } - - public String getColor() { - return this.color; - } - - public void setColor(String color) { - this.color = color; - } - - public String getImagePath() { - return this.imagePath; - } - - public void setImagePath(String imagePath) { - this.imagePath = imagePath; - } -} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java new file mode 100644 index 0000000..5c88fdf --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java @@ -0,0 +1,93 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 巡检任务本地库实体类,不包含任务里面需要巡检的标识器信息 + */ +@Entity(tableName = "task_detail") +public class TaskBean { + @PrimaryKey(autoGenerate = true) + private long id;//主键ID + private String taskCode; // 任务编号 + private String description; // 任务名称 + private String createTime; // 任务创建的时间 + private String status; // 任务状态 + private String createUserName; // 任务创建者名称 + private String startTime; // 任务被开始执行的时间 + private String endTime; // 任务执行结束的时间 + private String isFree; // 是否自由巡检。1-是,0-否 + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getTaskCode() { + return taskCode; + } + + public void setTaskCode(String taskCode) { + this.taskCode = taskCode; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getCreateUserName() { + return createUserName; + } + + public void setCreateUserName(String createUserName) { + this.createUserName = createUserName; + } + + public String getStartTime() { + return startTime; + } + + public void setStartTime(String startTime) { + this.startTime = startTime; + } + + public String getEndTime() { + return endTime; + } + + public void setEndTime(String endTime) { + this.endTime = endTime; + } + + public String getIsFree() { + return isFree; + } + + public void setIsFree(String isFree) { + this.isFree = isFree; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java deleted file mode 100644 index 91737b3..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java +++ /dev/null @@ -1,114 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 巡检任务本地库实体类,不包含任务里面需要巡检的标识器信息 - */ -@Entity -public class TaskLocalBean { - @Id - private Long id;//任务ID - - private String taskCode;//任务编号 - private String description;//任务名称 - private String createTime;//任务创建的时间 - private String status;//任务状态 - private String createUserName;//任务创建者名称 - private String startTime;//任务被开始执行的时间 - private String endTime;//任务执行结束的时间 - private String isFreeTask;//是否自由巡检。1-是,0-否 - - @Generated(hash = 1482022528) - public TaskLocalBean(Long id, String taskCode, String description, - String createTime, String status, String createUserName, - String startTime, String endTime, String isFreeTask) { - this.id = id; - this.taskCode = taskCode; - this.description = description; - this.createTime = createTime; - this.status = status; - this.createUserName = createUserName; - this.startTime = startTime; - this.endTime = endTime; - this.isFreeTask = isFreeTask; - } - - @Generated(hash = 949704588) - public TaskLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getTaskCode() { - return this.taskCode; - } - - public void setTaskCode(String taskCode) { - this.taskCode = taskCode; - } - - public String getDescription() { - return this.description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getCreateTime() { - return this.createTime; - } - - public void setCreateTime(String createTime) { - this.createTime = createTime; - } - - public String getStatus() { - return this.status; - } - - public void setStatus(String status) { - this.status = status; - } - - public String getCreateUserName() { - return this.createUserName; - } - - public void setCreateUserName(String createUserName) { - this.createUserName = createUserName; - } - - public String getStartTime() { - return this.startTime; - } - - public void setStartTime(String startTime) { - this.startTime = startTime; - } - - public String getEndTime() { - return this.endTime; - } - - public void setEndTime(String endTime) { - this.endTime = endTime; - } - - public String getIsFreeTask() { - return this.isFreeTask; - } - - public void setIsFreeTask(String isFreeTask) { - this.isFreeTask = isFreeTask; - } -} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerBean.java new file mode 100644 index 0000000..c563a60 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerBean.java @@ -0,0 +1,110 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 巡检任务里面需要巡检的标识器信息本地库实体类 + */ +@Entity(tableName = "task_marker_info") +public class TaskMarkerBean { + //标识器后台库的主键ID,不是标识器实际ID + @PrimaryKey(autoGenerate = true) + private long id; + + /** + * 任务ID,通过此字段关联[TaskBean.id] + */ + private String taskId; + + /** + * 任务Code,通过此字段关联[TaskBean.taskCode] + *

+ *

+ * 双重验证,防止出现同时刻重复的情况 + */ + private String taskCode; + + /** + * 对应后台字段[TaskModel.MessageModel.TaskDetailInfosModel.markerIdReal],也就是探测仪扫描出来的ID + */ + private String markerId; + + private Double lng; + private Double lat; + + /** + * 是否已被探测到 + * 1-是,0-否 + */ + private String isDetected; + + /** + * 被探测到的时间,对应后台字段[TaskModel.MessageModel.TaskDetailInfosModel.finishTime] + */ + private String detectedTime; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getTaskId() { + return taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getTaskCode() { + return taskCode; + } + + public void setTaskCode(String taskCode) { + this.taskCode = taskCode; + } + + public String getMarkerId() { + return markerId; + } + + public void setMarkerId(String markerId) { + this.markerId = markerId; + } + + public Double getLng() { + return lng; + } + + public void setLng(Double lng) { + this.lng = lng; + } + + public Double getLat() { + return lat; + } + + public void setLat(Double lat) { + this.lat = lat; + } + + public String getIsDetected() { + return isDetected; + } + + public void setIsDetected(String isDetected) { + this.isDetected = isDetected; + } + + public String getDetectedTime() { + return detectedTime; + } + + public void setDetectedTime(String detectedTime) { + this.detectedTime = detectedTime; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerLocalBean.java deleted file mode 100644 index de9f459..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerLocalBean.java +++ /dev/null @@ -1,128 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import com.casic.common.detector.gd.model.TaskModel; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 巡检任务里面需要巡检的标识器信息本地库实体类 - */ -@Entity -public class TaskMarkerLocalBean { - @Id - private Long id;//标识器后台库的主键ID,不是标识器实际ID - - /** - * 任务ID,通过此字段关联{@link TaskLocalBean#id} - */ - private String taskId; - - /** - * 任务Code,通过此字段关联{@link TaskLocalBean#taskCode} - *

- * 双重验证,防止出现同时刻重复的情况 - */ - private String taskCode; - - /** - * 对应后台字段{@link TaskModel.MessageModel.TaskDetailInfosModel#markerIdReal},也就是探测仪扫描出来的ID - */ - private String markerId; - - private double lng; - private double lat; - - /** - * 是否已被探测到 - * 1-是,0-否 - */ - private String isDetected; - - /** - * 被探测到的时间,对应后台字段{@link TaskModel.MessageModel.TaskDetailInfosModel#finishTime} - */ - private String detectedTime; - - @Generated(hash = 677328533) - public TaskMarkerLocalBean(Long id, String taskId, String taskCode, String markerId, - double lng, double lat, String isDetected, String detectedTime) { - this.id = id; - this.taskId = taskId; - this.taskCode = taskCode; - this.markerId = markerId; - this.lng = lng; - this.lat = lat; - this.isDetected = isDetected; - this.detectedTime = detectedTime; - } - - @Generated(hash = 1162404642) - public TaskMarkerLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getTaskId() { - return this.taskId; - } - - public void setTaskId(String taskId) { - this.taskId = taskId; - } - - public String getTaskCode() { - return this.taskCode; - } - - public void setTaskCode(String taskCode) { - this.taskCode = taskCode; - } - - public String getMarkerId() { - return this.markerId; - } - - public void setMarkerId(String markerId) { - this.markerId = markerId; - } - - public double getLng() { - return this.lng; - } - - public void setLng(double lng) { - this.lng = lng; - } - - public double getLat() { - return this.lat; - } - - public void setLat(double lat) { - this.lat = lat; - } - - public String getIsDetected() { - return this.isDetected; - } - - public void setIsDetected(String isDetected) { - this.isDetected = isDetected; - } - - public String getDetectedTime() { - return this.detectedTime; - } - - public void setDetectedTime(String detectedTime) { - this.detectedTime = detectedTime; - } -} diff --git a/app/src/main/java/com/casic/common/detector/gd/dao/MarkerBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/dao/MarkerBeanDao.java new file mode 100644 index 0000000..2beb7ed --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/dao/MarkerBeanDao.java @@ -0,0 +1,29 @@ +package com.casic.common.detector.gd.dao; + +import androidx.room.Dao; +import androidx.room.Insert; +import androidx.room.Query; +import androidx.room.RawQuery; +import androidx.sqlite.db.SupportSQLiteQuery; + +import com.casic.common.detector.gd.bean.MarkerBean; + +import java.util.List; + +@Dao +public interface MarkerBeanDao { + @Query("DELETE FROM marker_detail") + void deleteAll(); + + @Insert + void insert(MarkerBean marker); + + @Query("SELECT * FROM marker_detail") + List loadAll(); + + @Query("SELECT * FROM marker_detail WHERE markerId = :markerId") + List queryMarkerById(String markerId); + + @RawQuery + List loadMarkersByCondition(SupportSQLiteQuery query); +} diff --git a/app/src/main/java/com/casic/common/detector/gd/dao/TaskBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/dao/TaskBeanDao.java new file mode 100644 index 0000000..9c70ac2 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/dao/TaskBeanDao.java @@ -0,0 +1,120 @@ +package com.casic.common.detector.gd.dao; + +import androidx.room.Dao; +import androidx.room.Insert; +import androidx.room.Query; +import androidx.room.Transaction; + +import com.casic.common.detector.gd.bean.TaskBean; +import com.casic.common.detector.gd.bean.TaskMarkerBean; +import com.casic.common.detector.gd.model.TaskDetailLocalModel; +import com.casic.common.detector.gd.model.TaskModel; +import com.casic.common.detector.gd.utils.LocaleConstant; +import com.pengxh.kt.lite.utils.SaveKeyValues; + +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Locale; + +@Dao +public interface TaskBeanDao { + @Query("SELECT COUNT(*) FROM task_detail WHERE id = :taskId") + int isTaskExist(long taskId); + + @Insert + void insert(TaskBean task); + + default void saveTask(Long taskId, String taskName) { + if (isTaskExist(taskId) == 0) { + TaskBean task = new TaskBean(); + task.setId(taskId); + task.setTaskCode(new SimpleDateFormat("yyyyMMddHHmmss", Locale.CHINA).format(new Date())); + task.setDescription(taskName); + String time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA).format(new Date()); + task.setCreateTime(time); + task.setStatus("0"); + String userName = (String) SaveKeyValues.INSTANCE.getValue(LocaleConstant.USER_NAME, ""); + task.setCreateUserName(userName); + task.setStartTime(time); + task.setEndTime(""); + task.setIsFree("1"); + insert(task); + } + } + + default void saveTask(TaskModel.MessageModel model) { + TaskBean task = new TaskBean(); + task.setId(model.getId()); + task.setTaskCode(model.getTaskCode()); + task.setDescription(model.getDescription()); + task.setCreateTime(model.getDeployDate()); + task.setStatus(model.getStatus()); + task.setCreateUserName(model.getCreatorName()); + task.setStartTime(model.getBeginDate()); + task.setEndTime(model.getEndDate()); + task.setIsFree("0"); + if (isTaskExist(task.getId()) == 0) { + insert(task); + } + } + + @Query("SELECT * FROM task_detail") + List loadAll(); + + @Transaction + default ArrayList loadLocalTask(TaskMarkerBeanDao taskMarkerBeanDao) { + ArrayList result = new ArrayList<>(); + List tasks = loadAll(); + for (TaskBean it : tasks) { + TaskDetailLocalModel model = new TaskDetailLocalModel(); + model.setTaskId(String.valueOf(it.getId())); + model.setTaskCode(it.getTaskCode()); + model.setDescription(it.getDescription()); + model.setCreateTime(it.getCreateTime()); + model.setStatus(it.getStatus()); + model.setCreateUserName(it.getCreateUserName()); + model.setIsFreeTask(it.getIsFree()); + ArrayList results = new ArrayList<>(); + if ("0".equals(it.getIsFree())) { + // 非自由巡检才有Marker + List markers = taskMarkerBeanDao.getMarkersByIdAndCode(String.valueOf(it.getId()), it.getTaskCode()); + for (TaskMarkerBean marker : markers) { + TaskDetailLocalModel.TaskMarkerLocalModel localModel = new TaskDetailLocalModel.TaskMarkerLocalModel(); + localModel.setMarkerId(marker.getMarkerId()); + localModel.setLng(marker.getLng()); + localModel.setLat(marker.getLat()); + localModel.setIsDetected(marker.getIsDetected()); + localModel.setDetectedTime(marker.getDetectedTime()); + + results.add(localModel); + } + } + model.setMarkerModels(results); + result.add(model); + } + return result; + } + + @Query("DELETE FROM task_detail WHERE id = :taskId AND taskCode = :taskCode") + void deleteTaskById(long taskId, String taskCode); + + @Transaction + default void deleteLocalTaskById(long taskId, String taskCode, TaskMarkerBeanDao taskMarkerBeanDao) { + TaskBean task = loadAll().stream() + .filter(it -> it.getId() == taskId && taskCode.equals(it.getTaskCode())) + .findFirst() + .orElse(null); + if (task == null) return; + deleteTaskById(taskId, taskCode); + + // 删除此任务关联的Marker。非自由巡检才有Marker + if ("0".equals(task.getIsFree())) { + List markers = taskMarkerBeanDao.getMarkersByIdAndCode(String.valueOf(task.getId()), task.getTaskCode()); + for (TaskMarkerBean marker : markers) { + taskMarkerBeanDao.delete(marker); + } + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/dao/TaskMarkerBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/dao/TaskMarkerBeanDao.java new file mode 100644 index 0000000..cc2156a --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/dao/TaskMarkerBeanDao.java @@ -0,0 +1,52 @@ +package com.casic.common.detector.gd.dao; + +import androidx.room.Dao; +import androidx.room.Delete; +import androidx.room.Insert; +import androidx.room.Query; +import androidx.room.Update; + +import com.casic.common.detector.gd.bean.TaskMarkerBean; +import com.casic.common.detector.gd.model.TaskModel; + +import java.util.List; + +@Dao +public interface TaskMarkerBeanDao { + + @Insert + void insert(TaskMarkerBean marker); + + @Query("SELECT COUNT(*) FROM task_marker_info WHERE id = :markerId") + int isMarkerExist(String markerId); + + default void saveTaskMarker(long taskId, String taskCode, TaskModel.MessageModel.TaskDetailInfosModel marker) { + if (isMarkerExist(marker.getMarkerId()) == 0) { + TaskMarkerBean bean = new TaskMarkerBean(); + bean.setId(marker.getId()); + bean.setTaskId(String.valueOf(taskId)); + bean.setTaskCode(taskCode); + bean.setMarkerId(marker.getMarkerIdReal()); + bean.setLng(marker.getLongitude()); + bean.setLat(marker.getLatitude()); + bean.setIsDetected("0"); + bean.setDetectedTime(""); + insert(bean); + } + } + + @Query("SELECT * FROM task_marker_info WHERE taskId = :taskId AND taskCode = :taskCode AND markerId = :markerId AND isDetected = :state") + TaskMarkerBean queryTaskMarkerById(String taskId, String taskCode, String markerId, String state); + + @Update + void updateLocalTaskMarkerState(TaskMarkerBean marker); + + @Query("SELECT * FROM task_marker_info WHERE isDetected = :state") + List queryMarkerByState(String state); + + @Query("SELECT * FROM task_marker_info WHERE taskId = :taskId AND taskCode = :taskCode") + List getMarkersByIdAndCode(String taskId, String taskCode); + + @Delete + void delete(TaskMarkerBean marker); +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/extensions/Long.kt b/app/src/main/java/com/casic/common/detector/gd/extensions/Long.kt deleted file mode 100644 index 6713d8d..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/extensions/Long.kt +++ /dev/null @@ -1,10 +0,0 @@ -package com.casic.common.detector.gd.extensions - -import java.text.SimpleDateFormat -import java.util.Date -import java.util.Locale - -fun Long.createTaskCode(): String { - val dateFormat = SimpleDateFormat("yyyyMMddHHmmss", Locale.CHINA) - return dateFormat.format(Date(this)) -} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoMaster.java b/app/src/main/java/com/casic/common/detector/gd/greendao/DaoMaster.java deleted file mode 100644 index 6ab94b3..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoMaster.java +++ /dev/null @@ -1,102 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import android.content.Context; -import android.database.sqlite.SQLiteDatabase; -import android.database.sqlite.SQLiteDatabase.CursorFactory; -import android.util.Log; - -import org.greenrobot.greendao.AbstractDaoMaster; -import org.greenrobot.greendao.database.StandardDatabase; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.database.DatabaseOpenHelper; -import org.greenrobot.greendao.identityscope.IdentityScopeType; - - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** - * Master of DAO (schema version 1): knows all DAOs. - */ -public class DaoMaster extends AbstractDaoMaster { - public static final int SCHEMA_VERSION = 1; - - /** Creates underlying database table using DAOs. */ - public static void createAllTables(Database db, boolean ifNotExists) { - MarkerLocalBeanDao.createTable(db, ifNotExists); - TaskLocalBeanDao.createTable(db, ifNotExists); - TaskMarkerLocalBeanDao.createTable(db, ifNotExists); - } - - /** Drops underlying database table using DAOs. */ - public static void dropAllTables(Database db, boolean ifExists) { - MarkerLocalBeanDao.dropTable(db, ifExists); - TaskLocalBeanDao.dropTable(db, ifExists); - TaskMarkerLocalBeanDao.dropTable(db, ifExists); - } - - /** - * WARNING: Drops all table on Upgrade! Use only during development. - * Convenience method using a {@link DevOpenHelper}. - */ - public static DaoSession newDevSession(Context context, String name) { - Database db = new DevOpenHelper(context, name).getWritableDb(); - DaoMaster daoMaster = new DaoMaster(db); - return daoMaster.newSession(); - } - - public DaoMaster(SQLiteDatabase db) { - this(new StandardDatabase(db)); - } - - public DaoMaster(Database db) { - super(db, SCHEMA_VERSION); - registerDaoClass(MarkerLocalBeanDao.class); - registerDaoClass(TaskLocalBeanDao.class); - registerDaoClass(TaskMarkerLocalBeanDao.class); - } - - public DaoSession newSession() { - return new DaoSession(db, IdentityScopeType.Session, daoConfigMap); - } - - public DaoSession newSession(IdentityScopeType type) { - return new DaoSession(db, type, daoConfigMap); - } - - /** - * Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} - - */ - public static abstract class OpenHelper extends DatabaseOpenHelper { - public OpenHelper(Context context, String name) { - super(context, name, SCHEMA_VERSION); - } - - public OpenHelper(Context context, String name, CursorFactory factory) { - super(context, name, factory, SCHEMA_VERSION); - } - - @Override - public void onCreate(Database db) { - Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION); - createAllTables(db, false); - } - } - - /** WARNING: Drops all table on Upgrade! Use only during development. */ - public static class DevOpenHelper extends OpenHelper { - public DevOpenHelper(Context context, String name) { - super(context, name); - } - - public DevOpenHelper(Context context, String name, CursorFactory factory) { - super(context, name, factory); - } - - @Override - public void onUpgrade(Database db, int oldVersion, int newVersion) { - Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables"); - dropAllTables(db, true); - onCreate(db); - } - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoSession.java b/app/src/main/java/com/casic/common/detector/gd/greendao/DaoSession.java deleted file mode 100644 index c8b1a20..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoSession.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import java.util.Map; - -import org.greenrobot.greendao.AbstractDao; -import org.greenrobot.greendao.AbstractDaoSession; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.identityscope.IdentityScopeType; -import org.greenrobot.greendao.internal.DaoConfig; - -import com.casic.common.detector.gd.bean.MarkerLocalBean; -import com.casic.common.detector.gd.bean.TaskLocalBean; -import com.casic.common.detector.gd.bean.TaskMarkerLocalBean; - -import com.casic.common.detector.gd.greendao.MarkerLocalBeanDao; -import com.casic.common.detector.gd.greendao.TaskLocalBeanDao; -import com.casic.common.detector.gd.greendao.TaskMarkerLocalBeanDao; - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. - -/** - * {@inheritDoc} - * - * @see org.greenrobot.greendao.AbstractDaoSession - */ -public class DaoSession extends AbstractDaoSession { - - private final DaoConfig markerLocalBeanDaoConfig; - private final DaoConfig taskLocalBeanDaoConfig; - private final DaoConfig taskMarkerLocalBeanDaoConfig; - - private final MarkerLocalBeanDao markerLocalBeanDao; - private final TaskLocalBeanDao taskLocalBeanDao; - private final TaskMarkerLocalBeanDao taskMarkerLocalBeanDao; - - public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> - daoConfigMap) { - super(db); - - markerLocalBeanDaoConfig = daoConfigMap.get(MarkerLocalBeanDao.class).clone(); - markerLocalBeanDaoConfig.initIdentityScope(type); - - taskLocalBeanDaoConfig = daoConfigMap.get(TaskLocalBeanDao.class).clone(); - taskLocalBeanDaoConfig.initIdentityScope(type); - - taskMarkerLocalBeanDaoConfig = daoConfigMap.get(TaskMarkerLocalBeanDao.class).clone(); - taskMarkerLocalBeanDaoConfig.initIdentityScope(type); - - markerLocalBeanDao = new MarkerLocalBeanDao(markerLocalBeanDaoConfig, this); - taskLocalBeanDao = new TaskLocalBeanDao(taskLocalBeanDaoConfig, this); - taskMarkerLocalBeanDao = new TaskMarkerLocalBeanDao(taskMarkerLocalBeanDaoConfig, this); - - registerDao(MarkerLocalBean.class, markerLocalBeanDao); - registerDao(TaskLocalBean.class, taskLocalBeanDao); - registerDao(TaskMarkerLocalBean.class, taskMarkerLocalBeanDao); - } - - public void clear() { - markerLocalBeanDaoConfig.clearIdentityScope(); - taskLocalBeanDaoConfig.clearIdentityScope(); - taskMarkerLocalBeanDaoConfig.clearIdentityScope(); - } - - public MarkerLocalBeanDao getMarkerLocalBeanDao() { - return markerLocalBeanDao; - } - - public TaskLocalBeanDao getTaskLocalBeanDao() { - return taskLocalBeanDao; - } - - public TaskMarkerLocalBeanDao getTaskMarkerLocalBeanDao() { - return taskMarkerLocalBeanDao; - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/MarkerLocalBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/greendao/MarkerLocalBeanDao.java deleted file mode 100644 index 2f792c3..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/MarkerLocalBeanDao.java +++ /dev/null @@ -1,479 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import android.database.Cursor; -import android.database.sqlite.SQLiteStatement; - -import org.greenrobot.greendao.AbstractDao; -import org.greenrobot.greendao.Property; -import org.greenrobot.greendao.internal.DaoConfig; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.database.DatabaseStatement; - -import com.casic.common.detector.gd.bean.MarkerLocalBean; - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** - * DAO for table "MARKER_LOCAL_BEAN". -*/ -public class MarkerLocalBeanDao extends AbstractDao { - - public static final String TABLENAME = "MARKER_LOCAL_BEAN"; - - /** - * Properties of entity MarkerLocalBean.
- * Can be used for QueryBuilder and for referencing column names. - */ - public static class Properties { - public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property PipelineType = new Property(1, String.class, "pipelineType", false, "PIPELINE_TYPE"); - public final static Property PipelineDiameter = new Property(2, String.class, "pipelineDiameter", false, "PIPELINE_DIAMETER"); - public final static Property PipelineMaterial = new Property(3, String.class, "pipelineMaterial", false, "PIPELINE_MATERIAL"); - public final static Property BuryMethod = new Property(4, String.class, "buryMethod", false, "BURY_METHOD"); - public final static Property BuryDepth = new Property(5, String.class, "buryDepth", false, "BURY_DEPTH"); - public final static Property Area = new Property(6, String.class, "area", false, "AREA"); - public final static Property Line = new Property(7, String.class, "line", false, "LINE"); - public final static Property Road = new Property(8, String.class, "road", false, "ROAD"); - public final static Property ConstructTime = new Property(9, String.class, "constructTime", false, "CONSTRUCT_TIME"); - public final static Property Owner = new Property(10, String.class, "owner", false, "OWNER"); - public final static Property ObjectId = new Property(11, String.class, "objectId", false, "OBJECT_ID"); - public final static Property MarkerId = new Property(12, String.class, "markerId", false, "MARKER_ID"); - public final static Property MarkerType = new Property(13, String.class, "markerType", false, "MARKER_TYPE"); - public final static Property MarkerDepth = new Property(14, String.class, "markerDepth", false, "MARKER_DEPTH"); - public final static Property InstallationDept = new Property(15, String.class, "installationDept", false, "INSTALLATION_DEPT"); - public final static Property Lng = new Property(16, String.class, "lng", false, "LNG"); - public final static Property Lat = new Property(17, String.class, "lat", false, "LAT"); - public final static Property UpdateTime = new Property(18, String.class, "updateTime", false, "UPDATE_TIME"); - public final static Property Remark = new Property(19, String.class, "remark", false, "REMARK"); - public final static Property UnderlyingPipelineType = new Property(20, String.class, "underlyingPipelineType", false, "UNDERLYING_PIPELINE_TYPE"); - public final static Property UnderlyingPipelineDepth = new Property(21, String.class, "underlyingPipelineDepth", false, "UNDERLYING_PIPELINE_DEPTH"); - public final static Property UnderlyingPipelineDiameter = new Property(22, String.class, "underlyingPipelineDiameter", false, "UNDERLYING_PIPELINE_DIAMETER"); - public final static Property UnderlyingPipelineMaterial = new Property(23, String.class, "underlyingPipelineMaterial", false, "UNDERLYING_PIPELINE_MATERIAL"); - public final static Property ObjectType = new Property(24, String.class, "objectType", false, "OBJECT_TYPE"); - public final static Property Color = new Property(25, String.class, "color", false, "COLOR"); - public final static Property ImagePath = new Property(26, String.class, "imagePath", false, "IMAGE_PATH"); - } - - - public MarkerLocalBeanDao(DaoConfig config) { - super(config); - } - - public MarkerLocalBeanDao(DaoConfig config, DaoSession daoSession) { - super(config, daoSession); - } - - /** Creates the underlying database table. */ - public static void createTable(Database db, boolean ifNotExists) { - String constraint = ifNotExists? "IF NOT EXISTS ": ""; - db.execSQL("CREATE TABLE " + constraint + "\"MARKER_LOCAL_BEAN\" (" + // - "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id - "\"PIPELINE_TYPE\" TEXT," + // 1: pipelineType - "\"PIPELINE_DIAMETER\" TEXT," + // 2: pipelineDiameter - "\"PIPELINE_MATERIAL\" TEXT," + // 3: pipelineMaterial - "\"BURY_METHOD\" TEXT," + // 4: buryMethod - "\"BURY_DEPTH\" TEXT," + // 5: buryDepth - "\"AREA\" TEXT," + // 6: area - "\"LINE\" TEXT," + // 7: line - "\"ROAD\" TEXT," + // 8: road - "\"CONSTRUCT_TIME\" TEXT," + // 9: constructTime - "\"OWNER\" TEXT," + // 10: owner - "\"OBJECT_ID\" TEXT," + // 11: objectId - "\"MARKER_ID\" TEXT," + // 12: markerId - "\"MARKER_TYPE\" TEXT," + // 13: markerType - "\"MARKER_DEPTH\" TEXT," + // 14: markerDepth - "\"INSTALLATION_DEPT\" TEXT," + // 15: installationDept - "\"LNG\" TEXT," + // 16: lng - "\"LAT\" TEXT," + // 17: lat - "\"UPDATE_TIME\" TEXT," + // 18: updateTime - "\"REMARK\" TEXT," + // 19: remark - "\"UNDERLYING_PIPELINE_TYPE\" TEXT," + // 20: underlyingPipelineType - "\"UNDERLYING_PIPELINE_DEPTH\" TEXT," + // 21: underlyingPipelineDepth - "\"UNDERLYING_PIPELINE_DIAMETER\" TEXT," + // 22: underlyingPipelineDiameter - "\"UNDERLYING_PIPELINE_MATERIAL\" TEXT," + // 23: underlyingPipelineMaterial - "\"OBJECT_TYPE\" TEXT," + // 24: objectType - "\"COLOR\" TEXT," + // 25: color - "\"IMAGE_PATH\" TEXT);"); // 26: imagePath - } - - /** Drops the underlying database table. */ - public static void dropTable(Database db, boolean ifExists) { - String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"MARKER_LOCAL_BEAN\""; - db.execSQL(sql); - } - - @Override - protected final void bindValues(DatabaseStatement stmt, MarkerLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String pipelineType = entity.getPipelineType(); - if (pipelineType != null) { - stmt.bindString(2, pipelineType); - } - - String pipelineDiameter = entity.getPipelineDiameter(); - if (pipelineDiameter != null) { - stmt.bindString(3, pipelineDiameter); - } - - String pipelineMaterial = entity.getPipelineMaterial(); - if (pipelineMaterial != null) { - stmt.bindString(4, pipelineMaterial); - } - - String buryMethod = entity.getBuryMethod(); - if (buryMethod != null) { - stmt.bindString(5, buryMethod); - } - - String buryDepth = entity.getBuryDepth(); - if (buryDepth != null) { - stmt.bindString(6, buryDepth); - } - - String area = entity.getArea(); - if (area != null) { - stmt.bindString(7, area); - } - - String line = entity.getLine(); - if (line != null) { - stmt.bindString(8, line); - } - - String road = entity.getRoad(); - if (road != null) { - stmt.bindString(9, road); - } - - String constructTime = entity.getConstructTime(); - if (constructTime != null) { - stmt.bindString(10, constructTime); - } - - String owner = entity.getOwner(); - if (owner != null) { - stmt.bindString(11, owner); - } - - String objectId = entity.getObjectId(); - if (objectId != null) { - stmt.bindString(12, objectId); - } - - String markerId = entity.getMarkerId(); - if (markerId != null) { - stmt.bindString(13, markerId); - } - - String markerType = entity.getMarkerType(); - if (markerType != null) { - stmt.bindString(14, markerType); - } - - String markerDepth = entity.getMarkerDepth(); - if (markerDepth != null) { - stmt.bindString(15, markerDepth); - } - - String installationDept = entity.getInstallationDept(); - if (installationDept != null) { - stmt.bindString(16, installationDept); - } - - String lng = entity.getLng(); - if (lng != null) { - stmt.bindString(17, lng); - } - - String lat = entity.getLat(); - if (lat != null) { - stmt.bindString(18, lat); - } - - String updateTime = entity.getUpdateTime(); - if (updateTime != null) { - stmt.bindString(19, updateTime); - } - - String remark = entity.getRemark(); - if (remark != null) { - stmt.bindString(20, remark); - } - - String underlyingPipelineType = entity.getUnderlyingPipelineType(); - if (underlyingPipelineType != null) { - stmt.bindString(21, underlyingPipelineType); - } - - String underlyingPipelineDepth = entity.getUnderlyingPipelineDepth(); - if (underlyingPipelineDepth != null) { - stmt.bindString(22, underlyingPipelineDepth); - } - - String underlyingPipelineDiameter = entity.getUnderlyingPipelineDiameter(); - if (underlyingPipelineDiameter != null) { - stmt.bindString(23, underlyingPipelineDiameter); - } - - String underlyingPipelineMaterial = entity.getUnderlyingPipelineMaterial(); - if (underlyingPipelineMaterial != null) { - stmt.bindString(24, underlyingPipelineMaterial); - } - - String objectType = entity.getObjectType(); - if (objectType != null) { - stmt.bindString(25, objectType); - } - - String color = entity.getColor(); - if (color != null) { - stmt.bindString(26, color); - } - - String imagePath = entity.getImagePath(); - if (imagePath != null) { - stmt.bindString(27, imagePath); - } - } - - @Override - protected final void bindValues(SQLiteStatement stmt, MarkerLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String pipelineType = entity.getPipelineType(); - if (pipelineType != null) { - stmt.bindString(2, pipelineType); - } - - String pipelineDiameter = entity.getPipelineDiameter(); - if (pipelineDiameter != null) { - stmt.bindString(3, pipelineDiameter); - } - - String pipelineMaterial = entity.getPipelineMaterial(); - if (pipelineMaterial != null) { - stmt.bindString(4, pipelineMaterial); - } - - String buryMethod = entity.getBuryMethod(); - if (buryMethod != null) { - stmt.bindString(5, buryMethod); - } - - String buryDepth = entity.getBuryDepth(); - if (buryDepth != null) { - stmt.bindString(6, buryDepth); - } - - String area = entity.getArea(); - if (area != null) { - stmt.bindString(7, area); - } - - String line = entity.getLine(); - if (line != null) { - stmt.bindString(8, line); - } - - String road = entity.getRoad(); - if (road != null) { - stmt.bindString(9, road); - } - - String constructTime = entity.getConstructTime(); - if (constructTime != null) { - stmt.bindString(10, constructTime); - } - - String owner = entity.getOwner(); - if (owner != null) { - stmt.bindString(11, owner); - } - - String objectId = entity.getObjectId(); - if (objectId != null) { - stmt.bindString(12, objectId); - } - - String markerId = entity.getMarkerId(); - if (markerId != null) { - stmt.bindString(13, markerId); - } - - String markerType = entity.getMarkerType(); - if (markerType != null) { - stmt.bindString(14, markerType); - } - - String markerDepth = entity.getMarkerDepth(); - if (markerDepth != null) { - stmt.bindString(15, markerDepth); - } - - String installationDept = entity.getInstallationDept(); - if (installationDept != null) { - stmt.bindString(16, installationDept); - } - - String lng = entity.getLng(); - if (lng != null) { - stmt.bindString(17, lng); - } - - String lat = entity.getLat(); - if (lat != null) { - stmt.bindString(18, lat); - } - - String updateTime = entity.getUpdateTime(); - if (updateTime != null) { - stmt.bindString(19, updateTime); - } - - String remark = entity.getRemark(); - if (remark != null) { - stmt.bindString(20, remark); - } - - String underlyingPipelineType = entity.getUnderlyingPipelineType(); - if (underlyingPipelineType != null) { - stmt.bindString(21, underlyingPipelineType); - } - - String underlyingPipelineDepth = entity.getUnderlyingPipelineDepth(); - if (underlyingPipelineDepth != null) { - stmt.bindString(22, underlyingPipelineDepth); - } - - String underlyingPipelineDiameter = entity.getUnderlyingPipelineDiameter(); - if (underlyingPipelineDiameter != null) { - stmt.bindString(23, underlyingPipelineDiameter); - } - - String underlyingPipelineMaterial = entity.getUnderlyingPipelineMaterial(); - if (underlyingPipelineMaterial != null) { - stmt.bindString(24, underlyingPipelineMaterial); - } - - String objectType = entity.getObjectType(); - if (objectType != null) { - stmt.bindString(25, objectType); - } - - String color = entity.getColor(); - if (color != null) { - stmt.bindString(26, color); - } - - String imagePath = entity.getImagePath(); - if (imagePath != null) { - stmt.bindString(27, imagePath); - } - } - - @Override - public Long readKey(Cursor cursor, int offset) { - return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); - } - - @Override - public MarkerLocalBean readEntity(Cursor cursor, int offset) { - MarkerLocalBean entity = new MarkerLocalBean( // - cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // pipelineType - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // pipelineDiameter - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // pipelineMaterial - cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // buryMethod - cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // buryDepth - cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // area - cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // line - cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // road - cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // constructTime - cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10), // owner - cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11), // objectId - cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12), // markerId - cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13), // markerType - cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14), // markerDepth - cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15), // installationDept - cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16), // lng - cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17), // lat - cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18), // updateTime - cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19), // remark - cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20), // underlyingPipelineType - cursor.isNull(offset + 21) ? null : cursor.getString(offset + 21), // underlyingPipelineDepth - cursor.isNull(offset + 22) ? null : cursor.getString(offset + 22), // underlyingPipelineDiameter - cursor.isNull(offset + 23) ? null : cursor.getString(offset + 23), // underlyingPipelineMaterial - cursor.isNull(offset + 24) ? null : cursor.getString(offset + 24), // objectType - cursor.isNull(offset + 25) ? null : cursor.getString(offset + 25), // color - cursor.isNull(offset + 26) ? null : cursor.getString(offset + 26) // imagePath - ); - return entity; - } - - @Override - public void readEntity(Cursor cursor, MarkerLocalBean entity, int offset) { - entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setPipelineType(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); - entity.setPipelineDiameter(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); - entity.setPipelineMaterial(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); - entity.setBuryMethod(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); - entity.setBuryDepth(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); - entity.setArea(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); - entity.setLine(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); - entity.setRoad(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); - entity.setConstructTime(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9)); - entity.setOwner(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); - entity.setObjectId(cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11)); - entity.setMarkerId(cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12)); - entity.setMarkerType(cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13)); - entity.setMarkerDepth(cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14)); - entity.setInstallationDept(cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15)); - entity.setLng(cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16)); - entity.setLat(cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17)); - entity.setUpdateTime(cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18)); - entity.setRemark(cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19)); - entity.setUnderlyingPipelineType(cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20)); - entity.setUnderlyingPipelineDepth(cursor.isNull(offset + 21) ? null : cursor.getString(offset + 21)); - entity.setUnderlyingPipelineDiameter(cursor.isNull(offset + 22) ? null : cursor.getString(offset + 22)); - entity.setUnderlyingPipelineMaterial(cursor.isNull(offset + 23) ? null : cursor.getString(offset + 23)); - entity.setObjectType(cursor.isNull(offset + 24) ? null : cursor.getString(offset + 24)); - entity.setColor(cursor.isNull(offset + 25) ? null : cursor.getString(offset + 25)); - entity.setImagePath(cursor.isNull(offset + 26) ? null : cursor.getString(offset + 26)); - } - - @Override - protected final Long updateKeyAfterInsert(MarkerLocalBean entity, long rowId) { - entity.setId(rowId); - return rowId; - } - - @Override - public Long getKey(MarkerLocalBean entity) { - if(entity != null) { - return entity.getId(); - } else { - return null; - } - } - - @Override - public boolean hasKey(MarkerLocalBean entity) { - return entity.getId() != null; - } - - @Override - protected final boolean isEntityUpdateable() { - return true; - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/TaskLocalBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/greendao/TaskLocalBeanDao.java deleted file mode 100644 index fb88157..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/TaskLocalBeanDao.java +++ /dev/null @@ -1,227 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import android.database.Cursor; -import android.database.sqlite.SQLiteStatement; - -import org.greenrobot.greendao.AbstractDao; -import org.greenrobot.greendao.Property; -import org.greenrobot.greendao.internal.DaoConfig; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.database.DatabaseStatement; - -import com.casic.common.detector.gd.bean.TaskLocalBean; - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** - * DAO for table "TASK_LOCAL_BEAN". -*/ -public class TaskLocalBeanDao extends AbstractDao { - - public static final String TABLENAME = "TASK_LOCAL_BEAN"; - - /** - * Properties of entity TaskLocalBean.
- * Can be used for QueryBuilder and for referencing column names. - */ - public static class Properties { - public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property TaskCode = new Property(1, String.class, "taskCode", false, "TASK_CODE"); - public final static Property Description = new Property(2, String.class, "description", false, "DESCRIPTION"); - public final static Property CreateTime = new Property(3, String.class, "createTime", false, "CREATE_TIME"); - public final static Property Status = new Property(4, String.class, "status", false, "STATUS"); - public final static Property CreateUserName = new Property(5, String.class, "createUserName", false, "CREATE_USER_NAME"); - public final static Property StartTime = new Property(6, String.class, "startTime", false, "START_TIME"); - public final static Property EndTime = new Property(7, String.class, "endTime", false, "END_TIME"); - public final static Property IsFreeTask = new Property(8, String.class, "isFreeTask", false, "IS_FREE_TASK"); - } - - - public TaskLocalBeanDao(DaoConfig config) { - super(config); - } - - public TaskLocalBeanDao(DaoConfig config, DaoSession daoSession) { - super(config, daoSession); - } - - /** Creates the underlying database table. */ - public static void createTable(Database db, boolean ifNotExists) { - String constraint = ifNotExists? "IF NOT EXISTS ": ""; - db.execSQL("CREATE TABLE " + constraint + "\"TASK_LOCAL_BEAN\" (" + // - "\"_id\" INTEGER PRIMARY KEY ," + // 0: id - "\"TASK_CODE\" TEXT," + // 1: taskCode - "\"DESCRIPTION\" TEXT," + // 2: description - "\"CREATE_TIME\" TEXT," + // 3: createTime - "\"STATUS\" TEXT," + // 4: status - "\"CREATE_USER_NAME\" TEXT," + // 5: createUserName - "\"START_TIME\" TEXT," + // 6: startTime - "\"END_TIME\" TEXT," + // 7: endTime - "\"IS_FREE_TASK\" TEXT);"); // 8: isFreeTask - } - - /** Drops the underlying database table. */ - public static void dropTable(Database db, boolean ifExists) { - String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"TASK_LOCAL_BEAN\""; - db.execSQL(sql); - } - - @Override - protected final void bindValues(DatabaseStatement stmt, TaskLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String taskCode = entity.getTaskCode(); - if (taskCode != null) { - stmt.bindString(2, taskCode); - } - - String description = entity.getDescription(); - if (description != null) { - stmt.bindString(3, description); - } - - String createTime = entity.getCreateTime(); - if (createTime != null) { - stmt.bindString(4, createTime); - } - - String status = entity.getStatus(); - if (status != null) { - stmt.bindString(5, status); - } - - String createUserName = entity.getCreateUserName(); - if (createUserName != null) { - stmt.bindString(6, createUserName); - } - - String startTime = entity.getStartTime(); - if (startTime != null) { - stmt.bindString(7, startTime); - } - - String endTime = entity.getEndTime(); - if (endTime != null) { - stmt.bindString(8, endTime); - } - - String isFreeTask = entity.getIsFreeTask(); - if (isFreeTask != null) { - stmt.bindString(9, isFreeTask); - } - } - - @Override - protected final void bindValues(SQLiteStatement stmt, TaskLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String taskCode = entity.getTaskCode(); - if (taskCode != null) { - stmt.bindString(2, taskCode); - } - - String description = entity.getDescription(); - if (description != null) { - stmt.bindString(3, description); - } - - String createTime = entity.getCreateTime(); - if (createTime != null) { - stmt.bindString(4, createTime); - } - - String status = entity.getStatus(); - if (status != null) { - stmt.bindString(5, status); - } - - String createUserName = entity.getCreateUserName(); - if (createUserName != null) { - stmt.bindString(6, createUserName); - } - - String startTime = entity.getStartTime(); - if (startTime != null) { - stmt.bindString(7, startTime); - } - - String endTime = entity.getEndTime(); - if (endTime != null) { - stmt.bindString(8, endTime); - } - - String isFreeTask = entity.getIsFreeTask(); - if (isFreeTask != null) { - stmt.bindString(9, isFreeTask); - } - } - - @Override - public Long readKey(Cursor cursor, int offset) { - return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); - } - - @Override - public TaskLocalBean readEntity(Cursor cursor, int offset) { - TaskLocalBean entity = new TaskLocalBean( // - cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // taskCode - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // description - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // createTime - cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // status - cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // createUserName - cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // startTime - cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // endTime - cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8) // isFreeTask - ); - return entity; - } - - @Override - public void readEntity(Cursor cursor, TaskLocalBean entity, int offset) { - entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setTaskCode(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); - entity.setDescription(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); - entity.setCreateTime(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); - entity.setStatus(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); - entity.setCreateUserName(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); - entity.setStartTime(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); - entity.setEndTime(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); - entity.setIsFreeTask(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); - } - - @Override - protected final Long updateKeyAfterInsert(TaskLocalBean entity, long rowId) { - entity.setId(rowId); - return rowId; - } - - @Override - public Long getKey(TaskLocalBean entity) { - if(entity != null) { - return entity.getId(); - } else { - return null; - } - } - - @Override - public boolean hasKey(TaskLocalBean entity) { - return entity.getId() != null; - } - - @Override - protected final boolean isEntityUpdateable() { - return true; - } - -} diff --git a/app/build.gradle b/app/build.gradle index d0cb423..921c8c8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,25 +1,20 @@ import java.text.SimpleDateFormat -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply plugin: 'org.greenrobot.greendao' +plugins { + id('com.android.application') + id('org.jetbrains.kotlin.android') +} android { - compileSdkVersion 33 + namespace 'com.casic.common.detector.gd' + compileSdk 35 defaultConfig { - applicationId "com.casic.common.detector.gd" - minSdkVersion 26 - targetSdkVersion 33 + applicationId 'com.casic.common.detector.gd' + minSdk 26 + targetSdk 35 versionCode 5092 - versionName "5.0.9.2" - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } + versionName '5.0.9.2' } signingConfigs { @@ -31,6 +26,14 @@ } } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + signingConfig signingConfigs.release + } + } + compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 @@ -47,27 +50,16 @@ } } - kotlin { - experimental { - coroutines 'enable' - } - } - buildFeatures { + buildConfig true viewBinding true } - applicationVariants.configureEach { variant -> - variant.outputs.configureEach { - outputFileName = "COM_TCY_" + getBuildDate() + "_" + defaultConfig.versionName + ".apk" + applicationVariants.configureEach { + outputs.configureEach { + outputFileName = 'COM_TCY_' + getBuildDate() + '_' + defaultConfig.versionName + '.apk' } } - - greendao { - schemaVersion 1//数据库版本号 - targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 - daoPackage "${defaultConfig.applicationId}.greendao"//设置DaoMaster、DaoSession、Dao包名 - } } static def getBuildDate() { @@ -76,27 +68,22 @@ } dependencies { - //基础依赖库 - implementation 'com.github.AndroidCoderPeng:Kotlin-lite-lib:1.1.4' - implementation 'androidx.core:core-ktx:1.9.0' - def base_version = "1.6.1" - implementation "androidx.appcompat:appcompat:${base_version}" - implementation "com.google.android.material:material:${base_version}" + implementation 'com.github.AndroidCoderPeng:Kotlin-lite-lib:1.1.5' + implementation 'androidx.core:core-ktx:1.13.1' + implementation 'androidx.appcompat:appcompat:1.7.0' + implementation 'com.google.android.material:material:1.12.0' //Google官方授权框架 implementation 'pub.devrel:easypermissions:3.0.0' - //沉浸式状态栏。基础依赖包,必须要依赖 - implementation 'com.gyf.immersionbar:immersionbar:3.0.0' - //fragment快速实现 - implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0' + //沉浸式状态栏 + implementation 'com.geyifeng.immersionbar:immersionbar:3.2.2' //官方Json解析库 implementation 'com.google.code.gson:gson:2.10.1' - def vm_version = '2.5.1' //Kotlin协程 - implementation "androidx.lifecycle:lifecycle-runtime-ktx:${vm_version}" + implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.2' //MVVM+LiveData - implementation "androidx.lifecycle:lifecycle-livedata-ktx:${vm_version}" - implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:${vm_version}" - implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.6.2' + implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2' + implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' //返回值转换器 implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' @@ -105,9 +92,10 @@ implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' //网络请求和接口封装 implementation 'com.squareup.retrofit2:retrofit:2.9.0' - implementation 'com.squareup.okhttp3:okhttp:4.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.12.0' //数据库框架 - implementation 'org.greenrobot:greendao:3.3.0' + implementation 'androidx.room:room-runtime:2.6.1' + annotationProcessor 'androidx.room:room-compiler:2.5.2' //高德导航、定位、地图三合一 implementation 'com.amap.api:navi-3dmap:latest.integration' //经纬度逆编码 @@ -115,7 +103,7 @@ //excel implementation 'net.sourceforge.jexcelapi:jxl:2.6.12' //图片加载框架 - implementation 'com.github.bumptech.glide:glide:4.9.0' + implementation 'com.github.bumptech.glide:glide:4.12.0' //图片选择框架 implementation 'io.github.lucksiege:pictureselector:v3.11.1' //大图 diff --git a/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt b/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt index 7b695ff..50ba734 100644 --- a/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt +++ b/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt @@ -4,9 +4,9 @@ import android.app.Application import android.os.Bundle import android.util.Log -import com.casic.common.detector.gd.greendao.DaoMaster -import com.casic.common.detector.gd.greendao.DaoSession +import androidx.room.Room.databaseBuilder import com.casic.common.detector.gd.uart.SerialPort +import com.casic.common.detector.gd.utils.DetectorDataBase import com.casic.common.detector.gd.utils.GpioManager import com.pengxh.kt.lite.extensions.show import com.pengxh.kt.lite.utils.SaveKeyValues @@ -43,44 +43,42 @@ private var application: BaseApplication by Delegates.notNull() fun get() = application - - private lateinit var daoSession: DaoSession } + lateinit var dataBase: DetectorDataBase + override fun onCreate() { super.onCreate() application = this SaveKeyValues.initSharedPreferences(this) CrashReport.initCrashReport(this, "01e80d3a74", true) - val devOpenHelper = DaoMaster.DevOpenHelper(this, "Detector.db", null) - val daoMaster = DaoMaster(devOpenHelper.writableDatabase) - daoSession = daoMaster.newSession() + dataBase = databaseBuilder(this, DetectorDataBase::class.java, "Detector.db") + .allowMainThreadQueries() + .build() /** * Open the serial port * */ try { serialPorts.apply { - add(SerialPort(File("/dev/ttysWK1"), 9600, 0)) - //千寻报文数据下发串口号 - add(SerialPort(File("/dev/ttyS1"), 9600, 0)) + add(SerialPort(File("/dev/ttysWK1"), 9600, 0)) //信号通讯串口 + add(SerialPort(File("/dev/ttyS1"), 9600, 0)) //千寻报文数据下发串口号 } Log.d(kTag, "onCreate: 已初始化 ${serialPorts.size} 个串口") } catch (e: SecurityException) { "您没有串口的读写权限!".show(this) + e.printStackTrace() } catch (e: IOException) { "因为不明原因,串口无法打开!".show(this) + e.printStackTrace() } catch (e: InvalidParameterException) { "请检查串口!".show(this) + e.printStackTrace() } registerActivityLifecycleCallbacks(this) } - fun getDaoSession(): DaoSession { - return daoSession - } - override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) { } diff --git a/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt b/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt index 053b9dd..1d0c9e3 100644 --- a/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt +++ b/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt @@ -14,12 +14,10 @@ import com.casic.common.detector.gd.utils.SerialPortCommand import com.pengxh.kt.lite.utils.WeakReferenceHandler import java.io.IOException -import java.util.Timer abstract class SerialPortBaseActivity : AppCompatActivity(), Handler.Callback { private val kTag = "SerialPortBaseActivity" - private val taskTimer by lazy { Timer() } private val weakReferenceHandler by lazy { WeakReferenceHandler(this) } private val serialPorts by lazy { BaseApplication.get().getSerialPorts() } protected lateinit var binding: VB @@ -30,7 +28,6 @@ setContentView(binding.root) setupTopBarLayout() initOnCreate(savedInstanceState) - observeRequestState() initEvent() if (serialPorts.isNotEmpty()) { @@ -71,11 +68,6 @@ abstract fun initOnCreate(savedInstanceState: Bundle?) /** - * 数据请求状态监听 - */ - abstract fun observeRequestState() - - /** * 初始化业务逻辑 */ abstract fun initEvent() diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java new file mode 100644 index 0000000..7a18c20 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java @@ -0,0 +1,255 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 从平台下载的标识器本地库实体类 + */ +@Entity(tableName = "marker_detail") +public class MarkerBean { + @PrimaryKey(autoGenerate = true) + private long id; //主键ID + private String pipelineType; // 管线类型 + private String pipelineDiameter; // 管线直径 + private String pipelineMaterial; // 管材 + private String buryMethod; // 埋设方式 + private String buryDepth; // 埋深 + private String area; // 所属区域 + private String line; // 所属线路 + private String road; // 所属道路 + private String constructTime; // 建设年代 + private String owner; // 权属单位 + private String objectId; // 标识对象ID,无实际用途 + private String markerId; // 标识器ID + private String markerType; // 标识器类型 + private String markerDepth; // 标识器埋深 + private String installationDept; // 安装部门 + private String lng; // 经度 + private String lat; // 纬度 + private String updateTime; // 最后修改时间,更新时间 + private String remark; // 备注信息 + private String underlyingPipelineType; // 下层管线类型 + private String underlyingPipelineDepth; // 下层埋深 + private String underlyingPipelineDiameter; // 下层管径 + private String underlyingPipelineMaterial; // 下层管材 + private String objectType; //标识对象类型 + private String color; // 颜色 + private String imagePath; // 图片路径 + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getPipelineType() { + return pipelineType; + } + + public void setPipelineType(String pipelineType) { + this.pipelineType = pipelineType; + } + + public String getPipelineDiameter() { + return pipelineDiameter; + } + + public void setPipelineDiameter(String pipelineDiameter) { + this.pipelineDiameter = pipelineDiameter; + } + + public String getPipelineMaterial() { + return pipelineMaterial; + } + + public void setPipelineMaterial(String pipelineMaterial) { + this.pipelineMaterial = pipelineMaterial; + } + + public String getBuryMethod() { + return buryMethod; + } + + public void setBuryMethod(String buryMethod) { + this.buryMethod = buryMethod; + } + + public String getBuryDepth() { + return buryDepth; + } + + public void setBuryDepth(String buryDepth) { + this.buryDepth = buryDepth; + } + + public String getArea() { + return area; + } + + public void setArea(String area) { + this.area = area; + } + + public String getLine() { + return line; + } + + public void setLine(String line) { + this.line = line; + } + + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + + public String getConstructTime() { + return constructTime; + } + + public void setConstructTime(String constructTime) { + this.constructTime = constructTime; + } + + public String getOwner() { + return owner; + } + + public void setOwner(String owner) { + this.owner = owner; + } + + public String getObjectId() { + return objectId; + } + + public void setObjectId(String objectId) { + this.objectId = objectId; + } + + public String getMarkerId() { + return markerId; + } + + public void setMarkerId(String markerId) { + this.markerId = markerId; + } + + public String getMarkerType() { + return markerType; + } + + public void setMarkerType(String markerType) { + this.markerType = markerType; + } + + public String getMarkerDepth() { + return markerDepth; + } + + public void setMarkerDepth(String markerDepth) { + this.markerDepth = markerDepth; + } + + public String getInstallationDept() { + return installationDept; + } + + public void setInstallationDept(String installationDept) { + this.installationDept = installationDept; + } + + public String getLng() { + return lng; + } + + public void setLng(String lng) { + this.lng = lng; + } + + public String getLat() { + return lat; + } + + public void setLat(String lat) { + this.lat = lat; + } + + public String getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } + + public String getUnderlyingPipelineType() { + return underlyingPipelineType; + } + + public void setUnderlyingPipelineType(String underlyingPipelineType) { + this.underlyingPipelineType = underlyingPipelineType; + } + + public String getUnderlyingPipelineDepth() { + return underlyingPipelineDepth; + } + + public void setUnderlyingPipelineDepth(String underlyingPipelineDepth) { + this.underlyingPipelineDepth = underlyingPipelineDepth; + } + + public String getUnderlyingPipelineDiameter() { + return underlyingPipelineDiameter; + } + + public void setUnderlyingPipelineDiameter(String underlyingPipelineDiameter) { + this.underlyingPipelineDiameter = underlyingPipelineDiameter; + } + + public String getUnderlyingPipelineMaterial() { + return underlyingPipelineMaterial; + } + + public void setUnderlyingPipelineMaterial(String underlyingPipelineMaterial) { + this.underlyingPipelineMaterial = underlyingPipelineMaterial; + } + + public String getObjectType() { + return objectType; + } + + public void setObjectType(String objectType) { + this.objectType = objectType; + } + + public String getColor() { + return color; + } + + public void setColor(String color) { + this.color = color; + } + + public String getImagePath() { + return imagePath; + } + + public void setImagePath(String imagePath) { + this.imagePath = imagePath; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java deleted file mode 100644 index 3f2fcdc..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java +++ /dev/null @@ -1,327 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 从平台下载的标识器本地库实体类 - */ -@Entity -public class MarkerLocalBean { - @Id(autoincrement = true) - private Long id;//本地库主键ID - - // 管线类型 - private String pipelineType; - // 管线直径 - private String pipelineDiameter; - // 管材 - private String pipelineMaterial; - // 埋设方式 - private String buryMethod; - // 埋深 - private String buryDepth; - // 所属区域 - private String area; - // 所属线路 - private String line; - // 所属道路 - private String road; - // 建设年代 - private String constructTime; - // 权属单位 - private String owner; - //标识对象ID,无实际用途 - @Deprecated - private String objectId; - // 标识器ID - private String markerId; - // 标识器类型 - private String markerType; - // 标识器埋深 - private String markerDepth; - // 安装部门 - private String installationDept; - // 经度 - private String lng; - // 纬度 - private String lat; - //最后修改时间,更新时间 - private String updateTime; - // 备注信息 - private String remark; - // 下层管线类型 - private String underlyingPipelineType; - // 下层埋深 - private String underlyingPipelineDepth; - // 下层管径 - private String underlyingPipelineDiameter; - // 下层管材 - private String underlyingPipelineMaterial; - //标识对象类型 - private String objectType; - // 颜色 - private String color; - // 图片路径 - private String imagePath; - - @Generated(hash = 1479045776) - public MarkerLocalBean(Long id, String pipelineType, String pipelineDiameter, - String pipelineMaterial, String buryMethod, String buryDepth, - String area, String line, String road, String constructTime, - String owner, String objectId, String markerId, String markerType, - String markerDepth, String installationDept, String lng, String lat, - String updateTime, String remark, String underlyingPipelineType, - String underlyingPipelineDepth, String underlyingPipelineDiameter, - String underlyingPipelineMaterial, String objectType, String color, - String imagePath) { - this.id = id; - this.pipelineType = pipelineType; - this.pipelineDiameter = pipelineDiameter; - this.pipelineMaterial = pipelineMaterial; - this.buryMethod = buryMethod; - this.buryDepth = buryDepth; - this.area = area; - this.line = line; - this.road = road; - this.constructTime = constructTime; - this.owner = owner; - this.objectId = objectId; - this.markerId = markerId; - this.markerType = markerType; - this.markerDepth = markerDepth; - this.installationDept = installationDept; - this.lng = lng; - this.lat = lat; - this.updateTime = updateTime; - this.remark = remark; - this.underlyingPipelineType = underlyingPipelineType; - this.underlyingPipelineDepth = underlyingPipelineDepth; - this.underlyingPipelineDiameter = underlyingPipelineDiameter; - this.underlyingPipelineMaterial = underlyingPipelineMaterial; - this.objectType = objectType; - this.color = color; - this.imagePath = imagePath; - } - - @Generated(hash = 1538606012) - public MarkerLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getPipelineType() { - return this.pipelineType; - } - - public void setPipelineType(String pipelineType) { - this.pipelineType = pipelineType; - } - - public String getPipelineDiameter() { - return this.pipelineDiameter; - } - - public void setPipelineDiameter(String pipelineDiameter) { - this.pipelineDiameter = pipelineDiameter; - } - - public String getPipelineMaterial() { - return this.pipelineMaterial; - } - - public void setPipelineMaterial(String pipelineMaterial) { - this.pipelineMaterial = pipelineMaterial; - } - - public String getBuryMethod() { - return this.buryMethod; - } - - public void setBuryMethod(String buryMethod) { - this.buryMethod = buryMethod; - } - - public String getBuryDepth() { - return this.buryDepth; - } - - public void setBuryDepth(String buryDepth) { - this.buryDepth = buryDepth; - } - - public String getArea() { - return this.area; - } - - public void setArea(String area) { - this.area = area; - } - - public String getLine() { - return this.line; - } - - public void setLine(String line) { - this.line = line; - } - - public String getRoad() { - return this.road; - } - - public void setRoad(String road) { - this.road = road; - } - - public String getConstructTime() { - return this.constructTime; - } - - public void setConstructTime(String constructTime) { - this.constructTime = constructTime; - } - - public String getOwner() { - return this.owner; - } - - public void setOwner(String owner) { - this.owner = owner; - } - - public String getObjectId() { - return this.objectId; - } - - public void setObjectId(String objectId) { - this.objectId = objectId; - } - - public String getMarkerId() { - return this.markerId; - } - - public void setMarkerId(String markerId) { - this.markerId = markerId; - } - - public String getMarkerType() { - return this.markerType; - } - - public void setMarkerType(String markerType) { - this.markerType = markerType; - } - - public String getMarkerDepth() { - return this.markerDepth; - } - - public void setMarkerDepth(String markerDepth) { - this.markerDepth = markerDepth; - } - - public String getInstallationDept() { - return this.installationDept; - } - - public void setInstallationDept(String installationDept) { - this.installationDept = installationDept; - } - - public String getLng() { - return this.lng; - } - - public void setLng(String lng) { - this.lng = lng; - } - - public String getLat() { - return this.lat; - } - - public void setLat(String lat) { - this.lat = lat; - } - - public String getUpdateTime() { - return this.updateTime; - } - - public void setUpdateTime(String updateTime) { - this.updateTime = updateTime; - } - - public String getRemark() { - return this.remark; - } - - public void setRemark(String remark) { - this.remark = remark; - } - - public String getUnderlyingPipelineType() { - return this.underlyingPipelineType; - } - - public void setUnderlyingPipelineType(String underlyingPipelineType) { - this.underlyingPipelineType = underlyingPipelineType; - } - - public String getUnderlyingPipelineDepth() { - return this.underlyingPipelineDepth; - } - - public void setUnderlyingPipelineDepth(String underlyingPipelineDepth) { - this.underlyingPipelineDepth = underlyingPipelineDepth; - } - - public String getUnderlyingPipelineDiameter() { - return this.underlyingPipelineDiameter; - } - - public void setUnderlyingPipelineDiameter(String underlyingPipelineDiameter) { - this.underlyingPipelineDiameter = underlyingPipelineDiameter; - } - - public String getUnderlyingPipelineMaterial() { - return this.underlyingPipelineMaterial; - } - - public void setUnderlyingPipelineMaterial(String underlyingPipelineMaterial) { - this.underlyingPipelineMaterial = underlyingPipelineMaterial; - } - - public String getObjectType() { - return this.objectType; - } - - public void setObjectType(String objectType) { - this.objectType = objectType; - } - - public String getColor() { - return this.color; - } - - public void setColor(String color) { - this.color = color; - } - - public String getImagePath() { - return this.imagePath; - } - - public void setImagePath(String imagePath) { - this.imagePath = imagePath; - } -} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java new file mode 100644 index 0000000..5c88fdf --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java @@ -0,0 +1,93 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 巡检任务本地库实体类,不包含任务里面需要巡检的标识器信息 + */ +@Entity(tableName = "task_detail") +public class TaskBean { + @PrimaryKey(autoGenerate = true) + private long id;//主键ID + private String taskCode; // 任务编号 + private String description; // 任务名称 + private String createTime; // 任务创建的时间 + private String status; // 任务状态 + private String createUserName; // 任务创建者名称 + private String startTime; // 任务被开始执行的时间 + private String endTime; // 任务执行结束的时间 + private String isFree; // 是否自由巡检。1-是,0-否 + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getTaskCode() { + return taskCode; + } + + public void setTaskCode(String taskCode) { + this.taskCode = taskCode; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getCreateUserName() { + return createUserName; + } + + public void setCreateUserName(String createUserName) { + this.createUserName = createUserName; + } + + public String getStartTime() { + return startTime; + } + + public void setStartTime(String startTime) { + this.startTime = startTime; + } + + public String getEndTime() { + return endTime; + } + + public void setEndTime(String endTime) { + this.endTime = endTime; + } + + public String getIsFree() { + return isFree; + } + + public void setIsFree(String isFree) { + this.isFree = isFree; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java deleted file mode 100644 index 91737b3..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java +++ /dev/null @@ -1,114 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 巡检任务本地库实体类,不包含任务里面需要巡检的标识器信息 - */ -@Entity -public class TaskLocalBean { - @Id - private Long id;//任务ID - - private String taskCode;//任务编号 - private String description;//任务名称 - private String createTime;//任务创建的时间 - private String status;//任务状态 - private String createUserName;//任务创建者名称 - private String startTime;//任务被开始执行的时间 - private String endTime;//任务执行结束的时间 - private String isFreeTask;//是否自由巡检。1-是,0-否 - - @Generated(hash = 1482022528) - public TaskLocalBean(Long id, String taskCode, String description, - String createTime, String status, String createUserName, - String startTime, String endTime, String isFreeTask) { - this.id = id; - this.taskCode = taskCode; - this.description = description; - this.createTime = createTime; - this.status = status; - this.createUserName = createUserName; - this.startTime = startTime; - this.endTime = endTime; - this.isFreeTask = isFreeTask; - } - - @Generated(hash = 949704588) - public TaskLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getTaskCode() { - return this.taskCode; - } - - public void setTaskCode(String taskCode) { - this.taskCode = taskCode; - } - - public String getDescription() { - return this.description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getCreateTime() { - return this.createTime; - } - - public void setCreateTime(String createTime) { - this.createTime = createTime; - } - - public String getStatus() { - return this.status; - } - - public void setStatus(String status) { - this.status = status; - } - - public String getCreateUserName() { - return this.createUserName; - } - - public void setCreateUserName(String createUserName) { - this.createUserName = createUserName; - } - - public String getStartTime() { - return this.startTime; - } - - public void setStartTime(String startTime) { - this.startTime = startTime; - } - - public String getEndTime() { - return this.endTime; - } - - public void setEndTime(String endTime) { - this.endTime = endTime; - } - - public String getIsFreeTask() { - return this.isFreeTask; - } - - public void setIsFreeTask(String isFreeTask) { - this.isFreeTask = isFreeTask; - } -} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerBean.java new file mode 100644 index 0000000..c563a60 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerBean.java @@ -0,0 +1,110 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 巡检任务里面需要巡检的标识器信息本地库实体类 + */ +@Entity(tableName = "task_marker_info") +public class TaskMarkerBean { + //标识器后台库的主键ID,不是标识器实际ID + @PrimaryKey(autoGenerate = true) + private long id; + + /** + * 任务ID,通过此字段关联[TaskBean.id] + */ + private String taskId; + + /** + * 任务Code,通过此字段关联[TaskBean.taskCode] + *

+ *

+ * 双重验证,防止出现同时刻重复的情况 + */ + private String taskCode; + + /** + * 对应后台字段[TaskModel.MessageModel.TaskDetailInfosModel.markerIdReal],也就是探测仪扫描出来的ID + */ + private String markerId; + + private Double lng; + private Double lat; + + /** + * 是否已被探测到 + * 1-是,0-否 + */ + private String isDetected; + + /** + * 被探测到的时间,对应后台字段[TaskModel.MessageModel.TaskDetailInfosModel.finishTime] + */ + private String detectedTime; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getTaskId() { + return taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getTaskCode() { + return taskCode; + } + + public void setTaskCode(String taskCode) { + this.taskCode = taskCode; + } + + public String getMarkerId() { + return markerId; + } + + public void setMarkerId(String markerId) { + this.markerId = markerId; + } + + public Double getLng() { + return lng; + } + + public void setLng(Double lng) { + this.lng = lng; + } + + public Double getLat() { + return lat; + } + + public void setLat(Double lat) { + this.lat = lat; + } + + public String getIsDetected() { + return isDetected; + } + + public void setIsDetected(String isDetected) { + this.isDetected = isDetected; + } + + public String getDetectedTime() { + return detectedTime; + } + + public void setDetectedTime(String detectedTime) { + this.detectedTime = detectedTime; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerLocalBean.java deleted file mode 100644 index de9f459..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerLocalBean.java +++ /dev/null @@ -1,128 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import com.casic.common.detector.gd.model.TaskModel; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 巡检任务里面需要巡检的标识器信息本地库实体类 - */ -@Entity -public class TaskMarkerLocalBean { - @Id - private Long id;//标识器后台库的主键ID,不是标识器实际ID - - /** - * 任务ID,通过此字段关联{@link TaskLocalBean#id} - */ - private String taskId; - - /** - * 任务Code,通过此字段关联{@link TaskLocalBean#taskCode} - *

- * 双重验证,防止出现同时刻重复的情况 - */ - private String taskCode; - - /** - * 对应后台字段{@link TaskModel.MessageModel.TaskDetailInfosModel#markerIdReal},也就是探测仪扫描出来的ID - */ - private String markerId; - - private double lng; - private double lat; - - /** - * 是否已被探测到 - * 1-是,0-否 - */ - private String isDetected; - - /** - * 被探测到的时间,对应后台字段{@link TaskModel.MessageModel.TaskDetailInfosModel#finishTime} - */ - private String detectedTime; - - @Generated(hash = 677328533) - public TaskMarkerLocalBean(Long id, String taskId, String taskCode, String markerId, - double lng, double lat, String isDetected, String detectedTime) { - this.id = id; - this.taskId = taskId; - this.taskCode = taskCode; - this.markerId = markerId; - this.lng = lng; - this.lat = lat; - this.isDetected = isDetected; - this.detectedTime = detectedTime; - } - - @Generated(hash = 1162404642) - public TaskMarkerLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getTaskId() { - return this.taskId; - } - - public void setTaskId(String taskId) { - this.taskId = taskId; - } - - public String getTaskCode() { - return this.taskCode; - } - - public void setTaskCode(String taskCode) { - this.taskCode = taskCode; - } - - public String getMarkerId() { - return this.markerId; - } - - public void setMarkerId(String markerId) { - this.markerId = markerId; - } - - public double getLng() { - return this.lng; - } - - public void setLng(double lng) { - this.lng = lng; - } - - public double getLat() { - return this.lat; - } - - public void setLat(double lat) { - this.lat = lat; - } - - public String getIsDetected() { - return this.isDetected; - } - - public void setIsDetected(String isDetected) { - this.isDetected = isDetected; - } - - public String getDetectedTime() { - return this.detectedTime; - } - - public void setDetectedTime(String detectedTime) { - this.detectedTime = detectedTime; - } -} diff --git a/app/src/main/java/com/casic/common/detector/gd/dao/MarkerBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/dao/MarkerBeanDao.java new file mode 100644 index 0000000..2beb7ed --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/dao/MarkerBeanDao.java @@ -0,0 +1,29 @@ +package com.casic.common.detector.gd.dao; + +import androidx.room.Dao; +import androidx.room.Insert; +import androidx.room.Query; +import androidx.room.RawQuery; +import androidx.sqlite.db.SupportSQLiteQuery; + +import com.casic.common.detector.gd.bean.MarkerBean; + +import java.util.List; + +@Dao +public interface MarkerBeanDao { + @Query("DELETE FROM marker_detail") + void deleteAll(); + + @Insert + void insert(MarkerBean marker); + + @Query("SELECT * FROM marker_detail") + List loadAll(); + + @Query("SELECT * FROM marker_detail WHERE markerId = :markerId") + List queryMarkerById(String markerId); + + @RawQuery + List loadMarkersByCondition(SupportSQLiteQuery query); +} diff --git a/app/src/main/java/com/casic/common/detector/gd/dao/TaskBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/dao/TaskBeanDao.java new file mode 100644 index 0000000..9c70ac2 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/dao/TaskBeanDao.java @@ -0,0 +1,120 @@ +package com.casic.common.detector.gd.dao; + +import androidx.room.Dao; +import androidx.room.Insert; +import androidx.room.Query; +import androidx.room.Transaction; + +import com.casic.common.detector.gd.bean.TaskBean; +import com.casic.common.detector.gd.bean.TaskMarkerBean; +import com.casic.common.detector.gd.model.TaskDetailLocalModel; +import com.casic.common.detector.gd.model.TaskModel; +import com.casic.common.detector.gd.utils.LocaleConstant; +import com.pengxh.kt.lite.utils.SaveKeyValues; + +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Locale; + +@Dao +public interface TaskBeanDao { + @Query("SELECT COUNT(*) FROM task_detail WHERE id = :taskId") + int isTaskExist(long taskId); + + @Insert + void insert(TaskBean task); + + default void saveTask(Long taskId, String taskName) { + if (isTaskExist(taskId) == 0) { + TaskBean task = new TaskBean(); + task.setId(taskId); + task.setTaskCode(new SimpleDateFormat("yyyyMMddHHmmss", Locale.CHINA).format(new Date())); + task.setDescription(taskName); + String time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA).format(new Date()); + task.setCreateTime(time); + task.setStatus("0"); + String userName = (String) SaveKeyValues.INSTANCE.getValue(LocaleConstant.USER_NAME, ""); + task.setCreateUserName(userName); + task.setStartTime(time); + task.setEndTime(""); + task.setIsFree("1"); + insert(task); + } + } + + default void saveTask(TaskModel.MessageModel model) { + TaskBean task = new TaskBean(); + task.setId(model.getId()); + task.setTaskCode(model.getTaskCode()); + task.setDescription(model.getDescription()); + task.setCreateTime(model.getDeployDate()); + task.setStatus(model.getStatus()); + task.setCreateUserName(model.getCreatorName()); + task.setStartTime(model.getBeginDate()); + task.setEndTime(model.getEndDate()); + task.setIsFree("0"); + if (isTaskExist(task.getId()) == 0) { + insert(task); + } + } + + @Query("SELECT * FROM task_detail") + List loadAll(); + + @Transaction + default ArrayList loadLocalTask(TaskMarkerBeanDao taskMarkerBeanDao) { + ArrayList result = new ArrayList<>(); + List tasks = loadAll(); + for (TaskBean it : tasks) { + TaskDetailLocalModel model = new TaskDetailLocalModel(); + model.setTaskId(String.valueOf(it.getId())); + model.setTaskCode(it.getTaskCode()); + model.setDescription(it.getDescription()); + model.setCreateTime(it.getCreateTime()); + model.setStatus(it.getStatus()); + model.setCreateUserName(it.getCreateUserName()); + model.setIsFreeTask(it.getIsFree()); + ArrayList results = new ArrayList<>(); + if ("0".equals(it.getIsFree())) { + // 非自由巡检才有Marker + List markers = taskMarkerBeanDao.getMarkersByIdAndCode(String.valueOf(it.getId()), it.getTaskCode()); + for (TaskMarkerBean marker : markers) { + TaskDetailLocalModel.TaskMarkerLocalModel localModel = new TaskDetailLocalModel.TaskMarkerLocalModel(); + localModel.setMarkerId(marker.getMarkerId()); + localModel.setLng(marker.getLng()); + localModel.setLat(marker.getLat()); + localModel.setIsDetected(marker.getIsDetected()); + localModel.setDetectedTime(marker.getDetectedTime()); + + results.add(localModel); + } + } + model.setMarkerModels(results); + result.add(model); + } + return result; + } + + @Query("DELETE FROM task_detail WHERE id = :taskId AND taskCode = :taskCode") + void deleteTaskById(long taskId, String taskCode); + + @Transaction + default void deleteLocalTaskById(long taskId, String taskCode, TaskMarkerBeanDao taskMarkerBeanDao) { + TaskBean task = loadAll().stream() + .filter(it -> it.getId() == taskId && taskCode.equals(it.getTaskCode())) + .findFirst() + .orElse(null); + if (task == null) return; + deleteTaskById(taskId, taskCode); + + // 删除此任务关联的Marker。非自由巡检才有Marker + if ("0".equals(task.getIsFree())) { + List markers = taskMarkerBeanDao.getMarkersByIdAndCode(String.valueOf(task.getId()), task.getTaskCode()); + for (TaskMarkerBean marker : markers) { + taskMarkerBeanDao.delete(marker); + } + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/dao/TaskMarkerBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/dao/TaskMarkerBeanDao.java new file mode 100644 index 0000000..cc2156a --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/dao/TaskMarkerBeanDao.java @@ -0,0 +1,52 @@ +package com.casic.common.detector.gd.dao; + +import androidx.room.Dao; +import androidx.room.Delete; +import androidx.room.Insert; +import androidx.room.Query; +import androidx.room.Update; + +import com.casic.common.detector.gd.bean.TaskMarkerBean; +import com.casic.common.detector.gd.model.TaskModel; + +import java.util.List; + +@Dao +public interface TaskMarkerBeanDao { + + @Insert + void insert(TaskMarkerBean marker); + + @Query("SELECT COUNT(*) FROM task_marker_info WHERE id = :markerId") + int isMarkerExist(String markerId); + + default void saveTaskMarker(long taskId, String taskCode, TaskModel.MessageModel.TaskDetailInfosModel marker) { + if (isMarkerExist(marker.getMarkerId()) == 0) { + TaskMarkerBean bean = new TaskMarkerBean(); + bean.setId(marker.getId()); + bean.setTaskId(String.valueOf(taskId)); + bean.setTaskCode(taskCode); + bean.setMarkerId(marker.getMarkerIdReal()); + bean.setLng(marker.getLongitude()); + bean.setLat(marker.getLatitude()); + bean.setIsDetected("0"); + bean.setDetectedTime(""); + insert(bean); + } + } + + @Query("SELECT * FROM task_marker_info WHERE taskId = :taskId AND taskCode = :taskCode AND markerId = :markerId AND isDetected = :state") + TaskMarkerBean queryTaskMarkerById(String taskId, String taskCode, String markerId, String state); + + @Update + void updateLocalTaskMarkerState(TaskMarkerBean marker); + + @Query("SELECT * FROM task_marker_info WHERE isDetected = :state") + List queryMarkerByState(String state); + + @Query("SELECT * FROM task_marker_info WHERE taskId = :taskId AND taskCode = :taskCode") + List getMarkersByIdAndCode(String taskId, String taskCode); + + @Delete + void delete(TaskMarkerBean marker); +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/extensions/Long.kt b/app/src/main/java/com/casic/common/detector/gd/extensions/Long.kt deleted file mode 100644 index 6713d8d..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/extensions/Long.kt +++ /dev/null @@ -1,10 +0,0 @@ -package com.casic.common.detector.gd.extensions - -import java.text.SimpleDateFormat -import java.util.Date -import java.util.Locale - -fun Long.createTaskCode(): String { - val dateFormat = SimpleDateFormat("yyyyMMddHHmmss", Locale.CHINA) - return dateFormat.format(Date(this)) -} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoMaster.java b/app/src/main/java/com/casic/common/detector/gd/greendao/DaoMaster.java deleted file mode 100644 index 6ab94b3..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoMaster.java +++ /dev/null @@ -1,102 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import android.content.Context; -import android.database.sqlite.SQLiteDatabase; -import android.database.sqlite.SQLiteDatabase.CursorFactory; -import android.util.Log; - -import org.greenrobot.greendao.AbstractDaoMaster; -import org.greenrobot.greendao.database.StandardDatabase; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.database.DatabaseOpenHelper; -import org.greenrobot.greendao.identityscope.IdentityScopeType; - - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** - * Master of DAO (schema version 1): knows all DAOs. - */ -public class DaoMaster extends AbstractDaoMaster { - public static final int SCHEMA_VERSION = 1; - - /** Creates underlying database table using DAOs. */ - public static void createAllTables(Database db, boolean ifNotExists) { - MarkerLocalBeanDao.createTable(db, ifNotExists); - TaskLocalBeanDao.createTable(db, ifNotExists); - TaskMarkerLocalBeanDao.createTable(db, ifNotExists); - } - - /** Drops underlying database table using DAOs. */ - public static void dropAllTables(Database db, boolean ifExists) { - MarkerLocalBeanDao.dropTable(db, ifExists); - TaskLocalBeanDao.dropTable(db, ifExists); - TaskMarkerLocalBeanDao.dropTable(db, ifExists); - } - - /** - * WARNING: Drops all table on Upgrade! Use only during development. - * Convenience method using a {@link DevOpenHelper}. - */ - public static DaoSession newDevSession(Context context, String name) { - Database db = new DevOpenHelper(context, name).getWritableDb(); - DaoMaster daoMaster = new DaoMaster(db); - return daoMaster.newSession(); - } - - public DaoMaster(SQLiteDatabase db) { - this(new StandardDatabase(db)); - } - - public DaoMaster(Database db) { - super(db, SCHEMA_VERSION); - registerDaoClass(MarkerLocalBeanDao.class); - registerDaoClass(TaskLocalBeanDao.class); - registerDaoClass(TaskMarkerLocalBeanDao.class); - } - - public DaoSession newSession() { - return new DaoSession(db, IdentityScopeType.Session, daoConfigMap); - } - - public DaoSession newSession(IdentityScopeType type) { - return new DaoSession(db, type, daoConfigMap); - } - - /** - * Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} - - */ - public static abstract class OpenHelper extends DatabaseOpenHelper { - public OpenHelper(Context context, String name) { - super(context, name, SCHEMA_VERSION); - } - - public OpenHelper(Context context, String name, CursorFactory factory) { - super(context, name, factory, SCHEMA_VERSION); - } - - @Override - public void onCreate(Database db) { - Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION); - createAllTables(db, false); - } - } - - /** WARNING: Drops all table on Upgrade! Use only during development. */ - public static class DevOpenHelper extends OpenHelper { - public DevOpenHelper(Context context, String name) { - super(context, name); - } - - public DevOpenHelper(Context context, String name, CursorFactory factory) { - super(context, name, factory); - } - - @Override - public void onUpgrade(Database db, int oldVersion, int newVersion) { - Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables"); - dropAllTables(db, true); - onCreate(db); - } - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoSession.java b/app/src/main/java/com/casic/common/detector/gd/greendao/DaoSession.java deleted file mode 100644 index c8b1a20..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoSession.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import java.util.Map; - -import org.greenrobot.greendao.AbstractDao; -import org.greenrobot.greendao.AbstractDaoSession; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.identityscope.IdentityScopeType; -import org.greenrobot.greendao.internal.DaoConfig; - -import com.casic.common.detector.gd.bean.MarkerLocalBean; -import com.casic.common.detector.gd.bean.TaskLocalBean; -import com.casic.common.detector.gd.bean.TaskMarkerLocalBean; - -import com.casic.common.detector.gd.greendao.MarkerLocalBeanDao; -import com.casic.common.detector.gd.greendao.TaskLocalBeanDao; -import com.casic.common.detector.gd.greendao.TaskMarkerLocalBeanDao; - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. - -/** - * {@inheritDoc} - * - * @see org.greenrobot.greendao.AbstractDaoSession - */ -public class DaoSession extends AbstractDaoSession { - - private final DaoConfig markerLocalBeanDaoConfig; - private final DaoConfig taskLocalBeanDaoConfig; - private final DaoConfig taskMarkerLocalBeanDaoConfig; - - private final MarkerLocalBeanDao markerLocalBeanDao; - private final TaskLocalBeanDao taskLocalBeanDao; - private final TaskMarkerLocalBeanDao taskMarkerLocalBeanDao; - - public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> - daoConfigMap) { - super(db); - - markerLocalBeanDaoConfig = daoConfigMap.get(MarkerLocalBeanDao.class).clone(); - markerLocalBeanDaoConfig.initIdentityScope(type); - - taskLocalBeanDaoConfig = daoConfigMap.get(TaskLocalBeanDao.class).clone(); - taskLocalBeanDaoConfig.initIdentityScope(type); - - taskMarkerLocalBeanDaoConfig = daoConfigMap.get(TaskMarkerLocalBeanDao.class).clone(); - taskMarkerLocalBeanDaoConfig.initIdentityScope(type); - - markerLocalBeanDao = new MarkerLocalBeanDao(markerLocalBeanDaoConfig, this); - taskLocalBeanDao = new TaskLocalBeanDao(taskLocalBeanDaoConfig, this); - taskMarkerLocalBeanDao = new TaskMarkerLocalBeanDao(taskMarkerLocalBeanDaoConfig, this); - - registerDao(MarkerLocalBean.class, markerLocalBeanDao); - registerDao(TaskLocalBean.class, taskLocalBeanDao); - registerDao(TaskMarkerLocalBean.class, taskMarkerLocalBeanDao); - } - - public void clear() { - markerLocalBeanDaoConfig.clearIdentityScope(); - taskLocalBeanDaoConfig.clearIdentityScope(); - taskMarkerLocalBeanDaoConfig.clearIdentityScope(); - } - - public MarkerLocalBeanDao getMarkerLocalBeanDao() { - return markerLocalBeanDao; - } - - public TaskLocalBeanDao getTaskLocalBeanDao() { - return taskLocalBeanDao; - } - - public TaskMarkerLocalBeanDao getTaskMarkerLocalBeanDao() { - return taskMarkerLocalBeanDao; - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/MarkerLocalBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/greendao/MarkerLocalBeanDao.java deleted file mode 100644 index 2f792c3..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/MarkerLocalBeanDao.java +++ /dev/null @@ -1,479 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import android.database.Cursor; -import android.database.sqlite.SQLiteStatement; - -import org.greenrobot.greendao.AbstractDao; -import org.greenrobot.greendao.Property; -import org.greenrobot.greendao.internal.DaoConfig; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.database.DatabaseStatement; - -import com.casic.common.detector.gd.bean.MarkerLocalBean; - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** - * DAO for table "MARKER_LOCAL_BEAN". -*/ -public class MarkerLocalBeanDao extends AbstractDao { - - public static final String TABLENAME = "MARKER_LOCAL_BEAN"; - - /** - * Properties of entity MarkerLocalBean.
- * Can be used for QueryBuilder and for referencing column names. - */ - public static class Properties { - public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property PipelineType = new Property(1, String.class, "pipelineType", false, "PIPELINE_TYPE"); - public final static Property PipelineDiameter = new Property(2, String.class, "pipelineDiameter", false, "PIPELINE_DIAMETER"); - public final static Property PipelineMaterial = new Property(3, String.class, "pipelineMaterial", false, "PIPELINE_MATERIAL"); - public final static Property BuryMethod = new Property(4, String.class, "buryMethod", false, "BURY_METHOD"); - public final static Property BuryDepth = new Property(5, String.class, "buryDepth", false, "BURY_DEPTH"); - public final static Property Area = new Property(6, String.class, "area", false, "AREA"); - public final static Property Line = new Property(7, String.class, "line", false, "LINE"); - public final static Property Road = new Property(8, String.class, "road", false, "ROAD"); - public final static Property ConstructTime = new Property(9, String.class, "constructTime", false, "CONSTRUCT_TIME"); - public final static Property Owner = new Property(10, String.class, "owner", false, "OWNER"); - public final static Property ObjectId = new Property(11, String.class, "objectId", false, "OBJECT_ID"); - public final static Property MarkerId = new Property(12, String.class, "markerId", false, "MARKER_ID"); - public final static Property MarkerType = new Property(13, String.class, "markerType", false, "MARKER_TYPE"); - public final static Property MarkerDepth = new Property(14, String.class, "markerDepth", false, "MARKER_DEPTH"); - public final static Property InstallationDept = new Property(15, String.class, "installationDept", false, "INSTALLATION_DEPT"); - public final static Property Lng = new Property(16, String.class, "lng", false, "LNG"); - public final static Property Lat = new Property(17, String.class, "lat", false, "LAT"); - public final static Property UpdateTime = new Property(18, String.class, "updateTime", false, "UPDATE_TIME"); - public final static Property Remark = new Property(19, String.class, "remark", false, "REMARK"); - public final static Property UnderlyingPipelineType = new Property(20, String.class, "underlyingPipelineType", false, "UNDERLYING_PIPELINE_TYPE"); - public final static Property UnderlyingPipelineDepth = new Property(21, String.class, "underlyingPipelineDepth", false, "UNDERLYING_PIPELINE_DEPTH"); - public final static Property UnderlyingPipelineDiameter = new Property(22, String.class, "underlyingPipelineDiameter", false, "UNDERLYING_PIPELINE_DIAMETER"); - public final static Property UnderlyingPipelineMaterial = new Property(23, String.class, "underlyingPipelineMaterial", false, "UNDERLYING_PIPELINE_MATERIAL"); - public final static Property ObjectType = new Property(24, String.class, "objectType", false, "OBJECT_TYPE"); - public final static Property Color = new Property(25, String.class, "color", false, "COLOR"); - public final static Property ImagePath = new Property(26, String.class, "imagePath", false, "IMAGE_PATH"); - } - - - public MarkerLocalBeanDao(DaoConfig config) { - super(config); - } - - public MarkerLocalBeanDao(DaoConfig config, DaoSession daoSession) { - super(config, daoSession); - } - - /** Creates the underlying database table. */ - public static void createTable(Database db, boolean ifNotExists) { - String constraint = ifNotExists? "IF NOT EXISTS ": ""; - db.execSQL("CREATE TABLE " + constraint + "\"MARKER_LOCAL_BEAN\" (" + // - "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id - "\"PIPELINE_TYPE\" TEXT," + // 1: pipelineType - "\"PIPELINE_DIAMETER\" TEXT," + // 2: pipelineDiameter - "\"PIPELINE_MATERIAL\" TEXT," + // 3: pipelineMaterial - "\"BURY_METHOD\" TEXT," + // 4: buryMethod - "\"BURY_DEPTH\" TEXT," + // 5: buryDepth - "\"AREA\" TEXT," + // 6: area - "\"LINE\" TEXT," + // 7: line - "\"ROAD\" TEXT," + // 8: road - "\"CONSTRUCT_TIME\" TEXT," + // 9: constructTime - "\"OWNER\" TEXT," + // 10: owner - "\"OBJECT_ID\" TEXT," + // 11: objectId - "\"MARKER_ID\" TEXT," + // 12: markerId - "\"MARKER_TYPE\" TEXT," + // 13: markerType - "\"MARKER_DEPTH\" TEXT," + // 14: markerDepth - "\"INSTALLATION_DEPT\" TEXT," + // 15: installationDept - "\"LNG\" TEXT," + // 16: lng - "\"LAT\" TEXT," + // 17: lat - "\"UPDATE_TIME\" TEXT," + // 18: updateTime - "\"REMARK\" TEXT," + // 19: remark - "\"UNDERLYING_PIPELINE_TYPE\" TEXT," + // 20: underlyingPipelineType - "\"UNDERLYING_PIPELINE_DEPTH\" TEXT," + // 21: underlyingPipelineDepth - "\"UNDERLYING_PIPELINE_DIAMETER\" TEXT," + // 22: underlyingPipelineDiameter - "\"UNDERLYING_PIPELINE_MATERIAL\" TEXT," + // 23: underlyingPipelineMaterial - "\"OBJECT_TYPE\" TEXT," + // 24: objectType - "\"COLOR\" TEXT," + // 25: color - "\"IMAGE_PATH\" TEXT);"); // 26: imagePath - } - - /** Drops the underlying database table. */ - public static void dropTable(Database db, boolean ifExists) { - String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"MARKER_LOCAL_BEAN\""; - db.execSQL(sql); - } - - @Override - protected final void bindValues(DatabaseStatement stmt, MarkerLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String pipelineType = entity.getPipelineType(); - if (pipelineType != null) { - stmt.bindString(2, pipelineType); - } - - String pipelineDiameter = entity.getPipelineDiameter(); - if (pipelineDiameter != null) { - stmt.bindString(3, pipelineDiameter); - } - - String pipelineMaterial = entity.getPipelineMaterial(); - if (pipelineMaterial != null) { - stmt.bindString(4, pipelineMaterial); - } - - String buryMethod = entity.getBuryMethod(); - if (buryMethod != null) { - stmt.bindString(5, buryMethod); - } - - String buryDepth = entity.getBuryDepth(); - if (buryDepth != null) { - stmt.bindString(6, buryDepth); - } - - String area = entity.getArea(); - if (area != null) { - stmt.bindString(7, area); - } - - String line = entity.getLine(); - if (line != null) { - stmt.bindString(8, line); - } - - String road = entity.getRoad(); - if (road != null) { - stmt.bindString(9, road); - } - - String constructTime = entity.getConstructTime(); - if (constructTime != null) { - stmt.bindString(10, constructTime); - } - - String owner = entity.getOwner(); - if (owner != null) { - stmt.bindString(11, owner); - } - - String objectId = entity.getObjectId(); - if (objectId != null) { - stmt.bindString(12, objectId); - } - - String markerId = entity.getMarkerId(); - if (markerId != null) { - stmt.bindString(13, markerId); - } - - String markerType = entity.getMarkerType(); - if (markerType != null) { - stmt.bindString(14, markerType); - } - - String markerDepth = entity.getMarkerDepth(); - if (markerDepth != null) { - stmt.bindString(15, markerDepth); - } - - String installationDept = entity.getInstallationDept(); - if (installationDept != null) { - stmt.bindString(16, installationDept); - } - - String lng = entity.getLng(); - if (lng != null) { - stmt.bindString(17, lng); - } - - String lat = entity.getLat(); - if (lat != null) { - stmt.bindString(18, lat); - } - - String updateTime = entity.getUpdateTime(); - if (updateTime != null) { - stmt.bindString(19, updateTime); - } - - String remark = entity.getRemark(); - if (remark != null) { - stmt.bindString(20, remark); - } - - String underlyingPipelineType = entity.getUnderlyingPipelineType(); - if (underlyingPipelineType != null) { - stmt.bindString(21, underlyingPipelineType); - } - - String underlyingPipelineDepth = entity.getUnderlyingPipelineDepth(); - if (underlyingPipelineDepth != null) { - stmt.bindString(22, underlyingPipelineDepth); - } - - String underlyingPipelineDiameter = entity.getUnderlyingPipelineDiameter(); - if (underlyingPipelineDiameter != null) { - stmt.bindString(23, underlyingPipelineDiameter); - } - - String underlyingPipelineMaterial = entity.getUnderlyingPipelineMaterial(); - if (underlyingPipelineMaterial != null) { - stmt.bindString(24, underlyingPipelineMaterial); - } - - String objectType = entity.getObjectType(); - if (objectType != null) { - stmt.bindString(25, objectType); - } - - String color = entity.getColor(); - if (color != null) { - stmt.bindString(26, color); - } - - String imagePath = entity.getImagePath(); - if (imagePath != null) { - stmt.bindString(27, imagePath); - } - } - - @Override - protected final void bindValues(SQLiteStatement stmt, MarkerLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String pipelineType = entity.getPipelineType(); - if (pipelineType != null) { - stmt.bindString(2, pipelineType); - } - - String pipelineDiameter = entity.getPipelineDiameter(); - if (pipelineDiameter != null) { - stmt.bindString(3, pipelineDiameter); - } - - String pipelineMaterial = entity.getPipelineMaterial(); - if (pipelineMaterial != null) { - stmt.bindString(4, pipelineMaterial); - } - - String buryMethod = entity.getBuryMethod(); - if (buryMethod != null) { - stmt.bindString(5, buryMethod); - } - - String buryDepth = entity.getBuryDepth(); - if (buryDepth != null) { - stmt.bindString(6, buryDepth); - } - - String area = entity.getArea(); - if (area != null) { - stmt.bindString(7, area); - } - - String line = entity.getLine(); - if (line != null) { - stmt.bindString(8, line); - } - - String road = entity.getRoad(); - if (road != null) { - stmt.bindString(9, road); - } - - String constructTime = entity.getConstructTime(); - if (constructTime != null) { - stmt.bindString(10, constructTime); - } - - String owner = entity.getOwner(); - if (owner != null) { - stmt.bindString(11, owner); - } - - String objectId = entity.getObjectId(); - if (objectId != null) { - stmt.bindString(12, objectId); - } - - String markerId = entity.getMarkerId(); - if (markerId != null) { - stmt.bindString(13, markerId); - } - - String markerType = entity.getMarkerType(); - if (markerType != null) { - stmt.bindString(14, markerType); - } - - String markerDepth = entity.getMarkerDepth(); - if (markerDepth != null) { - stmt.bindString(15, markerDepth); - } - - String installationDept = entity.getInstallationDept(); - if (installationDept != null) { - stmt.bindString(16, installationDept); - } - - String lng = entity.getLng(); - if (lng != null) { - stmt.bindString(17, lng); - } - - String lat = entity.getLat(); - if (lat != null) { - stmt.bindString(18, lat); - } - - String updateTime = entity.getUpdateTime(); - if (updateTime != null) { - stmt.bindString(19, updateTime); - } - - String remark = entity.getRemark(); - if (remark != null) { - stmt.bindString(20, remark); - } - - String underlyingPipelineType = entity.getUnderlyingPipelineType(); - if (underlyingPipelineType != null) { - stmt.bindString(21, underlyingPipelineType); - } - - String underlyingPipelineDepth = entity.getUnderlyingPipelineDepth(); - if (underlyingPipelineDepth != null) { - stmt.bindString(22, underlyingPipelineDepth); - } - - String underlyingPipelineDiameter = entity.getUnderlyingPipelineDiameter(); - if (underlyingPipelineDiameter != null) { - stmt.bindString(23, underlyingPipelineDiameter); - } - - String underlyingPipelineMaterial = entity.getUnderlyingPipelineMaterial(); - if (underlyingPipelineMaterial != null) { - stmt.bindString(24, underlyingPipelineMaterial); - } - - String objectType = entity.getObjectType(); - if (objectType != null) { - stmt.bindString(25, objectType); - } - - String color = entity.getColor(); - if (color != null) { - stmt.bindString(26, color); - } - - String imagePath = entity.getImagePath(); - if (imagePath != null) { - stmt.bindString(27, imagePath); - } - } - - @Override - public Long readKey(Cursor cursor, int offset) { - return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); - } - - @Override - public MarkerLocalBean readEntity(Cursor cursor, int offset) { - MarkerLocalBean entity = new MarkerLocalBean( // - cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // pipelineType - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // pipelineDiameter - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // pipelineMaterial - cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // buryMethod - cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // buryDepth - cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // area - cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // line - cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // road - cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // constructTime - cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10), // owner - cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11), // objectId - cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12), // markerId - cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13), // markerType - cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14), // markerDepth - cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15), // installationDept - cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16), // lng - cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17), // lat - cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18), // updateTime - cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19), // remark - cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20), // underlyingPipelineType - cursor.isNull(offset + 21) ? null : cursor.getString(offset + 21), // underlyingPipelineDepth - cursor.isNull(offset + 22) ? null : cursor.getString(offset + 22), // underlyingPipelineDiameter - cursor.isNull(offset + 23) ? null : cursor.getString(offset + 23), // underlyingPipelineMaterial - cursor.isNull(offset + 24) ? null : cursor.getString(offset + 24), // objectType - cursor.isNull(offset + 25) ? null : cursor.getString(offset + 25), // color - cursor.isNull(offset + 26) ? null : cursor.getString(offset + 26) // imagePath - ); - return entity; - } - - @Override - public void readEntity(Cursor cursor, MarkerLocalBean entity, int offset) { - entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setPipelineType(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); - entity.setPipelineDiameter(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); - entity.setPipelineMaterial(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); - entity.setBuryMethod(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); - entity.setBuryDepth(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); - entity.setArea(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); - entity.setLine(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); - entity.setRoad(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); - entity.setConstructTime(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9)); - entity.setOwner(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); - entity.setObjectId(cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11)); - entity.setMarkerId(cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12)); - entity.setMarkerType(cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13)); - entity.setMarkerDepth(cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14)); - entity.setInstallationDept(cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15)); - entity.setLng(cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16)); - entity.setLat(cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17)); - entity.setUpdateTime(cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18)); - entity.setRemark(cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19)); - entity.setUnderlyingPipelineType(cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20)); - entity.setUnderlyingPipelineDepth(cursor.isNull(offset + 21) ? null : cursor.getString(offset + 21)); - entity.setUnderlyingPipelineDiameter(cursor.isNull(offset + 22) ? null : cursor.getString(offset + 22)); - entity.setUnderlyingPipelineMaterial(cursor.isNull(offset + 23) ? null : cursor.getString(offset + 23)); - entity.setObjectType(cursor.isNull(offset + 24) ? null : cursor.getString(offset + 24)); - entity.setColor(cursor.isNull(offset + 25) ? null : cursor.getString(offset + 25)); - entity.setImagePath(cursor.isNull(offset + 26) ? null : cursor.getString(offset + 26)); - } - - @Override - protected final Long updateKeyAfterInsert(MarkerLocalBean entity, long rowId) { - entity.setId(rowId); - return rowId; - } - - @Override - public Long getKey(MarkerLocalBean entity) { - if(entity != null) { - return entity.getId(); - } else { - return null; - } - } - - @Override - public boolean hasKey(MarkerLocalBean entity) { - return entity.getId() != null; - } - - @Override - protected final boolean isEntityUpdateable() { - return true; - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/TaskLocalBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/greendao/TaskLocalBeanDao.java deleted file mode 100644 index fb88157..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/TaskLocalBeanDao.java +++ /dev/null @@ -1,227 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import android.database.Cursor; -import android.database.sqlite.SQLiteStatement; - -import org.greenrobot.greendao.AbstractDao; -import org.greenrobot.greendao.Property; -import org.greenrobot.greendao.internal.DaoConfig; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.database.DatabaseStatement; - -import com.casic.common.detector.gd.bean.TaskLocalBean; - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** - * DAO for table "TASK_LOCAL_BEAN". -*/ -public class TaskLocalBeanDao extends AbstractDao { - - public static final String TABLENAME = "TASK_LOCAL_BEAN"; - - /** - * Properties of entity TaskLocalBean.
- * Can be used for QueryBuilder and for referencing column names. - */ - public static class Properties { - public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property TaskCode = new Property(1, String.class, "taskCode", false, "TASK_CODE"); - public final static Property Description = new Property(2, String.class, "description", false, "DESCRIPTION"); - public final static Property CreateTime = new Property(3, String.class, "createTime", false, "CREATE_TIME"); - public final static Property Status = new Property(4, String.class, "status", false, "STATUS"); - public final static Property CreateUserName = new Property(5, String.class, "createUserName", false, "CREATE_USER_NAME"); - public final static Property StartTime = new Property(6, String.class, "startTime", false, "START_TIME"); - public final static Property EndTime = new Property(7, String.class, "endTime", false, "END_TIME"); - public final static Property IsFreeTask = new Property(8, String.class, "isFreeTask", false, "IS_FREE_TASK"); - } - - - public TaskLocalBeanDao(DaoConfig config) { - super(config); - } - - public TaskLocalBeanDao(DaoConfig config, DaoSession daoSession) { - super(config, daoSession); - } - - /** Creates the underlying database table. */ - public static void createTable(Database db, boolean ifNotExists) { - String constraint = ifNotExists? "IF NOT EXISTS ": ""; - db.execSQL("CREATE TABLE " + constraint + "\"TASK_LOCAL_BEAN\" (" + // - "\"_id\" INTEGER PRIMARY KEY ," + // 0: id - "\"TASK_CODE\" TEXT," + // 1: taskCode - "\"DESCRIPTION\" TEXT," + // 2: description - "\"CREATE_TIME\" TEXT," + // 3: createTime - "\"STATUS\" TEXT," + // 4: status - "\"CREATE_USER_NAME\" TEXT," + // 5: createUserName - "\"START_TIME\" TEXT," + // 6: startTime - "\"END_TIME\" TEXT," + // 7: endTime - "\"IS_FREE_TASK\" TEXT);"); // 8: isFreeTask - } - - /** Drops the underlying database table. */ - public static void dropTable(Database db, boolean ifExists) { - String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"TASK_LOCAL_BEAN\""; - db.execSQL(sql); - } - - @Override - protected final void bindValues(DatabaseStatement stmt, TaskLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String taskCode = entity.getTaskCode(); - if (taskCode != null) { - stmt.bindString(2, taskCode); - } - - String description = entity.getDescription(); - if (description != null) { - stmt.bindString(3, description); - } - - String createTime = entity.getCreateTime(); - if (createTime != null) { - stmt.bindString(4, createTime); - } - - String status = entity.getStatus(); - if (status != null) { - stmt.bindString(5, status); - } - - String createUserName = entity.getCreateUserName(); - if (createUserName != null) { - stmt.bindString(6, createUserName); - } - - String startTime = entity.getStartTime(); - if (startTime != null) { - stmt.bindString(7, startTime); - } - - String endTime = entity.getEndTime(); - if (endTime != null) { - stmt.bindString(8, endTime); - } - - String isFreeTask = entity.getIsFreeTask(); - if (isFreeTask != null) { - stmt.bindString(9, isFreeTask); - } - } - - @Override - protected final void bindValues(SQLiteStatement stmt, TaskLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String taskCode = entity.getTaskCode(); - if (taskCode != null) { - stmt.bindString(2, taskCode); - } - - String description = entity.getDescription(); - if (description != null) { - stmt.bindString(3, description); - } - - String createTime = entity.getCreateTime(); - if (createTime != null) { - stmt.bindString(4, createTime); - } - - String status = entity.getStatus(); - if (status != null) { - stmt.bindString(5, status); - } - - String createUserName = entity.getCreateUserName(); - if (createUserName != null) { - stmt.bindString(6, createUserName); - } - - String startTime = entity.getStartTime(); - if (startTime != null) { - stmt.bindString(7, startTime); - } - - String endTime = entity.getEndTime(); - if (endTime != null) { - stmt.bindString(8, endTime); - } - - String isFreeTask = entity.getIsFreeTask(); - if (isFreeTask != null) { - stmt.bindString(9, isFreeTask); - } - } - - @Override - public Long readKey(Cursor cursor, int offset) { - return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); - } - - @Override - public TaskLocalBean readEntity(Cursor cursor, int offset) { - TaskLocalBean entity = new TaskLocalBean( // - cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // taskCode - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // description - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // createTime - cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // status - cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // createUserName - cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // startTime - cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // endTime - cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8) // isFreeTask - ); - return entity; - } - - @Override - public void readEntity(Cursor cursor, TaskLocalBean entity, int offset) { - entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setTaskCode(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); - entity.setDescription(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); - entity.setCreateTime(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); - entity.setStatus(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); - entity.setCreateUserName(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); - entity.setStartTime(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); - entity.setEndTime(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); - entity.setIsFreeTask(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); - } - - @Override - protected final Long updateKeyAfterInsert(TaskLocalBean entity, long rowId) { - entity.setId(rowId); - return rowId; - } - - @Override - public Long getKey(TaskLocalBean entity) { - if(entity != null) { - return entity.getId(); - } else { - return null; - } - } - - @Override - public boolean hasKey(TaskLocalBean entity) { - return entity.getId() != null; - } - - @Override - protected final boolean isEntityUpdateable() { - return true; - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/TaskMarkerLocalBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/greendao/TaskMarkerLocalBeanDao.java deleted file mode 100644 index e96c735..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/TaskMarkerLocalBeanDao.java +++ /dev/null @@ -1,197 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import android.database.Cursor; -import android.database.sqlite.SQLiteStatement; - -import org.greenrobot.greendao.AbstractDao; -import org.greenrobot.greendao.Property; -import org.greenrobot.greendao.internal.DaoConfig; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.database.DatabaseStatement; - -import com.casic.common.detector.gd.bean.TaskMarkerLocalBean; - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** - * DAO for table "TASK_MARKER_LOCAL_BEAN". -*/ -public class TaskMarkerLocalBeanDao extends AbstractDao { - - public static final String TABLENAME = "TASK_MARKER_LOCAL_BEAN"; - - /** - * Properties of entity TaskMarkerLocalBean.
- * Can be used for QueryBuilder and for referencing column names. - */ - public static class Properties { - public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property TaskId = new Property(1, String.class, "taskId", false, "TASK_ID"); - public final static Property TaskCode = new Property(2, String.class, "taskCode", false, "TASK_CODE"); - public final static Property MarkerId = new Property(3, String.class, "markerId", false, "MARKER_ID"); - public final static Property Lng = new Property(4, double.class, "lng", false, "LNG"); - public final static Property Lat = new Property(5, double.class, "lat", false, "LAT"); - public final static Property IsDetected = new Property(6, String.class, "isDetected", false, "IS_DETECTED"); - public final static Property DetectedTime = new Property(7, String.class, "detectedTime", false, "DETECTED_TIME"); - } - - - public TaskMarkerLocalBeanDao(DaoConfig config) { - super(config); - } - - public TaskMarkerLocalBeanDao(DaoConfig config, DaoSession daoSession) { - super(config, daoSession); - } - - /** Creates the underlying database table. */ - public static void createTable(Database db, boolean ifNotExists) { - String constraint = ifNotExists? "IF NOT EXISTS ": ""; - db.execSQL("CREATE TABLE " + constraint + "\"TASK_MARKER_LOCAL_BEAN\" (" + // - "\"_id\" INTEGER PRIMARY KEY ," + // 0: id - "\"TASK_ID\" TEXT," + // 1: taskId - "\"TASK_CODE\" TEXT," + // 2: taskCode - "\"MARKER_ID\" TEXT," + // 3: markerId - "\"LNG\" REAL NOT NULL ," + // 4: lng - "\"LAT\" REAL NOT NULL ," + // 5: lat - "\"IS_DETECTED\" TEXT," + // 6: isDetected - "\"DETECTED_TIME\" TEXT);"); // 7: detectedTime - } - - /** Drops the underlying database table. */ - public static void dropTable(Database db, boolean ifExists) { - String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"TASK_MARKER_LOCAL_BEAN\""; - db.execSQL(sql); - } - - @Override - protected final void bindValues(DatabaseStatement stmt, TaskMarkerLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String taskId = entity.getTaskId(); - if (taskId != null) { - stmt.bindString(2, taskId); - } - - String taskCode = entity.getTaskCode(); - if (taskCode != null) { - stmt.bindString(3, taskCode); - } - - String markerId = entity.getMarkerId(); - if (markerId != null) { - stmt.bindString(4, markerId); - } - stmt.bindDouble(5, entity.getLng()); - stmt.bindDouble(6, entity.getLat()); - - String isDetected = entity.getIsDetected(); - if (isDetected != null) { - stmt.bindString(7, isDetected); - } - - String detectedTime = entity.getDetectedTime(); - if (detectedTime != null) { - stmt.bindString(8, detectedTime); - } - } - - @Override - protected final void bindValues(SQLiteStatement stmt, TaskMarkerLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String taskId = entity.getTaskId(); - if (taskId != null) { - stmt.bindString(2, taskId); - } - - String taskCode = entity.getTaskCode(); - if (taskCode != null) { - stmt.bindString(3, taskCode); - } - - String markerId = entity.getMarkerId(); - if (markerId != null) { - stmt.bindString(4, markerId); - } - stmt.bindDouble(5, entity.getLng()); - stmt.bindDouble(6, entity.getLat()); - - String isDetected = entity.getIsDetected(); - if (isDetected != null) { - stmt.bindString(7, isDetected); - } - - String detectedTime = entity.getDetectedTime(); - if (detectedTime != null) { - stmt.bindString(8, detectedTime); - } - } - - @Override - public Long readKey(Cursor cursor, int offset) { - return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); - } - - @Override - public TaskMarkerLocalBean readEntity(Cursor cursor, int offset) { - TaskMarkerLocalBean entity = new TaskMarkerLocalBean( // - cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // taskId - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // taskCode - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // markerId - cursor.getDouble(offset + 4), // lng - cursor.getDouble(offset + 5), // lat - cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // isDetected - cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7) // detectedTime - ); - return entity; - } - - @Override - public void readEntity(Cursor cursor, TaskMarkerLocalBean entity, int offset) { - entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setTaskId(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); - entity.setTaskCode(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); - entity.setMarkerId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); - entity.setLng(cursor.getDouble(offset + 4)); - entity.setLat(cursor.getDouble(offset + 5)); - entity.setIsDetected(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); - entity.setDetectedTime(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); - } - - @Override - protected final Long updateKeyAfterInsert(TaskMarkerLocalBean entity, long rowId) { - entity.setId(rowId); - return rowId; - } - - @Override - public Long getKey(TaskMarkerLocalBean entity) { - if(entity != null) { - return entity.getId(); - } else { - return null; - } - } - - @Override - public boolean hasKey(TaskMarkerLocalBean entity) { - return entity.getId() != null; - } - - @Override - protected final boolean isEntityUpdateable() { - return true; - } - -} diff --git a/app/build.gradle b/app/build.gradle index d0cb423..921c8c8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,25 +1,20 @@ import java.text.SimpleDateFormat -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply plugin: 'org.greenrobot.greendao' +plugins { + id('com.android.application') + id('org.jetbrains.kotlin.android') +} android { - compileSdkVersion 33 + namespace 'com.casic.common.detector.gd' + compileSdk 35 defaultConfig { - applicationId "com.casic.common.detector.gd" - minSdkVersion 26 - targetSdkVersion 33 + applicationId 'com.casic.common.detector.gd' + minSdk 26 + targetSdk 35 versionCode 5092 - versionName "5.0.9.2" - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } + versionName '5.0.9.2' } signingConfigs { @@ -31,6 +26,14 @@ } } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + signingConfig signingConfigs.release + } + } + compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 @@ -47,27 +50,16 @@ } } - kotlin { - experimental { - coroutines 'enable' - } - } - buildFeatures { + buildConfig true viewBinding true } - applicationVariants.configureEach { variant -> - variant.outputs.configureEach { - outputFileName = "COM_TCY_" + getBuildDate() + "_" + defaultConfig.versionName + ".apk" + applicationVariants.configureEach { + outputs.configureEach { + outputFileName = 'COM_TCY_' + getBuildDate() + '_' + defaultConfig.versionName + '.apk' } } - - greendao { - schemaVersion 1//数据库版本号 - targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 - daoPackage "${defaultConfig.applicationId}.greendao"//设置DaoMaster、DaoSession、Dao包名 - } } static def getBuildDate() { @@ -76,27 +68,22 @@ } dependencies { - //基础依赖库 - implementation 'com.github.AndroidCoderPeng:Kotlin-lite-lib:1.1.4' - implementation 'androidx.core:core-ktx:1.9.0' - def base_version = "1.6.1" - implementation "androidx.appcompat:appcompat:${base_version}" - implementation "com.google.android.material:material:${base_version}" + implementation 'com.github.AndroidCoderPeng:Kotlin-lite-lib:1.1.5' + implementation 'androidx.core:core-ktx:1.13.1' + implementation 'androidx.appcompat:appcompat:1.7.0' + implementation 'com.google.android.material:material:1.12.0' //Google官方授权框架 implementation 'pub.devrel:easypermissions:3.0.0' - //沉浸式状态栏。基础依赖包,必须要依赖 - implementation 'com.gyf.immersionbar:immersionbar:3.0.0' - //fragment快速实现 - implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0' + //沉浸式状态栏 + implementation 'com.geyifeng.immersionbar:immersionbar:3.2.2' //官方Json解析库 implementation 'com.google.code.gson:gson:2.10.1' - def vm_version = '2.5.1' //Kotlin协程 - implementation "androidx.lifecycle:lifecycle-runtime-ktx:${vm_version}" + implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.2' //MVVM+LiveData - implementation "androidx.lifecycle:lifecycle-livedata-ktx:${vm_version}" - implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:${vm_version}" - implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.6.2' + implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2' + implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' //返回值转换器 implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' @@ -105,9 +92,10 @@ implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' //网络请求和接口封装 implementation 'com.squareup.retrofit2:retrofit:2.9.0' - implementation 'com.squareup.okhttp3:okhttp:4.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.12.0' //数据库框架 - implementation 'org.greenrobot:greendao:3.3.0' + implementation 'androidx.room:room-runtime:2.6.1' + annotationProcessor 'androidx.room:room-compiler:2.5.2' //高德导航、定位、地图三合一 implementation 'com.amap.api:navi-3dmap:latest.integration' //经纬度逆编码 @@ -115,7 +103,7 @@ //excel implementation 'net.sourceforge.jexcelapi:jxl:2.6.12' //图片加载框架 - implementation 'com.github.bumptech.glide:glide:4.9.0' + implementation 'com.github.bumptech.glide:glide:4.12.0' //图片选择框架 implementation 'io.github.lucksiege:pictureselector:v3.11.1' //大图 diff --git a/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt b/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt index 7b695ff..50ba734 100644 --- a/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt +++ b/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt @@ -4,9 +4,9 @@ import android.app.Application import android.os.Bundle import android.util.Log -import com.casic.common.detector.gd.greendao.DaoMaster -import com.casic.common.detector.gd.greendao.DaoSession +import androidx.room.Room.databaseBuilder import com.casic.common.detector.gd.uart.SerialPort +import com.casic.common.detector.gd.utils.DetectorDataBase import com.casic.common.detector.gd.utils.GpioManager import com.pengxh.kt.lite.extensions.show import com.pengxh.kt.lite.utils.SaveKeyValues @@ -43,44 +43,42 @@ private var application: BaseApplication by Delegates.notNull() fun get() = application - - private lateinit var daoSession: DaoSession } + lateinit var dataBase: DetectorDataBase + override fun onCreate() { super.onCreate() application = this SaveKeyValues.initSharedPreferences(this) CrashReport.initCrashReport(this, "01e80d3a74", true) - val devOpenHelper = DaoMaster.DevOpenHelper(this, "Detector.db", null) - val daoMaster = DaoMaster(devOpenHelper.writableDatabase) - daoSession = daoMaster.newSession() + dataBase = databaseBuilder(this, DetectorDataBase::class.java, "Detector.db") + .allowMainThreadQueries() + .build() /** * Open the serial port * */ try { serialPorts.apply { - add(SerialPort(File("/dev/ttysWK1"), 9600, 0)) - //千寻报文数据下发串口号 - add(SerialPort(File("/dev/ttyS1"), 9600, 0)) + add(SerialPort(File("/dev/ttysWK1"), 9600, 0)) //信号通讯串口 + add(SerialPort(File("/dev/ttyS1"), 9600, 0)) //千寻报文数据下发串口号 } Log.d(kTag, "onCreate: 已初始化 ${serialPorts.size} 个串口") } catch (e: SecurityException) { "您没有串口的读写权限!".show(this) + e.printStackTrace() } catch (e: IOException) { "因为不明原因,串口无法打开!".show(this) + e.printStackTrace() } catch (e: InvalidParameterException) { "请检查串口!".show(this) + e.printStackTrace() } registerActivityLifecycleCallbacks(this) } - fun getDaoSession(): DaoSession { - return daoSession - } - override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) { } diff --git a/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt b/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt index 053b9dd..1d0c9e3 100644 --- a/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt +++ b/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt @@ -14,12 +14,10 @@ import com.casic.common.detector.gd.utils.SerialPortCommand import com.pengxh.kt.lite.utils.WeakReferenceHandler import java.io.IOException -import java.util.Timer abstract class SerialPortBaseActivity : AppCompatActivity(), Handler.Callback { private val kTag = "SerialPortBaseActivity" - private val taskTimer by lazy { Timer() } private val weakReferenceHandler by lazy { WeakReferenceHandler(this) } private val serialPorts by lazy { BaseApplication.get().getSerialPorts() } protected lateinit var binding: VB @@ -30,7 +28,6 @@ setContentView(binding.root) setupTopBarLayout() initOnCreate(savedInstanceState) - observeRequestState() initEvent() if (serialPorts.isNotEmpty()) { @@ -71,11 +68,6 @@ abstract fun initOnCreate(savedInstanceState: Bundle?) /** - * 数据请求状态监听 - */ - abstract fun observeRequestState() - - /** * 初始化业务逻辑 */ abstract fun initEvent() diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java new file mode 100644 index 0000000..7a18c20 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java @@ -0,0 +1,255 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 从平台下载的标识器本地库实体类 + */ +@Entity(tableName = "marker_detail") +public class MarkerBean { + @PrimaryKey(autoGenerate = true) + private long id; //主键ID + private String pipelineType; // 管线类型 + private String pipelineDiameter; // 管线直径 + private String pipelineMaterial; // 管材 + private String buryMethod; // 埋设方式 + private String buryDepth; // 埋深 + private String area; // 所属区域 + private String line; // 所属线路 + private String road; // 所属道路 + private String constructTime; // 建设年代 + private String owner; // 权属单位 + private String objectId; // 标识对象ID,无实际用途 + private String markerId; // 标识器ID + private String markerType; // 标识器类型 + private String markerDepth; // 标识器埋深 + private String installationDept; // 安装部门 + private String lng; // 经度 + private String lat; // 纬度 + private String updateTime; // 最后修改时间,更新时间 + private String remark; // 备注信息 + private String underlyingPipelineType; // 下层管线类型 + private String underlyingPipelineDepth; // 下层埋深 + private String underlyingPipelineDiameter; // 下层管径 + private String underlyingPipelineMaterial; // 下层管材 + private String objectType; //标识对象类型 + private String color; // 颜色 + private String imagePath; // 图片路径 + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getPipelineType() { + return pipelineType; + } + + public void setPipelineType(String pipelineType) { + this.pipelineType = pipelineType; + } + + public String getPipelineDiameter() { + return pipelineDiameter; + } + + public void setPipelineDiameter(String pipelineDiameter) { + this.pipelineDiameter = pipelineDiameter; + } + + public String getPipelineMaterial() { + return pipelineMaterial; + } + + public void setPipelineMaterial(String pipelineMaterial) { + this.pipelineMaterial = pipelineMaterial; + } + + public String getBuryMethod() { + return buryMethod; + } + + public void setBuryMethod(String buryMethod) { + this.buryMethod = buryMethod; + } + + public String getBuryDepth() { + return buryDepth; + } + + public void setBuryDepth(String buryDepth) { + this.buryDepth = buryDepth; + } + + public String getArea() { + return area; + } + + public void setArea(String area) { + this.area = area; + } + + public String getLine() { + return line; + } + + public void setLine(String line) { + this.line = line; + } + + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + + public String getConstructTime() { + return constructTime; + } + + public void setConstructTime(String constructTime) { + this.constructTime = constructTime; + } + + public String getOwner() { + return owner; + } + + public void setOwner(String owner) { + this.owner = owner; + } + + public String getObjectId() { + return objectId; + } + + public void setObjectId(String objectId) { + this.objectId = objectId; + } + + public String getMarkerId() { + return markerId; + } + + public void setMarkerId(String markerId) { + this.markerId = markerId; + } + + public String getMarkerType() { + return markerType; + } + + public void setMarkerType(String markerType) { + this.markerType = markerType; + } + + public String getMarkerDepth() { + return markerDepth; + } + + public void setMarkerDepth(String markerDepth) { + this.markerDepth = markerDepth; + } + + public String getInstallationDept() { + return installationDept; + } + + public void setInstallationDept(String installationDept) { + this.installationDept = installationDept; + } + + public String getLng() { + return lng; + } + + public void setLng(String lng) { + this.lng = lng; + } + + public String getLat() { + return lat; + } + + public void setLat(String lat) { + this.lat = lat; + } + + public String getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } + + public String getUnderlyingPipelineType() { + return underlyingPipelineType; + } + + public void setUnderlyingPipelineType(String underlyingPipelineType) { + this.underlyingPipelineType = underlyingPipelineType; + } + + public String getUnderlyingPipelineDepth() { + return underlyingPipelineDepth; + } + + public void setUnderlyingPipelineDepth(String underlyingPipelineDepth) { + this.underlyingPipelineDepth = underlyingPipelineDepth; + } + + public String getUnderlyingPipelineDiameter() { + return underlyingPipelineDiameter; + } + + public void setUnderlyingPipelineDiameter(String underlyingPipelineDiameter) { + this.underlyingPipelineDiameter = underlyingPipelineDiameter; + } + + public String getUnderlyingPipelineMaterial() { + return underlyingPipelineMaterial; + } + + public void setUnderlyingPipelineMaterial(String underlyingPipelineMaterial) { + this.underlyingPipelineMaterial = underlyingPipelineMaterial; + } + + public String getObjectType() { + return objectType; + } + + public void setObjectType(String objectType) { + this.objectType = objectType; + } + + public String getColor() { + return color; + } + + public void setColor(String color) { + this.color = color; + } + + public String getImagePath() { + return imagePath; + } + + public void setImagePath(String imagePath) { + this.imagePath = imagePath; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java deleted file mode 100644 index 3f2fcdc..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java +++ /dev/null @@ -1,327 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 从平台下载的标识器本地库实体类 - */ -@Entity -public class MarkerLocalBean { - @Id(autoincrement = true) - private Long id;//本地库主键ID - - // 管线类型 - private String pipelineType; - // 管线直径 - private String pipelineDiameter; - // 管材 - private String pipelineMaterial; - // 埋设方式 - private String buryMethod; - // 埋深 - private String buryDepth; - // 所属区域 - private String area; - // 所属线路 - private String line; - // 所属道路 - private String road; - // 建设年代 - private String constructTime; - // 权属单位 - private String owner; - //标识对象ID,无实际用途 - @Deprecated - private String objectId; - // 标识器ID - private String markerId; - // 标识器类型 - private String markerType; - // 标识器埋深 - private String markerDepth; - // 安装部门 - private String installationDept; - // 经度 - private String lng; - // 纬度 - private String lat; - //最后修改时间,更新时间 - private String updateTime; - // 备注信息 - private String remark; - // 下层管线类型 - private String underlyingPipelineType; - // 下层埋深 - private String underlyingPipelineDepth; - // 下层管径 - private String underlyingPipelineDiameter; - // 下层管材 - private String underlyingPipelineMaterial; - //标识对象类型 - private String objectType; - // 颜色 - private String color; - // 图片路径 - private String imagePath; - - @Generated(hash = 1479045776) - public MarkerLocalBean(Long id, String pipelineType, String pipelineDiameter, - String pipelineMaterial, String buryMethod, String buryDepth, - String area, String line, String road, String constructTime, - String owner, String objectId, String markerId, String markerType, - String markerDepth, String installationDept, String lng, String lat, - String updateTime, String remark, String underlyingPipelineType, - String underlyingPipelineDepth, String underlyingPipelineDiameter, - String underlyingPipelineMaterial, String objectType, String color, - String imagePath) { - this.id = id; - this.pipelineType = pipelineType; - this.pipelineDiameter = pipelineDiameter; - this.pipelineMaterial = pipelineMaterial; - this.buryMethod = buryMethod; - this.buryDepth = buryDepth; - this.area = area; - this.line = line; - this.road = road; - this.constructTime = constructTime; - this.owner = owner; - this.objectId = objectId; - this.markerId = markerId; - this.markerType = markerType; - this.markerDepth = markerDepth; - this.installationDept = installationDept; - this.lng = lng; - this.lat = lat; - this.updateTime = updateTime; - this.remark = remark; - this.underlyingPipelineType = underlyingPipelineType; - this.underlyingPipelineDepth = underlyingPipelineDepth; - this.underlyingPipelineDiameter = underlyingPipelineDiameter; - this.underlyingPipelineMaterial = underlyingPipelineMaterial; - this.objectType = objectType; - this.color = color; - this.imagePath = imagePath; - } - - @Generated(hash = 1538606012) - public MarkerLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getPipelineType() { - return this.pipelineType; - } - - public void setPipelineType(String pipelineType) { - this.pipelineType = pipelineType; - } - - public String getPipelineDiameter() { - return this.pipelineDiameter; - } - - public void setPipelineDiameter(String pipelineDiameter) { - this.pipelineDiameter = pipelineDiameter; - } - - public String getPipelineMaterial() { - return this.pipelineMaterial; - } - - public void setPipelineMaterial(String pipelineMaterial) { - this.pipelineMaterial = pipelineMaterial; - } - - public String getBuryMethod() { - return this.buryMethod; - } - - public void setBuryMethod(String buryMethod) { - this.buryMethod = buryMethod; - } - - public String getBuryDepth() { - return this.buryDepth; - } - - public void setBuryDepth(String buryDepth) { - this.buryDepth = buryDepth; - } - - public String getArea() { - return this.area; - } - - public void setArea(String area) { - this.area = area; - } - - public String getLine() { - return this.line; - } - - public void setLine(String line) { - this.line = line; - } - - public String getRoad() { - return this.road; - } - - public void setRoad(String road) { - this.road = road; - } - - public String getConstructTime() { - return this.constructTime; - } - - public void setConstructTime(String constructTime) { - this.constructTime = constructTime; - } - - public String getOwner() { - return this.owner; - } - - public void setOwner(String owner) { - this.owner = owner; - } - - public String getObjectId() { - return this.objectId; - } - - public void setObjectId(String objectId) { - this.objectId = objectId; - } - - public String getMarkerId() { - return this.markerId; - } - - public void setMarkerId(String markerId) { - this.markerId = markerId; - } - - public String getMarkerType() { - return this.markerType; - } - - public void setMarkerType(String markerType) { - this.markerType = markerType; - } - - public String getMarkerDepth() { - return this.markerDepth; - } - - public void setMarkerDepth(String markerDepth) { - this.markerDepth = markerDepth; - } - - public String getInstallationDept() { - return this.installationDept; - } - - public void setInstallationDept(String installationDept) { - this.installationDept = installationDept; - } - - public String getLng() { - return this.lng; - } - - public void setLng(String lng) { - this.lng = lng; - } - - public String getLat() { - return this.lat; - } - - public void setLat(String lat) { - this.lat = lat; - } - - public String getUpdateTime() { - return this.updateTime; - } - - public void setUpdateTime(String updateTime) { - this.updateTime = updateTime; - } - - public String getRemark() { - return this.remark; - } - - public void setRemark(String remark) { - this.remark = remark; - } - - public String getUnderlyingPipelineType() { - return this.underlyingPipelineType; - } - - public void setUnderlyingPipelineType(String underlyingPipelineType) { - this.underlyingPipelineType = underlyingPipelineType; - } - - public String getUnderlyingPipelineDepth() { - return this.underlyingPipelineDepth; - } - - public void setUnderlyingPipelineDepth(String underlyingPipelineDepth) { - this.underlyingPipelineDepth = underlyingPipelineDepth; - } - - public String getUnderlyingPipelineDiameter() { - return this.underlyingPipelineDiameter; - } - - public void setUnderlyingPipelineDiameter(String underlyingPipelineDiameter) { - this.underlyingPipelineDiameter = underlyingPipelineDiameter; - } - - public String getUnderlyingPipelineMaterial() { - return this.underlyingPipelineMaterial; - } - - public void setUnderlyingPipelineMaterial(String underlyingPipelineMaterial) { - this.underlyingPipelineMaterial = underlyingPipelineMaterial; - } - - public String getObjectType() { - return this.objectType; - } - - public void setObjectType(String objectType) { - this.objectType = objectType; - } - - public String getColor() { - return this.color; - } - - public void setColor(String color) { - this.color = color; - } - - public String getImagePath() { - return this.imagePath; - } - - public void setImagePath(String imagePath) { - this.imagePath = imagePath; - } -} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java new file mode 100644 index 0000000..5c88fdf --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java @@ -0,0 +1,93 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 巡检任务本地库实体类,不包含任务里面需要巡检的标识器信息 + */ +@Entity(tableName = "task_detail") +public class TaskBean { + @PrimaryKey(autoGenerate = true) + private long id;//主键ID + private String taskCode; // 任务编号 + private String description; // 任务名称 + private String createTime; // 任务创建的时间 + private String status; // 任务状态 + private String createUserName; // 任务创建者名称 + private String startTime; // 任务被开始执行的时间 + private String endTime; // 任务执行结束的时间 + private String isFree; // 是否自由巡检。1-是,0-否 + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getTaskCode() { + return taskCode; + } + + public void setTaskCode(String taskCode) { + this.taskCode = taskCode; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getCreateUserName() { + return createUserName; + } + + public void setCreateUserName(String createUserName) { + this.createUserName = createUserName; + } + + public String getStartTime() { + return startTime; + } + + public void setStartTime(String startTime) { + this.startTime = startTime; + } + + public String getEndTime() { + return endTime; + } + + public void setEndTime(String endTime) { + this.endTime = endTime; + } + + public String getIsFree() { + return isFree; + } + + public void setIsFree(String isFree) { + this.isFree = isFree; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java deleted file mode 100644 index 91737b3..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java +++ /dev/null @@ -1,114 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 巡检任务本地库实体类,不包含任务里面需要巡检的标识器信息 - */ -@Entity -public class TaskLocalBean { - @Id - private Long id;//任务ID - - private String taskCode;//任务编号 - private String description;//任务名称 - private String createTime;//任务创建的时间 - private String status;//任务状态 - private String createUserName;//任务创建者名称 - private String startTime;//任务被开始执行的时间 - private String endTime;//任务执行结束的时间 - private String isFreeTask;//是否自由巡检。1-是,0-否 - - @Generated(hash = 1482022528) - public TaskLocalBean(Long id, String taskCode, String description, - String createTime, String status, String createUserName, - String startTime, String endTime, String isFreeTask) { - this.id = id; - this.taskCode = taskCode; - this.description = description; - this.createTime = createTime; - this.status = status; - this.createUserName = createUserName; - this.startTime = startTime; - this.endTime = endTime; - this.isFreeTask = isFreeTask; - } - - @Generated(hash = 949704588) - public TaskLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getTaskCode() { - return this.taskCode; - } - - public void setTaskCode(String taskCode) { - this.taskCode = taskCode; - } - - public String getDescription() { - return this.description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getCreateTime() { - return this.createTime; - } - - public void setCreateTime(String createTime) { - this.createTime = createTime; - } - - public String getStatus() { - return this.status; - } - - public void setStatus(String status) { - this.status = status; - } - - public String getCreateUserName() { - return this.createUserName; - } - - public void setCreateUserName(String createUserName) { - this.createUserName = createUserName; - } - - public String getStartTime() { - return this.startTime; - } - - public void setStartTime(String startTime) { - this.startTime = startTime; - } - - public String getEndTime() { - return this.endTime; - } - - public void setEndTime(String endTime) { - this.endTime = endTime; - } - - public String getIsFreeTask() { - return this.isFreeTask; - } - - public void setIsFreeTask(String isFreeTask) { - this.isFreeTask = isFreeTask; - } -} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerBean.java new file mode 100644 index 0000000..c563a60 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerBean.java @@ -0,0 +1,110 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 巡检任务里面需要巡检的标识器信息本地库实体类 + */ +@Entity(tableName = "task_marker_info") +public class TaskMarkerBean { + //标识器后台库的主键ID,不是标识器实际ID + @PrimaryKey(autoGenerate = true) + private long id; + + /** + * 任务ID,通过此字段关联[TaskBean.id] + */ + private String taskId; + + /** + * 任务Code,通过此字段关联[TaskBean.taskCode] + *

+ *

+ * 双重验证,防止出现同时刻重复的情况 + */ + private String taskCode; + + /** + * 对应后台字段[TaskModel.MessageModel.TaskDetailInfosModel.markerIdReal],也就是探测仪扫描出来的ID + */ + private String markerId; + + private Double lng; + private Double lat; + + /** + * 是否已被探测到 + * 1-是,0-否 + */ + private String isDetected; + + /** + * 被探测到的时间,对应后台字段[TaskModel.MessageModel.TaskDetailInfosModel.finishTime] + */ + private String detectedTime; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getTaskId() { + return taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getTaskCode() { + return taskCode; + } + + public void setTaskCode(String taskCode) { + this.taskCode = taskCode; + } + + public String getMarkerId() { + return markerId; + } + + public void setMarkerId(String markerId) { + this.markerId = markerId; + } + + public Double getLng() { + return lng; + } + + public void setLng(Double lng) { + this.lng = lng; + } + + public Double getLat() { + return lat; + } + + public void setLat(Double lat) { + this.lat = lat; + } + + public String getIsDetected() { + return isDetected; + } + + public void setIsDetected(String isDetected) { + this.isDetected = isDetected; + } + + public String getDetectedTime() { + return detectedTime; + } + + public void setDetectedTime(String detectedTime) { + this.detectedTime = detectedTime; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerLocalBean.java deleted file mode 100644 index de9f459..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerLocalBean.java +++ /dev/null @@ -1,128 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import com.casic.common.detector.gd.model.TaskModel; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 巡检任务里面需要巡检的标识器信息本地库实体类 - */ -@Entity -public class TaskMarkerLocalBean { - @Id - private Long id;//标识器后台库的主键ID,不是标识器实际ID - - /** - * 任务ID,通过此字段关联{@link TaskLocalBean#id} - */ - private String taskId; - - /** - * 任务Code,通过此字段关联{@link TaskLocalBean#taskCode} - *

- * 双重验证,防止出现同时刻重复的情况 - */ - private String taskCode; - - /** - * 对应后台字段{@link TaskModel.MessageModel.TaskDetailInfosModel#markerIdReal},也就是探测仪扫描出来的ID - */ - private String markerId; - - private double lng; - private double lat; - - /** - * 是否已被探测到 - * 1-是,0-否 - */ - private String isDetected; - - /** - * 被探测到的时间,对应后台字段{@link TaskModel.MessageModel.TaskDetailInfosModel#finishTime} - */ - private String detectedTime; - - @Generated(hash = 677328533) - public TaskMarkerLocalBean(Long id, String taskId, String taskCode, String markerId, - double lng, double lat, String isDetected, String detectedTime) { - this.id = id; - this.taskId = taskId; - this.taskCode = taskCode; - this.markerId = markerId; - this.lng = lng; - this.lat = lat; - this.isDetected = isDetected; - this.detectedTime = detectedTime; - } - - @Generated(hash = 1162404642) - public TaskMarkerLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getTaskId() { - return this.taskId; - } - - public void setTaskId(String taskId) { - this.taskId = taskId; - } - - public String getTaskCode() { - return this.taskCode; - } - - public void setTaskCode(String taskCode) { - this.taskCode = taskCode; - } - - public String getMarkerId() { - return this.markerId; - } - - public void setMarkerId(String markerId) { - this.markerId = markerId; - } - - public double getLng() { - return this.lng; - } - - public void setLng(double lng) { - this.lng = lng; - } - - public double getLat() { - return this.lat; - } - - public void setLat(double lat) { - this.lat = lat; - } - - public String getIsDetected() { - return this.isDetected; - } - - public void setIsDetected(String isDetected) { - this.isDetected = isDetected; - } - - public String getDetectedTime() { - return this.detectedTime; - } - - public void setDetectedTime(String detectedTime) { - this.detectedTime = detectedTime; - } -} diff --git a/app/src/main/java/com/casic/common/detector/gd/dao/MarkerBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/dao/MarkerBeanDao.java new file mode 100644 index 0000000..2beb7ed --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/dao/MarkerBeanDao.java @@ -0,0 +1,29 @@ +package com.casic.common.detector.gd.dao; + +import androidx.room.Dao; +import androidx.room.Insert; +import androidx.room.Query; +import androidx.room.RawQuery; +import androidx.sqlite.db.SupportSQLiteQuery; + +import com.casic.common.detector.gd.bean.MarkerBean; + +import java.util.List; + +@Dao +public interface MarkerBeanDao { + @Query("DELETE FROM marker_detail") + void deleteAll(); + + @Insert + void insert(MarkerBean marker); + + @Query("SELECT * FROM marker_detail") + List loadAll(); + + @Query("SELECT * FROM marker_detail WHERE markerId = :markerId") + List queryMarkerById(String markerId); + + @RawQuery + List loadMarkersByCondition(SupportSQLiteQuery query); +} diff --git a/app/src/main/java/com/casic/common/detector/gd/dao/TaskBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/dao/TaskBeanDao.java new file mode 100644 index 0000000..9c70ac2 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/dao/TaskBeanDao.java @@ -0,0 +1,120 @@ +package com.casic.common.detector.gd.dao; + +import androidx.room.Dao; +import androidx.room.Insert; +import androidx.room.Query; +import androidx.room.Transaction; + +import com.casic.common.detector.gd.bean.TaskBean; +import com.casic.common.detector.gd.bean.TaskMarkerBean; +import com.casic.common.detector.gd.model.TaskDetailLocalModel; +import com.casic.common.detector.gd.model.TaskModel; +import com.casic.common.detector.gd.utils.LocaleConstant; +import com.pengxh.kt.lite.utils.SaveKeyValues; + +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Locale; + +@Dao +public interface TaskBeanDao { + @Query("SELECT COUNT(*) FROM task_detail WHERE id = :taskId") + int isTaskExist(long taskId); + + @Insert + void insert(TaskBean task); + + default void saveTask(Long taskId, String taskName) { + if (isTaskExist(taskId) == 0) { + TaskBean task = new TaskBean(); + task.setId(taskId); + task.setTaskCode(new SimpleDateFormat("yyyyMMddHHmmss", Locale.CHINA).format(new Date())); + task.setDescription(taskName); + String time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA).format(new Date()); + task.setCreateTime(time); + task.setStatus("0"); + String userName = (String) SaveKeyValues.INSTANCE.getValue(LocaleConstant.USER_NAME, ""); + task.setCreateUserName(userName); + task.setStartTime(time); + task.setEndTime(""); + task.setIsFree("1"); + insert(task); + } + } + + default void saveTask(TaskModel.MessageModel model) { + TaskBean task = new TaskBean(); + task.setId(model.getId()); + task.setTaskCode(model.getTaskCode()); + task.setDescription(model.getDescription()); + task.setCreateTime(model.getDeployDate()); + task.setStatus(model.getStatus()); + task.setCreateUserName(model.getCreatorName()); + task.setStartTime(model.getBeginDate()); + task.setEndTime(model.getEndDate()); + task.setIsFree("0"); + if (isTaskExist(task.getId()) == 0) { + insert(task); + } + } + + @Query("SELECT * FROM task_detail") + List loadAll(); + + @Transaction + default ArrayList loadLocalTask(TaskMarkerBeanDao taskMarkerBeanDao) { + ArrayList result = new ArrayList<>(); + List tasks = loadAll(); + for (TaskBean it : tasks) { + TaskDetailLocalModel model = new TaskDetailLocalModel(); + model.setTaskId(String.valueOf(it.getId())); + model.setTaskCode(it.getTaskCode()); + model.setDescription(it.getDescription()); + model.setCreateTime(it.getCreateTime()); + model.setStatus(it.getStatus()); + model.setCreateUserName(it.getCreateUserName()); + model.setIsFreeTask(it.getIsFree()); + ArrayList results = new ArrayList<>(); + if ("0".equals(it.getIsFree())) { + // 非自由巡检才有Marker + List markers = taskMarkerBeanDao.getMarkersByIdAndCode(String.valueOf(it.getId()), it.getTaskCode()); + for (TaskMarkerBean marker : markers) { + TaskDetailLocalModel.TaskMarkerLocalModel localModel = new TaskDetailLocalModel.TaskMarkerLocalModel(); + localModel.setMarkerId(marker.getMarkerId()); + localModel.setLng(marker.getLng()); + localModel.setLat(marker.getLat()); + localModel.setIsDetected(marker.getIsDetected()); + localModel.setDetectedTime(marker.getDetectedTime()); + + results.add(localModel); + } + } + model.setMarkerModels(results); + result.add(model); + } + return result; + } + + @Query("DELETE FROM task_detail WHERE id = :taskId AND taskCode = :taskCode") + void deleteTaskById(long taskId, String taskCode); + + @Transaction + default void deleteLocalTaskById(long taskId, String taskCode, TaskMarkerBeanDao taskMarkerBeanDao) { + TaskBean task = loadAll().stream() + .filter(it -> it.getId() == taskId && taskCode.equals(it.getTaskCode())) + .findFirst() + .orElse(null); + if (task == null) return; + deleteTaskById(taskId, taskCode); + + // 删除此任务关联的Marker。非自由巡检才有Marker + if ("0".equals(task.getIsFree())) { + List markers = taskMarkerBeanDao.getMarkersByIdAndCode(String.valueOf(task.getId()), task.getTaskCode()); + for (TaskMarkerBean marker : markers) { + taskMarkerBeanDao.delete(marker); + } + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/dao/TaskMarkerBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/dao/TaskMarkerBeanDao.java new file mode 100644 index 0000000..cc2156a --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/dao/TaskMarkerBeanDao.java @@ -0,0 +1,52 @@ +package com.casic.common.detector.gd.dao; + +import androidx.room.Dao; +import androidx.room.Delete; +import androidx.room.Insert; +import androidx.room.Query; +import androidx.room.Update; + +import com.casic.common.detector.gd.bean.TaskMarkerBean; +import com.casic.common.detector.gd.model.TaskModel; + +import java.util.List; + +@Dao +public interface TaskMarkerBeanDao { + + @Insert + void insert(TaskMarkerBean marker); + + @Query("SELECT COUNT(*) FROM task_marker_info WHERE id = :markerId") + int isMarkerExist(String markerId); + + default void saveTaskMarker(long taskId, String taskCode, TaskModel.MessageModel.TaskDetailInfosModel marker) { + if (isMarkerExist(marker.getMarkerId()) == 0) { + TaskMarkerBean bean = new TaskMarkerBean(); + bean.setId(marker.getId()); + bean.setTaskId(String.valueOf(taskId)); + bean.setTaskCode(taskCode); + bean.setMarkerId(marker.getMarkerIdReal()); + bean.setLng(marker.getLongitude()); + bean.setLat(marker.getLatitude()); + bean.setIsDetected("0"); + bean.setDetectedTime(""); + insert(bean); + } + } + + @Query("SELECT * FROM task_marker_info WHERE taskId = :taskId AND taskCode = :taskCode AND markerId = :markerId AND isDetected = :state") + TaskMarkerBean queryTaskMarkerById(String taskId, String taskCode, String markerId, String state); + + @Update + void updateLocalTaskMarkerState(TaskMarkerBean marker); + + @Query("SELECT * FROM task_marker_info WHERE isDetected = :state") + List queryMarkerByState(String state); + + @Query("SELECT * FROM task_marker_info WHERE taskId = :taskId AND taskCode = :taskCode") + List getMarkersByIdAndCode(String taskId, String taskCode); + + @Delete + void delete(TaskMarkerBean marker); +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/extensions/Long.kt b/app/src/main/java/com/casic/common/detector/gd/extensions/Long.kt deleted file mode 100644 index 6713d8d..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/extensions/Long.kt +++ /dev/null @@ -1,10 +0,0 @@ -package com.casic.common.detector.gd.extensions - -import java.text.SimpleDateFormat -import java.util.Date -import java.util.Locale - -fun Long.createTaskCode(): String { - val dateFormat = SimpleDateFormat("yyyyMMddHHmmss", Locale.CHINA) - return dateFormat.format(Date(this)) -} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoMaster.java b/app/src/main/java/com/casic/common/detector/gd/greendao/DaoMaster.java deleted file mode 100644 index 6ab94b3..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoMaster.java +++ /dev/null @@ -1,102 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import android.content.Context; -import android.database.sqlite.SQLiteDatabase; -import android.database.sqlite.SQLiteDatabase.CursorFactory; -import android.util.Log; - -import org.greenrobot.greendao.AbstractDaoMaster; -import org.greenrobot.greendao.database.StandardDatabase; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.database.DatabaseOpenHelper; -import org.greenrobot.greendao.identityscope.IdentityScopeType; - - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** - * Master of DAO (schema version 1): knows all DAOs. - */ -public class DaoMaster extends AbstractDaoMaster { - public static final int SCHEMA_VERSION = 1; - - /** Creates underlying database table using DAOs. */ - public static void createAllTables(Database db, boolean ifNotExists) { - MarkerLocalBeanDao.createTable(db, ifNotExists); - TaskLocalBeanDao.createTable(db, ifNotExists); - TaskMarkerLocalBeanDao.createTable(db, ifNotExists); - } - - /** Drops underlying database table using DAOs. */ - public static void dropAllTables(Database db, boolean ifExists) { - MarkerLocalBeanDao.dropTable(db, ifExists); - TaskLocalBeanDao.dropTable(db, ifExists); - TaskMarkerLocalBeanDao.dropTable(db, ifExists); - } - - /** - * WARNING: Drops all table on Upgrade! Use only during development. - * Convenience method using a {@link DevOpenHelper}. - */ - public static DaoSession newDevSession(Context context, String name) { - Database db = new DevOpenHelper(context, name).getWritableDb(); - DaoMaster daoMaster = new DaoMaster(db); - return daoMaster.newSession(); - } - - public DaoMaster(SQLiteDatabase db) { - this(new StandardDatabase(db)); - } - - public DaoMaster(Database db) { - super(db, SCHEMA_VERSION); - registerDaoClass(MarkerLocalBeanDao.class); - registerDaoClass(TaskLocalBeanDao.class); - registerDaoClass(TaskMarkerLocalBeanDao.class); - } - - public DaoSession newSession() { - return new DaoSession(db, IdentityScopeType.Session, daoConfigMap); - } - - public DaoSession newSession(IdentityScopeType type) { - return new DaoSession(db, type, daoConfigMap); - } - - /** - * Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} - - */ - public static abstract class OpenHelper extends DatabaseOpenHelper { - public OpenHelper(Context context, String name) { - super(context, name, SCHEMA_VERSION); - } - - public OpenHelper(Context context, String name, CursorFactory factory) { - super(context, name, factory, SCHEMA_VERSION); - } - - @Override - public void onCreate(Database db) { - Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION); - createAllTables(db, false); - } - } - - /** WARNING: Drops all table on Upgrade! Use only during development. */ - public static class DevOpenHelper extends OpenHelper { - public DevOpenHelper(Context context, String name) { - super(context, name); - } - - public DevOpenHelper(Context context, String name, CursorFactory factory) { - super(context, name, factory); - } - - @Override - public void onUpgrade(Database db, int oldVersion, int newVersion) { - Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables"); - dropAllTables(db, true); - onCreate(db); - } - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoSession.java b/app/src/main/java/com/casic/common/detector/gd/greendao/DaoSession.java deleted file mode 100644 index c8b1a20..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoSession.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import java.util.Map; - -import org.greenrobot.greendao.AbstractDao; -import org.greenrobot.greendao.AbstractDaoSession; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.identityscope.IdentityScopeType; -import org.greenrobot.greendao.internal.DaoConfig; - -import com.casic.common.detector.gd.bean.MarkerLocalBean; -import com.casic.common.detector.gd.bean.TaskLocalBean; -import com.casic.common.detector.gd.bean.TaskMarkerLocalBean; - -import com.casic.common.detector.gd.greendao.MarkerLocalBeanDao; -import com.casic.common.detector.gd.greendao.TaskLocalBeanDao; -import com.casic.common.detector.gd.greendao.TaskMarkerLocalBeanDao; - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. - -/** - * {@inheritDoc} - * - * @see org.greenrobot.greendao.AbstractDaoSession - */ -public class DaoSession extends AbstractDaoSession { - - private final DaoConfig markerLocalBeanDaoConfig; - private final DaoConfig taskLocalBeanDaoConfig; - private final DaoConfig taskMarkerLocalBeanDaoConfig; - - private final MarkerLocalBeanDao markerLocalBeanDao; - private final TaskLocalBeanDao taskLocalBeanDao; - private final TaskMarkerLocalBeanDao taskMarkerLocalBeanDao; - - public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> - daoConfigMap) { - super(db); - - markerLocalBeanDaoConfig = daoConfigMap.get(MarkerLocalBeanDao.class).clone(); - markerLocalBeanDaoConfig.initIdentityScope(type); - - taskLocalBeanDaoConfig = daoConfigMap.get(TaskLocalBeanDao.class).clone(); - taskLocalBeanDaoConfig.initIdentityScope(type); - - taskMarkerLocalBeanDaoConfig = daoConfigMap.get(TaskMarkerLocalBeanDao.class).clone(); - taskMarkerLocalBeanDaoConfig.initIdentityScope(type); - - markerLocalBeanDao = new MarkerLocalBeanDao(markerLocalBeanDaoConfig, this); - taskLocalBeanDao = new TaskLocalBeanDao(taskLocalBeanDaoConfig, this); - taskMarkerLocalBeanDao = new TaskMarkerLocalBeanDao(taskMarkerLocalBeanDaoConfig, this); - - registerDao(MarkerLocalBean.class, markerLocalBeanDao); - registerDao(TaskLocalBean.class, taskLocalBeanDao); - registerDao(TaskMarkerLocalBean.class, taskMarkerLocalBeanDao); - } - - public void clear() { - markerLocalBeanDaoConfig.clearIdentityScope(); - taskLocalBeanDaoConfig.clearIdentityScope(); - taskMarkerLocalBeanDaoConfig.clearIdentityScope(); - } - - public MarkerLocalBeanDao getMarkerLocalBeanDao() { - return markerLocalBeanDao; - } - - public TaskLocalBeanDao getTaskLocalBeanDao() { - return taskLocalBeanDao; - } - - public TaskMarkerLocalBeanDao getTaskMarkerLocalBeanDao() { - return taskMarkerLocalBeanDao; - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/MarkerLocalBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/greendao/MarkerLocalBeanDao.java deleted file mode 100644 index 2f792c3..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/MarkerLocalBeanDao.java +++ /dev/null @@ -1,479 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import android.database.Cursor; -import android.database.sqlite.SQLiteStatement; - -import org.greenrobot.greendao.AbstractDao; -import org.greenrobot.greendao.Property; -import org.greenrobot.greendao.internal.DaoConfig; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.database.DatabaseStatement; - -import com.casic.common.detector.gd.bean.MarkerLocalBean; - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** - * DAO for table "MARKER_LOCAL_BEAN". -*/ -public class MarkerLocalBeanDao extends AbstractDao { - - public static final String TABLENAME = "MARKER_LOCAL_BEAN"; - - /** - * Properties of entity MarkerLocalBean.
- * Can be used for QueryBuilder and for referencing column names. - */ - public static class Properties { - public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property PipelineType = new Property(1, String.class, "pipelineType", false, "PIPELINE_TYPE"); - public final static Property PipelineDiameter = new Property(2, String.class, "pipelineDiameter", false, "PIPELINE_DIAMETER"); - public final static Property PipelineMaterial = new Property(3, String.class, "pipelineMaterial", false, "PIPELINE_MATERIAL"); - public final static Property BuryMethod = new Property(4, String.class, "buryMethod", false, "BURY_METHOD"); - public final static Property BuryDepth = new Property(5, String.class, "buryDepth", false, "BURY_DEPTH"); - public final static Property Area = new Property(6, String.class, "area", false, "AREA"); - public final static Property Line = new Property(7, String.class, "line", false, "LINE"); - public final static Property Road = new Property(8, String.class, "road", false, "ROAD"); - public final static Property ConstructTime = new Property(9, String.class, "constructTime", false, "CONSTRUCT_TIME"); - public final static Property Owner = new Property(10, String.class, "owner", false, "OWNER"); - public final static Property ObjectId = new Property(11, String.class, "objectId", false, "OBJECT_ID"); - public final static Property MarkerId = new Property(12, String.class, "markerId", false, "MARKER_ID"); - public final static Property MarkerType = new Property(13, String.class, "markerType", false, "MARKER_TYPE"); - public final static Property MarkerDepth = new Property(14, String.class, "markerDepth", false, "MARKER_DEPTH"); - public final static Property InstallationDept = new Property(15, String.class, "installationDept", false, "INSTALLATION_DEPT"); - public final static Property Lng = new Property(16, String.class, "lng", false, "LNG"); - public final static Property Lat = new Property(17, String.class, "lat", false, "LAT"); - public final static Property UpdateTime = new Property(18, String.class, "updateTime", false, "UPDATE_TIME"); - public final static Property Remark = new Property(19, String.class, "remark", false, "REMARK"); - public final static Property UnderlyingPipelineType = new Property(20, String.class, "underlyingPipelineType", false, "UNDERLYING_PIPELINE_TYPE"); - public final static Property UnderlyingPipelineDepth = new Property(21, String.class, "underlyingPipelineDepth", false, "UNDERLYING_PIPELINE_DEPTH"); - public final static Property UnderlyingPipelineDiameter = new Property(22, String.class, "underlyingPipelineDiameter", false, "UNDERLYING_PIPELINE_DIAMETER"); - public final static Property UnderlyingPipelineMaterial = new Property(23, String.class, "underlyingPipelineMaterial", false, "UNDERLYING_PIPELINE_MATERIAL"); - public final static Property ObjectType = new Property(24, String.class, "objectType", false, "OBJECT_TYPE"); - public final static Property Color = new Property(25, String.class, "color", false, "COLOR"); - public final static Property ImagePath = new Property(26, String.class, "imagePath", false, "IMAGE_PATH"); - } - - - public MarkerLocalBeanDao(DaoConfig config) { - super(config); - } - - public MarkerLocalBeanDao(DaoConfig config, DaoSession daoSession) { - super(config, daoSession); - } - - /** Creates the underlying database table. */ - public static void createTable(Database db, boolean ifNotExists) { - String constraint = ifNotExists? "IF NOT EXISTS ": ""; - db.execSQL("CREATE TABLE " + constraint + "\"MARKER_LOCAL_BEAN\" (" + // - "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id - "\"PIPELINE_TYPE\" TEXT," + // 1: pipelineType - "\"PIPELINE_DIAMETER\" TEXT," + // 2: pipelineDiameter - "\"PIPELINE_MATERIAL\" TEXT," + // 3: pipelineMaterial - "\"BURY_METHOD\" TEXT," + // 4: buryMethod - "\"BURY_DEPTH\" TEXT," + // 5: buryDepth - "\"AREA\" TEXT," + // 6: area - "\"LINE\" TEXT," + // 7: line - "\"ROAD\" TEXT," + // 8: road - "\"CONSTRUCT_TIME\" TEXT," + // 9: constructTime - "\"OWNER\" TEXT," + // 10: owner - "\"OBJECT_ID\" TEXT," + // 11: objectId - "\"MARKER_ID\" TEXT," + // 12: markerId - "\"MARKER_TYPE\" TEXT," + // 13: markerType - "\"MARKER_DEPTH\" TEXT," + // 14: markerDepth - "\"INSTALLATION_DEPT\" TEXT," + // 15: installationDept - "\"LNG\" TEXT," + // 16: lng - "\"LAT\" TEXT," + // 17: lat - "\"UPDATE_TIME\" TEXT," + // 18: updateTime - "\"REMARK\" TEXT," + // 19: remark - "\"UNDERLYING_PIPELINE_TYPE\" TEXT," + // 20: underlyingPipelineType - "\"UNDERLYING_PIPELINE_DEPTH\" TEXT," + // 21: underlyingPipelineDepth - "\"UNDERLYING_PIPELINE_DIAMETER\" TEXT," + // 22: underlyingPipelineDiameter - "\"UNDERLYING_PIPELINE_MATERIAL\" TEXT," + // 23: underlyingPipelineMaterial - "\"OBJECT_TYPE\" TEXT," + // 24: objectType - "\"COLOR\" TEXT," + // 25: color - "\"IMAGE_PATH\" TEXT);"); // 26: imagePath - } - - /** Drops the underlying database table. */ - public static void dropTable(Database db, boolean ifExists) { - String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"MARKER_LOCAL_BEAN\""; - db.execSQL(sql); - } - - @Override - protected final void bindValues(DatabaseStatement stmt, MarkerLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String pipelineType = entity.getPipelineType(); - if (pipelineType != null) { - stmt.bindString(2, pipelineType); - } - - String pipelineDiameter = entity.getPipelineDiameter(); - if (pipelineDiameter != null) { - stmt.bindString(3, pipelineDiameter); - } - - String pipelineMaterial = entity.getPipelineMaterial(); - if (pipelineMaterial != null) { - stmt.bindString(4, pipelineMaterial); - } - - String buryMethod = entity.getBuryMethod(); - if (buryMethod != null) { - stmt.bindString(5, buryMethod); - } - - String buryDepth = entity.getBuryDepth(); - if (buryDepth != null) { - stmt.bindString(6, buryDepth); - } - - String area = entity.getArea(); - if (area != null) { - stmt.bindString(7, area); - } - - String line = entity.getLine(); - if (line != null) { - stmt.bindString(8, line); - } - - String road = entity.getRoad(); - if (road != null) { - stmt.bindString(9, road); - } - - String constructTime = entity.getConstructTime(); - if (constructTime != null) { - stmt.bindString(10, constructTime); - } - - String owner = entity.getOwner(); - if (owner != null) { - stmt.bindString(11, owner); - } - - String objectId = entity.getObjectId(); - if (objectId != null) { - stmt.bindString(12, objectId); - } - - String markerId = entity.getMarkerId(); - if (markerId != null) { - stmt.bindString(13, markerId); - } - - String markerType = entity.getMarkerType(); - if (markerType != null) { - stmt.bindString(14, markerType); - } - - String markerDepth = entity.getMarkerDepth(); - if (markerDepth != null) { - stmt.bindString(15, markerDepth); - } - - String installationDept = entity.getInstallationDept(); - if (installationDept != null) { - stmt.bindString(16, installationDept); - } - - String lng = entity.getLng(); - if (lng != null) { - stmt.bindString(17, lng); - } - - String lat = entity.getLat(); - if (lat != null) { - stmt.bindString(18, lat); - } - - String updateTime = entity.getUpdateTime(); - if (updateTime != null) { - stmt.bindString(19, updateTime); - } - - String remark = entity.getRemark(); - if (remark != null) { - stmt.bindString(20, remark); - } - - String underlyingPipelineType = entity.getUnderlyingPipelineType(); - if (underlyingPipelineType != null) { - stmt.bindString(21, underlyingPipelineType); - } - - String underlyingPipelineDepth = entity.getUnderlyingPipelineDepth(); - if (underlyingPipelineDepth != null) { - stmt.bindString(22, underlyingPipelineDepth); - } - - String underlyingPipelineDiameter = entity.getUnderlyingPipelineDiameter(); - if (underlyingPipelineDiameter != null) { - stmt.bindString(23, underlyingPipelineDiameter); - } - - String underlyingPipelineMaterial = entity.getUnderlyingPipelineMaterial(); - if (underlyingPipelineMaterial != null) { - stmt.bindString(24, underlyingPipelineMaterial); - } - - String objectType = entity.getObjectType(); - if (objectType != null) { - stmt.bindString(25, objectType); - } - - String color = entity.getColor(); - if (color != null) { - stmt.bindString(26, color); - } - - String imagePath = entity.getImagePath(); - if (imagePath != null) { - stmt.bindString(27, imagePath); - } - } - - @Override - protected final void bindValues(SQLiteStatement stmt, MarkerLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String pipelineType = entity.getPipelineType(); - if (pipelineType != null) { - stmt.bindString(2, pipelineType); - } - - String pipelineDiameter = entity.getPipelineDiameter(); - if (pipelineDiameter != null) { - stmt.bindString(3, pipelineDiameter); - } - - String pipelineMaterial = entity.getPipelineMaterial(); - if (pipelineMaterial != null) { - stmt.bindString(4, pipelineMaterial); - } - - String buryMethod = entity.getBuryMethod(); - if (buryMethod != null) { - stmt.bindString(5, buryMethod); - } - - String buryDepth = entity.getBuryDepth(); - if (buryDepth != null) { - stmt.bindString(6, buryDepth); - } - - String area = entity.getArea(); - if (area != null) { - stmt.bindString(7, area); - } - - String line = entity.getLine(); - if (line != null) { - stmt.bindString(8, line); - } - - String road = entity.getRoad(); - if (road != null) { - stmt.bindString(9, road); - } - - String constructTime = entity.getConstructTime(); - if (constructTime != null) { - stmt.bindString(10, constructTime); - } - - String owner = entity.getOwner(); - if (owner != null) { - stmt.bindString(11, owner); - } - - String objectId = entity.getObjectId(); - if (objectId != null) { - stmt.bindString(12, objectId); - } - - String markerId = entity.getMarkerId(); - if (markerId != null) { - stmt.bindString(13, markerId); - } - - String markerType = entity.getMarkerType(); - if (markerType != null) { - stmt.bindString(14, markerType); - } - - String markerDepth = entity.getMarkerDepth(); - if (markerDepth != null) { - stmt.bindString(15, markerDepth); - } - - String installationDept = entity.getInstallationDept(); - if (installationDept != null) { - stmt.bindString(16, installationDept); - } - - String lng = entity.getLng(); - if (lng != null) { - stmt.bindString(17, lng); - } - - String lat = entity.getLat(); - if (lat != null) { - stmt.bindString(18, lat); - } - - String updateTime = entity.getUpdateTime(); - if (updateTime != null) { - stmt.bindString(19, updateTime); - } - - String remark = entity.getRemark(); - if (remark != null) { - stmt.bindString(20, remark); - } - - String underlyingPipelineType = entity.getUnderlyingPipelineType(); - if (underlyingPipelineType != null) { - stmt.bindString(21, underlyingPipelineType); - } - - String underlyingPipelineDepth = entity.getUnderlyingPipelineDepth(); - if (underlyingPipelineDepth != null) { - stmt.bindString(22, underlyingPipelineDepth); - } - - String underlyingPipelineDiameter = entity.getUnderlyingPipelineDiameter(); - if (underlyingPipelineDiameter != null) { - stmt.bindString(23, underlyingPipelineDiameter); - } - - String underlyingPipelineMaterial = entity.getUnderlyingPipelineMaterial(); - if (underlyingPipelineMaterial != null) { - stmt.bindString(24, underlyingPipelineMaterial); - } - - String objectType = entity.getObjectType(); - if (objectType != null) { - stmt.bindString(25, objectType); - } - - String color = entity.getColor(); - if (color != null) { - stmt.bindString(26, color); - } - - String imagePath = entity.getImagePath(); - if (imagePath != null) { - stmt.bindString(27, imagePath); - } - } - - @Override - public Long readKey(Cursor cursor, int offset) { - return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); - } - - @Override - public MarkerLocalBean readEntity(Cursor cursor, int offset) { - MarkerLocalBean entity = new MarkerLocalBean( // - cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // pipelineType - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // pipelineDiameter - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // pipelineMaterial - cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // buryMethod - cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // buryDepth - cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // area - cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // line - cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // road - cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // constructTime - cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10), // owner - cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11), // objectId - cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12), // markerId - cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13), // markerType - cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14), // markerDepth - cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15), // installationDept - cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16), // lng - cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17), // lat - cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18), // updateTime - cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19), // remark - cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20), // underlyingPipelineType - cursor.isNull(offset + 21) ? null : cursor.getString(offset + 21), // underlyingPipelineDepth - cursor.isNull(offset + 22) ? null : cursor.getString(offset + 22), // underlyingPipelineDiameter - cursor.isNull(offset + 23) ? null : cursor.getString(offset + 23), // underlyingPipelineMaterial - cursor.isNull(offset + 24) ? null : cursor.getString(offset + 24), // objectType - cursor.isNull(offset + 25) ? null : cursor.getString(offset + 25), // color - cursor.isNull(offset + 26) ? null : cursor.getString(offset + 26) // imagePath - ); - return entity; - } - - @Override - public void readEntity(Cursor cursor, MarkerLocalBean entity, int offset) { - entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setPipelineType(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); - entity.setPipelineDiameter(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); - entity.setPipelineMaterial(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); - entity.setBuryMethod(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); - entity.setBuryDepth(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); - entity.setArea(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); - entity.setLine(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); - entity.setRoad(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); - entity.setConstructTime(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9)); - entity.setOwner(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); - entity.setObjectId(cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11)); - entity.setMarkerId(cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12)); - entity.setMarkerType(cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13)); - entity.setMarkerDepth(cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14)); - entity.setInstallationDept(cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15)); - entity.setLng(cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16)); - entity.setLat(cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17)); - entity.setUpdateTime(cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18)); - entity.setRemark(cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19)); - entity.setUnderlyingPipelineType(cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20)); - entity.setUnderlyingPipelineDepth(cursor.isNull(offset + 21) ? null : cursor.getString(offset + 21)); - entity.setUnderlyingPipelineDiameter(cursor.isNull(offset + 22) ? null : cursor.getString(offset + 22)); - entity.setUnderlyingPipelineMaterial(cursor.isNull(offset + 23) ? null : cursor.getString(offset + 23)); - entity.setObjectType(cursor.isNull(offset + 24) ? null : cursor.getString(offset + 24)); - entity.setColor(cursor.isNull(offset + 25) ? null : cursor.getString(offset + 25)); - entity.setImagePath(cursor.isNull(offset + 26) ? null : cursor.getString(offset + 26)); - } - - @Override - protected final Long updateKeyAfterInsert(MarkerLocalBean entity, long rowId) { - entity.setId(rowId); - return rowId; - } - - @Override - public Long getKey(MarkerLocalBean entity) { - if(entity != null) { - return entity.getId(); - } else { - return null; - } - } - - @Override - public boolean hasKey(MarkerLocalBean entity) { - return entity.getId() != null; - } - - @Override - protected final boolean isEntityUpdateable() { - return true; - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/TaskLocalBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/greendao/TaskLocalBeanDao.java deleted file mode 100644 index fb88157..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/TaskLocalBeanDao.java +++ /dev/null @@ -1,227 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import android.database.Cursor; -import android.database.sqlite.SQLiteStatement; - -import org.greenrobot.greendao.AbstractDao; -import org.greenrobot.greendao.Property; -import org.greenrobot.greendao.internal.DaoConfig; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.database.DatabaseStatement; - -import com.casic.common.detector.gd.bean.TaskLocalBean; - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** - * DAO for table "TASK_LOCAL_BEAN". -*/ -public class TaskLocalBeanDao extends AbstractDao { - - public static final String TABLENAME = "TASK_LOCAL_BEAN"; - - /** - * Properties of entity TaskLocalBean.
- * Can be used for QueryBuilder and for referencing column names. - */ - public static class Properties { - public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property TaskCode = new Property(1, String.class, "taskCode", false, "TASK_CODE"); - public final static Property Description = new Property(2, String.class, "description", false, "DESCRIPTION"); - public final static Property CreateTime = new Property(3, String.class, "createTime", false, "CREATE_TIME"); - public final static Property Status = new Property(4, String.class, "status", false, "STATUS"); - public final static Property CreateUserName = new Property(5, String.class, "createUserName", false, "CREATE_USER_NAME"); - public final static Property StartTime = new Property(6, String.class, "startTime", false, "START_TIME"); - public final static Property EndTime = new Property(7, String.class, "endTime", false, "END_TIME"); - public final static Property IsFreeTask = new Property(8, String.class, "isFreeTask", false, "IS_FREE_TASK"); - } - - - public TaskLocalBeanDao(DaoConfig config) { - super(config); - } - - public TaskLocalBeanDao(DaoConfig config, DaoSession daoSession) { - super(config, daoSession); - } - - /** Creates the underlying database table. */ - public static void createTable(Database db, boolean ifNotExists) { - String constraint = ifNotExists? "IF NOT EXISTS ": ""; - db.execSQL("CREATE TABLE " + constraint + "\"TASK_LOCAL_BEAN\" (" + // - "\"_id\" INTEGER PRIMARY KEY ," + // 0: id - "\"TASK_CODE\" TEXT," + // 1: taskCode - "\"DESCRIPTION\" TEXT," + // 2: description - "\"CREATE_TIME\" TEXT," + // 3: createTime - "\"STATUS\" TEXT," + // 4: status - "\"CREATE_USER_NAME\" TEXT," + // 5: createUserName - "\"START_TIME\" TEXT," + // 6: startTime - "\"END_TIME\" TEXT," + // 7: endTime - "\"IS_FREE_TASK\" TEXT);"); // 8: isFreeTask - } - - /** Drops the underlying database table. */ - public static void dropTable(Database db, boolean ifExists) { - String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"TASK_LOCAL_BEAN\""; - db.execSQL(sql); - } - - @Override - protected final void bindValues(DatabaseStatement stmt, TaskLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String taskCode = entity.getTaskCode(); - if (taskCode != null) { - stmt.bindString(2, taskCode); - } - - String description = entity.getDescription(); - if (description != null) { - stmt.bindString(3, description); - } - - String createTime = entity.getCreateTime(); - if (createTime != null) { - stmt.bindString(4, createTime); - } - - String status = entity.getStatus(); - if (status != null) { - stmt.bindString(5, status); - } - - String createUserName = entity.getCreateUserName(); - if (createUserName != null) { - stmt.bindString(6, createUserName); - } - - String startTime = entity.getStartTime(); - if (startTime != null) { - stmt.bindString(7, startTime); - } - - String endTime = entity.getEndTime(); - if (endTime != null) { - stmt.bindString(8, endTime); - } - - String isFreeTask = entity.getIsFreeTask(); - if (isFreeTask != null) { - stmt.bindString(9, isFreeTask); - } - } - - @Override - protected final void bindValues(SQLiteStatement stmt, TaskLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String taskCode = entity.getTaskCode(); - if (taskCode != null) { - stmt.bindString(2, taskCode); - } - - String description = entity.getDescription(); - if (description != null) { - stmt.bindString(3, description); - } - - String createTime = entity.getCreateTime(); - if (createTime != null) { - stmt.bindString(4, createTime); - } - - String status = entity.getStatus(); - if (status != null) { - stmt.bindString(5, status); - } - - String createUserName = entity.getCreateUserName(); - if (createUserName != null) { - stmt.bindString(6, createUserName); - } - - String startTime = entity.getStartTime(); - if (startTime != null) { - stmt.bindString(7, startTime); - } - - String endTime = entity.getEndTime(); - if (endTime != null) { - stmt.bindString(8, endTime); - } - - String isFreeTask = entity.getIsFreeTask(); - if (isFreeTask != null) { - stmt.bindString(9, isFreeTask); - } - } - - @Override - public Long readKey(Cursor cursor, int offset) { - return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); - } - - @Override - public TaskLocalBean readEntity(Cursor cursor, int offset) { - TaskLocalBean entity = new TaskLocalBean( // - cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // taskCode - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // description - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // createTime - cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // status - cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // createUserName - cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // startTime - cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // endTime - cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8) // isFreeTask - ); - return entity; - } - - @Override - public void readEntity(Cursor cursor, TaskLocalBean entity, int offset) { - entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setTaskCode(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); - entity.setDescription(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); - entity.setCreateTime(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); - entity.setStatus(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); - entity.setCreateUserName(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); - entity.setStartTime(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); - entity.setEndTime(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); - entity.setIsFreeTask(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); - } - - @Override - protected final Long updateKeyAfterInsert(TaskLocalBean entity, long rowId) { - entity.setId(rowId); - return rowId; - } - - @Override - public Long getKey(TaskLocalBean entity) { - if(entity != null) { - return entity.getId(); - } else { - return null; - } - } - - @Override - public boolean hasKey(TaskLocalBean entity) { - return entity.getId() != null; - } - - @Override - protected final boolean isEntityUpdateable() { - return true; - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/TaskMarkerLocalBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/greendao/TaskMarkerLocalBeanDao.java deleted file mode 100644 index e96c735..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/TaskMarkerLocalBeanDao.java +++ /dev/null @@ -1,197 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import android.database.Cursor; -import android.database.sqlite.SQLiteStatement; - -import org.greenrobot.greendao.AbstractDao; -import org.greenrobot.greendao.Property; -import org.greenrobot.greendao.internal.DaoConfig; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.database.DatabaseStatement; - -import com.casic.common.detector.gd.bean.TaskMarkerLocalBean; - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** - * DAO for table "TASK_MARKER_LOCAL_BEAN". -*/ -public class TaskMarkerLocalBeanDao extends AbstractDao { - - public static final String TABLENAME = "TASK_MARKER_LOCAL_BEAN"; - - /** - * Properties of entity TaskMarkerLocalBean.
- * Can be used for QueryBuilder and for referencing column names. - */ - public static class Properties { - public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property TaskId = new Property(1, String.class, "taskId", false, "TASK_ID"); - public final static Property TaskCode = new Property(2, String.class, "taskCode", false, "TASK_CODE"); - public final static Property MarkerId = new Property(3, String.class, "markerId", false, "MARKER_ID"); - public final static Property Lng = new Property(4, double.class, "lng", false, "LNG"); - public final static Property Lat = new Property(5, double.class, "lat", false, "LAT"); - public final static Property IsDetected = new Property(6, String.class, "isDetected", false, "IS_DETECTED"); - public final static Property DetectedTime = new Property(7, String.class, "detectedTime", false, "DETECTED_TIME"); - } - - - public TaskMarkerLocalBeanDao(DaoConfig config) { - super(config); - } - - public TaskMarkerLocalBeanDao(DaoConfig config, DaoSession daoSession) { - super(config, daoSession); - } - - /** Creates the underlying database table. */ - public static void createTable(Database db, boolean ifNotExists) { - String constraint = ifNotExists? "IF NOT EXISTS ": ""; - db.execSQL("CREATE TABLE " + constraint + "\"TASK_MARKER_LOCAL_BEAN\" (" + // - "\"_id\" INTEGER PRIMARY KEY ," + // 0: id - "\"TASK_ID\" TEXT," + // 1: taskId - "\"TASK_CODE\" TEXT," + // 2: taskCode - "\"MARKER_ID\" TEXT," + // 3: markerId - "\"LNG\" REAL NOT NULL ," + // 4: lng - "\"LAT\" REAL NOT NULL ," + // 5: lat - "\"IS_DETECTED\" TEXT," + // 6: isDetected - "\"DETECTED_TIME\" TEXT);"); // 7: detectedTime - } - - /** Drops the underlying database table. */ - public static void dropTable(Database db, boolean ifExists) { - String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"TASK_MARKER_LOCAL_BEAN\""; - db.execSQL(sql); - } - - @Override - protected final void bindValues(DatabaseStatement stmt, TaskMarkerLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String taskId = entity.getTaskId(); - if (taskId != null) { - stmt.bindString(2, taskId); - } - - String taskCode = entity.getTaskCode(); - if (taskCode != null) { - stmt.bindString(3, taskCode); - } - - String markerId = entity.getMarkerId(); - if (markerId != null) { - stmt.bindString(4, markerId); - } - stmt.bindDouble(5, entity.getLng()); - stmt.bindDouble(6, entity.getLat()); - - String isDetected = entity.getIsDetected(); - if (isDetected != null) { - stmt.bindString(7, isDetected); - } - - String detectedTime = entity.getDetectedTime(); - if (detectedTime != null) { - stmt.bindString(8, detectedTime); - } - } - - @Override - protected final void bindValues(SQLiteStatement stmt, TaskMarkerLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String taskId = entity.getTaskId(); - if (taskId != null) { - stmt.bindString(2, taskId); - } - - String taskCode = entity.getTaskCode(); - if (taskCode != null) { - stmt.bindString(3, taskCode); - } - - String markerId = entity.getMarkerId(); - if (markerId != null) { - stmt.bindString(4, markerId); - } - stmt.bindDouble(5, entity.getLng()); - stmt.bindDouble(6, entity.getLat()); - - String isDetected = entity.getIsDetected(); - if (isDetected != null) { - stmt.bindString(7, isDetected); - } - - String detectedTime = entity.getDetectedTime(); - if (detectedTime != null) { - stmt.bindString(8, detectedTime); - } - } - - @Override - public Long readKey(Cursor cursor, int offset) { - return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); - } - - @Override - public TaskMarkerLocalBean readEntity(Cursor cursor, int offset) { - TaskMarkerLocalBean entity = new TaskMarkerLocalBean( // - cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // taskId - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // taskCode - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // markerId - cursor.getDouble(offset + 4), // lng - cursor.getDouble(offset + 5), // lat - cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // isDetected - cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7) // detectedTime - ); - return entity; - } - - @Override - public void readEntity(Cursor cursor, TaskMarkerLocalBean entity, int offset) { - entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setTaskId(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); - entity.setTaskCode(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); - entity.setMarkerId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); - entity.setLng(cursor.getDouble(offset + 4)); - entity.setLat(cursor.getDouble(offset + 5)); - entity.setIsDetected(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); - entity.setDetectedTime(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); - } - - @Override - protected final Long updateKeyAfterInsert(TaskMarkerLocalBean entity, long rowId) { - entity.setId(rowId); - return rowId; - } - - @Override - public Long getKey(TaskMarkerLocalBean entity) { - if(entity != null) { - return entity.getId(); - } else { - return null; - } - } - - @Override - public boolean hasKey(TaskMarkerLocalBean entity) { - return entity.getId() != null; - } - - @Override - protected final boolean isEntityUpdateable() { - return true; - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/model/TaskModel.java b/app/src/main/java/com/casic/common/detector/gd/model/TaskModel.java index 6e853ad..67ef5fb 100644 --- a/app/src/main/java/com/casic/common/detector/gd/model/TaskModel.java +++ b/app/src/main/java/com/casic/common/detector/gd/model/TaskModel.java @@ -24,7 +24,7 @@ } public static class MessageModel { - private int id; + private Long id; private String taskCode; private String description; private String deployDate; @@ -38,11 +38,11 @@ private int isValid; private List taskDetailInfos; - public int getId() { + public Long getId() { return id; } - public void setId(int id) { + public void setId(Long id) { this.id = id; } @@ -143,25 +143,25 @@ } public static class TaskDetailInfosModel { - private int id; + private long id; private String taskId; private String taskCode; private Object markerName; - private int markerId; + private String markerId; private String markerIdReal; private double longitude; private double latitude; private int isChecked; private int isNormal; - private Object imagePath; - private Object description; - private Object finishTime; + private String imagePath; + private String description; + private String finishTime; - public int getId() { + public long getId() { return id; } - public void setId(int id) { + public void setId(long id) { this.id = id; } @@ -189,11 +189,11 @@ this.markerName = markerName; } - public int getMarkerId() { + public String getMarkerId() { return markerId; } - public void setMarkerId(int markerId) { + public void setMarkerId(String markerId) { this.markerId = markerId; } @@ -237,27 +237,27 @@ this.isNormal = isNormal; } - public Object getImagePath() { + public String getImagePath() { return imagePath; } - public void setImagePath(Object imagePath) { + public void setImagePath(String imagePath) { this.imagePath = imagePath; } - public Object getDescription() { + public String getDescription() { return description; } - public void setDescription(Object description) { + public void setDescription(String description) { this.description = description; } - public Object getFinishTime() { + public String getFinishTime() { return finishTime; } - public void setFinishTime(Object finishTime) { + public void setFinishTime(String finishTime) { this.finishTime = finishTime; } } diff --git a/app/build.gradle b/app/build.gradle index d0cb423..921c8c8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,25 +1,20 @@ import java.text.SimpleDateFormat -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply plugin: 'org.greenrobot.greendao' +plugins { + id('com.android.application') + id('org.jetbrains.kotlin.android') +} android { - compileSdkVersion 33 + namespace 'com.casic.common.detector.gd' + compileSdk 35 defaultConfig { - applicationId "com.casic.common.detector.gd" - minSdkVersion 26 - targetSdkVersion 33 + applicationId 'com.casic.common.detector.gd' + minSdk 26 + targetSdk 35 versionCode 5092 - versionName "5.0.9.2" - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } + versionName '5.0.9.2' } signingConfigs { @@ -31,6 +26,14 @@ } } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + signingConfig signingConfigs.release + } + } + compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 @@ -47,27 +50,16 @@ } } - kotlin { - experimental { - coroutines 'enable' - } - } - buildFeatures { + buildConfig true viewBinding true } - applicationVariants.configureEach { variant -> - variant.outputs.configureEach { - outputFileName = "COM_TCY_" + getBuildDate() + "_" + defaultConfig.versionName + ".apk" + applicationVariants.configureEach { + outputs.configureEach { + outputFileName = 'COM_TCY_' + getBuildDate() + '_' + defaultConfig.versionName + '.apk' } } - - greendao { - schemaVersion 1//数据库版本号 - targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 - daoPackage "${defaultConfig.applicationId}.greendao"//设置DaoMaster、DaoSession、Dao包名 - } } static def getBuildDate() { @@ -76,27 +68,22 @@ } dependencies { - //基础依赖库 - implementation 'com.github.AndroidCoderPeng:Kotlin-lite-lib:1.1.4' - implementation 'androidx.core:core-ktx:1.9.0' - def base_version = "1.6.1" - implementation "androidx.appcompat:appcompat:${base_version}" - implementation "com.google.android.material:material:${base_version}" + implementation 'com.github.AndroidCoderPeng:Kotlin-lite-lib:1.1.5' + implementation 'androidx.core:core-ktx:1.13.1' + implementation 'androidx.appcompat:appcompat:1.7.0' + implementation 'com.google.android.material:material:1.12.0' //Google官方授权框架 implementation 'pub.devrel:easypermissions:3.0.0' - //沉浸式状态栏。基础依赖包,必须要依赖 - implementation 'com.gyf.immersionbar:immersionbar:3.0.0' - //fragment快速实现 - implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0' + //沉浸式状态栏 + implementation 'com.geyifeng.immersionbar:immersionbar:3.2.2' //官方Json解析库 implementation 'com.google.code.gson:gson:2.10.1' - def vm_version = '2.5.1' //Kotlin协程 - implementation "androidx.lifecycle:lifecycle-runtime-ktx:${vm_version}" + implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.2' //MVVM+LiveData - implementation "androidx.lifecycle:lifecycle-livedata-ktx:${vm_version}" - implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:${vm_version}" - implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.6.2' + implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2' + implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' //返回值转换器 implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' @@ -105,9 +92,10 @@ implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' //网络请求和接口封装 implementation 'com.squareup.retrofit2:retrofit:2.9.0' - implementation 'com.squareup.okhttp3:okhttp:4.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.12.0' //数据库框架 - implementation 'org.greenrobot:greendao:3.3.0' + implementation 'androidx.room:room-runtime:2.6.1' + annotationProcessor 'androidx.room:room-compiler:2.5.2' //高德导航、定位、地图三合一 implementation 'com.amap.api:navi-3dmap:latest.integration' //经纬度逆编码 @@ -115,7 +103,7 @@ //excel implementation 'net.sourceforge.jexcelapi:jxl:2.6.12' //图片加载框架 - implementation 'com.github.bumptech.glide:glide:4.9.0' + implementation 'com.github.bumptech.glide:glide:4.12.0' //图片选择框架 implementation 'io.github.lucksiege:pictureselector:v3.11.1' //大图 diff --git a/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt b/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt index 7b695ff..50ba734 100644 --- a/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt +++ b/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt @@ -4,9 +4,9 @@ import android.app.Application import android.os.Bundle import android.util.Log -import com.casic.common.detector.gd.greendao.DaoMaster -import com.casic.common.detector.gd.greendao.DaoSession +import androidx.room.Room.databaseBuilder import com.casic.common.detector.gd.uart.SerialPort +import com.casic.common.detector.gd.utils.DetectorDataBase import com.casic.common.detector.gd.utils.GpioManager import com.pengxh.kt.lite.extensions.show import com.pengxh.kt.lite.utils.SaveKeyValues @@ -43,44 +43,42 @@ private var application: BaseApplication by Delegates.notNull() fun get() = application - - private lateinit var daoSession: DaoSession } + lateinit var dataBase: DetectorDataBase + override fun onCreate() { super.onCreate() application = this SaveKeyValues.initSharedPreferences(this) CrashReport.initCrashReport(this, "01e80d3a74", true) - val devOpenHelper = DaoMaster.DevOpenHelper(this, "Detector.db", null) - val daoMaster = DaoMaster(devOpenHelper.writableDatabase) - daoSession = daoMaster.newSession() + dataBase = databaseBuilder(this, DetectorDataBase::class.java, "Detector.db") + .allowMainThreadQueries() + .build() /** * Open the serial port * */ try { serialPorts.apply { - add(SerialPort(File("/dev/ttysWK1"), 9600, 0)) - //千寻报文数据下发串口号 - add(SerialPort(File("/dev/ttyS1"), 9600, 0)) + add(SerialPort(File("/dev/ttysWK1"), 9600, 0)) //信号通讯串口 + add(SerialPort(File("/dev/ttyS1"), 9600, 0)) //千寻报文数据下发串口号 } Log.d(kTag, "onCreate: 已初始化 ${serialPorts.size} 个串口") } catch (e: SecurityException) { "您没有串口的读写权限!".show(this) + e.printStackTrace() } catch (e: IOException) { "因为不明原因,串口无法打开!".show(this) + e.printStackTrace() } catch (e: InvalidParameterException) { "请检查串口!".show(this) + e.printStackTrace() } registerActivityLifecycleCallbacks(this) } - fun getDaoSession(): DaoSession { - return daoSession - } - override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) { } diff --git a/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt b/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt index 053b9dd..1d0c9e3 100644 --- a/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt +++ b/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt @@ -14,12 +14,10 @@ import com.casic.common.detector.gd.utils.SerialPortCommand import com.pengxh.kt.lite.utils.WeakReferenceHandler import java.io.IOException -import java.util.Timer abstract class SerialPortBaseActivity : AppCompatActivity(), Handler.Callback { private val kTag = "SerialPortBaseActivity" - private val taskTimer by lazy { Timer() } private val weakReferenceHandler by lazy { WeakReferenceHandler(this) } private val serialPorts by lazy { BaseApplication.get().getSerialPorts() } protected lateinit var binding: VB @@ -30,7 +28,6 @@ setContentView(binding.root) setupTopBarLayout() initOnCreate(savedInstanceState) - observeRequestState() initEvent() if (serialPorts.isNotEmpty()) { @@ -71,11 +68,6 @@ abstract fun initOnCreate(savedInstanceState: Bundle?) /** - * 数据请求状态监听 - */ - abstract fun observeRequestState() - - /** * 初始化业务逻辑 */ abstract fun initEvent() diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java new file mode 100644 index 0000000..7a18c20 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java @@ -0,0 +1,255 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 从平台下载的标识器本地库实体类 + */ +@Entity(tableName = "marker_detail") +public class MarkerBean { + @PrimaryKey(autoGenerate = true) + private long id; //主键ID + private String pipelineType; // 管线类型 + private String pipelineDiameter; // 管线直径 + private String pipelineMaterial; // 管材 + private String buryMethod; // 埋设方式 + private String buryDepth; // 埋深 + private String area; // 所属区域 + private String line; // 所属线路 + private String road; // 所属道路 + private String constructTime; // 建设年代 + private String owner; // 权属单位 + private String objectId; // 标识对象ID,无实际用途 + private String markerId; // 标识器ID + private String markerType; // 标识器类型 + private String markerDepth; // 标识器埋深 + private String installationDept; // 安装部门 + private String lng; // 经度 + private String lat; // 纬度 + private String updateTime; // 最后修改时间,更新时间 + private String remark; // 备注信息 + private String underlyingPipelineType; // 下层管线类型 + private String underlyingPipelineDepth; // 下层埋深 + private String underlyingPipelineDiameter; // 下层管径 + private String underlyingPipelineMaterial; // 下层管材 + private String objectType; //标识对象类型 + private String color; // 颜色 + private String imagePath; // 图片路径 + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getPipelineType() { + return pipelineType; + } + + public void setPipelineType(String pipelineType) { + this.pipelineType = pipelineType; + } + + public String getPipelineDiameter() { + return pipelineDiameter; + } + + public void setPipelineDiameter(String pipelineDiameter) { + this.pipelineDiameter = pipelineDiameter; + } + + public String getPipelineMaterial() { + return pipelineMaterial; + } + + public void setPipelineMaterial(String pipelineMaterial) { + this.pipelineMaterial = pipelineMaterial; + } + + public String getBuryMethod() { + return buryMethod; + } + + public void setBuryMethod(String buryMethod) { + this.buryMethod = buryMethod; + } + + public String getBuryDepth() { + return buryDepth; + } + + public void setBuryDepth(String buryDepth) { + this.buryDepth = buryDepth; + } + + public String getArea() { + return area; + } + + public void setArea(String area) { + this.area = area; + } + + public String getLine() { + return line; + } + + public void setLine(String line) { + this.line = line; + } + + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + + public String getConstructTime() { + return constructTime; + } + + public void setConstructTime(String constructTime) { + this.constructTime = constructTime; + } + + public String getOwner() { + return owner; + } + + public void setOwner(String owner) { + this.owner = owner; + } + + public String getObjectId() { + return objectId; + } + + public void setObjectId(String objectId) { + this.objectId = objectId; + } + + public String getMarkerId() { + return markerId; + } + + public void setMarkerId(String markerId) { + this.markerId = markerId; + } + + public String getMarkerType() { + return markerType; + } + + public void setMarkerType(String markerType) { + this.markerType = markerType; + } + + public String getMarkerDepth() { + return markerDepth; + } + + public void setMarkerDepth(String markerDepth) { + this.markerDepth = markerDepth; + } + + public String getInstallationDept() { + return installationDept; + } + + public void setInstallationDept(String installationDept) { + this.installationDept = installationDept; + } + + public String getLng() { + return lng; + } + + public void setLng(String lng) { + this.lng = lng; + } + + public String getLat() { + return lat; + } + + public void setLat(String lat) { + this.lat = lat; + } + + public String getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } + + public String getUnderlyingPipelineType() { + return underlyingPipelineType; + } + + public void setUnderlyingPipelineType(String underlyingPipelineType) { + this.underlyingPipelineType = underlyingPipelineType; + } + + public String getUnderlyingPipelineDepth() { + return underlyingPipelineDepth; + } + + public void setUnderlyingPipelineDepth(String underlyingPipelineDepth) { + this.underlyingPipelineDepth = underlyingPipelineDepth; + } + + public String getUnderlyingPipelineDiameter() { + return underlyingPipelineDiameter; + } + + public void setUnderlyingPipelineDiameter(String underlyingPipelineDiameter) { + this.underlyingPipelineDiameter = underlyingPipelineDiameter; + } + + public String getUnderlyingPipelineMaterial() { + return underlyingPipelineMaterial; + } + + public void setUnderlyingPipelineMaterial(String underlyingPipelineMaterial) { + this.underlyingPipelineMaterial = underlyingPipelineMaterial; + } + + public String getObjectType() { + return objectType; + } + + public void setObjectType(String objectType) { + this.objectType = objectType; + } + + public String getColor() { + return color; + } + + public void setColor(String color) { + this.color = color; + } + + public String getImagePath() { + return imagePath; + } + + public void setImagePath(String imagePath) { + this.imagePath = imagePath; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java deleted file mode 100644 index 3f2fcdc..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java +++ /dev/null @@ -1,327 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 从平台下载的标识器本地库实体类 - */ -@Entity -public class MarkerLocalBean { - @Id(autoincrement = true) - private Long id;//本地库主键ID - - // 管线类型 - private String pipelineType; - // 管线直径 - private String pipelineDiameter; - // 管材 - private String pipelineMaterial; - // 埋设方式 - private String buryMethod; - // 埋深 - private String buryDepth; - // 所属区域 - private String area; - // 所属线路 - private String line; - // 所属道路 - private String road; - // 建设年代 - private String constructTime; - // 权属单位 - private String owner; - //标识对象ID,无实际用途 - @Deprecated - private String objectId; - // 标识器ID - private String markerId; - // 标识器类型 - private String markerType; - // 标识器埋深 - private String markerDepth; - // 安装部门 - private String installationDept; - // 经度 - private String lng; - // 纬度 - private String lat; - //最后修改时间,更新时间 - private String updateTime; - // 备注信息 - private String remark; - // 下层管线类型 - private String underlyingPipelineType; - // 下层埋深 - private String underlyingPipelineDepth; - // 下层管径 - private String underlyingPipelineDiameter; - // 下层管材 - private String underlyingPipelineMaterial; - //标识对象类型 - private String objectType; - // 颜色 - private String color; - // 图片路径 - private String imagePath; - - @Generated(hash = 1479045776) - public MarkerLocalBean(Long id, String pipelineType, String pipelineDiameter, - String pipelineMaterial, String buryMethod, String buryDepth, - String area, String line, String road, String constructTime, - String owner, String objectId, String markerId, String markerType, - String markerDepth, String installationDept, String lng, String lat, - String updateTime, String remark, String underlyingPipelineType, - String underlyingPipelineDepth, String underlyingPipelineDiameter, - String underlyingPipelineMaterial, String objectType, String color, - String imagePath) { - this.id = id; - this.pipelineType = pipelineType; - this.pipelineDiameter = pipelineDiameter; - this.pipelineMaterial = pipelineMaterial; - this.buryMethod = buryMethod; - this.buryDepth = buryDepth; - this.area = area; - this.line = line; - this.road = road; - this.constructTime = constructTime; - this.owner = owner; - this.objectId = objectId; - this.markerId = markerId; - this.markerType = markerType; - this.markerDepth = markerDepth; - this.installationDept = installationDept; - this.lng = lng; - this.lat = lat; - this.updateTime = updateTime; - this.remark = remark; - this.underlyingPipelineType = underlyingPipelineType; - this.underlyingPipelineDepth = underlyingPipelineDepth; - this.underlyingPipelineDiameter = underlyingPipelineDiameter; - this.underlyingPipelineMaterial = underlyingPipelineMaterial; - this.objectType = objectType; - this.color = color; - this.imagePath = imagePath; - } - - @Generated(hash = 1538606012) - public MarkerLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getPipelineType() { - return this.pipelineType; - } - - public void setPipelineType(String pipelineType) { - this.pipelineType = pipelineType; - } - - public String getPipelineDiameter() { - return this.pipelineDiameter; - } - - public void setPipelineDiameter(String pipelineDiameter) { - this.pipelineDiameter = pipelineDiameter; - } - - public String getPipelineMaterial() { - return this.pipelineMaterial; - } - - public void setPipelineMaterial(String pipelineMaterial) { - this.pipelineMaterial = pipelineMaterial; - } - - public String getBuryMethod() { - return this.buryMethod; - } - - public void setBuryMethod(String buryMethod) { - this.buryMethod = buryMethod; - } - - public String getBuryDepth() { - return this.buryDepth; - } - - public void setBuryDepth(String buryDepth) { - this.buryDepth = buryDepth; - } - - public String getArea() { - return this.area; - } - - public void setArea(String area) { - this.area = area; - } - - public String getLine() { - return this.line; - } - - public void setLine(String line) { - this.line = line; - } - - public String getRoad() { - return this.road; - } - - public void setRoad(String road) { - this.road = road; - } - - public String getConstructTime() { - return this.constructTime; - } - - public void setConstructTime(String constructTime) { - this.constructTime = constructTime; - } - - public String getOwner() { - return this.owner; - } - - public void setOwner(String owner) { - this.owner = owner; - } - - public String getObjectId() { - return this.objectId; - } - - public void setObjectId(String objectId) { - this.objectId = objectId; - } - - public String getMarkerId() { - return this.markerId; - } - - public void setMarkerId(String markerId) { - this.markerId = markerId; - } - - public String getMarkerType() { - return this.markerType; - } - - public void setMarkerType(String markerType) { - this.markerType = markerType; - } - - public String getMarkerDepth() { - return this.markerDepth; - } - - public void setMarkerDepth(String markerDepth) { - this.markerDepth = markerDepth; - } - - public String getInstallationDept() { - return this.installationDept; - } - - public void setInstallationDept(String installationDept) { - this.installationDept = installationDept; - } - - public String getLng() { - return this.lng; - } - - public void setLng(String lng) { - this.lng = lng; - } - - public String getLat() { - return this.lat; - } - - public void setLat(String lat) { - this.lat = lat; - } - - public String getUpdateTime() { - return this.updateTime; - } - - public void setUpdateTime(String updateTime) { - this.updateTime = updateTime; - } - - public String getRemark() { - return this.remark; - } - - public void setRemark(String remark) { - this.remark = remark; - } - - public String getUnderlyingPipelineType() { - return this.underlyingPipelineType; - } - - public void setUnderlyingPipelineType(String underlyingPipelineType) { - this.underlyingPipelineType = underlyingPipelineType; - } - - public String getUnderlyingPipelineDepth() { - return this.underlyingPipelineDepth; - } - - public void setUnderlyingPipelineDepth(String underlyingPipelineDepth) { - this.underlyingPipelineDepth = underlyingPipelineDepth; - } - - public String getUnderlyingPipelineDiameter() { - return this.underlyingPipelineDiameter; - } - - public void setUnderlyingPipelineDiameter(String underlyingPipelineDiameter) { - this.underlyingPipelineDiameter = underlyingPipelineDiameter; - } - - public String getUnderlyingPipelineMaterial() { - return this.underlyingPipelineMaterial; - } - - public void setUnderlyingPipelineMaterial(String underlyingPipelineMaterial) { - this.underlyingPipelineMaterial = underlyingPipelineMaterial; - } - - public String getObjectType() { - return this.objectType; - } - - public void setObjectType(String objectType) { - this.objectType = objectType; - } - - public String getColor() { - return this.color; - } - - public void setColor(String color) { - this.color = color; - } - - public String getImagePath() { - return this.imagePath; - } - - public void setImagePath(String imagePath) { - this.imagePath = imagePath; - } -} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java new file mode 100644 index 0000000..5c88fdf --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java @@ -0,0 +1,93 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 巡检任务本地库实体类,不包含任务里面需要巡检的标识器信息 + */ +@Entity(tableName = "task_detail") +public class TaskBean { + @PrimaryKey(autoGenerate = true) + private long id;//主键ID + private String taskCode; // 任务编号 + private String description; // 任务名称 + private String createTime; // 任务创建的时间 + private String status; // 任务状态 + private String createUserName; // 任务创建者名称 + private String startTime; // 任务被开始执行的时间 + private String endTime; // 任务执行结束的时间 + private String isFree; // 是否自由巡检。1-是,0-否 + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getTaskCode() { + return taskCode; + } + + public void setTaskCode(String taskCode) { + this.taskCode = taskCode; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getCreateUserName() { + return createUserName; + } + + public void setCreateUserName(String createUserName) { + this.createUserName = createUserName; + } + + public String getStartTime() { + return startTime; + } + + public void setStartTime(String startTime) { + this.startTime = startTime; + } + + public String getEndTime() { + return endTime; + } + + public void setEndTime(String endTime) { + this.endTime = endTime; + } + + public String getIsFree() { + return isFree; + } + + public void setIsFree(String isFree) { + this.isFree = isFree; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java deleted file mode 100644 index 91737b3..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java +++ /dev/null @@ -1,114 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 巡检任务本地库实体类,不包含任务里面需要巡检的标识器信息 - */ -@Entity -public class TaskLocalBean { - @Id - private Long id;//任务ID - - private String taskCode;//任务编号 - private String description;//任务名称 - private String createTime;//任务创建的时间 - private String status;//任务状态 - private String createUserName;//任务创建者名称 - private String startTime;//任务被开始执行的时间 - private String endTime;//任务执行结束的时间 - private String isFreeTask;//是否自由巡检。1-是,0-否 - - @Generated(hash = 1482022528) - public TaskLocalBean(Long id, String taskCode, String description, - String createTime, String status, String createUserName, - String startTime, String endTime, String isFreeTask) { - this.id = id; - this.taskCode = taskCode; - this.description = description; - this.createTime = createTime; - this.status = status; - this.createUserName = createUserName; - this.startTime = startTime; - this.endTime = endTime; - this.isFreeTask = isFreeTask; - } - - @Generated(hash = 949704588) - public TaskLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getTaskCode() { - return this.taskCode; - } - - public void setTaskCode(String taskCode) { - this.taskCode = taskCode; - } - - public String getDescription() { - return this.description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getCreateTime() { - return this.createTime; - } - - public void setCreateTime(String createTime) { - this.createTime = createTime; - } - - public String getStatus() { - return this.status; - } - - public void setStatus(String status) { - this.status = status; - } - - public String getCreateUserName() { - return this.createUserName; - } - - public void setCreateUserName(String createUserName) { - this.createUserName = createUserName; - } - - public String getStartTime() { - return this.startTime; - } - - public void setStartTime(String startTime) { - this.startTime = startTime; - } - - public String getEndTime() { - return this.endTime; - } - - public void setEndTime(String endTime) { - this.endTime = endTime; - } - - public String getIsFreeTask() { - return this.isFreeTask; - } - - public void setIsFreeTask(String isFreeTask) { - this.isFreeTask = isFreeTask; - } -} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerBean.java new file mode 100644 index 0000000..c563a60 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerBean.java @@ -0,0 +1,110 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 巡检任务里面需要巡检的标识器信息本地库实体类 + */ +@Entity(tableName = "task_marker_info") +public class TaskMarkerBean { + //标识器后台库的主键ID,不是标识器实际ID + @PrimaryKey(autoGenerate = true) + private long id; + + /** + * 任务ID,通过此字段关联[TaskBean.id] + */ + private String taskId; + + /** + * 任务Code,通过此字段关联[TaskBean.taskCode] + *

+ *

+ * 双重验证,防止出现同时刻重复的情况 + */ + private String taskCode; + + /** + * 对应后台字段[TaskModel.MessageModel.TaskDetailInfosModel.markerIdReal],也就是探测仪扫描出来的ID + */ + private String markerId; + + private Double lng; + private Double lat; + + /** + * 是否已被探测到 + * 1-是,0-否 + */ + private String isDetected; + + /** + * 被探测到的时间,对应后台字段[TaskModel.MessageModel.TaskDetailInfosModel.finishTime] + */ + private String detectedTime; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getTaskId() { + return taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getTaskCode() { + return taskCode; + } + + public void setTaskCode(String taskCode) { + this.taskCode = taskCode; + } + + public String getMarkerId() { + return markerId; + } + + public void setMarkerId(String markerId) { + this.markerId = markerId; + } + + public Double getLng() { + return lng; + } + + public void setLng(Double lng) { + this.lng = lng; + } + + public Double getLat() { + return lat; + } + + public void setLat(Double lat) { + this.lat = lat; + } + + public String getIsDetected() { + return isDetected; + } + + public void setIsDetected(String isDetected) { + this.isDetected = isDetected; + } + + public String getDetectedTime() { + return detectedTime; + } + + public void setDetectedTime(String detectedTime) { + this.detectedTime = detectedTime; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerLocalBean.java deleted file mode 100644 index de9f459..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerLocalBean.java +++ /dev/null @@ -1,128 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import com.casic.common.detector.gd.model.TaskModel; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 巡检任务里面需要巡检的标识器信息本地库实体类 - */ -@Entity -public class TaskMarkerLocalBean { - @Id - private Long id;//标识器后台库的主键ID,不是标识器实际ID - - /** - * 任务ID,通过此字段关联{@link TaskLocalBean#id} - */ - private String taskId; - - /** - * 任务Code,通过此字段关联{@link TaskLocalBean#taskCode} - *

- * 双重验证,防止出现同时刻重复的情况 - */ - private String taskCode; - - /** - * 对应后台字段{@link TaskModel.MessageModel.TaskDetailInfosModel#markerIdReal},也就是探测仪扫描出来的ID - */ - private String markerId; - - private double lng; - private double lat; - - /** - * 是否已被探测到 - * 1-是,0-否 - */ - private String isDetected; - - /** - * 被探测到的时间,对应后台字段{@link TaskModel.MessageModel.TaskDetailInfosModel#finishTime} - */ - private String detectedTime; - - @Generated(hash = 677328533) - public TaskMarkerLocalBean(Long id, String taskId, String taskCode, String markerId, - double lng, double lat, String isDetected, String detectedTime) { - this.id = id; - this.taskId = taskId; - this.taskCode = taskCode; - this.markerId = markerId; - this.lng = lng; - this.lat = lat; - this.isDetected = isDetected; - this.detectedTime = detectedTime; - } - - @Generated(hash = 1162404642) - public TaskMarkerLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getTaskId() { - return this.taskId; - } - - public void setTaskId(String taskId) { - this.taskId = taskId; - } - - public String getTaskCode() { - return this.taskCode; - } - - public void setTaskCode(String taskCode) { - this.taskCode = taskCode; - } - - public String getMarkerId() { - return this.markerId; - } - - public void setMarkerId(String markerId) { - this.markerId = markerId; - } - - public double getLng() { - return this.lng; - } - - public void setLng(double lng) { - this.lng = lng; - } - - public double getLat() { - return this.lat; - } - - public void setLat(double lat) { - this.lat = lat; - } - - public String getIsDetected() { - return this.isDetected; - } - - public void setIsDetected(String isDetected) { - this.isDetected = isDetected; - } - - public String getDetectedTime() { - return this.detectedTime; - } - - public void setDetectedTime(String detectedTime) { - this.detectedTime = detectedTime; - } -} diff --git a/app/src/main/java/com/casic/common/detector/gd/dao/MarkerBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/dao/MarkerBeanDao.java new file mode 100644 index 0000000..2beb7ed --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/dao/MarkerBeanDao.java @@ -0,0 +1,29 @@ +package com.casic.common.detector.gd.dao; + +import androidx.room.Dao; +import androidx.room.Insert; +import androidx.room.Query; +import androidx.room.RawQuery; +import androidx.sqlite.db.SupportSQLiteQuery; + +import com.casic.common.detector.gd.bean.MarkerBean; + +import java.util.List; + +@Dao +public interface MarkerBeanDao { + @Query("DELETE FROM marker_detail") + void deleteAll(); + + @Insert + void insert(MarkerBean marker); + + @Query("SELECT * FROM marker_detail") + List loadAll(); + + @Query("SELECT * FROM marker_detail WHERE markerId = :markerId") + List queryMarkerById(String markerId); + + @RawQuery + List loadMarkersByCondition(SupportSQLiteQuery query); +} diff --git a/app/src/main/java/com/casic/common/detector/gd/dao/TaskBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/dao/TaskBeanDao.java new file mode 100644 index 0000000..9c70ac2 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/dao/TaskBeanDao.java @@ -0,0 +1,120 @@ +package com.casic.common.detector.gd.dao; + +import androidx.room.Dao; +import androidx.room.Insert; +import androidx.room.Query; +import androidx.room.Transaction; + +import com.casic.common.detector.gd.bean.TaskBean; +import com.casic.common.detector.gd.bean.TaskMarkerBean; +import com.casic.common.detector.gd.model.TaskDetailLocalModel; +import com.casic.common.detector.gd.model.TaskModel; +import com.casic.common.detector.gd.utils.LocaleConstant; +import com.pengxh.kt.lite.utils.SaveKeyValues; + +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Locale; + +@Dao +public interface TaskBeanDao { + @Query("SELECT COUNT(*) FROM task_detail WHERE id = :taskId") + int isTaskExist(long taskId); + + @Insert + void insert(TaskBean task); + + default void saveTask(Long taskId, String taskName) { + if (isTaskExist(taskId) == 0) { + TaskBean task = new TaskBean(); + task.setId(taskId); + task.setTaskCode(new SimpleDateFormat("yyyyMMddHHmmss", Locale.CHINA).format(new Date())); + task.setDescription(taskName); + String time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA).format(new Date()); + task.setCreateTime(time); + task.setStatus("0"); + String userName = (String) SaveKeyValues.INSTANCE.getValue(LocaleConstant.USER_NAME, ""); + task.setCreateUserName(userName); + task.setStartTime(time); + task.setEndTime(""); + task.setIsFree("1"); + insert(task); + } + } + + default void saveTask(TaskModel.MessageModel model) { + TaskBean task = new TaskBean(); + task.setId(model.getId()); + task.setTaskCode(model.getTaskCode()); + task.setDescription(model.getDescription()); + task.setCreateTime(model.getDeployDate()); + task.setStatus(model.getStatus()); + task.setCreateUserName(model.getCreatorName()); + task.setStartTime(model.getBeginDate()); + task.setEndTime(model.getEndDate()); + task.setIsFree("0"); + if (isTaskExist(task.getId()) == 0) { + insert(task); + } + } + + @Query("SELECT * FROM task_detail") + List loadAll(); + + @Transaction + default ArrayList loadLocalTask(TaskMarkerBeanDao taskMarkerBeanDao) { + ArrayList result = new ArrayList<>(); + List tasks = loadAll(); + for (TaskBean it : tasks) { + TaskDetailLocalModel model = new TaskDetailLocalModel(); + model.setTaskId(String.valueOf(it.getId())); + model.setTaskCode(it.getTaskCode()); + model.setDescription(it.getDescription()); + model.setCreateTime(it.getCreateTime()); + model.setStatus(it.getStatus()); + model.setCreateUserName(it.getCreateUserName()); + model.setIsFreeTask(it.getIsFree()); + ArrayList results = new ArrayList<>(); + if ("0".equals(it.getIsFree())) { + // 非自由巡检才有Marker + List markers = taskMarkerBeanDao.getMarkersByIdAndCode(String.valueOf(it.getId()), it.getTaskCode()); + for (TaskMarkerBean marker : markers) { + TaskDetailLocalModel.TaskMarkerLocalModel localModel = new TaskDetailLocalModel.TaskMarkerLocalModel(); + localModel.setMarkerId(marker.getMarkerId()); + localModel.setLng(marker.getLng()); + localModel.setLat(marker.getLat()); + localModel.setIsDetected(marker.getIsDetected()); + localModel.setDetectedTime(marker.getDetectedTime()); + + results.add(localModel); + } + } + model.setMarkerModels(results); + result.add(model); + } + return result; + } + + @Query("DELETE FROM task_detail WHERE id = :taskId AND taskCode = :taskCode") + void deleteTaskById(long taskId, String taskCode); + + @Transaction + default void deleteLocalTaskById(long taskId, String taskCode, TaskMarkerBeanDao taskMarkerBeanDao) { + TaskBean task = loadAll().stream() + .filter(it -> it.getId() == taskId && taskCode.equals(it.getTaskCode())) + .findFirst() + .orElse(null); + if (task == null) return; + deleteTaskById(taskId, taskCode); + + // 删除此任务关联的Marker。非自由巡检才有Marker + if ("0".equals(task.getIsFree())) { + List markers = taskMarkerBeanDao.getMarkersByIdAndCode(String.valueOf(task.getId()), task.getTaskCode()); + for (TaskMarkerBean marker : markers) { + taskMarkerBeanDao.delete(marker); + } + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/dao/TaskMarkerBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/dao/TaskMarkerBeanDao.java new file mode 100644 index 0000000..cc2156a --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/dao/TaskMarkerBeanDao.java @@ -0,0 +1,52 @@ +package com.casic.common.detector.gd.dao; + +import androidx.room.Dao; +import androidx.room.Delete; +import androidx.room.Insert; +import androidx.room.Query; +import androidx.room.Update; + +import com.casic.common.detector.gd.bean.TaskMarkerBean; +import com.casic.common.detector.gd.model.TaskModel; + +import java.util.List; + +@Dao +public interface TaskMarkerBeanDao { + + @Insert + void insert(TaskMarkerBean marker); + + @Query("SELECT COUNT(*) FROM task_marker_info WHERE id = :markerId") + int isMarkerExist(String markerId); + + default void saveTaskMarker(long taskId, String taskCode, TaskModel.MessageModel.TaskDetailInfosModel marker) { + if (isMarkerExist(marker.getMarkerId()) == 0) { + TaskMarkerBean bean = new TaskMarkerBean(); + bean.setId(marker.getId()); + bean.setTaskId(String.valueOf(taskId)); + bean.setTaskCode(taskCode); + bean.setMarkerId(marker.getMarkerIdReal()); + bean.setLng(marker.getLongitude()); + bean.setLat(marker.getLatitude()); + bean.setIsDetected("0"); + bean.setDetectedTime(""); + insert(bean); + } + } + + @Query("SELECT * FROM task_marker_info WHERE taskId = :taskId AND taskCode = :taskCode AND markerId = :markerId AND isDetected = :state") + TaskMarkerBean queryTaskMarkerById(String taskId, String taskCode, String markerId, String state); + + @Update + void updateLocalTaskMarkerState(TaskMarkerBean marker); + + @Query("SELECT * FROM task_marker_info WHERE isDetected = :state") + List queryMarkerByState(String state); + + @Query("SELECT * FROM task_marker_info WHERE taskId = :taskId AND taskCode = :taskCode") + List getMarkersByIdAndCode(String taskId, String taskCode); + + @Delete + void delete(TaskMarkerBean marker); +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/extensions/Long.kt b/app/src/main/java/com/casic/common/detector/gd/extensions/Long.kt deleted file mode 100644 index 6713d8d..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/extensions/Long.kt +++ /dev/null @@ -1,10 +0,0 @@ -package com.casic.common.detector.gd.extensions - -import java.text.SimpleDateFormat -import java.util.Date -import java.util.Locale - -fun Long.createTaskCode(): String { - val dateFormat = SimpleDateFormat("yyyyMMddHHmmss", Locale.CHINA) - return dateFormat.format(Date(this)) -} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoMaster.java b/app/src/main/java/com/casic/common/detector/gd/greendao/DaoMaster.java deleted file mode 100644 index 6ab94b3..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoMaster.java +++ /dev/null @@ -1,102 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import android.content.Context; -import android.database.sqlite.SQLiteDatabase; -import android.database.sqlite.SQLiteDatabase.CursorFactory; -import android.util.Log; - -import org.greenrobot.greendao.AbstractDaoMaster; -import org.greenrobot.greendao.database.StandardDatabase; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.database.DatabaseOpenHelper; -import org.greenrobot.greendao.identityscope.IdentityScopeType; - - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** - * Master of DAO (schema version 1): knows all DAOs. - */ -public class DaoMaster extends AbstractDaoMaster { - public static final int SCHEMA_VERSION = 1; - - /** Creates underlying database table using DAOs. */ - public static void createAllTables(Database db, boolean ifNotExists) { - MarkerLocalBeanDao.createTable(db, ifNotExists); - TaskLocalBeanDao.createTable(db, ifNotExists); - TaskMarkerLocalBeanDao.createTable(db, ifNotExists); - } - - /** Drops underlying database table using DAOs. */ - public static void dropAllTables(Database db, boolean ifExists) { - MarkerLocalBeanDao.dropTable(db, ifExists); - TaskLocalBeanDao.dropTable(db, ifExists); - TaskMarkerLocalBeanDao.dropTable(db, ifExists); - } - - /** - * WARNING: Drops all table on Upgrade! Use only during development. - * Convenience method using a {@link DevOpenHelper}. - */ - public static DaoSession newDevSession(Context context, String name) { - Database db = new DevOpenHelper(context, name).getWritableDb(); - DaoMaster daoMaster = new DaoMaster(db); - return daoMaster.newSession(); - } - - public DaoMaster(SQLiteDatabase db) { - this(new StandardDatabase(db)); - } - - public DaoMaster(Database db) { - super(db, SCHEMA_VERSION); - registerDaoClass(MarkerLocalBeanDao.class); - registerDaoClass(TaskLocalBeanDao.class); - registerDaoClass(TaskMarkerLocalBeanDao.class); - } - - public DaoSession newSession() { - return new DaoSession(db, IdentityScopeType.Session, daoConfigMap); - } - - public DaoSession newSession(IdentityScopeType type) { - return new DaoSession(db, type, daoConfigMap); - } - - /** - * Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} - - */ - public static abstract class OpenHelper extends DatabaseOpenHelper { - public OpenHelper(Context context, String name) { - super(context, name, SCHEMA_VERSION); - } - - public OpenHelper(Context context, String name, CursorFactory factory) { - super(context, name, factory, SCHEMA_VERSION); - } - - @Override - public void onCreate(Database db) { - Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION); - createAllTables(db, false); - } - } - - /** WARNING: Drops all table on Upgrade! Use only during development. */ - public static class DevOpenHelper extends OpenHelper { - public DevOpenHelper(Context context, String name) { - super(context, name); - } - - public DevOpenHelper(Context context, String name, CursorFactory factory) { - super(context, name, factory); - } - - @Override - public void onUpgrade(Database db, int oldVersion, int newVersion) { - Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables"); - dropAllTables(db, true); - onCreate(db); - } - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoSession.java b/app/src/main/java/com/casic/common/detector/gd/greendao/DaoSession.java deleted file mode 100644 index c8b1a20..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoSession.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import java.util.Map; - -import org.greenrobot.greendao.AbstractDao; -import org.greenrobot.greendao.AbstractDaoSession; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.identityscope.IdentityScopeType; -import org.greenrobot.greendao.internal.DaoConfig; - -import com.casic.common.detector.gd.bean.MarkerLocalBean; -import com.casic.common.detector.gd.bean.TaskLocalBean; -import com.casic.common.detector.gd.bean.TaskMarkerLocalBean; - -import com.casic.common.detector.gd.greendao.MarkerLocalBeanDao; -import com.casic.common.detector.gd.greendao.TaskLocalBeanDao; -import com.casic.common.detector.gd.greendao.TaskMarkerLocalBeanDao; - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. - -/** - * {@inheritDoc} - * - * @see org.greenrobot.greendao.AbstractDaoSession - */ -public class DaoSession extends AbstractDaoSession { - - private final DaoConfig markerLocalBeanDaoConfig; - private final DaoConfig taskLocalBeanDaoConfig; - private final DaoConfig taskMarkerLocalBeanDaoConfig; - - private final MarkerLocalBeanDao markerLocalBeanDao; - private final TaskLocalBeanDao taskLocalBeanDao; - private final TaskMarkerLocalBeanDao taskMarkerLocalBeanDao; - - public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> - daoConfigMap) { - super(db); - - markerLocalBeanDaoConfig = daoConfigMap.get(MarkerLocalBeanDao.class).clone(); - markerLocalBeanDaoConfig.initIdentityScope(type); - - taskLocalBeanDaoConfig = daoConfigMap.get(TaskLocalBeanDao.class).clone(); - taskLocalBeanDaoConfig.initIdentityScope(type); - - taskMarkerLocalBeanDaoConfig = daoConfigMap.get(TaskMarkerLocalBeanDao.class).clone(); - taskMarkerLocalBeanDaoConfig.initIdentityScope(type); - - markerLocalBeanDao = new MarkerLocalBeanDao(markerLocalBeanDaoConfig, this); - taskLocalBeanDao = new TaskLocalBeanDao(taskLocalBeanDaoConfig, this); - taskMarkerLocalBeanDao = new TaskMarkerLocalBeanDao(taskMarkerLocalBeanDaoConfig, this); - - registerDao(MarkerLocalBean.class, markerLocalBeanDao); - registerDao(TaskLocalBean.class, taskLocalBeanDao); - registerDao(TaskMarkerLocalBean.class, taskMarkerLocalBeanDao); - } - - public void clear() { - markerLocalBeanDaoConfig.clearIdentityScope(); - taskLocalBeanDaoConfig.clearIdentityScope(); - taskMarkerLocalBeanDaoConfig.clearIdentityScope(); - } - - public MarkerLocalBeanDao getMarkerLocalBeanDao() { - return markerLocalBeanDao; - } - - public TaskLocalBeanDao getTaskLocalBeanDao() { - return taskLocalBeanDao; - } - - public TaskMarkerLocalBeanDao getTaskMarkerLocalBeanDao() { - return taskMarkerLocalBeanDao; - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/MarkerLocalBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/greendao/MarkerLocalBeanDao.java deleted file mode 100644 index 2f792c3..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/MarkerLocalBeanDao.java +++ /dev/null @@ -1,479 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import android.database.Cursor; -import android.database.sqlite.SQLiteStatement; - -import org.greenrobot.greendao.AbstractDao; -import org.greenrobot.greendao.Property; -import org.greenrobot.greendao.internal.DaoConfig; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.database.DatabaseStatement; - -import com.casic.common.detector.gd.bean.MarkerLocalBean; - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** - * DAO for table "MARKER_LOCAL_BEAN". -*/ -public class MarkerLocalBeanDao extends AbstractDao { - - public static final String TABLENAME = "MARKER_LOCAL_BEAN"; - - /** - * Properties of entity MarkerLocalBean.
- * Can be used for QueryBuilder and for referencing column names. - */ - public static class Properties { - public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property PipelineType = new Property(1, String.class, "pipelineType", false, "PIPELINE_TYPE"); - public final static Property PipelineDiameter = new Property(2, String.class, "pipelineDiameter", false, "PIPELINE_DIAMETER"); - public final static Property PipelineMaterial = new Property(3, String.class, "pipelineMaterial", false, "PIPELINE_MATERIAL"); - public final static Property BuryMethod = new Property(4, String.class, "buryMethod", false, "BURY_METHOD"); - public final static Property BuryDepth = new Property(5, String.class, "buryDepth", false, "BURY_DEPTH"); - public final static Property Area = new Property(6, String.class, "area", false, "AREA"); - public final static Property Line = new Property(7, String.class, "line", false, "LINE"); - public final static Property Road = new Property(8, String.class, "road", false, "ROAD"); - public final static Property ConstructTime = new Property(9, String.class, "constructTime", false, "CONSTRUCT_TIME"); - public final static Property Owner = new Property(10, String.class, "owner", false, "OWNER"); - public final static Property ObjectId = new Property(11, String.class, "objectId", false, "OBJECT_ID"); - public final static Property MarkerId = new Property(12, String.class, "markerId", false, "MARKER_ID"); - public final static Property MarkerType = new Property(13, String.class, "markerType", false, "MARKER_TYPE"); - public final static Property MarkerDepth = new Property(14, String.class, "markerDepth", false, "MARKER_DEPTH"); - public final static Property InstallationDept = new Property(15, String.class, "installationDept", false, "INSTALLATION_DEPT"); - public final static Property Lng = new Property(16, String.class, "lng", false, "LNG"); - public final static Property Lat = new Property(17, String.class, "lat", false, "LAT"); - public final static Property UpdateTime = new Property(18, String.class, "updateTime", false, "UPDATE_TIME"); - public final static Property Remark = new Property(19, String.class, "remark", false, "REMARK"); - public final static Property UnderlyingPipelineType = new Property(20, String.class, "underlyingPipelineType", false, "UNDERLYING_PIPELINE_TYPE"); - public final static Property UnderlyingPipelineDepth = new Property(21, String.class, "underlyingPipelineDepth", false, "UNDERLYING_PIPELINE_DEPTH"); - public final static Property UnderlyingPipelineDiameter = new Property(22, String.class, "underlyingPipelineDiameter", false, "UNDERLYING_PIPELINE_DIAMETER"); - public final static Property UnderlyingPipelineMaterial = new Property(23, String.class, "underlyingPipelineMaterial", false, "UNDERLYING_PIPELINE_MATERIAL"); - public final static Property ObjectType = new Property(24, String.class, "objectType", false, "OBJECT_TYPE"); - public final static Property Color = new Property(25, String.class, "color", false, "COLOR"); - public final static Property ImagePath = new Property(26, String.class, "imagePath", false, "IMAGE_PATH"); - } - - - public MarkerLocalBeanDao(DaoConfig config) { - super(config); - } - - public MarkerLocalBeanDao(DaoConfig config, DaoSession daoSession) { - super(config, daoSession); - } - - /** Creates the underlying database table. */ - public static void createTable(Database db, boolean ifNotExists) { - String constraint = ifNotExists? "IF NOT EXISTS ": ""; - db.execSQL("CREATE TABLE " + constraint + "\"MARKER_LOCAL_BEAN\" (" + // - "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id - "\"PIPELINE_TYPE\" TEXT," + // 1: pipelineType - "\"PIPELINE_DIAMETER\" TEXT," + // 2: pipelineDiameter - "\"PIPELINE_MATERIAL\" TEXT," + // 3: pipelineMaterial - "\"BURY_METHOD\" TEXT," + // 4: buryMethod - "\"BURY_DEPTH\" TEXT," + // 5: buryDepth - "\"AREA\" TEXT," + // 6: area - "\"LINE\" TEXT," + // 7: line - "\"ROAD\" TEXT," + // 8: road - "\"CONSTRUCT_TIME\" TEXT," + // 9: constructTime - "\"OWNER\" TEXT," + // 10: owner - "\"OBJECT_ID\" TEXT," + // 11: objectId - "\"MARKER_ID\" TEXT," + // 12: markerId - "\"MARKER_TYPE\" TEXT," + // 13: markerType - "\"MARKER_DEPTH\" TEXT," + // 14: markerDepth - "\"INSTALLATION_DEPT\" TEXT," + // 15: installationDept - "\"LNG\" TEXT," + // 16: lng - "\"LAT\" TEXT," + // 17: lat - "\"UPDATE_TIME\" TEXT," + // 18: updateTime - "\"REMARK\" TEXT," + // 19: remark - "\"UNDERLYING_PIPELINE_TYPE\" TEXT," + // 20: underlyingPipelineType - "\"UNDERLYING_PIPELINE_DEPTH\" TEXT," + // 21: underlyingPipelineDepth - "\"UNDERLYING_PIPELINE_DIAMETER\" TEXT," + // 22: underlyingPipelineDiameter - "\"UNDERLYING_PIPELINE_MATERIAL\" TEXT," + // 23: underlyingPipelineMaterial - "\"OBJECT_TYPE\" TEXT," + // 24: objectType - "\"COLOR\" TEXT," + // 25: color - "\"IMAGE_PATH\" TEXT);"); // 26: imagePath - } - - /** Drops the underlying database table. */ - public static void dropTable(Database db, boolean ifExists) { - String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"MARKER_LOCAL_BEAN\""; - db.execSQL(sql); - } - - @Override - protected final void bindValues(DatabaseStatement stmt, MarkerLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String pipelineType = entity.getPipelineType(); - if (pipelineType != null) { - stmt.bindString(2, pipelineType); - } - - String pipelineDiameter = entity.getPipelineDiameter(); - if (pipelineDiameter != null) { - stmt.bindString(3, pipelineDiameter); - } - - String pipelineMaterial = entity.getPipelineMaterial(); - if (pipelineMaterial != null) { - stmt.bindString(4, pipelineMaterial); - } - - String buryMethod = entity.getBuryMethod(); - if (buryMethod != null) { - stmt.bindString(5, buryMethod); - } - - String buryDepth = entity.getBuryDepth(); - if (buryDepth != null) { - stmt.bindString(6, buryDepth); - } - - String area = entity.getArea(); - if (area != null) { - stmt.bindString(7, area); - } - - String line = entity.getLine(); - if (line != null) { - stmt.bindString(8, line); - } - - String road = entity.getRoad(); - if (road != null) { - stmt.bindString(9, road); - } - - String constructTime = entity.getConstructTime(); - if (constructTime != null) { - stmt.bindString(10, constructTime); - } - - String owner = entity.getOwner(); - if (owner != null) { - stmt.bindString(11, owner); - } - - String objectId = entity.getObjectId(); - if (objectId != null) { - stmt.bindString(12, objectId); - } - - String markerId = entity.getMarkerId(); - if (markerId != null) { - stmt.bindString(13, markerId); - } - - String markerType = entity.getMarkerType(); - if (markerType != null) { - stmt.bindString(14, markerType); - } - - String markerDepth = entity.getMarkerDepth(); - if (markerDepth != null) { - stmt.bindString(15, markerDepth); - } - - String installationDept = entity.getInstallationDept(); - if (installationDept != null) { - stmt.bindString(16, installationDept); - } - - String lng = entity.getLng(); - if (lng != null) { - stmt.bindString(17, lng); - } - - String lat = entity.getLat(); - if (lat != null) { - stmt.bindString(18, lat); - } - - String updateTime = entity.getUpdateTime(); - if (updateTime != null) { - stmt.bindString(19, updateTime); - } - - String remark = entity.getRemark(); - if (remark != null) { - stmt.bindString(20, remark); - } - - String underlyingPipelineType = entity.getUnderlyingPipelineType(); - if (underlyingPipelineType != null) { - stmt.bindString(21, underlyingPipelineType); - } - - String underlyingPipelineDepth = entity.getUnderlyingPipelineDepth(); - if (underlyingPipelineDepth != null) { - stmt.bindString(22, underlyingPipelineDepth); - } - - String underlyingPipelineDiameter = entity.getUnderlyingPipelineDiameter(); - if (underlyingPipelineDiameter != null) { - stmt.bindString(23, underlyingPipelineDiameter); - } - - String underlyingPipelineMaterial = entity.getUnderlyingPipelineMaterial(); - if (underlyingPipelineMaterial != null) { - stmt.bindString(24, underlyingPipelineMaterial); - } - - String objectType = entity.getObjectType(); - if (objectType != null) { - stmt.bindString(25, objectType); - } - - String color = entity.getColor(); - if (color != null) { - stmt.bindString(26, color); - } - - String imagePath = entity.getImagePath(); - if (imagePath != null) { - stmt.bindString(27, imagePath); - } - } - - @Override - protected final void bindValues(SQLiteStatement stmt, MarkerLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String pipelineType = entity.getPipelineType(); - if (pipelineType != null) { - stmt.bindString(2, pipelineType); - } - - String pipelineDiameter = entity.getPipelineDiameter(); - if (pipelineDiameter != null) { - stmt.bindString(3, pipelineDiameter); - } - - String pipelineMaterial = entity.getPipelineMaterial(); - if (pipelineMaterial != null) { - stmt.bindString(4, pipelineMaterial); - } - - String buryMethod = entity.getBuryMethod(); - if (buryMethod != null) { - stmt.bindString(5, buryMethod); - } - - String buryDepth = entity.getBuryDepth(); - if (buryDepth != null) { - stmt.bindString(6, buryDepth); - } - - String area = entity.getArea(); - if (area != null) { - stmt.bindString(7, area); - } - - String line = entity.getLine(); - if (line != null) { - stmt.bindString(8, line); - } - - String road = entity.getRoad(); - if (road != null) { - stmt.bindString(9, road); - } - - String constructTime = entity.getConstructTime(); - if (constructTime != null) { - stmt.bindString(10, constructTime); - } - - String owner = entity.getOwner(); - if (owner != null) { - stmt.bindString(11, owner); - } - - String objectId = entity.getObjectId(); - if (objectId != null) { - stmt.bindString(12, objectId); - } - - String markerId = entity.getMarkerId(); - if (markerId != null) { - stmt.bindString(13, markerId); - } - - String markerType = entity.getMarkerType(); - if (markerType != null) { - stmt.bindString(14, markerType); - } - - String markerDepth = entity.getMarkerDepth(); - if (markerDepth != null) { - stmt.bindString(15, markerDepth); - } - - String installationDept = entity.getInstallationDept(); - if (installationDept != null) { - stmt.bindString(16, installationDept); - } - - String lng = entity.getLng(); - if (lng != null) { - stmt.bindString(17, lng); - } - - String lat = entity.getLat(); - if (lat != null) { - stmt.bindString(18, lat); - } - - String updateTime = entity.getUpdateTime(); - if (updateTime != null) { - stmt.bindString(19, updateTime); - } - - String remark = entity.getRemark(); - if (remark != null) { - stmt.bindString(20, remark); - } - - String underlyingPipelineType = entity.getUnderlyingPipelineType(); - if (underlyingPipelineType != null) { - stmt.bindString(21, underlyingPipelineType); - } - - String underlyingPipelineDepth = entity.getUnderlyingPipelineDepth(); - if (underlyingPipelineDepth != null) { - stmt.bindString(22, underlyingPipelineDepth); - } - - String underlyingPipelineDiameter = entity.getUnderlyingPipelineDiameter(); - if (underlyingPipelineDiameter != null) { - stmt.bindString(23, underlyingPipelineDiameter); - } - - String underlyingPipelineMaterial = entity.getUnderlyingPipelineMaterial(); - if (underlyingPipelineMaterial != null) { - stmt.bindString(24, underlyingPipelineMaterial); - } - - String objectType = entity.getObjectType(); - if (objectType != null) { - stmt.bindString(25, objectType); - } - - String color = entity.getColor(); - if (color != null) { - stmt.bindString(26, color); - } - - String imagePath = entity.getImagePath(); - if (imagePath != null) { - stmt.bindString(27, imagePath); - } - } - - @Override - public Long readKey(Cursor cursor, int offset) { - return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); - } - - @Override - public MarkerLocalBean readEntity(Cursor cursor, int offset) { - MarkerLocalBean entity = new MarkerLocalBean( // - cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // pipelineType - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // pipelineDiameter - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // pipelineMaterial - cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // buryMethod - cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // buryDepth - cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // area - cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // line - cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // road - cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // constructTime - cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10), // owner - cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11), // objectId - cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12), // markerId - cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13), // markerType - cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14), // markerDepth - cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15), // installationDept - cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16), // lng - cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17), // lat - cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18), // updateTime - cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19), // remark - cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20), // underlyingPipelineType - cursor.isNull(offset + 21) ? null : cursor.getString(offset + 21), // underlyingPipelineDepth - cursor.isNull(offset + 22) ? null : cursor.getString(offset + 22), // underlyingPipelineDiameter - cursor.isNull(offset + 23) ? null : cursor.getString(offset + 23), // underlyingPipelineMaterial - cursor.isNull(offset + 24) ? null : cursor.getString(offset + 24), // objectType - cursor.isNull(offset + 25) ? null : cursor.getString(offset + 25), // color - cursor.isNull(offset + 26) ? null : cursor.getString(offset + 26) // imagePath - ); - return entity; - } - - @Override - public void readEntity(Cursor cursor, MarkerLocalBean entity, int offset) { - entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setPipelineType(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); - entity.setPipelineDiameter(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); - entity.setPipelineMaterial(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); - entity.setBuryMethod(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); - entity.setBuryDepth(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); - entity.setArea(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); - entity.setLine(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); - entity.setRoad(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); - entity.setConstructTime(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9)); - entity.setOwner(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); - entity.setObjectId(cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11)); - entity.setMarkerId(cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12)); - entity.setMarkerType(cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13)); - entity.setMarkerDepth(cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14)); - entity.setInstallationDept(cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15)); - entity.setLng(cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16)); - entity.setLat(cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17)); - entity.setUpdateTime(cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18)); - entity.setRemark(cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19)); - entity.setUnderlyingPipelineType(cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20)); - entity.setUnderlyingPipelineDepth(cursor.isNull(offset + 21) ? null : cursor.getString(offset + 21)); - entity.setUnderlyingPipelineDiameter(cursor.isNull(offset + 22) ? null : cursor.getString(offset + 22)); - entity.setUnderlyingPipelineMaterial(cursor.isNull(offset + 23) ? null : cursor.getString(offset + 23)); - entity.setObjectType(cursor.isNull(offset + 24) ? null : cursor.getString(offset + 24)); - entity.setColor(cursor.isNull(offset + 25) ? null : cursor.getString(offset + 25)); - entity.setImagePath(cursor.isNull(offset + 26) ? null : cursor.getString(offset + 26)); - } - - @Override - protected final Long updateKeyAfterInsert(MarkerLocalBean entity, long rowId) { - entity.setId(rowId); - return rowId; - } - - @Override - public Long getKey(MarkerLocalBean entity) { - if(entity != null) { - return entity.getId(); - } else { - return null; - } - } - - @Override - public boolean hasKey(MarkerLocalBean entity) { - return entity.getId() != null; - } - - @Override - protected final boolean isEntityUpdateable() { - return true; - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/TaskLocalBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/greendao/TaskLocalBeanDao.java deleted file mode 100644 index fb88157..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/TaskLocalBeanDao.java +++ /dev/null @@ -1,227 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import android.database.Cursor; -import android.database.sqlite.SQLiteStatement; - -import org.greenrobot.greendao.AbstractDao; -import org.greenrobot.greendao.Property; -import org.greenrobot.greendao.internal.DaoConfig; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.database.DatabaseStatement; - -import com.casic.common.detector.gd.bean.TaskLocalBean; - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** - * DAO for table "TASK_LOCAL_BEAN". -*/ -public class TaskLocalBeanDao extends AbstractDao { - - public static final String TABLENAME = "TASK_LOCAL_BEAN"; - - /** - * Properties of entity TaskLocalBean.
- * Can be used for QueryBuilder and for referencing column names. - */ - public static class Properties { - public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property TaskCode = new Property(1, String.class, "taskCode", false, "TASK_CODE"); - public final static Property Description = new Property(2, String.class, "description", false, "DESCRIPTION"); - public final static Property CreateTime = new Property(3, String.class, "createTime", false, "CREATE_TIME"); - public final static Property Status = new Property(4, String.class, "status", false, "STATUS"); - public final static Property CreateUserName = new Property(5, String.class, "createUserName", false, "CREATE_USER_NAME"); - public final static Property StartTime = new Property(6, String.class, "startTime", false, "START_TIME"); - public final static Property EndTime = new Property(7, String.class, "endTime", false, "END_TIME"); - public final static Property IsFreeTask = new Property(8, String.class, "isFreeTask", false, "IS_FREE_TASK"); - } - - - public TaskLocalBeanDao(DaoConfig config) { - super(config); - } - - public TaskLocalBeanDao(DaoConfig config, DaoSession daoSession) { - super(config, daoSession); - } - - /** Creates the underlying database table. */ - public static void createTable(Database db, boolean ifNotExists) { - String constraint = ifNotExists? "IF NOT EXISTS ": ""; - db.execSQL("CREATE TABLE " + constraint + "\"TASK_LOCAL_BEAN\" (" + // - "\"_id\" INTEGER PRIMARY KEY ," + // 0: id - "\"TASK_CODE\" TEXT," + // 1: taskCode - "\"DESCRIPTION\" TEXT," + // 2: description - "\"CREATE_TIME\" TEXT," + // 3: createTime - "\"STATUS\" TEXT," + // 4: status - "\"CREATE_USER_NAME\" TEXT," + // 5: createUserName - "\"START_TIME\" TEXT," + // 6: startTime - "\"END_TIME\" TEXT," + // 7: endTime - "\"IS_FREE_TASK\" TEXT);"); // 8: isFreeTask - } - - /** Drops the underlying database table. */ - public static void dropTable(Database db, boolean ifExists) { - String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"TASK_LOCAL_BEAN\""; - db.execSQL(sql); - } - - @Override - protected final void bindValues(DatabaseStatement stmt, TaskLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String taskCode = entity.getTaskCode(); - if (taskCode != null) { - stmt.bindString(2, taskCode); - } - - String description = entity.getDescription(); - if (description != null) { - stmt.bindString(3, description); - } - - String createTime = entity.getCreateTime(); - if (createTime != null) { - stmt.bindString(4, createTime); - } - - String status = entity.getStatus(); - if (status != null) { - stmt.bindString(5, status); - } - - String createUserName = entity.getCreateUserName(); - if (createUserName != null) { - stmt.bindString(6, createUserName); - } - - String startTime = entity.getStartTime(); - if (startTime != null) { - stmt.bindString(7, startTime); - } - - String endTime = entity.getEndTime(); - if (endTime != null) { - stmt.bindString(8, endTime); - } - - String isFreeTask = entity.getIsFreeTask(); - if (isFreeTask != null) { - stmt.bindString(9, isFreeTask); - } - } - - @Override - protected final void bindValues(SQLiteStatement stmt, TaskLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String taskCode = entity.getTaskCode(); - if (taskCode != null) { - stmt.bindString(2, taskCode); - } - - String description = entity.getDescription(); - if (description != null) { - stmt.bindString(3, description); - } - - String createTime = entity.getCreateTime(); - if (createTime != null) { - stmt.bindString(4, createTime); - } - - String status = entity.getStatus(); - if (status != null) { - stmt.bindString(5, status); - } - - String createUserName = entity.getCreateUserName(); - if (createUserName != null) { - stmt.bindString(6, createUserName); - } - - String startTime = entity.getStartTime(); - if (startTime != null) { - stmt.bindString(7, startTime); - } - - String endTime = entity.getEndTime(); - if (endTime != null) { - stmt.bindString(8, endTime); - } - - String isFreeTask = entity.getIsFreeTask(); - if (isFreeTask != null) { - stmt.bindString(9, isFreeTask); - } - } - - @Override - public Long readKey(Cursor cursor, int offset) { - return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); - } - - @Override - public TaskLocalBean readEntity(Cursor cursor, int offset) { - TaskLocalBean entity = new TaskLocalBean( // - cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // taskCode - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // description - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // createTime - cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // status - cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // createUserName - cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // startTime - cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // endTime - cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8) // isFreeTask - ); - return entity; - } - - @Override - public void readEntity(Cursor cursor, TaskLocalBean entity, int offset) { - entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setTaskCode(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); - entity.setDescription(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); - entity.setCreateTime(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); - entity.setStatus(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); - entity.setCreateUserName(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); - entity.setStartTime(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); - entity.setEndTime(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); - entity.setIsFreeTask(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); - } - - @Override - protected final Long updateKeyAfterInsert(TaskLocalBean entity, long rowId) { - entity.setId(rowId); - return rowId; - } - - @Override - public Long getKey(TaskLocalBean entity) { - if(entity != null) { - return entity.getId(); - } else { - return null; - } - } - - @Override - public boolean hasKey(TaskLocalBean entity) { - return entity.getId() != null; - } - - @Override - protected final boolean isEntityUpdateable() { - return true; - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/TaskMarkerLocalBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/greendao/TaskMarkerLocalBeanDao.java deleted file mode 100644 index e96c735..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/TaskMarkerLocalBeanDao.java +++ /dev/null @@ -1,197 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import android.database.Cursor; -import android.database.sqlite.SQLiteStatement; - -import org.greenrobot.greendao.AbstractDao; -import org.greenrobot.greendao.Property; -import org.greenrobot.greendao.internal.DaoConfig; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.database.DatabaseStatement; - -import com.casic.common.detector.gd.bean.TaskMarkerLocalBean; - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** - * DAO for table "TASK_MARKER_LOCAL_BEAN". -*/ -public class TaskMarkerLocalBeanDao extends AbstractDao { - - public static final String TABLENAME = "TASK_MARKER_LOCAL_BEAN"; - - /** - * Properties of entity TaskMarkerLocalBean.
- * Can be used for QueryBuilder and for referencing column names. - */ - public static class Properties { - public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property TaskId = new Property(1, String.class, "taskId", false, "TASK_ID"); - public final static Property TaskCode = new Property(2, String.class, "taskCode", false, "TASK_CODE"); - public final static Property MarkerId = new Property(3, String.class, "markerId", false, "MARKER_ID"); - public final static Property Lng = new Property(4, double.class, "lng", false, "LNG"); - public final static Property Lat = new Property(5, double.class, "lat", false, "LAT"); - public final static Property IsDetected = new Property(6, String.class, "isDetected", false, "IS_DETECTED"); - public final static Property DetectedTime = new Property(7, String.class, "detectedTime", false, "DETECTED_TIME"); - } - - - public TaskMarkerLocalBeanDao(DaoConfig config) { - super(config); - } - - public TaskMarkerLocalBeanDao(DaoConfig config, DaoSession daoSession) { - super(config, daoSession); - } - - /** Creates the underlying database table. */ - public static void createTable(Database db, boolean ifNotExists) { - String constraint = ifNotExists? "IF NOT EXISTS ": ""; - db.execSQL("CREATE TABLE " + constraint + "\"TASK_MARKER_LOCAL_BEAN\" (" + // - "\"_id\" INTEGER PRIMARY KEY ," + // 0: id - "\"TASK_ID\" TEXT," + // 1: taskId - "\"TASK_CODE\" TEXT," + // 2: taskCode - "\"MARKER_ID\" TEXT," + // 3: markerId - "\"LNG\" REAL NOT NULL ," + // 4: lng - "\"LAT\" REAL NOT NULL ," + // 5: lat - "\"IS_DETECTED\" TEXT," + // 6: isDetected - "\"DETECTED_TIME\" TEXT);"); // 7: detectedTime - } - - /** Drops the underlying database table. */ - public static void dropTable(Database db, boolean ifExists) { - String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"TASK_MARKER_LOCAL_BEAN\""; - db.execSQL(sql); - } - - @Override - protected final void bindValues(DatabaseStatement stmt, TaskMarkerLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String taskId = entity.getTaskId(); - if (taskId != null) { - stmt.bindString(2, taskId); - } - - String taskCode = entity.getTaskCode(); - if (taskCode != null) { - stmt.bindString(3, taskCode); - } - - String markerId = entity.getMarkerId(); - if (markerId != null) { - stmt.bindString(4, markerId); - } - stmt.bindDouble(5, entity.getLng()); - stmt.bindDouble(6, entity.getLat()); - - String isDetected = entity.getIsDetected(); - if (isDetected != null) { - stmt.bindString(7, isDetected); - } - - String detectedTime = entity.getDetectedTime(); - if (detectedTime != null) { - stmt.bindString(8, detectedTime); - } - } - - @Override - protected final void bindValues(SQLiteStatement stmt, TaskMarkerLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String taskId = entity.getTaskId(); - if (taskId != null) { - stmt.bindString(2, taskId); - } - - String taskCode = entity.getTaskCode(); - if (taskCode != null) { - stmt.bindString(3, taskCode); - } - - String markerId = entity.getMarkerId(); - if (markerId != null) { - stmt.bindString(4, markerId); - } - stmt.bindDouble(5, entity.getLng()); - stmt.bindDouble(6, entity.getLat()); - - String isDetected = entity.getIsDetected(); - if (isDetected != null) { - stmt.bindString(7, isDetected); - } - - String detectedTime = entity.getDetectedTime(); - if (detectedTime != null) { - stmt.bindString(8, detectedTime); - } - } - - @Override - public Long readKey(Cursor cursor, int offset) { - return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); - } - - @Override - public TaskMarkerLocalBean readEntity(Cursor cursor, int offset) { - TaskMarkerLocalBean entity = new TaskMarkerLocalBean( // - cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // taskId - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // taskCode - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // markerId - cursor.getDouble(offset + 4), // lng - cursor.getDouble(offset + 5), // lat - cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // isDetected - cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7) // detectedTime - ); - return entity; - } - - @Override - public void readEntity(Cursor cursor, TaskMarkerLocalBean entity, int offset) { - entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setTaskId(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); - entity.setTaskCode(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); - entity.setMarkerId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); - entity.setLng(cursor.getDouble(offset + 4)); - entity.setLat(cursor.getDouble(offset + 5)); - entity.setIsDetected(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); - entity.setDetectedTime(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); - } - - @Override - protected final Long updateKeyAfterInsert(TaskMarkerLocalBean entity, long rowId) { - entity.setId(rowId); - return rowId; - } - - @Override - public Long getKey(TaskMarkerLocalBean entity) { - if(entity != null) { - return entity.getId(); - } else { - return null; - } - } - - @Override - public boolean hasKey(TaskMarkerLocalBean entity) { - return entity.getId() != null; - } - - @Override - protected final boolean isEntityUpdateable() { - return true; - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/model/TaskModel.java b/app/src/main/java/com/casic/common/detector/gd/model/TaskModel.java index 6e853ad..67ef5fb 100644 --- a/app/src/main/java/com/casic/common/detector/gd/model/TaskModel.java +++ b/app/src/main/java/com/casic/common/detector/gd/model/TaskModel.java @@ -24,7 +24,7 @@ } public static class MessageModel { - private int id; + private Long id; private String taskCode; private String description; private String deployDate; @@ -38,11 +38,11 @@ private int isValid; private List taskDetailInfos; - public int getId() { + public Long getId() { return id; } - public void setId(int id) { + public void setId(Long id) { this.id = id; } @@ -143,25 +143,25 @@ } public static class TaskDetailInfosModel { - private int id; + private long id; private String taskId; private String taskCode; private Object markerName; - private int markerId; + private String markerId; private String markerIdReal; private double longitude; private double latitude; private int isChecked; private int isNormal; - private Object imagePath; - private Object description; - private Object finishTime; + private String imagePath; + private String description; + private String finishTime; - public int getId() { + public long getId() { return id; } - public void setId(int id) { + public void setId(long id) { this.id = id; } @@ -189,11 +189,11 @@ this.markerName = markerName; } - public int getMarkerId() { + public String getMarkerId() { return markerId; } - public void setMarkerId(int markerId) { + public void setMarkerId(String markerId) { this.markerId = markerId; } @@ -237,27 +237,27 @@ this.isNormal = isNormal; } - public Object getImagePath() { + public String getImagePath() { return imagePath; } - public void setImagePath(Object imagePath) { + public void setImagePath(String imagePath) { this.imagePath = imagePath; } - public Object getDescription() { + public String getDescription() { return description; } - public void setDescription(Object description) { + public void setDescription(String description) { this.description = description; } - public Object getFinishTime() { + public String getFinishTime() { return finishTime; } - public void setFinishTime(Object finishTime) { + public void setFinishTime(String finishTime) { this.finishTime = finishTime; } } diff --git a/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitService.kt index 7522a87..0adad51 100644 --- a/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitService.kt @@ -50,7 +50,7 @@ */ @Multipart @POST("/ems/marker/save-marker-photo.do") - suspend fun installLabel( + suspend fun install( @PartMap jsonMarker: Map, @Part fileBuffer1: MultipartBody.Part?, @Part fileBuffer2: MultipartBody.Part?, diff --git a/app/build.gradle b/app/build.gradle index d0cb423..921c8c8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,25 +1,20 @@ import java.text.SimpleDateFormat -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply plugin: 'org.greenrobot.greendao' +plugins { + id('com.android.application') + id('org.jetbrains.kotlin.android') +} android { - compileSdkVersion 33 + namespace 'com.casic.common.detector.gd' + compileSdk 35 defaultConfig { - applicationId "com.casic.common.detector.gd" - minSdkVersion 26 - targetSdkVersion 33 + applicationId 'com.casic.common.detector.gd' + minSdk 26 + targetSdk 35 versionCode 5092 - versionName "5.0.9.2" - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } + versionName '5.0.9.2' } signingConfigs { @@ -31,6 +26,14 @@ } } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + signingConfig signingConfigs.release + } + } + compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 @@ -47,27 +50,16 @@ } } - kotlin { - experimental { - coroutines 'enable' - } - } - buildFeatures { + buildConfig true viewBinding true } - applicationVariants.configureEach { variant -> - variant.outputs.configureEach { - outputFileName = "COM_TCY_" + getBuildDate() + "_" + defaultConfig.versionName + ".apk" + applicationVariants.configureEach { + outputs.configureEach { + outputFileName = 'COM_TCY_' + getBuildDate() + '_' + defaultConfig.versionName + '.apk' } } - - greendao { - schemaVersion 1//数据库版本号 - targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 - daoPackage "${defaultConfig.applicationId}.greendao"//设置DaoMaster、DaoSession、Dao包名 - } } static def getBuildDate() { @@ -76,27 +68,22 @@ } dependencies { - //基础依赖库 - implementation 'com.github.AndroidCoderPeng:Kotlin-lite-lib:1.1.4' - implementation 'androidx.core:core-ktx:1.9.0' - def base_version = "1.6.1" - implementation "androidx.appcompat:appcompat:${base_version}" - implementation "com.google.android.material:material:${base_version}" + implementation 'com.github.AndroidCoderPeng:Kotlin-lite-lib:1.1.5' + implementation 'androidx.core:core-ktx:1.13.1' + implementation 'androidx.appcompat:appcompat:1.7.0' + implementation 'com.google.android.material:material:1.12.0' //Google官方授权框架 implementation 'pub.devrel:easypermissions:3.0.0' - //沉浸式状态栏。基础依赖包,必须要依赖 - implementation 'com.gyf.immersionbar:immersionbar:3.0.0' - //fragment快速实现 - implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0' + //沉浸式状态栏 + implementation 'com.geyifeng.immersionbar:immersionbar:3.2.2' //官方Json解析库 implementation 'com.google.code.gson:gson:2.10.1' - def vm_version = '2.5.1' //Kotlin协程 - implementation "androidx.lifecycle:lifecycle-runtime-ktx:${vm_version}" + implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.2' //MVVM+LiveData - implementation "androidx.lifecycle:lifecycle-livedata-ktx:${vm_version}" - implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:${vm_version}" - implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.6.2' + implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2' + implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' //返回值转换器 implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' @@ -105,9 +92,10 @@ implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' //网络请求和接口封装 implementation 'com.squareup.retrofit2:retrofit:2.9.0' - implementation 'com.squareup.okhttp3:okhttp:4.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.12.0' //数据库框架 - implementation 'org.greenrobot:greendao:3.3.0' + implementation 'androidx.room:room-runtime:2.6.1' + annotationProcessor 'androidx.room:room-compiler:2.5.2' //高德导航、定位、地图三合一 implementation 'com.amap.api:navi-3dmap:latest.integration' //经纬度逆编码 @@ -115,7 +103,7 @@ //excel implementation 'net.sourceforge.jexcelapi:jxl:2.6.12' //图片加载框架 - implementation 'com.github.bumptech.glide:glide:4.9.0' + implementation 'com.github.bumptech.glide:glide:4.12.0' //图片选择框架 implementation 'io.github.lucksiege:pictureselector:v3.11.1' //大图 diff --git a/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt b/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt index 7b695ff..50ba734 100644 --- a/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt +++ b/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt @@ -4,9 +4,9 @@ import android.app.Application import android.os.Bundle import android.util.Log -import com.casic.common.detector.gd.greendao.DaoMaster -import com.casic.common.detector.gd.greendao.DaoSession +import androidx.room.Room.databaseBuilder import com.casic.common.detector.gd.uart.SerialPort +import com.casic.common.detector.gd.utils.DetectorDataBase import com.casic.common.detector.gd.utils.GpioManager import com.pengxh.kt.lite.extensions.show import com.pengxh.kt.lite.utils.SaveKeyValues @@ -43,44 +43,42 @@ private var application: BaseApplication by Delegates.notNull() fun get() = application - - private lateinit var daoSession: DaoSession } + lateinit var dataBase: DetectorDataBase + override fun onCreate() { super.onCreate() application = this SaveKeyValues.initSharedPreferences(this) CrashReport.initCrashReport(this, "01e80d3a74", true) - val devOpenHelper = DaoMaster.DevOpenHelper(this, "Detector.db", null) - val daoMaster = DaoMaster(devOpenHelper.writableDatabase) - daoSession = daoMaster.newSession() + dataBase = databaseBuilder(this, DetectorDataBase::class.java, "Detector.db") + .allowMainThreadQueries() + .build() /** * Open the serial port * */ try { serialPorts.apply { - add(SerialPort(File("/dev/ttysWK1"), 9600, 0)) - //千寻报文数据下发串口号 - add(SerialPort(File("/dev/ttyS1"), 9600, 0)) + add(SerialPort(File("/dev/ttysWK1"), 9600, 0)) //信号通讯串口 + add(SerialPort(File("/dev/ttyS1"), 9600, 0)) //千寻报文数据下发串口号 } Log.d(kTag, "onCreate: 已初始化 ${serialPorts.size} 个串口") } catch (e: SecurityException) { "您没有串口的读写权限!".show(this) + e.printStackTrace() } catch (e: IOException) { "因为不明原因,串口无法打开!".show(this) + e.printStackTrace() } catch (e: InvalidParameterException) { "请检查串口!".show(this) + e.printStackTrace() } registerActivityLifecycleCallbacks(this) } - fun getDaoSession(): DaoSession { - return daoSession - } - override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) { } diff --git a/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt b/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt index 053b9dd..1d0c9e3 100644 --- a/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt +++ b/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt @@ -14,12 +14,10 @@ import com.casic.common.detector.gd.utils.SerialPortCommand import com.pengxh.kt.lite.utils.WeakReferenceHandler import java.io.IOException -import java.util.Timer abstract class SerialPortBaseActivity : AppCompatActivity(), Handler.Callback { private val kTag = "SerialPortBaseActivity" - private val taskTimer by lazy { Timer() } private val weakReferenceHandler by lazy { WeakReferenceHandler(this) } private val serialPorts by lazy { BaseApplication.get().getSerialPorts() } protected lateinit var binding: VB @@ -30,7 +28,6 @@ setContentView(binding.root) setupTopBarLayout() initOnCreate(savedInstanceState) - observeRequestState() initEvent() if (serialPorts.isNotEmpty()) { @@ -71,11 +68,6 @@ abstract fun initOnCreate(savedInstanceState: Bundle?) /** - * 数据请求状态监听 - */ - abstract fun observeRequestState() - - /** * 初始化业务逻辑 */ abstract fun initEvent() diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java new file mode 100644 index 0000000..7a18c20 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java @@ -0,0 +1,255 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 从平台下载的标识器本地库实体类 + */ +@Entity(tableName = "marker_detail") +public class MarkerBean { + @PrimaryKey(autoGenerate = true) + private long id; //主键ID + private String pipelineType; // 管线类型 + private String pipelineDiameter; // 管线直径 + private String pipelineMaterial; // 管材 + private String buryMethod; // 埋设方式 + private String buryDepth; // 埋深 + private String area; // 所属区域 + private String line; // 所属线路 + private String road; // 所属道路 + private String constructTime; // 建设年代 + private String owner; // 权属单位 + private String objectId; // 标识对象ID,无实际用途 + private String markerId; // 标识器ID + private String markerType; // 标识器类型 + private String markerDepth; // 标识器埋深 + private String installationDept; // 安装部门 + private String lng; // 经度 + private String lat; // 纬度 + private String updateTime; // 最后修改时间,更新时间 + private String remark; // 备注信息 + private String underlyingPipelineType; // 下层管线类型 + private String underlyingPipelineDepth; // 下层埋深 + private String underlyingPipelineDiameter; // 下层管径 + private String underlyingPipelineMaterial; // 下层管材 + private String objectType; //标识对象类型 + private String color; // 颜色 + private String imagePath; // 图片路径 + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getPipelineType() { + return pipelineType; + } + + public void setPipelineType(String pipelineType) { + this.pipelineType = pipelineType; + } + + public String getPipelineDiameter() { + return pipelineDiameter; + } + + public void setPipelineDiameter(String pipelineDiameter) { + this.pipelineDiameter = pipelineDiameter; + } + + public String getPipelineMaterial() { + return pipelineMaterial; + } + + public void setPipelineMaterial(String pipelineMaterial) { + this.pipelineMaterial = pipelineMaterial; + } + + public String getBuryMethod() { + return buryMethod; + } + + public void setBuryMethod(String buryMethod) { + this.buryMethod = buryMethod; + } + + public String getBuryDepth() { + return buryDepth; + } + + public void setBuryDepth(String buryDepth) { + this.buryDepth = buryDepth; + } + + public String getArea() { + return area; + } + + public void setArea(String area) { + this.area = area; + } + + public String getLine() { + return line; + } + + public void setLine(String line) { + this.line = line; + } + + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + + public String getConstructTime() { + return constructTime; + } + + public void setConstructTime(String constructTime) { + this.constructTime = constructTime; + } + + public String getOwner() { + return owner; + } + + public void setOwner(String owner) { + this.owner = owner; + } + + public String getObjectId() { + return objectId; + } + + public void setObjectId(String objectId) { + this.objectId = objectId; + } + + public String getMarkerId() { + return markerId; + } + + public void setMarkerId(String markerId) { + this.markerId = markerId; + } + + public String getMarkerType() { + return markerType; + } + + public void setMarkerType(String markerType) { + this.markerType = markerType; + } + + public String getMarkerDepth() { + return markerDepth; + } + + public void setMarkerDepth(String markerDepth) { + this.markerDepth = markerDepth; + } + + public String getInstallationDept() { + return installationDept; + } + + public void setInstallationDept(String installationDept) { + this.installationDept = installationDept; + } + + public String getLng() { + return lng; + } + + public void setLng(String lng) { + this.lng = lng; + } + + public String getLat() { + return lat; + } + + public void setLat(String lat) { + this.lat = lat; + } + + public String getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } + + public String getUnderlyingPipelineType() { + return underlyingPipelineType; + } + + public void setUnderlyingPipelineType(String underlyingPipelineType) { + this.underlyingPipelineType = underlyingPipelineType; + } + + public String getUnderlyingPipelineDepth() { + return underlyingPipelineDepth; + } + + public void setUnderlyingPipelineDepth(String underlyingPipelineDepth) { + this.underlyingPipelineDepth = underlyingPipelineDepth; + } + + public String getUnderlyingPipelineDiameter() { + return underlyingPipelineDiameter; + } + + public void setUnderlyingPipelineDiameter(String underlyingPipelineDiameter) { + this.underlyingPipelineDiameter = underlyingPipelineDiameter; + } + + public String getUnderlyingPipelineMaterial() { + return underlyingPipelineMaterial; + } + + public void setUnderlyingPipelineMaterial(String underlyingPipelineMaterial) { + this.underlyingPipelineMaterial = underlyingPipelineMaterial; + } + + public String getObjectType() { + return objectType; + } + + public void setObjectType(String objectType) { + this.objectType = objectType; + } + + public String getColor() { + return color; + } + + public void setColor(String color) { + this.color = color; + } + + public String getImagePath() { + return imagePath; + } + + public void setImagePath(String imagePath) { + this.imagePath = imagePath; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java deleted file mode 100644 index 3f2fcdc..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java +++ /dev/null @@ -1,327 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 从平台下载的标识器本地库实体类 - */ -@Entity -public class MarkerLocalBean { - @Id(autoincrement = true) - private Long id;//本地库主键ID - - // 管线类型 - private String pipelineType; - // 管线直径 - private String pipelineDiameter; - // 管材 - private String pipelineMaterial; - // 埋设方式 - private String buryMethod; - // 埋深 - private String buryDepth; - // 所属区域 - private String area; - // 所属线路 - private String line; - // 所属道路 - private String road; - // 建设年代 - private String constructTime; - // 权属单位 - private String owner; - //标识对象ID,无实际用途 - @Deprecated - private String objectId; - // 标识器ID - private String markerId; - // 标识器类型 - private String markerType; - // 标识器埋深 - private String markerDepth; - // 安装部门 - private String installationDept; - // 经度 - private String lng; - // 纬度 - private String lat; - //最后修改时间,更新时间 - private String updateTime; - // 备注信息 - private String remark; - // 下层管线类型 - private String underlyingPipelineType; - // 下层埋深 - private String underlyingPipelineDepth; - // 下层管径 - private String underlyingPipelineDiameter; - // 下层管材 - private String underlyingPipelineMaterial; - //标识对象类型 - private String objectType; - // 颜色 - private String color; - // 图片路径 - private String imagePath; - - @Generated(hash = 1479045776) - public MarkerLocalBean(Long id, String pipelineType, String pipelineDiameter, - String pipelineMaterial, String buryMethod, String buryDepth, - String area, String line, String road, String constructTime, - String owner, String objectId, String markerId, String markerType, - String markerDepth, String installationDept, String lng, String lat, - String updateTime, String remark, String underlyingPipelineType, - String underlyingPipelineDepth, String underlyingPipelineDiameter, - String underlyingPipelineMaterial, String objectType, String color, - String imagePath) { - this.id = id; - this.pipelineType = pipelineType; - this.pipelineDiameter = pipelineDiameter; - this.pipelineMaterial = pipelineMaterial; - this.buryMethod = buryMethod; - this.buryDepth = buryDepth; - this.area = area; - this.line = line; - this.road = road; - this.constructTime = constructTime; - this.owner = owner; - this.objectId = objectId; - this.markerId = markerId; - this.markerType = markerType; - this.markerDepth = markerDepth; - this.installationDept = installationDept; - this.lng = lng; - this.lat = lat; - this.updateTime = updateTime; - this.remark = remark; - this.underlyingPipelineType = underlyingPipelineType; - this.underlyingPipelineDepth = underlyingPipelineDepth; - this.underlyingPipelineDiameter = underlyingPipelineDiameter; - this.underlyingPipelineMaterial = underlyingPipelineMaterial; - this.objectType = objectType; - this.color = color; - this.imagePath = imagePath; - } - - @Generated(hash = 1538606012) - public MarkerLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getPipelineType() { - return this.pipelineType; - } - - public void setPipelineType(String pipelineType) { - this.pipelineType = pipelineType; - } - - public String getPipelineDiameter() { - return this.pipelineDiameter; - } - - public void setPipelineDiameter(String pipelineDiameter) { - this.pipelineDiameter = pipelineDiameter; - } - - public String getPipelineMaterial() { - return this.pipelineMaterial; - } - - public void setPipelineMaterial(String pipelineMaterial) { - this.pipelineMaterial = pipelineMaterial; - } - - public String getBuryMethod() { - return this.buryMethod; - } - - public void setBuryMethod(String buryMethod) { - this.buryMethod = buryMethod; - } - - public String getBuryDepth() { - return this.buryDepth; - } - - public void setBuryDepth(String buryDepth) { - this.buryDepth = buryDepth; - } - - public String getArea() { - return this.area; - } - - public void setArea(String area) { - this.area = area; - } - - public String getLine() { - return this.line; - } - - public void setLine(String line) { - this.line = line; - } - - public String getRoad() { - return this.road; - } - - public void setRoad(String road) { - this.road = road; - } - - public String getConstructTime() { - return this.constructTime; - } - - public void setConstructTime(String constructTime) { - this.constructTime = constructTime; - } - - public String getOwner() { - return this.owner; - } - - public void setOwner(String owner) { - this.owner = owner; - } - - public String getObjectId() { - return this.objectId; - } - - public void setObjectId(String objectId) { - this.objectId = objectId; - } - - public String getMarkerId() { - return this.markerId; - } - - public void setMarkerId(String markerId) { - this.markerId = markerId; - } - - public String getMarkerType() { - return this.markerType; - } - - public void setMarkerType(String markerType) { - this.markerType = markerType; - } - - public String getMarkerDepth() { - return this.markerDepth; - } - - public void setMarkerDepth(String markerDepth) { - this.markerDepth = markerDepth; - } - - public String getInstallationDept() { - return this.installationDept; - } - - public void setInstallationDept(String installationDept) { - this.installationDept = installationDept; - } - - public String getLng() { - return this.lng; - } - - public void setLng(String lng) { - this.lng = lng; - } - - public String getLat() { - return this.lat; - } - - public void setLat(String lat) { - this.lat = lat; - } - - public String getUpdateTime() { - return this.updateTime; - } - - public void setUpdateTime(String updateTime) { - this.updateTime = updateTime; - } - - public String getRemark() { - return this.remark; - } - - public void setRemark(String remark) { - this.remark = remark; - } - - public String getUnderlyingPipelineType() { - return this.underlyingPipelineType; - } - - public void setUnderlyingPipelineType(String underlyingPipelineType) { - this.underlyingPipelineType = underlyingPipelineType; - } - - public String getUnderlyingPipelineDepth() { - return this.underlyingPipelineDepth; - } - - public void setUnderlyingPipelineDepth(String underlyingPipelineDepth) { - this.underlyingPipelineDepth = underlyingPipelineDepth; - } - - public String getUnderlyingPipelineDiameter() { - return this.underlyingPipelineDiameter; - } - - public void setUnderlyingPipelineDiameter(String underlyingPipelineDiameter) { - this.underlyingPipelineDiameter = underlyingPipelineDiameter; - } - - public String getUnderlyingPipelineMaterial() { - return this.underlyingPipelineMaterial; - } - - public void setUnderlyingPipelineMaterial(String underlyingPipelineMaterial) { - this.underlyingPipelineMaterial = underlyingPipelineMaterial; - } - - public String getObjectType() { - return this.objectType; - } - - public void setObjectType(String objectType) { - this.objectType = objectType; - } - - public String getColor() { - return this.color; - } - - public void setColor(String color) { - this.color = color; - } - - public String getImagePath() { - return this.imagePath; - } - - public void setImagePath(String imagePath) { - this.imagePath = imagePath; - } -} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java new file mode 100644 index 0000000..5c88fdf --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java @@ -0,0 +1,93 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 巡检任务本地库实体类,不包含任务里面需要巡检的标识器信息 + */ +@Entity(tableName = "task_detail") +public class TaskBean { + @PrimaryKey(autoGenerate = true) + private long id;//主键ID + private String taskCode; // 任务编号 + private String description; // 任务名称 + private String createTime; // 任务创建的时间 + private String status; // 任务状态 + private String createUserName; // 任务创建者名称 + private String startTime; // 任务被开始执行的时间 + private String endTime; // 任务执行结束的时间 + private String isFree; // 是否自由巡检。1-是,0-否 + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getTaskCode() { + return taskCode; + } + + public void setTaskCode(String taskCode) { + this.taskCode = taskCode; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getCreateUserName() { + return createUserName; + } + + public void setCreateUserName(String createUserName) { + this.createUserName = createUserName; + } + + public String getStartTime() { + return startTime; + } + + public void setStartTime(String startTime) { + this.startTime = startTime; + } + + public String getEndTime() { + return endTime; + } + + public void setEndTime(String endTime) { + this.endTime = endTime; + } + + public String getIsFree() { + return isFree; + } + + public void setIsFree(String isFree) { + this.isFree = isFree; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java deleted file mode 100644 index 91737b3..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java +++ /dev/null @@ -1,114 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 巡检任务本地库实体类,不包含任务里面需要巡检的标识器信息 - */ -@Entity -public class TaskLocalBean { - @Id - private Long id;//任务ID - - private String taskCode;//任务编号 - private String description;//任务名称 - private String createTime;//任务创建的时间 - private String status;//任务状态 - private String createUserName;//任务创建者名称 - private String startTime;//任务被开始执行的时间 - private String endTime;//任务执行结束的时间 - private String isFreeTask;//是否自由巡检。1-是,0-否 - - @Generated(hash = 1482022528) - public TaskLocalBean(Long id, String taskCode, String description, - String createTime, String status, String createUserName, - String startTime, String endTime, String isFreeTask) { - this.id = id; - this.taskCode = taskCode; - this.description = description; - this.createTime = createTime; - this.status = status; - this.createUserName = createUserName; - this.startTime = startTime; - this.endTime = endTime; - this.isFreeTask = isFreeTask; - } - - @Generated(hash = 949704588) - public TaskLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getTaskCode() { - return this.taskCode; - } - - public void setTaskCode(String taskCode) { - this.taskCode = taskCode; - } - - public String getDescription() { - return this.description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getCreateTime() { - return this.createTime; - } - - public void setCreateTime(String createTime) { - this.createTime = createTime; - } - - public String getStatus() { - return this.status; - } - - public void setStatus(String status) { - this.status = status; - } - - public String getCreateUserName() { - return this.createUserName; - } - - public void setCreateUserName(String createUserName) { - this.createUserName = createUserName; - } - - public String getStartTime() { - return this.startTime; - } - - public void setStartTime(String startTime) { - this.startTime = startTime; - } - - public String getEndTime() { - return this.endTime; - } - - public void setEndTime(String endTime) { - this.endTime = endTime; - } - - public String getIsFreeTask() { - return this.isFreeTask; - } - - public void setIsFreeTask(String isFreeTask) { - this.isFreeTask = isFreeTask; - } -} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerBean.java new file mode 100644 index 0000000..c563a60 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerBean.java @@ -0,0 +1,110 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 巡检任务里面需要巡检的标识器信息本地库实体类 + */ +@Entity(tableName = "task_marker_info") +public class TaskMarkerBean { + //标识器后台库的主键ID,不是标识器实际ID + @PrimaryKey(autoGenerate = true) + private long id; + + /** + * 任务ID,通过此字段关联[TaskBean.id] + */ + private String taskId; + + /** + * 任务Code,通过此字段关联[TaskBean.taskCode] + *

+ *

+ * 双重验证,防止出现同时刻重复的情况 + */ + private String taskCode; + + /** + * 对应后台字段[TaskModel.MessageModel.TaskDetailInfosModel.markerIdReal],也就是探测仪扫描出来的ID + */ + private String markerId; + + private Double lng; + private Double lat; + + /** + * 是否已被探测到 + * 1-是,0-否 + */ + private String isDetected; + + /** + * 被探测到的时间,对应后台字段[TaskModel.MessageModel.TaskDetailInfosModel.finishTime] + */ + private String detectedTime; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getTaskId() { + return taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getTaskCode() { + return taskCode; + } + + public void setTaskCode(String taskCode) { + this.taskCode = taskCode; + } + + public String getMarkerId() { + return markerId; + } + + public void setMarkerId(String markerId) { + this.markerId = markerId; + } + + public Double getLng() { + return lng; + } + + public void setLng(Double lng) { + this.lng = lng; + } + + public Double getLat() { + return lat; + } + + public void setLat(Double lat) { + this.lat = lat; + } + + public String getIsDetected() { + return isDetected; + } + + public void setIsDetected(String isDetected) { + this.isDetected = isDetected; + } + + public String getDetectedTime() { + return detectedTime; + } + + public void setDetectedTime(String detectedTime) { + this.detectedTime = detectedTime; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerLocalBean.java deleted file mode 100644 index de9f459..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerLocalBean.java +++ /dev/null @@ -1,128 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import com.casic.common.detector.gd.model.TaskModel; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 巡检任务里面需要巡检的标识器信息本地库实体类 - */ -@Entity -public class TaskMarkerLocalBean { - @Id - private Long id;//标识器后台库的主键ID,不是标识器实际ID - - /** - * 任务ID,通过此字段关联{@link TaskLocalBean#id} - */ - private String taskId; - - /** - * 任务Code,通过此字段关联{@link TaskLocalBean#taskCode} - *

- * 双重验证,防止出现同时刻重复的情况 - */ - private String taskCode; - - /** - * 对应后台字段{@link TaskModel.MessageModel.TaskDetailInfosModel#markerIdReal},也就是探测仪扫描出来的ID - */ - private String markerId; - - private double lng; - private double lat; - - /** - * 是否已被探测到 - * 1-是,0-否 - */ - private String isDetected; - - /** - * 被探测到的时间,对应后台字段{@link TaskModel.MessageModel.TaskDetailInfosModel#finishTime} - */ - private String detectedTime; - - @Generated(hash = 677328533) - public TaskMarkerLocalBean(Long id, String taskId, String taskCode, String markerId, - double lng, double lat, String isDetected, String detectedTime) { - this.id = id; - this.taskId = taskId; - this.taskCode = taskCode; - this.markerId = markerId; - this.lng = lng; - this.lat = lat; - this.isDetected = isDetected; - this.detectedTime = detectedTime; - } - - @Generated(hash = 1162404642) - public TaskMarkerLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getTaskId() { - return this.taskId; - } - - public void setTaskId(String taskId) { - this.taskId = taskId; - } - - public String getTaskCode() { - return this.taskCode; - } - - public void setTaskCode(String taskCode) { - this.taskCode = taskCode; - } - - public String getMarkerId() { - return this.markerId; - } - - public void setMarkerId(String markerId) { - this.markerId = markerId; - } - - public double getLng() { - return this.lng; - } - - public void setLng(double lng) { - this.lng = lng; - } - - public double getLat() { - return this.lat; - } - - public void setLat(double lat) { - this.lat = lat; - } - - public String getIsDetected() { - return this.isDetected; - } - - public void setIsDetected(String isDetected) { - this.isDetected = isDetected; - } - - public String getDetectedTime() { - return this.detectedTime; - } - - public void setDetectedTime(String detectedTime) { - this.detectedTime = detectedTime; - } -} diff --git a/app/src/main/java/com/casic/common/detector/gd/dao/MarkerBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/dao/MarkerBeanDao.java new file mode 100644 index 0000000..2beb7ed --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/dao/MarkerBeanDao.java @@ -0,0 +1,29 @@ +package com.casic.common.detector.gd.dao; + +import androidx.room.Dao; +import androidx.room.Insert; +import androidx.room.Query; +import androidx.room.RawQuery; +import androidx.sqlite.db.SupportSQLiteQuery; + +import com.casic.common.detector.gd.bean.MarkerBean; + +import java.util.List; + +@Dao +public interface MarkerBeanDao { + @Query("DELETE FROM marker_detail") + void deleteAll(); + + @Insert + void insert(MarkerBean marker); + + @Query("SELECT * FROM marker_detail") + List loadAll(); + + @Query("SELECT * FROM marker_detail WHERE markerId = :markerId") + List queryMarkerById(String markerId); + + @RawQuery + List loadMarkersByCondition(SupportSQLiteQuery query); +} diff --git a/app/src/main/java/com/casic/common/detector/gd/dao/TaskBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/dao/TaskBeanDao.java new file mode 100644 index 0000000..9c70ac2 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/dao/TaskBeanDao.java @@ -0,0 +1,120 @@ +package com.casic.common.detector.gd.dao; + +import androidx.room.Dao; +import androidx.room.Insert; +import androidx.room.Query; +import androidx.room.Transaction; + +import com.casic.common.detector.gd.bean.TaskBean; +import com.casic.common.detector.gd.bean.TaskMarkerBean; +import com.casic.common.detector.gd.model.TaskDetailLocalModel; +import com.casic.common.detector.gd.model.TaskModel; +import com.casic.common.detector.gd.utils.LocaleConstant; +import com.pengxh.kt.lite.utils.SaveKeyValues; + +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Locale; + +@Dao +public interface TaskBeanDao { + @Query("SELECT COUNT(*) FROM task_detail WHERE id = :taskId") + int isTaskExist(long taskId); + + @Insert + void insert(TaskBean task); + + default void saveTask(Long taskId, String taskName) { + if (isTaskExist(taskId) == 0) { + TaskBean task = new TaskBean(); + task.setId(taskId); + task.setTaskCode(new SimpleDateFormat("yyyyMMddHHmmss", Locale.CHINA).format(new Date())); + task.setDescription(taskName); + String time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA).format(new Date()); + task.setCreateTime(time); + task.setStatus("0"); + String userName = (String) SaveKeyValues.INSTANCE.getValue(LocaleConstant.USER_NAME, ""); + task.setCreateUserName(userName); + task.setStartTime(time); + task.setEndTime(""); + task.setIsFree("1"); + insert(task); + } + } + + default void saveTask(TaskModel.MessageModel model) { + TaskBean task = new TaskBean(); + task.setId(model.getId()); + task.setTaskCode(model.getTaskCode()); + task.setDescription(model.getDescription()); + task.setCreateTime(model.getDeployDate()); + task.setStatus(model.getStatus()); + task.setCreateUserName(model.getCreatorName()); + task.setStartTime(model.getBeginDate()); + task.setEndTime(model.getEndDate()); + task.setIsFree("0"); + if (isTaskExist(task.getId()) == 0) { + insert(task); + } + } + + @Query("SELECT * FROM task_detail") + List loadAll(); + + @Transaction + default ArrayList loadLocalTask(TaskMarkerBeanDao taskMarkerBeanDao) { + ArrayList result = new ArrayList<>(); + List tasks = loadAll(); + for (TaskBean it : tasks) { + TaskDetailLocalModel model = new TaskDetailLocalModel(); + model.setTaskId(String.valueOf(it.getId())); + model.setTaskCode(it.getTaskCode()); + model.setDescription(it.getDescription()); + model.setCreateTime(it.getCreateTime()); + model.setStatus(it.getStatus()); + model.setCreateUserName(it.getCreateUserName()); + model.setIsFreeTask(it.getIsFree()); + ArrayList results = new ArrayList<>(); + if ("0".equals(it.getIsFree())) { + // 非自由巡检才有Marker + List markers = taskMarkerBeanDao.getMarkersByIdAndCode(String.valueOf(it.getId()), it.getTaskCode()); + for (TaskMarkerBean marker : markers) { + TaskDetailLocalModel.TaskMarkerLocalModel localModel = new TaskDetailLocalModel.TaskMarkerLocalModel(); + localModel.setMarkerId(marker.getMarkerId()); + localModel.setLng(marker.getLng()); + localModel.setLat(marker.getLat()); + localModel.setIsDetected(marker.getIsDetected()); + localModel.setDetectedTime(marker.getDetectedTime()); + + results.add(localModel); + } + } + model.setMarkerModels(results); + result.add(model); + } + return result; + } + + @Query("DELETE FROM task_detail WHERE id = :taskId AND taskCode = :taskCode") + void deleteTaskById(long taskId, String taskCode); + + @Transaction + default void deleteLocalTaskById(long taskId, String taskCode, TaskMarkerBeanDao taskMarkerBeanDao) { + TaskBean task = loadAll().stream() + .filter(it -> it.getId() == taskId && taskCode.equals(it.getTaskCode())) + .findFirst() + .orElse(null); + if (task == null) return; + deleteTaskById(taskId, taskCode); + + // 删除此任务关联的Marker。非自由巡检才有Marker + if ("0".equals(task.getIsFree())) { + List markers = taskMarkerBeanDao.getMarkersByIdAndCode(String.valueOf(task.getId()), task.getTaskCode()); + for (TaskMarkerBean marker : markers) { + taskMarkerBeanDao.delete(marker); + } + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/dao/TaskMarkerBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/dao/TaskMarkerBeanDao.java new file mode 100644 index 0000000..cc2156a --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/dao/TaskMarkerBeanDao.java @@ -0,0 +1,52 @@ +package com.casic.common.detector.gd.dao; + +import androidx.room.Dao; +import androidx.room.Delete; +import androidx.room.Insert; +import androidx.room.Query; +import androidx.room.Update; + +import com.casic.common.detector.gd.bean.TaskMarkerBean; +import com.casic.common.detector.gd.model.TaskModel; + +import java.util.List; + +@Dao +public interface TaskMarkerBeanDao { + + @Insert + void insert(TaskMarkerBean marker); + + @Query("SELECT COUNT(*) FROM task_marker_info WHERE id = :markerId") + int isMarkerExist(String markerId); + + default void saveTaskMarker(long taskId, String taskCode, TaskModel.MessageModel.TaskDetailInfosModel marker) { + if (isMarkerExist(marker.getMarkerId()) == 0) { + TaskMarkerBean bean = new TaskMarkerBean(); + bean.setId(marker.getId()); + bean.setTaskId(String.valueOf(taskId)); + bean.setTaskCode(taskCode); + bean.setMarkerId(marker.getMarkerIdReal()); + bean.setLng(marker.getLongitude()); + bean.setLat(marker.getLatitude()); + bean.setIsDetected("0"); + bean.setDetectedTime(""); + insert(bean); + } + } + + @Query("SELECT * FROM task_marker_info WHERE taskId = :taskId AND taskCode = :taskCode AND markerId = :markerId AND isDetected = :state") + TaskMarkerBean queryTaskMarkerById(String taskId, String taskCode, String markerId, String state); + + @Update + void updateLocalTaskMarkerState(TaskMarkerBean marker); + + @Query("SELECT * FROM task_marker_info WHERE isDetected = :state") + List queryMarkerByState(String state); + + @Query("SELECT * FROM task_marker_info WHERE taskId = :taskId AND taskCode = :taskCode") + List getMarkersByIdAndCode(String taskId, String taskCode); + + @Delete + void delete(TaskMarkerBean marker); +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/extensions/Long.kt b/app/src/main/java/com/casic/common/detector/gd/extensions/Long.kt deleted file mode 100644 index 6713d8d..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/extensions/Long.kt +++ /dev/null @@ -1,10 +0,0 @@ -package com.casic.common.detector.gd.extensions - -import java.text.SimpleDateFormat -import java.util.Date -import java.util.Locale - -fun Long.createTaskCode(): String { - val dateFormat = SimpleDateFormat("yyyyMMddHHmmss", Locale.CHINA) - return dateFormat.format(Date(this)) -} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoMaster.java b/app/src/main/java/com/casic/common/detector/gd/greendao/DaoMaster.java deleted file mode 100644 index 6ab94b3..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoMaster.java +++ /dev/null @@ -1,102 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import android.content.Context; -import android.database.sqlite.SQLiteDatabase; -import android.database.sqlite.SQLiteDatabase.CursorFactory; -import android.util.Log; - -import org.greenrobot.greendao.AbstractDaoMaster; -import org.greenrobot.greendao.database.StandardDatabase; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.database.DatabaseOpenHelper; -import org.greenrobot.greendao.identityscope.IdentityScopeType; - - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** - * Master of DAO (schema version 1): knows all DAOs. - */ -public class DaoMaster extends AbstractDaoMaster { - public static final int SCHEMA_VERSION = 1; - - /** Creates underlying database table using DAOs. */ - public static void createAllTables(Database db, boolean ifNotExists) { - MarkerLocalBeanDao.createTable(db, ifNotExists); - TaskLocalBeanDao.createTable(db, ifNotExists); - TaskMarkerLocalBeanDao.createTable(db, ifNotExists); - } - - /** Drops underlying database table using DAOs. */ - public static void dropAllTables(Database db, boolean ifExists) { - MarkerLocalBeanDao.dropTable(db, ifExists); - TaskLocalBeanDao.dropTable(db, ifExists); - TaskMarkerLocalBeanDao.dropTable(db, ifExists); - } - - /** - * WARNING: Drops all table on Upgrade! Use only during development. - * Convenience method using a {@link DevOpenHelper}. - */ - public static DaoSession newDevSession(Context context, String name) { - Database db = new DevOpenHelper(context, name).getWritableDb(); - DaoMaster daoMaster = new DaoMaster(db); - return daoMaster.newSession(); - } - - public DaoMaster(SQLiteDatabase db) { - this(new StandardDatabase(db)); - } - - public DaoMaster(Database db) { - super(db, SCHEMA_VERSION); - registerDaoClass(MarkerLocalBeanDao.class); - registerDaoClass(TaskLocalBeanDao.class); - registerDaoClass(TaskMarkerLocalBeanDao.class); - } - - public DaoSession newSession() { - return new DaoSession(db, IdentityScopeType.Session, daoConfigMap); - } - - public DaoSession newSession(IdentityScopeType type) { - return new DaoSession(db, type, daoConfigMap); - } - - /** - * Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} - - */ - public static abstract class OpenHelper extends DatabaseOpenHelper { - public OpenHelper(Context context, String name) { - super(context, name, SCHEMA_VERSION); - } - - public OpenHelper(Context context, String name, CursorFactory factory) { - super(context, name, factory, SCHEMA_VERSION); - } - - @Override - public void onCreate(Database db) { - Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION); - createAllTables(db, false); - } - } - - /** WARNING: Drops all table on Upgrade! Use only during development. */ - public static class DevOpenHelper extends OpenHelper { - public DevOpenHelper(Context context, String name) { - super(context, name); - } - - public DevOpenHelper(Context context, String name, CursorFactory factory) { - super(context, name, factory); - } - - @Override - public void onUpgrade(Database db, int oldVersion, int newVersion) { - Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables"); - dropAllTables(db, true); - onCreate(db); - } - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoSession.java b/app/src/main/java/com/casic/common/detector/gd/greendao/DaoSession.java deleted file mode 100644 index c8b1a20..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoSession.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import java.util.Map; - -import org.greenrobot.greendao.AbstractDao; -import org.greenrobot.greendao.AbstractDaoSession; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.identityscope.IdentityScopeType; -import org.greenrobot.greendao.internal.DaoConfig; - -import com.casic.common.detector.gd.bean.MarkerLocalBean; -import com.casic.common.detector.gd.bean.TaskLocalBean; -import com.casic.common.detector.gd.bean.TaskMarkerLocalBean; - -import com.casic.common.detector.gd.greendao.MarkerLocalBeanDao; -import com.casic.common.detector.gd.greendao.TaskLocalBeanDao; -import com.casic.common.detector.gd.greendao.TaskMarkerLocalBeanDao; - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. - -/** - * {@inheritDoc} - * - * @see org.greenrobot.greendao.AbstractDaoSession - */ -public class DaoSession extends AbstractDaoSession { - - private final DaoConfig markerLocalBeanDaoConfig; - private final DaoConfig taskLocalBeanDaoConfig; - private final DaoConfig taskMarkerLocalBeanDaoConfig; - - private final MarkerLocalBeanDao markerLocalBeanDao; - private final TaskLocalBeanDao taskLocalBeanDao; - private final TaskMarkerLocalBeanDao taskMarkerLocalBeanDao; - - public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> - daoConfigMap) { - super(db); - - markerLocalBeanDaoConfig = daoConfigMap.get(MarkerLocalBeanDao.class).clone(); - markerLocalBeanDaoConfig.initIdentityScope(type); - - taskLocalBeanDaoConfig = daoConfigMap.get(TaskLocalBeanDao.class).clone(); - taskLocalBeanDaoConfig.initIdentityScope(type); - - taskMarkerLocalBeanDaoConfig = daoConfigMap.get(TaskMarkerLocalBeanDao.class).clone(); - taskMarkerLocalBeanDaoConfig.initIdentityScope(type); - - markerLocalBeanDao = new MarkerLocalBeanDao(markerLocalBeanDaoConfig, this); - taskLocalBeanDao = new TaskLocalBeanDao(taskLocalBeanDaoConfig, this); - taskMarkerLocalBeanDao = new TaskMarkerLocalBeanDao(taskMarkerLocalBeanDaoConfig, this); - - registerDao(MarkerLocalBean.class, markerLocalBeanDao); - registerDao(TaskLocalBean.class, taskLocalBeanDao); - registerDao(TaskMarkerLocalBean.class, taskMarkerLocalBeanDao); - } - - public void clear() { - markerLocalBeanDaoConfig.clearIdentityScope(); - taskLocalBeanDaoConfig.clearIdentityScope(); - taskMarkerLocalBeanDaoConfig.clearIdentityScope(); - } - - public MarkerLocalBeanDao getMarkerLocalBeanDao() { - return markerLocalBeanDao; - } - - public TaskLocalBeanDao getTaskLocalBeanDao() { - return taskLocalBeanDao; - } - - public TaskMarkerLocalBeanDao getTaskMarkerLocalBeanDao() { - return taskMarkerLocalBeanDao; - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/MarkerLocalBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/greendao/MarkerLocalBeanDao.java deleted file mode 100644 index 2f792c3..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/MarkerLocalBeanDao.java +++ /dev/null @@ -1,479 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import android.database.Cursor; -import android.database.sqlite.SQLiteStatement; - -import org.greenrobot.greendao.AbstractDao; -import org.greenrobot.greendao.Property; -import org.greenrobot.greendao.internal.DaoConfig; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.database.DatabaseStatement; - -import com.casic.common.detector.gd.bean.MarkerLocalBean; - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** - * DAO for table "MARKER_LOCAL_BEAN". -*/ -public class MarkerLocalBeanDao extends AbstractDao { - - public static final String TABLENAME = "MARKER_LOCAL_BEAN"; - - /** - * Properties of entity MarkerLocalBean.
- * Can be used for QueryBuilder and for referencing column names. - */ - public static class Properties { - public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property PipelineType = new Property(1, String.class, "pipelineType", false, "PIPELINE_TYPE"); - public final static Property PipelineDiameter = new Property(2, String.class, "pipelineDiameter", false, "PIPELINE_DIAMETER"); - public final static Property PipelineMaterial = new Property(3, String.class, "pipelineMaterial", false, "PIPELINE_MATERIAL"); - public final static Property BuryMethod = new Property(4, String.class, "buryMethod", false, "BURY_METHOD"); - public final static Property BuryDepth = new Property(5, String.class, "buryDepth", false, "BURY_DEPTH"); - public final static Property Area = new Property(6, String.class, "area", false, "AREA"); - public final static Property Line = new Property(7, String.class, "line", false, "LINE"); - public final static Property Road = new Property(8, String.class, "road", false, "ROAD"); - public final static Property ConstructTime = new Property(9, String.class, "constructTime", false, "CONSTRUCT_TIME"); - public final static Property Owner = new Property(10, String.class, "owner", false, "OWNER"); - public final static Property ObjectId = new Property(11, String.class, "objectId", false, "OBJECT_ID"); - public final static Property MarkerId = new Property(12, String.class, "markerId", false, "MARKER_ID"); - public final static Property MarkerType = new Property(13, String.class, "markerType", false, "MARKER_TYPE"); - public final static Property MarkerDepth = new Property(14, String.class, "markerDepth", false, "MARKER_DEPTH"); - public final static Property InstallationDept = new Property(15, String.class, "installationDept", false, "INSTALLATION_DEPT"); - public final static Property Lng = new Property(16, String.class, "lng", false, "LNG"); - public final static Property Lat = new Property(17, String.class, "lat", false, "LAT"); - public final static Property UpdateTime = new Property(18, String.class, "updateTime", false, "UPDATE_TIME"); - public final static Property Remark = new Property(19, String.class, "remark", false, "REMARK"); - public final static Property UnderlyingPipelineType = new Property(20, String.class, "underlyingPipelineType", false, "UNDERLYING_PIPELINE_TYPE"); - public final static Property UnderlyingPipelineDepth = new Property(21, String.class, "underlyingPipelineDepth", false, "UNDERLYING_PIPELINE_DEPTH"); - public final static Property UnderlyingPipelineDiameter = new Property(22, String.class, "underlyingPipelineDiameter", false, "UNDERLYING_PIPELINE_DIAMETER"); - public final static Property UnderlyingPipelineMaterial = new Property(23, String.class, "underlyingPipelineMaterial", false, "UNDERLYING_PIPELINE_MATERIAL"); - public final static Property ObjectType = new Property(24, String.class, "objectType", false, "OBJECT_TYPE"); - public final static Property Color = new Property(25, String.class, "color", false, "COLOR"); - public final static Property ImagePath = new Property(26, String.class, "imagePath", false, "IMAGE_PATH"); - } - - - public MarkerLocalBeanDao(DaoConfig config) { - super(config); - } - - public MarkerLocalBeanDao(DaoConfig config, DaoSession daoSession) { - super(config, daoSession); - } - - /** Creates the underlying database table. */ - public static void createTable(Database db, boolean ifNotExists) { - String constraint = ifNotExists? "IF NOT EXISTS ": ""; - db.execSQL("CREATE TABLE " + constraint + "\"MARKER_LOCAL_BEAN\" (" + // - "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id - "\"PIPELINE_TYPE\" TEXT," + // 1: pipelineType - "\"PIPELINE_DIAMETER\" TEXT," + // 2: pipelineDiameter - "\"PIPELINE_MATERIAL\" TEXT," + // 3: pipelineMaterial - "\"BURY_METHOD\" TEXT," + // 4: buryMethod - "\"BURY_DEPTH\" TEXT," + // 5: buryDepth - "\"AREA\" TEXT," + // 6: area - "\"LINE\" TEXT," + // 7: line - "\"ROAD\" TEXT," + // 8: road - "\"CONSTRUCT_TIME\" TEXT," + // 9: constructTime - "\"OWNER\" TEXT," + // 10: owner - "\"OBJECT_ID\" TEXT," + // 11: objectId - "\"MARKER_ID\" TEXT," + // 12: markerId - "\"MARKER_TYPE\" TEXT," + // 13: markerType - "\"MARKER_DEPTH\" TEXT," + // 14: markerDepth - "\"INSTALLATION_DEPT\" TEXT," + // 15: installationDept - "\"LNG\" TEXT," + // 16: lng - "\"LAT\" TEXT," + // 17: lat - "\"UPDATE_TIME\" TEXT," + // 18: updateTime - "\"REMARK\" TEXT," + // 19: remark - "\"UNDERLYING_PIPELINE_TYPE\" TEXT," + // 20: underlyingPipelineType - "\"UNDERLYING_PIPELINE_DEPTH\" TEXT," + // 21: underlyingPipelineDepth - "\"UNDERLYING_PIPELINE_DIAMETER\" TEXT," + // 22: underlyingPipelineDiameter - "\"UNDERLYING_PIPELINE_MATERIAL\" TEXT," + // 23: underlyingPipelineMaterial - "\"OBJECT_TYPE\" TEXT," + // 24: objectType - "\"COLOR\" TEXT," + // 25: color - "\"IMAGE_PATH\" TEXT);"); // 26: imagePath - } - - /** Drops the underlying database table. */ - public static void dropTable(Database db, boolean ifExists) { - String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"MARKER_LOCAL_BEAN\""; - db.execSQL(sql); - } - - @Override - protected final void bindValues(DatabaseStatement stmt, MarkerLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String pipelineType = entity.getPipelineType(); - if (pipelineType != null) { - stmt.bindString(2, pipelineType); - } - - String pipelineDiameter = entity.getPipelineDiameter(); - if (pipelineDiameter != null) { - stmt.bindString(3, pipelineDiameter); - } - - String pipelineMaterial = entity.getPipelineMaterial(); - if (pipelineMaterial != null) { - stmt.bindString(4, pipelineMaterial); - } - - String buryMethod = entity.getBuryMethod(); - if (buryMethod != null) { - stmt.bindString(5, buryMethod); - } - - String buryDepth = entity.getBuryDepth(); - if (buryDepth != null) { - stmt.bindString(6, buryDepth); - } - - String area = entity.getArea(); - if (area != null) { - stmt.bindString(7, area); - } - - String line = entity.getLine(); - if (line != null) { - stmt.bindString(8, line); - } - - String road = entity.getRoad(); - if (road != null) { - stmt.bindString(9, road); - } - - String constructTime = entity.getConstructTime(); - if (constructTime != null) { - stmt.bindString(10, constructTime); - } - - String owner = entity.getOwner(); - if (owner != null) { - stmt.bindString(11, owner); - } - - String objectId = entity.getObjectId(); - if (objectId != null) { - stmt.bindString(12, objectId); - } - - String markerId = entity.getMarkerId(); - if (markerId != null) { - stmt.bindString(13, markerId); - } - - String markerType = entity.getMarkerType(); - if (markerType != null) { - stmt.bindString(14, markerType); - } - - String markerDepth = entity.getMarkerDepth(); - if (markerDepth != null) { - stmt.bindString(15, markerDepth); - } - - String installationDept = entity.getInstallationDept(); - if (installationDept != null) { - stmt.bindString(16, installationDept); - } - - String lng = entity.getLng(); - if (lng != null) { - stmt.bindString(17, lng); - } - - String lat = entity.getLat(); - if (lat != null) { - stmt.bindString(18, lat); - } - - String updateTime = entity.getUpdateTime(); - if (updateTime != null) { - stmt.bindString(19, updateTime); - } - - String remark = entity.getRemark(); - if (remark != null) { - stmt.bindString(20, remark); - } - - String underlyingPipelineType = entity.getUnderlyingPipelineType(); - if (underlyingPipelineType != null) { - stmt.bindString(21, underlyingPipelineType); - } - - String underlyingPipelineDepth = entity.getUnderlyingPipelineDepth(); - if (underlyingPipelineDepth != null) { - stmt.bindString(22, underlyingPipelineDepth); - } - - String underlyingPipelineDiameter = entity.getUnderlyingPipelineDiameter(); - if (underlyingPipelineDiameter != null) { - stmt.bindString(23, underlyingPipelineDiameter); - } - - String underlyingPipelineMaterial = entity.getUnderlyingPipelineMaterial(); - if (underlyingPipelineMaterial != null) { - stmt.bindString(24, underlyingPipelineMaterial); - } - - String objectType = entity.getObjectType(); - if (objectType != null) { - stmt.bindString(25, objectType); - } - - String color = entity.getColor(); - if (color != null) { - stmt.bindString(26, color); - } - - String imagePath = entity.getImagePath(); - if (imagePath != null) { - stmt.bindString(27, imagePath); - } - } - - @Override - protected final void bindValues(SQLiteStatement stmt, MarkerLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String pipelineType = entity.getPipelineType(); - if (pipelineType != null) { - stmt.bindString(2, pipelineType); - } - - String pipelineDiameter = entity.getPipelineDiameter(); - if (pipelineDiameter != null) { - stmt.bindString(3, pipelineDiameter); - } - - String pipelineMaterial = entity.getPipelineMaterial(); - if (pipelineMaterial != null) { - stmt.bindString(4, pipelineMaterial); - } - - String buryMethod = entity.getBuryMethod(); - if (buryMethod != null) { - stmt.bindString(5, buryMethod); - } - - String buryDepth = entity.getBuryDepth(); - if (buryDepth != null) { - stmt.bindString(6, buryDepth); - } - - String area = entity.getArea(); - if (area != null) { - stmt.bindString(7, area); - } - - String line = entity.getLine(); - if (line != null) { - stmt.bindString(8, line); - } - - String road = entity.getRoad(); - if (road != null) { - stmt.bindString(9, road); - } - - String constructTime = entity.getConstructTime(); - if (constructTime != null) { - stmt.bindString(10, constructTime); - } - - String owner = entity.getOwner(); - if (owner != null) { - stmt.bindString(11, owner); - } - - String objectId = entity.getObjectId(); - if (objectId != null) { - stmt.bindString(12, objectId); - } - - String markerId = entity.getMarkerId(); - if (markerId != null) { - stmt.bindString(13, markerId); - } - - String markerType = entity.getMarkerType(); - if (markerType != null) { - stmt.bindString(14, markerType); - } - - String markerDepth = entity.getMarkerDepth(); - if (markerDepth != null) { - stmt.bindString(15, markerDepth); - } - - String installationDept = entity.getInstallationDept(); - if (installationDept != null) { - stmt.bindString(16, installationDept); - } - - String lng = entity.getLng(); - if (lng != null) { - stmt.bindString(17, lng); - } - - String lat = entity.getLat(); - if (lat != null) { - stmt.bindString(18, lat); - } - - String updateTime = entity.getUpdateTime(); - if (updateTime != null) { - stmt.bindString(19, updateTime); - } - - String remark = entity.getRemark(); - if (remark != null) { - stmt.bindString(20, remark); - } - - String underlyingPipelineType = entity.getUnderlyingPipelineType(); - if (underlyingPipelineType != null) { - stmt.bindString(21, underlyingPipelineType); - } - - String underlyingPipelineDepth = entity.getUnderlyingPipelineDepth(); - if (underlyingPipelineDepth != null) { - stmt.bindString(22, underlyingPipelineDepth); - } - - String underlyingPipelineDiameter = entity.getUnderlyingPipelineDiameter(); - if (underlyingPipelineDiameter != null) { - stmt.bindString(23, underlyingPipelineDiameter); - } - - String underlyingPipelineMaterial = entity.getUnderlyingPipelineMaterial(); - if (underlyingPipelineMaterial != null) { - stmt.bindString(24, underlyingPipelineMaterial); - } - - String objectType = entity.getObjectType(); - if (objectType != null) { - stmt.bindString(25, objectType); - } - - String color = entity.getColor(); - if (color != null) { - stmt.bindString(26, color); - } - - String imagePath = entity.getImagePath(); - if (imagePath != null) { - stmt.bindString(27, imagePath); - } - } - - @Override - public Long readKey(Cursor cursor, int offset) { - return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); - } - - @Override - public MarkerLocalBean readEntity(Cursor cursor, int offset) { - MarkerLocalBean entity = new MarkerLocalBean( // - cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // pipelineType - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // pipelineDiameter - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // pipelineMaterial - cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // buryMethod - cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // buryDepth - cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // area - cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // line - cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // road - cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // constructTime - cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10), // owner - cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11), // objectId - cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12), // markerId - cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13), // markerType - cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14), // markerDepth - cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15), // installationDept - cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16), // lng - cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17), // lat - cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18), // updateTime - cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19), // remark - cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20), // underlyingPipelineType - cursor.isNull(offset + 21) ? null : cursor.getString(offset + 21), // underlyingPipelineDepth - cursor.isNull(offset + 22) ? null : cursor.getString(offset + 22), // underlyingPipelineDiameter - cursor.isNull(offset + 23) ? null : cursor.getString(offset + 23), // underlyingPipelineMaterial - cursor.isNull(offset + 24) ? null : cursor.getString(offset + 24), // objectType - cursor.isNull(offset + 25) ? null : cursor.getString(offset + 25), // color - cursor.isNull(offset + 26) ? null : cursor.getString(offset + 26) // imagePath - ); - return entity; - } - - @Override - public void readEntity(Cursor cursor, MarkerLocalBean entity, int offset) { - entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setPipelineType(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); - entity.setPipelineDiameter(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); - entity.setPipelineMaterial(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); - entity.setBuryMethod(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); - entity.setBuryDepth(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); - entity.setArea(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); - entity.setLine(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); - entity.setRoad(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); - entity.setConstructTime(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9)); - entity.setOwner(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); - entity.setObjectId(cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11)); - entity.setMarkerId(cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12)); - entity.setMarkerType(cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13)); - entity.setMarkerDepth(cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14)); - entity.setInstallationDept(cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15)); - entity.setLng(cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16)); - entity.setLat(cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17)); - entity.setUpdateTime(cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18)); - entity.setRemark(cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19)); - entity.setUnderlyingPipelineType(cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20)); - entity.setUnderlyingPipelineDepth(cursor.isNull(offset + 21) ? null : cursor.getString(offset + 21)); - entity.setUnderlyingPipelineDiameter(cursor.isNull(offset + 22) ? null : cursor.getString(offset + 22)); - entity.setUnderlyingPipelineMaterial(cursor.isNull(offset + 23) ? null : cursor.getString(offset + 23)); - entity.setObjectType(cursor.isNull(offset + 24) ? null : cursor.getString(offset + 24)); - entity.setColor(cursor.isNull(offset + 25) ? null : cursor.getString(offset + 25)); - entity.setImagePath(cursor.isNull(offset + 26) ? null : cursor.getString(offset + 26)); - } - - @Override - protected final Long updateKeyAfterInsert(MarkerLocalBean entity, long rowId) { - entity.setId(rowId); - return rowId; - } - - @Override - public Long getKey(MarkerLocalBean entity) { - if(entity != null) { - return entity.getId(); - } else { - return null; - } - } - - @Override - public boolean hasKey(MarkerLocalBean entity) { - return entity.getId() != null; - } - - @Override - protected final boolean isEntityUpdateable() { - return true; - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/TaskLocalBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/greendao/TaskLocalBeanDao.java deleted file mode 100644 index fb88157..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/TaskLocalBeanDao.java +++ /dev/null @@ -1,227 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import android.database.Cursor; -import android.database.sqlite.SQLiteStatement; - -import org.greenrobot.greendao.AbstractDao; -import org.greenrobot.greendao.Property; -import org.greenrobot.greendao.internal.DaoConfig; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.database.DatabaseStatement; - -import com.casic.common.detector.gd.bean.TaskLocalBean; - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** - * DAO for table "TASK_LOCAL_BEAN". -*/ -public class TaskLocalBeanDao extends AbstractDao { - - public static final String TABLENAME = "TASK_LOCAL_BEAN"; - - /** - * Properties of entity TaskLocalBean.
- * Can be used for QueryBuilder and for referencing column names. - */ - public static class Properties { - public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property TaskCode = new Property(1, String.class, "taskCode", false, "TASK_CODE"); - public final static Property Description = new Property(2, String.class, "description", false, "DESCRIPTION"); - public final static Property CreateTime = new Property(3, String.class, "createTime", false, "CREATE_TIME"); - public final static Property Status = new Property(4, String.class, "status", false, "STATUS"); - public final static Property CreateUserName = new Property(5, String.class, "createUserName", false, "CREATE_USER_NAME"); - public final static Property StartTime = new Property(6, String.class, "startTime", false, "START_TIME"); - public final static Property EndTime = new Property(7, String.class, "endTime", false, "END_TIME"); - public final static Property IsFreeTask = new Property(8, String.class, "isFreeTask", false, "IS_FREE_TASK"); - } - - - public TaskLocalBeanDao(DaoConfig config) { - super(config); - } - - public TaskLocalBeanDao(DaoConfig config, DaoSession daoSession) { - super(config, daoSession); - } - - /** Creates the underlying database table. */ - public static void createTable(Database db, boolean ifNotExists) { - String constraint = ifNotExists? "IF NOT EXISTS ": ""; - db.execSQL("CREATE TABLE " + constraint + "\"TASK_LOCAL_BEAN\" (" + // - "\"_id\" INTEGER PRIMARY KEY ," + // 0: id - "\"TASK_CODE\" TEXT," + // 1: taskCode - "\"DESCRIPTION\" TEXT," + // 2: description - "\"CREATE_TIME\" TEXT," + // 3: createTime - "\"STATUS\" TEXT," + // 4: status - "\"CREATE_USER_NAME\" TEXT," + // 5: createUserName - "\"START_TIME\" TEXT," + // 6: startTime - "\"END_TIME\" TEXT," + // 7: endTime - "\"IS_FREE_TASK\" TEXT);"); // 8: isFreeTask - } - - /** Drops the underlying database table. */ - public static void dropTable(Database db, boolean ifExists) { - String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"TASK_LOCAL_BEAN\""; - db.execSQL(sql); - } - - @Override - protected final void bindValues(DatabaseStatement stmt, TaskLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String taskCode = entity.getTaskCode(); - if (taskCode != null) { - stmt.bindString(2, taskCode); - } - - String description = entity.getDescription(); - if (description != null) { - stmt.bindString(3, description); - } - - String createTime = entity.getCreateTime(); - if (createTime != null) { - stmt.bindString(4, createTime); - } - - String status = entity.getStatus(); - if (status != null) { - stmt.bindString(5, status); - } - - String createUserName = entity.getCreateUserName(); - if (createUserName != null) { - stmt.bindString(6, createUserName); - } - - String startTime = entity.getStartTime(); - if (startTime != null) { - stmt.bindString(7, startTime); - } - - String endTime = entity.getEndTime(); - if (endTime != null) { - stmt.bindString(8, endTime); - } - - String isFreeTask = entity.getIsFreeTask(); - if (isFreeTask != null) { - stmt.bindString(9, isFreeTask); - } - } - - @Override - protected final void bindValues(SQLiteStatement stmt, TaskLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String taskCode = entity.getTaskCode(); - if (taskCode != null) { - stmt.bindString(2, taskCode); - } - - String description = entity.getDescription(); - if (description != null) { - stmt.bindString(3, description); - } - - String createTime = entity.getCreateTime(); - if (createTime != null) { - stmt.bindString(4, createTime); - } - - String status = entity.getStatus(); - if (status != null) { - stmt.bindString(5, status); - } - - String createUserName = entity.getCreateUserName(); - if (createUserName != null) { - stmt.bindString(6, createUserName); - } - - String startTime = entity.getStartTime(); - if (startTime != null) { - stmt.bindString(7, startTime); - } - - String endTime = entity.getEndTime(); - if (endTime != null) { - stmt.bindString(8, endTime); - } - - String isFreeTask = entity.getIsFreeTask(); - if (isFreeTask != null) { - stmt.bindString(9, isFreeTask); - } - } - - @Override - public Long readKey(Cursor cursor, int offset) { - return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); - } - - @Override - public TaskLocalBean readEntity(Cursor cursor, int offset) { - TaskLocalBean entity = new TaskLocalBean( // - cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // taskCode - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // description - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // createTime - cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // status - cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // createUserName - cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // startTime - cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // endTime - cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8) // isFreeTask - ); - return entity; - } - - @Override - public void readEntity(Cursor cursor, TaskLocalBean entity, int offset) { - entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setTaskCode(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); - entity.setDescription(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); - entity.setCreateTime(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); - entity.setStatus(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); - entity.setCreateUserName(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); - entity.setStartTime(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); - entity.setEndTime(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); - entity.setIsFreeTask(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); - } - - @Override - protected final Long updateKeyAfterInsert(TaskLocalBean entity, long rowId) { - entity.setId(rowId); - return rowId; - } - - @Override - public Long getKey(TaskLocalBean entity) { - if(entity != null) { - return entity.getId(); - } else { - return null; - } - } - - @Override - public boolean hasKey(TaskLocalBean entity) { - return entity.getId() != null; - } - - @Override - protected final boolean isEntityUpdateable() { - return true; - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/TaskMarkerLocalBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/greendao/TaskMarkerLocalBeanDao.java deleted file mode 100644 index e96c735..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/TaskMarkerLocalBeanDao.java +++ /dev/null @@ -1,197 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import android.database.Cursor; -import android.database.sqlite.SQLiteStatement; - -import org.greenrobot.greendao.AbstractDao; -import org.greenrobot.greendao.Property; -import org.greenrobot.greendao.internal.DaoConfig; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.database.DatabaseStatement; - -import com.casic.common.detector.gd.bean.TaskMarkerLocalBean; - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** - * DAO for table "TASK_MARKER_LOCAL_BEAN". -*/ -public class TaskMarkerLocalBeanDao extends AbstractDao { - - public static final String TABLENAME = "TASK_MARKER_LOCAL_BEAN"; - - /** - * Properties of entity TaskMarkerLocalBean.
- * Can be used for QueryBuilder and for referencing column names. - */ - public static class Properties { - public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property TaskId = new Property(1, String.class, "taskId", false, "TASK_ID"); - public final static Property TaskCode = new Property(2, String.class, "taskCode", false, "TASK_CODE"); - public final static Property MarkerId = new Property(3, String.class, "markerId", false, "MARKER_ID"); - public final static Property Lng = new Property(4, double.class, "lng", false, "LNG"); - public final static Property Lat = new Property(5, double.class, "lat", false, "LAT"); - public final static Property IsDetected = new Property(6, String.class, "isDetected", false, "IS_DETECTED"); - public final static Property DetectedTime = new Property(7, String.class, "detectedTime", false, "DETECTED_TIME"); - } - - - public TaskMarkerLocalBeanDao(DaoConfig config) { - super(config); - } - - public TaskMarkerLocalBeanDao(DaoConfig config, DaoSession daoSession) { - super(config, daoSession); - } - - /** Creates the underlying database table. */ - public static void createTable(Database db, boolean ifNotExists) { - String constraint = ifNotExists? "IF NOT EXISTS ": ""; - db.execSQL("CREATE TABLE " + constraint + "\"TASK_MARKER_LOCAL_BEAN\" (" + // - "\"_id\" INTEGER PRIMARY KEY ," + // 0: id - "\"TASK_ID\" TEXT," + // 1: taskId - "\"TASK_CODE\" TEXT," + // 2: taskCode - "\"MARKER_ID\" TEXT," + // 3: markerId - "\"LNG\" REAL NOT NULL ," + // 4: lng - "\"LAT\" REAL NOT NULL ," + // 5: lat - "\"IS_DETECTED\" TEXT," + // 6: isDetected - "\"DETECTED_TIME\" TEXT);"); // 7: detectedTime - } - - /** Drops the underlying database table. */ - public static void dropTable(Database db, boolean ifExists) { - String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"TASK_MARKER_LOCAL_BEAN\""; - db.execSQL(sql); - } - - @Override - protected final void bindValues(DatabaseStatement stmt, TaskMarkerLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String taskId = entity.getTaskId(); - if (taskId != null) { - stmt.bindString(2, taskId); - } - - String taskCode = entity.getTaskCode(); - if (taskCode != null) { - stmt.bindString(3, taskCode); - } - - String markerId = entity.getMarkerId(); - if (markerId != null) { - stmt.bindString(4, markerId); - } - stmt.bindDouble(5, entity.getLng()); - stmt.bindDouble(6, entity.getLat()); - - String isDetected = entity.getIsDetected(); - if (isDetected != null) { - stmt.bindString(7, isDetected); - } - - String detectedTime = entity.getDetectedTime(); - if (detectedTime != null) { - stmt.bindString(8, detectedTime); - } - } - - @Override - protected final void bindValues(SQLiteStatement stmt, TaskMarkerLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String taskId = entity.getTaskId(); - if (taskId != null) { - stmt.bindString(2, taskId); - } - - String taskCode = entity.getTaskCode(); - if (taskCode != null) { - stmt.bindString(3, taskCode); - } - - String markerId = entity.getMarkerId(); - if (markerId != null) { - stmt.bindString(4, markerId); - } - stmt.bindDouble(5, entity.getLng()); - stmt.bindDouble(6, entity.getLat()); - - String isDetected = entity.getIsDetected(); - if (isDetected != null) { - stmt.bindString(7, isDetected); - } - - String detectedTime = entity.getDetectedTime(); - if (detectedTime != null) { - stmt.bindString(8, detectedTime); - } - } - - @Override - public Long readKey(Cursor cursor, int offset) { - return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); - } - - @Override - public TaskMarkerLocalBean readEntity(Cursor cursor, int offset) { - TaskMarkerLocalBean entity = new TaskMarkerLocalBean( // - cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // taskId - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // taskCode - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // markerId - cursor.getDouble(offset + 4), // lng - cursor.getDouble(offset + 5), // lat - cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // isDetected - cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7) // detectedTime - ); - return entity; - } - - @Override - public void readEntity(Cursor cursor, TaskMarkerLocalBean entity, int offset) { - entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setTaskId(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); - entity.setTaskCode(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); - entity.setMarkerId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); - entity.setLng(cursor.getDouble(offset + 4)); - entity.setLat(cursor.getDouble(offset + 5)); - entity.setIsDetected(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); - entity.setDetectedTime(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); - } - - @Override - protected final Long updateKeyAfterInsert(TaskMarkerLocalBean entity, long rowId) { - entity.setId(rowId); - return rowId; - } - - @Override - public Long getKey(TaskMarkerLocalBean entity) { - if(entity != null) { - return entity.getId(); - } else { - return null; - } - } - - @Override - public boolean hasKey(TaskMarkerLocalBean entity) { - return entity.getId() != null; - } - - @Override - protected final boolean isEntityUpdateable() { - return true; - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/model/TaskModel.java b/app/src/main/java/com/casic/common/detector/gd/model/TaskModel.java index 6e853ad..67ef5fb 100644 --- a/app/src/main/java/com/casic/common/detector/gd/model/TaskModel.java +++ b/app/src/main/java/com/casic/common/detector/gd/model/TaskModel.java @@ -24,7 +24,7 @@ } public static class MessageModel { - private int id; + private Long id; private String taskCode; private String description; private String deployDate; @@ -38,11 +38,11 @@ private int isValid; private List taskDetailInfos; - public int getId() { + public Long getId() { return id; } - public void setId(int id) { + public void setId(Long id) { this.id = id; } @@ -143,25 +143,25 @@ } public static class TaskDetailInfosModel { - private int id; + private long id; private String taskId; private String taskCode; private Object markerName; - private int markerId; + private String markerId; private String markerIdReal; private double longitude; private double latitude; private int isChecked; private int isNormal; - private Object imagePath; - private Object description; - private Object finishTime; + private String imagePath; + private String description; + private String finishTime; - public int getId() { + public long getId() { return id; } - public void setId(int id) { + public void setId(long id) { this.id = id; } @@ -189,11 +189,11 @@ this.markerName = markerName; } - public int getMarkerId() { + public String getMarkerId() { return markerId; } - public void setMarkerId(int markerId) { + public void setMarkerId(String markerId) { this.markerId = markerId; } @@ -237,27 +237,27 @@ this.isNormal = isNormal; } - public Object getImagePath() { + public String getImagePath() { return imagePath; } - public void setImagePath(Object imagePath) { + public void setImagePath(String imagePath) { this.imagePath = imagePath; } - public Object getDescription() { + public String getDescription() { return description; } - public void setDescription(Object description) { + public void setDescription(String description) { this.description = description; } - public Object getFinishTime() { + public String getFinishTime() { return finishTime; } - public void setFinishTime(Object finishTime) { + public void setFinishTime(String finishTime) { this.finishTime = finishTime; } } diff --git a/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitService.kt index 7522a87..0adad51 100644 --- a/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitService.kt @@ -50,7 +50,7 @@ */ @Multipart @POST("/ems/marker/save-marker-photo.do") - suspend fun installLabel( + suspend fun install( @PartMap jsonMarker: Map, @Part fileBuffer1: MultipartBody.Part?, @Part fileBuffer2: MultipartBody.Part?, diff --git a/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitServiceManager.kt index 5f6c701..ae2a0fa 100644 --- a/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitServiceManager.kt +++ b/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitServiceManager.kt @@ -37,22 +37,28 @@ /** * 获取标识器信息文件 */ - suspend fun getMarkerFile(userId: String, companyId: String): String { - return createApi().getMarkerFile(userId, companyId) + suspend fun getMarkerFile(): String { + val companyId = SaveKeyValues.getValue(LocaleConstant.USER_COMPANY_ID, "") as String + /** + * 后台设计如此,都传companyId + * */ + return createApi().getMarkerFile(companyId, companyId) } /** * 获取巡检工单 */ - suspend fun getTasksByUser(userName: String): String { + suspend fun getTasksByUser(): String { + val userName = SaveKeyValues.getValue(LocaleConstant.USER_NAME, "") as String return createApi().getTasksByUser(userName) } /** * 提交工单 */ - suspend fun uploadTask(userId: String, taskId: String?, state: String): String { + suspend fun uploadTask(taskId: String?, state: String): String { + val userId = SaveKeyValues.getValue(LocaleConstant.USER_ID, "") as String return createApi().uploadTask(userId, taskId.toString(), state) } @@ -60,8 +66,7 @@ * 安装新标识器 * Multipart上传图片,文件,带多参数上传 */ - suspend fun installLabel( - companyId: String, + suspend fun installMarker( recordType: String, markerObjectType: String, pipeMaterial: String, @@ -77,7 +82,6 @@ road: String, constructTime: String, ownerComp: String, - markerObjectId: String, markerId: String, markerType: String, markerDepth: String, @@ -89,6 +93,8 @@ memo: String, realPaths: ArrayList ): String { + val companyId = SaveKeyValues.getValue(LocaleConstant.USER_COMPANY_ID, "") as String + val objectId = SaveKeyValues.getValue(LocaleConstant.OBJECT_ID, "") as String val param = JsonObject() param.addProperty("companyId", companyId) param.addProperty("recordType", recordType) @@ -106,7 +112,7 @@ param.addProperty("road", road) param.addProperty("constructTime", constructTime) param.addProperty("ownerComp", ownerComp) - param.addProperty("markerObjectId", markerObjectId) + param.addProperty("markerObjectId", objectId) param.addProperty("markerId", markerId) param.addProperty("markerType", markerType) param.addProperty("markerDepth", markerDepth) @@ -133,19 +139,19 @@ return when (multiParts.size) { 3 -> { - createApi().installLabel(res, multiParts[0], multiParts[1], multiParts[2]) + createApi().install(res, multiParts[0], multiParts[1], multiParts[2]) } 2 -> { - createApi().installLabel(res, multiParts[0], multiParts[1], null) + createApi().install(res, multiParts[0], multiParts[1], null) } 1 -> { - createApi().installLabel(res, multiParts[0], null, null) + createApi().install(res, multiParts[0], null, null) } else -> { - createApi().installLabel(res, null, null, null) + createApi().install(res, null, null, null) } } } @@ -216,7 +222,7 @@ /** * 上传自由巡检过程中发现的标识器 */ - suspend fun uploadTaskMarker(taskId: String, ids: ArrayList): String { + suspend fun uploadTaskMarker(taskId: Long, ids: ArrayList): String { val param = JsonObject() param.addProperty("taskId", taskId) param.addProperty("ids", ids.joinToString(separator = ",")) diff --git a/app/build.gradle b/app/build.gradle index d0cb423..921c8c8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,25 +1,20 @@ import java.text.SimpleDateFormat -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply plugin: 'org.greenrobot.greendao' +plugins { + id('com.android.application') + id('org.jetbrains.kotlin.android') +} android { - compileSdkVersion 33 + namespace 'com.casic.common.detector.gd' + compileSdk 35 defaultConfig { - applicationId "com.casic.common.detector.gd" - minSdkVersion 26 - targetSdkVersion 33 + applicationId 'com.casic.common.detector.gd' + minSdk 26 + targetSdk 35 versionCode 5092 - versionName "5.0.9.2" - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } + versionName '5.0.9.2' } signingConfigs { @@ -31,6 +26,14 @@ } } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + signingConfig signingConfigs.release + } + } + compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 @@ -47,27 +50,16 @@ } } - kotlin { - experimental { - coroutines 'enable' - } - } - buildFeatures { + buildConfig true viewBinding true } - applicationVariants.configureEach { variant -> - variant.outputs.configureEach { - outputFileName = "COM_TCY_" + getBuildDate() + "_" + defaultConfig.versionName + ".apk" + applicationVariants.configureEach { + outputs.configureEach { + outputFileName = 'COM_TCY_' + getBuildDate() + '_' + defaultConfig.versionName + '.apk' } } - - greendao { - schemaVersion 1//数据库版本号 - targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 - daoPackage "${defaultConfig.applicationId}.greendao"//设置DaoMaster、DaoSession、Dao包名 - } } static def getBuildDate() { @@ -76,27 +68,22 @@ } dependencies { - //基础依赖库 - implementation 'com.github.AndroidCoderPeng:Kotlin-lite-lib:1.1.4' - implementation 'androidx.core:core-ktx:1.9.0' - def base_version = "1.6.1" - implementation "androidx.appcompat:appcompat:${base_version}" - implementation "com.google.android.material:material:${base_version}" + implementation 'com.github.AndroidCoderPeng:Kotlin-lite-lib:1.1.5' + implementation 'androidx.core:core-ktx:1.13.1' + implementation 'androidx.appcompat:appcompat:1.7.0' + implementation 'com.google.android.material:material:1.12.0' //Google官方授权框架 implementation 'pub.devrel:easypermissions:3.0.0' - //沉浸式状态栏。基础依赖包,必须要依赖 - implementation 'com.gyf.immersionbar:immersionbar:3.0.0' - //fragment快速实现 - implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0' + //沉浸式状态栏 + implementation 'com.geyifeng.immersionbar:immersionbar:3.2.2' //官方Json解析库 implementation 'com.google.code.gson:gson:2.10.1' - def vm_version = '2.5.1' //Kotlin协程 - implementation "androidx.lifecycle:lifecycle-runtime-ktx:${vm_version}" + implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.2' //MVVM+LiveData - implementation "androidx.lifecycle:lifecycle-livedata-ktx:${vm_version}" - implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:${vm_version}" - implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.6.2' + implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2' + implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' //返回值转换器 implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' @@ -105,9 +92,10 @@ implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' //网络请求和接口封装 implementation 'com.squareup.retrofit2:retrofit:2.9.0' - implementation 'com.squareup.okhttp3:okhttp:4.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.12.0' //数据库框架 - implementation 'org.greenrobot:greendao:3.3.0' + implementation 'androidx.room:room-runtime:2.6.1' + annotationProcessor 'androidx.room:room-compiler:2.5.2' //高德导航、定位、地图三合一 implementation 'com.amap.api:navi-3dmap:latest.integration' //经纬度逆编码 @@ -115,7 +103,7 @@ //excel implementation 'net.sourceforge.jexcelapi:jxl:2.6.12' //图片加载框架 - implementation 'com.github.bumptech.glide:glide:4.9.0' + implementation 'com.github.bumptech.glide:glide:4.12.0' //图片选择框架 implementation 'io.github.lucksiege:pictureselector:v3.11.1' //大图 diff --git a/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt b/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt index 7b695ff..50ba734 100644 --- a/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt +++ b/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt @@ -4,9 +4,9 @@ import android.app.Application import android.os.Bundle import android.util.Log -import com.casic.common.detector.gd.greendao.DaoMaster -import com.casic.common.detector.gd.greendao.DaoSession +import androidx.room.Room.databaseBuilder import com.casic.common.detector.gd.uart.SerialPort +import com.casic.common.detector.gd.utils.DetectorDataBase import com.casic.common.detector.gd.utils.GpioManager import com.pengxh.kt.lite.extensions.show import com.pengxh.kt.lite.utils.SaveKeyValues @@ -43,44 +43,42 @@ private var application: BaseApplication by Delegates.notNull() fun get() = application - - private lateinit var daoSession: DaoSession } + lateinit var dataBase: DetectorDataBase + override fun onCreate() { super.onCreate() application = this SaveKeyValues.initSharedPreferences(this) CrashReport.initCrashReport(this, "01e80d3a74", true) - val devOpenHelper = DaoMaster.DevOpenHelper(this, "Detector.db", null) - val daoMaster = DaoMaster(devOpenHelper.writableDatabase) - daoSession = daoMaster.newSession() + dataBase = databaseBuilder(this, DetectorDataBase::class.java, "Detector.db") + .allowMainThreadQueries() + .build() /** * Open the serial port * */ try { serialPorts.apply { - add(SerialPort(File("/dev/ttysWK1"), 9600, 0)) - //千寻报文数据下发串口号 - add(SerialPort(File("/dev/ttyS1"), 9600, 0)) + add(SerialPort(File("/dev/ttysWK1"), 9600, 0)) //信号通讯串口 + add(SerialPort(File("/dev/ttyS1"), 9600, 0)) //千寻报文数据下发串口号 } Log.d(kTag, "onCreate: 已初始化 ${serialPorts.size} 个串口") } catch (e: SecurityException) { "您没有串口的读写权限!".show(this) + e.printStackTrace() } catch (e: IOException) { "因为不明原因,串口无法打开!".show(this) + e.printStackTrace() } catch (e: InvalidParameterException) { "请检查串口!".show(this) + e.printStackTrace() } registerActivityLifecycleCallbacks(this) } - fun getDaoSession(): DaoSession { - return daoSession - } - override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) { } diff --git a/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt b/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt index 053b9dd..1d0c9e3 100644 --- a/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt +++ b/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt @@ -14,12 +14,10 @@ import com.casic.common.detector.gd.utils.SerialPortCommand import com.pengxh.kt.lite.utils.WeakReferenceHandler import java.io.IOException -import java.util.Timer abstract class SerialPortBaseActivity : AppCompatActivity(), Handler.Callback { private val kTag = "SerialPortBaseActivity" - private val taskTimer by lazy { Timer() } private val weakReferenceHandler by lazy { WeakReferenceHandler(this) } private val serialPorts by lazy { BaseApplication.get().getSerialPorts() } protected lateinit var binding: VB @@ -30,7 +28,6 @@ setContentView(binding.root) setupTopBarLayout() initOnCreate(savedInstanceState) - observeRequestState() initEvent() if (serialPorts.isNotEmpty()) { @@ -71,11 +68,6 @@ abstract fun initOnCreate(savedInstanceState: Bundle?) /** - * 数据请求状态监听 - */ - abstract fun observeRequestState() - - /** * 初始化业务逻辑 */ abstract fun initEvent() diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java new file mode 100644 index 0000000..7a18c20 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java @@ -0,0 +1,255 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 从平台下载的标识器本地库实体类 + */ +@Entity(tableName = "marker_detail") +public class MarkerBean { + @PrimaryKey(autoGenerate = true) + private long id; //主键ID + private String pipelineType; // 管线类型 + private String pipelineDiameter; // 管线直径 + private String pipelineMaterial; // 管材 + private String buryMethod; // 埋设方式 + private String buryDepth; // 埋深 + private String area; // 所属区域 + private String line; // 所属线路 + private String road; // 所属道路 + private String constructTime; // 建设年代 + private String owner; // 权属单位 + private String objectId; // 标识对象ID,无实际用途 + private String markerId; // 标识器ID + private String markerType; // 标识器类型 + private String markerDepth; // 标识器埋深 + private String installationDept; // 安装部门 + private String lng; // 经度 + private String lat; // 纬度 + private String updateTime; // 最后修改时间,更新时间 + private String remark; // 备注信息 + private String underlyingPipelineType; // 下层管线类型 + private String underlyingPipelineDepth; // 下层埋深 + private String underlyingPipelineDiameter; // 下层管径 + private String underlyingPipelineMaterial; // 下层管材 + private String objectType; //标识对象类型 + private String color; // 颜色 + private String imagePath; // 图片路径 + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getPipelineType() { + return pipelineType; + } + + public void setPipelineType(String pipelineType) { + this.pipelineType = pipelineType; + } + + public String getPipelineDiameter() { + return pipelineDiameter; + } + + public void setPipelineDiameter(String pipelineDiameter) { + this.pipelineDiameter = pipelineDiameter; + } + + public String getPipelineMaterial() { + return pipelineMaterial; + } + + public void setPipelineMaterial(String pipelineMaterial) { + this.pipelineMaterial = pipelineMaterial; + } + + public String getBuryMethod() { + return buryMethod; + } + + public void setBuryMethod(String buryMethod) { + this.buryMethod = buryMethod; + } + + public String getBuryDepth() { + return buryDepth; + } + + public void setBuryDepth(String buryDepth) { + this.buryDepth = buryDepth; + } + + public String getArea() { + return area; + } + + public void setArea(String area) { + this.area = area; + } + + public String getLine() { + return line; + } + + public void setLine(String line) { + this.line = line; + } + + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + + public String getConstructTime() { + return constructTime; + } + + public void setConstructTime(String constructTime) { + this.constructTime = constructTime; + } + + public String getOwner() { + return owner; + } + + public void setOwner(String owner) { + this.owner = owner; + } + + public String getObjectId() { + return objectId; + } + + public void setObjectId(String objectId) { + this.objectId = objectId; + } + + public String getMarkerId() { + return markerId; + } + + public void setMarkerId(String markerId) { + this.markerId = markerId; + } + + public String getMarkerType() { + return markerType; + } + + public void setMarkerType(String markerType) { + this.markerType = markerType; + } + + public String getMarkerDepth() { + return markerDepth; + } + + public void setMarkerDepth(String markerDepth) { + this.markerDepth = markerDepth; + } + + public String getInstallationDept() { + return installationDept; + } + + public void setInstallationDept(String installationDept) { + this.installationDept = installationDept; + } + + public String getLng() { + return lng; + } + + public void setLng(String lng) { + this.lng = lng; + } + + public String getLat() { + return lat; + } + + public void setLat(String lat) { + this.lat = lat; + } + + public String getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } + + public String getUnderlyingPipelineType() { + return underlyingPipelineType; + } + + public void setUnderlyingPipelineType(String underlyingPipelineType) { + this.underlyingPipelineType = underlyingPipelineType; + } + + public String getUnderlyingPipelineDepth() { + return underlyingPipelineDepth; + } + + public void setUnderlyingPipelineDepth(String underlyingPipelineDepth) { + this.underlyingPipelineDepth = underlyingPipelineDepth; + } + + public String getUnderlyingPipelineDiameter() { + return underlyingPipelineDiameter; + } + + public void setUnderlyingPipelineDiameter(String underlyingPipelineDiameter) { + this.underlyingPipelineDiameter = underlyingPipelineDiameter; + } + + public String getUnderlyingPipelineMaterial() { + return underlyingPipelineMaterial; + } + + public void setUnderlyingPipelineMaterial(String underlyingPipelineMaterial) { + this.underlyingPipelineMaterial = underlyingPipelineMaterial; + } + + public String getObjectType() { + return objectType; + } + + public void setObjectType(String objectType) { + this.objectType = objectType; + } + + public String getColor() { + return color; + } + + public void setColor(String color) { + this.color = color; + } + + public String getImagePath() { + return imagePath; + } + + public void setImagePath(String imagePath) { + this.imagePath = imagePath; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java deleted file mode 100644 index 3f2fcdc..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java +++ /dev/null @@ -1,327 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 从平台下载的标识器本地库实体类 - */ -@Entity -public class MarkerLocalBean { - @Id(autoincrement = true) - private Long id;//本地库主键ID - - // 管线类型 - private String pipelineType; - // 管线直径 - private String pipelineDiameter; - // 管材 - private String pipelineMaterial; - // 埋设方式 - private String buryMethod; - // 埋深 - private String buryDepth; - // 所属区域 - private String area; - // 所属线路 - private String line; - // 所属道路 - private String road; - // 建设年代 - private String constructTime; - // 权属单位 - private String owner; - //标识对象ID,无实际用途 - @Deprecated - private String objectId; - // 标识器ID - private String markerId; - // 标识器类型 - private String markerType; - // 标识器埋深 - private String markerDepth; - // 安装部门 - private String installationDept; - // 经度 - private String lng; - // 纬度 - private String lat; - //最后修改时间,更新时间 - private String updateTime; - // 备注信息 - private String remark; - // 下层管线类型 - private String underlyingPipelineType; - // 下层埋深 - private String underlyingPipelineDepth; - // 下层管径 - private String underlyingPipelineDiameter; - // 下层管材 - private String underlyingPipelineMaterial; - //标识对象类型 - private String objectType; - // 颜色 - private String color; - // 图片路径 - private String imagePath; - - @Generated(hash = 1479045776) - public MarkerLocalBean(Long id, String pipelineType, String pipelineDiameter, - String pipelineMaterial, String buryMethod, String buryDepth, - String area, String line, String road, String constructTime, - String owner, String objectId, String markerId, String markerType, - String markerDepth, String installationDept, String lng, String lat, - String updateTime, String remark, String underlyingPipelineType, - String underlyingPipelineDepth, String underlyingPipelineDiameter, - String underlyingPipelineMaterial, String objectType, String color, - String imagePath) { - this.id = id; - this.pipelineType = pipelineType; - this.pipelineDiameter = pipelineDiameter; - this.pipelineMaterial = pipelineMaterial; - this.buryMethod = buryMethod; - this.buryDepth = buryDepth; - this.area = area; - this.line = line; - this.road = road; - this.constructTime = constructTime; - this.owner = owner; - this.objectId = objectId; - this.markerId = markerId; - this.markerType = markerType; - this.markerDepth = markerDepth; - this.installationDept = installationDept; - this.lng = lng; - this.lat = lat; - this.updateTime = updateTime; - this.remark = remark; - this.underlyingPipelineType = underlyingPipelineType; - this.underlyingPipelineDepth = underlyingPipelineDepth; - this.underlyingPipelineDiameter = underlyingPipelineDiameter; - this.underlyingPipelineMaterial = underlyingPipelineMaterial; - this.objectType = objectType; - this.color = color; - this.imagePath = imagePath; - } - - @Generated(hash = 1538606012) - public MarkerLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getPipelineType() { - return this.pipelineType; - } - - public void setPipelineType(String pipelineType) { - this.pipelineType = pipelineType; - } - - public String getPipelineDiameter() { - return this.pipelineDiameter; - } - - public void setPipelineDiameter(String pipelineDiameter) { - this.pipelineDiameter = pipelineDiameter; - } - - public String getPipelineMaterial() { - return this.pipelineMaterial; - } - - public void setPipelineMaterial(String pipelineMaterial) { - this.pipelineMaterial = pipelineMaterial; - } - - public String getBuryMethod() { - return this.buryMethod; - } - - public void setBuryMethod(String buryMethod) { - this.buryMethod = buryMethod; - } - - public String getBuryDepth() { - return this.buryDepth; - } - - public void setBuryDepth(String buryDepth) { - this.buryDepth = buryDepth; - } - - public String getArea() { - return this.area; - } - - public void setArea(String area) { - this.area = area; - } - - public String getLine() { - return this.line; - } - - public void setLine(String line) { - this.line = line; - } - - public String getRoad() { - return this.road; - } - - public void setRoad(String road) { - this.road = road; - } - - public String getConstructTime() { - return this.constructTime; - } - - public void setConstructTime(String constructTime) { - this.constructTime = constructTime; - } - - public String getOwner() { - return this.owner; - } - - public void setOwner(String owner) { - this.owner = owner; - } - - public String getObjectId() { - return this.objectId; - } - - public void setObjectId(String objectId) { - this.objectId = objectId; - } - - public String getMarkerId() { - return this.markerId; - } - - public void setMarkerId(String markerId) { - this.markerId = markerId; - } - - public String getMarkerType() { - return this.markerType; - } - - public void setMarkerType(String markerType) { - this.markerType = markerType; - } - - public String getMarkerDepth() { - return this.markerDepth; - } - - public void setMarkerDepth(String markerDepth) { - this.markerDepth = markerDepth; - } - - public String getInstallationDept() { - return this.installationDept; - } - - public void setInstallationDept(String installationDept) { - this.installationDept = installationDept; - } - - public String getLng() { - return this.lng; - } - - public void setLng(String lng) { - this.lng = lng; - } - - public String getLat() { - return this.lat; - } - - public void setLat(String lat) { - this.lat = lat; - } - - public String getUpdateTime() { - return this.updateTime; - } - - public void setUpdateTime(String updateTime) { - this.updateTime = updateTime; - } - - public String getRemark() { - return this.remark; - } - - public void setRemark(String remark) { - this.remark = remark; - } - - public String getUnderlyingPipelineType() { - return this.underlyingPipelineType; - } - - public void setUnderlyingPipelineType(String underlyingPipelineType) { - this.underlyingPipelineType = underlyingPipelineType; - } - - public String getUnderlyingPipelineDepth() { - return this.underlyingPipelineDepth; - } - - public void setUnderlyingPipelineDepth(String underlyingPipelineDepth) { - this.underlyingPipelineDepth = underlyingPipelineDepth; - } - - public String getUnderlyingPipelineDiameter() { - return this.underlyingPipelineDiameter; - } - - public void setUnderlyingPipelineDiameter(String underlyingPipelineDiameter) { - this.underlyingPipelineDiameter = underlyingPipelineDiameter; - } - - public String getUnderlyingPipelineMaterial() { - return this.underlyingPipelineMaterial; - } - - public void setUnderlyingPipelineMaterial(String underlyingPipelineMaterial) { - this.underlyingPipelineMaterial = underlyingPipelineMaterial; - } - - public String getObjectType() { - return this.objectType; - } - - public void setObjectType(String objectType) { - this.objectType = objectType; - } - - public String getColor() { - return this.color; - } - - public void setColor(String color) { - this.color = color; - } - - public String getImagePath() { - return this.imagePath; - } - - public void setImagePath(String imagePath) { - this.imagePath = imagePath; - } -} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java new file mode 100644 index 0000000..5c88fdf --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java @@ -0,0 +1,93 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 巡检任务本地库实体类,不包含任务里面需要巡检的标识器信息 + */ +@Entity(tableName = "task_detail") +public class TaskBean { + @PrimaryKey(autoGenerate = true) + private long id;//主键ID + private String taskCode; // 任务编号 + private String description; // 任务名称 + private String createTime; // 任务创建的时间 + private String status; // 任务状态 + private String createUserName; // 任务创建者名称 + private String startTime; // 任务被开始执行的时间 + private String endTime; // 任务执行结束的时间 + private String isFree; // 是否自由巡检。1-是,0-否 + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getTaskCode() { + return taskCode; + } + + public void setTaskCode(String taskCode) { + this.taskCode = taskCode; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getCreateUserName() { + return createUserName; + } + + public void setCreateUserName(String createUserName) { + this.createUserName = createUserName; + } + + public String getStartTime() { + return startTime; + } + + public void setStartTime(String startTime) { + this.startTime = startTime; + } + + public String getEndTime() { + return endTime; + } + + public void setEndTime(String endTime) { + this.endTime = endTime; + } + + public String getIsFree() { + return isFree; + } + + public void setIsFree(String isFree) { + this.isFree = isFree; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java deleted file mode 100644 index 91737b3..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java +++ /dev/null @@ -1,114 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 巡检任务本地库实体类,不包含任务里面需要巡检的标识器信息 - */ -@Entity -public class TaskLocalBean { - @Id - private Long id;//任务ID - - private String taskCode;//任务编号 - private String description;//任务名称 - private String createTime;//任务创建的时间 - private String status;//任务状态 - private String createUserName;//任务创建者名称 - private String startTime;//任务被开始执行的时间 - private String endTime;//任务执行结束的时间 - private String isFreeTask;//是否自由巡检。1-是,0-否 - - @Generated(hash = 1482022528) - public TaskLocalBean(Long id, String taskCode, String description, - String createTime, String status, String createUserName, - String startTime, String endTime, String isFreeTask) { - this.id = id; - this.taskCode = taskCode; - this.description = description; - this.createTime = createTime; - this.status = status; - this.createUserName = createUserName; - this.startTime = startTime; - this.endTime = endTime; - this.isFreeTask = isFreeTask; - } - - @Generated(hash = 949704588) - public TaskLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getTaskCode() { - return this.taskCode; - } - - public void setTaskCode(String taskCode) { - this.taskCode = taskCode; - } - - public String getDescription() { - return this.description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getCreateTime() { - return this.createTime; - } - - public void setCreateTime(String createTime) { - this.createTime = createTime; - } - - public String getStatus() { - return this.status; - } - - public void setStatus(String status) { - this.status = status; - } - - public String getCreateUserName() { - return this.createUserName; - } - - public void setCreateUserName(String createUserName) { - this.createUserName = createUserName; - } - - public String getStartTime() { - return this.startTime; - } - - public void setStartTime(String startTime) { - this.startTime = startTime; - } - - public String getEndTime() { - return this.endTime; - } - - public void setEndTime(String endTime) { - this.endTime = endTime; - } - - public String getIsFreeTask() { - return this.isFreeTask; - } - - public void setIsFreeTask(String isFreeTask) { - this.isFreeTask = isFreeTask; - } -} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerBean.java new file mode 100644 index 0000000..c563a60 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerBean.java @@ -0,0 +1,110 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 巡检任务里面需要巡检的标识器信息本地库实体类 + */ +@Entity(tableName = "task_marker_info") +public class TaskMarkerBean { + //标识器后台库的主键ID,不是标识器实际ID + @PrimaryKey(autoGenerate = true) + private long id; + + /** + * 任务ID,通过此字段关联[TaskBean.id] + */ + private String taskId; + + /** + * 任务Code,通过此字段关联[TaskBean.taskCode] + *

+ *

+ * 双重验证,防止出现同时刻重复的情况 + */ + private String taskCode; + + /** + * 对应后台字段[TaskModel.MessageModel.TaskDetailInfosModel.markerIdReal],也就是探测仪扫描出来的ID + */ + private String markerId; + + private Double lng; + private Double lat; + + /** + * 是否已被探测到 + * 1-是,0-否 + */ + private String isDetected; + + /** + * 被探测到的时间,对应后台字段[TaskModel.MessageModel.TaskDetailInfosModel.finishTime] + */ + private String detectedTime; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getTaskId() { + return taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getTaskCode() { + return taskCode; + } + + public void setTaskCode(String taskCode) { + this.taskCode = taskCode; + } + + public String getMarkerId() { + return markerId; + } + + public void setMarkerId(String markerId) { + this.markerId = markerId; + } + + public Double getLng() { + return lng; + } + + public void setLng(Double lng) { + this.lng = lng; + } + + public Double getLat() { + return lat; + } + + public void setLat(Double lat) { + this.lat = lat; + } + + public String getIsDetected() { + return isDetected; + } + + public void setIsDetected(String isDetected) { + this.isDetected = isDetected; + } + + public String getDetectedTime() { + return detectedTime; + } + + public void setDetectedTime(String detectedTime) { + this.detectedTime = detectedTime; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerLocalBean.java deleted file mode 100644 index de9f459..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerLocalBean.java +++ /dev/null @@ -1,128 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import com.casic.common.detector.gd.model.TaskModel; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 巡检任务里面需要巡检的标识器信息本地库实体类 - */ -@Entity -public class TaskMarkerLocalBean { - @Id - private Long id;//标识器后台库的主键ID,不是标识器实际ID - - /** - * 任务ID,通过此字段关联{@link TaskLocalBean#id} - */ - private String taskId; - - /** - * 任务Code,通过此字段关联{@link TaskLocalBean#taskCode} - *

- * 双重验证,防止出现同时刻重复的情况 - */ - private String taskCode; - - /** - * 对应后台字段{@link TaskModel.MessageModel.TaskDetailInfosModel#markerIdReal},也就是探测仪扫描出来的ID - */ - private String markerId; - - private double lng; - private double lat; - - /** - * 是否已被探测到 - * 1-是,0-否 - */ - private String isDetected; - - /** - * 被探测到的时间,对应后台字段{@link TaskModel.MessageModel.TaskDetailInfosModel#finishTime} - */ - private String detectedTime; - - @Generated(hash = 677328533) - public TaskMarkerLocalBean(Long id, String taskId, String taskCode, String markerId, - double lng, double lat, String isDetected, String detectedTime) { - this.id = id; - this.taskId = taskId; - this.taskCode = taskCode; - this.markerId = markerId; - this.lng = lng; - this.lat = lat; - this.isDetected = isDetected; - this.detectedTime = detectedTime; - } - - @Generated(hash = 1162404642) - public TaskMarkerLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getTaskId() { - return this.taskId; - } - - public void setTaskId(String taskId) { - this.taskId = taskId; - } - - public String getTaskCode() { - return this.taskCode; - } - - public void setTaskCode(String taskCode) { - this.taskCode = taskCode; - } - - public String getMarkerId() { - return this.markerId; - } - - public void setMarkerId(String markerId) { - this.markerId = markerId; - } - - public double getLng() { - return this.lng; - } - - public void setLng(double lng) { - this.lng = lng; - } - - public double getLat() { - return this.lat; - } - - public void setLat(double lat) { - this.lat = lat; - } - - public String getIsDetected() { - return this.isDetected; - } - - public void setIsDetected(String isDetected) { - this.isDetected = isDetected; - } - - public String getDetectedTime() { - return this.detectedTime; - } - - public void setDetectedTime(String detectedTime) { - this.detectedTime = detectedTime; - } -} diff --git a/app/src/main/java/com/casic/common/detector/gd/dao/MarkerBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/dao/MarkerBeanDao.java new file mode 100644 index 0000000..2beb7ed --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/dao/MarkerBeanDao.java @@ -0,0 +1,29 @@ +package com.casic.common.detector.gd.dao; + +import androidx.room.Dao; +import androidx.room.Insert; +import androidx.room.Query; +import androidx.room.RawQuery; +import androidx.sqlite.db.SupportSQLiteQuery; + +import com.casic.common.detector.gd.bean.MarkerBean; + +import java.util.List; + +@Dao +public interface MarkerBeanDao { + @Query("DELETE FROM marker_detail") + void deleteAll(); + + @Insert + void insert(MarkerBean marker); + + @Query("SELECT * FROM marker_detail") + List loadAll(); + + @Query("SELECT * FROM marker_detail WHERE markerId = :markerId") + List queryMarkerById(String markerId); + + @RawQuery + List loadMarkersByCondition(SupportSQLiteQuery query); +} diff --git a/app/src/main/java/com/casic/common/detector/gd/dao/TaskBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/dao/TaskBeanDao.java new file mode 100644 index 0000000..9c70ac2 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/dao/TaskBeanDao.java @@ -0,0 +1,120 @@ +package com.casic.common.detector.gd.dao; + +import androidx.room.Dao; +import androidx.room.Insert; +import androidx.room.Query; +import androidx.room.Transaction; + +import com.casic.common.detector.gd.bean.TaskBean; +import com.casic.common.detector.gd.bean.TaskMarkerBean; +import com.casic.common.detector.gd.model.TaskDetailLocalModel; +import com.casic.common.detector.gd.model.TaskModel; +import com.casic.common.detector.gd.utils.LocaleConstant; +import com.pengxh.kt.lite.utils.SaveKeyValues; + +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Locale; + +@Dao +public interface TaskBeanDao { + @Query("SELECT COUNT(*) FROM task_detail WHERE id = :taskId") + int isTaskExist(long taskId); + + @Insert + void insert(TaskBean task); + + default void saveTask(Long taskId, String taskName) { + if (isTaskExist(taskId) == 0) { + TaskBean task = new TaskBean(); + task.setId(taskId); + task.setTaskCode(new SimpleDateFormat("yyyyMMddHHmmss", Locale.CHINA).format(new Date())); + task.setDescription(taskName); + String time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA).format(new Date()); + task.setCreateTime(time); + task.setStatus("0"); + String userName = (String) SaveKeyValues.INSTANCE.getValue(LocaleConstant.USER_NAME, ""); + task.setCreateUserName(userName); + task.setStartTime(time); + task.setEndTime(""); + task.setIsFree("1"); + insert(task); + } + } + + default void saveTask(TaskModel.MessageModel model) { + TaskBean task = new TaskBean(); + task.setId(model.getId()); + task.setTaskCode(model.getTaskCode()); + task.setDescription(model.getDescription()); + task.setCreateTime(model.getDeployDate()); + task.setStatus(model.getStatus()); + task.setCreateUserName(model.getCreatorName()); + task.setStartTime(model.getBeginDate()); + task.setEndTime(model.getEndDate()); + task.setIsFree("0"); + if (isTaskExist(task.getId()) == 0) { + insert(task); + } + } + + @Query("SELECT * FROM task_detail") + List loadAll(); + + @Transaction + default ArrayList loadLocalTask(TaskMarkerBeanDao taskMarkerBeanDao) { + ArrayList result = new ArrayList<>(); + List tasks = loadAll(); + for (TaskBean it : tasks) { + TaskDetailLocalModel model = new TaskDetailLocalModel(); + model.setTaskId(String.valueOf(it.getId())); + model.setTaskCode(it.getTaskCode()); + model.setDescription(it.getDescription()); + model.setCreateTime(it.getCreateTime()); + model.setStatus(it.getStatus()); + model.setCreateUserName(it.getCreateUserName()); + model.setIsFreeTask(it.getIsFree()); + ArrayList results = new ArrayList<>(); + if ("0".equals(it.getIsFree())) { + // 非自由巡检才有Marker + List markers = taskMarkerBeanDao.getMarkersByIdAndCode(String.valueOf(it.getId()), it.getTaskCode()); + for (TaskMarkerBean marker : markers) { + TaskDetailLocalModel.TaskMarkerLocalModel localModel = new TaskDetailLocalModel.TaskMarkerLocalModel(); + localModel.setMarkerId(marker.getMarkerId()); + localModel.setLng(marker.getLng()); + localModel.setLat(marker.getLat()); + localModel.setIsDetected(marker.getIsDetected()); + localModel.setDetectedTime(marker.getDetectedTime()); + + results.add(localModel); + } + } + model.setMarkerModels(results); + result.add(model); + } + return result; + } + + @Query("DELETE FROM task_detail WHERE id = :taskId AND taskCode = :taskCode") + void deleteTaskById(long taskId, String taskCode); + + @Transaction + default void deleteLocalTaskById(long taskId, String taskCode, TaskMarkerBeanDao taskMarkerBeanDao) { + TaskBean task = loadAll().stream() + .filter(it -> it.getId() == taskId && taskCode.equals(it.getTaskCode())) + .findFirst() + .orElse(null); + if (task == null) return; + deleteTaskById(taskId, taskCode); + + // 删除此任务关联的Marker。非自由巡检才有Marker + if ("0".equals(task.getIsFree())) { + List markers = taskMarkerBeanDao.getMarkersByIdAndCode(String.valueOf(task.getId()), task.getTaskCode()); + for (TaskMarkerBean marker : markers) { + taskMarkerBeanDao.delete(marker); + } + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/dao/TaskMarkerBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/dao/TaskMarkerBeanDao.java new file mode 100644 index 0000000..cc2156a --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/dao/TaskMarkerBeanDao.java @@ -0,0 +1,52 @@ +package com.casic.common.detector.gd.dao; + +import androidx.room.Dao; +import androidx.room.Delete; +import androidx.room.Insert; +import androidx.room.Query; +import androidx.room.Update; + +import com.casic.common.detector.gd.bean.TaskMarkerBean; +import com.casic.common.detector.gd.model.TaskModel; + +import java.util.List; + +@Dao +public interface TaskMarkerBeanDao { + + @Insert + void insert(TaskMarkerBean marker); + + @Query("SELECT COUNT(*) FROM task_marker_info WHERE id = :markerId") + int isMarkerExist(String markerId); + + default void saveTaskMarker(long taskId, String taskCode, TaskModel.MessageModel.TaskDetailInfosModel marker) { + if (isMarkerExist(marker.getMarkerId()) == 0) { + TaskMarkerBean bean = new TaskMarkerBean(); + bean.setId(marker.getId()); + bean.setTaskId(String.valueOf(taskId)); + bean.setTaskCode(taskCode); + bean.setMarkerId(marker.getMarkerIdReal()); + bean.setLng(marker.getLongitude()); + bean.setLat(marker.getLatitude()); + bean.setIsDetected("0"); + bean.setDetectedTime(""); + insert(bean); + } + } + + @Query("SELECT * FROM task_marker_info WHERE taskId = :taskId AND taskCode = :taskCode AND markerId = :markerId AND isDetected = :state") + TaskMarkerBean queryTaskMarkerById(String taskId, String taskCode, String markerId, String state); + + @Update + void updateLocalTaskMarkerState(TaskMarkerBean marker); + + @Query("SELECT * FROM task_marker_info WHERE isDetected = :state") + List queryMarkerByState(String state); + + @Query("SELECT * FROM task_marker_info WHERE taskId = :taskId AND taskCode = :taskCode") + List getMarkersByIdAndCode(String taskId, String taskCode); + + @Delete + void delete(TaskMarkerBean marker); +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/extensions/Long.kt b/app/src/main/java/com/casic/common/detector/gd/extensions/Long.kt deleted file mode 100644 index 6713d8d..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/extensions/Long.kt +++ /dev/null @@ -1,10 +0,0 @@ -package com.casic.common.detector.gd.extensions - -import java.text.SimpleDateFormat -import java.util.Date -import java.util.Locale - -fun Long.createTaskCode(): String { - val dateFormat = SimpleDateFormat("yyyyMMddHHmmss", Locale.CHINA) - return dateFormat.format(Date(this)) -} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoMaster.java b/app/src/main/java/com/casic/common/detector/gd/greendao/DaoMaster.java deleted file mode 100644 index 6ab94b3..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoMaster.java +++ /dev/null @@ -1,102 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import android.content.Context; -import android.database.sqlite.SQLiteDatabase; -import android.database.sqlite.SQLiteDatabase.CursorFactory; -import android.util.Log; - -import org.greenrobot.greendao.AbstractDaoMaster; -import org.greenrobot.greendao.database.StandardDatabase; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.database.DatabaseOpenHelper; -import org.greenrobot.greendao.identityscope.IdentityScopeType; - - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** - * Master of DAO (schema version 1): knows all DAOs. - */ -public class DaoMaster extends AbstractDaoMaster { - public static final int SCHEMA_VERSION = 1; - - /** Creates underlying database table using DAOs. */ - public static void createAllTables(Database db, boolean ifNotExists) { - MarkerLocalBeanDao.createTable(db, ifNotExists); - TaskLocalBeanDao.createTable(db, ifNotExists); - TaskMarkerLocalBeanDao.createTable(db, ifNotExists); - } - - /** Drops underlying database table using DAOs. */ - public static void dropAllTables(Database db, boolean ifExists) { - MarkerLocalBeanDao.dropTable(db, ifExists); - TaskLocalBeanDao.dropTable(db, ifExists); - TaskMarkerLocalBeanDao.dropTable(db, ifExists); - } - - /** - * WARNING: Drops all table on Upgrade! Use only during development. - * Convenience method using a {@link DevOpenHelper}. - */ - public static DaoSession newDevSession(Context context, String name) { - Database db = new DevOpenHelper(context, name).getWritableDb(); - DaoMaster daoMaster = new DaoMaster(db); - return daoMaster.newSession(); - } - - public DaoMaster(SQLiteDatabase db) { - this(new StandardDatabase(db)); - } - - public DaoMaster(Database db) { - super(db, SCHEMA_VERSION); - registerDaoClass(MarkerLocalBeanDao.class); - registerDaoClass(TaskLocalBeanDao.class); - registerDaoClass(TaskMarkerLocalBeanDao.class); - } - - public DaoSession newSession() { - return new DaoSession(db, IdentityScopeType.Session, daoConfigMap); - } - - public DaoSession newSession(IdentityScopeType type) { - return new DaoSession(db, type, daoConfigMap); - } - - /** - * Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} - - */ - public static abstract class OpenHelper extends DatabaseOpenHelper { - public OpenHelper(Context context, String name) { - super(context, name, SCHEMA_VERSION); - } - - public OpenHelper(Context context, String name, CursorFactory factory) { - super(context, name, factory, SCHEMA_VERSION); - } - - @Override - public void onCreate(Database db) { - Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION); - createAllTables(db, false); - } - } - - /** WARNING: Drops all table on Upgrade! Use only during development. */ - public static class DevOpenHelper extends OpenHelper { - public DevOpenHelper(Context context, String name) { - super(context, name); - } - - public DevOpenHelper(Context context, String name, CursorFactory factory) { - super(context, name, factory); - } - - @Override - public void onUpgrade(Database db, int oldVersion, int newVersion) { - Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables"); - dropAllTables(db, true); - onCreate(db); - } - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoSession.java b/app/src/main/java/com/casic/common/detector/gd/greendao/DaoSession.java deleted file mode 100644 index c8b1a20..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoSession.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import java.util.Map; - -import org.greenrobot.greendao.AbstractDao; -import org.greenrobot.greendao.AbstractDaoSession; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.identityscope.IdentityScopeType; -import org.greenrobot.greendao.internal.DaoConfig; - -import com.casic.common.detector.gd.bean.MarkerLocalBean; -import com.casic.common.detector.gd.bean.TaskLocalBean; -import com.casic.common.detector.gd.bean.TaskMarkerLocalBean; - -import com.casic.common.detector.gd.greendao.MarkerLocalBeanDao; -import com.casic.common.detector.gd.greendao.TaskLocalBeanDao; -import com.casic.common.detector.gd.greendao.TaskMarkerLocalBeanDao; - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. - -/** - * {@inheritDoc} - * - * @see org.greenrobot.greendao.AbstractDaoSession - */ -public class DaoSession extends AbstractDaoSession { - - private final DaoConfig markerLocalBeanDaoConfig; - private final DaoConfig taskLocalBeanDaoConfig; - private final DaoConfig taskMarkerLocalBeanDaoConfig; - - private final MarkerLocalBeanDao markerLocalBeanDao; - private final TaskLocalBeanDao taskLocalBeanDao; - private final TaskMarkerLocalBeanDao taskMarkerLocalBeanDao; - - public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> - daoConfigMap) { - super(db); - - markerLocalBeanDaoConfig = daoConfigMap.get(MarkerLocalBeanDao.class).clone(); - markerLocalBeanDaoConfig.initIdentityScope(type); - - taskLocalBeanDaoConfig = daoConfigMap.get(TaskLocalBeanDao.class).clone(); - taskLocalBeanDaoConfig.initIdentityScope(type); - - taskMarkerLocalBeanDaoConfig = daoConfigMap.get(TaskMarkerLocalBeanDao.class).clone(); - taskMarkerLocalBeanDaoConfig.initIdentityScope(type); - - markerLocalBeanDao = new MarkerLocalBeanDao(markerLocalBeanDaoConfig, this); - taskLocalBeanDao = new TaskLocalBeanDao(taskLocalBeanDaoConfig, this); - taskMarkerLocalBeanDao = new TaskMarkerLocalBeanDao(taskMarkerLocalBeanDaoConfig, this); - - registerDao(MarkerLocalBean.class, markerLocalBeanDao); - registerDao(TaskLocalBean.class, taskLocalBeanDao); - registerDao(TaskMarkerLocalBean.class, taskMarkerLocalBeanDao); - } - - public void clear() { - markerLocalBeanDaoConfig.clearIdentityScope(); - taskLocalBeanDaoConfig.clearIdentityScope(); - taskMarkerLocalBeanDaoConfig.clearIdentityScope(); - } - - public MarkerLocalBeanDao getMarkerLocalBeanDao() { - return markerLocalBeanDao; - } - - public TaskLocalBeanDao getTaskLocalBeanDao() { - return taskLocalBeanDao; - } - - public TaskMarkerLocalBeanDao getTaskMarkerLocalBeanDao() { - return taskMarkerLocalBeanDao; - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/MarkerLocalBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/greendao/MarkerLocalBeanDao.java deleted file mode 100644 index 2f792c3..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/MarkerLocalBeanDao.java +++ /dev/null @@ -1,479 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import android.database.Cursor; -import android.database.sqlite.SQLiteStatement; - -import org.greenrobot.greendao.AbstractDao; -import org.greenrobot.greendao.Property; -import org.greenrobot.greendao.internal.DaoConfig; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.database.DatabaseStatement; - -import com.casic.common.detector.gd.bean.MarkerLocalBean; - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** - * DAO for table "MARKER_LOCAL_BEAN". -*/ -public class MarkerLocalBeanDao extends AbstractDao { - - public static final String TABLENAME = "MARKER_LOCAL_BEAN"; - - /** - * Properties of entity MarkerLocalBean.
- * Can be used for QueryBuilder and for referencing column names. - */ - public static class Properties { - public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property PipelineType = new Property(1, String.class, "pipelineType", false, "PIPELINE_TYPE"); - public final static Property PipelineDiameter = new Property(2, String.class, "pipelineDiameter", false, "PIPELINE_DIAMETER"); - public final static Property PipelineMaterial = new Property(3, String.class, "pipelineMaterial", false, "PIPELINE_MATERIAL"); - public final static Property BuryMethod = new Property(4, String.class, "buryMethod", false, "BURY_METHOD"); - public final static Property BuryDepth = new Property(5, String.class, "buryDepth", false, "BURY_DEPTH"); - public final static Property Area = new Property(6, String.class, "area", false, "AREA"); - public final static Property Line = new Property(7, String.class, "line", false, "LINE"); - public final static Property Road = new Property(8, String.class, "road", false, "ROAD"); - public final static Property ConstructTime = new Property(9, String.class, "constructTime", false, "CONSTRUCT_TIME"); - public final static Property Owner = new Property(10, String.class, "owner", false, "OWNER"); - public final static Property ObjectId = new Property(11, String.class, "objectId", false, "OBJECT_ID"); - public final static Property MarkerId = new Property(12, String.class, "markerId", false, "MARKER_ID"); - public final static Property MarkerType = new Property(13, String.class, "markerType", false, "MARKER_TYPE"); - public final static Property MarkerDepth = new Property(14, String.class, "markerDepth", false, "MARKER_DEPTH"); - public final static Property InstallationDept = new Property(15, String.class, "installationDept", false, "INSTALLATION_DEPT"); - public final static Property Lng = new Property(16, String.class, "lng", false, "LNG"); - public final static Property Lat = new Property(17, String.class, "lat", false, "LAT"); - public final static Property UpdateTime = new Property(18, String.class, "updateTime", false, "UPDATE_TIME"); - public final static Property Remark = new Property(19, String.class, "remark", false, "REMARK"); - public final static Property UnderlyingPipelineType = new Property(20, String.class, "underlyingPipelineType", false, "UNDERLYING_PIPELINE_TYPE"); - public final static Property UnderlyingPipelineDepth = new Property(21, String.class, "underlyingPipelineDepth", false, "UNDERLYING_PIPELINE_DEPTH"); - public final static Property UnderlyingPipelineDiameter = new Property(22, String.class, "underlyingPipelineDiameter", false, "UNDERLYING_PIPELINE_DIAMETER"); - public final static Property UnderlyingPipelineMaterial = new Property(23, String.class, "underlyingPipelineMaterial", false, "UNDERLYING_PIPELINE_MATERIAL"); - public final static Property ObjectType = new Property(24, String.class, "objectType", false, "OBJECT_TYPE"); - public final static Property Color = new Property(25, String.class, "color", false, "COLOR"); - public final static Property ImagePath = new Property(26, String.class, "imagePath", false, "IMAGE_PATH"); - } - - - public MarkerLocalBeanDao(DaoConfig config) { - super(config); - } - - public MarkerLocalBeanDao(DaoConfig config, DaoSession daoSession) { - super(config, daoSession); - } - - /** Creates the underlying database table. */ - public static void createTable(Database db, boolean ifNotExists) { - String constraint = ifNotExists? "IF NOT EXISTS ": ""; - db.execSQL("CREATE TABLE " + constraint + "\"MARKER_LOCAL_BEAN\" (" + // - "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id - "\"PIPELINE_TYPE\" TEXT," + // 1: pipelineType - "\"PIPELINE_DIAMETER\" TEXT," + // 2: pipelineDiameter - "\"PIPELINE_MATERIAL\" TEXT," + // 3: pipelineMaterial - "\"BURY_METHOD\" TEXT," + // 4: buryMethod - "\"BURY_DEPTH\" TEXT," + // 5: buryDepth - "\"AREA\" TEXT," + // 6: area - "\"LINE\" TEXT," + // 7: line - "\"ROAD\" TEXT," + // 8: road - "\"CONSTRUCT_TIME\" TEXT," + // 9: constructTime - "\"OWNER\" TEXT," + // 10: owner - "\"OBJECT_ID\" TEXT," + // 11: objectId - "\"MARKER_ID\" TEXT," + // 12: markerId - "\"MARKER_TYPE\" TEXT," + // 13: markerType - "\"MARKER_DEPTH\" TEXT," + // 14: markerDepth - "\"INSTALLATION_DEPT\" TEXT," + // 15: installationDept - "\"LNG\" TEXT," + // 16: lng - "\"LAT\" TEXT," + // 17: lat - "\"UPDATE_TIME\" TEXT," + // 18: updateTime - "\"REMARK\" TEXT," + // 19: remark - "\"UNDERLYING_PIPELINE_TYPE\" TEXT," + // 20: underlyingPipelineType - "\"UNDERLYING_PIPELINE_DEPTH\" TEXT," + // 21: underlyingPipelineDepth - "\"UNDERLYING_PIPELINE_DIAMETER\" TEXT," + // 22: underlyingPipelineDiameter - "\"UNDERLYING_PIPELINE_MATERIAL\" TEXT," + // 23: underlyingPipelineMaterial - "\"OBJECT_TYPE\" TEXT," + // 24: objectType - "\"COLOR\" TEXT," + // 25: color - "\"IMAGE_PATH\" TEXT);"); // 26: imagePath - } - - /** Drops the underlying database table. */ - public static void dropTable(Database db, boolean ifExists) { - String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"MARKER_LOCAL_BEAN\""; - db.execSQL(sql); - } - - @Override - protected final void bindValues(DatabaseStatement stmt, MarkerLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String pipelineType = entity.getPipelineType(); - if (pipelineType != null) { - stmt.bindString(2, pipelineType); - } - - String pipelineDiameter = entity.getPipelineDiameter(); - if (pipelineDiameter != null) { - stmt.bindString(3, pipelineDiameter); - } - - String pipelineMaterial = entity.getPipelineMaterial(); - if (pipelineMaterial != null) { - stmt.bindString(4, pipelineMaterial); - } - - String buryMethod = entity.getBuryMethod(); - if (buryMethod != null) { - stmt.bindString(5, buryMethod); - } - - String buryDepth = entity.getBuryDepth(); - if (buryDepth != null) { - stmt.bindString(6, buryDepth); - } - - String area = entity.getArea(); - if (area != null) { - stmt.bindString(7, area); - } - - String line = entity.getLine(); - if (line != null) { - stmt.bindString(8, line); - } - - String road = entity.getRoad(); - if (road != null) { - stmt.bindString(9, road); - } - - String constructTime = entity.getConstructTime(); - if (constructTime != null) { - stmt.bindString(10, constructTime); - } - - String owner = entity.getOwner(); - if (owner != null) { - stmt.bindString(11, owner); - } - - String objectId = entity.getObjectId(); - if (objectId != null) { - stmt.bindString(12, objectId); - } - - String markerId = entity.getMarkerId(); - if (markerId != null) { - stmt.bindString(13, markerId); - } - - String markerType = entity.getMarkerType(); - if (markerType != null) { - stmt.bindString(14, markerType); - } - - String markerDepth = entity.getMarkerDepth(); - if (markerDepth != null) { - stmt.bindString(15, markerDepth); - } - - String installationDept = entity.getInstallationDept(); - if (installationDept != null) { - stmt.bindString(16, installationDept); - } - - String lng = entity.getLng(); - if (lng != null) { - stmt.bindString(17, lng); - } - - String lat = entity.getLat(); - if (lat != null) { - stmt.bindString(18, lat); - } - - String updateTime = entity.getUpdateTime(); - if (updateTime != null) { - stmt.bindString(19, updateTime); - } - - String remark = entity.getRemark(); - if (remark != null) { - stmt.bindString(20, remark); - } - - String underlyingPipelineType = entity.getUnderlyingPipelineType(); - if (underlyingPipelineType != null) { - stmt.bindString(21, underlyingPipelineType); - } - - String underlyingPipelineDepth = entity.getUnderlyingPipelineDepth(); - if (underlyingPipelineDepth != null) { - stmt.bindString(22, underlyingPipelineDepth); - } - - String underlyingPipelineDiameter = entity.getUnderlyingPipelineDiameter(); - if (underlyingPipelineDiameter != null) { - stmt.bindString(23, underlyingPipelineDiameter); - } - - String underlyingPipelineMaterial = entity.getUnderlyingPipelineMaterial(); - if (underlyingPipelineMaterial != null) { - stmt.bindString(24, underlyingPipelineMaterial); - } - - String objectType = entity.getObjectType(); - if (objectType != null) { - stmt.bindString(25, objectType); - } - - String color = entity.getColor(); - if (color != null) { - stmt.bindString(26, color); - } - - String imagePath = entity.getImagePath(); - if (imagePath != null) { - stmt.bindString(27, imagePath); - } - } - - @Override - protected final void bindValues(SQLiteStatement stmt, MarkerLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String pipelineType = entity.getPipelineType(); - if (pipelineType != null) { - stmt.bindString(2, pipelineType); - } - - String pipelineDiameter = entity.getPipelineDiameter(); - if (pipelineDiameter != null) { - stmt.bindString(3, pipelineDiameter); - } - - String pipelineMaterial = entity.getPipelineMaterial(); - if (pipelineMaterial != null) { - stmt.bindString(4, pipelineMaterial); - } - - String buryMethod = entity.getBuryMethod(); - if (buryMethod != null) { - stmt.bindString(5, buryMethod); - } - - String buryDepth = entity.getBuryDepth(); - if (buryDepth != null) { - stmt.bindString(6, buryDepth); - } - - String area = entity.getArea(); - if (area != null) { - stmt.bindString(7, area); - } - - String line = entity.getLine(); - if (line != null) { - stmt.bindString(8, line); - } - - String road = entity.getRoad(); - if (road != null) { - stmt.bindString(9, road); - } - - String constructTime = entity.getConstructTime(); - if (constructTime != null) { - stmt.bindString(10, constructTime); - } - - String owner = entity.getOwner(); - if (owner != null) { - stmt.bindString(11, owner); - } - - String objectId = entity.getObjectId(); - if (objectId != null) { - stmt.bindString(12, objectId); - } - - String markerId = entity.getMarkerId(); - if (markerId != null) { - stmt.bindString(13, markerId); - } - - String markerType = entity.getMarkerType(); - if (markerType != null) { - stmt.bindString(14, markerType); - } - - String markerDepth = entity.getMarkerDepth(); - if (markerDepth != null) { - stmt.bindString(15, markerDepth); - } - - String installationDept = entity.getInstallationDept(); - if (installationDept != null) { - stmt.bindString(16, installationDept); - } - - String lng = entity.getLng(); - if (lng != null) { - stmt.bindString(17, lng); - } - - String lat = entity.getLat(); - if (lat != null) { - stmt.bindString(18, lat); - } - - String updateTime = entity.getUpdateTime(); - if (updateTime != null) { - stmt.bindString(19, updateTime); - } - - String remark = entity.getRemark(); - if (remark != null) { - stmt.bindString(20, remark); - } - - String underlyingPipelineType = entity.getUnderlyingPipelineType(); - if (underlyingPipelineType != null) { - stmt.bindString(21, underlyingPipelineType); - } - - String underlyingPipelineDepth = entity.getUnderlyingPipelineDepth(); - if (underlyingPipelineDepth != null) { - stmt.bindString(22, underlyingPipelineDepth); - } - - String underlyingPipelineDiameter = entity.getUnderlyingPipelineDiameter(); - if (underlyingPipelineDiameter != null) { - stmt.bindString(23, underlyingPipelineDiameter); - } - - String underlyingPipelineMaterial = entity.getUnderlyingPipelineMaterial(); - if (underlyingPipelineMaterial != null) { - stmt.bindString(24, underlyingPipelineMaterial); - } - - String objectType = entity.getObjectType(); - if (objectType != null) { - stmt.bindString(25, objectType); - } - - String color = entity.getColor(); - if (color != null) { - stmt.bindString(26, color); - } - - String imagePath = entity.getImagePath(); - if (imagePath != null) { - stmt.bindString(27, imagePath); - } - } - - @Override - public Long readKey(Cursor cursor, int offset) { - return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); - } - - @Override - public MarkerLocalBean readEntity(Cursor cursor, int offset) { - MarkerLocalBean entity = new MarkerLocalBean( // - cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // pipelineType - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // pipelineDiameter - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // pipelineMaterial - cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // buryMethod - cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // buryDepth - cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // area - cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // line - cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // road - cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // constructTime - cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10), // owner - cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11), // objectId - cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12), // markerId - cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13), // markerType - cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14), // markerDepth - cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15), // installationDept - cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16), // lng - cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17), // lat - cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18), // updateTime - cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19), // remark - cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20), // underlyingPipelineType - cursor.isNull(offset + 21) ? null : cursor.getString(offset + 21), // underlyingPipelineDepth - cursor.isNull(offset + 22) ? null : cursor.getString(offset + 22), // underlyingPipelineDiameter - cursor.isNull(offset + 23) ? null : cursor.getString(offset + 23), // underlyingPipelineMaterial - cursor.isNull(offset + 24) ? null : cursor.getString(offset + 24), // objectType - cursor.isNull(offset + 25) ? null : cursor.getString(offset + 25), // color - cursor.isNull(offset + 26) ? null : cursor.getString(offset + 26) // imagePath - ); - return entity; - } - - @Override - public void readEntity(Cursor cursor, MarkerLocalBean entity, int offset) { - entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setPipelineType(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); - entity.setPipelineDiameter(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); - entity.setPipelineMaterial(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); - entity.setBuryMethod(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); - entity.setBuryDepth(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); - entity.setArea(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); - entity.setLine(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); - entity.setRoad(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); - entity.setConstructTime(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9)); - entity.setOwner(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); - entity.setObjectId(cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11)); - entity.setMarkerId(cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12)); - entity.setMarkerType(cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13)); - entity.setMarkerDepth(cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14)); - entity.setInstallationDept(cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15)); - entity.setLng(cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16)); - entity.setLat(cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17)); - entity.setUpdateTime(cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18)); - entity.setRemark(cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19)); - entity.setUnderlyingPipelineType(cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20)); - entity.setUnderlyingPipelineDepth(cursor.isNull(offset + 21) ? null : cursor.getString(offset + 21)); - entity.setUnderlyingPipelineDiameter(cursor.isNull(offset + 22) ? null : cursor.getString(offset + 22)); - entity.setUnderlyingPipelineMaterial(cursor.isNull(offset + 23) ? null : cursor.getString(offset + 23)); - entity.setObjectType(cursor.isNull(offset + 24) ? null : cursor.getString(offset + 24)); - entity.setColor(cursor.isNull(offset + 25) ? null : cursor.getString(offset + 25)); - entity.setImagePath(cursor.isNull(offset + 26) ? null : cursor.getString(offset + 26)); - } - - @Override - protected final Long updateKeyAfterInsert(MarkerLocalBean entity, long rowId) { - entity.setId(rowId); - return rowId; - } - - @Override - public Long getKey(MarkerLocalBean entity) { - if(entity != null) { - return entity.getId(); - } else { - return null; - } - } - - @Override - public boolean hasKey(MarkerLocalBean entity) { - return entity.getId() != null; - } - - @Override - protected final boolean isEntityUpdateable() { - return true; - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/TaskLocalBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/greendao/TaskLocalBeanDao.java deleted file mode 100644 index fb88157..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/TaskLocalBeanDao.java +++ /dev/null @@ -1,227 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import android.database.Cursor; -import android.database.sqlite.SQLiteStatement; - -import org.greenrobot.greendao.AbstractDao; -import org.greenrobot.greendao.Property; -import org.greenrobot.greendao.internal.DaoConfig; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.database.DatabaseStatement; - -import com.casic.common.detector.gd.bean.TaskLocalBean; - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** - * DAO for table "TASK_LOCAL_BEAN". -*/ -public class TaskLocalBeanDao extends AbstractDao { - - public static final String TABLENAME = "TASK_LOCAL_BEAN"; - - /** - * Properties of entity TaskLocalBean.
- * Can be used for QueryBuilder and for referencing column names. - */ - public static class Properties { - public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property TaskCode = new Property(1, String.class, "taskCode", false, "TASK_CODE"); - public final static Property Description = new Property(2, String.class, "description", false, "DESCRIPTION"); - public final static Property CreateTime = new Property(3, String.class, "createTime", false, "CREATE_TIME"); - public final static Property Status = new Property(4, String.class, "status", false, "STATUS"); - public final static Property CreateUserName = new Property(5, String.class, "createUserName", false, "CREATE_USER_NAME"); - public final static Property StartTime = new Property(6, String.class, "startTime", false, "START_TIME"); - public final static Property EndTime = new Property(7, String.class, "endTime", false, "END_TIME"); - public final static Property IsFreeTask = new Property(8, String.class, "isFreeTask", false, "IS_FREE_TASK"); - } - - - public TaskLocalBeanDao(DaoConfig config) { - super(config); - } - - public TaskLocalBeanDao(DaoConfig config, DaoSession daoSession) { - super(config, daoSession); - } - - /** Creates the underlying database table. */ - public static void createTable(Database db, boolean ifNotExists) { - String constraint = ifNotExists? "IF NOT EXISTS ": ""; - db.execSQL("CREATE TABLE " + constraint + "\"TASK_LOCAL_BEAN\" (" + // - "\"_id\" INTEGER PRIMARY KEY ," + // 0: id - "\"TASK_CODE\" TEXT," + // 1: taskCode - "\"DESCRIPTION\" TEXT," + // 2: description - "\"CREATE_TIME\" TEXT," + // 3: createTime - "\"STATUS\" TEXT," + // 4: status - "\"CREATE_USER_NAME\" TEXT," + // 5: createUserName - "\"START_TIME\" TEXT," + // 6: startTime - "\"END_TIME\" TEXT," + // 7: endTime - "\"IS_FREE_TASK\" TEXT);"); // 8: isFreeTask - } - - /** Drops the underlying database table. */ - public static void dropTable(Database db, boolean ifExists) { - String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"TASK_LOCAL_BEAN\""; - db.execSQL(sql); - } - - @Override - protected final void bindValues(DatabaseStatement stmt, TaskLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String taskCode = entity.getTaskCode(); - if (taskCode != null) { - stmt.bindString(2, taskCode); - } - - String description = entity.getDescription(); - if (description != null) { - stmt.bindString(3, description); - } - - String createTime = entity.getCreateTime(); - if (createTime != null) { - stmt.bindString(4, createTime); - } - - String status = entity.getStatus(); - if (status != null) { - stmt.bindString(5, status); - } - - String createUserName = entity.getCreateUserName(); - if (createUserName != null) { - stmt.bindString(6, createUserName); - } - - String startTime = entity.getStartTime(); - if (startTime != null) { - stmt.bindString(7, startTime); - } - - String endTime = entity.getEndTime(); - if (endTime != null) { - stmt.bindString(8, endTime); - } - - String isFreeTask = entity.getIsFreeTask(); - if (isFreeTask != null) { - stmt.bindString(9, isFreeTask); - } - } - - @Override - protected final void bindValues(SQLiteStatement stmt, TaskLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String taskCode = entity.getTaskCode(); - if (taskCode != null) { - stmt.bindString(2, taskCode); - } - - String description = entity.getDescription(); - if (description != null) { - stmt.bindString(3, description); - } - - String createTime = entity.getCreateTime(); - if (createTime != null) { - stmt.bindString(4, createTime); - } - - String status = entity.getStatus(); - if (status != null) { - stmt.bindString(5, status); - } - - String createUserName = entity.getCreateUserName(); - if (createUserName != null) { - stmt.bindString(6, createUserName); - } - - String startTime = entity.getStartTime(); - if (startTime != null) { - stmt.bindString(7, startTime); - } - - String endTime = entity.getEndTime(); - if (endTime != null) { - stmt.bindString(8, endTime); - } - - String isFreeTask = entity.getIsFreeTask(); - if (isFreeTask != null) { - stmt.bindString(9, isFreeTask); - } - } - - @Override - public Long readKey(Cursor cursor, int offset) { - return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); - } - - @Override - public TaskLocalBean readEntity(Cursor cursor, int offset) { - TaskLocalBean entity = new TaskLocalBean( // - cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // taskCode - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // description - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // createTime - cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // status - cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // createUserName - cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // startTime - cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // endTime - cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8) // isFreeTask - ); - return entity; - } - - @Override - public void readEntity(Cursor cursor, TaskLocalBean entity, int offset) { - entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setTaskCode(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); - entity.setDescription(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); - entity.setCreateTime(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); - entity.setStatus(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); - entity.setCreateUserName(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); - entity.setStartTime(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); - entity.setEndTime(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); - entity.setIsFreeTask(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); - } - - @Override - protected final Long updateKeyAfterInsert(TaskLocalBean entity, long rowId) { - entity.setId(rowId); - return rowId; - } - - @Override - public Long getKey(TaskLocalBean entity) { - if(entity != null) { - return entity.getId(); - } else { - return null; - } - } - - @Override - public boolean hasKey(TaskLocalBean entity) { - return entity.getId() != null; - } - - @Override - protected final boolean isEntityUpdateable() { - return true; - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/TaskMarkerLocalBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/greendao/TaskMarkerLocalBeanDao.java deleted file mode 100644 index e96c735..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/TaskMarkerLocalBeanDao.java +++ /dev/null @@ -1,197 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import android.database.Cursor; -import android.database.sqlite.SQLiteStatement; - -import org.greenrobot.greendao.AbstractDao; -import org.greenrobot.greendao.Property; -import org.greenrobot.greendao.internal.DaoConfig; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.database.DatabaseStatement; - -import com.casic.common.detector.gd.bean.TaskMarkerLocalBean; - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** - * DAO for table "TASK_MARKER_LOCAL_BEAN". -*/ -public class TaskMarkerLocalBeanDao extends AbstractDao { - - public static final String TABLENAME = "TASK_MARKER_LOCAL_BEAN"; - - /** - * Properties of entity TaskMarkerLocalBean.
- * Can be used for QueryBuilder and for referencing column names. - */ - public static class Properties { - public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property TaskId = new Property(1, String.class, "taskId", false, "TASK_ID"); - public final static Property TaskCode = new Property(2, String.class, "taskCode", false, "TASK_CODE"); - public final static Property MarkerId = new Property(3, String.class, "markerId", false, "MARKER_ID"); - public final static Property Lng = new Property(4, double.class, "lng", false, "LNG"); - public final static Property Lat = new Property(5, double.class, "lat", false, "LAT"); - public final static Property IsDetected = new Property(6, String.class, "isDetected", false, "IS_DETECTED"); - public final static Property DetectedTime = new Property(7, String.class, "detectedTime", false, "DETECTED_TIME"); - } - - - public TaskMarkerLocalBeanDao(DaoConfig config) { - super(config); - } - - public TaskMarkerLocalBeanDao(DaoConfig config, DaoSession daoSession) { - super(config, daoSession); - } - - /** Creates the underlying database table. */ - public static void createTable(Database db, boolean ifNotExists) { - String constraint = ifNotExists? "IF NOT EXISTS ": ""; - db.execSQL("CREATE TABLE " + constraint + "\"TASK_MARKER_LOCAL_BEAN\" (" + // - "\"_id\" INTEGER PRIMARY KEY ," + // 0: id - "\"TASK_ID\" TEXT," + // 1: taskId - "\"TASK_CODE\" TEXT," + // 2: taskCode - "\"MARKER_ID\" TEXT," + // 3: markerId - "\"LNG\" REAL NOT NULL ," + // 4: lng - "\"LAT\" REAL NOT NULL ," + // 5: lat - "\"IS_DETECTED\" TEXT," + // 6: isDetected - "\"DETECTED_TIME\" TEXT);"); // 7: detectedTime - } - - /** Drops the underlying database table. */ - public static void dropTable(Database db, boolean ifExists) { - String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"TASK_MARKER_LOCAL_BEAN\""; - db.execSQL(sql); - } - - @Override - protected final void bindValues(DatabaseStatement stmt, TaskMarkerLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String taskId = entity.getTaskId(); - if (taskId != null) { - stmt.bindString(2, taskId); - } - - String taskCode = entity.getTaskCode(); - if (taskCode != null) { - stmt.bindString(3, taskCode); - } - - String markerId = entity.getMarkerId(); - if (markerId != null) { - stmt.bindString(4, markerId); - } - stmt.bindDouble(5, entity.getLng()); - stmt.bindDouble(6, entity.getLat()); - - String isDetected = entity.getIsDetected(); - if (isDetected != null) { - stmt.bindString(7, isDetected); - } - - String detectedTime = entity.getDetectedTime(); - if (detectedTime != null) { - stmt.bindString(8, detectedTime); - } - } - - @Override - protected final void bindValues(SQLiteStatement stmt, TaskMarkerLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String taskId = entity.getTaskId(); - if (taskId != null) { - stmt.bindString(2, taskId); - } - - String taskCode = entity.getTaskCode(); - if (taskCode != null) { - stmt.bindString(3, taskCode); - } - - String markerId = entity.getMarkerId(); - if (markerId != null) { - stmt.bindString(4, markerId); - } - stmt.bindDouble(5, entity.getLng()); - stmt.bindDouble(6, entity.getLat()); - - String isDetected = entity.getIsDetected(); - if (isDetected != null) { - stmt.bindString(7, isDetected); - } - - String detectedTime = entity.getDetectedTime(); - if (detectedTime != null) { - stmt.bindString(8, detectedTime); - } - } - - @Override - public Long readKey(Cursor cursor, int offset) { - return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); - } - - @Override - public TaskMarkerLocalBean readEntity(Cursor cursor, int offset) { - TaskMarkerLocalBean entity = new TaskMarkerLocalBean( // - cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // taskId - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // taskCode - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // markerId - cursor.getDouble(offset + 4), // lng - cursor.getDouble(offset + 5), // lat - cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // isDetected - cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7) // detectedTime - ); - return entity; - } - - @Override - public void readEntity(Cursor cursor, TaskMarkerLocalBean entity, int offset) { - entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setTaskId(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); - entity.setTaskCode(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); - entity.setMarkerId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); - entity.setLng(cursor.getDouble(offset + 4)); - entity.setLat(cursor.getDouble(offset + 5)); - entity.setIsDetected(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); - entity.setDetectedTime(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); - } - - @Override - protected final Long updateKeyAfterInsert(TaskMarkerLocalBean entity, long rowId) { - entity.setId(rowId); - return rowId; - } - - @Override - public Long getKey(TaskMarkerLocalBean entity) { - if(entity != null) { - return entity.getId(); - } else { - return null; - } - } - - @Override - public boolean hasKey(TaskMarkerLocalBean entity) { - return entity.getId() != null; - } - - @Override - protected final boolean isEntityUpdateable() { - return true; - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/model/TaskModel.java b/app/src/main/java/com/casic/common/detector/gd/model/TaskModel.java index 6e853ad..67ef5fb 100644 --- a/app/src/main/java/com/casic/common/detector/gd/model/TaskModel.java +++ b/app/src/main/java/com/casic/common/detector/gd/model/TaskModel.java @@ -24,7 +24,7 @@ } public static class MessageModel { - private int id; + private Long id; private String taskCode; private String description; private String deployDate; @@ -38,11 +38,11 @@ private int isValid; private List taskDetailInfos; - public int getId() { + public Long getId() { return id; } - public void setId(int id) { + public void setId(Long id) { this.id = id; } @@ -143,25 +143,25 @@ } public static class TaskDetailInfosModel { - private int id; + private long id; private String taskId; private String taskCode; private Object markerName; - private int markerId; + private String markerId; private String markerIdReal; private double longitude; private double latitude; private int isChecked; private int isNormal; - private Object imagePath; - private Object description; - private Object finishTime; + private String imagePath; + private String description; + private String finishTime; - public int getId() { + public long getId() { return id; } - public void setId(int id) { + public void setId(long id) { this.id = id; } @@ -189,11 +189,11 @@ this.markerName = markerName; } - public int getMarkerId() { + public String getMarkerId() { return markerId; } - public void setMarkerId(int markerId) { + public void setMarkerId(String markerId) { this.markerId = markerId; } @@ -237,27 +237,27 @@ this.isNormal = isNormal; } - public Object getImagePath() { + public String getImagePath() { return imagePath; } - public void setImagePath(Object imagePath) { + public void setImagePath(String imagePath) { this.imagePath = imagePath; } - public Object getDescription() { + public String getDescription() { return description; } - public void setDescription(Object description) { + public void setDescription(String description) { this.description = description; } - public Object getFinishTime() { + public String getFinishTime() { return finishTime; } - public void setFinishTime(Object finishTime) { + public void setFinishTime(String finishTime) { this.finishTime = finishTime; } } diff --git a/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitService.kt index 7522a87..0adad51 100644 --- a/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitService.kt @@ -50,7 +50,7 @@ */ @Multipart @POST("/ems/marker/save-marker-photo.do") - suspend fun installLabel( + suspend fun install( @PartMap jsonMarker: Map, @Part fileBuffer1: MultipartBody.Part?, @Part fileBuffer2: MultipartBody.Part?, diff --git a/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitServiceManager.kt index 5f6c701..ae2a0fa 100644 --- a/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitServiceManager.kt +++ b/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitServiceManager.kt @@ -37,22 +37,28 @@ /** * 获取标识器信息文件 */ - suspend fun getMarkerFile(userId: String, companyId: String): String { - return createApi().getMarkerFile(userId, companyId) + suspend fun getMarkerFile(): String { + val companyId = SaveKeyValues.getValue(LocaleConstant.USER_COMPANY_ID, "") as String + /** + * 后台设计如此,都传companyId + * */ + return createApi().getMarkerFile(companyId, companyId) } /** * 获取巡检工单 */ - suspend fun getTasksByUser(userName: String): String { + suspend fun getTasksByUser(): String { + val userName = SaveKeyValues.getValue(LocaleConstant.USER_NAME, "") as String return createApi().getTasksByUser(userName) } /** * 提交工单 */ - suspend fun uploadTask(userId: String, taskId: String?, state: String): String { + suspend fun uploadTask(taskId: String?, state: String): String { + val userId = SaveKeyValues.getValue(LocaleConstant.USER_ID, "") as String return createApi().uploadTask(userId, taskId.toString(), state) } @@ -60,8 +66,7 @@ * 安装新标识器 * Multipart上传图片,文件,带多参数上传 */ - suspend fun installLabel( - companyId: String, + suspend fun installMarker( recordType: String, markerObjectType: String, pipeMaterial: String, @@ -77,7 +82,6 @@ road: String, constructTime: String, ownerComp: String, - markerObjectId: String, markerId: String, markerType: String, markerDepth: String, @@ -89,6 +93,8 @@ memo: String, realPaths: ArrayList ): String { + val companyId = SaveKeyValues.getValue(LocaleConstant.USER_COMPANY_ID, "") as String + val objectId = SaveKeyValues.getValue(LocaleConstant.OBJECT_ID, "") as String val param = JsonObject() param.addProperty("companyId", companyId) param.addProperty("recordType", recordType) @@ -106,7 +112,7 @@ param.addProperty("road", road) param.addProperty("constructTime", constructTime) param.addProperty("ownerComp", ownerComp) - param.addProperty("markerObjectId", markerObjectId) + param.addProperty("markerObjectId", objectId) param.addProperty("markerId", markerId) param.addProperty("markerType", markerType) param.addProperty("markerDepth", markerDepth) @@ -133,19 +139,19 @@ return when (multiParts.size) { 3 -> { - createApi().installLabel(res, multiParts[0], multiParts[1], multiParts[2]) + createApi().install(res, multiParts[0], multiParts[1], multiParts[2]) } 2 -> { - createApi().installLabel(res, multiParts[0], multiParts[1], null) + createApi().install(res, multiParts[0], multiParts[1], null) } 1 -> { - createApi().installLabel(res, multiParts[0], null, null) + createApi().install(res, multiParts[0], null, null) } else -> { - createApi().installLabel(res, null, null, null) + createApi().install(res, null, null, null) } } } @@ -216,7 +222,7 @@ /** * 上传自由巡检过程中发现的标识器 */ - suspend fun uploadTaskMarker(taskId: String, ids: ArrayList): String { + suspend fun uploadTaskMarker(taskId: Long, ids: ArrayList): String { val param = JsonObject() param.addProperty("taskId", taskId) param.addProperty("ids", ids.joinToString(separator = ",")) diff --git a/app/src/main/java/com/casic/common/detector/gd/service/NtripConnectService.kt b/app/src/main/java/com/casic/common/detector/gd/service/NtripConnectService.kt index de9ac80..20e1a6a 100644 --- a/app/src/main/java/com/casic/common/detector/gd/service/NtripConnectService.kt +++ b/app/src/main/java/com/casic/common/detector/gd/service/NtripConnectService.kt @@ -9,10 +9,6 @@ import android.util.Log import android.view.Gravity import android.widget.Toast -import androidx.lifecycle.Lifecycle -import androidx.lifecycle.LifecycleOwner -import androidx.lifecycle.LifecycleRegistry -import androidx.lifecycle.lifecycleScope import com.casic.common.detector.gd.base.BaseApplication import com.casic.common.detector.gd.extensions.convertToGPGGA import com.casic.common.detector.gd.utils.LocaleConstant @@ -23,26 +19,24 @@ import com.pengxh.kt.lite.utils.WeakReferenceHandler import com.pengxh.kt.lite.utils.socket.tcp.OnTcpConnectStateListener import com.pengxh.kt.lite.utils.socket.tcp.TcpClient +import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.Job import kotlinx.coroutines.launch import java.io.OutputStream import java.nio.charset.StandardCharsets -class NtripConnectService : Service(), LifecycleOwner, OnTcpConnectStateListener, Handler.Callback { +class NtripConnectService : Service(), OnTcpConnectStateListener, Handler.Callback { companion object { var weakReferenceHandler: WeakReferenceHandler? = null } private val kTag = "NtripConnectService" - private val registry = LifecycleRegistry(this) private val socketClient by lazy { TcpClient(this) } private var outStream: OutputStream? = null - - override fun getLifecycle(): Lifecycle { - return registry - } + private val serviceScope = CoroutineScope(Dispatchers.Main + Job()) // 创建一个独立的CoroutineScope override fun onBind(intent: Intent?): IBinder? { return null @@ -117,7 +111,7 @@ * */ val result = String(this, StandardCharsets.UTF_8) if (result.contains("ICY 200 OK")) { - lifecycleScope.launch(Dispatchers.Main) { + serviceScope.launch { "高精度定位服务连接成功".show(this@NtripConnectService) } //连接服务即打开串口 @@ -135,12 +129,12 @@ * Content-Type: text/plain * Connection: clos * */ - lifecycleScope.launch(Dispatchers.Main) { + serviceScope.launch { "差分定位服务鉴权失败,无法解析位置".show(this@NtripConnectService) } } else { //居中显示 - lifecycleScope.launch(Dispatchers.Main) { + serviceScope.launch { val toast = Toast.makeText( this@NtripConnectService, "收到千寻数据,长度:${size}", Toast.LENGTH_SHORT ) @@ -167,7 +161,7 @@ return } - lifecycleScope.launch(Dispatchers.IO) { + serviceScope.launch(Dispatchers.IO) { socketClient.start(remoteHost, remotePort.toInt()) } } diff --git a/app/build.gradle b/app/build.gradle index d0cb423..921c8c8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,25 +1,20 @@ import java.text.SimpleDateFormat -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply plugin: 'org.greenrobot.greendao' +plugins { + id('com.android.application') + id('org.jetbrains.kotlin.android') +} android { - compileSdkVersion 33 + namespace 'com.casic.common.detector.gd' + compileSdk 35 defaultConfig { - applicationId "com.casic.common.detector.gd" - minSdkVersion 26 - targetSdkVersion 33 + applicationId 'com.casic.common.detector.gd' + minSdk 26 + targetSdk 35 versionCode 5092 - versionName "5.0.9.2" - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } + versionName '5.0.9.2' } signingConfigs { @@ -31,6 +26,14 @@ } } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + signingConfig signingConfigs.release + } + } + compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 @@ -47,27 +50,16 @@ } } - kotlin { - experimental { - coroutines 'enable' - } - } - buildFeatures { + buildConfig true viewBinding true } - applicationVariants.configureEach { variant -> - variant.outputs.configureEach { - outputFileName = "COM_TCY_" + getBuildDate() + "_" + defaultConfig.versionName + ".apk" + applicationVariants.configureEach { + outputs.configureEach { + outputFileName = 'COM_TCY_' + getBuildDate() + '_' + defaultConfig.versionName + '.apk' } } - - greendao { - schemaVersion 1//数据库版本号 - targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 - daoPackage "${defaultConfig.applicationId}.greendao"//设置DaoMaster、DaoSession、Dao包名 - } } static def getBuildDate() { @@ -76,27 +68,22 @@ } dependencies { - //基础依赖库 - implementation 'com.github.AndroidCoderPeng:Kotlin-lite-lib:1.1.4' - implementation 'androidx.core:core-ktx:1.9.0' - def base_version = "1.6.1" - implementation "androidx.appcompat:appcompat:${base_version}" - implementation "com.google.android.material:material:${base_version}" + implementation 'com.github.AndroidCoderPeng:Kotlin-lite-lib:1.1.5' + implementation 'androidx.core:core-ktx:1.13.1' + implementation 'androidx.appcompat:appcompat:1.7.0' + implementation 'com.google.android.material:material:1.12.0' //Google官方授权框架 implementation 'pub.devrel:easypermissions:3.0.0' - //沉浸式状态栏。基础依赖包,必须要依赖 - implementation 'com.gyf.immersionbar:immersionbar:3.0.0' - //fragment快速实现 - implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0' + //沉浸式状态栏 + implementation 'com.geyifeng.immersionbar:immersionbar:3.2.2' //官方Json解析库 implementation 'com.google.code.gson:gson:2.10.1' - def vm_version = '2.5.1' //Kotlin协程 - implementation "androidx.lifecycle:lifecycle-runtime-ktx:${vm_version}" + implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.2' //MVVM+LiveData - implementation "androidx.lifecycle:lifecycle-livedata-ktx:${vm_version}" - implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:${vm_version}" - implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.6.2' + implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2' + implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' //返回值转换器 implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' @@ -105,9 +92,10 @@ implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' //网络请求和接口封装 implementation 'com.squareup.retrofit2:retrofit:2.9.0' - implementation 'com.squareup.okhttp3:okhttp:4.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.12.0' //数据库框架 - implementation 'org.greenrobot:greendao:3.3.0' + implementation 'androidx.room:room-runtime:2.6.1' + annotationProcessor 'androidx.room:room-compiler:2.5.2' //高德导航、定位、地图三合一 implementation 'com.amap.api:navi-3dmap:latest.integration' //经纬度逆编码 @@ -115,7 +103,7 @@ //excel implementation 'net.sourceforge.jexcelapi:jxl:2.6.12' //图片加载框架 - implementation 'com.github.bumptech.glide:glide:4.9.0' + implementation 'com.github.bumptech.glide:glide:4.12.0' //图片选择框架 implementation 'io.github.lucksiege:pictureselector:v3.11.1' //大图 diff --git a/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt b/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt index 7b695ff..50ba734 100644 --- a/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt +++ b/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt @@ -4,9 +4,9 @@ import android.app.Application import android.os.Bundle import android.util.Log -import com.casic.common.detector.gd.greendao.DaoMaster -import com.casic.common.detector.gd.greendao.DaoSession +import androidx.room.Room.databaseBuilder import com.casic.common.detector.gd.uart.SerialPort +import com.casic.common.detector.gd.utils.DetectorDataBase import com.casic.common.detector.gd.utils.GpioManager import com.pengxh.kt.lite.extensions.show import com.pengxh.kt.lite.utils.SaveKeyValues @@ -43,44 +43,42 @@ private var application: BaseApplication by Delegates.notNull() fun get() = application - - private lateinit var daoSession: DaoSession } + lateinit var dataBase: DetectorDataBase + override fun onCreate() { super.onCreate() application = this SaveKeyValues.initSharedPreferences(this) CrashReport.initCrashReport(this, "01e80d3a74", true) - val devOpenHelper = DaoMaster.DevOpenHelper(this, "Detector.db", null) - val daoMaster = DaoMaster(devOpenHelper.writableDatabase) - daoSession = daoMaster.newSession() + dataBase = databaseBuilder(this, DetectorDataBase::class.java, "Detector.db") + .allowMainThreadQueries() + .build() /** * Open the serial port * */ try { serialPorts.apply { - add(SerialPort(File("/dev/ttysWK1"), 9600, 0)) - //千寻报文数据下发串口号 - add(SerialPort(File("/dev/ttyS1"), 9600, 0)) + add(SerialPort(File("/dev/ttysWK1"), 9600, 0)) //信号通讯串口 + add(SerialPort(File("/dev/ttyS1"), 9600, 0)) //千寻报文数据下发串口号 } Log.d(kTag, "onCreate: 已初始化 ${serialPorts.size} 个串口") } catch (e: SecurityException) { "您没有串口的读写权限!".show(this) + e.printStackTrace() } catch (e: IOException) { "因为不明原因,串口无法打开!".show(this) + e.printStackTrace() } catch (e: InvalidParameterException) { "请检查串口!".show(this) + e.printStackTrace() } registerActivityLifecycleCallbacks(this) } - fun getDaoSession(): DaoSession { - return daoSession - } - override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) { } diff --git a/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt b/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt index 053b9dd..1d0c9e3 100644 --- a/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt +++ b/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt @@ -14,12 +14,10 @@ import com.casic.common.detector.gd.utils.SerialPortCommand import com.pengxh.kt.lite.utils.WeakReferenceHandler import java.io.IOException -import java.util.Timer abstract class SerialPortBaseActivity : AppCompatActivity(), Handler.Callback { private val kTag = "SerialPortBaseActivity" - private val taskTimer by lazy { Timer() } private val weakReferenceHandler by lazy { WeakReferenceHandler(this) } private val serialPorts by lazy { BaseApplication.get().getSerialPorts() } protected lateinit var binding: VB @@ -30,7 +28,6 @@ setContentView(binding.root) setupTopBarLayout() initOnCreate(savedInstanceState) - observeRequestState() initEvent() if (serialPorts.isNotEmpty()) { @@ -71,11 +68,6 @@ abstract fun initOnCreate(savedInstanceState: Bundle?) /** - * 数据请求状态监听 - */ - abstract fun observeRequestState() - - /** * 初始化业务逻辑 */ abstract fun initEvent() diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java new file mode 100644 index 0000000..7a18c20 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java @@ -0,0 +1,255 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 从平台下载的标识器本地库实体类 + */ +@Entity(tableName = "marker_detail") +public class MarkerBean { + @PrimaryKey(autoGenerate = true) + private long id; //主键ID + private String pipelineType; // 管线类型 + private String pipelineDiameter; // 管线直径 + private String pipelineMaterial; // 管材 + private String buryMethod; // 埋设方式 + private String buryDepth; // 埋深 + private String area; // 所属区域 + private String line; // 所属线路 + private String road; // 所属道路 + private String constructTime; // 建设年代 + private String owner; // 权属单位 + private String objectId; // 标识对象ID,无实际用途 + private String markerId; // 标识器ID + private String markerType; // 标识器类型 + private String markerDepth; // 标识器埋深 + private String installationDept; // 安装部门 + private String lng; // 经度 + private String lat; // 纬度 + private String updateTime; // 最后修改时间,更新时间 + private String remark; // 备注信息 + private String underlyingPipelineType; // 下层管线类型 + private String underlyingPipelineDepth; // 下层埋深 + private String underlyingPipelineDiameter; // 下层管径 + private String underlyingPipelineMaterial; // 下层管材 + private String objectType; //标识对象类型 + private String color; // 颜色 + private String imagePath; // 图片路径 + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getPipelineType() { + return pipelineType; + } + + public void setPipelineType(String pipelineType) { + this.pipelineType = pipelineType; + } + + public String getPipelineDiameter() { + return pipelineDiameter; + } + + public void setPipelineDiameter(String pipelineDiameter) { + this.pipelineDiameter = pipelineDiameter; + } + + public String getPipelineMaterial() { + return pipelineMaterial; + } + + public void setPipelineMaterial(String pipelineMaterial) { + this.pipelineMaterial = pipelineMaterial; + } + + public String getBuryMethod() { + return buryMethod; + } + + public void setBuryMethod(String buryMethod) { + this.buryMethod = buryMethod; + } + + public String getBuryDepth() { + return buryDepth; + } + + public void setBuryDepth(String buryDepth) { + this.buryDepth = buryDepth; + } + + public String getArea() { + return area; + } + + public void setArea(String area) { + this.area = area; + } + + public String getLine() { + return line; + } + + public void setLine(String line) { + this.line = line; + } + + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + + public String getConstructTime() { + return constructTime; + } + + public void setConstructTime(String constructTime) { + this.constructTime = constructTime; + } + + public String getOwner() { + return owner; + } + + public void setOwner(String owner) { + this.owner = owner; + } + + public String getObjectId() { + return objectId; + } + + public void setObjectId(String objectId) { + this.objectId = objectId; + } + + public String getMarkerId() { + return markerId; + } + + public void setMarkerId(String markerId) { + this.markerId = markerId; + } + + public String getMarkerType() { + return markerType; + } + + public void setMarkerType(String markerType) { + this.markerType = markerType; + } + + public String getMarkerDepth() { + return markerDepth; + } + + public void setMarkerDepth(String markerDepth) { + this.markerDepth = markerDepth; + } + + public String getInstallationDept() { + return installationDept; + } + + public void setInstallationDept(String installationDept) { + this.installationDept = installationDept; + } + + public String getLng() { + return lng; + } + + public void setLng(String lng) { + this.lng = lng; + } + + public String getLat() { + return lat; + } + + public void setLat(String lat) { + this.lat = lat; + } + + public String getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } + + public String getUnderlyingPipelineType() { + return underlyingPipelineType; + } + + public void setUnderlyingPipelineType(String underlyingPipelineType) { + this.underlyingPipelineType = underlyingPipelineType; + } + + public String getUnderlyingPipelineDepth() { + return underlyingPipelineDepth; + } + + public void setUnderlyingPipelineDepth(String underlyingPipelineDepth) { + this.underlyingPipelineDepth = underlyingPipelineDepth; + } + + public String getUnderlyingPipelineDiameter() { + return underlyingPipelineDiameter; + } + + public void setUnderlyingPipelineDiameter(String underlyingPipelineDiameter) { + this.underlyingPipelineDiameter = underlyingPipelineDiameter; + } + + public String getUnderlyingPipelineMaterial() { + return underlyingPipelineMaterial; + } + + public void setUnderlyingPipelineMaterial(String underlyingPipelineMaterial) { + this.underlyingPipelineMaterial = underlyingPipelineMaterial; + } + + public String getObjectType() { + return objectType; + } + + public void setObjectType(String objectType) { + this.objectType = objectType; + } + + public String getColor() { + return color; + } + + public void setColor(String color) { + this.color = color; + } + + public String getImagePath() { + return imagePath; + } + + public void setImagePath(String imagePath) { + this.imagePath = imagePath; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java deleted file mode 100644 index 3f2fcdc..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java +++ /dev/null @@ -1,327 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 从平台下载的标识器本地库实体类 - */ -@Entity -public class MarkerLocalBean { - @Id(autoincrement = true) - private Long id;//本地库主键ID - - // 管线类型 - private String pipelineType; - // 管线直径 - private String pipelineDiameter; - // 管材 - private String pipelineMaterial; - // 埋设方式 - private String buryMethod; - // 埋深 - private String buryDepth; - // 所属区域 - private String area; - // 所属线路 - private String line; - // 所属道路 - private String road; - // 建设年代 - private String constructTime; - // 权属单位 - private String owner; - //标识对象ID,无实际用途 - @Deprecated - private String objectId; - // 标识器ID - private String markerId; - // 标识器类型 - private String markerType; - // 标识器埋深 - private String markerDepth; - // 安装部门 - private String installationDept; - // 经度 - private String lng; - // 纬度 - private String lat; - //最后修改时间,更新时间 - private String updateTime; - // 备注信息 - private String remark; - // 下层管线类型 - private String underlyingPipelineType; - // 下层埋深 - private String underlyingPipelineDepth; - // 下层管径 - private String underlyingPipelineDiameter; - // 下层管材 - private String underlyingPipelineMaterial; - //标识对象类型 - private String objectType; - // 颜色 - private String color; - // 图片路径 - private String imagePath; - - @Generated(hash = 1479045776) - public MarkerLocalBean(Long id, String pipelineType, String pipelineDiameter, - String pipelineMaterial, String buryMethod, String buryDepth, - String area, String line, String road, String constructTime, - String owner, String objectId, String markerId, String markerType, - String markerDepth, String installationDept, String lng, String lat, - String updateTime, String remark, String underlyingPipelineType, - String underlyingPipelineDepth, String underlyingPipelineDiameter, - String underlyingPipelineMaterial, String objectType, String color, - String imagePath) { - this.id = id; - this.pipelineType = pipelineType; - this.pipelineDiameter = pipelineDiameter; - this.pipelineMaterial = pipelineMaterial; - this.buryMethod = buryMethod; - this.buryDepth = buryDepth; - this.area = area; - this.line = line; - this.road = road; - this.constructTime = constructTime; - this.owner = owner; - this.objectId = objectId; - this.markerId = markerId; - this.markerType = markerType; - this.markerDepth = markerDepth; - this.installationDept = installationDept; - this.lng = lng; - this.lat = lat; - this.updateTime = updateTime; - this.remark = remark; - this.underlyingPipelineType = underlyingPipelineType; - this.underlyingPipelineDepth = underlyingPipelineDepth; - this.underlyingPipelineDiameter = underlyingPipelineDiameter; - this.underlyingPipelineMaterial = underlyingPipelineMaterial; - this.objectType = objectType; - this.color = color; - this.imagePath = imagePath; - } - - @Generated(hash = 1538606012) - public MarkerLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getPipelineType() { - return this.pipelineType; - } - - public void setPipelineType(String pipelineType) { - this.pipelineType = pipelineType; - } - - public String getPipelineDiameter() { - return this.pipelineDiameter; - } - - public void setPipelineDiameter(String pipelineDiameter) { - this.pipelineDiameter = pipelineDiameter; - } - - public String getPipelineMaterial() { - return this.pipelineMaterial; - } - - public void setPipelineMaterial(String pipelineMaterial) { - this.pipelineMaterial = pipelineMaterial; - } - - public String getBuryMethod() { - return this.buryMethod; - } - - public void setBuryMethod(String buryMethod) { - this.buryMethod = buryMethod; - } - - public String getBuryDepth() { - return this.buryDepth; - } - - public void setBuryDepth(String buryDepth) { - this.buryDepth = buryDepth; - } - - public String getArea() { - return this.area; - } - - public void setArea(String area) { - this.area = area; - } - - public String getLine() { - return this.line; - } - - public void setLine(String line) { - this.line = line; - } - - public String getRoad() { - return this.road; - } - - public void setRoad(String road) { - this.road = road; - } - - public String getConstructTime() { - return this.constructTime; - } - - public void setConstructTime(String constructTime) { - this.constructTime = constructTime; - } - - public String getOwner() { - return this.owner; - } - - public void setOwner(String owner) { - this.owner = owner; - } - - public String getObjectId() { - return this.objectId; - } - - public void setObjectId(String objectId) { - this.objectId = objectId; - } - - public String getMarkerId() { - return this.markerId; - } - - public void setMarkerId(String markerId) { - this.markerId = markerId; - } - - public String getMarkerType() { - return this.markerType; - } - - public void setMarkerType(String markerType) { - this.markerType = markerType; - } - - public String getMarkerDepth() { - return this.markerDepth; - } - - public void setMarkerDepth(String markerDepth) { - this.markerDepth = markerDepth; - } - - public String getInstallationDept() { - return this.installationDept; - } - - public void setInstallationDept(String installationDept) { - this.installationDept = installationDept; - } - - public String getLng() { - return this.lng; - } - - public void setLng(String lng) { - this.lng = lng; - } - - public String getLat() { - return this.lat; - } - - public void setLat(String lat) { - this.lat = lat; - } - - public String getUpdateTime() { - return this.updateTime; - } - - public void setUpdateTime(String updateTime) { - this.updateTime = updateTime; - } - - public String getRemark() { - return this.remark; - } - - public void setRemark(String remark) { - this.remark = remark; - } - - public String getUnderlyingPipelineType() { - return this.underlyingPipelineType; - } - - public void setUnderlyingPipelineType(String underlyingPipelineType) { - this.underlyingPipelineType = underlyingPipelineType; - } - - public String getUnderlyingPipelineDepth() { - return this.underlyingPipelineDepth; - } - - public void setUnderlyingPipelineDepth(String underlyingPipelineDepth) { - this.underlyingPipelineDepth = underlyingPipelineDepth; - } - - public String getUnderlyingPipelineDiameter() { - return this.underlyingPipelineDiameter; - } - - public void setUnderlyingPipelineDiameter(String underlyingPipelineDiameter) { - this.underlyingPipelineDiameter = underlyingPipelineDiameter; - } - - public String getUnderlyingPipelineMaterial() { - return this.underlyingPipelineMaterial; - } - - public void setUnderlyingPipelineMaterial(String underlyingPipelineMaterial) { - this.underlyingPipelineMaterial = underlyingPipelineMaterial; - } - - public String getObjectType() { - return this.objectType; - } - - public void setObjectType(String objectType) { - this.objectType = objectType; - } - - public String getColor() { - return this.color; - } - - public void setColor(String color) { - this.color = color; - } - - public String getImagePath() { - return this.imagePath; - } - - public void setImagePath(String imagePath) { - this.imagePath = imagePath; - } -} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java new file mode 100644 index 0000000..5c88fdf --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java @@ -0,0 +1,93 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 巡检任务本地库实体类,不包含任务里面需要巡检的标识器信息 + */ +@Entity(tableName = "task_detail") +public class TaskBean { + @PrimaryKey(autoGenerate = true) + private long id;//主键ID + private String taskCode; // 任务编号 + private String description; // 任务名称 + private String createTime; // 任务创建的时间 + private String status; // 任务状态 + private String createUserName; // 任务创建者名称 + private String startTime; // 任务被开始执行的时间 + private String endTime; // 任务执行结束的时间 + private String isFree; // 是否自由巡检。1-是,0-否 + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getTaskCode() { + return taskCode; + } + + public void setTaskCode(String taskCode) { + this.taskCode = taskCode; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getCreateUserName() { + return createUserName; + } + + public void setCreateUserName(String createUserName) { + this.createUserName = createUserName; + } + + public String getStartTime() { + return startTime; + } + + public void setStartTime(String startTime) { + this.startTime = startTime; + } + + public String getEndTime() { + return endTime; + } + + public void setEndTime(String endTime) { + this.endTime = endTime; + } + + public String getIsFree() { + return isFree; + } + + public void setIsFree(String isFree) { + this.isFree = isFree; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java deleted file mode 100644 index 91737b3..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java +++ /dev/null @@ -1,114 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 巡检任务本地库实体类,不包含任务里面需要巡检的标识器信息 - */ -@Entity -public class TaskLocalBean { - @Id - private Long id;//任务ID - - private String taskCode;//任务编号 - private String description;//任务名称 - private String createTime;//任务创建的时间 - private String status;//任务状态 - private String createUserName;//任务创建者名称 - private String startTime;//任务被开始执行的时间 - private String endTime;//任务执行结束的时间 - private String isFreeTask;//是否自由巡检。1-是,0-否 - - @Generated(hash = 1482022528) - public TaskLocalBean(Long id, String taskCode, String description, - String createTime, String status, String createUserName, - String startTime, String endTime, String isFreeTask) { - this.id = id; - this.taskCode = taskCode; - this.description = description; - this.createTime = createTime; - this.status = status; - this.createUserName = createUserName; - this.startTime = startTime; - this.endTime = endTime; - this.isFreeTask = isFreeTask; - } - - @Generated(hash = 949704588) - public TaskLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getTaskCode() { - return this.taskCode; - } - - public void setTaskCode(String taskCode) { - this.taskCode = taskCode; - } - - public String getDescription() { - return this.description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getCreateTime() { - return this.createTime; - } - - public void setCreateTime(String createTime) { - this.createTime = createTime; - } - - public String getStatus() { - return this.status; - } - - public void setStatus(String status) { - this.status = status; - } - - public String getCreateUserName() { - return this.createUserName; - } - - public void setCreateUserName(String createUserName) { - this.createUserName = createUserName; - } - - public String getStartTime() { - return this.startTime; - } - - public void setStartTime(String startTime) { - this.startTime = startTime; - } - - public String getEndTime() { - return this.endTime; - } - - public void setEndTime(String endTime) { - this.endTime = endTime; - } - - public String getIsFreeTask() { - return this.isFreeTask; - } - - public void setIsFreeTask(String isFreeTask) { - this.isFreeTask = isFreeTask; - } -} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerBean.java new file mode 100644 index 0000000..c563a60 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerBean.java @@ -0,0 +1,110 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 巡检任务里面需要巡检的标识器信息本地库实体类 + */ +@Entity(tableName = "task_marker_info") +public class TaskMarkerBean { + //标识器后台库的主键ID,不是标识器实际ID + @PrimaryKey(autoGenerate = true) + private long id; + + /** + * 任务ID,通过此字段关联[TaskBean.id] + */ + private String taskId; + + /** + * 任务Code,通过此字段关联[TaskBean.taskCode] + *

+ *

+ * 双重验证,防止出现同时刻重复的情况 + */ + private String taskCode; + + /** + * 对应后台字段[TaskModel.MessageModel.TaskDetailInfosModel.markerIdReal],也就是探测仪扫描出来的ID + */ + private String markerId; + + private Double lng; + private Double lat; + + /** + * 是否已被探测到 + * 1-是,0-否 + */ + private String isDetected; + + /** + * 被探测到的时间,对应后台字段[TaskModel.MessageModel.TaskDetailInfosModel.finishTime] + */ + private String detectedTime; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getTaskId() { + return taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getTaskCode() { + return taskCode; + } + + public void setTaskCode(String taskCode) { + this.taskCode = taskCode; + } + + public String getMarkerId() { + return markerId; + } + + public void setMarkerId(String markerId) { + this.markerId = markerId; + } + + public Double getLng() { + return lng; + } + + public void setLng(Double lng) { + this.lng = lng; + } + + public Double getLat() { + return lat; + } + + public void setLat(Double lat) { + this.lat = lat; + } + + public String getIsDetected() { + return isDetected; + } + + public void setIsDetected(String isDetected) { + this.isDetected = isDetected; + } + + public String getDetectedTime() { + return detectedTime; + } + + public void setDetectedTime(String detectedTime) { + this.detectedTime = detectedTime; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerLocalBean.java deleted file mode 100644 index de9f459..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerLocalBean.java +++ /dev/null @@ -1,128 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import com.casic.common.detector.gd.model.TaskModel; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 巡检任务里面需要巡检的标识器信息本地库实体类 - */ -@Entity -public class TaskMarkerLocalBean { - @Id - private Long id;//标识器后台库的主键ID,不是标识器实际ID - - /** - * 任务ID,通过此字段关联{@link TaskLocalBean#id} - */ - private String taskId; - - /** - * 任务Code,通过此字段关联{@link TaskLocalBean#taskCode} - *

- * 双重验证,防止出现同时刻重复的情况 - */ - private String taskCode; - - /** - * 对应后台字段{@link TaskModel.MessageModel.TaskDetailInfosModel#markerIdReal},也就是探测仪扫描出来的ID - */ - private String markerId; - - private double lng; - private double lat; - - /** - * 是否已被探测到 - * 1-是,0-否 - */ - private String isDetected; - - /** - * 被探测到的时间,对应后台字段{@link TaskModel.MessageModel.TaskDetailInfosModel#finishTime} - */ - private String detectedTime; - - @Generated(hash = 677328533) - public TaskMarkerLocalBean(Long id, String taskId, String taskCode, String markerId, - double lng, double lat, String isDetected, String detectedTime) { - this.id = id; - this.taskId = taskId; - this.taskCode = taskCode; - this.markerId = markerId; - this.lng = lng; - this.lat = lat; - this.isDetected = isDetected; - this.detectedTime = detectedTime; - } - - @Generated(hash = 1162404642) - public TaskMarkerLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getTaskId() { - return this.taskId; - } - - public void setTaskId(String taskId) { - this.taskId = taskId; - } - - public String getTaskCode() { - return this.taskCode; - } - - public void setTaskCode(String taskCode) { - this.taskCode = taskCode; - } - - public String getMarkerId() { - return this.markerId; - } - - public void setMarkerId(String markerId) { - this.markerId = markerId; - } - - public double getLng() { - return this.lng; - } - - public void setLng(double lng) { - this.lng = lng; - } - - public double getLat() { - return this.lat; - } - - public void setLat(double lat) { - this.lat = lat; - } - - public String getIsDetected() { - return this.isDetected; - } - - public void setIsDetected(String isDetected) { - this.isDetected = isDetected; - } - - public String getDetectedTime() { - return this.detectedTime; - } - - public void setDetectedTime(String detectedTime) { - this.detectedTime = detectedTime; - } -} diff --git a/app/src/main/java/com/casic/common/detector/gd/dao/MarkerBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/dao/MarkerBeanDao.java new file mode 100644 index 0000000..2beb7ed --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/dao/MarkerBeanDao.java @@ -0,0 +1,29 @@ +package com.casic.common.detector.gd.dao; + +import androidx.room.Dao; +import androidx.room.Insert; +import androidx.room.Query; +import androidx.room.RawQuery; +import androidx.sqlite.db.SupportSQLiteQuery; + +import com.casic.common.detector.gd.bean.MarkerBean; + +import java.util.List; + +@Dao +public interface MarkerBeanDao { + @Query("DELETE FROM marker_detail") + void deleteAll(); + + @Insert + void insert(MarkerBean marker); + + @Query("SELECT * FROM marker_detail") + List loadAll(); + + @Query("SELECT * FROM marker_detail WHERE markerId = :markerId") + List queryMarkerById(String markerId); + + @RawQuery + List loadMarkersByCondition(SupportSQLiteQuery query); +} diff --git a/app/src/main/java/com/casic/common/detector/gd/dao/TaskBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/dao/TaskBeanDao.java new file mode 100644 index 0000000..9c70ac2 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/dao/TaskBeanDao.java @@ -0,0 +1,120 @@ +package com.casic.common.detector.gd.dao; + +import androidx.room.Dao; +import androidx.room.Insert; +import androidx.room.Query; +import androidx.room.Transaction; + +import com.casic.common.detector.gd.bean.TaskBean; +import com.casic.common.detector.gd.bean.TaskMarkerBean; +import com.casic.common.detector.gd.model.TaskDetailLocalModel; +import com.casic.common.detector.gd.model.TaskModel; +import com.casic.common.detector.gd.utils.LocaleConstant; +import com.pengxh.kt.lite.utils.SaveKeyValues; + +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Locale; + +@Dao +public interface TaskBeanDao { + @Query("SELECT COUNT(*) FROM task_detail WHERE id = :taskId") + int isTaskExist(long taskId); + + @Insert + void insert(TaskBean task); + + default void saveTask(Long taskId, String taskName) { + if (isTaskExist(taskId) == 0) { + TaskBean task = new TaskBean(); + task.setId(taskId); + task.setTaskCode(new SimpleDateFormat("yyyyMMddHHmmss", Locale.CHINA).format(new Date())); + task.setDescription(taskName); + String time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA).format(new Date()); + task.setCreateTime(time); + task.setStatus("0"); + String userName = (String) SaveKeyValues.INSTANCE.getValue(LocaleConstant.USER_NAME, ""); + task.setCreateUserName(userName); + task.setStartTime(time); + task.setEndTime(""); + task.setIsFree("1"); + insert(task); + } + } + + default void saveTask(TaskModel.MessageModel model) { + TaskBean task = new TaskBean(); + task.setId(model.getId()); + task.setTaskCode(model.getTaskCode()); + task.setDescription(model.getDescription()); + task.setCreateTime(model.getDeployDate()); + task.setStatus(model.getStatus()); + task.setCreateUserName(model.getCreatorName()); + task.setStartTime(model.getBeginDate()); + task.setEndTime(model.getEndDate()); + task.setIsFree("0"); + if (isTaskExist(task.getId()) == 0) { + insert(task); + } + } + + @Query("SELECT * FROM task_detail") + List loadAll(); + + @Transaction + default ArrayList loadLocalTask(TaskMarkerBeanDao taskMarkerBeanDao) { + ArrayList result = new ArrayList<>(); + List tasks = loadAll(); + for (TaskBean it : tasks) { + TaskDetailLocalModel model = new TaskDetailLocalModel(); + model.setTaskId(String.valueOf(it.getId())); + model.setTaskCode(it.getTaskCode()); + model.setDescription(it.getDescription()); + model.setCreateTime(it.getCreateTime()); + model.setStatus(it.getStatus()); + model.setCreateUserName(it.getCreateUserName()); + model.setIsFreeTask(it.getIsFree()); + ArrayList results = new ArrayList<>(); + if ("0".equals(it.getIsFree())) { + // 非自由巡检才有Marker + List markers = taskMarkerBeanDao.getMarkersByIdAndCode(String.valueOf(it.getId()), it.getTaskCode()); + for (TaskMarkerBean marker : markers) { + TaskDetailLocalModel.TaskMarkerLocalModel localModel = new TaskDetailLocalModel.TaskMarkerLocalModel(); + localModel.setMarkerId(marker.getMarkerId()); + localModel.setLng(marker.getLng()); + localModel.setLat(marker.getLat()); + localModel.setIsDetected(marker.getIsDetected()); + localModel.setDetectedTime(marker.getDetectedTime()); + + results.add(localModel); + } + } + model.setMarkerModels(results); + result.add(model); + } + return result; + } + + @Query("DELETE FROM task_detail WHERE id = :taskId AND taskCode = :taskCode") + void deleteTaskById(long taskId, String taskCode); + + @Transaction + default void deleteLocalTaskById(long taskId, String taskCode, TaskMarkerBeanDao taskMarkerBeanDao) { + TaskBean task = loadAll().stream() + .filter(it -> it.getId() == taskId && taskCode.equals(it.getTaskCode())) + .findFirst() + .orElse(null); + if (task == null) return; + deleteTaskById(taskId, taskCode); + + // 删除此任务关联的Marker。非自由巡检才有Marker + if ("0".equals(task.getIsFree())) { + List markers = taskMarkerBeanDao.getMarkersByIdAndCode(String.valueOf(task.getId()), task.getTaskCode()); + for (TaskMarkerBean marker : markers) { + taskMarkerBeanDao.delete(marker); + } + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/dao/TaskMarkerBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/dao/TaskMarkerBeanDao.java new file mode 100644 index 0000000..cc2156a --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/dao/TaskMarkerBeanDao.java @@ -0,0 +1,52 @@ +package com.casic.common.detector.gd.dao; + +import androidx.room.Dao; +import androidx.room.Delete; +import androidx.room.Insert; +import androidx.room.Query; +import androidx.room.Update; + +import com.casic.common.detector.gd.bean.TaskMarkerBean; +import com.casic.common.detector.gd.model.TaskModel; + +import java.util.List; + +@Dao +public interface TaskMarkerBeanDao { + + @Insert + void insert(TaskMarkerBean marker); + + @Query("SELECT COUNT(*) FROM task_marker_info WHERE id = :markerId") + int isMarkerExist(String markerId); + + default void saveTaskMarker(long taskId, String taskCode, TaskModel.MessageModel.TaskDetailInfosModel marker) { + if (isMarkerExist(marker.getMarkerId()) == 0) { + TaskMarkerBean bean = new TaskMarkerBean(); + bean.setId(marker.getId()); + bean.setTaskId(String.valueOf(taskId)); + bean.setTaskCode(taskCode); + bean.setMarkerId(marker.getMarkerIdReal()); + bean.setLng(marker.getLongitude()); + bean.setLat(marker.getLatitude()); + bean.setIsDetected("0"); + bean.setDetectedTime(""); + insert(bean); + } + } + + @Query("SELECT * FROM task_marker_info WHERE taskId = :taskId AND taskCode = :taskCode AND markerId = :markerId AND isDetected = :state") + TaskMarkerBean queryTaskMarkerById(String taskId, String taskCode, String markerId, String state); + + @Update + void updateLocalTaskMarkerState(TaskMarkerBean marker); + + @Query("SELECT * FROM task_marker_info WHERE isDetected = :state") + List queryMarkerByState(String state); + + @Query("SELECT * FROM task_marker_info WHERE taskId = :taskId AND taskCode = :taskCode") + List getMarkersByIdAndCode(String taskId, String taskCode); + + @Delete + void delete(TaskMarkerBean marker); +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/extensions/Long.kt b/app/src/main/java/com/casic/common/detector/gd/extensions/Long.kt deleted file mode 100644 index 6713d8d..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/extensions/Long.kt +++ /dev/null @@ -1,10 +0,0 @@ -package com.casic.common.detector.gd.extensions - -import java.text.SimpleDateFormat -import java.util.Date -import java.util.Locale - -fun Long.createTaskCode(): String { - val dateFormat = SimpleDateFormat("yyyyMMddHHmmss", Locale.CHINA) - return dateFormat.format(Date(this)) -} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoMaster.java b/app/src/main/java/com/casic/common/detector/gd/greendao/DaoMaster.java deleted file mode 100644 index 6ab94b3..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoMaster.java +++ /dev/null @@ -1,102 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import android.content.Context; -import android.database.sqlite.SQLiteDatabase; -import android.database.sqlite.SQLiteDatabase.CursorFactory; -import android.util.Log; - -import org.greenrobot.greendao.AbstractDaoMaster; -import org.greenrobot.greendao.database.StandardDatabase; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.database.DatabaseOpenHelper; -import org.greenrobot.greendao.identityscope.IdentityScopeType; - - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** - * Master of DAO (schema version 1): knows all DAOs. - */ -public class DaoMaster extends AbstractDaoMaster { - public static final int SCHEMA_VERSION = 1; - - /** Creates underlying database table using DAOs. */ - public static void createAllTables(Database db, boolean ifNotExists) { - MarkerLocalBeanDao.createTable(db, ifNotExists); - TaskLocalBeanDao.createTable(db, ifNotExists); - TaskMarkerLocalBeanDao.createTable(db, ifNotExists); - } - - /** Drops underlying database table using DAOs. */ - public static void dropAllTables(Database db, boolean ifExists) { - MarkerLocalBeanDao.dropTable(db, ifExists); - TaskLocalBeanDao.dropTable(db, ifExists); - TaskMarkerLocalBeanDao.dropTable(db, ifExists); - } - - /** - * WARNING: Drops all table on Upgrade! Use only during development. - * Convenience method using a {@link DevOpenHelper}. - */ - public static DaoSession newDevSession(Context context, String name) { - Database db = new DevOpenHelper(context, name).getWritableDb(); - DaoMaster daoMaster = new DaoMaster(db); - return daoMaster.newSession(); - } - - public DaoMaster(SQLiteDatabase db) { - this(new StandardDatabase(db)); - } - - public DaoMaster(Database db) { - super(db, SCHEMA_VERSION); - registerDaoClass(MarkerLocalBeanDao.class); - registerDaoClass(TaskLocalBeanDao.class); - registerDaoClass(TaskMarkerLocalBeanDao.class); - } - - public DaoSession newSession() { - return new DaoSession(db, IdentityScopeType.Session, daoConfigMap); - } - - public DaoSession newSession(IdentityScopeType type) { - return new DaoSession(db, type, daoConfigMap); - } - - /** - * Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} - - */ - public static abstract class OpenHelper extends DatabaseOpenHelper { - public OpenHelper(Context context, String name) { - super(context, name, SCHEMA_VERSION); - } - - public OpenHelper(Context context, String name, CursorFactory factory) { - super(context, name, factory, SCHEMA_VERSION); - } - - @Override - public void onCreate(Database db) { - Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION); - createAllTables(db, false); - } - } - - /** WARNING: Drops all table on Upgrade! Use only during development. */ - public static class DevOpenHelper extends OpenHelper { - public DevOpenHelper(Context context, String name) { - super(context, name); - } - - public DevOpenHelper(Context context, String name, CursorFactory factory) { - super(context, name, factory); - } - - @Override - public void onUpgrade(Database db, int oldVersion, int newVersion) { - Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables"); - dropAllTables(db, true); - onCreate(db); - } - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoSession.java b/app/src/main/java/com/casic/common/detector/gd/greendao/DaoSession.java deleted file mode 100644 index c8b1a20..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoSession.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import java.util.Map; - -import org.greenrobot.greendao.AbstractDao; -import org.greenrobot.greendao.AbstractDaoSession; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.identityscope.IdentityScopeType; -import org.greenrobot.greendao.internal.DaoConfig; - -import com.casic.common.detector.gd.bean.MarkerLocalBean; -import com.casic.common.detector.gd.bean.TaskLocalBean; -import com.casic.common.detector.gd.bean.TaskMarkerLocalBean; - -import com.casic.common.detector.gd.greendao.MarkerLocalBeanDao; -import com.casic.common.detector.gd.greendao.TaskLocalBeanDao; -import com.casic.common.detector.gd.greendao.TaskMarkerLocalBeanDao; - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. - -/** - * {@inheritDoc} - * - * @see org.greenrobot.greendao.AbstractDaoSession - */ -public class DaoSession extends AbstractDaoSession { - - private final DaoConfig markerLocalBeanDaoConfig; - private final DaoConfig taskLocalBeanDaoConfig; - private final DaoConfig taskMarkerLocalBeanDaoConfig; - - private final MarkerLocalBeanDao markerLocalBeanDao; - private final TaskLocalBeanDao taskLocalBeanDao; - private final TaskMarkerLocalBeanDao taskMarkerLocalBeanDao; - - public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> - daoConfigMap) { - super(db); - - markerLocalBeanDaoConfig = daoConfigMap.get(MarkerLocalBeanDao.class).clone(); - markerLocalBeanDaoConfig.initIdentityScope(type); - - taskLocalBeanDaoConfig = daoConfigMap.get(TaskLocalBeanDao.class).clone(); - taskLocalBeanDaoConfig.initIdentityScope(type); - - taskMarkerLocalBeanDaoConfig = daoConfigMap.get(TaskMarkerLocalBeanDao.class).clone(); - taskMarkerLocalBeanDaoConfig.initIdentityScope(type); - - markerLocalBeanDao = new MarkerLocalBeanDao(markerLocalBeanDaoConfig, this); - taskLocalBeanDao = new TaskLocalBeanDao(taskLocalBeanDaoConfig, this); - taskMarkerLocalBeanDao = new TaskMarkerLocalBeanDao(taskMarkerLocalBeanDaoConfig, this); - - registerDao(MarkerLocalBean.class, markerLocalBeanDao); - registerDao(TaskLocalBean.class, taskLocalBeanDao); - registerDao(TaskMarkerLocalBean.class, taskMarkerLocalBeanDao); - } - - public void clear() { - markerLocalBeanDaoConfig.clearIdentityScope(); - taskLocalBeanDaoConfig.clearIdentityScope(); - taskMarkerLocalBeanDaoConfig.clearIdentityScope(); - } - - public MarkerLocalBeanDao getMarkerLocalBeanDao() { - return markerLocalBeanDao; - } - - public TaskLocalBeanDao getTaskLocalBeanDao() { - return taskLocalBeanDao; - } - - public TaskMarkerLocalBeanDao getTaskMarkerLocalBeanDao() { - return taskMarkerLocalBeanDao; - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/MarkerLocalBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/greendao/MarkerLocalBeanDao.java deleted file mode 100644 index 2f792c3..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/MarkerLocalBeanDao.java +++ /dev/null @@ -1,479 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import android.database.Cursor; -import android.database.sqlite.SQLiteStatement; - -import org.greenrobot.greendao.AbstractDao; -import org.greenrobot.greendao.Property; -import org.greenrobot.greendao.internal.DaoConfig; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.database.DatabaseStatement; - -import com.casic.common.detector.gd.bean.MarkerLocalBean; - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** - * DAO for table "MARKER_LOCAL_BEAN". -*/ -public class MarkerLocalBeanDao extends AbstractDao { - - public static final String TABLENAME = "MARKER_LOCAL_BEAN"; - - /** - * Properties of entity MarkerLocalBean.
- * Can be used for QueryBuilder and for referencing column names. - */ - public static class Properties { - public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property PipelineType = new Property(1, String.class, "pipelineType", false, "PIPELINE_TYPE"); - public final static Property PipelineDiameter = new Property(2, String.class, "pipelineDiameter", false, "PIPELINE_DIAMETER"); - public final static Property PipelineMaterial = new Property(3, String.class, "pipelineMaterial", false, "PIPELINE_MATERIAL"); - public final static Property BuryMethod = new Property(4, String.class, "buryMethod", false, "BURY_METHOD"); - public final static Property BuryDepth = new Property(5, String.class, "buryDepth", false, "BURY_DEPTH"); - public final static Property Area = new Property(6, String.class, "area", false, "AREA"); - public final static Property Line = new Property(7, String.class, "line", false, "LINE"); - public final static Property Road = new Property(8, String.class, "road", false, "ROAD"); - public final static Property ConstructTime = new Property(9, String.class, "constructTime", false, "CONSTRUCT_TIME"); - public final static Property Owner = new Property(10, String.class, "owner", false, "OWNER"); - public final static Property ObjectId = new Property(11, String.class, "objectId", false, "OBJECT_ID"); - public final static Property MarkerId = new Property(12, String.class, "markerId", false, "MARKER_ID"); - public final static Property MarkerType = new Property(13, String.class, "markerType", false, "MARKER_TYPE"); - public final static Property MarkerDepth = new Property(14, String.class, "markerDepth", false, "MARKER_DEPTH"); - public final static Property InstallationDept = new Property(15, String.class, "installationDept", false, "INSTALLATION_DEPT"); - public final static Property Lng = new Property(16, String.class, "lng", false, "LNG"); - public final static Property Lat = new Property(17, String.class, "lat", false, "LAT"); - public final static Property UpdateTime = new Property(18, String.class, "updateTime", false, "UPDATE_TIME"); - public final static Property Remark = new Property(19, String.class, "remark", false, "REMARK"); - public final static Property UnderlyingPipelineType = new Property(20, String.class, "underlyingPipelineType", false, "UNDERLYING_PIPELINE_TYPE"); - public final static Property UnderlyingPipelineDepth = new Property(21, String.class, "underlyingPipelineDepth", false, "UNDERLYING_PIPELINE_DEPTH"); - public final static Property UnderlyingPipelineDiameter = new Property(22, String.class, "underlyingPipelineDiameter", false, "UNDERLYING_PIPELINE_DIAMETER"); - public final static Property UnderlyingPipelineMaterial = new Property(23, String.class, "underlyingPipelineMaterial", false, "UNDERLYING_PIPELINE_MATERIAL"); - public final static Property ObjectType = new Property(24, String.class, "objectType", false, "OBJECT_TYPE"); - public final static Property Color = new Property(25, String.class, "color", false, "COLOR"); - public final static Property ImagePath = new Property(26, String.class, "imagePath", false, "IMAGE_PATH"); - } - - - public MarkerLocalBeanDao(DaoConfig config) { - super(config); - } - - public MarkerLocalBeanDao(DaoConfig config, DaoSession daoSession) { - super(config, daoSession); - } - - /** Creates the underlying database table. */ - public static void createTable(Database db, boolean ifNotExists) { - String constraint = ifNotExists? "IF NOT EXISTS ": ""; - db.execSQL("CREATE TABLE " + constraint + "\"MARKER_LOCAL_BEAN\" (" + // - "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id - "\"PIPELINE_TYPE\" TEXT," + // 1: pipelineType - "\"PIPELINE_DIAMETER\" TEXT," + // 2: pipelineDiameter - "\"PIPELINE_MATERIAL\" TEXT," + // 3: pipelineMaterial - "\"BURY_METHOD\" TEXT," + // 4: buryMethod - "\"BURY_DEPTH\" TEXT," + // 5: buryDepth - "\"AREA\" TEXT," + // 6: area - "\"LINE\" TEXT," + // 7: line - "\"ROAD\" TEXT," + // 8: road - "\"CONSTRUCT_TIME\" TEXT," + // 9: constructTime - "\"OWNER\" TEXT," + // 10: owner - "\"OBJECT_ID\" TEXT," + // 11: objectId - "\"MARKER_ID\" TEXT," + // 12: markerId - "\"MARKER_TYPE\" TEXT," + // 13: markerType - "\"MARKER_DEPTH\" TEXT," + // 14: markerDepth - "\"INSTALLATION_DEPT\" TEXT," + // 15: installationDept - "\"LNG\" TEXT," + // 16: lng - "\"LAT\" TEXT," + // 17: lat - "\"UPDATE_TIME\" TEXT," + // 18: updateTime - "\"REMARK\" TEXT," + // 19: remark - "\"UNDERLYING_PIPELINE_TYPE\" TEXT," + // 20: underlyingPipelineType - "\"UNDERLYING_PIPELINE_DEPTH\" TEXT," + // 21: underlyingPipelineDepth - "\"UNDERLYING_PIPELINE_DIAMETER\" TEXT," + // 22: underlyingPipelineDiameter - "\"UNDERLYING_PIPELINE_MATERIAL\" TEXT," + // 23: underlyingPipelineMaterial - "\"OBJECT_TYPE\" TEXT," + // 24: objectType - "\"COLOR\" TEXT," + // 25: color - "\"IMAGE_PATH\" TEXT);"); // 26: imagePath - } - - /** Drops the underlying database table. */ - public static void dropTable(Database db, boolean ifExists) { - String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"MARKER_LOCAL_BEAN\""; - db.execSQL(sql); - } - - @Override - protected final void bindValues(DatabaseStatement stmt, MarkerLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String pipelineType = entity.getPipelineType(); - if (pipelineType != null) { - stmt.bindString(2, pipelineType); - } - - String pipelineDiameter = entity.getPipelineDiameter(); - if (pipelineDiameter != null) { - stmt.bindString(3, pipelineDiameter); - } - - String pipelineMaterial = entity.getPipelineMaterial(); - if (pipelineMaterial != null) { - stmt.bindString(4, pipelineMaterial); - } - - String buryMethod = entity.getBuryMethod(); - if (buryMethod != null) { - stmt.bindString(5, buryMethod); - } - - String buryDepth = entity.getBuryDepth(); - if (buryDepth != null) { - stmt.bindString(6, buryDepth); - } - - String area = entity.getArea(); - if (area != null) { - stmt.bindString(7, area); - } - - String line = entity.getLine(); - if (line != null) { - stmt.bindString(8, line); - } - - String road = entity.getRoad(); - if (road != null) { - stmt.bindString(9, road); - } - - String constructTime = entity.getConstructTime(); - if (constructTime != null) { - stmt.bindString(10, constructTime); - } - - String owner = entity.getOwner(); - if (owner != null) { - stmt.bindString(11, owner); - } - - String objectId = entity.getObjectId(); - if (objectId != null) { - stmt.bindString(12, objectId); - } - - String markerId = entity.getMarkerId(); - if (markerId != null) { - stmt.bindString(13, markerId); - } - - String markerType = entity.getMarkerType(); - if (markerType != null) { - stmt.bindString(14, markerType); - } - - String markerDepth = entity.getMarkerDepth(); - if (markerDepth != null) { - stmt.bindString(15, markerDepth); - } - - String installationDept = entity.getInstallationDept(); - if (installationDept != null) { - stmt.bindString(16, installationDept); - } - - String lng = entity.getLng(); - if (lng != null) { - stmt.bindString(17, lng); - } - - String lat = entity.getLat(); - if (lat != null) { - stmt.bindString(18, lat); - } - - String updateTime = entity.getUpdateTime(); - if (updateTime != null) { - stmt.bindString(19, updateTime); - } - - String remark = entity.getRemark(); - if (remark != null) { - stmt.bindString(20, remark); - } - - String underlyingPipelineType = entity.getUnderlyingPipelineType(); - if (underlyingPipelineType != null) { - stmt.bindString(21, underlyingPipelineType); - } - - String underlyingPipelineDepth = entity.getUnderlyingPipelineDepth(); - if (underlyingPipelineDepth != null) { - stmt.bindString(22, underlyingPipelineDepth); - } - - String underlyingPipelineDiameter = entity.getUnderlyingPipelineDiameter(); - if (underlyingPipelineDiameter != null) { - stmt.bindString(23, underlyingPipelineDiameter); - } - - String underlyingPipelineMaterial = entity.getUnderlyingPipelineMaterial(); - if (underlyingPipelineMaterial != null) { - stmt.bindString(24, underlyingPipelineMaterial); - } - - String objectType = entity.getObjectType(); - if (objectType != null) { - stmt.bindString(25, objectType); - } - - String color = entity.getColor(); - if (color != null) { - stmt.bindString(26, color); - } - - String imagePath = entity.getImagePath(); - if (imagePath != null) { - stmt.bindString(27, imagePath); - } - } - - @Override - protected final void bindValues(SQLiteStatement stmt, MarkerLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String pipelineType = entity.getPipelineType(); - if (pipelineType != null) { - stmt.bindString(2, pipelineType); - } - - String pipelineDiameter = entity.getPipelineDiameter(); - if (pipelineDiameter != null) { - stmt.bindString(3, pipelineDiameter); - } - - String pipelineMaterial = entity.getPipelineMaterial(); - if (pipelineMaterial != null) { - stmt.bindString(4, pipelineMaterial); - } - - String buryMethod = entity.getBuryMethod(); - if (buryMethod != null) { - stmt.bindString(5, buryMethod); - } - - String buryDepth = entity.getBuryDepth(); - if (buryDepth != null) { - stmt.bindString(6, buryDepth); - } - - String area = entity.getArea(); - if (area != null) { - stmt.bindString(7, area); - } - - String line = entity.getLine(); - if (line != null) { - stmt.bindString(8, line); - } - - String road = entity.getRoad(); - if (road != null) { - stmt.bindString(9, road); - } - - String constructTime = entity.getConstructTime(); - if (constructTime != null) { - stmt.bindString(10, constructTime); - } - - String owner = entity.getOwner(); - if (owner != null) { - stmt.bindString(11, owner); - } - - String objectId = entity.getObjectId(); - if (objectId != null) { - stmt.bindString(12, objectId); - } - - String markerId = entity.getMarkerId(); - if (markerId != null) { - stmt.bindString(13, markerId); - } - - String markerType = entity.getMarkerType(); - if (markerType != null) { - stmt.bindString(14, markerType); - } - - String markerDepth = entity.getMarkerDepth(); - if (markerDepth != null) { - stmt.bindString(15, markerDepth); - } - - String installationDept = entity.getInstallationDept(); - if (installationDept != null) { - stmt.bindString(16, installationDept); - } - - String lng = entity.getLng(); - if (lng != null) { - stmt.bindString(17, lng); - } - - String lat = entity.getLat(); - if (lat != null) { - stmt.bindString(18, lat); - } - - String updateTime = entity.getUpdateTime(); - if (updateTime != null) { - stmt.bindString(19, updateTime); - } - - String remark = entity.getRemark(); - if (remark != null) { - stmt.bindString(20, remark); - } - - String underlyingPipelineType = entity.getUnderlyingPipelineType(); - if (underlyingPipelineType != null) { - stmt.bindString(21, underlyingPipelineType); - } - - String underlyingPipelineDepth = entity.getUnderlyingPipelineDepth(); - if (underlyingPipelineDepth != null) { - stmt.bindString(22, underlyingPipelineDepth); - } - - String underlyingPipelineDiameter = entity.getUnderlyingPipelineDiameter(); - if (underlyingPipelineDiameter != null) { - stmt.bindString(23, underlyingPipelineDiameter); - } - - String underlyingPipelineMaterial = entity.getUnderlyingPipelineMaterial(); - if (underlyingPipelineMaterial != null) { - stmt.bindString(24, underlyingPipelineMaterial); - } - - String objectType = entity.getObjectType(); - if (objectType != null) { - stmt.bindString(25, objectType); - } - - String color = entity.getColor(); - if (color != null) { - stmt.bindString(26, color); - } - - String imagePath = entity.getImagePath(); - if (imagePath != null) { - stmt.bindString(27, imagePath); - } - } - - @Override - public Long readKey(Cursor cursor, int offset) { - return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); - } - - @Override - public MarkerLocalBean readEntity(Cursor cursor, int offset) { - MarkerLocalBean entity = new MarkerLocalBean( // - cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // pipelineType - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // pipelineDiameter - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // pipelineMaterial - cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // buryMethod - cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // buryDepth - cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // area - cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // line - cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // road - cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // constructTime - cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10), // owner - cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11), // objectId - cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12), // markerId - cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13), // markerType - cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14), // markerDepth - cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15), // installationDept - cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16), // lng - cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17), // lat - cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18), // updateTime - cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19), // remark - cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20), // underlyingPipelineType - cursor.isNull(offset + 21) ? null : cursor.getString(offset + 21), // underlyingPipelineDepth - cursor.isNull(offset + 22) ? null : cursor.getString(offset + 22), // underlyingPipelineDiameter - cursor.isNull(offset + 23) ? null : cursor.getString(offset + 23), // underlyingPipelineMaterial - cursor.isNull(offset + 24) ? null : cursor.getString(offset + 24), // objectType - cursor.isNull(offset + 25) ? null : cursor.getString(offset + 25), // color - cursor.isNull(offset + 26) ? null : cursor.getString(offset + 26) // imagePath - ); - return entity; - } - - @Override - public void readEntity(Cursor cursor, MarkerLocalBean entity, int offset) { - entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setPipelineType(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); - entity.setPipelineDiameter(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); - entity.setPipelineMaterial(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); - entity.setBuryMethod(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); - entity.setBuryDepth(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); - entity.setArea(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); - entity.setLine(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); - entity.setRoad(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); - entity.setConstructTime(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9)); - entity.setOwner(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); - entity.setObjectId(cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11)); - entity.setMarkerId(cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12)); - entity.setMarkerType(cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13)); - entity.setMarkerDepth(cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14)); - entity.setInstallationDept(cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15)); - entity.setLng(cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16)); - entity.setLat(cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17)); - entity.setUpdateTime(cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18)); - entity.setRemark(cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19)); - entity.setUnderlyingPipelineType(cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20)); - entity.setUnderlyingPipelineDepth(cursor.isNull(offset + 21) ? null : cursor.getString(offset + 21)); - entity.setUnderlyingPipelineDiameter(cursor.isNull(offset + 22) ? null : cursor.getString(offset + 22)); - entity.setUnderlyingPipelineMaterial(cursor.isNull(offset + 23) ? null : cursor.getString(offset + 23)); - entity.setObjectType(cursor.isNull(offset + 24) ? null : cursor.getString(offset + 24)); - entity.setColor(cursor.isNull(offset + 25) ? null : cursor.getString(offset + 25)); - entity.setImagePath(cursor.isNull(offset + 26) ? null : cursor.getString(offset + 26)); - } - - @Override - protected final Long updateKeyAfterInsert(MarkerLocalBean entity, long rowId) { - entity.setId(rowId); - return rowId; - } - - @Override - public Long getKey(MarkerLocalBean entity) { - if(entity != null) { - return entity.getId(); - } else { - return null; - } - } - - @Override - public boolean hasKey(MarkerLocalBean entity) { - return entity.getId() != null; - } - - @Override - protected final boolean isEntityUpdateable() { - return true; - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/TaskLocalBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/greendao/TaskLocalBeanDao.java deleted file mode 100644 index fb88157..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/TaskLocalBeanDao.java +++ /dev/null @@ -1,227 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import android.database.Cursor; -import android.database.sqlite.SQLiteStatement; - -import org.greenrobot.greendao.AbstractDao; -import org.greenrobot.greendao.Property; -import org.greenrobot.greendao.internal.DaoConfig; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.database.DatabaseStatement; - -import com.casic.common.detector.gd.bean.TaskLocalBean; - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** - * DAO for table "TASK_LOCAL_BEAN". -*/ -public class TaskLocalBeanDao extends AbstractDao { - - public static final String TABLENAME = "TASK_LOCAL_BEAN"; - - /** - * Properties of entity TaskLocalBean.
- * Can be used for QueryBuilder and for referencing column names. - */ - public static class Properties { - public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property TaskCode = new Property(1, String.class, "taskCode", false, "TASK_CODE"); - public final static Property Description = new Property(2, String.class, "description", false, "DESCRIPTION"); - public final static Property CreateTime = new Property(3, String.class, "createTime", false, "CREATE_TIME"); - public final static Property Status = new Property(4, String.class, "status", false, "STATUS"); - public final static Property CreateUserName = new Property(5, String.class, "createUserName", false, "CREATE_USER_NAME"); - public final static Property StartTime = new Property(6, String.class, "startTime", false, "START_TIME"); - public final static Property EndTime = new Property(7, String.class, "endTime", false, "END_TIME"); - public final static Property IsFreeTask = new Property(8, String.class, "isFreeTask", false, "IS_FREE_TASK"); - } - - - public TaskLocalBeanDao(DaoConfig config) { - super(config); - } - - public TaskLocalBeanDao(DaoConfig config, DaoSession daoSession) { - super(config, daoSession); - } - - /** Creates the underlying database table. */ - public static void createTable(Database db, boolean ifNotExists) { - String constraint = ifNotExists? "IF NOT EXISTS ": ""; - db.execSQL("CREATE TABLE " + constraint + "\"TASK_LOCAL_BEAN\" (" + // - "\"_id\" INTEGER PRIMARY KEY ," + // 0: id - "\"TASK_CODE\" TEXT," + // 1: taskCode - "\"DESCRIPTION\" TEXT," + // 2: description - "\"CREATE_TIME\" TEXT," + // 3: createTime - "\"STATUS\" TEXT," + // 4: status - "\"CREATE_USER_NAME\" TEXT," + // 5: createUserName - "\"START_TIME\" TEXT," + // 6: startTime - "\"END_TIME\" TEXT," + // 7: endTime - "\"IS_FREE_TASK\" TEXT);"); // 8: isFreeTask - } - - /** Drops the underlying database table. */ - public static void dropTable(Database db, boolean ifExists) { - String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"TASK_LOCAL_BEAN\""; - db.execSQL(sql); - } - - @Override - protected final void bindValues(DatabaseStatement stmt, TaskLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String taskCode = entity.getTaskCode(); - if (taskCode != null) { - stmt.bindString(2, taskCode); - } - - String description = entity.getDescription(); - if (description != null) { - stmt.bindString(3, description); - } - - String createTime = entity.getCreateTime(); - if (createTime != null) { - stmt.bindString(4, createTime); - } - - String status = entity.getStatus(); - if (status != null) { - stmt.bindString(5, status); - } - - String createUserName = entity.getCreateUserName(); - if (createUserName != null) { - stmt.bindString(6, createUserName); - } - - String startTime = entity.getStartTime(); - if (startTime != null) { - stmt.bindString(7, startTime); - } - - String endTime = entity.getEndTime(); - if (endTime != null) { - stmt.bindString(8, endTime); - } - - String isFreeTask = entity.getIsFreeTask(); - if (isFreeTask != null) { - stmt.bindString(9, isFreeTask); - } - } - - @Override - protected final void bindValues(SQLiteStatement stmt, TaskLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String taskCode = entity.getTaskCode(); - if (taskCode != null) { - stmt.bindString(2, taskCode); - } - - String description = entity.getDescription(); - if (description != null) { - stmt.bindString(3, description); - } - - String createTime = entity.getCreateTime(); - if (createTime != null) { - stmt.bindString(4, createTime); - } - - String status = entity.getStatus(); - if (status != null) { - stmt.bindString(5, status); - } - - String createUserName = entity.getCreateUserName(); - if (createUserName != null) { - stmt.bindString(6, createUserName); - } - - String startTime = entity.getStartTime(); - if (startTime != null) { - stmt.bindString(7, startTime); - } - - String endTime = entity.getEndTime(); - if (endTime != null) { - stmt.bindString(8, endTime); - } - - String isFreeTask = entity.getIsFreeTask(); - if (isFreeTask != null) { - stmt.bindString(9, isFreeTask); - } - } - - @Override - public Long readKey(Cursor cursor, int offset) { - return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); - } - - @Override - public TaskLocalBean readEntity(Cursor cursor, int offset) { - TaskLocalBean entity = new TaskLocalBean( // - cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // taskCode - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // description - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // createTime - cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // status - cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // createUserName - cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // startTime - cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // endTime - cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8) // isFreeTask - ); - return entity; - } - - @Override - public void readEntity(Cursor cursor, TaskLocalBean entity, int offset) { - entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setTaskCode(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); - entity.setDescription(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); - entity.setCreateTime(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); - entity.setStatus(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); - entity.setCreateUserName(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); - entity.setStartTime(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); - entity.setEndTime(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); - entity.setIsFreeTask(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); - } - - @Override - protected final Long updateKeyAfterInsert(TaskLocalBean entity, long rowId) { - entity.setId(rowId); - return rowId; - } - - @Override - public Long getKey(TaskLocalBean entity) { - if(entity != null) { - return entity.getId(); - } else { - return null; - } - } - - @Override - public boolean hasKey(TaskLocalBean entity) { - return entity.getId() != null; - } - - @Override - protected final boolean isEntityUpdateable() { - return true; - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/TaskMarkerLocalBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/greendao/TaskMarkerLocalBeanDao.java deleted file mode 100644 index e96c735..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/TaskMarkerLocalBeanDao.java +++ /dev/null @@ -1,197 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import android.database.Cursor; -import android.database.sqlite.SQLiteStatement; - -import org.greenrobot.greendao.AbstractDao; -import org.greenrobot.greendao.Property; -import org.greenrobot.greendao.internal.DaoConfig; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.database.DatabaseStatement; - -import com.casic.common.detector.gd.bean.TaskMarkerLocalBean; - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** - * DAO for table "TASK_MARKER_LOCAL_BEAN". -*/ -public class TaskMarkerLocalBeanDao extends AbstractDao { - - public static final String TABLENAME = "TASK_MARKER_LOCAL_BEAN"; - - /** - * Properties of entity TaskMarkerLocalBean.
- * Can be used for QueryBuilder and for referencing column names. - */ - public static class Properties { - public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property TaskId = new Property(1, String.class, "taskId", false, "TASK_ID"); - public final static Property TaskCode = new Property(2, String.class, "taskCode", false, "TASK_CODE"); - public final static Property MarkerId = new Property(3, String.class, "markerId", false, "MARKER_ID"); - public final static Property Lng = new Property(4, double.class, "lng", false, "LNG"); - public final static Property Lat = new Property(5, double.class, "lat", false, "LAT"); - public final static Property IsDetected = new Property(6, String.class, "isDetected", false, "IS_DETECTED"); - public final static Property DetectedTime = new Property(7, String.class, "detectedTime", false, "DETECTED_TIME"); - } - - - public TaskMarkerLocalBeanDao(DaoConfig config) { - super(config); - } - - public TaskMarkerLocalBeanDao(DaoConfig config, DaoSession daoSession) { - super(config, daoSession); - } - - /** Creates the underlying database table. */ - public static void createTable(Database db, boolean ifNotExists) { - String constraint = ifNotExists? "IF NOT EXISTS ": ""; - db.execSQL("CREATE TABLE " + constraint + "\"TASK_MARKER_LOCAL_BEAN\" (" + // - "\"_id\" INTEGER PRIMARY KEY ," + // 0: id - "\"TASK_ID\" TEXT," + // 1: taskId - "\"TASK_CODE\" TEXT," + // 2: taskCode - "\"MARKER_ID\" TEXT," + // 3: markerId - "\"LNG\" REAL NOT NULL ," + // 4: lng - "\"LAT\" REAL NOT NULL ," + // 5: lat - "\"IS_DETECTED\" TEXT," + // 6: isDetected - "\"DETECTED_TIME\" TEXT);"); // 7: detectedTime - } - - /** Drops the underlying database table. */ - public static void dropTable(Database db, boolean ifExists) { - String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"TASK_MARKER_LOCAL_BEAN\""; - db.execSQL(sql); - } - - @Override - protected final void bindValues(DatabaseStatement stmt, TaskMarkerLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String taskId = entity.getTaskId(); - if (taskId != null) { - stmt.bindString(2, taskId); - } - - String taskCode = entity.getTaskCode(); - if (taskCode != null) { - stmt.bindString(3, taskCode); - } - - String markerId = entity.getMarkerId(); - if (markerId != null) { - stmt.bindString(4, markerId); - } - stmt.bindDouble(5, entity.getLng()); - stmt.bindDouble(6, entity.getLat()); - - String isDetected = entity.getIsDetected(); - if (isDetected != null) { - stmt.bindString(7, isDetected); - } - - String detectedTime = entity.getDetectedTime(); - if (detectedTime != null) { - stmt.bindString(8, detectedTime); - } - } - - @Override - protected final void bindValues(SQLiteStatement stmt, TaskMarkerLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String taskId = entity.getTaskId(); - if (taskId != null) { - stmt.bindString(2, taskId); - } - - String taskCode = entity.getTaskCode(); - if (taskCode != null) { - stmt.bindString(3, taskCode); - } - - String markerId = entity.getMarkerId(); - if (markerId != null) { - stmt.bindString(4, markerId); - } - stmt.bindDouble(5, entity.getLng()); - stmt.bindDouble(6, entity.getLat()); - - String isDetected = entity.getIsDetected(); - if (isDetected != null) { - stmt.bindString(7, isDetected); - } - - String detectedTime = entity.getDetectedTime(); - if (detectedTime != null) { - stmt.bindString(8, detectedTime); - } - } - - @Override - public Long readKey(Cursor cursor, int offset) { - return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); - } - - @Override - public TaskMarkerLocalBean readEntity(Cursor cursor, int offset) { - TaskMarkerLocalBean entity = new TaskMarkerLocalBean( // - cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // taskId - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // taskCode - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // markerId - cursor.getDouble(offset + 4), // lng - cursor.getDouble(offset + 5), // lat - cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // isDetected - cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7) // detectedTime - ); - return entity; - } - - @Override - public void readEntity(Cursor cursor, TaskMarkerLocalBean entity, int offset) { - entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setTaskId(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); - entity.setTaskCode(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); - entity.setMarkerId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); - entity.setLng(cursor.getDouble(offset + 4)); - entity.setLat(cursor.getDouble(offset + 5)); - entity.setIsDetected(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); - entity.setDetectedTime(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); - } - - @Override - protected final Long updateKeyAfterInsert(TaskMarkerLocalBean entity, long rowId) { - entity.setId(rowId); - return rowId; - } - - @Override - public Long getKey(TaskMarkerLocalBean entity) { - if(entity != null) { - return entity.getId(); - } else { - return null; - } - } - - @Override - public boolean hasKey(TaskMarkerLocalBean entity) { - return entity.getId() != null; - } - - @Override - protected final boolean isEntityUpdateable() { - return true; - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/model/TaskModel.java b/app/src/main/java/com/casic/common/detector/gd/model/TaskModel.java index 6e853ad..67ef5fb 100644 --- a/app/src/main/java/com/casic/common/detector/gd/model/TaskModel.java +++ b/app/src/main/java/com/casic/common/detector/gd/model/TaskModel.java @@ -24,7 +24,7 @@ } public static class MessageModel { - private int id; + private Long id; private String taskCode; private String description; private String deployDate; @@ -38,11 +38,11 @@ private int isValid; private List taskDetailInfos; - public int getId() { + public Long getId() { return id; } - public void setId(int id) { + public void setId(Long id) { this.id = id; } @@ -143,25 +143,25 @@ } public static class TaskDetailInfosModel { - private int id; + private long id; private String taskId; private String taskCode; private Object markerName; - private int markerId; + private String markerId; private String markerIdReal; private double longitude; private double latitude; private int isChecked; private int isNormal; - private Object imagePath; - private Object description; - private Object finishTime; + private String imagePath; + private String description; + private String finishTime; - public int getId() { + public long getId() { return id; } - public void setId(int id) { + public void setId(long id) { this.id = id; } @@ -189,11 +189,11 @@ this.markerName = markerName; } - public int getMarkerId() { + public String getMarkerId() { return markerId; } - public void setMarkerId(int markerId) { + public void setMarkerId(String markerId) { this.markerId = markerId; } @@ -237,27 +237,27 @@ this.isNormal = isNormal; } - public Object getImagePath() { + public String getImagePath() { return imagePath; } - public void setImagePath(Object imagePath) { + public void setImagePath(String imagePath) { this.imagePath = imagePath; } - public Object getDescription() { + public String getDescription() { return description; } - public void setDescription(Object description) { + public void setDescription(String description) { this.description = description; } - public Object getFinishTime() { + public String getFinishTime() { return finishTime; } - public void setFinishTime(Object finishTime) { + public void setFinishTime(String finishTime) { this.finishTime = finishTime; } } diff --git a/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitService.kt index 7522a87..0adad51 100644 --- a/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitService.kt @@ -50,7 +50,7 @@ */ @Multipart @POST("/ems/marker/save-marker-photo.do") - suspend fun installLabel( + suspend fun install( @PartMap jsonMarker: Map, @Part fileBuffer1: MultipartBody.Part?, @Part fileBuffer2: MultipartBody.Part?, diff --git a/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitServiceManager.kt index 5f6c701..ae2a0fa 100644 --- a/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitServiceManager.kt +++ b/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitServiceManager.kt @@ -37,22 +37,28 @@ /** * 获取标识器信息文件 */ - suspend fun getMarkerFile(userId: String, companyId: String): String { - return createApi().getMarkerFile(userId, companyId) + suspend fun getMarkerFile(): String { + val companyId = SaveKeyValues.getValue(LocaleConstant.USER_COMPANY_ID, "") as String + /** + * 后台设计如此,都传companyId + * */ + return createApi().getMarkerFile(companyId, companyId) } /** * 获取巡检工单 */ - suspend fun getTasksByUser(userName: String): String { + suspend fun getTasksByUser(): String { + val userName = SaveKeyValues.getValue(LocaleConstant.USER_NAME, "") as String return createApi().getTasksByUser(userName) } /** * 提交工单 */ - suspend fun uploadTask(userId: String, taskId: String?, state: String): String { + suspend fun uploadTask(taskId: String?, state: String): String { + val userId = SaveKeyValues.getValue(LocaleConstant.USER_ID, "") as String return createApi().uploadTask(userId, taskId.toString(), state) } @@ -60,8 +66,7 @@ * 安装新标识器 * Multipart上传图片,文件,带多参数上传 */ - suspend fun installLabel( - companyId: String, + suspend fun installMarker( recordType: String, markerObjectType: String, pipeMaterial: String, @@ -77,7 +82,6 @@ road: String, constructTime: String, ownerComp: String, - markerObjectId: String, markerId: String, markerType: String, markerDepth: String, @@ -89,6 +93,8 @@ memo: String, realPaths: ArrayList ): String { + val companyId = SaveKeyValues.getValue(LocaleConstant.USER_COMPANY_ID, "") as String + val objectId = SaveKeyValues.getValue(LocaleConstant.OBJECT_ID, "") as String val param = JsonObject() param.addProperty("companyId", companyId) param.addProperty("recordType", recordType) @@ -106,7 +112,7 @@ param.addProperty("road", road) param.addProperty("constructTime", constructTime) param.addProperty("ownerComp", ownerComp) - param.addProperty("markerObjectId", markerObjectId) + param.addProperty("markerObjectId", objectId) param.addProperty("markerId", markerId) param.addProperty("markerType", markerType) param.addProperty("markerDepth", markerDepth) @@ -133,19 +139,19 @@ return when (multiParts.size) { 3 -> { - createApi().installLabel(res, multiParts[0], multiParts[1], multiParts[2]) + createApi().install(res, multiParts[0], multiParts[1], multiParts[2]) } 2 -> { - createApi().installLabel(res, multiParts[0], multiParts[1], null) + createApi().install(res, multiParts[0], multiParts[1], null) } 1 -> { - createApi().installLabel(res, multiParts[0], null, null) + createApi().install(res, multiParts[0], null, null) } else -> { - createApi().installLabel(res, null, null, null) + createApi().install(res, null, null, null) } } } @@ -216,7 +222,7 @@ /** * 上传自由巡检过程中发现的标识器 */ - suspend fun uploadTaskMarker(taskId: String, ids: ArrayList): String { + suspend fun uploadTaskMarker(taskId: Long, ids: ArrayList): String { val param = JsonObject() param.addProperty("taskId", taskId) param.addProperty("ids", ids.joinToString(separator = ",")) diff --git a/app/src/main/java/com/casic/common/detector/gd/service/NtripConnectService.kt b/app/src/main/java/com/casic/common/detector/gd/service/NtripConnectService.kt index de9ac80..20e1a6a 100644 --- a/app/src/main/java/com/casic/common/detector/gd/service/NtripConnectService.kt +++ b/app/src/main/java/com/casic/common/detector/gd/service/NtripConnectService.kt @@ -9,10 +9,6 @@ import android.util.Log import android.view.Gravity import android.widget.Toast -import androidx.lifecycle.Lifecycle -import androidx.lifecycle.LifecycleOwner -import androidx.lifecycle.LifecycleRegistry -import androidx.lifecycle.lifecycleScope import com.casic.common.detector.gd.base.BaseApplication import com.casic.common.detector.gd.extensions.convertToGPGGA import com.casic.common.detector.gd.utils.LocaleConstant @@ -23,26 +19,24 @@ import com.pengxh.kt.lite.utils.WeakReferenceHandler import com.pengxh.kt.lite.utils.socket.tcp.OnTcpConnectStateListener import com.pengxh.kt.lite.utils.socket.tcp.TcpClient +import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.Job import kotlinx.coroutines.launch import java.io.OutputStream import java.nio.charset.StandardCharsets -class NtripConnectService : Service(), LifecycleOwner, OnTcpConnectStateListener, Handler.Callback { +class NtripConnectService : Service(), OnTcpConnectStateListener, Handler.Callback { companion object { var weakReferenceHandler: WeakReferenceHandler? = null } private val kTag = "NtripConnectService" - private val registry = LifecycleRegistry(this) private val socketClient by lazy { TcpClient(this) } private var outStream: OutputStream? = null - - override fun getLifecycle(): Lifecycle { - return registry - } + private val serviceScope = CoroutineScope(Dispatchers.Main + Job()) // 创建一个独立的CoroutineScope override fun onBind(intent: Intent?): IBinder? { return null @@ -117,7 +111,7 @@ * */ val result = String(this, StandardCharsets.UTF_8) if (result.contains("ICY 200 OK")) { - lifecycleScope.launch(Dispatchers.Main) { + serviceScope.launch { "高精度定位服务连接成功".show(this@NtripConnectService) } //连接服务即打开串口 @@ -135,12 +129,12 @@ * Content-Type: text/plain * Connection: clos * */ - lifecycleScope.launch(Dispatchers.Main) { + serviceScope.launch { "差分定位服务鉴权失败,无法解析位置".show(this@NtripConnectService) } } else { //居中显示 - lifecycleScope.launch(Dispatchers.Main) { + serviceScope.launch { val toast = Toast.makeText( this@NtripConnectService, "收到千寻数据,长度:${size}", Toast.LENGTH_SHORT ) @@ -167,7 +161,7 @@ return } - lifecycleScope.launch(Dispatchers.IO) { + serviceScope.launch(Dispatchers.IO) { socketClient.start(remoteHost, remotePort.toInt()) } } diff --git a/app/src/main/java/com/casic/common/detector/gd/utils/DataBaseManager.kt b/app/src/main/java/com/casic/common/detector/gd/utils/DataBaseManager.kt deleted file mode 100644 index aa22759..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/utils/DataBaseManager.kt +++ /dev/null @@ -1,200 +0,0 @@ -package com.casic.common.detector.gd.utils - -import com.casic.common.detector.gd.base.BaseApplication -import com.casic.common.detector.gd.bean.MarkerLocalBean -import com.casic.common.detector.gd.bean.TaskLocalBean -import com.casic.common.detector.gd.bean.TaskMarkerLocalBean -import com.casic.common.detector.gd.greendao.MarkerLocalBeanDao -import com.casic.common.detector.gd.greendao.TaskLocalBeanDao -import com.casic.common.detector.gd.greendao.TaskMarkerLocalBeanDao -import com.casic.common.detector.gd.model.TaskDetailLocalModel -import com.casic.common.detector.gd.model.TaskModel - -class DataBaseManager private constructor() { - companion object { - //Kotlin委托模式双重锁单例 - val get by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) { - DataBaseManager() - } - } - - private var taskLocalBeanDao = BaseApplication.get().getDaoSession().taskLocalBeanDao - private var taskMarkerLocalBeanDao = - BaseApplication.get().getDaoSession().taskMarkerLocalBeanDao - - fun saveTaskInLocale(task: TaskModel.MessageModel) { - val bean = TaskLocalBean() - bean.id = task.id.toLong() - bean.taskCode = task.taskCode - bean.description = task.description - bean.createTime = task.deployDate - bean.status = task.status - bean.createUserName = task.creatorName - if (task.beginDate == null) { - bean.startTime = "" - } - if (task.endDate == null) { - bean.endTime = "" - } - bean.isFreeTask = "0" - if (!bean.isExist()) { - taskLocalBeanDao.insert(bean) - } - } - - fun saveTaskInLocale(bean: TaskLocalBean) { - if (!bean.isExist()) { - taskLocalBeanDao.insert(bean) - } - } - - private fun TaskLocalBean.isExist(): Boolean { - val result = taskLocalBeanDao.queryBuilder().where( - TaskLocalBeanDao.Properties.Id.eq(this.id) - ).list() - return !result.isNullOrEmpty() - } - - fun saveTaskMarkerInLocale( - taskId: Int, taskCode: String, marker: TaskModel.MessageModel.TaskDetailInfosModel - ) { - val bean = TaskMarkerLocalBean() - bean.id = marker.id.toLong() - bean.taskId = taskId.toString() - bean.taskCode = taskCode - bean.markerId = marker.markerIdReal - bean.lng = marker.longitude - bean.lat = marker.latitude - bean.isDetected = "0" - bean.detectedTime = "" - if (!bean.isExist()) { - taskMarkerLocalBeanDao.insert(bean) - } - } - - private fun TaskMarkerLocalBean.isExist(): Boolean { - val result = taskMarkerLocalBeanDao.queryBuilder().where( - TaskMarkerLocalBeanDao.Properties.Id.eq(this.id) - ).list() - return !result.isNullOrEmpty() - } - - fun loadLocalTask(): ArrayList { - val result = ArrayList() - - val tasks = taskLocalBeanDao.loadAll() - tasks.forEach { - val model = TaskDetailLocalModel() - model.taskId = it.id.toString() - model.taskCode = it.taskCode - model.description = it.description - model.createTime = it.createTime - model.status = it.status - model.createUserName = it.createUserName - model.isFreeTask = it.isFreeTask - - val markers = ArrayList() - if (it.isFreeTask == "0") { - //非自由巡检才有Marker - val markerLocalBeans = taskMarkerLocalBeanDao.queryBuilder().where( - TaskMarkerLocalBeanDao.Properties.TaskId.eq(it.id), - TaskMarkerLocalBeanDao.Properties.TaskCode.eq(it.taskCode) - ).list() - markerLocalBeans.forEach { marker -> - val localModel = TaskDetailLocalModel.TaskMarkerLocalModel() - localModel.markerId = marker.markerId - localModel.lng = marker.lng - localModel.lat = marker.lat - localModel.isDetected = marker.isDetected - localModel.detectedTime = marker.detectedTime - - markers.add(localModel) - } - } - model.markerModels = markers - result.add(model) - } - return result - } - - fun deleteLocalTaskById(taskId: String, taskCode: String) { - val task = taskLocalBeanDao.queryBuilder().where( - TaskLocalBeanDao.Properties.Id.eq(taskId), - TaskLocalBeanDao.Properties.TaskCode.eq(taskCode) - ).list().firstOrNull() ?: return - taskLocalBeanDao.delete(task) - - //删除此任务关联的Marker。非自由巡检才有Marker - if (task.isFreeTask == "0") { - val markers = taskMarkerLocalBeanDao.queryBuilder() - .where( - TaskMarkerLocalBeanDao.Properties.TaskId.eq(taskId), - TaskMarkerLocalBeanDao.Properties.TaskCode.eq(taskCode) - ).list() - markers.forEach { - taskMarkerLocalBeanDao.delete(it) - } - } - } - - fun queryTaskMarkerById( - taskId: String, taskCode: String, markerId: String, state: String - ): TaskMarkerLocalBean? { - return taskMarkerLocalBeanDao.queryBuilder() - .where( - TaskMarkerLocalBeanDao.Properties.TaskId.eq(taskId), - TaskMarkerLocalBeanDao.Properties.TaskCode.eq(taskCode), - TaskMarkerLocalBeanDao.Properties.MarkerId.eq(markerId), - TaskMarkerLocalBeanDao.Properties.IsDetected.eq(state) - ).list().firstOrNull() - } - - fun updateLocalTaskMarkerState(marker: TaskMarkerLocalBean) { - marker.isDetected = "1" - taskMarkerLocalBeanDao.update(marker) - } - - fun queryMarkerByState(state: String): List { - return taskMarkerLocalBeanDao.queryBuilder() - .where(TaskMarkerLocalBeanDao.Properties.IsDetected.eq(state)) - .list() - } - - private var markerLocalBeanDao = BaseApplication.get().getDaoSession().markerLocalBeanDao - - fun clearMarkers() { - markerLocalBeanDao.deleteAll() - } - - fun saveMarkerInLocale(bean: MarkerLocalBean) { - markerLocalBeanDao.insert(bean) - } - - fun loadMarkers(): MutableList { - return markerLocalBeanDao.loadAll() - } - - fun loadMarkersByCondition(selectedItem: String, value: String?): MutableList { - val property = when (selectedItem) { - LocaleConstant.SPINNER_ARRAY[0] -> MarkerLocalBeanDao.Properties.MarkerId - LocaleConstant.SPINNER_ARRAY[1] -> MarkerLocalBeanDao.Properties.Area - LocaleConstant.SPINNER_ARRAY[2] -> MarkerLocalBeanDao.Properties.Line - LocaleConstant.SPINNER_ARRAY[3] -> MarkerLocalBeanDao.Properties.Road - LocaleConstant.SPINNER_ARRAY[4] -> MarkerLocalBeanDao.Properties.Owner - LocaleConstant.SPINNER_ARRAY[5] -> MarkerLocalBeanDao.Properties.InstallationDept - LocaleConstant.SPINNER_ARRAY[6] -> MarkerLocalBeanDao.Properties.UpdateTime - else -> MarkerLocalBeanDao.Properties.Remark - } - return if (value == null) { - markerLocalBeanDao.queryBuilder().where(property.isNotNull).list() - } else { - markerLocalBeanDao.queryBuilder().where(property.eq(value)).list() - } - } - - fun queryMarkerById(markerId: String): List { - return markerLocalBeanDao.queryBuilder() - .where(MarkerLocalBeanDao.Properties.MarkerId.eq(markerId)) - .list() - } -} \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index d0cb423..921c8c8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,25 +1,20 @@ import java.text.SimpleDateFormat -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply plugin: 'org.greenrobot.greendao' +plugins { + id('com.android.application') + id('org.jetbrains.kotlin.android') +} android { - compileSdkVersion 33 + namespace 'com.casic.common.detector.gd' + compileSdk 35 defaultConfig { - applicationId "com.casic.common.detector.gd" - minSdkVersion 26 - targetSdkVersion 33 + applicationId 'com.casic.common.detector.gd' + minSdk 26 + targetSdk 35 versionCode 5092 - versionName "5.0.9.2" - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } + versionName '5.0.9.2' } signingConfigs { @@ -31,6 +26,14 @@ } } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + signingConfig signingConfigs.release + } + } + compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 @@ -47,27 +50,16 @@ } } - kotlin { - experimental { - coroutines 'enable' - } - } - buildFeatures { + buildConfig true viewBinding true } - applicationVariants.configureEach { variant -> - variant.outputs.configureEach { - outputFileName = "COM_TCY_" + getBuildDate() + "_" + defaultConfig.versionName + ".apk" + applicationVariants.configureEach { + outputs.configureEach { + outputFileName = 'COM_TCY_' + getBuildDate() + '_' + defaultConfig.versionName + '.apk' } } - - greendao { - schemaVersion 1//数据库版本号 - targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 - daoPackage "${defaultConfig.applicationId}.greendao"//设置DaoMaster、DaoSession、Dao包名 - } } static def getBuildDate() { @@ -76,27 +68,22 @@ } dependencies { - //基础依赖库 - implementation 'com.github.AndroidCoderPeng:Kotlin-lite-lib:1.1.4' - implementation 'androidx.core:core-ktx:1.9.0' - def base_version = "1.6.1" - implementation "androidx.appcompat:appcompat:${base_version}" - implementation "com.google.android.material:material:${base_version}" + implementation 'com.github.AndroidCoderPeng:Kotlin-lite-lib:1.1.5' + implementation 'androidx.core:core-ktx:1.13.1' + implementation 'androidx.appcompat:appcompat:1.7.0' + implementation 'com.google.android.material:material:1.12.0' //Google官方授权框架 implementation 'pub.devrel:easypermissions:3.0.0' - //沉浸式状态栏。基础依赖包,必须要依赖 - implementation 'com.gyf.immersionbar:immersionbar:3.0.0' - //fragment快速实现 - implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0' + //沉浸式状态栏 + implementation 'com.geyifeng.immersionbar:immersionbar:3.2.2' //官方Json解析库 implementation 'com.google.code.gson:gson:2.10.1' - def vm_version = '2.5.1' //Kotlin协程 - implementation "androidx.lifecycle:lifecycle-runtime-ktx:${vm_version}" + implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.2' //MVVM+LiveData - implementation "androidx.lifecycle:lifecycle-livedata-ktx:${vm_version}" - implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:${vm_version}" - implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.6.2' + implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2' + implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' //返回值转换器 implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' @@ -105,9 +92,10 @@ implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' //网络请求和接口封装 implementation 'com.squareup.retrofit2:retrofit:2.9.0' - implementation 'com.squareup.okhttp3:okhttp:4.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.12.0' //数据库框架 - implementation 'org.greenrobot:greendao:3.3.0' + implementation 'androidx.room:room-runtime:2.6.1' + annotationProcessor 'androidx.room:room-compiler:2.5.2' //高德导航、定位、地图三合一 implementation 'com.amap.api:navi-3dmap:latest.integration' //经纬度逆编码 @@ -115,7 +103,7 @@ //excel implementation 'net.sourceforge.jexcelapi:jxl:2.6.12' //图片加载框架 - implementation 'com.github.bumptech.glide:glide:4.9.0' + implementation 'com.github.bumptech.glide:glide:4.12.0' //图片选择框架 implementation 'io.github.lucksiege:pictureselector:v3.11.1' //大图 diff --git a/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt b/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt index 7b695ff..50ba734 100644 --- a/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt +++ b/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt @@ -4,9 +4,9 @@ import android.app.Application import android.os.Bundle import android.util.Log -import com.casic.common.detector.gd.greendao.DaoMaster -import com.casic.common.detector.gd.greendao.DaoSession +import androidx.room.Room.databaseBuilder import com.casic.common.detector.gd.uart.SerialPort +import com.casic.common.detector.gd.utils.DetectorDataBase import com.casic.common.detector.gd.utils.GpioManager import com.pengxh.kt.lite.extensions.show import com.pengxh.kt.lite.utils.SaveKeyValues @@ -43,44 +43,42 @@ private var application: BaseApplication by Delegates.notNull() fun get() = application - - private lateinit var daoSession: DaoSession } + lateinit var dataBase: DetectorDataBase + override fun onCreate() { super.onCreate() application = this SaveKeyValues.initSharedPreferences(this) CrashReport.initCrashReport(this, "01e80d3a74", true) - val devOpenHelper = DaoMaster.DevOpenHelper(this, "Detector.db", null) - val daoMaster = DaoMaster(devOpenHelper.writableDatabase) - daoSession = daoMaster.newSession() + dataBase = databaseBuilder(this, DetectorDataBase::class.java, "Detector.db") + .allowMainThreadQueries() + .build() /** * Open the serial port * */ try { serialPorts.apply { - add(SerialPort(File("/dev/ttysWK1"), 9600, 0)) - //千寻报文数据下发串口号 - add(SerialPort(File("/dev/ttyS1"), 9600, 0)) + add(SerialPort(File("/dev/ttysWK1"), 9600, 0)) //信号通讯串口 + add(SerialPort(File("/dev/ttyS1"), 9600, 0)) //千寻报文数据下发串口号 } Log.d(kTag, "onCreate: 已初始化 ${serialPorts.size} 个串口") } catch (e: SecurityException) { "您没有串口的读写权限!".show(this) + e.printStackTrace() } catch (e: IOException) { "因为不明原因,串口无法打开!".show(this) + e.printStackTrace() } catch (e: InvalidParameterException) { "请检查串口!".show(this) + e.printStackTrace() } registerActivityLifecycleCallbacks(this) } - fun getDaoSession(): DaoSession { - return daoSession - } - override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) { } diff --git a/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt b/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt index 053b9dd..1d0c9e3 100644 --- a/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt +++ b/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt @@ -14,12 +14,10 @@ import com.casic.common.detector.gd.utils.SerialPortCommand import com.pengxh.kt.lite.utils.WeakReferenceHandler import java.io.IOException -import java.util.Timer abstract class SerialPortBaseActivity : AppCompatActivity(), Handler.Callback { private val kTag = "SerialPortBaseActivity" - private val taskTimer by lazy { Timer() } private val weakReferenceHandler by lazy { WeakReferenceHandler(this) } private val serialPorts by lazy { BaseApplication.get().getSerialPorts() } protected lateinit var binding: VB @@ -30,7 +28,6 @@ setContentView(binding.root) setupTopBarLayout() initOnCreate(savedInstanceState) - observeRequestState() initEvent() if (serialPorts.isNotEmpty()) { @@ -71,11 +68,6 @@ abstract fun initOnCreate(savedInstanceState: Bundle?) /** - * 数据请求状态监听 - */ - abstract fun observeRequestState() - - /** * 初始化业务逻辑 */ abstract fun initEvent() diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java new file mode 100644 index 0000000..7a18c20 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java @@ -0,0 +1,255 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 从平台下载的标识器本地库实体类 + */ +@Entity(tableName = "marker_detail") +public class MarkerBean { + @PrimaryKey(autoGenerate = true) + private long id; //主键ID + private String pipelineType; // 管线类型 + private String pipelineDiameter; // 管线直径 + private String pipelineMaterial; // 管材 + private String buryMethod; // 埋设方式 + private String buryDepth; // 埋深 + private String area; // 所属区域 + private String line; // 所属线路 + private String road; // 所属道路 + private String constructTime; // 建设年代 + private String owner; // 权属单位 + private String objectId; // 标识对象ID,无实际用途 + private String markerId; // 标识器ID + private String markerType; // 标识器类型 + private String markerDepth; // 标识器埋深 + private String installationDept; // 安装部门 + private String lng; // 经度 + private String lat; // 纬度 + private String updateTime; // 最后修改时间,更新时间 + private String remark; // 备注信息 + private String underlyingPipelineType; // 下层管线类型 + private String underlyingPipelineDepth; // 下层埋深 + private String underlyingPipelineDiameter; // 下层管径 + private String underlyingPipelineMaterial; // 下层管材 + private String objectType; //标识对象类型 + private String color; // 颜色 + private String imagePath; // 图片路径 + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getPipelineType() { + return pipelineType; + } + + public void setPipelineType(String pipelineType) { + this.pipelineType = pipelineType; + } + + public String getPipelineDiameter() { + return pipelineDiameter; + } + + public void setPipelineDiameter(String pipelineDiameter) { + this.pipelineDiameter = pipelineDiameter; + } + + public String getPipelineMaterial() { + return pipelineMaterial; + } + + public void setPipelineMaterial(String pipelineMaterial) { + this.pipelineMaterial = pipelineMaterial; + } + + public String getBuryMethod() { + return buryMethod; + } + + public void setBuryMethod(String buryMethod) { + this.buryMethod = buryMethod; + } + + public String getBuryDepth() { + return buryDepth; + } + + public void setBuryDepth(String buryDepth) { + this.buryDepth = buryDepth; + } + + public String getArea() { + return area; + } + + public void setArea(String area) { + this.area = area; + } + + public String getLine() { + return line; + } + + public void setLine(String line) { + this.line = line; + } + + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + + public String getConstructTime() { + return constructTime; + } + + public void setConstructTime(String constructTime) { + this.constructTime = constructTime; + } + + public String getOwner() { + return owner; + } + + public void setOwner(String owner) { + this.owner = owner; + } + + public String getObjectId() { + return objectId; + } + + public void setObjectId(String objectId) { + this.objectId = objectId; + } + + public String getMarkerId() { + return markerId; + } + + public void setMarkerId(String markerId) { + this.markerId = markerId; + } + + public String getMarkerType() { + return markerType; + } + + public void setMarkerType(String markerType) { + this.markerType = markerType; + } + + public String getMarkerDepth() { + return markerDepth; + } + + public void setMarkerDepth(String markerDepth) { + this.markerDepth = markerDepth; + } + + public String getInstallationDept() { + return installationDept; + } + + public void setInstallationDept(String installationDept) { + this.installationDept = installationDept; + } + + public String getLng() { + return lng; + } + + public void setLng(String lng) { + this.lng = lng; + } + + public String getLat() { + return lat; + } + + public void setLat(String lat) { + this.lat = lat; + } + + public String getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } + + public String getUnderlyingPipelineType() { + return underlyingPipelineType; + } + + public void setUnderlyingPipelineType(String underlyingPipelineType) { + this.underlyingPipelineType = underlyingPipelineType; + } + + public String getUnderlyingPipelineDepth() { + return underlyingPipelineDepth; + } + + public void setUnderlyingPipelineDepth(String underlyingPipelineDepth) { + this.underlyingPipelineDepth = underlyingPipelineDepth; + } + + public String getUnderlyingPipelineDiameter() { + return underlyingPipelineDiameter; + } + + public void setUnderlyingPipelineDiameter(String underlyingPipelineDiameter) { + this.underlyingPipelineDiameter = underlyingPipelineDiameter; + } + + public String getUnderlyingPipelineMaterial() { + return underlyingPipelineMaterial; + } + + public void setUnderlyingPipelineMaterial(String underlyingPipelineMaterial) { + this.underlyingPipelineMaterial = underlyingPipelineMaterial; + } + + public String getObjectType() { + return objectType; + } + + public void setObjectType(String objectType) { + this.objectType = objectType; + } + + public String getColor() { + return color; + } + + public void setColor(String color) { + this.color = color; + } + + public String getImagePath() { + return imagePath; + } + + public void setImagePath(String imagePath) { + this.imagePath = imagePath; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java deleted file mode 100644 index 3f2fcdc..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java +++ /dev/null @@ -1,327 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 从平台下载的标识器本地库实体类 - */ -@Entity -public class MarkerLocalBean { - @Id(autoincrement = true) - private Long id;//本地库主键ID - - // 管线类型 - private String pipelineType; - // 管线直径 - private String pipelineDiameter; - // 管材 - private String pipelineMaterial; - // 埋设方式 - private String buryMethod; - // 埋深 - private String buryDepth; - // 所属区域 - private String area; - // 所属线路 - private String line; - // 所属道路 - private String road; - // 建设年代 - private String constructTime; - // 权属单位 - private String owner; - //标识对象ID,无实际用途 - @Deprecated - private String objectId; - // 标识器ID - private String markerId; - // 标识器类型 - private String markerType; - // 标识器埋深 - private String markerDepth; - // 安装部门 - private String installationDept; - // 经度 - private String lng; - // 纬度 - private String lat; - //最后修改时间,更新时间 - private String updateTime; - // 备注信息 - private String remark; - // 下层管线类型 - private String underlyingPipelineType; - // 下层埋深 - private String underlyingPipelineDepth; - // 下层管径 - private String underlyingPipelineDiameter; - // 下层管材 - private String underlyingPipelineMaterial; - //标识对象类型 - private String objectType; - // 颜色 - private String color; - // 图片路径 - private String imagePath; - - @Generated(hash = 1479045776) - public MarkerLocalBean(Long id, String pipelineType, String pipelineDiameter, - String pipelineMaterial, String buryMethod, String buryDepth, - String area, String line, String road, String constructTime, - String owner, String objectId, String markerId, String markerType, - String markerDepth, String installationDept, String lng, String lat, - String updateTime, String remark, String underlyingPipelineType, - String underlyingPipelineDepth, String underlyingPipelineDiameter, - String underlyingPipelineMaterial, String objectType, String color, - String imagePath) { - this.id = id; - this.pipelineType = pipelineType; - this.pipelineDiameter = pipelineDiameter; - this.pipelineMaterial = pipelineMaterial; - this.buryMethod = buryMethod; - this.buryDepth = buryDepth; - this.area = area; - this.line = line; - this.road = road; - this.constructTime = constructTime; - this.owner = owner; - this.objectId = objectId; - this.markerId = markerId; - this.markerType = markerType; - this.markerDepth = markerDepth; - this.installationDept = installationDept; - this.lng = lng; - this.lat = lat; - this.updateTime = updateTime; - this.remark = remark; - this.underlyingPipelineType = underlyingPipelineType; - this.underlyingPipelineDepth = underlyingPipelineDepth; - this.underlyingPipelineDiameter = underlyingPipelineDiameter; - this.underlyingPipelineMaterial = underlyingPipelineMaterial; - this.objectType = objectType; - this.color = color; - this.imagePath = imagePath; - } - - @Generated(hash = 1538606012) - public MarkerLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getPipelineType() { - return this.pipelineType; - } - - public void setPipelineType(String pipelineType) { - this.pipelineType = pipelineType; - } - - public String getPipelineDiameter() { - return this.pipelineDiameter; - } - - public void setPipelineDiameter(String pipelineDiameter) { - this.pipelineDiameter = pipelineDiameter; - } - - public String getPipelineMaterial() { - return this.pipelineMaterial; - } - - public void setPipelineMaterial(String pipelineMaterial) { - this.pipelineMaterial = pipelineMaterial; - } - - public String getBuryMethod() { - return this.buryMethod; - } - - public void setBuryMethod(String buryMethod) { - this.buryMethod = buryMethod; - } - - public String getBuryDepth() { - return this.buryDepth; - } - - public void setBuryDepth(String buryDepth) { - this.buryDepth = buryDepth; - } - - public String getArea() { - return this.area; - } - - public void setArea(String area) { - this.area = area; - } - - public String getLine() { - return this.line; - } - - public void setLine(String line) { - this.line = line; - } - - public String getRoad() { - return this.road; - } - - public void setRoad(String road) { - this.road = road; - } - - public String getConstructTime() { - return this.constructTime; - } - - public void setConstructTime(String constructTime) { - this.constructTime = constructTime; - } - - public String getOwner() { - return this.owner; - } - - public void setOwner(String owner) { - this.owner = owner; - } - - public String getObjectId() { - return this.objectId; - } - - public void setObjectId(String objectId) { - this.objectId = objectId; - } - - public String getMarkerId() { - return this.markerId; - } - - public void setMarkerId(String markerId) { - this.markerId = markerId; - } - - public String getMarkerType() { - return this.markerType; - } - - public void setMarkerType(String markerType) { - this.markerType = markerType; - } - - public String getMarkerDepth() { - return this.markerDepth; - } - - public void setMarkerDepth(String markerDepth) { - this.markerDepth = markerDepth; - } - - public String getInstallationDept() { - return this.installationDept; - } - - public void setInstallationDept(String installationDept) { - this.installationDept = installationDept; - } - - public String getLng() { - return this.lng; - } - - public void setLng(String lng) { - this.lng = lng; - } - - public String getLat() { - return this.lat; - } - - public void setLat(String lat) { - this.lat = lat; - } - - public String getUpdateTime() { - return this.updateTime; - } - - public void setUpdateTime(String updateTime) { - this.updateTime = updateTime; - } - - public String getRemark() { - return this.remark; - } - - public void setRemark(String remark) { - this.remark = remark; - } - - public String getUnderlyingPipelineType() { - return this.underlyingPipelineType; - } - - public void setUnderlyingPipelineType(String underlyingPipelineType) { - this.underlyingPipelineType = underlyingPipelineType; - } - - public String getUnderlyingPipelineDepth() { - return this.underlyingPipelineDepth; - } - - public void setUnderlyingPipelineDepth(String underlyingPipelineDepth) { - this.underlyingPipelineDepth = underlyingPipelineDepth; - } - - public String getUnderlyingPipelineDiameter() { - return this.underlyingPipelineDiameter; - } - - public void setUnderlyingPipelineDiameter(String underlyingPipelineDiameter) { - this.underlyingPipelineDiameter = underlyingPipelineDiameter; - } - - public String getUnderlyingPipelineMaterial() { - return this.underlyingPipelineMaterial; - } - - public void setUnderlyingPipelineMaterial(String underlyingPipelineMaterial) { - this.underlyingPipelineMaterial = underlyingPipelineMaterial; - } - - public String getObjectType() { - return this.objectType; - } - - public void setObjectType(String objectType) { - this.objectType = objectType; - } - - public String getColor() { - return this.color; - } - - public void setColor(String color) { - this.color = color; - } - - public String getImagePath() { - return this.imagePath; - } - - public void setImagePath(String imagePath) { - this.imagePath = imagePath; - } -} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java new file mode 100644 index 0000000..5c88fdf --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java @@ -0,0 +1,93 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 巡检任务本地库实体类,不包含任务里面需要巡检的标识器信息 + */ +@Entity(tableName = "task_detail") +public class TaskBean { + @PrimaryKey(autoGenerate = true) + private long id;//主键ID + private String taskCode; // 任务编号 + private String description; // 任务名称 + private String createTime; // 任务创建的时间 + private String status; // 任务状态 + private String createUserName; // 任务创建者名称 + private String startTime; // 任务被开始执行的时间 + private String endTime; // 任务执行结束的时间 + private String isFree; // 是否自由巡检。1-是,0-否 + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getTaskCode() { + return taskCode; + } + + public void setTaskCode(String taskCode) { + this.taskCode = taskCode; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getCreateUserName() { + return createUserName; + } + + public void setCreateUserName(String createUserName) { + this.createUserName = createUserName; + } + + public String getStartTime() { + return startTime; + } + + public void setStartTime(String startTime) { + this.startTime = startTime; + } + + public String getEndTime() { + return endTime; + } + + public void setEndTime(String endTime) { + this.endTime = endTime; + } + + public String getIsFree() { + return isFree; + } + + public void setIsFree(String isFree) { + this.isFree = isFree; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java deleted file mode 100644 index 91737b3..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java +++ /dev/null @@ -1,114 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 巡检任务本地库实体类,不包含任务里面需要巡检的标识器信息 - */ -@Entity -public class TaskLocalBean { - @Id - private Long id;//任务ID - - private String taskCode;//任务编号 - private String description;//任务名称 - private String createTime;//任务创建的时间 - private String status;//任务状态 - private String createUserName;//任务创建者名称 - private String startTime;//任务被开始执行的时间 - private String endTime;//任务执行结束的时间 - private String isFreeTask;//是否自由巡检。1-是,0-否 - - @Generated(hash = 1482022528) - public TaskLocalBean(Long id, String taskCode, String description, - String createTime, String status, String createUserName, - String startTime, String endTime, String isFreeTask) { - this.id = id; - this.taskCode = taskCode; - this.description = description; - this.createTime = createTime; - this.status = status; - this.createUserName = createUserName; - this.startTime = startTime; - this.endTime = endTime; - this.isFreeTask = isFreeTask; - } - - @Generated(hash = 949704588) - public TaskLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getTaskCode() { - return this.taskCode; - } - - public void setTaskCode(String taskCode) { - this.taskCode = taskCode; - } - - public String getDescription() { - return this.description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getCreateTime() { - return this.createTime; - } - - public void setCreateTime(String createTime) { - this.createTime = createTime; - } - - public String getStatus() { - return this.status; - } - - public void setStatus(String status) { - this.status = status; - } - - public String getCreateUserName() { - return this.createUserName; - } - - public void setCreateUserName(String createUserName) { - this.createUserName = createUserName; - } - - public String getStartTime() { - return this.startTime; - } - - public void setStartTime(String startTime) { - this.startTime = startTime; - } - - public String getEndTime() { - return this.endTime; - } - - public void setEndTime(String endTime) { - this.endTime = endTime; - } - - public String getIsFreeTask() { - return this.isFreeTask; - } - - public void setIsFreeTask(String isFreeTask) { - this.isFreeTask = isFreeTask; - } -} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerBean.java new file mode 100644 index 0000000..c563a60 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerBean.java @@ -0,0 +1,110 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 巡检任务里面需要巡检的标识器信息本地库实体类 + */ +@Entity(tableName = "task_marker_info") +public class TaskMarkerBean { + //标识器后台库的主键ID,不是标识器实际ID + @PrimaryKey(autoGenerate = true) + private long id; + + /** + * 任务ID,通过此字段关联[TaskBean.id] + */ + private String taskId; + + /** + * 任务Code,通过此字段关联[TaskBean.taskCode] + *

+ *

+ * 双重验证,防止出现同时刻重复的情况 + */ + private String taskCode; + + /** + * 对应后台字段[TaskModel.MessageModel.TaskDetailInfosModel.markerIdReal],也就是探测仪扫描出来的ID + */ + private String markerId; + + private Double lng; + private Double lat; + + /** + * 是否已被探测到 + * 1-是,0-否 + */ + private String isDetected; + + /** + * 被探测到的时间,对应后台字段[TaskModel.MessageModel.TaskDetailInfosModel.finishTime] + */ + private String detectedTime; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getTaskId() { + return taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getTaskCode() { + return taskCode; + } + + public void setTaskCode(String taskCode) { + this.taskCode = taskCode; + } + + public String getMarkerId() { + return markerId; + } + + public void setMarkerId(String markerId) { + this.markerId = markerId; + } + + public Double getLng() { + return lng; + } + + public void setLng(Double lng) { + this.lng = lng; + } + + public Double getLat() { + return lat; + } + + public void setLat(Double lat) { + this.lat = lat; + } + + public String getIsDetected() { + return isDetected; + } + + public void setIsDetected(String isDetected) { + this.isDetected = isDetected; + } + + public String getDetectedTime() { + return detectedTime; + } + + public void setDetectedTime(String detectedTime) { + this.detectedTime = detectedTime; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerLocalBean.java deleted file mode 100644 index de9f459..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerLocalBean.java +++ /dev/null @@ -1,128 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import com.casic.common.detector.gd.model.TaskModel; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 巡检任务里面需要巡检的标识器信息本地库实体类 - */ -@Entity -public class TaskMarkerLocalBean { - @Id - private Long id;//标识器后台库的主键ID,不是标识器实际ID - - /** - * 任务ID,通过此字段关联{@link TaskLocalBean#id} - */ - private String taskId; - - /** - * 任务Code,通过此字段关联{@link TaskLocalBean#taskCode} - *

- * 双重验证,防止出现同时刻重复的情况 - */ - private String taskCode; - - /** - * 对应后台字段{@link TaskModel.MessageModel.TaskDetailInfosModel#markerIdReal},也就是探测仪扫描出来的ID - */ - private String markerId; - - private double lng; - private double lat; - - /** - * 是否已被探测到 - * 1-是,0-否 - */ - private String isDetected; - - /** - * 被探测到的时间,对应后台字段{@link TaskModel.MessageModel.TaskDetailInfosModel#finishTime} - */ - private String detectedTime; - - @Generated(hash = 677328533) - public TaskMarkerLocalBean(Long id, String taskId, String taskCode, String markerId, - double lng, double lat, String isDetected, String detectedTime) { - this.id = id; - this.taskId = taskId; - this.taskCode = taskCode; - this.markerId = markerId; - this.lng = lng; - this.lat = lat; - this.isDetected = isDetected; - this.detectedTime = detectedTime; - } - - @Generated(hash = 1162404642) - public TaskMarkerLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getTaskId() { - return this.taskId; - } - - public void setTaskId(String taskId) { - this.taskId = taskId; - } - - public String getTaskCode() { - return this.taskCode; - } - - public void setTaskCode(String taskCode) { - this.taskCode = taskCode; - } - - public String getMarkerId() { - return this.markerId; - } - - public void setMarkerId(String markerId) { - this.markerId = markerId; - } - - public double getLng() { - return this.lng; - } - - public void setLng(double lng) { - this.lng = lng; - } - - public double getLat() { - return this.lat; - } - - public void setLat(double lat) { - this.lat = lat; - } - - public String getIsDetected() { - return this.isDetected; - } - - public void setIsDetected(String isDetected) { - this.isDetected = isDetected; - } - - public String getDetectedTime() { - return this.detectedTime; - } - - public void setDetectedTime(String detectedTime) { - this.detectedTime = detectedTime; - } -} diff --git a/app/src/main/java/com/casic/common/detector/gd/dao/MarkerBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/dao/MarkerBeanDao.java new file mode 100644 index 0000000..2beb7ed --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/dao/MarkerBeanDao.java @@ -0,0 +1,29 @@ +package com.casic.common.detector.gd.dao; + +import androidx.room.Dao; +import androidx.room.Insert; +import androidx.room.Query; +import androidx.room.RawQuery; +import androidx.sqlite.db.SupportSQLiteQuery; + +import com.casic.common.detector.gd.bean.MarkerBean; + +import java.util.List; + +@Dao +public interface MarkerBeanDao { + @Query("DELETE FROM marker_detail") + void deleteAll(); + + @Insert + void insert(MarkerBean marker); + + @Query("SELECT * FROM marker_detail") + List loadAll(); + + @Query("SELECT * FROM marker_detail WHERE markerId = :markerId") + List queryMarkerById(String markerId); + + @RawQuery + List loadMarkersByCondition(SupportSQLiteQuery query); +} diff --git a/app/src/main/java/com/casic/common/detector/gd/dao/TaskBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/dao/TaskBeanDao.java new file mode 100644 index 0000000..9c70ac2 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/dao/TaskBeanDao.java @@ -0,0 +1,120 @@ +package com.casic.common.detector.gd.dao; + +import androidx.room.Dao; +import androidx.room.Insert; +import androidx.room.Query; +import androidx.room.Transaction; + +import com.casic.common.detector.gd.bean.TaskBean; +import com.casic.common.detector.gd.bean.TaskMarkerBean; +import com.casic.common.detector.gd.model.TaskDetailLocalModel; +import com.casic.common.detector.gd.model.TaskModel; +import com.casic.common.detector.gd.utils.LocaleConstant; +import com.pengxh.kt.lite.utils.SaveKeyValues; + +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Locale; + +@Dao +public interface TaskBeanDao { + @Query("SELECT COUNT(*) FROM task_detail WHERE id = :taskId") + int isTaskExist(long taskId); + + @Insert + void insert(TaskBean task); + + default void saveTask(Long taskId, String taskName) { + if (isTaskExist(taskId) == 0) { + TaskBean task = new TaskBean(); + task.setId(taskId); + task.setTaskCode(new SimpleDateFormat("yyyyMMddHHmmss", Locale.CHINA).format(new Date())); + task.setDescription(taskName); + String time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA).format(new Date()); + task.setCreateTime(time); + task.setStatus("0"); + String userName = (String) SaveKeyValues.INSTANCE.getValue(LocaleConstant.USER_NAME, ""); + task.setCreateUserName(userName); + task.setStartTime(time); + task.setEndTime(""); + task.setIsFree("1"); + insert(task); + } + } + + default void saveTask(TaskModel.MessageModel model) { + TaskBean task = new TaskBean(); + task.setId(model.getId()); + task.setTaskCode(model.getTaskCode()); + task.setDescription(model.getDescription()); + task.setCreateTime(model.getDeployDate()); + task.setStatus(model.getStatus()); + task.setCreateUserName(model.getCreatorName()); + task.setStartTime(model.getBeginDate()); + task.setEndTime(model.getEndDate()); + task.setIsFree("0"); + if (isTaskExist(task.getId()) == 0) { + insert(task); + } + } + + @Query("SELECT * FROM task_detail") + List loadAll(); + + @Transaction + default ArrayList loadLocalTask(TaskMarkerBeanDao taskMarkerBeanDao) { + ArrayList result = new ArrayList<>(); + List tasks = loadAll(); + for (TaskBean it : tasks) { + TaskDetailLocalModel model = new TaskDetailLocalModel(); + model.setTaskId(String.valueOf(it.getId())); + model.setTaskCode(it.getTaskCode()); + model.setDescription(it.getDescription()); + model.setCreateTime(it.getCreateTime()); + model.setStatus(it.getStatus()); + model.setCreateUserName(it.getCreateUserName()); + model.setIsFreeTask(it.getIsFree()); + ArrayList results = new ArrayList<>(); + if ("0".equals(it.getIsFree())) { + // 非自由巡检才有Marker + List markers = taskMarkerBeanDao.getMarkersByIdAndCode(String.valueOf(it.getId()), it.getTaskCode()); + for (TaskMarkerBean marker : markers) { + TaskDetailLocalModel.TaskMarkerLocalModel localModel = new TaskDetailLocalModel.TaskMarkerLocalModel(); + localModel.setMarkerId(marker.getMarkerId()); + localModel.setLng(marker.getLng()); + localModel.setLat(marker.getLat()); + localModel.setIsDetected(marker.getIsDetected()); + localModel.setDetectedTime(marker.getDetectedTime()); + + results.add(localModel); + } + } + model.setMarkerModels(results); + result.add(model); + } + return result; + } + + @Query("DELETE FROM task_detail WHERE id = :taskId AND taskCode = :taskCode") + void deleteTaskById(long taskId, String taskCode); + + @Transaction + default void deleteLocalTaskById(long taskId, String taskCode, TaskMarkerBeanDao taskMarkerBeanDao) { + TaskBean task = loadAll().stream() + .filter(it -> it.getId() == taskId && taskCode.equals(it.getTaskCode())) + .findFirst() + .orElse(null); + if (task == null) return; + deleteTaskById(taskId, taskCode); + + // 删除此任务关联的Marker。非自由巡检才有Marker + if ("0".equals(task.getIsFree())) { + List markers = taskMarkerBeanDao.getMarkersByIdAndCode(String.valueOf(task.getId()), task.getTaskCode()); + for (TaskMarkerBean marker : markers) { + taskMarkerBeanDao.delete(marker); + } + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/dao/TaskMarkerBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/dao/TaskMarkerBeanDao.java new file mode 100644 index 0000000..cc2156a --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/dao/TaskMarkerBeanDao.java @@ -0,0 +1,52 @@ +package com.casic.common.detector.gd.dao; + +import androidx.room.Dao; +import androidx.room.Delete; +import androidx.room.Insert; +import androidx.room.Query; +import androidx.room.Update; + +import com.casic.common.detector.gd.bean.TaskMarkerBean; +import com.casic.common.detector.gd.model.TaskModel; + +import java.util.List; + +@Dao +public interface TaskMarkerBeanDao { + + @Insert + void insert(TaskMarkerBean marker); + + @Query("SELECT COUNT(*) FROM task_marker_info WHERE id = :markerId") + int isMarkerExist(String markerId); + + default void saveTaskMarker(long taskId, String taskCode, TaskModel.MessageModel.TaskDetailInfosModel marker) { + if (isMarkerExist(marker.getMarkerId()) == 0) { + TaskMarkerBean bean = new TaskMarkerBean(); + bean.setId(marker.getId()); + bean.setTaskId(String.valueOf(taskId)); + bean.setTaskCode(taskCode); + bean.setMarkerId(marker.getMarkerIdReal()); + bean.setLng(marker.getLongitude()); + bean.setLat(marker.getLatitude()); + bean.setIsDetected("0"); + bean.setDetectedTime(""); + insert(bean); + } + } + + @Query("SELECT * FROM task_marker_info WHERE taskId = :taskId AND taskCode = :taskCode AND markerId = :markerId AND isDetected = :state") + TaskMarkerBean queryTaskMarkerById(String taskId, String taskCode, String markerId, String state); + + @Update + void updateLocalTaskMarkerState(TaskMarkerBean marker); + + @Query("SELECT * FROM task_marker_info WHERE isDetected = :state") + List queryMarkerByState(String state); + + @Query("SELECT * FROM task_marker_info WHERE taskId = :taskId AND taskCode = :taskCode") + List getMarkersByIdAndCode(String taskId, String taskCode); + + @Delete + void delete(TaskMarkerBean marker); +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/extensions/Long.kt b/app/src/main/java/com/casic/common/detector/gd/extensions/Long.kt deleted file mode 100644 index 6713d8d..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/extensions/Long.kt +++ /dev/null @@ -1,10 +0,0 @@ -package com.casic.common.detector.gd.extensions - -import java.text.SimpleDateFormat -import java.util.Date -import java.util.Locale - -fun Long.createTaskCode(): String { - val dateFormat = SimpleDateFormat("yyyyMMddHHmmss", Locale.CHINA) - return dateFormat.format(Date(this)) -} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoMaster.java b/app/src/main/java/com/casic/common/detector/gd/greendao/DaoMaster.java deleted file mode 100644 index 6ab94b3..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoMaster.java +++ /dev/null @@ -1,102 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import android.content.Context; -import android.database.sqlite.SQLiteDatabase; -import android.database.sqlite.SQLiteDatabase.CursorFactory; -import android.util.Log; - -import org.greenrobot.greendao.AbstractDaoMaster; -import org.greenrobot.greendao.database.StandardDatabase; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.database.DatabaseOpenHelper; -import org.greenrobot.greendao.identityscope.IdentityScopeType; - - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** - * Master of DAO (schema version 1): knows all DAOs. - */ -public class DaoMaster extends AbstractDaoMaster { - public static final int SCHEMA_VERSION = 1; - - /** Creates underlying database table using DAOs. */ - public static void createAllTables(Database db, boolean ifNotExists) { - MarkerLocalBeanDao.createTable(db, ifNotExists); - TaskLocalBeanDao.createTable(db, ifNotExists); - TaskMarkerLocalBeanDao.createTable(db, ifNotExists); - } - - /** Drops underlying database table using DAOs. */ - public static void dropAllTables(Database db, boolean ifExists) { - MarkerLocalBeanDao.dropTable(db, ifExists); - TaskLocalBeanDao.dropTable(db, ifExists); - TaskMarkerLocalBeanDao.dropTable(db, ifExists); - } - - /** - * WARNING: Drops all table on Upgrade! Use only during development. - * Convenience method using a {@link DevOpenHelper}. - */ - public static DaoSession newDevSession(Context context, String name) { - Database db = new DevOpenHelper(context, name).getWritableDb(); - DaoMaster daoMaster = new DaoMaster(db); - return daoMaster.newSession(); - } - - public DaoMaster(SQLiteDatabase db) { - this(new StandardDatabase(db)); - } - - public DaoMaster(Database db) { - super(db, SCHEMA_VERSION); - registerDaoClass(MarkerLocalBeanDao.class); - registerDaoClass(TaskLocalBeanDao.class); - registerDaoClass(TaskMarkerLocalBeanDao.class); - } - - public DaoSession newSession() { - return new DaoSession(db, IdentityScopeType.Session, daoConfigMap); - } - - public DaoSession newSession(IdentityScopeType type) { - return new DaoSession(db, type, daoConfigMap); - } - - /** - * Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} - - */ - public static abstract class OpenHelper extends DatabaseOpenHelper { - public OpenHelper(Context context, String name) { - super(context, name, SCHEMA_VERSION); - } - - public OpenHelper(Context context, String name, CursorFactory factory) { - super(context, name, factory, SCHEMA_VERSION); - } - - @Override - public void onCreate(Database db) { - Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION); - createAllTables(db, false); - } - } - - /** WARNING: Drops all table on Upgrade! Use only during development. */ - public static class DevOpenHelper extends OpenHelper { - public DevOpenHelper(Context context, String name) { - super(context, name); - } - - public DevOpenHelper(Context context, String name, CursorFactory factory) { - super(context, name, factory); - } - - @Override - public void onUpgrade(Database db, int oldVersion, int newVersion) { - Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables"); - dropAllTables(db, true); - onCreate(db); - } - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoSession.java b/app/src/main/java/com/casic/common/detector/gd/greendao/DaoSession.java deleted file mode 100644 index c8b1a20..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoSession.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import java.util.Map; - -import org.greenrobot.greendao.AbstractDao; -import org.greenrobot.greendao.AbstractDaoSession; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.identityscope.IdentityScopeType; -import org.greenrobot.greendao.internal.DaoConfig; - -import com.casic.common.detector.gd.bean.MarkerLocalBean; -import com.casic.common.detector.gd.bean.TaskLocalBean; -import com.casic.common.detector.gd.bean.TaskMarkerLocalBean; - -import com.casic.common.detector.gd.greendao.MarkerLocalBeanDao; -import com.casic.common.detector.gd.greendao.TaskLocalBeanDao; -import com.casic.common.detector.gd.greendao.TaskMarkerLocalBeanDao; - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. - -/** - * {@inheritDoc} - * - * @see org.greenrobot.greendao.AbstractDaoSession - */ -public class DaoSession extends AbstractDaoSession { - - private final DaoConfig markerLocalBeanDaoConfig; - private final DaoConfig taskLocalBeanDaoConfig; - private final DaoConfig taskMarkerLocalBeanDaoConfig; - - private final MarkerLocalBeanDao markerLocalBeanDao; - private final TaskLocalBeanDao taskLocalBeanDao; - private final TaskMarkerLocalBeanDao taskMarkerLocalBeanDao; - - public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> - daoConfigMap) { - super(db); - - markerLocalBeanDaoConfig = daoConfigMap.get(MarkerLocalBeanDao.class).clone(); - markerLocalBeanDaoConfig.initIdentityScope(type); - - taskLocalBeanDaoConfig = daoConfigMap.get(TaskLocalBeanDao.class).clone(); - taskLocalBeanDaoConfig.initIdentityScope(type); - - taskMarkerLocalBeanDaoConfig = daoConfigMap.get(TaskMarkerLocalBeanDao.class).clone(); - taskMarkerLocalBeanDaoConfig.initIdentityScope(type); - - markerLocalBeanDao = new MarkerLocalBeanDao(markerLocalBeanDaoConfig, this); - taskLocalBeanDao = new TaskLocalBeanDao(taskLocalBeanDaoConfig, this); - taskMarkerLocalBeanDao = new TaskMarkerLocalBeanDao(taskMarkerLocalBeanDaoConfig, this); - - registerDao(MarkerLocalBean.class, markerLocalBeanDao); - registerDao(TaskLocalBean.class, taskLocalBeanDao); - registerDao(TaskMarkerLocalBean.class, taskMarkerLocalBeanDao); - } - - public void clear() { - markerLocalBeanDaoConfig.clearIdentityScope(); - taskLocalBeanDaoConfig.clearIdentityScope(); - taskMarkerLocalBeanDaoConfig.clearIdentityScope(); - } - - public MarkerLocalBeanDao getMarkerLocalBeanDao() { - return markerLocalBeanDao; - } - - public TaskLocalBeanDao getTaskLocalBeanDao() { - return taskLocalBeanDao; - } - - public TaskMarkerLocalBeanDao getTaskMarkerLocalBeanDao() { - return taskMarkerLocalBeanDao; - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/MarkerLocalBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/greendao/MarkerLocalBeanDao.java deleted file mode 100644 index 2f792c3..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/MarkerLocalBeanDao.java +++ /dev/null @@ -1,479 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import android.database.Cursor; -import android.database.sqlite.SQLiteStatement; - -import org.greenrobot.greendao.AbstractDao; -import org.greenrobot.greendao.Property; -import org.greenrobot.greendao.internal.DaoConfig; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.database.DatabaseStatement; - -import com.casic.common.detector.gd.bean.MarkerLocalBean; - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** - * DAO for table "MARKER_LOCAL_BEAN". -*/ -public class MarkerLocalBeanDao extends AbstractDao { - - public static final String TABLENAME = "MARKER_LOCAL_BEAN"; - - /** - * Properties of entity MarkerLocalBean.
- * Can be used for QueryBuilder and for referencing column names. - */ - public static class Properties { - public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property PipelineType = new Property(1, String.class, "pipelineType", false, "PIPELINE_TYPE"); - public final static Property PipelineDiameter = new Property(2, String.class, "pipelineDiameter", false, "PIPELINE_DIAMETER"); - public final static Property PipelineMaterial = new Property(3, String.class, "pipelineMaterial", false, "PIPELINE_MATERIAL"); - public final static Property BuryMethod = new Property(4, String.class, "buryMethod", false, "BURY_METHOD"); - public final static Property BuryDepth = new Property(5, String.class, "buryDepth", false, "BURY_DEPTH"); - public final static Property Area = new Property(6, String.class, "area", false, "AREA"); - public final static Property Line = new Property(7, String.class, "line", false, "LINE"); - public final static Property Road = new Property(8, String.class, "road", false, "ROAD"); - public final static Property ConstructTime = new Property(9, String.class, "constructTime", false, "CONSTRUCT_TIME"); - public final static Property Owner = new Property(10, String.class, "owner", false, "OWNER"); - public final static Property ObjectId = new Property(11, String.class, "objectId", false, "OBJECT_ID"); - public final static Property MarkerId = new Property(12, String.class, "markerId", false, "MARKER_ID"); - public final static Property MarkerType = new Property(13, String.class, "markerType", false, "MARKER_TYPE"); - public final static Property MarkerDepth = new Property(14, String.class, "markerDepth", false, "MARKER_DEPTH"); - public final static Property InstallationDept = new Property(15, String.class, "installationDept", false, "INSTALLATION_DEPT"); - public final static Property Lng = new Property(16, String.class, "lng", false, "LNG"); - public final static Property Lat = new Property(17, String.class, "lat", false, "LAT"); - public final static Property UpdateTime = new Property(18, String.class, "updateTime", false, "UPDATE_TIME"); - public final static Property Remark = new Property(19, String.class, "remark", false, "REMARK"); - public final static Property UnderlyingPipelineType = new Property(20, String.class, "underlyingPipelineType", false, "UNDERLYING_PIPELINE_TYPE"); - public final static Property UnderlyingPipelineDepth = new Property(21, String.class, "underlyingPipelineDepth", false, "UNDERLYING_PIPELINE_DEPTH"); - public final static Property UnderlyingPipelineDiameter = new Property(22, String.class, "underlyingPipelineDiameter", false, "UNDERLYING_PIPELINE_DIAMETER"); - public final static Property UnderlyingPipelineMaterial = new Property(23, String.class, "underlyingPipelineMaterial", false, "UNDERLYING_PIPELINE_MATERIAL"); - public final static Property ObjectType = new Property(24, String.class, "objectType", false, "OBJECT_TYPE"); - public final static Property Color = new Property(25, String.class, "color", false, "COLOR"); - public final static Property ImagePath = new Property(26, String.class, "imagePath", false, "IMAGE_PATH"); - } - - - public MarkerLocalBeanDao(DaoConfig config) { - super(config); - } - - public MarkerLocalBeanDao(DaoConfig config, DaoSession daoSession) { - super(config, daoSession); - } - - /** Creates the underlying database table. */ - public static void createTable(Database db, boolean ifNotExists) { - String constraint = ifNotExists? "IF NOT EXISTS ": ""; - db.execSQL("CREATE TABLE " + constraint + "\"MARKER_LOCAL_BEAN\" (" + // - "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id - "\"PIPELINE_TYPE\" TEXT," + // 1: pipelineType - "\"PIPELINE_DIAMETER\" TEXT," + // 2: pipelineDiameter - "\"PIPELINE_MATERIAL\" TEXT," + // 3: pipelineMaterial - "\"BURY_METHOD\" TEXT," + // 4: buryMethod - "\"BURY_DEPTH\" TEXT," + // 5: buryDepth - "\"AREA\" TEXT," + // 6: area - "\"LINE\" TEXT," + // 7: line - "\"ROAD\" TEXT," + // 8: road - "\"CONSTRUCT_TIME\" TEXT," + // 9: constructTime - "\"OWNER\" TEXT," + // 10: owner - "\"OBJECT_ID\" TEXT," + // 11: objectId - "\"MARKER_ID\" TEXT," + // 12: markerId - "\"MARKER_TYPE\" TEXT," + // 13: markerType - "\"MARKER_DEPTH\" TEXT," + // 14: markerDepth - "\"INSTALLATION_DEPT\" TEXT," + // 15: installationDept - "\"LNG\" TEXT," + // 16: lng - "\"LAT\" TEXT," + // 17: lat - "\"UPDATE_TIME\" TEXT," + // 18: updateTime - "\"REMARK\" TEXT," + // 19: remark - "\"UNDERLYING_PIPELINE_TYPE\" TEXT," + // 20: underlyingPipelineType - "\"UNDERLYING_PIPELINE_DEPTH\" TEXT," + // 21: underlyingPipelineDepth - "\"UNDERLYING_PIPELINE_DIAMETER\" TEXT," + // 22: underlyingPipelineDiameter - "\"UNDERLYING_PIPELINE_MATERIAL\" TEXT," + // 23: underlyingPipelineMaterial - "\"OBJECT_TYPE\" TEXT," + // 24: objectType - "\"COLOR\" TEXT," + // 25: color - "\"IMAGE_PATH\" TEXT);"); // 26: imagePath - } - - /** Drops the underlying database table. */ - public static void dropTable(Database db, boolean ifExists) { - String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"MARKER_LOCAL_BEAN\""; - db.execSQL(sql); - } - - @Override - protected final void bindValues(DatabaseStatement stmt, MarkerLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String pipelineType = entity.getPipelineType(); - if (pipelineType != null) { - stmt.bindString(2, pipelineType); - } - - String pipelineDiameter = entity.getPipelineDiameter(); - if (pipelineDiameter != null) { - stmt.bindString(3, pipelineDiameter); - } - - String pipelineMaterial = entity.getPipelineMaterial(); - if (pipelineMaterial != null) { - stmt.bindString(4, pipelineMaterial); - } - - String buryMethod = entity.getBuryMethod(); - if (buryMethod != null) { - stmt.bindString(5, buryMethod); - } - - String buryDepth = entity.getBuryDepth(); - if (buryDepth != null) { - stmt.bindString(6, buryDepth); - } - - String area = entity.getArea(); - if (area != null) { - stmt.bindString(7, area); - } - - String line = entity.getLine(); - if (line != null) { - stmt.bindString(8, line); - } - - String road = entity.getRoad(); - if (road != null) { - stmt.bindString(9, road); - } - - String constructTime = entity.getConstructTime(); - if (constructTime != null) { - stmt.bindString(10, constructTime); - } - - String owner = entity.getOwner(); - if (owner != null) { - stmt.bindString(11, owner); - } - - String objectId = entity.getObjectId(); - if (objectId != null) { - stmt.bindString(12, objectId); - } - - String markerId = entity.getMarkerId(); - if (markerId != null) { - stmt.bindString(13, markerId); - } - - String markerType = entity.getMarkerType(); - if (markerType != null) { - stmt.bindString(14, markerType); - } - - String markerDepth = entity.getMarkerDepth(); - if (markerDepth != null) { - stmt.bindString(15, markerDepth); - } - - String installationDept = entity.getInstallationDept(); - if (installationDept != null) { - stmt.bindString(16, installationDept); - } - - String lng = entity.getLng(); - if (lng != null) { - stmt.bindString(17, lng); - } - - String lat = entity.getLat(); - if (lat != null) { - stmt.bindString(18, lat); - } - - String updateTime = entity.getUpdateTime(); - if (updateTime != null) { - stmt.bindString(19, updateTime); - } - - String remark = entity.getRemark(); - if (remark != null) { - stmt.bindString(20, remark); - } - - String underlyingPipelineType = entity.getUnderlyingPipelineType(); - if (underlyingPipelineType != null) { - stmt.bindString(21, underlyingPipelineType); - } - - String underlyingPipelineDepth = entity.getUnderlyingPipelineDepth(); - if (underlyingPipelineDepth != null) { - stmt.bindString(22, underlyingPipelineDepth); - } - - String underlyingPipelineDiameter = entity.getUnderlyingPipelineDiameter(); - if (underlyingPipelineDiameter != null) { - stmt.bindString(23, underlyingPipelineDiameter); - } - - String underlyingPipelineMaterial = entity.getUnderlyingPipelineMaterial(); - if (underlyingPipelineMaterial != null) { - stmt.bindString(24, underlyingPipelineMaterial); - } - - String objectType = entity.getObjectType(); - if (objectType != null) { - stmt.bindString(25, objectType); - } - - String color = entity.getColor(); - if (color != null) { - stmt.bindString(26, color); - } - - String imagePath = entity.getImagePath(); - if (imagePath != null) { - stmt.bindString(27, imagePath); - } - } - - @Override - protected final void bindValues(SQLiteStatement stmt, MarkerLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String pipelineType = entity.getPipelineType(); - if (pipelineType != null) { - stmt.bindString(2, pipelineType); - } - - String pipelineDiameter = entity.getPipelineDiameter(); - if (pipelineDiameter != null) { - stmt.bindString(3, pipelineDiameter); - } - - String pipelineMaterial = entity.getPipelineMaterial(); - if (pipelineMaterial != null) { - stmt.bindString(4, pipelineMaterial); - } - - String buryMethod = entity.getBuryMethod(); - if (buryMethod != null) { - stmt.bindString(5, buryMethod); - } - - String buryDepth = entity.getBuryDepth(); - if (buryDepth != null) { - stmt.bindString(6, buryDepth); - } - - String area = entity.getArea(); - if (area != null) { - stmt.bindString(7, area); - } - - String line = entity.getLine(); - if (line != null) { - stmt.bindString(8, line); - } - - String road = entity.getRoad(); - if (road != null) { - stmt.bindString(9, road); - } - - String constructTime = entity.getConstructTime(); - if (constructTime != null) { - stmt.bindString(10, constructTime); - } - - String owner = entity.getOwner(); - if (owner != null) { - stmt.bindString(11, owner); - } - - String objectId = entity.getObjectId(); - if (objectId != null) { - stmt.bindString(12, objectId); - } - - String markerId = entity.getMarkerId(); - if (markerId != null) { - stmt.bindString(13, markerId); - } - - String markerType = entity.getMarkerType(); - if (markerType != null) { - stmt.bindString(14, markerType); - } - - String markerDepth = entity.getMarkerDepth(); - if (markerDepth != null) { - stmt.bindString(15, markerDepth); - } - - String installationDept = entity.getInstallationDept(); - if (installationDept != null) { - stmt.bindString(16, installationDept); - } - - String lng = entity.getLng(); - if (lng != null) { - stmt.bindString(17, lng); - } - - String lat = entity.getLat(); - if (lat != null) { - stmt.bindString(18, lat); - } - - String updateTime = entity.getUpdateTime(); - if (updateTime != null) { - stmt.bindString(19, updateTime); - } - - String remark = entity.getRemark(); - if (remark != null) { - stmt.bindString(20, remark); - } - - String underlyingPipelineType = entity.getUnderlyingPipelineType(); - if (underlyingPipelineType != null) { - stmt.bindString(21, underlyingPipelineType); - } - - String underlyingPipelineDepth = entity.getUnderlyingPipelineDepth(); - if (underlyingPipelineDepth != null) { - stmt.bindString(22, underlyingPipelineDepth); - } - - String underlyingPipelineDiameter = entity.getUnderlyingPipelineDiameter(); - if (underlyingPipelineDiameter != null) { - stmt.bindString(23, underlyingPipelineDiameter); - } - - String underlyingPipelineMaterial = entity.getUnderlyingPipelineMaterial(); - if (underlyingPipelineMaterial != null) { - stmt.bindString(24, underlyingPipelineMaterial); - } - - String objectType = entity.getObjectType(); - if (objectType != null) { - stmt.bindString(25, objectType); - } - - String color = entity.getColor(); - if (color != null) { - stmt.bindString(26, color); - } - - String imagePath = entity.getImagePath(); - if (imagePath != null) { - stmt.bindString(27, imagePath); - } - } - - @Override - public Long readKey(Cursor cursor, int offset) { - return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); - } - - @Override - public MarkerLocalBean readEntity(Cursor cursor, int offset) { - MarkerLocalBean entity = new MarkerLocalBean( // - cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // pipelineType - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // pipelineDiameter - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // pipelineMaterial - cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // buryMethod - cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // buryDepth - cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // area - cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // line - cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // road - cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // constructTime - cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10), // owner - cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11), // objectId - cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12), // markerId - cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13), // markerType - cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14), // markerDepth - cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15), // installationDept - cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16), // lng - cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17), // lat - cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18), // updateTime - cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19), // remark - cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20), // underlyingPipelineType - cursor.isNull(offset + 21) ? null : cursor.getString(offset + 21), // underlyingPipelineDepth - cursor.isNull(offset + 22) ? null : cursor.getString(offset + 22), // underlyingPipelineDiameter - cursor.isNull(offset + 23) ? null : cursor.getString(offset + 23), // underlyingPipelineMaterial - cursor.isNull(offset + 24) ? null : cursor.getString(offset + 24), // objectType - cursor.isNull(offset + 25) ? null : cursor.getString(offset + 25), // color - cursor.isNull(offset + 26) ? null : cursor.getString(offset + 26) // imagePath - ); - return entity; - } - - @Override - public void readEntity(Cursor cursor, MarkerLocalBean entity, int offset) { - entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setPipelineType(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); - entity.setPipelineDiameter(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); - entity.setPipelineMaterial(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); - entity.setBuryMethod(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); - entity.setBuryDepth(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); - entity.setArea(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); - entity.setLine(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); - entity.setRoad(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); - entity.setConstructTime(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9)); - entity.setOwner(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); - entity.setObjectId(cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11)); - entity.setMarkerId(cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12)); - entity.setMarkerType(cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13)); - entity.setMarkerDepth(cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14)); - entity.setInstallationDept(cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15)); - entity.setLng(cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16)); - entity.setLat(cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17)); - entity.setUpdateTime(cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18)); - entity.setRemark(cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19)); - entity.setUnderlyingPipelineType(cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20)); - entity.setUnderlyingPipelineDepth(cursor.isNull(offset + 21) ? null : cursor.getString(offset + 21)); - entity.setUnderlyingPipelineDiameter(cursor.isNull(offset + 22) ? null : cursor.getString(offset + 22)); - entity.setUnderlyingPipelineMaterial(cursor.isNull(offset + 23) ? null : cursor.getString(offset + 23)); - entity.setObjectType(cursor.isNull(offset + 24) ? null : cursor.getString(offset + 24)); - entity.setColor(cursor.isNull(offset + 25) ? null : cursor.getString(offset + 25)); - entity.setImagePath(cursor.isNull(offset + 26) ? null : cursor.getString(offset + 26)); - } - - @Override - protected final Long updateKeyAfterInsert(MarkerLocalBean entity, long rowId) { - entity.setId(rowId); - return rowId; - } - - @Override - public Long getKey(MarkerLocalBean entity) { - if(entity != null) { - return entity.getId(); - } else { - return null; - } - } - - @Override - public boolean hasKey(MarkerLocalBean entity) { - return entity.getId() != null; - } - - @Override - protected final boolean isEntityUpdateable() { - return true; - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/TaskLocalBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/greendao/TaskLocalBeanDao.java deleted file mode 100644 index fb88157..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/TaskLocalBeanDao.java +++ /dev/null @@ -1,227 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import android.database.Cursor; -import android.database.sqlite.SQLiteStatement; - -import org.greenrobot.greendao.AbstractDao; -import org.greenrobot.greendao.Property; -import org.greenrobot.greendao.internal.DaoConfig; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.database.DatabaseStatement; - -import com.casic.common.detector.gd.bean.TaskLocalBean; - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** - * DAO for table "TASK_LOCAL_BEAN". -*/ -public class TaskLocalBeanDao extends AbstractDao { - - public static final String TABLENAME = "TASK_LOCAL_BEAN"; - - /** - * Properties of entity TaskLocalBean.
- * Can be used for QueryBuilder and for referencing column names. - */ - public static class Properties { - public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property TaskCode = new Property(1, String.class, "taskCode", false, "TASK_CODE"); - public final static Property Description = new Property(2, String.class, "description", false, "DESCRIPTION"); - public final static Property CreateTime = new Property(3, String.class, "createTime", false, "CREATE_TIME"); - public final static Property Status = new Property(4, String.class, "status", false, "STATUS"); - public final static Property CreateUserName = new Property(5, String.class, "createUserName", false, "CREATE_USER_NAME"); - public final static Property StartTime = new Property(6, String.class, "startTime", false, "START_TIME"); - public final static Property EndTime = new Property(7, String.class, "endTime", false, "END_TIME"); - public final static Property IsFreeTask = new Property(8, String.class, "isFreeTask", false, "IS_FREE_TASK"); - } - - - public TaskLocalBeanDao(DaoConfig config) { - super(config); - } - - public TaskLocalBeanDao(DaoConfig config, DaoSession daoSession) { - super(config, daoSession); - } - - /** Creates the underlying database table. */ - public static void createTable(Database db, boolean ifNotExists) { - String constraint = ifNotExists? "IF NOT EXISTS ": ""; - db.execSQL("CREATE TABLE " + constraint + "\"TASK_LOCAL_BEAN\" (" + // - "\"_id\" INTEGER PRIMARY KEY ," + // 0: id - "\"TASK_CODE\" TEXT," + // 1: taskCode - "\"DESCRIPTION\" TEXT," + // 2: description - "\"CREATE_TIME\" TEXT," + // 3: createTime - "\"STATUS\" TEXT," + // 4: status - "\"CREATE_USER_NAME\" TEXT," + // 5: createUserName - "\"START_TIME\" TEXT," + // 6: startTime - "\"END_TIME\" TEXT," + // 7: endTime - "\"IS_FREE_TASK\" TEXT);"); // 8: isFreeTask - } - - /** Drops the underlying database table. */ - public static void dropTable(Database db, boolean ifExists) { - String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"TASK_LOCAL_BEAN\""; - db.execSQL(sql); - } - - @Override - protected final void bindValues(DatabaseStatement stmt, TaskLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String taskCode = entity.getTaskCode(); - if (taskCode != null) { - stmt.bindString(2, taskCode); - } - - String description = entity.getDescription(); - if (description != null) { - stmt.bindString(3, description); - } - - String createTime = entity.getCreateTime(); - if (createTime != null) { - stmt.bindString(4, createTime); - } - - String status = entity.getStatus(); - if (status != null) { - stmt.bindString(5, status); - } - - String createUserName = entity.getCreateUserName(); - if (createUserName != null) { - stmt.bindString(6, createUserName); - } - - String startTime = entity.getStartTime(); - if (startTime != null) { - stmt.bindString(7, startTime); - } - - String endTime = entity.getEndTime(); - if (endTime != null) { - stmt.bindString(8, endTime); - } - - String isFreeTask = entity.getIsFreeTask(); - if (isFreeTask != null) { - stmt.bindString(9, isFreeTask); - } - } - - @Override - protected final void bindValues(SQLiteStatement stmt, TaskLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String taskCode = entity.getTaskCode(); - if (taskCode != null) { - stmt.bindString(2, taskCode); - } - - String description = entity.getDescription(); - if (description != null) { - stmt.bindString(3, description); - } - - String createTime = entity.getCreateTime(); - if (createTime != null) { - stmt.bindString(4, createTime); - } - - String status = entity.getStatus(); - if (status != null) { - stmt.bindString(5, status); - } - - String createUserName = entity.getCreateUserName(); - if (createUserName != null) { - stmt.bindString(6, createUserName); - } - - String startTime = entity.getStartTime(); - if (startTime != null) { - stmt.bindString(7, startTime); - } - - String endTime = entity.getEndTime(); - if (endTime != null) { - stmt.bindString(8, endTime); - } - - String isFreeTask = entity.getIsFreeTask(); - if (isFreeTask != null) { - stmt.bindString(9, isFreeTask); - } - } - - @Override - public Long readKey(Cursor cursor, int offset) { - return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); - } - - @Override - public TaskLocalBean readEntity(Cursor cursor, int offset) { - TaskLocalBean entity = new TaskLocalBean( // - cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // taskCode - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // description - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // createTime - cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // status - cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // createUserName - cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // startTime - cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // endTime - cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8) // isFreeTask - ); - return entity; - } - - @Override - public void readEntity(Cursor cursor, TaskLocalBean entity, int offset) { - entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setTaskCode(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); - entity.setDescription(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); - entity.setCreateTime(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); - entity.setStatus(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); - entity.setCreateUserName(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); - entity.setStartTime(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); - entity.setEndTime(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); - entity.setIsFreeTask(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); - } - - @Override - protected final Long updateKeyAfterInsert(TaskLocalBean entity, long rowId) { - entity.setId(rowId); - return rowId; - } - - @Override - public Long getKey(TaskLocalBean entity) { - if(entity != null) { - return entity.getId(); - } else { - return null; - } - } - - @Override - public boolean hasKey(TaskLocalBean entity) { - return entity.getId() != null; - } - - @Override - protected final boolean isEntityUpdateable() { - return true; - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/TaskMarkerLocalBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/greendao/TaskMarkerLocalBeanDao.java deleted file mode 100644 index e96c735..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/TaskMarkerLocalBeanDao.java +++ /dev/null @@ -1,197 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import android.database.Cursor; -import android.database.sqlite.SQLiteStatement; - -import org.greenrobot.greendao.AbstractDao; -import org.greenrobot.greendao.Property; -import org.greenrobot.greendao.internal.DaoConfig; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.database.DatabaseStatement; - -import com.casic.common.detector.gd.bean.TaskMarkerLocalBean; - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** - * DAO for table "TASK_MARKER_LOCAL_BEAN". -*/ -public class TaskMarkerLocalBeanDao extends AbstractDao { - - public static final String TABLENAME = "TASK_MARKER_LOCAL_BEAN"; - - /** - * Properties of entity TaskMarkerLocalBean.
- * Can be used for QueryBuilder and for referencing column names. - */ - public static class Properties { - public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property TaskId = new Property(1, String.class, "taskId", false, "TASK_ID"); - public final static Property TaskCode = new Property(2, String.class, "taskCode", false, "TASK_CODE"); - public final static Property MarkerId = new Property(3, String.class, "markerId", false, "MARKER_ID"); - public final static Property Lng = new Property(4, double.class, "lng", false, "LNG"); - public final static Property Lat = new Property(5, double.class, "lat", false, "LAT"); - public final static Property IsDetected = new Property(6, String.class, "isDetected", false, "IS_DETECTED"); - public final static Property DetectedTime = new Property(7, String.class, "detectedTime", false, "DETECTED_TIME"); - } - - - public TaskMarkerLocalBeanDao(DaoConfig config) { - super(config); - } - - public TaskMarkerLocalBeanDao(DaoConfig config, DaoSession daoSession) { - super(config, daoSession); - } - - /** Creates the underlying database table. */ - public static void createTable(Database db, boolean ifNotExists) { - String constraint = ifNotExists? "IF NOT EXISTS ": ""; - db.execSQL("CREATE TABLE " + constraint + "\"TASK_MARKER_LOCAL_BEAN\" (" + // - "\"_id\" INTEGER PRIMARY KEY ," + // 0: id - "\"TASK_ID\" TEXT," + // 1: taskId - "\"TASK_CODE\" TEXT," + // 2: taskCode - "\"MARKER_ID\" TEXT," + // 3: markerId - "\"LNG\" REAL NOT NULL ," + // 4: lng - "\"LAT\" REAL NOT NULL ," + // 5: lat - "\"IS_DETECTED\" TEXT," + // 6: isDetected - "\"DETECTED_TIME\" TEXT);"); // 7: detectedTime - } - - /** Drops the underlying database table. */ - public static void dropTable(Database db, boolean ifExists) { - String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"TASK_MARKER_LOCAL_BEAN\""; - db.execSQL(sql); - } - - @Override - protected final void bindValues(DatabaseStatement stmt, TaskMarkerLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String taskId = entity.getTaskId(); - if (taskId != null) { - stmt.bindString(2, taskId); - } - - String taskCode = entity.getTaskCode(); - if (taskCode != null) { - stmt.bindString(3, taskCode); - } - - String markerId = entity.getMarkerId(); - if (markerId != null) { - stmt.bindString(4, markerId); - } - stmt.bindDouble(5, entity.getLng()); - stmt.bindDouble(6, entity.getLat()); - - String isDetected = entity.getIsDetected(); - if (isDetected != null) { - stmt.bindString(7, isDetected); - } - - String detectedTime = entity.getDetectedTime(); - if (detectedTime != null) { - stmt.bindString(8, detectedTime); - } - } - - @Override - protected final void bindValues(SQLiteStatement stmt, TaskMarkerLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String taskId = entity.getTaskId(); - if (taskId != null) { - stmt.bindString(2, taskId); - } - - String taskCode = entity.getTaskCode(); - if (taskCode != null) { - stmt.bindString(3, taskCode); - } - - String markerId = entity.getMarkerId(); - if (markerId != null) { - stmt.bindString(4, markerId); - } - stmt.bindDouble(5, entity.getLng()); - stmt.bindDouble(6, entity.getLat()); - - String isDetected = entity.getIsDetected(); - if (isDetected != null) { - stmt.bindString(7, isDetected); - } - - String detectedTime = entity.getDetectedTime(); - if (detectedTime != null) { - stmt.bindString(8, detectedTime); - } - } - - @Override - public Long readKey(Cursor cursor, int offset) { - return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); - } - - @Override - public TaskMarkerLocalBean readEntity(Cursor cursor, int offset) { - TaskMarkerLocalBean entity = new TaskMarkerLocalBean( // - cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // taskId - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // taskCode - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // markerId - cursor.getDouble(offset + 4), // lng - cursor.getDouble(offset + 5), // lat - cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // isDetected - cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7) // detectedTime - ); - return entity; - } - - @Override - public void readEntity(Cursor cursor, TaskMarkerLocalBean entity, int offset) { - entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setTaskId(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); - entity.setTaskCode(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); - entity.setMarkerId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); - entity.setLng(cursor.getDouble(offset + 4)); - entity.setLat(cursor.getDouble(offset + 5)); - entity.setIsDetected(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); - entity.setDetectedTime(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); - } - - @Override - protected final Long updateKeyAfterInsert(TaskMarkerLocalBean entity, long rowId) { - entity.setId(rowId); - return rowId; - } - - @Override - public Long getKey(TaskMarkerLocalBean entity) { - if(entity != null) { - return entity.getId(); - } else { - return null; - } - } - - @Override - public boolean hasKey(TaskMarkerLocalBean entity) { - return entity.getId() != null; - } - - @Override - protected final boolean isEntityUpdateable() { - return true; - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/model/TaskModel.java b/app/src/main/java/com/casic/common/detector/gd/model/TaskModel.java index 6e853ad..67ef5fb 100644 --- a/app/src/main/java/com/casic/common/detector/gd/model/TaskModel.java +++ b/app/src/main/java/com/casic/common/detector/gd/model/TaskModel.java @@ -24,7 +24,7 @@ } public static class MessageModel { - private int id; + private Long id; private String taskCode; private String description; private String deployDate; @@ -38,11 +38,11 @@ private int isValid; private List taskDetailInfos; - public int getId() { + public Long getId() { return id; } - public void setId(int id) { + public void setId(Long id) { this.id = id; } @@ -143,25 +143,25 @@ } public static class TaskDetailInfosModel { - private int id; + private long id; private String taskId; private String taskCode; private Object markerName; - private int markerId; + private String markerId; private String markerIdReal; private double longitude; private double latitude; private int isChecked; private int isNormal; - private Object imagePath; - private Object description; - private Object finishTime; + private String imagePath; + private String description; + private String finishTime; - public int getId() { + public long getId() { return id; } - public void setId(int id) { + public void setId(long id) { this.id = id; } @@ -189,11 +189,11 @@ this.markerName = markerName; } - public int getMarkerId() { + public String getMarkerId() { return markerId; } - public void setMarkerId(int markerId) { + public void setMarkerId(String markerId) { this.markerId = markerId; } @@ -237,27 +237,27 @@ this.isNormal = isNormal; } - public Object getImagePath() { + public String getImagePath() { return imagePath; } - public void setImagePath(Object imagePath) { + public void setImagePath(String imagePath) { this.imagePath = imagePath; } - public Object getDescription() { + public String getDescription() { return description; } - public void setDescription(Object description) { + public void setDescription(String description) { this.description = description; } - public Object getFinishTime() { + public String getFinishTime() { return finishTime; } - public void setFinishTime(Object finishTime) { + public void setFinishTime(String finishTime) { this.finishTime = finishTime; } } diff --git a/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitService.kt index 7522a87..0adad51 100644 --- a/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitService.kt @@ -50,7 +50,7 @@ */ @Multipart @POST("/ems/marker/save-marker-photo.do") - suspend fun installLabel( + suspend fun install( @PartMap jsonMarker: Map, @Part fileBuffer1: MultipartBody.Part?, @Part fileBuffer2: MultipartBody.Part?, diff --git a/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitServiceManager.kt index 5f6c701..ae2a0fa 100644 --- a/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitServiceManager.kt +++ b/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitServiceManager.kt @@ -37,22 +37,28 @@ /** * 获取标识器信息文件 */ - suspend fun getMarkerFile(userId: String, companyId: String): String { - return createApi().getMarkerFile(userId, companyId) + suspend fun getMarkerFile(): String { + val companyId = SaveKeyValues.getValue(LocaleConstant.USER_COMPANY_ID, "") as String + /** + * 后台设计如此,都传companyId + * */ + return createApi().getMarkerFile(companyId, companyId) } /** * 获取巡检工单 */ - suspend fun getTasksByUser(userName: String): String { + suspend fun getTasksByUser(): String { + val userName = SaveKeyValues.getValue(LocaleConstant.USER_NAME, "") as String return createApi().getTasksByUser(userName) } /** * 提交工单 */ - suspend fun uploadTask(userId: String, taskId: String?, state: String): String { + suspend fun uploadTask(taskId: String?, state: String): String { + val userId = SaveKeyValues.getValue(LocaleConstant.USER_ID, "") as String return createApi().uploadTask(userId, taskId.toString(), state) } @@ -60,8 +66,7 @@ * 安装新标识器 * Multipart上传图片,文件,带多参数上传 */ - suspend fun installLabel( - companyId: String, + suspend fun installMarker( recordType: String, markerObjectType: String, pipeMaterial: String, @@ -77,7 +82,6 @@ road: String, constructTime: String, ownerComp: String, - markerObjectId: String, markerId: String, markerType: String, markerDepth: String, @@ -89,6 +93,8 @@ memo: String, realPaths: ArrayList ): String { + val companyId = SaveKeyValues.getValue(LocaleConstant.USER_COMPANY_ID, "") as String + val objectId = SaveKeyValues.getValue(LocaleConstant.OBJECT_ID, "") as String val param = JsonObject() param.addProperty("companyId", companyId) param.addProperty("recordType", recordType) @@ -106,7 +112,7 @@ param.addProperty("road", road) param.addProperty("constructTime", constructTime) param.addProperty("ownerComp", ownerComp) - param.addProperty("markerObjectId", markerObjectId) + param.addProperty("markerObjectId", objectId) param.addProperty("markerId", markerId) param.addProperty("markerType", markerType) param.addProperty("markerDepth", markerDepth) @@ -133,19 +139,19 @@ return when (multiParts.size) { 3 -> { - createApi().installLabel(res, multiParts[0], multiParts[1], multiParts[2]) + createApi().install(res, multiParts[0], multiParts[1], multiParts[2]) } 2 -> { - createApi().installLabel(res, multiParts[0], multiParts[1], null) + createApi().install(res, multiParts[0], multiParts[1], null) } 1 -> { - createApi().installLabel(res, multiParts[0], null, null) + createApi().install(res, multiParts[0], null, null) } else -> { - createApi().installLabel(res, null, null, null) + createApi().install(res, null, null, null) } } } @@ -216,7 +222,7 @@ /** * 上传自由巡检过程中发现的标识器 */ - suspend fun uploadTaskMarker(taskId: String, ids: ArrayList): String { + suspend fun uploadTaskMarker(taskId: Long, ids: ArrayList): String { val param = JsonObject() param.addProperty("taskId", taskId) param.addProperty("ids", ids.joinToString(separator = ",")) diff --git a/app/src/main/java/com/casic/common/detector/gd/service/NtripConnectService.kt b/app/src/main/java/com/casic/common/detector/gd/service/NtripConnectService.kt index de9ac80..20e1a6a 100644 --- a/app/src/main/java/com/casic/common/detector/gd/service/NtripConnectService.kt +++ b/app/src/main/java/com/casic/common/detector/gd/service/NtripConnectService.kt @@ -9,10 +9,6 @@ import android.util.Log import android.view.Gravity import android.widget.Toast -import androidx.lifecycle.Lifecycle -import androidx.lifecycle.LifecycleOwner -import androidx.lifecycle.LifecycleRegistry -import androidx.lifecycle.lifecycleScope import com.casic.common.detector.gd.base.BaseApplication import com.casic.common.detector.gd.extensions.convertToGPGGA import com.casic.common.detector.gd.utils.LocaleConstant @@ -23,26 +19,24 @@ import com.pengxh.kt.lite.utils.WeakReferenceHandler import com.pengxh.kt.lite.utils.socket.tcp.OnTcpConnectStateListener import com.pengxh.kt.lite.utils.socket.tcp.TcpClient +import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.Job import kotlinx.coroutines.launch import java.io.OutputStream import java.nio.charset.StandardCharsets -class NtripConnectService : Service(), LifecycleOwner, OnTcpConnectStateListener, Handler.Callback { +class NtripConnectService : Service(), OnTcpConnectStateListener, Handler.Callback { companion object { var weakReferenceHandler: WeakReferenceHandler? = null } private val kTag = "NtripConnectService" - private val registry = LifecycleRegistry(this) private val socketClient by lazy { TcpClient(this) } private var outStream: OutputStream? = null - - override fun getLifecycle(): Lifecycle { - return registry - } + private val serviceScope = CoroutineScope(Dispatchers.Main + Job()) // 创建一个独立的CoroutineScope override fun onBind(intent: Intent?): IBinder? { return null @@ -117,7 +111,7 @@ * */ val result = String(this, StandardCharsets.UTF_8) if (result.contains("ICY 200 OK")) { - lifecycleScope.launch(Dispatchers.Main) { + serviceScope.launch { "高精度定位服务连接成功".show(this@NtripConnectService) } //连接服务即打开串口 @@ -135,12 +129,12 @@ * Content-Type: text/plain * Connection: clos * */ - lifecycleScope.launch(Dispatchers.Main) { + serviceScope.launch { "差分定位服务鉴权失败,无法解析位置".show(this@NtripConnectService) } } else { //居中显示 - lifecycleScope.launch(Dispatchers.Main) { + serviceScope.launch { val toast = Toast.makeText( this@NtripConnectService, "收到千寻数据,长度:${size}", Toast.LENGTH_SHORT ) @@ -167,7 +161,7 @@ return } - lifecycleScope.launch(Dispatchers.IO) { + serviceScope.launch(Dispatchers.IO) { socketClient.start(remoteHost, remotePort.toInt()) } } diff --git a/app/src/main/java/com/casic/common/detector/gd/utils/DataBaseManager.kt b/app/src/main/java/com/casic/common/detector/gd/utils/DataBaseManager.kt deleted file mode 100644 index aa22759..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/utils/DataBaseManager.kt +++ /dev/null @@ -1,200 +0,0 @@ -package com.casic.common.detector.gd.utils - -import com.casic.common.detector.gd.base.BaseApplication -import com.casic.common.detector.gd.bean.MarkerLocalBean -import com.casic.common.detector.gd.bean.TaskLocalBean -import com.casic.common.detector.gd.bean.TaskMarkerLocalBean -import com.casic.common.detector.gd.greendao.MarkerLocalBeanDao -import com.casic.common.detector.gd.greendao.TaskLocalBeanDao -import com.casic.common.detector.gd.greendao.TaskMarkerLocalBeanDao -import com.casic.common.detector.gd.model.TaskDetailLocalModel -import com.casic.common.detector.gd.model.TaskModel - -class DataBaseManager private constructor() { - companion object { - //Kotlin委托模式双重锁单例 - val get by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) { - DataBaseManager() - } - } - - private var taskLocalBeanDao = BaseApplication.get().getDaoSession().taskLocalBeanDao - private var taskMarkerLocalBeanDao = - BaseApplication.get().getDaoSession().taskMarkerLocalBeanDao - - fun saveTaskInLocale(task: TaskModel.MessageModel) { - val bean = TaskLocalBean() - bean.id = task.id.toLong() - bean.taskCode = task.taskCode - bean.description = task.description - bean.createTime = task.deployDate - bean.status = task.status - bean.createUserName = task.creatorName - if (task.beginDate == null) { - bean.startTime = "" - } - if (task.endDate == null) { - bean.endTime = "" - } - bean.isFreeTask = "0" - if (!bean.isExist()) { - taskLocalBeanDao.insert(bean) - } - } - - fun saveTaskInLocale(bean: TaskLocalBean) { - if (!bean.isExist()) { - taskLocalBeanDao.insert(bean) - } - } - - private fun TaskLocalBean.isExist(): Boolean { - val result = taskLocalBeanDao.queryBuilder().where( - TaskLocalBeanDao.Properties.Id.eq(this.id) - ).list() - return !result.isNullOrEmpty() - } - - fun saveTaskMarkerInLocale( - taskId: Int, taskCode: String, marker: TaskModel.MessageModel.TaskDetailInfosModel - ) { - val bean = TaskMarkerLocalBean() - bean.id = marker.id.toLong() - bean.taskId = taskId.toString() - bean.taskCode = taskCode - bean.markerId = marker.markerIdReal - bean.lng = marker.longitude - bean.lat = marker.latitude - bean.isDetected = "0" - bean.detectedTime = "" - if (!bean.isExist()) { - taskMarkerLocalBeanDao.insert(bean) - } - } - - private fun TaskMarkerLocalBean.isExist(): Boolean { - val result = taskMarkerLocalBeanDao.queryBuilder().where( - TaskMarkerLocalBeanDao.Properties.Id.eq(this.id) - ).list() - return !result.isNullOrEmpty() - } - - fun loadLocalTask(): ArrayList { - val result = ArrayList() - - val tasks = taskLocalBeanDao.loadAll() - tasks.forEach { - val model = TaskDetailLocalModel() - model.taskId = it.id.toString() - model.taskCode = it.taskCode - model.description = it.description - model.createTime = it.createTime - model.status = it.status - model.createUserName = it.createUserName - model.isFreeTask = it.isFreeTask - - val markers = ArrayList() - if (it.isFreeTask == "0") { - //非自由巡检才有Marker - val markerLocalBeans = taskMarkerLocalBeanDao.queryBuilder().where( - TaskMarkerLocalBeanDao.Properties.TaskId.eq(it.id), - TaskMarkerLocalBeanDao.Properties.TaskCode.eq(it.taskCode) - ).list() - markerLocalBeans.forEach { marker -> - val localModel = TaskDetailLocalModel.TaskMarkerLocalModel() - localModel.markerId = marker.markerId - localModel.lng = marker.lng - localModel.lat = marker.lat - localModel.isDetected = marker.isDetected - localModel.detectedTime = marker.detectedTime - - markers.add(localModel) - } - } - model.markerModels = markers - result.add(model) - } - return result - } - - fun deleteLocalTaskById(taskId: String, taskCode: String) { - val task = taskLocalBeanDao.queryBuilder().where( - TaskLocalBeanDao.Properties.Id.eq(taskId), - TaskLocalBeanDao.Properties.TaskCode.eq(taskCode) - ).list().firstOrNull() ?: return - taskLocalBeanDao.delete(task) - - //删除此任务关联的Marker。非自由巡检才有Marker - if (task.isFreeTask == "0") { - val markers = taskMarkerLocalBeanDao.queryBuilder() - .where( - TaskMarkerLocalBeanDao.Properties.TaskId.eq(taskId), - TaskMarkerLocalBeanDao.Properties.TaskCode.eq(taskCode) - ).list() - markers.forEach { - taskMarkerLocalBeanDao.delete(it) - } - } - } - - fun queryTaskMarkerById( - taskId: String, taskCode: String, markerId: String, state: String - ): TaskMarkerLocalBean? { - return taskMarkerLocalBeanDao.queryBuilder() - .where( - TaskMarkerLocalBeanDao.Properties.TaskId.eq(taskId), - TaskMarkerLocalBeanDao.Properties.TaskCode.eq(taskCode), - TaskMarkerLocalBeanDao.Properties.MarkerId.eq(markerId), - TaskMarkerLocalBeanDao.Properties.IsDetected.eq(state) - ).list().firstOrNull() - } - - fun updateLocalTaskMarkerState(marker: TaskMarkerLocalBean) { - marker.isDetected = "1" - taskMarkerLocalBeanDao.update(marker) - } - - fun queryMarkerByState(state: String): List { - return taskMarkerLocalBeanDao.queryBuilder() - .where(TaskMarkerLocalBeanDao.Properties.IsDetected.eq(state)) - .list() - } - - private var markerLocalBeanDao = BaseApplication.get().getDaoSession().markerLocalBeanDao - - fun clearMarkers() { - markerLocalBeanDao.deleteAll() - } - - fun saveMarkerInLocale(bean: MarkerLocalBean) { - markerLocalBeanDao.insert(bean) - } - - fun loadMarkers(): MutableList { - return markerLocalBeanDao.loadAll() - } - - fun loadMarkersByCondition(selectedItem: String, value: String?): MutableList { - val property = when (selectedItem) { - LocaleConstant.SPINNER_ARRAY[0] -> MarkerLocalBeanDao.Properties.MarkerId - LocaleConstant.SPINNER_ARRAY[1] -> MarkerLocalBeanDao.Properties.Area - LocaleConstant.SPINNER_ARRAY[2] -> MarkerLocalBeanDao.Properties.Line - LocaleConstant.SPINNER_ARRAY[3] -> MarkerLocalBeanDao.Properties.Road - LocaleConstant.SPINNER_ARRAY[4] -> MarkerLocalBeanDao.Properties.Owner - LocaleConstant.SPINNER_ARRAY[5] -> MarkerLocalBeanDao.Properties.InstallationDept - LocaleConstant.SPINNER_ARRAY[6] -> MarkerLocalBeanDao.Properties.UpdateTime - else -> MarkerLocalBeanDao.Properties.Remark - } - return if (value == null) { - markerLocalBeanDao.queryBuilder().where(property.isNotNull).list() - } else { - markerLocalBeanDao.queryBuilder().where(property.eq(value)).list() - } - } - - fun queryMarkerById(markerId: String): List { - return markerLocalBeanDao.queryBuilder() - .where(MarkerLocalBeanDao.Properties.MarkerId.eq(markerId)) - .list() - } -} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/utils/DetectorDataBase.java b/app/src/main/java/com/casic/common/detector/gd/utils/DetectorDataBase.java new file mode 100644 index 0000000..f686cac --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/utils/DetectorDataBase.java @@ -0,0 +1,21 @@ +package com.casic.common.detector.gd.utils; + +import androidx.room.Database; +import androidx.room.RoomDatabase; + +import com.casic.common.detector.gd.bean.MarkerBean; +import com.casic.common.detector.gd.bean.TaskBean; +import com.casic.common.detector.gd.bean.TaskMarkerBean; +import com.casic.common.detector.gd.dao.MarkerBeanDao; +import com.casic.common.detector.gd.dao.TaskBeanDao; +import com.casic.common.detector.gd.dao.TaskMarkerBeanDao; + + +@Database(entities = {MarkerBean.class, TaskBean.class, TaskMarkerBean.class}, version = 1) +public abstract class DetectorDataBase extends RoomDatabase { + public abstract MarkerBeanDao markerBeanDao(); + + public abstract TaskBeanDao taskBeanDao(); + + public abstract TaskMarkerBeanDao taskMarkerBeanDao(); +} \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index d0cb423..921c8c8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,25 +1,20 @@ import java.text.SimpleDateFormat -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply plugin: 'org.greenrobot.greendao' +plugins { + id('com.android.application') + id('org.jetbrains.kotlin.android') +} android { - compileSdkVersion 33 + namespace 'com.casic.common.detector.gd' + compileSdk 35 defaultConfig { - applicationId "com.casic.common.detector.gd" - minSdkVersion 26 - targetSdkVersion 33 + applicationId 'com.casic.common.detector.gd' + minSdk 26 + targetSdk 35 versionCode 5092 - versionName "5.0.9.2" - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } + versionName '5.0.9.2' } signingConfigs { @@ -31,6 +26,14 @@ } } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + signingConfig signingConfigs.release + } + } + compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 @@ -47,27 +50,16 @@ } } - kotlin { - experimental { - coroutines 'enable' - } - } - buildFeatures { + buildConfig true viewBinding true } - applicationVariants.configureEach { variant -> - variant.outputs.configureEach { - outputFileName = "COM_TCY_" + getBuildDate() + "_" + defaultConfig.versionName + ".apk" + applicationVariants.configureEach { + outputs.configureEach { + outputFileName = 'COM_TCY_' + getBuildDate() + '_' + defaultConfig.versionName + '.apk' } } - - greendao { - schemaVersion 1//数据库版本号 - targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 - daoPackage "${defaultConfig.applicationId}.greendao"//设置DaoMaster、DaoSession、Dao包名 - } } static def getBuildDate() { @@ -76,27 +68,22 @@ } dependencies { - //基础依赖库 - implementation 'com.github.AndroidCoderPeng:Kotlin-lite-lib:1.1.4' - implementation 'androidx.core:core-ktx:1.9.0' - def base_version = "1.6.1" - implementation "androidx.appcompat:appcompat:${base_version}" - implementation "com.google.android.material:material:${base_version}" + implementation 'com.github.AndroidCoderPeng:Kotlin-lite-lib:1.1.5' + implementation 'androidx.core:core-ktx:1.13.1' + implementation 'androidx.appcompat:appcompat:1.7.0' + implementation 'com.google.android.material:material:1.12.0' //Google官方授权框架 implementation 'pub.devrel:easypermissions:3.0.0' - //沉浸式状态栏。基础依赖包,必须要依赖 - implementation 'com.gyf.immersionbar:immersionbar:3.0.0' - //fragment快速实现 - implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0' + //沉浸式状态栏 + implementation 'com.geyifeng.immersionbar:immersionbar:3.2.2' //官方Json解析库 implementation 'com.google.code.gson:gson:2.10.1' - def vm_version = '2.5.1' //Kotlin协程 - implementation "androidx.lifecycle:lifecycle-runtime-ktx:${vm_version}" + implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.2' //MVVM+LiveData - implementation "androidx.lifecycle:lifecycle-livedata-ktx:${vm_version}" - implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:${vm_version}" - implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.6.2' + implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2' + implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' //返回值转换器 implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' @@ -105,9 +92,10 @@ implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' //网络请求和接口封装 implementation 'com.squareup.retrofit2:retrofit:2.9.0' - implementation 'com.squareup.okhttp3:okhttp:4.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.12.0' //数据库框架 - implementation 'org.greenrobot:greendao:3.3.0' + implementation 'androidx.room:room-runtime:2.6.1' + annotationProcessor 'androidx.room:room-compiler:2.5.2' //高德导航、定位、地图三合一 implementation 'com.amap.api:navi-3dmap:latest.integration' //经纬度逆编码 @@ -115,7 +103,7 @@ //excel implementation 'net.sourceforge.jexcelapi:jxl:2.6.12' //图片加载框架 - implementation 'com.github.bumptech.glide:glide:4.9.0' + implementation 'com.github.bumptech.glide:glide:4.12.0' //图片选择框架 implementation 'io.github.lucksiege:pictureselector:v3.11.1' //大图 diff --git a/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt b/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt index 7b695ff..50ba734 100644 --- a/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt +++ b/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt @@ -4,9 +4,9 @@ import android.app.Application import android.os.Bundle import android.util.Log -import com.casic.common.detector.gd.greendao.DaoMaster -import com.casic.common.detector.gd.greendao.DaoSession +import androidx.room.Room.databaseBuilder import com.casic.common.detector.gd.uart.SerialPort +import com.casic.common.detector.gd.utils.DetectorDataBase import com.casic.common.detector.gd.utils.GpioManager import com.pengxh.kt.lite.extensions.show import com.pengxh.kt.lite.utils.SaveKeyValues @@ -43,44 +43,42 @@ private var application: BaseApplication by Delegates.notNull() fun get() = application - - private lateinit var daoSession: DaoSession } + lateinit var dataBase: DetectorDataBase + override fun onCreate() { super.onCreate() application = this SaveKeyValues.initSharedPreferences(this) CrashReport.initCrashReport(this, "01e80d3a74", true) - val devOpenHelper = DaoMaster.DevOpenHelper(this, "Detector.db", null) - val daoMaster = DaoMaster(devOpenHelper.writableDatabase) - daoSession = daoMaster.newSession() + dataBase = databaseBuilder(this, DetectorDataBase::class.java, "Detector.db") + .allowMainThreadQueries() + .build() /** * Open the serial port * */ try { serialPorts.apply { - add(SerialPort(File("/dev/ttysWK1"), 9600, 0)) - //千寻报文数据下发串口号 - add(SerialPort(File("/dev/ttyS1"), 9600, 0)) + add(SerialPort(File("/dev/ttysWK1"), 9600, 0)) //信号通讯串口 + add(SerialPort(File("/dev/ttyS1"), 9600, 0)) //千寻报文数据下发串口号 } Log.d(kTag, "onCreate: 已初始化 ${serialPorts.size} 个串口") } catch (e: SecurityException) { "您没有串口的读写权限!".show(this) + e.printStackTrace() } catch (e: IOException) { "因为不明原因,串口无法打开!".show(this) + e.printStackTrace() } catch (e: InvalidParameterException) { "请检查串口!".show(this) + e.printStackTrace() } registerActivityLifecycleCallbacks(this) } - fun getDaoSession(): DaoSession { - return daoSession - } - override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) { } diff --git a/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt b/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt index 053b9dd..1d0c9e3 100644 --- a/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt +++ b/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt @@ -14,12 +14,10 @@ import com.casic.common.detector.gd.utils.SerialPortCommand import com.pengxh.kt.lite.utils.WeakReferenceHandler import java.io.IOException -import java.util.Timer abstract class SerialPortBaseActivity : AppCompatActivity(), Handler.Callback { private val kTag = "SerialPortBaseActivity" - private val taskTimer by lazy { Timer() } private val weakReferenceHandler by lazy { WeakReferenceHandler(this) } private val serialPorts by lazy { BaseApplication.get().getSerialPorts() } protected lateinit var binding: VB @@ -30,7 +28,6 @@ setContentView(binding.root) setupTopBarLayout() initOnCreate(savedInstanceState) - observeRequestState() initEvent() if (serialPorts.isNotEmpty()) { @@ -71,11 +68,6 @@ abstract fun initOnCreate(savedInstanceState: Bundle?) /** - * 数据请求状态监听 - */ - abstract fun observeRequestState() - - /** * 初始化业务逻辑 */ abstract fun initEvent() diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java new file mode 100644 index 0000000..7a18c20 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java @@ -0,0 +1,255 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 从平台下载的标识器本地库实体类 + */ +@Entity(tableName = "marker_detail") +public class MarkerBean { + @PrimaryKey(autoGenerate = true) + private long id; //主键ID + private String pipelineType; // 管线类型 + private String pipelineDiameter; // 管线直径 + private String pipelineMaterial; // 管材 + private String buryMethod; // 埋设方式 + private String buryDepth; // 埋深 + private String area; // 所属区域 + private String line; // 所属线路 + private String road; // 所属道路 + private String constructTime; // 建设年代 + private String owner; // 权属单位 + private String objectId; // 标识对象ID,无实际用途 + private String markerId; // 标识器ID + private String markerType; // 标识器类型 + private String markerDepth; // 标识器埋深 + private String installationDept; // 安装部门 + private String lng; // 经度 + private String lat; // 纬度 + private String updateTime; // 最后修改时间,更新时间 + private String remark; // 备注信息 + private String underlyingPipelineType; // 下层管线类型 + private String underlyingPipelineDepth; // 下层埋深 + private String underlyingPipelineDiameter; // 下层管径 + private String underlyingPipelineMaterial; // 下层管材 + private String objectType; //标识对象类型 + private String color; // 颜色 + private String imagePath; // 图片路径 + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getPipelineType() { + return pipelineType; + } + + public void setPipelineType(String pipelineType) { + this.pipelineType = pipelineType; + } + + public String getPipelineDiameter() { + return pipelineDiameter; + } + + public void setPipelineDiameter(String pipelineDiameter) { + this.pipelineDiameter = pipelineDiameter; + } + + public String getPipelineMaterial() { + return pipelineMaterial; + } + + public void setPipelineMaterial(String pipelineMaterial) { + this.pipelineMaterial = pipelineMaterial; + } + + public String getBuryMethod() { + return buryMethod; + } + + public void setBuryMethod(String buryMethod) { + this.buryMethod = buryMethod; + } + + public String getBuryDepth() { + return buryDepth; + } + + public void setBuryDepth(String buryDepth) { + this.buryDepth = buryDepth; + } + + public String getArea() { + return area; + } + + public void setArea(String area) { + this.area = area; + } + + public String getLine() { + return line; + } + + public void setLine(String line) { + this.line = line; + } + + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + + public String getConstructTime() { + return constructTime; + } + + public void setConstructTime(String constructTime) { + this.constructTime = constructTime; + } + + public String getOwner() { + return owner; + } + + public void setOwner(String owner) { + this.owner = owner; + } + + public String getObjectId() { + return objectId; + } + + public void setObjectId(String objectId) { + this.objectId = objectId; + } + + public String getMarkerId() { + return markerId; + } + + public void setMarkerId(String markerId) { + this.markerId = markerId; + } + + public String getMarkerType() { + return markerType; + } + + public void setMarkerType(String markerType) { + this.markerType = markerType; + } + + public String getMarkerDepth() { + return markerDepth; + } + + public void setMarkerDepth(String markerDepth) { + this.markerDepth = markerDepth; + } + + public String getInstallationDept() { + return installationDept; + } + + public void setInstallationDept(String installationDept) { + this.installationDept = installationDept; + } + + public String getLng() { + return lng; + } + + public void setLng(String lng) { + this.lng = lng; + } + + public String getLat() { + return lat; + } + + public void setLat(String lat) { + this.lat = lat; + } + + public String getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } + + public String getUnderlyingPipelineType() { + return underlyingPipelineType; + } + + public void setUnderlyingPipelineType(String underlyingPipelineType) { + this.underlyingPipelineType = underlyingPipelineType; + } + + public String getUnderlyingPipelineDepth() { + return underlyingPipelineDepth; + } + + public void setUnderlyingPipelineDepth(String underlyingPipelineDepth) { + this.underlyingPipelineDepth = underlyingPipelineDepth; + } + + public String getUnderlyingPipelineDiameter() { + return underlyingPipelineDiameter; + } + + public void setUnderlyingPipelineDiameter(String underlyingPipelineDiameter) { + this.underlyingPipelineDiameter = underlyingPipelineDiameter; + } + + public String getUnderlyingPipelineMaterial() { + return underlyingPipelineMaterial; + } + + public void setUnderlyingPipelineMaterial(String underlyingPipelineMaterial) { + this.underlyingPipelineMaterial = underlyingPipelineMaterial; + } + + public String getObjectType() { + return objectType; + } + + public void setObjectType(String objectType) { + this.objectType = objectType; + } + + public String getColor() { + return color; + } + + public void setColor(String color) { + this.color = color; + } + + public String getImagePath() { + return imagePath; + } + + public void setImagePath(String imagePath) { + this.imagePath = imagePath; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java deleted file mode 100644 index 3f2fcdc..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java +++ /dev/null @@ -1,327 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 从平台下载的标识器本地库实体类 - */ -@Entity -public class MarkerLocalBean { - @Id(autoincrement = true) - private Long id;//本地库主键ID - - // 管线类型 - private String pipelineType; - // 管线直径 - private String pipelineDiameter; - // 管材 - private String pipelineMaterial; - // 埋设方式 - private String buryMethod; - // 埋深 - private String buryDepth; - // 所属区域 - private String area; - // 所属线路 - private String line; - // 所属道路 - private String road; - // 建设年代 - private String constructTime; - // 权属单位 - private String owner; - //标识对象ID,无实际用途 - @Deprecated - private String objectId; - // 标识器ID - private String markerId; - // 标识器类型 - private String markerType; - // 标识器埋深 - private String markerDepth; - // 安装部门 - private String installationDept; - // 经度 - private String lng; - // 纬度 - private String lat; - //最后修改时间,更新时间 - private String updateTime; - // 备注信息 - private String remark; - // 下层管线类型 - private String underlyingPipelineType; - // 下层埋深 - private String underlyingPipelineDepth; - // 下层管径 - private String underlyingPipelineDiameter; - // 下层管材 - private String underlyingPipelineMaterial; - //标识对象类型 - private String objectType; - // 颜色 - private String color; - // 图片路径 - private String imagePath; - - @Generated(hash = 1479045776) - public MarkerLocalBean(Long id, String pipelineType, String pipelineDiameter, - String pipelineMaterial, String buryMethod, String buryDepth, - String area, String line, String road, String constructTime, - String owner, String objectId, String markerId, String markerType, - String markerDepth, String installationDept, String lng, String lat, - String updateTime, String remark, String underlyingPipelineType, - String underlyingPipelineDepth, String underlyingPipelineDiameter, - String underlyingPipelineMaterial, String objectType, String color, - String imagePath) { - this.id = id; - this.pipelineType = pipelineType; - this.pipelineDiameter = pipelineDiameter; - this.pipelineMaterial = pipelineMaterial; - this.buryMethod = buryMethod; - this.buryDepth = buryDepth; - this.area = area; - this.line = line; - this.road = road; - this.constructTime = constructTime; - this.owner = owner; - this.objectId = objectId; - this.markerId = markerId; - this.markerType = markerType; - this.markerDepth = markerDepth; - this.installationDept = installationDept; - this.lng = lng; - this.lat = lat; - this.updateTime = updateTime; - this.remark = remark; - this.underlyingPipelineType = underlyingPipelineType; - this.underlyingPipelineDepth = underlyingPipelineDepth; - this.underlyingPipelineDiameter = underlyingPipelineDiameter; - this.underlyingPipelineMaterial = underlyingPipelineMaterial; - this.objectType = objectType; - this.color = color; - this.imagePath = imagePath; - } - - @Generated(hash = 1538606012) - public MarkerLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getPipelineType() { - return this.pipelineType; - } - - public void setPipelineType(String pipelineType) { - this.pipelineType = pipelineType; - } - - public String getPipelineDiameter() { - return this.pipelineDiameter; - } - - public void setPipelineDiameter(String pipelineDiameter) { - this.pipelineDiameter = pipelineDiameter; - } - - public String getPipelineMaterial() { - return this.pipelineMaterial; - } - - public void setPipelineMaterial(String pipelineMaterial) { - this.pipelineMaterial = pipelineMaterial; - } - - public String getBuryMethod() { - return this.buryMethod; - } - - public void setBuryMethod(String buryMethod) { - this.buryMethod = buryMethod; - } - - public String getBuryDepth() { - return this.buryDepth; - } - - public void setBuryDepth(String buryDepth) { - this.buryDepth = buryDepth; - } - - public String getArea() { - return this.area; - } - - public void setArea(String area) { - this.area = area; - } - - public String getLine() { - return this.line; - } - - public void setLine(String line) { - this.line = line; - } - - public String getRoad() { - return this.road; - } - - public void setRoad(String road) { - this.road = road; - } - - public String getConstructTime() { - return this.constructTime; - } - - public void setConstructTime(String constructTime) { - this.constructTime = constructTime; - } - - public String getOwner() { - return this.owner; - } - - public void setOwner(String owner) { - this.owner = owner; - } - - public String getObjectId() { - return this.objectId; - } - - public void setObjectId(String objectId) { - this.objectId = objectId; - } - - public String getMarkerId() { - return this.markerId; - } - - public void setMarkerId(String markerId) { - this.markerId = markerId; - } - - public String getMarkerType() { - return this.markerType; - } - - public void setMarkerType(String markerType) { - this.markerType = markerType; - } - - public String getMarkerDepth() { - return this.markerDepth; - } - - public void setMarkerDepth(String markerDepth) { - this.markerDepth = markerDepth; - } - - public String getInstallationDept() { - return this.installationDept; - } - - public void setInstallationDept(String installationDept) { - this.installationDept = installationDept; - } - - public String getLng() { - return this.lng; - } - - public void setLng(String lng) { - this.lng = lng; - } - - public String getLat() { - return this.lat; - } - - public void setLat(String lat) { - this.lat = lat; - } - - public String getUpdateTime() { - return this.updateTime; - } - - public void setUpdateTime(String updateTime) { - this.updateTime = updateTime; - } - - public String getRemark() { - return this.remark; - } - - public void setRemark(String remark) { - this.remark = remark; - } - - public String getUnderlyingPipelineType() { - return this.underlyingPipelineType; - } - - public void setUnderlyingPipelineType(String underlyingPipelineType) { - this.underlyingPipelineType = underlyingPipelineType; - } - - public String getUnderlyingPipelineDepth() { - return this.underlyingPipelineDepth; - } - - public void setUnderlyingPipelineDepth(String underlyingPipelineDepth) { - this.underlyingPipelineDepth = underlyingPipelineDepth; - } - - public String getUnderlyingPipelineDiameter() { - return this.underlyingPipelineDiameter; - } - - public void setUnderlyingPipelineDiameter(String underlyingPipelineDiameter) { - this.underlyingPipelineDiameter = underlyingPipelineDiameter; - } - - public String getUnderlyingPipelineMaterial() { - return this.underlyingPipelineMaterial; - } - - public void setUnderlyingPipelineMaterial(String underlyingPipelineMaterial) { - this.underlyingPipelineMaterial = underlyingPipelineMaterial; - } - - public String getObjectType() { - return this.objectType; - } - - public void setObjectType(String objectType) { - this.objectType = objectType; - } - - public String getColor() { - return this.color; - } - - public void setColor(String color) { - this.color = color; - } - - public String getImagePath() { - return this.imagePath; - } - - public void setImagePath(String imagePath) { - this.imagePath = imagePath; - } -} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java new file mode 100644 index 0000000..5c88fdf --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java @@ -0,0 +1,93 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 巡检任务本地库实体类,不包含任务里面需要巡检的标识器信息 + */ +@Entity(tableName = "task_detail") +public class TaskBean { + @PrimaryKey(autoGenerate = true) + private long id;//主键ID + private String taskCode; // 任务编号 + private String description; // 任务名称 + private String createTime; // 任务创建的时间 + private String status; // 任务状态 + private String createUserName; // 任务创建者名称 + private String startTime; // 任务被开始执行的时间 + private String endTime; // 任务执行结束的时间 + private String isFree; // 是否自由巡检。1-是,0-否 + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getTaskCode() { + return taskCode; + } + + public void setTaskCode(String taskCode) { + this.taskCode = taskCode; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getCreateUserName() { + return createUserName; + } + + public void setCreateUserName(String createUserName) { + this.createUserName = createUserName; + } + + public String getStartTime() { + return startTime; + } + + public void setStartTime(String startTime) { + this.startTime = startTime; + } + + public String getEndTime() { + return endTime; + } + + public void setEndTime(String endTime) { + this.endTime = endTime; + } + + public String getIsFree() { + return isFree; + } + + public void setIsFree(String isFree) { + this.isFree = isFree; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java deleted file mode 100644 index 91737b3..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java +++ /dev/null @@ -1,114 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 巡检任务本地库实体类,不包含任务里面需要巡检的标识器信息 - */ -@Entity -public class TaskLocalBean { - @Id - private Long id;//任务ID - - private String taskCode;//任务编号 - private String description;//任务名称 - private String createTime;//任务创建的时间 - private String status;//任务状态 - private String createUserName;//任务创建者名称 - private String startTime;//任务被开始执行的时间 - private String endTime;//任务执行结束的时间 - private String isFreeTask;//是否自由巡检。1-是,0-否 - - @Generated(hash = 1482022528) - public TaskLocalBean(Long id, String taskCode, String description, - String createTime, String status, String createUserName, - String startTime, String endTime, String isFreeTask) { - this.id = id; - this.taskCode = taskCode; - this.description = description; - this.createTime = createTime; - this.status = status; - this.createUserName = createUserName; - this.startTime = startTime; - this.endTime = endTime; - this.isFreeTask = isFreeTask; - } - - @Generated(hash = 949704588) - public TaskLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getTaskCode() { - return this.taskCode; - } - - public void setTaskCode(String taskCode) { - this.taskCode = taskCode; - } - - public String getDescription() { - return this.description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getCreateTime() { - return this.createTime; - } - - public void setCreateTime(String createTime) { - this.createTime = createTime; - } - - public String getStatus() { - return this.status; - } - - public void setStatus(String status) { - this.status = status; - } - - public String getCreateUserName() { - return this.createUserName; - } - - public void setCreateUserName(String createUserName) { - this.createUserName = createUserName; - } - - public String getStartTime() { - return this.startTime; - } - - public void setStartTime(String startTime) { - this.startTime = startTime; - } - - public String getEndTime() { - return this.endTime; - } - - public void setEndTime(String endTime) { - this.endTime = endTime; - } - - public String getIsFreeTask() { - return this.isFreeTask; - } - - public void setIsFreeTask(String isFreeTask) { - this.isFreeTask = isFreeTask; - } -} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerBean.java new file mode 100644 index 0000000..c563a60 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerBean.java @@ -0,0 +1,110 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 巡检任务里面需要巡检的标识器信息本地库实体类 + */ +@Entity(tableName = "task_marker_info") +public class TaskMarkerBean { + //标识器后台库的主键ID,不是标识器实际ID + @PrimaryKey(autoGenerate = true) + private long id; + + /** + * 任务ID,通过此字段关联[TaskBean.id] + */ + private String taskId; + + /** + * 任务Code,通过此字段关联[TaskBean.taskCode] + *

+ *

+ * 双重验证,防止出现同时刻重复的情况 + */ + private String taskCode; + + /** + * 对应后台字段[TaskModel.MessageModel.TaskDetailInfosModel.markerIdReal],也就是探测仪扫描出来的ID + */ + private String markerId; + + private Double lng; + private Double lat; + + /** + * 是否已被探测到 + * 1-是,0-否 + */ + private String isDetected; + + /** + * 被探测到的时间,对应后台字段[TaskModel.MessageModel.TaskDetailInfosModel.finishTime] + */ + private String detectedTime; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getTaskId() { + return taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getTaskCode() { + return taskCode; + } + + public void setTaskCode(String taskCode) { + this.taskCode = taskCode; + } + + public String getMarkerId() { + return markerId; + } + + public void setMarkerId(String markerId) { + this.markerId = markerId; + } + + public Double getLng() { + return lng; + } + + public void setLng(Double lng) { + this.lng = lng; + } + + public Double getLat() { + return lat; + } + + public void setLat(Double lat) { + this.lat = lat; + } + + public String getIsDetected() { + return isDetected; + } + + public void setIsDetected(String isDetected) { + this.isDetected = isDetected; + } + + public String getDetectedTime() { + return detectedTime; + } + + public void setDetectedTime(String detectedTime) { + this.detectedTime = detectedTime; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerLocalBean.java deleted file mode 100644 index de9f459..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerLocalBean.java +++ /dev/null @@ -1,128 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import com.casic.common.detector.gd.model.TaskModel; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 巡检任务里面需要巡检的标识器信息本地库实体类 - */ -@Entity -public class TaskMarkerLocalBean { - @Id - private Long id;//标识器后台库的主键ID,不是标识器实际ID - - /** - * 任务ID,通过此字段关联{@link TaskLocalBean#id} - */ - private String taskId; - - /** - * 任务Code,通过此字段关联{@link TaskLocalBean#taskCode} - *

- * 双重验证,防止出现同时刻重复的情况 - */ - private String taskCode; - - /** - * 对应后台字段{@link TaskModel.MessageModel.TaskDetailInfosModel#markerIdReal},也就是探测仪扫描出来的ID - */ - private String markerId; - - private double lng; - private double lat; - - /** - * 是否已被探测到 - * 1-是,0-否 - */ - private String isDetected; - - /** - * 被探测到的时间,对应后台字段{@link TaskModel.MessageModel.TaskDetailInfosModel#finishTime} - */ - private String detectedTime; - - @Generated(hash = 677328533) - public TaskMarkerLocalBean(Long id, String taskId, String taskCode, String markerId, - double lng, double lat, String isDetected, String detectedTime) { - this.id = id; - this.taskId = taskId; - this.taskCode = taskCode; - this.markerId = markerId; - this.lng = lng; - this.lat = lat; - this.isDetected = isDetected; - this.detectedTime = detectedTime; - } - - @Generated(hash = 1162404642) - public TaskMarkerLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getTaskId() { - return this.taskId; - } - - public void setTaskId(String taskId) { - this.taskId = taskId; - } - - public String getTaskCode() { - return this.taskCode; - } - - public void setTaskCode(String taskCode) { - this.taskCode = taskCode; - } - - public String getMarkerId() { - return this.markerId; - } - - public void setMarkerId(String markerId) { - this.markerId = markerId; - } - - public double getLng() { - return this.lng; - } - - public void setLng(double lng) { - this.lng = lng; - } - - public double getLat() { - return this.lat; - } - - public void setLat(double lat) { - this.lat = lat; - } - - public String getIsDetected() { - return this.isDetected; - } - - public void setIsDetected(String isDetected) { - this.isDetected = isDetected; - } - - public String getDetectedTime() { - return this.detectedTime; - } - - public void setDetectedTime(String detectedTime) { - this.detectedTime = detectedTime; - } -} diff --git a/app/src/main/java/com/casic/common/detector/gd/dao/MarkerBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/dao/MarkerBeanDao.java new file mode 100644 index 0000000..2beb7ed --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/dao/MarkerBeanDao.java @@ -0,0 +1,29 @@ +package com.casic.common.detector.gd.dao; + +import androidx.room.Dao; +import androidx.room.Insert; +import androidx.room.Query; +import androidx.room.RawQuery; +import androidx.sqlite.db.SupportSQLiteQuery; + +import com.casic.common.detector.gd.bean.MarkerBean; + +import java.util.List; + +@Dao +public interface MarkerBeanDao { + @Query("DELETE FROM marker_detail") + void deleteAll(); + + @Insert + void insert(MarkerBean marker); + + @Query("SELECT * FROM marker_detail") + List loadAll(); + + @Query("SELECT * FROM marker_detail WHERE markerId = :markerId") + List queryMarkerById(String markerId); + + @RawQuery + List loadMarkersByCondition(SupportSQLiteQuery query); +} diff --git a/app/src/main/java/com/casic/common/detector/gd/dao/TaskBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/dao/TaskBeanDao.java new file mode 100644 index 0000000..9c70ac2 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/dao/TaskBeanDao.java @@ -0,0 +1,120 @@ +package com.casic.common.detector.gd.dao; + +import androidx.room.Dao; +import androidx.room.Insert; +import androidx.room.Query; +import androidx.room.Transaction; + +import com.casic.common.detector.gd.bean.TaskBean; +import com.casic.common.detector.gd.bean.TaskMarkerBean; +import com.casic.common.detector.gd.model.TaskDetailLocalModel; +import com.casic.common.detector.gd.model.TaskModel; +import com.casic.common.detector.gd.utils.LocaleConstant; +import com.pengxh.kt.lite.utils.SaveKeyValues; + +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Locale; + +@Dao +public interface TaskBeanDao { + @Query("SELECT COUNT(*) FROM task_detail WHERE id = :taskId") + int isTaskExist(long taskId); + + @Insert + void insert(TaskBean task); + + default void saveTask(Long taskId, String taskName) { + if (isTaskExist(taskId) == 0) { + TaskBean task = new TaskBean(); + task.setId(taskId); + task.setTaskCode(new SimpleDateFormat("yyyyMMddHHmmss", Locale.CHINA).format(new Date())); + task.setDescription(taskName); + String time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA).format(new Date()); + task.setCreateTime(time); + task.setStatus("0"); + String userName = (String) SaveKeyValues.INSTANCE.getValue(LocaleConstant.USER_NAME, ""); + task.setCreateUserName(userName); + task.setStartTime(time); + task.setEndTime(""); + task.setIsFree("1"); + insert(task); + } + } + + default void saveTask(TaskModel.MessageModel model) { + TaskBean task = new TaskBean(); + task.setId(model.getId()); + task.setTaskCode(model.getTaskCode()); + task.setDescription(model.getDescription()); + task.setCreateTime(model.getDeployDate()); + task.setStatus(model.getStatus()); + task.setCreateUserName(model.getCreatorName()); + task.setStartTime(model.getBeginDate()); + task.setEndTime(model.getEndDate()); + task.setIsFree("0"); + if (isTaskExist(task.getId()) == 0) { + insert(task); + } + } + + @Query("SELECT * FROM task_detail") + List loadAll(); + + @Transaction + default ArrayList loadLocalTask(TaskMarkerBeanDao taskMarkerBeanDao) { + ArrayList result = new ArrayList<>(); + List tasks = loadAll(); + for (TaskBean it : tasks) { + TaskDetailLocalModel model = new TaskDetailLocalModel(); + model.setTaskId(String.valueOf(it.getId())); + model.setTaskCode(it.getTaskCode()); + model.setDescription(it.getDescription()); + model.setCreateTime(it.getCreateTime()); + model.setStatus(it.getStatus()); + model.setCreateUserName(it.getCreateUserName()); + model.setIsFreeTask(it.getIsFree()); + ArrayList results = new ArrayList<>(); + if ("0".equals(it.getIsFree())) { + // 非自由巡检才有Marker + List markers = taskMarkerBeanDao.getMarkersByIdAndCode(String.valueOf(it.getId()), it.getTaskCode()); + for (TaskMarkerBean marker : markers) { + TaskDetailLocalModel.TaskMarkerLocalModel localModel = new TaskDetailLocalModel.TaskMarkerLocalModel(); + localModel.setMarkerId(marker.getMarkerId()); + localModel.setLng(marker.getLng()); + localModel.setLat(marker.getLat()); + localModel.setIsDetected(marker.getIsDetected()); + localModel.setDetectedTime(marker.getDetectedTime()); + + results.add(localModel); + } + } + model.setMarkerModels(results); + result.add(model); + } + return result; + } + + @Query("DELETE FROM task_detail WHERE id = :taskId AND taskCode = :taskCode") + void deleteTaskById(long taskId, String taskCode); + + @Transaction + default void deleteLocalTaskById(long taskId, String taskCode, TaskMarkerBeanDao taskMarkerBeanDao) { + TaskBean task = loadAll().stream() + .filter(it -> it.getId() == taskId && taskCode.equals(it.getTaskCode())) + .findFirst() + .orElse(null); + if (task == null) return; + deleteTaskById(taskId, taskCode); + + // 删除此任务关联的Marker。非自由巡检才有Marker + if ("0".equals(task.getIsFree())) { + List markers = taskMarkerBeanDao.getMarkersByIdAndCode(String.valueOf(task.getId()), task.getTaskCode()); + for (TaskMarkerBean marker : markers) { + taskMarkerBeanDao.delete(marker); + } + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/dao/TaskMarkerBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/dao/TaskMarkerBeanDao.java new file mode 100644 index 0000000..cc2156a --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/dao/TaskMarkerBeanDao.java @@ -0,0 +1,52 @@ +package com.casic.common.detector.gd.dao; + +import androidx.room.Dao; +import androidx.room.Delete; +import androidx.room.Insert; +import androidx.room.Query; +import androidx.room.Update; + +import com.casic.common.detector.gd.bean.TaskMarkerBean; +import com.casic.common.detector.gd.model.TaskModel; + +import java.util.List; + +@Dao +public interface TaskMarkerBeanDao { + + @Insert + void insert(TaskMarkerBean marker); + + @Query("SELECT COUNT(*) FROM task_marker_info WHERE id = :markerId") + int isMarkerExist(String markerId); + + default void saveTaskMarker(long taskId, String taskCode, TaskModel.MessageModel.TaskDetailInfosModel marker) { + if (isMarkerExist(marker.getMarkerId()) == 0) { + TaskMarkerBean bean = new TaskMarkerBean(); + bean.setId(marker.getId()); + bean.setTaskId(String.valueOf(taskId)); + bean.setTaskCode(taskCode); + bean.setMarkerId(marker.getMarkerIdReal()); + bean.setLng(marker.getLongitude()); + bean.setLat(marker.getLatitude()); + bean.setIsDetected("0"); + bean.setDetectedTime(""); + insert(bean); + } + } + + @Query("SELECT * FROM task_marker_info WHERE taskId = :taskId AND taskCode = :taskCode AND markerId = :markerId AND isDetected = :state") + TaskMarkerBean queryTaskMarkerById(String taskId, String taskCode, String markerId, String state); + + @Update + void updateLocalTaskMarkerState(TaskMarkerBean marker); + + @Query("SELECT * FROM task_marker_info WHERE isDetected = :state") + List queryMarkerByState(String state); + + @Query("SELECT * FROM task_marker_info WHERE taskId = :taskId AND taskCode = :taskCode") + List getMarkersByIdAndCode(String taskId, String taskCode); + + @Delete + void delete(TaskMarkerBean marker); +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/extensions/Long.kt b/app/src/main/java/com/casic/common/detector/gd/extensions/Long.kt deleted file mode 100644 index 6713d8d..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/extensions/Long.kt +++ /dev/null @@ -1,10 +0,0 @@ -package com.casic.common.detector.gd.extensions - -import java.text.SimpleDateFormat -import java.util.Date -import java.util.Locale - -fun Long.createTaskCode(): String { - val dateFormat = SimpleDateFormat("yyyyMMddHHmmss", Locale.CHINA) - return dateFormat.format(Date(this)) -} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoMaster.java b/app/src/main/java/com/casic/common/detector/gd/greendao/DaoMaster.java deleted file mode 100644 index 6ab94b3..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoMaster.java +++ /dev/null @@ -1,102 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import android.content.Context; -import android.database.sqlite.SQLiteDatabase; -import android.database.sqlite.SQLiteDatabase.CursorFactory; -import android.util.Log; - -import org.greenrobot.greendao.AbstractDaoMaster; -import org.greenrobot.greendao.database.StandardDatabase; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.database.DatabaseOpenHelper; -import org.greenrobot.greendao.identityscope.IdentityScopeType; - - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** - * Master of DAO (schema version 1): knows all DAOs. - */ -public class DaoMaster extends AbstractDaoMaster { - public static final int SCHEMA_VERSION = 1; - - /** Creates underlying database table using DAOs. */ - public static void createAllTables(Database db, boolean ifNotExists) { - MarkerLocalBeanDao.createTable(db, ifNotExists); - TaskLocalBeanDao.createTable(db, ifNotExists); - TaskMarkerLocalBeanDao.createTable(db, ifNotExists); - } - - /** Drops underlying database table using DAOs. */ - public static void dropAllTables(Database db, boolean ifExists) { - MarkerLocalBeanDao.dropTable(db, ifExists); - TaskLocalBeanDao.dropTable(db, ifExists); - TaskMarkerLocalBeanDao.dropTable(db, ifExists); - } - - /** - * WARNING: Drops all table on Upgrade! Use only during development. - * Convenience method using a {@link DevOpenHelper}. - */ - public static DaoSession newDevSession(Context context, String name) { - Database db = new DevOpenHelper(context, name).getWritableDb(); - DaoMaster daoMaster = new DaoMaster(db); - return daoMaster.newSession(); - } - - public DaoMaster(SQLiteDatabase db) { - this(new StandardDatabase(db)); - } - - public DaoMaster(Database db) { - super(db, SCHEMA_VERSION); - registerDaoClass(MarkerLocalBeanDao.class); - registerDaoClass(TaskLocalBeanDao.class); - registerDaoClass(TaskMarkerLocalBeanDao.class); - } - - public DaoSession newSession() { - return new DaoSession(db, IdentityScopeType.Session, daoConfigMap); - } - - public DaoSession newSession(IdentityScopeType type) { - return new DaoSession(db, type, daoConfigMap); - } - - /** - * Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} - - */ - public static abstract class OpenHelper extends DatabaseOpenHelper { - public OpenHelper(Context context, String name) { - super(context, name, SCHEMA_VERSION); - } - - public OpenHelper(Context context, String name, CursorFactory factory) { - super(context, name, factory, SCHEMA_VERSION); - } - - @Override - public void onCreate(Database db) { - Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION); - createAllTables(db, false); - } - } - - /** WARNING: Drops all table on Upgrade! Use only during development. */ - public static class DevOpenHelper extends OpenHelper { - public DevOpenHelper(Context context, String name) { - super(context, name); - } - - public DevOpenHelper(Context context, String name, CursorFactory factory) { - super(context, name, factory); - } - - @Override - public void onUpgrade(Database db, int oldVersion, int newVersion) { - Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables"); - dropAllTables(db, true); - onCreate(db); - } - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoSession.java b/app/src/main/java/com/casic/common/detector/gd/greendao/DaoSession.java deleted file mode 100644 index c8b1a20..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoSession.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import java.util.Map; - -import org.greenrobot.greendao.AbstractDao; -import org.greenrobot.greendao.AbstractDaoSession; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.identityscope.IdentityScopeType; -import org.greenrobot.greendao.internal.DaoConfig; - -import com.casic.common.detector.gd.bean.MarkerLocalBean; -import com.casic.common.detector.gd.bean.TaskLocalBean; -import com.casic.common.detector.gd.bean.TaskMarkerLocalBean; - -import com.casic.common.detector.gd.greendao.MarkerLocalBeanDao; -import com.casic.common.detector.gd.greendao.TaskLocalBeanDao; -import com.casic.common.detector.gd.greendao.TaskMarkerLocalBeanDao; - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. - -/** - * {@inheritDoc} - * - * @see org.greenrobot.greendao.AbstractDaoSession - */ -public class DaoSession extends AbstractDaoSession { - - private final DaoConfig markerLocalBeanDaoConfig; - private final DaoConfig taskLocalBeanDaoConfig; - private final DaoConfig taskMarkerLocalBeanDaoConfig; - - private final MarkerLocalBeanDao markerLocalBeanDao; - private final TaskLocalBeanDao taskLocalBeanDao; - private final TaskMarkerLocalBeanDao taskMarkerLocalBeanDao; - - public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> - daoConfigMap) { - super(db); - - markerLocalBeanDaoConfig = daoConfigMap.get(MarkerLocalBeanDao.class).clone(); - markerLocalBeanDaoConfig.initIdentityScope(type); - - taskLocalBeanDaoConfig = daoConfigMap.get(TaskLocalBeanDao.class).clone(); - taskLocalBeanDaoConfig.initIdentityScope(type); - - taskMarkerLocalBeanDaoConfig = daoConfigMap.get(TaskMarkerLocalBeanDao.class).clone(); - taskMarkerLocalBeanDaoConfig.initIdentityScope(type); - - markerLocalBeanDao = new MarkerLocalBeanDao(markerLocalBeanDaoConfig, this); - taskLocalBeanDao = new TaskLocalBeanDao(taskLocalBeanDaoConfig, this); - taskMarkerLocalBeanDao = new TaskMarkerLocalBeanDao(taskMarkerLocalBeanDaoConfig, this); - - registerDao(MarkerLocalBean.class, markerLocalBeanDao); - registerDao(TaskLocalBean.class, taskLocalBeanDao); - registerDao(TaskMarkerLocalBean.class, taskMarkerLocalBeanDao); - } - - public void clear() { - markerLocalBeanDaoConfig.clearIdentityScope(); - taskLocalBeanDaoConfig.clearIdentityScope(); - taskMarkerLocalBeanDaoConfig.clearIdentityScope(); - } - - public MarkerLocalBeanDao getMarkerLocalBeanDao() { - return markerLocalBeanDao; - } - - public TaskLocalBeanDao getTaskLocalBeanDao() { - return taskLocalBeanDao; - } - - public TaskMarkerLocalBeanDao getTaskMarkerLocalBeanDao() { - return taskMarkerLocalBeanDao; - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/MarkerLocalBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/greendao/MarkerLocalBeanDao.java deleted file mode 100644 index 2f792c3..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/MarkerLocalBeanDao.java +++ /dev/null @@ -1,479 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import android.database.Cursor; -import android.database.sqlite.SQLiteStatement; - -import org.greenrobot.greendao.AbstractDao; -import org.greenrobot.greendao.Property; -import org.greenrobot.greendao.internal.DaoConfig; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.database.DatabaseStatement; - -import com.casic.common.detector.gd.bean.MarkerLocalBean; - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** - * DAO for table "MARKER_LOCAL_BEAN". -*/ -public class MarkerLocalBeanDao extends AbstractDao { - - public static final String TABLENAME = "MARKER_LOCAL_BEAN"; - - /** - * Properties of entity MarkerLocalBean.
- * Can be used for QueryBuilder and for referencing column names. - */ - public static class Properties { - public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property PipelineType = new Property(1, String.class, "pipelineType", false, "PIPELINE_TYPE"); - public final static Property PipelineDiameter = new Property(2, String.class, "pipelineDiameter", false, "PIPELINE_DIAMETER"); - public final static Property PipelineMaterial = new Property(3, String.class, "pipelineMaterial", false, "PIPELINE_MATERIAL"); - public final static Property BuryMethod = new Property(4, String.class, "buryMethod", false, "BURY_METHOD"); - public final static Property BuryDepth = new Property(5, String.class, "buryDepth", false, "BURY_DEPTH"); - public final static Property Area = new Property(6, String.class, "area", false, "AREA"); - public final static Property Line = new Property(7, String.class, "line", false, "LINE"); - public final static Property Road = new Property(8, String.class, "road", false, "ROAD"); - public final static Property ConstructTime = new Property(9, String.class, "constructTime", false, "CONSTRUCT_TIME"); - public final static Property Owner = new Property(10, String.class, "owner", false, "OWNER"); - public final static Property ObjectId = new Property(11, String.class, "objectId", false, "OBJECT_ID"); - public final static Property MarkerId = new Property(12, String.class, "markerId", false, "MARKER_ID"); - public final static Property MarkerType = new Property(13, String.class, "markerType", false, "MARKER_TYPE"); - public final static Property MarkerDepth = new Property(14, String.class, "markerDepth", false, "MARKER_DEPTH"); - public final static Property InstallationDept = new Property(15, String.class, "installationDept", false, "INSTALLATION_DEPT"); - public final static Property Lng = new Property(16, String.class, "lng", false, "LNG"); - public final static Property Lat = new Property(17, String.class, "lat", false, "LAT"); - public final static Property UpdateTime = new Property(18, String.class, "updateTime", false, "UPDATE_TIME"); - public final static Property Remark = new Property(19, String.class, "remark", false, "REMARK"); - public final static Property UnderlyingPipelineType = new Property(20, String.class, "underlyingPipelineType", false, "UNDERLYING_PIPELINE_TYPE"); - public final static Property UnderlyingPipelineDepth = new Property(21, String.class, "underlyingPipelineDepth", false, "UNDERLYING_PIPELINE_DEPTH"); - public final static Property UnderlyingPipelineDiameter = new Property(22, String.class, "underlyingPipelineDiameter", false, "UNDERLYING_PIPELINE_DIAMETER"); - public final static Property UnderlyingPipelineMaterial = new Property(23, String.class, "underlyingPipelineMaterial", false, "UNDERLYING_PIPELINE_MATERIAL"); - public final static Property ObjectType = new Property(24, String.class, "objectType", false, "OBJECT_TYPE"); - public final static Property Color = new Property(25, String.class, "color", false, "COLOR"); - public final static Property ImagePath = new Property(26, String.class, "imagePath", false, "IMAGE_PATH"); - } - - - public MarkerLocalBeanDao(DaoConfig config) { - super(config); - } - - public MarkerLocalBeanDao(DaoConfig config, DaoSession daoSession) { - super(config, daoSession); - } - - /** Creates the underlying database table. */ - public static void createTable(Database db, boolean ifNotExists) { - String constraint = ifNotExists? "IF NOT EXISTS ": ""; - db.execSQL("CREATE TABLE " + constraint + "\"MARKER_LOCAL_BEAN\" (" + // - "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id - "\"PIPELINE_TYPE\" TEXT," + // 1: pipelineType - "\"PIPELINE_DIAMETER\" TEXT," + // 2: pipelineDiameter - "\"PIPELINE_MATERIAL\" TEXT," + // 3: pipelineMaterial - "\"BURY_METHOD\" TEXT," + // 4: buryMethod - "\"BURY_DEPTH\" TEXT," + // 5: buryDepth - "\"AREA\" TEXT," + // 6: area - "\"LINE\" TEXT," + // 7: line - "\"ROAD\" TEXT," + // 8: road - "\"CONSTRUCT_TIME\" TEXT," + // 9: constructTime - "\"OWNER\" TEXT," + // 10: owner - "\"OBJECT_ID\" TEXT," + // 11: objectId - "\"MARKER_ID\" TEXT," + // 12: markerId - "\"MARKER_TYPE\" TEXT," + // 13: markerType - "\"MARKER_DEPTH\" TEXT," + // 14: markerDepth - "\"INSTALLATION_DEPT\" TEXT," + // 15: installationDept - "\"LNG\" TEXT," + // 16: lng - "\"LAT\" TEXT," + // 17: lat - "\"UPDATE_TIME\" TEXT," + // 18: updateTime - "\"REMARK\" TEXT," + // 19: remark - "\"UNDERLYING_PIPELINE_TYPE\" TEXT," + // 20: underlyingPipelineType - "\"UNDERLYING_PIPELINE_DEPTH\" TEXT," + // 21: underlyingPipelineDepth - "\"UNDERLYING_PIPELINE_DIAMETER\" TEXT," + // 22: underlyingPipelineDiameter - "\"UNDERLYING_PIPELINE_MATERIAL\" TEXT," + // 23: underlyingPipelineMaterial - "\"OBJECT_TYPE\" TEXT," + // 24: objectType - "\"COLOR\" TEXT," + // 25: color - "\"IMAGE_PATH\" TEXT);"); // 26: imagePath - } - - /** Drops the underlying database table. */ - public static void dropTable(Database db, boolean ifExists) { - String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"MARKER_LOCAL_BEAN\""; - db.execSQL(sql); - } - - @Override - protected final void bindValues(DatabaseStatement stmt, MarkerLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String pipelineType = entity.getPipelineType(); - if (pipelineType != null) { - stmt.bindString(2, pipelineType); - } - - String pipelineDiameter = entity.getPipelineDiameter(); - if (pipelineDiameter != null) { - stmt.bindString(3, pipelineDiameter); - } - - String pipelineMaterial = entity.getPipelineMaterial(); - if (pipelineMaterial != null) { - stmt.bindString(4, pipelineMaterial); - } - - String buryMethod = entity.getBuryMethod(); - if (buryMethod != null) { - stmt.bindString(5, buryMethod); - } - - String buryDepth = entity.getBuryDepth(); - if (buryDepth != null) { - stmt.bindString(6, buryDepth); - } - - String area = entity.getArea(); - if (area != null) { - stmt.bindString(7, area); - } - - String line = entity.getLine(); - if (line != null) { - stmt.bindString(8, line); - } - - String road = entity.getRoad(); - if (road != null) { - stmt.bindString(9, road); - } - - String constructTime = entity.getConstructTime(); - if (constructTime != null) { - stmt.bindString(10, constructTime); - } - - String owner = entity.getOwner(); - if (owner != null) { - stmt.bindString(11, owner); - } - - String objectId = entity.getObjectId(); - if (objectId != null) { - stmt.bindString(12, objectId); - } - - String markerId = entity.getMarkerId(); - if (markerId != null) { - stmt.bindString(13, markerId); - } - - String markerType = entity.getMarkerType(); - if (markerType != null) { - stmt.bindString(14, markerType); - } - - String markerDepth = entity.getMarkerDepth(); - if (markerDepth != null) { - stmt.bindString(15, markerDepth); - } - - String installationDept = entity.getInstallationDept(); - if (installationDept != null) { - stmt.bindString(16, installationDept); - } - - String lng = entity.getLng(); - if (lng != null) { - stmt.bindString(17, lng); - } - - String lat = entity.getLat(); - if (lat != null) { - stmt.bindString(18, lat); - } - - String updateTime = entity.getUpdateTime(); - if (updateTime != null) { - stmt.bindString(19, updateTime); - } - - String remark = entity.getRemark(); - if (remark != null) { - stmt.bindString(20, remark); - } - - String underlyingPipelineType = entity.getUnderlyingPipelineType(); - if (underlyingPipelineType != null) { - stmt.bindString(21, underlyingPipelineType); - } - - String underlyingPipelineDepth = entity.getUnderlyingPipelineDepth(); - if (underlyingPipelineDepth != null) { - stmt.bindString(22, underlyingPipelineDepth); - } - - String underlyingPipelineDiameter = entity.getUnderlyingPipelineDiameter(); - if (underlyingPipelineDiameter != null) { - stmt.bindString(23, underlyingPipelineDiameter); - } - - String underlyingPipelineMaterial = entity.getUnderlyingPipelineMaterial(); - if (underlyingPipelineMaterial != null) { - stmt.bindString(24, underlyingPipelineMaterial); - } - - String objectType = entity.getObjectType(); - if (objectType != null) { - stmt.bindString(25, objectType); - } - - String color = entity.getColor(); - if (color != null) { - stmt.bindString(26, color); - } - - String imagePath = entity.getImagePath(); - if (imagePath != null) { - stmt.bindString(27, imagePath); - } - } - - @Override - protected final void bindValues(SQLiteStatement stmt, MarkerLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String pipelineType = entity.getPipelineType(); - if (pipelineType != null) { - stmt.bindString(2, pipelineType); - } - - String pipelineDiameter = entity.getPipelineDiameter(); - if (pipelineDiameter != null) { - stmt.bindString(3, pipelineDiameter); - } - - String pipelineMaterial = entity.getPipelineMaterial(); - if (pipelineMaterial != null) { - stmt.bindString(4, pipelineMaterial); - } - - String buryMethod = entity.getBuryMethod(); - if (buryMethod != null) { - stmt.bindString(5, buryMethod); - } - - String buryDepth = entity.getBuryDepth(); - if (buryDepth != null) { - stmt.bindString(6, buryDepth); - } - - String area = entity.getArea(); - if (area != null) { - stmt.bindString(7, area); - } - - String line = entity.getLine(); - if (line != null) { - stmt.bindString(8, line); - } - - String road = entity.getRoad(); - if (road != null) { - stmt.bindString(9, road); - } - - String constructTime = entity.getConstructTime(); - if (constructTime != null) { - stmt.bindString(10, constructTime); - } - - String owner = entity.getOwner(); - if (owner != null) { - stmt.bindString(11, owner); - } - - String objectId = entity.getObjectId(); - if (objectId != null) { - stmt.bindString(12, objectId); - } - - String markerId = entity.getMarkerId(); - if (markerId != null) { - stmt.bindString(13, markerId); - } - - String markerType = entity.getMarkerType(); - if (markerType != null) { - stmt.bindString(14, markerType); - } - - String markerDepth = entity.getMarkerDepth(); - if (markerDepth != null) { - stmt.bindString(15, markerDepth); - } - - String installationDept = entity.getInstallationDept(); - if (installationDept != null) { - stmt.bindString(16, installationDept); - } - - String lng = entity.getLng(); - if (lng != null) { - stmt.bindString(17, lng); - } - - String lat = entity.getLat(); - if (lat != null) { - stmt.bindString(18, lat); - } - - String updateTime = entity.getUpdateTime(); - if (updateTime != null) { - stmt.bindString(19, updateTime); - } - - String remark = entity.getRemark(); - if (remark != null) { - stmt.bindString(20, remark); - } - - String underlyingPipelineType = entity.getUnderlyingPipelineType(); - if (underlyingPipelineType != null) { - stmt.bindString(21, underlyingPipelineType); - } - - String underlyingPipelineDepth = entity.getUnderlyingPipelineDepth(); - if (underlyingPipelineDepth != null) { - stmt.bindString(22, underlyingPipelineDepth); - } - - String underlyingPipelineDiameter = entity.getUnderlyingPipelineDiameter(); - if (underlyingPipelineDiameter != null) { - stmt.bindString(23, underlyingPipelineDiameter); - } - - String underlyingPipelineMaterial = entity.getUnderlyingPipelineMaterial(); - if (underlyingPipelineMaterial != null) { - stmt.bindString(24, underlyingPipelineMaterial); - } - - String objectType = entity.getObjectType(); - if (objectType != null) { - stmt.bindString(25, objectType); - } - - String color = entity.getColor(); - if (color != null) { - stmt.bindString(26, color); - } - - String imagePath = entity.getImagePath(); - if (imagePath != null) { - stmt.bindString(27, imagePath); - } - } - - @Override - public Long readKey(Cursor cursor, int offset) { - return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); - } - - @Override - public MarkerLocalBean readEntity(Cursor cursor, int offset) { - MarkerLocalBean entity = new MarkerLocalBean( // - cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // pipelineType - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // pipelineDiameter - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // pipelineMaterial - cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // buryMethod - cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // buryDepth - cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // area - cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // line - cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // road - cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // constructTime - cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10), // owner - cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11), // objectId - cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12), // markerId - cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13), // markerType - cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14), // markerDepth - cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15), // installationDept - cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16), // lng - cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17), // lat - cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18), // updateTime - cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19), // remark - cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20), // underlyingPipelineType - cursor.isNull(offset + 21) ? null : cursor.getString(offset + 21), // underlyingPipelineDepth - cursor.isNull(offset + 22) ? null : cursor.getString(offset + 22), // underlyingPipelineDiameter - cursor.isNull(offset + 23) ? null : cursor.getString(offset + 23), // underlyingPipelineMaterial - cursor.isNull(offset + 24) ? null : cursor.getString(offset + 24), // objectType - cursor.isNull(offset + 25) ? null : cursor.getString(offset + 25), // color - cursor.isNull(offset + 26) ? null : cursor.getString(offset + 26) // imagePath - ); - return entity; - } - - @Override - public void readEntity(Cursor cursor, MarkerLocalBean entity, int offset) { - entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setPipelineType(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); - entity.setPipelineDiameter(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); - entity.setPipelineMaterial(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); - entity.setBuryMethod(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); - entity.setBuryDepth(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); - entity.setArea(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); - entity.setLine(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); - entity.setRoad(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); - entity.setConstructTime(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9)); - entity.setOwner(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); - entity.setObjectId(cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11)); - entity.setMarkerId(cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12)); - entity.setMarkerType(cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13)); - entity.setMarkerDepth(cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14)); - entity.setInstallationDept(cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15)); - entity.setLng(cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16)); - entity.setLat(cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17)); - entity.setUpdateTime(cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18)); - entity.setRemark(cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19)); - entity.setUnderlyingPipelineType(cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20)); - entity.setUnderlyingPipelineDepth(cursor.isNull(offset + 21) ? null : cursor.getString(offset + 21)); - entity.setUnderlyingPipelineDiameter(cursor.isNull(offset + 22) ? null : cursor.getString(offset + 22)); - entity.setUnderlyingPipelineMaterial(cursor.isNull(offset + 23) ? null : cursor.getString(offset + 23)); - entity.setObjectType(cursor.isNull(offset + 24) ? null : cursor.getString(offset + 24)); - entity.setColor(cursor.isNull(offset + 25) ? null : cursor.getString(offset + 25)); - entity.setImagePath(cursor.isNull(offset + 26) ? null : cursor.getString(offset + 26)); - } - - @Override - protected final Long updateKeyAfterInsert(MarkerLocalBean entity, long rowId) { - entity.setId(rowId); - return rowId; - } - - @Override - public Long getKey(MarkerLocalBean entity) { - if(entity != null) { - return entity.getId(); - } else { - return null; - } - } - - @Override - public boolean hasKey(MarkerLocalBean entity) { - return entity.getId() != null; - } - - @Override - protected final boolean isEntityUpdateable() { - return true; - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/TaskLocalBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/greendao/TaskLocalBeanDao.java deleted file mode 100644 index fb88157..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/TaskLocalBeanDao.java +++ /dev/null @@ -1,227 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import android.database.Cursor; -import android.database.sqlite.SQLiteStatement; - -import org.greenrobot.greendao.AbstractDao; -import org.greenrobot.greendao.Property; -import org.greenrobot.greendao.internal.DaoConfig; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.database.DatabaseStatement; - -import com.casic.common.detector.gd.bean.TaskLocalBean; - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** - * DAO for table "TASK_LOCAL_BEAN". -*/ -public class TaskLocalBeanDao extends AbstractDao { - - public static final String TABLENAME = "TASK_LOCAL_BEAN"; - - /** - * Properties of entity TaskLocalBean.
- * Can be used for QueryBuilder and for referencing column names. - */ - public static class Properties { - public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property TaskCode = new Property(1, String.class, "taskCode", false, "TASK_CODE"); - public final static Property Description = new Property(2, String.class, "description", false, "DESCRIPTION"); - public final static Property CreateTime = new Property(3, String.class, "createTime", false, "CREATE_TIME"); - public final static Property Status = new Property(4, String.class, "status", false, "STATUS"); - public final static Property CreateUserName = new Property(5, String.class, "createUserName", false, "CREATE_USER_NAME"); - public final static Property StartTime = new Property(6, String.class, "startTime", false, "START_TIME"); - public final static Property EndTime = new Property(7, String.class, "endTime", false, "END_TIME"); - public final static Property IsFreeTask = new Property(8, String.class, "isFreeTask", false, "IS_FREE_TASK"); - } - - - public TaskLocalBeanDao(DaoConfig config) { - super(config); - } - - public TaskLocalBeanDao(DaoConfig config, DaoSession daoSession) { - super(config, daoSession); - } - - /** Creates the underlying database table. */ - public static void createTable(Database db, boolean ifNotExists) { - String constraint = ifNotExists? "IF NOT EXISTS ": ""; - db.execSQL("CREATE TABLE " + constraint + "\"TASK_LOCAL_BEAN\" (" + // - "\"_id\" INTEGER PRIMARY KEY ," + // 0: id - "\"TASK_CODE\" TEXT," + // 1: taskCode - "\"DESCRIPTION\" TEXT," + // 2: description - "\"CREATE_TIME\" TEXT," + // 3: createTime - "\"STATUS\" TEXT," + // 4: status - "\"CREATE_USER_NAME\" TEXT," + // 5: createUserName - "\"START_TIME\" TEXT," + // 6: startTime - "\"END_TIME\" TEXT," + // 7: endTime - "\"IS_FREE_TASK\" TEXT);"); // 8: isFreeTask - } - - /** Drops the underlying database table. */ - public static void dropTable(Database db, boolean ifExists) { - String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"TASK_LOCAL_BEAN\""; - db.execSQL(sql); - } - - @Override - protected final void bindValues(DatabaseStatement stmt, TaskLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String taskCode = entity.getTaskCode(); - if (taskCode != null) { - stmt.bindString(2, taskCode); - } - - String description = entity.getDescription(); - if (description != null) { - stmt.bindString(3, description); - } - - String createTime = entity.getCreateTime(); - if (createTime != null) { - stmt.bindString(4, createTime); - } - - String status = entity.getStatus(); - if (status != null) { - stmt.bindString(5, status); - } - - String createUserName = entity.getCreateUserName(); - if (createUserName != null) { - stmt.bindString(6, createUserName); - } - - String startTime = entity.getStartTime(); - if (startTime != null) { - stmt.bindString(7, startTime); - } - - String endTime = entity.getEndTime(); - if (endTime != null) { - stmt.bindString(8, endTime); - } - - String isFreeTask = entity.getIsFreeTask(); - if (isFreeTask != null) { - stmt.bindString(9, isFreeTask); - } - } - - @Override - protected final void bindValues(SQLiteStatement stmt, TaskLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String taskCode = entity.getTaskCode(); - if (taskCode != null) { - stmt.bindString(2, taskCode); - } - - String description = entity.getDescription(); - if (description != null) { - stmt.bindString(3, description); - } - - String createTime = entity.getCreateTime(); - if (createTime != null) { - stmt.bindString(4, createTime); - } - - String status = entity.getStatus(); - if (status != null) { - stmt.bindString(5, status); - } - - String createUserName = entity.getCreateUserName(); - if (createUserName != null) { - stmt.bindString(6, createUserName); - } - - String startTime = entity.getStartTime(); - if (startTime != null) { - stmt.bindString(7, startTime); - } - - String endTime = entity.getEndTime(); - if (endTime != null) { - stmt.bindString(8, endTime); - } - - String isFreeTask = entity.getIsFreeTask(); - if (isFreeTask != null) { - stmt.bindString(9, isFreeTask); - } - } - - @Override - public Long readKey(Cursor cursor, int offset) { - return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); - } - - @Override - public TaskLocalBean readEntity(Cursor cursor, int offset) { - TaskLocalBean entity = new TaskLocalBean( // - cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // taskCode - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // description - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // createTime - cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // status - cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // createUserName - cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // startTime - cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // endTime - cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8) // isFreeTask - ); - return entity; - } - - @Override - public void readEntity(Cursor cursor, TaskLocalBean entity, int offset) { - entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setTaskCode(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); - entity.setDescription(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); - entity.setCreateTime(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); - entity.setStatus(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); - entity.setCreateUserName(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); - entity.setStartTime(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); - entity.setEndTime(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); - entity.setIsFreeTask(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); - } - - @Override - protected final Long updateKeyAfterInsert(TaskLocalBean entity, long rowId) { - entity.setId(rowId); - return rowId; - } - - @Override - public Long getKey(TaskLocalBean entity) { - if(entity != null) { - return entity.getId(); - } else { - return null; - } - } - - @Override - public boolean hasKey(TaskLocalBean entity) { - return entity.getId() != null; - } - - @Override - protected final boolean isEntityUpdateable() { - return true; - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/TaskMarkerLocalBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/greendao/TaskMarkerLocalBeanDao.java deleted file mode 100644 index e96c735..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/TaskMarkerLocalBeanDao.java +++ /dev/null @@ -1,197 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import android.database.Cursor; -import android.database.sqlite.SQLiteStatement; - -import org.greenrobot.greendao.AbstractDao; -import org.greenrobot.greendao.Property; -import org.greenrobot.greendao.internal.DaoConfig; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.database.DatabaseStatement; - -import com.casic.common.detector.gd.bean.TaskMarkerLocalBean; - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** - * DAO for table "TASK_MARKER_LOCAL_BEAN". -*/ -public class TaskMarkerLocalBeanDao extends AbstractDao { - - public static final String TABLENAME = "TASK_MARKER_LOCAL_BEAN"; - - /** - * Properties of entity TaskMarkerLocalBean.
- * Can be used for QueryBuilder and for referencing column names. - */ - public static class Properties { - public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property TaskId = new Property(1, String.class, "taskId", false, "TASK_ID"); - public final static Property TaskCode = new Property(2, String.class, "taskCode", false, "TASK_CODE"); - public final static Property MarkerId = new Property(3, String.class, "markerId", false, "MARKER_ID"); - public final static Property Lng = new Property(4, double.class, "lng", false, "LNG"); - public final static Property Lat = new Property(5, double.class, "lat", false, "LAT"); - public final static Property IsDetected = new Property(6, String.class, "isDetected", false, "IS_DETECTED"); - public final static Property DetectedTime = new Property(7, String.class, "detectedTime", false, "DETECTED_TIME"); - } - - - public TaskMarkerLocalBeanDao(DaoConfig config) { - super(config); - } - - public TaskMarkerLocalBeanDao(DaoConfig config, DaoSession daoSession) { - super(config, daoSession); - } - - /** Creates the underlying database table. */ - public static void createTable(Database db, boolean ifNotExists) { - String constraint = ifNotExists? "IF NOT EXISTS ": ""; - db.execSQL("CREATE TABLE " + constraint + "\"TASK_MARKER_LOCAL_BEAN\" (" + // - "\"_id\" INTEGER PRIMARY KEY ," + // 0: id - "\"TASK_ID\" TEXT," + // 1: taskId - "\"TASK_CODE\" TEXT," + // 2: taskCode - "\"MARKER_ID\" TEXT," + // 3: markerId - "\"LNG\" REAL NOT NULL ," + // 4: lng - "\"LAT\" REAL NOT NULL ," + // 5: lat - "\"IS_DETECTED\" TEXT," + // 6: isDetected - "\"DETECTED_TIME\" TEXT);"); // 7: detectedTime - } - - /** Drops the underlying database table. */ - public static void dropTable(Database db, boolean ifExists) { - String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"TASK_MARKER_LOCAL_BEAN\""; - db.execSQL(sql); - } - - @Override - protected final void bindValues(DatabaseStatement stmt, TaskMarkerLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String taskId = entity.getTaskId(); - if (taskId != null) { - stmt.bindString(2, taskId); - } - - String taskCode = entity.getTaskCode(); - if (taskCode != null) { - stmt.bindString(3, taskCode); - } - - String markerId = entity.getMarkerId(); - if (markerId != null) { - stmt.bindString(4, markerId); - } - stmt.bindDouble(5, entity.getLng()); - stmt.bindDouble(6, entity.getLat()); - - String isDetected = entity.getIsDetected(); - if (isDetected != null) { - stmt.bindString(7, isDetected); - } - - String detectedTime = entity.getDetectedTime(); - if (detectedTime != null) { - stmt.bindString(8, detectedTime); - } - } - - @Override - protected final void bindValues(SQLiteStatement stmt, TaskMarkerLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String taskId = entity.getTaskId(); - if (taskId != null) { - stmt.bindString(2, taskId); - } - - String taskCode = entity.getTaskCode(); - if (taskCode != null) { - stmt.bindString(3, taskCode); - } - - String markerId = entity.getMarkerId(); - if (markerId != null) { - stmt.bindString(4, markerId); - } - stmt.bindDouble(5, entity.getLng()); - stmt.bindDouble(6, entity.getLat()); - - String isDetected = entity.getIsDetected(); - if (isDetected != null) { - stmt.bindString(7, isDetected); - } - - String detectedTime = entity.getDetectedTime(); - if (detectedTime != null) { - stmt.bindString(8, detectedTime); - } - } - - @Override - public Long readKey(Cursor cursor, int offset) { - return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); - } - - @Override - public TaskMarkerLocalBean readEntity(Cursor cursor, int offset) { - TaskMarkerLocalBean entity = new TaskMarkerLocalBean( // - cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // taskId - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // taskCode - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // markerId - cursor.getDouble(offset + 4), // lng - cursor.getDouble(offset + 5), // lat - cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // isDetected - cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7) // detectedTime - ); - return entity; - } - - @Override - public void readEntity(Cursor cursor, TaskMarkerLocalBean entity, int offset) { - entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setTaskId(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); - entity.setTaskCode(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); - entity.setMarkerId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); - entity.setLng(cursor.getDouble(offset + 4)); - entity.setLat(cursor.getDouble(offset + 5)); - entity.setIsDetected(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); - entity.setDetectedTime(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); - } - - @Override - protected final Long updateKeyAfterInsert(TaskMarkerLocalBean entity, long rowId) { - entity.setId(rowId); - return rowId; - } - - @Override - public Long getKey(TaskMarkerLocalBean entity) { - if(entity != null) { - return entity.getId(); - } else { - return null; - } - } - - @Override - public boolean hasKey(TaskMarkerLocalBean entity) { - return entity.getId() != null; - } - - @Override - protected final boolean isEntityUpdateable() { - return true; - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/model/TaskModel.java b/app/src/main/java/com/casic/common/detector/gd/model/TaskModel.java index 6e853ad..67ef5fb 100644 --- a/app/src/main/java/com/casic/common/detector/gd/model/TaskModel.java +++ b/app/src/main/java/com/casic/common/detector/gd/model/TaskModel.java @@ -24,7 +24,7 @@ } public static class MessageModel { - private int id; + private Long id; private String taskCode; private String description; private String deployDate; @@ -38,11 +38,11 @@ private int isValid; private List taskDetailInfos; - public int getId() { + public Long getId() { return id; } - public void setId(int id) { + public void setId(Long id) { this.id = id; } @@ -143,25 +143,25 @@ } public static class TaskDetailInfosModel { - private int id; + private long id; private String taskId; private String taskCode; private Object markerName; - private int markerId; + private String markerId; private String markerIdReal; private double longitude; private double latitude; private int isChecked; private int isNormal; - private Object imagePath; - private Object description; - private Object finishTime; + private String imagePath; + private String description; + private String finishTime; - public int getId() { + public long getId() { return id; } - public void setId(int id) { + public void setId(long id) { this.id = id; } @@ -189,11 +189,11 @@ this.markerName = markerName; } - public int getMarkerId() { + public String getMarkerId() { return markerId; } - public void setMarkerId(int markerId) { + public void setMarkerId(String markerId) { this.markerId = markerId; } @@ -237,27 +237,27 @@ this.isNormal = isNormal; } - public Object getImagePath() { + public String getImagePath() { return imagePath; } - public void setImagePath(Object imagePath) { + public void setImagePath(String imagePath) { this.imagePath = imagePath; } - public Object getDescription() { + public String getDescription() { return description; } - public void setDescription(Object description) { + public void setDescription(String description) { this.description = description; } - public Object getFinishTime() { + public String getFinishTime() { return finishTime; } - public void setFinishTime(Object finishTime) { + public void setFinishTime(String finishTime) { this.finishTime = finishTime; } } diff --git a/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitService.kt index 7522a87..0adad51 100644 --- a/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitService.kt @@ -50,7 +50,7 @@ */ @Multipart @POST("/ems/marker/save-marker-photo.do") - suspend fun installLabel( + suspend fun install( @PartMap jsonMarker: Map, @Part fileBuffer1: MultipartBody.Part?, @Part fileBuffer2: MultipartBody.Part?, diff --git a/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitServiceManager.kt index 5f6c701..ae2a0fa 100644 --- a/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitServiceManager.kt +++ b/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitServiceManager.kt @@ -37,22 +37,28 @@ /** * 获取标识器信息文件 */ - suspend fun getMarkerFile(userId: String, companyId: String): String { - return createApi().getMarkerFile(userId, companyId) + suspend fun getMarkerFile(): String { + val companyId = SaveKeyValues.getValue(LocaleConstant.USER_COMPANY_ID, "") as String + /** + * 后台设计如此,都传companyId + * */ + return createApi().getMarkerFile(companyId, companyId) } /** * 获取巡检工单 */ - suspend fun getTasksByUser(userName: String): String { + suspend fun getTasksByUser(): String { + val userName = SaveKeyValues.getValue(LocaleConstant.USER_NAME, "") as String return createApi().getTasksByUser(userName) } /** * 提交工单 */ - suspend fun uploadTask(userId: String, taskId: String?, state: String): String { + suspend fun uploadTask(taskId: String?, state: String): String { + val userId = SaveKeyValues.getValue(LocaleConstant.USER_ID, "") as String return createApi().uploadTask(userId, taskId.toString(), state) } @@ -60,8 +66,7 @@ * 安装新标识器 * Multipart上传图片,文件,带多参数上传 */ - suspend fun installLabel( - companyId: String, + suspend fun installMarker( recordType: String, markerObjectType: String, pipeMaterial: String, @@ -77,7 +82,6 @@ road: String, constructTime: String, ownerComp: String, - markerObjectId: String, markerId: String, markerType: String, markerDepth: String, @@ -89,6 +93,8 @@ memo: String, realPaths: ArrayList ): String { + val companyId = SaveKeyValues.getValue(LocaleConstant.USER_COMPANY_ID, "") as String + val objectId = SaveKeyValues.getValue(LocaleConstant.OBJECT_ID, "") as String val param = JsonObject() param.addProperty("companyId", companyId) param.addProperty("recordType", recordType) @@ -106,7 +112,7 @@ param.addProperty("road", road) param.addProperty("constructTime", constructTime) param.addProperty("ownerComp", ownerComp) - param.addProperty("markerObjectId", markerObjectId) + param.addProperty("markerObjectId", objectId) param.addProperty("markerId", markerId) param.addProperty("markerType", markerType) param.addProperty("markerDepth", markerDepth) @@ -133,19 +139,19 @@ return when (multiParts.size) { 3 -> { - createApi().installLabel(res, multiParts[0], multiParts[1], multiParts[2]) + createApi().install(res, multiParts[0], multiParts[1], multiParts[2]) } 2 -> { - createApi().installLabel(res, multiParts[0], multiParts[1], null) + createApi().install(res, multiParts[0], multiParts[1], null) } 1 -> { - createApi().installLabel(res, multiParts[0], null, null) + createApi().install(res, multiParts[0], null, null) } else -> { - createApi().installLabel(res, null, null, null) + createApi().install(res, null, null, null) } } } @@ -216,7 +222,7 @@ /** * 上传自由巡检过程中发现的标识器 */ - suspend fun uploadTaskMarker(taskId: String, ids: ArrayList): String { + suspend fun uploadTaskMarker(taskId: Long, ids: ArrayList): String { val param = JsonObject() param.addProperty("taskId", taskId) param.addProperty("ids", ids.joinToString(separator = ",")) diff --git a/app/src/main/java/com/casic/common/detector/gd/service/NtripConnectService.kt b/app/src/main/java/com/casic/common/detector/gd/service/NtripConnectService.kt index de9ac80..20e1a6a 100644 --- a/app/src/main/java/com/casic/common/detector/gd/service/NtripConnectService.kt +++ b/app/src/main/java/com/casic/common/detector/gd/service/NtripConnectService.kt @@ -9,10 +9,6 @@ import android.util.Log import android.view.Gravity import android.widget.Toast -import androidx.lifecycle.Lifecycle -import androidx.lifecycle.LifecycleOwner -import androidx.lifecycle.LifecycleRegistry -import androidx.lifecycle.lifecycleScope import com.casic.common.detector.gd.base.BaseApplication import com.casic.common.detector.gd.extensions.convertToGPGGA import com.casic.common.detector.gd.utils.LocaleConstant @@ -23,26 +19,24 @@ import com.pengxh.kt.lite.utils.WeakReferenceHandler import com.pengxh.kt.lite.utils.socket.tcp.OnTcpConnectStateListener import com.pengxh.kt.lite.utils.socket.tcp.TcpClient +import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.Job import kotlinx.coroutines.launch import java.io.OutputStream import java.nio.charset.StandardCharsets -class NtripConnectService : Service(), LifecycleOwner, OnTcpConnectStateListener, Handler.Callback { +class NtripConnectService : Service(), OnTcpConnectStateListener, Handler.Callback { companion object { var weakReferenceHandler: WeakReferenceHandler? = null } private val kTag = "NtripConnectService" - private val registry = LifecycleRegistry(this) private val socketClient by lazy { TcpClient(this) } private var outStream: OutputStream? = null - - override fun getLifecycle(): Lifecycle { - return registry - } + private val serviceScope = CoroutineScope(Dispatchers.Main + Job()) // 创建一个独立的CoroutineScope override fun onBind(intent: Intent?): IBinder? { return null @@ -117,7 +111,7 @@ * */ val result = String(this, StandardCharsets.UTF_8) if (result.contains("ICY 200 OK")) { - lifecycleScope.launch(Dispatchers.Main) { + serviceScope.launch { "高精度定位服务连接成功".show(this@NtripConnectService) } //连接服务即打开串口 @@ -135,12 +129,12 @@ * Content-Type: text/plain * Connection: clos * */ - lifecycleScope.launch(Dispatchers.Main) { + serviceScope.launch { "差分定位服务鉴权失败,无法解析位置".show(this@NtripConnectService) } } else { //居中显示 - lifecycleScope.launch(Dispatchers.Main) { + serviceScope.launch { val toast = Toast.makeText( this@NtripConnectService, "收到千寻数据,长度:${size}", Toast.LENGTH_SHORT ) @@ -167,7 +161,7 @@ return } - lifecycleScope.launch(Dispatchers.IO) { + serviceScope.launch(Dispatchers.IO) { socketClient.start(remoteHost, remotePort.toInt()) } } diff --git a/app/src/main/java/com/casic/common/detector/gd/utils/DataBaseManager.kt b/app/src/main/java/com/casic/common/detector/gd/utils/DataBaseManager.kt deleted file mode 100644 index aa22759..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/utils/DataBaseManager.kt +++ /dev/null @@ -1,200 +0,0 @@ -package com.casic.common.detector.gd.utils - -import com.casic.common.detector.gd.base.BaseApplication -import com.casic.common.detector.gd.bean.MarkerLocalBean -import com.casic.common.detector.gd.bean.TaskLocalBean -import com.casic.common.detector.gd.bean.TaskMarkerLocalBean -import com.casic.common.detector.gd.greendao.MarkerLocalBeanDao -import com.casic.common.detector.gd.greendao.TaskLocalBeanDao -import com.casic.common.detector.gd.greendao.TaskMarkerLocalBeanDao -import com.casic.common.detector.gd.model.TaskDetailLocalModel -import com.casic.common.detector.gd.model.TaskModel - -class DataBaseManager private constructor() { - companion object { - //Kotlin委托模式双重锁单例 - val get by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) { - DataBaseManager() - } - } - - private var taskLocalBeanDao = BaseApplication.get().getDaoSession().taskLocalBeanDao - private var taskMarkerLocalBeanDao = - BaseApplication.get().getDaoSession().taskMarkerLocalBeanDao - - fun saveTaskInLocale(task: TaskModel.MessageModel) { - val bean = TaskLocalBean() - bean.id = task.id.toLong() - bean.taskCode = task.taskCode - bean.description = task.description - bean.createTime = task.deployDate - bean.status = task.status - bean.createUserName = task.creatorName - if (task.beginDate == null) { - bean.startTime = "" - } - if (task.endDate == null) { - bean.endTime = "" - } - bean.isFreeTask = "0" - if (!bean.isExist()) { - taskLocalBeanDao.insert(bean) - } - } - - fun saveTaskInLocale(bean: TaskLocalBean) { - if (!bean.isExist()) { - taskLocalBeanDao.insert(bean) - } - } - - private fun TaskLocalBean.isExist(): Boolean { - val result = taskLocalBeanDao.queryBuilder().where( - TaskLocalBeanDao.Properties.Id.eq(this.id) - ).list() - return !result.isNullOrEmpty() - } - - fun saveTaskMarkerInLocale( - taskId: Int, taskCode: String, marker: TaskModel.MessageModel.TaskDetailInfosModel - ) { - val bean = TaskMarkerLocalBean() - bean.id = marker.id.toLong() - bean.taskId = taskId.toString() - bean.taskCode = taskCode - bean.markerId = marker.markerIdReal - bean.lng = marker.longitude - bean.lat = marker.latitude - bean.isDetected = "0" - bean.detectedTime = "" - if (!bean.isExist()) { - taskMarkerLocalBeanDao.insert(bean) - } - } - - private fun TaskMarkerLocalBean.isExist(): Boolean { - val result = taskMarkerLocalBeanDao.queryBuilder().where( - TaskMarkerLocalBeanDao.Properties.Id.eq(this.id) - ).list() - return !result.isNullOrEmpty() - } - - fun loadLocalTask(): ArrayList { - val result = ArrayList() - - val tasks = taskLocalBeanDao.loadAll() - tasks.forEach { - val model = TaskDetailLocalModel() - model.taskId = it.id.toString() - model.taskCode = it.taskCode - model.description = it.description - model.createTime = it.createTime - model.status = it.status - model.createUserName = it.createUserName - model.isFreeTask = it.isFreeTask - - val markers = ArrayList() - if (it.isFreeTask == "0") { - //非自由巡检才有Marker - val markerLocalBeans = taskMarkerLocalBeanDao.queryBuilder().where( - TaskMarkerLocalBeanDao.Properties.TaskId.eq(it.id), - TaskMarkerLocalBeanDao.Properties.TaskCode.eq(it.taskCode) - ).list() - markerLocalBeans.forEach { marker -> - val localModel = TaskDetailLocalModel.TaskMarkerLocalModel() - localModel.markerId = marker.markerId - localModel.lng = marker.lng - localModel.lat = marker.lat - localModel.isDetected = marker.isDetected - localModel.detectedTime = marker.detectedTime - - markers.add(localModel) - } - } - model.markerModels = markers - result.add(model) - } - return result - } - - fun deleteLocalTaskById(taskId: String, taskCode: String) { - val task = taskLocalBeanDao.queryBuilder().where( - TaskLocalBeanDao.Properties.Id.eq(taskId), - TaskLocalBeanDao.Properties.TaskCode.eq(taskCode) - ).list().firstOrNull() ?: return - taskLocalBeanDao.delete(task) - - //删除此任务关联的Marker。非自由巡检才有Marker - if (task.isFreeTask == "0") { - val markers = taskMarkerLocalBeanDao.queryBuilder() - .where( - TaskMarkerLocalBeanDao.Properties.TaskId.eq(taskId), - TaskMarkerLocalBeanDao.Properties.TaskCode.eq(taskCode) - ).list() - markers.forEach { - taskMarkerLocalBeanDao.delete(it) - } - } - } - - fun queryTaskMarkerById( - taskId: String, taskCode: String, markerId: String, state: String - ): TaskMarkerLocalBean? { - return taskMarkerLocalBeanDao.queryBuilder() - .where( - TaskMarkerLocalBeanDao.Properties.TaskId.eq(taskId), - TaskMarkerLocalBeanDao.Properties.TaskCode.eq(taskCode), - TaskMarkerLocalBeanDao.Properties.MarkerId.eq(markerId), - TaskMarkerLocalBeanDao.Properties.IsDetected.eq(state) - ).list().firstOrNull() - } - - fun updateLocalTaskMarkerState(marker: TaskMarkerLocalBean) { - marker.isDetected = "1" - taskMarkerLocalBeanDao.update(marker) - } - - fun queryMarkerByState(state: String): List { - return taskMarkerLocalBeanDao.queryBuilder() - .where(TaskMarkerLocalBeanDao.Properties.IsDetected.eq(state)) - .list() - } - - private var markerLocalBeanDao = BaseApplication.get().getDaoSession().markerLocalBeanDao - - fun clearMarkers() { - markerLocalBeanDao.deleteAll() - } - - fun saveMarkerInLocale(bean: MarkerLocalBean) { - markerLocalBeanDao.insert(bean) - } - - fun loadMarkers(): MutableList { - return markerLocalBeanDao.loadAll() - } - - fun loadMarkersByCondition(selectedItem: String, value: String?): MutableList { - val property = when (selectedItem) { - LocaleConstant.SPINNER_ARRAY[0] -> MarkerLocalBeanDao.Properties.MarkerId - LocaleConstant.SPINNER_ARRAY[1] -> MarkerLocalBeanDao.Properties.Area - LocaleConstant.SPINNER_ARRAY[2] -> MarkerLocalBeanDao.Properties.Line - LocaleConstant.SPINNER_ARRAY[3] -> MarkerLocalBeanDao.Properties.Road - LocaleConstant.SPINNER_ARRAY[4] -> MarkerLocalBeanDao.Properties.Owner - LocaleConstant.SPINNER_ARRAY[5] -> MarkerLocalBeanDao.Properties.InstallationDept - LocaleConstant.SPINNER_ARRAY[6] -> MarkerLocalBeanDao.Properties.UpdateTime - else -> MarkerLocalBeanDao.Properties.Remark - } - return if (value == null) { - markerLocalBeanDao.queryBuilder().where(property.isNotNull).list() - } else { - markerLocalBeanDao.queryBuilder().where(property.eq(value)).list() - } - } - - fun queryMarkerById(markerId: String): List { - return markerLocalBeanDao.queryBuilder() - .where(MarkerLocalBeanDao.Properties.MarkerId.eq(markerId)) - .list() - } -} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/utils/DetectorDataBase.java b/app/src/main/java/com/casic/common/detector/gd/utils/DetectorDataBase.java new file mode 100644 index 0000000..f686cac --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/utils/DetectorDataBase.java @@ -0,0 +1,21 @@ +package com.casic.common.detector.gd.utils; + +import androidx.room.Database; +import androidx.room.RoomDatabase; + +import com.casic.common.detector.gd.bean.MarkerBean; +import com.casic.common.detector.gd.bean.TaskBean; +import com.casic.common.detector.gd.bean.TaskMarkerBean; +import com.casic.common.detector.gd.dao.MarkerBeanDao; +import com.casic.common.detector.gd.dao.TaskBeanDao; +import com.casic.common.detector.gd.dao.TaskMarkerBeanDao; + + +@Database(entities = {MarkerBean.class, TaskBean.class, TaskMarkerBean.class}, version = 1) +public abstract class DetectorDataBase extends RoomDatabase { + public abstract MarkerBeanDao markerBeanDao(); + + public abstract TaskBeanDao taskBeanDao(); + + public abstract TaskMarkerBeanDao taskMarkerBeanDao(); +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/utils/ExcelKit.kt b/app/src/main/java/com/casic/common/detector/gd/utils/ExcelKit.kt index 200fac7..015969f 100644 --- a/app/src/main/java/com/casic/common/detector/gd/utils/ExcelKit.kt +++ b/app/src/main/java/com/casic/common/detector/gd/utils/ExcelKit.kt @@ -1,19 +1,19 @@ package com.casic.common.detector.gd.utils -import com.casic.common.detector.gd.bean.MarkerLocalBean +import com.casic.common.detector.gd.base.BaseApplication +import com.casic.common.detector.gd.bean.MarkerBean import jxl.Workbook import jxl.read.biff.BiffException import java.io.File object ExcelKit { - fun read(filePath: String): ArrayList { - val result = ArrayList() + fun read(filePath: String): ArrayList { + val result = ArrayList() try { val workbook = Workbook.getWorkbook(File(filePath)) val sheet = workbook.getSheet(0) - for (i in 1 until sheet.rows) { - val marker = MarkerLocalBean() + val marker = MarkerBean() marker.pipelineType = sheet.getCell(0, i).contents marker.pipelineDiameter = sheet.getCell(1, i).contents marker.pipelineMaterial = sheet.getCell(2, i).contents @@ -40,9 +40,10 @@ marker.objectType = sheet.getCell(23, i).contents marker.color = sheet.getCell(24, i).contents marker.imagePath = sheet.getCell(25, i).contents - - result.add(marker) - DataBaseManager.get.saveMarkerInLocale(marker) + if (!marker.markerId.isNullOrBlank()) { + result.add(marker) + BaseApplication.get().dataBase.markerBeanDao().insert(marker) + } } workbook.close() } catch (e: BiffException) { diff --git a/app/build.gradle b/app/build.gradle index d0cb423..921c8c8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,25 +1,20 @@ import java.text.SimpleDateFormat -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply plugin: 'org.greenrobot.greendao' +plugins { + id('com.android.application') + id('org.jetbrains.kotlin.android') +} android { - compileSdkVersion 33 + namespace 'com.casic.common.detector.gd' + compileSdk 35 defaultConfig { - applicationId "com.casic.common.detector.gd" - minSdkVersion 26 - targetSdkVersion 33 + applicationId 'com.casic.common.detector.gd' + minSdk 26 + targetSdk 35 versionCode 5092 - versionName "5.0.9.2" - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } + versionName '5.0.9.2' } signingConfigs { @@ -31,6 +26,14 @@ } } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + signingConfig signingConfigs.release + } + } + compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 @@ -47,27 +50,16 @@ } } - kotlin { - experimental { - coroutines 'enable' - } - } - buildFeatures { + buildConfig true viewBinding true } - applicationVariants.configureEach { variant -> - variant.outputs.configureEach { - outputFileName = "COM_TCY_" + getBuildDate() + "_" + defaultConfig.versionName + ".apk" + applicationVariants.configureEach { + outputs.configureEach { + outputFileName = 'COM_TCY_' + getBuildDate() + '_' + defaultConfig.versionName + '.apk' } } - - greendao { - schemaVersion 1//数据库版本号 - targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 - daoPackage "${defaultConfig.applicationId}.greendao"//设置DaoMaster、DaoSession、Dao包名 - } } static def getBuildDate() { @@ -76,27 +68,22 @@ } dependencies { - //基础依赖库 - implementation 'com.github.AndroidCoderPeng:Kotlin-lite-lib:1.1.4' - implementation 'androidx.core:core-ktx:1.9.0' - def base_version = "1.6.1" - implementation "androidx.appcompat:appcompat:${base_version}" - implementation "com.google.android.material:material:${base_version}" + implementation 'com.github.AndroidCoderPeng:Kotlin-lite-lib:1.1.5' + implementation 'androidx.core:core-ktx:1.13.1' + implementation 'androidx.appcompat:appcompat:1.7.0' + implementation 'com.google.android.material:material:1.12.0' //Google官方授权框架 implementation 'pub.devrel:easypermissions:3.0.0' - //沉浸式状态栏。基础依赖包,必须要依赖 - implementation 'com.gyf.immersionbar:immersionbar:3.0.0' - //fragment快速实现 - implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0' + //沉浸式状态栏 + implementation 'com.geyifeng.immersionbar:immersionbar:3.2.2' //官方Json解析库 implementation 'com.google.code.gson:gson:2.10.1' - def vm_version = '2.5.1' //Kotlin协程 - implementation "androidx.lifecycle:lifecycle-runtime-ktx:${vm_version}" + implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.2' //MVVM+LiveData - implementation "androidx.lifecycle:lifecycle-livedata-ktx:${vm_version}" - implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:${vm_version}" - implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.6.2' + implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2' + implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' //返回值转换器 implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' @@ -105,9 +92,10 @@ implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' //网络请求和接口封装 implementation 'com.squareup.retrofit2:retrofit:2.9.0' - implementation 'com.squareup.okhttp3:okhttp:4.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.12.0' //数据库框架 - implementation 'org.greenrobot:greendao:3.3.0' + implementation 'androidx.room:room-runtime:2.6.1' + annotationProcessor 'androidx.room:room-compiler:2.5.2' //高德导航、定位、地图三合一 implementation 'com.amap.api:navi-3dmap:latest.integration' //经纬度逆编码 @@ -115,7 +103,7 @@ //excel implementation 'net.sourceforge.jexcelapi:jxl:2.6.12' //图片加载框架 - implementation 'com.github.bumptech.glide:glide:4.9.0' + implementation 'com.github.bumptech.glide:glide:4.12.0' //图片选择框架 implementation 'io.github.lucksiege:pictureselector:v3.11.1' //大图 diff --git a/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt b/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt index 7b695ff..50ba734 100644 --- a/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt +++ b/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt @@ -4,9 +4,9 @@ import android.app.Application import android.os.Bundle import android.util.Log -import com.casic.common.detector.gd.greendao.DaoMaster -import com.casic.common.detector.gd.greendao.DaoSession +import androidx.room.Room.databaseBuilder import com.casic.common.detector.gd.uart.SerialPort +import com.casic.common.detector.gd.utils.DetectorDataBase import com.casic.common.detector.gd.utils.GpioManager import com.pengxh.kt.lite.extensions.show import com.pengxh.kt.lite.utils.SaveKeyValues @@ -43,44 +43,42 @@ private var application: BaseApplication by Delegates.notNull() fun get() = application - - private lateinit var daoSession: DaoSession } + lateinit var dataBase: DetectorDataBase + override fun onCreate() { super.onCreate() application = this SaveKeyValues.initSharedPreferences(this) CrashReport.initCrashReport(this, "01e80d3a74", true) - val devOpenHelper = DaoMaster.DevOpenHelper(this, "Detector.db", null) - val daoMaster = DaoMaster(devOpenHelper.writableDatabase) - daoSession = daoMaster.newSession() + dataBase = databaseBuilder(this, DetectorDataBase::class.java, "Detector.db") + .allowMainThreadQueries() + .build() /** * Open the serial port * */ try { serialPorts.apply { - add(SerialPort(File("/dev/ttysWK1"), 9600, 0)) - //千寻报文数据下发串口号 - add(SerialPort(File("/dev/ttyS1"), 9600, 0)) + add(SerialPort(File("/dev/ttysWK1"), 9600, 0)) //信号通讯串口 + add(SerialPort(File("/dev/ttyS1"), 9600, 0)) //千寻报文数据下发串口号 } Log.d(kTag, "onCreate: 已初始化 ${serialPorts.size} 个串口") } catch (e: SecurityException) { "您没有串口的读写权限!".show(this) + e.printStackTrace() } catch (e: IOException) { "因为不明原因,串口无法打开!".show(this) + e.printStackTrace() } catch (e: InvalidParameterException) { "请检查串口!".show(this) + e.printStackTrace() } registerActivityLifecycleCallbacks(this) } - fun getDaoSession(): DaoSession { - return daoSession - } - override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) { } diff --git a/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt b/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt index 053b9dd..1d0c9e3 100644 --- a/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt +++ b/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt @@ -14,12 +14,10 @@ import com.casic.common.detector.gd.utils.SerialPortCommand import com.pengxh.kt.lite.utils.WeakReferenceHandler import java.io.IOException -import java.util.Timer abstract class SerialPortBaseActivity : AppCompatActivity(), Handler.Callback { private val kTag = "SerialPortBaseActivity" - private val taskTimer by lazy { Timer() } private val weakReferenceHandler by lazy { WeakReferenceHandler(this) } private val serialPorts by lazy { BaseApplication.get().getSerialPorts() } protected lateinit var binding: VB @@ -30,7 +28,6 @@ setContentView(binding.root) setupTopBarLayout() initOnCreate(savedInstanceState) - observeRequestState() initEvent() if (serialPorts.isNotEmpty()) { @@ -71,11 +68,6 @@ abstract fun initOnCreate(savedInstanceState: Bundle?) /** - * 数据请求状态监听 - */ - abstract fun observeRequestState() - - /** * 初始化业务逻辑 */ abstract fun initEvent() diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java new file mode 100644 index 0000000..7a18c20 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java @@ -0,0 +1,255 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 从平台下载的标识器本地库实体类 + */ +@Entity(tableName = "marker_detail") +public class MarkerBean { + @PrimaryKey(autoGenerate = true) + private long id; //主键ID + private String pipelineType; // 管线类型 + private String pipelineDiameter; // 管线直径 + private String pipelineMaterial; // 管材 + private String buryMethod; // 埋设方式 + private String buryDepth; // 埋深 + private String area; // 所属区域 + private String line; // 所属线路 + private String road; // 所属道路 + private String constructTime; // 建设年代 + private String owner; // 权属单位 + private String objectId; // 标识对象ID,无实际用途 + private String markerId; // 标识器ID + private String markerType; // 标识器类型 + private String markerDepth; // 标识器埋深 + private String installationDept; // 安装部门 + private String lng; // 经度 + private String lat; // 纬度 + private String updateTime; // 最后修改时间,更新时间 + private String remark; // 备注信息 + private String underlyingPipelineType; // 下层管线类型 + private String underlyingPipelineDepth; // 下层埋深 + private String underlyingPipelineDiameter; // 下层管径 + private String underlyingPipelineMaterial; // 下层管材 + private String objectType; //标识对象类型 + private String color; // 颜色 + private String imagePath; // 图片路径 + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getPipelineType() { + return pipelineType; + } + + public void setPipelineType(String pipelineType) { + this.pipelineType = pipelineType; + } + + public String getPipelineDiameter() { + return pipelineDiameter; + } + + public void setPipelineDiameter(String pipelineDiameter) { + this.pipelineDiameter = pipelineDiameter; + } + + public String getPipelineMaterial() { + return pipelineMaterial; + } + + public void setPipelineMaterial(String pipelineMaterial) { + this.pipelineMaterial = pipelineMaterial; + } + + public String getBuryMethod() { + return buryMethod; + } + + public void setBuryMethod(String buryMethod) { + this.buryMethod = buryMethod; + } + + public String getBuryDepth() { + return buryDepth; + } + + public void setBuryDepth(String buryDepth) { + this.buryDepth = buryDepth; + } + + public String getArea() { + return area; + } + + public void setArea(String area) { + this.area = area; + } + + public String getLine() { + return line; + } + + public void setLine(String line) { + this.line = line; + } + + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + + public String getConstructTime() { + return constructTime; + } + + public void setConstructTime(String constructTime) { + this.constructTime = constructTime; + } + + public String getOwner() { + return owner; + } + + public void setOwner(String owner) { + this.owner = owner; + } + + public String getObjectId() { + return objectId; + } + + public void setObjectId(String objectId) { + this.objectId = objectId; + } + + public String getMarkerId() { + return markerId; + } + + public void setMarkerId(String markerId) { + this.markerId = markerId; + } + + public String getMarkerType() { + return markerType; + } + + public void setMarkerType(String markerType) { + this.markerType = markerType; + } + + public String getMarkerDepth() { + return markerDepth; + } + + public void setMarkerDepth(String markerDepth) { + this.markerDepth = markerDepth; + } + + public String getInstallationDept() { + return installationDept; + } + + public void setInstallationDept(String installationDept) { + this.installationDept = installationDept; + } + + public String getLng() { + return lng; + } + + public void setLng(String lng) { + this.lng = lng; + } + + public String getLat() { + return lat; + } + + public void setLat(String lat) { + this.lat = lat; + } + + public String getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } + + public String getUnderlyingPipelineType() { + return underlyingPipelineType; + } + + public void setUnderlyingPipelineType(String underlyingPipelineType) { + this.underlyingPipelineType = underlyingPipelineType; + } + + public String getUnderlyingPipelineDepth() { + return underlyingPipelineDepth; + } + + public void setUnderlyingPipelineDepth(String underlyingPipelineDepth) { + this.underlyingPipelineDepth = underlyingPipelineDepth; + } + + public String getUnderlyingPipelineDiameter() { + return underlyingPipelineDiameter; + } + + public void setUnderlyingPipelineDiameter(String underlyingPipelineDiameter) { + this.underlyingPipelineDiameter = underlyingPipelineDiameter; + } + + public String getUnderlyingPipelineMaterial() { + return underlyingPipelineMaterial; + } + + public void setUnderlyingPipelineMaterial(String underlyingPipelineMaterial) { + this.underlyingPipelineMaterial = underlyingPipelineMaterial; + } + + public String getObjectType() { + return objectType; + } + + public void setObjectType(String objectType) { + this.objectType = objectType; + } + + public String getColor() { + return color; + } + + public void setColor(String color) { + this.color = color; + } + + public String getImagePath() { + return imagePath; + } + + public void setImagePath(String imagePath) { + this.imagePath = imagePath; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java deleted file mode 100644 index 3f2fcdc..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java +++ /dev/null @@ -1,327 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 从平台下载的标识器本地库实体类 - */ -@Entity -public class MarkerLocalBean { - @Id(autoincrement = true) - private Long id;//本地库主键ID - - // 管线类型 - private String pipelineType; - // 管线直径 - private String pipelineDiameter; - // 管材 - private String pipelineMaterial; - // 埋设方式 - private String buryMethod; - // 埋深 - private String buryDepth; - // 所属区域 - private String area; - // 所属线路 - private String line; - // 所属道路 - private String road; - // 建设年代 - private String constructTime; - // 权属单位 - private String owner; - //标识对象ID,无实际用途 - @Deprecated - private String objectId; - // 标识器ID - private String markerId; - // 标识器类型 - private String markerType; - // 标识器埋深 - private String markerDepth; - // 安装部门 - private String installationDept; - // 经度 - private String lng; - // 纬度 - private String lat; - //最后修改时间,更新时间 - private String updateTime; - // 备注信息 - private String remark; - // 下层管线类型 - private String underlyingPipelineType; - // 下层埋深 - private String underlyingPipelineDepth; - // 下层管径 - private String underlyingPipelineDiameter; - // 下层管材 - private String underlyingPipelineMaterial; - //标识对象类型 - private String objectType; - // 颜色 - private String color; - // 图片路径 - private String imagePath; - - @Generated(hash = 1479045776) - public MarkerLocalBean(Long id, String pipelineType, String pipelineDiameter, - String pipelineMaterial, String buryMethod, String buryDepth, - String area, String line, String road, String constructTime, - String owner, String objectId, String markerId, String markerType, - String markerDepth, String installationDept, String lng, String lat, - String updateTime, String remark, String underlyingPipelineType, - String underlyingPipelineDepth, String underlyingPipelineDiameter, - String underlyingPipelineMaterial, String objectType, String color, - String imagePath) { - this.id = id; - this.pipelineType = pipelineType; - this.pipelineDiameter = pipelineDiameter; - this.pipelineMaterial = pipelineMaterial; - this.buryMethod = buryMethod; - this.buryDepth = buryDepth; - this.area = area; - this.line = line; - this.road = road; - this.constructTime = constructTime; - this.owner = owner; - this.objectId = objectId; - this.markerId = markerId; - this.markerType = markerType; - this.markerDepth = markerDepth; - this.installationDept = installationDept; - this.lng = lng; - this.lat = lat; - this.updateTime = updateTime; - this.remark = remark; - this.underlyingPipelineType = underlyingPipelineType; - this.underlyingPipelineDepth = underlyingPipelineDepth; - this.underlyingPipelineDiameter = underlyingPipelineDiameter; - this.underlyingPipelineMaterial = underlyingPipelineMaterial; - this.objectType = objectType; - this.color = color; - this.imagePath = imagePath; - } - - @Generated(hash = 1538606012) - public MarkerLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getPipelineType() { - return this.pipelineType; - } - - public void setPipelineType(String pipelineType) { - this.pipelineType = pipelineType; - } - - public String getPipelineDiameter() { - return this.pipelineDiameter; - } - - public void setPipelineDiameter(String pipelineDiameter) { - this.pipelineDiameter = pipelineDiameter; - } - - public String getPipelineMaterial() { - return this.pipelineMaterial; - } - - public void setPipelineMaterial(String pipelineMaterial) { - this.pipelineMaterial = pipelineMaterial; - } - - public String getBuryMethod() { - return this.buryMethod; - } - - public void setBuryMethod(String buryMethod) { - this.buryMethod = buryMethod; - } - - public String getBuryDepth() { - return this.buryDepth; - } - - public void setBuryDepth(String buryDepth) { - this.buryDepth = buryDepth; - } - - public String getArea() { - return this.area; - } - - public void setArea(String area) { - this.area = area; - } - - public String getLine() { - return this.line; - } - - public void setLine(String line) { - this.line = line; - } - - public String getRoad() { - return this.road; - } - - public void setRoad(String road) { - this.road = road; - } - - public String getConstructTime() { - return this.constructTime; - } - - public void setConstructTime(String constructTime) { - this.constructTime = constructTime; - } - - public String getOwner() { - return this.owner; - } - - public void setOwner(String owner) { - this.owner = owner; - } - - public String getObjectId() { - return this.objectId; - } - - public void setObjectId(String objectId) { - this.objectId = objectId; - } - - public String getMarkerId() { - return this.markerId; - } - - public void setMarkerId(String markerId) { - this.markerId = markerId; - } - - public String getMarkerType() { - return this.markerType; - } - - public void setMarkerType(String markerType) { - this.markerType = markerType; - } - - public String getMarkerDepth() { - return this.markerDepth; - } - - public void setMarkerDepth(String markerDepth) { - this.markerDepth = markerDepth; - } - - public String getInstallationDept() { - return this.installationDept; - } - - public void setInstallationDept(String installationDept) { - this.installationDept = installationDept; - } - - public String getLng() { - return this.lng; - } - - public void setLng(String lng) { - this.lng = lng; - } - - public String getLat() { - return this.lat; - } - - public void setLat(String lat) { - this.lat = lat; - } - - public String getUpdateTime() { - return this.updateTime; - } - - public void setUpdateTime(String updateTime) { - this.updateTime = updateTime; - } - - public String getRemark() { - return this.remark; - } - - public void setRemark(String remark) { - this.remark = remark; - } - - public String getUnderlyingPipelineType() { - return this.underlyingPipelineType; - } - - public void setUnderlyingPipelineType(String underlyingPipelineType) { - this.underlyingPipelineType = underlyingPipelineType; - } - - public String getUnderlyingPipelineDepth() { - return this.underlyingPipelineDepth; - } - - public void setUnderlyingPipelineDepth(String underlyingPipelineDepth) { - this.underlyingPipelineDepth = underlyingPipelineDepth; - } - - public String getUnderlyingPipelineDiameter() { - return this.underlyingPipelineDiameter; - } - - public void setUnderlyingPipelineDiameter(String underlyingPipelineDiameter) { - this.underlyingPipelineDiameter = underlyingPipelineDiameter; - } - - public String getUnderlyingPipelineMaterial() { - return this.underlyingPipelineMaterial; - } - - public void setUnderlyingPipelineMaterial(String underlyingPipelineMaterial) { - this.underlyingPipelineMaterial = underlyingPipelineMaterial; - } - - public String getObjectType() { - return this.objectType; - } - - public void setObjectType(String objectType) { - this.objectType = objectType; - } - - public String getColor() { - return this.color; - } - - public void setColor(String color) { - this.color = color; - } - - public String getImagePath() { - return this.imagePath; - } - - public void setImagePath(String imagePath) { - this.imagePath = imagePath; - } -} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java new file mode 100644 index 0000000..5c88fdf --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java @@ -0,0 +1,93 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 巡检任务本地库实体类,不包含任务里面需要巡检的标识器信息 + */ +@Entity(tableName = "task_detail") +public class TaskBean { + @PrimaryKey(autoGenerate = true) + private long id;//主键ID + private String taskCode; // 任务编号 + private String description; // 任务名称 + private String createTime; // 任务创建的时间 + private String status; // 任务状态 + private String createUserName; // 任务创建者名称 + private String startTime; // 任务被开始执行的时间 + private String endTime; // 任务执行结束的时间 + private String isFree; // 是否自由巡检。1-是,0-否 + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getTaskCode() { + return taskCode; + } + + public void setTaskCode(String taskCode) { + this.taskCode = taskCode; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getCreateUserName() { + return createUserName; + } + + public void setCreateUserName(String createUserName) { + this.createUserName = createUserName; + } + + public String getStartTime() { + return startTime; + } + + public void setStartTime(String startTime) { + this.startTime = startTime; + } + + public String getEndTime() { + return endTime; + } + + public void setEndTime(String endTime) { + this.endTime = endTime; + } + + public String getIsFree() { + return isFree; + } + + public void setIsFree(String isFree) { + this.isFree = isFree; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java deleted file mode 100644 index 91737b3..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java +++ /dev/null @@ -1,114 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 巡检任务本地库实体类,不包含任务里面需要巡检的标识器信息 - */ -@Entity -public class TaskLocalBean { - @Id - private Long id;//任务ID - - private String taskCode;//任务编号 - private String description;//任务名称 - private String createTime;//任务创建的时间 - private String status;//任务状态 - private String createUserName;//任务创建者名称 - private String startTime;//任务被开始执行的时间 - private String endTime;//任务执行结束的时间 - private String isFreeTask;//是否自由巡检。1-是,0-否 - - @Generated(hash = 1482022528) - public TaskLocalBean(Long id, String taskCode, String description, - String createTime, String status, String createUserName, - String startTime, String endTime, String isFreeTask) { - this.id = id; - this.taskCode = taskCode; - this.description = description; - this.createTime = createTime; - this.status = status; - this.createUserName = createUserName; - this.startTime = startTime; - this.endTime = endTime; - this.isFreeTask = isFreeTask; - } - - @Generated(hash = 949704588) - public TaskLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getTaskCode() { - return this.taskCode; - } - - public void setTaskCode(String taskCode) { - this.taskCode = taskCode; - } - - public String getDescription() { - return this.description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getCreateTime() { - return this.createTime; - } - - public void setCreateTime(String createTime) { - this.createTime = createTime; - } - - public String getStatus() { - return this.status; - } - - public void setStatus(String status) { - this.status = status; - } - - public String getCreateUserName() { - return this.createUserName; - } - - public void setCreateUserName(String createUserName) { - this.createUserName = createUserName; - } - - public String getStartTime() { - return this.startTime; - } - - public void setStartTime(String startTime) { - this.startTime = startTime; - } - - public String getEndTime() { - return this.endTime; - } - - public void setEndTime(String endTime) { - this.endTime = endTime; - } - - public String getIsFreeTask() { - return this.isFreeTask; - } - - public void setIsFreeTask(String isFreeTask) { - this.isFreeTask = isFreeTask; - } -} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerBean.java new file mode 100644 index 0000000..c563a60 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerBean.java @@ -0,0 +1,110 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 巡检任务里面需要巡检的标识器信息本地库实体类 + */ +@Entity(tableName = "task_marker_info") +public class TaskMarkerBean { + //标识器后台库的主键ID,不是标识器实际ID + @PrimaryKey(autoGenerate = true) + private long id; + + /** + * 任务ID,通过此字段关联[TaskBean.id] + */ + private String taskId; + + /** + * 任务Code,通过此字段关联[TaskBean.taskCode] + *

+ *

+ * 双重验证,防止出现同时刻重复的情况 + */ + private String taskCode; + + /** + * 对应后台字段[TaskModel.MessageModel.TaskDetailInfosModel.markerIdReal],也就是探测仪扫描出来的ID + */ + private String markerId; + + private Double lng; + private Double lat; + + /** + * 是否已被探测到 + * 1-是,0-否 + */ + private String isDetected; + + /** + * 被探测到的时间,对应后台字段[TaskModel.MessageModel.TaskDetailInfosModel.finishTime] + */ + private String detectedTime; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getTaskId() { + return taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getTaskCode() { + return taskCode; + } + + public void setTaskCode(String taskCode) { + this.taskCode = taskCode; + } + + public String getMarkerId() { + return markerId; + } + + public void setMarkerId(String markerId) { + this.markerId = markerId; + } + + public Double getLng() { + return lng; + } + + public void setLng(Double lng) { + this.lng = lng; + } + + public Double getLat() { + return lat; + } + + public void setLat(Double lat) { + this.lat = lat; + } + + public String getIsDetected() { + return isDetected; + } + + public void setIsDetected(String isDetected) { + this.isDetected = isDetected; + } + + public String getDetectedTime() { + return detectedTime; + } + + public void setDetectedTime(String detectedTime) { + this.detectedTime = detectedTime; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerLocalBean.java deleted file mode 100644 index de9f459..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerLocalBean.java +++ /dev/null @@ -1,128 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import com.casic.common.detector.gd.model.TaskModel; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 巡检任务里面需要巡检的标识器信息本地库实体类 - */ -@Entity -public class TaskMarkerLocalBean { - @Id - private Long id;//标识器后台库的主键ID,不是标识器实际ID - - /** - * 任务ID,通过此字段关联{@link TaskLocalBean#id} - */ - private String taskId; - - /** - * 任务Code,通过此字段关联{@link TaskLocalBean#taskCode} - *

- * 双重验证,防止出现同时刻重复的情况 - */ - private String taskCode; - - /** - * 对应后台字段{@link TaskModel.MessageModel.TaskDetailInfosModel#markerIdReal},也就是探测仪扫描出来的ID - */ - private String markerId; - - private double lng; - private double lat; - - /** - * 是否已被探测到 - * 1-是,0-否 - */ - private String isDetected; - - /** - * 被探测到的时间,对应后台字段{@link TaskModel.MessageModel.TaskDetailInfosModel#finishTime} - */ - private String detectedTime; - - @Generated(hash = 677328533) - public TaskMarkerLocalBean(Long id, String taskId, String taskCode, String markerId, - double lng, double lat, String isDetected, String detectedTime) { - this.id = id; - this.taskId = taskId; - this.taskCode = taskCode; - this.markerId = markerId; - this.lng = lng; - this.lat = lat; - this.isDetected = isDetected; - this.detectedTime = detectedTime; - } - - @Generated(hash = 1162404642) - public TaskMarkerLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getTaskId() { - return this.taskId; - } - - public void setTaskId(String taskId) { - this.taskId = taskId; - } - - public String getTaskCode() { - return this.taskCode; - } - - public void setTaskCode(String taskCode) { - this.taskCode = taskCode; - } - - public String getMarkerId() { - return this.markerId; - } - - public void setMarkerId(String markerId) { - this.markerId = markerId; - } - - public double getLng() { - return this.lng; - } - - public void setLng(double lng) { - this.lng = lng; - } - - public double getLat() { - return this.lat; - } - - public void setLat(double lat) { - this.lat = lat; - } - - public String getIsDetected() { - return this.isDetected; - } - - public void setIsDetected(String isDetected) { - this.isDetected = isDetected; - } - - public String getDetectedTime() { - return this.detectedTime; - } - - public void setDetectedTime(String detectedTime) { - this.detectedTime = detectedTime; - } -} diff --git a/app/src/main/java/com/casic/common/detector/gd/dao/MarkerBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/dao/MarkerBeanDao.java new file mode 100644 index 0000000..2beb7ed --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/dao/MarkerBeanDao.java @@ -0,0 +1,29 @@ +package com.casic.common.detector.gd.dao; + +import androidx.room.Dao; +import androidx.room.Insert; +import androidx.room.Query; +import androidx.room.RawQuery; +import androidx.sqlite.db.SupportSQLiteQuery; + +import com.casic.common.detector.gd.bean.MarkerBean; + +import java.util.List; + +@Dao +public interface MarkerBeanDao { + @Query("DELETE FROM marker_detail") + void deleteAll(); + + @Insert + void insert(MarkerBean marker); + + @Query("SELECT * FROM marker_detail") + List loadAll(); + + @Query("SELECT * FROM marker_detail WHERE markerId = :markerId") + List queryMarkerById(String markerId); + + @RawQuery + List loadMarkersByCondition(SupportSQLiteQuery query); +} diff --git a/app/src/main/java/com/casic/common/detector/gd/dao/TaskBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/dao/TaskBeanDao.java new file mode 100644 index 0000000..9c70ac2 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/dao/TaskBeanDao.java @@ -0,0 +1,120 @@ +package com.casic.common.detector.gd.dao; + +import androidx.room.Dao; +import androidx.room.Insert; +import androidx.room.Query; +import androidx.room.Transaction; + +import com.casic.common.detector.gd.bean.TaskBean; +import com.casic.common.detector.gd.bean.TaskMarkerBean; +import com.casic.common.detector.gd.model.TaskDetailLocalModel; +import com.casic.common.detector.gd.model.TaskModel; +import com.casic.common.detector.gd.utils.LocaleConstant; +import com.pengxh.kt.lite.utils.SaveKeyValues; + +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Locale; + +@Dao +public interface TaskBeanDao { + @Query("SELECT COUNT(*) FROM task_detail WHERE id = :taskId") + int isTaskExist(long taskId); + + @Insert + void insert(TaskBean task); + + default void saveTask(Long taskId, String taskName) { + if (isTaskExist(taskId) == 0) { + TaskBean task = new TaskBean(); + task.setId(taskId); + task.setTaskCode(new SimpleDateFormat("yyyyMMddHHmmss", Locale.CHINA).format(new Date())); + task.setDescription(taskName); + String time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA).format(new Date()); + task.setCreateTime(time); + task.setStatus("0"); + String userName = (String) SaveKeyValues.INSTANCE.getValue(LocaleConstant.USER_NAME, ""); + task.setCreateUserName(userName); + task.setStartTime(time); + task.setEndTime(""); + task.setIsFree("1"); + insert(task); + } + } + + default void saveTask(TaskModel.MessageModel model) { + TaskBean task = new TaskBean(); + task.setId(model.getId()); + task.setTaskCode(model.getTaskCode()); + task.setDescription(model.getDescription()); + task.setCreateTime(model.getDeployDate()); + task.setStatus(model.getStatus()); + task.setCreateUserName(model.getCreatorName()); + task.setStartTime(model.getBeginDate()); + task.setEndTime(model.getEndDate()); + task.setIsFree("0"); + if (isTaskExist(task.getId()) == 0) { + insert(task); + } + } + + @Query("SELECT * FROM task_detail") + List loadAll(); + + @Transaction + default ArrayList loadLocalTask(TaskMarkerBeanDao taskMarkerBeanDao) { + ArrayList result = new ArrayList<>(); + List tasks = loadAll(); + for (TaskBean it : tasks) { + TaskDetailLocalModel model = new TaskDetailLocalModel(); + model.setTaskId(String.valueOf(it.getId())); + model.setTaskCode(it.getTaskCode()); + model.setDescription(it.getDescription()); + model.setCreateTime(it.getCreateTime()); + model.setStatus(it.getStatus()); + model.setCreateUserName(it.getCreateUserName()); + model.setIsFreeTask(it.getIsFree()); + ArrayList results = new ArrayList<>(); + if ("0".equals(it.getIsFree())) { + // 非自由巡检才有Marker + List markers = taskMarkerBeanDao.getMarkersByIdAndCode(String.valueOf(it.getId()), it.getTaskCode()); + for (TaskMarkerBean marker : markers) { + TaskDetailLocalModel.TaskMarkerLocalModel localModel = new TaskDetailLocalModel.TaskMarkerLocalModel(); + localModel.setMarkerId(marker.getMarkerId()); + localModel.setLng(marker.getLng()); + localModel.setLat(marker.getLat()); + localModel.setIsDetected(marker.getIsDetected()); + localModel.setDetectedTime(marker.getDetectedTime()); + + results.add(localModel); + } + } + model.setMarkerModels(results); + result.add(model); + } + return result; + } + + @Query("DELETE FROM task_detail WHERE id = :taskId AND taskCode = :taskCode") + void deleteTaskById(long taskId, String taskCode); + + @Transaction + default void deleteLocalTaskById(long taskId, String taskCode, TaskMarkerBeanDao taskMarkerBeanDao) { + TaskBean task = loadAll().stream() + .filter(it -> it.getId() == taskId && taskCode.equals(it.getTaskCode())) + .findFirst() + .orElse(null); + if (task == null) return; + deleteTaskById(taskId, taskCode); + + // 删除此任务关联的Marker。非自由巡检才有Marker + if ("0".equals(task.getIsFree())) { + List markers = taskMarkerBeanDao.getMarkersByIdAndCode(String.valueOf(task.getId()), task.getTaskCode()); + for (TaskMarkerBean marker : markers) { + taskMarkerBeanDao.delete(marker); + } + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/dao/TaskMarkerBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/dao/TaskMarkerBeanDao.java new file mode 100644 index 0000000..cc2156a --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/dao/TaskMarkerBeanDao.java @@ -0,0 +1,52 @@ +package com.casic.common.detector.gd.dao; + +import androidx.room.Dao; +import androidx.room.Delete; +import androidx.room.Insert; +import androidx.room.Query; +import androidx.room.Update; + +import com.casic.common.detector.gd.bean.TaskMarkerBean; +import com.casic.common.detector.gd.model.TaskModel; + +import java.util.List; + +@Dao +public interface TaskMarkerBeanDao { + + @Insert + void insert(TaskMarkerBean marker); + + @Query("SELECT COUNT(*) FROM task_marker_info WHERE id = :markerId") + int isMarkerExist(String markerId); + + default void saveTaskMarker(long taskId, String taskCode, TaskModel.MessageModel.TaskDetailInfosModel marker) { + if (isMarkerExist(marker.getMarkerId()) == 0) { + TaskMarkerBean bean = new TaskMarkerBean(); + bean.setId(marker.getId()); + bean.setTaskId(String.valueOf(taskId)); + bean.setTaskCode(taskCode); + bean.setMarkerId(marker.getMarkerIdReal()); + bean.setLng(marker.getLongitude()); + bean.setLat(marker.getLatitude()); + bean.setIsDetected("0"); + bean.setDetectedTime(""); + insert(bean); + } + } + + @Query("SELECT * FROM task_marker_info WHERE taskId = :taskId AND taskCode = :taskCode AND markerId = :markerId AND isDetected = :state") + TaskMarkerBean queryTaskMarkerById(String taskId, String taskCode, String markerId, String state); + + @Update + void updateLocalTaskMarkerState(TaskMarkerBean marker); + + @Query("SELECT * FROM task_marker_info WHERE isDetected = :state") + List queryMarkerByState(String state); + + @Query("SELECT * FROM task_marker_info WHERE taskId = :taskId AND taskCode = :taskCode") + List getMarkersByIdAndCode(String taskId, String taskCode); + + @Delete + void delete(TaskMarkerBean marker); +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/extensions/Long.kt b/app/src/main/java/com/casic/common/detector/gd/extensions/Long.kt deleted file mode 100644 index 6713d8d..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/extensions/Long.kt +++ /dev/null @@ -1,10 +0,0 @@ -package com.casic.common.detector.gd.extensions - -import java.text.SimpleDateFormat -import java.util.Date -import java.util.Locale - -fun Long.createTaskCode(): String { - val dateFormat = SimpleDateFormat("yyyyMMddHHmmss", Locale.CHINA) - return dateFormat.format(Date(this)) -} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoMaster.java b/app/src/main/java/com/casic/common/detector/gd/greendao/DaoMaster.java deleted file mode 100644 index 6ab94b3..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoMaster.java +++ /dev/null @@ -1,102 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import android.content.Context; -import android.database.sqlite.SQLiteDatabase; -import android.database.sqlite.SQLiteDatabase.CursorFactory; -import android.util.Log; - -import org.greenrobot.greendao.AbstractDaoMaster; -import org.greenrobot.greendao.database.StandardDatabase; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.database.DatabaseOpenHelper; -import org.greenrobot.greendao.identityscope.IdentityScopeType; - - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** - * Master of DAO (schema version 1): knows all DAOs. - */ -public class DaoMaster extends AbstractDaoMaster { - public static final int SCHEMA_VERSION = 1; - - /** Creates underlying database table using DAOs. */ - public static void createAllTables(Database db, boolean ifNotExists) { - MarkerLocalBeanDao.createTable(db, ifNotExists); - TaskLocalBeanDao.createTable(db, ifNotExists); - TaskMarkerLocalBeanDao.createTable(db, ifNotExists); - } - - /** Drops underlying database table using DAOs. */ - public static void dropAllTables(Database db, boolean ifExists) { - MarkerLocalBeanDao.dropTable(db, ifExists); - TaskLocalBeanDao.dropTable(db, ifExists); - TaskMarkerLocalBeanDao.dropTable(db, ifExists); - } - - /** - * WARNING: Drops all table on Upgrade! Use only during development. - * Convenience method using a {@link DevOpenHelper}. - */ - public static DaoSession newDevSession(Context context, String name) { - Database db = new DevOpenHelper(context, name).getWritableDb(); - DaoMaster daoMaster = new DaoMaster(db); - return daoMaster.newSession(); - } - - public DaoMaster(SQLiteDatabase db) { - this(new StandardDatabase(db)); - } - - public DaoMaster(Database db) { - super(db, SCHEMA_VERSION); - registerDaoClass(MarkerLocalBeanDao.class); - registerDaoClass(TaskLocalBeanDao.class); - registerDaoClass(TaskMarkerLocalBeanDao.class); - } - - public DaoSession newSession() { - return new DaoSession(db, IdentityScopeType.Session, daoConfigMap); - } - - public DaoSession newSession(IdentityScopeType type) { - return new DaoSession(db, type, daoConfigMap); - } - - /** - * Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} - - */ - public static abstract class OpenHelper extends DatabaseOpenHelper { - public OpenHelper(Context context, String name) { - super(context, name, SCHEMA_VERSION); - } - - public OpenHelper(Context context, String name, CursorFactory factory) { - super(context, name, factory, SCHEMA_VERSION); - } - - @Override - public void onCreate(Database db) { - Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION); - createAllTables(db, false); - } - } - - /** WARNING: Drops all table on Upgrade! Use only during development. */ - public static class DevOpenHelper extends OpenHelper { - public DevOpenHelper(Context context, String name) { - super(context, name); - } - - public DevOpenHelper(Context context, String name, CursorFactory factory) { - super(context, name, factory); - } - - @Override - public void onUpgrade(Database db, int oldVersion, int newVersion) { - Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables"); - dropAllTables(db, true); - onCreate(db); - } - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoSession.java b/app/src/main/java/com/casic/common/detector/gd/greendao/DaoSession.java deleted file mode 100644 index c8b1a20..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoSession.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import java.util.Map; - -import org.greenrobot.greendao.AbstractDao; -import org.greenrobot.greendao.AbstractDaoSession; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.identityscope.IdentityScopeType; -import org.greenrobot.greendao.internal.DaoConfig; - -import com.casic.common.detector.gd.bean.MarkerLocalBean; -import com.casic.common.detector.gd.bean.TaskLocalBean; -import com.casic.common.detector.gd.bean.TaskMarkerLocalBean; - -import com.casic.common.detector.gd.greendao.MarkerLocalBeanDao; -import com.casic.common.detector.gd.greendao.TaskLocalBeanDao; -import com.casic.common.detector.gd.greendao.TaskMarkerLocalBeanDao; - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. - -/** - * {@inheritDoc} - * - * @see org.greenrobot.greendao.AbstractDaoSession - */ -public class DaoSession extends AbstractDaoSession { - - private final DaoConfig markerLocalBeanDaoConfig; - private final DaoConfig taskLocalBeanDaoConfig; - private final DaoConfig taskMarkerLocalBeanDaoConfig; - - private final MarkerLocalBeanDao markerLocalBeanDao; - private final TaskLocalBeanDao taskLocalBeanDao; - private final TaskMarkerLocalBeanDao taskMarkerLocalBeanDao; - - public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> - daoConfigMap) { - super(db); - - markerLocalBeanDaoConfig = daoConfigMap.get(MarkerLocalBeanDao.class).clone(); - markerLocalBeanDaoConfig.initIdentityScope(type); - - taskLocalBeanDaoConfig = daoConfigMap.get(TaskLocalBeanDao.class).clone(); - taskLocalBeanDaoConfig.initIdentityScope(type); - - taskMarkerLocalBeanDaoConfig = daoConfigMap.get(TaskMarkerLocalBeanDao.class).clone(); - taskMarkerLocalBeanDaoConfig.initIdentityScope(type); - - markerLocalBeanDao = new MarkerLocalBeanDao(markerLocalBeanDaoConfig, this); - taskLocalBeanDao = new TaskLocalBeanDao(taskLocalBeanDaoConfig, this); - taskMarkerLocalBeanDao = new TaskMarkerLocalBeanDao(taskMarkerLocalBeanDaoConfig, this); - - registerDao(MarkerLocalBean.class, markerLocalBeanDao); - registerDao(TaskLocalBean.class, taskLocalBeanDao); - registerDao(TaskMarkerLocalBean.class, taskMarkerLocalBeanDao); - } - - public void clear() { - markerLocalBeanDaoConfig.clearIdentityScope(); - taskLocalBeanDaoConfig.clearIdentityScope(); - taskMarkerLocalBeanDaoConfig.clearIdentityScope(); - } - - public MarkerLocalBeanDao getMarkerLocalBeanDao() { - return markerLocalBeanDao; - } - - public TaskLocalBeanDao getTaskLocalBeanDao() { - return taskLocalBeanDao; - } - - public TaskMarkerLocalBeanDao getTaskMarkerLocalBeanDao() { - return taskMarkerLocalBeanDao; - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/MarkerLocalBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/greendao/MarkerLocalBeanDao.java deleted file mode 100644 index 2f792c3..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/MarkerLocalBeanDao.java +++ /dev/null @@ -1,479 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import android.database.Cursor; -import android.database.sqlite.SQLiteStatement; - -import org.greenrobot.greendao.AbstractDao; -import org.greenrobot.greendao.Property; -import org.greenrobot.greendao.internal.DaoConfig; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.database.DatabaseStatement; - -import com.casic.common.detector.gd.bean.MarkerLocalBean; - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** - * DAO for table "MARKER_LOCAL_BEAN". -*/ -public class MarkerLocalBeanDao extends AbstractDao { - - public static final String TABLENAME = "MARKER_LOCAL_BEAN"; - - /** - * Properties of entity MarkerLocalBean.
- * Can be used for QueryBuilder and for referencing column names. - */ - public static class Properties { - public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property PipelineType = new Property(1, String.class, "pipelineType", false, "PIPELINE_TYPE"); - public final static Property PipelineDiameter = new Property(2, String.class, "pipelineDiameter", false, "PIPELINE_DIAMETER"); - public final static Property PipelineMaterial = new Property(3, String.class, "pipelineMaterial", false, "PIPELINE_MATERIAL"); - public final static Property BuryMethod = new Property(4, String.class, "buryMethod", false, "BURY_METHOD"); - public final static Property BuryDepth = new Property(5, String.class, "buryDepth", false, "BURY_DEPTH"); - public final static Property Area = new Property(6, String.class, "area", false, "AREA"); - public final static Property Line = new Property(7, String.class, "line", false, "LINE"); - public final static Property Road = new Property(8, String.class, "road", false, "ROAD"); - public final static Property ConstructTime = new Property(9, String.class, "constructTime", false, "CONSTRUCT_TIME"); - public final static Property Owner = new Property(10, String.class, "owner", false, "OWNER"); - public final static Property ObjectId = new Property(11, String.class, "objectId", false, "OBJECT_ID"); - public final static Property MarkerId = new Property(12, String.class, "markerId", false, "MARKER_ID"); - public final static Property MarkerType = new Property(13, String.class, "markerType", false, "MARKER_TYPE"); - public final static Property MarkerDepth = new Property(14, String.class, "markerDepth", false, "MARKER_DEPTH"); - public final static Property InstallationDept = new Property(15, String.class, "installationDept", false, "INSTALLATION_DEPT"); - public final static Property Lng = new Property(16, String.class, "lng", false, "LNG"); - public final static Property Lat = new Property(17, String.class, "lat", false, "LAT"); - public final static Property UpdateTime = new Property(18, String.class, "updateTime", false, "UPDATE_TIME"); - public final static Property Remark = new Property(19, String.class, "remark", false, "REMARK"); - public final static Property UnderlyingPipelineType = new Property(20, String.class, "underlyingPipelineType", false, "UNDERLYING_PIPELINE_TYPE"); - public final static Property UnderlyingPipelineDepth = new Property(21, String.class, "underlyingPipelineDepth", false, "UNDERLYING_PIPELINE_DEPTH"); - public final static Property UnderlyingPipelineDiameter = new Property(22, String.class, "underlyingPipelineDiameter", false, "UNDERLYING_PIPELINE_DIAMETER"); - public final static Property UnderlyingPipelineMaterial = new Property(23, String.class, "underlyingPipelineMaterial", false, "UNDERLYING_PIPELINE_MATERIAL"); - public final static Property ObjectType = new Property(24, String.class, "objectType", false, "OBJECT_TYPE"); - public final static Property Color = new Property(25, String.class, "color", false, "COLOR"); - public final static Property ImagePath = new Property(26, String.class, "imagePath", false, "IMAGE_PATH"); - } - - - public MarkerLocalBeanDao(DaoConfig config) { - super(config); - } - - public MarkerLocalBeanDao(DaoConfig config, DaoSession daoSession) { - super(config, daoSession); - } - - /** Creates the underlying database table. */ - public static void createTable(Database db, boolean ifNotExists) { - String constraint = ifNotExists? "IF NOT EXISTS ": ""; - db.execSQL("CREATE TABLE " + constraint + "\"MARKER_LOCAL_BEAN\" (" + // - "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id - "\"PIPELINE_TYPE\" TEXT," + // 1: pipelineType - "\"PIPELINE_DIAMETER\" TEXT," + // 2: pipelineDiameter - "\"PIPELINE_MATERIAL\" TEXT," + // 3: pipelineMaterial - "\"BURY_METHOD\" TEXT," + // 4: buryMethod - "\"BURY_DEPTH\" TEXT," + // 5: buryDepth - "\"AREA\" TEXT," + // 6: area - "\"LINE\" TEXT," + // 7: line - "\"ROAD\" TEXT," + // 8: road - "\"CONSTRUCT_TIME\" TEXT," + // 9: constructTime - "\"OWNER\" TEXT," + // 10: owner - "\"OBJECT_ID\" TEXT," + // 11: objectId - "\"MARKER_ID\" TEXT," + // 12: markerId - "\"MARKER_TYPE\" TEXT," + // 13: markerType - "\"MARKER_DEPTH\" TEXT," + // 14: markerDepth - "\"INSTALLATION_DEPT\" TEXT," + // 15: installationDept - "\"LNG\" TEXT," + // 16: lng - "\"LAT\" TEXT," + // 17: lat - "\"UPDATE_TIME\" TEXT," + // 18: updateTime - "\"REMARK\" TEXT," + // 19: remark - "\"UNDERLYING_PIPELINE_TYPE\" TEXT," + // 20: underlyingPipelineType - "\"UNDERLYING_PIPELINE_DEPTH\" TEXT," + // 21: underlyingPipelineDepth - "\"UNDERLYING_PIPELINE_DIAMETER\" TEXT," + // 22: underlyingPipelineDiameter - "\"UNDERLYING_PIPELINE_MATERIAL\" TEXT," + // 23: underlyingPipelineMaterial - "\"OBJECT_TYPE\" TEXT," + // 24: objectType - "\"COLOR\" TEXT," + // 25: color - "\"IMAGE_PATH\" TEXT);"); // 26: imagePath - } - - /** Drops the underlying database table. */ - public static void dropTable(Database db, boolean ifExists) { - String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"MARKER_LOCAL_BEAN\""; - db.execSQL(sql); - } - - @Override - protected final void bindValues(DatabaseStatement stmt, MarkerLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String pipelineType = entity.getPipelineType(); - if (pipelineType != null) { - stmt.bindString(2, pipelineType); - } - - String pipelineDiameter = entity.getPipelineDiameter(); - if (pipelineDiameter != null) { - stmt.bindString(3, pipelineDiameter); - } - - String pipelineMaterial = entity.getPipelineMaterial(); - if (pipelineMaterial != null) { - stmt.bindString(4, pipelineMaterial); - } - - String buryMethod = entity.getBuryMethod(); - if (buryMethod != null) { - stmt.bindString(5, buryMethod); - } - - String buryDepth = entity.getBuryDepth(); - if (buryDepth != null) { - stmt.bindString(6, buryDepth); - } - - String area = entity.getArea(); - if (area != null) { - stmt.bindString(7, area); - } - - String line = entity.getLine(); - if (line != null) { - stmt.bindString(8, line); - } - - String road = entity.getRoad(); - if (road != null) { - stmt.bindString(9, road); - } - - String constructTime = entity.getConstructTime(); - if (constructTime != null) { - stmt.bindString(10, constructTime); - } - - String owner = entity.getOwner(); - if (owner != null) { - stmt.bindString(11, owner); - } - - String objectId = entity.getObjectId(); - if (objectId != null) { - stmt.bindString(12, objectId); - } - - String markerId = entity.getMarkerId(); - if (markerId != null) { - stmt.bindString(13, markerId); - } - - String markerType = entity.getMarkerType(); - if (markerType != null) { - stmt.bindString(14, markerType); - } - - String markerDepth = entity.getMarkerDepth(); - if (markerDepth != null) { - stmt.bindString(15, markerDepth); - } - - String installationDept = entity.getInstallationDept(); - if (installationDept != null) { - stmt.bindString(16, installationDept); - } - - String lng = entity.getLng(); - if (lng != null) { - stmt.bindString(17, lng); - } - - String lat = entity.getLat(); - if (lat != null) { - stmt.bindString(18, lat); - } - - String updateTime = entity.getUpdateTime(); - if (updateTime != null) { - stmt.bindString(19, updateTime); - } - - String remark = entity.getRemark(); - if (remark != null) { - stmt.bindString(20, remark); - } - - String underlyingPipelineType = entity.getUnderlyingPipelineType(); - if (underlyingPipelineType != null) { - stmt.bindString(21, underlyingPipelineType); - } - - String underlyingPipelineDepth = entity.getUnderlyingPipelineDepth(); - if (underlyingPipelineDepth != null) { - stmt.bindString(22, underlyingPipelineDepth); - } - - String underlyingPipelineDiameter = entity.getUnderlyingPipelineDiameter(); - if (underlyingPipelineDiameter != null) { - stmt.bindString(23, underlyingPipelineDiameter); - } - - String underlyingPipelineMaterial = entity.getUnderlyingPipelineMaterial(); - if (underlyingPipelineMaterial != null) { - stmt.bindString(24, underlyingPipelineMaterial); - } - - String objectType = entity.getObjectType(); - if (objectType != null) { - stmt.bindString(25, objectType); - } - - String color = entity.getColor(); - if (color != null) { - stmt.bindString(26, color); - } - - String imagePath = entity.getImagePath(); - if (imagePath != null) { - stmt.bindString(27, imagePath); - } - } - - @Override - protected final void bindValues(SQLiteStatement stmt, MarkerLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String pipelineType = entity.getPipelineType(); - if (pipelineType != null) { - stmt.bindString(2, pipelineType); - } - - String pipelineDiameter = entity.getPipelineDiameter(); - if (pipelineDiameter != null) { - stmt.bindString(3, pipelineDiameter); - } - - String pipelineMaterial = entity.getPipelineMaterial(); - if (pipelineMaterial != null) { - stmt.bindString(4, pipelineMaterial); - } - - String buryMethod = entity.getBuryMethod(); - if (buryMethod != null) { - stmt.bindString(5, buryMethod); - } - - String buryDepth = entity.getBuryDepth(); - if (buryDepth != null) { - stmt.bindString(6, buryDepth); - } - - String area = entity.getArea(); - if (area != null) { - stmt.bindString(7, area); - } - - String line = entity.getLine(); - if (line != null) { - stmt.bindString(8, line); - } - - String road = entity.getRoad(); - if (road != null) { - stmt.bindString(9, road); - } - - String constructTime = entity.getConstructTime(); - if (constructTime != null) { - stmt.bindString(10, constructTime); - } - - String owner = entity.getOwner(); - if (owner != null) { - stmt.bindString(11, owner); - } - - String objectId = entity.getObjectId(); - if (objectId != null) { - stmt.bindString(12, objectId); - } - - String markerId = entity.getMarkerId(); - if (markerId != null) { - stmt.bindString(13, markerId); - } - - String markerType = entity.getMarkerType(); - if (markerType != null) { - stmt.bindString(14, markerType); - } - - String markerDepth = entity.getMarkerDepth(); - if (markerDepth != null) { - stmt.bindString(15, markerDepth); - } - - String installationDept = entity.getInstallationDept(); - if (installationDept != null) { - stmt.bindString(16, installationDept); - } - - String lng = entity.getLng(); - if (lng != null) { - stmt.bindString(17, lng); - } - - String lat = entity.getLat(); - if (lat != null) { - stmt.bindString(18, lat); - } - - String updateTime = entity.getUpdateTime(); - if (updateTime != null) { - stmt.bindString(19, updateTime); - } - - String remark = entity.getRemark(); - if (remark != null) { - stmt.bindString(20, remark); - } - - String underlyingPipelineType = entity.getUnderlyingPipelineType(); - if (underlyingPipelineType != null) { - stmt.bindString(21, underlyingPipelineType); - } - - String underlyingPipelineDepth = entity.getUnderlyingPipelineDepth(); - if (underlyingPipelineDepth != null) { - stmt.bindString(22, underlyingPipelineDepth); - } - - String underlyingPipelineDiameter = entity.getUnderlyingPipelineDiameter(); - if (underlyingPipelineDiameter != null) { - stmt.bindString(23, underlyingPipelineDiameter); - } - - String underlyingPipelineMaterial = entity.getUnderlyingPipelineMaterial(); - if (underlyingPipelineMaterial != null) { - stmt.bindString(24, underlyingPipelineMaterial); - } - - String objectType = entity.getObjectType(); - if (objectType != null) { - stmt.bindString(25, objectType); - } - - String color = entity.getColor(); - if (color != null) { - stmt.bindString(26, color); - } - - String imagePath = entity.getImagePath(); - if (imagePath != null) { - stmt.bindString(27, imagePath); - } - } - - @Override - public Long readKey(Cursor cursor, int offset) { - return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); - } - - @Override - public MarkerLocalBean readEntity(Cursor cursor, int offset) { - MarkerLocalBean entity = new MarkerLocalBean( // - cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // pipelineType - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // pipelineDiameter - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // pipelineMaterial - cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // buryMethod - cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // buryDepth - cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // area - cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // line - cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // road - cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // constructTime - cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10), // owner - cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11), // objectId - cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12), // markerId - cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13), // markerType - cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14), // markerDepth - cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15), // installationDept - cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16), // lng - cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17), // lat - cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18), // updateTime - cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19), // remark - cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20), // underlyingPipelineType - cursor.isNull(offset + 21) ? null : cursor.getString(offset + 21), // underlyingPipelineDepth - cursor.isNull(offset + 22) ? null : cursor.getString(offset + 22), // underlyingPipelineDiameter - cursor.isNull(offset + 23) ? null : cursor.getString(offset + 23), // underlyingPipelineMaterial - cursor.isNull(offset + 24) ? null : cursor.getString(offset + 24), // objectType - cursor.isNull(offset + 25) ? null : cursor.getString(offset + 25), // color - cursor.isNull(offset + 26) ? null : cursor.getString(offset + 26) // imagePath - ); - return entity; - } - - @Override - public void readEntity(Cursor cursor, MarkerLocalBean entity, int offset) { - entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setPipelineType(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); - entity.setPipelineDiameter(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); - entity.setPipelineMaterial(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); - entity.setBuryMethod(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); - entity.setBuryDepth(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); - entity.setArea(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); - entity.setLine(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); - entity.setRoad(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); - entity.setConstructTime(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9)); - entity.setOwner(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); - entity.setObjectId(cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11)); - entity.setMarkerId(cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12)); - entity.setMarkerType(cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13)); - entity.setMarkerDepth(cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14)); - entity.setInstallationDept(cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15)); - entity.setLng(cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16)); - entity.setLat(cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17)); - entity.setUpdateTime(cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18)); - entity.setRemark(cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19)); - entity.setUnderlyingPipelineType(cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20)); - entity.setUnderlyingPipelineDepth(cursor.isNull(offset + 21) ? null : cursor.getString(offset + 21)); - entity.setUnderlyingPipelineDiameter(cursor.isNull(offset + 22) ? null : cursor.getString(offset + 22)); - entity.setUnderlyingPipelineMaterial(cursor.isNull(offset + 23) ? null : cursor.getString(offset + 23)); - entity.setObjectType(cursor.isNull(offset + 24) ? null : cursor.getString(offset + 24)); - entity.setColor(cursor.isNull(offset + 25) ? null : cursor.getString(offset + 25)); - entity.setImagePath(cursor.isNull(offset + 26) ? null : cursor.getString(offset + 26)); - } - - @Override - protected final Long updateKeyAfterInsert(MarkerLocalBean entity, long rowId) { - entity.setId(rowId); - return rowId; - } - - @Override - public Long getKey(MarkerLocalBean entity) { - if(entity != null) { - return entity.getId(); - } else { - return null; - } - } - - @Override - public boolean hasKey(MarkerLocalBean entity) { - return entity.getId() != null; - } - - @Override - protected final boolean isEntityUpdateable() { - return true; - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/TaskLocalBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/greendao/TaskLocalBeanDao.java deleted file mode 100644 index fb88157..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/TaskLocalBeanDao.java +++ /dev/null @@ -1,227 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import android.database.Cursor; -import android.database.sqlite.SQLiteStatement; - -import org.greenrobot.greendao.AbstractDao; -import org.greenrobot.greendao.Property; -import org.greenrobot.greendao.internal.DaoConfig; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.database.DatabaseStatement; - -import com.casic.common.detector.gd.bean.TaskLocalBean; - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** - * DAO for table "TASK_LOCAL_BEAN". -*/ -public class TaskLocalBeanDao extends AbstractDao { - - public static final String TABLENAME = "TASK_LOCAL_BEAN"; - - /** - * Properties of entity TaskLocalBean.
- * Can be used for QueryBuilder and for referencing column names. - */ - public static class Properties { - public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property TaskCode = new Property(1, String.class, "taskCode", false, "TASK_CODE"); - public final static Property Description = new Property(2, String.class, "description", false, "DESCRIPTION"); - public final static Property CreateTime = new Property(3, String.class, "createTime", false, "CREATE_TIME"); - public final static Property Status = new Property(4, String.class, "status", false, "STATUS"); - public final static Property CreateUserName = new Property(5, String.class, "createUserName", false, "CREATE_USER_NAME"); - public final static Property StartTime = new Property(6, String.class, "startTime", false, "START_TIME"); - public final static Property EndTime = new Property(7, String.class, "endTime", false, "END_TIME"); - public final static Property IsFreeTask = new Property(8, String.class, "isFreeTask", false, "IS_FREE_TASK"); - } - - - public TaskLocalBeanDao(DaoConfig config) { - super(config); - } - - public TaskLocalBeanDao(DaoConfig config, DaoSession daoSession) { - super(config, daoSession); - } - - /** Creates the underlying database table. */ - public static void createTable(Database db, boolean ifNotExists) { - String constraint = ifNotExists? "IF NOT EXISTS ": ""; - db.execSQL("CREATE TABLE " + constraint + "\"TASK_LOCAL_BEAN\" (" + // - "\"_id\" INTEGER PRIMARY KEY ," + // 0: id - "\"TASK_CODE\" TEXT," + // 1: taskCode - "\"DESCRIPTION\" TEXT," + // 2: description - "\"CREATE_TIME\" TEXT," + // 3: createTime - "\"STATUS\" TEXT," + // 4: status - "\"CREATE_USER_NAME\" TEXT," + // 5: createUserName - "\"START_TIME\" TEXT," + // 6: startTime - "\"END_TIME\" TEXT," + // 7: endTime - "\"IS_FREE_TASK\" TEXT);"); // 8: isFreeTask - } - - /** Drops the underlying database table. */ - public static void dropTable(Database db, boolean ifExists) { - String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"TASK_LOCAL_BEAN\""; - db.execSQL(sql); - } - - @Override - protected final void bindValues(DatabaseStatement stmt, TaskLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String taskCode = entity.getTaskCode(); - if (taskCode != null) { - stmt.bindString(2, taskCode); - } - - String description = entity.getDescription(); - if (description != null) { - stmt.bindString(3, description); - } - - String createTime = entity.getCreateTime(); - if (createTime != null) { - stmt.bindString(4, createTime); - } - - String status = entity.getStatus(); - if (status != null) { - stmt.bindString(5, status); - } - - String createUserName = entity.getCreateUserName(); - if (createUserName != null) { - stmt.bindString(6, createUserName); - } - - String startTime = entity.getStartTime(); - if (startTime != null) { - stmt.bindString(7, startTime); - } - - String endTime = entity.getEndTime(); - if (endTime != null) { - stmt.bindString(8, endTime); - } - - String isFreeTask = entity.getIsFreeTask(); - if (isFreeTask != null) { - stmt.bindString(9, isFreeTask); - } - } - - @Override - protected final void bindValues(SQLiteStatement stmt, TaskLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String taskCode = entity.getTaskCode(); - if (taskCode != null) { - stmt.bindString(2, taskCode); - } - - String description = entity.getDescription(); - if (description != null) { - stmt.bindString(3, description); - } - - String createTime = entity.getCreateTime(); - if (createTime != null) { - stmt.bindString(4, createTime); - } - - String status = entity.getStatus(); - if (status != null) { - stmt.bindString(5, status); - } - - String createUserName = entity.getCreateUserName(); - if (createUserName != null) { - stmt.bindString(6, createUserName); - } - - String startTime = entity.getStartTime(); - if (startTime != null) { - stmt.bindString(7, startTime); - } - - String endTime = entity.getEndTime(); - if (endTime != null) { - stmt.bindString(8, endTime); - } - - String isFreeTask = entity.getIsFreeTask(); - if (isFreeTask != null) { - stmt.bindString(9, isFreeTask); - } - } - - @Override - public Long readKey(Cursor cursor, int offset) { - return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); - } - - @Override - public TaskLocalBean readEntity(Cursor cursor, int offset) { - TaskLocalBean entity = new TaskLocalBean( // - cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // taskCode - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // description - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // createTime - cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // status - cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // createUserName - cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // startTime - cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // endTime - cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8) // isFreeTask - ); - return entity; - } - - @Override - public void readEntity(Cursor cursor, TaskLocalBean entity, int offset) { - entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setTaskCode(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); - entity.setDescription(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); - entity.setCreateTime(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); - entity.setStatus(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); - entity.setCreateUserName(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); - entity.setStartTime(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); - entity.setEndTime(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); - entity.setIsFreeTask(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); - } - - @Override - protected final Long updateKeyAfterInsert(TaskLocalBean entity, long rowId) { - entity.setId(rowId); - return rowId; - } - - @Override - public Long getKey(TaskLocalBean entity) { - if(entity != null) { - return entity.getId(); - } else { - return null; - } - } - - @Override - public boolean hasKey(TaskLocalBean entity) { - return entity.getId() != null; - } - - @Override - protected final boolean isEntityUpdateable() { - return true; - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/TaskMarkerLocalBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/greendao/TaskMarkerLocalBeanDao.java deleted file mode 100644 index e96c735..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/TaskMarkerLocalBeanDao.java +++ /dev/null @@ -1,197 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import android.database.Cursor; -import android.database.sqlite.SQLiteStatement; - -import org.greenrobot.greendao.AbstractDao; -import org.greenrobot.greendao.Property; -import org.greenrobot.greendao.internal.DaoConfig; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.database.DatabaseStatement; - -import com.casic.common.detector.gd.bean.TaskMarkerLocalBean; - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** - * DAO for table "TASK_MARKER_LOCAL_BEAN". -*/ -public class TaskMarkerLocalBeanDao extends AbstractDao { - - public static final String TABLENAME = "TASK_MARKER_LOCAL_BEAN"; - - /** - * Properties of entity TaskMarkerLocalBean.
- * Can be used for QueryBuilder and for referencing column names. - */ - public static class Properties { - public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property TaskId = new Property(1, String.class, "taskId", false, "TASK_ID"); - public final static Property TaskCode = new Property(2, String.class, "taskCode", false, "TASK_CODE"); - public final static Property MarkerId = new Property(3, String.class, "markerId", false, "MARKER_ID"); - public final static Property Lng = new Property(4, double.class, "lng", false, "LNG"); - public final static Property Lat = new Property(5, double.class, "lat", false, "LAT"); - public final static Property IsDetected = new Property(6, String.class, "isDetected", false, "IS_DETECTED"); - public final static Property DetectedTime = new Property(7, String.class, "detectedTime", false, "DETECTED_TIME"); - } - - - public TaskMarkerLocalBeanDao(DaoConfig config) { - super(config); - } - - public TaskMarkerLocalBeanDao(DaoConfig config, DaoSession daoSession) { - super(config, daoSession); - } - - /** Creates the underlying database table. */ - public static void createTable(Database db, boolean ifNotExists) { - String constraint = ifNotExists? "IF NOT EXISTS ": ""; - db.execSQL("CREATE TABLE " + constraint + "\"TASK_MARKER_LOCAL_BEAN\" (" + // - "\"_id\" INTEGER PRIMARY KEY ," + // 0: id - "\"TASK_ID\" TEXT," + // 1: taskId - "\"TASK_CODE\" TEXT," + // 2: taskCode - "\"MARKER_ID\" TEXT," + // 3: markerId - "\"LNG\" REAL NOT NULL ," + // 4: lng - "\"LAT\" REAL NOT NULL ," + // 5: lat - "\"IS_DETECTED\" TEXT," + // 6: isDetected - "\"DETECTED_TIME\" TEXT);"); // 7: detectedTime - } - - /** Drops the underlying database table. */ - public static void dropTable(Database db, boolean ifExists) { - String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"TASK_MARKER_LOCAL_BEAN\""; - db.execSQL(sql); - } - - @Override - protected final void bindValues(DatabaseStatement stmt, TaskMarkerLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String taskId = entity.getTaskId(); - if (taskId != null) { - stmt.bindString(2, taskId); - } - - String taskCode = entity.getTaskCode(); - if (taskCode != null) { - stmt.bindString(3, taskCode); - } - - String markerId = entity.getMarkerId(); - if (markerId != null) { - stmt.bindString(4, markerId); - } - stmt.bindDouble(5, entity.getLng()); - stmt.bindDouble(6, entity.getLat()); - - String isDetected = entity.getIsDetected(); - if (isDetected != null) { - stmt.bindString(7, isDetected); - } - - String detectedTime = entity.getDetectedTime(); - if (detectedTime != null) { - stmt.bindString(8, detectedTime); - } - } - - @Override - protected final void bindValues(SQLiteStatement stmt, TaskMarkerLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String taskId = entity.getTaskId(); - if (taskId != null) { - stmt.bindString(2, taskId); - } - - String taskCode = entity.getTaskCode(); - if (taskCode != null) { - stmt.bindString(3, taskCode); - } - - String markerId = entity.getMarkerId(); - if (markerId != null) { - stmt.bindString(4, markerId); - } - stmt.bindDouble(5, entity.getLng()); - stmt.bindDouble(6, entity.getLat()); - - String isDetected = entity.getIsDetected(); - if (isDetected != null) { - stmt.bindString(7, isDetected); - } - - String detectedTime = entity.getDetectedTime(); - if (detectedTime != null) { - stmt.bindString(8, detectedTime); - } - } - - @Override - public Long readKey(Cursor cursor, int offset) { - return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); - } - - @Override - public TaskMarkerLocalBean readEntity(Cursor cursor, int offset) { - TaskMarkerLocalBean entity = new TaskMarkerLocalBean( // - cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // taskId - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // taskCode - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // markerId - cursor.getDouble(offset + 4), // lng - cursor.getDouble(offset + 5), // lat - cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // isDetected - cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7) // detectedTime - ); - return entity; - } - - @Override - public void readEntity(Cursor cursor, TaskMarkerLocalBean entity, int offset) { - entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setTaskId(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); - entity.setTaskCode(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); - entity.setMarkerId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); - entity.setLng(cursor.getDouble(offset + 4)); - entity.setLat(cursor.getDouble(offset + 5)); - entity.setIsDetected(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); - entity.setDetectedTime(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); - } - - @Override - protected final Long updateKeyAfterInsert(TaskMarkerLocalBean entity, long rowId) { - entity.setId(rowId); - return rowId; - } - - @Override - public Long getKey(TaskMarkerLocalBean entity) { - if(entity != null) { - return entity.getId(); - } else { - return null; - } - } - - @Override - public boolean hasKey(TaskMarkerLocalBean entity) { - return entity.getId() != null; - } - - @Override - protected final boolean isEntityUpdateable() { - return true; - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/model/TaskModel.java b/app/src/main/java/com/casic/common/detector/gd/model/TaskModel.java index 6e853ad..67ef5fb 100644 --- a/app/src/main/java/com/casic/common/detector/gd/model/TaskModel.java +++ b/app/src/main/java/com/casic/common/detector/gd/model/TaskModel.java @@ -24,7 +24,7 @@ } public static class MessageModel { - private int id; + private Long id; private String taskCode; private String description; private String deployDate; @@ -38,11 +38,11 @@ private int isValid; private List taskDetailInfos; - public int getId() { + public Long getId() { return id; } - public void setId(int id) { + public void setId(Long id) { this.id = id; } @@ -143,25 +143,25 @@ } public static class TaskDetailInfosModel { - private int id; + private long id; private String taskId; private String taskCode; private Object markerName; - private int markerId; + private String markerId; private String markerIdReal; private double longitude; private double latitude; private int isChecked; private int isNormal; - private Object imagePath; - private Object description; - private Object finishTime; + private String imagePath; + private String description; + private String finishTime; - public int getId() { + public long getId() { return id; } - public void setId(int id) { + public void setId(long id) { this.id = id; } @@ -189,11 +189,11 @@ this.markerName = markerName; } - public int getMarkerId() { + public String getMarkerId() { return markerId; } - public void setMarkerId(int markerId) { + public void setMarkerId(String markerId) { this.markerId = markerId; } @@ -237,27 +237,27 @@ this.isNormal = isNormal; } - public Object getImagePath() { + public String getImagePath() { return imagePath; } - public void setImagePath(Object imagePath) { + public void setImagePath(String imagePath) { this.imagePath = imagePath; } - public Object getDescription() { + public String getDescription() { return description; } - public void setDescription(Object description) { + public void setDescription(String description) { this.description = description; } - public Object getFinishTime() { + public String getFinishTime() { return finishTime; } - public void setFinishTime(Object finishTime) { + public void setFinishTime(String finishTime) { this.finishTime = finishTime; } } diff --git a/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitService.kt index 7522a87..0adad51 100644 --- a/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitService.kt @@ -50,7 +50,7 @@ */ @Multipart @POST("/ems/marker/save-marker-photo.do") - suspend fun installLabel( + suspend fun install( @PartMap jsonMarker: Map, @Part fileBuffer1: MultipartBody.Part?, @Part fileBuffer2: MultipartBody.Part?, diff --git a/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitServiceManager.kt index 5f6c701..ae2a0fa 100644 --- a/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitServiceManager.kt +++ b/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitServiceManager.kt @@ -37,22 +37,28 @@ /** * 获取标识器信息文件 */ - suspend fun getMarkerFile(userId: String, companyId: String): String { - return createApi().getMarkerFile(userId, companyId) + suspend fun getMarkerFile(): String { + val companyId = SaveKeyValues.getValue(LocaleConstant.USER_COMPANY_ID, "") as String + /** + * 后台设计如此,都传companyId + * */ + return createApi().getMarkerFile(companyId, companyId) } /** * 获取巡检工单 */ - suspend fun getTasksByUser(userName: String): String { + suspend fun getTasksByUser(): String { + val userName = SaveKeyValues.getValue(LocaleConstant.USER_NAME, "") as String return createApi().getTasksByUser(userName) } /** * 提交工单 */ - suspend fun uploadTask(userId: String, taskId: String?, state: String): String { + suspend fun uploadTask(taskId: String?, state: String): String { + val userId = SaveKeyValues.getValue(LocaleConstant.USER_ID, "") as String return createApi().uploadTask(userId, taskId.toString(), state) } @@ -60,8 +66,7 @@ * 安装新标识器 * Multipart上传图片,文件,带多参数上传 */ - suspend fun installLabel( - companyId: String, + suspend fun installMarker( recordType: String, markerObjectType: String, pipeMaterial: String, @@ -77,7 +82,6 @@ road: String, constructTime: String, ownerComp: String, - markerObjectId: String, markerId: String, markerType: String, markerDepth: String, @@ -89,6 +93,8 @@ memo: String, realPaths: ArrayList ): String { + val companyId = SaveKeyValues.getValue(LocaleConstant.USER_COMPANY_ID, "") as String + val objectId = SaveKeyValues.getValue(LocaleConstant.OBJECT_ID, "") as String val param = JsonObject() param.addProperty("companyId", companyId) param.addProperty("recordType", recordType) @@ -106,7 +112,7 @@ param.addProperty("road", road) param.addProperty("constructTime", constructTime) param.addProperty("ownerComp", ownerComp) - param.addProperty("markerObjectId", markerObjectId) + param.addProperty("markerObjectId", objectId) param.addProperty("markerId", markerId) param.addProperty("markerType", markerType) param.addProperty("markerDepth", markerDepth) @@ -133,19 +139,19 @@ return when (multiParts.size) { 3 -> { - createApi().installLabel(res, multiParts[0], multiParts[1], multiParts[2]) + createApi().install(res, multiParts[0], multiParts[1], multiParts[2]) } 2 -> { - createApi().installLabel(res, multiParts[0], multiParts[1], null) + createApi().install(res, multiParts[0], multiParts[1], null) } 1 -> { - createApi().installLabel(res, multiParts[0], null, null) + createApi().install(res, multiParts[0], null, null) } else -> { - createApi().installLabel(res, null, null, null) + createApi().install(res, null, null, null) } } } @@ -216,7 +222,7 @@ /** * 上传自由巡检过程中发现的标识器 */ - suspend fun uploadTaskMarker(taskId: String, ids: ArrayList): String { + suspend fun uploadTaskMarker(taskId: Long, ids: ArrayList): String { val param = JsonObject() param.addProperty("taskId", taskId) param.addProperty("ids", ids.joinToString(separator = ",")) diff --git a/app/src/main/java/com/casic/common/detector/gd/service/NtripConnectService.kt b/app/src/main/java/com/casic/common/detector/gd/service/NtripConnectService.kt index de9ac80..20e1a6a 100644 --- a/app/src/main/java/com/casic/common/detector/gd/service/NtripConnectService.kt +++ b/app/src/main/java/com/casic/common/detector/gd/service/NtripConnectService.kt @@ -9,10 +9,6 @@ import android.util.Log import android.view.Gravity import android.widget.Toast -import androidx.lifecycle.Lifecycle -import androidx.lifecycle.LifecycleOwner -import androidx.lifecycle.LifecycleRegistry -import androidx.lifecycle.lifecycleScope import com.casic.common.detector.gd.base.BaseApplication import com.casic.common.detector.gd.extensions.convertToGPGGA import com.casic.common.detector.gd.utils.LocaleConstant @@ -23,26 +19,24 @@ import com.pengxh.kt.lite.utils.WeakReferenceHandler import com.pengxh.kt.lite.utils.socket.tcp.OnTcpConnectStateListener import com.pengxh.kt.lite.utils.socket.tcp.TcpClient +import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.Job import kotlinx.coroutines.launch import java.io.OutputStream import java.nio.charset.StandardCharsets -class NtripConnectService : Service(), LifecycleOwner, OnTcpConnectStateListener, Handler.Callback { +class NtripConnectService : Service(), OnTcpConnectStateListener, Handler.Callback { companion object { var weakReferenceHandler: WeakReferenceHandler? = null } private val kTag = "NtripConnectService" - private val registry = LifecycleRegistry(this) private val socketClient by lazy { TcpClient(this) } private var outStream: OutputStream? = null - - override fun getLifecycle(): Lifecycle { - return registry - } + private val serviceScope = CoroutineScope(Dispatchers.Main + Job()) // 创建一个独立的CoroutineScope override fun onBind(intent: Intent?): IBinder? { return null @@ -117,7 +111,7 @@ * */ val result = String(this, StandardCharsets.UTF_8) if (result.contains("ICY 200 OK")) { - lifecycleScope.launch(Dispatchers.Main) { + serviceScope.launch { "高精度定位服务连接成功".show(this@NtripConnectService) } //连接服务即打开串口 @@ -135,12 +129,12 @@ * Content-Type: text/plain * Connection: clos * */ - lifecycleScope.launch(Dispatchers.Main) { + serviceScope.launch { "差分定位服务鉴权失败,无法解析位置".show(this@NtripConnectService) } } else { //居中显示 - lifecycleScope.launch(Dispatchers.Main) { + serviceScope.launch { val toast = Toast.makeText( this@NtripConnectService, "收到千寻数据,长度:${size}", Toast.LENGTH_SHORT ) @@ -167,7 +161,7 @@ return } - lifecycleScope.launch(Dispatchers.IO) { + serviceScope.launch(Dispatchers.IO) { socketClient.start(remoteHost, remotePort.toInt()) } } diff --git a/app/src/main/java/com/casic/common/detector/gd/utils/DataBaseManager.kt b/app/src/main/java/com/casic/common/detector/gd/utils/DataBaseManager.kt deleted file mode 100644 index aa22759..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/utils/DataBaseManager.kt +++ /dev/null @@ -1,200 +0,0 @@ -package com.casic.common.detector.gd.utils - -import com.casic.common.detector.gd.base.BaseApplication -import com.casic.common.detector.gd.bean.MarkerLocalBean -import com.casic.common.detector.gd.bean.TaskLocalBean -import com.casic.common.detector.gd.bean.TaskMarkerLocalBean -import com.casic.common.detector.gd.greendao.MarkerLocalBeanDao -import com.casic.common.detector.gd.greendao.TaskLocalBeanDao -import com.casic.common.detector.gd.greendao.TaskMarkerLocalBeanDao -import com.casic.common.detector.gd.model.TaskDetailLocalModel -import com.casic.common.detector.gd.model.TaskModel - -class DataBaseManager private constructor() { - companion object { - //Kotlin委托模式双重锁单例 - val get by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) { - DataBaseManager() - } - } - - private var taskLocalBeanDao = BaseApplication.get().getDaoSession().taskLocalBeanDao - private var taskMarkerLocalBeanDao = - BaseApplication.get().getDaoSession().taskMarkerLocalBeanDao - - fun saveTaskInLocale(task: TaskModel.MessageModel) { - val bean = TaskLocalBean() - bean.id = task.id.toLong() - bean.taskCode = task.taskCode - bean.description = task.description - bean.createTime = task.deployDate - bean.status = task.status - bean.createUserName = task.creatorName - if (task.beginDate == null) { - bean.startTime = "" - } - if (task.endDate == null) { - bean.endTime = "" - } - bean.isFreeTask = "0" - if (!bean.isExist()) { - taskLocalBeanDao.insert(bean) - } - } - - fun saveTaskInLocale(bean: TaskLocalBean) { - if (!bean.isExist()) { - taskLocalBeanDao.insert(bean) - } - } - - private fun TaskLocalBean.isExist(): Boolean { - val result = taskLocalBeanDao.queryBuilder().where( - TaskLocalBeanDao.Properties.Id.eq(this.id) - ).list() - return !result.isNullOrEmpty() - } - - fun saveTaskMarkerInLocale( - taskId: Int, taskCode: String, marker: TaskModel.MessageModel.TaskDetailInfosModel - ) { - val bean = TaskMarkerLocalBean() - bean.id = marker.id.toLong() - bean.taskId = taskId.toString() - bean.taskCode = taskCode - bean.markerId = marker.markerIdReal - bean.lng = marker.longitude - bean.lat = marker.latitude - bean.isDetected = "0" - bean.detectedTime = "" - if (!bean.isExist()) { - taskMarkerLocalBeanDao.insert(bean) - } - } - - private fun TaskMarkerLocalBean.isExist(): Boolean { - val result = taskMarkerLocalBeanDao.queryBuilder().where( - TaskMarkerLocalBeanDao.Properties.Id.eq(this.id) - ).list() - return !result.isNullOrEmpty() - } - - fun loadLocalTask(): ArrayList { - val result = ArrayList() - - val tasks = taskLocalBeanDao.loadAll() - tasks.forEach { - val model = TaskDetailLocalModel() - model.taskId = it.id.toString() - model.taskCode = it.taskCode - model.description = it.description - model.createTime = it.createTime - model.status = it.status - model.createUserName = it.createUserName - model.isFreeTask = it.isFreeTask - - val markers = ArrayList() - if (it.isFreeTask == "0") { - //非自由巡检才有Marker - val markerLocalBeans = taskMarkerLocalBeanDao.queryBuilder().where( - TaskMarkerLocalBeanDao.Properties.TaskId.eq(it.id), - TaskMarkerLocalBeanDao.Properties.TaskCode.eq(it.taskCode) - ).list() - markerLocalBeans.forEach { marker -> - val localModel = TaskDetailLocalModel.TaskMarkerLocalModel() - localModel.markerId = marker.markerId - localModel.lng = marker.lng - localModel.lat = marker.lat - localModel.isDetected = marker.isDetected - localModel.detectedTime = marker.detectedTime - - markers.add(localModel) - } - } - model.markerModels = markers - result.add(model) - } - return result - } - - fun deleteLocalTaskById(taskId: String, taskCode: String) { - val task = taskLocalBeanDao.queryBuilder().where( - TaskLocalBeanDao.Properties.Id.eq(taskId), - TaskLocalBeanDao.Properties.TaskCode.eq(taskCode) - ).list().firstOrNull() ?: return - taskLocalBeanDao.delete(task) - - //删除此任务关联的Marker。非自由巡检才有Marker - if (task.isFreeTask == "0") { - val markers = taskMarkerLocalBeanDao.queryBuilder() - .where( - TaskMarkerLocalBeanDao.Properties.TaskId.eq(taskId), - TaskMarkerLocalBeanDao.Properties.TaskCode.eq(taskCode) - ).list() - markers.forEach { - taskMarkerLocalBeanDao.delete(it) - } - } - } - - fun queryTaskMarkerById( - taskId: String, taskCode: String, markerId: String, state: String - ): TaskMarkerLocalBean? { - return taskMarkerLocalBeanDao.queryBuilder() - .where( - TaskMarkerLocalBeanDao.Properties.TaskId.eq(taskId), - TaskMarkerLocalBeanDao.Properties.TaskCode.eq(taskCode), - TaskMarkerLocalBeanDao.Properties.MarkerId.eq(markerId), - TaskMarkerLocalBeanDao.Properties.IsDetected.eq(state) - ).list().firstOrNull() - } - - fun updateLocalTaskMarkerState(marker: TaskMarkerLocalBean) { - marker.isDetected = "1" - taskMarkerLocalBeanDao.update(marker) - } - - fun queryMarkerByState(state: String): List { - return taskMarkerLocalBeanDao.queryBuilder() - .where(TaskMarkerLocalBeanDao.Properties.IsDetected.eq(state)) - .list() - } - - private var markerLocalBeanDao = BaseApplication.get().getDaoSession().markerLocalBeanDao - - fun clearMarkers() { - markerLocalBeanDao.deleteAll() - } - - fun saveMarkerInLocale(bean: MarkerLocalBean) { - markerLocalBeanDao.insert(bean) - } - - fun loadMarkers(): MutableList { - return markerLocalBeanDao.loadAll() - } - - fun loadMarkersByCondition(selectedItem: String, value: String?): MutableList { - val property = when (selectedItem) { - LocaleConstant.SPINNER_ARRAY[0] -> MarkerLocalBeanDao.Properties.MarkerId - LocaleConstant.SPINNER_ARRAY[1] -> MarkerLocalBeanDao.Properties.Area - LocaleConstant.SPINNER_ARRAY[2] -> MarkerLocalBeanDao.Properties.Line - LocaleConstant.SPINNER_ARRAY[3] -> MarkerLocalBeanDao.Properties.Road - LocaleConstant.SPINNER_ARRAY[4] -> MarkerLocalBeanDao.Properties.Owner - LocaleConstant.SPINNER_ARRAY[5] -> MarkerLocalBeanDao.Properties.InstallationDept - LocaleConstant.SPINNER_ARRAY[6] -> MarkerLocalBeanDao.Properties.UpdateTime - else -> MarkerLocalBeanDao.Properties.Remark - } - return if (value == null) { - markerLocalBeanDao.queryBuilder().where(property.isNotNull).list() - } else { - markerLocalBeanDao.queryBuilder().where(property.eq(value)).list() - } - } - - fun queryMarkerById(markerId: String): List { - return markerLocalBeanDao.queryBuilder() - .where(MarkerLocalBeanDao.Properties.MarkerId.eq(markerId)) - .list() - } -} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/utils/DetectorDataBase.java b/app/src/main/java/com/casic/common/detector/gd/utils/DetectorDataBase.java new file mode 100644 index 0000000..f686cac --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/utils/DetectorDataBase.java @@ -0,0 +1,21 @@ +package com.casic.common.detector.gd.utils; + +import androidx.room.Database; +import androidx.room.RoomDatabase; + +import com.casic.common.detector.gd.bean.MarkerBean; +import com.casic.common.detector.gd.bean.TaskBean; +import com.casic.common.detector.gd.bean.TaskMarkerBean; +import com.casic.common.detector.gd.dao.MarkerBeanDao; +import com.casic.common.detector.gd.dao.TaskBeanDao; +import com.casic.common.detector.gd.dao.TaskMarkerBeanDao; + + +@Database(entities = {MarkerBean.class, TaskBean.class, TaskMarkerBean.class}, version = 1) +public abstract class DetectorDataBase extends RoomDatabase { + public abstract MarkerBeanDao markerBeanDao(); + + public abstract TaskBeanDao taskBeanDao(); + + public abstract TaskMarkerBeanDao taskMarkerBeanDao(); +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/utils/ExcelKit.kt b/app/src/main/java/com/casic/common/detector/gd/utils/ExcelKit.kt index 200fac7..015969f 100644 --- a/app/src/main/java/com/casic/common/detector/gd/utils/ExcelKit.kt +++ b/app/src/main/java/com/casic/common/detector/gd/utils/ExcelKit.kt @@ -1,19 +1,19 @@ package com.casic.common.detector.gd.utils -import com.casic.common.detector.gd.bean.MarkerLocalBean +import com.casic.common.detector.gd.base.BaseApplication +import com.casic.common.detector.gd.bean.MarkerBean import jxl.Workbook import jxl.read.biff.BiffException import java.io.File object ExcelKit { - fun read(filePath: String): ArrayList { - val result = ArrayList() + fun read(filePath: String): ArrayList { + val result = ArrayList() try { val workbook = Workbook.getWorkbook(File(filePath)) val sheet = workbook.getSheet(0) - for (i in 1 until sheet.rows) { - val marker = MarkerLocalBean() + val marker = MarkerBean() marker.pipelineType = sheet.getCell(0, i).contents marker.pipelineDiameter = sheet.getCell(1, i).contents marker.pipelineMaterial = sheet.getCell(2, i).contents @@ -40,9 +40,10 @@ marker.objectType = sheet.getCell(23, i).contents marker.color = sheet.getCell(24, i).contents marker.imagePath = sheet.getCell(25, i).contents - - result.add(marker) - DataBaseManager.get.saveMarkerInLocale(marker) + if (!marker.markerId.isNullOrBlank()) { + result.add(marker) + BaseApplication.get().dataBase.markerBeanDao().insert(marker) + } } workbook.close() } catch (e: BiffException) { diff --git a/app/src/main/java/com/casic/common/detector/gd/utils/LocaleConstant.kt b/app/src/main/java/com/casic/common/detector/gd/utils/LocaleConstant.kt index c658924..8ac5f76 100644 --- a/app/src/main/java/com/casic/common/detector/gd/utils/LocaleConstant.kt +++ b/app/src/main/java/com/casic/common/detector/gd/utils/LocaleConstant.kt @@ -1,6 +1,8 @@ package com.casic.common.detector.gd.utils import android.Manifest +import androidx.sqlite.db.SimpleSQLiteQuery +import androidx.sqlite.db.SupportSQLiteQuery object LocaleConstant { @@ -59,4 +61,19 @@ var BURY_METHOD_ARRAY = arrayOf("直埋", "圆管", "管块", "管沟", "架空") var IDENTIFIER_TYPE_ARRAY = arrayOf("EM30", "EM50", "EM14") var COLOR_ARRAY = arrayOf("蓝色", "橙色", "红色", "黑色", "紫色", "黄色", "绿色") + + fun buildQuery(selectedItem: String, value: String): SupportSQLiteQuery { + val columnName = when (selectedItem) { + SPINNER_ARRAY[0] -> "markerId" + SPINNER_ARRAY[1] -> "area" + SPINNER_ARRAY[2] -> "line" + SPINNER_ARRAY[3] -> "road" + SPINNER_ARRAY[4] -> "owner" + SPINNER_ARRAY[5] -> "installationDept" + SPINNER_ARRAY[6] -> "updateTime" + else -> "remark" + } + val queryBuilder = StringBuilder("SELECT * FROM marker_detail WHERE $columnName = ?") + return SimpleSQLiteQuery(queryBuilder.toString(), arrayOf(value)) + } } \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index d0cb423..921c8c8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,25 +1,20 @@ import java.text.SimpleDateFormat -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply plugin: 'org.greenrobot.greendao' +plugins { + id('com.android.application') + id('org.jetbrains.kotlin.android') +} android { - compileSdkVersion 33 + namespace 'com.casic.common.detector.gd' + compileSdk 35 defaultConfig { - applicationId "com.casic.common.detector.gd" - minSdkVersion 26 - targetSdkVersion 33 + applicationId 'com.casic.common.detector.gd' + minSdk 26 + targetSdk 35 versionCode 5092 - versionName "5.0.9.2" - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } + versionName '5.0.9.2' } signingConfigs { @@ -31,6 +26,14 @@ } } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + signingConfig signingConfigs.release + } + } + compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 @@ -47,27 +50,16 @@ } } - kotlin { - experimental { - coroutines 'enable' - } - } - buildFeatures { + buildConfig true viewBinding true } - applicationVariants.configureEach { variant -> - variant.outputs.configureEach { - outputFileName = "COM_TCY_" + getBuildDate() + "_" + defaultConfig.versionName + ".apk" + applicationVariants.configureEach { + outputs.configureEach { + outputFileName = 'COM_TCY_' + getBuildDate() + '_' + defaultConfig.versionName + '.apk' } } - - greendao { - schemaVersion 1//数据库版本号 - targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 - daoPackage "${defaultConfig.applicationId}.greendao"//设置DaoMaster、DaoSession、Dao包名 - } } static def getBuildDate() { @@ -76,27 +68,22 @@ } dependencies { - //基础依赖库 - implementation 'com.github.AndroidCoderPeng:Kotlin-lite-lib:1.1.4' - implementation 'androidx.core:core-ktx:1.9.0' - def base_version = "1.6.1" - implementation "androidx.appcompat:appcompat:${base_version}" - implementation "com.google.android.material:material:${base_version}" + implementation 'com.github.AndroidCoderPeng:Kotlin-lite-lib:1.1.5' + implementation 'androidx.core:core-ktx:1.13.1' + implementation 'androidx.appcompat:appcompat:1.7.0' + implementation 'com.google.android.material:material:1.12.0' //Google官方授权框架 implementation 'pub.devrel:easypermissions:3.0.0' - //沉浸式状态栏。基础依赖包,必须要依赖 - implementation 'com.gyf.immersionbar:immersionbar:3.0.0' - //fragment快速实现 - implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0' + //沉浸式状态栏 + implementation 'com.geyifeng.immersionbar:immersionbar:3.2.2' //官方Json解析库 implementation 'com.google.code.gson:gson:2.10.1' - def vm_version = '2.5.1' //Kotlin协程 - implementation "androidx.lifecycle:lifecycle-runtime-ktx:${vm_version}" + implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.2' //MVVM+LiveData - implementation "androidx.lifecycle:lifecycle-livedata-ktx:${vm_version}" - implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:${vm_version}" - implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.6.2' + implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2' + implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' //返回值转换器 implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' @@ -105,9 +92,10 @@ implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' //网络请求和接口封装 implementation 'com.squareup.retrofit2:retrofit:2.9.0' - implementation 'com.squareup.okhttp3:okhttp:4.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.12.0' //数据库框架 - implementation 'org.greenrobot:greendao:3.3.0' + implementation 'androidx.room:room-runtime:2.6.1' + annotationProcessor 'androidx.room:room-compiler:2.5.2' //高德导航、定位、地图三合一 implementation 'com.amap.api:navi-3dmap:latest.integration' //经纬度逆编码 @@ -115,7 +103,7 @@ //excel implementation 'net.sourceforge.jexcelapi:jxl:2.6.12' //图片加载框架 - implementation 'com.github.bumptech.glide:glide:4.9.0' + implementation 'com.github.bumptech.glide:glide:4.12.0' //图片选择框架 implementation 'io.github.lucksiege:pictureselector:v3.11.1' //大图 diff --git a/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt b/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt index 7b695ff..50ba734 100644 --- a/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt +++ b/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt @@ -4,9 +4,9 @@ import android.app.Application import android.os.Bundle import android.util.Log -import com.casic.common.detector.gd.greendao.DaoMaster -import com.casic.common.detector.gd.greendao.DaoSession +import androidx.room.Room.databaseBuilder import com.casic.common.detector.gd.uart.SerialPort +import com.casic.common.detector.gd.utils.DetectorDataBase import com.casic.common.detector.gd.utils.GpioManager import com.pengxh.kt.lite.extensions.show import com.pengxh.kt.lite.utils.SaveKeyValues @@ -43,44 +43,42 @@ private var application: BaseApplication by Delegates.notNull() fun get() = application - - private lateinit var daoSession: DaoSession } + lateinit var dataBase: DetectorDataBase + override fun onCreate() { super.onCreate() application = this SaveKeyValues.initSharedPreferences(this) CrashReport.initCrashReport(this, "01e80d3a74", true) - val devOpenHelper = DaoMaster.DevOpenHelper(this, "Detector.db", null) - val daoMaster = DaoMaster(devOpenHelper.writableDatabase) - daoSession = daoMaster.newSession() + dataBase = databaseBuilder(this, DetectorDataBase::class.java, "Detector.db") + .allowMainThreadQueries() + .build() /** * Open the serial port * */ try { serialPorts.apply { - add(SerialPort(File("/dev/ttysWK1"), 9600, 0)) - //千寻报文数据下发串口号 - add(SerialPort(File("/dev/ttyS1"), 9600, 0)) + add(SerialPort(File("/dev/ttysWK1"), 9600, 0)) //信号通讯串口 + add(SerialPort(File("/dev/ttyS1"), 9600, 0)) //千寻报文数据下发串口号 } Log.d(kTag, "onCreate: 已初始化 ${serialPorts.size} 个串口") } catch (e: SecurityException) { "您没有串口的读写权限!".show(this) + e.printStackTrace() } catch (e: IOException) { "因为不明原因,串口无法打开!".show(this) + e.printStackTrace() } catch (e: InvalidParameterException) { "请检查串口!".show(this) + e.printStackTrace() } registerActivityLifecycleCallbacks(this) } - fun getDaoSession(): DaoSession { - return daoSession - } - override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) { } diff --git a/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt b/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt index 053b9dd..1d0c9e3 100644 --- a/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt +++ b/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt @@ -14,12 +14,10 @@ import com.casic.common.detector.gd.utils.SerialPortCommand import com.pengxh.kt.lite.utils.WeakReferenceHandler import java.io.IOException -import java.util.Timer abstract class SerialPortBaseActivity : AppCompatActivity(), Handler.Callback { private val kTag = "SerialPortBaseActivity" - private val taskTimer by lazy { Timer() } private val weakReferenceHandler by lazy { WeakReferenceHandler(this) } private val serialPorts by lazy { BaseApplication.get().getSerialPorts() } protected lateinit var binding: VB @@ -30,7 +28,6 @@ setContentView(binding.root) setupTopBarLayout() initOnCreate(savedInstanceState) - observeRequestState() initEvent() if (serialPorts.isNotEmpty()) { @@ -71,11 +68,6 @@ abstract fun initOnCreate(savedInstanceState: Bundle?) /** - * 数据请求状态监听 - */ - abstract fun observeRequestState() - - /** * 初始化业务逻辑 */ abstract fun initEvent() diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java new file mode 100644 index 0000000..7a18c20 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java @@ -0,0 +1,255 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 从平台下载的标识器本地库实体类 + */ +@Entity(tableName = "marker_detail") +public class MarkerBean { + @PrimaryKey(autoGenerate = true) + private long id; //主键ID + private String pipelineType; // 管线类型 + private String pipelineDiameter; // 管线直径 + private String pipelineMaterial; // 管材 + private String buryMethod; // 埋设方式 + private String buryDepth; // 埋深 + private String area; // 所属区域 + private String line; // 所属线路 + private String road; // 所属道路 + private String constructTime; // 建设年代 + private String owner; // 权属单位 + private String objectId; // 标识对象ID,无实际用途 + private String markerId; // 标识器ID + private String markerType; // 标识器类型 + private String markerDepth; // 标识器埋深 + private String installationDept; // 安装部门 + private String lng; // 经度 + private String lat; // 纬度 + private String updateTime; // 最后修改时间,更新时间 + private String remark; // 备注信息 + private String underlyingPipelineType; // 下层管线类型 + private String underlyingPipelineDepth; // 下层埋深 + private String underlyingPipelineDiameter; // 下层管径 + private String underlyingPipelineMaterial; // 下层管材 + private String objectType; //标识对象类型 + private String color; // 颜色 + private String imagePath; // 图片路径 + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getPipelineType() { + return pipelineType; + } + + public void setPipelineType(String pipelineType) { + this.pipelineType = pipelineType; + } + + public String getPipelineDiameter() { + return pipelineDiameter; + } + + public void setPipelineDiameter(String pipelineDiameter) { + this.pipelineDiameter = pipelineDiameter; + } + + public String getPipelineMaterial() { + return pipelineMaterial; + } + + public void setPipelineMaterial(String pipelineMaterial) { + this.pipelineMaterial = pipelineMaterial; + } + + public String getBuryMethod() { + return buryMethod; + } + + public void setBuryMethod(String buryMethod) { + this.buryMethod = buryMethod; + } + + public String getBuryDepth() { + return buryDepth; + } + + public void setBuryDepth(String buryDepth) { + this.buryDepth = buryDepth; + } + + public String getArea() { + return area; + } + + public void setArea(String area) { + this.area = area; + } + + public String getLine() { + return line; + } + + public void setLine(String line) { + this.line = line; + } + + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + + public String getConstructTime() { + return constructTime; + } + + public void setConstructTime(String constructTime) { + this.constructTime = constructTime; + } + + public String getOwner() { + return owner; + } + + public void setOwner(String owner) { + this.owner = owner; + } + + public String getObjectId() { + return objectId; + } + + public void setObjectId(String objectId) { + this.objectId = objectId; + } + + public String getMarkerId() { + return markerId; + } + + public void setMarkerId(String markerId) { + this.markerId = markerId; + } + + public String getMarkerType() { + return markerType; + } + + public void setMarkerType(String markerType) { + this.markerType = markerType; + } + + public String getMarkerDepth() { + return markerDepth; + } + + public void setMarkerDepth(String markerDepth) { + this.markerDepth = markerDepth; + } + + public String getInstallationDept() { + return installationDept; + } + + public void setInstallationDept(String installationDept) { + this.installationDept = installationDept; + } + + public String getLng() { + return lng; + } + + public void setLng(String lng) { + this.lng = lng; + } + + public String getLat() { + return lat; + } + + public void setLat(String lat) { + this.lat = lat; + } + + public String getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } + + public String getUnderlyingPipelineType() { + return underlyingPipelineType; + } + + public void setUnderlyingPipelineType(String underlyingPipelineType) { + this.underlyingPipelineType = underlyingPipelineType; + } + + public String getUnderlyingPipelineDepth() { + return underlyingPipelineDepth; + } + + public void setUnderlyingPipelineDepth(String underlyingPipelineDepth) { + this.underlyingPipelineDepth = underlyingPipelineDepth; + } + + public String getUnderlyingPipelineDiameter() { + return underlyingPipelineDiameter; + } + + public void setUnderlyingPipelineDiameter(String underlyingPipelineDiameter) { + this.underlyingPipelineDiameter = underlyingPipelineDiameter; + } + + public String getUnderlyingPipelineMaterial() { + return underlyingPipelineMaterial; + } + + public void setUnderlyingPipelineMaterial(String underlyingPipelineMaterial) { + this.underlyingPipelineMaterial = underlyingPipelineMaterial; + } + + public String getObjectType() { + return objectType; + } + + public void setObjectType(String objectType) { + this.objectType = objectType; + } + + public String getColor() { + return color; + } + + public void setColor(String color) { + this.color = color; + } + + public String getImagePath() { + return imagePath; + } + + public void setImagePath(String imagePath) { + this.imagePath = imagePath; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java deleted file mode 100644 index 3f2fcdc..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java +++ /dev/null @@ -1,327 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 从平台下载的标识器本地库实体类 - */ -@Entity -public class MarkerLocalBean { - @Id(autoincrement = true) - private Long id;//本地库主键ID - - // 管线类型 - private String pipelineType; - // 管线直径 - private String pipelineDiameter; - // 管材 - private String pipelineMaterial; - // 埋设方式 - private String buryMethod; - // 埋深 - private String buryDepth; - // 所属区域 - private String area; - // 所属线路 - private String line; - // 所属道路 - private String road; - // 建设年代 - private String constructTime; - // 权属单位 - private String owner; - //标识对象ID,无实际用途 - @Deprecated - private String objectId; - // 标识器ID - private String markerId; - // 标识器类型 - private String markerType; - // 标识器埋深 - private String markerDepth; - // 安装部门 - private String installationDept; - // 经度 - private String lng; - // 纬度 - private String lat; - //最后修改时间,更新时间 - private String updateTime; - // 备注信息 - private String remark; - // 下层管线类型 - private String underlyingPipelineType; - // 下层埋深 - private String underlyingPipelineDepth; - // 下层管径 - private String underlyingPipelineDiameter; - // 下层管材 - private String underlyingPipelineMaterial; - //标识对象类型 - private String objectType; - // 颜色 - private String color; - // 图片路径 - private String imagePath; - - @Generated(hash = 1479045776) - public MarkerLocalBean(Long id, String pipelineType, String pipelineDiameter, - String pipelineMaterial, String buryMethod, String buryDepth, - String area, String line, String road, String constructTime, - String owner, String objectId, String markerId, String markerType, - String markerDepth, String installationDept, String lng, String lat, - String updateTime, String remark, String underlyingPipelineType, - String underlyingPipelineDepth, String underlyingPipelineDiameter, - String underlyingPipelineMaterial, String objectType, String color, - String imagePath) { - this.id = id; - this.pipelineType = pipelineType; - this.pipelineDiameter = pipelineDiameter; - this.pipelineMaterial = pipelineMaterial; - this.buryMethod = buryMethod; - this.buryDepth = buryDepth; - this.area = area; - this.line = line; - this.road = road; - this.constructTime = constructTime; - this.owner = owner; - this.objectId = objectId; - this.markerId = markerId; - this.markerType = markerType; - this.markerDepth = markerDepth; - this.installationDept = installationDept; - this.lng = lng; - this.lat = lat; - this.updateTime = updateTime; - this.remark = remark; - this.underlyingPipelineType = underlyingPipelineType; - this.underlyingPipelineDepth = underlyingPipelineDepth; - this.underlyingPipelineDiameter = underlyingPipelineDiameter; - this.underlyingPipelineMaterial = underlyingPipelineMaterial; - this.objectType = objectType; - this.color = color; - this.imagePath = imagePath; - } - - @Generated(hash = 1538606012) - public MarkerLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getPipelineType() { - return this.pipelineType; - } - - public void setPipelineType(String pipelineType) { - this.pipelineType = pipelineType; - } - - public String getPipelineDiameter() { - return this.pipelineDiameter; - } - - public void setPipelineDiameter(String pipelineDiameter) { - this.pipelineDiameter = pipelineDiameter; - } - - public String getPipelineMaterial() { - return this.pipelineMaterial; - } - - public void setPipelineMaterial(String pipelineMaterial) { - this.pipelineMaterial = pipelineMaterial; - } - - public String getBuryMethod() { - return this.buryMethod; - } - - public void setBuryMethod(String buryMethod) { - this.buryMethod = buryMethod; - } - - public String getBuryDepth() { - return this.buryDepth; - } - - public void setBuryDepth(String buryDepth) { - this.buryDepth = buryDepth; - } - - public String getArea() { - return this.area; - } - - public void setArea(String area) { - this.area = area; - } - - public String getLine() { - return this.line; - } - - public void setLine(String line) { - this.line = line; - } - - public String getRoad() { - return this.road; - } - - public void setRoad(String road) { - this.road = road; - } - - public String getConstructTime() { - return this.constructTime; - } - - public void setConstructTime(String constructTime) { - this.constructTime = constructTime; - } - - public String getOwner() { - return this.owner; - } - - public void setOwner(String owner) { - this.owner = owner; - } - - public String getObjectId() { - return this.objectId; - } - - public void setObjectId(String objectId) { - this.objectId = objectId; - } - - public String getMarkerId() { - return this.markerId; - } - - public void setMarkerId(String markerId) { - this.markerId = markerId; - } - - public String getMarkerType() { - return this.markerType; - } - - public void setMarkerType(String markerType) { - this.markerType = markerType; - } - - public String getMarkerDepth() { - return this.markerDepth; - } - - public void setMarkerDepth(String markerDepth) { - this.markerDepth = markerDepth; - } - - public String getInstallationDept() { - return this.installationDept; - } - - public void setInstallationDept(String installationDept) { - this.installationDept = installationDept; - } - - public String getLng() { - return this.lng; - } - - public void setLng(String lng) { - this.lng = lng; - } - - public String getLat() { - return this.lat; - } - - public void setLat(String lat) { - this.lat = lat; - } - - public String getUpdateTime() { - return this.updateTime; - } - - public void setUpdateTime(String updateTime) { - this.updateTime = updateTime; - } - - public String getRemark() { - return this.remark; - } - - public void setRemark(String remark) { - this.remark = remark; - } - - public String getUnderlyingPipelineType() { - return this.underlyingPipelineType; - } - - public void setUnderlyingPipelineType(String underlyingPipelineType) { - this.underlyingPipelineType = underlyingPipelineType; - } - - public String getUnderlyingPipelineDepth() { - return this.underlyingPipelineDepth; - } - - public void setUnderlyingPipelineDepth(String underlyingPipelineDepth) { - this.underlyingPipelineDepth = underlyingPipelineDepth; - } - - public String getUnderlyingPipelineDiameter() { - return this.underlyingPipelineDiameter; - } - - public void setUnderlyingPipelineDiameter(String underlyingPipelineDiameter) { - this.underlyingPipelineDiameter = underlyingPipelineDiameter; - } - - public String getUnderlyingPipelineMaterial() { - return this.underlyingPipelineMaterial; - } - - public void setUnderlyingPipelineMaterial(String underlyingPipelineMaterial) { - this.underlyingPipelineMaterial = underlyingPipelineMaterial; - } - - public String getObjectType() { - return this.objectType; - } - - public void setObjectType(String objectType) { - this.objectType = objectType; - } - - public String getColor() { - return this.color; - } - - public void setColor(String color) { - this.color = color; - } - - public String getImagePath() { - return this.imagePath; - } - - public void setImagePath(String imagePath) { - this.imagePath = imagePath; - } -} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java new file mode 100644 index 0000000..5c88fdf --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java @@ -0,0 +1,93 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 巡检任务本地库实体类,不包含任务里面需要巡检的标识器信息 + */ +@Entity(tableName = "task_detail") +public class TaskBean { + @PrimaryKey(autoGenerate = true) + private long id;//主键ID + private String taskCode; // 任务编号 + private String description; // 任务名称 + private String createTime; // 任务创建的时间 + private String status; // 任务状态 + private String createUserName; // 任务创建者名称 + private String startTime; // 任务被开始执行的时间 + private String endTime; // 任务执行结束的时间 + private String isFree; // 是否自由巡检。1-是,0-否 + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getTaskCode() { + return taskCode; + } + + public void setTaskCode(String taskCode) { + this.taskCode = taskCode; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getCreateUserName() { + return createUserName; + } + + public void setCreateUserName(String createUserName) { + this.createUserName = createUserName; + } + + public String getStartTime() { + return startTime; + } + + public void setStartTime(String startTime) { + this.startTime = startTime; + } + + public String getEndTime() { + return endTime; + } + + public void setEndTime(String endTime) { + this.endTime = endTime; + } + + public String getIsFree() { + return isFree; + } + + public void setIsFree(String isFree) { + this.isFree = isFree; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java deleted file mode 100644 index 91737b3..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java +++ /dev/null @@ -1,114 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 巡检任务本地库实体类,不包含任务里面需要巡检的标识器信息 - */ -@Entity -public class TaskLocalBean { - @Id - private Long id;//任务ID - - private String taskCode;//任务编号 - private String description;//任务名称 - private String createTime;//任务创建的时间 - private String status;//任务状态 - private String createUserName;//任务创建者名称 - private String startTime;//任务被开始执行的时间 - private String endTime;//任务执行结束的时间 - private String isFreeTask;//是否自由巡检。1-是,0-否 - - @Generated(hash = 1482022528) - public TaskLocalBean(Long id, String taskCode, String description, - String createTime, String status, String createUserName, - String startTime, String endTime, String isFreeTask) { - this.id = id; - this.taskCode = taskCode; - this.description = description; - this.createTime = createTime; - this.status = status; - this.createUserName = createUserName; - this.startTime = startTime; - this.endTime = endTime; - this.isFreeTask = isFreeTask; - } - - @Generated(hash = 949704588) - public TaskLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getTaskCode() { - return this.taskCode; - } - - public void setTaskCode(String taskCode) { - this.taskCode = taskCode; - } - - public String getDescription() { - return this.description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getCreateTime() { - return this.createTime; - } - - public void setCreateTime(String createTime) { - this.createTime = createTime; - } - - public String getStatus() { - return this.status; - } - - public void setStatus(String status) { - this.status = status; - } - - public String getCreateUserName() { - return this.createUserName; - } - - public void setCreateUserName(String createUserName) { - this.createUserName = createUserName; - } - - public String getStartTime() { - return this.startTime; - } - - public void setStartTime(String startTime) { - this.startTime = startTime; - } - - public String getEndTime() { - return this.endTime; - } - - public void setEndTime(String endTime) { - this.endTime = endTime; - } - - public String getIsFreeTask() { - return this.isFreeTask; - } - - public void setIsFreeTask(String isFreeTask) { - this.isFreeTask = isFreeTask; - } -} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerBean.java new file mode 100644 index 0000000..c563a60 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerBean.java @@ -0,0 +1,110 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 巡检任务里面需要巡检的标识器信息本地库实体类 + */ +@Entity(tableName = "task_marker_info") +public class TaskMarkerBean { + //标识器后台库的主键ID,不是标识器实际ID + @PrimaryKey(autoGenerate = true) + private long id; + + /** + * 任务ID,通过此字段关联[TaskBean.id] + */ + private String taskId; + + /** + * 任务Code,通过此字段关联[TaskBean.taskCode] + *

+ *

+ * 双重验证,防止出现同时刻重复的情况 + */ + private String taskCode; + + /** + * 对应后台字段[TaskModel.MessageModel.TaskDetailInfosModel.markerIdReal],也就是探测仪扫描出来的ID + */ + private String markerId; + + private Double lng; + private Double lat; + + /** + * 是否已被探测到 + * 1-是,0-否 + */ + private String isDetected; + + /** + * 被探测到的时间,对应后台字段[TaskModel.MessageModel.TaskDetailInfosModel.finishTime] + */ + private String detectedTime; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getTaskId() { + return taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getTaskCode() { + return taskCode; + } + + public void setTaskCode(String taskCode) { + this.taskCode = taskCode; + } + + public String getMarkerId() { + return markerId; + } + + public void setMarkerId(String markerId) { + this.markerId = markerId; + } + + public Double getLng() { + return lng; + } + + public void setLng(Double lng) { + this.lng = lng; + } + + public Double getLat() { + return lat; + } + + public void setLat(Double lat) { + this.lat = lat; + } + + public String getIsDetected() { + return isDetected; + } + + public void setIsDetected(String isDetected) { + this.isDetected = isDetected; + } + + public String getDetectedTime() { + return detectedTime; + } + + public void setDetectedTime(String detectedTime) { + this.detectedTime = detectedTime; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerLocalBean.java deleted file mode 100644 index de9f459..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerLocalBean.java +++ /dev/null @@ -1,128 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import com.casic.common.detector.gd.model.TaskModel; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 巡检任务里面需要巡检的标识器信息本地库实体类 - */ -@Entity -public class TaskMarkerLocalBean { - @Id - private Long id;//标识器后台库的主键ID,不是标识器实际ID - - /** - * 任务ID,通过此字段关联{@link TaskLocalBean#id} - */ - private String taskId; - - /** - * 任务Code,通过此字段关联{@link TaskLocalBean#taskCode} - *

- * 双重验证,防止出现同时刻重复的情况 - */ - private String taskCode; - - /** - * 对应后台字段{@link TaskModel.MessageModel.TaskDetailInfosModel#markerIdReal},也就是探测仪扫描出来的ID - */ - private String markerId; - - private double lng; - private double lat; - - /** - * 是否已被探测到 - * 1-是,0-否 - */ - private String isDetected; - - /** - * 被探测到的时间,对应后台字段{@link TaskModel.MessageModel.TaskDetailInfosModel#finishTime} - */ - private String detectedTime; - - @Generated(hash = 677328533) - public TaskMarkerLocalBean(Long id, String taskId, String taskCode, String markerId, - double lng, double lat, String isDetected, String detectedTime) { - this.id = id; - this.taskId = taskId; - this.taskCode = taskCode; - this.markerId = markerId; - this.lng = lng; - this.lat = lat; - this.isDetected = isDetected; - this.detectedTime = detectedTime; - } - - @Generated(hash = 1162404642) - public TaskMarkerLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getTaskId() { - return this.taskId; - } - - public void setTaskId(String taskId) { - this.taskId = taskId; - } - - public String getTaskCode() { - return this.taskCode; - } - - public void setTaskCode(String taskCode) { - this.taskCode = taskCode; - } - - public String getMarkerId() { - return this.markerId; - } - - public void setMarkerId(String markerId) { - this.markerId = markerId; - } - - public double getLng() { - return this.lng; - } - - public void setLng(double lng) { - this.lng = lng; - } - - public double getLat() { - return this.lat; - } - - public void setLat(double lat) { - this.lat = lat; - } - - public String getIsDetected() { - return this.isDetected; - } - - public void setIsDetected(String isDetected) { - this.isDetected = isDetected; - } - - public String getDetectedTime() { - return this.detectedTime; - } - - public void setDetectedTime(String detectedTime) { - this.detectedTime = detectedTime; - } -} diff --git a/app/src/main/java/com/casic/common/detector/gd/dao/MarkerBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/dao/MarkerBeanDao.java new file mode 100644 index 0000000..2beb7ed --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/dao/MarkerBeanDao.java @@ -0,0 +1,29 @@ +package com.casic.common.detector.gd.dao; + +import androidx.room.Dao; +import androidx.room.Insert; +import androidx.room.Query; +import androidx.room.RawQuery; +import androidx.sqlite.db.SupportSQLiteQuery; + +import com.casic.common.detector.gd.bean.MarkerBean; + +import java.util.List; + +@Dao +public interface MarkerBeanDao { + @Query("DELETE FROM marker_detail") + void deleteAll(); + + @Insert + void insert(MarkerBean marker); + + @Query("SELECT * FROM marker_detail") + List loadAll(); + + @Query("SELECT * FROM marker_detail WHERE markerId = :markerId") + List queryMarkerById(String markerId); + + @RawQuery + List loadMarkersByCondition(SupportSQLiteQuery query); +} diff --git a/app/src/main/java/com/casic/common/detector/gd/dao/TaskBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/dao/TaskBeanDao.java new file mode 100644 index 0000000..9c70ac2 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/dao/TaskBeanDao.java @@ -0,0 +1,120 @@ +package com.casic.common.detector.gd.dao; + +import androidx.room.Dao; +import androidx.room.Insert; +import androidx.room.Query; +import androidx.room.Transaction; + +import com.casic.common.detector.gd.bean.TaskBean; +import com.casic.common.detector.gd.bean.TaskMarkerBean; +import com.casic.common.detector.gd.model.TaskDetailLocalModel; +import com.casic.common.detector.gd.model.TaskModel; +import com.casic.common.detector.gd.utils.LocaleConstant; +import com.pengxh.kt.lite.utils.SaveKeyValues; + +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Locale; + +@Dao +public interface TaskBeanDao { + @Query("SELECT COUNT(*) FROM task_detail WHERE id = :taskId") + int isTaskExist(long taskId); + + @Insert + void insert(TaskBean task); + + default void saveTask(Long taskId, String taskName) { + if (isTaskExist(taskId) == 0) { + TaskBean task = new TaskBean(); + task.setId(taskId); + task.setTaskCode(new SimpleDateFormat("yyyyMMddHHmmss", Locale.CHINA).format(new Date())); + task.setDescription(taskName); + String time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA).format(new Date()); + task.setCreateTime(time); + task.setStatus("0"); + String userName = (String) SaveKeyValues.INSTANCE.getValue(LocaleConstant.USER_NAME, ""); + task.setCreateUserName(userName); + task.setStartTime(time); + task.setEndTime(""); + task.setIsFree("1"); + insert(task); + } + } + + default void saveTask(TaskModel.MessageModel model) { + TaskBean task = new TaskBean(); + task.setId(model.getId()); + task.setTaskCode(model.getTaskCode()); + task.setDescription(model.getDescription()); + task.setCreateTime(model.getDeployDate()); + task.setStatus(model.getStatus()); + task.setCreateUserName(model.getCreatorName()); + task.setStartTime(model.getBeginDate()); + task.setEndTime(model.getEndDate()); + task.setIsFree("0"); + if (isTaskExist(task.getId()) == 0) { + insert(task); + } + } + + @Query("SELECT * FROM task_detail") + List loadAll(); + + @Transaction + default ArrayList loadLocalTask(TaskMarkerBeanDao taskMarkerBeanDao) { + ArrayList result = new ArrayList<>(); + List tasks = loadAll(); + for (TaskBean it : tasks) { + TaskDetailLocalModel model = new TaskDetailLocalModel(); + model.setTaskId(String.valueOf(it.getId())); + model.setTaskCode(it.getTaskCode()); + model.setDescription(it.getDescription()); + model.setCreateTime(it.getCreateTime()); + model.setStatus(it.getStatus()); + model.setCreateUserName(it.getCreateUserName()); + model.setIsFreeTask(it.getIsFree()); + ArrayList results = new ArrayList<>(); + if ("0".equals(it.getIsFree())) { + // 非自由巡检才有Marker + List markers = taskMarkerBeanDao.getMarkersByIdAndCode(String.valueOf(it.getId()), it.getTaskCode()); + for (TaskMarkerBean marker : markers) { + TaskDetailLocalModel.TaskMarkerLocalModel localModel = new TaskDetailLocalModel.TaskMarkerLocalModel(); + localModel.setMarkerId(marker.getMarkerId()); + localModel.setLng(marker.getLng()); + localModel.setLat(marker.getLat()); + localModel.setIsDetected(marker.getIsDetected()); + localModel.setDetectedTime(marker.getDetectedTime()); + + results.add(localModel); + } + } + model.setMarkerModels(results); + result.add(model); + } + return result; + } + + @Query("DELETE FROM task_detail WHERE id = :taskId AND taskCode = :taskCode") + void deleteTaskById(long taskId, String taskCode); + + @Transaction + default void deleteLocalTaskById(long taskId, String taskCode, TaskMarkerBeanDao taskMarkerBeanDao) { + TaskBean task = loadAll().stream() + .filter(it -> it.getId() == taskId && taskCode.equals(it.getTaskCode())) + .findFirst() + .orElse(null); + if (task == null) return; + deleteTaskById(taskId, taskCode); + + // 删除此任务关联的Marker。非自由巡检才有Marker + if ("0".equals(task.getIsFree())) { + List markers = taskMarkerBeanDao.getMarkersByIdAndCode(String.valueOf(task.getId()), task.getTaskCode()); + for (TaskMarkerBean marker : markers) { + taskMarkerBeanDao.delete(marker); + } + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/dao/TaskMarkerBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/dao/TaskMarkerBeanDao.java new file mode 100644 index 0000000..cc2156a --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/dao/TaskMarkerBeanDao.java @@ -0,0 +1,52 @@ +package com.casic.common.detector.gd.dao; + +import androidx.room.Dao; +import androidx.room.Delete; +import androidx.room.Insert; +import androidx.room.Query; +import androidx.room.Update; + +import com.casic.common.detector.gd.bean.TaskMarkerBean; +import com.casic.common.detector.gd.model.TaskModel; + +import java.util.List; + +@Dao +public interface TaskMarkerBeanDao { + + @Insert + void insert(TaskMarkerBean marker); + + @Query("SELECT COUNT(*) FROM task_marker_info WHERE id = :markerId") + int isMarkerExist(String markerId); + + default void saveTaskMarker(long taskId, String taskCode, TaskModel.MessageModel.TaskDetailInfosModel marker) { + if (isMarkerExist(marker.getMarkerId()) == 0) { + TaskMarkerBean bean = new TaskMarkerBean(); + bean.setId(marker.getId()); + bean.setTaskId(String.valueOf(taskId)); + bean.setTaskCode(taskCode); + bean.setMarkerId(marker.getMarkerIdReal()); + bean.setLng(marker.getLongitude()); + bean.setLat(marker.getLatitude()); + bean.setIsDetected("0"); + bean.setDetectedTime(""); + insert(bean); + } + } + + @Query("SELECT * FROM task_marker_info WHERE taskId = :taskId AND taskCode = :taskCode AND markerId = :markerId AND isDetected = :state") + TaskMarkerBean queryTaskMarkerById(String taskId, String taskCode, String markerId, String state); + + @Update + void updateLocalTaskMarkerState(TaskMarkerBean marker); + + @Query("SELECT * FROM task_marker_info WHERE isDetected = :state") + List queryMarkerByState(String state); + + @Query("SELECT * FROM task_marker_info WHERE taskId = :taskId AND taskCode = :taskCode") + List getMarkersByIdAndCode(String taskId, String taskCode); + + @Delete + void delete(TaskMarkerBean marker); +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/extensions/Long.kt b/app/src/main/java/com/casic/common/detector/gd/extensions/Long.kt deleted file mode 100644 index 6713d8d..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/extensions/Long.kt +++ /dev/null @@ -1,10 +0,0 @@ -package com.casic.common.detector.gd.extensions - -import java.text.SimpleDateFormat -import java.util.Date -import java.util.Locale - -fun Long.createTaskCode(): String { - val dateFormat = SimpleDateFormat("yyyyMMddHHmmss", Locale.CHINA) - return dateFormat.format(Date(this)) -} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoMaster.java b/app/src/main/java/com/casic/common/detector/gd/greendao/DaoMaster.java deleted file mode 100644 index 6ab94b3..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoMaster.java +++ /dev/null @@ -1,102 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import android.content.Context; -import android.database.sqlite.SQLiteDatabase; -import android.database.sqlite.SQLiteDatabase.CursorFactory; -import android.util.Log; - -import org.greenrobot.greendao.AbstractDaoMaster; -import org.greenrobot.greendao.database.StandardDatabase; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.database.DatabaseOpenHelper; -import org.greenrobot.greendao.identityscope.IdentityScopeType; - - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** - * Master of DAO (schema version 1): knows all DAOs. - */ -public class DaoMaster extends AbstractDaoMaster { - public static final int SCHEMA_VERSION = 1; - - /** Creates underlying database table using DAOs. */ - public static void createAllTables(Database db, boolean ifNotExists) { - MarkerLocalBeanDao.createTable(db, ifNotExists); - TaskLocalBeanDao.createTable(db, ifNotExists); - TaskMarkerLocalBeanDao.createTable(db, ifNotExists); - } - - /** Drops underlying database table using DAOs. */ - public static void dropAllTables(Database db, boolean ifExists) { - MarkerLocalBeanDao.dropTable(db, ifExists); - TaskLocalBeanDao.dropTable(db, ifExists); - TaskMarkerLocalBeanDao.dropTable(db, ifExists); - } - - /** - * WARNING: Drops all table on Upgrade! Use only during development. - * Convenience method using a {@link DevOpenHelper}. - */ - public static DaoSession newDevSession(Context context, String name) { - Database db = new DevOpenHelper(context, name).getWritableDb(); - DaoMaster daoMaster = new DaoMaster(db); - return daoMaster.newSession(); - } - - public DaoMaster(SQLiteDatabase db) { - this(new StandardDatabase(db)); - } - - public DaoMaster(Database db) { - super(db, SCHEMA_VERSION); - registerDaoClass(MarkerLocalBeanDao.class); - registerDaoClass(TaskLocalBeanDao.class); - registerDaoClass(TaskMarkerLocalBeanDao.class); - } - - public DaoSession newSession() { - return new DaoSession(db, IdentityScopeType.Session, daoConfigMap); - } - - public DaoSession newSession(IdentityScopeType type) { - return new DaoSession(db, type, daoConfigMap); - } - - /** - * Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} - - */ - public static abstract class OpenHelper extends DatabaseOpenHelper { - public OpenHelper(Context context, String name) { - super(context, name, SCHEMA_VERSION); - } - - public OpenHelper(Context context, String name, CursorFactory factory) { - super(context, name, factory, SCHEMA_VERSION); - } - - @Override - public void onCreate(Database db) { - Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION); - createAllTables(db, false); - } - } - - /** WARNING: Drops all table on Upgrade! Use only during development. */ - public static class DevOpenHelper extends OpenHelper { - public DevOpenHelper(Context context, String name) { - super(context, name); - } - - public DevOpenHelper(Context context, String name, CursorFactory factory) { - super(context, name, factory); - } - - @Override - public void onUpgrade(Database db, int oldVersion, int newVersion) { - Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables"); - dropAllTables(db, true); - onCreate(db); - } - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoSession.java b/app/src/main/java/com/casic/common/detector/gd/greendao/DaoSession.java deleted file mode 100644 index c8b1a20..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoSession.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import java.util.Map; - -import org.greenrobot.greendao.AbstractDao; -import org.greenrobot.greendao.AbstractDaoSession; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.identityscope.IdentityScopeType; -import org.greenrobot.greendao.internal.DaoConfig; - -import com.casic.common.detector.gd.bean.MarkerLocalBean; -import com.casic.common.detector.gd.bean.TaskLocalBean; -import com.casic.common.detector.gd.bean.TaskMarkerLocalBean; - -import com.casic.common.detector.gd.greendao.MarkerLocalBeanDao; -import com.casic.common.detector.gd.greendao.TaskLocalBeanDao; -import com.casic.common.detector.gd.greendao.TaskMarkerLocalBeanDao; - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. - -/** - * {@inheritDoc} - * - * @see org.greenrobot.greendao.AbstractDaoSession - */ -public class DaoSession extends AbstractDaoSession { - - private final DaoConfig markerLocalBeanDaoConfig; - private final DaoConfig taskLocalBeanDaoConfig; - private final DaoConfig taskMarkerLocalBeanDaoConfig; - - private final MarkerLocalBeanDao markerLocalBeanDao; - private final TaskLocalBeanDao taskLocalBeanDao; - private final TaskMarkerLocalBeanDao taskMarkerLocalBeanDao; - - public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> - daoConfigMap) { - super(db); - - markerLocalBeanDaoConfig = daoConfigMap.get(MarkerLocalBeanDao.class).clone(); - markerLocalBeanDaoConfig.initIdentityScope(type); - - taskLocalBeanDaoConfig = daoConfigMap.get(TaskLocalBeanDao.class).clone(); - taskLocalBeanDaoConfig.initIdentityScope(type); - - taskMarkerLocalBeanDaoConfig = daoConfigMap.get(TaskMarkerLocalBeanDao.class).clone(); - taskMarkerLocalBeanDaoConfig.initIdentityScope(type); - - markerLocalBeanDao = new MarkerLocalBeanDao(markerLocalBeanDaoConfig, this); - taskLocalBeanDao = new TaskLocalBeanDao(taskLocalBeanDaoConfig, this); - taskMarkerLocalBeanDao = new TaskMarkerLocalBeanDao(taskMarkerLocalBeanDaoConfig, this); - - registerDao(MarkerLocalBean.class, markerLocalBeanDao); - registerDao(TaskLocalBean.class, taskLocalBeanDao); - registerDao(TaskMarkerLocalBean.class, taskMarkerLocalBeanDao); - } - - public void clear() { - markerLocalBeanDaoConfig.clearIdentityScope(); - taskLocalBeanDaoConfig.clearIdentityScope(); - taskMarkerLocalBeanDaoConfig.clearIdentityScope(); - } - - public MarkerLocalBeanDao getMarkerLocalBeanDao() { - return markerLocalBeanDao; - } - - public TaskLocalBeanDao getTaskLocalBeanDao() { - return taskLocalBeanDao; - } - - public TaskMarkerLocalBeanDao getTaskMarkerLocalBeanDao() { - return taskMarkerLocalBeanDao; - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/MarkerLocalBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/greendao/MarkerLocalBeanDao.java deleted file mode 100644 index 2f792c3..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/MarkerLocalBeanDao.java +++ /dev/null @@ -1,479 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import android.database.Cursor; -import android.database.sqlite.SQLiteStatement; - -import org.greenrobot.greendao.AbstractDao; -import org.greenrobot.greendao.Property; -import org.greenrobot.greendao.internal.DaoConfig; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.database.DatabaseStatement; - -import com.casic.common.detector.gd.bean.MarkerLocalBean; - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** - * DAO for table "MARKER_LOCAL_BEAN". -*/ -public class MarkerLocalBeanDao extends AbstractDao { - - public static final String TABLENAME = "MARKER_LOCAL_BEAN"; - - /** - * Properties of entity MarkerLocalBean.
- * Can be used for QueryBuilder and for referencing column names. - */ - public static class Properties { - public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property PipelineType = new Property(1, String.class, "pipelineType", false, "PIPELINE_TYPE"); - public final static Property PipelineDiameter = new Property(2, String.class, "pipelineDiameter", false, "PIPELINE_DIAMETER"); - public final static Property PipelineMaterial = new Property(3, String.class, "pipelineMaterial", false, "PIPELINE_MATERIAL"); - public final static Property BuryMethod = new Property(4, String.class, "buryMethod", false, "BURY_METHOD"); - public final static Property BuryDepth = new Property(5, String.class, "buryDepth", false, "BURY_DEPTH"); - public final static Property Area = new Property(6, String.class, "area", false, "AREA"); - public final static Property Line = new Property(7, String.class, "line", false, "LINE"); - public final static Property Road = new Property(8, String.class, "road", false, "ROAD"); - public final static Property ConstructTime = new Property(9, String.class, "constructTime", false, "CONSTRUCT_TIME"); - public final static Property Owner = new Property(10, String.class, "owner", false, "OWNER"); - public final static Property ObjectId = new Property(11, String.class, "objectId", false, "OBJECT_ID"); - public final static Property MarkerId = new Property(12, String.class, "markerId", false, "MARKER_ID"); - public final static Property MarkerType = new Property(13, String.class, "markerType", false, "MARKER_TYPE"); - public final static Property MarkerDepth = new Property(14, String.class, "markerDepth", false, "MARKER_DEPTH"); - public final static Property InstallationDept = new Property(15, String.class, "installationDept", false, "INSTALLATION_DEPT"); - public final static Property Lng = new Property(16, String.class, "lng", false, "LNG"); - public final static Property Lat = new Property(17, String.class, "lat", false, "LAT"); - public final static Property UpdateTime = new Property(18, String.class, "updateTime", false, "UPDATE_TIME"); - public final static Property Remark = new Property(19, String.class, "remark", false, "REMARK"); - public final static Property UnderlyingPipelineType = new Property(20, String.class, "underlyingPipelineType", false, "UNDERLYING_PIPELINE_TYPE"); - public final static Property UnderlyingPipelineDepth = new Property(21, String.class, "underlyingPipelineDepth", false, "UNDERLYING_PIPELINE_DEPTH"); - public final static Property UnderlyingPipelineDiameter = new Property(22, String.class, "underlyingPipelineDiameter", false, "UNDERLYING_PIPELINE_DIAMETER"); - public final static Property UnderlyingPipelineMaterial = new Property(23, String.class, "underlyingPipelineMaterial", false, "UNDERLYING_PIPELINE_MATERIAL"); - public final static Property ObjectType = new Property(24, String.class, "objectType", false, "OBJECT_TYPE"); - public final static Property Color = new Property(25, String.class, "color", false, "COLOR"); - public final static Property ImagePath = new Property(26, String.class, "imagePath", false, "IMAGE_PATH"); - } - - - public MarkerLocalBeanDao(DaoConfig config) { - super(config); - } - - public MarkerLocalBeanDao(DaoConfig config, DaoSession daoSession) { - super(config, daoSession); - } - - /** Creates the underlying database table. */ - public static void createTable(Database db, boolean ifNotExists) { - String constraint = ifNotExists? "IF NOT EXISTS ": ""; - db.execSQL("CREATE TABLE " + constraint + "\"MARKER_LOCAL_BEAN\" (" + // - "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id - "\"PIPELINE_TYPE\" TEXT," + // 1: pipelineType - "\"PIPELINE_DIAMETER\" TEXT," + // 2: pipelineDiameter - "\"PIPELINE_MATERIAL\" TEXT," + // 3: pipelineMaterial - "\"BURY_METHOD\" TEXT," + // 4: buryMethod - "\"BURY_DEPTH\" TEXT," + // 5: buryDepth - "\"AREA\" TEXT," + // 6: area - "\"LINE\" TEXT," + // 7: line - "\"ROAD\" TEXT," + // 8: road - "\"CONSTRUCT_TIME\" TEXT," + // 9: constructTime - "\"OWNER\" TEXT," + // 10: owner - "\"OBJECT_ID\" TEXT," + // 11: objectId - "\"MARKER_ID\" TEXT," + // 12: markerId - "\"MARKER_TYPE\" TEXT," + // 13: markerType - "\"MARKER_DEPTH\" TEXT," + // 14: markerDepth - "\"INSTALLATION_DEPT\" TEXT," + // 15: installationDept - "\"LNG\" TEXT," + // 16: lng - "\"LAT\" TEXT," + // 17: lat - "\"UPDATE_TIME\" TEXT," + // 18: updateTime - "\"REMARK\" TEXT," + // 19: remark - "\"UNDERLYING_PIPELINE_TYPE\" TEXT," + // 20: underlyingPipelineType - "\"UNDERLYING_PIPELINE_DEPTH\" TEXT," + // 21: underlyingPipelineDepth - "\"UNDERLYING_PIPELINE_DIAMETER\" TEXT," + // 22: underlyingPipelineDiameter - "\"UNDERLYING_PIPELINE_MATERIAL\" TEXT," + // 23: underlyingPipelineMaterial - "\"OBJECT_TYPE\" TEXT," + // 24: objectType - "\"COLOR\" TEXT," + // 25: color - "\"IMAGE_PATH\" TEXT);"); // 26: imagePath - } - - /** Drops the underlying database table. */ - public static void dropTable(Database db, boolean ifExists) { - String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"MARKER_LOCAL_BEAN\""; - db.execSQL(sql); - } - - @Override - protected final void bindValues(DatabaseStatement stmt, MarkerLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String pipelineType = entity.getPipelineType(); - if (pipelineType != null) { - stmt.bindString(2, pipelineType); - } - - String pipelineDiameter = entity.getPipelineDiameter(); - if (pipelineDiameter != null) { - stmt.bindString(3, pipelineDiameter); - } - - String pipelineMaterial = entity.getPipelineMaterial(); - if (pipelineMaterial != null) { - stmt.bindString(4, pipelineMaterial); - } - - String buryMethod = entity.getBuryMethod(); - if (buryMethod != null) { - stmt.bindString(5, buryMethod); - } - - String buryDepth = entity.getBuryDepth(); - if (buryDepth != null) { - stmt.bindString(6, buryDepth); - } - - String area = entity.getArea(); - if (area != null) { - stmt.bindString(7, area); - } - - String line = entity.getLine(); - if (line != null) { - stmt.bindString(8, line); - } - - String road = entity.getRoad(); - if (road != null) { - stmt.bindString(9, road); - } - - String constructTime = entity.getConstructTime(); - if (constructTime != null) { - stmt.bindString(10, constructTime); - } - - String owner = entity.getOwner(); - if (owner != null) { - stmt.bindString(11, owner); - } - - String objectId = entity.getObjectId(); - if (objectId != null) { - stmt.bindString(12, objectId); - } - - String markerId = entity.getMarkerId(); - if (markerId != null) { - stmt.bindString(13, markerId); - } - - String markerType = entity.getMarkerType(); - if (markerType != null) { - stmt.bindString(14, markerType); - } - - String markerDepth = entity.getMarkerDepth(); - if (markerDepth != null) { - stmt.bindString(15, markerDepth); - } - - String installationDept = entity.getInstallationDept(); - if (installationDept != null) { - stmt.bindString(16, installationDept); - } - - String lng = entity.getLng(); - if (lng != null) { - stmt.bindString(17, lng); - } - - String lat = entity.getLat(); - if (lat != null) { - stmt.bindString(18, lat); - } - - String updateTime = entity.getUpdateTime(); - if (updateTime != null) { - stmt.bindString(19, updateTime); - } - - String remark = entity.getRemark(); - if (remark != null) { - stmt.bindString(20, remark); - } - - String underlyingPipelineType = entity.getUnderlyingPipelineType(); - if (underlyingPipelineType != null) { - stmt.bindString(21, underlyingPipelineType); - } - - String underlyingPipelineDepth = entity.getUnderlyingPipelineDepth(); - if (underlyingPipelineDepth != null) { - stmt.bindString(22, underlyingPipelineDepth); - } - - String underlyingPipelineDiameter = entity.getUnderlyingPipelineDiameter(); - if (underlyingPipelineDiameter != null) { - stmt.bindString(23, underlyingPipelineDiameter); - } - - String underlyingPipelineMaterial = entity.getUnderlyingPipelineMaterial(); - if (underlyingPipelineMaterial != null) { - stmt.bindString(24, underlyingPipelineMaterial); - } - - String objectType = entity.getObjectType(); - if (objectType != null) { - stmt.bindString(25, objectType); - } - - String color = entity.getColor(); - if (color != null) { - stmt.bindString(26, color); - } - - String imagePath = entity.getImagePath(); - if (imagePath != null) { - stmt.bindString(27, imagePath); - } - } - - @Override - protected final void bindValues(SQLiteStatement stmt, MarkerLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String pipelineType = entity.getPipelineType(); - if (pipelineType != null) { - stmt.bindString(2, pipelineType); - } - - String pipelineDiameter = entity.getPipelineDiameter(); - if (pipelineDiameter != null) { - stmt.bindString(3, pipelineDiameter); - } - - String pipelineMaterial = entity.getPipelineMaterial(); - if (pipelineMaterial != null) { - stmt.bindString(4, pipelineMaterial); - } - - String buryMethod = entity.getBuryMethod(); - if (buryMethod != null) { - stmt.bindString(5, buryMethod); - } - - String buryDepth = entity.getBuryDepth(); - if (buryDepth != null) { - stmt.bindString(6, buryDepth); - } - - String area = entity.getArea(); - if (area != null) { - stmt.bindString(7, area); - } - - String line = entity.getLine(); - if (line != null) { - stmt.bindString(8, line); - } - - String road = entity.getRoad(); - if (road != null) { - stmt.bindString(9, road); - } - - String constructTime = entity.getConstructTime(); - if (constructTime != null) { - stmt.bindString(10, constructTime); - } - - String owner = entity.getOwner(); - if (owner != null) { - stmt.bindString(11, owner); - } - - String objectId = entity.getObjectId(); - if (objectId != null) { - stmt.bindString(12, objectId); - } - - String markerId = entity.getMarkerId(); - if (markerId != null) { - stmt.bindString(13, markerId); - } - - String markerType = entity.getMarkerType(); - if (markerType != null) { - stmt.bindString(14, markerType); - } - - String markerDepth = entity.getMarkerDepth(); - if (markerDepth != null) { - stmt.bindString(15, markerDepth); - } - - String installationDept = entity.getInstallationDept(); - if (installationDept != null) { - stmt.bindString(16, installationDept); - } - - String lng = entity.getLng(); - if (lng != null) { - stmt.bindString(17, lng); - } - - String lat = entity.getLat(); - if (lat != null) { - stmt.bindString(18, lat); - } - - String updateTime = entity.getUpdateTime(); - if (updateTime != null) { - stmt.bindString(19, updateTime); - } - - String remark = entity.getRemark(); - if (remark != null) { - stmt.bindString(20, remark); - } - - String underlyingPipelineType = entity.getUnderlyingPipelineType(); - if (underlyingPipelineType != null) { - stmt.bindString(21, underlyingPipelineType); - } - - String underlyingPipelineDepth = entity.getUnderlyingPipelineDepth(); - if (underlyingPipelineDepth != null) { - stmt.bindString(22, underlyingPipelineDepth); - } - - String underlyingPipelineDiameter = entity.getUnderlyingPipelineDiameter(); - if (underlyingPipelineDiameter != null) { - stmt.bindString(23, underlyingPipelineDiameter); - } - - String underlyingPipelineMaterial = entity.getUnderlyingPipelineMaterial(); - if (underlyingPipelineMaterial != null) { - stmt.bindString(24, underlyingPipelineMaterial); - } - - String objectType = entity.getObjectType(); - if (objectType != null) { - stmt.bindString(25, objectType); - } - - String color = entity.getColor(); - if (color != null) { - stmt.bindString(26, color); - } - - String imagePath = entity.getImagePath(); - if (imagePath != null) { - stmt.bindString(27, imagePath); - } - } - - @Override - public Long readKey(Cursor cursor, int offset) { - return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); - } - - @Override - public MarkerLocalBean readEntity(Cursor cursor, int offset) { - MarkerLocalBean entity = new MarkerLocalBean( // - cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // pipelineType - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // pipelineDiameter - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // pipelineMaterial - cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // buryMethod - cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // buryDepth - cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // area - cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // line - cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // road - cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // constructTime - cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10), // owner - cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11), // objectId - cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12), // markerId - cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13), // markerType - cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14), // markerDepth - cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15), // installationDept - cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16), // lng - cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17), // lat - cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18), // updateTime - cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19), // remark - cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20), // underlyingPipelineType - cursor.isNull(offset + 21) ? null : cursor.getString(offset + 21), // underlyingPipelineDepth - cursor.isNull(offset + 22) ? null : cursor.getString(offset + 22), // underlyingPipelineDiameter - cursor.isNull(offset + 23) ? null : cursor.getString(offset + 23), // underlyingPipelineMaterial - cursor.isNull(offset + 24) ? null : cursor.getString(offset + 24), // objectType - cursor.isNull(offset + 25) ? null : cursor.getString(offset + 25), // color - cursor.isNull(offset + 26) ? null : cursor.getString(offset + 26) // imagePath - ); - return entity; - } - - @Override - public void readEntity(Cursor cursor, MarkerLocalBean entity, int offset) { - entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setPipelineType(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); - entity.setPipelineDiameter(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); - entity.setPipelineMaterial(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); - entity.setBuryMethod(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); - entity.setBuryDepth(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); - entity.setArea(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); - entity.setLine(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); - entity.setRoad(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); - entity.setConstructTime(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9)); - entity.setOwner(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); - entity.setObjectId(cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11)); - entity.setMarkerId(cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12)); - entity.setMarkerType(cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13)); - entity.setMarkerDepth(cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14)); - entity.setInstallationDept(cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15)); - entity.setLng(cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16)); - entity.setLat(cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17)); - entity.setUpdateTime(cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18)); - entity.setRemark(cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19)); - entity.setUnderlyingPipelineType(cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20)); - entity.setUnderlyingPipelineDepth(cursor.isNull(offset + 21) ? null : cursor.getString(offset + 21)); - entity.setUnderlyingPipelineDiameter(cursor.isNull(offset + 22) ? null : cursor.getString(offset + 22)); - entity.setUnderlyingPipelineMaterial(cursor.isNull(offset + 23) ? null : cursor.getString(offset + 23)); - entity.setObjectType(cursor.isNull(offset + 24) ? null : cursor.getString(offset + 24)); - entity.setColor(cursor.isNull(offset + 25) ? null : cursor.getString(offset + 25)); - entity.setImagePath(cursor.isNull(offset + 26) ? null : cursor.getString(offset + 26)); - } - - @Override - protected final Long updateKeyAfterInsert(MarkerLocalBean entity, long rowId) { - entity.setId(rowId); - return rowId; - } - - @Override - public Long getKey(MarkerLocalBean entity) { - if(entity != null) { - return entity.getId(); - } else { - return null; - } - } - - @Override - public boolean hasKey(MarkerLocalBean entity) { - return entity.getId() != null; - } - - @Override - protected final boolean isEntityUpdateable() { - return true; - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/TaskLocalBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/greendao/TaskLocalBeanDao.java deleted file mode 100644 index fb88157..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/TaskLocalBeanDao.java +++ /dev/null @@ -1,227 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import android.database.Cursor; -import android.database.sqlite.SQLiteStatement; - -import org.greenrobot.greendao.AbstractDao; -import org.greenrobot.greendao.Property; -import org.greenrobot.greendao.internal.DaoConfig; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.database.DatabaseStatement; - -import com.casic.common.detector.gd.bean.TaskLocalBean; - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** - * DAO for table "TASK_LOCAL_BEAN". -*/ -public class TaskLocalBeanDao extends AbstractDao { - - public static final String TABLENAME = "TASK_LOCAL_BEAN"; - - /** - * Properties of entity TaskLocalBean.
- * Can be used for QueryBuilder and for referencing column names. - */ - public static class Properties { - public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property TaskCode = new Property(1, String.class, "taskCode", false, "TASK_CODE"); - public final static Property Description = new Property(2, String.class, "description", false, "DESCRIPTION"); - public final static Property CreateTime = new Property(3, String.class, "createTime", false, "CREATE_TIME"); - public final static Property Status = new Property(4, String.class, "status", false, "STATUS"); - public final static Property CreateUserName = new Property(5, String.class, "createUserName", false, "CREATE_USER_NAME"); - public final static Property StartTime = new Property(6, String.class, "startTime", false, "START_TIME"); - public final static Property EndTime = new Property(7, String.class, "endTime", false, "END_TIME"); - public final static Property IsFreeTask = new Property(8, String.class, "isFreeTask", false, "IS_FREE_TASK"); - } - - - public TaskLocalBeanDao(DaoConfig config) { - super(config); - } - - public TaskLocalBeanDao(DaoConfig config, DaoSession daoSession) { - super(config, daoSession); - } - - /** Creates the underlying database table. */ - public static void createTable(Database db, boolean ifNotExists) { - String constraint = ifNotExists? "IF NOT EXISTS ": ""; - db.execSQL("CREATE TABLE " + constraint + "\"TASK_LOCAL_BEAN\" (" + // - "\"_id\" INTEGER PRIMARY KEY ," + // 0: id - "\"TASK_CODE\" TEXT," + // 1: taskCode - "\"DESCRIPTION\" TEXT," + // 2: description - "\"CREATE_TIME\" TEXT," + // 3: createTime - "\"STATUS\" TEXT," + // 4: status - "\"CREATE_USER_NAME\" TEXT," + // 5: createUserName - "\"START_TIME\" TEXT," + // 6: startTime - "\"END_TIME\" TEXT," + // 7: endTime - "\"IS_FREE_TASK\" TEXT);"); // 8: isFreeTask - } - - /** Drops the underlying database table. */ - public static void dropTable(Database db, boolean ifExists) { - String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"TASK_LOCAL_BEAN\""; - db.execSQL(sql); - } - - @Override - protected final void bindValues(DatabaseStatement stmt, TaskLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String taskCode = entity.getTaskCode(); - if (taskCode != null) { - stmt.bindString(2, taskCode); - } - - String description = entity.getDescription(); - if (description != null) { - stmt.bindString(3, description); - } - - String createTime = entity.getCreateTime(); - if (createTime != null) { - stmt.bindString(4, createTime); - } - - String status = entity.getStatus(); - if (status != null) { - stmt.bindString(5, status); - } - - String createUserName = entity.getCreateUserName(); - if (createUserName != null) { - stmt.bindString(6, createUserName); - } - - String startTime = entity.getStartTime(); - if (startTime != null) { - stmt.bindString(7, startTime); - } - - String endTime = entity.getEndTime(); - if (endTime != null) { - stmt.bindString(8, endTime); - } - - String isFreeTask = entity.getIsFreeTask(); - if (isFreeTask != null) { - stmt.bindString(9, isFreeTask); - } - } - - @Override - protected final void bindValues(SQLiteStatement stmt, TaskLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String taskCode = entity.getTaskCode(); - if (taskCode != null) { - stmt.bindString(2, taskCode); - } - - String description = entity.getDescription(); - if (description != null) { - stmt.bindString(3, description); - } - - String createTime = entity.getCreateTime(); - if (createTime != null) { - stmt.bindString(4, createTime); - } - - String status = entity.getStatus(); - if (status != null) { - stmt.bindString(5, status); - } - - String createUserName = entity.getCreateUserName(); - if (createUserName != null) { - stmt.bindString(6, createUserName); - } - - String startTime = entity.getStartTime(); - if (startTime != null) { - stmt.bindString(7, startTime); - } - - String endTime = entity.getEndTime(); - if (endTime != null) { - stmt.bindString(8, endTime); - } - - String isFreeTask = entity.getIsFreeTask(); - if (isFreeTask != null) { - stmt.bindString(9, isFreeTask); - } - } - - @Override - public Long readKey(Cursor cursor, int offset) { - return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); - } - - @Override - public TaskLocalBean readEntity(Cursor cursor, int offset) { - TaskLocalBean entity = new TaskLocalBean( // - cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // taskCode - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // description - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // createTime - cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // status - cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // createUserName - cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // startTime - cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // endTime - cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8) // isFreeTask - ); - return entity; - } - - @Override - public void readEntity(Cursor cursor, TaskLocalBean entity, int offset) { - entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setTaskCode(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); - entity.setDescription(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); - entity.setCreateTime(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); - entity.setStatus(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); - entity.setCreateUserName(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); - entity.setStartTime(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); - entity.setEndTime(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); - entity.setIsFreeTask(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); - } - - @Override - protected final Long updateKeyAfterInsert(TaskLocalBean entity, long rowId) { - entity.setId(rowId); - return rowId; - } - - @Override - public Long getKey(TaskLocalBean entity) { - if(entity != null) { - return entity.getId(); - } else { - return null; - } - } - - @Override - public boolean hasKey(TaskLocalBean entity) { - return entity.getId() != null; - } - - @Override - protected final boolean isEntityUpdateable() { - return true; - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/TaskMarkerLocalBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/greendao/TaskMarkerLocalBeanDao.java deleted file mode 100644 index e96c735..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/TaskMarkerLocalBeanDao.java +++ /dev/null @@ -1,197 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import android.database.Cursor; -import android.database.sqlite.SQLiteStatement; - -import org.greenrobot.greendao.AbstractDao; -import org.greenrobot.greendao.Property; -import org.greenrobot.greendao.internal.DaoConfig; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.database.DatabaseStatement; - -import com.casic.common.detector.gd.bean.TaskMarkerLocalBean; - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** - * DAO for table "TASK_MARKER_LOCAL_BEAN". -*/ -public class TaskMarkerLocalBeanDao extends AbstractDao { - - public static final String TABLENAME = "TASK_MARKER_LOCAL_BEAN"; - - /** - * Properties of entity TaskMarkerLocalBean.
- * Can be used for QueryBuilder and for referencing column names. - */ - public static class Properties { - public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property TaskId = new Property(1, String.class, "taskId", false, "TASK_ID"); - public final static Property TaskCode = new Property(2, String.class, "taskCode", false, "TASK_CODE"); - public final static Property MarkerId = new Property(3, String.class, "markerId", false, "MARKER_ID"); - public final static Property Lng = new Property(4, double.class, "lng", false, "LNG"); - public final static Property Lat = new Property(5, double.class, "lat", false, "LAT"); - public final static Property IsDetected = new Property(6, String.class, "isDetected", false, "IS_DETECTED"); - public final static Property DetectedTime = new Property(7, String.class, "detectedTime", false, "DETECTED_TIME"); - } - - - public TaskMarkerLocalBeanDao(DaoConfig config) { - super(config); - } - - public TaskMarkerLocalBeanDao(DaoConfig config, DaoSession daoSession) { - super(config, daoSession); - } - - /** Creates the underlying database table. */ - public static void createTable(Database db, boolean ifNotExists) { - String constraint = ifNotExists? "IF NOT EXISTS ": ""; - db.execSQL("CREATE TABLE " + constraint + "\"TASK_MARKER_LOCAL_BEAN\" (" + // - "\"_id\" INTEGER PRIMARY KEY ," + // 0: id - "\"TASK_ID\" TEXT," + // 1: taskId - "\"TASK_CODE\" TEXT," + // 2: taskCode - "\"MARKER_ID\" TEXT," + // 3: markerId - "\"LNG\" REAL NOT NULL ," + // 4: lng - "\"LAT\" REAL NOT NULL ," + // 5: lat - "\"IS_DETECTED\" TEXT," + // 6: isDetected - "\"DETECTED_TIME\" TEXT);"); // 7: detectedTime - } - - /** Drops the underlying database table. */ - public static void dropTable(Database db, boolean ifExists) { - String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"TASK_MARKER_LOCAL_BEAN\""; - db.execSQL(sql); - } - - @Override - protected final void bindValues(DatabaseStatement stmt, TaskMarkerLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String taskId = entity.getTaskId(); - if (taskId != null) { - stmt.bindString(2, taskId); - } - - String taskCode = entity.getTaskCode(); - if (taskCode != null) { - stmt.bindString(3, taskCode); - } - - String markerId = entity.getMarkerId(); - if (markerId != null) { - stmt.bindString(4, markerId); - } - stmt.bindDouble(5, entity.getLng()); - stmt.bindDouble(6, entity.getLat()); - - String isDetected = entity.getIsDetected(); - if (isDetected != null) { - stmt.bindString(7, isDetected); - } - - String detectedTime = entity.getDetectedTime(); - if (detectedTime != null) { - stmt.bindString(8, detectedTime); - } - } - - @Override - protected final void bindValues(SQLiteStatement stmt, TaskMarkerLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String taskId = entity.getTaskId(); - if (taskId != null) { - stmt.bindString(2, taskId); - } - - String taskCode = entity.getTaskCode(); - if (taskCode != null) { - stmt.bindString(3, taskCode); - } - - String markerId = entity.getMarkerId(); - if (markerId != null) { - stmt.bindString(4, markerId); - } - stmt.bindDouble(5, entity.getLng()); - stmt.bindDouble(6, entity.getLat()); - - String isDetected = entity.getIsDetected(); - if (isDetected != null) { - stmt.bindString(7, isDetected); - } - - String detectedTime = entity.getDetectedTime(); - if (detectedTime != null) { - stmt.bindString(8, detectedTime); - } - } - - @Override - public Long readKey(Cursor cursor, int offset) { - return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); - } - - @Override - public TaskMarkerLocalBean readEntity(Cursor cursor, int offset) { - TaskMarkerLocalBean entity = new TaskMarkerLocalBean( // - cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // taskId - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // taskCode - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // markerId - cursor.getDouble(offset + 4), // lng - cursor.getDouble(offset + 5), // lat - cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // isDetected - cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7) // detectedTime - ); - return entity; - } - - @Override - public void readEntity(Cursor cursor, TaskMarkerLocalBean entity, int offset) { - entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setTaskId(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); - entity.setTaskCode(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); - entity.setMarkerId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); - entity.setLng(cursor.getDouble(offset + 4)); - entity.setLat(cursor.getDouble(offset + 5)); - entity.setIsDetected(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); - entity.setDetectedTime(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); - } - - @Override - protected final Long updateKeyAfterInsert(TaskMarkerLocalBean entity, long rowId) { - entity.setId(rowId); - return rowId; - } - - @Override - public Long getKey(TaskMarkerLocalBean entity) { - if(entity != null) { - return entity.getId(); - } else { - return null; - } - } - - @Override - public boolean hasKey(TaskMarkerLocalBean entity) { - return entity.getId() != null; - } - - @Override - protected final boolean isEntityUpdateable() { - return true; - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/model/TaskModel.java b/app/src/main/java/com/casic/common/detector/gd/model/TaskModel.java index 6e853ad..67ef5fb 100644 --- a/app/src/main/java/com/casic/common/detector/gd/model/TaskModel.java +++ b/app/src/main/java/com/casic/common/detector/gd/model/TaskModel.java @@ -24,7 +24,7 @@ } public static class MessageModel { - private int id; + private Long id; private String taskCode; private String description; private String deployDate; @@ -38,11 +38,11 @@ private int isValid; private List taskDetailInfos; - public int getId() { + public Long getId() { return id; } - public void setId(int id) { + public void setId(Long id) { this.id = id; } @@ -143,25 +143,25 @@ } public static class TaskDetailInfosModel { - private int id; + private long id; private String taskId; private String taskCode; private Object markerName; - private int markerId; + private String markerId; private String markerIdReal; private double longitude; private double latitude; private int isChecked; private int isNormal; - private Object imagePath; - private Object description; - private Object finishTime; + private String imagePath; + private String description; + private String finishTime; - public int getId() { + public long getId() { return id; } - public void setId(int id) { + public void setId(long id) { this.id = id; } @@ -189,11 +189,11 @@ this.markerName = markerName; } - public int getMarkerId() { + public String getMarkerId() { return markerId; } - public void setMarkerId(int markerId) { + public void setMarkerId(String markerId) { this.markerId = markerId; } @@ -237,27 +237,27 @@ this.isNormal = isNormal; } - public Object getImagePath() { + public String getImagePath() { return imagePath; } - public void setImagePath(Object imagePath) { + public void setImagePath(String imagePath) { this.imagePath = imagePath; } - public Object getDescription() { + public String getDescription() { return description; } - public void setDescription(Object description) { + public void setDescription(String description) { this.description = description; } - public Object getFinishTime() { + public String getFinishTime() { return finishTime; } - public void setFinishTime(Object finishTime) { + public void setFinishTime(String finishTime) { this.finishTime = finishTime; } } diff --git a/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitService.kt index 7522a87..0adad51 100644 --- a/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitService.kt @@ -50,7 +50,7 @@ */ @Multipart @POST("/ems/marker/save-marker-photo.do") - suspend fun installLabel( + suspend fun install( @PartMap jsonMarker: Map, @Part fileBuffer1: MultipartBody.Part?, @Part fileBuffer2: MultipartBody.Part?, diff --git a/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitServiceManager.kt index 5f6c701..ae2a0fa 100644 --- a/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitServiceManager.kt +++ b/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitServiceManager.kt @@ -37,22 +37,28 @@ /** * 获取标识器信息文件 */ - suspend fun getMarkerFile(userId: String, companyId: String): String { - return createApi().getMarkerFile(userId, companyId) + suspend fun getMarkerFile(): String { + val companyId = SaveKeyValues.getValue(LocaleConstant.USER_COMPANY_ID, "") as String + /** + * 后台设计如此,都传companyId + * */ + return createApi().getMarkerFile(companyId, companyId) } /** * 获取巡检工单 */ - suspend fun getTasksByUser(userName: String): String { + suspend fun getTasksByUser(): String { + val userName = SaveKeyValues.getValue(LocaleConstant.USER_NAME, "") as String return createApi().getTasksByUser(userName) } /** * 提交工单 */ - suspend fun uploadTask(userId: String, taskId: String?, state: String): String { + suspend fun uploadTask(taskId: String?, state: String): String { + val userId = SaveKeyValues.getValue(LocaleConstant.USER_ID, "") as String return createApi().uploadTask(userId, taskId.toString(), state) } @@ -60,8 +66,7 @@ * 安装新标识器 * Multipart上传图片,文件,带多参数上传 */ - suspend fun installLabel( - companyId: String, + suspend fun installMarker( recordType: String, markerObjectType: String, pipeMaterial: String, @@ -77,7 +82,6 @@ road: String, constructTime: String, ownerComp: String, - markerObjectId: String, markerId: String, markerType: String, markerDepth: String, @@ -89,6 +93,8 @@ memo: String, realPaths: ArrayList ): String { + val companyId = SaveKeyValues.getValue(LocaleConstant.USER_COMPANY_ID, "") as String + val objectId = SaveKeyValues.getValue(LocaleConstant.OBJECT_ID, "") as String val param = JsonObject() param.addProperty("companyId", companyId) param.addProperty("recordType", recordType) @@ -106,7 +112,7 @@ param.addProperty("road", road) param.addProperty("constructTime", constructTime) param.addProperty("ownerComp", ownerComp) - param.addProperty("markerObjectId", markerObjectId) + param.addProperty("markerObjectId", objectId) param.addProperty("markerId", markerId) param.addProperty("markerType", markerType) param.addProperty("markerDepth", markerDepth) @@ -133,19 +139,19 @@ return when (multiParts.size) { 3 -> { - createApi().installLabel(res, multiParts[0], multiParts[1], multiParts[2]) + createApi().install(res, multiParts[0], multiParts[1], multiParts[2]) } 2 -> { - createApi().installLabel(res, multiParts[0], multiParts[1], null) + createApi().install(res, multiParts[0], multiParts[1], null) } 1 -> { - createApi().installLabel(res, multiParts[0], null, null) + createApi().install(res, multiParts[0], null, null) } else -> { - createApi().installLabel(res, null, null, null) + createApi().install(res, null, null, null) } } } @@ -216,7 +222,7 @@ /** * 上传自由巡检过程中发现的标识器 */ - suspend fun uploadTaskMarker(taskId: String, ids: ArrayList): String { + suspend fun uploadTaskMarker(taskId: Long, ids: ArrayList): String { val param = JsonObject() param.addProperty("taskId", taskId) param.addProperty("ids", ids.joinToString(separator = ",")) diff --git a/app/src/main/java/com/casic/common/detector/gd/service/NtripConnectService.kt b/app/src/main/java/com/casic/common/detector/gd/service/NtripConnectService.kt index de9ac80..20e1a6a 100644 --- a/app/src/main/java/com/casic/common/detector/gd/service/NtripConnectService.kt +++ b/app/src/main/java/com/casic/common/detector/gd/service/NtripConnectService.kt @@ -9,10 +9,6 @@ import android.util.Log import android.view.Gravity import android.widget.Toast -import androidx.lifecycle.Lifecycle -import androidx.lifecycle.LifecycleOwner -import androidx.lifecycle.LifecycleRegistry -import androidx.lifecycle.lifecycleScope import com.casic.common.detector.gd.base.BaseApplication import com.casic.common.detector.gd.extensions.convertToGPGGA import com.casic.common.detector.gd.utils.LocaleConstant @@ -23,26 +19,24 @@ import com.pengxh.kt.lite.utils.WeakReferenceHandler import com.pengxh.kt.lite.utils.socket.tcp.OnTcpConnectStateListener import com.pengxh.kt.lite.utils.socket.tcp.TcpClient +import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.Job import kotlinx.coroutines.launch import java.io.OutputStream import java.nio.charset.StandardCharsets -class NtripConnectService : Service(), LifecycleOwner, OnTcpConnectStateListener, Handler.Callback { +class NtripConnectService : Service(), OnTcpConnectStateListener, Handler.Callback { companion object { var weakReferenceHandler: WeakReferenceHandler? = null } private val kTag = "NtripConnectService" - private val registry = LifecycleRegistry(this) private val socketClient by lazy { TcpClient(this) } private var outStream: OutputStream? = null - - override fun getLifecycle(): Lifecycle { - return registry - } + private val serviceScope = CoroutineScope(Dispatchers.Main + Job()) // 创建一个独立的CoroutineScope override fun onBind(intent: Intent?): IBinder? { return null @@ -117,7 +111,7 @@ * */ val result = String(this, StandardCharsets.UTF_8) if (result.contains("ICY 200 OK")) { - lifecycleScope.launch(Dispatchers.Main) { + serviceScope.launch { "高精度定位服务连接成功".show(this@NtripConnectService) } //连接服务即打开串口 @@ -135,12 +129,12 @@ * Content-Type: text/plain * Connection: clos * */ - lifecycleScope.launch(Dispatchers.Main) { + serviceScope.launch { "差分定位服务鉴权失败,无法解析位置".show(this@NtripConnectService) } } else { //居中显示 - lifecycleScope.launch(Dispatchers.Main) { + serviceScope.launch { val toast = Toast.makeText( this@NtripConnectService, "收到千寻数据,长度:${size}", Toast.LENGTH_SHORT ) @@ -167,7 +161,7 @@ return } - lifecycleScope.launch(Dispatchers.IO) { + serviceScope.launch(Dispatchers.IO) { socketClient.start(remoteHost, remotePort.toInt()) } } diff --git a/app/src/main/java/com/casic/common/detector/gd/utils/DataBaseManager.kt b/app/src/main/java/com/casic/common/detector/gd/utils/DataBaseManager.kt deleted file mode 100644 index aa22759..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/utils/DataBaseManager.kt +++ /dev/null @@ -1,200 +0,0 @@ -package com.casic.common.detector.gd.utils - -import com.casic.common.detector.gd.base.BaseApplication -import com.casic.common.detector.gd.bean.MarkerLocalBean -import com.casic.common.detector.gd.bean.TaskLocalBean -import com.casic.common.detector.gd.bean.TaskMarkerLocalBean -import com.casic.common.detector.gd.greendao.MarkerLocalBeanDao -import com.casic.common.detector.gd.greendao.TaskLocalBeanDao -import com.casic.common.detector.gd.greendao.TaskMarkerLocalBeanDao -import com.casic.common.detector.gd.model.TaskDetailLocalModel -import com.casic.common.detector.gd.model.TaskModel - -class DataBaseManager private constructor() { - companion object { - //Kotlin委托模式双重锁单例 - val get by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) { - DataBaseManager() - } - } - - private var taskLocalBeanDao = BaseApplication.get().getDaoSession().taskLocalBeanDao - private var taskMarkerLocalBeanDao = - BaseApplication.get().getDaoSession().taskMarkerLocalBeanDao - - fun saveTaskInLocale(task: TaskModel.MessageModel) { - val bean = TaskLocalBean() - bean.id = task.id.toLong() - bean.taskCode = task.taskCode - bean.description = task.description - bean.createTime = task.deployDate - bean.status = task.status - bean.createUserName = task.creatorName - if (task.beginDate == null) { - bean.startTime = "" - } - if (task.endDate == null) { - bean.endTime = "" - } - bean.isFreeTask = "0" - if (!bean.isExist()) { - taskLocalBeanDao.insert(bean) - } - } - - fun saveTaskInLocale(bean: TaskLocalBean) { - if (!bean.isExist()) { - taskLocalBeanDao.insert(bean) - } - } - - private fun TaskLocalBean.isExist(): Boolean { - val result = taskLocalBeanDao.queryBuilder().where( - TaskLocalBeanDao.Properties.Id.eq(this.id) - ).list() - return !result.isNullOrEmpty() - } - - fun saveTaskMarkerInLocale( - taskId: Int, taskCode: String, marker: TaskModel.MessageModel.TaskDetailInfosModel - ) { - val bean = TaskMarkerLocalBean() - bean.id = marker.id.toLong() - bean.taskId = taskId.toString() - bean.taskCode = taskCode - bean.markerId = marker.markerIdReal - bean.lng = marker.longitude - bean.lat = marker.latitude - bean.isDetected = "0" - bean.detectedTime = "" - if (!bean.isExist()) { - taskMarkerLocalBeanDao.insert(bean) - } - } - - private fun TaskMarkerLocalBean.isExist(): Boolean { - val result = taskMarkerLocalBeanDao.queryBuilder().where( - TaskMarkerLocalBeanDao.Properties.Id.eq(this.id) - ).list() - return !result.isNullOrEmpty() - } - - fun loadLocalTask(): ArrayList { - val result = ArrayList() - - val tasks = taskLocalBeanDao.loadAll() - tasks.forEach { - val model = TaskDetailLocalModel() - model.taskId = it.id.toString() - model.taskCode = it.taskCode - model.description = it.description - model.createTime = it.createTime - model.status = it.status - model.createUserName = it.createUserName - model.isFreeTask = it.isFreeTask - - val markers = ArrayList() - if (it.isFreeTask == "0") { - //非自由巡检才有Marker - val markerLocalBeans = taskMarkerLocalBeanDao.queryBuilder().where( - TaskMarkerLocalBeanDao.Properties.TaskId.eq(it.id), - TaskMarkerLocalBeanDao.Properties.TaskCode.eq(it.taskCode) - ).list() - markerLocalBeans.forEach { marker -> - val localModel = TaskDetailLocalModel.TaskMarkerLocalModel() - localModel.markerId = marker.markerId - localModel.lng = marker.lng - localModel.lat = marker.lat - localModel.isDetected = marker.isDetected - localModel.detectedTime = marker.detectedTime - - markers.add(localModel) - } - } - model.markerModels = markers - result.add(model) - } - return result - } - - fun deleteLocalTaskById(taskId: String, taskCode: String) { - val task = taskLocalBeanDao.queryBuilder().where( - TaskLocalBeanDao.Properties.Id.eq(taskId), - TaskLocalBeanDao.Properties.TaskCode.eq(taskCode) - ).list().firstOrNull() ?: return - taskLocalBeanDao.delete(task) - - //删除此任务关联的Marker。非自由巡检才有Marker - if (task.isFreeTask == "0") { - val markers = taskMarkerLocalBeanDao.queryBuilder() - .where( - TaskMarkerLocalBeanDao.Properties.TaskId.eq(taskId), - TaskMarkerLocalBeanDao.Properties.TaskCode.eq(taskCode) - ).list() - markers.forEach { - taskMarkerLocalBeanDao.delete(it) - } - } - } - - fun queryTaskMarkerById( - taskId: String, taskCode: String, markerId: String, state: String - ): TaskMarkerLocalBean? { - return taskMarkerLocalBeanDao.queryBuilder() - .where( - TaskMarkerLocalBeanDao.Properties.TaskId.eq(taskId), - TaskMarkerLocalBeanDao.Properties.TaskCode.eq(taskCode), - TaskMarkerLocalBeanDao.Properties.MarkerId.eq(markerId), - TaskMarkerLocalBeanDao.Properties.IsDetected.eq(state) - ).list().firstOrNull() - } - - fun updateLocalTaskMarkerState(marker: TaskMarkerLocalBean) { - marker.isDetected = "1" - taskMarkerLocalBeanDao.update(marker) - } - - fun queryMarkerByState(state: String): List { - return taskMarkerLocalBeanDao.queryBuilder() - .where(TaskMarkerLocalBeanDao.Properties.IsDetected.eq(state)) - .list() - } - - private var markerLocalBeanDao = BaseApplication.get().getDaoSession().markerLocalBeanDao - - fun clearMarkers() { - markerLocalBeanDao.deleteAll() - } - - fun saveMarkerInLocale(bean: MarkerLocalBean) { - markerLocalBeanDao.insert(bean) - } - - fun loadMarkers(): MutableList { - return markerLocalBeanDao.loadAll() - } - - fun loadMarkersByCondition(selectedItem: String, value: String?): MutableList { - val property = when (selectedItem) { - LocaleConstant.SPINNER_ARRAY[0] -> MarkerLocalBeanDao.Properties.MarkerId - LocaleConstant.SPINNER_ARRAY[1] -> MarkerLocalBeanDao.Properties.Area - LocaleConstant.SPINNER_ARRAY[2] -> MarkerLocalBeanDao.Properties.Line - LocaleConstant.SPINNER_ARRAY[3] -> MarkerLocalBeanDao.Properties.Road - LocaleConstant.SPINNER_ARRAY[4] -> MarkerLocalBeanDao.Properties.Owner - LocaleConstant.SPINNER_ARRAY[5] -> MarkerLocalBeanDao.Properties.InstallationDept - LocaleConstant.SPINNER_ARRAY[6] -> MarkerLocalBeanDao.Properties.UpdateTime - else -> MarkerLocalBeanDao.Properties.Remark - } - return if (value == null) { - markerLocalBeanDao.queryBuilder().where(property.isNotNull).list() - } else { - markerLocalBeanDao.queryBuilder().where(property.eq(value)).list() - } - } - - fun queryMarkerById(markerId: String): List { - return markerLocalBeanDao.queryBuilder() - .where(MarkerLocalBeanDao.Properties.MarkerId.eq(markerId)) - .list() - } -} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/utils/DetectorDataBase.java b/app/src/main/java/com/casic/common/detector/gd/utils/DetectorDataBase.java new file mode 100644 index 0000000..f686cac --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/utils/DetectorDataBase.java @@ -0,0 +1,21 @@ +package com.casic.common.detector.gd.utils; + +import androidx.room.Database; +import androidx.room.RoomDatabase; + +import com.casic.common.detector.gd.bean.MarkerBean; +import com.casic.common.detector.gd.bean.TaskBean; +import com.casic.common.detector.gd.bean.TaskMarkerBean; +import com.casic.common.detector.gd.dao.MarkerBeanDao; +import com.casic.common.detector.gd.dao.TaskBeanDao; +import com.casic.common.detector.gd.dao.TaskMarkerBeanDao; + + +@Database(entities = {MarkerBean.class, TaskBean.class, TaskMarkerBean.class}, version = 1) +public abstract class DetectorDataBase extends RoomDatabase { + public abstract MarkerBeanDao markerBeanDao(); + + public abstract TaskBeanDao taskBeanDao(); + + public abstract TaskMarkerBeanDao taskMarkerBeanDao(); +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/utils/ExcelKit.kt b/app/src/main/java/com/casic/common/detector/gd/utils/ExcelKit.kt index 200fac7..015969f 100644 --- a/app/src/main/java/com/casic/common/detector/gd/utils/ExcelKit.kt +++ b/app/src/main/java/com/casic/common/detector/gd/utils/ExcelKit.kt @@ -1,19 +1,19 @@ package com.casic.common.detector.gd.utils -import com.casic.common.detector.gd.bean.MarkerLocalBean +import com.casic.common.detector.gd.base.BaseApplication +import com.casic.common.detector.gd.bean.MarkerBean import jxl.Workbook import jxl.read.biff.BiffException import java.io.File object ExcelKit { - fun read(filePath: String): ArrayList { - val result = ArrayList() + fun read(filePath: String): ArrayList { + val result = ArrayList() try { val workbook = Workbook.getWorkbook(File(filePath)) val sheet = workbook.getSheet(0) - for (i in 1 until sheet.rows) { - val marker = MarkerLocalBean() + val marker = MarkerBean() marker.pipelineType = sheet.getCell(0, i).contents marker.pipelineDiameter = sheet.getCell(1, i).contents marker.pipelineMaterial = sheet.getCell(2, i).contents @@ -40,9 +40,10 @@ marker.objectType = sheet.getCell(23, i).contents marker.color = sheet.getCell(24, i).contents marker.imagePath = sheet.getCell(25, i).contents - - result.add(marker) - DataBaseManager.get.saveMarkerInLocale(marker) + if (!marker.markerId.isNullOrBlank()) { + result.add(marker) + BaseApplication.get().dataBase.markerBeanDao().insert(marker) + } } workbook.close() } catch (e: BiffException) { diff --git a/app/src/main/java/com/casic/common/detector/gd/utils/LocaleConstant.kt b/app/src/main/java/com/casic/common/detector/gd/utils/LocaleConstant.kt index c658924..8ac5f76 100644 --- a/app/src/main/java/com/casic/common/detector/gd/utils/LocaleConstant.kt +++ b/app/src/main/java/com/casic/common/detector/gd/utils/LocaleConstant.kt @@ -1,6 +1,8 @@ package com.casic.common.detector.gd.utils import android.Manifest +import androidx.sqlite.db.SimpleSQLiteQuery +import androidx.sqlite.db.SupportSQLiteQuery object LocaleConstant { @@ -59,4 +61,19 @@ var BURY_METHOD_ARRAY = arrayOf("直埋", "圆管", "管块", "管沟", "架空") var IDENTIFIER_TYPE_ARRAY = arrayOf("EM30", "EM50", "EM14") var COLOR_ARRAY = arrayOf("蓝色", "橙色", "红色", "黑色", "紫色", "黄色", "绿色") + + fun buildQuery(selectedItem: String, value: String): SupportSQLiteQuery { + val columnName = when (selectedItem) { + SPINNER_ARRAY[0] -> "markerId" + SPINNER_ARRAY[1] -> "area" + SPINNER_ARRAY[2] -> "line" + SPINNER_ARRAY[3] -> "road" + SPINNER_ARRAY[4] -> "owner" + SPINNER_ARRAY[5] -> "installationDept" + SPINNER_ARRAY[6] -> "updateTime" + else -> "remark" + } + val queryBuilder = StringBuilder("SELECT * FROM marker_detail WHERE $columnName = ?") + return SimpleSQLiteQuery(queryBuilder.toString(), arrayOf(value)) + } } \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/view/InstallMarkerActivity.kt b/app/src/main/java/com/casic/common/detector/gd/view/InstallMarkerActivity.kt index daf5b0f..9e09df1 100644 --- a/app/src/main/java/com/casic/common/detector/gd/view/InstallMarkerActivity.kt +++ b/app/src/main/java/com/casic/common/detector/gd/view/InstallMarkerActivity.kt @@ -14,8 +14,9 @@ import com.amap.api.location.AMapLocation import com.casic.common.detector.gd.R import com.casic.common.detector.gd.adapter.EditableImageAdapter +import com.casic.common.detector.gd.base.BaseApplication import com.casic.common.detector.gd.base.SerialPortBaseActivity -import com.casic.common.detector.gd.bean.MarkerLocalBean +import com.casic.common.detector.gd.bean.MarkerBean import com.casic.common.detector.gd.callback.OnGetLocationListener import com.casic.common.detector.gd.callback.OnImageCompressListener import com.casic.common.detector.gd.databinding.ActivityInstallMarkerBinding @@ -27,7 +28,6 @@ import com.casic.common.detector.gd.extensions.toColor import com.casic.common.detector.gd.extensions.toObjectType import com.casic.common.detector.gd.utils.CurrentSegment -import com.casic.common.detector.gd.utils.DataBaseManager import com.casic.common.detector.gd.utils.LocaleConstant import com.casic.common.detector.gd.utils.LocationKit import com.casic.common.detector.gd.utils.RuntimeCache @@ -44,7 +44,6 @@ import com.pengxh.kt.lite.extensions.timestampToCompleteDate import com.pengxh.kt.lite.extensions.timestampToTime import com.pengxh.kt.lite.extensions.toJson -import com.pengxh.kt.lite.utils.LoadState import com.pengxh.kt.lite.utils.LoadingDialog import com.pengxh.kt.lite.utils.SaveKeyValues import com.pengxh.kt.lite.widget.TitleBarView @@ -115,8 +114,6 @@ //安装 binding.installButton.setOnClickListener { - val companyId = SaveKeyValues.getValue(LocaleConstant.USER_COMPANY_ID, "") as String - val objectId = SaveKeyValues.getValue(LocaleConstant.OBJECT_ID, "") as String if (binding.objectInclude.pipeInclude.markerObjectTypeView.text.isNullOrBlank()) { when (binding.objectInclude.objectTypeSpinner.selectedItem.toString()) { "管线" -> "请输入管线种类!".show(this) @@ -189,8 +186,7 @@ //先存本地再上传服务器 saveMarkerInLocal() - taskViewModel.installLabel( - this, companyId, + taskViewModel.installMarker( binding.objectInclude.objectTypeSpinner.selectedItem.toString().toObjectType(), binding.objectInclude.pipeInclude.markerObjectTypeView.text.toString(), binding.objectInclude.pipeInclude.materialSpinner.selectedItem.toString(), @@ -206,7 +202,6 @@ binding.objectInclude.roadView.text.toString(), binding.objectInclude.constructDateView.text.toString(), binding.objectInclude.ownerView.text.toString(), - objectId, binding.identifierInclude.identifierIdView.text.toString(), binding.identifierInclude.identifierTypeSpinner.selectedItem.toString(), "${binding.identifierInclude.identifierDeepView.text}mm", @@ -216,7 +211,19 @@ binding.identifierInclude.latView.text.toString(), binding.identifierInclude.colorSpinner.selectedItem.toString().toColor(), binding.remarkView.text.toString(), - realPaths + realPaths, + onLoading = { + LoadingDialog.show(this, "标识器安装中,请稍后...") + }, + onSuccess = { + LoadingDialog.dismiss() + clearDefaultData() + "安装成功".show(this) + }, + onFailed = { + LoadingDialog.dismiss() + it.show(this) + } ) //保存默认值 @@ -268,7 +275,7 @@ private fun saveMarkerInLocal() { val objectId = SaveKeyValues.getValue(LocaleConstant.OBJECT_ID, "") as String - val marker = MarkerLocalBean() + val marker = MarkerBean() marker.objectType = binding.objectInclude.objectTypeSpinner.selectedItem.toString() marker.pipelineType = binding.objectInclude.pipeInclude.markerObjectTypeView.text.toString() marker.pipelineMaterial = @@ -302,7 +309,7 @@ marker.remark = binding.remarkView.text.toString() marker.imagePath = realPaths.toJson() - DataBaseManager.get.saveMarkerInLocale(marker) + BaseApplication.get().dataBase.markerBeanDao().insert(marker) } private fun takePicture() { @@ -339,8 +346,8 @@ override fun initOnCreate(savedInstanceState: Bundle?) { locationKit.getCurrentLocation(true, object : OnGetLocationListener { override fun onSuccess(location: AMapLocation) { - binding.identifierInclude.lngView.text = location.longitude.toString() - binding.identifierInclude.latView.text = location.latitude.toString() + binding.identifierInclude.lngView.text = "${location.longitude}" + binding.identifierInclude.latView.text = "${location.latitude}" } override fun onError() { @@ -357,22 +364,6 @@ return ActivityInstallMarkerBinding.inflate(layoutInflater) } - override fun observeRequestState() { - taskViewModel.loadState.observe(this) { - when (it) { - LoadState.Loading -> LoadingDialog.show(this, "标识器安装中,请稍后...") - - LoadState.Success -> { - LoadingDialog.dismiss() - clearDefaultData() - "安装成功".show(this) - } - - else -> LoadingDialog.dismiss() - } - } - } - override fun setupTopBarLayout() { binding.rootView.initImmersionBar(this, true, R.color.white) binding.titleView.setOnClickListener(object : TitleBarView.OnClickListener { diff --git a/app/build.gradle b/app/build.gradle index d0cb423..921c8c8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,25 +1,20 @@ import java.text.SimpleDateFormat -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply plugin: 'org.greenrobot.greendao' +plugins { + id('com.android.application') + id('org.jetbrains.kotlin.android') +} android { - compileSdkVersion 33 + namespace 'com.casic.common.detector.gd' + compileSdk 35 defaultConfig { - applicationId "com.casic.common.detector.gd" - minSdkVersion 26 - targetSdkVersion 33 + applicationId 'com.casic.common.detector.gd' + minSdk 26 + targetSdk 35 versionCode 5092 - versionName "5.0.9.2" - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } + versionName '5.0.9.2' } signingConfigs { @@ -31,6 +26,14 @@ } } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + signingConfig signingConfigs.release + } + } + compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 @@ -47,27 +50,16 @@ } } - kotlin { - experimental { - coroutines 'enable' - } - } - buildFeatures { + buildConfig true viewBinding true } - applicationVariants.configureEach { variant -> - variant.outputs.configureEach { - outputFileName = "COM_TCY_" + getBuildDate() + "_" + defaultConfig.versionName + ".apk" + applicationVariants.configureEach { + outputs.configureEach { + outputFileName = 'COM_TCY_' + getBuildDate() + '_' + defaultConfig.versionName + '.apk' } } - - greendao { - schemaVersion 1//数据库版本号 - targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 - daoPackage "${defaultConfig.applicationId}.greendao"//设置DaoMaster、DaoSession、Dao包名 - } } static def getBuildDate() { @@ -76,27 +68,22 @@ } dependencies { - //基础依赖库 - implementation 'com.github.AndroidCoderPeng:Kotlin-lite-lib:1.1.4' - implementation 'androidx.core:core-ktx:1.9.0' - def base_version = "1.6.1" - implementation "androidx.appcompat:appcompat:${base_version}" - implementation "com.google.android.material:material:${base_version}" + implementation 'com.github.AndroidCoderPeng:Kotlin-lite-lib:1.1.5' + implementation 'androidx.core:core-ktx:1.13.1' + implementation 'androidx.appcompat:appcompat:1.7.0' + implementation 'com.google.android.material:material:1.12.0' //Google官方授权框架 implementation 'pub.devrel:easypermissions:3.0.0' - //沉浸式状态栏。基础依赖包,必须要依赖 - implementation 'com.gyf.immersionbar:immersionbar:3.0.0' - //fragment快速实现 - implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0' + //沉浸式状态栏 + implementation 'com.geyifeng.immersionbar:immersionbar:3.2.2' //官方Json解析库 implementation 'com.google.code.gson:gson:2.10.1' - def vm_version = '2.5.1' //Kotlin协程 - implementation "androidx.lifecycle:lifecycle-runtime-ktx:${vm_version}" + implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.2' //MVVM+LiveData - implementation "androidx.lifecycle:lifecycle-livedata-ktx:${vm_version}" - implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:${vm_version}" - implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.6.2' + implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2' + implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' //返回值转换器 implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' @@ -105,9 +92,10 @@ implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' //网络请求和接口封装 implementation 'com.squareup.retrofit2:retrofit:2.9.0' - implementation 'com.squareup.okhttp3:okhttp:4.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.12.0' //数据库框架 - implementation 'org.greenrobot:greendao:3.3.0' + implementation 'androidx.room:room-runtime:2.6.1' + annotationProcessor 'androidx.room:room-compiler:2.5.2' //高德导航、定位、地图三合一 implementation 'com.amap.api:navi-3dmap:latest.integration' //经纬度逆编码 @@ -115,7 +103,7 @@ //excel implementation 'net.sourceforge.jexcelapi:jxl:2.6.12' //图片加载框架 - implementation 'com.github.bumptech.glide:glide:4.9.0' + implementation 'com.github.bumptech.glide:glide:4.12.0' //图片选择框架 implementation 'io.github.lucksiege:pictureselector:v3.11.1' //大图 diff --git a/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt b/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt index 7b695ff..50ba734 100644 --- a/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt +++ b/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt @@ -4,9 +4,9 @@ import android.app.Application import android.os.Bundle import android.util.Log -import com.casic.common.detector.gd.greendao.DaoMaster -import com.casic.common.detector.gd.greendao.DaoSession +import androidx.room.Room.databaseBuilder import com.casic.common.detector.gd.uart.SerialPort +import com.casic.common.detector.gd.utils.DetectorDataBase import com.casic.common.detector.gd.utils.GpioManager import com.pengxh.kt.lite.extensions.show import com.pengxh.kt.lite.utils.SaveKeyValues @@ -43,44 +43,42 @@ private var application: BaseApplication by Delegates.notNull() fun get() = application - - private lateinit var daoSession: DaoSession } + lateinit var dataBase: DetectorDataBase + override fun onCreate() { super.onCreate() application = this SaveKeyValues.initSharedPreferences(this) CrashReport.initCrashReport(this, "01e80d3a74", true) - val devOpenHelper = DaoMaster.DevOpenHelper(this, "Detector.db", null) - val daoMaster = DaoMaster(devOpenHelper.writableDatabase) - daoSession = daoMaster.newSession() + dataBase = databaseBuilder(this, DetectorDataBase::class.java, "Detector.db") + .allowMainThreadQueries() + .build() /** * Open the serial port * */ try { serialPorts.apply { - add(SerialPort(File("/dev/ttysWK1"), 9600, 0)) - //千寻报文数据下发串口号 - add(SerialPort(File("/dev/ttyS1"), 9600, 0)) + add(SerialPort(File("/dev/ttysWK1"), 9600, 0)) //信号通讯串口 + add(SerialPort(File("/dev/ttyS1"), 9600, 0)) //千寻报文数据下发串口号 } Log.d(kTag, "onCreate: 已初始化 ${serialPorts.size} 个串口") } catch (e: SecurityException) { "您没有串口的读写权限!".show(this) + e.printStackTrace() } catch (e: IOException) { "因为不明原因,串口无法打开!".show(this) + e.printStackTrace() } catch (e: InvalidParameterException) { "请检查串口!".show(this) + e.printStackTrace() } registerActivityLifecycleCallbacks(this) } - fun getDaoSession(): DaoSession { - return daoSession - } - override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) { } diff --git a/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt b/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt index 053b9dd..1d0c9e3 100644 --- a/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt +++ b/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt @@ -14,12 +14,10 @@ import com.casic.common.detector.gd.utils.SerialPortCommand import com.pengxh.kt.lite.utils.WeakReferenceHandler import java.io.IOException -import java.util.Timer abstract class SerialPortBaseActivity : AppCompatActivity(), Handler.Callback { private val kTag = "SerialPortBaseActivity" - private val taskTimer by lazy { Timer() } private val weakReferenceHandler by lazy { WeakReferenceHandler(this) } private val serialPorts by lazy { BaseApplication.get().getSerialPorts() } protected lateinit var binding: VB @@ -30,7 +28,6 @@ setContentView(binding.root) setupTopBarLayout() initOnCreate(savedInstanceState) - observeRequestState() initEvent() if (serialPorts.isNotEmpty()) { @@ -71,11 +68,6 @@ abstract fun initOnCreate(savedInstanceState: Bundle?) /** - * 数据请求状态监听 - */ - abstract fun observeRequestState() - - /** * 初始化业务逻辑 */ abstract fun initEvent() diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java new file mode 100644 index 0000000..7a18c20 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java @@ -0,0 +1,255 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 从平台下载的标识器本地库实体类 + */ +@Entity(tableName = "marker_detail") +public class MarkerBean { + @PrimaryKey(autoGenerate = true) + private long id; //主键ID + private String pipelineType; // 管线类型 + private String pipelineDiameter; // 管线直径 + private String pipelineMaterial; // 管材 + private String buryMethod; // 埋设方式 + private String buryDepth; // 埋深 + private String area; // 所属区域 + private String line; // 所属线路 + private String road; // 所属道路 + private String constructTime; // 建设年代 + private String owner; // 权属单位 + private String objectId; // 标识对象ID,无实际用途 + private String markerId; // 标识器ID + private String markerType; // 标识器类型 + private String markerDepth; // 标识器埋深 + private String installationDept; // 安装部门 + private String lng; // 经度 + private String lat; // 纬度 + private String updateTime; // 最后修改时间,更新时间 + private String remark; // 备注信息 + private String underlyingPipelineType; // 下层管线类型 + private String underlyingPipelineDepth; // 下层埋深 + private String underlyingPipelineDiameter; // 下层管径 + private String underlyingPipelineMaterial; // 下层管材 + private String objectType; //标识对象类型 + private String color; // 颜色 + private String imagePath; // 图片路径 + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getPipelineType() { + return pipelineType; + } + + public void setPipelineType(String pipelineType) { + this.pipelineType = pipelineType; + } + + public String getPipelineDiameter() { + return pipelineDiameter; + } + + public void setPipelineDiameter(String pipelineDiameter) { + this.pipelineDiameter = pipelineDiameter; + } + + public String getPipelineMaterial() { + return pipelineMaterial; + } + + public void setPipelineMaterial(String pipelineMaterial) { + this.pipelineMaterial = pipelineMaterial; + } + + public String getBuryMethod() { + return buryMethod; + } + + public void setBuryMethod(String buryMethod) { + this.buryMethod = buryMethod; + } + + public String getBuryDepth() { + return buryDepth; + } + + public void setBuryDepth(String buryDepth) { + this.buryDepth = buryDepth; + } + + public String getArea() { + return area; + } + + public void setArea(String area) { + this.area = area; + } + + public String getLine() { + return line; + } + + public void setLine(String line) { + this.line = line; + } + + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + + public String getConstructTime() { + return constructTime; + } + + public void setConstructTime(String constructTime) { + this.constructTime = constructTime; + } + + public String getOwner() { + return owner; + } + + public void setOwner(String owner) { + this.owner = owner; + } + + public String getObjectId() { + return objectId; + } + + public void setObjectId(String objectId) { + this.objectId = objectId; + } + + public String getMarkerId() { + return markerId; + } + + public void setMarkerId(String markerId) { + this.markerId = markerId; + } + + public String getMarkerType() { + return markerType; + } + + public void setMarkerType(String markerType) { + this.markerType = markerType; + } + + public String getMarkerDepth() { + return markerDepth; + } + + public void setMarkerDepth(String markerDepth) { + this.markerDepth = markerDepth; + } + + public String getInstallationDept() { + return installationDept; + } + + public void setInstallationDept(String installationDept) { + this.installationDept = installationDept; + } + + public String getLng() { + return lng; + } + + public void setLng(String lng) { + this.lng = lng; + } + + public String getLat() { + return lat; + } + + public void setLat(String lat) { + this.lat = lat; + } + + public String getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } + + public String getUnderlyingPipelineType() { + return underlyingPipelineType; + } + + public void setUnderlyingPipelineType(String underlyingPipelineType) { + this.underlyingPipelineType = underlyingPipelineType; + } + + public String getUnderlyingPipelineDepth() { + return underlyingPipelineDepth; + } + + public void setUnderlyingPipelineDepth(String underlyingPipelineDepth) { + this.underlyingPipelineDepth = underlyingPipelineDepth; + } + + public String getUnderlyingPipelineDiameter() { + return underlyingPipelineDiameter; + } + + public void setUnderlyingPipelineDiameter(String underlyingPipelineDiameter) { + this.underlyingPipelineDiameter = underlyingPipelineDiameter; + } + + public String getUnderlyingPipelineMaterial() { + return underlyingPipelineMaterial; + } + + public void setUnderlyingPipelineMaterial(String underlyingPipelineMaterial) { + this.underlyingPipelineMaterial = underlyingPipelineMaterial; + } + + public String getObjectType() { + return objectType; + } + + public void setObjectType(String objectType) { + this.objectType = objectType; + } + + public String getColor() { + return color; + } + + public void setColor(String color) { + this.color = color; + } + + public String getImagePath() { + return imagePath; + } + + public void setImagePath(String imagePath) { + this.imagePath = imagePath; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java deleted file mode 100644 index 3f2fcdc..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java +++ /dev/null @@ -1,327 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 从平台下载的标识器本地库实体类 - */ -@Entity -public class MarkerLocalBean { - @Id(autoincrement = true) - private Long id;//本地库主键ID - - // 管线类型 - private String pipelineType; - // 管线直径 - private String pipelineDiameter; - // 管材 - private String pipelineMaterial; - // 埋设方式 - private String buryMethod; - // 埋深 - private String buryDepth; - // 所属区域 - private String area; - // 所属线路 - private String line; - // 所属道路 - private String road; - // 建设年代 - private String constructTime; - // 权属单位 - private String owner; - //标识对象ID,无实际用途 - @Deprecated - private String objectId; - // 标识器ID - private String markerId; - // 标识器类型 - private String markerType; - // 标识器埋深 - private String markerDepth; - // 安装部门 - private String installationDept; - // 经度 - private String lng; - // 纬度 - private String lat; - //最后修改时间,更新时间 - private String updateTime; - // 备注信息 - private String remark; - // 下层管线类型 - private String underlyingPipelineType; - // 下层埋深 - private String underlyingPipelineDepth; - // 下层管径 - private String underlyingPipelineDiameter; - // 下层管材 - private String underlyingPipelineMaterial; - //标识对象类型 - private String objectType; - // 颜色 - private String color; - // 图片路径 - private String imagePath; - - @Generated(hash = 1479045776) - public MarkerLocalBean(Long id, String pipelineType, String pipelineDiameter, - String pipelineMaterial, String buryMethod, String buryDepth, - String area, String line, String road, String constructTime, - String owner, String objectId, String markerId, String markerType, - String markerDepth, String installationDept, String lng, String lat, - String updateTime, String remark, String underlyingPipelineType, - String underlyingPipelineDepth, String underlyingPipelineDiameter, - String underlyingPipelineMaterial, String objectType, String color, - String imagePath) { - this.id = id; - this.pipelineType = pipelineType; - this.pipelineDiameter = pipelineDiameter; - this.pipelineMaterial = pipelineMaterial; - this.buryMethod = buryMethod; - this.buryDepth = buryDepth; - this.area = area; - this.line = line; - this.road = road; - this.constructTime = constructTime; - this.owner = owner; - this.objectId = objectId; - this.markerId = markerId; - this.markerType = markerType; - this.markerDepth = markerDepth; - this.installationDept = installationDept; - this.lng = lng; - this.lat = lat; - this.updateTime = updateTime; - this.remark = remark; - this.underlyingPipelineType = underlyingPipelineType; - this.underlyingPipelineDepth = underlyingPipelineDepth; - this.underlyingPipelineDiameter = underlyingPipelineDiameter; - this.underlyingPipelineMaterial = underlyingPipelineMaterial; - this.objectType = objectType; - this.color = color; - this.imagePath = imagePath; - } - - @Generated(hash = 1538606012) - public MarkerLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getPipelineType() { - return this.pipelineType; - } - - public void setPipelineType(String pipelineType) { - this.pipelineType = pipelineType; - } - - public String getPipelineDiameter() { - return this.pipelineDiameter; - } - - public void setPipelineDiameter(String pipelineDiameter) { - this.pipelineDiameter = pipelineDiameter; - } - - public String getPipelineMaterial() { - return this.pipelineMaterial; - } - - public void setPipelineMaterial(String pipelineMaterial) { - this.pipelineMaterial = pipelineMaterial; - } - - public String getBuryMethod() { - return this.buryMethod; - } - - public void setBuryMethod(String buryMethod) { - this.buryMethod = buryMethod; - } - - public String getBuryDepth() { - return this.buryDepth; - } - - public void setBuryDepth(String buryDepth) { - this.buryDepth = buryDepth; - } - - public String getArea() { - return this.area; - } - - public void setArea(String area) { - this.area = area; - } - - public String getLine() { - return this.line; - } - - public void setLine(String line) { - this.line = line; - } - - public String getRoad() { - return this.road; - } - - public void setRoad(String road) { - this.road = road; - } - - public String getConstructTime() { - return this.constructTime; - } - - public void setConstructTime(String constructTime) { - this.constructTime = constructTime; - } - - public String getOwner() { - return this.owner; - } - - public void setOwner(String owner) { - this.owner = owner; - } - - public String getObjectId() { - return this.objectId; - } - - public void setObjectId(String objectId) { - this.objectId = objectId; - } - - public String getMarkerId() { - return this.markerId; - } - - public void setMarkerId(String markerId) { - this.markerId = markerId; - } - - public String getMarkerType() { - return this.markerType; - } - - public void setMarkerType(String markerType) { - this.markerType = markerType; - } - - public String getMarkerDepth() { - return this.markerDepth; - } - - public void setMarkerDepth(String markerDepth) { - this.markerDepth = markerDepth; - } - - public String getInstallationDept() { - return this.installationDept; - } - - public void setInstallationDept(String installationDept) { - this.installationDept = installationDept; - } - - public String getLng() { - return this.lng; - } - - public void setLng(String lng) { - this.lng = lng; - } - - public String getLat() { - return this.lat; - } - - public void setLat(String lat) { - this.lat = lat; - } - - public String getUpdateTime() { - return this.updateTime; - } - - public void setUpdateTime(String updateTime) { - this.updateTime = updateTime; - } - - public String getRemark() { - return this.remark; - } - - public void setRemark(String remark) { - this.remark = remark; - } - - public String getUnderlyingPipelineType() { - return this.underlyingPipelineType; - } - - public void setUnderlyingPipelineType(String underlyingPipelineType) { - this.underlyingPipelineType = underlyingPipelineType; - } - - public String getUnderlyingPipelineDepth() { - return this.underlyingPipelineDepth; - } - - public void setUnderlyingPipelineDepth(String underlyingPipelineDepth) { - this.underlyingPipelineDepth = underlyingPipelineDepth; - } - - public String getUnderlyingPipelineDiameter() { - return this.underlyingPipelineDiameter; - } - - public void setUnderlyingPipelineDiameter(String underlyingPipelineDiameter) { - this.underlyingPipelineDiameter = underlyingPipelineDiameter; - } - - public String getUnderlyingPipelineMaterial() { - return this.underlyingPipelineMaterial; - } - - public void setUnderlyingPipelineMaterial(String underlyingPipelineMaterial) { - this.underlyingPipelineMaterial = underlyingPipelineMaterial; - } - - public String getObjectType() { - return this.objectType; - } - - public void setObjectType(String objectType) { - this.objectType = objectType; - } - - public String getColor() { - return this.color; - } - - public void setColor(String color) { - this.color = color; - } - - public String getImagePath() { - return this.imagePath; - } - - public void setImagePath(String imagePath) { - this.imagePath = imagePath; - } -} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java new file mode 100644 index 0000000..5c88fdf --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java @@ -0,0 +1,93 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 巡检任务本地库实体类,不包含任务里面需要巡检的标识器信息 + */ +@Entity(tableName = "task_detail") +public class TaskBean { + @PrimaryKey(autoGenerate = true) + private long id;//主键ID + private String taskCode; // 任务编号 + private String description; // 任务名称 + private String createTime; // 任务创建的时间 + private String status; // 任务状态 + private String createUserName; // 任务创建者名称 + private String startTime; // 任务被开始执行的时间 + private String endTime; // 任务执行结束的时间 + private String isFree; // 是否自由巡检。1-是,0-否 + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getTaskCode() { + return taskCode; + } + + public void setTaskCode(String taskCode) { + this.taskCode = taskCode; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getCreateUserName() { + return createUserName; + } + + public void setCreateUserName(String createUserName) { + this.createUserName = createUserName; + } + + public String getStartTime() { + return startTime; + } + + public void setStartTime(String startTime) { + this.startTime = startTime; + } + + public String getEndTime() { + return endTime; + } + + public void setEndTime(String endTime) { + this.endTime = endTime; + } + + public String getIsFree() { + return isFree; + } + + public void setIsFree(String isFree) { + this.isFree = isFree; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java deleted file mode 100644 index 91737b3..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java +++ /dev/null @@ -1,114 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 巡检任务本地库实体类,不包含任务里面需要巡检的标识器信息 - */ -@Entity -public class TaskLocalBean { - @Id - private Long id;//任务ID - - private String taskCode;//任务编号 - private String description;//任务名称 - private String createTime;//任务创建的时间 - private String status;//任务状态 - private String createUserName;//任务创建者名称 - private String startTime;//任务被开始执行的时间 - private String endTime;//任务执行结束的时间 - private String isFreeTask;//是否自由巡检。1-是,0-否 - - @Generated(hash = 1482022528) - public TaskLocalBean(Long id, String taskCode, String description, - String createTime, String status, String createUserName, - String startTime, String endTime, String isFreeTask) { - this.id = id; - this.taskCode = taskCode; - this.description = description; - this.createTime = createTime; - this.status = status; - this.createUserName = createUserName; - this.startTime = startTime; - this.endTime = endTime; - this.isFreeTask = isFreeTask; - } - - @Generated(hash = 949704588) - public TaskLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getTaskCode() { - return this.taskCode; - } - - public void setTaskCode(String taskCode) { - this.taskCode = taskCode; - } - - public String getDescription() { - return this.description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getCreateTime() { - return this.createTime; - } - - public void setCreateTime(String createTime) { - this.createTime = createTime; - } - - public String getStatus() { - return this.status; - } - - public void setStatus(String status) { - this.status = status; - } - - public String getCreateUserName() { - return this.createUserName; - } - - public void setCreateUserName(String createUserName) { - this.createUserName = createUserName; - } - - public String getStartTime() { - return this.startTime; - } - - public void setStartTime(String startTime) { - this.startTime = startTime; - } - - public String getEndTime() { - return this.endTime; - } - - public void setEndTime(String endTime) { - this.endTime = endTime; - } - - public String getIsFreeTask() { - return this.isFreeTask; - } - - public void setIsFreeTask(String isFreeTask) { - this.isFreeTask = isFreeTask; - } -} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerBean.java new file mode 100644 index 0000000..c563a60 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerBean.java @@ -0,0 +1,110 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 巡检任务里面需要巡检的标识器信息本地库实体类 + */ +@Entity(tableName = "task_marker_info") +public class TaskMarkerBean { + //标识器后台库的主键ID,不是标识器实际ID + @PrimaryKey(autoGenerate = true) + private long id; + + /** + * 任务ID,通过此字段关联[TaskBean.id] + */ + private String taskId; + + /** + * 任务Code,通过此字段关联[TaskBean.taskCode] + *

+ *

+ * 双重验证,防止出现同时刻重复的情况 + */ + private String taskCode; + + /** + * 对应后台字段[TaskModel.MessageModel.TaskDetailInfosModel.markerIdReal],也就是探测仪扫描出来的ID + */ + private String markerId; + + private Double lng; + private Double lat; + + /** + * 是否已被探测到 + * 1-是,0-否 + */ + private String isDetected; + + /** + * 被探测到的时间,对应后台字段[TaskModel.MessageModel.TaskDetailInfosModel.finishTime] + */ + private String detectedTime; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getTaskId() { + return taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getTaskCode() { + return taskCode; + } + + public void setTaskCode(String taskCode) { + this.taskCode = taskCode; + } + + public String getMarkerId() { + return markerId; + } + + public void setMarkerId(String markerId) { + this.markerId = markerId; + } + + public Double getLng() { + return lng; + } + + public void setLng(Double lng) { + this.lng = lng; + } + + public Double getLat() { + return lat; + } + + public void setLat(Double lat) { + this.lat = lat; + } + + public String getIsDetected() { + return isDetected; + } + + public void setIsDetected(String isDetected) { + this.isDetected = isDetected; + } + + public String getDetectedTime() { + return detectedTime; + } + + public void setDetectedTime(String detectedTime) { + this.detectedTime = detectedTime; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerLocalBean.java deleted file mode 100644 index de9f459..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerLocalBean.java +++ /dev/null @@ -1,128 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import com.casic.common.detector.gd.model.TaskModel; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 巡检任务里面需要巡检的标识器信息本地库实体类 - */ -@Entity -public class TaskMarkerLocalBean { - @Id - private Long id;//标识器后台库的主键ID,不是标识器实际ID - - /** - * 任务ID,通过此字段关联{@link TaskLocalBean#id} - */ - private String taskId; - - /** - * 任务Code,通过此字段关联{@link TaskLocalBean#taskCode} - *

- * 双重验证,防止出现同时刻重复的情况 - */ - private String taskCode; - - /** - * 对应后台字段{@link TaskModel.MessageModel.TaskDetailInfosModel#markerIdReal},也就是探测仪扫描出来的ID - */ - private String markerId; - - private double lng; - private double lat; - - /** - * 是否已被探测到 - * 1-是,0-否 - */ - private String isDetected; - - /** - * 被探测到的时间,对应后台字段{@link TaskModel.MessageModel.TaskDetailInfosModel#finishTime} - */ - private String detectedTime; - - @Generated(hash = 677328533) - public TaskMarkerLocalBean(Long id, String taskId, String taskCode, String markerId, - double lng, double lat, String isDetected, String detectedTime) { - this.id = id; - this.taskId = taskId; - this.taskCode = taskCode; - this.markerId = markerId; - this.lng = lng; - this.lat = lat; - this.isDetected = isDetected; - this.detectedTime = detectedTime; - } - - @Generated(hash = 1162404642) - public TaskMarkerLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getTaskId() { - return this.taskId; - } - - public void setTaskId(String taskId) { - this.taskId = taskId; - } - - public String getTaskCode() { - return this.taskCode; - } - - public void setTaskCode(String taskCode) { - this.taskCode = taskCode; - } - - public String getMarkerId() { - return this.markerId; - } - - public void setMarkerId(String markerId) { - this.markerId = markerId; - } - - public double getLng() { - return this.lng; - } - - public void setLng(double lng) { - this.lng = lng; - } - - public double getLat() { - return this.lat; - } - - public void setLat(double lat) { - this.lat = lat; - } - - public String getIsDetected() { - return this.isDetected; - } - - public void setIsDetected(String isDetected) { - this.isDetected = isDetected; - } - - public String getDetectedTime() { - return this.detectedTime; - } - - public void setDetectedTime(String detectedTime) { - this.detectedTime = detectedTime; - } -} diff --git a/app/src/main/java/com/casic/common/detector/gd/dao/MarkerBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/dao/MarkerBeanDao.java new file mode 100644 index 0000000..2beb7ed --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/dao/MarkerBeanDao.java @@ -0,0 +1,29 @@ +package com.casic.common.detector.gd.dao; + +import androidx.room.Dao; +import androidx.room.Insert; +import androidx.room.Query; +import androidx.room.RawQuery; +import androidx.sqlite.db.SupportSQLiteQuery; + +import com.casic.common.detector.gd.bean.MarkerBean; + +import java.util.List; + +@Dao +public interface MarkerBeanDao { + @Query("DELETE FROM marker_detail") + void deleteAll(); + + @Insert + void insert(MarkerBean marker); + + @Query("SELECT * FROM marker_detail") + List loadAll(); + + @Query("SELECT * FROM marker_detail WHERE markerId = :markerId") + List queryMarkerById(String markerId); + + @RawQuery + List loadMarkersByCondition(SupportSQLiteQuery query); +} diff --git a/app/src/main/java/com/casic/common/detector/gd/dao/TaskBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/dao/TaskBeanDao.java new file mode 100644 index 0000000..9c70ac2 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/dao/TaskBeanDao.java @@ -0,0 +1,120 @@ +package com.casic.common.detector.gd.dao; + +import androidx.room.Dao; +import androidx.room.Insert; +import androidx.room.Query; +import androidx.room.Transaction; + +import com.casic.common.detector.gd.bean.TaskBean; +import com.casic.common.detector.gd.bean.TaskMarkerBean; +import com.casic.common.detector.gd.model.TaskDetailLocalModel; +import com.casic.common.detector.gd.model.TaskModel; +import com.casic.common.detector.gd.utils.LocaleConstant; +import com.pengxh.kt.lite.utils.SaveKeyValues; + +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Locale; + +@Dao +public interface TaskBeanDao { + @Query("SELECT COUNT(*) FROM task_detail WHERE id = :taskId") + int isTaskExist(long taskId); + + @Insert + void insert(TaskBean task); + + default void saveTask(Long taskId, String taskName) { + if (isTaskExist(taskId) == 0) { + TaskBean task = new TaskBean(); + task.setId(taskId); + task.setTaskCode(new SimpleDateFormat("yyyyMMddHHmmss", Locale.CHINA).format(new Date())); + task.setDescription(taskName); + String time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA).format(new Date()); + task.setCreateTime(time); + task.setStatus("0"); + String userName = (String) SaveKeyValues.INSTANCE.getValue(LocaleConstant.USER_NAME, ""); + task.setCreateUserName(userName); + task.setStartTime(time); + task.setEndTime(""); + task.setIsFree("1"); + insert(task); + } + } + + default void saveTask(TaskModel.MessageModel model) { + TaskBean task = new TaskBean(); + task.setId(model.getId()); + task.setTaskCode(model.getTaskCode()); + task.setDescription(model.getDescription()); + task.setCreateTime(model.getDeployDate()); + task.setStatus(model.getStatus()); + task.setCreateUserName(model.getCreatorName()); + task.setStartTime(model.getBeginDate()); + task.setEndTime(model.getEndDate()); + task.setIsFree("0"); + if (isTaskExist(task.getId()) == 0) { + insert(task); + } + } + + @Query("SELECT * FROM task_detail") + List loadAll(); + + @Transaction + default ArrayList loadLocalTask(TaskMarkerBeanDao taskMarkerBeanDao) { + ArrayList result = new ArrayList<>(); + List tasks = loadAll(); + for (TaskBean it : tasks) { + TaskDetailLocalModel model = new TaskDetailLocalModel(); + model.setTaskId(String.valueOf(it.getId())); + model.setTaskCode(it.getTaskCode()); + model.setDescription(it.getDescription()); + model.setCreateTime(it.getCreateTime()); + model.setStatus(it.getStatus()); + model.setCreateUserName(it.getCreateUserName()); + model.setIsFreeTask(it.getIsFree()); + ArrayList results = new ArrayList<>(); + if ("0".equals(it.getIsFree())) { + // 非自由巡检才有Marker + List markers = taskMarkerBeanDao.getMarkersByIdAndCode(String.valueOf(it.getId()), it.getTaskCode()); + for (TaskMarkerBean marker : markers) { + TaskDetailLocalModel.TaskMarkerLocalModel localModel = new TaskDetailLocalModel.TaskMarkerLocalModel(); + localModel.setMarkerId(marker.getMarkerId()); + localModel.setLng(marker.getLng()); + localModel.setLat(marker.getLat()); + localModel.setIsDetected(marker.getIsDetected()); + localModel.setDetectedTime(marker.getDetectedTime()); + + results.add(localModel); + } + } + model.setMarkerModels(results); + result.add(model); + } + return result; + } + + @Query("DELETE FROM task_detail WHERE id = :taskId AND taskCode = :taskCode") + void deleteTaskById(long taskId, String taskCode); + + @Transaction + default void deleteLocalTaskById(long taskId, String taskCode, TaskMarkerBeanDao taskMarkerBeanDao) { + TaskBean task = loadAll().stream() + .filter(it -> it.getId() == taskId && taskCode.equals(it.getTaskCode())) + .findFirst() + .orElse(null); + if (task == null) return; + deleteTaskById(taskId, taskCode); + + // 删除此任务关联的Marker。非自由巡检才有Marker + if ("0".equals(task.getIsFree())) { + List markers = taskMarkerBeanDao.getMarkersByIdAndCode(String.valueOf(task.getId()), task.getTaskCode()); + for (TaskMarkerBean marker : markers) { + taskMarkerBeanDao.delete(marker); + } + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/dao/TaskMarkerBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/dao/TaskMarkerBeanDao.java new file mode 100644 index 0000000..cc2156a --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/dao/TaskMarkerBeanDao.java @@ -0,0 +1,52 @@ +package com.casic.common.detector.gd.dao; + +import androidx.room.Dao; +import androidx.room.Delete; +import androidx.room.Insert; +import androidx.room.Query; +import androidx.room.Update; + +import com.casic.common.detector.gd.bean.TaskMarkerBean; +import com.casic.common.detector.gd.model.TaskModel; + +import java.util.List; + +@Dao +public interface TaskMarkerBeanDao { + + @Insert + void insert(TaskMarkerBean marker); + + @Query("SELECT COUNT(*) FROM task_marker_info WHERE id = :markerId") + int isMarkerExist(String markerId); + + default void saveTaskMarker(long taskId, String taskCode, TaskModel.MessageModel.TaskDetailInfosModel marker) { + if (isMarkerExist(marker.getMarkerId()) == 0) { + TaskMarkerBean bean = new TaskMarkerBean(); + bean.setId(marker.getId()); + bean.setTaskId(String.valueOf(taskId)); + bean.setTaskCode(taskCode); + bean.setMarkerId(marker.getMarkerIdReal()); + bean.setLng(marker.getLongitude()); + bean.setLat(marker.getLatitude()); + bean.setIsDetected("0"); + bean.setDetectedTime(""); + insert(bean); + } + } + + @Query("SELECT * FROM task_marker_info WHERE taskId = :taskId AND taskCode = :taskCode AND markerId = :markerId AND isDetected = :state") + TaskMarkerBean queryTaskMarkerById(String taskId, String taskCode, String markerId, String state); + + @Update + void updateLocalTaskMarkerState(TaskMarkerBean marker); + + @Query("SELECT * FROM task_marker_info WHERE isDetected = :state") + List queryMarkerByState(String state); + + @Query("SELECT * FROM task_marker_info WHERE taskId = :taskId AND taskCode = :taskCode") + List getMarkersByIdAndCode(String taskId, String taskCode); + + @Delete + void delete(TaskMarkerBean marker); +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/extensions/Long.kt b/app/src/main/java/com/casic/common/detector/gd/extensions/Long.kt deleted file mode 100644 index 6713d8d..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/extensions/Long.kt +++ /dev/null @@ -1,10 +0,0 @@ -package com.casic.common.detector.gd.extensions - -import java.text.SimpleDateFormat -import java.util.Date -import java.util.Locale - -fun Long.createTaskCode(): String { - val dateFormat = SimpleDateFormat("yyyyMMddHHmmss", Locale.CHINA) - return dateFormat.format(Date(this)) -} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoMaster.java b/app/src/main/java/com/casic/common/detector/gd/greendao/DaoMaster.java deleted file mode 100644 index 6ab94b3..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoMaster.java +++ /dev/null @@ -1,102 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import android.content.Context; -import android.database.sqlite.SQLiteDatabase; -import android.database.sqlite.SQLiteDatabase.CursorFactory; -import android.util.Log; - -import org.greenrobot.greendao.AbstractDaoMaster; -import org.greenrobot.greendao.database.StandardDatabase; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.database.DatabaseOpenHelper; -import org.greenrobot.greendao.identityscope.IdentityScopeType; - - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** - * Master of DAO (schema version 1): knows all DAOs. - */ -public class DaoMaster extends AbstractDaoMaster { - public static final int SCHEMA_VERSION = 1; - - /** Creates underlying database table using DAOs. */ - public static void createAllTables(Database db, boolean ifNotExists) { - MarkerLocalBeanDao.createTable(db, ifNotExists); - TaskLocalBeanDao.createTable(db, ifNotExists); - TaskMarkerLocalBeanDao.createTable(db, ifNotExists); - } - - /** Drops underlying database table using DAOs. */ - public static void dropAllTables(Database db, boolean ifExists) { - MarkerLocalBeanDao.dropTable(db, ifExists); - TaskLocalBeanDao.dropTable(db, ifExists); - TaskMarkerLocalBeanDao.dropTable(db, ifExists); - } - - /** - * WARNING: Drops all table on Upgrade! Use only during development. - * Convenience method using a {@link DevOpenHelper}. - */ - public static DaoSession newDevSession(Context context, String name) { - Database db = new DevOpenHelper(context, name).getWritableDb(); - DaoMaster daoMaster = new DaoMaster(db); - return daoMaster.newSession(); - } - - public DaoMaster(SQLiteDatabase db) { - this(new StandardDatabase(db)); - } - - public DaoMaster(Database db) { - super(db, SCHEMA_VERSION); - registerDaoClass(MarkerLocalBeanDao.class); - registerDaoClass(TaskLocalBeanDao.class); - registerDaoClass(TaskMarkerLocalBeanDao.class); - } - - public DaoSession newSession() { - return new DaoSession(db, IdentityScopeType.Session, daoConfigMap); - } - - public DaoSession newSession(IdentityScopeType type) { - return new DaoSession(db, type, daoConfigMap); - } - - /** - * Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} - - */ - public static abstract class OpenHelper extends DatabaseOpenHelper { - public OpenHelper(Context context, String name) { - super(context, name, SCHEMA_VERSION); - } - - public OpenHelper(Context context, String name, CursorFactory factory) { - super(context, name, factory, SCHEMA_VERSION); - } - - @Override - public void onCreate(Database db) { - Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION); - createAllTables(db, false); - } - } - - /** WARNING: Drops all table on Upgrade! Use only during development. */ - public static class DevOpenHelper extends OpenHelper { - public DevOpenHelper(Context context, String name) { - super(context, name); - } - - public DevOpenHelper(Context context, String name, CursorFactory factory) { - super(context, name, factory); - } - - @Override - public void onUpgrade(Database db, int oldVersion, int newVersion) { - Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables"); - dropAllTables(db, true); - onCreate(db); - } - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoSession.java b/app/src/main/java/com/casic/common/detector/gd/greendao/DaoSession.java deleted file mode 100644 index c8b1a20..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoSession.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import java.util.Map; - -import org.greenrobot.greendao.AbstractDao; -import org.greenrobot.greendao.AbstractDaoSession; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.identityscope.IdentityScopeType; -import org.greenrobot.greendao.internal.DaoConfig; - -import com.casic.common.detector.gd.bean.MarkerLocalBean; -import com.casic.common.detector.gd.bean.TaskLocalBean; -import com.casic.common.detector.gd.bean.TaskMarkerLocalBean; - -import com.casic.common.detector.gd.greendao.MarkerLocalBeanDao; -import com.casic.common.detector.gd.greendao.TaskLocalBeanDao; -import com.casic.common.detector.gd.greendao.TaskMarkerLocalBeanDao; - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. - -/** - * {@inheritDoc} - * - * @see org.greenrobot.greendao.AbstractDaoSession - */ -public class DaoSession extends AbstractDaoSession { - - private final DaoConfig markerLocalBeanDaoConfig; - private final DaoConfig taskLocalBeanDaoConfig; - private final DaoConfig taskMarkerLocalBeanDaoConfig; - - private final MarkerLocalBeanDao markerLocalBeanDao; - private final TaskLocalBeanDao taskLocalBeanDao; - private final TaskMarkerLocalBeanDao taskMarkerLocalBeanDao; - - public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> - daoConfigMap) { - super(db); - - markerLocalBeanDaoConfig = daoConfigMap.get(MarkerLocalBeanDao.class).clone(); - markerLocalBeanDaoConfig.initIdentityScope(type); - - taskLocalBeanDaoConfig = daoConfigMap.get(TaskLocalBeanDao.class).clone(); - taskLocalBeanDaoConfig.initIdentityScope(type); - - taskMarkerLocalBeanDaoConfig = daoConfigMap.get(TaskMarkerLocalBeanDao.class).clone(); - taskMarkerLocalBeanDaoConfig.initIdentityScope(type); - - markerLocalBeanDao = new MarkerLocalBeanDao(markerLocalBeanDaoConfig, this); - taskLocalBeanDao = new TaskLocalBeanDao(taskLocalBeanDaoConfig, this); - taskMarkerLocalBeanDao = new TaskMarkerLocalBeanDao(taskMarkerLocalBeanDaoConfig, this); - - registerDao(MarkerLocalBean.class, markerLocalBeanDao); - registerDao(TaskLocalBean.class, taskLocalBeanDao); - registerDao(TaskMarkerLocalBean.class, taskMarkerLocalBeanDao); - } - - public void clear() { - markerLocalBeanDaoConfig.clearIdentityScope(); - taskLocalBeanDaoConfig.clearIdentityScope(); - taskMarkerLocalBeanDaoConfig.clearIdentityScope(); - } - - public MarkerLocalBeanDao getMarkerLocalBeanDao() { - return markerLocalBeanDao; - } - - public TaskLocalBeanDao getTaskLocalBeanDao() { - return taskLocalBeanDao; - } - - public TaskMarkerLocalBeanDao getTaskMarkerLocalBeanDao() { - return taskMarkerLocalBeanDao; - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/MarkerLocalBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/greendao/MarkerLocalBeanDao.java deleted file mode 100644 index 2f792c3..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/MarkerLocalBeanDao.java +++ /dev/null @@ -1,479 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import android.database.Cursor; -import android.database.sqlite.SQLiteStatement; - -import org.greenrobot.greendao.AbstractDao; -import org.greenrobot.greendao.Property; -import org.greenrobot.greendao.internal.DaoConfig; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.database.DatabaseStatement; - -import com.casic.common.detector.gd.bean.MarkerLocalBean; - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** - * DAO for table "MARKER_LOCAL_BEAN". -*/ -public class MarkerLocalBeanDao extends AbstractDao { - - public static final String TABLENAME = "MARKER_LOCAL_BEAN"; - - /** - * Properties of entity MarkerLocalBean.
- * Can be used for QueryBuilder and for referencing column names. - */ - public static class Properties { - public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property PipelineType = new Property(1, String.class, "pipelineType", false, "PIPELINE_TYPE"); - public final static Property PipelineDiameter = new Property(2, String.class, "pipelineDiameter", false, "PIPELINE_DIAMETER"); - public final static Property PipelineMaterial = new Property(3, String.class, "pipelineMaterial", false, "PIPELINE_MATERIAL"); - public final static Property BuryMethod = new Property(4, String.class, "buryMethod", false, "BURY_METHOD"); - public final static Property BuryDepth = new Property(5, String.class, "buryDepth", false, "BURY_DEPTH"); - public final static Property Area = new Property(6, String.class, "area", false, "AREA"); - public final static Property Line = new Property(7, String.class, "line", false, "LINE"); - public final static Property Road = new Property(8, String.class, "road", false, "ROAD"); - public final static Property ConstructTime = new Property(9, String.class, "constructTime", false, "CONSTRUCT_TIME"); - public final static Property Owner = new Property(10, String.class, "owner", false, "OWNER"); - public final static Property ObjectId = new Property(11, String.class, "objectId", false, "OBJECT_ID"); - public final static Property MarkerId = new Property(12, String.class, "markerId", false, "MARKER_ID"); - public final static Property MarkerType = new Property(13, String.class, "markerType", false, "MARKER_TYPE"); - public final static Property MarkerDepth = new Property(14, String.class, "markerDepth", false, "MARKER_DEPTH"); - public final static Property InstallationDept = new Property(15, String.class, "installationDept", false, "INSTALLATION_DEPT"); - public final static Property Lng = new Property(16, String.class, "lng", false, "LNG"); - public final static Property Lat = new Property(17, String.class, "lat", false, "LAT"); - public final static Property UpdateTime = new Property(18, String.class, "updateTime", false, "UPDATE_TIME"); - public final static Property Remark = new Property(19, String.class, "remark", false, "REMARK"); - public final static Property UnderlyingPipelineType = new Property(20, String.class, "underlyingPipelineType", false, "UNDERLYING_PIPELINE_TYPE"); - public final static Property UnderlyingPipelineDepth = new Property(21, String.class, "underlyingPipelineDepth", false, "UNDERLYING_PIPELINE_DEPTH"); - public final static Property UnderlyingPipelineDiameter = new Property(22, String.class, "underlyingPipelineDiameter", false, "UNDERLYING_PIPELINE_DIAMETER"); - public final static Property UnderlyingPipelineMaterial = new Property(23, String.class, "underlyingPipelineMaterial", false, "UNDERLYING_PIPELINE_MATERIAL"); - public final static Property ObjectType = new Property(24, String.class, "objectType", false, "OBJECT_TYPE"); - public final static Property Color = new Property(25, String.class, "color", false, "COLOR"); - public final static Property ImagePath = new Property(26, String.class, "imagePath", false, "IMAGE_PATH"); - } - - - public MarkerLocalBeanDao(DaoConfig config) { - super(config); - } - - public MarkerLocalBeanDao(DaoConfig config, DaoSession daoSession) { - super(config, daoSession); - } - - /** Creates the underlying database table. */ - public static void createTable(Database db, boolean ifNotExists) { - String constraint = ifNotExists? "IF NOT EXISTS ": ""; - db.execSQL("CREATE TABLE " + constraint + "\"MARKER_LOCAL_BEAN\" (" + // - "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id - "\"PIPELINE_TYPE\" TEXT," + // 1: pipelineType - "\"PIPELINE_DIAMETER\" TEXT," + // 2: pipelineDiameter - "\"PIPELINE_MATERIAL\" TEXT," + // 3: pipelineMaterial - "\"BURY_METHOD\" TEXT," + // 4: buryMethod - "\"BURY_DEPTH\" TEXT," + // 5: buryDepth - "\"AREA\" TEXT," + // 6: area - "\"LINE\" TEXT," + // 7: line - "\"ROAD\" TEXT," + // 8: road - "\"CONSTRUCT_TIME\" TEXT," + // 9: constructTime - "\"OWNER\" TEXT," + // 10: owner - "\"OBJECT_ID\" TEXT," + // 11: objectId - "\"MARKER_ID\" TEXT," + // 12: markerId - "\"MARKER_TYPE\" TEXT," + // 13: markerType - "\"MARKER_DEPTH\" TEXT," + // 14: markerDepth - "\"INSTALLATION_DEPT\" TEXT," + // 15: installationDept - "\"LNG\" TEXT," + // 16: lng - "\"LAT\" TEXT," + // 17: lat - "\"UPDATE_TIME\" TEXT," + // 18: updateTime - "\"REMARK\" TEXT," + // 19: remark - "\"UNDERLYING_PIPELINE_TYPE\" TEXT," + // 20: underlyingPipelineType - "\"UNDERLYING_PIPELINE_DEPTH\" TEXT," + // 21: underlyingPipelineDepth - "\"UNDERLYING_PIPELINE_DIAMETER\" TEXT," + // 22: underlyingPipelineDiameter - "\"UNDERLYING_PIPELINE_MATERIAL\" TEXT," + // 23: underlyingPipelineMaterial - "\"OBJECT_TYPE\" TEXT," + // 24: objectType - "\"COLOR\" TEXT," + // 25: color - "\"IMAGE_PATH\" TEXT);"); // 26: imagePath - } - - /** Drops the underlying database table. */ - public static void dropTable(Database db, boolean ifExists) { - String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"MARKER_LOCAL_BEAN\""; - db.execSQL(sql); - } - - @Override - protected final void bindValues(DatabaseStatement stmt, MarkerLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String pipelineType = entity.getPipelineType(); - if (pipelineType != null) { - stmt.bindString(2, pipelineType); - } - - String pipelineDiameter = entity.getPipelineDiameter(); - if (pipelineDiameter != null) { - stmt.bindString(3, pipelineDiameter); - } - - String pipelineMaterial = entity.getPipelineMaterial(); - if (pipelineMaterial != null) { - stmt.bindString(4, pipelineMaterial); - } - - String buryMethod = entity.getBuryMethod(); - if (buryMethod != null) { - stmt.bindString(5, buryMethod); - } - - String buryDepth = entity.getBuryDepth(); - if (buryDepth != null) { - stmt.bindString(6, buryDepth); - } - - String area = entity.getArea(); - if (area != null) { - stmt.bindString(7, area); - } - - String line = entity.getLine(); - if (line != null) { - stmt.bindString(8, line); - } - - String road = entity.getRoad(); - if (road != null) { - stmt.bindString(9, road); - } - - String constructTime = entity.getConstructTime(); - if (constructTime != null) { - stmt.bindString(10, constructTime); - } - - String owner = entity.getOwner(); - if (owner != null) { - stmt.bindString(11, owner); - } - - String objectId = entity.getObjectId(); - if (objectId != null) { - stmt.bindString(12, objectId); - } - - String markerId = entity.getMarkerId(); - if (markerId != null) { - stmt.bindString(13, markerId); - } - - String markerType = entity.getMarkerType(); - if (markerType != null) { - stmt.bindString(14, markerType); - } - - String markerDepth = entity.getMarkerDepth(); - if (markerDepth != null) { - stmt.bindString(15, markerDepth); - } - - String installationDept = entity.getInstallationDept(); - if (installationDept != null) { - stmt.bindString(16, installationDept); - } - - String lng = entity.getLng(); - if (lng != null) { - stmt.bindString(17, lng); - } - - String lat = entity.getLat(); - if (lat != null) { - stmt.bindString(18, lat); - } - - String updateTime = entity.getUpdateTime(); - if (updateTime != null) { - stmt.bindString(19, updateTime); - } - - String remark = entity.getRemark(); - if (remark != null) { - stmt.bindString(20, remark); - } - - String underlyingPipelineType = entity.getUnderlyingPipelineType(); - if (underlyingPipelineType != null) { - stmt.bindString(21, underlyingPipelineType); - } - - String underlyingPipelineDepth = entity.getUnderlyingPipelineDepth(); - if (underlyingPipelineDepth != null) { - stmt.bindString(22, underlyingPipelineDepth); - } - - String underlyingPipelineDiameter = entity.getUnderlyingPipelineDiameter(); - if (underlyingPipelineDiameter != null) { - stmt.bindString(23, underlyingPipelineDiameter); - } - - String underlyingPipelineMaterial = entity.getUnderlyingPipelineMaterial(); - if (underlyingPipelineMaterial != null) { - stmt.bindString(24, underlyingPipelineMaterial); - } - - String objectType = entity.getObjectType(); - if (objectType != null) { - stmt.bindString(25, objectType); - } - - String color = entity.getColor(); - if (color != null) { - stmt.bindString(26, color); - } - - String imagePath = entity.getImagePath(); - if (imagePath != null) { - stmt.bindString(27, imagePath); - } - } - - @Override - protected final void bindValues(SQLiteStatement stmt, MarkerLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String pipelineType = entity.getPipelineType(); - if (pipelineType != null) { - stmt.bindString(2, pipelineType); - } - - String pipelineDiameter = entity.getPipelineDiameter(); - if (pipelineDiameter != null) { - stmt.bindString(3, pipelineDiameter); - } - - String pipelineMaterial = entity.getPipelineMaterial(); - if (pipelineMaterial != null) { - stmt.bindString(4, pipelineMaterial); - } - - String buryMethod = entity.getBuryMethod(); - if (buryMethod != null) { - stmt.bindString(5, buryMethod); - } - - String buryDepth = entity.getBuryDepth(); - if (buryDepth != null) { - stmt.bindString(6, buryDepth); - } - - String area = entity.getArea(); - if (area != null) { - stmt.bindString(7, area); - } - - String line = entity.getLine(); - if (line != null) { - stmt.bindString(8, line); - } - - String road = entity.getRoad(); - if (road != null) { - stmt.bindString(9, road); - } - - String constructTime = entity.getConstructTime(); - if (constructTime != null) { - stmt.bindString(10, constructTime); - } - - String owner = entity.getOwner(); - if (owner != null) { - stmt.bindString(11, owner); - } - - String objectId = entity.getObjectId(); - if (objectId != null) { - stmt.bindString(12, objectId); - } - - String markerId = entity.getMarkerId(); - if (markerId != null) { - stmt.bindString(13, markerId); - } - - String markerType = entity.getMarkerType(); - if (markerType != null) { - stmt.bindString(14, markerType); - } - - String markerDepth = entity.getMarkerDepth(); - if (markerDepth != null) { - stmt.bindString(15, markerDepth); - } - - String installationDept = entity.getInstallationDept(); - if (installationDept != null) { - stmt.bindString(16, installationDept); - } - - String lng = entity.getLng(); - if (lng != null) { - stmt.bindString(17, lng); - } - - String lat = entity.getLat(); - if (lat != null) { - stmt.bindString(18, lat); - } - - String updateTime = entity.getUpdateTime(); - if (updateTime != null) { - stmt.bindString(19, updateTime); - } - - String remark = entity.getRemark(); - if (remark != null) { - stmt.bindString(20, remark); - } - - String underlyingPipelineType = entity.getUnderlyingPipelineType(); - if (underlyingPipelineType != null) { - stmt.bindString(21, underlyingPipelineType); - } - - String underlyingPipelineDepth = entity.getUnderlyingPipelineDepth(); - if (underlyingPipelineDepth != null) { - stmt.bindString(22, underlyingPipelineDepth); - } - - String underlyingPipelineDiameter = entity.getUnderlyingPipelineDiameter(); - if (underlyingPipelineDiameter != null) { - stmt.bindString(23, underlyingPipelineDiameter); - } - - String underlyingPipelineMaterial = entity.getUnderlyingPipelineMaterial(); - if (underlyingPipelineMaterial != null) { - stmt.bindString(24, underlyingPipelineMaterial); - } - - String objectType = entity.getObjectType(); - if (objectType != null) { - stmt.bindString(25, objectType); - } - - String color = entity.getColor(); - if (color != null) { - stmt.bindString(26, color); - } - - String imagePath = entity.getImagePath(); - if (imagePath != null) { - stmt.bindString(27, imagePath); - } - } - - @Override - public Long readKey(Cursor cursor, int offset) { - return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); - } - - @Override - public MarkerLocalBean readEntity(Cursor cursor, int offset) { - MarkerLocalBean entity = new MarkerLocalBean( // - cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // pipelineType - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // pipelineDiameter - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // pipelineMaterial - cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // buryMethod - cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // buryDepth - cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // area - cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // line - cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // road - cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // constructTime - cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10), // owner - cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11), // objectId - cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12), // markerId - cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13), // markerType - cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14), // markerDepth - cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15), // installationDept - cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16), // lng - cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17), // lat - cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18), // updateTime - cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19), // remark - cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20), // underlyingPipelineType - cursor.isNull(offset + 21) ? null : cursor.getString(offset + 21), // underlyingPipelineDepth - cursor.isNull(offset + 22) ? null : cursor.getString(offset + 22), // underlyingPipelineDiameter - cursor.isNull(offset + 23) ? null : cursor.getString(offset + 23), // underlyingPipelineMaterial - cursor.isNull(offset + 24) ? null : cursor.getString(offset + 24), // objectType - cursor.isNull(offset + 25) ? null : cursor.getString(offset + 25), // color - cursor.isNull(offset + 26) ? null : cursor.getString(offset + 26) // imagePath - ); - return entity; - } - - @Override - public void readEntity(Cursor cursor, MarkerLocalBean entity, int offset) { - entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setPipelineType(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); - entity.setPipelineDiameter(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); - entity.setPipelineMaterial(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); - entity.setBuryMethod(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); - entity.setBuryDepth(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); - entity.setArea(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); - entity.setLine(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); - entity.setRoad(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); - entity.setConstructTime(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9)); - entity.setOwner(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); - entity.setObjectId(cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11)); - entity.setMarkerId(cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12)); - entity.setMarkerType(cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13)); - entity.setMarkerDepth(cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14)); - entity.setInstallationDept(cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15)); - entity.setLng(cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16)); - entity.setLat(cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17)); - entity.setUpdateTime(cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18)); - entity.setRemark(cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19)); - entity.setUnderlyingPipelineType(cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20)); - entity.setUnderlyingPipelineDepth(cursor.isNull(offset + 21) ? null : cursor.getString(offset + 21)); - entity.setUnderlyingPipelineDiameter(cursor.isNull(offset + 22) ? null : cursor.getString(offset + 22)); - entity.setUnderlyingPipelineMaterial(cursor.isNull(offset + 23) ? null : cursor.getString(offset + 23)); - entity.setObjectType(cursor.isNull(offset + 24) ? null : cursor.getString(offset + 24)); - entity.setColor(cursor.isNull(offset + 25) ? null : cursor.getString(offset + 25)); - entity.setImagePath(cursor.isNull(offset + 26) ? null : cursor.getString(offset + 26)); - } - - @Override - protected final Long updateKeyAfterInsert(MarkerLocalBean entity, long rowId) { - entity.setId(rowId); - return rowId; - } - - @Override - public Long getKey(MarkerLocalBean entity) { - if(entity != null) { - return entity.getId(); - } else { - return null; - } - } - - @Override - public boolean hasKey(MarkerLocalBean entity) { - return entity.getId() != null; - } - - @Override - protected final boolean isEntityUpdateable() { - return true; - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/TaskLocalBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/greendao/TaskLocalBeanDao.java deleted file mode 100644 index fb88157..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/TaskLocalBeanDao.java +++ /dev/null @@ -1,227 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import android.database.Cursor; -import android.database.sqlite.SQLiteStatement; - -import org.greenrobot.greendao.AbstractDao; -import org.greenrobot.greendao.Property; -import org.greenrobot.greendao.internal.DaoConfig; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.database.DatabaseStatement; - -import com.casic.common.detector.gd.bean.TaskLocalBean; - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** - * DAO for table "TASK_LOCAL_BEAN". -*/ -public class TaskLocalBeanDao extends AbstractDao { - - public static final String TABLENAME = "TASK_LOCAL_BEAN"; - - /** - * Properties of entity TaskLocalBean.
- * Can be used for QueryBuilder and for referencing column names. - */ - public static class Properties { - public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property TaskCode = new Property(1, String.class, "taskCode", false, "TASK_CODE"); - public final static Property Description = new Property(2, String.class, "description", false, "DESCRIPTION"); - public final static Property CreateTime = new Property(3, String.class, "createTime", false, "CREATE_TIME"); - public final static Property Status = new Property(4, String.class, "status", false, "STATUS"); - public final static Property CreateUserName = new Property(5, String.class, "createUserName", false, "CREATE_USER_NAME"); - public final static Property StartTime = new Property(6, String.class, "startTime", false, "START_TIME"); - public final static Property EndTime = new Property(7, String.class, "endTime", false, "END_TIME"); - public final static Property IsFreeTask = new Property(8, String.class, "isFreeTask", false, "IS_FREE_TASK"); - } - - - public TaskLocalBeanDao(DaoConfig config) { - super(config); - } - - public TaskLocalBeanDao(DaoConfig config, DaoSession daoSession) { - super(config, daoSession); - } - - /** Creates the underlying database table. */ - public static void createTable(Database db, boolean ifNotExists) { - String constraint = ifNotExists? "IF NOT EXISTS ": ""; - db.execSQL("CREATE TABLE " + constraint + "\"TASK_LOCAL_BEAN\" (" + // - "\"_id\" INTEGER PRIMARY KEY ," + // 0: id - "\"TASK_CODE\" TEXT," + // 1: taskCode - "\"DESCRIPTION\" TEXT," + // 2: description - "\"CREATE_TIME\" TEXT," + // 3: createTime - "\"STATUS\" TEXT," + // 4: status - "\"CREATE_USER_NAME\" TEXT," + // 5: createUserName - "\"START_TIME\" TEXT," + // 6: startTime - "\"END_TIME\" TEXT," + // 7: endTime - "\"IS_FREE_TASK\" TEXT);"); // 8: isFreeTask - } - - /** Drops the underlying database table. */ - public static void dropTable(Database db, boolean ifExists) { - String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"TASK_LOCAL_BEAN\""; - db.execSQL(sql); - } - - @Override - protected final void bindValues(DatabaseStatement stmt, TaskLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String taskCode = entity.getTaskCode(); - if (taskCode != null) { - stmt.bindString(2, taskCode); - } - - String description = entity.getDescription(); - if (description != null) { - stmt.bindString(3, description); - } - - String createTime = entity.getCreateTime(); - if (createTime != null) { - stmt.bindString(4, createTime); - } - - String status = entity.getStatus(); - if (status != null) { - stmt.bindString(5, status); - } - - String createUserName = entity.getCreateUserName(); - if (createUserName != null) { - stmt.bindString(6, createUserName); - } - - String startTime = entity.getStartTime(); - if (startTime != null) { - stmt.bindString(7, startTime); - } - - String endTime = entity.getEndTime(); - if (endTime != null) { - stmt.bindString(8, endTime); - } - - String isFreeTask = entity.getIsFreeTask(); - if (isFreeTask != null) { - stmt.bindString(9, isFreeTask); - } - } - - @Override - protected final void bindValues(SQLiteStatement stmt, TaskLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String taskCode = entity.getTaskCode(); - if (taskCode != null) { - stmt.bindString(2, taskCode); - } - - String description = entity.getDescription(); - if (description != null) { - stmt.bindString(3, description); - } - - String createTime = entity.getCreateTime(); - if (createTime != null) { - stmt.bindString(4, createTime); - } - - String status = entity.getStatus(); - if (status != null) { - stmt.bindString(5, status); - } - - String createUserName = entity.getCreateUserName(); - if (createUserName != null) { - stmt.bindString(6, createUserName); - } - - String startTime = entity.getStartTime(); - if (startTime != null) { - stmt.bindString(7, startTime); - } - - String endTime = entity.getEndTime(); - if (endTime != null) { - stmt.bindString(8, endTime); - } - - String isFreeTask = entity.getIsFreeTask(); - if (isFreeTask != null) { - stmt.bindString(9, isFreeTask); - } - } - - @Override - public Long readKey(Cursor cursor, int offset) { - return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); - } - - @Override - public TaskLocalBean readEntity(Cursor cursor, int offset) { - TaskLocalBean entity = new TaskLocalBean( // - cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // taskCode - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // description - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // createTime - cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // status - cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // createUserName - cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // startTime - cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // endTime - cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8) // isFreeTask - ); - return entity; - } - - @Override - public void readEntity(Cursor cursor, TaskLocalBean entity, int offset) { - entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setTaskCode(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); - entity.setDescription(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); - entity.setCreateTime(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); - entity.setStatus(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); - entity.setCreateUserName(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); - entity.setStartTime(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); - entity.setEndTime(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); - entity.setIsFreeTask(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); - } - - @Override - protected final Long updateKeyAfterInsert(TaskLocalBean entity, long rowId) { - entity.setId(rowId); - return rowId; - } - - @Override - public Long getKey(TaskLocalBean entity) { - if(entity != null) { - return entity.getId(); - } else { - return null; - } - } - - @Override - public boolean hasKey(TaskLocalBean entity) { - return entity.getId() != null; - } - - @Override - protected final boolean isEntityUpdateable() { - return true; - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/TaskMarkerLocalBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/greendao/TaskMarkerLocalBeanDao.java deleted file mode 100644 index e96c735..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/TaskMarkerLocalBeanDao.java +++ /dev/null @@ -1,197 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import android.database.Cursor; -import android.database.sqlite.SQLiteStatement; - -import org.greenrobot.greendao.AbstractDao; -import org.greenrobot.greendao.Property; -import org.greenrobot.greendao.internal.DaoConfig; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.database.DatabaseStatement; - -import com.casic.common.detector.gd.bean.TaskMarkerLocalBean; - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** - * DAO for table "TASK_MARKER_LOCAL_BEAN". -*/ -public class TaskMarkerLocalBeanDao extends AbstractDao { - - public static final String TABLENAME = "TASK_MARKER_LOCAL_BEAN"; - - /** - * Properties of entity TaskMarkerLocalBean.
- * Can be used for QueryBuilder and for referencing column names. - */ - public static class Properties { - public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property TaskId = new Property(1, String.class, "taskId", false, "TASK_ID"); - public final static Property TaskCode = new Property(2, String.class, "taskCode", false, "TASK_CODE"); - public final static Property MarkerId = new Property(3, String.class, "markerId", false, "MARKER_ID"); - public final static Property Lng = new Property(4, double.class, "lng", false, "LNG"); - public final static Property Lat = new Property(5, double.class, "lat", false, "LAT"); - public final static Property IsDetected = new Property(6, String.class, "isDetected", false, "IS_DETECTED"); - public final static Property DetectedTime = new Property(7, String.class, "detectedTime", false, "DETECTED_TIME"); - } - - - public TaskMarkerLocalBeanDao(DaoConfig config) { - super(config); - } - - public TaskMarkerLocalBeanDao(DaoConfig config, DaoSession daoSession) { - super(config, daoSession); - } - - /** Creates the underlying database table. */ - public static void createTable(Database db, boolean ifNotExists) { - String constraint = ifNotExists? "IF NOT EXISTS ": ""; - db.execSQL("CREATE TABLE " + constraint + "\"TASK_MARKER_LOCAL_BEAN\" (" + // - "\"_id\" INTEGER PRIMARY KEY ," + // 0: id - "\"TASK_ID\" TEXT," + // 1: taskId - "\"TASK_CODE\" TEXT," + // 2: taskCode - "\"MARKER_ID\" TEXT," + // 3: markerId - "\"LNG\" REAL NOT NULL ," + // 4: lng - "\"LAT\" REAL NOT NULL ," + // 5: lat - "\"IS_DETECTED\" TEXT," + // 6: isDetected - "\"DETECTED_TIME\" TEXT);"); // 7: detectedTime - } - - /** Drops the underlying database table. */ - public static void dropTable(Database db, boolean ifExists) { - String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"TASK_MARKER_LOCAL_BEAN\""; - db.execSQL(sql); - } - - @Override - protected final void bindValues(DatabaseStatement stmt, TaskMarkerLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String taskId = entity.getTaskId(); - if (taskId != null) { - stmt.bindString(2, taskId); - } - - String taskCode = entity.getTaskCode(); - if (taskCode != null) { - stmt.bindString(3, taskCode); - } - - String markerId = entity.getMarkerId(); - if (markerId != null) { - stmt.bindString(4, markerId); - } - stmt.bindDouble(5, entity.getLng()); - stmt.bindDouble(6, entity.getLat()); - - String isDetected = entity.getIsDetected(); - if (isDetected != null) { - stmt.bindString(7, isDetected); - } - - String detectedTime = entity.getDetectedTime(); - if (detectedTime != null) { - stmt.bindString(8, detectedTime); - } - } - - @Override - protected final void bindValues(SQLiteStatement stmt, TaskMarkerLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String taskId = entity.getTaskId(); - if (taskId != null) { - stmt.bindString(2, taskId); - } - - String taskCode = entity.getTaskCode(); - if (taskCode != null) { - stmt.bindString(3, taskCode); - } - - String markerId = entity.getMarkerId(); - if (markerId != null) { - stmt.bindString(4, markerId); - } - stmt.bindDouble(5, entity.getLng()); - stmt.bindDouble(6, entity.getLat()); - - String isDetected = entity.getIsDetected(); - if (isDetected != null) { - stmt.bindString(7, isDetected); - } - - String detectedTime = entity.getDetectedTime(); - if (detectedTime != null) { - stmt.bindString(8, detectedTime); - } - } - - @Override - public Long readKey(Cursor cursor, int offset) { - return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); - } - - @Override - public TaskMarkerLocalBean readEntity(Cursor cursor, int offset) { - TaskMarkerLocalBean entity = new TaskMarkerLocalBean( // - cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // taskId - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // taskCode - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // markerId - cursor.getDouble(offset + 4), // lng - cursor.getDouble(offset + 5), // lat - cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // isDetected - cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7) // detectedTime - ); - return entity; - } - - @Override - public void readEntity(Cursor cursor, TaskMarkerLocalBean entity, int offset) { - entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setTaskId(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); - entity.setTaskCode(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); - entity.setMarkerId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); - entity.setLng(cursor.getDouble(offset + 4)); - entity.setLat(cursor.getDouble(offset + 5)); - entity.setIsDetected(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); - entity.setDetectedTime(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); - } - - @Override - protected final Long updateKeyAfterInsert(TaskMarkerLocalBean entity, long rowId) { - entity.setId(rowId); - return rowId; - } - - @Override - public Long getKey(TaskMarkerLocalBean entity) { - if(entity != null) { - return entity.getId(); - } else { - return null; - } - } - - @Override - public boolean hasKey(TaskMarkerLocalBean entity) { - return entity.getId() != null; - } - - @Override - protected final boolean isEntityUpdateable() { - return true; - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/model/TaskModel.java b/app/src/main/java/com/casic/common/detector/gd/model/TaskModel.java index 6e853ad..67ef5fb 100644 --- a/app/src/main/java/com/casic/common/detector/gd/model/TaskModel.java +++ b/app/src/main/java/com/casic/common/detector/gd/model/TaskModel.java @@ -24,7 +24,7 @@ } public static class MessageModel { - private int id; + private Long id; private String taskCode; private String description; private String deployDate; @@ -38,11 +38,11 @@ private int isValid; private List taskDetailInfos; - public int getId() { + public Long getId() { return id; } - public void setId(int id) { + public void setId(Long id) { this.id = id; } @@ -143,25 +143,25 @@ } public static class TaskDetailInfosModel { - private int id; + private long id; private String taskId; private String taskCode; private Object markerName; - private int markerId; + private String markerId; private String markerIdReal; private double longitude; private double latitude; private int isChecked; private int isNormal; - private Object imagePath; - private Object description; - private Object finishTime; + private String imagePath; + private String description; + private String finishTime; - public int getId() { + public long getId() { return id; } - public void setId(int id) { + public void setId(long id) { this.id = id; } @@ -189,11 +189,11 @@ this.markerName = markerName; } - public int getMarkerId() { + public String getMarkerId() { return markerId; } - public void setMarkerId(int markerId) { + public void setMarkerId(String markerId) { this.markerId = markerId; } @@ -237,27 +237,27 @@ this.isNormal = isNormal; } - public Object getImagePath() { + public String getImagePath() { return imagePath; } - public void setImagePath(Object imagePath) { + public void setImagePath(String imagePath) { this.imagePath = imagePath; } - public Object getDescription() { + public String getDescription() { return description; } - public void setDescription(Object description) { + public void setDescription(String description) { this.description = description; } - public Object getFinishTime() { + public String getFinishTime() { return finishTime; } - public void setFinishTime(Object finishTime) { + public void setFinishTime(String finishTime) { this.finishTime = finishTime; } } diff --git a/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitService.kt index 7522a87..0adad51 100644 --- a/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitService.kt @@ -50,7 +50,7 @@ */ @Multipart @POST("/ems/marker/save-marker-photo.do") - suspend fun installLabel( + suspend fun install( @PartMap jsonMarker: Map, @Part fileBuffer1: MultipartBody.Part?, @Part fileBuffer2: MultipartBody.Part?, diff --git a/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitServiceManager.kt index 5f6c701..ae2a0fa 100644 --- a/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitServiceManager.kt +++ b/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitServiceManager.kt @@ -37,22 +37,28 @@ /** * 获取标识器信息文件 */ - suspend fun getMarkerFile(userId: String, companyId: String): String { - return createApi().getMarkerFile(userId, companyId) + suspend fun getMarkerFile(): String { + val companyId = SaveKeyValues.getValue(LocaleConstant.USER_COMPANY_ID, "") as String + /** + * 后台设计如此,都传companyId + * */ + return createApi().getMarkerFile(companyId, companyId) } /** * 获取巡检工单 */ - suspend fun getTasksByUser(userName: String): String { + suspend fun getTasksByUser(): String { + val userName = SaveKeyValues.getValue(LocaleConstant.USER_NAME, "") as String return createApi().getTasksByUser(userName) } /** * 提交工单 */ - suspend fun uploadTask(userId: String, taskId: String?, state: String): String { + suspend fun uploadTask(taskId: String?, state: String): String { + val userId = SaveKeyValues.getValue(LocaleConstant.USER_ID, "") as String return createApi().uploadTask(userId, taskId.toString(), state) } @@ -60,8 +66,7 @@ * 安装新标识器 * Multipart上传图片,文件,带多参数上传 */ - suspend fun installLabel( - companyId: String, + suspend fun installMarker( recordType: String, markerObjectType: String, pipeMaterial: String, @@ -77,7 +82,6 @@ road: String, constructTime: String, ownerComp: String, - markerObjectId: String, markerId: String, markerType: String, markerDepth: String, @@ -89,6 +93,8 @@ memo: String, realPaths: ArrayList ): String { + val companyId = SaveKeyValues.getValue(LocaleConstant.USER_COMPANY_ID, "") as String + val objectId = SaveKeyValues.getValue(LocaleConstant.OBJECT_ID, "") as String val param = JsonObject() param.addProperty("companyId", companyId) param.addProperty("recordType", recordType) @@ -106,7 +112,7 @@ param.addProperty("road", road) param.addProperty("constructTime", constructTime) param.addProperty("ownerComp", ownerComp) - param.addProperty("markerObjectId", markerObjectId) + param.addProperty("markerObjectId", objectId) param.addProperty("markerId", markerId) param.addProperty("markerType", markerType) param.addProperty("markerDepth", markerDepth) @@ -133,19 +139,19 @@ return when (multiParts.size) { 3 -> { - createApi().installLabel(res, multiParts[0], multiParts[1], multiParts[2]) + createApi().install(res, multiParts[0], multiParts[1], multiParts[2]) } 2 -> { - createApi().installLabel(res, multiParts[0], multiParts[1], null) + createApi().install(res, multiParts[0], multiParts[1], null) } 1 -> { - createApi().installLabel(res, multiParts[0], null, null) + createApi().install(res, multiParts[0], null, null) } else -> { - createApi().installLabel(res, null, null, null) + createApi().install(res, null, null, null) } } } @@ -216,7 +222,7 @@ /** * 上传自由巡检过程中发现的标识器 */ - suspend fun uploadTaskMarker(taskId: String, ids: ArrayList): String { + suspend fun uploadTaskMarker(taskId: Long, ids: ArrayList): String { val param = JsonObject() param.addProperty("taskId", taskId) param.addProperty("ids", ids.joinToString(separator = ",")) diff --git a/app/src/main/java/com/casic/common/detector/gd/service/NtripConnectService.kt b/app/src/main/java/com/casic/common/detector/gd/service/NtripConnectService.kt index de9ac80..20e1a6a 100644 --- a/app/src/main/java/com/casic/common/detector/gd/service/NtripConnectService.kt +++ b/app/src/main/java/com/casic/common/detector/gd/service/NtripConnectService.kt @@ -9,10 +9,6 @@ import android.util.Log import android.view.Gravity import android.widget.Toast -import androidx.lifecycle.Lifecycle -import androidx.lifecycle.LifecycleOwner -import androidx.lifecycle.LifecycleRegistry -import androidx.lifecycle.lifecycleScope import com.casic.common.detector.gd.base.BaseApplication import com.casic.common.detector.gd.extensions.convertToGPGGA import com.casic.common.detector.gd.utils.LocaleConstant @@ -23,26 +19,24 @@ import com.pengxh.kt.lite.utils.WeakReferenceHandler import com.pengxh.kt.lite.utils.socket.tcp.OnTcpConnectStateListener import com.pengxh.kt.lite.utils.socket.tcp.TcpClient +import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.Job import kotlinx.coroutines.launch import java.io.OutputStream import java.nio.charset.StandardCharsets -class NtripConnectService : Service(), LifecycleOwner, OnTcpConnectStateListener, Handler.Callback { +class NtripConnectService : Service(), OnTcpConnectStateListener, Handler.Callback { companion object { var weakReferenceHandler: WeakReferenceHandler? = null } private val kTag = "NtripConnectService" - private val registry = LifecycleRegistry(this) private val socketClient by lazy { TcpClient(this) } private var outStream: OutputStream? = null - - override fun getLifecycle(): Lifecycle { - return registry - } + private val serviceScope = CoroutineScope(Dispatchers.Main + Job()) // 创建一个独立的CoroutineScope override fun onBind(intent: Intent?): IBinder? { return null @@ -117,7 +111,7 @@ * */ val result = String(this, StandardCharsets.UTF_8) if (result.contains("ICY 200 OK")) { - lifecycleScope.launch(Dispatchers.Main) { + serviceScope.launch { "高精度定位服务连接成功".show(this@NtripConnectService) } //连接服务即打开串口 @@ -135,12 +129,12 @@ * Content-Type: text/plain * Connection: clos * */ - lifecycleScope.launch(Dispatchers.Main) { + serviceScope.launch { "差分定位服务鉴权失败,无法解析位置".show(this@NtripConnectService) } } else { //居中显示 - lifecycleScope.launch(Dispatchers.Main) { + serviceScope.launch { val toast = Toast.makeText( this@NtripConnectService, "收到千寻数据,长度:${size}", Toast.LENGTH_SHORT ) @@ -167,7 +161,7 @@ return } - lifecycleScope.launch(Dispatchers.IO) { + serviceScope.launch(Dispatchers.IO) { socketClient.start(remoteHost, remotePort.toInt()) } } diff --git a/app/src/main/java/com/casic/common/detector/gd/utils/DataBaseManager.kt b/app/src/main/java/com/casic/common/detector/gd/utils/DataBaseManager.kt deleted file mode 100644 index aa22759..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/utils/DataBaseManager.kt +++ /dev/null @@ -1,200 +0,0 @@ -package com.casic.common.detector.gd.utils - -import com.casic.common.detector.gd.base.BaseApplication -import com.casic.common.detector.gd.bean.MarkerLocalBean -import com.casic.common.detector.gd.bean.TaskLocalBean -import com.casic.common.detector.gd.bean.TaskMarkerLocalBean -import com.casic.common.detector.gd.greendao.MarkerLocalBeanDao -import com.casic.common.detector.gd.greendao.TaskLocalBeanDao -import com.casic.common.detector.gd.greendao.TaskMarkerLocalBeanDao -import com.casic.common.detector.gd.model.TaskDetailLocalModel -import com.casic.common.detector.gd.model.TaskModel - -class DataBaseManager private constructor() { - companion object { - //Kotlin委托模式双重锁单例 - val get by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) { - DataBaseManager() - } - } - - private var taskLocalBeanDao = BaseApplication.get().getDaoSession().taskLocalBeanDao - private var taskMarkerLocalBeanDao = - BaseApplication.get().getDaoSession().taskMarkerLocalBeanDao - - fun saveTaskInLocale(task: TaskModel.MessageModel) { - val bean = TaskLocalBean() - bean.id = task.id.toLong() - bean.taskCode = task.taskCode - bean.description = task.description - bean.createTime = task.deployDate - bean.status = task.status - bean.createUserName = task.creatorName - if (task.beginDate == null) { - bean.startTime = "" - } - if (task.endDate == null) { - bean.endTime = "" - } - bean.isFreeTask = "0" - if (!bean.isExist()) { - taskLocalBeanDao.insert(bean) - } - } - - fun saveTaskInLocale(bean: TaskLocalBean) { - if (!bean.isExist()) { - taskLocalBeanDao.insert(bean) - } - } - - private fun TaskLocalBean.isExist(): Boolean { - val result = taskLocalBeanDao.queryBuilder().where( - TaskLocalBeanDao.Properties.Id.eq(this.id) - ).list() - return !result.isNullOrEmpty() - } - - fun saveTaskMarkerInLocale( - taskId: Int, taskCode: String, marker: TaskModel.MessageModel.TaskDetailInfosModel - ) { - val bean = TaskMarkerLocalBean() - bean.id = marker.id.toLong() - bean.taskId = taskId.toString() - bean.taskCode = taskCode - bean.markerId = marker.markerIdReal - bean.lng = marker.longitude - bean.lat = marker.latitude - bean.isDetected = "0" - bean.detectedTime = "" - if (!bean.isExist()) { - taskMarkerLocalBeanDao.insert(bean) - } - } - - private fun TaskMarkerLocalBean.isExist(): Boolean { - val result = taskMarkerLocalBeanDao.queryBuilder().where( - TaskMarkerLocalBeanDao.Properties.Id.eq(this.id) - ).list() - return !result.isNullOrEmpty() - } - - fun loadLocalTask(): ArrayList { - val result = ArrayList() - - val tasks = taskLocalBeanDao.loadAll() - tasks.forEach { - val model = TaskDetailLocalModel() - model.taskId = it.id.toString() - model.taskCode = it.taskCode - model.description = it.description - model.createTime = it.createTime - model.status = it.status - model.createUserName = it.createUserName - model.isFreeTask = it.isFreeTask - - val markers = ArrayList() - if (it.isFreeTask == "0") { - //非自由巡检才有Marker - val markerLocalBeans = taskMarkerLocalBeanDao.queryBuilder().where( - TaskMarkerLocalBeanDao.Properties.TaskId.eq(it.id), - TaskMarkerLocalBeanDao.Properties.TaskCode.eq(it.taskCode) - ).list() - markerLocalBeans.forEach { marker -> - val localModel = TaskDetailLocalModel.TaskMarkerLocalModel() - localModel.markerId = marker.markerId - localModel.lng = marker.lng - localModel.lat = marker.lat - localModel.isDetected = marker.isDetected - localModel.detectedTime = marker.detectedTime - - markers.add(localModel) - } - } - model.markerModels = markers - result.add(model) - } - return result - } - - fun deleteLocalTaskById(taskId: String, taskCode: String) { - val task = taskLocalBeanDao.queryBuilder().where( - TaskLocalBeanDao.Properties.Id.eq(taskId), - TaskLocalBeanDao.Properties.TaskCode.eq(taskCode) - ).list().firstOrNull() ?: return - taskLocalBeanDao.delete(task) - - //删除此任务关联的Marker。非自由巡检才有Marker - if (task.isFreeTask == "0") { - val markers = taskMarkerLocalBeanDao.queryBuilder() - .where( - TaskMarkerLocalBeanDao.Properties.TaskId.eq(taskId), - TaskMarkerLocalBeanDao.Properties.TaskCode.eq(taskCode) - ).list() - markers.forEach { - taskMarkerLocalBeanDao.delete(it) - } - } - } - - fun queryTaskMarkerById( - taskId: String, taskCode: String, markerId: String, state: String - ): TaskMarkerLocalBean? { - return taskMarkerLocalBeanDao.queryBuilder() - .where( - TaskMarkerLocalBeanDao.Properties.TaskId.eq(taskId), - TaskMarkerLocalBeanDao.Properties.TaskCode.eq(taskCode), - TaskMarkerLocalBeanDao.Properties.MarkerId.eq(markerId), - TaskMarkerLocalBeanDao.Properties.IsDetected.eq(state) - ).list().firstOrNull() - } - - fun updateLocalTaskMarkerState(marker: TaskMarkerLocalBean) { - marker.isDetected = "1" - taskMarkerLocalBeanDao.update(marker) - } - - fun queryMarkerByState(state: String): List { - return taskMarkerLocalBeanDao.queryBuilder() - .where(TaskMarkerLocalBeanDao.Properties.IsDetected.eq(state)) - .list() - } - - private var markerLocalBeanDao = BaseApplication.get().getDaoSession().markerLocalBeanDao - - fun clearMarkers() { - markerLocalBeanDao.deleteAll() - } - - fun saveMarkerInLocale(bean: MarkerLocalBean) { - markerLocalBeanDao.insert(bean) - } - - fun loadMarkers(): MutableList { - return markerLocalBeanDao.loadAll() - } - - fun loadMarkersByCondition(selectedItem: String, value: String?): MutableList { - val property = when (selectedItem) { - LocaleConstant.SPINNER_ARRAY[0] -> MarkerLocalBeanDao.Properties.MarkerId - LocaleConstant.SPINNER_ARRAY[1] -> MarkerLocalBeanDao.Properties.Area - LocaleConstant.SPINNER_ARRAY[2] -> MarkerLocalBeanDao.Properties.Line - LocaleConstant.SPINNER_ARRAY[3] -> MarkerLocalBeanDao.Properties.Road - LocaleConstant.SPINNER_ARRAY[4] -> MarkerLocalBeanDao.Properties.Owner - LocaleConstant.SPINNER_ARRAY[5] -> MarkerLocalBeanDao.Properties.InstallationDept - LocaleConstant.SPINNER_ARRAY[6] -> MarkerLocalBeanDao.Properties.UpdateTime - else -> MarkerLocalBeanDao.Properties.Remark - } - return if (value == null) { - markerLocalBeanDao.queryBuilder().where(property.isNotNull).list() - } else { - markerLocalBeanDao.queryBuilder().where(property.eq(value)).list() - } - } - - fun queryMarkerById(markerId: String): List { - return markerLocalBeanDao.queryBuilder() - .where(MarkerLocalBeanDao.Properties.MarkerId.eq(markerId)) - .list() - } -} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/utils/DetectorDataBase.java b/app/src/main/java/com/casic/common/detector/gd/utils/DetectorDataBase.java new file mode 100644 index 0000000..f686cac --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/utils/DetectorDataBase.java @@ -0,0 +1,21 @@ +package com.casic.common.detector.gd.utils; + +import androidx.room.Database; +import androidx.room.RoomDatabase; + +import com.casic.common.detector.gd.bean.MarkerBean; +import com.casic.common.detector.gd.bean.TaskBean; +import com.casic.common.detector.gd.bean.TaskMarkerBean; +import com.casic.common.detector.gd.dao.MarkerBeanDao; +import com.casic.common.detector.gd.dao.TaskBeanDao; +import com.casic.common.detector.gd.dao.TaskMarkerBeanDao; + + +@Database(entities = {MarkerBean.class, TaskBean.class, TaskMarkerBean.class}, version = 1) +public abstract class DetectorDataBase extends RoomDatabase { + public abstract MarkerBeanDao markerBeanDao(); + + public abstract TaskBeanDao taskBeanDao(); + + public abstract TaskMarkerBeanDao taskMarkerBeanDao(); +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/utils/ExcelKit.kt b/app/src/main/java/com/casic/common/detector/gd/utils/ExcelKit.kt index 200fac7..015969f 100644 --- a/app/src/main/java/com/casic/common/detector/gd/utils/ExcelKit.kt +++ b/app/src/main/java/com/casic/common/detector/gd/utils/ExcelKit.kt @@ -1,19 +1,19 @@ package com.casic.common.detector.gd.utils -import com.casic.common.detector.gd.bean.MarkerLocalBean +import com.casic.common.detector.gd.base.BaseApplication +import com.casic.common.detector.gd.bean.MarkerBean import jxl.Workbook import jxl.read.biff.BiffException import java.io.File object ExcelKit { - fun read(filePath: String): ArrayList { - val result = ArrayList() + fun read(filePath: String): ArrayList { + val result = ArrayList() try { val workbook = Workbook.getWorkbook(File(filePath)) val sheet = workbook.getSheet(0) - for (i in 1 until sheet.rows) { - val marker = MarkerLocalBean() + val marker = MarkerBean() marker.pipelineType = sheet.getCell(0, i).contents marker.pipelineDiameter = sheet.getCell(1, i).contents marker.pipelineMaterial = sheet.getCell(2, i).contents @@ -40,9 +40,10 @@ marker.objectType = sheet.getCell(23, i).contents marker.color = sheet.getCell(24, i).contents marker.imagePath = sheet.getCell(25, i).contents - - result.add(marker) - DataBaseManager.get.saveMarkerInLocale(marker) + if (!marker.markerId.isNullOrBlank()) { + result.add(marker) + BaseApplication.get().dataBase.markerBeanDao().insert(marker) + } } workbook.close() } catch (e: BiffException) { diff --git a/app/src/main/java/com/casic/common/detector/gd/utils/LocaleConstant.kt b/app/src/main/java/com/casic/common/detector/gd/utils/LocaleConstant.kt index c658924..8ac5f76 100644 --- a/app/src/main/java/com/casic/common/detector/gd/utils/LocaleConstant.kt +++ b/app/src/main/java/com/casic/common/detector/gd/utils/LocaleConstant.kt @@ -1,6 +1,8 @@ package com.casic.common.detector.gd.utils import android.Manifest +import androidx.sqlite.db.SimpleSQLiteQuery +import androidx.sqlite.db.SupportSQLiteQuery object LocaleConstant { @@ -59,4 +61,19 @@ var BURY_METHOD_ARRAY = arrayOf("直埋", "圆管", "管块", "管沟", "架空") var IDENTIFIER_TYPE_ARRAY = arrayOf("EM30", "EM50", "EM14") var COLOR_ARRAY = arrayOf("蓝色", "橙色", "红色", "黑色", "紫色", "黄色", "绿色") + + fun buildQuery(selectedItem: String, value: String): SupportSQLiteQuery { + val columnName = when (selectedItem) { + SPINNER_ARRAY[0] -> "markerId" + SPINNER_ARRAY[1] -> "area" + SPINNER_ARRAY[2] -> "line" + SPINNER_ARRAY[3] -> "road" + SPINNER_ARRAY[4] -> "owner" + SPINNER_ARRAY[5] -> "installationDept" + SPINNER_ARRAY[6] -> "updateTime" + else -> "remark" + } + val queryBuilder = StringBuilder("SELECT * FROM marker_detail WHERE $columnName = ?") + return SimpleSQLiteQuery(queryBuilder.toString(), arrayOf(value)) + } } \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/view/InstallMarkerActivity.kt b/app/src/main/java/com/casic/common/detector/gd/view/InstallMarkerActivity.kt index daf5b0f..9e09df1 100644 --- a/app/src/main/java/com/casic/common/detector/gd/view/InstallMarkerActivity.kt +++ b/app/src/main/java/com/casic/common/detector/gd/view/InstallMarkerActivity.kt @@ -14,8 +14,9 @@ import com.amap.api.location.AMapLocation import com.casic.common.detector.gd.R import com.casic.common.detector.gd.adapter.EditableImageAdapter +import com.casic.common.detector.gd.base.BaseApplication import com.casic.common.detector.gd.base.SerialPortBaseActivity -import com.casic.common.detector.gd.bean.MarkerLocalBean +import com.casic.common.detector.gd.bean.MarkerBean import com.casic.common.detector.gd.callback.OnGetLocationListener import com.casic.common.detector.gd.callback.OnImageCompressListener import com.casic.common.detector.gd.databinding.ActivityInstallMarkerBinding @@ -27,7 +28,6 @@ import com.casic.common.detector.gd.extensions.toColor import com.casic.common.detector.gd.extensions.toObjectType import com.casic.common.detector.gd.utils.CurrentSegment -import com.casic.common.detector.gd.utils.DataBaseManager import com.casic.common.detector.gd.utils.LocaleConstant import com.casic.common.detector.gd.utils.LocationKit import com.casic.common.detector.gd.utils.RuntimeCache @@ -44,7 +44,6 @@ import com.pengxh.kt.lite.extensions.timestampToCompleteDate import com.pengxh.kt.lite.extensions.timestampToTime import com.pengxh.kt.lite.extensions.toJson -import com.pengxh.kt.lite.utils.LoadState import com.pengxh.kt.lite.utils.LoadingDialog import com.pengxh.kt.lite.utils.SaveKeyValues import com.pengxh.kt.lite.widget.TitleBarView @@ -115,8 +114,6 @@ //安装 binding.installButton.setOnClickListener { - val companyId = SaveKeyValues.getValue(LocaleConstant.USER_COMPANY_ID, "") as String - val objectId = SaveKeyValues.getValue(LocaleConstant.OBJECT_ID, "") as String if (binding.objectInclude.pipeInclude.markerObjectTypeView.text.isNullOrBlank()) { when (binding.objectInclude.objectTypeSpinner.selectedItem.toString()) { "管线" -> "请输入管线种类!".show(this) @@ -189,8 +186,7 @@ //先存本地再上传服务器 saveMarkerInLocal() - taskViewModel.installLabel( - this, companyId, + taskViewModel.installMarker( binding.objectInclude.objectTypeSpinner.selectedItem.toString().toObjectType(), binding.objectInclude.pipeInclude.markerObjectTypeView.text.toString(), binding.objectInclude.pipeInclude.materialSpinner.selectedItem.toString(), @@ -206,7 +202,6 @@ binding.objectInclude.roadView.text.toString(), binding.objectInclude.constructDateView.text.toString(), binding.objectInclude.ownerView.text.toString(), - objectId, binding.identifierInclude.identifierIdView.text.toString(), binding.identifierInclude.identifierTypeSpinner.selectedItem.toString(), "${binding.identifierInclude.identifierDeepView.text}mm", @@ -216,7 +211,19 @@ binding.identifierInclude.latView.text.toString(), binding.identifierInclude.colorSpinner.selectedItem.toString().toColor(), binding.remarkView.text.toString(), - realPaths + realPaths, + onLoading = { + LoadingDialog.show(this, "标识器安装中,请稍后...") + }, + onSuccess = { + LoadingDialog.dismiss() + clearDefaultData() + "安装成功".show(this) + }, + onFailed = { + LoadingDialog.dismiss() + it.show(this) + } ) //保存默认值 @@ -268,7 +275,7 @@ private fun saveMarkerInLocal() { val objectId = SaveKeyValues.getValue(LocaleConstant.OBJECT_ID, "") as String - val marker = MarkerLocalBean() + val marker = MarkerBean() marker.objectType = binding.objectInclude.objectTypeSpinner.selectedItem.toString() marker.pipelineType = binding.objectInclude.pipeInclude.markerObjectTypeView.text.toString() marker.pipelineMaterial = @@ -302,7 +309,7 @@ marker.remark = binding.remarkView.text.toString() marker.imagePath = realPaths.toJson() - DataBaseManager.get.saveMarkerInLocale(marker) + BaseApplication.get().dataBase.markerBeanDao().insert(marker) } private fun takePicture() { @@ -339,8 +346,8 @@ override fun initOnCreate(savedInstanceState: Bundle?) { locationKit.getCurrentLocation(true, object : OnGetLocationListener { override fun onSuccess(location: AMapLocation) { - binding.identifierInclude.lngView.text = location.longitude.toString() - binding.identifierInclude.latView.text = location.latitude.toString() + binding.identifierInclude.lngView.text = "${location.longitude}" + binding.identifierInclude.latView.text = "${location.latitude}" } override fun onError() { @@ -357,22 +364,6 @@ return ActivityInstallMarkerBinding.inflate(layoutInflater) } - override fun observeRequestState() { - taskViewModel.loadState.observe(this) { - when (it) { - LoadState.Loading -> LoadingDialog.show(this, "标识器安装中,请稍后...") - - LoadState.Success -> { - LoadingDialog.dismiss() - clearDefaultData() - "安装成功".show(this) - } - - else -> LoadingDialog.dismiss() - } - } - } - override fun setupTopBarLayout() { binding.rootView.initImmersionBar(this, true, R.color.white) binding.titleView.setOnClickListener(object : TitleBarView.OnClickListener { diff --git a/app/src/main/java/com/casic/common/detector/gd/view/MainActivity.kt b/app/src/main/java/com/casic/common/detector/gd/view/MainActivity.kt index fb0b260..a6352fb 100644 --- a/app/src/main/java/com/casic/common/detector/gd/view/MainActivity.kt +++ b/app/src/main/java/com/casic/common/detector/gd/view/MainActivity.kt @@ -5,7 +5,6 @@ import android.graphics.Color import android.media.AudioAttributes import android.media.SoundPool -import android.os.Build import android.os.Bundle import android.os.CountDownTimer import android.os.Handler @@ -31,19 +30,17 @@ import com.casic.common.detector.gd.R import com.casic.common.detector.gd.base.BaseApplication import com.casic.common.detector.gd.base.SerialPortBaseActivity -import com.casic.common.detector.gd.bean.MarkerLocalBean -import com.casic.common.detector.gd.bean.TaskLocalBean +import com.casic.common.detector.gd.bean.MarkerBean import com.casic.common.detector.gd.callback.OnGetAddressListener import com.casic.common.detector.gd.callback.OnGetLocationListener import com.casic.common.detector.gd.databinding.ActivityMainBinding import com.casic.common.detector.gd.extensions.appendDownloadUrl -import com.casic.common.detector.gd.extensions.createTaskCode import com.casic.common.detector.gd.extensions.initImmersionBar +import com.casic.common.detector.gd.model.MarkerFileModel import com.casic.common.detector.gd.model.TaskDetailLocalModel import com.casic.common.detector.gd.model.TaskModel import com.casic.common.detector.gd.service.NtripConnectService import com.casic.common.detector.gd.utils.CurrentSegment -import com.casic.common.detector.gd.utils.DataBaseManager import com.casic.common.detector.gd.utils.ExcelKit import com.casic.common.detector.gd.utils.FileType import com.casic.common.detector.gd.utils.LocaleConstant @@ -62,9 +59,7 @@ import com.pengxh.kt.lite.extensions.isNetworkConnected import com.pengxh.kt.lite.extensions.navigatePageTo import com.pengxh.kt.lite.extensions.show -import com.pengxh.kt.lite.extensions.timestampToCompleteDate import com.pengxh.kt.lite.utils.FileDownloadManager -import com.pengxh.kt.lite.utils.LoadState import com.pengxh.kt.lite.utils.LoadingDialog import com.pengxh.kt.lite.utils.SaveKeyValues import com.pengxh.kt.lite.widget.TitleBarView @@ -86,6 +81,9 @@ private val samplePopupWindow by lazy { SamplePopupWindow(this) } private val detailDialog by lazy { MarkerDetailDialog(this) } private val locationKit by lazy { LocationKit(this) } + private val markerBeanDao by lazy { BaseApplication.get().dataBase.markerBeanDao() } + private val taskBeanDao by lazy { BaseApplication.get().dataBase.taskBeanDao() } + private val taskMarkerBeanDao by lazy { BaseApplication.get().dataBase.taskMarkerBeanDao() } private val taskViewModel by lazy { ViewModelProvider(this)[TaskViewModel::class.java] } private val attr = AudioAttributes.Builder().setUsage(AudioAttributes.USAGE_ALARM) .setContentType(AudioAttributes.CONTENT_TYPE_MUSIC).build() @@ -94,7 +92,7 @@ private var isFreeTask = false private var freeTaskTitle = "" private var ids = ArrayList() - private var freeTaskId: String? = null + private var freeTaskId = 0L private var soundResourceId = 0 private var isExecuteTask = false private lateinit var aMap: AMap @@ -111,89 +109,14 @@ //地图初始化 initMapConfig(savedInstanceState) - Intent(this, NtripConnectService::class.java).also { - startService(it) - } +// Intent(this, NtripConnectService::class.java).apply { +// startService(this) +// } soundResourceId = soundPool.load(this, R.raw.ring3, 1) //右上角菜单 samplePopupWindow.setPopupMenuItem(LocaleConstant.POPUP_TITLES) samplePopupWindow.setBackgroundDrawable(null) - - //task网络请求监听 - taskViewModel.markerFileResult.observe(this) { - if (it.isSuccess) { - //清空之前的数据 - DataBaseManager.get.clearMarkers() - //下载最新的数据 - val companyId = SaveKeyValues.getValue(LocaleConstant.USER_COMPANY_ID, "") - val downloadUrl = companyId.toString().appendDownloadUrl(FileType.Excel) - Log.d(kTag, "downloadUrl => $downloadUrl") - FileDownloadManager.Builder().setDownloadFileSource(downloadUrl) - .setFileSuffix("xls").setFileSaveDirectory(createDownloadFileDir()) - .setOnFileDownloadListener(object : FileDownloadManager.OnFileDownloadListener { - override fun onDownloadStart(total: Long) { - - } - - override fun onDownloadEnd(file: File) { - lifecycleScope.launch(Dispatchers.IO) { ExcelKit.read(file.absolutePath) } - LoadingDialog.dismiss() - showMarkersOnMap() - } - - override fun onDownloadFailed(t: Throwable) { - t.printStackTrace() - } - - override fun onProgressChanged(progress: Long) { - - } - }).build().start() - } - } - taskViewModel.taskResult.observe(this) { - if (it.success == "true") { - AlertMessageDialog.Builder().setContext(this).setTitle("温馨提示") - .setMessage("您有${it.message.size}个新任务!").setPositiveButton("知道了") - .setOnDialogButtonClickListener(object : - AlertMessageDialog.OnDialogButtonClickListener { - override fun onConfirmClick() { - saveUserTasks(it) - } - }).build().show() - } - } - taskViewModel.freeTaskResult.observe(this) { - freeTaskId = it - // 自由巡检保存在本地 - val bean = TaskLocalBean() - bean.id = freeTaskId.toString().toLong() - val currentTimeMillis = System.currentTimeMillis() - bean.taskCode = currentTimeMillis.createTaskCode() - bean.description = freeTaskTitle - val time = currentTimeMillis.timestampToCompleteDate() - bean.createTime = time - bean.status = "0" - val userName = SaveKeyValues.getValue(LocaleConstant.USER_NAME, "") as String - bean.createUserName = userName - bean.startTime = time - bean.endTime = "" - bean.isFreeTask = "1" - DataBaseManager.get.saveTaskInLocale(bean) - } - taskViewModel.uploadTaskMarkerResult.observe(this) { - "自由巡检任务已完成".show(this) - ids.clear() - //清空自由巡检添加的Marker - aMap.clear() - showMarkersOnMap() - } - taskViewModel.executeTaskResult.observe(this) { - "工单任务已完成".show(this) - aMap.clear() - showMarkersOnMap() - } } override fun initEvent() { @@ -216,7 +139,7 @@ }).build().show() } else { lifecycleScope.launch(Dispatchers.Main) { - val markers = DataBaseManager.get.queryMarkerByState("0") + val markers = taskMarkerBeanDao.queryMarkerByState("0") //如果有需要补全的标识器,Popup右侧会有小圆点提示 if (markers.isNotEmpty()) { samplePopupWindow.setShowPosition(4) @@ -239,13 +162,7 @@ 3 -> uploadEvent() 4 -> completionMarker() 5 -> showRtkConfigDialog() - 6 -> { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { - SatelliteStatusDialog(context).show() - } else { - "卫星数据仅支持Android 7.0以上系统".show(context) - } - } + 6 -> SatelliteStatusDialog(context).show() } } }) @@ -268,25 +185,23 @@ //查看 binding.viewButton.setOnClickListener { - QueryMarkerDialog.Builder().setContext(this).setTitle("查看标识器") - .setSpinnerArray(LocaleConstant.SPINNER_ARRAY).setNegativeButton("取消") + QueryMarkerDialog.Builder() + .setContext(this) + .setTitle("查看标识器") + .setSpinnerArray(LocaleConstant.SPINNER_ARRAY) + .setNegativeButton("取消") .setPositiveButton("确定").setOnDialogButtonClickListener(object : QueryMarkerDialog.OnDialogButtonClickListener { override fun onConfirmClick(selectedItem: String, value: String) { //查询数据库 - lifecycleScope.launch(Dispatchers.Main) { - val markers = DataBaseManager.get.loadMarkersByCondition( - selectedItem, value - ) as ArrayList - - if (markers.isEmpty()) { - "无法查到相关数据信息,请检查您的查询条件".show(context) - } else { + val buildQuery = LocaleConstant.buildQuery(selectedItem, value) + markerBeanDao.loadMarkersByCondition(buildQuery).run { + if (isNotEmpty()) { val latitudeList = ArrayList() val longitudeList = ArrayList() - val latitude = markers.first().lat - val longitude = markers.first().lng + val latitude = first().lat + val longitude = first().lng if (latitude.isNotBlank() && longitude.isNotBlank()) { if (CoordinateConverter.isAMapDataAvailable( latitude.toDouble(), longitude.toDouble() @@ -300,10 +215,11 @@ if (latitudeList.isNotEmpty() && longitudeList.isNotEmpty()) { //移动地图到所有labelBeans的第一个点 - val center = LatLng(latitudeList.first(), longitudeList.first()) - //移动到指定经纬度 - aMap.moveCamera(CameraUpdateFactory.newLatLngZoom(center, 16f)) + val target = LatLng(latitudeList.first(), longitudeList.first()) + aMap.moveCamera(CameraUpdateFactory.newLatLngZoom(target, 16f)) } + } else { + "无法查到相关信息,请检查您的查询条件".show(context) } } } @@ -316,32 +232,39 @@ //巡检 binding.inspectionButton.setOnClickListener { - val tasks = DataBaseManager.get.loadLocalTask() - if (tasks.isNotEmpty()) { - val arrayList = ArrayList() - tasks.forEachIndexed { index, task -> - arrayList.add("任务${index + 1}:${task.taskId},${task.description}") + lifecycleScope.launch { + val tasks = withContext(Dispatchers.IO) { + taskBeanDao.loadLocalTask(taskMarkerBeanDao) } + if (tasks.isNotEmpty()) { + val arrayList = ArrayList() + tasks.forEachIndexed { index, task -> + arrayList.add("任务${index + 1}:${task.taskId},${task.description}") + } - BottomActionSheet.Builder().setContext(this).setItemTextColor(Color.BLUE) - .setActionItemTitle(arrayList) - .setOnActionSheetListener(object : BottomActionSheet.OnActionSheetListener { - override fun onActionItemClick(position: Int) { - val task = tasks[position] - SaveKeyValues.putValue(LocaleConstant.TASK_ID, task.taskId) - SaveKeyValues.putValue(LocaleConstant.TASK_CODE, task.taskCode) - executeTask(task) - } - }).build().show() - } else { - AlertMessageDialog.Builder().setContext(this).setTitle("温馨提示") - .setMessage("所有任务已完成,请点击右上角菜单下载新工单或者开始自由巡检") - .setPositiveButton("开始自由巡检").setOnDialogButtonClickListener(object : - AlertMessageDialog.OnDialogButtonClickListener { - override fun onConfirmClick() { - executeFreeTask() - } - }).build().show() + BottomActionSheet.Builder().setContext(context) + .setItemTextColor(Color.BLUE) + .setActionItemTitle(arrayList) + .setOnActionSheetListener(object : BottomActionSheet.OnActionSheetListener { + override fun onActionItemClick(position: Int) { + val task = tasks[position] + SaveKeyValues.putValue(LocaleConstant.TASK_ID, task.taskId) + SaveKeyValues.putValue(LocaleConstant.TASK_CODE, task.taskCode) + executeTask(task) + } + }).build().show() + } else { + AlertMessageDialog.Builder() + .setContext(context) + .setTitle("温馨提示") + .setMessage("所有任务已完成,请点击右上角菜单下载新工单或者开始自由巡检") + .setPositiveButton("开始自由巡检").setOnDialogButtonClickListener(object : + AlertMessageDialog.OnDialogButtonClickListener { + override fun onConfirmClick() { + executeFreeTask() + } + }).build().show() + } } } @@ -371,8 +294,11 @@ //自由巡检 binding.stopFreeTaskButton.setOnLongClickListener { - AlertMessageDialog.Builder().setContext(this).setTitle("温馨提示") - .setMessage("是否确定结束此次自由巡检任务?").setPositiveButton("是") + AlertMessageDialog.Builder() + .setContext(this) + .setTitle("温馨提示") + .setMessage("是否确定结束此次自由巡检任务?") + .setPositiveButton("是") .setOnDialogButtonClickListener(object : AlertMessageDialog.OnDialogButtonClickListener { override fun onConfirmClick() { @@ -381,14 +307,38 @@ stopSerialPortCommand() binding.stopFreeTaskButton.visibility = View.GONE - if (freeTaskId.isNullOrBlank()) { + if (freeTaskId == 0L) { "任务ID异常,无法提交任务,请联系服务器管理员".show(context) return } - freeTaskId?.apply { - taskViewModel.uploadTaskMarker(context, this, ids) - } + taskViewModel.uploadTaskMarker( + freeTaskId, + ids, + onLoading = { + LoadingDialog.show(context, "任务提交中,请稍后...") + }, + onSuccess = { + LoadingDialog.dismiss() + "自由巡检任务已完成".show(context) + ids.clear() + aMap.clear() + showMarkersOnMap() + + //删除本地数据库 + val taskCode = SaveKeyValues.getValue( + LocaleConstant.TASK_CODE, "" + ) as String + taskBeanDao.deleteLocalTaskById( + freeTaskId, taskCode, taskMarkerBeanDao + ) + SaveKeyValues.putValue(LocaleConstant.TASK_ID, "") + }, + onFailed = { + LoadingDialog.dismiss() + it.show(context) + } + ) } }).build().show() true @@ -399,25 +349,52 @@ RtkConfigDialog(this).setOnDialogButtonClickListener(object : RtkConfigDialog.OnDialogButtonClickListener { override fun onConfirmClick() { - NtripConnectService.weakReferenceHandler?.apply { - sendEmptyMessage(2024082201) - } + NtripConnectService.weakReferenceHandler?.sendEmptyMessage(2024082201) } }).show() } private fun uploadTask(taskId: String, taskCode: String, state: String) { if (isNetworkConnected()) { - val userId = SaveKeyValues.getValue(LocaleConstant.USER_ID, "") as String - taskViewModel.uploadTask(this, userId, taskId, taskCode, state) + taskViewModel.uploadTask( + taskId, state, + onLoading = { + LoadingDialog.show(this, "工单提交中,请稍后...") + }, + onSuccess = { + LoadingDialog.dismiss() + //工单提交之后,并且状态是2,删除本地Task记录 + if (state == "2") { + "工单${taskId}已提交!".show(this) + //删除本地数据库 + taskBeanDao.deleteLocalTaskById( + taskId.toLong(), taskCode, taskMarkerBeanDao + ) + SaveKeyValues.putValue(LocaleConstant.TASK_ID, "") + } else { + Log.d(kTag, "uploadTask: 仅执行工单,不删除本地工单数据") + } + aMap.clear() + showMarkersOnMap() + "工单任务已完成".show(this) + }, + onFailed = { + LoadingDialog.dismiss() + it.show(this) + } + ) } else { "网络连接已断开,请检查".show(this) } } private fun executeTask(task: TaskDetailLocalModel) { - AlertControlDialog.Builder().setContext(this).setTitle("提示").setMessage("请选择操作方式") - .setPositiveButton("执行工单").setNegativeButton("提交工单") + AlertControlDialog.Builder() + .setContext(this) + .setTitle("提示") + .setMessage("请选择操作方式") + .setPositiveButton("执行工单") + .setNegativeButton("提交工单") .setOnDialogButtonClickListener(object : AlertControlDialog.OnDialogButtonClickListener { override fun onConfirmClick() { @@ -432,7 +409,7 @@ isExecuteTask = true } else { "此工单下无标识器,将执行自由巡检任务".show(context) - freeTaskId = task.taskId + freeTaskId = task.taskId.toLong() detectMarker() } } @@ -453,7 +430,18 @@ override fun onConfirmClick(value: String) { freeTaskTitle = value val userId = SaveKeyValues.getValue(LocaleConstant.USER_ID, "") as String - taskViewModel.createFreeTask(context, userId, value) + taskViewModel.createFreeTask( + userId, value, + onLoading = {}, + onSuccess = { + freeTaskId = it + // 自由巡检保存在本地 + taskBeanDao.saveTask(it, freeTaskTitle) + }, + onFailed = { + it.show(context) + } + ) detectMarker() } @@ -481,7 +469,7 @@ if (RuntimeCache.currentSegment == CurrentSegment.FreeInspection) { //显示标识器详细信息 if (!detailDialog.isShowing) { - DataBaseManager.get.queryMarkerById(markerId).firstOrNull().apply { + markerBeanDao.queryMarkerById(markerId).firstOrNull().apply { if (this == null) { "无法查询到此ID【${markerId}】的信息".show(context) } else { @@ -501,7 +489,7 @@ //不重复标注Marker if (!ids.contains(markerId)) { - val markers = DataBaseManager.get.queryMarkerById(markerId) + val markers = markerBeanDao.queryMarkerById(markerId) if (markers.isNotEmpty()) { val marker = markers.first() val latLng = LatLng(marker.lat.toDouble(), marker.lng.toDouble()) @@ -522,16 +510,6 @@ } - override fun observeRequestState() { - taskViewModel.loadState.observe(this) { - when (it) { - LoadState.Loading -> LoadingDialog.show(this, "提交工单中,请稍后") - - else -> LoadingDialog.dismiss() - } - } - } - private fun initMapConfig(savedInstanceState: Bundle?) { binding.mapView.onCreate(savedInstanceState) aMap = binding.mapView.map @@ -592,54 +570,25 @@ private fun saveUserTasks(task: TaskModel) { task.message.forEach { model -> //保存任务详情 - DataBaseManager.get.saveTaskInLocale(model) + taskBeanDao.saveTask(model) model.taskDetailInfos.forEach { marker -> //只保存有标识器ID得数据 if (!marker.markerIdReal.isNullOrBlank()) { - DataBaseManager.get.saveTaskMarkerInLocale(model.id, model.taskCode, marker) + taskMarkerBeanDao.saveTaskMarker(model.id, model.taskCode, marker) } } } "工单下载成功!".show(this) } - private fun showMarkersOnMap() { - lifecycleScope.launch(Dispatchers.IO) { - //取缓存 - val markers = DataBaseManager.get.loadMarkers() - if (markers.isEmpty()) { - return@launch - } - val first = markers.first() - val defaultLatLng = LatLng(first.lat.toDouble(), first.lng.toDouble()) - //移动到指定经纬度 - val cameraPosition = CameraPosition(defaultLatLng, 14f, 0f, 0f) - val cameraUpdate = CameraUpdateFactory.newCameraPosition(cameraPosition) - withContext(Dispatchers.Main) { - aMap.animateCamera(cameraUpdate, 1500, null) - LoadingDialog.dismiss() - } - - markers.forEach { marker -> - val latitude = marker.lat.toString().toDouble() - val longitude = marker.lng.toString().toDouble() - //将所有设备信息转化缓存为Marker点 - val options = MarkerOptions() - .position(LatLng(latitude, longitude)) - .title(marker.markerId) - aMap.addMarker(options) - } - } - } - override fun onMarkerClick(marker: Marker?): Boolean { - marker?.apply { - showNavigationOption(title, position) + marker?.let { + showNavigationOption(it.title, it.position) } return true } - override fun onMapLongClick(p0: LatLng?) { + override fun onMapLongClick(latLng: LatLng?) { showMarkersOnMap() } @@ -664,7 +613,7 @@ } override fun onCancelClick() { - val result = DataBaseManager.get.queryMarkerById(title) + val result = markerBeanDao.queryMarkerById(title) MarkerDetailDialog(context).setMarker(result.first()).show() } }).build().show() @@ -695,20 +644,24 @@ //更新标识器数据 private fun updateMarkers() { - AlertControlDialog.Builder().setContext(this).setTitle("提示").setMessage("是否更新数据?") - .setNegativeButton("取消").setPositiveButton("确定") + AlertControlDialog.Builder() + .setContext(this) + .setTitle("提示") + .setMessage("是否更新数据?") + .setNegativeButton("取消") + .setPositiveButton("确定") .setOnDialogButtonClickListener(object : AlertControlDialog.OnDialogButtonClickListener { override fun onConfirmClick() { if (isNetworkConnected()) { - val companyId = SaveKeyValues.getValue(LocaleConstant.USER_COMPANY_ID, "") - - LoadingDialog.show(this@MainActivity, "获取标识器信息中,请稍后") - /** - * 后台设计如此,都传companyId - * */ + //清空之前的数据 + markerBeanDao.deleteAll() + aMap.clear() + //获取标识器数据 taskViewModel.getMarkerFile( - context, companyId.toString(), companyId.toString() + onLoading = {}, + onSuccess = { handleMarkerFile(it) }, + onFailed = { it.show(context) } ) } else { "网络连接已断开,请检查".show(context) @@ -721,11 +674,105 @@ }).build().show() } + private fun handleMarkerFile(it: MarkerFileModel) { + if (it.isSuccess) { + //下载最新的数据 + val companyId = SaveKeyValues.getValue(LocaleConstant.USER_COMPANY_ID, "") + val downloadUrl = companyId.toString().appendDownloadUrl(FileType.Excel) + Log.d(kTag, "handleMarkerFile => $downloadUrl") + FileDownloadManager.Builder() + .setDownloadFileSource(downloadUrl) + .setFileSuffix("xls") + .setFileSaveDirectory(createDownloadFileDir()) + .setOnFileDownloadListener(object : FileDownloadManager.OnFileDownloadListener { + override fun onDownloadStart(total: Long) { + LoadingDialog.show(context, "标识器数据解析中,请稍后...") + } + + override fun onDownloadEnd(file: File) { + lifecycleScope.launch(Dispatchers.IO) { + ExcelKit.read(file.absolutePath).apply { + renderMarkers(this) + }.also { + withContext(Dispatchers.Main) { + LoadingDialog.dismiss() + "标识器数据渲染完成".show(context) + } + } + } + } + + override fun onDownloadFailed(t: Throwable) { + t.printStackTrace() + LoadingDialog.dismiss() + "标识器数据下载失败".show(context) + } + + override fun onProgressChanged(progress: Long) { + + } + }).build().start() + } + } + + private fun showMarkersOnMap() { + lifecycleScope.launch(Dispatchers.IO) { + //取缓存 + markerBeanDao.loadAll().run { + renderMarkers(this) + }.also { + withContext(Dispatchers.Main) { + "标识器数据渲染完成".show(context) + } + } + } + } + + private fun renderMarkers(markers: List) { + if (markers.isEmpty()) { + return + } + val first = markers.first() + val defaultLatLng = LatLng(first.lat.toDouble(), first.lng.toDouble()) + //移动到指定经纬度 + val cameraPosition = CameraPosition(defaultLatLng, 14f, 0f, 0f) + val cameraUpdate = CameraUpdateFactory.newCameraPosition(cameraPosition) + aMap.animateCamera(cameraUpdate, 1500, null) + markers.forEach { marker -> + val latitude = marker.lat.toString().toDouble() + val longitude = marker.lng.toString().toDouble() + //将所有设备信息转化缓存为Marker点 + val options = MarkerOptions() + .position(LatLng(latitude, longitude)) + .title(marker.markerId) + aMap.addMarker(options) + } + } + //下载工单 private fun downloadTask() { if (isNetworkConnected()) { - val userName = SaveKeyValues.getValue(LocaleConstant.USER_NAME, "") - taskViewModel.getTasksByUser(this, userName.toString()) + taskViewModel.getTasksByUser( + onLoading = {}, + onSuccess = { + if (it.success == "true") { + AlertMessageDialog.Builder() + .setContext(this) + .setTitle("温馨提示") + .setMessage("您有${it.message.size}个新任务!") + .setPositiveButton("知道了") + .setOnDialogButtonClickListener(object : + AlertMessageDialog.OnDialogButtonClickListener { + override fun onConfirmClick() { + saveUserTasks(it) + } + }).build().show() + } + }, + onFailed = { + it.show(this) + } + ) } else { "网络连接已断开,请检查".show(this) } @@ -744,7 +791,7 @@ //标识器补全 private fun completionMarker() { val companyId = SaveKeyValues.getValue(LocaleConstant.USER_COMPANY_ID, "") as String - val markers = DataBaseManager.get.queryMarkerByState("0") + val markers = taskMarkerBeanDao.queryMarkerByState("0") if (markers.isNotEmpty()) { //TODO 逻辑没梳理明白 } else { diff --git a/app/build.gradle b/app/build.gradle index d0cb423..921c8c8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,25 +1,20 @@ import java.text.SimpleDateFormat -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply plugin: 'org.greenrobot.greendao' +plugins { + id('com.android.application') + id('org.jetbrains.kotlin.android') +} android { - compileSdkVersion 33 + namespace 'com.casic.common.detector.gd' + compileSdk 35 defaultConfig { - applicationId "com.casic.common.detector.gd" - minSdkVersion 26 - targetSdkVersion 33 + applicationId 'com.casic.common.detector.gd' + minSdk 26 + targetSdk 35 versionCode 5092 - versionName "5.0.9.2" - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } + versionName '5.0.9.2' } signingConfigs { @@ -31,6 +26,14 @@ } } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + signingConfig signingConfigs.release + } + } + compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 @@ -47,27 +50,16 @@ } } - kotlin { - experimental { - coroutines 'enable' - } - } - buildFeatures { + buildConfig true viewBinding true } - applicationVariants.configureEach { variant -> - variant.outputs.configureEach { - outputFileName = "COM_TCY_" + getBuildDate() + "_" + defaultConfig.versionName + ".apk" + applicationVariants.configureEach { + outputs.configureEach { + outputFileName = 'COM_TCY_' + getBuildDate() + '_' + defaultConfig.versionName + '.apk' } } - - greendao { - schemaVersion 1//数据库版本号 - targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 - daoPackage "${defaultConfig.applicationId}.greendao"//设置DaoMaster、DaoSession、Dao包名 - } } static def getBuildDate() { @@ -76,27 +68,22 @@ } dependencies { - //基础依赖库 - implementation 'com.github.AndroidCoderPeng:Kotlin-lite-lib:1.1.4' - implementation 'androidx.core:core-ktx:1.9.0' - def base_version = "1.6.1" - implementation "androidx.appcompat:appcompat:${base_version}" - implementation "com.google.android.material:material:${base_version}" + implementation 'com.github.AndroidCoderPeng:Kotlin-lite-lib:1.1.5' + implementation 'androidx.core:core-ktx:1.13.1' + implementation 'androidx.appcompat:appcompat:1.7.0' + implementation 'com.google.android.material:material:1.12.0' //Google官方授权框架 implementation 'pub.devrel:easypermissions:3.0.0' - //沉浸式状态栏。基础依赖包,必须要依赖 - implementation 'com.gyf.immersionbar:immersionbar:3.0.0' - //fragment快速实现 - implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0' + //沉浸式状态栏 + implementation 'com.geyifeng.immersionbar:immersionbar:3.2.2' //官方Json解析库 implementation 'com.google.code.gson:gson:2.10.1' - def vm_version = '2.5.1' //Kotlin协程 - implementation "androidx.lifecycle:lifecycle-runtime-ktx:${vm_version}" + implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.2' //MVVM+LiveData - implementation "androidx.lifecycle:lifecycle-livedata-ktx:${vm_version}" - implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:${vm_version}" - implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.6.2' + implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2' + implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' //返回值转换器 implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' @@ -105,9 +92,10 @@ implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' //网络请求和接口封装 implementation 'com.squareup.retrofit2:retrofit:2.9.0' - implementation 'com.squareup.okhttp3:okhttp:4.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.12.0' //数据库框架 - implementation 'org.greenrobot:greendao:3.3.0' + implementation 'androidx.room:room-runtime:2.6.1' + annotationProcessor 'androidx.room:room-compiler:2.5.2' //高德导航、定位、地图三合一 implementation 'com.amap.api:navi-3dmap:latest.integration' //经纬度逆编码 @@ -115,7 +103,7 @@ //excel implementation 'net.sourceforge.jexcelapi:jxl:2.6.12' //图片加载框架 - implementation 'com.github.bumptech.glide:glide:4.9.0' + implementation 'com.github.bumptech.glide:glide:4.12.0' //图片选择框架 implementation 'io.github.lucksiege:pictureselector:v3.11.1' //大图 diff --git a/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt b/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt index 7b695ff..50ba734 100644 --- a/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt +++ b/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt @@ -4,9 +4,9 @@ import android.app.Application import android.os.Bundle import android.util.Log -import com.casic.common.detector.gd.greendao.DaoMaster -import com.casic.common.detector.gd.greendao.DaoSession +import androidx.room.Room.databaseBuilder import com.casic.common.detector.gd.uart.SerialPort +import com.casic.common.detector.gd.utils.DetectorDataBase import com.casic.common.detector.gd.utils.GpioManager import com.pengxh.kt.lite.extensions.show import com.pengxh.kt.lite.utils.SaveKeyValues @@ -43,44 +43,42 @@ private var application: BaseApplication by Delegates.notNull() fun get() = application - - private lateinit var daoSession: DaoSession } + lateinit var dataBase: DetectorDataBase + override fun onCreate() { super.onCreate() application = this SaveKeyValues.initSharedPreferences(this) CrashReport.initCrashReport(this, "01e80d3a74", true) - val devOpenHelper = DaoMaster.DevOpenHelper(this, "Detector.db", null) - val daoMaster = DaoMaster(devOpenHelper.writableDatabase) - daoSession = daoMaster.newSession() + dataBase = databaseBuilder(this, DetectorDataBase::class.java, "Detector.db") + .allowMainThreadQueries() + .build() /** * Open the serial port * */ try { serialPorts.apply { - add(SerialPort(File("/dev/ttysWK1"), 9600, 0)) - //千寻报文数据下发串口号 - add(SerialPort(File("/dev/ttyS1"), 9600, 0)) + add(SerialPort(File("/dev/ttysWK1"), 9600, 0)) //信号通讯串口 + add(SerialPort(File("/dev/ttyS1"), 9600, 0)) //千寻报文数据下发串口号 } Log.d(kTag, "onCreate: 已初始化 ${serialPorts.size} 个串口") } catch (e: SecurityException) { "您没有串口的读写权限!".show(this) + e.printStackTrace() } catch (e: IOException) { "因为不明原因,串口无法打开!".show(this) + e.printStackTrace() } catch (e: InvalidParameterException) { "请检查串口!".show(this) + e.printStackTrace() } registerActivityLifecycleCallbacks(this) } - fun getDaoSession(): DaoSession { - return daoSession - } - override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) { } diff --git a/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt b/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt index 053b9dd..1d0c9e3 100644 --- a/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt +++ b/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt @@ -14,12 +14,10 @@ import com.casic.common.detector.gd.utils.SerialPortCommand import com.pengxh.kt.lite.utils.WeakReferenceHandler import java.io.IOException -import java.util.Timer abstract class SerialPortBaseActivity : AppCompatActivity(), Handler.Callback { private val kTag = "SerialPortBaseActivity" - private val taskTimer by lazy { Timer() } private val weakReferenceHandler by lazy { WeakReferenceHandler(this) } private val serialPorts by lazy { BaseApplication.get().getSerialPorts() } protected lateinit var binding: VB @@ -30,7 +28,6 @@ setContentView(binding.root) setupTopBarLayout() initOnCreate(savedInstanceState) - observeRequestState() initEvent() if (serialPorts.isNotEmpty()) { @@ -71,11 +68,6 @@ abstract fun initOnCreate(savedInstanceState: Bundle?) /** - * 数据请求状态监听 - */ - abstract fun observeRequestState() - - /** * 初始化业务逻辑 */ abstract fun initEvent() diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java new file mode 100644 index 0000000..7a18c20 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java @@ -0,0 +1,255 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 从平台下载的标识器本地库实体类 + */ +@Entity(tableName = "marker_detail") +public class MarkerBean { + @PrimaryKey(autoGenerate = true) + private long id; //主键ID + private String pipelineType; // 管线类型 + private String pipelineDiameter; // 管线直径 + private String pipelineMaterial; // 管材 + private String buryMethod; // 埋设方式 + private String buryDepth; // 埋深 + private String area; // 所属区域 + private String line; // 所属线路 + private String road; // 所属道路 + private String constructTime; // 建设年代 + private String owner; // 权属单位 + private String objectId; // 标识对象ID,无实际用途 + private String markerId; // 标识器ID + private String markerType; // 标识器类型 + private String markerDepth; // 标识器埋深 + private String installationDept; // 安装部门 + private String lng; // 经度 + private String lat; // 纬度 + private String updateTime; // 最后修改时间,更新时间 + private String remark; // 备注信息 + private String underlyingPipelineType; // 下层管线类型 + private String underlyingPipelineDepth; // 下层埋深 + private String underlyingPipelineDiameter; // 下层管径 + private String underlyingPipelineMaterial; // 下层管材 + private String objectType; //标识对象类型 + private String color; // 颜色 + private String imagePath; // 图片路径 + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getPipelineType() { + return pipelineType; + } + + public void setPipelineType(String pipelineType) { + this.pipelineType = pipelineType; + } + + public String getPipelineDiameter() { + return pipelineDiameter; + } + + public void setPipelineDiameter(String pipelineDiameter) { + this.pipelineDiameter = pipelineDiameter; + } + + public String getPipelineMaterial() { + return pipelineMaterial; + } + + public void setPipelineMaterial(String pipelineMaterial) { + this.pipelineMaterial = pipelineMaterial; + } + + public String getBuryMethod() { + return buryMethod; + } + + public void setBuryMethod(String buryMethod) { + this.buryMethod = buryMethod; + } + + public String getBuryDepth() { + return buryDepth; + } + + public void setBuryDepth(String buryDepth) { + this.buryDepth = buryDepth; + } + + public String getArea() { + return area; + } + + public void setArea(String area) { + this.area = area; + } + + public String getLine() { + return line; + } + + public void setLine(String line) { + this.line = line; + } + + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + + public String getConstructTime() { + return constructTime; + } + + public void setConstructTime(String constructTime) { + this.constructTime = constructTime; + } + + public String getOwner() { + return owner; + } + + public void setOwner(String owner) { + this.owner = owner; + } + + public String getObjectId() { + return objectId; + } + + public void setObjectId(String objectId) { + this.objectId = objectId; + } + + public String getMarkerId() { + return markerId; + } + + public void setMarkerId(String markerId) { + this.markerId = markerId; + } + + public String getMarkerType() { + return markerType; + } + + public void setMarkerType(String markerType) { + this.markerType = markerType; + } + + public String getMarkerDepth() { + return markerDepth; + } + + public void setMarkerDepth(String markerDepth) { + this.markerDepth = markerDepth; + } + + public String getInstallationDept() { + return installationDept; + } + + public void setInstallationDept(String installationDept) { + this.installationDept = installationDept; + } + + public String getLng() { + return lng; + } + + public void setLng(String lng) { + this.lng = lng; + } + + public String getLat() { + return lat; + } + + public void setLat(String lat) { + this.lat = lat; + } + + public String getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } + + public String getUnderlyingPipelineType() { + return underlyingPipelineType; + } + + public void setUnderlyingPipelineType(String underlyingPipelineType) { + this.underlyingPipelineType = underlyingPipelineType; + } + + public String getUnderlyingPipelineDepth() { + return underlyingPipelineDepth; + } + + public void setUnderlyingPipelineDepth(String underlyingPipelineDepth) { + this.underlyingPipelineDepth = underlyingPipelineDepth; + } + + public String getUnderlyingPipelineDiameter() { + return underlyingPipelineDiameter; + } + + public void setUnderlyingPipelineDiameter(String underlyingPipelineDiameter) { + this.underlyingPipelineDiameter = underlyingPipelineDiameter; + } + + public String getUnderlyingPipelineMaterial() { + return underlyingPipelineMaterial; + } + + public void setUnderlyingPipelineMaterial(String underlyingPipelineMaterial) { + this.underlyingPipelineMaterial = underlyingPipelineMaterial; + } + + public String getObjectType() { + return objectType; + } + + public void setObjectType(String objectType) { + this.objectType = objectType; + } + + public String getColor() { + return color; + } + + public void setColor(String color) { + this.color = color; + } + + public String getImagePath() { + return imagePath; + } + + public void setImagePath(String imagePath) { + this.imagePath = imagePath; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java deleted file mode 100644 index 3f2fcdc..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java +++ /dev/null @@ -1,327 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 从平台下载的标识器本地库实体类 - */ -@Entity -public class MarkerLocalBean { - @Id(autoincrement = true) - private Long id;//本地库主键ID - - // 管线类型 - private String pipelineType; - // 管线直径 - private String pipelineDiameter; - // 管材 - private String pipelineMaterial; - // 埋设方式 - private String buryMethod; - // 埋深 - private String buryDepth; - // 所属区域 - private String area; - // 所属线路 - private String line; - // 所属道路 - private String road; - // 建设年代 - private String constructTime; - // 权属单位 - private String owner; - //标识对象ID,无实际用途 - @Deprecated - private String objectId; - // 标识器ID - private String markerId; - // 标识器类型 - private String markerType; - // 标识器埋深 - private String markerDepth; - // 安装部门 - private String installationDept; - // 经度 - private String lng; - // 纬度 - private String lat; - //最后修改时间,更新时间 - private String updateTime; - // 备注信息 - private String remark; - // 下层管线类型 - private String underlyingPipelineType; - // 下层埋深 - private String underlyingPipelineDepth; - // 下层管径 - private String underlyingPipelineDiameter; - // 下层管材 - private String underlyingPipelineMaterial; - //标识对象类型 - private String objectType; - // 颜色 - private String color; - // 图片路径 - private String imagePath; - - @Generated(hash = 1479045776) - public MarkerLocalBean(Long id, String pipelineType, String pipelineDiameter, - String pipelineMaterial, String buryMethod, String buryDepth, - String area, String line, String road, String constructTime, - String owner, String objectId, String markerId, String markerType, - String markerDepth, String installationDept, String lng, String lat, - String updateTime, String remark, String underlyingPipelineType, - String underlyingPipelineDepth, String underlyingPipelineDiameter, - String underlyingPipelineMaterial, String objectType, String color, - String imagePath) { - this.id = id; - this.pipelineType = pipelineType; - this.pipelineDiameter = pipelineDiameter; - this.pipelineMaterial = pipelineMaterial; - this.buryMethod = buryMethod; - this.buryDepth = buryDepth; - this.area = area; - this.line = line; - this.road = road; - this.constructTime = constructTime; - this.owner = owner; - this.objectId = objectId; - this.markerId = markerId; - this.markerType = markerType; - this.markerDepth = markerDepth; - this.installationDept = installationDept; - this.lng = lng; - this.lat = lat; - this.updateTime = updateTime; - this.remark = remark; - this.underlyingPipelineType = underlyingPipelineType; - this.underlyingPipelineDepth = underlyingPipelineDepth; - this.underlyingPipelineDiameter = underlyingPipelineDiameter; - this.underlyingPipelineMaterial = underlyingPipelineMaterial; - this.objectType = objectType; - this.color = color; - this.imagePath = imagePath; - } - - @Generated(hash = 1538606012) - public MarkerLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getPipelineType() { - return this.pipelineType; - } - - public void setPipelineType(String pipelineType) { - this.pipelineType = pipelineType; - } - - public String getPipelineDiameter() { - return this.pipelineDiameter; - } - - public void setPipelineDiameter(String pipelineDiameter) { - this.pipelineDiameter = pipelineDiameter; - } - - public String getPipelineMaterial() { - return this.pipelineMaterial; - } - - public void setPipelineMaterial(String pipelineMaterial) { - this.pipelineMaterial = pipelineMaterial; - } - - public String getBuryMethod() { - return this.buryMethod; - } - - public void setBuryMethod(String buryMethod) { - this.buryMethod = buryMethod; - } - - public String getBuryDepth() { - return this.buryDepth; - } - - public void setBuryDepth(String buryDepth) { - this.buryDepth = buryDepth; - } - - public String getArea() { - return this.area; - } - - public void setArea(String area) { - this.area = area; - } - - public String getLine() { - return this.line; - } - - public void setLine(String line) { - this.line = line; - } - - public String getRoad() { - return this.road; - } - - public void setRoad(String road) { - this.road = road; - } - - public String getConstructTime() { - return this.constructTime; - } - - public void setConstructTime(String constructTime) { - this.constructTime = constructTime; - } - - public String getOwner() { - return this.owner; - } - - public void setOwner(String owner) { - this.owner = owner; - } - - public String getObjectId() { - return this.objectId; - } - - public void setObjectId(String objectId) { - this.objectId = objectId; - } - - public String getMarkerId() { - return this.markerId; - } - - public void setMarkerId(String markerId) { - this.markerId = markerId; - } - - public String getMarkerType() { - return this.markerType; - } - - public void setMarkerType(String markerType) { - this.markerType = markerType; - } - - public String getMarkerDepth() { - return this.markerDepth; - } - - public void setMarkerDepth(String markerDepth) { - this.markerDepth = markerDepth; - } - - public String getInstallationDept() { - return this.installationDept; - } - - public void setInstallationDept(String installationDept) { - this.installationDept = installationDept; - } - - public String getLng() { - return this.lng; - } - - public void setLng(String lng) { - this.lng = lng; - } - - public String getLat() { - return this.lat; - } - - public void setLat(String lat) { - this.lat = lat; - } - - public String getUpdateTime() { - return this.updateTime; - } - - public void setUpdateTime(String updateTime) { - this.updateTime = updateTime; - } - - public String getRemark() { - return this.remark; - } - - public void setRemark(String remark) { - this.remark = remark; - } - - public String getUnderlyingPipelineType() { - return this.underlyingPipelineType; - } - - public void setUnderlyingPipelineType(String underlyingPipelineType) { - this.underlyingPipelineType = underlyingPipelineType; - } - - public String getUnderlyingPipelineDepth() { - return this.underlyingPipelineDepth; - } - - public void setUnderlyingPipelineDepth(String underlyingPipelineDepth) { - this.underlyingPipelineDepth = underlyingPipelineDepth; - } - - public String getUnderlyingPipelineDiameter() { - return this.underlyingPipelineDiameter; - } - - public void setUnderlyingPipelineDiameter(String underlyingPipelineDiameter) { - this.underlyingPipelineDiameter = underlyingPipelineDiameter; - } - - public String getUnderlyingPipelineMaterial() { - return this.underlyingPipelineMaterial; - } - - public void setUnderlyingPipelineMaterial(String underlyingPipelineMaterial) { - this.underlyingPipelineMaterial = underlyingPipelineMaterial; - } - - public String getObjectType() { - return this.objectType; - } - - public void setObjectType(String objectType) { - this.objectType = objectType; - } - - public String getColor() { - return this.color; - } - - public void setColor(String color) { - this.color = color; - } - - public String getImagePath() { - return this.imagePath; - } - - public void setImagePath(String imagePath) { - this.imagePath = imagePath; - } -} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java new file mode 100644 index 0000000..5c88fdf --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java @@ -0,0 +1,93 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 巡检任务本地库实体类,不包含任务里面需要巡检的标识器信息 + */ +@Entity(tableName = "task_detail") +public class TaskBean { + @PrimaryKey(autoGenerate = true) + private long id;//主键ID + private String taskCode; // 任务编号 + private String description; // 任务名称 + private String createTime; // 任务创建的时间 + private String status; // 任务状态 + private String createUserName; // 任务创建者名称 + private String startTime; // 任务被开始执行的时间 + private String endTime; // 任务执行结束的时间 + private String isFree; // 是否自由巡检。1-是,0-否 + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getTaskCode() { + return taskCode; + } + + public void setTaskCode(String taskCode) { + this.taskCode = taskCode; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getCreateUserName() { + return createUserName; + } + + public void setCreateUserName(String createUserName) { + this.createUserName = createUserName; + } + + public String getStartTime() { + return startTime; + } + + public void setStartTime(String startTime) { + this.startTime = startTime; + } + + public String getEndTime() { + return endTime; + } + + public void setEndTime(String endTime) { + this.endTime = endTime; + } + + public String getIsFree() { + return isFree; + } + + public void setIsFree(String isFree) { + this.isFree = isFree; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java deleted file mode 100644 index 91737b3..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java +++ /dev/null @@ -1,114 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 巡检任务本地库实体类,不包含任务里面需要巡检的标识器信息 - */ -@Entity -public class TaskLocalBean { - @Id - private Long id;//任务ID - - private String taskCode;//任务编号 - private String description;//任务名称 - private String createTime;//任务创建的时间 - private String status;//任务状态 - private String createUserName;//任务创建者名称 - private String startTime;//任务被开始执行的时间 - private String endTime;//任务执行结束的时间 - private String isFreeTask;//是否自由巡检。1-是,0-否 - - @Generated(hash = 1482022528) - public TaskLocalBean(Long id, String taskCode, String description, - String createTime, String status, String createUserName, - String startTime, String endTime, String isFreeTask) { - this.id = id; - this.taskCode = taskCode; - this.description = description; - this.createTime = createTime; - this.status = status; - this.createUserName = createUserName; - this.startTime = startTime; - this.endTime = endTime; - this.isFreeTask = isFreeTask; - } - - @Generated(hash = 949704588) - public TaskLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getTaskCode() { - return this.taskCode; - } - - public void setTaskCode(String taskCode) { - this.taskCode = taskCode; - } - - public String getDescription() { - return this.description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getCreateTime() { - return this.createTime; - } - - public void setCreateTime(String createTime) { - this.createTime = createTime; - } - - public String getStatus() { - return this.status; - } - - public void setStatus(String status) { - this.status = status; - } - - public String getCreateUserName() { - return this.createUserName; - } - - public void setCreateUserName(String createUserName) { - this.createUserName = createUserName; - } - - public String getStartTime() { - return this.startTime; - } - - public void setStartTime(String startTime) { - this.startTime = startTime; - } - - public String getEndTime() { - return this.endTime; - } - - public void setEndTime(String endTime) { - this.endTime = endTime; - } - - public String getIsFreeTask() { - return this.isFreeTask; - } - - public void setIsFreeTask(String isFreeTask) { - this.isFreeTask = isFreeTask; - } -} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerBean.java new file mode 100644 index 0000000..c563a60 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerBean.java @@ -0,0 +1,110 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 巡检任务里面需要巡检的标识器信息本地库实体类 + */ +@Entity(tableName = "task_marker_info") +public class TaskMarkerBean { + //标识器后台库的主键ID,不是标识器实际ID + @PrimaryKey(autoGenerate = true) + private long id; + + /** + * 任务ID,通过此字段关联[TaskBean.id] + */ + private String taskId; + + /** + * 任务Code,通过此字段关联[TaskBean.taskCode] + *

+ *

+ * 双重验证,防止出现同时刻重复的情况 + */ + private String taskCode; + + /** + * 对应后台字段[TaskModel.MessageModel.TaskDetailInfosModel.markerIdReal],也就是探测仪扫描出来的ID + */ + private String markerId; + + private Double lng; + private Double lat; + + /** + * 是否已被探测到 + * 1-是,0-否 + */ + private String isDetected; + + /** + * 被探测到的时间,对应后台字段[TaskModel.MessageModel.TaskDetailInfosModel.finishTime] + */ + private String detectedTime; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getTaskId() { + return taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getTaskCode() { + return taskCode; + } + + public void setTaskCode(String taskCode) { + this.taskCode = taskCode; + } + + public String getMarkerId() { + return markerId; + } + + public void setMarkerId(String markerId) { + this.markerId = markerId; + } + + public Double getLng() { + return lng; + } + + public void setLng(Double lng) { + this.lng = lng; + } + + public Double getLat() { + return lat; + } + + public void setLat(Double lat) { + this.lat = lat; + } + + public String getIsDetected() { + return isDetected; + } + + public void setIsDetected(String isDetected) { + this.isDetected = isDetected; + } + + public String getDetectedTime() { + return detectedTime; + } + + public void setDetectedTime(String detectedTime) { + this.detectedTime = detectedTime; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerLocalBean.java deleted file mode 100644 index de9f459..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerLocalBean.java +++ /dev/null @@ -1,128 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import com.casic.common.detector.gd.model.TaskModel; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 巡检任务里面需要巡检的标识器信息本地库实体类 - */ -@Entity -public class TaskMarkerLocalBean { - @Id - private Long id;//标识器后台库的主键ID,不是标识器实际ID - - /** - * 任务ID,通过此字段关联{@link TaskLocalBean#id} - */ - private String taskId; - - /** - * 任务Code,通过此字段关联{@link TaskLocalBean#taskCode} - *

- * 双重验证,防止出现同时刻重复的情况 - */ - private String taskCode; - - /** - * 对应后台字段{@link TaskModel.MessageModel.TaskDetailInfosModel#markerIdReal},也就是探测仪扫描出来的ID - */ - private String markerId; - - private double lng; - private double lat; - - /** - * 是否已被探测到 - * 1-是,0-否 - */ - private String isDetected; - - /** - * 被探测到的时间,对应后台字段{@link TaskModel.MessageModel.TaskDetailInfosModel#finishTime} - */ - private String detectedTime; - - @Generated(hash = 677328533) - public TaskMarkerLocalBean(Long id, String taskId, String taskCode, String markerId, - double lng, double lat, String isDetected, String detectedTime) { - this.id = id; - this.taskId = taskId; - this.taskCode = taskCode; - this.markerId = markerId; - this.lng = lng; - this.lat = lat; - this.isDetected = isDetected; - this.detectedTime = detectedTime; - } - - @Generated(hash = 1162404642) - public TaskMarkerLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getTaskId() { - return this.taskId; - } - - public void setTaskId(String taskId) { - this.taskId = taskId; - } - - public String getTaskCode() { - return this.taskCode; - } - - public void setTaskCode(String taskCode) { - this.taskCode = taskCode; - } - - public String getMarkerId() { - return this.markerId; - } - - public void setMarkerId(String markerId) { - this.markerId = markerId; - } - - public double getLng() { - return this.lng; - } - - public void setLng(double lng) { - this.lng = lng; - } - - public double getLat() { - return this.lat; - } - - public void setLat(double lat) { - this.lat = lat; - } - - public String getIsDetected() { - return this.isDetected; - } - - public void setIsDetected(String isDetected) { - this.isDetected = isDetected; - } - - public String getDetectedTime() { - return this.detectedTime; - } - - public void setDetectedTime(String detectedTime) { - this.detectedTime = detectedTime; - } -} diff --git a/app/src/main/java/com/casic/common/detector/gd/dao/MarkerBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/dao/MarkerBeanDao.java new file mode 100644 index 0000000..2beb7ed --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/dao/MarkerBeanDao.java @@ -0,0 +1,29 @@ +package com.casic.common.detector.gd.dao; + +import androidx.room.Dao; +import androidx.room.Insert; +import androidx.room.Query; +import androidx.room.RawQuery; +import androidx.sqlite.db.SupportSQLiteQuery; + +import com.casic.common.detector.gd.bean.MarkerBean; + +import java.util.List; + +@Dao +public interface MarkerBeanDao { + @Query("DELETE FROM marker_detail") + void deleteAll(); + + @Insert + void insert(MarkerBean marker); + + @Query("SELECT * FROM marker_detail") + List loadAll(); + + @Query("SELECT * FROM marker_detail WHERE markerId = :markerId") + List queryMarkerById(String markerId); + + @RawQuery + List loadMarkersByCondition(SupportSQLiteQuery query); +} diff --git a/app/src/main/java/com/casic/common/detector/gd/dao/TaskBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/dao/TaskBeanDao.java new file mode 100644 index 0000000..9c70ac2 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/dao/TaskBeanDao.java @@ -0,0 +1,120 @@ +package com.casic.common.detector.gd.dao; + +import androidx.room.Dao; +import androidx.room.Insert; +import androidx.room.Query; +import androidx.room.Transaction; + +import com.casic.common.detector.gd.bean.TaskBean; +import com.casic.common.detector.gd.bean.TaskMarkerBean; +import com.casic.common.detector.gd.model.TaskDetailLocalModel; +import com.casic.common.detector.gd.model.TaskModel; +import com.casic.common.detector.gd.utils.LocaleConstant; +import com.pengxh.kt.lite.utils.SaveKeyValues; + +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Locale; + +@Dao +public interface TaskBeanDao { + @Query("SELECT COUNT(*) FROM task_detail WHERE id = :taskId") + int isTaskExist(long taskId); + + @Insert + void insert(TaskBean task); + + default void saveTask(Long taskId, String taskName) { + if (isTaskExist(taskId) == 0) { + TaskBean task = new TaskBean(); + task.setId(taskId); + task.setTaskCode(new SimpleDateFormat("yyyyMMddHHmmss", Locale.CHINA).format(new Date())); + task.setDescription(taskName); + String time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA).format(new Date()); + task.setCreateTime(time); + task.setStatus("0"); + String userName = (String) SaveKeyValues.INSTANCE.getValue(LocaleConstant.USER_NAME, ""); + task.setCreateUserName(userName); + task.setStartTime(time); + task.setEndTime(""); + task.setIsFree("1"); + insert(task); + } + } + + default void saveTask(TaskModel.MessageModel model) { + TaskBean task = new TaskBean(); + task.setId(model.getId()); + task.setTaskCode(model.getTaskCode()); + task.setDescription(model.getDescription()); + task.setCreateTime(model.getDeployDate()); + task.setStatus(model.getStatus()); + task.setCreateUserName(model.getCreatorName()); + task.setStartTime(model.getBeginDate()); + task.setEndTime(model.getEndDate()); + task.setIsFree("0"); + if (isTaskExist(task.getId()) == 0) { + insert(task); + } + } + + @Query("SELECT * FROM task_detail") + List loadAll(); + + @Transaction + default ArrayList loadLocalTask(TaskMarkerBeanDao taskMarkerBeanDao) { + ArrayList result = new ArrayList<>(); + List tasks = loadAll(); + for (TaskBean it : tasks) { + TaskDetailLocalModel model = new TaskDetailLocalModel(); + model.setTaskId(String.valueOf(it.getId())); + model.setTaskCode(it.getTaskCode()); + model.setDescription(it.getDescription()); + model.setCreateTime(it.getCreateTime()); + model.setStatus(it.getStatus()); + model.setCreateUserName(it.getCreateUserName()); + model.setIsFreeTask(it.getIsFree()); + ArrayList results = new ArrayList<>(); + if ("0".equals(it.getIsFree())) { + // 非自由巡检才有Marker + List markers = taskMarkerBeanDao.getMarkersByIdAndCode(String.valueOf(it.getId()), it.getTaskCode()); + for (TaskMarkerBean marker : markers) { + TaskDetailLocalModel.TaskMarkerLocalModel localModel = new TaskDetailLocalModel.TaskMarkerLocalModel(); + localModel.setMarkerId(marker.getMarkerId()); + localModel.setLng(marker.getLng()); + localModel.setLat(marker.getLat()); + localModel.setIsDetected(marker.getIsDetected()); + localModel.setDetectedTime(marker.getDetectedTime()); + + results.add(localModel); + } + } + model.setMarkerModels(results); + result.add(model); + } + return result; + } + + @Query("DELETE FROM task_detail WHERE id = :taskId AND taskCode = :taskCode") + void deleteTaskById(long taskId, String taskCode); + + @Transaction + default void deleteLocalTaskById(long taskId, String taskCode, TaskMarkerBeanDao taskMarkerBeanDao) { + TaskBean task = loadAll().stream() + .filter(it -> it.getId() == taskId && taskCode.equals(it.getTaskCode())) + .findFirst() + .orElse(null); + if (task == null) return; + deleteTaskById(taskId, taskCode); + + // 删除此任务关联的Marker。非自由巡检才有Marker + if ("0".equals(task.getIsFree())) { + List markers = taskMarkerBeanDao.getMarkersByIdAndCode(String.valueOf(task.getId()), task.getTaskCode()); + for (TaskMarkerBean marker : markers) { + taskMarkerBeanDao.delete(marker); + } + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/dao/TaskMarkerBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/dao/TaskMarkerBeanDao.java new file mode 100644 index 0000000..cc2156a --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/dao/TaskMarkerBeanDao.java @@ -0,0 +1,52 @@ +package com.casic.common.detector.gd.dao; + +import androidx.room.Dao; +import androidx.room.Delete; +import androidx.room.Insert; +import androidx.room.Query; +import androidx.room.Update; + +import com.casic.common.detector.gd.bean.TaskMarkerBean; +import com.casic.common.detector.gd.model.TaskModel; + +import java.util.List; + +@Dao +public interface TaskMarkerBeanDao { + + @Insert + void insert(TaskMarkerBean marker); + + @Query("SELECT COUNT(*) FROM task_marker_info WHERE id = :markerId") + int isMarkerExist(String markerId); + + default void saveTaskMarker(long taskId, String taskCode, TaskModel.MessageModel.TaskDetailInfosModel marker) { + if (isMarkerExist(marker.getMarkerId()) == 0) { + TaskMarkerBean bean = new TaskMarkerBean(); + bean.setId(marker.getId()); + bean.setTaskId(String.valueOf(taskId)); + bean.setTaskCode(taskCode); + bean.setMarkerId(marker.getMarkerIdReal()); + bean.setLng(marker.getLongitude()); + bean.setLat(marker.getLatitude()); + bean.setIsDetected("0"); + bean.setDetectedTime(""); + insert(bean); + } + } + + @Query("SELECT * FROM task_marker_info WHERE taskId = :taskId AND taskCode = :taskCode AND markerId = :markerId AND isDetected = :state") + TaskMarkerBean queryTaskMarkerById(String taskId, String taskCode, String markerId, String state); + + @Update + void updateLocalTaskMarkerState(TaskMarkerBean marker); + + @Query("SELECT * FROM task_marker_info WHERE isDetected = :state") + List queryMarkerByState(String state); + + @Query("SELECT * FROM task_marker_info WHERE taskId = :taskId AND taskCode = :taskCode") + List getMarkersByIdAndCode(String taskId, String taskCode); + + @Delete + void delete(TaskMarkerBean marker); +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/extensions/Long.kt b/app/src/main/java/com/casic/common/detector/gd/extensions/Long.kt deleted file mode 100644 index 6713d8d..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/extensions/Long.kt +++ /dev/null @@ -1,10 +0,0 @@ -package com.casic.common.detector.gd.extensions - -import java.text.SimpleDateFormat -import java.util.Date -import java.util.Locale - -fun Long.createTaskCode(): String { - val dateFormat = SimpleDateFormat("yyyyMMddHHmmss", Locale.CHINA) - return dateFormat.format(Date(this)) -} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoMaster.java b/app/src/main/java/com/casic/common/detector/gd/greendao/DaoMaster.java deleted file mode 100644 index 6ab94b3..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoMaster.java +++ /dev/null @@ -1,102 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import android.content.Context; -import android.database.sqlite.SQLiteDatabase; -import android.database.sqlite.SQLiteDatabase.CursorFactory; -import android.util.Log; - -import org.greenrobot.greendao.AbstractDaoMaster; -import org.greenrobot.greendao.database.StandardDatabase; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.database.DatabaseOpenHelper; -import org.greenrobot.greendao.identityscope.IdentityScopeType; - - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** - * Master of DAO (schema version 1): knows all DAOs. - */ -public class DaoMaster extends AbstractDaoMaster { - public static final int SCHEMA_VERSION = 1; - - /** Creates underlying database table using DAOs. */ - public static void createAllTables(Database db, boolean ifNotExists) { - MarkerLocalBeanDao.createTable(db, ifNotExists); - TaskLocalBeanDao.createTable(db, ifNotExists); - TaskMarkerLocalBeanDao.createTable(db, ifNotExists); - } - - /** Drops underlying database table using DAOs. */ - public static void dropAllTables(Database db, boolean ifExists) { - MarkerLocalBeanDao.dropTable(db, ifExists); - TaskLocalBeanDao.dropTable(db, ifExists); - TaskMarkerLocalBeanDao.dropTable(db, ifExists); - } - - /** - * WARNING: Drops all table on Upgrade! Use only during development. - * Convenience method using a {@link DevOpenHelper}. - */ - public static DaoSession newDevSession(Context context, String name) { - Database db = new DevOpenHelper(context, name).getWritableDb(); - DaoMaster daoMaster = new DaoMaster(db); - return daoMaster.newSession(); - } - - public DaoMaster(SQLiteDatabase db) { - this(new StandardDatabase(db)); - } - - public DaoMaster(Database db) { - super(db, SCHEMA_VERSION); - registerDaoClass(MarkerLocalBeanDao.class); - registerDaoClass(TaskLocalBeanDao.class); - registerDaoClass(TaskMarkerLocalBeanDao.class); - } - - public DaoSession newSession() { - return new DaoSession(db, IdentityScopeType.Session, daoConfigMap); - } - - public DaoSession newSession(IdentityScopeType type) { - return new DaoSession(db, type, daoConfigMap); - } - - /** - * Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} - - */ - public static abstract class OpenHelper extends DatabaseOpenHelper { - public OpenHelper(Context context, String name) { - super(context, name, SCHEMA_VERSION); - } - - public OpenHelper(Context context, String name, CursorFactory factory) { - super(context, name, factory, SCHEMA_VERSION); - } - - @Override - public void onCreate(Database db) { - Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION); - createAllTables(db, false); - } - } - - /** WARNING: Drops all table on Upgrade! Use only during development. */ - public static class DevOpenHelper extends OpenHelper { - public DevOpenHelper(Context context, String name) { - super(context, name); - } - - public DevOpenHelper(Context context, String name, CursorFactory factory) { - super(context, name, factory); - } - - @Override - public void onUpgrade(Database db, int oldVersion, int newVersion) { - Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables"); - dropAllTables(db, true); - onCreate(db); - } - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoSession.java b/app/src/main/java/com/casic/common/detector/gd/greendao/DaoSession.java deleted file mode 100644 index c8b1a20..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoSession.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import java.util.Map; - -import org.greenrobot.greendao.AbstractDao; -import org.greenrobot.greendao.AbstractDaoSession; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.identityscope.IdentityScopeType; -import org.greenrobot.greendao.internal.DaoConfig; - -import com.casic.common.detector.gd.bean.MarkerLocalBean; -import com.casic.common.detector.gd.bean.TaskLocalBean; -import com.casic.common.detector.gd.bean.TaskMarkerLocalBean; - -import com.casic.common.detector.gd.greendao.MarkerLocalBeanDao; -import com.casic.common.detector.gd.greendao.TaskLocalBeanDao; -import com.casic.common.detector.gd.greendao.TaskMarkerLocalBeanDao; - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. - -/** - * {@inheritDoc} - * - * @see org.greenrobot.greendao.AbstractDaoSession - */ -public class DaoSession extends AbstractDaoSession { - - private final DaoConfig markerLocalBeanDaoConfig; - private final DaoConfig taskLocalBeanDaoConfig; - private final DaoConfig taskMarkerLocalBeanDaoConfig; - - private final MarkerLocalBeanDao markerLocalBeanDao; - private final TaskLocalBeanDao taskLocalBeanDao; - private final TaskMarkerLocalBeanDao taskMarkerLocalBeanDao; - - public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> - daoConfigMap) { - super(db); - - markerLocalBeanDaoConfig = daoConfigMap.get(MarkerLocalBeanDao.class).clone(); - markerLocalBeanDaoConfig.initIdentityScope(type); - - taskLocalBeanDaoConfig = daoConfigMap.get(TaskLocalBeanDao.class).clone(); - taskLocalBeanDaoConfig.initIdentityScope(type); - - taskMarkerLocalBeanDaoConfig = daoConfigMap.get(TaskMarkerLocalBeanDao.class).clone(); - taskMarkerLocalBeanDaoConfig.initIdentityScope(type); - - markerLocalBeanDao = new MarkerLocalBeanDao(markerLocalBeanDaoConfig, this); - taskLocalBeanDao = new TaskLocalBeanDao(taskLocalBeanDaoConfig, this); - taskMarkerLocalBeanDao = new TaskMarkerLocalBeanDao(taskMarkerLocalBeanDaoConfig, this); - - registerDao(MarkerLocalBean.class, markerLocalBeanDao); - registerDao(TaskLocalBean.class, taskLocalBeanDao); - registerDao(TaskMarkerLocalBean.class, taskMarkerLocalBeanDao); - } - - public void clear() { - markerLocalBeanDaoConfig.clearIdentityScope(); - taskLocalBeanDaoConfig.clearIdentityScope(); - taskMarkerLocalBeanDaoConfig.clearIdentityScope(); - } - - public MarkerLocalBeanDao getMarkerLocalBeanDao() { - return markerLocalBeanDao; - } - - public TaskLocalBeanDao getTaskLocalBeanDao() { - return taskLocalBeanDao; - } - - public TaskMarkerLocalBeanDao getTaskMarkerLocalBeanDao() { - return taskMarkerLocalBeanDao; - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/MarkerLocalBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/greendao/MarkerLocalBeanDao.java deleted file mode 100644 index 2f792c3..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/MarkerLocalBeanDao.java +++ /dev/null @@ -1,479 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import android.database.Cursor; -import android.database.sqlite.SQLiteStatement; - -import org.greenrobot.greendao.AbstractDao; -import org.greenrobot.greendao.Property; -import org.greenrobot.greendao.internal.DaoConfig; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.database.DatabaseStatement; - -import com.casic.common.detector.gd.bean.MarkerLocalBean; - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** - * DAO for table "MARKER_LOCAL_BEAN". -*/ -public class MarkerLocalBeanDao extends AbstractDao { - - public static final String TABLENAME = "MARKER_LOCAL_BEAN"; - - /** - * Properties of entity MarkerLocalBean.
- * Can be used for QueryBuilder and for referencing column names. - */ - public static class Properties { - public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property PipelineType = new Property(1, String.class, "pipelineType", false, "PIPELINE_TYPE"); - public final static Property PipelineDiameter = new Property(2, String.class, "pipelineDiameter", false, "PIPELINE_DIAMETER"); - public final static Property PipelineMaterial = new Property(3, String.class, "pipelineMaterial", false, "PIPELINE_MATERIAL"); - public final static Property BuryMethod = new Property(4, String.class, "buryMethod", false, "BURY_METHOD"); - public final static Property BuryDepth = new Property(5, String.class, "buryDepth", false, "BURY_DEPTH"); - public final static Property Area = new Property(6, String.class, "area", false, "AREA"); - public final static Property Line = new Property(7, String.class, "line", false, "LINE"); - public final static Property Road = new Property(8, String.class, "road", false, "ROAD"); - public final static Property ConstructTime = new Property(9, String.class, "constructTime", false, "CONSTRUCT_TIME"); - public final static Property Owner = new Property(10, String.class, "owner", false, "OWNER"); - public final static Property ObjectId = new Property(11, String.class, "objectId", false, "OBJECT_ID"); - public final static Property MarkerId = new Property(12, String.class, "markerId", false, "MARKER_ID"); - public final static Property MarkerType = new Property(13, String.class, "markerType", false, "MARKER_TYPE"); - public final static Property MarkerDepth = new Property(14, String.class, "markerDepth", false, "MARKER_DEPTH"); - public final static Property InstallationDept = new Property(15, String.class, "installationDept", false, "INSTALLATION_DEPT"); - public final static Property Lng = new Property(16, String.class, "lng", false, "LNG"); - public final static Property Lat = new Property(17, String.class, "lat", false, "LAT"); - public final static Property UpdateTime = new Property(18, String.class, "updateTime", false, "UPDATE_TIME"); - public final static Property Remark = new Property(19, String.class, "remark", false, "REMARK"); - public final static Property UnderlyingPipelineType = new Property(20, String.class, "underlyingPipelineType", false, "UNDERLYING_PIPELINE_TYPE"); - public final static Property UnderlyingPipelineDepth = new Property(21, String.class, "underlyingPipelineDepth", false, "UNDERLYING_PIPELINE_DEPTH"); - public final static Property UnderlyingPipelineDiameter = new Property(22, String.class, "underlyingPipelineDiameter", false, "UNDERLYING_PIPELINE_DIAMETER"); - public final static Property UnderlyingPipelineMaterial = new Property(23, String.class, "underlyingPipelineMaterial", false, "UNDERLYING_PIPELINE_MATERIAL"); - public final static Property ObjectType = new Property(24, String.class, "objectType", false, "OBJECT_TYPE"); - public final static Property Color = new Property(25, String.class, "color", false, "COLOR"); - public final static Property ImagePath = new Property(26, String.class, "imagePath", false, "IMAGE_PATH"); - } - - - public MarkerLocalBeanDao(DaoConfig config) { - super(config); - } - - public MarkerLocalBeanDao(DaoConfig config, DaoSession daoSession) { - super(config, daoSession); - } - - /** Creates the underlying database table. */ - public static void createTable(Database db, boolean ifNotExists) { - String constraint = ifNotExists? "IF NOT EXISTS ": ""; - db.execSQL("CREATE TABLE " + constraint + "\"MARKER_LOCAL_BEAN\" (" + // - "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id - "\"PIPELINE_TYPE\" TEXT," + // 1: pipelineType - "\"PIPELINE_DIAMETER\" TEXT," + // 2: pipelineDiameter - "\"PIPELINE_MATERIAL\" TEXT," + // 3: pipelineMaterial - "\"BURY_METHOD\" TEXT," + // 4: buryMethod - "\"BURY_DEPTH\" TEXT," + // 5: buryDepth - "\"AREA\" TEXT," + // 6: area - "\"LINE\" TEXT," + // 7: line - "\"ROAD\" TEXT," + // 8: road - "\"CONSTRUCT_TIME\" TEXT," + // 9: constructTime - "\"OWNER\" TEXT," + // 10: owner - "\"OBJECT_ID\" TEXT," + // 11: objectId - "\"MARKER_ID\" TEXT," + // 12: markerId - "\"MARKER_TYPE\" TEXT," + // 13: markerType - "\"MARKER_DEPTH\" TEXT," + // 14: markerDepth - "\"INSTALLATION_DEPT\" TEXT," + // 15: installationDept - "\"LNG\" TEXT," + // 16: lng - "\"LAT\" TEXT," + // 17: lat - "\"UPDATE_TIME\" TEXT," + // 18: updateTime - "\"REMARK\" TEXT," + // 19: remark - "\"UNDERLYING_PIPELINE_TYPE\" TEXT," + // 20: underlyingPipelineType - "\"UNDERLYING_PIPELINE_DEPTH\" TEXT," + // 21: underlyingPipelineDepth - "\"UNDERLYING_PIPELINE_DIAMETER\" TEXT," + // 22: underlyingPipelineDiameter - "\"UNDERLYING_PIPELINE_MATERIAL\" TEXT," + // 23: underlyingPipelineMaterial - "\"OBJECT_TYPE\" TEXT," + // 24: objectType - "\"COLOR\" TEXT," + // 25: color - "\"IMAGE_PATH\" TEXT);"); // 26: imagePath - } - - /** Drops the underlying database table. */ - public static void dropTable(Database db, boolean ifExists) { - String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"MARKER_LOCAL_BEAN\""; - db.execSQL(sql); - } - - @Override - protected final void bindValues(DatabaseStatement stmt, MarkerLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String pipelineType = entity.getPipelineType(); - if (pipelineType != null) { - stmt.bindString(2, pipelineType); - } - - String pipelineDiameter = entity.getPipelineDiameter(); - if (pipelineDiameter != null) { - stmt.bindString(3, pipelineDiameter); - } - - String pipelineMaterial = entity.getPipelineMaterial(); - if (pipelineMaterial != null) { - stmt.bindString(4, pipelineMaterial); - } - - String buryMethod = entity.getBuryMethod(); - if (buryMethod != null) { - stmt.bindString(5, buryMethod); - } - - String buryDepth = entity.getBuryDepth(); - if (buryDepth != null) { - stmt.bindString(6, buryDepth); - } - - String area = entity.getArea(); - if (area != null) { - stmt.bindString(7, area); - } - - String line = entity.getLine(); - if (line != null) { - stmt.bindString(8, line); - } - - String road = entity.getRoad(); - if (road != null) { - stmt.bindString(9, road); - } - - String constructTime = entity.getConstructTime(); - if (constructTime != null) { - stmt.bindString(10, constructTime); - } - - String owner = entity.getOwner(); - if (owner != null) { - stmt.bindString(11, owner); - } - - String objectId = entity.getObjectId(); - if (objectId != null) { - stmt.bindString(12, objectId); - } - - String markerId = entity.getMarkerId(); - if (markerId != null) { - stmt.bindString(13, markerId); - } - - String markerType = entity.getMarkerType(); - if (markerType != null) { - stmt.bindString(14, markerType); - } - - String markerDepth = entity.getMarkerDepth(); - if (markerDepth != null) { - stmt.bindString(15, markerDepth); - } - - String installationDept = entity.getInstallationDept(); - if (installationDept != null) { - stmt.bindString(16, installationDept); - } - - String lng = entity.getLng(); - if (lng != null) { - stmt.bindString(17, lng); - } - - String lat = entity.getLat(); - if (lat != null) { - stmt.bindString(18, lat); - } - - String updateTime = entity.getUpdateTime(); - if (updateTime != null) { - stmt.bindString(19, updateTime); - } - - String remark = entity.getRemark(); - if (remark != null) { - stmt.bindString(20, remark); - } - - String underlyingPipelineType = entity.getUnderlyingPipelineType(); - if (underlyingPipelineType != null) { - stmt.bindString(21, underlyingPipelineType); - } - - String underlyingPipelineDepth = entity.getUnderlyingPipelineDepth(); - if (underlyingPipelineDepth != null) { - stmt.bindString(22, underlyingPipelineDepth); - } - - String underlyingPipelineDiameter = entity.getUnderlyingPipelineDiameter(); - if (underlyingPipelineDiameter != null) { - stmt.bindString(23, underlyingPipelineDiameter); - } - - String underlyingPipelineMaterial = entity.getUnderlyingPipelineMaterial(); - if (underlyingPipelineMaterial != null) { - stmt.bindString(24, underlyingPipelineMaterial); - } - - String objectType = entity.getObjectType(); - if (objectType != null) { - stmt.bindString(25, objectType); - } - - String color = entity.getColor(); - if (color != null) { - stmt.bindString(26, color); - } - - String imagePath = entity.getImagePath(); - if (imagePath != null) { - stmt.bindString(27, imagePath); - } - } - - @Override - protected final void bindValues(SQLiteStatement stmt, MarkerLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String pipelineType = entity.getPipelineType(); - if (pipelineType != null) { - stmt.bindString(2, pipelineType); - } - - String pipelineDiameter = entity.getPipelineDiameter(); - if (pipelineDiameter != null) { - stmt.bindString(3, pipelineDiameter); - } - - String pipelineMaterial = entity.getPipelineMaterial(); - if (pipelineMaterial != null) { - stmt.bindString(4, pipelineMaterial); - } - - String buryMethod = entity.getBuryMethod(); - if (buryMethod != null) { - stmt.bindString(5, buryMethod); - } - - String buryDepth = entity.getBuryDepth(); - if (buryDepth != null) { - stmt.bindString(6, buryDepth); - } - - String area = entity.getArea(); - if (area != null) { - stmt.bindString(7, area); - } - - String line = entity.getLine(); - if (line != null) { - stmt.bindString(8, line); - } - - String road = entity.getRoad(); - if (road != null) { - stmt.bindString(9, road); - } - - String constructTime = entity.getConstructTime(); - if (constructTime != null) { - stmt.bindString(10, constructTime); - } - - String owner = entity.getOwner(); - if (owner != null) { - stmt.bindString(11, owner); - } - - String objectId = entity.getObjectId(); - if (objectId != null) { - stmt.bindString(12, objectId); - } - - String markerId = entity.getMarkerId(); - if (markerId != null) { - stmt.bindString(13, markerId); - } - - String markerType = entity.getMarkerType(); - if (markerType != null) { - stmt.bindString(14, markerType); - } - - String markerDepth = entity.getMarkerDepth(); - if (markerDepth != null) { - stmt.bindString(15, markerDepth); - } - - String installationDept = entity.getInstallationDept(); - if (installationDept != null) { - stmt.bindString(16, installationDept); - } - - String lng = entity.getLng(); - if (lng != null) { - stmt.bindString(17, lng); - } - - String lat = entity.getLat(); - if (lat != null) { - stmt.bindString(18, lat); - } - - String updateTime = entity.getUpdateTime(); - if (updateTime != null) { - stmt.bindString(19, updateTime); - } - - String remark = entity.getRemark(); - if (remark != null) { - stmt.bindString(20, remark); - } - - String underlyingPipelineType = entity.getUnderlyingPipelineType(); - if (underlyingPipelineType != null) { - stmt.bindString(21, underlyingPipelineType); - } - - String underlyingPipelineDepth = entity.getUnderlyingPipelineDepth(); - if (underlyingPipelineDepth != null) { - stmt.bindString(22, underlyingPipelineDepth); - } - - String underlyingPipelineDiameter = entity.getUnderlyingPipelineDiameter(); - if (underlyingPipelineDiameter != null) { - stmt.bindString(23, underlyingPipelineDiameter); - } - - String underlyingPipelineMaterial = entity.getUnderlyingPipelineMaterial(); - if (underlyingPipelineMaterial != null) { - stmt.bindString(24, underlyingPipelineMaterial); - } - - String objectType = entity.getObjectType(); - if (objectType != null) { - stmt.bindString(25, objectType); - } - - String color = entity.getColor(); - if (color != null) { - stmt.bindString(26, color); - } - - String imagePath = entity.getImagePath(); - if (imagePath != null) { - stmt.bindString(27, imagePath); - } - } - - @Override - public Long readKey(Cursor cursor, int offset) { - return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); - } - - @Override - public MarkerLocalBean readEntity(Cursor cursor, int offset) { - MarkerLocalBean entity = new MarkerLocalBean( // - cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // pipelineType - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // pipelineDiameter - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // pipelineMaterial - cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // buryMethod - cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // buryDepth - cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // area - cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // line - cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // road - cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // constructTime - cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10), // owner - cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11), // objectId - cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12), // markerId - cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13), // markerType - cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14), // markerDepth - cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15), // installationDept - cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16), // lng - cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17), // lat - cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18), // updateTime - cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19), // remark - cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20), // underlyingPipelineType - cursor.isNull(offset + 21) ? null : cursor.getString(offset + 21), // underlyingPipelineDepth - cursor.isNull(offset + 22) ? null : cursor.getString(offset + 22), // underlyingPipelineDiameter - cursor.isNull(offset + 23) ? null : cursor.getString(offset + 23), // underlyingPipelineMaterial - cursor.isNull(offset + 24) ? null : cursor.getString(offset + 24), // objectType - cursor.isNull(offset + 25) ? null : cursor.getString(offset + 25), // color - cursor.isNull(offset + 26) ? null : cursor.getString(offset + 26) // imagePath - ); - return entity; - } - - @Override - public void readEntity(Cursor cursor, MarkerLocalBean entity, int offset) { - entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setPipelineType(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); - entity.setPipelineDiameter(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); - entity.setPipelineMaterial(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); - entity.setBuryMethod(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); - entity.setBuryDepth(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); - entity.setArea(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); - entity.setLine(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); - entity.setRoad(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); - entity.setConstructTime(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9)); - entity.setOwner(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); - entity.setObjectId(cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11)); - entity.setMarkerId(cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12)); - entity.setMarkerType(cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13)); - entity.setMarkerDepth(cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14)); - entity.setInstallationDept(cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15)); - entity.setLng(cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16)); - entity.setLat(cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17)); - entity.setUpdateTime(cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18)); - entity.setRemark(cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19)); - entity.setUnderlyingPipelineType(cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20)); - entity.setUnderlyingPipelineDepth(cursor.isNull(offset + 21) ? null : cursor.getString(offset + 21)); - entity.setUnderlyingPipelineDiameter(cursor.isNull(offset + 22) ? null : cursor.getString(offset + 22)); - entity.setUnderlyingPipelineMaterial(cursor.isNull(offset + 23) ? null : cursor.getString(offset + 23)); - entity.setObjectType(cursor.isNull(offset + 24) ? null : cursor.getString(offset + 24)); - entity.setColor(cursor.isNull(offset + 25) ? null : cursor.getString(offset + 25)); - entity.setImagePath(cursor.isNull(offset + 26) ? null : cursor.getString(offset + 26)); - } - - @Override - protected final Long updateKeyAfterInsert(MarkerLocalBean entity, long rowId) { - entity.setId(rowId); - return rowId; - } - - @Override - public Long getKey(MarkerLocalBean entity) { - if(entity != null) { - return entity.getId(); - } else { - return null; - } - } - - @Override - public boolean hasKey(MarkerLocalBean entity) { - return entity.getId() != null; - } - - @Override - protected final boolean isEntityUpdateable() { - return true; - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/TaskLocalBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/greendao/TaskLocalBeanDao.java deleted file mode 100644 index fb88157..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/TaskLocalBeanDao.java +++ /dev/null @@ -1,227 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import android.database.Cursor; -import android.database.sqlite.SQLiteStatement; - -import org.greenrobot.greendao.AbstractDao; -import org.greenrobot.greendao.Property; -import org.greenrobot.greendao.internal.DaoConfig; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.database.DatabaseStatement; - -import com.casic.common.detector.gd.bean.TaskLocalBean; - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** - * DAO for table "TASK_LOCAL_BEAN". -*/ -public class TaskLocalBeanDao extends AbstractDao { - - public static final String TABLENAME = "TASK_LOCAL_BEAN"; - - /** - * Properties of entity TaskLocalBean.
- * Can be used for QueryBuilder and for referencing column names. - */ - public static class Properties { - public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property TaskCode = new Property(1, String.class, "taskCode", false, "TASK_CODE"); - public final static Property Description = new Property(2, String.class, "description", false, "DESCRIPTION"); - public final static Property CreateTime = new Property(3, String.class, "createTime", false, "CREATE_TIME"); - public final static Property Status = new Property(4, String.class, "status", false, "STATUS"); - public final static Property CreateUserName = new Property(5, String.class, "createUserName", false, "CREATE_USER_NAME"); - public final static Property StartTime = new Property(6, String.class, "startTime", false, "START_TIME"); - public final static Property EndTime = new Property(7, String.class, "endTime", false, "END_TIME"); - public final static Property IsFreeTask = new Property(8, String.class, "isFreeTask", false, "IS_FREE_TASK"); - } - - - public TaskLocalBeanDao(DaoConfig config) { - super(config); - } - - public TaskLocalBeanDao(DaoConfig config, DaoSession daoSession) { - super(config, daoSession); - } - - /** Creates the underlying database table. */ - public static void createTable(Database db, boolean ifNotExists) { - String constraint = ifNotExists? "IF NOT EXISTS ": ""; - db.execSQL("CREATE TABLE " + constraint + "\"TASK_LOCAL_BEAN\" (" + // - "\"_id\" INTEGER PRIMARY KEY ," + // 0: id - "\"TASK_CODE\" TEXT," + // 1: taskCode - "\"DESCRIPTION\" TEXT," + // 2: description - "\"CREATE_TIME\" TEXT," + // 3: createTime - "\"STATUS\" TEXT," + // 4: status - "\"CREATE_USER_NAME\" TEXT," + // 5: createUserName - "\"START_TIME\" TEXT," + // 6: startTime - "\"END_TIME\" TEXT," + // 7: endTime - "\"IS_FREE_TASK\" TEXT);"); // 8: isFreeTask - } - - /** Drops the underlying database table. */ - public static void dropTable(Database db, boolean ifExists) { - String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"TASK_LOCAL_BEAN\""; - db.execSQL(sql); - } - - @Override - protected final void bindValues(DatabaseStatement stmt, TaskLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String taskCode = entity.getTaskCode(); - if (taskCode != null) { - stmt.bindString(2, taskCode); - } - - String description = entity.getDescription(); - if (description != null) { - stmt.bindString(3, description); - } - - String createTime = entity.getCreateTime(); - if (createTime != null) { - stmt.bindString(4, createTime); - } - - String status = entity.getStatus(); - if (status != null) { - stmt.bindString(5, status); - } - - String createUserName = entity.getCreateUserName(); - if (createUserName != null) { - stmt.bindString(6, createUserName); - } - - String startTime = entity.getStartTime(); - if (startTime != null) { - stmt.bindString(7, startTime); - } - - String endTime = entity.getEndTime(); - if (endTime != null) { - stmt.bindString(8, endTime); - } - - String isFreeTask = entity.getIsFreeTask(); - if (isFreeTask != null) { - stmt.bindString(9, isFreeTask); - } - } - - @Override - protected final void bindValues(SQLiteStatement stmt, TaskLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String taskCode = entity.getTaskCode(); - if (taskCode != null) { - stmt.bindString(2, taskCode); - } - - String description = entity.getDescription(); - if (description != null) { - stmt.bindString(3, description); - } - - String createTime = entity.getCreateTime(); - if (createTime != null) { - stmt.bindString(4, createTime); - } - - String status = entity.getStatus(); - if (status != null) { - stmt.bindString(5, status); - } - - String createUserName = entity.getCreateUserName(); - if (createUserName != null) { - stmt.bindString(6, createUserName); - } - - String startTime = entity.getStartTime(); - if (startTime != null) { - stmt.bindString(7, startTime); - } - - String endTime = entity.getEndTime(); - if (endTime != null) { - stmt.bindString(8, endTime); - } - - String isFreeTask = entity.getIsFreeTask(); - if (isFreeTask != null) { - stmt.bindString(9, isFreeTask); - } - } - - @Override - public Long readKey(Cursor cursor, int offset) { - return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); - } - - @Override - public TaskLocalBean readEntity(Cursor cursor, int offset) { - TaskLocalBean entity = new TaskLocalBean( // - cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // taskCode - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // description - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // createTime - cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // status - cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // createUserName - cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // startTime - cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // endTime - cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8) // isFreeTask - ); - return entity; - } - - @Override - public void readEntity(Cursor cursor, TaskLocalBean entity, int offset) { - entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setTaskCode(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); - entity.setDescription(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); - entity.setCreateTime(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); - entity.setStatus(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); - entity.setCreateUserName(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); - entity.setStartTime(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); - entity.setEndTime(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); - entity.setIsFreeTask(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); - } - - @Override - protected final Long updateKeyAfterInsert(TaskLocalBean entity, long rowId) { - entity.setId(rowId); - return rowId; - } - - @Override - public Long getKey(TaskLocalBean entity) { - if(entity != null) { - return entity.getId(); - } else { - return null; - } - } - - @Override - public boolean hasKey(TaskLocalBean entity) { - return entity.getId() != null; - } - - @Override - protected final boolean isEntityUpdateable() { - return true; - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/TaskMarkerLocalBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/greendao/TaskMarkerLocalBeanDao.java deleted file mode 100644 index e96c735..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/TaskMarkerLocalBeanDao.java +++ /dev/null @@ -1,197 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import android.database.Cursor; -import android.database.sqlite.SQLiteStatement; - -import org.greenrobot.greendao.AbstractDao; -import org.greenrobot.greendao.Property; -import org.greenrobot.greendao.internal.DaoConfig; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.database.DatabaseStatement; - -import com.casic.common.detector.gd.bean.TaskMarkerLocalBean; - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** - * DAO for table "TASK_MARKER_LOCAL_BEAN". -*/ -public class TaskMarkerLocalBeanDao extends AbstractDao { - - public static final String TABLENAME = "TASK_MARKER_LOCAL_BEAN"; - - /** - * Properties of entity TaskMarkerLocalBean.
- * Can be used for QueryBuilder and for referencing column names. - */ - public static class Properties { - public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property TaskId = new Property(1, String.class, "taskId", false, "TASK_ID"); - public final static Property TaskCode = new Property(2, String.class, "taskCode", false, "TASK_CODE"); - public final static Property MarkerId = new Property(3, String.class, "markerId", false, "MARKER_ID"); - public final static Property Lng = new Property(4, double.class, "lng", false, "LNG"); - public final static Property Lat = new Property(5, double.class, "lat", false, "LAT"); - public final static Property IsDetected = new Property(6, String.class, "isDetected", false, "IS_DETECTED"); - public final static Property DetectedTime = new Property(7, String.class, "detectedTime", false, "DETECTED_TIME"); - } - - - public TaskMarkerLocalBeanDao(DaoConfig config) { - super(config); - } - - public TaskMarkerLocalBeanDao(DaoConfig config, DaoSession daoSession) { - super(config, daoSession); - } - - /** Creates the underlying database table. */ - public static void createTable(Database db, boolean ifNotExists) { - String constraint = ifNotExists? "IF NOT EXISTS ": ""; - db.execSQL("CREATE TABLE " + constraint + "\"TASK_MARKER_LOCAL_BEAN\" (" + // - "\"_id\" INTEGER PRIMARY KEY ," + // 0: id - "\"TASK_ID\" TEXT," + // 1: taskId - "\"TASK_CODE\" TEXT," + // 2: taskCode - "\"MARKER_ID\" TEXT," + // 3: markerId - "\"LNG\" REAL NOT NULL ," + // 4: lng - "\"LAT\" REAL NOT NULL ," + // 5: lat - "\"IS_DETECTED\" TEXT," + // 6: isDetected - "\"DETECTED_TIME\" TEXT);"); // 7: detectedTime - } - - /** Drops the underlying database table. */ - public static void dropTable(Database db, boolean ifExists) { - String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"TASK_MARKER_LOCAL_BEAN\""; - db.execSQL(sql); - } - - @Override - protected final void bindValues(DatabaseStatement stmt, TaskMarkerLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String taskId = entity.getTaskId(); - if (taskId != null) { - stmt.bindString(2, taskId); - } - - String taskCode = entity.getTaskCode(); - if (taskCode != null) { - stmt.bindString(3, taskCode); - } - - String markerId = entity.getMarkerId(); - if (markerId != null) { - stmt.bindString(4, markerId); - } - stmt.bindDouble(5, entity.getLng()); - stmt.bindDouble(6, entity.getLat()); - - String isDetected = entity.getIsDetected(); - if (isDetected != null) { - stmt.bindString(7, isDetected); - } - - String detectedTime = entity.getDetectedTime(); - if (detectedTime != null) { - stmt.bindString(8, detectedTime); - } - } - - @Override - protected final void bindValues(SQLiteStatement stmt, TaskMarkerLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String taskId = entity.getTaskId(); - if (taskId != null) { - stmt.bindString(2, taskId); - } - - String taskCode = entity.getTaskCode(); - if (taskCode != null) { - stmt.bindString(3, taskCode); - } - - String markerId = entity.getMarkerId(); - if (markerId != null) { - stmt.bindString(4, markerId); - } - stmt.bindDouble(5, entity.getLng()); - stmt.bindDouble(6, entity.getLat()); - - String isDetected = entity.getIsDetected(); - if (isDetected != null) { - stmt.bindString(7, isDetected); - } - - String detectedTime = entity.getDetectedTime(); - if (detectedTime != null) { - stmt.bindString(8, detectedTime); - } - } - - @Override - public Long readKey(Cursor cursor, int offset) { - return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); - } - - @Override - public TaskMarkerLocalBean readEntity(Cursor cursor, int offset) { - TaskMarkerLocalBean entity = new TaskMarkerLocalBean( // - cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // taskId - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // taskCode - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // markerId - cursor.getDouble(offset + 4), // lng - cursor.getDouble(offset + 5), // lat - cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // isDetected - cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7) // detectedTime - ); - return entity; - } - - @Override - public void readEntity(Cursor cursor, TaskMarkerLocalBean entity, int offset) { - entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setTaskId(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); - entity.setTaskCode(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); - entity.setMarkerId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); - entity.setLng(cursor.getDouble(offset + 4)); - entity.setLat(cursor.getDouble(offset + 5)); - entity.setIsDetected(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); - entity.setDetectedTime(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); - } - - @Override - protected final Long updateKeyAfterInsert(TaskMarkerLocalBean entity, long rowId) { - entity.setId(rowId); - return rowId; - } - - @Override - public Long getKey(TaskMarkerLocalBean entity) { - if(entity != null) { - return entity.getId(); - } else { - return null; - } - } - - @Override - public boolean hasKey(TaskMarkerLocalBean entity) { - return entity.getId() != null; - } - - @Override - protected final boolean isEntityUpdateable() { - return true; - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/model/TaskModel.java b/app/src/main/java/com/casic/common/detector/gd/model/TaskModel.java index 6e853ad..67ef5fb 100644 --- a/app/src/main/java/com/casic/common/detector/gd/model/TaskModel.java +++ b/app/src/main/java/com/casic/common/detector/gd/model/TaskModel.java @@ -24,7 +24,7 @@ } public static class MessageModel { - private int id; + private Long id; private String taskCode; private String description; private String deployDate; @@ -38,11 +38,11 @@ private int isValid; private List taskDetailInfos; - public int getId() { + public Long getId() { return id; } - public void setId(int id) { + public void setId(Long id) { this.id = id; } @@ -143,25 +143,25 @@ } public static class TaskDetailInfosModel { - private int id; + private long id; private String taskId; private String taskCode; private Object markerName; - private int markerId; + private String markerId; private String markerIdReal; private double longitude; private double latitude; private int isChecked; private int isNormal; - private Object imagePath; - private Object description; - private Object finishTime; + private String imagePath; + private String description; + private String finishTime; - public int getId() { + public long getId() { return id; } - public void setId(int id) { + public void setId(long id) { this.id = id; } @@ -189,11 +189,11 @@ this.markerName = markerName; } - public int getMarkerId() { + public String getMarkerId() { return markerId; } - public void setMarkerId(int markerId) { + public void setMarkerId(String markerId) { this.markerId = markerId; } @@ -237,27 +237,27 @@ this.isNormal = isNormal; } - public Object getImagePath() { + public String getImagePath() { return imagePath; } - public void setImagePath(Object imagePath) { + public void setImagePath(String imagePath) { this.imagePath = imagePath; } - public Object getDescription() { + public String getDescription() { return description; } - public void setDescription(Object description) { + public void setDescription(String description) { this.description = description; } - public Object getFinishTime() { + public String getFinishTime() { return finishTime; } - public void setFinishTime(Object finishTime) { + public void setFinishTime(String finishTime) { this.finishTime = finishTime; } } diff --git a/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitService.kt index 7522a87..0adad51 100644 --- a/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitService.kt @@ -50,7 +50,7 @@ */ @Multipart @POST("/ems/marker/save-marker-photo.do") - suspend fun installLabel( + suspend fun install( @PartMap jsonMarker: Map, @Part fileBuffer1: MultipartBody.Part?, @Part fileBuffer2: MultipartBody.Part?, diff --git a/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitServiceManager.kt index 5f6c701..ae2a0fa 100644 --- a/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitServiceManager.kt +++ b/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitServiceManager.kt @@ -37,22 +37,28 @@ /** * 获取标识器信息文件 */ - suspend fun getMarkerFile(userId: String, companyId: String): String { - return createApi().getMarkerFile(userId, companyId) + suspend fun getMarkerFile(): String { + val companyId = SaveKeyValues.getValue(LocaleConstant.USER_COMPANY_ID, "") as String + /** + * 后台设计如此,都传companyId + * */ + return createApi().getMarkerFile(companyId, companyId) } /** * 获取巡检工单 */ - suspend fun getTasksByUser(userName: String): String { + suspend fun getTasksByUser(): String { + val userName = SaveKeyValues.getValue(LocaleConstant.USER_NAME, "") as String return createApi().getTasksByUser(userName) } /** * 提交工单 */ - suspend fun uploadTask(userId: String, taskId: String?, state: String): String { + suspend fun uploadTask(taskId: String?, state: String): String { + val userId = SaveKeyValues.getValue(LocaleConstant.USER_ID, "") as String return createApi().uploadTask(userId, taskId.toString(), state) } @@ -60,8 +66,7 @@ * 安装新标识器 * Multipart上传图片,文件,带多参数上传 */ - suspend fun installLabel( - companyId: String, + suspend fun installMarker( recordType: String, markerObjectType: String, pipeMaterial: String, @@ -77,7 +82,6 @@ road: String, constructTime: String, ownerComp: String, - markerObjectId: String, markerId: String, markerType: String, markerDepth: String, @@ -89,6 +93,8 @@ memo: String, realPaths: ArrayList ): String { + val companyId = SaveKeyValues.getValue(LocaleConstant.USER_COMPANY_ID, "") as String + val objectId = SaveKeyValues.getValue(LocaleConstant.OBJECT_ID, "") as String val param = JsonObject() param.addProperty("companyId", companyId) param.addProperty("recordType", recordType) @@ -106,7 +112,7 @@ param.addProperty("road", road) param.addProperty("constructTime", constructTime) param.addProperty("ownerComp", ownerComp) - param.addProperty("markerObjectId", markerObjectId) + param.addProperty("markerObjectId", objectId) param.addProperty("markerId", markerId) param.addProperty("markerType", markerType) param.addProperty("markerDepth", markerDepth) @@ -133,19 +139,19 @@ return when (multiParts.size) { 3 -> { - createApi().installLabel(res, multiParts[0], multiParts[1], multiParts[2]) + createApi().install(res, multiParts[0], multiParts[1], multiParts[2]) } 2 -> { - createApi().installLabel(res, multiParts[0], multiParts[1], null) + createApi().install(res, multiParts[0], multiParts[1], null) } 1 -> { - createApi().installLabel(res, multiParts[0], null, null) + createApi().install(res, multiParts[0], null, null) } else -> { - createApi().installLabel(res, null, null, null) + createApi().install(res, null, null, null) } } } @@ -216,7 +222,7 @@ /** * 上传自由巡检过程中发现的标识器 */ - suspend fun uploadTaskMarker(taskId: String, ids: ArrayList): String { + suspend fun uploadTaskMarker(taskId: Long, ids: ArrayList): String { val param = JsonObject() param.addProperty("taskId", taskId) param.addProperty("ids", ids.joinToString(separator = ",")) diff --git a/app/src/main/java/com/casic/common/detector/gd/service/NtripConnectService.kt b/app/src/main/java/com/casic/common/detector/gd/service/NtripConnectService.kt index de9ac80..20e1a6a 100644 --- a/app/src/main/java/com/casic/common/detector/gd/service/NtripConnectService.kt +++ b/app/src/main/java/com/casic/common/detector/gd/service/NtripConnectService.kt @@ -9,10 +9,6 @@ import android.util.Log import android.view.Gravity import android.widget.Toast -import androidx.lifecycle.Lifecycle -import androidx.lifecycle.LifecycleOwner -import androidx.lifecycle.LifecycleRegistry -import androidx.lifecycle.lifecycleScope import com.casic.common.detector.gd.base.BaseApplication import com.casic.common.detector.gd.extensions.convertToGPGGA import com.casic.common.detector.gd.utils.LocaleConstant @@ -23,26 +19,24 @@ import com.pengxh.kt.lite.utils.WeakReferenceHandler import com.pengxh.kt.lite.utils.socket.tcp.OnTcpConnectStateListener import com.pengxh.kt.lite.utils.socket.tcp.TcpClient +import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.Job import kotlinx.coroutines.launch import java.io.OutputStream import java.nio.charset.StandardCharsets -class NtripConnectService : Service(), LifecycleOwner, OnTcpConnectStateListener, Handler.Callback { +class NtripConnectService : Service(), OnTcpConnectStateListener, Handler.Callback { companion object { var weakReferenceHandler: WeakReferenceHandler? = null } private val kTag = "NtripConnectService" - private val registry = LifecycleRegistry(this) private val socketClient by lazy { TcpClient(this) } private var outStream: OutputStream? = null - - override fun getLifecycle(): Lifecycle { - return registry - } + private val serviceScope = CoroutineScope(Dispatchers.Main + Job()) // 创建一个独立的CoroutineScope override fun onBind(intent: Intent?): IBinder? { return null @@ -117,7 +111,7 @@ * */ val result = String(this, StandardCharsets.UTF_8) if (result.contains("ICY 200 OK")) { - lifecycleScope.launch(Dispatchers.Main) { + serviceScope.launch { "高精度定位服务连接成功".show(this@NtripConnectService) } //连接服务即打开串口 @@ -135,12 +129,12 @@ * Content-Type: text/plain * Connection: clos * */ - lifecycleScope.launch(Dispatchers.Main) { + serviceScope.launch { "差分定位服务鉴权失败,无法解析位置".show(this@NtripConnectService) } } else { //居中显示 - lifecycleScope.launch(Dispatchers.Main) { + serviceScope.launch { val toast = Toast.makeText( this@NtripConnectService, "收到千寻数据,长度:${size}", Toast.LENGTH_SHORT ) @@ -167,7 +161,7 @@ return } - lifecycleScope.launch(Dispatchers.IO) { + serviceScope.launch(Dispatchers.IO) { socketClient.start(remoteHost, remotePort.toInt()) } } diff --git a/app/src/main/java/com/casic/common/detector/gd/utils/DataBaseManager.kt b/app/src/main/java/com/casic/common/detector/gd/utils/DataBaseManager.kt deleted file mode 100644 index aa22759..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/utils/DataBaseManager.kt +++ /dev/null @@ -1,200 +0,0 @@ -package com.casic.common.detector.gd.utils - -import com.casic.common.detector.gd.base.BaseApplication -import com.casic.common.detector.gd.bean.MarkerLocalBean -import com.casic.common.detector.gd.bean.TaskLocalBean -import com.casic.common.detector.gd.bean.TaskMarkerLocalBean -import com.casic.common.detector.gd.greendao.MarkerLocalBeanDao -import com.casic.common.detector.gd.greendao.TaskLocalBeanDao -import com.casic.common.detector.gd.greendao.TaskMarkerLocalBeanDao -import com.casic.common.detector.gd.model.TaskDetailLocalModel -import com.casic.common.detector.gd.model.TaskModel - -class DataBaseManager private constructor() { - companion object { - //Kotlin委托模式双重锁单例 - val get by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) { - DataBaseManager() - } - } - - private var taskLocalBeanDao = BaseApplication.get().getDaoSession().taskLocalBeanDao - private var taskMarkerLocalBeanDao = - BaseApplication.get().getDaoSession().taskMarkerLocalBeanDao - - fun saveTaskInLocale(task: TaskModel.MessageModel) { - val bean = TaskLocalBean() - bean.id = task.id.toLong() - bean.taskCode = task.taskCode - bean.description = task.description - bean.createTime = task.deployDate - bean.status = task.status - bean.createUserName = task.creatorName - if (task.beginDate == null) { - bean.startTime = "" - } - if (task.endDate == null) { - bean.endTime = "" - } - bean.isFreeTask = "0" - if (!bean.isExist()) { - taskLocalBeanDao.insert(bean) - } - } - - fun saveTaskInLocale(bean: TaskLocalBean) { - if (!bean.isExist()) { - taskLocalBeanDao.insert(bean) - } - } - - private fun TaskLocalBean.isExist(): Boolean { - val result = taskLocalBeanDao.queryBuilder().where( - TaskLocalBeanDao.Properties.Id.eq(this.id) - ).list() - return !result.isNullOrEmpty() - } - - fun saveTaskMarkerInLocale( - taskId: Int, taskCode: String, marker: TaskModel.MessageModel.TaskDetailInfosModel - ) { - val bean = TaskMarkerLocalBean() - bean.id = marker.id.toLong() - bean.taskId = taskId.toString() - bean.taskCode = taskCode - bean.markerId = marker.markerIdReal - bean.lng = marker.longitude - bean.lat = marker.latitude - bean.isDetected = "0" - bean.detectedTime = "" - if (!bean.isExist()) { - taskMarkerLocalBeanDao.insert(bean) - } - } - - private fun TaskMarkerLocalBean.isExist(): Boolean { - val result = taskMarkerLocalBeanDao.queryBuilder().where( - TaskMarkerLocalBeanDao.Properties.Id.eq(this.id) - ).list() - return !result.isNullOrEmpty() - } - - fun loadLocalTask(): ArrayList { - val result = ArrayList() - - val tasks = taskLocalBeanDao.loadAll() - tasks.forEach { - val model = TaskDetailLocalModel() - model.taskId = it.id.toString() - model.taskCode = it.taskCode - model.description = it.description - model.createTime = it.createTime - model.status = it.status - model.createUserName = it.createUserName - model.isFreeTask = it.isFreeTask - - val markers = ArrayList() - if (it.isFreeTask == "0") { - //非自由巡检才有Marker - val markerLocalBeans = taskMarkerLocalBeanDao.queryBuilder().where( - TaskMarkerLocalBeanDao.Properties.TaskId.eq(it.id), - TaskMarkerLocalBeanDao.Properties.TaskCode.eq(it.taskCode) - ).list() - markerLocalBeans.forEach { marker -> - val localModel = TaskDetailLocalModel.TaskMarkerLocalModel() - localModel.markerId = marker.markerId - localModel.lng = marker.lng - localModel.lat = marker.lat - localModel.isDetected = marker.isDetected - localModel.detectedTime = marker.detectedTime - - markers.add(localModel) - } - } - model.markerModels = markers - result.add(model) - } - return result - } - - fun deleteLocalTaskById(taskId: String, taskCode: String) { - val task = taskLocalBeanDao.queryBuilder().where( - TaskLocalBeanDao.Properties.Id.eq(taskId), - TaskLocalBeanDao.Properties.TaskCode.eq(taskCode) - ).list().firstOrNull() ?: return - taskLocalBeanDao.delete(task) - - //删除此任务关联的Marker。非自由巡检才有Marker - if (task.isFreeTask == "0") { - val markers = taskMarkerLocalBeanDao.queryBuilder() - .where( - TaskMarkerLocalBeanDao.Properties.TaskId.eq(taskId), - TaskMarkerLocalBeanDao.Properties.TaskCode.eq(taskCode) - ).list() - markers.forEach { - taskMarkerLocalBeanDao.delete(it) - } - } - } - - fun queryTaskMarkerById( - taskId: String, taskCode: String, markerId: String, state: String - ): TaskMarkerLocalBean? { - return taskMarkerLocalBeanDao.queryBuilder() - .where( - TaskMarkerLocalBeanDao.Properties.TaskId.eq(taskId), - TaskMarkerLocalBeanDao.Properties.TaskCode.eq(taskCode), - TaskMarkerLocalBeanDao.Properties.MarkerId.eq(markerId), - TaskMarkerLocalBeanDao.Properties.IsDetected.eq(state) - ).list().firstOrNull() - } - - fun updateLocalTaskMarkerState(marker: TaskMarkerLocalBean) { - marker.isDetected = "1" - taskMarkerLocalBeanDao.update(marker) - } - - fun queryMarkerByState(state: String): List { - return taskMarkerLocalBeanDao.queryBuilder() - .where(TaskMarkerLocalBeanDao.Properties.IsDetected.eq(state)) - .list() - } - - private var markerLocalBeanDao = BaseApplication.get().getDaoSession().markerLocalBeanDao - - fun clearMarkers() { - markerLocalBeanDao.deleteAll() - } - - fun saveMarkerInLocale(bean: MarkerLocalBean) { - markerLocalBeanDao.insert(bean) - } - - fun loadMarkers(): MutableList { - return markerLocalBeanDao.loadAll() - } - - fun loadMarkersByCondition(selectedItem: String, value: String?): MutableList { - val property = when (selectedItem) { - LocaleConstant.SPINNER_ARRAY[0] -> MarkerLocalBeanDao.Properties.MarkerId - LocaleConstant.SPINNER_ARRAY[1] -> MarkerLocalBeanDao.Properties.Area - LocaleConstant.SPINNER_ARRAY[2] -> MarkerLocalBeanDao.Properties.Line - LocaleConstant.SPINNER_ARRAY[3] -> MarkerLocalBeanDao.Properties.Road - LocaleConstant.SPINNER_ARRAY[4] -> MarkerLocalBeanDao.Properties.Owner - LocaleConstant.SPINNER_ARRAY[5] -> MarkerLocalBeanDao.Properties.InstallationDept - LocaleConstant.SPINNER_ARRAY[6] -> MarkerLocalBeanDao.Properties.UpdateTime - else -> MarkerLocalBeanDao.Properties.Remark - } - return if (value == null) { - markerLocalBeanDao.queryBuilder().where(property.isNotNull).list() - } else { - markerLocalBeanDao.queryBuilder().where(property.eq(value)).list() - } - } - - fun queryMarkerById(markerId: String): List { - return markerLocalBeanDao.queryBuilder() - .where(MarkerLocalBeanDao.Properties.MarkerId.eq(markerId)) - .list() - } -} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/utils/DetectorDataBase.java b/app/src/main/java/com/casic/common/detector/gd/utils/DetectorDataBase.java new file mode 100644 index 0000000..f686cac --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/utils/DetectorDataBase.java @@ -0,0 +1,21 @@ +package com.casic.common.detector.gd.utils; + +import androidx.room.Database; +import androidx.room.RoomDatabase; + +import com.casic.common.detector.gd.bean.MarkerBean; +import com.casic.common.detector.gd.bean.TaskBean; +import com.casic.common.detector.gd.bean.TaskMarkerBean; +import com.casic.common.detector.gd.dao.MarkerBeanDao; +import com.casic.common.detector.gd.dao.TaskBeanDao; +import com.casic.common.detector.gd.dao.TaskMarkerBeanDao; + + +@Database(entities = {MarkerBean.class, TaskBean.class, TaskMarkerBean.class}, version = 1) +public abstract class DetectorDataBase extends RoomDatabase { + public abstract MarkerBeanDao markerBeanDao(); + + public abstract TaskBeanDao taskBeanDao(); + + public abstract TaskMarkerBeanDao taskMarkerBeanDao(); +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/utils/ExcelKit.kt b/app/src/main/java/com/casic/common/detector/gd/utils/ExcelKit.kt index 200fac7..015969f 100644 --- a/app/src/main/java/com/casic/common/detector/gd/utils/ExcelKit.kt +++ b/app/src/main/java/com/casic/common/detector/gd/utils/ExcelKit.kt @@ -1,19 +1,19 @@ package com.casic.common.detector.gd.utils -import com.casic.common.detector.gd.bean.MarkerLocalBean +import com.casic.common.detector.gd.base.BaseApplication +import com.casic.common.detector.gd.bean.MarkerBean import jxl.Workbook import jxl.read.biff.BiffException import java.io.File object ExcelKit { - fun read(filePath: String): ArrayList { - val result = ArrayList() + fun read(filePath: String): ArrayList { + val result = ArrayList() try { val workbook = Workbook.getWorkbook(File(filePath)) val sheet = workbook.getSheet(0) - for (i in 1 until sheet.rows) { - val marker = MarkerLocalBean() + val marker = MarkerBean() marker.pipelineType = sheet.getCell(0, i).contents marker.pipelineDiameter = sheet.getCell(1, i).contents marker.pipelineMaterial = sheet.getCell(2, i).contents @@ -40,9 +40,10 @@ marker.objectType = sheet.getCell(23, i).contents marker.color = sheet.getCell(24, i).contents marker.imagePath = sheet.getCell(25, i).contents - - result.add(marker) - DataBaseManager.get.saveMarkerInLocale(marker) + if (!marker.markerId.isNullOrBlank()) { + result.add(marker) + BaseApplication.get().dataBase.markerBeanDao().insert(marker) + } } workbook.close() } catch (e: BiffException) { diff --git a/app/src/main/java/com/casic/common/detector/gd/utils/LocaleConstant.kt b/app/src/main/java/com/casic/common/detector/gd/utils/LocaleConstant.kt index c658924..8ac5f76 100644 --- a/app/src/main/java/com/casic/common/detector/gd/utils/LocaleConstant.kt +++ b/app/src/main/java/com/casic/common/detector/gd/utils/LocaleConstant.kt @@ -1,6 +1,8 @@ package com.casic.common.detector.gd.utils import android.Manifest +import androidx.sqlite.db.SimpleSQLiteQuery +import androidx.sqlite.db.SupportSQLiteQuery object LocaleConstant { @@ -59,4 +61,19 @@ var BURY_METHOD_ARRAY = arrayOf("直埋", "圆管", "管块", "管沟", "架空") var IDENTIFIER_TYPE_ARRAY = arrayOf("EM30", "EM50", "EM14") var COLOR_ARRAY = arrayOf("蓝色", "橙色", "红色", "黑色", "紫色", "黄色", "绿色") + + fun buildQuery(selectedItem: String, value: String): SupportSQLiteQuery { + val columnName = when (selectedItem) { + SPINNER_ARRAY[0] -> "markerId" + SPINNER_ARRAY[1] -> "area" + SPINNER_ARRAY[2] -> "line" + SPINNER_ARRAY[3] -> "road" + SPINNER_ARRAY[4] -> "owner" + SPINNER_ARRAY[5] -> "installationDept" + SPINNER_ARRAY[6] -> "updateTime" + else -> "remark" + } + val queryBuilder = StringBuilder("SELECT * FROM marker_detail WHERE $columnName = ?") + return SimpleSQLiteQuery(queryBuilder.toString(), arrayOf(value)) + } } \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/view/InstallMarkerActivity.kt b/app/src/main/java/com/casic/common/detector/gd/view/InstallMarkerActivity.kt index daf5b0f..9e09df1 100644 --- a/app/src/main/java/com/casic/common/detector/gd/view/InstallMarkerActivity.kt +++ b/app/src/main/java/com/casic/common/detector/gd/view/InstallMarkerActivity.kt @@ -14,8 +14,9 @@ import com.amap.api.location.AMapLocation import com.casic.common.detector.gd.R import com.casic.common.detector.gd.adapter.EditableImageAdapter +import com.casic.common.detector.gd.base.BaseApplication import com.casic.common.detector.gd.base.SerialPortBaseActivity -import com.casic.common.detector.gd.bean.MarkerLocalBean +import com.casic.common.detector.gd.bean.MarkerBean import com.casic.common.detector.gd.callback.OnGetLocationListener import com.casic.common.detector.gd.callback.OnImageCompressListener import com.casic.common.detector.gd.databinding.ActivityInstallMarkerBinding @@ -27,7 +28,6 @@ import com.casic.common.detector.gd.extensions.toColor import com.casic.common.detector.gd.extensions.toObjectType import com.casic.common.detector.gd.utils.CurrentSegment -import com.casic.common.detector.gd.utils.DataBaseManager import com.casic.common.detector.gd.utils.LocaleConstant import com.casic.common.detector.gd.utils.LocationKit import com.casic.common.detector.gd.utils.RuntimeCache @@ -44,7 +44,6 @@ import com.pengxh.kt.lite.extensions.timestampToCompleteDate import com.pengxh.kt.lite.extensions.timestampToTime import com.pengxh.kt.lite.extensions.toJson -import com.pengxh.kt.lite.utils.LoadState import com.pengxh.kt.lite.utils.LoadingDialog import com.pengxh.kt.lite.utils.SaveKeyValues import com.pengxh.kt.lite.widget.TitleBarView @@ -115,8 +114,6 @@ //安装 binding.installButton.setOnClickListener { - val companyId = SaveKeyValues.getValue(LocaleConstant.USER_COMPANY_ID, "") as String - val objectId = SaveKeyValues.getValue(LocaleConstant.OBJECT_ID, "") as String if (binding.objectInclude.pipeInclude.markerObjectTypeView.text.isNullOrBlank()) { when (binding.objectInclude.objectTypeSpinner.selectedItem.toString()) { "管线" -> "请输入管线种类!".show(this) @@ -189,8 +186,7 @@ //先存本地再上传服务器 saveMarkerInLocal() - taskViewModel.installLabel( - this, companyId, + taskViewModel.installMarker( binding.objectInclude.objectTypeSpinner.selectedItem.toString().toObjectType(), binding.objectInclude.pipeInclude.markerObjectTypeView.text.toString(), binding.objectInclude.pipeInclude.materialSpinner.selectedItem.toString(), @@ -206,7 +202,6 @@ binding.objectInclude.roadView.text.toString(), binding.objectInclude.constructDateView.text.toString(), binding.objectInclude.ownerView.text.toString(), - objectId, binding.identifierInclude.identifierIdView.text.toString(), binding.identifierInclude.identifierTypeSpinner.selectedItem.toString(), "${binding.identifierInclude.identifierDeepView.text}mm", @@ -216,7 +211,19 @@ binding.identifierInclude.latView.text.toString(), binding.identifierInclude.colorSpinner.selectedItem.toString().toColor(), binding.remarkView.text.toString(), - realPaths + realPaths, + onLoading = { + LoadingDialog.show(this, "标识器安装中,请稍后...") + }, + onSuccess = { + LoadingDialog.dismiss() + clearDefaultData() + "安装成功".show(this) + }, + onFailed = { + LoadingDialog.dismiss() + it.show(this) + } ) //保存默认值 @@ -268,7 +275,7 @@ private fun saveMarkerInLocal() { val objectId = SaveKeyValues.getValue(LocaleConstant.OBJECT_ID, "") as String - val marker = MarkerLocalBean() + val marker = MarkerBean() marker.objectType = binding.objectInclude.objectTypeSpinner.selectedItem.toString() marker.pipelineType = binding.objectInclude.pipeInclude.markerObjectTypeView.text.toString() marker.pipelineMaterial = @@ -302,7 +309,7 @@ marker.remark = binding.remarkView.text.toString() marker.imagePath = realPaths.toJson() - DataBaseManager.get.saveMarkerInLocale(marker) + BaseApplication.get().dataBase.markerBeanDao().insert(marker) } private fun takePicture() { @@ -339,8 +346,8 @@ override fun initOnCreate(savedInstanceState: Bundle?) { locationKit.getCurrentLocation(true, object : OnGetLocationListener { override fun onSuccess(location: AMapLocation) { - binding.identifierInclude.lngView.text = location.longitude.toString() - binding.identifierInclude.latView.text = location.latitude.toString() + binding.identifierInclude.lngView.text = "${location.longitude}" + binding.identifierInclude.latView.text = "${location.latitude}" } override fun onError() { @@ -357,22 +364,6 @@ return ActivityInstallMarkerBinding.inflate(layoutInflater) } - override fun observeRequestState() { - taskViewModel.loadState.observe(this) { - when (it) { - LoadState.Loading -> LoadingDialog.show(this, "标识器安装中,请稍后...") - - LoadState.Success -> { - LoadingDialog.dismiss() - clearDefaultData() - "安装成功".show(this) - } - - else -> LoadingDialog.dismiss() - } - } - } - override fun setupTopBarLayout() { binding.rootView.initImmersionBar(this, true, R.color.white) binding.titleView.setOnClickListener(object : TitleBarView.OnClickListener { diff --git a/app/src/main/java/com/casic/common/detector/gd/view/MainActivity.kt b/app/src/main/java/com/casic/common/detector/gd/view/MainActivity.kt index fb0b260..a6352fb 100644 --- a/app/src/main/java/com/casic/common/detector/gd/view/MainActivity.kt +++ b/app/src/main/java/com/casic/common/detector/gd/view/MainActivity.kt @@ -5,7 +5,6 @@ import android.graphics.Color import android.media.AudioAttributes import android.media.SoundPool -import android.os.Build import android.os.Bundle import android.os.CountDownTimer import android.os.Handler @@ -31,19 +30,17 @@ import com.casic.common.detector.gd.R import com.casic.common.detector.gd.base.BaseApplication import com.casic.common.detector.gd.base.SerialPortBaseActivity -import com.casic.common.detector.gd.bean.MarkerLocalBean -import com.casic.common.detector.gd.bean.TaskLocalBean +import com.casic.common.detector.gd.bean.MarkerBean import com.casic.common.detector.gd.callback.OnGetAddressListener import com.casic.common.detector.gd.callback.OnGetLocationListener import com.casic.common.detector.gd.databinding.ActivityMainBinding import com.casic.common.detector.gd.extensions.appendDownloadUrl -import com.casic.common.detector.gd.extensions.createTaskCode import com.casic.common.detector.gd.extensions.initImmersionBar +import com.casic.common.detector.gd.model.MarkerFileModel import com.casic.common.detector.gd.model.TaskDetailLocalModel import com.casic.common.detector.gd.model.TaskModel import com.casic.common.detector.gd.service.NtripConnectService import com.casic.common.detector.gd.utils.CurrentSegment -import com.casic.common.detector.gd.utils.DataBaseManager import com.casic.common.detector.gd.utils.ExcelKit import com.casic.common.detector.gd.utils.FileType import com.casic.common.detector.gd.utils.LocaleConstant @@ -62,9 +59,7 @@ import com.pengxh.kt.lite.extensions.isNetworkConnected import com.pengxh.kt.lite.extensions.navigatePageTo import com.pengxh.kt.lite.extensions.show -import com.pengxh.kt.lite.extensions.timestampToCompleteDate import com.pengxh.kt.lite.utils.FileDownloadManager -import com.pengxh.kt.lite.utils.LoadState import com.pengxh.kt.lite.utils.LoadingDialog import com.pengxh.kt.lite.utils.SaveKeyValues import com.pengxh.kt.lite.widget.TitleBarView @@ -86,6 +81,9 @@ private val samplePopupWindow by lazy { SamplePopupWindow(this) } private val detailDialog by lazy { MarkerDetailDialog(this) } private val locationKit by lazy { LocationKit(this) } + private val markerBeanDao by lazy { BaseApplication.get().dataBase.markerBeanDao() } + private val taskBeanDao by lazy { BaseApplication.get().dataBase.taskBeanDao() } + private val taskMarkerBeanDao by lazy { BaseApplication.get().dataBase.taskMarkerBeanDao() } private val taskViewModel by lazy { ViewModelProvider(this)[TaskViewModel::class.java] } private val attr = AudioAttributes.Builder().setUsage(AudioAttributes.USAGE_ALARM) .setContentType(AudioAttributes.CONTENT_TYPE_MUSIC).build() @@ -94,7 +92,7 @@ private var isFreeTask = false private var freeTaskTitle = "" private var ids = ArrayList() - private var freeTaskId: String? = null + private var freeTaskId = 0L private var soundResourceId = 0 private var isExecuteTask = false private lateinit var aMap: AMap @@ -111,89 +109,14 @@ //地图初始化 initMapConfig(savedInstanceState) - Intent(this, NtripConnectService::class.java).also { - startService(it) - } +// Intent(this, NtripConnectService::class.java).apply { +// startService(this) +// } soundResourceId = soundPool.load(this, R.raw.ring3, 1) //右上角菜单 samplePopupWindow.setPopupMenuItem(LocaleConstant.POPUP_TITLES) samplePopupWindow.setBackgroundDrawable(null) - - //task网络请求监听 - taskViewModel.markerFileResult.observe(this) { - if (it.isSuccess) { - //清空之前的数据 - DataBaseManager.get.clearMarkers() - //下载最新的数据 - val companyId = SaveKeyValues.getValue(LocaleConstant.USER_COMPANY_ID, "") - val downloadUrl = companyId.toString().appendDownloadUrl(FileType.Excel) - Log.d(kTag, "downloadUrl => $downloadUrl") - FileDownloadManager.Builder().setDownloadFileSource(downloadUrl) - .setFileSuffix("xls").setFileSaveDirectory(createDownloadFileDir()) - .setOnFileDownloadListener(object : FileDownloadManager.OnFileDownloadListener { - override fun onDownloadStart(total: Long) { - - } - - override fun onDownloadEnd(file: File) { - lifecycleScope.launch(Dispatchers.IO) { ExcelKit.read(file.absolutePath) } - LoadingDialog.dismiss() - showMarkersOnMap() - } - - override fun onDownloadFailed(t: Throwable) { - t.printStackTrace() - } - - override fun onProgressChanged(progress: Long) { - - } - }).build().start() - } - } - taskViewModel.taskResult.observe(this) { - if (it.success == "true") { - AlertMessageDialog.Builder().setContext(this).setTitle("温馨提示") - .setMessage("您有${it.message.size}个新任务!").setPositiveButton("知道了") - .setOnDialogButtonClickListener(object : - AlertMessageDialog.OnDialogButtonClickListener { - override fun onConfirmClick() { - saveUserTasks(it) - } - }).build().show() - } - } - taskViewModel.freeTaskResult.observe(this) { - freeTaskId = it - // 自由巡检保存在本地 - val bean = TaskLocalBean() - bean.id = freeTaskId.toString().toLong() - val currentTimeMillis = System.currentTimeMillis() - bean.taskCode = currentTimeMillis.createTaskCode() - bean.description = freeTaskTitle - val time = currentTimeMillis.timestampToCompleteDate() - bean.createTime = time - bean.status = "0" - val userName = SaveKeyValues.getValue(LocaleConstant.USER_NAME, "") as String - bean.createUserName = userName - bean.startTime = time - bean.endTime = "" - bean.isFreeTask = "1" - DataBaseManager.get.saveTaskInLocale(bean) - } - taskViewModel.uploadTaskMarkerResult.observe(this) { - "自由巡检任务已完成".show(this) - ids.clear() - //清空自由巡检添加的Marker - aMap.clear() - showMarkersOnMap() - } - taskViewModel.executeTaskResult.observe(this) { - "工单任务已完成".show(this) - aMap.clear() - showMarkersOnMap() - } } override fun initEvent() { @@ -216,7 +139,7 @@ }).build().show() } else { lifecycleScope.launch(Dispatchers.Main) { - val markers = DataBaseManager.get.queryMarkerByState("0") + val markers = taskMarkerBeanDao.queryMarkerByState("0") //如果有需要补全的标识器,Popup右侧会有小圆点提示 if (markers.isNotEmpty()) { samplePopupWindow.setShowPosition(4) @@ -239,13 +162,7 @@ 3 -> uploadEvent() 4 -> completionMarker() 5 -> showRtkConfigDialog() - 6 -> { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { - SatelliteStatusDialog(context).show() - } else { - "卫星数据仅支持Android 7.0以上系统".show(context) - } - } + 6 -> SatelliteStatusDialog(context).show() } } }) @@ -268,25 +185,23 @@ //查看 binding.viewButton.setOnClickListener { - QueryMarkerDialog.Builder().setContext(this).setTitle("查看标识器") - .setSpinnerArray(LocaleConstant.SPINNER_ARRAY).setNegativeButton("取消") + QueryMarkerDialog.Builder() + .setContext(this) + .setTitle("查看标识器") + .setSpinnerArray(LocaleConstant.SPINNER_ARRAY) + .setNegativeButton("取消") .setPositiveButton("确定").setOnDialogButtonClickListener(object : QueryMarkerDialog.OnDialogButtonClickListener { override fun onConfirmClick(selectedItem: String, value: String) { //查询数据库 - lifecycleScope.launch(Dispatchers.Main) { - val markers = DataBaseManager.get.loadMarkersByCondition( - selectedItem, value - ) as ArrayList - - if (markers.isEmpty()) { - "无法查到相关数据信息,请检查您的查询条件".show(context) - } else { + val buildQuery = LocaleConstant.buildQuery(selectedItem, value) + markerBeanDao.loadMarkersByCondition(buildQuery).run { + if (isNotEmpty()) { val latitudeList = ArrayList() val longitudeList = ArrayList() - val latitude = markers.first().lat - val longitude = markers.first().lng + val latitude = first().lat + val longitude = first().lng if (latitude.isNotBlank() && longitude.isNotBlank()) { if (CoordinateConverter.isAMapDataAvailable( latitude.toDouble(), longitude.toDouble() @@ -300,10 +215,11 @@ if (latitudeList.isNotEmpty() && longitudeList.isNotEmpty()) { //移动地图到所有labelBeans的第一个点 - val center = LatLng(latitudeList.first(), longitudeList.first()) - //移动到指定经纬度 - aMap.moveCamera(CameraUpdateFactory.newLatLngZoom(center, 16f)) + val target = LatLng(latitudeList.first(), longitudeList.first()) + aMap.moveCamera(CameraUpdateFactory.newLatLngZoom(target, 16f)) } + } else { + "无法查到相关信息,请检查您的查询条件".show(context) } } } @@ -316,32 +232,39 @@ //巡检 binding.inspectionButton.setOnClickListener { - val tasks = DataBaseManager.get.loadLocalTask() - if (tasks.isNotEmpty()) { - val arrayList = ArrayList() - tasks.forEachIndexed { index, task -> - arrayList.add("任务${index + 1}:${task.taskId},${task.description}") + lifecycleScope.launch { + val tasks = withContext(Dispatchers.IO) { + taskBeanDao.loadLocalTask(taskMarkerBeanDao) } + if (tasks.isNotEmpty()) { + val arrayList = ArrayList() + tasks.forEachIndexed { index, task -> + arrayList.add("任务${index + 1}:${task.taskId},${task.description}") + } - BottomActionSheet.Builder().setContext(this).setItemTextColor(Color.BLUE) - .setActionItemTitle(arrayList) - .setOnActionSheetListener(object : BottomActionSheet.OnActionSheetListener { - override fun onActionItemClick(position: Int) { - val task = tasks[position] - SaveKeyValues.putValue(LocaleConstant.TASK_ID, task.taskId) - SaveKeyValues.putValue(LocaleConstant.TASK_CODE, task.taskCode) - executeTask(task) - } - }).build().show() - } else { - AlertMessageDialog.Builder().setContext(this).setTitle("温馨提示") - .setMessage("所有任务已完成,请点击右上角菜单下载新工单或者开始自由巡检") - .setPositiveButton("开始自由巡检").setOnDialogButtonClickListener(object : - AlertMessageDialog.OnDialogButtonClickListener { - override fun onConfirmClick() { - executeFreeTask() - } - }).build().show() + BottomActionSheet.Builder().setContext(context) + .setItemTextColor(Color.BLUE) + .setActionItemTitle(arrayList) + .setOnActionSheetListener(object : BottomActionSheet.OnActionSheetListener { + override fun onActionItemClick(position: Int) { + val task = tasks[position] + SaveKeyValues.putValue(LocaleConstant.TASK_ID, task.taskId) + SaveKeyValues.putValue(LocaleConstant.TASK_CODE, task.taskCode) + executeTask(task) + } + }).build().show() + } else { + AlertMessageDialog.Builder() + .setContext(context) + .setTitle("温馨提示") + .setMessage("所有任务已完成,请点击右上角菜单下载新工单或者开始自由巡检") + .setPositiveButton("开始自由巡检").setOnDialogButtonClickListener(object : + AlertMessageDialog.OnDialogButtonClickListener { + override fun onConfirmClick() { + executeFreeTask() + } + }).build().show() + } } } @@ -371,8 +294,11 @@ //自由巡检 binding.stopFreeTaskButton.setOnLongClickListener { - AlertMessageDialog.Builder().setContext(this).setTitle("温馨提示") - .setMessage("是否确定结束此次自由巡检任务?").setPositiveButton("是") + AlertMessageDialog.Builder() + .setContext(this) + .setTitle("温馨提示") + .setMessage("是否确定结束此次自由巡检任务?") + .setPositiveButton("是") .setOnDialogButtonClickListener(object : AlertMessageDialog.OnDialogButtonClickListener { override fun onConfirmClick() { @@ -381,14 +307,38 @@ stopSerialPortCommand() binding.stopFreeTaskButton.visibility = View.GONE - if (freeTaskId.isNullOrBlank()) { + if (freeTaskId == 0L) { "任务ID异常,无法提交任务,请联系服务器管理员".show(context) return } - freeTaskId?.apply { - taskViewModel.uploadTaskMarker(context, this, ids) - } + taskViewModel.uploadTaskMarker( + freeTaskId, + ids, + onLoading = { + LoadingDialog.show(context, "任务提交中,请稍后...") + }, + onSuccess = { + LoadingDialog.dismiss() + "自由巡检任务已完成".show(context) + ids.clear() + aMap.clear() + showMarkersOnMap() + + //删除本地数据库 + val taskCode = SaveKeyValues.getValue( + LocaleConstant.TASK_CODE, "" + ) as String + taskBeanDao.deleteLocalTaskById( + freeTaskId, taskCode, taskMarkerBeanDao + ) + SaveKeyValues.putValue(LocaleConstant.TASK_ID, "") + }, + onFailed = { + LoadingDialog.dismiss() + it.show(context) + } + ) } }).build().show() true @@ -399,25 +349,52 @@ RtkConfigDialog(this).setOnDialogButtonClickListener(object : RtkConfigDialog.OnDialogButtonClickListener { override fun onConfirmClick() { - NtripConnectService.weakReferenceHandler?.apply { - sendEmptyMessage(2024082201) - } + NtripConnectService.weakReferenceHandler?.sendEmptyMessage(2024082201) } }).show() } private fun uploadTask(taskId: String, taskCode: String, state: String) { if (isNetworkConnected()) { - val userId = SaveKeyValues.getValue(LocaleConstant.USER_ID, "") as String - taskViewModel.uploadTask(this, userId, taskId, taskCode, state) + taskViewModel.uploadTask( + taskId, state, + onLoading = { + LoadingDialog.show(this, "工单提交中,请稍后...") + }, + onSuccess = { + LoadingDialog.dismiss() + //工单提交之后,并且状态是2,删除本地Task记录 + if (state == "2") { + "工单${taskId}已提交!".show(this) + //删除本地数据库 + taskBeanDao.deleteLocalTaskById( + taskId.toLong(), taskCode, taskMarkerBeanDao + ) + SaveKeyValues.putValue(LocaleConstant.TASK_ID, "") + } else { + Log.d(kTag, "uploadTask: 仅执行工单,不删除本地工单数据") + } + aMap.clear() + showMarkersOnMap() + "工单任务已完成".show(this) + }, + onFailed = { + LoadingDialog.dismiss() + it.show(this) + } + ) } else { "网络连接已断开,请检查".show(this) } } private fun executeTask(task: TaskDetailLocalModel) { - AlertControlDialog.Builder().setContext(this).setTitle("提示").setMessage("请选择操作方式") - .setPositiveButton("执行工单").setNegativeButton("提交工单") + AlertControlDialog.Builder() + .setContext(this) + .setTitle("提示") + .setMessage("请选择操作方式") + .setPositiveButton("执行工单") + .setNegativeButton("提交工单") .setOnDialogButtonClickListener(object : AlertControlDialog.OnDialogButtonClickListener { override fun onConfirmClick() { @@ -432,7 +409,7 @@ isExecuteTask = true } else { "此工单下无标识器,将执行自由巡检任务".show(context) - freeTaskId = task.taskId + freeTaskId = task.taskId.toLong() detectMarker() } } @@ -453,7 +430,18 @@ override fun onConfirmClick(value: String) { freeTaskTitle = value val userId = SaveKeyValues.getValue(LocaleConstant.USER_ID, "") as String - taskViewModel.createFreeTask(context, userId, value) + taskViewModel.createFreeTask( + userId, value, + onLoading = {}, + onSuccess = { + freeTaskId = it + // 自由巡检保存在本地 + taskBeanDao.saveTask(it, freeTaskTitle) + }, + onFailed = { + it.show(context) + } + ) detectMarker() } @@ -481,7 +469,7 @@ if (RuntimeCache.currentSegment == CurrentSegment.FreeInspection) { //显示标识器详细信息 if (!detailDialog.isShowing) { - DataBaseManager.get.queryMarkerById(markerId).firstOrNull().apply { + markerBeanDao.queryMarkerById(markerId).firstOrNull().apply { if (this == null) { "无法查询到此ID【${markerId}】的信息".show(context) } else { @@ -501,7 +489,7 @@ //不重复标注Marker if (!ids.contains(markerId)) { - val markers = DataBaseManager.get.queryMarkerById(markerId) + val markers = markerBeanDao.queryMarkerById(markerId) if (markers.isNotEmpty()) { val marker = markers.first() val latLng = LatLng(marker.lat.toDouble(), marker.lng.toDouble()) @@ -522,16 +510,6 @@ } - override fun observeRequestState() { - taskViewModel.loadState.observe(this) { - when (it) { - LoadState.Loading -> LoadingDialog.show(this, "提交工单中,请稍后") - - else -> LoadingDialog.dismiss() - } - } - } - private fun initMapConfig(savedInstanceState: Bundle?) { binding.mapView.onCreate(savedInstanceState) aMap = binding.mapView.map @@ -592,54 +570,25 @@ private fun saveUserTasks(task: TaskModel) { task.message.forEach { model -> //保存任务详情 - DataBaseManager.get.saveTaskInLocale(model) + taskBeanDao.saveTask(model) model.taskDetailInfos.forEach { marker -> //只保存有标识器ID得数据 if (!marker.markerIdReal.isNullOrBlank()) { - DataBaseManager.get.saveTaskMarkerInLocale(model.id, model.taskCode, marker) + taskMarkerBeanDao.saveTaskMarker(model.id, model.taskCode, marker) } } } "工单下载成功!".show(this) } - private fun showMarkersOnMap() { - lifecycleScope.launch(Dispatchers.IO) { - //取缓存 - val markers = DataBaseManager.get.loadMarkers() - if (markers.isEmpty()) { - return@launch - } - val first = markers.first() - val defaultLatLng = LatLng(first.lat.toDouble(), first.lng.toDouble()) - //移动到指定经纬度 - val cameraPosition = CameraPosition(defaultLatLng, 14f, 0f, 0f) - val cameraUpdate = CameraUpdateFactory.newCameraPosition(cameraPosition) - withContext(Dispatchers.Main) { - aMap.animateCamera(cameraUpdate, 1500, null) - LoadingDialog.dismiss() - } - - markers.forEach { marker -> - val latitude = marker.lat.toString().toDouble() - val longitude = marker.lng.toString().toDouble() - //将所有设备信息转化缓存为Marker点 - val options = MarkerOptions() - .position(LatLng(latitude, longitude)) - .title(marker.markerId) - aMap.addMarker(options) - } - } - } - override fun onMarkerClick(marker: Marker?): Boolean { - marker?.apply { - showNavigationOption(title, position) + marker?.let { + showNavigationOption(it.title, it.position) } return true } - override fun onMapLongClick(p0: LatLng?) { + override fun onMapLongClick(latLng: LatLng?) { showMarkersOnMap() } @@ -664,7 +613,7 @@ } override fun onCancelClick() { - val result = DataBaseManager.get.queryMarkerById(title) + val result = markerBeanDao.queryMarkerById(title) MarkerDetailDialog(context).setMarker(result.first()).show() } }).build().show() @@ -695,20 +644,24 @@ //更新标识器数据 private fun updateMarkers() { - AlertControlDialog.Builder().setContext(this).setTitle("提示").setMessage("是否更新数据?") - .setNegativeButton("取消").setPositiveButton("确定") + AlertControlDialog.Builder() + .setContext(this) + .setTitle("提示") + .setMessage("是否更新数据?") + .setNegativeButton("取消") + .setPositiveButton("确定") .setOnDialogButtonClickListener(object : AlertControlDialog.OnDialogButtonClickListener { override fun onConfirmClick() { if (isNetworkConnected()) { - val companyId = SaveKeyValues.getValue(LocaleConstant.USER_COMPANY_ID, "") - - LoadingDialog.show(this@MainActivity, "获取标识器信息中,请稍后") - /** - * 后台设计如此,都传companyId - * */ + //清空之前的数据 + markerBeanDao.deleteAll() + aMap.clear() + //获取标识器数据 taskViewModel.getMarkerFile( - context, companyId.toString(), companyId.toString() + onLoading = {}, + onSuccess = { handleMarkerFile(it) }, + onFailed = { it.show(context) } ) } else { "网络连接已断开,请检查".show(context) @@ -721,11 +674,105 @@ }).build().show() } + private fun handleMarkerFile(it: MarkerFileModel) { + if (it.isSuccess) { + //下载最新的数据 + val companyId = SaveKeyValues.getValue(LocaleConstant.USER_COMPANY_ID, "") + val downloadUrl = companyId.toString().appendDownloadUrl(FileType.Excel) + Log.d(kTag, "handleMarkerFile => $downloadUrl") + FileDownloadManager.Builder() + .setDownloadFileSource(downloadUrl) + .setFileSuffix("xls") + .setFileSaveDirectory(createDownloadFileDir()) + .setOnFileDownloadListener(object : FileDownloadManager.OnFileDownloadListener { + override fun onDownloadStart(total: Long) { + LoadingDialog.show(context, "标识器数据解析中,请稍后...") + } + + override fun onDownloadEnd(file: File) { + lifecycleScope.launch(Dispatchers.IO) { + ExcelKit.read(file.absolutePath).apply { + renderMarkers(this) + }.also { + withContext(Dispatchers.Main) { + LoadingDialog.dismiss() + "标识器数据渲染完成".show(context) + } + } + } + } + + override fun onDownloadFailed(t: Throwable) { + t.printStackTrace() + LoadingDialog.dismiss() + "标识器数据下载失败".show(context) + } + + override fun onProgressChanged(progress: Long) { + + } + }).build().start() + } + } + + private fun showMarkersOnMap() { + lifecycleScope.launch(Dispatchers.IO) { + //取缓存 + markerBeanDao.loadAll().run { + renderMarkers(this) + }.also { + withContext(Dispatchers.Main) { + "标识器数据渲染完成".show(context) + } + } + } + } + + private fun renderMarkers(markers: List) { + if (markers.isEmpty()) { + return + } + val first = markers.first() + val defaultLatLng = LatLng(first.lat.toDouble(), first.lng.toDouble()) + //移动到指定经纬度 + val cameraPosition = CameraPosition(defaultLatLng, 14f, 0f, 0f) + val cameraUpdate = CameraUpdateFactory.newCameraPosition(cameraPosition) + aMap.animateCamera(cameraUpdate, 1500, null) + markers.forEach { marker -> + val latitude = marker.lat.toString().toDouble() + val longitude = marker.lng.toString().toDouble() + //将所有设备信息转化缓存为Marker点 + val options = MarkerOptions() + .position(LatLng(latitude, longitude)) + .title(marker.markerId) + aMap.addMarker(options) + } + } + //下载工单 private fun downloadTask() { if (isNetworkConnected()) { - val userName = SaveKeyValues.getValue(LocaleConstant.USER_NAME, "") - taskViewModel.getTasksByUser(this, userName.toString()) + taskViewModel.getTasksByUser( + onLoading = {}, + onSuccess = { + if (it.success == "true") { + AlertMessageDialog.Builder() + .setContext(this) + .setTitle("温馨提示") + .setMessage("您有${it.message.size}个新任务!") + .setPositiveButton("知道了") + .setOnDialogButtonClickListener(object : + AlertMessageDialog.OnDialogButtonClickListener { + override fun onConfirmClick() { + saveUserTasks(it) + } + }).build().show() + } + }, + onFailed = { + it.show(this) + } + ) } else { "网络连接已断开,请检查".show(this) } @@ -744,7 +791,7 @@ //标识器补全 private fun completionMarker() { val companyId = SaveKeyValues.getValue(LocaleConstant.USER_COMPANY_ID, "") as String - val markers = DataBaseManager.get.queryMarkerByState("0") + val markers = taskMarkerBeanDao.queryMarkerByState("0") if (markers.isNotEmpty()) { //TODO 逻辑没梳理明白 } else { diff --git a/app/src/main/java/com/casic/common/detector/gd/view/SearchMarkerActivity.kt b/app/src/main/java/com/casic/common/detector/gd/view/SearchMarkerActivity.kt index 4a92c97..b2e3301 100644 --- a/app/src/main/java/com/casic/common/detector/gd/view/SearchMarkerActivity.kt +++ b/app/src/main/java/com/casic/common/detector/gd/view/SearchMarkerActivity.kt @@ -1,6 +1,5 @@ package com.casic.common.detector.gd.view -import android.content.Context import android.content.res.ColorStateList import android.graphics.Color import android.hardware.Sensor @@ -13,18 +12,19 @@ import android.os.Handler import android.os.Looper import android.view.View +import androidx.core.graphics.toColorInt import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.lifecycleScope import com.amap.api.location.AMapLocation import com.amap.api.maps.AMapUtils import com.amap.api.maps.model.LatLng import com.casic.common.detector.gd.R +import com.casic.common.detector.gd.base.BaseApplication import com.casic.common.detector.gd.base.SerialPortBaseActivity import com.casic.common.detector.gd.callback.OnGetLocationListener import com.casic.common.detector.gd.databinding.ActivitySearchMarkerBinding import com.casic.common.detector.gd.model.MarkerDistanceData import com.casic.common.detector.gd.utils.CurrentSegment -import com.casic.common.detector.gd.utils.DataBaseManager import com.casic.common.detector.gd.utils.LocaleConstant import com.casic.common.detector.gd.utils.LocationKit import com.casic.common.detector.gd.utils.RuntimeCache @@ -50,8 +50,10 @@ private val context = this private val locationKit by lazy { LocationKit(this) } private val markerPoints by lazy { ArrayList() } + private val markerBeanDao by lazy { BaseApplication.get().dataBase.markerBeanDao() } + private val taskMarkerBeanDao by lazy { BaseApplication.get().dataBase.taskMarkerBeanDao() } private val taskViewModel by lazy { ViewModelProvider(this)[TaskViewModel::class.java] } - private val sensorManager by lazy { getSystemService(Context.SENSOR_SERVICE) as SensorManager } + private val sensorManager by lazy { getSystemService(SENSOR_SERVICE) as SensorManager } private val attr = AudioAttributes.Builder().setUsage(AudioAttributes.USAGE_ALARM) .setContentType(AudioAttributes.CONTENT_TYPE_MUSIC).build() private val soundPool = SoundPool.Builder().setMaxStreams(16).setAudioAttributes(attr).build() @@ -109,7 +111,7 @@ override fun initEvent() { binding.depthButton.setOnClickListener { RuntimeCache.currentSegment = CurrentSegment.DetectDepth - val result = DataBaseManager.get.queryMarkerById(markerId) + val result = markerBeanDao.queryMarkerById(markerId) if (result.isNotEmpty()) { val command = when (result.first().markerType) { "EM30" -> SerialPortCommand.DETECT_EM30_DEPTH @@ -139,7 +141,7 @@ } binding.markerInfoButton.setOnClickListener { - val result = DataBaseManager.get.queryMarkerById(markerId) + val result = markerBeanDao.queryMarkerById(markerId) if (result.isNotEmpty()) { MarkerDetailDialog(this).setMarker(result.first()).show() } else { @@ -154,12 +156,12 @@ binding.depthButton.isEnabled = true binding.depthButton.setTextColor(Color.WHITE) binding.depthButton.backgroundTintList = - ColorStateList.valueOf(Color.parseColor("#004364")) + ColorStateList.valueOf("#004364".toColorInt()) binding.markerInfoButton.isEnabled = true binding.markerInfoButton.setTextColor(Color.WHITE) binding.markerInfoButton.backgroundTintList = - ColorStateList.valueOf(Color.parseColor("#FFA200")) + ColorStateList.valueOf("#FFA200".toColorInt()) handleMarker(markerId) } @@ -171,12 +173,22 @@ if (isExecuteTask) { val taskId = SaveKeyValues.getValue(LocaleConstant.TASK_ID, "") as String val taskCode = SaveKeyValues.getValue(LocaleConstant.TASK_CODE, "") as String - val taskMarkerLocalBean = DataBaseManager.get.queryTaskMarkerById( + val marker = taskMarkerBeanDao.queryTaskMarkerById( taskId, taskCode, id, "0" ) - taskMarkerLocalBean?.apply { - taskViewModel.uploadMarker(context, this) + if (marker == null) { + return } + taskViewModel.uploadMarker( + marker.markerId, + onLoading = {}, + onSuccess = { + "标识器${marker.markerId}已探测!".show(this) + marker.isDetected = "1" + taskMarkerBeanDao.updateLocalTaskMarkerState(marker) + }, + onFailed = {} + ) } } @@ -185,15 +197,22 @@ detectDepthRunnable?.let { handler.removeCallbacks(it) } detectDepthRunnable = null LoadingDialog.dismiss() - AlertMessageDialog.Builder().setContext(context).setTitle("温馨提示") - .setMessage("标识器埋深:${depth}厘米").setPositiveButton("知道了") - .setOnDialogButtonClickListener(object : - AlertMessageDialog.OnDialogButtonClickListener { - override fun onConfirmClick() { - RuntimeCache.currentSegment = CurrentSegment.SearchMarker - sendSerialPortCommand(SerialPortCommand.SEARCH_SIGNAL) - } - }).build().show() + if (!this.isDestroyed) { + AlertMessageDialog.Builder() + .setContext(context) + .setTitle("温馨提示") + .setMessage("标识器埋深:${depth}厘米") + .setPositiveButton("知道了") + .setOnDialogButtonClickListener(object : + AlertMessageDialog.OnDialogButtonClickListener { + override fun onConfirmClick() { + RuntimeCache.currentSegment = CurrentSegment.SearchMarker + sendSerialPortCommand(SerialPortCommand.SEARCH_SIGNAL) + } + }).build().show() + } else { + "标识器埋深:${depth}厘米".show(this) + } } } @@ -201,13 +220,13 @@ if (RuntimeCache.currentSegment == CurrentSegment.SearchMarker) { if (signalEnergy > 1000) { binding.markerIdButton.isEnabled = true - binding.markerIdButton.setTextColor(Color.parseColor("#428d00")) + binding.markerIdButton.setTextColor("#428d00".toColorInt()) binding.markerIdButton.backgroundTintList = ColorStateList.valueOf( - Color.parseColor("#7EFF00") + "#7EFF00".toColorInt() ) binding.searchResultView.text = "已检测到标识器" - binding.searchResultView.setTextColor(Color.parseColor("#428d00")) + binding.searchResultView.setTextColor("#428d00".toColorInt()) binding.searchResultView.setBackgroundResource(R.mipmap.bg_small_text_green) } @@ -230,19 +249,19 @@ signalEnergy <= 700 -> { setEnergyTip( "信号较弱,可能距离较远", - Color.parseColor("#8D1717"), + "#8D1717".toColorInt(), R.mipmap.bg_large_text_red ) disableButtons() binding.searchResultView.text = "未检测到标识器" - binding.searchResultView.setTextColor(Color.parseColor("#8D1717")) + binding.searchResultView.setTextColor("#8D1717".toColorInt()) binding.searchResultView.setBackgroundResource(R.mipmap.bg_small_text_red) } signalEnergy >= 4100 -> { setEnergyTip( "信号极强,接近标识器正上方", - Color.parseColor("#428d00"), + "#428d00".toColorInt(), R.mipmap.bg_large_text_green ) } @@ -250,7 +269,7 @@ else -> { setEnergyTip( "已靠近,请继续移动位置", - Color.parseColor("#8C5700"), + "#8C5700".toColorInt(), R.mipmap.bg_large_text_yellow ) } @@ -263,8 +282,8 @@ binding.energyTipsView.setBackgroundResource(backgroundRes) } - private val colorStateList = ColorStateList.valueOf(Color.parseColor("#8A8A8A")) - private val textColor = Color.parseColor("#CCCCCC") + private val colorStateList = ColorStateList.valueOf("#8A8A8A".toColorInt()) + private val textColor = "#CCCCCC".toColorInt() private fun disableButtons() { binding.depthButton.isEnabled = false @@ -287,7 +306,7 @@ val latitude = location.latitude lifecycleScope.launch(Dispatchers.IO) { val dataPoints = ArrayList() - DataBaseManager.get.loadMarkers().forEach { + markerBeanDao.loadAll().forEach { val distance = AMapUtils.calculateLineDistance( LatLng(it.lat.toDouble(), it.lng.toDouble()), LatLng(latitude, longitude) ) @@ -332,10 +351,6 @@ return ActivitySearchMarkerBinding.inflate(layoutInflater) } - override fun observeRequestState() { - - } - override fun setupTopBarLayout() { } diff --git a/app/build.gradle b/app/build.gradle index d0cb423..921c8c8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,25 +1,20 @@ import java.text.SimpleDateFormat -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply plugin: 'org.greenrobot.greendao' +plugins { + id('com.android.application') + id('org.jetbrains.kotlin.android') +} android { - compileSdkVersion 33 + namespace 'com.casic.common.detector.gd' + compileSdk 35 defaultConfig { - applicationId "com.casic.common.detector.gd" - minSdkVersion 26 - targetSdkVersion 33 + applicationId 'com.casic.common.detector.gd' + minSdk 26 + targetSdk 35 versionCode 5092 - versionName "5.0.9.2" - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } + versionName '5.0.9.2' } signingConfigs { @@ -31,6 +26,14 @@ } } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + signingConfig signingConfigs.release + } + } + compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 @@ -47,27 +50,16 @@ } } - kotlin { - experimental { - coroutines 'enable' - } - } - buildFeatures { + buildConfig true viewBinding true } - applicationVariants.configureEach { variant -> - variant.outputs.configureEach { - outputFileName = "COM_TCY_" + getBuildDate() + "_" + defaultConfig.versionName + ".apk" + applicationVariants.configureEach { + outputs.configureEach { + outputFileName = 'COM_TCY_' + getBuildDate() + '_' + defaultConfig.versionName + '.apk' } } - - greendao { - schemaVersion 1//数据库版本号 - targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 - daoPackage "${defaultConfig.applicationId}.greendao"//设置DaoMaster、DaoSession、Dao包名 - } } static def getBuildDate() { @@ -76,27 +68,22 @@ } dependencies { - //基础依赖库 - implementation 'com.github.AndroidCoderPeng:Kotlin-lite-lib:1.1.4' - implementation 'androidx.core:core-ktx:1.9.0' - def base_version = "1.6.1" - implementation "androidx.appcompat:appcompat:${base_version}" - implementation "com.google.android.material:material:${base_version}" + implementation 'com.github.AndroidCoderPeng:Kotlin-lite-lib:1.1.5' + implementation 'androidx.core:core-ktx:1.13.1' + implementation 'androidx.appcompat:appcompat:1.7.0' + implementation 'com.google.android.material:material:1.12.0' //Google官方授权框架 implementation 'pub.devrel:easypermissions:3.0.0' - //沉浸式状态栏。基础依赖包,必须要依赖 - implementation 'com.gyf.immersionbar:immersionbar:3.0.0' - //fragment快速实现 - implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0' + //沉浸式状态栏 + implementation 'com.geyifeng.immersionbar:immersionbar:3.2.2' //官方Json解析库 implementation 'com.google.code.gson:gson:2.10.1' - def vm_version = '2.5.1' //Kotlin协程 - implementation "androidx.lifecycle:lifecycle-runtime-ktx:${vm_version}" + implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.2' //MVVM+LiveData - implementation "androidx.lifecycle:lifecycle-livedata-ktx:${vm_version}" - implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:${vm_version}" - implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.6.2' + implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2' + implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' //返回值转换器 implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' @@ -105,9 +92,10 @@ implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' //网络请求和接口封装 implementation 'com.squareup.retrofit2:retrofit:2.9.0' - implementation 'com.squareup.okhttp3:okhttp:4.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.12.0' //数据库框架 - implementation 'org.greenrobot:greendao:3.3.0' + implementation 'androidx.room:room-runtime:2.6.1' + annotationProcessor 'androidx.room:room-compiler:2.5.2' //高德导航、定位、地图三合一 implementation 'com.amap.api:navi-3dmap:latest.integration' //经纬度逆编码 @@ -115,7 +103,7 @@ //excel implementation 'net.sourceforge.jexcelapi:jxl:2.6.12' //图片加载框架 - implementation 'com.github.bumptech.glide:glide:4.9.0' + implementation 'com.github.bumptech.glide:glide:4.12.0' //图片选择框架 implementation 'io.github.lucksiege:pictureselector:v3.11.1' //大图 diff --git a/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt b/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt index 7b695ff..50ba734 100644 --- a/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt +++ b/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt @@ -4,9 +4,9 @@ import android.app.Application import android.os.Bundle import android.util.Log -import com.casic.common.detector.gd.greendao.DaoMaster -import com.casic.common.detector.gd.greendao.DaoSession +import androidx.room.Room.databaseBuilder import com.casic.common.detector.gd.uart.SerialPort +import com.casic.common.detector.gd.utils.DetectorDataBase import com.casic.common.detector.gd.utils.GpioManager import com.pengxh.kt.lite.extensions.show import com.pengxh.kt.lite.utils.SaveKeyValues @@ -43,44 +43,42 @@ private var application: BaseApplication by Delegates.notNull() fun get() = application - - private lateinit var daoSession: DaoSession } + lateinit var dataBase: DetectorDataBase + override fun onCreate() { super.onCreate() application = this SaveKeyValues.initSharedPreferences(this) CrashReport.initCrashReport(this, "01e80d3a74", true) - val devOpenHelper = DaoMaster.DevOpenHelper(this, "Detector.db", null) - val daoMaster = DaoMaster(devOpenHelper.writableDatabase) - daoSession = daoMaster.newSession() + dataBase = databaseBuilder(this, DetectorDataBase::class.java, "Detector.db") + .allowMainThreadQueries() + .build() /** * Open the serial port * */ try { serialPorts.apply { - add(SerialPort(File("/dev/ttysWK1"), 9600, 0)) - //千寻报文数据下发串口号 - add(SerialPort(File("/dev/ttyS1"), 9600, 0)) + add(SerialPort(File("/dev/ttysWK1"), 9600, 0)) //信号通讯串口 + add(SerialPort(File("/dev/ttyS1"), 9600, 0)) //千寻报文数据下发串口号 } Log.d(kTag, "onCreate: 已初始化 ${serialPorts.size} 个串口") } catch (e: SecurityException) { "您没有串口的读写权限!".show(this) + e.printStackTrace() } catch (e: IOException) { "因为不明原因,串口无法打开!".show(this) + e.printStackTrace() } catch (e: InvalidParameterException) { "请检查串口!".show(this) + e.printStackTrace() } registerActivityLifecycleCallbacks(this) } - fun getDaoSession(): DaoSession { - return daoSession - } - override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) { } diff --git a/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt b/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt index 053b9dd..1d0c9e3 100644 --- a/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt +++ b/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt @@ -14,12 +14,10 @@ import com.casic.common.detector.gd.utils.SerialPortCommand import com.pengxh.kt.lite.utils.WeakReferenceHandler import java.io.IOException -import java.util.Timer abstract class SerialPortBaseActivity : AppCompatActivity(), Handler.Callback { private val kTag = "SerialPortBaseActivity" - private val taskTimer by lazy { Timer() } private val weakReferenceHandler by lazy { WeakReferenceHandler(this) } private val serialPorts by lazy { BaseApplication.get().getSerialPorts() } protected lateinit var binding: VB @@ -30,7 +28,6 @@ setContentView(binding.root) setupTopBarLayout() initOnCreate(savedInstanceState) - observeRequestState() initEvent() if (serialPorts.isNotEmpty()) { @@ -71,11 +68,6 @@ abstract fun initOnCreate(savedInstanceState: Bundle?) /** - * 数据请求状态监听 - */ - abstract fun observeRequestState() - - /** * 初始化业务逻辑 */ abstract fun initEvent() diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java new file mode 100644 index 0000000..7a18c20 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java @@ -0,0 +1,255 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 从平台下载的标识器本地库实体类 + */ +@Entity(tableName = "marker_detail") +public class MarkerBean { + @PrimaryKey(autoGenerate = true) + private long id; //主键ID + private String pipelineType; // 管线类型 + private String pipelineDiameter; // 管线直径 + private String pipelineMaterial; // 管材 + private String buryMethod; // 埋设方式 + private String buryDepth; // 埋深 + private String area; // 所属区域 + private String line; // 所属线路 + private String road; // 所属道路 + private String constructTime; // 建设年代 + private String owner; // 权属单位 + private String objectId; // 标识对象ID,无实际用途 + private String markerId; // 标识器ID + private String markerType; // 标识器类型 + private String markerDepth; // 标识器埋深 + private String installationDept; // 安装部门 + private String lng; // 经度 + private String lat; // 纬度 + private String updateTime; // 最后修改时间,更新时间 + private String remark; // 备注信息 + private String underlyingPipelineType; // 下层管线类型 + private String underlyingPipelineDepth; // 下层埋深 + private String underlyingPipelineDiameter; // 下层管径 + private String underlyingPipelineMaterial; // 下层管材 + private String objectType; //标识对象类型 + private String color; // 颜色 + private String imagePath; // 图片路径 + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getPipelineType() { + return pipelineType; + } + + public void setPipelineType(String pipelineType) { + this.pipelineType = pipelineType; + } + + public String getPipelineDiameter() { + return pipelineDiameter; + } + + public void setPipelineDiameter(String pipelineDiameter) { + this.pipelineDiameter = pipelineDiameter; + } + + public String getPipelineMaterial() { + return pipelineMaterial; + } + + public void setPipelineMaterial(String pipelineMaterial) { + this.pipelineMaterial = pipelineMaterial; + } + + public String getBuryMethod() { + return buryMethod; + } + + public void setBuryMethod(String buryMethod) { + this.buryMethod = buryMethod; + } + + public String getBuryDepth() { + return buryDepth; + } + + public void setBuryDepth(String buryDepth) { + this.buryDepth = buryDepth; + } + + public String getArea() { + return area; + } + + public void setArea(String area) { + this.area = area; + } + + public String getLine() { + return line; + } + + public void setLine(String line) { + this.line = line; + } + + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + + public String getConstructTime() { + return constructTime; + } + + public void setConstructTime(String constructTime) { + this.constructTime = constructTime; + } + + public String getOwner() { + return owner; + } + + public void setOwner(String owner) { + this.owner = owner; + } + + public String getObjectId() { + return objectId; + } + + public void setObjectId(String objectId) { + this.objectId = objectId; + } + + public String getMarkerId() { + return markerId; + } + + public void setMarkerId(String markerId) { + this.markerId = markerId; + } + + public String getMarkerType() { + return markerType; + } + + public void setMarkerType(String markerType) { + this.markerType = markerType; + } + + public String getMarkerDepth() { + return markerDepth; + } + + public void setMarkerDepth(String markerDepth) { + this.markerDepth = markerDepth; + } + + public String getInstallationDept() { + return installationDept; + } + + public void setInstallationDept(String installationDept) { + this.installationDept = installationDept; + } + + public String getLng() { + return lng; + } + + public void setLng(String lng) { + this.lng = lng; + } + + public String getLat() { + return lat; + } + + public void setLat(String lat) { + this.lat = lat; + } + + public String getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } + + public String getUnderlyingPipelineType() { + return underlyingPipelineType; + } + + public void setUnderlyingPipelineType(String underlyingPipelineType) { + this.underlyingPipelineType = underlyingPipelineType; + } + + public String getUnderlyingPipelineDepth() { + return underlyingPipelineDepth; + } + + public void setUnderlyingPipelineDepth(String underlyingPipelineDepth) { + this.underlyingPipelineDepth = underlyingPipelineDepth; + } + + public String getUnderlyingPipelineDiameter() { + return underlyingPipelineDiameter; + } + + public void setUnderlyingPipelineDiameter(String underlyingPipelineDiameter) { + this.underlyingPipelineDiameter = underlyingPipelineDiameter; + } + + public String getUnderlyingPipelineMaterial() { + return underlyingPipelineMaterial; + } + + public void setUnderlyingPipelineMaterial(String underlyingPipelineMaterial) { + this.underlyingPipelineMaterial = underlyingPipelineMaterial; + } + + public String getObjectType() { + return objectType; + } + + public void setObjectType(String objectType) { + this.objectType = objectType; + } + + public String getColor() { + return color; + } + + public void setColor(String color) { + this.color = color; + } + + public String getImagePath() { + return imagePath; + } + + public void setImagePath(String imagePath) { + this.imagePath = imagePath; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java deleted file mode 100644 index 3f2fcdc..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java +++ /dev/null @@ -1,327 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 从平台下载的标识器本地库实体类 - */ -@Entity -public class MarkerLocalBean { - @Id(autoincrement = true) - private Long id;//本地库主键ID - - // 管线类型 - private String pipelineType; - // 管线直径 - private String pipelineDiameter; - // 管材 - private String pipelineMaterial; - // 埋设方式 - private String buryMethod; - // 埋深 - private String buryDepth; - // 所属区域 - private String area; - // 所属线路 - private String line; - // 所属道路 - private String road; - // 建设年代 - private String constructTime; - // 权属单位 - private String owner; - //标识对象ID,无实际用途 - @Deprecated - private String objectId; - // 标识器ID - private String markerId; - // 标识器类型 - private String markerType; - // 标识器埋深 - private String markerDepth; - // 安装部门 - private String installationDept; - // 经度 - private String lng; - // 纬度 - private String lat; - //最后修改时间,更新时间 - private String updateTime; - // 备注信息 - private String remark; - // 下层管线类型 - private String underlyingPipelineType; - // 下层埋深 - private String underlyingPipelineDepth; - // 下层管径 - private String underlyingPipelineDiameter; - // 下层管材 - private String underlyingPipelineMaterial; - //标识对象类型 - private String objectType; - // 颜色 - private String color; - // 图片路径 - private String imagePath; - - @Generated(hash = 1479045776) - public MarkerLocalBean(Long id, String pipelineType, String pipelineDiameter, - String pipelineMaterial, String buryMethod, String buryDepth, - String area, String line, String road, String constructTime, - String owner, String objectId, String markerId, String markerType, - String markerDepth, String installationDept, String lng, String lat, - String updateTime, String remark, String underlyingPipelineType, - String underlyingPipelineDepth, String underlyingPipelineDiameter, - String underlyingPipelineMaterial, String objectType, String color, - String imagePath) { - this.id = id; - this.pipelineType = pipelineType; - this.pipelineDiameter = pipelineDiameter; - this.pipelineMaterial = pipelineMaterial; - this.buryMethod = buryMethod; - this.buryDepth = buryDepth; - this.area = area; - this.line = line; - this.road = road; - this.constructTime = constructTime; - this.owner = owner; - this.objectId = objectId; - this.markerId = markerId; - this.markerType = markerType; - this.markerDepth = markerDepth; - this.installationDept = installationDept; - this.lng = lng; - this.lat = lat; - this.updateTime = updateTime; - this.remark = remark; - this.underlyingPipelineType = underlyingPipelineType; - this.underlyingPipelineDepth = underlyingPipelineDepth; - this.underlyingPipelineDiameter = underlyingPipelineDiameter; - this.underlyingPipelineMaterial = underlyingPipelineMaterial; - this.objectType = objectType; - this.color = color; - this.imagePath = imagePath; - } - - @Generated(hash = 1538606012) - public MarkerLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getPipelineType() { - return this.pipelineType; - } - - public void setPipelineType(String pipelineType) { - this.pipelineType = pipelineType; - } - - public String getPipelineDiameter() { - return this.pipelineDiameter; - } - - public void setPipelineDiameter(String pipelineDiameter) { - this.pipelineDiameter = pipelineDiameter; - } - - public String getPipelineMaterial() { - return this.pipelineMaterial; - } - - public void setPipelineMaterial(String pipelineMaterial) { - this.pipelineMaterial = pipelineMaterial; - } - - public String getBuryMethod() { - return this.buryMethod; - } - - public void setBuryMethod(String buryMethod) { - this.buryMethod = buryMethod; - } - - public String getBuryDepth() { - return this.buryDepth; - } - - public void setBuryDepth(String buryDepth) { - this.buryDepth = buryDepth; - } - - public String getArea() { - return this.area; - } - - public void setArea(String area) { - this.area = area; - } - - public String getLine() { - return this.line; - } - - public void setLine(String line) { - this.line = line; - } - - public String getRoad() { - return this.road; - } - - public void setRoad(String road) { - this.road = road; - } - - public String getConstructTime() { - return this.constructTime; - } - - public void setConstructTime(String constructTime) { - this.constructTime = constructTime; - } - - public String getOwner() { - return this.owner; - } - - public void setOwner(String owner) { - this.owner = owner; - } - - public String getObjectId() { - return this.objectId; - } - - public void setObjectId(String objectId) { - this.objectId = objectId; - } - - public String getMarkerId() { - return this.markerId; - } - - public void setMarkerId(String markerId) { - this.markerId = markerId; - } - - public String getMarkerType() { - return this.markerType; - } - - public void setMarkerType(String markerType) { - this.markerType = markerType; - } - - public String getMarkerDepth() { - return this.markerDepth; - } - - public void setMarkerDepth(String markerDepth) { - this.markerDepth = markerDepth; - } - - public String getInstallationDept() { - return this.installationDept; - } - - public void setInstallationDept(String installationDept) { - this.installationDept = installationDept; - } - - public String getLng() { - return this.lng; - } - - public void setLng(String lng) { - this.lng = lng; - } - - public String getLat() { - return this.lat; - } - - public void setLat(String lat) { - this.lat = lat; - } - - public String getUpdateTime() { - return this.updateTime; - } - - public void setUpdateTime(String updateTime) { - this.updateTime = updateTime; - } - - public String getRemark() { - return this.remark; - } - - public void setRemark(String remark) { - this.remark = remark; - } - - public String getUnderlyingPipelineType() { - return this.underlyingPipelineType; - } - - public void setUnderlyingPipelineType(String underlyingPipelineType) { - this.underlyingPipelineType = underlyingPipelineType; - } - - public String getUnderlyingPipelineDepth() { - return this.underlyingPipelineDepth; - } - - public void setUnderlyingPipelineDepth(String underlyingPipelineDepth) { - this.underlyingPipelineDepth = underlyingPipelineDepth; - } - - public String getUnderlyingPipelineDiameter() { - return this.underlyingPipelineDiameter; - } - - public void setUnderlyingPipelineDiameter(String underlyingPipelineDiameter) { - this.underlyingPipelineDiameter = underlyingPipelineDiameter; - } - - public String getUnderlyingPipelineMaterial() { - return this.underlyingPipelineMaterial; - } - - public void setUnderlyingPipelineMaterial(String underlyingPipelineMaterial) { - this.underlyingPipelineMaterial = underlyingPipelineMaterial; - } - - public String getObjectType() { - return this.objectType; - } - - public void setObjectType(String objectType) { - this.objectType = objectType; - } - - public String getColor() { - return this.color; - } - - public void setColor(String color) { - this.color = color; - } - - public String getImagePath() { - return this.imagePath; - } - - public void setImagePath(String imagePath) { - this.imagePath = imagePath; - } -} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java new file mode 100644 index 0000000..5c88fdf --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java @@ -0,0 +1,93 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 巡检任务本地库实体类,不包含任务里面需要巡检的标识器信息 + */ +@Entity(tableName = "task_detail") +public class TaskBean { + @PrimaryKey(autoGenerate = true) + private long id;//主键ID + private String taskCode; // 任务编号 + private String description; // 任务名称 + private String createTime; // 任务创建的时间 + private String status; // 任务状态 + private String createUserName; // 任务创建者名称 + private String startTime; // 任务被开始执行的时间 + private String endTime; // 任务执行结束的时间 + private String isFree; // 是否自由巡检。1-是,0-否 + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getTaskCode() { + return taskCode; + } + + public void setTaskCode(String taskCode) { + this.taskCode = taskCode; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getCreateUserName() { + return createUserName; + } + + public void setCreateUserName(String createUserName) { + this.createUserName = createUserName; + } + + public String getStartTime() { + return startTime; + } + + public void setStartTime(String startTime) { + this.startTime = startTime; + } + + public String getEndTime() { + return endTime; + } + + public void setEndTime(String endTime) { + this.endTime = endTime; + } + + public String getIsFree() { + return isFree; + } + + public void setIsFree(String isFree) { + this.isFree = isFree; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java deleted file mode 100644 index 91737b3..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java +++ /dev/null @@ -1,114 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 巡检任务本地库实体类,不包含任务里面需要巡检的标识器信息 - */ -@Entity -public class TaskLocalBean { - @Id - private Long id;//任务ID - - private String taskCode;//任务编号 - private String description;//任务名称 - private String createTime;//任务创建的时间 - private String status;//任务状态 - private String createUserName;//任务创建者名称 - private String startTime;//任务被开始执行的时间 - private String endTime;//任务执行结束的时间 - private String isFreeTask;//是否自由巡检。1-是,0-否 - - @Generated(hash = 1482022528) - public TaskLocalBean(Long id, String taskCode, String description, - String createTime, String status, String createUserName, - String startTime, String endTime, String isFreeTask) { - this.id = id; - this.taskCode = taskCode; - this.description = description; - this.createTime = createTime; - this.status = status; - this.createUserName = createUserName; - this.startTime = startTime; - this.endTime = endTime; - this.isFreeTask = isFreeTask; - } - - @Generated(hash = 949704588) - public TaskLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getTaskCode() { - return this.taskCode; - } - - public void setTaskCode(String taskCode) { - this.taskCode = taskCode; - } - - public String getDescription() { - return this.description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getCreateTime() { - return this.createTime; - } - - public void setCreateTime(String createTime) { - this.createTime = createTime; - } - - public String getStatus() { - return this.status; - } - - public void setStatus(String status) { - this.status = status; - } - - public String getCreateUserName() { - return this.createUserName; - } - - public void setCreateUserName(String createUserName) { - this.createUserName = createUserName; - } - - public String getStartTime() { - return this.startTime; - } - - public void setStartTime(String startTime) { - this.startTime = startTime; - } - - public String getEndTime() { - return this.endTime; - } - - public void setEndTime(String endTime) { - this.endTime = endTime; - } - - public String getIsFreeTask() { - return this.isFreeTask; - } - - public void setIsFreeTask(String isFreeTask) { - this.isFreeTask = isFreeTask; - } -} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerBean.java new file mode 100644 index 0000000..c563a60 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerBean.java @@ -0,0 +1,110 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 巡检任务里面需要巡检的标识器信息本地库实体类 + */ +@Entity(tableName = "task_marker_info") +public class TaskMarkerBean { + //标识器后台库的主键ID,不是标识器实际ID + @PrimaryKey(autoGenerate = true) + private long id; + + /** + * 任务ID,通过此字段关联[TaskBean.id] + */ + private String taskId; + + /** + * 任务Code,通过此字段关联[TaskBean.taskCode] + *

+ *

+ * 双重验证,防止出现同时刻重复的情况 + */ + private String taskCode; + + /** + * 对应后台字段[TaskModel.MessageModel.TaskDetailInfosModel.markerIdReal],也就是探测仪扫描出来的ID + */ + private String markerId; + + private Double lng; + private Double lat; + + /** + * 是否已被探测到 + * 1-是,0-否 + */ + private String isDetected; + + /** + * 被探测到的时间,对应后台字段[TaskModel.MessageModel.TaskDetailInfosModel.finishTime] + */ + private String detectedTime; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getTaskId() { + return taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getTaskCode() { + return taskCode; + } + + public void setTaskCode(String taskCode) { + this.taskCode = taskCode; + } + + public String getMarkerId() { + return markerId; + } + + public void setMarkerId(String markerId) { + this.markerId = markerId; + } + + public Double getLng() { + return lng; + } + + public void setLng(Double lng) { + this.lng = lng; + } + + public Double getLat() { + return lat; + } + + public void setLat(Double lat) { + this.lat = lat; + } + + public String getIsDetected() { + return isDetected; + } + + public void setIsDetected(String isDetected) { + this.isDetected = isDetected; + } + + public String getDetectedTime() { + return detectedTime; + } + + public void setDetectedTime(String detectedTime) { + this.detectedTime = detectedTime; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerLocalBean.java deleted file mode 100644 index de9f459..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerLocalBean.java +++ /dev/null @@ -1,128 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import com.casic.common.detector.gd.model.TaskModel; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 巡检任务里面需要巡检的标识器信息本地库实体类 - */ -@Entity -public class TaskMarkerLocalBean { - @Id - private Long id;//标识器后台库的主键ID,不是标识器实际ID - - /** - * 任务ID,通过此字段关联{@link TaskLocalBean#id} - */ - private String taskId; - - /** - * 任务Code,通过此字段关联{@link TaskLocalBean#taskCode} - *

- * 双重验证,防止出现同时刻重复的情况 - */ - private String taskCode; - - /** - * 对应后台字段{@link TaskModel.MessageModel.TaskDetailInfosModel#markerIdReal},也就是探测仪扫描出来的ID - */ - private String markerId; - - private double lng; - private double lat; - - /** - * 是否已被探测到 - * 1-是,0-否 - */ - private String isDetected; - - /** - * 被探测到的时间,对应后台字段{@link TaskModel.MessageModel.TaskDetailInfosModel#finishTime} - */ - private String detectedTime; - - @Generated(hash = 677328533) - public TaskMarkerLocalBean(Long id, String taskId, String taskCode, String markerId, - double lng, double lat, String isDetected, String detectedTime) { - this.id = id; - this.taskId = taskId; - this.taskCode = taskCode; - this.markerId = markerId; - this.lng = lng; - this.lat = lat; - this.isDetected = isDetected; - this.detectedTime = detectedTime; - } - - @Generated(hash = 1162404642) - public TaskMarkerLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getTaskId() { - return this.taskId; - } - - public void setTaskId(String taskId) { - this.taskId = taskId; - } - - public String getTaskCode() { - return this.taskCode; - } - - public void setTaskCode(String taskCode) { - this.taskCode = taskCode; - } - - public String getMarkerId() { - return this.markerId; - } - - public void setMarkerId(String markerId) { - this.markerId = markerId; - } - - public double getLng() { - return this.lng; - } - - public void setLng(double lng) { - this.lng = lng; - } - - public double getLat() { - return this.lat; - } - - public void setLat(double lat) { - this.lat = lat; - } - - public String getIsDetected() { - return this.isDetected; - } - - public void setIsDetected(String isDetected) { - this.isDetected = isDetected; - } - - public String getDetectedTime() { - return this.detectedTime; - } - - public void setDetectedTime(String detectedTime) { - this.detectedTime = detectedTime; - } -} diff --git a/app/src/main/java/com/casic/common/detector/gd/dao/MarkerBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/dao/MarkerBeanDao.java new file mode 100644 index 0000000..2beb7ed --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/dao/MarkerBeanDao.java @@ -0,0 +1,29 @@ +package com.casic.common.detector.gd.dao; + +import androidx.room.Dao; +import androidx.room.Insert; +import androidx.room.Query; +import androidx.room.RawQuery; +import androidx.sqlite.db.SupportSQLiteQuery; + +import com.casic.common.detector.gd.bean.MarkerBean; + +import java.util.List; + +@Dao +public interface MarkerBeanDao { + @Query("DELETE FROM marker_detail") + void deleteAll(); + + @Insert + void insert(MarkerBean marker); + + @Query("SELECT * FROM marker_detail") + List loadAll(); + + @Query("SELECT * FROM marker_detail WHERE markerId = :markerId") + List queryMarkerById(String markerId); + + @RawQuery + List loadMarkersByCondition(SupportSQLiteQuery query); +} diff --git a/app/src/main/java/com/casic/common/detector/gd/dao/TaskBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/dao/TaskBeanDao.java new file mode 100644 index 0000000..9c70ac2 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/dao/TaskBeanDao.java @@ -0,0 +1,120 @@ +package com.casic.common.detector.gd.dao; + +import androidx.room.Dao; +import androidx.room.Insert; +import androidx.room.Query; +import androidx.room.Transaction; + +import com.casic.common.detector.gd.bean.TaskBean; +import com.casic.common.detector.gd.bean.TaskMarkerBean; +import com.casic.common.detector.gd.model.TaskDetailLocalModel; +import com.casic.common.detector.gd.model.TaskModel; +import com.casic.common.detector.gd.utils.LocaleConstant; +import com.pengxh.kt.lite.utils.SaveKeyValues; + +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Locale; + +@Dao +public interface TaskBeanDao { + @Query("SELECT COUNT(*) FROM task_detail WHERE id = :taskId") + int isTaskExist(long taskId); + + @Insert + void insert(TaskBean task); + + default void saveTask(Long taskId, String taskName) { + if (isTaskExist(taskId) == 0) { + TaskBean task = new TaskBean(); + task.setId(taskId); + task.setTaskCode(new SimpleDateFormat("yyyyMMddHHmmss", Locale.CHINA).format(new Date())); + task.setDescription(taskName); + String time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA).format(new Date()); + task.setCreateTime(time); + task.setStatus("0"); + String userName = (String) SaveKeyValues.INSTANCE.getValue(LocaleConstant.USER_NAME, ""); + task.setCreateUserName(userName); + task.setStartTime(time); + task.setEndTime(""); + task.setIsFree("1"); + insert(task); + } + } + + default void saveTask(TaskModel.MessageModel model) { + TaskBean task = new TaskBean(); + task.setId(model.getId()); + task.setTaskCode(model.getTaskCode()); + task.setDescription(model.getDescription()); + task.setCreateTime(model.getDeployDate()); + task.setStatus(model.getStatus()); + task.setCreateUserName(model.getCreatorName()); + task.setStartTime(model.getBeginDate()); + task.setEndTime(model.getEndDate()); + task.setIsFree("0"); + if (isTaskExist(task.getId()) == 0) { + insert(task); + } + } + + @Query("SELECT * FROM task_detail") + List loadAll(); + + @Transaction + default ArrayList loadLocalTask(TaskMarkerBeanDao taskMarkerBeanDao) { + ArrayList result = new ArrayList<>(); + List tasks = loadAll(); + for (TaskBean it : tasks) { + TaskDetailLocalModel model = new TaskDetailLocalModel(); + model.setTaskId(String.valueOf(it.getId())); + model.setTaskCode(it.getTaskCode()); + model.setDescription(it.getDescription()); + model.setCreateTime(it.getCreateTime()); + model.setStatus(it.getStatus()); + model.setCreateUserName(it.getCreateUserName()); + model.setIsFreeTask(it.getIsFree()); + ArrayList results = new ArrayList<>(); + if ("0".equals(it.getIsFree())) { + // 非自由巡检才有Marker + List markers = taskMarkerBeanDao.getMarkersByIdAndCode(String.valueOf(it.getId()), it.getTaskCode()); + for (TaskMarkerBean marker : markers) { + TaskDetailLocalModel.TaskMarkerLocalModel localModel = new TaskDetailLocalModel.TaskMarkerLocalModel(); + localModel.setMarkerId(marker.getMarkerId()); + localModel.setLng(marker.getLng()); + localModel.setLat(marker.getLat()); + localModel.setIsDetected(marker.getIsDetected()); + localModel.setDetectedTime(marker.getDetectedTime()); + + results.add(localModel); + } + } + model.setMarkerModels(results); + result.add(model); + } + return result; + } + + @Query("DELETE FROM task_detail WHERE id = :taskId AND taskCode = :taskCode") + void deleteTaskById(long taskId, String taskCode); + + @Transaction + default void deleteLocalTaskById(long taskId, String taskCode, TaskMarkerBeanDao taskMarkerBeanDao) { + TaskBean task = loadAll().stream() + .filter(it -> it.getId() == taskId && taskCode.equals(it.getTaskCode())) + .findFirst() + .orElse(null); + if (task == null) return; + deleteTaskById(taskId, taskCode); + + // 删除此任务关联的Marker。非自由巡检才有Marker + if ("0".equals(task.getIsFree())) { + List markers = taskMarkerBeanDao.getMarkersByIdAndCode(String.valueOf(task.getId()), task.getTaskCode()); + for (TaskMarkerBean marker : markers) { + taskMarkerBeanDao.delete(marker); + } + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/dao/TaskMarkerBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/dao/TaskMarkerBeanDao.java new file mode 100644 index 0000000..cc2156a --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/dao/TaskMarkerBeanDao.java @@ -0,0 +1,52 @@ +package com.casic.common.detector.gd.dao; + +import androidx.room.Dao; +import androidx.room.Delete; +import androidx.room.Insert; +import androidx.room.Query; +import androidx.room.Update; + +import com.casic.common.detector.gd.bean.TaskMarkerBean; +import com.casic.common.detector.gd.model.TaskModel; + +import java.util.List; + +@Dao +public interface TaskMarkerBeanDao { + + @Insert + void insert(TaskMarkerBean marker); + + @Query("SELECT COUNT(*) FROM task_marker_info WHERE id = :markerId") + int isMarkerExist(String markerId); + + default void saveTaskMarker(long taskId, String taskCode, TaskModel.MessageModel.TaskDetailInfosModel marker) { + if (isMarkerExist(marker.getMarkerId()) == 0) { + TaskMarkerBean bean = new TaskMarkerBean(); + bean.setId(marker.getId()); + bean.setTaskId(String.valueOf(taskId)); + bean.setTaskCode(taskCode); + bean.setMarkerId(marker.getMarkerIdReal()); + bean.setLng(marker.getLongitude()); + bean.setLat(marker.getLatitude()); + bean.setIsDetected("0"); + bean.setDetectedTime(""); + insert(bean); + } + } + + @Query("SELECT * FROM task_marker_info WHERE taskId = :taskId AND taskCode = :taskCode AND markerId = :markerId AND isDetected = :state") + TaskMarkerBean queryTaskMarkerById(String taskId, String taskCode, String markerId, String state); + + @Update + void updateLocalTaskMarkerState(TaskMarkerBean marker); + + @Query("SELECT * FROM task_marker_info WHERE isDetected = :state") + List queryMarkerByState(String state); + + @Query("SELECT * FROM task_marker_info WHERE taskId = :taskId AND taskCode = :taskCode") + List getMarkersByIdAndCode(String taskId, String taskCode); + + @Delete + void delete(TaskMarkerBean marker); +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/extensions/Long.kt b/app/src/main/java/com/casic/common/detector/gd/extensions/Long.kt deleted file mode 100644 index 6713d8d..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/extensions/Long.kt +++ /dev/null @@ -1,10 +0,0 @@ -package com.casic.common.detector.gd.extensions - -import java.text.SimpleDateFormat -import java.util.Date -import java.util.Locale - -fun Long.createTaskCode(): String { - val dateFormat = SimpleDateFormat("yyyyMMddHHmmss", Locale.CHINA) - return dateFormat.format(Date(this)) -} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoMaster.java b/app/src/main/java/com/casic/common/detector/gd/greendao/DaoMaster.java deleted file mode 100644 index 6ab94b3..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoMaster.java +++ /dev/null @@ -1,102 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import android.content.Context; -import android.database.sqlite.SQLiteDatabase; -import android.database.sqlite.SQLiteDatabase.CursorFactory; -import android.util.Log; - -import org.greenrobot.greendao.AbstractDaoMaster; -import org.greenrobot.greendao.database.StandardDatabase; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.database.DatabaseOpenHelper; -import org.greenrobot.greendao.identityscope.IdentityScopeType; - - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** - * Master of DAO (schema version 1): knows all DAOs. - */ -public class DaoMaster extends AbstractDaoMaster { - public static final int SCHEMA_VERSION = 1; - - /** Creates underlying database table using DAOs. */ - public static void createAllTables(Database db, boolean ifNotExists) { - MarkerLocalBeanDao.createTable(db, ifNotExists); - TaskLocalBeanDao.createTable(db, ifNotExists); - TaskMarkerLocalBeanDao.createTable(db, ifNotExists); - } - - /** Drops underlying database table using DAOs. */ - public static void dropAllTables(Database db, boolean ifExists) { - MarkerLocalBeanDao.dropTable(db, ifExists); - TaskLocalBeanDao.dropTable(db, ifExists); - TaskMarkerLocalBeanDao.dropTable(db, ifExists); - } - - /** - * WARNING: Drops all table on Upgrade! Use only during development. - * Convenience method using a {@link DevOpenHelper}. - */ - public static DaoSession newDevSession(Context context, String name) { - Database db = new DevOpenHelper(context, name).getWritableDb(); - DaoMaster daoMaster = new DaoMaster(db); - return daoMaster.newSession(); - } - - public DaoMaster(SQLiteDatabase db) { - this(new StandardDatabase(db)); - } - - public DaoMaster(Database db) { - super(db, SCHEMA_VERSION); - registerDaoClass(MarkerLocalBeanDao.class); - registerDaoClass(TaskLocalBeanDao.class); - registerDaoClass(TaskMarkerLocalBeanDao.class); - } - - public DaoSession newSession() { - return new DaoSession(db, IdentityScopeType.Session, daoConfigMap); - } - - public DaoSession newSession(IdentityScopeType type) { - return new DaoSession(db, type, daoConfigMap); - } - - /** - * Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} - - */ - public static abstract class OpenHelper extends DatabaseOpenHelper { - public OpenHelper(Context context, String name) { - super(context, name, SCHEMA_VERSION); - } - - public OpenHelper(Context context, String name, CursorFactory factory) { - super(context, name, factory, SCHEMA_VERSION); - } - - @Override - public void onCreate(Database db) { - Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION); - createAllTables(db, false); - } - } - - /** WARNING: Drops all table on Upgrade! Use only during development. */ - public static class DevOpenHelper extends OpenHelper { - public DevOpenHelper(Context context, String name) { - super(context, name); - } - - public DevOpenHelper(Context context, String name, CursorFactory factory) { - super(context, name, factory); - } - - @Override - public void onUpgrade(Database db, int oldVersion, int newVersion) { - Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables"); - dropAllTables(db, true); - onCreate(db); - } - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoSession.java b/app/src/main/java/com/casic/common/detector/gd/greendao/DaoSession.java deleted file mode 100644 index c8b1a20..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoSession.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import java.util.Map; - -import org.greenrobot.greendao.AbstractDao; -import org.greenrobot.greendao.AbstractDaoSession; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.identityscope.IdentityScopeType; -import org.greenrobot.greendao.internal.DaoConfig; - -import com.casic.common.detector.gd.bean.MarkerLocalBean; -import com.casic.common.detector.gd.bean.TaskLocalBean; -import com.casic.common.detector.gd.bean.TaskMarkerLocalBean; - -import com.casic.common.detector.gd.greendao.MarkerLocalBeanDao; -import com.casic.common.detector.gd.greendao.TaskLocalBeanDao; -import com.casic.common.detector.gd.greendao.TaskMarkerLocalBeanDao; - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. - -/** - * {@inheritDoc} - * - * @see org.greenrobot.greendao.AbstractDaoSession - */ -public class DaoSession extends AbstractDaoSession { - - private final DaoConfig markerLocalBeanDaoConfig; - private final DaoConfig taskLocalBeanDaoConfig; - private final DaoConfig taskMarkerLocalBeanDaoConfig; - - private final MarkerLocalBeanDao markerLocalBeanDao; - private final TaskLocalBeanDao taskLocalBeanDao; - private final TaskMarkerLocalBeanDao taskMarkerLocalBeanDao; - - public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> - daoConfigMap) { - super(db); - - markerLocalBeanDaoConfig = daoConfigMap.get(MarkerLocalBeanDao.class).clone(); - markerLocalBeanDaoConfig.initIdentityScope(type); - - taskLocalBeanDaoConfig = daoConfigMap.get(TaskLocalBeanDao.class).clone(); - taskLocalBeanDaoConfig.initIdentityScope(type); - - taskMarkerLocalBeanDaoConfig = daoConfigMap.get(TaskMarkerLocalBeanDao.class).clone(); - taskMarkerLocalBeanDaoConfig.initIdentityScope(type); - - markerLocalBeanDao = new MarkerLocalBeanDao(markerLocalBeanDaoConfig, this); - taskLocalBeanDao = new TaskLocalBeanDao(taskLocalBeanDaoConfig, this); - taskMarkerLocalBeanDao = new TaskMarkerLocalBeanDao(taskMarkerLocalBeanDaoConfig, this); - - registerDao(MarkerLocalBean.class, markerLocalBeanDao); - registerDao(TaskLocalBean.class, taskLocalBeanDao); - registerDao(TaskMarkerLocalBean.class, taskMarkerLocalBeanDao); - } - - public void clear() { - markerLocalBeanDaoConfig.clearIdentityScope(); - taskLocalBeanDaoConfig.clearIdentityScope(); - taskMarkerLocalBeanDaoConfig.clearIdentityScope(); - } - - public MarkerLocalBeanDao getMarkerLocalBeanDao() { - return markerLocalBeanDao; - } - - public TaskLocalBeanDao getTaskLocalBeanDao() { - return taskLocalBeanDao; - } - - public TaskMarkerLocalBeanDao getTaskMarkerLocalBeanDao() { - return taskMarkerLocalBeanDao; - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/MarkerLocalBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/greendao/MarkerLocalBeanDao.java deleted file mode 100644 index 2f792c3..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/MarkerLocalBeanDao.java +++ /dev/null @@ -1,479 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import android.database.Cursor; -import android.database.sqlite.SQLiteStatement; - -import org.greenrobot.greendao.AbstractDao; -import org.greenrobot.greendao.Property; -import org.greenrobot.greendao.internal.DaoConfig; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.database.DatabaseStatement; - -import com.casic.common.detector.gd.bean.MarkerLocalBean; - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** - * DAO for table "MARKER_LOCAL_BEAN". -*/ -public class MarkerLocalBeanDao extends AbstractDao { - - public static final String TABLENAME = "MARKER_LOCAL_BEAN"; - - /** - * Properties of entity MarkerLocalBean.
- * Can be used for QueryBuilder and for referencing column names. - */ - public static class Properties { - public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property PipelineType = new Property(1, String.class, "pipelineType", false, "PIPELINE_TYPE"); - public final static Property PipelineDiameter = new Property(2, String.class, "pipelineDiameter", false, "PIPELINE_DIAMETER"); - public final static Property PipelineMaterial = new Property(3, String.class, "pipelineMaterial", false, "PIPELINE_MATERIAL"); - public final static Property BuryMethod = new Property(4, String.class, "buryMethod", false, "BURY_METHOD"); - public final static Property BuryDepth = new Property(5, String.class, "buryDepth", false, "BURY_DEPTH"); - public final static Property Area = new Property(6, String.class, "area", false, "AREA"); - public final static Property Line = new Property(7, String.class, "line", false, "LINE"); - public final static Property Road = new Property(8, String.class, "road", false, "ROAD"); - public final static Property ConstructTime = new Property(9, String.class, "constructTime", false, "CONSTRUCT_TIME"); - public final static Property Owner = new Property(10, String.class, "owner", false, "OWNER"); - public final static Property ObjectId = new Property(11, String.class, "objectId", false, "OBJECT_ID"); - public final static Property MarkerId = new Property(12, String.class, "markerId", false, "MARKER_ID"); - public final static Property MarkerType = new Property(13, String.class, "markerType", false, "MARKER_TYPE"); - public final static Property MarkerDepth = new Property(14, String.class, "markerDepth", false, "MARKER_DEPTH"); - public final static Property InstallationDept = new Property(15, String.class, "installationDept", false, "INSTALLATION_DEPT"); - public final static Property Lng = new Property(16, String.class, "lng", false, "LNG"); - public final static Property Lat = new Property(17, String.class, "lat", false, "LAT"); - public final static Property UpdateTime = new Property(18, String.class, "updateTime", false, "UPDATE_TIME"); - public final static Property Remark = new Property(19, String.class, "remark", false, "REMARK"); - public final static Property UnderlyingPipelineType = new Property(20, String.class, "underlyingPipelineType", false, "UNDERLYING_PIPELINE_TYPE"); - public final static Property UnderlyingPipelineDepth = new Property(21, String.class, "underlyingPipelineDepth", false, "UNDERLYING_PIPELINE_DEPTH"); - public final static Property UnderlyingPipelineDiameter = new Property(22, String.class, "underlyingPipelineDiameter", false, "UNDERLYING_PIPELINE_DIAMETER"); - public final static Property UnderlyingPipelineMaterial = new Property(23, String.class, "underlyingPipelineMaterial", false, "UNDERLYING_PIPELINE_MATERIAL"); - public final static Property ObjectType = new Property(24, String.class, "objectType", false, "OBJECT_TYPE"); - public final static Property Color = new Property(25, String.class, "color", false, "COLOR"); - public final static Property ImagePath = new Property(26, String.class, "imagePath", false, "IMAGE_PATH"); - } - - - public MarkerLocalBeanDao(DaoConfig config) { - super(config); - } - - public MarkerLocalBeanDao(DaoConfig config, DaoSession daoSession) { - super(config, daoSession); - } - - /** Creates the underlying database table. */ - public static void createTable(Database db, boolean ifNotExists) { - String constraint = ifNotExists? "IF NOT EXISTS ": ""; - db.execSQL("CREATE TABLE " + constraint + "\"MARKER_LOCAL_BEAN\" (" + // - "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id - "\"PIPELINE_TYPE\" TEXT," + // 1: pipelineType - "\"PIPELINE_DIAMETER\" TEXT," + // 2: pipelineDiameter - "\"PIPELINE_MATERIAL\" TEXT," + // 3: pipelineMaterial - "\"BURY_METHOD\" TEXT," + // 4: buryMethod - "\"BURY_DEPTH\" TEXT," + // 5: buryDepth - "\"AREA\" TEXT," + // 6: area - "\"LINE\" TEXT," + // 7: line - "\"ROAD\" TEXT," + // 8: road - "\"CONSTRUCT_TIME\" TEXT," + // 9: constructTime - "\"OWNER\" TEXT," + // 10: owner - "\"OBJECT_ID\" TEXT," + // 11: objectId - "\"MARKER_ID\" TEXT," + // 12: markerId - "\"MARKER_TYPE\" TEXT," + // 13: markerType - "\"MARKER_DEPTH\" TEXT," + // 14: markerDepth - "\"INSTALLATION_DEPT\" TEXT," + // 15: installationDept - "\"LNG\" TEXT," + // 16: lng - "\"LAT\" TEXT," + // 17: lat - "\"UPDATE_TIME\" TEXT," + // 18: updateTime - "\"REMARK\" TEXT," + // 19: remark - "\"UNDERLYING_PIPELINE_TYPE\" TEXT," + // 20: underlyingPipelineType - "\"UNDERLYING_PIPELINE_DEPTH\" TEXT," + // 21: underlyingPipelineDepth - "\"UNDERLYING_PIPELINE_DIAMETER\" TEXT," + // 22: underlyingPipelineDiameter - "\"UNDERLYING_PIPELINE_MATERIAL\" TEXT," + // 23: underlyingPipelineMaterial - "\"OBJECT_TYPE\" TEXT," + // 24: objectType - "\"COLOR\" TEXT," + // 25: color - "\"IMAGE_PATH\" TEXT);"); // 26: imagePath - } - - /** Drops the underlying database table. */ - public static void dropTable(Database db, boolean ifExists) { - String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"MARKER_LOCAL_BEAN\""; - db.execSQL(sql); - } - - @Override - protected final void bindValues(DatabaseStatement stmt, MarkerLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String pipelineType = entity.getPipelineType(); - if (pipelineType != null) { - stmt.bindString(2, pipelineType); - } - - String pipelineDiameter = entity.getPipelineDiameter(); - if (pipelineDiameter != null) { - stmt.bindString(3, pipelineDiameter); - } - - String pipelineMaterial = entity.getPipelineMaterial(); - if (pipelineMaterial != null) { - stmt.bindString(4, pipelineMaterial); - } - - String buryMethod = entity.getBuryMethod(); - if (buryMethod != null) { - stmt.bindString(5, buryMethod); - } - - String buryDepth = entity.getBuryDepth(); - if (buryDepth != null) { - stmt.bindString(6, buryDepth); - } - - String area = entity.getArea(); - if (area != null) { - stmt.bindString(7, area); - } - - String line = entity.getLine(); - if (line != null) { - stmt.bindString(8, line); - } - - String road = entity.getRoad(); - if (road != null) { - stmt.bindString(9, road); - } - - String constructTime = entity.getConstructTime(); - if (constructTime != null) { - stmt.bindString(10, constructTime); - } - - String owner = entity.getOwner(); - if (owner != null) { - stmt.bindString(11, owner); - } - - String objectId = entity.getObjectId(); - if (objectId != null) { - stmt.bindString(12, objectId); - } - - String markerId = entity.getMarkerId(); - if (markerId != null) { - stmt.bindString(13, markerId); - } - - String markerType = entity.getMarkerType(); - if (markerType != null) { - stmt.bindString(14, markerType); - } - - String markerDepth = entity.getMarkerDepth(); - if (markerDepth != null) { - stmt.bindString(15, markerDepth); - } - - String installationDept = entity.getInstallationDept(); - if (installationDept != null) { - stmt.bindString(16, installationDept); - } - - String lng = entity.getLng(); - if (lng != null) { - stmt.bindString(17, lng); - } - - String lat = entity.getLat(); - if (lat != null) { - stmt.bindString(18, lat); - } - - String updateTime = entity.getUpdateTime(); - if (updateTime != null) { - stmt.bindString(19, updateTime); - } - - String remark = entity.getRemark(); - if (remark != null) { - stmt.bindString(20, remark); - } - - String underlyingPipelineType = entity.getUnderlyingPipelineType(); - if (underlyingPipelineType != null) { - stmt.bindString(21, underlyingPipelineType); - } - - String underlyingPipelineDepth = entity.getUnderlyingPipelineDepth(); - if (underlyingPipelineDepth != null) { - stmt.bindString(22, underlyingPipelineDepth); - } - - String underlyingPipelineDiameter = entity.getUnderlyingPipelineDiameter(); - if (underlyingPipelineDiameter != null) { - stmt.bindString(23, underlyingPipelineDiameter); - } - - String underlyingPipelineMaterial = entity.getUnderlyingPipelineMaterial(); - if (underlyingPipelineMaterial != null) { - stmt.bindString(24, underlyingPipelineMaterial); - } - - String objectType = entity.getObjectType(); - if (objectType != null) { - stmt.bindString(25, objectType); - } - - String color = entity.getColor(); - if (color != null) { - stmt.bindString(26, color); - } - - String imagePath = entity.getImagePath(); - if (imagePath != null) { - stmt.bindString(27, imagePath); - } - } - - @Override - protected final void bindValues(SQLiteStatement stmt, MarkerLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String pipelineType = entity.getPipelineType(); - if (pipelineType != null) { - stmt.bindString(2, pipelineType); - } - - String pipelineDiameter = entity.getPipelineDiameter(); - if (pipelineDiameter != null) { - stmt.bindString(3, pipelineDiameter); - } - - String pipelineMaterial = entity.getPipelineMaterial(); - if (pipelineMaterial != null) { - stmt.bindString(4, pipelineMaterial); - } - - String buryMethod = entity.getBuryMethod(); - if (buryMethod != null) { - stmt.bindString(5, buryMethod); - } - - String buryDepth = entity.getBuryDepth(); - if (buryDepth != null) { - stmt.bindString(6, buryDepth); - } - - String area = entity.getArea(); - if (area != null) { - stmt.bindString(7, area); - } - - String line = entity.getLine(); - if (line != null) { - stmt.bindString(8, line); - } - - String road = entity.getRoad(); - if (road != null) { - stmt.bindString(9, road); - } - - String constructTime = entity.getConstructTime(); - if (constructTime != null) { - stmt.bindString(10, constructTime); - } - - String owner = entity.getOwner(); - if (owner != null) { - stmt.bindString(11, owner); - } - - String objectId = entity.getObjectId(); - if (objectId != null) { - stmt.bindString(12, objectId); - } - - String markerId = entity.getMarkerId(); - if (markerId != null) { - stmt.bindString(13, markerId); - } - - String markerType = entity.getMarkerType(); - if (markerType != null) { - stmt.bindString(14, markerType); - } - - String markerDepth = entity.getMarkerDepth(); - if (markerDepth != null) { - stmt.bindString(15, markerDepth); - } - - String installationDept = entity.getInstallationDept(); - if (installationDept != null) { - stmt.bindString(16, installationDept); - } - - String lng = entity.getLng(); - if (lng != null) { - stmt.bindString(17, lng); - } - - String lat = entity.getLat(); - if (lat != null) { - stmt.bindString(18, lat); - } - - String updateTime = entity.getUpdateTime(); - if (updateTime != null) { - stmt.bindString(19, updateTime); - } - - String remark = entity.getRemark(); - if (remark != null) { - stmt.bindString(20, remark); - } - - String underlyingPipelineType = entity.getUnderlyingPipelineType(); - if (underlyingPipelineType != null) { - stmt.bindString(21, underlyingPipelineType); - } - - String underlyingPipelineDepth = entity.getUnderlyingPipelineDepth(); - if (underlyingPipelineDepth != null) { - stmt.bindString(22, underlyingPipelineDepth); - } - - String underlyingPipelineDiameter = entity.getUnderlyingPipelineDiameter(); - if (underlyingPipelineDiameter != null) { - stmt.bindString(23, underlyingPipelineDiameter); - } - - String underlyingPipelineMaterial = entity.getUnderlyingPipelineMaterial(); - if (underlyingPipelineMaterial != null) { - stmt.bindString(24, underlyingPipelineMaterial); - } - - String objectType = entity.getObjectType(); - if (objectType != null) { - stmt.bindString(25, objectType); - } - - String color = entity.getColor(); - if (color != null) { - stmt.bindString(26, color); - } - - String imagePath = entity.getImagePath(); - if (imagePath != null) { - stmt.bindString(27, imagePath); - } - } - - @Override - public Long readKey(Cursor cursor, int offset) { - return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); - } - - @Override - public MarkerLocalBean readEntity(Cursor cursor, int offset) { - MarkerLocalBean entity = new MarkerLocalBean( // - cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // pipelineType - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // pipelineDiameter - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // pipelineMaterial - cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // buryMethod - cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // buryDepth - cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // area - cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // line - cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // road - cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // constructTime - cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10), // owner - cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11), // objectId - cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12), // markerId - cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13), // markerType - cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14), // markerDepth - cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15), // installationDept - cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16), // lng - cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17), // lat - cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18), // updateTime - cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19), // remark - cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20), // underlyingPipelineType - cursor.isNull(offset + 21) ? null : cursor.getString(offset + 21), // underlyingPipelineDepth - cursor.isNull(offset + 22) ? null : cursor.getString(offset + 22), // underlyingPipelineDiameter - cursor.isNull(offset + 23) ? null : cursor.getString(offset + 23), // underlyingPipelineMaterial - cursor.isNull(offset + 24) ? null : cursor.getString(offset + 24), // objectType - cursor.isNull(offset + 25) ? null : cursor.getString(offset + 25), // color - cursor.isNull(offset + 26) ? null : cursor.getString(offset + 26) // imagePath - ); - return entity; - } - - @Override - public void readEntity(Cursor cursor, MarkerLocalBean entity, int offset) { - entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setPipelineType(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); - entity.setPipelineDiameter(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); - entity.setPipelineMaterial(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); - entity.setBuryMethod(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); - entity.setBuryDepth(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); - entity.setArea(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); - entity.setLine(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); - entity.setRoad(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); - entity.setConstructTime(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9)); - entity.setOwner(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); - entity.setObjectId(cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11)); - entity.setMarkerId(cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12)); - entity.setMarkerType(cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13)); - entity.setMarkerDepth(cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14)); - entity.setInstallationDept(cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15)); - entity.setLng(cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16)); - entity.setLat(cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17)); - entity.setUpdateTime(cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18)); - entity.setRemark(cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19)); - entity.setUnderlyingPipelineType(cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20)); - entity.setUnderlyingPipelineDepth(cursor.isNull(offset + 21) ? null : cursor.getString(offset + 21)); - entity.setUnderlyingPipelineDiameter(cursor.isNull(offset + 22) ? null : cursor.getString(offset + 22)); - entity.setUnderlyingPipelineMaterial(cursor.isNull(offset + 23) ? null : cursor.getString(offset + 23)); - entity.setObjectType(cursor.isNull(offset + 24) ? null : cursor.getString(offset + 24)); - entity.setColor(cursor.isNull(offset + 25) ? null : cursor.getString(offset + 25)); - entity.setImagePath(cursor.isNull(offset + 26) ? null : cursor.getString(offset + 26)); - } - - @Override - protected final Long updateKeyAfterInsert(MarkerLocalBean entity, long rowId) { - entity.setId(rowId); - return rowId; - } - - @Override - public Long getKey(MarkerLocalBean entity) { - if(entity != null) { - return entity.getId(); - } else { - return null; - } - } - - @Override - public boolean hasKey(MarkerLocalBean entity) { - return entity.getId() != null; - } - - @Override - protected final boolean isEntityUpdateable() { - return true; - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/TaskLocalBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/greendao/TaskLocalBeanDao.java deleted file mode 100644 index fb88157..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/TaskLocalBeanDao.java +++ /dev/null @@ -1,227 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import android.database.Cursor; -import android.database.sqlite.SQLiteStatement; - -import org.greenrobot.greendao.AbstractDao; -import org.greenrobot.greendao.Property; -import org.greenrobot.greendao.internal.DaoConfig; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.database.DatabaseStatement; - -import com.casic.common.detector.gd.bean.TaskLocalBean; - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** - * DAO for table "TASK_LOCAL_BEAN". -*/ -public class TaskLocalBeanDao extends AbstractDao { - - public static final String TABLENAME = "TASK_LOCAL_BEAN"; - - /** - * Properties of entity TaskLocalBean.
- * Can be used for QueryBuilder and for referencing column names. - */ - public static class Properties { - public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property TaskCode = new Property(1, String.class, "taskCode", false, "TASK_CODE"); - public final static Property Description = new Property(2, String.class, "description", false, "DESCRIPTION"); - public final static Property CreateTime = new Property(3, String.class, "createTime", false, "CREATE_TIME"); - public final static Property Status = new Property(4, String.class, "status", false, "STATUS"); - public final static Property CreateUserName = new Property(5, String.class, "createUserName", false, "CREATE_USER_NAME"); - public final static Property StartTime = new Property(6, String.class, "startTime", false, "START_TIME"); - public final static Property EndTime = new Property(7, String.class, "endTime", false, "END_TIME"); - public final static Property IsFreeTask = new Property(8, String.class, "isFreeTask", false, "IS_FREE_TASK"); - } - - - public TaskLocalBeanDao(DaoConfig config) { - super(config); - } - - public TaskLocalBeanDao(DaoConfig config, DaoSession daoSession) { - super(config, daoSession); - } - - /** Creates the underlying database table. */ - public static void createTable(Database db, boolean ifNotExists) { - String constraint = ifNotExists? "IF NOT EXISTS ": ""; - db.execSQL("CREATE TABLE " + constraint + "\"TASK_LOCAL_BEAN\" (" + // - "\"_id\" INTEGER PRIMARY KEY ," + // 0: id - "\"TASK_CODE\" TEXT," + // 1: taskCode - "\"DESCRIPTION\" TEXT," + // 2: description - "\"CREATE_TIME\" TEXT," + // 3: createTime - "\"STATUS\" TEXT," + // 4: status - "\"CREATE_USER_NAME\" TEXT," + // 5: createUserName - "\"START_TIME\" TEXT," + // 6: startTime - "\"END_TIME\" TEXT," + // 7: endTime - "\"IS_FREE_TASK\" TEXT);"); // 8: isFreeTask - } - - /** Drops the underlying database table. */ - public static void dropTable(Database db, boolean ifExists) { - String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"TASK_LOCAL_BEAN\""; - db.execSQL(sql); - } - - @Override - protected final void bindValues(DatabaseStatement stmt, TaskLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String taskCode = entity.getTaskCode(); - if (taskCode != null) { - stmt.bindString(2, taskCode); - } - - String description = entity.getDescription(); - if (description != null) { - stmt.bindString(3, description); - } - - String createTime = entity.getCreateTime(); - if (createTime != null) { - stmt.bindString(4, createTime); - } - - String status = entity.getStatus(); - if (status != null) { - stmt.bindString(5, status); - } - - String createUserName = entity.getCreateUserName(); - if (createUserName != null) { - stmt.bindString(6, createUserName); - } - - String startTime = entity.getStartTime(); - if (startTime != null) { - stmt.bindString(7, startTime); - } - - String endTime = entity.getEndTime(); - if (endTime != null) { - stmt.bindString(8, endTime); - } - - String isFreeTask = entity.getIsFreeTask(); - if (isFreeTask != null) { - stmt.bindString(9, isFreeTask); - } - } - - @Override - protected final void bindValues(SQLiteStatement stmt, TaskLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String taskCode = entity.getTaskCode(); - if (taskCode != null) { - stmt.bindString(2, taskCode); - } - - String description = entity.getDescription(); - if (description != null) { - stmt.bindString(3, description); - } - - String createTime = entity.getCreateTime(); - if (createTime != null) { - stmt.bindString(4, createTime); - } - - String status = entity.getStatus(); - if (status != null) { - stmt.bindString(5, status); - } - - String createUserName = entity.getCreateUserName(); - if (createUserName != null) { - stmt.bindString(6, createUserName); - } - - String startTime = entity.getStartTime(); - if (startTime != null) { - stmt.bindString(7, startTime); - } - - String endTime = entity.getEndTime(); - if (endTime != null) { - stmt.bindString(8, endTime); - } - - String isFreeTask = entity.getIsFreeTask(); - if (isFreeTask != null) { - stmt.bindString(9, isFreeTask); - } - } - - @Override - public Long readKey(Cursor cursor, int offset) { - return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); - } - - @Override - public TaskLocalBean readEntity(Cursor cursor, int offset) { - TaskLocalBean entity = new TaskLocalBean( // - cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // taskCode - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // description - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // createTime - cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // status - cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // createUserName - cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // startTime - cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // endTime - cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8) // isFreeTask - ); - return entity; - } - - @Override - public void readEntity(Cursor cursor, TaskLocalBean entity, int offset) { - entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setTaskCode(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); - entity.setDescription(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); - entity.setCreateTime(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); - entity.setStatus(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); - entity.setCreateUserName(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); - entity.setStartTime(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); - entity.setEndTime(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); - entity.setIsFreeTask(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); - } - - @Override - protected final Long updateKeyAfterInsert(TaskLocalBean entity, long rowId) { - entity.setId(rowId); - return rowId; - } - - @Override - public Long getKey(TaskLocalBean entity) { - if(entity != null) { - return entity.getId(); - } else { - return null; - } - } - - @Override - public boolean hasKey(TaskLocalBean entity) { - return entity.getId() != null; - } - - @Override - protected final boolean isEntityUpdateable() { - return true; - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/TaskMarkerLocalBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/greendao/TaskMarkerLocalBeanDao.java deleted file mode 100644 index e96c735..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/TaskMarkerLocalBeanDao.java +++ /dev/null @@ -1,197 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import android.database.Cursor; -import android.database.sqlite.SQLiteStatement; - -import org.greenrobot.greendao.AbstractDao; -import org.greenrobot.greendao.Property; -import org.greenrobot.greendao.internal.DaoConfig; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.database.DatabaseStatement; - -import com.casic.common.detector.gd.bean.TaskMarkerLocalBean; - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** - * DAO for table "TASK_MARKER_LOCAL_BEAN". -*/ -public class TaskMarkerLocalBeanDao extends AbstractDao { - - public static final String TABLENAME = "TASK_MARKER_LOCAL_BEAN"; - - /** - * Properties of entity TaskMarkerLocalBean.
- * Can be used for QueryBuilder and for referencing column names. - */ - public static class Properties { - public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property TaskId = new Property(1, String.class, "taskId", false, "TASK_ID"); - public final static Property TaskCode = new Property(2, String.class, "taskCode", false, "TASK_CODE"); - public final static Property MarkerId = new Property(3, String.class, "markerId", false, "MARKER_ID"); - public final static Property Lng = new Property(4, double.class, "lng", false, "LNG"); - public final static Property Lat = new Property(5, double.class, "lat", false, "LAT"); - public final static Property IsDetected = new Property(6, String.class, "isDetected", false, "IS_DETECTED"); - public final static Property DetectedTime = new Property(7, String.class, "detectedTime", false, "DETECTED_TIME"); - } - - - public TaskMarkerLocalBeanDao(DaoConfig config) { - super(config); - } - - public TaskMarkerLocalBeanDao(DaoConfig config, DaoSession daoSession) { - super(config, daoSession); - } - - /** Creates the underlying database table. */ - public static void createTable(Database db, boolean ifNotExists) { - String constraint = ifNotExists? "IF NOT EXISTS ": ""; - db.execSQL("CREATE TABLE " + constraint + "\"TASK_MARKER_LOCAL_BEAN\" (" + // - "\"_id\" INTEGER PRIMARY KEY ," + // 0: id - "\"TASK_ID\" TEXT," + // 1: taskId - "\"TASK_CODE\" TEXT," + // 2: taskCode - "\"MARKER_ID\" TEXT," + // 3: markerId - "\"LNG\" REAL NOT NULL ," + // 4: lng - "\"LAT\" REAL NOT NULL ," + // 5: lat - "\"IS_DETECTED\" TEXT," + // 6: isDetected - "\"DETECTED_TIME\" TEXT);"); // 7: detectedTime - } - - /** Drops the underlying database table. */ - public static void dropTable(Database db, boolean ifExists) { - String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"TASK_MARKER_LOCAL_BEAN\""; - db.execSQL(sql); - } - - @Override - protected final void bindValues(DatabaseStatement stmt, TaskMarkerLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String taskId = entity.getTaskId(); - if (taskId != null) { - stmt.bindString(2, taskId); - } - - String taskCode = entity.getTaskCode(); - if (taskCode != null) { - stmt.bindString(3, taskCode); - } - - String markerId = entity.getMarkerId(); - if (markerId != null) { - stmt.bindString(4, markerId); - } - stmt.bindDouble(5, entity.getLng()); - stmt.bindDouble(6, entity.getLat()); - - String isDetected = entity.getIsDetected(); - if (isDetected != null) { - stmt.bindString(7, isDetected); - } - - String detectedTime = entity.getDetectedTime(); - if (detectedTime != null) { - stmt.bindString(8, detectedTime); - } - } - - @Override - protected final void bindValues(SQLiteStatement stmt, TaskMarkerLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String taskId = entity.getTaskId(); - if (taskId != null) { - stmt.bindString(2, taskId); - } - - String taskCode = entity.getTaskCode(); - if (taskCode != null) { - stmt.bindString(3, taskCode); - } - - String markerId = entity.getMarkerId(); - if (markerId != null) { - stmt.bindString(4, markerId); - } - stmt.bindDouble(5, entity.getLng()); - stmt.bindDouble(6, entity.getLat()); - - String isDetected = entity.getIsDetected(); - if (isDetected != null) { - stmt.bindString(7, isDetected); - } - - String detectedTime = entity.getDetectedTime(); - if (detectedTime != null) { - stmt.bindString(8, detectedTime); - } - } - - @Override - public Long readKey(Cursor cursor, int offset) { - return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); - } - - @Override - public TaskMarkerLocalBean readEntity(Cursor cursor, int offset) { - TaskMarkerLocalBean entity = new TaskMarkerLocalBean( // - cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // taskId - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // taskCode - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // markerId - cursor.getDouble(offset + 4), // lng - cursor.getDouble(offset + 5), // lat - cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // isDetected - cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7) // detectedTime - ); - return entity; - } - - @Override - public void readEntity(Cursor cursor, TaskMarkerLocalBean entity, int offset) { - entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setTaskId(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); - entity.setTaskCode(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); - entity.setMarkerId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); - entity.setLng(cursor.getDouble(offset + 4)); - entity.setLat(cursor.getDouble(offset + 5)); - entity.setIsDetected(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); - entity.setDetectedTime(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); - } - - @Override - protected final Long updateKeyAfterInsert(TaskMarkerLocalBean entity, long rowId) { - entity.setId(rowId); - return rowId; - } - - @Override - public Long getKey(TaskMarkerLocalBean entity) { - if(entity != null) { - return entity.getId(); - } else { - return null; - } - } - - @Override - public boolean hasKey(TaskMarkerLocalBean entity) { - return entity.getId() != null; - } - - @Override - protected final boolean isEntityUpdateable() { - return true; - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/model/TaskModel.java b/app/src/main/java/com/casic/common/detector/gd/model/TaskModel.java index 6e853ad..67ef5fb 100644 --- a/app/src/main/java/com/casic/common/detector/gd/model/TaskModel.java +++ b/app/src/main/java/com/casic/common/detector/gd/model/TaskModel.java @@ -24,7 +24,7 @@ } public static class MessageModel { - private int id; + private Long id; private String taskCode; private String description; private String deployDate; @@ -38,11 +38,11 @@ private int isValid; private List taskDetailInfos; - public int getId() { + public Long getId() { return id; } - public void setId(int id) { + public void setId(Long id) { this.id = id; } @@ -143,25 +143,25 @@ } public static class TaskDetailInfosModel { - private int id; + private long id; private String taskId; private String taskCode; private Object markerName; - private int markerId; + private String markerId; private String markerIdReal; private double longitude; private double latitude; private int isChecked; private int isNormal; - private Object imagePath; - private Object description; - private Object finishTime; + private String imagePath; + private String description; + private String finishTime; - public int getId() { + public long getId() { return id; } - public void setId(int id) { + public void setId(long id) { this.id = id; } @@ -189,11 +189,11 @@ this.markerName = markerName; } - public int getMarkerId() { + public String getMarkerId() { return markerId; } - public void setMarkerId(int markerId) { + public void setMarkerId(String markerId) { this.markerId = markerId; } @@ -237,27 +237,27 @@ this.isNormal = isNormal; } - public Object getImagePath() { + public String getImagePath() { return imagePath; } - public void setImagePath(Object imagePath) { + public void setImagePath(String imagePath) { this.imagePath = imagePath; } - public Object getDescription() { + public String getDescription() { return description; } - public void setDescription(Object description) { + public void setDescription(String description) { this.description = description; } - public Object getFinishTime() { + public String getFinishTime() { return finishTime; } - public void setFinishTime(Object finishTime) { + public void setFinishTime(String finishTime) { this.finishTime = finishTime; } } diff --git a/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitService.kt index 7522a87..0adad51 100644 --- a/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitService.kt @@ -50,7 +50,7 @@ */ @Multipart @POST("/ems/marker/save-marker-photo.do") - suspend fun installLabel( + suspend fun install( @PartMap jsonMarker: Map, @Part fileBuffer1: MultipartBody.Part?, @Part fileBuffer2: MultipartBody.Part?, diff --git a/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitServiceManager.kt index 5f6c701..ae2a0fa 100644 --- a/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitServiceManager.kt +++ b/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitServiceManager.kt @@ -37,22 +37,28 @@ /** * 获取标识器信息文件 */ - suspend fun getMarkerFile(userId: String, companyId: String): String { - return createApi().getMarkerFile(userId, companyId) + suspend fun getMarkerFile(): String { + val companyId = SaveKeyValues.getValue(LocaleConstant.USER_COMPANY_ID, "") as String + /** + * 后台设计如此,都传companyId + * */ + return createApi().getMarkerFile(companyId, companyId) } /** * 获取巡检工单 */ - suspend fun getTasksByUser(userName: String): String { + suspend fun getTasksByUser(): String { + val userName = SaveKeyValues.getValue(LocaleConstant.USER_NAME, "") as String return createApi().getTasksByUser(userName) } /** * 提交工单 */ - suspend fun uploadTask(userId: String, taskId: String?, state: String): String { + suspend fun uploadTask(taskId: String?, state: String): String { + val userId = SaveKeyValues.getValue(LocaleConstant.USER_ID, "") as String return createApi().uploadTask(userId, taskId.toString(), state) } @@ -60,8 +66,7 @@ * 安装新标识器 * Multipart上传图片,文件,带多参数上传 */ - suspend fun installLabel( - companyId: String, + suspend fun installMarker( recordType: String, markerObjectType: String, pipeMaterial: String, @@ -77,7 +82,6 @@ road: String, constructTime: String, ownerComp: String, - markerObjectId: String, markerId: String, markerType: String, markerDepth: String, @@ -89,6 +93,8 @@ memo: String, realPaths: ArrayList ): String { + val companyId = SaveKeyValues.getValue(LocaleConstant.USER_COMPANY_ID, "") as String + val objectId = SaveKeyValues.getValue(LocaleConstant.OBJECT_ID, "") as String val param = JsonObject() param.addProperty("companyId", companyId) param.addProperty("recordType", recordType) @@ -106,7 +112,7 @@ param.addProperty("road", road) param.addProperty("constructTime", constructTime) param.addProperty("ownerComp", ownerComp) - param.addProperty("markerObjectId", markerObjectId) + param.addProperty("markerObjectId", objectId) param.addProperty("markerId", markerId) param.addProperty("markerType", markerType) param.addProperty("markerDepth", markerDepth) @@ -133,19 +139,19 @@ return when (multiParts.size) { 3 -> { - createApi().installLabel(res, multiParts[0], multiParts[1], multiParts[2]) + createApi().install(res, multiParts[0], multiParts[1], multiParts[2]) } 2 -> { - createApi().installLabel(res, multiParts[0], multiParts[1], null) + createApi().install(res, multiParts[0], multiParts[1], null) } 1 -> { - createApi().installLabel(res, multiParts[0], null, null) + createApi().install(res, multiParts[0], null, null) } else -> { - createApi().installLabel(res, null, null, null) + createApi().install(res, null, null, null) } } } @@ -216,7 +222,7 @@ /** * 上传自由巡检过程中发现的标识器 */ - suspend fun uploadTaskMarker(taskId: String, ids: ArrayList): String { + suspend fun uploadTaskMarker(taskId: Long, ids: ArrayList): String { val param = JsonObject() param.addProperty("taskId", taskId) param.addProperty("ids", ids.joinToString(separator = ",")) diff --git a/app/src/main/java/com/casic/common/detector/gd/service/NtripConnectService.kt b/app/src/main/java/com/casic/common/detector/gd/service/NtripConnectService.kt index de9ac80..20e1a6a 100644 --- a/app/src/main/java/com/casic/common/detector/gd/service/NtripConnectService.kt +++ b/app/src/main/java/com/casic/common/detector/gd/service/NtripConnectService.kt @@ -9,10 +9,6 @@ import android.util.Log import android.view.Gravity import android.widget.Toast -import androidx.lifecycle.Lifecycle -import androidx.lifecycle.LifecycleOwner -import androidx.lifecycle.LifecycleRegistry -import androidx.lifecycle.lifecycleScope import com.casic.common.detector.gd.base.BaseApplication import com.casic.common.detector.gd.extensions.convertToGPGGA import com.casic.common.detector.gd.utils.LocaleConstant @@ -23,26 +19,24 @@ import com.pengxh.kt.lite.utils.WeakReferenceHandler import com.pengxh.kt.lite.utils.socket.tcp.OnTcpConnectStateListener import com.pengxh.kt.lite.utils.socket.tcp.TcpClient +import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.Job import kotlinx.coroutines.launch import java.io.OutputStream import java.nio.charset.StandardCharsets -class NtripConnectService : Service(), LifecycleOwner, OnTcpConnectStateListener, Handler.Callback { +class NtripConnectService : Service(), OnTcpConnectStateListener, Handler.Callback { companion object { var weakReferenceHandler: WeakReferenceHandler? = null } private val kTag = "NtripConnectService" - private val registry = LifecycleRegistry(this) private val socketClient by lazy { TcpClient(this) } private var outStream: OutputStream? = null - - override fun getLifecycle(): Lifecycle { - return registry - } + private val serviceScope = CoroutineScope(Dispatchers.Main + Job()) // 创建一个独立的CoroutineScope override fun onBind(intent: Intent?): IBinder? { return null @@ -117,7 +111,7 @@ * */ val result = String(this, StandardCharsets.UTF_8) if (result.contains("ICY 200 OK")) { - lifecycleScope.launch(Dispatchers.Main) { + serviceScope.launch { "高精度定位服务连接成功".show(this@NtripConnectService) } //连接服务即打开串口 @@ -135,12 +129,12 @@ * Content-Type: text/plain * Connection: clos * */ - lifecycleScope.launch(Dispatchers.Main) { + serviceScope.launch { "差分定位服务鉴权失败,无法解析位置".show(this@NtripConnectService) } } else { //居中显示 - lifecycleScope.launch(Dispatchers.Main) { + serviceScope.launch { val toast = Toast.makeText( this@NtripConnectService, "收到千寻数据,长度:${size}", Toast.LENGTH_SHORT ) @@ -167,7 +161,7 @@ return } - lifecycleScope.launch(Dispatchers.IO) { + serviceScope.launch(Dispatchers.IO) { socketClient.start(remoteHost, remotePort.toInt()) } } diff --git a/app/src/main/java/com/casic/common/detector/gd/utils/DataBaseManager.kt b/app/src/main/java/com/casic/common/detector/gd/utils/DataBaseManager.kt deleted file mode 100644 index aa22759..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/utils/DataBaseManager.kt +++ /dev/null @@ -1,200 +0,0 @@ -package com.casic.common.detector.gd.utils - -import com.casic.common.detector.gd.base.BaseApplication -import com.casic.common.detector.gd.bean.MarkerLocalBean -import com.casic.common.detector.gd.bean.TaskLocalBean -import com.casic.common.detector.gd.bean.TaskMarkerLocalBean -import com.casic.common.detector.gd.greendao.MarkerLocalBeanDao -import com.casic.common.detector.gd.greendao.TaskLocalBeanDao -import com.casic.common.detector.gd.greendao.TaskMarkerLocalBeanDao -import com.casic.common.detector.gd.model.TaskDetailLocalModel -import com.casic.common.detector.gd.model.TaskModel - -class DataBaseManager private constructor() { - companion object { - //Kotlin委托模式双重锁单例 - val get by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) { - DataBaseManager() - } - } - - private var taskLocalBeanDao = BaseApplication.get().getDaoSession().taskLocalBeanDao - private var taskMarkerLocalBeanDao = - BaseApplication.get().getDaoSession().taskMarkerLocalBeanDao - - fun saveTaskInLocale(task: TaskModel.MessageModel) { - val bean = TaskLocalBean() - bean.id = task.id.toLong() - bean.taskCode = task.taskCode - bean.description = task.description - bean.createTime = task.deployDate - bean.status = task.status - bean.createUserName = task.creatorName - if (task.beginDate == null) { - bean.startTime = "" - } - if (task.endDate == null) { - bean.endTime = "" - } - bean.isFreeTask = "0" - if (!bean.isExist()) { - taskLocalBeanDao.insert(bean) - } - } - - fun saveTaskInLocale(bean: TaskLocalBean) { - if (!bean.isExist()) { - taskLocalBeanDao.insert(bean) - } - } - - private fun TaskLocalBean.isExist(): Boolean { - val result = taskLocalBeanDao.queryBuilder().where( - TaskLocalBeanDao.Properties.Id.eq(this.id) - ).list() - return !result.isNullOrEmpty() - } - - fun saveTaskMarkerInLocale( - taskId: Int, taskCode: String, marker: TaskModel.MessageModel.TaskDetailInfosModel - ) { - val bean = TaskMarkerLocalBean() - bean.id = marker.id.toLong() - bean.taskId = taskId.toString() - bean.taskCode = taskCode - bean.markerId = marker.markerIdReal - bean.lng = marker.longitude - bean.lat = marker.latitude - bean.isDetected = "0" - bean.detectedTime = "" - if (!bean.isExist()) { - taskMarkerLocalBeanDao.insert(bean) - } - } - - private fun TaskMarkerLocalBean.isExist(): Boolean { - val result = taskMarkerLocalBeanDao.queryBuilder().where( - TaskMarkerLocalBeanDao.Properties.Id.eq(this.id) - ).list() - return !result.isNullOrEmpty() - } - - fun loadLocalTask(): ArrayList { - val result = ArrayList() - - val tasks = taskLocalBeanDao.loadAll() - tasks.forEach { - val model = TaskDetailLocalModel() - model.taskId = it.id.toString() - model.taskCode = it.taskCode - model.description = it.description - model.createTime = it.createTime - model.status = it.status - model.createUserName = it.createUserName - model.isFreeTask = it.isFreeTask - - val markers = ArrayList() - if (it.isFreeTask == "0") { - //非自由巡检才有Marker - val markerLocalBeans = taskMarkerLocalBeanDao.queryBuilder().where( - TaskMarkerLocalBeanDao.Properties.TaskId.eq(it.id), - TaskMarkerLocalBeanDao.Properties.TaskCode.eq(it.taskCode) - ).list() - markerLocalBeans.forEach { marker -> - val localModel = TaskDetailLocalModel.TaskMarkerLocalModel() - localModel.markerId = marker.markerId - localModel.lng = marker.lng - localModel.lat = marker.lat - localModel.isDetected = marker.isDetected - localModel.detectedTime = marker.detectedTime - - markers.add(localModel) - } - } - model.markerModels = markers - result.add(model) - } - return result - } - - fun deleteLocalTaskById(taskId: String, taskCode: String) { - val task = taskLocalBeanDao.queryBuilder().where( - TaskLocalBeanDao.Properties.Id.eq(taskId), - TaskLocalBeanDao.Properties.TaskCode.eq(taskCode) - ).list().firstOrNull() ?: return - taskLocalBeanDao.delete(task) - - //删除此任务关联的Marker。非自由巡检才有Marker - if (task.isFreeTask == "0") { - val markers = taskMarkerLocalBeanDao.queryBuilder() - .where( - TaskMarkerLocalBeanDao.Properties.TaskId.eq(taskId), - TaskMarkerLocalBeanDao.Properties.TaskCode.eq(taskCode) - ).list() - markers.forEach { - taskMarkerLocalBeanDao.delete(it) - } - } - } - - fun queryTaskMarkerById( - taskId: String, taskCode: String, markerId: String, state: String - ): TaskMarkerLocalBean? { - return taskMarkerLocalBeanDao.queryBuilder() - .where( - TaskMarkerLocalBeanDao.Properties.TaskId.eq(taskId), - TaskMarkerLocalBeanDao.Properties.TaskCode.eq(taskCode), - TaskMarkerLocalBeanDao.Properties.MarkerId.eq(markerId), - TaskMarkerLocalBeanDao.Properties.IsDetected.eq(state) - ).list().firstOrNull() - } - - fun updateLocalTaskMarkerState(marker: TaskMarkerLocalBean) { - marker.isDetected = "1" - taskMarkerLocalBeanDao.update(marker) - } - - fun queryMarkerByState(state: String): List { - return taskMarkerLocalBeanDao.queryBuilder() - .where(TaskMarkerLocalBeanDao.Properties.IsDetected.eq(state)) - .list() - } - - private var markerLocalBeanDao = BaseApplication.get().getDaoSession().markerLocalBeanDao - - fun clearMarkers() { - markerLocalBeanDao.deleteAll() - } - - fun saveMarkerInLocale(bean: MarkerLocalBean) { - markerLocalBeanDao.insert(bean) - } - - fun loadMarkers(): MutableList { - return markerLocalBeanDao.loadAll() - } - - fun loadMarkersByCondition(selectedItem: String, value: String?): MutableList { - val property = when (selectedItem) { - LocaleConstant.SPINNER_ARRAY[0] -> MarkerLocalBeanDao.Properties.MarkerId - LocaleConstant.SPINNER_ARRAY[1] -> MarkerLocalBeanDao.Properties.Area - LocaleConstant.SPINNER_ARRAY[2] -> MarkerLocalBeanDao.Properties.Line - LocaleConstant.SPINNER_ARRAY[3] -> MarkerLocalBeanDao.Properties.Road - LocaleConstant.SPINNER_ARRAY[4] -> MarkerLocalBeanDao.Properties.Owner - LocaleConstant.SPINNER_ARRAY[5] -> MarkerLocalBeanDao.Properties.InstallationDept - LocaleConstant.SPINNER_ARRAY[6] -> MarkerLocalBeanDao.Properties.UpdateTime - else -> MarkerLocalBeanDao.Properties.Remark - } - return if (value == null) { - markerLocalBeanDao.queryBuilder().where(property.isNotNull).list() - } else { - markerLocalBeanDao.queryBuilder().where(property.eq(value)).list() - } - } - - fun queryMarkerById(markerId: String): List { - return markerLocalBeanDao.queryBuilder() - .where(MarkerLocalBeanDao.Properties.MarkerId.eq(markerId)) - .list() - } -} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/utils/DetectorDataBase.java b/app/src/main/java/com/casic/common/detector/gd/utils/DetectorDataBase.java new file mode 100644 index 0000000..f686cac --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/utils/DetectorDataBase.java @@ -0,0 +1,21 @@ +package com.casic.common.detector.gd.utils; + +import androidx.room.Database; +import androidx.room.RoomDatabase; + +import com.casic.common.detector.gd.bean.MarkerBean; +import com.casic.common.detector.gd.bean.TaskBean; +import com.casic.common.detector.gd.bean.TaskMarkerBean; +import com.casic.common.detector.gd.dao.MarkerBeanDao; +import com.casic.common.detector.gd.dao.TaskBeanDao; +import com.casic.common.detector.gd.dao.TaskMarkerBeanDao; + + +@Database(entities = {MarkerBean.class, TaskBean.class, TaskMarkerBean.class}, version = 1) +public abstract class DetectorDataBase extends RoomDatabase { + public abstract MarkerBeanDao markerBeanDao(); + + public abstract TaskBeanDao taskBeanDao(); + + public abstract TaskMarkerBeanDao taskMarkerBeanDao(); +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/utils/ExcelKit.kt b/app/src/main/java/com/casic/common/detector/gd/utils/ExcelKit.kt index 200fac7..015969f 100644 --- a/app/src/main/java/com/casic/common/detector/gd/utils/ExcelKit.kt +++ b/app/src/main/java/com/casic/common/detector/gd/utils/ExcelKit.kt @@ -1,19 +1,19 @@ package com.casic.common.detector.gd.utils -import com.casic.common.detector.gd.bean.MarkerLocalBean +import com.casic.common.detector.gd.base.BaseApplication +import com.casic.common.detector.gd.bean.MarkerBean import jxl.Workbook import jxl.read.biff.BiffException import java.io.File object ExcelKit { - fun read(filePath: String): ArrayList { - val result = ArrayList() + fun read(filePath: String): ArrayList { + val result = ArrayList() try { val workbook = Workbook.getWorkbook(File(filePath)) val sheet = workbook.getSheet(0) - for (i in 1 until sheet.rows) { - val marker = MarkerLocalBean() + val marker = MarkerBean() marker.pipelineType = sheet.getCell(0, i).contents marker.pipelineDiameter = sheet.getCell(1, i).contents marker.pipelineMaterial = sheet.getCell(2, i).contents @@ -40,9 +40,10 @@ marker.objectType = sheet.getCell(23, i).contents marker.color = sheet.getCell(24, i).contents marker.imagePath = sheet.getCell(25, i).contents - - result.add(marker) - DataBaseManager.get.saveMarkerInLocale(marker) + if (!marker.markerId.isNullOrBlank()) { + result.add(marker) + BaseApplication.get().dataBase.markerBeanDao().insert(marker) + } } workbook.close() } catch (e: BiffException) { diff --git a/app/src/main/java/com/casic/common/detector/gd/utils/LocaleConstant.kt b/app/src/main/java/com/casic/common/detector/gd/utils/LocaleConstant.kt index c658924..8ac5f76 100644 --- a/app/src/main/java/com/casic/common/detector/gd/utils/LocaleConstant.kt +++ b/app/src/main/java/com/casic/common/detector/gd/utils/LocaleConstant.kt @@ -1,6 +1,8 @@ package com.casic.common.detector.gd.utils import android.Manifest +import androidx.sqlite.db.SimpleSQLiteQuery +import androidx.sqlite.db.SupportSQLiteQuery object LocaleConstant { @@ -59,4 +61,19 @@ var BURY_METHOD_ARRAY = arrayOf("直埋", "圆管", "管块", "管沟", "架空") var IDENTIFIER_TYPE_ARRAY = arrayOf("EM30", "EM50", "EM14") var COLOR_ARRAY = arrayOf("蓝色", "橙色", "红色", "黑色", "紫色", "黄色", "绿色") + + fun buildQuery(selectedItem: String, value: String): SupportSQLiteQuery { + val columnName = when (selectedItem) { + SPINNER_ARRAY[0] -> "markerId" + SPINNER_ARRAY[1] -> "area" + SPINNER_ARRAY[2] -> "line" + SPINNER_ARRAY[3] -> "road" + SPINNER_ARRAY[4] -> "owner" + SPINNER_ARRAY[5] -> "installationDept" + SPINNER_ARRAY[6] -> "updateTime" + else -> "remark" + } + val queryBuilder = StringBuilder("SELECT * FROM marker_detail WHERE $columnName = ?") + return SimpleSQLiteQuery(queryBuilder.toString(), arrayOf(value)) + } } \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/view/InstallMarkerActivity.kt b/app/src/main/java/com/casic/common/detector/gd/view/InstallMarkerActivity.kt index daf5b0f..9e09df1 100644 --- a/app/src/main/java/com/casic/common/detector/gd/view/InstallMarkerActivity.kt +++ b/app/src/main/java/com/casic/common/detector/gd/view/InstallMarkerActivity.kt @@ -14,8 +14,9 @@ import com.amap.api.location.AMapLocation import com.casic.common.detector.gd.R import com.casic.common.detector.gd.adapter.EditableImageAdapter +import com.casic.common.detector.gd.base.BaseApplication import com.casic.common.detector.gd.base.SerialPortBaseActivity -import com.casic.common.detector.gd.bean.MarkerLocalBean +import com.casic.common.detector.gd.bean.MarkerBean import com.casic.common.detector.gd.callback.OnGetLocationListener import com.casic.common.detector.gd.callback.OnImageCompressListener import com.casic.common.detector.gd.databinding.ActivityInstallMarkerBinding @@ -27,7 +28,6 @@ import com.casic.common.detector.gd.extensions.toColor import com.casic.common.detector.gd.extensions.toObjectType import com.casic.common.detector.gd.utils.CurrentSegment -import com.casic.common.detector.gd.utils.DataBaseManager import com.casic.common.detector.gd.utils.LocaleConstant import com.casic.common.detector.gd.utils.LocationKit import com.casic.common.detector.gd.utils.RuntimeCache @@ -44,7 +44,6 @@ import com.pengxh.kt.lite.extensions.timestampToCompleteDate import com.pengxh.kt.lite.extensions.timestampToTime import com.pengxh.kt.lite.extensions.toJson -import com.pengxh.kt.lite.utils.LoadState import com.pengxh.kt.lite.utils.LoadingDialog import com.pengxh.kt.lite.utils.SaveKeyValues import com.pengxh.kt.lite.widget.TitleBarView @@ -115,8 +114,6 @@ //安装 binding.installButton.setOnClickListener { - val companyId = SaveKeyValues.getValue(LocaleConstant.USER_COMPANY_ID, "") as String - val objectId = SaveKeyValues.getValue(LocaleConstant.OBJECT_ID, "") as String if (binding.objectInclude.pipeInclude.markerObjectTypeView.text.isNullOrBlank()) { when (binding.objectInclude.objectTypeSpinner.selectedItem.toString()) { "管线" -> "请输入管线种类!".show(this) @@ -189,8 +186,7 @@ //先存本地再上传服务器 saveMarkerInLocal() - taskViewModel.installLabel( - this, companyId, + taskViewModel.installMarker( binding.objectInclude.objectTypeSpinner.selectedItem.toString().toObjectType(), binding.objectInclude.pipeInclude.markerObjectTypeView.text.toString(), binding.objectInclude.pipeInclude.materialSpinner.selectedItem.toString(), @@ -206,7 +202,6 @@ binding.objectInclude.roadView.text.toString(), binding.objectInclude.constructDateView.text.toString(), binding.objectInclude.ownerView.text.toString(), - objectId, binding.identifierInclude.identifierIdView.text.toString(), binding.identifierInclude.identifierTypeSpinner.selectedItem.toString(), "${binding.identifierInclude.identifierDeepView.text}mm", @@ -216,7 +211,19 @@ binding.identifierInclude.latView.text.toString(), binding.identifierInclude.colorSpinner.selectedItem.toString().toColor(), binding.remarkView.text.toString(), - realPaths + realPaths, + onLoading = { + LoadingDialog.show(this, "标识器安装中,请稍后...") + }, + onSuccess = { + LoadingDialog.dismiss() + clearDefaultData() + "安装成功".show(this) + }, + onFailed = { + LoadingDialog.dismiss() + it.show(this) + } ) //保存默认值 @@ -268,7 +275,7 @@ private fun saveMarkerInLocal() { val objectId = SaveKeyValues.getValue(LocaleConstant.OBJECT_ID, "") as String - val marker = MarkerLocalBean() + val marker = MarkerBean() marker.objectType = binding.objectInclude.objectTypeSpinner.selectedItem.toString() marker.pipelineType = binding.objectInclude.pipeInclude.markerObjectTypeView.text.toString() marker.pipelineMaterial = @@ -302,7 +309,7 @@ marker.remark = binding.remarkView.text.toString() marker.imagePath = realPaths.toJson() - DataBaseManager.get.saveMarkerInLocale(marker) + BaseApplication.get().dataBase.markerBeanDao().insert(marker) } private fun takePicture() { @@ -339,8 +346,8 @@ override fun initOnCreate(savedInstanceState: Bundle?) { locationKit.getCurrentLocation(true, object : OnGetLocationListener { override fun onSuccess(location: AMapLocation) { - binding.identifierInclude.lngView.text = location.longitude.toString() - binding.identifierInclude.latView.text = location.latitude.toString() + binding.identifierInclude.lngView.text = "${location.longitude}" + binding.identifierInclude.latView.text = "${location.latitude}" } override fun onError() { @@ -357,22 +364,6 @@ return ActivityInstallMarkerBinding.inflate(layoutInflater) } - override fun observeRequestState() { - taskViewModel.loadState.observe(this) { - when (it) { - LoadState.Loading -> LoadingDialog.show(this, "标识器安装中,请稍后...") - - LoadState.Success -> { - LoadingDialog.dismiss() - clearDefaultData() - "安装成功".show(this) - } - - else -> LoadingDialog.dismiss() - } - } - } - override fun setupTopBarLayout() { binding.rootView.initImmersionBar(this, true, R.color.white) binding.titleView.setOnClickListener(object : TitleBarView.OnClickListener { diff --git a/app/src/main/java/com/casic/common/detector/gd/view/MainActivity.kt b/app/src/main/java/com/casic/common/detector/gd/view/MainActivity.kt index fb0b260..a6352fb 100644 --- a/app/src/main/java/com/casic/common/detector/gd/view/MainActivity.kt +++ b/app/src/main/java/com/casic/common/detector/gd/view/MainActivity.kt @@ -5,7 +5,6 @@ import android.graphics.Color import android.media.AudioAttributes import android.media.SoundPool -import android.os.Build import android.os.Bundle import android.os.CountDownTimer import android.os.Handler @@ -31,19 +30,17 @@ import com.casic.common.detector.gd.R import com.casic.common.detector.gd.base.BaseApplication import com.casic.common.detector.gd.base.SerialPortBaseActivity -import com.casic.common.detector.gd.bean.MarkerLocalBean -import com.casic.common.detector.gd.bean.TaskLocalBean +import com.casic.common.detector.gd.bean.MarkerBean import com.casic.common.detector.gd.callback.OnGetAddressListener import com.casic.common.detector.gd.callback.OnGetLocationListener import com.casic.common.detector.gd.databinding.ActivityMainBinding import com.casic.common.detector.gd.extensions.appendDownloadUrl -import com.casic.common.detector.gd.extensions.createTaskCode import com.casic.common.detector.gd.extensions.initImmersionBar +import com.casic.common.detector.gd.model.MarkerFileModel import com.casic.common.detector.gd.model.TaskDetailLocalModel import com.casic.common.detector.gd.model.TaskModel import com.casic.common.detector.gd.service.NtripConnectService import com.casic.common.detector.gd.utils.CurrentSegment -import com.casic.common.detector.gd.utils.DataBaseManager import com.casic.common.detector.gd.utils.ExcelKit import com.casic.common.detector.gd.utils.FileType import com.casic.common.detector.gd.utils.LocaleConstant @@ -62,9 +59,7 @@ import com.pengxh.kt.lite.extensions.isNetworkConnected import com.pengxh.kt.lite.extensions.navigatePageTo import com.pengxh.kt.lite.extensions.show -import com.pengxh.kt.lite.extensions.timestampToCompleteDate import com.pengxh.kt.lite.utils.FileDownloadManager -import com.pengxh.kt.lite.utils.LoadState import com.pengxh.kt.lite.utils.LoadingDialog import com.pengxh.kt.lite.utils.SaveKeyValues import com.pengxh.kt.lite.widget.TitleBarView @@ -86,6 +81,9 @@ private val samplePopupWindow by lazy { SamplePopupWindow(this) } private val detailDialog by lazy { MarkerDetailDialog(this) } private val locationKit by lazy { LocationKit(this) } + private val markerBeanDao by lazy { BaseApplication.get().dataBase.markerBeanDao() } + private val taskBeanDao by lazy { BaseApplication.get().dataBase.taskBeanDao() } + private val taskMarkerBeanDao by lazy { BaseApplication.get().dataBase.taskMarkerBeanDao() } private val taskViewModel by lazy { ViewModelProvider(this)[TaskViewModel::class.java] } private val attr = AudioAttributes.Builder().setUsage(AudioAttributes.USAGE_ALARM) .setContentType(AudioAttributes.CONTENT_TYPE_MUSIC).build() @@ -94,7 +92,7 @@ private var isFreeTask = false private var freeTaskTitle = "" private var ids = ArrayList() - private var freeTaskId: String? = null + private var freeTaskId = 0L private var soundResourceId = 0 private var isExecuteTask = false private lateinit var aMap: AMap @@ -111,89 +109,14 @@ //地图初始化 initMapConfig(savedInstanceState) - Intent(this, NtripConnectService::class.java).also { - startService(it) - } +// Intent(this, NtripConnectService::class.java).apply { +// startService(this) +// } soundResourceId = soundPool.load(this, R.raw.ring3, 1) //右上角菜单 samplePopupWindow.setPopupMenuItem(LocaleConstant.POPUP_TITLES) samplePopupWindow.setBackgroundDrawable(null) - - //task网络请求监听 - taskViewModel.markerFileResult.observe(this) { - if (it.isSuccess) { - //清空之前的数据 - DataBaseManager.get.clearMarkers() - //下载最新的数据 - val companyId = SaveKeyValues.getValue(LocaleConstant.USER_COMPANY_ID, "") - val downloadUrl = companyId.toString().appendDownloadUrl(FileType.Excel) - Log.d(kTag, "downloadUrl => $downloadUrl") - FileDownloadManager.Builder().setDownloadFileSource(downloadUrl) - .setFileSuffix("xls").setFileSaveDirectory(createDownloadFileDir()) - .setOnFileDownloadListener(object : FileDownloadManager.OnFileDownloadListener { - override fun onDownloadStart(total: Long) { - - } - - override fun onDownloadEnd(file: File) { - lifecycleScope.launch(Dispatchers.IO) { ExcelKit.read(file.absolutePath) } - LoadingDialog.dismiss() - showMarkersOnMap() - } - - override fun onDownloadFailed(t: Throwable) { - t.printStackTrace() - } - - override fun onProgressChanged(progress: Long) { - - } - }).build().start() - } - } - taskViewModel.taskResult.observe(this) { - if (it.success == "true") { - AlertMessageDialog.Builder().setContext(this).setTitle("温馨提示") - .setMessage("您有${it.message.size}个新任务!").setPositiveButton("知道了") - .setOnDialogButtonClickListener(object : - AlertMessageDialog.OnDialogButtonClickListener { - override fun onConfirmClick() { - saveUserTasks(it) - } - }).build().show() - } - } - taskViewModel.freeTaskResult.observe(this) { - freeTaskId = it - // 自由巡检保存在本地 - val bean = TaskLocalBean() - bean.id = freeTaskId.toString().toLong() - val currentTimeMillis = System.currentTimeMillis() - bean.taskCode = currentTimeMillis.createTaskCode() - bean.description = freeTaskTitle - val time = currentTimeMillis.timestampToCompleteDate() - bean.createTime = time - bean.status = "0" - val userName = SaveKeyValues.getValue(LocaleConstant.USER_NAME, "") as String - bean.createUserName = userName - bean.startTime = time - bean.endTime = "" - bean.isFreeTask = "1" - DataBaseManager.get.saveTaskInLocale(bean) - } - taskViewModel.uploadTaskMarkerResult.observe(this) { - "自由巡检任务已完成".show(this) - ids.clear() - //清空自由巡检添加的Marker - aMap.clear() - showMarkersOnMap() - } - taskViewModel.executeTaskResult.observe(this) { - "工单任务已完成".show(this) - aMap.clear() - showMarkersOnMap() - } } override fun initEvent() { @@ -216,7 +139,7 @@ }).build().show() } else { lifecycleScope.launch(Dispatchers.Main) { - val markers = DataBaseManager.get.queryMarkerByState("0") + val markers = taskMarkerBeanDao.queryMarkerByState("0") //如果有需要补全的标识器,Popup右侧会有小圆点提示 if (markers.isNotEmpty()) { samplePopupWindow.setShowPosition(4) @@ -239,13 +162,7 @@ 3 -> uploadEvent() 4 -> completionMarker() 5 -> showRtkConfigDialog() - 6 -> { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { - SatelliteStatusDialog(context).show() - } else { - "卫星数据仅支持Android 7.0以上系统".show(context) - } - } + 6 -> SatelliteStatusDialog(context).show() } } }) @@ -268,25 +185,23 @@ //查看 binding.viewButton.setOnClickListener { - QueryMarkerDialog.Builder().setContext(this).setTitle("查看标识器") - .setSpinnerArray(LocaleConstant.SPINNER_ARRAY).setNegativeButton("取消") + QueryMarkerDialog.Builder() + .setContext(this) + .setTitle("查看标识器") + .setSpinnerArray(LocaleConstant.SPINNER_ARRAY) + .setNegativeButton("取消") .setPositiveButton("确定").setOnDialogButtonClickListener(object : QueryMarkerDialog.OnDialogButtonClickListener { override fun onConfirmClick(selectedItem: String, value: String) { //查询数据库 - lifecycleScope.launch(Dispatchers.Main) { - val markers = DataBaseManager.get.loadMarkersByCondition( - selectedItem, value - ) as ArrayList - - if (markers.isEmpty()) { - "无法查到相关数据信息,请检查您的查询条件".show(context) - } else { + val buildQuery = LocaleConstant.buildQuery(selectedItem, value) + markerBeanDao.loadMarkersByCondition(buildQuery).run { + if (isNotEmpty()) { val latitudeList = ArrayList() val longitudeList = ArrayList() - val latitude = markers.first().lat - val longitude = markers.first().lng + val latitude = first().lat + val longitude = first().lng if (latitude.isNotBlank() && longitude.isNotBlank()) { if (CoordinateConverter.isAMapDataAvailable( latitude.toDouble(), longitude.toDouble() @@ -300,10 +215,11 @@ if (latitudeList.isNotEmpty() && longitudeList.isNotEmpty()) { //移动地图到所有labelBeans的第一个点 - val center = LatLng(latitudeList.first(), longitudeList.first()) - //移动到指定经纬度 - aMap.moveCamera(CameraUpdateFactory.newLatLngZoom(center, 16f)) + val target = LatLng(latitudeList.first(), longitudeList.first()) + aMap.moveCamera(CameraUpdateFactory.newLatLngZoom(target, 16f)) } + } else { + "无法查到相关信息,请检查您的查询条件".show(context) } } } @@ -316,32 +232,39 @@ //巡检 binding.inspectionButton.setOnClickListener { - val tasks = DataBaseManager.get.loadLocalTask() - if (tasks.isNotEmpty()) { - val arrayList = ArrayList() - tasks.forEachIndexed { index, task -> - arrayList.add("任务${index + 1}:${task.taskId},${task.description}") + lifecycleScope.launch { + val tasks = withContext(Dispatchers.IO) { + taskBeanDao.loadLocalTask(taskMarkerBeanDao) } + if (tasks.isNotEmpty()) { + val arrayList = ArrayList() + tasks.forEachIndexed { index, task -> + arrayList.add("任务${index + 1}:${task.taskId},${task.description}") + } - BottomActionSheet.Builder().setContext(this).setItemTextColor(Color.BLUE) - .setActionItemTitle(arrayList) - .setOnActionSheetListener(object : BottomActionSheet.OnActionSheetListener { - override fun onActionItemClick(position: Int) { - val task = tasks[position] - SaveKeyValues.putValue(LocaleConstant.TASK_ID, task.taskId) - SaveKeyValues.putValue(LocaleConstant.TASK_CODE, task.taskCode) - executeTask(task) - } - }).build().show() - } else { - AlertMessageDialog.Builder().setContext(this).setTitle("温馨提示") - .setMessage("所有任务已完成,请点击右上角菜单下载新工单或者开始自由巡检") - .setPositiveButton("开始自由巡检").setOnDialogButtonClickListener(object : - AlertMessageDialog.OnDialogButtonClickListener { - override fun onConfirmClick() { - executeFreeTask() - } - }).build().show() + BottomActionSheet.Builder().setContext(context) + .setItemTextColor(Color.BLUE) + .setActionItemTitle(arrayList) + .setOnActionSheetListener(object : BottomActionSheet.OnActionSheetListener { + override fun onActionItemClick(position: Int) { + val task = tasks[position] + SaveKeyValues.putValue(LocaleConstant.TASK_ID, task.taskId) + SaveKeyValues.putValue(LocaleConstant.TASK_CODE, task.taskCode) + executeTask(task) + } + }).build().show() + } else { + AlertMessageDialog.Builder() + .setContext(context) + .setTitle("温馨提示") + .setMessage("所有任务已完成,请点击右上角菜单下载新工单或者开始自由巡检") + .setPositiveButton("开始自由巡检").setOnDialogButtonClickListener(object : + AlertMessageDialog.OnDialogButtonClickListener { + override fun onConfirmClick() { + executeFreeTask() + } + }).build().show() + } } } @@ -371,8 +294,11 @@ //自由巡检 binding.stopFreeTaskButton.setOnLongClickListener { - AlertMessageDialog.Builder().setContext(this).setTitle("温馨提示") - .setMessage("是否确定结束此次自由巡检任务?").setPositiveButton("是") + AlertMessageDialog.Builder() + .setContext(this) + .setTitle("温馨提示") + .setMessage("是否确定结束此次自由巡检任务?") + .setPositiveButton("是") .setOnDialogButtonClickListener(object : AlertMessageDialog.OnDialogButtonClickListener { override fun onConfirmClick() { @@ -381,14 +307,38 @@ stopSerialPortCommand() binding.stopFreeTaskButton.visibility = View.GONE - if (freeTaskId.isNullOrBlank()) { + if (freeTaskId == 0L) { "任务ID异常,无法提交任务,请联系服务器管理员".show(context) return } - freeTaskId?.apply { - taskViewModel.uploadTaskMarker(context, this, ids) - } + taskViewModel.uploadTaskMarker( + freeTaskId, + ids, + onLoading = { + LoadingDialog.show(context, "任务提交中,请稍后...") + }, + onSuccess = { + LoadingDialog.dismiss() + "自由巡检任务已完成".show(context) + ids.clear() + aMap.clear() + showMarkersOnMap() + + //删除本地数据库 + val taskCode = SaveKeyValues.getValue( + LocaleConstant.TASK_CODE, "" + ) as String + taskBeanDao.deleteLocalTaskById( + freeTaskId, taskCode, taskMarkerBeanDao + ) + SaveKeyValues.putValue(LocaleConstant.TASK_ID, "") + }, + onFailed = { + LoadingDialog.dismiss() + it.show(context) + } + ) } }).build().show() true @@ -399,25 +349,52 @@ RtkConfigDialog(this).setOnDialogButtonClickListener(object : RtkConfigDialog.OnDialogButtonClickListener { override fun onConfirmClick() { - NtripConnectService.weakReferenceHandler?.apply { - sendEmptyMessage(2024082201) - } + NtripConnectService.weakReferenceHandler?.sendEmptyMessage(2024082201) } }).show() } private fun uploadTask(taskId: String, taskCode: String, state: String) { if (isNetworkConnected()) { - val userId = SaveKeyValues.getValue(LocaleConstant.USER_ID, "") as String - taskViewModel.uploadTask(this, userId, taskId, taskCode, state) + taskViewModel.uploadTask( + taskId, state, + onLoading = { + LoadingDialog.show(this, "工单提交中,请稍后...") + }, + onSuccess = { + LoadingDialog.dismiss() + //工单提交之后,并且状态是2,删除本地Task记录 + if (state == "2") { + "工单${taskId}已提交!".show(this) + //删除本地数据库 + taskBeanDao.deleteLocalTaskById( + taskId.toLong(), taskCode, taskMarkerBeanDao + ) + SaveKeyValues.putValue(LocaleConstant.TASK_ID, "") + } else { + Log.d(kTag, "uploadTask: 仅执行工单,不删除本地工单数据") + } + aMap.clear() + showMarkersOnMap() + "工单任务已完成".show(this) + }, + onFailed = { + LoadingDialog.dismiss() + it.show(this) + } + ) } else { "网络连接已断开,请检查".show(this) } } private fun executeTask(task: TaskDetailLocalModel) { - AlertControlDialog.Builder().setContext(this).setTitle("提示").setMessage("请选择操作方式") - .setPositiveButton("执行工单").setNegativeButton("提交工单") + AlertControlDialog.Builder() + .setContext(this) + .setTitle("提示") + .setMessage("请选择操作方式") + .setPositiveButton("执行工单") + .setNegativeButton("提交工单") .setOnDialogButtonClickListener(object : AlertControlDialog.OnDialogButtonClickListener { override fun onConfirmClick() { @@ -432,7 +409,7 @@ isExecuteTask = true } else { "此工单下无标识器,将执行自由巡检任务".show(context) - freeTaskId = task.taskId + freeTaskId = task.taskId.toLong() detectMarker() } } @@ -453,7 +430,18 @@ override fun onConfirmClick(value: String) { freeTaskTitle = value val userId = SaveKeyValues.getValue(LocaleConstant.USER_ID, "") as String - taskViewModel.createFreeTask(context, userId, value) + taskViewModel.createFreeTask( + userId, value, + onLoading = {}, + onSuccess = { + freeTaskId = it + // 自由巡检保存在本地 + taskBeanDao.saveTask(it, freeTaskTitle) + }, + onFailed = { + it.show(context) + } + ) detectMarker() } @@ -481,7 +469,7 @@ if (RuntimeCache.currentSegment == CurrentSegment.FreeInspection) { //显示标识器详细信息 if (!detailDialog.isShowing) { - DataBaseManager.get.queryMarkerById(markerId).firstOrNull().apply { + markerBeanDao.queryMarkerById(markerId).firstOrNull().apply { if (this == null) { "无法查询到此ID【${markerId}】的信息".show(context) } else { @@ -501,7 +489,7 @@ //不重复标注Marker if (!ids.contains(markerId)) { - val markers = DataBaseManager.get.queryMarkerById(markerId) + val markers = markerBeanDao.queryMarkerById(markerId) if (markers.isNotEmpty()) { val marker = markers.first() val latLng = LatLng(marker.lat.toDouble(), marker.lng.toDouble()) @@ -522,16 +510,6 @@ } - override fun observeRequestState() { - taskViewModel.loadState.observe(this) { - when (it) { - LoadState.Loading -> LoadingDialog.show(this, "提交工单中,请稍后") - - else -> LoadingDialog.dismiss() - } - } - } - private fun initMapConfig(savedInstanceState: Bundle?) { binding.mapView.onCreate(savedInstanceState) aMap = binding.mapView.map @@ -592,54 +570,25 @@ private fun saveUserTasks(task: TaskModel) { task.message.forEach { model -> //保存任务详情 - DataBaseManager.get.saveTaskInLocale(model) + taskBeanDao.saveTask(model) model.taskDetailInfos.forEach { marker -> //只保存有标识器ID得数据 if (!marker.markerIdReal.isNullOrBlank()) { - DataBaseManager.get.saveTaskMarkerInLocale(model.id, model.taskCode, marker) + taskMarkerBeanDao.saveTaskMarker(model.id, model.taskCode, marker) } } } "工单下载成功!".show(this) } - private fun showMarkersOnMap() { - lifecycleScope.launch(Dispatchers.IO) { - //取缓存 - val markers = DataBaseManager.get.loadMarkers() - if (markers.isEmpty()) { - return@launch - } - val first = markers.first() - val defaultLatLng = LatLng(first.lat.toDouble(), first.lng.toDouble()) - //移动到指定经纬度 - val cameraPosition = CameraPosition(defaultLatLng, 14f, 0f, 0f) - val cameraUpdate = CameraUpdateFactory.newCameraPosition(cameraPosition) - withContext(Dispatchers.Main) { - aMap.animateCamera(cameraUpdate, 1500, null) - LoadingDialog.dismiss() - } - - markers.forEach { marker -> - val latitude = marker.lat.toString().toDouble() - val longitude = marker.lng.toString().toDouble() - //将所有设备信息转化缓存为Marker点 - val options = MarkerOptions() - .position(LatLng(latitude, longitude)) - .title(marker.markerId) - aMap.addMarker(options) - } - } - } - override fun onMarkerClick(marker: Marker?): Boolean { - marker?.apply { - showNavigationOption(title, position) + marker?.let { + showNavigationOption(it.title, it.position) } return true } - override fun onMapLongClick(p0: LatLng?) { + override fun onMapLongClick(latLng: LatLng?) { showMarkersOnMap() } @@ -664,7 +613,7 @@ } override fun onCancelClick() { - val result = DataBaseManager.get.queryMarkerById(title) + val result = markerBeanDao.queryMarkerById(title) MarkerDetailDialog(context).setMarker(result.first()).show() } }).build().show() @@ -695,20 +644,24 @@ //更新标识器数据 private fun updateMarkers() { - AlertControlDialog.Builder().setContext(this).setTitle("提示").setMessage("是否更新数据?") - .setNegativeButton("取消").setPositiveButton("确定") + AlertControlDialog.Builder() + .setContext(this) + .setTitle("提示") + .setMessage("是否更新数据?") + .setNegativeButton("取消") + .setPositiveButton("确定") .setOnDialogButtonClickListener(object : AlertControlDialog.OnDialogButtonClickListener { override fun onConfirmClick() { if (isNetworkConnected()) { - val companyId = SaveKeyValues.getValue(LocaleConstant.USER_COMPANY_ID, "") - - LoadingDialog.show(this@MainActivity, "获取标识器信息中,请稍后") - /** - * 后台设计如此,都传companyId - * */ + //清空之前的数据 + markerBeanDao.deleteAll() + aMap.clear() + //获取标识器数据 taskViewModel.getMarkerFile( - context, companyId.toString(), companyId.toString() + onLoading = {}, + onSuccess = { handleMarkerFile(it) }, + onFailed = { it.show(context) } ) } else { "网络连接已断开,请检查".show(context) @@ -721,11 +674,105 @@ }).build().show() } + private fun handleMarkerFile(it: MarkerFileModel) { + if (it.isSuccess) { + //下载最新的数据 + val companyId = SaveKeyValues.getValue(LocaleConstant.USER_COMPANY_ID, "") + val downloadUrl = companyId.toString().appendDownloadUrl(FileType.Excel) + Log.d(kTag, "handleMarkerFile => $downloadUrl") + FileDownloadManager.Builder() + .setDownloadFileSource(downloadUrl) + .setFileSuffix("xls") + .setFileSaveDirectory(createDownloadFileDir()) + .setOnFileDownloadListener(object : FileDownloadManager.OnFileDownloadListener { + override fun onDownloadStart(total: Long) { + LoadingDialog.show(context, "标识器数据解析中,请稍后...") + } + + override fun onDownloadEnd(file: File) { + lifecycleScope.launch(Dispatchers.IO) { + ExcelKit.read(file.absolutePath).apply { + renderMarkers(this) + }.also { + withContext(Dispatchers.Main) { + LoadingDialog.dismiss() + "标识器数据渲染完成".show(context) + } + } + } + } + + override fun onDownloadFailed(t: Throwable) { + t.printStackTrace() + LoadingDialog.dismiss() + "标识器数据下载失败".show(context) + } + + override fun onProgressChanged(progress: Long) { + + } + }).build().start() + } + } + + private fun showMarkersOnMap() { + lifecycleScope.launch(Dispatchers.IO) { + //取缓存 + markerBeanDao.loadAll().run { + renderMarkers(this) + }.also { + withContext(Dispatchers.Main) { + "标识器数据渲染完成".show(context) + } + } + } + } + + private fun renderMarkers(markers: List) { + if (markers.isEmpty()) { + return + } + val first = markers.first() + val defaultLatLng = LatLng(first.lat.toDouble(), first.lng.toDouble()) + //移动到指定经纬度 + val cameraPosition = CameraPosition(defaultLatLng, 14f, 0f, 0f) + val cameraUpdate = CameraUpdateFactory.newCameraPosition(cameraPosition) + aMap.animateCamera(cameraUpdate, 1500, null) + markers.forEach { marker -> + val latitude = marker.lat.toString().toDouble() + val longitude = marker.lng.toString().toDouble() + //将所有设备信息转化缓存为Marker点 + val options = MarkerOptions() + .position(LatLng(latitude, longitude)) + .title(marker.markerId) + aMap.addMarker(options) + } + } + //下载工单 private fun downloadTask() { if (isNetworkConnected()) { - val userName = SaveKeyValues.getValue(LocaleConstant.USER_NAME, "") - taskViewModel.getTasksByUser(this, userName.toString()) + taskViewModel.getTasksByUser( + onLoading = {}, + onSuccess = { + if (it.success == "true") { + AlertMessageDialog.Builder() + .setContext(this) + .setTitle("温馨提示") + .setMessage("您有${it.message.size}个新任务!") + .setPositiveButton("知道了") + .setOnDialogButtonClickListener(object : + AlertMessageDialog.OnDialogButtonClickListener { + override fun onConfirmClick() { + saveUserTasks(it) + } + }).build().show() + } + }, + onFailed = { + it.show(this) + } + ) } else { "网络连接已断开,请检查".show(this) } @@ -744,7 +791,7 @@ //标识器补全 private fun completionMarker() { val companyId = SaveKeyValues.getValue(LocaleConstant.USER_COMPANY_ID, "") as String - val markers = DataBaseManager.get.queryMarkerByState("0") + val markers = taskMarkerBeanDao.queryMarkerByState("0") if (markers.isNotEmpty()) { //TODO 逻辑没梳理明白 } else { diff --git a/app/src/main/java/com/casic/common/detector/gd/view/SearchMarkerActivity.kt b/app/src/main/java/com/casic/common/detector/gd/view/SearchMarkerActivity.kt index 4a92c97..b2e3301 100644 --- a/app/src/main/java/com/casic/common/detector/gd/view/SearchMarkerActivity.kt +++ b/app/src/main/java/com/casic/common/detector/gd/view/SearchMarkerActivity.kt @@ -1,6 +1,5 @@ package com.casic.common.detector.gd.view -import android.content.Context import android.content.res.ColorStateList import android.graphics.Color import android.hardware.Sensor @@ -13,18 +12,19 @@ import android.os.Handler import android.os.Looper import android.view.View +import androidx.core.graphics.toColorInt import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.lifecycleScope import com.amap.api.location.AMapLocation import com.amap.api.maps.AMapUtils import com.amap.api.maps.model.LatLng import com.casic.common.detector.gd.R +import com.casic.common.detector.gd.base.BaseApplication import com.casic.common.detector.gd.base.SerialPortBaseActivity import com.casic.common.detector.gd.callback.OnGetLocationListener import com.casic.common.detector.gd.databinding.ActivitySearchMarkerBinding import com.casic.common.detector.gd.model.MarkerDistanceData import com.casic.common.detector.gd.utils.CurrentSegment -import com.casic.common.detector.gd.utils.DataBaseManager import com.casic.common.detector.gd.utils.LocaleConstant import com.casic.common.detector.gd.utils.LocationKit import com.casic.common.detector.gd.utils.RuntimeCache @@ -50,8 +50,10 @@ private val context = this private val locationKit by lazy { LocationKit(this) } private val markerPoints by lazy { ArrayList() } + private val markerBeanDao by lazy { BaseApplication.get().dataBase.markerBeanDao() } + private val taskMarkerBeanDao by lazy { BaseApplication.get().dataBase.taskMarkerBeanDao() } private val taskViewModel by lazy { ViewModelProvider(this)[TaskViewModel::class.java] } - private val sensorManager by lazy { getSystemService(Context.SENSOR_SERVICE) as SensorManager } + private val sensorManager by lazy { getSystemService(SENSOR_SERVICE) as SensorManager } private val attr = AudioAttributes.Builder().setUsage(AudioAttributes.USAGE_ALARM) .setContentType(AudioAttributes.CONTENT_TYPE_MUSIC).build() private val soundPool = SoundPool.Builder().setMaxStreams(16).setAudioAttributes(attr).build() @@ -109,7 +111,7 @@ override fun initEvent() { binding.depthButton.setOnClickListener { RuntimeCache.currentSegment = CurrentSegment.DetectDepth - val result = DataBaseManager.get.queryMarkerById(markerId) + val result = markerBeanDao.queryMarkerById(markerId) if (result.isNotEmpty()) { val command = when (result.first().markerType) { "EM30" -> SerialPortCommand.DETECT_EM30_DEPTH @@ -139,7 +141,7 @@ } binding.markerInfoButton.setOnClickListener { - val result = DataBaseManager.get.queryMarkerById(markerId) + val result = markerBeanDao.queryMarkerById(markerId) if (result.isNotEmpty()) { MarkerDetailDialog(this).setMarker(result.first()).show() } else { @@ -154,12 +156,12 @@ binding.depthButton.isEnabled = true binding.depthButton.setTextColor(Color.WHITE) binding.depthButton.backgroundTintList = - ColorStateList.valueOf(Color.parseColor("#004364")) + ColorStateList.valueOf("#004364".toColorInt()) binding.markerInfoButton.isEnabled = true binding.markerInfoButton.setTextColor(Color.WHITE) binding.markerInfoButton.backgroundTintList = - ColorStateList.valueOf(Color.parseColor("#FFA200")) + ColorStateList.valueOf("#FFA200".toColorInt()) handleMarker(markerId) } @@ -171,12 +173,22 @@ if (isExecuteTask) { val taskId = SaveKeyValues.getValue(LocaleConstant.TASK_ID, "") as String val taskCode = SaveKeyValues.getValue(LocaleConstant.TASK_CODE, "") as String - val taskMarkerLocalBean = DataBaseManager.get.queryTaskMarkerById( + val marker = taskMarkerBeanDao.queryTaskMarkerById( taskId, taskCode, id, "0" ) - taskMarkerLocalBean?.apply { - taskViewModel.uploadMarker(context, this) + if (marker == null) { + return } + taskViewModel.uploadMarker( + marker.markerId, + onLoading = {}, + onSuccess = { + "标识器${marker.markerId}已探测!".show(this) + marker.isDetected = "1" + taskMarkerBeanDao.updateLocalTaskMarkerState(marker) + }, + onFailed = {} + ) } } @@ -185,15 +197,22 @@ detectDepthRunnable?.let { handler.removeCallbacks(it) } detectDepthRunnable = null LoadingDialog.dismiss() - AlertMessageDialog.Builder().setContext(context).setTitle("温馨提示") - .setMessage("标识器埋深:${depth}厘米").setPositiveButton("知道了") - .setOnDialogButtonClickListener(object : - AlertMessageDialog.OnDialogButtonClickListener { - override fun onConfirmClick() { - RuntimeCache.currentSegment = CurrentSegment.SearchMarker - sendSerialPortCommand(SerialPortCommand.SEARCH_SIGNAL) - } - }).build().show() + if (!this.isDestroyed) { + AlertMessageDialog.Builder() + .setContext(context) + .setTitle("温馨提示") + .setMessage("标识器埋深:${depth}厘米") + .setPositiveButton("知道了") + .setOnDialogButtonClickListener(object : + AlertMessageDialog.OnDialogButtonClickListener { + override fun onConfirmClick() { + RuntimeCache.currentSegment = CurrentSegment.SearchMarker + sendSerialPortCommand(SerialPortCommand.SEARCH_SIGNAL) + } + }).build().show() + } else { + "标识器埋深:${depth}厘米".show(this) + } } } @@ -201,13 +220,13 @@ if (RuntimeCache.currentSegment == CurrentSegment.SearchMarker) { if (signalEnergy > 1000) { binding.markerIdButton.isEnabled = true - binding.markerIdButton.setTextColor(Color.parseColor("#428d00")) + binding.markerIdButton.setTextColor("#428d00".toColorInt()) binding.markerIdButton.backgroundTintList = ColorStateList.valueOf( - Color.parseColor("#7EFF00") + "#7EFF00".toColorInt() ) binding.searchResultView.text = "已检测到标识器" - binding.searchResultView.setTextColor(Color.parseColor("#428d00")) + binding.searchResultView.setTextColor("#428d00".toColorInt()) binding.searchResultView.setBackgroundResource(R.mipmap.bg_small_text_green) } @@ -230,19 +249,19 @@ signalEnergy <= 700 -> { setEnergyTip( "信号较弱,可能距离较远", - Color.parseColor("#8D1717"), + "#8D1717".toColorInt(), R.mipmap.bg_large_text_red ) disableButtons() binding.searchResultView.text = "未检测到标识器" - binding.searchResultView.setTextColor(Color.parseColor("#8D1717")) + binding.searchResultView.setTextColor("#8D1717".toColorInt()) binding.searchResultView.setBackgroundResource(R.mipmap.bg_small_text_red) } signalEnergy >= 4100 -> { setEnergyTip( "信号极强,接近标识器正上方", - Color.parseColor("#428d00"), + "#428d00".toColorInt(), R.mipmap.bg_large_text_green ) } @@ -250,7 +269,7 @@ else -> { setEnergyTip( "已靠近,请继续移动位置", - Color.parseColor("#8C5700"), + "#8C5700".toColorInt(), R.mipmap.bg_large_text_yellow ) } @@ -263,8 +282,8 @@ binding.energyTipsView.setBackgroundResource(backgroundRes) } - private val colorStateList = ColorStateList.valueOf(Color.parseColor("#8A8A8A")) - private val textColor = Color.parseColor("#CCCCCC") + private val colorStateList = ColorStateList.valueOf("#8A8A8A".toColorInt()) + private val textColor = "#CCCCCC".toColorInt() private fun disableButtons() { binding.depthButton.isEnabled = false @@ -287,7 +306,7 @@ val latitude = location.latitude lifecycleScope.launch(Dispatchers.IO) { val dataPoints = ArrayList() - DataBaseManager.get.loadMarkers().forEach { + markerBeanDao.loadAll().forEach { val distance = AMapUtils.calculateLineDistance( LatLng(it.lat.toDouble(), it.lng.toDouble()), LatLng(latitude, longitude) ) @@ -332,10 +351,6 @@ return ActivitySearchMarkerBinding.inflate(layoutInflater) } - override fun observeRequestState() { - - } - override fun setupTopBarLayout() { } diff --git a/app/src/main/java/com/casic/common/detector/gd/view/SearchMarkerAuditActivity.kt b/app/src/main/java/com/casic/common/detector/gd/view/SearchMarkerAuditActivity.kt index 1dc59a7..dd4cc84 100644 --- a/app/src/main/java/com/casic/common/detector/gd/view/SearchMarkerAuditActivity.kt +++ b/app/src/main/java/com/casic/common/detector/gd/view/SearchMarkerAuditActivity.kt @@ -1,6 +1,5 @@ package com.casic.common.detector.gd.view -import android.content.Context import android.hardware.Sensor import android.hardware.SensorEvent import android.hardware.SensorEventListener @@ -13,9 +12,9 @@ import com.amap.api.maps.AMapUtils import com.amap.api.maps.model.LatLng import com.casic.common.detector.gd.R +import com.casic.common.detector.gd.base.BaseApplication import com.casic.common.detector.gd.callback.OnGetLocationListener import com.casic.common.detector.gd.databinding.ActivitySearchMarkerAuditBinding -import com.casic.common.detector.gd.utils.DataBaseManager import com.casic.common.detector.gd.utils.LocaleConstant import com.casic.common.detector.gd.utils.LocationKit import com.casic.common.detector.gd.widgets.MarkerDetailDialog @@ -36,7 +35,8 @@ private val kTag = "SearchMarkerActivity" private val context = this private val locationKit by lazy { LocationKit(this) } - private val sensorManager by lazy { getSystemService(Context.SENSOR_SERVICE) as SensorManager } + private val sensorManager by lazy { getSystemService(SENSOR_SERVICE) as SensorManager } + private val markerBeanDao by lazy { BaseApplication.get().dataBase.markerBeanDao() } private val attr = AudioAttributes.Builder().setUsage(AudioAttributes.USAGE_ALARM) .setContentType(AudioAttributes.CONTENT_TYPE_MUSIC).build() private val soundPool = SoundPool.Builder().setMaxStreams(16).setAudioAttributes(attr).build() @@ -72,7 +72,7 @@ override fun initEvent() { binding.markerInfoButton.setOnClickListener { //查库 - val result = DataBaseManager.get.queryMarkerById(nearestMarkerId) + val result = markerBeanDao.queryMarkerById(nearestMarkerId) if (result.isNotEmpty()) { MarkerDetailDialog(this).setMarker(result.first()).show() } else { @@ -90,7 +90,7 @@ val latitude = location.latitude lifecycleScope.launch(Dispatchers.IO) { val dataPoints = ArrayList() - DataBaseManager.get.loadMarkers().forEach { + markerBeanDao.loadAll().forEach { val distance = AMapUtils.calculateLineDistance( LatLng(it.lat.toDouble(), it.lng.toDouble()), LatLng(latitude, longitude) ) @@ -105,7 +105,8 @@ ) } withContext(Dispatchers.Main) { - binding.radarScanView.renderPointData(dataPoints, + binding.radarScanView.renderPointData( + dataPoints, object : RadarScanView.OnGetNearestPointCallback { override fun getNearestPoint(point: RadarScanView.DataPoint?) { if (point == null) { diff --git a/app/build.gradle b/app/build.gradle index d0cb423..921c8c8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,25 +1,20 @@ import java.text.SimpleDateFormat -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply plugin: 'org.greenrobot.greendao' +plugins { + id('com.android.application') + id('org.jetbrains.kotlin.android') +} android { - compileSdkVersion 33 + namespace 'com.casic.common.detector.gd' + compileSdk 35 defaultConfig { - applicationId "com.casic.common.detector.gd" - minSdkVersion 26 - targetSdkVersion 33 + applicationId 'com.casic.common.detector.gd' + minSdk 26 + targetSdk 35 versionCode 5092 - versionName "5.0.9.2" - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } + versionName '5.0.9.2' } signingConfigs { @@ -31,6 +26,14 @@ } } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + signingConfig signingConfigs.release + } + } + compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 @@ -47,27 +50,16 @@ } } - kotlin { - experimental { - coroutines 'enable' - } - } - buildFeatures { + buildConfig true viewBinding true } - applicationVariants.configureEach { variant -> - variant.outputs.configureEach { - outputFileName = "COM_TCY_" + getBuildDate() + "_" + defaultConfig.versionName + ".apk" + applicationVariants.configureEach { + outputs.configureEach { + outputFileName = 'COM_TCY_' + getBuildDate() + '_' + defaultConfig.versionName + '.apk' } } - - greendao { - schemaVersion 1//数据库版本号 - targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 - daoPackage "${defaultConfig.applicationId}.greendao"//设置DaoMaster、DaoSession、Dao包名 - } } static def getBuildDate() { @@ -76,27 +68,22 @@ } dependencies { - //基础依赖库 - implementation 'com.github.AndroidCoderPeng:Kotlin-lite-lib:1.1.4' - implementation 'androidx.core:core-ktx:1.9.0' - def base_version = "1.6.1" - implementation "androidx.appcompat:appcompat:${base_version}" - implementation "com.google.android.material:material:${base_version}" + implementation 'com.github.AndroidCoderPeng:Kotlin-lite-lib:1.1.5' + implementation 'androidx.core:core-ktx:1.13.1' + implementation 'androidx.appcompat:appcompat:1.7.0' + implementation 'com.google.android.material:material:1.12.0' //Google官方授权框架 implementation 'pub.devrel:easypermissions:3.0.0' - //沉浸式状态栏。基础依赖包,必须要依赖 - implementation 'com.gyf.immersionbar:immersionbar:3.0.0' - //fragment快速实现 - implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0' + //沉浸式状态栏 + implementation 'com.geyifeng.immersionbar:immersionbar:3.2.2' //官方Json解析库 implementation 'com.google.code.gson:gson:2.10.1' - def vm_version = '2.5.1' //Kotlin协程 - implementation "androidx.lifecycle:lifecycle-runtime-ktx:${vm_version}" + implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.2' //MVVM+LiveData - implementation "androidx.lifecycle:lifecycle-livedata-ktx:${vm_version}" - implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:${vm_version}" - implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.6.2' + implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2' + implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' //返回值转换器 implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' @@ -105,9 +92,10 @@ implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' //网络请求和接口封装 implementation 'com.squareup.retrofit2:retrofit:2.9.0' - implementation 'com.squareup.okhttp3:okhttp:4.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.12.0' //数据库框架 - implementation 'org.greenrobot:greendao:3.3.0' + implementation 'androidx.room:room-runtime:2.6.1' + annotationProcessor 'androidx.room:room-compiler:2.5.2' //高德导航、定位、地图三合一 implementation 'com.amap.api:navi-3dmap:latest.integration' //经纬度逆编码 @@ -115,7 +103,7 @@ //excel implementation 'net.sourceforge.jexcelapi:jxl:2.6.12' //图片加载框架 - implementation 'com.github.bumptech.glide:glide:4.9.0' + implementation 'com.github.bumptech.glide:glide:4.12.0' //图片选择框架 implementation 'io.github.lucksiege:pictureselector:v3.11.1' //大图 diff --git a/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt b/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt index 7b695ff..50ba734 100644 --- a/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt +++ b/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt @@ -4,9 +4,9 @@ import android.app.Application import android.os.Bundle import android.util.Log -import com.casic.common.detector.gd.greendao.DaoMaster -import com.casic.common.detector.gd.greendao.DaoSession +import androidx.room.Room.databaseBuilder import com.casic.common.detector.gd.uart.SerialPort +import com.casic.common.detector.gd.utils.DetectorDataBase import com.casic.common.detector.gd.utils.GpioManager import com.pengxh.kt.lite.extensions.show import com.pengxh.kt.lite.utils.SaveKeyValues @@ -43,44 +43,42 @@ private var application: BaseApplication by Delegates.notNull() fun get() = application - - private lateinit var daoSession: DaoSession } + lateinit var dataBase: DetectorDataBase + override fun onCreate() { super.onCreate() application = this SaveKeyValues.initSharedPreferences(this) CrashReport.initCrashReport(this, "01e80d3a74", true) - val devOpenHelper = DaoMaster.DevOpenHelper(this, "Detector.db", null) - val daoMaster = DaoMaster(devOpenHelper.writableDatabase) - daoSession = daoMaster.newSession() + dataBase = databaseBuilder(this, DetectorDataBase::class.java, "Detector.db") + .allowMainThreadQueries() + .build() /** * Open the serial port * */ try { serialPorts.apply { - add(SerialPort(File("/dev/ttysWK1"), 9600, 0)) - //千寻报文数据下发串口号 - add(SerialPort(File("/dev/ttyS1"), 9600, 0)) + add(SerialPort(File("/dev/ttysWK1"), 9600, 0)) //信号通讯串口 + add(SerialPort(File("/dev/ttyS1"), 9600, 0)) //千寻报文数据下发串口号 } Log.d(kTag, "onCreate: 已初始化 ${serialPorts.size} 个串口") } catch (e: SecurityException) { "您没有串口的读写权限!".show(this) + e.printStackTrace() } catch (e: IOException) { "因为不明原因,串口无法打开!".show(this) + e.printStackTrace() } catch (e: InvalidParameterException) { "请检查串口!".show(this) + e.printStackTrace() } registerActivityLifecycleCallbacks(this) } - fun getDaoSession(): DaoSession { - return daoSession - } - override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) { } diff --git a/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt b/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt index 053b9dd..1d0c9e3 100644 --- a/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt +++ b/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt @@ -14,12 +14,10 @@ import com.casic.common.detector.gd.utils.SerialPortCommand import com.pengxh.kt.lite.utils.WeakReferenceHandler import java.io.IOException -import java.util.Timer abstract class SerialPortBaseActivity : AppCompatActivity(), Handler.Callback { private val kTag = "SerialPortBaseActivity" - private val taskTimer by lazy { Timer() } private val weakReferenceHandler by lazy { WeakReferenceHandler(this) } private val serialPorts by lazy { BaseApplication.get().getSerialPorts() } protected lateinit var binding: VB @@ -30,7 +28,6 @@ setContentView(binding.root) setupTopBarLayout() initOnCreate(savedInstanceState) - observeRequestState() initEvent() if (serialPorts.isNotEmpty()) { @@ -71,11 +68,6 @@ abstract fun initOnCreate(savedInstanceState: Bundle?) /** - * 数据请求状态监听 - */ - abstract fun observeRequestState() - - /** * 初始化业务逻辑 */ abstract fun initEvent() diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java new file mode 100644 index 0000000..7a18c20 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java @@ -0,0 +1,255 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 从平台下载的标识器本地库实体类 + */ +@Entity(tableName = "marker_detail") +public class MarkerBean { + @PrimaryKey(autoGenerate = true) + private long id; //主键ID + private String pipelineType; // 管线类型 + private String pipelineDiameter; // 管线直径 + private String pipelineMaterial; // 管材 + private String buryMethod; // 埋设方式 + private String buryDepth; // 埋深 + private String area; // 所属区域 + private String line; // 所属线路 + private String road; // 所属道路 + private String constructTime; // 建设年代 + private String owner; // 权属单位 + private String objectId; // 标识对象ID,无实际用途 + private String markerId; // 标识器ID + private String markerType; // 标识器类型 + private String markerDepth; // 标识器埋深 + private String installationDept; // 安装部门 + private String lng; // 经度 + private String lat; // 纬度 + private String updateTime; // 最后修改时间,更新时间 + private String remark; // 备注信息 + private String underlyingPipelineType; // 下层管线类型 + private String underlyingPipelineDepth; // 下层埋深 + private String underlyingPipelineDiameter; // 下层管径 + private String underlyingPipelineMaterial; // 下层管材 + private String objectType; //标识对象类型 + private String color; // 颜色 + private String imagePath; // 图片路径 + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getPipelineType() { + return pipelineType; + } + + public void setPipelineType(String pipelineType) { + this.pipelineType = pipelineType; + } + + public String getPipelineDiameter() { + return pipelineDiameter; + } + + public void setPipelineDiameter(String pipelineDiameter) { + this.pipelineDiameter = pipelineDiameter; + } + + public String getPipelineMaterial() { + return pipelineMaterial; + } + + public void setPipelineMaterial(String pipelineMaterial) { + this.pipelineMaterial = pipelineMaterial; + } + + public String getBuryMethod() { + return buryMethod; + } + + public void setBuryMethod(String buryMethod) { + this.buryMethod = buryMethod; + } + + public String getBuryDepth() { + return buryDepth; + } + + public void setBuryDepth(String buryDepth) { + this.buryDepth = buryDepth; + } + + public String getArea() { + return area; + } + + public void setArea(String area) { + this.area = area; + } + + public String getLine() { + return line; + } + + public void setLine(String line) { + this.line = line; + } + + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + + public String getConstructTime() { + return constructTime; + } + + public void setConstructTime(String constructTime) { + this.constructTime = constructTime; + } + + public String getOwner() { + return owner; + } + + public void setOwner(String owner) { + this.owner = owner; + } + + public String getObjectId() { + return objectId; + } + + public void setObjectId(String objectId) { + this.objectId = objectId; + } + + public String getMarkerId() { + return markerId; + } + + public void setMarkerId(String markerId) { + this.markerId = markerId; + } + + public String getMarkerType() { + return markerType; + } + + public void setMarkerType(String markerType) { + this.markerType = markerType; + } + + public String getMarkerDepth() { + return markerDepth; + } + + public void setMarkerDepth(String markerDepth) { + this.markerDepth = markerDepth; + } + + public String getInstallationDept() { + return installationDept; + } + + public void setInstallationDept(String installationDept) { + this.installationDept = installationDept; + } + + public String getLng() { + return lng; + } + + public void setLng(String lng) { + this.lng = lng; + } + + public String getLat() { + return lat; + } + + public void setLat(String lat) { + this.lat = lat; + } + + public String getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } + + public String getUnderlyingPipelineType() { + return underlyingPipelineType; + } + + public void setUnderlyingPipelineType(String underlyingPipelineType) { + this.underlyingPipelineType = underlyingPipelineType; + } + + public String getUnderlyingPipelineDepth() { + return underlyingPipelineDepth; + } + + public void setUnderlyingPipelineDepth(String underlyingPipelineDepth) { + this.underlyingPipelineDepth = underlyingPipelineDepth; + } + + public String getUnderlyingPipelineDiameter() { + return underlyingPipelineDiameter; + } + + public void setUnderlyingPipelineDiameter(String underlyingPipelineDiameter) { + this.underlyingPipelineDiameter = underlyingPipelineDiameter; + } + + public String getUnderlyingPipelineMaterial() { + return underlyingPipelineMaterial; + } + + public void setUnderlyingPipelineMaterial(String underlyingPipelineMaterial) { + this.underlyingPipelineMaterial = underlyingPipelineMaterial; + } + + public String getObjectType() { + return objectType; + } + + public void setObjectType(String objectType) { + this.objectType = objectType; + } + + public String getColor() { + return color; + } + + public void setColor(String color) { + this.color = color; + } + + public String getImagePath() { + return imagePath; + } + + public void setImagePath(String imagePath) { + this.imagePath = imagePath; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java deleted file mode 100644 index 3f2fcdc..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java +++ /dev/null @@ -1,327 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 从平台下载的标识器本地库实体类 - */ -@Entity -public class MarkerLocalBean { - @Id(autoincrement = true) - private Long id;//本地库主键ID - - // 管线类型 - private String pipelineType; - // 管线直径 - private String pipelineDiameter; - // 管材 - private String pipelineMaterial; - // 埋设方式 - private String buryMethod; - // 埋深 - private String buryDepth; - // 所属区域 - private String area; - // 所属线路 - private String line; - // 所属道路 - private String road; - // 建设年代 - private String constructTime; - // 权属单位 - private String owner; - //标识对象ID,无实际用途 - @Deprecated - private String objectId; - // 标识器ID - private String markerId; - // 标识器类型 - private String markerType; - // 标识器埋深 - private String markerDepth; - // 安装部门 - private String installationDept; - // 经度 - private String lng; - // 纬度 - private String lat; - //最后修改时间,更新时间 - private String updateTime; - // 备注信息 - private String remark; - // 下层管线类型 - private String underlyingPipelineType; - // 下层埋深 - private String underlyingPipelineDepth; - // 下层管径 - private String underlyingPipelineDiameter; - // 下层管材 - private String underlyingPipelineMaterial; - //标识对象类型 - private String objectType; - // 颜色 - private String color; - // 图片路径 - private String imagePath; - - @Generated(hash = 1479045776) - public MarkerLocalBean(Long id, String pipelineType, String pipelineDiameter, - String pipelineMaterial, String buryMethod, String buryDepth, - String area, String line, String road, String constructTime, - String owner, String objectId, String markerId, String markerType, - String markerDepth, String installationDept, String lng, String lat, - String updateTime, String remark, String underlyingPipelineType, - String underlyingPipelineDepth, String underlyingPipelineDiameter, - String underlyingPipelineMaterial, String objectType, String color, - String imagePath) { - this.id = id; - this.pipelineType = pipelineType; - this.pipelineDiameter = pipelineDiameter; - this.pipelineMaterial = pipelineMaterial; - this.buryMethod = buryMethod; - this.buryDepth = buryDepth; - this.area = area; - this.line = line; - this.road = road; - this.constructTime = constructTime; - this.owner = owner; - this.objectId = objectId; - this.markerId = markerId; - this.markerType = markerType; - this.markerDepth = markerDepth; - this.installationDept = installationDept; - this.lng = lng; - this.lat = lat; - this.updateTime = updateTime; - this.remark = remark; - this.underlyingPipelineType = underlyingPipelineType; - this.underlyingPipelineDepth = underlyingPipelineDepth; - this.underlyingPipelineDiameter = underlyingPipelineDiameter; - this.underlyingPipelineMaterial = underlyingPipelineMaterial; - this.objectType = objectType; - this.color = color; - this.imagePath = imagePath; - } - - @Generated(hash = 1538606012) - public MarkerLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getPipelineType() { - return this.pipelineType; - } - - public void setPipelineType(String pipelineType) { - this.pipelineType = pipelineType; - } - - public String getPipelineDiameter() { - return this.pipelineDiameter; - } - - public void setPipelineDiameter(String pipelineDiameter) { - this.pipelineDiameter = pipelineDiameter; - } - - public String getPipelineMaterial() { - return this.pipelineMaterial; - } - - public void setPipelineMaterial(String pipelineMaterial) { - this.pipelineMaterial = pipelineMaterial; - } - - public String getBuryMethod() { - return this.buryMethod; - } - - public void setBuryMethod(String buryMethod) { - this.buryMethod = buryMethod; - } - - public String getBuryDepth() { - return this.buryDepth; - } - - public void setBuryDepth(String buryDepth) { - this.buryDepth = buryDepth; - } - - public String getArea() { - return this.area; - } - - public void setArea(String area) { - this.area = area; - } - - public String getLine() { - return this.line; - } - - public void setLine(String line) { - this.line = line; - } - - public String getRoad() { - return this.road; - } - - public void setRoad(String road) { - this.road = road; - } - - public String getConstructTime() { - return this.constructTime; - } - - public void setConstructTime(String constructTime) { - this.constructTime = constructTime; - } - - public String getOwner() { - return this.owner; - } - - public void setOwner(String owner) { - this.owner = owner; - } - - public String getObjectId() { - return this.objectId; - } - - public void setObjectId(String objectId) { - this.objectId = objectId; - } - - public String getMarkerId() { - return this.markerId; - } - - public void setMarkerId(String markerId) { - this.markerId = markerId; - } - - public String getMarkerType() { - return this.markerType; - } - - public void setMarkerType(String markerType) { - this.markerType = markerType; - } - - public String getMarkerDepth() { - return this.markerDepth; - } - - public void setMarkerDepth(String markerDepth) { - this.markerDepth = markerDepth; - } - - public String getInstallationDept() { - return this.installationDept; - } - - public void setInstallationDept(String installationDept) { - this.installationDept = installationDept; - } - - public String getLng() { - return this.lng; - } - - public void setLng(String lng) { - this.lng = lng; - } - - public String getLat() { - return this.lat; - } - - public void setLat(String lat) { - this.lat = lat; - } - - public String getUpdateTime() { - return this.updateTime; - } - - public void setUpdateTime(String updateTime) { - this.updateTime = updateTime; - } - - public String getRemark() { - return this.remark; - } - - public void setRemark(String remark) { - this.remark = remark; - } - - public String getUnderlyingPipelineType() { - return this.underlyingPipelineType; - } - - public void setUnderlyingPipelineType(String underlyingPipelineType) { - this.underlyingPipelineType = underlyingPipelineType; - } - - public String getUnderlyingPipelineDepth() { - return this.underlyingPipelineDepth; - } - - public void setUnderlyingPipelineDepth(String underlyingPipelineDepth) { - this.underlyingPipelineDepth = underlyingPipelineDepth; - } - - public String getUnderlyingPipelineDiameter() { - return this.underlyingPipelineDiameter; - } - - public void setUnderlyingPipelineDiameter(String underlyingPipelineDiameter) { - this.underlyingPipelineDiameter = underlyingPipelineDiameter; - } - - public String getUnderlyingPipelineMaterial() { - return this.underlyingPipelineMaterial; - } - - public void setUnderlyingPipelineMaterial(String underlyingPipelineMaterial) { - this.underlyingPipelineMaterial = underlyingPipelineMaterial; - } - - public String getObjectType() { - return this.objectType; - } - - public void setObjectType(String objectType) { - this.objectType = objectType; - } - - public String getColor() { - return this.color; - } - - public void setColor(String color) { - this.color = color; - } - - public String getImagePath() { - return this.imagePath; - } - - public void setImagePath(String imagePath) { - this.imagePath = imagePath; - } -} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java new file mode 100644 index 0000000..5c88fdf --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java @@ -0,0 +1,93 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 巡检任务本地库实体类,不包含任务里面需要巡检的标识器信息 + */ +@Entity(tableName = "task_detail") +public class TaskBean { + @PrimaryKey(autoGenerate = true) + private long id;//主键ID + private String taskCode; // 任务编号 + private String description; // 任务名称 + private String createTime; // 任务创建的时间 + private String status; // 任务状态 + private String createUserName; // 任务创建者名称 + private String startTime; // 任务被开始执行的时间 + private String endTime; // 任务执行结束的时间 + private String isFree; // 是否自由巡检。1-是,0-否 + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getTaskCode() { + return taskCode; + } + + public void setTaskCode(String taskCode) { + this.taskCode = taskCode; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getCreateUserName() { + return createUserName; + } + + public void setCreateUserName(String createUserName) { + this.createUserName = createUserName; + } + + public String getStartTime() { + return startTime; + } + + public void setStartTime(String startTime) { + this.startTime = startTime; + } + + public String getEndTime() { + return endTime; + } + + public void setEndTime(String endTime) { + this.endTime = endTime; + } + + public String getIsFree() { + return isFree; + } + + public void setIsFree(String isFree) { + this.isFree = isFree; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java deleted file mode 100644 index 91737b3..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java +++ /dev/null @@ -1,114 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 巡检任务本地库实体类,不包含任务里面需要巡检的标识器信息 - */ -@Entity -public class TaskLocalBean { - @Id - private Long id;//任务ID - - private String taskCode;//任务编号 - private String description;//任务名称 - private String createTime;//任务创建的时间 - private String status;//任务状态 - private String createUserName;//任务创建者名称 - private String startTime;//任务被开始执行的时间 - private String endTime;//任务执行结束的时间 - private String isFreeTask;//是否自由巡检。1-是,0-否 - - @Generated(hash = 1482022528) - public TaskLocalBean(Long id, String taskCode, String description, - String createTime, String status, String createUserName, - String startTime, String endTime, String isFreeTask) { - this.id = id; - this.taskCode = taskCode; - this.description = description; - this.createTime = createTime; - this.status = status; - this.createUserName = createUserName; - this.startTime = startTime; - this.endTime = endTime; - this.isFreeTask = isFreeTask; - } - - @Generated(hash = 949704588) - public TaskLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getTaskCode() { - return this.taskCode; - } - - public void setTaskCode(String taskCode) { - this.taskCode = taskCode; - } - - public String getDescription() { - return this.description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getCreateTime() { - return this.createTime; - } - - public void setCreateTime(String createTime) { - this.createTime = createTime; - } - - public String getStatus() { - return this.status; - } - - public void setStatus(String status) { - this.status = status; - } - - public String getCreateUserName() { - return this.createUserName; - } - - public void setCreateUserName(String createUserName) { - this.createUserName = createUserName; - } - - public String getStartTime() { - return this.startTime; - } - - public void setStartTime(String startTime) { - this.startTime = startTime; - } - - public String getEndTime() { - return this.endTime; - } - - public void setEndTime(String endTime) { - this.endTime = endTime; - } - - public String getIsFreeTask() { - return this.isFreeTask; - } - - public void setIsFreeTask(String isFreeTask) { - this.isFreeTask = isFreeTask; - } -} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerBean.java new file mode 100644 index 0000000..c563a60 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerBean.java @@ -0,0 +1,110 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 巡检任务里面需要巡检的标识器信息本地库实体类 + */ +@Entity(tableName = "task_marker_info") +public class TaskMarkerBean { + //标识器后台库的主键ID,不是标识器实际ID + @PrimaryKey(autoGenerate = true) + private long id; + + /** + * 任务ID,通过此字段关联[TaskBean.id] + */ + private String taskId; + + /** + * 任务Code,通过此字段关联[TaskBean.taskCode] + *

+ *

+ * 双重验证,防止出现同时刻重复的情况 + */ + private String taskCode; + + /** + * 对应后台字段[TaskModel.MessageModel.TaskDetailInfosModel.markerIdReal],也就是探测仪扫描出来的ID + */ + private String markerId; + + private Double lng; + private Double lat; + + /** + * 是否已被探测到 + * 1-是,0-否 + */ + private String isDetected; + + /** + * 被探测到的时间,对应后台字段[TaskModel.MessageModel.TaskDetailInfosModel.finishTime] + */ + private String detectedTime; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getTaskId() { + return taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getTaskCode() { + return taskCode; + } + + public void setTaskCode(String taskCode) { + this.taskCode = taskCode; + } + + public String getMarkerId() { + return markerId; + } + + public void setMarkerId(String markerId) { + this.markerId = markerId; + } + + public Double getLng() { + return lng; + } + + public void setLng(Double lng) { + this.lng = lng; + } + + public Double getLat() { + return lat; + } + + public void setLat(Double lat) { + this.lat = lat; + } + + public String getIsDetected() { + return isDetected; + } + + public void setIsDetected(String isDetected) { + this.isDetected = isDetected; + } + + public String getDetectedTime() { + return detectedTime; + } + + public void setDetectedTime(String detectedTime) { + this.detectedTime = detectedTime; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerLocalBean.java deleted file mode 100644 index de9f459..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerLocalBean.java +++ /dev/null @@ -1,128 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import com.casic.common.detector.gd.model.TaskModel; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 巡检任务里面需要巡检的标识器信息本地库实体类 - */ -@Entity -public class TaskMarkerLocalBean { - @Id - private Long id;//标识器后台库的主键ID,不是标识器实际ID - - /** - * 任务ID,通过此字段关联{@link TaskLocalBean#id} - */ - private String taskId; - - /** - * 任务Code,通过此字段关联{@link TaskLocalBean#taskCode} - *

- * 双重验证,防止出现同时刻重复的情况 - */ - private String taskCode; - - /** - * 对应后台字段{@link TaskModel.MessageModel.TaskDetailInfosModel#markerIdReal},也就是探测仪扫描出来的ID - */ - private String markerId; - - private double lng; - private double lat; - - /** - * 是否已被探测到 - * 1-是,0-否 - */ - private String isDetected; - - /** - * 被探测到的时间,对应后台字段{@link TaskModel.MessageModel.TaskDetailInfosModel#finishTime} - */ - private String detectedTime; - - @Generated(hash = 677328533) - public TaskMarkerLocalBean(Long id, String taskId, String taskCode, String markerId, - double lng, double lat, String isDetected, String detectedTime) { - this.id = id; - this.taskId = taskId; - this.taskCode = taskCode; - this.markerId = markerId; - this.lng = lng; - this.lat = lat; - this.isDetected = isDetected; - this.detectedTime = detectedTime; - } - - @Generated(hash = 1162404642) - public TaskMarkerLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getTaskId() { - return this.taskId; - } - - public void setTaskId(String taskId) { - this.taskId = taskId; - } - - public String getTaskCode() { - return this.taskCode; - } - - public void setTaskCode(String taskCode) { - this.taskCode = taskCode; - } - - public String getMarkerId() { - return this.markerId; - } - - public void setMarkerId(String markerId) { - this.markerId = markerId; - } - - public double getLng() { - return this.lng; - } - - public void setLng(double lng) { - this.lng = lng; - } - - public double getLat() { - return this.lat; - } - - public void setLat(double lat) { - this.lat = lat; - } - - public String getIsDetected() { - return this.isDetected; - } - - public void setIsDetected(String isDetected) { - this.isDetected = isDetected; - } - - public String getDetectedTime() { - return this.detectedTime; - } - - public void setDetectedTime(String detectedTime) { - this.detectedTime = detectedTime; - } -} diff --git a/app/src/main/java/com/casic/common/detector/gd/dao/MarkerBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/dao/MarkerBeanDao.java new file mode 100644 index 0000000..2beb7ed --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/dao/MarkerBeanDao.java @@ -0,0 +1,29 @@ +package com.casic.common.detector.gd.dao; + +import androidx.room.Dao; +import androidx.room.Insert; +import androidx.room.Query; +import androidx.room.RawQuery; +import androidx.sqlite.db.SupportSQLiteQuery; + +import com.casic.common.detector.gd.bean.MarkerBean; + +import java.util.List; + +@Dao +public interface MarkerBeanDao { + @Query("DELETE FROM marker_detail") + void deleteAll(); + + @Insert + void insert(MarkerBean marker); + + @Query("SELECT * FROM marker_detail") + List loadAll(); + + @Query("SELECT * FROM marker_detail WHERE markerId = :markerId") + List queryMarkerById(String markerId); + + @RawQuery + List loadMarkersByCondition(SupportSQLiteQuery query); +} diff --git a/app/src/main/java/com/casic/common/detector/gd/dao/TaskBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/dao/TaskBeanDao.java new file mode 100644 index 0000000..9c70ac2 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/dao/TaskBeanDao.java @@ -0,0 +1,120 @@ +package com.casic.common.detector.gd.dao; + +import androidx.room.Dao; +import androidx.room.Insert; +import androidx.room.Query; +import androidx.room.Transaction; + +import com.casic.common.detector.gd.bean.TaskBean; +import com.casic.common.detector.gd.bean.TaskMarkerBean; +import com.casic.common.detector.gd.model.TaskDetailLocalModel; +import com.casic.common.detector.gd.model.TaskModel; +import com.casic.common.detector.gd.utils.LocaleConstant; +import com.pengxh.kt.lite.utils.SaveKeyValues; + +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Locale; + +@Dao +public interface TaskBeanDao { + @Query("SELECT COUNT(*) FROM task_detail WHERE id = :taskId") + int isTaskExist(long taskId); + + @Insert + void insert(TaskBean task); + + default void saveTask(Long taskId, String taskName) { + if (isTaskExist(taskId) == 0) { + TaskBean task = new TaskBean(); + task.setId(taskId); + task.setTaskCode(new SimpleDateFormat("yyyyMMddHHmmss", Locale.CHINA).format(new Date())); + task.setDescription(taskName); + String time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA).format(new Date()); + task.setCreateTime(time); + task.setStatus("0"); + String userName = (String) SaveKeyValues.INSTANCE.getValue(LocaleConstant.USER_NAME, ""); + task.setCreateUserName(userName); + task.setStartTime(time); + task.setEndTime(""); + task.setIsFree("1"); + insert(task); + } + } + + default void saveTask(TaskModel.MessageModel model) { + TaskBean task = new TaskBean(); + task.setId(model.getId()); + task.setTaskCode(model.getTaskCode()); + task.setDescription(model.getDescription()); + task.setCreateTime(model.getDeployDate()); + task.setStatus(model.getStatus()); + task.setCreateUserName(model.getCreatorName()); + task.setStartTime(model.getBeginDate()); + task.setEndTime(model.getEndDate()); + task.setIsFree("0"); + if (isTaskExist(task.getId()) == 0) { + insert(task); + } + } + + @Query("SELECT * FROM task_detail") + List loadAll(); + + @Transaction + default ArrayList loadLocalTask(TaskMarkerBeanDao taskMarkerBeanDao) { + ArrayList result = new ArrayList<>(); + List tasks = loadAll(); + for (TaskBean it : tasks) { + TaskDetailLocalModel model = new TaskDetailLocalModel(); + model.setTaskId(String.valueOf(it.getId())); + model.setTaskCode(it.getTaskCode()); + model.setDescription(it.getDescription()); + model.setCreateTime(it.getCreateTime()); + model.setStatus(it.getStatus()); + model.setCreateUserName(it.getCreateUserName()); + model.setIsFreeTask(it.getIsFree()); + ArrayList results = new ArrayList<>(); + if ("0".equals(it.getIsFree())) { + // 非自由巡检才有Marker + List markers = taskMarkerBeanDao.getMarkersByIdAndCode(String.valueOf(it.getId()), it.getTaskCode()); + for (TaskMarkerBean marker : markers) { + TaskDetailLocalModel.TaskMarkerLocalModel localModel = new TaskDetailLocalModel.TaskMarkerLocalModel(); + localModel.setMarkerId(marker.getMarkerId()); + localModel.setLng(marker.getLng()); + localModel.setLat(marker.getLat()); + localModel.setIsDetected(marker.getIsDetected()); + localModel.setDetectedTime(marker.getDetectedTime()); + + results.add(localModel); + } + } + model.setMarkerModels(results); + result.add(model); + } + return result; + } + + @Query("DELETE FROM task_detail WHERE id = :taskId AND taskCode = :taskCode") + void deleteTaskById(long taskId, String taskCode); + + @Transaction + default void deleteLocalTaskById(long taskId, String taskCode, TaskMarkerBeanDao taskMarkerBeanDao) { + TaskBean task = loadAll().stream() + .filter(it -> it.getId() == taskId && taskCode.equals(it.getTaskCode())) + .findFirst() + .orElse(null); + if (task == null) return; + deleteTaskById(taskId, taskCode); + + // 删除此任务关联的Marker。非自由巡检才有Marker + if ("0".equals(task.getIsFree())) { + List markers = taskMarkerBeanDao.getMarkersByIdAndCode(String.valueOf(task.getId()), task.getTaskCode()); + for (TaskMarkerBean marker : markers) { + taskMarkerBeanDao.delete(marker); + } + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/dao/TaskMarkerBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/dao/TaskMarkerBeanDao.java new file mode 100644 index 0000000..cc2156a --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/dao/TaskMarkerBeanDao.java @@ -0,0 +1,52 @@ +package com.casic.common.detector.gd.dao; + +import androidx.room.Dao; +import androidx.room.Delete; +import androidx.room.Insert; +import androidx.room.Query; +import androidx.room.Update; + +import com.casic.common.detector.gd.bean.TaskMarkerBean; +import com.casic.common.detector.gd.model.TaskModel; + +import java.util.List; + +@Dao +public interface TaskMarkerBeanDao { + + @Insert + void insert(TaskMarkerBean marker); + + @Query("SELECT COUNT(*) FROM task_marker_info WHERE id = :markerId") + int isMarkerExist(String markerId); + + default void saveTaskMarker(long taskId, String taskCode, TaskModel.MessageModel.TaskDetailInfosModel marker) { + if (isMarkerExist(marker.getMarkerId()) == 0) { + TaskMarkerBean bean = new TaskMarkerBean(); + bean.setId(marker.getId()); + bean.setTaskId(String.valueOf(taskId)); + bean.setTaskCode(taskCode); + bean.setMarkerId(marker.getMarkerIdReal()); + bean.setLng(marker.getLongitude()); + bean.setLat(marker.getLatitude()); + bean.setIsDetected("0"); + bean.setDetectedTime(""); + insert(bean); + } + } + + @Query("SELECT * FROM task_marker_info WHERE taskId = :taskId AND taskCode = :taskCode AND markerId = :markerId AND isDetected = :state") + TaskMarkerBean queryTaskMarkerById(String taskId, String taskCode, String markerId, String state); + + @Update + void updateLocalTaskMarkerState(TaskMarkerBean marker); + + @Query("SELECT * FROM task_marker_info WHERE isDetected = :state") + List queryMarkerByState(String state); + + @Query("SELECT * FROM task_marker_info WHERE taskId = :taskId AND taskCode = :taskCode") + List getMarkersByIdAndCode(String taskId, String taskCode); + + @Delete + void delete(TaskMarkerBean marker); +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/extensions/Long.kt b/app/src/main/java/com/casic/common/detector/gd/extensions/Long.kt deleted file mode 100644 index 6713d8d..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/extensions/Long.kt +++ /dev/null @@ -1,10 +0,0 @@ -package com.casic.common.detector.gd.extensions - -import java.text.SimpleDateFormat -import java.util.Date -import java.util.Locale - -fun Long.createTaskCode(): String { - val dateFormat = SimpleDateFormat("yyyyMMddHHmmss", Locale.CHINA) - return dateFormat.format(Date(this)) -} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoMaster.java b/app/src/main/java/com/casic/common/detector/gd/greendao/DaoMaster.java deleted file mode 100644 index 6ab94b3..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoMaster.java +++ /dev/null @@ -1,102 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import android.content.Context; -import android.database.sqlite.SQLiteDatabase; -import android.database.sqlite.SQLiteDatabase.CursorFactory; -import android.util.Log; - -import org.greenrobot.greendao.AbstractDaoMaster; -import org.greenrobot.greendao.database.StandardDatabase; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.database.DatabaseOpenHelper; -import org.greenrobot.greendao.identityscope.IdentityScopeType; - - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** - * Master of DAO (schema version 1): knows all DAOs. - */ -public class DaoMaster extends AbstractDaoMaster { - public static final int SCHEMA_VERSION = 1; - - /** Creates underlying database table using DAOs. */ - public static void createAllTables(Database db, boolean ifNotExists) { - MarkerLocalBeanDao.createTable(db, ifNotExists); - TaskLocalBeanDao.createTable(db, ifNotExists); - TaskMarkerLocalBeanDao.createTable(db, ifNotExists); - } - - /** Drops underlying database table using DAOs. */ - public static void dropAllTables(Database db, boolean ifExists) { - MarkerLocalBeanDao.dropTable(db, ifExists); - TaskLocalBeanDao.dropTable(db, ifExists); - TaskMarkerLocalBeanDao.dropTable(db, ifExists); - } - - /** - * WARNING: Drops all table on Upgrade! Use only during development. - * Convenience method using a {@link DevOpenHelper}. - */ - public static DaoSession newDevSession(Context context, String name) { - Database db = new DevOpenHelper(context, name).getWritableDb(); - DaoMaster daoMaster = new DaoMaster(db); - return daoMaster.newSession(); - } - - public DaoMaster(SQLiteDatabase db) { - this(new StandardDatabase(db)); - } - - public DaoMaster(Database db) { - super(db, SCHEMA_VERSION); - registerDaoClass(MarkerLocalBeanDao.class); - registerDaoClass(TaskLocalBeanDao.class); - registerDaoClass(TaskMarkerLocalBeanDao.class); - } - - public DaoSession newSession() { - return new DaoSession(db, IdentityScopeType.Session, daoConfigMap); - } - - public DaoSession newSession(IdentityScopeType type) { - return new DaoSession(db, type, daoConfigMap); - } - - /** - * Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} - - */ - public static abstract class OpenHelper extends DatabaseOpenHelper { - public OpenHelper(Context context, String name) { - super(context, name, SCHEMA_VERSION); - } - - public OpenHelper(Context context, String name, CursorFactory factory) { - super(context, name, factory, SCHEMA_VERSION); - } - - @Override - public void onCreate(Database db) { - Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION); - createAllTables(db, false); - } - } - - /** WARNING: Drops all table on Upgrade! Use only during development. */ - public static class DevOpenHelper extends OpenHelper { - public DevOpenHelper(Context context, String name) { - super(context, name); - } - - public DevOpenHelper(Context context, String name, CursorFactory factory) { - super(context, name, factory); - } - - @Override - public void onUpgrade(Database db, int oldVersion, int newVersion) { - Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables"); - dropAllTables(db, true); - onCreate(db); - } - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoSession.java b/app/src/main/java/com/casic/common/detector/gd/greendao/DaoSession.java deleted file mode 100644 index c8b1a20..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoSession.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import java.util.Map; - -import org.greenrobot.greendao.AbstractDao; -import org.greenrobot.greendao.AbstractDaoSession; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.identityscope.IdentityScopeType; -import org.greenrobot.greendao.internal.DaoConfig; - -import com.casic.common.detector.gd.bean.MarkerLocalBean; -import com.casic.common.detector.gd.bean.TaskLocalBean; -import com.casic.common.detector.gd.bean.TaskMarkerLocalBean; - -import com.casic.common.detector.gd.greendao.MarkerLocalBeanDao; -import com.casic.common.detector.gd.greendao.TaskLocalBeanDao; -import com.casic.common.detector.gd.greendao.TaskMarkerLocalBeanDao; - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. - -/** - * {@inheritDoc} - * - * @see org.greenrobot.greendao.AbstractDaoSession - */ -public class DaoSession extends AbstractDaoSession { - - private final DaoConfig markerLocalBeanDaoConfig; - private final DaoConfig taskLocalBeanDaoConfig; - private final DaoConfig taskMarkerLocalBeanDaoConfig; - - private final MarkerLocalBeanDao markerLocalBeanDao; - private final TaskLocalBeanDao taskLocalBeanDao; - private final TaskMarkerLocalBeanDao taskMarkerLocalBeanDao; - - public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> - daoConfigMap) { - super(db); - - markerLocalBeanDaoConfig = daoConfigMap.get(MarkerLocalBeanDao.class).clone(); - markerLocalBeanDaoConfig.initIdentityScope(type); - - taskLocalBeanDaoConfig = daoConfigMap.get(TaskLocalBeanDao.class).clone(); - taskLocalBeanDaoConfig.initIdentityScope(type); - - taskMarkerLocalBeanDaoConfig = daoConfigMap.get(TaskMarkerLocalBeanDao.class).clone(); - taskMarkerLocalBeanDaoConfig.initIdentityScope(type); - - markerLocalBeanDao = new MarkerLocalBeanDao(markerLocalBeanDaoConfig, this); - taskLocalBeanDao = new TaskLocalBeanDao(taskLocalBeanDaoConfig, this); - taskMarkerLocalBeanDao = new TaskMarkerLocalBeanDao(taskMarkerLocalBeanDaoConfig, this); - - registerDao(MarkerLocalBean.class, markerLocalBeanDao); - registerDao(TaskLocalBean.class, taskLocalBeanDao); - registerDao(TaskMarkerLocalBean.class, taskMarkerLocalBeanDao); - } - - public void clear() { - markerLocalBeanDaoConfig.clearIdentityScope(); - taskLocalBeanDaoConfig.clearIdentityScope(); - taskMarkerLocalBeanDaoConfig.clearIdentityScope(); - } - - public MarkerLocalBeanDao getMarkerLocalBeanDao() { - return markerLocalBeanDao; - } - - public TaskLocalBeanDao getTaskLocalBeanDao() { - return taskLocalBeanDao; - } - - public TaskMarkerLocalBeanDao getTaskMarkerLocalBeanDao() { - return taskMarkerLocalBeanDao; - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/MarkerLocalBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/greendao/MarkerLocalBeanDao.java deleted file mode 100644 index 2f792c3..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/MarkerLocalBeanDao.java +++ /dev/null @@ -1,479 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import android.database.Cursor; -import android.database.sqlite.SQLiteStatement; - -import org.greenrobot.greendao.AbstractDao; -import org.greenrobot.greendao.Property; -import org.greenrobot.greendao.internal.DaoConfig; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.database.DatabaseStatement; - -import com.casic.common.detector.gd.bean.MarkerLocalBean; - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** - * DAO for table "MARKER_LOCAL_BEAN". -*/ -public class MarkerLocalBeanDao extends AbstractDao { - - public static final String TABLENAME = "MARKER_LOCAL_BEAN"; - - /** - * Properties of entity MarkerLocalBean.
- * Can be used for QueryBuilder and for referencing column names. - */ - public static class Properties { - public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property PipelineType = new Property(1, String.class, "pipelineType", false, "PIPELINE_TYPE"); - public final static Property PipelineDiameter = new Property(2, String.class, "pipelineDiameter", false, "PIPELINE_DIAMETER"); - public final static Property PipelineMaterial = new Property(3, String.class, "pipelineMaterial", false, "PIPELINE_MATERIAL"); - public final static Property BuryMethod = new Property(4, String.class, "buryMethod", false, "BURY_METHOD"); - public final static Property BuryDepth = new Property(5, String.class, "buryDepth", false, "BURY_DEPTH"); - public final static Property Area = new Property(6, String.class, "area", false, "AREA"); - public final static Property Line = new Property(7, String.class, "line", false, "LINE"); - public final static Property Road = new Property(8, String.class, "road", false, "ROAD"); - public final static Property ConstructTime = new Property(9, String.class, "constructTime", false, "CONSTRUCT_TIME"); - public final static Property Owner = new Property(10, String.class, "owner", false, "OWNER"); - public final static Property ObjectId = new Property(11, String.class, "objectId", false, "OBJECT_ID"); - public final static Property MarkerId = new Property(12, String.class, "markerId", false, "MARKER_ID"); - public final static Property MarkerType = new Property(13, String.class, "markerType", false, "MARKER_TYPE"); - public final static Property MarkerDepth = new Property(14, String.class, "markerDepth", false, "MARKER_DEPTH"); - public final static Property InstallationDept = new Property(15, String.class, "installationDept", false, "INSTALLATION_DEPT"); - public final static Property Lng = new Property(16, String.class, "lng", false, "LNG"); - public final static Property Lat = new Property(17, String.class, "lat", false, "LAT"); - public final static Property UpdateTime = new Property(18, String.class, "updateTime", false, "UPDATE_TIME"); - public final static Property Remark = new Property(19, String.class, "remark", false, "REMARK"); - public final static Property UnderlyingPipelineType = new Property(20, String.class, "underlyingPipelineType", false, "UNDERLYING_PIPELINE_TYPE"); - public final static Property UnderlyingPipelineDepth = new Property(21, String.class, "underlyingPipelineDepth", false, "UNDERLYING_PIPELINE_DEPTH"); - public final static Property UnderlyingPipelineDiameter = new Property(22, String.class, "underlyingPipelineDiameter", false, "UNDERLYING_PIPELINE_DIAMETER"); - public final static Property UnderlyingPipelineMaterial = new Property(23, String.class, "underlyingPipelineMaterial", false, "UNDERLYING_PIPELINE_MATERIAL"); - public final static Property ObjectType = new Property(24, String.class, "objectType", false, "OBJECT_TYPE"); - public final static Property Color = new Property(25, String.class, "color", false, "COLOR"); - public final static Property ImagePath = new Property(26, String.class, "imagePath", false, "IMAGE_PATH"); - } - - - public MarkerLocalBeanDao(DaoConfig config) { - super(config); - } - - public MarkerLocalBeanDao(DaoConfig config, DaoSession daoSession) { - super(config, daoSession); - } - - /** Creates the underlying database table. */ - public static void createTable(Database db, boolean ifNotExists) { - String constraint = ifNotExists? "IF NOT EXISTS ": ""; - db.execSQL("CREATE TABLE " + constraint + "\"MARKER_LOCAL_BEAN\" (" + // - "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id - "\"PIPELINE_TYPE\" TEXT," + // 1: pipelineType - "\"PIPELINE_DIAMETER\" TEXT," + // 2: pipelineDiameter - "\"PIPELINE_MATERIAL\" TEXT," + // 3: pipelineMaterial - "\"BURY_METHOD\" TEXT," + // 4: buryMethod - "\"BURY_DEPTH\" TEXT," + // 5: buryDepth - "\"AREA\" TEXT," + // 6: area - "\"LINE\" TEXT," + // 7: line - "\"ROAD\" TEXT," + // 8: road - "\"CONSTRUCT_TIME\" TEXT," + // 9: constructTime - "\"OWNER\" TEXT," + // 10: owner - "\"OBJECT_ID\" TEXT," + // 11: objectId - "\"MARKER_ID\" TEXT," + // 12: markerId - "\"MARKER_TYPE\" TEXT," + // 13: markerType - "\"MARKER_DEPTH\" TEXT," + // 14: markerDepth - "\"INSTALLATION_DEPT\" TEXT," + // 15: installationDept - "\"LNG\" TEXT," + // 16: lng - "\"LAT\" TEXT," + // 17: lat - "\"UPDATE_TIME\" TEXT," + // 18: updateTime - "\"REMARK\" TEXT," + // 19: remark - "\"UNDERLYING_PIPELINE_TYPE\" TEXT," + // 20: underlyingPipelineType - "\"UNDERLYING_PIPELINE_DEPTH\" TEXT," + // 21: underlyingPipelineDepth - "\"UNDERLYING_PIPELINE_DIAMETER\" TEXT," + // 22: underlyingPipelineDiameter - "\"UNDERLYING_PIPELINE_MATERIAL\" TEXT," + // 23: underlyingPipelineMaterial - "\"OBJECT_TYPE\" TEXT," + // 24: objectType - "\"COLOR\" TEXT," + // 25: color - "\"IMAGE_PATH\" TEXT);"); // 26: imagePath - } - - /** Drops the underlying database table. */ - public static void dropTable(Database db, boolean ifExists) { - String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"MARKER_LOCAL_BEAN\""; - db.execSQL(sql); - } - - @Override - protected final void bindValues(DatabaseStatement stmt, MarkerLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String pipelineType = entity.getPipelineType(); - if (pipelineType != null) { - stmt.bindString(2, pipelineType); - } - - String pipelineDiameter = entity.getPipelineDiameter(); - if (pipelineDiameter != null) { - stmt.bindString(3, pipelineDiameter); - } - - String pipelineMaterial = entity.getPipelineMaterial(); - if (pipelineMaterial != null) { - stmt.bindString(4, pipelineMaterial); - } - - String buryMethod = entity.getBuryMethod(); - if (buryMethod != null) { - stmt.bindString(5, buryMethod); - } - - String buryDepth = entity.getBuryDepth(); - if (buryDepth != null) { - stmt.bindString(6, buryDepth); - } - - String area = entity.getArea(); - if (area != null) { - stmt.bindString(7, area); - } - - String line = entity.getLine(); - if (line != null) { - stmt.bindString(8, line); - } - - String road = entity.getRoad(); - if (road != null) { - stmt.bindString(9, road); - } - - String constructTime = entity.getConstructTime(); - if (constructTime != null) { - stmt.bindString(10, constructTime); - } - - String owner = entity.getOwner(); - if (owner != null) { - stmt.bindString(11, owner); - } - - String objectId = entity.getObjectId(); - if (objectId != null) { - stmt.bindString(12, objectId); - } - - String markerId = entity.getMarkerId(); - if (markerId != null) { - stmt.bindString(13, markerId); - } - - String markerType = entity.getMarkerType(); - if (markerType != null) { - stmt.bindString(14, markerType); - } - - String markerDepth = entity.getMarkerDepth(); - if (markerDepth != null) { - stmt.bindString(15, markerDepth); - } - - String installationDept = entity.getInstallationDept(); - if (installationDept != null) { - stmt.bindString(16, installationDept); - } - - String lng = entity.getLng(); - if (lng != null) { - stmt.bindString(17, lng); - } - - String lat = entity.getLat(); - if (lat != null) { - stmt.bindString(18, lat); - } - - String updateTime = entity.getUpdateTime(); - if (updateTime != null) { - stmt.bindString(19, updateTime); - } - - String remark = entity.getRemark(); - if (remark != null) { - stmt.bindString(20, remark); - } - - String underlyingPipelineType = entity.getUnderlyingPipelineType(); - if (underlyingPipelineType != null) { - stmt.bindString(21, underlyingPipelineType); - } - - String underlyingPipelineDepth = entity.getUnderlyingPipelineDepth(); - if (underlyingPipelineDepth != null) { - stmt.bindString(22, underlyingPipelineDepth); - } - - String underlyingPipelineDiameter = entity.getUnderlyingPipelineDiameter(); - if (underlyingPipelineDiameter != null) { - stmt.bindString(23, underlyingPipelineDiameter); - } - - String underlyingPipelineMaterial = entity.getUnderlyingPipelineMaterial(); - if (underlyingPipelineMaterial != null) { - stmt.bindString(24, underlyingPipelineMaterial); - } - - String objectType = entity.getObjectType(); - if (objectType != null) { - stmt.bindString(25, objectType); - } - - String color = entity.getColor(); - if (color != null) { - stmt.bindString(26, color); - } - - String imagePath = entity.getImagePath(); - if (imagePath != null) { - stmt.bindString(27, imagePath); - } - } - - @Override - protected final void bindValues(SQLiteStatement stmt, MarkerLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String pipelineType = entity.getPipelineType(); - if (pipelineType != null) { - stmt.bindString(2, pipelineType); - } - - String pipelineDiameter = entity.getPipelineDiameter(); - if (pipelineDiameter != null) { - stmt.bindString(3, pipelineDiameter); - } - - String pipelineMaterial = entity.getPipelineMaterial(); - if (pipelineMaterial != null) { - stmt.bindString(4, pipelineMaterial); - } - - String buryMethod = entity.getBuryMethod(); - if (buryMethod != null) { - stmt.bindString(5, buryMethod); - } - - String buryDepth = entity.getBuryDepth(); - if (buryDepth != null) { - stmt.bindString(6, buryDepth); - } - - String area = entity.getArea(); - if (area != null) { - stmt.bindString(7, area); - } - - String line = entity.getLine(); - if (line != null) { - stmt.bindString(8, line); - } - - String road = entity.getRoad(); - if (road != null) { - stmt.bindString(9, road); - } - - String constructTime = entity.getConstructTime(); - if (constructTime != null) { - stmt.bindString(10, constructTime); - } - - String owner = entity.getOwner(); - if (owner != null) { - stmt.bindString(11, owner); - } - - String objectId = entity.getObjectId(); - if (objectId != null) { - stmt.bindString(12, objectId); - } - - String markerId = entity.getMarkerId(); - if (markerId != null) { - stmt.bindString(13, markerId); - } - - String markerType = entity.getMarkerType(); - if (markerType != null) { - stmt.bindString(14, markerType); - } - - String markerDepth = entity.getMarkerDepth(); - if (markerDepth != null) { - stmt.bindString(15, markerDepth); - } - - String installationDept = entity.getInstallationDept(); - if (installationDept != null) { - stmt.bindString(16, installationDept); - } - - String lng = entity.getLng(); - if (lng != null) { - stmt.bindString(17, lng); - } - - String lat = entity.getLat(); - if (lat != null) { - stmt.bindString(18, lat); - } - - String updateTime = entity.getUpdateTime(); - if (updateTime != null) { - stmt.bindString(19, updateTime); - } - - String remark = entity.getRemark(); - if (remark != null) { - stmt.bindString(20, remark); - } - - String underlyingPipelineType = entity.getUnderlyingPipelineType(); - if (underlyingPipelineType != null) { - stmt.bindString(21, underlyingPipelineType); - } - - String underlyingPipelineDepth = entity.getUnderlyingPipelineDepth(); - if (underlyingPipelineDepth != null) { - stmt.bindString(22, underlyingPipelineDepth); - } - - String underlyingPipelineDiameter = entity.getUnderlyingPipelineDiameter(); - if (underlyingPipelineDiameter != null) { - stmt.bindString(23, underlyingPipelineDiameter); - } - - String underlyingPipelineMaterial = entity.getUnderlyingPipelineMaterial(); - if (underlyingPipelineMaterial != null) { - stmt.bindString(24, underlyingPipelineMaterial); - } - - String objectType = entity.getObjectType(); - if (objectType != null) { - stmt.bindString(25, objectType); - } - - String color = entity.getColor(); - if (color != null) { - stmt.bindString(26, color); - } - - String imagePath = entity.getImagePath(); - if (imagePath != null) { - stmt.bindString(27, imagePath); - } - } - - @Override - public Long readKey(Cursor cursor, int offset) { - return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); - } - - @Override - public MarkerLocalBean readEntity(Cursor cursor, int offset) { - MarkerLocalBean entity = new MarkerLocalBean( // - cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // pipelineType - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // pipelineDiameter - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // pipelineMaterial - cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // buryMethod - cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // buryDepth - cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // area - cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // line - cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // road - cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // constructTime - cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10), // owner - cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11), // objectId - cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12), // markerId - cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13), // markerType - cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14), // markerDepth - cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15), // installationDept - cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16), // lng - cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17), // lat - cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18), // updateTime - cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19), // remark - cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20), // underlyingPipelineType - cursor.isNull(offset + 21) ? null : cursor.getString(offset + 21), // underlyingPipelineDepth - cursor.isNull(offset + 22) ? null : cursor.getString(offset + 22), // underlyingPipelineDiameter - cursor.isNull(offset + 23) ? null : cursor.getString(offset + 23), // underlyingPipelineMaterial - cursor.isNull(offset + 24) ? null : cursor.getString(offset + 24), // objectType - cursor.isNull(offset + 25) ? null : cursor.getString(offset + 25), // color - cursor.isNull(offset + 26) ? null : cursor.getString(offset + 26) // imagePath - ); - return entity; - } - - @Override - public void readEntity(Cursor cursor, MarkerLocalBean entity, int offset) { - entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setPipelineType(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); - entity.setPipelineDiameter(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); - entity.setPipelineMaterial(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); - entity.setBuryMethod(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); - entity.setBuryDepth(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); - entity.setArea(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); - entity.setLine(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); - entity.setRoad(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); - entity.setConstructTime(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9)); - entity.setOwner(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); - entity.setObjectId(cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11)); - entity.setMarkerId(cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12)); - entity.setMarkerType(cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13)); - entity.setMarkerDepth(cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14)); - entity.setInstallationDept(cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15)); - entity.setLng(cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16)); - entity.setLat(cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17)); - entity.setUpdateTime(cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18)); - entity.setRemark(cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19)); - entity.setUnderlyingPipelineType(cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20)); - entity.setUnderlyingPipelineDepth(cursor.isNull(offset + 21) ? null : cursor.getString(offset + 21)); - entity.setUnderlyingPipelineDiameter(cursor.isNull(offset + 22) ? null : cursor.getString(offset + 22)); - entity.setUnderlyingPipelineMaterial(cursor.isNull(offset + 23) ? null : cursor.getString(offset + 23)); - entity.setObjectType(cursor.isNull(offset + 24) ? null : cursor.getString(offset + 24)); - entity.setColor(cursor.isNull(offset + 25) ? null : cursor.getString(offset + 25)); - entity.setImagePath(cursor.isNull(offset + 26) ? null : cursor.getString(offset + 26)); - } - - @Override - protected final Long updateKeyAfterInsert(MarkerLocalBean entity, long rowId) { - entity.setId(rowId); - return rowId; - } - - @Override - public Long getKey(MarkerLocalBean entity) { - if(entity != null) { - return entity.getId(); - } else { - return null; - } - } - - @Override - public boolean hasKey(MarkerLocalBean entity) { - return entity.getId() != null; - } - - @Override - protected final boolean isEntityUpdateable() { - return true; - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/TaskLocalBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/greendao/TaskLocalBeanDao.java deleted file mode 100644 index fb88157..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/TaskLocalBeanDao.java +++ /dev/null @@ -1,227 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import android.database.Cursor; -import android.database.sqlite.SQLiteStatement; - -import org.greenrobot.greendao.AbstractDao; -import org.greenrobot.greendao.Property; -import org.greenrobot.greendao.internal.DaoConfig; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.database.DatabaseStatement; - -import com.casic.common.detector.gd.bean.TaskLocalBean; - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** - * DAO for table "TASK_LOCAL_BEAN". -*/ -public class TaskLocalBeanDao extends AbstractDao { - - public static final String TABLENAME = "TASK_LOCAL_BEAN"; - - /** - * Properties of entity TaskLocalBean.
- * Can be used for QueryBuilder and for referencing column names. - */ - public static class Properties { - public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property TaskCode = new Property(1, String.class, "taskCode", false, "TASK_CODE"); - public final static Property Description = new Property(2, String.class, "description", false, "DESCRIPTION"); - public final static Property CreateTime = new Property(3, String.class, "createTime", false, "CREATE_TIME"); - public final static Property Status = new Property(4, String.class, "status", false, "STATUS"); - public final static Property CreateUserName = new Property(5, String.class, "createUserName", false, "CREATE_USER_NAME"); - public final static Property StartTime = new Property(6, String.class, "startTime", false, "START_TIME"); - public final static Property EndTime = new Property(7, String.class, "endTime", false, "END_TIME"); - public final static Property IsFreeTask = new Property(8, String.class, "isFreeTask", false, "IS_FREE_TASK"); - } - - - public TaskLocalBeanDao(DaoConfig config) { - super(config); - } - - public TaskLocalBeanDao(DaoConfig config, DaoSession daoSession) { - super(config, daoSession); - } - - /** Creates the underlying database table. */ - public static void createTable(Database db, boolean ifNotExists) { - String constraint = ifNotExists? "IF NOT EXISTS ": ""; - db.execSQL("CREATE TABLE " + constraint + "\"TASK_LOCAL_BEAN\" (" + // - "\"_id\" INTEGER PRIMARY KEY ," + // 0: id - "\"TASK_CODE\" TEXT," + // 1: taskCode - "\"DESCRIPTION\" TEXT," + // 2: description - "\"CREATE_TIME\" TEXT," + // 3: createTime - "\"STATUS\" TEXT," + // 4: status - "\"CREATE_USER_NAME\" TEXT," + // 5: createUserName - "\"START_TIME\" TEXT," + // 6: startTime - "\"END_TIME\" TEXT," + // 7: endTime - "\"IS_FREE_TASK\" TEXT);"); // 8: isFreeTask - } - - /** Drops the underlying database table. */ - public static void dropTable(Database db, boolean ifExists) { - String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"TASK_LOCAL_BEAN\""; - db.execSQL(sql); - } - - @Override - protected final void bindValues(DatabaseStatement stmt, TaskLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String taskCode = entity.getTaskCode(); - if (taskCode != null) { - stmt.bindString(2, taskCode); - } - - String description = entity.getDescription(); - if (description != null) { - stmt.bindString(3, description); - } - - String createTime = entity.getCreateTime(); - if (createTime != null) { - stmt.bindString(4, createTime); - } - - String status = entity.getStatus(); - if (status != null) { - stmt.bindString(5, status); - } - - String createUserName = entity.getCreateUserName(); - if (createUserName != null) { - stmt.bindString(6, createUserName); - } - - String startTime = entity.getStartTime(); - if (startTime != null) { - stmt.bindString(7, startTime); - } - - String endTime = entity.getEndTime(); - if (endTime != null) { - stmt.bindString(8, endTime); - } - - String isFreeTask = entity.getIsFreeTask(); - if (isFreeTask != null) { - stmt.bindString(9, isFreeTask); - } - } - - @Override - protected final void bindValues(SQLiteStatement stmt, TaskLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String taskCode = entity.getTaskCode(); - if (taskCode != null) { - stmt.bindString(2, taskCode); - } - - String description = entity.getDescription(); - if (description != null) { - stmt.bindString(3, description); - } - - String createTime = entity.getCreateTime(); - if (createTime != null) { - stmt.bindString(4, createTime); - } - - String status = entity.getStatus(); - if (status != null) { - stmt.bindString(5, status); - } - - String createUserName = entity.getCreateUserName(); - if (createUserName != null) { - stmt.bindString(6, createUserName); - } - - String startTime = entity.getStartTime(); - if (startTime != null) { - stmt.bindString(7, startTime); - } - - String endTime = entity.getEndTime(); - if (endTime != null) { - stmt.bindString(8, endTime); - } - - String isFreeTask = entity.getIsFreeTask(); - if (isFreeTask != null) { - stmt.bindString(9, isFreeTask); - } - } - - @Override - public Long readKey(Cursor cursor, int offset) { - return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); - } - - @Override - public TaskLocalBean readEntity(Cursor cursor, int offset) { - TaskLocalBean entity = new TaskLocalBean( // - cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // taskCode - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // description - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // createTime - cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // status - cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // createUserName - cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // startTime - cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // endTime - cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8) // isFreeTask - ); - return entity; - } - - @Override - public void readEntity(Cursor cursor, TaskLocalBean entity, int offset) { - entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setTaskCode(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); - entity.setDescription(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); - entity.setCreateTime(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); - entity.setStatus(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); - entity.setCreateUserName(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); - entity.setStartTime(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); - entity.setEndTime(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); - entity.setIsFreeTask(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); - } - - @Override - protected final Long updateKeyAfterInsert(TaskLocalBean entity, long rowId) { - entity.setId(rowId); - return rowId; - } - - @Override - public Long getKey(TaskLocalBean entity) { - if(entity != null) { - return entity.getId(); - } else { - return null; - } - } - - @Override - public boolean hasKey(TaskLocalBean entity) { - return entity.getId() != null; - } - - @Override - protected final boolean isEntityUpdateable() { - return true; - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/TaskMarkerLocalBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/greendao/TaskMarkerLocalBeanDao.java deleted file mode 100644 index e96c735..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/TaskMarkerLocalBeanDao.java +++ /dev/null @@ -1,197 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import android.database.Cursor; -import android.database.sqlite.SQLiteStatement; - -import org.greenrobot.greendao.AbstractDao; -import org.greenrobot.greendao.Property; -import org.greenrobot.greendao.internal.DaoConfig; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.database.DatabaseStatement; - -import com.casic.common.detector.gd.bean.TaskMarkerLocalBean; - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** - * DAO for table "TASK_MARKER_LOCAL_BEAN". -*/ -public class TaskMarkerLocalBeanDao extends AbstractDao { - - public static final String TABLENAME = "TASK_MARKER_LOCAL_BEAN"; - - /** - * Properties of entity TaskMarkerLocalBean.
- * Can be used for QueryBuilder and for referencing column names. - */ - public static class Properties { - public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property TaskId = new Property(1, String.class, "taskId", false, "TASK_ID"); - public final static Property TaskCode = new Property(2, String.class, "taskCode", false, "TASK_CODE"); - public final static Property MarkerId = new Property(3, String.class, "markerId", false, "MARKER_ID"); - public final static Property Lng = new Property(4, double.class, "lng", false, "LNG"); - public final static Property Lat = new Property(5, double.class, "lat", false, "LAT"); - public final static Property IsDetected = new Property(6, String.class, "isDetected", false, "IS_DETECTED"); - public final static Property DetectedTime = new Property(7, String.class, "detectedTime", false, "DETECTED_TIME"); - } - - - public TaskMarkerLocalBeanDao(DaoConfig config) { - super(config); - } - - public TaskMarkerLocalBeanDao(DaoConfig config, DaoSession daoSession) { - super(config, daoSession); - } - - /** Creates the underlying database table. */ - public static void createTable(Database db, boolean ifNotExists) { - String constraint = ifNotExists? "IF NOT EXISTS ": ""; - db.execSQL("CREATE TABLE " + constraint + "\"TASK_MARKER_LOCAL_BEAN\" (" + // - "\"_id\" INTEGER PRIMARY KEY ," + // 0: id - "\"TASK_ID\" TEXT," + // 1: taskId - "\"TASK_CODE\" TEXT," + // 2: taskCode - "\"MARKER_ID\" TEXT," + // 3: markerId - "\"LNG\" REAL NOT NULL ," + // 4: lng - "\"LAT\" REAL NOT NULL ," + // 5: lat - "\"IS_DETECTED\" TEXT," + // 6: isDetected - "\"DETECTED_TIME\" TEXT);"); // 7: detectedTime - } - - /** Drops the underlying database table. */ - public static void dropTable(Database db, boolean ifExists) { - String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"TASK_MARKER_LOCAL_BEAN\""; - db.execSQL(sql); - } - - @Override - protected final void bindValues(DatabaseStatement stmt, TaskMarkerLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String taskId = entity.getTaskId(); - if (taskId != null) { - stmt.bindString(2, taskId); - } - - String taskCode = entity.getTaskCode(); - if (taskCode != null) { - stmt.bindString(3, taskCode); - } - - String markerId = entity.getMarkerId(); - if (markerId != null) { - stmt.bindString(4, markerId); - } - stmt.bindDouble(5, entity.getLng()); - stmt.bindDouble(6, entity.getLat()); - - String isDetected = entity.getIsDetected(); - if (isDetected != null) { - stmt.bindString(7, isDetected); - } - - String detectedTime = entity.getDetectedTime(); - if (detectedTime != null) { - stmt.bindString(8, detectedTime); - } - } - - @Override - protected final void bindValues(SQLiteStatement stmt, TaskMarkerLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String taskId = entity.getTaskId(); - if (taskId != null) { - stmt.bindString(2, taskId); - } - - String taskCode = entity.getTaskCode(); - if (taskCode != null) { - stmt.bindString(3, taskCode); - } - - String markerId = entity.getMarkerId(); - if (markerId != null) { - stmt.bindString(4, markerId); - } - stmt.bindDouble(5, entity.getLng()); - stmt.bindDouble(6, entity.getLat()); - - String isDetected = entity.getIsDetected(); - if (isDetected != null) { - stmt.bindString(7, isDetected); - } - - String detectedTime = entity.getDetectedTime(); - if (detectedTime != null) { - stmt.bindString(8, detectedTime); - } - } - - @Override - public Long readKey(Cursor cursor, int offset) { - return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); - } - - @Override - public TaskMarkerLocalBean readEntity(Cursor cursor, int offset) { - TaskMarkerLocalBean entity = new TaskMarkerLocalBean( // - cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // taskId - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // taskCode - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // markerId - cursor.getDouble(offset + 4), // lng - cursor.getDouble(offset + 5), // lat - cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // isDetected - cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7) // detectedTime - ); - return entity; - } - - @Override - public void readEntity(Cursor cursor, TaskMarkerLocalBean entity, int offset) { - entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setTaskId(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); - entity.setTaskCode(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); - entity.setMarkerId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); - entity.setLng(cursor.getDouble(offset + 4)); - entity.setLat(cursor.getDouble(offset + 5)); - entity.setIsDetected(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); - entity.setDetectedTime(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); - } - - @Override - protected final Long updateKeyAfterInsert(TaskMarkerLocalBean entity, long rowId) { - entity.setId(rowId); - return rowId; - } - - @Override - public Long getKey(TaskMarkerLocalBean entity) { - if(entity != null) { - return entity.getId(); - } else { - return null; - } - } - - @Override - public boolean hasKey(TaskMarkerLocalBean entity) { - return entity.getId() != null; - } - - @Override - protected final boolean isEntityUpdateable() { - return true; - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/model/TaskModel.java b/app/src/main/java/com/casic/common/detector/gd/model/TaskModel.java index 6e853ad..67ef5fb 100644 --- a/app/src/main/java/com/casic/common/detector/gd/model/TaskModel.java +++ b/app/src/main/java/com/casic/common/detector/gd/model/TaskModel.java @@ -24,7 +24,7 @@ } public static class MessageModel { - private int id; + private Long id; private String taskCode; private String description; private String deployDate; @@ -38,11 +38,11 @@ private int isValid; private List taskDetailInfos; - public int getId() { + public Long getId() { return id; } - public void setId(int id) { + public void setId(Long id) { this.id = id; } @@ -143,25 +143,25 @@ } public static class TaskDetailInfosModel { - private int id; + private long id; private String taskId; private String taskCode; private Object markerName; - private int markerId; + private String markerId; private String markerIdReal; private double longitude; private double latitude; private int isChecked; private int isNormal; - private Object imagePath; - private Object description; - private Object finishTime; + private String imagePath; + private String description; + private String finishTime; - public int getId() { + public long getId() { return id; } - public void setId(int id) { + public void setId(long id) { this.id = id; } @@ -189,11 +189,11 @@ this.markerName = markerName; } - public int getMarkerId() { + public String getMarkerId() { return markerId; } - public void setMarkerId(int markerId) { + public void setMarkerId(String markerId) { this.markerId = markerId; } @@ -237,27 +237,27 @@ this.isNormal = isNormal; } - public Object getImagePath() { + public String getImagePath() { return imagePath; } - public void setImagePath(Object imagePath) { + public void setImagePath(String imagePath) { this.imagePath = imagePath; } - public Object getDescription() { + public String getDescription() { return description; } - public void setDescription(Object description) { + public void setDescription(String description) { this.description = description; } - public Object getFinishTime() { + public String getFinishTime() { return finishTime; } - public void setFinishTime(Object finishTime) { + public void setFinishTime(String finishTime) { this.finishTime = finishTime; } } diff --git a/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitService.kt index 7522a87..0adad51 100644 --- a/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitService.kt @@ -50,7 +50,7 @@ */ @Multipart @POST("/ems/marker/save-marker-photo.do") - suspend fun installLabel( + suspend fun install( @PartMap jsonMarker: Map, @Part fileBuffer1: MultipartBody.Part?, @Part fileBuffer2: MultipartBody.Part?, diff --git a/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitServiceManager.kt index 5f6c701..ae2a0fa 100644 --- a/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitServiceManager.kt +++ b/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitServiceManager.kt @@ -37,22 +37,28 @@ /** * 获取标识器信息文件 */ - suspend fun getMarkerFile(userId: String, companyId: String): String { - return createApi().getMarkerFile(userId, companyId) + suspend fun getMarkerFile(): String { + val companyId = SaveKeyValues.getValue(LocaleConstant.USER_COMPANY_ID, "") as String + /** + * 后台设计如此,都传companyId + * */ + return createApi().getMarkerFile(companyId, companyId) } /** * 获取巡检工单 */ - suspend fun getTasksByUser(userName: String): String { + suspend fun getTasksByUser(): String { + val userName = SaveKeyValues.getValue(LocaleConstant.USER_NAME, "") as String return createApi().getTasksByUser(userName) } /** * 提交工单 */ - suspend fun uploadTask(userId: String, taskId: String?, state: String): String { + suspend fun uploadTask(taskId: String?, state: String): String { + val userId = SaveKeyValues.getValue(LocaleConstant.USER_ID, "") as String return createApi().uploadTask(userId, taskId.toString(), state) } @@ -60,8 +66,7 @@ * 安装新标识器 * Multipart上传图片,文件,带多参数上传 */ - suspend fun installLabel( - companyId: String, + suspend fun installMarker( recordType: String, markerObjectType: String, pipeMaterial: String, @@ -77,7 +82,6 @@ road: String, constructTime: String, ownerComp: String, - markerObjectId: String, markerId: String, markerType: String, markerDepth: String, @@ -89,6 +93,8 @@ memo: String, realPaths: ArrayList ): String { + val companyId = SaveKeyValues.getValue(LocaleConstant.USER_COMPANY_ID, "") as String + val objectId = SaveKeyValues.getValue(LocaleConstant.OBJECT_ID, "") as String val param = JsonObject() param.addProperty("companyId", companyId) param.addProperty("recordType", recordType) @@ -106,7 +112,7 @@ param.addProperty("road", road) param.addProperty("constructTime", constructTime) param.addProperty("ownerComp", ownerComp) - param.addProperty("markerObjectId", markerObjectId) + param.addProperty("markerObjectId", objectId) param.addProperty("markerId", markerId) param.addProperty("markerType", markerType) param.addProperty("markerDepth", markerDepth) @@ -133,19 +139,19 @@ return when (multiParts.size) { 3 -> { - createApi().installLabel(res, multiParts[0], multiParts[1], multiParts[2]) + createApi().install(res, multiParts[0], multiParts[1], multiParts[2]) } 2 -> { - createApi().installLabel(res, multiParts[0], multiParts[1], null) + createApi().install(res, multiParts[0], multiParts[1], null) } 1 -> { - createApi().installLabel(res, multiParts[0], null, null) + createApi().install(res, multiParts[0], null, null) } else -> { - createApi().installLabel(res, null, null, null) + createApi().install(res, null, null, null) } } } @@ -216,7 +222,7 @@ /** * 上传自由巡检过程中发现的标识器 */ - suspend fun uploadTaskMarker(taskId: String, ids: ArrayList): String { + suspend fun uploadTaskMarker(taskId: Long, ids: ArrayList): String { val param = JsonObject() param.addProperty("taskId", taskId) param.addProperty("ids", ids.joinToString(separator = ",")) diff --git a/app/src/main/java/com/casic/common/detector/gd/service/NtripConnectService.kt b/app/src/main/java/com/casic/common/detector/gd/service/NtripConnectService.kt index de9ac80..20e1a6a 100644 --- a/app/src/main/java/com/casic/common/detector/gd/service/NtripConnectService.kt +++ b/app/src/main/java/com/casic/common/detector/gd/service/NtripConnectService.kt @@ -9,10 +9,6 @@ import android.util.Log import android.view.Gravity import android.widget.Toast -import androidx.lifecycle.Lifecycle -import androidx.lifecycle.LifecycleOwner -import androidx.lifecycle.LifecycleRegistry -import androidx.lifecycle.lifecycleScope import com.casic.common.detector.gd.base.BaseApplication import com.casic.common.detector.gd.extensions.convertToGPGGA import com.casic.common.detector.gd.utils.LocaleConstant @@ -23,26 +19,24 @@ import com.pengxh.kt.lite.utils.WeakReferenceHandler import com.pengxh.kt.lite.utils.socket.tcp.OnTcpConnectStateListener import com.pengxh.kt.lite.utils.socket.tcp.TcpClient +import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.Job import kotlinx.coroutines.launch import java.io.OutputStream import java.nio.charset.StandardCharsets -class NtripConnectService : Service(), LifecycleOwner, OnTcpConnectStateListener, Handler.Callback { +class NtripConnectService : Service(), OnTcpConnectStateListener, Handler.Callback { companion object { var weakReferenceHandler: WeakReferenceHandler? = null } private val kTag = "NtripConnectService" - private val registry = LifecycleRegistry(this) private val socketClient by lazy { TcpClient(this) } private var outStream: OutputStream? = null - - override fun getLifecycle(): Lifecycle { - return registry - } + private val serviceScope = CoroutineScope(Dispatchers.Main + Job()) // 创建一个独立的CoroutineScope override fun onBind(intent: Intent?): IBinder? { return null @@ -117,7 +111,7 @@ * */ val result = String(this, StandardCharsets.UTF_8) if (result.contains("ICY 200 OK")) { - lifecycleScope.launch(Dispatchers.Main) { + serviceScope.launch { "高精度定位服务连接成功".show(this@NtripConnectService) } //连接服务即打开串口 @@ -135,12 +129,12 @@ * Content-Type: text/plain * Connection: clos * */ - lifecycleScope.launch(Dispatchers.Main) { + serviceScope.launch { "差分定位服务鉴权失败,无法解析位置".show(this@NtripConnectService) } } else { //居中显示 - lifecycleScope.launch(Dispatchers.Main) { + serviceScope.launch { val toast = Toast.makeText( this@NtripConnectService, "收到千寻数据,长度:${size}", Toast.LENGTH_SHORT ) @@ -167,7 +161,7 @@ return } - lifecycleScope.launch(Dispatchers.IO) { + serviceScope.launch(Dispatchers.IO) { socketClient.start(remoteHost, remotePort.toInt()) } } diff --git a/app/src/main/java/com/casic/common/detector/gd/utils/DataBaseManager.kt b/app/src/main/java/com/casic/common/detector/gd/utils/DataBaseManager.kt deleted file mode 100644 index aa22759..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/utils/DataBaseManager.kt +++ /dev/null @@ -1,200 +0,0 @@ -package com.casic.common.detector.gd.utils - -import com.casic.common.detector.gd.base.BaseApplication -import com.casic.common.detector.gd.bean.MarkerLocalBean -import com.casic.common.detector.gd.bean.TaskLocalBean -import com.casic.common.detector.gd.bean.TaskMarkerLocalBean -import com.casic.common.detector.gd.greendao.MarkerLocalBeanDao -import com.casic.common.detector.gd.greendao.TaskLocalBeanDao -import com.casic.common.detector.gd.greendao.TaskMarkerLocalBeanDao -import com.casic.common.detector.gd.model.TaskDetailLocalModel -import com.casic.common.detector.gd.model.TaskModel - -class DataBaseManager private constructor() { - companion object { - //Kotlin委托模式双重锁单例 - val get by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) { - DataBaseManager() - } - } - - private var taskLocalBeanDao = BaseApplication.get().getDaoSession().taskLocalBeanDao - private var taskMarkerLocalBeanDao = - BaseApplication.get().getDaoSession().taskMarkerLocalBeanDao - - fun saveTaskInLocale(task: TaskModel.MessageModel) { - val bean = TaskLocalBean() - bean.id = task.id.toLong() - bean.taskCode = task.taskCode - bean.description = task.description - bean.createTime = task.deployDate - bean.status = task.status - bean.createUserName = task.creatorName - if (task.beginDate == null) { - bean.startTime = "" - } - if (task.endDate == null) { - bean.endTime = "" - } - bean.isFreeTask = "0" - if (!bean.isExist()) { - taskLocalBeanDao.insert(bean) - } - } - - fun saveTaskInLocale(bean: TaskLocalBean) { - if (!bean.isExist()) { - taskLocalBeanDao.insert(bean) - } - } - - private fun TaskLocalBean.isExist(): Boolean { - val result = taskLocalBeanDao.queryBuilder().where( - TaskLocalBeanDao.Properties.Id.eq(this.id) - ).list() - return !result.isNullOrEmpty() - } - - fun saveTaskMarkerInLocale( - taskId: Int, taskCode: String, marker: TaskModel.MessageModel.TaskDetailInfosModel - ) { - val bean = TaskMarkerLocalBean() - bean.id = marker.id.toLong() - bean.taskId = taskId.toString() - bean.taskCode = taskCode - bean.markerId = marker.markerIdReal - bean.lng = marker.longitude - bean.lat = marker.latitude - bean.isDetected = "0" - bean.detectedTime = "" - if (!bean.isExist()) { - taskMarkerLocalBeanDao.insert(bean) - } - } - - private fun TaskMarkerLocalBean.isExist(): Boolean { - val result = taskMarkerLocalBeanDao.queryBuilder().where( - TaskMarkerLocalBeanDao.Properties.Id.eq(this.id) - ).list() - return !result.isNullOrEmpty() - } - - fun loadLocalTask(): ArrayList { - val result = ArrayList() - - val tasks = taskLocalBeanDao.loadAll() - tasks.forEach { - val model = TaskDetailLocalModel() - model.taskId = it.id.toString() - model.taskCode = it.taskCode - model.description = it.description - model.createTime = it.createTime - model.status = it.status - model.createUserName = it.createUserName - model.isFreeTask = it.isFreeTask - - val markers = ArrayList() - if (it.isFreeTask == "0") { - //非自由巡检才有Marker - val markerLocalBeans = taskMarkerLocalBeanDao.queryBuilder().where( - TaskMarkerLocalBeanDao.Properties.TaskId.eq(it.id), - TaskMarkerLocalBeanDao.Properties.TaskCode.eq(it.taskCode) - ).list() - markerLocalBeans.forEach { marker -> - val localModel = TaskDetailLocalModel.TaskMarkerLocalModel() - localModel.markerId = marker.markerId - localModel.lng = marker.lng - localModel.lat = marker.lat - localModel.isDetected = marker.isDetected - localModel.detectedTime = marker.detectedTime - - markers.add(localModel) - } - } - model.markerModels = markers - result.add(model) - } - return result - } - - fun deleteLocalTaskById(taskId: String, taskCode: String) { - val task = taskLocalBeanDao.queryBuilder().where( - TaskLocalBeanDao.Properties.Id.eq(taskId), - TaskLocalBeanDao.Properties.TaskCode.eq(taskCode) - ).list().firstOrNull() ?: return - taskLocalBeanDao.delete(task) - - //删除此任务关联的Marker。非自由巡检才有Marker - if (task.isFreeTask == "0") { - val markers = taskMarkerLocalBeanDao.queryBuilder() - .where( - TaskMarkerLocalBeanDao.Properties.TaskId.eq(taskId), - TaskMarkerLocalBeanDao.Properties.TaskCode.eq(taskCode) - ).list() - markers.forEach { - taskMarkerLocalBeanDao.delete(it) - } - } - } - - fun queryTaskMarkerById( - taskId: String, taskCode: String, markerId: String, state: String - ): TaskMarkerLocalBean? { - return taskMarkerLocalBeanDao.queryBuilder() - .where( - TaskMarkerLocalBeanDao.Properties.TaskId.eq(taskId), - TaskMarkerLocalBeanDao.Properties.TaskCode.eq(taskCode), - TaskMarkerLocalBeanDao.Properties.MarkerId.eq(markerId), - TaskMarkerLocalBeanDao.Properties.IsDetected.eq(state) - ).list().firstOrNull() - } - - fun updateLocalTaskMarkerState(marker: TaskMarkerLocalBean) { - marker.isDetected = "1" - taskMarkerLocalBeanDao.update(marker) - } - - fun queryMarkerByState(state: String): List { - return taskMarkerLocalBeanDao.queryBuilder() - .where(TaskMarkerLocalBeanDao.Properties.IsDetected.eq(state)) - .list() - } - - private var markerLocalBeanDao = BaseApplication.get().getDaoSession().markerLocalBeanDao - - fun clearMarkers() { - markerLocalBeanDao.deleteAll() - } - - fun saveMarkerInLocale(bean: MarkerLocalBean) { - markerLocalBeanDao.insert(bean) - } - - fun loadMarkers(): MutableList { - return markerLocalBeanDao.loadAll() - } - - fun loadMarkersByCondition(selectedItem: String, value: String?): MutableList { - val property = when (selectedItem) { - LocaleConstant.SPINNER_ARRAY[0] -> MarkerLocalBeanDao.Properties.MarkerId - LocaleConstant.SPINNER_ARRAY[1] -> MarkerLocalBeanDao.Properties.Area - LocaleConstant.SPINNER_ARRAY[2] -> MarkerLocalBeanDao.Properties.Line - LocaleConstant.SPINNER_ARRAY[3] -> MarkerLocalBeanDao.Properties.Road - LocaleConstant.SPINNER_ARRAY[4] -> MarkerLocalBeanDao.Properties.Owner - LocaleConstant.SPINNER_ARRAY[5] -> MarkerLocalBeanDao.Properties.InstallationDept - LocaleConstant.SPINNER_ARRAY[6] -> MarkerLocalBeanDao.Properties.UpdateTime - else -> MarkerLocalBeanDao.Properties.Remark - } - return if (value == null) { - markerLocalBeanDao.queryBuilder().where(property.isNotNull).list() - } else { - markerLocalBeanDao.queryBuilder().where(property.eq(value)).list() - } - } - - fun queryMarkerById(markerId: String): List { - return markerLocalBeanDao.queryBuilder() - .where(MarkerLocalBeanDao.Properties.MarkerId.eq(markerId)) - .list() - } -} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/utils/DetectorDataBase.java b/app/src/main/java/com/casic/common/detector/gd/utils/DetectorDataBase.java new file mode 100644 index 0000000..f686cac --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/utils/DetectorDataBase.java @@ -0,0 +1,21 @@ +package com.casic.common.detector.gd.utils; + +import androidx.room.Database; +import androidx.room.RoomDatabase; + +import com.casic.common.detector.gd.bean.MarkerBean; +import com.casic.common.detector.gd.bean.TaskBean; +import com.casic.common.detector.gd.bean.TaskMarkerBean; +import com.casic.common.detector.gd.dao.MarkerBeanDao; +import com.casic.common.detector.gd.dao.TaskBeanDao; +import com.casic.common.detector.gd.dao.TaskMarkerBeanDao; + + +@Database(entities = {MarkerBean.class, TaskBean.class, TaskMarkerBean.class}, version = 1) +public abstract class DetectorDataBase extends RoomDatabase { + public abstract MarkerBeanDao markerBeanDao(); + + public abstract TaskBeanDao taskBeanDao(); + + public abstract TaskMarkerBeanDao taskMarkerBeanDao(); +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/utils/ExcelKit.kt b/app/src/main/java/com/casic/common/detector/gd/utils/ExcelKit.kt index 200fac7..015969f 100644 --- a/app/src/main/java/com/casic/common/detector/gd/utils/ExcelKit.kt +++ b/app/src/main/java/com/casic/common/detector/gd/utils/ExcelKit.kt @@ -1,19 +1,19 @@ package com.casic.common.detector.gd.utils -import com.casic.common.detector.gd.bean.MarkerLocalBean +import com.casic.common.detector.gd.base.BaseApplication +import com.casic.common.detector.gd.bean.MarkerBean import jxl.Workbook import jxl.read.biff.BiffException import java.io.File object ExcelKit { - fun read(filePath: String): ArrayList { - val result = ArrayList() + fun read(filePath: String): ArrayList { + val result = ArrayList() try { val workbook = Workbook.getWorkbook(File(filePath)) val sheet = workbook.getSheet(0) - for (i in 1 until sheet.rows) { - val marker = MarkerLocalBean() + val marker = MarkerBean() marker.pipelineType = sheet.getCell(0, i).contents marker.pipelineDiameter = sheet.getCell(1, i).contents marker.pipelineMaterial = sheet.getCell(2, i).contents @@ -40,9 +40,10 @@ marker.objectType = sheet.getCell(23, i).contents marker.color = sheet.getCell(24, i).contents marker.imagePath = sheet.getCell(25, i).contents - - result.add(marker) - DataBaseManager.get.saveMarkerInLocale(marker) + if (!marker.markerId.isNullOrBlank()) { + result.add(marker) + BaseApplication.get().dataBase.markerBeanDao().insert(marker) + } } workbook.close() } catch (e: BiffException) { diff --git a/app/src/main/java/com/casic/common/detector/gd/utils/LocaleConstant.kt b/app/src/main/java/com/casic/common/detector/gd/utils/LocaleConstant.kt index c658924..8ac5f76 100644 --- a/app/src/main/java/com/casic/common/detector/gd/utils/LocaleConstant.kt +++ b/app/src/main/java/com/casic/common/detector/gd/utils/LocaleConstant.kt @@ -1,6 +1,8 @@ package com.casic.common.detector.gd.utils import android.Manifest +import androidx.sqlite.db.SimpleSQLiteQuery +import androidx.sqlite.db.SupportSQLiteQuery object LocaleConstant { @@ -59,4 +61,19 @@ var BURY_METHOD_ARRAY = arrayOf("直埋", "圆管", "管块", "管沟", "架空") var IDENTIFIER_TYPE_ARRAY = arrayOf("EM30", "EM50", "EM14") var COLOR_ARRAY = arrayOf("蓝色", "橙色", "红色", "黑色", "紫色", "黄色", "绿色") + + fun buildQuery(selectedItem: String, value: String): SupportSQLiteQuery { + val columnName = when (selectedItem) { + SPINNER_ARRAY[0] -> "markerId" + SPINNER_ARRAY[1] -> "area" + SPINNER_ARRAY[2] -> "line" + SPINNER_ARRAY[3] -> "road" + SPINNER_ARRAY[4] -> "owner" + SPINNER_ARRAY[5] -> "installationDept" + SPINNER_ARRAY[6] -> "updateTime" + else -> "remark" + } + val queryBuilder = StringBuilder("SELECT * FROM marker_detail WHERE $columnName = ?") + return SimpleSQLiteQuery(queryBuilder.toString(), arrayOf(value)) + } } \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/view/InstallMarkerActivity.kt b/app/src/main/java/com/casic/common/detector/gd/view/InstallMarkerActivity.kt index daf5b0f..9e09df1 100644 --- a/app/src/main/java/com/casic/common/detector/gd/view/InstallMarkerActivity.kt +++ b/app/src/main/java/com/casic/common/detector/gd/view/InstallMarkerActivity.kt @@ -14,8 +14,9 @@ import com.amap.api.location.AMapLocation import com.casic.common.detector.gd.R import com.casic.common.detector.gd.adapter.EditableImageAdapter +import com.casic.common.detector.gd.base.BaseApplication import com.casic.common.detector.gd.base.SerialPortBaseActivity -import com.casic.common.detector.gd.bean.MarkerLocalBean +import com.casic.common.detector.gd.bean.MarkerBean import com.casic.common.detector.gd.callback.OnGetLocationListener import com.casic.common.detector.gd.callback.OnImageCompressListener import com.casic.common.detector.gd.databinding.ActivityInstallMarkerBinding @@ -27,7 +28,6 @@ import com.casic.common.detector.gd.extensions.toColor import com.casic.common.detector.gd.extensions.toObjectType import com.casic.common.detector.gd.utils.CurrentSegment -import com.casic.common.detector.gd.utils.DataBaseManager import com.casic.common.detector.gd.utils.LocaleConstant import com.casic.common.detector.gd.utils.LocationKit import com.casic.common.detector.gd.utils.RuntimeCache @@ -44,7 +44,6 @@ import com.pengxh.kt.lite.extensions.timestampToCompleteDate import com.pengxh.kt.lite.extensions.timestampToTime import com.pengxh.kt.lite.extensions.toJson -import com.pengxh.kt.lite.utils.LoadState import com.pengxh.kt.lite.utils.LoadingDialog import com.pengxh.kt.lite.utils.SaveKeyValues import com.pengxh.kt.lite.widget.TitleBarView @@ -115,8 +114,6 @@ //安装 binding.installButton.setOnClickListener { - val companyId = SaveKeyValues.getValue(LocaleConstant.USER_COMPANY_ID, "") as String - val objectId = SaveKeyValues.getValue(LocaleConstant.OBJECT_ID, "") as String if (binding.objectInclude.pipeInclude.markerObjectTypeView.text.isNullOrBlank()) { when (binding.objectInclude.objectTypeSpinner.selectedItem.toString()) { "管线" -> "请输入管线种类!".show(this) @@ -189,8 +186,7 @@ //先存本地再上传服务器 saveMarkerInLocal() - taskViewModel.installLabel( - this, companyId, + taskViewModel.installMarker( binding.objectInclude.objectTypeSpinner.selectedItem.toString().toObjectType(), binding.objectInclude.pipeInclude.markerObjectTypeView.text.toString(), binding.objectInclude.pipeInclude.materialSpinner.selectedItem.toString(), @@ -206,7 +202,6 @@ binding.objectInclude.roadView.text.toString(), binding.objectInclude.constructDateView.text.toString(), binding.objectInclude.ownerView.text.toString(), - objectId, binding.identifierInclude.identifierIdView.text.toString(), binding.identifierInclude.identifierTypeSpinner.selectedItem.toString(), "${binding.identifierInclude.identifierDeepView.text}mm", @@ -216,7 +211,19 @@ binding.identifierInclude.latView.text.toString(), binding.identifierInclude.colorSpinner.selectedItem.toString().toColor(), binding.remarkView.text.toString(), - realPaths + realPaths, + onLoading = { + LoadingDialog.show(this, "标识器安装中,请稍后...") + }, + onSuccess = { + LoadingDialog.dismiss() + clearDefaultData() + "安装成功".show(this) + }, + onFailed = { + LoadingDialog.dismiss() + it.show(this) + } ) //保存默认值 @@ -268,7 +275,7 @@ private fun saveMarkerInLocal() { val objectId = SaveKeyValues.getValue(LocaleConstant.OBJECT_ID, "") as String - val marker = MarkerLocalBean() + val marker = MarkerBean() marker.objectType = binding.objectInclude.objectTypeSpinner.selectedItem.toString() marker.pipelineType = binding.objectInclude.pipeInclude.markerObjectTypeView.text.toString() marker.pipelineMaterial = @@ -302,7 +309,7 @@ marker.remark = binding.remarkView.text.toString() marker.imagePath = realPaths.toJson() - DataBaseManager.get.saveMarkerInLocale(marker) + BaseApplication.get().dataBase.markerBeanDao().insert(marker) } private fun takePicture() { @@ -339,8 +346,8 @@ override fun initOnCreate(savedInstanceState: Bundle?) { locationKit.getCurrentLocation(true, object : OnGetLocationListener { override fun onSuccess(location: AMapLocation) { - binding.identifierInclude.lngView.text = location.longitude.toString() - binding.identifierInclude.latView.text = location.latitude.toString() + binding.identifierInclude.lngView.text = "${location.longitude}" + binding.identifierInclude.latView.text = "${location.latitude}" } override fun onError() { @@ -357,22 +364,6 @@ return ActivityInstallMarkerBinding.inflate(layoutInflater) } - override fun observeRequestState() { - taskViewModel.loadState.observe(this) { - when (it) { - LoadState.Loading -> LoadingDialog.show(this, "标识器安装中,请稍后...") - - LoadState.Success -> { - LoadingDialog.dismiss() - clearDefaultData() - "安装成功".show(this) - } - - else -> LoadingDialog.dismiss() - } - } - } - override fun setupTopBarLayout() { binding.rootView.initImmersionBar(this, true, R.color.white) binding.titleView.setOnClickListener(object : TitleBarView.OnClickListener { diff --git a/app/src/main/java/com/casic/common/detector/gd/view/MainActivity.kt b/app/src/main/java/com/casic/common/detector/gd/view/MainActivity.kt index fb0b260..a6352fb 100644 --- a/app/src/main/java/com/casic/common/detector/gd/view/MainActivity.kt +++ b/app/src/main/java/com/casic/common/detector/gd/view/MainActivity.kt @@ -5,7 +5,6 @@ import android.graphics.Color import android.media.AudioAttributes import android.media.SoundPool -import android.os.Build import android.os.Bundle import android.os.CountDownTimer import android.os.Handler @@ -31,19 +30,17 @@ import com.casic.common.detector.gd.R import com.casic.common.detector.gd.base.BaseApplication import com.casic.common.detector.gd.base.SerialPortBaseActivity -import com.casic.common.detector.gd.bean.MarkerLocalBean -import com.casic.common.detector.gd.bean.TaskLocalBean +import com.casic.common.detector.gd.bean.MarkerBean import com.casic.common.detector.gd.callback.OnGetAddressListener import com.casic.common.detector.gd.callback.OnGetLocationListener import com.casic.common.detector.gd.databinding.ActivityMainBinding import com.casic.common.detector.gd.extensions.appendDownloadUrl -import com.casic.common.detector.gd.extensions.createTaskCode import com.casic.common.detector.gd.extensions.initImmersionBar +import com.casic.common.detector.gd.model.MarkerFileModel import com.casic.common.detector.gd.model.TaskDetailLocalModel import com.casic.common.detector.gd.model.TaskModel import com.casic.common.detector.gd.service.NtripConnectService import com.casic.common.detector.gd.utils.CurrentSegment -import com.casic.common.detector.gd.utils.DataBaseManager import com.casic.common.detector.gd.utils.ExcelKit import com.casic.common.detector.gd.utils.FileType import com.casic.common.detector.gd.utils.LocaleConstant @@ -62,9 +59,7 @@ import com.pengxh.kt.lite.extensions.isNetworkConnected import com.pengxh.kt.lite.extensions.navigatePageTo import com.pengxh.kt.lite.extensions.show -import com.pengxh.kt.lite.extensions.timestampToCompleteDate import com.pengxh.kt.lite.utils.FileDownloadManager -import com.pengxh.kt.lite.utils.LoadState import com.pengxh.kt.lite.utils.LoadingDialog import com.pengxh.kt.lite.utils.SaveKeyValues import com.pengxh.kt.lite.widget.TitleBarView @@ -86,6 +81,9 @@ private val samplePopupWindow by lazy { SamplePopupWindow(this) } private val detailDialog by lazy { MarkerDetailDialog(this) } private val locationKit by lazy { LocationKit(this) } + private val markerBeanDao by lazy { BaseApplication.get().dataBase.markerBeanDao() } + private val taskBeanDao by lazy { BaseApplication.get().dataBase.taskBeanDao() } + private val taskMarkerBeanDao by lazy { BaseApplication.get().dataBase.taskMarkerBeanDao() } private val taskViewModel by lazy { ViewModelProvider(this)[TaskViewModel::class.java] } private val attr = AudioAttributes.Builder().setUsage(AudioAttributes.USAGE_ALARM) .setContentType(AudioAttributes.CONTENT_TYPE_MUSIC).build() @@ -94,7 +92,7 @@ private var isFreeTask = false private var freeTaskTitle = "" private var ids = ArrayList() - private var freeTaskId: String? = null + private var freeTaskId = 0L private var soundResourceId = 0 private var isExecuteTask = false private lateinit var aMap: AMap @@ -111,89 +109,14 @@ //地图初始化 initMapConfig(savedInstanceState) - Intent(this, NtripConnectService::class.java).also { - startService(it) - } +// Intent(this, NtripConnectService::class.java).apply { +// startService(this) +// } soundResourceId = soundPool.load(this, R.raw.ring3, 1) //右上角菜单 samplePopupWindow.setPopupMenuItem(LocaleConstant.POPUP_TITLES) samplePopupWindow.setBackgroundDrawable(null) - - //task网络请求监听 - taskViewModel.markerFileResult.observe(this) { - if (it.isSuccess) { - //清空之前的数据 - DataBaseManager.get.clearMarkers() - //下载最新的数据 - val companyId = SaveKeyValues.getValue(LocaleConstant.USER_COMPANY_ID, "") - val downloadUrl = companyId.toString().appendDownloadUrl(FileType.Excel) - Log.d(kTag, "downloadUrl => $downloadUrl") - FileDownloadManager.Builder().setDownloadFileSource(downloadUrl) - .setFileSuffix("xls").setFileSaveDirectory(createDownloadFileDir()) - .setOnFileDownloadListener(object : FileDownloadManager.OnFileDownloadListener { - override fun onDownloadStart(total: Long) { - - } - - override fun onDownloadEnd(file: File) { - lifecycleScope.launch(Dispatchers.IO) { ExcelKit.read(file.absolutePath) } - LoadingDialog.dismiss() - showMarkersOnMap() - } - - override fun onDownloadFailed(t: Throwable) { - t.printStackTrace() - } - - override fun onProgressChanged(progress: Long) { - - } - }).build().start() - } - } - taskViewModel.taskResult.observe(this) { - if (it.success == "true") { - AlertMessageDialog.Builder().setContext(this).setTitle("温馨提示") - .setMessage("您有${it.message.size}个新任务!").setPositiveButton("知道了") - .setOnDialogButtonClickListener(object : - AlertMessageDialog.OnDialogButtonClickListener { - override fun onConfirmClick() { - saveUserTasks(it) - } - }).build().show() - } - } - taskViewModel.freeTaskResult.observe(this) { - freeTaskId = it - // 自由巡检保存在本地 - val bean = TaskLocalBean() - bean.id = freeTaskId.toString().toLong() - val currentTimeMillis = System.currentTimeMillis() - bean.taskCode = currentTimeMillis.createTaskCode() - bean.description = freeTaskTitle - val time = currentTimeMillis.timestampToCompleteDate() - bean.createTime = time - bean.status = "0" - val userName = SaveKeyValues.getValue(LocaleConstant.USER_NAME, "") as String - bean.createUserName = userName - bean.startTime = time - bean.endTime = "" - bean.isFreeTask = "1" - DataBaseManager.get.saveTaskInLocale(bean) - } - taskViewModel.uploadTaskMarkerResult.observe(this) { - "自由巡检任务已完成".show(this) - ids.clear() - //清空自由巡检添加的Marker - aMap.clear() - showMarkersOnMap() - } - taskViewModel.executeTaskResult.observe(this) { - "工单任务已完成".show(this) - aMap.clear() - showMarkersOnMap() - } } override fun initEvent() { @@ -216,7 +139,7 @@ }).build().show() } else { lifecycleScope.launch(Dispatchers.Main) { - val markers = DataBaseManager.get.queryMarkerByState("0") + val markers = taskMarkerBeanDao.queryMarkerByState("0") //如果有需要补全的标识器,Popup右侧会有小圆点提示 if (markers.isNotEmpty()) { samplePopupWindow.setShowPosition(4) @@ -239,13 +162,7 @@ 3 -> uploadEvent() 4 -> completionMarker() 5 -> showRtkConfigDialog() - 6 -> { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { - SatelliteStatusDialog(context).show() - } else { - "卫星数据仅支持Android 7.0以上系统".show(context) - } - } + 6 -> SatelliteStatusDialog(context).show() } } }) @@ -268,25 +185,23 @@ //查看 binding.viewButton.setOnClickListener { - QueryMarkerDialog.Builder().setContext(this).setTitle("查看标识器") - .setSpinnerArray(LocaleConstant.SPINNER_ARRAY).setNegativeButton("取消") + QueryMarkerDialog.Builder() + .setContext(this) + .setTitle("查看标识器") + .setSpinnerArray(LocaleConstant.SPINNER_ARRAY) + .setNegativeButton("取消") .setPositiveButton("确定").setOnDialogButtonClickListener(object : QueryMarkerDialog.OnDialogButtonClickListener { override fun onConfirmClick(selectedItem: String, value: String) { //查询数据库 - lifecycleScope.launch(Dispatchers.Main) { - val markers = DataBaseManager.get.loadMarkersByCondition( - selectedItem, value - ) as ArrayList - - if (markers.isEmpty()) { - "无法查到相关数据信息,请检查您的查询条件".show(context) - } else { + val buildQuery = LocaleConstant.buildQuery(selectedItem, value) + markerBeanDao.loadMarkersByCondition(buildQuery).run { + if (isNotEmpty()) { val latitudeList = ArrayList() val longitudeList = ArrayList() - val latitude = markers.first().lat - val longitude = markers.first().lng + val latitude = first().lat + val longitude = first().lng if (latitude.isNotBlank() && longitude.isNotBlank()) { if (CoordinateConverter.isAMapDataAvailable( latitude.toDouble(), longitude.toDouble() @@ -300,10 +215,11 @@ if (latitudeList.isNotEmpty() && longitudeList.isNotEmpty()) { //移动地图到所有labelBeans的第一个点 - val center = LatLng(latitudeList.first(), longitudeList.first()) - //移动到指定经纬度 - aMap.moveCamera(CameraUpdateFactory.newLatLngZoom(center, 16f)) + val target = LatLng(latitudeList.first(), longitudeList.first()) + aMap.moveCamera(CameraUpdateFactory.newLatLngZoom(target, 16f)) } + } else { + "无法查到相关信息,请检查您的查询条件".show(context) } } } @@ -316,32 +232,39 @@ //巡检 binding.inspectionButton.setOnClickListener { - val tasks = DataBaseManager.get.loadLocalTask() - if (tasks.isNotEmpty()) { - val arrayList = ArrayList() - tasks.forEachIndexed { index, task -> - arrayList.add("任务${index + 1}:${task.taskId},${task.description}") + lifecycleScope.launch { + val tasks = withContext(Dispatchers.IO) { + taskBeanDao.loadLocalTask(taskMarkerBeanDao) } + if (tasks.isNotEmpty()) { + val arrayList = ArrayList() + tasks.forEachIndexed { index, task -> + arrayList.add("任务${index + 1}:${task.taskId},${task.description}") + } - BottomActionSheet.Builder().setContext(this).setItemTextColor(Color.BLUE) - .setActionItemTitle(arrayList) - .setOnActionSheetListener(object : BottomActionSheet.OnActionSheetListener { - override fun onActionItemClick(position: Int) { - val task = tasks[position] - SaveKeyValues.putValue(LocaleConstant.TASK_ID, task.taskId) - SaveKeyValues.putValue(LocaleConstant.TASK_CODE, task.taskCode) - executeTask(task) - } - }).build().show() - } else { - AlertMessageDialog.Builder().setContext(this).setTitle("温馨提示") - .setMessage("所有任务已完成,请点击右上角菜单下载新工单或者开始自由巡检") - .setPositiveButton("开始自由巡检").setOnDialogButtonClickListener(object : - AlertMessageDialog.OnDialogButtonClickListener { - override fun onConfirmClick() { - executeFreeTask() - } - }).build().show() + BottomActionSheet.Builder().setContext(context) + .setItemTextColor(Color.BLUE) + .setActionItemTitle(arrayList) + .setOnActionSheetListener(object : BottomActionSheet.OnActionSheetListener { + override fun onActionItemClick(position: Int) { + val task = tasks[position] + SaveKeyValues.putValue(LocaleConstant.TASK_ID, task.taskId) + SaveKeyValues.putValue(LocaleConstant.TASK_CODE, task.taskCode) + executeTask(task) + } + }).build().show() + } else { + AlertMessageDialog.Builder() + .setContext(context) + .setTitle("温馨提示") + .setMessage("所有任务已完成,请点击右上角菜单下载新工单或者开始自由巡检") + .setPositiveButton("开始自由巡检").setOnDialogButtonClickListener(object : + AlertMessageDialog.OnDialogButtonClickListener { + override fun onConfirmClick() { + executeFreeTask() + } + }).build().show() + } } } @@ -371,8 +294,11 @@ //自由巡检 binding.stopFreeTaskButton.setOnLongClickListener { - AlertMessageDialog.Builder().setContext(this).setTitle("温馨提示") - .setMessage("是否确定结束此次自由巡检任务?").setPositiveButton("是") + AlertMessageDialog.Builder() + .setContext(this) + .setTitle("温馨提示") + .setMessage("是否确定结束此次自由巡检任务?") + .setPositiveButton("是") .setOnDialogButtonClickListener(object : AlertMessageDialog.OnDialogButtonClickListener { override fun onConfirmClick() { @@ -381,14 +307,38 @@ stopSerialPortCommand() binding.stopFreeTaskButton.visibility = View.GONE - if (freeTaskId.isNullOrBlank()) { + if (freeTaskId == 0L) { "任务ID异常,无法提交任务,请联系服务器管理员".show(context) return } - freeTaskId?.apply { - taskViewModel.uploadTaskMarker(context, this, ids) - } + taskViewModel.uploadTaskMarker( + freeTaskId, + ids, + onLoading = { + LoadingDialog.show(context, "任务提交中,请稍后...") + }, + onSuccess = { + LoadingDialog.dismiss() + "自由巡检任务已完成".show(context) + ids.clear() + aMap.clear() + showMarkersOnMap() + + //删除本地数据库 + val taskCode = SaveKeyValues.getValue( + LocaleConstant.TASK_CODE, "" + ) as String + taskBeanDao.deleteLocalTaskById( + freeTaskId, taskCode, taskMarkerBeanDao + ) + SaveKeyValues.putValue(LocaleConstant.TASK_ID, "") + }, + onFailed = { + LoadingDialog.dismiss() + it.show(context) + } + ) } }).build().show() true @@ -399,25 +349,52 @@ RtkConfigDialog(this).setOnDialogButtonClickListener(object : RtkConfigDialog.OnDialogButtonClickListener { override fun onConfirmClick() { - NtripConnectService.weakReferenceHandler?.apply { - sendEmptyMessage(2024082201) - } + NtripConnectService.weakReferenceHandler?.sendEmptyMessage(2024082201) } }).show() } private fun uploadTask(taskId: String, taskCode: String, state: String) { if (isNetworkConnected()) { - val userId = SaveKeyValues.getValue(LocaleConstant.USER_ID, "") as String - taskViewModel.uploadTask(this, userId, taskId, taskCode, state) + taskViewModel.uploadTask( + taskId, state, + onLoading = { + LoadingDialog.show(this, "工单提交中,请稍后...") + }, + onSuccess = { + LoadingDialog.dismiss() + //工单提交之后,并且状态是2,删除本地Task记录 + if (state == "2") { + "工单${taskId}已提交!".show(this) + //删除本地数据库 + taskBeanDao.deleteLocalTaskById( + taskId.toLong(), taskCode, taskMarkerBeanDao + ) + SaveKeyValues.putValue(LocaleConstant.TASK_ID, "") + } else { + Log.d(kTag, "uploadTask: 仅执行工单,不删除本地工单数据") + } + aMap.clear() + showMarkersOnMap() + "工单任务已完成".show(this) + }, + onFailed = { + LoadingDialog.dismiss() + it.show(this) + } + ) } else { "网络连接已断开,请检查".show(this) } } private fun executeTask(task: TaskDetailLocalModel) { - AlertControlDialog.Builder().setContext(this).setTitle("提示").setMessage("请选择操作方式") - .setPositiveButton("执行工单").setNegativeButton("提交工单") + AlertControlDialog.Builder() + .setContext(this) + .setTitle("提示") + .setMessage("请选择操作方式") + .setPositiveButton("执行工单") + .setNegativeButton("提交工单") .setOnDialogButtonClickListener(object : AlertControlDialog.OnDialogButtonClickListener { override fun onConfirmClick() { @@ -432,7 +409,7 @@ isExecuteTask = true } else { "此工单下无标识器,将执行自由巡检任务".show(context) - freeTaskId = task.taskId + freeTaskId = task.taskId.toLong() detectMarker() } } @@ -453,7 +430,18 @@ override fun onConfirmClick(value: String) { freeTaskTitle = value val userId = SaveKeyValues.getValue(LocaleConstant.USER_ID, "") as String - taskViewModel.createFreeTask(context, userId, value) + taskViewModel.createFreeTask( + userId, value, + onLoading = {}, + onSuccess = { + freeTaskId = it + // 自由巡检保存在本地 + taskBeanDao.saveTask(it, freeTaskTitle) + }, + onFailed = { + it.show(context) + } + ) detectMarker() } @@ -481,7 +469,7 @@ if (RuntimeCache.currentSegment == CurrentSegment.FreeInspection) { //显示标识器详细信息 if (!detailDialog.isShowing) { - DataBaseManager.get.queryMarkerById(markerId).firstOrNull().apply { + markerBeanDao.queryMarkerById(markerId).firstOrNull().apply { if (this == null) { "无法查询到此ID【${markerId}】的信息".show(context) } else { @@ -501,7 +489,7 @@ //不重复标注Marker if (!ids.contains(markerId)) { - val markers = DataBaseManager.get.queryMarkerById(markerId) + val markers = markerBeanDao.queryMarkerById(markerId) if (markers.isNotEmpty()) { val marker = markers.first() val latLng = LatLng(marker.lat.toDouble(), marker.lng.toDouble()) @@ -522,16 +510,6 @@ } - override fun observeRequestState() { - taskViewModel.loadState.observe(this) { - when (it) { - LoadState.Loading -> LoadingDialog.show(this, "提交工单中,请稍后") - - else -> LoadingDialog.dismiss() - } - } - } - private fun initMapConfig(savedInstanceState: Bundle?) { binding.mapView.onCreate(savedInstanceState) aMap = binding.mapView.map @@ -592,54 +570,25 @@ private fun saveUserTasks(task: TaskModel) { task.message.forEach { model -> //保存任务详情 - DataBaseManager.get.saveTaskInLocale(model) + taskBeanDao.saveTask(model) model.taskDetailInfos.forEach { marker -> //只保存有标识器ID得数据 if (!marker.markerIdReal.isNullOrBlank()) { - DataBaseManager.get.saveTaskMarkerInLocale(model.id, model.taskCode, marker) + taskMarkerBeanDao.saveTaskMarker(model.id, model.taskCode, marker) } } } "工单下载成功!".show(this) } - private fun showMarkersOnMap() { - lifecycleScope.launch(Dispatchers.IO) { - //取缓存 - val markers = DataBaseManager.get.loadMarkers() - if (markers.isEmpty()) { - return@launch - } - val first = markers.first() - val defaultLatLng = LatLng(first.lat.toDouble(), first.lng.toDouble()) - //移动到指定经纬度 - val cameraPosition = CameraPosition(defaultLatLng, 14f, 0f, 0f) - val cameraUpdate = CameraUpdateFactory.newCameraPosition(cameraPosition) - withContext(Dispatchers.Main) { - aMap.animateCamera(cameraUpdate, 1500, null) - LoadingDialog.dismiss() - } - - markers.forEach { marker -> - val latitude = marker.lat.toString().toDouble() - val longitude = marker.lng.toString().toDouble() - //将所有设备信息转化缓存为Marker点 - val options = MarkerOptions() - .position(LatLng(latitude, longitude)) - .title(marker.markerId) - aMap.addMarker(options) - } - } - } - override fun onMarkerClick(marker: Marker?): Boolean { - marker?.apply { - showNavigationOption(title, position) + marker?.let { + showNavigationOption(it.title, it.position) } return true } - override fun onMapLongClick(p0: LatLng?) { + override fun onMapLongClick(latLng: LatLng?) { showMarkersOnMap() } @@ -664,7 +613,7 @@ } override fun onCancelClick() { - val result = DataBaseManager.get.queryMarkerById(title) + val result = markerBeanDao.queryMarkerById(title) MarkerDetailDialog(context).setMarker(result.first()).show() } }).build().show() @@ -695,20 +644,24 @@ //更新标识器数据 private fun updateMarkers() { - AlertControlDialog.Builder().setContext(this).setTitle("提示").setMessage("是否更新数据?") - .setNegativeButton("取消").setPositiveButton("确定") + AlertControlDialog.Builder() + .setContext(this) + .setTitle("提示") + .setMessage("是否更新数据?") + .setNegativeButton("取消") + .setPositiveButton("确定") .setOnDialogButtonClickListener(object : AlertControlDialog.OnDialogButtonClickListener { override fun onConfirmClick() { if (isNetworkConnected()) { - val companyId = SaveKeyValues.getValue(LocaleConstant.USER_COMPANY_ID, "") - - LoadingDialog.show(this@MainActivity, "获取标识器信息中,请稍后") - /** - * 后台设计如此,都传companyId - * */ + //清空之前的数据 + markerBeanDao.deleteAll() + aMap.clear() + //获取标识器数据 taskViewModel.getMarkerFile( - context, companyId.toString(), companyId.toString() + onLoading = {}, + onSuccess = { handleMarkerFile(it) }, + onFailed = { it.show(context) } ) } else { "网络连接已断开,请检查".show(context) @@ -721,11 +674,105 @@ }).build().show() } + private fun handleMarkerFile(it: MarkerFileModel) { + if (it.isSuccess) { + //下载最新的数据 + val companyId = SaveKeyValues.getValue(LocaleConstant.USER_COMPANY_ID, "") + val downloadUrl = companyId.toString().appendDownloadUrl(FileType.Excel) + Log.d(kTag, "handleMarkerFile => $downloadUrl") + FileDownloadManager.Builder() + .setDownloadFileSource(downloadUrl) + .setFileSuffix("xls") + .setFileSaveDirectory(createDownloadFileDir()) + .setOnFileDownloadListener(object : FileDownloadManager.OnFileDownloadListener { + override fun onDownloadStart(total: Long) { + LoadingDialog.show(context, "标识器数据解析中,请稍后...") + } + + override fun onDownloadEnd(file: File) { + lifecycleScope.launch(Dispatchers.IO) { + ExcelKit.read(file.absolutePath).apply { + renderMarkers(this) + }.also { + withContext(Dispatchers.Main) { + LoadingDialog.dismiss() + "标识器数据渲染完成".show(context) + } + } + } + } + + override fun onDownloadFailed(t: Throwable) { + t.printStackTrace() + LoadingDialog.dismiss() + "标识器数据下载失败".show(context) + } + + override fun onProgressChanged(progress: Long) { + + } + }).build().start() + } + } + + private fun showMarkersOnMap() { + lifecycleScope.launch(Dispatchers.IO) { + //取缓存 + markerBeanDao.loadAll().run { + renderMarkers(this) + }.also { + withContext(Dispatchers.Main) { + "标识器数据渲染完成".show(context) + } + } + } + } + + private fun renderMarkers(markers: List) { + if (markers.isEmpty()) { + return + } + val first = markers.first() + val defaultLatLng = LatLng(first.lat.toDouble(), first.lng.toDouble()) + //移动到指定经纬度 + val cameraPosition = CameraPosition(defaultLatLng, 14f, 0f, 0f) + val cameraUpdate = CameraUpdateFactory.newCameraPosition(cameraPosition) + aMap.animateCamera(cameraUpdate, 1500, null) + markers.forEach { marker -> + val latitude = marker.lat.toString().toDouble() + val longitude = marker.lng.toString().toDouble() + //将所有设备信息转化缓存为Marker点 + val options = MarkerOptions() + .position(LatLng(latitude, longitude)) + .title(marker.markerId) + aMap.addMarker(options) + } + } + //下载工单 private fun downloadTask() { if (isNetworkConnected()) { - val userName = SaveKeyValues.getValue(LocaleConstant.USER_NAME, "") - taskViewModel.getTasksByUser(this, userName.toString()) + taskViewModel.getTasksByUser( + onLoading = {}, + onSuccess = { + if (it.success == "true") { + AlertMessageDialog.Builder() + .setContext(this) + .setTitle("温馨提示") + .setMessage("您有${it.message.size}个新任务!") + .setPositiveButton("知道了") + .setOnDialogButtonClickListener(object : + AlertMessageDialog.OnDialogButtonClickListener { + override fun onConfirmClick() { + saveUserTasks(it) + } + }).build().show() + } + }, + onFailed = { + it.show(this) + } + ) } else { "网络连接已断开,请检查".show(this) } @@ -744,7 +791,7 @@ //标识器补全 private fun completionMarker() { val companyId = SaveKeyValues.getValue(LocaleConstant.USER_COMPANY_ID, "") as String - val markers = DataBaseManager.get.queryMarkerByState("0") + val markers = taskMarkerBeanDao.queryMarkerByState("0") if (markers.isNotEmpty()) { //TODO 逻辑没梳理明白 } else { diff --git a/app/src/main/java/com/casic/common/detector/gd/view/SearchMarkerActivity.kt b/app/src/main/java/com/casic/common/detector/gd/view/SearchMarkerActivity.kt index 4a92c97..b2e3301 100644 --- a/app/src/main/java/com/casic/common/detector/gd/view/SearchMarkerActivity.kt +++ b/app/src/main/java/com/casic/common/detector/gd/view/SearchMarkerActivity.kt @@ -1,6 +1,5 @@ package com.casic.common.detector.gd.view -import android.content.Context import android.content.res.ColorStateList import android.graphics.Color import android.hardware.Sensor @@ -13,18 +12,19 @@ import android.os.Handler import android.os.Looper import android.view.View +import androidx.core.graphics.toColorInt import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.lifecycleScope import com.amap.api.location.AMapLocation import com.amap.api.maps.AMapUtils import com.amap.api.maps.model.LatLng import com.casic.common.detector.gd.R +import com.casic.common.detector.gd.base.BaseApplication import com.casic.common.detector.gd.base.SerialPortBaseActivity import com.casic.common.detector.gd.callback.OnGetLocationListener import com.casic.common.detector.gd.databinding.ActivitySearchMarkerBinding import com.casic.common.detector.gd.model.MarkerDistanceData import com.casic.common.detector.gd.utils.CurrentSegment -import com.casic.common.detector.gd.utils.DataBaseManager import com.casic.common.detector.gd.utils.LocaleConstant import com.casic.common.detector.gd.utils.LocationKit import com.casic.common.detector.gd.utils.RuntimeCache @@ -50,8 +50,10 @@ private val context = this private val locationKit by lazy { LocationKit(this) } private val markerPoints by lazy { ArrayList() } + private val markerBeanDao by lazy { BaseApplication.get().dataBase.markerBeanDao() } + private val taskMarkerBeanDao by lazy { BaseApplication.get().dataBase.taskMarkerBeanDao() } private val taskViewModel by lazy { ViewModelProvider(this)[TaskViewModel::class.java] } - private val sensorManager by lazy { getSystemService(Context.SENSOR_SERVICE) as SensorManager } + private val sensorManager by lazy { getSystemService(SENSOR_SERVICE) as SensorManager } private val attr = AudioAttributes.Builder().setUsage(AudioAttributes.USAGE_ALARM) .setContentType(AudioAttributes.CONTENT_TYPE_MUSIC).build() private val soundPool = SoundPool.Builder().setMaxStreams(16).setAudioAttributes(attr).build() @@ -109,7 +111,7 @@ override fun initEvent() { binding.depthButton.setOnClickListener { RuntimeCache.currentSegment = CurrentSegment.DetectDepth - val result = DataBaseManager.get.queryMarkerById(markerId) + val result = markerBeanDao.queryMarkerById(markerId) if (result.isNotEmpty()) { val command = when (result.first().markerType) { "EM30" -> SerialPortCommand.DETECT_EM30_DEPTH @@ -139,7 +141,7 @@ } binding.markerInfoButton.setOnClickListener { - val result = DataBaseManager.get.queryMarkerById(markerId) + val result = markerBeanDao.queryMarkerById(markerId) if (result.isNotEmpty()) { MarkerDetailDialog(this).setMarker(result.first()).show() } else { @@ -154,12 +156,12 @@ binding.depthButton.isEnabled = true binding.depthButton.setTextColor(Color.WHITE) binding.depthButton.backgroundTintList = - ColorStateList.valueOf(Color.parseColor("#004364")) + ColorStateList.valueOf("#004364".toColorInt()) binding.markerInfoButton.isEnabled = true binding.markerInfoButton.setTextColor(Color.WHITE) binding.markerInfoButton.backgroundTintList = - ColorStateList.valueOf(Color.parseColor("#FFA200")) + ColorStateList.valueOf("#FFA200".toColorInt()) handleMarker(markerId) } @@ -171,12 +173,22 @@ if (isExecuteTask) { val taskId = SaveKeyValues.getValue(LocaleConstant.TASK_ID, "") as String val taskCode = SaveKeyValues.getValue(LocaleConstant.TASK_CODE, "") as String - val taskMarkerLocalBean = DataBaseManager.get.queryTaskMarkerById( + val marker = taskMarkerBeanDao.queryTaskMarkerById( taskId, taskCode, id, "0" ) - taskMarkerLocalBean?.apply { - taskViewModel.uploadMarker(context, this) + if (marker == null) { + return } + taskViewModel.uploadMarker( + marker.markerId, + onLoading = {}, + onSuccess = { + "标识器${marker.markerId}已探测!".show(this) + marker.isDetected = "1" + taskMarkerBeanDao.updateLocalTaskMarkerState(marker) + }, + onFailed = {} + ) } } @@ -185,15 +197,22 @@ detectDepthRunnable?.let { handler.removeCallbacks(it) } detectDepthRunnable = null LoadingDialog.dismiss() - AlertMessageDialog.Builder().setContext(context).setTitle("温馨提示") - .setMessage("标识器埋深:${depth}厘米").setPositiveButton("知道了") - .setOnDialogButtonClickListener(object : - AlertMessageDialog.OnDialogButtonClickListener { - override fun onConfirmClick() { - RuntimeCache.currentSegment = CurrentSegment.SearchMarker - sendSerialPortCommand(SerialPortCommand.SEARCH_SIGNAL) - } - }).build().show() + if (!this.isDestroyed) { + AlertMessageDialog.Builder() + .setContext(context) + .setTitle("温馨提示") + .setMessage("标识器埋深:${depth}厘米") + .setPositiveButton("知道了") + .setOnDialogButtonClickListener(object : + AlertMessageDialog.OnDialogButtonClickListener { + override fun onConfirmClick() { + RuntimeCache.currentSegment = CurrentSegment.SearchMarker + sendSerialPortCommand(SerialPortCommand.SEARCH_SIGNAL) + } + }).build().show() + } else { + "标识器埋深:${depth}厘米".show(this) + } } } @@ -201,13 +220,13 @@ if (RuntimeCache.currentSegment == CurrentSegment.SearchMarker) { if (signalEnergy > 1000) { binding.markerIdButton.isEnabled = true - binding.markerIdButton.setTextColor(Color.parseColor("#428d00")) + binding.markerIdButton.setTextColor("#428d00".toColorInt()) binding.markerIdButton.backgroundTintList = ColorStateList.valueOf( - Color.parseColor("#7EFF00") + "#7EFF00".toColorInt() ) binding.searchResultView.text = "已检测到标识器" - binding.searchResultView.setTextColor(Color.parseColor("#428d00")) + binding.searchResultView.setTextColor("#428d00".toColorInt()) binding.searchResultView.setBackgroundResource(R.mipmap.bg_small_text_green) } @@ -230,19 +249,19 @@ signalEnergy <= 700 -> { setEnergyTip( "信号较弱,可能距离较远", - Color.parseColor("#8D1717"), + "#8D1717".toColorInt(), R.mipmap.bg_large_text_red ) disableButtons() binding.searchResultView.text = "未检测到标识器" - binding.searchResultView.setTextColor(Color.parseColor("#8D1717")) + binding.searchResultView.setTextColor("#8D1717".toColorInt()) binding.searchResultView.setBackgroundResource(R.mipmap.bg_small_text_red) } signalEnergy >= 4100 -> { setEnergyTip( "信号极强,接近标识器正上方", - Color.parseColor("#428d00"), + "#428d00".toColorInt(), R.mipmap.bg_large_text_green ) } @@ -250,7 +269,7 @@ else -> { setEnergyTip( "已靠近,请继续移动位置", - Color.parseColor("#8C5700"), + "#8C5700".toColorInt(), R.mipmap.bg_large_text_yellow ) } @@ -263,8 +282,8 @@ binding.energyTipsView.setBackgroundResource(backgroundRes) } - private val colorStateList = ColorStateList.valueOf(Color.parseColor("#8A8A8A")) - private val textColor = Color.parseColor("#CCCCCC") + private val colorStateList = ColorStateList.valueOf("#8A8A8A".toColorInt()) + private val textColor = "#CCCCCC".toColorInt() private fun disableButtons() { binding.depthButton.isEnabled = false @@ -287,7 +306,7 @@ val latitude = location.latitude lifecycleScope.launch(Dispatchers.IO) { val dataPoints = ArrayList() - DataBaseManager.get.loadMarkers().forEach { + markerBeanDao.loadAll().forEach { val distance = AMapUtils.calculateLineDistance( LatLng(it.lat.toDouble(), it.lng.toDouble()), LatLng(latitude, longitude) ) @@ -332,10 +351,6 @@ return ActivitySearchMarkerBinding.inflate(layoutInflater) } - override fun observeRequestState() { - - } - override fun setupTopBarLayout() { } diff --git a/app/src/main/java/com/casic/common/detector/gd/view/SearchMarkerAuditActivity.kt b/app/src/main/java/com/casic/common/detector/gd/view/SearchMarkerAuditActivity.kt index 1dc59a7..dd4cc84 100644 --- a/app/src/main/java/com/casic/common/detector/gd/view/SearchMarkerAuditActivity.kt +++ b/app/src/main/java/com/casic/common/detector/gd/view/SearchMarkerAuditActivity.kt @@ -1,6 +1,5 @@ package com.casic.common.detector.gd.view -import android.content.Context import android.hardware.Sensor import android.hardware.SensorEvent import android.hardware.SensorEventListener @@ -13,9 +12,9 @@ import com.amap.api.maps.AMapUtils import com.amap.api.maps.model.LatLng import com.casic.common.detector.gd.R +import com.casic.common.detector.gd.base.BaseApplication import com.casic.common.detector.gd.callback.OnGetLocationListener import com.casic.common.detector.gd.databinding.ActivitySearchMarkerAuditBinding -import com.casic.common.detector.gd.utils.DataBaseManager import com.casic.common.detector.gd.utils.LocaleConstant import com.casic.common.detector.gd.utils.LocationKit import com.casic.common.detector.gd.widgets.MarkerDetailDialog @@ -36,7 +35,8 @@ private val kTag = "SearchMarkerActivity" private val context = this private val locationKit by lazy { LocationKit(this) } - private val sensorManager by lazy { getSystemService(Context.SENSOR_SERVICE) as SensorManager } + private val sensorManager by lazy { getSystemService(SENSOR_SERVICE) as SensorManager } + private val markerBeanDao by lazy { BaseApplication.get().dataBase.markerBeanDao() } private val attr = AudioAttributes.Builder().setUsage(AudioAttributes.USAGE_ALARM) .setContentType(AudioAttributes.CONTENT_TYPE_MUSIC).build() private val soundPool = SoundPool.Builder().setMaxStreams(16).setAudioAttributes(attr).build() @@ -72,7 +72,7 @@ override fun initEvent() { binding.markerInfoButton.setOnClickListener { //查库 - val result = DataBaseManager.get.queryMarkerById(nearestMarkerId) + val result = markerBeanDao.queryMarkerById(nearestMarkerId) if (result.isNotEmpty()) { MarkerDetailDialog(this).setMarker(result.first()).show() } else { @@ -90,7 +90,7 @@ val latitude = location.latitude lifecycleScope.launch(Dispatchers.IO) { val dataPoints = ArrayList() - DataBaseManager.get.loadMarkers().forEach { + markerBeanDao.loadAll().forEach { val distance = AMapUtils.calculateLineDistance( LatLng(it.lat.toDouble(), it.lng.toDouble()), LatLng(latitude, longitude) ) @@ -105,7 +105,8 @@ ) } withContext(Dispatchers.Main) { - binding.radarScanView.renderPointData(dataPoints, + binding.radarScanView.renderPointData( + dataPoints, object : RadarScanView.OnGetNearestPointCallback { override fun getNearestPoint(point: RadarScanView.DataPoint?) { if (point == null) { diff --git a/app/src/main/java/com/casic/common/detector/gd/vm/TaskViewModel.kt b/app/src/main/java/com/casic/common/detector/gd/vm/TaskViewModel.kt index ee0d63a..665d95c 100644 --- a/app/src/main/java/com/casic/common/detector/gd/vm/TaskViewModel.kt +++ b/app/src/main/java/com/casic/common/detector/gd/vm/TaskViewModel.kt @@ -1,95 +1,87 @@ package com.casic.common.detector.gd.vm -import android.content.Context -import android.util.Log -import androidx.lifecycle.MutableLiveData -import com.casic.common.detector.gd.bean.TaskMarkerLocalBean import com.casic.common.detector.gd.extensions.getResponseMessage import com.casic.common.detector.gd.extensions.getResponseState import com.casic.common.detector.gd.model.MarkerFileModel import com.casic.common.detector.gd.model.TaskModel import com.casic.common.detector.gd.retrofit.RetrofitServiceManager -import com.casic.common.detector.gd.utils.DataBaseManager -import com.casic.common.detector.gd.utils.LocaleConstant -import com.google.gson.Gson import com.google.gson.JsonParser -import com.google.gson.reflect.TypeToken import com.pengxh.kt.lite.base.BaseViewModel import com.pengxh.kt.lite.extensions.launch -import com.pengxh.kt.lite.extensions.show -import com.pengxh.kt.lite.utils.LoadState -import com.pengxh.kt.lite.utils.SaveKeyValues +import com.pengxh.kt.lite.extensions.unpackingResponse class TaskViewModel : BaseViewModel() { - - private val kTag = "TaskViewModel" - private val gson by lazy { Gson() } - val markerFileResult = MutableLiveData() - val taskResult = MutableLiveData() - val freeTaskResult = MutableLiveData() - val uploadTaskMarkerResult = MutableLiveData() - val executeTaskResult = MutableLiveData() - - fun createFreeTask(context: Context, patrollerId: String, description: String) = launch({ + fun createFreeTask( + patrollerId: String, + description: String, + onLoading: () -> Unit, + onSuccess: (Long) -> Unit, + onFailed: (String) -> Unit + ) = launch({ + onLoading() val response = RetrofitServiceManager.createFreeTask(patrollerId, description) if (response.getResponseState()) { val element = JsonParser.parseString(response) val jsonObject = element.asJsonObject - freeTaskResult.value = jsonObject.get("taskId").asInt.toString() + onSuccess(jsonObject.get("taskId").asLong) } else { - response.getResponseMessage().show(context) + onFailed(response.getResponseMessage()) } }, { - it.printStackTrace() + onFailed(it.message ?: "Unknown error") }) - fun uploadTaskMarker(context: Context, taskId: String, ids: ArrayList) = launch({ + fun uploadTaskMarker( + taskId: Long, + ids: ArrayList, + onLoading: () -> Unit, + onSuccess: () -> Unit, + onFailed: (String) -> Unit + ) = launch({ + onLoading() val response = RetrofitServiceManager.uploadTaskMarker(taskId, ids) if (response.getResponseState()) { - val element = JsonParser.parseString(response) - val jsonObject = element.asJsonObject - uploadTaskMarkerResult.value = jsonObject.get("success").asString - - //删除本地数据库 - val taskCode = SaveKeyValues.getValue(LocaleConstant.TASK_CODE, "") as String - DataBaseManager.get.deleteLocalTaskById(taskId, taskCode) - SaveKeyValues.putValue(LocaleConstant.TASK_ID, "") + onSuccess() } else { - response.getResponseMessage().show(context) + onFailed(response.getResponseMessage()) } }, { - it.printStackTrace() + onFailed(it.message ?: "Unknown error") }) - fun getMarkerFile(context: Context, userId: String, companyId: String) = launch({ - val response = RetrofitServiceManager.getMarkerFile(userId, companyId) + fun getMarkerFile( + onLoading: () -> Unit, + onSuccess: (MarkerFileModel) -> Unit, + onFailed: (String) -> Unit + ) = launch({ + onLoading() + val response = RetrofitServiceManager.getMarkerFile() if (response.getResponseState()) { - markerFileResult.value = gson.fromJson( - response, object : TypeToken() {}.type - ) + onSuccess(unpackingResponse(response)) } else { - response.getResponseMessage().show(context) + onFailed(response.getResponseMessage()) } }, { - it.printStackTrace() + onFailed(it.message ?: "Unknown error") }) - fun getTasksByUser(context: Context, userName: String) = launch({ - val response = RetrofitServiceManager.getTasksByUser(userName) + fun getTasksByUser( + onLoading: () -> Unit, + onSuccess: (TaskModel) -> Unit, + onFailed: (String) -> Unit + ) = launch({ + onLoading() + val response = RetrofitServiceManager.getTasksByUser() if (response.getResponseState()) { - taskResult.value = gson.fromJson( - response, object : TypeToken() {}.type - ) + onSuccess(unpackingResponse(response)) } else { - response.getResponseMessage().show(context) + onFailed(response.getResponseMessage()) } }, { - it.printStackTrace() + onFailed(it.message ?: "Unknown error") }) - fun installLabel( - context: Context, - companyId: String, + fun installMarker( recordType: String, markerObjectType: String, pipeMaterial: String, @@ -105,7 +97,6 @@ road: String, constructTime: String, ownerComp: String, - markerObjectId: String, markerId: String, markerType: String, markerDepth: String, @@ -115,11 +106,13 @@ latitude: String, colorType: String, memo: String, - realPaths: ArrayList + realPaths: ArrayList, + onLoading: () -> Unit, + onSuccess: () -> Unit, + onFailed: (String) -> Unit ) = launch({ - loadState.value = LoadState.Loading - val response = RetrofitServiceManager.installLabel( - companyId, + onLoading() + val response = RetrofitServiceManager.installMarker( recordType, markerObjectType, pipeMaterial, @@ -135,7 +128,6 @@ road, constructTime, ownerComp, - markerObjectId, markerId, markerType, markerDepth, @@ -148,67 +140,65 @@ realPaths ) if (response.getResponseState()) { - loadState.value = LoadState.Success + onSuccess() } else { - loadState.value = LoadState.Fail - response.getResponseMessage().show(context) + onFailed(response.getResponseMessage()) } }, { - it.printStackTrace() - loadState.value = LoadState.Fail + onFailed(it.message ?: "Unknown error") }) fun uploadTask( - context: Context, userId: String, taskId: String, taskCode: String, state: String + taskId: String, + state: String, + onLoading: () -> Unit, + onSuccess: () -> Unit, + onFailed: (String) -> Unit ) = launch({ - loadState.value = LoadState.Loading - val response = RetrofitServiceManager.uploadTask(userId, taskId, state) + onLoading() + val response = RetrofitServiceManager.uploadTask(taskId, state) if (response.getResponseState()) { - loadState.value = LoadState.Success - //工单提交之后,并且状态是2,删除本地Task记录 - if (state == "2") { - "工单${taskId}已提交!".show(context) - //删除本地数据库 - DataBaseManager.get.deleteLocalTaskById(taskId, taskCode) - SaveKeyValues.putValue(LocaleConstant.TASK_ID, "") - - val element = JsonParser.parseString(response) - val jsonObject = element.asJsonObject - executeTaskResult.value = jsonObject.get("success").asString - } else { - Log.d(kTag, "uploadTask: 仅执行工单,不删除本地工单数据") - } + onSuccess() } else { - loadState.value = LoadState.Fail - response.getResponseMessage().show(context) + onFailed(response.getResponseMessage()) } }, { - it.printStackTrace() - loadState.value = LoadState.Fail + onFailed(it.message ?: "Unknown error") }) fun uploadEvent( - context: Context, taskId: String, event: String, realPaths: ArrayList + taskId: String, + event: String, + realPaths: ArrayList, + onLoading: () -> Unit, + onSuccess: () -> Unit, + onFailed: (String) -> Unit ) = launch({ - loadState.value = LoadState.Loading + onLoading() val response = RetrofitServiceManager.uploadEvent(taskId, event, realPaths) if (response.getResponseState()) { - loadState.value = LoadState.Success + onSuccess() } else { - loadState.value = LoadState.Fail - response.getResponseMessage().show(context) + onFailed(response.getResponseMessage()) } }, { - it.printStackTrace() - loadState.value = LoadState.Fail + onFailed(it.message ?: "Unknown error") }) - fun uploadMarker(context: Context, marker: TaskMarkerLocalBean) = launch({ - //主键ID代替MarkerId - RetrofitServiceManager.uploadMarker(marker.id.toString()) - "标识器${marker.markerId}已探测!".show(context) - DataBaseManager.get.updateLocalTaskMarkerState(marker) + fun uploadMarker( + markerId: String, + onLoading: () -> Unit, + onSuccess: () -> Unit, + onFailed: (String) -> Unit + ) = launch({ + onLoading() + val response = RetrofitServiceManager.uploadMarker(markerId) + if (response.getResponseState()) { + onSuccess() + } else { + onFailed(response.getResponseMessage()) + } }, { - it.printStackTrace() + onFailed(it.message ?: "Unknown error") }) } \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index d0cb423..921c8c8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,25 +1,20 @@ import java.text.SimpleDateFormat -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply plugin: 'org.greenrobot.greendao' +plugins { + id('com.android.application') + id('org.jetbrains.kotlin.android') +} android { - compileSdkVersion 33 + namespace 'com.casic.common.detector.gd' + compileSdk 35 defaultConfig { - applicationId "com.casic.common.detector.gd" - minSdkVersion 26 - targetSdkVersion 33 + applicationId 'com.casic.common.detector.gd' + minSdk 26 + targetSdk 35 versionCode 5092 - versionName "5.0.9.2" - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } + versionName '5.0.9.2' } signingConfigs { @@ -31,6 +26,14 @@ } } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + signingConfig signingConfigs.release + } + } + compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 @@ -47,27 +50,16 @@ } } - kotlin { - experimental { - coroutines 'enable' - } - } - buildFeatures { + buildConfig true viewBinding true } - applicationVariants.configureEach { variant -> - variant.outputs.configureEach { - outputFileName = "COM_TCY_" + getBuildDate() + "_" + defaultConfig.versionName + ".apk" + applicationVariants.configureEach { + outputs.configureEach { + outputFileName = 'COM_TCY_' + getBuildDate() + '_' + defaultConfig.versionName + '.apk' } } - - greendao { - schemaVersion 1//数据库版本号 - targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 - daoPackage "${defaultConfig.applicationId}.greendao"//设置DaoMaster、DaoSession、Dao包名 - } } static def getBuildDate() { @@ -76,27 +68,22 @@ } dependencies { - //基础依赖库 - implementation 'com.github.AndroidCoderPeng:Kotlin-lite-lib:1.1.4' - implementation 'androidx.core:core-ktx:1.9.0' - def base_version = "1.6.1" - implementation "androidx.appcompat:appcompat:${base_version}" - implementation "com.google.android.material:material:${base_version}" + implementation 'com.github.AndroidCoderPeng:Kotlin-lite-lib:1.1.5' + implementation 'androidx.core:core-ktx:1.13.1' + implementation 'androidx.appcompat:appcompat:1.7.0' + implementation 'com.google.android.material:material:1.12.0' //Google官方授权框架 implementation 'pub.devrel:easypermissions:3.0.0' - //沉浸式状态栏。基础依赖包,必须要依赖 - implementation 'com.gyf.immersionbar:immersionbar:3.0.0' - //fragment快速实现 - implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0' + //沉浸式状态栏 + implementation 'com.geyifeng.immersionbar:immersionbar:3.2.2' //官方Json解析库 implementation 'com.google.code.gson:gson:2.10.1' - def vm_version = '2.5.1' //Kotlin协程 - implementation "androidx.lifecycle:lifecycle-runtime-ktx:${vm_version}" + implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.2' //MVVM+LiveData - implementation "androidx.lifecycle:lifecycle-livedata-ktx:${vm_version}" - implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:${vm_version}" - implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.6.2' + implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2' + implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' //返回值转换器 implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' @@ -105,9 +92,10 @@ implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' //网络请求和接口封装 implementation 'com.squareup.retrofit2:retrofit:2.9.0' - implementation 'com.squareup.okhttp3:okhttp:4.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.12.0' //数据库框架 - implementation 'org.greenrobot:greendao:3.3.0' + implementation 'androidx.room:room-runtime:2.6.1' + annotationProcessor 'androidx.room:room-compiler:2.5.2' //高德导航、定位、地图三合一 implementation 'com.amap.api:navi-3dmap:latest.integration' //经纬度逆编码 @@ -115,7 +103,7 @@ //excel implementation 'net.sourceforge.jexcelapi:jxl:2.6.12' //图片加载框架 - implementation 'com.github.bumptech.glide:glide:4.9.0' + implementation 'com.github.bumptech.glide:glide:4.12.0' //图片选择框架 implementation 'io.github.lucksiege:pictureselector:v3.11.1' //大图 diff --git a/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt b/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt index 7b695ff..50ba734 100644 --- a/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt +++ b/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt @@ -4,9 +4,9 @@ import android.app.Application import android.os.Bundle import android.util.Log -import com.casic.common.detector.gd.greendao.DaoMaster -import com.casic.common.detector.gd.greendao.DaoSession +import androidx.room.Room.databaseBuilder import com.casic.common.detector.gd.uart.SerialPort +import com.casic.common.detector.gd.utils.DetectorDataBase import com.casic.common.detector.gd.utils.GpioManager import com.pengxh.kt.lite.extensions.show import com.pengxh.kt.lite.utils.SaveKeyValues @@ -43,44 +43,42 @@ private var application: BaseApplication by Delegates.notNull() fun get() = application - - private lateinit var daoSession: DaoSession } + lateinit var dataBase: DetectorDataBase + override fun onCreate() { super.onCreate() application = this SaveKeyValues.initSharedPreferences(this) CrashReport.initCrashReport(this, "01e80d3a74", true) - val devOpenHelper = DaoMaster.DevOpenHelper(this, "Detector.db", null) - val daoMaster = DaoMaster(devOpenHelper.writableDatabase) - daoSession = daoMaster.newSession() + dataBase = databaseBuilder(this, DetectorDataBase::class.java, "Detector.db") + .allowMainThreadQueries() + .build() /** * Open the serial port * */ try { serialPorts.apply { - add(SerialPort(File("/dev/ttysWK1"), 9600, 0)) - //千寻报文数据下发串口号 - add(SerialPort(File("/dev/ttyS1"), 9600, 0)) + add(SerialPort(File("/dev/ttysWK1"), 9600, 0)) //信号通讯串口 + add(SerialPort(File("/dev/ttyS1"), 9600, 0)) //千寻报文数据下发串口号 } Log.d(kTag, "onCreate: 已初始化 ${serialPorts.size} 个串口") } catch (e: SecurityException) { "您没有串口的读写权限!".show(this) + e.printStackTrace() } catch (e: IOException) { "因为不明原因,串口无法打开!".show(this) + e.printStackTrace() } catch (e: InvalidParameterException) { "请检查串口!".show(this) + e.printStackTrace() } registerActivityLifecycleCallbacks(this) } - fun getDaoSession(): DaoSession { - return daoSession - } - override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) { } diff --git a/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt b/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt index 053b9dd..1d0c9e3 100644 --- a/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt +++ b/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt @@ -14,12 +14,10 @@ import com.casic.common.detector.gd.utils.SerialPortCommand import com.pengxh.kt.lite.utils.WeakReferenceHandler import java.io.IOException -import java.util.Timer abstract class SerialPortBaseActivity : AppCompatActivity(), Handler.Callback { private val kTag = "SerialPortBaseActivity" - private val taskTimer by lazy { Timer() } private val weakReferenceHandler by lazy { WeakReferenceHandler(this) } private val serialPorts by lazy { BaseApplication.get().getSerialPorts() } protected lateinit var binding: VB @@ -30,7 +28,6 @@ setContentView(binding.root) setupTopBarLayout() initOnCreate(savedInstanceState) - observeRequestState() initEvent() if (serialPorts.isNotEmpty()) { @@ -71,11 +68,6 @@ abstract fun initOnCreate(savedInstanceState: Bundle?) /** - * 数据请求状态监听 - */ - abstract fun observeRequestState() - - /** * 初始化业务逻辑 */ abstract fun initEvent() diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java new file mode 100644 index 0000000..7a18c20 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java @@ -0,0 +1,255 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 从平台下载的标识器本地库实体类 + */ +@Entity(tableName = "marker_detail") +public class MarkerBean { + @PrimaryKey(autoGenerate = true) + private long id; //主键ID + private String pipelineType; // 管线类型 + private String pipelineDiameter; // 管线直径 + private String pipelineMaterial; // 管材 + private String buryMethod; // 埋设方式 + private String buryDepth; // 埋深 + private String area; // 所属区域 + private String line; // 所属线路 + private String road; // 所属道路 + private String constructTime; // 建设年代 + private String owner; // 权属单位 + private String objectId; // 标识对象ID,无实际用途 + private String markerId; // 标识器ID + private String markerType; // 标识器类型 + private String markerDepth; // 标识器埋深 + private String installationDept; // 安装部门 + private String lng; // 经度 + private String lat; // 纬度 + private String updateTime; // 最后修改时间,更新时间 + private String remark; // 备注信息 + private String underlyingPipelineType; // 下层管线类型 + private String underlyingPipelineDepth; // 下层埋深 + private String underlyingPipelineDiameter; // 下层管径 + private String underlyingPipelineMaterial; // 下层管材 + private String objectType; //标识对象类型 + private String color; // 颜色 + private String imagePath; // 图片路径 + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getPipelineType() { + return pipelineType; + } + + public void setPipelineType(String pipelineType) { + this.pipelineType = pipelineType; + } + + public String getPipelineDiameter() { + return pipelineDiameter; + } + + public void setPipelineDiameter(String pipelineDiameter) { + this.pipelineDiameter = pipelineDiameter; + } + + public String getPipelineMaterial() { + return pipelineMaterial; + } + + public void setPipelineMaterial(String pipelineMaterial) { + this.pipelineMaterial = pipelineMaterial; + } + + public String getBuryMethod() { + return buryMethod; + } + + public void setBuryMethod(String buryMethod) { + this.buryMethod = buryMethod; + } + + public String getBuryDepth() { + return buryDepth; + } + + public void setBuryDepth(String buryDepth) { + this.buryDepth = buryDepth; + } + + public String getArea() { + return area; + } + + public void setArea(String area) { + this.area = area; + } + + public String getLine() { + return line; + } + + public void setLine(String line) { + this.line = line; + } + + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + + public String getConstructTime() { + return constructTime; + } + + public void setConstructTime(String constructTime) { + this.constructTime = constructTime; + } + + public String getOwner() { + return owner; + } + + public void setOwner(String owner) { + this.owner = owner; + } + + public String getObjectId() { + return objectId; + } + + public void setObjectId(String objectId) { + this.objectId = objectId; + } + + public String getMarkerId() { + return markerId; + } + + public void setMarkerId(String markerId) { + this.markerId = markerId; + } + + public String getMarkerType() { + return markerType; + } + + public void setMarkerType(String markerType) { + this.markerType = markerType; + } + + public String getMarkerDepth() { + return markerDepth; + } + + public void setMarkerDepth(String markerDepth) { + this.markerDepth = markerDepth; + } + + public String getInstallationDept() { + return installationDept; + } + + public void setInstallationDept(String installationDept) { + this.installationDept = installationDept; + } + + public String getLng() { + return lng; + } + + public void setLng(String lng) { + this.lng = lng; + } + + public String getLat() { + return lat; + } + + public void setLat(String lat) { + this.lat = lat; + } + + public String getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } + + public String getUnderlyingPipelineType() { + return underlyingPipelineType; + } + + public void setUnderlyingPipelineType(String underlyingPipelineType) { + this.underlyingPipelineType = underlyingPipelineType; + } + + public String getUnderlyingPipelineDepth() { + return underlyingPipelineDepth; + } + + public void setUnderlyingPipelineDepth(String underlyingPipelineDepth) { + this.underlyingPipelineDepth = underlyingPipelineDepth; + } + + public String getUnderlyingPipelineDiameter() { + return underlyingPipelineDiameter; + } + + public void setUnderlyingPipelineDiameter(String underlyingPipelineDiameter) { + this.underlyingPipelineDiameter = underlyingPipelineDiameter; + } + + public String getUnderlyingPipelineMaterial() { + return underlyingPipelineMaterial; + } + + public void setUnderlyingPipelineMaterial(String underlyingPipelineMaterial) { + this.underlyingPipelineMaterial = underlyingPipelineMaterial; + } + + public String getObjectType() { + return objectType; + } + + public void setObjectType(String objectType) { + this.objectType = objectType; + } + + public String getColor() { + return color; + } + + public void setColor(String color) { + this.color = color; + } + + public String getImagePath() { + return imagePath; + } + + public void setImagePath(String imagePath) { + this.imagePath = imagePath; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java deleted file mode 100644 index 3f2fcdc..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java +++ /dev/null @@ -1,327 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 从平台下载的标识器本地库实体类 - */ -@Entity -public class MarkerLocalBean { - @Id(autoincrement = true) - private Long id;//本地库主键ID - - // 管线类型 - private String pipelineType; - // 管线直径 - private String pipelineDiameter; - // 管材 - private String pipelineMaterial; - // 埋设方式 - private String buryMethod; - // 埋深 - private String buryDepth; - // 所属区域 - private String area; - // 所属线路 - private String line; - // 所属道路 - private String road; - // 建设年代 - private String constructTime; - // 权属单位 - private String owner; - //标识对象ID,无实际用途 - @Deprecated - private String objectId; - // 标识器ID - private String markerId; - // 标识器类型 - private String markerType; - // 标识器埋深 - private String markerDepth; - // 安装部门 - private String installationDept; - // 经度 - private String lng; - // 纬度 - private String lat; - //最后修改时间,更新时间 - private String updateTime; - // 备注信息 - private String remark; - // 下层管线类型 - private String underlyingPipelineType; - // 下层埋深 - private String underlyingPipelineDepth; - // 下层管径 - private String underlyingPipelineDiameter; - // 下层管材 - private String underlyingPipelineMaterial; - //标识对象类型 - private String objectType; - // 颜色 - private String color; - // 图片路径 - private String imagePath; - - @Generated(hash = 1479045776) - public MarkerLocalBean(Long id, String pipelineType, String pipelineDiameter, - String pipelineMaterial, String buryMethod, String buryDepth, - String area, String line, String road, String constructTime, - String owner, String objectId, String markerId, String markerType, - String markerDepth, String installationDept, String lng, String lat, - String updateTime, String remark, String underlyingPipelineType, - String underlyingPipelineDepth, String underlyingPipelineDiameter, - String underlyingPipelineMaterial, String objectType, String color, - String imagePath) { - this.id = id; - this.pipelineType = pipelineType; - this.pipelineDiameter = pipelineDiameter; - this.pipelineMaterial = pipelineMaterial; - this.buryMethod = buryMethod; - this.buryDepth = buryDepth; - this.area = area; - this.line = line; - this.road = road; - this.constructTime = constructTime; - this.owner = owner; - this.objectId = objectId; - this.markerId = markerId; - this.markerType = markerType; - this.markerDepth = markerDepth; - this.installationDept = installationDept; - this.lng = lng; - this.lat = lat; - this.updateTime = updateTime; - this.remark = remark; - this.underlyingPipelineType = underlyingPipelineType; - this.underlyingPipelineDepth = underlyingPipelineDepth; - this.underlyingPipelineDiameter = underlyingPipelineDiameter; - this.underlyingPipelineMaterial = underlyingPipelineMaterial; - this.objectType = objectType; - this.color = color; - this.imagePath = imagePath; - } - - @Generated(hash = 1538606012) - public MarkerLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getPipelineType() { - return this.pipelineType; - } - - public void setPipelineType(String pipelineType) { - this.pipelineType = pipelineType; - } - - public String getPipelineDiameter() { - return this.pipelineDiameter; - } - - public void setPipelineDiameter(String pipelineDiameter) { - this.pipelineDiameter = pipelineDiameter; - } - - public String getPipelineMaterial() { - return this.pipelineMaterial; - } - - public void setPipelineMaterial(String pipelineMaterial) { - this.pipelineMaterial = pipelineMaterial; - } - - public String getBuryMethod() { - return this.buryMethod; - } - - public void setBuryMethod(String buryMethod) { - this.buryMethod = buryMethod; - } - - public String getBuryDepth() { - return this.buryDepth; - } - - public void setBuryDepth(String buryDepth) { - this.buryDepth = buryDepth; - } - - public String getArea() { - return this.area; - } - - public void setArea(String area) { - this.area = area; - } - - public String getLine() { - return this.line; - } - - public void setLine(String line) { - this.line = line; - } - - public String getRoad() { - return this.road; - } - - public void setRoad(String road) { - this.road = road; - } - - public String getConstructTime() { - return this.constructTime; - } - - public void setConstructTime(String constructTime) { - this.constructTime = constructTime; - } - - public String getOwner() { - return this.owner; - } - - public void setOwner(String owner) { - this.owner = owner; - } - - public String getObjectId() { - return this.objectId; - } - - public void setObjectId(String objectId) { - this.objectId = objectId; - } - - public String getMarkerId() { - return this.markerId; - } - - public void setMarkerId(String markerId) { - this.markerId = markerId; - } - - public String getMarkerType() { - return this.markerType; - } - - public void setMarkerType(String markerType) { - this.markerType = markerType; - } - - public String getMarkerDepth() { - return this.markerDepth; - } - - public void setMarkerDepth(String markerDepth) { - this.markerDepth = markerDepth; - } - - public String getInstallationDept() { - return this.installationDept; - } - - public void setInstallationDept(String installationDept) { - this.installationDept = installationDept; - } - - public String getLng() { - return this.lng; - } - - public void setLng(String lng) { - this.lng = lng; - } - - public String getLat() { - return this.lat; - } - - public void setLat(String lat) { - this.lat = lat; - } - - public String getUpdateTime() { - return this.updateTime; - } - - public void setUpdateTime(String updateTime) { - this.updateTime = updateTime; - } - - public String getRemark() { - return this.remark; - } - - public void setRemark(String remark) { - this.remark = remark; - } - - public String getUnderlyingPipelineType() { - return this.underlyingPipelineType; - } - - public void setUnderlyingPipelineType(String underlyingPipelineType) { - this.underlyingPipelineType = underlyingPipelineType; - } - - public String getUnderlyingPipelineDepth() { - return this.underlyingPipelineDepth; - } - - public void setUnderlyingPipelineDepth(String underlyingPipelineDepth) { - this.underlyingPipelineDepth = underlyingPipelineDepth; - } - - public String getUnderlyingPipelineDiameter() { - return this.underlyingPipelineDiameter; - } - - public void setUnderlyingPipelineDiameter(String underlyingPipelineDiameter) { - this.underlyingPipelineDiameter = underlyingPipelineDiameter; - } - - public String getUnderlyingPipelineMaterial() { - return this.underlyingPipelineMaterial; - } - - public void setUnderlyingPipelineMaterial(String underlyingPipelineMaterial) { - this.underlyingPipelineMaterial = underlyingPipelineMaterial; - } - - public String getObjectType() { - return this.objectType; - } - - public void setObjectType(String objectType) { - this.objectType = objectType; - } - - public String getColor() { - return this.color; - } - - public void setColor(String color) { - this.color = color; - } - - public String getImagePath() { - return this.imagePath; - } - - public void setImagePath(String imagePath) { - this.imagePath = imagePath; - } -} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java new file mode 100644 index 0000000..5c88fdf --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java @@ -0,0 +1,93 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 巡检任务本地库实体类,不包含任务里面需要巡检的标识器信息 + */ +@Entity(tableName = "task_detail") +public class TaskBean { + @PrimaryKey(autoGenerate = true) + private long id;//主键ID + private String taskCode; // 任务编号 + private String description; // 任务名称 + private String createTime; // 任务创建的时间 + private String status; // 任务状态 + private String createUserName; // 任务创建者名称 + private String startTime; // 任务被开始执行的时间 + private String endTime; // 任务执行结束的时间 + private String isFree; // 是否自由巡检。1-是,0-否 + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getTaskCode() { + return taskCode; + } + + public void setTaskCode(String taskCode) { + this.taskCode = taskCode; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getCreateUserName() { + return createUserName; + } + + public void setCreateUserName(String createUserName) { + this.createUserName = createUserName; + } + + public String getStartTime() { + return startTime; + } + + public void setStartTime(String startTime) { + this.startTime = startTime; + } + + public String getEndTime() { + return endTime; + } + + public void setEndTime(String endTime) { + this.endTime = endTime; + } + + public String getIsFree() { + return isFree; + } + + public void setIsFree(String isFree) { + this.isFree = isFree; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java deleted file mode 100644 index 91737b3..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java +++ /dev/null @@ -1,114 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 巡检任务本地库实体类,不包含任务里面需要巡检的标识器信息 - */ -@Entity -public class TaskLocalBean { - @Id - private Long id;//任务ID - - private String taskCode;//任务编号 - private String description;//任务名称 - private String createTime;//任务创建的时间 - private String status;//任务状态 - private String createUserName;//任务创建者名称 - private String startTime;//任务被开始执行的时间 - private String endTime;//任务执行结束的时间 - private String isFreeTask;//是否自由巡检。1-是,0-否 - - @Generated(hash = 1482022528) - public TaskLocalBean(Long id, String taskCode, String description, - String createTime, String status, String createUserName, - String startTime, String endTime, String isFreeTask) { - this.id = id; - this.taskCode = taskCode; - this.description = description; - this.createTime = createTime; - this.status = status; - this.createUserName = createUserName; - this.startTime = startTime; - this.endTime = endTime; - this.isFreeTask = isFreeTask; - } - - @Generated(hash = 949704588) - public TaskLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getTaskCode() { - return this.taskCode; - } - - public void setTaskCode(String taskCode) { - this.taskCode = taskCode; - } - - public String getDescription() { - return this.description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getCreateTime() { - return this.createTime; - } - - public void setCreateTime(String createTime) { - this.createTime = createTime; - } - - public String getStatus() { - return this.status; - } - - public void setStatus(String status) { - this.status = status; - } - - public String getCreateUserName() { - return this.createUserName; - } - - public void setCreateUserName(String createUserName) { - this.createUserName = createUserName; - } - - public String getStartTime() { - return this.startTime; - } - - public void setStartTime(String startTime) { - this.startTime = startTime; - } - - public String getEndTime() { - return this.endTime; - } - - public void setEndTime(String endTime) { - this.endTime = endTime; - } - - public String getIsFreeTask() { - return this.isFreeTask; - } - - public void setIsFreeTask(String isFreeTask) { - this.isFreeTask = isFreeTask; - } -} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerBean.java new file mode 100644 index 0000000..c563a60 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerBean.java @@ -0,0 +1,110 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 巡检任务里面需要巡检的标识器信息本地库实体类 + */ +@Entity(tableName = "task_marker_info") +public class TaskMarkerBean { + //标识器后台库的主键ID,不是标识器实际ID + @PrimaryKey(autoGenerate = true) + private long id; + + /** + * 任务ID,通过此字段关联[TaskBean.id] + */ + private String taskId; + + /** + * 任务Code,通过此字段关联[TaskBean.taskCode] + *

+ *

+ * 双重验证,防止出现同时刻重复的情况 + */ + private String taskCode; + + /** + * 对应后台字段[TaskModel.MessageModel.TaskDetailInfosModel.markerIdReal],也就是探测仪扫描出来的ID + */ + private String markerId; + + private Double lng; + private Double lat; + + /** + * 是否已被探测到 + * 1-是,0-否 + */ + private String isDetected; + + /** + * 被探测到的时间,对应后台字段[TaskModel.MessageModel.TaskDetailInfosModel.finishTime] + */ + private String detectedTime; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getTaskId() { + return taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getTaskCode() { + return taskCode; + } + + public void setTaskCode(String taskCode) { + this.taskCode = taskCode; + } + + public String getMarkerId() { + return markerId; + } + + public void setMarkerId(String markerId) { + this.markerId = markerId; + } + + public Double getLng() { + return lng; + } + + public void setLng(Double lng) { + this.lng = lng; + } + + public Double getLat() { + return lat; + } + + public void setLat(Double lat) { + this.lat = lat; + } + + public String getIsDetected() { + return isDetected; + } + + public void setIsDetected(String isDetected) { + this.isDetected = isDetected; + } + + public String getDetectedTime() { + return detectedTime; + } + + public void setDetectedTime(String detectedTime) { + this.detectedTime = detectedTime; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerLocalBean.java deleted file mode 100644 index de9f459..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerLocalBean.java +++ /dev/null @@ -1,128 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import com.casic.common.detector.gd.model.TaskModel; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 巡检任务里面需要巡检的标识器信息本地库实体类 - */ -@Entity -public class TaskMarkerLocalBean { - @Id - private Long id;//标识器后台库的主键ID,不是标识器实际ID - - /** - * 任务ID,通过此字段关联{@link TaskLocalBean#id} - */ - private String taskId; - - /** - * 任务Code,通过此字段关联{@link TaskLocalBean#taskCode} - *

- * 双重验证,防止出现同时刻重复的情况 - */ - private String taskCode; - - /** - * 对应后台字段{@link TaskModel.MessageModel.TaskDetailInfosModel#markerIdReal},也就是探测仪扫描出来的ID - */ - private String markerId; - - private double lng; - private double lat; - - /** - * 是否已被探测到 - * 1-是,0-否 - */ - private String isDetected; - - /** - * 被探测到的时间,对应后台字段{@link TaskModel.MessageModel.TaskDetailInfosModel#finishTime} - */ - private String detectedTime; - - @Generated(hash = 677328533) - public TaskMarkerLocalBean(Long id, String taskId, String taskCode, String markerId, - double lng, double lat, String isDetected, String detectedTime) { - this.id = id; - this.taskId = taskId; - this.taskCode = taskCode; - this.markerId = markerId; - this.lng = lng; - this.lat = lat; - this.isDetected = isDetected; - this.detectedTime = detectedTime; - } - - @Generated(hash = 1162404642) - public TaskMarkerLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getTaskId() { - return this.taskId; - } - - public void setTaskId(String taskId) { - this.taskId = taskId; - } - - public String getTaskCode() { - return this.taskCode; - } - - public void setTaskCode(String taskCode) { - this.taskCode = taskCode; - } - - public String getMarkerId() { - return this.markerId; - } - - public void setMarkerId(String markerId) { - this.markerId = markerId; - } - - public double getLng() { - return this.lng; - } - - public void setLng(double lng) { - this.lng = lng; - } - - public double getLat() { - return this.lat; - } - - public void setLat(double lat) { - this.lat = lat; - } - - public String getIsDetected() { - return this.isDetected; - } - - public void setIsDetected(String isDetected) { - this.isDetected = isDetected; - } - - public String getDetectedTime() { - return this.detectedTime; - } - - public void setDetectedTime(String detectedTime) { - this.detectedTime = detectedTime; - } -} diff --git a/app/src/main/java/com/casic/common/detector/gd/dao/MarkerBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/dao/MarkerBeanDao.java new file mode 100644 index 0000000..2beb7ed --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/dao/MarkerBeanDao.java @@ -0,0 +1,29 @@ +package com.casic.common.detector.gd.dao; + +import androidx.room.Dao; +import androidx.room.Insert; +import androidx.room.Query; +import androidx.room.RawQuery; +import androidx.sqlite.db.SupportSQLiteQuery; + +import com.casic.common.detector.gd.bean.MarkerBean; + +import java.util.List; + +@Dao +public interface MarkerBeanDao { + @Query("DELETE FROM marker_detail") + void deleteAll(); + + @Insert + void insert(MarkerBean marker); + + @Query("SELECT * FROM marker_detail") + List loadAll(); + + @Query("SELECT * FROM marker_detail WHERE markerId = :markerId") + List queryMarkerById(String markerId); + + @RawQuery + List loadMarkersByCondition(SupportSQLiteQuery query); +} diff --git a/app/src/main/java/com/casic/common/detector/gd/dao/TaskBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/dao/TaskBeanDao.java new file mode 100644 index 0000000..9c70ac2 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/dao/TaskBeanDao.java @@ -0,0 +1,120 @@ +package com.casic.common.detector.gd.dao; + +import androidx.room.Dao; +import androidx.room.Insert; +import androidx.room.Query; +import androidx.room.Transaction; + +import com.casic.common.detector.gd.bean.TaskBean; +import com.casic.common.detector.gd.bean.TaskMarkerBean; +import com.casic.common.detector.gd.model.TaskDetailLocalModel; +import com.casic.common.detector.gd.model.TaskModel; +import com.casic.common.detector.gd.utils.LocaleConstant; +import com.pengxh.kt.lite.utils.SaveKeyValues; + +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Locale; + +@Dao +public interface TaskBeanDao { + @Query("SELECT COUNT(*) FROM task_detail WHERE id = :taskId") + int isTaskExist(long taskId); + + @Insert + void insert(TaskBean task); + + default void saveTask(Long taskId, String taskName) { + if (isTaskExist(taskId) == 0) { + TaskBean task = new TaskBean(); + task.setId(taskId); + task.setTaskCode(new SimpleDateFormat("yyyyMMddHHmmss", Locale.CHINA).format(new Date())); + task.setDescription(taskName); + String time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA).format(new Date()); + task.setCreateTime(time); + task.setStatus("0"); + String userName = (String) SaveKeyValues.INSTANCE.getValue(LocaleConstant.USER_NAME, ""); + task.setCreateUserName(userName); + task.setStartTime(time); + task.setEndTime(""); + task.setIsFree("1"); + insert(task); + } + } + + default void saveTask(TaskModel.MessageModel model) { + TaskBean task = new TaskBean(); + task.setId(model.getId()); + task.setTaskCode(model.getTaskCode()); + task.setDescription(model.getDescription()); + task.setCreateTime(model.getDeployDate()); + task.setStatus(model.getStatus()); + task.setCreateUserName(model.getCreatorName()); + task.setStartTime(model.getBeginDate()); + task.setEndTime(model.getEndDate()); + task.setIsFree("0"); + if (isTaskExist(task.getId()) == 0) { + insert(task); + } + } + + @Query("SELECT * FROM task_detail") + List loadAll(); + + @Transaction + default ArrayList loadLocalTask(TaskMarkerBeanDao taskMarkerBeanDao) { + ArrayList result = new ArrayList<>(); + List tasks = loadAll(); + for (TaskBean it : tasks) { + TaskDetailLocalModel model = new TaskDetailLocalModel(); + model.setTaskId(String.valueOf(it.getId())); + model.setTaskCode(it.getTaskCode()); + model.setDescription(it.getDescription()); + model.setCreateTime(it.getCreateTime()); + model.setStatus(it.getStatus()); + model.setCreateUserName(it.getCreateUserName()); + model.setIsFreeTask(it.getIsFree()); + ArrayList results = new ArrayList<>(); + if ("0".equals(it.getIsFree())) { + // 非自由巡检才有Marker + List markers = taskMarkerBeanDao.getMarkersByIdAndCode(String.valueOf(it.getId()), it.getTaskCode()); + for (TaskMarkerBean marker : markers) { + TaskDetailLocalModel.TaskMarkerLocalModel localModel = new TaskDetailLocalModel.TaskMarkerLocalModel(); + localModel.setMarkerId(marker.getMarkerId()); + localModel.setLng(marker.getLng()); + localModel.setLat(marker.getLat()); + localModel.setIsDetected(marker.getIsDetected()); + localModel.setDetectedTime(marker.getDetectedTime()); + + results.add(localModel); + } + } + model.setMarkerModels(results); + result.add(model); + } + return result; + } + + @Query("DELETE FROM task_detail WHERE id = :taskId AND taskCode = :taskCode") + void deleteTaskById(long taskId, String taskCode); + + @Transaction + default void deleteLocalTaskById(long taskId, String taskCode, TaskMarkerBeanDao taskMarkerBeanDao) { + TaskBean task = loadAll().stream() + .filter(it -> it.getId() == taskId && taskCode.equals(it.getTaskCode())) + .findFirst() + .orElse(null); + if (task == null) return; + deleteTaskById(taskId, taskCode); + + // 删除此任务关联的Marker。非自由巡检才有Marker + if ("0".equals(task.getIsFree())) { + List markers = taskMarkerBeanDao.getMarkersByIdAndCode(String.valueOf(task.getId()), task.getTaskCode()); + for (TaskMarkerBean marker : markers) { + taskMarkerBeanDao.delete(marker); + } + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/dao/TaskMarkerBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/dao/TaskMarkerBeanDao.java new file mode 100644 index 0000000..cc2156a --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/dao/TaskMarkerBeanDao.java @@ -0,0 +1,52 @@ +package com.casic.common.detector.gd.dao; + +import androidx.room.Dao; +import androidx.room.Delete; +import androidx.room.Insert; +import androidx.room.Query; +import androidx.room.Update; + +import com.casic.common.detector.gd.bean.TaskMarkerBean; +import com.casic.common.detector.gd.model.TaskModel; + +import java.util.List; + +@Dao +public interface TaskMarkerBeanDao { + + @Insert + void insert(TaskMarkerBean marker); + + @Query("SELECT COUNT(*) FROM task_marker_info WHERE id = :markerId") + int isMarkerExist(String markerId); + + default void saveTaskMarker(long taskId, String taskCode, TaskModel.MessageModel.TaskDetailInfosModel marker) { + if (isMarkerExist(marker.getMarkerId()) == 0) { + TaskMarkerBean bean = new TaskMarkerBean(); + bean.setId(marker.getId()); + bean.setTaskId(String.valueOf(taskId)); + bean.setTaskCode(taskCode); + bean.setMarkerId(marker.getMarkerIdReal()); + bean.setLng(marker.getLongitude()); + bean.setLat(marker.getLatitude()); + bean.setIsDetected("0"); + bean.setDetectedTime(""); + insert(bean); + } + } + + @Query("SELECT * FROM task_marker_info WHERE taskId = :taskId AND taskCode = :taskCode AND markerId = :markerId AND isDetected = :state") + TaskMarkerBean queryTaskMarkerById(String taskId, String taskCode, String markerId, String state); + + @Update + void updateLocalTaskMarkerState(TaskMarkerBean marker); + + @Query("SELECT * FROM task_marker_info WHERE isDetected = :state") + List queryMarkerByState(String state); + + @Query("SELECT * FROM task_marker_info WHERE taskId = :taskId AND taskCode = :taskCode") + List getMarkersByIdAndCode(String taskId, String taskCode); + + @Delete + void delete(TaskMarkerBean marker); +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/extensions/Long.kt b/app/src/main/java/com/casic/common/detector/gd/extensions/Long.kt deleted file mode 100644 index 6713d8d..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/extensions/Long.kt +++ /dev/null @@ -1,10 +0,0 @@ -package com.casic.common.detector.gd.extensions - -import java.text.SimpleDateFormat -import java.util.Date -import java.util.Locale - -fun Long.createTaskCode(): String { - val dateFormat = SimpleDateFormat("yyyyMMddHHmmss", Locale.CHINA) - return dateFormat.format(Date(this)) -} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoMaster.java b/app/src/main/java/com/casic/common/detector/gd/greendao/DaoMaster.java deleted file mode 100644 index 6ab94b3..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoMaster.java +++ /dev/null @@ -1,102 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import android.content.Context; -import android.database.sqlite.SQLiteDatabase; -import android.database.sqlite.SQLiteDatabase.CursorFactory; -import android.util.Log; - -import org.greenrobot.greendao.AbstractDaoMaster; -import org.greenrobot.greendao.database.StandardDatabase; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.database.DatabaseOpenHelper; -import org.greenrobot.greendao.identityscope.IdentityScopeType; - - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** - * Master of DAO (schema version 1): knows all DAOs. - */ -public class DaoMaster extends AbstractDaoMaster { - public static final int SCHEMA_VERSION = 1; - - /** Creates underlying database table using DAOs. */ - public static void createAllTables(Database db, boolean ifNotExists) { - MarkerLocalBeanDao.createTable(db, ifNotExists); - TaskLocalBeanDao.createTable(db, ifNotExists); - TaskMarkerLocalBeanDao.createTable(db, ifNotExists); - } - - /** Drops underlying database table using DAOs. */ - public static void dropAllTables(Database db, boolean ifExists) { - MarkerLocalBeanDao.dropTable(db, ifExists); - TaskLocalBeanDao.dropTable(db, ifExists); - TaskMarkerLocalBeanDao.dropTable(db, ifExists); - } - - /** - * WARNING: Drops all table on Upgrade! Use only during development. - * Convenience method using a {@link DevOpenHelper}. - */ - public static DaoSession newDevSession(Context context, String name) { - Database db = new DevOpenHelper(context, name).getWritableDb(); - DaoMaster daoMaster = new DaoMaster(db); - return daoMaster.newSession(); - } - - public DaoMaster(SQLiteDatabase db) { - this(new StandardDatabase(db)); - } - - public DaoMaster(Database db) { - super(db, SCHEMA_VERSION); - registerDaoClass(MarkerLocalBeanDao.class); - registerDaoClass(TaskLocalBeanDao.class); - registerDaoClass(TaskMarkerLocalBeanDao.class); - } - - public DaoSession newSession() { - return new DaoSession(db, IdentityScopeType.Session, daoConfigMap); - } - - public DaoSession newSession(IdentityScopeType type) { - return new DaoSession(db, type, daoConfigMap); - } - - /** - * Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} - - */ - public static abstract class OpenHelper extends DatabaseOpenHelper { - public OpenHelper(Context context, String name) { - super(context, name, SCHEMA_VERSION); - } - - public OpenHelper(Context context, String name, CursorFactory factory) { - super(context, name, factory, SCHEMA_VERSION); - } - - @Override - public void onCreate(Database db) { - Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION); - createAllTables(db, false); - } - } - - /** WARNING: Drops all table on Upgrade! Use only during development. */ - public static class DevOpenHelper extends OpenHelper { - public DevOpenHelper(Context context, String name) { - super(context, name); - } - - public DevOpenHelper(Context context, String name, CursorFactory factory) { - super(context, name, factory); - } - - @Override - public void onUpgrade(Database db, int oldVersion, int newVersion) { - Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables"); - dropAllTables(db, true); - onCreate(db); - } - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoSession.java b/app/src/main/java/com/casic/common/detector/gd/greendao/DaoSession.java deleted file mode 100644 index c8b1a20..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoSession.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import java.util.Map; - -import org.greenrobot.greendao.AbstractDao; -import org.greenrobot.greendao.AbstractDaoSession; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.identityscope.IdentityScopeType; -import org.greenrobot.greendao.internal.DaoConfig; - -import com.casic.common.detector.gd.bean.MarkerLocalBean; -import com.casic.common.detector.gd.bean.TaskLocalBean; -import com.casic.common.detector.gd.bean.TaskMarkerLocalBean; - -import com.casic.common.detector.gd.greendao.MarkerLocalBeanDao; -import com.casic.common.detector.gd.greendao.TaskLocalBeanDao; -import com.casic.common.detector.gd.greendao.TaskMarkerLocalBeanDao; - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. - -/** - * {@inheritDoc} - * - * @see org.greenrobot.greendao.AbstractDaoSession - */ -public class DaoSession extends AbstractDaoSession { - - private final DaoConfig markerLocalBeanDaoConfig; - private final DaoConfig taskLocalBeanDaoConfig; - private final DaoConfig taskMarkerLocalBeanDaoConfig; - - private final MarkerLocalBeanDao markerLocalBeanDao; - private final TaskLocalBeanDao taskLocalBeanDao; - private final TaskMarkerLocalBeanDao taskMarkerLocalBeanDao; - - public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> - daoConfigMap) { - super(db); - - markerLocalBeanDaoConfig = daoConfigMap.get(MarkerLocalBeanDao.class).clone(); - markerLocalBeanDaoConfig.initIdentityScope(type); - - taskLocalBeanDaoConfig = daoConfigMap.get(TaskLocalBeanDao.class).clone(); - taskLocalBeanDaoConfig.initIdentityScope(type); - - taskMarkerLocalBeanDaoConfig = daoConfigMap.get(TaskMarkerLocalBeanDao.class).clone(); - taskMarkerLocalBeanDaoConfig.initIdentityScope(type); - - markerLocalBeanDao = new MarkerLocalBeanDao(markerLocalBeanDaoConfig, this); - taskLocalBeanDao = new TaskLocalBeanDao(taskLocalBeanDaoConfig, this); - taskMarkerLocalBeanDao = new TaskMarkerLocalBeanDao(taskMarkerLocalBeanDaoConfig, this); - - registerDao(MarkerLocalBean.class, markerLocalBeanDao); - registerDao(TaskLocalBean.class, taskLocalBeanDao); - registerDao(TaskMarkerLocalBean.class, taskMarkerLocalBeanDao); - } - - public void clear() { - markerLocalBeanDaoConfig.clearIdentityScope(); - taskLocalBeanDaoConfig.clearIdentityScope(); - taskMarkerLocalBeanDaoConfig.clearIdentityScope(); - } - - public MarkerLocalBeanDao getMarkerLocalBeanDao() { - return markerLocalBeanDao; - } - - public TaskLocalBeanDao getTaskLocalBeanDao() { - return taskLocalBeanDao; - } - - public TaskMarkerLocalBeanDao getTaskMarkerLocalBeanDao() { - return taskMarkerLocalBeanDao; - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/MarkerLocalBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/greendao/MarkerLocalBeanDao.java deleted file mode 100644 index 2f792c3..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/MarkerLocalBeanDao.java +++ /dev/null @@ -1,479 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import android.database.Cursor; -import android.database.sqlite.SQLiteStatement; - -import org.greenrobot.greendao.AbstractDao; -import org.greenrobot.greendao.Property; -import org.greenrobot.greendao.internal.DaoConfig; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.database.DatabaseStatement; - -import com.casic.common.detector.gd.bean.MarkerLocalBean; - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** - * DAO for table "MARKER_LOCAL_BEAN". -*/ -public class MarkerLocalBeanDao extends AbstractDao { - - public static final String TABLENAME = "MARKER_LOCAL_BEAN"; - - /** - * Properties of entity MarkerLocalBean.
- * Can be used for QueryBuilder and for referencing column names. - */ - public static class Properties { - public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property PipelineType = new Property(1, String.class, "pipelineType", false, "PIPELINE_TYPE"); - public final static Property PipelineDiameter = new Property(2, String.class, "pipelineDiameter", false, "PIPELINE_DIAMETER"); - public final static Property PipelineMaterial = new Property(3, String.class, "pipelineMaterial", false, "PIPELINE_MATERIAL"); - public final static Property BuryMethod = new Property(4, String.class, "buryMethod", false, "BURY_METHOD"); - public final static Property BuryDepth = new Property(5, String.class, "buryDepth", false, "BURY_DEPTH"); - public final static Property Area = new Property(6, String.class, "area", false, "AREA"); - public final static Property Line = new Property(7, String.class, "line", false, "LINE"); - public final static Property Road = new Property(8, String.class, "road", false, "ROAD"); - public final static Property ConstructTime = new Property(9, String.class, "constructTime", false, "CONSTRUCT_TIME"); - public final static Property Owner = new Property(10, String.class, "owner", false, "OWNER"); - public final static Property ObjectId = new Property(11, String.class, "objectId", false, "OBJECT_ID"); - public final static Property MarkerId = new Property(12, String.class, "markerId", false, "MARKER_ID"); - public final static Property MarkerType = new Property(13, String.class, "markerType", false, "MARKER_TYPE"); - public final static Property MarkerDepth = new Property(14, String.class, "markerDepth", false, "MARKER_DEPTH"); - public final static Property InstallationDept = new Property(15, String.class, "installationDept", false, "INSTALLATION_DEPT"); - public final static Property Lng = new Property(16, String.class, "lng", false, "LNG"); - public final static Property Lat = new Property(17, String.class, "lat", false, "LAT"); - public final static Property UpdateTime = new Property(18, String.class, "updateTime", false, "UPDATE_TIME"); - public final static Property Remark = new Property(19, String.class, "remark", false, "REMARK"); - public final static Property UnderlyingPipelineType = new Property(20, String.class, "underlyingPipelineType", false, "UNDERLYING_PIPELINE_TYPE"); - public final static Property UnderlyingPipelineDepth = new Property(21, String.class, "underlyingPipelineDepth", false, "UNDERLYING_PIPELINE_DEPTH"); - public final static Property UnderlyingPipelineDiameter = new Property(22, String.class, "underlyingPipelineDiameter", false, "UNDERLYING_PIPELINE_DIAMETER"); - public final static Property UnderlyingPipelineMaterial = new Property(23, String.class, "underlyingPipelineMaterial", false, "UNDERLYING_PIPELINE_MATERIAL"); - public final static Property ObjectType = new Property(24, String.class, "objectType", false, "OBJECT_TYPE"); - public final static Property Color = new Property(25, String.class, "color", false, "COLOR"); - public final static Property ImagePath = new Property(26, String.class, "imagePath", false, "IMAGE_PATH"); - } - - - public MarkerLocalBeanDao(DaoConfig config) { - super(config); - } - - public MarkerLocalBeanDao(DaoConfig config, DaoSession daoSession) { - super(config, daoSession); - } - - /** Creates the underlying database table. */ - public static void createTable(Database db, boolean ifNotExists) { - String constraint = ifNotExists? "IF NOT EXISTS ": ""; - db.execSQL("CREATE TABLE " + constraint + "\"MARKER_LOCAL_BEAN\" (" + // - "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id - "\"PIPELINE_TYPE\" TEXT," + // 1: pipelineType - "\"PIPELINE_DIAMETER\" TEXT," + // 2: pipelineDiameter - "\"PIPELINE_MATERIAL\" TEXT," + // 3: pipelineMaterial - "\"BURY_METHOD\" TEXT," + // 4: buryMethod - "\"BURY_DEPTH\" TEXT," + // 5: buryDepth - "\"AREA\" TEXT," + // 6: area - "\"LINE\" TEXT," + // 7: line - "\"ROAD\" TEXT," + // 8: road - "\"CONSTRUCT_TIME\" TEXT," + // 9: constructTime - "\"OWNER\" TEXT," + // 10: owner - "\"OBJECT_ID\" TEXT," + // 11: objectId - "\"MARKER_ID\" TEXT," + // 12: markerId - "\"MARKER_TYPE\" TEXT," + // 13: markerType - "\"MARKER_DEPTH\" TEXT," + // 14: markerDepth - "\"INSTALLATION_DEPT\" TEXT," + // 15: installationDept - "\"LNG\" TEXT," + // 16: lng - "\"LAT\" TEXT," + // 17: lat - "\"UPDATE_TIME\" TEXT," + // 18: updateTime - "\"REMARK\" TEXT," + // 19: remark - "\"UNDERLYING_PIPELINE_TYPE\" TEXT," + // 20: underlyingPipelineType - "\"UNDERLYING_PIPELINE_DEPTH\" TEXT," + // 21: underlyingPipelineDepth - "\"UNDERLYING_PIPELINE_DIAMETER\" TEXT," + // 22: underlyingPipelineDiameter - "\"UNDERLYING_PIPELINE_MATERIAL\" TEXT," + // 23: underlyingPipelineMaterial - "\"OBJECT_TYPE\" TEXT," + // 24: objectType - "\"COLOR\" TEXT," + // 25: color - "\"IMAGE_PATH\" TEXT);"); // 26: imagePath - } - - /** Drops the underlying database table. */ - public static void dropTable(Database db, boolean ifExists) { - String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"MARKER_LOCAL_BEAN\""; - db.execSQL(sql); - } - - @Override - protected final void bindValues(DatabaseStatement stmt, MarkerLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String pipelineType = entity.getPipelineType(); - if (pipelineType != null) { - stmt.bindString(2, pipelineType); - } - - String pipelineDiameter = entity.getPipelineDiameter(); - if (pipelineDiameter != null) { - stmt.bindString(3, pipelineDiameter); - } - - String pipelineMaterial = entity.getPipelineMaterial(); - if (pipelineMaterial != null) { - stmt.bindString(4, pipelineMaterial); - } - - String buryMethod = entity.getBuryMethod(); - if (buryMethod != null) { - stmt.bindString(5, buryMethod); - } - - String buryDepth = entity.getBuryDepth(); - if (buryDepth != null) { - stmt.bindString(6, buryDepth); - } - - String area = entity.getArea(); - if (area != null) { - stmt.bindString(7, area); - } - - String line = entity.getLine(); - if (line != null) { - stmt.bindString(8, line); - } - - String road = entity.getRoad(); - if (road != null) { - stmt.bindString(9, road); - } - - String constructTime = entity.getConstructTime(); - if (constructTime != null) { - stmt.bindString(10, constructTime); - } - - String owner = entity.getOwner(); - if (owner != null) { - stmt.bindString(11, owner); - } - - String objectId = entity.getObjectId(); - if (objectId != null) { - stmt.bindString(12, objectId); - } - - String markerId = entity.getMarkerId(); - if (markerId != null) { - stmt.bindString(13, markerId); - } - - String markerType = entity.getMarkerType(); - if (markerType != null) { - stmt.bindString(14, markerType); - } - - String markerDepth = entity.getMarkerDepth(); - if (markerDepth != null) { - stmt.bindString(15, markerDepth); - } - - String installationDept = entity.getInstallationDept(); - if (installationDept != null) { - stmt.bindString(16, installationDept); - } - - String lng = entity.getLng(); - if (lng != null) { - stmt.bindString(17, lng); - } - - String lat = entity.getLat(); - if (lat != null) { - stmt.bindString(18, lat); - } - - String updateTime = entity.getUpdateTime(); - if (updateTime != null) { - stmt.bindString(19, updateTime); - } - - String remark = entity.getRemark(); - if (remark != null) { - stmt.bindString(20, remark); - } - - String underlyingPipelineType = entity.getUnderlyingPipelineType(); - if (underlyingPipelineType != null) { - stmt.bindString(21, underlyingPipelineType); - } - - String underlyingPipelineDepth = entity.getUnderlyingPipelineDepth(); - if (underlyingPipelineDepth != null) { - stmt.bindString(22, underlyingPipelineDepth); - } - - String underlyingPipelineDiameter = entity.getUnderlyingPipelineDiameter(); - if (underlyingPipelineDiameter != null) { - stmt.bindString(23, underlyingPipelineDiameter); - } - - String underlyingPipelineMaterial = entity.getUnderlyingPipelineMaterial(); - if (underlyingPipelineMaterial != null) { - stmt.bindString(24, underlyingPipelineMaterial); - } - - String objectType = entity.getObjectType(); - if (objectType != null) { - stmt.bindString(25, objectType); - } - - String color = entity.getColor(); - if (color != null) { - stmt.bindString(26, color); - } - - String imagePath = entity.getImagePath(); - if (imagePath != null) { - stmt.bindString(27, imagePath); - } - } - - @Override - protected final void bindValues(SQLiteStatement stmt, MarkerLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String pipelineType = entity.getPipelineType(); - if (pipelineType != null) { - stmt.bindString(2, pipelineType); - } - - String pipelineDiameter = entity.getPipelineDiameter(); - if (pipelineDiameter != null) { - stmt.bindString(3, pipelineDiameter); - } - - String pipelineMaterial = entity.getPipelineMaterial(); - if (pipelineMaterial != null) { - stmt.bindString(4, pipelineMaterial); - } - - String buryMethod = entity.getBuryMethod(); - if (buryMethod != null) { - stmt.bindString(5, buryMethod); - } - - String buryDepth = entity.getBuryDepth(); - if (buryDepth != null) { - stmt.bindString(6, buryDepth); - } - - String area = entity.getArea(); - if (area != null) { - stmt.bindString(7, area); - } - - String line = entity.getLine(); - if (line != null) { - stmt.bindString(8, line); - } - - String road = entity.getRoad(); - if (road != null) { - stmt.bindString(9, road); - } - - String constructTime = entity.getConstructTime(); - if (constructTime != null) { - stmt.bindString(10, constructTime); - } - - String owner = entity.getOwner(); - if (owner != null) { - stmt.bindString(11, owner); - } - - String objectId = entity.getObjectId(); - if (objectId != null) { - stmt.bindString(12, objectId); - } - - String markerId = entity.getMarkerId(); - if (markerId != null) { - stmt.bindString(13, markerId); - } - - String markerType = entity.getMarkerType(); - if (markerType != null) { - stmt.bindString(14, markerType); - } - - String markerDepth = entity.getMarkerDepth(); - if (markerDepth != null) { - stmt.bindString(15, markerDepth); - } - - String installationDept = entity.getInstallationDept(); - if (installationDept != null) { - stmt.bindString(16, installationDept); - } - - String lng = entity.getLng(); - if (lng != null) { - stmt.bindString(17, lng); - } - - String lat = entity.getLat(); - if (lat != null) { - stmt.bindString(18, lat); - } - - String updateTime = entity.getUpdateTime(); - if (updateTime != null) { - stmt.bindString(19, updateTime); - } - - String remark = entity.getRemark(); - if (remark != null) { - stmt.bindString(20, remark); - } - - String underlyingPipelineType = entity.getUnderlyingPipelineType(); - if (underlyingPipelineType != null) { - stmt.bindString(21, underlyingPipelineType); - } - - String underlyingPipelineDepth = entity.getUnderlyingPipelineDepth(); - if (underlyingPipelineDepth != null) { - stmt.bindString(22, underlyingPipelineDepth); - } - - String underlyingPipelineDiameter = entity.getUnderlyingPipelineDiameter(); - if (underlyingPipelineDiameter != null) { - stmt.bindString(23, underlyingPipelineDiameter); - } - - String underlyingPipelineMaterial = entity.getUnderlyingPipelineMaterial(); - if (underlyingPipelineMaterial != null) { - stmt.bindString(24, underlyingPipelineMaterial); - } - - String objectType = entity.getObjectType(); - if (objectType != null) { - stmt.bindString(25, objectType); - } - - String color = entity.getColor(); - if (color != null) { - stmt.bindString(26, color); - } - - String imagePath = entity.getImagePath(); - if (imagePath != null) { - stmt.bindString(27, imagePath); - } - } - - @Override - public Long readKey(Cursor cursor, int offset) { - return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); - } - - @Override - public MarkerLocalBean readEntity(Cursor cursor, int offset) { - MarkerLocalBean entity = new MarkerLocalBean( // - cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // pipelineType - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // pipelineDiameter - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // pipelineMaterial - cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // buryMethod - cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // buryDepth - cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // area - cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // line - cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // road - cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // constructTime - cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10), // owner - cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11), // objectId - cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12), // markerId - cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13), // markerType - cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14), // markerDepth - cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15), // installationDept - cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16), // lng - cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17), // lat - cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18), // updateTime - cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19), // remark - cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20), // underlyingPipelineType - cursor.isNull(offset + 21) ? null : cursor.getString(offset + 21), // underlyingPipelineDepth - cursor.isNull(offset + 22) ? null : cursor.getString(offset + 22), // underlyingPipelineDiameter - cursor.isNull(offset + 23) ? null : cursor.getString(offset + 23), // underlyingPipelineMaterial - cursor.isNull(offset + 24) ? null : cursor.getString(offset + 24), // objectType - cursor.isNull(offset + 25) ? null : cursor.getString(offset + 25), // color - cursor.isNull(offset + 26) ? null : cursor.getString(offset + 26) // imagePath - ); - return entity; - } - - @Override - public void readEntity(Cursor cursor, MarkerLocalBean entity, int offset) { - entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setPipelineType(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); - entity.setPipelineDiameter(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); - entity.setPipelineMaterial(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); - entity.setBuryMethod(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); - entity.setBuryDepth(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); - entity.setArea(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); - entity.setLine(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); - entity.setRoad(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); - entity.setConstructTime(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9)); - entity.setOwner(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); - entity.setObjectId(cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11)); - entity.setMarkerId(cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12)); - entity.setMarkerType(cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13)); - entity.setMarkerDepth(cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14)); - entity.setInstallationDept(cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15)); - entity.setLng(cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16)); - entity.setLat(cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17)); - entity.setUpdateTime(cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18)); - entity.setRemark(cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19)); - entity.setUnderlyingPipelineType(cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20)); - entity.setUnderlyingPipelineDepth(cursor.isNull(offset + 21) ? null : cursor.getString(offset + 21)); - entity.setUnderlyingPipelineDiameter(cursor.isNull(offset + 22) ? null : cursor.getString(offset + 22)); - entity.setUnderlyingPipelineMaterial(cursor.isNull(offset + 23) ? null : cursor.getString(offset + 23)); - entity.setObjectType(cursor.isNull(offset + 24) ? null : cursor.getString(offset + 24)); - entity.setColor(cursor.isNull(offset + 25) ? null : cursor.getString(offset + 25)); - entity.setImagePath(cursor.isNull(offset + 26) ? null : cursor.getString(offset + 26)); - } - - @Override - protected final Long updateKeyAfterInsert(MarkerLocalBean entity, long rowId) { - entity.setId(rowId); - return rowId; - } - - @Override - public Long getKey(MarkerLocalBean entity) { - if(entity != null) { - return entity.getId(); - } else { - return null; - } - } - - @Override - public boolean hasKey(MarkerLocalBean entity) { - return entity.getId() != null; - } - - @Override - protected final boolean isEntityUpdateable() { - return true; - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/TaskLocalBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/greendao/TaskLocalBeanDao.java deleted file mode 100644 index fb88157..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/TaskLocalBeanDao.java +++ /dev/null @@ -1,227 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import android.database.Cursor; -import android.database.sqlite.SQLiteStatement; - -import org.greenrobot.greendao.AbstractDao; -import org.greenrobot.greendao.Property; -import org.greenrobot.greendao.internal.DaoConfig; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.database.DatabaseStatement; - -import com.casic.common.detector.gd.bean.TaskLocalBean; - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** - * DAO for table "TASK_LOCAL_BEAN". -*/ -public class TaskLocalBeanDao extends AbstractDao { - - public static final String TABLENAME = "TASK_LOCAL_BEAN"; - - /** - * Properties of entity TaskLocalBean.
- * Can be used for QueryBuilder and for referencing column names. - */ - public static class Properties { - public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property TaskCode = new Property(1, String.class, "taskCode", false, "TASK_CODE"); - public final static Property Description = new Property(2, String.class, "description", false, "DESCRIPTION"); - public final static Property CreateTime = new Property(3, String.class, "createTime", false, "CREATE_TIME"); - public final static Property Status = new Property(4, String.class, "status", false, "STATUS"); - public final static Property CreateUserName = new Property(5, String.class, "createUserName", false, "CREATE_USER_NAME"); - public final static Property StartTime = new Property(6, String.class, "startTime", false, "START_TIME"); - public final static Property EndTime = new Property(7, String.class, "endTime", false, "END_TIME"); - public final static Property IsFreeTask = new Property(8, String.class, "isFreeTask", false, "IS_FREE_TASK"); - } - - - public TaskLocalBeanDao(DaoConfig config) { - super(config); - } - - public TaskLocalBeanDao(DaoConfig config, DaoSession daoSession) { - super(config, daoSession); - } - - /** Creates the underlying database table. */ - public static void createTable(Database db, boolean ifNotExists) { - String constraint = ifNotExists? "IF NOT EXISTS ": ""; - db.execSQL("CREATE TABLE " + constraint + "\"TASK_LOCAL_BEAN\" (" + // - "\"_id\" INTEGER PRIMARY KEY ," + // 0: id - "\"TASK_CODE\" TEXT," + // 1: taskCode - "\"DESCRIPTION\" TEXT," + // 2: description - "\"CREATE_TIME\" TEXT," + // 3: createTime - "\"STATUS\" TEXT," + // 4: status - "\"CREATE_USER_NAME\" TEXT," + // 5: createUserName - "\"START_TIME\" TEXT," + // 6: startTime - "\"END_TIME\" TEXT," + // 7: endTime - "\"IS_FREE_TASK\" TEXT);"); // 8: isFreeTask - } - - /** Drops the underlying database table. */ - public static void dropTable(Database db, boolean ifExists) { - String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"TASK_LOCAL_BEAN\""; - db.execSQL(sql); - } - - @Override - protected final void bindValues(DatabaseStatement stmt, TaskLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String taskCode = entity.getTaskCode(); - if (taskCode != null) { - stmt.bindString(2, taskCode); - } - - String description = entity.getDescription(); - if (description != null) { - stmt.bindString(3, description); - } - - String createTime = entity.getCreateTime(); - if (createTime != null) { - stmt.bindString(4, createTime); - } - - String status = entity.getStatus(); - if (status != null) { - stmt.bindString(5, status); - } - - String createUserName = entity.getCreateUserName(); - if (createUserName != null) { - stmt.bindString(6, createUserName); - } - - String startTime = entity.getStartTime(); - if (startTime != null) { - stmt.bindString(7, startTime); - } - - String endTime = entity.getEndTime(); - if (endTime != null) { - stmt.bindString(8, endTime); - } - - String isFreeTask = entity.getIsFreeTask(); - if (isFreeTask != null) { - stmt.bindString(9, isFreeTask); - } - } - - @Override - protected final void bindValues(SQLiteStatement stmt, TaskLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String taskCode = entity.getTaskCode(); - if (taskCode != null) { - stmt.bindString(2, taskCode); - } - - String description = entity.getDescription(); - if (description != null) { - stmt.bindString(3, description); - } - - String createTime = entity.getCreateTime(); - if (createTime != null) { - stmt.bindString(4, createTime); - } - - String status = entity.getStatus(); - if (status != null) { - stmt.bindString(5, status); - } - - String createUserName = entity.getCreateUserName(); - if (createUserName != null) { - stmt.bindString(6, createUserName); - } - - String startTime = entity.getStartTime(); - if (startTime != null) { - stmt.bindString(7, startTime); - } - - String endTime = entity.getEndTime(); - if (endTime != null) { - stmt.bindString(8, endTime); - } - - String isFreeTask = entity.getIsFreeTask(); - if (isFreeTask != null) { - stmt.bindString(9, isFreeTask); - } - } - - @Override - public Long readKey(Cursor cursor, int offset) { - return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); - } - - @Override - public TaskLocalBean readEntity(Cursor cursor, int offset) { - TaskLocalBean entity = new TaskLocalBean( // - cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // taskCode - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // description - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // createTime - cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // status - cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // createUserName - cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // startTime - cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // endTime - cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8) // isFreeTask - ); - return entity; - } - - @Override - public void readEntity(Cursor cursor, TaskLocalBean entity, int offset) { - entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setTaskCode(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); - entity.setDescription(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); - entity.setCreateTime(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); - entity.setStatus(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); - entity.setCreateUserName(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); - entity.setStartTime(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); - entity.setEndTime(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); - entity.setIsFreeTask(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); - } - - @Override - protected final Long updateKeyAfterInsert(TaskLocalBean entity, long rowId) { - entity.setId(rowId); - return rowId; - } - - @Override - public Long getKey(TaskLocalBean entity) { - if(entity != null) { - return entity.getId(); - } else { - return null; - } - } - - @Override - public boolean hasKey(TaskLocalBean entity) { - return entity.getId() != null; - } - - @Override - protected final boolean isEntityUpdateable() { - return true; - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/TaskMarkerLocalBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/greendao/TaskMarkerLocalBeanDao.java deleted file mode 100644 index e96c735..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/TaskMarkerLocalBeanDao.java +++ /dev/null @@ -1,197 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import android.database.Cursor; -import android.database.sqlite.SQLiteStatement; - -import org.greenrobot.greendao.AbstractDao; -import org.greenrobot.greendao.Property; -import org.greenrobot.greendao.internal.DaoConfig; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.database.DatabaseStatement; - -import com.casic.common.detector.gd.bean.TaskMarkerLocalBean; - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** - * DAO for table "TASK_MARKER_LOCAL_BEAN". -*/ -public class TaskMarkerLocalBeanDao extends AbstractDao { - - public static final String TABLENAME = "TASK_MARKER_LOCAL_BEAN"; - - /** - * Properties of entity TaskMarkerLocalBean.
- * Can be used for QueryBuilder and for referencing column names. - */ - public static class Properties { - public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property TaskId = new Property(1, String.class, "taskId", false, "TASK_ID"); - public final static Property TaskCode = new Property(2, String.class, "taskCode", false, "TASK_CODE"); - public final static Property MarkerId = new Property(3, String.class, "markerId", false, "MARKER_ID"); - public final static Property Lng = new Property(4, double.class, "lng", false, "LNG"); - public final static Property Lat = new Property(5, double.class, "lat", false, "LAT"); - public final static Property IsDetected = new Property(6, String.class, "isDetected", false, "IS_DETECTED"); - public final static Property DetectedTime = new Property(7, String.class, "detectedTime", false, "DETECTED_TIME"); - } - - - public TaskMarkerLocalBeanDao(DaoConfig config) { - super(config); - } - - public TaskMarkerLocalBeanDao(DaoConfig config, DaoSession daoSession) { - super(config, daoSession); - } - - /** Creates the underlying database table. */ - public static void createTable(Database db, boolean ifNotExists) { - String constraint = ifNotExists? "IF NOT EXISTS ": ""; - db.execSQL("CREATE TABLE " + constraint + "\"TASK_MARKER_LOCAL_BEAN\" (" + // - "\"_id\" INTEGER PRIMARY KEY ," + // 0: id - "\"TASK_ID\" TEXT," + // 1: taskId - "\"TASK_CODE\" TEXT," + // 2: taskCode - "\"MARKER_ID\" TEXT," + // 3: markerId - "\"LNG\" REAL NOT NULL ," + // 4: lng - "\"LAT\" REAL NOT NULL ," + // 5: lat - "\"IS_DETECTED\" TEXT," + // 6: isDetected - "\"DETECTED_TIME\" TEXT);"); // 7: detectedTime - } - - /** Drops the underlying database table. */ - public static void dropTable(Database db, boolean ifExists) { - String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"TASK_MARKER_LOCAL_BEAN\""; - db.execSQL(sql); - } - - @Override - protected final void bindValues(DatabaseStatement stmt, TaskMarkerLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String taskId = entity.getTaskId(); - if (taskId != null) { - stmt.bindString(2, taskId); - } - - String taskCode = entity.getTaskCode(); - if (taskCode != null) { - stmt.bindString(3, taskCode); - } - - String markerId = entity.getMarkerId(); - if (markerId != null) { - stmt.bindString(4, markerId); - } - stmt.bindDouble(5, entity.getLng()); - stmt.bindDouble(6, entity.getLat()); - - String isDetected = entity.getIsDetected(); - if (isDetected != null) { - stmt.bindString(7, isDetected); - } - - String detectedTime = entity.getDetectedTime(); - if (detectedTime != null) { - stmt.bindString(8, detectedTime); - } - } - - @Override - protected final void bindValues(SQLiteStatement stmt, TaskMarkerLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String taskId = entity.getTaskId(); - if (taskId != null) { - stmt.bindString(2, taskId); - } - - String taskCode = entity.getTaskCode(); - if (taskCode != null) { - stmt.bindString(3, taskCode); - } - - String markerId = entity.getMarkerId(); - if (markerId != null) { - stmt.bindString(4, markerId); - } - stmt.bindDouble(5, entity.getLng()); - stmt.bindDouble(6, entity.getLat()); - - String isDetected = entity.getIsDetected(); - if (isDetected != null) { - stmt.bindString(7, isDetected); - } - - String detectedTime = entity.getDetectedTime(); - if (detectedTime != null) { - stmt.bindString(8, detectedTime); - } - } - - @Override - public Long readKey(Cursor cursor, int offset) { - return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); - } - - @Override - public TaskMarkerLocalBean readEntity(Cursor cursor, int offset) { - TaskMarkerLocalBean entity = new TaskMarkerLocalBean( // - cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // taskId - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // taskCode - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // markerId - cursor.getDouble(offset + 4), // lng - cursor.getDouble(offset + 5), // lat - cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // isDetected - cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7) // detectedTime - ); - return entity; - } - - @Override - public void readEntity(Cursor cursor, TaskMarkerLocalBean entity, int offset) { - entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setTaskId(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); - entity.setTaskCode(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); - entity.setMarkerId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); - entity.setLng(cursor.getDouble(offset + 4)); - entity.setLat(cursor.getDouble(offset + 5)); - entity.setIsDetected(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); - entity.setDetectedTime(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); - } - - @Override - protected final Long updateKeyAfterInsert(TaskMarkerLocalBean entity, long rowId) { - entity.setId(rowId); - return rowId; - } - - @Override - public Long getKey(TaskMarkerLocalBean entity) { - if(entity != null) { - return entity.getId(); - } else { - return null; - } - } - - @Override - public boolean hasKey(TaskMarkerLocalBean entity) { - return entity.getId() != null; - } - - @Override - protected final boolean isEntityUpdateable() { - return true; - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/model/TaskModel.java b/app/src/main/java/com/casic/common/detector/gd/model/TaskModel.java index 6e853ad..67ef5fb 100644 --- a/app/src/main/java/com/casic/common/detector/gd/model/TaskModel.java +++ b/app/src/main/java/com/casic/common/detector/gd/model/TaskModel.java @@ -24,7 +24,7 @@ } public static class MessageModel { - private int id; + private Long id; private String taskCode; private String description; private String deployDate; @@ -38,11 +38,11 @@ private int isValid; private List taskDetailInfos; - public int getId() { + public Long getId() { return id; } - public void setId(int id) { + public void setId(Long id) { this.id = id; } @@ -143,25 +143,25 @@ } public static class TaskDetailInfosModel { - private int id; + private long id; private String taskId; private String taskCode; private Object markerName; - private int markerId; + private String markerId; private String markerIdReal; private double longitude; private double latitude; private int isChecked; private int isNormal; - private Object imagePath; - private Object description; - private Object finishTime; + private String imagePath; + private String description; + private String finishTime; - public int getId() { + public long getId() { return id; } - public void setId(int id) { + public void setId(long id) { this.id = id; } @@ -189,11 +189,11 @@ this.markerName = markerName; } - public int getMarkerId() { + public String getMarkerId() { return markerId; } - public void setMarkerId(int markerId) { + public void setMarkerId(String markerId) { this.markerId = markerId; } @@ -237,27 +237,27 @@ this.isNormal = isNormal; } - public Object getImagePath() { + public String getImagePath() { return imagePath; } - public void setImagePath(Object imagePath) { + public void setImagePath(String imagePath) { this.imagePath = imagePath; } - public Object getDescription() { + public String getDescription() { return description; } - public void setDescription(Object description) { + public void setDescription(String description) { this.description = description; } - public Object getFinishTime() { + public String getFinishTime() { return finishTime; } - public void setFinishTime(Object finishTime) { + public void setFinishTime(String finishTime) { this.finishTime = finishTime; } } diff --git a/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitService.kt index 7522a87..0adad51 100644 --- a/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitService.kt @@ -50,7 +50,7 @@ */ @Multipart @POST("/ems/marker/save-marker-photo.do") - suspend fun installLabel( + suspend fun install( @PartMap jsonMarker: Map, @Part fileBuffer1: MultipartBody.Part?, @Part fileBuffer2: MultipartBody.Part?, diff --git a/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitServiceManager.kt index 5f6c701..ae2a0fa 100644 --- a/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitServiceManager.kt +++ b/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitServiceManager.kt @@ -37,22 +37,28 @@ /** * 获取标识器信息文件 */ - suspend fun getMarkerFile(userId: String, companyId: String): String { - return createApi().getMarkerFile(userId, companyId) + suspend fun getMarkerFile(): String { + val companyId = SaveKeyValues.getValue(LocaleConstant.USER_COMPANY_ID, "") as String + /** + * 后台设计如此,都传companyId + * */ + return createApi().getMarkerFile(companyId, companyId) } /** * 获取巡检工单 */ - suspend fun getTasksByUser(userName: String): String { + suspend fun getTasksByUser(): String { + val userName = SaveKeyValues.getValue(LocaleConstant.USER_NAME, "") as String return createApi().getTasksByUser(userName) } /** * 提交工单 */ - suspend fun uploadTask(userId: String, taskId: String?, state: String): String { + suspend fun uploadTask(taskId: String?, state: String): String { + val userId = SaveKeyValues.getValue(LocaleConstant.USER_ID, "") as String return createApi().uploadTask(userId, taskId.toString(), state) } @@ -60,8 +66,7 @@ * 安装新标识器 * Multipart上传图片,文件,带多参数上传 */ - suspend fun installLabel( - companyId: String, + suspend fun installMarker( recordType: String, markerObjectType: String, pipeMaterial: String, @@ -77,7 +82,6 @@ road: String, constructTime: String, ownerComp: String, - markerObjectId: String, markerId: String, markerType: String, markerDepth: String, @@ -89,6 +93,8 @@ memo: String, realPaths: ArrayList ): String { + val companyId = SaveKeyValues.getValue(LocaleConstant.USER_COMPANY_ID, "") as String + val objectId = SaveKeyValues.getValue(LocaleConstant.OBJECT_ID, "") as String val param = JsonObject() param.addProperty("companyId", companyId) param.addProperty("recordType", recordType) @@ -106,7 +112,7 @@ param.addProperty("road", road) param.addProperty("constructTime", constructTime) param.addProperty("ownerComp", ownerComp) - param.addProperty("markerObjectId", markerObjectId) + param.addProperty("markerObjectId", objectId) param.addProperty("markerId", markerId) param.addProperty("markerType", markerType) param.addProperty("markerDepth", markerDepth) @@ -133,19 +139,19 @@ return when (multiParts.size) { 3 -> { - createApi().installLabel(res, multiParts[0], multiParts[1], multiParts[2]) + createApi().install(res, multiParts[0], multiParts[1], multiParts[2]) } 2 -> { - createApi().installLabel(res, multiParts[0], multiParts[1], null) + createApi().install(res, multiParts[0], multiParts[1], null) } 1 -> { - createApi().installLabel(res, multiParts[0], null, null) + createApi().install(res, multiParts[0], null, null) } else -> { - createApi().installLabel(res, null, null, null) + createApi().install(res, null, null, null) } } } @@ -216,7 +222,7 @@ /** * 上传自由巡检过程中发现的标识器 */ - suspend fun uploadTaskMarker(taskId: String, ids: ArrayList): String { + suspend fun uploadTaskMarker(taskId: Long, ids: ArrayList): String { val param = JsonObject() param.addProperty("taskId", taskId) param.addProperty("ids", ids.joinToString(separator = ",")) diff --git a/app/src/main/java/com/casic/common/detector/gd/service/NtripConnectService.kt b/app/src/main/java/com/casic/common/detector/gd/service/NtripConnectService.kt index de9ac80..20e1a6a 100644 --- a/app/src/main/java/com/casic/common/detector/gd/service/NtripConnectService.kt +++ b/app/src/main/java/com/casic/common/detector/gd/service/NtripConnectService.kt @@ -9,10 +9,6 @@ import android.util.Log import android.view.Gravity import android.widget.Toast -import androidx.lifecycle.Lifecycle -import androidx.lifecycle.LifecycleOwner -import androidx.lifecycle.LifecycleRegistry -import androidx.lifecycle.lifecycleScope import com.casic.common.detector.gd.base.BaseApplication import com.casic.common.detector.gd.extensions.convertToGPGGA import com.casic.common.detector.gd.utils.LocaleConstant @@ -23,26 +19,24 @@ import com.pengxh.kt.lite.utils.WeakReferenceHandler import com.pengxh.kt.lite.utils.socket.tcp.OnTcpConnectStateListener import com.pengxh.kt.lite.utils.socket.tcp.TcpClient +import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.Job import kotlinx.coroutines.launch import java.io.OutputStream import java.nio.charset.StandardCharsets -class NtripConnectService : Service(), LifecycleOwner, OnTcpConnectStateListener, Handler.Callback { +class NtripConnectService : Service(), OnTcpConnectStateListener, Handler.Callback { companion object { var weakReferenceHandler: WeakReferenceHandler? = null } private val kTag = "NtripConnectService" - private val registry = LifecycleRegistry(this) private val socketClient by lazy { TcpClient(this) } private var outStream: OutputStream? = null - - override fun getLifecycle(): Lifecycle { - return registry - } + private val serviceScope = CoroutineScope(Dispatchers.Main + Job()) // 创建一个独立的CoroutineScope override fun onBind(intent: Intent?): IBinder? { return null @@ -117,7 +111,7 @@ * */ val result = String(this, StandardCharsets.UTF_8) if (result.contains("ICY 200 OK")) { - lifecycleScope.launch(Dispatchers.Main) { + serviceScope.launch { "高精度定位服务连接成功".show(this@NtripConnectService) } //连接服务即打开串口 @@ -135,12 +129,12 @@ * Content-Type: text/plain * Connection: clos * */ - lifecycleScope.launch(Dispatchers.Main) { + serviceScope.launch { "差分定位服务鉴权失败,无法解析位置".show(this@NtripConnectService) } } else { //居中显示 - lifecycleScope.launch(Dispatchers.Main) { + serviceScope.launch { val toast = Toast.makeText( this@NtripConnectService, "收到千寻数据,长度:${size}", Toast.LENGTH_SHORT ) @@ -167,7 +161,7 @@ return } - lifecycleScope.launch(Dispatchers.IO) { + serviceScope.launch(Dispatchers.IO) { socketClient.start(remoteHost, remotePort.toInt()) } } diff --git a/app/src/main/java/com/casic/common/detector/gd/utils/DataBaseManager.kt b/app/src/main/java/com/casic/common/detector/gd/utils/DataBaseManager.kt deleted file mode 100644 index aa22759..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/utils/DataBaseManager.kt +++ /dev/null @@ -1,200 +0,0 @@ -package com.casic.common.detector.gd.utils - -import com.casic.common.detector.gd.base.BaseApplication -import com.casic.common.detector.gd.bean.MarkerLocalBean -import com.casic.common.detector.gd.bean.TaskLocalBean -import com.casic.common.detector.gd.bean.TaskMarkerLocalBean -import com.casic.common.detector.gd.greendao.MarkerLocalBeanDao -import com.casic.common.detector.gd.greendao.TaskLocalBeanDao -import com.casic.common.detector.gd.greendao.TaskMarkerLocalBeanDao -import com.casic.common.detector.gd.model.TaskDetailLocalModel -import com.casic.common.detector.gd.model.TaskModel - -class DataBaseManager private constructor() { - companion object { - //Kotlin委托模式双重锁单例 - val get by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) { - DataBaseManager() - } - } - - private var taskLocalBeanDao = BaseApplication.get().getDaoSession().taskLocalBeanDao - private var taskMarkerLocalBeanDao = - BaseApplication.get().getDaoSession().taskMarkerLocalBeanDao - - fun saveTaskInLocale(task: TaskModel.MessageModel) { - val bean = TaskLocalBean() - bean.id = task.id.toLong() - bean.taskCode = task.taskCode - bean.description = task.description - bean.createTime = task.deployDate - bean.status = task.status - bean.createUserName = task.creatorName - if (task.beginDate == null) { - bean.startTime = "" - } - if (task.endDate == null) { - bean.endTime = "" - } - bean.isFreeTask = "0" - if (!bean.isExist()) { - taskLocalBeanDao.insert(bean) - } - } - - fun saveTaskInLocale(bean: TaskLocalBean) { - if (!bean.isExist()) { - taskLocalBeanDao.insert(bean) - } - } - - private fun TaskLocalBean.isExist(): Boolean { - val result = taskLocalBeanDao.queryBuilder().where( - TaskLocalBeanDao.Properties.Id.eq(this.id) - ).list() - return !result.isNullOrEmpty() - } - - fun saveTaskMarkerInLocale( - taskId: Int, taskCode: String, marker: TaskModel.MessageModel.TaskDetailInfosModel - ) { - val bean = TaskMarkerLocalBean() - bean.id = marker.id.toLong() - bean.taskId = taskId.toString() - bean.taskCode = taskCode - bean.markerId = marker.markerIdReal - bean.lng = marker.longitude - bean.lat = marker.latitude - bean.isDetected = "0" - bean.detectedTime = "" - if (!bean.isExist()) { - taskMarkerLocalBeanDao.insert(bean) - } - } - - private fun TaskMarkerLocalBean.isExist(): Boolean { - val result = taskMarkerLocalBeanDao.queryBuilder().where( - TaskMarkerLocalBeanDao.Properties.Id.eq(this.id) - ).list() - return !result.isNullOrEmpty() - } - - fun loadLocalTask(): ArrayList { - val result = ArrayList() - - val tasks = taskLocalBeanDao.loadAll() - tasks.forEach { - val model = TaskDetailLocalModel() - model.taskId = it.id.toString() - model.taskCode = it.taskCode - model.description = it.description - model.createTime = it.createTime - model.status = it.status - model.createUserName = it.createUserName - model.isFreeTask = it.isFreeTask - - val markers = ArrayList() - if (it.isFreeTask == "0") { - //非自由巡检才有Marker - val markerLocalBeans = taskMarkerLocalBeanDao.queryBuilder().where( - TaskMarkerLocalBeanDao.Properties.TaskId.eq(it.id), - TaskMarkerLocalBeanDao.Properties.TaskCode.eq(it.taskCode) - ).list() - markerLocalBeans.forEach { marker -> - val localModel = TaskDetailLocalModel.TaskMarkerLocalModel() - localModel.markerId = marker.markerId - localModel.lng = marker.lng - localModel.lat = marker.lat - localModel.isDetected = marker.isDetected - localModel.detectedTime = marker.detectedTime - - markers.add(localModel) - } - } - model.markerModels = markers - result.add(model) - } - return result - } - - fun deleteLocalTaskById(taskId: String, taskCode: String) { - val task = taskLocalBeanDao.queryBuilder().where( - TaskLocalBeanDao.Properties.Id.eq(taskId), - TaskLocalBeanDao.Properties.TaskCode.eq(taskCode) - ).list().firstOrNull() ?: return - taskLocalBeanDao.delete(task) - - //删除此任务关联的Marker。非自由巡检才有Marker - if (task.isFreeTask == "0") { - val markers = taskMarkerLocalBeanDao.queryBuilder() - .where( - TaskMarkerLocalBeanDao.Properties.TaskId.eq(taskId), - TaskMarkerLocalBeanDao.Properties.TaskCode.eq(taskCode) - ).list() - markers.forEach { - taskMarkerLocalBeanDao.delete(it) - } - } - } - - fun queryTaskMarkerById( - taskId: String, taskCode: String, markerId: String, state: String - ): TaskMarkerLocalBean? { - return taskMarkerLocalBeanDao.queryBuilder() - .where( - TaskMarkerLocalBeanDao.Properties.TaskId.eq(taskId), - TaskMarkerLocalBeanDao.Properties.TaskCode.eq(taskCode), - TaskMarkerLocalBeanDao.Properties.MarkerId.eq(markerId), - TaskMarkerLocalBeanDao.Properties.IsDetected.eq(state) - ).list().firstOrNull() - } - - fun updateLocalTaskMarkerState(marker: TaskMarkerLocalBean) { - marker.isDetected = "1" - taskMarkerLocalBeanDao.update(marker) - } - - fun queryMarkerByState(state: String): List { - return taskMarkerLocalBeanDao.queryBuilder() - .where(TaskMarkerLocalBeanDao.Properties.IsDetected.eq(state)) - .list() - } - - private var markerLocalBeanDao = BaseApplication.get().getDaoSession().markerLocalBeanDao - - fun clearMarkers() { - markerLocalBeanDao.deleteAll() - } - - fun saveMarkerInLocale(bean: MarkerLocalBean) { - markerLocalBeanDao.insert(bean) - } - - fun loadMarkers(): MutableList { - return markerLocalBeanDao.loadAll() - } - - fun loadMarkersByCondition(selectedItem: String, value: String?): MutableList { - val property = when (selectedItem) { - LocaleConstant.SPINNER_ARRAY[0] -> MarkerLocalBeanDao.Properties.MarkerId - LocaleConstant.SPINNER_ARRAY[1] -> MarkerLocalBeanDao.Properties.Area - LocaleConstant.SPINNER_ARRAY[2] -> MarkerLocalBeanDao.Properties.Line - LocaleConstant.SPINNER_ARRAY[3] -> MarkerLocalBeanDao.Properties.Road - LocaleConstant.SPINNER_ARRAY[4] -> MarkerLocalBeanDao.Properties.Owner - LocaleConstant.SPINNER_ARRAY[5] -> MarkerLocalBeanDao.Properties.InstallationDept - LocaleConstant.SPINNER_ARRAY[6] -> MarkerLocalBeanDao.Properties.UpdateTime - else -> MarkerLocalBeanDao.Properties.Remark - } - return if (value == null) { - markerLocalBeanDao.queryBuilder().where(property.isNotNull).list() - } else { - markerLocalBeanDao.queryBuilder().where(property.eq(value)).list() - } - } - - fun queryMarkerById(markerId: String): List { - return markerLocalBeanDao.queryBuilder() - .where(MarkerLocalBeanDao.Properties.MarkerId.eq(markerId)) - .list() - } -} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/utils/DetectorDataBase.java b/app/src/main/java/com/casic/common/detector/gd/utils/DetectorDataBase.java new file mode 100644 index 0000000..f686cac --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/utils/DetectorDataBase.java @@ -0,0 +1,21 @@ +package com.casic.common.detector.gd.utils; + +import androidx.room.Database; +import androidx.room.RoomDatabase; + +import com.casic.common.detector.gd.bean.MarkerBean; +import com.casic.common.detector.gd.bean.TaskBean; +import com.casic.common.detector.gd.bean.TaskMarkerBean; +import com.casic.common.detector.gd.dao.MarkerBeanDao; +import com.casic.common.detector.gd.dao.TaskBeanDao; +import com.casic.common.detector.gd.dao.TaskMarkerBeanDao; + + +@Database(entities = {MarkerBean.class, TaskBean.class, TaskMarkerBean.class}, version = 1) +public abstract class DetectorDataBase extends RoomDatabase { + public abstract MarkerBeanDao markerBeanDao(); + + public abstract TaskBeanDao taskBeanDao(); + + public abstract TaskMarkerBeanDao taskMarkerBeanDao(); +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/utils/ExcelKit.kt b/app/src/main/java/com/casic/common/detector/gd/utils/ExcelKit.kt index 200fac7..015969f 100644 --- a/app/src/main/java/com/casic/common/detector/gd/utils/ExcelKit.kt +++ b/app/src/main/java/com/casic/common/detector/gd/utils/ExcelKit.kt @@ -1,19 +1,19 @@ package com.casic.common.detector.gd.utils -import com.casic.common.detector.gd.bean.MarkerLocalBean +import com.casic.common.detector.gd.base.BaseApplication +import com.casic.common.detector.gd.bean.MarkerBean import jxl.Workbook import jxl.read.biff.BiffException import java.io.File object ExcelKit { - fun read(filePath: String): ArrayList { - val result = ArrayList() + fun read(filePath: String): ArrayList { + val result = ArrayList() try { val workbook = Workbook.getWorkbook(File(filePath)) val sheet = workbook.getSheet(0) - for (i in 1 until sheet.rows) { - val marker = MarkerLocalBean() + val marker = MarkerBean() marker.pipelineType = sheet.getCell(0, i).contents marker.pipelineDiameter = sheet.getCell(1, i).contents marker.pipelineMaterial = sheet.getCell(2, i).contents @@ -40,9 +40,10 @@ marker.objectType = sheet.getCell(23, i).contents marker.color = sheet.getCell(24, i).contents marker.imagePath = sheet.getCell(25, i).contents - - result.add(marker) - DataBaseManager.get.saveMarkerInLocale(marker) + if (!marker.markerId.isNullOrBlank()) { + result.add(marker) + BaseApplication.get().dataBase.markerBeanDao().insert(marker) + } } workbook.close() } catch (e: BiffException) { diff --git a/app/src/main/java/com/casic/common/detector/gd/utils/LocaleConstant.kt b/app/src/main/java/com/casic/common/detector/gd/utils/LocaleConstant.kt index c658924..8ac5f76 100644 --- a/app/src/main/java/com/casic/common/detector/gd/utils/LocaleConstant.kt +++ b/app/src/main/java/com/casic/common/detector/gd/utils/LocaleConstant.kt @@ -1,6 +1,8 @@ package com.casic.common.detector.gd.utils import android.Manifest +import androidx.sqlite.db.SimpleSQLiteQuery +import androidx.sqlite.db.SupportSQLiteQuery object LocaleConstant { @@ -59,4 +61,19 @@ var BURY_METHOD_ARRAY = arrayOf("直埋", "圆管", "管块", "管沟", "架空") var IDENTIFIER_TYPE_ARRAY = arrayOf("EM30", "EM50", "EM14") var COLOR_ARRAY = arrayOf("蓝色", "橙色", "红色", "黑色", "紫色", "黄色", "绿色") + + fun buildQuery(selectedItem: String, value: String): SupportSQLiteQuery { + val columnName = when (selectedItem) { + SPINNER_ARRAY[0] -> "markerId" + SPINNER_ARRAY[1] -> "area" + SPINNER_ARRAY[2] -> "line" + SPINNER_ARRAY[3] -> "road" + SPINNER_ARRAY[4] -> "owner" + SPINNER_ARRAY[5] -> "installationDept" + SPINNER_ARRAY[6] -> "updateTime" + else -> "remark" + } + val queryBuilder = StringBuilder("SELECT * FROM marker_detail WHERE $columnName = ?") + return SimpleSQLiteQuery(queryBuilder.toString(), arrayOf(value)) + } } \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/view/InstallMarkerActivity.kt b/app/src/main/java/com/casic/common/detector/gd/view/InstallMarkerActivity.kt index daf5b0f..9e09df1 100644 --- a/app/src/main/java/com/casic/common/detector/gd/view/InstallMarkerActivity.kt +++ b/app/src/main/java/com/casic/common/detector/gd/view/InstallMarkerActivity.kt @@ -14,8 +14,9 @@ import com.amap.api.location.AMapLocation import com.casic.common.detector.gd.R import com.casic.common.detector.gd.adapter.EditableImageAdapter +import com.casic.common.detector.gd.base.BaseApplication import com.casic.common.detector.gd.base.SerialPortBaseActivity -import com.casic.common.detector.gd.bean.MarkerLocalBean +import com.casic.common.detector.gd.bean.MarkerBean import com.casic.common.detector.gd.callback.OnGetLocationListener import com.casic.common.detector.gd.callback.OnImageCompressListener import com.casic.common.detector.gd.databinding.ActivityInstallMarkerBinding @@ -27,7 +28,6 @@ import com.casic.common.detector.gd.extensions.toColor import com.casic.common.detector.gd.extensions.toObjectType import com.casic.common.detector.gd.utils.CurrentSegment -import com.casic.common.detector.gd.utils.DataBaseManager import com.casic.common.detector.gd.utils.LocaleConstant import com.casic.common.detector.gd.utils.LocationKit import com.casic.common.detector.gd.utils.RuntimeCache @@ -44,7 +44,6 @@ import com.pengxh.kt.lite.extensions.timestampToCompleteDate import com.pengxh.kt.lite.extensions.timestampToTime import com.pengxh.kt.lite.extensions.toJson -import com.pengxh.kt.lite.utils.LoadState import com.pengxh.kt.lite.utils.LoadingDialog import com.pengxh.kt.lite.utils.SaveKeyValues import com.pengxh.kt.lite.widget.TitleBarView @@ -115,8 +114,6 @@ //安装 binding.installButton.setOnClickListener { - val companyId = SaveKeyValues.getValue(LocaleConstant.USER_COMPANY_ID, "") as String - val objectId = SaveKeyValues.getValue(LocaleConstant.OBJECT_ID, "") as String if (binding.objectInclude.pipeInclude.markerObjectTypeView.text.isNullOrBlank()) { when (binding.objectInclude.objectTypeSpinner.selectedItem.toString()) { "管线" -> "请输入管线种类!".show(this) @@ -189,8 +186,7 @@ //先存本地再上传服务器 saveMarkerInLocal() - taskViewModel.installLabel( - this, companyId, + taskViewModel.installMarker( binding.objectInclude.objectTypeSpinner.selectedItem.toString().toObjectType(), binding.objectInclude.pipeInclude.markerObjectTypeView.text.toString(), binding.objectInclude.pipeInclude.materialSpinner.selectedItem.toString(), @@ -206,7 +202,6 @@ binding.objectInclude.roadView.text.toString(), binding.objectInclude.constructDateView.text.toString(), binding.objectInclude.ownerView.text.toString(), - objectId, binding.identifierInclude.identifierIdView.text.toString(), binding.identifierInclude.identifierTypeSpinner.selectedItem.toString(), "${binding.identifierInclude.identifierDeepView.text}mm", @@ -216,7 +211,19 @@ binding.identifierInclude.latView.text.toString(), binding.identifierInclude.colorSpinner.selectedItem.toString().toColor(), binding.remarkView.text.toString(), - realPaths + realPaths, + onLoading = { + LoadingDialog.show(this, "标识器安装中,请稍后...") + }, + onSuccess = { + LoadingDialog.dismiss() + clearDefaultData() + "安装成功".show(this) + }, + onFailed = { + LoadingDialog.dismiss() + it.show(this) + } ) //保存默认值 @@ -268,7 +275,7 @@ private fun saveMarkerInLocal() { val objectId = SaveKeyValues.getValue(LocaleConstant.OBJECT_ID, "") as String - val marker = MarkerLocalBean() + val marker = MarkerBean() marker.objectType = binding.objectInclude.objectTypeSpinner.selectedItem.toString() marker.pipelineType = binding.objectInclude.pipeInclude.markerObjectTypeView.text.toString() marker.pipelineMaterial = @@ -302,7 +309,7 @@ marker.remark = binding.remarkView.text.toString() marker.imagePath = realPaths.toJson() - DataBaseManager.get.saveMarkerInLocale(marker) + BaseApplication.get().dataBase.markerBeanDao().insert(marker) } private fun takePicture() { @@ -339,8 +346,8 @@ override fun initOnCreate(savedInstanceState: Bundle?) { locationKit.getCurrentLocation(true, object : OnGetLocationListener { override fun onSuccess(location: AMapLocation) { - binding.identifierInclude.lngView.text = location.longitude.toString() - binding.identifierInclude.latView.text = location.latitude.toString() + binding.identifierInclude.lngView.text = "${location.longitude}" + binding.identifierInclude.latView.text = "${location.latitude}" } override fun onError() { @@ -357,22 +364,6 @@ return ActivityInstallMarkerBinding.inflate(layoutInflater) } - override fun observeRequestState() { - taskViewModel.loadState.observe(this) { - when (it) { - LoadState.Loading -> LoadingDialog.show(this, "标识器安装中,请稍后...") - - LoadState.Success -> { - LoadingDialog.dismiss() - clearDefaultData() - "安装成功".show(this) - } - - else -> LoadingDialog.dismiss() - } - } - } - override fun setupTopBarLayout() { binding.rootView.initImmersionBar(this, true, R.color.white) binding.titleView.setOnClickListener(object : TitleBarView.OnClickListener { diff --git a/app/src/main/java/com/casic/common/detector/gd/view/MainActivity.kt b/app/src/main/java/com/casic/common/detector/gd/view/MainActivity.kt index fb0b260..a6352fb 100644 --- a/app/src/main/java/com/casic/common/detector/gd/view/MainActivity.kt +++ b/app/src/main/java/com/casic/common/detector/gd/view/MainActivity.kt @@ -5,7 +5,6 @@ import android.graphics.Color import android.media.AudioAttributes import android.media.SoundPool -import android.os.Build import android.os.Bundle import android.os.CountDownTimer import android.os.Handler @@ -31,19 +30,17 @@ import com.casic.common.detector.gd.R import com.casic.common.detector.gd.base.BaseApplication import com.casic.common.detector.gd.base.SerialPortBaseActivity -import com.casic.common.detector.gd.bean.MarkerLocalBean -import com.casic.common.detector.gd.bean.TaskLocalBean +import com.casic.common.detector.gd.bean.MarkerBean import com.casic.common.detector.gd.callback.OnGetAddressListener import com.casic.common.detector.gd.callback.OnGetLocationListener import com.casic.common.detector.gd.databinding.ActivityMainBinding import com.casic.common.detector.gd.extensions.appendDownloadUrl -import com.casic.common.detector.gd.extensions.createTaskCode import com.casic.common.detector.gd.extensions.initImmersionBar +import com.casic.common.detector.gd.model.MarkerFileModel import com.casic.common.detector.gd.model.TaskDetailLocalModel import com.casic.common.detector.gd.model.TaskModel import com.casic.common.detector.gd.service.NtripConnectService import com.casic.common.detector.gd.utils.CurrentSegment -import com.casic.common.detector.gd.utils.DataBaseManager import com.casic.common.detector.gd.utils.ExcelKit import com.casic.common.detector.gd.utils.FileType import com.casic.common.detector.gd.utils.LocaleConstant @@ -62,9 +59,7 @@ import com.pengxh.kt.lite.extensions.isNetworkConnected import com.pengxh.kt.lite.extensions.navigatePageTo import com.pengxh.kt.lite.extensions.show -import com.pengxh.kt.lite.extensions.timestampToCompleteDate import com.pengxh.kt.lite.utils.FileDownloadManager -import com.pengxh.kt.lite.utils.LoadState import com.pengxh.kt.lite.utils.LoadingDialog import com.pengxh.kt.lite.utils.SaveKeyValues import com.pengxh.kt.lite.widget.TitleBarView @@ -86,6 +81,9 @@ private val samplePopupWindow by lazy { SamplePopupWindow(this) } private val detailDialog by lazy { MarkerDetailDialog(this) } private val locationKit by lazy { LocationKit(this) } + private val markerBeanDao by lazy { BaseApplication.get().dataBase.markerBeanDao() } + private val taskBeanDao by lazy { BaseApplication.get().dataBase.taskBeanDao() } + private val taskMarkerBeanDao by lazy { BaseApplication.get().dataBase.taskMarkerBeanDao() } private val taskViewModel by lazy { ViewModelProvider(this)[TaskViewModel::class.java] } private val attr = AudioAttributes.Builder().setUsage(AudioAttributes.USAGE_ALARM) .setContentType(AudioAttributes.CONTENT_TYPE_MUSIC).build() @@ -94,7 +92,7 @@ private var isFreeTask = false private var freeTaskTitle = "" private var ids = ArrayList() - private var freeTaskId: String? = null + private var freeTaskId = 0L private var soundResourceId = 0 private var isExecuteTask = false private lateinit var aMap: AMap @@ -111,89 +109,14 @@ //地图初始化 initMapConfig(savedInstanceState) - Intent(this, NtripConnectService::class.java).also { - startService(it) - } +// Intent(this, NtripConnectService::class.java).apply { +// startService(this) +// } soundResourceId = soundPool.load(this, R.raw.ring3, 1) //右上角菜单 samplePopupWindow.setPopupMenuItem(LocaleConstant.POPUP_TITLES) samplePopupWindow.setBackgroundDrawable(null) - - //task网络请求监听 - taskViewModel.markerFileResult.observe(this) { - if (it.isSuccess) { - //清空之前的数据 - DataBaseManager.get.clearMarkers() - //下载最新的数据 - val companyId = SaveKeyValues.getValue(LocaleConstant.USER_COMPANY_ID, "") - val downloadUrl = companyId.toString().appendDownloadUrl(FileType.Excel) - Log.d(kTag, "downloadUrl => $downloadUrl") - FileDownloadManager.Builder().setDownloadFileSource(downloadUrl) - .setFileSuffix("xls").setFileSaveDirectory(createDownloadFileDir()) - .setOnFileDownloadListener(object : FileDownloadManager.OnFileDownloadListener { - override fun onDownloadStart(total: Long) { - - } - - override fun onDownloadEnd(file: File) { - lifecycleScope.launch(Dispatchers.IO) { ExcelKit.read(file.absolutePath) } - LoadingDialog.dismiss() - showMarkersOnMap() - } - - override fun onDownloadFailed(t: Throwable) { - t.printStackTrace() - } - - override fun onProgressChanged(progress: Long) { - - } - }).build().start() - } - } - taskViewModel.taskResult.observe(this) { - if (it.success == "true") { - AlertMessageDialog.Builder().setContext(this).setTitle("温馨提示") - .setMessage("您有${it.message.size}个新任务!").setPositiveButton("知道了") - .setOnDialogButtonClickListener(object : - AlertMessageDialog.OnDialogButtonClickListener { - override fun onConfirmClick() { - saveUserTasks(it) - } - }).build().show() - } - } - taskViewModel.freeTaskResult.observe(this) { - freeTaskId = it - // 自由巡检保存在本地 - val bean = TaskLocalBean() - bean.id = freeTaskId.toString().toLong() - val currentTimeMillis = System.currentTimeMillis() - bean.taskCode = currentTimeMillis.createTaskCode() - bean.description = freeTaskTitle - val time = currentTimeMillis.timestampToCompleteDate() - bean.createTime = time - bean.status = "0" - val userName = SaveKeyValues.getValue(LocaleConstant.USER_NAME, "") as String - bean.createUserName = userName - bean.startTime = time - bean.endTime = "" - bean.isFreeTask = "1" - DataBaseManager.get.saveTaskInLocale(bean) - } - taskViewModel.uploadTaskMarkerResult.observe(this) { - "自由巡检任务已完成".show(this) - ids.clear() - //清空自由巡检添加的Marker - aMap.clear() - showMarkersOnMap() - } - taskViewModel.executeTaskResult.observe(this) { - "工单任务已完成".show(this) - aMap.clear() - showMarkersOnMap() - } } override fun initEvent() { @@ -216,7 +139,7 @@ }).build().show() } else { lifecycleScope.launch(Dispatchers.Main) { - val markers = DataBaseManager.get.queryMarkerByState("0") + val markers = taskMarkerBeanDao.queryMarkerByState("0") //如果有需要补全的标识器,Popup右侧会有小圆点提示 if (markers.isNotEmpty()) { samplePopupWindow.setShowPosition(4) @@ -239,13 +162,7 @@ 3 -> uploadEvent() 4 -> completionMarker() 5 -> showRtkConfigDialog() - 6 -> { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { - SatelliteStatusDialog(context).show() - } else { - "卫星数据仅支持Android 7.0以上系统".show(context) - } - } + 6 -> SatelliteStatusDialog(context).show() } } }) @@ -268,25 +185,23 @@ //查看 binding.viewButton.setOnClickListener { - QueryMarkerDialog.Builder().setContext(this).setTitle("查看标识器") - .setSpinnerArray(LocaleConstant.SPINNER_ARRAY).setNegativeButton("取消") + QueryMarkerDialog.Builder() + .setContext(this) + .setTitle("查看标识器") + .setSpinnerArray(LocaleConstant.SPINNER_ARRAY) + .setNegativeButton("取消") .setPositiveButton("确定").setOnDialogButtonClickListener(object : QueryMarkerDialog.OnDialogButtonClickListener { override fun onConfirmClick(selectedItem: String, value: String) { //查询数据库 - lifecycleScope.launch(Dispatchers.Main) { - val markers = DataBaseManager.get.loadMarkersByCondition( - selectedItem, value - ) as ArrayList - - if (markers.isEmpty()) { - "无法查到相关数据信息,请检查您的查询条件".show(context) - } else { + val buildQuery = LocaleConstant.buildQuery(selectedItem, value) + markerBeanDao.loadMarkersByCondition(buildQuery).run { + if (isNotEmpty()) { val latitudeList = ArrayList() val longitudeList = ArrayList() - val latitude = markers.first().lat - val longitude = markers.first().lng + val latitude = first().lat + val longitude = first().lng if (latitude.isNotBlank() && longitude.isNotBlank()) { if (CoordinateConverter.isAMapDataAvailable( latitude.toDouble(), longitude.toDouble() @@ -300,10 +215,11 @@ if (latitudeList.isNotEmpty() && longitudeList.isNotEmpty()) { //移动地图到所有labelBeans的第一个点 - val center = LatLng(latitudeList.first(), longitudeList.first()) - //移动到指定经纬度 - aMap.moveCamera(CameraUpdateFactory.newLatLngZoom(center, 16f)) + val target = LatLng(latitudeList.first(), longitudeList.first()) + aMap.moveCamera(CameraUpdateFactory.newLatLngZoom(target, 16f)) } + } else { + "无法查到相关信息,请检查您的查询条件".show(context) } } } @@ -316,32 +232,39 @@ //巡检 binding.inspectionButton.setOnClickListener { - val tasks = DataBaseManager.get.loadLocalTask() - if (tasks.isNotEmpty()) { - val arrayList = ArrayList() - tasks.forEachIndexed { index, task -> - arrayList.add("任务${index + 1}:${task.taskId},${task.description}") + lifecycleScope.launch { + val tasks = withContext(Dispatchers.IO) { + taskBeanDao.loadLocalTask(taskMarkerBeanDao) } + if (tasks.isNotEmpty()) { + val arrayList = ArrayList() + tasks.forEachIndexed { index, task -> + arrayList.add("任务${index + 1}:${task.taskId},${task.description}") + } - BottomActionSheet.Builder().setContext(this).setItemTextColor(Color.BLUE) - .setActionItemTitle(arrayList) - .setOnActionSheetListener(object : BottomActionSheet.OnActionSheetListener { - override fun onActionItemClick(position: Int) { - val task = tasks[position] - SaveKeyValues.putValue(LocaleConstant.TASK_ID, task.taskId) - SaveKeyValues.putValue(LocaleConstant.TASK_CODE, task.taskCode) - executeTask(task) - } - }).build().show() - } else { - AlertMessageDialog.Builder().setContext(this).setTitle("温馨提示") - .setMessage("所有任务已完成,请点击右上角菜单下载新工单或者开始自由巡检") - .setPositiveButton("开始自由巡检").setOnDialogButtonClickListener(object : - AlertMessageDialog.OnDialogButtonClickListener { - override fun onConfirmClick() { - executeFreeTask() - } - }).build().show() + BottomActionSheet.Builder().setContext(context) + .setItemTextColor(Color.BLUE) + .setActionItemTitle(arrayList) + .setOnActionSheetListener(object : BottomActionSheet.OnActionSheetListener { + override fun onActionItemClick(position: Int) { + val task = tasks[position] + SaveKeyValues.putValue(LocaleConstant.TASK_ID, task.taskId) + SaveKeyValues.putValue(LocaleConstant.TASK_CODE, task.taskCode) + executeTask(task) + } + }).build().show() + } else { + AlertMessageDialog.Builder() + .setContext(context) + .setTitle("温馨提示") + .setMessage("所有任务已完成,请点击右上角菜单下载新工单或者开始自由巡检") + .setPositiveButton("开始自由巡检").setOnDialogButtonClickListener(object : + AlertMessageDialog.OnDialogButtonClickListener { + override fun onConfirmClick() { + executeFreeTask() + } + }).build().show() + } } } @@ -371,8 +294,11 @@ //自由巡检 binding.stopFreeTaskButton.setOnLongClickListener { - AlertMessageDialog.Builder().setContext(this).setTitle("温馨提示") - .setMessage("是否确定结束此次自由巡检任务?").setPositiveButton("是") + AlertMessageDialog.Builder() + .setContext(this) + .setTitle("温馨提示") + .setMessage("是否确定结束此次自由巡检任务?") + .setPositiveButton("是") .setOnDialogButtonClickListener(object : AlertMessageDialog.OnDialogButtonClickListener { override fun onConfirmClick() { @@ -381,14 +307,38 @@ stopSerialPortCommand() binding.stopFreeTaskButton.visibility = View.GONE - if (freeTaskId.isNullOrBlank()) { + if (freeTaskId == 0L) { "任务ID异常,无法提交任务,请联系服务器管理员".show(context) return } - freeTaskId?.apply { - taskViewModel.uploadTaskMarker(context, this, ids) - } + taskViewModel.uploadTaskMarker( + freeTaskId, + ids, + onLoading = { + LoadingDialog.show(context, "任务提交中,请稍后...") + }, + onSuccess = { + LoadingDialog.dismiss() + "自由巡检任务已完成".show(context) + ids.clear() + aMap.clear() + showMarkersOnMap() + + //删除本地数据库 + val taskCode = SaveKeyValues.getValue( + LocaleConstant.TASK_CODE, "" + ) as String + taskBeanDao.deleteLocalTaskById( + freeTaskId, taskCode, taskMarkerBeanDao + ) + SaveKeyValues.putValue(LocaleConstant.TASK_ID, "") + }, + onFailed = { + LoadingDialog.dismiss() + it.show(context) + } + ) } }).build().show() true @@ -399,25 +349,52 @@ RtkConfigDialog(this).setOnDialogButtonClickListener(object : RtkConfigDialog.OnDialogButtonClickListener { override fun onConfirmClick() { - NtripConnectService.weakReferenceHandler?.apply { - sendEmptyMessage(2024082201) - } + NtripConnectService.weakReferenceHandler?.sendEmptyMessage(2024082201) } }).show() } private fun uploadTask(taskId: String, taskCode: String, state: String) { if (isNetworkConnected()) { - val userId = SaveKeyValues.getValue(LocaleConstant.USER_ID, "") as String - taskViewModel.uploadTask(this, userId, taskId, taskCode, state) + taskViewModel.uploadTask( + taskId, state, + onLoading = { + LoadingDialog.show(this, "工单提交中,请稍后...") + }, + onSuccess = { + LoadingDialog.dismiss() + //工单提交之后,并且状态是2,删除本地Task记录 + if (state == "2") { + "工单${taskId}已提交!".show(this) + //删除本地数据库 + taskBeanDao.deleteLocalTaskById( + taskId.toLong(), taskCode, taskMarkerBeanDao + ) + SaveKeyValues.putValue(LocaleConstant.TASK_ID, "") + } else { + Log.d(kTag, "uploadTask: 仅执行工单,不删除本地工单数据") + } + aMap.clear() + showMarkersOnMap() + "工单任务已完成".show(this) + }, + onFailed = { + LoadingDialog.dismiss() + it.show(this) + } + ) } else { "网络连接已断开,请检查".show(this) } } private fun executeTask(task: TaskDetailLocalModel) { - AlertControlDialog.Builder().setContext(this).setTitle("提示").setMessage("请选择操作方式") - .setPositiveButton("执行工单").setNegativeButton("提交工单") + AlertControlDialog.Builder() + .setContext(this) + .setTitle("提示") + .setMessage("请选择操作方式") + .setPositiveButton("执行工单") + .setNegativeButton("提交工单") .setOnDialogButtonClickListener(object : AlertControlDialog.OnDialogButtonClickListener { override fun onConfirmClick() { @@ -432,7 +409,7 @@ isExecuteTask = true } else { "此工单下无标识器,将执行自由巡检任务".show(context) - freeTaskId = task.taskId + freeTaskId = task.taskId.toLong() detectMarker() } } @@ -453,7 +430,18 @@ override fun onConfirmClick(value: String) { freeTaskTitle = value val userId = SaveKeyValues.getValue(LocaleConstant.USER_ID, "") as String - taskViewModel.createFreeTask(context, userId, value) + taskViewModel.createFreeTask( + userId, value, + onLoading = {}, + onSuccess = { + freeTaskId = it + // 自由巡检保存在本地 + taskBeanDao.saveTask(it, freeTaskTitle) + }, + onFailed = { + it.show(context) + } + ) detectMarker() } @@ -481,7 +469,7 @@ if (RuntimeCache.currentSegment == CurrentSegment.FreeInspection) { //显示标识器详细信息 if (!detailDialog.isShowing) { - DataBaseManager.get.queryMarkerById(markerId).firstOrNull().apply { + markerBeanDao.queryMarkerById(markerId).firstOrNull().apply { if (this == null) { "无法查询到此ID【${markerId}】的信息".show(context) } else { @@ -501,7 +489,7 @@ //不重复标注Marker if (!ids.contains(markerId)) { - val markers = DataBaseManager.get.queryMarkerById(markerId) + val markers = markerBeanDao.queryMarkerById(markerId) if (markers.isNotEmpty()) { val marker = markers.first() val latLng = LatLng(marker.lat.toDouble(), marker.lng.toDouble()) @@ -522,16 +510,6 @@ } - override fun observeRequestState() { - taskViewModel.loadState.observe(this) { - when (it) { - LoadState.Loading -> LoadingDialog.show(this, "提交工单中,请稍后") - - else -> LoadingDialog.dismiss() - } - } - } - private fun initMapConfig(savedInstanceState: Bundle?) { binding.mapView.onCreate(savedInstanceState) aMap = binding.mapView.map @@ -592,54 +570,25 @@ private fun saveUserTasks(task: TaskModel) { task.message.forEach { model -> //保存任务详情 - DataBaseManager.get.saveTaskInLocale(model) + taskBeanDao.saveTask(model) model.taskDetailInfos.forEach { marker -> //只保存有标识器ID得数据 if (!marker.markerIdReal.isNullOrBlank()) { - DataBaseManager.get.saveTaskMarkerInLocale(model.id, model.taskCode, marker) + taskMarkerBeanDao.saveTaskMarker(model.id, model.taskCode, marker) } } } "工单下载成功!".show(this) } - private fun showMarkersOnMap() { - lifecycleScope.launch(Dispatchers.IO) { - //取缓存 - val markers = DataBaseManager.get.loadMarkers() - if (markers.isEmpty()) { - return@launch - } - val first = markers.first() - val defaultLatLng = LatLng(first.lat.toDouble(), first.lng.toDouble()) - //移动到指定经纬度 - val cameraPosition = CameraPosition(defaultLatLng, 14f, 0f, 0f) - val cameraUpdate = CameraUpdateFactory.newCameraPosition(cameraPosition) - withContext(Dispatchers.Main) { - aMap.animateCamera(cameraUpdate, 1500, null) - LoadingDialog.dismiss() - } - - markers.forEach { marker -> - val latitude = marker.lat.toString().toDouble() - val longitude = marker.lng.toString().toDouble() - //将所有设备信息转化缓存为Marker点 - val options = MarkerOptions() - .position(LatLng(latitude, longitude)) - .title(marker.markerId) - aMap.addMarker(options) - } - } - } - override fun onMarkerClick(marker: Marker?): Boolean { - marker?.apply { - showNavigationOption(title, position) + marker?.let { + showNavigationOption(it.title, it.position) } return true } - override fun onMapLongClick(p0: LatLng?) { + override fun onMapLongClick(latLng: LatLng?) { showMarkersOnMap() } @@ -664,7 +613,7 @@ } override fun onCancelClick() { - val result = DataBaseManager.get.queryMarkerById(title) + val result = markerBeanDao.queryMarkerById(title) MarkerDetailDialog(context).setMarker(result.first()).show() } }).build().show() @@ -695,20 +644,24 @@ //更新标识器数据 private fun updateMarkers() { - AlertControlDialog.Builder().setContext(this).setTitle("提示").setMessage("是否更新数据?") - .setNegativeButton("取消").setPositiveButton("确定") + AlertControlDialog.Builder() + .setContext(this) + .setTitle("提示") + .setMessage("是否更新数据?") + .setNegativeButton("取消") + .setPositiveButton("确定") .setOnDialogButtonClickListener(object : AlertControlDialog.OnDialogButtonClickListener { override fun onConfirmClick() { if (isNetworkConnected()) { - val companyId = SaveKeyValues.getValue(LocaleConstant.USER_COMPANY_ID, "") - - LoadingDialog.show(this@MainActivity, "获取标识器信息中,请稍后") - /** - * 后台设计如此,都传companyId - * */ + //清空之前的数据 + markerBeanDao.deleteAll() + aMap.clear() + //获取标识器数据 taskViewModel.getMarkerFile( - context, companyId.toString(), companyId.toString() + onLoading = {}, + onSuccess = { handleMarkerFile(it) }, + onFailed = { it.show(context) } ) } else { "网络连接已断开,请检查".show(context) @@ -721,11 +674,105 @@ }).build().show() } + private fun handleMarkerFile(it: MarkerFileModel) { + if (it.isSuccess) { + //下载最新的数据 + val companyId = SaveKeyValues.getValue(LocaleConstant.USER_COMPANY_ID, "") + val downloadUrl = companyId.toString().appendDownloadUrl(FileType.Excel) + Log.d(kTag, "handleMarkerFile => $downloadUrl") + FileDownloadManager.Builder() + .setDownloadFileSource(downloadUrl) + .setFileSuffix("xls") + .setFileSaveDirectory(createDownloadFileDir()) + .setOnFileDownloadListener(object : FileDownloadManager.OnFileDownloadListener { + override fun onDownloadStart(total: Long) { + LoadingDialog.show(context, "标识器数据解析中,请稍后...") + } + + override fun onDownloadEnd(file: File) { + lifecycleScope.launch(Dispatchers.IO) { + ExcelKit.read(file.absolutePath).apply { + renderMarkers(this) + }.also { + withContext(Dispatchers.Main) { + LoadingDialog.dismiss() + "标识器数据渲染完成".show(context) + } + } + } + } + + override fun onDownloadFailed(t: Throwable) { + t.printStackTrace() + LoadingDialog.dismiss() + "标识器数据下载失败".show(context) + } + + override fun onProgressChanged(progress: Long) { + + } + }).build().start() + } + } + + private fun showMarkersOnMap() { + lifecycleScope.launch(Dispatchers.IO) { + //取缓存 + markerBeanDao.loadAll().run { + renderMarkers(this) + }.also { + withContext(Dispatchers.Main) { + "标识器数据渲染完成".show(context) + } + } + } + } + + private fun renderMarkers(markers: List) { + if (markers.isEmpty()) { + return + } + val first = markers.first() + val defaultLatLng = LatLng(first.lat.toDouble(), first.lng.toDouble()) + //移动到指定经纬度 + val cameraPosition = CameraPosition(defaultLatLng, 14f, 0f, 0f) + val cameraUpdate = CameraUpdateFactory.newCameraPosition(cameraPosition) + aMap.animateCamera(cameraUpdate, 1500, null) + markers.forEach { marker -> + val latitude = marker.lat.toString().toDouble() + val longitude = marker.lng.toString().toDouble() + //将所有设备信息转化缓存为Marker点 + val options = MarkerOptions() + .position(LatLng(latitude, longitude)) + .title(marker.markerId) + aMap.addMarker(options) + } + } + //下载工单 private fun downloadTask() { if (isNetworkConnected()) { - val userName = SaveKeyValues.getValue(LocaleConstant.USER_NAME, "") - taskViewModel.getTasksByUser(this, userName.toString()) + taskViewModel.getTasksByUser( + onLoading = {}, + onSuccess = { + if (it.success == "true") { + AlertMessageDialog.Builder() + .setContext(this) + .setTitle("温馨提示") + .setMessage("您有${it.message.size}个新任务!") + .setPositiveButton("知道了") + .setOnDialogButtonClickListener(object : + AlertMessageDialog.OnDialogButtonClickListener { + override fun onConfirmClick() { + saveUserTasks(it) + } + }).build().show() + } + }, + onFailed = { + it.show(this) + } + ) } else { "网络连接已断开,请检查".show(this) } @@ -744,7 +791,7 @@ //标识器补全 private fun completionMarker() { val companyId = SaveKeyValues.getValue(LocaleConstant.USER_COMPANY_ID, "") as String - val markers = DataBaseManager.get.queryMarkerByState("0") + val markers = taskMarkerBeanDao.queryMarkerByState("0") if (markers.isNotEmpty()) { //TODO 逻辑没梳理明白 } else { diff --git a/app/src/main/java/com/casic/common/detector/gd/view/SearchMarkerActivity.kt b/app/src/main/java/com/casic/common/detector/gd/view/SearchMarkerActivity.kt index 4a92c97..b2e3301 100644 --- a/app/src/main/java/com/casic/common/detector/gd/view/SearchMarkerActivity.kt +++ b/app/src/main/java/com/casic/common/detector/gd/view/SearchMarkerActivity.kt @@ -1,6 +1,5 @@ package com.casic.common.detector.gd.view -import android.content.Context import android.content.res.ColorStateList import android.graphics.Color import android.hardware.Sensor @@ -13,18 +12,19 @@ import android.os.Handler import android.os.Looper import android.view.View +import androidx.core.graphics.toColorInt import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.lifecycleScope import com.amap.api.location.AMapLocation import com.amap.api.maps.AMapUtils import com.amap.api.maps.model.LatLng import com.casic.common.detector.gd.R +import com.casic.common.detector.gd.base.BaseApplication import com.casic.common.detector.gd.base.SerialPortBaseActivity import com.casic.common.detector.gd.callback.OnGetLocationListener import com.casic.common.detector.gd.databinding.ActivitySearchMarkerBinding import com.casic.common.detector.gd.model.MarkerDistanceData import com.casic.common.detector.gd.utils.CurrentSegment -import com.casic.common.detector.gd.utils.DataBaseManager import com.casic.common.detector.gd.utils.LocaleConstant import com.casic.common.detector.gd.utils.LocationKit import com.casic.common.detector.gd.utils.RuntimeCache @@ -50,8 +50,10 @@ private val context = this private val locationKit by lazy { LocationKit(this) } private val markerPoints by lazy { ArrayList() } + private val markerBeanDao by lazy { BaseApplication.get().dataBase.markerBeanDao() } + private val taskMarkerBeanDao by lazy { BaseApplication.get().dataBase.taskMarkerBeanDao() } private val taskViewModel by lazy { ViewModelProvider(this)[TaskViewModel::class.java] } - private val sensorManager by lazy { getSystemService(Context.SENSOR_SERVICE) as SensorManager } + private val sensorManager by lazy { getSystemService(SENSOR_SERVICE) as SensorManager } private val attr = AudioAttributes.Builder().setUsage(AudioAttributes.USAGE_ALARM) .setContentType(AudioAttributes.CONTENT_TYPE_MUSIC).build() private val soundPool = SoundPool.Builder().setMaxStreams(16).setAudioAttributes(attr).build() @@ -109,7 +111,7 @@ override fun initEvent() { binding.depthButton.setOnClickListener { RuntimeCache.currentSegment = CurrentSegment.DetectDepth - val result = DataBaseManager.get.queryMarkerById(markerId) + val result = markerBeanDao.queryMarkerById(markerId) if (result.isNotEmpty()) { val command = when (result.first().markerType) { "EM30" -> SerialPortCommand.DETECT_EM30_DEPTH @@ -139,7 +141,7 @@ } binding.markerInfoButton.setOnClickListener { - val result = DataBaseManager.get.queryMarkerById(markerId) + val result = markerBeanDao.queryMarkerById(markerId) if (result.isNotEmpty()) { MarkerDetailDialog(this).setMarker(result.first()).show() } else { @@ -154,12 +156,12 @@ binding.depthButton.isEnabled = true binding.depthButton.setTextColor(Color.WHITE) binding.depthButton.backgroundTintList = - ColorStateList.valueOf(Color.parseColor("#004364")) + ColorStateList.valueOf("#004364".toColorInt()) binding.markerInfoButton.isEnabled = true binding.markerInfoButton.setTextColor(Color.WHITE) binding.markerInfoButton.backgroundTintList = - ColorStateList.valueOf(Color.parseColor("#FFA200")) + ColorStateList.valueOf("#FFA200".toColorInt()) handleMarker(markerId) } @@ -171,12 +173,22 @@ if (isExecuteTask) { val taskId = SaveKeyValues.getValue(LocaleConstant.TASK_ID, "") as String val taskCode = SaveKeyValues.getValue(LocaleConstant.TASK_CODE, "") as String - val taskMarkerLocalBean = DataBaseManager.get.queryTaskMarkerById( + val marker = taskMarkerBeanDao.queryTaskMarkerById( taskId, taskCode, id, "0" ) - taskMarkerLocalBean?.apply { - taskViewModel.uploadMarker(context, this) + if (marker == null) { + return } + taskViewModel.uploadMarker( + marker.markerId, + onLoading = {}, + onSuccess = { + "标识器${marker.markerId}已探测!".show(this) + marker.isDetected = "1" + taskMarkerBeanDao.updateLocalTaskMarkerState(marker) + }, + onFailed = {} + ) } } @@ -185,15 +197,22 @@ detectDepthRunnable?.let { handler.removeCallbacks(it) } detectDepthRunnable = null LoadingDialog.dismiss() - AlertMessageDialog.Builder().setContext(context).setTitle("温馨提示") - .setMessage("标识器埋深:${depth}厘米").setPositiveButton("知道了") - .setOnDialogButtonClickListener(object : - AlertMessageDialog.OnDialogButtonClickListener { - override fun onConfirmClick() { - RuntimeCache.currentSegment = CurrentSegment.SearchMarker - sendSerialPortCommand(SerialPortCommand.SEARCH_SIGNAL) - } - }).build().show() + if (!this.isDestroyed) { + AlertMessageDialog.Builder() + .setContext(context) + .setTitle("温馨提示") + .setMessage("标识器埋深:${depth}厘米") + .setPositiveButton("知道了") + .setOnDialogButtonClickListener(object : + AlertMessageDialog.OnDialogButtonClickListener { + override fun onConfirmClick() { + RuntimeCache.currentSegment = CurrentSegment.SearchMarker + sendSerialPortCommand(SerialPortCommand.SEARCH_SIGNAL) + } + }).build().show() + } else { + "标识器埋深:${depth}厘米".show(this) + } } } @@ -201,13 +220,13 @@ if (RuntimeCache.currentSegment == CurrentSegment.SearchMarker) { if (signalEnergy > 1000) { binding.markerIdButton.isEnabled = true - binding.markerIdButton.setTextColor(Color.parseColor("#428d00")) + binding.markerIdButton.setTextColor("#428d00".toColorInt()) binding.markerIdButton.backgroundTintList = ColorStateList.valueOf( - Color.parseColor("#7EFF00") + "#7EFF00".toColorInt() ) binding.searchResultView.text = "已检测到标识器" - binding.searchResultView.setTextColor(Color.parseColor("#428d00")) + binding.searchResultView.setTextColor("#428d00".toColorInt()) binding.searchResultView.setBackgroundResource(R.mipmap.bg_small_text_green) } @@ -230,19 +249,19 @@ signalEnergy <= 700 -> { setEnergyTip( "信号较弱,可能距离较远", - Color.parseColor("#8D1717"), + "#8D1717".toColorInt(), R.mipmap.bg_large_text_red ) disableButtons() binding.searchResultView.text = "未检测到标识器" - binding.searchResultView.setTextColor(Color.parseColor("#8D1717")) + binding.searchResultView.setTextColor("#8D1717".toColorInt()) binding.searchResultView.setBackgroundResource(R.mipmap.bg_small_text_red) } signalEnergy >= 4100 -> { setEnergyTip( "信号极强,接近标识器正上方", - Color.parseColor("#428d00"), + "#428d00".toColorInt(), R.mipmap.bg_large_text_green ) } @@ -250,7 +269,7 @@ else -> { setEnergyTip( "已靠近,请继续移动位置", - Color.parseColor("#8C5700"), + "#8C5700".toColorInt(), R.mipmap.bg_large_text_yellow ) } @@ -263,8 +282,8 @@ binding.energyTipsView.setBackgroundResource(backgroundRes) } - private val colorStateList = ColorStateList.valueOf(Color.parseColor("#8A8A8A")) - private val textColor = Color.parseColor("#CCCCCC") + private val colorStateList = ColorStateList.valueOf("#8A8A8A".toColorInt()) + private val textColor = "#CCCCCC".toColorInt() private fun disableButtons() { binding.depthButton.isEnabled = false @@ -287,7 +306,7 @@ val latitude = location.latitude lifecycleScope.launch(Dispatchers.IO) { val dataPoints = ArrayList() - DataBaseManager.get.loadMarkers().forEach { + markerBeanDao.loadAll().forEach { val distance = AMapUtils.calculateLineDistance( LatLng(it.lat.toDouble(), it.lng.toDouble()), LatLng(latitude, longitude) ) @@ -332,10 +351,6 @@ return ActivitySearchMarkerBinding.inflate(layoutInflater) } - override fun observeRequestState() { - - } - override fun setupTopBarLayout() { } diff --git a/app/src/main/java/com/casic/common/detector/gd/view/SearchMarkerAuditActivity.kt b/app/src/main/java/com/casic/common/detector/gd/view/SearchMarkerAuditActivity.kt index 1dc59a7..dd4cc84 100644 --- a/app/src/main/java/com/casic/common/detector/gd/view/SearchMarkerAuditActivity.kt +++ b/app/src/main/java/com/casic/common/detector/gd/view/SearchMarkerAuditActivity.kt @@ -1,6 +1,5 @@ package com.casic.common.detector.gd.view -import android.content.Context import android.hardware.Sensor import android.hardware.SensorEvent import android.hardware.SensorEventListener @@ -13,9 +12,9 @@ import com.amap.api.maps.AMapUtils import com.amap.api.maps.model.LatLng import com.casic.common.detector.gd.R +import com.casic.common.detector.gd.base.BaseApplication import com.casic.common.detector.gd.callback.OnGetLocationListener import com.casic.common.detector.gd.databinding.ActivitySearchMarkerAuditBinding -import com.casic.common.detector.gd.utils.DataBaseManager import com.casic.common.detector.gd.utils.LocaleConstant import com.casic.common.detector.gd.utils.LocationKit import com.casic.common.detector.gd.widgets.MarkerDetailDialog @@ -36,7 +35,8 @@ private val kTag = "SearchMarkerActivity" private val context = this private val locationKit by lazy { LocationKit(this) } - private val sensorManager by lazy { getSystemService(Context.SENSOR_SERVICE) as SensorManager } + private val sensorManager by lazy { getSystemService(SENSOR_SERVICE) as SensorManager } + private val markerBeanDao by lazy { BaseApplication.get().dataBase.markerBeanDao() } private val attr = AudioAttributes.Builder().setUsage(AudioAttributes.USAGE_ALARM) .setContentType(AudioAttributes.CONTENT_TYPE_MUSIC).build() private val soundPool = SoundPool.Builder().setMaxStreams(16).setAudioAttributes(attr).build() @@ -72,7 +72,7 @@ override fun initEvent() { binding.markerInfoButton.setOnClickListener { //查库 - val result = DataBaseManager.get.queryMarkerById(nearestMarkerId) + val result = markerBeanDao.queryMarkerById(nearestMarkerId) if (result.isNotEmpty()) { MarkerDetailDialog(this).setMarker(result.first()).show() } else { @@ -90,7 +90,7 @@ val latitude = location.latitude lifecycleScope.launch(Dispatchers.IO) { val dataPoints = ArrayList() - DataBaseManager.get.loadMarkers().forEach { + markerBeanDao.loadAll().forEach { val distance = AMapUtils.calculateLineDistance( LatLng(it.lat.toDouble(), it.lng.toDouble()), LatLng(latitude, longitude) ) @@ -105,7 +105,8 @@ ) } withContext(Dispatchers.Main) { - binding.radarScanView.renderPointData(dataPoints, + binding.radarScanView.renderPointData( + dataPoints, object : RadarScanView.OnGetNearestPointCallback { override fun getNearestPoint(point: RadarScanView.DataPoint?) { if (point == null) { diff --git a/app/src/main/java/com/casic/common/detector/gd/vm/TaskViewModel.kt b/app/src/main/java/com/casic/common/detector/gd/vm/TaskViewModel.kt index ee0d63a..665d95c 100644 --- a/app/src/main/java/com/casic/common/detector/gd/vm/TaskViewModel.kt +++ b/app/src/main/java/com/casic/common/detector/gd/vm/TaskViewModel.kt @@ -1,95 +1,87 @@ package com.casic.common.detector.gd.vm -import android.content.Context -import android.util.Log -import androidx.lifecycle.MutableLiveData -import com.casic.common.detector.gd.bean.TaskMarkerLocalBean import com.casic.common.detector.gd.extensions.getResponseMessage import com.casic.common.detector.gd.extensions.getResponseState import com.casic.common.detector.gd.model.MarkerFileModel import com.casic.common.detector.gd.model.TaskModel import com.casic.common.detector.gd.retrofit.RetrofitServiceManager -import com.casic.common.detector.gd.utils.DataBaseManager -import com.casic.common.detector.gd.utils.LocaleConstant -import com.google.gson.Gson import com.google.gson.JsonParser -import com.google.gson.reflect.TypeToken import com.pengxh.kt.lite.base.BaseViewModel import com.pengxh.kt.lite.extensions.launch -import com.pengxh.kt.lite.extensions.show -import com.pengxh.kt.lite.utils.LoadState -import com.pengxh.kt.lite.utils.SaveKeyValues +import com.pengxh.kt.lite.extensions.unpackingResponse class TaskViewModel : BaseViewModel() { - - private val kTag = "TaskViewModel" - private val gson by lazy { Gson() } - val markerFileResult = MutableLiveData() - val taskResult = MutableLiveData() - val freeTaskResult = MutableLiveData() - val uploadTaskMarkerResult = MutableLiveData() - val executeTaskResult = MutableLiveData() - - fun createFreeTask(context: Context, patrollerId: String, description: String) = launch({ + fun createFreeTask( + patrollerId: String, + description: String, + onLoading: () -> Unit, + onSuccess: (Long) -> Unit, + onFailed: (String) -> Unit + ) = launch({ + onLoading() val response = RetrofitServiceManager.createFreeTask(patrollerId, description) if (response.getResponseState()) { val element = JsonParser.parseString(response) val jsonObject = element.asJsonObject - freeTaskResult.value = jsonObject.get("taskId").asInt.toString() + onSuccess(jsonObject.get("taskId").asLong) } else { - response.getResponseMessage().show(context) + onFailed(response.getResponseMessage()) } }, { - it.printStackTrace() + onFailed(it.message ?: "Unknown error") }) - fun uploadTaskMarker(context: Context, taskId: String, ids: ArrayList) = launch({ + fun uploadTaskMarker( + taskId: Long, + ids: ArrayList, + onLoading: () -> Unit, + onSuccess: () -> Unit, + onFailed: (String) -> Unit + ) = launch({ + onLoading() val response = RetrofitServiceManager.uploadTaskMarker(taskId, ids) if (response.getResponseState()) { - val element = JsonParser.parseString(response) - val jsonObject = element.asJsonObject - uploadTaskMarkerResult.value = jsonObject.get("success").asString - - //删除本地数据库 - val taskCode = SaveKeyValues.getValue(LocaleConstant.TASK_CODE, "") as String - DataBaseManager.get.deleteLocalTaskById(taskId, taskCode) - SaveKeyValues.putValue(LocaleConstant.TASK_ID, "") + onSuccess() } else { - response.getResponseMessage().show(context) + onFailed(response.getResponseMessage()) } }, { - it.printStackTrace() + onFailed(it.message ?: "Unknown error") }) - fun getMarkerFile(context: Context, userId: String, companyId: String) = launch({ - val response = RetrofitServiceManager.getMarkerFile(userId, companyId) + fun getMarkerFile( + onLoading: () -> Unit, + onSuccess: (MarkerFileModel) -> Unit, + onFailed: (String) -> Unit + ) = launch({ + onLoading() + val response = RetrofitServiceManager.getMarkerFile() if (response.getResponseState()) { - markerFileResult.value = gson.fromJson( - response, object : TypeToken() {}.type - ) + onSuccess(unpackingResponse(response)) } else { - response.getResponseMessage().show(context) + onFailed(response.getResponseMessage()) } }, { - it.printStackTrace() + onFailed(it.message ?: "Unknown error") }) - fun getTasksByUser(context: Context, userName: String) = launch({ - val response = RetrofitServiceManager.getTasksByUser(userName) + fun getTasksByUser( + onLoading: () -> Unit, + onSuccess: (TaskModel) -> Unit, + onFailed: (String) -> Unit + ) = launch({ + onLoading() + val response = RetrofitServiceManager.getTasksByUser() if (response.getResponseState()) { - taskResult.value = gson.fromJson( - response, object : TypeToken() {}.type - ) + onSuccess(unpackingResponse(response)) } else { - response.getResponseMessage().show(context) + onFailed(response.getResponseMessage()) } }, { - it.printStackTrace() + onFailed(it.message ?: "Unknown error") }) - fun installLabel( - context: Context, - companyId: String, + fun installMarker( recordType: String, markerObjectType: String, pipeMaterial: String, @@ -105,7 +97,6 @@ road: String, constructTime: String, ownerComp: String, - markerObjectId: String, markerId: String, markerType: String, markerDepth: String, @@ -115,11 +106,13 @@ latitude: String, colorType: String, memo: String, - realPaths: ArrayList + realPaths: ArrayList, + onLoading: () -> Unit, + onSuccess: () -> Unit, + onFailed: (String) -> Unit ) = launch({ - loadState.value = LoadState.Loading - val response = RetrofitServiceManager.installLabel( - companyId, + onLoading() + val response = RetrofitServiceManager.installMarker( recordType, markerObjectType, pipeMaterial, @@ -135,7 +128,6 @@ road, constructTime, ownerComp, - markerObjectId, markerId, markerType, markerDepth, @@ -148,67 +140,65 @@ realPaths ) if (response.getResponseState()) { - loadState.value = LoadState.Success + onSuccess() } else { - loadState.value = LoadState.Fail - response.getResponseMessage().show(context) + onFailed(response.getResponseMessage()) } }, { - it.printStackTrace() - loadState.value = LoadState.Fail + onFailed(it.message ?: "Unknown error") }) fun uploadTask( - context: Context, userId: String, taskId: String, taskCode: String, state: String + taskId: String, + state: String, + onLoading: () -> Unit, + onSuccess: () -> Unit, + onFailed: (String) -> Unit ) = launch({ - loadState.value = LoadState.Loading - val response = RetrofitServiceManager.uploadTask(userId, taskId, state) + onLoading() + val response = RetrofitServiceManager.uploadTask(taskId, state) if (response.getResponseState()) { - loadState.value = LoadState.Success - //工单提交之后,并且状态是2,删除本地Task记录 - if (state == "2") { - "工单${taskId}已提交!".show(context) - //删除本地数据库 - DataBaseManager.get.deleteLocalTaskById(taskId, taskCode) - SaveKeyValues.putValue(LocaleConstant.TASK_ID, "") - - val element = JsonParser.parseString(response) - val jsonObject = element.asJsonObject - executeTaskResult.value = jsonObject.get("success").asString - } else { - Log.d(kTag, "uploadTask: 仅执行工单,不删除本地工单数据") - } + onSuccess() } else { - loadState.value = LoadState.Fail - response.getResponseMessage().show(context) + onFailed(response.getResponseMessage()) } }, { - it.printStackTrace() - loadState.value = LoadState.Fail + onFailed(it.message ?: "Unknown error") }) fun uploadEvent( - context: Context, taskId: String, event: String, realPaths: ArrayList + taskId: String, + event: String, + realPaths: ArrayList, + onLoading: () -> Unit, + onSuccess: () -> Unit, + onFailed: (String) -> Unit ) = launch({ - loadState.value = LoadState.Loading + onLoading() val response = RetrofitServiceManager.uploadEvent(taskId, event, realPaths) if (response.getResponseState()) { - loadState.value = LoadState.Success + onSuccess() } else { - loadState.value = LoadState.Fail - response.getResponseMessage().show(context) + onFailed(response.getResponseMessage()) } }, { - it.printStackTrace() - loadState.value = LoadState.Fail + onFailed(it.message ?: "Unknown error") }) - fun uploadMarker(context: Context, marker: TaskMarkerLocalBean) = launch({ - //主键ID代替MarkerId - RetrofitServiceManager.uploadMarker(marker.id.toString()) - "标识器${marker.markerId}已探测!".show(context) - DataBaseManager.get.updateLocalTaskMarkerState(marker) + fun uploadMarker( + markerId: String, + onLoading: () -> Unit, + onSuccess: () -> Unit, + onFailed: (String) -> Unit + ) = launch({ + onLoading() + val response = RetrofitServiceManager.uploadMarker(markerId) + if (response.getResponseState()) { + onSuccess() + } else { + onFailed(response.getResponseMessage()) + } }, { - it.printStackTrace() + onFailed(it.message ?: "Unknown error") }) } \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/widgets/MarkerDetailDialog.kt b/app/src/main/java/com/casic/common/detector/gd/widgets/MarkerDetailDialog.kt index 44723f2..3890584 100644 --- a/app/src/main/java/com/casic/common/detector/gd/widgets/MarkerDetailDialog.kt +++ b/app/src/main/java/com/casic/common/detector/gd/widgets/MarkerDetailDialog.kt @@ -3,8 +3,7 @@ import android.app.Dialog import android.content.Context import android.os.Bundle -import com.casic.common.detector.gd.R -import com.casic.common.detector.gd.bean.MarkerLocalBean +import com.casic.common.detector.gd.bean.MarkerBean import com.casic.common.detector.gd.databinding.DialogMarkerDetailBinding import com.casic.common.detector.gd.extensions.appendDownloadUrl import com.casic.common.detector.gd.extensions.initDialogLayoutParams @@ -15,12 +14,11 @@ import com.pengxh.kt.lite.extensions.navigatePageTo import com.pengxh.kt.lite.extensions.show -class MarkerDetailDialog(context: Context) : - Dialog(context, R.style.UserDefinedDialogStyle) { +class MarkerDetailDialog(context: Context) : Dialog(context) { - private lateinit var marker: MarkerLocalBean + private lateinit var marker: MarkerBean - fun setMarker(marker: MarkerLocalBean): MarkerDetailDialog { + fun setMarker(marker: MarkerBean): MarkerDetailDialog { this.marker = marker return this } @@ -52,7 +50,7 @@ binding.showImageView.setOnClickListener { //查数据库 - if (marker.imagePath.isNullOrEmpty()) { + if (marker.imagePath.isEmpty()) { "此标识器无图片".show(context) } else { val realPaths = ArrayList() //真实图片路径 diff --git a/app/build.gradle b/app/build.gradle index d0cb423..921c8c8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,25 +1,20 @@ import java.text.SimpleDateFormat -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply plugin: 'org.greenrobot.greendao' +plugins { + id('com.android.application') + id('org.jetbrains.kotlin.android') +} android { - compileSdkVersion 33 + namespace 'com.casic.common.detector.gd' + compileSdk 35 defaultConfig { - applicationId "com.casic.common.detector.gd" - minSdkVersion 26 - targetSdkVersion 33 + applicationId 'com.casic.common.detector.gd' + minSdk 26 + targetSdk 35 versionCode 5092 - versionName "5.0.9.2" - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } + versionName '5.0.9.2' } signingConfigs { @@ -31,6 +26,14 @@ } } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + signingConfig signingConfigs.release + } + } + compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 @@ -47,27 +50,16 @@ } } - kotlin { - experimental { - coroutines 'enable' - } - } - buildFeatures { + buildConfig true viewBinding true } - applicationVariants.configureEach { variant -> - variant.outputs.configureEach { - outputFileName = "COM_TCY_" + getBuildDate() + "_" + defaultConfig.versionName + ".apk" + applicationVariants.configureEach { + outputs.configureEach { + outputFileName = 'COM_TCY_' + getBuildDate() + '_' + defaultConfig.versionName + '.apk' } } - - greendao { - schemaVersion 1//数据库版本号 - targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 - daoPackage "${defaultConfig.applicationId}.greendao"//设置DaoMaster、DaoSession、Dao包名 - } } static def getBuildDate() { @@ -76,27 +68,22 @@ } dependencies { - //基础依赖库 - implementation 'com.github.AndroidCoderPeng:Kotlin-lite-lib:1.1.4' - implementation 'androidx.core:core-ktx:1.9.0' - def base_version = "1.6.1" - implementation "androidx.appcompat:appcompat:${base_version}" - implementation "com.google.android.material:material:${base_version}" + implementation 'com.github.AndroidCoderPeng:Kotlin-lite-lib:1.1.5' + implementation 'androidx.core:core-ktx:1.13.1' + implementation 'androidx.appcompat:appcompat:1.7.0' + implementation 'com.google.android.material:material:1.12.0' //Google官方授权框架 implementation 'pub.devrel:easypermissions:3.0.0' - //沉浸式状态栏。基础依赖包,必须要依赖 - implementation 'com.gyf.immersionbar:immersionbar:3.0.0' - //fragment快速实现 - implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0' + //沉浸式状态栏 + implementation 'com.geyifeng.immersionbar:immersionbar:3.2.2' //官方Json解析库 implementation 'com.google.code.gson:gson:2.10.1' - def vm_version = '2.5.1' //Kotlin协程 - implementation "androidx.lifecycle:lifecycle-runtime-ktx:${vm_version}" + implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.2' //MVVM+LiveData - implementation "androidx.lifecycle:lifecycle-livedata-ktx:${vm_version}" - implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:${vm_version}" - implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.6.2' + implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2' + implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' //返回值转换器 implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' @@ -105,9 +92,10 @@ implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' //网络请求和接口封装 implementation 'com.squareup.retrofit2:retrofit:2.9.0' - implementation 'com.squareup.okhttp3:okhttp:4.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.12.0' //数据库框架 - implementation 'org.greenrobot:greendao:3.3.0' + implementation 'androidx.room:room-runtime:2.6.1' + annotationProcessor 'androidx.room:room-compiler:2.5.2' //高德导航、定位、地图三合一 implementation 'com.amap.api:navi-3dmap:latest.integration' //经纬度逆编码 @@ -115,7 +103,7 @@ //excel implementation 'net.sourceforge.jexcelapi:jxl:2.6.12' //图片加载框架 - implementation 'com.github.bumptech.glide:glide:4.9.0' + implementation 'com.github.bumptech.glide:glide:4.12.0' //图片选择框架 implementation 'io.github.lucksiege:pictureselector:v3.11.1' //大图 diff --git a/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt b/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt index 7b695ff..50ba734 100644 --- a/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt +++ b/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt @@ -4,9 +4,9 @@ import android.app.Application import android.os.Bundle import android.util.Log -import com.casic.common.detector.gd.greendao.DaoMaster -import com.casic.common.detector.gd.greendao.DaoSession +import androidx.room.Room.databaseBuilder import com.casic.common.detector.gd.uart.SerialPort +import com.casic.common.detector.gd.utils.DetectorDataBase import com.casic.common.detector.gd.utils.GpioManager import com.pengxh.kt.lite.extensions.show import com.pengxh.kt.lite.utils.SaveKeyValues @@ -43,44 +43,42 @@ private var application: BaseApplication by Delegates.notNull() fun get() = application - - private lateinit var daoSession: DaoSession } + lateinit var dataBase: DetectorDataBase + override fun onCreate() { super.onCreate() application = this SaveKeyValues.initSharedPreferences(this) CrashReport.initCrashReport(this, "01e80d3a74", true) - val devOpenHelper = DaoMaster.DevOpenHelper(this, "Detector.db", null) - val daoMaster = DaoMaster(devOpenHelper.writableDatabase) - daoSession = daoMaster.newSession() + dataBase = databaseBuilder(this, DetectorDataBase::class.java, "Detector.db") + .allowMainThreadQueries() + .build() /** * Open the serial port * */ try { serialPorts.apply { - add(SerialPort(File("/dev/ttysWK1"), 9600, 0)) - //千寻报文数据下发串口号 - add(SerialPort(File("/dev/ttyS1"), 9600, 0)) + add(SerialPort(File("/dev/ttysWK1"), 9600, 0)) //信号通讯串口 + add(SerialPort(File("/dev/ttyS1"), 9600, 0)) //千寻报文数据下发串口号 } Log.d(kTag, "onCreate: 已初始化 ${serialPorts.size} 个串口") } catch (e: SecurityException) { "您没有串口的读写权限!".show(this) + e.printStackTrace() } catch (e: IOException) { "因为不明原因,串口无法打开!".show(this) + e.printStackTrace() } catch (e: InvalidParameterException) { "请检查串口!".show(this) + e.printStackTrace() } registerActivityLifecycleCallbacks(this) } - fun getDaoSession(): DaoSession { - return daoSession - } - override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) { } diff --git a/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt b/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt index 053b9dd..1d0c9e3 100644 --- a/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt +++ b/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt @@ -14,12 +14,10 @@ import com.casic.common.detector.gd.utils.SerialPortCommand import com.pengxh.kt.lite.utils.WeakReferenceHandler import java.io.IOException -import java.util.Timer abstract class SerialPortBaseActivity : AppCompatActivity(), Handler.Callback { private val kTag = "SerialPortBaseActivity" - private val taskTimer by lazy { Timer() } private val weakReferenceHandler by lazy { WeakReferenceHandler(this) } private val serialPorts by lazy { BaseApplication.get().getSerialPorts() } protected lateinit var binding: VB @@ -30,7 +28,6 @@ setContentView(binding.root) setupTopBarLayout() initOnCreate(savedInstanceState) - observeRequestState() initEvent() if (serialPorts.isNotEmpty()) { @@ -71,11 +68,6 @@ abstract fun initOnCreate(savedInstanceState: Bundle?) /** - * 数据请求状态监听 - */ - abstract fun observeRequestState() - - /** * 初始化业务逻辑 */ abstract fun initEvent() diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java new file mode 100644 index 0000000..7a18c20 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java @@ -0,0 +1,255 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 从平台下载的标识器本地库实体类 + */ +@Entity(tableName = "marker_detail") +public class MarkerBean { + @PrimaryKey(autoGenerate = true) + private long id; //主键ID + private String pipelineType; // 管线类型 + private String pipelineDiameter; // 管线直径 + private String pipelineMaterial; // 管材 + private String buryMethod; // 埋设方式 + private String buryDepth; // 埋深 + private String area; // 所属区域 + private String line; // 所属线路 + private String road; // 所属道路 + private String constructTime; // 建设年代 + private String owner; // 权属单位 + private String objectId; // 标识对象ID,无实际用途 + private String markerId; // 标识器ID + private String markerType; // 标识器类型 + private String markerDepth; // 标识器埋深 + private String installationDept; // 安装部门 + private String lng; // 经度 + private String lat; // 纬度 + private String updateTime; // 最后修改时间,更新时间 + private String remark; // 备注信息 + private String underlyingPipelineType; // 下层管线类型 + private String underlyingPipelineDepth; // 下层埋深 + private String underlyingPipelineDiameter; // 下层管径 + private String underlyingPipelineMaterial; // 下层管材 + private String objectType; //标识对象类型 + private String color; // 颜色 + private String imagePath; // 图片路径 + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getPipelineType() { + return pipelineType; + } + + public void setPipelineType(String pipelineType) { + this.pipelineType = pipelineType; + } + + public String getPipelineDiameter() { + return pipelineDiameter; + } + + public void setPipelineDiameter(String pipelineDiameter) { + this.pipelineDiameter = pipelineDiameter; + } + + public String getPipelineMaterial() { + return pipelineMaterial; + } + + public void setPipelineMaterial(String pipelineMaterial) { + this.pipelineMaterial = pipelineMaterial; + } + + public String getBuryMethod() { + return buryMethod; + } + + public void setBuryMethod(String buryMethod) { + this.buryMethod = buryMethod; + } + + public String getBuryDepth() { + return buryDepth; + } + + public void setBuryDepth(String buryDepth) { + this.buryDepth = buryDepth; + } + + public String getArea() { + return area; + } + + public void setArea(String area) { + this.area = area; + } + + public String getLine() { + return line; + } + + public void setLine(String line) { + this.line = line; + } + + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + + public String getConstructTime() { + return constructTime; + } + + public void setConstructTime(String constructTime) { + this.constructTime = constructTime; + } + + public String getOwner() { + return owner; + } + + public void setOwner(String owner) { + this.owner = owner; + } + + public String getObjectId() { + return objectId; + } + + public void setObjectId(String objectId) { + this.objectId = objectId; + } + + public String getMarkerId() { + return markerId; + } + + public void setMarkerId(String markerId) { + this.markerId = markerId; + } + + public String getMarkerType() { + return markerType; + } + + public void setMarkerType(String markerType) { + this.markerType = markerType; + } + + public String getMarkerDepth() { + return markerDepth; + } + + public void setMarkerDepth(String markerDepth) { + this.markerDepth = markerDepth; + } + + public String getInstallationDept() { + return installationDept; + } + + public void setInstallationDept(String installationDept) { + this.installationDept = installationDept; + } + + public String getLng() { + return lng; + } + + public void setLng(String lng) { + this.lng = lng; + } + + public String getLat() { + return lat; + } + + public void setLat(String lat) { + this.lat = lat; + } + + public String getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } + + public String getUnderlyingPipelineType() { + return underlyingPipelineType; + } + + public void setUnderlyingPipelineType(String underlyingPipelineType) { + this.underlyingPipelineType = underlyingPipelineType; + } + + public String getUnderlyingPipelineDepth() { + return underlyingPipelineDepth; + } + + public void setUnderlyingPipelineDepth(String underlyingPipelineDepth) { + this.underlyingPipelineDepth = underlyingPipelineDepth; + } + + public String getUnderlyingPipelineDiameter() { + return underlyingPipelineDiameter; + } + + public void setUnderlyingPipelineDiameter(String underlyingPipelineDiameter) { + this.underlyingPipelineDiameter = underlyingPipelineDiameter; + } + + public String getUnderlyingPipelineMaterial() { + return underlyingPipelineMaterial; + } + + public void setUnderlyingPipelineMaterial(String underlyingPipelineMaterial) { + this.underlyingPipelineMaterial = underlyingPipelineMaterial; + } + + public String getObjectType() { + return objectType; + } + + public void setObjectType(String objectType) { + this.objectType = objectType; + } + + public String getColor() { + return color; + } + + public void setColor(String color) { + this.color = color; + } + + public String getImagePath() { + return imagePath; + } + + public void setImagePath(String imagePath) { + this.imagePath = imagePath; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java deleted file mode 100644 index 3f2fcdc..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java +++ /dev/null @@ -1,327 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 从平台下载的标识器本地库实体类 - */ -@Entity -public class MarkerLocalBean { - @Id(autoincrement = true) - private Long id;//本地库主键ID - - // 管线类型 - private String pipelineType; - // 管线直径 - private String pipelineDiameter; - // 管材 - private String pipelineMaterial; - // 埋设方式 - private String buryMethod; - // 埋深 - private String buryDepth; - // 所属区域 - private String area; - // 所属线路 - private String line; - // 所属道路 - private String road; - // 建设年代 - private String constructTime; - // 权属单位 - private String owner; - //标识对象ID,无实际用途 - @Deprecated - private String objectId; - // 标识器ID - private String markerId; - // 标识器类型 - private String markerType; - // 标识器埋深 - private String markerDepth; - // 安装部门 - private String installationDept; - // 经度 - private String lng; - // 纬度 - private String lat; - //最后修改时间,更新时间 - private String updateTime; - // 备注信息 - private String remark; - // 下层管线类型 - private String underlyingPipelineType; - // 下层埋深 - private String underlyingPipelineDepth; - // 下层管径 - private String underlyingPipelineDiameter; - // 下层管材 - private String underlyingPipelineMaterial; - //标识对象类型 - private String objectType; - // 颜色 - private String color; - // 图片路径 - private String imagePath; - - @Generated(hash = 1479045776) - public MarkerLocalBean(Long id, String pipelineType, String pipelineDiameter, - String pipelineMaterial, String buryMethod, String buryDepth, - String area, String line, String road, String constructTime, - String owner, String objectId, String markerId, String markerType, - String markerDepth, String installationDept, String lng, String lat, - String updateTime, String remark, String underlyingPipelineType, - String underlyingPipelineDepth, String underlyingPipelineDiameter, - String underlyingPipelineMaterial, String objectType, String color, - String imagePath) { - this.id = id; - this.pipelineType = pipelineType; - this.pipelineDiameter = pipelineDiameter; - this.pipelineMaterial = pipelineMaterial; - this.buryMethod = buryMethod; - this.buryDepth = buryDepth; - this.area = area; - this.line = line; - this.road = road; - this.constructTime = constructTime; - this.owner = owner; - this.objectId = objectId; - this.markerId = markerId; - this.markerType = markerType; - this.markerDepth = markerDepth; - this.installationDept = installationDept; - this.lng = lng; - this.lat = lat; - this.updateTime = updateTime; - this.remark = remark; - this.underlyingPipelineType = underlyingPipelineType; - this.underlyingPipelineDepth = underlyingPipelineDepth; - this.underlyingPipelineDiameter = underlyingPipelineDiameter; - this.underlyingPipelineMaterial = underlyingPipelineMaterial; - this.objectType = objectType; - this.color = color; - this.imagePath = imagePath; - } - - @Generated(hash = 1538606012) - public MarkerLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getPipelineType() { - return this.pipelineType; - } - - public void setPipelineType(String pipelineType) { - this.pipelineType = pipelineType; - } - - public String getPipelineDiameter() { - return this.pipelineDiameter; - } - - public void setPipelineDiameter(String pipelineDiameter) { - this.pipelineDiameter = pipelineDiameter; - } - - public String getPipelineMaterial() { - return this.pipelineMaterial; - } - - public void setPipelineMaterial(String pipelineMaterial) { - this.pipelineMaterial = pipelineMaterial; - } - - public String getBuryMethod() { - return this.buryMethod; - } - - public void setBuryMethod(String buryMethod) { - this.buryMethod = buryMethod; - } - - public String getBuryDepth() { - return this.buryDepth; - } - - public void setBuryDepth(String buryDepth) { - this.buryDepth = buryDepth; - } - - public String getArea() { - return this.area; - } - - public void setArea(String area) { - this.area = area; - } - - public String getLine() { - return this.line; - } - - public void setLine(String line) { - this.line = line; - } - - public String getRoad() { - return this.road; - } - - public void setRoad(String road) { - this.road = road; - } - - public String getConstructTime() { - return this.constructTime; - } - - public void setConstructTime(String constructTime) { - this.constructTime = constructTime; - } - - public String getOwner() { - return this.owner; - } - - public void setOwner(String owner) { - this.owner = owner; - } - - public String getObjectId() { - return this.objectId; - } - - public void setObjectId(String objectId) { - this.objectId = objectId; - } - - public String getMarkerId() { - return this.markerId; - } - - public void setMarkerId(String markerId) { - this.markerId = markerId; - } - - public String getMarkerType() { - return this.markerType; - } - - public void setMarkerType(String markerType) { - this.markerType = markerType; - } - - public String getMarkerDepth() { - return this.markerDepth; - } - - public void setMarkerDepth(String markerDepth) { - this.markerDepth = markerDepth; - } - - public String getInstallationDept() { - return this.installationDept; - } - - public void setInstallationDept(String installationDept) { - this.installationDept = installationDept; - } - - public String getLng() { - return this.lng; - } - - public void setLng(String lng) { - this.lng = lng; - } - - public String getLat() { - return this.lat; - } - - public void setLat(String lat) { - this.lat = lat; - } - - public String getUpdateTime() { - return this.updateTime; - } - - public void setUpdateTime(String updateTime) { - this.updateTime = updateTime; - } - - public String getRemark() { - return this.remark; - } - - public void setRemark(String remark) { - this.remark = remark; - } - - public String getUnderlyingPipelineType() { - return this.underlyingPipelineType; - } - - public void setUnderlyingPipelineType(String underlyingPipelineType) { - this.underlyingPipelineType = underlyingPipelineType; - } - - public String getUnderlyingPipelineDepth() { - return this.underlyingPipelineDepth; - } - - public void setUnderlyingPipelineDepth(String underlyingPipelineDepth) { - this.underlyingPipelineDepth = underlyingPipelineDepth; - } - - public String getUnderlyingPipelineDiameter() { - return this.underlyingPipelineDiameter; - } - - public void setUnderlyingPipelineDiameter(String underlyingPipelineDiameter) { - this.underlyingPipelineDiameter = underlyingPipelineDiameter; - } - - public String getUnderlyingPipelineMaterial() { - return this.underlyingPipelineMaterial; - } - - public void setUnderlyingPipelineMaterial(String underlyingPipelineMaterial) { - this.underlyingPipelineMaterial = underlyingPipelineMaterial; - } - - public String getObjectType() { - return this.objectType; - } - - public void setObjectType(String objectType) { - this.objectType = objectType; - } - - public String getColor() { - return this.color; - } - - public void setColor(String color) { - this.color = color; - } - - public String getImagePath() { - return this.imagePath; - } - - public void setImagePath(String imagePath) { - this.imagePath = imagePath; - } -} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java new file mode 100644 index 0000000..5c88fdf --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java @@ -0,0 +1,93 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 巡检任务本地库实体类,不包含任务里面需要巡检的标识器信息 + */ +@Entity(tableName = "task_detail") +public class TaskBean { + @PrimaryKey(autoGenerate = true) + private long id;//主键ID + private String taskCode; // 任务编号 + private String description; // 任务名称 + private String createTime; // 任务创建的时间 + private String status; // 任务状态 + private String createUserName; // 任务创建者名称 + private String startTime; // 任务被开始执行的时间 + private String endTime; // 任务执行结束的时间 + private String isFree; // 是否自由巡检。1-是,0-否 + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getTaskCode() { + return taskCode; + } + + public void setTaskCode(String taskCode) { + this.taskCode = taskCode; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getCreateUserName() { + return createUserName; + } + + public void setCreateUserName(String createUserName) { + this.createUserName = createUserName; + } + + public String getStartTime() { + return startTime; + } + + public void setStartTime(String startTime) { + this.startTime = startTime; + } + + public String getEndTime() { + return endTime; + } + + public void setEndTime(String endTime) { + this.endTime = endTime; + } + + public String getIsFree() { + return isFree; + } + + public void setIsFree(String isFree) { + this.isFree = isFree; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java deleted file mode 100644 index 91737b3..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java +++ /dev/null @@ -1,114 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 巡检任务本地库实体类,不包含任务里面需要巡检的标识器信息 - */ -@Entity -public class TaskLocalBean { - @Id - private Long id;//任务ID - - private String taskCode;//任务编号 - private String description;//任务名称 - private String createTime;//任务创建的时间 - private String status;//任务状态 - private String createUserName;//任务创建者名称 - private String startTime;//任务被开始执行的时间 - private String endTime;//任务执行结束的时间 - private String isFreeTask;//是否自由巡检。1-是,0-否 - - @Generated(hash = 1482022528) - public TaskLocalBean(Long id, String taskCode, String description, - String createTime, String status, String createUserName, - String startTime, String endTime, String isFreeTask) { - this.id = id; - this.taskCode = taskCode; - this.description = description; - this.createTime = createTime; - this.status = status; - this.createUserName = createUserName; - this.startTime = startTime; - this.endTime = endTime; - this.isFreeTask = isFreeTask; - } - - @Generated(hash = 949704588) - public TaskLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getTaskCode() { - return this.taskCode; - } - - public void setTaskCode(String taskCode) { - this.taskCode = taskCode; - } - - public String getDescription() { - return this.description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getCreateTime() { - return this.createTime; - } - - public void setCreateTime(String createTime) { - this.createTime = createTime; - } - - public String getStatus() { - return this.status; - } - - public void setStatus(String status) { - this.status = status; - } - - public String getCreateUserName() { - return this.createUserName; - } - - public void setCreateUserName(String createUserName) { - this.createUserName = createUserName; - } - - public String getStartTime() { - return this.startTime; - } - - public void setStartTime(String startTime) { - this.startTime = startTime; - } - - public String getEndTime() { - return this.endTime; - } - - public void setEndTime(String endTime) { - this.endTime = endTime; - } - - public String getIsFreeTask() { - return this.isFreeTask; - } - - public void setIsFreeTask(String isFreeTask) { - this.isFreeTask = isFreeTask; - } -} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerBean.java new file mode 100644 index 0000000..c563a60 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerBean.java @@ -0,0 +1,110 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 巡检任务里面需要巡检的标识器信息本地库实体类 + */ +@Entity(tableName = "task_marker_info") +public class TaskMarkerBean { + //标识器后台库的主键ID,不是标识器实际ID + @PrimaryKey(autoGenerate = true) + private long id; + + /** + * 任务ID,通过此字段关联[TaskBean.id] + */ + private String taskId; + + /** + * 任务Code,通过此字段关联[TaskBean.taskCode] + *

+ *

+ * 双重验证,防止出现同时刻重复的情况 + */ + private String taskCode; + + /** + * 对应后台字段[TaskModel.MessageModel.TaskDetailInfosModel.markerIdReal],也就是探测仪扫描出来的ID + */ + private String markerId; + + private Double lng; + private Double lat; + + /** + * 是否已被探测到 + * 1-是,0-否 + */ + private String isDetected; + + /** + * 被探测到的时间,对应后台字段[TaskModel.MessageModel.TaskDetailInfosModel.finishTime] + */ + private String detectedTime; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getTaskId() { + return taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getTaskCode() { + return taskCode; + } + + public void setTaskCode(String taskCode) { + this.taskCode = taskCode; + } + + public String getMarkerId() { + return markerId; + } + + public void setMarkerId(String markerId) { + this.markerId = markerId; + } + + public Double getLng() { + return lng; + } + + public void setLng(Double lng) { + this.lng = lng; + } + + public Double getLat() { + return lat; + } + + public void setLat(Double lat) { + this.lat = lat; + } + + public String getIsDetected() { + return isDetected; + } + + public void setIsDetected(String isDetected) { + this.isDetected = isDetected; + } + + public String getDetectedTime() { + return detectedTime; + } + + public void setDetectedTime(String detectedTime) { + this.detectedTime = detectedTime; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerLocalBean.java deleted file mode 100644 index de9f459..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerLocalBean.java +++ /dev/null @@ -1,128 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import com.casic.common.detector.gd.model.TaskModel; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 巡检任务里面需要巡检的标识器信息本地库实体类 - */ -@Entity -public class TaskMarkerLocalBean { - @Id - private Long id;//标识器后台库的主键ID,不是标识器实际ID - - /** - * 任务ID,通过此字段关联{@link TaskLocalBean#id} - */ - private String taskId; - - /** - * 任务Code,通过此字段关联{@link TaskLocalBean#taskCode} - *

- * 双重验证,防止出现同时刻重复的情况 - */ - private String taskCode; - - /** - * 对应后台字段{@link TaskModel.MessageModel.TaskDetailInfosModel#markerIdReal},也就是探测仪扫描出来的ID - */ - private String markerId; - - private double lng; - private double lat; - - /** - * 是否已被探测到 - * 1-是,0-否 - */ - private String isDetected; - - /** - * 被探测到的时间,对应后台字段{@link TaskModel.MessageModel.TaskDetailInfosModel#finishTime} - */ - private String detectedTime; - - @Generated(hash = 677328533) - public TaskMarkerLocalBean(Long id, String taskId, String taskCode, String markerId, - double lng, double lat, String isDetected, String detectedTime) { - this.id = id; - this.taskId = taskId; - this.taskCode = taskCode; - this.markerId = markerId; - this.lng = lng; - this.lat = lat; - this.isDetected = isDetected; - this.detectedTime = detectedTime; - } - - @Generated(hash = 1162404642) - public TaskMarkerLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getTaskId() { - return this.taskId; - } - - public void setTaskId(String taskId) { - this.taskId = taskId; - } - - public String getTaskCode() { - return this.taskCode; - } - - public void setTaskCode(String taskCode) { - this.taskCode = taskCode; - } - - public String getMarkerId() { - return this.markerId; - } - - public void setMarkerId(String markerId) { - this.markerId = markerId; - } - - public double getLng() { - return this.lng; - } - - public void setLng(double lng) { - this.lng = lng; - } - - public double getLat() { - return this.lat; - } - - public void setLat(double lat) { - this.lat = lat; - } - - public String getIsDetected() { - return this.isDetected; - } - - public void setIsDetected(String isDetected) { - this.isDetected = isDetected; - } - - public String getDetectedTime() { - return this.detectedTime; - } - - public void setDetectedTime(String detectedTime) { - this.detectedTime = detectedTime; - } -} diff --git a/app/src/main/java/com/casic/common/detector/gd/dao/MarkerBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/dao/MarkerBeanDao.java new file mode 100644 index 0000000..2beb7ed --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/dao/MarkerBeanDao.java @@ -0,0 +1,29 @@ +package com.casic.common.detector.gd.dao; + +import androidx.room.Dao; +import androidx.room.Insert; +import androidx.room.Query; +import androidx.room.RawQuery; +import androidx.sqlite.db.SupportSQLiteQuery; + +import com.casic.common.detector.gd.bean.MarkerBean; + +import java.util.List; + +@Dao +public interface MarkerBeanDao { + @Query("DELETE FROM marker_detail") + void deleteAll(); + + @Insert + void insert(MarkerBean marker); + + @Query("SELECT * FROM marker_detail") + List loadAll(); + + @Query("SELECT * FROM marker_detail WHERE markerId = :markerId") + List queryMarkerById(String markerId); + + @RawQuery + List loadMarkersByCondition(SupportSQLiteQuery query); +} diff --git a/app/src/main/java/com/casic/common/detector/gd/dao/TaskBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/dao/TaskBeanDao.java new file mode 100644 index 0000000..9c70ac2 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/dao/TaskBeanDao.java @@ -0,0 +1,120 @@ +package com.casic.common.detector.gd.dao; + +import androidx.room.Dao; +import androidx.room.Insert; +import androidx.room.Query; +import androidx.room.Transaction; + +import com.casic.common.detector.gd.bean.TaskBean; +import com.casic.common.detector.gd.bean.TaskMarkerBean; +import com.casic.common.detector.gd.model.TaskDetailLocalModel; +import com.casic.common.detector.gd.model.TaskModel; +import com.casic.common.detector.gd.utils.LocaleConstant; +import com.pengxh.kt.lite.utils.SaveKeyValues; + +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Locale; + +@Dao +public interface TaskBeanDao { + @Query("SELECT COUNT(*) FROM task_detail WHERE id = :taskId") + int isTaskExist(long taskId); + + @Insert + void insert(TaskBean task); + + default void saveTask(Long taskId, String taskName) { + if (isTaskExist(taskId) == 0) { + TaskBean task = new TaskBean(); + task.setId(taskId); + task.setTaskCode(new SimpleDateFormat("yyyyMMddHHmmss", Locale.CHINA).format(new Date())); + task.setDescription(taskName); + String time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA).format(new Date()); + task.setCreateTime(time); + task.setStatus("0"); + String userName = (String) SaveKeyValues.INSTANCE.getValue(LocaleConstant.USER_NAME, ""); + task.setCreateUserName(userName); + task.setStartTime(time); + task.setEndTime(""); + task.setIsFree("1"); + insert(task); + } + } + + default void saveTask(TaskModel.MessageModel model) { + TaskBean task = new TaskBean(); + task.setId(model.getId()); + task.setTaskCode(model.getTaskCode()); + task.setDescription(model.getDescription()); + task.setCreateTime(model.getDeployDate()); + task.setStatus(model.getStatus()); + task.setCreateUserName(model.getCreatorName()); + task.setStartTime(model.getBeginDate()); + task.setEndTime(model.getEndDate()); + task.setIsFree("0"); + if (isTaskExist(task.getId()) == 0) { + insert(task); + } + } + + @Query("SELECT * FROM task_detail") + List loadAll(); + + @Transaction + default ArrayList loadLocalTask(TaskMarkerBeanDao taskMarkerBeanDao) { + ArrayList result = new ArrayList<>(); + List tasks = loadAll(); + for (TaskBean it : tasks) { + TaskDetailLocalModel model = new TaskDetailLocalModel(); + model.setTaskId(String.valueOf(it.getId())); + model.setTaskCode(it.getTaskCode()); + model.setDescription(it.getDescription()); + model.setCreateTime(it.getCreateTime()); + model.setStatus(it.getStatus()); + model.setCreateUserName(it.getCreateUserName()); + model.setIsFreeTask(it.getIsFree()); + ArrayList results = new ArrayList<>(); + if ("0".equals(it.getIsFree())) { + // 非自由巡检才有Marker + List markers = taskMarkerBeanDao.getMarkersByIdAndCode(String.valueOf(it.getId()), it.getTaskCode()); + for (TaskMarkerBean marker : markers) { + TaskDetailLocalModel.TaskMarkerLocalModel localModel = new TaskDetailLocalModel.TaskMarkerLocalModel(); + localModel.setMarkerId(marker.getMarkerId()); + localModel.setLng(marker.getLng()); + localModel.setLat(marker.getLat()); + localModel.setIsDetected(marker.getIsDetected()); + localModel.setDetectedTime(marker.getDetectedTime()); + + results.add(localModel); + } + } + model.setMarkerModels(results); + result.add(model); + } + return result; + } + + @Query("DELETE FROM task_detail WHERE id = :taskId AND taskCode = :taskCode") + void deleteTaskById(long taskId, String taskCode); + + @Transaction + default void deleteLocalTaskById(long taskId, String taskCode, TaskMarkerBeanDao taskMarkerBeanDao) { + TaskBean task = loadAll().stream() + .filter(it -> it.getId() == taskId && taskCode.equals(it.getTaskCode())) + .findFirst() + .orElse(null); + if (task == null) return; + deleteTaskById(taskId, taskCode); + + // 删除此任务关联的Marker。非自由巡检才有Marker + if ("0".equals(task.getIsFree())) { + List markers = taskMarkerBeanDao.getMarkersByIdAndCode(String.valueOf(task.getId()), task.getTaskCode()); + for (TaskMarkerBean marker : markers) { + taskMarkerBeanDao.delete(marker); + } + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/dao/TaskMarkerBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/dao/TaskMarkerBeanDao.java new file mode 100644 index 0000000..cc2156a --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/dao/TaskMarkerBeanDao.java @@ -0,0 +1,52 @@ +package com.casic.common.detector.gd.dao; + +import androidx.room.Dao; +import androidx.room.Delete; +import androidx.room.Insert; +import androidx.room.Query; +import androidx.room.Update; + +import com.casic.common.detector.gd.bean.TaskMarkerBean; +import com.casic.common.detector.gd.model.TaskModel; + +import java.util.List; + +@Dao +public interface TaskMarkerBeanDao { + + @Insert + void insert(TaskMarkerBean marker); + + @Query("SELECT COUNT(*) FROM task_marker_info WHERE id = :markerId") + int isMarkerExist(String markerId); + + default void saveTaskMarker(long taskId, String taskCode, TaskModel.MessageModel.TaskDetailInfosModel marker) { + if (isMarkerExist(marker.getMarkerId()) == 0) { + TaskMarkerBean bean = new TaskMarkerBean(); + bean.setId(marker.getId()); + bean.setTaskId(String.valueOf(taskId)); + bean.setTaskCode(taskCode); + bean.setMarkerId(marker.getMarkerIdReal()); + bean.setLng(marker.getLongitude()); + bean.setLat(marker.getLatitude()); + bean.setIsDetected("0"); + bean.setDetectedTime(""); + insert(bean); + } + } + + @Query("SELECT * FROM task_marker_info WHERE taskId = :taskId AND taskCode = :taskCode AND markerId = :markerId AND isDetected = :state") + TaskMarkerBean queryTaskMarkerById(String taskId, String taskCode, String markerId, String state); + + @Update + void updateLocalTaskMarkerState(TaskMarkerBean marker); + + @Query("SELECT * FROM task_marker_info WHERE isDetected = :state") + List queryMarkerByState(String state); + + @Query("SELECT * FROM task_marker_info WHERE taskId = :taskId AND taskCode = :taskCode") + List getMarkersByIdAndCode(String taskId, String taskCode); + + @Delete + void delete(TaskMarkerBean marker); +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/extensions/Long.kt b/app/src/main/java/com/casic/common/detector/gd/extensions/Long.kt deleted file mode 100644 index 6713d8d..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/extensions/Long.kt +++ /dev/null @@ -1,10 +0,0 @@ -package com.casic.common.detector.gd.extensions - -import java.text.SimpleDateFormat -import java.util.Date -import java.util.Locale - -fun Long.createTaskCode(): String { - val dateFormat = SimpleDateFormat("yyyyMMddHHmmss", Locale.CHINA) - return dateFormat.format(Date(this)) -} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoMaster.java b/app/src/main/java/com/casic/common/detector/gd/greendao/DaoMaster.java deleted file mode 100644 index 6ab94b3..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoMaster.java +++ /dev/null @@ -1,102 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import android.content.Context; -import android.database.sqlite.SQLiteDatabase; -import android.database.sqlite.SQLiteDatabase.CursorFactory; -import android.util.Log; - -import org.greenrobot.greendao.AbstractDaoMaster; -import org.greenrobot.greendao.database.StandardDatabase; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.database.DatabaseOpenHelper; -import org.greenrobot.greendao.identityscope.IdentityScopeType; - - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** - * Master of DAO (schema version 1): knows all DAOs. - */ -public class DaoMaster extends AbstractDaoMaster { - public static final int SCHEMA_VERSION = 1; - - /** Creates underlying database table using DAOs. */ - public static void createAllTables(Database db, boolean ifNotExists) { - MarkerLocalBeanDao.createTable(db, ifNotExists); - TaskLocalBeanDao.createTable(db, ifNotExists); - TaskMarkerLocalBeanDao.createTable(db, ifNotExists); - } - - /** Drops underlying database table using DAOs. */ - public static void dropAllTables(Database db, boolean ifExists) { - MarkerLocalBeanDao.dropTable(db, ifExists); - TaskLocalBeanDao.dropTable(db, ifExists); - TaskMarkerLocalBeanDao.dropTable(db, ifExists); - } - - /** - * WARNING: Drops all table on Upgrade! Use only during development. - * Convenience method using a {@link DevOpenHelper}. - */ - public static DaoSession newDevSession(Context context, String name) { - Database db = new DevOpenHelper(context, name).getWritableDb(); - DaoMaster daoMaster = new DaoMaster(db); - return daoMaster.newSession(); - } - - public DaoMaster(SQLiteDatabase db) { - this(new StandardDatabase(db)); - } - - public DaoMaster(Database db) { - super(db, SCHEMA_VERSION); - registerDaoClass(MarkerLocalBeanDao.class); - registerDaoClass(TaskLocalBeanDao.class); - registerDaoClass(TaskMarkerLocalBeanDao.class); - } - - public DaoSession newSession() { - return new DaoSession(db, IdentityScopeType.Session, daoConfigMap); - } - - public DaoSession newSession(IdentityScopeType type) { - return new DaoSession(db, type, daoConfigMap); - } - - /** - * Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} - - */ - public static abstract class OpenHelper extends DatabaseOpenHelper { - public OpenHelper(Context context, String name) { - super(context, name, SCHEMA_VERSION); - } - - public OpenHelper(Context context, String name, CursorFactory factory) { - super(context, name, factory, SCHEMA_VERSION); - } - - @Override - public void onCreate(Database db) { - Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION); - createAllTables(db, false); - } - } - - /** WARNING: Drops all table on Upgrade! Use only during development. */ - public static class DevOpenHelper extends OpenHelper { - public DevOpenHelper(Context context, String name) { - super(context, name); - } - - public DevOpenHelper(Context context, String name, CursorFactory factory) { - super(context, name, factory); - } - - @Override - public void onUpgrade(Database db, int oldVersion, int newVersion) { - Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables"); - dropAllTables(db, true); - onCreate(db); - } - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoSession.java b/app/src/main/java/com/casic/common/detector/gd/greendao/DaoSession.java deleted file mode 100644 index c8b1a20..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoSession.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import java.util.Map; - -import org.greenrobot.greendao.AbstractDao; -import org.greenrobot.greendao.AbstractDaoSession; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.identityscope.IdentityScopeType; -import org.greenrobot.greendao.internal.DaoConfig; - -import com.casic.common.detector.gd.bean.MarkerLocalBean; -import com.casic.common.detector.gd.bean.TaskLocalBean; -import com.casic.common.detector.gd.bean.TaskMarkerLocalBean; - -import com.casic.common.detector.gd.greendao.MarkerLocalBeanDao; -import com.casic.common.detector.gd.greendao.TaskLocalBeanDao; -import com.casic.common.detector.gd.greendao.TaskMarkerLocalBeanDao; - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. - -/** - * {@inheritDoc} - * - * @see org.greenrobot.greendao.AbstractDaoSession - */ -public class DaoSession extends AbstractDaoSession { - - private final DaoConfig markerLocalBeanDaoConfig; - private final DaoConfig taskLocalBeanDaoConfig; - private final DaoConfig taskMarkerLocalBeanDaoConfig; - - private final MarkerLocalBeanDao markerLocalBeanDao; - private final TaskLocalBeanDao taskLocalBeanDao; - private final TaskMarkerLocalBeanDao taskMarkerLocalBeanDao; - - public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> - daoConfigMap) { - super(db); - - markerLocalBeanDaoConfig = daoConfigMap.get(MarkerLocalBeanDao.class).clone(); - markerLocalBeanDaoConfig.initIdentityScope(type); - - taskLocalBeanDaoConfig = daoConfigMap.get(TaskLocalBeanDao.class).clone(); - taskLocalBeanDaoConfig.initIdentityScope(type); - - taskMarkerLocalBeanDaoConfig = daoConfigMap.get(TaskMarkerLocalBeanDao.class).clone(); - taskMarkerLocalBeanDaoConfig.initIdentityScope(type); - - markerLocalBeanDao = new MarkerLocalBeanDao(markerLocalBeanDaoConfig, this); - taskLocalBeanDao = new TaskLocalBeanDao(taskLocalBeanDaoConfig, this); - taskMarkerLocalBeanDao = new TaskMarkerLocalBeanDao(taskMarkerLocalBeanDaoConfig, this); - - registerDao(MarkerLocalBean.class, markerLocalBeanDao); - registerDao(TaskLocalBean.class, taskLocalBeanDao); - registerDao(TaskMarkerLocalBean.class, taskMarkerLocalBeanDao); - } - - public void clear() { - markerLocalBeanDaoConfig.clearIdentityScope(); - taskLocalBeanDaoConfig.clearIdentityScope(); - taskMarkerLocalBeanDaoConfig.clearIdentityScope(); - } - - public MarkerLocalBeanDao getMarkerLocalBeanDao() { - return markerLocalBeanDao; - } - - public TaskLocalBeanDao getTaskLocalBeanDao() { - return taskLocalBeanDao; - } - - public TaskMarkerLocalBeanDao getTaskMarkerLocalBeanDao() { - return taskMarkerLocalBeanDao; - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/MarkerLocalBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/greendao/MarkerLocalBeanDao.java deleted file mode 100644 index 2f792c3..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/MarkerLocalBeanDao.java +++ /dev/null @@ -1,479 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import android.database.Cursor; -import android.database.sqlite.SQLiteStatement; - -import org.greenrobot.greendao.AbstractDao; -import org.greenrobot.greendao.Property; -import org.greenrobot.greendao.internal.DaoConfig; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.database.DatabaseStatement; - -import com.casic.common.detector.gd.bean.MarkerLocalBean; - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** - * DAO for table "MARKER_LOCAL_BEAN". -*/ -public class MarkerLocalBeanDao extends AbstractDao { - - public static final String TABLENAME = "MARKER_LOCAL_BEAN"; - - /** - * Properties of entity MarkerLocalBean.
- * Can be used for QueryBuilder and for referencing column names. - */ - public static class Properties { - public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property PipelineType = new Property(1, String.class, "pipelineType", false, "PIPELINE_TYPE"); - public final static Property PipelineDiameter = new Property(2, String.class, "pipelineDiameter", false, "PIPELINE_DIAMETER"); - public final static Property PipelineMaterial = new Property(3, String.class, "pipelineMaterial", false, "PIPELINE_MATERIAL"); - public final static Property BuryMethod = new Property(4, String.class, "buryMethod", false, "BURY_METHOD"); - public final static Property BuryDepth = new Property(5, String.class, "buryDepth", false, "BURY_DEPTH"); - public final static Property Area = new Property(6, String.class, "area", false, "AREA"); - public final static Property Line = new Property(7, String.class, "line", false, "LINE"); - public final static Property Road = new Property(8, String.class, "road", false, "ROAD"); - public final static Property ConstructTime = new Property(9, String.class, "constructTime", false, "CONSTRUCT_TIME"); - public final static Property Owner = new Property(10, String.class, "owner", false, "OWNER"); - public final static Property ObjectId = new Property(11, String.class, "objectId", false, "OBJECT_ID"); - public final static Property MarkerId = new Property(12, String.class, "markerId", false, "MARKER_ID"); - public final static Property MarkerType = new Property(13, String.class, "markerType", false, "MARKER_TYPE"); - public final static Property MarkerDepth = new Property(14, String.class, "markerDepth", false, "MARKER_DEPTH"); - public final static Property InstallationDept = new Property(15, String.class, "installationDept", false, "INSTALLATION_DEPT"); - public final static Property Lng = new Property(16, String.class, "lng", false, "LNG"); - public final static Property Lat = new Property(17, String.class, "lat", false, "LAT"); - public final static Property UpdateTime = new Property(18, String.class, "updateTime", false, "UPDATE_TIME"); - public final static Property Remark = new Property(19, String.class, "remark", false, "REMARK"); - public final static Property UnderlyingPipelineType = new Property(20, String.class, "underlyingPipelineType", false, "UNDERLYING_PIPELINE_TYPE"); - public final static Property UnderlyingPipelineDepth = new Property(21, String.class, "underlyingPipelineDepth", false, "UNDERLYING_PIPELINE_DEPTH"); - public final static Property UnderlyingPipelineDiameter = new Property(22, String.class, "underlyingPipelineDiameter", false, "UNDERLYING_PIPELINE_DIAMETER"); - public final static Property UnderlyingPipelineMaterial = new Property(23, String.class, "underlyingPipelineMaterial", false, "UNDERLYING_PIPELINE_MATERIAL"); - public final static Property ObjectType = new Property(24, String.class, "objectType", false, "OBJECT_TYPE"); - public final static Property Color = new Property(25, String.class, "color", false, "COLOR"); - public final static Property ImagePath = new Property(26, String.class, "imagePath", false, "IMAGE_PATH"); - } - - - public MarkerLocalBeanDao(DaoConfig config) { - super(config); - } - - public MarkerLocalBeanDao(DaoConfig config, DaoSession daoSession) { - super(config, daoSession); - } - - /** Creates the underlying database table. */ - public static void createTable(Database db, boolean ifNotExists) { - String constraint = ifNotExists? "IF NOT EXISTS ": ""; - db.execSQL("CREATE TABLE " + constraint + "\"MARKER_LOCAL_BEAN\" (" + // - "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id - "\"PIPELINE_TYPE\" TEXT," + // 1: pipelineType - "\"PIPELINE_DIAMETER\" TEXT," + // 2: pipelineDiameter - "\"PIPELINE_MATERIAL\" TEXT," + // 3: pipelineMaterial - "\"BURY_METHOD\" TEXT," + // 4: buryMethod - "\"BURY_DEPTH\" TEXT," + // 5: buryDepth - "\"AREA\" TEXT," + // 6: area - "\"LINE\" TEXT," + // 7: line - "\"ROAD\" TEXT," + // 8: road - "\"CONSTRUCT_TIME\" TEXT," + // 9: constructTime - "\"OWNER\" TEXT," + // 10: owner - "\"OBJECT_ID\" TEXT," + // 11: objectId - "\"MARKER_ID\" TEXT," + // 12: markerId - "\"MARKER_TYPE\" TEXT," + // 13: markerType - "\"MARKER_DEPTH\" TEXT," + // 14: markerDepth - "\"INSTALLATION_DEPT\" TEXT," + // 15: installationDept - "\"LNG\" TEXT," + // 16: lng - "\"LAT\" TEXT," + // 17: lat - "\"UPDATE_TIME\" TEXT," + // 18: updateTime - "\"REMARK\" TEXT," + // 19: remark - "\"UNDERLYING_PIPELINE_TYPE\" TEXT," + // 20: underlyingPipelineType - "\"UNDERLYING_PIPELINE_DEPTH\" TEXT," + // 21: underlyingPipelineDepth - "\"UNDERLYING_PIPELINE_DIAMETER\" TEXT," + // 22: underlyingPipelineDiameter - "\"UNDERLYING_PIPELINE_MATERIAL\" TEXT," + // 23: underlyingPipelineMaterial - "\"OBJECT_TYPE\" TEXT," + // 24: objectType - "\"COLOR\" TEXT," + // 25: color - "\"IMAGE_PATH\" TEXT);"); // 26: imagePath - } - - /** Drops the underlying database table. */ - public static void dropTable(Database db, boolean ifExists) { - String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"MARKER_LOCAL_BEAN\""; - db.execSQL(sql); - } - - @Override - protected final void bindValues(DatabaseStatement stmt, MarkerLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String pipelineType = entity.getPipelineType(); - if (pipelineType != null) { - stmt.bindString(2, pipelineType); - } - - String pipelineDiameter = entity.getPipelineDiameter(); - if (pipelineDiameter != null) { - stmt.bindString(3, pipelineDiameter); - } - - String pipelineMaterial = entity.getPipelineMaterial(); - if (pipelineMaterial != null) { - stmt.bindString(4, pipelineMaterial); - } - - String buryMethod = entity.getBuryMethod(); - if (buryMethod != null) { - stmt.bindString(5, buryMethod); - } - - String buryDepth = entity.getBuryDepth(); - if (buryDepth != null) { - stmt.bindString(6, buryDepth); - } - - String area = entity.getArea(); - if (area != null) { - stmt.bindString(7, area); - } - - String line = entity.getLine(); - if (line != null) { - stmt.bindString(8, line); - } - - String road = entity.getRoad(); - if (road != null) { - stmt.bindString(9, road); - } - - String constructTime = entity.getConstructTime(); - if (constructTime != null) { - stmt.bindString(10, constructTime); - } - - String owner = entity.getOwner(); - if (owner != null) { - stmt.bindString(11, owner); - } - - String objectId = entity.getObjectId(); - if (objectId != null) { - stmt.bindString(12, objectId); - } - - String markerId = entity.getMarkerId(); - if (markerId != null) { - stmt.bindString(13, markerId); - } - - String markerType = entity.getMarkerType(); - if (markerType != null) { - stmt.bindString(14, markerType); - } - - String markerDepth = entity.getMarkerDepth(); - if (markerDepth != null) { - stmt.bindString(15, markerDepth); - } - - String installationDept = entity.getInstallationDept(); - if (installationDept != null) { - stmt.bindString(16, installationDept); - } - - String lng = entity.getLng(); - if (lng != null) { - stmt.bindString(17, lng); - } - - String lat = entity.getLat(); - if (lat != null) { - stmt.bindString(18, lat); - } - - String updateTime = entity.getUpdateTime(); - if (updateTime != null) { - stmt.bindString(19, updateTime); - } - - String remark = entity.getRemark(); - if (remark != null) { - stmt.bindString(20, remark); - } - - String underlyingPipelineType = entity.getUnderlyingPipelineType(); - if (underlyingPipelineType != null) { - stmt.bindString(21, underlyingPipelineType); - } - - String underlyingPipelineDepth = entity.getUnderlyingPipelineDepth(); - if (underlyingPipelineDepth != null) { - stmt.bindString(22, underlyingPipelineDepth); - } - - String underlyingPipelineDiameter = entity.getUnderlyingPipelineDiameter(); - if (underlyingPipelineDiameter != null) { - stmt.bindString(23, underlyingPipelineDiameter); - } - - String underlyingPipelineMaterial = entity.getUnderlyingPipelineMaterial(); - if (underlyingPipelineMaterial != null) { - stmt.bindString(24, underlyingPipelineMaterial); - } - - String objectType = entity.getObjectType(); - if (objectType != null) { - stmt.bindString(25, objectType); - } - - String color = entity.getColor(); - if (color != null) { - stmt.bindString(26, color); - } - - String imagePath = entity.getImagePath(); - if (imagePath != null) { - stmt.bindString(27, imagePath); - } - } - - @Override - protected final void bindValues(SQLiteStatement stmt, MarkerLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String pipelineType = entity.getPipelineType(); - if (pipelineType != null) { - stmt.bindString(2, pipelineType); - } - - String pipelineDiameter = entity.getPipelineDiameter(); - if (pipelineDiameter != null) { - stmt.bindString(3, pipelineDiameter); - } - - String pipelineMaterial = entity.getPipelineMaterial(); - if (pipelineMaterial != null) { - stmt.bindString(4, pipelineMaterial); - } - - String buryMethod = entity.getBuryMethod(); - if (buryMethod != null) { - stmt.bindString(5, buryMethod); - } - - String buryDepth = entity.getBuryDepth(); - if (buryDepth != null) { - stmt.bindString(6, buryDepth); - } - - String area = entity.getArea(); - if (area != null) { - stmt.bindString(7, area); - } - - String line = entity.getLine(); - if (line != null) { - stmt.bindString(8, line); - } - - String road = entity.getRoad(); - if (road != null) { - stmt.bindString(9, road); - } - - String constructTime = entity.getConstructTime(); - if (constructTime != null) { - stmt.bindString(10, constructTime); - } - - String owner = entity.getOwner(); - if (owner != null) { - stmt.bindString(11, owner); - } - - String objectId = entity.getObjectId(); - if (objectId != null) { - stmt.bindString(12, objectId); - } - - String markerId = entity.getMarkerId(); - if (markerId != null) { - stmt.bindString(13, markerId); - } - - String markerType = entity.getMarkerType(); - if (markerType != null) { - stmt.bindString(14, markerType); - } - - String markerDepth = entity.getMarkerDepth(); - if (markerDepth != null) { - stmt.bindString(15, markerDepth); - } - - String installationDept = entity.getInstallationDept(); - if (installationDept != null) { - stmt.bindString(16, installationDept); - } - - String lng = entity.getLng(); - if (lng != null) { - stmt.bindString(17, lng); - } - - String lat = entity.getLat(); - if (lat != null) { - stmt.bindString(18, lat); - } - - String updateTime = entity.getUpdateTime(); - if (updateTime != null) { - stmt.bindString(19, updateTime); - } - - String remark = entity.getRemark(); - if (remark != null) { - stmt.bindString(20, remark); - } - - String underlyingPipelineType = entity.getUnderlyingPipelineType(); - if (underlyingPipelineType != null) { - stmt.bindString(21, underlyingPipelineType); - } - - String underlyingPipelineDepth = entity.getUnderlyingPipelineDepth(); - if (underlyingPipelineDepth != null) { - stmt.bindString(22, underlyingPipelineDepth); - } - - String underlyingPipelineDiameter = entity.getUnderlyingPipelineDiameter(); - if (underlyingPipelineDiameter != null) { - stmt.bindString(23, underlyingPipelineDiameter); - } - - String underlyingPipelineMaterial = entity.getUnderlyingPipelineMaterial(); - if (underlyingPipelineMaterial != null) { - stmt.bindString(24, underlyingPipelineMaterial); - } - - String objectType = entity.getObjectType(); - if (objectType != null) { - stmt.bindString(25, objectType); - } - - String color = entity.getColor(); - if (color != null) { - stmt.bindString(26, color); - } - - String imagePath = entity.getImagePath(); - if (imagePath != null) { - stmt.bindString(27, imagePath); - } - } - - @Override - public Long readKey(Cursor cursor, int offset) { - return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); - } - - @Override - public MarkerLocalBean readEntity(Cursor cursor, int offset) { - MarkerLocalBean entity = new MarkerLocalBean( // - cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // pipelineType - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // pipelineDiameter - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // pipelineMaterial - cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // buryMethod - cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // buryDepth - cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // area - cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // line - cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // road - cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // constructTime - cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10), // owner - cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11), // objectId - cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12), // markerId - cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13), // markerType - cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14), // markerDepth - cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15), // installationDept - cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16), // lng - cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17), // lat - cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18), // updateTime - cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19), // remark - cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20), // underlyingPipelineType - cursor.isNull(offset + 21) ? null : cursor.getString(offset + 21), // underlyingPipelineDepth - cursor.isNull(offset + 22) ? null : cursor.getString(offset + 22), // underlyingPipelineDiameter - cursor.isNull(offset + 23) ? null : cursor.getString(offset + 23), // underlyingPipelineMaterial - cursor.isNull(offset + 24) ? null : cursor.getString(offset + 24), // objectType - cursor.isNull(offset + 25) ? null : cursor.getString(offset + 25), // color - cursor.isNull(offset + 26) ? null : cursor.getString(offset + 26) // imagePath - ); - return entity; - } - - @Override - public void readEntity(Cursor cursor, MarkerLocalBean entity, int offset) { - entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setPipelineType(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); - entity.setPipelineDiameter(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); - entity.setPipelineMaterial(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); - entity.setBuryMethod(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); - entity.setBuryDepth(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); - entity.setArea(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); - entity.setLine(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); - entity.setRoad(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); - entity.setConstructTime(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9)); - entity.setOwner(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); - entity.setObjectId(cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11)); - entity.setMarkerId(cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12)); - entity.setMarkerType(cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13)); - entity.setMarkerDepth(cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14)); - entity.setInstallationDept(cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15)); - entity.setLng(cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16)); - entity.setLat(cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17)); - entity.setUpdateTime(cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18)); - entity.setRemark(cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19)); - entity.setUnderlyingPipelineType(cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20)); - entity.setUnderlyingPipelineDepth(cursor.isNull(offset + 21) ? null : cursor.getString(offset + 21)); - entity.setUnderlyingPipelineDiameter(cursor.isNull(offset + 22) ? null : cursor.getString(offset + 22)); - entity.setUnderlyingPipelineMaterial(cursor.isNull(offset + 23) ? null : cursor.getString(offset + 23)); - entity.setObjectType(cursor.isNull(offset + 24) ? null : cursor.getString(offset + 24)); - entity.setColor(cursor.isNull(offset + 25) ? null : cursor.getString(offset + 25)); - entity.setImagePath(cursor.isNull(offset + 26) ? null : cursor.getString(offset + 26)); - } - - @Override - protected final Long updateKeyAfterInsert(MarkerLocalBean entity, long rowId) { - entity.setId(rowId); - return rowId; - } - - @Override - public Long getKey(MarkerLocalBean entity) { - if(entity != null) { - return entity.getId(); - } else { - return null; - } - } - - @Override - public boolean hasKey(MarkerLocalBean entity) { - return entity.getId() != null; - } - - @Override - protected final boolean isEntityUpdateable() { - return true; - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/TaskLocalBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/greendao/TaskLocalBeanDao.java deleted file mode 100644 index fb88157..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/TaskLocalBeanDao.java +++ /dev/null @@ -1,227 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import android.database.Cursor; -import android.database.sqlite.SQLiteStatement; - -import org.greenrobot.greendao.AbstractDao; -import org.greenrobot.greendao.Property; -import org.greenrobot.greendao.internal.DaoConfig; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.database.DatabaseStatement; - -import com.casic.common.detector.gd.bean.TaskLocalBean; - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** - * DAO for table "TASK_LOCAL_BEAN". -*/ -public class TaskLocalBeanDao extends AbstractDao { - - public static final String TABLENAME = "TASK_LOCAL_BEAN"; - - /** - * Properties of entity TaskLocalBean.
- * Can be used for QueryBuilder and for referencing column names. - */ - public static class Properties { - public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property TaskCode = new Property(1, String.class, "taskCode", false, "TASK_CODE"); - public final static Property Description = new Property(2, String.class, "description", false, "DESCRIPTION"); - public final static Property CreateTime = new Property(3, String.class, "createTime", false, "CREATE_TIME"); - public final static Property Status = new Property(4, String.class, "status", false, "STATUS"); - public final static Property CreateUserName = new Property(5, String.class, "createUserName", false, "CREATE_USER_NAME"); - public final static Property StartTime = new Property(6, String.class, "startTime", false, "START_TIME"); - public final static Property EndTime = new Property(7, String.class, "endTime", false, "END_TIME"); - public final static Property IsFreeTask = new Property(8, String.class, "isFreeTask", false, "IS_FREE_TASK"); - } - - - public TaskLocalBeanDao(DaoConfig config) { - super(config); - } - - public TaskLocalBeanDao(DaoConfig config, DaoSession daoSession) { - super(config, daoSession); - } - - /** Creates the underlying database table. */ - public static void createTable(Database db, boolean ifNotExists) { - String constraint = ifNotExists? "IF NOT EXISTS ": ""; - db.execSQL("CREATE TABLE " + constraint + "\"TASK_LOCAL_BEAN\" (" + // - "\"_id\" INTEGER PRIMARY KEY ," + // 0: id - "\"TASK_CODE\" TEXT," + // 1: taskCode - "\"DESCRIPTION\" TEXT," + // 2: description - "\"CREATE_TIME\" TEXT," + // 3: createTime - "\"STATUS\" TEXT," + // 4: status - "\"CREATE_USER_NAME\" TEXT," + // 5: createUserName - "\"START_TIME\" TEXT," + // 6: startTime - "\"END_TIME\" TEXT," + // 7: endTime - "\"IS_FREE_TASK\" TEXT);"); // 8: isFreeTask - } - - /** Drops the underlying database table. */ - public static void dropTable(Database db, boolean ifExists) { - String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"TASK_LOCAL_BEAN\""; - db.execSQL(sql); - } - - @Override - protected final void bindValues(DatabaseStatement stmt, TaskLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String taskCode = entity.getTaskCode(); - if (taskCode != null) { - stmt.bindString(2, taskCode); - } - - String description = entity.getDescription(); - if (description != null) { - stmt.bindString(3, description); - } - - String createTime = entity.getCreateTime(); - if (createTime != null) { - stmt.bindString(4, createTime); - } - - String status = entity.getStatus(); - if (status != null) { - stmt.bindString(5, status); - } - - String createUserName = entity.getCreateUserName(); - if (createUserName != null) { - stmt.bindString(6, createUserName); - } - - String startTime = entity.getStartTime(); - if (startTime != null) { - stmt.bindString(7, startTime); - } - - String endTime = entity.getEndTime(); - if (endTime != null) { - stmt.bindString(8, endTime); - } - - String isFreeTask = entity.getIsFreeTask(); - if (isFreeTask != null) { - stmt.bindString(9, isFreeTask); - } - } - - @Override - protected final void bindValues(SQLiteStatement stmt, TaskLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String taskCode = entity.getTaskCode(); - if (taskCode != null) { - stmt.bindString(2, taskCode); - } - - String description = entity.getDescription(); - if (description != null) { - stmt.bindString(3, description); - } - - String createTime = entity.getCreateTime(); - if (createTime != null) { - stmt.bindString(4, createTime); - } - - String status = entity.getStatus(); - if (status != null) { - stmt.bindString(5, status); - } - - String createUserName = entity.getCreateUserName(); - if (createUserName != null) { - stmt.bindString(6, createUserName); - } - - String startTime = entity.getStartTime(); - if (startTime != null) { - stmt.bindString(7, startTime); - } - - String endTime = entity.getEndTime(); - if (endTime != null) { - stmt.bindString(8, endTime); - } - - String isFreeTask = entity.getIsFreeTask(); - if (isFreeTask != null) { - stmt.bindString(9, isFreeTask); - } - } - - @Override - public Long readKey(Cursor cursor, int offset) { - return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); - } - - @Override - public TaskLocalBean readEntity(Cursor cursor, int offset) { - TaskLocalBean entity = new TaskLocalBean( // - cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // taskCode - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // description - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // createTime - cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // status - cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // createUserName - cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // startTime - cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // endTime - cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8) // isFreeTask - ); - return entity; - } - - @Override - public void readEntity(Cursor cursor, TaskLocalBean entity, int offset) { - entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setTaskCode(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); - entity.setDescription(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); - entity.setCreateTime(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); - entity.setStatus(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); - entity.setCreateUserName(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); - entity.setStartTime(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); - entity.setEndTime(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); - entity.setIsFreeTask(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); - } - - @Override - protected final Long updateKeyAfterInsert(TaskLocalBean entity, long rowId) { - entity.setId(rowId); - return rowId; - } - - @Override - public Long getKey(TaskLocalBean entity) { - if(entity != null) { - return entity.getId(); - } else { - return null; - } - } - - @Override - public boolean hasKey(TaskLocalBean entity) { - return entity.getId() != null; - } - - @Override - protected final boolean isEntityUpdateable() { - return true; - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/TaskMarkerLocalBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/greendao/TaskMarkerLocalBeanDao.java deleted file mode 100644 index e96c735..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/TaskMarkerLocalBeanDao.java +++ /dev/null @@ -1,197 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import android.database.Cursor; -import android.database.sqlite.SQLiteStatement; - -import org.greenrobot.greendao.AbstractDao; -import org.greenrobot.greendao.Property; -import org.greenrobot.greendao.internal.DaoConfig; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.database.DatabaseStatement; - -import com.casic.common.detector.gd.bean.TaskMarkerLocalBean; - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** - * DAO for table "TASK_MARKER_LOCAL_BEAN". -*/ -public class TaskMarkerLocalBeanDao extends AbstractDao { - - public static final String TABLENAME = "TASK_MARKER_LOCAL_BEAN"; - - /** - * Properties of entity TaskMarkerLocalBean.
- * Can be used for QueryBuilder and for referencing column names. - */ - public static class Properties { - public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property TaskId = new Property(1, String.class, "taskId", false, "TASK_ID"); - public final static Property TaskCode = new Property(2, String.class, "taskCode", false, "TASK_CODE"); - public final static Property MarkerId = new Property(3, String.class, "markerId", false, "MARKER_ID"); - public final static Property Lng = new Property(4, double.class, "lng", false, "LNG"); - public final static Property Lat = new Property(5, double.class, "lat", false, "LAT"); - public final static Property IsDetected = new Property(6, String.class, "isDetected", false, "IS_DETECTED"); - public final static Property DetectedTime = new Property(7, String.class, "detectedTime", false, "DETECTED_TIME"); - } - - - public TaskMarkerLocalBeanDao(DaoConfig config) { - super(config); - } - - public TaskMarkerLocalBeanDao(DaoConfig config, DaoSession daoSession) { - super(config, daoSession); - } - - /** Creates the underlying database table. */ - public static void createTable(Database db, boolean ifNotExists) { - String constraint = ifNotExists? "IF NOT EXISTS ": ""; - db.execSQL("CREATE TABLE " + constraint + "\"TASK_MARKER_LOCAL_BEAN\" (" + // - "\"_id\" INTEGER PRIMARY KEY ," + // 0: id - "\"TASK_ID\" TEXT," + // 1: taskId - "\"TASK_CODE\" TEXT," + // 2: taskCode - "\"MARKER_ID\" TEXT," + // 3: markerId - "\"LNG\" REAL NOT NULL ," + // 4: lng - "\"LAT\" REAL NOT NULL ," + // 5: lat - "\"IS_DETECTED\" TEXT," + // 6: isDetected - "\"DETECTED_TIME\" TEXT);"); // 7: detectedTime - } - - /** Drops the underlying database table. */ - public static void dropTable(Database db, boolean ifExists) { - String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"TASK_MARKER_LOCAL_BEAN\""; - db.execSQL(sql); - } - - @Override - protected final void bindValues(DatabaseStatement stmt, TaskMarkerLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String taskId = entity.getTaskId(); - if (taskId != null) { - stmt.bindString(2, taskId); - } - - String taskCode = entity.getTaskCode(); - if (taskCode != null) { - stmt.bindString(3, taskCode); - } - - String markerId = entity.getMarkerId(); - if (markerId != null) { - stmt.bindString(4, markerId); - } - stmt.bindDouble(5, entity.getLng()); - stmt.bindDouble(6, entity.getLat()); - - String isDetected = entity.getIsDetected(); - if (isDetected != null) { - stmt.bindString(7, isDetected); - } - - String detectedTime = entity.getDetectedTime(); - if (detectedTime != null) { - stmt.bindString(8, detectedTime); - } - } - - @Override - protected final void bindValues(SQLiteStatement stmt, TaskMarkerLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String taskId = entity.getTaskId(); - if (taskId != null) { - stmt.bindString(2, taskId); - } - - String taskCode = entity.getTaskCode(); - if (taskCode != null) { - stmt.bindString(3, taskCode); - } - - String markerId = entity.getMarkerId(); - if (markerId != null) { - stmt.bindString(4, markerId); - } - stmt.bindDouble(5, entity.getLng()); - stmt.bindDouble(6, entity.getLat()); - - String isDetected = entity.getIsDetected(); - if (isDetected != null) { - stmt.bindString(7, isDetected); - } - - String detectedTime = entity.getDetectedTime(); - if (detectedTime != null) { - stmt.bindString(8, detectedTime); - } - } - - @Override - public Long readKey(Cursor cursor, int offset) { - return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); - } - - @Override - public TaskMarkerLocalBean readEntity(Cursor cursor, int offset) { - TaskMarkerLocalBean entity = new TaskMarkerLocalBean( // - cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // taskId - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // taskCode - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // markerId - cursor.getDouble(offset + 4), // lng - cursor.getDouble(offset + 5), // lat - cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // isDetected - cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7) // detectedTime - ); - return entity; - } - - @Override - public void readEntity(Cursor cursor, TaskMarkerLocalBean entity, int offset) { - entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setTaskId(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); - entity.setTaskCode(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); - entity.setMarkerId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); - entity.setLng(cursor.getDouble(offset + 4)); - entity.setLat(cursor.getDouble(offset + 5)); - entity.setIsDetected(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); - entity.setDetectedTime(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); - } - - @Override - protected final Long updateKeyAfterInsert(TaskMarkerLocalBean entity, long rowId) { - entity.setId(rowId); - return rowId; - } - - @Override - public Long getKey(TaskMarkerLocalBean entity) { - if(entity != null) { - return entity.getId(); - } else { - return null; - } - } - - @Override - public boolean hasKey(TaskMarkerLocalBean entity) { - return entity.getId() != null; - } - - @Override - protected final boolean isEntityUpdateable() { - return true; - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/model/TaskModel.java b/app/src/main/java/com/casic/common/detector/gd/model/TaskModel.java index 6e853ad..67ef5fb 100644 --- a/app/src/main/java/com/casic/common/detector/gd/model/TaskModel.java +++ b/app/src/main/java/com/casic/common/detector/gd/model/TaskModel.java @@ -24,7 +24,7 @@ } public static class MessageModel { - private int id; + private Long id; private String taskCode; private String description; private String deployDate; @@ -38,11 +38,11 @@ private int isValid; private List taskDetailInfos; - public int getId() { + public Long getId() { return id; } - public void setId(int id) { + public void setId(Long id) { this.id = id; } @@ -143,25 +143,25 @@ } public static class TaskDetailInfosModel { - private int id; + private long id; private String taskId; private String taskCode; private Object markerName; - private int markerId; + private String markerId; private String markerIdReal; private double longitude; private double latitude; private int isChecked; private int isNormal; - private Object imagePath; - private Object description; - private Object finishTime; + private String imagePath; + private String description; + private String finishTime; - public int getId() { + public long getId() { return id; } - public void setId(int id) { + public void setId(long id) { this.id = id; } @@ -189,11 +189,11 @@ this.markerName = markerName; } - public int getMarkerId() { + public String getMarkerId() { return markerId; } - public void setMarkerId(int markerId) { + public void setMarkerId(String markerId) { this.markerId = markerId; } @@ -237,27 +237,27 @@ this.isNormal = isNormal; } - public Object getImagePath() { + public String getImagePath() { return imagePath; } - public void setImagePath(Object imagePath) { + public void setImagePath(String imagePath) { this.imagePath = imagePath; } - public Object getDescription() { + public String getDescription() { return description; } - public void setDescription(Object description) { + public void setDescription(String description) { this.description = description; } - public Object getFinishTime() { + public String getFinishTime() { return finishTime; } - public void setFinishTime(Object finishTime) { + public void setFinishTime(String finishTime) { this.finishTime = finishTime; } } diff --git a/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitService.kt index 7522a87..0adad51 100644 --- a/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitService.kt @@ -50,7 +50,7 @@ */ @Multipart @POST("/ems/marker/save-marker-photo.do") - suspend fun installLabel( + suspend fun install( @PartMap jsonMarker: Map, @Part fileBuffer1: MultipartBody.Part?, @Part fileBuffer2: MultipartBody.Part?, diff --git a/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitServiceManager.kt index 5f6c701..ae2a0fa 100644 --- a/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitServiceManager.kt +++ b/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitServiceManager.kt @@ -37,22 +37,28 @@ /** * 获取标识器信息文件 */ - suspend fun getMarkerFile(userId: String, companyId: String): String { - return createApi().getMarkerFile(userId, companyId) + suspend fun getMarkerFile(): String { + val companyId = SaveKeyValues.getValue(LocaleConstant.USER_COMPANY_ID, "") as String + /** + * 后台设计如此,都传companyId + * */ + return createApi().getMarkerFile(companyId, companyId) } /** * 获取巡检工单 */ - suspend fun getTasksByUser(userName: String): String { + suspend fun getTasksByUser(): String { + val userName = SaveKeyValues.getValue(LocaleConstant.USER_NAME, "") as String return createApi().getTasksByUser(userName) } /** * 提交工单 */ - suspend fun uploadTask(userId: String, taskId: String?, state: String): String { + suspend fun uploadTask(taskId: String?, state: String): String { + val userId = SaveKeyValues.getValue(LocaleConstant.USER_ID, "") as String return createApi().uploadTask(userId, taskId.toString(), state) } @@ -60,8 +66,7 @@ * 安装新标识器 * Multipart上传图片,文件,带多参数上传 */ - suspend fun installLabel( - companyId: String, + suspend fun installMarker( recordType: String, markerObjectType: String, pipeMaterial: String, @@ -77,7 +82,6 @@ road: String, constructTime: String, ownerComp: String, - markerObjectId: String, markerId: String, markerType: String, markerDepth: String, @@ -89,6 +93,8 @@ memo: String, realPaths: ArrayList ): String { + val companyId = SaveKeyValues.getValue(LocaleConstant.USER_COMPANY_ID, "") as String + val objectId = SaveKeyValues.getValue(LocaleConstant.OBJECT_ID, "") as String val param = JsonObject() param.addProperty("companyId", companyId) param.addProperty("recordType", recordType) @@ -106,7 +112,7 @@ param.addProperty("road", road) param.addProperty("constructTime", constructTime) param.addProperty("ownerComp", ownerComp) - param.addProperty("markerObjectId", markerObjectId) + param.addProperty("markerObjectId", objectId) param.addProperty("markerId", markerId) param.addProperty("markerType", markerType) param.addProperty("markerDepth", markerDepth) @@ -133,19 +139,19 @@ return when (multiParts.size) { 3 -> { - createApi().installLabel(res, multiParts[0], multiParts[1], multiParts[2]) + createApi().install(res, multiParts[0], multiParts[1], multiParts[2]) } 2 -> { - createApi().installLabel(res, multiParts[0], multiParts[1], null) + createApi().install(res, multiParts[0], multiParts[1], null) } 1 -> { - createApi().installLabel(res, multiParts[0], null, null) + createApi().install(res, multiParts[0], null, null) } else -> { - createApi().installLabel(res, null, null, null) + createApi().install(res, null, null, null) } } } @@ -216,7 +222,7 @@ /** * 上传自由巡检过程中发现的标识器 */ - suspend fun uploadTaskMarker(taskId: String, ids: ArrayList): String { + suspend fun uploadTaskMarker(taskId: Long, ids: ArrayList): String { val param = JsonObject() param.addProperty("taskId", taskId) param.addProperty("ids", ids.joinToString(separator = ",")) diff --git a/app/src/main/java/com/casic/common/detector/gd/service/NtripConnectService.kt b/app/src/main/java/com/casic/common/detector/gd/service/NtripConnectService.kt index de9ac80..20e1a6a 100644 --- a/app/src/main/java/com/casic/common/detector/gd/service/NtripConnectService.kt +++ b/app/src/main/java/com/casic/common/detector/gd/service/NtripConnectService.kt @@ -9,10 +9,6 @@ import android.util.Log import android.view.Gravity import android.widget.Toast -import androidx.lifecycle.Lifecycle -import androidx.lifecycle.LifecycleOwner -import androidx.lifecycle.LifecycleRegistry -import androidx.lifecycle.lifecycleScope import com.casic.common.detector.gd.base.BaseApplication import com.casic.common.detector.gd.extensions.convertToGPGGA import com.casic.common.detector.gd.utils.LocaleConstant @@ -23,26 +19,24 @@ import com.pengxh.kt.lite.utils.WeakReferenceHandler import com.pengxh.kt.lite.utils.socket.tcp.OnTcpConnectStateListener import com.pengxh.kt.lite.utils.socket.tcp.TcpClient +import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.Job import kotlinx.coroutines.launch import java.io.OutputStream import java.nio.charset.StandardCharsets -class NtripConnectService : Service(), LifecycleOwner, OnTcpConnectStateListener, Handler.Callback { +class NtripConnectService : Service(), OnTcpConnectStateListener, Handler.Callback { companion object { var weakReferenceHandler: WeakReferenceHandler? = null } private val kTag = "NtripConnectService" - private val registry = LifecycleRegistry(this) private val socketClient by lazy { TcpClient(this) } private var outStream: OutputStream? = null - - override fun getLifecycle(): Lifecycle { - return registry - } + private val serviceScope = CoroutineScope(Dispatchers.Main + Job()) // 创建一个独立的CoroutineScope override fun onBind(intent: Intent?): IBinder? { return null @@ -117,7 +111,7 @@ * */ val result = String(this, StandardCharsets.UTF_8) if (result.contains("ICY 200 OK")) { - lifecycleScope.launch(Dispatchers.Main) { + serviceScope.launch { "高精度定位服务连接成功".show(this@NtripConnectService) } //连接服务即打开串口 @@ -135,12 +129,12 @@ * Content-Type: text/plain * Connection: clos * */ - lifecycleScope.launch(Dispatchers.Main) { + serviceScope.launch { "差分定位服务鉴权失败,无法解析位置".show(this@NtripConnectService) } } else { //居中显示 - lifecycleScope.launch(Dispatchers.Main) { + serviceScope.launch { val toast = Toast.makeText( this@NtripConnectService, "收到千寻数据,长度:${size}", Toast.LENGTH_SHORT ) @@ -167,7 +161,7 @@ return } - lifecycleScope.launch(Dispatchers.IO) { + serviceScope.launch(Dispatchers.IO) { socketClient.start(remoteHost, remotePort.toInt()) } } diff --git a/app/src/main/java/com/casic/common/detector/gd/utils/DataBaseManager.kt b/app/src/main/java/com/casic/common/detector/gd/utils/DataBaseManager.kt deleted file mode 100644 index aa22759..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/utils/DataBaseManager.kt +++ /dev/null @@ -1,200 +0,0 @@ -package com.casic.common.detector.gd.utils - -import com.casic.common.detector.gd.base.BaseApplication -import com.casic.common.detector.gd.bean.MarkerLocalBean -import com.casic.common.detector.gd.bean.TaskLocalBean -import com.casic.common.detector.gd.bean.TaskMarkerLocalBean -import com.casic.common.detector.gd.greendao.MarkerLocalBeanDao -import com.casic.common.detector.gd.greendao.TaskLocalBeanDao -import com.casic.common.detector.gd.greendao.TaskMarkerLocalBeanDao -import com.casic.common.detector.gd.model.TaskDetailLocalModel -import com.casic.common.detector.gd.model.TaskModel - -class DataBaseManager private constructor() { - companion object { - //Kotlin委托模式双重锁单例 - val get by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) { - DataBaseManager() - } - } - - private var taskLocalBeanDao = BaseApplication.get().getDaoSession().taskLocalBeanDao - private var taskMarkerLocalBeanDao = - BaseApplication.get().getDaoSession().taskMarkerLocalBeanDao - - fun saveTaskInLocale(task: TaskModel.MessageModel) { - val bean = TaskLocalBean() - bean.id = task.id.toLong() - bean.taskCode = task.taskCode - bean.description = task.description - bean.createTime = task.deployDate - bean.status = task.status - bean.createUserName = task.creatorName - if (task.beginDate == null) { - bean.startTime = "" - } - if (task.endDate == null) { - bean.endTime = "" - } - bean.isFreeTask = "0" - if (!bean.isExist()) { - taskLocalBeanDao.insert(bean) - } - } - - fun saveTaskInLocale(bean: TaskLocalBean) { - if (!bean.isExist()) { - taskLocalBeanDao.insert(bean) - } - } - - private fun TaskLocalBean.isExist(): Boolean { - val result = taskLocalBeanDao.queryBuilder().where( - TaskLocalBeanDao.Properties.Id.eq(this.id) - ).list() - return !result.isNullOrEmpty() - } - - fun saveTaskMarkerInLocale( - taskId: Int, taskCode: String, marker: TaskModel.MessageModel.TaskDetailInfosModel - ) { - val bean = TaskMarkerLocalBean() - bean.id = marker.id.toLong() - bean.taskId = taskId.toString() - bean.taskCode = taskCode - bean.markerId = marker.markerIdReal - bean.lng = marker.longitude - bean.lat = marker.latitude - bean.isDetected = "0" - bean.detectedTime = "" - if (!bean.isExist()) { - taskMarkerLocalBeanDao.insert(bean) - } - } - - private fun TaskMarkerLocalBean.isExist(): Boolean { - val result = taskMarkerLocalBeanDao.queryBuilder().where( - TaskMarkerLocalBeanDao.Properties.Id.eq(this.id) - ).list() - return !result.isNullOrEmpty() - } - - fun loadLocalTask(): ArrayList { - val result = ArrayList() - - val tasks = taskLocalBeanDao.loadAll() - tasks.forEach { - val model = TaskDetailLocalModel() - model.taskId = it.id.toString() - model.taskCode = it.taskCode - model.description = it.description - model.createTime = it.createTime - model.status = it.status - model.createUserName = it.createUserName - model.isFreeTask = it.isFreeTask - - val markers = ArrayList() - if (it.isFreeTask == "0") { - //非自由巡检才有Marker - val markerLocalBeans = taskMarkerLocalBeanDao.queryBuilder().where( - TaskMarkerLocalBeanDao.Properties.TaskId.eq(it.id), - TaskMarkerLocalBeanDao.Properties.TaskCode.eq(it.taskCode) - ).list() - markerLocalBeans.forEach { marker -> - val localModel = TaskDetailLocalModel.TaskMarkerLocalModel() - localModel.markerId = marker.markerId - localModel.lng = marker.lng - localModel.lat = marker.lat - localModel.isDetected = marker.isDetected - localModel.detectedTime = marker.detectedTime - - markers.add(localModel) - } - } - model.markerModels = markers - result.add(model) - } - return result - } - - fun deleteLocalTaskById(taskId: String, taskCode: String) { - val task = taskLocalBeanDao.queryBuilder().where( - TaskLocalBeanDao.Properties.Id.eq(taskId), - TaskLocalBeanDao.Properties.TaskCode.eq(taskCode) - ).list().firstOrNull() ?: return - taskLocalBeanDao.delete(task) - - //删除此任务关联的Marker。非自由巡检才有Marker - if (task.isFreeTask == "0") { - val markers = taskMarkerLocalBeanDao.queryBuilder() - .where( - TaskMarkerLocalBeanDao.Properties.TaskId.eq(taskId), - TaskMarkerLocalBeanDao.Properties.TaskCode.eq(taskCode) - ).list() - markers.forEach { - taskMarkerLocalBeanDao.delete(it) - } - } - } - - fun queryTaskMarkerById( - taskId: String, taskCode: String, markerId: String, state: String - ): TaskMarkerLocalBean? { - return taskMarkerLocalBeanDao.queryBuilder() - .where( - TaskMarkerLocalBeanDao.Properties.TaskId.eq(taskId), - TaskMarkerLocalBeanDao.Properties.TaskCode.eq(taskCode), - TaskMarkerLocalBeanDao.Properties.MarkerId.eq(markerId), - TaskMarkerLocalBeanDao.Properties.IsDetected.eq(state) - ).list().firstOrNull() - } - - fun updateLocalTaskMarkerState(marker: TaskMarkerLocalBean) { - marker.isDetected = "1" - taskMarkerLocalBeanDao.update(marker) - } - - fun queryMarkerByState(state: String): List { - return taskMarkerLocalBeanDao.queryBuilder() - .where(TaskMarkerLocalBeanDao.Properties.IsDetected.eq(state)) - .list() - } - - private var markerLocalBeanDao = BaseApplication.get().getDaoSession().markerLocalBeanDao - - fun clearMarkers() { - markerLocalBeanDao.deleteAll() - } - - fun saveMarkerInLocale(bean: MarkerLocalBean) { - markerLocalBeanDao.insert(bean) - } - - fun loadMarkers(): MutableList { - return markerLocalBeanDao.loadAll() - } - - fun loadMarkersByCondition(selectedItem: String, value: String?): MutableList { - val property = when (selectedItem) { - LocaleConstant.SPINNER_ARRAY[0] -> MarkerLocalBeanDao.Properties.MarkerId - LocaleConstant.SPINNER_ARRAY[1] -> MarkerLocalBeanDao.Properties.Area - LocaleConstant.SPINNER_ARRAY[2] -> MarkerLocalBeanDao.Properties.Line - LocaleConstant.SPINNER_ARRAY[3] -> MarkerLocalBeanDao.Properties.Road - LocaleConstant.SPINNER_ARRAY[4] -> MarkerLocalBeanDao.Properties.Owner - LocaleConstant.SPINNER_ARRAY[5] -> MarkerLocalBeanDao.Properties.InstallationDept - LocaleConstant.SPINNER_ARRAY[6] -> MarkerLocalBeanDao.Properties.UpdateTime - else -> MarkerLocalBeanDao.Properties.Remark - } - return if (value == null) { - markerLocalBeanDao.queryBuilder().where(property.isNotNull).list() - } else { - markerLocalBeanDao.queryBuilder().where(property.eq(value)).list() - } - } - - fun queryMarkerById(markerId: String): List { - return markerLocalBeanDao.queryBuilder() - .where(MarkerLocalBeanDao.Properties.MarkerId.eq(markerId)) - .list() - } -} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/utils/DetectorDataBase.java b/app/src/main/java/com/casic/common/detector/gd/utils/DetectorDataBase.java new file mode 100644 index 0000000..f686cac --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/utils/DetectorDataBase.java @@ -0,0 +1,21 @@ +package com.casic.common.detector.gd.utils; + +import androidx.room.Database; +import androidx.room.RoomDatabase; + +import com.casic.common.detector.gd.bean.MarkerBean; +import com.casic.common.detector.gd.bean.TaskBean; +import com.casic.common.detector.gd.bean.TaskMarkerBean; +import com.casic.common.detector.gd.dao.MarkerBeanDao; +import com.casic.common.detector.gd.dao.TaskBeanDao; +import com.casic.common.detector.gd.dao.TaskMarkerBeanDao; + + +@Database(entities = {MarkerBean.class, TaskBean.class, TaskMarkerBean.class}, version = 1) +public abstract class DetectorDataBase extends RoomDatabase { + public abstract MarkerBeanDao markerBeanDao(); + + public abstract TaskBeanDao taskBeanDao(); + + public abstract TaskMarkerBeanDao taskMarkerBeanDao(); +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/utils/ExcelKit.kt b/app/src/main/java/com/casic/common/detector/gd/utils/ExcelKit.kt index 200fac7..015969f 100644 --- a/app/src/main/java/com/casic/common/detector/gd/utils/ExcelKit.kt +++ b/app/src/main/java/com/casic/common/detector/gd/utils/ExcelKit.kt @@ -1,19 +1,19 @@ package com.casic.common.detector.gd.utils -import com.casic.common.detector.gd.bean.MarkerLocalBean +import com.casic.common.detector.gd.base.BaseApplication +import com.casic.common.detector.gd.bean.MarkerBean import jxl.Workbook import jxl.read.biff.BiffException import java.io.File object ExcelKit { - fun read(filePath: String): ArrayList { - val result = ArrayList() + fun read(filePath: String): ArrayList { + val result = ArrayList() try { val workbook = Workbook.getWorkbook(File(filePath)) val sheet = workbook.getSheet(0) - for (i in 1 until sheet.rows) { - val marker = MarkerLocalBean() + val marker = MarkerBean() marker.pipelineType = sheet.getCell(0, i).contents marker.pipelineDiameter = sheet.getCell(1, i).contents marker.pipelineMaterial = sheet.getCell(2, i).contents @@ -40,9 +40,10 @@ marker.objectType = sheet.getCell(23, i).contents marker.color = sheet.getCell(24, i).contents marker.imagePath = sheet.getCell(25, i).contents - - result.add(marker) - DataBaseManager.get.saveMarkerInLocale(marker) + if (!marker.markerId.isNullOrBlank()) { + result.add(marker) + BaseApplication.get().dataBase.markerBeanDao().insert(marker) + } } workbook.close() } catch (e: BiffException) { diff --git a/app/src/main/java/com/casic/common/detector/gd/utils/LocaleConstant.kt b/app/src/main/java/com/casic/common/detector/gd/utils/LocaleConstant.kt index c658924..8ac5f76 100644 --- a/app/src/main/java/com/casic/common/detector/gd/utils/LocaleConstant.kt +++ b/app/src/main/java/com/casic/common/detector/gd/utils/LocaleConstant.kt @@ -1,6 +1,8 @@ package com.casic.common.detector.gd.utils import android.Manifest +import androidx.sqlite.db.SimpleSQLiteQuery +import androidx.sqlite.db.SupportSQLiteQuery object LocaleConstant { @@ -59,4 +61,19 @@ var BURY_METHOD_ARRAY = arrayOf("直埋", "圆管", "管块", "管沟", "架空") var IDENTIFIER_TYPE_ARRAY = arrayOf("EM30", "EM50", "EM14") var COLOR_ARRAY = arrayOf("蓝色", "橙色", "红色", "黑色", "紫色", "黄色", "绿色") + + fun buildQuery(selectedItem: String, value: String): SupportSQLiteQuery { + val columnName = when (selectedItem) { + SPINNER_ARRAY[0] -> "markerId" + SPINNER_ARRAY[1] -> "area" + SPINNER_ARRAY[2] -> "line" + SPINNER_ARRAY[3] -> "road" + SPINNER_ARRAY[4] -> "owner" + SPINNER_ARRAY[5] -> "installationDept" + SPINNER_ARRAY[6] -> "updateTime" + else -> "remark" + } + val queryBuilder = StringBuilder("SELECT * FROM marker_detail WHERE $columnName = ?") + return SimpleSQLiteQuery(queryBuilder.toString(), arrayOf(value)) + } } \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/view/InstallMarkerActivity.kt b/app/src/main/java/com/casic/common/detector/gd/view/InstallMarkerActivity.kt index daf5b0f..9e09df1 100644 --- a/app/src/main/java/com/casic/common/detector/gd/view/InstallMarkerActivity.kt +++ b/app/src/main/java/com/casic/common/detector/gd/view/InstallMarkerActivity.kt @@ -14,8 +14,9 @@ import com.amap.api.location.AMapLocation import com.casic.common.detector.gd.R import com.casic.common.detector.gd.adapter.EditableImageAdapter +import com.casic.common.detector.gd.base.BaseApplication import com.casic.common.detector.gd.base.SerialPortBaseActivity -import com.casic.common.detector.gd.bean.MarkerLocalBean +import com.casic.common.detector.gd.bean.MarkerBean import com.casic.common.detector.gd.callback.OnGetLocationListener import com.casic.common.detector.gd.callback.OnImageCompressListener import com.casic.common.detector.gd.databinding.ActivityInstallMarkerBinding @@ -27,7 +28,6 @@ import com.casic.common.detector.gd.extensions.toColor import com.casic.common.detector.gd.extensions.toObjectType import com.casic.common.detector.gd.utils.CurrentSegment -import com.casic.common.detector.gd.utils.DataBaseManager import com.casic.common.detector.gd.utils.LocaleConstant import com.casic.common.detector.gd.utils.LocationKit import com.casic.common.detector.gd.utils.RuntimeCache @@ -44,7 +44,6 @@ import com.pengxh.kt.lite.extensions.timestampToCompleteDate import com.pengxh.kt.lite.extensions.timestampToTime import com.pengxh.kt.lite.extensions.toJson -import com.pengxh.kt.lite.utils.LoadState import com.pengxh.kt.lite.utils.LoadingDialog import com.pengxh.kt.lite.utils.SaveKeyValues import com.pengxh.kt.lite.widget.TitleBarView @@ -115,8 +114,6 @@ //安装 binding.installButton.setOnClickListener { - val companyId = SaveKeyValues.getValue(LocaleConstant.USER_COMPANY_ID, "") as String - val objectId = SaveKeyValues.getValue(LocaleConstant.OBJECT_ID, "") as String if (binding.objectInclude.pipeInclude.markerObjectTypeView.text.isNullOrBlank()) { when (binding.objectInclude.objectTypeSpinner.selectedItem.toString()) { "管线" -> "请输入管线种类!".show(this) @@ -189,8 +186,7 @@ //先存本地再上传服务器 saveMarkerInLocal() - taskViewModel.installLabel( - this, companyId, + taskViewModel.installMarker( binding.objectInclude.objectTypeSpinner.selectedItem.toString().toObjectType(), binding.objectInclude.pipeInclude.markerObjectTypeView.text.toString(), binding.objectInclude.pipeInclude.materialSpinner.selectedItem.toString(), @@ -206,7 +202,6 @@ binding.objectInclude.roadView.text.toString(), binding.objectInclude.constructDateView.text.toString(), binding.objectInclude.ownerView.text.toString(), - objectId, binding.identifierInclude.identifierIdView.text.toString(), binding.identifierInclude.identifierTypeSpinner.selectedItem.toString(), "${binding.identifierInclude.identifierDeepView.text}mm", @@ -216,7 +211,19 @@ binding.identifierInclude.latView.text.toString(), binding.identifierInclude.colorSpinner.selectedItem.toString().toColor(), binding.remarkView.text.toString(), - realPaths + realPaths, + onLoading = { + LoadingDialog.show(this, "标识器安装中,请稍后...") + }, + onSuccess = { + LoadingDialog.dismiss() + clearDefaultData() + "安装成功".show(this) + }, + onFailed = { + LoadingDialog.dismiss() + it.show(this) + } ) //保存默认值 @@ -268,7 +275,7 @@ private fun saveMarkerInLocal() { val objectId = SaveKeyValues.getValue(LocaleConstant.OBJECT_ID, "") as String - val marker = MarkerLocalBean() + val marker = MarkerBean() marker.objectType = binding.objectInclude.objectTypeSpinner.selectedItem.toString() marker.pipelineType = binding.objectInclude.pipeInclude.markerObjectTypeView.text.toString() marker.pipelineMaterial = @@ -302,7 +309,7 @@ marker.remark = binding.remarkView.text.toString() marker.imagePath = realPaths.toJson() - DataBaseManager.get.saveMarkerInLocale(marker) + BaseApplication.get().dataBase.markerBeanDao().insert(marker) } private fun takePicture() { @@ -339,8 +346,8 @@ override fun initOnCreate(savedInstanceState: Bundle?) { locationKit.getCurrentLocation(true, object : OnGetLocationListener { override fun onSuccess(location: AMapLocation) { - binding.identifierInclude.lngView.text = location.longitude.toString() - binding.identifierInclude.latView.text = location.latitude.toString() + binding.identifierInclude.lngView.text = "${location.longitude}" + binding.identifierInclude.latView.text = "${location.latitude}" } override fun onError() { @@ -357,22 +364,6 @@ return ActivityInstallMarkerBinding.inflate(layoutInflater) } - override fun observeRequestState() { - taskViewModel.loadState.observe(this) { - when (it) { - LoadState.Loading -> LoadingDialog.show(this, "标识器安装中,请稍后...") - - LoadState.Success -> { - LoadingDialog.dismiss() - clearDefaultData() - "安装成功".show(this) - } - - else -> LoadingDialog.dismiss() - } - } - } - override fun setupTopBarLayout() { binding.rootView.initImmersionBar(this, true, R.color.white) binding.titleView.setOnClickListener(object : TitleBarView.OnClickListener { diff --git a/app/src/main/java/com/casic/common/detector/gd/view/MainActivity.kt b/app/src/main/java/com/casic/common/detector/gd/view/MainActivity.kt index fb0b260..a6352fb 100644 --- a/app/src/main/java/com/casic/common/detector/gd/view/MainActivity.kt +++ b/app/src/main/java/com/casic/common/detector/gd/view/MainActivity.kt @@ -5,7 +5,6 @@ import android.graphics.Color import android.media.AudioAttributes import android.media.SoundPool -import android.os.Build import android.os.Bundle import android.os.CountDownTimer import android.os.Handler @@ -31,19 +30,17 @@ import com.casic.common.detector.gd.R import com.casic.common.detector.gd.base.BaseApplication import com.casic.common.detector.gd.base.SerialPortBaseActivity -import com.casic.common.detector.gd.bean.MarkerLocalBean -import com.casic.common.detector.gd.bean.TaskLocalBean +import com.casic.common.detector.gd.bean.MarkerBean import com.casic.common.detector.gd.callback.OnGetAddressListener import com.casic.common.detector.gd.callback.OnGetLocationListener import com.casic.common.detector.gd.databinding.ActivityMainBinding import com.casic.common.detector.gd.extensions.appendDownloadUrl -import com.casic.common.detector.gd.extensions.createTaskCode import com.casic.common.detector.gd.extensions.initImmersionBar +import com.casic.common.detector.gd.model.MarkerFileModel import com.casic.common.detector.gd.model.TaskDetailLocalModel import com.casic.common.detector.gd.model.TaskModel import com.casic.common.detector.gd.service.NtripConnectService import com.casic.common.detector.gd.utils.CurrentSegment -import com.casic.common.detector.gd.utils.DataBaseManager import com.casic.common.detector.gd.utils.ExcelKit import com.casic.common.detector.gd.utils.FileType import com.casic.common.detector.gd.utils.LocaleConstant @@ -62,9 +59,7 @@ import com.pengxh.kt.lite.extensions.isNetworkConnected import com.pengxh.kt.lite.extensions.navigatePageTo import com.pengxh.kt.lite.extensions.show -import com.pengxh.kt.lite.extensions.timestampToCompleteDate import com.pengxh.kt.lite.utils.FileDownloadManager -import com.pengxh.kt.lite.utils.LoadState import com.pengxh.kt.lite.utils.LoadingDialog import com.pengxh.kt.lite.utils.SaveKeyValues import com.pengxh.kt.lite.widget.TitleBarView @@ -86,6 +81,9 @@ private val samplePopupWindow by lazy { SamplePopupWindow(this) } private val detailDialog by lazy { MarkerDetailDialog(this) } private val locationKit by lazy { LocationKit(this) } + private val markerBeanDao by lazy { BaseApplication.get().dataBase.markerBeanDao() } + private val taskBeanDao by lazy { BaseApplication.get().dataBase.taskBeanDao() } + private val taskMarkerBeanDao by lazy { BaseApplication.get().dataBase.taskMarkerBeanDao() } private val taskViewModel by lazy { ViewModelProvider(this)[TaskViewModel::class.java] } private val attr = AudioAttributes.Builder().setUsage(AudioAttributes.USAGE_ALARM) .setContentType(AudioAttributes.CONTENT_TYPE_MUSIC).build() @@ -94,7 +92,7 @@ private var isFreeTask = false private var freeTaskTitle = "" private var ids = ArrayList() - private var freeTaskId: String? = null + private var freeTaskId = 0L private var soundResourceId = 0 private var isExecuteTask = false private lateinit var aMap: AMap @@ -111,89 +109,14 @@ //地图初始化 initMapConfig(savedInstanceState) - Intent(this, NtripConnectService::class.java).also { - startService(it) - } +// Intent(this, NtripConnectService::class.java).apply { +// startService(this) +// } soundResourceId = soundPool.load(this, R.raw.ring3, 1) //右上角菜单 samplePopupWindow.setPopupMenuItem(LocaleConstant.POPUP_TITLES) samplePopupWindow.setBackgroundDrawable(null) - - //task网络请求监听 - taskViewModel.markerFileResult.observe(this) { - if (it.isSuccess) { - //清空之前的数据 - DataBaseManager.get.clearMarkers() - //下载最新的数据 - val companyId = SaveKeyValues.getValue(LocaleConstant.USER_COMPANY_ID, "") - val downloadUrl = companyId.toString().appendDownloadUrl(FileType.Excel) - Log.d(kTag, "downloadUrl => $downloadUrl") - FileDownloadManager.Builder().setDownloadFileSource(downloadUrl) - .setFileSuffix("xls").setFileSaveDirectory(createDownloadFileDir()) - .setOnFileDownloadListener(object : FileDownloadManager.OnFileDownloadListener { - override fun onDownloadStart(total: Long) { - - } - - override fun onDownloadEnd(file: File) { - lifecycleScope.launch(Dispatchers.IO) { ExcelKit.read(file.absolutePath) } - LoadingDialog.dismiss() - showMarkersOnMap() - } - - override fun onDownloadFailed(t: Throwable) { - t.printStackTrace() - } - - override fun onProgressChanged(progress: Long) { - - } - }).build().start() - } - } - taskViewModel.taskResult.observe(this) { - if (it.success == "true") { - AlertMessageDialog.Builder().setContext(this).setTitle("温馨提示") - .setMessage("您有${it.message.size}个新任务!").setPositiveButton("知道了") - .setOnDialogButtonClickListener(object : - AlertMessageDialog.OnDialogButtonClickListener { - override fun onConfirmClick() { - saveUserTasks(it) - } - }).build().show() - } - } - taskViewModel.freeTaskResult.observe(this) { - freeTaskId = it - // 自由巡检保存在本地 - val bean = TaskLocalBean() - bean.id = freeTaskId.toString().toLong() - val currentTimeMillis = System.currentTimeMillis() - bean.taskCode = currentTimeMillis.createTaskCode() - bean.description = freeTaskTitle - val time = currentTimeMillis.timestampToCompleteDate() - bean.createTime = time - bean.status = "0" - val userName = SaveKeyValues.getValue(LocaleConstant.USER_NAME, "") as String - bean.createUserName = userName - bean.startTime = time - bean.endTime = "" - bean.isFreeTask = "1" - DataBaseManager.get.saveTaskInLocale(bean) - } - taskViewModel.uploadTaskMarkerResult.observe(this) { - "自由巡检任务已完成".show(this) - ids.clear() - //清空自由巡检添加的Marker - aMap.clear() - showMarkersOnMap() - } - taskViewModel.executeTaskResult.observe(this) { - "工单任务已完成".show(this) - aMap.clear() - showMarkersOnMap() - } } override fun initEvent() { @@ -216,7 +139,7 @@ }).build().show() } else { lifecycleScope.launch(Dispatchers.Main) { - val markers = DataBaseManager.get.queryMarkerByState("0") + val markers = taskMarkerBeanDao.queryMarkerByState("0") //如果有需要补全的标识器,Popup右侧会有小圆点提示 if (markers.isNotEmpty()) { samplePopupWindow.setShowPosition(4) @@ -239,13 +162,7 @@ 3 -> uploadEvent() 4 -> completionMarker() 5 -> showRtkConfigDialog() - 6 -> { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { - SatelliteStatusDialog(context).show() - } else { - "卫星数据仅支持Android 7.0以上系统".show(context) - } - } + 6 -> SatelliteStatusDialog(context).show() } } }) @@ -268,25 +185,23 @@ //查看 binding.viewButton.setOnClickListener { - QueryMarkerDialog.Builder().setContext(this).setTitle("查看标识器") - .setSpinnerArray(LocaleConstant.SPINNER_ARRAY).setNegativeButton("取消") + QueryMarkerDialog.Builder() + .setContext(this) + .setTitle("查看标识器") + .setSpinnerArray(LocaleConstant.SPINNER_ARRAY) + .setNegativeButton("取消") .setPositiveButton("确定").setOnDialogButtonClickListener(object : QueryMarkerDialog.OnDialogButtonClickListener { override fun onConfirmClick(selectedItem: String, value: String) { //查询数据库 - lifecycleScope.launch(Dispatchers.Main) { - val markers = DataBaseManager.get.loadMarkersByCondition( - selectedItem, value - ) as ArrayList - - if (markers.isEmpty()) { - "无法查到相关数据信息,请检查您的查询条件".show(context) - } else { + val buildQuery = LocaleConstant.buildQuery(selectedItem, value) + markerBeanDao.loadMarkersByCondition(buildQuery).run { + if (isNotEmpty()) { val latitudeList = ArrayList() val longitudeList = ArrayList() - val latitude = markers.first().lat - val longitude = markers.first().lng + val latitude = first().lat + val longitude = first().lng if (latitude.isNotBlank() && longitude.isNotBlank()) { if (CoordinateConverter.isAMapDataAvailable( latitude.toDouble(), longitude.toDouble() @@ -300,10 +215,11 @@ if (latitudeList.isNotEmpty() && longitudeList.isNotEmpty()) { //移动地图到所有labelBeans的第一个点 - val center = LatLng(latitudeList.first(), longitudeList.first()) - //移动到指定经纬度 - aMap.moveCamera(CameraUpdateFactory.newLatLngZoom(center, 16f)) + val target = LatLng(latitudeList.first(), longitudeList.first()) + aMap.moveCamera(CameraUpdateFactory.newLatLngZoom(target, 16f)) } + } else { + "无法查到相关信息,请检查您的查询条件".show(context) } } } @@ -316,32 +232,39 @@ //巡检 binding.inspectionButton.setOnClickListener { - val tasks = DataBaseManager.get.loadLocalTask() - if (tasks.isNotEmpty()) { - val arrayList = ArrayList() - tasks.forEachIndexed { index, task -> - arrayList.add("任务${index + 1}:${task.taskId},${task.description}") + lifecycleScope.launch { + val tasks = withContext(Dispatchers.IO) { + taskBeanDao.loadLocalTask(taskMarkerBeanDao) } + if (tasks.isNotEmpty()) { + val arrayList = ArrayList() + tasks.forEachIndexed { index, task -> + arrayList.add("任务${index + 1}:${task.taskId},${task.description}") + } - BottomActionSheet.Builder().setContext(this).setItemTextColor(Color.BLUE) - .setActionItemTitle(arrayList) - .setOnActionSheetListener(object : BottomActionSheet.OnActionSheetListener { - override fun onActionItemClick(position: Int) { - val task = tasks[position] - SaveKeyValues.putValue(LocaleConstant.TASK_ID, task.taskId) - SaveKeyValues.putValue(LocaleConstant.TASK_CODE, task.taskCode) - executeTask(task) - } - }).build().show() - } else { - AlertMessageDialog.Builder().setContext(this).setTitle("温馨提示") - .setMessage("所有任务已完成,请点击右上角菜单下载新工单或者开始自由巡检") - .setPositiveButton("开始自由巡检").setOnDialogButtonClickListener(object : - AlertMessageDialog.OnDialogButtonClickListener { - override fun onConfirmClick() { - executeFreeTask() - } - }).build().show() + BottomActionSheet.Builder().setContext(context) + .setItemTextColor(Color.BLUE) + .setActionItemTitle(arrayList) + .setOnActionSheetListener(object : BottomActionSheet.OnActionSheetListener { + override fun onActionItemClick(position: Int) { + val task = tasks[position] + SaveKeyValues.putValue(LocaleConstant.TASK_ID, task.taskId) + SaveKeyValues.putValue(LocaleConstant.TASK_CODE, task.taskCode) + executeTask(task) + } + }).build().show() + } else { + AlertMessageDialog.Builder() + .setContext(context) + .setTitle("温馨提示") + .setMessage("所有任务已完成,请点击右上角菜单下载新工单或者开始自由巡检") + .setPositiveButton("开始自由巡检").setOnDialogButtonClickListener(object : + AlertMessageDialog.OnDialogButtonClickListener { + override fun onConfirmClick() { + executeFreeTask() + } + }).build().show() + } } } @@ -371,8 +294,11 @@ //自由巡检 binding.stopFreeTaskButton.setOnLongClickListener { - AlertMessageDialog.Builder().setContext(this).setTitle("温馨提示") - .setMessage("是否确定结束此次自由巡检任务?").setPositiveButton("是") + AlertMessageDialog.Builder() + .setContext(this) + .setTitle("温馨提示") + .setMessage("是否确定结束此次自由巡检任务?") + .setPositiveButton("是") .setOnDialogButtonClickListener(object : AlertMessageDialog.OnDialogButtonClickListener { override fun onConfirmClick() { @@ -381,14 +307,38 @@ stopSerialPortCommand() binding.stopFreeTaskButton.visibility = View.GONE - if (freeTaskId.isNullOrBlank()) { + if (freeTaskId == 0L) { "任务ID异常,无法提交任务,请联系服务器管理员".show(context) return } - freeTaskId?.apply { - taskViewModel.uploadTaskMarker(context, this, ids) - } + taskViewModel.uploadTaskMarker( + freeTaskId, + ids, + onLoading = { + LoadingDialog.show(context, "任务提交中,请稍后...") + }, + onSuccess = { + LoadingDialog.dismiss() + "自由巡检任务已完成".show(context) + ids.clear() + aMap.clear() + showMarkersOnMap() + + //删除本地数据库 + val taskCode = SaveKeyValues.getValue( + LocaleConstant.TASK_CODE, "" + ) as String + taskBeanDao.deleteLocalTaskById( + freeTaskId, taskCode, taskMarkerBeanDao + ) + SaveKeyValues.putValue(LocaleConstant.TASK_ID, "") + }, + onFailed = { + LoadingDialog.dismiss() + it.show(context) + } + ) } }).build().show() true @@ -399,25 +349,52 @@ RtkConfigDialog(this).setOnDialogButtonClickListener(object : RtkConfigDialog.OnDialogButtonClickListener { override fun onConfirmClick() { - NtripConnectService.weakReferenceHandler?.apply { - sendEmptyMessage(2024082201) - } + NtripConnectService.weakReferenceHandler?.sendEmptyMessage(2024082201) } }).show() } private fun uploadTask(taskId: String, taskCode: String, state: String) { if (isNetworkConnected()) { - val userId = SaveKeyValues.getValue(LocaleConstant.USER_ID, "") as String - taskViewModel.uploadTask(this, userId, taskId, taskCode, state) + taskViewModel.uploadTask( + taskId, state, + onLoading = { + LoadingDialog.show(this, "工单提交中,请稍后...") + }, + onSuccess = { + LoadingDialog.dismiss() + //工单提交之后,并且状态是2,删除本地Task记录 + if (state == "2") { + "工单${taskId}已提交!".show(this) + //删除本地数据库 + taskBeanDao.deleteLocalTaskById( + taskId.toLong(), taskCode, taskMarkerBeanDao + ) + SaveKeyValues.putValue(LocaleConstant.TASK_ID, "") + } else { + Log.d(kTag, "uploadTask: 仅执行工单,不删除本地工单数据") + } + aMap.clear() + showMarkersOnMap() + "工单任务已完成".show(this) + }, + onFailed = { + LoadingDialog.dismiss() + it.show(this) + } + ) } else { "网络连接已断开,请检查".show(this) } } private fun executeTask(task: TaskDetailLocalModel) { - AlertControlDialog.Builder().setContext(this).setTitle("提示").setMessage("请选择操作方式") - .setPositiveButton("执行工单").setNegativeButton("提交工单") + AlertControlDialog.Builder() + .setContext(this) + .setTitle("提示") + .setMessage("请选择操作方式") + .setPositiveButton("执行工单") + .setNegativeButton("提交工单") .setOnDialogButtonClickListener(object : AlertControlDialog.OnDialogButtonClickListener { override fun onConfirmClick() { @@ -432,7 +409,7 @@ isExecuteTask = true } else { "此工单下无标识器,将执行自由巡检任务".show(context) - freeTaskId = task.taskId + freeTaskId = task.taskId.toLong() detectMarker() } } @@ -453,7 +430,18 @@ override fun onConfirmClick(value: String) { freeTaskTitle = value val userId = SaveKeyValues.getValue(LocaleConstant.USER_ID, "") as String - taskViewModel.createFreeTask(context, userId, value) + taskViewModel.createFreeTask( + userId, value, + onLoading = {}, + onSuccess = { + freeTaskId = it + // 自由巡检保存在本地 + taskBeanDao.saveTask(it, freeTaskTitle) + }, + onFailed = { + it.show(context) + } + ) detectMarker() } @@ -481,7 +469,7 @@ if (RuntimeCache.currentSegment == CurrentSegment.FreeInspection) { //显示标识器详细信息 if (!detailDialog.isShowing) { - DataBaseManager.get.queryMarkerById(markerId).firstOrNull().apply { + markerBeanDao.queryMarkerById(markerId).firstOrNull().apply { if (this == null) { "无法查询到此ID【${markerId}】的信息".show(context) } else { @@ -501,7 +489,7 @@ //不重复标注Marker if (!ids.contains(markerId)) { - val markers = DataBaseManager.get.queryMarkerById(markerId) + val markers = markerBeanDao.queryMarkerById(markerId) if (markers.isNotEmpty()) { val marker = markers.first() val latLng = LatLng(marker.lat.toDouble(), marker.lng.toDouble()) @@ -522,16 +510,6 @@ } - override fun observeRequestState() { - taskViewModel.loadState.observe(this) { - when (it) { - LoadState.Loading -> LoadingDialog.show(this, "提交工单中,请稍后") - - else -> LoadingDialog.dismiss() - } - } - } - private fun initMapConfig(savedInstanceState: Bundle?) { binding.mapView.onCreate(savedInstanceState) aMap = binding.mapView.map @@ -592,54 +570,25 @@ private fun saveUserTasks(task: TaskModel) { task.message.forEach { model -> //保存任务详情 - DataBaseManager.get.saveTaskInLocale(model) + taskBeanDao.saveTask(model) model.taskDetailInfos.forEach { marker -> //只保存有标识器ID得数据 if (!marker.markerIdReal.isNullOrBlank()) { - DataBaseManager.get.saveTaskMarkerInLocale(model.id, model.taskCode, marker) + taskMarkerBeanDao.saveTaskMarker(model.id, model.taskCode, marker) } } } "工单下载成功!".show(this) } - private fun showMarkersOnMap() { - lifecycleScope.launch(Dispatchers.IO) { - //取缓存 - val markers = DataBaseManager.get.loadMarkers() - if (markers.isEmpty()) { - return@launch - } - val first = markers.first() - val defaultLatLng = LatLng(first.lat.toDouble(), first.lng.toDouble()) - //移动到指定经纬度 - val cameraPosition = CameraPosition(defaultLatLng, 14f, 0f, 0f) - val cameraUpdate = CameraUpdateFactory.newCameraPosition(cameraPosition) - withContext(Dispatchers.Main) { - aMap.animateCamera(cameraUpdate, 1500, null) - LoadingDialog.dismiss() - } - - markers.forEach { marker -> - val latitude = marker.lat.toString().toDouble() - val longitude = marker.lng.toString().toDouble() - //将所有设备信息转化缓存为Marker点 - val options = MarkerOptions() - .position(LatLng(latitude, longitude)) - .title(marker.markerId) - aMap.addMarker(options) - } - } - } - override fun onMarkerClick(marker: Marker?): Boolean { - marker?.apply { - showNavigationOption(title, position) + marker?.let { + showNavigationOption(it.title, it.position) } return true } - override fun onMapLongClick(p0: LatLng?) { + override fun onMapLongClick(latLng: LatLng?) { showMarkersOnMap() } @@ -664,7 +613,7 @@ } override fun onCancelClick() { - val result = DataBaseManager.get.queryMarkerById(title) + val result = markerBeanDao.queryMarkerById(title) MarkerDetailDialog(context).setMarker(result.first()).show() } }).build().show() @@ -695,20 +644,24 @@ //更新标识器数据 private fun updateMarkers() { - AlertControlDialog.Builder().setContext(this).setTitle("提示").setMessage("是否更新数据?") - .setNegativeButton("取消").setPositiveButton("确定") + AlertControlDialog.Builder() + .setContext(this) + .setTitle("提示") + .setMessage("是否更新数据?") + .setNegativeButton("取消") + .setPositiveButton("确定") .setOnDialogButtonClickListener(object : AlertControlDialog.OnDialogButtonClickListener { override fun onConfirmClick() { if (isNetworkConnected()) { - val companyId = SaveKeyValues.getValue(LocaleConstant.USER_COMPANY_ID, "") - - LoadingDialog.show(this@MainActivity, "获取标识器信息中,请稍后") - /** - * 后台设计如此,都传companyId - * */ + //清空之前的数据 + markerBeanDao.deleteAll() + aMap.clear() + //获取标识器数据 taskViewModel.getMarkerFile( - context, companyId.toString(), companyId.toString() + onLoading = {}, + onSuccess = { handleMarkerFile(it) }, + onFailed = { it.show(context) } ) } else { "网络连接已断开,请检查".show(context) @@ -721,11 +674,105 @@ }).build().show() } + private fun handleMarkerFile(it: MarkerFileModel) { + if (it.isSuccess) { + //下载最新的数据 + val companyId = SaveKeyValues.getValue(LocaleConstant.USER_COMPANY_ID, "") + val downloadUrl = companyId.toString().appendDownloadUrl(FileType.Excel) + Log.d(kTag, "handleMarkerFile => $downloadUrl") + FileDownloadManager.Builder() + .setDownloadFileSource(downloadUrl) + .setFileSuffix("xls") + .setFileSaveDirectory(createDownloadFileDir()) + .setOnFileDownloadListener(object : FileDownloadManager.OnFileDownloadListener { + override fun onDownloadStart(total: Long) { + LoadingDialog.show(context, "标识器数据解析中,请稍后...") + } + + override fun onDownloadEnd(file: File) { + lifecycleScope.launch(Dispatchers.IO) { + ExcelKit.read(file.absolutePath).apply { + renderMarkers(this) + }.also { + withContext(Dispatchers.Main) { + LoadingDialog.dismiss() + "标识器数据渲染完成".show(context) + } + } + } + } + + override fun onDownloadFailed(t: Throwable) { + t.printStackTrace() + LoadingDialog.dismiss() + "标识器数据下载失败".show(context) + } + + override fun onProgressChanged(progress: Long) { + + } + }).build().start() + } + } + + private fun showMarkersOnMap() { + lifecycleScope.launch(Dispatchers.IO) { + //取缓存 + markerBeanDao.loadAll().run { + renderMarkers(this) + }.also { + withContext(Dispatchers.Main) { + "标识器数据渲染完成".show(context) + } + } + } + } + + private fun renderMarkers(markers: List) { + if (markers.isEmpty()) { + return + } + val first = markers.first() + val defaultLatLng = LatLng(first.lat.toDouble(), first.lng.toDouble()) + //移动到指定经纬度 + val cameraPosition = CameraPosition(defaultLatLng, 14f, 0f, 0f) + val cameraUpdate = CameraUpdateFactory.newCameraPosition(cameraPosition) + aMap.animateCamera(cameraUpdate, 1500, null) + markers.forEach { marker -> + val latitude = marker.lat.toString().toDouble() + val longitude = marker.lng.toString().toDouble() + //将所有设备信息转化缓存为Marker点 + val options = MarkerOptions() + .position(LatLng(latitude, longitude)) + .title(marker.markerId) + aMap.addMarker(options) + } + } + //下载工单 private fun downloadTask() { if (isNetworkConnected()) { - val userName = SaveKeyValues.getValue(LocaleConstant.USER_NAME, "") - taskViewModel.getTasksByUser(this, userName.toString()) + taskViewModel.getTasksByUser( + onLoading = {}, + onSuccess = { + if (it.success == "true") { + AlertMessageDialog.Builder() + .setContext(this) + .setTitle("温馨提示") + .setMessage("您有${it.message.size}个新任务!") + .setPositiveButton("知道了") + .setOnDialogButtonClickListener(object : + AlertMessageDialog.OnDialogButtonClickListener { + override fun onConfirmClick() { + saveUserTasks(it) + } + }).build().show() + } + }, + onFailed = { + it.show(this) + } + ) } else { "网络连接已断开,请检查".show(this) } @@ -744,7 +791,7 @@ //标识器补全 private fun completionMarker() { val companyId = SaveKeyValues.getValue(LocaleConstant.USER_COMPANY_ID, "") as String - val markers = DataBaseManager.get.queryMarkerByState("0") + val markers = taskMarkerBeanDao.queryMarkerByState("0") if (markers.isNotEmpty()) { //TODO 逻辑没梳理明白 } else { diff --git a/app/src/main/java/com/casic/common/detector/gd/view/SearchMarkerActivity.kt b/app/src/main/java/com/casic/common/detector/gd/view/SearchMarkerActivity.kt index 4a92c97..b2e3301 100644 --- a/app/src/main/java/com/casic/common/detector/gd/view/SearchMarkerActivity.kt +++ b/app/src/main/java/com/casic/common/detector/gd/view/SearchMarkerActivity.kt @@ -1,6 +1,5 @@ package com.casic.common.detector.gd.view -import android.content.Context import android.content.res.ColorStateList import android.graphics.Color import android.hardware.Sensor @@ -13,18 +12,19 @@ import android.os.Handler import android.os.Looper import android.view.View +import androidx.core.graphics.toColorInt import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.lifecycleScope import com.amap.api.location.AMapLocation import com.amap.api.maps.AMapUtils import com.amap.api.maps.model.LatLng import com.casic.common.detector.gd.R +import com.casic.common.detector.gd.base.BaseApplication import com.casic.common.detector.gd.base.SerialPortBaseActivity import com.casic.common.detector.gd.callback.OnGetLocationListener import com.casic.common.detector.gd.databinding.ActivitySearchMarkerBinding import com.casic.common.detector.gd.model.MarkerDistanceData import com.casic.common.detector.gd.utils.CurrentSegment -import com.casic.common.detector.gd.utils.DataBaseManager import com.casic.common.detector.gd.utils.LocaleConstant import com.casic.common.detector.gd.utils.LocationKit import com.casic.common.detector.gd.utils.RuntimeCache @@ -50,8 +50,10 @@ private val context = this private val locationKit by lazy { LocationKit(this) } private val markerPoints by lazy { ArrayList() } + private val markerBeanDao by lazy { BaseApplication.get().dataBase.markerBeanDao() } + private val taskMarkerBeanDao by lazy { BaseApplication.get().dataBase.taskMarkerBeanDao() } private val taskViewModel by lazy { ViewModelProvider(this)[TaskViewModel::class.java] } - private val sensorManager by lazy { getSystemService(Context.SENSOR_SERVICE) as SensorManager } + private val sensorManager by lazy { getSystemService(SENSOR_SERVICE) as SensorManager } private val attr = AudioAttributes.Builder().setUsage(AudioAttributes.USAGE_ALARM) .setContentType(AudioAttributes.CONTENT_TYPE_MUSIC).build() private val soundPool = SoundPool.Builder().setMaxStreams(16).setAudioAttributes(attr).build() @@ -109,7 +111,7 @@ override fun initEvent() { binding.depthButton.setOnClickListener { RuntimeCache.currentSegment = CurrentSegment.DetectDepth - val result = DataBaseManager.get.queryMarkerById(markerId) + val result = markerBeanDao.queryMarkerById(markerId) if (result.isNotEmpty()) { val command = when (result.first().markerType) { "EM30" -> SerialPortCommand.DETECT_EM30_DEPTH @@ -139,7 +141,7 @@ } binding.markerInfoButton.setOnClickListener { - val result = DataBaseManager.get.queryMarkerById(markerId) + val result = markerBeanDao.queryMarkerById(markerId) if (result.isNotEmpty()) { MarkerDetailDialog(this).setMarker(result.first()).show() } else { @@ -154,12 +156,12 @@ binding.depthButton.isEnabled = true binding.depthButton.setTextColor(Color.WHITE) binding.depthButton.backgroundTintList = - ColorStateList.valueOf(Color.parseColor("#004364")) + ColorStateList.valueOf("#004364".toColorInt()) binding.markerInfoButton.isEnabled = true binding.markerInfoButton.setTextColor(Color.WHITE) binding.markerInfoButton.backgroundTintList = - ColorStateList.valueOf(Color.parseColor("#FFA200")) + ColorStateList.valueOf("#FFA200".toColorInt()) handleMarker(markerId) } @@ -171,12 +173,22 @@ if (isExecuteTask) { val taskId = SaveKeyValues.getValue(LocaleConstant.TASK_ID, "") as String val taskCode = SaveKeyValues.getValue(LocaleConstant.TASK_CODE, "") as String - val taskMarkerLocalBean = DataBaseManager.get.queryTaskMarkerById( + val marker = taskMarkerBeanDao.queryTaskMarkerById( taskId, taskCode, id, "0" ) - taskMarkerLocalBean?.apply { - taskViewModel.uploadMarker(context, this) + if (marker == null) { + return } + taskViewModel.uploadMarker( + marker.markerId, + onLoading = {}, + onSuccess = { + "标识器${marker.markerId}已探测!".show(this) + marker.isDetected = "1" + taskMarkerBeanDao.updateLocalTaskMarkerState(marker) + }, + onFailed = {} + ) } } @@ -185,15 +197,22 @@ detectDepthRunnable?.let { handler.removeCallbacks(it) } detectDepthRunnable = null LoadingDialog.dismiss() - AlertMessageDialog.Builder().setContext(context).setTitle("温馨提示") - .setMessage("标识器埋深:${depth}厘米").setPositiveButton("知道了") - .setOnDialogButtonClickListener(object : - AlertMessageDialog.OnDialogButtonClickListener { - override fun onConfirmClick() { - RuntimeCache.currentSegment = CurrentSegment.SearchMarker - sendSerialPortCommand(SerialPortCommand.SEARCH_SIGNAL) - } - }).build().show() + if (!this.isDestroyed) { + AlertMessageDialog.Builder() + .setContext(context) + .setTitle("温馨提示") + .setMessage("标识器埋深:${depth}厘米") + .setPositiveButton("知道了") + .setOnDialogButtonClickListener(object : + AlertMessageDialog.OnDialogButtonClickListener { + override fun onConfirmClick() { + RuntimeCache.currentSegment = CurrentSegment.SearchMarker + sendSerialPortCommand(SerialPortCommand.SEARCH_SIGNAL) + } + }).build().show() + } else { + "标识器埋深:${depth}厘米".show(this) + } } } @@ -201,13 +220,13 @@ if (RuntimeCache.currentSegment == CurrentSegment.SearchMarker) { if (signalEnergy > 1000) { binding.markerIdButton.isEnabled = true - binding.markerIdButton.setTextColor(Color.parseColor("#428d00")) + binding.markerIdButton.setTextColor("#428d00".toColorInt()) binding.markerIdButton.backgroundTintList = ColorStateList.valueOf( - Color.parseColor("#7EFF00") + "#7EFF00".toColorInt() ) binding.searchResultView.text = "已检测到标识器" - binding.searchResultView.setTextColor(Color.parseColor("#428d00")) + binding.searchResultView.setTextColor("#428d00".toColorInt()) binding.searchResultView.setBackgroundResource(R.mipmap.bg_small_text_green) } @@ -230,19 +249,19 @@ signalEnergy <= 700 -> { setEnergyTip( "信号较弱,可能距离较远", - Color.parseColor("#8D1717"), + "#8D1717".toColorInt(), R.mipmap.bg_large_text_red ) disableButtons() binding.searchResultView.text = "未检测到标识器" - binding.searchResultView.setTextColor(Color.parseColor("#8D1717")) + binding.searchResultView.setTextColor("#8D1717".toColorInt()) binding.searchResultView.setBackgroundResource(R.mipmap.bg_small_text_red) } signalEnergy >= 4100 -> { setEnergyTip( "信号极强,接近标识器正上方", - Color.parseColor("#428d00"), + "#428d00".toColorInt(), R.mipmap.bg_large_text_green ) } @@ -250,7 +269,7 @@ else -> { setEnergyTip( "已靠近,请继续移动位置", - Color.parseColor("#8C5700"), + "#8C5700".toColorInt(), R.mipmap.bg_large_text_yellow ) } @@ -263,8 +282,8 @@ binding.energyTipsView.setBackgroundResource(backgroundRes) } - private val colorStateList = ColorStateList.valueOf(Color.parseColor("#8A8A8A")) - private val textColor = Color.parseColor("#CCCCCC") + private val colorStateList = ColorStateList.valueOf("#8A8A8A".toColorInt()) + private val textColor = "#CCCCCC".toColorInt() private fun disableButtons() { binding.depthButton.isEnabled = false @@ -287,7 +306,7 @@ val latitude = location.latitude lifecycleScope.launch(Dispatchers.IO) { val dataPoints = ArrayList() - DataBaseManager.get.loadMarkers().forEach { + markerBeanDao.loadAll().forEach { val distance = AMapUtils.calculateLineDistance( LatLng(it.lat.toDouble(), it.lng.toDouble()), LatLng(latitude, longitude) ) @@ -332,10 +351,6 @@ return ActivitySearchMarkerBinding.inflate(layoutInflater) } - override fun observeRequestState() { - - } - override fun setupTopBarLayout() { } diff --git a/app/src/main/java/com/casic/common/detector/gd/view/SearchMarkerAuditActivity.kt b/app/src/main/java/com/casic/common/detector/gd/view/SearchMarkerAuditActivity.kt index 1dc59a7..dd4cc84 100644 --- a/app/src/main/java/com/casic/common/detector/gd/view/SearchMarkerAuditActivity.kt +++ b/app/src/main/java/com/casic/common/detector/gd/view/SearchMarkerAuditActivity.kt @@ -1,6 +1,5 @@ package com.casic.common.detector.gd.view -import android.content.Context import android.hardware.Sensor import android.hardware.SensorEvent import android.hardware.SensorEventListener @@ -13,9 +12,9 @@ import com.amap.api.maps.AMapUtils import com.amap.api.maps.model.LatLng import com.casic.common.detector.gd.R +import com.casic.common.detector.gd.base.BaseApplication import com.casic.common.detector.gd.callback.OnGetLocationListener import com.casic.common.detector.gd.databinding.ActivitySearchMarkerAuditBinding -import com.casic.common.detector.gd.utils.DataBaseManager import com.casic.common.detector.gd.utils.LocaleConstant import com.casic.common.detector.gd.utils.LocationKit import com.casic.common.detector.gd.widgets.MarkerDetailDialog @@ -36,7 +35,8 @@ private val kTag = "SearchMarkerActivity" private val context = this private val locationKit by lazy { LocationKit(this) } - private val sensorManager by lazy { getSystemService(Context.SENSOR_SERVICE) as SensorManager } + private val sensorManager by lazy { getSystemService(SENSOR_SERVICE) as SensorManager } + private val markerBeanDao by lazy { BaseApplication.get().dataBase.markerBeanDao() } private val attr = AudioAttributes.Builder().setUsage(AudioAttributes.USAGE_ALARM) .setContentType(AudioAttributes.CONTENT_TYPE_MUSIC).build() private val soundPool = SoundPool.Builder().setMaxStreams(16).setAudioAttributes(attr).build() @@ -72,7 +72,7 @@ override fun initEvent() { binding.markerInfoButton.setOnClickListener { //查库 - val result = DataBaseManager.get.queryMarkerById(nearestMarkerId) + val result = markerBeanDao.queryMarkerById(nearestMarkerId) if (result.isNotEmpty()) { MarkerDetailDialog(this).setMarker(result.first()).show() } else { @@ -90,7 +90,7 @@ val latitude = location.latitude lifecycleScope.launch(Dispatchers.IO) { val dataPoints = ArrayList() - DataBaseManager.get.loadMarkers().forEach { + markerBeanDao.loadAll().forEach { val distance = AMapUtils.calculateLineDistance( LatLng(it.lat.toDouble(), it.lng.toDouble()), LatLng(latitude, longitude) ) @@ -105,7 +105,8 @@ ) } withContext(Dispatchers.Main) { - binding.radarScanView.renderPointData(dataPoints, + binding.radarScanView.renderPointData( + dataPoints, object : RadarScanView.OnGetNearestPointCallback { override fun getNearestPoint(point: RadarScanView.DataPoint?) { if (point == null) { diff --git a/app/src/main/java/com/casic/common/detector/gd/vm/TaskViewModel.kt b/app/src/main/java/com/casic/common/detector/gd/vm/TaskViewModel.kt index ee0d63a..665d95c 100644 --- a/app/src/main/java/com/casic/common/detector/gd/vm/TaskViewModel.kt +++ b/app/src/main/java/com/casic/common/detector/gd/vm/TaskViewModel.kt @@ -1,95 +1,87 @@ package com.casic.common.detector.gd.vm -import android.content.Context -import android.util.Log -import androidx.lifecycle.MutableLiveData -import com.casic.common.detector.gd.bean.TaskMarkerLocalBean import com.casic.common.detector.gd.extensions.getResponseMessage import com.casic.common.detector.gd.extensions.getResponseState import com.casic.common.detector.gd.model.MarkerFileModel import com.casic.common.detector.gd.model.TaskModel import com.casic.common.detector.gd.retrofit.RetrofitServiceManager -import com.casic.common.detector.gd.utils.DataBaseManager -import com.casic.common.detector.gd.utils.LocaleConstant -import com.google.gson.Gson import com.google.gson.JsonParser -import com.google.gson.reflect.TypeToken import com.pengxh.kt.lite.base.BaseViewModel import com.pengxh.kt.lite.extensions.launch -import com.pengxh.kt.lite.extensions.show -import com.pengxh.kt.lite.utils.LoadState -import com.pengxh.kt.lite.utils.SaveKeyValues +import com.pengxh.kt.lite.extensions.unpackingResponse class TaskViewModel : BaseViewModel() { - - private val kTag = "TaskViewModel" - private val gson by lazy { Gson() } - val markerFileResult = MutableLiveData() - val taskResult = MutableLiveData() - val freeTaskResult = MutableLiveData() - val uploadTaskMarkerResult = MutableLiveData() - val executeTaskResult = MutableLiveData() - - fun createFreeTask(context: Context, patrollerId: String, description: String) = launch({ + fun createFreeTask( + patrollerId: String, + description: String, + onLoading: () -> Unit, + onSuccess: (Long) -> Unit, + onFailed: (String) -> Unit + ) = launch({ + onLoading() val response = RetrofitServiceManager.createFreeTask(patrollerId, description) if (response.getResponseState()) { val element = JsonParser.parseString(response) val jsonObject = element.asJsonObject - freeTaskResult.value = jsonObject.get("taskId").asInt.toString() + onSuccess(jsonObject.get("taskId").asLong) } else { - response.getResponseMessage().show(context) + onFailed(response.getResponseMessage()) } }, { - it.printStackTrace() + onFailed(it.message ?: "Unknown error") }) - fun uploadTaskMarker(context: Context, taskId: String, ids: ArrayList) = launch({ + fun uploadTaskMarker( + taskId: Long, + ids: ArrayList, + onLoading: () -> Unit, + onSuccess: () -> Unit, + onFailed: (String) -> Unit + ) = launch({ + onLoading() val response = RetrofitServiceManager.uploadTaskMarker(taskId, ids) if (response.getResponseState()) { - val element = JsonParser.parseString(response) - val jsonObject = element.asJsonObject - uploadTaskMarkerResult.value = jsonObject.get("success").asString - - //删除本地数据库 - val taskCode = SaveKeyValues.getValue(LocaleConstant.TASK_CODE, "") as String - DataBaseManager.get.deleteLocalTaskById(taskId, taskCode) - SaveKeyValues.putValue(LocaleConstant.TASK_ID, "") + onSuccess() } else { - response.getResponseMessage().show(context) + onFailed(response.getResponseMessage()) } }, { - it.printStackTrace() + onFailed(it.message ?: "Unknown error") }) - fun getMarkerFile(context: Context, userId: String, companyId: String) = launch({ - val response = RetrofitServiceManager.getMarkerFile(userId, companyId) + fun getMarkerFile( + onLoading: () -> Unit, + onSuccess: (MarkerFileModel) -> Unit, + onFailed: (String) -> Unit + ) = launch({ + onLoading() + val response = RetrofitServiceManager.getMarkerFile() if (response.getResponseState()) { - markerFileResult.value = gson.fromJson( - response, object : TypeToken() {}.type - ) + onSuccess(unpackingResponse(response)) } else { - response.getResponseMessage().show(context) + onFailed(response.getResponseMessage()) } }, { - it.printStackTrace() + onFailed(it.message ?: "Unknown error") }) - fun getTasksByUser(context: Context, userName: String) = launch({ - val response = RetrofitServiceManager.getTasksByUser(userName) + fun getTasksByUser( + onLoading: () -> Unit, + onSuccess: (TaskModel) -> Unit, + onFailed: (String) -> Unit + ) = launch({ + onLoading() + val response = RetrofitServiceManager.getTasksByUser() if (response.getResponseState()) { - taskResult.value = gson.fromJson( - response, object : TypeToken() {}.type - ) + onSuccess(unpackingResponse(response)) } else { - response.getResponseMessage().show(context) + onFailed(response.getResponseMessage()) } }, { - it.printStackTrace() + onFailed(it.message ?: "Unknown error") }) - fun installLabel( - context: Context, - companyId: String, + fun installMarker( recordType: String, markerObjectType: String, pipeMaterial: String, @@ -105,7 +97,6 @@ road: String, constructTime: String, ownerComp: String, - markerObjectId: String, markerId: String, markerType: String, markerDepth: String, @@ -115,11 +106,13 @@ latitude: String, colorType: String, memo: String, - realPaths: ArrayList + realPaths: ArrayList, + onLoading: () -> Unit, + onSuccess: () -> Unit, + onFailed: (String) -> Unit ) = launch({ - loadState.value = LoadState.Loading - val response = RetrofitServiceManager.installLabel( - companyId, + onLoading() + val response = RetrofitServiceManager.installMarker( recordType, markerObjectType, pipeMaterial, @@ -135,7 +128,6 @@ road, constructTime, ownerComp, - markerObjectId, markerId, markerType, markerDepth, @@ -148,67 +140,65 @@ realPaths ) if (response.getResponseState()) { - loadState.value = LoadState.Success + onSuccess() } else { - loadState.value = LoadState.Fail - response.getResponseMessage().show(context) + onFailed(response.getResponseMessage()) } }, { - it.printStackTrace() - loadState.value = LoadState.Fail + onFailed(it.message ?: "Unknown error") }) fun uploadTask( - context: Context, userId: String, taskId: String, taskCode: String, state: String + taskId: String, + state: String, + onLoading: () -> Unit, + onSuccess: () -> Unit, + onFailed: (String) -> Unit ) = launch({ - loadState.value = LoadState.Loading - val response = RetrofitServiceManager.uploadTask(userId, taskId, state) + onLoading() + val response = RetrofitServiceManager.uploadTask(taskId, state) if (response.getResponseState()) { - loadState.value = LoadState.Success - //工单提交之后,并且状态是2,删除本地Task记录 - if (state == "2") { - "工单${taskId}已提交!".show(context) - //删除本地数据库 - DataBaseManager.get.deleteLocalTaskById(taskId, taskCode) - SaveKeyValues.putValue(LocaleConstant.TASK_ID, "") - - val element = JsonParser.parseString(response) - val jsonObject = element.asJsonObject - executeTaskResult.value = jsonObject.get("success").asString - } else { - Log.d(kTag, "uploadTask: 仅执行工单,不删除本地工单数据") - } + onSuccess() } else { - loadState.value = LoadState.Fail - response.getResponseMessage().show(context) + onFailed(response.getResponseMessage()) } }, { - it.printStackTrace() - loadState.value = LoadState.Fail + onFailed(it.message ?: "Unknown error") }) fun uploadEvent( - context: Context, taskId: String, event: String, realPaths: ArrayList + taskId: String, + event: String, + realPaths: ArrayList, + onLoading: () -> Unit, + onSuccess: () -> Unit, + onFailed: (String) -> Unit ) = launch({ - loadState.value = LoadState.Loading + onLoading() val response = RetrofitServiceManager.uploadEvent(taskId, event, realPaths) if (response.getResponseState()) { - loadState.value = LoadState.Success + onSuccess() } else { - loadState.value = LoadState.Fail - response.getResponseMessage().show(context) + onFailed(response.getResponseMessage()) } }, { - it.printStackTrace() - loadState.value = LoadState.Fail + onFailed(it.message ?: "Unknown error") }) - fun uploadMarker(context: Context, marker: TaskMarkerLocalBean) = launch({ - //主键ID代替MarkerId - RetrofitServiceManager.uploadMarker(marker.id.toString()) - "标识器${marker.markerId}已探测!".show(context) - DataBaseManager.get.updateLocalTaskMarkerState(marker) + fun uploadMarker( + markerId: String, + onLoading: () -> Unit, + onSuccess: () -> Unit, + onFailed: (String) -> Unit + ) = launch({ + onLoading() + val response = RetrofitServiceManager.uploadMarker(markerId) + if (response.getResponseState()) { + onSuccess() + } else { + onFailed(response.getResponseMessage()) + } }, { - it.printStackTrace() + onFailed(it.message ?: "Unknown error") }) } \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/widgets/MarkerDetailDialog.kt b/app/src/main/java/com/casic/common/detector/gd/widgets/MarkerDetailDialog.kt index 44723f2..3890584 100644 --- a/app/src/main/java/com/casic/common/detector/gd/widgets/MarkerDetailDialog.kt +++ b/app/src/main/java/com/casic/common/detector/gd/widgets/MarkerDetailDialog.kt @@ -3,8 +3,7 @@ import android.app.Dialog import android.content.Context import android.os.Bundle -import com.casic.common.detector.gd.R -import com.casic.common.detector.gd.bean.MarkerLocalBean +import com.casic.common.detector.gd.bean.MarkerBean import com.casic.common.detector.gd.databinding.DialogMarkerDetailBinding import com.casic.common.detector.gd.extensions.appendDownloadUrl import com.casic.common.detector.gd.extensions.initDialogLayoutParams @@ -15,12 +14,11 @@ import com.pengxh.kt.lite.extensions.navigatePageTo import com.pengxh.kt.lite.extensions.show -class MarkerDetailDialog(context: Context) : - Dialog(context, R.style.UserDefinedDialogStyle) { +class MarkerDetailDialog(context: Context) : Dialog(context) { - private lateinit var marker: MarkerLocalBean + private lateinit var marker: MarkerBean - fun setMarker(marker: MarkerLocalBean): MarkerDetailDialog { + fun setMarker(marker: MarkerBean): MarkerDetailDialog { this.marker = marker return this } @@ -52,7 +50,7 @@ binding.showImageView.setOnClickListener { //查数据库 - if (marker.imagePath.isNullOrEmpty()) { + if (marker.imagePath.isEmpty()) { "此标识器无图片".show(context) } else { val realPaths = ArrayList() //真实图片路径 diff --git a/app/src/main/java/com/casic/common/detector/gd/widgets/QueryMarkerDialog.kt b/app/src/main/java/com/casic/common/detector/gd/widgets/QueryMarkerDialog.kt index 304fdbb..64a1b93 100644 --- a/app/src/main/java/com/casic/common/detector/gd/widgets/QueryMarkerDialog.kt +++ b/app/src/main/java/com/casic/common/detector/gd/widgets/QueryMarkerDialog.kt @@ -6,20 +6,19 @@ import android.view.View import android.widget.AdapterView import android.widget.ArrayAdapter -import com.casic.common.detector.gd.R +import com.casic.common.detector.gd.base.BaseApplication import com.casic.common.detector.gd.databinding.DialogQueryMarkerBinding -import com.casic.common.detector.gd.utils.DataBaseManager +import com.casic.common.detector.gd.utils.LocaleConstant import com.pengxh.kt.lite.extensions.binding import com.pengxh.kt.lite.extensions.initDialogLayoutParams import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.Job import kotlinx.coroutines.launch import kotlinx.coroutines.withContext -class QueryMarkerDialog private constructor(builder: Builder) : Dialog( - builder.context, R.style.UserDefinedDialogStyle -) { +class QueryMarkerDialog private constructor(builder: Builder) : Dialog(builder.context) { private val ctx = builder.context private val title = builder.title private val spinnerArray = builder.spinnerArray @@ -71,6 +70,7 @@ } private val binding: DialogQueryMarkerBinding by binding() + private val serviceScope = CoroutineScope(Dispatchers.Main + Job()) override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -97,12 +97,11 @@ ) { //查库 val autoCompleteData = HashSet() - CoroutineScope(Dispatchers.Main).launch { + val markerBeanDao = BaseApplication.get().dataBase.markerBeanDao() + val buildQuery = LocaleConstant.buildQuery(spinnerArray[position], "") + serviceScope.launch { val labelBeans = withContext(Dispatchers.IO) { - DataBaseManager.get.loadMarkersByCondition( - spinnerArray[position], - null - ) + markerBeanDao.loadMarkersByCondition(buildQuery) } for (labelBean in labelBeans) { when (position) { diff --git a/app/build.gradle b/app/build.gradle index d0cb423..921c8c8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,25 +1,20 @@ import java.text.SimpleDateFormat -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply plugin: 'org.greenrobot.greendao' +plugins { + id('com.android.application') + id('org.jetbrains.kotlin.android') +} android { - compileSdkVersion 33 + namespace 'com.casic.common.detector.gd' + compileSdk 35 defaultConfig { - applicationId "com.casic.common.detector.gd" - minSdkVersion 26 - targetSdkVersion 33 + applicationId 'com.casic.common.detector.gd' + minSdk 26 + targetSdk 35 versionCode 5092 - versionName "5.0.9.2" - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } + versionName '5.0.9.2' } signingConfigs { @@ -31,6 +26,14 @@ } } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + signingConfig signingConfigs.release + } + } + compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 @@ -47,27 +50,16 @@ } } - kotlin { - experimental { - coroutines 'enable' - } - } - buildFeatures { + buildConfig true viewBinding true } - applicationVariants.configureEach { variant -> - variant.outputs.configureEach { - outputFileName = "COM_TCY_" + getBuildDate() + "_" + defaultConfig.versionName + ".apk" + applicationVariants.configureEach { + outputs.configureEach { + outputFileName = 'COM_TCY_' + getBuildDate() + '_' + defaultConfig.versionName + '.apk' } } - - greendao { - schemaVersion 1//数据库版本号 - targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 - daoPackage "${defaultConfig.applicationId}.greendao"//设置DaoMaster、DaoSession、Dao包名 - } } static def getBuildDate() { @@ -76,27 +68,22 @@ } dependencies { - //基础依赖库 - implementation 'com.github.AndroidCoderPeng:Kotlin-lite-lib:1.1.4' - implementation 'androidx.core:core-ktx:1.9.0' - def base_version = "1.6.1" - implementation "androidx.appcompat:appcompat:${base_version}" - implementation "com.google.android.material:material:${base_version}" + implementation 'com.github.AndroidCoderPeng:Kotlin-lite-lib:1.1.5' + implementation 'androidx.core:core-ktx:1.13.1' + implementation 'androidx.appcompat:appcompat:1.7.0' + implementation 'com.google.android.material:material:1.12.0' //Google官方授权框架 implementation 'pub.devrel:easypermissions:3.0.0' - //沉浸式状态栏。基础依赖包,必须要依赖 - implementation 'com.gyf.immersionbar:immersionbar:3.0.0' - //fragment快速实现 - implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0' + //沉浸式状态栏 + implementation 'com.geyifeng.immersionbar:immersionbar:3.2.2' //官方Json解析库 implementation 'com.google.code.gson:gson:2.10.1' - def vm_version = '2.5.1' //Kotlin协程 - implementation "androidx.lifecycle:lifecycle-runtime-ktx:${vm_version}" + implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.2' //MVVM+LiveData - implementation "androidx.lifecycle:lifecycle-livedata-ktx:${vm_version}" - implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:${vm_version}" - implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.6.2' + implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2' + implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' //返回值转换器 implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' @@ -105,9 +92,10 @@ implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' //网络请求和接口封装 implementation 'com.squareup.retrofit2:retrofit:2.9.0' - implementation 'com.squareup.okhttp3:okhttp:4.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.12.0' //数据库框架 - implementation 'org.greenrobot:greendao:3.3.0' + implementation 'androidx.room:room-runtime:2.6.1' + annotationProcessor 'androidx.room:room-compiler:2.5.2' //高德导航、定位、地图三合一 implementation 'com.amap.api:navi-3dmap:latest.integration' //经纬度逆编码 @@ -115,7 +103,7 @@ //excel implementation 'net.sourceforge.jexcelapi:jxl:2.6.12' //图片加载框架 - implementation 'com.github.bumptech.glide:glide:4.9.0' + implementation 'com.github.bumptech.glide:glide:4.12.0' //图片选择框架 implementation 'io.github.lucksiege:pictureselector:v3.11.1' //大图 diff --git a/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt b/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt index 7b695ff..50ba734 100644 --- a/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt +++ b/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt @@ -4,9 +4,9 @@ import android.app.Application import android.os.Bundle import android.util.Log -import com.casic.common.detector.gd.greendao.DaoMaster -import com.casic.common.detector.gd.greendao.DaoSession +import androidx.room.Room.databaseBuilder import com.casic.common.detector.gd.uart.SerialPort +import com.casic.common.detector.gd.utils.DetectorDataBase import com.casic.common.detector.gd.utils.GpioManager import com.pengxh.kt.lite.extensions.show import com.pengxh.kt.lite.utils.SaveKeyValues @@ -43,44 +43,42 @@ private var application: BaseApplication by Delegates.notNull() fun get() = application - - private lateinit var daoSession: DaoSession } + lateinit var dataBase: DetectorDataBase + override fun onCreate() { super.onCreate() application = this SaveKeyValues.initSharedPreferences(this) CrashReport.initCrashReport(this, "01e80d3a74", true) - val devOpenHelper = DaoMaster.DevOpenHelper(this, "Detector.db", null) - val daoMaster = DaoMaster(devOpenHelper.writableDatabase) - daoSession = daoMaster.newSession() + dataBase = databaseBuilder(this, DetectorDataBase::class.java, "Detector.db") + .allowMainThreadQueries() + .build() /** * Open the serial port * */ try { serialPorts.apply { - add(SerialPort(File("/dev/ttysWK1"), 9600, 0)) - //千寻报文数据下发串口号 - add(SerialPort(File("/dev/ttyS1"), 9600, 0)) + add(SerialPort(File("/dev/ttysWK1"), 9600, 0)) //信号通讯串口 + add(SerialPort(File("/dev/ttyS1"), 9600, 0)) //千寻报文数据下发串口号 } Log.d(kTag, "onCreate: 已初始化 ${serialPorts.size} 个串口") } catch (e: SecurityException) { "您没有串口的读写权限!".show(this) + e.printStackTrace() } catch (e: IOException) { "因为不明原因,串口无法打开!".show(this) + e.printStackTrace() } catch (e: InvalidParameterException) { "请检查串口!".show(this) + e.printStackTrace() } registerActivityLifecycleCallbacks(this) } - fun getDaoSession(): DaoSession { - return daoSession - } - override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) { } diff --git a/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt b/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt index 053b9dd..1d0c9e3 100644 --- a/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt +++ b/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt @@ -14,12 +14,10 @@ import com.casic.common.detector.gd.utils.SerialPortCommand import com.pengxh.kt.lite.utils.WeakReferenceHandler import java.io.IOException -import java.util.Timer abstract class SerialPortBaseActivity : AppCompatActivity(), Handler.Callback { private val kTag = "SerialPortBaseActivity" - private val taskTimer by lazy { Timer() } private val weakReferenceHandler by lazy { WeakReferenceHandler(this) } private val serialPorts by lazy { BaseApplication.get().getSerialPorts() } protected lateinit var binding: VB @@ -30,7 +28,6 @@ setContentView(binding.root) setupTopBarLayout() initOnCreate(savedInstanceState) - observeRequestState() initEvent() if (serialPorts.isNotEmpty()) { @@ -71,11 +68,6 @@ abstract fun initOnCreate(savedInstanceState: Bundle?) /** - * 数据请求状态监听 - */ - abstract fun observeRequestState() - - /** * 初始化业务逻辑 */ abstract fun initEvent() diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java new file mode 100644 index 0000000..7a18c20 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java @@ -0,0 +1,255 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 从平台下载的标识器本地库实体类 + */ +@Entity(tableName = "marker_detail") +public class MarkerBean { + @PrimaryKey(autoGenerate = true) + private long id; //主键ID + private String pipelineType; // 管线类型 + private String pipelineDiameter; // 管线直径 + private String pipelineMaterial; // 管材 + private String buryMethod; // 埋设方式 + private String buryDepth; // 埋深 + private String area; // 所属区域 + private String line; // 所属线路 + private String road; // 所属道路 + private String constructTime; // 建设年代 + private String owner; // 权属单位 + private String objectId; // 标识对象ID,无实际用途 + private String markerId; // 标识器ID + private String markerType; // 标识器类型 + private String markerDepth; // 标识器埋深 + private String installationDept; // 安装部门 + private String lng; // 经度 + private String lat; // 纬度 + private String updateTime; // 最后修改时间,更新时间 + private String remark; // 备注信息 + private String underlyingPipelineType; // 下层管线类型 + private String underlyingPipelineDepth; // 下层埋深 + private String underlyingPipelineDiameter; // 下层管径 + private String underlyingPipelineMaterial; // 下层管材 + private String objectType; //标识对象类型 + private String color; // 颜色 + private String imagePath; // 图片路径 + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getPipelineType() { + return pipelineType; + } + + public void setPipelineType(String pipelineType) { + this.pipelineType = pipelineType; + } + + public String getPipelineDiameter() { + return pipelineDiameter; + } + + public void setPipelineDiameter(String pipelineDiameter) { + this.pipelineDiameter = pipelineDiameter; + } + + public String getPipelineMaterial() { + return pipelineMaterial; + } + + public void setPipelineMaterial(String pipelineMaterial) { + this.pipelineMaterial = pipelineMaterial; + } + + public String getBuryMethod() { + return buryMethod; + } + + public void setBuryMethod(String buryMethod) { + this.buryMethod = buryMethod; + } + + public String getBuryDepth() { + return buryDepth; + } + + public void setBuryDepth(String buryDepth) { + this.buryDepth = buryDepth; + } + + public String getArea() { + return area; + } + + public void setArea(String area) { + this.area = area; + } + + public String getLine() { + return line; + } + + public void setLine(String line) { + this.line = line; + } + + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + + public String getConstructTime() { + return constructTime; + } + + public void setConstructTime(String constructTime) { + this.constructTime = constructTime; + } + + public String getOwner() { + return owner; + } + + public void setOwner(String owner) { + this.owner = owner; + } + + public String getObjectId() { + return objectId; + } + + public void setObjectId(String objectId) { + this.objectId = objectId; + } + + public String getMarkerId() { + return markerId; + } + + public void setMarkerId(String markerId) { + this.markerId = markerId; + } + + public String getMarkerType() { + return markerType; + } + + public void setMarkerType(String markerType) { + this.markerType = markerType; + } + + public String getMarkerDepth() { + return markerDepth; + } + + public void setMarkerDepth(String markerDepth) { + this.markerDepth = markerDepth; + } + + public String getInstallationDept() { + return installationDept; + } + + public void setInstallationDept(String installationDept) { + this.installationDept = installationDept; + } + + public String getLng() { + return lng; + } + + public void setLng(String lng) { + this.lng = lng; + } + + public String getLat() { + return lat; + } + + public void setLat(String lat) { + this.lat = lat; + } + + public String getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } + + public String getUnderlyingPipelineType() { + return underlyingPipelineType; + } + + public void setUnderlyingPipelineType(String underlyingPipelineType) { + this.underlyingPipelineType = underlyingPipelineType; + } + + public String getUnderlyingPipelineDepth() { + return underlyingPipelineDepth; + } + + public void setUnderlyingPipelineDepth(String underlyingPipelineDepth) { + this.underlyingPipelineDepth = underlyingPipelineDepth; + } + + public String getUnderlyingPipelineDiameter() { + return underlyingPipelineDiameter; + } + + public void setUnderlyingPipelineDiameter(String underlyingPipelineDiameter) { + this.underlyingPipelineDiameter = underlyingPipelineDiameter; + } + + public String getUnderlyingPipelineMaterial() { + return underlyingPipelineMaterial; + } + + public void setUnderlyingPipelineMaterial(String underlyingPipelineMaterial) { + this.underlyingPipelineMaterial = underlyingPipelineMaterial; + } + + public String getObjectType() { + return objectType; + } + + public void setObjectType(String objectType) { + this.objectType = objectType; + } + + public String getColor() { + return color; + } + + public void setColor(String color) { + this.color = color; + } + + public String getImagePath() { + return imagePath; + } + + public void setImagePath(String imagePath) { + this.imagePath = imagePath; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java deleted file mode 100644 index 3f2fcdc..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java +++ /dev/null @@ -1,327 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 从平台下载的标识器本地库实体类 - */ -@Entity -public class MarkerLocalBean { - @Id(autoincrement = true) - private Long id;//本地库主键ID - - // 管线类型 - private String pipelineType; - // 管线直径 - private String pipelineDiameter; - // 管材 - private String pipelineMaterial; - // 埋设方式 - private String buryMethod; - // 埋深 - private String buryDepth; - // 所属区域 - private String area; - // 所属线路 - private String line; - // 所属道路 - private String road; - // 建设年代 - private String constructTime; - // 权属单位 - private String owner; - //标识对象ID,无实际用途 - @Deprecated - private String objectId; - // 标识器ID - private String markerId; - // 标识器类型 - private String markerType; - // 标识器埋深 - private String markerDepth; - // 安装部门 - private String installationDept; - // 经度 - private String lng; - // 纬度 - private String lat; - //最后修改时间,更新时间 - private String updateTime; - // 备注信息 - private String remark; - // 下层管线类型 - private String underlyingPipelineType; - // 下层埋深 - private String underlyingPipelineDepth; - // 下层管径 - private String underlyingPipelineDiameter; - // 下层管材 - private String underlyingPipelineMaterial; - //标识对象类型 - private String objectType; - // 颜色 - private String color; - // 图片路径 - private String imagePath; - - @Generated(hash = 1479045776) - public MarkerLocalBean(Long id, String pipelineType, String pipelineDiameter, - String pipelineMaterial, String buryMethod, String buryDepth, - String area, String line, String road, String constructTime, - String owner, String objectId, String markerId, String markerType, - String markerDepth, String installationDept, String lng, String lat, - String updateTime, String remark, String underlyingPipelineType, - String underlyingPipelineDepth, String underlyingPipelineDiameter, - String underlyingPipelineMaterial, String objectType, String color, - String imagePath) { - this.id = id; - this.pipelineType = pipelineType; - this.pipelineDiameter = pipelineDiameter; - this.pipelineMaterial = pipelineMaterial; - this.buryMethod = buryMethod; - this.buryDepth = buryDepth; - this.area = area; - this.line = line; - this.road = road; - this.constructTime = constructTime; - this.owner = owner; - this.objectId = objectId; - this.markerId = markerId; - this.markerType = markerType; - this.markerDepth = markerDepth; - this.installationDept = installationDept; - this.lng = lng; - this.lat = lat; - this.updateTime = updateTime; - this.remark = remark; - this.underlyingPipelineType = underlyingPipelineType; - this.underlyingPipelineDepth = underlyingPipelineDepth; - this.underlyingPipelineDiameter = underlyingPipelineDiameter; - this.underlyingPipelineMaterial = underlyingPipelineMaterial; - this.objectType = objectType; - this.color = color; - this.imagePath = imagePath; - } - - @Generated(hash = 1538606012) - public MarkerLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getPipelineType() { - return this.pipelineType; - } - - public void setPipelineType(String pipelineType) { - this.pipelineType = pipelineType; - } - - public String getPipelineDiameter() { - return this.pipelineDiameter; - } - - public void setPipelineDiameter(String pipelineDiameter) { - this.pipelineDiameter = pipelineDiameter; - } - - public String getPipelineMaterial() { - return this.pipelineMaterial; - } - - public void setPipelineMaterial(String pipelineMaterial) { - this.pipelineMaterial = pipelineMaterial; - } - - public String getBuryMethod() { - return this.buryMethod; - } - - public void setBuryMethod(String buryMethod) { - this.buryMethod = buryMethod; - } - - public String getBuryDepth() { - return this.buryDepth; - } - - public void setBuryDepth(String buryDepth) { - this.buryDepth = buryDepth; - } - - public String getArea() { - return this.area; - } - - public void setArea(String area) { - this.area = area; - } - - public String getLine() { - return this.line; - } - - public void setLine(String line) { - this.line = line; - } - - public String getRoad() { - return this.road; - } - - public void setRoad(String road) { - this.road = road; - } - - public String getConstructTime() { - return this.constructTime; - } - - public void setConstructTime(String constructTime) { - this.constructTime = constructTime; - } - - public String getOwner() { - return this.owner; - } - - public void setOwner(String owner) { - this.owner = owner; - } - - public String getObjectId() { - return this.objectId; - } - - public void setObjectId(String objectId) { - this.objectId = objectId; - } - - public String getMarkerId() { - return this.markerId; - } - - public void setMarkerId(String markerId) { - this.markerId = markerId; - } - - public String getMarkerType() { - return this.markerType; - } - - public void setMarkerType(String markerType) { - this.markerType = markerType; - } - - public String getMarkerDepth() { - return this.markerDepth; - } - - public void setMarkerDepth(String markerDepth) { - this.markerDepth = markerDepth; - } - - public String getInstallationDept() { - return this.installationDept; - } - - public void setInstallationDept(String installationDept) { - this.installationDept = installationDept; - } - - public String getLng() { - return this.lng; - } - - public void setLng(String lng) { - this.lng = lng; - } - - public String getLat() { - return this.lat; - } - - public void setLat(String lat) { - this.lat = lat; - } - - public String getUpdateTime() { - return this.updateTime; - } - - public void setUpdateTime(String updateTime) { - this.updateTime = updateTime; - } - - public String getRemark() { - return this.remark; - } - - public void setRemark(String remark) { - this.remark = remark; - } - - public String getUnderlyingPipelineType() { - return this.underlyingPipelineType; - } - - public void setUnderlyingPipelineType(String underlyingPipelineType) { - this.underlyingPipelineType = underlyingPipelineType; - } - - public String getUnderlyingPipelineDepth() { - return this.underlyingPipelineDepth; - } - - public void setUnderlyingPipelineDepth(String underlyingPipelineDepth) { - this.underlyingPipelineDepth = underlyingPipelineDepth; - } - - public String getUnderlyingPipelineDiameter() { - return this.underlyingPipelineDiameter; - } - - public void setUnderlyingPipelineDiameter(String underlyingPipelineDiameter) { - this.underlyingPipelineDiameter = underlyingPipelineDiameter; - } - - public String getUnderlyingPipelineMaterial() { - return this.underlyingPipelineMaterial; - } - - public void setUnderlyingPipelineMaterial(String underlyingPipelineMaterial) { - this.underlyingPipelineMaterial = underlyingPipelineMaterial; - } - - public String getObjectType() { - return this.objectType; - } - - public void setObjectType(String objectType) { - this.objectType = objectType; - } - - public String getColor() { - return this.color; - } - - public void setColor(String color) { - this.color = color; - } - - public String getImagePath() { - return this.imagePath; - } - - public void setImagePath(String imagePath) { - this.imagePath = imagePath; - } -} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java new file mode 100644 index 0000000..5c88fdf --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java @@ -0,0 +1,93 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 巡检任务本地库实体类,不包含任务里面需要巡检的标识器信息 + */ +@Entity(tableName = "task_detail") +public class TaskBean { + @PrimaryKey(autoGenerate = true) + private long id;//主键ID + private String taskCode; // 任务编号 + private String description; // 任务名称 + private String createTime; // 任务创建的时间 + private String status; // 任务状态 + private String createUserName; // 任务创建者名称 + private String startTime; // 任务被开始执行的时间 + private String endTime; // 任务执行结束的时间 + private String isFree; // 是否自由巡检。1-是,0-否 + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getTaskCode() { + return taskCode; + } + + public void setTaskCode(String taskCode) { + this.taskCode = taskCode; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getCreateUserName() { + return createUserName; + } + + public void setCreateUserName(String createUserName) { + this.createUserName = createUserName; + } + + public String getStartTime() { + return startTime; + } + + public void setStartTime(String startTime) { + this.startTime = startTime; + } + + public String getEndTime() { + return endTime; + } + + public void setEndTime(String endTime) { + this.endTime = endTime; + } + + public String getIsFree() { + return isFree; + } + + public void setIsFree(String isFree) { + this.isFree = isFree; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java deleted file mode 100644 index 91737b3..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java +++ /dev/null @@ -1,114 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 巡检任务本地库实体类,不包含任务里面需要巡检的标识器信息 - */ -@Entity -public class TaskLocalBean { - @Id - private Long id;//任务ID - - private String taskCode;//任务编号 - private String description;//任务名称 - private String createTime;//任务创建的时间 - private String status;//任务状态 - private String createUserName;//任务创建者名称 - private String startTime;//任务被开始执行的时间 - private String endTime;//任务执行结束的时间 - private String isFreeTask;//是否自由巡检。1-是,0-否 - - @Generated(hash = 1482022528) - public TaskLocalBean(Long id, String taskCode, String description, - String createTime, String status, String createUserName, - String startTime, String endTime, String isFreeTask) { - this.id = id; - this.taskCode = taskCode; - this.description = description; - this.createTime = createTime; - this.status = status; - this.createUserName = createUserName; - this.startTime = startTime; - this.endTime = endTime; - this.isFreeTask = isFreeTask; - } - - @Generated(hash = 949704588) - public TaskLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getTaskCode() { - return this.taskCode; - } - - public void setTaskCode(String taskCode) { - this.taskCode = taskCode; - } - - public String getDescription() { - return this.description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getCreateTime() { - return this.createTime; - } - - public void setCreateTime(String createTime) { - this.createTime = createTime; - } - - public String getStatus() { - return this.status; - } - - public void setStatus(String status) { - this.status = status; - } - - public String getCreateUserName() { - return this.createUserName; - } - - public void setCreateUserName(String createUserName) { - this.createUserName = createUserName; - } - - public String getStartTime() { - return this.startTime; - } - - public void setStartTime(String startTime) { - this.startTime = startTime; - } - - public String getEndTime() { - return this.endTime; - } - - public void setEndTime(String endTime) { - this.endTime = endTime; - } - - public String getIsFreeTask() { - return this.isFreeTask; - } - - public void setIsFreeTask(String isFreeTask) { - this.isFreeTask = isFreeTask; - } -} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerBean.java new file mode 100644 index 0000000..c563a60 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerBean.java @@ -0,0 +1,110 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 巡检任务里面需要巡检的标识器信息本地库实体类 + */ +@Entity(tableName = "task_marker_info") +public class TaskMarkerBean { + //标识器后台库的主键ID,不是标识器实际ID + @PrimaryKey(autoGenerate = true) + private long id; + + /** + * 任务ID,通过此字段关联[TaskBean.id] + */ + private String taskId; + + /** + * 任务Code,通过此字段关联[TaskBean.taskCode] + *

+ *

+ * 双重验证,防止出现同时刻重复的情况 + */ + private String taskCode; + + /** + * 对应后台字段[TaskModel.MessageModel.TaskDetailInfosModel.markerIdReal],也就是探测仪扫描出来的ID + */ + private String markerId; + + private Double lng; + private Double lat; + + /** + * 是否已被探测到 + * 1-是,0-否 + */ + private String isDetected; + + /** + * 被探测到的时间,对应后台字段[TaskModel.MessageModel.TaskDetailInfosModel.finishTime] + */ + private String detectedTime; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getTaskId() { + return taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getTaskCode() { + return taskCode; + } + + public void setTaskCode(String taskCode) { + this.taskCode = taskCode; + } + + public String getMarkerId() { + return markerId; + } + + public void setMarkerId(String markerId) { + this.markerId = markerId; + } + + public Double getLng() { + return lng; + } + + public void setLng(Double lng) { + this.lng = lng; + } + + public Double getLat() { + return lat; + } + + public void setLat(Double lat) { + this.lat = lat; + } + + public String getIsDetected() { + return isDetected; + } + + public void setIsDetected(String isDetected) { + this.isDetected = isDetected; + } + + public String getDetectedTime() { + return detectedTime; + } + + public void setDetectedTime(String detectedTime) { + this.detectedTime = detectedTime; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerLocalBean.java deleted file mode 100644 index de9f459..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerLocalBean.java +++ /dev/null @@ -1,128 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import com.casic.common.detector.gd.model.TaskModel; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 巡检任务里面需要巡检的标识器信息本地库实体类 - */ -@Entity -public class TaskMarkerLocalBean { - @Id - private Long id;//标识器后台库的主键ID,不是标识器实际ID - - /** - * 任务ID,通过此字段关联{@link TaskLocalBean#id} - */ - private String taskId; - - /** - * 任务Code,通过此字段关联{@link TaskLocalBean#taskCode} - *

- * 双重验证,防止出现同时刻重复的情况 - */ - private String taskCode; - - /** - * 对应后台字段{@link TaskModel.MessageModel.TaskDetailInfosModel#markerIdReal},也就是探测仪扫描出来的ID - */ - private String markerId; - - private double lng; - private double lat; - - /** - * 是否已被探测到 - * 1-是,0-否 - */ - private String isDetected; - - /** - * 被探测到的时间,对应后台字段{@link TaskModel.MessageModel.TaskDetailInfosModel#finishTime} - */ - private String detectedTime; - - @Generated(hash = 677328533) - public TaskMarkerLocalBean(Long id, String taskId, String taskCode, String markerId, - double lng, double lat, String isDetected, String detectedTime) { - this.id = id; - this.taskId = taskId; - this.taskCode = taskCode; - this.markerId = markerId; - this.lng = lng; - this.lat = lat; - this.isDetected = isDetected; - this.detectedTime = detectedTime; - } - - @Generated(hash = 1162404642) - public TaskMarkerLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getTaskId() { - return this.taskId; - } - - public void setTaskId(String taskId) { - this.taskId = taskId; - } - - public String getTaskCode() { - return this.taskCode; - } - - public void setTaskCode(String taskCode) { - this.taskCode = taskCode; - } - - public String getMarkerId() { - return this.markerId; - } - - public void setMarkerId(String markerId) { - this.markerId = markerId; - } - - public double getLng() { - return this.lng; - } - - public void setLng(double lng) { - this.lng = lng; - } - - public double getLat() { - return this.lat; - } - - public void setLat(double lat) { - this.lat = lat; - } - - public String getIsDetected() { - return this.isDetected; - } - - public void setIsDetected(String isDetected) { - this.isDetected = isDetected; - } - - public String getDetectedTime() { - return this.detectedTime; - } - - public void setDetectedTime(String detectedTime) { - this.detectedTime = detectedTime; - } -} diff --git a/app/src/main/java/com/casic/common/detector/gd/dao/MarkerBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/dao/MarkerBeanDao.java new file mode 100644 index 0000000..2beb7ed --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/dao/MarkerBeanDao.java @@ -0,0 +1,29 @@ +package com.casic.common.detector.gd.dao; + +import androidx.room.Dao; +import androidx.room.Insert; +import androidx.room.Query; +import androidx.room.RawQuery; +import androidx.sqlite.db.SupportSQLiteQuery; + +import com.casic.common.detector.gd.bean.MarkerBean; + +import java.util.List; + +@Dao +public interface MarkerBeanDao { + @Query("DELETE FROM marker_detail") + void deleteAll(); + + @Insert + void insert(MarkerBean marker); + + @Query("SELECT * FROM marker_detail") + List loadAll(); + + @Query("SELECT * FROM marker_detail WHERE markerId = :markerId") + List queryMarkerById(String markerId); + + @RawQuery + List loadMarkersByCondition(SupportSQLiteQuery query); +} diff --git a/app/src/main/java/com/casic/common/detector/gd/dao/TaskBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/dao/TaskBeanDao.java new file mode 100644 index 0000000..9c70ac2 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/dao/TaskBeanDao.java @@ -0,0 +1,120 @@ +package com.casic.common.detector.gd.dao; + +import androidx.room.Dao; +import androidx.room.Insert; +import androidx.room.Query; +import androidx.room.Transaction; + +import com.casic.common.detector.gd.bean.TaskBean; +import com.casic.common.detector.gd.bean.TaskMarkerBean; +import com.casic.common.detector.gd.model.TaskDetailLocalModel; +import com.casic.common.detector.gd.model.TaskModel; +import com.casic.common.detector.gd.utils.LocaleConstant; +import com.pengxh.kt.lite.utils.SaveKeyValues; + +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Locale; + +@Dao +public interface TaskBeanDao { + @Query("SELECT COUNT(*) FROM task_detail WHERE id = :taskId") + int isTaskExist(long taskId); + + @Insert + void insert(TaskBean task); + + default void saveTask(Long taskId, String taskName) { + if (isTaskExist(taskId) == 0) { + TaskBean task = new TaskBean(); + task.setId(taskId); + task.setTaskCode(new SimpleDateFormat("yyyyMMddHHmmss", Locale.CHINA).format(new Date())); + task.setDescription(taskName); + String time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA).format(new Date()); + task.setCreateTime(time); + task.setStatus("0"); + String userName = (String) SaveKeyValues.INSTANCE.getValue(LocaleConstant.USER_NAME, ""); + task.setCreateUserName(userName); + task.setStartTime(time); + task.setEndTime(""); + task.setIsFree("1"); + insert(task); + } + } + + default void saveTask(TaskModel.MessageModel model) { + TaskBean task = new TaskBean(); + task.setId(model.getId()); + task.setTaskCode(model.getTaskCode()); + task.setDescription(model.getDescription()); + task.setCreateTime(model.getDeployDate()); + task.setStatus(model.getStatus()); + task.setCreateUserName(model.getCreatorName()); + task.setStartTime(model.getBeginDate()); + task.setEndTime(model.getEndDate()); + task.setIsFree("0"); + if (isTaskExist(task.getId()) == 0) { + insert(task); + } + } + + @Query("SELECT * FROM task_detail") + List loadAll(); + + @Transaction + default ArrayList loadLocalTask(TaskMarkerBeanDao taskMarkerBeanDao) { + ArrayList result = new ArrayList<>(); + List tasks = loadAll(); + for (TaskBean it : tasks) { + TaskDetailLocalModel model = new TaskDetailLocalModel(); + model.setTaskId(String.valueOf(it.getId())); + model.setTaskCode(it.getTaskCode()); + model.setDescription(it.getDescription()); + model.setCreateTime(it.getCreateTime()); + model.setStatus(it.getStatus()); + model.setCreateUserName(it.getCreateUserName()); + model.setIsFreeTask(it.getIsFree()); + ArrayList results = new ArrayList<>(); + if ("0".equals(it.getIsFree())) { + // 非自由巡检才有Marker + List markers = taskMarkerBeanDao.getMarkersByIdAndCode(String.valueOf(it.getId()), it.getTaskCode()); + for (TaskMarkerBean marker : markers) { + TaskDetailLocalModel.TaskMarkerLocalModel localModel = new TaskDetailLocalModel.TaskMarkerLocalModel(); + localModel.setMarkerId(marker.getMarkerId()); + localModel.setLng(marker.getLng()); + localModel.setLat(marker.getLat()); + localModel.setIsDetected(marker.getIsDetected()); + localModel.setDetectedTime(marker.getDetectedTime()); + + results.add(localModel); + } + } + model.setMarkerModels(results); + result.add(model); + } + return result; + } + + @Query("DELETE FROM task_detail WHERE id = :taskId AND taskCode = :taskCode") + void deleteTaskById(long taskId, String taskCode); + + @Transaction + default void deleteLocalTaskById(long taskId, String taskCode, TaskMarkerBeanDao taskMarkerBeanDao) { + TaskBean task = loadAll().stream() + .filter(it -> it.getId() == taskId && taskCode.equals(it.getTaskCode())) + .findFirst() + .orElse(null); + if (task == null) return; + deleteTaskById(taskId, taskCode); + + // 删除此任务关联的Marker。非自由巡检才有Marker + if ("0".equals(task.getIsFree())) { + List markers = taskMarkerBeanDao.getMarkersByIdAndCode(String.valueOf(task.getId()), task.getTaskCode()); + for (TaskMarkerBean marker : markers) { + taskMarkerBeanDao.delete(marker); + } + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/dao/TaskMarkerBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/dao/TaskMarkerBeanDao.java new file mode 100644 index 0000000..cc2156a --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/dao/TaskMarkerBeanDao.java @@ -0,0 +1,52 @@ +package com.casic.common.detector.gd.dao; + +import androidx.room.Dao; +import androidx.room.Delete; +import androidx.room.Insert; +import androidx.room.Query; +import androidx.room.Update; + +import com.casic.common.detector.gd.bean.TaskMarkerBean; +import com.casic.common.detector.gd.model.TaskModel; + +import java.util.List; + +@Dao +public interface TaskMarkerBeanDao { + + @Insert + void insert(TaskMarkerBean marker); + + @Query("SELECT COUNT(*) FROM task_marker_info WHERE id = :markerId") + int isMarkerExist(String markerId); + + default void saveTaskMarker(long taskId, String taskCode, TaskModel.MessageModel.TaskDetailInfosModel marker) { + if (isMarkerExist(marker.getMarkerId()) == 0) { + TaskMarkerBean bean = new TaskMarkerBean(); + bean.setId(marker.getId()); + bean.setTaskId(String.valueOf(taskId)); + bean.setTaskCode(taskCode); + bean.setMarkerId(marker.getMarkerIdReal()); + bean.setLng(marker.getLongitude()); + bean.setLat(marker.getLatitude()); + bean.setIsDetected("0"); + bean.setDetectedTime(""); + insert(bean); + } + } + + @Query("SELECT * FROM task_marker_info WHERE taskId = :taskId AND taskCode = :taskCode AND markerId = :markerId AND isDetected = :state") + TaskMarkerBean queryTaskMarkerById(String taskId, String taskCode, String markerId, String state); + + @Update + void updateLocalTaskMarkerState(TaskMarkerBean marker); + + @Query("SELECT * FROM task_marker_info WHERE isDetected = :state") + List queryMarkerByState(String state); + + @Query("SELECT * FROM task_marker_info WHERE taskId = :taskId AND taskCode = :taskCode") + List getMarkersByIdAndCode(String taskId, String taskCode); + + @Delete + void delete(TaskMarkerBean marker); +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/extensions/Long.kt b/app/src/main/java/com/casic/common/detector/gd/extensions/Long.kt deleted file mode 100644 index 6713d8d..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/extensions/Long.kt +++ /dev/null @@ -1,10 +0,0 @@ -package com.casic.common.detector.gd.extensions - -import java.text.SimpleDateFormat -import java.util.Date -import java.util.Locale - -fun Long.createTaskCode(): String { - val dateFormat = SimpleDateFormat("yyyyMMddHHmmss", Locale.CHINA) - return dateFormat.format(Date(this)) -} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoMaster.java b/app/src/main/java/com/casic/common/detector/gd/greendao/DaoMaster.java deleted file mode 100644 index 6ab94b3..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoMaster.java +++ /dev/null @@ -1,102 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import android.content.Context; -import android.database.sqlite.SQLiteDatabase; -import android.database.sqlite.SQLiteDatabase.CursorFactory; -import android.util.Log; - -import org.greenrobot.greendao.AbstractDaoMaster; -import org.greenrobot.greendao.database.StandardDatabase; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.database.DatabaseOpenHelper; -import org.greenrobot.greendao.identityscope.IdentityScopeType; - - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** - * Master of DAO (schema version 1): knows all DAOs. - */ -public class DaoMaster extends AbstractDaoMaster { - public static final int SCHEMA_VERSION = 1; - - /** Creates underlying database table using DAOs. */ - public static void createAllTables(Database db, boolean ifNotExists) { - MarkerLocalBeanDao.createTable(db, ifNotExists); - TaskLocalBeanDao.createTable(db, ifNotExists); - TaskMarkerLocalBeanDao.createTable(db, ifNotExists); - } - - /** Drops underlying database table using DAOs. */ - public static void dropAllTables(Database db, boolean ifExists) { - MarkerLocalBeanDao.dropTable(db, ifExists); - TaskLocalBeanDao.dropTable(db, ifExists); - TaskMarkerLocalBeanDao.dropTable(db, ifExists); - } - - /** - * WARNING: Drops all table on Upgrade! Use only during development. - * Convenience method using a {@link DevOpenHelper}. - */ - public static DaoSession newDevSession(Context context, String name) { - Database db = new DevOpenHelper(context, name).getWritableDb(); - DaoMaster daoMaster = new DaoMaster(db); - return daoMaster.newSession(); - } - - public DaoMaster(SQLiteDatabase db) { - this(new StandardDatabase(db)); - } - - public DaoMaster(Database db) { - super(db, SCHEMA_VERSION); - registerDaoClass(MarkerLocalBeanDao.class); - registerDaoClass(TaskLocalBeanDao.class); - registerDaoClass(TaskMarkerLocalBeanDao.class); - } - - public DaoSession newSession() { - return new DaoSession(db, IdentityScopeType.Session, daoConfigMap); - } - - public DaoSession newSession(IdentityScopeType type) { - return new DaoSession(db, type, daoConfigMap); - } - - /** - * Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} - - */ - public static abstract class OpenHelper extends DatabaseOpenHelper { - public OpenHelper(Context context, String name) { - super(context, name, SCHEMA_VERSION); - } - - public OpenHelper(Context context, String name, CursorFactory factory) { - super(context, name, factory, SCHEMA_VERSION); - } - - @Override - public void onCreate(Database db) { - Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION); - createAllTables(db, false); - } - } - - /** WARNING: Drops all table on Upgrade! Use only during development. */ - public static class DevOpenHelper extends OpenHelper { - public DevOpenHelper(Context context, String name) { - super(context, name); - } - - public DevOpenHelper(Context context, String name, CursorFactory factory) { - super(context, name, factory); - } - - @Override - public void onUpgrade(Database db, int oldVersion, int newVersion) { - Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables"); - dropAllTables(db, true); - onCreate(db); - } - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoSession.java b/app/src/main/java/com/casic/common/detector/gd/greendao/DaoSession.java deleted file mode 100644 index c8b1a20..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoSession.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import java.util.Map; - -import org.greenrobot.greendao.AbstractDao; -import org.greenrobot.greendao.AbstractDaoSession; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.identityscope.IdentityScopeType; -import org.greenrobot.greendao.internal.DaoConfig; - -import com.casic.common.detector.gd.bean.MarkerLocalBean; -import com.casic.common.detector.gd.bean.TaskLocalBean; -import com.casic.common.detector.gd.bean.TaskMarkerLocalBean; - -import com.casic.common.detector.gd.greendao.MarkerLocalBeanDao; -import com.casic.common.detector.gd.greendao.TaskLocalBeanDao; -import com.casic.common.detector.gd.greendao.TaskMarkerLocalBeanDao; - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. - -/** - * {@inheritDoc} - * - * @see org.greenrobot.greendao.AbstractDaoSession - */ -public class DaoSession extends AbstractDaoSession { - - private final DaoConfig markerLocalBeanDaoConfig; - private final DaoConfig taskLocalBeanDaoConfig; - private final DaoConfig taskMarkerLocalBeanDaoConfig; - - private final MarkerLocalBeanDao markerLocalBeanDao; - private final TaskLocalBeanDao taskLocalBeanDao; - private final TaskMarkerLocalBeanDao taskMarkerLocalBeanDao; - - public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> - daoConfigMap) { - super(db); - - markerLocalBeanDaoConfig = daoConfigMap.get(MarkerLocalBeanDao.class).clone(); - markerLocalBeanDaoConfig.initIdentityScope(type); - - taskLocalBeanDaoConfig = daoConfigMap.get(TaskLocalBeanDao.class).clone(); - taskLocalBeanDaoConfig.initIdentityScope(type); - - taskMarkerLocalBeanDaoConfig = daoConfigMap.get(TaskMarkerLocalBeanDao.class).clone(); - taskMarkerLocalBeanDaoConfig.initIdentityScope(type); - - markerLocalBeanDao = new MarkerLocalBeanDao(markerLocalBeanDaoConfig, this); - taskLocalBeanDao = new TaskLocalBeanDao(taskLocalBeanDaoConfig, this); - taskMarkerLocalBeanDao = new TaskMarkerLocalBeanDao(taskMarkerLocalBeanDaoConfig, this); - - registerDao(MarkerLocalBean.class, markerLocalBeanDao); - registerDao(TaskLocalBean.class, taskLocalBeanDao); - registerDao(TaskMarkerLocalBean.class, taskMarkerLocalBeanDao); - } - - public void clear() { - markerLocalBeanDaoConfig.clearIdentityScope(); - taskLocalBeanDaoConfig.clearIdentityScope(); - taskMarkerLocalBeanDaoConfig.clearIdentityScope(); - } - - public MarkerLocalBeanDao getMarkerLocalBeanDao() { - return markerLocalBeanDao; - } - - public TaskLocalBeanDao getTaskLocalBeanDao() { - return taskLocalBeanDao; - } - - public TaskMarkerLocalBeanDao getTaskMarkerLocalBeanDao() { - return taskMarkerLocalBeanDao; - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/MarkerLocalBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/greendao/MarkerLocalBeanDao.java deleted file mode 100644 index 2f792c3..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/MarkerLocalBeanDao.java +++ /dev/null @@ -1,479 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import android.database.Cursor; -import android.database.sqlite.SQLiteStatement; - -import org.greenrobot.greendao.AbstractDao; -import org.greenrobot.greendao.Property; -import org.greenrobot.greendao.internal.DaoConfig; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.database.DatabaseStatement; - -import com.casic.common.detector.gd.bean.MarkerLocalBean; - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** - * DAO for table "MARKER_LOCAL_BEAN". -*/ -public class MarkerLocalBeanDao extends AbstractDao { - - public static final String TABLENAME = "MARKER_LOCAL_BEAN"; - - /** - * Properties of entity MarkerLocalBean.
- * Can be used for QueryBuilder and for referencing column names. - */ - public static class Properties { - public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property PipelineType = new Property(1, String.class, "pipelineType", false, "PIPELINE_TYPE"); - public final static Property PipelineDiameter = new Property(2, String.class, "pipelineDiameter", false, "PIPELINE_DIAMETER"); - public final static Property PipelineMaterial = new Property(3, String.class, "pipelineMaterial", false, "PIPELINE_MATERIAL"); - public final static Property BuryMethod = new Property(4, String.class, "buryMethod", false, "BURY_METHOD"); - public final static Property BuryDepth = new Property(5, String.class, "buryDepth", false, "BURY_DEPTH"); - public final static Property Area = new Property(6, String.class, "area", false, "AREA"); - public final static Property Line = new Property(7, String.class, "line", false, "LINE"); - public final static Property Road = new Property(8, String.class, "road", false, "ROAD"); - public final static Property ConstructTime = new Property(9, String.class, "constructTime", false, "CONSTRUCT_TIME"); - public final static Property Owner = new Property(10, String.class, "owner", false, "OWNER"); - public final static Property ObjectId = new Property(11, String.class, "objectId", false, "OBJECT_ID"); - public final static Property MarkerId = new Property(12, String.class, "markerId", false, "MARKER_ID"); - public final static Property MarkerType = new Property(13, String.class, "markerType", false, "MARKER_TYPE"); - public final static Property MarkerDepth = new Property(14, String.class, "markerDepth", false, "MARKER_DEPTH"); - public final static Property InstallationDept = new Property(15, String.class, "installationDept", false, "INSTALLATION_DEPT"); - public final static Property Lng = new Property(16, String.class, "lng", false, "LNG"); - public final static Property Lat = new Property(17, String.class, "lat", false, "LAT"); - public final static Property UpdateTime = new Property(18, String.class, "updateTime", false, "UPDATE_TIME"); - public final static Property Remark = new Property(19, String.class, "remark", false, "REMARK"); - public final static Property UnderlyingPipelineType = new Property(20, String.class, "underlyingPipelineType", false, "UNDERLYING_PIPELINE_TYPE"); - public final static Property UnderlyingPipelineDepth = new Property(21, String.class, "underlyingPipelineDepth", false, "UNDERLYING_PIPELINE_DEPTH"); - public final static Property UnderlyingPipelineDiameter = new Property(22, String.class, "underlyingPipelineDiameter", false, "UNDERLYING_PIPELINE_DIAMETER"); - public final static Property UnderlyingPipelineMaterial = new Property(23, String.class, "underlyingPipelineMaterial", false, "UNDERLYING_PIPELINE_MATERIAL"); - public final static Property ObjectType = new Property(24, String.class, "objectType", false, "OBJECT_TYPE"); - public final static Property Color = new Property(25, String.class, "color", false, "COLOR"); - public final static Property ImagePath = new Property(26, String.class, "imagePath", false, "IMAGE_PATH"); - } - - - public MarkerLocalBeanDao(DaoConfig config) { - super(config); - } - - public MarkerLocalBeanDao(DaoConfig config, DaoSession daoSession) { - super(config, daoSession); - } - - /** Creates the underlying database table. */ - public static void createTable(Database db, boolean ifNotExists) { - String constraint = ifNotExists? "IF NOT EXISTS ": ""; - db.execSQL("CREATE TABLE " + constraint + "\"MARKER_LOCAL_BEAN\" (" + // - "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id - "\"PIPELINE_TYPE\" TEXT," + // 1: pipelineType - "\"PIPELINE_DIAMETER\" TEXT," + // 2: pipelineDiameter - "\"PIPELINE_MATERIAL\" TEXT," + // 3: pipelineMaterial - "\"BURY_METHOD\" TEXT," + // 4: buryMethod - "\"BURY_DEPTH\" TEXT," + // 5: buryDepth - "\"AREA\" TEXT," + // 6: area - "\"LINE\" TEXT," + // 7: line - "\"ROAD\" TEXT," + // 8: road - "\"CONSTRUCT_TIME\" TEXT," + // 9: constructTime - "\"OWNER\" TEXT," + // 10: owner - "\"OBJECT_ID\" TEXT," + // 11: objectId - "\"MARKER_ID\" TEXT," + // 12: markerId - "\"MARKER_TYPE\" TEXT," + // 13: markerType - "\"MARKER_DEPTH\" TEXT," + // 14: markerDepth - "\"INSTALLATION_DEPT\" TEXT," + // 15: installationDept - "\"LNG\" TEXT," + // 16: lng - "\"LAT\" TEXT," + // 17: lat - "\"UPDATE_TIME\" TEXT," + // 18: updateTime - "\"REMARK\" TEXT," + // 19: remark - "\"UNDERLYING_PIPELINE_TYPE\" TEXT," + // 20: underlyingPipelineType - "\"UNDERLYING_PIPELINE_DEPTH\" TEXT," + // 21: underlyingPipelineDepth - "\"UNDERLYING_PIPELINE_DIAMETER\" TEXT," + // 22: underlyingPipelineDiameter - "\"UNDERLYING_PIPELINE_MATERIAL\" TEXT," + // 23: underlyingPipelineMaterial - "\"OBJECT_TYPE\" TEXT," + // 24: objectType - "\"COLOR\" TEXT," + // 25: color - "\"IMAGE_PATH\" TEXT);"); // 26: imagePath - } - - /** Drops the underlying database table. */ - public static void dropTable(Database db, boolean ifExists) { - String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"MARKER_LOCAL_BEAN\""; - db.execSQL(sql); - } - - @Override - protected final void bindValues(DatabaseStatement stmt, MarkerLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String pipelineType = entity.getPipelineType(); - if (pipelineType != null) { - stmt.bindString(2, pipelineType); - } - - String pipelineDiameter = entity.getPipelineDiameter(); - if (pipelineDiameter != null) { - stmt.bindString(3, pipelineDiameter); - } - - String pipelineMaterial = entity.getPipelineMaterial(); - if (pipelineMaterial != null) { - stmt.bindString(4, pipelineMaterial); - } - - String buryMethod = entity.getBuryMethod(); - if (buryMethod != null) { - stmt.bindString(5, buryMethod); - } - - String buryDepth = entity.getBuryDepth(); - if (buryDepth != null) { - stmt.bindString(6, buryDepth); - } - - String area = entity.getArea(); - if (area != null) { - stmt.bindString(7, area); - } - - String line = entity.getLine(); - if (line != null) { - stmt.bindString(8, line); - } - - String road = entity.getRoad(); - if (road != null) { - stmt.bindString(9, road); - } - - String constructTime = entity.getConstructTime(); - if (constructTime != null) { - stmt.bindString(10, constructTime); - } - - String owner = entity.getOwner(); - if (owner != null) { - stmt.bindString(11, owner); - } - - String objectId = entity.getObjectId(); - if (objectId != null) { - stmt.bindString(12, objectId); - } - - String markerId = entity.getMarkerId(); - if (markerId != null) { - stmt.bindString(13, markerId); - } - - String markerType = entity.getMarkerType(); - if (markerType != null) { - stmt.bindString(14, markerType); - } - - String markerDepth = entity.getMarkerDepth(); - if (markerDepth != null) { - stmt.bindString(15, markerDepth); - } - - String installationDept = entity.getInstallationDept(); - if (installationDept != null) { - stmt.bindString(16, installationDept); - } - - String lng = entity.getLng(); - if (lng != null) { - stmt.bindString(17, lng); - } - - String lat = entity.getLat(); - if (lat != null) { - stmt.bindString(18, lat); - } - - String updateTime = entity.getUpdateTime(); - if (updateTime != null) { - stmt.bindString(19, updateTime); - } - - String remark = entity.getRemark(); - if (remark != null) { - stmt.bindString(20, remark); - } - - String underlyingPipelineType = entity.getUnderlyingPipelineType(); - if (underlyingPipelineType != null) { - stmt.bindString(21, underlyingPipelineType); - } - - String underlyingPipelineDepth = entity.getUnderlyingPipelineDepth(); - if (underlyingPipelineDepth != null) { - stmt.bindString(22, underlyingPipelineDepth); - } - - String underlyingPipelineDiameter = entity.getUnderlyingPipelineDiameter(); - if (underlyingPipelineDiameter != null) { - stmt.bindString(23, underlyingPipelineDiameter); - } - - String underlyingPipelineMaterial = entity.getUnderlyingPipelineMaterial(); - if (underlyingPipelineMaterial != null) { - stmt.bindString(24, underlyingPipelineMaterial); - } - - String objectType = entity.getObjectType(); - if (objectType != null) { - stmt.bindString(25, objectType); - } - - String color = entity.getColor(); - if (color != null) { - stmt.bindString(26, color); - } - - String imagePath = entity.getImagePath(); - if (imagePath != null) { - stmt.bindString(27, imagePath); - } - } - - @Override - protected final void bindValues(SQLiteStatement stmt, MarkerLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String pipelineType = entity.getPipelineType(); - if (pipelineType != null) { - stmt.bindString(2, pipelineType); - } - - String pipelineDiameter = entity.getPipelineDiameter(); - if (pipelineDiameter != null) { - stmt.bindString(3, pipelineDiameter); - } - - String pipelineMaterial = entity.getPipelineMaterial(); - if (pipelineMaterial != null) { - stmt.bindString(4, pipelineMaterial); - } - - String buryMethod = entity.getBuryMethod(); - if (buryMethod != null) { - stmt.bindString(5, buryMethod); - } - - String buryDepth = entity.getBuryDepth(); - if (buryDepth != null) { - stmt.bindString(6, buryDepth); - } - - String area = entity.getArea(); - if (area != null) { - stmt.bindString(7, area); - } - - String line = entity.getLine(); - if (line != null) { - stmt.bindString(8, line); - } - - String road = entity.getRoad(); - if (road != null) { - stmt.bindString(9, road); - } - - String constructTime = entity.getConstructTime(); - if (constructTime != null) { - stmt.bindString(10, constructTime); - } - - String owner = entity.getOwner(); - if (owner != null) { - stmt.bindString(11, owner); - } - - String objectId = entity.getObjectId(); - if (objectId != null) { - stmt.bindString(12, objectId); - } - - String markerId = entity.getMarkerId(); - if (markerId != null) { - stmt.bindString(13, markerId); - } - - String markerType = entity.getMarkerType(); - if (markerType != null) { - stmt.bindString(14, markerType); - } - - String markerDepth = entity.getMarkerDepth(); - if (markerDepth != null) { - stmt.bindString(15, markerDepth); - } - - String installationDept = entity.getInstallationDept(); - if (installationDept != null) { - stmt.bindString(16, installationDept); - } - - String lng = entity.getLng(); - if (lng != null) { - stmt.bindString(17, lng); - } - - String lat = entity.getLat(); - if (lat != null) { - stmt.bindString(18, lat); - } - - String updateTime = entity.getUpdateTime(); - if (updateTime != null) { - stmt.bindString(19, updateTime); - } - - String remark = entity.getRemark(); - if (remark != null) { - stmt.bindString(20, remark); - } - - String underlyingPipelineType = entity.getUnderlyingPipelineType(); - if (underlyingPipelineType != null) { - stmt.bindString(21, underlyingPipelineType); - } - - String underlyingPipelineDepth = entity.getUnderlyingPipelineDepth(); - if (underlyingPipelineDepth != null) { - stmt.bindString(22, underlyingPipelineDepth); - } - - String underlyingPipelineDiameter = entity.getUnderlyingPipelineDiameter(); - if (underlyingPipelineDiameter != null) { - stmt.bindString(23, underlyingPipelineDiameter); - } - - String underlyingPipelineMaterial = entity.getUnderlyingPipelineMaterial(); - if (underlyingPipelineMaterial != null) { - stmt.bindString(24, underlyingPipelineMaterial); - } - - String objectType = entity.getObjectType(); - if (objectType != null) { - stmt.bindString(25, objectType); - } - - String color = entity.getColor(); - if (color != null) { - stmt.bindString(26, color); - } - - String imagePath = entity.getImagePath(); - if (imagePath != null) { - stmt.bindString(27, imagePath); - } - } - - @Override - public Long readKey(Cursor cursor, int offset) { - return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); - } - - @Override - public MarkerLocalBean readEntity(Cursor cursor, int offset) { - MarkerLocalBean entity = new MarkerLocalBean( // - cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // pipelineType - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // pipelineDiameter - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // pipelineMaterial - cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // buryMethod - cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // buryDepth - cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // area - cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // line - cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // road - cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // constructTime - cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10), // owner - cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11), // objectId - cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12), // markerId - cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13), // markerType - cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14), // markerDepth - cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15), // installationDept - cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16), // lng - cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17), // lat - cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18), // updateTime - cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19), // remark - cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20), // underlyingPipelineType - cursor.isNull(offset + 21) ? null : cursor.getString(offset + 21), // underlyingPipelineDepth - cursor.isNull(offset + 22) ? null : cursor.getString(offset + 22), // underlyingPipelineDiameter - cursor.isNull(offset + 23) ? null : cursor.getString(offset + 23), // underlyingPipelineMaterial - cursor.isNull(offset + 24) ? null : cursor.getString(offset + 24), // objectType - cursor.isNull(offset + 25) ? null : cursor.getString(offset + 25), // color - cursor.isNull(offset + 26) ? null : cursor.getString(offset + 26) // imagePath - ); - return entity; - } - - @Override - public void readEntity(Cursor cursor, MarkerLocalBean entity, int offset) { - entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setPipelineType(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); - entity.setPipelineDiameter(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); - entity.setPipelineMaterial(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); - entity.setBuryMethod(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); - entity.setBuryDepth(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); - entity.setArea(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); - entity.setLine(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); - entity.setRoad(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); - entity.setConstructTime(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9)); - entity.setOwner(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); - entity.setObjectId(cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11)); - entity.setMarkerId(cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12)); - entity.setMarkerType(cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13)); - entity.setMarkerDepth(cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14)); - entity.setInstallationDept(cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15)); - entity.setLng(cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16)); - entity.setLat(cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17)); - entity.setUpdateTime(cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18)); - entity.setRemark(cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19)); - entity.setUnderlyingPipelineType(cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20)); - entity.setUnderlyingPipelineDepth(cursor.isNull(offset + 21) ? null : cursor.getString(offset + 21)); - entity.setUnderlyingPipelineDiameter(cursor.isNull(offset + 22) ? null : cursor.getString(offset + 22)); - entity.setUnderlyingPipelineMaterial(cursor.isNull(offset + 23) ? null : cursor.getString(offset + 23)); - entity.setObjectType(cursor.isNull(offset + 24) ? null : cursor.getString(offset + 24)); - entity.setColor(cursor.isNull(offset + 25) ? null : cursor.getString(offset + 25)); - entity.setImagePath(cursor.isNull(offset + 26) ? null : cursor.getString(offset + 26)); - } - - @Override - protected final Long updateKeyAfterInsert(MarkerLocalBean entity, long rowId) { - entity.setId(rowId); - return rowId; - } - - @Override - public Long getKey(MarkerLocalBean entity) { - if(entity != null) { - return entity.getId(); - } else { - return null; - } - } - - @Override - public boolean hasKey(MarkerLocalBean entity) { - return entity.getId() != null; - } - - @Override - protected final boolean isEntityUpdateable() { - return true; - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/TaskLocalBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/greendao/TaskLocalBeanDao.java deleted file mode 100644 index fb88157..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/TaskLocalBeanDao.java +++ /dev/null @@ -1,227 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import android.database.Cursor; -import android.database.sqlite.SQLiteStatement; - -import org.greenrobot.greendao.AbstractDao; -import org.greenrobot.greendao.Property; -import org.greenrobot.greendao.internal.DaoConfig; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.database.DatabaseStatement; - -import com.casic.common.detector.gd.bean.TaskLocalBean; - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** - * DAO for table "TASK_LOCAL_BEAN". -*/ -public class TaskLocalBeanDao extends AbstractDao { - - public static final String TABLENAME = "TASK_LOCAL_BEAN"; - - /** - * Properties of entity TaskLocalBean.
- * Can be used for QueryBuilder and for referencing column names. - */ - public static class Properties { - public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property TaskCode = new Property(1, String.class, "taskCode", false, "TASK_CODE"); - public final static Property Description = new Property(2, String.class, "description", false, "DESCRIPTION"); - public final static Property CreateTime = new Property(3, String.class, "createTime", false, "CREATE_TIME"); - public final static Property Status = new Property(4, String.class, "status", false, "STATUS"); - public final static Property CreateUserName = new Property(5, String.class, "createUserName", false, "CREATE_USER_NAME"); - public final static Property StartTime = new Property(6, String.class, "startTime", false, "START_TIME"); - public final static Property EndTime = new Property(7, String.class, "endTime", false, "END_TIME"); - public final static Property IsFreeTask = new Property(8, String.class, "isFreeTask", false, "IS_FREE_TASK"); - } - - - public TaskLocalBeanDao(DaoConfig config) { - super(config); - } - - public TaskLocalBeanDao(DaoConfig config, DaoSession daoSession) { - super(config, daoSession); - } - - /** Creates the underlying database table. */ - public static void createTable(Database db, boolean ifNotExists) { - String constraint = ifNotExists? "IF NOT EXISTS ": ""; - db.execSQL("CREATE TABLE " + constraint + "\"TASK_LOCAL_BEAN\" (" + // - "\"_id\" INTEGER PRIMARY KEY ," + // 0: id - "\"TASK_CODE\" TEXT," + // 1: taskCode - "\"DESCRIPTION\" TEXT," + // 2: description - "\"CREATE_TIME\" TEXT," + // 3: createTime - "\"STATUS\" TEXT," + // 4: status - "\"CREATE_USER_NAME\" TEXT," + // 5: createUserName - "\"START_TIME\" TEXT," + // 6: startTime - "\"END_TIME\" TEXT," + // 7: endTime - "\"IS_FREE_TASK\" TEXT);"); // 8: isFreeTask - } - - /** Drops the underlying database table. */ - public static void dropTable(Database db, boolean ifExists) { - String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"TASK_LOCAL_BEAN\""; - db.execSQL(sql); - } - - @Override - protected final void bindValues(DatabaseStatement stmt, TaskLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String taskCode = entity.getTaskCode(); - if (taskCode != null) { - stmt.bindString(2, taskCode); - } - - String description = entity.getDescription(); - if (description != null) { - stmt.bindString(3, description); - } - - String createTime = entity.getCreateTime(); - if (createTime != null) { - stmt.bindString(4, createTime); - } - - String status = entity.getStatus(); - if (status != null) { - stmt.bindString(5, status); - } - - String createUserName = entity.getCreateUserName(); - if (createUserName != null) { - stmt.bindString(6, createUserName); - } - - String startTime = entity.getStartTime(); - if (startTime != null) { - stmt.bindString(7, startTime); - } - - String endTime = entity.getEndTime(); - if (endTime != null) { - stmt.bindString(8, endTime); - } - - String isFreeTask = entity.getIsFreeTask(); - if (isFreeTask != null) { - stmt.bindString(9, isFreeTask); - } - } - - @Override - protected final void bindValues(SQLiteStatement stmt, TaskLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String taskCode = entity.getTaskCode(); - if (taskCode != null) { - stmt.bindString(2, taskCode); - } - - String description = entity.getDescription(); - if (description != null) { - stmt.bindString(3, description); - } - - String createTime = entity.getCreateTime(); - if (createTime != null) { - stmt.bindString(4, createTime); - } - - String status = entity.getStatus(); - if (status != null) { - stmt.bindString(5, status); - } - - String createUserName = entity.getCreateUserName(); - if (createUserName != null) { - stmt.bindString(6, createUserName); - } - - String startTime = entity.getStartTime(); - if (startTime != null) { - stmt.bindString(7, startTime); - } - - String endTime = entity.getEndTime(); - if (endTime != null) { - stmt.bindString(8, endTime); - } - - String isFreeTask = entity.getIsFreeTask(); - if (isFreeTask != null) { - stmt.bindString(9, isFreeTask); - } - } - - @Override - public Long readKey(Cursor cursor, int offset) { - return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); - } - - @Override - public TaskLocalBean readEntity(Cursor cursor, int offset) { - TaskLocalBean entity = new TaskLocalBean( // - cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // taskCode - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // description - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // createTime - cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // status - cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // createUserName - cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // startTime - cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // endTime - cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8) // isFreeTask - ); - return entity; - } - - @Override - public void readEntity(Cursor cursor, TaskLocalBean entity, int offset) { - entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setTaskCode(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); - entity.setDescription(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); - entity.setCreateTime(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); - entity.setStatus(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); - entity.setCreateUserName(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); - entity.setStartTime(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); - entity.setEndTime(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); - entity.setIsFreeTask(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); - } - - @Override - protected final Long updateKeyAfterInsert(TaskLocalBean entity, long rowId) { - entity.setId(rowId); - return rowId; - } - - @Override - public Long getKey(TaskLocalBean entity) { - if(entity != null) { - return entity.getId(); - } else { - return null; - } - } - - @Override - public boolean hasKey(TaskLocalBean entity) { - return entity.getId() != null; - } - - @Override - protected final boolean isEntityUpdateable() { - return true; - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/TaskMarkerLocalBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/greendao/TaskMarkerLocalBeanDao.java deleted file mode 100644 index e96c735..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/TaskMarkerLocalBeanDao.java +++ /dev/null @@ -1,197 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import android.database.Cursor; -import android.database.sqlite.SQLiteStatement; - -import org.greenrobot.greendao.AbstractDao; -import org.greenrobot.greendao.Property; -import org.greenrobot.greendao.internal.DaoConfig; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.database.DatabaseStatement; - -import com.casic.common.detector.gd.bean.TaskMarkerLocalBean; - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** - * DAO for table "TASK_MARKER_LOCAL_BEAN". -*/ -public class TaskMarkerLocalBeanDao extends AbstractDao { - - public static final String TABLENAME = "TASK_MARKER_LOCAL_BEAN"; - - /** - * Properties of entity TaskMarkerLocalBean.
- * Can be used for QueryBuilder and for referencing column names. - */ - public static class Properties { - public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property TaskId = new Property(1, String.class, "taskId", false, "TASK_ID"); - public final static Property TaskCode = new Property(2, String.class, "taskCode", false, "TASK_CODE"); - public final static Property MarkerId = new Property(3, String.class, "markerId", false, "MARKER_ID"); - public final static Property Lng = new Property(4, double.class, "lng", false, "LNG"); - public final static Property Lat = new Property(5, double.class, "lat", false, "LAT"); - public final static Property IsDetected = new Property(6, String.class, "isDetected", false, "IS_DETECTED"); - public final static Property DetectedTime = new Property(7, String.class, "detectedTime", false, "DETECTED_TIME"); - } - - - public TaskMarkerLocalBeanDao(DaoConfig config) { - super(config); - } - - public TaskMarkerLocalBeanDao(DaoConfig config, DaoSession daoSession) { - super(config, daoSession); - } - - /** Creates the underlying database table. */ - public static void createTable(Database db, boolean ifNotExists) { - String constraint = ifNotExists? "IF NOT EXISTS ": ""; - db.execSQL("CREATE TABLE " + constraint + "\"TASK_MARKER_LOCAL_BEAN\" (" + // - "\"_id\" INTEGER PRIMARY KEY ," + // 0: id - "\"TASK_ID\" TEXT," + // 1: taskId - "\"TASK_CODE\" TEXT," + // 2: taskCode - "\"MARKER_ID\" TEXT," + // 3: markerId - "\"LNG\" REAL NOT NULL ," + // 4: lng - "\"LAT\" REAL NOT NULL ," + // 5: lat - "\"IS_DETECTED\" TEXT," + // 6: isDetected - "\"DETECTED_TIME\" TEXT);"); // 7: detectedTime - } - - /** Drops the underlying database table. */ - public static void dropTable(Database db, boolean ifExists) { - String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"TASK_MARKER_LOCAL_BEAN\""; - db.execSQL(sql); - } - - @Override - protected final void bindValues(DatabaseStatement stmt, TaskMarkerLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String taskId = entity.getTaskId(); - if (taskId != null) { - stmt.bindString(2, taskId); - } - - String taskCode = entity.getTaskCode(); - if (taskCode != null) { - stmt.bindString(3, taskCode); - } - - String markerId = entity.getMarkerId(); - if (markerId != null) { - stmt.bindString(4, markerId); - } - stmt.bindDouble(5, entity.getLng()); - stmt.bindDouble(6, entity.getLat()); - - String isDetected = entity.getIsDetected(); - if (isDetected != null) { - stmt.bindString(7, isDetected); - } - - String detectedTime = entity.getDetectedTime(); - if (detectedTime != null) { - stmt.bindString(8, detectedTime); - } - } - - @Override - protected final void bindValues(SQLiteStatement stmt, TaskMarkerLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String taskId = entity.getTaskId(); - if (taskId != null) { - stmt.bindString(2, taskId); - } - - String taskCode = entity.getTaskCode(); - if (taskCode != null) { - stmt.bindString(3, taskCode); - } - - String markerId = entity.getMarkerId(); - if (markerId != null) { - stmt.bindString(4, markerId); - } - stmt.bindDouble(5, entity.getLng()); - stmt.bindDouble(6, entity.getLat()); - - String isDetected = entity.getIsDetected(); - if (isDetected != null) { - stmt.bindString(7, isDetected); - } - - String detectedTime = entity.getDetectedTime(); - if (detectedTime != null) { - stmt.bindString(8, detectedTime); - } - } - - @Override - public Long readKey(Cursor cursor, int offset) { - return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); - } - - @Override - public TaskMarkerLocalBean readEntity(Cursor cursor, int offset) { - TaskMarkerLocalBean entity = new TaskMarkerLocalBean( // - cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // taskId - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // taskCode - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // markerId - cursor.getDouble(offset + 4), // lng - cursor.getDouble(offset + 5), // lat - cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // isDetected - cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7) // detectedTime - ); - return entity; - } - - @Override - public void readEntity(Cursor cursor, TaskMarkerLocalBean entity, int offset) { - entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setTaskId(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); - entity.setTaskCode(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); - entity.setMarkerId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); - entity.setLng(cursor.getDouble(offset + 4)); - entity.setLat(cursor.getDouble(offset + 5)); - entity.setIsDetected(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); - entity.setDetectedTime(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); - } - - @Override - protected final Long updateKeyAfterInsert(TaskMarkerLocalBean entity, long rowId) { - entity.setId(rowId); - return rowId; - } - - @Override - public Long getKey(TaskMarkerLocalBean entity) { - if(entity != null) { - return entity.getId(); - } else { - return null; - } - } - - @Override - public boolean hasKey(TaskMarkerLocalBean entity) { - return entity.getId() != null; - } - - @Override - protected final boolean isEntityUpdateable() { - return true; - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/model/TaskModel.java b/app/src/main/java/com/casic/common/detector/gd/model/TaskModel.java index 6e853ad..67ef5fb 100644 --- a/app/src/main/java/com/casic/common/detector/gd/model/TaskModel.java +++ b/app/src/main/java/com/casic/common/detector/gd/model/TaskModel.java @@ -24,7 +24,7 @@ } public static class MessageModel { - private int id; + private Long id; private String taskCode; private String description; private String deployDate; @@ -38,11 +38,11 @@ private int isValid; private List taskDetailInfos; - public int getId() { + public Long getId() { return id; } - public void setId(int id) { + public void setId(Long id) { this.id = id; } @@ -143,25 +143,25 @@ } public static class TaskDetailInfosModel { - private int id; + private long id; private String taskId; private String taskCode; private Object markerName; - private int markerId; + private String markerId; private String markerIdReal; private double longitude; private double latitude; private int isChecked; private int isNormal; - private Object imagePath; - private Object description; - private Object finishTime; + private String imagePath; + private String description; + private String finishTime; - public int getId() { + public long getId() { return id; } - public void setId(int id) { + public void setId(long id) { this.id = id; } @@ -189,11 +189,11 @@ this.markerName = markerName; } - public int getMarkerId() { + public String getMarkerId() { return markerId; } - public void setMarkerId(int markerId) { + public void setMarkerId(String markerId) { this.markerId = markerId; } @@ -237,27 +237,27 @@ this.isNormal = isNormal; } - public Object getImagePath() { + public String getImagePath() { return imagePath; } - public void setImagePath(Object imagePath) { + public void setImagePath(String imagePath) { this.imagePath = imagePath; } - public Object getDescription() { + public String getDescription() { return description; } - public void setDescription(Object description) { + public void setDescription(String description) { this.description = description; } - public Object getFinishTime() { + public String getFinishTime() { return finishTime; } - public void setFinishTime(Object finishTime) { + public void setFinishTime(String finishTime) { this.finishTime = finishTime; } } diff --git a/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitService.kt index 7522a87..0adad51 100644 --- a/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitService.kt @@ -50,7 +50,7 @@ */ @Multipart @POST("/ems/marker/save-marker-photo.do") - suspend fun installLabel( + suspend fun install( @PartMap jsonMarker: Map, @Part fileBuffer1: MultipartBody.Part?, @Part fileBuffer2: MultipartBody.Part?, diff --git a/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitServiceManager.kt index 5f6c701..ae2a0fa 100644 --- a/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitServiceManager.kt +++ b/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitServiceManager.kt @@ -37,22 +37,28 @@ /** * 获取标识器信息文件 */ - suspend fun getMarkerFile(userId: String, companyId: String): String { - return createApi().getMarkerFile(userId, companyId) + suspend fun getMarkerFile(): String { + val companyId = SaveKeyValues.getValue(LocaleConstant.USER_COMPANY_ID, "") as String + /** + * 后台设计如此,都传companyId + * */ + return createApi().getMarkerFile(companyId, companyId) } /** * 获取巡检工单 */ - suspend fun getTasksByUser(userName: String): String { + suspend fun getTasksByUser(): String { + val userName = SaveKeyValues.getValue(LocaleConstant.USER_NAME, "") as String return createApi().getTasksByUser(userName) } /** * 提交工单 */ - suspend fun uploadTask(userId: String, taskId: String?, state: String): String { + suspend fun uploadTask(taskId: String?, state: String): String { + val userId = SaveKeyValues.getValue(LocaleConstant.USER_ID, "") as String return createApi().uploadTask(userId, taskId.toString(), state) } @@ -60,8 +66,7 @@ * 安装新标识器 * Multipart上传图片,文件,带多参数上传 */ - suspend fun installLabel( - companyId: String, + suspend fun installMarker( recordType: String, markerObjectType: String, pipeMaterial: String, @@ -77,7 +82,6 @@ road: String, constructTime: String, ownerComp: String, - markerObjectId: String, markerId: String, markerType: String, markerDepth: String, @@ -89,6 +93,8 @@ memo: String, realPaths: ArrayList ): String { + val companyId = SaveKeyValues.getValue(LocaleConstant.USER_COMPANY_ID, "") as String + val objectId = SaveKeyValues.getValue(LocaleConstant.OBJECT_ID, "") as String val param = JsonObject() param.addProperty("companyId", companyId) param.addProperty("recordType", recordType) @@ -106,7 +112,7 @@ param.addProperty("road", road) param.addProperty("constructTime", constructTime) param.addProperty("ownerComp", ownerComp) - param.addProperty("markerObjectId", markerObjectId) + param.addProperty("markerObjectId", objectId) param.addProperty("markerId", markerId) param.addProperty("markerType", markerType) param.addProperty("markerDepth", markerDepth) @@ -133,19 +139,19 @@ return when (multiParts.size) { 3 -> { - createApi().installLabel(res, multiParts[0], multiParts[1], multiParts[2]) + createApi().install(res, multiParts[0], multiParts[1], multiParts[2]) } 2 -> { - createApi().installLabel(res, multiParts[0], multiParts[1], null) + createApi().install(res, multiParts[0], multiParts[1], null) } 1 -> { - createApi().installLabel(res, multiParts[0], null, null) + createApi().install(res, multiParts[0], null, null) } else -> { - createApi().installLabel(res, null, null, null) + createApi().install(res, null, null, null) } } } @@ -216,7 +222,7 @@ /** * 上传自由巡检过程中发现的标识器 */ - suspend fun uploadTaskMarker(taskId: String, ids: ArrayList): String { + suspend fun uploadTaskMarker(taskId: Long, ids: ArrayList): String { val param = JsonObject() param.addProperty("taskId", taskId) param.addProperty("ids", ids.joinToString(separator = ",")) diff --git a/app/src/main/java/com/casic/common/detector/gd/service/NtripConnectService.kt b/app/src/main/java/com/casic/common/detector/gd/service/NtripConnectService.kt index de9ac80..20e1a6a 100644 --- a/app/src/main/java/com/casic/common/detector/gd/service/NtripConnectService.kt +++ b/app/src/main/java/com/casic/common/detector/gd/service/NtripConnectService.kt @@ -9,10 +9,6 @@ import android.util.Log import android.view.Gravity import android.widget.Toast -import androidx.lifecycle.Lifecycle -import androidx.lifecycle.LifecycleOwner -import androidx.lifecycle.LifecycleRegistry -import androidx.lifecycle.lifecycleScope import com.casic.common.detector.gd.base.BaseApplication import com.casic.common.detector.gd.extensions.convertToGPGGA import com.casic.common.detector.gd.utils.LocaleConstant @@ -23,26 +19,24 @@ import com.pengxh.kt.lite.utils.WeakReferenceHandler import com.pengxh.kt.lite.utils.socket.tcp.OnTcpConnectStateListener import com.pengxh.kt.lite.utils.socket.tcp.TcpClient +import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.Job import kotlinx.coroutines.launch import java.io.OutputStream import java.nio.charset.StandardCharsets -class NtripConnectService : Service(), LifecycleOwner, OnTcpConnectStateListener, Handler.Callback { +class NtripConnectService : Service(), OnTcpConnectStateListener, Handler.Callback { companion object { var weakReferenceHandler: WeakReferenceHandler? = null } private val kTag = "NtripConnectService" - private val registry = LifecycleRegistry(this) private val socketClient by lazy { TcpClient(this) } private var outStream: OutputStream? = null - - override fun getLifecycle(): Lifecycle { - return registry - } + private val serviceScope = CoroutineScope(Dispatchers.Main + Job()) // 创建一个独立的CoroutineScope override fun onBind(intent: Intent?): IBinder? { return null @@ -117,7 +111,7 @@ * */ val result = String(this, StandardCharsets.UTF_8) if (result.contains("ICY 200 OK")) { - lifecycleScope.launch(Dispatchers.Main) { + serviceScope.launch { "高精度定位服务连接成功".show(this@NtripConnectService) } //连接服务即打开串口 @@ -135,12 +129,12 @@ * Content-Type: text/plain * Connection: clos * */ - lifecycleScope.launch(Dispatchers.Main) { + serviceScope.launch { "差分定位服务鉴权失败,无法解析位置".show(this@NtripConnectService) } } else { //居中显示 - lifecycleScope.launch(Dispatchers.Main) { + serviceScope.launch { val toast = Toast.makeText( this@NtripConnectService, "收到千寻数据,长度:${size}", Toast.LENGTH_SHORT ) @@ -167,7 +161,7 @@ return } - lifecycleScope.launch(Dispatchers.IO) { + serviceScope.launch(Dispatchers.IO) { socketClient.start(remoteHost, remotePort.toInt()) } } diff --git a/app/src/main/java/com/casic/common/detector/gd/utils/DataBaseManager.kt b/app/src/main/java/com/casic/common/detector/gd/utils/DataBaseManager.kt deleted file mode 100644 index aa22759..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/utils/DataBaseManager.kt +++ /dev/null @@ -1,200 +0,0 @@ -package com.casic.common.detector.gd.utils - -import com.casic.common.detector.gd.base.BaseApplication -import com.casic.common.detector.gd.bean.MarkerLocalBean -import com.casic.common.detector.gd.bean.TaskLocalBean -import com.casic.common.detector.gd.bean.TaskMarkerLocalBean -import com.casic.common.detector.gd.greendao.MarkerLocalBeanDao -import com.casic.common.detector.gd.greendao.TaskLocalBeanDao -import com.casic.common.detector.gd.greendao.TaskMarkerLocalBeanDao -import com.casic.common.detector.gd.model.TaskDetailLocalModel -import com.casic.common.detector.gd.model.TaskModel - -class DataBaseManager private constructor() { - companion object { - //Kotlin委托模式双重锁单例 - val get by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) { - DataBaseManager() - } - } - - private var taskLocalBeanDao = BaseApplication.get().getDaoSession().taskLocalBeanDao - private var taskMarkerLocalBeanDao = - BaseApplication.get().getDaoSession().taskMarkerLocalBeanDao - - fun saveTaskInLocale(task: TaskModel.MessageModel) { - val bean = TaskLocalBean() - bean.id = task.id.toLong() - bean.taskCode = task.taskCode - bean.description = task.description - bean.createTime = task.deployDate - bean.status = task.status - bean.createUserName = task.creatorName - if (task.beginDate == null) { - bean.startTime = "" - } - if (task.endDate == null) { - bean.endTime = "" - } - bean.isFreeTask = "0" - if (!bean.isExist()) { - taskLocalBeanDao.insert(bean) - } - } - - fun saveTaskInLocale(bean: TaskLocalBean) { - if (!bean.isExist()) { - taskLocalBeanDao.insert(bean) - } - } - - private fun TaskLocalBean.isExist(): Boolean { - val result = taskLocalBeanDao.queryBuilder().where( - TaskLocalBeanDao.Properties.Id.eq(this.id) - ).list() - return !result.isNullOrEmpty() - } - - fun saveTaskMarkerInLocale( - taskId: Int, taskCode: String, marker: TaskModel.MessageModel.TaskDetailInfosModel - ) { - val bean = TaskMarkerLocalBean() - bean.id = marker.id.toLong() - bean.taskId = taskId.toString() - bean.taskCode = taskCode - bean.markerId = marker.markerIdReal - bean.lng = marker.longitude - bean.lat = marker.latitude - bean.isDetected = "0" - bean.detectedTime = "" - if (!bean.isExist()) { - taskMarkerLocalBeanDao.insert(bean) - } - } - - private fun TaskMarkerLocalBean.isExist(): Boolean { - val result = taskMarkerLocalBeanDao.queryBuilder().where( - TaskMarkerLocalBeanDao.Properties.Id.eq(this.id) - ).list() - return !result.isNullOrEmpty() - } - - fun loadLocalTask(): ArrayList { - val result = ArrayList() - - val tasks = taskLocalBeanDao.loadAll() - tasks.forEach { - val model = TaskDetailLocalModel() - model.taskId = it.id.toString() - model.taskCode = it.taskCode - model.description = it.description - model.createTime = it.createTime - model.status = it.status - model.createUserName = it.createUserName - model.isFreeTask = it.isFreeTask - - val markers = ArrayList() - if (it.isFreeTask == "0") { - //非自由巡检才有Marker - val markerLocalBeans = taskMarkerLocalBeanDao.queryBuilder().where( - TaskMarkerLocalBeanDao.Properties.TaskId.eq(it.id), - TaskMarkerLocalBeanDao.Properties.TaskCode.eq(it.taskCode) - ).list() - markerLocalBeans.forEach { marker -> - val localModel = TaskDetailLocalModel.TaskMarkerLocalModel() - localModel.markerId = marker.markerId - localModel.lng = marker.lng - localModel.lat = marker.lat - localModel.isDetected = marker.isDetected - localModel.detectedTime = marker.detectedTime - - markers.add(localModel) - } - } - model.markerModels = markers - result.add(model) - } - return result - } - - fun deleteLocalTaskById(taskId: String, taskCode: String) { - val task = taskLocalBeanDao.queryBuilder().where( - TaskLocalBeanDao.Properties.Id.eq(taskId), - TaskLocalBeanDao.Properties.TaskCode.eq(taskCode) - ).list().firstOrNull() ?: return - taskLocalBeanDao.delete(task) - - //删除此任务关联的Marker。非自由巡检才有Marker - if (task.isFreeTask == "0") { - val markers = taskMarkerLocalBeanDao.queryBuilder() - .where( - TaskMarkerLocalBeanDao.Properties.TaskId.eq(taskId), - TaskMarkerLocalBeanDao.Properties.TaskCode.eq(taskCode) - ).list() - markers.forEach { - taskMarkerLocalBeanDao.delete(it) - } - } - } - - fun queryTaskMarkerById( - taskId: String, taskCode: String, markerId: String, state: String - ): TaskMarkerLocalBean? { - return taskMarkerLocalBeanDao.queryBuilder() - .where( - TaskMarkerLocalBeanDao.Properties.TaskId.eq(taskId), - TaskMarkerLocalBeanDao.Properties.TaskCode.eq(taskCode), - TaskMarkerLocalBeanDao.Properties.MarkerId.eq(markerId), - TaskMarkerLocalBeanDao.Properties.IsDetected.eq(state) - ).list().firstOrNull() - } - - fun updateLocalTaskMarkerState(marker: TaskMarkerLocalBean) { - marker.isDetected = "1" - taskMarkerLocalBeanDao.update(marker) - } - - fun queryMarkerByState(state: String): List { - return taskMarkerLocalBeanDao.queryBuilder() - .where(TaskMarkerLocalBeanDao.Properties.IsDetected.eq(state)) - .list() - } - - private var markerLocalBeanDao = BaseApplication.get().getDaoSession().markerLocalBeanDao - - fun clearMarkers() { - markerLocalBeanDao.deleteAll() - } - - fun saveMarkerInLocale(bean: MarkerLocalBean) { - markerLocalBeanDao.insert(bean) - } - - fun loadMarkers(): MutableList { - return markerLocalBeanDao.loadAll() - } - - fun loadMarkersByCondition(selectedItem: String, value: String?): MutableList { - val property = when (selectedItem) { - LocaleConstant.SPINNER_ARRAY[0] -> MarkerLocalBeanDao.Properties.MarkerId - LocaleConstant.SPINNER_ARRAY[1] -> MarkerLocalBeanDao.Properties.Area - LocaleConstant.SPINNER_ARRAY[2] -> MarkerLocalBeanDao.Properties.Line - LocaleConstant.SPINNER_ARRAY[3] -> MarkerLocalBeanDao.Properties.Road - LocaleConstant.SPINNER_ARRAY[4] -> MarkerLocalBeanDao.Properties.Owner - LocaleConstant.SPINNER_ARRAY[5] -> MarkerLocalBeanDao.Properties.InstallationDept - LocaleConstant.SPINNER_ARRAY[6] -> MarkerLocalBeanDao.Properties.UpdateTime - else -> MarkerLocalBeanDao.Properties.Remark - } - return if (value == null) { - markerLocalBeanDao.queryBuilder().where(property.isNotNull).list() - } else { - markerLocalBeanDao.queryBuilder().where(property.eq(value)).list() - } - } - - fun queryMarkerById(markerId: String): List { - return markerLocalBeanDao.queryBuilder() - .where(MarkerLocalBeanDao.Properties.MarkerId.eq(markerId)) - .list() - } -} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/utils/DetectorDataBase.java b/app/src/main/java/com/casic/common/detector/gd/utils/DetectorDataBase.java new file mode 100644 index 0000000..f686cac --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/utils/DetectorDataBase.java @@ -0,0 +1,21 @@ +package com.casic.common.detector.gd.utils; + +import androidx.room.Database; +import androidx.room.RoomDatabase; + +import com.casic.common.detector.gd.bean.MarkerBean; +import com.casic.common.detector.gd.bean.TaskBean; +import com.casic.common.detector.gd.bean.TaskMarkerBean; +import com.casic.common.detector.gd.dao.MarkerBeanDao; +import com.casic.common.detector.gd.dao.TaskBeanDao; +import com.casic.common.detector.gd.dao.TaskMarkerBeanDao; + + +@Database(entities = {MarkerBean.class, TaskBean.class, TaskMarkerBean.class}, version = 1) +public abstract class DetectorDataBase extends RoomDatabase { + public abstract MarkerBeanDao markerBeanDao(); + + public abstract TaskBeanDao taskBeanDao(); + + public abstract TaskMarkerBeanDao taskMarkerBeanDao(); +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/utils/ExcelKit.kt b/app/src/main/java/com/casic/common/detector/gd/utils/ExcelKit.kt index 200fac7..015969f 100644 --- a/app/src/main/java/com/casic/common/detector/gd/utils/ExcelKit.kt +++ b/app/src/main/java/com/casic/common/detector/gd/utils/ExcelKit.kt @@ -1,19 +1,19 @@ package com.casic.common.detector.gd.utils -import com.casic.common.detector.gd.bean.MarkerLocalBean +import com.casic.common.detector.gd.base.BaseApplication +import com.casic.common.detector.gd.bean.MarkerBean import jxl.Workbook import jxl.read.biff.BiffException import java.io.File object ExcelKit { - fun read(filePath: String): ArrayList { - val result = ArrayList() + fun read(filePath: String): ArrayList { + val result = ArrayList() try { val workbook = Workbook.getWorkbook(File(filePath)) val sheet = workbook.getSheet(0) - for (i in 1 until sheet.rows) { - val marker = MarkerLocalBean() + val marker = MarkerBean() marker.pipelineType = sheet.getCell(0, i).contents marker.pipelineDiameter = sheet.getCell(1, i).contents marker.pipelineMaterial = sheet.getCell(2, i).contents @@ -40,9 +40,10 @@ marker.objectType = sheet.getCell(23, i).contents marker.color = sheet.getCell(24, i).contents marker.imagePath = sheet.getCell(25, i).contents - - result.add(marker) - DataBaseManager.get.saveMarkerInLocale(marker) + if (!marker.markerId.isNullOrBlank()) { + result.add(marker) + BaseApplication.get().dataBase.markerBeanDao().insert(marker) + } } workbook.close() } catch (e: BiffException) { diff --git a/app/src/main/java/com/casic/common/detector/gd/utils/LocaleConstant.kt b/app/src/main/java/com/casic/common/detector/gd/utils/LocaleConstant.kt index c658924..8ac5f76 100644 --- a/app/src/main/java/com/casic/common/detector/gd/utils/LocaleConstant.kt +++ b/app/src/main/java/com/casic/common/detector/gd/utils/LocaleConstant.kt @@ -1,6 +1,8 @@ package com.casic.common.detector.gd.utils import android.Manifest +import androidx.sqlite.db.SimpleSQLiteQuery +import androidx.sqlite.db.SupportSQLiteQuery object LocaleConstant { @@ -59,4 +61,19 @@ var BURY_METHOD_ARRAY = arrayOf("直埋", "圆管", "管块", "管沟", "架空") var IDENTIFIER_TYPE_ARRAY = arrayOf("EM30", "EM50", "EM14") var COLOR_ARRAY = arrayOf("蓝色", "橙色", "红色", "黑色", "紫色", "黄色", "绿色") + + fun buildQuery(selectedItem: String, value: String): SupportSQLiteQuery { + val columnName = when (selectedItem) { + SPINNER_ARRAY[0] -> "markerId" + SPINNER_ARRAY[1] -> "area" + SPINNER_ARRAY[2] -> "line" + SPINNER_ARRAY[3] -> "road" + SPINNER_ARRAY[4] -> "owner" + SPINNER_ARRAY[5] -> "installationDept" + SPINNER_ARRAY[6] -> "updateTime" + else -> "remark" + } + val queryBuilder = StringBuilder("SELECT * FROM marker_detail WHERE $columnName = ?") + return SimpleSQLiteQuery(queryBuilder.toString(), arrayOf(value)) + } } \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/view/InstallMarkerActivity.kt b/app/src/main/java/com/casic/common/detector/gd/view/InstallMarkerActivity.kt index daf5b0f..9e09df1 100644 --- a/app/src/main/java/com/casic/common/detector/gd/view/InstallMarkerActivity.kt +++ b/app/src/main/java/com/casic/common/detector/gd/view/InstallMarkerActivity.kt @@ -14,8 +14,9 @@ import com.amap.api.location.AMapLocation import com.casic.common.detector.gd.R import com.casic.common.detector.gd.adapter.EditableImageAdapter +import com.casic.common.detector.gd.base.BaseApplication import com.casic.common.detector.gd.base.SerialPortBaseActivity -import com.casic.common.detector.gd.bean.MarkerLocalBean +import com.casic.common.detector.gd.bean.MarkerBean import com.casic.common.detector.gd.callback.OnGetLocationListener import com.casic.common.detector.gd.callback.OnImageCompressListener import com.casic.common.detector.gd.databinding.ActivityInstallMarkerBinding @@ -27,7 +28,6 @@ import com.casic.common.detector.gd.extensions.toColor import com.casic.common.detector.gd.extensions.toObjectType import com.casic.common.detector.gd.utils.CurrentSegment -import com.casic.common.detector.gd.utils.DataBaseManager import com.casic.common.detector.gd.utils.LocaleConstant import com.casic.common.detector.gd.utils.LocationKit import com.casic.common.detector.gd.utils.RuntimeCache @@ -44,7 +44,6 @@ import com.pengxh.kt.lite.extensions.timestampToCompleteDate import com.pengxh.kt.lite.extensions.timestampToTime import com.pengxh.kt.lite.extensions.toJson -import com.pengxh.kt.lite.utils.LoadState import com.pengxh.kt.lite.utils.LoadingDialog import com.pengxh.kt.lite.utils.SaveKeyValues import com.pengxh.kt.lite.widget.TitleBarView @@ -115,8 +114,6 @@ //安装 binding.installButton.setOnClickListener { - val companyId = SaveKeyValues.getValue(LocaleConstant.USER_COMPANY_ID, "") as String - val objectId = SaveKeyValues.getValue(LocaleConstant.OBJECT_ID, "") as String if (binding.objectInclude.pipeInclude.markerObjectTypeView.text.isNullOrBlank()) { when (binding.objectInclude.objectTypeSpinner.selectedItem.toString()) { "管线" -> "请输入管线种类!".show(this) @@ -189,8 +186,7 @@ //先存本地再上传服务器 saveMarkerInLocal() - taskViewModel.installLabel( - this, companyId, + taskViewModel.installMarker( binding.objectInclude.objectTypeSpinner.selectedItem.toString().toObjectType(), binding.objectInclude.pipeInclude.markerObjectTypeView.text.toString(), binding.objectInclude.pipeInclude.materialSpinner.selectedItem.toString(), @@ -206,7 +202,6 @@ binding.objectInclude.roadView.text.toString(), binding.objectInclude.constructDateView.text.toString(), binding.objectInclude.ownerView.text.toString(), - objectId, binding.identifierInclude.identifierIdView.text.toString(), binding.identifierInclude.identifierTypeSpinner.selectedItem.toString(), "${binding.identifierInclude.identifierDeepView.text}mm", @@ -216,7 +211,19 @@ binding.identifierInclude.latView.text.toString(), binding.identifierInclude.colorSpinner.selectedItem.toString().toColor(), binding.remarkView.text.toString(), - realPaths + realPaths, + onLoading = { + LoadingDialog.show(this, "标识器安装中,请稍后...") + }, + onSuccess = { + LoadingDialog.dismiss() + clearDefaultData() + "安装成功".show(this) + }, + onFailed = { + LoadingDialog.dismiss() + it.show(this) + } ) //保存默认值 @@ -268,7 +275,7 @@ private fun saveMarkerInLocal() { val objectId = SaveKeyValues.getValue(LocaleConstant.OBJECT_ID, "") as String - val marker = MarkerLocalBean() + val marker = MarkerBean() marker.objectType = binding.objectInclude.objectTypeSpinner.selectedItem.toString() marker.pipelineType = binding.objectInclude.pipeInclude.markerObjectTypeView.text.toString() marker.pipelineMaterial = @@ -302,7 +309,7 @@ marker.remark = binding.remarkView.text.toString() marker.imagePath = realPaths.toJson() - DataBaseManager.get.saveMarkerInLocale(marker) + BaseApplication.get().dataBase.markerBeanDao().insert(marker) } private fun takePicture() { @@ -339,8 +346,8 @@ override fun initOnCreate(savedInstanceState: Bundle?) { locationKit.getCurrentLocation(true, object : OnGetLocationListener { override fun onSuccess(location: AMapLocation) { - binding.identifierInclude.lngView.text = location.longitude.toString() - binding.identifierInclude.latView.text = location.latitude.toString() + binding.identifierInclude.lngView.text = "${location.longitude}" + binding.identifierInclude.latView.text = "${location.latitude}" } override fun onError() { @@ -357,22 +364,6 @@ return ActivityInstallMarkerBinding.inflate(layoutInflater) } - override fun observeRequestState() { - taskViewModel.loadState.observe(this) { - when (it) { - LoadState.Loading -> LoadingDialog.show(this, "标识器安装中,请稍后...") - - LoadState.Success -> { - LoadingDialog.dismiss() - clearDefaultData() - "安装成功".show(this) - } - - else -> LoadingDialog.dismiss() - } - } - } - override fun setupTopBarLayout() { binding.rootView.initImmersionBar(this, true, R.color.white) binding.titleView.setOnClickListener(object : TitleBarView.OnClickListener { diff --git a/app/src/main/java/com/casic/common/detector/gd/view/MainActivity.kt b/app/src/main/java/com/casic/common/detector/gd/view/MainActivity.kt index fb0b260..a6352fb 100644 --- a/app/src/main/java/com/casic/common/detector/gd/view/MainActivity.kt +++ b/app/src/main/java/com/casic/common/detector/gd/view/MainActivity.kt @@ -5,7 +5,6 @@ import android.graphics.Color import android.media.AudioAttributes import android.media.SoundPool -import android.os.Build import android.os.Bundle import android.os.CountDownTimer import android.os.Handler @@ -31,19 +30,17 @@ import com.casic.common.detector.gd.R import com.casic.common.detector.gd.base.BaseApplication import com.casic.common.detector.gd.base.SerialPortBaseActivity -import com.casic.common.detector.gd.bean.MarkerLocalBean -import com.casic.common.detector.gd.bean.TaskLocalBean +import com.casic.common.detector.gd.bean.MarkerBean import com.casic.common.detector.gd.callback.OnGetAddressListener import com.casic.common.detector.gd.callback.OnGetLocationListener import com.casic.common.detector.gd.databinding.ActivityMainBinding import com.casic.common.detector.gd.extensions.appendDownloadUrl -import com.casic.common.detector.gd.extensions.createTaskCode import com.casic.common.detector.gd.extensions.initImmersionBar +import com.casic.common.detector.gd.model.MarkerFileModel import com.casic.common.detector.gd.model.TaskDetailLocalModel import com.casic.common.detector.gd.model.TaskModel import com.casic.common.detector.gd.service.NtripConnectService import com.casic.common.detector.gd.utils.CurrentSegment -import com.casic.common.detector.gd.utils.DataBaseManager import com.casic.common.detector.gd.utils.ExcelKit import com.casic.common.detector.gd.utils.FileType import com.casic.common.detector.gd.utils.LocaleConstant @@ -62,9 +59,7 @@ import com.pengxh.kt.lite.extensions.isNetworkConnected import com.pengxh.kt.lite.extensions.navigatePageTo import com.pengxh.kt.lite.extensions.show -import com.pengxh.kt.lite.extensions.timestampToCompleteDate import com.pengxh.kt.lite.utils.FileDownloadManager -import com.pengxh.kt.lite.utils.LoadState import com.pengxh.kt.lite.utils.LoadingDialog import com.pengxh.kt.lite.utils.SaveKeyValues import com.pengxh.kt.lite.widget.TitleBarView @@ -86,6 +81,9 @@ private val samplePopupWindow by lazy { SamplePopupWindow(this) } private val detailDialog by lazy { MarkerDetailDialog(this) } private val locationKit by lazy { LocationKit(this) } + private val markerBeanDao by lazy { BaseApplication.get().dataBase.markerBeanDao() } + private val taskBeanDao by lazy { BaseApplication.get().dataBase.taskBeanDao() } + private val taskMarkerBeanDao by lazy { BaseApplication.get().dataBase.taskMarkerBeanDao() } private val taskViewModel by lazy { ViewModelProvider(this)[TaskViewModel::class.java] } private val attr = AudioAttributes.Builder().setUsage(AudioAttributes.USAGE_ALARM) .setContentType(AudioAttributes.CONTENT_TYPE_MUSIC).build() @@ -94,7 +92,7 @@ private var isFreeTask = false private var freeTaskTitle = "" private var ids = ArrayList() - private var freeTaskId: String? = null + private var freeTaskId = 0L private var soundResourceId = 0 private var isExecuteTask = false private lateinit var aMap: AMap @@ -111,89 +109,14 @@ //地图初始化 initMapConfig(savedInstanceState) - Intent(this, NtripConnectService::class.java).also { - startService(it) - } +// Intent(this, NtripConnectService::class.java).apply { +// startService(this) +// } soundResourceId = soundPool.load(this, R.raw.ring3, 1) //右上角菜单 samplePopupWindow.setPopupMenuItem(LocaleConstant.POPUP_TITLES) samplePopupWindow.setBackgroundDrawable(null) - - //task网络请求监听 - taskViewModel.markerFileResult.observe(this) { - if (it.isSuccess) { - //清空之前的数据 - DataBaseManager.get.clearMarkers() - //下载最新的数据 - val companyId = SaveKeyValues.getValue(LocaleConstant.USER_COMPANY_ID, "") - val downloadUrl = companyId.toString().appendDownloadUrl(FileType.Excel) - Log.d(kTag, "downloadUrl => $downloadUrl") - FileDownloadManager.Builder().setDownloadFileSource(downloadUrl) - .setFileSuffix("xls").setFileSaveDirectory(createDownloadFileDir()) - .setOnFileDownloadListener(object : FileDownloadManager.OnFileDownloadListener { - override fun onDownloadStart(total: Long) { - - } - - override fun onDownloadEnd(file: File) { - lifecycleScope.launch(Dispatchers.IO) { ExcelKit.read(file.absolutePath) } - LoadingDialog.dismiss() - showMarkersOnMap() - } - - override fun onDownloadFailed(t: Throwable) { - t.printStackTrace() - } - - override fun onProgressChanged(progress: Long) { - - } - }).build().start() - } - } - taskViewModel.taskResult.observe(this) { - if (it.success == "true") { - AlertMessageDialog.Builder().setContext(this).setTitle("温馨提示") - .setMessage("您有${it.message.size}个新任务!").setPositiveButton("知道了") - .setOnDialogButtonClickListener(object : - AlertMessageDialog.OnDialogButtonClickListener { - override fun onConfirmClick() { - saveUserTasks(it) - } - }).build().show() - } - } - taskViewModel.freeTaskResult.observe(this) { - freeTaskId = it - // 自由巡检保存在本地 - val bean = TaskLocalBean() - bean.id = freeTaskId.toString().toLong() - val currentTimeMillis = System.currentTimeMillis() - bean.taskCode = currentTimeMillis.createTaskCode() - bean.description = freeTaskTitle - val time = currentTimeMillis.timestampToCompleteDate() - bean.createTime = time - bean.status = "0" - val userName = SaveKeyValues.getValue(LocaleConstant.USER_NAME, "") as String - bean.createUserName = userName - bean.startTime = time - bean.endTime = "" - bean.isFreeTask = "1" - DataBaseManager.get.saveTaskInLocale(bean) - } - taskViewModel.uploadTaskMarkerResult.observe(this) { - "自由巡检任务已完成".show(this) - ids.clear() - //清空自由巡检添加的Marker - aMap.clear() - showMarkersOnMap() - } - taskViewModel.executeTaskResult.observe(this) { - "工单任务已完成".show(this) - aMap.clear() - showMarkersOnMap() - } } override fun initEvent() { @@ -216,7 +139,7 @@ }).build().show() } else { lifecycleScope.launch(Dispatchers.Main) { - val markers = DataBaseManager.get.queryMarkerByState("0") + val markers = taskMarkerBeanDao.queryMarkerByState("0") //如果有需要补全的标识器,Popup右侧会有小圆点提示 if (markers.isNotEmpty()) { samplePopupWindow.setShowPosition(4) @@ -239,13 +162,7 @@ 3 -> uploadEvent() 4 -> completionMarker() 5 -> showRtkConfigDialog() - 6 -> { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { - SatelliteStatusDialog(context).show() - } else { - "卫星数据仅支持Android 7.0以上系统".show(context) - } - } + 6 -> SatelliteStatusDialog(context).show() } } }) @@ -268,25 +185,23 @@ //查看 binding.viewButton.setOnClickListener { - QueryMarkerDialog.Builder().setContext(this).setTitle("查看标识器") - .setSpinnerArray(LocaleConstant.SPINNER_ARRAY).setNegativeButton("取消") + QueryMarkerDialog.Builder() + .setContext(this) + .setTitle("查看标识器") + .setSpinnerArray(LocaleConstant.SPINNER_ARRAY) + .setNegativeButton("取消") .setPositiveButton("确定").setOnDialogButtonClickListener(object : QueryMarkerDialog.OnDialogButtonClickListener { override fun onConfirmClick(selectedItem: String, value: String) { //查询数据库 - lifecycleScope.launch(Dispatchers.Main) { - val markers = DataBaseManager.get.loadMarkersByCondition( - selectedItem, value - ) as ArrayList - - if (markers.isEmpty()) { - "无法查到相关数据信息,请检查您的查询条件".show(context) - } else { + val buildQuery = LocaleConstant.buildQuery(selectedItem, value) + markerBeanDao.loadMarkersByCondition(buildQuery).run { + if (isNotEmpty()) { val latitudeList = ArrayList() val longitudeList = ArrayList() - val latitude = markers.first().lat - val longitude = markers.first().lng + val latitude = first().lat + val longitude = first().lng if (latitude.isNotBlank() && longitude.isNotBlank()) { if (CoordinateConverter.isAMapDataAvailable( latitude.toDouble(), longitude.toDouble() @@ -300,10 +215,11 @@ if (latitudeList.isNotEmpty() && longitudeList.isNotEmpty()) { //移动地图到所有labelBeans的第一个点 - val center = LatLng(latitudeList.first(), longitudeList.first()) - //移动到指定经纬度 - aMap.moveCamera(CameraUpdateFactory.newLatLngZoom(center, 16f)) + val target = LatLng(latitudeList.first(), longitudeList.first()) + aMap.moveCamera(CameraUpdateFactory.newLatLngZoom(target, 16f)) } + } else { + "无法查到相关信息,请检查您的查询条件".show(context) } } } @@ -316,32 +232,39 @@ //巡检 binding.inspectionButton.setOnClickListener { - val tasks = DataBaseManager.get.loadLocalTask() - if (tasks.isNotEmpty()) { - val arrayList = ArrayList() - tasks.forEachIndexed { index, task -> - arrayList.add("任务${index + 1}:${task.taskId},${task.description}") + lifecycleScope.launch { + val tasks = withContext(Dispatchers.IO) { + taskBeanDao.loadLocalTask(taskMarkerBeanDao) } + if (tasks.isNotEmpty()) { + val arrayList = ArrayList() + tasks.forEachIndexed { index, task -> + arrayList.add("任务${index + 1}:${task.taskId},${task.description}") + } - BottomActionSheet.Builder().setContext(this).setItemTextColor(Color.BLUE) - .setActionItemTitle(arrayList) - .setOnActionSheetListener(object : BottomActionSheet.OnActionSheetListener { - override fun onActionItemClick(position: Int) { - val task = tasks[position] - SaveKeyValues.putValue(LocaleConstant.TASK_ID, task.taskId) - SaveKeyValues.putValue(LocaleConstant.TASK_CODE, task.taskCode) - executeTask(task) - } - }).build().show() - } else { - AlertMessageDialog.Builder().setContext(this).setTitle("温馨提示") - .setMessage("所有任务已完成,请点击右上角菜单下载新工单或者开始自由巡检") - .setPositiveButton("开始自由巡检").setOnDialogButtonClickListener(object : - AlertMessageDialog.OnDialogButtonClickListener { - override fun onConfirmClick() { - executeFreeTask() - } - }).build().show() + BottomActionSheet.Builder().setContext(context) + .setItemTextColor(Color.BLUE) + .setActionItemTitle(arrayList) + .setOnActionSheetListener(object : BottomActionSheet.OnActionSheetListener { + override fun onActionItemClick(position: Int) { + val task = tasks[position] + SaveKeyValues.putValue(LocaleConstant.TASK_ID, task.taskId) + SaveKeyValues.putValue(LocaleConstant.TASK_CODE, task.taskCode) + executeTask(task) + } + }).build().show() + } else { + AlertMessageDialog.Builder() + .setContext(context) + .setTitle("温馨提示") + .setMessage("所有任务已完成,请点击右上角菜单下载新工单或者开始自由巡检") + .setPositiveButton("开始自由巡检").setOnDialogButtonClickListener(object : + AlertMessageDialog.OnDialogButtonClickListener { + override fun onConfirmClick() { + executeFreeTask() + } + }).build().show() + } } } @@ -371,8 +294,11 @@ //自由巡检 binding.stopFreeTaskButton.setOnLongClickListener { - AlertMessageDialog.Builder().setContext(this).setTitle("温馨提示") - .setMessage("是否确定结束此次自由巡检任务?").setPositiveButton("是") + AlertMessageDialog.Builder() + .setContext(this) + .setTitle("温馨提示") + .setMessage("是否确定结束此次自由巡检任务?") + .setPositiveButton("是") .setOnDialogButtonClickListener(object : AlertMessageDialog.OnDialogButtonClickListener { override fun onConfirmClick() { @@ -381,14 +307,38 @@ stopSerialPortCommand() binding.stopFreeTaskButton.visibility = View.GONE - if (freeTaskId.isNullOrBlank()) { + if (freeTaskId == 0L) { "任务ID异常,无法提交任务,请联系服务器管理员".show(context) return } - freeTaskId?.apply { - taskViewModel.uploadTaskMarker(context, this, ids) - } + taskViewModel.uploadTaskMarker( + freeTaskId, + ids, + onLoading = { + LoadingDialog.show(context, "任务提交中,请稍后...") + }, + onSuccess = { + LoadingDialog.dismiss() + "自由巡检任务已完成".show(context) + ids.clear() + aMap.clear() + showMarkersOnMap() + + //删除本地数据库 + val taskCode = SaveKeyValues.getValue( + LocaleConstant.TASK_CODE, "" + ) as String + taskBeanDao.deleteLocalTaskById( + freeTaskId, taskCode, taskMarkerBeanDao + ) + SaveKeyValues.putValue(LocaleConstant.TASK_ID, "") + }, + onFailed = { + LoadingDialog.dismiss() + it.show(context) + } + ) } }).build().show() true @@ -399,25 +349,52 @@ RtkConfigDialog(this).setOnDialogButtonClickListener(object : RtkConfigDialog.OnDialogButtonClickListener { override fun onConfirmClick() { - NtripConnectService.weakReferenceHandler?.apply { - sendEmptyMessage(2024082201) - } + NtripConnectService.weakReferenceHandler?.sendEmptyMessage(2024082201) } }).show() } private fun uploadTask(taskId: String, taskCode: String, state: String) { if (isNetworkConnected()) { - val userId = SaveKeyValues.getValue(LocaleConstant.USER_ID, "") as String - taskViewModel.uploadTask(this, userId, taskId, taskCode, state) + taskViewModel.uploadTask( + taskId, state, + onLoading = { + LoadingDialog.show(this, "工单提交中,请稍后...") + }, + onSuccess = { + LoadingDialog.dismiss() + //工单提交之后,并且状态是2,删除本地Task记录 + if (state == "2") { + "工单${taskId}已提交!".show(this) + //删除本地数据库 + taskBeanDao.deleteLocalTaskById( + taskId.toLong(), taskCode, taskMarkerBeanDao + ) + SaveKeyValues.putValue(LocaleConstant.TASK_ID, "") + } else { + Log.d(kTag, "uploadTask: 仅执行工单,不删除本地工单数据") + } + aMap.clear() + showMarkersOnMap() + "工单任务已完成".show(this) + }, + onFailed = { + LoadingDialog.dismiss() + it.show(this) + } + ) } else { "网络连接已断开,请检查".show(this) } } private fun executeTask(task: TaskDetailLocalModel) { - AlertControlDialog.Builder().setContext(this).setTitle("提示").setMessage("请选择操作方式") - .setPositiveButton("执行工单").setNegativeButton("提交工单") + AlertControlDialog.Builder() + .setContext(this) + .setTitle("提示") + .setMessage("请选择操作方式") + .setPositiveButton("执行工单") + .setNegativeButton("提交工单") .setOnDialogButtonClickListener(object : AlertControlDialog.OnDialogButtonClickListener { override fun onConfirmClick() { @@ -432,7 +409,7 @@ isExecuteTask = true } else { "此工单下无标识器,将执行自由巡检任务".show(context) - freeTaskId = task.taskId + freeTaskId = task.taskId.toLong() detectMarker() } } @@ -453,7 +430,18 @@ override fun onConfirmClick(value: String) { freeTaskTitle = value val userId = SaveKeyValues.getValue(LocaleConstant.USER_ID, "") as String - taskViewModel.createFreeTask(context, userId, value) + taskViewModel.createFreeTask( + userId, value, + onLoading = {}, + onSuccess = { + freeTaskId = it + // 自由巡检保存在本地 + taskBeanDao.saveTask(it, freeTaskTitle) + }, + onFailed = { + it.show(context) + } + ) detectMarker() } @@ -481,7 +469,7 @@ if (RuntimeCache.currentSegment == CurrentSegment.FreeInspection) { //显示标识器详细信息 if (!detailDialog.isShowing) { - DataBaseManager.get.queryMarkerById(markerId).firstOrNull().apply { + markerBeanDao.queryMarkerById(markerId).firstOrNull().apply { if (this == null) { "无法查询到此ID【${markerId}】的信息".show(context) } else { @@ -501,7 +489,7 @@ //不重复标注Marker if (!ids.contains(markerId)) { - val markers = DataBaseManager.get.queryMarkerById(markerId) + val markers = markerBeanDao.queryMarkerById(markerId) if (markers.isNotEmpty()) { val marker = markers.first() val latLng = LatLng(marker.lat.toDouble(), marker.lng.toDouble()) @@ -522,16 +510,6 @@ } - override fun observeRequestState() { - taskViewModel.loadState.observe(this) { - when (it) { - LoadState.Loading -> LoadingDialog.show(this, "提交工单中,请稍后") - - else -> LoadingDialog.dismiss() - } - } - } - private fun initMapConfig(savedInstanceState: Bundle?) { binding.mapView.onCreate(savedInstanceState) aMap = binding.mapView.map @@ -592,54 +570,25 @@ private fun saveUserTasks(task: TaskModel) { task.message.forEach { model -> //保存任务详情 - DataBaseManager.get.saveTaskInLocale(model) + taskBeanDao.saveTask(model) model.taskDetailInfos.forEach { marker -> //只保存有标识器ID得数据 if (!marker.markerIdReal.isNullOrBlank()) { - DataBaseManager.get.saveTaskMarkerInLocale(model.id, model.taskCode, marker) + taskMarkerBeanDao.saveTaskMarker(model.id, model.taskCode, marker) } } } "工单下载成功!".show(this) } - private fun showMarkersOnMap() { - lifecycleScope.launch(Dispatchers.IO) { - //取缓存 - val markers = DataBaseManager.get.loadMarkers() - if (markers.isEmpty()) { - return@launch - } - val first = markers.first() - val defaultLatLng = LatLng(first.lat.toDouble(), first.lng.toDouble()) - //移动到指定经纬度 - val cameraPosition = CameraPosition(defaultLatLng, 14f, 0f, 0f) - val cameraUpdate = CameraUpdateFactory.newCameraPosition(cameraPosition) - withContext(Dispatchers.Main) { - aMap.animateCamera(cameraUpdate, 1500, null) - LoadingDialog.dismiss() - } - - markers.forEach { marker -> - val latitude = marker.lat.toString().toDouble() - val longitude = marker.lng.toString().toDouble() - //将所有设备信息转化缓存为Marker点 - val options = MarkerOptions() - .position(LatLng(latitude, longitude)) - .title(marker.markerId) - aMap.addMarker(options) - } - } - } - override fun onMarkerClick(marker: Marker?): Boolean { - marker?.apply { - showNavigationOption(title, position) + marker?.let { + showNavigationOption(it.title, it.position) } return true } - override fun onMapLongClick(p0: LatLng?) { + override fun onMapLongClick(latLng: LatLng?) { showMarkersOnMap() } @@ -664,7 +613,7 @@ } override fun onCancelClick() { - val result = DataBaseManager.get.queryMarkerById(title) + val result = markerBeanDao.queryMarkerById(title) MarkerDetailDialog(context).setMarker(result.first()).show() } }).build().show() @@ -695,20 +644,24 @@ //更新标识器数据 private fun updateMarkers() { - AlertControlDialog.Builder().setContext(this).setTitle("提示").setMessage("是否更新数据?") - .setNegativeButton("取消").setPositiveButton("确定") + AlertControlDialog.Builder() + .setContext(this) + .setTitle("提示") + .setMessage("是否更新数据?") + .setNegativeButton("取消") + .setPositiveButton("确定") .setOnDialogButtonClickListener(object : AlertControlDialog.OnDialogButtonClickListener { override fun onConfirmClick() { if (isNetworkConnected()) { - val companyId = SaveKeyValues.getValue(LocaleConstant.USER_COMPANY_ID, "") - - LoadingDialog.show(this@MainActivity, "获取标识器信息中,请稍后") - /** - * 后台设计如此,都传companyId - * */ + //清空之前的数据 + markerBeanDao.deleteAll() + aMap.clear() + //获取标识器数据 taskViewModel.getMarkerFile( - context, companyId.toString(), companyId.toString() + onLoading = {}, + onSuccess = { handleMarkerFile(it) }, + onFailed = { it.show(context) } ) } else { "网络连接已断开,请检查".show(context) @@ -721,11 +674,105 @@ }).build().show() } + private fun handleMarkerFile(it: MarkerFileModel) { + if (it.isSuccess) { + //下载最新的数据 + val companyId = SaveKeyValues.getValue(LocaleConstant.USER_COMPANY_ID, "") + val downloadUrl = companyId.toString().appendDownloadUrl(FileType.Excel) + Log.d(kTag, "handleMarkerFile => $downloadUrl") + FileDownloadManager.Builder() + .setDownloadFileSource(downloadUrl) + .setFileSuffix("xls") + .setFileSaveDirectory(createDownloadFileDir()) + .setOnFileDownloadListener(object : FileDownloadManager.OnFileDownloadListener { + override fun onDownloadStart(total: Long) { + LoadingDialog.show(context, "标识器数据解析中,请稍后...") + } + + override fun onDownloadEnd(file: File) { + lifecycleScope.launch(Dispatchers.IO) { + ExcelKit.read(file.absolutePath).apply { + renderMarkers(this) + }.also { + withContext(Dispatchers.Main) { + LoadingDialog.dismiss() + "标识器数据渲染完成".show(context) + } + } + } + } + + override fun onDownloadFailed(t: Throwable) { + t.printStackTrace() + LoadingDialog.dismiss() + "标识器数据下载失败".show(context) + } + + override fun onProgressChanged(progress: Long) { + + } + }).build().start() + } + } + + private fun showMarkersOnMap() { + lifecycleScope.launch(Dispatchers.IO) { + //取缓存 + markerBeanDao.loadAll().run { + renderMarkers(this) + }.also { + withContext(Dispatchers.Main) { + "标识器数据渲染完成".show(context) + } + } + } + } + + private fun renderMarkers(markers: List) { + if (markers.isEmpty()) { + return + } + val first = markers.first() + val defaultLatLng = LatLng(first.lat.toDouble(), first.lng.toDouble()) + //移动到指定经纬度 + val cameraPosition = CameraPosition(defaultLatLng, 14f, 0f, 0f) + val cameraUpdate = CameraUpdateFactory.newCameraPosition(cameraPosition) + aMap.animateCamera(cameraUpdate, 1500, null) + markers.forEach { marker -> + val latitude = marker.lat.toString().toDouble() + val longitude = marker.lng.toString().toDouble() + //将所有设备信息转化缓存为Marker点 + val options = MarkerOptions() + .position(LatLng(latitude, longitude)) + .title(marker.markerId) + aMap.addMarker(options) + } + } + //下载工单 private fun downloadTask() { if (isNetworkConnected()) { - val userName = SaveKeyValues.getValue(LocaleConstant.USER_NAME, "") - taskViewModel.getTasksByUser(this, userName.toString()) + taskViewModel.getTasksByUser( + onLoading = {}, + onSuccess = { + if (it.success == "true") { + AlertMessageDialog.Builder() + .setContext(this) + .setTitle("温馨提示") + .setMessage("您有${it.message.size}个新任务!") + .setPositiveButton("知道了") + .setOnDialogButtonClickListener(object : + AlertMessageDialog.OnDialogButtonClickListener { + override fun onConfirmClick() { + saveUserTasks(it) + } + }).build().show() + } + }, + onFailed = { + it.show(this) + } + ) } else { "网络连接已断开,请检查".show(this) } @@ -744,7 +791,7 @@ //标识器补全 private fun completionMarker() { val companyId = SaveKeyValues.getValue(LocaleConstant.USER_COMPANY_ID, "") as String - val markers = DataBaseManager.get.queryMarkerByState("0") + val markers = taskMarkerBeanDao.queryMarkerByState("0") if (markers.isNotEmpty()) { //TODO 逻辑没梳理明白 } else { diff --git a/app/src/main/java/com/casic/common/detector/gd/view/SearchMarkerActivity.kt b/app/src/main/java/com/casic/common/detector/gd/view/SearchMarkerActivity.kt index 4a92c97..b2e3301 100644 --- a/app/src/main/java/com/casic/common/detector/gd/view/SearchMarkerActivity.kt +++ b/app/src/main/java/com/casic/common/detector/gd/view/SearchMarkerActivity.kt @@ -1,6 +1,5 @@ package com.casic.common.detector.gd.view -import android.content.Context import android.content.res.ColorStateList import android.graphics.Color import android.hardware.Sensor @@ -13,18 +12,19 @@ import android.os.Handler import android.os.Looper import android.view.View +import androidx.core.graphics.toColorInt import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.lifecycleScope import com.amap.api.location.AMapLocation import com.amap.api.maps.AMapUtils import com.amap.api.maps.model.LatLng import com.casic.common.detector.gd.R +import com.casic.common.detector.gd.base.BaseApplication import com.casic.common.detector.gd.base.SerialPortBaseActivity import com.casic.common.detector.gd.callback.OnGetLocationListener import com.casic.common.detector.gd.databinding.ActivitySearchMarkerBinding import com.casic.common.detector.gd.model.MarkerDistanceData import com.casic.common.detector.gd.utils.CurrentSegment -import com.casic.common.detector.gd.utils.DataBaseManager import com.casic.common.detector.gd.utils.LocaleConstant import com.casic.common.detector.gd.utils.LocationKit import com.casic.common.detector.gd.utils.RuntimeCache @@ -50,8 +50,10 @@ private val context = this private val locationKit by lazy { LocationKit(this) } private val markerPoints by lazy { ArrayList() } + private val markerBeanDao by lazy { BaseApplication.get().dataBase.markerBeanDao() } + private val taskMarkerBeanDao by lazy { BaseApplication.get().dataBase.taskMarkerBeanDao() } private val taskViewModel by lazy { ViewModelProvider(this)[TaskViewModel::class.java] } - private val sensorManager by lazy { getSystemService(Context.SENSOR_SERVICE) as SensorManager } + private val sensorManager by lazy { getSystemService(SENSOR_SERVICE) as SensorManager } private val attr = AudioAttributes.Builder().setUsage(AudioAttributes.USAGE_ALARM) .setContentType(AudioAttributes.CONTENT_TYPE_MUSIC).build() private val soundPool = SoundPool.Builder().setMaxStreams(16).setAudioAttributes(attr).build() @@ -109,7 +111,7 @@ override fun initEvent() { binding.depthButton.setOnClickListener { RuntimeCache.currentSegment = CurrentSegment.DetectDepth - val result = DataBaseManager.get.queryMarkerById(markerId) + val result = markerBeanDao.queryMarkerById(markerId) if (result.isNotEmpty()) { val command = when (result.first().markerType) { "EM30" -> SerialPortCommand.DETECT_EM30_DEPTH @@ -139,7 +141,7 @@ } binding.markerInfoButton.setOnClickListener { - val result = DataBaseManager.get.queryMarkerById(markerId) + val result = markerBeanDao.queryMarkerById(markerId) if (result.isNotEmpty()) { MarkerDetailDialog(this).setMarker(result.first()).show() } else { @@ -154,12 +156,12 @@ binding.depthButton.isEnabled = true binding.depthButton.setTextColor(Color.WHITE) binding.depthButton.backgroundTintList = - ColorStateList.valueOf(Color.parseColor("#004364")) + ColorStateList.valueOf("#004364".toColorInt()) binding.markerInfoButton.isEnabled = true binding.markerInfoButton.setTextColor(Color.WHITE) binding.markerInfoButton.backgroundTintList = - ColorStateList.valueOf(Color.parseColor("#FFA200")) + ColorStateList.valueOf("#FFA200".toColorInt()) handleMarker(markerId) } @@ -171,12 +173,22 @@ if (isExecuteTask) { val taskId = SaveKeyValues.getValue(LocaleConstant.TASK_ID, "") as String val taskCode = SaveKeyValues.getValue(LocaleConstant.TASK_CODE, "") as String - val taskMarkerLocalBean = DataBaseManager.get.queryTaskMarkerById( + val marker = taskMarkerBeanDao.queryTaskMarkerById( taskId, taskCode, id, "0" ) - taskMarkerLocalBean?.apply { - taskViewModel.uploadMarker(context, this) + if (marker == null) { + return } + taskViewModel.uploadMarker( + marker.markerId, + onLoading = {}, + onSuccess = { + "标识器${marker.markerId}已探测!".show(this) + marker.isDetected = "1" + taskMarkerBeanDao.updateLocalTaskMarkerState(marker) + }, + onFailed = {} + ) } } @@ -185,15 +197,22 @@ detectDepthRunnable?.let { handler.removeCallbacks(it) } detectDepthRunnable = null LoadingDialog.dismiss() - AlertMessageDialog.Builder().setContext(context).setTitle("温馨提示") - .setMessage("标识器埋深:${depth}厘米").setPositiveButton("知道了") - .setOnDialogButtonClickListener(object : - AlertMessageDialog.OnDialogButtonClickListener { - override fun onConfirmClick() { - RuntimeCache.currentSegment = CurrentSegment.SearchMarker - sendSerialPortCommand(SerialPortCommand.SEARCH_SIGNAL) - } - }).build().show() + if (!this.isDestroyed) { + AlertMessageDialog.Builder() + .setContext(context) + .setTitle("温馨提示") + .setMessage("标识器埋深:${depth}厘米") + .setPositiveButton("知道了") + .setOnDialogButtonClickListener(object : + AlertMessageDialog.OnDialogButtonClickListener { + override fun onConfirmClick() { + RuntimeCache.currentSegment = CurrentSegment.SearchMarker + sendSerialPortCommand(SerialPortCommand.SEARCH_SIGNAL) + } + }).build().show() + } else { + "标识器埋深:${depth}厘米".show(this) + } } } @@ -201,13 +220,13 @@ if (RuntimeCache.currentSegment == CurrentSegment.SearchMarker) { if (signalEnergy > 1000) { binding.markerIdButton.isEnabled = true - binding.markerIdButton.setTextColor(Color.parseColor("#428d00")) + binding.markerIdButton.setTextColor("#428d00".toColorInt()) binding.markerIdButton.backgroundTintList = ColorStateList.valueOf( - Color.parseColor("#7EFF00") + "#7EFF00".toColorInt() ) binding.searchResultView.text = "已检测到标识器" - binding.searchResultView.setTextColor(Color.parseColor("#428d00")) + binding.searchResultView.setTextColor("#428d00".toColorInt()) binding.searchResultView.setBackgroundResource(R.mipmap.bg_small_text_green) } @@ -230,19 +249,19 @@ signalEnergy <= 700 -> { setEnergyTip( "信号较弱,可能距离较远", - Color.parseColor("#8D1717"), + "#8D1717".toColorInt(), R.mipmap.bg_large_text_red ) disableButtons() binding.searchResultView.text = "未检测到标识器" - binding.searchResultView.setTextColor(Color.parseColor("#8D1717")) + binding.searchResultView.setTextColor("#8D1717".toColorInt()) binding.searchResultView.setBackgroundResource(R.mipmap.bg_small_text_red) } signalEnergy >= 4100 -> { setEnergyTip( "信号极强,接近标识器正上方", - Color.parseColor("#428d00"), + "#428d00".toColorInt(), R.mipmap.bg_large_text_green ) } @@ -250,7 +269,7 @@ else -> { setEnergyTip( "已靠近,请继续移动位置", - Color.parseColor("#8C5700"), + "#8C5700".toColorInt(), R.mipmap.bg_large_text_yellow ) } @@ -263,8 +282,8 @@ binding.energyTipsView.setBackgroundResource(backgroundRes) } - private val colorStateList = ColorStateList.valueOf(Color.parseColor("#8A8A8A")) - private val textColor = Color.parseColor("#CCCCCC") + private val colorStateList = ColorStateList.valueOf("#8A8A8A".toColorInt()) + private val textColor = "#CCCCCC".toColorInt() private fun disableButtons() { binding.depthButton.isEnabled = false @@ -287,7 +306,7 @@ val latitude = location.latitude lifecycleScope.launch(Dispatchers.IO) { val dataPoints = ArrayList() - DataBaseManager.get.loadMarkers().forEach { + markerBeanDao.loadAll().forEach { val distance = AMapUtils.calculateLineDistance( LatLng(it.lat.toDouble(), it.lng.toDouble()), LatLng(latitude, longitude) ) @@ -332,10 +351,6 @@ return ActivitySearchMarkerBinding.inflate(layoutInflater) } - override fun observeRequestState() { - - } - override fun setupTopBarLayout() { } diff --git a/app/src/main/java/com/casic/common/detector/gd/view/SearchMarkerAuditActivity.kt b/app/src/main/java/com/casic/common/detector/gd/view/SearchMarkerAuditActivity.kt index 1dc59a7..dd4cc84 100644 --- a/app/src/main/java/com/casic/common/detector/gd/view/SearchMarkerAuditActivity.kt +++ b/app/src/main/java/com/casic/common/detector/gd/view/SearchMarkerAuditActivity.kt @@ -1,6 +1,5 @@ package com.casic.common.detector.gd.view -import android.content.Context import android.hardware.Sensor import android.hardware.SensorEvent import android.hardware.SensorEventListener @@ -13,9 +12,9 @@ import com.amap.api.maps.AMapUtils import com.amap.api.maps.model.LatLng import com.casic.common.detector.gd.R +import com.casic.common.detector.gd.base.BaseApplication import com.casic.common.detector.gd.callback.OnGetLocationListener import com.casic.common.detector.gd.databinding.ActivitySearchMarkerAuditBinding -import com.casic.common.detector.gd.utils.DataBaseManager import com.casic.common.detector.gd.utils.LocaleConstant import com.casic.common.detector.gd.utils.LocationKit import com.casic.common.detector.gd.widgets.MarkerDetailDialog @@ -36,7 +35,8 @@ private val kTag = "SearchMarkerActivity" private val context = this private val locationKit by lazy { LocationKit(this) } - private val sensorManager by lazy { getSystemService(Context.SENSOR_SERVICE) as SensorManager } + private val sensorManager by lazy { getSystemService(SENSOR_SERVICE) as SensorManager } + private val markerBeanDao by lazy { BaseApplication.get().dataBase.markerBeanDao() } private val attr = AudioAttributes.Builder().setUsage(AudioAttributes.USAGE_ALARM) .setContentType(AudioAttributes.CONTENT_TYPE_MUSIC).build() private val soundPool = SoundPool.Builder().setMaxStreams(16).setAudioAttributes(attr).build() @@ -72,7 +72,7 @@ override fun initEvent() { binding.markerInfoButton.setOnClickListener { //查库 - val result = DataBaseManager.get.queryMarkerById(nearestMarkerId) + val result = markerBeanDao.queryMarkerById(nearestMarkerId) if (result.isNotEmpty()) { MarkerDetailDialog(this).setMarker(result.first()).show() } else { @@ -90,7 +90,7 @@ val latitude = location.latitude lifecycleScope.launch(Dispatchers.IO) { val dataPoints = ArrayList() - DataBaseManager.get.loadMarkers().forEach { + markerBeanDao.loadAll().forEach { val distance = AMapUtils.calculateLineDistance( LatLng(it.lat.toDouble(), it.lng.toDouble()), LatLng(latitude, longitude) ) @@ -105,7 +105,8 @@ ) } withContext(Dispatchers.Main) { - binding.radarScanView.renderPointData(dataPoints, + binding.radarScanView.renderPointData( + dataPoints, object : RadarScanView.OnGetNearestPointCallback { override fun getNearestPoint(point: RadarScanView.DataPoint?) { if (point == null) { diff --git a/app/src/main/java/com/casic/common/detector/gd/vm/TaskViewModel.kt b/app/src/main/java/com/casic/common/detector/gd/vm/TaskViewModel.kt index ee0d63a..665d95c 100644 --- a/app/src/main/java/com/casic/common/detector/gd/vm/TaskViewModel.kt +++ b/app/src/main/java/com/casic/common/detector/gd/vm/TaskViewModel.kt @@ -1,95 +1,87 @@ package com.casic.common.detector.gd.vm -import android.content.Context -import android.util.Log -import androidx.lifecycle.MutableLiveData -import com.casic.common.detector.gd.bean.TaskMarkerLocalBean import com.casic.common.detector.gd.extensions.getResponseMessage import com.casic.common.detector.gd.extensions.getResponseState import com.casic.common.detector.gd.model.MarkerFileModel import com.casic.common.detector.gd.model.TaskModel import com.casic.common.detector.gd.retrofit.RetrofitServiceManager -import com.casic.common.detector.gd.utils.DataBaseManager -import com.casic.common.detector.gd.utils.LocaleConstant -import com.google.gson.Gson import com.google.gson.JsonParser -import com.google.gson.reflect.TypeToken import com.pengxh.kt.lite.base.BaseViewModel import com.pengxh.kt.lite.extensions.launch -import com.pengxh.kt.lite.extensions.show -import com.pengxh.kt.lite.utils.LoadState -import com.pengxh.kt.lite.utils.SaveKeyValues +import com.pengxh.kt.lite.extensions.unpackingResponse class TaskViewModel : BaseViewModel() { - - private val kTag = "TaskViewModel" - private val gson by lazy { Gson() } - val markerFileResult = MutableLiveData() - val taskResult = MutableLiveData() - val freeTaskResult = MutableLiveData() - val uploadTaskMarkerResult = MutableLiveData() - val executeTaskResult = MutableLiveData() - - fun createFreeTask(context: Context, patrollerId: String, description: String) = launch({ + fun createFreeTask( + patrollerId: String, + description: String, + onLoading: () -> Unit, + onSuccess: (Long) -> Unit, + onFailed: (String) -> Unit + ) = launch({ + onLoading() val response = RetrofitServiceManager.createFreeTask(patrollerId, description) if (response.getResponseState()) { val element = JsonParser.parseString(response) val jsonObject = element.asJsonObject - freeTaskResult.value = jsonObject.get("taskId").asInt.toString() + onSuccess(jsonObject.get("taskId").asLong) } else { - response.getResponseMessage().show(context) + onFailed(response.getResponseMessage()) } }, { - it.printStackTrace() + onFailed(it.message ?: "Unknown error") }) - fun uploadTaskMarker(context: Context, taskId: String, ids: ArrayList) = launch({ + fun uploadTaskMarker( + taskId: Long, + ids: ArrayList, + onLoading: () -> Unit, + onSuccess: () -> Unit, + onFailed: (String) -> Unit + ) = launch({ + onLoading() val response = RetrofitServiceManager.uploadTaskMarker(taskId, ids) if (response.getResponseState()) { - val element = JsonParser.parseString(response) - val jsonObject = element.asJsonObject - uploadTaskMarkerResult.value = jsonObject.get("success").asString - - //删除本地数据库 - val taskCode = SaveKeyValues.getValue(LocaleConstant.TASK_CODE, "") as String - DataBaseManager.get.deleteLocalTaskById(taskId, taskCode) - SaveKeyValues.putValue(LocaleConstant.TASK_ID, "") + onSuccess() } else { - response.getResponseMessage().show(context) + onFailed(response.getResponseMessage()) } }, { - it.printStackTrace() + onFailed(it.message ?: "Unknown error") }) - fun getMarkerFile(context: Context, userId: String, companyId: String) = launch({ - val response = RetrofitServiceManager.getMarkerFile(userId, companyId) + fun getMarkerFile( + onLoading: () -> Unit, + onSuccess: (MarkerFileModel) -> Unit, + onFailed: (String) -> Unit + ) = launch({ + onLoading() + val response = RetrofitServiceManager.getMarkerFile() if (response.getResponseState()) { - markerFileResult.value = gson.fromJson( - response, object : TypeToken() {}.type - ) + onSuccess(unpackingResponse(response)) } else { - response.getResponseMessage().show(context) + onFailed(response.getResponseMessage()) } }, { - it.printStackTrace() + onFailed(it.message ?: "Unknown error") }) - fun getTasksByUser(context: Context, userName: String) = launch({ - val response = RetrofitServiceManager.getTasksByUser(userName) + fun getTasksByUser( + onLoading: () -> Unit, + onSuccess: (TaskModel) -> Unit, + onFailed: (String) -> Unit + ) = launch({ + onLoading() + val response = RetrofitServiceManager.getTasksByUser() if (response.getResponseState()) { - taskResult.value = gson.fromJson( - response, object : TypeToken() {}.type - ) + onSuccess(unpackingResponse(response)) } else { - response.getResponseMessage().show(context) + onFailed(response.getResponseMessage()) } }, { - it.printStackTrace() + onFailed(it.message ?: "Unknown error") }) - fun installLabel( - context: Context, - companyId: String, + fun installMarker( recordType: String, markerObjectType: String, pipeMaterial: String, @@ -105,7 +97,6 @@ road: String, constructTime: String, ownerComp: String, - markerObjectId: String, markerId: String, markerType: String, markerDepth: String, @@ -115,11 +106,13 @@ latitude: String, colorType: String, memo: String, - realPaths: ArrayList + realPaths: ArrayList, + onLoading: () -> Unit, + onSuccess: () -> Unit, + onFailed: (String) -> Unit ) = launch({ - loadState.value = LoadState.Loading - val response = RetrofitServiceManager.installLabel( - companyId, + onLoading() + val response = RetrofitServiceManager.installMarker( recordType, markerObjectType, pipeMaterial, @@ -135,7 +128,6 @@ road, constructTime, ownerComp, - markerObjectId, markerId, markerType, markerDepth, @@ -148,67 +140,65 @@ realPaths ) if (response.getResponseState()) { - loadState.value = LoadState.Success + onSuccess() } else { - loadState.value = LoadState.Fail - response.getResponseMessage().show(context) + onFailed(response.getResponseMessage()) } }, { - it.printStackTrace() - loadState.value = LoadState.Fail + onFailed(it.message ?: "Unknown error") }) fun uploadTask( - context: Context, userId: String, taskId: String, taskCode: String, state: String + taskId: String, + state: String, + onLoading: () -> Unit, + onSuccess: () -> Unit, + onFailed: (String) -> Unit ) = launch({ - loadState.value = LoadState.Loading - val response = RetrofitServiceManager.uploadTask(userId, taskId, state) + onLoading() + val response = RetrofitServiceManager.uploadTask(taskId, state) if (response.getResponseState()) { - loadState.value = LoadState.Success - //工单提交之后,并且状态是2,删除本地Task记录 - if (state == "2") { - "工单${taskId}已提交!".show(context) - //删除本地数据库 - DataBaseManager.get.deleteLocalTaskById(taskId, taskCode) - SaveKeyValues.putValue(LocaleConstant.TASK_ID, "") - - val element = JsonParser.parseString(response) - val jsonObject = element.asJsonObject - executeTaskResult.value = jsonObject.get("success").asString - } else { - Log.d(kTag, "uploadTask: 仅执行工单,不删除本地工单数据") - } + onSuccess() } else { - loadState.value = LoadState.Fail - response.getResponseMessage().show(context) + onFailed(response.getResponseMessage()) } }, { - it.printStackTrace() - loadState.value = LoadState.Fail + onFailed(it.message ?: "Unknown error") }) fun uploadEvent( - context: Context, taskId: String, event: String, realPaths: ArrayList + taskId: String, + event: String, + realPaths: ArrayList, + onLoading: () -> Unit, + onSuccess: () -> Unit, + onFailed: (String) -> Unit ) = launch({ - loadState.value = LoadState.Loading + onLoading() val response = RetrofitServiceManager.uploadEvent(taskId, event, realPaths) if (response.getResponseState()) { - loadState.value = LoadState.Success + onSuccess() } else { - loadState.value = LoadState.Fail - response.getResponseMessage().show(context) + onFailed(response.getResponseMessage()) } }, { - it.printStackTrace() - loadState.value = LoadState.Fail + onFailed(it.message ?: "Unknown error") }) - fun uploadMarker(context: Context, marker: TaskMarkerLocalBean) = launch({ - //主键ID代替MarkerId - RetrofitServiceManager.uploadMarker(marker.id.toString()) - "标识器${marker.markerId}已探测!".show(context) - DataBaseManager.get.updateLocalTaskMarkerState(marker) + fun uploadMarker( + markerId: String, + onLoading: () -> Unit, + onSuccess: () -> Unit, + onFailed: (String) -> Unit + ) = launch({ + onLoading() + val response = RetrofitServiceManager.uploadMarker(markerId) + if (response.getResponseState()) { + onSuccess() + } else { + onFailed(response.getResponseMessage()) + } }, { - it.printStackTrace() + onFailed(it.message ?: "Unknown error") }) } \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/widgets/MarkerDetailDialog.kt b/app/src/main/java/com/casic/common/detector/gd/widgets/MarkerDetailDialog.kt index 44723f2..3890584 100644 --- a/app/src/main/java/com/casic/common/detector/gd/widgets/MarkerDetailDialog.kt +++ b/app/src/main/java/com/casic/common/detector/gd/widgets/MarkerDetailDialog.kt @@ -3,8 +3,7 @@ import android.app.Dialog import android.content.Context import android.os.Bundle -import com.casic.common.detector.gd.R -import com.casic.common.detector.gd.bean.MarkerLocalBean +import com.casic.common.detector.gd.bean.MarkerBean import com.casic.common.detector.gd.databinding.DialogMarkerDetailBinding import com.casic.common.detector.gd.extensions.appendDownloadUrl import com.casic.common.detector.gd.extensions.initDialogLayoutParams @@ -15,12 +14,11 @@ import com.pengxh.kt.lite.extensions.navigatePageTo import com.pengxh.kt.lite.extensions.show -class MarkerDetailDialog(context: Context) : - Dialog(context, R.style.UserDefinedDialogStyle) { +class MarkerDetailDialog(context: Context) : Dialog(context) { - private lateinit var marker: MarkerLocalBean + private lateinit var marker: MarkerBean - fun setMarker(marker: MarkerLocalBean): MarkerDetailDialog { + fun setMarker(marker: MarkerBean): MarkerDetailDialog { this.marker = marker return this } @@ -52,7 +50,7 @@ binding.showImageView.setOnClickListener { //查数据库 - if (marker.imagePath.isNullOrEmpty()) { + if (marker.imagePath.isEmpty()) { "此标识器无图片".show(context) } else { val realPaths = ArrayList() //真实图片路径 diff --git a/app/src/main/java/com/casic/common/detector/gd/widgets/QueryMarkerDialog.kt b/app/src/main/java/com/casic/common/detector/gd/widgets/QueryMarkerDialog.kt index 304fdbb..64a1b93 100644 --- a/app/src/main/java/com/casic/common/detector/gd/widgets/QueryMarkerDialog.kt +++ b/app/src/main/java/com/casic/common/detector/gd/widgets/QueryMarkerDialog.kt @@ -6,20 +6,19 @@ import android.view.View import android.widget.AdapterView import android.widget.ArrayAdapter -import com.casic.common.detector.gd.R +import com.casic.common.detector.gd.base.BaseApplication import com.casic.common.detector.gd.databinding.DialogQueryMarkerBinding -import com.casic.common.detector.gd.utils.DataBaseManager +import com.casic.common.detector.gd.utils.LocaleConstant import com.pengxh.kt.lite.extensions.binding import com.pengxh.kt.lite.extensions.initDialogLayoutParams import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.Job import kotlinx.coroutines.launch import kotlinx.coroutines.withContext -class QueryMarkerDialog private constructor(builder: Builder) : Dialog( - builder.context, R.style.UserDefinedDialogStyle -) { +class QueryMarkerDialog private constructor(builder: Builder) : Dialog(builder.context) { private val ctx = builder.context private val title = builder.title private val spinnerArray = builder.spinnerArray @@ -71,6 +70,7 @@ } private val binding: DialogQueryMarkerBinding by binding() + private val serviceScope = CoroutineScope(Dispatchers.Main + Job()) override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -97,12 +97,11 @@ ) { //查库 val autoCompleteData = HashSet() - CoroutineScope(Dispatchers.Main).launch { + val markerBeanDao = BaseApplication.get().dataBase.markerBeanDao() + val buildQuery = LocaleConstant.buildQuery(spinnerArray[position], "") + serviceScope.launch { val labelBeans = withContext(Dispatchers.IO) { - DataBaseManager.get.loadMarkersByCondition( - spinnerArray[position], - null - ) + markerBeanDao.loadMarkersByCondition(buildQuery) } for (labelBean in labelBeans) { when (position) { diff --git a/build.gradle b/build.gradle index 987ad74..8af745d 100644 --- a/build.gradle +++ b/build.gradle @@ -1,31 +1,5 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. -buildscript { - ext.kotlin_version = '1.6.10' - repositories { - maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' } - mavenCentral() - google() - } - dependencies { - classpath 'com.android.tools.build:gradle:4.2.2' - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath 'org.greenrobot:greendao-gradle-plugin:3.3.0' - - // NOTE: Do not place your application dependencies here; they belong - // in the individual module build.gradle files - } -} - -allprojects { - repositories { - maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' } - //依赖库 - maven { url 'https://jitpack.io' } - mavenCentral() - google() - } -} - -tasks.register('clean', Delete) { - delete rootProject.buildDir +plugins { + id("com.android.application") version "8.1.0" apply false + id("org.jetbrains.kotlin.android") version "2.0.21" apply false } \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index d0cb423..921c8c8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,25 +1,20 @@ import java.text.SimpleDateFormat -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply plugin: 'org.greenrobot.greendao' +plugins { + id('com.android.application') + id('org.jetbrains.kotlin.android') +} android { - compileSdkVersion 33 + namespace 'com.casic.common.detector.gd' + compileSdk 35 defaultConfig { - applicationId "com.casic.common.detector.gd" - minSdkVersion 26 - targetSdkVersion 33 + applicationId 'com.casic.common.detector.gd' + minSdk 26 + targetSdk 35 versionCode 5092 - versionName "5.0.9.2" - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } + versionName '5.0.9.2' } signingConfigs { @@ -31,6 +26,14 @@ } } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + signingConfig signingConfigs.release + } + } + compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 @@ -47,27 +50,16 @@ } } - kotlin { - experimental { - coroutines 'enable' - } - } - buildFeatures { + buildConfig true viewBinding true } - applicationVariants.configureEach { variant -> - variant.outputs.configureEach { - outputFileName = "COM_TCY_" + getBuildDate() + "_" + defaultConfig.versionName + ".apk" + applicationVariants.configureEach { + outputs.configureEach { + outputFileName = 'COM_TCY_' + getBuildDate() + '_' + defaultConfig.versionName + '.apk' } } - - greendao { - schemaVersion 1//数据库版本号 - targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 - daoPackage "${defaultConfig.applicationId}.greendao"//设置DaoMaster、DaoSession、Dao包名 - } } static def getBuildDate() { @@ -76,27 +68,22 @@ } dependencies { - //基础依赖库 - implementation 'com.github.AndroidCoderPeng:Kotlin-lite-lib:1.1.4' - implementation 'androidx.core:core-ktx:1.9.0' - def base_version = "1.6.1" - implementation "androidx.appcompat:appcompat:${base_version}" - implementation "com.google.android.material:material:${base_version}" + implementation 'com.github.AndroidCoderPeng:Kotlin-lite-lib:1.1.5' + implementation 'androidx.core:core-ktx:1.13.1' + implementation 'androidx.appcompat:appcompat:1.7.0' + implementation 'com.google.android.material:material:1.12.0' //Google官方授权框架 implementation 'pub.devrel:easypermissions:3.0.0' - //沉浸式状态栏。基础依赖包,必须要依赖 - implementation 'com.gyf.immersionbar:immersionbar:3.0.0' - //fragment快速实现 - implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0' + //沉浸式状态栏 + implementation 'com.geyifeng.immersionbar:immersionbar:3.2.2' //官方Json解析库 implementation 'com.google.code.gson:gson:2.10.1' - def vm_version = '2.5.1' //Kotlin协程 - implementation "androidx.lifecycle:lifecycle-runtime-ktx:${vm_version}" + implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.2' //MVVM+LiveData - implementation "androidx.lifecycle:lifecycle-livedata-ktx:${vm_version}" - implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:${vm_version}" - implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.6.2' + implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2' + implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' //返回值转换器 implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' @@ -105,9 +92,10 @@ implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' //网络请求和接口封装 implementation 'com.squareup.retrofit2:retrofit:2.9.0' - implementation 'com.squareup.okhttp3:okhttp:4.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.12.0' //数据库框架 - implementation 'org.greenrobot:greendao:3.3.0' + implementation 'androidx.room:room-runtime:2.6.1' + annotationProcessor 'androidx.room:room-compiler:2.5.2' //高德导航、定位、地图三合一 implementation 'com.amap.api:navi-3dmap:latest.integration' //经纬度逆编码 @@ -115,7 +103,7 @@ //excel implementation 'net.sourceforge.jexcelapi:jxl:2.6.12' //图片加载框架 - implementation 'com.github.bumptech.glide:glide:4.9.0' + implementation 'com.github.bumptech.glide:glide:4.12.0' //图片选择框架 implementation 'io.github.lucksiege:pictureselector:v3.11.1' //大图 diff --git a/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt b/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt index 7b695ff..50ba734 100644 --- a/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt +++ b/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt @@ -4,9 +4,9 @@ import android.app.Application import android.os.Bundle import android.util.Log -import com.casic.common.detector.gd.greendao.DaoMaster -import com.casic.common.detector.gd.greendao.DaoSession +import androidx.room.Room.databaseBuilder import com.casic.common.detector.gd.uart.SerialPort +import com.casic.common.detector.gd.utils.DetectorDataBase import com.casic.common.detector.gd.utils.GpioManager import com.pengxh.kt.lite.extensions.show import com.pengxh.kt.lite.utils.SaveKeyValues @@ -43,44 +43,42 @@ private var application: BaseApplication by Delegates.notNull() fun get() = application - - private lateinit var daoSession: DaoSession } + lateinit var dataBase: DetectorDataBase + override fun onCreate() { super.onCreate() application = this SaveKeyValues.initSharedPreferences(this) CrashReport.initCrashReport(this, "01e80d3a74", true) - val devOpenHelper = DaoMaster.DevOpenHelper(this, "Detector.db", null) - val daoMaster = DaoMaster(devOpenHelper.writableDatabase) - daoSession = daoMaster.newSession() + dataBase = databaseBuilder(this, DetectorDataBase::class.java, "Detector.db") + .allowMainThreadQueries() + .build() /** * Open the serial port * */ try { serialPorts.apply { - add(SerialPort(File("/dev/ttysWK1"), 9600, 0)) - //千寻报文数据下发串口号 - add(SerialPort(File("/dev/ttyS1"), 9600, 0)) + add(SerialPort(File("/dev/ttysWK1"), 9600, 0)) //信号通讯串口 + add(SerialPort(File("/dev/ttyS1"), 9600, 0)) //千寻报文数据下发串口号 } Log.d(kTag, "onCreate: 已初始化 ${serialPorts.size} 个串口") } catch (e: SecurityException) { "您没有串口的读写权限!".show(this) + e.printStackTrace() } catch (e: IOException) { "因为不明原因,串口无法打开!".show(this) + e.printStackTrace() } catch (e: InvalidParameterException) { "请检查串口!".show(this) + e.printStackTrace() } registerActivityLifecycleCallbacks(this) } - fun getDaoSession(): DaoSession { - return daoSession - } - override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) { } diff --git a/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt b/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt index 053b9dd..1d0c9e3 100644 --- a/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt +++ b/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt @@ -14,12 +14,10 @@ import com.casic.common.detector.gd.utils.SerialPortCommand import com.pengxh.kt.lite.utils.WeakReferenceHandler import java.io.IOException -import java.util.Timer abstract class SerialPortBaseActivity : AppCompatActivity(), Handler.Callback { private val kTag = "SerialPortBaseActivity" - private val taskTimer by lazy { Timer() } private val weakReferenceHandler by lazy { WeakReferenceHandler(this) } private val serialPorts by lazy { BaseApplication.get().getSerialPorts() } protected lateinit var binding: VB @@ -30,7 +28,6 @@ setContentView(binding.root) setupTopBarLayout() initOnCreate(savedInstanceState) - observeRequestState() initEvent() if (serialPorts.isNotEmpty()) { @@ -71,11 +68,6 @@ abstract fun initOnCreate(savedInstanceState: Bundle?) /** - * 数据请求状态监听 - */ - abstract fun observeRequestState() - - /** * 初始化业务逻辑 */ abstract fun initEvent() diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java new file mode 100644 index 0000000..7a18c20 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java @@ -0,0 +1,255 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 从平台下载的标识器本地库实体类 + */ +@Entity(tableName = "marker_detail") +public class MarkerBean { + @PrimaryKey(autoGenerate = true) + private long id; //主键ID + private String pipelineType; // 管线类型 + private String pipelineDiameter; // 管线直径 + private String pipelineMaterial; // 管材 + private String buryMethod; // 埋设方式 + private String buryDepth; // 埋深 + private String area; // 所属区域 + private String line; // 所属线路 + private String road; // 所属道路 + private String constructTime; // 建设年代 + private String owner; // 权属单位 + private String objectId; // 标识对象ID,无实际用途 + private String markerId; // 标识器ID + private String markerType; // 标识器类型 + private String markerDepth; // 标识器埋深 + private String installationDept; // 安装部门 + private String lng; // 经度 + private String lat; // 纬度 + private String updateTime; // 最后修改时间,更新时间 + private String remark; // 备注信息 + private String underlyingPipelineType; // 下层管线类型 + private String underlyingPipelineDepth; // 下层埋深 + private String underlyingPipelineDiameter; // 下层管径 + private String underlyingPipelineMaterial; // 下层管材 + private String objectType; //标识对象类型 + private String color; // 颜色 + private String imagePath; // 图片路径 + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getPipelineType() { + return pipelineType; + } + + public void setPipelineType(String pipelineType) { + this.pipelineType = pipelineType; + } + + public String getPipelineDiameter() { + return pipelineDiameter; + } + + public void setPipelineDiameter(String pipelineDiameter) { + this.pipelineDiameter = pipelineDiameter; + } + + public String getPipelineMaterial() { + return pipelineMaterial; + } + + public void setPipelineMaterial(String pipelineMaterial) { + this.pipelineMaterial = pipelineMaterial; + } + + public String getBuryMethod() { + return buryMethod; + } + + public void setBuryMethod(String buryMethod) { + this.buryMethod = buryMethod; + } + + public String getBuryDepth() { + return buryDepth; + } + + public void setBuryDepth(String buryDepth) { + this.buryDepth = buryDepth; + } + + public String getArea() { + return area; + } + + public void setArea(String area) { + this.area = area; + } + + public String getLine() { + return line; + } + + public void setLine(String line) { + this.line = line; + } + + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + + public String getConstructTime() { + return constructTime; + } + + public void setConstructTime(String constructTime) { + this.constructTime = constructTime; + } + + public String getOwner() { + return owner; + } + + public void setOwner(String owner) { + this.owner = owner; + } + + public String getObjectId() { + return objectId; + } + + public void setObjectId(String objectId) { + this.objectId = objectId; + } + + public String getMarkerId() { + return markerId; + } + + public void setMarkerId(String markerId) { + this.markerId = markerId; + } + + public String getMarkerType() { + return markerType; + } + + public void setMarkerType(String markerType) { + this.markerType = markerType; + } + + public String getMarkerDepth() { + return markerDepth; + } + + public void setMarkerDepth(String markerDepth) { + this.markerDepth = markerDepth; + } + + public String getInstallationDept() { + return installationDept; + } + + public void setInstallationDept(String installationDept) { + this.installationDept = installationDept; + } + + public String getLng() { + return lng; + } + + public void setLng(String lng) { + this.lng = lng; + } + + public String getLat() { + return lat; + } + + public void setLat(String lat) { + this.lat = lat; + } + + public String getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } + + public String getUnderlyingPipelineType() { + return underlyingPipelineType; + } + + public void setUnderlyingPipelineType(String underlyingPipelineType) { + this.underlyingPipelineType = underlyingPipelineType; + } + + public String getUnderlyingPipelineDepth() { + return underlyingPipelineDepth; + } + + public void setUnderlyingPipelineDepth(String underlyingPipelineDepth) { + this.underlyingPipelineDepth = underlyingPipelineDepth; + } + + public String getUnderlyingPipelineDiameter() { + return underlyingPipelineDiameter; + } + + public void setUnderlyingPipelineDiameter(String underlyingPipelineDiameter) { + this.underlyingPipelineDiameter = underlyingPipelineDiameter; + } + + public String getUnderlyingPipelineMaterial() { + return underlyingPipelineMaterial; + } + + public void setUnderlyingPipelineMaterial(String underlyingPipelineMaterial) { + this.underlyingPipelineMaterial = underlyingPipelineMaterial; + } + + public String getObjectType() { + return objectType; + } + + public void setObjectType(String objectType) { + this.objectType = objectType; + } + + public String getColor() { + return color; + } + + public void setColor(String color) { + this.color = color; + } + + public String getImagePath() { + return imagePath; + } + + public void setImagePath(String imagePath) { + this.imagePath = imagePath; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java deleted file mode 100644 index 3f2fcdc..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java +++ /dev/null @@ -1,327 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 从平台下载的标识器本地库实体类 - */ -@Entity -public class MarkerLocalBean { - @Id(autoincrement = true) - private Long id;//本地库主键ID - - // 管线类型 - private String pipelineType; - // 管线直径 - private String pipelineDiameter; - // 管材 - private String pipelineMaterial; - // 埋设方式 - private String buryMethod; - // 埋深 - private String buryDepth; - // 所属区域 - private String area; - // 所属线路 - private String line; - // 所属道路 - private String road; - // 建设年代 - private String constructTime; - // 权属单位 - private String owner; - //标识对象ID,无实际用途 - @Deprecated - private String objectId; - // 标识器ID - private String markerId; - // 标识器类型 - private String markerType; - // 标识器埋深 - private String markerDepth; - // 安装部门 - private String installationDept; - // 经度 - private String lng; - // 纬度 - private String lat; - //最后修改时间,更新时间 - private String updateTime; - // 备注信息 - private String remark; - // 下层管线类型 - private String underlyingPipelineType; - // 下层埋深 - private String underlyingPipelineDepth; - // 下层管径 - private String underlyingPipelineDiameter; - // 下层管材 - private String underlyingPipelineMaterial; - //标识对象类型 - private String objectType; - // 颜色 - private String color; - // 图片路径 - private String imagePath; - - @Generated(hash = 1479045776) - public MarkerLocalBean(Long id, String pipelineType, String pipelineDiameter, - String pipelineMaterial, String buryMethod, String buryDepth, - String area, String line, String road, String constructTime, - String owner, String objectId, String markerId, String markerType, - String markerDepth, String installationDept, String lng, String lat, - String updateTime, String remark, String underlyingPipelineType, - String underlyingPipelineDepth, String underlyingPipelineDiameter, - String underlyingPipelineMaterial, String objectType, String color, - String imagePath) { - this.id = id; - this.pipelineType = pipelineType; - this.pipelineDiameter = pipelineDiameter; - this.pipelineMaterial = pipelineMaterial; - this.buryMethod = buryMethod; - this.buryDepth = buryDepth; - this.area = area; - this.line = line; - this.road = road; - this.constructTime = constructTime; - this.owner = owner; - this.objectId = objectId; - this.markerId = markerId; - this.markerType = markerType; - this.markerDepth = markerDepth; - this.installationDept = installationDept; - this.lng = lng; - this.lat = lat; - this.updateTime = updateTime; - this.remark = remark; - this.underlyingPipelineType = underlyingPipelineType; - this.underlyingPipelineDepth = underlyingPipelineDepth; - this.underlyingPipelineDiameter = underlyingPipelineDiameter; - this.underlyingPipelineMaterial = underlyingPipelineMaterial; - this.objectType = objectType; - this.color = color; - this.imagePath = imagePath; - } - - @Generated(hash = 1538606012) - public MarkerLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getPipelineType() { - return this.pipelineType; - } - - public void setPipelineType(String pipelineType) { - this.pipelineType = pipelineType; - } - - public String getPipelineDiameter() { - return this.pipelineDiameter; - } - - public void setPipelineDiameter(String pipelineDiameter) { - this.pipelineDiameter = pipelineDiameter; - } - - public String getPipelineMaterial() { - return this.pipelineMaterial; - } - - public void setPipelineMaterial(String pipelineMaterial) { - this.pipelineMaterial = pipelineMaterial; - } - - public String getBuryMethod() { - return this.buryMethod; - } - - public void setBuryMethod(String buryMethod) { - this.buryMethod = buryMethod; - } - - public String getBuryDepth() { - return this.buryDepth; - } - - public void setBuryDepth(String buryDepth) { - this.buryDepth = buryDepth; - } - - public String getArea() { - return this.area; - } - - public void setArea(String area) { - this.area = area; - } - - public String getLine() { - return this.line; - } - - public void setLine(String line) { - this.line = line; - } - - public String getRoad() { - return this.road; - } - - public void setRoad(String road) { - this.road = road; - } - - public String getConstructTime() { - return this.constructTime; - } - - public void setConstructTime(String constructTime) { - this.constructTime = constructTime; - } - - public String getOwner() { - return this.owner; - } - - public void setOwner(String owner) { - this.owner = owner; - } - - public String getObjectId() { - return this.objectId; - } - - public void setObjectId(String objectId) { - this.objectId = objectId; - } - - public String getMarkerId() { - return this.markerId; - } - - public void setMarkerId(String markerId) { - this.markerId = markerId; - } - - public String getMarkerType() { - return this.markerType; - } - - public void setMarkerType(String markerType) { - this.markerType = markerType; - } - - public String getMarkerDepth() { - return this.markerDepth; - } - - public void setMarkerDepth(String markerDepth) { - this.markerDepth = markerDepth; - } - - public String getInstallationDept() { - return this.installationDept; - } - - public void setInstallationDept(String installationDept) { - this.installationDept = installationDept; - } - - public String getLng() { - return this.lng; - } - - public void setLng(String lng) { - this.lng = lng; - } - - public String getLat() { - return this.lat; - } - - public void setLat(String lat) { - this.lat = lat; - } - - public String getUpdateTime() { - return this.updateTime; - } - - public void setUpdateTime(String updateTime) { - this.updateTime = updateTime; - } - - public String getRemark() { - return this.remark; - } - - public void setRemark(String remark) { - this.remark = remark; - } - - public String getUnderlyingPipelineType() { - return this.underlyingPipelineType; - } - - public void setUnderlyingPipelineType(String underlyingPipelineType) { - this.underlyingPipelineType = underlyingPipelineType; - } - - public String getUnderlyingPipelineDepth() { - return this.underlyingPipelineDepth; - } - - public void setUnderlyingPipelineDepth(String underlyingPipelineDepth) { - this.underlyingPipelineDepth = underlyingPipelineDepth; - } - - public String getUnderlyingPipelineDiameter() { - return this.underlyingPipelineDiameter; - } - - public void setUnderlyingPipelineDiameter(String underlyingPipelineDiameter) { - this.underlyingPipelineDiameter = underlyingPipelineDiameter; - } - - public String getUnderlyingPipelineMaterial() { - return this.underlyingPipelineMaterial; - } - - public void setUnderlyingPipelineMaterial(String underlyingPipelineMaterial) { - this.underlyingPipelineMaterial = underlyingPipelineMaterial; - } - - public String getObjectType() { - return this.objectType; - } - - public void setObjectType(String objectType) { - this.objectType = objectType; - } - - public String getColor() { - return this.color; - } - - public void setColor(String color) { - this.color = color; - } - - public String getImagePath() { - return this.imagePath; - } - - public void setImagePath(String imagePath) { - this.imagePath = imagePath; - } -} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java new file mode 100644 index 0000000..5c88fdf --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java @@ -0,0 +1,93 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 巡检任务本地库实体类,不包含任务里面需要巡检的标识器信息 + */ +@Entity(tableName = "task_detail") +public class TaskBean { + @PrimaryKey(autoGenerate = true) + private long id;//主键ID + private String taskCode; // 任务编号 + private String description; // 任务名称 + private String createTime; // 任务创建的时间 + private String status; // 任务状态 + private String createUserName; // 任务创建者名称 + private String startTime; // 任务被开始执行的时间 + private String endTime; // 任务执行结束的时间 + private String isFree; // 是否自由巡检。1-是,0-否 + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getTaskCode() { + return taskCode; + } + + public void setTaskCode(String taskCode) { + this.taskCode = taskCode; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getCreateUserName() { + return createUserName; + } + + public void setCreateUserName(String createUserName) { + this.createUserName = createUserName; + } + + public String getStartTime() { + return startTime; + } + + public void setStartTime(String startTime) { + this.startTime = startTime; + } + + public String getEndTime() { + return endTime; + } + + public void setEndTime(String endTime) { + this.endTime = endTime; + } + + public String getIsFree() { + return isFree; + } + + public void setIsFree(String isFree) { + this.isFree = isFree; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java deleted file mode 100644 index 91737b3..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java +++ /dev/null @@ -1,114 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 巡检任务本地库实体类,不包含任务里面需要巡检的标识器信息 - */ -@Entity -public class TaskLocalBean { - @Id - private Long id;//任务ID - - private String taskCode;//任务编号 - private String description;//任务名称 - private String createTime;//任务创建的时间 - private String status;//任务状态 - private String createUserName;//任务创建者名称 - private String startTime;//任务被开始执行的时间 - private String endTime;//任务执行结束的时间 - private String isFreeTask;//是否自由巡检。1-是,0-否 - - @Generated(hash = 1482022528) - public TaskLocalBean(Long id, String taskCode, String description, - String createTime, String status, String createUserName, - String startTime, String endTime, String isFreeTask) { - this.id = id; - this.taskCode = taskCode; - this.description = description; - this.createTime = createTime; - this.status = status; - this.createUserName = createUserName; - this.startTime = startTime; - this.endTime = endTime; - this.isFreeTask = isFreeTask; - } - - @Generated(hash = 949704588) - public TaskLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getTaskCode() { - return this.taskCode; - } - - public void setTaskCode(String taskCode) { - this.taskCode = taskCode; - } - - public String getDescription() { - return this.description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getCreateTime() { - return this.createTime; - } - - public void setCreateTime(String createTime) { - this.createTime = createTime; - } - - public String getStatus() { - return this.status; - } - - public void setStatus(String status) { - this.status = status; - } - - public String getCreateUserName() { - return this.createUserName; - } - - public void setCreateUserName(String createUserName) { - this.createUserName = createUserName; - } - - public String getStartTime() { - return this.startTime; - } - - public void setStartTime(String startTime) { - this.startTime = startTime; - } - - public String getEndTime() { - return this.endTime; - } - - public void setEndTime(String endTime) { - this.endTime = endTime; - } - - public String getIsFreeTask() { - return this.isFreeTask; - } - - public void setIsFreeTask(String isFreeTask) { - this.isFreeTask = isFreeTask; - } -} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerBean.java new file mode 100644 index 0000000..c563a60 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerBean.java @@ -0,0 +1,110 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 巡检任务里面需要巡检的标识器信息本地库实体类 + */ +@Entity(tableName = "task_marker_info") +public class TaskMarkerBean { + //标识器后台库的主键ID,不是标识器实际ID + @PrimaryKey(autoGenerate = true) + private long id; + + /** + * 任务ID,通过此字段关联[TaskBean.id] + */ + private String taskId; + + /** + * 任务Code,通过此字段关联[TaskBean.taskCode] + *

+ *

+ * 双重验证,防止出现同时刻重复的情况 + */ + private String taskCode; + + /** + * 对应后台字段[TaskModel.MessageModel.TaskDetailInfosModel.markerIdReal],也就是探测仪扫描出来的ID + */ + private String markerId; + + private Double lng; + private Double lat; + + /** + * 是否已被探测到 + * 1-是,0-否 + */ + private String isDetected; + + /** + * 被探测到的时间,对应后台字段[TaskModel.MessageModel.TaskDetailInfosModel.finishTime] + */ + private String detectedTime; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getTaskId() { + return taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getTaskCode() { + return taskCode; + } + + public void setTaskCode(String taskCode) { + this.taskCode = taskCode; + } + + public String getMarkerId() { + return markerId; + } + + public void setMarkerId(String markerId) { + this.markerId = markerId; + } + + public Double getLng() { + return lng; + } + + public void setLng(Double lng) { + this.lng = lng; + } + + public Double getLat() { + return lat; + } + + public void setLat(Double lat) { + this.lat = lat; + } + + public String getIsDetected() { + return isDetected; + } + + public void setIsDetected(String isDetected) { + this.isDetected = isDetected; + } + + public String getDetectedTime() { + return detectedTime; + } + + public void setDetectedTime(String detectedTime) { + this.detectedTime = detectedTime; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerLocalBean.java deleted file mode 100644 index de9f459..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerLocalBean.java +++ /dev/null @@ -1,128 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import com.casic.common.detector.gd.model.TaskModel; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 巡检任务里面需要巡检的标识器信息本地库实体类 - */ -@Entity -public class TaskMarkerLocalBean { - @Id - private Long id;//标识器后台库的主键ID,不是标识器实际ID - - /** - * 任务ID,通过此字段关联{@link TaskLocalBean#id} - */ - private String taskId; - - /** - * 任务Code,通过此字段关联{@link TaskLocalBean#taskCode} - *

- * 双重验证,防止出现同时刻重复的情况 - */ - private String taskCode; - - /** - * 对应后台字段{@link TaskModel.MessageModel.TaskDetailInfosModel#markerIdReal},也就是探测仪扫描出来的ID - */ - private String markerId; - - private double lng; - private double lat; - - /** - * 是否已被探测到 - * 1-是,0-否 - */ - private String isDetected; - - /** - * 被探测到的时间,对应后台字段{@link TaskModel.MessageModel.TaskDetailInfosModel#finishTime} - */ - private String detectedTime; - - @Generated(hash = 677328533) - public TaskMarkerLocalBean(Long id, String taskId, String taskCode, String markerId, - double lng, double lat, String isDetected, String detectedTime) { - this.id = id; - this.taskId = taskId; - this.taskCode = taskCode; - this.markerId = markerId; - this.lng = lng; - this.lat = lat; - this.isDetected = isDetected; - this.detectedTime = detectedTime; - } - - @Generated(hash = 1162404642) - public TaskMarkerLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getTaskId() { - return this.taskId; - } - - public void setTaskId(String taskId) { - this.taskId = taskId; - } - - public String getTaskCode() { - return this.taskCode; - } - - public void setTaskCode(String taskCode) { - this.taskCode = taskCode; - } - - public String getMarkerId() { - return this.markerId; - } - - public void setMarkerId(String markerId) { - this.markerId = markerId; - } - - public double getLng() { - return this.lng; - } - - public void setLng(double lng) { - this.lng = lng; - } - - public double getLat() { - return this.lat; - } - - public void setLat(double lat) { - this.lat = lat; - } - - public String getIsDetected() { - return this.isDetected; - } - - public void setIsDetected(String isDetected) { - this.isDetected = isDetected; - } - - public String getDetectedTime() { - return this.detectedTime; - } - - public void setDetectedTime(String detectedTime) { - this.detectedTime = detectedTime; - } -} diff --git a/app/src/main/java/com/casic/common/detector/gd/dao/MarkerBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/dao/MarkerBeanDao.java new file mode 100644 index 0000000..2beb7ed --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/dao/MarkerBeanDao.java @@ -0,0 +1,29 @@ +package com.casic.common.detector.gd.dao; + +import androidx.room.Dao; +import androidx.room.Insert; +import androidx.room.Query; +import androidx.room.RawQuery; +import androidx.sqlite.db.SupportSQLiteQuery; + +import com.casic.common.detector.gd.bean.MarkerBean; + +import java.util.List; + +@Dao +public interface MarkerBeanDao { + @Query("DELETE FROM marker_detail") + void deleteAll(); + + @Insert + void insert(MarkerBean marker); + + @Query("SELECT * FROM marker_detail") + List loadAll(); + + @Query("SELECT * FROM marker_detail WHERE markerId = :markerId") + List queryMarkerById(String markerId); + + @RawQuery + List loadMarkersByCondition(SupportSQLiteQuery query); +} diff --git a/app/src/main/java/com/casic/common/detector/gd/dao/TaskBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/dao/TaskBeanDao.java new file mode 100644 index 0000000..9c70ac2 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/dao/TaskBeanDao.java @@ -0,0 +1,120 @@ +package com.casic.common.detector.gd.dao; + +import androidx.room.Dao; +import androidx.room.Insert; +import androidx.room.Query; +import androidx.room.Transaction; + +import com.casic.common.detector.gd.bean.TaskBean; +import com.casic.common.detector.gd.bean.TaskMarkerBean; +import com.casic.common.detector.gd.model.TaskDetailLocalModel; +import com.casic.common.detector.gd.model.TaskModel; +import com.casic.common.detector.gd.utils.LocaleConstant; +import com.pengxh.kt.lite.utils.SaveKeyValues; + +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Locale; + +@Dao +public interface TaskBeanDao { + @Query("SELECT COUNT(*) FROM task_detail WHERE id = :taskId") + int isTaskExist(long taskId); + + @Insert + void insert(TaskBean task); + + default void saveTask(Long taskId, String taskName) { + if (isTaskExist(taskId) == 0) { + TaskBean task = new TaskBean(); + task.setId(taskId); + task.setTaskCode(new SimpleDateFormat("yyyyMMddHHmmss", Locale.CHINA).format(new Date())); + task.setDescription(taskName); + String time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA).format(new Date()); + task.setCreateTime(time); + task.setStatus("0"); + String userName = (String) SaveKeyValues.INSTANCE.getValue(LocaleConstant.USER_NAME, ""); + task.setCreateUserName(userName); + task.setStartTime(time); + task.setEndTime(""); + task.setIsFree("1"); + insert(task); + } + } + + default void saveTask(TaskModel.MessageModel model) { + TaskBean task = new TaskBean(); + task.setId(model.getId()); + task.setTaskCode(model.getTaskCode()); + task.setDescription(model.getDescription()); + task.setCreateTime(model.getDeployDate()); + task.setStatus(model.getStatus()); + task.setCreateUserName(model.getCreatorName()); + task.setStartTime(model.getBeginDate()); + task.setEndTime(model.getEndDate()); + task.setIsFree("0"); + if (isTaskExist(task.getId()) == 0) { + insert(task); + } + } + + @Query("SELECT * FROM task_detail") + List loadAll(); + + @Transaction + default ArrayList loadLocalTask(TaskMarkerBeanDao taskMarkerBeanDao) { + ArrayList result = new ArrayList<>(); + List tasks = loadAll(); + for (TaskBean it : tasks) { + TaskDetailLocalModel model = new TaskDetailLocalModel(); + model.setTaskId(String.valueOf(it.getId())); + model.setTaskCode(it.getTaskCode()); + model.setDescription(it.getDescription()); + model.setCreateTime(it.getCreateTime()); + model.setStatus(it.getStatus()); + model.setCreateUserName(it.getCreateUserName()); + model.setIsFreeTask(it.getIsFree()); + ArrayList results = new ArrayList<>(); + if ("0".equals(it.getIsFree())) { + // 非自由巡检才有Marker + List markers = taskMarkerBeanDao.getMarkersByIdAndCode(String.valueOf(it.getId()), it.getTaskCode()); + for (TaskMarkerBean marker : markers) { + TaskDetailLocalModel.TaskMarkerLocalModel localModel = new TaskDetailLocalModel.TaskMarkerLocalModel(); + localModel.setMarkerId(marker.getMarkerId()); + localModel.setLng(marker.getLng()); + localModel.setLat(marker.getLat()); + localModel.setIsDetected(marker.getIsDetected()); + localModel.setDetectedTime(marker.getDetectedTime()); + + results.add(localModel); + } + } + model.setMarkerModels(results); + result.add(model); + } + return result; + } + + @Query("DELETE FROM task_detail WHERE id = :taskId AND taskCode = :taskCode") + void deleteTaskById(long taskId, String taskCode); + + @Transaction + default void deleteLocalTaskById(long taskId, String taskCode, TaskMarkerBeanDao taskMarkerBeanDao) { + TaskBean task = loadAll().stream() + .filter(it -> it.getId() == taskId && taskCode.equals(it.getTaskCode())) + .findFirst() + .orElse(null); + if (task == null) return; + deleteTaskById(taskId, taskCode); + + // 删除此任务关联的Marker。非自由巡检才有Marker + if ("0".equals(task.getIsFree())) { + List markers = taskMarkerBeanDao.getMarkersByIdAndCode(String.valueOf(task.getId()), task.getTaskCode()); + for (TaskMarkerBean marker : markers) { + taskMarkerBeanDao.delete(marker); + } + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/dao/TaskMarkerBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/dao/TaskMarkerBeanDao.java new file mode 100644 index 0000000..cc2156a --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/dao/TaskMarkerBeanDao.java @@ -0,0 +1,52 @@ +package com.casic.common.detector.gd.dao; + +import androidx.room.Dao; +import androidx.room.Delete; +import androidx.room.Insert; +import androidx.room.Query; +import androidx.room.Update; + +import com.casic.common.detector.gd.bean.TaskMarkerBean; +import com.casic.common.detector.gd.model.TaskModel; + +import java.util.List; + +@Dao +public interface TaskMarkerBeanDao { + + @Insert + void insert(TaskMarkerBean marker); + + @Query("SELECT COUNT(*) FROM task_marker_info WHERE id = :markerId") + int isMarkerExist(String markerId); + + default void saveTaskMarker(long taskId, String taskCode, TaskModel.MessageModel.TaskDetailInfosModel marker) { + if (isMarkerExist(marker.getMarkerId()) == 0) { + TaskMarkerBean bean = new TaskMarkerBean(); + bean.setId(marker.getId()); + bean.setTaskId(String.valueOf(taskId)); + bean.setTaskCode(taskCode); + bean.setMarkerId(marker.getMarkerIdReal()); + bean.setLng(marker.getLongitude()); + bean.setLat(marker.getLatitude()); + bean.setIsDetected("0"); + bean.setDetectedTime(""); + insert(bean); + } + } + + @Query("SELECT * FROM task_marker_info WHERE taskId = :taskId AND taskCode = :taskCode AND markerId = :markerId AND isDetected = :state") + TaskMarkerBean queryTaskMarkerById(String taskId, String taskCode, String markerId, String state); + + @Update + void updateLocalTaskMarkerState(TaskMarkerBean marker); + + @Query("SELECT * FROM task_marker_info WHERE isDetected = :state") + List queryMarkerByState(String state); + + @Query("SELECT * FROM task_marker_info WHERE taskId = :taskId AND taskCode = :taskCode") + List getMarkersByIdAndCode(String taskId, String taskCode); + + @Delete + void delete(TaskMarkerBean marker); +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/extensions/Long.kt b/app/src/main/java/com/casic/common/detector/gd/extensions/Long.kt deleted file mode 100644 index 6713d8d..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/extensions/Long.kt +++ /dev/null @@ -1,10 +0,0 @@ -package com.casic.common.detector.gd.extensions - -import java.text.SimpleDateFormat -import java.util.Date -import java.util.Locale - -fun Long.createTaskCode(): String { - val dateFormat = SimpleDateFormat("yyyyMMddHHmmss", Locale.CHINA) - return dateFormat.format(Date(this)) -} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoMaster.java b/app/src/main/java/com/casic/common/detector/gd/greendao/DaoMaster.java deleted file mode 100644 index 6ab94b3..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoMaster.java +++ /dev/null @@ -1,102 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import android.content.Context; -import android.database.sqlite.SQLiteDatabase; -import android.database.sqlite.SQLiteDatabase.CursorFactory; -import android.util.Log; - -import org.greenrobot.greendao.AbstractDaoMaster; -import org.greenrobot.greendao.database.StandardDatabase; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.database.DatabaseOpenHelper; -import org.greenrobot.greendao.identityscope.IdentityScopeType; - - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** - * Master of DAO (schema version 1): knows all DAOs. - */ -public class DaoMaster extends AbstractDaoMaster { - public static final int SCHEMA_VERSION = 1; - - /** Creates underlying database table using DAOs. */ - public static void createAllTables(Database db, boolean ifNotExists) { - MarkerLocalBeanDao.createTable(db, ifNotExists); - TaskLocalBeanDao.createTable(db, ifNotExists); - TaskMarkerLocalBeanDao.createTable(db, ifNotExists); - } - - /** Drops underlying database table using DAOs. */ - public static void dropAllTables(Database db, boolean ifExists) { - MarkerLocalBeanDao.dropTable(db, ifExists); - TaskLocalBeanDao.dropTable(db, ifExists); - TaskMarkerLocalBeanDao.dropTable(db, ifExists); - } - - /** - * WARNING: Drops all table on Upgrade! Use only during development. - * Convenience method using a {@link DevOpenHelper}. - */ - public static DaoSession newDevSession(Context context, String name) { - Database db = new DevOpenHelper(context, name).getWritableDb(); - DaoMaster daoMaster = new DaoMaster(db); - return daoMaster.newSession(); - } - - public DaoMaster(SQLiteDatabase db) { - this(new StandardDatabase(db)); - } - - public DaoMaster(Database db) { - super(db, SCHEMA_VERSION); - registerDaoClass(MarkerLocalBeanDao.class); - registerDaoClass(TaskLocalBeanDao.class); - registerDaoClass(TaskMarkerLocalBeanDao.class); - } - - public DaoSession newSession() { - return new DaoSession(db, IdentityScopeType.Session, daoConfigMap); - } - - public DaoSession newSession(IdentityScopeType type) { - return new DaoSession(db, type, daoConfigMap); - } - - /** - * Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} - - */ - public static abstract class OpenHelper extends DatabaseOpenHelper { - public OpenHelper(Context context, String name) { - super(context, name, SCHEMA_VERSION); - } - - public OpenHelper(Context context, String name, CursorFactory factory) { - super(context, name, factory, SCHEMA_VERSION); - } - - @Override - public void onCreate(Database db) { - Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION); - createAllTables(db, false); - } - } - - /** WARNING: Drops all table on Upgrade! Use only during development. */ - public static class DevOpenHelper extends OpenHelper { - public DevOpenHelper(Context context, String name) { - super(context, name); - } - - public DevOpenHelper(Context context, String name, CursorFactory factory) { - super(context, name, factory); - } - - @Override - public void onUpgrade(Database db, int oldVersion, int newVersion) { - Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables"); - dropAllTables(db, true); - onCreate(db); - } - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoSession.java b/app/src/main/java/com/casic/common/detector/gd/greendao/DaoSession.java deleted file mode 100644 index c8b1a20..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoSession.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import java.util.Map; - -import org.greenrobot.greendao.AbstractDao; -import org.greenrobot.greendao.AbstractDaoSession; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.identityscope.IdentityScopeType; -import org.greenrobot.greendao.internal.DaoConfig; - -import com.casic.common.detector.gd.bean.MarkerLocalBean; -import com.casic.common.detector.gd.bean.TaskLocalBean; -import com.casic.common.detector.gd.bean.TaskMarkerLocalBean; - -import com.casic.common.detector.gd.greendao.MarkerLocalBeanDao; -import com.casic.common.detector.gd.greendao.TaskLocalBeanDao; -import com.casic.common.detector.gd.greendao.TaskMarkerLocalBeanDao; - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. - -/** - * {@inheritDoc} - * - * @see org.greenrobot.greendao.AbstractDaoSession - */ -public class DaoSession extends AbstractDaoSession { - - private final DaoConfig markerLocalBeanDaoConfig; - private final DaoConfig taskLocalBeanDaoConfig; - private final DaoConfig taskMarkerLocalBeanDaoConfig; - - private final MarkerLocalBeanDao markerLocalBeanDao; - private final TaskLocalBeanDao taskLocalBeanDao; - private final TaskMarkerLocalBeanDao taskMarkerLocalBeanDao; - - public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> - daoConfigMap) { - super(db); - - markerLocalBeanDaoConfig = daoConfigMap.get(MarkerLocalBeanDao.class).clone(); - markerLocalBeanDaoConfig.initIdentityScope(type); - - taskLocalBeanDaoConfig = daoConfigMap.get(TaskLocalBeanDao.class).clone(); - taskLocalBeanDaoConfig.initIdentityScope(type); - - taskMarkerLocalBeanDaoConfig = daoConfigMap.get(TaskMarkerLocalBeanDao.class).clone(); - taskMarkerLocalBeanDaoConfig.initIdentityScope(type); - - markerLocalBeanDao = new MarkerLocalBeanDao(markerLocalBeanDaoConfig, this); - taskLocalBeanDao = new TaskLocalBeanDao(taskLocalBeanDaoConfig, this); - taskMarkerLocalBeanDao = new TaskMarkerLocalBeanDao(taskMarkerLocalBeanDaoConfig, this); - - registerDao(MarkerLocalBean.class, markerLocalBeanDao); - registerDao(TaskLocalBean.class, taskLocalBeanDao); - registerDao(TaskMarkerLocalBean.class, taskMarkerLocalBeanDao); - } - - public void clear() { - markerLocalBeanDaoConfig.clearIdentityScope(); - taskLocalBeanDaoConfig.clearIdentityScope(); - taskMarkerLocalBeanDaoConfig.clearIdentityScope(); - } - - public MarkerLocalBeanDao getMarkerLocalBeanDao() { - return markerLocalBeanDao; - } - - public TaskLocalBeanDao getTaskLocalBeanDao() { - return taskLocalBeanDao; - } - - public TaskMarkerLocalBeanDao getTaskMarkerLocalBeanDao() { - return taskMarkerLocalBeanDao; - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/MarkerLocalBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/greendao/MarkerLocalBeanDao.java deleted file mode 100644 index 2f792c3..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/MarkerLocalBeanDao.java +++ /dev/null @@ -1,479 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import android.database.Cursor; -import android.database.sqlite.SQLiteStatement; - -import org.greenrobot.greendao.AbstractDao; -import org.greenrobot.greendao.Property; -import org.greenrobot.greendao.internal.DaoConfig; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.database.DatabaseStatement; - -import com.casic.common.detector.gd.bean.MarkerLocalBean; - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** - * DAO for table "MARKER_LOCAL_BEAN". -*/ -public class MarkerLocalBeanDao extends AbstractDao { - - public static final String TABLENAME = "MARKER_LOCAL_BEAN"; - - /** - * Properties of entity MarkerLocalBean.
- * Can be used for QueryBuilder and for referencing column names. - */ - public static class Properties { - public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property PipelineType = new Property(1, String.class, "pipelineType", false, "PIPELINE_TYPE"); - public final static Property PipelineDiameter = new Property(2, String.class, "pipelineDiameter", false, "PIPELINE_DIAMETER"); - public final static Property PipelineMaterial = new Property(3, String.class, "pipelineMaterial", false, "PIPELINE_MATERIAL"); - public final static Property BuryMethod = new Property(4, String.class, "buryMethod", false, "BURY_METHOD"); - public final static Property BuryDepth = new Property(5, String.class, "buryDepth", false, "BURY_DEPTH"); - public final static Property Area = new Property(6, String.class, "area", false, "AREA"); - public final static Property Line = new Property(7, String.class, "line", false, "LINE"); - public final static Property Road = new Property(8, String.class, "road", false, "ROAD"); - public final static Property ConstructTime = new Property(9, String.class, "constructTime", false, "CONSTRUCT_TIME"); - public final static Property Owner = new Property(10, String.class, "owner", false, "OWNER"); - public final static Property ObjectId = new Property(11, String.class, "objectId", false, "OBJECT_ID"); - public final static Property MarkerId = new Property(12, String.class, "markerId", false, "MARKER_ID"); - public final static Property MarkerType = new Property(13, String.class, "markerType", false, "MARKER_TYPE"); - public final static Property MarkerDepth = new Property(14, String.class, "markerDepth", false, "MARKER_DEPTH"); - public final static Property InstallationDept = new Property(15, String.class, "installationDept", false, "INSTALLATION_DEPT"); - public final static Property Lng = new Property(16, String.class, "lng", false, "LNG"); - public final static Property Lat = new Property(17, String.class, "lat", false, "LAT"); - public final static Property UpdateTime = new Property(18, String.class, "updateTime", false, "UPDATE_TIME"); - public final static Property Remark = new Property(19, String.class, "remark", false, "REMARK"); - public final static Property UnderlyingPipelineType = new Property(20, String.class, "underlyingPipelineType", false, "UNDERLYING_PIPELINE_TYPE"); - public final static Property UnderlyingPipelineDepth = new Property(21, String.class, "underlyingPipelineDepth", false, "UNDERLYING_PIPELINE_DEPTH"); - public final static Property UnderlyingPipelineDiameter = new Property(22, String.class, "underlyingPipelineDiameter", false, "UNDERLYING_PIPELINE_DIAMETER"); - public final static Property UnderlyingPipelineMaterial = new Property(23, String.class, "underlyingPipelineMaterial", false, "UNDERLYING_PIPELINE_MATERIAL"); - public final static Property ObjectType = new Property(24, String.class, "objectType", false, "OBJECT_TYPE"); - public final static Property Color = new Property(25, String.class, "color", false, "COLOR"); - public final static Property ImagePath = new Property(26, String.class, "imagePath", false, "IMAGE_PATH"); - } - - - public MarkerLocalBeanDao(DaoConfig config) { - super(config); - } - - public MarkerLocalBeanDao(DaoConfig config, DaoSession daoSession) { - super(config, daoSession); - } - - /** Creates the underlying database table. */ - public static void createTable(Database db, boolean ifNotExists) { - String constraint = ifNotExists? "IF NOT EXISTS ": ""; - db.execSQL("CREATE TABLE " + constraint + "\"MARKER_LOCAL_BEAN\" (" + // - "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id - "\"PIPELINE_TYPE\" TEXT," + // 1: pipelineType - "\"PIPELINE_DIAMETER\" TEXT," + // 2: pipelineDiameter - "\"PIPELINE_MATERIAL\" TEXT," + // 3: pipelineMaterial - "\"BURY_METHOD\" TEXT," + // 4: buryMethod - "\"BURY_DEPTH\" TEXT," + // 5: buryDepth - "\"AREA\" TEXT," + // 6: area - "\"LINE\" TEXT," + // 7: line - "\"ROAD\" TEXT," + // 8: road - "\"CONSTRUCT_TIME\" TEXT," + // 9: constructTime - "\"OWNER\" TEXT," + // 10: owner - "\"OBJECT_ID\" TEXT," + // 11: objectId - "\"MARKER_ID\" TEXT," + // 12: markerId - "\"MARKER_TYPE\" TEXT," + // 13: markerType - "\"MARKER_DEPTH\" TEXT," + // 14: markerDepth - "\"INSTALLATION_DEPT\" TEXT," + // 15: installationDept - "\"LNG\" TEXT," + // 16: lng - "\"LAT\" TEXT," + // 17: lat - "\"UPDATE_TIME\" TEXT," + // 18: updateTime - "\"REMARK\" TEXT," + // 19: remark - "\"UNDERLYING_PIPELINE_TYPE\" TEXT," + // 20: underlyingPipelineType - "\"UNDERLYING_PIPELINE_DEPTH\" TEXT," + // 21: underlyingPipelineDepth - "\"UNDERLYING_PIPELINE_DIAMETER\" TEXT," + // 22: underlyingPipelineDiameter - "\"UNDERLYING_PIPELINE_MATERIAL\" TEXT," + // 23: underlyingPipelineMaterial - "\"OBJECT_TYPE\" TEXT," + // 24: objectType - "\"COLOR\" TEXT," + // 25: color - "\"IMAGE_PATH\" TEXT);"); // 26: imagePath - } - - /** Drops the underlying database table. */ - public static void dropTable(Database db, boolean ifExists) { - String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"MARKER_LOCAL_BEAN\""; - db.execSQL(sql); - } - - @Override - protected final void bindValues(DatabaseStatement stmt, MarkerLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String pipelineType = entity.getPipelineType(); - if (pipelineType != null) { - stmt.bindString(2, pipelineType); - } - - String pipelineDiameter = entity.getPipelineDiameter(); - if (pipelineDiameter != null) { - stmt.bindString(3, pipelineDiameter); - } - - String pipelineMaterial = entity.getPipelineMaterial(); - if (pipelineMaterial != null) { - stmt.bindString(4, pipelineMaterial); - } - - String buryMethod = entity.getBuryMethod(); - if (buryMethod != null) { - stmt.bindString(5, buryMethod); - } - - String buryDepth = entity.getBuryDepth(); - if (buryDepth != null) { - stmt.bindString(6, buryDepth); - } - - String area = entity.getArea(); - if (area != null) { - stmt.bindString(7, area); - } - - String line = entity.getLine(); - if (line != null) { - stmt.bindString(8, line); - } - - String road = entity.getRoad(); - if (road != null) { - stmt.bindString(9, road); - } - - String constructTime = entity.getConstructTime(); - if (constructTime != null) { - stmt.bindString(10, constructTime); - } - - String owner = entity.getOwner(); - if (owner != null) { - stmt.bindString(11, owner); - } - - String objectId = entity.getObjectId(); - if (objectId != null) { - stmt.bindString(12, objectId); - } - - String markerId = entity.getMarkerId(); - if (markerId != null) { - stmt.bindString(13, markerId); - } - - String markerType = entity.getMarkerType(); - if (markerType != null) { - stmt.bindString(14, markerType); - } - - String markerDepth = entity.getMarkerDepth(); - if (markerDepth != null) { - stmt.bindString(15, markerDepth); - } - - String installationDept = entity.getInstallationDept(); - if (installationDept != null) { - stmt.bindString(16, installationDept); - } - - String lng = entity.getLng(); - if (lng != null) { - stmt.bindString(17, lng); - } - - String lat = entity.getLat(); - if (lat != null) { - stmt.bindString(18, lat); - } - - String updateTime = entity.getUpdateTime(); - if (updateTime != null) { - stmt.bindString(19, updateTime); - } - - String remark = entity.getRemark(); - if (remark != null) { - stmt.bindString(20, remark); - } - - String underlyingPipelineType = entity.getUnderlyingPipelineType(); - if (underlyingPipelineType != null) { - stmt.bindString(21, underlyingPipelineType); - } - - String underlyingPipelineDepth = entity.getUnderlyingPipelineDepth(); - if (underlyingPipelineDepth != null) { - stmt.bindString(22, underlyingPipelineDepth); - } - - String underlyingPipelineDiameter = entity.getUnderlyingPipelineDiameter(); - if (underlyingPipelineDiameter != null) { - stmt.bindString(23, underlyingPipelineDiameter); - } - - String underlyingPipelineMaterial = entity.getUnderlyingPipelineMaterial(); - if (underlyingPipelineMaterial != null) { - stmt.bindString(24, underlyingPipelineMaterial); - } - - String objectType = entity.getObjectType(); - if (objectType != null) { - stmt.bindString(25, objectType); - } - - String color = entity.getColor(); - if (color != null) { - stmt.bindString(26, color); - } - - String imagePath = entity.getImagePath(); - if (imagePath != null) { - stmt.bindString(27, imagePath); - } - } - - @Override - protected final void bindValues(SQLiteStatement stmt, MarkerLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String pipelineType = entity.getPipelineType(); - if (pipelineType != null) { - stmt.bindString(2, pipelineType); - } - - String pipelineDiameter = entity.getPipelineDiameter(); - if (pipelineDiameter != null) { - stmt.bindString(3, pipelineDiameter); - } - - String pipelineMaterial = entity.getPipelineMaterial(); - if (pipelineMaterial != null) { - stmt.bindString(4, pipelineMaterial); - } - - String buryMethod = entity.getBuryMethod(); - if (buryMethod != null) { - stmt.bindString(5, buryMethod); - } - - String buryDepth = entity.getBuryDepth(); - if (buryDepth != null) { - stmt.bindString(6, buryDepth); - } - - String area = entity.getArea(); - if (area != null) { - stmt.bindString(7, area); - } - - String line = entity.getLine(); - if (line != null) { - stmt.bindString(8, line); - } - - String road = entity.getRoad(); - if (road != null) { - stmt.bindString(9, road); - } - - String constructTime = entity.getConstructTime(); - if (constructTime != null) { - stmt.bindString(10, constructTime); - } - - String owner = entity.getOwner(); - if (owner != null) { - stmt.bindString(11, owner); - } - - String objectId = entity.getObjectId(); - if (objectId != null) { - stmt.bindString(12, objectId); - } - - String markerId = entity.getMarkerId(); - if (markerId != null) { - stmt.bindString(13, markerId); - } - - String markerType = entity.getMarkerType(); - if (markerType != null) { - stmt.bindString(14, markerType); - } - - String markerDepth = entity.getMarkerDepth(); - if (markerDepth != null) { - stmt.bindString(15, markerDepth); - } - - String installationDept = entity.getInstallationDept(); - if (installationDept != null) { - stmt.bindString(16, installationDept); - } - - String lng = entity.getLng(); - if (lng != null) { - stmt.bindString(17, lng); - } - - String lat = entity.getLat(); - if (lat != null) { - stmt.bindString(18, lat); - } - - String updateTime = entity.getUpdateTime(); - if (updateTime != null) { - stmt.bindString(19, updateTime); - } - - String remark = entity.getRemark(); - if (remark != null) { - stmt.bindString(20, remark); - } - - String underlyingPipelineType = entity.getUnderlyingPipelineType(); - if (underlyingPipelineType != null) { - stmt.bindString(21, underlyingPipelineType); - } - - String underlyingPipelineDepth = entity.getUnderlyingPipelineDepth(); - if (underlyingPipelineDepth != null) { - stmt.bindString(22, underlyingPipelineDepth); - } - - String underlyingPipelineDiameter = entity.getUnderlyingPipelineDiameter(); - if (underlyingPipelineDiameter != null) { - stmt.bindString(23, underlyingPipelineDiameter); - } - - String underlyingPipelineMaterial = entity.getUnderlyingPipelineMaterial(); - if (underlyingPipelineMaterial != null) { - stmt.bindString(24, underlyingPipelineMaterial); - } - - String objectType = entity.getObjectType(); - if (objectType != null) { - stmt.bindString(25, objectType); - } - - String color = entity.getColor(); - if (color != null) { - stmt.bindString(26, color); - } - - String imagePath = entity.getImagePath(); - if (imagePath != null) { - stmt.bindString(27, imagePath); - } - } - - @Override - public Long readKey(Cursor cursor, int offset) { - return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); - } - - @Override - public MarkerLocalBean readEntity(Cursor cursor, int offset) { - MarkerLocalBean entity = new MarkerLocalBean( // - cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // pipelineType - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // pipelineDiameter - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // pipelineMaterial - cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // buryMethod - cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // buryDepth - cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // area - cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // line - cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // road - cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // constructTime - cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10), // owner - cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11), // objectId - cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12), // markerId - cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13), // markerType - cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14), // markerDepth - cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15), // installationDept - cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16), // lng - cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17), // lat - cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18), // updateTime - cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19), // remark - cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20), // underlyingPipelineType - cursor.isNull(offset + 21) ? null : cursor.getString(offset + 21), // underlyingPipelineDepth - cursor.isNull(offset + 22) ? null : cursor.getString(offset + 22), // underlyingPipelineDiameter - cursor.isNull(offset + 23) ? null : cursor.getString(offset + 23), // underlyingPipelineMaterial - cursor.isNull(offset + 24) ? null : cursor.getString(offset + 24), // objectType - cursor.isNull(offset + 25) ? null : cursor.getString(offset + 25), // color - cursor.isNull(offset + 26) ? null : cursor.getString(offset + 26) // imagePath - ); - return entity; - } - - @Override - public void readEntity(Cursor cursor, MarkerLocalBean entity, int offset) { - entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setPipelineType(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); - entity.setPipelineDiameter(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); - entity.setPipelineMaterial(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); - entity.setBuryMethod(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); - entity.setBuryDepth(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); - entity.setArea(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); - entity.setLine(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); - entity.setRoad(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); - entity.setConstructTime(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9)); - entity.setOwner(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); - entity.setObjectId(cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11)); - entity.setMarkerId(cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12)); - entity.setMarkerType(cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13)); - entity.setMarkerDepth(cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14)); - entity.setInstallationDept(cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15)); - entity.setLng(cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16)); - entity.setLat(cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17)); - entity.setUpdateTime(cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18)); - entity.setRemark(cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19)); - entity.setUnderlyingPipelineType(cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20)); - entity.setUnderlyingPipelineDepth(cursor.isNull(offset + 21) ? null : cursor.getString(offset + 21)); - entity.setUnderlyingPipelineDiameter(cursor.isNull(offset + 22) ? null : cursor.getString(offset + 22)); - entity.setUnderlyingPipelineMaterial(cursor.isNull(offset + 23) ? null : cursor.getString(offset + 23)); - entity.setObjectType(cursor.isNull(offset + 24) ? null : cursor.getString(offset + 24)); - entity.setColor(cursor.isNull(offset + 25) ? null : cursor.getString(offset + 25)); - entity.setImagePath(cursor.isNull(offset + 26) ? null : cursor.getString(offset + 26)); - } - - @Override - protected final Long updateKeyAfterInsert(MarkerLocalBean entity, long rowId) { - entity.setId(rowId); - return rowId; - } - - @Override - public Long getKey(MarkerLocalBean entity) { - if(entity != null) { - return entity.getId(); - } else { - return null; - } - } - - @Override - public boolean hasKey(MarkerLocalBean entity) { - return entity.getId() != null; - } - - @Override - protected final boolean isEntityUpdateable() { - return true; - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/TaskLocalBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/greendao/TaskLocalBeanDao.java deleted file mode 100644 index fb88157..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/TaskLocalBeanDao.java +++ /dev/null @@ -1,227 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import android.database.Cursor; -import android.database.sqlite.SQLiteStatement; - -import org.greenrobot.greendao.AbstractDao; -import org.greenrobot.greendao.Property; -import org.greenrobot.greendao.internal.DaoConfig; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.database.DatabaseStatement; - -import com.casic.common.detector.gd.bean.TaskLocalBean; - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** - * DAO for table "TASK_LOCAL_BEAN". -*/ -public class TaskLocalBeanDao extends AbstractDao { - - public static final String TABLENAME = "TASK_LOCAL_BEAN"; - - /** - * Properties of entity TaskLocalBean.
- * Can be used for QueryBuilder and for referencing column names. - */ - public static class Properties { - public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property TaskCode = new Property(1, String.class, "taskCode", false, "TASK_CODE"); - public final static Property Description = new Property(2, String.class, "description", false, "DESCRIPTION"); - public final static Property CreateTime = new Property(3, String.class, "createTime", false, "CREATE_TIME"); - public final static Property Status = new Property(4, String.class, "status", false, "STATUS"); - public final static Property CreateUserName = new Property(5, String.class, "createUserName", false, "CREATE_USER_NAME"); - public final static Property StartTime = new Property(6, String.class, "startTime", false, "START_TIME"); - public final static Property EndTime = new Property(7, String.class, "endTime", false, "END_TIME"); - public final static Property IsFreeTask = new Property(8, String.class, "isFreeTask", false, "IS_FREE_TASK"); - } - - - public TaskLocalBeanDao(DaoConfig config) { - super(config); - } - - public TaskLocalBeanDao(DaoConfig config, DaoSession daoSession) { - super(config, daoSession); - } - - /** Creates the underlying database table. */ - public static void createTable(Database db, boolean ifNotExists) { - String constraint = ifNotExists? "IF NOT EXISTS ": ""; - db.execSQL("CREATE TABLE " + constraint + "\"TASK_LOCAL_BEAN\" (" + // - "\"_id\" INTEGER PRIMARY KEY ," + // 0: id - "\"TASK_CODE\" TEXT," + // 1: taskCode - "\"DESCRIPTION\" TEXT," + // 2: description - "\"CREATE_TIME\" TEXT," + // 3: createTime - "\"STATUS\" TEXT," + // 4: status - "\"CREATE_USER_NAME\" TEXT," + // 5: createUserName - "\"START_TIME\" TEXT," + // 6: startTime - "\"END_TIME\" TEXT," + // 7: endTime - "\"IS_FREE_TASK\" TEXT);"); // 8: isFreeTask - } - - /** Drops the underlying database table. */ - public static void dropTable(Database db, boolean ifExists) { - String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"TASK_LOCAL_BEAN\""; - db.execSQL(sql); - } - - @Override - protected final void bindValues(DatabaseStatement stmt, TaskLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String taskCode = entity.getTaskCode(); - if (taskCode != null) { - stmt.bindString(2, taskCode); - } - - String description = entity.getDescription(); - if (description != null) { - stmt.bindString(3, description); - } - - String createTime = entity.getCreateTime(); - if (createTime != null) { - stmt.bindString(4, createTime); - } - - String status = entity.getStatus(); - if (status != null) { - stmt.bindString(5, status); - } - - String createUserName = entity.getCreateUserName(); - if (createUserName != null) { - stmt.bindString(6, createUserName); - } - - String startTime = entity.getStartTime(); - if (startTime != null) { - stmt.bindString(7, startTime); - } - - String endTime = entity.getEndTime(); - if (endTime != null) { - stmt.bindString(8, endTime); - } - - String isFreeTask = entity.getIsFreeTask(); - if (isFreeTask != null) { - stmt.bindString(9, isFreeTask); - } - } - - @Override - protected final void bindValues(SQLiteStatement stmt, TaskLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String taskCode = entity.getTaskCode(); - if (taskCode != null) { - stmt.bindString(2, taskCode); - } - - String description = entity.getDescription(); - if (description != null) { - stmt.bindString(3, description); - } - - String createTime = entity.getCreateTime(); - if (createTime != null) { - stmt.bindString(4, createTime); - } - - String status = entity.getStatus(); - if (status != null) { - stmt.bindString(5, status); - } - - String createUserName = entity.getCreateUserName(); - if (createUserName != null) { - stmt.bindString(6, createUserName); - } - - String startTime = entity.getStartTime(); - if (startTime != null) { - stmt.bindString(7, startTime); - } - - String endTime = entity.getEndTime(); - if (endTime != null) { - stmt.bindString(8, endTime); - } - - String isFreeTask = entity.getIsFreeTask(); - if (isFreeTask != null) { - stmt.bindString(9, isFreeTask); - } - } - - @Override - public Long readKey(Cursor cursor, int offset) { - return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); - } - - @Override - public TaskLocalBean readEntity(Cursor cursor, int offset) { - TaskLocalBean entity = new TaskLocalBean( // - cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // taskCode - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // description - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // createTime - cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // status - cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // createUserName - cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // startTime - cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // endTime - cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8) // isFreeTask - ); - return entity; - } - - @Override - public void readEntity(Cursor cursor, TaskLocalBean entity, int offset) { - entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setTaskCode(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); - entity.setDescription(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); - entity.setCreateTime(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); - entity.setStatus(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); - entity.setCreateUserName(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); - entity.setStartTime(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); - entity.setEndTime(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); - entity.setIsFreeTask(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); - } - - @Override - protected final Long updateKeyAfterInsert(TaskLocalBean entity, long rowId) { - entity.setId(rowId); - return rowId; - } - - @Override - public Long getKey(TaskLocalBean entity) { - if(entity != null) { - return entity.getId(); - } else { - return null; - } - } - - @Override - public boolean hasKey(TaskLocalBean entity) { - return entity.getId() != null; - } - - @Override - protected final boolean isEntityUpdateable() { - return true; - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/TaskMarkerLocalBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/greendao/TaskMarkerLocalBeanDao.java deleted file mode 100644 index e96c735..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/TaskMarkerLocalBeanDao.java +++ /dev/null @@ -1,197 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import android.database.Cursor; -import android.database.sqlite.SQLiteStatement; - -import org.greenrobot.greendao.AbstractDao; -import org.greenrobot.greendao.Property; -import org.greenrobot.greendao.internal.DaoConfig; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.database.DatabaseStatement; - -import com.casic.common.detector.gd.bean.TaskMarkerLocalBean; - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** - * DAO for table "TASK_MARKER_LOCAL_BEAN". -*/ -public class TaskMarkerLocalBeanDao extends AbstractDao { - - public static final String TABLENAME = "TASK_MARKER_LOCAL_BEAN"; - - /** - * Properties of entity TaskMarkerLocalBean.
- * Can be used for QueryBuilder and for referencing column names. - */ - public static class Properties { - public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property TaskId = new Property(1, String.class, "taskId", false, "TASK_ID"); - public final static Property TaskCode = new Property(2, String.class, "taskCode", false, "TASK_CODE"); - public final static Property MarkerId = new Property(3, String.class, "markerId", false, "MARKER_ID"); - public final static Property Lng = new Property(4, double.class, "lng", false, "LNG"); - public final static Property Lat = new Property(5, double.class, "lat", false, "LAT"); - public final static Property IsDetected = new Property(6, String.class, "isDetected", false, "IS_DETECTED"); - public final static Property DetectedTime = new Property(7, String.class, "detectedTime", false, "DETECTED_TIME"); - } - - - public TaskMarkerLocalBeanDao(DaoConfig config) { - super(config); - } - - public TaskMarkerLocalBeanDao(DaoConfig config, DaoSession daoSession) { - super(config, daoSession); - } - - /** Creates the underlying database table. */ - public static void createTable(Database db, boolean ifNotExists) { - String constraint = ifNotExists? "IF NOT EXISTS ": ""; - db.execSQL("CREATE TABLE " + constraint + "\"TASK_MARKER_LOCAL_BEAN\" (" + // - "\"_id\" INTEGER PRIMARY KEY ," + // 0: id - "\"TASK_ID\" TEXT," + // 1: taskId - "\"TASK_CODE\" TEXT," + // 2: taskCode - "\"MARKER_ID\" TEXT," + // 3: markerId - "\"LNG\" REAL NOT NULL ," + // 4: lng - "\"LAT\" REAL NOT NULL ," + // 5: lat - "\"IS_DETECTED\" TEXT," + // 6: isDetected - "\"DETECTED_TIME\" TEXT);"); // 7: detectedTime - } - - /** Drops the underlying database table. */ - public static void dropTable(Database db, boolean ifExists) { - String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"TASK_MARKER_LOCAL_BEAN\""; - db.execSQL(sql); - } - - @Override - protected final void bindValues(DatabaseStatement stmt, TaskMarkerLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String taskId = entity.getTaskId(); - if (taskId != null) { - stmt.bindString(2, taskId); - } - - String taskCode = entity.getTaskCode(); - if (taskCode != null) { - stmt.bindString(3, taskCode); - } - - String markerId = entity.getMarkerId(); - if (markerId != null) { - stmt.bindString(4, markerId); - } - stmt.bindDouble(5, entity.getLng()); - stmt.bindDouble(6, entity.getLat()); - - String isDetected = entity.getIsDetected(); - if (isDetected != null) { - stmt.bindString(7, isDetected); - } - - String detectedTime = entity.getDetectedTime(); - if (detectedTime != null) { - stmt.bindString(8, detectedTime); - } - } - - @Override - protected final void bindValues(SQLiteStatement stmt, TaskMarkerLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String taskId = entity.getTaskId(); - if (taskId != null) { - stmt.bindString(2, taskId); - } - - String taskCode = entity.getTaskCode(); - if (taskCode != null) { - stmt.bindString(3, taskCode); - } - - String markerId = entity.getMarkerId(); - if (markerId != null) { - stmt.bindString(4, markerId); - } - stmt.bindDouble(5, entity.getLng()); - stmt.bindDouble(6, entity.getLat()); - - String isDetected = entity.getIsDetected(); - if (isDetected != null) { - stmt.bindString(7, isDetected); - } - - String detectedTime = entity.getDetectedTime(); - if (detectedTime != null) { - stmt.bindString(8, detectedTime); - } - } - - @Override - public Long readKey(Cursor cursor, int offset) { - return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); - } - - @Override - public TaskMarkerLocalBean readEntity(Cursor cursor, int offset) { - TaskMarkerLocalBean entity = new TaskMarkerLocalBean( // - cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // taskId - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // taskCode - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // markerId - cursor.getDouble(offset + 4), // lng - cursor.getDouble(offset + 5), // lat - cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // isDetected - cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7) // detectedTime - ); - return entity; - } - - @Override - public void readEntity(Cursor cursor, TaskMarkerLocalBean entity, int offset) { - entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setTaskId(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); - entity.setTaskCode(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); - entity.setMarkerId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); - entity.setLng(cursor.getDouble(offset + 4)); - entity.setLat(cursor.getDouble(offset + 5)); - entity.setIsDetected(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); - entity.setDetectedTime(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); - } - - @Override - protected final Long updateKeyAfterInsert(TaskMarkerLocalBean entity, long rowId) { - entity.setId(rowId); - return rowId; - } - - @Override - public Long getKey(TaskMarkerLocalBean entity) { - if(entity != null) { - return entity.getId(); - } else { - return null; - } - } - - @Override - public boolean hasKey(TaskMarkerLocalBean entity) { - return entity.getId() != null; - } - - @Override - protected final boolean isEntityUpdateable() { - return true; - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/model/TaskModel.java b/app/src/main/java/com/casic/common/detector/gd/model/TaskModel.java index 6e853ad..67ef5fb 100644 --- a/app/src/main/java/com/casic/common/detector/gd/model/TaskModel.java +++ b/app/src/main/java/com/casic/common/detector/gd/model/TaskModel.java @@ -24,7 +24,7 @@ } public static class MessageModel { - private int id; + private Long id; private String taskCode; private String description; private String deployDate; @@ -38,11 +38,11 @@ private int isValid; private List taskDetailInfos; - public int getId() { + public Long getId() { return id; } - public void setId(int id) { + public void setId(Long id) { this.id = id; } @@ -143,25 +143,25 @@ } public static class TaskDetailInfosModel { - private int id; + private long id; private String taskId; private String taskCode; private Object markerName; - private int markerId; + private String markerId; private String markerIdReal; private double longitude; private double latitude; private int isChecked; private int isNormal; - private Object imagePath; - private Object description; - private Object finishTime; + private String imagePath; + private String description; + private String finishTime; - public int getId() { + public long getId() { return id; } - public void setId(int id) { + public void setId(long id) { this.id = id; } @@ -189,11 +189,11 @@ this.markerName = markerName; } - public int getMarkerId() { + public String getMarkerId() { return markerId; } - public void setMarkerId(int markerId) { + public void setMarkerId(String markerId) { this.markerId = markerId; } @@ -237,27 +237,27 @@ this.isNormal = isNormal; } - public Object getImagePath() { + public String getImagePath() { return imagePath; } - public void setImagePath(Object imagePath) { + public void setImagePath(String imagePath) { this.imagePath = imagePath; } - public Object getDescription() { + public String getDescription() { return description; } - public void setDescription(Object description) { + public void setDescription(String description) { this.description = description; } - public Object getFinishTime() { + public String getFinishTime() { return finishTime; } - public void setFinishTime(Object finishTime) { + public void setFinishTime(String finishTime) { this.finishTime = finishTime; } } diff --git a/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitService.kt index 7522a87..0adad51 100644 --- a/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitService.kt @@ -50,7 +50,7 @@ */ @Multipart @POST("/ems/marker/save-marker-photo.do") - suspend fun installLabel( + suspend fun install( @PartMap jsonMarker: Map, @Part fileBuffer1: MultipartBody.Part?, @Part fileBuffer2: MultipartBody.Part?, diff --git a/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitServiceManager.kt index 5f6c701..ae2a0fa 100644 --- a/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitServiceManager.kt +++ b/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitServiceManager.kt @@ -37,22 +37,28 @@ /** * 获取标识器信息文件 */ - suspend fun getMarkerFile(userId: String, companyId: String): String { - return createApi().getMarkerFile(userId, companyId) + suspend fun getMarkerFile(): String { + val companyId = SaveKeyValues.getValue(LocaleConstant.USER_COMPANY_ID, "") as String + /** + * 后台设计如此,都传companyId + * */ + return createApi().getMarkerFile(companyId, companyId) } /** * 获取巡检工单 */ - suspend fun getTasksByUser(userName: String): String { + suspend fun getTasksByUser(): String { + val userName = SaveKeyValues.getValue(LocaleConstant.USER_NAME, "") as String return createApi().getTasksByUser(userName) } /** * 提交工单 */ - suspend fun uploadTask(userId: String, taskId: String?, state: String): String { + suspend fun uploadTask(taskId: String?, state: String): String { + val userId = SaveKeyValues.getValue(LocaleConstant.USER_ID, "") as String return createApi().uploadTask(userId, taskId.toString(), state) } @@ -60,8 +66,7 @@ * 安装新标识器 * Multipart上传图片,文件,带多参数上传 */ - suspend fun installLabel( - companyId: String, + suspend fun installMarker( recordType: String, markerObjectType: String, pipeMaterial: String, @@ -77,7 +82,6 @@ road: String, constructTime: String, ownerComp: String, - markerObjectId: String, markerId: String, markerType: String, markerDepth: String, @@ -89,6 +93,8 @@ memo: String, realPaths: ArrayList ): String { + val companyId = SaveKeyValues.getValue(LocaleConstant.USER_COMPANY_ID, "") as String + val objectId = SaveKeyValues.getValue(LocaleConstant.OBJECT_ID, "") as String val param = JsonObject() param.addProperty("companyId", companyId) param.addProperty("recordType", recordType) @@ -106,7 +112,7 @@ param.addProperty("road", road) param.addProperty("constructTime", constructTime) param.addProperty("ownerComp", ownerComp) - param.addProperty("markerObjectId", markerObjectId) + param.addProperty("markerObjectId", objectId) param.addProperty("markerId", markerId) param.addProperty("markerType", markerType) param.addProperty("markerDepth", markerDepth) @@ -133,19 +139,19 @@ return when (multiParts.size) { 3 -> { - createApi().installLabel(res, multiParts[0], multiParts[1], multiParts[2]) + createApi().install(res, multiParts[0], multiParts[1], multiParts[2]) } 2 -> { - createApi().installLabel(res, multiParts[0], multiParts[1], null) + createApi().install(res, multiParts[0], multiParts[1], null) } 1 -> { - createApi().installLabel(res, multiParts[0], null, null) + createApi().install(res, multiParts[0], null, null) } else -> { - createApi().installLabel(res, null, null, null) + createApi().install(res, null, null, null) } } } @@ -216,7 +222,7 @@ /** * 上传自由巡检过程中发现的标识器 */ - suspend fun uploadTaskMarker(taskId: String, ids: ArrayList): String { + suspend fun uploadTaskMarker(taskId: Long, ids: ArrayList): String { val param = JsonObject() param.addProperty("taskId", taskId) param.addProperty("ids", ids.joinToString(separator = ",")) diff --git a/app/src/main/java/com/casic/common/detector/gd/service/NtripConnectService.kt b/app/src/main/java/com/casic/common/detector/gd/service/NtripConnectService.kt index de9ac80..20e1a6a 100644 --- a/app/src/main/java/com/casic/common/detector/gd/service/NtripConnectService.kt +++ b/app/src/main/java/com/casic/common/detector/gd/service/NtripConnectService.kt @@ -9,10 +9,6 @@ import android.util.Log import android.view.Gravity import android.widget.Toast -import androidx.lifecycle.Lifecycle -import androidx.lifecycle.LifecycleOwner -import androidx.lifecycle.LifecycleRegistry -import androidx.lifecycle.lifecycleScope import com.casic.common.detector.gd.base.BaseApplication import com.casic.common.detector.gd.extensions.convertToGPGGA import com.casic.common.detector.gd.utils.LocaleConstant @@ -23,26 +19,24 @@ import com.pengxh.kt.lite.utils.WeakReferenceHandler import com.pengxh.kt.lite.utils.socket.tcp.OnTcpConnectStateListener import com.pengxh.kt.lite.utils.socket.tcp.TcpClient +import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.Job import kotlinx.coroutines.launch import java.io.OutputStream import java.nio.charset.StandardCharsets -class NtripConnectService : Service(), LifecycleOwner, OnTcpConnectStateListener, Handler.Callback { +class NtripConnectService : Service(), OnTcpConnectStateListener, Handler.Callback { companion object { var weakReferenceHandler: WeakReferenceHandler? = null } private val kTag = "NtripConnectService" - private val registry = LifecycleRegistry(this) private val socketClient by lazy { TcpClient(this) } private var outStream: OutputStream? = null - - override fun getLifecycle(): Lifecycle { - return registry - } + private val serviceScope = CoroutineScope(Dispatchers.Main + Job()) // 创建一个独立的CoroutineScope override fun onBind(intent: Intent?): IBinder? { return null @@ -117,7 +111,7 @@ * */ val result = String(this, StandardCharsets.UTF_8) if (result.contains("ICY 200 OK")) { - lifecycleScope.launch(Dispatchers.Main) { + serviceScope.launch { "高精度定位服务连接成功".show(this@NtripConnectService) } //连接服务即打开串口 @@ -135,12 +129,12 @@ * Content-Type: text/plain * Connection: clos * */ - lifecycleScope.launch(Dispatchers.Main) { + serviceScope.launch { "差分定位服务鉴权失败,无法解析位置".show(this@NtripConnectService) } } else { //居中显示 - lifecycleScope.launch(Dispatchers.Main) { + serviceScope.launch { val toast = Toast.makeText( this@NtripConnectService, "收到千寻数据,长度:${size}", Toast.LENGTH_SHORT ) @@ -167,7 +161,7 @@ return } - lifecycleScope.launch(Dispatchers.IO) { + serviceScope.launch(Dispatchers.IO) { socketClient.start(remoteHost, remotePort.toInt()) } } diff --git a/app/src/main/java/com/casic/common/detector/gd/utils/DataBaseManager.kt b/app/src/main/java/com/casic/common/detector/gd/utils/DataBaseManager.kt deleted file mode 100644 index aa22759..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/utils/DataBaseManager.kt +++ /dev/null @@ -1,200 +0,0 @@ -package com.casic.common.detector.gd.utils - -import com.casic.common.detector.gd.base.BaseApplication -import com.casic.common.detector.gd.bean.MarkerLocalBean -import com.casic.common.detector.gd.bean.TaskLocalBean -import com.casic.common.detector.gd.bean.TaskMarkerLocalBean -import com.casic.common.detector.gd.greendao.MarkerLocalBeanDao -import com.casic.common.detector.gd.greendao.TaskLocalBeanDao -import com.casic.common.detector.gd.greendao.TaskMarkerLocalBeanDao -import com.casic.common.detector.gd.model.TaskDetailLocalModel -import com.casic.common.detector.gd.model.TaskModel - -class DataBaseManager private constructor() { - companion object { - //Kotlin委托模式双重锁单例 - val get by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) { - DataBaseManager() - } - } - - private var taskLocalBeanDao = BaseApplication.get().getDaoSession().taskLocalBeanDao - private var taskMarkerLocalBeanDao = - BaseApplication.get().getDaoSession().taskMarkerLocalBeanDao - - fun saveTaskInLocale(task: TaskModel.MessageModel) { - val bean = TaskLocalBean() - bean.id = task.id.toLong() - bean.taskCode = task.taskCode - bean.description = task.description - bean.createTime = task.deployDate - bean.status = task.status - bean.createUserName = task.creatorName - if (task.beginDate == null) { - bean.startTime = "" - } - if (task.endDate == null) { - bean.endTime = "" - } - bean.isFreeTask = "0" - if (!bean.isExist()) { - taskLocalBeanDao.insert(bean) - } - } - - fun saveTaskInLocale(bean: TaskLocalBean) { - if (!bean.isExist()) { - taskLocalBeanDao.insert(bean) - } - } - - private fun TaskLocalBean.isExist(): Boolean { - val result = taskLocalBeanDao.queryBuilder().where( - TaskLocalBeanDao.Properties.Id.eq(this.id) - ).list() - return !result.isNullOrEmpty() - } - - fun saveTaskMarkerInLocale( - taskId: Int, taskCode: String, marker: TaskModel.MessageModel.TaskDetailInfosModel - ) { - val bean = TaskMarkerLocalBean() - bean.id = marker.id.toLong() - bean.taskId = taskId.toString() - bean.taskCode = taskCode - bean.markerId = marker.markerIdReal - bean.lng = marker.longitude - bean.lat = marker.latitude - bean.isDetected = "0" - bean.detectedTime = "" - if (!bean.isExist()) { - taskMarkerLocalBeanDao.insert(bean) - } - } - - private fun TaskMarkerLocalBean.isExist(): Boolean { - val result = taskMarkerLocalBeanDao.queryBuilder().where( - TaskMarkerLocalBeanDao.Properties.Id.eq(this.id) - ).list() - return !result.isNullOrEmpty() - } - - fun loadLocalTask(): ArrayList { - val result = ArrayList() - - val tasks = taskLocalBeanDao.loadAll() - tasks.forEach { - val model = TaskDetailLocalModel() - model.taskId = it.id.toString() - model.taskCode = it.taskCode - model.description = it.description - model.createTime = it.createTime - model.status = it.status - model.createUserName = it.createUserName - model.isFreeTask = it.isFreeTask - - val markers = ArrayList() - if (it.isFreeTask == "0") { - //非自由巡检才有Marker - val markerLocalBeans = taskMarkerLocalBeanDao.queryBuilder().where( - TaskMarkerLocalBeanDao.Properties.TaskId.eq(it.id), - TaskMarkerLocalBeanDao.Properties.TaskCode.eq(it.taskCode) - ).list() - markerLocalBeans.forEach { marker -> - val localModel = TaskDetailLocalModel.TaskMarkerLocalModel() - localModel.markerId = marker.markerId - localModel.lng = marker.lng - localModel.lat = marker.lat - localModel.isDetected = marker.isDetected - localModel.detectedTime = marker.detectedTime - - markers.add(localModel) - } - } - model.markerModels = markers - result.add(model) - } - return result - } - - fun deleteLocalTaskById(taskId: String, taskCode: String) { - val task = taskLocalBeanDao.queryBuilder().where( - TaskLocalBeanDao.Properties.Id.eq(taskId), - TaskLocalBeanDao.Properties.TaskCode.eq(taskCode) - ).list().firstOrNull() ?: return - taskLocalBeanDao.delete(task) - - //删除此任务关联的Marker。非自由巡检才有Marker - if (task.isFreeTask == "0") { - val markers = taskMarkerLocalBeanDao.queryBuilder() - .where( - TaskMarkerLocalBeanDao.Properties.TaskId.eq(taskId), - TaskMarkerLocalBeanDao.Properties.TaskCode.eq(taskCode) - ).list() - markers.forEach { - taskMarkerLocalBeanDao.delete(it) - } - } - } - - fun queryTaskMarkerById( - taskId: String, taskCode: String, markerId: String, state: String - ): TaskMarkerLocalBean? { - return taskMarkerLocalBeanDao.queryBuilder() - .where( - TaskMarkerLocalBeanDao.Properties.TaskId.eq(taskId), - TaskMarkerLocalBeanDao.Properties.TaskCode.eq(taskCode), - TaskMarkerLocalBeanDao.Properties.MarkerId.eq(markerId), - TaskMarkerLocalBeanDao.Properties.IsDetected.eq(state) - ).list().firstOrNull() - } - - fun updateLocalTaskMarkerState(marker: TaskMarkerLocalBean) { - marker.isDetected = "1" - taskMarkerLocalBeanDao.update(marker) - } - - fun queryMarkerByState(state: String): List { - return taskMarkerLocalBeanDao.queryBuilder() - .where(TaskMarkerLocalBeanDao.Properties.IsDetected.eq(state)) - .list() - } - - private var markerLocalBeanDao = BaseApplication.get().getDaoSession().markerLocalBeanDao - - fun clearMarkers() { - markerLocalBeanDao.deleteAll() - } - - fun saveMarkerInLocale(bean: MarkerLocalBean) { - markerLocalBeanDao.insert(bean) - } - - fun loadMarkers(): MutableList { - return markerLocalBeanDao.loadAll() - } - - fun loadMarkersByCondition(selectedItem: String, value: String?): MutableList { - val property = when (selectedItem) { - LocaleConstant.SPINNER_ARRAY[0] -> MarkerLocalBeanDao.Properties.MarkerId - LocaleConstant.SPINNER_ARRAY[1] -> MarkerLocalBeanDao.Properties.Area - LocaleConstant.SPINNER_ARRAY[2] -> MarkerLocalBeanDao.Properties.Line - LocaleConstant.SPINNER_ARRAY[3] -> MarkerLocalBeanDao.Properties.Road - LocaleConstant.SPINNER_ARRAY[4] -> MarkerLocalBeanDao.Properties.Owner - LocaleConstant.SPINNER_ARRAY[5] -> MarkerLocalBeanDao.Properties.InstallationDept - LocaleConstant.SPINNER_ARRAY[6] -> MarkerLocalBeanDao.Properties.UpdateTime - else -> MarkerLocalBeanDao.Properties.Remark - } - return if (value == null) { - markerLocalBeanDao.queryBuilder().where(property.isNotNull).list() - } else { - markerLocalBeanDao.queryBuilder().where(property.eq(value)).list() - } - } - - fun queryMarkerById(markerId: String): List { - return markerLocalBeanDao.queryBuilder() - .where(MarkerLocalBeanDao.Properties.MarkerId.eq(markerId)) - .list() - } -} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/utils/DetectorDataBase.java b/app/src/main/java/com/casic/common/detector/gd/utils/DetectorDataBase.java new file mode 100644 index 0000000..f686cac --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/utils/DetectorDataBase.java @@ -0,0 +1,21 @@ +package com.casic.common.detector.gd.utils; + +import androidx.room.Database; +import androidx.room.RoomDatabase; + +import com.casic.common.detector.gd.bean.MarkerBean; +import com.casic.common.detector.gd.bean.TaskBean; +import com.casic.common.detector.gd.bean.TaskMarkerBean; +import com.casic.common.detector.gd.dao.MarkerBeanDao; +import com.casic.common.detector.gd.dao.TaskBeanDao; +import com.casic.common.detector.gd.dao.TaskMarkerBeanDao; + + +@Database(entities = {MarkerBean.class, TaskBean.class, TaskMarkerBean.class}, version = 1) +public abstract class DetectorDataBase extends RoomDatabase { + public abstract MarkerBeanDao markerBeanDao(); + + public abstract TaskBeanDao taskBeanDao(); + + public abstract TaskMarkerBeanDao taskMarkerBeanDao(); +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/utils/ExcelKit.kt b/app/src/main/java/com/casic/common/detector/gd/utils/ExcelKit.kt index 200fac7..015969f 100644 --- a/app/src/main/java/com/casic/common/detector/gd/utils/ExcelKit.kt +++ b/app/src/main/java/com/casic/common/detector/gd/utils/ExcelKit.kt @@ -1,19 +1,19 @@ package com.casic.common.detector.gd.utils -import com.casic.common.detector.gd.bean.MarkerLocalBean +import com.casic.common.detector.gd.base.BaseApplication +import com.casic.common.detector.gd.bean.MarkerBean import jxl.Workbook import jxl.read.biff.BiffException import java.io.File object ExcelKit { - fun read(filePath: String): ArrayList { - val result = ArrayList() + fun read(filePath: String): ArrayList { + val result = ArrayList() try { val workbook = Workbook.getWorkbook(File(filePath)) val sheet = workbook.getSheet(0) - for (i in 1 until sheet.rows) { - val marker = MarkerLocalBean() + val marker = MarkerBean() marker.pipelineType = sheet.getCell(0, i).contents marker.pipelineDiameter = sheet.getCell(1, i).contents marker.pipelineMaterial = sheet.getCell(2, i).contents @@ -40,9 +40,10 @@ marker.objectType = sheet.getCell(23, i).contents marker.color = sheet.getCell(24, i).contents marker.imagePath = sheet.getCell(25, i).contents - - result.add(marker) - DataBaseManager.get.saveMarkerInLocale(marker) + if (!marker.markerId.isNullOrBlank()) { + result.add(marker) + BaseApplication.get().dataBase.markerBeanDao().insert(marker) + } } workbook.close() } catch (e: BiffException) { diff --git a/app/src/main/java/com/casic/common/detector/gd/utils/LocaleConstant.kt b/app/src/main/java/com/casic/common/detector/gd/utils/LocaleConstant.kt index c658924..8ac5f76 100644 --- a/app/src/main/java/com/casic/common/detector/gd/utils/LocaleConstant.kt +++ b/app/src/main/java/com/casic/common/detector/gd/utils/LocaleConstant.kt @@ -1,6 +1,8 @@ package com.casic.common.detector.gd.utils import android.Manifest +import androidx.sqlite.db.SimpleSQLiteQuery +import androidx.sqlite.db.SupportSQLiteQuery object LocaleConstant { @@ -59,4 +61,19 @@ var BURY_METHOD_ARRAY = arrayOf("直埋", "圆管", "管块", "管沟", "架空") var IDENTIFIER_TYPE_ARRAY = arrayOf("EM30", "EM50", "EM14") var COLOR_ARRAY = arrayOf("蓝色", "橙色", "红色", "黑色", "紫色", "黄色", "绿色") + + fun buildQuery(selectedItem: String, value: String): SupportSQLiteQuery { + val columnName = when (selectedItem) { + SPINNER_ARRAY[0] -> "markerId" + SPINNER_ARRAY[1] -> "area" + SPINNER_ARRAY[2] -> "line" + SPINNER_ARRAY[3] -> "road" + SPINNER_ARRAY[4] -> "owner" + SPINNER_ARRAY[5] -> "installationDept" + SPINNER_ARRAY[6] -> "updateTime" + else -> "remark" + } + val queryBuilder = StringBuilder("SELECT * FROM marker_detail WHERE $columnName = ?") + return SimpleSQLiteQuery(queryBuilder.toString(), arrayOf(value)) + } } \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/view/InstallMarkerActivity.kt b/app/src/main/java/com/casic/common/detector/gd/view/InstallMarkerActivity.kt index daf5b0f..9e09df1 100644 --- a/app/src/main/java/com/casic/common/detector/gd/view/InstallMarkerActivity.kt +++ b/app/src/main/java/com/casic/common/detector/gd/view/InstallMarkerActivity.kt @@ -14,8 +14,9 @@ import com.amap.api.location.AMapLocation import com.casic.common.detector.gd.R import com.casic.common.detector.gd.adapter.EditableImageAdapter +import com.casic.common.detector.gd.base.BaseApplication import com.casic.common.detector.gd.base.SerialPortBaseActivity -import com.casic.common.detector.gd.bean.MarkerLocalBean +import com.casic.common.detector.gd.bean.MarkerBean import com.casic.common.detector.gd.callback.OnGetLocationListener import com.casic.common.detector.gd.callback.OnImageCompressListener import com.casic.common.detector.gd.databinding.ActivityInstallMarkerBinding @@ -27,7 +28,6 @@ import com.casic.common.detector.gd.extensions.toColor import com.casic.common.detector.gd.extensions.toObjectType import com.casic.common.detector.gd.utils.CurrentSegment -import com.casic.common.detector.gd.utils.DataBaseManager import com.casic.common.detector.gd.utils.LocaleConstant import com.casic.common.detector.gd.utils.LocationKit import com.casic.common.detector.gd.utils.RuntimeCache @@ -44,7 +44,6 @@ import com.pengxh.kt.lite.extensions.timestampToCompleteDate import com.pengxh.kt.lite.extensions.timestampToTime import com.pengxh.kt.lite.extensions.toJson -import com.pengxh.kt.lite.utils.LoadState import com.pengxh.kt.lite.utils.LoadingDialog import com.pengxh.kt.lite.utils.SaveKeyValues import com.pengxh.kt.lite.widget.TitleBarView @@ -115,8 +114,6 @@ //安装 binding.installButton.setOnClickListener { - val companyId = SaveKeyValues.getValue(LocaleConstant.USER_COMPANY_ID, "") as String - val objectId = SaveKeyValues.getValue(LocaleConstant.OBJECT_ID, "") as String if (binding.objectInclude.pipeInclude.markerObjectTypeView.text.isNullOrBlank()) { when (binding.objectInclude.objectTypeSpinner.selectedItem.toString()) { "管线" -> "请输入管线种类!".show(this) @@ -189,8 +186,7 @@ //先存本地再上传服务器 saveMarkerInLocal() - taskViewModel.installLabel( - this, companyId, + taskViewModel.installMarker( binding.objectInclude.objectTypeSpinner.selectedItem.toString().toObjectType(), binding.objectInclude.pipeInclude.markerObjectTypeView.text.toString(), binding.objectInclude.pipeInclude.materialSpinner.selectedItem.toString(), @@ -206,7 +202,6 @@ binding.objectInclude.roadView.text.toString(), binding.objectInclude.constructDateView.text.toString(), binding.objectInclude.ownerView.text.toString(), - objectId, binding.identifierInclude.identifierIdView.text.toString(), binding.identifierInclude.identifierTypeSpinner.selectedItem.toString(), "${binding.identifierInclude.identifierDeepView.text}mm", @@ -216,7 +211,19 @@ binding.identifierInclude.latView.text.toString(), binding.identifierInclude.colorSpinner.selectedItem.toString().toColor(), binding.remarkView.text.toString(), - realPaths + realPaths, + onLoading = { + LoadingDialog.show(this, "标识器安装中,请稍后...") + }, + onSuccess = { + LoadingDialog.dismiss() + clearDefaultData() + "安装成功".show(this) + }, + onFailed = { + LoadingDialog.dismiss() + it.show(this) + } ) //保存默认值 @@ -268,7 +275,7 @@ private fun saveMarkerInLocal() { val objectId = SaveKeyValues.getValue(LocaleConstant.OBJECT_ID, "") as String - val marker = MarkerLocalBean() + val marker = MarkerBean() marker.objectType = binding.objectInclude.objectTypeSpinner.selectedItem.toString() marker.pipelineType = binding.objectInclude.pipeInclude.markerObjectTypeView.text.toString() marker.pipelineMaterial = @@ -302,7 +309,7 @@ marker.remark = binding.remarkView.text.toString() marker.imagePath = realPaths.toJson() - DataBaseManager.get.saveMarkerInLocale(marker) + BaseApplication.get().dataBase.markerBeanDao().insert(marker) } private fun takePicture() { @@ -339,8 +346,8 @@ override fun initOnCreate(savedInstanceState: Bundle?) { locationKit.getCurrentLocation(true, object : OnGetLocationListener { override fun onSuccess(location: AMapLocation) { - binding.identifierInclude.lngView.text = location.longitude.toString() - binding.identifierInclude.latView.text = location.latitude.toString() + binding.identifierInclude.lngView.text = "${location.longitude}" + binding.identifierInclude.latView.text = "${location.latitude}" } override fun onError() { @@ -357,22 +364,6 @@ return ActivityInstallMarkerBinding.inflate(layoutInflater) } - override fun observeRequestState() { - taskViewModel.loadState.observe(this) { - when (it) { - LoadState.Loading -> LoadingDialog.show(this, "标识器安装中,请稍后...") - - LoadState.Success -> { - LoadingDialog.dismiss() - clearDefaultData() - "安装成功".show(this) - } - - else -> LoadingDialog.dismiss() - } - } - } - override fun setupTopBarLayout() { binding.rootView.initImmersionBar(this, true, R.color.white) binding.titleView.setOnClickListener(object : TitleBarView.OnClickListener { diff --git a/app/src/main/java/com/casic/common/detector/gd/view/MainActivity.kt b/app/src/main/java/com/casic/common/detector/gd/view/MainActivity.kt index fb0b260..a6352fb 100644 --- a/app/src/main/java/com/casic/common/detector/gd/view/MainActivity.kt +++ b/app/src/main/java/com/casic/common/detector/gd/view/MainActivity.kt @@ -5,7 +5,6 @@ import android.graphics.Color import android.media.AudioAttributes import android.media.SoundPool -import android.os.Build import android.os.Bundle import android.os.CountDownTimer import android.os.Handler @@ -31,19 +30,17 @@ import com.casic.common.detector.gd.R import com.casic.common.detector.gd.base.BaseApplication import com.casic.common.detector.gd.base.SerialPortBaseActivity -import com.casic.common.detector.gd.bean.MarkerLocalBean -import com.casic.common.detector.gd.bean.TaskLocalBean +import com.casic.common.detector.gd.bean.MarkerBean import com.casic.common.detector.gd.callback.OnGetAddressListener import com.casic.common.detector.gd.callback.OnGetLocationListener import com.casic.common.detector.gd.databinding.ActivityMainBinding import com.casic.common.detector.gd.extensions.appendDownloadUrl -import com.casic.common.detector.gd.extensions.createTaskCode import com.casic.common.detector.gd.extensions.initImmersionBar +import com.casic.common.detector.gd.model.MarkerFileModel import com.casic.common.detector.gd.model.TaskDetailLocalModel import com.casic.common.detector.gd.model.TaskModel import com.casic.common.detector.gd.service.NtripConnectService import com.casic.common.detector.gd.utils.CurrentSegment -import com.casic.common.detector.gd.utils.DataBaseManager import com.casic.common.detector.gd.utils.ExcelKit import com.casic.common.detector.gd.utils.FileType import com.casic.common.detector.gd.utils.LocaleConstant @@ -62,9 +59,7 @@ import com.pengxh.kt.lite.extensions.isNetworkConnected import com.pengxh.kt.lite.extensions.navigatePageTo import com.pengxh.kt.lite.extensions.show -import com.pengxh.kt.lite.extensions.timestampToCompleteDate import com.pengxh.kt.lite.utils.FileDownloadManager -import com.pengxh.kt.lite.utils.LoadState import com.pengxh.kt.lite.utils.LoadingDialog import com.pengxh.kt.lite.utils.SaveKeyValues import com.pengxh.kt.lite.widget.TitleBarView @@ -86,6 +81,9 @@ private val samplePopupWindow by lazy { SamplePopupWindow(this) } private val detailDialog by lazy { MarkerDetailDialog(this) } private val locationKit by lazy { LocationKit(this) } + private val markerBeanDao by lazy { BaseApplication.get().dataBase.markerBeanDao() } + private val taskBeanDao by lazy { BaseApplication.get().dataBase.taskBeanDao() } + private val taskMarkerBeanDao by lazy { BaseApplication.get().dataBase.taskMarkerBeanDao() } private val taskViewModel by lazy { ViewModelProvider(this)[TaskViewModel::class.java] } private val attr = AudioAttributes.Builder().setUsage(AudioAttributes.USAGE_ALARM) .setContentType(AudioAttributes.CONTENT_TYPE_MUSIC).build() @@ -94,7 +92,7 @@ private var isFreeTask = false private var freeTaskTitle = "" private var ids = ArrayList() - private var freeTaskId: String? = null + private var freeTaskId = 0L private var soundResourceId = 0 private var isExecuteTask = false private lateinit var aMap: AMap @@ -111,89 +109,14 @@ //地图初始化 initMapConfig(savedInstanceState) - Intent(this, NtripConnectService::class.java).also { - startService(it) - } +// Intent(this, NtripConnectService::class.java).apply { +// startService(this) +// } soundResourceId = soundPool.load(this, R.raw.ring3, 1) //右上角菜单 samplePopupWindow.setPopupMenuItem(LocaleConstant.POPUP_TITLES) samplePopupWindow.setBackgroundDrawable(null) - - //task网络请求监听 - taskViewModel.markerFileResult.observe(this) { - if (it.isSuccess) { - //清空之前的数据 - DataBaseManager.get.clearMarkers() - //下载最新的数据 - val companyId = SaveKeyValues.getValue(LocaleConstant.USER_COMPANY_ID, "") - val downloadUrl = companyId.toString().appendDownloadUrl(FileType.Excel) - Log.d(kTag, "downloadUrl => $downloadUrl") - FileDownloadManager.Builder().setDownloadFileSource(downloadUrl) - .setFileSuffix("xls").setFileSaveDirectory(createDownloadFileDir()) - .setOnFileDownloadListener(object : FileDownloadManager.OnFileDownloadListener { - override fun onDownloadStart(total: Long) { - - } - - override fun onDownloadEnd(file: File) { - lifecycleScope.launch(Dispatchers.IO) { ExcelKit.read(file.absolutePath) } - LoadingDialog.dismiss() - showMarkersOnMap() - } - - override fun onDownloadFailed(t: Throwable) { - t.printStackTrace() - } - - override fun onProgressChanged(progress: Long) { - - } - }).build().start() - } - } - taskViewModel.taskResult.observe(this) { - if (it.success == "true") { - AlertMessageDialog.Builder().setContext(this).setTitle("温馨提示") - .setMessage("您有${it.message.size}个新任务!").setPositiveButton("知道了") - .setOnDialogButtonClickListener(object : - AlertMessageDialog.OnDialogButtonClickListener { - override fun onConfirmClick() { - saveUserTasks(it) - } - }).build().show() - } - } - taskViewModel.freeTaskResult.observe(this) { - freeTaskId = it - // 自由巡检保存在本地 - val bean = TaskLocalBean() - bean.id = freeTaskId.toString().toLong() - val currentTimeMillis = System.currentTimeMillis() - bean.taskCode = currentTimeMillis.createTaskCode() - bean.description = freeTaskTitle - val time = currentTimeMillis.timestampToCompleteDate() - bean.createTime = time - bean.status = "0" - val userName = SaveKeyValues.getValue(LocaleConstant.USER_NAME, "") as String - bean.createUserName = userName - bean.startTime = time - bean.endTime = "" - bean.isFreeTask = "1" - DataBaseManager.get.saveTaskInLocale(bean) - } - taskViewModel.uploadTaskMarkerResult.observe(this) { - "自由巡检任务已完成".show(this) - ids.clear() - //清空自由巡检添加的Marker - aMap.clear() - showMarkersOnMap() - } - taskViewModel.executeTaskResult.observe(this) { - "工单任务已完成".show(this) - aMap.clear() - showMarkersOnMap() - } } override fun initEvent() { @@ -216,7 +139,7 @@ }).build().show() } else { lifecycleScope.launch(Dispatchers.Main) { - val markers = DataBaseManager.get.queryMarkerByState("0") + val markers = taskMarkerBeanDao.queryMarkerByState("0") //如果有需要补全的标识器,Popup右侧会有小圆点提示 if (markers.isNotEmpty()) { samplePopupWindow.setShowPosition(4) @@ -239,13 +162,7 @@ 3 -> uploadEvent() 4 -> completionMarker() 5 -> showRtkConfigDialog() - 6 -> { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { - SatelliteStatusDialog(context).show() - } else { - "卫星数据仅支持Android 7.0以上系统".show(context) - } - } + 6 -> SatelliteStatusDialog(context).show() } } }) @@ -268,25 +185,23 @@ //查看 binding.viewButton.setOnClickListener { - QueryMarkerDialog.Builder().setContext(this).setTitle("查看标识器") - .setSpinnerArray(LocaleConstant.SPINNER_ARRAY).setNegativeButton("取消") + QueryMarkerDialog.Builder() + .setContext(this) + .setTitle("查看标识器") + .setSpinnerArray(LocaleConstant.SPINNER_ARRAY) + .setNegativeButton("取消") .setPositiveButton("确定").setOnDialogButtonClickListener(object : QueryMarkerDialog.OnDialogButtonClickListener { override fun onConfirmClick(selectedItem: String, value: String) { //查询数据库 - lifecycleScope.launch(Dispatchers.Main) { - val markers = DataBaseManager.get.loadMarkersByCondition( - selectedItem, value - ) as ArrayList - - if (markers.isEmpty()) { - "无法查到相关数据信息,请检查您的查询条件".show(context) - } else { + val buildQuery = LocaleConstant.buildQuery(selectedItem, value) + markerBeanDao.loadMarkersByCondition(buildQuery).run { + if (isNotEmpty()) { val latitudeList = ArrayList() val longitudeList = ArrayList() - val latitude = markers.first().lat - val longitude = markers.first().lng + val latitude = first().lat + val longitude = first().lng if (latitude.isNotBlank() && longitude.isNotBlank()) { if (CoordinateConverter.isAMapDataAvailable( latitude.toDouble(), longitude.toDouble() @@ -300,10 +215,11 @@ if (latitudeList.isNotEmpty() && longitudeList.isNotEmpty()) { //移动地图到所有labelBeans的第一个点 - val center = LatLng(latitudeList.first(), longitudeList.first()) - //移动到指定经纬度 - aMap.moveCamera(CameraUpdateFactory.newLatLngZoom(center, 16f)) + val target = LatLng(latitudeList.first(), longitudeList.first()) + aMap.moveCamera(CameraUpdateFactory.newLatLngZoom(target, 16f)) } + } else { + "无法查到相关信息,请检查您的查询条件".show(context) } } } @@ -316,32 +232,39 @@ //巡检 binding.inspectionButton.setOnClickListener { - val tasks = DataBaseManager.get.loadLocalTask() - if (tasks.isNotEmpty()) { - val arrayList = ArrayList() - tasks.forEachIndexed { index, task -> - arrayList.add("任务${index + 1}:${task.taskId},${task.description}") + lifecycleScope.launch { + val tasks = withContext(Dispatchers.IO) { + taskBeanDao.loadLocalTask(taskMarkerBeanDao) } + if (tasks.isNotEmpty()) { + val arrayList = ArrayList() + tasks.forEachIndexed { index, task -> + arrayList.add("任务${index + 1}:${task.taskId},${task.description}") + } - BottomActionSheet.Builder().setContext(this).setItemTextColor(Color.BLUE) - .setActionItemTitle(arrayList) - .setOnActionSheetListener(object : BottomActionSheet.OnActionSheetListener { - override fun onActionItemClick(position: Int) { - val task = tasks[position] - SaveKeyValues.putValue(LocaleConstant.TASK_ID, task.taskId) - SaveKeyValues.putValue(LocaleConstant.TASK_CODE, task.taskCode) - executeTask(task) - } - }).build().show() - } else { - AlertMessageDialog.Builder().setContext(this).setTitle("温馨提示") - .setMessage("所有任务已完成,请点击右上角菜单下载新工单或者开始自由巡检") - .setPositiveButton("开始自由巡检").setOnDialogButtonClickListener(object : - AlertMessageDialog.OnDialogButtonClickListener { - override fun onConfirmClick() { - executeFreeTask() - } - }).build().show() + BottomActionSheet.Builder().setContext(context) + .setItemTextColor(Color.BLUE) + .setActionItemTitle(arrayList) + .setOnActionSheetListener(object : BottomActionSheet.OnActionSheetListener { + override fun onActionItemClick(position: Int) { + val task = tasks[position] + SaveKeyValues.putValue(LocaleConstant.TASK_ID, task.taskId) + SaveKeyValues.putValue(LocaleConstant.TASK_CODE, task.taskCode) + executeTask(task) + } + }).build().show() + } else { + AlertMessageDialog.Builder() + .setContext(context) + .setTitle("温馨提示") + .setMessage("所有任务已完成,请点击右上角菜单下载新工单或者开始自由巡检") + .setPositiveButton("开始自由巡检").setOnDialogButtonClickListener(object : + AlertMessageDialog.OnDialogButtonClickListener { + override fun onConfirmClick() { + executeFreeTask() + } + }).build().show() + } } } @@ -371,8 +294,11 @@ //自由巡检 binding.stopFreeTaskButton.setOnLongClickListener { - AlertMessageDialog.Builder().setContext(this).setTitle("温馨提示") - .setMessage("是否确定结束此次自由巡检任务?").setPositiveButton("是") + AlertMessageDialog.Builder() + .setContext(this) + .setTitle("温馨提示") + .setMessage("是否确定结束此次自由巡检任务?") + .setPositiveButton("是") .setOnDialogButtonClickListener(object : AlertMessageDialog.OnDialogButtonClickListener { override fun onConfirmClick() { @@ -381,14 +307,38 @@ stopSerialPortCommand() binding.stopFreeTaskButton.visibility = View.GONE - if (freeTaskId.isNullOrBlank()) { + if (freeTaskId == 0L) { "任务ID异常,无法提交任务,请联系服务器管理员".show(context) return } - freeTaskId?.apply { - taskViewModel.uploadTaskMarker(context, this, ids) - } + taskViewModel.uploadTaskMarker( + freeTaskId, + ids, + onLoading = { + LoadingDialog.show(context, "任务提交中,请稍后...") + }, + onSuccess = { + LoadingDialog.dismiss() + "自由巡检任务已完成".show(context) + ids.clear() + aMap.clear() + showMarkersOnMap() + + //删除本地数据库 + val taskCode = SaveKeyValues.getValue( + LocaleConstant.TASK_CODE, "" + ) as String + taskBeanDao.deleteLocalTaskById( + freeTaskId, taskCode, taskMarkerBeanDao + ) + SaveKeyValues.putValue(LocaleConstant.TASK_ID, "") + }, + onFailed = { + LoadingDialog.dismiss() + it.show(context) + } + ) } }).build().show() true @@ -399,25 +349,52 @@ RtkConfigDialog(this).setOnDialogButtonClickListener(object : RtkConfigDialog.OnDialogButtonClickListener { override fun onConfirmClick() { - NtripConnectService.weakReferenceHandler?.apply { - sendEmptyMessage(2024082201) - } + NtripConnectService.weakReferenceHandler?.sendEmptyMessage(2024082201) } }).show() } private fun uploadTask(taskId: String, taskCode: String, state: String) { if (isNetworkConnected()) { - val userId = SaveKeyValues.getValue(LocaleConstant.USER_ID, "") as String - taskViewModel.uploadTask(this, userId, taskId, taskCode, state) + taskViewModel.uploadTask( + taskId, state, + onLoading = { + LoadingDialog.show(this, "工单提交中,请稍后...") + }, + onSuccess = { + LoadingDialog.dismiss() + //工单提交之后,并且状态是2,删除本地Task记录 + if (state == "2") { + "工单${taskId}已提交!".show(this) + //删除本地数据库 + taskBeanDao.deleteLocalTaskById( + taskId.toLong(), taskCode, taskMarkerBeanDao + ) + SaveKeyValues.putValue(LocaleConstant.TASK_ID, "") + } else { + Log.d(kTag, "uploadTask: 仅执行工单,不删除本地工单数据") + } + aMap.clear() + showMarkersOnMap() + "工单任务已完成".show(this) + }, + onFailed = { + LoadingDialog.dismiss() + it.show(this) + } + ) } else { "网络连接已断开,请检查".show(this) } } private fun executeTask(task: TaskDetailLocalModel) { - AlertControlDialog.Builder().setContext(this).setTitle("提示").setMessage("请选择操作方式") - .setPositiveButton("执行工单").setNegativeButton("提交工单") + AlertControlDialog.Builder() + .setContext(this) + .setTitle("提示") + .setMessage("请选择操作方式") + .setPositiveButton("执行工单") + .setNegativeButton("提交工单") .setOnDialogButtonClickListener(object : AlertControlDialog.OnDialogButtonClickListener { override fun onConfirmClick() { @@ -432,7 +409,7 @@ isExecuteTask = true } else { "此工单下无标识器,将执行自由巡检任务".show(context) - freeTaskId = task.taskId + freeTaskId = task.taskId.toLong() detectMarker() } } @@ -453,7 +430,18 @@ override fun onConfirmClick(value: String) { freeTaskTitle = value val userId = SaveKeyValues.getValue(LocaleConstant.USER_ID, "") as String - taskViewModel.createFreeTask(context, userId, value) + taskViewModel.createFreeTask( + userId, value, + onLoading = {}, + onSuccess = { + freeTaskId = it + // 自由巡检保存在本地 + taskBeanDao.saveTask(it, freeTaskTitle) + }, + onFailed = { + it.show(context) + } + ) detectMarker() } @@ -481,7 +469,7 @@ if (RuntimeCache.currentSegment == CurrentSegment.FreeInspection) { //显示标识器详细信息 if (!detailDialog.isShowing) { - DataBaseManager.get.queryMarkerById(markerId).firstOrNull().apply { + markerBeanDao.queryMarkerById(markerId).firstOrNull().apply { if (this == null) { "无法查询到此ID【${markerId}】的信息".show(context) } else { @@ -501,7 +489,7 @@ //不重复标注Marker if (!ids.contains(markerId)) { - val markers = DataBaseManager.get.queryMarkerById(markerId) + val markers = markerBeanDao.queryMarkerById(markerId) if (markers.isNotEmpty()) { val marker = markers.first() val latLng = LatLng(marker.lat.toDouble(), marker.lng.toDouble()) @@ -522,16 +510,6 @@ } - override fun observeRequestState() { - taskViewModel.loadState.observe(this) { - when (it) { - LoadState.Loading -> LoadingDialog.show(this, "提交工单中,请稍后") - - else -> LoadingDialog.dismiss() - } - } - } - private fun initMapConfig(savedInstanceState: Bundle?) { binding.mapView.onCreate(savedInstanceState) aMap = binding.mapView.map @@ -592,54 +570,25 @@ private fun saveUserTasks(task: TaskModel) { task.message.forEach { model -> //保存任务详情 - DataBaseManager.get.saveTaskInLocale(model) + taskBeanDao.saveTask(model) model.taskDetailInfos.forEach { marker -> //只保存有标识器ID得数据 if (!marker.markerIdReal.isNullOrBlank()) { - DataBaseManager.get.saveTaskMarkerInLocale(model.id, model.taskCode, marker) + taskMarkerBeanDao.saveTaskMarker(model.id, model.taskCode, marker) } } } "工单下载成功!".show(this) } - private fun showMarkersOnMap() { - lifecycleScope.launch(Dispatchers.IO) { - //取缓存 - val markers = DataBaseManager.get.loadMarkers() - if (markers.isEmpty()) { - return@launch - } - val first = markers.first() - val defaultLatLng = LatLng(first.lat.toDouble(), first.lng.toDouble()) - //移动到指定经纬度 - val cameraPosition = CameraPosition(defaultLatLng, 14f, 0f, 0f) - val cameraUpdate = CameraUpdateFactory.newCameraPosition(cameraPosition) - withContext(Dispatchers.Main) { - aMap.animateCamera(cameraUpdate, 1500, null) - LoadingDialog.dismiss() - } - - markers.forEach { marker -> - val latitude = marker.lat.toString().toDouble() - val longitude = marker.lng.toString().toDouble() - //将所有设备信息转化缓存为Marker点 - val options = MarkerOptions() - .position(LatLng(latitude, longitude)) - .title(marker.markerId) - aMap.addMarker(options) - } - } - } - override fun onMarkerClick(marker: Marker?): Boolean { - marker?.apply { - showNavigationOption(title, position) + marker?.let { + showNavigationOption(it.title, it.position) } return true } - override fun onMapLongClick(p0: LatLng?) { + override fun onMapLongClick(latLng: LatLng?) { showMarkersOnMap() } @@ -664,7 +613,7 @@ } override fun onCancelClick() { - val result = DataBaseManager.get.queryMarkerById(title) + val result = markerBeanDao.queryMarkerById(title) MarkerDetailDialog(context).setMarker(result.first()).show() } }).build().show() @@ -695,20 +644,24 @@ //更新标识器数据 private fun updateMarkers() { - AlertControlDialog.Builder().setContext(this).setTitle("提示").setMessage("是否更新数据?") - .setNegativeButton("取消").setPositiveButton("确定") + AlertControlDialog.Builder() + .setContext(this) + .setTitle("提示") + .setMessage("是否更新数据?") + .setNegativeButton("取消") + .setPositiveButton("确定") .setOnDialogButtonClickListener(object : AlertControlDialog.OnDialogButtonClickListener { override fun onConfirmClick() { if (isNetworkConnected()) { - val companyId = SaveKeyValues.getValue(LocaleConstant.USER_COMPANY_ID, "") - - LoadingDialog.show(this@MainActivity, "获取标识器信息中,请稍后") - /** - * 后台设计如此,都传companyId - * */ + //清空之前的数据 + markerBeanDao.deleteAll() + aMap.clear() + //获取标识器数据 taskViewModel.getMarkerFile( - context, companyId.toString(), companyId.toString() + onLoading = {}, + onSuccess = { handleMarkerFile(it) }, + onFailed = { it.show(context) } ) } else { "网络连接已断开,请检查".show(context) @@ -721,11 +674,105 @@ }).build().show() } + private fun handleMarkerFile(it: MarkerFileModel) { + if (it.isSuccess) { + //下载最新的数据 + val companyId = SaveKeyValues.getValue(LocaleConstant.USER_COMPANY_ID, "") + val downloadUrl = companyId.toString().appendDownloadUrl(FileType.Excel) + Log.d(kTag, "handleMarkerFile => $downloadUrl") + FileDownloadManager.Builder() + .setDownloadFileSource(downloadUrl) + .setFileSuffix("xls") + .setFileSaveDirectory(createDownloadFileDir()) + .setOnFileDownloadListener(object : FileDownloadManager.OnFileDownloadListener { + override fun onDownloadStart(total: Long) { + LoadingDialog.show(context, "标识器数据解析中,请稍后...") + } + + override fun onDownloadEnd(file: File) { + lifecycleScope.launch(Dispatchers.IO) { + ExcelKit.read(file.absolutePath).apply { + renderMarkers(this) + }.also { + withContext(Dispatchers.Main) { + LoadingDialog.dismiss() + "标识器数据渲染完成".show(context) + } + } + } + } + + override fun onDownloadFailed(t: Throwable) { + t.printStackTrace() + LoadingDialog.dismiss() + "标识器数据下载失败".show(context) + } + + override fun onProgressChanged(progress: Long) { + + } + }).build().start() + } + } + + private fun showMarkersOnMap() { + lifecycleScope.launch(Dispatchers.IO) { + //取缓存 + markerBeanDao.loadAll().run { + renderMarkers(this) + }.also { + withContext(Dispatchers.Main) { + "标识器数据渲染完成".show(context) + } + } + } + } + + private fun renderMarkers(markers: List) { + if (markers.isEmpty()) { + return + } + val first = markers.first() + val defaultLatLng = LatLng(first.lat.toDouble(), first.lng.toDouble()) + //移动到指定经纬度 + val cameraPosition = CameraPosition(defaultLatLng, 14f, 0f, 0f) + val cameraUpdate = CameraUpdateFactory.newCameraPosition(cameraPosition) + aMap.animateCamera(cameraUpdate, 1500, null) + markers.forEach { marker -> + val latitude = marker.lat.toString().toDouble() + val longitude = marker.lng.toString().toDouble() + //将所有设备信息转化缓存为Marker点 + val options = MarkerOptions() + .position(LatLng(latitude, longitude)) + .title(marker.markerId) + aMap.addMarker(options) + } + } + //下载工单 private fun downloadTask() { if (isNetworkConnected()) { - val userName = SaveKeyValues.getValue(LocaleConstant.USER_NAME, "") - taskViewModel.getTasksByUser(this, userName.toString()) + taskViewModel.getTasksByUser( + onLoading = {}, + onSuccess = { + if (it.success == "true") { + AlertMessageDialog.Builder() + .setContext(this) + .setTitle("温馨提示") + .setMessage("您有${it.message.size}个新任务!") + .setPositiveButton("知道了") + .setOnDialogButtonClickListener(object : + AlertMessageDialog.OnDialogButtonClickListener { + override fun onConfirmClick() { + saveUserTasks(it) + } + }).build().show() + } + }, + onFailed = { + it.show(this) + } + ) } else { "网络连接已断开,请检查".show(this) } @@ -744,7 +791,7 @@ //标识器补全 private fun completionMarker() { val companyId = SaveKeyValues.getValue(LocaleConstant.USER_COMPANY_ID, "") as String - val markers = DataBaseManager.get.queryMarkerByState("0") + val markers = taskMarkerBeanDao.queryMarkerByState("0") if (markers.isNotEmpty()) { //TODO 逻辑没梳理明白 } else { diff --git a/app/src/main/java/com/casic/common/detector/gd/view/SearchMarkerActivity.kt b/app/src/main/java/com/casic/common/detector/gd/view/SearchMarkerActivity.kt index 4a92c97..b2e3301 100644 --- a/app/src/main/java/com/casic/common/detector/gd/view/SearchMarkerActivity.kt +++ b/app/src/main/java/com/casic/common/detector/gd/view/SearchMarkerActivity.kt @@ -1,6 +1,5 @@ package com.casic.common.detector.gd.view -import android.content.Context import android.content.res.ColorStateList import android.graphics.Color import android.hardware.Sensor @@ -13,18 +12,19 @@ import android.os.Handler import android.os.Looper import android.view.View +import androidx.core.graphics.toColorInt import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.lifecycleScope import com.amap.api.location.AMapLocation import com.amap.api.maps.AMapUtils import com.amap.api.maps.model.LatLng import com.casic.common.detector.gd.R +import com.casic.common.detector.gd.base.BaseApplication import com.casic.common.detector.gd.base.SerialPortBaseActivity import com.casic.common.detector.gd.callback.OnGetLocationListener import com.casic.common.detector.gd.databinding.ActivitySearchMarkerBinding import com.casic.common.detector.gd.model.MarkerDistanceData import com.casic.common.detector.gd.utils.CurrentSegment -import com.casic.common.detector.gd.utils.DataBaseManager import com.casic.common.detector.gd.utils.LocaleConstant import com.casic.common.detector.gd.utils.LocationKit import com.casic.common.detector.gd.utils.RuntimeCache @@ -50,8 +50,10 @@ private val context = this private val locationKit by lazy { LocationKit(this) } private val markerPoints by lazy { ArrayList() } + private val markerBeanDao by lazy { BaseApplication.get().dataBase.markerBeanDao() } + private val taskMarkerBeanDao by lazy { BaseApplication.get().dataBase.taskMarkerBeanDao() } private val taskViewModel by lazy { ViewModelProvider(this)[TaskViewModel::class.java] } - private val sensorManager by lazy { getSystemService(Context.SENSOR_SERVICE) as SensorManager } + private val sensorManager by lazy { getSystemService(SENSOR_SERVICE) as SensorManager } private val attr = AudioAttributes.Builder().setUsage(AudioAttributes.USAGE_ALARM) .setContentType(AudioAttributes.CONTENT_TYPE_MUSIC).build() private val soundPool = SoundPool.Builder().setMaxStreams(16).setAudioAttributes(attr).build() @@ -109,7 +111,7 @@ override fun initEvent() { binding.depthButton.setOnClickListener { RuntimeCache.currentSegment = CurrentSegment.DetectDepth - val result = DataBaseManager.get.queryMarkerById(markerId) + val result = markerBeanDao.queryMarkerById(markerId) if (result.isNotEmpty()) { val command = when (result.first().markerType) { "EM30" -> SerialPortCommand.DETECT_EM30_DEPTH @@ -139,7 +141,7 @@ } binding.markerInfoButton.setOnClickListener { - val result = DataBaseManager.get.queryMarkerById(markerId) + val result = markerBeanDao.queryMarkerById(markerId) if (result.isNotEmpty()) { MarkerDetailDialog(this).setMarker(result.first()).show() } else { @@ -154,12 +156,12 @@ binding.depthButton.isEnabled = true binding.depthButton.setTextColor(Color.WHITE) binding.depthButton.backgroundTintList = - ColorStateList.valueOf(Color.parseColor("#004364")) + ColorStateList.valueOf("#004364".toColorInt()) binding.markerInfoButton.isEnabled = true binding.markerInfoButton.setTextColor(Color.WHITE) binding.markerInfoButton.backgroundTintList = - ColorStateList.valueOf(Color.parseColor("#FFA200")) + ColorStateList.valueOf("#FFA200".toColorInt()) handleMarker(markerId) } @@ -171,12 +173,22 @@ if (isExecuteTask) { val taskId = SaveKeyValues.getValue(LocaleConstant.TASK_ID, "") as String val taskCode = SaveKeyValues.getValue(LocaleConstant.TASK_CODE, "") as String - val taskMarkerLocalBean = DataBaseManager.get.queryTaskMarkerById( + val marker = taskMarkerBeanDao.queryTaskMarkerById( taskId, taskCode, id, "0" ) - taskMarkerLocalBean?.apply { - taskViewModel.uploadMarker(context, this) + if (marker == null) { + return } + taskViewModel.uploadMarker( + marker.markerId, + onLoading = {}, + onSuccess = { + "标识器${marker.markerId}已探测!".show(this) + marker.isDetected = "1" + taskMarkerBeanDao.updateLocalTaskMarkerState(marker) + }, + onFailed = {} + ) } } @@ -185,15 +197,22 @@ detectDepthRunnable?.let { handler.removeCallbacks(it) } detectDepthRunnable = null LoadingDialog.dismiss() - AlertMessageDialog.Builder().setContext(context).setTitle("温馨提示") - .setMessage("标识器埋深:${depth}厘米").setPositiveButton("知道了") - .setOnDialogButtonClickListener(object : - AlertMessageDialog.OnDialogButtonClickListener { - override fun onConfirmClick() { - RuntimeCache.currentSegment = CurrentSegment.SearchMarker - sendSerialPortCommand(SerialPortCommand.SEARCH_SIGNAL) - } - }).build().show() + if (!this.isDestroyed) { + AlertMessageDialog.Builder() + .setContext(context) + .setTitle("温馨提示") + .setMessage("标识器埋深:${depth}厘米") + .setPositiveButton("知道了") + .setOnDialogButtonClickListener(object : + AlertMessageDialog.OnDialogButtonClickListener { + override fun onConfirmClick() { + RuntimeCache.currentSegment = CurrentSegment.SearchMarker + sendSerialPortCommand(SerialPortCommand.SEARCH_SIGNAL) + } + }).build().show() + } else { + "标识器埋深:${depth}厘米".show(this) + } } } @@ -201,13 +220,13 @@ if (RuntimeCache.currentSegment == CurrentSegment.SearchMarker) { if (signalEnergy > 1000) { binding.markerIdButton.isEnabled = true - binding.markerIdButton.setTextColor(Color.parseColor("#428d00")) + binding.markerIdButton.setTextColor("#428d00".toColorInt()) binding.markerIdButton.backgroundTintList = ColorStateList.valueOf( - Color.parseColor("#7EFF00") + "#7EFF00".toColorInt() ) binding.searchResultView.text = "已检测到标识器" - binding.searchResultView.setTextColor(Color.parseColor("#428d00")) + binding.searchResultView.setTextColor("#428d00".toColorInt()) binding.searchResultView.setBackgroundResource(R.mipmap.bg_small_text_green) } @@ -230,19 +249,19 @@ signalEnergy <= 700 -> { setEnergyTip( "信号较弱,可能距离较远", - Color.parseColor("#8D1717"), + "#8D1717".toColorInt(), R.mipmap.bg_large_text_red ) disableButtons() binding.searchResultView.text = "未检测到标识器" - binding.searchResultView.setTextColor(Color.parseColor("#8D1717")) + binding.searchResultView.setTextColor("#8D1717".toColorInt()) binding.searchResultView.setBackgroundResource(R.mipmap.bg_small_text_red) } signalEnergy >= 4100 -> { setEnergyTip( "信号极强,接近标识器正上方", - Color.parseColor("#428d00"), + "#428d00".toColorInt(), R.mipmap.bg_large_text_green ) } @@ -250,7 +269,7 @@ else -> { setEnergyTip( "已靠近,请继续移动位置", - Color.parseColor("#8C5700"), + "#8C5700".toColorInt(), R.mipmap.bg_large_text_yellow ) } @@ -263,8 +282,8 @@ binding.energyTipsView.setBackgroundResource(backgroundRes) } - private val colorStateList = ColorStateList.valueOf(Color.parseColor("#8A8A8A")) - private val textColor = Color.parseColor("#CCCCCC") + private val colorStateList = ColorStateList.valueOf("#8A8A8A".toColorInt()) + private val textColor = "#CCCCCC".toColorInt() private fun disableButtons() { binding.depthButton.isEnabled = false @@ -287,7 +306,7 @@ val latitude = location.latitude lifecycleScope.launch(Dispatchers.IO) { val dataPoints = ArrayList() - DataBaseManager.get.loadMarkers().forEach { + markerBeanDao.loadAll().forEach { val distance = AMapUtils.calculateLineDistance( LatLng(it.lat.toDouble(), it.lng.toDouble()), LatLng(latitude, longitude) ) @@ -332,10 +351,6 @@ return ActivitySearchMarkerBinding.inflate(layoutInflater) } - override fun observeRequestState() { - - } - override fun setupTopBarLayout() { } diff --git a/app/src/main/java/com/casic/common/detector/gd/view/SearchMarkerAuditActivity.kt b/app/src/main/java/com/casic/common/detector/gd/view/SearchMarkerAuditActivity.kt index 1dc59a7..dd4cc84 100644 --- a/app/src/main/java/com/casic/common/detector/gd/view/SearchMarkerAuditActivity.kt +++ b/app/src/main/java/com/casic/common/detector/gd/view/SearchMarkerAuditActivity.kt @@ -1,6 +1,5 @@ package com.casic.common.detector.gd.view -import android.content.Context import android.hardware.Sensor import android.hardware.SensorEvent import android.hardware.SensorEventListener @@ -13,9 +12,9 @@ import com.amap.api.maps.AMapUtils import com.amap.api.maps.model.LatLng import com.casic.common.detector.gd.R +import com.casic.common.detector.gd.base.BaseApplication import com.casic.common.detector.gd.callback.OnGetLocationListener import com.casic.common.detector.gd.databinding.ActivitySearchMarkerAuditBinding -import com.casic.common.detector.gd.utils.DataBaseManager import com.casic.common.detector.gd.utils.LocaleConstant import com.casic.common.detector.gd.utils.LocationKit import com.casic.common.detector.gd.widgets.MarkerDetailDialog @@ -36,7 +35,8 @@ private val kTag = "SearchMarkerActivity" private val context = this private val locationKit by lazy { LocationKit(this) } - private val sensorManager by lazy { getSystemService(Context.SENSOR_SERVICE) as SensorManager } + private val sensorManager by lazy { getSystemService(SENSOR_SERVICE) as SensorManager } + private val markerBeanDao by lazy { BaseApplication.get().dataBase.markerBeanDao() } private val attr = AudioAttributes.Builder().setUsage(AudioAttributes.USAGE_ALARM) .setContentType(AudioAttributes.CONTENT_TYPE_MUSIC).build() private val soundPool = SoundPool.Builder().setMaxStreams(16).setAudioAttributes(attr).build() @@ -72,7 +72,7 @@ override fun initEvent() { binding.markerInfoButton.setOnClickListener { //查库 - val result = DataBaseManager.get.queryMarkerById(nearestMarkerId) + val result = markerBeanDao.queryMarkerById(nearestMarkerId) if (result.isNotEmpty()) { MarkerDetailDialog(this).setMarker(result.first()).show() } else { @@ -90,7 +90,7 @@ val latitude = location.latitude lifecycleScope.launch(Dispatchers.IO) { val dataPoints = ArrayList() - DataBaseManager.get.loadMarkers().forEach { + markerBeanDao.loadAll().forEach { val distance = AMapUtils.calculateLineDistance( LatLng(it.lat.toDouble(), it.lng.toDouble()), LatLng(latitude, longitude) ) @@ -105,7 +105,8 @@ ) } withContext(Dispatchers.Main) { - binding.radarScanView.renderPointData(dataPoints, + binding.radarScanView.renderPointData( + dataPoints, object : RadarScanView.OnGetNearestPointCallback { override fun getNearestPoint(point: RadarScanView.DataPoint?) { if (point == null) { diff --git a/app/src/main/java/com/casic/common/detector/gd/vm/TaskViewModel.kt b/app/src/main/java/com/casic/common/detector/gd/vm/TaskViewModel.kt index ee0d63a..665d95c 100644 --- a/app/src/main/java/com/casic/common/detector/gd/vm/TaskViewModel.kt +++ b/app/src/main/java/com/casic/common/detector/gd/vm/TaskViewModel.kt @@ -1,95 +1,87 @@ package com.casic.common.detector.gd.vm -import android.content.Context -import android.util.Log -import androidx.lifecycle.MutableLiveData -import com.casic.common.detector.gd.bean.TaskMarkerLocalBean import com.casic.common.detector.gd.extensions.getResponseMessage import com.casic.common.detector.gd.extensions.getResponseState import com.casic.common.detector.gd.model.MarkerFileModel import com.casic.common.detector.gd.model.TaskModel import com.casic.common.detector.gd.retrofit.RetrofitServiceManager -import com.casic.common.detector.gd.utils.DataBaseManager -import com.casic.common.detector.gd.utils.LocaleConstant -import com.google.gson.Gson import com.google.gson.JsonParser -import com.google.gson.reflect.TypeToken import com.pengxh.kt.lite.base.BaseViewModel import com.pengxh.kt.lite.extensions.launch -import com.pengxh.kt.lite.extensions.show -import com.pengxh.kt.lite.utils.LoadState -import com.pengxh.kt.lite.utils.SaveKeyValues +import com.pengxh.kt.lite.extensions.unpackingResponse class TaskViewModel : BaseViewModel() { - - private val kTag = "TaskViewModel" - private val gson by lazy { Gson() } - val markerFileResult = MutableLiveData() - val taskResult = MutableLiveData() - val freeTaskResult = MutableLiveData() - val uploadTaskMarkerResult = MutableLiveData() - val executeTaskResult = MutableLiveData() - - fun createFreeTask(context: Context, patrollerId: String, description: String) = launch({ + fun createFreeTask( + patrollerId: String, + description: String, + onLoading: () -> Unit, + onSuccess: (Long) -> Unit, + onFailed: (String) -> Unit + ) = launch({ + onLoading() val response = RetrofitServiceManager.createFreeTask(patrollerId, description) if (response.getResponseState()) { val element = JsonParser.parseString(response) val jsonObject = element.asJsonObject - freeTaskResult.value = jsonObject.get("taskId").asInt.toString() + onSuccess(jsonObject.get("taskId").asLong) } else { - response.getResponseMessage().show(context) + onFailed(response.getResponseMessage()) } }, { - it.printStackTrace() + onFailed(it.message ?: "Unknown error") }) - fun uploadTaskMarker(context: Context, taskId: String, ids: ArrayList) = launch({ + fun uploadTaskMarker( + taskId: Long, + ids: ArrayList, + onLoading: () -> Unit, + onSuccess: () -> Unit, + onFailed: (String) -> Unit + ) = launch({ + onLoading() val response = RetrofitServiceManager.uploadTaskMarker(taskId, ids) if (response.getResponseState()) { - val element = JsonParser.parseString(response) - val jsonObject = element.asJsonObject - uploadTaskMarkerResult.value = jsonObject.get("success").asString - - //删除本地数据库 - val taskCode = SaveKeyValues.getValue(LocaleConstant.TASK_CODE, "") as String - DataBaseManager.get.deleteLocalTaskById(taskId, taskCode) - SaveKeyValues.putValue(LocaleConstant.TASK_ID, "") + onSuccess() } else { - response.getResponseMessage().show(context) + onFailed(response.getResponseMessage()) } }, { - it.printStackTrace() + onFailed(it.message ?: "Unknown error") }) - fun getMarkerFile(context: Context, userId: String, companyId: String) = launch({ - val response = RetrofitServiceManager.getMarkerFile(userId, companyId) + fun getMarkerFile( + onLoading: () -> Unit, + onSuccess: (MarkerFileModel) -> Unit, + onFailed: (String) -> Unit + ) = launch({ + onLoading() + val response = RetrofitServiceManager.getMarkerFile() if (response.getResponseState()) { - markerFileResult.value = gson.fromJson( - response, object : TypeToken() {}.type - ) + onSuccess(unpackingResponse(response)) } else { - response.getResponseMessage().show(context) + onFailed(response.getResponseMessage()) } }, { - it.printStackTrace() + onFailed(it.message ?: "Unknown error") }) - fun getTasksByUser(context: Context, userName: String) = launch({ - val response = RetrofitServiceManager.getTasksByUser(userName) + fun getTasksByUser( + onLoading: () -> Unit, + onSuccess: (TaskModel) -> Unit, + onFailed: (String) -> Unit + ) = launch({ + onLoading() + val response = RetrofitServiceManager.getTasksByUser() if (response.getResponseState()) { - taskResult.value = gson.fromJson( - response, object : TypeToken() {}.type - ) + onSuccess(unpackingResponse(response)) } else { - response.getResponseMessage().show(context) + onFailed(response.getResponseMessage()) } }, { - it.printStackTrace() + onFailed(it.message ?: "Unknown error") }) - fun installLabel( - context: Context, - companyId: String, + fun installMarker( recordType: String, markerObjectType: String, pipeMaterial: String, @@ -105,7 +97,6 @@ road: String, constructTime: String, ownerComp: String, - markerObjectId: String, markerId: String, markerType: String, markerDepth: String, @@ -115,11 +106,13 @@ latitude: String, colorType: String, memo: String, - realPaths: ArrayList + realPaths: ArrayList, + onLoading: () -> Unit, + onSuccess: () -> Unit, + onFailed: (String) -> Unit ) = launch({ - loadState.value = LoadState.Loading - val response = RetrofitServiceManager.installLabel( - companyId, + onLoading() + val response = RetrofitServiceManager.installMarker( recordType, markerObjectType, pipeMaterial, @@ -135,7 +128,6 @@ road, constructTime, ownerComp, - markerObjectId, markerId, markerType, markerDepth, @@ -148,67 +140,65 @@ realPaths ) if (response.getResponseState()) { - loadState.value = LoadState.Success + onSuccess() } else { - loadState.value = LoadState.Fail - response.getResponseMessage().show(context) + onFailed(response.getResponseMessage()) } }, { - it.printStackTrace() - loadState.value = LoadState.Fail + onFailed(it.message ?: "Unknown error") }) fun uploadTask( - context: Context, userId: String, taskId: String, taskCode: String, state: String + taskId: String, + state: String, + onLoading: () -> Unit, + onSuccess: () -> Unit, + onFailed: (String) -> Unit ) = launch({ - loadState.value = LoadState.Loading - val response = RetrofitServiceManager.uploadTask(userId, taskId, state) + onLoading() + val response = RetrofitServiceManager.uploadTask(taskId, state) if (response.getResponseState()) { - loadState.value = LoadState.Success - //工单提交之后,并且状态是2,删除本地Task记录 - if (state == "2") { - "工单${taskId}已提交!".show(context) - //删除本地数据库 - DataBaseManager.get.deleteLocalTaskById(taskId, taskCode) - SaveKeyValues.putValue(LocaleConstant.TASK_ID, "") - - val element = JsonParser.parseString(response) - val jsonObject = element.asJsonObject - executeTaskResult.value = jsonObject.get("success").asString - } else { - Log.d(kTag, "uploadTask: 仅执行工单,不删除本地工单数据") - } + onSuccess() } else { - loadState.value = LoadState.Fail - response.getResponseMessage().show(context) + onFailed(response.getResponseMessage()) } }, { - it.printStackTrace() - loadState.value = LoadState.Fail + onFailed(it.message ?: "Unknown error") }) fun uploadEvent( - context: Context, taskId: String, event: String, realPaths: ArrayList + taskId: String, + event: String, + realPaths: ArrayList, + onLoading: () -> Unit, + onSuccess: () -> Unit, + onFailed: (String) -> Unit ) = launch({ - loadState.value = LoadState.Loading + onLoading() val response = RetrofitServiceManager.uploadEvent(taskId, event, realPaths) if (response.getResponseState()) { - loadState.value = LoadState.Success + onSuccess() } else { - loadState.value = LoadState.Fail - response.getResponseMessage().show(context) + onFailed(response.getResponseMessage()) } }, { - it.printStackTrace() - loadState.value = LoadState.Fail + onFailed(it.message ?: "Unknown error") }) - fun uploadMarker(context: Context, marker: TaskMarkerLocalBean) = launch({ - //主键ID代替MarkerId - RetrofitServiceManager.uploadMarker(marker.id.toString()) - "标识器${marker.markerId}已探测!".show(context) - DataBaseManager.get.updateLocalTaskMarkerState(marker) + fun uploadMarker( + markerId: String, + onLoading: () -> Unit, + onSuccess: () -> Unit, + onFailed: (String) -> Unit + ) = launch({ + onLoading() + val response = RetrofitServiceManager.uploadMarker(markerId) + if (response.getResponseState()) { + onSuccess() + } else { + onFailed(response.getResponseMessage()) + } }, { - it.printStackTrace() + onFailed(it.message ?: "Unknown error") }) } \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/widgets/MarkerDetailDialog.kt b/app/src/main/java/com/casic/common/detector/gd/widgets/MarkerDetailDialog.kt index 44723f2..3890584 100644 --- a/app/src/main/java/com/casic/common/detector/gd/widgets/MarkerDetailDialog.kt +++ b/app/src/main/java/com/casic/common/detector/gd/widgets/MarkerDetailDialog.kt @@ -3,8 +3,7 @@ import android.app.Dialog import android.content.Context import android.os.Bundle -import com.casic.common.detector.gd.R -import com.casic.common.detector.gd.bean.MarkerLocalBean +import com.casic.common.detector.gd.bean.MarkerBean import com.casic.common.detector.gd.databinding.DialogMarkerDetailBinding import com.casic.common.detector.gd.extensions.appendDownloadUrl import com.casic.common.detector.gd.extensions.initDialogLayoutParams @@ -15,12 +14,11 @@ import com.pengxh.kt.lite.extensions.navigatePageTo import com.pengxh.kt.lite.extensions.show -class MarkerDetailDialog(context: Context) : - Dialog(context, R.style.UserDefinedDialogStyle) { +class MarkerDetailDialog(context: Context) : Dialog(context) { - private lateinit var marker: MarkerLocalBean + private lateinit var marker: MarkerBean - fun setMarker(marker: MarkerLocalBean): MarkerDetailDialog { + fun setMarker(marker: MarkerBean): MarkerDetailDialog { this.marker = marker return this } @@ -52,7 +50,7 @@ binding.showImageView.setOnClickListener { //查数据库 - if (marker.imagePath.isNullOrEmpty()) { + if (marker.imagePath.isEmpty()) { "此标识器无图片".show(context) } else { val realPaths = ArrayList() //真实图片路径 diff --git a/app/src/main/java/com/casic/common/detector/gd/widgets/QueryMarkerDialog.kt b/app/src/main/java/com/casic/common/detector/gd/widgets/QueryMarkerDialog.kt index 304fdbb..64a1b93 100644 --- a/app/src/main/java/com/casic/common/detector/gd/widgets/QueryMarkerDialog.kt +++ b/app/src/main/java/com/casic/common/detector/gd/widgets/QueryMarkerDialog.kt @@ -6,20 +6,19 @@ import android.view.View import android.widget.AdapterView import android.widget.ArrayAdapter -import com.casic.common.detector.gd.R +import com.casic.common.detector.gd.base.BaseApplication import com.casic.common.detector.gd.databinding.DialogQueryMarkerBinding -import com.casic.common.detector.gd.utils.DataBaseManager +import com.casic.common.detector.gd.utils.LocaleConstant import com.pengxh.kt.lite.extensions.binding import com.pengxh.kt.lite.extensions.initDialogLayoutParams import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.Job import kotlinx.coroutines.launch import kotlinx.coroutines.withContext -class QueryMarkerDialog private constructor(builder: Builder) : Dialog( - builder.context, R.style.UserDefinedDialogStyle -) { +class QueryMarkerDialog private constructor(builder: Builder) : Dialog(builder.context) { private val ctx = builder.context private val title = builder.title private val spinnerArray = builder.spinnerArray @@ -71,6 +70,7 @@ } private val binding: DialogQueryMarkerBinding by binding() + private val serviceScope = CoroutineScope(Dispatchers.Main + Job()) override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -97,12 +97,11 @@ ) { //查库 val autoCompleteData = HashSet() - CoroutineScope(Dispatchers.Main).launch { + val markerBeanDao = BaseApplication.get().dataBase.markerBeanDao() + val buildQuery = LocaleConstant.buildQuery(spinnerArray[position], "") + serviceScope.launch { val labelBeans = withContext(Dispatchers.IO) { - DataBaseManager.get.loadMarkersByCondition( - spinnerArray[position], - null - ) + markerBeanDao.loadMarkersByCondition(buildQuery) } for (labelBean in labelBeans) { when (position) { diff --git a/build.gradle b/build.gradle index 987ad74..8af745d 100644 --- a/build.gradle +++ b/build.gradle @@ -1,31 +1,5 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. -buildscript { - ext.kotlin_version = '1.6.10' - repositories { - maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' } - mavenCentral() - google() - } - dependencies { - classpath 'com.android.tools.build:gradle:4.2.2' - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath 'org.greenrobot:greendao-gradle-plugin:3.3.0' - - // NOTE: Do not place your application dependencies here; they belong - // in the individual module build.gradle files - } -} - -allprojects { - repositories { - maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' } - //依赖库 - maven { url 'https://jitpack.io' } - mavenCentral() - google() - } -} - -tasks.register('clean', Delete) { - delete rootProject.buildDir +plugins { + id("com.android.application") version "8.1.0" apply false + id("org.jetbrains.kotlin.android") version "2.0.21" apply false } \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index dfadfe5..d00fa47 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Thu Nov 07 08:41:44 CST 2024 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip +distributionUrl=https\://mirrors.cloud.tencent.com/gradle/gradle-8.0-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/app/build.gradle b/app/build.gradle index d0cb423..921c8c8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,25 +1,20 @@ import java.text.SimpleDateFormat -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply plugin: 'org.greenrobot.greendao' +plugins { + id('com.android.application') + id('org.jetbrains.kotlin.android') +} android { - compileSdkVersion 33 + namespace 'com.casic.common.detector.gd' + compileSdk 35 defaultConfig { - applicationId "com.casic.common.detector.gd" - minSdkVersion 26 - targetSdkVersion 33 + applicationId 'com.casic.common.detector.gd' + minSdk 26 + targetSdk 35 versionCode 5092 - versionName "5.0.9.2" - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } + versionName '5.0.9.2' } signingConfigs { @@ -31,6 +26,14 @@ } } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + signingConfig signingConfigs.release + } + } + compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 @@ -47,27 +50,16 @@ } } - kotlin { - experimental { - coroutines 'enable' - } - } - buildFeatures { + buildConfig true viewBinding true } - applicationVariants.configureEach { variant -> - variant.outputs.configureEach { - outputFileName = "COM_TCY_" + getBuildDate() + "_" + defaultConfig.versionName + ".apk" + applicationVariants.configureEach { + outputs.configureEach { + outputFileName = 'COM_TCY_' + getBuildDate() + '_' + defaultConfig.versionName + '.apk' } } - - greendao { - schemaVersion 1//数据库版本号 - targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 - daoPackage "${defaultConfig.applicationId}.greendao"//设置DaoMaster、DaoSession、Dao包名 - } } static def getBuildDate() { @@ -76,27 +68,22 @@ } dependencies { - //基础依赖库 - implementation 'com.github.AndroidCoderPeng:Kotlin-lite-lib:1.1.4' - implementation 'androidx.core:core-ktx:1.9.0' - def base_version = "1.6.1" - implementation "androidx.appcompat:appcompat:${base_version}" - implementation "com.google.android.material:material:${base_version}" + implementation 'com.github.AndroidCoderPeng:Kotlin-lite-lib:1.1.5' + implementation 'androidx.core:core-ktx:1.13.1' + implementation 'androidx.appcompat:appcompat:1.7.0' + implementation 'com.google.android.material:material:1.12.0' //Google官方授权框架 implementation 'pub.devrel:easypermissions:3.0.0' - //沉浸式状态栏。基础依赖包,必须要依赖 - implementation 'com.gyf.immersionbar:immersionbar:3.0.0' - //fragment快速实现 - implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0' + //沉浸式状态栏 + implementation 'com.geyifeng.immersionbar:immersionbar:3.2.2' //官方Json解析库 implementation 'com.google.code.gson:gson:2.10.1' - def vm_version = '2.5.1' //Kotlin协程 - implementation "androidx.lifecycle:lifecycle-runtime-ktx:${vm_version}" + implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.2' //MVVM+LiveData - implementation "androidx.lifecycle:lifecycle-livedata-ktx:${vm_version}" - implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:${vm_version}" - implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.6.2' + implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2' + implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' //返回值转换器 implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' @@ -105,9 +92,10 @@ implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' //网络请求和接口封装 implementation 'com.squareup.retrofit2:retrofit:2.9.0' - implementation 'com.squareup.okhttp3:okhttp:4.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.12.0' //数据库框架 - implementation 'org.greenrobot:greendao:3.3.0' + implementation 'androidx.room:room-runtime:2.6.1' + annotationProcessor 'androidx.room:room-compiler:2.5.2' //高德导航、定位、地图三合一 implementation 'com.amap.api:navi-3dmap:latest.integration' //经纬度逆编码 @@ -115,7 +103,7 @@ //excel implementation 'net.sourceforge.jexcelapi:jxl:2.6.12' //图片加载框架 - implementation 'com.github.bumptech.glide:glide:4.9.0' + implementation 'com.github.bumptech.glide:glide:4.12.0' //图片选择框架 implementation 'io.github.lucksiege:pictureselector:v3.11.1' //大图 diff --git a/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt b/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt index 7b695ff..50ba734 100644 --- a/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt +++ b/app/src/main/java/com/casic/common/detector/gd/base/BaseApplication.kt @@ -4,9 +4,9 @@ import android.app.Application import android.os.Bundle import android.util.Log -import com.casic.common.detector.gd.greendao.DaoMaster -import com.casic.common.detector.gd.greendao.DaoSession +import androidx.room.Room.databaseBuilder import com.casic.common.detector.gd.uart.SerialPort +import com.casic.common.detector.gd.utils.DetectorDataBase import com.casic.common.detector.gd.utils.GpioManager import com.pengxh.kt.lite.extensions.show import com.pengxh.kt.lite.utils.SaveKeyValues @@ -43,44 +43,42 @@ private var application: BaseApplication by Delegates.notNull() fun get() = application - - private lateinit var daoSession: DaoSession } + lateinit var dataBase: DetectorDataBase + override fun onCreate() { super.onCreate() application = this SaveKeyValues.initSharedPreferences(this) CrashReport.initCrashReport(this, "01e80d3a74", true) - val devOpenHelper = DaoMaster.DevOpenHelper(this, "Detector.db", null) - val daoMaster = DaoMaster(devOpenHelper.writableDatabase) - daoSession = daoMaster.newSession() + dataBase = databaseBuilder(this, DetectorDataBase::class.java, "Detector.db") + .allowMainThreadQueries() + .build() /** * Open the serial port * */ try { serialPorts.apply { - add(SerialPort(File("/dev/ttysWK1"), 9600, 0)) - //千寻报文数据下发串口号 - add(SerialPort(File("/dev/ttyS1"), 9600, 0)) + add(SerialPort(File("/dev/ttysWK1"), 9600, 0)) //信号通讯串口 + add(SerialPort(File("/dev/ttyS1"), 9600, 0)) //千寻报文数据下发串口号 } Log.d(kTag, "onCreate: 已初始化 ${serialPorts.size} 个串口") } catch (e: SecurityException) { "您没有串口的读写权限!".show(this) + e.printStackTrace() } catch (e: IOException) { "因为不明原因,串口无法打开!".show(this) + e.printStackTrace() } catch (e: InvalidParameterException) { "请检查串口!".show(this) + e.printStackTrace() } registerActivityLifecycleCallbacks(this) } - fun getDaoSession(): DaoSession { - return daoSession - } - override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) { } diff --git a/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt b/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt index 053b9dd..1d0c9e3 100644 --- a/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt +++ b/app/src/main/java/com/casic/common/detector/gd/base/SerialPortBaseActivity.kt @@ -14,12 +14,10 @@ import com.casic.common.detector.gd.utils.SerialPortCommand import com.pengxh.kt.lite.utils.WeakReferenceHandler import java.io.IOException -import java.util.Timer abstract class SerialPortBaseActivity : AppCompatActivity(), Handler.Callback { private val kTag = "SerialPortBaseActivity" - private val taskTimer by lazy { Timer() } private val weakReferenceHandler by lazy { WeakReferenceHandler(this) } private val serialPorts by lazy { BaseApplication.get().getSerialPorts() } protected lateinit var binding: VB @@ -30,7 +28,6 @@ setContentView(binding.root) setupTopBarLayout() initOnCreate(savedInstanceState) - observeRequestState() initEvent() if (serialPorts.isNotEmpty()) { @@ -71,11 +68,6 @@ abstract fun initOnCreate(savedInstanceState: Bundle?) /** - * 数据请求状态监听 - */ - abstract fun observeRequestState() - - /** * 初始化业务逻辑 */ abstract fun initEvent() diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java new file mode 100644 index 0000000..7a18c20 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerBean.java @@ -0,0 +1,255 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 从平台下载的标识器本地库实体类 + */ +@Entity(tableName = "marker_detail") +public class MarkerBean { + @PrimaryKey(autoGenerate = true) + private long id; //主键ID + private String pipelineType; // 管线类型 + private String pipelineDiameter; // 管线直径 + private String pipelineMaterial; // 管材 + private String buryMethod; // 埋设方式 + private String buryDepth; // 埋深 + private String area; // 所属区域 + private String line; // 所属线路 + private String road; // 所属道路 + private String constructTime; // 建设年代 + private String owner; // 权属单位 + private String objectId; // 标识对象ID,无实际用途 + private String markerId; // 标识器ID + private String markerType; // 标识器类型 + private String markerDepth; // 标识器埋深 + private String installationDept; // 安装部门 + private String lng; // 经度 + private String lat; // 纬度 + private String updateTime; // 最后修改时间,更新时间 + private String remark; // 备注信息 + private String underlyingPipelineType; // 下层管线类型 + private String underlyingPipelineDepth; // 下层埋深 + private String underlyingPipelineDiameter; // 下层管径 + private String underlyingPipelineMaterial; // 下层管材 + private String objectType; //标识对象类型 + private String color; // 颜色 + private String imagePath; // 图片路径 + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getPipelineType() { + return pipelineType; + } + + public void setPipelineType(String pipelineType) { + this.pipelineType = pipelineType; + } + + public String getPipelineDiameter() { + return pipelineDiameter; + } + + public void setPipelineDiameter(String pipelineDiameter) { + this.pipelineDiameter = pipelineDiameter; + } + + public String getPipelineMaterial() { + return pipelineMaterial; + } + + public void setPipelineMaterial(String pipelineMaterial) { + this.pipelineMaterial = pipelineMaterial; + } + + public String getBuryMethod() { + return buryMethod; + } + + public void setBuryMethod(String buryMethod) { + this.buryMethod = buryMethod; + } + + public String getBuryDepth() { + return buryDepth; + } + + public void setBuryDepth(String buryDepth) { + this.buryDepth = buryDepth; + } + + public String getArea() { + return area; + } + + public void setArea(String area) { + this.area = area; + } + + public String getLine() { + return line; + } + + public void setLine(String line) { + this.line = line; + } + + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + + public String getConstructTime() { + return constructTime; + } + + public void setConstructTime(String constructTime) { + this.constructTime = constructTime; + } + + public String getOwner() { + return owner; + } + + public void setOwner(String owner) { + this.owner = owner; + } + + public String getObjectId() { + return objectId; + } + + public void setObjectId(String objectId) { + this.objectId = objectId; + } + + public String getMarkerId() { + return markerId; + } + + public void setMarkerId(String markerId) { + this.markerId = markerId; + } + + public String getMarkerType() { + return markerType; + } + + public void setMarkerType(String markerType) { + this.markerType = markerType; + } + + public String getMarkerDepth() { + return markerDepth; + } + + public void setMarkerDepth(String markerDepth) { + this.markerDepth = markerDepth; + } + + public String getInstallationDept() { + return installationDept; + } + + public void setInstallationDept(String installationDept) { + this.installationDept = installationDept; + } + + public String getLng() { + return lng; + } + + public void setLng(String lng) { + this.lng = lng; + } + + public String getLat() { + return lat; + } + + public void setLat(String lat) { + this.lat = lat; + } + + public String getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } + + public String getUnderlyingPipelineType() { + return underlyingPipelineType; + } + + public void setUnderlyingPipelineType(String underlyingPipelineType) { + this.underlyingPipelineType = underlyingPipelineType; + } + + public String getUnderlyingPipelineDepth() { + return underlyingPipelineDepth; + } + + public void setUnderlyingPipelineDepth(String underlyingPipelineDepth) { + this.underlyingPipelineDepth = underlyingPipelineDepth; + } + + public String getUnderlyingPipelineDiameter() { + return underlyingPipelineDiameter; + } + + public void setUnderlyingPipelineDiameter(String underlyingPipelineDiameter) { + this.underlyingPipelineDiameter = underlyingPipelineDiameter; + } + + public String getUnderlyingPipelineMaterial() { + return underlyingPipelineMaterial; + } + + public void setUnderlyingPipelineMaterial(String underlyingPipelineMaterial) { + this.underlyingPipelineMaterial = underlyingPipelineMaterial; + } + + public String getObjectType() { + return objectType; + } + + public void setObjectType(String objectType) { + this.objectType = objectType; + } + + public String getColor() { + return color; + } + + public void setColor(String color) { + this.color = color; + } + + public String getImagePath() { + return imagePath; + } + + public void setImagePath(String imagePath) { + this.imagePath = imagePath; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java deleted file mode 100644 index 3f2fcdc..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/MarkerLocalBean.java +++ /dev/null @@ -1,327 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 从平台下载的标识器本地库实体类 - */ -@Entity -public class MarkerLocalBean { - @Id(autoincrement = true) - private Long id;//本地库主键ID - - // 管线类型 - private String pipelineType; - // 管线直径 - private String pipelineDiameter; - // 管材 - private String pipelineMaterial; - // 埋设方式 - private String buryMethod; - // 埋深 - private String buryDepth; - // 所属区域 - private String area; - // 所属线路 - private String line; - // 所属道路 - private String road; - // 建设年代 - private String constructTime; - // 权属单位 - private String owner; - //标识对象ID,无实际用途 - @Deprecated - private String objectId; - // 标识器ID - private String markerId; - // 标识器类型 - private String markerType; - // 标识器埋深 - private String markerDepth; - // 安装部门 - private String installationDept; - // 经度 - private String lng; - // 纬度 - private String lat; - //最后修改时间,更新时间 - private String updateTime; - // 备注信息 - private String remark; - // 下层管线类型 - private String underlyingPipelineType; - // 下层埋深 - private String underlyingPipelineDepth; - // 下层管径 - private String underlyingPipelineDiameter; - // 下层管材 - private String underlyingPipelineMaterial; - //标识对象类型 - private String objectType; - // 颜色 - private String color; - // 图片路径 - private String imagePath; - - @Generated(hash = 1479045776) - public MarkerLocalBean(Long id, String pipelineType, String pipelineDiameter, - String pipelineMaterial, String buryMethod, String buryDepth, - String area, String line, String road, String constructTime, - String owner, String objectId, String markerId, String markerType, - String markerDepth, String installationDept, String lng, String lat, - String updateTime, String remark, String underlyingPipelineType, - String underlyingPipelineDepth, String underlyingPipelineDiameter, - String underlyingPipelineMaterial, String objectType, String color, - String imagePath) { - this.id = id; - this.pipelineType = pipelineType; - this.pipelineDiameter = pipelineDiameter; - this.pipelineMaterial = pipelineMaterial; - this.buryMethod = buryMethod; - this.buryDepth = buryDepth; - this.area = area; - this.line = line; - this.road = road; - this.constructTime = constructTime; - this.owner = owner; - this.objectId = objectId; - this.markerId = markerId; - this.markerType = markerType; - this.markerDepth = markerDepth; - this.installationDept = installationDept; - this.lng = lng; - this.lat = lat; - this.updateTime = updateTime; - this.remark = remark; - this.underlyingPipelineType = underlyingPipelineType; - this.underlyingPipelineDepth = underlyingPipelineDepth; - this.underlyingPipelineDiameter = underlyingPipelineDiameter; - this.underlyingPipelineMaterial = underlyingPipelineMaterial; - this.objectType = objectType; - this.color = color; - this.imagePath = imagePath; - } - - @Generated(hash = 1538606012) - public MarkerLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getPipelineType() { - return this.pipelineType; - } - - public void setPipelineType(String pipelineType) { - this.pipelineType = pipelineType; - } - - public String getPipelineDiameter() { - return this.pipelineDiameter; - } - - public void setPipelineDiameter(String pipelineDiameter) { - this.pipelineDiameter = pipelineDiameter; - } - - public String getPipelineMaterial() { - return this.pipelineMaterial; - } - - public void setPipelineMaterial(String pipelineMaterial) { - this.pipelineMaterial = pipelineMaterial; - } - - public String getBuryMethod() { - return this.buryMethod; - } - - public void setBuryMethod(String buryMethod) { - this.buryMethod = buryMethod; - } - - public String getBuryDepth() { - return this.buryDepth; - } - - public void setBuryDepth(String buryDepth) { - this.buryDepth = buryDepth; - } - - public String getArea() { - return this.area; - } - - public void setArea(String area) { - this.area = area; - } - - public String getLine() { - return this.line; - } - - public void setLine(String line) { - this.line = line; - } - - public String getRoad() { - return this.road; - } - - public void setRoad(String road) { - this.road = road; - } - - public String getConstructTime() { - return this.constructTime; - } - - public void setConstructTime(String constructTime) { - this.constructTime = constructTime; - } - - public String getOwner() { - return this.owner; - } - - public void setOwner(String owner) { - this.owner = owner; - } - - public String getObjectId() { - return this.objectId; - } - - public void setObjectId(String objectId) { - this.objectId = objectId; - } - - public String getMarkerId() { - return this.markerId; - } - - public void setMarkerId(String markerId) { - this.markerId = markerId; - } - - public String getMarkerType() { - return this.markerType; - } - - public void setMarkerType(String markerType) { - this.markerType = markerType; - } - - public String getMarkerDepth() { - return this.markerDepth; - } - - public void setMarkerDepth(String markerDepth) { - this.markerDepth = markerDepth; - } - - public String getInstallationDept() { - return this.installationDept; - } - - public void setInstallationDept(String installationDept) { - this.installationDept = installationDept; - } - - public String getLng() { - return this.lng; - } - - public void setLng(String lng) { - this.lng = lng; - } - - public String getLat() { - return this.lat; - } - - public void setLat(String lat) { - this.lat = lat; - } - - public String getUpdateTime() { - return this.updateTime; - } - - public void setUpdateTime(String updateTime) { - this.updateTime = updateTime; - } - - public String getRemark() { - return this.remark; - } - - public void setRemark(String remark) { - this.remark = remark; - } - - public String getUnderlyingPipelineType() { - return this.underlyingPipelineType; - } - - public void setUnderlyingPipelineType(String underlyingPipelineType) { - this.underlyingPipelineType = underlyingPipelineType; - } - - public String getUnderlyingPipelineDepth() { - return this.underlyingPipelineDepth; - } - - public void setUnderlyingPipelineDepth(String underlyingPipelineDepth) { - this.underlyingPipelineDepth = underlyingPipelineDepth; - } - - public String getUnderlyingPipelineDiameter() { - return this.underlyingPipelineDiameter; - } - - public void setUnderlyingPipelineDiameter(String underlyingPipelineDiameter) { - this.underlyingPipelineDiameter = underlyingPipelineDiameter; - } - - public String getUnderlyingPipelineMaterial() { - return this.underlyingPipelineMaterial; - } - - public void setUnderlyingPipelineMaterial(String underlyingPipelineMaterial) { - this.underlyingPipelineMaterial = underlyingPipelineMaterial; - } - - public String getObjectType() { - return this.objectType; - } - - public void setObjectType(String objectType) { - this.objectType = objectType; - } - - public String getColor() { - return this.color; - } - - public void setColor(String color) { - this.color = color; - } - - public String getImagePath() { - return this.imagePath; - } - - public void setImagePath(String imagePath) { - this.imagePath = imagePath; - } -} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java new file mode 100644 index 0000000..5c88fdf --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/TaskBean.java @@ -0,0 +1,93 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 巡检任务本地库实体类,不包含任务里面需要巡检的标识器信息 + */ +@Entity(tableName = "task_detail") +public class TaskBean { + @PrimaryKey(autoGenerate = true) + private long id;//主键ID + private String taskCode; // 任务编号 + private String description; // 任务名称 + private String createTime; // 任务创建的时间 + private String status; // 任务状态 + private String createUserName; // 任务创建者名称 + private String startTime; // 任务被开始执行的时间 + private String endTime; // 任务执行结束的时间 + private String isFree; // 是否自由巡检。1-是,0-否 + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getTaskCode() { + return taskCode; + } + + public void setTaskCode(String taskCode) { + this.taskCode = taskCode; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getCreateUserName() { + return createUserName; + } + + public void setCreateUserName(String createUserName) { + this.createUserName = createUserName; + } + + public String getStartTime() { + return startTime; + } + + public void setStartTime(String startTime) { + this.startTime = startTime; + } + + public String getEndTime() { + return endTime; + } + + public void setEndTime(String endTime) { + this.endTime = endTime; + } + + public String getIsFree() { + return isFree; + } + + public void setIsFree(String isFree) { + this.isFree = isFree; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java deleted file mode 100644 index 91737b3..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/TaskLocalBean.java +++ /dev/null @@ -1,114 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 巡检任务本地库实体类,不包含任务里面需要巡检的标识器信息 - */ -@Entity -public class TaskLocalBean { - @Id - private Long id;//任务ID - - private String taskCode;//任务编号 - private String description;//任务名称 - private String createTime;//任务创建的时间 - private String status;//任务状态 - private String createUserName;//任务创建者名称 - private String startTime;//任务被开始执行的时间 - private String endTime;//任务执行结束的时间 - private String isFreeTask;//是否自由巡检。1-是,0-否 - - @Generated(hash = 1482022528) - public TaskLocalBean(Long id, String taskCode, String description, - String createTime, String status, String createUserName, - String startTime, String endTime, String isFreeTask) { - this.id = id; - this.taskCode = taskCode; - this.description = description; - this.createTime = createTime; - this.status = status; - this.createUserName = createUserName; - this.startTime = startTime; - this.endTime = endTime; - this.isFreeTask = isFreeTask; - } - - @Generated(hash = 949704588) - public TaskLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getTaskCode() { - return this.taskCode; - } - - public void setTaskCode(String taskCode) { - this.taskCode = taskCode; - } - - public String getDescription() { - return this.description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getCreateTime() { - return this.createTime; - } - - public void setCreateTime(String createTime) { - this.createTime = createTime; - } - - public String getStatus() { - return this.status; - } - - public void setStatus(String status) { - this.status = status; - } - - public String getCreateUserName() { - return this.createUserName; - } - - public void setCreateUserName(String createUserName) { - this.createUserName = createUserName; - } - - public String getStartTime() { - return this.startTime; - } - - public void setStartTime(String startTime) { - this.startTime = startTime; - } - - public String getEndTime() { - return this.endTime; - } - - public void setEndTime(String endTime) { - this.endTime = endTime; - } - - public String getIsFreeTask() { - return this.isFreeTask; - } - - public void setIsFreeTask(String isFreeTask) { - this.isFreeTask = isFreeTask; - } -} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerBean.java new file mode 100644 index 0000000..c563a60 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerBean.java @@ -0,0 +1,110 @@ +package com.casic.common.detector.gd.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * 巡检任务里面需要巡检的标识器信息本地库实体类 + */ +@Entity(tableName = "task_marker_info") +public class TaskMarkerBean { + //标识器后台库的主键ID,不是标识器实际ID + @PrimaryKey(autoGenerate = true) + private long id; + + /** + * 任务ID,通过此字段关联[TaskBean.id] + */ + private String taskId; + + /** + * 任务Code,通过此字段关联[TaskBean.taskCode] + *

+ *

+ * 双重验证,防止出现同时刻重复的情况 + */ + private String taskCode; + + /** + * 对应后台字段[TaskModel.MessageModel.TaskDetailInfosModel.markerIdReal],也就是探测仪扫描出来的ID + */ + private String markerId; + + private Double lng; + private Double lat; + + /** + * 是否已被探测到 + * 1-是,0-否 + */ + private String isDetected; + + /** + * 被探测到的时间,对应后台字段[TaskModel.MessageModel.TaskDetailInfosModel.finishTime] + */ + private String detectedTime; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getTaskId() { + return taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getTaskCode() { + return taskCode; + } + + public void setTaskCode(String taskCode) { + this.taskCode = taskCode; + } + + public String getMarkerId() { + return markerId; + } + + public void setMarkerId(String markerId) { + this.markerId = markerId; + } + + public Double getLng() { + return lng; + } + + public void setLng(Double lng) { + this.lng = lng; + } + + public Double getLat() { + return lat; + } + + public void setLat(Double lat) { + this.lat = lat; + } + + public String getIsDetected() { + return isDetected; + } + + public void setIsDetected(String isDetected) { + this.isDetected = isDetected; + } + + public String getDetectedTime() { + return detectedTime; + } + + public void setDetectedTime(String detectedTime) { + this.detectedTime = detectedTime; + } +} diff --git a/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerLocalBean.java b/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerLocalBean.java deleted file mode 100644 index de9f459..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/bean/TaskMarkerLocalBean.java +++ /dev/null @@ -1,128 +0,0 @@ -package com.casic.common.detector.gd.bean; - -import com.casic.common.detector.gd.model.TaskModel; - -import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Generated; -import org.greenrobot.greendao.annotation.Id; - -/** - * 巡检任务里面需要巡检的标识器信息本地库实体类 - */ -@Entity -public class TaskMarkerLocalBean { - @Id - private Long id;//标识器后台库的主键ID,不是标识器实际ID - - /** - * 任务ID,通过此字段关联{@link TaskLocalBean#id} - */ - private String taskId; - - /** - * 任务Code,通过此字段关联{@link TaskLocalBean#taskCode} - *

- * 双重验证,防止出现同时刻重复的情况 - */ - private String taskCode; - - /** - * 对应后台字段{@link TaskModel.MessageModel.TaskDetailInfosModel#markerIdReal},也就是探测仪扫描出来的ID - */ - private String markerId; - - private double lng; - private double lat; - - /** - * 是否已被探测到 - * 1-是,0-否 - */ - private String isDetected; - - /** - * 被探测到的时间,对应后台字段{@link TaskModel.MessageModel.TaskDetailInfosModel#finishTime} - */ - private String detectedTime; - - @Generated(hash = 677328533) - public TaskMarkerLocalBean(Long id, String taskId, String taskCode, String markerId, - double lng, double lat, String isDetected, String detectedTime) { - this.id = id; - this.taskId = taskId; - this.taskCode = taskCode; - this.markerId = markerId; - this.lng = lng; - this.lat = lat; - this.isDetected = isDetected; - this.detectedTime = detectedTime; - } - - @Generated(hash = 1162404642) - public TaskMarkerLocalBean() { - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getTaskId() { - return this.taskId; - } - - public void setTaskId(String taskId) { - this.taskId = taskId; - } - - public String getTaskCode() { - return this.taskCode; - } - - public void setTaskCode(String taskCode) { - this.taskCode = taskCode; - } - - public String getMarkerId() { - return this.markerId; - } - - public void setMarkerId(String markerId) { - this.markerId = markerId; - } - - public double getLng() { - return this.lng; - } - - public void setLng(double lng) { - this.lng = lng; - } - - public double getLat() { - return this.lat; - } - - public void setLat(double lat) { - this.lat = lat; - } - - public String getIsDetected() { - return this.isDetected; - } - - public void setIsDetected(String isDetected) { - this.isDetected = isDetected; - } - - public String getDetectedTime() { - return this.detectedTime; - } - - public void setDetectedTime(String detectedTime) { - this.detectedTime = detectedTime; - } -} diff --git a/app/src/main/java/com/casic/common/detector/gd/dao/MarkerBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/dao/MarkerBeanDao.java new file mode 100644 index 0000000..2beb7ed --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/dao/MarkerBeanDao.java @@ -0,0 +1,29 @@ +package com.casic.common.detector.gd.dao; + +import androidx.room.Dao; +import androidx.room.Insert; +import androidx.room.Query; +import androidx.room.RawQuery; +import androidx.sqlite.db.SupportSQLiteQuery; + +import com.casic.common.detector.gd.bean.MarkerBean; + +import java.util.List; + +@Dao +public interface MarkerBeanDao { + @Query("DELETE FROM marker_detail") + void deleteAll(); + + @Insert + void insert(MarkerBean marker); + + @Query("SELECT * FROM marker_detail") + List loadAll(); + + @Query("SELECT * FROM marker_detail WHERE markerId = :markerId") + List queryMarkerById(String markerId); + + @RawQuery + List loadMarkersByCondition(SupportSQLiteQuery query); +} diff --git a/app/src/main/java/com/casic/common/detector/gd/dao/TaskBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/dao/TaskBeanDao.java new file mode 100644 index 0000000..9c70ac2 --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/dao/TaskBeanDao.java @@ -0,0 +1,120 @@ +package com.casic.common.detector.gd.dao; + +import androidx.room.Dao; +import androidx.room.Insert; +import androidx.room.Query; +import androidx.room.Transaction; + +import com.casic.common.detector.gd.bean.TaskBean; +import com.casic.common.detector.gd.bean.TaskMarkerBean; +import com.casic.common.detector.gd.model.TaskDetailLocalModel; +import com.casic.common.detector.gd.model.TaskModel; +import com.casic.common.detector.gd.utils.LocaleConstant; +import com.pengxh.kt.lite.utils.SaveKeyValues; + +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Locale; + +@Dao +public interface TaskBeanDao { + @Query("SELECT COUNT(*) FROM task_detail WHERE id = :taskId") + int isTaskExist(long taskId); + + @Insert + void insert(TaskBean task); + + default void saveTask(Long taskId, String taskName) { + if (isTaskExist(taskId) == 0) { + TaskBean task = new TaskBean(); + task.setId(taskId); + task.setTaskCode(new SimpleDateFormat("yyyyMMddHHmmss", Locale.CHINA).format(new Date())); + task.setDescription(taskName); + String time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA).format(new Date()); + task.setCreateTime(time); + task.setStatus("0"); + String userName = (String) SaveKeyValues.INSTANCE.getValue(LocaleConstant.USER_NAME, ""); + task.setCreateUserName(userName); + task.setStartTime(time); + task.setEndTime(""); + task.setIsFree("1"); + insert(task); + } + } + + default void saveTask(TaskModel.MessageModel model) { + TaskBean task = new TaskBean(); + task.setId(model.getId()); + task.setTaskCode(model.getTaskCode()); + task.setDescription(model.getDescription()); + task.setCreateTime(model.getDeployDate()); + task.setStatus(model.getStatus()); + task.setCreateUserName(model.getCreatorName()); + task.setStartTime(model.getBeginDate()); + task.setEndTime(model.getEndDate()); + task.setIsFree("0"); + if (isTaskExist(task.getId()) == 0) { + insert(task); + } + } + + @Query("SELECT * FROM task_detail") + List loadAll(); + + @Transaction + default ArrayList loadLocalTask(TaskMarkerBeanDao taskMarkerBeanDao) { + ArrayList result = new ArrayList<>(); + List tasks = loadAll(); + for (TaskBean it : tasks) { + TaskDetailLocalModel model = new TaskDetailLocalModel(); + model.setTaskId(String.valueOf(it.getId())); + model.setTaskCode(it.getTaskCode()); + model.setDescription(it.getDescription()); + model.setCreateTime(it.getCreateTime()); + model.setStatus(it.getStatus()); + model.setCreateUserName(it.getCreateUserName()); + model.setIsFreeTask(it.getIsFree()); + ArrayList results = new ArrayList<>(); + if ("0".equals(it.getIsFree())) { + // 非自由巡检才有Marker + List markers = taskMarkerBeanDao.getMarkersByIdAndCode(String.valueOf(it.getId()), it.getTaskCode()); + for (TaskMarkerBean marker : markers) { + TaskDetailLocalModel.TaskMarkerLocalModel localModel = new TaskDetailLocalModel.TaskMarkerLocalModel(); + localModel.setMarkerId(marker.getMarkerId()); + localModel.setLng(marker.getLng()); + localModel.setLat(marker.getLat()); + localModel.setIsDetected(marker.getIsDetected()); + localModel.setDetectedTime(marker.getDetectedTime()); + + results.add(localModel); + } + } + model.setMarkerModels(results); + result.add(model); + } + return result; + } + + @Query("DELETE FROM task_detail WHERE id = :taskId AND taskCode = :taskCode") + void deleteTaskById(long taskId, String taskCode); + + @Transaction + default void deleteLocalTaskById(long taskId, String taskCode, TaskMarkerBeanDao taskMarkerBeanDao) { + TaskBean task = loadAll().stream() + .filter(it -> it.getId() == taskId && taskCode.equals(it.getTaskCode())) + .findFirst() + .orElse(null); + if (task == null) return; + deleteTaskById(taskId, taskCode); + + // 删除此任务关联的Marker。非自由巡检才有Marker + if ("0".equals(task.getIsFree())) { + List markers = taskMarkerBeanDao.getMarkersByIdAndCode(String.valueOf(task.getId()), task.getTaskCode()); + for (TaskMarkerBean marker : markers) { + taskMarkerBeanDao.delete(marker); + } + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/dao/TaskMarkerBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/dao/TaskMarkerBeanDao.java new file mode 100644 index 0000000..cc2156a --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/dao/TaskMarkerBeanDao.java @@ -0,0 +1,52 @@ +package com.casic.common.detector.gd.dao; + +import androidx.room.Dao; +import androidx.room.Delete; +import androidx.room.Insert; +import androidx.room.Query; +import androidx.room.Update; + +import com.casic.common.detector.gd.bean.TaskMarkerBean; +import com.casic.common.detector.gd.model.TaskModel; + +import java.util.List; + +@Dao +public interface TaskMarkerBeanDao { + + @Insert + void insert(TaskMarkerBean marker); + + @Query("SELECT COUNT(*) FROM task_marker_info WHERE id = :markerId") + int isMarkerExist(String markerId); + + default void saveTaskMarker(long taskId, String taskCode, TaskModel.MessageModel.TaskDetailInfosModel marker) { + if (isMarkerExist(marker.getMarkerId()) == 0) { + TaskMarkerBean bean = new TaskMarkerBean(); + bean.setId(marker.getId()); + bean.setTaskId(String.valueOf(taskId)); + bean.setTaskCode(taskCode); + bean.setMarkerId(marker.getMarkerIdReal()); + bean.setLng(marker.getLongitude()); + bean.setLat(marker.getLatitude()); + bean.setIsDetected("0"); + bean.setDetectedTime(""); + insert(bean); + } + } + + @Query("SELECT * FROM task_marker_info WHERE taskId = :taskId AND taskCode = :taskCode AND markerId = :markerId AND isDetected = :state") + TaskMarkerBean queryTaskMarkerById(String taskId, String taskCode, String markerId, String state); + + @Update + void updateLocalTaskMarkerState(TaskMarkerBean marker); + + @Query("SELECT * FROM task_marker_info WHERE isDetected = :state") + List queryMarkerByState(String state); + + @Query("SELECT * FROM task_marker_info WHERE taskId = :taskId AND taskCode = :taskCode") + List getMarkersByIdAndCode(String taskId, String taskCode); + + @Delete + void delete(TaskMarkerBean marker); +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/extensions/Long.kt b/app/src/main/java/com/casic/common/detector/gd/extensions/Long.kt deleted file mode 100644 index 6713d8d..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/extensions/Long.kt +++ /dev/null @@ -1,10 +0,0 @@ -package com.casic.common.detector.gd.extensions - -import java.text.SimpleDateFormat -import java.util.Date -import java.util.Locale - -fun Long.createTaskCode(): String { - val dateFormat = SimpleDateFormat("yyyyMMddHHmmss", Locale.CHINA) - return dateFormat.format(Date(this)) -} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoMaster.java b/app/src/main/java/com/casic/common/detector/gd/greendao/DaoMaster.java deleted file mode 100644 index 6ab94b3..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoMaster.java +++ /dev/null @@ -1,102 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import android.content.Context; -import android.database.sqlite.SQLiteDatabase; -import android.database.sqlite.SQLiteDatabase.CursorFactory; -import android.util.Log; - -import org.greenrobot.greendao.AbstractDaoMaster; -import org.greenrobot.greendao.database.StandardDatabase; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.database.DatabaseOpenHelper; -import org.greenrobot.greendao.identityscope.IdentityScopeType; - - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** - * Master of DAO (schema version 1): knows all DAOs. - */ -public class DaoMaster extends AbstractDaoMaster { - public static final int SCHEMA_VERSION = 1; - - /** Creates underlying database table using DAOs. */ - public static void createAllTables(Database db, boolean ifNotExists) { - MarkerLocalBeanDao.createTable(db, ifNotExists); - TaskLocalBeanDao.createTable(db, ifNotExists); - TaskMarkerLocalBeanDao.createTable(db, ifNotExists); - } - - /** Drops underlying database table using DAOs. */ - public static void dropAllTables(Database db, boolean ifExists) { - MarkerLocalBeanDao.dropTable(db, ifExists); - TaskLocalBeanDao.dropTable(db, ifExists); - TaskMarkerLocalBeanDao.dropTable(db, ifExists); - } - - /** - * WARNING: Drops all table on Upgrade! Use only during development. - * Convenience method using a {@link DevOpenHelper}. - */ - public static DaoSession newDevSession(Context context, String name) { - Database db = new DevOpenHelper(context, name).getWritableDb(); - DaoMaster daoMaster = new DaoMaster(db); - return daoMaster.newSession(); - } - - public DaoMaster(SQLiteDatabase db) { - this(new StandardDatabase(db)); - } - - public DaoMaster(Database db) { - super(db, SCHEMA_VERSION); - registerDaoClass(MarkerLocalBeanDao.class); - registerDaoClass(TaskLocalBeanDao.class); - registerDaoClass(TaskMarkerLocalBeanDao.class); - } - - public DaoSession newSession() { - return new DaoSession(db, IdentityScopeType.Session, daoConfigMap); - } - - public DaoSession newSession(IdentityScopeType type) { - return new DaoSession(db, type, daoConfigMap); - } - - /** - * Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} - - */ - public static abstract class OpenHelper extends DatabaseOpenHelper { - public OpenHelper(Context context, String name) { - super(context, name, SCHEMA_VERSION); - } - - public OpenHelper(Context context, String name, CursorFactory factory) { - super(context, name, factory, SCHEMA_VERSION); - } - - @Override - public void onCreate(Database db) { - Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION); - createAllTables(db, false); - } - } - - /** WARNING: Drops all table on Upgrade! Use only during development. */ - public static class DevOpenHelper extends OpenHelper { - public DevOpenHelper(Context context, String name) { - super(context, name); - } - - public DevOpenHelper(Context context, String name, CursorFactory factory) { - super(context, name, factory); - } - - @Override - public void onUpgrade(Database db, int oldVersion, int newVersion) { - Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables"); - dropAllTables(db, true); - onCreate(db); - } - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoSession.java b/app/src/main/java/com/casic/common/detector/gd/greendao/DaoSession.java deleted file mode 100644 index c8b1a20..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/DaoSession.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import java.util.Map; - -import org.greenrobot.greendao.AbstractDao; -import org.greenrobot.greendao.AbstractDaoSession; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.identityscope.IdentityScopeType; -import org.greenrobot.greendao.internal.DaoConfig; - -import com.casic.common.detector.gd.bean.MarkerLocalBean; -import com.casic.common.detector.gd.bean.TaskLocalBean; -import com.casic.common.detector.gd.bean.TaskMarkerLocalBean; - -import com.casic.common.detector.gd.greendao.MarkerLocalBeanDao; -import com.casic.common.detector.gd.greendao.TaskLocalBeanDao; -import com.casic.common.detector.gd.greendao.TaskMarkerLocalBeanDao; - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. - -/** - * {@inheritDoc} - * - * @see org.greenrobot.greendao.AbstractDaoSession - */ -public class DaoSession extends AbstractDaoSession { - - private final DaoConfig markerLocalBeanDaoConfig; - private final DaoConfig taskLocalBeanDaoConfig; - private final DaoConfig taskMarkerLocalBeanDaoConfig; - - private final MarkerLocalBeanDao markerLocalBeanDao; - private final TaskLocalBeanDao taskLocalBeanDao; - private final TaskMarkerLocalBeanDao taskMarkerLocalBeanDao; - - public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> - daoConfigMap) { - super(db); - - markerLocalBeanDaoConfig = daoConfigMap.get(MarkerLocalBeanDao.class).clone(); - markerLocalBeanDaoConfig.initIdentityScope(type); - - taskLocalBeanDaoConfig = daoConfigMap.get(TaskLocalBeanDao.class).clone(); - taskLocalBeanDaoConfig.initIdentityScope(type); - - taskMarkerLocalBeanDaoConfig = daoConfigMap.get(TaskMarkerLocalBeanDao.class).clone(); - taskMarkerLocalBeanDaoConfig.initIdentityScope(type); - - markerLocalBeanDao = new MarkerLocalBeanDao(markerLocalBeanDaoConfig, this); - taskLocalBeanDao = new TaskLocalBeanDao(taskLocalBeanDaoConfig, this); - taskMarkerLocalBeanDao = new TaskMarkerLocalBeanDao(taskMarkerLocalBeanDaoConfig, this); - - registerDao(MarkerLocalBean.class, markerLocalBeanDao); - registerDao(TaskLocalBean.class, taskLocalBeanDao); - registerDao(TaskMarkerLocalBean.class, taskMarkerLocalBeanDao); - } - - public void clear() { - markerLocalBeanDaoConfig.clearIdentityScope(); - taskLocalBeanDaoConfig.clearIdentityScope(); - taskMarkerLocalBeanDaoConfig.clearIdentityScope(); - } - - public MarkerLocalBeanDao getMarkerLocalBeanDao() { - return markerLocalBeanDao; - } - - public TaskLocalBeanDao getTaskLocalBeanDao() { - return taskLocalBeanDao; - } - - public TaskMarkerLocalBeanDao getTaskMarkerLocalBeanDao() { - return taskMarkerLocalBeanDao; - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/MarkerLocalBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/greendao/MarkerLocalBeanDao.java deleted file mode 100644 index 2f792c3..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/MarkerLocalBeanDao.java +++ /dev/null @@ -1,479 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import android.database.Cursor; -import android.database.sqlite.SQLiteStatement; - -import org.greenrobot.greendao.AbstractDao; -import org.greenrobot.greendao.Property; -import org.greenrobot.greendao.internal.DaoConfig; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.database.DatabaseStatement; - -import com.casic.common.detector.gd.bean.MarkerLocalBean; - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** - * DAO for table "MARKER_LOCAL_BEAN". -*/ -public class MarkerLocalBeanDao extends AbstractDao { - - public static final String TABLENAME = "MARKER_LOCAL_BEAN"; - - /** - * Properties of entity MarkerLocalBean.
- * Can be used for QueryBuilder and for referencing column names. - */ - public static class Properties { - public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property PipelineType = new Property(1, String.class, "pipelineType", false, "PIPELINE_TYPE"); - public final static Property PipelineDiameter = new Property(2, String.class, "pipelineDiameter", false, "PIPELINE_DIAMETER"); - public final static Property PipelineMaterial = new Property(3, String.class, "pipelineMaterial", false, "PIPELINE_MATERIAL"); - public final static Property BuryMethod = new Property(4, String.class, "buryMethod", false, "BURY_METHOD"); - public final static Property BuryDepth = new Property(5, String.class, "buryDepth", false, "BURY_DEPTH"); - public final static Property Area = new Property(6, String.class, "area", false, "AREA"); - public final static Property Line = new Property(7, String.class, "line", false, "LINE"); - public final static Property Road = new Property(8, String.class, "road", false, "ROAD"); - public final static Property ConstructTime = new Property(9, String.class, "constructTime", false, "CONSTRUCT_TIME"); - public final static Property Owner = new Property(10, String.class, "owner", false, "OWNER"); - public final static Property ObjectId = new Property(11, String.class, "objectId", false, "OBJECT_ID"); - public final static Property MarkerId = new Property(12, String.class, "markerId", false, "MARKER_ID"); - public final static Property MarkerType = new Property(13, String.class, "markerType", false, "MARKER_TYPE"); - public final static Property MarkerDepth = new Property(14, String.class, "markerDepth", false, "MARKER_DEPTH"); - public final static Property InstallationDept = new Property(15, String.class, "installationDept", false, "INSTALLATION_DEPT"); - public final static Property Lng = new Property(16, String.class, "lng", false, "LNG"); - public final static Property Lat = new Property(17, String.class, "lat", false, "LAT"); - public final static Property UpdateTime = new Property(18, String.class, "updateTime", false, "UPDATE_TIME"); - public final static Property Remark = new Property(19, String.class, "remark", false, "REMARK"); - public final static Property UnderlyingPipelineType = new Property(20, String.class, "underlyingPipelineType", false, "UNDERLYING_PIPELINE_TYPE"); - public final static Property UnderlyingPipelineDepth = new Property(21, String.class, "underlyingPipelineDepth", false, "UNDERLYING_PIPELINE_DEPTH"); - public final static Property UnderlyingPipelineDiameter = new Property(22, String.class, "underlyingPipelineDiameter", false, "UNDERLYING_PIPELINE_DIAMETER"); - public final static Property UnderlyingPipelineMaterial = new Property(23, String.class, "underlyingPipelineMaterial", false, "UNDERLYING_PIPELINE_MATERIAL"); - public final static Property ObjectType = new Property(24, String.class, "objectType", false, "OBJECT_TYPE"); - public final static Property Color = new Property(25, String.class, "color", false, "COLOR"); - public final static Property ImagePath = new Property(26, String.class, "imagePath", false, "IMAGE_PATH"); - } - - - public MarkerLocalBeanDao(DaoConfig config) { - super(config); - } - - public MarkerLocalBeanDao(DaoConfig config, DaoSession daoSession) { - super(config, daoSession); - } - - /** Creates the underlying database table. */ - public static void createTable(Database db, boolean ifNotExists) { - String constraint = ifNotExists? "IF NOT EXISTS ": ""; - db.execSQL("CREATE TABLE " + constraint + "\"MARKER_LOCAL_BEAN\" (" + // - "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id - "\"PIPELINE_TYPE\" TEXT," + // 1: pipelineType - "\"PIPELINE_DIAMETER\" TEXT," + // 2: pipelineDiameter - "\"PIPELINE_MATERIAL\" TEXT," + // 3: pipelineMaterial - "\"BURY_METHOD\" TEXT," + // 4: buryMethod - "\"BURY_DEPTH\" TEXT," + // 5: buryDepth - "\"AREA\" TEXT," + // 6: area - "\"LINE\" TEXT," + // 7: line - "\"ROAD\" TEXT," + // 8: road - "\"CONSTRUCT_TIME\" TEXT," + // 9: constructTime - "\"OWNER\" TEXT," + // 10: owner - "\"OBJECT_ID\" TEXT," + // 11: objectId - "\"MARKER_ID\" TEXT," + // 12: markerId - "\"MARKER_TYPE\" TEXT," + // 13: markerType - "\"MARKER_DEPTH\" TEXT," + // 14: markerDepth - "\"INSTALLATION_DEPT\" TEXT," + // 15: installationDept - "\"LNG\" TEXT," + // 16: lng - "\"LAT\" TEXT," + // 17: lat - "\"UPDATE_TIME\" TEXT," + // 18: updateTime - "\"REMARK\" TEXT," + // 19: remark - "\"UNDERLYING_PIPELINE_TYPE\" TEXT," + // 20: underlyingPipelineType - "\"UNDERLYING_PIPELINE_DEPTH\" TEXT," + // 21: underlyingPipelineDepth - "\"UNDERLYING_PIPELINE_DIAMETER\" TEXT," + // 22: underlyingPipelineDiameter - "\"UNDERLYING_PIPELINE_MATERIAL\" TEXT," + // 23: underlyingPipelineMaterial - "\"OBJECT_TYPE\" TEXT," + // 24: objectType - "\"COLOR\" TEXT," + // 25: color - "\"IMAGE_PATH\" TEXT);"); // 26: imagePath - } - - /** Drops the underlying database table. */ - public static void dropTable(Database db, boolean ifExists) { - String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"MARKER_LOCAL_BEAN\""; - db.execSQL(sql); - } - - @Override - protected final void bindValues(DatabaseStatement stmt, MarkerLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String pipelineType = entity.getPipelineType(); - if (pipelineType != null) { - stmt.bindString(2, pipelineType); - } - - String pipelineDiameter = entity.getPipelineDiameter(); - if (pipelineDiameter != null) { - stmt.bindString(3, pipelineDiameter); - } - - String pipelineMaterial = entity.getPipelineMaterial(); - if (pipelineMaterial != null) { - stmt.bindString(4, pipelineMaterial); - } - - String buryMethod = entity.getBuryMethod(); - if (buryMethod != null) { - stmt.bindString(5, buryMethod); - } - - String buryDepth = entity.getBuryDepth(); - if (buryDepth != null) { - stmt.bindString(6, buryDepth); - } - - String area = entity.getArea(); - if (area != null) { - stmt.bindString(7, area); - } - - String line = entity.getLine(); - if (line != null) { - stmt.bindString(8, line); - } - - String road = entity.getRoad(); - if (road != null) { - stmt.bindString(9, road); - } - - String constructTime = entity.getConstructTime(); - if (constructTime != null) { - stmt.bindString(10, constructTime); - } - - String owner = entity.getOwner(); - if (owner != null) { - stmt.bindString(11, owner); - } - - String objectId = entity.getObjectId(); - if (objectId != null) { - stmt.bindString(12, objectId); - } - - String markerId = entity.getMarkerId(); - if (markerId != null) { - stmt.bindString(13, markerId); - } - - String markerType = entity.getMarkerType(); - if (markerType != null) { - stmt.bindString(14, markerType); - } - - String markerDepth = entity.getMarkerDepth(); - if (markerDepth != null) { - stmt.bindString(15, markerDepth); - } - - String installationDept = entity.getInstallationDept(); - if (installationDept != null) { - stmt.bindString(16, installationDept); - } - - String lng = entity.getLng(); - if (lng != null) { - stmt.bindString(17, lng); - } - - String lat = entity.getLat(); - if (lat != null) { - stmt.bindString(18, lat); - } - - String updateTime = entity.getUpdateTime(); - if (updateTime != null) { - stmt.bindString(19, updateTime); - } - - String remark = entity.getRemark(); - if (remark != null) { - stmt.bindString(20, remark); - } - - String underlyingPipelineType = entity.getUnderlyingPipelineType(); - if (underlyingPipelineType != null) { - stmt.bindString(21, underlyingPipelineType); - } - - String underlyingPipelineDepth = entity.getUnderlyingPipelineDepth(); - if (underlyingPipelineDepth != null) { - stmt.bindString(22, underlyingPipelineDepth); - } - - String underlyingPipelineDiameter = entity.getUnderlyingPipelineDiameter(); - if (underlyingPipelineDiameter != null) { - stmt.bindString(23, underlyingPipelineDiameter); - } - - String underlyingPipelineMaterial = entity.getUnderlyingPipelineMaterial(); - if (underlyingPipelineMaterial != null) { - stmt.bindString(24, underlyingPipelineMaterial); - } - - String objectType = entity.getObjectType(); - if (objectType != null) { - stmt.bindString(25, objectType); - } - - String color = entity.getColor(); - if (color != null) { - stmt.bindString(26, color); - } - - String imagePath = entity.getImagePath(); - if (imagePath != null) { - stmt.bindString(27, imagePath); - } - } - - @Override - protected final void bindValues(SQLiteStatement stmt, MarkerLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String pipelineType = entity.getPipelineType(); - if (pipelineType != null) { - stmt.bindString(2, pipelineType); - } - - String pipelineDiameter = entity.getPipelineDiameter(); - if (pipelineDiameter != null) { - stmt.bindString(3, pipelineDiameter); - } - - String pipelineMaterial = entity.getPipelineMaterial(); - if (pipelineMaterial != null) { - stmt.bindString(4, pipelineMaterial); - } - - String buryMethod = entity.getBuryMethod(); - if (buryMethod != null) { - stmt.bindString(5, buryMethod); - } - - String buryDepth = entity.getBuryDepth(); - if (buryDepth != null) { - stmt.bindString(6, buryDepth); - } - - String area = entity.getArea(); - if (area != null) { - stmt.bindString(7, area); - } - - String line = entity.getLine(); - if (line != null) { - stmt.bindString(8, line); - } - - String road = entity.getRoad(); - if (road != null) { - stmt.bindString(9, road); - } - - String constructTime = entity.getConstructTime(); - if (constructTime != null) { - stmt.bindString(10, constructTime); - } - - String owner = entity.getOwner(); - if (owner != null) { - stmt.bindString(11, owner); - } - - String objectId = entity.getObjectId(); - if (objectId != null) { - stmt.bindString(12, objectId); - } - - String markerId = entity.getMarkerId(); - if (markerId != null) { - stmt.bindString(13, markerId); - } - - String markerType = entity.getMarkerType(); - if (markerType != null) { - stmt.bindString(14, markerType); - } - - String markerDepth = entity.getMarkerDepth(); - if (markerDepth != null) { - stmt.bindString(15, markerDepth); - } - - String installationDept = entity.getInstallationDept(); - if (installationDept != null) { - stmt.bindString(16, installationDept); - } - - String lng = entity.getLng(); - if (lng != null) { - stmt.bindString(17, lng); - } - - String lat = entity.getLat(); - if (lat != null) { - stmt.bindString(18, lat); - } - - String updateTime = entity.getUpdateTime(); - if (updateTime != null) { - stmt.bindString(19, updateTime); - } - - String remark = entity.getRemark(); - if (remark != null) { - stmt.bindString(20, remark); - } - - String underlyingPipelineType = entity.getUnderlyingPipelineType(); - if (underlyingPipelineType != null) { - stmt.bindString(21, underlyingPipelineType); - } - - String underlyingPipelineDepth = entity.getUnderlyingPipelineDepth(); - if (underlyingPipelineDepth != null) { - stmt.bindString(22, underlyingPipelineDepth); - } - - String underlyingPipelineDiameter = entity.getUnderlyingPipelineDiameter(); - if (underlyingPipelineDiameter != null) { - stmt.bindString(23, underlyingPipelineDiameter); - } - - String underlyingPipelineMaterial = entity.getUnderlyingPipelineMaterial(); - if (underlyingPipelineMaterial != null) { - stmt.bindString(24, underlyingPipelineMaterial); - } - - String objectType = entity.getObjectType(); - if (objectType != null) { - stmt.bindString(25, objectType); - } - - String color = entity.getColor(); - if (color != null) { - stmt.bindString(26, color); - } - - String imagePath = entity.getImagePath(); - if (imagePath != null) { - stmt.bindString(27, imagePath); - } - } - - @Override - public Long readKey(Cursor cursor, int offset) { - return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); - } - - @Override - public MarkerLocalBean readEntity(Cursor cursor, int offset) { - MarkerLocalBean entity = new MarkerLocalBean( // - cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // pipelineType - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // pipelineDiameter - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // pipelineMaterial - cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // buryMethod - cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // buryDepth - cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // area - cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // line - cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // road - cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // constructTime - cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10), // owner - cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11), // objectId - cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12), // markerId - cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13), // markerType - cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14), // markerDepth - cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15), // installationDept - cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16), // lng - cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17), // lat - cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18), // updateTime - cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19), // remark - cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20), // underlyingPipelineType - cursor.isNull(offset + 21) ? null : cursor.getString(offset + 21), // underlyingPipelineDepth - cursor.isNull(offset + 22) ? null : cursor.getString(offset + 22), // underlyingPipelineDiameter - cursor.isNull(offset + 23) ? null : cursor.getString(offset + 23), // underlyingPipelineMaterial - cursor.isNull(offset + 24) ? null : cursor.getString(offset + 24), // objectType - cursor.isNull(offset + 25) ? null : cursor.getString(offset + 25), // color - cursor.isNull(offset + 26) ? null : cursor.getString(offset + 26) // imagePath - ); - return entity; - } - - @Override - public void readEntity(Cursor cursor, MarkerLocalBean entity, int offset) { - entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setPipelineType(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); - entity.setPipelineDiameter(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); - entity.setPipelineMaterial(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); - entity.setBuryMethod(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); - entity.setBuryDepth(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); - entity.setArea(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); - entity.setLine(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); - entity.setRoad(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); - entity.setConstructTime(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9)); - entity.setOwner(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); - entity.setObjectId(cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11)); - entity.setMarkerId(cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12)); - entity.setMarkerType(cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13)); - entity.setMarkerDepth(cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14)); - entity.setInstallationDept(cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15)); - entity.setLng(cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16)); - entity.setLat(cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17)); - entity.setUpdateTime(cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18)); - entity.setRemark(cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19)); - entity.setUnderlyingPipelineType(cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20)); - entity.setUnderlyingPipelineDepth(cursor.isNull(offset + 21) ? null : cursor.getString(offset + 21)); - entity.setUnderlyingPipelineDiameter(cursor.isNull(offset + 22) ? null : cursor.getString(offset + 22)); - entity.setUnderlyingPipelineMaterial(cursor.isNull(offset + 23) ? null : cursor.getString(offset + 23)); - entity.setObjectType(cursor.isNull(offset + 24) ? null : cursor.getString(offset + 24)); - entity.setColor(cursor.isNull(offset + 25) ? null : cursor.getString(offset + 25)); - entity.setImagePath(cursor.isNull(offset + 26) ? null : cursor.getString(offset + 26)); - } - - @Override - protected final Long updateKeyAfterInsert(MarkerLocalBean entity, long rowId) { - entity.setId(rowId); - return rowId; - } - - @Override - public Long getKey(MarkerLocalBean entity) { - if(entity != null) { - return entity.getId(); - } else { - return null; - } - } - - @Override - public boolean hasKey(MarkerLocalBean entity) { - return entity.getId() != null; - } - - @Override - protected final boolean isEntityUpdateable() { - return true; - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/TaskLocalBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/greendao/TaskLocalBeanDao.java deleted file mode 100644 index fb88157..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/TaskLocalBeanDao.java +++ /dev/null @@ -1,227 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import android.database.Cursor; -import android.database.sqlite.SQLiteStatement; - -import org.greenrobot.greendao.AbstractDao; -import org.greenrobot.greendao.Property; -import org.greenrobot.greendao.internal.DaoConfig; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.database.DatabaseStatement; - -import com.casic.common.detector.gd.bean.TaskLocalBean; - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** - * DAO for table "TASK_LOCAL_BEAN". -*/ -public class TaskLocalBeanDao extends AbstractDao { - - public static final String TABLENAME = "TASK_LOCAL_BEAN"; - - /** - * Properties of entity TaskLocalBean.
- * Can be used for QueryBuilder and for referencing column names. - */ - public static class Properties { - public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property TaskCode = new Property(1, String.class, "taskCode", false, "TASK_CODE"); - public final static Property Description = new Property(2, String.class, "description", false, "DESCRIPTION"); - public final static Property CreateTime = new Property(3, String.class, "createTime", false, "CREATE_TIME"); - public final static Property Status = new Property(4, String.class, "status", false, "STATUS"); - public final static Property CreateUserName = new Property(5, String.class, "createUserName", false, "CREATE_USER_NAME"); - public final static Property StartTime = new Property(6, String.class, "startTime", false, "START_TIME"); - public final static Property EndTime = new Property(7, String.class, "endTime", false, "END_TIME"); - public final static Property IsFreeTask = new Property(8, String.class, "isFreeTask", false, "IS_FREE_TASK"); - } - - - public TaskLocalBeanDao(DaoConfig config) { - super(config); - } - - public TaskLocalBeanDao(DaoConfig config, DaoSession daoSession) { - super(config, daoSession); - } - - /** Creates the underlying database table. */ - public static void createTable(Database db, boolean ifNotExists) { - String constraint = ifNotExists? "IF NOT EXISTS ": ""; - db.execSQL("CREATE TABLE " + constraint + "\"TASK_LOCAL_BEAN\" (" + // - "\"_id\" INTEGER PRIMARY KEY ," + // 0: id - "\"TASK_CODE\" TEXT," + // 1: taskCode - "\"DESCRIPTION\" TEXT," + // 2: description - "\"CREATE_TIME\" TEXT," + // 3: createTime - "\"STATUS\" TEXT," + // 4: status - "\"CREATE_USER_NAME\" TEXT," + // 5: createUserName - "\"START_TIME\" TEXT," + // 6: startTime - "\"END_TIME\" TEXT," + // 7: endTime - "\"IS_FREE_TASK\" TEXT);"); // 8: isFreeTask - } - - /** Drops the underlying database table. */ - public static void dropTable(Database db, boolean ifExists) { - String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"TASK_LOCAL_BEAN\""; - db.execSQL(sql); - } - - @Override - protected final void bindValues(DatabaseStatement stmt, TaskLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String taskCode = entity.getTaskCode(); - if (taskCode != null) { - stmt.bindString(2, taskCode); - } - - String description = entity.getDescription(); - if (description != null) { - stmt.bindString(3, description); - } - - String createTime = entity.getCreateTime(); - if (createTime != null) { - stmt.bindString(4, createTime); - } - - String status = entity.getStatus(); - if (status != null) { - stmt.bindString(5, status); - } - - String createUserName = entity.getCreateUserName(); - if (createUserName != null) { - stmt.bindString(6, createUserName); - } - - String startTime = entity.getStartTime(); - if (startTime != null) { - stmt.bindString(7, startTime); - } - - String endTime = entity.getEndTime(); - if (endTime != null) { - stmt.bindString(8, endTime); - } - - String isFreeTask = entity.getIsFreeTask(); - if (isFreeTask != null) { - stmt.bindString(9, isFreeTask); - } - } - - @Override - protected final void bindValues(SQLiteStatement stmt, TaskLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String taskCode = entity.getTaskCode(); - if (taskCode != null) { - stmt.bindString(2, taskCode); - } - - String description = entity.getDescription(); - if (description != null) { - stmt.bindString(3, description); - } - - String createTime = entity.getCreateTime(); - if (createTime != null) { - stmt.bindString(4, createTime); - } - - String status = entity.getStatus(); - if (status != null) { - stmt.bindString(5, status); - } - - String createUserName = entity.getCreateUserName(); - if (createUserName != null) { - stmt.bindString(6, createUserName); - } - - String startTime = entity.getStartTime(); - if (startTime != null) { - stmt.bindString(7, startTime); - } - - String endTime = entity.getEndTime(); - if (endTime != null) { - stmt.bindString(8, endTime); - } - - String isFreeTask = entity.getIsFreeTask(); - if (isFreeTask != null) { - stmt.bindString(9, isFreeTask); - } - } - - @Override - public Long readKey(Cursor cursor, int offset) { - return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); - } - - @Override - public TaskLocalBean readEntity(Cursor cursor, int offset) { - TaskLocalBean entity = new TaskLocalBean( // - cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // taskCode - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // description - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // createTime - cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // status - cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // createUserName - cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // startTime - cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // endTime - cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8) // isFreeTask - ); - return entity; - } - - @Override - public void readEntity(Cursor cursor, TaskLocalBean entity, int offset) { - entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setTaskCode(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); - entity.setDescription(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); - entity.setCreateTime(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); - entity.setStatus(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); - entity.setCreateUserName(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); - entity.setStartTime(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); - entity.setEndTime(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); - entity.setIsFreeTask(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); - } - - @Override - protected final Long updateKeyAfterInsert(TaskLocalBean entity, long rowId) { - entity.setId(rowId); - return rowId; - } - - @Override - public Long getKey(TaskLocalBean entity) { - if(entity != null) { - return entity.getId(); - } else { - return null; - } - } - - @Override - public boolean hasKey(TaskLocalBean entity) { - return entity.getId() != null; - } - - @Override - protected final boolean isEntityUpdateable() { - return true; - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/greendao/TaskMarkerLocalBeanDao.java b/app/src/main/java/com/casic/common/detector/gd/greendao/TaskMarkerLocalBeanDao.java deleted file mode 100644 index e96c735..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/greendao/TaskMarkerLocalBeanDao.java +++ /dev/null @@ -1,197 +0,0 @@ -package com.casic.common.detector.gd.greendao; - -import android.database.Cursor; -import android.database.sqlite.SQLiteStatement; - -import org.greenrobot.greendao.AbstractDao; -import org.greenrobot.greendao.Property; -import org.greenrobot.greendao.internal.DaoConfig; -import org.greenrobot.greendao.database.Database; -import org.greenrobot.greendao.database.DatabaseStatement; - -import com.casic.common.detector.gd.bean.TaskMarkerLocalBean; - -// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** - * DAO for table "TASK_MARKER_LOCAL_BEAN". -*/ -public class TaskMarkerLocalBeanDao extends AbstractDao { - - public static final String TABLENAME = "TASK_MARKER_LOCAL_BEAN"; - - /** - * Properties of entity TaskMarkerLocalBean.
- * Can be used for QueryBuilder and for referencing column names. - */ - public static class Properties { - public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property TaskId = new Property(1, String.class, "taskId", false, "TASK_ID"); - public final static Property TaskCode = new Property(2, String.class, "taskCode", false, "TASK_CODE"); - public final static Property MarkerId = new Property(3, String.class, "markerId", false, "MARKER_ID"); - public final static Property Lng = new Property(4, double.class, "lng", false, "LNG"); - public final static Property Lat = new Property(5, double.class, "lat", false, "LAT"); - public final static Property IsDetected = new Property(6, String.class, "isDetected", false, "IS_DETECTED"); - public final static Property DetectedTime = new Property(7, String.class, "detectedTime", false, "DETECTED_TIME"); - } - - - public TaskMarkerLocalBeanDao(DaoConfig config) { - super(config); - } - - public TaskMarkerLocalBeanDao(DaoConfig config, DaoSession daoSession) { - super(config, daoSession); - } - - /** Creates the underlying database table. */ - public static void createTable(Database db, boolean ifNotExists) { - String constraint = ifNotExists? "IF NOT EXISTS ": ""; - db.execSQL("CREATE TABLE " + constraint + "\"TASK_MARKER_LOCAL_BEAN\" (" + // - "\"_id\" INTEGER PRIMARY KEY ," + // 0: id - "\"TASK_ID\" TEXT," + // 1: taskId - "\"TASK_CODE\" TEXT," + // 2: taskCode - "\"MARKER_ID\" TEXT," + // 3: markerId - "\"LNG\" REAL NOT NULL ," + // 4: lng - "\"LAT\" REAL NOT NULL ," + // 5: lat - "\"IS_DETECTED\" TEXT," + // 6: isDetected - "\"DETECTED_TIME\" TEXT);"); // 7: detectedTime - } - - /** Drops the underlying database table. */ - public static void dropTable(Database db, boolean ifExists) { - String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"TASK_MARKER_LOCAL_BEAN\""; - db.execSQL(sql); - } - - @Override - protected final void bindValues(DatabaseStatement stmt, TaskMarkerLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String taskId = entity.getTaskId(); - if (taskId != null) { - stmt.bindString(2, taskId); - } - - String taskCode = entity.getTaskCode(); - if (taskCode != null) { - stmt.bindString(3, taskCode); - } - - String markerId = entity.getMarkerId(); - if (markerId != null) { - stmt.bindString(4, markerId); - } - stmt.bindDouble(5, entity.getLng()); - stmt.bindDouble(6, entity.getLat()); - - String isDetected = entity.getIsDetected(); - if (isDetected != null) { - stmt.bindString(7, isDetected); - } - - String detectedTime = entity.getDetectedTime(); - if (detectedTime != null) { - stmt.bindString(8, detectedTime); - } - } - - @Override - protected final void bindValues(SQLiteStatement stmt, TaskMarkerLocalBean entity) { - stmt.clearBindings(); - - Long id = entity.getId(); - if (id != null) { - stmt.bindLong(1, id); - } - - String taskId = entity.getTaskId(); - if (taskId != null) { - stmt.bindString(2, taskId); - } - - String taskCode = entity.getTaskCode(); - if (taskCode != null) { - stmt.bindString(3, taskCode); - } - - String markerId = entity.getMarkerId(); - if (markerId != null) { - stmt.bindString(4, markerId); - } - stmt.bindDouble(5, entity.getLng()); - stmt.bindDouble(6, entity.getLat()); - - String isDetected = entity.getIsDetected(); - if (isDetected != null) { - stmt.bindString(7, isDetected); - } - - String detectedTime = entity.getDetectedTime(); - if (detectedTime != null) { - stmt.bindString(8, detectedTime); - } - } - - @Override - public Long readKey(Cursor cursor, int offset) { - return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); - } - - @Override - public TaskMarkerLocalBean readEntity(Cursor cursor, int offset) { - TaskMarkerLocalBean entity = new TaskMarkerLocalBean( // - cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // taskId - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // taskCode - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // markerId - cursor.getDouble(offset + 4), // lng - cursor.getDouble(offset + 5), // lat - cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // isDetected - cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7) // detectedTime - ); - return entity; - } - - @Override - public void readEntity(Cursor cursor, TaskMarkerLocalBean entity, int offset) { - entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setTaskId(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); - entity.setTaskCode(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); - entity.setMarkerId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); - entity.setLng(cursor.getDouble(offset + 4)); - entity.setLat(cursor.getDouble(offset + 5)); - entity.setIsDetected(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); - entity.setDetectedTime(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); - } - - @Override - protected final Long updateKeyAfterInsert(TaskMarkerLocalBean entity, long rowId) { - entity.setId(rowId); - return rowId; - } - - @Override - public Long getKey(TaskMarkerLocalBean entity) { - if(entity != null) { - return entity.getId(); - } else { - return null; - } - } - - @Override - public boolean hasKey(TaskMarkerLocalBean entity) { - return entity.getId() != null; - } - - @Override - protected final boolean isEntityUpdateable() { - return true; - } - -} diff --git a/app/src/main/java/com/casic/common/detector/gd/model/TaskModel.java b/app/src/main/java/com/casic/common/detector/gd/model/TaskModel.java index 6e853ad..67ef5fb 100644 --- a/app/src/main/java/com/casic/common/detector/gd/model/TaskModel.java +++ b/app/src/main/java/com/casic/common/detector/gd/model/TaskModel.java @@ -24,7 +24,7 @@ } public static class MessageModel { - private int id; + private Long id; private String taskCode; private String description; private String deployDate; @@ -38,11 +38,11 @@ private int isValid; private List taskDetailInfos; - public int getId() { + public Long getId() { return id; } - public void setId(int id) { + public void setId(Long id) { this.id = id; } @@ -143,25 +143,25 @@ } public static class TaskDetailInfosModel { - private int id; + private long id; private String taskId; private String taskCode; private Object markerName; - private int markerId; + private String markerId; private String markerIdReal; private double longitude; private double latitude; private int isChecked; private int isNormal; - private Object imagePath; - private Object description; - private Object finishTime; + private String imagePath; + private String description; + private String finishTime; - public int getId() { + public long getId() { return id; } - public void setId(int id) { + public void setId(long id) { this.id = id; } @@ -189,11 +189,11 @@ this.markerName = markerName; } - public int getMarkerId() { + public String getMarkerId() { return markerId; } - public void setMarkerId(int markerId) { + public void setMarkerId(String markerId) { this.markerId = markerId; } @@ -237,27 +237,27 @@ this.isNormal = isNormal; } - public Object getImagePath() { + public String getImagePath() { return imagePath; } - public void setImagePath(Object imagePath) { + public void setImagePath(String imagePath) { this.imagePath = imagePath; } - public Object getDescription() { + public String getDescription() { return description; } - public void setDescription(Object description) { + public void setDescription(String description) { this.description = description; } - public Object getFinishTime() { + public String getFinishTime() { return finishTime; } - public void setFinishTime(Object finishTime) { + public void setFinishTime(String finishTime) { this.finishTime = finishTime; } } diff --git a/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitService.kt index 7522a87..0adad51 100644 --- a/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitService.kt @@ -50,7 +50,7 @@ */ @Multipart @POST("/ems/marker/save-marker-photo.do") - suspend fun installLabel( + suspend fun install( @PartMap jsonMarker: Map, @Part fileBuffer1: MultipartBody.Part?, @Part fileBuffer2: MultipartBody.Part?, diff --git a/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitServiceManager.kt index 5f6c701..ae2a0fa 100644 --- a/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitServiceManager.kt +++ b/app/src/main/java/com/casic/common/detector/gd/retrofit/RetrofitServiceManager.kt @@ -37,22 +37,28 @@ /** * 获取标识器信息文件 */ - suspend fun getMarkerFile(userId: String, companyId: String): String { - return createApi().getMarkerFile(userId, companyId) + suspend fun getMarkerFile(): String { + val companyId = SaveKeyValues.getValue(LocaleConstant.USER_COMPANY_ID, "") as String + /** + * 后台设计如此,都传companyId + * */ + return createApi().getMarkerFile(companyId, companyId) } /** * 获取巡检工单 */ - suspend fun getTasksByUser(userName: String): String { + suspend fun getTasksByUser(): String { + val userName = SaveKeyValues.getValue(LocaleConstant.USER_NAME, "") as String return createApi().getTasksByUser(userName) } /** * 提交工单 */ - suspend fun uploadTask(userId: String, taskId: String?, state: String): String { + suspend fun uploadTask(taskId: String?, state: String): String { + val userId = SaveKeyValues.getValue(LocaleConstant.USER_ID, "") as String return createApi().uploadTask(userId, taskId.toString(), state) } @@ -60,8 +66,7 @@ * 安装新标识器 * Multipart上传图片,文件,带多参数上传 */ - suspend fun installLabel( - companyId: String, + suspend fun installMarker( recordType: String, markerObjectType: String, pipeMaterial: String, @@ -77,7 +82,6 @@ road: String, constructTime: String, ownerComp: String, - markerObjectId: String, markerId: String, markerType: String, markerDepth: String, @@ -89,6 +93,8 @@ memo: String, realPaths: ArrayList ): String { + val companyId = SaveKeyValues.getValue(LocaleConstant.USER_COMPANY_ID, "") as String + val objectId = SaveKeyValues.getValue(LocaleConstant.OBJECT_ID, "") as String val param = JsonObject() param.addProperty("companyId", companyId) param.addProperty("recordType", recordType) @@ -106,7 +112,7 @@ param.addProperty("road", road) param.addProperty("constructTime", constructTime) param.addProperty("ownerComp", ownerComp) - param.addProperty("markerObjectId", markerObjectId) + param.addProperty("markerObjectId", objectId) param.addProperty("markerId", markerId) param.addProperty("markerType", markerType) param.addProperty("markerDepth", markerDepth) @@ -133,19 +139,19 @@ return when (multiParts.size) { 3 -> { - createApi().installLabel(res, multiParts[0], multiParts[1], multiParts[2]) + createApi().install(res, multiParts[0], multiParts[1], multiParts[2]) } 2 -> { - createApi().installLabel(res, multiParts[0], multiParts[1], null) + createApi().install(res, multiParts[0], multiParts[1], null) } 1 -> { - createApi().installLabel(res, multiParts[0], null, null) + createApi().install(res, multiParts[0], null, null) } else -> { - createApi().installLabel(res, null, null, null) + createApi().install(res, null, null, null) } } } @@ -216,7 +222,7 @@ /** * 上传自由巡检过程中发现的标识器 */ - suspend fun uploadTaskMarker(taskId: String, ids: ArrayList): String { + suspend fun uploadTaskMarker(taskId: Long, ids: ArrayList): String { val param = JsonObject() param.addProperty("taskId", taskId) param.addProperty("ids", ids.joinToString(separator = ",")) diff --git a/app/src/main/java/com/casic/common/detector/gd/service/NtripConnectService.kt b/app/src/main/java/com/casic/common/detector/gd/service/NtripConnectService.kt index de9ac80..20e1a6a 100644 --- a/app/src/main/java/com/casic/common/detector/gd/service/NtripConnectService.kt +++ b/app/src/main/java/com/casic/common/detector/gd/service/NtripConnectService.kt @@ -9,10 +9,6 @@ import android.util.Log import android.view.Gravity import android.widget.Toast -import androidx.lifecycle.Lifecycle -import androidx.lifecycle.LifecycleOwner -import androidx.lifecycle.LifecycleRegistry -import androidx.lifecycle.lifecycleScope import com.casic.common.detector.gd.base.BaseApplication import com.casic.common.detector.gd.extensions.convertToGPGGA import com.casic.common.detector.gd.utils.LocaleConstant @@ -23,26 +19,24 @@ import com.pengxh.kt.lite.utils.WeakReferenceHandler import com.pengxh.kt.lite.utils.socket.tcp.OnTcpConnectStateListener import com.pengxh.kt.lite.utils.socket.tcp.TcpClient +import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.Job import kotlinx.coroutines.launch import java.io.OutputStream import java.nio.charset.StandardCharsets -class NtripConnectService : Service(), LifecycleOwner, OnTcpConnectStateListener, Handler.Callback { +class NtripConnectService : Service(), OnTcpConnectStateListener, Handler.Callback { companion object { var weakReferenceHandler: WeakReferenceHandler? = null } private val kTag = "NtripConnectService" - private val registry = LifecycleRegistry(this) private val socketClient by lazy { TcpClient(this) } private var outStream: OutputStream? = null - - override fun getLifecycle(): Lifecycle { - return registry - } + private val serviceScope = CoroutineScope(Dispatchers.Main + Job()) // 创建一个独立的CoroutineScope override fun onBind(intent: Intent?): IBinder? { return null @@ -117,7 +111,7 @@ * */ val result = String(this, StandardCharsets.UTF_8) if (result.contains("ICY 200 OK")) { - lifecycleScope.launch(Dispatchers.Main) { + serviceScope.launch { "高精度定位服务连接成功".show(this@NtripConnectService) } //连接服务即打开串口 @@ -135,12 +129,12 @@ * Content-Type: text/plain * Connection: clos * */ - lifecycleScope.launch(Dispatchers.Main) { + serviceScope.launch { "差分定位服务鉴权失败,无法解析位置".show(this@NtripConnectService) } } else { //居中显示 - lifecycleScope.launch(Dispatchers.Main) { + serviceScope.launch { val toast = Toast.makeText( this@NtripConnectService, "收到千寻数据,长度:${size}", Toast.LENGTH_SHORT ) @@ -167,7 +161,7 @@ return } - lifecycleScope.launch(Dispatchers.IO) { + serviceScope.launch(Dispatchers.IO) { socketClient.start(remoteHost, remotePort.toInt()) } } diff --git a/app/src/main/java/com/casic/common/detector/gd/utils/DataBaseManager.kt b/app/src/main/java/com/casic/common/detector/gd/utils/DataBaseManager.kt deleted file mode 100644 index aa22759..0000000 --- a/app/src/main/java/com/casic/common/detector/gd/utils/DataBaseManager.kt +++ /dev/null @@ -1,200 +0,0 @@ -package com.casic.common.detector.gd.utils - -import com.casic.common.detector.gd.base.BaseApplication -import com.casic.common.detector.gd.bean.MarkerLocalBean -import com.casic.common.detector.gd.bean.TaskLocalBean -import com.casic.common.detector.gd.bean.TaskMarkerLocalBean -import com.casic.common.detector.gd.greendao.MarkerLocalBeanDao -import com.casic.common.detector.gd.greendao.TaskLocalBeanDao -import com.casic.common.detector.gd.greendao.TaskMarkerLocalBeanDao -import com.casic.common.detector.gd.model.TaskDetailLocalModel -import com.casic.common.detector.gd.model.TaskModel - -class DataBaseManager private constructor() { - companion object { - //Kotlin委托模式双重锁单例 - val get by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) { - DataBaseManager() - } - } - - private var taskLocalBeanDao = BaseApplication.get().getDaoSession().taskLocalBeanDao - private var taskMarkerLocalBeanDao = - BaseApplication.get().getDaoSession().taskMarkerLocalBeanDao - - fun saveTaskInLocale(task: TaskModel.MessageModel) { - val bean = TaskLocalBean() - bean.id = task.id.toLong() - bean.taskCode = task.taskCode - bean.description = task.description - bean.createTime = task.deployDate - bean.status = task.status - bean.createUserName = task.creatorName - if (task.beginDate == null) { - bean.startTime = "" - } - if (task.endDate == null) { - bean.endTime = "" - } - bean.isFreeTask = "0" - if (!bean.isExist()) { - taskLocalBeanDao.insert(bean) - } - } - - fun saveTaskInLocale(bean: TaskLocalBean) { - if (!bean.isExist()) { - taskLocalBeanDao.insert(bean) - } - } - - private fun TaskLocalBean.isExist(): Boolean { - val result = taskLocalBeanDao.queryBuilder().where( - TaskLocalBeanDao.Properties.Id.eq(this.id) - ).list() - return !result.isNullOrEmpty() - } - - fun saveTaskMarkerInLocale( - taskId: Int, taskCode: String, marker: TaskModel.MessageModel.TaskDetailInfosModel - ) { - val bean = TaskMarkerLocalBean() - bean.id = marker.id.toLong() - bean.taskId = taskId.toString() - bean.taskCode = taskCode - bean.markerId = marker.markerIdReal - bean.lng = marker.longitude - bean.lat = marker.latitude - bean.isDetected = "0" - bean.detectedTime = "" - if (!bean.isExist()) { - taskMarkerLocalBeanDao.insert(bean) - } - } - - private fun TaskMarkerLocalBean.isExist(): Boolean { - val result = taskMarkerLocalBeanDao.queryBuilder().where( - TaskMarkerLocalBeanDao.Properties.Id.eq(this.id) - ).list() - return !result.isNullOrEmpty() - } - - fun loadLocalTask(): ArrayList { - val result = ArrayList() - - val tasks = taskLocalBeanDao.loadAll() - tasks.forEach { - val model = TaskDetailLocalModel() - model.taskId = it.id.toString() - model.taskCode = it.taskCode - model.description = it.description - model.createTime = it.createTime - model.status = it.status - model.createUserName = it.createUserName - model.isFreeTask = it.isFreeTask - - val markers = ArrayList() - if (it.isFreeTask == "0") { - //非自由巡检才有Marker - val markerLocalBeans = taskMarkerLocalBeanDao.queryBuilder().where( - TaskMarkerLocalBeanDao.Properties.TaskId.eq(it.id), - TaskMarkerLocalBeanDao.Properties.TaskCode.eq(it.taskCode) - ).list() - markerLocalBeans.forEach { marker -> - val localModel = TaskDetailLocalModel.TaskMarkerLocalModel() - localModel.markerId = marker.markerId - localModel.lng = marker.lng - localModel.lat = marker.lat - localModel.isDetected = marker.isDetected - localModel.detectedTime = marker.detectedTime - - markers.add(localModel) - } - } - model.markerModels = markers - result.add(model) - } - return result - } - - fun deleteLocalTaskById(taskId: String, taskCode: String) { - val task = taskLocalBeanDao.queryBuilder().where( - TaskLocalBeanDao.Properties.Id.eq(taskId), - TaskLocalBeanDao.Properties.TaskCode.eq(taskCode) - ).list().firstOrNull() ?: return - taskLocalBeanDao.delete(task) - - //删除此任务关联的Marker。非自由巡检才有Marker - if (task.isFreeTask == "0") { - val markers = taskMarkerLocalBeanDao.queryBuilder() - .where( - TaskMarkerLocalBeanDao.Properties.TaskId.eq(taskId), - TaskMarkerLocalBeanDao.Properties.TaskCode.eq(taskCode) - ).list() - markers.forEach { - taskMarkerLocalBeanDao.delete(it) - } - } - } - - fun queryTaskMarkerById( - taskId: String, taskCode: String, markerId: String, state: String - ): TaskMarkerLocalBean? { - return taskMarkerLocalBeanDao.queryBuilder() - .where( - TaskMarkerLocalBeanDao.Properties.TaskId.eq(taskId), - TaskMarkerLocalBeanDao.Properties.TaskCode.eq(taskCode), - TaskMarkerLocalBeanDao.Properties.MarkerId.eq(markerId), - TaskMarkerLocalBeanDao.Properties.IsDetected.eq(state) - ).list().firstOrNull() - } - - fun updateLocalTaskMarkerState(marker: TaskMarkerLocalBean) { - marker.isDetected = "1" - taskMarkerLocalBeanDao.update(marker) - } - - fun queryMarkerByState(state: String): List { - return taskMarkerLocalBeanDao.queryBuilder() - .where(TaskMarkerLocalBeanDao.Properties.IsDetected.eq(state)) - .list() - } - - private var markerLocalBeanDao = BaseApplication.get().getDaoSession().markerLocalBeanDao - - fun clearMarkers() { - markerLocalBeanDao.deleteAll() - } - - fun saveMarkerInLocale(bean: MarkerLocalBean) { - markerLocalBeanDao.insert(bean) - } - - fun loadMarkers(): MutableList { - return markerLocalBeanDao.loadAll() - } - - fun loadMarkersByCondition(selectedItem: String, value: String?): MutableList { - val property = when (selectedItem) { - LocaleConstant.SPINNER_ARRAY[0] -> MarkerLocalBeanDao.Properties.MarkerId - LocaleConstant.SPINNER_ARRAY[1] -> MarkerLocalBeanDao.Properties.Area - LocaleConstant.SPINNER_ARRAY[2] -> MarkerLocalBeanDao.Properties.Line - LocaleConstant.SPINNER_ARRAY[3] -> MarkerLocalBeanDao.Properties.Road - LocaleConstant.SPINNER_ARRAY[4] -> MarkerLocalBeanDao.Properties.Owner - LocaleConstant.SPINNER_ARRAY[5] -> MarkerLocalBeanDao.Properties.InstallationDept - LocaleConstant.SPINNER_ARRAY[6] -> MarkerLocalBeanDao.Properties.UpdateTime - else -> MarkerLocalBeanDao.Properties.Remark - } - return if (value == null) { - markerLocalBeanDao.queryBuilder().where(property.isNotNull).list() - } else { - markerLocalBeanDao.queryBuilder().where(property.eq(value)).list() - } - } - - fun queryMarkerById(markerId: String): List { - return markerLocalBeanDao.queryBuilder() - .where(MarkerLocalBeanDao.Properties.MarkerId.eq(markerId)) - .list() - } -} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/utils/DetectorDataBase.java b/app/src/main/java/com/casic/common/detector/gd/utils/DetectorDataBase.java new file mode 100644 index 0000000..f686cac --- /dev/null +++ b/app/src/main/java/com/casic/common/detector/gd/utils/DetectorDataBase.java @@ -0,0 +1,21 @@ +package com.casic.common.detector.gd.utils; + +import androidx.room.Database; +import androidx.room.RoomDatabase; + +import com.casic.common.detector.gd.bean.MarkerBean; +import com.casic.common.detector.gd.bean.TaskBean; +import com.casic.common.detector.gd.bean.TaskMarkerBean; +import com.casic.common.detector.gd.dao.MarkerBeanDao; +import com.casic.common.detector.gd.dao.TaskBeanDao; +import com.casic.common.detector.gd.dao.TaskMarkerBeanDao; + + +@Database(entities = {MarkerBean.class, TaskBean.class, TaskMarkerBean.class}, version = 1) +public abstract class DetectorDataBase extends RoomDatabase { + public abstract MarkerBeanDao markerBeanDao(); + + public abstract TaskBeanDao taskBeanDao(); + + public abstract TaskMarkerBeanDao taskMarkerBeanDao(); +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/utils/ExcelKit.kt b/app/src/main/java/com/casic/common/detector/gd/utils/ExcelKit.kt index 200fac7..015969f 100644 --- a/app/src/main/java/com/casic/common/detector/gd/utils/ExcelKit.kt +++ b/app/src/main/java/com/casic/common/detector/gd/utils/ExcelKit.kt @@ -1,19 +1,19 @@ package com.casic.common.detector.gd.utils -import com.casic.common.detector.gd.bean.MarkerLocalBean +import com.casic.common.detector.gd.base.BaseApplication +import com.casic.common.detector.gd.bean.MarkerBean import jxl.Workbook import jxl.read.biff.BiffException import java.io.File object ExcelKit { - fun read(filePath: String): ArrayList { - val result = ArrayList() + fun read(filePath: String): ArrayList { + val result = ArrayList() try { val workbook = Workbook.getWorkbook(File(filePath)) val sheet = workbook.getSheet(0) - for (i in 1 until sheet.rows) { - val marker = MarkerLocalBean() + val marker = MarkerBean() marker.pipelineType = sheet.getCell(0, i).contents marker.pipelineDiameter = sheet.getCell(1, i).contents marker.pipelineMaterial = sheet.getCell(2, i).contents @@ -40,9 +40,10 @@ marker.objectType = sheet.getCell(23, i).contents marker.color = sheet.getCell(24, i).contents marker.imagePath = sheet.getCell(25, i).contents - - result.add(marker) - DataBaseManager.get.saveMarkerInLocale(marker) + if (!marker.markerId.isNullOrBlank()) { + result.add(marker) + BaseApplication.get().dataBase.markerBeanDao().insert(marker) + } } workbook.close() } catch (e: BiffException) { diff --git a/app/src/main/java/com/casic/common/detector/gd/utils/LocaleConstant.kt b/app/src/main/java/com/casic/common/detector/gd/utils/LocaleConstant.kt index c658924..8ac5f76 100644 --- a/app/src/main/java/com/casic/common/detector/gd/utils/LocaleConstant.kt +++ b/app/src/main/java/com/casic/common/detector/gd/utils/LocaleConstant.kt @@ -1,6 +1,8 @@ package com.casic.common.detector.gd.utils import android.Manifest +import androidx.sqlite.db.SimpleSQLiteQuery +import androidx.sqlite.db.SupportSQLiteQuery object LocaleConstant { @@ -59,4 +61,19 @@ var BURY_METHOD_ARRAY = arrayOf("直埋", "圆管", "管块", "管沟", "架空") var IDENTIFIER_TYPE_ARRAY = arrayOf("EM30", "EM50", "EM14") var COLOR_ARRAY = arrayOf("蓝色", "橙色", "红色", "黑色", "紫色", "黄色", "绿色") + + fun buildQuery(selectedItem: String, value: String): SupportSQLiteQuery { + val columnName = when (selectedItem) { + SPINNER_ARRAY[0] -> "markerId" + SPINNER_ARRAY[1] -> "area" + SPINNER_ARRAY[2] -> "line" + SPINNER_ARRAY[3] -> "road" + SPINNER_ARRAY[4] -> "owner" + SPINNER_ARRAY[5] -> "installationDept" + SPINNER_ARRAY[6] -> "updateTime" + else -> "remark" + } + val queryBuilder = StringBuilder("SELECT * FROM marker_detail WHERE $columnName = ?") + return SimpleSQLiteQuery(queryBuilder.toString(), arrayOf(value)) + } } \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/view/InstallMarkerActivity.kt b/app/src/main/java/com/casic/common/detector/gd/view/InstallMarkerActivity.kt index daf5b0f..9e09df1 100644 --- a/app/src/main/java/com/casic/common/detector/gd/view/InstallMarkerActivity.kt +++ b/app/src/main/java/com/casic/common/detector/gd/view/InstallMarkerActivity.kt @@ -14,8 +14,9 @@ import com.amap.api.location.AMapLocation import com.casic.common.detector.gd.R import com.casic.common.detector.gd.adapter.EditableImageAdapter +import com.casic.common.detector.gd.base.BaseApplication import com.casic.common.detector.gd.base.SerialPortBaseActivity -import com.casic.common.detector.gd.bean.MarkerLocalBean +import com.casic.common.detector.gd.bean.MarkerBean import com.casic.common.detector.gd.callback.OnGetLocationListener import com.casic.common.detector.gd.callback.OnImageCompressListener import com.casic.common.detector.gd.databinding.ActivityInstallMarkerBinding @@ -27,7 +28,6 @@ import com.casic.common.detector.gd.extensions.toColor import com.casic.common.detector.gd.extensions.toObjectType import com.casic.common.detector.gd.utils.CurrentSegment -import com.casic.common.detector.gd.utils.DataBaseManager import com.casic.common.detector.gd.utils.LocaleConstant import com.casic.common.detector.gd.utils.LocationKit import com.casic.common.detector.gd.utils.RuntimeCache @@ -44,7 +44,6 @@ import com.pengxh.kt.lite.extensions.timestampToCompleteDate import com.pengxh.kt.lite.extensions.timestampToTime import com.pengxh.kt.lite.extensions.toJson -import com.pengxh.kt.lite.utils.LoadState import com.pengxh.kt.lite.utils.LoadingDialog import com.pengxh.kt.lite.utils.SaveKeyValues import com.pengxh.kt.lite.widget.TitleBarView @@ -115,8 +114,6 @@ //安装 binding.installButton.setOnClickListener { - val companyId = SaveKeyValues.getValue(LocaleConstant.USER_COMPANY_ID, "") as String - val objectId = SaveKeyValues.getValue(LocaleConstant.OBJECT_ID, "") as String if (binding.objectInclude.pipeInclude.markerObjectTypeView.text.isNullOrBlank()) { when (binding.objectInclude.objectTypeSpinner.selectedItem.toString()) { "管线" -> "请输入管线种类!".show(this) @@ -189,8 +186,7 @@ //先存本地再上传服务器 saveMarkerInLocal() - taskViewModel.installLabel( - this, companyId, + taskViewModel.installMarker( binding.objectInclude.objectTypeSpinner.selectedItem.toString().toObjectType(), binding.objectInclude.pipeInclude.markerObjectTypeView.text.toString(), binding.objectInclude.pipeInclude.materialSpinner.selectedItem.toString(), @@ -206,7 +202,6 @@ binding.objectInclude.roadView.text.toString(), binding.objectInclude.constructDateView.text.toString(), binding.objectInclude.ownerView.text.toString(), - objectId, binding.identifierInclude.identifierIdView.text.toString(), binding.identifierInclude.identifierTypeSpinner.selectedItem.toString(), "${binding.identifierInclude.identifierDeepView.text}mm", @@ -216,7 +211,19 @@ binding.identifierInclude.latView.text.toString(), binding.identifierInclude.colorSpinner.selectedItem.toString().toColor(), binding.remarkView.text.toString(), - realPaths + realPaths, + onLoading = { + LoadingDialog.show(this, "标识器安装中,请稍后...") + }, + onSuccess = { + LoadingDialog.dismiss() + clearDefaultData() + "安装成功".show(this) + }, + onFailed = { + LoadingDialog.dismiss() + it.show(this) + } ) //保存默认值 @@ -268,7 +275,7 @@ private fun saveMarkerInLocal() { val objectId = SaveKeyValues.getValue(LocaleConstant.OBJECT_ID, "") as String - val marker = MarkerLocalBean() + val marker = MarkerBean() marker.objectType = binding.objectInclude.objectTypeSpinner.selectedItem.toString() marker.pipelineType = binding.objectInclude.pipeInclude.markerObjectTypeView.text.toString() marker.pipelineMaterial = @@ -302,7 +309,7 @@ marker.remark = binding.remarkView.text.toString() marker.imagePath = realPaths.toJson() - DataBaseManager.get.saveMarkerInLocale(marker) + BaseApplication.get().dataBase.markerBeanDao().insert(marker) } private fun takePicture() { @@ -339,8 +346,8 @@ override fun initOnCreate(savedInstanceState: Bundle?) { locationKit.getCurrentLocation(true, object : OnGetLocationListener { override fun onSuccess(location: AMapLocation) { - binding.identifierInclude.lngView.text = location.longitude.toString() - binding.identifierInclude.latView.text = location.latitude.toString() + binding.identifierInclude.lngView.text = "${location.longitude}" + binding.identifierInclude.latView.text = "${location.latitude}" } override fun onError() { @@ -357,22 +364,6 @@ return ActivityInstallMarkerBinding.inflate(layoutInflater) } - override fun observeRequestState() { - taskViewModel.loadState.observe(this) { - when (it) { - LoadState.Loading -> LoadingDialog.show(this, "标识器安装中,请稍后...") - - LoadState.Success -> { - LoadingDialog.dismiss() - clearDefaultData() - "安装成功".show(this) - } - - else -> LoadingDialog.dismiss() - } - } - } - override fun setupTopBarLayout() { binding.rootView.initImmersionBar(this, true, R.color.white) binding.titleView.setOnClickListener(object : TitleBarView.OnClickListener { diff --git a/app/src/main/java/com/casic/common/detector/gd/view/MainActivity.kt b/app/src/main/java/com/casic/common/detector/gd/view/MainActivity.kt index fb0b260..a6352fb 100644 --- a/app/src/main/java/com/casic/common/detector/gd/view/MainActivity.kt +++ b/app/src/main/java/com/casic/common/detector/gd/view/MainActivity.kt @@ -5,7 +5,6 @@ import android.graphics.Color import android.media.AudioAttributes import android.media.SoundPool -import android.os.Build import android.os.Bundle import android.os.CountDownTimer import android.os.Handler @@ -31,19 +30,17 @@ import com.casic.common.detector.gd.R import com.casic.common.detector.gd.base.BaseApplication import com.casic.common.detector.gd.base.SerialPortBaseActivity -import com.casic.common.detector.gd.bean.MarkerLocalBean -import com.casic.common.detector.gd.bean.TaskLocalBean +import com.casic.common.detector.gd.bean.MarkerBean import com.casic.common.detector.gd.callback.OnGetAddressListener import com.casic.common.detector.gd.callback.OnGetLocationListener import com.casic.common.detector.gd.databinding.ActivityMainBinding import com.casic.common.detector.gd.extensions.appendDownloadUrl -import com.casic.common.detector.gd.extensions.createTaskCode import com.casic.common.detector.gd.extensions.initImmersionBar +import com.casic.common.detector.gd.model.MarkerFileModel import com.casic.common.detector.gd.model.TaskDetailLocalModel import com.casic.common.detector.gd.model.TaskModel import com.casic.common.detector.gd.service.NtripConnectService import com.casic.common.detector.gd.utils.CurrentSegment -import com.casic.common.detector.gd.utils.DataBaseManager import com.casic.common.detector.gd.utils.ExcelKit import com.casic.common.detector.gd.utils.FileType import com.casic.common.detector.gd.utils.LocaleConstant @@ -62,9 +59,7 @@ import com.pengxh.kt.lite.extensions.isNetworkConnected import com.pengxh.kt.lite.extensions.navigatePageTo import com.pengxh.kt.lite.extensions.show -import com.pengxh.kt.lite.extensions.timestampToCompleteDate import com.pengxh.kt.lite.utils.FileDownloadManager -import com.pengxh.kt.lite.utils.LoadState import com.pengxh.kt.lite.utils.LoadingDialog import com.pengxh.kt.lite.utils.SaveKeyValues import com.pengxh.kt.lite.widget.TitleBarView @@ -86,6 +81,9 @@ private val samplePopupWindow by lazy { SamplePopupWindow(this) } private val detailDialog by lazy { MarkerDetailDialog(this) } private val locationKit by lazy { LocationKit(this) } + private val markerBeanDao by lazy { BaseApplication.get().dataBase.markerBeanDao() } + private val taskBeanDao by lazy { BaseApplication.get().dataBase.taskBeanDao() } + private val taskMarkerBeanDao by lazy { BaseApplication.get().dataBase.taskMarkerBeanDao() } private val taskViewModel by lazy { ViewModelProvider(this)[TaskViewModel::class.java] } private val attr = AudioAttributes.Builder().setUsage(AudioAttributes.USAGE_ALARM) .setContentType(AudioAttributes.CONTENT_TYPE_MUSIC).build() @@ -94,7 +92,7 @@ private var isFreeTask = false private var freeTaskTitle = "" private var ids = ArrayList() - private var freeTaskId: String? = null + private var freeTaskId = 0L private var soundResourceId = 0 private var isExecuteTask = false private lateinit var aMap: AMap @@ -111,89 +109,14 @@ //地图初始化 initMapConfig(savedInstanceState) - Intent(this, NtripConnectService::class.java).also { - startService(it) - } +// Intent(this, NtripConnectService::class.java).apply { +// startService(this) +// } soundResourceId = soundPool.load(this, R.raw.ring3, 1) //右上角菜单 samplePopupWindow.setPopupMenuItem(LocaleConstant.POPUP_TITLES) samplePopupWindow.setBackgroundDrawable(null) - - //task网络请求监听 - taskViewModel.markerFileResult.observe(this) { - if (it.isSuccess) { - //清空之前的数据 - DataBaseManager.get.clearMarkers() - //下载最新的数据 - val companyId = SaveKeyValues.getValue(LocaleConstant.USER_COMPANY_ID, "") - val downloadUrl = companyId.toString().appendDownloadUrl(FileType.Excel) - Log.d(kTag, "downloadUrl => $downloadUrl") - FileDownloadManager.Builder().setDownloadFileSource(downloadUrl) - .setFileSuffix("xls").setFileSaveDirectory(createDownloadFileDir()) - .setOnFileDownloadListener(object : FileDownloadManager.OnFileDownloadListener { - override fun onDownloadStart(total: Long) { - - } - - override fun onDownloadEnd(file: File) { - lifecycleScope.launch(Dispatchers.IO) { ExcelKit.read(file.absolutePath) } - LoadingDialog.dismiss() - showMarkersOnMap() - } - - override fun onDownloadFailed(t: Throwable) { - t.printStackTrace() - } - - override fun onProgressChanged(progress: Long) { - - } - }).build().start() - } - } - taskViewModel.taskResult.observe(this) { - if (it.success == "true") { - AlertMessageDialog.Builder().setContext(this).setTitle("温馨提示") - .setMessage("您有${it.message.size}个新任务!").setPositiveButton("知道了") - .setOnDialogButtonClickListener(object : - AlertMessageDialog.OnDialogButtonClickListener { - override fun onConfirmClick() { - saveUserTasks(it) - } - }).build().show() - } - } - taskViewModel.freeTaskResult.observe(this) { - freeTaskId = it - // 自由巡检保存在本地 - val bean = TaskLocalBean() - bean.id = freeTaskId.toString().toLong() - val currentTimeMillis = System.currentTimeMillis() - bean.taskCode = currentTimeMillis.createTaskCode() - bean.description = freeTaskTitle - val time = currentTimeMillis.timestampToCompleteDate() - bean.createTime = time - bean.status = "0" - val userName = SaveKeyValues.getValue(LocaleConstant.USER_NAME, "") as String - bean.createUserName = userName - bean.startTime = time - bean.endTime = "" - bean.isFreeTask = "1" - DataBaseManager.get.saveTaskInLocale(bean) - } - taskViewModel.uploadTaskMarkerResult.observe(this) { - "自由巡检任务已完成".show(this) - ids.clear() - //清空自由巡检添加的Marker - aMap.clear() - showMarkersOnMap() - } - taskViewModel.executeTaskResult.observe(this) { - "工单任务已完成".show(this) - aMap.clear() - showMarkersOnMap() - } } override fun initEvent() { @@ -216,7 +139,7 @@ }).build().show() } else { lifecycleScope.launch(Dispatchers.Main) { - val markers = DataBaseManager.get.queryMarkerByState("0") + val markers = taskMarkerBeanDao.queryMarkerByState("0") //如果有需要补全的标识器,Popup右侧会有小圆点提示 if (markers.isNotEmpty()) { samplePopupWindow.setShowPosition(4) @@ -239,13 +162,7 @@ 3 -> uploadEvent() 4 -> completionMarker() 5 -> showRtkConfigDialog() - 6 -> { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { - SatelliteStatusDialog(context).show() - } else { - "卫星数据仅支持Android 7.0以上系统".show(context) - } - } + 6 -> SatelliteStatusDialog(context).show() } } }) @@ -268,25 +185,23 @@ //查看 binding.viewButton.setOnClickListener { - QueryMarkerDialog.Builder().setContext(this).setTitle("查看标识器") - .setSpinnerArray(LocaleConstant.SPINNER_ARRAY).setNegativeButton("取消") + QueryMarkerDialog.Builder() + .setContext(this) + .setTitle("查看标识器") + .setSpinnerArray(LocaleConstant.SPINNER_ARRAY) + .setNegativeButton("取消") .setPositiveButton("确定").setOnDialogButtonClickListener(object : QueryMarkerDialog.OnDialogButtonClickListener { override fun onConfirmClick(selectedItem: String, value: String) { //查询数据库 - lifecycleScope.launch(Dispatchers.Main) { - val markers = DataBaseManager.get.loadMarkersByCondition( - selectedItem, value - ) as ArrayList - - if (markers.isEmpty()) { - "无法查到相关数据信息,请检查您的查询条件".show(context) - } else { + val buildQuery = LocaleConstant.buildQuery(selectedItem, value) + markerBeanDao.loadMarkersByCondition(buildQuery).run { + if (isNotEmpty()) { val latitudeList = ArrayList() val longitudeList = ArrayList() - val latitude = markers.first().lat - val longitude = markers.first().lng + val latitude = first().lat + val longitude = first().lng if (latitude.isNotBlank() && longitude.isNotBlank()) { if (CoordinateConverter.isAMapDataAvailable( latitude.toDouble(), longitude.toDouble() @@ -300,10 +215,11 @@ if (latitudeList.isNotEmpty() && longitudeList.isNotEmpty()) { //移动地图到所有labelBeans的第一个点 - val center = LatLng(latitudeList.first(), longitudeList.first()) - //移动到指定经纬度 - aMap.moveCamera(CameraUpdateFactory.newLatLngZoom(center, 16f)) + val target = LatLng(latitudeList.first(), longitudeList.first()) + aMap.moveCamera(CameraUpdateFactory.newLatLngZoom(target, 16f)) } + } else { + "无法查到相关信息,请检查您的查询条件".show(context) } } } @@ -316,32 +232,39 @@ //巡检 binding.inspectionButton.setOnClickListener { - val tasks = DataBaseManager.get.loadLocalTask() - if (tasks.isNotEmpty()) { - val arrayList = ArrayList() - tasks.forEachIndexed { index, task -> - arrayList.add("任务${index + 1}:${task.taskId},${task.description}") + lifecycleScope.launch { + val tasks = withContext(Dispatchers.IO) { + taskBeanDao.loadLocalTask(taskMarkerBeanDao) } + if (tasks.isNotEmpty()) { + val arrayList = ArrayList() + tasks.forEachIndexed { index, task -> + arrayList.add("任务${index + 1}:${task.taskId},${task.description}") + } - BottomActionSheet.Builder().setContext(this).setItemTextColor(Color.BLUE) - .setActionItemTitle(arrayList) - .setOnActionSheetListener(object : BottomActionSheet.OnActionSheetListener { - override fun onActionItemClick(position: Int) { - val task = tasks[position] - SaveKeyValues.putValue(LocaleConstant.TASK_ID, task.taskId) - SaveKeyValues.putValue(LocaleConstant.TASK_CODE, task.taskCode) - executeTask(task) - } - }).build().show() - } else { - AlertMessageDialog.Builder().setContext(this).setTitle("温馨提示") - .setMessage("所有任务已完成,请点击右上角菜单下载新工单或者开始自由巡检") - .setPositiveButton("开始自由巡检").setOnDialogButtonClickListener(object : - AlertMessageDialog.OnDialogButtonClickListener { - override fun onConfirmClick() { - executeFreeTask() - } - }).build().show() + BottomActionSheet.Builder().setContext(context) + .setItemTextColor(Color.BLUE) + .setActionItemTitle(arrayList) + .setOnActionSheetListener(object : BottomActionSheet.OnActionSheetListener { + override fun onActionItemClick(position: Int) { + val task = tasks[position] + SaveKeyValues.putValue(LocaleConstant.TASK_ID, task.taskId) + SaveKeyValues.putValue(LocaleConstant.TASK_CODE, task.taskCode) + executeTask(task) + } + }).build().show() + } else { + AlertMessageDialog.Builder() + .setContext(context) + .setTitle("温馨提示") + .setMessage("所有任务已完成,请点击右上角菜单下载新工单或者开始自由巡检") + .setPositiveButton("开始自由巡检").setOnDialogButtonClickListener(object : + AlertMessageDialog.OnDialogButtonClickListener { + override fun onConfirmClick() { + executeFreeTask() + } + }).build().show() + } } } @@ -371,8 +294,11 @@ //自由巡检 binding.stopFreeTaskButton.setOnLongClickListener { - AlertMessageDialog.Builder().setContext(this).setTitle("温馨提示") - .setMessage("是否确定结束此次自由巡检任务?").setPositiveButton("是") + AlertMessageDialog.Builder() + .setContext(this) + .setTitle("温馨提示") + .setMessage("是否确定结束此次自由巡检任务?") + .setPositiveButton("是") .setOnDialogButtonClickListener(object : AlertMessageDialog.OnDialogButtonClickListener { override fun onConfirmClick() { @@ -381,14 +307,38 @@ stopSerialPortCommand() binding.stopFreeTaskButton.visibility = View.GONE - if (freeTaskId.isNullOrBlank()) { + if (freeTaskId == 0L) { "任务ID异常,无法提交任务,请联系服务器管理员".show(context) return } - freeTaskId?.apply { - taskViewModel.uploadTaskMarker(context, this, ids) - } + taskViewModel.uploadTaskMarker( + freeTaskId, + ids, + onLoading = { + LoadingDialog.show(context, "任务提交中,请稍后...") + }, + onSuccess = { + LoadingDialog.dismiss() + "自由巡检任务已完成".show(context) + ids.clear() + aMap.clear() + showMarkersOnMap() + + //删除本地数据库 + val taskCode = SaveKeyValues.getValue( + LocaleConstant.TASK_CODE, "" + ) as String + taskBeanDao.deleteLocalTaskById( + freeTaskId, taskCode, taskMarkerBeanDao + ) + SaveKeyValues.putValue(LocaleConstant.TASK_ID, "") + }, + onFailed = { + LoadingDialog.dismiss() + it.show(context) + } + ) } }).build().show() true @@ -399,25 +349,52 @@ RtkConfigDialog(this).setOnDialogButtonClickListener(object : RtkConfigDialog.OnDialogButtonClickListener { override fun onConfirmClick() { - NtripConnectService.weakReferenceHandler?.apply { - sendEmptyMessage(2024082201) - } + NtripConnectService.weakReferenceHandler?.sendEmptyMessage(2024082201) } }).show() } private fun uploadTask(taskId: String, taskCode: String, state: String) { if (isNetworkConnected()) { - val userId = SaveKeyValues.getValue(LocaleConstant.USER_ID, "") as String - taskViewModel.uploadTask(this, userId, taskId, taskCode, state) + taskViewModel.uploadTask( + taskId, state, + onLoading = { + LoadingDialog.show(this, "工单提交中,请稍后...") + }, + onSuccess = { + LoadingDialog.dismiss() + //工单提交之后,并且状态是2,删除本地Task记录 + if (state == "2") { + "工单${taskId}已提交!".show(this) + //删除本地数据库 + taskBeanDao.deleteLocalTaskById( + taskId.toLong(), taskCode, taskMarkerBeanDao + ) + SaveKeyValues.putValue(LocaleConstant.TASK_ID, "") + } else { + Log.d(kTag, "uploadTask: 仅执行工单,不删除本地工单数据") + } + aMap.clear() + showMarkersOnMap() + "工单任务已完成".show(this) + }, + onFailed = { + LoadingDialog.dismiss() + it.show(this) + } + ) } else { "网络连接已断开,请检查".show(this) } } private fun executeTask(task: TaskDetailLocalModel) { - AlertControlDialog.Builder().setContext(this).setTitle("提示").setMessage("请选择操作方式") - .setPositiveButton("执行工单").setNegativeButton("提交工单") + AlertControlDialog.Builder() + .setContext(this) + .setTitle("提示") + .setMessage("请选择操作方式") + .setPositiveButton("执行工单") + .setNegativeButton("提交工单") .setOnDialogButtonClickListener(object : AlertControlDialog.OnDialogButtonClickListener { override fun onConfirmClick() { @@ -432,7 +409,7 @@ isExecuteTask = true } else { "此工单下无标识器,将执行自由巡检任务".show(context) - freeTaskId = task.taskId + freeTaskId = task.taskId.toLong() detectMarker() } } @@ -453,7 +430,18 @@ override fun onConfirmClick(value: String) { freeTaskTitle = value val userId = SaveKeyValues.getValue(LocaleConstant.USER_ID, "") as String - taskViewModel.createFreeTask(context, userId, value) + taskViewModel.createFreeTask( + userId, value, + onLoading = {}, + onSuccess = { + freeTaskId = it + // 自由巡检保存在本地 + taskBeanDao.saveTask(it, freeTaskTitle) + }, + onFailed = { + it.show(context) + } + ) detectMarker() } @@ -481,7 +469,7 @@ if (RuntimeCache.currentSegment == CurrentSegment.FreeInspection) { //显示标识器详细信息 if (!detailDialog.isShowing) { - DataBaseManager.get.queryMarkerById(markerId).firstOrNull().apply { + markerBeanDao.queryMarkerById(markerId).firstOrNull().apply { if (this == null) { "无法查询到此ID【${markerId}】的信息".show(context) } else { @@ -501,7 +489,7 @@ //不重复标注Marker if (!ids.contains(markerId)) { - val markers = DataBaseManager.get.queryMarkerById(markerId) + val markers = markerBeanDao.queryMarkerById(markerId) if (markers.isNotEmpty()) { val marker = markers.first() val latLng = LatLng(marker.lat.toDouble(), marker.lng.toDouble()) @@ -522,16 +510,6 @@ } - override fun observeRequestState() { - taskViewModel.loadState.observe(this) { - when (it) { - LoadState.Loading -> LoadingDialog.show(this, "提交工单中,请稍后") - - else -> LoadingDialog.dismiss() - } - } - } - private fun initMapConfig(savedInstanceState: Bundle?) { binding.mapView.onCreate(savedInstanceState) aMap = binding.mapView.map @@ -592,54 +570,25 @@ private fun saveUserTasks(task: TaskModel) { task.message.forEach { model -> //保存任务详情 - DataBaseManager.get.saveTaskInLocale(model) + taskBeanDao.saveTask(model) model.taskDetailInfos.forEach { marker -> //只保存有标识器ID得数据 if (!marker.markerIdReal.isNullOrBlank()) { - DataBaseManager.get.saveTaskMarkerInLocale(model.id, model.taskCode, marker) + taskMarkerBeanDao.saveTaskMarker(model.id, model.taskCode, marker) } } } "工单下载成功!".show(this) } - private fun showMarkersOnMap() { - lifecycleScope.launch(Dispatchers.IO) { - //取缓存 - val markers = DataBaseManager.get.loadMarkers() - if (markers.isEmpty()) { - return@launch - } - val first = markers.first() - val defaultLatLng = LatLng(first.lat.toDouble(), first.lng.toDouble()) - //移动到指定经纬度 - val cameraPosition = CameraPosition(defaultLatLng, 14f, 0f, 0f) - val cameraUpdate = CameraUpdateFactory.newCameraPosition(cameraPosition) - withContext(Dispatchers.Main) { - aMap.animateCamera(cameraUpdate, 1500, null) - LoadingDialog.dismiss() - } - - markers.forEach { marker -> - val latitude = marker.lat.toString().toDouble() - val longitude = marker.lng.toString().toDouble() - //将所有设备信息转化缓存为Marker点 - val options = MarkerOptions() - .position(LatLng(latitude, longitude)) - .title(marker.markerId) - aMap.addMarker(options) - } - } - } - override fun onMarkerClick(marker: Marker?): Boolean { - marker?.apply { - showNavigationOption(title, position) + marker?.let { + showNavigationOption(it.title, it.position) } return true } - override fun onMapLongClick(p0: LatLng?) { + override fun onMapLongClick(latLng: LatLng?) { showMarkersOnMap() } @@ -664,7 +613,7 @@ } override fun onCancelClick() { - val result = DataBaseManager.get.queryMarkerById(title) + val result = markerBeanDao.queryMarkerById(title) MarkerDetailDialog(context).setMarker(result.first()).show() } }).build().show() @@ -695,20 +644,24 @@ //更新标识器数据 private fun updateMarkers() { - AlertControlDialog.Builder().setContext(this).setTitle("提示").setMessage("是否更新数据?") - .setNegativeButton("取消").setPositiveButton("确定") + AlertControlDialog.Builder() + .setContext(this) + .setTitle("提示") + .setMessage("是否更新数据?") + .setNegativeButton("取消") + .setPositiveButton("确定") .setOnDialogButtonClickListener(object : AlertControlDialog.OnDialogButtonClickListener { override fun onConfirmClick() { if (isNetworkConnected()) { - val companyId = SaveKeyValues.getValue(LocaleConstant.USER_COMPANY_ID, "") - - LoadingDialog.show(this@MainActivity, "获取标识器信息中,请稍后") - /** - * 后台设计如此,都传companyId - * */ + //清空之前的数据 + markerBeanDao.deleteAll() + aMap.clear() + //获取标识器数据 taskViewModel.getMarkerFile( - context, companyId.toString(), companyId.toString() + onLoading = {}, + onSuccess = { handleMarkerFile(it) }, + onFailed = { it.show(context) } ) } else { "网络连接已断开,请检查".show(context) @@ -721,11 +674,105 @@ }).build().show() } + private fun handleMarkerFile(it: MarkerFileModel) { + if (it.isSuccess) { + //下载最新的数据 + val companyId = SaveKeyValues.getValue(LocaleConstant.USER_COMPANY_ID, "") + val downloadUrl = companyId.toString().appendDownloadUrl(FileType.Excel) + Log.d(kTag, "handleMarkerFile => $downloadUrl") + FileDownloadManager.Builder() + .setDownloadFileSource(downloadUrl) + .setFileSuffix("xls") + .setFileSaveDirectory(createDownloadFileDir()) + .setOnFileDownloadListener(object : FileDownloadManager.OnFileDownloadListener { + override fun onDownloadStart(total: Long) { + LoadingDialog.show(context, "标识器数据解析中,请稍后...") + } + + override fun onDownloadEnd(file: File) { + lifecycleScope.launch(Dispatchers.IO) { + ExcelKit.read(file.absolutePath).apply { + renderMarkers(this) + }.also { + withContext(Dispatchers.Main) { + LoadingDialog.dismiss() + "标识器数据渲染完成".show(context) + } + } + } + } + + override fun onDownloadFailed(t: Throwable) { + t.printStackTrace() + LoadingDialog.dismiss() + "标识器数据下载失败".show(context) + } + + override fun onProgressChanged(progress: Long) { + + } + }).build().start() + } + } + + private fun showMarkersOnMap() { + lifecycleScope.launch(Dispatchers.IO) { + //取缓存 + markerBeanDao.loadAll().run { + renderMarkers(this) + }.also { + withContext(Dispatchers.Main) { + "标识器数据渲染完成".show(context) + } + } + } + } + + private fun renderMarkers(markers: List) { + if (markers.isEmpty()) { + return + } + val first = markers.first() + val defaultLatLng = LatLng(first.lat.toDouble(), first.lng.toDouble()) + //移动到指定经纬度 + val cameraPosition = CameraPosition(defaultLatLng, 14f, 0f, 0f) + val cameraUpdate = CameraUpdateFactory.newCameraPosition(cameraPosition) + aMap.animateCamera(cameraUpdate, 1500, null) + markers.forEach { marker -> + val latitude = marker.lat.toString().toDouble() + val longitude = marker.lng.toString().toDouble() + //将所有设备信息转化缓存为Marker点 + val options = MarkerOptions() + .position(LatLng(latitude, longitude)) + .title(marker.markerId) + aMap.addMarker(options) + } + } + //下载工单 private fun downloadTask() { if (isNetworkConnected()) { - val userName = SaveKeyValues.getValue(LocaleConstant.USER_NAME, "") - taskViewModel.getTasksByUser(this, userName.toString()) + taskViewModel.getTasksByUser( + onLoading = {}, + onSuccess = { + if (it.success == "true") { + AlertMessageDialog.Builder() + .setContext(this) + .setTitle("温馨提示") + .setMessage("您有${it.message.size}个新任务!") + .setPositiveButton("知道了") + .setOnDialogButtonClickListener(object : + AlertMessageDialog.OnDialogButtonClickListener { + override fun onConfirmClick() { + saveUserTasks(it) + } + }).build().show() + } + }, + onFailed = { + it.show(this) + } + ) } else { "网络连接已断开,请检查".show(this) } @@ -744,7 +791,7 @@ //标识器补全 private fun completionMarker() { val companyId = SaveKeyValues.getValue(LocaleConstant.USER_COMPANY_ID, "") as String - val markers = DataBaseManager.get.queryMarkerByState("0") + val markers = taskMarkerBeanDao.queryMarkerByState("0") if (markers.isNotEmpty()) { //TODO 逻辑没梳理明白 } else { diff --git a/app/src/main/java/com/casic/common/detector/gd/view/SearchMarkerActivity.kt b/app/src/main/java/com/casic/common/detector/gd/view/SearchMarkerActivity.kt index 4a92c97..b2e3301 100644 --- a/app/src/main/java/com/casic/common/detector/gd/view/SearchMarkerActivity.kt +++ b/app/src/main/java/com/casic/common/detector/gd/view/SearchMarkerActivity.kt @@ -1,6 +1,5 @@ package com.casic.common.detector.gd.view -import android.content.Context import android.content.res.ColorStateList import android.graphics.Color import android.hardware.Sensor @@ -13,18 +12,19 @@ import android.os.Handler import android.os.Looper import android.view.View +import androidx.core.graphics.toColorInt import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.lifecycleScope import com.amap.api.location.AMapLocation import com.amap.api.maps.AMapUtils import com.amap.api.maps.model.LatLng import com.casic.common.detector.gd.R +import com.casic.common.detector.gd.base.BaseApplication import com.casic.common.detector.gd.base.SerialPortBaseActivity import com.casic.common.detector.gd.callback.OnGetLocationListener import com.casic.common.detector.gd.databinding.ActivitySearchMarkerBinding import com.casic.common.detector.gd.model.MarkerDistanceData import com.casic.common.detector.gd.utils.CurrentSegment -import com.casic.common.detector.gd.utils.DataBaseManager import com.casic.common.detector.gd.utils.LocaleConstant import com.casic.common.detector.gd.utils.LocationKit import com.casic.common.detector.gd.utils.RuntimeCache @@ -50,8 +50,10 @@ private val context = this private val locationKit by lazy { LocationKit(this) } private val markerPoints by lazy { ArrayList() } + private val markerBeanDao by lazy { BaseApplication.get().dataBase.markerBeanDao() } + private val taskMarkerBeanDao by lazy { BaseApplication.get().dataBase.taskMarkerBeanDao() } private val taskViewModel by lazy { ViewModelProvider(this)[TaskViewModel::class.java] } - private val sensorManager by lazy { getSystemService(Context.SENSOR_SERVICE) as SensorManager } + private val sensorManager by lazy { getSystemService(SENSOR_SERVICE) as SensorManager } private val attr = AudioAttributes.Builder().setUsage(AudioAttributes.USAGE_ALARM) .setContentType(AudioAttributes.CONTENT_TYPE_MUSIC).build() private val soundPool = SoundPool.Builder().setMaxStreams(16).setAudioAttributes(attr).build() @@ -109,7 +111,7 @@ override fun initEvent() { binding.depthButton.setOnClickListener { RuntimeCache.currentSegment = CurrentSegment.DetectDepth - val result = DataBaseManager.get.queryMarkerById(markerId) + val result = markerBeanDao.queryMarkerById(markerId) if (result.isNotEmpty()) { val command = when (result.first().markerType) { "EM30" -> SerialPortCommand.DETECT_EM30_DEPTH @@ -139,7 +141,7 @@ } binding.markerInfoButton.setOnClickListener { - val result = DataBaseManager.get.queryMarkerById(markerId) + val result = markerBeanDao.queryMarkerById(markerId) if (result.isNotEmpty()) { MarkerDetailDialog(this).setMarker(result.first()).show() } else { @@ -154,12 +156,12 @@ binding.depthButton.isEnabled = true binding.depthButton.setTextColor(Color.WHITE) binding.depthButton.backgroundTintList = - ColorStateList.valueOf(Color.parseColor("#004364")) + ColorStateList.valueOf("#004364".toColorInt()) binding.markerInfoButton.isEnabled = true binding.markerInfoButton.setTextColor(Color.WHITE) binding.markerInfoButton.backgroundTintList = - ColorStateList.valueOf(Color.parseColor("#FFA200")) + ColorStateList.valueOf("#FFA200".toColorInt()) handleMarker(markerId) } @@ -171,12 +173,22 @@ if (isExecuteTask) { val taskId = SaveKeyValues.getValue(LocaleConstant.TASK_ID, "") as String val taskCode = SaveKeyValues.getValue(LocaleConstant.TASK_CODE, "") as String - val taskMarkerLocalBean = DataBaseManager.get.queryTaskMarkerById( + val marker = taskMarkerBeanDao.queryTaskMarkerById( taskId, taskCode, id, "0" ) - taskMarkerLocalBean?.apply { - taskViewModel.uploadMarker(context, this) + if (marker == null) { + return } + taskViewModel.uploadMarker( + marker.markerId, + onLoading = {}, + onSuccess = { + "标识器${marker.markerId}已探测!".show(this) + marker.isDetected = "1" + taskMarkerBeanDao.updateLocalTaskMarkerState(marker) + }, + onFailed = {} + ) } } @@ -185,15 +197,22 @@ detectDepthRunnable?.let { handler.removeCallbacks(it) } detectDepthRunnable = null LoadingDialog.dismiss() - AlertMessageDialog.Builder().setContext(context).setTitle("温馨提示") - .setMessage("标识器埋深:${depth}厘米").setPositiveButton("知道了") - .setOnDialogButtonClickListener(object : - AlertMessageDialog.OnDialogButtonClickListener { - override fun onConfirmClick() { - RuntimeCache.currentSegment = CurrentSegment.SearchMarker - sendSerialPortCommand(SerialPortCommand.SEARCH_SIGNAL) - } - }).build().show() + if (!this.isDestroyed) { + AlertMessageDialog.Builder() + .setContext(context) + .setTitle("温馨提示") + .setMessage("标识器埋深:${depth}厘米") + .setPositiveButton("知道了") + .setOnDialogButtonClickListener(object : + AlertMessageDialog.OnDialogButtonClickListener { + override fun onConfirmClick() { + RuntimeCache.currentSegment = CurrentSegment.SearchMarker + sendSerialPortCommand(SerialPortCommand.SEARCH_SIGNAL) + } + }).build().show() + } else { + "标识器埋深:${depth}厘米".show(this) + } } } @@ -201,13 +220,13 @@ if (RuntimeCache.currentSegment == CurrentSegment.SearchMarker) { if (signalEnergy > 1000) { binding.markerIdButton.isEnabled = true - binding.markerIdButton.setTextColor(Color.parseColor("#428d00")) + binding.markerIdButton.setTextColor("#428d00".toColorInt()) binding.markerIdButton.backgroundTintList = ColorStateList.valueOf( - Color.parseColor("#7EFF00") + "#7EFF00".toColorInt() ) binding.searchResultView.text = "已检测到标识器" - binding.searchResultView.setTextColor(Color.parseColor("#428d00")) + binding.searchResultView.setTextColor("#428d00".toColorInt()) binding.searchResultView.setBackgroundResource(R.mipmap.bg_small_text_green) } @@ -230,19 +249,19 @@ signalEnergy <= 700 -> { setEnergyTip( "信号较弱,可能距离较远", - Color.parseColor("#8D1717"), + "#8D1717".toColorInt(), R.mipmap.bg_large_text_red ) disableButtons() binding.searchResultView.text = "未检测到标识器" - binding.searchResultView.setTextColor(Color.parseColor("#8D1717")) + binding.searchResultView.setTextColor("#8D1717".toColorInt()) binding.searchResultView.setBackgroundResource(R.mipmap.bg_small_text_red) } signalEnergy >= 4100 -> { setEnergyTip( "信号极强,接近标识器正上方", - Color.parseColor("#428d00"), + "#428d00".toColorInt(), R.mipmap.bg_large_text_green ) } @@ -250,7 +269,7 @@ else -> { setEnergyTip( "已靠近,请继续移动位置", - Color.parseColor("#8C5700"), + "#8C5700".toColorInt(), R.mipmap.bg_large_text_yellow ) } @@ -263,8 +282,8 @@ binding.energyTipsView.setBackgroundResource(backgroundRes) } - private val colorStateList = ColorStateList.valueOf(Color.parseColor("#8A8A8A")) - private val textColor = Color.parseColor("#CCCCCC") + private val colorStateList = ColorStateList.valueOf("#8A8A8A".toColorInt()) + private val textColor = "#CCCCCC".toColorInt() private fun disableButtons() { binding.depthButton.isEnabled = false @@ -287,7 +306,7 @@ val latitude = location.latitude lifecycleScope.launch(Dispatchers.IO) { val dataPoints = ArrayList() - DataBaseManager.get.loadMarkers().forEach { + markerBeanDao.loadAll().forEach { val distance = AMapUtils.calculateLineDistance( LatLng(it.lat.toDouble(), it.lng.toDouble()), LatLng(latitude, longitude) ) @@ -332,10 +351,6 @@ return ActivitySearchMarkerBinding.inflate(layoutInflater) } - override fun observeRequestState() { - - } - override fun setupTopBarLayout() { } diff --git a/app/src/main/java/com/casic/common/detector/gd/view/SearchMarkerAuditActivity.kt b/app/src/main/java/com/casic/common/detector/gd/view/SearchMarkerAuditActivity.kt index 1dc59a7..dd4cc84 100644 --- a/app/src/main/java/com/casic/common/detector/gd/view/SearchMarkerAuditActivity.kt +++ b/app/src/main/java/com/casic/common/detector/gd/view/SearchMarkerAuditActivity.kt @@ -1,6 +1,5 @@ package com.casic.common.detector.gd.view -import android.content.Context import android.hardware.Sensor import android.hardware.SensorEvent import android.hardware.SensorEventListener @@ -13,9 +12,9 @@ import com.amap.api.maps.AMapUtils import com.amap.api.maps.model.LatLng import com.casic.common.detector.gd.R +import com.casic.common.detector.gd.base.BaseApplication import com.casic.common.detector.gd.callback.OnGetLocationListener import com.casic.common.detector.gd.databinding.ActivitySearchMarkerAuditBinding -import com.casic.common.detector.gd.utils.DataBaseManager import com.casic.common.detector.gd.utils.LocaleConstant import com.casic.common.detector.gd.utils.LocationKit import com.casic.common.detector.gd.widgets.MarkerDetailDialog @@ -36,7 +35,8 @@ private val kTag = "SearchMarkerActivity" private val context = this private val locationKit by lazy { LocationKit(this) } - private val sensorManager by lazy { getSystemService(Context.SENSOR_SERVICE) as SensorManager } + private val sensorManager by lazy { getSystemService(SENSOR_SERVICE) as SensorManager } + private val markerBeanDao by lazy { BaseApplication.get().dataBase.markerBeanDao() } private val attr = AudioAttributes.Builder().setUsage(AudioAttributes.USAGE_ALARM) .setContentType(AudioAttributes.CONTENT_TYPE_MUSIC).build() private val soundPool = SoundPool.Builder().setMaxStreams(16).setAudioAttributes(attr).build() @@ -72,7 +72,7 @@ override fun initEvent() { binding.markerInfoButton.setOnClickListener { //查库 - val result = DataBaseManager.get.queryMarkerById(nearestMarkerId) + val result = markerBeanDao.queryMarkerById(nearestMarkerId) if (result.isNotEmpty()) { MarkerDetailDialog(this).setMarker(result.first()).show() } else { @@ -90,7 +90,7 @@ val latitude = location.latitude lifecycleScope.launch(Dispatchers.IO) { val dataPoints = ArrayList() - DataBaseManager.get.loadMarkers().forEach { + markerBeanDao.loadAll().forEach { val distance = AMapUtils.calculateLineDistance( LatLng(it.lat.toDouble(), it.lng.toDouble()), LatLng(latitude, longitude) ) @@ -105,7 +105,8 @@ ) } withContext(Dispatchers.Main) { - binding.radarScanView.renderPointData(dataPoints, + binding.radarScanView.renderPointData( + dataPoints, object : RadarScanView.OnGetNearestPointCallback { override fun getNearestPoint(point: RadarScanView.DataPoint?) { if (point == null) { diff --git a/app/src/main/java/com/casic/common/detector/gd/vm/TaskViewModel.kt b/app/src/main/java/com/casic/common/detector/gd/vm/TaskViewModel.kt index ee0d63a..665d95c 100644 --- a/app/src/main/java/com/casic/common/detector/gd/vm/TaskViewModel.kt +++ b/app/src/main/java/com/casic/common/detector/gd/vm/TaskViewModel.kt @@ -1,95 +1,87 @@ package com.casic.common.detector.gd.vm -import android.content.Context -import android.util.Log -import androidx.lifecycle.MutableLiveData -import com.casic.common.detector.gd.bean.TaskMarkerLocalBean import com.casic.common.detector.gd.extensions.getResponseMessage import com.casic.common.detector.gd.extensions.getResponseState import com.casic.common.detector.gd.model.MarkerFileModel import com.casic.common.detector.gd.model.TaskModel import com.casic.common.detector.gd.retrofit.RetrofitServiceManager -import com.casic.common.detector.gd.utils.DataBaseManager -import com.casic.common.detector.gd.utils.LocaleConstant -import com.google.gson.Gson import com.google.gson.JsonParser -import com.google.gson.reflect.TypeToken import com.pengxh.kt.lite.base.BaseViewModel import com.pengxh.kt.lite.extensions.launch -import com.pengxh.kt.lite.extensions.show -import com.pengxh.kt.lite.utils.LoadState -import com.pengxh.kt.lite.utils.SaveKeyValues +import com.pengxh.kt.lite.extensions.unpackingResponse class TaskViewModel : BaseViewModel() { - - private val kTag = "TaskViewModel" - private val gson by lazy { Gson() } - val markerFileResult = MutableLiveData() - val taskResult = MutableLiveData() - val freeTaskResult = MutableLiveData() - val uploadTaskMarkerResult = MutableLiveData() - val executeTaskResult = MutableLiveData() - - fun createFreeTask(context: Context, patrollerId: String, description: String) = launch({ + fun createFreeTask( + patrollerId: String, + description: String, + onLoading: () -> Unit, + onSuccess: (Long) -> Unit, + onFailed: (String) -> Unit + ) = launch({ + onLoading() val response = RetrofitServiceManager.createFreeTask(patrollerId, description) if (response.getResponseState()) { val element = JsonParser.parseString(response) val jsonObject = element.asJsonObject - freeTaskResult.value = jsonObject.get("taskId").asInt.toString() + onSuccess(jsonObject.get("taskId").asLong) } else { - response.getResponseMessage().show(context) + onFailed(response.getResponseMessage()) } }, { - it.printStackTrace() + onFailed(it.message ?: "Unknown error") }) - fun uploadTaskMarker(context: Context, taskId: String, ids: ArrayList) = launch({ + fun uploadTaskMarker( + taskId: Long, + ids: ArrayList, + onLoading: () -> Unit, + onSuccess: () -> Unit, + onFailed: (String) -> Unit + ) = launch({ + onLoading() val response = RetrofitServiceManager.uploadTaskMarker(taskId, ids) if (response.getResponseState()) { - val element = JsonParser.parseString(response) - val jsonObject = element.asJsonObject - uploadTaskMarkerResult.value = jsonObject.get("success").asString - - //删除本地数据库 - val taskCode = SaveKeyValues.getValue(LocaleConstant.TASK_CODE, "") as String - DataBaseManager.get.deleteLocalTaskById(taskId, taskCode) - SaveKeyValues.putValue(LocaleConstant.TASK_ID, "") + onSuccess() } else { - response.getResponseMessage().show(context) + onFailed(response.getResponseMessage()) } }, { - it.printStackTrace() + onFailed(it.message ?: "Unknown error") }) - fun getMarkerFile(context: Context, userId: String, companyId: String) = launch({ - val response = RetrofitServiceManager.getMarkerFile(userId, companyId) + fun getMarkerFile( + onLoading: () -> Unit, + onSuccess: (MarkerFileModel) -> Unit, + onFailed: (String) -> Unit + ) = launch({ + onLoading() + val response = RetrofitServiceManager.getMarkerFile() if (response.getResponseState()) { - markerFileResult.value = gson.fromJson( - response, object : TypeToken() {}.type - ) + onSuccess(unpackingResponse(response)) } else { - response.getResponseMessage().show(context) + onFailed(response.getResponseMessage()) } }, { - it.printStackTrace() + onFailed(it.message ?: "Unknown error") }) - fun getTasksByUser(context: Context, userName: String) = launch({ - val response = RetrofitServiceManager.getTasksByUser(userName) + fun getTasksByUser( + onLoading: () -> Unit, + onSuccess: (TaskModel) -> Unit, + onFailed: (String) -> Unit + ) = launch({ + onLoading() + val response = RetrofitServiceManager.getTasksByUser() if (response.getResponseState()) { - taskResult.value = gson.fromJson( - response, object : TypeToken() {}.type - ) + onSuccess(unpackingResponse(response)) } else { - response.getResponseMessage().show(context) + onFailed(response.getResponseMessage()) } }, { - it.printStackTrace() + onFailed(it.message ?: "Unknown error") }) - fun installLabel( - context: Context, - companyId: String, + fun installMarker( recordType: String, markerObjectType: String, pipeMaterial: String, @@ -105,7 +97,6 @@ road: String, constructTime: String, ownerComp: String, - markerObjectId: String, markerId: String, markerType: String, markerDepth: String, @@ -115,11 +106,13 @@ latitude: String, colorType: String, memo: String, - realPaths: ArrayList + realPaths: ArrayList, + onLoading: () -> Unit, + onSuccess: () -> Unit, + onFailed: (String) -> Unit ) = launch({ - loadState.value = LoadState.Loading - val response = RetrofitServiceManager.installLabel( - companyId, + onLoading() + val response = RetrofitServiceManager.installMarker( recordType, markerObjectType, pipeMaterial, @@ -135,7 +128,6 @@ road, constructTime, ownerComp, - markerObjectId, markerId, markerType, markerDepth, @@ -148,67 +140,65 @@ realPaths ) if (response.getResponseState()) { - loadState.value = LoadState.Success + onSuccess() } else { - loadState.value = LoadState.Fail - response.getResponseMessage().show(context) + onFailed(response.getResponseMessage()) } }, { - it.printStackTrace() - loadState.value = LoadState.Fail + onFailed(it.message ?: "Unknown error") }) fun uploadTask( - context: Context, userId: String, taskId: String, taskCode: String, state: String + taskId: String, + state: String, + onLoading: () -> Unit, + onSuccess: () -> Unit, + onFailed: (String) -> Unit ) = launch({ - loadState.value = LoadState.Loading - val response = RetrofitServiceManager.uploadTask(userId, taskId, state) + onLoading() + val response = RetrofitServiceManager.uploadTask(taskId, state) if (response.getResponseState()) { - loadState.value = LoadState.Success - //工单提交之后,并且状态是2,删除本地Task记录 - if (state == "2") { - "工单${taskId}已提交!".show(context) - //删除本地数据库 - DataBaseManager.get.deleteLocalTaskById(taskId, taskCode) - SaveKeyValues.putValue(LocaleConstant.TASK_ID, "") - - val element = JsonParser.parseString(response) - val jsonObject = element.asJsonObject - executeTaskResult.value = jsonObject.get("success").asString - } else { - Log.d(kTag, "uploadTask: 仅执行工单,不删除本地工单数据") - } + onSuccess() } else { - loadState.value = LoadState.Fail - response.getResponseMessage().show(context) + onFailed(response.getResponseMessage()) } }, { - it.printStackTrace() - loadState.value = LoadState.Fail + onFailed(it.message ?: "Unknown error") }) fun uploadEvent( - context: Context, taskId: String, event: String, realPaths: ArrayList + taskId: String, + event: String, + realPaths: ArrayList, + onLoading: () -> Unit, + onSuccess: () -> Unit, + onFailed: (String) -> Unit ) = launch({ - loadState.value = LoadState.Loading + onLoading() val response = RetrofitServiceManager.uploadEvent(taskId, event, realPaths) if (response.getResponseState()) { - loadState.value = LoadState.Success + onSuccess() } else { - loadState.value = LoadState.Fail - response.getResponseMessage().show(context) + onFailed(response.getResponseMessage()) } }, { - it.printStackTrace() - loadState.value = LoadState.Fail + onFailed(it.message ?: "Unknown error") }) - fun uploadMarker(context: Context, marker: TaskMarkerLocalBean) = launch({ - //主键ID代替MarkerId - RetrofitServiceManager.uploadMarker(marker.id.toString()) - "标识器${marker.markerId}已探测!".show(context) - DataBaseManager.get.updateLocalTaskMarkerState(marker) + fun uploadMarker( + markerId: String, + onLoading: () -> Unit, + onSuccess: () -> Unit, + onFailed: (String) -> Unit + ) = launch({ + onLoading() + val response = RetrofitServiceManager.uploadMarker(markerId) + if (response.getResponseState()) { + onSuccess() + } else { + onFailed(response.getResponseMessage()) + } }, { - it.printStackTrace() + onFailed(it.message ?: "Unknown error") }) } \ No newline at end of file diff --git a/app/src/main/java/com/casic/common/detector/gd/widgets/MarkerDetailDialog.kt b/app/src/main/java/com/casic/common/detector/gd/widgets/MarkerDetailDialog.kt index 44723f2..3890584 100644 --- a/app/src/main/java/com/casic/common/detector/gd/widgets/MarkerDetailDialog.kt +++ b/app/src/main/java/com/casic/common/detector/gd/widgets/MarkerDetailDialog.kt @@ -3,8 +3,7 @@ import android.app.Dialog import android.content.Context import android.os.Bundle -import com.casic.common.detector.gd.R -import com.casic.common.detector.gd.bean.MarkerLocalBean +import com.casic.common.detector.gd.bean.MarkerBean import com.casic.common.detector.gd.databinding.DialogMarkerDetailBinding import com.casic.common.detector.gd.extensions.appendDownloadUrl import com.casic.common.detector.gd.extensions.initDialogLayoutParams @@ -15,12 +14,11 @@ import com.pengxh.kt.lite.extensions.navigatePageTo import com.pengxh.kt.lite.extensions.show -class MarkerDetailDialog(context: Context) : - Dialog(context, R.style.UserDefinedDialogStyle) { +class MarkerDetailDialog(context: Context) : Dialog(context) { - private lateinit var marker: MarkerLocalBean + private lateinit var marker: MarkerBean - fun setMarker(marker: MarkerLocalBean): MarkerDetailDialog { + fun setMarker(marker: MarkerBean): MarkerDetailDialog { this.marker = marker return this } @@ -52,7 +50,7 @@ binding.showImageView.setOnClickListener { //查数据库 - if (marker.imagePath.isNullOrEmpty()) { + if (marker.imagePath.isEmpty()) { "此标识器无图片".show(context) } else { val realPaths = ArrayList() //真实图片路径 diff --git a/app/src/main/java/com/casic/common/detector/gd/widgets/QueryMarkerDialog.kt b/app/src/main/java/com/casic/common/detector/gd/widgets/QueryMarkerDialog.kt index 304fdbb..64a1b93 100644 --- a/app/src/main/java/com/casic/common/detector/gd/widgets/QueryMarkerDialog.kt +++ b/app/src/main/java/com/casic/common/detector/gd/widgets/QueryMarkerDialog.kt @@ -6,20 +6,19 @@ import android.view.View import android.widget.AdapterView import android.widget.ArrayAdapter -import com.casic.common.detector.gd.R +import com.casic.common.detector.gd.base.BaseApplication import com.casic.common.detector.gd.databinding.DialogQueryMarkerBinding -import com.casic.common.detector.gd.utils.DataBaseManager +import com.casic.common.detector.gd.utils.LocaleConstant import com.pengxh.kt.lite.extensions.binding import com.pengxh.kt.lite.extensions.initDialogLayoutParams import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.Job import kotlinx.coroutines.launch import kotlinx.coroutines.withContext -class QueryMarkerDialog private constructor(builder: Builder) : Dialog( - builder.context, R.style.UserDefinedDialogStyle -) { +class QueryMarkerDialog private constructor(builder: Builder) : Dialog(builder.context) { private val ctx = builder.context private val title = builder.title private val spinnerArray = builder.spinnerArray @@ -71,6 +70,7 @@ } private val binding: DialogQueryMarkerBinding by binding() + private val serviceScope = CoroutineScope(Dispatchers.Main + Job()) override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -97,12 +97,11 @@ ) { //查库 val autoCompleteData = HashSet() - CoroutineScope(Dispatchers.Main).launch { + val markerBeanDao = BaseApplication.get().dataBase.markerBeanDao() + val buildQuery = LocaleConstant.buildQuery(spinnerArray[position], "") + serviceScope.launch { val labelBeans = withContext(Dispatchers.IO) { - DataBaseManager.get.loadMarkersByCondition( - spinnerArray[position], - null - ) + markerBeanDao.loadMarkersByCondition(buildQuery) } for (labelBean in labelBeans) { when (position) { diff --git a/build.gradle b/build.gradle index 987ad74..8af745d 100644 --- a/build.gradle +++ b/build.gradle @@ -1,31 +1,5 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. -buildscript { - ext.kotlin_version = '1.6.10' - repositories { - maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' } - mavenCentral() - google() - } - dependencies { - classpath 'com.android.tools.build:gradle:4.2.2' - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath 'org.greenrobot:greendao-gradle-plugin:3.3.0' - - // NOTE: Do not place your application dependencies here; they belong - // in the individual module build.gradle files - } -} - -allprojects { - repositories { - maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' } - //依赖库 - maven { url 'https://jitpack.io' } - mavenCentral() - google() - } -} - -tasks.register('clean', Delete) { - delete rootProject.buildDir +plugins { + id("com.android.application") version "8.1.0" apply false + id("org.jetbrains.kotlin.android") version "2.0.21" apply false } \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index dfadfe5..d00fa47 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Thu Nov 07 08:41:44 CST 2024 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip +distributionUrl=https\://mirrors.cloud.tencent.com/gradle/gradle-8.0-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/settings.gradle b/settings.gradle index 2763685..054e0f3 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,2 +1,20 @@ +pluginManagement { + repositories { + google() + mavenCentral() + gradlePluginPortal() + } +} + +dependencyResolutionManagement { + repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) + repositories { + maven { url = uri("https://maven.aliyun.com/repository/public") } + maven { url = uri("https://jitpack.io") } + mavenCentral() + google() + } +} + rootProject.name = "Detector" -include ':app' \ No newline at end of file +include(":app") \ No newline at end of file