调整军测,增加水准

huangwei 11 months ago
parent 46a0d04cae
commit 3ce4e1bacb
  1. BIN
      aar/base/base-release.aar
  2. 2
      aar/base/build.gradle
  3. 5
      app/README.md
  4. 166
      app/build.gradle
  5. 5
      app/proguard-rules.pro
  6. 66
      app/src/androidTest/kotlin/HelloKotlin.kt
  7. 29
      app/src/main/AndroidManifest.xml
  8. 32
      app/src/main/java/com/bingce/controlnetwork/App.java
  9. 27
      app/src/main/java/com/bingce/controlnetwork/activity/AboutActivity.java
  10. 514
      app/src/main/java/com/bingce/controlnetwork/activity/MainActivity.java
  11. 51
      app/src/main/java/com/bingce/controlnetwork/activity/MainActivityUtils.java
  12. 11
      app/src/main/java/com/bingce/controlnetwork/activity/backup/launch/BackupImportHelper.java
  13. 4
      app/src/main/java/com/bingce/controlnetwork/activity/backup/launch/ZipMigrationUtils.java
  14. 37
      app/src/main/java/com/bingce/controlnetwork/activity/fragmentcontainer/FragmentContainer.java
  15. 4
      app/src/main/java/com/bingce/controlnetwork/activity/user/OpeningRenewalVipActivity.java
  16. 106
      app/src/main/java/com/bingce/controlnetwork/activity/user/RegisterActivity.java
  17. 24
      app/src/main/java/com/bingce/controlnetwork/activity/user/UserInfoActivity.java
  18. 3
      app/src/main/java/com/bingce/controlnetwork/adapter/PointSelectAdapter.java
  19. 7
      app/src/main/java/com/bingce/controlnetwork/adapter/ToleranceDetailAdapter.java
  20. 13
      app/src/main/java/com/bingce/controlnetwork/bean/MainUserBean.java
  21. 21
      app/src/main/java/com/bingce/controlnetwork/event/RefreshEvent.java
  22. 4
      app/src/main/java/com/bingce/controlnetwork/event/RefreshToleranceTotailEvent.java
  23. 14
      app/src/main/java/com/bingce/controlnetwork/fragment/AbstractHierarchicalListFragment.java
  24. 101
      app/src/main/java/com/bingce/controlnetwork/fragment/AbstractProjectToleranceFragment.java
  25. 36
      app/src/main/java/com/bingce/controlnetwork/fragment/ComponentStationSurveyorDataListFragment.java
  26. 8
      app/src/main/java/com/bingce/controlnetwork/fragment/ComponentSurveyorStationListFragment.java
  27. 21
      app/src/main/java/com/bingce/controlnetwork/fragment/ComponentSwitchStationListFragment.java
  28. 81
      app/src/main/java/com/bingce/controlnetwork/fragment/ComponentSwitchToleranceFragment.java
  29. 82
      app/src/main/java/com/bingce/controlnetwork/fragment/MainSurveyFragment.kt
  30. 94
      app/src/main/java/com/bingce/controlnetwork/fragment/PickPointFragment.java
  31. 341
      app/src/main/java/com/bingce/controlnetwork/fragment/ProjectListFragment.java
  32. 352
      app/src/main/java/com/bingce/controlnetwork/fragment/SurveyorStationListFragment.java
  33. 173
      app/src/main/java/com/bingce/controlnetwork/fragment/ToleranceAttributeEditFragment.java
  34. 180
      app/src/main/java/com/bingce/controlnetwork/fragment/ToleranceDetailFragment.java
  35. 42
      app/src/main/java/com/bingce/controlnetwork/fragment/ToleranceManageFragment.java
  36. 45
      app/src/main/java/com/bingce/controlnetwork/fragment/ToleranceSelectFragment.java
  37. 6
      app/src/main/java/com/bingce/controlnetwork/fragment/base/BaseFragment.java
  38. 182
      app/src/main/java/com/bingce/controlnetwork/fragment/projectdetail/ProjectDetailFragment.kt
  39. 38
      app/src/main/java/com/bingce/controlnetwork/fragment/projectdetail/ProjectDetailHeightTraverseFragment.kt
  40. 31
      app/src/main/java/com/bingce/controlnetwork/fragment/projectdetail/ProjectDetailTriangleFragment.kt
  41. 34
      app/src/main/java/com/bingce/controlnetwork/fragment/projectedit/AbstractProjectEditFragment.kt
  42. 63
      app/src/main/java/com/bingce/controlnetwork/fragment/projectedit/ProjectEditTriangleFragment.kt
  43. 28
      app/src/main/java/com/bingce/controlnetwork/fragment/station/AbstractStationFragment.java
  44. 21
      app/src/main/java/com/bingce/controlnetwork/fragment/station/defaultstation/DefaultStationSetupFragment.java
  45. 9
      app/src/main/java/com/bingce/controlnetwork/fragment/station/line/AbstractLineStationSetupFragment.java
  46. 9
      app/src/main/java/com/bingce/controlnetwork/fragment/station/line/close/LineStationCloseSetupFragment.java
  47. 27
      app/src/main/java/com/bingce/controlnetwork/fragment/stationdetail/SingleStationDetailAndEditFragment.java
  48. 48
      app/src/main/java/com/bingce/controlnetwork/fragment/stationsetting/StationSettingsFragment.java
  49. 153
      app/src/main/java/com/bingce/controlnetwork/fragment/stationsurvey/StationSurveyorFragment.java
  50. 6
      app/src/main/java/com/bingce/controlnetwork/fragment/stationsurvey/angledistance/MeasureFragment.java
  51. 5
      app/src/main/java/com/bingce/controlnetwork/fragment/stationsurvey/base/MeasureBaseFragment.java
  52. 123
      app/src/main/java/com/bingce/controlnetwork/fragment/stationsurvey/heighttraverse/MeasureHeightTraverseFragment.kt
  53. 23
      app/src/main/java/com/bingce/controlnetwork/fragment/stationsurvey/heighttraverse/MeasureHeightTraverseSubFragment.java
  54. 145
      app/src/main/java/com/bingce/controlnetwork/func/level/activity/LevelStationSettingActivity.kt
  55. 38
      app/src/main/java/com/bingce/controlnetwork/func/level/adapter/LevelRouteListAdapter.java
  56. 15
      app/src/main/java/com/bingce/controlnetwork/func/level/adapter/LevelRouteListViewHolder.java
  57. 13
      app/src/main/java/com/bingce/controlnetwork/func/level/constant/LevelConstant.kt
  58. 55
      app/src/main/java/com/bingce/controlnetwork/func/level/constant/LevelStationSettingContant.kt
  59. 129
      app/src/main/java/com/bingce/controlnetwork/func/level/dialog/LevelToleranceTipsFragment.java
  60. 231
      app/src/main/java/com/bingce/controlnetwork/func/level/export/LevelExportIDetection.kt
  61. 218
      app/src/main/java/com/bingce/controlnetwork/func/level/export/LevelExportSingalHeight.kt
  62. 86
      app/src/main/java/com/bingce/controlnetwork/func/level/fragment/LevelIDetectionCreateFragment.java
  63. 91
      app/src/main/java/com/bingce/controlnetwork/func/level/fragment/LevelInputAllowFragment.java
  64. 102
      app/src/main/java/com/bingce/controlnetwork/func/level/fragment/LevelInputFragment.java
  65. 382
      app/src/main/java/com/bingce/controlnetwork/func/level/fragment/LevelRouteCreateEditFragment.kt
  66. 158
      app/src/main/java/com/bingce/controlnetwork/func/level/fragment/LevelRouteFragment.kt
  67. 248
      app/src/main/java/com/bingce/controlnetwork/func/level/fragment/LevelSelectExportFragment.java
  68. 185
      app/src/main/java/com/bingce/controlnetwork/func/level/fragment/LevelStationSettingConditionFragment.kt
  69. 201
      app/src/main/java/com/bingce/controlnetwork/func/level/fragment/LevelStationSettingInformationFragment.kt
  70. 497
      app/src/main/java/com/bingce/controlnetwork/func/level/fragment/LevelSurveyFragment.java
  71. 380
      app/src/main/java/com/bingce/controlnetwork/func/level/fragment/LevelSurveySubFragment.java
  72. 107
      app/src/main/java/com/bingce/controlnetwork/func/level/fragment/LevelSurveyorHomeFragment.java
  73. 162
      app/src/main/java/com/bingce/controlnetwork/func/level/fragment/ProjectDetailLevelFragment.java
  74. 282
      app/src/main/java/com/bingce/controlnetwork/func/level/fragment/ProjectEditForLevelFragment.java
  75. 82
      app/src/main/java/com/bingce/controlnetwork/func/level/fragment/SelectLevelNextStationTypeFragment.java
  76. 136
      app/src/main/java/com/bingce/controlnetwork/func/level/fragment/TestDataSelectLevelFragment.java
  77. 234
      app/src/main/java/com/bingce/controlnetwork/func/level/idetection/LevelIDetectionCalUtil.kt
  78. 101
      app/src/main/java/com/bingce/controlnetwork/func/level/idetection/LevelIDetectionListActivity.kt
  79. 371
      app/src/main/java/com/bingce/controlnetwork/func/level/idetection/LevelIDetectionRecordActivity.kt
  80. 31
      app/src/main/java/com/bingce/controlnetwork/func/level/idetection/LevelIDetectionSampleActivity.kt
  81. 173
      app/src/main/java/com/bingce/controlnetwork/func/level/idetection/LevelIDetectionStationSettingActivity.kt
  82. 14
      app/src/main/java/com/bingce/controlnetwork/func/level/idetection/LevelIDetectionSurveyorData.kt
  83. 34
      app/src/main/java/com/bingce/controlnetwork/func/level/idetection/adapter/LevelIDetectionListAdapter.java
  84. 15
      app/src/main/java/com/bingce/controlnetwork/func/level/idetection/adapter/LevelIDetectionListHolder.java
  85. 120
      app/src/main/java/com/bingce/controlnetwork/func/level/idetection/adapter/LevelIDetectionRecordAdapter.java
  86. 15
      app/src/main/java/com/bingce/controlnetwork/func/level/idetection/adapter/LevelIDetectionRecordHolder.java
  87. 247
      app/src/main/java/com/bingce/controlnetwork/func/level/idetection/util/LevelIDetectionFindUtil.kt
  88. 39
      app/src/main/java/com/bingce/controlnetwork/func/level/idetection/viewmodel/LevelIDetectionListVm.kt
  89. 361
      app/src/main/java/com/bingce/controlnetwork/func/level/idetection/viewmodel/LevelIDetectionRecordVm.kt
  90. 8
      app/src/main/java/com/bingce/controlnetwork/func/level/sendreceive/ILevelBackData.kt
  91. 85
      app/src/main/java/com/bingce/controlnetwork/func/level/sendreceive/LevelRequest.kt
  92. 60
      app/src/main/java/com/bingce/controlnetwork/func/level/sendreceive/LevelRequestRelease.kt
  93. 8
      app/src/main/java/com/bingce/controlnetwork/func/level/sendreceive/LevelRequestState.kt
  94. 175
      app/src/main/java/com/bingce/controlnetwork/func/level/sendreceive/LevelRequestTest.kt
  95. 84
      app/src/main/java/com/bingce/controlnetwork/func/level/util/LevelDateUtil.java
  96. 704
      app/src/main/java/com/bingce/controlnetwork/func/level/util/LevelExportUtilTj.kt
  97. 38
      app/src/main/java/com/bingce/controlnetwork/func/level/util/LevelPointUtilTj.kt
  98. 271
      app/src/main/java/com/bingce/controlnetwork/func/level/util/LevelStationSettingLastData.kt
  99. 132
      app/src/main/java/com/bingce/controlnetwork/func/level/util/LevelStationSettingUtil.kt
  100. 237
      app/src/main/java/com/bingce/controlnetwork/func/level/util/LevelStationUtilTj.kt
  101. Some files were not shown because too many files have changed in this diff Show More

Binary file not shown.

@ -0,0 +1,2 @@
configurations.maybeCreate("default")
artifacts.add("default", file('base-release.aar'))

@ -0,0 +1,5 @@
打包注意事项:
1.检查 Test.java 中的DEBUG是否为false;
2.检查 打包版本号;
3.检查数据库版本号;
4.检查changelog.xml内容

@ -1,23 +1,22 @@
//import com.bingce.AndroidSdk import com.bingce.*
//import com.bingce.SurveyorVersionUtils
apply plugin: 'com.android.application' apply plugin: 'com.android.application'
apply plugin: 'org.jetbrains.kotlin.android' apply plugin: 'org.jetbrains.kotlin.android'
apply plugin: 'kotlin-kapt' apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-parcelize' apply plugin: 'kotlin-parcelize'
apply from: "../control_common/config.gradle" apply from: "../control_common/config.gradle"
android { android {
namespace 'com.bingce.controlnetwork' useLibrary Libs.httpLegacy
useLibrary "org.apache.http.legacy" compileSdk AndroidSdk.compileSdkVersion
compileSdk 34 namespace App.ControlNetwork.applicationId
defaultConfig { defaultConfig {
applicationId "com.bingce.controlnetwork" minSdkVersion AndroidSdk.minSdkVersion
minSdkVersion 26 targetSdkVersion AndroidSdk.targetSdkVersion
targetSdkVersion 34
ndk {} ndk {}
flavorDimensions "custom_made" testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true multiDexEnabled true
javaCompileOptions { javaCompileOptions {
@ -28,11 +27,11 @@ android {
] ]
} }
} }
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
} }
buildFeatures { buildFeatures {
viewBinding true viewBinding true
buildConfig true
} }
signingConfigs { signingConfigs {
@ -41,47 +40,82 @@ android {
} }
} }
def gitCommit = 'git rev-parse --short HEAD'.execute().text.trim()
System.out.println("base-java -- version:${gitCommit}")
buildTypes { buildTypes {
debug { debug {
signingConfig signingConfigs.debug signingConfig signingConfigs.debug
buildConfigField "String", "codeVersion", "\"${gitCommit}\"" minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
} }
release { release {
minifyEnabled true minifyEnabled true
shrinkResources true shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
buildConfigField "String", "codeVersion", "\"${gitCommit}\""
} }
} }
//key
// tj61365--
def flavor = "tj61365"
//key
//bingce--
//pro--
//tj61365--
//intl--
//intl_pro--
def flavor = "bingce"
// //
flavorDimensions 'custom_made' flavorDimensions = Arrays.asList("custom_made")
productFlavors { productFlavors {
// if (flavor == "bingce") {
bingce {
dimension 'custom_made'
buildConfigField "int", "CHANNEL_TYPE", "com.bingce.AppChannel.CUSTOM_CONTROL_PUBLIC"
versionCode _versionCode
versionName _versionName
}
}
//app
if (flavor == "pro") {
pro {//
dimension 'custom_made'
buildConfigField "int", "CHANNEL_TYPE", "com.bingce.AppChannel.CUSTOM_CONTROL_PRO"
versionCode(_versionCode * 100)
versionName _versionName
}
}
if (flavor == "tj61365") { if (flavor == "tj61365") {
// tj61365 { tj61365 {//
// dimension 'custom_made' dimension 'custom_made'
// buildConfigField "int", "CHANNEL_TYPE", "com.bingce.AppChannel.CUSTOM_CONTROL_TJ_61365" buildConfigField "int", "CHANNEL_TYPE", "com.bingce.AppChannel.CUSTOM_CONTROL_TJ_61365"
// versionCode(_versionCode * 100) versionCode(_versionCode * 100)
// versionName _versionName//"1.3.1" versionName _versionName
// } }
}
if (flavor == "intl") {
intl {//
dimension 'custom_made'
buildConfigField "int", "CHANNEL_TYPE", "com.bingce.AppChannel.CUSTOM_CONTROL_INTERNATIONAL"
versionCode(_versionCode * 100)
versionName _versionName
}
}
if (flavor == "intl_pro") {
intl_pro {//
dimension 'custom_made'
buildConfigField "int", "CHANNEL_TYPE", "com.bingce.AppChannel.CUSTOM_CONTROL_INTERNATIONAL_PRO"
versionCode(_versionCode * 100)
versionName _versionName
}
} }
} }
splits { splits {
// Split apks on build target ABI, view all options for the splits here:
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
abi { abi {
enable true enable true
reset() reset()
include 'arm64-v8a', 'armeabi-v7a'//,'armeabi-v7a', 'x86'//, 'x86_64', 'mips','armeabi', include 'arm64-v8a'//,'armeabi-v7a', 'x86'//, 'x86_64', 'mips','armeabi',
} }
} }
@ -94,50 +128,74 @@ android {
exclude 'META-INF/NOTICE' exclude 'META-INF/NOTICE'
exclude 'META-INF/*.kotlin_module' exclude 'META-INF/*.kotlin_module'
exclude '/META-INF/{AL2.0,LGPL2.1}'//compose
// exclude 'schemaorg_apache_xmlbeans/**'
// exclude 'assets/org/apache/**'
// exclude 'org/apache/**'
// exclude 'font_metrics.properties'
} }
lintOptions { lintOptions {
abortOnError false abortOnError false
disable 'GoogleAppIndexingWarning' disable 'GoogleAppIndexingWarning'
} }
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
} }
dependencies { dependencies {
implementation fileTree(include: ['*.jar', '*.aar'], dir: '../control_common/libs') implementation fileTree(include: ['*.jar', '*.aar'], dir: 'libs')
project.ext.dependencies.each { k, v ->
implementation v
}
project.ext.kapt.each { k, v -> kapt v }
implementation 'com.google.android.gms:play-services-auth:20.7.0'
implementation project(':control_common') implementation project(':control_common')
def moduleName = new ModuleName(project)
implementation project(moduleName.bingceModule("appBase"))
implementation project(moduleName.bingceModule("repository"))
implementation project(moduleName.bingceModule("base"))
implementation project(moduleName.bingceModule("leancloud"))
implementation project(moduleName.bingceModule("base-java"))
implementation project(moduleName.bingceModule("utils"))
implementation project(moduleName.bingceModule("coordlib"))
implementation project(moduleName.bingceModule("device"))
implementation project(moduleName.bingceModule("device-ui"))
implementation project(moduleName.bingceModule("rtk"))
implementation project(moduleName.bingceModule("totalstation"))
implementation project(moduleName.bingceModule("level"))
implementation project(moduleName.bingceModule("bcdialog-style"))
implementation project(moduleName.openSourceModule("utilcode"))
implementation project(moduleName.openSourceModule("colorful"))//
implementation project(moduleName.openSourceModule("dragExpandGrid"))//
implementation project(moduleName.openSourceModule("lsettingitemlibrary"))//
implementation project(moduleName.openSourceModule("spinkit"))//loading控件 使
implementation project(moduleName.openSourceModule("splashview"))//广view
implementation project(moduleName.openSourceModule("poishadowjar"))//excel
implementation project(moduleName.openSourceModule("safFilePicker"))//
implementation project(moduleName.openSourceModule("fastjson"))
implementation project(moduleName.openSourceModule("agentweb"))
implementation project(":opensource:exFilePicker")
implementation project(":sdk:tensorFlowTTS")//
implementation Libs.RxImagePicker.core
// implementation Libs.RxImagePicker.support
// implementation Libs.RxImagePicker.supportWechat
constraints { constraints {
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.8.0") { implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.9.10") {
because("kotlin-stdlib-jdk7 is now a part of kotlin-stdlib") because("kotlin-stdlib-jdk7 is now a part of kotlin-stdlib")
} }
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.0") { implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.10") {
because("kotlin-stdlib-jdk8 is now a part of kotlin-stdlib") because("kotlin-stdlib-jdk8 is now a part of kotlin-stdlib")
} }
} }
def leanCloudVersion = "8.2.16" // implementation "cn.leancloud:storage-android:8.2.5"
implementation "cn.leancloud:storage-android:$leanCloudVersion" // implementation "cn.leancloud:realtime-android:8.2.5"
implementation "cn.leancloud:realtime-android:$leanCloudVersion" implementation Libs.LeanCloud.storage
implementation Libs.LeanCloud.realtime
implementation 'com.getbase:floatingactionbutton:1.10.1'
implementation 'com.github.razir.progressbutton:progressbutton:2.1.0'
implementation "com.mikepenz:materialdrawer:6.1.2"
testImplementation "junit:junit:4.13.2" testImplementation "junit:junit:4.13.2"
androidTestImplementation "androidx.test:runner:1.1.0" androidTestImplementation "androidx.test:runner:1.1.0"
androidTestImplementation "androidx.test:rules:1.1.0"
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
implementation 'com.google.android.gms:play-services-auth:20.7.0'
def imagepicker = "2.5.6" project.ext.dependencies.each { k, v -> implementation v }
implementation "com.github.qingmei2:rximagepicker:$imagepicker" project.ext.kapt.each { k, v -> kapt v }
// implementation "com.github.qingmei2:rximagepicker_support:$imagepicker"
// implementation "com.github.qingmei2:rximagepicker_support_wechat:$imagepicker"
} }

@ -31,12 +31,7 @@ public static final int *;
-keep class androidx.appcompat.widget.SearchView { *; } -keep class androidx.appcompat.widget.SearchView { *; }
-keep class cn.aigestudio.datepicker.**{*;} -keep class cn.aigestudio.datepicker.**{*;}
-keep class io.realm.annotations.RealmModule
-keep @io.realm.annotations.RealmModule class *
-keep class io.realm.internal.Keep
-keep @io.realm.internal.Keep class * { *; }
-dontwarn javax.** -dontwarn javax.**
-dontwarn io.realm.**
-keep class com.tencent.mm.sdk.** { -keep class com.tencent.mm.sdk.** {
*; *;

@ -10,39 +10,39 @@ class HelloKotlin {
@Test @Test
fun test() { fun test() {
runBlocking { // runBlocking {
//
launch { // launch {
Log.d("hwhw", "请求1") // Log.d("hwhw", "请求1")
//
delay(1000) // delay(1000)
Log.d("hwhw", "请求1 delay") // Log.d("hwhw", "请求1 delay")
//
val apiCall = RetrofitClient.apiCall { // val apiCall = RetrofitClient.apiCall {
RetrofitClient.createService<CommonService>().getPassageData() // RetrofitClient.createService<CommonService>().getPassageData()
} // }
//
apiCall?.let { // apiCall?.let {
Log.d("hwhw", "请求成功1,$it") // Log.d("hwhw", "请求成功1,$it")
} // }
} // }
//
launch { // launch {
Log.d("hwhw", "请求2") // Log.d("hwhw", "请求2")
//
delay(1000) // delay(1000)
Log.d("hwhw", "请求2 delay") // Log.d("hwhw", "请求2 delay")
//
val apiCall1 = RetrofitClient.apiCall { // val apiCall1 = RetrofitClient.apiCall {
RetrofitClient.createService<CommonService>().getPassageData() // RetrofitClient.createService<CommonService>().getPassageData()
} // }
apiCall1?.let { // apiCall1?.let {
Log.d("hwhw", "请求成功2,$it") // Log.d("hwhw", "请求成功2,$it")
} // }
} // }
//
//
} // }
} }

@ -179,6 +179,35 @@
android:name=".activity.user.InputEmailActivity" android:name=".activity.user.InputEmailActivity"
android:configChanges="orientation|keyboardHidden|screenSize" android:configChanges="orientation|keyboardHidden|screenSize"
android:exported="true" /> android:exported="true" />
<activity
android:name=".newui.stationsetting.StationSettingsActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:exported="true" />
<activity
android:name=".newui.projectedit.ProjectCreateEditActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:exported="true" />
<activity
android:name=".func.level.activity.LevelStationSettingActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:exported="true" />
<activity
android:name=".func.level.idetection.LevelIDetectionRecordActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="i角检测" />
<activity
android:name=".func.level.idetection.LevelIDetectionListActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="i角检测" />
<activity
android:name=".func.level.idetection.LevelIDetectionSampleActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="i角检测" />
<activity
android:name=".func.level.idetection.LevelIDetectionStationSettingActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="i角检测" />
</application> </application>
</manifest> </manifest>

@ -5,6 +5,7 @@ import static com.bingce.AppChannel.customChannel;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.net.Uri; import android.net.Uri;
import android.text.TextUtils;
import android.util.Log; import android.util.Log;
import android.widget.ImageView; import android.widget.ImageView;
@ -13,11 +14,11 @@ import androidx.preference.PreferenceManager;
import com.bingce.AppChannel; import com.bingce.AppChannel;
import com.bingce.RepositoryBaseApp; import com.bingce.RepositoryBaseApp;
import com.bingce.controlapphelper.datasource.database.SurveyorDataBase; import com.bingce.controlapphelper.datasource.database.SurveyorDataBase;
import com.bingce.controlapphelper.datasource.database.ToleranceTemplate; import com.bingce.controlapphelper.datasource.database.tolerance.load.ToleranceLoadUtil;
import com.bingce.controlapphelper.util.DatabaseProvider;
import com.bingce.controlapphelper.util.SettingValueUtil; import com.bingce.controlapphelper.util.SettingValueUtil;
import com.bingce.controlnetwork.activity.NotificationActivity; import com.bingce.controlnetwork.activity.NotificationActivity;
import com.bingce.utils.DES; import com.bingce.utils.DES;
import com.bingce.utils.ThreadPoolUtil;
import com.bumptech.glide.Glide; import com.bumptech.glide.Glide;
import com.mikepenz.materialdrawer.util.AbstractDrawerImageLoader; import com.mikepenz.materialdrawer.util.AbstractDrawerImageLoader;
import com.mikepenz.materialdrawer.util.DrawerImageLoader; import com.mikepenz.materialdrawer.util.DrawerImageLoader;
@ -33,6 +34,7 @@ import cn.leancloud.LCInstallation;
import cn.leancloud.LCLogger; import cn.leancloud.LCLogger;
import cn.leancloud.LeanCloud; import cn.leancloud.LeanCloud;
import cn.leancloud.push.PushService; import cn.leancloud.push.PushService;
import cn.liuyanbing.surveyor.AppConfig;
import io.reactivex.functions.Consumer; import io.reactivex.functions.Consumer;
import io.reactivex.plugins.RxJavaPlugins; import io.reactivex.plugins.RxJavaPlugins;
@ -74,11 +76,16 @@ public class App extends RepositoryBaseApp {
public String wifiChatClientIp = ""; public String wifiChatClientIp = "";
public String lastPhoneLocation = ""; public String lastPhoneLocation = "";
/**
* 自动测量是否开启atr
*/
public String levelSurveyorTime;
private static App app; private static App app;
@Override @Override
public void onCreate() { public void onCreate() {
customChannel = AppChannel.CUSTOM_PUBLIC;//; customChannel = BuildConfig.CHANNEL_TYPE;//AppChannel.CUSTOM_PUBLIC;
super.onCreate(); super.onCreate();
app = this; app = this;
@ -148,6 +155,10 @@ public class App extends RepositoryBaseApp {
isCloseInstrumentAfterExit = prefs.getBoolean("isCloseInstrumentAfterExit", false); isCloseInstrumentAfterExit = prefs.getBoolean("isCloseInstrumentAfterExit", false);
magneticDeclination = prefs.getFloat("magneticDeclination", 0); magneticDeclination = prefs.getFloat("magneticDeclination", 0);
lastPhoneLocation = prefs.getString("lastPhoneLocation", ""); lastPhoneLocation = prefs.getString("lastPhoneLocation", "");
levelSurveyorTime = prefs.getString("levelSurveyorTime", "1");
if (TextUtils.isEmpty(levelSurveyorTime)) {
levelSurveyorTime = "1";
}
} }
@Override @Override
@ -164,6 +175,16 @@ public class App extends RepositoryBaseApp {
return BuildConfig.APPLICATION_ID; return BuildConfig.APPLICATION_ID;
} }
@Override
public boolean isThemeDark() {
return false;
}
@Override
public int angleNotNumber() {
return AppConfig.instance.angleDotNum();
}
public static App getApp() { public static App getApp() {
return app; return app;
} }
@ -175,9 +196,8 @@ public class App extends RepositoryBaseApp {
private void initControlApp() { private void initControlApp() {
Utils.init(this); Utils.init(this);
//加载限差配置 ThreadPoolUtil.execute(ToleranceLoadUtil::init);
ToleranceTemplate.setup();
//数据库 //数据库
DatabaseProvider.init(SurveyorDataBase.getInstance()); SurveyorDataBase.getInstance();
} }
} }

@ -14,6 +14,8 @@ import androidx.appcompat.widget.Toolbar;
import com.bingce.activity.PrivacyPolicyActivity; import com.bingce.activity.PrivacyPolicyActivity;
import com.bingce.activity.UserAgreementActivity; import com.bingce.activity.UserAgreementActivity;
import com.bingce.controlapphelper.util.CheckStorageUtil;
import com.bingce.controlnetwork.R;
import com.bingce.controlnetwork.util.CheckControlUpdateUtil; import com.bingce.controlnetwork.util.CheckControlUpdateUtil;
import com.bingce.surveyor.agentweb.AgentWebActivity; import com.bingce.surveyor.agentweb.AgentWebActivity;
import com.vansuita.materialabout.builder.AboutBuilder; import com.vansuita.materialabout.builder.AboutBuilder;
@ -24,9 +26,6 @@ import org.polaric.colorful.ColorfulActivity;
import blankj.utilcode.util.ToastUtils; import blankj.utilcode.util.ToastUtils;
import blankj.utilcode.util.Utils; import blankj.utilcode.util.Utils;
import com.bingce.controlnetwork.R;
import com.bingce.controlnetwork.util.CheckControlUpdateUtil;
public class AboutActivity extends ColorfulActivity { public class AboutActivity extends ColorfulActivity {
private Toolbar mToolbar; private Toolbar mToolbar;
@ -120,14 +119,24 @@ public class AboutActivity extends ColorfulActivity {
finish(); finish();
break; break;
case R.id.menu_debug_switch: case R.id.menu_debug_switch:
Utils.isTest = !Utils.isTest; startOpenCloseMeasureDebug();
if (Utils.isTest){
ToastUtils.showShort(R.string.debug_on);
}else{
ToastUtils.showShort(R.string.debug_off);
}
break; break;
} }
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
} }
/**
* 开始打开或关闭调试
*/
private void startOpenCloseMeasureDebug() {
CheckStorageUtil.check(this, () -> {
Utils.isTest = !Utils.isTest;
if (Utils.isTest) {
ToastUtils.showShort(R.string.debug_on);
} else {
ToastUtils.showShort(R.string.debug_off);
}
});
}
} }

@ -1,7 +1,6 @@
package com.bingce.controlnetwork.activity; package com.bingce.controlnetwork.activity;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.IntentFilter; import android.content.IntentFilter;
import android.content.SharedPreferences; import android.content.SharedPreferences;
@ -9,7 +8,6 @@ import android.graphics.Color;
import android.net.Uri; import android.net.Uri;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler;
import android.util.Log; import android.util.Log;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.Menu; import android.view.Menu;
@ -27,6 +25,7 @@ import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter; import androidx.fragment.app.FragmentPagerAdapter;
import androidx.lifecycle.ViewModelProvider;
import androidx.preference.PreferenceManager; import androidx.preference.PreferenceManager;
import androidx.viewpager.widget.ViewPager; import androidx.viewpager.widget.ViewPager;
@ -35,27 +34,30 @@ import com.afollestad.materialdialogs.MaterialDialog;
import com.bingce.AppChannel; import com.bingce.AppChannel;
import com.bingce.BaseApp; import com.bingce.BaseApp;
import com.bingce.activity.BaseMainActivity; import com.bingce.activity.BaseMainActivity;
import com.bingce.controlapphelper.datasource.database.config.ConfigOperate;
import com.bingce.controlapphelper.event.DatabaseReadyEvent; import com.bingce.controlapphelper.event.DatabaseReadyEvent;
import com.bingce.controlapphelper.event.ProjectChangedEvent;
import com.bingce.controlapphelper.event.SwitchPageEvent; import com.bingce.controlapphelper.event.SwitchPageEvent;
import com.bingce.controlapphelper.util.InterfaceUtil; import com.bingce.controlapphelper.util.InterfaceUtil;
import com.bingce.controlapphelper.util.SettingValueUtil; import com.bingce.controlapphelper.util.SettingValueUtil;
import com.bingce.controlnetwork.App; import com.bingce.controlnetwork.App;
import com.bingce.controlnetwork.R; import com.bingce.controlnetwork.R;
import com.bingce.controlnetwork.activity.backup.BackupExportActivity;
import com.bingce.controlnetwork.activity.backup.launch.BackupImportHelper; import com.bingce.controlnetwork.activity.backup.launch.BackupImportHelper;
import com.bingce.controlnetwork.activity.user.LoginActivity; import com.bingce.controlnetwork.activity.user.LoginActivity;
import com.bingce.controlnetwork.activity.user.RegisterActivity; import com.bingce.controlnetwork.activity.user.RegisterActivity;
import com.bingce.controlnetwork.activity.user.UserInfoActivity; import com.bingce.controlnetwork.activity.user.UserInfoActivity;
import com.bingce.controlnetwork.fragment.ConfigFragment; import com.bingce.controlnetwork.bean.MainUserBean;
import com.bingce.controlnetwork.fragment.MainSurveyFragment; import com.bingce.controlnetwork.fragment.MainSurveyFragment;
import com.bingce.controlnetwork.fragment.ProjectListFragment; import com.bingce.controlnetwork.fragment.ProjectListFragment;
import com.bingce.controlnetwork.fragment.ServiceFragment; import com.bingce.controlnetwork.fragment.ServiceFragment;
import com.bingce.controlnetwork.newui.configfragment.ConfigFragment;
import com.bingce.controlnetwork.newui.mefragment.MeFragment;
import com.bingce.controlnetwork.util.CheckControlUpdateUtil; import com.bingce.controlnetwork.util.CheckControlUpdateUtil;
import com.bingce.controlnetwork.viewmodel.MainActivityViewModel;
import com.bingce.data.sync.GlobalFlowCenter; import com.bingce.data.sync.GlobalFlowCenter;
import com.bingce.data.sync.utils.LeanCloudConfigLoader; import com.bingce.data.sync.utils.LeanCloudConfigLoader;
import com.bingce.data.sync.utils.LeanCloudUserLoginStateUtils; import com.bingce.data.sync.utils.LeanCloudUserLoginStateUtils;
import com.bingce.device.Device; import com.bingce.device.Device;
import com.bingce.device.ui.dialog.DialogUtil;
import com.bingce.device.ui.manager.DeviceConnectManager; import com.bingce.device.ui.manager.DeviceConnectManager;
import com.bingce.device.ui.manager.DeviceRemindManager; import com.bingce.device.ui.manager.DeviceRemindManager;
import com.bingce.device.ui.manager.DeviceRequestManager; import com.bingce.device.ui.manager.DeviceRequestManager;
@ -64,7 +66,7 @@ import com.bingce.event.OpenShortUrlEvent;
import com.bingce.surveyor.agentweb.AgentWebActivity; import com.bingce.surveyor.agentweb.AgentWebActivity;
import com.bingce.totalstation.TotalStation; import com.bingce.totalstation.TotalStation;
import com.bingce.ui.TabEntity; import com.bingce.ui.TabEntity;
import com.bingce.utils.ActivateUtil; import com.bingce.utils.AppUtil;
import com.bingce.utils.ColorUtil; import com.bingce.utils.ColorUtil;
import com.bingce.utils.CrashCollector; import com.bingce.utils.CrashCollector;
import com.bingce.utils.DateUtils; import com.bingce.utils.DateUtils;
@ -83,16 +85,6 @@ import com.flyco.tablayout.listener.OnTabSelectListener;
import com.jkyeo.splashview.SplashView; import com.jkyeo.splashview.SplashView;
import com.mikepenz.iconics.IconicsDrawable; import com.mikepenz.iconics.IconicsDrawable;
import com.mikepenz.material_design_iconic_typeface_library.MaterialDesignIconic; import com.mikepenz.material_design_iconic_typeface_library.MaterialDesignIconic;
import com.mikepenz.materialdrawer.AccountHeader;
import com.mikepenz.materialdrawer.AccountHeaderBuilder;
import com.mikepenz.materialdrawer.Drawer;
import com.mikepenz.materialdrawer.DrawerBuilder;
import com.mikepenz.materialdrawer.model.PrimaryDrawerItem;
import com.mikepenz.materialdrawer.model.ProfileDrawerItem;
import com.mikepenz.materialdrawer.model.ProfileSettingDrawerItem;
import com.mikepenz.materialdrawer.model.SecondaryDrawerItem;
import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem;
import com.mikepenz.materialdrawer.model.interfaces.IProfile;
import com.tencent.mm.opensdk.openapi.IWXAPI; import com.tencent.mm.opensdk.openapi.IWXAPI;
import com.tencent.mm.opensdk.openapi.WXAPIFactory; import com.tencent.mm.opensdk.openapi.WXAPIFactory;
import com.umeng.commonsdk.UMConfigure; import com.umeng.commonsdk.UMConfigure;
@ -108,6 +100,7 @@ import org.polaric.colorful.Colorful;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map;
import alibaba.fastjson.JSON; import alibaba.fastjson.JSON;
import alibaba.fastjson.JSONObject; import alibaba.fastjson.JSONObject;
@ -131,26 +124,27 @@ public class MainActivity extends BaseMainActivity implements Device.IDeviceConn
public final DeviceRemindManager deviceRemindManager = new DeviceRemindManager(this, this); public final DeviceRemindManager deviceRemindManager = new DeviceRemindManager(this, this);
public final static String MAIN_IN_ACTION_NAME = "cn.liuyanbing.surveyor.main_activity_local_receiver"; public final static String MAIN_IN_ACTION_NAME = "cn.liuyanbing.surveyor.main_activity_local_receiver";
private Toolbar mToolbar; private Toolbar mToolbar;
private AccountHeader accountHeader = null; // private AccountHeader accountHeader = null;
private Drawer drawerLeft = null; // private Drawer drawerLeft = null;
private NumberProgressBar cutDownProgressBar; private NumberProgressBar cutDownProgressBar;
private CheckBox powerOffCheckbox; private CheckBox powerOffCheckbox;
private final List<Fragment> mFragments = new ArrayList<>(); private final List<Fragment> mFragments = new ArrayList<>();
private String[] mTitles; private String[] mTitles;
private final int[] mIconUnSelectIds = new int[]{R.drawable.ic_tab_project_unselect, R.drawable.ic_ruler_unselected, R.mipmap.tab_home_unselect, R.mipmap.tab_service_unselect}; private final int[] mIconUnSelectIds = new int[]{R.drawable.ic_tab_project_unselect, R.drawable.ic_ruler_unselected, R.mipmap.tab_home_unselect, R.mipmap.tab_service_unselect, R.mipmap.tab_me_unselect};
private final int[] mIconSelectIds = new int[]{R.drawable.ic_tab_project_selected, R.drawable.ic_ruler_selected, R.mipmap.tab_home_select, R.mipmap.tab_service_select}; private final int[] mIconSelectIds = new int[]{R.drawable.ic_tab_project_selected, R.drawable.ic_ruler_selected, R.mipmap.tab_home_select, R.mipmap.tab_service_select, R.mipmap.tab_me_select};
private final ArrayList<CustomTabEntity> mTabEntities = new ArrayList<>(); private final ArrayList<CustomTabEntity> mTabEntities = new ArrayList<>();
private ViewPager mViewPager; private ViewPager mViewPager;
private CommonTabLayout mTabLayout; private CommonTabLayout mTabLayout;
private BackupImportHelper backupImportUtil = new BackupImportHelper(this); private BackupImportHelper backupImportUtil = new BackupImportHelper(this);
private MaterialDialog langDialog, unbindDeviceDialog;
private MainActivityViewModel mainActivityViewModel;
@SuppressLint("SourceLockedOrientationActivity") @SuppressLint("SourceLockedOrientationActivity")
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
if (ActivateUtil.encrypt(this, "control", AppChannel.customChannel) == null) mainActivityViewModel = new ViewModelProvider(this).get(MainActivityViewModel.class);
finish();
EventBus.getDefault().register(this); EventBus.getDefault().register(this);
if (isThemeDark()) { if (isThemeDark()) {
@ -170,20 +164,27 @@ public class MainActivity extends BaseMainActivity implements Device.IDeviceConn
VipManager.getInstance().controlSdkRefresh(this, ((App) Utils.getApp()).registerCodeV2, new VipManager.OnSdkRefreshListener() { VipManager.getInstance().controlSdkRefresh(this, ((App) Utils.getApp()).registerCodeV2, new VipManager.OnSdkRefreshListener() {
@Override @Override
public void onRefreshSuccess() { public void onRefreshSuccess() {
if (!AppUtil.isZh() && SdkUtils.isRegCodeValidate() && !SdkUtils.isIntlCodeValidate()) {//非中文环境需要国际许可码
DialogUtil.mDismissAlertDialog(MainActivity.this, R.string.hint, R.string.you_need_apply_for_an_international_license_code, R.string.i_know, null, null);
} else if ((AppUtil.isZh() && !VipManager.getInstance().isCnLevelExpireTimeValid() && VipManager.getInstance().isIntlLevelExpireTimeValid())
|| (!AppUtil.isZh() && VipManager.getInstance().isCnLevelExpireTimeValid() && !VipManager.getInstance().isIntlLevelExpireTimeValid())) {
if (langDialog == null || !langDialog.isShowing()) {
langDialog = new MaterialDialog.Builder(MainActivity.this).content(R.string.your_membership_is_not_available_in_the_current_language).positiveText(R.string.i_know).show();
}
}
if (!VipManager.getInstance().checkReg() if (!VipManager.getInstance().checkReg()
&& ((VipManager.getInstance().level > 0 && VipManager.getInstance().isInExpireDate) && (VipManager.getInstance().isCnLevelExpireTimeValid() || VipManager.getInstance().isIntlLevelExpireTimeValid())
|| (VipManager.getInstance().eduLevel > 0 && VipManager.getInstance().isEduInExpireDate)
|| (VipManager.getInstance().intlLevel > 0 && VipManager.getInstance().isIntlInExpireDate)
|| (VipManager.getInstance().controlLevel > 0 && VipManager.getInstance().isControlInExpireDate))
&& !VipManager.getInstance().isControlBoundDevice) { && !VipManager.getInstance().isControlBoundDevice) {
new MaterialDialog.Builder(MainActivity.this) if (unbindDeviceDialog == null || !unbindDeviceDialog.isShowing()) {
.title(R.string.hint) unbindDeviceDialog = new MaterialDialog.Builder(MainActivity.this)
.content(R.string.unbind_old_device_first) .title(R.string.hint)
.positiveText(R.string.unbind_device) .content(R.string.unbind_old_device_first)
.onPositive((dialog, which) -> .positiveText(R.string.unbind_device)
startActivity(new Intent(MainActivity.this, UserInfoActivity.class))) .onPositive((dialog, which) ->
.negativeText(R.string.not_now) startActivity(new Intent(MainActivity.this, UserInfoActivity.class)))
.show(); .negativeText(R.string.not_now)
.show();
}
} }
if (!StringUtils.isEmpty(SdkUtils.attach())) { if (!StringUtils.isEmpty(SdkUtils.attach())) {
JSONObject attach = JSON.parseObject(SdkUtils.attach()); JSONObject attach = JSON.parseObject(SdkUtils.attach());
@ -242,11 +243,12 @@ public class MainActivity extends BaseMainActivity implements Device.IDeviceConn
mTabLayout.setUnderlineColor(Color.BLACK); mTabLayout.setUnderlineColor(Color.BLACK);
} }
} }
mTitles = new String[]{getString(R.string.project), getString(R.string.survey), getString(R.string.label_manager), getString(R.string.service)}; mTitles = new String[]{getString(R.string.project), getString(R.string.survey), getString(R.string.label_manager), getString(R.string.service), getString(R.string.me)};
mFragments.add(new ProjectListFragment()); mFragments.add(new ProjectListFragment());
mFragments.add(new MainSurveyFragment()); mFragments.add(new MainSurveyFragment());
mFragments.add(new ConfigFragment()); mFragments.add(new ConfigFragment());
mFragments.add(new ServiceFragment()); mFragments.add(new ServiceFragment());
mFragments.add(new MeFragment());
for (int i = 0; i < mTitles.length; i++) { for (int i = 0; i < mTitles.length; i++) {
mTabEntities.add(new TabEntity(mTitles[i], mIconSelectIds[i], mIconUnSelectIds[i])); mTabEntities.add(new TabEntity(mTitles[i], mIconSelectIds[i], mIconUnSelectIds[i]));
} }
@ -270,6 +272,7 @@ public class MainActivity extends BaseMainActivity implements Device.IDeviceConn
mViewPager.setAdapter(new MyPagerAdapter(getSupportFragmentManager())); mViewPager.setAdapter(new MyPagerAdapter(getSupportFragmentManager()));
mViewPager.setCurrentItem(0); mViewPager.setCurrentItem(0);
mViewPager.setOffscreenPageLimit(4); mViewPager.setOffscreenPageLimit(4);
mViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { mViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override @Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
@ -287,140 +290,143 @@ public class MainActivity extends BaseMainActivity implements Device.IDeviceConn
} }
}); });
accountHeader = new AccountHeaderBuilder() // accountHeader = new AccountHeaderBuilder()
.withActivity(this) // .withActivity(this)
.withCompactStyle(true) // .withCompactStyle(true)
// .withHeaderBackground(R.drawable.drawer_header) //// .withHeaderBackground(R.drawable.drawer_header)
.withProfileImagesClickable(true) // .withProfileImagesClickable(true)
.withCurrentProfileHiddenInList(true) // .withCurrentProfileHiddenInList(true)
.addProfiles( // .addProfiles(
new ProfileDrawerItem() // new ProfileDrawerItem()
.withEmail(getString(R.string.not_log_in)) // .withEmail(getString(R.string.not_log_in))
.withIcon(R.drawable.app_logo) // .withIcon(R.drawable.app_logo)
.withIdentifier(1003), // .withIdentifier(1003),
new ProfileSettingDrawerItem() // new ProfileSettingDrawerItem()
.withName(getString(R.string.log_in)) // .withName(getString(R.string.log_in))
.withIcon(new IconicsDrawable(this).icon(MaterialDesignIconic.Icon.gmi_sign_in).paddingDp(5)) // .withIcon(new IconicsDrawable(this).icon(MaterialDesignIconic.Icon.gmi_sign_in).paddingDp(5))
.withIdentifier(1000).withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() { // .withIdentifier(1000).withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
@Override // @Override
public boolean onItemClick(View view, int position, IDrawerItem drawerItem) { // public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
Intent intent = new Intent(Utils.getApp(), LoginActivity.class); // Intent intent = new Intent(Utils.getApp(), LoginActivity.class);
intent.putExtra("finishTo", UserInfoActivity.class.getName()); // intent.putExtra("finishTo", UserInfoActivity.class.getName());
startActivity(intent); // startActivity(intent);
return false; // return false;
} // }
})) // }))
.withOnAccountHeaderProfileImageListener(new AccountHeader.OnAccountHeaderProfileImageListener() { // .withOnAccountHeaderProfileImageListener(new AccountHeader.OnAccountHeaderProfileImageListener() {
@Override // @Override
public boolean onProfileImageClick(View view, IProfile profile, boolean current) { // public boolean onProfileImageClick(View view, IProfile profile, boolean current) {
if (LCUser.getCurrentUser() == null) { // if (LCUser.getCurrentUser() == null) {
Intent intent = new Intent(Utils.getApp(), LoginActivity.class); // Intent intent = new Intent(Utils.getApp(), LoginActivity.class);
intent.putExtra("finishTo", UserInfoActivity.class.getName()); // intent.putExtra("finishTo", UserInfoActivity.class.getName());
startActivity(intent); // startActivity(intent);
} else { // } else {
startActivity(new Intent(MainActivity.this, UserInfoActivity.class)); // startActivity(new Intent(MainActivity.this, UserInfoActivity.class));
} // }
return false; // return false;
} // }
//
@Override // @Override
public boolean onProfileImageLongClick(View view, IProfile profile, boolean current) { // public boolean onProfileImageLongClick(View view, IProfile profile, boolean current) {
return false; // return false;
} // }
}) // })
.withOnlyMainProfileImageVisible(true) // .withOnlyMainProfileImageVisible(true)
.withSavedInstance(savedInstanceState) // .withSavedInstance(savedInstanceState)
.build(); // .build();
//
IDrawerItem[] items = new IDrawerItem[]{ // IDrawerItem[] items = new IDrawerItem[]{
// new PrimaryDrawerItem().withName(R.string.update_database).withDescription(R.string.update_database_description).withIcon(MaterialDesignIconic.Icon.gmi_upload).withIdentifier(14).withSelectable(false), //// new PrimaryDrawerItem().withName(R.string.update_database).withDescription(R.string.update_database_description).withIcon(MaterialDesignIconic.Icon.gmi_upload).withIdentifier(14).withSelectable(false),
// new PrimaryDrawerItem().withName(R.string.video_tutorial).withDescription(R.string.video_tutorial_description).withIcon(MaterialDesignIconic.Icon.gmi_collection_video).withIdentifier(15).withSelectable(false), //// new PrimaryDrawerItem().withName(R.string.video_tutorial).withDescription(R.string.video_tutorial_description).withIcon(MaterialDesignIconic.Icon.gmi_collection_video).withIdentifier(15).withSelectable(false),
new PrimaryDrawerItem().withName(R.string.docs).withIcon(MaterialDesignIconic.Icon.gmi_help_outline).withIdentifier(16).withSelectable(false), // new PrimaryDrawerItem().withName(R.string.docs).withIcon(MaterialDesignIconic.Icon.gmi_help_outline).withIdentifier(16).withSelectable(false),
new PrimaryDrawerItem().withName(R.string.tech_customer_service).withIcon(R.mipmap.icon_program_customer_service).withIdentifier(17).withSelectable(false), // new PrimaryDrawerItem().withName(R.string.tech_customer_service).withIcon(R.mipmap.icon_program_customer_service).withIdentifier(17).withSelectable(false),
new PrimaryDrawerItem().withName(R.string.app_data_backup).withIcon(MaterialDesignIconic.Icon.gmi_info_outline).withIcon(R.drawable.ic_backup).withIdentifier(24).withSelectable(false), // new PrimaryDrawerItem().withName(R.string.app_data_backup).withIcon(MaterialDesignIconic.Icon.gmi_info_outline).withIcon(R.drawable.ic_backup).withIdentifier(24).withSelectable(false),
new PrimaryDrawerItem().withName(R.string.app_backup_import).withIcon(MaterialDesignIconic.Icon.gmi_info_outline).withIcon(R.drawable.ic_import).withIdentifier(25).withSelectable(false), // new PrimaryDrawerItem().withName(R.string.app_backup_import).withIcon(MaterialDesignIconic.Icon.gmi_info_outline).withIcon(R.drawable.ic_import).withIdentifier(25).withSelectable(false),
new PrimaryDrawerItem().withName(R.string.about).withIcon(MaterialDesignIconic.Icon.gmi_info_outline).withIdentifier(19).withSelectable(false) // new PrimaryDrawerItem().withName(R.string.about).withIcon(MaterialDesignIconic.Icon.gmi_info_outline).withIdentifier(19).withSelectable(false)
}; // };
//Create the drawer // //Create the drawer
drawerLeft = new DrawerBuilder() // drawerLeft = new DrawerBuilder()
.withActivity(this) // .withActivity(this)
.withToolbar(mToolbar) // .withToolbar(mToolbar)
.withAccountHeader(accountHeader) //set the AccountHeader we created earlier for the header // .withAccountHeader(accountHeader) //set the AccountHeader we created earlier for the header
.addDrawerItems(items) // .addDrawerItems(items)
.addStickyDrawerItems(new SecondaryDrawerItem().withName(R.string.settings).withIcon(MaterialDesignIconic.Icon.gmi_settings).withIdentifier(20).withSelectable(false)) // .addStickyDrawerItems(new SecondaryDrawerItem().withName(R.string.settings).withIcon(MaterialDesignIconic.Icon.gmi_settings).withIdentifier(20).withSelectable(false))
.withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() { // .withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
@Override // @Override
public boolean onItemClick(View view, int position, IDrawerItem drawerItem) { // public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
if (drawerItem != null) { // if (drawerItem != null) {
switch ((int) drawerItem.getIdentifier()) { // switch ((int) drawerItem.getIdentifier()) {
case 14: // case 14:
new AlertDialog.Builder(MainActivity.this) // new AlertDialog.Builder(MainActivity.this)
.setTitle(R.string.confirm_update_database) // .setTitle(R.string.confirm_update_database)
.setPositiveButton(R.string.confirm, new DialogInterface.OnClickListener() { // .setPositiveButton(R.string.confirm, new DialogInterface.OnClickListener() {
@Override // @Override
public void onClick(DialogInterface dialog, int which) { // public void onClick(DialogInterface dialog, int which) {
EventBus.getDefault().post(new ProjectChangedEvent()); // EventBus.getDefault().post(new ProjectChangedEvent());
} // }
}).setNegativeButton(R.string.cancel, null).show(); // }).setNegativeButton(R.string.cancel, null).show();
break; // break;
case 15: // case 15:
showTutorialListDialog(); // showTutorialListDialog();
break; // break;
case 16: // case 16:
// Intent intent16 = new Intent(); //帮助文档
// intent16.setClass(Utils.getApp(), AgentWebActivity.class); //// Intent intent16 = new Intent();
// intent16.putExtra("short_url", "android_url_control_network_docs"); //// intent16.setClass(Utils.getApp(), AgentWebActivity.class);
// startActivity(intent16); //// intent16.putExtra("short_url", "android_url_control_network_docs");
AgentWebActivity.navigation2( //// startActivity(intent16);
MainActivity.this, // AgentWebActivity.navigation2(
"android_url_control_network_docs"); // MainActivity.this,
break; // "android_url_control_network_docs");
case 17: // break;
// Intent intent = new Intent(); // case 17:
// intent.setClass(Utils.getApp(), AgentWebActivity.class); //技术支持
// intent.putExtra("short_url", "android_url_tech_support"); //// Intent intent = new Intent();
// startActivity(intent); //// intent.setClass(Utils.getApp(), AgentWebActivity.class);
AgentWebActivity.navigation2( //// intent.putExtra("short_url", "android_url_tech_support");
MainActivity.this, //// startActivity(intent);
"android_url_tech_support" // AgentWebActivity.navigation2(
); // MainActivity.this,
break; // "android_url_tech_support"
case 19: // );
Intent intent17 = new Intent(Utils.getApp(), AboutActivity.class); // break;
startActivity(intent17); // case 19:
break; // Intent intent17 = new Intent(Utils.getApp(), AboutActivity.class);
case 20: // startActivity(intent17);
Intent intent18 = new Intent(Utils.getApp(), SettingsActivity.class); // break;
startActivityForResult(intent18, 331); // case 20:
break; // Intent intent18 = new Intent(Utils.getApp(), SettingsActivity.class);
case 24: // startActivityForResult(intent18, 331);
BackupExportActivity.start(MainActivity.this, BackupExportActivity.class); // break;
break; // case 24:
case 25: // BackupExportActivity.start(MainActivity.this, BackupExportActivity.class);
backupImportUtil.doImport(MainActivity.this, success -> { // break;
if (success) { // case 25:
restartApplication(); //导入
// initProject(); // backupImportUtil.doImport(MainActivity.this, success -> {
} // if (success) {
}); // restartApplication();
new Handler().postDelayed(new Runnable() { //// initProject();
@Override // }
public void run() { // });
drawerLeft.closeDrawer(); // new Handler().postDelayed(new Runnable() {
} // @Override
}, 60); // public void run() {
// drawerLeft.closeDrawer();
break; // }
// }, 60);
} //
} // break;
//
return false; // }
} // }
}) //
.withSavedInstance(savedInstanceState) // return false;
.withSelectedItem(-1) // }
.build(); // })
// .withSavedInstance(savedInstanceState)
// .withSelectedItem(-1)
// .build();
} }
public void setCurrentTab(int position) { public void setCurrentTab(int position) {
@ -619,10 +625,10 @@ public class MainActivity extends BaseMainActivity implements Device.IDeviceConn
@Override @Override
public boolean onKeyDown(int keyCode, KeyEvent event) { public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) { if (keyCode == KeyEvent.KEYCODE_BACK) {
if (drawerLeft != null && drawerLeft.isDrawerOpen()) { // if (drawerLeft != null && drawerLeft.isDrawerOpen()) {
drawerLeft.closeDrawer(); // drawerLeft.closeDrawer();
return true; // return true;
} // }
if (mViewPager != null) { if (mViewPager != null) {
Fragment viewPagerFragment = getViewPagerFragment(this, mViewPager.getId(), mViewPager.getCurrentItem()); Fragment viewPagerFragment = getViewPagerFragment(this, mViewPager.getId(), mViewPager.getCurrentItem());
@ -646,12 +652,12 @@ public class MainActivity extends BaseMainActivity implements Device.IDeviceConn
@Override @Override
protected void onSaveInstanceState(Bundle outState) { protected void onSaveInstanceState(Bundle outState) {
//add the values which need to be saved from the drawer to the bundle // //add the values which need to be saved from the drawer to the bundle
if (drawerLeft != null) // if (drawerLeft != null)
outState = drawerLeft.saveInstanceState(outState); // outState = drawerLeft.saveInstanceState(outState);
//add the values which need to be saved from the accountHeader to the bundle // //add the values which need to be saved from the accountHeader to the bundle
if (accountHeader != null) // if (accountHeader != null)
outState = accountHeader.saveInstanceState(outState); // outState = accountHeader.saveInstanceState(outState);
super.onSaveInstanceState(outState); super.onSaveInstanceState(outState);
} }
@ -684,7 +690,7 @@ public class MainActivity extends BaseMainActivity implements Device.IDeviceConn
startActivityForResult(intent4, 331); startActivityForResult(intent4, 331);
break; break;
case R.id.menu_activity_main_more: case R.id.menu_activity_main_more:
openLeftDrawer(); // openLeftDrawer();
break; break;
} }
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
@ -719,10 +725,10 @@ public class MainActivity extends BaseMainActivity implements Device.IDeviceConn
} }
if (((App) Utils.getApp()).isUserStatusChanged) { if (((App) Utils.getApp()).isUserStatusChanged) {
((App) Utils.getApp()).isUserStatusChanged = false; ((App) Utils.getApp()).isUserStatusChanged = false;
if (drawerLeft != null) // if (drawerLeft != null)
drawerLeft.openDrawer(); // drawerLeft.openDrawer();
if (accountHeader != null) // if (accountHeader != null)
accountHeader.toggleSelectionList(MainActivity.this); // accountHeader.toggleSelectionList(MainActivity.this);
updateHeaderResult(); updateHeaderResult();
} }
//按照设置选项,保持屏幕常亮,放在onResume而不放在onCreate里是因为,用户更改设置后返回主页就要开始常亮了 //按照设置选项,保持屏幕常亮,放在onResume而不放在onCreate里是因为,用户更改设置后返回主页就要开始常亮了
@ -995,34 +1001,34 @@ public class MainActivity extends BaseMainActivity implements Device.IDeviceConn
*/ */
public void updateHeaderResult() { public void updateHeaderResult() {
Log.d("updateHeaderResult", "updateHeaderResult"); Log.d("updateHeaderResult", "updateHeaderResult");
if (drawerLeft == null || accountHeader == null) // if (drawerLeft == null || accountHeader == null)
return; // return;
for (int i = accountHeader.getProfiles().size() - 1; i >= 0; i--) { // for (int i = accountHeader.getProfiles().size() - 1; i >= 0; i--) {
accountHeader.removeProfile(accountHeader.getProfiles().get(i)); // accountHeader.removeProfile(accountHeader.getProfiles().get(i));
} // }
if (LCUser.getCurrentUser() == null || !LCUser.getCurrentUser().isAuthenticated()) { // if (LCUser.getCurrentUser() == null || !LCUser.getCurrentUser().isAuthenticated()) {
accountHeader.addProfiles( // accountHeader.addProfiles(
new ProfileSettingDrawerItem().withName(getString(R.string.log_in)) // new ProfileSettingDrawerItem().withName(getString(R.string.log_in))
.withIcon(new IconicsDrawable(this).icon(MaterialDesignIconic.Icon.gmi_sign_in).paddingDp(5)) // .withIcon(new IconicsDrawable(this).icon(MaterialDesignIconic.Icon.gmi_sign_in).paddingDp(5))
.withIdentifier(1000).withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() { // .withIdentifier(1000).withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
@Override // @Override
public boolean onItemClick(View view, int position, IDrawerItem drawerItem) { // public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
Intent intent = new Intent(Utils.getApp(), LoginActivity.class); // Intent intent = new Intent(Utils.getApp(), LoginActivity.class);
intent.putExtra("finishTo", UserInfoActivity.class.getName()); // intent.putExtra("finishTo", UserInfoActivity.class.getName());
startActivity(intent); // startActivity(intent);
return false; // return false;
} // }
})); // }));
} else { // } else {
accountHeader.addProfiles(new ProfileSettingDrawerItem().withName(getString(R.string.user_info)).withIcon(new IconicsDrawable(this).icon(MaterialDesignIconic.Icon.gmi_account).paddingDp(5)).withIdentifier(1000).withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() { // accountHeader.addProfiles(new ProfileSettingDrawerItem().withName(getString(R.string.user_info)).withIcon(new IconicsDrawable(this).icon(MaterialDesignIconic.Icon.gmi_account).paddingDp(5)).withIdentifier(1000).withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
@Override // @Override
public boolean onItemClick(View view, int position, IDrawerItem drawerItem) { // public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
startActivity(new Intent(MainActivity.this, UserInfoActivity.class)); // startActivity(new Intent(MainActivity.this, UserInfoActivity.class));
return false; // return false;
} // }
})); // }));
} // }
updateProfileItem(); updateProfileItem();
@ -1033,13 +1039,22 @@ public class MainActivity extends BaseMainActivity implements Device.IDeviceConn
String nickname = LCUser.getCurrentUser().getString("nickname"); String nickname = LCUser.getCurrentUser().getString("nickname");
LCFile avatarFile = LCUser.getCurrentUser().getLCFile("avatar"); LCFile avatarFile = LCUser.getCurrentUser().getLCFile("avatar");
if (!StringUtils.isEmpty(nickname)) { if (!StringUtils.isEmpty(nickname)) {
ProfileDrawerItem item = new ProfileDrawerItem().withName(nickname).withEmail(LCUser.getCurrentUser().getUsername()).withIdentifier(1003); // ProfileDrawerItem item = new ProfileDrawerItem().withName(nickname).withEmail(LCUser.getCurrentUser().getUsername()).withIdentifier(1003);
if (avatarFile == null) { // if (avatarFile == null) {
item.withIcon(R.drawable.app_logo); // item.withIcon(R.drawable.app_logo);
} else { // } else {
item.withIcon(avatarFile.getUrl()); // item.withIcon(avatarFile.getUrl());
// }
// accountHeader.addProfiles(item);
String avatarUrl = null;
if (avatarFile != null) {
avatarUrl = avatarFile.getUrl();
} }
accountHeader.addProfiles(item);
mainActivityViewModel.getRefreshLoginUserLiveData().setValue(
new MainUserBean(LCUser.getCurrentUser().getUsername(),
nickname, avatarUrl));
} else { } else {
LCObject userProfile = LCUser.getCurrentUser().getLCObject("profile"); LCObject userProfile = LCUser.getCurrentUser().getLCObject("profile");
if (userProfile != null) { if (userProfile != null) {
@ -1055,19 +1070,28 @@ public class MainActivity extends BaseMainActivity implements Device.IDeviceConn
String nickname = avObject.getString("nickname"); String nickname = avObject.getString("nickname");
LCFile avatarFile = avObject.getLCFile("avatar"); LCFile avatarFile = avObject.getLCFile("avatar");
if (!StringUtils.isEmpty(nickname)) { if (!StringUtils.isEmpty(nickname)) {
ProfileDrawerItem item = new ProfileDrawerItem().withName(nickname).withEmail(LCUser.getCurrentUser().getUsername()).withIdentifier(1003); // ProfileDrawerItem item = new ProfileDrawerItem().withName(nickname).withEmail(LCUser.getCurrentUser().getUsername()).withIdentifier(1003);
if (avatarFile == null) { // if (avatarFile == null) {
item.withIcon(R.drawable.app_logo); // item.withIcon(R.drawable.app_logo);
} else { // } else {
item.withIcon(avatarFile.getUrl()); // item.withIcon(avatarFile.getUrl());
} // }
accountHeader.addProfiles(item); // accountHeader.addProfiles(item);
//保存到_User,下次不再查Profile //保存到_User,下次不再查Profile
LCUser.getCurrentUser().put("nickname", nickname); LCUser.getCurrentUser().put("nickname", nickname);
if (avatarFile != null)
String avatarUrl = null;
if (avatarFile != null) {
LCUser.getCurrentUser().put("avatar", avatarFile); LCUser.getCurrentUser().put("avatar", avatarFile);
avatarUrl = avatarFile.getUrl();
}
LCUser.getCurrentUser().saveInBackground().subscribe(); LCUser.getCurrentUser().saveInBackground().subscribe();
mainActivityViewModel.getRefreshLoginUserLiveData().setValue(
new MainUserBean(LCUser.getCurrentUser().getUsername(),
nickname, avatarUrl));
} }
} }
@ -1097,19 +1121,28 @@ public class MainActivity extends BaseMainActivity implements Device.IDeviceConn
String nickname = list.get(0).getString("nickname"); String nickname = list.get(0).getString("nickname");
LCFile avatarFile = list.get(0).getLCFile("avatar"); LCFile avatarFile = list.get(0).getLCFile("avatar");
if (!StringUtils.isEmpty(nickname)) { if (!StringUtils.isEmpty(nickname)) {
ProfileDrawerItem item = new ProfileDrawerItem().withName(nickname).withEmail(LCUser.getCurrentUser().getUsername()).withIdentifier(1003); // ProfileDrawerItem item = new ProfileDrawerItem().withName(nickname).withEmail(LCUser.getCurrentUser().getUsername()).withIdentifier(1003);
if (avatarFile == null) { // if (avatarFile == null) {
item.withIcon(R.drawable.app_logo); // item.withIcon(R.drawable.app_logo);
} else { // } else {
item.withIcon(avatarFile.getUrl()); // item.withIcon(avatarFile.getUrl());
} // }
accountHeader.addProfiles(item); // accountHeader.addProfiles(item);
String avatarUrl = null;
//保存到_User,下次不再查Profile //保存到_User,下次不再查Profile
LCUser.getCurrentUser().put("nickname", nickname); LCUser.getCurrentUser().put("nickname", nickname);
if (avatarFile != null)
if (avatarFile != null) {
LCUser.getCurrentUser().put("avatar", avatarFile); LCUser.getCurrentUser().put("avatar", avatarFile);
avatarUrl = avatarFile.getUrl();
}
LCUser.getCurrentUser().saveInBackground().subscribe(); LCUser.getCurrentUser().saveInBackground().subscribe();
mainActivityViewModel.getRefreshLoginUserLiveData().setValue(
new MainUserBean(LCUser.getCurrentUser().getUsername(),
nickname, avatarUrl));
} }
} }
} }
@ -1127,7 +1160,10 @@ public class MainActivity extends BaseMainActivity implements Device.IDeviceConn
} }
} }
} else { } else {
accountHeader.addProfiles(new ProfileDrawerItem().withEmail(getString(R.string.click_avatar_to_log_in)).withIcon(R.drawable.app_logo).withIdentifier(1003)); // accountHeader.addProfiles(new ProfileDrawerItem().withEmail(getString(R.string.click_avatar_to_log_in)).withIcon(R.drawable.app_logo).withIdentifier(1003));
mainActivityViewModel.getRefreshLoginUserLiveData().setValue(
new MainUserBean(null,
null, null));
} }
} }
@ -1135,8 +1171,8 @@ public class MainActivity extends BaseMainActivity implements Device.IDeviceConn
* 开启左侧菜单 * 开启左侧菜单
*/ */
public void openLeftDrawer() { public void openLeftDrawer() {
if (drawerLeft != null) // if (drawerLeft != null)
drawerLeft.openDrawer(); // drawerLeft.openDrawer();
} }
@Override @Override
@ -1151,7 +1187,7 @@ public class MainActivity extends BaseMainActivity implements Device.IDeviceConn
@Override @Override
public void onDeviceConnectSucceed() { public void onDeviceConnectSucceed() {
mainActivityUtils.onDeviceConnectSuccess(); mainActivityUtils.onDeviceConnectSucceed();
} }
@Override @Override

@ -9,6 +9,7 @@ import android.location.Location;
import android.location.LocationManager; import android.location.LocationManager;
import android.os.Build; import android.os.Build;
import android.provider.Settings; import android.provider.Settings;
import android.view.View;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
@ -30,12 +31,14 @@ import com.bingce.device.service.comm.emulator.EmulatorService;
import com.bingce.device.service.comm.localgps.LocationService; import com.bingce.device.service.comm.localgps.LocationService;
import com.bingce.device.service.comm.localgps.NativePositioningService; import com.bingce.device.service.comm.localgps.NativePositioningService;
import com.bingce.device.service.comm.otg.OTGCommService; import com.bingce.device.service.comm.otg.OTGCommService;
import com.bingce.device.service.comm.socket.SocketCommService; import com.bingce.device.service.comm.socket.TsSocketService;
import com.bingce.device.service.comm.spp.BTService; import com.bingce.device.service.comm.spp.BTService;
import com.bingce.device.ui.ConnectLevelActivity;
import com.bingce.device.ui.ConnectRtkActivity; import com.bingce.device.ui.ConnectRtkActivity;
import com.bingce.device.ui.ConnectTSActivity; import com.bingce.device.ui.ConnectTSActivity;
import com.bingce.device.ui.utils.DeviceUtil; import com.bingce.device.ui.utils.DeviceUtil;
import com.bingce.device.ui.widget.BCProgressDialog; import com.bingce.device.ui.widget.BCProgressDialog;
import com.bingce.level.Level;
import com.bingce.rtk.event.RtkSpeechEvent; import com.bingce.rtk.event.RtkSpeechEvent;
import com.bingce.totalstation.TotalStation; import com.bingce.totalstation.TotalStation;
import com.bingce.totalstation.TsConfig; import com.bingce.totalstation.TsConfig;
@ -95,16 +98,17 @@ public class MainActivityUtils extends AppCompatActivityProviderUtils {
/** /**
* 连接设备成功后启动相关服务因为Ntrip与SN无关可以在此执行与SN相关的服务在RtkReceivedSerialNumberEvent事件后执行 * 连接设备成功后启动相关服务因为Ntrip与SN无关可以在此执行与SN相关的服务在RtkReceivedSerialNumberEvent事件后执行
*/ */
public void onDeviceConnectSuccess() { public void onDeviceConnectSucceed() {
if (deviceConnectingProgressDialog != null && deviceConnectingProgressDialog.isShowing()) { if (deviceConnectingProgressDialog != null && deviceConnectingProgressDialog.isShowing()) {
deviceConnectingProgressDialog.dismiss(); deviceConnectingProgressDialog.dismiss();
} }
if (!TotalStation.getInstance().isInitDone()) { if (Device.getInstance().deviceType == DeviceTypeEnum.DEVICE_TYPE_TS) {
TotalStation.getInstance().runnableStart(); TotalStation.getInstance().runnableStart();
TotalStation.getInstance().init(); TotalStation.getInstance().init();
} else if (Device.getInstance().deviceType == DeviceTypeEnum.DEVICE_TYPE_LEVEL) {
Level.getInstance().init();
} }
//记录用户联机时手机定位的大概位置 //记录用户联机时手机定位的大概位置
if (ActivityCompat.checkSelfPermission(/*this*/context(), Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) { if (ActivityCompat.checkSelfPermission(/*this*/context(), Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
LocationManager mLocationManager = ((LocationManager) context().getSystemService(Context.LOCATION_SERVICE)); LocationManager mLocationManager = ((LocationManager) context().getSystemService(Context.LOCATION_SERVICE));
@ -312,16 +316,16 @@ public class MainActivityUtils extends AppCompatActivityProviderUtils {
} else if (Device.getInstance().connectType == ConnectTypeEnum.CONNECT_TYPE_QXBT) { } else if (Device.getInstance().connectType == ConnectTypeEnum.CONNECT_TYPE_QXBT) {
//千寻RTK需要GnssServer连接蓝牙 //千寻RTK需要GnssServer连接蓝牙
} else if (Device.getInstance().connectType == ConnectTypeEnum.CONNECT_TYPE_HOTSPOT) { } else if (Device.getInstance().connectType == ConnectTypeEnum.CONNECT_TYPE_HOTSPOT) {
if (!ServiceUtils.isServiceRunning(SocketCommService.class.getName())) { if (!ServiceUtils.isServiceRunning(TsSocketService.class.getName())) {
ServiceUtils.startService(SocketCommService.class); ServiceUtils.startService(TsSocketService.class);
} }
} else if (Device.getInstance().connectType == ConnectTypeEnum.CONNECT_TYPE_OTG) { } else if (Device.getInstance().connectType == ConnectTypeEnum.CONNECT_TYPE_OTG) {
if (!ServiceUtils.isServiceRunning(OTGCommService.class.getName())) { if (!ServiceUtils.isServiceRunning(OTGCommService.class.getName())) {
ServiceUtils.startService(OTGCommService.class); ServiceUtils.startService(OTGCommService.class);
} }
} else if (Device.getInstance().connectType == ConnectTypeEnum.CONNECT_TYPE_TPCOM) { } else if (Device.getInstance().connectType == ConnectTypeEnum.CONNECT_TYPE_TPCOM) {
if (!ServiceUtils.isServiceRunning(SocketCommService.class.getName())) { if (!ServiceUtils.isServiceRunning(TsSocketService.class.getName())) {
ServiceUtils.startService(SocketCommService.class); ServiceUtils.startService(TsSocketService.class);
} }
} else if (Device.getInstance().connectType == ConnectTypeEnum.CONNECT_TYPE_PHONE_LOCATION) { } else if (Device.getInstance().connectType == ConnectTypeEnum.CONNECT_TYPE_PHONE_LOCATION) {
if (!ServiceUtils.isServiceRunning(NativePositioningService.class.getName())) { if (!ServiceUtils.isServiceRunning(NativePositioningService.class.getName())) {
@ -338,7 +342,7 @@ public class MainActivityUtils extends AppCompatActivityProviderUtils {
new MaterialDialog.Builder(ActivityUtils.getTopActivity()) new MaterialDialog.Builder(ActivityUtils.getTopActivity())
.title(R.string.quick_connect) .title(R.string.quick_connect)
.content(instrumentInfo) .content(instrumentInfo)
.positiveText(Device.getInstance().deviceType == DeviceTypeEnum.DEVICE_TYPE_TS ? R.string.connect_and_setup_station : R.string.connect) .positiveText(R.string.connect)
.negativeText(R.string.config) .negativeText(R.string.config)
.neutralText(R.string.switch_instrument) .neutralText(R.string.switch_instrument)
.onPositive(new MaterialDialog.SingleButtonCallback() { .onPositive(new MaterialDialog.SingleButtonCallback() {
@ -357,6 +361,8 @@ public class MainActivityUtils extends AppCompatActivityProviderUtils {
Intent intent; Intent intent;
if (Device.getInstance().deviceType == DeviceTypeEnum.DEVICE_TYPE_TS) { if (Device.getInstance().deviceType == DeviceTypeEnum.DEVICE_TYPE_TS) {
intent = new Intent(ActivityUtils.getTopActivity(), ConnectTSActivity.class); intent = new Intent(ActivityUtils.getTopActivity(), ConnectTSActivity.class);
} else if (Device.getInstance().deviceType == DeviceTypeEnum.DEVICE_TYPE_LEVEL) {
intent = new Intent(ActivityUtils.getTopActivity(), ConnectLevelActivity.class);
} else { } else {
intent = new Intent(ActivityUtils.getTopActivity(), ConnectRtkActivity.class); intent = new Intent(ActivityUtils.getTopActivity(), ConnectRtkActivity.class);
} }
@ -379,6 +385,8 @@ public class MainActivityUtils extends AppCompatActivityProviderUtils {
Intent intent; Intent intent;
if (Device.getInstance().deviceType == DeviceTypeEnum.DEVICE_TYPE_TS) { if (Device.getInstance().deviceType == DeviceTypeEnum.DEVICE_TYPE_TS) {
intent = new Intent(ActivityUtils.getTopActivity(), ConnectTSActivity.class); intent = new Intent(ActivityUtils.getTopActivity(), ConnectTSActivity.class);
} else if (Device.getInstance().deviceType == DeviceTypeEnum.DEVICE_TYPE_LEVEL) {
intent = new Intent(ActivityUtils.getTopActivity(), ConnectLevelActivity.class);
} else { } else {
intent = new Intent(ActivityUtils.getTopActivity(), ConnectRtkActivity.class); intent = new Intent(ActivityUtils.getTopActivity(), ConnectRtkActivity.class);
} }
@ -389,9 +397,26 @@ public class MainActivityUtils extends AppCompatActivityProviderUtils {
} }
private void chooseInstrumentType() { private void chooseInstrumentType() {
Intent intent = new Intent(ActivityUtils.getTopActivity(), ConnectTSActivity.class); new MaterialDialog.Builder(ActivityUtils.getTopActivity())
intent.putExtra("customChannel", AppChannel.customChannel); .title(R.string.choose_instrument_type)
ActivityUtils.getTopActivity().startActivity(intent); .items(new String[]{ActivityUtils.getTopActivity().getString(R.string.total_station), ActivityUtils.getTopActivity().getString(R.string.device_type_level)})
.itemsCallback(new MaterialDialog.ListCallback() {
@Override
public void onSelection(MaterialDialog dialog, View itemView, int which, CharSequence text) {
switch (which) {
case 0:
Intent intent = new Intent(ActivityUtils.getTopActivity(), ConnectTSActivity.class);
intent.putExtra("customChannel", AppChannel.customChannel);
ActivityUtils.getTopActivity().startActivity(intent);
break;
case 1:
Intent intent2 = new Intent(ActivityUtils.getTopActivity(), ConnectLevelActivity.class);
intent2.putExtra("customChannel", AppChannel.customChannel);
ActivityUtils.getTopActivity().startActivity(intent2);
break;
}
}
}).show();
} }
@ -413,7 +438,7 @@ public class MainActivityUtils extends AppCompatActivityProviderUtils {
ServiceUtils.stopService(NativePositioningService.class); ServiceUtils.stopService(NativePositioningService.class);
ServiceUtils.stopService(BTService.class); ServiceUtils.stopService(BTService.class);
ServiceUtils.stopService(BleService.class); ServiceUtils.stopService(BleService.class);
ServiceUtils.startService(SocketCommService.class); ServiceUtils.startService(TsSocketService.class);
ThreadPoolUtil.execute(new Runnable() { ThreadPoolUtil.execute(new Runnable() {
@Override @Override
public void run() { public void run() {

@ -7,6 +7,7 @@ import android.content.Intent;
import androidx.activity.result.ActivityResultLauncher; import androidx.activity.result.ActivityResultLauncher;
import androidx.activity.result.contract.ActivityResultContracts; import androidx.activity.result.contract.ActivityResultContracts;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
public class BackupImportHelper { public class BackupImportHelper {
private ICallback callback; private ICallback callback;
@ -22,6 +23,16 @@ public class BackupImportHelper {
}); });
} }
public BackupImportHelper(Fragment fragment) {
importLauncher = fragment.registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> {
if (callback == null) {
return;
}
boolean success = result != null && Activity.RESULT_OK == result.getResultCode();
callback.onImported(success);
});
}
public void doImport(Context context, ICallback callback) { public void doImport(Context context, ICallback callback) {
this.callback = callback; this.callback = callback;
Intent intent = MigrationFolder2PrivateRoomActivity.intent(context, true); Intent intent = MigrationFolder2PrivateRoomActivity.intent(context, true);

@ -89,7 +89,7 @@ public class ZipMigrationUtils {
private static File[] unzipBackupFile(File duplicate, File unzipFolder, String errorString) { private static File[] unzipBackupFile(File duplicate, File unzipFolder, String errorString) {
if (!unzipFolder.exists()) { if (!unzipFolder.exists()) {
if (!unzipFolder.mkdir()) { if (!unzipFolder.mkdirs()) {
ToastUtils.showShort("解压备份文件失败"); ToastUtils.showShort("解压备份文件失败");
return null; return null;
} }
@ -102,7 +102,7 @@ public class ZipMigrationUtils {
ToastUtils.showShort("解压备份文件失败"); ToastUtils.showShort("解压备份文件失败");
return null; return null;
} }
if (!unzipFolder.mkdir()) { if (!unzipFolder.mkdirs()) {
ToastUtils.showShort("解压备份文件失败"); ToastUtils.showShort("解压备份文件失败");
return null; return null;
} }

@ -15,30 +15,6 @@ import com.bingce.controlnetwork.fragment.SurveyorSettingsFragment;
import com.bingce.controlnetwork.fragment.ToleranceDetailFragment; import com.bingce.controlnetwork.fragment.ToleranceDetailFragment;
import com.bingce.controlnetwork.fragment.ToleranceManageFragment; import com.bingce.controlnetwork.fragment.ToleranceManageFragment;
import com.bingce.controlnetwork.fragment.ToleranceSelectFragment; import com.bingce.controlnetwork.fragment.ToleranceSelectFragment;
import com.bingce.controlnetwork.fragment.station.line.attached.LineStationAttachedSetupFragment;
import com.bingce.controlnetwork.fragment.station.line.close.LineStationCloseSetupFragment;
import com.bingce.controlnetwork.fragment.station.line.random.LineStationRandomSetupFragment;
import com.bingce.controlnetwork.fragment.station.line.single.LineStationSingleSetupFragment;
import com.bingce.controlnetwork.fragment.station.line.well.LineStationWellDoubleGroundSetupFragment;
import com.bingce.controlnetwork.fragment.station.line.well.LineStationWellDoubleUnderGroundSetupFragment;
import com.bingce.controlnetwork.fragment.station.line.well.LineStationWellSetupFragment;
import java.util.HashMap;
import java.util.Map;
import com.bingce.controlnetwork.fragment.PickPointFragment;
import com.bingce.controlnetwork.fragment.PointListFragment;
import com.bingce.controlnetwork.fragment.PrismManageFragment;
import com.bingce.controlnetwork.fragment.ProjectToleranceSettingFragment;
import com.bingce.controlnetwork.fragment.SelectExportHeightTraverseFragment;
import com.bingce.controlnetwork.fragment.SelectExportSurveyorRecordFragment;
import com.bingce.controlnetwork.fragment.SelectExportSurveyorRecordWireFileFragment;
import com.bingce.controlnetwork.fragment.stationsetting.StationSettingHeightTraverseFragment;
import com.bingce.controlnetwork.fragment.stationsetting.StationSettingsFragment;
import com.bingce.controlnetwork.fragment.SurveyorSettingsFragment;
import com.bingce.controlnetwork.fragment.ToleranceDetailFragment;
import com.bingce.controlnetwork.fragment.ToleranceManageFragment;
import com.bingce.controlnetwork.fragment.ToleranceSelectFragment;
import com.bingce.controlnetwork.fragment.projectdetail.ProjectDetailHeightTraverseFragment; import com.bingce.controlnetwork.fragment.projectdetail.ProjectDetailHeightTraverseFragment;
import com.bingce.controlnetwork.fragment.projectdetail.ProjectDetailTriangleFragment; import com.bingce.controlnetwork.fragment.projectdetail.ProjectDetailTriangleFragment;
import com.bingce.controlnetwork.fragment.station.defaultstation.DefaultStationSetupFragment; import com.bingce.controlnetwork.fragment.station.defaultstation.DefaultStationSetupFragment;
@ -51,9 +27,18 @@ import com.bingce.controlnetwork.fragment.station.line.well.LineStationWellDoubl
import com.bingce.controlnetwork.fragment.station.line.well.LineStationWellDoubleUnderGroundSetupFragment; import com.bingce.controlnetwork.fragment.station.line.well.LineStationWellDoubleUnderGroundSetupFragment;
import com.bingce.controlnetwork.fragment.station.line.well.LineStationWellSetupFragment; import com.bingce.controlnetwork.fragment.station.line.well.LineStationWellSetupFragment;
import com.bingce.controlnetwork.fragment.stationdetail.SingleStationDetailAndEditFragment; import com.bingce.controlnetwork.fragment.stationdetail.SingleStationDetailAndEditFragment;
import com.bingce.controlnetwork.fragment.stationsetting.StationSettingHeightTraverseFragment;
import com.bingce.controlnetwork.fragment.stationsetting.StationSettingsFragment;
import com.bingce.controlnetwork.fragment.stationsurvey.StationSurveyorFragment; import com.bingce.controlnetwork.fragment.stationsurvey.StationSurveyorFragment;
import com.bingce.controlnetwork.fragment.stationsurvey.angledistance.MeasureFragment; import com.bingce.controlnetwork.fragment.stationsurvey.angledistance.MeasureFragment;
import com.bingce.controlnetwork.fragment.stationsurvey.heighttraverse.MeasureHeightTraverseFragment; import com.bingce.controlnetwork.fragment.stationsurvey.heighttraverse.MeasureHeightTraverseFragment;
import com.bingce.controlnetwork.func.level.fragment.LevelRouteCreateEditFragment;
import com.bingce.controlnetwork.func.level.fragment.LevelSelectExportFragment;
import com.bingce.controlnetwork.func.level.fragment.LevelSurveyFragment;
import com.bingce.controlnetwork.func.level.fragment.ProjectDetailLevelFragment;
import java.util.HashMap;
import java.util.Map;
public class FragmentContainer { public class FragmentContainer {
private interface IBuilder { private interface IBuilder {
@ -91,6 +76,10 @@ public class FragmentContainer {
factory.put(MeasureHeightTraverseFragment.TAG, MeasureHeightTraverseFragment::newInstance); factory.put(MeasureHeightTraverseFragment.TAG, MeasureHeightTraverseFragment::newInstance);
factory.put(SelectExportHeightTraverseFragment.TAG, SelectExportHeightTraverseFragment::newInstance); factory.put(SelectExportHeightTraverseFragment.TAG, SelectExportHeightTraverseFragment::newInstance);
factory.put(StationSettingHeightTraverseFragment.TAG, StationSettingHeightTraverseFragment::newInstance); factory.put(StationSettingHeightTraverseFragment.TAG, StationSettingHeightTraverseFragment::newInstance);
factory.put(ProjectDetailLevelFragment.TAG, ProjectDetailLevelFragment::newInstance);
factory.put(LevelSurveyFragment.TAG, LevelSurveyFragment::newInstance);
factory.put(LevelSelectExportFragment.TAG, LevelSelectExportFragment::newInstance);
factory.put(LevelRouteCreateEditFragment.TAG, LevelRouteCreateEditFragment::newInstance);
} }
public static Fragment getFragment(String tag, Bundle bundle) { public static Fragment getFragment(String tag, Bundle bundle) {

@ -96,7 +96,7 @@ public class OpeningRenewalVipActivity extends ColorfulActivity {
if (total_fee <= 0) { if (total_fee <= 0) {
binding.activityOpeningRenewalTvTotalFee.setText("联网获取价格"); binding.activityOpeningRenewalTvTotalFee.setText("联网获取价格");
} else { } else {
binding.activityOpeningRenewalTvTotalFee.setText(Util.formatDouble2String(total_fee / 100.0) + "元"); binding.activityOpeningRenewalTvTotalFee.setText(Util.formatDouble2StringDotAuto(total_fee / 100.0) + "元");
} }
} }
}); });
@ -145,7 +145,7 @@ public class OpeningRenewalVipActivity extends ColorfulActivity {
if (total_fee <= 0) { if (total_fee <= 0) {
binding.activityOpeningRenewalTvTotalFee.setText("联网获取价格"); binding.activityOpeningRenewalTvTotalFee.setText("联网获取价格");
} else { } else {
binding.activityOpeningRenewalTvTotalFee.setText(Util.formatDouble2String(total_fee / 100.0) + "元"); binding.activityOpeningRenewalTvTotalFee.setText(Util.formatDouble2StringDotAuto(total_fee / 100.0) + "元");
} }
} catch (Exception ex) { } catch (Exception ex) {
ex.printStackTrace(); ex.printStackTrace();

@ -25,8 +25,8 @@ import androidx.core.content.ContextCompat;
import com.afollestad.materialdialogs.DialogAction; import com.afollestad.materialdialogs.DialogAction;
import com.afollestad.materialdialogs.MaterialDialog; import com.afollestad.materialdialogs.MaterialDialog;
import com.bingce.AppChannel;
import com.bingce.controlapphelper.util.SettingValueUtil; import com.bingce.controlapphelper.util.SettingValueUtil;
import com.bingce.controlnetwork.App;
import com.bingce.controlnetwork.R; import com.bingce.controlnetwork.R;
import com.bingce.data.sync.utils.LeanCloudConfigLoader; import com.bingce.data.sync.utils.LeanCloudConfigLoader;
import com.bingce.device.enums.SpecialDeviceEnum; import com.bingce.device.enums.SpecialDeviceEnum;
@ -36,6 +36,7 @@ import com.bingce.utils.AppUtil;
import com.bingce.utils.ClipboardUtils; import com.bingce.utils.ClipboardUtils;
import com.bingce.utils.PropertiesGet; import com.bingce.utils.PropertiesGet;
import com.bingce.utils.RegisterUtil; import com.bingce.utils.RegisterUtil;
import com.bingce.utils.SdkUtils;
import com.bingce.utils.StringUtil; import com.bingce.utils.StringUtil;
import com.bingce.utils.Util; import com.bingce.utils.Util;
import com.bingce.utils.VipManager; import com.bingce.utils.VipManager;
@ -60,9 +61,6 @@ import cn.leancloud.LCException;
import cn.leancloud.LCObject; import cn.leancloud.LCObject;
import cn.leancloud.LCQuery; import cn.leancloud.LCQuery;
import cn.leancloud.LCUser; import cn.leancloud.LCUser;
import com.bingce.controlnetwork.App;
import io.reactivex.Observer; import io.reactivex.Observer;
import io.reactivex.disposables.Disposable; import io.reactivex.disposables.Disposable;
@ -90,13 +88,8 @@ public class RegisterActivity extends ColorfulActivity {
mTextViewVersion.setText("V" + AppUtils.getAppVersionName()); mTextViewVersion.setText("V" + AppUtils.getAppVersionName());
if (AppChannel.customChannel != AppChannel.CUSTOM_INTERNATIONAL if (!AppUtil.isZh() && SdkUtils.isRegCodeValidate() && !SdkUtils.isIntlCodeValidate()) {//非中文环境需要国际许可码
&& AppChannel.customChannel != AppChannel.CUSTOM_TERSUS_INTERNATIONAL DialogUtil.mDismissAlertDialog(this, R.string.hint, R.string.you_need_apply_for_an_international_license_code, R.string.i_know, null, null);
&& AppChannel.customChannel != AppChannel.CUSTOM_PENTAX_INTERNATIONAL
&& AppChannel.customChannel != AppChannel.CUSTOM_TUNNEL_AUTO_SCAN) {
if (!AppUtil.isZh()) {//国内发行版本在非简体中文语言下不可用
DialogUtil.mDismissAlertDialog(this, R.string.hint, R.string.activation_can_only_use_in_simple_chinese, R.string.i_know, null, dialogInterface -> finish());
}
} }
boolean isSpecial = false; boolean isSpecial = false;
@ -152,7 +145,7 @@ public class RegisterActivity extends ColorfulActivity {
if (checkStoragePermission != PackageManager.PERMISSION_GRANTED) { if (checkStoragePermission != PackageManager.PERMISSION_GRANTED) {
requestPhoneStatePermission(this); requestPhoneStatePermission(this);
} else { } else {
if ("SERIALNUMBERunknown".equals(RegisterUtil.getOriginalMachineCode()) || "SERIALNUMBERnull".equals(RegisterUtil.getOriginalMachineCode())) { if ("".equals(RegisterUtil.getOriginalMachineCode()) || "SERIALNUMBERunknown".equals(RegisterUtil.getOriginalMachineCode()) || "SERIALNUMBERnull".equals(RegisterUtil.getOriginalMachineCode())) {
new MaterialDialog.Builder(this) new MaterialDialog.Builder(this)
.title(R.string.hint) .title(R.string.hint)
.content("此手机机器码未知,请关闭相关限制软件请重启软件") .content("此手机机器码未知,请关闭相关限制软件请重启软件")
@ -174,7 +167,7 @@ public class RegisterActivity extends ColorfulActivity {
mBtnActivate.setText(R.string.activated); mBtnActivate.setText(R.string.activated);
} }
mMachineCode = RegisterUtil.getEncryptMachineCode(); mMachineCode = RegisterUtil.getEncryptMachineCodeInfo();
mOriginalMachineCode = RegisterUtil.getOriginalMachineCode(); mOriginalMachineCode = RegisterUtil.getOriginalMachineCode();
if (mMachineCode != null) { if (mMachineCode != null) {
met_machine_code.setText(mMachineCode); met_machine_code.setText(mMachineCode);
@ -226,14 +219,6 @@ public class RegisterActivity extends ColorfulActivity {
mBtnActivate.setOnClickListener(new OnClickListener() { mBtnActivate.setOnClickListener(new OnClickListener() {
@Override @Override
public void onClick(View arg0) { public void onClick(View arg0) {
if (AppChannel.customChannel != AppChannel.CUSTOM_INTERNATIONAL
&& AppChannel.customChannel != AppChannel.CUSTOM_TERSUS_INTERNATIONAL
&& AppChannel.customChannel != AppChannel.CUSTOM_PENTAX_INTERNATIONAL
&& AppChannel.customChannel != AppChannel.CUSTOM_TUNNEL_AUTO_SCAN) {
if (!AppUtil.isZh()) {//国内发行版本在非简体中文语言下不可用
DialogUtil.mDismissAlertDialog(RegisterActivity.this, R.string.hint, R.string.activation_can_only_use_in_simple_chinese, R.string.i_know, null, null);
}
}
final String registerCode = met_activate_code.getText().toString().trim().toUpperCase(Locale.CHINA).replaceAll(" |\n|\r", ""); final String registerCode = met_activate_code.getText().toString().trim().toUpperCase(Locale.CHINA).replaceAll(" |\n|\r", "");
if (mMachineCode == null) { if (mMachineCode == null) {
ToastUtils.showShort(R.string.machine_code_illegal); ToastUtils.showShort(R.string.machine_code_illegal);
@ -267,58 +252,61 @@ public class RegisterActivity extends ColorfulActivity {
if (avObjects == null || avObjects.isEmpty()) { if (avObjects == null || avObjects.isEmpty()) {
new LCQuery<>("Device") new LCQuery<>("Device")
.whereEqualTo("machineCode", mOriginalMachineCode) .whereEqualTo("machineCode", mOriginalMachineCode)
.whereEqualTo("controlRegCode", registerCode)
.limit(1) .limit(1)
.findInBackground() .findInBackground().subscribe(new Observer<List<LCObject>>() {
.subscribe(new Observer<List<LCObject>>() {
@Override @Override
public void onSubscribe(Disposable d) { public void onSubscribe(Disposable disposable) {
} }
@Override @Override
public void onNext(final List<LCObject> devices) { public void onNext(List<LCObject> lcObjects) {
if (isFinishing()) return; if (isFinishing()) return;
if (devices != null && !devices.isEmpty() if (!lcObjects.isEmpty()) {
&& devices.get(0).getBoolean("activated") if (lcObjects.get(0).getBoolean("activated") && !lcObjects.get(0).getBoolean("converted")) {
&& !devices.get(0).getBoolean("converted")) { ((App) Utils.getApp()).registerCodeV2 = registerCode;
((App) Utils.getApp()).registerCodeV2 = registerCode; Util.putPreference("registerCodeV2", registerCode);
Util.putPreference("registerCodeV2", registerCode);
VipManager.getInstance().controlSdkRefresh(RegisterActivity.this, ((App) Utils.getApp()).registerCodeV2, new VipManager.OnSdkRefreshListener() {
VipManager.getInstance().controlSdkRefresh(RegisterActivity.this, ((App) Utils.getApp()).registerCodeV2, new VipManager.OnSdkRefreshListener() { @Override
@Override public void onRefreshSuccess() {
public void onRefreshSuccess() { progressDialog.dismiss();
progressDialog.dismiss(); getSupportActionBar().setTitle(R.string.activated);
getSupportActionBar().setTitle(R.string.activated); mBtnActivate.setEnabled(false);
mBtnActivate.setEnabled(false); met_activate_code.setEnabled(false);
met_activate_code.setEnabled(false); ToastUtils.showShort(R.string.activate_success);
ToastUtils.showShort(R.string.activate_success); }
}
@Override
@Override public void onRefreshFailed(int errorCode) {
public void onRefreshFailed(int errorCode) { progressDialog.dismiss();
progressDialog.dismiss(); ToastUtils.showShort(getString(R.string.error_code) + ":" + errorCode);
ToastUtils.showShort(getString(R.string.error_code) + ":" + errorCode); }
} });
}); //激活次数+1
//激活次数+1 lcObjects.get(0).increment("activationTimes");
devices.get(0).increment("activationTimes"); lcObjects.get(0).saveInBackground().subscribe();
devices.get(0).saveInBackground().subscribe(); } else if (lcObjects.get(0).getBoolean("converted")) {
} else if (devices.get(0).getBoolean("converted")) { progressDialog.dismiss();
progressDialog.dismiss(); ToastUtils.showShort("此设备已经兑换过年会员,无法再绑定手机");
ToastUtils.showShort("此设备已经兑换过年会员,无法再绑定手机"); } else if (!lcObjects.get(0).getBoolean("activated")) {
} else if (!devices.get(0).getBoolean("activated")) { progressDialog.dismiss();
progressDialog.dismiss(); ToastUtils.showShort("无法激活,请联系开发人员");
ToastUtils.showShort("无法激活,请联系开发人员"); } else {
progressDialog.dismiss();
ToastUtils.showShort(R.string.cloud_has_not_register_code);
}
} else { } else {
progressDialog.dismiss(); progressDialog.dismiss();
ToastUtils.showShort(R.string.cloud_has_not_register_code); ToastUtils.showShort("激活码无效");
} }
} }
@Override @Override
public void onError(Throwable e) { public void onError(Throwable throwable) {
progressDialog.dismiss(); progressDialog.dismiss();
ToastUtils.showShort(getString(R.string.error_code) + ":" + new LCException(e).getCode()); ToastUtils.showShort(getString(R.string.error_code) + ":" + new LCException(throwable).getCode());
} }
@Override @Override

@ -33,9 +33,10 @@ import com.afollestad.materialdialogs.MaterialDialog;
import com.afollestad.materialdialogs.internal.MDButton; import com.afollestad.materialdialogs.internal.MDButton;
import com.bingce.AppChannel; import com.bingce.AppChannel;
import com.bingce.controlapphelper.util.SettingValueUtil; import com.bingce.controlapphelper.util.SettingValueUtil;
import com.bingce.controlnetwork.App;
import com.bingce.controlnetwork.R;
import com.bingce.controlnetwork.databinding.DialogEditNicknameBinding;
import com.bingce.controlnetwork.ui.WechatImagePicker; import com.bingce.controlnetwork.ui.WechatImagePicker;
import com.bingce.device.ui.dialog.DialogUtil;
import com.bingce.utils.AppUtil;
import com.bingce.utils.DateUtils; import com.bingce.utils.DateUtils;
import com.bingce.utils.FileUtil; import com.bingce.utils.FileUtil;
import com.bingce.utils.LCDeviceUtil; import com.bingce.utils.LCDeviceUtil;
@ -67,11 +68,6 @@ import cn.leancloud.LCFile;
import cn.leancloud.LCObject; import cn.leancloud.LCObject;
import cn.leancloud.LCQuery; import cn.leancloud.LCQuery;
import cn.leancloud.LCUser; import cn.leancloud.LCUser;
import com.bingce.controlnetwork.App;
import com.bingce.controlnetwork.R;
import com.bingce.controlnetwork.databinding.DialogEditNicknameBinding;
import de.hdodenhof.circleimageview.CircleImageView; import de.hdodenhof.circleimageview.CircleImageView;
import id.zelory.compressor.Compressor; import id.zelory.compressor.Compressor;
import io.reactivex.Observer; import io.reactivex.Observer;
@ -119,13 +115,6 @@ public class UserInfoActivity extends ColorfulActivity {
btn_opening_renewal = findViewById(R.id.activity_user_info_btn_opening_renewal); btn_opening_renewal = findViewById(R.id.activity_user_info_btn_opening_renewal);
btn_log_out = findViewById(R.id.activity_user_info_btn_log_out); btn_log_out = findViewById(R.id.activity_user_info_btn_log_out);
if (AppChannel.customChannel != AppChannel.CUSTOM_CONTROL_INTERNATIONAL
&& AppChannel.customChannel != AppChannel.CUSTOM_CONTROL_INTERNATIONAL_PRO) {
if (!AppUtil.isZh()) {//国内发行版本在非简体中文语言下不可用
DialogUtil.mDismissAlertDialog(this, R.string.hint, R.string.activation_can_only_use_in_simple_chinese, R.string.i_know, null, null);
}
}
updateUserInfo(); updateUserInfo();
avatarImageView.setOnClickListener(new View.OnClickListener() { avatarImageView.setOnClickListener(new View.OnClickListener() {
@ -294,7 +283,7 @@ public class UserInfoActivity extends ColorfulActivity {
LCDeviceUtil.updateDeviceInfo("controlnetwork", ((App) Utils.getApp()).registerCodeV2, new LCDeviceUtil.OnDeviceUpdateListener() { LCDeviceUtil.updateDeviceInfo("controlnetwork", ((App) Utils.getApp()).registerCodeV2, new LCDeviceUtil.OnDeviceUpdateListener() {
@Override @Override
public void onUpdateSuccess() { public void onUpdateSuccess() {
VipManager.getInstance().surveyorSdkRefresh(UserInfoActivity.this, ((App) Utils.getApp()).registerCodeV2, new VipManager.OnSdkRefreshListener() { VipManager.getInstance().controlSdkRefresh(UserInfoActivity.this, ((App) Utils.getApp()).registerCodeV2, new VipManager.OnSdkRefreshListener() {
@Override @Override
public void onRefreshSuccess() { public void onRefreshSuccess() {
progressDialog.dismiss(); progressDialog.dismiss();
@ -434,10 +423,7 @@ public class UserInfoActivity extends ColorfulActivity {
} }
if (!VipManager.getInstance().checkReg() if (!VipManager.getInstance().checkReg()
&& ((VipManager.getInstance().level > 0 && VipManager.getInstance().isInExpireDate) && (VipManager.getInstance().isCnLevelExpireTimeValid() || VipManager.getInstance().isIntlLevelExpireTimeValid())
|| (VipManager.getInstance().eduLevel > 0 && VipManager.getInstance().isEduInExpireDate)
|| (VipManager.getInstance().intlLevel > 0 && VipManager.getInstance().isIntlInExpireDate)
|| (VipManager.getInstance().controlLevel > 0 && VipManager.getInstance().isControlInExpireDate))
&& !VipManager.getInstance().isControlBoundDevice) { && !VipManager.getInstance().isControlBoundDevice) {
new MaterialDialog.Builder(UserInfoActivity.this) new MaterialDialog.Builder(UserInfoActivity.this)
.title(R.string.hint) .title(R.string.hint)

@ -25,7 +25,8 @@ public class PointSelectAdapter extends AbstractPointSelectAdapter {
@Override @Override
public int getGroupCount() { public int getGroupCount() {
return data.groupCount() + 1; // return data.groupCount() + 1;
return data.groupCount() ;
} }
@Override @Override

@ -6,6 +6,7 @@ import android.widget.BaseExpandableListAdapter;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import com.bingce.controlapphelper.interfacee.IProjectTolerance;
import com.bingce.controlapphelper.model.ProjectTolerance; import com.bingce.controlapphelper.model.ProjectTolerance;
import com.bingce.controlapphelper.model.UniversalListItem; import com.bingce.controlapphelper.model.UniversalListItem;
import com.bingce.controlapphelper.model.ViewItemType; import com.bingce.controlapphelper.model.ViewItemType;
@ -22,17 +23,17 @@ import java.util.List;
* 限差详情adapter * 限差详情adapter
* */ * */
public class ToleranceDetailAdapter extends BaseExpandableListAdapter { public class ToleranceDetailAdapter extends BaseExpandableListAdapter {
private ProjectTolerance data; private IProjectTolerance data;
private static final List<ViewItemType> childTypes = private static final List<ViewItemType> childTypes =
Arrays.asList( Arrays.asList(
ViewItemType.nameWithBool, ViewItemType.nameWithBool,
ViewItemType.nameWithText); ViewItemType.nameWithText);
public ToleranceDetailAdapter(ProjectTolerance limit) { public ToleranceDetailAdapter(IProjectTolerance limit) {
data = limit; data = limit;
} }
public void updateData(ProjectTolerance limit) { public void updateData(IProjectTolerance limit) {
this.data = limit; this.data = limit;
notifyDataSetChanged(); notifyDataSetChanged();
} }

@ -0,0 +1,13 @@
package com.bingce.controlnetwork.bean;
public class MainUserBean {
public String userName;
public String nickName;
public String avator;
public MainUserBean(String userName, String nickName, String avator) {
this.userName = userName;
this.nickName = nickName;
this.avator = avator;
}
}

@ -0,0 +1,21 @@
package com.bingce.controlnetwork.event;
public class RefreshEvent<T> {
public static final int REFRESH_BY_LEVEL_I_DETECTION_SETTING_UPDATE = 3;
private int type;
private T data;
public RefreshEvent(int type, T data) {
this.type = type;
this.data = data;
}
public int getType() {
return type;
}
public T getData() {
return data;
}
}

@ -0,0 +1,4 @@
package com.bingce.controlnetwork.event;
public class RefreshToleranceTotailEvent {
}

@ -14,12 +14,10 @@ import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import com.bingce.controlapphelper.model.IUniversalListItem; import com.bingce.controlapphelper.model.IUniversalListItem;
import org.jetbrains.annotations.NotNull;
import com.bingce.controlnetwork.R; import com.bingce.controlnetwork.R;
import com.bingce.controlnetwork.adapter.IndexWithTextAdapter; import com.bingce.controlnetwork.adapter.IndexWithTextAdapter;
import com.bingce.controlnetwork.adapter.IndexWithTextAdapter;
import org.jetbrains.annotations.NotNull;
public abstract class AbstractHierarchicalListFragment extends Fragment { public abstract class AbstractHierarchicalListFragment extends Fragment {
private View layout1; private View layout1;
@ -32,7 +30,7 @@ public abstract class AbstractHierarchicalListFragment extends Fragment {
private RecyclerView recyclerView2; private RecyclerView recyclerView2;
private boolean is1Layout = true;//通知当前显示的是layout1还是layout2 private boolean is1Layout = true;//通知当前显示的是layout1还是layout2
private int currentListIndex = 0;//当前显示的list在所有集合中的index private int currentListIndex = 0;//当前显示的list在所有集合中的index
private final IndexWithTextAdapter.IOnItemClick<Item> callback = item -> onItemClicked(currentListIndex, item); private final IndexWithTextAdapter.IOnItemClick<IUniversalListItem<?>> callback = item -> onItemClicked(currentListIndex, item);
@Nullable @Nullable
@org.jetbrains.annotations.Nullable @org.jetbrains.annotations.Nullable
@ -121,7 +119,7 @@ public abstract class AbstractHierarchicalListFragment extends Fragment {
RecyclerView recyclerView1, RecyclerView recyclerView1,
RecyclerView recyclerView2, RecyclerView recyclerView2,
AbstractHierarchicalListFragment fragment, AbstractHierarchicalListFragment fragment,
final IndexWithTextAdapter.IOnItemClick<Item> callback, final IndexWithTextAdapter.IOnItemClick<IUniversalListItem<?>> callback,
boolean targetLayoutIsLayout1, boolean targetLayoutIsLayout1,
int listIndex, int listIndex,
boolean moveForward) { boolean moveForward) {
@ -174,14 +172,14 @@ public abstract class AbstractHierarchicalListFragment extends Fragment {
} }
//通知child,通知list的item被点击,下一步执行 forward或结束加载 //通知child,通知list的item被点击,下一步执行 forward或结束加载
protected abstract void onItemClicked(int currentListIndex, Item item); protected abstract void onItemClicked(int currentListIndex, IUniversalListItem<?> item);
//通知child,准备back,用于加载数据 //通知child,准备back,用于加载数据
protected abstract void onBackClicked(int currentListIndex); protected abstract void onBackClicked(int currentListIndex);
//通知child,加载相应list的数据 //通知child,加载相应list的数据
protected abstract void setupList(int listIndex, TextView title, RecyclerView recyclerView, protected abstract void setupList(int listIndex, TextView title, RecyclerView recyclerView,
final IndexWithTextAdapter.IOnItemClick<Item> callback); final IndexWithTextAdapter.IOnItemClick<IUniversalListItem<?>> callback);
protected static class Item implements IUniversalListItem<String> { protected static class Item implements IUniversalListItem<String> {
private final String name; private final String name;

@ -11,23 +11,21 @@ import androidx.annotation.Nullable;
import androidx.annotation.WorkerThread; import androidx.annotation.WorkerThread;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import com.bingce.controlapphelper.datasource.database.ProjectType; import com.bingce.controlapphelper.datasource.database.tolerance.detail.IToleranceDetail;
import com.bingce.controlapphelper.datasource.database.SurveyorDatabaseFactory;
import com.bingce.controlapphelper.datasource.database.ToleranceTemplate;
import com.bingce.controlapphelper.datasource.database.tolerance.detail.IToleranceDetailDataSource;
import com.bingce.controlapphelper.datasource.database.tolerance.detail.ToleranceDetailRecord;
import com.bingce.controlapphelper.datasource.database.tolerance.group.ToleranceGroupConstants;
import com.bingce.controlapphelper.datasource.database.tolerance.group.ToleranceGroupRecord; import com.bingce.controlapphelper.datasource.database.tolerance.group.ToleranceGroupRecord;
import com.bingce.controlapphelper.datasource.database.tolerance.level.ToleranceLevelRecord; import com.bingce.controlapphelper.datasource.database.tolerance.level.ToleranceLevelRecord;
import com.bingce.controlapphelper.datasource.database.tolerance.load.IToleranceOperate;
import com.bingce.controlapphelper.datasource.database.tolerance.load.ToleranceLoadUtil;
import com.bingce.controlapphelper.model.BundleConstants; import com.bingce.controlapphelper.model.BundleConstants;
import com.bingce.controlapphelper.util.ToleranceUtil; import com.bingce.controlapphelper.util.ToleranceUtil;
import com.bingce.controlnetwork.R;
import com.bingce.controlnetwork.fragment.base.BaseFragment; import com.bingce.controlnetwork.fragment.base.BaseFragment;
import com.bingce.controlnetwork.ui.ViewUtil; import com.bingce.controlnetwork.ui.ViewUtil;
import com.bingce.controlnetwork.ui.widget.TextItemWithMore; import com.bingce.controlnetwork.ui.widget.TextItemWithMore;
import com.bingce.controlnetwork.util.tolerance.ToleranceOperateUtil;
import com.bingce.utils.IOnSingleGetCallback;
import com.bingce.utils.ThreadPoolUtil; import com.bingce.utils.ThreadPoolUtil;
import java.util.List; import com.bingce.controlnetwork.R;
/* /*
* 项目限差详情包含'LimitDetailFragment'+选择模板 * 项目限差详情包含'LimitDetailFragment'+选择模板
@ -61,42 +59,26 @@ public abstract class AbstractProjectToleranceFragment extends BaseFragment {
* *
* @param projectType * @param projectType
*/ */
protected ToleranceDetailRecord getFirstDefaultTolerance(String projectType) { protected IToleranceDetail getNewDefaultTolerance(String projectType) {
return ProjectType.getTarget(projectType, (projectTypeBack) -> { return ToleranceLoadUtil.getToleranceLoad(projectType).getNewDefaultTolerance(projectType);
List<ToleranceDetailRecord> list = null;
if (projectTypeBack == ProjectType.TRIANGLE) {
list = ToleranceTemplate.detailListOfGroup(ToleranceGroupConstants.VALUE_MUL_CYCLE_ANGLE);
} else if (projectTypeBack == ProjectType.CONNECTION) {
list = ToleranceTemplate.detailListOfGroup(ToleranceTemplate.CITY_GROUP_ID);
} else if (projectTypeBack == ProjectType.HEIGHT_TRAVERSE) {
list = ToleranceTemplate.detailListOfGroup(ToleranceGroupConstants.VALUE_HEIGHT_TRAVERSE);
}
if (list != null && !list.isEmpty()) {
return list.get(0);
}
return null;
});
} }
protected abstract void onCreateView(View view); protected abstract void onCreateView(View view);
protected void setCurrentToleranceName(View view, ToleranceDetailRecord toleranceRecord) { protected void setCurrentToleranceName(View view, IToleranceDetail toleranceRecord) {
View tv = view.findViewById(R.id.setting_index); View tv = view.findViewById(R.id.setting_index);
ThreadPoolUtil.execute(new Runnable() { ThreadPoolUtil.execute(() -> {
@Override if (toleranceRecord == null) return;
public void run() { IToleranceOperate operate = ToleranceOperateUtil.getOperate(toleranceRecord.getId());
if (toleranceRecord == null) { if (operate == null) return;
return; ToleranceGroupRecord group = operate.getGroup(toleranceRecord);
ToleranceLevelRecord level = operate.getLevel(toleranceRecord);
String name = ToleranceUtil.completedToleranceName(group, level, toleranceRecord);
runOnUI(() -> {
if (tv instanceof TextItemWithMore) {
((TextItemWithMore) tv).setDescribeText(name);
} }
ToleranceGroupRecord groupRecord = ToleranceTemplate.groupOf(toleranceRecord.groupId); });
ToleranceLevelRecord levelRecord = ToleranceTemplate.levelOf(toleranceRecord.levelId);
String name = ToleranceUtil.completedToleranceName(groupRecord, levelRecord, toleranceRecord);
runOnUI(() -> {
if (tv instanceof TextItemWithMore) {
((TextItemWithMore) tv).setDescribeText(name);
}
});
}
}); });
} }
@ -109,11 +91,10 @@ public abstract class AbstractProjectToleranceFragment extends BaseFragment {
*/ */
@WorkerThread @WorkerThread
protected void onSelectToleranceTemplateClick() { protected void onSelectToleranceTemplateClick() {
IToleranceDetailDataSource toleranceDetailDataSource = IToleranceOperate operate = ToleranceOperateUtil.getOperate(currentToleranceDetailRecordId);
SurveyorDatabaseFactory.instance.getToleranceDetailDataSource(); if (operate == null) return;
//缓存+数据库中获取 IToleranceDetail toleranceDetailRecordTj = operate.getIToleranceDetail(currentToleranceDetailRecordId);
ToleranceDetailRecord toleranceDetailRecord = toleranceDetailDataSource.getRecordSync(currentToleranceDetailRecordId); if (toleranceDetailRecordTj == null) {
if (toleranceDetailRecord == null) {
return; return;
} }
@ -122,21 +103,17 @@ public abstract class AbstractProjectToleranceFragment extends BaseFragment {
getChildFragmentManager(), getChildFragmentManager(),
getViewLifecycleOwner(), getViewLifecycleOwner(),
projectType, projectType,
toleranceDetailRecord.getGroupId(), toleranceDetailRecordTj.getGroupId(),
toleranceDetailRecord.getLevelId(), toleranceDetailRecordTj.getLevelId(),
toleranceDetailRecord.getId(), toleranceDetailRecordTj.getId(),
toleranceId -> ThreadPoolUtil.execute(() -> { toleranceId -> ThreadPoolUtil.execute(() -> {
//根据toleranceId查找缓存数据 //根据toleranceId查找缓存数据
ToleranceDetailRecord instance = IToleranceDetail instance = operate.getIToleranceDetail(toleranceId);
SurveyorDatabaseFactory.instance.getToleranceDetailDataSource().getRecordSync(toleranceId);
//更新页面数据 //更新页面数据
updateToleranceDetail(getView(), instance); updateToleranceDetail(getView(), instance);
// //新增 //新增
if (instance != null) { //这里增加存入数据库 已备杀死app后能获取到限差数据
//这里增加存入数据库 已备杀死app后能获取到限差数据 operate.saveToleranceDetail(instance);
SurveyorDatabaseFactory.instance.getToleranceDetailDataSource().record(instance);
}
}) })
)); ));
} }
@ -145,8 +122,14 @@ public abstract class AbstractProjectToleranceFragment extends BaseFragment {
currentToleranceDetailRecordId = toleranceId; currentToleranceDetailRecordId = toleranceId;
} }
protected void newToleranceDetailFragment(Bundle args, IOnSingleGetCallback<ToleranceDetailFragment> callback) {
if (callback != null) {
callback.onGet(ToleranceDetailFragment.newInstance(args, false));
}
}
@WorkerThread @WorkerThread
protected void updateToleranceDetail(View view, ToleranceDetailRecord tolerance) { protected void updateToleranceDetail(View view, IToleranceDetail tolerance) {
if (tolerance == null) { if (tolerance == null) {
return; return;
} }
@ -162,13 +145,13 @@ public abstract class AbstractProjectToleranceFragment extends BaseFragment {
if (getArguments() != null) { if (getArguments() != null) {
args.putString(BundleConstants.KEY_TOLERANCE_ID, tolerance.getId()); args.putString(BundleConstants.KEY_TOLERANCE_ID, tolerance.getId());
} }
getParentFragmentManager() newToleranceDetailFragment(args, detailFragmentInstance -> getParentFragmentManager()
.beginTransaction() .beginTransaction()
.replace(R.id.fragment_container, ToleranceDetailFragment.newInstance(args), AbstractProjectToleranceFragment.class.getName()) .replace(R.id.fragment_container, detailFragmentInstance, AbstractProjectToleranceFragment.class.getName())
.commit(); .commit());
} else { } else {
if (detailFragment instanceof ToleranceDetailFragment) { if (detailFragment instanceof ToleranceDetailFragment) {
((ToleranceDetailFragment) detailFragment).changeTolerance(tolerance.getId()); ((ToleranceDetailFragment) detailFragment).switchTolerance(tolerance.getId());
} }
} }
}); });

@ -2,6 +2,7 @@ package com.bingce.controlnetwork.fragment;
import android.content.Context; import android.content.Context;
import android.os.Bundle; import android.os.Bundle;
import android.text.TextUtils;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -27,16 +28,15 @@ import com.bingce.controlapphelper.surveyor.state.ISurveyState;
import com.bingce.controlapphelper.surveyor.surveyor.RequestSurveyorParamAuto; import com.bingce.controlapphelper.surveyor.surveyor.RequestSurveyorParamAuto;
import com.bingce.controlapphelper.util.DigitalUtil; import com.bingce.controlapphelper.util.DigitalUtil;
import com.bingce.controlapphelper.util.IUIRunner; import com.bingce.controlapphelper.util.IUIRunner;
import com.bingce.controlnetwork.adapter.SurveyorStationRecordsAdapter;
import com.bingce.controlnetwork.surveyor.state.angledistance.StateManager;
import com.bingce.totalstation.TotalStation;
import com.bingce.utils.ThreadPoolUtil;
import com.bingce.controlnetwork.R; import com.bingce.controlnetwork.R;
import com.bingce.controlnetwork.adapter.SurveyorStationRecordsAdapter; import com.bingce.controlnetwork.adapter.SurveyorStationRecordsAdapter;
import com.bingce.controlnetwork.fragment.base.BaseFragment; import com.bingce.controlnetwork.fragment.base.BaseFragment;
import com.bingce.controlnetwork.surveyor.state.IScrollDelegate; import com.bingce.controlnetwork.surveyor.state.IScrollDelegate;
import com.bingce.controlnetwork.surveyor.state.angledistance.StateManager; import com.bingce.controlnetwork.surveyor.state.angledistance.StateManager;
import com.bingce.totalstation.TotalStation;
import com.bingce.utils.ThreadPoolUtil;
import blankj.utilcode.util.ToastUtils;
/** /**
* 测站某个测期的测量数据列表 * 测站某个测期的测量数据列表
@ -305,6 +305,32 @@ public class ComponentStationSurveyorDataListFragment extends BaseFragment
stateManager.stationAdjust(StationDataAdjustDialogFragment.TYPE_ANGLE_DISTANCE); stateManager.stationAdjust(StationDataAdjustDialogFragment.TYPE_ANGLE_DISTANCE);
} }
/**
* 测站检测平差
*/
public void stationCheckAdjust() {
ThreadPoolUtil.execute(() -> {
SurveyorScheduleRecord scheduleRecord = SurveyorDatabaseFactory.instance.getScheduleDataSource()
.findScheduleSync(SurveyorScheduleConstants.getAllCycleScheduleKey(stationId(), null));
if (scheduleRecord == null || SurveyorScheduleConstants.STATUE_VALUE_NO_COMPLETED.equals(scheduleRecord.getStatue())) {
ToastUtils.showShort("请完成测站测量");
return;
}
if (SurveyorScheduleConstants.STATUE_VALUE_CHECKED.equals(scheduleRecord.getStatue())) {
//经过检测
stateManager.stationAdjustOnly(StationDataAdjustDialogFragment.TYPE_ANGLE_DISTANCE);
} else if (SurveyorScheduleConstants.STATUE_VALUE_COMPLETED.equals(scheduleRecord.getStatue())) {
//完成测量
String error = stateManager.stationCheckOnly();
if (!TextUtils.isEmpty(error)) {
TipsFragment.tipsOnly(getChildFragmentManager(), getViewLifecycleOwner(), requireContext(), error);
return;
}
stateManager.stationAdjustOnly(StationDataAdjustDialogFragment.TYPE_ANGLE_DISTANCE);
}
});
}
public void goBack() { public void goBack() {
if (stateManager == null) { if (stateManager == null) {
return; return;

@ -10,6 +10,7 @@ import androidx.annotation.Nullable;
import androidx.lifecycle.LiveData; import androidx.lifecycle.LiveData;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import com.bingce.controlapphelper.datasource.database.ProjectType;
import com.bingce.controlapphelper.datasource.database.SurveyorDatabaseFactory; import com.bingce.controlapphelper.datasource.database.SurveyorDatabaseFactory;
import com.bingce.controlapphelper.datasource.database.surveyorstation.SurveyorStationRecord; import com.bingce.controlapphelper.datasource.database.surveyorstation.SurveyorStationRecord;
import com.bingce.controlapphelper.model.BundleConstants; import com.bingce.controlapphelper.model.BundleConstants;
@ -18,6 +19,7 @@ import com.bingce.controlnetwork.R;
import com.bingce.controlnetwork.adapter.SurveyorStationListAdapter; import com.bingce.controlnetwork.adapter.SurveyorStationListAdapter;
import com.bingce.controlnetwork.fragment.base.BaseFragment; import com.bingce.controlnetwork.fragment.base.BaseFragment;
import com.bingce.controlnetwork.fragment.stationdetail.SingleStationDetailAndEditFragment; import com.bingce.controlnetwork.fragment.stationdetail.SingleStationDetailAndEditFragment;
import com.bingce.controlnetwork.fragment.stationsurvey.StationSurveyorFragment;
import com.bingce.controlnetwork.fragment.stationsurvey.angledistance.MeasureFragment; import com.bingce.controlnetwork.fragment.stationsurvey.angledistance.MeasureFragment;
import com.bingce.utils.ThreadPoolUtil; import com.bingce.utils.ThreadPoolUtil;
@ -56,7 +58,11 @@ public class ComponentSurveyorStationListFragment extends BaseFragment {
SingleStationDetailAndEditFragment.start(getContext(), stationId, stationName, item.getProjectId()); SingleStationDetailAndEditFragment.start(getContext(), stationId, stationName, item.getProjectId());
} else { } else {
//StationSurveyorFragment原始测量页 //StationSurveyorFragment原始测量页
MeasureFragment.start(getContext(), stationId, stationName); if (ProjectType.isConnection(item.projectType)) {
MeasureFragment.start(getContext(), stationId, stationName);
} else {
StationSurveyorFragment.start(getContext(), stationId, stationName);
}
} }
}); });
} }

@ -8,7 +8,9 @@ import androidx.recyclerview.widget.RecyclerView;
import com.bingce.controlapphelper.datasource.database.SurveyorDatabaseFactory; import com.bingce.controlapphelper.datasource.database.SurveyorDatabaseFactory;
import com.bingce.controlapphelper.datasource.database.project.ProjectRecord; import com.bingce.controlapphelper.datasource.database.project.ProjectRecord;
import com.bingce.controlapphelper.datasource.database.surveyorcycle.SurveyorPeriodRecord; import com.bingce.controlapphelper.datasource.database.surveyorcycle.SurveyorPeriodRecord;
import com.bingce.controlapphelper.model.IUniversalListItem;
import com.bingce.controlapphelper.util.Tools; import com.bingce.controlapphelper.util.Tools;
import com.bingce.controlnetwork.R;
import com.bingce.controlnetwork.adapter.IndexWithTextAdapter; import com.bingce.controlnetwork.adapter.IndexWithTextAdapter;
import com.bingce.controlnetwork.adapter.SelectableIndexWithTextAdapter; import com.bingce.controlnetwork.adapter.SelectableIndexWithTextAdapter;
import com.bingce.utils.ThreadPoolUtil; import com.bingce.utils.ThreadPoolUtil;
@ -20,10 +22,6 @@ import java.util.List;
import blankj.utilcode.util.ToastUtils; import blankj.utilcode.util.ToastUtils;
import com.bingce.controlnetwork.R;
import com.bingce.controlnetwork.adapter.IndexWithTextAdapter;
import com.bingce.controlnetwork.adapter.SelectableIndexWithTextAdapter;
/** /**
* 选择项目和测期的组件 * 选择项目和测期的组件
*/ */
@ -32,11 +30,11 @@ public class ComponentSwitchStationListFragment extends AbstractHierarchicalList
private static final int INDEX_CYCLE_LIST = 1; private static final int INDEX_CYCLE_LIST = 1;
private String projectId = ""; private String projectId = "";
private String projectName = ""; private String projectName = "";
private SelectableIndexWithTextAdapter<Item> projectAdapter; private SelectableIndexWithTextAdapter<IUniversalListItem<?>> projectAdapter;
private SelectableIndexWithTextAdapter<Item> periodAdapter; private SelectableIndexWithTextAdapter<IUniversalListItem<?>> periodAdapter;
@Override @Override
protected void onItemClicked(int currentListIndex, Item item) { protected void onItemClicked(int currentListIndex, IUniversalListItem<?> item) {
if (INDEX_PROJECT_LIST == currentListIndex) { if (INDEX_PROJECT_LIST == currentListIndex) {
projectId = item.getId(); projectId = item.getId();
projectName = item.getName(); projectName = item.getName();
@ -60,7 +58,7 @@ public class ComponentSwitchStationListFragment extends AbstractHierarchicalList
@Override @Override
protected void setupList(int listIndex, TextView title, RecyclerView recyclerView, protected void setupList(int listIndex, TextView title, RecyclerView recyclerView,
final IndexWithTextAdapter.IOnItemClick<Item> callback) { IndexWithTextAdapter.IOnItemClick<IUniversalListItem<?>> callback) {
if (INDEX_PROJECT_LIST == listIndex) { if (INDEX_PROJECT_LIST == listIndex) {
//加载 //加载
if (title != null) { if (title != null) {
@ -75,7 +73,7 @@ public class ComponentSwitchStationListFragment extends AbstractHierarchicalList
if (getArguments() != null) { if (getArguments() != null) {
selectedProject = getArguments().getString(KEY_PROJECT_ID); selectedProject = getArguments().getString(KEY_PROJECT_ID);
} }
List<Item> items = new ArrayList<>(); List<IUniversalListItem<?>> items = new ArrayList<>();
int targetIndex = 0; int targetIndex = 0;
for (int index = 0; index < projectRecords.size(); index++) { for (int index = 0; index < projectRecords.size(); index++) {
ProjectRecord projectRecord = projectRecords.get(index); ProjectRecord projectRecord = projectRecords.get(index);
@ -105,7 +103,7 @@ public class ComponentSwitchStationListFragment extends AbstractHierarchicalList
ThreadPoolUtil.execute(() -> { ThreadPoolUtil.execute(() -> {
List<SurveyorPeriodRecord> periodRecords = SurveyorDatabaseFactory.instance List<SurveyorPeriodRecord> periodRecords = SurveyorDatabaseFactory.instance
.getSurveyorPeriod().getDataListSyncByProjectId(projectId); .getSurveyorPeriod().getDataListSyncByProjectId(projectId);
List<Item> items = new ArrayList<>(); List<IUniversalListItem<?>> items = new ArrayList<>();
String selectedPeriodId = ""; String selectedPeriodId = "";
if (getArguments() != null) { if (getArguments() != null) {
selectedPeriodId = getArguments().getString(KEY_CYCLE_ID); selectedPeriodId = getArguments().getString(KEY_CYCLE_ID);
@ -136,9 +134,6 @@ public class ComponentSwitchStationListFragment extends AbstractHierarchicalList
} }
} }
private ComponentSwitchStationListFragment() {
}
private static final String KEY_PROJECT_ID = "___project_id"; private static final String KEY_PROJECT_ID = "___project_id";
private static final String KEY_CYCLE_ID = "__cycle_id"; private static final String KEY_CYCLE_ID = "__cycle_id";

@ -8,12 +8,14 @@ import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import com.bingce.controlapphelper.datasource.database.SurveyorDatabaseFactory; import com.bingce.controlapphelper.datasource.database.SurveyorDatabaseFactory;
import com.bingce.controlapphelper.datasource.database.ToleranceTemplate; import com.bingce.controlapphelper.datasource.database.tolerance.detail.IToleranceDetail;
import com.bingce.controlapphelper.datasource.database.tolerance.detail.IToleranceDetailDataSource; import com.bingce.controlapphelper.datasource.database.tolerance.detail.IToleranceDetailDataSource;
import com.bingce.controlapphelper.datasource.database.tolerance.detail.ToleranceDetailRecord;
import com.bingce.controlapphelper.datasource.database.tolerance.group.ToleranceGroupConstants; import com.bingce.controlapphelper.datasource.database.tolerance.group.ToleranceGroupConstants;
import com.bingce.controlapphelper.datasource.database.tolerance.group.ToleranceGroupRecord; import com.bingce.controlapphelper.datasource.database.tolerance.group.ToleranceGroupRecord;
import com.bingce.controlapphelper.datasource.database.tolerance.level.ToleranceLevelRecord; import com.bingce.controlapphelper.datasource.database.tolerance.level.ToleranceLevelRecord;
import com.bingce.controlapphelper.datasource.database.tolerance.load.ToleranceLoadUtil;
import com.bingce.controlapphelper.model.IUniversalListItem;
import com.bingce.controlnetwork.R;
import com.bingce.controlnetwork.adapter.IndexWithTextAdapter; import com.bingce.controlnetwork.adapter.IndexWithTextAdapter;
import com.bingce.controlnetwork.adapter.SelectableIndexWithTextAdapter; import com.bingce.controlnetwork.adapter.SelectableIndexWithTextAdapter;
import com.bingce.utils.ThreadPoolUtil; import com.bingce.utils.ThreadPoolUtil;
@ -25,10 +27,6 @@ import java.util.List;
import blankj.utilcode.util.ToastUtils; import blankj.utilcode.util.ToastUtils;
import com.bingce.controlnetwork.R;
import com.bingce.controlnetwork.adapter.IndexWithTextAdapter;
import com.bingce.controlnetwork.adapter.SelectableIndexWithTextAdapter;
/** /**
* 选择限差模板的内容 * 选择限差模板的内容
@ -41,16 +39,16 @@ public class ComponentSwitchToleranceFragment extends AbstractHierarchicalListFr
private String groupId = ""; private String groupId = "";
private String levelId = ""; private String levelId = "";
private String toleranceId = ""; private String toleranceId = "";
private SelectableIndexWithTextAdapter<Item> adapterGroup = null; private SelectableIndexWithTextAdapter<IUniversalListItem<?>> adapterGroup = null;
private SelectableIndexWithTextAdapter<Item> adapterLevel = null; private SelectableIndexWithTextAdapter<IUniversalListItem<?>> adapterLevel = null;
private SelectableIndexWithTextAdapter<Item> adapterDetail = null; private SelectableIndexWithTextAdapter<IUniversalListItem<?>> adapterDetail = null;
@Override @Override
protected void onItemClicked(int currentListIndex, Item item) { protected void onItemClicked(int currentListIndex, IUniversalListItem<?> item) {
if (INDEX_GROUP == currentListIndex) { if (INDEX_GROUP == currentListIndex) {
groupId = item.getId(); groupId = item.getId();
//检测目标group是否有level,如果没有直接进入detail //检测目标group是否有level,如果没有直接进入detail
List<ToleranceLevelRecord> levelRecordList = ToleranceTemplate.levelListOf(projectType, groupId); List<ToleranceLevelRecord> levelRecordList = ToleranceLoadUtil.getToleranceLoad(projectType).levelListOf(projectType, groupId);
if (levelRecordList.isEmpty()) { if (levelRecordList.isEmpty()) {
levelId = ""; levelId = "";
forward2(INDEX_TOLERANCE); forward2(INDEX_TOLERANCE);
@ -61,11 +59,15 @@ public class ComponentSwitchToleranceFragment extends AbstractHierarchicalListFr
levelId = item.getId(); levelId = item.getId();
forward2(INDEX_TOLERANCE); forward2(INDEX_TOLERANCE);
} else { } else {
SelectedToleranceEvent result = new SelectedToleranceEvent(item.getId()); callBackData(item.getId());
EventBus.getDefault().post(result);
} }
} }
private void callBackData(String id) {
SelectedToleranceEvent result = new SelectedToleranceEvent(id);
EventBus.getDefault().post(result);
}
@Override @Override
protected int preIndexOf(int index) { protected int preIndexOf(int index) {
if (INDEX_TOLERANCE == index) { if (INDEX_TOLERANCE == index) {
@ -95,29 +97,27 @@ public class ComponentSwitchToleranceFragment extends AbstractHierarchicalListFr
@Override @Override
protected void setupList(int listIndex, TextView title, RecyclerView recyclerView, protected void setupList(int listIndex, TextView title, RecyclerView recyclerView,
final IndexWithTextAdapter.IOnItemClick<Item> callback) { final IndexWithTextAdapter.IOnItemClick<IUniversalListItem<?>> callback) {
if (INDEX_GROUP == listIndex) { if (INDEX_GROUP == listIndex) {
if (title != null) { if (title != null) {
title.setText(R.string.tips_please_select_tolerance_group); title.setText(R.string.tips_please_select_tolerance_group);
} }
// List<ToleranceGroupRecord> toleranceGroupRecords = ToleranceTemplate.allGroups(); List<ToleranceGroupRecord> toleranceGroupRecords = ToleranceLoadUtil.getToleranceLoad(projectType).getGroupFromType(projectType);
List<ToleranceGroupRecord> toleranceGroupRecords = ToleranceTemplate.getGroupFromType(projectType); List<IUniversalListItem<?>> items = new ArrayList<>();
List<Item> items = new ArrayList<>();
int targetIndex = 0; int targetIndex = 0;
Item customGroup = null; IUniversalListItem<?> customGroup = null;
int index = -1; int index = -1;
for (ToleranceGroupRecord toleranceGroupRecord : toleranceGroupRecords) { for (ToleranceGroupRecord toleranceGroupRecord : toleranceGroupRecords) {
Item item = new Item(toleranceGroupRecord.getName(), toleranceGroupRecord.getId());
if (toleranceGroupRecord.isDeleted()) { if (toleranceGroupRecord.isDeleted()) {
continue; continue;
} }
if (ToleranceGroupConstants.VALUE_CUSTOM_GROUP.equals(toleranceGroupRecord.getId())) { if (ToleranceGroupConstants.VALUE_CUSTOM_GROUP.equals(toleranceGroupRecord.getId())) {
customGroup = item; customGroup = toleranceGroupRecord;
continue; continue;
} }
index++; index++;
items.add(item); items.add(toleranceGroupRecord);
if (groupId.equals(item.getId())) { if (groupId.equals(toleranceGroupRecord.getId())) {
targetIndex = index; targetIndex = index;
} }
} }
@ -139,14 +139,13 @@ public class ComponentSwitchToleranceFragment extends AbstractHierarchicalListFr
if (title != null) { if (title != null) {
title.setText(R.string.tips_please_select_tolerance_level); title.setText(R.string.tips_please_select_tolerance_level);
} }
List<ToleranceLevelRecord> toleranceLevelRecords = ToleranceTemplate.levelListOf(projectType, groupId); List<ToleranceLevelRecord> toleranceLevelRecords = ToleranceLoadUtil.getToleranceLoad(projectType).levelListOf(projectType, groupId);
List<Item> items = new ArrayList<>(); List<IUniversalListItem<?>> items = new ArrayList<>();
int targetIndex = 0; int targetIndex = 0;
for (int index = 0; index < toleranceLevelRecords.size(); index++) { for (int index = 0; index < toleranceLevelRecords.size(); index++) {
ToleranceLevelRecord toleranceLevelRecord = toleranceLevelRecords.get(index); ToleranceLevelRecord toleranceLevelRecord = toleranceLevelRecords.get(index);
Item item = new Item(toleranceLevelRecord.getName(), toleranceLevelRecord.getId()); items.add(toleranceLevelRecord);
items.add(item); if (levelId != null && levelId.equals(toleranceLevelRecord.getId())) {
if (levelId != null && levelId.equals(item.getId())) {
targetIndex = index; targetIndex = index;
} }
} }
@ -161,28 +160,35 @@ public class ComponentSwitchToleranceFragment extends AbstractHierarchicalListFr
ThreadPoolUtil.execute(() -> { ThreadPoolUtil.execute(() -> {
IToleranceDetailDataSource toleranceDetailDataSource = IToleranceDetailDataSource toleranceDetailDataSource =
SurveyorDatabaseFactory.instance.getToleranceDetailDataSource(); SurveyorDatabaseFactory.instance.getToleranceDetailDataSource();
List<ToleranceDetailRecord> toleranceDetailRecords; List<IToleranceDetail> toleranceDetailList;
int titleRes = R.string.tips_please_select_instrument_precision; int titleRes = R.string.tips_please_select_instrument_precision;
if (levelId == null || levelId.isEmpty()) {//自定义模板 if (levelId == null || levelId.isEmpty()) {//自定义模板
toleranceDetailRecords = toleranceDetailDataSource.getDataListByGroup(groupId); toleranceDetailList = ToleranceLoadUtil.getToleranceLoad(projectType).getDetailListByGroup(groupId);
//选择模板 //选择模板
titleRes = R.string.tips_please_select_custom_tolerance; titleRes = R.string.tips_please_select_custom_tolerance;
} else { } else {
toleranceDetailRecords = ToleranceTemplate.detailListOfLevel(projectType, levelId); toleranceDetailList = ToleranceLoadUtil.getToleranceLoad(projectType).detailListOfLevel(projectType, levelId);
} }
if (!ToleranceGroupConstants.VALUE_CUSTOM_GROUP.equals(groupId) &&
toleranceDetailList != null && toleranceDetailList.size() == 1) {
callBackData(toleranceDetailList.get(0).getId());
return;
}
int finalTitleRes = titleRes; int finalTitleRes = titleRes;
runOnUI(() -> { runOnUI(() -> {
if (title != null) { if (title != null) {
title.setText(finalTitleRes); title.setText(finalTitleRes);
} }
}); });
List<Item> items = new ArrayList<>(); List<IUniversalListItem<?>> items = new ArrayList<>();
int targetIndex = 0; int targetIndex = 0;
for (int index = 0; index < toleranceDetailRecords.size(); index++) { for (int index = 0; index < toleranceDetailList.size(); index++) {
ToleranceDetailRecord toleranceDetailRecord = toleranceDetailRecords.get(index); IToleranceDetail toleranceDetailRecordTj = toleranceDetailList.get(index);
Item item = new Item(toleranceDetailRecord.getName(), toleranceDetailRecord.getId()); items.add((IUniversalListItem<?>) toleranceDetailRecordTj);
items.add(item); if (toleranceId.equals(toleranceDetailRecordTj.getId())) {
if (toleranceId.equals(item.getId())) {
targetIndex = index; targetIndex = index;
} }
} }
@ -218,9 +224,6 @@ public class ComponentSwitchToleranceFragment extends AbstractHierarchicalListFr
} }
} }
private ComponentSwitchToleranceFragment() {
}
private static final String KEY_PROJECT_TYPE = "___PROJECT_TYPE___"; private static final String KEY_PROJECT_TYPE = "___PROJECT_TYPE___";
private static final String KEY_GROUP = "___GROUP___"; private static final String KEY_GROUP = "___GROUP___";
private static final String KEY_LEVEL = "___LEVEL___"; private static final String KEY_LEVEL = "___LEVEL___";

@ -9,6 +9,8 @@ import androidx.fragment.app.Fragment
import com.bingce.controlapphelper.datasource.database.ProjectType import com.bingce.controlapphelper.datasource.database.ProjectType
import com.bingce.controlapphelper.datasource.database.SurveyorDatabaseFactory import com.bingce.controlapphelper.datasource.database.SurveyorDatabaseFactory
import com.bingce.controlapphelper.datasource.database.config.ConfigConstants import com.bingce.controlapphelper.datasource.database.config.ConfigConstants
import com.bingce.controlapphelper.datasource.database.leveling.LevelingDbFactory
import com.bingce.controlapphelper.datasource.database.leveling.route.LevelRouteRecord
import com.bingce.controlapphelper.datasource.database.project.ProjectRecord import com.bingce.controlapphelper.datasource.database.project.ProjectRecord
import com.bingce.controlapphelper.datasource.database.route.RouteRecord import com.bingce.controlapphelper.datasource.database.route.RouteRecord
import com.bingce.controlapphelper.datasource.database.surveyorcycle.SurveyorPeriodRecord import com.bingce.controlapphelper.datasource.database.surveyorcycle.SurveyorPeriodRecord
@ -19,6 +21,7 @@ import com.bingce.controlnetwork.fragment.base.BaseFragment
import com.bingce.controlnetwork.fragment.bottompage.BottomBean import com.bingce.controlnetwork.fragment.bottompage.BottomBean
import com.bingce.controlnetwork.fragment.bottompage.BottomPageFragment import com.bingce.controlnetwork.fragment.bottompage.BottomPageFragment
import com.bingce.controlnetwork.fragment.bottompage.IData import com.bingce.controlnetwork.fragment.bottompage.IData
import com.bingce.controlnetwork.func.level.fragment.LevelSurveyorHomeFragment
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.MainScope import kotlinx.coroutines.MainScope
import kotlinx.coroutines.cancel import kotlinx.coroutines.cancel
@ -37,7 +40,7 @@ class MainSurveyFragment : BaseFragment() {
private val scope = MainScope() private val scope = MainScope()
//筛选项目的项目类型 //筛选项目的项目类型
private var selectProjectTypeTag: String? = null private var selectProjectType: String? = null
override fun onCreateView( override fun onCreateView(
inflater: LayoutInflater, inflater: LayoutInflater,
@ -80,7 +83,7 @@ class MainSurveyFragment : BaseFragment() {
selectData[0].name, selectData[0].name,
selectData[1].name selectData[1].name
) )
if (isHeightTraverse()) { if (ProjectType.isHeightTraverse(selectProjectType)) {
switchContent( switchContent(
title, title,
SurveyorRouteStationFragment.newInstance( SurveyorRouteStationFragment.newInstance(
@ -88,6 +91,15 @@ class MainSurveyFragment : BaseFragment() {
selectData[1].id selectData[1].id
) )
) )
} else if (ProjectType.isLevel(selectProjectType)) {
switchContent(
title,
LevelSurveyorHomeFragment.newInstance(
selectData[0].id,
selectData[1].id,
false
)
)
} else { } else {
switchContent( switchContent(
title, title,
@ -126,15 +138,26 @@ class MainSurveyFragment : BaseFragment() {
//二级数据 //二级数据
val projectRecord = val projectRecord =
SurveyorDatabaseFactory.instance.projectDataSource.getRecord(bottomBean.id) SurveyorDatabaseFactory.instance.projectDataSource.getRecord(bottomBean.id)
selectProjectTypeTag = projectRecord.getProjectType() selectProjectType = projectRecord.getProjectType()
if (isHeightTraverse()) { if (ProjectType.isHeightTraverse(selectProjectType)) {
val routeList = SurveyorDatabaseFactory.instance.getRouteDataSource() val routeList = SurveyorDatabaseFactory.instance.getRouteDataSource()
.getByProjectId(bottomBean.id) .getByProjectId(bottomBean.id)
for (routeRecord in routeList) { for (routeRecord in routeList) {
dataList.add( dataList.add(
BottomBean( BottomBean(
routeRecord.getId(), routeRecord.name, routeRecord.getId(), routeRecord.name,
1, tag = selectProjectTypeTag 1, tag = selectProjectType
)
)
}
} else if (ProjectType.isLevel(selectProjectType)) {
val routeList = LevelingDbFactory.instance.levelDataSource
.getByProjectId(bottomBean.id)
for (routeRecord in routeList) {
dataList.add(
BottomBean(
routeRecord.getId(), routeRecord.name,
1, tag = selectProjectType
) )
) )
} }
@ -145,7 +168,7 @@ class MainSurveyFragment : BaseFragment() {
dataList.add( dataList.add(
BottomBean( BottomBean(
periodItem.getId(), periodItem.getName(), periodItem.getId(), periodItem.getName(),
1, tag = selectProjectTypeTag 1, tag = selectProjectType
) )
) )
} }
@ -159,8 +182,10 @@ class MainSurveyFragment : BaseFragment() {
override fun getTitle(pageIndex: Int): String { override fun getTitle(pageIndex: Int): String {
return if (pageIndex == 0) { return if (pageIndex == 0) {
Tools.getString(R.string.please_select_an_project) Tools.getString(R.string.please_select_an_project)
} else if (selectProjectTypeTag != null && pageIndex == 1) { } else if (selectProjectType != null && pageIndex == 1) {
if (isHeightTraverse()) { if (ProjectType.isHeightTraverse(selectProjectType)
|| ProjectType.isLevel(selectProjectType)
) {
Tools.getString(R.string.please_select_an_route) Tools.getString(R.string.please_select_an_route)
} else { } else {
Tools.getString(R.string.please_select_an_period) Tools.getString(R.string.please_select_an_period)
@ -181,9 +206,11 @@ class MainSurveyFragment : BaseFragment() {
switchContent(null, null) switchContent(null, null)
return@launch return@launch
} }
val projectType = projectRecord.getProjectType()
if (projectRecord.getProjectType() == ProjectType.HEIGHT_TRAVERSE.flag) { if (ProjectType.isHeightTraverse(projectType)) {
loadHeightTraverseData(projectRecord) loadHeightTraverseData(projectRecord)
} else if (ProjectType.isLevel(projectType)) {
loadLevelData(projectRecord)
} else { } else {
loadNotHeightTraverseData(projectRecord) loadNotHeightTraverseData(projectRecord)
} }
@ -231,6 +258,23 @@ class MainSurveyFragment : BaseFragment() {
) )
} }
private suspend fun loadLevelData(projectRecord: ProjectRecord) {
val routeRecord = getLevelRouteRecord(projectRecord.getId())
val fragment =
if (routeRecord == null)
EmptyFragment()
else LevelSurveyorHomeFragment.newInstance(
projectRecord.getId(),
routeRecord.getId(),
false
)
switchContent(
getFilterTitle(projectRecord.getProjectName(), routeRecord?.routeName),
fragment
)
}
private fun getFilterTitle(projectName: String, secondName: String?): String { private fun getFilterTitle(projectName: String, secondName: String?): String {
val suffix = if (secondName == null) "" else " > $secondName" val suffix = if (secondName == null) "" else " > $secondName"
return projectName + suffix return projectName + suffix
@ -302,9 +346,21 @@ class MainSurveyFragment : BaseFragment() {
} }
} }
private fun isHeightTraverse(): Boolean { private suspend fun getLevelRouteRecord(
return selectProjectTypeTag == ProjectType.HEIGHT_TRAVERSE.flag projectId: String,
): LevelRouteRecord? {
return withContext(Dispatchers.IO) {
val defaultRouteId = SurveyorDatabaseFactory.instance
.configDataSource.getByKeySync(ConfigConstants.KEY_DEFAULT_ROUTE_ID)?.configValue
val routeRecord =
LevelingDbFactory.instance.levelDataSource
.getByIdSync(defaultRouteId)
if (routeRecord != null) {
return@withContext routeRecord
}
LevelingDbFactory.instance.levelDataSource
.getDefault(projectId)
}
} }
} }

@ -17,6 +17,8 @@ import androidx.activity.result.contract.ActivityResultContracts;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.lifecycle.LifecycleOwner;
import com.bingce.controlapphelper.datasource.database.SurveyorDatabaseFactory; import com.bingce.controlapphelper.datasource.database.SurveyorDatabaseFactory;
import com.bingce.controlapphelper.datasource.database.point.IPointDataSource; import com.bingce.controlapphelper.datasource.database.point.IPointDataSource;
@ -36,6 +38,7 @@ import org.jetbrains.annotations.NotNull;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public class PickPointFragment extends BaseFragment { public class PickPointFragment extends BaseFragment {
public static final String TAG = PickPointFragment.class.getName(); public static final String TAG = PickPointFragment.class.getName();
AbstractPointSelectAdapter adapter; AbstractPointSelectAdapter adapter;
@ -59,8 +62,9 @@ public class PickPointFragment extends BaseFragment {
ThreadPoolUtil.execute(() -> { ThreadPoolUtil.execute(() -> {
IPointDataSource pointDataSource = IPointDataSource pointDataSource =
SurveyorDatabaseFactory.instance.getPointDataSource(); SurveyorDatabaseFactory.instance.getPointDataSource();
List<PointRecord> globalControlPoints = pointDataSource //去掉全局控制点
.getListByProjectId(PointRecord.GLOBAL_CONTROL_POINT_PROJECT_ID, PointRecord.TYPE_GLOBAL_POINT); // List<PointRecordTj> globalControlPoints = pointDataSource
// .getListByProjectId(PointRecordTj.GLOBAL_CONTROL_POINT_PROJECT_ID, PointRecordTj.TYPE_GLOBAL_POINT);
KnownAndUnknownPoints knownAndUnknownPoints = KnownAndUnknownPoints knownAndUnknownPoints =
KnownAndUnknownPoints.loadData(false, filterId, projectId); KnownAndUnknownPoints.loadData(false, filterId, projectId);
@ -78,14 +82,15 @@ public class PickPointFragment extends BaseFragment {
//过滤全局控制点 //过滤全局控制点
List<PointRecord> others = new ArrayList<>(); List<PointRecord> others = new ArrayList<>();
for (PointRecord pointRecord : globalControlPoints) { //去掉全局控制点
if ((filterId != null && filterId.contains(pointRecord.getId())) || // for (PointRecordTj pointRecord : globalControlPoints) {
filterName.contains(pointRecord.getName()) || // if ((filterId != null && filterId.contains(pointRecord.getId())) ||
knownAndUnknownPoints.containsKnownPoint(pointRecord)) { // filterName.contains(pointRecord.getName()) ||
continue; // knownAndUnknownPoints.containsKnownPoint(pointRecord)) {
} // continue;
others.add(pointRecord); // }
} // others.add(pointRecord);
// }
adapter = new PointSelectAdapter(knownAndUnknownPoints, others, adapter = new PointSelectAdapter(knownAndUnknownPoints, others,
pickPointResult, pickPointResult,
finalMaxCount1, getContext()); finalMaxCount1, getContext());
@ -97,6 +102,28 @@ public class PickPointFragment extends BaseFragment {
} }
}); });
}); });
// String pointType = getArguments().getString(KEY_POINT_TYPE);
// if (PointRecord.TYPE_KNOWN_POINT.equals(pointType)) {
// KnownAndUnknownPoints.loadKnownData(filterId, projectId, instance -> runOnUI(() -> {
// adapter = new KnownAndUnknownPointSelectAdapter(instance, pickPointResult,
// finalMaxCount1, getContext());
// expandableListView.setAdapter(adapter);
// int groupCount = adapter.getGroupCount();
// for (int index = 0; index < groupCount; index++) {
// expandableListView.expandGroup(index);
// }
// }));
// } else {
// KnownAndUnknownPoints.loadKnownAndUnknownData(filterId, projectId, instance -> runOnUI(() -> {
// adapter = new KnownAndUnknownPointSelectAdapter(instance, pickPointResult,
// finalMaxCount1, getContext());
// expandableListView.setAdapter(adapter);
// int groupCount = adapter.getGroupCount();
// for (int index = 0; index < groupCount; index++) {
// expandableListView.expandGroup(index);
// }
// }));
// }
} }
setHasOptionsMenu(true); setHasOptionsMenu(true);
return view; return view;
@ -152,23 +179,58 @@ public class PickPointFragment extends BaseFragment {
}); });
} }
public static void pickKnownPoint( Context context,
String type,
int maxCount,
String title,
ArrayList<String> filterPointId, String projectId,
PickPointResult result, ActivityResultLauncher<Intent> launcher) {
pickPoint( context,
type, maxCount, title, filterPointId, projectId, result, launcher);
}
public static void pickKnownAndUnknownPoint(Context context,
String type,
int maxCount,
String title,
List<String> filterPointId, String projectId,
PickPointResult result, ActivityResultLauncher<Intent> launcher) {
pickPoint(context,
type, maxCount, title, filterPointId, projectId, result, launcher);
}
public static void pickPoint(Context context, public static void pickPoint(Context context,
String type, String type,
int maxCount, int maxCount,
String title, String title,
List<String> filterPointId, String projectId, List<String> filterPointId, String projectId,
PickPointResult result, ActivityResultLauncher<Intent> launcher) { PickPointResult result, ActivityResultLauncher<Intent> launcher) {
// ArrayList<String> list = new ArrayList<>();
// list.add(context.getString(R.string.global_control_point));
// if (knownOnly) {
// list.add(context.getString(R.string.project_known_point));
// } else {
// list.add(context.getString(R.string.project_known_unknown_point));
// }
// ListDialogFragment.showList(fragmentManager, list, lifecycleOwner, (index, value) -> {
if (launcher == null) { if (launcher == null) {
return; return;
} }
Bundle args = new Bundle(); Bundle args = new Bundle();
// if (index == 0) {
// args.putString(BundleConstants.KEY_PROJECT_ID, PointRecord.GLOBAL_CONTROL_POINT_PROJECT_ID);
// } else {
args.putString(BundleConstants.KEY_PROJECT_ID, projectId); args.putString(BundleConstants.KEY_PROJECT_ID, projectId);
// }
// if (knownOnly) {
// args.putString(KEY_POINT_TYPE, PointRecord.TYPE_KNOWN_POINT);
// }
args.putString(KEY_TYPE, type); args.putString(KEY_TYPE, type);
args.putInt(KEY_MAX_COUNT, maxCount); args.putInt(KEY_MAX_COUNT, maxCount);
args.putStringArrayList(KEY_FILTER, (ArrayList<String>) filterPointId); args.putStringArrayList(KEY_FILTER, (ArrayList<String>) filterPointId);
args.putParcelable(BundleConstants.KEY_RESULT, result); args.putParcelable(BundleConstants.KEY_RESULT, result);
launcher.launch(FragmentContainerActivity.startIntent(context, TAG, title, args)); launcher.launch(FragmentContainerActivity.startIntent(context, TAG, title, args));
// });
} }
public interface IOnSelectCallback { public interface IOnSelectCallback {

@ -10,205 +10,174 @@ import android.view.ViewGroup;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment; import androidx.annotation.WorkerThread;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import com.bingce.controlapphelper.datasource.database.ProjectType;
import com.bingce.controlapphelper.datasource.database.SurveyorDatabaseFactory; import com.bingce.controlapphelper.datasource.database.SurveyorDatabaseFactory;
import com.bingce.controlapphelper.datasource.database.config.ConfigConstants; import com.bingce.controlapphelper.datasource.database.config.ConfigConstants;
import com.bingce.controlapphelper.datasource.database.config.ConfigRecord;
import com.bingce.controlapphelper.datasource.database.config.IConfigDataSource; import com.bingce.controlapphelper.datasource.database.config.IConfigDataSource;
import com.bingce.controlapphelper.datasource.database.project.IProjectDataSource;
import com.bingce.controlapphelper.datasource.database.project.ProjectRecord; import com.bingce.controlapphelper.datasource.database.project.ProjectRecord;
import com.bingce.controlapphelper.event.DatabaseReadyEvent; import com.bingce.controlapphelper.datasource.database.surveyorcycle.ISurveyorPeriodDataSource;
import com.bingce.controlnetwork.adapter.ProjectListAdapter; import com.bingce.controlapphelper.datasource.database.surveyorcycle.SurveyorPeriodRecord;
import com.bingce.controlnetwork.guide.GuideSequence; import com.bingce.controlapphelper.datasource.database.tolerance.detail.IToleranceDetail;
import com.bingce.controlnetwork.guide.ITapTargetProvider; import com.bingce.controlapphelper.datasource.database.tolerance.group.ToleranceGroupRecord;
import com.bingce.controlapphelper.datasource.database.tolerance.level.ToleranceLevelRecord;
import com.bingce.controlapphelper.datasource.database.tolerance.load.IToleranceOperate;
import com.bingce.controlapphelper.util.SurveyorRecordUtil;
import com.bingce.controlapphelper.util.ToleranceUtil;
import com.bingce.controlapphelper.util.Tools;
import com.bingce.controlnetwork.R;
import com.bingce.controlnetwork.adapter.contextmenu.ContextMenuDeleteEdit;
import com.bingce.controlnetwork.fragment.base.BaseFragment;
import com.bingce.controlnetwork.fragment.projectdetail.ProjectDetailFragment;
import com.bingce.controlnetwork.fragment.projectedit.AbstractProjectEditFragment;
import com.bingce.controlnetwork.func.level.fragment.ProjectDetailLevelFragment;
import com.bingce.controlnetwork.newui.adapter.ProjectListAdapter;
import com.bingce.controlnetwork.newui.projectedit.ProjectCreateEditActivity;
import com.bingce.controlnetwork.newui.widget.selectitem.BaseSelectItemFragment;
import com.bingce.controlnetwork.newui.widget.selectitem.SelectProjectTypeFragment;
import com.bingce.controlnetwork.util.DialogUtil;
import com.bingce.controlnetwork.util.tolerance.ToleranceOperateUtil;
import com.bingce.surveyor.agentweb.AgentWebActivity; import com.bingce.surveyor.agentweb.AgentWebActivity;
import com.bingce.utils.ThreadPoolUtil; import com.bingce.utils.ThreadPoolUtil;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import com.bingce.controlnetwork.R; import java.util.List;
import com.bingce.controlnetwork.adapter.ProjectListAdapter;
import com.bingce.controlnetwork.fragment.projectdetail.ProjectDetailFragment;
import com.bingce.controlnetwork.fragment.projectedit.AbstractProjectEditFragment;
import com.bingce.controlnetwork.guide.GuideSequence;
import com.bingce.controlnetwork.guide.ITapTargetProvider;
import jp.wasabeef.recyclerview.animators.FadeInLeftAnimator; import jp.wasabeef.recyclerview.animators.FadeInLeftAnimator;
/** /**
* 主页面-项目 * 主页面-项目
*/ */
public class ProjectListFragment extends Fragment { public class ProjectListFragment extends BaseFragment {
private ProjectListAdapter projectListAdapter; private ProjectListAdapter projectListAdapter;
private final GuideSequence createProjectGuide; private RecyclerView recyclerView;
private final GuideSequence modifyProjectGuide; private View createNewProject;
private final IConfigDataSource configDataSource =
SurveyorDatabaseFactory.instance.getConfigDataSource();
private static final int GUIDE_INDEX_PROJECT_NEW = 0; @Nullable
private static final int GUIDE_INDEX_PROJECT_MODIFY = 0; @Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_project_list, container, false);
recyclerView = view.findViewById(R.id.recycler_view_project_list);
createNewProject = view.findViewById(R.id.create_new);
return view;
}
public ProjectListFragment() { @Override
createProjectGuide = new GuideSequence(GUIDE_INDEX_PROJECT_NEW + 1, new GuideSequence.IDelegate() { public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
@Override super.onViewCreated(view, savedInstanceState);
public void show(int index, ITapTargetProvider provider) { initView();
if (index == GUIDE_INDEX_PROJECT_NEW) { initListener();
if (getView() != null && getActivity() != null) { initObserver();
provider.show4View( }
getActivity(),
getView().findViewById(R.id.create_new),
getString(R.string.guide_create_new_project), null);
}
}
}
private void initAdapter() {
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
recyclerView.setItemAnimator(new FadeInLeftAnimator());
projectListAdapter = new ProjectListAdapter(requireContext());
projectListAdapter.setAdapterContextMenu(new ContextMenuDeleteEdit<ProjectRecord>() {
@Override @Override
public void dismiss(int index) { protected void delete(ProjectRecord item) {
ConfigConstants.markGuideCompleted(ConfigConstants.KEY_GUIDE_NEW_PROJECT, configDataSource); startDeleteProject(item);
}
});
modifyProjectGuide = new GuideSequence(GUIDE_INDEX_PROJECT_MODIFY + 1, new GuideSequence.IDelegate() {
@Override
public void show(int index, ITapTargetProvider provider) {
if (index == GUIDE_INDEX_PROJECT_MODIFY) {
if (getView() != null && getActivity() != null) {
provider.show4View(
getActivity(),
getView().findViewById(R.id.tap_placeholder),
getString(R.string.guide_edit_project),
getString(R.string.tips_project_list_edit_describe));
}
}
} }
@Override @Override
public void dismiss(int index) { protected void edit(ProjectRecord item) {
ConfigConstants.markGuideCompleted(ConfigConstants.KEY_GUIDE_MODIFY_PROJECT, configDataSource); startEditProject(item);
} }
}); });
projectListAdapter.setOnItemClickListener(this::goProjectDetail);
recyclerView.setAdapter(projectListAdapter);
} }
@Nullable private void initListener() {
@Override //新建项目
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { createNewProject.setOnClickListener(v -> {
View view = inflater.inflate(R.layout.fragment_project_list, container, false); //选择项目类型
initCreateNewProject(view); BaseSelectItemFragment.select(new SelectProjectTypeFragment(),
return view; getChildFragmentManager(),
getViewLifecycleOwner(),
value -> goCreateOrEditProject(value, null));
});
} }
/** /**
* 新建项目 * 去新建项目或编辑项目
*
* @param view onCreateView的view
*/ */
private void initCreateNewProject(View view) { private void goCreateOrEditProject(String projctType, ProjectRecord projectRecord) {
View createNew = view.findViewById(R.id.create_new); if (ProjectType.isLevel(projctType)) {
if (createNew != null) { String projectId = null;
createNew.setOnClickListener(v -> { if (projectRecord != null) {
//选择项目类型 projectId = projectRecord.getId();
SelectProjectTypeFragment }
.start( ProjectCreateEditActivity.launch(requireContext(), projctType, projectId);
getChildFragmentManager(), } else {
getViewLifecycleOwner(), if (projectRecord == null) {
projectType -> { AbstractProjectEditFragment.createProject(getChildFragmentManager(), requireContext(), projctType);
//新建项目的弹框 } else {
AbstractProjectEditFragment.createProject(getChildFragmentManager(), requireContext(), projectType); AbstractProjectEditFragment.editProject(getChildFragmentManager(), requireContext(),
}); projectRecord.getId(), projctType, projectRecord.getToleranceId(), projectRecord.getProjectName());
}); }
} }
} }
@Override private void initObserver() {
public void onStart() { SurveyorDatabaseFactory
super.onStart(); .instance
refreshData(); .getProjectDataSource()
} .getLiveDataList()
.observe(getViewLifecycleOwner(), this::addToleranceNameToProject);
@Override
public void onStop() {
super.onStop();
if (EventBus.getDefault().isRegistered(this)) {
EventBus.getDefault().unregister(this);
}
} }
@Subscribe(threadMode = ThreadMode.MAIN)
public void onMessageEvent(DatabaseReadyEvent event) {
refreshData();
}
private void refreshData() { private void addToleranceNameToProject(List<ProjectRecord> projectRecords) {
View view = getView();
if (view == null) {
return;
}
//显示引导
ThreadPoolUtil.execute(() -> { ThreadPoolUtil.execute(() -> {
int index = -1; for (ProjectRecord record : projectRecords) {
if (!ConfigConstants.isGuideCompleted(ConfigConstants.KEY_GUIDE_NEW_PROJECT, configDataSource)) { String toleName = null;
index = 0; IToleranceOperate operate = ToleranceOperateUtil.getOperate(record.getToleranceId());
if (operate != null) {
IToleranceDetail iToleranceDetail = operate.getIToleranceDetail(record.getToleranceId());
if (iToleranceDetail != null) {
ToleranceGroupRecord group = operate.getGroup(iToleranceDetail);
ToleranceLevelRecord level1 = operate.getLevel(iToleranceDetail);
toleName = ToleranceUtil.completedToleranceName(group, level1, iToleranceDetail);
}
}
record.toleranceName = toleName;
} }
int finalIndex = index; refreshAdapter(projectRecords);
ThreadPoolUtil.executeInMain(() -> createProjectGuide.start(finalIndex));
}); });
}
RecyclerView recyclerView = view.findViewById(R.id.recycler_view_project_list); private void refreshAdapter(List<ProjectRecord> projectRecords) {
if (recyclerView.getAdapter() != null) { ThreadPoolUtil.executeInMain(() -> {
return; if (projectListAdapter != null) {
} projectListAdapter.refreshData(projectRecords);
if (projectListAdapter == null) {
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
recyclerView.setItemAnimator(new FadeInLeftAnimator());
if (getContext() != null) {
projectListAdapter = new ProjectListAdapter(
this::goProjectDetail,
getContext(),
runnable -> {
if (getActivity() != null) {
getActivity().runOnUiThread(runnable);
}
},
getViewLifecycleOwner(),
getChildFragmentManager());
recyclerView.setAdapter(projectListAdapter);
} }
} });
SurveyorDatabaseFactory
.instance
.getProjectDataSource()
.getLiveDataList()
.observe(getViewLifecycleOwner(), projectRecords -> {
projectListAdapter.updateData(projectRecords);
//显示引导
if (projectRecords == null || projectRecords.isEmpty()) {
return;
}
ThreadPoolUtil.execute(() -> {
int index = -1;
if (!ConfigConstants.isGuideCompleted(ConfigConstants.KEY_GUIDE_MODIFY_PROJECT, configDataSource)) {
index = 0;
}
int finalIndex = index;
ThreadPoolUtil.executeInMain(() -> modifyProjectGuide.start(finalIndex));
});
});
} }
private void initView() {
initAdapter();
}
/** /**
* 进入项目详情 * 进入项目详情
*/ */
private void goProjectDetail(ProjectRecord item) { private void goProjectDetail(ProjectRecord item) {
ProjectDetailFragment.start(requireContext(), if (ProjectType.isLevel(item.projectType)) {
item.projectType, ProjectDetailLevelFragment.start(requireContext(), item.projectType, item.getId(), item.getName());
item.getId(), } else {
item.getName()); ProjectDetailFragment.start(requireContext(),
item.projectType,
item.getId(),
item.getName());
}
} }
@Override @Override
@ -220,11 +189,83 @@ public class ProjectListFragment extends Fragment {
@Override @Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == R.id.menu_activity_project_list_help) { if (item.getItemId() == R.id.menu_activity_project_list_help) {
// Intent intent = new Intent(Utils.getApp(), AgentWebActivity.class);
// intent.putExtra("short_url", "android_url_activity_project_list_help");
// startActivity(intent);
AgentWebActivity.navigation2(getContext(), "android_url_activity_project_list_help"); AgentWebActivity.navigation2(getContext(), "android_url_activity_project_list_help");
} }
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
} }
private void startEditProject(ProjectRecord item) {
goCreateOrEditProject(item.projectType, item);
}
private void startDeleteProject(ProjectRecord item) {
//删除的时候判断是否需要更新默认项目
ThreadPoolUtil.execute(() -> {
//检测是否有测量数据
if (SurveyorRecordUtil.isProjectSurveyor(item.getId())) {
//弹框提示
runOnUI(() -> TipsFragment.cancelAbleTips(
getChildFragmentManager(),
getViewLifecycleOwner(),
requireContext(),
"要删除的项目存在测量数据,是否确认删除?",
4,
() -> ThreadPoolUtil.execute(() -> doDelete(item))));
} else {
ThreadPoolUtil.executeInMain(() -> {
DialogUtil.showConfirmDialog(getChildFragmentManager(), getViewLifecycleOwner(), "您确定要删除该项目吗?",
Tools.getString(R.string.confirm), () -> {
ThreadPoolUtil.execute(() -> {
doDelete(item);
});
});
});
}
});
}
@WorkerThread
private void doDelete(ProjectRecord item) {
IProjectDataSource projectDataSource = SurveyorDatabaseFactory.instance.getProjectDataSource();
IConfigDataSource configDataSource = SurveyorDatabaseFactory.instance.getConfigDataSource();
ConfigRecord defaultProject = configDataSource.getByKeySync(ConfigConstants.KEY_DEFAULT_PROJECT_ID);
boolean needChangeDefaultProjectId = false;
if (defaultProject == null || defaultProject.getConfigValue().equals(item.getId())) {
needChangeDefaultProjectId = true;
}
//先删除项目及关联
projectDataSource.delete(item);
if (needChangeDefaultProjectId) {
String projectId = "";
String periodId = "";
List<ProjectRecord> projectRecords = projectDataSource.getDataList();
if (projectRecords != null) {
ISurveyorPeriodDataSource surveyorPeriodDataSource = SurveyorDatabaseFactory.instance.getSurveyorPeriod();
for (ProjectRecord projectRecord : projectRecords) {
if (projectRecord == null) {
continue;
}
List<SurveyorPeriodRecord> surveyorPeriodRecordList = surveyorPeriodDataSource.getDataListSyncByProjectId(projectRecord.getId());
for (SurveyorPeriodRecord surveyorPeriodRecord : surveyorPeriodRecordList) {
if (surveyorPeriodRecord == null) {
continue;
}
periodId = surveyorPeriodRecord.getId();
break;
}
if (!periodId.isEmpty()) {
projectId = projectRecord.getId();
break;
}
}
}
configDataSource.set(ConfigConstants.KEY_DEFAULT_PROJECT_ID, projectId);
configDataSource.set(ConfigConstants.KEY_DEFAULT_PERIOD_ID, periodId);
}
}
} }

@ -1,352 +0,0 @@
package com.bingce.controlnetwork.fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.bingce.controlapphelper.datasource.database.SurveyorDatabaseFactory;
import com.bingce.controlapphelper.datasource.database.config.ConfigConstants;
import com.bingce.controlapphelper.datasource.database.config.ConfigRecord;
import com.bingce.controlapphelper.datasource.database.config.IConfigDataSource;
import com.bingce.controlapphelper.datasource.database.project.IProjectDataSource;
import com.bingce.controlapphelper.datasource.database.project.ProjectRecord;
import com.bingce.controlapphelper.datasource.database.surveyorcycle.SurveyorPeriodRecord;
import com.bingce.controlnetwork.guide.GuideSequence;
import com.bingce.controlnetwork.guide.ITapTargetProvider;
import com.bingce.utils.IOnSingleGetCallback;
import com.bingce.utils.ThreadPoolUtil;
import java.util.List;
import com.bingce.controlnetwork.R;
import com.bingce.controlnetwork.fragment.base.BaseFragment;
import com.bingce.controlnetwork.guide.GuideSequence;
import com.bingce.controlnetwork.guide.ITapTargetProvider;
/**
* 主页面-测量
*/
public class SurveyorStationListFragment extends BaseFragment {
private final ComponentSurveyorStationListFragment fragment = ComponentSurveyorStationListFragment.newInstance("", "", false);
private String projectId;
private String periodId;
private final GuideSequence guideSequence;
private final IConfigDataSource configDataSource =
SurveyorDatabaseFactory.instance.getConfigDataSource();
private static final int GUIDE_INDEX_SWITCH_STATION = 0;//切换测站列表
public SurveyorStationListFragment() {
super();
guideSequence = new GuideSequence(GUIDE_INDEX_SWITCH_STATION + 1, new GuideSequence.IDelegate() {
@Override
public void show(int index, ITapTargetProvider provider) {
if (GUIDE_INDEX_SWITCH_STATION == index) {
provider.show4View(
getActivity(),
findViewById(R.id.select),
getString(R.string.guide_switch_station_list),
getString(R.string.guide_switch_station_list_describe)
);
}
}
@Override
public void dismiss(int index) {
if (GUIDE_INDEX_SWITCH_STATION == index) {
ConfigConstants.markGuideCompleted(ConfigConstants.KEY_GUIDE_SWITCH_STATION_LIST, configDataSource);
}
}
});
}
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_project_surveyor_station_list_layout, container, false);
}
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
SurveyorDatabaseFactory
.instance
.getConfigDataSource()
.getLiveDataByKey(ConfigConstants.KEY_DEFAULT_PROJECT_ID)
.observe(getViewLifecycleOwner(), onProjectIdCallback::onGet);
}
@Override
public void onResume() {
super.onResume();
refreshUI();
}
private final IOnSingleGetCallback<SurveyorPeriodRecord> onSurveyorCycleRecordCallback = new IOnSingleGetCallback<SurveyorPeriodRecord>() {
@Override
public void onGet(SurveyorPeriodRecord instance) {
if (instance == null) {
update(projectId, "");
return;
}
periodId = instance.getId();
update(projectId, periodId);
}
};
private final IOnSingleGetCallback<ProjectRecord> onProjectRecordCallback = new IOnSingleGetCallback<ProjectRecord>() {
@Override
public void onGet(ProjectRecord instance) {
if (instance == null) {
update("", "");
return;
}
projectId = instance.id;
SurveyorDatabaseFactory
.instance
.getSurveyorPeriod()
.getDefault(projectId, onSurveyorCycleRecordCallback);
}
};
/**
* 第一次获取到的测其id
*/
private final IOnSingleGetCallback<ConfigRecord> onSurveyorCycleCallback = new IOnSingleGetCallback<ConfigRecord>() {
@Override
public void onGet(ConfigRecord instance) {
if (instance == null) {
SurveyorDatabaseFactory
.instance
.getProjectDataSource()
.getDefaultRecord(onProjectRecordCallback);
return;
}
periodId = instance.getConfigValue();
update(projectId, periodId);
}
};
/**
* 第一次获取到的默认项目id
*/
private final IOnSingleGetCallback<ConfigRecord> onProjectIdCallback = new IOnSingleGetCallback<ConfigRecord>() {
@Override
public void onGet(ConfigRecord instance) {
if (instance == null) {
SurveyorDatabaseFactory
.instance
.getProjectDataSource()
.getDefaultRecord(onProjectRecordCallback);
return;
}
projectId = instance.getConfigValue();
//project是否被删除
if (projectId == null || projectId.isEmpty()) {
update("", "");
return;
}
SurveyorDatabaseFactory
.instance
.getConfigDataSource()
.getByKey(ConfigConstants.KEY_DEFAULT_PERIOD_ID, onSurveyorCycleCallback);
}
};
private void refreshUI() {
ThreadPoolUtil.execute(() -> {
//检测当前项目列表是否为空
IProjectDataSource projectDataSource =
SurveyorDatabaseFactory.instance.getProjectDataSource();
if (projectDataSource.recordCount() > 0 && !ConfigConstants.isGuideCompleted(ConfigConstants.KEY_GUIDE_SWITCH_STATION_LIST, configDataSource)) {
//当项目记录数大于0并且没有提示过的时候 进行引导提示
runOnUI(() -> guideSequence.start(GUIDE_INDEX_SWITCH_STATION));
}
});
}
private void updateText(String projectName, String cycleName) {
View view = getView();
if (view == null) {
return;
}
runOnUI(() -> {
View titleLayout = view.findViewById(R.id.title);
if (titleLayout != null &&
projectName != null && !projectName.isEmpty() &&
cycleName != null && !cycleName.isEmpty()) {
//当项目和测期都不为空的时候设置
titleLayout.setVisibility(View.VISIBLE);
TextView title = view.findViewById(R.id.titleView);
if (title != null && getContext() != null) {
String string = projectName + " > " + cycleName;
title.setText(string);
}
titleLayout.setOnClickListener(onSwitchClickListener);
} else if (titleLayout != null) {
titleLayout.setVisibility(View.INVISIBLE);
}
});
}
private final View.OnClickListener onSwitchClickListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
//去选择项目和测期
// SelectProjectAndSurveyorCycleFragment.select(
// getChildFragmentManager(),
// getViewLifecycleOwner(),
// projectId,
// cycleIndex,
// (pId, pName, cycleId, cycleName) -> {
// //刷新数据
// projectId = pId;
// cycleIndex = cycleId;
// //保存默认值
// IConfigDataSource configDataSource =
// SurveyorDatabaseFactory
// .instance
// .getConfigDataSource();
// //数据存储
// configDataSource.set(ConfigConstants.KEY_DEFAULT_PROJECT_ID, projectId);
// configDataSource.set(ConfigConstants.KEY_DEFAULT_CYCLE_ID, cycleIndex);
//
// updateText(pName, cycleName);
// fragment.update(pId, cycleId);
// });
// BottomPageFragment.showBottom(getChildFragmentManager(), getViewLifecycleOwner(),
// selectData,
// selectData -> {
//
// });
}
};
// private IData selectData = new IData() {
//
// @Nullable
// @Override
// public Object getData(@Nullable BottomBean bottomBean, @NonNull Continuation<? super List<? extends BottomBean>> $completion) {
// return null;
// }
//
// @Override
// public String getTitle(int pageIndex) {
// if (pageIndex == 0) {
// return "请选择项目";
// } else if (pageIndex == 1) {
// return "请选择测期";
// }
// return "";
// }
// @Nullable
// @Override
// public List<BottomBean> getData(@Nullable BottomBean bottomBean) {
// List<BottomBean> dataList = new ArrayList<>();
// if (bottomBean == null) {
// List<ProjectRecord> projectRecords = SurveyorDatabaseFactory
// .instance
// .getProjectDataSource()
// .getDataList();
//
// for (ProjectRecord projectRecord : projectRecords) {
// dataList.add(new BottomBean(projectRecord.getId(), projectRecord.getProjectName(),
// 0, false, null));
// }
//
// } else {
// if (bottomBean.getPageIndex() == 0) {
//
// List<SurveyorPeriodRecord> periodRecords = SurveyorDatabaseFactory.instance
// .getSurveyorPeriod().getDataListSyncByProjectId(bottomBean.getId());
//
// for (SurveyorPeriodRecord projectRecord : periodRecords) {
// dataList.add(new BottomBean(projectRecord.getId(), projectRecord.getName(),
// 1, false, null));
// }
//
// }
// }
//
// return dataList;
// }
// };
/**
* @param projectId
* @param periodId
*/
private void update(final String projectId, final String periodId) {
if (fragment == null) {
return;
}
View view = getView();
if (view == null) {
return;
}
ThreadPoolUtil.execute(() -> {
String projectName = "";
String cycleName = "";
ProjectRecord projectRecord =
SurveyorDatabaseFactory
.instance
.getProjectDataSource()
.getRecord(projectId);
if (projectRecord != null) {
projectName = projectRecord.getProjectName();
}
SurveyorPeriodRecord periodRecord =
SurveyorDatabaseFactory
.instance
.getSurveyorPeriod()
.getRecord(periodId);
if (periodRecord == null) {
//获取第一个测期
List<SurveyorPeriodRecord> records = SurveyorDatabaseFactory
.instance
.getSurveyorPeriod()
.getDataListSyncByProjectId(projectId);
if (!records.isEmpty()) {
periodRecord = records.get(0);
}
}
if (periodRecord != null) {
cycleName = periodRecord.getName();
this.periodId = periodRecord.getId();
}
updateText(projectName, cycleName);
this.projectId = projectId;
fragment.update(this.projectId, this.periodId);
});
}
public static SurveyorStationListFragment newInstance() {
return new SurveyorStationListFragment();
}
private void switchContentFragment() {
getChildFragmentManager()
.beginTransaction()
.replace(R.id.fragment_container, fragment, "___station_list")
.commit();
}
}

@ -17,9 +17,12 @@ import com.bingce.controlapphelper.model.BundleConstants;
import com.bingce.controlapphelper.model.ProjectTolerance; import com.bingce.controlapphelper.model.ProjectTolerance;
import com.bingce.controlapphelper.model.ToleranceAttributesType; import com.bingce.controlapphelper.model.ToleranceAttributesType;
import com.bingce.controlnetwork.R; import com.bingce.controlnetwork.R;
import com.bingce.controlnetwork.event.RefreshToleranceTotailEvent;
import com.bingce.utils.ThreadPoolUtil; import com.bingce.utils.ThreadPoolUtil;
import com.rengwuxian.materialedittext.MaterialEditText; import com.rengwuxian.materialedittext.MaterialEditText;
import org.greenrobot.eventbus.EventBus;
public class ToleranceAttributeEditFragment extends AbstractFullScreenDialogFragment { public class ToleranceAttributeEditFragment extends AbstractFullScreenDialogFragment {
@Override @Override
@ -36,98 +39,88 @@ public class ToleranceAttributeEditFragment extends AbstractFullScreenDialogFrag
return; return;
} }
ProjectTolerance projectTolerance = new ProjectTolerance(record); ProjectTolerance projectTolerance = new ProjectTolerance(record);
int attributeIndex = getArguments().getInt(KEY_ATTRIBUTE_INDEX, -1);
setData(contentView, projectTolerance); if (attributeIndex < 0) {
return;
});
}
return contentView;
}
private void setData(View contentView, ProjectTolerance projectTolerance) {
ThreadPoolUtil.executeInMain(() -> {
int attributeIndex = getArguments().getInt(KEY_ATTRIBUTE_INDEX, -1);
if (attributeIndex < 0) {
return;
}
ToleranceAttributesType type = ToleranceAttributesType.values()[attributeIndex];
MaterialEditText editor = contentView.findViewById(R.id.editor);
SwitchCompat switchCompat = contentView.findViewById(R.id.switch_control);
View integerView = contentView.findViewById(R.id.integerValue);
if (projectTolerance.isBoolValue(type)) {
if (editor != null) {
editor.setVisibility(View.GONE);
}
if (integerView != null) {
integerView.setVisibility(View.GONE);
}
if (switchCompat != null) {
switchCompat.setVisibility(View.VISIBLE);
switchCompat.setChecked(projectTolerance.getBoolAttribute(type));
}
} else if (projectTolerance.isDoubleValue(type)) {
if (editor != null) {
editor.setVisibility(View.VISIBLE);
String value = String.valueOf(projectTolerance.getDoubleAttribute(type));
editor.setText(value);
editor.setHint(value);
}
if (switchCompat != null) {
switchCompat.setVisibility(View.GONE);
}
if (integerView != null) {
integerView.setVisibility(View.GONE);
}
} else if (projectTolerance.isIntegerValue(type)) {
if (editor != null) {
editor.setVisibility(View.GONE);
}
if (switchCompat != null) {
switchCompat.setVisibility(View.GONE);
} }
if (integerView != null) { ToleranceAttributesType type = ToleranceAttributesType.values()[attributeIndex];
integerView.setVisibility(View.VISIBLE); MaterialEditText editor = contentView.findViewById(R.id.editor);
String value = String.valueOf(projectTolerance.getIntegerAttribute(type)); SwitchCompat switchCompat = contentView.findViewById(R.id.switch_control);
TextView countView = integerView.findViewById(R.id.count); View integerView = contentView.findViewById(R.id.integerValue);
countView.setText(value); if (projectTolerance.isBoolValue(type)) {
View left = integerView.findViewById(R.id.left); if (editor != null) {
View right = integerView.findViewById(R.id.right); integerView.setVisibility(View.GONE);
if (left != null) {
if (Integer.parseInt(value) <= 1) {
left.setEnabled(false);
}
left.setOnClickListener(v -> {
int count = Integer.parseInt(countView.getText().toString());
countView.setText(String.valueOf(count - 1));
if (count - 1 <= 1) {//禁止减小
left.setEnabled(false);
}
//减小后增大变为可用
if (right != null) {
right.setEnabled(true);
}
});
} }
if (right != null) { if (integerView != null) {
right.setOnClickListener(v -> { integerView.setVisibility(View.GONE);
int count = Integer.parseInt(countView.getText().toString()); }
countView.setText(String.valueOf(count + 1)); if (switchCompat != null) {
//增大后减小变为可用 switchCompat.setVisibility(View.VISIBLE);
if (left != null) { switchCompat.setChecked(projectTolerance.getBoolAttribute(type));
left.setEnabled(true); }
} } else if (projectTolerance.isDoubleValue(type)) {
if (type == ToleranceAttributesType.singleSurveyor && count + 1 >= 2) { if (editor != null) {
right.setEnabled(false); editor.setVisibility(View.VISIBLE);
String value = String.valueOf(projectTolerance.getDoubleAttribute(type));
editor.setText(value);
editor.setHint(value);
}
if (switchCompat != null) {
switchCompat.setVisibility(View.GONE);
}
if (integerView != null) {
integerView.setVisibility(View.GONE);
}
} else if (projectTolerance.isIntegerValue(type)) {
if (editor != null) {
editor.setVisibility(View.GONE);
}
if (switchCompat != null) {
switchCompat.setVisibility(View.GONE);
}
if (integerView != null) {
integerView.setVisibility(View.VISIBLE);
String value = String.valueOf(projectTolerance.getIntegerAttribute(type));
TextView countView = integerView.findViewById(R.id.count);
countView.setText(value);
View left = integerView.findViewById(R.id.left);
View right = integerView.findViewById(R.id.right);
if (left != null) {
if (Integer.parseInt(value) <= 1) {
left.setEnabled(false);
} }
}); left.setOnClickListener(v -> {
int count = Integer.parseInt(countView.getText().toString());
countView.setText(String.valueOf(count - 1));
if (count - 1 <= 1) {//禁止减小
left.setEnabled(false);
}
//减小后增大变为可用
if (right != null) {
right.setEnabled(true);
}
});
}
if (right != null) {
right.setOnClickListener(v -> {
int count = Integer.parseInt(countView.getText().toString());
countView.setText(String.valueOf(count + 1));
//增大后减小变为可用
if (left != null) {
left.setEnabled(true);
}
if (type == ToleranceAttributesType.singleSurveyor && count + 1 >= 2) {
right.setEnabled(false);
}
});
}
} }
} }
} });
}); }
return contentView;
} }
@Override @Override
protected void onConfirm() { protected void onConfirm() {
ThreadPoolUtil.execute(() -> { ThreadPoolUtil.execute(() -> {
@ -169,12 +162,12 @@ public class ToleranceAttributeEditFragment extends AbstractFullScreenDialogFrag
projectTolerance.setIntegerAttribute(type, Integer.parseInt(string)); projectTolerance.setIntegerAttribute(type, Integer.parseInt(string));
} }
//存储数据 //存储数据
projectTolerance.updateToleranceRecord(this::dismiss); projectTolerance.save2DataSource(() -> {
}); EventBus.getDefault().post(new RefreshToleranceTotailEvent());
} dismissAllowingStateLoss();
});
private ToleranceAttributeEditFragment() { });
super();
} }
private static final String KEY_ATTRIBUTE_INDEX = "__attribute_index___"; private static final String KEY_ATTRIBUTE_INDEX = "__attribute_index___";

@ -9,61 +9,89 @@ import android.widget.ExpandableListView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import com.bingce.controlapphelper.datasource.database.SurveyorDatabaseFactory; import com.bingce.controlapphelper.datasource.database.leveling.tolerance.LevelingToleranceDetail;
import com.bingce.controlapphelper.datasource.database.tolerance.detail.IToleranceDetail;
import com.bingce.controlapphelper.datasource.database.tolerance.detail.ToleranceDetailRecord;
import com.bingce.controlapphelper.datasource.database.tolerance.load.IToleranceOperate;
import com.bingce.controlapphelper.interfacee.IProjectTolerance;
import com.bingce.controlapphelper.model.BundleConstants; import com.bingce.controlapphelper.model.BundleConstants;
import com.bingce.controlapphelper.model.ProjectTolerance; import com.bingce.controlapphelper.model.ProjectTolerance;
import com.bingce.controlapphelper.util.SurveyorRecordUtil; import com.bingce.controlapphelper.model.tolerance.ProjectToleranceLeveling;
import com.bingce.controlapphelper.util.Tools;
import com.bingce.controlnetwork.R; import com.bingce.controlnetwork.R;
import com.bingce.controlnetwork.activity.fragmentcontainer.FragmentContainerActivity; import com.bingce.controlnetwork.activity.fragmentcontainer.FragmentContainerActivity;
import com.bingce.controlnetwork.adapter.ToleranceDetailAdapter; import com.bingce.controlnetwork.adapter.ToleranceDetailAdapter;
import com.bingce.controlnetwork.event.RefreshToleranceTotailEvent;
import com.bingce.controlnetwork.util.tolerance.ToleranceOperateUtil;
import com.bingce.utils.ThreadPoolUtil; import com.bingce.utils.ThreadPoolUtil;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
/** /**
* 限差详情页 * 限差详情页
*/ */
public class ToleranceDetailFragment extends Fragment { public class ToleranceDetailFragment extends Fragment {
public static final String TAG = ToleranceDetailFragment.class.getName(); public static final String TAG = ToleranceDetailFragment.class.getName();
private String toleranceId; private String currentToleranceId;
private ToleranceDetailAdapter adapter; private ToleranceDetailAdapter adapter;
private ToleranceDetailFragment() { private ExpandableListView expandableListView;
@Subscribe(threadMode = ThreadMode.MAIN)
public void refresh(RefreshToleranceTotailEvent event) {
refreshUi();
} }
@Override @Override
public void onAttach(@NonNull Context context) { public void onAttach(@NonNull Context context) {
super.onAttach(context); super.onAttach(context);
if (getArguments() != null) { if (getArguments() != null) {
toleranceId = getArguments().getString(BundleConstants.KEY_TOLERANCE_ID); currentToleranceId = getArguments().getString(BundleConstants.KEY_TOLERANCE_ID);
} }
} }
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) { Bundle savedInstanceState) {
EventBus.getDefault().register(this);
View view = inflater.inflate(R.layout.fragment_limit_detail_list, container, false); View view = inflater.inflate(R.layout.fragment_limit_detail_list, container, false);
if (view instanceof ExpandableListView) { expandableListView = view.findViewById(R.id.list);
changeTolerance(toleranceId, view); refreshUi();
}
return view; return view;
} }
public void changeTolerance(String id) { @Override
changeTolerance(id, getView()); public void onDestroyView() {
super.onDestroyView();
EventBus.getDefault().unregister(this);
} }
private void changeTolerance(String id, View view) { public void switchTolerance(String id) {
toleranceId = id; currentToleranceId = id;
ExpandableListView expandableListView = (ExpandableListView) view; refreshUi();
SurveyorDatabaseFactory }
.instance
.getToleranceDetailDataSource() private void refreshUi() {
.getLiveDataRecord(id) IToleranceOperate operate = ToleranceOperateUtil.getOperate(currentToleranceId);
.observe(getViewLifecycleOwner(), if (operate == null) {
toleranceRecord -> return;
updateTolerance(expandableListView, new ProjectTolerance(toleranceRecord))); }
ThreadPoolUtil.execute(() -> {
IToleranceDetail iToleranceDetail = operate.getIToleranceDetail(currentToleranceId);
ThreadPoolUtil.executeInMain(() -> {
if (iToleranceDetail != null) {
if (iToleranceDetail instanceof LevelingToleranceDetail) {
updateTolerance(expandableListView, new ProjectToleranceLeveling((LevelingToleranceDetail) iToleranceDetail));
} else if (iToleranceDetail instanceof ToleranceDetailRecord) {
updateTolerance(expandableListView, new ProjectTolerance((ToleranceDetailRecord) iToleranceDetail));
}
}
});
});
} }
/** /**
@ -72,70 +100,68 @@ public class ToleranceDetailFragment extends Fragment {
* @param expandableListView * @param expandableListView
* @param projectTolerance * @param projectTolerance
*/ */
private void updateTolerance(ExpandableListView expandableListView, ProjectTolerance projectTolerance) { private void updateTolerance(ExpandableListView expandableListView, IProjectTolerance projectTolerance) {
if (!toleranceId.equals(projectTolerance.id())) { if (!currentToleranceId.equals(projectTolerance.id())) {
return; return;
} }
boolean editableForWholeTolerance = projectTolerance.isWritable(); boolean editable = projectTolerance.isWritable();
//填充adapter //填充adapter
if (adapter == null) { if (adapter == null) {
adapter = new ToleranceDetailAdapter(projectTolerance); adapter = new ToleranceDetailAdapter(projectTolerance);
expandableListView.setAdapter(adapter); expandableListView.setAdapter(adapter);
//全部展开 expandAllItemView(expandableListView, projectTolerance);
int groupCount = expandableListView.getCount();
for (int index = 0; index < groupCount; index++) {
expandableListView.expandGroup(index);
}
} else { } else {
adapter.updateData(projectTolerance); adapter.updateData(projectTolerance);
expandAllItemView(expandableListView, projectTolerance);
} }
//设置点击事件 //设置点击事件
expandableListView.setOnChildClickListener((parent, v, groupPosition, childPosition, viewId) -> { expandableListView.setOnChildClickListener((parent, v, groupPosition, childPosition, viewId) -> {
checkToleranceClick(projectTolerance, groupPosition, childPosition, success -> { boolean forbidModify = false;
if (success) { if (getArguments() != null) {
ToleranceAttributeEditFragment forbidModify = getArguments().getBoolean(KEY_FORBID_MODIFY, false);
.editAndSave(toleranceId, }
projectTolerance.attributesType(groupPosition, childPosition), if (editable && !forbidModify) {//执行编辑
projectTolerance.attributesName(groupPosition, childPosition), ToleranceAttributeEditFragment
projectTolerance.groupName(groupPosition), .editAndSave(currentToleranceId,
getChildFragmentManager()); projectTolerance.attributesType(groupPosition, childPosition),
} projectTolerance.attributesName(groupPosition, childPosition),
}); projectTolerance.groupName(groupPosition),
getChildFragmentManager());
} else if (forbidModify) {
TipsFragment.tipsOnly(getChildFragmentManager(),
getViewLifecycleOwner(),
getContext(),
getString(R.string.tips_tolerance_cannt_modify_because_has_surveyed));
} else {
TipsFragment.tipsOnly(getChildFragmentManager(),
getViewLifecycleOwner(),
getContext(),
getString(R.string.tips_tolerance_template_cannt_delete));
}
return true; return true;
}); });
} }
private void checkToleranceClick(ProjectTolerance projectTolerance, int groupPosition, int childPosition, ICheckEditTolerance checkEditTolerance) { /**
ThreadPoolUtil.execute(() -> { * 全部展开
//该限差是否有项目测量数据 *
boolean hasSurveyedWithToleraeId = SurveyorRecordUtil.isToleranceSurveyor(toleranceId); * @param expandableListView
* @param projectTolerance
//单个点击限差是否可以编辑 */
boolean editToleranceSingle = projectTolerance.isEditTolerance(groupPosition, childPosition); private void expandAllItemView(ExpandableListView expandableListView, IProjectTolerance projectTolerance) {
int groupCount = projectTolerance.groupCount();
boolean isCanEditTolerance = false;//是否可以编辑限差 for (int index = 0; index < groupCount; index++) {
if (projectTolerance.isWritable() && editToleranceSingle && !hasSurveyedWithToleraeId) { expandableListView.expandGroup(index);
isCanEditTolerance = true; }
} else {
if (!editToleranceSingle) {
tipsError(getString(R.string.tips_tolerance_template_cannt_delete_short));
} else if (!projectTolerance.isWritable()) {
tipsError(getString(R.string.tips_tolerance_template_cannt_delete));
} else {
//这里统一提示有数据不能修改
tipsError(getString(R.string.tips_tolerance_cannt_modify_because_has_surveyed));
}
}
checkEditTolerance.result(isCanEditTolerance);
});
} }
private void tipsError(String errorMsg) { private static final String KEY_FORBID_MODIFY = "__forbid_modify";
runOnUi(() -> TipsFragment.tipsOnly(getChildFragmentManager(),
getViewLifecycleOwner(), public static ToleranceDetailFragment newInstance(Bundle args, boolean forbidModify) {
requireContext(), ToleranceDetailFragment fragment = new ToleranceDetailFragment();
errorMsg)); args.putBoolean(KEY_FORBID_MODIFY, forbidModify);
fragment.setArguments(args);
return fragment;
} }
public static ToleranceDetailFragment newInstance(Bundle args) { public static ToleranceDetailFragment newInstance(Bundle args) {
@ -144,20 +170,10 @@ public class ToleranceDetailFragment extends Fragment {
return fragment; return fragment;
} }
public static void start(Context context, String toleranceId) { public static void start(Context context, String toleranceId, boolean forbidModify) {
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putBoolean(KEY_FORBID_MODIFY, forbidModify);
args.putString(BundleConstants.KEY_TOLERANCE_ID, toleranceId); args.putString(BundleConstants.KEY_TOLERANCE_ID, toleranceId);
FragmentContainerActivity.start(context, TAG, Tools.getString(R.string.menu_item_project_tolerance_setting), args); FragmentContainerActivity.start(context, TAG, "限差设置", args);
}
private interface ICheckEditTolerance {
void result(boolean success);
}
private void runOnUi(Runnable runnable) {
FragmentActivity activity = getActivity();
if (activity != null) {
activity.runOnUiThread(runnable);
}
} }
} }

@ -14,13 +14,16 @@ import androidx.lifecycle.LifecycleOwner;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import com.bingce.controlapphelper.datasource.database.SurveyorDatabaseFactory; import com.bingce.controlapphelper.datasource.database.SurveyorDatabaseFactory;
import com.bingce.controlapphelper.datasource.database.ToleranceTemplate; import com.bingce.controlapphelper.datasource.database.project.IProjectDataSource;
import com.bingce.controlapphelper.datasource.database.project.ProjectRecord;
import com.bingce.controlapphelper.datasource.database.tolerance.detail.IToleranceDetailDataSource; import com.bingce.controlapphelper.datasource.database.tolerance.detail.IToleranceDetailDataSource;
import com.bingce.controlapphelper.datasource.database.tolerance.detail.ToleranceDetailRecord; import com.bingce.controlapphelper.datasource.database.tolerance.detail.ToleranceDetailRecord;
import com.bingce.controlapphelper.datasource.database.tolerance.group.ToleranceGroupRecord; import com.bingce.controlapphelper.datasource.database.tolerance.group.ToleranceGroupRecord;
import com.bingce.controlapphelper.datasource.database.tolerance.level.ToleranceLevelRecord; import com.bingce.controlapphelper.datasource.database.tolerance.level.ToleranceLevelRecord;
import com.bingce.controlapphelper.datasource.database.tolerance.load.ToleranceLoadUtil;
import com.bingce.controlapphelper.model.BundleConstants; import com.bingce.controlapphelper.model.BundleConstants;
import com.bingce.controlapphelper.surveyor.method.ToleranceMethodKt; import com.bingce.controlapphelper.surveyor.method.ToleranceMethodKt;
import com.bingce.controlapphelper.util.SurveyorRecordUtil;
import com.bingce.controlapphelper.util.ToleranceUtil; import com.bingce.controlapphelper.util.ToleranceUtil;
import com.bingce.controlnetwork.R; import com.bingce.controlnetwork.R;
import com.bingce.controlnetwork.activity.fragmentcontainer.FragmentContainerActivity; import com.bingce.controlnetwork.activity.fragmentcontainer.FragmentContainerActivity;
@ -73,7 +76,7 @@ public class ToleranceManageFragment extends BaseFragment {
getViewLifecycleOwner(), getViewLifecycleOwner(),
getContext(), getContext(),
toleranceDetailRecords, toleranceDetailRecords,
item -> ToleranceDetailFragment.start(getContext(), item.getId())); this::clickToleranceItem);
recyclerView.setAdapter(adapter); recyclerView.setAdapter(adapter);
} else { } else {
adapter.updateData(toleranceDetailRecords); adapter.updateData(toleranceDetailRecords);
@ -87,6 +90,29 @@ public class ToleranceManageFragment extends BaseFragment {
return rootView; return rootView;
} }
/**
* 点击限差进行编辑
*
* @param item
*/
private void clickToleranceItem(ToleranceDetailRecord item) {
ThreadPoolUtil.execute(() -> {
IProjectDataSource projectDataSource = SurveyorDatabaseFactory
.instance.getProjectDataSource();
List<ProjectRecord> projectRecordList = projectDataSource
.getDataListByToleranceId(item.getId());
boolean hasSurveyed = false;
for (ProjectRecord projectRecord : projectRecordList) {
if (SurveyorRecordUtil.isProjectSurveyor(projectRecord.getId())) {
hasSurveyed = true;
break;
}
}
boolean finalHasSurveyed = hasSurveyed;
runOnUI(() -> ToleranceDetailFragment.start(getContext(), item.getId(), finalHasSurveyed));
});
}
private void showSelectedToleranceDlg(View view) { private void showSelectedToleranceDlg(View view) {
SelectToleranceTemplateBottomSheetFragment.select( SelectToleranceTemplateBottomSheetFragment.select(
@ -109,16 +135,17 @@ public class ToleranceManageFragment extends BaseFragment {
SurveyorDatabaseFactory.instance.getToleranceDetailDataSource(); SurveyorDatabaseFactory.instance.getToleranceDetailDataSource();
ThreadPoolUtil.execute(() -> { ThreadPoolUtil.execute(() -> {
//先检测预置模板 //先检测预置模板
ToleranceDetailRecord toleranceDetailRecord = ToleranceTemplate.detailOf(toleranceId); ToleranceDetailRecord toleranceDetailRecord = (ToleranceDetailRecord) ToleranceLoadUtil.getTriangleToleranceLoad().detailOf(toleranceId);
if (toleranceDetailRecord == null) { if (toleranceDetailRecord == null) {
toleranceDetailRecord = toleranceDetailDataSource.getRecordSync(toleranceId); toleranceDetailRecord = toleranceDetailDataSource.getRecordSync(toleranceId);
} }
if (toleranceDetailRecord == null) { if (toleranceDetailRecord == null) {
return; return;
} }
//查询限差完整名称 //查询限差完整名称
ToleranceGroupRecord toleranceGroupRecord = ToleranceTemplate.groupOf(toleranceDetailRecord.groupId); ToleranceGroupRecord toleranceGroupRecord = ToleranceLoadUtil.getTriangleToleranceLoad().groupOf(toleranceDetailRecord.getGroupId());
ToleranceLevelRecord toleranceLevelRecord = ToleranceTemplate.levelOf(toleranceDetailRecord.levelId); ToleranceLevelRecord toleranceLevelRecord = ToleranceLoadUtil.getTriangleToleranceLoad().levelOf(toleranceDetailRecord.getLevelId());
if (toleranceGroupRecord == null) { if (toleranceGroupRecord == null) {
ToastUtils.showShort(R.string.error_tips_tolerance_template_read_failure); ToastUtils.showShort(R.string.error_tips_tolerance_template_read_failure);
return; return;
@ -142,13 +169,13 @@ public class ToleranceManageFragment extends BaseFragment {
} }
private static void gotoEditNewTolerance(Context context, ToleranceDetailRecord template, String name) { private static void gotoEditNewTolerance(Context context, ToleranceDetailRecord template, String name) {
ToleranceDetailRecord newInstance = new ToleranceDetailRecord(template); ToleranceDetailRecord newInstance = template.convertCustomRecord(template);
newInstance.singleSurveyor = template.singleSurveyor; newInstance.singleSurveyor = template.singleSurveyor;
newInstance.setName(name); newInstance.setName(name);
SurveyorDatabaseFactory SurveyorDatabaseFactory
.instance .instance
.getToleranceDetailDataSource() .getToleranceDetailDataSource()
.saveWithCallback(newInstance, () -> ToleranceDetailFragment.start(context, newInstance.getId())); .saveWithCallback(newInstance, () -> ToleranceDetailFragment.start(context, newInstance.getId(), false));
} }
private static class _Adapter extends BaseIndexTextWithContextMenuAdapter<ToleranceDetailRecord> private static class _Adapter extends BaseIndexTextWithContextMenuAdapter<ToleranceDetailRecord>
@ -200,4 +227,5 @@ public class ToleranceManageFragment extends BaseFragment {
fragment.setArguments(bundle); fragment.setArguments(bundle);
return fragment; return fragment;
} }
} }

@ -4,6 +4,7 @@ import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.text.TextUtils;
import android.view.Menu; import android.view.Menu;
import android.view.MenuInflater; import android.view.MenuInflater;
import android.view.MenuItem; import android.view.MenuItem;
@ -14,46 +15,42 @@ import androidx.activity.result.contract.ActivityResultContracts;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import com.bingce.controlapphelper.datasource.database.SurveyorDatabaseFactory; import com.bingce.controlapphelper.datasource.database.tolerance.detail.IToleranceDetail;
import com.bingce.controlapphelper.datasource.database.tolerance.detail.ToleranceDetailRecord; import com.bingce.controlapphelper.datasource.database.tolerance.load.IToleranceOperate;
import com.bingce.controlapphelper.model.BundleConstants; import com.bingce.controlapphelper.model.BundleConstants;
import com.bingce.controlnetwork.R; import com.bingce.controlnetwork.R;
import com.bingce.controlnetwork.activity.fragmentcontainer.FragmentContainerActivity; import com.bingce.controlnetwork.activity.fragmentcontainer.FragmentContainerActivity;
import com.bingce.controlnetwork.util.tolerance.ToleranceOperateUtil;
import com.bingce.utils.ThreadPoolUtil; import com.bingce.utils.ThreadPoolUtil;
public class ToleranceSelectFragment extends AbstractProjectToleranceFragment { public class ToleranceSelectFragment extends AbstractProjectToleranceFragment {
public static final String TAG = ToleranceSelectFragment.class.getName(); public static final String TAG = ToleranceSelectFragment.class.getName();
private ToleranceSelectFragment() {
super();
}
@Override @Override
protected void onCreateView(View view) { protected void onCreateView(View view) {
String toleranceId = null; String toleranceId = null;
if (getArguments() != null) { if (getArguments() != null) {
toleranceId = getArguments().getString(BundleConstants.KEY_TOLERANCE_ID); toleranceId = getArguments().getString(BundleConstants.KEY_TOLERANCE_ID);
if (toleranceId != null && !toleranceId.isEmpty()) {
String finalToleranceId = toleranceId;
ThreadPoolUtil.execute(() -> {
ToleranceDetailRecord instance =
SurveyorDatabaseFactory.instance
.getToleranceDetailDataSource().getRecordSync(finalToleranceId);
updateToleranceDetail(view, instance);
});
}
}
//当前没有限差的时候
if (toleranceId == null || toleranceId.isEmpty()) {
if (getArguments() != null) {
ToleranceDetailRecord firstDefaultTolerance = getFirstDefaultTolerance(projectType);
updateToleranceDetail(view, firstDefaultTolerance);
}
} }
initData(view, toleranceId);
setHasOptionsMenu(true); setHasOptionsMenu(true);
} }
private void initData(View view, String toleranceId) {
if (TextUtils.isEmpty(toleranceId)) {
IToleranceDetail firstDefaultTolerance = getNewDefaultTolerance(projectType);
updateToleranceDetail(view, firstDefaultTolerance);
} else {
ThreadPoolUtil.execute(() -> {
IToleranceOperate operate = ToleranceOperateUtil.getOperate(toleranceId);
if (operate != null) {
IToleranceDetail iToleranceDetail = operate.getIToleranceDetail(toleranceId);
updateToleranceDetail(view, iToleranceDetail);
}
});
}
}
@Override @Override
public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) { public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
inflater.inflate(R.menu.tolerance_select_menu, menu); inflater.inflate(R.menu.tolerance_select_menu, menu);
@ -95,7 +92,7 @@ public class ToleranceSelectFragment extends AbstractProjectToleranceFragment {
return; return;
} }
} }
selectCallback.onSelectTolerance(null); // selectCallback.onSelectTolerance(null);
}); });
} }

@ -6,8 +6,10 @@ import androidx.annotation.IdRes;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.lifecycle.Lifecycle; import androidx.lifecycle.Lifecycle;
public class BaseFragment extends Fragment { import com.bingce.controlapphelper.util.IUIRunner;
final protected void runOnUI(Runnable runnable) {
public class BaseFragment extends Fragment implements IUIRunner {
public void runOnUI(Runnable runnable) {
if (getActivity() == null) { if (getActivity() == null) {
return; return;
} }

@ -10,13 +10,11 @@ import android.view.MenuItem
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.annotation.WorkerThread import androidx.annotation.WorkerThread
import androidx.appcompat.widget.Toolbar
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
import blankj.utilcode.util.ToastUtils import blankj.utilcode.util.ToastUtils
import com.bingce.controlapphelper.datasource.database.ProjectType import com.bingce.controlapphelper.datasource.database.ProjectType
import com.bingce.controlapphelper.datasource.database.SurveyorDatabaseFactory import com.bingce.controlapphelper.datasource.database.SurveyorDatabaseFactory
import com.bingce.controlapphelper.datasource.database.config.ConfigConstants
import com.bingce.controlapphelper.event.SwitchPageEvent import com.bingce.controlapphelper.event.SwitchPageEvent
import com.bingce.controlapphelper.model.BundleConstants import com.bingce.controlapphelper.model.BundleConstants
import com.bingce.controlnetwork.R import com.bingce.controlnetwork.R
@ -25,20 +23,12 @@ import com.bingce.controlnetwork.databinding.FragmentProjectDetailListLayoutBind
import com.bingce.controlnetwork.fragment.PointListFragment import com.bingce.controlnetwork.fragment.PointListFragment
import com.bingce.controlnetwork.fragment.ProjectToleranceSettingFragment import com.bingce.controlnetwork.fragment.ProjectToleranceSettingFragment
import com.bingce.controlnetwork.fragment.base.BaseFragment import com.bingce.controlnetwork.fragment.base.BaseFragment
import com.bingce.controlnetwork.guide.GuideSequence
import com.bingce.controlnetwork.guide.ITapTargetProvider
import com.bingce.utils.ThreadPoolUtil
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import org.greenrobot.eventbus.EventBus import org.greenrobot.eventbus.EventBus
abstract class ProjectDetailFragment : BaseFragment() { abstract class ProjectDetailFragment : BaseFragment() {
val KEY_GUIDE_INDEX_SURVEYOR_TOLERANCE = 0
val KEY_GUIDE_INDEX_KNOWN_POINTS = 1
val KEY_GUIDE_INDEX_UN_KNOWN_POINTS = 2
val KEY_GUIDE_INDEX_SURVEYOR_CYCLE = 3
val KEY_GUIDE_INDEX_CREATE_STATION = 4
companion object { companion object {
@JvmStatic @JvmStatic
@ -63,95 +53,15 @@ abstract class ProjectDetailFragment : BaseFragment() {
protected val projectId: String by lazy { protected val projectId: String by lazy {
requireArguments().getString(BundleConstants.KEY_PROJECT_ID)!! requireArguments().getString(BundleConstants.KEY_PROJECT_ID)!!
} }
protected val projectType: String? by lazy { protected val projectType: String? by lazy {
requireArguments().getString(BundleConstants.KEY_PROJECT_TYPE) requireArguments().getString(BundleConstants.KEY_PROJECT_TYPE)
} }
private val editGuides: GuideSequence by lazy {
GuideSequence(KEY_GUIDE_INDEX_CREATE_STATION + 1, object : GuideSequence.IDelegate {
override fun show(index: Int, provider: ITapTargetProvider) {
val fragmentActivity = activity
if (fragmentActivity == null || fragmentActivity.isDestroyed || fragmentActivity.isFinishing) {
return
}
val guideMsgAndDesc = getGuideMsgAndDesc(index)
if (KEY_GUIDE_INDEX_SURVEYOR_TOLERANCE == index) {
if (fragmentActivity is FragmentContainerActivity) {
provider.show4ToolbarMenu(
fragmentActivity,
fragmentActivity.findViewById<Toolbar>(R.id.toolbar),
R.id.project_parameter_setting,
guideMsgAndDesc[0],
guideMsgAndDesc[1]
)
}
} else if (KEY_GUIDE_INDEX_KNOWN_POINTS == index) {
provider.show4View(
fragmentActivity,
fragmentActivity.findViewById<View>(R.id.known_point_list),
guideMsgAndDesc[0],
guideMsgAndDesc[1]
)
} else if (KEY_GUIDE_INDEX_UN_KNOWN_POINTS == index) {
provider.show4View(
fragmentActivity,
fragmentActivity.findViewById<View>(R.id.unknown_point_list),
guideMsgAndDesc[0],
guideMsgAndDesc[1]
)
} else if (KEY_GUIDE_INDEX_SURVEYOR_CYCLE == index) {
provider.show4View(
fragmentActivity,
fragmentActivity.findViewById<View>(R.id.cycle_layout),
guideMsgAndDesc[0],
guideMsgAndDesc[1]
)
} else if (KEY_GUIDE_INDEX_CREATE_STATION == index) {
provider.show4View(
fragmentActivity,
fragmentActivity.findViewById<View>(R.id.create_station_btn),
guideMsgAndDesc[0],
guideMsgAndDesc[1]
)
}
}
override fun dismiss(index: Int) {
if (KEY_GUIDE_INDEX_SURVEYOR_TOLERANCE == index) {
ConfigConstants.markGuideCompleted(
ConfigConstants.KEY_GUIDE_PROJECT_TOLERANCE,
configDataSource
)
} else if (KEY_GUIDE_INDEX_KNOWN_POINTS == index) {
ConfigConstants.markGuideCompleted(
ConfigConstants.KEY_GUIDE_PROJECT_KNOWN_POINT,
configDataSource
)
} else if (KEY_GUIDE_INDEX_UN_KNOWN_POINTS == index) {
ConfigConstants.markGuideCompleted(
ConfigConstants.KEY_GUIDE_PROJECT_UNKNOWN_POINT,
configDataSource
)
} else if (KEY_GUIDE_INDEX_SURVEYOR_CYCLE == index) {
ConfigConstants.markGuideCompleted(
ConfigConstants.KEY_GUIDE_PROJECT_SURVEYOR_CYCLE,
configDataSource
)
} else if (KEY_GUIDE_INDEX_CREATE_STATION == index) {
ConfigConstants.markGuideCompleted(
ConfigConstants.KEY_GUIDE_PROJECT_CRAETE_STATION,
configDataSource
)
}
}
})
}
override fun onCreateView( override fun onCreateView(
inflater: LayoutInflater, inflater: LayoutInflater,
container: ViewGroup?, container: ViewGroup?,
savedInstanceState: Bundle? savedInstanceState: Bundle?
): View { ): View {
_binding = FragmentProjectDetailListLayoutBinding.inflate(inflater, container, false) _binding = FragmentProjectDetailListLayoutBinding.inflate(inflater, container, false)
initView() initView()
@ -171,13 +81,14 @@ abstract class ProjectDetailFragment : BaseFragment() {
protected abstract fun clickCreateStation() protected abstract fun clickCreateStation()
protected abstract fun getGuideMsgAndDesc(position: Int): Array<String?>
private fun initView() { private fun initView() {
//设置开始测量
mBinding.ilBtn.btnTwo.text = getString(R.string.start_surveyor)
childFragmentManager childFragmentManager
.beginTransaction() .beginTransaction()
.replace(R.id.fragment_container, getContentFragment(), "__station_list") .replace(R.id.fragment_container, getContentFragment(), "__station_list")
.commit() .commit()
//已知点 //已知点
initKnownPoint() initKnownPoint()
//未知点 //未知点
@ -189,10 +100,10 @@ abstract class ProjectDetailFragment : BaseFragment() {
} }
private fun initCreateStation() = private fun initCreateStation() =
mBinding.createStationBtn.setOnClickListener { v -> clickCreateStation() } mBinding.ilBtn.btnOne.setOnClickListener { v -> clickCreateStation() }
private fun initGoMeasurePage() { private fun initGoMeasurePage() {
mBinding.ivGoMeasurePage.setOnClickListener { view -> mBinding.ilBtn.btnTwo.setOnClickListener { view ->
lifecycleScope.launch(Dispatchers.IO) { lifecycleScope.launch(Dispatchers.IO) {
val msg = saveDefaultProjectAndSoOn() val msg = saveDefaultProjectAndSoOn()
if (!msg.isNullOrEmpty()) { if (!msg.isNullOrEmpty()) {
@ -200,10 +111,10 @@ abstract class ProjectDetailFragment : BaseFragment() {
return@launch return@launch
} }
EventBus.getDefault().post( EventBus.getDefault().post(
SwitchPageEvent<Any?>( SwitchPageEvent<Any?>(
SwitchPageEvent.TYPE_SWITCH_TO_MEASURE_PAGE_AND_DATA, SwitchPageEvent.TYPE_SWITCH_TO_MEASURE_PAGE_AND_DATA,
null null
) )
) )
val activity = activity val activity = activity
activity?.finish() activity?.finish()
@ -214,8 +125,8 @@ abstract class ProjectDetailFragment : BaseFragment() {
private fun initUnKnownPoint() { private fun initUnKnownPoint() {
mBinding.unknownPointList.setOnClickListener { view -> mBinding.unknownPointList.setOnClickListener { view ->
PointListFragment.go2UnknownPointList( PointListFragment.go2UnknownPointList(
projectId, projectId,
context context
) )
} }
} }
@ -223,8 +134,8 @@ abstract class ProjectDetailFragment : BaseFragment() {
private fun initKnownPoint() { private fun initKnownPoint() {
mBinding.knownPointList.setOnClickListener { view -> mBinding.knownPointList.setOnClickListener { view ->
PointListFragment.go2KnownPointList( PointListFragment.go2KnownPointList(
projectId, projectId,
context context
) )
} }
} }
@ -232,59 +143,6 @@ abstract class ProjectDetailFragment : BaseFragment() {
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) { override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
inflater.inflate(R.menu.project_detail_fragment_menu, menu) inflater.inflate(R.menu.project_detail_fragment_menu, menu)
super.onCreateOptionsMenu(menu, inflater) super.onCreateOptionsMenu(menu, inflater)
ThreadPoolUtil.execute {
if (!ConfigConstants.isGuideCompleted(
ConfigConstants.KEY_GUIDE_PROJECT_TOLERANCE,
configDataSource
)
) {
ThreadPoolUtil.executeInMain {
editGuides.start(
KEY_GUIDE_INDEX_SURVEYOR_TOLERANCE
)
}
} else if (!ConfigConstants.isGuideCompleted(
ConfigConstants.KEY_GUIDE_PROJECT_KNOWN_POINT,
configDataSource
)
) {
ThreadPoolUtil.executeInMain {
editGuides.start(
KEY_GUIDE_INDEX_KNOWN_POINTS
)
}
} else if (!ConfigConstants.isGuideCompleted(
ConfigConstants.KEY_GUIDE_PROJECT_UNKNOWN_POINT,
configDataSource
)
) {
ThreadPoolUtil.executeInMain {
editGuides.start(
KEY_GUIDE_INDEX_UN_KNOWN_POINTS
)
}
} else if (!ConfigConstants.isGuideCompleted(
ConfigConstants.KEY_GUIDE_PROJECT_SURVEYOR_CYCLE,
configDataSource
)
) {
ThreadPoolUtil.executeInMain {
editGuides.start(
KEY_GUIDE_INDEX_SURVEYOR_CYCLE
)
}
} else if (!ConfigConstants.isGuideCompleted(
ConfigConstants.KEY_GUIDE_PROJECT_CRAETE_STATION,
configDataSource
)
) {
ThreadPoolUtil.executeInMain {
editGuides.start(
KEY_GUIDE_INDEX_CREATE_STATION
)
}
}
}
} }
override fun onOptionsItemSelected(item: MenuItem): Boolean { override fun onOptionsItemSelected(item: MenuItem): Boolean {

@ -4,13 +4,13 @@ import android.os.Bundle
import android.view.View import android.view.View
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.fragment.app.viewModels import androidx.fragment.app.viewModels
import com.bingce.controlnetwork.fragment.heighttraverse.viewmodel.HeightCreateOrEditVm
import com.bingce.controlnetwork.fragment.projectdetail.content.RouteFragment
import com.bingce.controlapphelper.datasource.database.SurveyorDataBase import com.bingce.controlapphelper.datasource.database.SurveyorDataBase
import com.bingce.controlapphelper.datasource.database.SurveyorDatabaseFactory import com.bingce.controlapphelper.datasource.database.SurveyorDatabaseFactory
import com.bingce.controlapphelper.datasource.database.config.ConfigConstants import com.bingce.controlapphelper.datasource.database.config.ConfigConstants
import com.bingce.controlapphelper.util.Tools import com.bingce.controlapphelper.util.Tools
import com.bingce.controlnetwork.R import com.bingce.controlnetwork.R
import com.bingce.controlnetwork.fragment.heighttraverse.viewmodel.HeightCreateOrEditVm
import com.bingce.controlnetwork.fragment.projectdetail.content.RouteFragment
class ProjectDetailHeightTraverseFragment : ProjectDetailFragment() { class ProjectDetailHeightTraverseFragment : ProjectDetailFragment() {
@ -61,43 +61,11 @@ class ProjectDetailHeightTraverseFragment : ProjectDetailFragment() {
) )
} }
override fun getGuideMsgAndDesc(position: Int): Array<String?> {
val array = arrayOfNulls<String>(2)
when (position) {
KEY_GUIDE_INDEX_SURVEYOR_TOLERANCE -> {
array[0] = getString(R.string.guide_modify_project_tolerance)
array[1] = getString(R.string.project_tolerance_apply_all_station)
}
KEY_GUIDE_INDEX_KNOWN_POINTS -> {
array[0] = getString(R.string.guide_edit_known_point)
array[1] = null
}
KEY_GUIDE_INDEX_UN_KNOWN_POINTS -> {
array[0] = getString(R.string.guide_edit_unknown_point)
array[1] = null
}
KEY_GUIDE_INDEX_SURVEYOR_CYCLE -> {
array[0] = getString(R.string.route_list)
array[1] = null
}
KEY_GUIDE_INDEX_CREATE_STATION -> {
array[0] = getString(R.string.create_new_route)
array[1] = null
}
}
return array
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
mBinding.tvCycleTitle.text = getString(R.string.route) mBinding.tvCycleTitle.text = getString(R.string.route)
mBinding.createStationBtn.text = getString(R.string.create_new_route) mBinding.ilBtn.btnOne.text = getString(R.string.create_new_route)
mBinding.ivCycleArrow.visibility = View.GONE mBinding.ivCycleArrow.visibility = View.GONE
} }
} }

@ -110,37 +110,6 @@ class ProjectDetailTriangleFragment : ProjectDetailFragment() {
} }
} }
override fun getGuideMsgAndDesc(position: Int): Array<String?> {
val array = arrayOfNulls<String>(2)
when (position) {
KEY_GUIDE_INDEX_SURVEYOR_TOLERANCE -> {
array[0] = getString(R.string.guide_modify_project_tolerance)
array[1] = getString(R.string.guide_modify_project_tolerance_describe)
}
KEY_GUIDE_INDEX_KNOWN_POINTS -> {
array[0] = getString(R.string.guide_edit_known_point)
array[1] = null
}
KEY_GUIDE_INDEX_UN_KNOWN_POINTS -> {
array[0] = getString(R.string.guide_edit_unknown_point)
array[1] = null
}
KEY_GUIDE_INDEX_SURVEYOR_CYCLE -> {
array[0] = getString(R.string.guide_switch_surveyor_cycle)
array[1] = null
}
KEY_GUIDE_INDEX_CREATE_STATION -> {
array[0] = getString(R.string.guide_create_new_station)
array[1] = null
}
}
return array
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
initListener() initListener()

@ -11,18 +11,18 @@ import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager import androidx.fragment.app.FragmentManager
import androidx.room.withTransaction import androidx.room.withTransaction
import blankj.utilcode.util.ToastUtils import blankj.utilcode.util.ToastUtils
import com.bingce.controlnetwork.fragment.AbstractFullScreenDialogFragment
import com.bingce.controlnetwork.fragment.ToleranceSelectFragment
import com.bingce.controlnetwork.ui.widget.dialog.LoadingUtilKt
import com.bingce.controlnetwork.util.DefaultNameUtil
import com.bingce.controlapphelper.datasource.database.ProjectType import com.bingce.controlapphelper.datasource.database.ProjectType
import com.bingce.controlapphelper.datasource.database.SurveyorDataBase import com.bingce.controlapphelper.datasource.database.SurveyorDataBase
import com.bingce.controlapphelper.datasource.database.SurveyorDatabaseFactory import com.bingce.controlapphelper.datasource.database.SurveyorDatabaseFactory
import com.bingce.controlapphelper.datasource.database.ToleranceTemplate
import com.bingce.controlapphelper.datasource.database.config.ConfigConstants import com.bingce.controlapphelper.datasource.database.config.ConfigConstants
import com.bingce.controlapphelper.datasource.database.project.ProjectRecord import com.bingce.controlapphelper.datasource.database.project.ProjectRecord
import com.bingce.controlapphelper.datasource.database.surveyorcycle.SurveyorPeriodRecord import com.bingce.controlapphelper.datasource.database.surveyorcycle.SurveyorPeriodRecord
import com.bingce.controlapphelper.datasource.database.tolerance.load.ToleranceLoadUtil
import com.bingce.controlnetwork.R import com.bingce.controlnetwork.R
import com.bingce.controlnetwork.fragment.AbstractFullScreenDialogFragment
import com.bingce.controlnetwork.fragment.ToleranceSelectFragment
import com.bingce.controlnetwork.ui.widget.dialog.LoadingUtilKt
import com.bingce.controlnetwork.util.DefaultNameUtil
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.MainScope import kotlinx.coroutines.MainScope
import kotlinx.coroutines.cancel import kotlinx.coroutines.cancel
@ -37,9 +37,6 @@ abstract class AbstractProjectEditFragment : AbstractFullScreenDialogFragment()
const val KEY_PROJECT_NAME = "___project___name___" const val KEY_PROJECT_NAME = "___project___name___"
const val KEY_TOLERANCE_ID = "___tolerance_id" const val KEY_TOLERANCE_ID = "___tolerance_id"
const val GUIDE_INDEX_PROJECT_NAME = 0
const val GUIDE_INDEX_PROJECT_TOLERANCE = 1
@JvmStatic @JvmStatic
fun editProject( fun editProject(
fragmentManager: FragmentManager, fragmentManager: FragmentManager,
@ -146,8 +143,9 @@ abstract class AbstractProjectEditFragment : AbstractFullScreenDialogFragment()
.getRecordSync(toleranceId) .getRecordSync(toleranceId)
} }
toleranceDetailRecord?.let { toleranceDetailRecord?.let {
val groupRecord = ToleranceTemplate.groupOf(it.groupId) val tjToleranceLoad = ToleranceLoadUtil.getTriangleToleranceLoad()
val levelRecord = ToleranceTemplate.levelOf(it.levelId) val groupRecord = tjToleranceLoad.groupOf(it.groupId)
val levelRecord = tjToleranceLoad.levelOf(it.levelId)
val lineName = if (levelRecord?.name == null) "" else "-${levelRecord.name}" val lineName = if (levelRecord?.name == null) "" else "-${levelRecord.name}"
@ -160,12 +158,24 @@ abstract class AbstractProjectEditFragment : AbstractFullScreenDialogFragment()
} }
protected open fun initData() { protected open fun initData() {
updateToleranceData(getToleranceId()) initToleranceData()
//设置项目名称 //设置项目名称
setProjectName(getProjectName() ?: DefaultNameUtil.getDefaultProjectName()) setProjectName(getProjectName() ?: "")//DefaultNameUtil.getDefaultProjectName()
updateShowSlopData(getProjectId()) updateShowSlopData(getProjectId())
} }
/**
* 初始化限差数据
*/
private fun initToleranceData() {
val projectType = getProjectType()
val newDefaultTolerance = ToleranceLoadUtil.getTriangleToleranceLoad().getNewDefaultTolerance(projectType)
val toleranceId =
getToleranceId() ?: newDefaultTolerance?.id
updateToleranceData(toleranceId)
}
private fun updateShowSlopData(projectId: String?) { private fun updateShowSlopData(projectId: String?) {
if (projectId == null) { if (projectId == null) {
val checked = when (getProjectType()) { val checked = when (getProjectType()) {

@ -4,16 +4,9 @@ import android.os.Bundle
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import com.bingce.controlnetwork.guide.GuideSequence
import com.bingce.controlnetwork.guide.ITapTargetProvider
import com.bingce.controlapphelper.datasource.database.SurveyorDatabaseFactory import com.bingce.controlapphelper.datasource.database.SurveyorDatabaseFactory
import com.bingce.controlapphelper.datasource.database.config.ConfigConstants
import com.bingce.controlapphelper.datasource.database.config.IConfigDataSource import com.bingce.controlapphelper.datasource.database.config.IConfigDataSource
import com.bingce.controlnetwork.R
import com.bingce.controlnetwork.databinding.FragmentProjectEditTriangleBinding import com.bingce.controlnetwork.databinding.FragmentProjectEditTriangleBinding
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
/** /**
* 三角测量和联系测量共用 * 三角测量和联系测量共用
@ -31,39 +24,11 @@ class ProjectEditTriangleFragment : AbstractProjectEditFragment() {
val configDataSource: IConfigDataSource = SurveyorDatabaseFactory.instance.configDataSource val configDataSource: IConfigDataSource = SurveyorDatabaseFactory.instance.configDataSource
private val createProjectGuide = GuideSequence(GUIDE_INDEX_PROJECT_TOLERANCE + 1, override fun createContentView(
object : GuideSequence.IDelegate { inflater: LayoutInflater,
override fun show(index: Int, provider: ITapTargetProvider) { container: ViewGroup?,
if (index == GUIDE_INDEX_PROJECT_NAME) { savedInstanceState: Bundle?
provider.show4View( ): View {
dialog,
view?.findViewById(R.id.editor),
getString(R.string.guide_input_project_name), getString(R.string.guide_project_name_can_same)
)
} else if (index == GUIDE_INDEX_PROJECT_TOLERANCE) {
provider.show4View(
dialog,
view?.findViewById(R.id.select_tolerance),
getString(R.string.guide_select_tolerance_of_project), null
)
}
}
override fun dismiss(index: Int) {
if (GUIDE_INDEX_PROJECT_NAME == index) {
ConfigConstants.markGuideCompleted(
ConfigConstants.KEY_GUIDE_INPUT_PROJECT_NAME, configDataSource
)
} else if (GUIDE_INDEX_PROJECT_TOLERANCE == index) {
ConfigConstants.markGuideCompleted(
ConfigConstants.KEY_GUIDE_SELECT_TOLERANCE, configDataSource
)
}
}
})
override fun createContentView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
_binding = FragmentProjectEditTriangleBinding.inflate(inflater, container, false) _binding = FragmentProjectEditTriangleBinding.inflate(inflater, container, false)
return mBinding.root return mBinding.root
} }
@ -72,24 +37,6 @@ class ProjectEditTriangleFragment : AbstractProjectEditFragment() {
return true return true
} }
override fun onResume() {
super.onResume()
dealTyroGuide()
}
private fun dealTyroGuide() {
scope.launch {
val index = withContext(Dispatchers.IO) {
if (!ConfigConstants.isGuideCompleted(ConfigConstants.KEY_GUIDE_INPUT_PROJECT_NAME, configDataSource)) {
0
} else if (!ConfigConstants.isGuideCompleted(ConfigConstants.KEY_GUIDE_SELECT_TOLERANCE, configDataSource)) {
1
} else -1
}
createProjectGuide.start(index)
}
}
override fun onDestroyView() { override fun onDestroyView() {
super.onDestroyView() super.onDestroyView()
_binding = null _binding = null

@ -11,18 +11,16 @@ import androidx.appcompat.widget.SwitchCompat;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import com.bingce.controlapphelper.util.Tools; import com.bingce.controlapphelper.util.Tools;
import org.jetbrains.annotations.NotNull;
import java.util.List;
import com.bingce.controlnetwork.R; import com.bingce.controlnetwork.R;
import com.bingce.controlnetwork.fragment.TipsFragment;
import com.bingce.controlnetwork.fragment.TipsWith2OptionFragment;
import com.bingce.controlnetwork.activity.fragmentcontainer.IOnBackFilter; import com.bingce.controlnetwork.activity.fragmentcontainer.IOnBackFilter;
import com.bingce.controlnetwork.fragment.TipsFragment; import com.bingce.controlnetwork.fragment.TipsFragment;
import com.bingce.controlnetwork.fragment.TipsWith2OptionFragment; import com.bingce.controlnetwork.fragment.TipsWith2OptionFragment;
import com.bingce.controlnetwork.fragment.base.BaseFragment; import com.bingce.controlnetwork.fragment.base.BaseFragment;
import com.bingce.controlnetwork.newui.widget.switchtext.SwitchWithText;
import org.jetbrains.annotations.NotNull;
import java.util.List;
public abstract class AbstractStationFragment extends BaseFragment implements IOnBackFilter { public abstract class AbstractStationFragment extends BaseFragment implements IOnBackFilter {
@ -80,9 +78,16 @@ public abstract class AbstractStationFragment extends BaseFragment implements IO
if (view == null) { if (view == null) {
return false; return false;
} }
SwitchCompat switchCompat = view.findViewById(id); View view1 = view.findViewById(id);
if (switchCompat != null) { if (view1 != null) {
return switchCompat.isChecked(); if (view1 instanceof SwitchWithText) {
SwitchWithText switchCompat = (SwitchWithText) view1;
return switchCompat.isChecked();
}
if (view1 instanceof SwitchCompat) {
SwitchCompat switchCompat = (SwitchCompat) view1;
return switchCompat.isChecked();
}
} }
return false; return false;
} }
@ -91,12 +96,11 @@ public abstract class AbstractStationFragment extends BaseFragment implements IO
return switchIsChecked(getView(), R.id.left_right_switch); return switchIsChecked(getView(), R.id.left_right_switch);
} }
protected void updateLeftRightMark(View view, boolean need) { protected void updateLeftRightMark(View view, boolean need) {
if (view == null) { if (view == null) {
return; return;
} }
SwitchCompat switchCompat = view.findViewById(R.id.left_right_switch); SwitchWithText switchCompat = view.findViewById(R.id.left_right_switch);
if (switchCompat != null) { if (switchCompat != null) {
switchCompat.setChecked(need); switchCompat.setChecked(need);
} }

@ -5,9 +5,9 @@ import android.os.Bundle;
import android.view.Menu; import android.view.Menu;
import android.view.MenuInflater; import android.view.MenuInflater;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.appcompat.widget.SwitchCompat;
import com.bingce.controlapphelper.datasource.database.SurveyorDatabaseFactory; import com.bingce.controlapphelper.datasource.database.SurveyorDatabaseFactory;
import com.bingce.controlapphelper.datasource.database.point.IPointDataSource; import com.bingce.controlapphelper.datasource.database.point.IPointDataSource;
@ -21,6 +21,7 @@ import com.bingce.controlapphelper.model.StationDetailItem;
import com.bingce.controlapphelper.util.PointUtil; import com.bingce.controlapphelper.util.PointUtil;
import com.bingce.controlnetwork.R; import com.bingce.controlnetwork.R;
import com.bingce.controlnetwork.activity.fragmentcontainer.FragmentContainerActivity; import com.bingce.controlnetwork.activity.fragmentcontainer.FragmentContainerActivity;
import com.bingce.controlnetwork.newui.widget.switchtext.SwitchWithText;
import com.bingce.utils.ThreadPoolUtil; import com.bingce.utils.ThreadPoolUtil;
import java.util.Arrays; import java.util.Arrays;
@ -30,6 +31,8 @@ public class DefaultStationSetupFragment extends AbstractSingleStationPointListF
public static final String TAG = DefaultStationSetupFragment.class.getName(); public static final String TAG = DefaultStationSetupFragment.class.getName();
private MenuItem confirmItem; private MenuItem confirmItem;
private boolean lastConfirmEnable = false;
@Override @Override
protected int layoutRes() { protected int layoutRes() {
return R.layout.fragment_default_surveyor_station_setup_layout; return R.layout.fragment_default_surveyor_station_setup_layout;
@ -57,9 +60,8 @@ public class DefaultStationSetupFragment extends AbstractSingleStationPointListF
inflater.inflate(R.menu.menu_confirm, menu); inflater.inflate(R.menu.menu_confirm, menu);
confirmItem = menu.findItem(R.id.menu_confirm); confirmItem = menu.findItem(R.id.menu_confirm);
if (confirmItem != null) { if (confirmItem != null) {
confirmItem.setEnabled(false); confirmItem.setEnabled(lastConfirmEnable);
} }
super.onCreateOptionsMenu(menu, inflater);
} }
@Override @Override
@ -184,16 +186,19 @@ public class DefaultStationSetupFragment extends AbstractSingleStationPointListF
@Override @Override
protected void onItemChanged() { protected void onItemChanged() {
if (confirmItem != null) {//设置menuItem enable if (confirmItem != null) {//设置menuItem enable
confirmItem.setEnabled(isCurrentDataValidate()); boolean confirmEnable = isCurrentDataValidate();
confirmItem.setEnabled(confirmEnable);
lastConfirmEnable = confirmEnable;
} }
//检测左右角是否 //检测左右角是否
SwitchCompat leftAndRightSwitch = findViewById(R.id.left_right_switch); SwitchWithText leftAndRightSwitch = findViewById(R.id.left_right_switch);
if (leftAndRightSwitch != null) { if (leftAndRightSwitch != null) {
if (surveyorPointSize() == 2) { int pointSize = surveyorPointSize();
leftAndRightSwitch.setEnabled(true); if (pointSize == 2) {
leftAndRightSwitch.setVisibility(View.VISIBLE);
} else { } else {
leftAndRightSwitch.setEnabled(false);
leftAndRightSwitch.setChecked(false); leftAndRightSwitch.setChecked(false);
leftAndRightSwitch.setVisibility(View.GONE);
} }
} }
} }

@ -5,7 +5,6 @@ import android.view.View;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.appcompat.widget.SwitchCompat;
import com.bingce.controlapphelper.datasource.database.SurveyorDatabaseFactory; import com.bingce.controlapphelper.datasource.database.SurveyorDatabaseFactory;
import com.bingce.controlapphelper.datasource.database.line.LineRecord; import com.bingce.controlapphelper.datasource.database.line.LineRecord;
@ -16,6 +15,7 @@ import com.bingce.controlapphelper.util.Tools;
import com.bingce.controlnetwork.R; import com.bingce.controlnetwork.R;
import com.bingce.controlnetwork.fragment.StringInputFragment; import com.bingce.controlnetwork.fragment.StringInputFragment;
import com.bingce.controlnetwork.fragment.station.AbstractStationFragment; import com.bingce.controlnetwork.fragment.station.AbstractStationFragment;
import com.bingce.controlnetwork.newui.widget.switchtext.SwitchWithText;
import com.bingce.controlnetwork.util.SurveyorStationUtil; import com.bingce.controlnetwork.util.SurveyorStationUtil;
import com.bingce.utils.IOnListGetCallback; import com.bingce.utils.IOnListGetCallback;
import com.bingce.utils.ThreadPoolUtil; import com.bingce.utils.ThreadPoolUtil;
@ -39,11 +39,6 @@ public abstract class AbstractLineStationSetupFragment extends AbstractStationFr
@Override @Override
public void onViewCreated(@NonNull @NotNull View view, @Nullable Bundle savedInstanceState) { public void onViewCreated(@NonNull @NotNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState); super.onViewCreated(view, savedInstanceState);
//显示左右角开关
// SwitchCompat switchCompat = view.findViewById(R.id.left_right_switch);
// if (switchCompat != null) {
// switchCompat.setEnabled(true);
// }
setLeftRightEnable(initLeftRightMeasure()); setLeftRightEnable(initLeftRightMeasure());
//读取projectRecord //读取projectRecord
ThreadPoolUtil.execute(() -> { ThreadPoolUtil.execute(() -> {
@ -63,7 +58,7 @@ public abstract class AbstractLineStationSetupFragment extends AbstractStationFr
//显示左右角开关 //显示左右角开关
View view = getView(); View view = getView();
if (view != null) { if (view != null) {
SwitchCompat switchCompat = view.findViewById(R.id.left_right_switch); SwitchWithText switchCompat = view.findViewById(R.id.left_right_switch);
if (switchCompat != null) { if (switchCompat != null) {
switchCompat.setEnabled(isEnable); switchCompat.setEnabled(isEnable);
} }

@ -6,7 +6,6 @@ import android.view.View;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.appcompat.widget.SwitchCompat;
import com.bingce.controlapphelper.datasource.database.SurveyorDatabaseFactory; import com.bingce.controlapphelper.datasource.database.SurveyorDatabaseFactory;
import com.bingce.controlapphelper.datasource.database.line.ILineRecordDataSource; import com.bingce.controlapphelper.datasource.database.line.ILineRecordDataSource;
@ -43,12 +42,10 @@ public class LineStationCloseSetupFragment extends LineStationSingleSetupFragmen
@Override @Override
public void onViewCreated(@NonNull @NotNull View view, @Nullable @org.jetbrains.annotations.Nullable Bundle savedInstanceState) { public void onViewCreated(@NonNull @NotNull View view, @Nullable @org.jetbrains.annotations.Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState); super.onViewCreated(view, savedInstanceState);
SwitchCompat setOnce = view.findViewById(R.id.start_point_setup_once); View leftRightSwitch = view.findViewById(R.id.left_right_switch);
if (setOnce == null) { if (leftRightSwitch != null) {
return; leftRightSwitch.setVisibility(View.GONE);
} }
setOnce.setVisibility(View.VISIBLE);
setOnce.setChecked(true);
} }
@Override @Override

@ -17,16 +17,16 @@ import com.bingce.controlapphelper.datasource.database.surveyorstation.ISurveyor
import com.bingce.controlapphelper.datasource.database.surveyorstation.SurveyorStationRecord; import com.bingce.controlapphelper.datasource.database.surveyorstation.SurveyorStationRecord;
import com.bingce.controlapphelper.model.BundleConstants; import com.bingce.controlapphelper.model.BundleConstants;
import com.bingce.controlapphelper.util.StationUtil; import com.bingce.controlapphelper.util.StationUtil;
import com.bingce.controlnetwork.R;
import com.bingce.controlnetwork.activity.fragmentcontainer.FragmentContainerActivity; import com.bingce.controlnetwork.activity.fragmentcontainer.FragmentContainerActivity;
import com.bingce.controlnetwork.databinding.FragmentSurveyorStationDetailOrEditLayoutBinding;
import com.bingce.controlnetwork.fragment.base.BaseFragment; import com.bingce.controlnetwork.fragment.base.BaseFragment;
import com.bingce.controlnetwork.fragment.station.defaultstation.ComponentSingleStationPointListFragment;
import com.bingce.controlnetwork.newui.widget.switchtext.SwitchWithText;
import com.bingce.utils.ThreadPoolUtil; import com.bingce.utils.ThreadPoolUtil;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import com.bingce.controlnetwork.R;
import com.bingce.controlnetwork.databinding.FragmentSurveyorStationDetailOrEditLayoutBinding;
import com.bingce.controlnetwork.fragment.station.defaultstation.ComponentSingleStationPointListFragment;
/** /**
* 测站详情--包含编辑测点站点功能,可能是多测回测角也可能是导线测站中某站 * 测站详情--包含编辑测点站点功能,可能是多测回测角也可能是导线测站中某站
*/ */
@ -39,6 +39,7 @@ public class SingleStationDetailAndEditFragment extends BaseFragment {
private FragmentSurveyorStationDetailOrEditLayoutBinding mBinding; private FragmentSurveyorStationDetailOrEditLayoutBinding mBinding;
private String stationId; private String stationId;
private boolean isHasDataForStation;//测站是否有测量记录 private boolean isHasDataForStation;//测站是否有测量记录
private SwitchWithText leftRightSwitch;
@Override @Override
@ -60,6 +61,8 @@ public class SingleStationDetailAndEditFragment extends BaseFragment {
return; return;
} }
leftRightSwitch = view.findViewById(R.id.left_right_switch);
stationDetailViewModel = new ViewModelProvider(requireActivity()).get(StationDetailViewModel.class); stationDetailViewModel = new ViewModelProvider(requireActivity()).get(StationDetailViewModel.class);
//创建显示点列表的fragment //创建显示点列表的fragment
@ -80,10 +83,9 @@ public class SingleStationDetailAndEditFragment extends BaseFragment {
mBinding.autoCloseSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> updateStationAutoClose(isChecked)); mBinding.autoCloseSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> updateStationAutoClose(isChecked));
mBinding.leftRightSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> updateStationLeftRightSurveyor(isChecked)); leftRightSwitch.setOnCheckChangeListener(this::updateStationLeftRightSurveyor);
} }
private void initData() { private void initData() {
ThreadPoolUtil.execute(() -> { ThreadPoolUtil.execute(() -> {
SurveyorStationRecord stationRecord = SurveyorDatabaseFactory.instance.getSurveyorStation().getRecordSync(stationId); SurveyorStationRecord stationRecord = SurveyorDatabaseFactory.instance.getSurveyorStation().getRecordSync(stationId);
@ -102,12 +104,12 @@ public class SingleStationDetailAndEditFragment extends BaseFragment {
} }
private void refreshViewCheckEnable(int surveyorPointSize) { private void refreshViewCheckEnable(int surveyorPointSize) {
if (isVisiable(mBinding.leftRightSwitch)) { if (isVisiable(leftRightSwitch)) {
boolean canLeftOrRightSurveyor = StationUtil.isCanLeftOrRightSurveyor(surveyorPointSize); boolean canLeftOrRightSurveyor = StationUtil.isCanLeftOrRightSurveyor(surveyorPointSize);
boolean checkNew = canLeftOrRightSurveyor && mBinding.leftRightSwitch.isChecked(); boolean checkNew = canLeftOrRightSurveyor && leftRightSwitch.isChecked();
mBinding.leftRightSwitch.setChecked(checkNew); leftRightSwitch.setChecked(checkNew);
mBinding.leftRightSwitch.setEnabled(canLeftOrRightSurveyor); leftRightSwitch.setEnabled(canLeftOrRightSurveyor);
} }
if (isVisiable(mBinding.autoCloseSwitch)) { if (isVisiable(mBinding.autoCloseSwitch)) {
boolean canZeroSurveyor = StationUtil.isCanZeroSurveyor(surveyorPointSize); boolean canZeroSurveyor = StationUtil.isCanZeroSurveyor(surveyorPointSize);
@ -136,10 +138,9 @@ public class SingleStationDetailAndEditFragment extends BaseFragment {
runOnUI(() -> { runOnUI(() -> {
if (!isTriangleProject(projectRecord)) { if (!isTriangleProject(projectRecord)) {
mBinding.autoCloseSwitch.setVisibility(View.GONE); mBinding.autoCloseSwitch.setVisibility(View.GONE);
mBinding.leftRightSwitch.setVisibility(View.GONE); leftRightSwitch.setVisibility(View.GONE);
mBinding.tips.setText(R.string.tips_forbid_edit_line_station); mBinding.tips.setText(R.string.tips_forbid_edit_line_station);
} else { } else {
if (stationRecord.isLineStation()) { if (stationRecord.isLineStation()) {
mBinding.tips.setText(R.string.tips_forbid_edit_line_station); mBinding.tips.setText(R.string.tips_forbid_edit_line_station);
} else { } else {
@ -149,7 +150,7 @@ public class SingleStationDetailAndEditFragment extends BaseFragment {
} }
} }
mBinding.leftRightSwitch.setChecked(stationRecord.leftAndRightSurveyor); leftRightSwitch.setChecked(stationRecord.leftAndRightSurveyor);
mBinding.autoCloseSwitch.setChecked(stationRecord.autoClose); mBinding.autoCloseSwitch.setChecked(stationRecord.autoClose);
refreshViewCheckEnable(stationRecord.items.size() - 1); refreshViewCheckEnable(stationRecord.items.size() - 1);

@ -16,6 +16,7 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import com.bingce.controlapphelper.datasource.database.ProjectType;
import com.bingce.controlapphelper.datasource.database.SurveyorDatabaseFactory; import com.bingce.controlapphelper.datasource.database.SurveyorDatabaseFactory;
import com.bingce.controlapphelper.datasource.database.config.ConfigConstants; import com.bingce.controlapphelper.datasource.database.config.ConfigConstants;
import com.bingce.controlapphelper.datasource.database.config.ConfigRecord; import com.bingce.controlapphelper.datasource.database.config.ConfigRecord;
@ -29,6 +30,7 @@ import com.bingce.controlapphelper.datasource.database.surveyorstation.model.Sur
import com.bingce.controlapphelper.util.HideKeyUtil; import com.bingce.controlapphelper.util.HideKeyUtil;
import com.bingce.controlapphelper.util.StationUtil; import com.bingce.controlapphelper.util.StationUtil;
import com.bingce.controlapphelper.util.Tools; import com.bingce.controlapphelper.util.Tools;
import com.bingce.controlnetwork.R;
import com.bingce.controlnetwork.activity.fragmentcontainer.FragmentContainerActivity; import com.bingce.controlnetwork.activity.fragmentcontainer.FragmentContainerActivity;
import com.bingce.controlnetwork.adapter.BaseAdapter; import com.bingce.controlnetwork.adapter.BaseAdapter;
import com.bingce.controlnetwork.adapter.SpinnerAdapter; import com.bingce.controlnetwork.adapter.SpinnerAdapter;
@ -42,11 +44,6 @@ import java.util.List;
import blankj.utilcode.util.ToastUtils; import blankj.utilcode.util.ToastUtils;
import com.bingce.controlnetwork.R;
import com.bingce.controlnetwork.activity.fragmentcontainer.FragmentContainerActivity;
import com.bingce.controlnetwork.adapter.BaseAdapter;
import com.bingce.controlnetwork.adapter.SpinnerAdapter;
/** /**
* 仪器棱镜设置 * 仪器棱镜设置
*/ */
@ -134,9 +131,11 @@ public class StationSettingsFragment extends BaseStationSettingFragment {
if (surveyorStationRecord.getInstrumentHeight() == null) { if (surveyorStationRecord.getInstrumentHeight() == null) {
surveyorStationRecord.setInstrumentHeight("0"); surveyorStationRecord.setInstrumentHeight("0");
} }
//是否是联系测量
boolean isConnection = ProjectType.isConnection(surveyorStationRecord.projectType);
//添加point title //添加point title
items.add(new _PointTitleItem()); items.add(new _PointTitleItem(isConnection));
//添加点坐标 //添加点坐标
IPointDataSource pointDataSource = SurveyorDatabaseFactory.instance.getPointDataSource(); IPointDataSource pointDataSource = SurveyorDatabaseFactory.instance.getPointDataSource();
List<SurveyorPoint> stationItems = surveyorStationRecord.getItems(); List<SurveyorPoint> stationItems = surveyorStationRecord.getItems();
@ -164,7 +163,8 @@ public class StationSettingsFragment extends BaseStationSettingFragment {
pointRecord.getName(), pointRecord.getName(),
surveyorPoint, surveyorPoint,
prismRecords, prismRecords,
!stationHasRecord !stationHasRecord,
isConnection
)); ));
} }
} }
@ -249,14 +249,28 @@ public class StationSettingsFragment extends BaseStationSettingFragment {
} }
private static class _PointTitleItem extends _Item { private static class _PointTitleItem extends _Item {
_PointTitleItem() { private final boolean isConnection;//是否是联系测量
_PointTitleItem(boolean isConnection) {
super(_VH.TYPE_POINT_TITLE, null); super(_VH.TYPE_POINT_TITLE, null);
this.isConnection = isConnection;
} }
@Override @Override
String prepare2Save() { String prepare2Save() {
return null; return null;
} }
@Override
void attach(View itemView) {
super.attach(itemView);
TextView tvAloneDistanceTitle = itemView.findViewById(R.id.tvAloneDistanceTitle);
if (isConnection) {
tvAloneDistanceTitle.setVisibility(View.VISIBLE);
} else {
tvAloneDistanceTitle.setVisibility(View.INVISIBLE);
}
}
} }
private static class _1EditTextItem extends _Item { private static class _1EditTextItem extends _Item {
@ -328,16 +342,19 @@ public class StationSettingsFragment extends BaseStationSettingFragment {
private final SurveyorPoint surveyorPoint; private final SurveyorPoint surveyorPoint;
private final List<PrismRecord> prismRecords; private final List<PrismRecord> prismRecords;
private final boolean isCanSelectAloneDistance; private final boolean isCanSelectAloneDistance;
private final boolean isConnection;//是否是联系测量
private final List<String> prismTypes; private final List<String> prismTypes;
_2EditTextItem(String pointName, _2EditTextItem(String pointName,
SurveyorPoint surveyorPoint, SurveyorPoint surveyorPoint,
List<PrismRecord> prismRecords, List<PrismRecord> prismRecords,
boolean isCanSelectAloneDistance) { boolean isCanSelectAloneDistance,
boolean isConnection) {
super(_VH.TYPE_2_EDIT_TEXT, pointName); super(_VH.TYPE_2_EDIT_TEXT, pointName);
this.surveyorPoint = surveyorPoint; this.surveyorPoint = surveyorPoint;
this.prismRecords = prismRecords; this.prismRecords = prismRecords;
this.isCanSelectAloneDistance = isCanSelectAloneDistance; this.isCanSelectAloneDistance = isCanSelectAloneDistance;
this.isConnection = isConnection;
prismTypes = new ArrayList<>(); prismTypes = new ArrayList<>();
for (PrismRecord prismRecord : prismRecords) { for (PrismRecord prismRecord : prismRecords) {
prismTypes.add(prismRecord.getShowPrismTypeName()); prismTypes.add(prismRecord.getShowPrismTypeName());
@ -377,10 +394,15 @@ public class StationSettingsFragment extends BaseStationSettingFragment {
CheckBox checkBox = itemView.findViewById(R.id.checkBox); CheckBox checkBox = itemView.findViewById(R.id.checkBox);
if (checkBox != null) { if (checkBox != null) {
checkBox.setEnabled(isCanSelectAloneDistance); if (isConnection) {
checkBox.setOnCheckedChangeListener((compoundButton, checked) -> { checkBox.setVisibility(View.VISIBLE);
surveyorPoint.setAloneDistance(checked); checkBox.setEnabled(isCanSelectAloneDistance);
}); checkBox.setOnCheckedChangeListener((compoundButton, checked) -> {
surveyorPoint.setAloneDistance(checked);
});
} else {
checkBox.setVisibility(View.INVISIBLE);
}
} }
} }

@ -39,6 +39,7 @@ import com.bingce.controlnetwork.fragment.ComponentStationSurveyorDataListFragme
import com.bingce.controlnetwork.fragment.SurveyorSettingsFragment; import com.bingce.controlnetwork.fragment.SurveyorSettingsFragment;
import com.bingce.controlnetwork.fragment.base.BaseFragment; import com.bingce.controlnetwork.fragment.base.BaseFragment;
import com.bingce.controlnetwork.fragment.stationsetting.StationSettingsFragment; import com.bingce.controlnetwork.fragment.stationsetting.StationSettingsFragment;
import com.bingce.controlnetwork.newui.stationsetting.StationSettingsActivity;
import com.bingce.controlnetwork.surveyor.surveyor.TestDataSelectFragment; import com.bingce.controlnetwork.surveyor.surveyor.TestDataSelectFragment;
import com.bingce.utils.ThreadPoolUtil; import com.bingce.utils.ThreadPoolUtil;
import com.github.razir.progressbutton.DrawableButtonExtensionsKt; import com.github.razir.progressbutton.DrawableButtonExtensionsKt;
@ -61,22 +62,6 @@ public class StationSurveyorFragment extends BaseFragment {
private SurveyorStationRecord surveyorStationRecord; private SurveyorStationRecord surveyorStationRecord;
private int cycleIndex = 0; private int cycleIndex = 0;
public StationSurveyorFragment() {
super();
}
@Override
public void onStart() {
super.onStart();
EventBus.getDefault().register(this);
}
@Override
public void onStop() {
super.onStop();
EventBus.getDefault().unregister(this);
}
@Subscribe(threadMode = ThreadMode.MAIN) @Subscribe(threadMode = ThreadMode.MAIN)
public void onRefreshGoBack(RefreshGoBackButton event) { public void onRefreshGoBack(RefreshGoBackButton event) {
if (goBack != null) { if (goBack != null) {
@ -133,7 +118,6 @@ public class StationSurveyorFragment extends BaseFragment {
@Override @Override
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
ThreadPoolUtil.execute(() -> MethodCheckSetting.checkStationSettings(stationId(), fragment, this::runOnUI));
//测量界面保持常亮 //测量界面保持常亮
if (getActivity() != null) { if (getActivity() != null) {
getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
@ -149,11 +133,19 @@ public class StationSurveyorFragment extends BaseFragment {
} }
} }
@Override
public void onDestroyView() {
super.onDestroyView();
EventBus.getDefault().unregister(this);
}
@Nullable @Nullable
@Override @Override
public View onCreateView(@NonNull LayoutInflater inflater, public View onCreateView(@NonNull LayoutInflater inflater,
@Nullable ViewGroup container, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) { @Nullable Bundle savedInstanceState) {
EventBus.getDefault().register(this);
View view = inflater.inflate(R.layout.fragment_project_surveyor_station_detail_layout, View view = inflater.inflate(R.layout.fragment_project_surveyor_station_detail_layout,
container, container,
false); false);
@ -187,7 +179,7 @@ public class StationSurveyorFragment extends BaseFragment {
.getSurveyorStation() .getSurveyorStation()
.getRecordSync(stationId()); .getRecordSync(stationId());
//监听当前测回切换 //监听当前测回切换
monitorCurrentCycle(view); initObserver(view);
//监听数据变化 //监听数据变化
ToleranceDetailRecord toleranceRecord = getTolerance(surveyorStationRecord); ToleranceDetailRecord toleranceRecord = getTolerance(surveyorStationRecord);
if (toleranceRecord == null) { if (toleranceRecord == null) {
@ -229,6 +221,23 @@ public class StationSurveyorFragment extends BaseFragment {
return view; return view;
} }
private void initObserver(View view) {
runOnUI(() -> {
monitorCurrentCycle(view);
//监听测站变化
SurveyorDatabaseFactory
.instance
.getSurveyorStation()
.getLiveDataRecord(stationId())
.observe(getViewLifecycleOwner(),
stationRecord -> checkStationSettings());
});
}
private void checkStationSettings() {
ThreadPoolUtil.execute(() -> MethodCheckSetting.checkStationSettings(stationId(), fragment, this::runOnUI));
}
@Override @Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState); super.onViewCreated(view, savedInstanceState);
@ -236,28 +245,25 @@ public class StationSurveyorFragment extends BaseFragment {
} }
@WorkerThread
private void monitorCurrentCycle(View view) { private void monitorCurrentCycle(View view) {
if (getActivity() != null) { SurveyorDatabaseFactory
getActivity().runOnUiThread(() -> SurveyorDatabaseFactory .instance
.instance .getScheduleDataSource()
.getScheduleDataSource() .findSchedule(SurveyorScheduleConstants.getCurrentCycleKey(stationId(), null))
.findSchedule(SurveyorScheduleConstants.getCurrentCycleKey(stationId(), null)) .observe(getViewLifecycleOwner(), record -> {
.observe(getViewLifecycleOwner(), record -> { TextView circleText = view.findViewById(R.id.circle_text);
TextView circleText = view.findViewById(R.id.circle_text); //测回发生变化的时候,更新相应ui
//测回发生变化的时候,更新相应ui int cycleIndex = DigitalUtil.valueOfIntString(record == null ? "0" : record.getStatue(), 0);
int cycleIndex = DigitalUtil.valueOfIntString(record == null ? "0" : record.getStatue(), 0); //更新测回名称
//更新测回名称 if (circleText != null) {
if (circleText != null) { boolean showLeftOrRight = true;
boolean showLeftOrRight = true; if (surveyorStationRecord != null) {
if (surveyorStationRecord != null) { showLeftOrRight = surveyorStationRecord.leftAndRightSurveyor;
showLeftOrRight = surveyorStationRecord.leftAndRightSurveyor;
}
circleText.setText(SurveyorCycleUtil.cycleName(cycleIndex, showLeftOrRight));
} }
StationSurveyorFragment.this.cycleIndex = cycleIndex; circleText.setText(SurveyorCycleUtil.cycleName(cycleIndex, showLeftOrRight));
})); }
} StationSurveyorFragment.this.cycleIndex = cycleIndex;
});
} }
private static void setSurveyorClick(View rootView, int id, Runnable runnable) { private static void setSurveyorClick(View rootView, int id, Runnable runnable) {
@ -289,40 +295,39 @@ public class StationSurveyorFragment extends BaseFragment {
} else { } else {
inflater.inflate(R.menu.menu_surveyor_station_record_data_edit_release, menu); inflater.inflate(R.menu.menu_surveyor_station_record_data_edit_release, menu);
} }
MenuItem stationCheck = menu.findItem(R.id.menu_item_station_check); // MenuItem stationCheck = menu.findItem(R.id.menu_item_station_check);
MenuItem stationAdjust = menu.findItem(R.id.menu_item_station_adjust); // MenuItem stationAdjust = menu.findItem(R.id.menu_item_station_adjust);
goBack = menu.findItem(R.id.menu_item_go_back); goBack = menu.findItem(R.id.menu_item_go_back);
SurveyorDatabaseFactory // SurveyorDatabaseFactory
.instance // .instance
.getScheduleDataSource() // .getScheduleDataSource()
.findSchedule(SurveyorScheduleConstants.getAllCycleScheduleKey(stationId(), null)) // .findSchedule(SurveyorScheduleConstants.getAllCycleScheduleKey(stationId(), null))
.observe(getViewLifecycleOwner(), surveyorScheduleRecord -> { // .observe(getViewLifecycleOwner(), surveyorScheduleRecord -> {
boolean checkStatue = false; // boolean checkStatue = false;
boolean adjustStatue = false; // boolean adjustStatue = false;
if (surveyorScheduleRecord != null) { // if (surveyorScheduleRecord != null) {
String statue = surveyorScheduleRecord.getStatue(); // String statue = surveyorScheduleRecord.getStatue();
if (SurveyorScheduleConstants.STATUE_VALUE_CHECKED.equals(statue)) { // if (SurveyorScheduleConstants.STATUE_VALUE_CHECKED.equals(statue)) {
adjustStatue = true; // adjustStatue = true;
} else if (SurveyorScheduleConstants.STATUE_VALUE_COMPLETED.equals(statue)) { // } else if (SurveyorScheduleConstants.STATUE_VALUE_COMPLETED.equals(statue)) {
checkStatue = true; // checkStatue = true;
} else if (SurveyorScheduleConstants.STATUE_VALUE_NO_COMPLETED.equals(statue)) { // } else if (SurveyorScheduleConstants.STATUE_VALUE_NO_COMPLETED.equals(statue)) {
//重置提醒标识 // //重置提醒标识
String key = ConfigConstants.KEY_CONFIG_STATION_CHECK_REMINDED + stationId(); // String key = ConfigConstants.KEY_CONFIG_STATION_CHECK_REMINDED + stationId();
SurveyorDatabaseFactory // SurveyorDatabaseFactory
.instance // .instance
.getConfigDataSource() // .getConfigDataSource()
.set(key, ConfigConstants.VALUE_NO); // .set(key, ConfigConstants.VALUE_NO);
} // }
} // }
//更新菜单enable // //更新菜单enable
if (stationCheck != null) { // if (stationCheck != null) {
stationCheck.setEnabled(checkStatue); // stationCheck.setEnabled(checkStatue);
} // }
if (stationAdjust != null) { // if (stationAdjust != null) {
stationAdjust.setEnabled(adjustStatue); // stationAdjust.setEnabled(adjustStatue);
} // }
}); // });
super.onCreateOptionsMenu(menu, inflater);
} }
@Override @Override
@ -350,7 +355,8 @@ public class StationSurveyorFragment extends BaseFragment {
fragment.goBack(); fragment.goBack();
} else if (R.id.menu_item_station_environment_prism_settings == item.getItemId()) { } else if (R.id.menu_item_station_environment_prism_settings == item.getItemId()) {
//环境、棱镜设置 //环境、棱镜设置
StationSettingsFragment.start(getContext(), stationId()); StationSettingsActivity.start(requireContext(),stationId());
// StationSettingsFragment.start(getContext(), stationId());
} else if (R.id.menu_item_surveyor_settings == item.getItemId()) { } else if (R.id.menu_item_surveyor_settings == item.getItemId()) {
//测量设置 //测量设置
ThreadPoolUtil.execute(() -> { ThreadPoolUtil.execute(() -> {
@ -360,6 +366,9 @@ public class StationSurveyorFragment extends BaseFragment {
} else if (R.id.menu_item_station_adjust == item.getItemId()) { } else if (R.id.menu_item_station_adjust == item.getItemId()) {
//测站平差,平差检测 //测站平差,平差检测
fragment.stationAdjust(); fragment.stationAdjust();
} else if (R.id.menu_item_check_adjust == item.getItemId()) {
//检测平差
fragment.stationCheckAdjust();
} }
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
} }

@ -136,7 +136,7 @@ public class MeasureFragment extends MeasureBaseFragment {
currentFragment.deleteStationAllPeroidRecord(); currentFragment.deleteStationAllPeroidRecord();
} }
} else if (R.id.menu_item_station_check == item.getItemId() && currentFragment != null) { } else if (R.id.menu_item_station_check == item.getItemId() && currentFragment != null) {
//测站检测 //测站检测 被检测平差替代
stationCheckBefore(); stationCheckBefore();
} else if (R.id.menu_item_data_source == item.getItemId()) { } else if (R.id.menu_item_data_source == item.getItemId()) {
//数据源 debug使用 //数据源 debug使用
@ -153,8 +153,8 @@ public class MeasureFragment extends MeasureBaseFragment {
String name = StationUtil.getStationName(surveyorStationRecord); String name = StationUtil.getStationName(surveyorStationRecord);
runOnUI(() -> SurveyorSettingsFragment.start(getContext(), surveyorStationRecord.getId(), name)); runOnUI(() -> SurveyorSettingsFragment.start(getContext(), surveyorStationRecord.getId(), name));
}); });
} else if (R.id.menu_item_station_adjust == item.getItemId() && currentFragment != null) { } else if (R.id.menu_item_check_adjust == item.getItemId() && currentFragment != null) {
//测平差 //测平差
stationCheckAdjustBefore(); stationCheckAdjustBefore();
} }
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);

@ -302,7 +302,8 @@ public abstract class MeasureBaseFragment extends BaseFragment {
SurveyStateEvent.postIdle(position); SurveyStateEvent.postIdle(position);
} }
setCycleForSwitchPage(); //切换tab测回可能会变刷新当前fragment
refreshCycleAndFragment();
currentFragment.refreshGoBackBtnEnable(); currentFragment.refreshGoBackBtnEnable();
} }
@ -315,7 +316,7 @@ public abstract class MeasureBaseFragment extends BaseFragment {
}); });
} }
private void setCycleForSwitchPage() { private void refreshCycleAndFragment() {
ThreadPoolUtil.execute(() -> { ThreadPoolUtil.execute(() -> {
SurveyorScheduleRecord record = SurveyorDatabaseFactory SurveyorScheduleRecord record = SurveyorDatabaseFactory
.instance .instance

@ -14,6 +14,7 @@ import com.bingce.controlapphelper.util.Tools
import com.bingce.controlnetwork.R import com.bingce.controlnetwork.R
import com.bingce.controlnetwork.activity.fragmentcontainer.FragmentContainerActivity import com.bingce.controlnetwork.activity.fragmentcontainer.FragmentContainerActivity
import com.bingce.controlnetwork.fragment.SurveyorSettingsFragment import com.bingce.controlnetwork.fragment.SurveyorSettingsFragment
import com.bingce.controlnetwork.fragment.TipsWith2OptionFragment
import com.bingce.controlnetwork.fragment.stationsetting.StationSettingHeightTraverseFragment import com.bingce.controlnetwork.fragment.stationsetting.StationSettingHeightTraverseFragment
import com.bingce.controlnetwork.fragment.stationsurvey.base.MeasureBaseFragment import com.bingce.controlnetwork.fragment.stationsurvey.base.MeasureBaseFragment
import com.bingce.controlnetwork.surveyor.state.heighttraverse.__BaseState import com.bingce.controlnetwork.surveyor.state.heighttraverse.__BaseState
@ -40,10 +41,10 @@ class MeasureHeightTraverseFragment : MeasureBaseFragment() {
val bundle = Bundle() val bundle = Bundle()
bundle.putString(BundleConstants.KEY_SURVEYOR_STATION_ID, surveyorStationId) bundle.putString(BundleConstants.KEY_SURVEYOR_STATION_ID, surveyorStationId)
FragmentContainerActivity.start( FragmentContainerActivity.start(
context, context,
TAG, TAG,
surveyorStationName, surveyorStationName,
bundle bundle
) )
} }
@ -53,7 +54,6 @@ class MeasureHeightTraverseFragment : MeasureBaseFragment() {
fragment.arguments = args fragment.arguments = args
return fragment return fragment
} }
} }
override fun isShowSelectCycle(position: Int): Boolean { override fun isShowSelectCycle(position: Int): Boolean {
@ -74,33 +74,33 @@ class MeasureHeightTraverseFragment : MeasureBaseFragment() {
val stationId = stationId() val stationId = stationId()
val stationRecord = val stationRecord =
SurveyorDatabaseFactory.instance.surveyorStation.getRecordSync(stationId) SurveyorDatabaseFactory.instance.surveyorStation.getRecordSync(stationId)
val configRecord = val configRecord =
SurveyorDatabaseFactory.instance.getHeightTraverseConfigDataSource() SurveyorDatabaseFactory.instance.getHeightTraverseConfigDataSource()
.getRecordByProjectId(stationRecord.getProjectId()) .getRecordByProjectId(stationRecord.getProjectId())
if (configRecord?.stationLayout == StationLayout.SEPARATE) { if (configRecord?.stationLayout == StationLayout.SEPARATE) {
fragments.add( fragments.add(
MeasureHeightTraverseSubFragment.newInstance( MeasureHeightTraverseSubFragment.newInstance(
stationId, stationId,
POSITION_BACK_PAGE POSITION_BACK_PAGE
) )
) )
fragments.add( fragments.add(
MeasureHeightTraverseSubFragment.newInstance( MeasureHeightTraverseSubFragment.newInstance(
stationId, stationId,
POSITION_FRONT_PAGE POSITION_FRONT_PAGE
) )
) )
tabs.add(Tools.getString(R.string.rearview)) tabs.add(Tools.getString(R.string.rearview))
tabs.add(Tools.getString(R.string.forward_view)) tabs.add(Tools.getString(R.string.forward_view))
} else if (configRecord?.stationLayout == StationLayout.EVERY) { } else if (configRecord?.stationLayout == StationLayout.EVERY) {
fragments.add( fragments.add(
MeasureHeightTraverseSubFragment.newInstance( MeasureHeightTraverseSubFragment.newInstance(
stationId, stationId,
POSITION_FRONT_PAGE POSITION_FRONT_PAGE
) )
) )
tabs.add(Tools.getString(R.string.forward_view)) tabs.add(Tools.getString(R.string.forward_view))
} }
@ -116,33 +116,37 @@ class MeasureHeightTraverseFragment : MeasureBaseFragment() {
override fun getCurrentPageCycleKey(): String { override fun getCurrentPageCycleKey(): String {
return SurveyorScheduleConstants.getCurrentCycleKey( return SurveyorScheduleConstants.getCurrentCycleKey(
stationId(), stationId(),
__BaseState.getScheduleKey(mBinding.vp.currentItem) __BaseState.getScheduleKey(mBinding.vp.currentItem)
) )
} }
override fun getScheduleIdForAllCycle(): String { override fun getScheduleIdForAllCycle(): String {
val measureHeightTraverseSubFragment = currentFragment as MeasureHeightTraverseSubFragment val positionFragment = getCurrentMeasurePos()
val positionFragment = measureHeightTraverseSubFragment.backOrFrontPosition
return SurveyorScheduleConstants.getAllCycleScheduleKey( return SurveyorScheduleConstants.getAllCycleScheduleKey(
stationId(), stationId(),
__BaseState.getScheduleKey(positionFragment) __BaseState.getScheduleKey(positionFragment)
) )
} }
private fun getCurrentMeasurePos(): Int {
val measureHeightTraverseSubFragment = currentFragment as MeasureHeightTraverseSubFragment
return measureHeightTraverseSubFragment.backOrFrontPosition
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
monitorCurrentCycle( monitorCurrentCycle(
SurveyorScheduleConstants.getCurrentCycleKey( SurveyorScheduleConstants.getCurrentCycleKey(
stationId(), stationId(),
SurveyorScheduleConstants.STATION_TYPE_HEIGHT_TRAVERSE_BACK SurveyorScheduleConstants.STATION_TYPE_HEIGHT_TRAVERSE_BACK
) )
) )
monitorCurrentCycle( monitorCurrentCycle(
SurveyorScheduleConstants.getCurrentCycleKey( SurveyorScheduleConstants.getCurrentCycleKey(
stationId(), stationId(),
SurveyorScheduleConstants.STATION_TYPE_HEIGHT_TRAVERSE_FRONT SurveyorScheduleConstants.STATION_TYPE_HEIGHT_TRAVERSE_FRONT
) )
) )
} }
@ -151,14 +155,11 @@ class MeasureHeightTraverseFragment : MeasureBaseFragment() {
//删除当前测回记录 //删除当前测回记录
if (surveyorStationRecord != null && currentFragment != null) { if (surveyorStationRecord != null && currentFragment != null) {
//通知fragment //通知fragment
currentFragment.deleteStationOnePeriodRecord(cycleIndex) currentFragment.deleteStationOnePeriodRecord(getCurrentMeasurePos())
} }
} else if (R.id.menu_item_delete_all_records == item.itemId) { } else if (R.id.menu_item_delete_all_records == item.itemId) {
//删除所有测回记录 //删除所有测回记录
if (surveyorStationRecord != null && currentFragment != null) { showDeleteStationRecord()
//通知fragment
currentFragment.deleteStationAllPeroidRecord()
}
} else if (R.id.menu_item_station_check == item.itemId && currentFragment != null) { } else if (R.id.menu_item_station_check == item.itemId && currentFragment != null) {
//测站检测 //测站检测
stationCheckBefore() stationCheckBefore()
@ -177,18 +178,52 @@ class MeasureHeightTraverseFragment : MeasureBaseFragment() {
val name = getStationName(surveyorStationRecord) val name = getStationName(surveyorStationRecord)
runOnUI { runOnUI {
SurveyorSettingsFragment.start( SurveyorSettingsFragment.start(
context, context,
surveyorStationRecord.getId(), surveyorStationRecord.getId(),
name name
) )
} }
} }
} else if (R.id.menu_item_station_adjust == item.itemId && currentFragment != null) { } else if (R.id.menu_item_check_adjust == item.itemId && currentFragment != null) {
//测平差 //测平差
stationCheckAdjustBefore() stationCheckAdjustBefore()
} }
return super.onOptionsItemSelected(item) return super.onOptionsItemSelected(item)
} }
/**
* 删除测站的后视和前视的所有测回记录
*/
private fun showDeleteStationRecord() {
if (surveyorStationRecord == null || currentFragment == null) {
return
}
val fragment = currentFragment as MeasureHeightTraverseSubFragment
if (fragment.isInvalite || fragment.isDead) {
return
}
val msg = if (fragments.size == 1) {
"是否确定删除该站的所有测回数据?"
} else {
"是否确定删除该站的后视和前视的所有测回数据?"
}
TipsWith2OptionFragment.tips(
childFragmentManager,
this,
null,
null,
null,
msg,
object : TipsWith2OptionFragment.SimpleCallback() {
override fun onConfirm() {
for (fragmentI in fragments) {
fragmentI.deleteStationAllPeroidRecord()
}
}
})
}
} }

@ -30,6 +30,7 @@ import com.bingce.controlapphelper.surveyor.state.ISurveyState;
import com.bingce.controlapphelper.surveyor.surveyor.RequestSurveyorParamAuto; import com.bingce.controlapphelper.surveyor.surveyor.RequestSurveyorParamAuto;
import com.bingce.controlapphelper.util.IUIRunner; import com.bingce.controlapphelper.util.IUIRunner;
import com.bingce.controlapphelper.util.IdUtil; import com.bingce.controlapphelper.util.IdUtil;
import com.bingce.controlnetwork.R;
import com.bingce.controlnetwork.adapter.MeasureHeightTraverseAdapter; import com.bingce.controlnetwork.adapter.MeasureHeightTraverseAdapter;
import com.bingce.controlnetwork.fragment.ComponentStationSurveyorDataListFragment; import com.bingce.controlnetwork.fragment.ComponentStationSurveyorDataListFragment;
import com.bingce.controlnetwork.fragment.StationDataAdjustDialogFragment; import com.bingce.controlnetwork.fragment.StationDataAdjustDialogFragment;
@ -43,16 +44,6 @@ import com.bingce.utils.ThreadPoolUtil;
import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.EventBus;
import com.bingce.controlnetwork.R;
import com.bingce.controlnetwork.adapter.MeasureHeightTraverseAdapter;
import com.bingce.controlnetwork.fragment.ComponentStationSurveyorDataListFragment;
import com.bingce.controlnetwork.fragment.StationDataAdjustDialogFragment;
import com.bingce.controlnetwork.fragment.base.BaseLazyFragment;
import com.bingce.controlnetwork.fragment.stationsurvey.IMeasureOperate;
import com.bingce.controlnetwork.fragment.stationsurvey.angledistance.MeasureVm;
import com.bingce.controlnetwork.surveyor.state.IScrollDelegate;
import com.bingce.controlnetwork.surveyor.state.heighttraverse.StateManagerHeightTraverse;
/** /**
* 测角测距 * 测角测距
*/ */
@ -300,11 +291,11 @@ public class MeasureHeightTraverseSubFragment extends BaseLazyFragment
} }
@Override @Override
public void deleteStationOnePeriodRecord(int cycleIndex) { public void deleteStationOnePeriodRecord(int positionFragment) {
if (stateManager == null) { if (stateManager == null) {
return; return;
} }
stateManager.deleteCurrentStationSurveyorData(cycleIndex); stateManager.deleteCurrentStationSurveyorData(positionFragment);
} }
@Override @Override
@ -398,6 +389,14 @@ public class MeasureHeightTraverseSubFragment extends BaseLazyFragment
return false; return false;
} }
public boolean isInvalite() {
return stateManager.isInValidate();
}
public boolean isDead() {
return stateManager.isDead();
}
private static final String KEY_STATION_ID = "__station_id"; private static final String KEY_STATION_ID = "__station_id";
private static final String KEY_TYPE_BACK_OR_FRONT = "__KEY_TYPE_BACK_OR_FRONT"; private static final String KEY_TYPE_BACK_OR_FRONT = "__KEY_TYPE_BACK_OR_FRONT";
public static final String TAG = ComponentStationSurveyorDataListFragment.class.getName(); public static final String TAG = ComponentStationSurveyorDataListFragment.class.getName();

@ -0,0 +1,145 @@
package com.bingce.controlnetwork.func.level.activity
import android.content.Context
import android.content.Intent
import android.view.Menu
import android.view.MenuItem
import androidx.activity.viewModels
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentStatePagerAdapter
import androidx.viewpager.widget.ViewPager.OnPageChangeListener
import com.bingce.controlnetwork.func.level.fragment.LevelStationSettingConditionFragment
import com.bingce.controlnetwork.func.level.fragment.LevelStationSettingInformationFragment
import com.bingce.controlnetwork.func.level.viewmodel.LevelStationSettingVm
import com.bingce.controlapphelper.model.BundleConstants
import com.bingce.controlnetwork.R
import com.bingce.controlnetwork.databinding.ActivityLevelStationSettingBinding
import com.bingce.controlnetwork.newui.base.BaseBindingActivity
import com.bingce.controlnetwork.newui.stationsetting.IStationSettingOperate
class LevelStationSettingActivity : BaseBindingActivity<ActivityLevelStationSettingBinding>() {
private val viewModel by viewModels<LevelStationSettingVm>()
private val fragments = mutableListOf<Fragment>()
private val fragmentTitleList = listOf("观测信息", "观测条件")
companion object {
private const val KEY_IS_SAVE_END_STATION = "KEY_IS_SAVE_END_STATION"
@JvmStatic
fun start(context: Context, routeId: String, stationId: String, isSaveEndStation: Boolean) {
context.startActivity(Intent(context, LevelStationSettingActivity::class.java).apply {
putExtra(BundleConstants.KEY_ROUTE_ID, routeId)
putExtra(BundleConstants.KEY_SURVEYOR_STATION_ID, stationId)
putExtra(KEY_IS_SAVE_END_STATION, isSaveEndStation)
})
}
}
override fun getBinding(): ActivityLevelStationSettingBinding {
return ActivityLevelStationSettingBinding.inflate(layoutInflater)
}
override fun initView() {
viewModel.initRouteStationId(getRouteId(), getStationId())
initViewPager()
}
override fun initData() {
viewModel.getEditLastData(getStationId())
viewModel.getInitCurrentTabPos {
mBinding.tabLayout.currentTab = it
}
}
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
menuInflater.inflate(R.menu.menu_confirm, menu)
return super.onCreateOptionsMenu(menu)
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
if (R.id.menu_confirm == item.itemId) {
doConfirm()
}
return super.onOptionsItemSelected(item)
}
private fun initViewPager() {
fragments.add(LevelStationSettingInformationFragment())
fragments.add(LevelStationSettingConditionFragment())
mBinding.vp.offscreenPageLimit = 3
mBinding.vp.adapter = MyPagerAdapter(supportFragmentManager)
mBinding.tabLayout.setViewPager(mBinding.vp)
mBinding.vp.addOnPageChangeListener(object : OnPageChangeListener {
override fun onPageScrolled(
position: Int,
positionOffset: Float,
positionOffsetPixels: Int
) {
}
override fun onPageSelected(position: Int) {
}
override fun onPageScrollStateChanged(state: Int) {
}
})
// //设置当前tab为仪高镜高
// mBinding.vp.currentItem = 1
}
private inner class MyPagerAdapter(fm: FragmentManager) : FragmentStatePagerAdapter(fm) {
override fun getCount(): Int {
return fragments.size
}
override fun getPageTitle(position: Int): CharSequence {
return fragmentTitleList[position]
}
override fun getItem(position: Int): Fragment {
return fragments[position]
}
override fun getItemPosition(`object`: Any): Int {
return POSITION_NONE
}
}
private fun doConfirm() {
//检查未完成的选项
for (fragment in fragments) {
val operate = fragment as IStationSettingOperate
if (operate.checkSaveNot()) {
val fragmentNotFinishPos = fragments.indexOf(fragment)
if (mBinding.vp.currentItem != fragmentNotFinishPos) {
mBinding.tabLayout.currentTab = fragmentNotFinishPos
}
return
}
}
viewModel.createNeedSaveLevelRouteSave(getRouteId(), getStationId())
//赋值
for (fragment in fragments) {
val operate = fragment as IStationSettingOperate
operate.setDataToStation()
}
viewModel.save(getIsSaveEndStation()) {
finish()
}
}
private fun getStationId() = intent.getStringExtra(BundleConstants.KEY_SURVEYOR_STATION_ID)!!
private fun getRouteId() = intent.getStringExtra(BundleConstants.KEY_ROUTE_ID)!!
private fun getIsSaveEndStation() = intent.getBooleanExtra(KEY_IS_SAVE_END_STATION, false)
}

@ -0,0 +1,38 @@
package com.bingce.controlnetwork.func.level.adapter;
import android.content.Context;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import com.bingce.controlapphelper.datasource.database.leveling.route.LevelRouteRecord;
import com.bingce.controlapphelper.model.LevelingMeasureOrderUtil;
import com.bingce.controlnetwork.databinding.ItemLevelRouteListBinding;
import com.bingce.controlnetwork.newui.adapter.BaseAdapterNew;
public class LevelRouteListAdapter extends BaseAdapterNew<LevelRouteListViewHolder, LevelRouteRecord> {
public LevelRouteListAdapter(Context context) {
super(context);
}
@NonNull
@Override
public LevelRouteListViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
return new LevelRouteListViewHolder(ItemLevelRouteListBinding.inflate(getInflater(), parent, false));
}
@Override
protected void onBindViewHolderDo(LevelRouteListViewHolder holder, int position) {
LevelRouteRecord bean = mDataList.get(position);
holder.mBinding.tvIndex.setText(String.valueOf(position + 1));
holder.mBinding.tvRouteName.setText(bean.getRouteName());
holder.mBinding.tvOrderType.setText(LevelingMeasureOrderUtil.INSTANCE.getTextByLevelingMeasureOrder(bean.getLevelingMeasureOrder()));
holder.mBinding.tvWay.setText(bean.getObservationDirection());
}
}

@ -0,0 +1,15 @@
package com.bingce.controlnetwork.func.level.adapter;
import androidx.recyclerview.widget.RecyclerView;
import com.bingce.controlnetwork.databinding.ItemLevelRouteListBinding;
public class LevelRouteListViewHolder extends RecyclerView.ViewHolder {
public final ItemLevelRouteListBinding mBinding;
public LevelRouteListViewHolder(ItemLevelRouteListBinding binding) {
super(binding.getRoot());
mBinding = binding;
}
}

@ -0,0 +1,13 @@
package cn.liuyanbing.surveyor.function.level.constant
/**
* 水准常量
*/
object LevelConstant {
/**
* 默认经纬度郑州
*/
const val LONGITUDE_DEFAULT = 113.6482317
const val LATITUDE_DEFAULT = 34.7492133
const val HEIGHT_DEFAULT = 0.0
}

@ -0,0 +1,55 @@
package com.bingce.controlnetwork.func.level.constant
import com.bingce.controlapphelper.util.Tools
import com.bingce.controlnetwork.R
object LevelStationSettingContant {
val observationDirectionList = listOf("往测", "返测", "检往", "检返", "重往", "重返")
val weatherList = listOf("", "", "", "")
val imagingList =
listOf("清晰", "小雾", "中雾", "大雾")
val sunDirectionList =
listOf("无太阳", "", "", "", "")
val windDirectionList =
listOf(
"",
"",
"",
"西",
"",
"东南",
"西南",
"东北",
"西北"
)
val windSpeedList =
listOf(
"",
"0级无风",
"1级软风",
"2级轻风",
"3级微风",
"4级和风",
"5级清劲风",
"6级强风",
"7级疾风",
"8级大风"
)
val roadsList =
listOf(
Tools.getString(R.string.please_choose),
"柏油路", "水泥路", "土路", "砂石路", "铁路", "其他"
)
val soilList =
listOf(
Tools.getString(R.string.please_choose),
"柏油", "水泥", "实土", "沙石", "草地"
)
val rulerTypeList = listOf("铟瓦尺", "木质", "其他")
//尺承类型
val rulerReceptTypeList =
listOf("钢尺桩", "5kg以上尺台", "不足5kg尺台", "钢帽钉", "木桩", "其他")
}

@ -0,0 +1,129 @@
package com.bingce.controlnetwork.func.level.dialog;
import static com.bingce.controlapphelper.model.LevelToleranceNoticeKt.VALUE_IGNORE;
import static com.bingce.controlapphelper.model.LevelToleranceNoticeKt.VALUE_REMEASURE_POINT;
import static com.bingce.controlapphelper.model.LevelToleranceNoticeKt.VALUE_REMEASURE_STATION;
import android.app.Dialog;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatDialogFragment;
import androidx.fragment.app.FragmentManager;
import androidx.lifecycle.LifecycleOwner;
import com.bingce.controlnetwork.R;
/**
* 水准限差超限提示框
*/
public class LevelToleranceTipsFragment extends AppCompatDialogFragment {
private static final String KEY_TITLE = "__TITLE";
private static final String KEY_CONTENT = "___CONTENT";
private static final String KEY_RESULT = "KEY_RESULT";
private static final String KEY_BUNDLE = "KEY_BUNDLE";
private static final String TAG = LevelToleranceTipsFragment.class.getName();
public static void tips(@NonNull FragmentManager fragmentManager,
@NonNull LifecycleOwner lifecycleOwner,
String title,
String content,
IOperatorCallback callback) {
Bundle args = new Bundle();
LevelToleranceTipsFragment fragment = new LevelToleranceTipsFragment();
fragment.setArguments(args);
args.putString(KEY_TITLE, title);
args.putString(KEY_CONTENT, content);
fragmentManager
.setFragmentResultListener(
KEY_BUNDLE,
lifecycleOwner,
(requestKey, result) -> {
int type = result.getInt(KEY_RESULT, -1);
if (VALUE_IGNORE == type) {
callback.onIgnore();
} else if (VALUE_REMEASURE_STATION == type) {
callback.onReMeasureStation();
} else if (VALUE_REMEASURE_POINT == type) {
callback.onReMeasurePoint();
}
});
fragment.show(fragmentManager, TAG);
}
public interface IOperatorCallback {
void onReMeasureStation();
void onReMeasurePoint();
void onIgnore();
}
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View contentView = inflater.inflate(R.layout.fragment_level_tolerance_tips, container, false);
TextView tvTitle = contentView.findViewById(R.id.tvTitle);
tvTitle.setText(getTitle());
TextView tvContent = contentView.findViewById(R.id.tvContent);
tvContent.setText(getContent());
contentView.findViewById(R.id.btnIgnore).setOnClickListener(v -> {
setBackResult(VALUE_IGNORE);
});
contentView.findViewById(R.id.btnRemeasureStation).setOnClickListener(v -> {
setBackResult(VALUE_REMEASURE_STATION);
});
contentView.findViewById(R.id.btnRemeasureCurrent).setOnClickListener(v -> {
setBackResult(VALUE_REMEASURE_POINT);
});
return contentView;
}
private void setBackResult(int clickType) {
Bundle bundle = new Bundle();
bundle.putInt(KEY_RESULT, clickType);
getParentFragmentManager().setFragmentResult(KEY_BUNDLE, bundle);
//关闭dialog
dismissAllowingStateLoss();
}
@Override
public void onStart() {
super.onStart();
Dialog dialog = getDialog();
if (dialog == null) {
return;
}
dialog.getWindow().setLayout(
WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.WRAP_CONTENT);
}
private String getTitle() {
Bundle arguments = getArguments();
if (arguments != null) {
return arguments.getString(KEY_TITLE);
}
return null;
}
private String getContent() {
Bundle arguments = getArguments();
if (arguments != null) {
return arguments.getString(KEY_CONTENT);
}
return null;
}
}

@ -0,0 +1,231 @@
package cn.liuyanbing.surveyor.function.level.export
import android.util.Log
import androidx.annotation.WorkerThread
import com.bingce.controlapphelper.datasource.database.leveling.LevelingDbFactory
import com.bingce.controlapphelper.datasource.database.leveling.idetection.constants.LevelIDetectionConstant
import com.bingce.controlapphelper.datasource.database.leveling.idetection.list.LevelIDetectionList
import com.bingce.controlapphelper.datasource.database.leveling.idetection.record.LevelIDetectionRecord
import com.bingce.controlapphelper.leveling.detaction.LevelFormatUtil
import com.bingce.controlapphelper.model.getLength
import com.bingce.controlnetwork.func.level.util.LevelDateUtil
import com.bingce.controlnetwork.func.level.util.LevelDateUtil.getLevelHeadDateHourMin
/**
* i角检测导出
*/
class LevelExportIDetection {
private var levelNoIndex = 0
companion object {
const val _N = "\r\n"
const val _S = "\u0020"
const val LEVEL_NO = "LEVEL|No"
const val TO = "TO"
const val INF = "INF"
const val SHU = "|"
const val CHECK_RECORD_SIZE = 20
}
@WorkerThread
fun export(iDetection: LevelIDetectionList): String? {
val recordList =
LevelingDbFactory.instance.iDetectionRecordDataSource.getRecordsByIDetectionId(
iDetection.id
)
if (recordList.isEmpty() || recordList.size != CHECK_RECORD_SIZE) {
return null
}
if (iDetection.iResult == null) {
return null
}
if (iDetection.shortDistance == null || iDetection.longDistance == null
|| iDetection.measureType == null
) {
return null
}
val firstRecordCreateDate = recordList.first().createDate
val dateYMD =
LevelDateUtil.getLevelHeadDateYearMonthDay(firstRecordCreateDate)
val dateHM = getLevelHeadDateHourMin(firstRecordCreateDate)
val settting =
LevelingDbFactory.instance.iDetectionSettingDataSource.getByIDetectionId(iDetection.id)
val sb = StringBuilder()
//startI
sb.append(LEVEL_NO).append(getLevelNoRightSpace()).append(getNoIndexName()).append(SHU)
.append(TO).append(getSpace2()).append("Start-I").append(getSpace10())
.append(iDetection.measureType).append(SHU).append(getSpace30()).append(SHU)
.append(getSpace30()).append(SHU).append(getSpace30()).append(SHU)
.append(_N)
levelNoIndexIncrease()
//i角检测的设置
appendSetting(sb, "instrumentModel", toString(settting.instrumentModel))
appendSetting(sb, "deviceNumber", "No.${toString(settting.deviceNumber)}")
appendSetting(sb, "dateYMD", dateYMD)
appendSetting(sb, "dateHM", dateHM)
appendSetting(sb, "rulerNum1", toString(settting.rulerNum1))
appendSetting(sb, "rulerNum2", toString(settting.rulerNum2))
appendSetting(sb, "imaging", toString(settting.imaging))
appendSetting(sb, "watcher", toString(settting.watcher))
appendSetting(sb, "recorder", toString(settting.recorder))
appendSetting(sb, "examiner", toString(settting.examiner))
//D1 D2
appendD1D2(sb, "D1", iDetection.shortDistance)
appendD1D2(sb, "D2", iDetection.longDistance)
//先排个序
recordList.sortWith(
Comparator.comparing(LevelIDetectionRecord::stationType)
.thenComparing(LevelIDetectionRecord::rulerType)
.thenComparing(LevelIDetectionRecord::measureTime)
)
for (record in recordList) {
Log.d(
"hwhw",
"" + record.stationType + "," + record.rulerType + "," + record.measureTime
)
appendRecord(sb, record)
}
//iResult
val iResultUnit = if (iDetection.iResult != null) {
"${iDetection.iResult} s"
} else {
""
}
val spaceIResultLeft = getSpace(30 - 4 - iResultUnit.length - 1)
sb.append(LEVEL_NO).append(getLevelNoRightSpace()).append(getNoIndexName()).append(SHU)
.append("I").append(getSpace(29)).append(SHU)
.append(getSpace30()).append(SHU)
.append(getSpace30()).append(SHU)
.append("I").append(spaceIResultLeft).append(iResultUnit).append(getSpace4())
.append(SHU)
.append(_N)
levelNoIndexIncrease()
//endI
sb.append(LEVEL_NO).append(getLevelNoRightSpace()).append(getNoIndexName()).append(SHU)
.append(TO).append(getSpace(4)).append("End-I").append(getSpace(19)).append(SHU)
.append(getSpace30()).append(SHU)
.append(getSpace30()).append(SHU)
.append(getSpace30()).append(SHU)
.append(_N)
return sb.toString()
}
private fun levelNoIndexIncrease() {
levelNoIndex++
}
private fun appendRecord(sb: StringBuilder, record: LevelIDetectionRecord) {
val hourMinSec = LevelDateUtil.getHourMinSec(record.createDate)
val height = LevelFormatUtil.formatHeight(record.height)
val distance = LevelFormatUtil.formatDistance(record.distance)
val heightUnit = "$height m"
val distanceUnit = "$distance m"
val space2 = getSpace2()
val spaceHeightLeft = getSpace(24 - 2 - heightUnit.length)
val spaceDistanceLeft = getSpace(28 - 2 - distanceUnit.length)
sb.append(LEVEL_NO).append(getLevelNoRightSpace()).append(getNoIndexName()).append(SHU)
.append("KD1").append(getSpace10()).append("${record.measureTime + 1}")
.append(getSpace8()).append(hourMinSec).append(SHU)
.append(getRI1A(record)).append(spaceHeightLeft).append(heightUnit).append(space2)
.append(SHU)
.append("HD").append(spaceDistanceLeft).append(distanceUnit).append(space2).append(SHU)
.append(getSpace30()).append(SHU)
.append(_N)
levelNoIndexIncrease()
}
private fun getRI1A(record: LevelIDetectionRecord): String {
return if (record.stationType == LevelIDetectionConstant.STATION_TYPE_0) {
if (record.rulerType == LevelIDetectionConstant.RULER_TYPE_0) {
"R_I1_A"
} else {
"R_I1_B"
}
} else {
if (record.rulerType == LevelIDetectionConstant.RULER_TYPE_0) {
"R_I2_A"
} else {
"R_I2_B"
}
}
}
private fun appendD1D2(sb: StringBuilder, d1: String, d1Value: String) {
val d1ValueFormat = LevelFormatUtil.formatHeight(toDouble(d1Value))
val d1ValueUnit = "$d1ValueFormat m"
val d1ValueUnitLength = d1ValueUnit.length
val spaceValueLeft = getSpace(30 - 4 - d1ValueUnitLength - 1)
val spaceValueRight = getSpace4()
sb.append(LEVEL_NO).append(getLevelNoRightSpace()).append(getNoIndexName()).append(SHU)
.append(d1).append(getSpace28()).append(SHU)
.append(getSpace30()).append(SHU)
.append(getSpace30()).append(SHU)
.append("D").append(spaceValueLeft).append(d1ValueUnit).append(spaceValueRight)
.append(SHU)
.append(_N)
levelNoIndexIncrease()
}
private fun appendSetting(sb: StringBuilder, key: String, value: String) {
sb.append(LEVEL_NO).append(getLevelNoRightSpace()).append(getNoIndexName()).append(SHU)
.append(INF).append(getSpace27()).append(SHU)
.append(key).append(getSettingKeyRightSpace(key)).append(SHU)
.append(getSpace30()).append(SHU)
.append(value).append(getSettingValueRightSpace(value)).append(SHU)
.append(_N)
levelNoIndexIncrease()
}
private fun getLevelNoRightSpace(): String {
val length = getNoIndexName().length
return getSpace(8 - length)
}
private fun getSettingKeyRightSpace(key: String): String {
val length = key.length
return getSpace(30 - length)
}
private fun getSettingValueRightSpace(value: String): String {
val length = getLength(value)
return getSpace(30 - length)
}
private fun getNoIndexName() = "${levelNoIndex + 1}"
private fun getSpace2() = getSpace(2)
private fun getSpace4() = getSpace(4)
private fun getSpace8() = getSpace(8)
private fun getSpace10() = getSpace(10)
private fun getSpace27() = getSpace(27)
private fun getSpace28() = getSpace(28)
private fun getSpace30() = getSpace(30)
private fun getSpace(size: Int) = _S.repeat(size)
private fun toString(value: String?) = value ?: ""
private fun toDouble(value: String?): Double {
return value?.toDouble() ?: 0.0
}
}

@ -0,0 +1,218 @@
package com.bingce.controlnetwork.func.level.export
import android.text.TextUtils
import androidx.annotation.WorkerThread
import com.bingce.controlapphelper.datasource.database.SurveyorDatabaseFactory
import com.bingce.controlapphelper.datasource.database.leveling.LevelingDbFactory
import com.bingce.controlapphelper.datasource.database.leveling.stationsetting.LevelingStationSettingRecord
import com.bingce.controlapphelper.datasource.database.point.PointRecord
import com.bingce.controlapphelper.leveling.detaction.LevelFormatUtil
import com.bingce.controlapphelper.model.LevelingMeasureOrder
import com.bingce.controlapphelper.model._N
import com.bingce.controlapphelper.model._S
import com.bingce.controlapphelper.model._T
import com.bingce.controlapphelper.surveyor.method.ExportStationMethod
import com.bingce.controlapphelper.surveyor.method.model.MeasureConstant
import java.io.File
class LevelExportSingalHeight {
private var routeIndex = 0
private val singalHeightSb = StringBuilder()
private val rulerLengthSb = StringBuilder()
private val pointNumNameSb = StringBuilder()
private val heightDistanceSb = StringBuilder()
private val pointKnownSb = StringBuilder()
@WorkerThread
fun export(projectFolder: File, projectId: String) {
collectRulerLength(projectId)
collectPoint(projectId)
collectSingalHeight(projectId)
val prepare4Folder = initPrepare4Folder(projectFolder)
saveData(projectFolder, singalHeightSb, "SingalHeight.txt")
saveData(prepare4Folder, rulerLengthSb, "尺长.txt")
saveData(prepare4Folder, pointNumNameSb, "点名点号.txt")
saveData(prepare4Folder, heightDistanceSb, "高差文件.txt")
saveData(prepare4Folder, pointKnownSb, "已知.txt")
}
private fun saveData(projectFolder: File, data: StringBuilder, fileName: String) {
if (data.isNotEmpty()) {
ExportStationMethod.save(
data.toString(),
projectFolder,
fileName
)
}
}
private fun collectSingalHeight(projectId: String) {
val routeList = LevelingDbFactory.instance.levelDataSource.getByProjectIdSync(projectId)
for (route in routeList) {
val routeId = route.getId()
val pointNameStart = getPointName(route.startPointId)
val pointNameEnd = getPointName(route.endPointId)
val levelingMeasureOrder = route.levelingMeasureOrder
val isHasTwiceStation = when (levelingMeasureOrder) {
LevelingMeasureOrder.SIM_BF,
LevelingMeasureOrder.SIM_BFFB -> {
true
}
else -> false
}
val routeLastStationSetting =
LevelingDbFactory.instance.stationSettingDataSource.getLatest(routeId)
appendData(
projectId,
routeId,
pointNameStart,
pointNameEnd,
false,
routeLastStationSetting
)
if (isHasTwiceStation) {
appendData(
projectId,
routeId,
pointNameStart,
pointNameEnd,
true,
routeLastStationSetting
)
}
}
heightDistanceSb.append("END")
}
/**
* 点名点号
* 已知点
*/
private fun collectPoint(projectId: String) {
val pointList = SurveyorDatabaseFactory.instance.pointDataSource.findByProjectIdSync(projectId)
for (point in pointList) {
if (PointRecord.TYPE_KNOWN_POINT == point.pointType) {
pointKnownSb.append(point.getName()).append(_S).append(point.getZFormat(4))
}
pointNumNameSb.append(point.getName()).append(_S).append("")
.append(_N)
}
pointNumNameSb.append("END")
pointKnownSb.append("END")
}
/**
* 收集尺长
*/
private fun collectRulerLength(projectId: String) {
val routeList = SurveyorDatabaseFactory.instance.pointDataSource.findByProjectIdSync(projectId)
for (route in routeList) {
val latest = LevelingDbFactory.instance.stationSettingDataSource.getLatest(route.id)
val rulerCorrectionFactor = if (!TextUtils.isEmpty(latest.rulerCorrectionFactor)) {
"${latest.rulerCorrectionFactor.toDouble() / 1000}"
} else {
"0"
}
rulerLengthSb.append("1").append(_S).append(rulerCorrectionFactor)
.append(_N)
}
rulerLengthSb.append("END")
}
private fun appendData(
projectId: String,
routeId: String,
pointNameStart: String,
pointNameEnd: String,
twiceStation: Boolean,
routeLatestSetting: LevelingStationSettingRecord
) {
val stationFirst =
LevelingDbFactory.instance.stationDataSource.getStationFirstTwiceStation(
projectId,
routeId,
twiceStation
)
val stationLatest =
LevelingDbFactory.instance.stationDataSource.getStationLatestTwiceStation(
projectId,
routeId,
twiceStation
)
val measureStation =
LevelingDbFactory.instance.measureStationDataSource.getRecordSync(stationLatest.getId())
?: return
singalHeightSb.append(getRouteNum()).append(_T)//编号
.append(pointNameStart).append(_T)//起点
.append(pointNameEnd).append(_T)//终点
.append(LevelFormatUtil.formatHeight(measureStation.heightDiffTotal)).append(_T)//高差
.append(LevelFormatUtil.formatHeight(measureStation.distanceTotal)).append(_T)//距离
.append("0.00000").append(_T)//温度改正
.append(getExportRulerCorrectionFactor(routeLatestSetting)).append(_T)//标尺改正系数
.append("1").append(_T)//结束标志
.append(routeLatestSetting.soil ?: "水泥").append(_T)//土质
.append(stationFirst.createDate.time).append(_T)//开始时间
.append(stationLatest.createDate.time).append(_T)//结束时间
.append(routeLatestSetting.temperature ?: MeasureConstant.DEFAULT_TEMPERATURE)
.append(_T)//温度
.append(routeLatestSetting.firstStationFrontFootNumber ?: "").append(_T)//标尺1
.append(routeLatestSetting.firstStationBackFootNumber ?: "").append(_T)//标尺2
.append(measureStation.stationNumForenoonTotal).append(_T)//上午测站数
.append(measureStation.stationNumAfternoonTotal).append(_T)//下午测站数
.append(_N)
heightDistanceSb.append(pointNameStart).append(_S)
.append(pointNameEnd).append(_S)
.append(LevelFormatUtil.formatHeight(measureStation.heightDiffTotal)).append(_S)//高差
.append(LevelFormatUtil.formatHeight(measureStation.distanceTotal)).append(_S)//距离
.append("1").append(_N)//结束标志
routeIndex++
}
private fun getExportRulerCorrectionFactor(routeLatestSetting: LevelingStationSettingRecord): String {
return if (!TextUtils.isEmpty(routeLatestSetting.rulerCorrectionFactor)) {
"${routeLatestSetting.rulerCorrectionFactor.toDouble() / 1000}"
} else {
"0"
}
}
private fun getPointName(pointId: String): String {
return SurveyorDatabaseFactory.instance.pointDataSource.findByIdSync(pointId)?.getName() ?: ""
}
private fun getRouteNum(): String {
return String.format("%04d", routeIndex + 1)
}
/**
* 初始化平差准备文件夹
*/
private fun initPrepare4Folder(projectFolder: File): File {
val exportFolder = File(projectFolder, "平差准备文件")
if (!exportFolder.exists()) {
exportFolder.mkdir()
}
return exportFolder
}
}

@ -0,0 +1,86 @@
package com.bingce.controlnetwork.func.level.fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.FragmentManager;
import androidx.lifecycle.LifecycleOwner;
import com.bingce.controlnetwork.R;
import com.bingce.controlnetwork.fragment.AbstractFullScreenDialogFragment;
/**
* 新建编辑i角检测
*/
public class LevelIDetectionCreateFragment extends AbstractFullScreenDialogFragment {
@Override
protected View createContentView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_level_i_detection_create_edit, container, false);
EditText editText = view.findViewById(R.id.editor);
if (editText != null && getArguments() != null) {
editText.setText(getArguments().getString(KEY_DEFAULT_STRING));
}
return view;
}
@Override
protected void onConfirm() {
Bundle args = new Bundle();
if (getView() != null) {
EditText editText = getView().findViewById(R.id.editor);
if (editText.getText() != null) {
String string = editText.getText().toString();
if (string.isEmpty()) {
Toast.makeText(getContext(),
R.string.string_no_empty,
Toast.LENGTH_SHORT).show();
return;
}
args.putString(KEY_STRING_RESULT, string);
}
}
getParentFragmentManager()
.setFragmentResult(KEY_REQUEST_INPUT, args);
super.onConfirm();
}
private static final String TAG = LevelIDetectionCreateFragment.class.getName();
private static final String KEY_REQUEST_INPUT = LevelIDetectionCreateFragment.class.getName() + "_REQUEST";
private static final String KEY_STRING_RESULT = LevelIDetectionCreateFragment.class.getName() + "_result";
private static final String KEY_DEFAULT_STRING = LevelIDetectionCreateFragment.class.getName() + "__DEFAULT_STRING";
public static void input(FragmentManager fragmentManager,
String title,
String defaultString,
LifecycleOwner lifecycleOwner,
IInputCallback callback) {
Bundle args = new Bundle();
LevelIDetectionCreateFragment fragment = new LevelIDetectionCreateFragment();
fragment.setArguments(args);
if (defaultString != null) {
args.putString(KEY_DEFAULT_STRING, defaultString);
}
AbstractFullScreenDialogFragment.setArgs(args, title, null);
fragmentManager
.setFragmentResultListener(
KEY_REQUEST_INPUT,
lifecycleOwner,
(requestKey, result) -> {
if (KEY_REQUEST_INPUT.equals(requestKey)) {
callback.onGetInput(result.getString(KEY_STRING_RESULT));
}
});
fragment.show(fragmentManager, TAG);
}
public interface IInputCallback {
void onGetInput(String string);
}
}

@ -0,0 +1,91 @@
package com.bingce.controlnetwork.func.level.fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatDialogFragment;
import androidx.fragment.app.FragmentManager;
import androidx.lifecycle.LifecycleOwner;
import com.bingce.controlnetwork.R;
import com.bingce.controlnetwork.newui.widget.switchtext.SwitchWithText;
public class LevelInputAllowFragment extends AppCompatDialogFragment {
public static String KEY_AUTO = "KEY_AUTO";
public static String KEY_REQUEST = "KEY_REQUEST";
public static void show(FragmentManager fragmentManager, LifecycleOwner lifecycleOwner,
boolean auto, IConfirmCallback callback) {
Bundle args = new Bundle();
LevelInputAllowFragment fragment = new LevelInputAllowFragment();
fragment.setArguments(args);
args.putBoolean(KEY_AUTO, auto);
fragmentManager
.setFragmentResultListener(
KEY_REQUEST,
lifecycleOwner,
(requestKey, result) -> {
if (KEY_REQUEST.equals(requestKey)) {
if (callback != null) {
callback.onConfirm(result.getBoolean(KEY_AUTO));
}
}
});
fragment.show(fragmentManager, null);
}
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View contentView = inflater.inflate(R.layout.fragment_level_input_allow, container, false);
SwitchWithText receiveDataType = contentView.findViewById(R.id.receiveDataType);
receiveDataType.setChecked(getAuto());
contentView.findViewById(R.id.btnConfirm).setOnClickListener(v -> {
Bundle bundle = new Bundle();
bundle.putBoolean(KEY_AUTO, receiveDataType.isChecked());
getParentFragmentManager()
.setFragmentResult(KEY_REQUEST, bundle);
dismissAllowingStateLoss();
});
return contentView;
}
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
if (getDialog() == null) {
return;
}
getDialog().getWindow().setLayout(
WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.WRAP_CONTENT);
}
public interface IConfirmCallback {
void onConfirm(Boolean auto);
}
/**
* 仪器获取
*/
private boolean getAuto() {
if (getArguments() != null) {
return getArguments().getBoolean(KEY_AUTO);
}
return true;
}
}

@ -0,0 +1,102 @@
package com.bingce.controlnetwork.func.level.fragment;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.EditText;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatDialogFragment;
import androidx.fragment.app.FragmentManager;
import androidx.lifecycle.LifecycleOwner;
import com.bingce.controlnetwork.R;
import blankj.utilcode.util.ToastUtils;
public class LevelInputFragment extends AppCompatDialogFragment {
public static String KEY_DISTANCE = "KEY_DISTANCE";
public static String KEY_HEIGHT = "KEY_HEIGHT";
public static String KEY_REQUEST = "KEY_REQUEST";
public static void show(FragmentManager fragmentManager, LifecycleOwner lifecycleOwner,
IConfirmCallback callback) {
Bundle args = new Bundle();
LevelInputFragment fragment = new LevelInputFragment();
fragment.setArguments(args);
fragmentManager
.setFragmentResultListener(
KEY_REQUEST,
lifecycleOwner,
(requestKey, result) -> {
if (KEY_REQUEST.equals(requestKey)) {
if (callback != null) {
double distance = result.getDouble(KEY_DISTANCE);
double height = result.getDouble(KEY_HEIGHT);
callback.onConfirm(distance, height);
}
}
});
fragment.show(fragmentManager, null);
}
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View contentView = inflater.inflate(R.layout.fragment_level_input, container, false);
EditText etDisTance = contentView.findViewById(R.id.etDisTance);
EditText etHeight = contentView.findViewById(R.id.etHeight);
contentView.findViewById(R.id.btnConfirm).setOnClickListener(v -> {
String disTance = getEtValue(etDisTance);
String height = getEtValue(etHeight);
if (TextUtils.isEmpty(disTance)) {
ToastUtils.showShort("请输入距离");
return;
}
if (TextUtils.isEmpty(height)) {
ToastUtils.showShort("请输入高度");
return;
}
Bundle bundle = new Bundle();
bundle.putDouble(KEY_DISTANCE, Double.parseDouble(disTance));
bundle.putDouble(KEY_HEIGHT, Double.parseDouble(height));
getParentFragmentManager()
.setFragmentResult(KEY_REQUEST, bundle);
dismissAllowingStateLoss();
});
return contentView;
}
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
if (getDialog() == null) {
return;
}
getDialog().getWindow().setLayout(
WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.WRAP_CONTENT);
}
private String getEtValue(EditText et) {
return et.getText().toString().trim();
}
public interface IConfirmCallback {
void onConfirm(double distance, double height);
}
}

@ -0,0 +1,382 @@
package com.bingce.controlnetwork.func.level.fragment
import android.content.Context
import android.os.Bundle
import android.text.TextUtils
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.AdapterView
import android.widget.ArrayAdapter
import android.widget.EditText
import androidx.fragment.app.Fragment
import androidx.fragment.app.viewModels
import androidx.lifecycle.lifecycleScope
import blankj.utilcode.util.ToastUtils
import cn.liuyanbing.surveyor.function.level.constant.LevelConstant
import com.bingce.controlnetwork.func.level.constant.LevelStationSettingContant
import com.bingce.controlnetwork.func.level.util.LevelStationSettingUtil.getSpinnerText
import com.bingce.controlapphelper.model.BundleConstants
import com.bingce.controlapphelper.model.LevelRouteSave
import com.bingce.controlapphelper.model.LevelingMeasureOrder
import com.bingce.controlapphelper.model.LevelingMeasureOrderUtil
import com.bingce.controlapphelper.model.PickPointResult
import com.bingce.controlapphelper.util.CheckLocationUtil
import com.bingce.controlapphelper.util.GetLocationUtil
import com.bingce.controlnetwork.R
import com.bingce.controlnetwork.activity.fragmentcontainer.FragmentContainerActivity
import com.bingce.controlnetwork.databinding.FragmentLevelCreateRouteBinding
import com.bingce.controlnetwork.fragment.PickPointFragment
import com.bingce.controlnetwork.func.level.viewmodel.LevelCreateOrEditRouteVm
import com.bingce.controlnetwork.newui.base.BaseFragmentBinding
import com.bingce.controlnetwork.newui.projectedit.ProjectLastData
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
class LevelRouteCreateEditFragment : BaseFragmentBinding<FragmentLevelCreateRouteBinding>() {
private val viewModel by viewModels<LevelCreateOrEditRouteVm>()
private val SELECT_POINT_TYPE_START = "SELECT_POINT_TYPE_START"
private val SELECT_POINT_TYPE_END = "SELECT_POINT_TYPE_END"
private var pickPointResultStart: PickPointResult? = null
private var pickPointResultEnd: PickPointResult? = null
private lateinit var levelingMeasureOrder: LevelingMeasureOrder
private val getLocation by lazy {
GetLocationUtil()
}
private val defaultStationLauncher = PickPointFragment.createActivityLauncher(
this
) { type: String, pickPointResult: PickPointResult ->
if (SELECT_POINT_TYPE_START == type) {
pickPointResultStart = pickPointResult
} else if (SELECT_POINT_TYPE_END == type) {
pickPointResultEnd = pickPointResult
}
if (pickPointResult.selectedIds.isNullOrEmpty()
|| pickPointResult.selectedNames.isNullOrEmpty()
|| pickPointResult.selectedNames.size != pickPointResult.selectedIds.size
) {
ToastUtils.showShort(R.string.abnormal_point_selection)
return@createActivityLauncher
}
setSelectPointUi()
}
companion object {
@JvmField
val TAG = LevelRouteCreateEditFragment::class.java.getName()
@JvmStatic
fun newInstance(args: Bundle?): Fragment {
val fragment: Fragment = LevelRouteCreateEditFragment()
fragment.setArguments(args)
return fragment
}
@JvmStatic
fun start(context: Context, projectId: String, routeId: String?, title: String) {
val bundle = Bundle()
bundle.putString(BundleConstants.KEY_PROJECT_ID, projectId)
bundle.putString(BundleConstants.KEY_ROUTE_ID, routeId)
FragmentContainerActivity.start(context, TAG, title, bundle)
}
}
override fun getViewBinding(
inflater: LayoutInflater,
container: ViewGroup?
): FragmentLevelCreateRouteBinding {
return FragmentLevelCreateRouteBinding.inflate(inflater, container, false)
}
override fun initView() {
lifecycle.addObserver(getLocation)
initLevelOrder()
initListener()
}
private fun initListener() {
mBinding.btnConfirm.setOnClickListener {
checkConfirm()
}
mBinding.btnDetermineAndMeasure.setOnClickListener {
}
mBinding.ivSelectStartPoint.setOnClickListener {
selectPoint(SELECT_POINT_TYPE_START)
}
mBinding.ivSelectEndPoint.setOnClickListener {
selectPoint(SELECT_POINT_TYPE_END)
}
mBinding.ivGetLocation.setOnClickListener {
getLocation {
setLocation(mBinding.etLongitude, mBinding.etLatitude, mBinding.etHeight, it)
}
}
}
override fun initData() {
initSpinnerObservationDirection()
initEditData()
}
private fun initEditData() {
val routeId = getRouteId()
if (routeId != null) {
viewModel.getEditRouteData(routeId) {
mBinding.etStartPoint.setText(it.startPointName)
mBinding.etEndPoint.setText(it.endPointName)
mBinding.spinnerObservationDirection.setSelection(
LevelStationSettingContant.observationDirectionList.indexOf(
it.observationDirection
)
)
// //经纬度
// if (isEmpty(it.longitude) || isEmpty(it.latitude)) {
// setDefaultLocation()
// } else {
// setLocation(
// mBinding.etLongitude,
// mBinding.etLatitude,
// mBinding.etHeight,
// it.longitude,
// it.latitude,
// it.z
// )
// }
}
} else {
setDefaultLocation()
}
}
private fun setSelectPointUi() {
if (pickPointResultStart == null) {
mBinding.etStartPoint.setText("")
} else {
mBinding.etStartPoint.setText(pickPointResultStart!!.selectedNames[0])
}
if (pickPointResultEnd == null) {
mBinding.etEndPoint.setText("")
} else {
mBinding.etEndPoint.setText(pickPointResultEnd!!.selectedNames[0])
}
}
private fun selectPoint(type: String) {
var title: String? = null
var pickPointResultSelected: PickPointResult? = null
var filderIds: List<String>? = null
if (SELECT_POINT_TYPE_START == type) {
pickPointResultSelected = pickPointResultStart
filderIds = pickPointResultEnd?.selectedIds
title = getString(R.string.choose_starting_point)
} else if (SELECT_POINT_TYPE_END == type) {
pickPointResultSelected = pickPointResultStart
filderIds = pickPointResultStart?.selectedIds
title = getString(R.string.select_end_point)
}
PickPointFragment.pickKnownAndUnknownPoint(
context,
type,
1,
title,
filderIds,
getProjectId(),
pickPointResultSelected,
defaultStationLauncher
)
}
/**
* 照准次序
*/
private fun initLevelOrder() {
val showList = LevelingMeasureOrderUtil.getShowList()
mBinding.spinner.setAdapter(
ArrayAdapter(
requireContext(),
android.R.layout.simple_list_item_1,
showList
)
)
mBinding.spinner.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
override fun onItemSelected(
parent: AdapterView<*>?,
view: View,
position: Int,
id: Long
) {
levelingMeasureOrder = LevelingMeasureOrderUtil.getLevelingMeasureOrderByCreate(
showList[position]
)
}
override fun onNothingSelected(parent: AdapterView<*>?) {}
}
mBinding.spinner.setSelection(0)
}
/**
* 观测方向
*/
private fun initSpinnerObservationDirection() {
mBinding.spinnerObservationDirection.adapter = ArrayAdapter(
requireContext(),
android.R.layout.simple_list_item_1,
LevelStationSettingContant.observationDirectionList
)
mBinding.spinnerObservationDirection.onItemSelectedListener =
object : AdapterView.OnItemSelectedListener {
override fun onItemSelected(
parent: AdapterView<*>?,
view: View,
position: Int,
id: Long
) {
}
override fun onNothingSelected(parent: AdapterView<*>?) {
}
}
}
private fun checkConfirm() {
val projectId = getProjectId()
if (projectId == null) {
ToastUtils.showShort(R.string.project_data_is_empty)
return
}
val startPointName = mBinding.etStartPoint.getText().toString().trim()
if (TextUtils.isEmpty(startPointName)) {
ToastUtils.showShort(R.string.please_enter_or_select_a_starting_point)
return
}
val endPointName = mBinding.etEndPoint.getText().toString().trim()
if (TextUtils.isEmpty(endPointName)) {
ToastUtils.showShort(R.string.please_enter_or_select_a_destination)
return
}
val longitude = mBinding.etLongitude.getText().toString().trim()
if (TextUtils.isEmpty(longitude)) {
ToastUtils.showShort(R.string.please_input_longitude)
return
}
val latitude = mBinding.etLatitude.getText().toString().trim()
if (TextUtils.isEmpty(latitude)) {
ToastUtils.showShort(R.string.please_input_latitude)
return
}
val height = mBinding.etHeight.getText().toString().trim()
if (TextUtils.isEmpty(height)) {
ToastUtils.showShort(R.string.please_enter_elevation)
return
}
val levelRouteSave = LevelRouteSave()
levelRouteSave.projectId = projectId
levelRouteSave.routeId = getRouteId()
levelRouteSave.routeName = "$startPointName-$endPointName"
levelRouteSave.startPointName = startPointName
levelRouteSave.endPointName = endPointName
levelRouteSave.levelingMeasureOrder = levelingMeasureOrder
//观测方向
levelRouteSave.observationDirection = getSpinnerText(mBinding.spinnerObservationDirection)
viewModel.startSave(requireContext(), levelRouteSave) { isSuccess: Boolean ->
if (isSuccess) requireActivity().finish()
}
}
private fun getProjectId() = getArgumentString(BundleConstants.KEY_PROJECT_ID)
private fun getRouteId() = getArgumentString(BundleConstants.KEY_ROUTE_ID)
private fun getLocation(resultListener: GetLocationUtil.IResultListener) {
CheckLocationUtil.check(requireContext()) {
getLocation.getResult(resultListener)
}
}
private fun setLocation(
etLongitude: EditText,
etLatitude: EditText,
etHeight: EditText,
result: GetLocationUtil.Result?
) {
setLocation(
etLongitude,
etLatitude,
etHeight,
result?.longitude,
result?.latitude,
result?.altitude
)
}
private fun setLocation(
etLongitude: EditText,
etLatitude: EditText,
etHeight: EditText,
longitude: String?,
latitude: String?,
z: String?
) {
etLongitude.setText(longitude)
etLatitude.setText(latitude)
etHeight.setText(z)
}
private fun setDefaultLocation() {
lifecycleScope.launch(Dispatchers.IO) {
val longitude = ProjectLastData.getLongitude()
val latitude = ProjectLastData.getLatitude()
withContext(Dispatchers.Main) {
if (isEmpty(latitude) || isEmpty(latitude)) {
setLocation(
mBinding.etLongitude,
mBinding.etLatitude,
mBinding.etHeight,
LevelConstant.LONGITUDE_DEFAULT.toString(),
LevelConstant.LATITUDE_DEFAULT.toString(),
LevelConstant.HEIGHT_DEFAULT.toString()
)
} else {
setLocation(
mBinding.etLongitude,
mBinding.etLatitude,
mBinding.etHeight,
longitude,
latitude,
LevelConstant.HEIGHT_DEFAULT.toString()
)
}
}
}
}
private fun isEmpty(value: String?) = TextUtils.isEmpty(value)
}

@ -0,0 +1,158 @@
package com.bingce.controlnetwork.func.level.fragment
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.fragment.app.viewModels
import androidx.lifecycle.lifecycleScope
import androidx.room.withTransaction
import com.bingce.controlapphelper.datasource.database.SurveyorDataBase
import com.bingce.controlapphelper.datasource.database.SurveyorDatabaseFactory
import com.bingce.controlapphelper.datasource.database.leveling.LevelingDbFactory
import com.bingce.controlapphelper.datasource.database.leveling.route.LevelRouteRecord
import com.bingce.controlnetwork.R
import com.bingce.controlnetwork.func.level.viewmodel.LevelCreateOrEditRouteVm
import com.bingce.controlapphelper.model.BundleConstants
import com.bingce.controlnetwork.adapter.contextmenu.ContextMenuDeleteEdit
import com.bingce.controlnetwork.databinding.FragmentListLayoutBinding
import com.bingce.controlnetwork.fragment.TipsFragment
import com.bingce.controlnetwork.func.level.adapter.LevelRouteListAdapter
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
class LevelRouteFragment : Fragment() {
private val createOrEditRouteVm by viewModels<LevelCreateOrEditRouteVm>()
private var _binding: FragmentListLayoutBinding? = null
val mBinding get() = _binding!!
private val dataList = mutableListOf<LevelRouteRecord>()
private val adapter by lazy {
LevelRouteListAdapter(requireContext())
}
private fun doLookAndEditRoute(item: LevelRouteRecord) {
createOrEditRouteVm.showCreateOrEditDialog(
requireContext(),
getProjectId(),
routeId = item.getId()
)
}
private fun doDelete(item: LevelRouteRecord) {
lifecycleScope.launch(Dispatchers.IO) {
val stationList = SurveyorDatabaseFactory.instance.surveyorStation.getByProjectRoute(
item.projectId,
item.getId()
)
var hasData = false
for (stationItem in stationList) {
val recordCount =
SurveyorDatabaseFactory.instance.surveyorRecordDataSource.recordCount(
stationItem.getId()
)
if (recordCount > 0) {
hasData = true
break
}
}
if (hasData) {
withContext(Dispatchers.Main) {
TipsFragment.cancelAbleTips(
childFragmentManager, viewLifecycleOwner, context,
getString(R.string.tips_is_sure_to_delete_route_with_record),
4
) {
deleteDatabase(item)
}
}
} else {
deleteDatabase(item)
}
}
}
private fun deleteDatabase(routeRecord: LevelRouteRecord) {
lifecycleScope.launch(Dispatchers.IO) {
SurveyorDataBase.getInstance().withTransaction {
//删除路线
LevelingDbFactory.instance.levelDataSource.delete(routeRecord)
//删除测站
LevelingDbFactory.instance.stationDataSource.deleteByRouteId(routeRecord.getId())
}
}
}
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View {
_binding = FragmentListLayoutBinding.inflate(inflater, container, false)
return mBinding.root
}
override fun onDestroyView() {
super.onDestroyView()
_binding = null
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
initAdapter()
LevelingDbFactory.instance.levelDataSource.getListLiveData(getProjectId())
.observe(viewLifecycleOwner) {
adapter.refreshData(it)
}
}
private fun initAdapter() {
mBinding.list.adapter = adapter
adapter.setAdapterContextMenu(object : ContextMenuDeleteEdit<LevelRouteRecord>() {
override fun delete(item: LevelRouteRecord) {
doDelete(item)
}
override fun edit(item: LevelRouteRecord) {
doLookAndEditRoute(item)
}
})
}
fun getProjectId() = requireArguments().getString(BundleConstants.KEY_PROJECT_ID)!!
companion object {
@JvmStatic
fun newInstance(projectId: String): LevelRouteFragment {
val bundle = Bundle()
bundle.putString(BundleConstants.KEY_PROJECT_ID, projectId)
val routeFragment = LevelRouteFragment()
routeFragment.arguments = bundle
return routeFragment
}
}
/**
* 获取即将要测量的路线id
*/
fun getSurveyorRouteId(): String? {
if (dataList.isNotEmpty()) {
return dataList.last().getId()
}
return null
}
}

@ -0,0 +1,248 @@
package com.bingce.controlnetwork.func.level.fragment;
import android.content.Context;
import android.os.Bundle;
import android.os.Environment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.fragment.app.DialogFragment;
import androidx.lifecycle.ViewModelProvider;
import com.bingce.controlapphelper.surveyor.method.ExportUtils;
import com.bingce.controlapphelper.util.CheckStorageUtil;
import com.bingce.controlapphelper.util.Tools;
import com.bingce.controlapphelper.widget.treeview.TreeNode;
import com.bingce.controlapphelper.widget.treeview.TreeView;
import com.bingce.controlapphelper.widget.treeview.custom.MyNodeViewFactory;
import com.bingce.controlnetwork.BuildConfig;
import com.bingce.controlnetwork.R;
import com.bingce.controlnetwork.activity.fragmentcontainer.FragmentContainerActivity;
import com.bingce.controlnetwork.databinding.FragmentSelectExportBinding;
import com.bingce.controlnetwork.fragment.FullLoadingFragment;
import com.bingce.controlnetwork.fragment.TipsWith2OptionFragment;
import com.bingce.controlnetwork.func.level.util.LevelExportUtilTj;
import com.bingce.controlnetwork.func.level.viewmodel.LevelSelectExportVm;
import com.bingce.controlnetwork.newui.base.BaseFragmentBinding;
import com.bingce.file.FileOperator;
import com.bingce.utils.ThreadPoolUtil;
import com.bingce.zip.ZipUtil;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import blankj.utilcode.util.FileUtils;
import blankj.utilcode.util.ToastUtils;
/**
* 水准选择导出
*/
public class LevelSelectExportFragment extends BaseFragmentBinding<FragmentSelectExportBinding> {
public static final String TAG = LevelSelectExportFragment.class.getName();
private LevelSelectExportVm viewModel;
private TreeNode rootNode;
public static LevelSelectExportFragment newInstance(Bundle args) {
LevelSelectExportFragment fragment = new LevelSelectExportFragment();
fragment.setArguments(args);
return fragment;
}
public static void start(Context context) {
FragmentContainerActivity.start(context, TAG, R.string.level_export, null);
}
@Override
protected FragmentSelectExportBinding getViewBinding(@NonNull LayoutInflater inflater, ViewGroup container) {
return FragmentSelectExportBinding.inflate(inflater, container, false);
}
@Override
protected void initView() {
viewModel = new ViewModelProvider(this).get(LevelSelectExportVm.class);
mBinding.title.setText(R.string.tips_select_expected_export_data_level);
initListener();
}
private void initListener() {
mBinding.export.setOnClickListener(v -> {
if (ExportUtils.isCanExport()) {
CheckStorageUtil.check(requireContext(), this::startExport);
}
});
}
private void startExport() {
DialogFragment dialogFragment = FullLoadingFragment.showLoading(getChildFragmentManager());
doExport(new ICallback() {
@Override
public void onFailureInMainThread(String msg) {
dialogFragment.dismiss();
ToastUtils.showShort(msg);
}
@Override
public void onSuccessInMainThread(File zip) {
if (dialogFragment.isVisible()) {
dialogFragment.dismiss();
}
TipsWith2OptionFragment.tipsCannotCancel(getChildFragmentManager(), getViewLifecycleOwner(),
getString(R.string.share),
getString(R.string.cancel),
getString(R.string.export_successful),
new TipsWith2OptionFragment.SimpleCallback() {
@Override
public void onConfirm() {
FileOperator.shareFile(getContext(), zip, BuildConfig.APPLICATION_ID);
}
});
}
});
}
private void doExport(ICallback callback) {
List<TreeNode> projectList = rootNode.getChildren();
ThreadPoolUtil.execute(() -> {
List<ExportRoute> exportRouteList = new ArrayList<>();
HashSet<String> exportProjectIdSet = new HashSet<>();
for (TreeNode projectNode : projectList) {
List<TreeNode> children = projectNode.getChildren();
for (TreeNode routeNode : children) {
if (routeNode.isEnable() && routeNode.isSelected()) {
String projectId = projectNode.getValue().getId();
String projectName = projectNode.getValue().getValue().toString();
exportProjectIdSet.add(projectId);
exportRouteList.add(new ExportRoute(projectId, projectName,
routeNode.getValue().getId(),
routeNode.getValue().getValue().toString()));
}
}
}
if (exportRouteList.isEmpty()) {
backError(callback, "没有要导出的数据");
return;
}
try {
LevelExportUtilTj levelExportUtilTj = new LevelExportUtilTj();
//导出路线数据
for (ExportRoute exportRoute : exportRouteList) {
levelExportUtilTj.doExportRouteData(exportRoute.projectId,
exportRoute.routeId);
}
for (String projectId : exportProjectIdSet) {
//导出项目数据
levelExportUtilTj.exportProjectTxt(projectId);
//导出点信息
levelExportUtilTj.exportControlTxt(projectId);
//导出i角检测
levelExportUtilTj.exportIDetection(projectId);
//导出SingalHeight和平差准备文件
levelExportUtilTj.exportTjSingalHeight(projectId);
}
} catch (Exception e) {
e.printStackTrace();
backError(callback, Tools.getString(R.string.export_failure));
File sourceFileFolder = LevelExportUtilTj.Companion.getExportOutFolder();
FileUtils.delete(sourceFileFolder);
return;
}
//压缩文件
File file = startZipFile();
if (file == null) {
return;
}
ThreadPoolUtil.executeInMain(() -> callback.onSuccessInMainThread(file));
});
}
private void backError(ICallback callback, String msg) {
ThreadPoolUtil.executeInMain(() -> callback.onFailureInMainThread(msg));
}
private File startZipFile() {
//源数据文件
File sourceFileFolder = LevelExportUtilTj.Companion.getExportOutFolder();
if (!sourceFileFolder.exists()) return null;
File[] files = sourceFileFolder.listFiles();
if (files == null || files.length == 0) return null;
List<File> sourceFileList = Arrays.asList(files);
//将文件存储到一个zip中
File zipFolder = new File(Environment.getExternalStorageDirectory(), ExportUtils.getExportFirstDirectory());
if (!zipFolder.exists()) {
zipFolder.mkdir();
}
Date date = new Date();
SimpleDateFormat format = new SimpleDateFormat("yyyy_MM_dd_HH_mm_ss", Locale.getDefault());
String dateString = format.format(date);
File zip = new File(zipFolder, "水准数据_" + dateString + ".zip");
if (!ZipUtil.zip(zip, sourceFileList)) {
ToastUtils.showShort(R.string.export_failure);
return null;
}
try {
//存储成功,删除被压缩的源文件
FileUtils.delete(sourceFileFolder);
} catch (Exception e) {
e.printStackTrace();
ToastUtils.showShort(R.string.export_failure);
return null;
}
return zip;
}
@Override
protected void initData() {
viewModel.initData(treeNode -> {
setData(treeNode);
return null;
});
}
private void setData(TreeNode treeNode) {
rootNode = treeNode;
TreeView treeView = new TreeView(treeNode, requireContext(), new MyNodeViewFactory());
treeView.setup(mBinding.list);
mBinding.list.setVisibility(View.VISIBLE);
mBinding.loading.setVisibility(View.GONE);
}
private interface ICallback {
void onFailureInMainThread(String msg);
void onSuccessInMainThread(File zip);
}
private static class ExportRoute {
public String projectId;
public String projectName;
public String routeId;
public String routeName;
public ExportRoute(String projectId, String projectName, String routeId, String routeName) {
this.projectId = projectId;
this.projectName = projectName;
this.routeId = routeId;
this.routeName = routeName;
}
}
}

@ -0,0 +1,185 @@
package com.bingce.controlnetwork.func.level.fragment
import android.text.TextUtils
import android.view.LayoutInflater
import android.view.ViewGroup
import android.widget.ArrayAdapter
import androidx.fragment.app.activityViewModels
import blankj.utilcode.util.ToastUtils
import com.bingce.controlnetwork.func.level.constant.LevelStationSettingContant
import com.bingce.controlnetwork.func.level.util.LevelStationSettingUtil
import com.bingce.controlnetwork.func.level.viewmodel.LevelStationSettingVm
import com.bingce.controlapphelper.model.LevelRouteSave
import com.bingce.controlapphelper.surveyor.method.model.MeasureConstant
import com.bingce.controlnetwork.databinding.FragmentLevelStationSettingConditionBinding
import com.bingce.controlnetwork.newui.base.BaseFragmentBinding
import com.bingce.controlnetwork.newui.stationsetting.IStationSettingOperate
/**
* 水准测站设置-观测条件
*/
class LevelStationSettingConditionFragment :
BaseFragmentBinding<FragmentLevelStationSettingConditionBinding>(), IStationSettingOperate {
private val stationSettingVm by activityViewModels<LevelStationSettingVm>()
private lateinit var levelRouteSave: LevelRouteSave
override fun getViewBinding(
inflater: LayoutInflater,
container: ViewGroup?
): FragmentLevelStationSettingConditionBinding {
return FragmentLevelStationSettingConditionBinding.inflate(inflater, container, false)
}
override fun initView() {
initEditTextTitle()
}
private fun initEditTextTitle() {
mBinding.ilTemperature.tvTitle.text = "温度(℃)"
}
override fun initData() {
initSpinnerWeather()
initSpinnerImaging()
initSpinnerSunDirection()
initSpinnerWindDirection()
initSpinnerWindSpeed()
initSpinnerRoads()
initSpinnerSoil()
stationSettingVm.editLastDataLiveData.observe(viewLifecycleOwner) {
if (it == null) {
setTemperatureData(MeasureConstant.DEFAULT_TEMPERATURE)
} else {
setData(it)
}
}
}
private fun initSpinnerSoil() {
mBinding.spinnerSoil.adapter = ArrayAdapter(
requireContext(),
android.R.layout.simple_list_item_1,
LevelStationSettingContant.soilList
)
}
private fun initSpinnerRoads() {
mBinding.spinnerRoads.adapter = ArrayAdapter(
requireContext(),
android.R.layout.simple_list_item_1,
LevelStationSettingContant.roadsList
)
}
private fun initSpinnerWindSpeed() {
mBinding.spinnerWindSpeed.adapter = ArrayAdapter(
requireContext(),
android.R.layout.simple_list_item_1,
LevelStationSettingContant.windSpeedList
)
}
private fun initSpinnerWindDirection() {
mBinding.spinnerWindDirection.adapter = ArrayAdapter(
requireContext(),
android.R.layout.simple_list_item_1,
LevelStationSettingContant.windDirectionList
)
}
private fun initSpinnerSunDirection() {
mBinding.spinnerSunDirection.adapter = ArrayAdapter(
requireContext(),
android.R.layout.simple_list_item_1,
LevelStationSettingContant.sunDirectionList
)
}
private fun initSpinnerImaging() {
mBinding.spinnerImaging.adapter = ArrayAdapter(
requireContext(),
android.R.layout.simple_list_item_1,
LevelStationSettingContant.imagingList
)
}
private fun initSpinnerWeather() {
mBinding.spinnerWeather.adapter = ArrayAdapter(
requireContext(),
android.R.layout.simple_list_item_1,
LevelStationSettingContant.weatherList
)
}
override fun checkSaveNot(): Boolean {
if (isEmpty(mBinding.ilTemperature.editText.text.toString().trim())) {
ToastUtils.showShort("请输入温度")
return true
}
collectData()
return false
}
override fun setDataToStation() {
stationSettingVm.addConditionDataToLevelRouteSave(levelRouteSave)
}
private fun collectData() {
levelRouteSave = LevelRouteSave()
levelRouteSave.temperature = mBinding.ilTemperature.editText.text.toString().trim()
levelRouteSave.weather = LevelStationSettingUtil.getSpinnerText(mBinding.spinnerWeather)
levelRouteSave.imaging = LevelStationSettingUtil.getSpinnerText(mBinding.spinnerImaging)
levelRouteSave.sunDirection =
LevelStationSettingUtil.getSpinnerText(mBinding.spinnerSunDirection)
levelRouteSave.windDirection =
LevelStationSettingUtil.getSpinnerText(mBinding.spinnerWindDirection)
levelRouteSave.windSpeed = LevelStationSettingUtil.getSpinnerText(mBinding.spinnerWindSpeed)
levelRouteSave.roads = LevelStationSettingUtil.getSpinnerText(mBinding.spinnerRoads)
levelRouteSave.soil = LevelStationSettingUtil.getSpinnerText(mBinding.spinnerSoil)
}
private fun isEmpty(value: String?) = TextUtils.isEmpty(value)
private fun setData(levelRouteSave: LevelRouteSave) {
setTemperatureData(levelRouteSave.temperature)
mBinding.spinnerWeather.setSelection(
LevelStationSettingContant.weatherList.indexOf(
levelRouteSave.weather
)
)
mBinding.spinnerImaging.setSelection(
LevelStationSettingContant.imagingList.indexOf(
levelRouteSave.imaging
)
)
mBinding.spinnerSunDirection.setSelection(
LevelStationSettingContant.sunDirectionList.indexOf(
levelRouteSave.sunDirection
)
)
mBinding.spinnerWindDirection.setSelection(
LevelStationSettingContant.windDirectionList.indexOf(
levelRouteSave.windDirection
)
)
mBinding.spinnerWindSpeed.setSelection(
LevelStationSettingContant.windSpeedList.indexOf(
levelRouteSave.windSpeed
)
)
mBinding.spinnerRoads.setSelection(
LevelStationSettingContant.roadsList.indexOf(
levelRouteSave.roads
)
)
mBinding.spinnerSoil.setSelection(LevelStationSettingContant.soilList.indexOf(levelRouteSave.soil))
}
private fun setTemperatureData(value: String?) {
mBinding.ilTemperature.editText.setText(value)
}
}

@ -0,0 +1,201 @@
package com.bingce.controlnetwork.func.level.fragment
import android.text.TextUtils
import android.view.Gravity
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ArrayAdapter
import android.widget.TextView
import androidx.fragment.app.activityViewModels
import blankj.utilcode.util.ToastUtils
import com.bingce.controlnetwork.func.level.constant.LevelStationSettingContant
import com.bingce.controlnetwork.func.level.util.LevelStationSettingUtil
import com.bingce.controlnetwork.func.level.viewmodel.LevelStationSettingVm
import com.bingce.controlapphelper.model.LevelRouteSave
import com.bingce.controlapphelper.util.Tools
import com.bingce.controlnetwork.R
import com.bingce.controlnetwork.databinding.FragmentLevelStationSettingInformationBinding
import com.bingce.controlnetwork.newui.base.BaseFragmentBinding
import com.bingce.controlnetwork.newui.stationsetting.IStationSettingOperate
import com.bingce.controlnetwork.widget.editspinner.EditSpinner
import com.bingce.controlnetwork.widget.editspinner.SimpleAdapter
/**
* 水准测站设置-观测信息
*/
class LevelStationSettingInformationFragment :
BaseFragmentBinding<FragmentLevelStationSettingInformationBinding>(), IStationSettingOperate {
private val viewModel by activityViewModels<LevelStationSettingVm>()
private lateinit var levelRouteSave: LevelRouteSave
override fun getViewBinding(
inflater: LayoutInflater,
container: ViewGroup?
): FragmentLevelStationSettingInformationBinding {
return FragmentLevelStationSettingInformationBinding.inflate(inflater, container, false)
}
override fun initView() {
initEditTextTitle()
initSpinnerRulerType()
initRulerReceptType()
viewModel.initHasTwoRuler { hasTwoRuler ->
if (hasTwoRuler) {
mBinding.ilFirstStationBackFootNumber.tvTitle.setText(R.string.first_station_back_foot_number_l)
mBinding.ilFirstStationFrontFootNumber.tvTitle.setText(R.string.first_station_front_foot_number_l)
mBinding.llRuler2.visibility = View.VISIBLE
} else {
mBinding.llRuler2.visibility = View.GONE
}
}
}
/**
* 初始化editText坐标的title
*/
private fun initEditTextTitle() {
mBinding.ilWatcher.tvTitle.text = "观测者"
mBinding.ilRecorder.tvTitle.text = "记录者"
mBinding.ilExaminer.tvTitle.text = "检查者"
mBinding.ilFirstStationBackFootNumber.tvTitle.text =
Tools.getString(R.string.first_station_back_foot_number)
mBinding.ilFirstStationFrontFootNumber.tvTitle.text =
Tools.getString(R.string.first_station_front_foot_number)
mBinding.ilFirstStationBackFootNumber2.tvTitle.text =
Tools.getString(R.string.first_station_back_foot_number_r)
mBinding.ilFirstStationFrontFootNumber2.tvTitle.text =
Tools.getString(R.string.first_station_front_foot_number_r)
mBinding.ilInstrumentModel.tvTitle.text = "仪器型号"
mBinding.ilDeviceNumber.tvTitle.text = "仪器编号"
mBinding.ilSteelRuleParam.tvTitle.text = "标尺因瓦带膨胀系数"
mBinding.ilRulerCorrectionFactor.tvTitle.text = "标尺改正系数(mm/m)"
mBinding.ilRulerLengthProvingTemperature.tvTitle.text = "标尺长度检定温度(℃)"
}
private fun initRulerReceptType() {
initEditSpinner(
mBinding.ilEditSpinnerRulerRecept.tvName,
"尺承类型",
mBinding.ilEditSpinnerRulerRecept.etSpinner,
"请输入或选择"
)
val adapter =
SimpleAdapter(requireContext(), LevelStationSettingContant.rulerReceptTypeList)
mBinding.ilEditSpinnerRulerRecept.etSpinner.setAdapter(adapter)
}
private fun initSpinnerRulerType() {
mBinding.spinnerRulerType.adapter = ArrayAdapter(
requireContext(),
android.R.layout.simple_list_item_1,
LevelStationSettingContant.rulerTypeList
)
}
override fun initData() {
viewModel.editLastDataLiveData.observe(viewLifecycleOwner) {
if (it == null) {
setRulerReceptTypeData("不足5kg尺台")
} else {
setData(it)
}
}
}
override fun checkSaveNot(): Boolean {
collectData()
if (isEmpty(levelRouteSave.frontFootNumber)) {
ToastUtils.showShort(R.string.first_station_front_foot_number_hint)
return true
}
if (isEmpty(levelRouteSave.backFootNumber)) {
ToastUtils.showShort(R.string.first_station_back_foot_number_hint)
return true
}
if (mBinding.llRuler2.visibility == View.VISIBLE) {
if (isEmpty(levelRouteSave.frontFootNumber2)) {
ToastUtils.showShort(R.string.first_station_front_foot_number_hint)
return true
}
if (isEmpty(levelRouteSave.backFootNumber2)) {
ToastUtils.showShort(R.string.first_station_back_foot_number_hint)
return true
}
}
return false
}
override fun setDataToStation() {
viewModel.addInforDataToLevelRouteSave(levelRouteSave)
}
private fun collectData() {
levelRouteSave = LevelRouteSave()
levelRouteSave.watcher = mBinding.ilWatcher.editText.text.toString().trim()
levelRouteSave.recorder = mBinding.ilRecorder.editText.text.toString().trim()
levelRouteSave.examiner = mBinding.ilExaminer.editText.text.toString().trim()
levelRouteSave.frontFootNumber =
mBinding.ilFirstStationFrontFootNumber.editText.text.toString().trim()
levelRouteSave.backFootNumber =
mBinding.ilFirstStationBackFootNumber.editText.text.toString().trim()
if (mBinding.llRuler2.visibility == View.VISIBLE) {
levelRouteSave.frontFootNumber2 =
mBinding.ilFirstStationFrontFootNumber2.editText.text.toString().trim()
levelRouteSave.backFootNumber2 =
mBinding.ilFirstStationBackFootNumber2.editText.text.toString().trim()
}
levelRouteSave.instrumentModel = mBinding.ilInstrumentModel.editText.text.toString().trim()
levelRouteSave.deviceNumber = mBinding.ilDeviceNumber.editText.text.toString().trim()
levelRouteSave.steelRuleParam = mBinding.ilSteelRuleParam.editText.text.toString().trim()
levelRouteSave.rulerCorrectionFactor =
mBinding.ilRulerCorrectionFactor.editText.text.toString().trim()
levelRouteSave.rulerLengthProvingTemperature =
mBinding.ilRulerLengthProvingTemperature.editText.text.toString().trim()
levelRouteSave.rulerType = LevelStationSettingUtil.getSpinnerText(mBinding.spinnerRulerType)
levelRouteSave.rulerReceptType = mBinding.ilEditSpinnerRulerRecept.etSpinner.text.trim()
}
private fun isEmpty(value: String?) = TextUtils.isEmpty(value)
private fun setData(levelRouteSave: LevelRouteSave) {
mBinding.ilWatcher.editText.setText(levelRouteSave.watcher)
mBinding.ilRecorder.editText.setText(levelRouteSave.recorder)
mBinding.ilExaminer.editText.setText(levelRouteSave.examiner)
mBinding.ilFirstStationBackFootNumber.editText.setText(levelRouteSave.backFootNumber)
mBinding.ilFirstStationFrontFootNumber.editText.setText(levelRouteSave.frontFootNumber)
mBinding.ilFirstStationBackFootNumber2.editText.setText(levelRouteSave.backFootNumber2)
mBinding.ilFirstStationFrontFootNumber2.editText.setText(levelRouteSave.frontFootNumber2)
mBinding.ilInstrumentModel.editText.setText(levelRouteSave.instrumentModel)
mBinding.ilDeviceNumber.editText.setText(levelRouteSave.deviceNumber)
mBinding.ilSteelRuleParam.editText.setText(levelRouteSave.steelRuleParam)
mBinding.ilRulerCorrectionFactor.editText.setText(levelRouteSave.rulerCorrectionFactor)
mBinding.ilRulerLengthProvingTemperature.editText.setText(levelRouteSave.rulerLengthProvingTemperature)
mBinding.spinnerRulerType.setSelection(
LevelStationSettingContant.rulerTypeList.indexOf(
levelRouteSave.rulerType
)
)
setRulerReceptTypeData(levelRouteSave.rulerReceptType)
}
private fun setRulerReceptTypeData(value: String?) {
mBinding.ilEditSpinnerRulerRecept.etSpinner.text = value
}
private fun initEditSpinner(
textView: TextView,
textViewName: String,
view: EditSpinner,
textHint: String
) {
textView.text = textViewName
view.setHint(textHint)
view.setEtGravity(Gravity.CENTER_VERTICAL or Gravity.END)
}
}

@ -0,0 +1,497 @@
package com.bingce.controlnetwork.func.level.fragment;
import android.content.Context;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentStatePagerAdapter;
import androidx.lifecycle.ViewModelProvider;
import androidx.viewpager.widget.PagerAdapter;
import androidx.viewpager.widget.ViewPager;
import com.bingce.controlapphelper.datasource.database.leveling.station.LevelingStationRecord;
import com.bingce.controlapphelper.leveling.detaction.ILevelRefreshBtn;
import com.bingce.controlapphelper.leveling.detaction.INextStation;
import com.bingce.controlapphelper.leveling.detaction.LevelCheckBtnUtil;
import com.bingce.controlapphelper.leveling.detaction.LevelReceiveData;
import com.bingce.controlapphelper.model.BundleConstants;
import com.bingce.controlapphelper.surveyor.test.Test;
import com.bingce.controlapphelper.util.Tools;
import com.bingce.controlnetwork.R;
import com.bingce.controlnetwork.activity.fragmentcontainer.FragmentContainerActivity;
import com.bingce.controlnetwork.databinding.FragmentLevelSurveyorBinding;
import com.bingce.controlnetwork.fragment.TipsFragment;
import com.bingce.controlnetwork.func.level.activity.LevelStationSettingActivity;
import com.bingce.controlnetwork.func.level.viewmodel.LevelSuveyorVm;
import com.bingce.controlnetwork.newui.base.BaseFragmentBinding;
import com.bingce.controlnetwork.util.DialogUtil;
import com.bingce.controlnetwork.util.StationSettingCheckUtil;
import com.bingce.utils.ThreadPoolUtil;
import java.util.ArrayList;
import java.util.List;
import blankj.utilcode.util.ToastUtils;
import com.bingce.controlnetwork.func.level.sendreceive.ILevelBackData;
import com.bingce.controlnetwork.func.level.sendreceive.LevelRequest;
import cn.liuyanbing.surveyor.function.level.sendreceive.LevelRequestRelease;
import com.bingce.controlnetwork.func.level.sendreceive.LevelRequestTest;
/**
* 水准测量页
*/
public class LevelSurveyFragment extends BaseFragmentBinding<FragmentLevelSurveyorBinding> {
public static final String TAG = LevelSurveyFragment.class.getName();
public static final String KEY_STATION_INDEX = "STATION_INDEX";
private LevelSuveyorVm viewModel;
private List<LevelSurveySubFragment> fragments;
private MenuItem rollBackBtn;
private MenuItem reMeasureStationBtn;
private StationSettingCheckUtil stationSettingCheckUtil;
private final INextStation nextStationI = this::showSelectLevelNextStepDialog;
private LevelRequest levelRequest;
private final ILevelBackData levelBackData = new ILevelBackData() {
@Override
public void receive(@NonNull LevelReceiveData data) {
receiveData(data);
}
@Override
public void measureError(@NonNull String msg) {
if (getView() == null) {
return;
}
DialogUtil.showAlertDialog(requireContext(), getChildFragmentManager(), getViewLifecycleOwner(), msg);
}
};
private MyPagerAdapter myPagerAdapter;
private void receiveData(LevelReceiveData data) {
if (getView() == null) {
return;
}
LevelSurveySubFragment currentFragment = getCurrentFragment();
if (currentFragment != null) {
currentFragment.recieveData(data);
}
}
private final ILevelRefreshBtn levelRefreshBtnI = new ILevelRefreshBtn() {
@Override
public void refreshMeasureBtn() {
boolean measureEnable = LevelCheckBtnUtil.getMeasureEnable(viewModel.getCurrentStationId());
ThreadPoolUtil.executeInMain(() -> {
setViewEnable(mBinding.surveyor, measureEnable);
setViewEnable(mBinding.btnInput, measureEnable);
});
}
@Override
public void refreshNextStationBtn() {
boolean measureEnable = LevelCheckBtnUtil.getNextStationEnable(viewModel.getCurrentStationId());
ThreadPoolUtil.executeInMain(() -> setViewEnable(mBinding.btnNextStation, measureEnable));
}
@Override
public void refreshRollBackBtn() {
doRefreshRollBackBtn();
}
@Override
public void refreshReMeasureBtn() {
doRefreshReMeasureBtn();
}
};
private void doRefreshReMeasureBtn() {
if (reMeasureStationBtn != null) {
boolean measureEnable = LevelCheckBtnUtil.getReMeasureStationEnable(viewModel.getCurrentStationId());
ThreadPoolUtil.executeInMain(() -> reMeasureStationBtn.setEnabled(measureEnable));
}
}
private void doRefreshRollBackBtn() {
if (rollBackBtn != null) {
boolean measureEnable = LevelCheckBtnUtil.getRollBackEnable(viewModel.getCurrentStationId());
ThreadPoolUtil.executeInMain(() -> rollBackBtn.setEnabled(measureEnable));
}
}
public static void start(Context context, String projectId, String routeId, String routeName) {
Bundle bundle = new Bundle();
bundle.putString(BundleConstants.KEY_PROJECT_ID, projectId);
bundle.putString(BundleConstants.KEY_ROUTE_ID, routeId);
bundle.putString(BundleConstants.KEY_ROUTE_NAME, routeName);
FragmentContainerActivity.start(context, TAG, "水准测量", bundle);
}
public static Fragment newInstance(Bundle args) {
Fragment fragment = new LevelSurveyFragment();
fragment.setArguments(args);
return fragment;
}
@Override
protected FragmentLevelSurveyorBinding getViewBinding(@NonNull LayoutInflater inflater, ViewGroup container) {
return FragmentLevelSurveyorBinding.inflate(inflater, container, false);
}
@Override
public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
inflater.inflate(R.menu.menu_level_survey, menu);
rollBackBtn = menu.findItem(R.id.rollBack);
reMeasureStationBtn = menu.findItem(R.id.reMeasureStation);
doRefreshRollBackBtn();
doRefreshReMeasureBtn();
}
@Override
public void onPrepareOptionsMenu(@NonNull Menu menu) {
if (Test.DEBUG) {
menu.findItem(R.id.test).setVisible(true);
}
super.onPrepareOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
if (R.id.rollBack == item.getItemId()) {
showConfirmDialog(getString(R.string.level_roll_back_hint), () -> {
LevelSurveySubFragment currentFragment = getCurrentFragment();
if (currentFragment != null) {
currentFragment.startRollBack();
}
});
} else if (R.id.reMeasureStation == item.getItemId()) {
showConfirmDialog(getString(R.string.level_remeasure_station_hint), () -> {
LevelSurveySubFragment currentFragment = getCurrentFragment();
if (currentFragment != null) {
currentFragment.reMeasureStation();
}
});
} else if (R.id.surveyorSettings == item.getItemId()) {
LevelingStationRecord currentStation = viewModel.getCurrentStation();
if (currentStation != null) {
LevelStationSettingActivity.start(requireContext(), getRouteId(), currentStation.getId(), false);
}
} else if (R.id.levelRouteResult == item.getItemId()) {
viewModel.calLevelRouteResult(result -> {
DialogUtil.showAlertDialog(requireContext(), getChildFragmentManager(), getViewLifecycleOwner(), result);
return null;
});
} else if (R.id.receiveDataType == item.getItemId()) {
LevelInputAllowFragment.show(getChildFragmentManager(), getViewLifecycleOwner(),
mBinding.surveyor.getVisibility() == View.VISIBLE,//是否仪器获取数据
auto -> {
viewModel.setGetDataAuto(getRouteId(), auto);
refreshManuleAutoInput(auto);
});
} else if (R.id.test == item.getItemId()) {
TestDataSelectLevelFragment.show(getChildFragmentManager(), position -> {
LevelRequestTest levelReceiveData1 = (LevelRequestTest) levelRequest;
levelReceiveData1.initTestData(position);
});
} else if (R.id.rollBackStation == item.getItemId()) {
startRollBackStation();
}
return super.onOptionsItemSelected(item);
}
private void startRollBackStation() {
if (!viewModel.getMeasureStationList().isEmpty()) {
String lastStationId = viewModel.getMeasureStationList().get(0).lastStationId;
if (TextUtils.isEmpty(lastStationId)) {
ToastUtils.showShort("没有上一站了");
return;
}
showConfirmDialog("是否要回退至上一站,该操作将清空当前站所有数据", () -> {
viewModel.rollBackStation();
});
}
}
@Override
public void onDestroyView() {
super.onDestroyView();
// EventBus.getDefault().unregister(this);
levelRequest.onDestroy();
LevelCheckBtnUtil.destroy();
}
@Override
protected void initView() {
setHasOptionsMenu(true);
initLevelRequest();
stationSettingCheckUtil = new StationSettingCheckUtil();
viewModel = new ViewModelProvider(this).get(LevelSuveyorVm.class);
viewModel.initData(levelRefreshBtnI, () -> {
initViewPager();
return null;
}, integer -> {
mBinding.vp.setCurrentItem(integer);
return null;
}, nextStationI);
viewModel.getGetDadaAuto(getRouteId(), auto -> {
refreshManuleAutoInput(auto);
return null;
});
initTitle();
initListener();
}
private void initLevelRequest() {
if (Test.DEBUG) {
levelRequest = new LevelRequestTest(levelBackData);
} else {
levelRequest = new LevelRequestRelease(levelBackData);
}
levelRequest.onStart();
}
private void initTitle() {
mBinding.tvRouteName.setText("测段:" + getRouteName());
}
@Override
protected void initData() {
viewModel.initDataStationList(getProjectId(), getRouteId());
viewModel.checkSunTime(getProjectId(), hint -> {
if (!TextUtils.isEmpty(hint)) {
DialogUtil.showAlertDialog(requireContext(), getChildFragmentManager(), getViewLifecycleOwner(), hint);
}
return null;
});
}
private void initListener() {
mBinding.surveyor.setOnClickListener(v -> {
stationSettingCheckUtil.checkStationSettingsLevel(viewModel.getCurrentStationId(), getChildFragmentManager(), this,
requireContext(),
this,
() -> levelRequest.requeset());
});
mBinding.btnNextStation.setOnClickListener(v -> {
stationSettingCheckUtil.checkStationSettingsLevel(viewModel.getCurrentStationId(), getChildFragmentManager(), this,
requireContext(),
this,
() -> {
LevelSurveySubFragment currentFragment = getCurrentFragment();
if (currentFragment != null) {
currentFragment.nextStation();
}
});
});
mBinding.btnInput.setOnClickListener(v -> {
stationSettingCheckUtil.checkStationSettingsLevel(viewModel.getCurrentStationId(), getChildFragmentManager(), this,
requireContext(),
this,
() -> {
runOnUI(() -> {
LevelInputFragment.show(getChildFragmentManager(), getViewLifecycleOwner(),
(distance, height) -> receiveData(new LevelReceiveData(height, distance)));
});
});
});
}
private String getProjectId() {
return getArgumentString(BundleConstants.KEY_PROJECT_ID);
}
private String getRouteId() {
return getArgumentString(BundleConstants.KEY_ROUTE_ID);
}
private String getRouteName() {
return getArgumentString(BundleConstants.KEY_ROUTE_NAME);
}
private void initViewPager() {
fragments = new ArrayList<>();
for (int i = 0; i < viewModel.getMeasureStationList().size(); i++) {
fragments.add(LevelSurveySubFragment.newInstance(i));
}
if (myPagerAdapter == null) {
mBinding.vp.setOffscreenPageLimit(3);
myPagerAdapter = new MyPagerAdapter(getChildFragmentManager());
mBinding.vp.setAdapter(myPagerAdapter);
mBinding.tabLayout.setViewPager(mBinding.vp);
mBinding.vp.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
public void onPageSelected(int position) {
viewModel.setCurrentFragmentPos(position);
viewModel.switchRefreshBtnEnable();
}
@Override
public void onPageScrollStateChanged(int state) {
}
});
} else {
myPagerAdapter.notifyDataSetChanged();
mBinding.tabLayout.notifyDataSetChanged();
mBinding.tabLayout.setCurrentTab(0);
}
}
private LevelSurveySubFragment getCurrentFragment() {
int currentFragmentPos = viewModel.getCurrentFragmentPos();
if (fragments != null && fragments.size() > currentFragmentPos) {
return fragments.get(currentFragmentPos);
}
return null;
}
private void setViewEnable(View view, boolean measureEnable) {
view.setEnabled(measureEnable);
if (measureEnable) {
view.setAlpha(1);
} else {
view.setAlpha(.4f);
}
}
private class MyPagerAdapter extends FragmentStatePagerAdapter {
public MyPagerAdapter(FragmentManager fm) {
super(fm);
}
@Override
public int getCount() {
return fragments.size();
}
@Override
public CharSequence getPageTitle(int position) {
return viewModel.getMeasureStationList().get(position).stationName;
}
@Override
public Fragment getItem(int position) {
return fragments.get(position);
}
@Override
public int getItemPosition(@NonNull Object object) {
return PagerAdapter.POSITION_NONE;
}
}
private void showConfirmDialog(String content, TipsFragment.IConfirmCallback callback) {
TipsFragment.cancelAbleTips(getChildFragmentManager(), getViewLifecycleOwner(), requireContext(),
content, -1, callback);
}
/**
* 下一站的弹框
*/
private void showSelectLevelNextStepDialog(LevelingStationRecord station) {
runOnUI(() -> SelectLevelNextStationTypeFragment.select(getChildFragmentManager(), getViewLifecycleOwner(), type -> {
switch (type) {
case SelectLevelNextStationTypeFragment.TYPE_CONTINUE_OBSERVE:
//继续观测
startMeasureNextStation(station);
break;
case SelectLevelNextStationTypeFragment.TYPE_INTERMITTENT:
viewModel.intermittent(station);
break;
case SelectLevelNextStationTypeFragment.TYPE_END_STATION:
checkEndStation(station);
break;
}
}));
}
/**
* 点击结束测站时验证
*
* @param station
*/
private void checkEndStation(LevelingStationRecord station) {
ThreadPoolUtil.execute(() -> {
//增加确认结束测站的提醒
if (station.isOddStation()) {
//当前是奇数站
ToastUtils.showShort("结束测站必须是偶数站!");
return;
}
//是否设置过结束测站的测站设置
boolean isSetEndStationSetting = viewModel.isHaveSetEndStationSetting(station.getId());
if (!isSetEndStationSetting) {
runOnUI(() -> StationSettingCheckUtil.showLevelSetStationSetting(getChildFragmentManager(),
getViewLifecycleOwner(), getContext(), StationSettingCheckUtil.HINT_LEVEL_END,
getRouteId(), station.getId(), true));
return;
}
runOnUI(() -> showConfirmEndRouteStartEndStation(station));
});
}
/**
* 下一站继续观测
*/
public void startMeasureNextStation(LevelingStationRecord station) {
viewModel.contineObserve(station);
}
/**
* 结束路线开始下一站的确认提醒
*
* @param station
*/
private void showConfirmEndRouteStartEndStation(LevelingStationRecord station) {
DialogUtil.showConfirmDialog(getChildFragmentManager(), getViewLifecycleOwner(), Tools.getString(R.string.level_end_route_hint), Tools.getString(R.string.confirm), new DialogUtil.IConfirmBack() {
@Override
public void onConfirm() {
viewModel.endStation(station);
}
});
}
private void refreshManuleAutoInput(boolean receiveDataTypeAuto) {
if (receiveDataTypeAuto) {
mBinding.surveyor.setVisibility(View.VISIBLE);
mBinding.btnInput.setVisibility(View.GONE);
} else {
mBinding.btnInput.setVisibility(View.VISIBLE);
mBinding.surveyor.setVisibility(View.GONE);
}
}
}

@ -0,0 +1,380 @@
package com.bingce.controlnetwork.func.level.fragment;
import static com.bingce.controlapphelper.model.LevelToleranceNoticeKt.VALUE_IGNORE;
import static com.bingce.controlapphelper.model.LevelToleranceNoticeKt.VALUE_REMEASURE_POINT;
import static com.bingce.controlapphelper.model.LevelToleranceNoticeKt.VALUE_REMEASURE_STATION;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.activity.result.ActivityResultLauncher;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.lifecycle.ViewModelProvider;
import com.bingce.controlapphelper.datasource.database.leveling.LevelingDbFactory;
import com.bingce.controlapphelper.datasource.database.leveling.measure.backfront.LevelingMeasureBackFrontRecord;
import com.bingce.controlapphelper.datasource.database.leveling.measure.station.LevelingMeasureStationRecord;
import com.bingce.controlapphelper.datasource.database.leveling.station.LevelingStationRecord;
import com.bingce.controlapphelper.leveling.detaction.IDetectionHint;
import com.bingce.controlapphelper.leveling.detaction.LevelReceiveData;
import com.bingce.controlapphelper.leveling.detaction.LevelSpeakMsg;
import com.bingce.controlapphelper.leveling.detaction.surveyorcache.SurveyorCacheData;
import com.bingce.controlapphelper.model.LevelToleranceNotice;
import com.bingce.controlapphelper.model.LevelingMeasureOrderUtil;
import com.bingce.controlapphelper.model.PickPointResult;
import com.bingce.controlnetwork.R;
import com.bingce.controlnetwork.databinding.FragmentLevelSurveyorSubBinding;
import com.bingce.controlnetwork.fragment.PickPointFragment;
import com.bingce.controlnetwork.fragment.TipsFragment;
import com.bingce.controlnetwork.func.level.dialog.LevelToleranceTipsFragment;
import com.bingce.controlnetwork.newui.base.BaseFragmentBinding;
import java.util.ArrayList;
import java.util.List;
import com.bingce.controlnetwork.func.level.viewmodel.LevelSuveyorSubVm;
import com.bingce.controlnetwork.func.level.viewmodel.LevelSuveyorVm;
import com.bingce.controlnetwork.util.DialogUtil;
/**
* 水准测量页
*/
public class LevelSurveySubFragment extends BaseFragmentBinding<FragmentLevelSurveyorSubBinding> {
public static final String TAG = LevelSurveySubFragment.class.getName();
private LevelSuveyorSubVm viewModel;
private LevelSuveyorVm stationListVm;
private final ActivityResultLauncher<Intent> defaultStationLauncher = PickPointFragment.createActivityLauncher(this, (type, pickPointResult) -> {
// if (pickPointResult.getSelectedIds().isEmpty() || pickPointResult.getSelectedNames().isEmpty()) {
// return;
// }
// //只有前视才允许选点
// String pointId = pickPointResult.getSelectedIds().get(0);
// viewModel.saveMeasureFrontPointId(pointId, () -> {
// setFrontPointNameUi(pickPointResult.getSelectedNames().get(0));
// return null;
// });
});
// private void setFrontPointNameUi(String name) {
// mBinding.ilPoint.tvPoint.setText(name);
// }
public static LevelSurveySubFragment newInstance(int stationIndex) {
Bundle args = new Bundle();
args.putInt(LevelSurveyFragment.KEY_STATION_INDEX, stationIndex);
LevelSurveySubFragment fragment = new LevelSurveySubFragment();
fragment.setArguments(args);
return fragment;
}
@Override
protected FragmentLevelSurveyorSubBinding getViewBinding(@NonNull LayoutInflater inflater, ViewGroup container) {
return FragmentLevelSurveyorSubBinding.inflate(inflater, container, false);
}
@Override
protected void initView() {
viewModel = new ViewModelProvider(this).get(LevelSuveyorSubVm.class);
stationListVm = new ViewModelProvider(requireParentFragment()).get(LevelSuveyorVm.class);
mBinding.ilSightDistanceDiffCurrent.tvTitle.setText("视距差:");
mBinding.ilDistanceTotal.tvTitle.setText("总距离:");
mBinding.ilSightDistanceDiffTotal.tvTitle.setText("累积视距差:");
mBinding.ilHeightDiffTotal.tvTitle.setText("总高差:");
mBinding.ilZ.tvTitle.setText("高程:");
initListener();
initObserver();
}
private void initObserver() {
viewModel.getStationLiveData().observe(this, stationRecord -> {
boolean measureBack = LevelingMeasureOrderUtil.INSTANCE.isMeasureBack(stationRecord);
String backFrontType = measureBack ? getString(R.string.rearview) : getString(R.string.forward_view);
mBinding.tvBackFrontType.setText(backFrontType);
//除了结束测站的第一个前视点可以选择测点
// setSelectPointShowHide(stationRecord);
setMeasureOrderAndCurrent(stationRecord);
setSurveyorCacheUiVisiable(stationRecord);
// viewModel.getMeasurePointName(stationRecord, pointName -> {
// setFrontPointNameUi(pointName);
// return null;
// });
});
viewModel.getSurveyorCacheDataLiveData().observe(this, this::setSurveyorCacheUi);
viewModel.getMeasureStationLiveData().observe(this, this::setMeasureStationUi);
//监听路线的最后一次设置更新尺子编号
if (stationListVm.getRouteId() != null) {
LevelingDbFactory.instance.getStationSettingDataSource().getLatestLiveData(stationListVm.getRouteId())
.observe(getViewLifecycleOwner(), levelingStationSettingRecord -> {
if (levelingStationSettingRecord != null) {
int stationIndex = getStationIndex();
if (stationIndex == 0) {
mBinding.tvRulerNumBack.setText(getRulerNumShow(levelingStationSettingRecord.firstStationBackFootNumber));
mBinding.tvRulerNumFront.setText(getRulerNumShow(levelingStationSettingRecord.firstStationFrontFootNumber));
} else {
mBinding.tvRulerNumBack.setText(getRulerNumShow(levelingStationSettingRecord.firstStationBackFootNumber2));
mBinding.tvRulerNumFront.setText(getRulerNumShow(levelingStationSettingRecord.firstStationFrontFootNumber2));
}
}
});
}
}
private String getRulerNumShow(String rulerNum) {
if (rulerNum==null) {
rulerNum = "";
}
return "No." + rulerNum;
}
private void setSelectPointShowHide(LevelingStationRecord stationRecord) {
viewModel.isEndStation(stationRecord, endStation -> {
//非单程双侧,前视,非终点站可以选择测点
boolean measureFirstFront = LevelingMeasureOrderUtil.INSTANCE.isMeasureFirstFront(stationRecord);
boolean canSelectPoint = measureFirstFront && getStationIndex() == 0 && !endStation;
// mBinding.ilPoint.ivSelectPoint.setVisibility(canSelectPoint ? View.VISIBLE : View.INVISIBLE);
// mBinding.ilPoint.tvPoint.setClickable(canSelectPoint);
return null;
});
}
private void setSurveyorCacheUiVisiable(LevelingStationRecord stationRecord) {
boolean showTwiceRead = LevelingMeasureOrderUtil.INSTANCE.isShowTwiceRead(stationRecord);
if (showTwiceRead) {
mBinding.ilB2.getRoot().setVisibility(View.VISIBLE);
mBinding.ilF2.getRoot().setVisibility(View.VISIBLE);
} else {
mBinding.ilB2.getRoot().setVisibility(View.GONE);
mBinding.ilF2.getRoot().setVisibility(View.GONE);
}
viewModel.setMeasureTextColor(stationRecord, mBinding.ilB1, mBinding.ilB2, mBinding.ilF1, mBinding.ilF2);
}
private void setMeasureOrderAndCurrent(LevelingStationRecord stationRecord) {
// String textByLevelingMeasureOrder = LevelingMeasureOrderUtil.INSTANCE.getTextByLevelingMeasureOrder(stationRecord.levelingMeasureOrder);
// mBinding.tvOrderType.setText(textByLevelingMeasureOrder);
CharSequence[] currentOrderArray = viewModel.getCurrentOrderArray(stationRecord);
mBinding.tvCurrentOrderOdd.setText(currentOrderArray[0]);
mBinding.tvCurrentOrderEven.setText(currentOrderArray[1]);
}
private void setSurveyorCacheUi(SurveyorCacheData surveyorCacheData) {
LevelingMeasureBackFrontRecord b1Data = surveyorCacheData.getB1Data();
LevelingMeasureBackFrontRecord b2Data = surveyorCacheData.getB2Data();
LevelingMeasureBackFrontRecord f1Data = surveyorCacheData.getF1Data();
LevelingMeasureBackFrontRecord f2Data = surveyorCacheData.getF2Data();
setSurveyorPointData(mBinding.ilB1.tvDisTance, mBinding.ilB1.tvHeight, b1Data);
setSurveyorPointData(mBinding.ilB2.tvDisTance, mBinding.ilB2.tvHeight, b2Data);
setSurveyorPointData(mBinding.ilF1.tvDisTance, mBinding.ilF1.tvHeight, f1Data);
setSurveyorPointData(mBinding.ilF2.tvDisTance, mBinding.ilF2.tvHeight, f2Data);
//更新视距差
String currentFrontBackDistancceDiff = surveyorCacheData.getCurrentFrontBackDistancceDiff();
mBinding.ilSightDistanceDiffCurrent.tvValue.setText(currentFrontBackDistancceDiff);
}
private void setSurveyorPointData(TextView tvDisTance, TextView tvHeight, LevelingMeasureBackFrontRecord data) {
if (data == null) {
tvDisTance.setText("");
tvHeight.setText("");
} else {
tvDisTance.setText(data.getMeasureDistanceShow());
tvHeight.setText(data.getMeasureHeightShow());
}
}
private void setMeasureStationUi(LevelingMeasureStationRecord record) {
if (record == null) {
mBinding.ilDistanceTotal.tvValue.setText("");
mBinding.ilSightDistanceDiffTotal.tvValue.setText("");
mBinding.ilHeightDiffTotal.tvValue.setText("");
mBinding.ilZ.tvValue.setText("");
return;
}
viewModel.getZ(z -> {
mBinding.ilZ.tvValue.setText(record.getZShow(z));
return null;
});
mBinding.ilDistanceTotal.tvValue.setText(record.getDistanceTotalShow());
mBinding.ilSightDistanceDiffTotal.tvValue.setText(record.getCumulativeVisualDistanceDiffShow());
mBinding.ilHeightDiffTotal.tvValue.setText(record.getHeightDiffTotalShow());
}
@Override
protected void initData() {
String currentStationId = getCurrentStationId();
if (currentStationId != null) {
viewModel.initData(currentStationId, new IDetectionHint() {
@Override
public void noticeHint(@NonNull LevelToleranceNotice notice) {
LevelToleranceTipsFragment.tips(getChildFragmentManager(), getViewLifecycleOwner(),
notice.getTitle(), notice.getContent(), new LevelToleranceTipsFragment.IOperatorCallback() {
@Override
public void onReMeasureStation() {
notice.getNoticeBack().levelContinue(VALUE_REMEASURE_STATION, notice.getIgnoreToleranceList());
}
@Override
public void onReMeasurePoint() {
notice.getNoticeBack().levelContinue(VALUE_REMEASURE_POINT, notice.getIgnoreToleranceList());
}
@Override
public void onIgnore() {
notice.getNoticeBack().levelContinue(VALUE_IGNORE, notice.getIgnoreToleranceList());
}
});
}
@Override
public void stationCheckFinish(@NonNull LevelingStationRecord stationRecord) {
if (stationRecord.endStation) {
LevelSpeakMsg.speakStationFinish("该测段已观测完毕");
stationListVm.calLevelRouteResult(result -> {
DialogUtil.showAlertDialog(requireContext(), getChildFragmentManager(), getViewLifecycleOwner(),
"该测段已观测完毕\n" + result);
return null;
});
} else {
boolean simStation = stationRecord.isSimStation();
if (simStation && !stationRecord.twiceStation) {
String hint = "请观测单程双转第二测站";
LevelSpeakMsg.speakStationFinish(hint);
//单程双转的第一个测站提示
TipsFragment.cancelAbleTips(getChildFragmentManager(), getViewLifecycleOwner(), requireContext(),
hint, -1,
() -> switchTwiceStation(stationRecord));
} else {
String hint = getString(R.string.level_check_finish_next_station_hint);
LevelSpeakMsg.speakStationFinish(hint);
TipsFragment.tipsOnly(getChildFragmentManager(), getViewLifecycleOwner(), requireContext(),
hint);
}
}
}
}, stationListVm.getNextStationI());
}
}
private String getCurrentStationId() {
int stationIndex = getStationIndex();
List<LevelingStationRecord> measureStationList = stationListVm.getMeasureStationList();
if (stationIndex >= 0 && measureStationList.size() > stationIndex) {
return measureStationList.get(stationIndex).getId();
}
return null;
}
/**
* 开始切换到第二测站第二个tab
*/
private void switchTwiceStation(LevelingStationRecord record) {
LevelSurveyFragment parentFragment = (LevelSurveyFragment) getParentFragment();
if (parentFragment != null) {
parentFragment.startMeasureNextStation(record);
}
}
/**
* 去创建测段
*/
private void goCreateRoute() {
String projectId = viewModel.getProjectId();
if (projectId != null) {
LevelRouteCreateEditFragment.start(requireContext(), projectId, null, getString(R.string.create_segment_survey));
requireActivity().finish();
}
}
private void initListener() {
// mBinding.ilPoint.tvPoint.setOnClickListener((v) -> {
// StringInputFragment.input(getChildFragmentManager(), "新建点", getViewLifecycleOwner(), string -> {
// if (TextUtils.isEmpty(string)) return;
// viewModel.saveMeasureFrontPoint(PointRecordTj.createHidePoint(string), () -> {
// setFrontPointNameUi(string);
// return null;
// });
// });
// });
//
// mBinding.ilPoint.ivSelectPoint.setOnClickListener((v) -> {
// if (viewModel.getProjectId() == null) return;
// PickPointResult alreadyResult = getAlreadySelectFrontPoint();
// PickPointFragment.pickKnownAndUnknownPoint(getChildFragmentManager(),
// getViewLifecycleOwner(),
// getContext(),
// "",
// 1,
// getString(R.string.select_surveyor_point),
// null,
// viewModel.getProjectId(), alreadyResult, defaultStationLauncher);
// });
}
@Nullable
private PickPointResult getAlreadySelectFrontPoint() {
PickPointResult alreadyResult = null;
LevelingStationRecord station = viewModel.getStationLiveData().getValue();
String measurePointId = null;
if (station != null) {
measurePointId = LevelingMeasureOrderUtil.INSTANCE.getMeasurePointId(station);
}
if (measurePointId != null) {
alreadyResult = new PickPointResult();
List<String> ids = new ArrayList<>();
List<String> names = new ArrayList<>();
ids.add(measurePointId);
alreadyResult.setSelectedIds(ids);
alreadyResult.setSelectedNames(names);
}
return alreadyResult;
}
public void startRollBack() {
viewModel.startRollBack();
}
public void reMeasureStation() {
viewModel.reMeasureStation();
}
public void recieveData(LevelReceiveData data) {
if (viewModel != null) {
viewModel.recieveData(data);
}
}
public void nextStation() {
viewModel.nextStation();
}
private int getStationIndex() {
return requireArguments().getInt(LevelSurveyFragment.KEY_STATION_INDEX);
}
}

@ -0,0 +1,107 @@
package com.bingce.controlnetwork.func.level.fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.bingce.controlapphelper.datasource.database.leveling.LevelingDbFactory;
import com.bingce.controlapphelper.datasource.database.leveling.route.LevelRouteRecord;
import com.bingce.controlapphelper.model.BundleConstants;
import com.bingce.controlnetwork.databinding.FragmentLevelSurveyorHomeBinding;
import com.bingce.controlnetwork.fragment.base.BaseFragment;
import com.bingce.controlnetwork.func.level.adapter.LevelRouteListAdapter;
import blankj.utilcode.util.ToastUtils;
/**
* 水准测量首页
*/
public class LevelSurveyorHomeFragment extends BaseFragment {
public static final String TAG = LevelSurveyorHomeFragment.class.getName();
private LevelRouteListAdapter adapter;
private FragmentLevelSurveyorHomeBinding mBinding;
private static final String KEY_DETAIL_OR_SURVEYOR = "___editable___";//标识点击item进入测量界面还是测站详情
public static LevelSurveyorHomeFragment newInstance(String projectId, String routeId) {
return newInstance(projectId, routeId, true);
}
public static LevelSurveyorHomeFragment newInstance(String projectId, String routeId, boolean detailOrSurveyor) {
LevelSurveyorHomeFragment fragment = new LevelSurveyorHomeFragment();
Bundle bundle = new Bundle();
bundle.putString(BundleConstants.KEY_PROJECT_ID, projectId);
bundle.putString(BundleConstants.KEY_ROUTE_ID, routeId);
bundle.putBoolean(KEY_DETAIL_OR_SURVEYOR, detailOrSurveyor);
fragment.setArguments(bundle);
return fragment;
}
/**
* 去测量
*/
private void goMeasurePage(LevelRouteRecord item) {
String projectId = item.getProjectId();
if (projectId == null) {
ToastUtils.showShort("项目id异常");
return;
}
LevelSurveyFragment.start(getContext(), projectId, item.getId(), item.getRouteName());
}
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
mBinding = FragmentLevelSurveyorHomeBinding.inflate(inflater, container, false);
return mBinding.getRoot();
}
@Override
public void onDestroyView() {
super.onDestroyView();
mBinding = null;
}
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
initView();
initData();
}
private void initView() {
adapter = new LevelRouteListAdapter(requireContext());
mBinding.recyclerView.setAdapter(adapter);
adapter.setOnItemClickListener(this::goMeasurePage);
}
private void initData() {
String projectId = getProjectId();
if (projectId != null) {
LevelingDbFactory.instance.getLevelDataSource().getListLiveData(projectId)
.observe(getViewLifecycleOwner(), routeList -> {
adapter.refreshData(routeList);
});
}
}
private String getProjectId() {
if (getArguments() != null) {
return getArguments().getString(BundleConstants.KEY_PROJECT_ID);
}
return null;
}
private String getRouteId() {
if (getArguments() != null) {
return getArguments().getString(BundleConstants.KEY_ROUTE_ID);
}
return null;
}
}

@ -0,0 +1,162 @@
package com.bingce.controlnetwork.func.level.fragment;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.FragmentActivity;
import androidx.lifecycle.ViewModelProvider;
import com.bingce.controlapphelper.datasource.database.config.ConfigOperate;
import com.bingce.controlapphelper.event.SwitchPageEvent;
import com.bingce.controlapphelper.model.BundleConstants;
import com.bingce.controlnetwork.R;
import com.bingce.controlnetwork.activity.fragmentcontainer.FragmentContainerActivity;
import com.bingce.controlnetwork.fragment.PointListFragment;
import com.bingce.controlnetwork.fragment.ProjectToleranceSettingFragment;
import com.bingce.controlnetwork.fragment.base.BaseFragment;
import com.bingce.controlnetwork.func.level.idetection.LevelIDetectionListActivity;
import com.bingce.controlnetwork.func.level.viewmodel.LevelCreateOrEditRouteVm;
import com.bingce.controlnetwork.ui.ViewUtil;
import com.bingce.utils.ThreadPoolUtil;
import org.greenrobot.eventbus.EventBus;
import org.jetbrains.annotations.NotNull;
/**
* 水准路线列表新建测段
*/
public class ProjectDetailLevelFragment extends BaseFragment {
public static final int title = R.string.project_detail;
public static final String TAG = ProjectDetailLevelFragment.class.getName();
private String projectId = "";
private String projectType = "";
//测站列表
private LevelRouteFragment fragment;
private LevelCreateOrEditRouteVm createEditRouteVm;
@Override
public View onCreateView(@NotNull LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
if (getArguments() != null) {
projectId = getArguments().getString(BundleConstants.KEY_PROJECT_ID);
projectType = getArguments().getString(BundleConstants.KEY_PROJECT_TYPE);
}
createEditRouteVm = new ViewModelProvider(this).get(LevelCreateOrEditRouteVm.class);
View view = inflater.inflate(R.layout.fragment_project_detail_list_level, container, false);
fragment = LevelRouteFragment.newInstance(projectId);
getChildFragmentManager()
.beginTransaction()
.replace(R.id.fragment_container, fragment, "__station_list")
.commit();
//已知点
View known = view.findViewById(R.id.known_point_list);
initKnownPoint(known);
//未知点
View unknown = view.findViewById(R.id.unknown_point_list);
initUnKnownPoint(unknown);
//新建测段
View ilBtn = view.findViewById(R.id.ilBtn);
Button createNewRoute = ilBtn.findViewById(R.id.btnOne);
createNewRoute.setText(R.string.create_segment_survey);
initCreateNewRoute(createNewRoute);
//去测量页面
Button ivGoMeasurePage = ilBtn.findViewById(R.id.btnTwo);
ivGoMeasurePage.setText(R.string.start_surveyor);
initGoMeasurePage(ivGoMeasurePage);
setHasOptionsMenu(true);
return view;
}
private void initGoMeasurePage(View ivGoMeasurePage) {
ViewUtil.setOnClick(ivGoMeasurePage, v -> {
FragmentActivity activity = getActivity();
if (activity != null) {
activity.finish();
}
ThreadPoolUtil.execute(() -> {
String surveyorRouteId = fragment.getSurveyorRouteId();
ConfigOperate.changeDefaultProjectAndRoute(projectId, surveyorRouteId);
EventBus.getDefault().post(new SwitchPageEvent<>(SwitchPageEvent.TYPE_SWITCH_TO_MEASURE_PAGE_AND_DATA, null));
});
});
}
private void initUnKnownPoint(View unknown) {
ViewUtil.setOnClick(unknown,
v -> PointListFragment.go2UnknownPointList(projectId, getContext()));
}
private void initKnownPoint(View known) {
ViewUtil.setOnClick(
known,
v -> PointListFragment.go2KnownPointList(projectId, getContext()));
}
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
getData();
}
private void getData() {
}
/**
* 新建测段
*/
private void initCreateNewRoute(View viewCreateRoute) {
if (viewCreateRoute != null) {
viewCreateRoute.setOnClickListener((v) -> createEditRouteVm.showCreateOrEditDialog(
requireContext(),
projectId,
null
));
}
}
@Override
public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
inflater.inflate(R.menu.project_detail_fragment_menu_level, menu);
super.onCreateOptionsMenu(menu, inflater);
}
@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
if (item.getItemId() == R.id.project_parameter_setting) {
//设置参数点击事件
ProjectToleranceSettingFragment.start(getContext(), projectId, projectType);
return true;
} else if (R.id.iAngleDetection == item.getItemId()) {
LevelIDetectionListActivity.launch(requireContext(), projectId);
}
return super.onOptionsItemSelected(item);
}
public static void start(Context context, String projectType, String projectId, String projectName) {
Bundle bundle = new Bundle();
bundle.putString(BundleConstants.KEY_PROJECT_ID, projectId);
bundle.putString(BundleConstants.KEY_PROJECT_TYPE, projectType);
FragmentContainerActivity.start(context, TAG, projectName, bundle);
}
public static ProjectDetailLevelFragment newInstance(Bundle bundle) {
ProjectDetailLevelFragment fragment = new ProjectDetailLevelFragment();
fragment.setArguments(bundle);
return fragment;
}
}

@ -0,0 +1,282 @@
package com.bingce.controlnetwork.func.level.fragment;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.Toast;
import androidx.activity.result.ActivityResultLauncher;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.WorkerThread;
import androidx.fragment.app.DialogFragment;
import androidx.fragment.app.FragmentManager;
import com.bingce.controlapphelper.datasource.database.ProjectTypeValue;
import com.bingce.controlapphelper.datasource.database.SurveyorDatabaseFactory;
import com.bingce.controlapphelper.datasource.database.project.ProjectRecord;
import com.bingce.controlapphelper.datasource.database.tolerance.detail.IToleranceDetail;
import com.bingce.controlapphelper.datasource.database.tolerance.detail.ToleranceDetailRecord;
import com.bingce.controlapphelper.datasource.database.tolerance.group.ToleranceGroupRecord;
import com.bingce.controlapphelper.datasource.database.tolerance.level.ToleranceLevelRecord;
import com.bingce.controlapphelper.datasource.database.tolerance.load.IToleranceOperate;
import com.bingce.controlapphelper.model.LevelingMeasureOrder;
import com.bingce.controlapphelper.model.LevelingMeasureOrderUtil;
import com.bingce.controlapphelper.util.ToleranceUtil;
import com.bingce.controlnetwork.R;
import com.bingce.controlnetwork.fragment.AbstractFullScreenDialogFragment;
import com.bingce.controlnetwork.fragment.ToleranceSelectFragment;
import com.bingce.controlnetwork.util.tolerance.ToleranceOperateUtil;
import com.bingce.utils.DateUtils;
import com.bingce.utils.ThreadPoolUtil;
import java.util.Date;
import java.util.List;
import blankj.utilcode.util.ToastUtils;
/**
* 水准新建编辑项目
*/
public class ProjectEditForLevelFragment extends AbstractFullScreenDialogFragment {
public final String TAG = ProjectEditForLevelFragment.class.getSimpleName();
private String toleranceId;
private final ActivityResultLauncher<Intent> activityResultLauncher;
private LevelingMeasureOrder levelingMeasureOrder;
public ProjectEditForLevelFragment() {
super();
activityResultLauncher = ToleranceSelectFragment
.createActivityLauncher(
this,
this::dealSelectTolerance);
}
@Override
protected View createContentView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_project_edit_for_level, container, false);
Button selectToleranceButton = view.findViewById(R.id.select_tolerance);
if (selectToleranceButton != null) {
selectToleranceButton.setOnClickListener(v ->
//选择限差方案
ToleranceSelectFragment.start(getContext(), toleranceId, ProjectTypeValue.LEVEL, activityResultLauncher)
);
}
//设置项目名称
EditText projectNameEdit = view.findViewById(R.id.editor);
if (projectNameEdit != null && getArguments() != null) {
String projectName = getArguments().getString(KEY_PROJECT_NAME);
if (projectName == null || projectName.isEmpty()) {
projectName = DateUtils.ymdWithCharacter(new Date());
}
projectNameEdit.setText(projectName);
}
if (getArguments() != null) {
toleranceId = getArguments().getString(KEY_TOLERANCE_ID);
if (toleranceId != null && !toleranceId.isEmpty()) {
ThreadPoolUtil.execute(() -> {
ToleranceDetailRecord instance =
SurveyorDatabaseFactory
.instance
.getToleranceDetailDataSource()
.getRecordSync(toleranceId);
updateTolerance(selectToleranceButton, instance);
});
}
String projectId = getArguments().getString(KEY_PROJECT_ID);
if (projectId != null && !projectId.isEmpty()) {
ThreadPoolUtil.execute(() -> {
ProjectRecord projectRecord =
SurveyorDatabaseFactory
.instance
.getProjectDataSource()
.getRecord(projectId);
if (projectRecord == null) {
return;
}
});
}
}
return view;
}
@WorkerThread
private void updateTolerance(Button button, IToleranceDetail iToleranceDetail) {
if (iToleranceDetail == null) {
return;
}
toleranceId = iToleranceDetail.getId();
IToleranceOperate operate = ToleranceOperateUtil.getOperate(toleranceId);
if (operate == null) return;
ToleranceGroupRecord group = operate.getGroup(iToleranceDetail);
ToleranceLevelRecord level = operate.getLevel(iToleranceDetail);
runOnUI(() -> {
if (button != null) {
String toleranceShowName = ToleranceUtil.completedToleranceName(group, level, iToleranceDetail);
button.setText(toleranceShowName);
}
});
}
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
List<String> showList = LevelingMeasureOrderUtil.INSTANCE.getShowList();
Spinner spinner = view.findViewById(R.id.spinner);
spinner.setAdapter(new ArrayAdapter<>(requireContext(), android.R.layout.simple_list_item_1, showList));
// spinner.setSelection(editTextItem.prismTypes.indexOf(editTextItem.surveyorPoint.getPrismTypeName()));
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
levelingMeasureOrder = LevelingMeasureOrderUtil.INSTANCE.getLevelingMeasureOrderByCreate(showList.get(position));
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
}
private void runOnUI(Runnable runnable) {
if (getActivity() != null) {
getActivity().runOnUiThread(runnable);
}
}
@Override
protected boolean quitWhenTouchBg() {
return true;
}
@Override
protected void onConfirm() {
View view = getView();
if (view == null) {
return;
}
//判断项目名称是否为空
EditText editor = view.findViewById(R.id.editor);
String projectName = editor.getText().toString();
if (projectName.isEmpty()) {
Toast.makeText(getContext(), R.string.tips_need_select_input_project_name, Toast.LENGTH_SHORT).show();
return;
}
//判断限差参数
if (toleranceId == null || toleranceId.isEmpty()) {
Toast.makeText(getContext(), R.string.tips_need_select_project_tolerance, Toast.LENGTH_SHORT).show();
return;
}
if (levelingMeasureOrder == null) {
ToastUtils.showShort(R.string.please_select_measure_order);
return;
}
if (getArguments() == null) {
return;
}
String projectId = getArguments().getString(KEY_PROJECT_ID);
boolean showSlop = true;
if (projectId == null || projectId.isEmpty()) {
ProjectRecord projectRecord = new ProjectRecord(projectName);
projectRecord.setToleranceId(toleranceId);
projectRecord.projectType = ProjectTypeValue.LEVEL;
projectRecord.setShowSlopDistance(showSlop);
//存储
SurveyorDatabaseFactory
.instance
.getProjectDataSource()
.saveRecordSync(projectRecord);
//判断是否需要记录默认项目和测期
// ThreadPoolUtil.execute(() -> {
// IConfigDataSource configDataSource =
// TjDbFactory.instance.getConfigDataSource();
// ConfigRecord defaultProject = configDataSource.getByKeySync(ConfigConstantsTj.KEY_DEFAULT_PROJECT_ID);
// if (defaultProject != null && !defaultProject.getConfigValue().isEmpty()) {
// return;
// }
// });
} else {
ThreadPoolUtil.execute(() -> {
ProjectRecord projectRecord =
SurveyorDatabaseFactory
.instance
.getProjectDataSource()
.getRecord(projectId);
projectRecord.setProjectName(projectName);
projectRecord.setToleranceId(toleranceId);
projectRecord.setShowSlopDistance(showSlop);
//存储
SurveyorDatabaseFactory
.instance
.getProjectDataSource()
.saveRecordSync(projectRecord);
});
}
super.onConfirm();
}
private static final String KEY_PROJECT_ID = "___project__id";
private static final String KEY_TOLERANCE_ID = "___tolerance_id";
private static final String KEY_PROJECT_NAME = "___project___name___";
private static DialogFragment newInstance(Context context, String projectId, String toleranceId, String projectName) {
ProjectEditForLevelFragment fragment = new ProjectEditForLevelFragment();
Bundle args = new Bundle();
if (projectId == null || projectId.isEmpty()) {
setArgs(args, context.getString(R.string.title_create_new_project), null);
} else {
setArgs(args, context.getString(R.string.title_edit_project), null);
args.putString(KEY_PROJECT_ID, projectId);
args.putString(KEY_TOLERANCE_ID, toleranceId);
args.putString(KEY_PROJECT_NAME, projectName);
}
fragment.setArguments(args);
return fragment;
}
public static void editProject(FragmentManager fragmentManager,
Context context,
String projectId, String toleranceId, String projectName) {
newInstance(context, projectId, toleranceId, projectName).show(fragmentManager, "_edit_project_fragment");
}
public static void createProject(FragmentManager fragmentManager, Context context) {
newInstance(context, null, null, null)
.show(fragmentManager, "__create_project_fragment__");
}
/**
* 处理选择返回的限差id
*
* @param id
*/
private void dealSelectTolerance(String id) {
ThreadPoolUtil.execute(() -> {
IToleranceOperate operate = ToleranceOperateUtil.getOperate(id);
if (operate == null) return;
IToleranceDetail toleranceDetail = operate.getIToleranceDetail(id);
//存限差数据
operate.saveToleranceDetail(toleranceDetail);
View view = getView();
if (view != null) {
updateTolerance(view.findViewById(R.id.select_tolerance), toleranceDetail);
}
});
}
}

@ -1,4 +1,4 @@
package com.bingce.controlnetwork.fragment; package com.bingce.controlnetwork.func.level.fragment;
import android.os.Bundle; import android.os.Bundle;
import android.view.LayoutInflater; import android.view.LayoutInflater;
@ -11,60 +11,48 @@ import androidx.annotation.Nullable;
import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentManager;
import androidx.lifecycle.LifecycleOwner; import androidx.lifecycle.LifecycleOwner;
import com.bingce.controlapphelper.datasource.database.ProjectType; import com.bingce.controlnetwork.fragment.SelectProjectAndSurveyorCycleFragment;
import com.google.android.material.bottomsheet.BottomSheetDialogFragment; import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
import blankj.utilcode.util.ToastUtils;
import com.bingce.controlnetwork.R; import com.bingce.controlnetwork.R;
/** /**
* 选择项目类型 * 水准选择下一站观测方式
*/ */
public class SelectProjectTypeFragment extends BottomSheetDialogFragment { public class SelectLevelNextStationTypeFragment extends BottomSheetDialogFragment {
public static final String TAG = SelectProjectAndSurveyorCycleFragment.class.getName(); public static final String TAG = SelectProjectAndSurveyorCycleFragment.class.getName();
private static final String KEY_REQUEST_SELECT = "__SELECT__";
private static final String KEY_TYPE = "__SELECT_TYPE__";
public static final String TYPE_CONTINUE_OBSERVE = "TYPE_CONTINUE_OBSERVE";
public static final String TYPE_INTERMITTENT = "TYPE_INTERMITTENT";
public static final String TYPE_END_STATION = "TYPE_END_STATION";
private SelectLevelNextStationTypeFragment() {
}
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) { Bundle savedInstanceState) {
View view = inflater View view = inflater.inflate(
.inflate( R.layout.fragment_select_level_next_station_type,
R.layout.fragment_select_project_type, container,
container, false);
false); initClickListener(view);
View.OnClickListener onClickListener = v -> { return view;
if (v == null) { }
dismiss();
return;
}
int id = v.getId();
String type = null;
if (id == R.id.btnTriangleWire) {
type = ProjectType.TRIANGLE.getFlag();
} else if (id == R.id.btnConnectionSurvey) {
type = ProjectType.CONNECTION.getFlag();
} else if (id == R.id.btnHeightTraverse) {
type = ProjectType.HEIGHT_TRAVERSE.getFlag();
}
if (type == null) {
ToastUtils.showShort("该导线正在开发中,请稍后...");
return;
}
Bundle args = new Bundle();
args.putString(KEY_TYPE, type);
getParentFragmentManager().setFragmentResult(KEY_REQUEST_SELECT, args);
dismiss();
};
setOnClickListener(view, R.id.btnTriangleWire, onClickListener); private void initClickListener(View view) {
setOnClickListener(view, R.id.btnConnectionSurvey, onClickListener); setOnClickListener(view, R.id.continueObserve, v -> backData(TYPE_CONTINUE_OBSERVE));
setOnClickListener(view, R.id.btnHeightTraverse, onClickListener); setOnClickListener(view, R.id.intermittent, v -> backData(TYPE_INTERMITTENT));
setOnClickListener(view, R.id.endStation, v -> backData(TYPE_END_STATION));
setOnClickListener(view, R.id.cancel, v -> dismiss()); setOnClickListener(view, R.id.cancel, v -> dismiss());
}
return view; private void backData(String type) {
Bundle args = new Bundle();
args.putString(KEY_TYPE, type);
getParentFragmentManager().setFragmentResult(KEY_REQUEST_SELECT, args);
dismissAllowingStateLoss();
} }
private static void setOnClickListener(View root, int id, View.OnClickListener onClickListener) { private static void setOnClickListener(View root, int id, View.OnClickListener onClickListener) {
@ -74,14 +62,10 @@ public class SelectProjectTypeFragment extends BottomSheetDialogFragment {
} }
} }
private static final String KEY_REQUEST_SELECT = "__SELECT__"; public static void select(FragmentManager fragmentManager,
private static final String KEY_TYPE = "__SELECT_TYPE__"; @NonNull LifecycleOwner lifecycleOwner,
IOnSelectCallback callback) {
SelectLevelNextStationTypeFragment fragment = new SelectLevelNextStationTypeFragment();
public static void start(FragmentManager fragmentManager,
@NonNull LifecycleOwner lifecycleOwner,
IOnSelectCallback callback) {
SelectProjectTypeFragment fragment = new SelectProjectTypeFragment();
fragmentManager fragmentManager
.setFragmentResultListener( .setFragmentResultListener(
KEY_REQUEST_SELECT, KEY_REQUEST_SELECT,

@ -0,0 +1,136 @@
package com.bingce.controlnetwork.func.level.fragment;
import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.DialogFragment;
import androidx.fragment.app.FragmentManager;
import androidx.recyclerview.widget.RecyclerView;
import com.bingce.controlnetwork.R;
import org.jetbrains.annotations.NotNull;
import java.util.List;
import com.bingce.controlnetwork.func.level.sendreceive.TestData;
public class TestDataSelectLevelFragment extends DialogFragment {
private static IClickItem clickItem;
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_single_list_layout, container, false);
// Set the adapter
if (view instanceof RecyclerView) {
RecyclerView recyclerView = (RecyclerView) view;
refreshRecyclerView(recyclerView);
}
return view;
}
@Override
public void onViewCreated(@NonNull @NotNull View view, @Nullable @org.jetbrains.annotations.Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
Dialog dialog = getDialog();
if (dialog == null) {
return;
}
Window window = dialog.getWindow();
if (window == null) {
return;
}
window.setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT);
WindowManager.LayoutParams lps = window.getAttributes();
lps.verticalMargin = 0.4F;
lps.horizontalMargin = 0.4F;
window.setAttributes(lps);
}
protected void refreshRecyclerView(RecyclerView recyclerView) {
List<String> list = TestData.Companion.getTextShowList();
recyclerView.setAdapter(new MyAdapter(list));
}
public static void show(FragmentManager fragmentManager, IClickItem clickItem) {
TestDataSelectLevelFragment.clickItem = clickItem;
TestDataSelectLevelFragment fragment = new TestDataSelectLevelFragment();
fragment.show(fragmentManager, TestDataSelectLevelFragment.class.getName());
}
private class MyAdapter extends RecyclerView.Adapter<ViewHolder> {
private final List<String> data;
public MyAdapter(List<String> data) {
this.data = data;
}
@NonNull
@Override
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
Context context = parent.getContext();
LayoutInflater inflater = LayoutInflater.from(context);
// Inflate the custom layout
View itemView = inflater.inflate(R.layout.list_item_index_text_layout, parent, false);
// Return a new holder instance
return new ViewHolder(itemView);
}
@Override
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
// Get the data model based on position
String item = data.get(position);
// Set item views based on your views and data model
holder.index.setText(String.valueOf(position + 1));
holder.text.setText(item);
holder.itemView.setOnClickListener(v -> {
if (clickItem != null) {
clickItem.click(holder.getBindingAdapterPosition());
dismissAllowingStateLoss();
}
});
}
@Override
public int getItemCount() {
return data.size();
}
// Provide a reference to the views for each data item
}
private static class ViewHolder extends RecyclerView.ViewHolder {
public TextView index;
public TextView text;
public ViewHolder(View itemView) {
super(itemView);
index = itemView.findViewById(R.id.index);
text = itemView.findViewById(R.id.text);
}
}
public interface IClickItem {
void click(int position);
}
}

@ -0,0 +1,234 @@
package com.bingce.controlnetwork.func.level.idetection
import com.bingce.controlapphelper.datasource.database.leveling.idetection.constants.LevelIDetectionConstant
import com.bingce.controlapphelper.datasource.database.leveling.idetection.record.LevelIDetectionRecord
import kotlin.math.pow
object LevelIDetectionCalUtil {
private val station1 = LevelIDetectionConstant.STATION_TYPE_0
private val station2 = LevelIDetectionConstant.STATION_TYPE_1
private val ruler1 = LevelIDetectionConstant.RULER_TYPE_0
private val ruler2 = LevelIDetectionConstant.RULER_TYPE_1
private val measureTime1 = LevelIDetectionConstant.MEASURE_TIME_0
private val measureTime2 = LevelIDetectionConstant.MEASURE_TIME_1
private val measureTime3 = LevelIDetectionConstant.MEASURE_TIME_2
private val measureTime4 = LevelIDetectionConstant.MEASURE_TIME_3
private val measureTime5 = LevelIDetectionConstant.MEASURE_TIME_4
/**
* 单位mm
* d1短距
* d2长距
*/
fun getIResult(
iDetectionId: String,
measureType: String,
d1: Double,
d2: Double,
stationRecordMap: HashMap<String, LevelIDetectionRecord>
): Double {
val a1 = getA1(iDetectionId, stationRecordMap)
val b1 = getB1(iDetectionId, stationRecordMap)
val a2 = getA2(iDetectionId, stationRecordMap)
val b2 = getB2(iDetectionId, stationRecordMap)
val deTa = getDeTa(measureType, a1, b1, a2, b2)
return getI(deTa, d1, d2)
}
private fun getI(deTa: Double, d1: Double, d2: Double) =
deTa * 206265 / (d2 - d1) - 1.61 * 10.0.pow(-5.0) * (d1 + d2)
private fun getDeTa(
measureType: String,
a1: Double,
b1: Double,
a2: Double,
b2: Double
): Double {
return if (LevelIDetectionConstant.A_I_I_B == measureType || LevelIDetectionConstant.I_A_B_I == measureType) {
((a2 - b2) - (a1 - b1)) / 2
} else {
(a2 - b2) - (a1 - b1)
}
}
/**
* 一站一尺
*/
private fun getA1(
iDetectionId: String,
stationRecordMap: HashMap<String, LevelIDetectionRecord>
): Double {
val height1 = getHeight(
stationRecordMap[LevelIDetectionRecord.getRecordId(
iDetectionId, station1, ruler1,
measureTime1
)]
)
val height2 = getHeight(
stationRecordMap[LevelIDetectionRecord.getRecordId(
iDetectionId, station1, ruler1,
measureTime2
)]
)
val height3 = getHeight(
stationRecordMap[LevelIDetectionRecord.getRecordId(
iDetectionId, station1, ruler1,
measureTime3
)]
)
val height4 = getHeight(
stationRecordMap[LevelIDetectionRecord.getRecordId(
iDetectionId, station1, ruler1,
measureTime4
)]
)
val height5 = getHeight(
stationRecordMap[LevelIDetectionRecord.getRecordId(
iDetectionId, station1, ruler1,
measureTime5
)]
)
return getAverage(height1, height2, height3, height4, height5)
}
/**
* 一站二尺
*/
private fun getB1(
iDetectionId: String,
stationRecordMap: HashMap<String, LevelIDetectionRecord>
): Double {
val height1 = getHeight(
stationRecordMap[LevelIDetectionRecord.getRecordId(
iDetectionId, station1, ruler2,
measureTime1
)]
)
val height2 = getHeight(
stationRecordMap[LevelIDetectionRecord.getRecordId(
iDetectionId, station1, ruler2,
measureTime2
)]
)
val height3 = getHeight(
stationRecordMap[LevelIDetectionRecord.getRecordId(
iDetectionId, station1, ruler2,
measureTime3
)]
)
val height4 = getHeight(
stationRecordMap[LevelIDetectionRecord.getRecordId(
iDetectionId, station1, ruler2,
measureTime4
)]
)
val height5 = getHeight(
stationRecordMap[LevelIDetectionRecord.getRecordId(
iDetectionId, station1, ruler2,
measureTime5
)]
)
return getAverage(height1, height2, height3, height4, height5)
}
/**
* 二站一尺
*/
private fun getA2(
iDetectionId: String,
stationRecordMap: HashMap<String, LevelIDetectionRecord>
): Double {
val height1 = getHeight(
stationRecordMap[LevelIDetectionRecord.getRecordId(
iDetectionId, station2, ruler1,
measureTime1
)]
)
val height2 = getHeight(
stationRecordMap[LevelIDetectionRecord.getRecordId(
iDetectionId, station2, ruler1,
measureTime2
)]
)
val height3 = getHeight(
stationRecordMap[LevelIDetectionRecord.getRecordId(
iDetectionId, station2, ruler1,
measureTime3
)]
)
val height4 = getHeight(
stationRecordMap[LevelIDetectionRecord.getRecordId(
iDetectionId, station2, ruler1,
measureTime4
)]
)
val height5 = getHeight(
stationRecordMap[LevelIDetectionRecord.getRecordId(
iDetectionId, station2, ruler1,
measureTime5
)]
)
return getAverage(height1, height2, height3, height4, height5)
}
/**
* 二站二尺
*/
private fun getB2(
iDetectionId: String,
stationRecordMap: HashMap<String, LevelIDetectionRecord>
): Double {
val height1 = getHeight(
stationRecordMap[LevelIDetectionRecord.getRecordId(
iDetectionId, station2, ruler2,
measureTime1
)]
)
val height2 = getHeight(
stationRecordMap[LevelIDetectionRecord.getRecordId(
iDetectionId, station2, ruler2,
measureTime2
)]
)
val height3 = getHeight(
stationRecordMap[LevelIDetectionRecord.getRecordId(
iDetectionId, station2, ruler2,
measureTime3
)]
)
val height4 = getHeight(
stationRecordMap[LevelIDetectionRecord.getRecordId(
iDetectionId, station2, ruler2,
measureTime4
)]
)
val height5 = getHeight(
stationRecordMap[LevelIDetectionRecord.getRecordId(
iDetectionId, station2, ruler2,
measureTime5
)]
)
return getAverage(height1, height2, height3, height4, height5)
}
private fun getHeight(record: LevelIDetectionRecord?): Double {
return record?.height ?: 0.0
}
/**
* 返回单位mm
*/
private fun getAverage(
height1: Double,
height2: Double,
height3: Double,
height4: Double,
height5: Double
): Double {
return (height1 + height2 + height3 + height4 + height5) / 5 * 1000
}
}

@ -0,0 +1,101 @@
package com.bingce.controlnetwork.func.level.idetection
import android.content.Context
import android.content.Intent
import androidx.activity.viewModels
import com.bingce.controlapphelper.datasource.database.leveling.idetection.list.LevelIDetectionList
import com.bingce.controlapphelper.model.BundleConstants
import com.bingce.controlapphelper.util.Tools
import com.bingce.controlapphelper.widget.swiperecyclerview.widget.DefaultItemDecoration
import com.bingce.controlnetwork.R
import com.bingce.controlnetwork.databinding.ActivityLevelIDetectionListBinding
import com.bingce.controlnetwork.func.level.fragment.LevelIDetectionCreateFragment
import com.bingce.controlnetwork.func.level.idetection.adapter.LevelIDetectionListAdapter
import com.bingce.controlnetwork.func.level.idetection.viewmodel.LevelIDetectionListVm
import com.bingce.controlnetwork.newui.base.BaseBindingActivity
import com.bingce.controlnetwork.newui.widget.swipemenu.SwipeMenuDelete
import com.bingce.controlnetwork.util.DialogUtil
import com.bingce.utils.DateUtils
import java.util.Date
/**
* 水准i角检测列表
*/
class LevelIDetectionListActivity : BaseBindingActivity<ActivityLevelIDetectionListBinding>() {
private val viewModel by viewModels<LevelIDetectionListVm>()
private val adater by lazy {
LevelIDetectionListAdapter(this)
}
companion object {
@JvmStatic
fun launch(context: Context, projectId: String) {
context.startActivity(Intent(context, LevelIDetectionListActivity::class.java).apply {
putExtra(BundleConstants.KEY_PROJECT_ID, projectId)
})
}
}
override fun getBinding(): ActivityLevelIDetectionListBinding {
return ActivityLevelIDetectionListBinding.inflate(layoutInflater)
}
override fun initView() {
initAdapter()
initListener()
}
private fun initListener() {
mBinding.tvCreateIAngleDetection.setOnClickListener {
LevelIDetectionCreateFragment.input(
supportFragmentManager,
"i角检测名称",
DateUtils.ymdHMSWithCharacter(Date()),
this
) { name -> viewModel.saveNewRecord(getProjectId(), name) }
}
}
private fun initAdapter() {
mBinding.ilSwipeList.swipeRecyclerView.addItemDecoration(
DefaultItemDecoration(
Tools.getColor(R.color.transparent), 1, 1
)
)
mBinding.ilSwipeList.swipeRecyclerView.setSwipeMenuCreator(
SwipeMenuDelete(this)
)
mBinding.ilSwipeList.swipeRecyclerView.setOnItemMenuClickListener { menuBridge, adapterPosition ->
menuBridge.closeMenu()
dealMenuClick(menuBridge.position, adater.getBean(adapterPosition))
}
mBinding.ilSwipeList.swipeRecyclerView.setOnItemClickListener { view, adapterPosition ->
val bean = adater.getBean(adapterPosition)
LevelIDetectionRecordActivity.launch(this, bean.id)
}
mBinding.ilSwipeList.swipeRecyclerView.adapter = adater
}
private fun dealMenuClick(position: Int, bean: LevelIDetectionList?) {
DialogUtil.showConfirmDialog(
supportFragmentManager, this, "您确定要删除该i角检测吗?",
Tools.getString(R.string.confirm)
) {
bean?.let {
viewModel.deleteRecord(it)
}
}
}
override fun initData() {
viewModel.getListLiveData(getProjectId()).observe(this) {
adater.refreshData(it)
}
}
private fun getProjectId() = intent.getStringExtra(BundleConstants.KEY_PROJECT_ID)!!
}

@ -0,0 +1,371 @@
package com.bingce.controlnetwork.func.level.idetection
import android.content.Context
import android.content.Intent
import android.text.TextUtils
import android.view.Menu
import android.view.MenuItem
import android.view.View
import android.widget.EditText
import androidx.activity.viewModels
import blankj.utilcode.util.ToastUtils
import com.bingce.controlnetwork.func.level.idetection.viewmodel.LevelIDetectionRecordVm
import com.bingce.controlnetwork.func.level.sendreceive.ILevelBackData
import com.bingce.controlnetwork.func.level.sendreceive.LevelRequest
import cn.liuyanbing.surveyor.function.level.sendreceive.LevelRequestRelease
import com.bingce.controlnetwork.newui.widget.selectitem.SelectIDetectionStationFragment
import com.bingce.controlapphelper.datasource.database.leveling.idetection.constants.LevelIDetectionConstant
import com.bingce.controlapphelper.datasource.database.leveling.idetection.constants.LevelIDetectionConstant.I_A_B_I
import com.bingce.controlapphelper.datasource.database.leveling.idetection.list.LevelIDetectionList
import com.bingce.controlapphelper.leveling.detaction.LevelReceiveData
import com.bingce.controlapphelper.model.BundleConstants
import com.bingce.controlapphelper.util.Tools
import com.bingce.controlapphelper.widget.swiperecyclerview.widget.DefaultItemDecoration
import com.bingce.controlnetwork.R
import com.bingce.controlnetwork.databinding.ActivityLevelIDetectionRecordBinding
import com.bingce.controlnetwork.event.RefreshEvent
import com.bingce.controlnetwork.fragment.TipsFragment
import com.bingce.controlnetwork.func.level.fragment.LevelInputAllowFragment
import com.bingce.controlnetwork.func.level.fragment.LevelInputFragment
import com.bingce.controlnetwork.func.level.idetection.adapter.LevelIDetectionRecordAdapter
import com.bingce.controlnetwork.newui.base.BaseBindingActivity
import com.bingce.controlnetwork.newui.widget.selectitem.BaseSelectItemFragment
import com.bingce.controlnetwork.newui.widget.selectitem.SelectIDetectionStationMeasureTypeFragment
import com.bingce.controlnetwork.util.DialogUtil
import com.bingce.controlnetwork.util.StationSettingCheckUtil
import com.bingce.utils.ScreenUtil
import org.greenrobot.eventbus.EventBus
import org.greenrobot.eventbus.Subscribe
import org.greenrobot.eventbus.ThreadMode
/**
* 水准i角检测-测量
*/
class LevelIDetectionRecordActivity : BaseBindingActivity<ActivityLevelIDetectionRecordBinding>() {
private val viewModel by viewModels<LevelIDetectionRecordVm>()
private val stationSettingCheckUtil = StationSettingCheckUtil()
private val adapter by lazy {
LevelIDetectionRecordAdapter(this, surveyorData)
}
private val surveyorData by lazy {
LevelIDetectionSurveyorData(getIDetectionId())
}
private val levelReceiveData: LevelRequest = LevelRequestRelease(object : ILevelBackData {
override fun receive(data: LevelReceiveData) {
receiveData(data)
}
override fun measureError(msg: String) {
if (isDestroyed || isFinishing) {
return
}
DialogUtil.showAlertDialog(
this@LevelIDetectionRecordActivity,
supportFragmentManager,
this@LevelIDetectionRecordActivity,
msg
)
}
})
@Subscribe(threadMode = ThreadMode.BACKGROUND)
fun refresh(event: RefreshEvent<*>) {
if (event.type == RefreshEvent.REFRESH_BY_LEVEL_I_DETECTION_SETTING_UPDATE) {
viewModel.updateStationSetting()
adapter.setStationSetting(viewModel.stationSetting)
runOnUiThread {
adapter.notifyDataSetChanged()
}
}
}
companion object {
@JvmStatic
fun launch(context: Context, levelIDetectionId: String) {
context.startActivity(Intent(context, LevelIDetectionRecordActivity::class.java).apply {
putExtra(BundleConstants.KEY_I_DETECTION_ID, levelIDetectionId)
})
}
}
override fun getBinding(): ActivityLevelIDetectionRecordBinding {
return ActivityLevelIDetectionRecordBinding.inflate(layoutInflater)
}
override fun onDestroy() {
super.onDestroy()
levelReceiveData.onDestroy()
EventBus.getDefault().unregister(this)
}
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
menuInflater.inflate(R.menu.menu_level_survey_i_detection, menu)
return super.onCreateOptionsMenu(menu)
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
if (R.id.result == item.itemId) {
startIResult()
} else if (R.id.stationSetting == item.itemId) {
goLevelIDetectionSetting()
} else if (R.id.rollBack == item.itemId) {
startRollBack()
} else if (R.id.level_i_detection_sample == item.itemId) {
LevelIDetectionSampleActivity.launch(this)
} else if (R.id.receiveDataType == item.itemId) {
showReceiveDataTypeDialog()
}
return super.onOptionsItemSelected(item)
}
/**
* i角检测的测站设置
*/
private fun goLevelIDetectionSetting() {
LevelIDetectionStationSettingActivity.launch(this, getIDetectionId())
}
private fun showReceiveDataTypeDialog() {
LevelInputAllowFragment.show(
supportFragmentManager,
this,
mBinding.surveyor.visibility == View.VISIBLE
) {
viewModel.setGetDataAuto(getIDetectionId(), it)
refreshManuleAutoInput(it)
}
}
private fun startIResult() {
val d1String = getEtText(mBinding.etShortDistance)
if (TextUtils.isEmpty(d1String)) {
ToastUtils.showShort("请输入短距")
return
}
val d2String = getEtText(mBinding.etLongDistance)
if (TextUtils.isEmpty(d2String)) {
ToastUtils.showShort("请输入长距")
return
}
if (viewModel.measureType == null) {
ToastUtils.showShort("请选择测量方式")
return
}
//存短长距和测量方式
viewModel.saveShortLongDistanceMeasureType(d1String, d2String)
//计算结果
val result = viewModel.startResult(getD(d1String), getD(d2String))
if (!TextUtils.isEmpty(result)) {
DialogUtil.showAlertDialog(
this,
supportFragmentManager,
this,
result
)
}
}
private fun getEtText(et: EditText): String {
return et.text.toString().trim()
}
/**
* 返回mm的D
*/
private fun getD(value: String): Double {
return value.toDouble() * 1000
}
private fun startRollBack() {
val findRollBackData = viewModel.findRollBackData()
if (findRollBackData == null) {
ToastUtils.showShort("没有可以回退的数据")
return
}
val deleteStationShow =
LevelIDetectionConstant.getStationTypeShow(findRollBackData.currentStationType)
val deleteRuleShow =
LevelIDetectionConstant.getRulerTypeShow(findRollBackData.currentRulerType)
val hint = "回退操作将删除 $deleteStationShow $deleteRuleShow 的数据,您是否还要回退?"
showConfirmDialog(hint) {
viewModel.deleteStationRulerData(findRollBackData) {
refreshAdapterAndButton()
}
}
}
override fun initView() {
EventBus.getDefault().register(this)
levelReceiveData.onStart()
initAdapter()
initListener()
viewModel.getGetDadaAuto(getIDetectionId()) {
refreshManuleAutoInput(it)
}
}
private fun initListener() {
mBinding.llStation.setOnClickListener {
if (adapter.itemCount == 0) {
ToastUtils.showShort("数据加载中,请稍后尝试")
return@setOnClickListener
}
BaseSelectItemFragment.select(
SelectIDetectionStationFragment(),
supportFragmentManager,
this, object : BaseSelectItemFragment.ISelectItem {
override fun onBack(value: String) {
//value stationType
viewModel.switchStation(value.toInt())
setCurrentStation()
refreshAdapterAndButton()
}
})
}
mBinding.llMeasureType.setOnClickListener {
BaseSelectItemFragment.select(
SelectIDetectionStationMeasureTypeFragment(),
supportFragmentManager,
this, object : BaseSelectItemFragment.ISelectItem {
override fun onBack(value: String) {
switchMeasureType(value)
}
})
}
mBinding.surveyor.setOnClickListener {
stationSettingCheckUtil.checkStationSettingsIDetection(
getIDetectionId(),
this,
this::runOnUiThread
) {
levelReceiveData.requeset()
}
}
mBinding.btnInput.setOnClickListener {
LevelInputFragment.show(
supportFragmentManager, this
) { distance: Double, height: Double ->
receiveData(LevelReceiveData(height, distance))
}
}
}
private fun receiveData(data: LevelReceiveData) {
if (isFinishing || isDestroyed) {
return
}
viewModel.receiveData(data.height, data.distance)
refreshAdapterAndButton()
}
/**
* 切换测量方法带存储
*/
private fun switchMeasureType(measureType: String) {
setCurrentMeasureType(measureType)
viewModel.saveMeasureType(getIDetectionId(), measureType)
}
private fun setCurrentMeasureType(measureType: String?) {
mBinding.tvMeasureType.text = measureType
viewModel.measureType = measureType
}
private fun setCurrentStation() {
val stationTypeShow =
LevelIDetectionConstant.getStationTypeShow(surveyorData.currentStationType)
mBinding.tvStation.text = stationTypeShow
}
private fun initAdapter() {
mBinding.recyclerView.adapter = adapter
mBinding.recyclerView.addItemDecoration(
DefaultItemDecoration(
Tools.getColor(R.color.transparent),
1,
ScreenUtil.dp2px(this, 10f)
)
)
}
override fun initData() {
viewModel.initData(surveyorData) {
adapter.setStationSetting(viewModel.stationSetting)
setCurrentStation()
if (it.measureType == null) {
switchMeasureType(I_A_B_I)
} else {
setCurrentMeasureType(it.measureType)
}
//设置短长距
setShortLongDistance(it)
refreshButton()
adapter.refreshData(viewModel.dataListAdapter)
}
}
private fun setShortLongDistance(it: LevelIDetectionList) {
mBinding.etShortDistance.setText(it.shortDistance)
mBinding.etLongDistance.setText(it.longDistance)
}
private fun getIDetectionId() = intent.getStringExtra(BundleConstants.KEY_I_DETECTION_ID)!!
private fun showConfirmDialog(content: String, callback: TipsFragment.IConfirmCallback) {
TipsFragment.cancelAbleTips(
supportFragmentManager, this, this,
content, -1, callback
)
}
private fun refreshAdapterAndButton() {
adapter.notifyDataSetChanged()
refreshButton()
}
private fun refreshButton() {
//刷新测量按钮
setViewEnable(mBinding.surveyor, surveyorData.isHaveSurveyor())
setViewEnable(mBinding.btnInput, surveyorData.isHaveSurveyor())
}
private fun setViewEnable(view: View, measureEnable: Boolean) {
view.isEnabled = measureEnable
if (measureEnable) {
view.alpha = 1f
} else {
view.alpha = .4f
}
}
private fun refreshManuleAutoInput(receiveDataTypeAuto: Boolean) {
if (receiveDataTypeAuto) {
mBinding.surveyor.visibility = View.VISIBLE
mBinding.btnInput.visibility = View.GONE
} else {
mBinding.btnInput.visibility = View.VISIBLE
mBinding.surveyor.visibility = View.GONE
}
}
}

@ -0,0 +1,31 @@
package com.bingce.controlnetwork.func.level.idetection
import android.content.Context
import android.content.Intent
import com.bingce.controlnetwork.databinding.ActivityLevelIDetectionSampleBinding
import com.bingce.controlnetwork.newui.base.BaseBindingActivity
/**
* 水准i角检测示例图
*/
class LevelIDetectionSampleActivity : BaseBindingActivity<ActivityLevelIDetectionSampleBinding>() {
companion object {
@JvmStatic
fun launch(context: Context) {
context.startActivity(Intent(context, LevelIDetectionSampleActivity::class.java))
}
}
override fun getBinding(): ActivityLevelIDetectionSampleBinding {
return ActivityLevelIDetectionSampleBinding.inflate(layoutInflater)
}
override fun initView() {
}
override fun initData() {
}
}

@ -0,0 +1,173 @@
package com.bingce.controlnetwork.func.level.idetection
import android.content.Context
import android.content.Intent
import android.text.TextUtils
import android.view.Menu
import android.view.MenuItem
import android.widget.ArrayAdapter
import androidx.lifecycle.lifecycleScope
import blankj.utilcode.util.ToastUtils
import com.bingce.controlnetwork.func.level.constant.LevelStationSettingContant
import com.bingce.controlnetwork.func.level.util.LevelStationSettingUtil
import com.bingce.controlapphelper.datasource.database.leveling.LevelingDbFactory
import com.bingce.controlapphelper.datasource.database.leveling.idetection.isetting.LevelIDetectionSetting
import com.bingce.controlapphelper.model.BundleConstants
import com.bingce.controlnetwork.R
import com.bingce.controlnetwork.databinding.ActivityLevelIDetectionStationSettingBinding
import com.bingce.controlnetwork.event.RefreshEvent
import com.bingce.controlnetwork.newui.base.BaseBindingActivity
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import org.greenrobot.eventbus.EventBus
/**
* i角检测测站设置
*/
class LevelIDetectionStationSettingActivity :
BaseBindingActivity<ActivityLevelIDetectionStationSettingBinding>() {
companion object {
@JvmStatic
fun launch(context: Context, iDetectionId: String) {
context.startActivity(
Intent(
context,
LevelIDetectionStationSettingActivity::class.java
).apply {
putExtra(BundleConstants.KEY_I_DETECTION_ID, iDetectionId)
})
}
}
override fun getBinding(): ActivityLevelIDetectionStationSettingBinding {
return ActivityLevelIDetectionStationSettingBinding.inflate(layoutInflater)
}
override fun initView() {
initEditTextTitle()
initSpinnerImaging()
}
override fun initData() {
getEditData()
}
private fun getEditData() {
lifecycleScope.launch(Dispatchers.IO) {
val iDetectionId = getIDetectionId()
val record =
LevelingDbFactory.instance.iDetectionSettingDataSource.getByIDetectionId(
iDetectionId
)
if (record != null) {
withContext(Dispatchers.Main) {
setData(record)
}
}
}
}
/**
* 初始化editText坐标的title
*/
private fun initEditTextTitle() {
mBinding.ilWatcher.tvTitle.text = "观测者"
mBinding.ilRecorder.tvTitle.text = "记录者"
mBinding.ilExaminer.tvTitle.text = "检查者"
mBinding.ilRuler1.tvTitle.text = "尺一编号"
mBinding.ilRuler2.tvTitle.text = "尺二编号"
mBinding.ilInstrumentModel.tvTitle.text = "仪器型号"
mBinding.ilDeviceNumber.tvTitle.text = "仪器编号"
}
private fun setData(record: LevelIDetectionSetting) {
mBinding.ilWatcher.editText.setText(record.watcher)
mBinding.ilRecorder.editText.setText(record.recorder)
mBinding.ilExaminer.editText.setText(record.examiner)
mBinding.ilRuler1.editText.setText(record.rulerNum1)
mBinding.ilRuler2.editText.setText(record.rulerNum2)
mBinding.ilInstrumentModel.editText.setText(record.instrumentModel)
mBinding.ilDeviceNumber.editText.setText(record.deviceNumber)
mBinding.spinnerImaging.setSelection(LevelStationSettingContant.imagingList.indexOf(record.imaging))
}
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
menuInflater.inflate(R.menu.menu_save, menu)
return super.onCreateOptionsMenu(menu)
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
if (item.itemId == R.id.menuSave) {
startSave()
}
return super.onOptionsItemSelected(item)
}
private fun initSpinnerImaging() {
mBinding.spinnerImaging.adapter = ArrayAdapter(
this,
android.R.layout.simple_list_item_1,
LevelStationSettingContant.imagingList
)
}
private fun startSave() {
val watcher = mBinding.ilWatcher.editText.text.toString().trim()
val recorder = mBinding.ilRecorder.editText.text.toString().trim()
val examiner = mBinding.ilExaminer.editText.text.toString().trim()
val ruler1 = mBinding.ilRuler1.editText.text.toString().trim()
val ruler2 = mBinding.ilRuler2.editText.text.toString().trim()
val instrumentModel = mBinding.ilInstrumentModel.editText.text.toString().trim()
val deviceNumber = mBinding.ilDeviceNumber.editText.text.toString().trim()
val imaging = LevelStationSettingUtil.getSpinnerText(mBinding.spinnerImaging)
if (isEmpty(ruler1)) {
ToastUtils.showShort("请输入尺一编号")
return
}
if (isEmpty(ruler2)) {
ToastUtils.showShort("请输入尺二编号")
return
}
lifecycleScope.launch(Dispatchers.IO) {
val iDetectionId = getIDetectionId()
val record =
LevelingDbFactory.instance.iDetectionSettingDataSource.getByIDetectionId(
iDetectionId
)
val saveRecord = record ?: LevelIDetectionSetting(iDetectionId)
saveRecord.watcher = watcher
saveRecord.recorder = recorder
saveRecord.examiner = examiner
saveRecord.rulerNum1 = ruler1
saveRecord.rulerNum2 = ruler2
saveRecord.instrumentModel = instrumentModel
saveRecord.deviceNumber = deviceNumber
saveRecord.imaging = imaging
if (record == null) {
LevelingDbFactory.instance.iDetectionSettingDataSource.save(saveRecord)
} else {
LevelingDbFactory.instance.iDetectionSettingDataSource.update(saveRecord)
}
EventBus.getDefault()
.post(RefreshEvent(RefreshEvent.REFRESH_BY_LEVEL_I_DETECTION_SETTING_UPDATE, null))
finish()
}
}
private fun isEmpty(value: String?) = TextUtils.isEmpty(value)
private fun getIDetectionId() = intent.getStringExtra(BundleConstants.KEY_I_DETECTION_ID)!!
}

@ -0,0 +1,14 @@
package com.bingce.controlnetwork.func.level.idetection
import com.bingce.controlapphelper.datasource.database.leveling.idetection.constants.LevelIDetectionConstant
/**
* 当前测量的测站尺子第几个
*/
class LevelIDetectionSurveyorData(val currentIDetectionId: String) {
var currentStationType = LevelIDetectionConstant.STATION_TYPE_0
var currentMeasureTime = LevelIDetectionConstant.MEASURE_TIME_0
var currentRulerType = -1//默认不选中尺寸,因为可能已经测完
fun isHaveSurveyor() = currentRulerType != -1
}

@ -0,0 +1,34 @@
package com.bingce.controlnetwork.func.level.idetection.adapter;
import android.content.Context;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import com.bingce.controlapphelper.datasource.database.leveling.idetection.list.LevelIDetectionList;
import com.bingce.controlnetwork.databinding.ItemLevelIDetectionListBinding;
import com.bingce.controlnetwork.newui.adapter.BaseAdapterNew;
/**
* i角检测列表
*/
public class LevelIDetectionListAdapter extends BaseAdapterNew<LevelIDetectionListHolder, LevelIDetectionList> {
public LevelIDetectionListAdapter(Context context) {
super(context);
}
@Override
protected void onBindViewHolderDo(LevelIDetectionListHolder holder, int position) {
LevelIDetectionList bean = mDataList.get(position);
holder.mBinding.tvIndex.setText(String.valueOf(position + 1));
holder.mBinding.tvName.setText(bean.name);
}
@NonNull
@Override
public LevelIDetectionListHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
return new LevelIDetectionListHolder(ItemLevelIDetectionListBinding.inflate(getInflater(), parent, false));
}
}

@ -0,0 +1,15 @@
package com.bingce.controlnetwork.func.level.idetection.adapter;
import androidx.recyclerview.widget.RecyclerView;
import com.bingce.controlnetwork.databinding.ItemLevelIDetectionListBinding;
public class LevelIDetectionListHolder extends RecyclerView.ViewHolder {
public final ItemLevelIDetectionListBinding mBinding;
public LevelIDetectionListHolder(ItemLevelIDetectionListBinding binding) {
super(binding.getRoot());
mBinding = binding;
}
}

@ -0,0 +1,120 @@
package com.bingce.controlnetwork.func.level.idetection.adapter;
import static com.bingce.controlapphelper.datasource.database.leveling.idetection.constants.LevelIDetectionConstant.MEASURE_TIME_0;
import static com.bingce.controlapphelper.datasource.database.leveling.idetection.constants.LevelIDetectionConstant.MEASURE_TIME_1;
import static com.bingce.controlapphelper.datasource.database.leveling.idetection.constants.LevelIDetectionConstant.MEASURE_TIME_2;
import static com.bingce.controlapphelper.datasource.database.leveling.idetection.constants.LevelIDetectionConstant.MEASURE_TIME_3;
import static com.bingce.controlapphelper.datasource.database.leveling.idetection.constants.LevelIDetectionConstant.MEASURE_TIME_4;
import static com.bingce.controlapphelper.datasource.database.leveling.idetection.constants.LevelIDetectionConstant.RULER_TYPE_0;
import static com.bingce.controlapphelper.datasource.database.leveling.idetection.constants.LevelIDetectionConstant.RULER_TYPE_1;
import android.content.Context;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import com.bingce.controlapphelper.datasource.database.leveling.idetection.constants.LevelIDetectionConstant;
import com.bingce.controlapphelper.datasource.database.leveling.idetection.isetting.LevelIDetectionSetting;
import com.bingce.controlapphelper.datasource.database.leveling.idetection.record.LevelIDetectionRecord;
import com.bingce.controlapphelper.leveling.detaction.LevelFormatUtil;
import com.bingce.controlapphelper.util.Tools;
import com.bingce.controlnetwork.R;
import com.bingce.controlnetwork.databinding.ItemLevelIDetectionRecordBinding;
import com.bingce.controlnetwork.newui.adapter.BaseAdapterNew;
import java.util.Map;
import com.bingce.controlnetwork.func.level.idetection.LevelIDetectionSurveyorData;
/**
* i角检测列表
*/
public class LevelIDetectionRecordAdapter extends BaseAdapterNew<LevelIDetectionRecordHolder, Map<String, LevelIDetectionRecord>> {
private final LevelIDetectionSurveyorData surveyorData;
private LevelIDetectionSetting stationSetting;
public LevelIDetectionRecordAdapter(Context context, LevelIDetectionSurveyorData surveyorData) {
super(context);
this.surveyorData = surveyorData;
}
@NonNull
@Override
public LevelIDetectionRecordHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
return new LevelIDetectionRecordHolder(ItemLevelIDetectionRecordBinding.inflate(getInflater(), parent, false));
}
@Override
protected void onBindViewHolderDo(LevelIDetectionRecordHolder holder, int position) {
Map<String, LevelIDetectionRecord> recordMap = mDataList.get(0);
//尺子
int rulerType;
if (position == 0) {
rulerType = RULER_TYPE_0;
} else {
rulerType = RULER_TYPE_1;
}
//当前测的尺子选中
boolean isSelect = rulerType == surveyorData.getCurrentRulerType();
if (isSelect) {
holder.mBinding.getRoot().setBackgroundDrawable(Tools.getDrawable(R.drawable.select_mask));
} else {
holder.mBinding.getRoot().setBackgroundColor(Tools.getColor(R.color.white));
}
LevelIDetectionRecord record1 = getRecord(recordMap, rulerType, MEASURE_TIME_0);
LevelIDetectionRecord record2 = getRecord(recordMap, rulerType, MEASURE_TIME_1);
LevelIDetectionRecord record3 = getRecord(recordMap, rulerType, MEASURE_TIME_2);
LevelIDetectionRecord record4 = getRecord(recordMap, rulerType, MEASURE_TIME_3);
LevelIDetectionRecord record5 = getRecord(recordMap, rulerType, MEASURE_TIME_4);
//尺几
holder.mBinding.tvRulerType.setText(LevelIDetectionConstant.getRulerTypeShow(rulerType));
//尺号
holder.mBinding.tvRulerNum.setText(LevelIDetectionConstant.getRulerNumShow(rulerType, stationSetting));
holder.mBinding.tvHeight1.setText(getHeight(record1));
holder.mBinding.tvDistance1.setText(getDistance(record1));
holder.mBinding.tvHeight2.setText(getHeight(record2));
holder.mBinding.tvDistance2.setText(getDistance(record2));
holder.mBinding.tvHeight3.setText(getHeight(record3));
holder.mBinding.tvDistance3.setText(getDistance(record3));
holder.mBinding.tvHeight4.setText(getHeight(record4));
holder.mBinding.tvDistance4.setText(getDistance(record4));
holder.mBinding.tvHeight5.setText(getHeight(record5));
holder.mBinding.tvDistance5.setText(getDistance(record5));
}
private LevelIDetectionRecord getRecord(Map<String, LevelIDetectionRecord> map, int rulerType, int measureTime) {
String recordId = LevelIDetectionRecord.getRecordId(surveyorData.getCurrentIDetectionId(), surveyorData.getCurrentStationType(), rulerType, measureTime);
return map.get(recordId);
}
private String getHeight(LevelIDetectionRecord record) {
if (record == null) {
return "";
}
return LevelFormatUtil.INSTANCE.formatHeight(record.height);
}
private String getDistance(LevelIDetectionRecord record) {
if (record == null) {
return "";
}
return LevelFormatUtil.INSTANCE.formatDistance(record.distance);
}
@Override
public int getItemCount() {
return mDataList == null ? 0 : 2;
}
public void setStationSetting(LevelIDetectionSetting stationSetting) {
this.stationSetting = stationSetting;
}
}

@ -0,0 +1,15 @@
package com.bingce.controlnetwork.func.level.idetection.adapter;
import androidx.recyclerview.widget.RecyclerView;
import com.bingce.controlnetwork.databinding.ItemLevelIDetectionRecordBinding;
public class LevelIDetectionRecordHolder extends RecyclerView.ViewHolder {
public final ItemLevelIDetectionRecordBinding mBinding;
public LevelIDetectionRecordHolder(ItemLevelIDetectionRecordBinding binding) {
super(binding.getRoot());
mBinding = binding;
}
}

@ -0,0 +1,247 @@
package com.bingce.controlnetwork.func.level.idetection.util
import com.bingce.controlnetwork.func.level.idetection.LevelIDetectionSurveyorData
import com.bingce.controlapphelper.datasource.database.leveling.idetection.constants.LevelIDetectionConstant.MEASURE_TIME_0
import com.bingce.controlapphelper.datasource.database.leveling.idetection.constants.LevelIDetectionConstant.MEASURE_TIME_1
import com.bingce.controlapphelper.datasource.database.leveling.idetection.constants.LevelIDetectionConstant.MEASURE_TIME_2
import com.bingce.controlapphelper.datasource.database.leveling.idetection.constants.LevelIDetectionConstant.MEASURE_TIME_3
import com.bingce.controlapphelper.datasource.database.leveling.idetection.constants.LevelIDetectionConstant.MEASURE_TIME_4
import com.bingce.controlapphelper.datasource.database.leveling.idetection.constants.LevelIDetectionConstant.RULER_TYPE_0
import com.bingce.controlapphelper.datasource.database.leveling.idetection.constants.LevelIDetectionConstant.RULER_TYPE_1
import com.bingce.controlapphelper.datasource.database.leveling.idetection.constants.LevelIDetectionConstant.STATION_TYPE_0
import com.bingce.controlapphelper.datasource.database.leveling.idetection.constants.LevelIDetectionConstant.STATION_TYPE_1
import com.bingce.controlapphelper.datasource.database.leveling.idetection.record.LevelIDetectionRecord
/**
* 查找工具
*/
class LevelIDetectionFindUtil {
fun getFindMeasureList(iDetectionId: String): List<LevelIDetectionRecord> {
val station1 = STATION_TYPE_0
val station2 = STATION_TYPE_1
val ruler1 = RULER_TYPE_0
val ruler2 = RULER_TYPE_1
val measureTime1 = MEASURE_TIME_0
val measureTime2 = MEASURE_TIME_1
val measureTime3 = MEASURE_TIME_2
val measureTime4 = MEASURE_TIME_3
val measureTime5 = MEASURE_TIME_4
return listOf(
LevelIDetectionRecord.create(
iDetectionId,
station1,
ruler1,
measureTime1
),
LevelIDetectionRecord.create(
iDetectionId,
station1,
ruler1,
measureTime2
),
LevelIDetectionRecord.create(
iDetectionId,
station1,
ruler1,
measureTime3
),
LevelIDetectionRecord.create(
iDetectionId,
station1,
ruler1,
measureTime4
),
LevelIDetectionRecord.create(
iDetectionId,
station1,
ruler1,
measureTime5
),
LevelIDetectionRecord.create(
iDetectionId,
station1,
ruler2,
measureTime1
),
LevelIDetectionRecord.create(
iDetectionId,
station1,
ruler2,
measureTime2
),
LevelIDetectionRecord.create(
iDetectionId,
station1,
ruler2,
measureTime3
),
LevelIDetectionRecord.create(
iDetectionId,
station1,
ruler2,
measureTime4
),
LevelIDetectionRecord.create(
iDetectionId,
station1,
ruler2,
measureTime5
),
LevelIDetectionRecord.create(
iDetectionId,
station2,
ruler1,
measureTime1
),
LevelIDetectionRecord.create(
iDetectionId,
station2,
ruler1,
measureTime2
),
LevelIDetectionRecord.create(
iDetectionId,
station2,
ruler1,
measureTime3
),
LevelIDetectionRecord.create(
iDetectionId,
station2,
ruler1,
measureTime4
),
LevelIDetectionRecord.create(
iDetectionId,
station2,
ruler1,
measureTime5
),
LevelIDetectionRecord.create(
iDetectionId,
station2,
ruler2,
measureTime1
),
LevelIDetectionRecord.create(
iDetectionId,
station2,
ruler2,
measureTime2
),
LevelIDetectionRecord.create(
iDetectionId,
station2,
ruler2,
measureTime3
),
LevelIDetectionRecord.create(
iDetectionId,
station2,
ruler2,
measureTime4
),
LevelIDetectionRecord.create(
iDetectionId,
station2,
ruler2,
measureTime5
)
)
}
fun getFindMeasureList(
iDetectionId: String,
stationType: Int
): List<LevelIDetectionRecord> {
val ruler1 = RULER_TYPE_0
val ruler2 = RULER_TYPE_1
val measureTime1 = MEASURE_TIME_0
val measureTime2 = MEASURE_TIME_1
val measureTime3 = MEASURE_TIME_2
val measureTime4 = MEASURE_TIME_3
val measureTime5 = MEASURE_TIME_4
return listOf(
LevelIDetectionRecord.create(
iDetectionId,
stationType,
ruler1,
measureTime1
),
LevelIDetectionRecord.create(
iDetectionId,
stationType,
ruler1,
measureTime2
),
LevelIDetectionRecord.create(
iDetectionId,
stationType,
ruler1,
measureTime3
),
LevelIDetectionRecord.create(
iDetectionId,
stationType,
ruler1,
measureTime4
),
LevelIDetectionRecord.create(
iDetectionId,
stationType,
ruler1,
measureTime5
),
LevelIDetectionRecord.create(
iDetectionId,
stationType,
ruler2,
measureTime1
),
LevelIDetectionRecord.create(
iDetectionId,
stationType,
ruler2,
measureTime2
),
LevelIDetectionRecord.create(
iDetectionId,
stationType,
ruler2,
measureTime3
),
LevelIDetectionRecord.create(
iDetectionId,
stationType,
ruler2,
measureTime4
),
LevelIDetectionRecord.create(
iDetectionId,
stationType,
ruler2,
measureTime5
)
)
}
fun find(
recordList: List<LevelIDetectionRecord>,
findCase: (LevelIDetectionRecord) -> Boolean
): LevelIDetectionSurveyorData? {
for (record in recordList) {
if (findCase(record)) {
val surveyorData = LevelIDetectionSurveyorData("")
surveyorData.currentStationType = record.stationType
surveyorData.currentRulerType = record.rulerType
surveyorData.currentMeasureTime = record.measureTime
return surveyorData
}
}
return null
}
}

@ -0,0 +1,39 @@
package com.bingce.controlnetwork.func.level.idetection.viewmodel
import androidx.lifecycle.LiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.bingce.controlapphelper.datasource.database.leveling.LevelingDbFactory
import com.bingce.controlapphelper.datasource.database.leveling.idetection.list.LevelIDetectionList
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
class LevelIDetectionListVm : ViewModel() {
fun getListLiveData(projectId: String): LiveData<List<LevelIDetectionList>> {
return LevelingDbFactory.instance.iDetectionListDataSource.getListByProjectIdDescLiveData(
projectId
)
}
/**
* 创建i角检测
*/
fun saveNewRecord(projectId: String, name: String) {
viewModelScope.launch(Dispatchers.IO) {
val bean = LevelIDetectionList.create(projectId, name)
LevelingDbFactory.instance.iDetectionListDataSource.save(bean)
}
}
/**
* 创建i角检测
*/
fun deleteRecord(bean: LevelIDetectionList) {
viewModelScope.launch(Dispatchers.IO) {
LevelingDbFactory.instance.iDetectionListDataSource.delete(bean)
}
}
}

@ -0,0 +1,361 @@
package com.bingce.controlnetwork.func.level.idetection.viewmodel
import androidx.annotation.WorkerThread
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import blankj.utilcode.util.ToastUtils
import com.bingce.controlnetwork.func.level.idetection.LevelIDetectionCalUtil
import com.bingce.controlnetwork.func.level.idetection.LevelIDetectionSurveyorData
import com.bingce.controlnetwork.func.level.idetection.util.LevelIDetectionFindUtil
import com.bingce.controlapphelper.datasource.database.leveling.LevelingDb
import com.bingce.controlapphelper.datasource.database.leveling.LevelingDbFactory
import com.bingce.controlapphelper.datasource.database.leveling.idetection.constants.LevelIDetectionConstant
import com.bingce.controlapphelper.datasource.database.leveling.idetection.constants.LevelIDetectionConstant.MEASURE_TIME_0
import com.bingce.controlapphelper.datasource.database.leveling.idetection.constants.LevelIDetectionConstant.MEASURE_TIME_1
import com.bingce.controlapphelper.datasource.database.leveling.idetection.constants.LevelIDetectionConstant.MEASURE_TIME_2
import com.bingce.controlapphelper.datasource.database.leveling.idetection.constants.LevelIDetectionConstant.MEASURE_TIME_3
import com.bingce.controlapphelper.datasource.database.leveling.idetection.constants.LevelIDetectionConstant.MEASURE_TIME_4
import com.bingce.controlapphelper.datasource.database.leveling.idetection.constants.LevelIDetectionConstant.RULER_TYPE_1
import com.bingce.controlapphelper.datasource.database.leveling.idetection.isetting.LevelIDetectionSetting
import com.bingce.controlapphelper.datasource.database.leveling.idetection.list.LevelIDetectionList
import com.bingce.controlapphelper.datasource.database.leveling.idetection.record.LevelIDetectionRecord
import com.bingce.controlapphelper.leveling.detaction.LevelFormatUtil
import com.bingce.controlapphelper.util.Tools
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
class LevelIDetectionRecordVm : ViewModel() {
//key 记录id
val dataListAdapter = mutableListOf<Map<String, LevelIDetectionRecord>>()
//key 记录id
private val stationRecordMap = hashMapOf<String, LevelIDetectionRecord>()
lateinit var surveyorData: LevelIDetectionSurveyorData
var measureType: String? = null
var stationSetting: LevelIDetectionSetting? = null
val findUtil = LevelIDetectionFindUtil()
fun initData(
surveyorData: LevelIDetectionSurveyorData,
callBack: (LevelIDetectionList) -> Unit
) {
this.surveyorData = surveyorData
viewModelScope.launch(Dispatchers.IO) {
dataListAdapter.clear()
dataListAdapter.add(stationRecordMap)
val records =
LevelingDbFactory.instance.iDetectionRecordDataSource.getRecordsByIDetectionId(
surveyorData.currentIDetectionId
)
//更新测站设置
updateStationSetting()
for (record in records) {
stationRecordMap[record.id] = record
}
//查询第一个需要测量的数据
val findMeasureDataAll = findMeasureDataAll()
if (findMeasureDataAll != null) {
changeCurrentSurveyorData(findMeasureDataAll)
}
val iDetectionRecord =
LevelingDbFactory.instance.iDetectionListDataSource.getById(surveyorData.currentIDetectionId)
withContext(Dispatchers.Main) {
callBack(iDetectionRecord)
}
}
}
/**
* 存数据
*/
fun receiveData(height: Double, distance: Double) {
if (surveyorData.currentRulerType == -1) {
ToastUtils.showShort("未找到观测尺")
return
}
//存当前测量的数据
val recordId = LevelIDetectionRecord.getRecordId(
surveyorData.currentIDetectionId,
surveyorData.currentStationType,
surveyorData.currentRulerType,
surveyorData.currentMeasureTime
)
val record = LevelIDetectionRecord.create(
surveyorData.currentIDetectionId, surveyorData.currentStationType,
surveyorData.currentRulerType, surveyorData.currentMeasureTime,
height, distance
)
stationRecordMap[recordId] = record
//测完一个数据更新尺子和测量次数
if (surveyorData.currentMeasureTime == MEASURE_TIME_4) {
//最后一个测完了
if (surveyorData.currentRulerType == RULER_TYPE_1) {
//该站全部测完
surveyorData.currentRulerType = -1
surveyorData.currentMeasureTime = MEASURE_TIME_0
Tools.speak("该测站测量完毕")
} else {
//一尺测量完
surveyorData.currentRulerType = RULER_TYPE_1
surveyorData.currentMeasureTime = MEASURE_TIME_0
Tools.speak("尺一测量完毕")
}
} else {
//不是最后一次直接加
surveyorData.currentMeasureTime++
if (surveyorData.currentMeasureTime > MEASURE_TIME_4) {
surveyorData.currentMeasureTime = MEASURE_TIME_4
}
}
//存数据库
viewModelScope.launch(Dispatchers.IO) {
LevelingDb.getInstance().iDetectionRecordDao().save(record)
}
}
/**
* 找第一个没有数据的
*/
private fun findMeasureDataAll(): LevelIDetectionSurveyorData? {
val recordList = findUtil.getFindMeasureList(surveyorData.currentIDetectionId)
return findUtil.find(recordList) {
stationRecordMap[it.id] == null
}
}
/**
* 找第一个没有数据的
*/
fun switchStation(stationType: Int) {
val recordList = findUtil.getFindMeasureList(surveyorData.currentIDetectionId, stationType)
val find = findUtil.find(recordList) {
stationRecordMap[it.id] == null
}
if (find != null) {
changeCurrentSurveyorData(find)
} else {
val surveyorData = LevelIDetectionSurveyorData("")
surveyorData.currentStationType = stationType
changeCurrentSurveyorData(surveyorData)
}
}
private fun changeCurrentSurveyorData(surveyorData: LevelIDetectionSurveyorData) {
this.surveyorData.currentStationType = surveyorData.currentStationType
this.surveyorData.currentRulerType = surveyorData.currentRulerType
this.surveyorData.currentMeasureTime = surveyorData.currentMeasureTime
}
/**
* 找最后一个有数据的
*/
fun findRollBackData(): LevelIDetectionSurveyorData? {
val recordList = findUtil.getFindMeasureList(
surveyorData.currentIDetectionId,
surveyorData.currentStationType
).reversed()
return findUtil.find(recordList) {
stationRecordMap[it.id] != null
}
}
/**
* 回退删除数据
* 一次删一个测站的一个尺子的数据
*/
fun deleteStationRulerData(findRollBackData: LevelIDetectionSurveyorData, success: () -> Unit) {
viewModelScope.launch(Dispatchers.IO) {
val deleteIDetectionId = surveyorData.currentIDetectionId
val deleteStationType = findRollBackData.currentStationType
val deleteRulerType = findRollBackData.currentRulerType
val recordId1 = LevelIDetectionRecord.getRecordId(
deleteIDetectionId,
deleteStationType,
deleteRulerType,
MEASURE_TIME_0
)
val recordId2 = LevelIDetectionRecord.getRecordId(
deleteIDetectionId,
deleteStationType,
deleteRulerType,
MEASURE_TIME_1
)
val recordId3 = LevelIDetectionRecord.getRecordId(
deleteIDetectionId,
deleteStationType,
deleteRulerType,
MEASURE_TIME_2
)
val recordId4 = LevelIDetectionRecord.getRecordId(
deleteIDetectionId,
deleteStationType,
deleteRulerType,
MEASURE_TIME_3
)
val recordId5 = LevelIDetectionRecord.getRecordId(
deleteIDetectionId,
deleteStationType,
deleteRulerType,
MEASURE_TIME_4
)
//删除缓存
stationRecordMap.remove(recordId1)
stationRecordMap.remove(recordId2)
stationRecordMap.remove(recordId3)
stationRecordMap.remove(recordId4)
stationRecordMap.remove(recordId5)
//删除数据
LevelingDbFactory.instance.iDetectionRecordDataSource.deleteById(recordId1)
LevelingDbFactory.instance.iDetectionRecordDataSource.deleteById(recordId2)
LevelingDbFactory.instance.iDetectionRecordDataSource.deleteById(recordId3)
LevelingDbFactory.instance.iDetectionRecordDataSource.deleteById(recordId4)
LevelingDbFactory.instance.iDetectionRecordDataSource.deleteById(recordId5)
//确定要测哪个
findRollBackData.currentMeasureTime = MEASURE_TIME_0
changeCurrentSurveyorData(findRollBackData)
withContext(Dispatchers.Main) {
success()
}
}
}
/**
* 保存测量方式
*/
fun saveMeasureType(iDetectionId: String, measureType: String) {
viewModelScope.launch(Dispatchers.IO) {
val record =
LevelingDbFactory.instance.iDetectionListDataSource.getById(iDetectionId)
record.measureType = measureType
LevelingDbFactory.instance.iDetectionListDataSource.update(record)
}
}
/**
* 单位mm
* d1短距
* d2长距
*/
fun startResult(d1: Double, d2: Double): String? {
val findMeasureList = findUtil.getFindMeasureList(surveyorData.currentIDetectionId)
for (needCheckItem in findMeasureList) {
val levelIDetectionRecord = stationRecordMap[needCheckItem.id]
if (levelIDetectionRecord == null) {
ToastUtils.showShort(LevelIDetectionConstant.getStationTypeShow(needCheckItem.stationType) + "数据不完整")
return null
}
}
val iResult = LevelIDetectionCalUtil.getIResult(
surveyorData.currentIDetectionId,
measureType!!,
d1,
d2,
stationRecordMap
)
val hint = if (iResult.isFinite()) {
val formatAngle = LevelFormatUtil.formatAngle(iResult)
saveIResult(formatAngle)
if (iResult > 15) {
"i角计算结果:$formatAngle\"\n大于15\",请校正仪器"
} else {
"i角计算结果:$formatAngle\"\n合限"
}
} else {
saveIResult(null)
"i角计算结果:数据异常,请检查"
}
return hint
}
/**
* 存短长距和测量方法
* 这些变化快统一存
*/
private fun saveIResult(iResult: String?) {
viewModelScope.launch(Dispatchers.IO) {
val iDetectionItem =
LevelingDbFactory.instance.iDetectionListDataSource.getById(surveyorData.currentIDetectionId)
iDetectionItem.iResult = iResult
LevelingDbFactory.instance.iDetectionListDataSource.update(iDetectionItem)
}
}
/**
* 存短长距和测量方法
* 这些变化快统一存
*/
fun saveShortLongDistanceMeasureType(d1Short: String, d2Long: String) {
viewModelScope.launch(Dispatchers.IO) {
val iDetectionItem =
LevelingDbFactory.instance.iDetectionListDataSource.getById(surveyorData.currentIDetectionId)
iDetectionItem.shortDistance = d1Short
iDetectionItem.longDistance = d2Long
iDetectionItem.measureType = measureType
LevelingDbFactory.instance.iDetectionListDataSource.update(iDetectionItem)
}
}
fun getGetDadaAuto(iDetectionId: String, callBack: (Boolean) -> Unit) {
viewModelScope.launch(Dispatchers.IO) {
val record =
LevelingDbFactory.instance.iDetectionSettingDataSource.getByIDetectionId(
iDetectionId
)
withContext(Dispatchers.Main) {
if (record == null) {
callBack(true)
} else {
callBack(!record.getDataManually)
}
}
}
}
fun setGetDataAuto(iDetectionId: String, auto: Boolean) {
viewModelScope.launch(Dispatchers.IO) {
var record =
LevelingDbFactory.instance.iDetectionSettingDataSource.getByIDetectionId(
iDetectionId
)
if (record == null) {
record = LevelIDetectionSetting(iDetectionId)
record.getDataManually = !auto
LevelingDbFactory.instance.iDetectionSettingDataSource.save(record)
} else {
record.getDataManually = !auto
LevelingDbFactory.instance.iDetectionSettingDataSource.update(record)
}
}
}
@WorkerThread
fun updateStationSetting() {
stationSetting =
LevelingDbFactory.instance.iDetectionSettingDataSource.getByIDetectionId(
surveyorData.currentIDetectionId
)
}
}

@ -0,0 +1,8 @@
package com.bingce.controlnetwork.func.level.sendreceive
import com.bingce.controlapphelper.leveling.detaction.LevelReceiveData
interface ILevelBackData {
fun receive(data: LevelReceiveData)
fun measureError(msg: String)
}

@ -0,0 +1,85 @@
package com.bingce.controlnetwork.func.level.sendreceive
import blankj.utilcode.util.ToastUtils
import cn.liuyanbing.surveyor.function.level.sendreceive.LevelRequestState
import com.bingce.controlapphelper.leveling.detaction.LevelReceiveData
import com.bingce.controlnetwork.App
abstract class LevelRequest(protected val backDataI: ILevelBackData) {
private var requestTime = 0L
private var requestState = LevelRequestState.INIT
private val receiveDataList = mutableListOf<LevelReceiveData>()
abstract fun doRequest()
abstract fun onStart()
abstract fun onDestroy()
abstract fun sendCommand()
fun requeset() {
if (checkRequestNot()) {
return
}
requestState = LevelRequestState.REQUEST_ING
requestTime = System.currentTimeMillis()
//获取数据
doRequest()
}
private fun checkRequestNot(): Boolean {
val intervalTime = System.currentTimeMillis() - requestTime
// if (intervalTime < 600) {
// return true
// }
if (requestState == LevelRequestState.REQUEST_ING) {
ToastUtils.showShort("测量中,请稍后...")
return true
}
if (requestState == LevelRequestState.REQUEST_ING) {
if (intervalTime > 20000) {
//超过20秒回复默认状态
requestState = LevelRequestState.INIT
}
}
return false
}
protected fun resetInit() {
requestTime = 0
requestState = LevelRequestState.INIT
}
protected fun addReceiveData(data: LevelReceiveData) {
receiveDataList.add(data)
}
protected fun clearReceiveDataList() {
receiveDataList.clear()
}
protected fun isNeedRequestAgain(): Boolean {
val levelSurveyorTime = App.getApp().levelSurveyorTime.toInt()
return receiveDataList.size < levelSurveyorTime
}
/**
* 获取返回的数据
*/
protected fun getBackData(): LevelReceiveData {
var height = 0.0
var distance = 0.0
for (item in receiveDataList) {
height += item.height
distance += item.distance
}
val size = receiveDataList.size
return LevelReceiveData(height / size, distance / size)
}
protected fun hasData() = receiveDataList.isNotEmpty()
}

@ -0,0 +1,60 @@
package cn.liuyanbing.surveyor.function.level.sendreceive
import blankj.utilcode.util.ToastUtils
import com.bingce.controlapphelper.leveling.detaction.LevelReceiveData
import com.bingce.controlnetwork.func.level.sendreceive.ILevelBackData
import com.bingce.controlnetwork.func.level.sendreceive.LevelRequest
import com.bingce.device.Device
import com.bingce.level.Level
import com.bingce.level.LevelListener
/**
* 发布版
*/
class LevelRequestRelease(backDataI: ILevelBackData) : LevelRequest(backDataI),
LevelListener.LevelReadListener {
override fun doRequest() {
if (!Device.getInstance().isDeviceConnected) {
ToastUtils.showShort("设备未连接,请连接设备")
resetInit()
return
}
ToastUtils.showShort("开始测量")
sendCommand()
}
override fun onStart() {
//LevelListener
LevelListener.getInstance().addLevelReadListener(this)
}
override fun onDestroy() {
LevelListener.getInstance().removeLevelReadListener(this)
}
override fun onReadSuccess(height: Double, distance: Double) {
addReceiveData(LevelReceiveData(height, distance))
if (isNeedRequestAgain()) {
sendCommand()
return
}
if (hasData()) {
backDataI.receive(getBackData())
}
clearReceiveDataList()
resetInit()
}
override fun onReadFailed(errorCode: String?, errorMsg: String?, original: String?) {
val error = errorMsg ?: ""
backDataI.measureError(error)
clearReceiveDataList()
resetInit()
}
override fun sendCommand() {
Level.getInstance().requestMeasure()
}
}

@ -0,0 +1,8 @@
package cn.liuyanbing.surveyor.function.level.sendreceive
import androidx.annotation.Keep
@Keep
enum class LevelRequestState {
INIT,REQUEST_ING
}

File diff suppressed because one or more lines are too long

@ -0,0 +1,84 @@
package com.bingce.controlnetwork.func.level.util;
import com.bingce.controlnetwork.func.level.util.suntime.SunTimes;
import java.text.SimpleDateFormat;
import java.time.Duration;
import java.time.LocalTime;
import java.time.ZonedDateTime;
import java.util.Date;
public class LevelDateUtil {
/**
* 34.757975, 113.665412
*
* @param lat
* @param lng
*/
public static String getLevelOperateSunTimeHint(double lat, double lng) {
ZonedDateTime now = ZonedDateTime.now();
SunTimes times = SunTimes.compute()
.on(now.with(LocalTime.MIN)) // set a date
.at(lat, lng) // set a location
.execute(); // get the results
ZonedDateTime rise = times.getRise();
ZonedDateTime set = times.getSet();
if (rise == null || set == null) {
//未计算出日出和日落时间
return null;
}
// 计算日中时间
ZonedDateTime noon = rise.plus(Duration.between(rise, set).dividedBy(2));
// 计算前后两个小时的时间窗口
ZonedDateTime startWindow = noon.minusHours(2);
ZonedDateTime endWindow = noon.plusHours(2);
ZonedDateTime riseAfter2 = rise.plusMinutes(30);
ZonedDateTime setBefore2 = set.minusMinutes(30);
boolean isWithinTwoHoursOfNoon = !now.isBefore(startWindow) && !now.isAfter(endWindow);
if (now.isBefore(riseAfter2)) {
//当前时间在日出前2小时内
return "请在日出后30分钟进行作业";
}
if (now.isAfter(setBefore2)) {
//当前时间在日落后2小时
return "请在日落前30分钟进行作业";
}
// 输出结果
if (isWithinTwoHoursOfNoon) {
//当前时间在日中前后2小时内
return "请勿在日中前后2小时内进行作业";
}
return null;
}
public static String dateToYearMonthDayHourMin(Date date) {
SimpleDateFormat simple = new SimpleDateFormat("yyyy年MM月dd日HH:mm");
return simple.format(date);
}
public static String getLevelHeadDateYearMonthDay(Date date) {
SimpleDateFormat simple = new SimpleDateFormat("yyyy年MM月dd日");
return simple.format(date);
}
public static String getLevelHeadDateHourMin(Date date) {
SimpleDateFormat simple = new SimpleDateFormat("HH:mm");
return simple.format(date);
}
public static String getHourMinSec(Date date) {
SimpleDateFormat simple = new SimpleDateFormat("HH:mm:ss");
return simple.format(date);
}
}

@ -0,0 +1,704 @@
package com.bingce.controlnetwork.func.level.util
import android.text.TextUtils
import androidx.annotation.WorkerThread
import blankj.utilcode.util.Utils
import cn.liuyanbing.surveyor.function.level.export.LevelExportIDetection
import com.bingce.controlnetwork.func.level.export.LevelExportSingalHeight
import com.bingce.controlapphelper.datasource.database.SurveyorDatabaseFactory
import com.bingce.controlapphelper.datasource.database.leveling.LevelingDbFactory
import com.bingce.controlapphelper.datasource.database.leveling.measure.backfront.LevelingMeasureBackFrontRecord
import com.bingce.controlapphelper.datasource.database.leveling.route.LevelRouteRecord
import com.bingce.controlapphelper.datasource.database.leveling.station.LevelingStationRecord
import com.bingce.controlapphelper.datasource.database.point.PointRecord
import com.bingce.controlapphelper.leveling.detaction.LevelFormatUtil
import com.bingce.controlapphelper.model.LevelExportLine
import com.bingce.controlapphelper.model.LevelingMeasureOrder
import com.bingce.controlapphelper.model.LevelingMeasureOrderUtil
import com.bingce.controlapphelper.model.LevelingStationState
import com.bingce.controlapphelper.model._N
import com.bingce.controlapphelper.surveyor.method.ExportStationMethod
import com.bingce.controlapphelper.surveyor.method.ExportUtils
import com.bingce.controlapphelper.util.DateUtil
import com.bingce.utils.DateUtils
import com.bingce.utils.Util
import java.io.File
class LevelExportUtilTj {
companion object {
const val EXPORT_LEVEL_FOLDER = "Leveling"
//导出的外层目录
val exportOutFolder = File(Utils.getApp().externalCacheDir, EXPORT_LEVEL_FOLDER)
}
private lateinit var exportRouteFolder: File
private lateinit var exportProjectFolder: File
private var column1Index = 0
private var startPointHeight = 0.0
private var startPointName = ""
private var endPointName = ""
private val printSbLev = StringBuilder()
/**
* 导出路线文件夹下的数据
*/
@WorkerThread
fun doExportRouteData(projectId: String, routeId: String) {
val routeRecord = LevelingDbFactory.instance.levelDataSource.getByIdSync(routeId)
?: throw IllegalArgumentException("routeRecord==null")
//路线的基础数据
confirmRouteCommonData(routeRecord)
//收集路线的具体数据
collectRouteLevData(projectId, routeRecord)
}
private fun confirmRouteCommonData(it: LevelRouteRecord) {
val startPoint =
SurveyorDatabaseFactory.instance.pointDataSource.findByIdSync(it.startPointId)
startPointHeight = getPointHeight(startPoint)
startPointName = getPointName(startPoint)
val endPoint = SurveyorDatabaseFactory.instance.pointDataSource.findByIdSync(it.endPointId)
endPointName = getPointName(endPoint)
}
private fun collectRouteLevData(projectId: String, it: LevelRouteRecord) {
val routeId = it.getId()
val routeName = it.routeName
val levelingMeasureOrder = it.levelingMeasureOrder
val isHasTwiceStation = when (levelingMeasureOrder) {
LevelingMeasureOrder.SIM_BF,
LevelingMeasureOrder.SIM_BFFB -> {
true
}
else -> false
}
collectRouteLevDataLeftOrRight(
projectId,
routeId,
false,
levelingMeasureOrder
)
if (isHasTwiceStation) {
collectRouteLevDataLeftOrRight(
projectId,
routeId,
true,
levelingMeasureOrder
)
}
if (printSbLev.isNotEmpty()) {
initExportFile(projectId, routeName)
if (::exportRouteFolder.isInitialized) {
saveRouteLevFile(exportRouteFolder, routeName)
saveRouteTxtFile(exportRouteFolder, routeId, routeName)
saveRouteInfoFile(exportRouteFolder, projectId, routeId, routeName)
}
}
}
/**
* INF 观测记录
*/
private fun saveRouteInfoFile(
exportFolder: File,
projectId: String,
routeId: String,
routeName: String
) {
val projectRecord = SurveyorDatabaseFactory.instance.projectDataSource.getRecord(projectId)
val routeRecord = LevelingDbFactory.instance.levelDataSource.getByIdSync(routeId)!!
val toleranceTetail =
LevelingDbFactory.instance.toleranceDetailDataSource.getRecordSync(projectRecord.toleranceId)
val startPointNameRoute =
SurveyorDatabaseFactory.instance.pointDataSource.findByIdSync(routeRecord.startPointId)
.getName()
val endPointNameRoute =
SurveyorDatabaseFactory.instance.pointDataSource.findByIdSync(routeRecord.endPointId)
.getName()
//作业单位
val measureUnit = projectRecord.measureUnit ?: ""
//限差等级
val exportGrade = toleranceTetail.exportGrade
//测站数量 单程双转的按照twiceStaion false处理
val stationCount =
LevelingDbFactory.instance.stationDataSource.getCountByRoute(projectId, routeId, false)
val stationListLeft =
LevelingDbFactory.instance.stationDataSource.getStationList(projectId, routeId, false)
val stationListRight =
LevelingDbFactory.instance.stationDataSource.getStationList(projectId, routeId, true)
val remeasureCountAll =
getRemeasureCount(stationListLeft) + getRemeasureCount(stationListRight)
//8,9,10行
val routeDistanceHeightInfo =
getRouteDistanceHeightInfo(
stationListLeft?.lastOrNull(),
stationListRight?.lastOrNull()
)
val record = LevelingDbFactory.instance.stationSettingDataSource.getLatest(routeId)
record?.let {
val sb = StringBuilder()
//第一行
sb.append(measureUnit).append(",")
sb.append(exportToString(it.watcher)).append(",")
sb.append(exportToString(it.recorder)).append(",")
sb.append(exportToString(it.examiner)).append("\n")
//第二行
sb.append(exportGrade).append(",")
sb.append("").append(",")//观测方法:自动采集法
sb.append(routeRecord.observationDirection).append(",")
sb.append(stationCount).append(",")//测站数
sb.append(remeasureCountAll).append("\n")//重测数
//第三行
sb.append(exportToString(it.instrumentModel)).append(",")
sb.append("No.${exportToString(it.deviceNumber)}").append(",")
sb.append("").append(",")//测微读数精度
sb.append("").append(",")//视距乘常数
sb.append("").append("\n")//视距加常数
//第四行
sb.append(exportToString(it.rulerType)).append(",")
sb.append("").append(",")//标尺分划
sb.append(exportToString(it.rulerReceptType)).append("\n")//尺承类型
//第五行
sb.append(startPointNameRoute).append(",")//起点
sb.append(endPointNameRoute).append("\n")//终点
//第六行
sb.append(exportToString(it.firstStationBackFootNumber)).append(",")
sb.append(exportToString(it.firstStationFrontFootNumber)).append("\n")
//第七行
sb.append(exportToString(it.firstStationBackFootNumber2)).append(",")
sb.append(exportToString(it.firstStationFrontFootNumber2)).append("\n")
//第八行
sb.append(routeDistanceHeightInfo)
ExportStationMethod.save(sb.toString(), exportFolder, "${routeName}.INF")
}
}
/**
* INFO文件里的距离和高差
*/
private fun getRouteDistanceHeightInfo(
leftEndStation: LevelingStationRecord?,
rightEndStation: LevelingStationRecord?
): String {
val sb = StringBuilder()
if (leftEndStation == null && rightEndStation == null) {
sb.append("").append(",").append("").append(",").append("").append(",").append("")
.append("\n")
.append(",").append("\n")
.append("").append("\n")
.append("").append("\n")
return sb.toString()
}
val left =
LevelingDbFactory.instance.measureStationDataSource.getRecordSync(leftEndStation?.getId())
val right =
LevelingDbFactory.instance.measureStationDataSource.getRecordSync(rightEndStation?.getId())
val distanceTotalLeft = formatDistance(left?.distanceTotal)
val heightDiffTotalLeft = formatDistance(left?.heightDiffTotal)
val distanceTotalRight = formatDistance(right?.distanceTotal)
val heightDiffTotalRight = formatDistance(right?.heightDiffTotal)
val heightAverage = if (left?.heightDiffTotal != null && right?.heightDiffTotal != null) {
formatDistance((left.heightDiffTotal + right.heightDiffTotal) / 2)
} else if (left?.heightDiffTotal != null) {
formatDistance(left.heightDiffTotal)
} else {
""
}
//测段不符值 右-左
val rightLeftHeightDiff =
if (left?.heightDiffTotal != null && right?.heightDiffTotal != null) {
formatDistance(right.heightDiffTotal - left.heightDiffTotal)
} else {
"0"
}
sb.append(distanceTotalLeft).append(",").append(heightDiffTotalLeft).append(",")
.append(distanceTotalRight).append(",").append(heightDiffTotalRight).append("\n")
//第二行
.append(heightAverage).append("\n")
//第三行
.append(rightLeftHeightDiff).append("\n")
return sb.toString()
}
private fun formatDistance(value: Double?): String {
if (value == null) {
return ""
}
return ExportUtils.formatDistance(value)
}
private fun exportToString(value: String?) = value ?: ""
/**
* 通过测站列表获取重测数量
*/
@WorkerThread
private fun getRemeasureCount(stationList: List<LevelingStationRecord>): Int {
var count = 0
for (station in stationList) {
val remeasureCountByStationId =
LevelingDbFactory.instance.measureBackFrontDataSource.getRemeasureCountByStationId(
station.getId()
)
count += remeasureCountByStationId
}
return count
}
/**
* TXT 观测条件
*/
private fun saveRouteTxtFile(exportFolder: File, routeId: String, routeName: String) {
// //起点,终点,照准次序,测站数量,路线总长度(km),路线总高差
// val routeRecord = TjDbFactory.instance.routeDataSource.getByIdSync(routeId) ?: return
// val startPointName =
// TjDbFactory.instance.pointDataSource.findByIdSync(routeRecord.startPointId).name
// val endPointName =
// TjDbFactory.instance.pointDataSource.findByIdSync(routeRecord.endPointId).name
// val orderText =
// LevelingMeasureOrderUtil.getTextByLevelingMeasureOrder(routeRecord.levelingMeasureOrder)
//
// val stationCount = LevelingDbFactory.instance.stationDataSource.getCountByRoute(
// routeRecord.projectId,
// routeId,
// false
// )
//
// val stationLatest = LevelingDbFactory.instance.stationDataSource.getStationLatest(
// routeRecord.projectId,
// routeId
// )
//
// val measureStationList = mutableListOf<LevelingMeasureStationRecord>()
// val measureStationRecordLast =
// LevelingDbFactory.instance.measureStationDataSource.getRecordSync(stationLatest.getId())
// if (stationLatest.twiceStation) {
// val measureStationRecordLeft =
// LevelingDbFactory.instance.measureStationDataSource.getRecordSync(stationLatest.lastStationId)
// measureStationList.add(measureStationRecordLeft)
// measureStationList.add(measureStationRecordLast)
// } else {
// measureStationList.add(measureStationRecordLast)
// }
//
// val sb = StringBuilder()
// for (item in measureStationList) {
// sb.append(startPointName).append(",")
// sb.append(endPointName).append(",")
// sb.append(orderText).append(",")
// sb.append(stationCount).append(",")
//
// sb.append(ExportUtilsTj.formatDistance(item.distanceTotal)).append(",")
// sb.append(ExportUtilsTj.formatDistance(item.heightDiffTotal))
// sb.append("\n")
// }
//观测条件list
val observationConditionList =
LevelingDbFactory.instance.stationSettingDataSource.getByRouteId(routeId)
val sb = StringBuilder()
for (item in observationConditionList) {
val station =
LevelingDbFactory.instance.stationDataSource.getRecordSync(item.stationId)
val stationNum = station.stationName.replace("测站", "")
//第一行
sb.append(stationNum).append(",")
.append(LevelDateUtil.dateToYearMonthDayHourMin(item.createDate)).append("\n")
//第二行
sb.append(exportToString(item.temperature)).append(",")
.append(exportToString(item.sunDirection)).append(",")
.append(exportToString(item.imaging)).append(",")
.append(exportToString(item.weather)).append("\n")
//第三行
sb.append(exportToString(item.windDirection)).append(",")
.append(exportToString(item.windSpeed)).append(",")
.append(exportToString(item.roads)).append(",")
.append(exportToString(item.soil)).append("\n")
}
ExportStationMethod.save(sb.toString(), exportFolder, "${routeName}.TXT")
}
private fun removeLastBuilder(sb: StringBuilder) {
if (sb.isNotEmpty()) {
sb.deleteCharAt(sb.lastIndex)
}
}
private fun saveRouteLevFile(exportFolder: File, routeName: String) {
ExportStationMethod.save(printSbLev.toString(), exportFolder, "${routeName}.LEV")
}
private fun initExportFile(projectId: String, routeName: String) {
exportProjectFolder = initExportProjectFolder(projectId)
confirmRouteFolder(exportProjectFolder, routeName)
}
private fun initExportProjectFolder(projectId: String): File {
val exportFolder = File(Utils.getApp().externalCacheDir, EXPORT_LEVEL_FOLDER)
if (!exportFolder.exists()) {
exportFolder.mkdirs()
}
val projectName =
SurveyorDatabaseFactory.instance.projectDataSource.getRecord(projectId).projectName
val projectFolder = File(exportFolder, projectName)
if (!projectFolder.exists()) {
projectFolder.mkdir()
}
return projectFolder
}
/**
* 重名项目或路线文件夹增加_1
*/
private fun confirmRouteFolder(exportProjectFolder: File, name: String) {
val exportFolderTarget = File(exportProjectFolder, name)
if (!exportFolderTarget.exists()) {
exportFolderTarget.mkdir()
this.exportRouteFolder = exportFolderTarget
return
}
confirmRouteFolder(exportProjectFolder, name + "_1")
}
/**
* 收集左线或者右线的数据
*/
private fun collectRouteLevDataLeftOrRight(
projectId: String,
routeId: String,
twiceStation: Boolean,
levelingMeasureOrder: LevelingMeasureOrder
) {
val orderText =
LevelingMeasureOrderUtil.getTextByLevelingMeasureOrder(levelingMeasureOrder)
val stationList = LevelingDbFactory.instance.stationDataSource.getStationList(
projectId,
routeId,
twiceStation
)
var finishIndex = 0
for ((index, station) in stationList.withIndex()) {
if (station.stationState != LevelingStationState.FINISH)
break
if (index == 0) {
appendStartOrEndLine("Start-Line", orderText)
appendRouteStationHead(routeId, station)
appendZ(station.backSightPointId, startPointHeight)
}
//测量数据
appendMeasureData(station)
finishIndex = index
column1Index++
}
//最后完成测站
val lastFinishStation = stationList[finishIndex]
val stationHeightDiffTotal = getStationHeightDiffTotal(lastFinishStation)
//结束点高程
appendZ(
lastFinishStation.frontSightPointId,
getFrontPointZ(stationHeightDiffTotal)
)
column1Index++
//end-line
appendStartOrEndLine("End-Line", "")
}
private fun getStationHeightDiffTotal(stationRecord: LevelingStationRecord): Double {
//当前站的累积高差
return LevelingDbFactory.instance.measureStationDataSource.getRecordSync(stationRecord.getId()).heightDiffTotal
}
private fun getFrontPointZ(heightDiffTotal: Double) = startPointHeight + heightDiffTotal
private fun appendStartOrEndLine(startOrEndLine: String, column2Name3: String) {
val dataFirstLine = LevelExportLine(
LevelExportLine.Column1(column1Index),
LevelExportLine.Column2("TO", startOrEndLine, column2Name3),
LevelExportLine.ColumnHeight("", ""),
LevelExportLine.ColumnDistance(""),
LevelExportLine.ColumnEnd(null, null)
).getData()
printSbLev.append(dataFirstLine).append(_N)
column1Index++
}
/**
* 路线的首站头
* 起点终点等
*/
private fun appendRouteStationHead(routeId: String, station: LevelingStationRecord) {
val stationSetting = LevelingDbFactory.instance.stationSettingDataSource.getLatest(routeId)
val measureDataList =
LevelingDbFactory.instance.measureBackFrontDataSource.getMeasureDataList(station.getId())
val firstRecordDate = measureDataList.first().createDate
val endRecordDate = measureDataList.last().createDate
val levelHeadDateYearMonthDay =
LevelDateUtil.getLevelHeadDateYearMonthDay(firstRecordDate)
val startHourMin = LevelDateUtil.getLevelHeadDateHourMin(firstRecordDate)
val endHourMin = LevelDateUtil.getLevelHeadDateHourMin(endRecordDate)
val line1 = getRouteStationHeadLine("startName", startPointName)
printSbLev.append(line1).append(_N)
val line2 = getRouteStationHeadLine("endName", endPointName)
printSbLev.append(line2).append(_N)
val line3 = getRouteStationHeadLine("observationDate", levelHeadDateYearMonthDay)
printSbLev.append(line3).append(_N)
val line4 = getRouteStationHeadLine("observationStartTime", startHourMin)
printSbLev.append(line4).append(_N)
val line5 = getRouteStationHeadLine("observationEndTime", endHourMin)
printSbLev.append(line5).append(_N)
val line6 = getRouteStationHeadLine("weather", stationSetting.weather ?: "")
printSbLev.append(line6).append(_N)
val line7 = getRouteStationHeadLine("imaging", stationSetting.imaging ?: "")
printSbLev.append(line7).append(_N)
column1Index++
}
private fun getRouteStationHeadLine(key: String, value: String): String {
return LevelExportLine(
LevelExportLine.Column1(column1Index),
LevelExportLine.Column2("INF", "", ""),
LevelExportLine.ColumnHeight(key, ""),
LevelExportLine.ColumnDistance(""),
LevelExportLine.ColumnEnd(value, "")
).getData()
}
/**
* 测量数据
*/
private fun appendMeasureData(station: LevelingStationRecord) {
val measureDataList =
LevelingDbFactory.instance.measureBackFrontDataSource.getMeasureDataList(station.getId())
val stationHeightDiffTotal = getStationHeightDiffTotal(station)
val backDataList = mutableListOf<LevelingMeasureBackFrontRecord>()
val frontDataList = mutableListOf<LevelingMeasureBackFrontRecord>()
for ((index, record) in measureDataList.withIndex()) {
val point = getPoint(record.measurePointId)
val pointName = getPointName(point)
var rbOrRf: String
if (record.measurePointId == station.backSightPointId) {
rbOrRf = "Rb"
backDataList.add(record)
} else {
rbOrRf = "Rf"
frontDataList.add(record)
}
val time = DateUtil.formatDateHHmmss(record.createDate)
val line = LevelExportLine(
LevelExportLine.Column1(column1Index),
LevelExportLine.Column2("KD1", pointName, time),
LevelExportLine.ColumnHeight(rbOrRf, "${record.measureHeightShow} m"),
LevelExportLine.ColumnDistance(record.measureDistanceShow),
LevelExportLine.ColumnEnd(null, null)
).getData()
printSbLev.append(line).append(_N)
//最后再增加一行
if (index == measureDataList.lastIndex) {
//每一站的结果
column1Index++
appendZ(point.getId(), getFrontPointZ(stationHeightDiffTotal))
}
column1Index++
}
}
private fun getPointHeight(point: PointRecord?): Double {
return point?.getZ() ?: 0.0
}
private fun getPointName(point: PointRecord?): String {
return point?.getName() ?: ""
}
private fun getPoint(pointId: String): PointRecord {
return SurveyorDatabaseFactory.instance.pointDataSource.findByIdSync(pointId)
}
private fun appendZ(pointId: String, height: Double) {
val startPoint = getPoint(pointId)
val z = LevelFormatUtil.formatHeight(height)
val dataSecondLine = LevelExportLine(
LevelExportLine.Column1(column1Index),
LevelExportLine.Column2("KD1", getPointName(startPoint), ""),
LevelExportLine.ColumnHeight("", ""),
LevelExportLine.ColumnDistance(""),
LevelExportLine.ColumnEnd("Z", "$z m")
).getData()
printSbLev.append(dataSecondLine).append(_N)
column1Index++
}
data class CalTotal(var heightDiffTotal: Double = 0.0, var distanceTotal: Double = 0.0) {
fun addHeightDiffTotal(heightDiffTotal: Double) {
this.heightDiffTotal += heightDiffTotal
}
fun addDistanceTotal(distanceTotal: Double) {
this.distanceTotal += distanceTotal
}
}
@WorkerThread
fun exportProjectTxt(projectId: String) {
val projectFolder = initExportProjectFolder(projectId)
val projectRecord = SurveyorDatabaseFactory.instance.projectDataSource.getRecord(projectId)
val text = projectRecord.projectName +
"," +
"" +
"," +
"," +
"," +
"," +
"," +
"," +
"," +
(if (projectRecord == null) "" else projectRecord.getMeasureUnit()) +
"," +
(if (projectRecord == null) "" else DateUtils.toDate(projectRecord.getCreateDate())) +
"\n"
ExportStationMethod.save(
text,
projectFolder,
"project.TXT"
)
}
fun exportControlTxt(projectId: String) {
val projectFolder = initExportProjectFolder(projectId)
val knownList = SurveyorDatabaseFactory.instance.pointDataSource.getListByProjectId(
projectId,
PointRecord.TYPE_KNOWN_POINT
)
val unknownList = SurveyorDatabaseFactory.instance.pointDataSource.getListByProjectId(
projectId,
PointRecord.TYPE_UNKNOWN_POINT
)
val stringBuilder = StringBuilder()
appendExportPoint(stringBuilder, knownList)
appendExportPoint(stringBuilder, unknownList)
ExportStationMethod.save(
stringBuilder.toString(),
projectFolder,
"controlpoint.TXT"
)
}
private fun appendExportPoint(sb: StringBuilder, list: List<PointRecord>) {
for (pointRecord in list) {
sb
.append(pointRecord.getName())
.append(",")
.append(pointRecord.getCode())
.append(",")
.append(getXyzFormat(pointRecord.getX()))
.append(",")
.append(getXyzFormat(pointRecord.getY()))
.append(",")
.append(getXyzFormat(pointRecord.getZ()))
.append(",")
// .append(pointRecord.getLongitude())
.append(",")
// .append(pointRecord.getLatitude())
.append(",")
.append("")
.append("\n")
}
}
private fun getXyzFormat(xyz: Double): String {
return Util.formatDouble2String(xyz, 4)
}
/**
* 导出i角检测
*/
@WorkerThread
fun exportIDetection(projectId: String) {
val projectName =
SurveyorDatabaseFactory.instance.projectDataSource.getRecord(projectId).projectName
val iDetectionList =
LevelingDbFactory.instance.iDetectionListDataSource.getListByProjectIdDesc(projectId)
val sb = StringBuilder()
val levelExportIDetection = LevelExportIDetection()
for (iDetection in iDetectionList) {
val export = levelExportIDetection.export(iDetection)
if (!TextUtils.isEmpty(export)) {
sb.append(export)
}
}
if (sb.isNotEmpty()) {
val projectFolder = initExportProjectFolder(projectId)
ExportStationMethod.save(
sb.toString(),
projectFolder,
"$projectName.IAC"
)
}
}
/**
* 导出
*/
fun exportTjSingalHeight(projectId: String) {
val levelExportSingalHeight = LevelExportSingalHeight()
val projectFolder = initExportProjectFolder(projectId)
levelExportSingalHeight.export(projectFolder, projectId)
}
}

@ -0,0 +1,38 @@
package com.bingce.controlnetwork.func.level.util
import androidx.annotation.WorkerThread
import com.bingce.controlapphelper.datasource.database.SurveyorDatabaseFactory
import com.bingce.controlapphelper.datasource.database.leveling.LevelingDbFactory
import com.bingce.controlapphelper.datasource.database.point.PointRecord
import com.bingce.controlapphelper.util.RegExUtil
object LevelPointUtilTj {
@WorkerThread
@JvmStatic
fun createFrontPointByBackPointId(
routeId: String,
backPointId: String,
firstStaion: Boolean = false,
endStattion: Boolean = false,
): PointRecord {
val frontPoint = if (endStattion) {
val route = LevelingDbFactory.instance.levelDataSource.getByIdSync(routeId)
SurveyorDatabaseFactory.instance.pointDataSource.findByIdSync(route?.endPointId)
} else if (firstStaion) {
createHidePoint("1")
} else {
val backPoint = SurveyorDatabaseFactory.instance.pointDataSource.findByIdSync(backPointId)
val frontPointName = RegExUtil.getPointNameIncrease(backPoint.getName())
createHidePoint(frontPointName)
}
return frontPoint
}
private fun createHidePoint(pointName: String): PointRecord {
val point = PointRecord.createHidePoint(pointName)
//存点
SurveyorDatabaseFactory.instance.pointDataSource.saveSync(point)
return point
}
}

@ -0,0 +1,271 @@
package com.bingce.controlnetwork.func.level.util
import androidx.annotation.WorkerThread
import com.bingce.controlapphelper.datasource.database.SurveyorDatabaseFactory
/**
* 水准测站设置上次值
*/
object LevelStationSettingLastData {
private const val KEY_WATCHER = "LEVEL_STATION_SETTING_LAST_DATA_WATCHER"
private const val KEY_RECORDER = "LEVEL_STATION_SETTING_LAST_DATA_RECORDER"
private const val KEY_EXAMINER = "LEVEL_STATION_SETTING_LAST_DATA_EXAMINER"
private const val KEY_FRONT_FOOT_NUMBER = "LEVEL_STATION_SETTING_LAST_DATA_FRONT_FOOT_NUMBER"
private const val KEY_BACK_FOOT_NUMBER = "LEVEL_STATION_SETTING_LAST_DATA_BACK_FOOT_NUMBER"
private const val KEY_FRONT_FOOT_NUMBER_2 =
"LEVEL_STATION_SETTING_LAST_DATA_FRONT_FOOT_NUMBER_2"
private const val KEY_BACK_FOOT_NUMBER_2 = "LEVEL_STATION_SETTING_LAST_DATA_BACK_FOOT_NUMBER_2"
private const val KEY_INSTRUMENT_MODEL = "LEVEL_STATION_SETTING_LAST_DATA_INSTRUMENT_MODEL"
private const val KEY_DEVICE_NUMBER = "LEVEL_STATION_SETTING_LAST_DATA_DEVICE_NUMBER"
private const val KEY_STEEL_RULE_PARAM = "LEVEL_STATION_SETTING_LAST_DATA_STEEL_RULE_PARAM"
private const val KEY_RULER_LENGTH_PROVING_TEMPERATURE =
"LEVEL_STATION_SETTING_LAST_DATA_RULER_LENGTH_PROVING_TEMPERATURE"
private const val KEY_TEMPERATURE = "LEVEL_STATION_SETTING_LAST_DATA_TEMPERATURE"
private const val KEY_WEATHER = "LEVEL_STATION_SETTING_LAST_DATA_WEATHER"
private const val KEY_IMAGING = "LEVEL_STATION_SETTING_LAST_DATA_IMAGING"
private const val KEY_SUN_DIRECTION = "LEVEL_STATION_SETTING_LAST_DATA_SUN_DIRECTION"
private const val KEY_WIND_DIRECTION = "LEVEL_STATION_SETTING_LAST_DATA_WIND_DIRECTION"
private const val KEY_WIND_SPEED = "LEVEL_STATION_SETTING_LAST_DATA_WIND_SPEED"
private const val KEY_ROADS = "LEVEL_STATION_SETTING_LAST_DATA_ROADS"
private const val KEY_SOIL = "LEVEL_STATION_SETTING_LAST_DATA_SOIL"
private const val KEY_RULER_TYPE = "LEVEL_STATION_SETTING_LAST_DATA_RULER_TYPE"
private const val KEY_RULER_RECEPT_TYPE = "LEVEL_STATION_SETTING_LAST_DATA_RULER_RECEPT_TYPE"
private const val KEY_RULER_CORRECTION_FACTOR =
"LEVEL_STATION_SETTING_LAST_DATA_RULER_CORRECTION_FACTOR"
@WorkerThread
fun getExaminer(): String? {
return get(KEY_EXAMINER)
}
@WorkerThread
fun setExaminer(examiner: String?) {
save(KEY_EXAMINER, examiner)
}
@WorkerThread
fun getRecorder(): String? {
return get(KEY_RECORDER)
}
@WorkerThread
fun setRecorder(recorder: String?) {
save(KEY_RECORDER, recorder)
}
@WorkerThread
fun getWatcher(): String? {
return get(KEY_WATCHER)
}
@WorkerThread
fun setWatcher(watcher: String?) {
save(KEY_WATCHER, watcher)
}
@WorkerThread
fun getFrontFootNumber(): String? {
return get(KEY_FRONT_FOOT_NUMBER)
}
@WorkerThread
fun setFrontFootNumber(watcher: String?) {
save(KEY_FRONT_FOOT_NUMBER, watcher)
}
@WorkerThread
fun getFrontFootNumber2(): String? {
return get(KEY_FRONT_FOOT_NUMBER_2)
}
@WorkerThread
fun setFrontFootNumber2(watcher: String?) {
save(KEY_FRONT_FOOT_NUMBER_2, watcher)
}
@WorkerThread
fun getBackFootNumber(): String? {
return get(KEY_BACK_FOOT_NUMBER)
}
@WorkerThread
fun setBackFootNumber(watcher: String?) {
save(KEY_BACK_FOOT_NUMBER, watcher)
}
@WorkerThread
fun getBackFootNumber2(): String? {
return get(KEY_BACK_FOOT_NUMBER_2)
}
@WorkerThread
fun setBackFootNumber2(watcher: String?) {
save(KEY_BACK_FOOT_NUMBER_2, watcher)
}
@WorkerThread
fun getInstrumentModel(): String? {
return get(KEY_INSTRUMENT_MODEL)
}
@WorkerThread
fun setInstrumentModel(watcher: String?) {
save(KEY_INSTRUMENT_MODEL, watcher)
}
@WorkerThread
fun getDeviceNumber(): String? {
return get(KEY_DEVICE_NUMBER)
}
@WorkerThread
fun setDeviceNumber(watcher: String?) {
save(KEY_DEVICE_NUMBER, watcher)
}
@WorkerThread
fun getSteelRuleParam(): String? {
return get(KEY_STEEL_RULE_PARAM)
}
@WorkerThread
fun setTemperature(watcher: String?) {
save(KEY_TEMPERATURE, watcher)
}
@WorkerThread
fun getTemperature(): String? {
return get(KEY_TEMPERATURE)
}
@WorkerThread
fun setWeather(watcher: String?) {
save(KEY_WEATHER, watcher)
}
@WorkerThread
fun getWeather(): String? {
return get(KEY_WEATHER)
}
@WorkerThread
fun setImaging(watcher: String?) {
save(KEY_IMAGING, watcher)
}
@WorkerThread
fun getImaging(): String? {
return get(KEY_IMAGING)
}
/////////////
@WorkerThread
fun setSteelRuleParam(watcher: String?) {
save(KEY_STEEL_RULE_PARAM, watcher)
}
@WorkerThread
fun getRulerLengthProvingTemperature(): String? {
return get(KEY_RULER_LENGTH_PROVING_TEMPERATURE)
}
@WorkerThread
fun setRulerLengthProvingTemperature(watcher: String?) {
save(KEY_RULER_LENGTH_PROVING_TEMPERATURE, watcher)
}
@WorkerThread
fun getSunDirection(): String? {
return get(KEY_SUN_DIRECTION)
}
@WorkerThread
fun setSunDirection(watcher: String?) {
save(KEY_SUN_DIRECTION, watcher)
}
@WorkerThread
fun getWindDirection(): String? {
return get(KEY_WIND_DIRECTION)
}
@WorkerThread
fun setWindDirection(watcher: String?) {
save(KEY_WIND_DIRECTION, watcher)
}
@WorkerThread
fun getWindSpeed(): String? {
return get(KEY_WIND_SPEED)
}
@WorkerThread
fun setWindSpeed(watcher: String?) {
save(KEY_WIND_SPEED, watcher)
}
@WorkerThread
fun getRoads(): String? {
return get(KEY_ROADS)
}
@WorkerThread
fun setRoads(watcher: String?) {
save(KEY_ROADS, watcher)
}
@WorkerThread
fun getSoil(): String? {
return get(KEY_SOIL)
}
@WorkerThread
fun setSoil(watcher: String?) {
save(KEY_SOIL, watcher)
}
@WorkerThread
fun getRulerType(): String? {
return get(KEY_RULER_TYPE)
}
@WorkerThread
fun setRulerType(watcher: String?) {
save(KEY_RULER_TYPE, watcher)
}
@WorkerThread
fun getRulerReceptType(): String? {
return get(KEY_RULER_RECEPT_TYPE)
}
@WorkerThread
fun setRulerReceptType(watcher: String?) {
save(KEY_RULER_RECEPT_TYPE, watcher)
}
@WorkerThread
fun getRulerCorrectionFactor(): String? {
return get(KEY_RULER_CORRECTION_FACTOR)
}
@WorkerThread
fun setRulerCorrectionFactor(watcher: String?) {
save(KEY_RULER_CORRECTION_FACTOR, watcher)
}
private fun save(key: String, value: String?) {
SurveyorDatabaseFactory.instance.getConfigDataSource().setSync(key, value)
}
private fun get(key: String): String? {
val measureUnitRecord =
SurveyorDatabaseFactory.instance.getConfigDataSource()
.getByKeySync(key)
return measureUnitRecord?.getConfigValue()
}
}

@ -0,0 +1,132 @@
package com.bingce.controlnetwork.func.level.util
import android.widget.Spinner
import androidx.annotation.WorkerThread
import com.bingce.controlapphelper.datasource.database.leveling.LevelingDbFactory
import com.bingce.controlapphelper.datasource.database.leveling.stationsetting.LevelingStationSettingRecord
import com.bingce.controlapphelper.model.LevelRouteSave
import com.bingce.controlapphelper.util.Tools
import com.bingce.controlnetwork.R
object LevelStationSettingUtil {
/**
* 保存测站设置
*/
fun saveStationSetting(
isSaveEndStationToStationSetting: Boolean,
levelRouteSave: LevelRouteSave
) {
var saveEndStation = isSaveEndStationToStationSetting
val stationSetting = if (levelRouteSave.stationId != null) {
val before =
LevelingDbFactory.instance.stationSettingDataSource.getByStationId(levelRouteSave.stationId)
if (before != null) {
saveEndStation = before.setEndStationSetting or saveEndStation
}
before ?: LevelingStationSettingRecord()
} else {
LevelingStationSettingRecord()
}
//初始化保存的endStation
stationSetting.setEndStationSetting = saveEndStation
stationSetting.routeId = levelRouteSave.routeId
stationSetting.stationId = levelRouteSave.stationId
stationSetting.watcher = levelRouteSave.watcher
stationSetting.recorder = levelRouteSave.recorder
stationSetting.examiner = levelRouteSave.examiner
stationSetting.firstStationBackFootNumber = levelRouteSave.backFootNumber
stationSetting.firstStationFrontFootNumber = levelRouteSave.frontFootNumber
stationSetting.firstStationBackFootNumber2 = levelRouteSave.backFootNumber2
stationSetting.firstStationFrontFootNumber2 = levelRouteSave.frontFootNumber2
stationSetting.instrumentModel = levelRouteSave.instrumentModel
stationSetting.deviceNumber = levelRouteSave.deviceNumber
stationSetting.steelRuleParam = levelRouteSave.steelRuleParam
stationSetting.rulerLengthProvingTemperature = levelRouteSave.rulerLengthProvingTemperature
stationSetting.rulerCorrectionFactor = levelRouteSave.rulerCorrectionFactor
stationSetting.rulerType = levelRouteSave.rulerType
stationSetting.rulerReceptType = levelRouteSave.rulerReceptType
stationSetting.temperature = levelRouteSave.temperature
stationSetting.weather = levelRouteSave.weather
stationSetting.imaging = levelRouteSave.imaging
stationSetting.sunDirection = levelRouteSave.sunDirection
stationSetting.windDirection = levelRouteSave.windDirection
stationSetting.windSpeed = levelRouteSave.windSpeed
stationSetting.roads = levelRouteSave.roads
stationSetting.soil = levelRouteSave.soil
LevelingDbFactory.instance.stationSettingDataSource.save(stationSetting)
}
fun getSpinnerText(spinner: Spinner): String {
val text = spinner.selectedItem.toString()
if (text.contains(Tools.getString(R.string.please_choose))) {
return ""
}
return text
}
@WorkerThread
fun saveStationSettingLastData(levelRouteSave: LevelRouteSave) {
LevelStationSettingLastData.setWatcher(levelRouteSave.watcher)
LevelStationSettingLastData.setRecorder(levelRouteSave.recorder)
LevelStationSettingLastData.setExaminer(levelRouteSave.examiner)
LevelStationSettingLastData.setBackFootNumber(levelRouteSave.backFootNumber)
LevelStationSettingLastData.setFrontFootNumber(levelRouteSave.frontFootNumber)
LevelStationSettingLastData.setBackFootNumber2(levelRouteSave.backFootNumber2)
LevelStationSettingLastData.setFrontFootNumber2(levelRouteSave.frontFootNumber2)
LevelStationSettingLastData.setInstrumentModel(levelRouteSave.instrumentModel)
LevelStationSettingLastData.setDeviceNumber(levelRouteSave.deviceNumber)
LevelStationSettingLastData.setSteelRuleParam(levelRouteSave.steelRuleParam)
LevelStationSettingLastData.setRulerLengthProvingTemperature(levelRouteSave.rulerLengthProvingTemperature)
LevelStationSettingLastData.setRulerCorrectionFactor(levelRouteSave.rulerCorrectionFactor)
LevelStationSettingLastData.setRulerType(levelRouteSave.rulerType)
LevelStationSettingLastData.setRulerReceptType(levelRouteSave.rulerReceptType)
LevelStationSettingLastData.setTemperature(levelRouteSave.temperature)
LevelStationSettingLastData.setWeather(levelRouteSave.weather)
LevelStationSettingLastData.setImaging(levelRouteSave.imaging)
LevelStationSettingLastData.setSunDirection(levelRouteSave.sunDirection)
LevelStationSettingLastData.setWindDirection(levelRouteSave.windDirection)
LevelStationSettingLastData.setWindSpeed(levelRouteSave.windSpeed)
LevelStationSettingLastData.setRoads(levelRouteSave.roads)
LevelStationSettingLastData.setSoil(levelRouteSave.soil)
}
@WorkerThread
fun getStationSettingLastData(): LevelRouteSave {
return LevelRouteSave.createLastData(
LevelStationSettingLastData.getWatcher(),
LevelStationSettingLastData.getRecorder(),
LevelStationSettingLastData.getExaminer(),
LevelStationSettingLastData.getBackFootNumber(),
LevelStationSettingLastData.getFrontFootNumber(),
LevelStationSettingLastData.getBackFootNumber2(),
LevelStationSettingLastData.getFrontFootNumber2(),
LevelStationSettingLastData.getInstrumentModel(),
LevelStationSettingLastData.getDeviceNumber(),
LevelStationSettingLastData.getSteelRuleParam(),
LevelStationSettingLastData.getRulerLengthProvingTemperature(),
LevelStationSettingLastData.getRulerCorrectionFactor(),
LevelStationSettingLastData.getRulerType(),
LevelStationSettingLastData.getRulerReceptType(),
LevelStationSettingLastData.getTemperature(),
LevelStationSettingLastData.getWeather(),
LevelStationSettingLastData.getImaging(),
LevelStationSettingLastData.getSunDirection(),
LevelStationSettingLastData.getWindDirection(),
LevelStationSettingLastData.getWindSpeed(),
LevelStationSettingLastData.getRoads(),
LevelStationSettingLastData.getSoil()
)
}
}

@ -0,0 +1,237 @@
package com.bingce.controlnetwork.func.level.util
import androidx.annotation.WorkerThread
import blankj.utilcode.util.ToastUtils
import com.bingce.controlapphelper.datasource.database.SurveyorDatabaseFactory
import com.bingce.controlapphelper.datasource.database.leveling.LevelingDbFactory
import com.bingce.controlapphelper.datasource.database.leveling.measure.station.LevelingMeasureStationRecord
import com.bingce.controlapphelper.datasource.database.leveling.station.LevelingStationRecord
import com.bingce.controlapphelper.model.LevelingMeasureOrder
import com.bingce.controlapphelper.model.StationOddEven
import com.bingce.controlapphelper.util.RegExUtil
import com.bingce.utils.DateUtils
object LevelStationUtilTj {
@WorkerThread
@JvmStatic
fun createStation(
projectId: String,
routeId: String,
backPointId: String,
firstStation: Boolean = false,
endStation: Boolean = false
) {
val routeRecord = LevelingDbFactory.instance.levelDataSource.getByIdSync(routeId)
routeRecord?.let {
val levelingMeasureOrder = it.levelingMeasureOrder
//新建路线的时候创建一个水准测站
val frontPoint =
LevelPointUtilTj.createFrontPointByBackPointId(
routeId,
backPointId,
firstStation,
endStation
)
val stationNamePrefix = "测站"
val lastStationNameIndex = getLastStationNameIndex(projectId, routeId)
//创建测站的奇偶站
val createStationOdd = getCreateStationOdd(projectId, routeId)
when (levelingMeasureOrder) {
LevelingMeasureOrder.SIM_BF, LevelingMeasureOrder.SIM_BFFB -> {
val relationId = DateUtils.genRandomTimeId()
saveOneStationRecord(
projectId,
routeId,
"${stationNamePrefix}${lastStationNameIndex.plus(1)}_L",
backPointId,
frontPoint.getId(),
false,
createStationOdd,
relationId,
endStation = false
)
saveOneStationRecord(
projectId,
routeId,
"${stationNamePrefix}${lastStationNameIndex.plus(1)}_R",
backPointId,
frontPoint.getId(),
true,
createStationOdd,
relationId,
endStation = endStation
)
}
LevelingMeasureOrder.A_BF, LevelingMeasureOrder.A_BFFB, LevelingMeasureOrder.A_FBBF -> {
saveOneStationRecord(
projectId,
routeId,
"${stationNamePrefix}${lastStationNameIndex.plus(1)}",
backPointId,
frontPoint.getId(),
false,
createStationOdd,
endStation = endStation
)
}
else -> {
saveOneStationRecord(
projectId,
routeId,
"${stationNamePrefix}${lastStationNameIndex.plus(1)}",
backPointId,
frontPoint.getId(),
false,
createStationOdd,
endStation = endStation
)
}
}
}
}
@WorkerThread
private fun getLastStationNameIndex(projectId: String, routeId: String): Int {
val stationLatest =
LevelingDbFactory.instance.stationDataSource.getStationLatest(projectId, routeId)
return stationLatest?.stationName?.let {
val findNum = RegExUtil.findNum(it)
findNum?.toInt() ?: 0
} ?: 0
}
@WorkerThread
private fun getLastStationId(projectId: String, routeId: String): String? {
return getStationLatest(projectId, routeId)?.id
}
private fun getStationLatest(projectId: String, routeId: String) =
LevelingDbFactory.instance.stationDataSource.getStationLatest(projectId, routeId)
@WorkerThread
private fun saveOneStationRecord(
projectId: String,
routeId: String,
stationName: String,
backPointId: String,
frontPointId: String,
twiceStation: Boolean,
oddStation: StationOddEven,
relationId: String? = null,
endStation: Boolean = false
) {
val lastStationId = getLastStationId(projectId, routeId)
val station = LevelingStationRecord.createStation(
projectId,
routeId,
stationName,
lastStationId,
twiceStation,
backPointId,
frontPointId,
0,
oddStation,
endStation
)
station.relationStationId = relationId
LevelingDbFactory.instance.stationDataSource.save(station)
}
private fun getCreateStationOdd(
projectId: String,
routeId: String
): StationOddEven {
val stationLatest = getStationLatest(projectId, routeId)
?: return StationOddEven.ODD_STATION
return if (stationLatest.isOddStation) {
StationOddEven.EVEN_STATION
} else {
StationOddEven.ODD_STATION
}
}
@JvmStatic
fun checkStationForResult(stationId: String): Boolean {
val stationRecord = LevelingDbFactory.instance.stationDataSource.getRecordSync(stationId)
if (stationRecord.isFinish) {
return true
} else {
if (stationRecord == null || !stationRecord.isFull) {
ToastUtils.showShort("该测站数据不完整!")
}
if (!stationRecord.isFinish) {
ToastUtils.showShort("该测站未通过检测!")
}
return false
}
}
@JvmStatic
fun getStationFinishCount(projectId: String, routeId: String): Int {
return LevelingDbFactory.instance.stationDataSource.getCountFinish(projectId, routeId)
}
/**
* 获取要测量的测站列表
*/
fun getMeasureStationList(projectId: String, routeId: String): List<LevelingStationRecord> {
val stationLatest =
LevelingDbFactory.instance.stationDataSource.getStationLatest(projectId, routeId)
val returnList = mutableListOf<LevelingStationRecord>()
if (stationLatest != null) {
if (stationLatest.twiceStation) {
//单程双转点
val statonList =
LevelingDbFactory.instance.stationDataSource.getStationListByRelationId(
projectId,
routeId,
stationLatest.relationStationId
)
returnList.addAll(statonList)
} else {
returnList.add(stationLatest)
}
}
return returnList
}
@WorkerThread
fun getStationRouteResult(stationRecord: LevelingStationRecord): String {
val routeName =
LevelingDbFactory.instance.levelDataSource.getByIdSync(stationRecord.routeId)?.routeName ?: ""
val sb = StringBuilder()
if (stationRecord.twiceStation) {
val relationStation = LevelingDbFactory.instance.stationDataSource
.getRelationStation(stationRecord.relationStationId, false)
val twiceStationMeasureRecord = getMeasureStationRecord(relationStation.getId())
appendMeasureResult(sb, routeName, twiceStationMeasureRecord)
}
val measureStationRecord = getMeasureStationRecord(stationRecord.getId())
appendMeasureResult(sb, routeName, measureStationRecord)
return sb.toString()
}
private fun appendMeasureResult(
sb: StringBuilder,
routeName: String,
measureStationRecord: LevelingMeasureStationRecord
) {
sb.append("${routeName}的总高差${measureStationRecord.heightDiffTotalShow},总距离${measureStationRecord.distanceTotalShow}")
.append("\n")
}
private fun getMeasureStationRecord(stationId: String) =
LevelingDbFactory.instance.measureStationDataSource.getRecordSync(stationId)
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save