Compare commits

...

12 Commits

  1. 1
      .gitignore
  2. 14
      README.md
  3. BIN
      aar/base/base-release.aar
  4. 2
      aar/coordlib/build.gradle
  5. BIN
      aar/coordlib/coordlib-release.aar
  6. BIN
      aar/rtk/rtk-release.aar
  7. 2
      aar/sensor/build.gradle
  8. BIN
      aar/sensor/sensor-release.aar
  9. BIN
      aar/totalstation/totalstation-release.aar
  10. 13
      app/build.gradle
  11. 7
      app/src/main/AndroidManifest.xml
  12. 12
      app/src/main/java/com/bingce/controlnetwork/App.java
  13. 29
      app/src/main/java/com/bingce/controlnetwork/activity/MainActivityUtils.java
  14. 3
      app/src/main/java/com/bingce/controlnetwork/activity/fragmentcontainer/FragmentContainer.java
  15. 8
      app/src/main/java/com/bingce/controlnetwork/activity/user/OpeningRenewalVipActivity.java
  16. 13
      app/src/main/java/com/bingce/controlnetwork/adapter/SurveyorStationRecordsAdapter.java
  17. 58
      app/src/main/java/com/bingce/controlnetwork/adapter/SurveyorStationRecordsWellAdapter.java
  18. 88
      app/src/main/java/com/bingce/controlnetwork/bean/SurveyorScheduleConstants.java
  19. 11
      app/src/main/java/com/bingce/controlnetwork/event/AutoSurveyorButtonVisibleEvent.java
  20. 35
      app/src/main/java/com/bingce/controlnetwork/event/RefreshRollBackEvent.java
  21. 4
      app/src/main/java/com/bingce/controlnetwork/event/ReplaceSurveyorFragmentEvent.java
  22. 56
      app/src/main/java/com/bingce/controlnetwork/event/SurveyStateEvent.java
  23. 144
      app/src/main/java/com/bingce/controlnetwork/fragment/ComponentSurveyorStationListFragment.java
  24. 3
      app/src/main/java/com/bingce/controlnetwork/fragment/SelectExportSurveyorRecordFragment.java
  25. 128
      app/src/main/java/com/bingce/controlnetwork/fragment/StationDataAdjustAloneVerOrDistanceDialogFragment.java
  26. 12
      app/src/main/java/com/bingce/controlnetwork/fragment/StationDataAdjustDialogFragment.java
  27. 183
      app/src/main/java/com/bingce/controlnetwork/fragment/StationDataAdjustDialogFragmentTj.java
  28. 110
      app/src/main/java/com/bingce/controlnetwork/fragment/StationSurveyorRecordFragment.java
  29. 10
      app/src/main/java/com/bingce/controlnetwork/fragment/stationsurvey/IMeasureOperate.java
  30. 213
      app/src/main/java/com/bingce/controlnetwork/fragment/stationsurvey/StationSettingCheckUtil.java
  31. 315
      app/src/main/java/com/bingce/controlnetwork/fragment/stationsurvey/StationSurveyorFragment.java
  32. 394
      app/src/main/java/com/bingce/controlnetwork/fragment/stationsurvey/angledistance/MeasureDistanceFragment.java
  33. 180
      app/src/main/java/com/bingce/controlnetwork/fragment/stationsurvey/angledistance/MeasureFragment.java
  34. 154
      app/src/main/java/com/bingce/controlnetwork/fragment/stationsurvey/base/BaseFragmentLazy.java
  35. 2
      app/src/main/java/com/bingce/controlnetwork/fragment/stationsurvey/base/MeasureBaseFragment.java
  36. 6
      app/src/main/java/com/bingce/controlnetwork/fragment/stationsurvey/heighttraverse/MeasureHeightTraverseFragment.kt
  37. 36
      app/src/main/java/com/bingce/controlnetwork/fragment/stationsurvey/heighttraverse/MeasureHeightTraverseSubFragment.java
  38. 476
      app/src/main/java/com/bingce/controlnetwork/fragment/stationsurvey/separate/StationSurveyorSeparateDistanceFragment.java
  39. 375
      app/src/main/java/com/bingce/controlnetwork/fragment/stationsurvey/separate/StationSurveyorSeparateFragment.java
  40. 475
      app/src/main/java/com/bingce/controlnetwork/fragment/stationsurvey/separate/StationSurveyorSeparateHorAngleFragment.java
  41. 469
      app/src/main/java/com/bingce/controlnetwork/fragment/stationsurvey/separate/StationSurveyorSeparateVerAngleFragment.java
  42. 129
      app/src/main/java/com/bingce/controlnetwork/fragment/stationsurvey/separate/StationSurveyorSepatateAdapter.java
  43. 500
      app/src/main/java/com/bingce/controlnetwork/fragment/stationsurvey/well/StationSurveyorWellDistanceDataFragment.java
  44. 457
      app/src/main/java/com/bingce/controlnetwork/fragment/stationsurvey/well/StationSurveyorWellFragment.java
  45. 167
      app/src/main/java/com/bingce/controlnetwork/fragment/stationsurvey/well/StationSurveyorWellLevelAngleDataFragment.java
  46. 2
      app/src/main/java/com/bingce/controlnetwork/func/level/export/LevelExportIDetection.kt
  47. 2
      app/src/main/java/com/bingce/controlnetwork/func/level/export/LevelExportSingalHeight.kt
  48. 8
      app/src/main/java/com/bingce/controlnetwork/func/level/fragment/LevelSurveyFragment.java
  49. 8
      app/src/main/java/com/bingce/controlnetwork/func/level/fragment/LevelSurveySubFragment.java
  50. 2
      app/src/main/java/com/bingce/controlnetwork/func/level/idetection/LevelIDetectionRecordActivity.kt
  51. 2
      app/src/main/java/com/bingce/controlnetwork/func/level/idetection/adapter/LevelIDetectionRecordAdapter.java
  52. 2
      app/src/main/java/com/bingce/controlnetwork/func/level/idetection/viewmodel/LevelIDetectionRecordVm.kt
  53. 2
      app/src/main/java/com/bingce/controlnetwork/func/level/sendreceive/ILevelBackData.kt
  54. 2
      app/src/main/java/com/bingce/controlnetwork/func/level/sendreceive/LevelRequest.kt
  55. 2
      app/src/main/java/com/bingce/controlnetwork/func/level/sendreceive/LevelRequestRelease.kt
  56. 2
      app/src/main/java/com/bingce/controlnetwork/func/level/sendreceive/LevelRequestTest.kt
  57. 16
      app/src/main/java/com/bingce/controlnetwork/func/level/util/LevelExportUtilTj.kt
  58. 4
      app/src/main/java/com/bingce/controlnetwork/func/level/viewmodel/LevelCreateOrEditRouteVm.kt
  59. 12
      app/src/main/java/com/bingce/controlnetwork/func/level/viewmodel/LevelSuveyorSubVm.kt
  60. 6
      app/src/main/java/com/bingce/controlnetwork/func/level/viewmodel/LevelSuveyorVm.kt
  61. 186
      app/src/main/java/com/bingce/controlnetwork/model/AloneAdjustItem.java
  62. 18
      app/src/main/java/com/bingce/controlnetwork/model/StationCheckErrorItem.java
  63. 14
      app/src/main/java/com/bingce/controlnetwork/model/StationCheckErrorPoint.java
  64. 8
      app/src/main/java/com/bingce/controlnetwork/newui/stationlist/StationListFragment.kt
  65. 108
      app/src/main/java/com/bingce/controlnetwork/newui/stationsetting/StationSettingSettingFragment.kt
  66. 49
      app/src/main/java/com/bingce/controlnetwork/newui/stationsetting/StationSettingVm.kt
  67. 4
      app/src/main/java/com/bingce/controlnetwork/newui/stationsetting/StationSettingsActivity.kt
  68. 18
      app/src/main/java/com/bingce/controlnetwork/newui/stationsetting/model/StationSettingSettingData.kt
  69. 16
      app/src/main/java/com/bingce/controlnetwork/newui/stationsurveyor/ISurveyorMenuOperate.java
  70. 162
      app/src/main/java/com/bingce/controlnetwork/newui/stationsurveyor/StationSurveyorHomeActivity.kt
  71. 28
      app/src/main/java/com/bingce/controlnetwork/newui/stationsurveyor/StationSurveyorHomeViewModel.kt
  72. 1098
      app/src/main/java/com/bingce/controlnetwork/surveyor/data/CachedData.java
  73. 8
      app/src/main/java/com/bingce/controlnetwork/surveyor/data/CachedDataPointType.java
  74. 16
      app/src/main/java/com/bingce/controlnetwork/surveyor/data/FaultTolerantData.java
  75. 155
      app/src/main/java/com/bingce/controlnetwork/surveyor/data/ICachedData.java
  76. 8
      app/src/main/java/com/bingce/controlnetwork/surveyor/data/ICycleRecorder.java
  77. 8
      app/src/main/java/com/bingce/controlnetwork/surveyor/data/IDistanceTypeChangeListener.java
  78. 8
      app/src/main/java/com/bingce/controlnetwork/surveyor/data/IStationPointRecordCollect.java
  79. 83
      app/src/main/java/com/bingce/controlnetwork/surveyor/data/ISurveyorData.java
  80. 39
      app/src/main/java/com/bingce/controlnetwork/surveyor/data/SpeakCache.java
  81. 245
      app/src/main/java/com/bingce/controlnetwork/surveyor/data/SurveyorData.java
  82. 276
      app/src/main/java/com/bingce/controlnetwork/surveyor/method/AutoSurveyorMethod.java
  83. 156
      app/src/main/java/com/bingce/controlnetwork/surveyor/method/AverageValueMethod.java
  84. 577
      app/src/main/java/com/bingce/controlnetwork/surveyor/method/DeviationValueOfRadianMethod.java
  85. 140
      app/src/main/java/com/bingce/controlnetwork/surveyor/method/ExportUtilsPla.java
  86. 181
      app/src/main/java/com/bingce/controlnetwork/surveyor/method/FindTargetMethod.java
  87. 147
      app/src/main/java/com/bingce/controlnetwork/surveyor/method/SingleCycleCheckMethod.java
  88. 10
      app/src/main/java/com/bingce/controlnetwork/surveyor/method/SingleCycleTipsMethod.java
  89. 646
      app/src/main/java/com/bingce/controlnetwork/surveyor/method/SurveyorAdjustMethodPla.java
  90. 119
      app/src/main/java/com/bingce/controlnetwork/surveyor/method/ValueOf2cMethod.java
  91. 11
      app/src/main/java/com/bingce/controlnetwork/surveyor/method/model/CacheResult.java
  92. 18
      app/src/main/java/com/bingce/controlnetwork/surveyor/method/model/IStateDelegate.java
  93. 27
      app/src/main/java/com/bingce/controlnetwork/surveyor/state/IAutoModeSwitcher.java
  94. 13
      app/src/main/java/com/bingce/controlnetwork/surveyor/state/ISurveyState.java
  95. 10
      app/src/main/java/com/bingce/controlnetwork/surveyor/state/ISurveyorDataScrollDelegate.java
  96. 54
      app/src/main/java/com/bingce/controlnetwork/surveyor/state/StateConstantsPla.java
  97. 243
      app/src/main/java/com/bingce/controlnetwork/surveyor/state/StateManagerPla.java
  98. 36
      app/src/main/java/com/bingce/controlnetwork/surveyor/state/StateType.java
  99. 186
      app/src/main/java/com/bingce/controlnetwork/surveyor/state/_Check2CState.java
  100. 37
      app/src/main/java/com/bingce/controlnetwork/surveyor/state/_CheckHalfCycleZeroState.java
  101. Some files were not shown because too many files have changed in this diff Show More

1
.gitignore vendored

@ -29,3 +29,4 @@ obj/
/app/*/release
/alpha/*/release
/pad/*/release
/aar/base/base-release.aar

@ -1 +1,15 @@
#### 1. 项目简介
解放军信息工程导线助手
#### 2. 代码信息
##### 2.1 仓库地址
- 主项目:http://code.bingce.com/wangguannan/control_pla.git
分支:main_modify
- 子仓库(control_common):http://code.bingce.com/BingCe-Android/control_common.git
分支:huangwei_level_modify

Binary file not shown.

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

Binary file not shown.

Binary file not shown.

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

Binary file not shown.

@ -3,6 +3,8 @@ import com.bingce.App
import com.bingce.Libs
import com.bingce.ModuleName
import java.text.SimpleDateFormat
apply plugin: 'com.android.application'
apply plugin: 'org.jetbrains.kotlin.android'
apply plugin: 'kotlin-kapt'
@ -16,8 +18,11 @@ android {
namespace App.ControlNetwork.applicationId
defaultConfig {
versionName "1.0.1"
versionCode 1
def currentDate = new SimpleDateFormat(".yy.M.d").format(new Date())
def code = new SimpleDateFormat("yyyyMMdd").format(new Date()).toInteger()
versionName "1.1${currentDate}"
versionCode code
applicationId "com.bingce.controlnetwork.pla"
minSdkVersion AndroidSdk.minSdkVersion
targetSdkVersion AndroidSdk.targetSdkVersion
@ -61,9 +66,9 @@ android {
applicationVariants.all {
variant ->
variant.outputs.all {
def createTime = new Date().format("YYYY-MM-dd-HH-mm-ss", TimeZone.getTimeZone("GMT+08:00"))
def createTime = new Date().format("HH-mm-ss", TimeZone.getTimeZone("GMT+08:00"))
// app包名称
outputFileName = "app_v" + defaultConfig.versionName + "_" + createTime + ".apk"
outputFileName = "pla_v" + defaultConfig.versionName + "_" + createTime + ".apk"
}
}
}

@ -132,10 +132,10 @@
android:exported="true"
android:label="数据备份" />
<activity
android:label="数据导入"
android:name=".activity.backup.launch.MigrationFolder2PrivateRoomActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:exported="true" />
android:exported="true"
android:label="数据导入" />
<activity
android:name="ru.bartwell.exfilepicker.ui.activity.ExFilePickerActivity"
android:exported="true"
@ -221,6 +221,9 @@
android:name=".activity.ViewRecentCrashActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="@string/view_recent_log" />
<activity
android:name=".newui.stationsurveyor.StationSurveyorHomeActivity"
android:configChanges="orientation|keyboardHidden|screenSize" />
</application>
</manifest>

@ -80,6 +80,18 @@ public class App extends RepositoryBaseApp {
public String levelSurveyorTime;
public boolean isCompletedLearn;
/**
* 自动测量是否二次照准
*/
public boolean isTwiceAiming = true;
/**
* 小数点位数
*/
public int notNumber = 3;
private static App app;
@Override

@ -337,8 +337,33 @@ public class MainActivityUtils extends AppCompatActivityProviderUtils {
}
}
if (!Device.getInstance().isDeviceConnected()) {
if (!"".equals(Device.getInstance().deviceBlueName)) {
String instrumentInfo = ActivityUtils.getTopActivity().getString(R.string.instrument_name) + ":" + Device.getInstance().deviceBlueName + "\n" + ActivityUtils.getTopActivity().getString(R.string.instrument_type_name) + ":" + Device.getInstance().deviceBrand;
String blueName;
String macAddress;
String brand;
switch (Device.getInstance().deviceType) {
case DEVICE_TYPE_TS:
blueName = Device.getInstance().tsBlueName;
macAddress = Device.getInstance().tsMacAddress;
brand = Device.getInstance().tsBrand;
break;
case DEVICE_TYPE_RTK:
blueName = Device.getInstance().rtkBlueName;
macAddress = Device.getInstance().rtkMacAddress;
brand = Device.getInstance().rtkBrand;
break;
case DEVICE_TYPE_LEVEL:
blueName = Device.getInstance().levelBlueName;
macAddress = Device.getInstance().levelMacAddress;
brand = Device.getInstance().levelBrand;
break;
default:
blueName = Device.getInstance().sensorBlueName;
macAddress = Device.getInstance().sensorMacAddress;
brand = Device.getInstance().levelBrand;
break;
}
if (!"".equals(blueName)) {
String instrumentInfo = ActivityUtils.getTopActivity().getString(R.string.instrument_name) + ":" + blueName + "\n" + ActivityUtils.getTopActivity().getString(R.string.instrument_type_name) + ":" + brand;
new MaterialDialog.Builder(ActivityUtils.getTopActivity())
.title(R.string.quick_connect)
.content(instrumentInfo)

@ -30,7 +30,6 @@ import com.bingce.controlnetwork.fragment.stationdetail.SingleStationDetailAndEd
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.angledistance.MeasureFragment;
import com.bingce.controlnetwork.fragment.stationsurvey.heighttraverse.MeasureHeightTraverseFragment;
import com.bingce.controlnetwork.func.level.fragment.LevelRouteCreateEditFragment;
import com.bingce.controlnetwork.func.level.fragment.LevelSelectExportFragment;
@ -71,7 +70,7 @@ public class FragmentContainer {
factory.put(LineStationWellDoubleGroundSetupFragment.TAG, LineStationWellDoubleGroundSetupFragment::newInstance);
factory.put(LineStationWellDoubleUnderGroundSetupFragment.TAG, LineStationWellDoubleUnderGroundSetupFragment::newInstance);
factory.put(PrismManageFragment.TAG, PrismManageFragment::newInstance);
factory.put(MeasureFragment.TAG, MeasureFragment::newInstance);
// factory.put(MeasureFragment.TAG, MeasureFragment::newInstance);
factory.put(CreateStationForHeightTraverseFragment.TAG, CreateStationForHeightTraverseFragment::newInstance);
factory.put(MeasureHeightTraverseFragment.TAG, MeasureHeightTraverseFragment::newInstance);
factory.put(SelectExportHeightTraverseFragment.TAG, SelectExportHeightTraverseFragment::newInstance);

@ -339,12 +339,12 @@ public class OpeningRenewalVipActivity extends ColorfulActivity {
* @param fee 金额单位分
*/
private void nativeOrder(int fee) {
WxPayV3.getInstance().generateNativeVipOrder(this,
WxPayV3.getInstance().generateBcNativeVipOrder(this,
LCUser.getCurrentUser().getSessionToken(),
"导线助手会员",
fee,
orderType,
new WxPayV3.nativeOrderGenerateListener() {
new WxPayV3.NativeOrderGenerateListener() {
@Override
public void onOrderGenerateSuccess(String code_url) {
showQrCode(code_url);
@ -377,12 +377,12 @@ public class OpeningRenewalVipActivity extends ColorfulActivity {
})
.show();
WxPayV3.getInstance().generateAppVipOrder(this,
WxPayV3.getInstance().generateBcAppVipOrder(this,
LCUser.getCurrentUser().getSessionToken(),
"导线助手会员",
fee,
orderType,
new WxPayV3.appOrderGenerateListener() {
new WxPayV3.AppOrderGenerateListener() {
@Override
public void onOrderGenerateSuccess() {
hasPayResult = false;

@ -7,16 +7,15 @@ import androidx.recyclerview.widget.RecyclerView;
import com.bingce.controlapphelper.model.IAdapter;
import com.bingce.controlapphelper.model.ViewItemType;
import com.bingce.controlapphelper.surveyor.data.ICachedData;
import com.bingce.controlapphelper.surveyor.data.ICycleRecorder;
import com.bingce.controlapphelper.surveyor.data.IDistanceTypeChangeListener;
import com.bingce.controlapphelper.surveyor.data.ISurveyorData;
import org.jetbrains.annotations.NotNull;
import com.bingce.controlnetwork.surveyor.data.ICachedData;
import com.bingce.controlnetwork.surveyor.data.ICycleRecorder;
import com.bingce.controlnetwork.surveyor.data.IDistanceTypeChangeListener;
import com.bingce.controlnetwork.surveyor.data.ISurveyorData;
import com.bingce.controlnetwork.ui.vh.SurveyorDataViewHolder;
import com.bingce.controlnetwork.ui.widget.ViewFactory;
import org.jetbrains.annotations.NotNull;
/*
* 测量记录adapter
* */

@ -7,41 +7,42 @@ import androidx.recyclerview.widget.RecyclerView;
import com.bingce.controlapphelper.model.IAdapter;
import com.bingce.controlapphelper.model.ViewItemType;
import com.bingce.controlapphelper.surveyor.data.CachedDataAloneDistance;
import com.bingce.controlapphelper.surveyor.data.ICachedData;
import com.bingce.controlapphelper.surveyor.data.ICycleRecorder;
import com.bingce.controlapphelper.surveyor.data.IDistanceTypeChangeListener;
import com.bingce.controlapphelper.surveyor.data.IMeasureCache;
import com.bingce.controlapphelper.surveyor.data.ISurveyorData;
import com.bingce.controlnetwork.ui.vh.SurveyorDataAloneDistanceViewHolder;
import com.bingce.controlnetwork.surveyor.data.ICachedData;
import com.bingce.controlnetwork.surveyor.data.ICycleRecorder;
import com.bingce.controlnetwork.surveyor.data.IDistanceTypeChangeListener;
import com.bingce.controlnetwork.surveyor.data.ISurveyorData;
import com.bingce.controlnetwork.ui.vh.SurveyorDataViewHolder;
import com.bingce.controlnetwork.ui.vh.SurveyorDataWellDistanceViewHolder;
import com.bingce.controlnetwork.ui.widget.ViewFactory;
/**
* 测量记录adapter
* 井定向-距离
*/
public class MeasureAngleDistanceAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
public class SurveyorStationRecordsWellAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
implements IAdapter, IDistanceTypeChangeListener {
public static final String TYPE_ANGLE = "TYPE_ANGLE";
public static final String TYPE_HORIZONTAL_ANGLE = "TYPE_HORIZONTAL_ANGLE";
public static final String TYPE_DISTANCE = "TYPE_DISTANCE";
private final IMeasureCache cachedData;
private ICachedData cachedData;
private final ISurveyorData surveyorData;
private final ICycleRecorder cycleRecorder;
private boolean showSlopDistance = true;
private String projectType;
private final String stationId;
private final String type;//区分水平还是距离
public MeasureAngleDistanceAdapter(
public SurveyorStationRecordsWellAdapter(
String projectType,
String stationId,
IMeasureCache cachedData,
ICachedData cachedData,
ICycleRecorder cycleRecorder,
ISurveyorData surveyorData,
String type) {
this.projectType = projectType;
this.stationId = stationId;
this.cachedData = cachedData;
this.surveyorData = surveyorData;
@ -51,12 +52,19 @@ public class MeasureAngleDistanceAdapter extends RecyclerView.Adapter<RecyclerVi
cachedData.register(this);
}
public void setCachedData(ICachedData cachedData) {
this.cachedData.unregister(this);
this.cachedData = cachedData;
//注册数据监听
cachedData.register(this);
}
@NonNull
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
RecyclerView.ViewHolder vh = null;
switch (type) {
case TYPE_ANGLE:
case TYPE_HORIZONTAL_ANGLE:
vh = ViewFactory.generatorViewHolder(parent.getContext(), parent, ViewItemType.surveyorStationPointItem);
break;
case TYPE_DISTANCE:
@ -69,12 +77,13 @@ public class MeasureAngleDistanceAdapter extends RecyclerView.Adapter<RecyclerVi
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
if (holder instanceof SurveyorDataAloneDistanceViewHolder) {
SurveyorDataAloneDistanceViewHolder holderDistance = (SurveyorDataAloneDistanceViewHolder) holder;
if (holder instanceof SurveyorDataWellDistanceViewHolder) {
SurveyorDataWellDistanceViewHolder holderDistance = (SurveyorDataWellDistanceViewHolder) holder;
holderDistance.setup(position,
projectType,
stationId,
showSlopDistance,
(CachedDataAloneDistance) cachedData,
cachedData,
cycleRecorder,
surveyorData);
} else if (holder instanceof SurveyorDataViewHolder) {
@ -82,7 +91,7 @@ public class MeasureAngleDistanceAdapter extends RecyclerView.Adapter<RecyclerVi
holderHorizontalAngle.setup(position,
stationId,
showSlopDistance,
(ICachedData) cachedData,
cachedData,
cycleRecorder,
surveyorData);
}
@ -96,12 +105,21 @@ public class MeasureAngleDistanceAdapter extends RecyclerView.Adapter<RecyclerVi
@Override
public int getItemCount() {
return cachedData.pointCount();
int count = 0;
switch (type) {
case TYPE_HORIZONTAL_ANGLE:
count = cachedData.pointCount();
break;
case TYPE_DISTANCE:
count = cachedData.realPointCount();
break;
}
return count;
}
@Override
public void onDataChange() {
notifyDataSetChanged();
notifyItemRangeChanged(0, getItemCount());
}
@Override

@ -0,0 +1,88 @@
package com.bingce.controlnetwork.bean;
import com.bingce.controlnetwork.surveyor.state.StateConstantsPla;
public class SurveyorScheduleConstants {
public static final String KEY_ID = "id";
public static final String STATUE_VALUE_NO_COMPLETED = "0";//未完成测量
public static final String STATUE_VALUE_COMPLETED = "1";//完成测量
public static final String STATUE_VALUE_CHECKED = "2";//经过检测
public static final String DB_NAME = "___SurveyorSchedule____";
public static final String DB_SQL_SELECT_BY_ID = "SELECT * FROM " + DB_NAME + " WHERE id =:id";
//进度key //值勿改
//单独测距
private static final String STATION_TYPE_WELL_DISTANCE = "STATION_TYPE_WELL_DISTANCE";
//水平角
private static final String STATION_TYPE_SEPARATE_HOR_ANGLE = "STATION_TYPE_SEPARATE_HOR_ANGLE";
//垂直角
private static final String STATION_TYPE_SEPARATE_VER_ANGLE = "STATION_TYPE_SEPARATE_VER_ANGLE";
/**
* 当前测回的key
*
* @param stationId
* @param measureWhat
* @return
*/
public static String stationCurrentCycleKey(String stationId, int measureWhat) {
return stationId + getSubTypeKey(measureWhat) + "___key___current__cycle";
}
/**
* 某个测回进度key
*
* @param stationId
* @param measureWhat
* @param cycleIndex
* @return
*/
public static String stationSingleCycleScheduleKey(String stationId, int measureWhat, int cycleIndex) {
return stationId + getSubTypeKey(measureWhat) + "_single__cycle___" + cycleIndex;
}
/**
* 所有测回进度key
*
* @param stationId
* @param measureWhat
* @return
*/
public static String stationAllCycleScheduleKey(String stationId, int measureWhat) {
return stationId + getSubTypeKey(measureWhat) + "_all__cycle___";
}
/**
* 分开观测垂直角测站的点id
*
* @param stationId
* @param measureWhat
* @return
*/
public static String stationCurrentPointIdKey(String stationId, int measureWhat) {
return stationId + getSubTypeKey(measureWhat) + "key_current_point_id";
}
private static String getSubTypeKey(int measureWhat) {
switch (measureWhat) {
case StateConstantsPla.VALUE_MEASURE_WHAT_DISTANCE:
return STATION_TYPE_WELL_DISTANCE;
case StateConstantsPla.VALUE_MEASURE_WHAT_ANGLE_HOR:
return STATION_TYPE_SEPARATE_HOR_ANGLE;
case StateConstantsPla.VALUE_MEASURE_WHAT_ANGLE_VER:
return STATION_TYPE_SEPARATE_VER_ANGLE;
case StateConstantsPla.VALUE_MEASURE_WHAT_DEFAULT:
// case StateConstants.VALUE_MEASURE_WHAT_ANGLE:
default:
return "";
}
}
}

@ -0,0 +1,11 @@
package com.bingce.controlnetwork.event;
public class AutoSurveyorButtonVisibleEvent {
public final boolean isReadyAutoSurvey;//是否具备自动测量条件
public final boolean isOpenAutoSurvey;//是否允许自动测量
public AutoSurveyorButtonVisibleEvent(boolean isReadyAutoSurvey, boolean isOpenAutoSurvey) {
this.isReadyAutoSurvey = isReadyAutoSurvey;
this.isOpenAutoSurvey = isOpenAutoSurvey;
}
}

@ -0,0 +1,35 @@
package com.bingce.controlnetwork.event;
import com.bingce.controlnetwork.surveyor.state.StateConstantsPla;
/*
* 刷新回退按钮
* */
public class RefreshRollBackEvent {
public final boolean validate;
public final int fragmentPosition;
public RefreshRollBackEvent(final boolean validate, final int fragmentPosition) {
this.validate = validate;
this.fragmentPosition = fragmentPosition;
}
public static int getFragmentPosition(int measureWhat, boolean isSeparateObservation) {
if (measureWhat == StateConstantsPla.VALUE_MEASURE_WHAT_DEFAULT
// || measureWhat == StateConstants.VALUE_MEASURE_WHAT_ANGLE
|| measureWhat == StateConstantsPla.VALUE_MEASURE_WHAT_ANGLE_HOR) {
return 0;
} else if (measureWhat == StateConstantsPla.VALUE_MEASURE_WHAT_ANGLE_VER) {
return 1;
} else if (measureWhat == StateConstantsPla.VALUE_MEASURE_WHAT_DISTANCE) {
if (isSeparateObservation) {
return 3;
} else {
return 1;
}
}
return 0;
}
}

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

@ -0,0 +1,56 @@
package com.bingce.controlnetwork.event;
import org.greenrobot.eventbus.EventBus;
public class SurveyStateEvent {
private final static int STATE_IDLE = 0;
private final static int STATE_SURVEYING = STATE_IDLE + 1;
private final static int STATE_SURVEY_SUCCESS = STATE_SURVEYING + 1;
private final static int STATE_SURVEY_FAILURE = STATE_SURVEY_SUCCESS + 1;
private final static int STATE_SURVEY_COMPLETED = STATE_SURVEY_FAILURE + 1;
public final int state;
private SurveyStateEvent(int state) {
this.state = state;
}
public boolean isIdle() {
return STATE_IDLE == state;
}
public boolean isSurveying() {
return STATE_SURVEYING == state;
}
public boolean isSuccess() {
return STATE_SURVEY_SUCCESS == state;
}
public boolean isFailure() {
return STATE_SURVEY_FAILURE == state;
}
public boolean isCompleted() {
return STATE_SURVEY_COMPLETED == state;
}
public static void postIdle() {
EventBus.getDefault().post(new SurveyStateEvent(STATE_IDLE));
}
public static void postSurveying() {
EventBus.getDefault().post(new SurveyStateEvent(STATE_SURVEYING));
}
public static void postSuccess() {
EventBus.getDefault().post(new SurveyStateEvent(STATE_SURVEY_SUCCESS));
}
public static void postFailure() {
EventBus.getDefault().post(new SurveyStateEvent(STATE_SURVEY_FAILURE));
}
public static void postCompleted() {
EventBus.getDefault().post(new SurveyStateEvent(STATE_SURVEY_COMPLETED));
}
}

@ -1,144 +0,0 @@
package com.bingce.controlnetwork.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 androidx.lifecycle.LiveData;
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.surveyorstation.SurveyorStationRecord;
import com.bingce.controlapphelper.model.BundleConstants;
import com.bingce.controlapphelper.util.StationUtil;
import com.bingce.controlnetwork.R;
import com.bingce.controlnetwork.adapter.SurveyorStationListAdapter;
import com.bingce.controlnetwork.fragment.base.BaseFragment;
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.utils.ThreadPoolUtil;
import java.util.List;
/**
* 测站列表(项目和测量共用)
*/
public class ComponentSurveyorStationListFragment extends BaseFragment {
public static final String TAG = "cn.liuyanbing.surveyor.fragment.dummy__SurveyorStationListFragment___";
private SurveyorStationListAdapter adapter;
private RecyclerView recyclerView;
private LiveData<List<SurveyorStationRecord>> stationLiveData;
/**
* 去测量或者详情页面
*/
private void goStationMeasureOrDetail(SurveyorStationRecord item, boolean detailOrSurveyorFinal) {
String stationId = item.getId();
ThreadPoolUtil.execute(() -> {
SurveyorStationRecord stationRecord = SurveyorDatabaseFactory
.instance
.getSurveyorStation()
.getRecordSync(stationId);
if (stationRecord == null || stationRecord.getItems() == null || stationRecord.getItems().isEmpty()) {
return;
}
String lineTypeFromStation = StationUtil.getLineTypeFromStation(stationRecord);
//站的名称 导线+点名
String stationName = StationUtil.getStationName(stationRecord);
if (detailOrSurveyorFinal) {
SingleStationDetailAndEditFragment.start(getContext(), stationId, stationName, item.getProjectId(), null);
} else {
//StationSurveyorFragment原始测量页
if (ProjectType.isConnection(item.projectType)) {
MeasureFragment.start(getContext(), stationId, stationName);
} else {
StationSurveyorFragment.start(getContext(), stationId, stationName);
}
}
});
}
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_list_layout, container, false);
if (view instanceof RecyclerView) {
recyclerView = (RecyclerView) view;
if (getArguments() != null) {
update(getArguments().getString(BundleConstants.KEY_PROJECT_ID),
getArguments().getString(KEY_TIME_INDEX));
}
}
return view;
}
/**
* 根据项目id和测期id获取测站记录
*
* @param projectId
* @param periodId
*/
public void update(String projectId, String periodId) {
if (stationLiveData != null) {
stationLiveData.removeObservers(this);
}
stationLiveData = SurveyorDatabaseFactory
.instance
.getSurveyorStation().getLiveDataList(projectId, periodId);
stationLiveData.observe(getViewLifecycleOwner(), this::updateUi);
}
private void updateUi(List<SurveyorStationRecord> dataList) {
runOnUI(() -> {
if (adapter == null) {
boolean detailOrSurveyor = false;
if (getArguments() != null) {
detailOrSurveyor = getArguments().getBoolean(KEY_DETAIL_OR_SURVEYOR, false);
}
boolean detailOrSurveyorFinal = detailOrSurveyor;
adapter = new SurveyorStationListAdapter(dataList,
getChildFragmentManager(),
getViewLifecycleOwner(),
runnable -> {
if (getActivity() != null) {
getActivity().runOnUiThread(runnable);
}
},
getContext(),
item -> goStationMeasureOrDetail(item, detailOrSurveyorFinal),
detailOrSurveyor);
recyclerView.setAdapter(adapter);
} else {
adapter.updateData(dataList);
}
});
}
private static final String KEY_TIME_INDEX = "___time_index__";
private static final String KEY_DETAIL_OR_SURVEYOR = "___editable___";//标识点击item进入测量界面还是测站详情
public static ComponentSurveyorStationListFragment newInstance(String projectId, String surveyorPeriodId, boolean isDetail) {
ComponentSurveyorStationListFragment fragment = new ComponentSurveyorStationListFragment();
Bundle bundle = new Bundle();
bundle.putString(BundleConstants.KEY_PROJECT_ID, projectId);
bundle.putString(KEY_TIME_INDEX, surveyorPeriodId);
bundle.putBoolean(KEY_DETAIL_OR_SURVEYOR, isDetail);
fragment.setArguments(bundle);
return fragment;
}
public static ComponentSurveyorStationListFragment newInstance(String projectId, String surveyorPeriodId) {
return newInstance(projectId, surveyorPeriodId, true);
}
}

@ -32,6 +32,7 @@ import com.bingce.controlnetwork.surveyor.method.ExportUtilsPla;
import com.bingce.controlnetwork.ui.widget.treeview.TreeNode;
import com.bingce.controlnetwork.ui.widget.treeview.TreeView;
import com.bingce.controlnetwork.ui.widget.treeview.custom.MyNodeViewFactory;
import com.bingce.controlnetwork.util.StationUtilPla;
import com.bingce.file.FileOperator;
import com.bingce.utils.ThreadPoolUtil;
@ -176,7 +177,7 @@ public class SelectExportSurveyorRecordFragment extends BaseFragment {
2);
periodNode.addChild(stationNode);
boolean stationCanExport = StationUtil.isStationCanExport(stationRecord);
boolean stationCanExport = StationUtilPla.checkStationCanExport(stationRecord);
stationNode.setEnable(stationCanExport);
if (stationCanExport) {
projectHasData = true;

@ -0,0 +1,128 @@
package com.bingce.controlnetwork.fragment;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.os.Parcelable;
import android.text.TextUtils;
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.ColorRes;
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.controlapphelper.surveyor.method.ExportUtils;
import com.bingce.controlapphelper.surveyor.method.RadianMethod;
import com.bingce.controlapphelper.util.Tools;
import com.bingce.controlnetwork.R;
import com.bingce.controlnetwork.adapter.BaseAdapter;
import com.bingce.controlnetwork.model.AloneAdjustItem;
import com.bingce.controlnetwork.surveyor.state.StateConstantsPla;
import com.bingce.controlnetwork.ui.vh.StationAdjustAloneDistanceViewHolder;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.List;
public class StationDataAdjustAloneVerOrDistanceDialogFragment extends DialogFragment {
private static final String KEY_LIST = "__key_list";
private static final String KEY_MEASURE_WHAT = "KEY_MEASURE_WHAT";
private int measureWhatAloneAngleOrDistance;
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
if (getDialog() == null) {
return;
}
Window window = getDialog().getWindow();
window.setBackgroundDrawable(new ColorDrawable(0x00000000));
window.setLayout(
WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.WRAP_CONTENT);
}
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_station_data_adjust_dialog_alone_distance, container, false);
if (getArguments() != null) {
measureWhatAloneAngleOrDistance = getArguments().getInt(KEY_MEASURE_WHAT);
ArrayList<AloneAdjustItem> items = getArguments().getParcelableArrayList(KEY_LIST);
TextView tvTitle = rootView.findViewById(R.id.distance_angle_title);
tvTitle.setText(getTitle());
RecyclerView recyclerView = rootView.findViewById(R.id.list);
_Adapter adapter = new _Adapter(items);
recyclerView.setAdapter(adapter);
}
return rootView;
}
private String getTitle() {
if (StateConstantsPla.isMeasureVerAngle(measureWhatAloneAngleOrDistance)) {
return "垂直角";
} else if (StateConstantsPla.isMeasureDistance(measureWhatAloneAngleOrDistance)) {
return "距离";
}
return "";
}
private class _Adapter extends BaseAdapter<AloneAdjustItem, StationAdjustAloneDistanceViewHolder> {
public _Adapter(List<AloneAdjustItem> items) {
super(items);
}
@Override
protected StationAdjustAloneDistanceViewHolder createVH(@NotNull ViewGroup parent, int viewType) {
return new StationAdjustAloneDistanceViewHolder(getLayoutInflater().inflate(R.layout.item_station_adjust_alone_distance, parent, false));
}
@Override
public void onBindViewHolder(@NonNull @NotNull StationAdjustAloneDistanceViewHolder holder, int position) {
AloneAdjustItem item = getItem(position);
setText(holder.pointName, item.getPointName(), R.color.text_color_1);
if (!TextUtils.isEmpty(item.getErrorMsg())) {
setText(holder.distance, item.getErrorMsg(), R.color.value_dirty);
} else {
setText(holder.distance, getShowText(item), R.color.text_color_1);
}
}
private void setText(TextView textView, String string, @ColorRes int color) {
if (textView != null) {
textView.setText(string);
textView.setTextColor(Tools.getColor(color));
}
}
private String getShowText(AloneAdjustItem item) {
if (StateConstantsPla.isMeasureVerAngle(measureWhatAloneAngleOrDistance)) {
return RadianMethod.dmsStringOf(item.getVerAngle());
} else if (StateConstantsPla.isMeasureDistance(measureWhatAloneAngleOrDistance)) {
return ExportUtils.formatDistance(item.getDistance());
}
return "";
}
}
public static void showDialog(FragmentManager fragmentManager, int measureWhat, List<AloneAdjustItem> finalItemList) {
StationDataAdjustAloneVerOrDistanceDialogFragment dialogFragment = new StationDataAdjustAloneVerOrDistanceDialogFragment();
Bundle args = new Bundle();
args.putParcelableArrayList(KEY_LIST, (ArrayList<? extends Parcelable>) finalItemList);
args.putInt(KEY_MEASURE_WHAT, measureWhat);
dialogFragment.setArguments(args);
dialogFragment.show(fragmentManager, null);
}
}

@ -1,5 +1,6 @@
package com.bingce.controlnetwork.fragment;
import android.content.Context;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
@ -20,7 +21,10 @@ import com.bingce.controlapphelper.model.ViewItemType;
import com.bingce.controlapphelper.surveyor.method.RadianMethod;
import com.bingce.controlapphelper.surveyor.method.SurveyorAdjustMethod;
import com.bingce.controlapphelper.util.SettingValueUtil;
import com.bingce.controlnetwork.R;
import com.bingce.controlnetwork.adapter.BaseAdapter;
import com.bingce.controlnetwork.ui.vh.StationAdjustItemViewHolder;
import com.bingce.controlnetwork.ui.widget.ViewFactory;
import com.bingce.utils.Util;
import org.jetbrains.annotations.NotNull;
@ -28,11 +32,9 @@ import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.List;
import com.bingce.controlnetwork.R;
import com.bingce.controlnetwork.ui.vh.StationAdjustItemViewHolder;
import com.bingce.controlnetwork.ui.widget.ViewFactory;
public class StationDataAdjustDialogFragment extends DialogFragment {
public static final String KEY_MEASURE_WHAT = "__key_measure_what";
public static final String KEY_SHOW_TYPE = "__key_show_type";
private static final String KEY_LIST = "__key_list";
private static final String KEY_IS_SHOW_SLOP_DISTANCE = "__key_show_slop";
@ -169,6 +171,7 @@ public class StationDataAdjustDialogFragment extends DialogFragment {
}
}
public static void showDialog(String type, ArrayList<SurveyorAdjustMethod.Item> finalItemList,
Boolean isShowSlopDistance,
FragmentManager fragmentManager) {
@ -180,4 +183,5 @@ public class StationDataAdjustDialogFragment extends DialogFragment {
dialogFragment.setArguments(args);
dialogFragment.show(fragmentManager, StationDataAdjustDialogFragment.class.getName());
}
}

@ -0,0 +1,183 @@
package com.bingce.controlnetwork.fragment;
import android.content.Context;
import android.graphics.drawable.ColorDrawable;
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.controlapphelper.model.ViewItemType;
import com.bingce.controlapphelper.surveyor.method.RadianMethod;
import com.bingce.controlapphelper.util.SettingValueUtil;
import com.bingce.controlnetwork.R;
import com.bingce.controlnetwork.adapter.BaseAdapter;
import com.bingce.controlnetwork.surveyor.method.SurveyorAdjustMethodPla;
import com.bingce.controlnetwork.surveyor.state.StateConstantsPla;
import com.bingce.controlnetwork.ui.vh.StationAdjustItemViewHolder;
import com.bingce.controlnetwork.ui.widget.ViewFactory;
import com.bingce.utils.Util;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.List;
public class StationDataAdjustDialogFragmentTj extends DialogFragment {
public static final String KEY_MEASURE_WHAT = "__key_measure_what";
private static final String KEY_LIST = "__key_list";
private static final String KEY_IS_SHOW_SLOP_DISTANCE = "__key_show_slop";
private int measureWhat;
@Override
public void onAttach(@NonNull Context context) {
super.onAttach(context);
Bundle arguments = getArguments();
if (arguments != null) {
measureWhat = arguments.getInt(KEY_MEASURE_WHAT, StateConstantsPla.VALUE_MEASURE_WHAT_DEFAULT);
}
}
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
if (getDialog() == null) {
return;
}
Window window = getDialog().getWindow();
window.setBackgroundDrawable(new ColorDrawable(0x00000000));
window.setLayout(
WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.WRAP_CONTENT);
}
@Nullable
@org.jetbrains.annotations.Nullable
@Override
public View onCreateView(@NonNull @NotNull LayoutInflater inflater, @Nullable @org.jetbrains.annotations.Nullable ViewGroup container, @Nullable @org.jetbrains.annotations.Nullable Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_station_data_adjust_dialog_layout, container, false);
if (getArguments() != null) {
ArrayList<SurveyorAdjustMethodPla.Item> items = getArguments().getParcelableArrayList(KEY_LIST);
boolean isShowSlop = getArguments().getBoolean(KEY_IS_SHOW_SLOP_DISTANCE, true);
RecyclerView recyclerView = rootView.findViewById(R.id.list);
TextView distanceTitle = rootView.findViewById(R.id.distance_angle_title);
if (recyclerView != null) {
_Adapter adapter = new _Adapter(items);
recyclerView.setAdapter(adapter);
if (distanceTitle != null) {
distanceTitle.setText(isShowSlop ? R.string.distance_slope : R.string.distance_horizontal);
}
}
initShowView(rootView.findViewById(R.id.hor_angle_title),
rootView.findViewById(R.id.ver_angle_title),
rootView.findViewById(R.id.distance_angle_title));
}
return rootView;
}
private void initShowView(View horView, View verView, View disView) {
switch (measureWhat) {
case StateConstantsPla.VALUE_MEASURE_WHAT_DISTANCE:
horView.setVisibility(View.GONE);
verView.setVisibility(View.GONE);
disView.setVisibility(View.VISIBLE);
break;
case StateConstantsPla.VALUE_MEASURE_WHAT_ANGLE_HOR:
horView.setVisibility(View.VISIBLE);
verView.setVisibility(View.GONE);
disView.setVisibility(View.GONE);
break;
case StateConstantsPla.VALUE_MEASURE_WHAT_ANGLE_VER:
horView.setVisibility(View.GONE);
verView.setVisibility(View.VISIBLE);
disView.setVisibility(View.GONE);
break;
// case StateConstants.VALUE_MEASURE_WHAT_ANGLE:
case StateConstantsPla.VALUE_MEASURE_WHAT_DEFAULT:
default:
horView.setVisibility(View.VISIBLE);
verView.setVisibility(View.VISIBLE);
disView.setVisibility(View.VISIBLE);
break;
}
}
private class _Adapter extends BaseAdapter<SurveyorAdjustMethodPla.Item, StationAdjustItemViewHolder> {
public _Adapter(List<SurveyorAdjustMethodPla.Item> items) {
super(items);
}
@Override
protected StationAdjustItemViewHolder createVH(@NotNull ViewGroup parent, int viewType) {
RecyclerView.ViewHolder viewHolder = ViewFactory.generatorViewHolder(parent.getContext(), parent, ViewItemType.stationAdjust);
if (viewHolder instanceof StationAdjustItemViewHolder) {
return (StationAdjustItemViewHolder) viewHolder;
}
return null;
}
@Override
public void onBindViewHolder(@NonNull @NotNull StationAdjustItemViewHolder holder, int position) {
SurveyorAdjustMethodPla.Item item = getItem(position);
initShowView(holder.horAngle, holder.verAngle, holder.distance);
setText(holder.pointName, item.getPointName());
setText(holder.horAngle, formatAngle(item.getHorAngle()));
setText(holder.verAngle, formatAngle(item.getVerAngle()));
setText(holder.distance, formatDistance(item.getDistance()));
}
private void setText(TextView textView, String string) {
if (textView != null) {
textView.setText(string);
}
}
private String formatAngle(double angle) {
// if (angle < 0) {
// return "";
// }
return RadianMethod.dmsStringOf(angle);
}
private String formatDistance(double distance) {
if (distance < 0) {
return "";
}
return Util.formatDouble2String(distance, SettingValueUtil.getLengthDecimalPoint());
}
}
public static void showDialog(int measureWhat, ArrayList<SurveyorAdjustMethodPla.Item> finalItemList,
Boolean isShowSlopDistance,
FragmentManager fragmentManager) {
StationDataAdjustDialogFragmentTj dialogFragment = new StationDataAdjustDialogFragmentTj();
Bundle args = new Bundle();
args.putInt(KEY_MEASURE_WHAT, measureWhat);
args.putParcelableArrayList(KEY_LIST, finalItemList);
args.putBoolean(KEY_IS_SHOW_SLOP_DISTANCE, isShowSlopDistance);
dialogFragment.setArguments(args);
dialogFragment.show(fragmentManager, StationDataAdjustDialogFragmentTj.class.getName());
}
}

@ -2,7 +2,6 @@ package com.bingce.controlnetwork.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;
@ -16,40 +15,40 @@ import androidx.recyclerview.widget.RecyclerView;
import com.bingce.controlapphelper.datasource.database.SurveyorDatabaseFactory;
import com.bingce.controlapphelper.datasource.database.project.ProjectRecord;
import com.bingce.controlapphelper.datasource.database.schedule.SurveyorScheduleConstants;
import com.bingce.controlapphelper.datasource.database.schedule.SurveyorScheduleRecord;
import com.bingce.controlapphelper.datasource.database.surveyorstation.SurveyorStationRecord;
import com.bingce.controlapphelper.datasource.database.tolerance.detail.ToleranceDetailRecord;
import com.bingce.controlapphelper.surveyor.data.CachedData;
import com.bingce.controlapphelper.surveyor.data.ICachedData;
import com.bingce.controlapphelper.surveyor.data.IDistanceTypeChangeListener;
import com.bingce.controlapphelper.surveyor.data.SurveyorData;
import com.bingce.controlapphelper.surveyor.state.ISurveyState;
import com.bingce.controlapphelper.surveyor.surveyor.RequestSurveyorParamAuto;
import com.bingce.controlapphelper.util.DigitalUtil;
import com.bingce.controlapphelper.util.IUIRunner;
import com.bingce.controlnetwork.R;
import com.bingce.controlnetwork.adapter.SurveyorStationRecordsAdapter;
import com.bingce.controlnetwork.bean.SurveyorScheduleConstants;
import com.bingce.controlnetwork.fragment.base.BaseFragment;
import com.bingce.controlnetwork.surveyor.state.IScrollDelegate;
import com.bingce.controlnetwork.surveyor.state.angledistance.StateManager;
import com.bingce.totalstation.TotalStation;
import com.bingce.controlnetwork.surveyor.data.CachedData;
import com.bingce.controlnetwork.surveyor.data.CachedDataPointType;
import com.bingce.controlnetwork.surveyor.data.ICachedData;
import com.bingce.controlnetwork.surveyor.data.IDistanceTypeChangeListener;
import com.bingce.controlnetwork.surveyor.data.SurveyorData;
import com.bingce.controlnetwork.surveyor.state.ISurveyState;
import com.bingce.controlnetwork.surveyor.state.ISurveyorDataScrollDelegate;
import com.bingce.controlnetwork.surveyor.state.StateConstantsPla;
import com.bingce.controlnetwork.surveyor.state.StateManagerPla;
import com.bingce.utils.ThreadPoolUtil;
import blankj.utilcode.util.ToastUtils;
/**
* 测站某个测期的测量数据列表
* 量记录
*/
public class ComponentStationSurveyorDataListFragment extends BaseFragment
public class StationSurveyorRecordFragment extends BaseFragment
implements IDistanceTypeChangeListener, ISurveyState {
private SurveyorStationRecordsAdapter adapter = null;
private StateManager stateManager;
private StateManagerPla stateManager;
private RecyclerView recyclerView;
private IDistanceTypeChangeListener cachedDataListener = null;
private IDistanceTypeChangeListener surveyedDataListener = null;
private ISurveyState surveyState;
private String stationId() {
if (getArguments() == null) {
return null;
@ -75,7 +74,7 @@ public class ComponentStationSurveyorDataListFragment extends BaseFragment
getChildFragmentManager(),
getViewLifecycleOwner(),
this::runOnUI,
index -> {
(cycleIndex, index) -> {
if (index >= 0 && adapter != null && index < adapter.getItemCount()) {
recyclerView.scrollToPosition(index);
}
@ -83,6 +82,7 @@ public class ComponentStationSurveyorDataListFragment extends BaseFragment
new ICollectCacheCallback() {
@Override
public void onFailure() {
//TODO 收集测站测量信息失败,提示
}
@Override
@ -90,7 +90,7 @@ public class ComponentStationSurveyorDataListFragment extends BaseFragment
boolean showSlopDistance,
ICachedData cachedData,
SurveyorData surveyorData,
StateManager stateManager) {
StateManagerPla stateManager) {
onCollectStationData(showSlopDistance, cachedData, surveyorData, stateManager);
surveyState = stateManager;
}
@ -105,13 +105,16 @@ public class ComponentStationSurveyorDataListFragment extends BaseFragment
boolean showSlopDistance,
ICachedData cachedData,
SurveyorData surveyorData,
StateManager stateManager) {
StateManagerPla stateManager) {
this.stateManager = stateManager;
cachedDataListener = cachedData;
surveyedDataListener = surveyorData;
//测量数据收集完毕后,就可以更新UI了
runOnUI(() -> {
if (getView() == null) {
return;
}
//刷新UI
if (adapter == null) {
adapter = new SurveyorStationRecordsAdapter(stationId(), cachedData, surveyorData, surveyorData);
@ -126,14 +129,14 @@ public class ComponentStationSurveyorDataListFragment extends BaseFragment
}
}
// //监听测站数据
// //监听「平距」「斜距」切换,更新UI显示
// SurveyorDatabaseFactory
// .instance
// .getSurveyorStation()
// .getLiveDataRecord(stationId())
// .observe(getViewLifecycleOwner(),
// surveyorStationRecord -> onShowSlopDistance(surveyorStationRecord.isShowSlopDistance()));
//监听测站数据
//监听「平距」「斜距」切换,更新UI显示
SurveyorDatabaseFactory
.instance
.getSurveyorStation()
.getLiveDataRecord(stationId())
.observe(getViewLifecycleOwner(),
surveyorStationRecord -> onShowSlopDistance(surveyorStationRecord.isShowSlopDistance()));
});
}
@ -146,21 +149,23 @@ public class ComponentStationSurveyorDataListFragment extends BaseFragment
FragmentManager fragmentManager,
LifecycleOwner lifecycleOwner,
IUIRunner runner,
IScrollDelegate scrollDelegate,
ISurveyorDataScrollDelegate scrollDelegate,
ICollectCacheCallback callback) {
if (callback == null) {
return;
}
boolean isSupportAutoMode = TotalStation.getInstance().isSupportMotor();
ThreadPoolUtil.execute(() -> {
int measureWhat = StateConstantsPla.VALUE_MEASURE_WHAT_DEFAULT;
//读取当前测站的当前测回--很重要
SurveyorScheduleRecord scheduleRecord =
SurveyorDatabaseFactory
.instance
.getScheduleDataSource()
.findScheduleSync(SurveyorScheduleConstants.getCurrentCycleKey(stationId, null));
.findScheduleSync(SurveyorScheduleConstants.stationCurrentCycleKey(stationId, measureWhat));
int defaultCycle = scheduleRecord == null ? 0 :
DigitalUtil.valueOfIntString(scheduleRecord.getStatue(), 0);
DigitalUtil.string2Int(scheduleRecord.getStatue(), 0);
//加载测站信息
SurveyorStationRecord surveyorStationRecord =
SurveyorDatabaseFactory
@ -187,7 +192,7 @@ public class ComponentStationSurveyorDataListFragment extends BaseFragment
}
//创建缓存数据
CachedData cachedData =
CachedData.newInstance(surveyorStationRecord.isAutoClose(),
CachedData.newInstance(measureWhat, CachedDataPointType.ALL_POINT, surveyorStationRecord.isAutoClose(),
surveyorStationRecord.isLeftAndRightSurveyor(),
stationId, toleranceRecord);
if (cachedData == null) {
@ -203,16 +208,13 @@ public class ComponentStationSurveyorDataListFragment extends BaseFragment
//创建stateManager实例
SurveyorData surveyorDataSource = new SurveyorData(toleranceRecord.getSurveyorCount());
surveyorDataSource.onShowSlopDistance(surveyorStationRecord.isShowSlopDistance());
RequestSurveyorParamAuto requestSurveyorParamAuto = new RequestSurveyorParamAuto(stationId, cachedData);
StateManager stateManager = StateManager.newInstance(
isSupportAutoMode,
requestSurveyorParamAuto,
StateManagerPla stateManager = StateManagerPla.newInstance(measureWhat,
surveyorStationRecord,
context,
fragmentManager,
lifecycleOwner,
toleranceRecord,
cachedData,
surveyorDataSource,
surveyorDataSource,
cachedData,
@ -243,7 +245,7 @@ public class ComponentStationSurveyorDataListFragment extends BaseFragment
private interface ICollectCacheCallback {
void onFailure();
void onSuccess(boolean showSlopDistance, ICachedData cachedData, SurveyorData surveyorData, StateManager stateManager);
void onSuccess(boolean showSlopDistance, ICachedData cachedData, SurveyorData surveyorData, StateManagerPla stateManager);
}
public void doSurveyor() {
@ -298,33 +300,7 @@ public class ComponentStationSurveyorDataListFragment extends BaseFragment
if (stateManager == null) {
return;
}
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);
}
});
stateManager.stationAdjust();
}
public void goBack() {
@ -365,10 +341,10 @@ public class ComponentStationSurveyorDataListFragment extends BaseFragment
}
private static final String KEY_STATION_ID = "__station_id";
public static final String TAG = ComponentStationSurveyorDataListFragment.class.getName();
public static final String TAG = StationSurveyorRecordFragment.class.getName();
public static ComponentStationSurveyorDataListFragment newInstance(String stationId) {
ComponentStationSurveyorDataListFragment fragment = new ComponentStationSurveyorDataListFragment();
public static StationSurveyorRecordFragment newInstance(String stationId) {
StationSurveyorRecordFragment fragment = new StationSurveyorRecordFragment();
Bundle bundle = new Bundle();
bundle.putString(KEY_STATION_ID, stationId);
fragment.setArguments(bundle);

@ -10,9 +10,9 @@ public interface IMeasureOperate {
void switchCycle(int cycleIndex);
void deleteStationAllPeroidRecord();
void deleteStationAllCycleRecord();
void deleteStationOnePeriodRecord(int cycleIndex);
void deleteStationOneCycleRecord(int cycleIndex);
String stationCheck();
@ -21,8 +21,10 @@ public interface IMeasureOperate {
void goBack();
boolean isCurrentCycleComplete();
int measureTypePosition();
void refreshGoBackBtnEnable();
int getMeasureWhat();
void onResumeState();
void onPauseState();
int measureTypePosition();
}

@ -0,0 +1,213 @@
package com.bingce.controlnetwork.fragment.stationsurvey;
import android.content.Context;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
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.leveling.LevelingDbFactory;
import com.bingce.controlapphelper.datasource.database.leveling.idetection.isetting.LevelIDetectionSetting;
import com.bingce.controlapphelper.datasource.database.leveling.station.LevelingStationRecord;
import com.bingce.controlapphelper.datasource.database.leveling.stationsetting.LevelingStationSettingRecord;
import com.bingce.controlapphelper.datasource.database.surveyorstation.ISurveyorStationDataSource;
import com.bingce.controlapphelper.datasource.database.surveyorstation.SurveyorStationRecord;
import com.bingce.controlapphelper.datasource.database.surveyorstation.model.SurveyorPoint;
import com.bingce.controlapphelper.util.IUIRunner;
import com.bingce.controlnetwork.fragment.TipsWith2OptionFragment;
import com.bingce.controlnetwork.func.level.activity.LevelStationSettingActivity;
import com.bingce.controlnetwork.func.level.idetection.LevelIDetectionStationSettingActivity;
import com.bingce.controlnetwork.newui.stationsetting.StationSettingsActivity;
import com.bingce.utils.ThreadPoolUtil;
import java.util.List;
import blankj.utilcode.util.ToastUtils;
public class StationSettingCheckUtil {
//请设置温度、成像、太阳方向等相关信息(App只对以上信息进行留存,不会依此对数据进行校正).
private static final String HINT = "开始测量前请先进行测站设置";
private static final String HINT_LEVEL = "开始测量前请先进行测段设置";
public static final String HINT_LEVEL_END = "测段结束前请先进行测段设置";
private boolean isCheckSuccess;
/**
* 检测测站是否设置了棱镜相关属性如果没有则跳转到设置界面
*/
public void checkStationSettings(String stationId,
@NonNull Fragment fragment,
@NonNull IUIRunner runner, ICheckSuccess checkSuccess) {
if (isCheckSuccess) {
checkSuccess.onSuccess();
return;
}
ThreadPoolUtil.execute(() -> {
ISurveyorStationDataSource stationDataSource =
SurveyorDatabaseFactory.instance.getSurveyorStation();
//检测温度、湿度、气压、棱镜是否设置
SurveyorStationRecord stationRecord = stationDataSource.getRecordSync(stationId);
if (stationRecord == null) {
ToastUtils.showShort("stationRecord == null");
return;
}
List<SurveyorPoint> stationItemList = stationRecord.getItems();
if (stationItemList == null || stationItemList.isEmpty()) {
ToastUtils.showShort("stationItemList == null || stationItemList.isEmpty()");
return;
}
boolean failure = false;
for (SurveyorPoint stationItem : stationItemList) {
if (SurveyorPoint.TYPE_STATION.equals(stationItem.getType())) {
continue;
}
if (stationItem.isWellSteel()) {
continue;
}
if (isEmpty(stationItem.getPrismHeight())) {
failure = true;
break;
}
}
if (!failure && (isEmpty(stationRecord.getTemperature()) ||
isEmpty(stationRecord.getHumidity()) ||
isEmpty(stationRecord.getAirPressure()) ||
isEmpty(stationRecord.getInstrumentHeight()))) {
failure = true;
}
if (failure) {
runner.runOnUI(() -> TipsWith2OptionFragment.hardTips(
fragment.getChildFragmentManager(),
fragment.getViewLifecycleOwner(),
HINT,
new TipsWith2OptionFragment.SimpleCallback() {
@Override
public void onConfirm() {
// StationSettingsFragment.start(fragment.getContext(), stationId);
StationSettingsActivity.start(fragment.requireContext(), stationId);
}
@Override
public void onCancel() {
// if (fragment.getActivity() != null) {
// fragment.getActivity().finish();
// }
}
}));
return;
}
isCheckSuccess = true;
checkSuccess.onSuccess();
});
}
public static boolean isEmpty(String string) {
return string == null || string.isEmpty();
}
public interface ICheckSuccess {
void onSuccess();
}
/**
* 水准测站检测
*/
public void checkStationSettingsLevel(String stationId,
FragmentManager fragmentManager,
LifecycleOwner lifecycleOwner,
Context context,
IUIRunner runner, ICheckSuccess checkSuccessListener) {
if (isCheckSuccess) {
checkSuccessListener.onSuccess();
return;
}
ThreadPoolUtil.execute(() -> {
LevelingStationRecord stationRecord = LevelingDbFactory.instance.getStationDataSource().getRecordSync(stationId);
if (stationRecord == null) {
ToastUtils.showShort("stationRecord == null");
return;
}
LevelingStationSettingRecord stationSettingLatest = LevelingDbFactory.instance.getStationSettingDataSource().getLatest(stationRecord.routeId);
if (stationSettingLatest == null || stationSettingLatest.weather == null) {
//需要设置环境设置
runner.runOnUI(() -> showLevelSetStationSetting(fragmentManager,
lifecycleOwner, context,
HINT_LEVEL,
stationRecord.routeId, stationId, false)
);
return;
}
isCheckSuccess = true;
checkSuccessListener.onSuccess();
});
}
/**
* i角检测的测站设置
*/
public void checkStationSettingsIDetection(String iDetectionId,
@NonNull AppCompatActivity activity,
@NonNull IUIRunner runner, ICheckSuccess checkSuccessListener) {
if (isCheckSuccess) {
checkSuccessListener.onSuccess();
return;
}
ThreadPoolUtil.execute(() -> {
LevelIDetectionSetting setting = LevelingDbFactory.instance.getIDetectionSettingDataSource().getByIDetectionId(iDetectionId);
if (setting == null) {
//需要设置环境设置
runner.runOnUI(() -> TipsWith2OptionFragment.hardTips(
activity.getSupportFragmentManager(),
activity,
HINT,
new TipsWith2OptionFragment.SimpleCallback() {
@Override
public void onConfirm() {
LevelIDetectionStationSettingActivity.launch(activity, iDetectionId);
}
})
);
return;
}
isCheckSuccess = true;
checkSuccessListener.onSuccess();
});
}
/**
* 提示需要进行测站设置
*/
public static void showLevelSetStationSetting(@NonNull FragmentManager fragmentManager,
@NonNull LifecycleOwner lifecycleOwner,
Context context,
String hint,
String routeId,
String stationId,
boolean isSaveEndStation) {
TipsWith2OptionFragment.hardTips(
fragmentManager,
lifecycleOwner,
hint,
new TipsWith2OptionFragment.SimpleCallback() {
@Override
public void onConfirm() {
LevelStationSettingActivity.start(context, routeId, stationId, isSaveEndStation);
}
});
}
}

@ -4,8 +4,6 @@ import android.content.Context;
import android.graphics.Color;
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;
@ -17,28 +15,30 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.WorkerThread;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import com.bingce.controlapphelper.datasource.database.SurveyorDatabaseFactory;
import com.bingce.controlapphelper.datasource.database.project.ProjectRecord;
import com.bingce.controlapphelper.datasource.database.schedule.SurveyorScheduleConstants;
import com.bingce.controlapphelper.datasource.database.surveyorstation.SurveyorStationRecord;
import com.bingce.controlapphelper.datasource.database.tolerance.detail.ToleranceDetailRecord;
import com.bingce.controlapphelper.event.AutoSurveyorButtonVisibleEvent;
import com.bingce.controlapphelper.event.RefreshGoBackButton;
import com.bingce.controlapphelper.event.SurveyStateEvent;
import com.bingce.controlapphelper.model.BundleConstants;
import com.bingce.controlapphelper.surveyor.test.Test;
import com.bingce.controlapphelper.util.DigitalUtil;
import com.bingce.controlapphelper.util.StationUtil;
import com.bingce.controlapphelper.util.SurveyorCycleUtil;
import com.bingce.controlnetwork.R;
import com.bingce.controlnetwork.activity.fragmentcontainer.FragmentContainerActivity;
import com.bingce.controlnetwork.bean.SurveyorScheduleConstants;
import com.bingce.controlnetwork.event.AutoSurveyorButtonVisibleEvent;
import com.bingce.controlnetwork.event.RefreshRollBackEvent;
import com.bingce.controlnetwork.event.SurveyStateEvent;
import com.bingce.controlnetwork.fragment.BottomSheetSelectListFragment;
import com.bingce.controlnetwork.fragment.ComponentStationSurveyorDataListFragment;
import com.bingce.controlnetwork.fragment.SurveyorSettingsFragment;
import com.bingce.controlnetwork.fragment.StationSurveyorRecordFragment;
import com.bingce.controlnetwork.fragment.base.BaseFragment;
import com.bingce.controlnetwork.newui.stationsetting.StationSettingsActivity;
import com.bingce.controlnetwork.newui.stationsurveyor.ISurveyorMenuOperate;
import com.bingce.controlnetwork.newui.stationsurveyor.StationSurveyorHomeActivity;
import com.bingce.controlnetwork.surveyor.state.StateConstantsPla;
import com.bingce.controlnetwork.surveyor.surveyor.TestDataSelectFragment;
import com.bingce.controlnetwork.util.StationUtilPla;
import com.bingce.utils.ThreadPoolUtil;
import com.github.razir.progressbutton.DrawableButtonExtensionsKt;
import com.github.razir.progressbutton.ProgressButtonHolderKt;
@ -50,21 +50,34 @@ import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import blankj.utilcode.util.ToastUtils;
/**
* 测站测量页面开始测量
* 合并观测页面
*/
public class StationSurveyorFragment extends BaseFragment {
public class StationSurveyorFragment extends BaseFragment implements ISurveyorMenuOperate {
public static final String TAG = StationSurveyorFragment.class.getName();
private ComponentStationSurveyorDataListFragment fragment;
private MenuItem goBack = null;//数据回退菜单
private StationSurveyorRecordFragment fragment;
private SurveyorStationRecord surveyorStationRecord;
private int cycleIndex = 0;
private final StationSettingCheckUtil stationSettingCheckUtil=new StationSettingCheckUtil();
@Override
public void onStart() {
super.onStart();
EventBus.getDefault().register(this);
}
@Override
public void onStop() {
super.onStop();
EventBus.getDefault().unregister(this);
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void onRefreshGoBack(RefreshGoBackButton event) {
if (goBack != null) {
goBack.setEnabled(event.validate);
}
public void onRefreshGoBack(RefreshRollBackEvent event) {
setRollBackEnable(event.validate);
}
@Subscribe(threadMode = ThreadMode.MAIN)
@ -101,7 +114,7 @@ public class StationSurveyorFragment extends BaseFragment {
}
Button autoSurveyButton = getView().findViewById(R.id.auto_surveyor);
if (autoSurveyButton != null) {
autoSurveyButton.setVisibility(event.isReadyAutoSurvey() && !event.isOpenAutoSurvey()
autoSurveyButton.setVisibility(event.isReadyAutoSurvey && !event.isOpenAutoSurvey
? View.VISIBLE : View.GONE);
}
}
@ -131,39 +144,34 @@ public class StationSurveyorFragment extends BaseFragment {
}
}
@Override
public void onDestroyView() {
super.onDestroyView();
EventBus.getDefault().unregister(this);
}
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater,
@Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
EventBus.getDefault().register(this);
View view = inflater.inflate(R.layout.fragment_project_surveyor_station_detail_layout,
container,
false);
replaceFragment();
//1.添加测量数据显示fragment
fragment = StationSurveyorRecordFragment
.newInstance(stationId());
getChildFragmentManager()
.beginTransaction()
.replace(R.id.fragment_container, fragment, "___station_list")
.commit();
//2.设置测量按钮
Button surveyor = view.findViewById(R.id.surveyor);
if (surveyor != null) {
ProgressButtonHolderKt.bindProgressButton(getViewLifecycleOwner(), surveyor);
}
setSurveyorClick(view, R.id.surveyor, () -> {
if (fragment != null) {
fragment.doSurveyor();
}
});
setSurveyorClick(view, R.id.surveyor, this::startSurveyor);
setSurveyorClick(view, R.id.auto_surveyor, () -> {
if (fragment != null) {
fragment.autoSurvey();
}
stationSettingCheckUtil.checkStationSettings(stationId(), fragment, this, () -> {
if (fragment != null) {
fragment.autoSurvey();
}
});
});
//3.查询测站信息
ThreadPoolUtil.execute(() -> {
@ -172,7 +180,7 @@ public class StationSurveyorFragment extends BaseFragment {
.getSurveyorStation()
.getRecordSync(stationId());
//监听当前测回切换
initObserver(view);
monitorCurrentCycle(view);
//监听数据变化
ToleranceDetailRecord toleranceRecord = getTolerance(surveyorStationRecord);
if (toleranceRecord == null) {
@ -183,7 +191,9 @@ public class StationSurveyorFragment extends BaseFragment {
if (pick == null) {
return;
}
int cycleCount = toleranceRecord.getCycleCount();
int cycleCount = StationUtilPla.getCycleCount(StateConstantsPla.VALUE_MEASURE_WHAT_DEFAULT,
surveyorStationRecord, toleranceRecord);
pick.setOnClickListener(v -> {
ArrayList<String> cycleList = SurveyorCycleUtil.cycleStrings(cycleCount,
surveyorStationRecord != null && surveyorStationRecord.leftAndRightSurveyor);
@ -208,69 +218,33 @@ public class StationSurveyorFragment extends BaseFragment {
});
});
setHasOptionsMenu(true);
return view;
}
private void replaceFragment() {
//1.添加测量数据显示fragment
fragment = ComponentStationSurveyorDataListFragment
.newInstance(stationId());
getChildFragmentManager()
.beginTransaction()
.replace(R.id.fragment_container, fragment, "___station_list")
.commit();
}
private void initObserver(View view) {
runOnUI(() -> {
monitorCurrentCycle(view);
//监听测站变化
SurveyorDatabaseFactory
.instance
.getSurveyorStation()
.getLiveDataRecord(stationId())
.observe(getViewLifecycleOwner(),
stationRecord -> {
replaceFragment();
checkStationSettings();
});
});
}
private void checkStationSettings() {
ThreadPoolUtil.execute(() -> MethodCheckSetting.checkStationSettings(stationId(), fragment, this::runOnUI));
}
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
}
@WorkerThread
private void monitorCurrentCycle(View view) {
SurveyorDatabaseFactory
.instance
.getScheduleDataSource()
.findSchedule(SurveyorScheduleConstants.getCurrentCycleKey(stationId(), null))
.observe(getViewLifecycleOwner(), record -> {
TextView circleText = view.findViewById(R.id.circle_text);
//测回发生变化的时候,更新相应ui
int cycleIndex = DigitalUtil.valueOfIntString(record == null ? "0" : record.getStatue(), 0);
//更新测回名称
if (circleText != null) {
boolean showLeftOrRight = true;
if (surveyorStationRecord != null) {
showLeftOrRight = surveyorStationRecord.leftAndRightSurveyor;
if (getActivity() != null) {
getActivity().runOnUiThread(() -> SurveyorDatabaseFactory
.instance
.getScheduleDataSource()
.findSchedule(SurveyorScheduleConstants.stationCurrentCycleKey(stationId(), StateConstantsPla.VALUE_MEASURE_WHAT_DEFAULT))
.observe(getViewLifecycleOwner(), record -> {
TextView circleText = view.findViewById(R.id.circle_text);
//测回发生变化的时候,更新相应ui
int cycleIndex = DigitalUtil.string2Int(record == null ? "0" : record.getStatue(), 0);
//更新测回名称
if (circleText != null) {
boolean showLeftOrRight = true;
if (surveyorStationRecord != null) {
showLeftOrRight = surveyorStationRecord.leftAndRightSurveyor;
}
circleText.setText(SurveyorCycleUtil.cycleName(cycleIndex, showLeftOrRight));
}
circleText.setText(SurveyorCycleUtil.cycleName(cycleIndex, showLeftOrRight));
}
StationSurveyorFragment.this.cycleIndex = cycleIndex;
});
StationSurveyorFragment.this.cycleIndex = cycleIndex;
}));
}
}
private static void setSurveyorClick(View rootView, int id, Runnable runnable) {
@ -295,88 +269,9 @@ public class StationSurveyorFragment extends BaseFragment {
}
}
@Override
public void onCreateOptionsMenu(@NonNull @NotNull Menu menu, @NonNull @NotNull MenuInflater inflater) {
if (Test.DEBUG) {
inflater.inflate(R.menu.menu_surveyor_station_record_data_edit_debug_pla, menu);
} else {
inflater.inflate(R.menu.menu_surveyor_station_record_data_edit_release_pla, menu);
}
// MenuItem stationCheck = menu.findItem(R.id.menu_item_station_check);
// MenuItem stationAdjust = menu.findItem(R.id.menu_item_station_adjust);
goBack = menu.findItem(R.id.menu_item_go_back);
// SurveyorDatabaseFactory
// .instance
// .getScheduleDataSource()
// .findSchedule(SurveyorScheduleConstants.getAllCycleScheduleKey(stationId(), null))
// .observe(getViewLifecycleOwner(), surveyorScheduleRecord -> {
// boolean checkStatue = false;
// boolean adjustStatue = false;
// if (surveyorScheduleRecord != null) {
// String statue = surveyorScheduleRecord.getStatue();
// if (SurveyorScheduleConstants.STATUE_VALUE_CHECKED.equals(statue)) {
// adjustStatue = true;
// } else if (SurveyorScheduleConstants.STATUE_VALUE_COMPLETED.equals(statue)) {
// checkStatue = true;
// } else if (SurveyorScheduleConstants.STATUE_VALUE_NO_COMPLETED.equals(statue)) {
// //重置提醒标识
// String key = ConfigConstants.KEY_CONFIG_STATION_CHECK_REMINDED + stationId();
// SurveyorDatabaseFactory
// .instance
// .getConfigDataSource()
// .set(key, ConfigConstants.VALUE_NO);
// }
// }
// //更新菜单enable
// if (stationCheck != null) {
// stationCheck.setEnabled(checkStatue);
// }
// if (stationAdjust != null) {
// stationAdjust.setEnabled(adjustStatue);
// }
// });
}
@Override
public boolean onOptionsItemSelected(@NonNull @NotNull MenuItem item) {
if (R.id.menu_item_delete_current_records == item.getItemId()) {
//删除当前测回记录
if (surveyorStationRecord != null) {
//通知fragment
fragment.deleteByStationAndPeriod(cycleIndex);
}
} else if (R.id.menu_item_delete_all_records == item.getItemId()) {
//删除所有测回记录
if (surveyorStationRecord != null) {
//通知fragment
fragment.deleteCurrentStationSurveyorData();
}
} else if (R.id.menu_item_station_check == item.getItemId()) {
//测站检测,检测所有测回
fragment.stationCheck();
} else if (R.id.menu_item_data_source == item.getItemId()) {
//数据源 debug使用
TestDataSelectFragment.show(getChildFragmentManager());
} else if (R.id.menu_item_go_back == item.getItemId()) {
//回退
fragment.goBack();
} else if (R.id.menu_item_station_environment_prism_settings == item.getItemId()) {
//环境、棱镜设置
StationSettingsActivity.start(requireContext(), stationId());
// StationSettingsFragment.start(getContext(), stationId());
} else if (R.id.menu_item_surveyor_settings == item.getItemId()) {
//测量设置
ThreadPoolUtil.execute(() -> {
String name = StationUtil.getStationName(surveyorStationRecord);
runOnUI(() -> SurveyorSettingsFragment.start(getContext(), surveyorStationRecord.getId(), name));
});
} else if (R.id.menu_item_station_adjust == item.getItemId()) {
//测站平差,平差检测
fragment.stationAdjust();
} else if (R.id.menu_item_check_adjust == item.getItemId()) {
//检测平差
fragment.stationCheckAdjust();
}
return super.onOptionsItemSelected(item);
}
@ -411,4 +306,74 @@ public class StationSurveyorFragment extends BaseFragment {
fragment.setArguments(args);
return fragment;
}
@Override
public void deleteCurrentPeriodRecords() {
//删除当前测回记录
if (surveyorStationRecord != null) {
//通知fragment
fragment.deleteByStationAndPeriod(cycleIndex);
}
}
@Override
public void deleteAllPeriodRecords() {
//删除所有测回记录
if (surveyorStationRecord != null) {
//通知fragment
fragment.deleteCurrentStationSurveyorData();
}
}
@Override
public void test() {
//数据源 debug使用
TestDataSelectFragment.show(getChildFragmentManager());
}
@Override
public void rollBack() {
//回退
fragment.goBack();
}
@Override
public void stationSetting() {
//环境、棱镜设置
StationSettingsActivity.start(fragment.requireContext(), stationId());
// StationSettingsFragment.start(getContext(), stationId());
}
//SurveyorSettingsFragment 测量设置
@Override
public void adjust() {
//测站平差,平差检测
StationUtilPla.checkStationCanAdjust(stationId(), StateConstantsPla.VALUE_MEASURE_WHAT_DEFAULT, new StationUtilPla.ICanAdjust() {
@Override
public void adjust(boolean isCanAdjust) {
if (!isCanAdjust) {
ToastUtils.showShort("测站未通过检测!");
return;
}
fragment.stationAdjust();
}
});
}
@Override
public void startSurveyor() {
stationSettingCheckUtil.checkStationSettings(stationId(), fragment, this, () -> {
if (fragment != null) {
fragment.doSurveyor();
}
});
}
private void setRollBackEnable(boolean validate) {
FragmentActivity activity = getActivity();
if (activity != null) {
StationSurveyorHomeActivity homeActivity = (StationSurveyorHomeActivity) activity;
homeActivity.setRollBackEnable(validate);
}
}
}

@ -1,394 +0,0 @@
package com.bingce.controlnetwork.fragment.stationsurvey.angledistance;
import android.content.Context;
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 androidx.annotation.WorkerThread;
import androidx.fragment.app.FragmentManager;
import androidx.lifecycle.LifecycleOwner;
import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.RecyclerView;
import com.bingce.controlapphelper.datasource.database.SurveyorDatabaseFactory;
import com.bingce.controlapphelper.datasource.database.project.ProjectRecord;
import com.bingce.controlapphelper.datasource.database.schedule.SurveyorScheduleConstants;
import com.bingce.controlapphelper.datasource.database.schedule.SurveyorScheduleRecord;
import com.bingce.controlapphelper.datasource.database.surveyorstation.SurveyorStationRecord;
import com.bingce.controlapphelper.datasource.database.tolerance.detail.ToleranceDetailRecord;
import com.bingce.controlapphelper.event.RefreshGoBackButtonAloneDistance;
import com.bingce.controlapphelper.surveyor.data.CachedDataAloneDistance;
import com.bingce.controlapphelper.surveyor.data.IDistanceTypeChangeListener;
import com.bingce.controlapphelper.surveyor.data.IMeasureCache;
import com.bingce.controlapphelper.surveyor.data.ISurveyorData;
import com.bingce.controlapphelper.surveyor.data.SurveyorData;
import com.bingce.controlapphelper.surveyor.state.ISurveyState;
import com.bingce.controlapphelper.util.DigitalUtil;
import com.bingce.controlapphelper.util.IUIRunner;
import com.bingce.controlnetwork.adapter.MeasureAngleDistanceAdapter;
import com.bingce.controlnetwork.fragment.ComponentStationSurveyorDataListFragment;
import com.bingce.controlnetwork.fragment.base.BaseFragment;
import com.bingce.controlnetwork.fragment.stationsurvey.IMeasureOperate;
import com.bingce.controlnetwork.surveyor.state.IScrollDelegate;
import com.bingce.totalstation.TotalStation;
import com.bingce.utils.ThreadPoolUtil;
import org.greenrobot.eventbus.EventBus;
import blankj.utilcode.util.ToastUtils;
import com.bingce.controlnetwork.R;
import com.bingce.controlnetwork.adapter.MeasureAngleDistanceAdapter;
import com.bingce.controlnetwork.fragment.base.BaseFragment;
import com.bingce.controlnetwork.fragment.ComponentStationSurveyorDataListFragment;
import com.bingce.controlnetwork.fragment.stationsurvey.IMeasureOperate;
import com.bingce.controlnetwork.surveyor.state.IScrollDelegate;
import com.bingce.controlnetwork.surveyor.state.alonedistance.StateManagerAloneDistance;
import com.bingce.controlnetwork.surveyor.state.alonedistance._CheckStationState;
import com.bingce.controlnetwork.surveyor.state.alonedistance._DoCalAdjustState;
import com.bingce.controlnetwork.surveyor.state.alonedistance._IsSingleCycleCompletedState;
/**
* 单独测距
*/
public class MeasureDistanceFragment extends BaseFragment
implements IDistanceTypeChangeListener, ISurveyState, IMeasureOperate {
private MeasureAngleDistanceAdapter adapter = null;
private StateManagerAloneDistance stateManager; //这里的stateManager是克隆StateManager
private RecyclerView recyclerView;
private IMeasureCache cachedData = null;
private ISurveyorData surveyedData = null;
private String stationId() {
if (getArguments() == null) {
return null;
}
return getArguments().getString(KEY_STATION_ID);
}
private String getWellType() {
if (getArguments() != null) {
return getArguments().getString(KEY_TYPE_ANGLE_OR_DISTANCE);
}
return null;
}
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater,
@Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
View view = inflater.inflate(
R.layout.fragment_project_surveyor_station_point_list_layout,
container,
false);
recyclerView = view.findViewById(R.id.recycler_view);
collectData(stationId(),
getContext(),
getChildFragmentManager(),
getViewLifecycleOwner(),
this::runOnUI,
index -> {
scrollToPosition(index);
},
new ICollectCacheCallback() {
@Override
public void onFailure() {
}
@Override
public void onSuccess(boolean showSlopDistance, IMeasureCache cachedData, SurveyorData surveyorData, StateManagerAloneDistance stateManager) {
onCollectStationData(showSlopDistance, cachedData, surveyorData, stateManager);
}
}
);
return view;
}
@WorkerThread
private void onCollectStationData(
boolean showSlopDistance,
IMeasureCache cachedData,
SurveyorData surveyorData,
StateManagerAloneDistance stateManager) {
this.stateManager = stateManager;
this.cachedData = cachedData;
this.surveyedData = surveyorData;
//测量数据收集完毕后,就可以更新UI了
runOnUI(() -> {
//刷新UI
if (adapter == null) {
adapter = new MeasureAngleDistanceAdapter(stationId(),
cachedData, surveyorData, surveyorData, getWellType());
adapter.onShowSlopDistance(showSlopDistance);
if (recyclerView != null) {
recyclerView.setAdapter(adapter);
//滚动到当前目标点
int currentItemIndex = surveyorData.currentIndex();
scrollToPosition(currentItemIndex);
}
adapter.setOnItemClickListener(position -> {
if (isSurveying() || isAutoSurveying()) {
ToastUtils.showShort(R.string.measuring_please_waite);
return;
}
stateManager.switchCurrentMeasurePosition(position);
scrollToPosition(position);
// adapter.notifyDataSetChanged();
});
}
//监听测站数据,更新界面「平距」「斜距」显示
SurveyorDatabaseFactory
.instance
.getSurveyorStation()
.getLiveDataRecord(stationId())
.observe(getViewLifecycleOwner(),
surveyorStationRecord -> {
stateManager.updateStationRecord(surveyorStationRecord);
onShowSlopDistance(surveyorStationRecord.isShowSlopDistance());
});
});
}
private void scrollToPosition(int position) {
if (position >= 0 && adapter != null && position < adapter.getItemCount()) {
recyclerView.scrollToPosition(position);
adapter.notifyDataSetChanged();
}
}
/**
* 收集测站信息
*/
private synchronized void collectData(
String stationId,
Context context,
FragmentManager fragmentManager,
LifecycleOwner lifecycleOwner,
IUIRunner runner,
IScrollDelegate scrollDelegate,
ICollectCacheCallback callback) {
boolean isSupportAutoMode = TotalStation.getInstance().isSupportMotor();
ThreadPoolUtil.execute(() -> {
//读取当前测站的当前测回--很重要
SurveyorScheduleRecord scheduleRecord =
SurveyorDatabaseFactory
.instance
.getScheduleDataSource()
.findScheduleSync(SurveyorScheduleConstants.getCurrentCycleKey(stationId, SurveyorScheduleConstants.SCHEDULE_OR_CYCLE_TYPE_ALONE_DISTANCE));
int defaultCycle = scheduleRecord == null ? 0 :
DigitalUtil.valueOfIntString(scheduleRecord.getStatue(), 0);
//加载测站信息
SurveyorStationRecord surveyorStationRecord =
SurveyorDatabaseFactory
.instance
.getSurveyorStation()
.getRecordSync(stationId);
//加载对应项目
ProjectRecord projectRecord = SurveyorDatabaseFactory
.instance
.getProjectDataSource()
.getRecord(surveyorStationRecord.getProjectId());
if (projectRecord == null) {
callback.onFailure();
return;
}
//加载对应限差
ToleranceDetailRecord toleranceRecord = SurveyorDatabaseFactory
.instance
.getToleranceDetailDataSource()
.getRecordSync(projectRecord.getToleranceId());
if (toleranceRecord == null) {
callback.onFailure();
return;
}
//创建缓存数据
CachedDataAloneDistance cachedData = CachedDataAloneDistance.newInstance(stationId);
//是否显示斜距?
cachedData.onShowSlopDistance(surveyorStationRecord.isShowSlopDistance());
//创建stateManager实例
SurveyorData surveyorDataSource = new SurveyorData(ToleranceDetailRecord.ALONE_DISTANCE_MEASURE_COUNT);
surveyorDataSource.onShowSlopDistance(surveyorStationRecord.isShowSlopDistance());
StateManagerAloneDistance stateManager = StateManagerAloneDistance.newInstance(
isSupportAutoMode,
surveyorStationRecord,
context,
fragmentManager,
lifecycleOwner,
toleranceRecord,
surveyorDataSource,
surveyorDataSource,
cachedData,
createMeasureVm(),
scrollDelegate,
runner);
//fragment创建后立即计算当前cycle的测量状态
runner.runOnUI(() ->
stateManager.calScheduleWhenEnterSurveyFragment(defaultCycle));
callback.onSuccess(surveyorStationRecord.isShowSlopDistance(), cachedData, surveyorDataSource, stateManager);
});
}
public interface ICollectCacheCallback {
void onFailure();
void onSuccess(boolean showSlopDistance, IMeasureCache cachedData, SurveyorData surveyorData, StateManagerAloneDistance stateManager);
}
@Override
public void doSurveyor() {
if (stateManager == null) {
return;
}
stateManager.doSurveyor();
}
@Override
public void autoSurvey() {
if (stateManager == null) {
return;
}
stateManager.doAutoSurveyor();
}
@Override
public void switchCycle(int cycleIndex) {
if (stateManager == null) {
return;
}
stateManager.switch2Cycle(cycleIndex);
}
@Override
public void deleteStationAllPeroidRecord() {
if (stateManager == null) {
return;
}
stateManager.deleteCurrentStationSurveyorData();
}
@Override
public void deleteStationOnePeriodRecord(int cycleIndex) {
// if (stateManager == null) {
// return;
// }
// stateManager.deleteCurrentStationSurveyorData(cycleIndex);
}
@Override
public String stationCheck() {
if (stateManager == null) {
return null;
}
return _CheckStationState._stationCheckAloneDistance(stationId(), stateManager.getToleranceRecord(), stateManager.getCachedData());
}
@Override
public void stationAdjust() {
if (stateManager == null) {
return;
}
_DoCalAdjustState.doCalAdjust(stationId(), stateManager.getCachedData(), requireContext(),
getChildFragmentManager(), getViewLifecycleOwner());
// stateManager.stationAdjust();
}
@Override
public void goBack() {
if (stateManager == null) {
return;
}
stateManager.moveBack();
}
@Override
public void onShowSlopDistance(boolean value) {
if (cachedData != null) {
cachedData.onShowSlopDistance(value);
}
if (surveyedData != null) {
surveyedData.onShowSlopDistance(value);
}
if (adapter != null) {
adapter.onShowSlopDistance(value);
adapter.notifyItemRangeChanged(0, adapter.getItemCount());
}
}
@Override
public boolean isSurveying() {
if (stateManager != null) {
return stateManager.isSurveying();
}
return false;
}
@Override
public boolean isAutoSurveying() {
if (stateManager != null) {
return stateManager.isAutoSurveying();
}
return false;
}
private static final String KEY_STATION_ID = "__station_id";
private static final String KEY_TYPE_ANGLE_OR_DISTANCE = "__key_type_angle_or_distance";
public static final String TAG = ComponentStationSurveyorDataListFragment.class.getName();
public static MeasureDistanceFragment newInstance(String stationId, String typeAngleOrDistance) {
MeasureDistanceFragment fragment = new MeasureDistanceFragment();
Bundle bundle = new Bundle();
bundle.putString(KEY_STATION_ID, stationId);
bundle.putString(KEY_TYPE_ANGLE_OR_DISTANCE, typeAngleOrDistance);
fragment.setArguments(bundle);
return fragment;
}
@Override
public boolean isCurrentCycleComplete() {
if (stateManager == null)
return false;
boolean completed = _IsSingleCycleCompletedState.isSingleCycleCompleted(
stationId(),
StateManagerAloneDistance.CYCLE_INDEX_DEFAULT,
stateManager.getCachedData(), ToleranceDetailRecord.ALONE_DISTANCE_MEASURE_COUNT);
return completed;
}
@Override
public void refreshGoBackBtnEnable() {
if (stateManager == null || stateManager.getCachedData().pointCount() == 0) {
EventBus.getDefault().post(new RefreshGoBackButtonAloneDistance(false));
return;
}
stateManager.refreshGoBackBtnEnable();
}
@Override
public int measureTypePosition() {
return MeasureFragment.POSITION_DISTANCE_MEASURE;
}
private MeasureVm createMeasureVm() {
return new ViewModelProvider(requireParentFragment()).get(MeasureVm.class);
}
}

@ -1,180 +0,0 @@
package com.bingce.controlnetwork.fragment.stationsurvey.angledistance;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import com.bingce.controlapphelper.datasource.database.SurveyorDatabaseFactory;
import com.bingce.controlapphelper.datasource.database.schedule.SurveyorScheduleConstants;
import com.bingce.controlapphelper.model.BundleConstants;
import com.bingce.controlapphelper.util.StationUtil;
import com.bingce.controlapphelper.util.Tools;
import com.bingce.controlnetwork.R;
import com.bingce.controlnetwork.activity.fragmentcontainer.FragmentContainerActivity;
import com.bingce.controlnetwork.adapter.MeasureAngleDistanceAdapter;
import com.bingce.controlnetwork.fragment.SurveyorSettingsFragment;
import com.bingce.controlnetwork.fragment.stationsurvey.MethodCheckSetting;
import com.bingce.controlnetwork.fragment.stationsurvey.base.MeasureBaseFragment;
import com.bingce.controlnetwork.newui.stationsetting.StationSettingsActivity;
import com.bingce.controlnetwork.surveyor.surveyor.TestDataSelectFragment;
import com.bingce.utils.ThreadPoolUtil;
import org.jetbrains.annotations.NotNull;
/**
* 测站测量页面开始测量
*/
public class MeasureFragment extends MeasureBaseFragment {
public static final String TAG = MeasureFragment.class.getName();
//方位观测fragment的在adapter的索引
public static final int POSITION_DIRECTION_MEASURE = 0;
public static final int POSITION_DISTANCE_MEASURE = 1;
@Override
protected boolean isShowSelectCycle(int position) {
return POSITION_DIRECTION_MEASURE == position;
}
@Override
protected int defaultPageIndex() {
return POSITION_DIRECTION_MEASURE;
}
@Override
protected void addFragmentsTabs(Runnable runnable) {
MeasureDefaultFragment fragmentAngle = MeasureDefaultFragment.newInstance(stationId(), MeasureAngleDistanceAdapter.TYPE_ANGLE);
fragments.add(fragmentAngle);
MeasureDistanceFragment fragmentDistance = MeasureDistanceFragment.newInstance(stationId(), MeasureAngleDistanceAdapter.TYPE_DISTANCE);
fragments.add(fragmentDistance);
tabs.add(Tools.getString(R.string.azimuth_observation));
tabs.add(Tools.getString(R.string.alone_measure_distance));
runnable.run();
}
@Override
protected boolean isAloneDistancePage(int pageIndex) {
return POSITION_DISTANCE_MEASURE == pageIndex;
}
@Override
protected String getCurrentPageCycleKey() {
if (mBinding.vp.getCurrentItem() == POSITION_DIRECTION_MEASURE) {
return SurveyorScheduleConstants.getCurrentCycleKey(stationId(), null);
} else {
return SurveyorScheduleConstants.getCurrentCycleKey(stationId(), SurveyorScheduleConstants.SCHEDULE_OR_CYCLE_TYPE_ALONE_DISTANCE);
}
}
@Override
protected String getScheduleIdForAllCycle() {
int currentItem = mBinding.vp.getCurrentItem();
String scheduleId;
if (!isAloneDistancePage(currentItem)) {
scheduleId = SurveyorScheduleConstants.getAllCycleScheduleKey(stationId(), null);
} else {
scheduleId = SurveyorScheduleConstants.getAllCycleScheduleKey(stationId(), SurveyorScheduleConstants.SCHEDULE_OR_CYCLE_TYPE_ALONE_DISTANCE);
}
return scheduleId;
}
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = super.onCreateView(inflater, container, savedInstanceState);
initObserver();
return view;
}
private void initObserver() {
//监听测站变化
SurveyorDatabaseFactory
.instance
.getSurveyorStation()
.getLiveDataRecord(stationId())
.observe(getViewLifecycleOwner(),
stationRecord -> {
checkStationSettings();
});
// SurveyorScheduleConstants.getCurrentCycleKey(stationId(), SurveyorScheduleConstants.SCHEDULE_OR_CYCLE_TYPE_ALONE_DISTANCE);
monitorCurrentCycle(SurveyorScheduleConstants.getCurrentCycleKey(stationId(), null));
}
private void checkStationSettings() {
ThreadPoolUtil.execute(() -> MethodCheckSetting.checkStationSettings(stationId(), this, this::runOnUI));
}
@Override
public void onPrepareOptionsMenu(@NonNull Menu menu) {
super.onPrepareOptionsMenu(menu);
//删除当前测回记录
menu.findItem(R.id.menu_item_delete_current_records).setEnabled(deleteSingleCycleEnable());
}
@Override
public boolean onOptionsItemSelected(@NonNull @NotNull MenuItem item) {
if (R.id.menu_item_delete_current_records == item.getItemId()) {
//删除当前测回记录
if (surveyorStationRecord != null && currentFragment != null) {
//通知fragment
currentFragment.deleteStationOnePeriodRecord(cycleIndex);
}
} else if (R.id.menu_item_delete_all_records == item.getItemId()) {
//删除所有测回记录
if (surveyorStationRecord != null && currentFragment != null) {
//通知fragment
currentFragment.deleteStationAllPeroidRecord();
}
} else if (R.id.menu_item_station_check == item.getItemId() && currentFragment != null) {
//测站检测 被检测平差替代
stationCheckBefore();
} else if (R.id.menu_item_data_source == item.getItemId()) {
//数据源 debug使用
TestDataSelectFragment.show(getChildFragmentManager());
} else if (R.id.menu_item_go_back == item.getItemId() && currentFragment != null) {
//回退
currentFragment.goBack();
} else if (R.id.menu_item_station_environment_prism_settings == item.getItemId()) {
//环境、棱镜设置
StationSettingsActivity.start(requireContext(), stationId());
// StationSettingsFragment.start(getContext(), stationId());
} else if (R.id.menu_item_surveyor_settings == item.getItemId()) {
//测量设置 设置是否显示平距
ThreadPoolUtil.execute(() -> {
String name = StationUtil.getStationName(surveyorStationRecord);
runOnUI(() -> SurveyorSettingsFragment.start(getContext(), surveyorStationRecord.getId(), name));
});
} else if (R.id.menu_item_check_adjust == item.getItemId() && currentFragment != null) {
//检测平差
stationCheckAdjustBefore();
}
return super.onOptionsItemSelected(item);
}
private boolean deleteSingleCycleEnable() {
return currentFragment != null && currentFragment instanceof MeasureDefaultFragment;
}
public static void start(Context context, String surveyorStationId, String surveyorStationName) {
Bundle bundle = new Bundle();
bundle.putString(BundleConstants.KEY_SURVEYOR_STATION_ID, surveyorStationId);
FragmentContainerActivity.start(context, TAG, surveyorStationName, bundle);
}
public static Fragment newInstance(Bundle args) {
Fragment fragment = new MeasureFragment();
fragment.setArguments(args);
return fragment;
}
}

@ -0,0 +1,154 @@
package com.bingce.controlnetwork.fragment.stationsurvey.base;
import android.os.Bundle;
import android.view.View;
import androidx.annotation.IdRes;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
/**
* Created by dasu on 2016/9/27.
* <p>
* Fragment基类封装了懒加载的实现
* <p>
* 1Viewpager + Fragment情况下fragment的生命周期因Viewpager的缓存机制而失去了具体意义
* 该抽象类自定义新的回调方法当fragment可见状态改变时会触发的回调方法 Fragment 第一次可见时会回调的方法
*
* @see #onFragmentVisibleChange(boolean)
* @see #onFragmentFirstVisible()
*/
public abstract class BaseFragmentLazy extends Fragment {
private boolean isFragmentVisible;
private boolean isReuseView;
private boolean isFirstVisible;
private View rootView;
//setUserVisibleHint()在Fragment创建时会先被调用一次,传入isVisibleToUser = false
//如果当前Fragment可见,那么setUserVisibleHint()会再次被调用一次,传入isVisibleToUser = true
//如果Fragment从可见->不可见,那么setUserVisibleHint()也会被调用,传入isVisibleToUser = false
//总结:setUserVisibleHint()除了Fragment的可见状态发生变化时会被回调外,在new Fragment()时也会被回调
//如果我们需要在 Fragment 可见与不可见时干点事,用这个的话就会有多余的回调了,那么就需要重新封装一个
@Override
public void setUserVisibleHint(boolean isVisibleToUser) {
super.setUserVisibleHint(isVisibleToUser);
//setUserVisibleHint()有可能在fragment的生命周期外被调用
if (rootView == null) {
return;
}
if (isFirstVisible && isVisibleToUser) {
onFragmentFirstVisible();
isFirstVisible = false;
}
if (isVisibleToUser) {
onFragmentVisibleChange(true);
isFragmentVisible = true;
return;
}
if (isFragmentVisible) {
isFragmentVisible = false;
onFragmentVisibleChange(false);
}
}
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
initVariable();
}
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
//如果setUserVisibleHint()在rootView创建前调用时,那么
//就等到rootView创建完后才回调onFragmentVisibleChange(true)
//保证onFragmentVisibleChange()的回调发生在rootView创建完成之后,以便支持ui操作
if (rootView == null) {
rootView = view;
if (getUserVisibleHint()) {
if (isFirstVisible) {
onFragmentFirstVisible();
isFirstVisible = false;
}
onFragmentVisibleChange(true);
isFragmentVisible = true;
}
}
super.onViewCreated(isReuseView ? rootView : view, savedInstanceState);
}
@Override
public void onDestroyView() {
super.onDestroyView();
}
@Override
public void onDestroy() {
super.onDestroy();
initVariable();
}
private void initVariable() {
isFirstVisible = true;
isFragmentVisible = false;
rootView = null;
isReuseView = true;
}
/**
* 设置是否使用 view 的复用默认开启
* view 的复用是指ViewPager 在销毁和重建 Fragment 时会不断调用 onCreateView() -> onDestroyView()
* 之间的生命函数这样可能会出现重复创建 view 的情况导致界面上显示多个相同的 Fragment
* view 的复用其实就是指保存第一次创建的 view后面再 onCreateView() 时直接返回第一次创建的 view
*
* @param isReuse
*/
protected void reuseView(boolean isReuse) {
isReuseView = isReuse;
}
/**
* 去除setUserVisibleHint()多余的回调场景保证只有当fragment可见状态发生变化时才回调
* 回调时机在view创建完后所以支持ui操作解决在setUserVisibleHint()里进行ui操作有可能报null异常的问题
* <p>
* 可在该回调方法里进行一些ui显示与隐藏比如加载框的显示和隐藏
*
* @param isVisible true 不可见 -> 可见
* false 可见 -> 不可见
*/
protected void onFragmentVisibleChange(boolean isVisible) {
}
/**
* 在fragment首次可见时回调可在这里进行加载数据保证只在第一次打开Fragment时才会加载数据
* 这样就可以防止每次进入都重复加载数据
* 该方法会在 onFragmentVisibleChange() 之前调用所以第一次打开时可以用一个全局变量表示数据下载状态
* 然后在该方法内将状态设置为下载状态接着去执行下载的任务
* 最后在 onFragmentVisibleChange() 里根据数据下载状态来控制下载进度ui控件的显示与隐藏
*/
protected void onFragmentFirstVisible() {
}
protected boolean isFragmentVisible() {
return isFragmentVisible;
}
final protected void runOnUI(Runnable runnable) {
if (getActivity() == null) {
return;
}
getActivity().runOnUiThread(runnable);
}
final protected <T extends View> T findViewById(@IdRes int id) {
if (getActivity() == null) {
return null;
}
return getActivity().findViewById(id);
}
}

@ -305,7 +305,7 @@ public abstract class MeasureBaseFragment extends BaseFragment {
//切换tab测回可能会变刷新当前fragment
refreshCycleAndFragment();
currentFragment.refreshGoBackBtnEnable();
// currentFragment.refreshGoBackBtnEnable();
}
@Override

@ -155,7 +155,7 @@ class MeasureHeightTraverseFragment : MeasureBaseFragment() {
//删除当前测回记录
if (surveyorStationRecord != null && currentFragment != null) {
//通知fragment
currentFragment.deleteStationOnePeriodRecord(getCurrentMeasurePos())
currentFragment.deleteStationOneCycleRecord(getCurrentMeasurePos())
}
} else if (R.id.menu_item_delete_all_records == item.itemId) {
//删除所有测回记录
@ -185,7 +185,7 @@ class MeasureHeightTraverseFragment : MeasureBaseFragment() {
)
}
}
} else if (R.id.menu_item_check_adjust == item.itemId && currentFragment != null) {
} else if (R.id.menu_item_station_adjust == item.itemId && currentFragment != null) {
//检测平差
stationCheckAdjustBefore()
}
@ -220,7 +220,7 @@ class MeasureHeightTraverseFragment : MeasureBaseFragment() {
object : TipsWith2OptionFragment.SimpleCallback() {
override fun onConfirm() {
for (fragmentI in fragments) {
fragmentI.deleteStationAllPeroidRecord()
fragmentI.deleteStationAllCycleRecord()
}
}
})

@ -18,7 +18,6 @@ import com.bingce.controlapphelper.datasource.database.SurveyorDatabaseFactory;
import com.bingce.controlapphelper.datasource.database.project.ProjectRecord;
import com.bingce.controlapphelper.datasource.database.surveyorstation.SurveyorStationRecord;
import com.bingce.controlapphelper.datasource.database.tolerance.detail.ToleranceDetailRecord;
import com.bingce.controlapphelper.event.RefreshGoBackButton;
import com.bingce.controlapphelper.model.DataCategory;
import com.bingce.controlapphelper.model.LeftOrRight;
import com.bingce.controlapphelper.surveyor.data.CachedDataHeightTraverse;
@ -32,7 +31,6 @@ import com.bingce.controlapphelper.util.IUIRunner;
import com.bingce.controlapphelper.util.IdUtil;
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;
@ -42,8 +40,6 @@ import com.bingce.controlnetwork.surveyor.state.heighttraverse.StateManagerHeigh
import com.bingce.totalstation.TotalStation;
import com.bingce.utils.ThreadPoolUtil;
import org.greenrobot.eventbus.EventBus;
/**
* 测角测距
*/
@ -283,7 +279,7 @@ public class MeasureHeightTraverseSubFragment extends BaseLazyFragment
}
@Override
public void deleteStationAllPeroidRecord() {
public void deleteStationAllCycleRecord() {
if (stateManager == null) {
return;
}
@ -291,11 +287,12 @@ public class MeasureHeightTraverseSubFragment extends BaseLazyFragment
}
@Override
public void deleteStationOnePeriodRecord(int positionFragment) {
public void deleteStationOneCycleRecord(int cycleIndex) {
if (stateManager == null) {
return;
}
stateManager.deleteCurrentStationSurveyorData(positionFragment);
// TODO: 2024/8/30
stateManager.deleteCurrentStationSurveyorData(0);
}
@Override
@ -345,20 +342,27 @@ public class MeasureHeightTraverseSubFragment extends BaseLazyFragment
return true;
}
@Override
public void refreshGoBackBtnEnable() {
if (stateManager == null || stateManager.getCachedData().pointCount() == 0) {
EventBus.getDefault().post(new RefreshGoBackButton(false));
return;
}
stateManager.refreshGoBackBtnEnable();
}
@Override
public int measureTypePosition() {
return getBackOrFrontPosition();
}
@Override
public int getMeasureWhat() {
return 0;
}
@Override
public void onResumeState() {
}
@Override
public void onPauseState() {
}
@Override
public void onShowSlopDistance(boolean value) {
if (cachedData != null) {
@ -399,7 +403,7 @@ public class MeasureHeightTraverseSubFragment extends BaseLazyFragment
private static final String KEY_STATION_ID = "__station_id";
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 = MeasureHeightTraverseSubFragment.class.getName();
public static MeasureHeightTraverseSubFragment newInstance(String stationId, int frontOrBack) {
MeasureHeightTraverseSubFragment fragment = new MeasureHeightTraverseSubFragment();

@ -0,0 +1,476 @@
package com.bingce.controlnetwork.fragment.stationsurvey.separate;
import android.content.Context;
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 androidx.annotation.WorkerThread;
import androidx.fragment.app.FragmentManager;
import androidx.lifecycle.LifecycleOwner;
import androidx.recyclerview.widget.RecyclerView;
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.surveyorstation.SurveyorStationRecord;
import com.bingce.controlapphelper.datasource.database.tolerance.detail.ToleranceDetailRecord;
import com.bingce.controlapphelper.model.ViewItemType;
import com.bingce.controlapphelper.surveyor.data.IDistanceTypeChangeListener;
import com.bingce.controlapphelper.util.IUIRunner;
import com.bingce.controlapphelper.util.Tools;
import com.bingce.controlnetwork.R;
import com.bingce.controlnetwork.fragment.TipsWith2OptionFragment;
import com.bingce.controlnetwork.fragment.stationsurvey.IMeasureOperate;
import com.bingce.controlnetwork.fragment.stationsurvey.base.BaseFragmentLazy;
import com.bingce.controlnetwork.surveyor.data.CachedData;
import com.bingce.controlnetwork.surveyor.data.CachedDataPointType;
import com.bingce.controlnetwork.surveyor.data.ICachedData;
import com.bingce.controlnetwork.surveyor.data.ISurveyorData;
import com.bingce.controlnetwork.surveyor.data.SurveyorData;
import com.bingce.controlnetwork.surveyor.state.ISurveyState;
import com.bingce.controlnetwork.surveyor.state.ISurveyorDataScrollDelegate;
import com.bingce.controlnetwork.surveyor.state.StateConstantsPla;
import com.bingce.controlnetwork.surveyor.state.wellDistance.StateManagerWell;
import com.bingce.controlnetwork.surveyor.state.wellDistance._CheckToleranceState;
import com.bingce.utils.ThreadPoolUtil;
import blankj.utilcode.util.ToastUtils;
import com.bingce.controlnetwork.surveyor.state.wellDistance.IWeatherShowDialogListener;
/**
* 井定向钢丝测距或者单独测距
*/
public class StationSurveyorSeparateDistanceFragment extends BaseFragmentLazy
implements IDistanceTypeChangeListener, ISurveyState, IMeasureOperate {
private StationSurveyorSepatateAdapter adapter = null;
private StateManagerWell stateManager; //这里的stateManager是克隆StateManager
private RecyclerView recyclerView;
private ICachedData cachedData = null;
private ISurveyorData surveyedData = null;
private ISurveyState surveyState;
private final IWeatherShowDialogListener weatherShowDialogListener = (stationId, currentCycleIndex, pointId, beforeOrAfter, msg) -> {
if (getView() == null) return;
TipsWith2OptionFragment
.tips(
getChildFragmentManager(),
getViewLifecycleOwner(),
Tools.getString(R.string.confirm),
Tools.getString(R.string.cancel),
msg,
new TipsWith2OptionFragment.SimpleCallback() {
@Override
public void onConfirm() {
// DistanceWeatherSettingTjActivity.launch(requireContext(), stationId, currentCycleIndex, pointId, beforeOrAfter);
}
@Override
public void onIgnore() {
super.onIgnore();
}
}
);
};
private String stationId() {
if (getArguments() == null) {
return null;
}
return getArguments().getString(KEY_STATION_ID);
}
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater,
@Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
View view = inflater.inflate(
R.layout.fragment_project_surveyor_station_point_list_layout,
container,
false);
recyclerView = view.findViewById(R.id.recycler_view);
String stationId = stationId();
if (stationId != null) {
//收集信息
collectData(stationId,
getContext(),
getChildFragmentManager(),
getViewLifecycleOwner(),
this::runOnUI,
this::scrollToPosition,
new ICollectCacheCallback() {
@Override
public void onFailure() {
}
@Override
public void onSuccess(boolean showSlopDistance, ICachedData cachedData, SurveyorData surveyorData, StateManagerWell stateManager) {
onCollectStationData(showSlopDistance, cachedData, surveyorData, stateManager);
surveyState = stateManager;
}
}
);
}
return view;
}
@WorkerThread
private void onCollectStationData(
boolean showSlopDistance,
ICachedData cachedData,
SurveyorData surveyorData,
StateManagerWell stateManager) {
this.stateManager = stateManager;
this.cachedData = cachedData;
this.surveyedData = surveyorData;
//更新完棱镜类型刷新页面
// stateManager.setRefreshFragmentUiListener(() -> changeCacheDataAndRefreshUi(stationId()));
//测量数据收集完毕后,就可以更新UI了
runOnUI(() -> {
if (getView() == null) {
return;
}
//刷新UI
if (adapter == null) {
adapter = new StationSurveyorSepatateAdapter(stateManager.getProjectType(), stationId(),
cachedData, stateManager.getTolreanceRecord(), surveyorData, surveyorData, ViewItemType.aloneDistanceMeasure);
adapter.onShowSlopDistance(showSlopDistance);
if (recyclerView != null) {
recyclerView.setAdapter(adapter);
//滚动到当前目标点
int currentItemIndex = surveyorData.currentIndex();
scrollToPosition(0, currentItemIndex);
}
adapter.setOnItemClickListener(position -> {
if (isSurveying()) {
ToastUtils.showShort("正在测量中,请稍后...");
return;
}
stateManager.setCurrentIndex(position);
stateManager.setCurrentCycleIndex(0);
stateManager.refeshRollBackBtn();
scrollToPosition(0, position);
});
}
//监听测站数据,更新界面「平距」「斜距」显示
SurveyorDatabaseFactory
.instance
.getSurveyorStation()
.getLiveDataRecord(stationId())
.observe(getViewLifecycleOwner(),
surveyorStationRecord -> onShowSlopDistance(surveyorStationRecord.isShowSlopDistance()));
});
}
private void scrollToPosition(int cycleIndex, int position) {
if (position >= 0 && adapter != null && position < adapter.getItemCount()) {
recyclerView.scrollToPosition(position);
adapter.notifyDataSetChanged();
}
}
/**
* 收集测站信息
*/
private void collectData(
String stationId,
Context context,
FragmentManager fragmentManager,
LifecycleOwner lifecycleOwner,
IUIRunner runner,
ISurveyorDataScrollDelegate scrollDelegate,
ICollectCacheCallback callback) {
if (callback == null) {
return;
}
ThreadPoolUtil.execute(() -> {
//加载测站信息
SurveyorStationRecord stationRecord =
SurveyorDatabaseFactory
.instance
.getSurveyorStation()
.getRecordSync(stationId);
//加载对应项目
ProjectRecord projectRecord = SurveyorDatabaseFactory
.instance
.getProjectDataSource()
.getRecord(stationRecord.getProjectId());
if (projectRecord == null) {
callback.onFailure();
return;
}
//加载对应限差
ToleranceDetailRecord toleranceRecord = SurveyorDatabaseFactory
.instance
.getToleranceDetailDataSource()
.getRecordSync(projectRecord.getToleranceId());
if (toleranceRecord == null) {
callback.onFailure();
return;
}
//创建缓存数据
CachedDataPointType cachedDataPointType = CachedDataPointType.ALONE_MEASURE_DISTANCE_POINT;
if (isConnection(stationRecord.projectType)) {
//如果是联系列表收集的是钢丝
cachedDataPointType = CachedDataPointType.STEEL_POINT;
}
CachedData cachedData = CachedData.newInstance(StateConstantsPla.VALUE_MEASURE_WHAT_DISTANCE, cachedDataPointType, stationRecord.isAutoClose(),
stationRecord.isLeftAndRightSurveyor(),
stationId, toleranceRecord);
if (cachedData == null) {
callback.onFailure();
return;
}
//是否显示斜距?
cachedData.onShowSlopDistance(stationRecord.isShowSlopDistance());
//创建stateManager实例
SurveyorData surveyorDataSource = new SurveyorData(ToleranceDetailRecord.ALONE_DISTANCE_MEASURE_COUNT);
surveyorDataSource.onShowSlopDistance(stationRecord.isShowSlopDistance());
//
StateManagerWell stateManager = StateManagerWell.newInstance(
stationRecord,
context,
fragmentManager,
lifecycleOwner,
toleranceRecord,
cachedData,
surveyorDataSource,
surveyorDataSource,
cachedData,
scrollDelegate,
runner,
weatherShowDialogListener
);
callback.onSuccess(stationRecord.isShowSlopDistance(), cachedData, surveyorDataSource, stateManager);
});
}
/**
* 改变cacheData并刷新Ui
*/
private void changeCacheDataAndRefreshUi(String stationId) {
ThreadPoolUtil.execute(() -> {
//加载测站信息
SurveyorStationRecord surveyorStationRecord =
SurveyorDatabaseFactory
.instance
.getSurveyorStation()
.getRecordSync(stationId);
//加载对应项目
ProjectRecord projectRecord = SurveyorDatabaseFactory
.instance
.getProjectDataSource()
.getRecord(surveyorStationRecord.getProjectId());
if (projectRecord == null) {
return;
}
//加载对应限差
ToleranceDetailRecord toleranceRecord = SurveyorDatabaseFactory
.instance
.getToleranceDetailDataSource()
.getRecordSync(projectRecord.getToleranceId());
if (toleranceRecord == null) {
return;
}
//创建缓存数据
CachedDataPointType cachedDataPointType = CachedDataPointType.ALONE_MEASURE_DISTANCE_POINT;
if (isConnection(surveyorStationRecord.projectType)) {
cachedDataPointType = CachedDataPointType.STEEL_POINT;
}
CachedData cachedData = CachedData.newInstance(StateConstantsPla.VALUE_MEASURE_WHAT_DEFAULT, cachedDataPointType, surveyorStationRecord.isAutoClose(),
surveyorStationRecord.isLeftAndRightSurveyor(),
stationId, toleranceRecord);
if (cachedData != null) {
//是否显示斜距?
cachedData.onShowSlopDistance(surveyorStationRecord.isShowSlopDistance());
// stateManager.setCachedData(cachedData);
adapter.setCachedData(cachedData);
runOnUI(() -> adapter.notifyDataSetChanged());
}
});
}
public interface ICollectCacheCallback {
void onFailure();
void onSuccess(boolean showSlopDistance, ICachedData cachedData, SurveyorData surveyorData, StateManagerWell stateManager);
}
@Override
public void doSurveyor() {
if (stateManager == null) {
return;
}
stateManager.doSurveyor();
}
@Override
public void autoSurvey() {
}
@Override
public void switchCycle(int cycleIndex) {
if (stateManager == null) {
return;
}
stateManager.switch2Cycle(cycleIndex);
}
@Override
public void deleteStationAllCycleRecord() {
if (stateManager == null) {
return;
}
stateManager.deletePointAllCycleData();
}
@Override
public void deleteStationOneCycleRecord(int cycleIndex) {
if (stateManager == null) {
return;
}
stateManager.deletePointCurrentCycleData();
}
@Override
public String stationCheck() {
if (stateManager == null) {
return null;
}
stateManager.stationCheck();
return null;
}
@Override
public void stationAdjust() {
if (stateManager != null) {
stateManager.stationAdjust();
}
}
@Override
public void goBack() {
if (stateManager == null) {
return;
}
stateManager.moveBack();
}
@Override
public void onShowSlopDistance(boolean value) {
if (cachedData != null) {
cachedData.onShowSlopDistance(value);
}
if (surveyedData != null) {
surveyedData.onShowSlopDistance(value);
}
if (adapter != null) {
adapter.onShowSlopDistance(value);
adapter.notifyItemRangeChanged(0, adapter.getItemCount());
}
}
@Override
public boolean isSurveying() {
if (surveyState != null) {
return surveyState.isSurveying();
}
return false;
}
@Override
public boolean isAutoSurveying() {
if (surveyState != null) {
return surveyState.isAutoSurveying();
}
return false;
}
private static final String KEY_STATION_ID = "__station_id";
private static final String KEY_WELL_TYPE = "__well_type";
public static final String TAG = StationSurveyorSeparateDistanceFragment.class.getName();
public static StationSurveyorSeparateDistanceFragment newInstance(String stationId) {
StationSurveyorSeparateDistanceFragment fragment = new StationSurveyorSeparateDistanceFragment();
Bundle bundle = new Bundle();
bundle.putString(KEY_STATION_ID, stationId);
fragment.setArguments(bundle);
return fragment;
}
@Override
public boolean isCurrentCycleComplete() {
if (stateManager == null)
return false;
return _CheckToleranceState.isCompleteAllPointForAloneDistance(stationId(), 0, stateManager.getCachedData());
}
@Override
public int measureTypePosition() {
return 0;
}
@Override
public int getMeasureWhat() {
return StateConstantsPla.VALUE_MEASURE_WHAT_DISTANCE;
}
@Override
public void onResumeState() {
if (stateManager != null) {
stateManager.resume();
}
}
@Override
public void onPauseState() {
if (stateManager != null) {
stateManager.quite();
}
}
@Override
protected void onFragmentFirstVisible() {
if (stateManager != null)
stateManager.calScheduleWhenEnterSurveyFragment();
// if (stateManager != null)
// stateManager.enter(StateType.idle);
}
/**
* 是否联系测量
*
* @param projectType 项目类型
* @return
*/
private boolean isConnection(String projectType) {
return ProjectTypeValue.CONNECTION.equals(projectType);
}
}

@ -0,0 +1,375 @@
package com.bingce.controlnetwork.fragment.stationsurvey.separate;
import android.content.Context;
import android.graphics.Color;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.Button;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentStatePagerAdapter;
import androidx.viewpager.widget.PagerAdapter;
import androidx.viewpager.widget.ViewPager;
import com.bingce.controlapphelper.model.BundleConstants;
import com.bingce.controlnetwork.R;
import com.bingce.controlnetwork.activity.fragmentcontainer.FragmentContainerActivity;
import com.bingce.controlnetwork.event.RefreshRollBackEvent;
import com.bingce.controlnetwork.event.SurveyStateEvent;
import com.bingce.controlnetwork.fragment.base.BaseFragment;
import com.bingce.controlnetwork.fragment.stationsurvey.IMeasureOperate;
import com.bingce.controlnetwork.newui.stationsetting.StationSettingsActivity;
import com.bingce.controlnetwork.newui.stationsurveyor.ISurveyorMenuOperate;
import com.bingce.controlnetwork.newui.stationsurveyor.StationSurveyorHomeActivity;
import com.bingce.controlnetwork.surveyor.surveyor.TestDataSelectFragment;
import com.bingce.controlnetwork.util.StationSettingCheckUtil;
import com.flyco.tablayout.SlidingTabLayout;
import com.github.razir.progressbutton.DrawableButtonExtensionsKt;
import com.github.razir.progressbutton.ProgressButtonHolderKt;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import java.util.ArrayList;
import java.util.List;
/**
* 测站测量页面开始测量
* 水平角垂直角距离分开观测
*/
public class StationSurveyorSeparateFragment extends BaseFragment implements ISurveyorMenuOperate {
public static final String TAG = StationSurveyorSeparateFragment.class.getName();
// private SurveyorStationRecord surveyorStationRecord;
//方位观测fragment的在adapter的索引
public static final int POSITION_ANGLE_HOR = 0;
public static final int POSITION_ANGLE_VER = 1;
public static final int POSITION_DISTANCE_MEASURE = 2;
private final String[] tabs = {
"水平角观测", "垂直角观测", "距离观测"
};
private List<IMeasureOperate> fragments;
private IMeasureOperate currentFragment;
private ViewPager vp;
private final StationSettingCheckUtil stationSettingCheckUtil = new StationSettingCheckUtil();
@Subscribe(threadMode = ThreadMode.MAIN)
public void onRefreshGoBack(RefreshRollBackEvent event) {
if (vp != null) {
int currentItem = vp.getCurrentItem();
if (currentItem == POSITION_ANGLE_HOR) {
setRollBackEnable(event.validate);
} else if (currentItem == POSITION_DISTANCE_MEASURE) {
setRollBackEnable(event.validate);
}
}
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void onSurveyorStateChanged(SurveyStateEvent event) {
if (getView() == null) {
return;
}
Button surveyorButton = getView().findViewById(R.id.surveyor);
if (surveyorButton == null) {
return;
}
if (event.isIdle() || event.isSuccess() || event.isCompleted()) {
DrawableButtonExtensionsKt.hideProgress(surveyorButton, R.string.start_surveyor);
} else if (event.isSurveying()) {
DrawableButtonExtensionsKt.showProgress(surveyorButton, progressParams -> {
progressParams.setButtonTextRes(R.string.tips_surveying);
progressParams.setProgressColor(Color.WHITE);
return null;
});
} else if (event.isFailure()) {
DrawableButtonExtensionsKt.hideProgress(surveyorButton, R.string.tips_surveyor_failure_and_retry);
}
boolean enable = event.isIdle() || event.isFailure() || event.isSuccess();
setSurveyorEnable(getView(), R.id.surveyor, enable);
}
private String stationId() {
if (getArguments() == null) {
return null;
}
return getArguments().getString(BundleConstants.KEY_SURVEYOR_STATION_ID);
}
@Override
public void onStart() {
super.onStart();
EventBus.getDefault().register(this);
}
@Override
public void onStop() {
super.onStop();
EventBus.getDefault().unregister(this);
}
@Override
public void onResume() {
super.onResume();
//测量界面保持常亮
if (getActivity() != null) {
getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}
if (currentFragment != null) {
currentFragment.onResumeState();
}
}
@Override
public void onPause() {
super.onPause();
//清除界面常亮
if (getActivity() != null) {
getActivity().getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}
if (currentFragment != null) {
currentFragment.onPauseState();
}
}
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater,
@Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_station_surveyor_separate,
container,
false);
//2.设置测量按钮
Button surveyor = view.findViewById(R.id.surveyor);
if (surveyor != null) {
ProgressButtonHolderKt.bindProgressButton(getViewLifecycleOwner(), surveyor);
}
setClick(view, R.id.surveyor, this::startSurveyor);
setHasOptionsMenu(true);
return view;
}
private void initData() {
// ThreadPoolUtil.execute(() -> {
// surveyorStationRecord = TjDbFactory
// .instance
// .getSurveyorStation()
// .getRecordSync(stationId());
// //监听数据变化
// ToleranceDetailRecordTj toleranceRecord = getTolerance(surveyorStationRecord);
// if (toleranceRecord == null) {
// return;
// }
// int cycleCount = StationUtilTj.getCycleCount(surveyorStationRecord, toleranceRecord);
// cycleList = SurveyorCycleUtil.cycleStrings(cycleCount,
// surveyorStationRecord != null && surveyorStationRecord.leftAndRightSurveyor);
// });
}
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
initViewPager(view);
initData();
}
private void initViewPager(View view) {
fragments = new ArrayList<>();
fragments.add(StationSurveyorSeparateHorAngleFragment.newInstance(stationId()));
fragments.add(StationSurveyorSeparateVerAngleFragment.newInstance(stationId()));
fragments.add(StationSurveyorSeparateDistanceFragment.newInstance(stationId()));
SlidingTabLayout tabLayout = view.findViewById(R.id.tabLayout);
vp = view.findViewById(R.id.vp);
vp.setOffscreenPageLimit(3);
vp.setAdapter(new MyPagerAdapter(getChildFragmentManager()));
tabLayout.setViewPager(vp);
vp.setCurrentItem(POSITION_ANGLE_HOR);
currentFragment = fragments.get(POSITION_ANGLE_HOR);
vp.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
public void onPageSelected(int position) {
currentFragment = fragments.get(position);
//刷新按钮状态
boolean currentCycleComplete = currentFragment.isCurrentCycleComplete();
if (currentCycleComplete) {
SurveyStateEvent.postCompleted();
} else {
SurveyStateEvent.postIdle();
}
}
@Override
public void onPageScrollStateChanged(int state) {
}
});
}
private static void setClick(View rootView, int id, Runnable runnable) {
View view = rootView.findViewById(id);
if (view != null) {
view.setOnClickListener(v -> runnable.run());
}
}
private static void setSurveyorEnable(View rootView, int id, boolean enable) {
if (rootView == null) {
return;
}
View view = rootView.findViewById(id);
if (view != null) {
view.setEnabled(enable);
if (enable) {
view.setAlpha(1);
} else {
view.setAlpha(.4f);
}
}
}
private void setRollBackEnable(boolean validate) {
FragmentActivity activity = getActivity();
if (activity != null) {
StationSurveyorHomeActivity homeActivity = (StationSurveyorHomeActivity) activity;
homeActivity.setRollBackEnable(validate);
}
}
public static void start(Context context, String surveyorStationId, String surveyorStationName) {
Bundle bundle = new Bundle();
bundle.putString(BundleConstants.KEY_SURVEYOR_STATION_ID, surveyorStationId);
FragmentContainerActivity.start(context, TAG, surveyorStationName, bundle);
}
public static Fragment newInstance(Bundle args) {
Fragment fragment = new StationSurveyorSeparateFragment();
fragment.setArguments(args);
return fragment;
}
@Override
public void deleteCurrentPeriodRecords() {
//删除当前测回记录
if (currentFragment != null) {
currentFragment.deleteStationOneCycleRecord(0);//0是占位
}
}
@Override
public void deleteAllPeriodRecords() {
//删除所有测回记录
if (currentFragment != null) {
currentFragment.deleteStationAllCycleRecord();
}
}
@Override
public void test() {
//数据源 debug使用
TestDataSelectFragment.show(getChildFragmentManager());
}
@Override
public void rollBack() {
//回退
currentFragment.goBack();
}
@Override
public void stationSetting() {
//环境、棱镜设置
StationSettingsActivity.start(requireContext(), stationId());
// StationSettingsFragment.start(getContext(), stationId());
}
//SurveyorSettingsFragment 测量设置
@Override
public void adjust() {
//测站平差
if (currentFragment != null) {
currentFragment.stationAdjust();
}
}
@Override
public void startSurveyor() {
stationSettingCheckUtil.checkStationSettings(stationId(), this, this, () -> {
if (currentFragment != null) {
currentFragment.doSurveyor();
}
});
}
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 tabs[position];
}
@Override
public Fragment getItem(int position) {
return (Fragment) fragments.get(position);
}
@Override
public int getItemPosition(@NonNull Object object) {
return PagerAdapter.POSITION_NONE;
}
}
private boolean isHorAnglePage() {
return vp.getCurrentItem() == POSITION_ANGLE_HOR;
}
private boolean isVerAnglePage() {
return vp.getCurrentItem() == POSITION_ANGLE_VER;
}
private boolean isDistancePage() {
return vp.getCurrentItem() == POSITION_DISTANCE_MEASURE;
}
}

@ -0,0 +1,475 @@
package com.bingce.controlnetwork.fragment.stationsurvey.separate;
import android.content.Context;
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 androidx.annotation.WorkerThread;
import androidx.fragment.app.FragmentManager;
import androidx.lifecycle.LifecycleOwner;
import androidx.lifecycle.LiveData;
import androidx.recyclerview.widget.RecyclerView;
import com.bingce.controlapphelper.datasource.database.SurveyorDatabaseFactory;
import com.bingce.controlapphelper.datasource.database.project.ProjectRecord;
import com.bingce.controlapphelper.datasource.database.schedule.SurveyorScheduleRecord;
import com.bingce.controlapphelper.datasource.database.surveyorstation.SurveyorStationRecord;
import com.bingce.controlapphelper.datasource.database.tolerance.detail.ToleranceDetailRecord;
import com.bingce.controlapphelper.model.ViewItemType;
import com.bingce.controlapphelper.util.DigitalUtil;
import com.bingce.controlapphelper.util.IUIRunner;
import com.bingce.controlapphelper.util.SurveyorCycleUtil;
import com.bingce.controlnetwork.R;
import com.bingce.controlnetwork.bean.SurveyorScheduleConstants;
import com.bingce.controlnetwork.fragment.BottomSheetSelectListFragment;
import com.bingce.controlnetwork.fragment.base.BaseFragment;
import com.bingce.controlnetwork.fragment.stationsurvey.IMeasureOperate;
import com.bingce.controlnetwork.surveyor.data.CachedData;
import com.bingce.controlnetwork.surveyor.data.CachedDataPointType;
import com.bingce.controlnetwork.surveyor.data.ICachedData;
import com.bingce.controlnetwork.surveyor.data.IDistanceTypeChangeListener;
import com.bingce.controlnetwork.surveyor.data.ISurveyorData;
import com.bingce.controlnetwork.surveyor.data.SurveyorData;
import com.bingce.controlnetwork.surveyor.state.ISurveyState;
import com.bingce.controlnetwork.surveyor.state.ISurveyorDataScrollDelegate;
import com.bingce.controlnetwork.surveyor.state.StateConstantsPla;
import com.bingce.controlnetwork.surveyor.state.StateManagerPla;
import com.bingce.controlnetwork.surveyor.state._IsSingleCycleCompletedState;
import com.bingce.controlnetwork.util.StationUtilPla;
import com.bingce.utils.ThreadPoolUtil;
import java.util.ArrayList;
import blankj.utilcode.util.ToastUtils;
/**
* 井定向测量-方位测量
*/
public class StationSurveyorSeparateHorAngleFragment extends BaseFragment
implements IDistanceTypeChangeListener, ISurveyState, IMeasureOperate {
private StationSurveyorSepatateAdapter adapter = null;
private StateManagerPla stateManager;
private RecyclerView recyclerView;
private ICachedData cachedData = null;
private ISurveyorData surveyedData = null;
private ISurveyState surveyState;
private LiveData<SurveyorScheduleRecord> horCycleLiveData;
private int cycleIndex = 0;
private ArrayList<String> cycleList;
private TextView tvCycle;
private View cycleLayout;
private LiveData<SurveyorScheduleRecord> cycleLiveData;
private String stationId() {
if (getArguments() == null) {
return null;
}
return getArguments().getString(KEY_STATION_ID);
}
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater,
@Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
View view = inflater.inflate(
R.layout.fragment_station_surveyor_separate_hor_angle,
container,
false);
String stationId = stationId();
cycleLayout = view.findViewById(R.id.cycleLayout);
tvCycle = view.findViewById(R.id.tvCycle);
recyclerView = view.findViewById(R.id.recyclerView);
//选择测回
cycleLayout.setOnClickListener(v -> selectCycleDialog());
if (stationId != null) {
//收集信息
collectData(stationId,
getContext(),
getChildFragmentManager(),
getViewLifecycleOwner(),
this,
(cycleIndex, pointIndex) -> {
if (pointIndex >= 0 && adapter != null && pointIndex < adapter.getItemCount()) {
recyclerView.scrollToPosition(pointIndex);
}
},
new ICollectCacheCallback() {
@Override
public void onFailure() {
//收集测站测量信息失败,提示
}
@Override
public void onSuccess(boolean showSlopDistance, ICachedData cachedData, SurveyorData surveyorData, StateManagerPla stateManager) {
onCollectStationData(showSlopDistance, cachedData, surveyorData, stateManager);
surveyState = stateManager;
}
}
);
}
return view;
}
@WorkerThread
private void onCollectStationData(
boolean showSlopDistance,
ICachedData cachedData,
SurveyorData surveyorData,
StateManagerPla stateManager) {
this.stateManager = stateManager;
this.cachedData = cachedData;
surveyedData = surveyorData;
//测量数据收集完毕后,就可以更新UI了
runOnUI(() -> {
if (getView() == null) {
return;
}
//刷新UI
if (adapter == null) {
adapter = new StationSurveyorSepatateAdapter(stateManager.getProjectType(), stationId(),
cachedData, stateManager.getTolreanceRecord(), surveyorData, surveyorData, ViewItemType.sepatateHorAngle);
adapter.onShowSlopDistance(showSlopDistance);
if (recyclerView != null) {
recyclerView.setAdapter(adapter);
//滚动到当前目标点
int currentItemIndex = surveyorData.currentIndex();
if (currentItemIndex >= 0 && currentItemIndex < adapter.getItemCount()) {
recyclerView.scrollToPosition(currentItemIndex);
}
}
}
if (getView() != null) {
initCycleObserver(stateManager.getStationRecord());
//监听测站数据
//监听「平距」「斜距」切换,更新UI显示
SurveyorDatabaseFactory
.instance
.getSurveyorStation()
.getLiveDataRecord(stationId())
.observe(getViewLifecycleOwner(),
surveyorStationRecord -> onShowSlopDistance(surveyorStationRecord.isShowSlopDistance()));
}
});
}
/**
* 收集测站信息
*/
private void collectData(
String stationId,
Context context,
FragmentManager fragmentManager,
LifecycleOwner lifecycleOwner,
IUIRunner runner,
ISurveyorDataScrollDelegate scrollDelegate,
ICollectCacheCallback callback) {
if (callback == null) {
return;
}
ThreadPoolUtil.execute(() -> {
//读取当前测站的当前测回--很重要
SurveyorScheduleRecord scheduleRecord =
SurveyorDatabaseFactory
.instance
.getScheduleDataSource()
.findScheduleSync(SurveyorScheduleConstants.stationCurrentCycleKey(stationId, StateConstantsPla.VALUE_MEASURE_WHAT_ANGLE_HOR));
int defaultCycle = scheduleRecord == null ? 0 :
DigitalUtil.string2Int(scheduleRecord.getStatue(), 0);
//加载测站信息
SurveyorStationRecord surveyorStationRecord =
SurveyorDatabaseFactory
.instance
.getSurveyorStation()
.getRecordSync(stationId);
//加载对应项目
ProjectRecord projectRecord = SurveyorDatabaseFactory
.instance
.getProjectDataSource()
.getRecord(surveyorStationRecord.getProjectId());
if (projectRecord == null) {
callback.onFailure();
return;
}
//加载对应限差
ToleranceDetailRecord toleranceRecord = SurveyorDatabaseFactory
.instance
.getToleranceDetailDataSource()
.getRecordSync(projectRecord.getToleranceId());
if (toleranceRecord == null) {
callback.onFailure();
return;
}
int cycleCount = StationUtilPla.getCycleCount(getMeasureWhat(), surveyorStationRecord, toleranceRecord);
cycleList = SurveyorCycleUtil.cycleStrings(cycleCount,
surveyorStationRecord.leftAndRightSurveyor);
//创建缓存数据
CachedData cachedData =
CachedData.newInstance(StateConstantsPla.VALUE_MEASURE_WHAT_ANGLE_HOR, CachedDataPointType.ALL_POINT, surveyorStationRecord.isAutoClose(),
surveyorStationRecord.isLeftAndRightSurveyor(),
stationId, toleranceRecord);
if (cachedData == null) {
callback.onFailure();
return;
}
//是否显示斜距?
cachedData.onShowSlopDistance(surveyorStationRecord.isShowSlopDistance());
if (cachedData.pointCount() <= 0) {
callback.onFailure();
return;
}
//创建stateManager实例
SurveyorData surveyorDataSource = new SurveyorData(toleranceRecord.getSurveyorCount());
surveyorDataSource.onShowSlopDistance(surveyorStationRecord.isShowSlopDistance());
StateManagerPla stateManager = StateManagerPla.newInstance(
StateConstantsPla.VALUE_MEASURE_WHAT_ANGLE_HOR,
surveyorStationRecord,
context,
fragmentManager,
lifecycleOwner,
toleranceRecord,
cachedData,
surveyorDataSource,
surveyorDataSource,
cachedData,
scrollDelegate,
runner);
//fragment创建后立即计算当前cycle的测量状态
runner.runOnUI(() -> stateManager.calScheduleWhenEnterSurveyFragment(defaultCycle));
callback.onSuccess(surveyorStationRecord.isShowSlopDistance(), cachedData, surveyorDataSource, stateManager);
});
}
@Override
public void onPause() {
super.onPause();
}
public interface ICollectCacheCallback {
void onFailure();
void onSuccess(boolean showSlopDistance, ICachedData cachedData, SurveyorData surveyorData, StateManagerPla stateManager);
}
@Override
public void doSurveyor() {
if (stateManager == null) {
return;
}
stateManager.doSurveyor();
}
@Override
public void autoSurvey() {
if (stateManager == null) {
return;
}
stateManager.doAutoSurveyor();
}
@Override
public void switchCycle(int cycleIndex) {
if (stateManager == null) {
return;
}
stateManager.switch2Cycle(cycleIndex);
}
@Override
public void deleteStationAllCycleRecord() {
if (stateManager == null) {
return;
}
stateManager.deleteCurrentStationSurveyorData();
}
@Override
public void deleteStationOneCycleRecord(int cycleIndexNoUse) {
if (stateManager == null) {
return;
}
stateManager.deleteCurrentStationSurveyorData(cycleIndex);
}
@Override
public String stationCheck() {
if (stateManager == null) {
return null;
}
stateManager.stationCheck();
return null;
}
@Override
public void stationAdjust() {
StationUtilPla.checkStationCanAdjust(stationId(), getMeasureWhat(), isCanAdjust -> {
if (!isCanAdjust) {
ToastUtils.showShort("测站未通过检测");
return;
}
if (stateManager != null) {
stateManager.stationAdjust();
}
});
}
@Override
public void goBack() {
if (stateManager == null) {
return;
}
stateManager.moveBack();
}
@Override
public boolean isCurrentCycleComplete() {
if (stateManager == null)
return false;
boolean completed = _IsSingleCycleCompletedState.isSingleCycleCompleted(
stationId(),
stateManager.getCurrentCycle(),
stateManager.getCachedData());
return completed;
}
@Override
public int measureTypePosition() {
return 0;
}
@Override
public int getMeasureWhat() {
return StateConstantsPla.VALUE_MEASURE_WHAT_ANGLE_HOR;
}
@Override
public void onResumeState() {
if (stateManager != null) {
stateManager.resume();
}
}
@Override
public void onPauseState() {
if (stateManager != null) {
stateManager.quite();
}
}
@Override
public void onShowSlopDistance(boolean value) {
if (cachedData != null) {
cachedData.onShowSlopDistance(value);
}
if (surveyedData != null) {
surveyedData.onShowSlopDistance(value);
}
if (adapter != null) {
adapter.onShowSlopDistance(value);
adapter.notifyItemRangeChanged(0, adapter.getItemCount());
}
}
@Override
public boolean isSurveying() {
if (surveyState != null) {
return surveyState.isSurveying();
}
return false;
}
@Override
public boolean isAutoSurveying() {
if (surveyState != null) {
return surveyState.isAutoSurveying();
}
return false;
}
private static final String KEY_STATION_ID = "__station_id";
public static final String TAG = StationSurveyorSeparateHorAngleFragment.class.getName();
public static StationSurveyorSeparateHorAngleFragment newInstance(String stationId) {
StationSurveyorSeparateHorAngleFragment fragment = new StationSurveyorSeparateHorAngleFragment();
Bundle bundle = new Bundle();
bundle.putString(KEY_STATION_ID, stationId);
fragment.setArguments(bundle);
return fragment;
}
private void initCycleObserver(SurveyorStationRecord record) {
if (cycleLiveData != null) {
cycleLiveData.removeObservers(this);
}
cycleLiveData = getScheduleLiveData(getHorCycleKey());
cycleLiveData
.observe(getViewLifecycleOwner(), surveyorScheduleRecord -> refreshCurrentCycleUi(record, surveyorScheduleRecord));
}
private void selectCycleDialog() {
if (cycleList == null || cycleList.isEmpty()) {
return;
}
BottomSheetSelectListFragment.showSelect(
getChildFragmentManager(),
getViewLifecycleOwner(),
cycleIndex,
cycleList,
null,//不再限制测期
(index, string) -> {
switchCycle(index);
});
}
private void refreshCurrentCycleUi(SurveyorStationRecord stationRecord, SurveyorScheduleRecord record) {
//测回发生变化的时候,更新相应ui
int cycleIndex = DigitalUtil.string2Int(record == null ? "0" : record.getStatue(), 0);
//更新测回名称
if (tvCycle != null) {
boolean showLeftOrRight = true;
if (stationRecord != null) {
showLeftOrRight = stationRecord.leftAndRightSurveyor;
}
tvCycle.setText(SurveyorCycleUtil.cycleName(cycleIndex, showLeftOrRight));
}
this.cycleIndex = cycleIndex;
}
protected LiveData<SurveyorScheduleRecord> getScheduleLiveData(String key) {
return SurveyorDatabaseFactory
.instance
.getScheduleDataSource()
.findSchedule(key);
}
private String getHorCycleKey() {
return SurveyorScheduleConstants.stationCurrentCycleKey(stationId(), StateConstantsPla.VALUE_MEASURE_WHAT_ANGLE_HOR);
}
}

@ -0,0 +1,469 @@
package com.bingce.controlnetwork.fragment.stationsurvey.separate;
import android.content.Context;
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 androidx.annotation.WorkerThread;
import androidx.fragment.app.FragmentManager;
import androidx.lifecycle.LifecycleOwner;
import androidx.recyclerview.widget.RecyclerView;
import com.bingce.controlapphelper.datasource.database.SurveyorDatabaseFactory;
import com.bingce.controlapphelper.datasource.database.project.ProjectRecord;
import com.bingce.controlapphelper.datasource.database.surveyorstation.SurveyorStationRecord;
import com.bingce.controlapphelper.datasource.database.tolerance.detail.ToleranceDetailRecord;
import com.bingce.controlapphelper.model.ViewItemType;
import com.bingce.controlapphelper.util.IUIRunner;
import com.bingce.controlnetwork.R;
import com.bingce.controlnetwork.event.SurveyStateEvent;
import com.bingce.controlnetwork.fragment.BottomSheetSelectListFragment;
import com.bingce.controlnetwork.fragment.stationsurvey.IMeasureOperate;
import com.bingce.controlnetwork.fragment.stationsurvey.base.BaseFragmentLazy;
import com.bingce.controlnetwork.surveyor.data.CachedData;
import com.bingce.controlnetwork.surveyor.data.CachedDataPointType;
import com.bingce.controlnetwork.surveyor.data.ICachedData;
import com.bingce.controlnetwork.surveyor.data.IDistanceTypeChangeListener;
import com.bingce.controlnetwork.surveyor.data.ISurveyorData;
import com.bingce.controlnetwork.surveyor.data.SurveyorData;
import com.bingce.controlnetwork.surveyor.state.ISurveyState;
import com.bingce.controlnetwork.surveyor.state.ISurveyorDataScrollDelegate;
import com.bingce.controlnetwork.surveyor.state.StateConstantsPla;
import com.bingce.controlnetwork.surveyor.state.separateVerAngle.StateManagerSeparateVerAngle;
import com.bingce.utils.ThreadPoolUtil;
import java.util.ArrayList;
import com.bingce.controlnetwork.surveyor.state.separateVerAngle.VerAngleCheckTolerance;
import com.bingce.controlnetwork.surveyor.state.separateVerAngle.VerAngleFindIndexUtil;
/**
* 分开观测-垂直角
*/
public class StationSurveyorSeparateVerAngleFragment extends BaseFragmentLazy
implements IDistanceTypeChangeListener, ISurveyState, IMeasureOperate {
private StationSurveyorSepatateAdapter adapter = null;
private StateManagerSeparateVerAngle stateManager;
private RecyclerView recyclerView;
private ICachedData cachedData = null;
private ISurveyorData surveyorData = null;
private ISurveyState surveyState;
private View llPoint;
private TextView tvPoint;
private String stationId() {
if (getArguments() == null) {
return null;
}
return getArguments().getString(KEY_STATION_ID);
}
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater,
@Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
View view = inflater.inflate(
R.layout.fragment_station_surveyor_separate_ver_angle,
container,
false);
recyclerView = view.findViewById(R.id.recyclerView);
llPoint = view.findViewById(R.id.llPoint);
tvPoint = view.findViewById(R.id.tvPoint);
llPoint.setOnClickListener(v -> selectSurveyorPoint());
return view;
}
@Override
protected void onFragmentFirstVisible() {
super.onFragmentFirstVisible();
firstLoadData();
}
private void firstLoadData() {
String stationId = stationId();
if (stationId != null) {
//收集信息
collectData(stationId,
getContext(),
getChildFragmentManager(),
getViewLifecycleOwner(),
this::runOnUI,
(cycleIndex, pointIndex) -> {
if (cycleIndex >= 0 && adapter != null && cycleIndex < adapter.getItemCount()) {
recyclerView.scrollToPosition(cycleIndex);
}
setTvPointText();
},
new ICollectCacheCallback() {
@Override
public void onFailure() {
// TODO: 收集测站测量信息失败,提示
}
@Override
public void onSuccess(boolean showSlopDistance, ICachedData cachedData, SurveyorData surveyorData, StateManagerSeparateVerAngle stateManager) {
onCollectStationData(showSlopDistance, cachedData, surveyorData, stateManager);
surveyState = stateManager;
}
}
);
}
}
@WorkerThread
private void onCollectStationData(
boolean showSlopDistance,
ICachedData cachedData,
SurveyorData surveyorData,
StateManagerSeparateVerAngle stateManager) {
this.stateManager = stateManager;
this.cachedData = cachedData;
this.surveyorData = surveyorData;
//测量数据收集完毕后,就可以更新UI了
runOnUI(() -> {
if (getView() == null) {
return;
}
//刷新UI
if (adapter == null) {
adapter = new StationSurveyorSepatateAdapter(stateManager.getProjectType(), stationId(),
cachedData, stateManager.getTolreanceRecord(), surveyorData, surveyorData, ViewItemType.sepatateVerAngle);
adapter.onShowSlopDistance(showSlopDistance);
if (recyclerView != null) {
recyclerView.setAdapter(adapter);
//滚动到当前目标点
int currentItemIndex = surveyorData.currentCycleIndex();
if (currentItemIndex >= 0 && currentItemIndex < adapter.getItemCount()) {
recyclerView.scrollToPosition(currentItemIndex);
}
}
}
//设置当前点
setTvPointText();
//监听测站数据
//监听「平距」「斜距」切换,更新UI显示
SurveyorDatabaseFactory
.instance
.getSurveyorStation()
.getLiveDataRecord(stationId())
.observe(getViewLifecycleOwner(),
surveyorStationRecord -> onShowSlopDistance(surveyorStationRecord.isShowSlopDistance()));
});
}
private void setTvPointText() {
SurveyorData data = (SurveyorData) surveyorData;
tvPoint.setText(stringPoint(cachedData.pointName(0, data.currentIndex())));
}
/**
* 收集测站信息
*/
private void collectData(
String stationId,
Context context,
FragmentManager fragmentManager,
LifecycleOwner lifecycleOwner,
IUIRunner runner,
ISurveyorDataScrollDelegate scrollDelegate,
ICollectCacheCallback callback) {
if (callback == null) {
return;
}
ThreadPoolUtil.execute(() -> {
//加载测站信息
SurveyorStationRecord surveyorStationRecord =
SurveyorDatabaseFactory
.instance
.getSurveyorStation()
.getRecordSync(stationId);
//加载对应项目
ProjectRecord projectRecord = SurveyorDatabaseFactory
.instance
.getProjectDataSource()
.getRecord(surveyorStationRecord.getProjectId());
if (projectRecord == null) {
callback.onFailure();
return;
}
//加载对应限差
ToleranceDetailRecord toleranceRecord = SurveyorDatabaseFactory
.instance
.getToleranceDetailDataSource()
.getRecordSync(projectRecord.getToleranceId());
if (toleranceRecord == null) {
callback.onFailure();
return;
}
//创建缓存数据
CachedData cachedData =
CachedData.newInstance(StateConstantsPla.VALUE_MEASURE_WHAT_ANGLE_VER, CachedDataPointType.ALONE_MEASURE_VER_ANGLE_POINT, surveyorStationRecord.isAutoClose(),
surveyorStationRecord.isLeftAndRightSurveyor(),
stationId, toleranceRecord);
if (cachedData == null) {
callback.onFailure();
return;
}
//是否显示斜距?
cachedData.onShowSlopDistance(surveyorStationRecord.isShowSlopDistance());
if (cachedData.pointCount() <= 0) {
setViewVisiableByCacheDataCount(false);
callback.onFailure();
return;
}
setViewVisiableByCacheDataCount(true);
// TODO: 2024/8/30 toleranceRecord.getCycleCount()
VerAngleFindIndexUtil.VerFindTarget verFindTarget = VerAngleFindIndexUtil.findFront(stationId, cachedData,
0, toleranceRecord.getCycleCount());
refreshBtnEnable(verFindTarget.getCycleIndex() != -1);
//创建stateManager实例
SurveyorData surveyorDataSource = new SurveyorData(toleranceRecord.getSurveyorCount());
surveyorDataSource.onShowSlopDistance(surveyorStationRecord.isShowSlopDistance());
surveyorDataSource.setCurrentIndex(verFindTarget.getPointIndex());
surveyorDataSource.changeCycleIndex(verFindTarget.getCycleIndex());
surveyorDataSource.setLeftOrRight(verFindTarget.getLeftOrRight());
StateManagerSeparateVerAngle stateManager = StateManagerSeparateVerAngle.newInstance(
StateConstantsPla.VALUE_MEASURE_WHAT_ANGLE_VER,
surveyorStationRecord,
context,
fragmentManager,
lifecycleOwner,
toleranceRecord,
cachedData,
surveyorDataSource,
surveyorDataSource,
cachedData,
scrollDelegate,
runner);
callback.onSuccess(surveyorStationRecord.isShowSlopDistance(), cachedData, surveyorDataSource, stateManager);
});
}
private void setViewVisiableByCacheDataCount(boolean visiable) {
runOnUI(() -> {
llPoint.setVisibility(visiable ? View.VISIBLE : View.GONE);
});
}
/**
* 刷新按钮状态
*
* @param enable
*/
private void refreshBtnEnable(boolean enable) {
if (enable) {
SurveyStateEvent.postIdle();
} else {
SurveyStateEvent.postCompleted();
}
}
@Override
public void onPause() {
super.onPause();
}
public interface ICollectCacheCallback {
void onFailure();
void onSuccess(boolean showSlopDistance, ICachedData cachedData, SurveyorData surveyorData, StateManagerSeparateVerAngle stateManager);
}
@Override
public void doSurveyor() {
if (stateManager == null) {
return;
}
stateManager.doSurveyor();
}
@Override
public void autoSurvey() {
if (stateManager == null) {
return;
}
// stateManager.doAutoSurveyor();
}
@Override
public void switchCycle(int cycleIndex) {
//暂无使用
}
@Override
public void deleteStationAllCycleRecord() {
if (stateManager == null) {
return;
}
stateManager.deletePointAllCycleData();
}
@Override
public void deleteStationOneCycleRecord(int cycleIndex) {
if (stateManager == null) {
return;
}
stateManager.deleteCurrentCycleData();
}
@Override
public String stationCheck() {
//暂无使用
return null;
}
@Override
public void stationAdjust() {
if (stateManager != null) {
stateManager.stationAdjust();
}
}
@Override
public void goBack() {
if (stateManager == null) {
return;
}
stateManager.startRollBack();
}
@Override
public boolean isCurrentCycleComplete() {
String stationId = stationId();
if (stationId == null || stateManager == null) {
return true;
}
return VerAngleCheckTolerance.isAllPointMeasured(stationId, cachedData, stateManager.getCycleCount());
}
@Override
public int measureTypePosition() {
return 0;
}
@Override
public int getMeasureWhat() {
return StateConstantsPla.VALUE_MEASURE_WHAT_ANGLE_VER;
}
@Override
public void onResumeState() {
if (stateManager != null) {
stateManager.resume();
}
}
@Override
public void onPauseState() {
if (stateManager != null) {
stateManager.quite();
}
}
@Override
public void onShowSlopDistance(boolean value) {
if (cachedData != null) {
cachedData.onShowSlopDistance(value);
}
if (surveyorData != null) {
surveyorData.onShowSlopDistance(value);
}
if (adapter != null) {
adapter.onShowSlopDistance(value);
adapter.notifyItemRangeChanged(0, adapter.getItemCount());
}
}
@Override
public boolean isSurveying() {
if (surveyState != null) {
return surveyState.isSurveying();
}
return false;
}
@Override
public boolean isAutoSurveying() {
if (surveyState != null) {
return surveyState.isAutoSurveying();
}
return false;
}
private static final String KEY_STATION_ID = "__station_id";
public static final String TAG = StationSurveyorSeparateVerAngleFragment.class.getName();
public static StationSurveyorSeparateVerAngleFragment newInstance(String stationId) {
StationSurveyorSeparateVerAngleFragment fragment = new StationSurveyorSeparateVerAngleFragment();
Bundle bundle = new Bundle();
bundle.putString(KEY_STATION_ID, stationId);
fragment.setArguments(bundle);
return fragment;
}
private void selectSurveyorPoint() {
if (stateManager == null) {
return;
}
if (surveyorData == null) {
return;
}
if (cachedData == null || cachedData.pointCount() == 0) {
return;
}
int currentCycle = stateManager.getCurrentCycle();
ArrayList<String> showPointList = new ArrayList<>();
for (int i = 0; i < cachedData.realPointCount(); i++) {
showPointList.add(cachedData.pointName(currentCycle, i));
}
BottomSheetSelectListFragment.showSelect(
getChildFragmentManager(),
getViewLifecycleOwner(),
surveyorData.currentIndex(),
showPointList,
null,//不再限制测期
(index, string) -> {
//切换测点
VerAngleFindIndexUtil.VerFindTarget target = VerAngleFindIndexUtil.getTargetByPointIndexFront(stateManager.stationId(), cachedData,
index, stateManager.getTolreanceRecord().cycleCount); // TODO: 2024/8/30 getTolreanceRecord().cycleCount
stateManager.setSurveyorData(target, true);
//刷新ui
setTvPointText();
cachedData.notifyDateChange();
});
}
private String stringPoint(String name) {
return String.format("测点:%s", name);
}
}

@ -0,0 +1,129 @@
package com.bingce.controlnetwork.fragment.stationsurvey.separate;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.bingce.controlapphelper.datasource.database.tolerance.detail.ToleranceDetailRecord;
import com.bingce.controlapphelper.model.IAdapter;
import com.bingce.controlapphelper.model.ViewItemType;
import com.bingce.controlnetwork.surveyor.data.ICachedData;
import com.bingce.controlnetwork.surveyor.data.ICycleRecorder;
import com.bingce.controlnetwork.surveyor.data.IDistanceTypeChangeListener;
import com.bingce.controlnetwork.surveyor.data.ISurveyorData;
import com.bingce.controlnetwork.ui.vh.AbstractSurveyorDataViewHolder;
import com.bingce.controlnetwork.ui.vh.SurveyorDataWellDistanceViewHolder;
import com.bingce.controlnetwork.ui.widget.ViewFactory;
import java.util.Objects;
/**
* 测量记录adapter
* 分开观测 水平角垂直角距离共用
*/
public class StationSurveyorSepatateAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
implements IAdapter, IDistanceTypeChangeListener {
private ICachedData cachedData;
private final ISurveyorData surveyorData;
private final ICycleRecorder cycleRecorder;
private boolean showSlopDistance = true;
private final String projectType;
private final String stationId;
private final ViewItemType layoutType;//区分水平还是距离
private final ToleranceDetailRecord toleranceRecord;//区分水平还是距离
public StationSurveyorSepatateAdapter(
String projectType,
String stationId,
ICachedData cachedData,
ToleranceDetailRecord toleranceRecord,
ICycleRecorder cycleRecorder,
ISurveyorData surveyorData,
ViewItemType layoutType) {
this.projectType = projectType;
this.stationId = stationId;
this.cachedData = cachedData;
this.toleranceRecord = toleranceRecord;
this.surveyorData = surveyorData;
this.cycleRecorder = cycleRecorder;
this.layoutType = layoutType;
//注册数据监听
cachedData.register(this);
}
public void setCachedData(ICachedData cachedData) {
this.cachedData.unregister(this);
this.cachedData = cachedData;
//注册数据监听
cachedData.register(this);
}
@NonNull
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
return Objects.requireNonNull(ViewFactory.generatorViewHolder(parent.getContext(), parent, layoutType));
}
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
if (holder instanceof SurveyorDataWellDistanceViewHolder) {
SurveyorDataWellDistanceViewHolder holderDistance = (SurveyorDataWellDistanceViewHolder) holder;
holderDistance.setup(position,
projectType,
stationId,
showSlopDistance,
cachedData,
cycleRecorder,
surveyorData);
} else if (holder instanceof AbstractSurveyorDataViewHolder) {
AbstractSurveyorDataViewHolder abstractSurveyorDataViewHolder = (AbstractSurveyorDataViewHolder) holder;
abstractSurveyorDataViewHolder.setup(position,
stationId,
showSlopDistance,
cachedData,
cycleRecorder,
surveyorData);
}
holder.itemView.setOnClickListener(v -> {
if (iItemClickListener != null) {
iItemClickListener.click(position);
}
});
}
@Override
public int getItemCount() {
if (layoutType == ViewItemType.aloneDistanceMeasure) {
return cachedData.realPointCount();
} else if (layoutType == ViewItemType.sepatateVerAngle) {
return toleranceRecord.cycleCount;// TODO: 2024/8/30
} else {
return cachedData.pointCount();
}
}
@Override
public void onDataChange() {
notifyDataSetChanged();
}
@Override
public void onShowSlopDistance(boolean value) {
this.showSlopDistance = value;
}
private IItemClickListener iItemClickListener;
public void setOnItemClickListener(IItemClickListener iItemClickListener) {
this.iItemClickListener = iItemClickListener;
}
public interface IItemClickListener {
void click(int position);
}
}

@ -0,0 +1,500 @@
package com.bingce.controlnetwork.fragment.stationsurvey.well;
import android.content.Context;
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 androidx.annotation.WorkerThread;
import androidx.fragment.app.FragmentManager;
import androidx.lifecycle.LifecycleOwner;
import androidx.recyclerview.widget.RecyclerView;
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.schedule.SurveyorScheduleRecord;
import com.bingce.controlapphelper.datasource.database.surveyorstation.SurveyorStationRecord;
import com.bingce.controlapphelper.datasource.database.tolerance.detail.ToleranceDetailRecord;
import com.bingce.controlapphelper.util.DigitalUtil;
import com.bingce.controlapphelper.util.IUIRunner;
import com.bingce.controlapphelper.util.Tools;
import com.bingce.controlnetwork.R;
import com.bingce.controlnetwork.adapter.SurveyorStationRecordsWellAdapter;
import com.bingce.controlnetwork.bean.SurveyorScheduleConstants;
import com.bingce.controlnetwork.fragment.TipsWith2OptionFragment;
import com.bingce.controlnetwork.fragment.stationsurvey.IMeasureOperate;
import com.bingce.controlnetwork.fragment.stationsurvey.base.BaseFragmentLazy;
import com.bingce.controlnetwork.surveyor.data.CachedData;
import com.bingce.controlnetwork.surveyor.data.CachedDataPointType;
import com.bingce.controlnetwork.surveyor.data.ICachedData;
import com.bingce.controlnetwork.surveyor.data.IDistanceTypeChangeListener;
import com.bingce.controlnetwork.surveyor.data.ISurveyorData;
import com.bingce.controlnetwork.surveyor.data.SurveyorData;
import com.bingce.controlnetwork.surveyor.state.ISurveyState;
import com.bingce.controlnetwork.surveyor.state.ISurveyorDataScrollDelegate;
import com.bingce.controlnetwork.surveyor.state.StateConstantsPla;
import com.bingce.controlnetwork.surveyor.state.wellDistance.StateManagerWell;
import com.bingce.controlnetwork.surveyor.state.wellDistance._CheckToleranceState;
import com.bingce.utils.ThreadPoolUtil;
import blankj.utilcode.util.ToastUtils;
import com.bingce.controlnetwork.surveyor.state.wellDistance.IWeatherShowDialogListener;
/**
* 井定向钢丝测距或者单独测距
*/
public class StationSurveyorWellDistanceDataFragment extends BaseFragmentLazy
implements IDistanceTypeChangeListener, ISurveyState, IMeasureOperate {
private SurveyorStationRecordsWellAdapter adapter = null;
private StateManagerWell stateManager; //这里的stateManager是克隆StateManager
private RecyclerView recyclerView;
private ICachedData cachedData = null;
private ISurveyorData surveyedData = null;
private ISurveyState surveyState;
private final IWeatherShowDialogListener weatherShowDialogListener = (stationId, currentCycleIndex, pointId, beforeOrAfter, msg) -> {
if (getView() == null) return;
TipsWith2OptionFragment
.tips(
getChildFragmentManager(),
getViewLifecycleOwner(),
Tools.getString(R.string.confirm),
Tools.getString(R.string.cancel),
msg,
new TipsWith2OptionFragment.SimpleCallback() {
@Override
public void onConfirm() {
// DistanceWeatherSettingTjActivity.launch(requireContext(), stationId, currentCycleIndex, pointId, beforeOrAfter);
}
}
);
};
private String stationId() {
if (getArguments() == null) {
return null;
}
return getArguments().getString(KEY_STATION_ID);
}
private String getWellType() {
if (getArguments() != null) {
return getArguments().getString(KEY_WELL_TYPE);
}
return null;
}
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater,
@Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
View view = inflater.inflate(
R.layout.fragment_project_surveyor_station_point_list_layout,
container,
false);
recyclerView = view.findViewById(R.id.recycler_view);
String stationId = stationId();
if (stationId != null) {
//收集信息
collectData(stationId,
getContext(),
getChildFragmentManager(),
getViewLifecycleOwner(),
this::runOnUI,
this::scrollToPosition,
new ICollectCacheCallback() {
@Override
public void onFailure() {
}
@Override
public void onSuccess(boolean showSlopDistance, ICachedData cachedData, SurveyorData surveyorData, StateManagerWell stateManager) {
onCollectStationData(showSlopDistance, cachedData, surveyorData, stateManager);
surveyState = stateManager;
}
}
);
}
return view;
}
@Override
public boolean getUserVisibleHint() {
return super.getUserVisibleHint();
}
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
}
@WorkerThread
private void onCollectStationData(
boolean showSlopDistance,
ICachedData cachedData,
SurveyorData surveyorData,
StateManagerWell stateManager) {
this.stateManager = stateManager;
this.cachedData = cachedData;
this.surveyedData = surveyorData;
//更新完棱镜类型刷新页面
// stateManager.setRefreshFragmentUiListener(() -> changeCacheDataAndRefreshUi(stationId()));
//测量数据收集完毕后,就可以更新UI了
runOnUI(() -> {
if (getView() == null) {
return;
}
//刷新UI
if (adapter == null) {
adapter = new SurveyorStationRecordsWellAdapter(stateManager.getProjectType(), stationId(),
cachedData, surveyorData, surveyorData, getWellType());
adapter.onShowSlopDistance(showSlopDistance);
if (recyclerView != null) {
recyclerView.setAdapter(adapter);
//滚动到当前目标点
int currentItemIndex = surveyorData.currentIndex();
scrollToPosition(0, currentItemIndex);
}
adapter.setOnItemClickListener(position -> {
if (isSurveying()) {
ToastUtils.showShort("正在测量中,请稍后...");
return;
}
stateManager.setCurrentIndex(position);
stateManager.setCurrentCycleIndex(0);
stateManager.refeshRollBackBtn();
scrollToPosition(0, position);
});
}
//监听测站数据,更新界面「平距」「斜距」显示
SurveyorDatabaseFactory
.instance
.getSurveyorStation()
.getLiveDataRecord(stationId())
.observe(getViewLifecycleOwner(),
surveyorStationRecord -> onShowSlopDistance(surveyorStationRecord.isShowSlopDistance()));
});
}
private void scrollToPosition(int cycleIndex, int position) {
if (position >= 0 && adapter != null && position < adapter.getItemCount()) {
runOnUI(() -> {
recyclerView.scrollToPosition(position);
adapter.notifyDataSetChanged();
});
}
}
/**
* 收集测站信息
*/
private void collectData(
String stationId,
Context context,
FragmentManager fragmentManager,
LifecycleOwner lifecycleOwner,
IUIRunner runner,
ISurveyorDataScrollDelegate scrollDelegate,
ICollectCacheCallback callback) {
if (callback == null) {
return;
}
ThreadPoolUtil.execute(() -> {
//读取当前测站的当前测回--很重要
SurveyorScheduleRecord scheduleRecord =
SurveyorDatabaseFactory
.instance
.getScheduleDataSource()
.findScheduleSync(SurveyorScheduleConstants.stationCurrentCycleKey(stationId, StateConstantsPla.VALUE_MEASURE_WHAT_DISTANCE));
int defaultCycle = scheduleRecord == null ? 0 :
DigitalUtil.string2Int(scheduleRecord.getStatue(), 0);
//加载测站信息
SurveyorStationRecord surveyorStationRecord =
SurveyorDatabaseFactory
.instance
.getSurveyorStation()
.getRecordSync(stationId);
//加载对应项目
ProjectRecord projectRecord = SurveyorDatabaseFactory
.instance
.getProjectDataSource()
.getRecord(surveyorStationRecord.getProjectId());
if (projectRecord == null) {
callback.onFailure();
return;
}
//加载对应限差
ToleranceDetailRecord toleranceRecord = SurveyorDatabaseFactory
.instance
.getToleranceDetailDataSource()
.getRecordSync(projectRecord.getToleranceId());
if (toleranceRecord == null) {
callback.onFailure();
return;
}
//创建缓存数据
CachedDataPointType cachedDataPointType = CachedDataPointType.ALONE_MEASURE_DISTANCE_POINT;
if (isConnection(surveyorStationRecord.projectType)) {
cachedDataPointType = CachedDataPointType.STEEL_POINT;
}
CachedData cachedData = CachedData.newInstance(StateConstantsPla.VALUE_MEASURE_WHAT_DEFAULT, cachedDataPointType, surveyorStationRecord.isAutoClose(),
surveyorStationRecord.isLeftAndRightSurveyor(),
stationId, toleranceRecord);
if (cachedData == null) {
callback.onFailure();
return;
}
//是否显示斜距?
cachedData.onShowSlopDistance(surveyorStationRecord.isShowSlopDistance());
//创建stateManager实例
SurveyorData surveyorDataSource = new SurveyorData(ToleranceDetailRecord.ALONE_DISTANCE_MEASURE_COUNT);
surveyorDataSource.onShowSlopDistance(surveyorStationRecord.isShowSlopDistance());
StateManagerWell stateManager = StateManagerWell.newInstance(
surveyorStationRecord,
context,
fragmentManager,
lifecycleOwner,
toleranceRecord,
cachedData,
surveyorDataSource,
surveyorDataSource,
cachedData,
scrollDelegate,
runner,
weatherShowDialogListener
);
callback.onSuccess(surveyorStationRecord.isShowSlopDistance(), cachedData, surveyorDataSource, stateManager);
});
}
/**
* 改变cacheData并刷新Ui
*/
private void changeCacheDataAndRefreshUi(String stationId) {
ThreadPoolUtil.execute(() -> {
//加载测站信息
SurveyorStationRecord surveyorStationRecord =
SurveyorDatabaseFactory
.instance
.getSurveyorStation()
.getRecordSync(stationId);
//加载对应项目
ProjectRecord projectRecord = SurveyorDatabaseFactory
.instance
.getProjectDataSource()
.getRecord(surveyorStationRecord.getProjectId());
if (projectRecord == null) {
return;
}
//加载对应限差
ToleranceDetailRecord toleranceRecord = SurveyorDatabaseFactory
.instance
.getToleranceDetailDataSource()
.getRecordSync(projectRecord.getToleranceId());
if (toleranceRecord == null) {
return;
}
//创建缓存数据
CachedDataPointType cachedDataPointType = CachedDataPointType.ALONE_MEASURE_DISTANCE_POINT;
if (isConnection(surveyorStationRecord.projectType)) {
cachedDataPointType = CachedDataPointType.STEEL_POINT;
}
CachedData cachedData = CachedData.newInstance(StateConstantsPla.VALUE_MEASURE_WHAT_DEFAULT, cachedDataPointType, surveyorStationRecord.isAutoClose(),
surveyorStationRecord.isLeftAndRightSurveyor(),
stationId, toleranceRecord);
if (cachedData != null) {
//是否显示斜距?
cachedData.onShowSlopDistance(surveyorStationRecord.isShowSlopDistance());
// stateManager.setCachedData(cachedData);
adapter.setCachedData(cachedData);
runOnUI(() -> adapter.notifyDataSetChanged());
}
});
}
public interface ICollectCacheCallback {
void onFailure();
void onSuccess(boolean showSlopDistance, ICachedData cachedData, SurveyorData surveyorData, StateManagerWell stateManager);
}
@Override
public void doSurveyor() {
if (stateManager == null) {
return;
}
stateManager.doSurveyor();
}
@Override
public void autoSurvey() {
}
@Override
public void switchCycle(int cycleIndex) {
if (stateManager == null) {
return;
}
stateManager.switch2Cycle(cycleIndex);
}
@Override
public void deleteStationAllCycleRecord() {
if (stateManager == null) {
return;
}
stateManager.deletePointAllCycleData();
}
@Override
public void deleteStationOneCycleRecord(int cycleIndex) {
if (stateManager == null) {
return;
}
stateManager.deletePointCurrentCycleData();
}
@Override
public String stationCheck() {
if (stateManager == null) {
return null;
}
stateManager.stationCheck();
return null;
}
@Override
public void stationAdjust() {
if (stateManager != null) {
stateManager.stationAdjust();
}
}
@Override
public void goBack() {
if (stateManager == null) {
return;
}
stateManager.moveBack();
}
@Override
public void onShowSlopDistance(boolean value) {
if (cachedData != null) {
cachedData.onShowSlopDistance(value);
}
if (surveyedData != null) {
surveyedData.onShowSlopDistance(value);
}
if (adapter != null) {
adapter.onShowSlopDistance(value);
adapter.notifyItemRangeChanged(0, adapter.getItemCount());
}
}
@Override
public boolean isSurveying() {
if (surveyState != null) {
return surveyState.isSurveying();
}
return false;
}
@Override
public boolean isAutoSurveying() {
if (surveyState != null) {
return surveyState.isAutoSurveying();
}
return false;
}
private static final String KEY_STATION_ID = "__station_id";
private static final String KEY_WELL_TYPE = "__well_type";
public static final String TAG = StationSurveyorWellDistanceDataFragment.class.getName();
public static StationSurveyorWellDistanceDataFragment newInstance(String stationId, String wellType) {
StationSurveyorWellDistanceDataFragment fragment = new StationSurveyorWellDistanceDataFragment();
Bundle bundle = new Bundle();
bundle.putString(KEY_STATION_ID, stationId);
bundle.putString(KEY_WELL_TYPE, wellType);
fragment.setArguments(bundle);
return fragment;
}
@Override
public boolean isCurrentCycleComplete() {
if (stateManager == null)
return false;
return _CheckToleranceState.isCompleteAllPointForAloneDistance(stationId(), 0, stateManager.getCachedData());
}
@Override
public int measureTypePosition() {
return 0;
}
@Override
public int getMeasureWhat() {
return StateConstantsPla.VALUE_MEASURE_WHAT_DISTANCE;
}
@Override
public void onResumeState() {
if (stateManager != null) {
stateManager.resume();
}
}
@Override
public void onPauseState() {
if (stateManager != null) {
stateManager.quite();
}
}
@Override
protected void onFragmentFirstVisible() {
if (stateManager != null)
stateManager.calScheduleWhenEnterSurveyFragment();
}
/**
* 是否联系测量
*
* @param projectType 项目类型
* @return
*/
private boolean isConnection(String projectType) {
return ProjectTypeValue.CONNECTION.equals(projectType);
}
}

@ -0,0 +1,457 @@
package com.bingce.controlnetwork.fragment.stationsurvey.well;
import android.content.Context;
import android.graphics.Color;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.WorkerThread;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;
import androidx.viewpager.widget.ViewPager;
import com.bingce.controlapphelper.datasource.database.SurveyorDatabaseFactory;
import com.bingce.controlapphelper.datasource.database.project.ProjectRecord;
import com.bingce.controlapphelper.datasource.database.surveyorstation.SurveyorStationRecord;
import com.bingce.controlapphelper.datasource.database.tolerance.detail.ToleranceDetailRecord;
import com.bingce.controlapphelper.model.BundleConstants;
import com.bingce.controlapphelper.util.DigitalUtil;
import com.bingce.controlapphelper.util.SurveyorCycleUtil;
import com.bingce.controlnetwork.R;
import com.bingce.controlnetwork.activity.fragmentcontainer.FragmentContainerActivity;
import com.bingce.controlnetwork.adapter.SurveyorStationRecordsWellAdapter;
import com.bingce.controlnetwork.bean.SurveyorScheduleConstants;
import com.bingce.controlnetwork.event.RefreshRollBackEvent;
import com.bingce.controlnetwork.event.SurveyStateEvent;
import com.bingce.controlnetwork.fragment.BottomSheetSelectListFragment;
import com.bingce.controlnetwork.fragment.base.BaseFragment;
import com.bingce.controlnetwork.fragment.stationsurvey.IMeasureOperate;
import com.bingce.controlnetwork.newui.stationsetting.StationSettingsActivity;
import com.bingce.controlnetwork.newui.stationsurveyor.ISurveyorMenuOperate;
import com.bingce.controlnetwork.newui.stationsurveyor.StationSurveyorHomeActivity;
import com.bingce.controlnetwork.surveyor.state.StateConstantsPla;
import com.bingce.controlnetwork.surveyor.surveyor.TestDataSelectFragment;
import com.bingce.controlnetwork.util.StationSettingCheckUtil;
import com.bingce.controlnetwork.util.StationUtilPla;
import com.bingce.utils.ThreadPoolUtil;
import com.flyco.tablayout.SlidingTabLayout;
import com.github.razir.progressbutton.DrawableButtonExtensionsKt;
import com.github.razir.progressbutton.ProgressButtonHolderKt;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import java.util.ArrayList;
import java.util.List;
/**
* 测站测量页面开始测量
*/
public class StationSurveyorWellFragment extends BaseFragment implements ISurveyorMenuOperate {
public static final String TAG = StationSurveyorWellFragment.class.getName();
private MenuItem menuItemRollBack;
private SurveyorStationRecord surveyorStationRecord;
private int cycleIndex = 0;
//方位观测fragment的在adapter的索引
public static final int POSITION_DIRECTION_MEASURE = 0;
public static final int POSITION_DISTANCE_MEASURE = 1;
private final String[] tabs = {
"方位观测", "单独测距"
};
private List<IMeasureOperate> fragments;
private IMeasureOperate currentFragment;
private ViewPager vp;
private final StationSettingCheckUtil stationSettingCheckUtil = new StationSettingCheckUtil();
@Subscribe(threadMode = ThreadMode.MAIN)
public void onRefreshGoBack(RefreshRollBackEvent event) {
if (vp != null) {
int currentItem = vp.getCurrentItem();
if (currentItem == POSITION_DIRECTION_MEASURE) {
setRollBackEnable(event.validate);
} else if (currentItem == POSITION_DISTANCE_MEASURE) {
setRollBackEnable(event.validate);
}
}
}
private void setRollBackEnable(boolean validate) {
FragmentActivity activity = getActivity();
if (activity != null) {
StationSurveyorHomeActivity homeActivity = (StationSurveyorHomeActivity) activity;
homeActivity.setRollBackEnable(validate);
}
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void onSurveyorStateChanged(SurveyStateEvent event) {
if (getView() == null) {
return;
}
Button surveyorButton = getView().findViewById(R.id.surveyor);
if (surveyorButton == null) {
return;
}
if (event.isIdle() || event.isSuccess() || event.isCompleted()) {
DrawableButtonExtensionsKt.hideProgress(surveyorButton, R.string.start_surveyor);
} else if (event.isSurveying()) {
DrawableButtonExtensionsKt.showProgress(surveyorButton, progressParams -> {
progressParams.setButtonTextRes(R.string.tips_surveying);
progressParams.setProgressColor(Color.WHITE);
return null;
});
} else if (event.isFailure()) {
DrawableButtonExtensionsKt.hideProgress(surveyorButton, R.string.tips_surveyor_failure_and_retry);
}
boolean enable = event.isIdle() || event.isFailure() || event.isSuccess();
setSurveyorEnable(getView(), R.id.surveyor, enable);
}
private String stationId() {
if (getArguments() == null) {
return null;
}
return getArguments().getString(BundleConstants.KEY_SURVEYOR_STATION_ID);
}
@Override
public void onStart() {
super.onStart();
EventBus.getDefault().register(this);
}
@Override
public void onStop() {
super.onStop();
EventBus.getDefault().unregister(this);
}
@Override
public void onResume() {
super.onResume();
//测量界面保持常亮
if (getActivity() != null) {
getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}
if (currentFragment != null) {
currentFragment.onResumeState();
}
}
@Override
public void onPause() {
super.onPause();
//清除界面常亮
if (getActivity() != null) {
getActivity().getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}
if (currentFragment != null) {
currentFragment.onPauseState();
}
}
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater,
@Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_project_surveyor_station_detail_layout_well,
container,
false);
//2.设置测量按钮
Button surveyor = view.findViewById(R.id.surveyor);
if (surveyor != null) {
ProgressButtonHolderKt.bindProgressButton(getViewLifecycleOwner(), surveyor);
}
setSurveyorClick(view, R.id.surveyor, this::startSurveyor);
//3.查询测站信息
ThreadPoolUtil.execute(() -> {
surveyorStationRecord = SurveyorDatabaseFactory
.instance
.getSurveyorStation()
.getRecordSync(stationId());
//监听当前测回切换
monitorCurrentCycle(view);
//监听数据变化
ToleranceDetailRecord toleranceRecord = getTolerance(surveyorStationRecord);
if (toleranceRecord == null) {
return;
}
//注册UI监听
View pick = view.findViewById(R.id.cycleLayout);
if (pick == null) {
return;
}
int cycleCount = StationUtilPla.getCycleCount(StateConstantsPla.VALUE_MEASURE_WHAT_DISTANCE, surveyorStationRecord, toleranceRecord);
pick.setOnClickListener(v -> {
//测回的点击事件
ArrayList<String> cycleList = SurveyorCycleUtil.cycleStrings(cycleCount,
surveyorStationRecord != null && surveyorStationRecord.leftAndRightSurveyor);
TextView circleText = view.findViewById(R.id.circle_text);
runOnUI(() -> BottomSheetSelectListFragment.showSelect(
getChildFragmentManager(),
getViewLifecycleOwner(),
cycleIndex,
cycleList,
null,//不再限制测期
(index, string) -> {
if (circleText != null) {
circleText.setText(string);
}
cycleIndex = index;
if (currentFragment != null) {
//检测当前测回是否完成
currentFragment.switchCycle(cycleIndex);
}
}));
});
});
setHasOptionsMenu(true);
return view;
}
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
initViewPager(view);
}
private void initViewPager(View view) {
fragments = new ArrayList<>();
StationSurveyorWellLevelAngleDataFragment fragmentAngle = StationSurveyorWellLevelAngleDataFragment.newInstance(stationId(), SurveyorStationRecordsWellAdapter.TYPE_HORIZONTAL_ANGLE);
fragments.add(fragmentAngle);
StationSurveyorWellDistanceDataFragment fragmentDistance = StationSurveyorWellDistanceDataFragment.newInstance(stationId(), SurveyorStationRecordsWellAdapter.TYPE_DISTANCE);
fragments.add(fragmentDistance);
SlidingTabLayout tabLayout = view.findViewById(R.id.tabLayout);
vp = view.findViewById(R.id.vp);
vp.setAdapter(new MyPagerAdapter(getChildFragmentManager()));
tabLayout.setViewPager(vp);
vp.setCurrentItem(POSITION_DIRECTION_MEASURE);
currentFragment = fragments.get(POSITION_DIRECTION_MEASURE);
vp.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
public void onPageSelected(int position) {
currentFragment = fragments.get(position);
View pick = view.findViewById(R.id.cycleLayout);
//钢丝测距不显示选择测回
pick.setVisibility(position == POSITION_DIRECTION_MEASURE ? View.VISIBLE : View.GONE);
//刷新按钮状态
boolean currentCycleComplete = currentFragment.isCurrentCycleComplete();
if (currentCycleComplete) {
SurveyStateEvent.postCompleted();
} else {
SurveyStateEvent.postIdle();
}
}
@Override
public void onPageScrollStateChanged(int state) {
}
});
}
@WorkerThread
private void monitorCurrentCycle(View view) {
if (getActivity() != null) {
getActivity().runOnUiThread(() -> SurveyorDatabaseFactory
.instance
.getScheduleDataSource()
.findSchedule(getScheduleId())
.observe(getViewLifecycleOwner(), record -> {
TextView circleText = view.findViewById(R.id.circle_text);
//测回发生变化的时候,更新相应ui
int cycleIndex = DigitalUtil.string2Int(record == null ? "0" : record.getStatue(), 0);
//更新测回名称
if (circleText != null) {
boolean showLeftOrRight = true;
if (surveyorStationRecord != null) {
showLeftOrRight = surveyorStationRecord.leftAndRightSurveyor;
}
circleText.setText(SurveyorCycleUtil.cycleName(cycleIndex, showLeftOrRight));
}
StationSurveyorWellFragment.this.cycleIndex = cycleIndex;
}));
}
}
private String getScheduleId() {
int currentItem = vp.getCurrentItem();
String scheduleId;
if (currentItem == POSITION_DIRECTION_MEASURE) {
scheduleId = SurveyorScheduleConstants.stationCurrentCycleKey(stationId(), StateConstantsPla.VALUE_MEASURE_WHAT_DEFAULT);
} else {
scheduleId = SurveyorScheduleConstants.stationCurrentCycleKey(stationId(), StateConstantsPla.VALUE_MEASURE_WHAT_DISTANCE);
}
return scheduleId;
}
private static void setSurveyorClick(View rootView, int id, Runnable runnable) {
View view = rootView.findViewById(id);
if (view != null) {
view.setOnClickListener(v -> runnable.run());
}
}
private static void setSurveyorEnable(View rootView, int id, boolean enable) {
if (rootView == null) {
return;
}
View view = rootView.findViewById(id);
if (view != null) {
view.setEnabled(enable);
if (enable) {
view.setAlpha(1);
} else {
view.setAlpha(.4f);
}
}
}
@WorkerThread
private static ToleranceDetailRecord getTolerance(SurveyorStationRecord surveyorStationRecord) {
if (surveyorStationRecord == null) {
return null;
}
//获取project信息
ProjectRecord projectRecord = SurveyorDatabaseFactory
.instance
.getProjectDataSource()
.getRecord(surveyorStationRecord.getProjectId());
if (projectRecord == null) {
return null;
}
//获取限差数据
return SurveyorDatabaseFactory
.instance
.getToleranceDetailDataSource()
.getRecordSync(projectRecord.getToleranceId());
}
public static void start(Context context, String surveyorStationId, String surveyorStationName) {
Bundle bundle = new Bundle();
bundle.putString(BundleConstants.KEY_SURVEYOR_STATION_ID, surveyorStationId);
FragmentContainerActivity.start(context, TAG, surveyorStationName, bundle);
}
public static Fragment newInstance(Bundle args) {
Fragment fragment = new StationSurveyorWellFragment();
fragment.setArguments(args);
return fragment;
}
@Override
public void deleteCurrentPeriodRecords() {
//删除当前测回记录
if (surveyorStationRecord != null && currentFragment != null) {
//通知fragment
currentFragment.deleteStationOneCycleRecord(cycleIndex);
}
}
@Override
public void deleteAllPeriodRecords() {
//删除所有测回记录
if (surveyorStationRecord != null && currentFragment != null) {
//通知fragment
currentFragment.deleteStationAllCycleRecord();
}
}
@Override
public void test() {
//数据源 debug使用
TestDataSelectFragment.show(getChildFragmentManager());
}
@Override
public void rollBack() {
//回退
currentFragment.goBack();
}
@Override
public void stationSetting() {
//环境、棱镜设置
StationSettingsActivity.start(requireContext(), stationId());
// StationSettingsFragment.start(getContext(), stationId());
}
//SurveyorSettingsFragment 测量设置
@Override
public void adjust() {
//测站平差,平差检测
if (currentFragment != null) {
currentFragment.stationAdjust();
}
}
@Override
public void startSurveyor() {
stationSettingCheckUtil.checkStationSettings(stationId(), this, this, () -> {
if (currentFragment != null) {
currentFragment.doSurveyor();
}
});
}
private class MyPagerAdapter extends FragmentPagerAdapter {
public MyPagerAdapter(FragmentManager fm) {
super(fm);
}
@Override
public int getCount() {
return fragments.size();
}
@Override
public CharSequence getPageTitle(int position) {
return tabs[position];
}
@Override
public Fragment getItem(int position) {
return (Fragment) fragments.get(position);
}
}
}

@ -1,4 +1,4 @@
package com.bingce.controlnetwork.fragment.stationsurvey.angledistance;
package com.bingce.controlnetwork.fragment.stationsurvey.well;
import android.content.Context;
import android.os.Bundle;
@ -11,7 +11,6 @@ import androidx.annotation.Nullable;
import androidx.annotation.WorkerThread;
import androidx.fragment.app.FragmentManager;
import androidx.lifecycle.LifecycleOwner;
import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.RecyclerView;
import com.bingce.controlapphelper.datasource.database.SurveyorDatabaseFactory;
@ -19,48 +18,36 @@ import com.bingce.controlapphelper.datasource.database.project.ProjectRecord;
import com.bingce.controlapphelper.datasource.database.schedule.SurveyorScheduleRecord;
import com.bingce.controlapphelper.datasource.database.surveyorstation.SurveyorStationRecord;
import com.bingce.controlapphelper.datasource.database.tolerance.detail.ToleranceDetailRecord;
import com.bingce.controlapphelper.event.RefreshGoBackButton;
import com.bingce.controlapphelper.surveyor.data.CachedData;
import com.bingce.controlapphelper.surveyor.data.IDistanceTypeChangeListener;
import com.bingce.controlapphelper.surveyor.data.SurveyorData;
import com.bingce.controlapphelper.surveyor.state.ISurveyState;
import com.bingce.controlapphelper.surveyor.surveyor.RequestSurveyorParamAuto;
import com.bingce.controlapphelper.util.DigitalUtil;
import com.bingce.controlapphelper.util.IUIRunner;
import com.bingce.controlnetwork.adapter.MeasureAngleDistanceAdapter;
import com.bingce.controlnetwork.fragment.ComponentStationSurveyorDataListFragment;
import com.bingce.controlnetwork.fragment.StationDataAdjustDialogFragment;
import com.bingce.controlnetwork.fragment.base.BaseFragment;
import com.bingce.controlnetwork.fragment.stationsurvey.IMeasureOperate;
import com.bingce.controlnetwork.surveyor.state.IScrollDelegate;
import com.bingce.controlnetwork.surveyor.state.angledistance.StateManager;
import com.bingce.controlnetwork.surveyor.state.angledistance._IsSingleCycleCompletedState;
import com.bingce.totalstation.TotalStation;
import com.bingce.utils.ThreadPoolUtil;
import org.greenrobot.eventbus.EventBus;
import com.bingce.controlnetwork.R;
import com.bingce.controlnetwork.adapter.MeasureAngleDistanceAdapter;
import com.bingce.controlnetwork.fragment.ComponentStationSurveyorDataListFragment;
import com.bingce.controlnetwork.fragment.StationDataAdjustDialogFragment;
import com.bingce.controlnetwork.adapter.SurveyorStationRecordsWellAdapter;
import com.bingce.controlnetwork.bean.SurveyorScheduleConstants;
import com.bingce.controlnetwork.fragment.base.BaseFragment;
import com.bingce.controlnetwork.fragment.stationsurvey.IMeasureOperate;
import com.bingce.controlnetwork.surveyor.state.IScrollDelegate;
import com.bingce.controlnetwork.surveyor.state.angledistance.StateManager;
import com.bingce.controlnetwork.surveyor.state.angledistance._IsSingleCycleCompletedState;
import com.bingce.controlnetwork.surveyor.data.CachedData;
import com.bingce.controlnetwork.surveyor.data.CachedDataPointType;
import com.bingce.controlnetwork.surveyor.data.ICachedData;
import com.bingce.controlnetwork.surveyor.data.IDistanceTypeChangeListener;
import com.bingce.controlnetwork.surveyor.data.ISurveyorData;
import com.bingce.controlnetwork.surveyor.data.SurveyorData;
import com.bingce.controlnetwork.surveyor.state.ISurveyState;
import com.bingce.controlnetwork.surveyor.state.ISurveyorDataScrollDelegate;
import com.bingce.controlnetwork.surveyor.state.StateConstantsPla;
import com.bingce.controlnetwork.surveyor.state.StateManagerPla;
import com.bingce.controlnetwork.surveyor.state._IsSingleCycleCompletedState;
import com.bingce.controlnetwork.util.StationUtilPla;
import com.bingce.utils.ThreadPoolUtil;
import com.bingce.controlapphelper.datasource.database.schedule.SurveyorScheduleConstants;
import com.bingce.controlapphelper.surveyor.data.ICachedData;
import com.bingce.controlapphelper.surveyor.data.ISurveyorData;
import blankj.utilcode.util.ToastUtils;
/**
* 测角测距
* 井定向测量-方位测量
*/
public class MeasureDefaultFragment extends BaseFragment
public class StationSurveyorWellLevelAngleDataFragment extends BaseFragment
implements IDistanceTypeChangeListener, ISurveyState, IMeasureOperate {
private MeasureAngleDistanceAdapter adapter = null;
private StateManager stateManager;
private SurveyorStationRecordsWellAdapter adapter = null;
private StateManagerPla stateManager;
private RecyclerView recyclerView;
private ICachedData cachedData = null;
private ISurveyorData surveyedData = null;
@ -73,9 +60,9 @@ public class MeasureDefaultFragment extends BaseFragment
return getArguments().getString(KEY_STATION_ID);
}
private String getTypeAngleOrDistance() {
private String getWellType() {
if (getArguments() != null) {
return getArguments().getString(KEY_TYPE_ANGLE_OR_DISTANCE);
return getArguments().getString(KEY_WELL_TYPE);
}
return null;
}
@ -98,7 +85,7 @@ public class MeasureDefaultFragment extends BaseFragment
getChildFragmentManager(),
getViewLifecycleOwner(),
this::runOnUI,
index -> {
(cycleIndex, index) -> {
if (index >= 0 && adapter != null && index < adapter.getItemCount()) {
recyclerView.scrollToPosition(index);
}
@ -106,10 +93,11 @@ public class MeasureDefaultFragment extends BaseFragment
new ICollectCacheCallback() {
@Override
public void onFailure() {
//TODO 收集测站测量信息失败,提示
}
@Override
public void onSuccess(boolean showSlopDistance, ICachedData cachedData, SurveyorData surveyorData, StateManager stateManager) {
public void onSuccess(boolean showSlopDistance, ICachedData cachedData, SurveyorData surveyorData, StateManagerPla stateManager) {
onCollectStationData(showSlopDistance, cachedData, surveyorData, stateManager);
surveyState = stateManager;
}
@ -125,17 +113,21 @@ public class MeasureDefaultFragment extends BaseFragment
boolean showSlopDistance,
ICachedData cachedData,
SurveyorData surveyorData,
StateManager stateManager) {
StateManagerPla stateManager) {
this.stateManager = stateManager;
this.cachedData = cachedData;
surveyedData = surveyorData;
//测量数据收集完毕后,就可以更新UI了
runOnUI(() -> {
if (getView() == null) {
return;
}
//刷新UI
if (adapter == null) {
adapter = new MeasureAngleDistanceAdapter(stationId(),
cachedData, surveyorData, surveyorData, getTypeAngleOrDistance());
adapter = new SurveyorStationRecordsWellAdapter(stateManager.getProjectType(), stationId(),
cachedData, surveyorData, surveyorData, getWellType());
adapter.onShowSlopDistance(showSlopDistance);
if (recyclerView != null) {
recyclerView.setAdapter(adapter);
@ -167,21 +159,20 @@ public class MeasureDefaultFragment extends BaseFragment
FragmentManager fragmentManager,
LifecycleOwner lifecycleOwner,
IUIRunner runner,
IScrollDelegate scrollDelegate,
ISurveyorDataScrollDelegate scrollDelegate,
ICollectCacheCallback callback) {
if (callback == null) {
return;
}
boolean isSupportAutoMode = TotalStation.getInstance().isSupportMotor();
ThreadPoolUtil.execute(() -> {
//读取当前测站的当前测回--很重要
SurveyorScheduleRecord scheduleRecord =
SurveyorDatabaseFactory
.instance
.getScheduleDataSource()
.findScheduleSync(SurveyorScheduleConstants.getCurrentCycleKey(stationId, SurveyorScheduleConstants.SCHEDULE_OR_CYCLE_TYPE_ALONE_DISTANCE));
.findScheduleSync(SurveyorScheduleConstants.stationCurrentCycleKey(stationId, StateConstantsPla.VALUE_MEASURE_WHAT_DEFAULT));
int defaultCycle = scheduleRecord == null ? 0 :
DigitalUtil.valueOfIntString(scheduleRecord.getStatue(), 0);
DigitalUtil.string2Int(scheduleRecord.getStatue(), 0);
//加载测站信息
SurveyorStationRecord surveyorStationRecord =
SurveyorDatabaseFactory
@ -208,7 +199,7 @@ public class MeasureDefaultFragment extends BaseFragment
}
//创建缓存数据
CachedData cachedData =
CachedData.newInstance(surveyorStationRecord.isAutoClose(),
CachedData.newInstance(StateConstantsPla.VALUE_MEASURE_WHAT_DEFAULT, CachedDataPointType.ALL_POINT, surveyorStationRecord.isAutoClose(),
surveyorStationRecord.isLeftAndRightSurveyor(),
stationId, toleranceRecord);
if (cachedData == null) {
@ -216,7 +207,6 @@ public class MeasureDefaultFragment extends BaseFragment
return;
}
//是否显示斜距?
cachedData.onShowSlopDistance(surveyorStationRecord.isShowSlopDistance());
if (cachedData.pointCount() <= 0) {
@ -228,19 +218,14 @@ public class MeasureDefaultFragment extends BaseFragment
SurveyorData surveyorDataSource = new SurveyorData(toleranceRecord.getSurveyorCount());
surveyorDataSource.onShowSlopDistance(surveyorStationRecord.isShowSlopDistance());
//存入cacheData 用于自动测量时使用
MeasureVm measureVm = new ViewModelProvider(requireParentFragment()).get(MeasureVm.class);
RequestSurveyorParamAuto requestSurveyorParamAuto = new RequestSurveyorParamAuto(stationId, cachedData);
measureVm.setRequestSurveyorParamAuto(requestSurveyorParamAuto);
StateManager stateManager = StateManager.newInstance(
isSupportAutoMode,
requestSurveyorParamAuto,
StateManagerPla stateManager = StateManagerPla.newInstance(
StateConstantsPla.VALUE_MEASURE_WHAT_DEFAULT,
surveyorStationRecord,
context,
fragmentManager,
lifecycleOwner,
toleranceRecord,
cachedData,
surveyorDataSource,
surveyorDataSource,
cachedData,
@ -252,26 +237,10 @@ public class MeasureDefaultFragment extends BaseFragment
});
}
@Override
public void onResume() {
super.onResume();
if (stateManager != null) {
stateManager.resume();
}
}
@Override
public void onPause() {
super.onPause();
if (stateManager != null) {
stateManager.quite();
}
}
public interface ICollectCacheCallback {
void onFailure();
void onSuccess(boolean showSlopDistance, ICachedData cachedData, SurveyorData surveyorData, StateManager stateManager);
void onSuccess(boolean showSlopDistance, ICachedData cachedData, SurveyorData surveyorData, StateManagerPla stateManager);
}
@Override
@ -299,7 +268,7 @@ public class MeasureDefaultFragment extends BaseFragment
}
@Override
public void deleteStationAllPeroidRecord() {
public void deleteStationAllCycleRecord() {
if (stateManager == null) {
return;
}
@ -307,7 +276,7 @@ public class MeasureDefaultFragment extends BaseFragment
}
@Override
public void deleteStationOnePeriodRecord(int cycleIndex) {
public void deleteStationOneCycleRecord(int cycleIndex) {
if (stateManager == null) {
return;
}
@ -319,15 +288,21 @@ public class MeasureDefaultFragment extends BaseFragment
if (stateManager == null) {
return null;
}
return stateManager.stationCheckOnly();
stateManager.stationCheck();
return null;
}
@Override
public void stationAdjust() {
if (stateManager == null) {
return;
}
stateManager.stationAdjustOnly(StationDataAdjustDialogFragment.TYPE_ANGLE_DISTANCE);
StationUtilPla.checkStationCanAdjust(stationId(), getMeasureWhat(), isCanAdjust -> {
if (!isCanAdjust) {
ToastUtils.showShort("测站未通过检测");
return;
}
if (stateManager != null) {
stateManager.stationAdjust();
}
});
}
@Override
@ -350,17 +325,27 @@ public class MeasureDefaultFragment extends BaseFragment
}
@Override
public void refreshGoBackBtnEnable() {
if (stateManager == null || stateManager.getCachedData().pointCount() == 0) {
EventBus.getDefault().post(new RefreshGoBackButton(false));
return;
public int measureTypePosition() {
return 0;
}
@Override
public int getMeasureWhat() {
return StateConstantsPla.VALUE_MEASURE_WHAT_DEFAULT;
}
@Override
public void onResumeState() {
if (stateManager != null) {
stateManager.resume();
}
stateManager.refreshGoBackBtnEnable();
}
@Override
public int measureTypePosition() {
return MeasureFragment.POSITION_DIRECTION_MEASURE;
public void onPauseState() {
if (stateManager != null) {
stateManager.quite();
}
}
@Override
@ -394,14 +379,14 @@ public class MeasureDefaultFragment extends BaseFragment
}
private static final String KEY_STATION_ID = "__station_id";
private static final String KEY_TYPE_ANGLE_OR_DISTANCE = "__key_type_angle_or_distance";
public static final String TAG = ComponentStationSurveyorDataListFragment.class.getName();
private static final String KEY_WELL_TYPE = "__well_type";
public static final String TAG = StationSurveyorWellLevelAngleDataFragment.class.getName();
public static MeasureDefaultFragment newInstance(String stationId, String typeAngleOrDistance) {
MeasureDefaultFragment fragment = new MeasureDefaultFragment();
public static StationSurveyorWellLevelAngleDataFragment newInstance(String stationId, String wellType) {
StationSurveyorWellLevelAngleDataFragment fragment = new StationSurveyorWellLevelAngleDataFragment();
Bundle bundle = new Bundle();
bundle.putString(KEY_STATION_ID, stationId);
bundle.putString(KEY_TYPE_ANGLE_OR_DISTANCE, typeAngleOrDistance);
bundle.putString(KEY_WELL_TYPE, wellType);
fragment.setArguments(bundle);
return fragment;
}

@ -6,7 +6,7 @@ import com.bingce.controlapphelper.datasource.database.leveling.LevelingDbFactor
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.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

@ -6,7 +6,7 @@ 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.detaction.LevelFormatUtil
import com.bingce.controlapphelper.model.LevelingMeasureOrder
import com.bingce.controlapphelper.model._N
import com.bingce.controlapphelper.model._S

@ -20,10 +20,10 @@ 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.detaction.ILevelRefreshBtn;
import com.bingce.controlapphelper.detaction.INextStation;
import com.bingce.controlapphelper.detaction.LevelCheckBtnUtil;
import com.bingce.controlapphelper.detaction.LevelReceiveData;
import com.bingce.controlapphelper.model.BundleConstants;
import com.bingce.controlapphelper.surveyor.test.Test;
import com.bingce.controlapphelper.util.Tools;

@ -22,10 +22,10 @@ import com.bingce.controlapphelper.datasource.database.leveling.measure.backfron
import com.bingce.controlapphelper.datasource.database.leveling.measure.station.LevelingMeasureStationRecord;
import com.bingce.controlapphelper.datasource.database.leveling.station.LevelingStationRecord;
import com.bingce.controlapphelper.datasource.database.leveling.stationsetting.LevelingStationSettingRecord;
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.detaction.IDetectionHint;
import com.bingce.controlapphelper.detaction.LevelReceiveData;
import com.bingce.controlapphelper.detaction.LevelSpeakMsg;
import com.bingce.controlapphelper.detaction.surveyorcache.SurveyorCacheData;
import com.bingce.controlapphelper.model.LevelToleranceNotice;
import com.bingce.controlapphelper.model.LevelingMeasureOrderUtil;
import com.bingce.controlapphelper.model.PickPointResult;

@ -13,7 +13,7 @@ import blankj.utilcode.util.ToastUtils
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.detaction.LevelReceiveData
import com.bingce.controlapphelper.model.BundleConstants
import com.bingce.controlapphelper.util.Tools
import com.bingce.controlapphelper.widget.swiperecyclerview.widget.DefaultItemDecoration

@ -16,7 +16,7 @@ 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.detaction.LevelFormatUtil;
import com.bingce.controlapphelper.util.Tools;
import com.bingce.controlnetwork.R;
import com.bingce.controlnetwork.databinding.ItemLevelIDetectionRecordBinding;

@ -16,7 +16,7 @@ import com.bingce.controlapphelper.datasource.database.leveling.idetection.const
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.detaction.LevelFormatUtil
import com.bingce.controlapphelper.util.Tools
import com.bingce.controlnetwork.func.level.idetection.LevelIDetectionCalUtil
import com.bingce.controlnetwork.func.level.idetection.LevelIDetectionSurveyorData

@ -1,6 +1,6 @@
package com.bingce.controlnetwork.func.level.sendreceive
import com.bingce.controlapphelper.leveling.detaction.LevelReceiveData
import com.bingce.controlapphelper.detaction.LevelReceiveData
interface ILevelBackData {
fun receive(data: LevelReceiveData)

@ -1,7 +1,7 @@
package com.bingce.controlnetwork.func.level.sendreceive
import blankj.utilcode.util.ToastUtils
import com.bingce.controlapphelper.leveling.detaction.LevelReceiveData
import com.bingce.controlapphelper.detaction.LevelReceiveData
import com.bingce.controlnetwork.App
abstract class LevelRequest(protected val backDataI: ILevelBackData) {

@ -1,7 +1,7 @@
package com.bingce.controlnetwork.func.level.sendreceive
import blankj.utilcode.util.ToastUtils
import com.bingce.controlapphelper.leveling.detaction.LevelReceiveData
import com.bingce.controlapphelper.detaction.LevelReceiveData
import com.bingce.device.Device
import com.bingce.level.Level
import com.bingce.level.LevelListener

@ -7,7 +7,7 @@ import android.os.Message
import android.util.Log
import blankj.utilcode.util.ToastUtils
import blankj.utilcode.util.Utils
import com.bingce.controlapphelper.leveling.detaction.LevelReceiveData
import com.bingce.controlapphelper.detaction.LevelReceiveData
import com.bingce.controlapphelper.util.GsonUtil
import com.bingce.path.PathManager
import com.bingce.utils.FileUtil

@ -12,7 +12,7 @@ import com.bingce.controlapphelper.datasource.database.leveling.measure.backfron
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.detaction.LevelFormatUtil
import com.bingce.controlapphelper.model.LevelExportLine
import com.bingce.controlapphelper.model.LevelingMeasureOrder
import com.bingce.controlapphelper.model.LevelingMeasureOrderUtil
@ -45,7 +45,7 @@ class LevelExportUtilTj {
private var endPointName = ""
private val printSbLev = StringBuilder()
private var printSbLev = StringBuilder()
/**
* 导出路线文件夹下的数据
@ -54,6 +54,8 @@ class LevelExportUtilTj {
fun doExportRouteData(projectId: String, routeId: String) {
val routeRecord = LevelingDbFactory.instance.levelDataSource.getByIdSync(routeId)
?: throw IllegalArgumentException("routeRecord==null")
// 初始化,防止导出多条路线时,后面的会在前面的基础上继续拼接
printSbLev = StringBuilder()
//路线的基础数据
confirmRouteCommonData(routeRecord)
//收集路线的具体数据
@ -434,7 +436,8 @@ class LevelExportUtilTj {
//结束点高程
appendZ(
lastFinishStation.frontSightPointId,
getFrontPointZ(stationHeightDiffTotal)
getFrontPointZ(stationHeightDiffTotal),
true
)
column1Index++
//end-line
@ -565,12 +568,15 @@ class LevelExportUtilTj {
return SurveyorDatabaseFactory.instance.pointDataSource.findByIdSync(pointId)
}
private fun appendZ(pointId: String, height: Double) {
/**
* @param isShowEndPoint 是否显示最后一个点
*/
private fun appendZ(pointId: String, height: Double, isShowEndPoint: Boolean = false) {
val startPoint = getPoint(pointId)
val z = LevelFormatUtil.formatHeight(height)
val dataSecondLine = LevelExportLine(
LevelExportLine.Column1(column1Index),
LevelExportLine.Column2("KD1", getPointName(startPoint), ""),
LevelExportLine.Column2("KD1", if (isShowEndPoint) endPointName else getPointName(startPoint), ""),
LevelExportLine.ColumnHeight("", ""),
LevelExportLine.ColumnDistance(""),
LevelExportLine.ColumnEnd("Z", "$z m")

@ -190,7 +190,9 @@ class LevelCreateOrEditRouteVm : ViewModel() {
private fun checkCanEdit(projectId: String, routeIdParam: String?): Boolean {
//路线有数据时候不能编辑
val routeId = routeIdParam ?: return true
val routeRecord = SurveyorDatabaseFactory.instance.getRouteDataSource().getByIdSync(routeId)
// val routeRecord = SurveyorDatabaseFactory.instance.getRouteDataSource().getByIdSync(routeId)
// 应该查 ___LEVEL_ROUTE_RECORDS____ 表
val routeRecord = LevelingDbFactory.instance.levelDataSource.getByIdSync(routeId)
if (routeRecord != null) {
val stationList = LevelingDbFactory.instance.getStationDataSource()
.getStationList(projectId, routeRecord.getId(), false)

@ -14,12 +14,12 @@ import com.bingce.controlapphelper.datasource.database.leveling.measure.station.
import com.bingce.controlapphelper.datasource.database.leveling.station.LevelingStationRecord
import com.bingce.controlapphelper.datasource.database.leveling.tolerance.LevelingToleranceDetail
import com.bingce.controlapphelper.datasource.database.point.PointRecord
import com.bingce.controlapphelper.leveling.detaction.DetectionController
import com.bingce.controlapphelper.leveling.detaction.IDetectionHint
import com.bingce.controlapphelper.leveling.detaction.INextStation
import com.bingce.controlapphelper.leveling.detaction.LevelReceiveData
import com.bingce.controlapphelper.leveling.detaction.LevelingProcess
import com.bingce.controlapphelper.leveling.detaction.surveyorcache.SurveyorCacheData
import com.bingce.controlapphelper.detaction.DetectionController
import com.bingce.controlapphelper.detaction.IDetectionHint
import com.bingce.controlapphelper.detaction.INextStation
import com.bingce.controlapphelper.detaction.LevelReceiveData
import com.bingce.controlapphelper.detaction.LevelingProcess
import com.bingce.controlapphelper.detaction.surveyorcache.SurveyorCacheData
import com.bingce.controlapphelper.model.B1
import com.bingce.controlapphelper.model.B2
import com.bingce.controlapphelper.model.F1

@ -9,9 +9,9 @@ import com.bingce.controlapphelper.datasource.database.SurveyorDatabaseFactory
import com.bingce.controlapphelper.datasource.database.leveling.LevelingDbFactory
import com.bingce.controlapphelper.datasource.database.leveling.station.LevelingStationRecord
import com.bingce.controlapphelper.datasource.database.leveling.stationsetting.LevelingStationSettingRecord
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.detaction.ILevelRefreshBtn
import com.bingce.controlapphelper.detaction.INextStation
import com.bingce.controlapphelper.detaction.LevelCheckBtnUtil
import com.bingce.controlapphelper.model.LevelingMeasureOrder
import com.bingce.controlapphelper.model.LevelingStationState
import com.bingce.controlnetwork.func.level.util.LevelDateUtil

@ -0,0 +1,186 @@
package com.bingce.controlnetwork.model;
import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;
import androidx.annotation.Keep;
/**
* 单独测距和单独测垂直角的平差结果他们都是对一个目标的所有测回测完
*/
@Keep
public class AloneAdjustItem implements Parcelable {
private String pointId;
private String pointName;
private double horAngle;
private double verAngle;
private double distance;
private String prismHeight;
private boolean aloneDistance;
private boolean isMeasureDistanceNot;
private boolean isMeasureVerNot;
private String errorMsg;
public AloneAdjustItem(String pointId, String pointName, double horAngle, double verAngle, double distance, String prismHeight, boolean aloneDistance,
boolean isMeasureDistanceNot, boolean isMeasureVerNot, String errorMsg) {
this.pointId = pointId;
this.pointName = pointName;
this.horAngle = horAngle;
this.verAngle = verAngle;
this.distance = distance;
this.prismHeight = prismHeight;
this.aloneDistance = aloneDistance;
this.isMeasureDistanceNot = isMeasureDistanceNot;
this.isMeasureVerNot = isMeasureVerNot;
this.errorMsg = errorMsg;
}
public String getPointId() {
return pointId;
}
public void setPointId(String pointId) {
this.pointId = pointId;
}
public String getPointName() {
return pointName;
}
public void setPointName(String pointName) {
this.pointName = pointName;
}
public double getHorAngle() {
return horAngle;
}
public void setHorAngle(double horAngle) {
this.horAngle = horAngle;
}
public double getVerAngle() {
return verAngle;
}
public void setVerAngle(double verAngle) {
this.verAngle = verAngle;
}
public double getDistance() {
return distance;
}
public void setDistance(double distance) {
this.distance = distance;
}
public String getPrismHeight() {
return prismHeight;
}
public void setPrismHeight(String prismHeight) {
this.prismHeight = prismHeight;
}
public boolean isAloneDistance() {
return aloneDistance;
}
public void setAloneDistance(boolean aloneDistance) {
this.aloneDistance = aloneDistance;
}
public boolean isMeasureDistanceNot() {
return isMeasureDistanceNot;
}
public void setMeasureDistanceNot(boolean measureDistanceNot) {
isMeasureDistanceNot = measureDistanceNot;
}
public boolean isMeasureVerNot() {
return isMeasureVerNot;
}
public void setMeasureVerNot(boolean measureVerNot) {
isMeasureVerNot = measureVerNot;
}
public String getErrorMsg() {
return errorMsg;
}
public void setErrorMsg(String errorMsg) {
this.errorMsg = errorMsg;
}
public String getPrismHeightActual() {
if (TextUtils.isEmpty(prismHeight)) {
return "0";
}
return prismHeight;
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(this.pointId);
dest.writeString(this.pointName);
dest.writeDouble(this.horAngle);
dest.writeDouble(this.verAngle);
dest.writeDouble(this.distance);
dest.writeString(this.prismHeight);
dest.writeByte(this.aloneDistance ? (byte) 1 : (byte) 0);
dest.writeByte(this.isMeasureDistanceNot ? (byte) 1 : (byte) 0);
dest.writeByte(this.isMeasureVerNot ? (byte) 1 : (byte) 0);
dest.writeString(this.errorMsg);
}
public void readFromParcel(Parcel source) {
this.pointId = source.readString();
this.pointName = source.readString();
this.horAngle = source.readDouble();
this.verAngle = source.readDouble();
this.distance = source.readDouble();
this.prismHeight = source.readString();
this.aloneDistance = source.readByte() != 0;
this.isMeasureDistanceNot = source.readByte() != 0;
this.isMeasureVerNot = source.readByte() != 0;
this.errorMsg = source.readString();
}
protected AloneAdjustItem(Parcel in) {
this.pointId = in.readString();
this.pointName = in.readString();
this.horAngle = in.readDouble();
this.verAngle = in.readDouble();
this.distance = in.readDouble();
this.prismHeight = in.readString();
this.aloneDistance = in.readByte() != 0;
this.isMeasureDistanceNot = in.readByte() != 0;
this.isMeasureVerNot = in.readByte() != 0;
this.errorMsg = in.readString();
}
public static final Creator<AloneAdjustItem> CREATOR = new Creator<AloneAdjustItem>() {
@Override
public AloneAdjustItem createFromParcel(Parcel source) {
return new AloneAdjustItem(source);
}
@Override
public AloneAdjustItem[] newArray(int size) {
return new AloneAdjustItem[size];
}
};
}

@ -0,0 +1,18 @@
package com.bingce.controlnetwork.model;
import androidx.annotation.Keep;
@Keep
public class StationCheckErrorItem {
public final String pointName;
public final int cycleIndex1;
public final int cycleIndex2;
public final double difference;
public StationCheckErrorItem(String pointName, int cycleIndex1, int cycleIndex2, double difference) {
this.pointName = pointName;
this.cycleIndex1 = cycleIndex1;
this.cycleIndex2 = cycleIndex2;
this.difference = difference;
}
}

@ -0,0 +1,14 @@
package com.bingce.controlnetwork.model;
import androidx.annotation.Keep;
@Keep
public class StationCheckErrorPoint {
public final String pointId;
public final String pointName;
public StationCheckErrorPoint(String pointId, String pointName) {
this.pointId = pointId;
this.pointName = pointName;
}
}

@ -15,10 +15,10 @@ import com.bingce.controlnetwork.databinding.FragmentListLayoutBinding
import com.bingce.controlnetwork.fragment.TipsWith2OptionFragment
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.newui.adapter.StationListAdapter
import com.bingce.controlnetwork.newui.base.BaseFragmentBinding
import com.bingce.controlnetwork.newui.model.StationListBean
import com.bingce.controlnetwork.newui.stationsurveyor.StationSurveyorHomeActivity
import com.bingce.controlnetwork.util.SurveyorStationUtil
import com.bingce.utils.ThreadPoolUtil
@ -73,9 +73,11 @@ class StationListFragment : BaseFragmentBinding<FragmentListLayoutBinding>() {
private fun clickStationItem(bean: StationListBean) {
//StationSurveyorFragment原始测量页
if (isConnection(bean.projectType)) {
MeasureFragment.start(context, bean.stationId, bean.stationName)
// MeasureFragment.start(context, bean.stationId, bean.stationName)
} else {
StationSurveyorFragment.start(context, bean.stationId, bean.stationName)
StationSurveyorHomeActivity.start(requireContext(), bean.stationId)
// StationSurveyorFragment.start(context, bean.stationId, bean.stationName)
}
}

@ -36,7 +36,9 @@ class StationSettingSettingFragment :
}
override fun initView() {
mBinding.scSeparate.setOnCheckedChangeListener { buttonView, isChecked ->
refreshEveryPointUi(isChecked)
}
}
override fun initData() {
@ -54,18 +56,17 @@ class StationSettingSettingFragment :
}
mBinding.scLeftRight.isChecked = viewModel.getStationLeftRight()
mBinding.scZero.isChecked = viewModel.getStationZero()
mBinding.scSeparate.isChecked = viewModel.getStationSeparateObservation()
//显示斜距还是平距
mBinding.showSlopSwitch.isChecked = viewModel.getShowSlop()
setDisEnableByHasData(mBinding.scLeftRight, mBinding.scZero)
setDisEnableByHasData(mBinding.scLeftRight, mBinding.scZero, mBinding.scSeparate)
isCanSetAloneDistance = viewModel.isCanShowAloneDistance()
refreshEveryPointUi()
refreshEveryPointUi(viewModel.getStationSeparateObservation())
}
}
private fun refreshEveryPointUi() {
private fun refreshEveryPointUi(separateObservation: Boolean) {
mBinding.llPoints.removeAllViews()
for (point in viewModel.settingData.pointList) {
val itemView =
@ -78,23 +79,44 @@ class StationSettingSettingFragment :
val tvPoint = itemView.findViewById<TextView>(R.id.tvPoint)
val scAloneMeasureDistance =
itemView.findViewById<SwitchCompat>(R.id.scAloneMeasureDistance)
val scOpenAtr = itemView.findViewById<SwitchCompat>(R.id.scOpenAtr)
val scMeasureVer = itemView.findViewById<SwitchCompat>(R.id.scMeasureVer)
val scMeasureDistance = itemView.findViewById<SwitchCompat>(R.id.scMeasureDistance)
// val scOpenAtr = itemView.findViewById<SwitchCompat>(R.id.scOpenAtr)
val spinnerPrismType = itemView.findViewById<Spinner>(R.id.spinnerPrismType)
if (isCanSetAloneDistance) {
scAloneMeasureDistance.visibility=View.VISIBLE
}else{
scAloneMeasureDistance.visibility=View.GONE
}
tvPoint.text = viewModel.settingData.getPointName(point.originalPointId)
//单独测距
scAloneMeasureDistance.isChecked = point.isAloneDistance
scAloneMeasureDistance.isChecked = point.isAloneMeasureDistance
scMeasureVer.isChecked = !point.isMeasureVerNot
scMeasureDistance.isChecked = !point.isMeasureDistanceNot
if (separateObservation) {
//分开观测
// 不显示单独测距
scAloneMeasureDistance.visibility = View.GONE
} else {
//合并观测
// 单独测距显示
scAloneMeasureDistance.visibility = View.VISIBLE
//设置垂直角文案
scMeasureVer.text = "垂直角一并观测"
scMeasureDistance.text = "距离一并观测"
}
setDisEnableByHasData(scAloneMeasureDistance)
scAloneMeasureDistance.setOnCheckedChangeListener { buttonView, isChecked ->
if (isChecked) {
//单独测距打开
scMeasureDistance.isChecked = false
scMeasureDistance.isEnabled = false
} else {
scMeasureDistance.isChecked = true
scMeasureDistance.isEnabled = true
}
}
setDisEnableByHasData(scAloneMeasureDistance, scMeasureVer, scMeasureDistance)
setItemSpinnerData(spinnerPrismType, scOpenAtr, point)
setItemSpinnerData(spinnerPrismType, point)
params.topMargin = ScreenUtil.dp2px(requireContext(), 12f)
mBinding.llPoints.addView(itemView, params)
@ -107,7 +129,6 @@ class StationSettingSettingFragment :
private fun setItemSpinnerData(
spinner: Spinner,
scOpenAtr: SwitchCompat,
point: SurveyorPoint
) {
spinner.adapter = ArrayAdapter<String>(
@ -116,25 +137,24 @@ class StationSettingSettingFragment :
viewModel.settingData.getAllPrismNameList()
)
spinner.setSelection(viewModel.settingData.getPointPrismSelection(point.originalPointId))
spinner.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
override fun onItemSelected(
parent: AdapterView<*>?,
view: View?,
position: Int,
id: Long
) {
val prismRecord = viewModel.settingData.getPrismRecord(position)
setItemOpenAtr(scOpenAtr, prismRecord, point)
}
override fun onNothingSelected(parent: AdapterView<*>?) {
}
}
// spinner.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
// override fun onItemSelected(
// parent: AdapterView<*>?,
// view: View?,
// position: Int,
// id: Long
// ) {
// val prismRecord = viewModel.settingData.getPrismRecord(position)
// setItemOpenAtr( prismRecord, point)
// }
//
// override fun onNothingSelected(parent: AdapterView<*>?) {
// }
//
// }
}
private fun setItemOpenAtr(
scOpenAtr: SwitchCompat,
selectPrismRecord: PrismRecord,
point: SurveyorPoint
) {
@ -143,9 +163,9 @@ class StationSettingSettingFragment :
selectPrismRecord.prismTypeLarge
)
val openAtrSurveyorPoint = SurveyorOpenAtrUtil.isOpenAtr(point)
val openAtr = openAtrEnable && openAtrSurveyorPoint
scOpenAtr.isChecked = openAtr
scOpenAtr.isEnabled = openAtrEnable
// val openAtr = openAtrEnable && openAtrSurveyorPoint
// scOpenAtr.isChecked = openAtr
// scOpenAtr.isEnabled = openAtrEnable
}
override fun setDataToStation() {
@ -155,6 +175,8 @@ class StationSettingSettingFragment :
if (mBinding.scZero.visibility == View.VISIBLE) {
viewModel.setStationZeroToStation(mBinding.scZero.isChecked)
}
val separateObservation = mBinding.scSeparate.isChecked
viewModel.setStationSeparateObservation(separateObservation)
//显示斜距还是平距
viewModel.setStationShowSlop(mBinding.showSlopSwitch.isChecked)
@ -163,19 +185,23 @@ class StationSettingSettingFragment :
val itemView = mBinding.llPoints.getChildAt(i)
val scAloneMeasureDistance =
itemView.findViewById<SwitchCompat>(R.id.scAloneMeasureDistance)
val scMeasureVer = itemView.findViewById<SwitchCompat>(R.id.scMeasureVer)
val scMeasureDistance = itemView.findViewById<SwitchCompat>(R.id.scMeasureDistance)
val spinnerPrismType = itemView.findViewById<Spinner>(R.id.spinnerPrismType)
val scOpenAtr = itemView.findViewById<SwitchCompat>(R.id.scOpenAtr)
// val scOpenAtr = itemView.findViewById<SwitchCompat>(R.id.scOpenAtr)
viewModel.setPointSettingToStation(
i,
separateObservation, i,
scAloneMeasureDistance.isChecked,
!scMeasureVer.isChecked,
!scMeasureDistance.isChecked,
spinnerPrismType.selectedItemPosition,
!scOpenAtr.isChecked
// !scOpenAtr.isChecked
)
}
//更新测站的单独测距状态
// viewModel.updateSeparetionToStation()
viewModel.updateSeparetionToStation()
}

@ -125,17 +125,23 @@ class StationSettingVm : ViewModel() {
* 当有一个点是单独测距这个测站就是单独测距
*/
fun setPointSettingToStation(
separateMeasure: Boolean,
pointIndex: Int,
aloneMeasureDistance: Boolean,
measureVerNot: Boolean,
measureDistanceNot: Boolean,
selectionPrismType: Int,
isOpenAtrNot: Boolean
// isOpenAtrNot:Boolean
) {
stationRecord?.let {
settingData.updatePointSettingData(
separateMeasure,
pointIndex,
aloneMeasureDistance,
measureVerNot,
measureDistanceNot,
selectionPrismType,
isOpenAtrNot
// isOpenAtrNot
)
}
}
@ -170,6 +176,9 @@ class StationSettingVm : ViewModel() {
fun getStationSurveyorPointSize() = stationRecord?.items?.size ?: 0
fun getStationSeparateObservation() = stationRecord?.isSeparateObservation ?: false
/**
* 存储数据库
*/
@ -208,21 +217,27 @@ class StationSettingVm : ViewModel() {
return ProjectType.isConnection(stationRecord!!.projectType)
}
// /**
// * 当测点的状态更新完再调用这个方法
// */
// fun updateSeparetionToStation() {
// stationRecord?.let {
// var aloneDistance = false
// for (item in it.items) {
// if (item.isAloneDistance) {
// aloneDistance = true
// break
// }
// }
// it.aloneMeasureDistance = aloneDistance
// }
// }
fun setStationSeparateObservation(isSeparateObservation: Boolean) {
stationRecord?.let {
it.isSeparateObservation = isSeparateObservation
}
}
/**
* 当测点的状态更新完再调用这个方法
*/
fun updateSeparetionToStation() {
stationRecord?.let {
var aloneDistance = false
for (item in it.items) {
if (item.isAloneMeasureDistance) {
aloneDistance = true
break
}
}
it.aloneMeasureDistance = aloneDistance
}
}
}

@ -14,8 +14,10 @@ import com.bingce.controlapphelper.model.BundleConstants
import com.bingce.controlapphelper.util.FastClickUtil
import com.bingce.controlnetwork.R
import com.bingce.controlnetwork.databinding.NewActivityStationSettingBinding
import com.bingce.controlnetwork.event.ReplaceSurveyorFragmentEvent
import com.bingce.controlnetwork.newui.base.BaseBindingActivity
import com.bingce.controlnetwork.util.KeyboardUtil
import org.greenrobot.eventbus.EventBus
class StationSettingsActivity : BaseBindingActivity<NewActivityStationSettingBinding>() {
@ -136,7 +138,7 @@ class StationSettingsActivity : BaseBindingActivity<NewActivityStationSettingBin
}
viewModel.saveToDataBase {
// EventBus.getDefault().post(ReplaceSurveyorFragmentEvent())
EventBus.getDefault().post(ReplaceSurveyorFragmentEvent())
ToastUtils.showShort(R.string.save_success)
}

@ -65,13 +65,25 @@ class StationSettingSettingData {
* 保存时
*/
fun updatePointSettingData(
separateMeasure: Boolean,
pointIndex: Int,
aloneMeasureDistance: Boolean,
measureVerNot: Boolean,
measureDistanceNot: Boolean,
selectionPosPrismType: Int,
isOpenAtrNot: Boolean
// isOpenAtrNot:Boolean
) {
val surveyorPoint = pointList[pointIndex]
surveyorPoint.isAloneDistance = aloneMeasureDistance
if (separateMeasure) {
//分开观测 隐藏了单独测距
surveyorPoint.isAloneMeasureDistance = !measureDistanceNot
surveyorPoint.isMeasureDistanceNot = measureDistanceNot
} else {
//合并观测里有单独测距
surveyorPoint.isAloneMeasureDistance = aloneMeasureDistance
surveyorPoint.isMeasureDistanceNot = measureDistanceNot
}
surveyorPoint.isMeasureVerNot = measureVerNot
//棱镜类型相关
val prismRecord = getPrismRecord(selectionPosPrismType)
surveyorPoint.prismType = prismRecord.prismType
@ -79,7 +91,7 @@ class StationSettingSettingData {
surveyorPoint.prismTypeConstant = prismRecord.prismTypeConstant
surveyorPoint.prismTypeName = prismRecord.prismTypeName
//openAtr
surveyorPoint.isOpenAtrNot = isOpenAtrNot
// surveyorPoint.isOpenAtrNot=isOpenAtrNot
}
fun getPrismRecord(selectionPosPrismType: Int) = prismAllList[selectionPosPrismType]

@ -0,0 +1,16 @@
package com.bingce.controlnetwork.newui.stationsurveyor;
public interface ISurveyorMenuOperate {
void deleteCurrentPeriodRecords();
void deleteAllPeriodRecords();
void test();
void rollBack();
void stationSetting();
void adjust();
void startSurveyor();
}

@ -0,0 +1,162 @@
package com.bingce.controlnetwork.newui.stationsurveyor
import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.text.TextUtils
import android.util.Log
import android.view.KeyEvent
import android.view.Menu
import android.view.MenuItem
import androidx.activity.viewModels
import androidx.lifecycle.lifecycleScope
import com.bingce.controlapphelper.datasource.database.ProjectTypeValue
import com.bingce.controlapphelper.datasource.database.SurveyorDatabaseFactory
import com.bingce.controlapphelper.model.BundleConstants
import com.bingce.controlapphelper.surveyor.test.Test
import com.bingce.controlapphelper.util.StationUtil
import com.bingce.controlnetwork.R
import com.bingce.controlnetwork.databinding.NewActivityStationSurveyorHomeBinding
import com.bingce.controlnetwork.event.ReplaceSurveyorFragmentEvent
import com.bingce.controlnetwork.fragment.stationsurvey.StationSurveyorFragment
import com.bingce.controlnetwork.fragment.stationsurvey.separate.StationSurveyorSeparateFragment
import com.bingce.controlnetwork.fragment.stationsurvey.well.StationSurveyorWellFragment
import com.bingce.controlnetwork.newui.base.BaseBindingActivity
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import org.greenrobot.eventbus.EventBus
import org.greenrobot.eventbus.Subscribe
import org.greenrobot.eventbus.ThreadMode
class StationSurveyorHomeActivity : BaseBindingActivity<NewActivityStationSurveyorHomeBinding>() {
private val viewModel by viewModels<StationSurveyorHomeViewModel>()
private var menuItemRollBack: MenuItem? = null
private var stationId: String? = null
private var menuOperate: ISurveyorMenuOperate? = null
@Subscribe(threadMode = ThreadMode.MAIN)
fun onReplaceSurveyorFragment(event: ReplaceSurveyorFragmentEvent) {
replaceFragment()
}
companion object {
@JvmStatic
fun start(context: Context, stationId: String) {
context.startActivity(Intent(context, StationSurveyorHomeActivity::class.java).apply {
putExtra(BundleConstants.KEY_SURVEYOR_STATION_ID, stationId)
})
}
}
override fun getBinding(): NewActivityStationSurveyorHomeBinding {
return NewActivityStationSurveyorHomeBinding.inflate(layoutInflater)
}
override fun initView() {
EventBus.getDefault().register(this)
stationId = getStationId()
initToolBarTitle()
}
private fun initToolBarTitle() {
lifecycleScope.launch(Dispatchers.IO) {
val stationRecord =
SurveyorDatabaseFactory.instance.surveyorStation.getRecordSync(stationId)
val stationName = StationUtil.getStationName(stationRecord)
withContext(Dispatchers.Main) {
setToolbarTitle(stationName)
}
}
}
override fun onDestroy() {
super.onDestroy()
EventBus.getDefault().unregister(this)
}
override fun initData() {
replaceFragment()
}
override fun onCreateOptionsMenu(menu: Menu): Boolean {
if (Test.DEBUG) {
menuInflater.inflate(R.menu.menu_surveyor_station_record_data_edit_debug_pla, menu)
} else {
menuInflater.inflate(R.menu.menu_surveyor_station_record_data_edit_release_pla, menu)
}
//回退
menuItemRollBack = menu.findItem(R.id.menu_item_go_back)
return super.onCreateOptionsMenu(menu)
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
if (R.id.menu_item_delete_current_records == item.itemId) {
menuOperate?.deleteCurrentPeriodRecords()
} else if (R.id.menu_item_delete_all_records == item.itemId) {
menuOperate?.deleteAllPeriodRecords()
} else if (R.id.menu_item_data_source == item.itemId) {
menuOperate?.test()
} else if (R.id.menu_item_go_back == item.itemId) {
menuOperate?.rollBack()
} else if (R.id.menu_item_station_environment_prism_settings == item.itemId) {
menuOperate?.stationSetting()
} else if (R.id.menu_item_station_adjust == item.itemId) {
menuOperate?.adjust()
}
return super.onOptionsItemSelected(item)
}
private fun getStationId() = intent.getStringExtra(BundleConstants.KEY_SURVEYOR_STATION_ID)
fun setRollBackEnable(enable: Boolean) {
menuItemRollBack?.isEnabled = enable
}
private fun replaceFragment() {
stationId?.let { stationId ->
viewModel.getStation(stationId) {
val bundle = Bundle()
bundle.putString(BundleConstants.KEY_SURVEYOR_STATION_ID, stationId)
val beginTransaction = supportFragmentManager.beginTransaction()
val fragment = if (TextUtils.equals(it.projectType, ProjectTypeValue.CONNECTION)) {
StationSurveyorWellFragment()
} else {
if (it.isSeparateObservation) {
//分开观测
StationSurveyorSeparateFragment()
} else {
if (it.aloneMeasureDistance) {
StationSurveyorWellFragment()
} else {
StationSurveyorFragment()
}
}
}
menuOperate = fragment
fragment.arguments = bundle
beginTransaction.replace(R.id.container, fragment)
beginTransaction.commitAllowingStateLoss()
}
}
}
override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean {
Log.d("hwhw", "StationSurveyorHomeActivity_onKeyDown==keyCode=" + keyCode)
if (keyCode == 131) {
menuOperate?.startSurveyor()
}
return super.onKeyDown(keyCode, event)
}
}

@ -0,0 +1,28 @@
package com.bingce.controlnetwork.newui.stationsurveyor
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import blankj.utilcode.util.ToastUtils
import com.bingce.controlapphelper.datasource.database.SurveyorDatabaseFactory
import com.bingce.controlapphelper.datasource.database.surveyorstation.SurveyorStationRecord
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
class StationSurveyorHomeViewModel : ViewModel() {
fun getStation(stationId: String, callBack: (SurveyorStationRecord) -> Unit) {
viewModelScope.launch(Dispatchers.IO) {
val stationRecord =
SurveyorDatabaseFactory.instance.surveyorStation.getRecordSync(stationId)
if (stationRecord == null || stationRecord.items.isNullOrEmpty()) {
ToastUtils.showLong("测站数据异常")
return@launch
}
withContext(Dispatchers.Main) {
callBack(stationRecord)
}
}
}
}

@ -0,0 +1,8 @@
package com.bingce.controlnetwork.surveyor.data;
public enum CachedDataPointType {
ALL_POINT,
STEEL_POINT,
ALONE_MEASURE_DISTANCE_POINT,
ALONE_MEASURE_VER_ANGLE_POINT
}

@ -0,0 +1,16 @@
package com.bingce.controlnetwork.surveyor.data;
/**
* 容错常量
*/
public class FaultTolerantData {
/**
* 井定向写死的垂直和距离错误的值
*/
public static final double WELL_ERROR_VER_ANGLE = Math.PI * 3;//写成这个数为了后面计算出负数就不显示了
public static final double ERROR_DISTANCE = -1;
public static final double ERROR_HOR_ANGLE = -1;//弧度
public static final double ERROR_VER_ANGLE = Double.MIN_VALUE;//弧度
}

@ -0,0 +1,155 @@
package com.bingce.controlnetwork.surveyor.data;
import com.bingce.controlapphelper.datasource.database.alonedistance.AloneDistanceRecord;
import com.bingce.controlapphelper.datasource.database.sdangle.SdAngleRecord;
import com.bingce.controlapphelper.datasource.database.surveyorrecord.SurveyorRecord;
import com.bingce.controlapphelper.datasource.database.surveyorstation.model.SurveyorPoint;
import com.bingce.controlapphelper.model.DataCategory;
import com.bingce.controlapphelper.model.IAdapter;
import com.bingce.controlapphelper.model.LeftOrRight;
import java.util.List;
public interface ICachedData extends IDistanceTypeChangeListener {
//点个数 改变过
int pointCount();
//实际的点的个数
int realPointCount();
//点名
String pointName(int cycleIndex, int itemIndex);
//id
String pointId(int cycleIndex, int itemIndex);
String realPointId(int cycleIndex, int itemIndex);
boolean isClosePoint(int cycleIndex, int itemIndex);
int getSurveyorCount();
SurveyorPoint getSurveyorPoint(int cycleIndex, int itemIndex);
/**
* 新加 判断这个点是否是井定向钢丝点
*
* @param cycleIndex
* @param itemIndex
* @return
*/
boolean isWellSteelPoint(int cycleIndex, int itemIndex);
boolean isAloneMeasureDistancePoint(int cycleIndex, int itemIndex);//是否是单独测距点
boolean isMeasureVerNot(int cycleIndex, int itemIndex);//是否观测垂直角
boolean isMeasureDistanceNot(int cycleIndex, int itemIndex);//是否观测距离
boolean isAbandonPoint(int cycleIndex, int itemIndex);
void setPointAbandon(int cycleIndex, int itemIndex);
//数据状态
DataCategory valueState(String recordId);
DataCategory valueState(String recordId, int surveyorIndex);
//获取相应点的测量值
double angleHor1(String recordId);
double angleHor2(String recordId);
double angleHor(String recordId);
double angleVer1(String recordId);
double angleVer2(String recordId);
double angleVer(String recordId);
double distance1(String recordId);
double distance2(String recordId);
double distance(String recordId);
double distanceSlop(String recordId);
//棱镜
String getPrismHeight(int cycleIndex, int itemIndex);
String getPrismName(int cycleIndex, int itemIndex);
String getPrismTypeName(int cycleIndex, int itemIndex);
//注册数据监听
void register(IAdapter adapter);
void unregister(IAdapter adapter);
void notifyDateChange();
//删除站的所有测回数据
void deleteSurveyorRecord(String stationId);
void deleteSurveyorRecord(String stationId, int cycleIndex);
void deleteSurveyorRecord(String stationId, int cycleIndex, int itemIndex, LeftOrRight leftOrRight);
/**
* 回退节点或者单测回
*/
boolean deleteWellDistancePointRecordOneCycle(String stationId, int pointIndex);
boolean deleteWellDistanceStationRecord(String stationId, int pointIndex);
//设置补测标识
void markReSurveyor(String stationId, int cycleIndex, List<String> pointIds);
/**
* 是否完成测量--确保所有数据都正确(dirty resurveyed 返回false)
* 只检测缓存数据不考虑当前测量数据
*
* @param cycleIndex 要检测的测回
* @return true该测回完成测量
*/
boolean isSingleCycleAllDataValidate(int cycleIndex);
boolean isSingleCycleAllDataValidateWell(int cycleIndex);
//缓存当前测量数据,并将最新数据存储到数据库中
void cache(int measureWhat, int cycleIndex, ISurveyorData surveyorDataSource, CallBackCache cache);
AloneDistanceRecord cacheWellDistance(int cycleIndex, int itemIndex, double slopDistance, double horDistance);
SurveyorRecord getSurveyorRecord(String key);
void updateCache(SurveyorRecord record);
void updateCache(SdAngleRecord record);
/**
* 新加
*
* @param key
* @return
*/
AloneDistanceRecord getWellRecord(String key);
void updateSurveyPointParams(SurveyorPoint item);
void saveLeanRecord(int measureWhat, String pointId, ISurveyorData surveyorData, CallBackCache callBackCache);
boolean isHasData(int cycleIndex, int itemIndex, LeftOrRight leftOrRight);
boolean isShowSlopDistance();
interface CallBackCache {
void success();
void failure();
}
}

@ -0,0 +1,8 @@
package com.bingce.controlnetwork.surveyor.data;
public interface ICycleRecorder {
//测回
int currentCycleIndex();
void changeCycleIndex(int cycleIndex);
}

@ -0,0 +1,8 @@
package com.bingce.controlnetwork.surveyor.data;
public interface IDistanceTypeChangeListener {
/**
* @param value true显示斜距false显示平距
*/
void onShowSlopDistance(boolean value);
}

@ -0,0 +1,8 @@
package com.bingce.controlnetwork.surveyor.data;
import com.bingce.controlapphelper.datasource.database.point.PointRecord;
public interface IStationPointRecordCollect {
PointRecord pointRecord(int cycleIndex, int itemIndex);
}

@ -0,0 +1,83 @@
package com.bingce.controlnetwork.surveyor.data;
import com.bingce.controlapphelper.model.DataCategory;
import com.bingce.controlapphelper.model.LeftOrRight;
/*
* 测量数据接口
*
* 不仅记录当前测量数据还记录当前测量进度---测期目标点盘左or盘右
* */
public interface ISurveyorData extends IDistanceTypeChangeListener {
double getAngleHor1();
double getAngleVer1();
double getDistance1();
double getSlopDistance1();
double getHorDistance1();
double getAngleHor2();
double getAngleVer2();
double getDistance2();
double getSlopDistance2();
double getHorDistance2();
double getAngleHor();
double getAngleVer();
double getDistance();
double getSlopDistance();
double getHorDistance();
boolean onSurveyor(double angleHor, double angleVer, double slopDistance, double horDistance);
void clearSurveyStateAndPosition();
void clearSurveyState();
boolean hasSurveyor1();
boolean hasSurveyor2();
void restoreSurveyor1();
/**
* 是否测量完成
*
* @return true;已经可以存储
*/
boolean ready2Record();
int surveyorCount();
//当前测点的索引
int currentIndex();
void setCurrentIndex(int index);
//设置当前正在测量的stationItem是测量盘左or盘右
LeftOrRight leftOrRight();
void setLeftOrRight(LeftOrRight surveyorState);
//数据类型
DataCategory dataCategory();
void setDataCategory(DataCategory category);
//当前测点的索引
int getMeasureTimes();
void setMeasureTimes(int times);
}

@ -0,0 +1,39 @@
package com.bingce.controlnetwork.surveyor.data;
import java.util.HashSet;
import java.util.Set;
public class SpeakCache {
private static SpeakCache instance;
private final Set<Integer> cacheSet = new HashSet<>();
//刚切换测回已经播放的时候
private static final int VALUE_SPEAK_SWITCH_CYCLE = 1;
private SpeakCache() {
}
public static SpeakCache getInstance() {
if (instance == null) {
instance = new SpeakCache();
}
return instance;
}
public void saveSpeakSwitchCycle() {
cacheSet.add(VALUE_SPEAK_SWITCH_CYCLE);
}
public void removeSpeakSwitchCycle() {
cacheSet.remove(VALUE_SPEAK_SWITCH_CYCLE);
}
public boolean isSpeakSwitchCycle() {
return cacheSet.contains(VALUE_SPEAK_SWITCH_CYCLE);
}
}

@ -0,0 +1,245 @@
package com.bingce.controlnetwork.surveyor.data;
import com.bingce.controlapphelper.model.DataCategory;
import com.bingce.controlapphelper.model.LeftOrRight;
import com.bingce.controlnetwork.surveyor.method.DeviationValueOfRadianMethod;
public class SurveyorData implements ISurveyorData, ICycleRecorder {
//测量进度index
private static final int INDEX_NEVER_SURVEYOR = -1;//没有执行过测量
private static final int INDEX_1_SURVEYOR = 0;//第一次测量完成
private static final int INDEX_2_SURVEYOR = 1;//第二次测量完成
//测量进度
private LeftOrRight surveyorState;//当前测量盘左or盘右
private int currentItemIndex;//当前测点索引
//测回
private int currentCycleIndex;//当前测期的索引
//数据类型
private DataCategory dataCategory = DataCategory.emptyCategory();
private final int surveyorCount;//每个测点测量的次数
//当前测点的测量进度
private int currentItemSurveyorSchedule = INDEX_NEVER_SURVEYOR;//-1.都没测量;0.第一次测量完成 1.第二次测量完成
//第一次测量数据
private double currentAngleHor1 = 0;
private double currentAngleVer1 = 0;
private double currentSlopDistance1 = 0;
private double currentHorDistance1 = 0;
//第二次测量数据
private double currentAngleHor2 = 0;
private double currentAngleVer2 = 0;
private double currentSlopDistance2 = 0;
private double currentHorDistance2 = 0;
private boolean showSlopDistance = true;
private int measureTimes = 0;
public SurveyorData(int surveyorCount) {
this.surveyorCount = surveyorCount;
clearSurveyStateAndPosition();
}
@Override
public void onShowSlopDistance(boolean value) {
showSlopDistance = value;
}
public double getAngleHor1() {
return currentAngleHor1;
}
public double getAngleVer1() {
return currentAngleVer1;
}
public double getDistance1() {
return showSlopDistance ? currentSlopDistance1 : currentHorDistance1;
}
@Override
public double getSlopDistance1() {
return currentSlopDistance1;
}
@Override
public double getHorDistance1() {
return currentHorDistance1;
}
public double getAngleHor2() {
return currentAngleHor2;
}
public double getAngleVer2() {
return currentAngleVer2;
}
public double getDistance2() {
return showSlopDistance ? currentSlopDistance2 : currentHorDistance2;
}
public double getAngleHor() {
if (surveyorCount == 1) {
return getAngleHor1();
}
return DeviationValueOfRadianMethod.similarAverage(getAngleHor1(), getAngleHor2());
}
public double getAngleVer() {
if (surveyorCount == 1) {
return getAngleVer1();
}
return DeviationValueOfRadianMethod.similarAverage(getAngleVer1(), getAngleVer2());
}
public double getDistance() {
if (surveyorCount == 1) {
return getDistance1();
}
return (getDistance1() + getDistance2()) / 2f;
}
public double getSlopDistance() {
if (surveyorCount == 1) {
return getSlopDistance1();
}
return (getSlopDistance1() + getSlopDistance2()) / 2f;
}
@Override
public double getHorDistance() {
if (surveyorCount == 1) {
return getHorDistance1();
}
return (getHorDistance1() + getHorDistance2()) / 2f;
}
@Override
public double getSlopDistance2() {
return currentSlopDistance2;
}
@Override
public double getHorDistance2() {
return currentHorDistance2;
}
public boolean onSurveyor(double angleHor, double angleVer, double slopDistance, double horDistance) {
boolean result = false;
if (INDEX_NEVER_SURVEYOR == currentItemSurveyorSchedule || surveyorCount == 1) {
currentAngleHor1 = angleHor;
currentAngleVer1 = angleVer;
currentSlopDistance1 = slopDistance;
currentHorDistance1 = horDistance;
currentItemSurveyorSchedule = INDEX_1_SURVEYOR;
result = surveyorCount == 1;
} else if (INDEX_1_SURVEYOR == currentItemSurveyorSchedule || surveyorCount == 2) {
//第一次测量完成
measureTimes = 1;
currentAngleHor2 = angleHor;
currentAngleVer2 = angleVer;
currentSlopDistance2 = slopDistance;
currentHorDistance2 = horDistance;
currentItemSurveyorSchedule = INDEX_2_SURVEYOR;
result = surveyorCount == 2;
}
return result;
}
public void clearSurveyStateAndPosition() {
clearSurveyState();
currentItemIndex = -1;
surveyorState = LeftOrRight.left;
}
@Override
public void clearSurveyState() {
currentItemSurveyorSchedule = INDEX_NEVER_SURVEYOR;
dataCategory = DataCategory.emptyCategory();
}
public boolean hasSurveyor1() {
return INDEX_1_SURVEYOR == currentItemSurveyorSchedule || INDEX_2_SURVEYOR == currentItemSurveyorSchedule;
}
public boolean hasSurveyor2() {
return INDEX_2_SURVEYOR == currentItemSurveyorSchedule;
}
public void restoreSurveyor1() {
currentItemSurveyorSchedule = INDEX_1_SURVEYOR;
}
@Override
public boolean ready2Record() {
if (surveyorCount == 1) {
return INDEX_1_SURVEYOR == currentItemSurveyorSchedule;
} else if (surveyorCount == 2) {
return INDEX_2_SURVEYOR == currentItemSurveyorSchedule;
}
return false;
}
@Override
public int surveyorCount() {
return surveyorCount;
}
@Override
public int currentIndex() {
return currentItemIndex;
}
@Override
public void setCurrentIndex(int currentItemIndex) {
this.currentItemIndex = currentItemIndex;
}
@Override
public LeftOrRight leftOrRight() {
return surveyorState;
}
@Override
public void setLeftOrRight(LeftOrRight surveyorState) {
this.surveyorState = surveyorState;
}
@Override
public int currentCycleIndex() {
return currentCycleIndex;
}
@Override
public void changeCycleIndex(int cycleIndex) {
this.currentCycleIndex = cycleIndex;
}
@Override
public DataCategory dataCategory() {
return dataCategory;
}
@Override
public void setDataCategory(DataCategory dataCategory) {
this.dataCategory = dataCategory;
}
@Override
public int getMeasureTimes() {
return measureTimes;
}
@Override
public void setMeasureTimes(int times) {
measureTimes = times;
}
}

@ -0,0 +1,276 @@
package com.bingce.controlnetwork.surveyor.method;
import com.bingce.controlapphelper.datasource.database.SurveyorDatabaseFactory;
import com.bingce.controlapphelper.datasource.database.learn.LearnBaseDataRecord;
import com.bingce.controlapphelper.datasource.database.point.PointRecord;
import com.bingce.controlapphelper.datasource.database.surveyorstation.model.SurveyorPoint;
import com.bingce.controlapphelper.model.DataCategory;
import com.bingce.controlapphelper.model.LeftOrRight;
import com.bingce.controlnetwork.App;
import com.bingce.controlnetwork.surveyor.data.ICachedData;
import com.bingce.controlnetwork.surveyor.data.IStationPointRecordCollect;
import com.bingce.controlnetwork.surveyor.data.ISurveyorData;
import com.bingce.controlnetwork.util.IdUtil;
import com.bingce.coordlib.model.Coordinate;
import com.bingce.totalstation.ControlSurveyData;
import com.bingce.totalstation.ControlSurveyResult;
import com.bingce.totalstation.util.TsUtil;
import com.bingce.utils.ThreadPoolUtil;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import blankj.utilcode.util.Utils;
import rxhttp.wrapper.annotations.NonNull;
public class AutoSurveyorMethod {
public static ControlSurveyResult checkAutoSurveyorInSingleCycle(
boolean autoClosed, String stationId, double instrumentHeight,
Coordinate stationBasePoint, int cycleIndex, int cycleCount, IPrismDelegate prismDelegate,
ICachedData cachedData, IStationPointRecordCollect pointRecordCollect) {
List<ControlSurveyData> controlSurveyData = collectSurveyData(autoClosed, stationId, cycleIndex, cycleCount,
prismDelegate, cachedData, pointRecordCollect);
return TsUtil.calcMotorStation(
stationBasePoint,
instrumentHeight,
controlSurveyData,
((App) Utils.getApp()).isCompletedLearn);
}
public static List<ControlSurveyData> collectSurveyData(
boolean autoClosed, String stationId, int cycleIndex, int cycleCount,
IPrismDelegate prismDelegate,
ICachedData cachedData,
IStationPointRecordCollect pointRecordCollect) {
return collectSurveyData(autoClosed, stationId, cycleIndex, cycleCount, prismDelegate, cachedData, null, pointRecordCollect);
}
public static List<ControlSurveyData> collectSurveyData(
boolean autoClosed, String stationId, int currentCycleIndex, int cycleCount,
IPrismDelegate prismDelegate,
ICachedData cachedData,
ISurveyorData surveyorData,
IStationPointRecordCollect pointRecordCollect) {
int originPointCount = cachedData.pointCount();
if (autoClosed) {
originPointCount--;
}
List<ControlSurveyData> controlSurveyDataList = new ArrayList<>();
for (int index = 0; index < originPointCount; index++) {
//先获取当前测回
ControlSurveyData controlSurveyData = getControlSurveyData(cachedData, surveyorData,
pointRecordCollect, prismDelegate, stationId, currentCycleIndex, index);
if (controlSurveyData != null && !controlSurveyData.isMeasured() && cycleCount > 1) {
for (int cycleIndex = 0; cycleIndex < cycleCount; cycleIndex++) {
if (currentCycleIndex == cycleIndex) {
continue;
}
if (cycleIndex % 2 == 1) {
//排除偶测回
continue;
}
controlSurveyData = getControlSurveyData(cachedData, surveyorData,
pointRecordCollect, prismDelegate, stationId, cycleIndex, index);
if (controlSurveyData != null && controlSurveyData.isMeasured()) {
break;
}
}
}
if (controlSurveyData != null) {
controlSurveyDataList.add(controlSurveyData);
}
}
return controlSurveyDataList;
}
public interface IPrismDelegate {
double prismOf(String originPointId);
}
private static ControlSurveyData getControlSurveyData(ICachedData cachedData, ISurveyorData surveyorData,
IStationPointRecordCollect pointRecordCollect,
IPrismDelegate prismDelegate, String stationId,
int cycleIndex, int index) {
PointRecord pointRecord = pointRecordCollect.pointRecord(cycleIndex, index);
if (pointRecord == null) {
return null;
}
if (cachedData.isAbandonPoint(cycleIndex, index)) {
return null;
}
String originPointId = pointRecord.getId();
String recordId = IdUtil.surveyorRecordKey(stationId, cycleIndex, originPointId, LeftOrRight.left);
DataCategory dataCategory = cachedData.valueState(recordId);
boolean measured = dataCategory == DataCategory.dirtyAndSurveyed || dataCategory == DataCategory.normalCategory();
if (!measured && surveyorData != null) {//如果cached中没有数据,检测surveyData
if (index == surveyorData.currentIndex()) {
if (surveyorData.ready2Record()) {
measured = true;
}
}
}
Coordinate target = null;
if (PointRecord.TYPE_KNOWN_POINT.equals(pointRecord.getPointType())) {
target = new Coordinate(pointRecord.getX(), pointRecord.getY(), pointRecord.getZ());
}
double hAngle = 0;
double vAngle = 0;
double distanceSlop = 0;
if (measured) {
if (surveyorData != null && surveyorData.currentIndex() == index) {
hAngle = surveyorData.getAngleHor();
vAngle = surveyorData.getAngleVer();
distanceSlop = surveyorData.getSlopDistance();
} else {
hAngle = cachedData.angleHor(recordId);
vAngle = cachedData.angleVer(recordId);
distanceSlop = cachedData.distanceSlop(recordId);
}
}
double prismHeight = prismDelegate.prismOf(originPointId);
return new ControlSurveyData(
measured, originPointId, target,
hAngle, vAngle, distanceSlop, prismHeight);
}
public static void getWaitLearnDataList(int measureWhat, String stationId, ICachedData cachedData, IStationPointRecordCollect pointRecordCollect
, CallBackWaiteLearnData callBackWaiteLearnData) {
ThreadPoolUtil.execute(() -> {
List<ControlSurveyData> waitLeanDataList = new ArrayList<>();
for (int pointIndex = 0; pointIndex < cachedData.realPointCount(); pointIndex++) {
if (cachedData.isAbandonPoint(0, pointIndex)) {
continue;
}
//测点坐标
Coordinate target = null;
PointRecord pointRecord = pointRecordCollect.pointRecord(0, pointIndex);
if (pointRecord != null && PointRecord.TYPE_KNOWN_POINT.equals(pointRecord.getPointType())) {
target = new Coordinate(pointRecord.getX(), pointRecord.getY(), pointRecord.getZ());
}
SurveyorPoint surveyorPoint = cachedData.getSurveyorPoint(0, pointIndex);
LearnBaseDataRecord learnBaseDataRecord = SurveyorDatabaseFactory.instance.getLearnDataSource().queryByStationPointId(stationId, surveyorPoint.getOriginalPointId());
boolean measured = false;
double hAngle = 0, vAngle = 0, distanceSlop = 0;
if (learnBaseDataRecord != null) {
measured = true;
hAngle = learnBaseDataRecord.angleHor;
vAngle = learnBaseDataRecord.angleVer;
distanceSlop = learnBaseDataRecord.distanceSlop;
}
waitLeanDataList.add(new ControlSurveyData(
measured, surveyorPoint.getOriginalPointId(), target,
hAngle, vAngle, distanceSlop, Double.parseDouble(surveyorPoint.getPrismHeightDeal())));
}
if (callBackWaiteLearnData != null) {
callBackWaiteLearnData.result(waitLeanDataList);
}
});
}
private interface CallBackWaiteLearnData {
void result(List<ControlSurveyData> list);
}
public interface CallBackLearnResultCode {
void result(int code);
}
public interface CallBackCheckDesign {
void result(String result);
}
public static void checkAndReloadLearnData(@NonNull Map<String, ControlSurveyData> learnDataMap,
int measureWhat,
String stationId,
ICachedData cachedData,
IStationPointRecordCollect stationPointRecordCollect,
double stationInstrument,
PointRecord stationPointRecord,
@NonNull CallBackLearnResultCode callBackLearnResultCode) {
if (learnDataMap != null && !learnDataMap.isEmpty()) {
callBackLearnResultCode.result(ControlSurveyResult.CODE_SUCCESS);
return;
}
getWaitLearnDataList(measureWhat, stationId, cachedData, stationPointRecordCollect, waitLearnDataList -> {
//得到
ControlSurveyResult controlSurveyResult = TsUtil.calcMotorStation(
getStationCoordinate(stationPointRecord),
stationInstrument,
waitLearnDataList,
((App) Utils.getApp()).isCompletedLearn);
learnDataMap.clear();
if (controlSurveyResult.getCode() == ControlSurveyResult.CODE_SUCCESS) {
List<ControlSurveyData> controlSurveyDataList = controlSurveyResult.getControlSurveyDataList();
for (ControlSurveyData controlSurveyData : controlSurveyDataList) {
learnDataMap.put(controlSurveyData.getPointId(), controlSurveyData);
}
}
//返回学习结果
callBackLearnResultCode.result(controlSurveyResult.getCode());
});
}
public static void checkDesignData(
int measureWhat,
String stationId,
ICachedData cachedData,
IStationPointRecordCollect stationPointRecordCollect,
double stationInstrument,
PointRecord stationPointRecord,
@NonNull CallBackCheckDesign callBackCheckDesign) {
getWaitLearnDataList(measureWhat, stationId, cachedData, stationPointRecordCollect, list -> {
String result = TsUtil.checkDesignAndMeasureValue(getStationCoordinate(stationPointRecord),
stationInstrument, list, ((App) Utils.getApp()).isCompletedLearn);
ThreadPoolUtil.executeInMain(() -> callBackCheckDesign.result(result));
});
}
private static Coordinate getStationCoordinate(PointRecord stationPointRecord) {
Coordinate stationCoordinate = null;
if (PointRecord.TYPE_KNOWN_POINT.equals(stationPointRecord.getPointType())) {
stationCoordinate = new Coordinate(
stationPointRecord.getX(),
stationPointRecord.getY(),
stationPointRecord.getZ());
}
return stationCoordinate;
}
}

@ -0,0 +1,156 @@
package com.bingce.controlnetwork.surveyor.method;
import com.bingce.controlapphelper.model.DataCategory;
import com.bingce.controlapphelper.model.LeftOrRight;
import com.bingce.controlapphelper.surveyor.method.DeviationValueOfRadianMethod;
import com.bingce.controlapphelper.surveyor.method.model.SdAngleValueType;
import com.bingce.controlnetwork.surveyor.data.ICachedData;
import com.bingce.controlnetwork.surveyor.data.ISurveyorData;
import com.bingce.controlnetwork.surveyor.method.model.CacheResult;
import com.bingce.controlnetwork.util.IdUtil;
public class AverageValueMethod {
/**
* 读取缓存数据中的某个测点测量数据,这个数据可能是缓存数据也可能是当前测量数据
*
* @param type 水平角垂直角还是距离
* @param stationId
* @param cycleIndex
* @param pointIndex
* @param surveyorData
* @param cachedData
* @param leftOrRight
* @return
*/
public static CacheResult leftOrRightValue(
SdAngleValueType type,
String stationId,
int cycleIndex,
int pointIndex,
ISurveyorData surveyorData,
int surveyorCycleIndex,
ICachedData cachedData,
LeftOrRight leftOrRight) {
int surveyorCount = surveyorData.surveyorCount();
String pointId = cachedData.pointId(cycleIndex, pointIndex);
String recordId = IdUtil.surveyorRecordKey(stationId, cycleIndex, pointId, leftOrRight);
boolean isCurrentSurveyor = cycleIndex == surveyorCycleIndex && pointIndex == surveyorData.currentIndex();
//&& isCurrentSurveyor &&
// surveyorData.leftOrRight() == leftOrRight
//itemIndex == surveyorData.currentIndex()
//优先使用当前测量数据
if (surveyorData.ready2Record() && isCurrentSurveyor && surveyorData.leftOrRight() == leftOrRight) {
return new CacheResult(true,
_surveyorValue(type, surveyorData));
} else {//如果缓存的有数据,则直接返回缓存数据
//检测相应数据是否已经缓存
DataCategory dataCategory = cachedData.valueState(recordId);
if (dataCategory.hasData()) {
return new CacheResult(true,
_cachedValue(type, recordId, surveyorCount, cachedData));
}
}
return new CacheResult(false, -1);
}
public static CacheResult leftOrRightValue(
SdAngleValueType type,
String recordId,
int surveyorCount,
ICachedData cachedData) {
//检测相应数据是否已经缓存
DataCategory dataCategory = cachedData.valueState(recordId);
if (dataCategory.hasData()) {
return new CacheResult(true,
_cachedValue(type, recordId, surveyorCount, cachedData));
}
return new CacheResult(false, -1);
}
/**
* 缓存的测量数据根据盘左盘右求出的均值
*
* @return 如果是角度返回的是弧度值如果是距离返回的单位是米
*/
public static CacheResult leftAndRightValue(
SdAngleValueType type, String leftRecordId, String rightRecordId,
int surveyorCount, ICachedData cachedDataSource) {
DataCategory leftDataCategory = cachedDataSource.valueState(leftRecordId);
DataCategory rightDataCategory = cachedDataSource.valueState(rightRecordId);
if (!leftDataCategory.isFreshData() || !rightDataCategory.isFreshData()) {
return new CacheResult(false, -1);
}
double left = _cachedValue(type, leftRecordId, surveyorCount, cachedDataSource);
double right = _cachedValue(type, rightRecordId, surveyorCount, cachedDataSource);
double value = 0;
switch (type) {
case horAngle:
value = DeviationValueOfRadianMethod.averageHorRadianOfLeftAndRight(left, right);
break;
case verAngle:
value = DeviationValueOfRadianMethod.averageVerRadianOfLeftAndRight(left, right);
break;
case distance:
value = DeviationValueOfRadianMethod.averageDistanceOfLeftAndRight(left, right);
break;
}
return new CacheResult(true, value);
}
private static double _cachedValue(SdAngleValueType type, String recordId, int surveyorCount,
ICachedData cachedData) {
switch (type) {
case horAngle:
return surveyorCount == 1 ?
cachedData.angleHor1(recordId) :
cachedData.angleHor(recordId);
case verAngle:
return surveyorCount == 1 ?
cachedData.angleVer1(recordId) :
cachedData.angleVer(recordId);
case distance:
return surveyorCount == 1 ?
cachedData.distance1(recordId) :
cachedData.distance(recordId);
}
return 0;
}
/**
* 从测量数据中读取测量值
*
* @param type 数据类型水平角垂直角or斜距
* @param surveyorData 测量数据对象
* @return 测量结果
*/
private static double _surveyorValue(SdAngleValueType type, ISurveyorData surveyorData) {
int surveyorCount = surveyorData.surveyorCount();
if (surveyorCount == 1) {
switch (type) {
case horAngle:
return surveyorData.getAngleHor1();
case verAngle:
return surveyorData.getAngleVer1();
case distance:
return surveyorData.getDistance1();
}
} else if (surveyorCount == 2) {
switch (type) {
case horAngle:
return surveyorData.getAngleHor();
case verAngle:
return surveyorData.getAngleVer();
case distance:
return surveyorData.getDistance();
}
}
return 0;
}
}

@ -0,0 +1,577 @@
package com.bingce.controlnetwork.surveyor.method;
import com.bingce.controlapphelper.datasource.database.surveyorstation.model.SurveyorPoint;
import com.bingce.controlapphelper.model.LeftOrRight;
import com.bingce.controlapphelper.surveyor.method.RadianMethod;
import com.bingce.controlapphelper.surveyor.method.model.SdAngleValueType;
import com.bingce.controlnetwork.surveyor.data.FaultTolerantData;
import com.bingce.controlnetwork.surveyor.data.ICachedData;
import com.bingce.controlnetwork.surveyor.method.model.CacheResult;
import com.bingce.controlnetwork.surveyor.state.base.AdjustmentMeasureWhatUtil;
import com.bingce.controlnetwork.util.IdUtil;
import com.bingce.utils.Util;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import blankj.utilcode.util.ToastUtils;
/**
* 角度偏差处理
* <p>
* 需要考虑极限边界的情况 359.9999 ~~~0.000011之类的
*/
public class DeviationValueOfRadianMethod {
final static double LIMIT = Math.PI / 36;//默认大小超过5就是有问题
/**
* 相近二次读数平均值
* <p>
* 前提是两个角度实际值相近比如359.9999和0.0001视为相近数其平均值将被视为0
*/
public static double similarAverage(double v1, double v2) {
double _1_average = (v1 + v2) / 2.0f;
//不能直接返回,需要判断二者差值大小
double _1_d1 = Math.abs(v1 - _1_average);
double _1_d2 = Math.abs(v2 - _1_average);
if (_1_d1 < LIMIT && _1_d2 < LIMIT) {//误差不超限,返回
return _1_average;
}
if (v1 > v2) {
v2 += Math.PI * 2;
} else {
v1 += Math.PI * 2;
}
double _2_average = (v1 + v2) / 2.0f;
double _2_d1 = Math.abs(v1 - _2_average);
double _2_d2 = Math.abs(v2 - _2_average);
if (_2_d1 < LIMIT && _2_d2 < LIMIT) {//误差不超限,返回
return RadianMethod.formatRadian(_2_average);
}
return (v1 + v2) / 2.0f;
}
public static double similarAverage(List<Double> angles) {
//如果是空,直接返回0
if (angles.isEmpty()) {
return 0;
}
//处理边界情况,如果列表中存在边界值,就添加一个偏移量,直到所有值都正常为止
//但是注意,尝试的次数是有限的,如果尝试次数超过10次,就直接返回平均值
double offset = Math.PI / 5.001;//36度左右作为每次的偏量
double offsetAll = 0;
int tryCount = 10;//最多尝试10次,如果还不行,就退出
while (tryCount >= 0) {
tryCount--;
//检测是否有边界值
boolean isOk = true;
for (double angle : angles) {
if (angle >= 2 * Math.PI - LIMIT || angle <= LIMIT) {
isOk = false;
break;
}
}
if (!isOk) {//如果有边界值,就添加偏移量,再次循环
for (int index = 0; index < angles.size(); index++) {
double v = angles.get(index) + offset;
if (v > Math.PI * 2.0) {
v -= Math.PI * 2.0;
}
angles.set(index, v);
}
offsetAll += offset;
continue;
}
//没有边界了,计算平均值,然后减去总偏移量
//开始计算
double all = 0;
for (double v : angles) {
all += v;
}
double v = all / angles.size() - offsetAll;
if (v < 0) {
v += Math.PI * 2.0;
}
return v;
}
//直接计算平均值
double all = 0;
for (double v : angles) {
all += v;
}
return all / angles.size();
}
/**
* 相近角度差值
* <p>
* 和夹角的含义完全不同
* <p>
* 夹角有方向概念两样的值不同的方向差别很大359 -> 1 夹角是2但是1 -> 359夹角是358
* 但是这里差值不同求的是误差变化没有方向概念不管是359 ->1 还是1 -> 359差值都是2
* <p>
* 用于计算二次读数差测回间同方向2c差半测回归零差
* <p>
* 前提是两个角度实际值相近比如359.9999和0.0001视为相近数其差值为0.0002
*
* @param angle1 读数1
* @param angle2 读数2
* @return 弧度值
*/
public static double similarRadianDiff(double angle1, double angle2) {
//检测二者是否过大
double d1 = Math.abs(angle1 - angle2);
if (d1 < LIMIT) {//差距在误差内
return d1;
}
//差距过大,将小值+360
if (angle1 > angle2) {
angle2 += Math.PI * 2;
} else {
angle1 += Math.PI * 2;
}
double d2 = Math.abs(angle1 - angle2);
if (d2 < LIMIT) {//差距在误差内
return d2;
}
return Math.min(d1, d2);
}
/**
* 求夹角
* 夹角有方向概念两样的值不同的方向差别很大359 -> 1 夹角是2但是1 -> 359夹角是358
* <p>
* 注意需要处理边界两侧的情况
* <p>
* 夹角是有方向的从from沿顺时针计算
* <p>
* 尤其用于归零值必须考虑夹角
*
* @param from 开始处的角度
* @param to 结束处的角度
* @return 二者的夹角结果是2PI以内的正值
*/
public static double includeAngle(double from, double to) {
return Util.getIncludedAngle(from, to, true);
}
/**
* 根据盘左盘右求出的水平角值
*
* @param angleLeftRadian 盘左水平角
* @param angleRightRadian 盘右水平角
* @return 水平角, 弧度值
*/
public static double averageHorRadianOfLeftAndRight(double angleLeftRadian, double angleRightRadian) {
//检测是否有某个值位于0左右
final double GAP = Util.dmsDoubleToRadian(5);
final double OFFSET = Util.dmsDoubleToRadian(20);
double left = RadianMethod.formatRadian(angleLeftRadian);
double right = RadianMethod.formatRadian(angleRightRadian);
boolean needOffset = false;
if (left >= Math.PI * 2 - GAP || left <= GAP) {
needOffset = true;
} else if (right >= Math.PI * 2 - GAP || right <= GAP) {
needOffset = true;
}
if (needOffset) {//如果位于0左右,添加偏移
left = RadianMethod.formatRadian(left + OFFSET);
right = RadianMethod.formatRadian(right + OFFSET);
}
//将盘右转到盘左值
right = RadianMethod.formatRadian(right - Math.PI);
if (needOffset) {
return (left + right) / 2 - OFFSET;
} else {
return (left + right) / 2;
}
}
/**
* 根据盘左盘右求出的垂直角值
*
* @param angleLeftRadian 盘左垂直角
* @param angleRightRadian 盘右垂直角
* @return 垂直角, 弧度值
*/
public static double averageVerRadianOfLeftAndRight(double angleLeftRadian, double angleRightRadian) {
return (angleRightRadian - angleLeftRadian - Math.PI) / 2.0;
}
/**
* 根据盘左盘右求出的斜距值
*
* @param distanceLeft 盘左斜距值
* @param distanceRight 盘右斜距值
* @return 斜距值
*/
public static double averageDistanceOfLeftAndRight(double distanceLeft, double distanceRight) {
return (distanceRight + distanceLeft) / 2.0;
}
/**
* 盘左盘右 水平角2c值
*
* @param angleLeftRadian 盘左水平角
* @param angleRightRadian 盘右水平角
* @return 水平角2c差 格式弧度
*/
public static double radianAngleHor2C(double angleLeftRadian, double angleRightRadian) {
//检测是否有某个值位于0左右
final double GAP = Util.dmsDoubleToRadian(5);
final double OFFSET = Util.dmsDoubleToRadian(20);
double left = RadianMethod.formatRadian(angleLeftRadian);
double right = RadianMethod.formatRadian(angleRightRadian);
boolean needOffset = false;
if (left >= (Math.PI * 2 - GAP) || left <= GAP) {
needOffset = true;
} else if (right >= (Math.PI * 2 - GAP) || right <= GAP) {
needOffset = true;
}
if (needOffset) {//如果位于0左右,添加偏移
left = RadianMethod.formatRadian(left + OFFSET);
right = RadianMethod.formatRadian(right + OFFSET);
}
//将盘右转到盘左值
right = RadianMethod.formatRadian(right - Math.PI);
return left - right;
}
/**
* 盘左盘右 垂直角2c值
*
* @param angleLeftRadian 盘左垂直角
* @param angleRightRadian 盘右垂直角
* @return 垂直角2c差 格式弧度
*/
public static double radianAngleVer2C(double angleLeftRadian, double angleRightRadian) {
return (angleLeftRadian + angleRightRadian - 2.0 * Math.PI) / 2.0;
}
/**
* 盘左盘右 斜距2c值
*
* @param distanceLeft 盘左斜距
* @param distanceRight 盘右斜距
* @return 斜距2c差, 单位m
*/
public static double distance2C(double distanceLeft, double distanceRight) {
return Math.abs(distanceLeft - distanceRight);
}
//某个测回的归零值列表
/**
* 记录水平角垂直角数据的对象
*/
public static class AngleDistValue {
public final String pointId;
public final String pointName;
public final double horRadian;
public final double verRadian;
public final double distance;
public final String prismHeight;
public final boolean aloneDistance;
public final boolean isMeasureDistanceNot;
public final boolean isMeasureVerNot;
public AngleDistValue(String realPointId, String pointName, double horRadian, double verRadian, double distance,
String prismHeight, boolean aloneDistance, boolean isMeasureDistanceNot, boolean isMeasureVerNot) {
this.pointId = realPointId;
this.pointName = pointName;
this.horRadian = horRadian;
this.verRadian = verRadian;
this.distance = distance;
this.prismHeight = prismHeight;
this.aloneDistance = aloneDistance;
this.isMeasureDistanceNot = isMeasureDistanceNot;
this.isMeasureVerNot = isMeasureVerNot;
}
}
/**
* 算的都是左角测量方向下的归零值
* <p>
* 无自动闭合情况下为了兼容左右角测量结果根据pointId将所有测量数据存入map中
* 根据左角测量来检测测回间同方向值互差所有测回的归零值使用左角第一个point来做0点
* <p>
* 如果是自动闭合情况则忽略左右角测量直接按照itemIndex依次计算第个测回的归零值
* 使用每次循环的itemIndex=0做0点
*/
public static List<AngleDistValue> zeroValueOfSingleCycleInLeftOrientation(
final int measureWhat,
final String stationId, final int cycleIndex, final int surveyorCount,
final ICachedData cachedDataSource) {
//1.收集数据,包含排序和处理闭合点
List<AngleDistValue> list = _collectAllSdaRecordInSingleCycle(measureWhat,
stationId, cycleIndex, surveyorCount, cachedDataSource, true);
//2.归零
return _zero(list);
}
/**
* 不强制左角方向按照测量方向可能是右角方向
*/
public static List<AngleDistValue> zeroValueOfSingleCycle(
final int measureWhat,
final String stationId, final int cycleIndex, final int surveyorCount,
final ICachedData cachedDataSource) {
//1.收集数据,包含处理闭合点,但是不排序
List<AngleDistValue> mapI = _collectAllSdaRecordInSingleCycle(
measureWhat,
stationId, cycleIndex, surveyorCount, cachedDataSource, false);
//2.归零
return _zero(mapI);
}
/**
* 计算单个测回内各方向水平角垂直角值和距离值原始测量数据
* <p>
* 不含闭合点如果有闭合点将自动求出和起始点的平均值放到起始点的位置
* <p>
* 返回的数据顺序是实际的测量顺序可能是左角也可能是右角
*
* @param cycleIndex 测回索引
* @param forceLeftOrientation 是否强制返回左角有顺序
* @return 数值列表包含闭合点
*/
private static List<AngleDistValue> _collectAllSdaRecordInSingleCycle(
int measureWhat,
String stationId, int cycleIndex, int surveyorCount,
final ICachedData cachedData, boolean forceLeftOrientation) {
int pointCount = cachedData.pointCount();
Map<String, AngleDistValue> values;
if (AdjustmentMeasureWhatUtil.isAdjustAll(measureWhat)) {
values = collectAllData(cachedData, cycleIndex, stationId, surveyorCount);
} else if (AdjustmentMeasureWhatUtil.isAdjustHorAngle(measureWhat)) {
values = collectHorAngleData(cachedData, cycleIndex, stationId, surveyorCount);
} else if (AdjustmentMeasureWhatUtil.isAdjustVerAngle(measureWhat)) {
values = collectVerAngleData(cachedData, cycleIndex, stationId, surveyorCount);
} else {
ToastUtils.showShort("_collectAllSdaRecordInSingleCycle is error");
throw new RuntimeException();
}
//根据第一个点和最后一个点,判断是否开启了闭合
//如果开启了闭合,需要将闭合点的平均值添加到起始点
if (values.size() >= 2) {
String firstId = cachedData.pointId(cycleIndex, 0);
String lastId = cachedData.pointId(cycleIndex, pointCount - 1);
if (SurveyorPoint.pointClosedId(firstId).equals(lastId)) {
//移除最后一个,将其值添加到第一个中
AngleDistValue first = values.get(firstId);
AngleDistValue last = values.get(lastId);
if (last != null && first != null) {
values.put(firstId,
new AngleDistValue(
first.pointId,
first.pointName,
DeviationValueOfRadianMethod.similarAverage(last.horRadian, first.horRadian),
DeviationValueOfRadianMethod.similarAverage(last.verRadian, first.verRadian),
(last.distance + first.distance) / 2f,
first.prismHeight, first.aloneDistance, first.isMeasureDistanceNot, first.isMeasureVerNot)
);
values.remove(lastId);
}
}
}
List<AngleDistValue> result = new ArrayList<>();
//如果强制使用左角方向,需要根据单测回点顺序排序
if (forceLeftOrientation) {
//这里使用第0测回作为排序依据
for (int index = 0; index < pointCount; index++) {
String id = cachedData.pointId(0, index);
AngleDistValue value = values.get(id);
//可能存在闭合点,但是如果有闭合点,上面已经取消,所以在map中没有对应值
if (value != null) {
result.add(value);
}
}
} else {//非强制左角,直接使用map顺序即可
for (Map.Entry<String, AngleDistValue> kv : values.entrySet()) {
if (kv.getValue() != null) {
result.add(kv.getValue());
}
}
}
return result;
}
/**
* 对角度距离列表执行归零操作
* 不排序传入的可能是左角测量值也可能是右角测量值
*
* @param list 原始值没有闭合点闭合点已经被平均到起始点
* @return 归零后的列表
*/
private static List<AngleDistValue> _zero(List<AngleDistValue> list) {
List<AngleDistValue> result = new ArrayList<>();
if (list != null && !list.isEmpty()) {
double horAngle0 = list.get(0).horRadian;
//归零操作
for (int index = 0; index < list.size(); index++) {
AngleDistValue value = list.get(index);
double horRadian = DeviationValueOfRadianMethod.includeAngle(horAngle0, value.horRadian);
result.add(new AngleDistValue(value.pointId, value.pointName, horRadian, value.verRadian, value.distance,
value.prismHeight, value.aloneDistance, value.isMeasureDistanceNot, value.isMeasureVerNot));
}
}
return result;
}
/**
*
*/
private static Map<String, AngleDistValue> collectAllData(ICachedData cachedData,
int cycleIndex,
String stationId,
int surveyorCount) {
Map<String, AngleDistValue> values = new LinkedHashMap<>();
for (int itemIndex = 0; itemIndex < cachedData.pointCount(); itemIndex++) {
//如果是跳过就不验证了
if (cachedData.isAbandonPoint(cycleIndex, itemIndex)) {
continue;
}
boolean aloneMeasureDistancePoint = cachedData.isAloneMeasureDistancePoint(cycleIndex, itemIndex);
boolean isMeasureDistanceNot = cachedData.isMeasureDistanceNot(cycleIndex, itemIndex);
boolean isMeasureVerNot = cachedData.isMeasureVerNot(cycleIndex, itemIndex);
boolean isWellSteelPoint = cachedData.isWellSteelPoint(cycleIndex, itemIndex);
String pointId = cachedData.pointId(cycleIndex, itemIndex);
String pointName = cachedData.pointName(cycleIndex, itemIndex);
String leftRecordId = IdUtil.surveyorRecordKey(stationId, cycleIndex, pointId, LeftOrRight.left);
String rightRecordId = IdUtil.surveyorRecordKey(stationId, cycleIndex, pointId, LeftOrRight.right);
String prismHeight = cachedData.getPrismHeight(cycleIndex, itemIndex);
//水平角
CacheResult cachedHorAngle = AverageValueMethod.leftAndRightValue(SdAngleValueType.horAngle,
leftRecordId,
rightRecordId,
surveyorCount,
cachedData);
if (!cachedHorAngle.validate) {
continue;
}
//垂直角
double verAngle = FaultTolerantData.ERROR_VER_ANGLE;
if (!cachedData.isMeasureVerNot(cycleIndex, itemIndex)) {
CacheResult cachedVerValue = AverageValueMethod.leftAndRightValue(SdAngleValueType.verAngle,
leftRecordId,
rightRecordId,
surveyorCount,
cachedData);
if (cachedVerValue.validate) {
verAngle = cachedVerValue.value;
}
}
//距离
double distance = FaultTolerantData.ERROR_DISTANCE;
if (!(aloneMeasureDistancePoint || isMeasureDistanceNot || isWellSteelPoint)) {
//不是钢丝不是单独测距不测距离
CacheResult cachedDistanceValue = AverageValueMethod.leftAndRightValue(SdAngleValueType.distance,
leftRecordId,
rightRecordId,
surveyorCount,
cachedData);
if (cachedDistanceValue.validate) {
distance = cachedDistanceValue.value;
}
}
AngleDistValue value = new AngleDistValue(pointId, pointName, cachedHorAngle.value, verAngle, distance,
prismHeight, aloneMeasureDistancePoint, isMeasureDistanceNot, isMeasureVerNot);
values.put(pointId, value);
}
return values;
}
/**
*
*/
private static Map<String, AngleDistValue> collectHorAngleData(ICachedData cachedData,
int cycleIndex,
String stationId,
int surveyorCount) {
Map<String, AngleDistValue> values = new LinkedHashMap<>();
for (int itemIndex = 0; itemIndex < cachedData.pointCount(); itemIndex++) {
//如果是跳过就不验证了
if (cachedData.isAbandonPoint(cycleIndex, itemIndex)) {
continue;
}
String pointId = cachedData.pointId(cycleIndex, itemIndex);
String leftRecordId = IdUtil.surveyorRecordKey(stationId, cycleIndex, pointId, LeftOrRight.left);
String rightRecordId = IdUtil.surveyorRecordKey(stationId, cycleIndex, pointId, LeftOrRight.right);
CacheResult cachedHorAngle = AverageValueMethod.leftAndRightValue(SdAngleValueType.horAngle,
leftRecordId,
rightRecordId,
surveyorCount,
cachedData);
if (!cachedHorAngle.validate) {
continue;
}
String realPointId = cachedData.realPointId(cycleIndex, itemIndex);
String pointName = cachedData.pointName(cycleIndex, itemIndex);
String prismHeight = cachedData.getPrismHeight(cycleIndex, itemIndex);
boolean aloneMeasureDistancePoint = cachedData.isAloneMeasureDistancePoint(cycleIndex, itemIndex);
boolean isMeasureDistanceNot = cachedData.isMeasureDistanceNot(cycleIndex, itemIndex);
boolean isMeasureVerNot = cachedData.isMeasureVerNot(cycleIndex, itemIndex);
AngleDistValue value = new AngleDistValue(realPointId, pointName, cachedHorAngle.value, FaultTolerantData.ERROR_VER_ANGLE,
FaultTolerantData.ERROR_DISTANCE, prismHeight, aloneMeasureDistancePoint, isMeasureDistanceNot, isMeasureVerNot);
values.put(pointId, value);
}
return values;
}
/**
*
*/
private static Map<String, AngleDistValue> collectVerAngleData(ICachedData cachedData,
int cycleIndex,
String stationId,
int surveyorCount) {
Map<String, AngleDistValue> values = new LinkedHashMap<>();
for (int itemIndex = 0; itemIndex < cachedData.realPointCount(); itemIndex++) {
//如果是跳过就不验证了
if (cachedData.isAbandonPoint(cycleIndex, itemIndex)) {
continue;
}
String pointId = cachedData.pointId(cycleIndex, itemIndex);
String leftRecordId = IdUtil.surveyorRecordKey(stationId, cycleIndex, pointId, LeftOrRight.left);
String rightRecordId = IdUtil.surveyorRecordKey(stationId, cycleIndex, pointId, LeftOrRight.right);
CacheResult cachedVerValue = AverageValueMethod.leftAndRightValue(SdAngleValueType.verAngle,
leftRecordId,
rightRecordId,
surveyorCount,
cachedData);
if (!cachedVerValue.validate) {
continue;
}
String pointName = cachedData.pointName(cycleIndex, itemIndex);
String prismHeight = cachedData.getPrismHeight(cycleIndex, itemIndex);
boolean aloneMeasureDistancePoint = cachedData.isAloneMeasureDistancePoint(cycleIndex, itemIndex);
boolean isMeasureDistanceNot = cachedData.isMeasureDistanceNot(cycleIndex, itemIndex);
boolean isMeasureVerNot = cachedData.isMeasureVerNot(cycleIndex, itemIndex);
AngleDistValue value = new AngleDistValue(pointId, pointName, FaultTolerantData.ERROR_VER_ANGLE,
cachedVerValue.value, FaultTolerantData.ERROR_DISTANCE, prismHeight, aloneMeasureDistancePoint, isMeasureDistanceNot, isMeasureVerNot);
values.put(pointId, value);
}
return values;
}
}

@ -6,7 +6,6 @@ import android.text.TextUtils;
import androidx.annotation.WorkerThread;
import com.bingce.controlapphelper.datasource.database.ProjectType;
import com.bingce.controlapphelper.datasource.database.ProjectTypeValue;
import com.bingce.controlapphelper.datasource.database.SurveyorDatabaseFactory;
import com.bingce.controlapphelper.datasource.database.line.ILineRecordDataSource;
@ -23,20 +22,18 @@ import com.bingce.controlapphelper.datasource.database.tolerance.detail.IToleran
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.surveyor.data.CachedData;
import com.bingce.controlapphelper.surveyor.data.CachedDataAloneDistance;
import com.bingce.controlapphelper.surveyor.method.ExportStationMethod;
import com.bingce.controlapphelper.surveyor.method.ExportUtils;
import com.bingce.controlapphelper.surveyor.method.SurveyorAdjustMethod;
import com.bingce.controlapphelper.util.Tools;
import com.bingce.controlnetwork.App;
import com.bingce.controlnetwork.R;
import com.bingce.controlnetwork.model.AloneAdjustItem;
import com.bingce.controlnetwork.newui.configfragment.SelectExportType;
import com.bingce.controlnetwork.surveyor.data.CachedData;
import com.bingce.controlnetwork.surveyor.data.CachedDataPointType;
import com.bingce.controlnetwork.surveyor.state.StateConstantsPla;
import com.bingce.controlnetwork.util.CheckRegUtil;
import com.bingce.utils.DateUtils;
import com.bingce.utils.RegisterUtil;
import com.bingce.utils.Util;
import com.bingce.utils.VipManager;
import com.bingce.zip.ZipUtil;
import org.jetbrains.annotations.NotNull;
@ -236,7 +233,7 @@ public class ExportUtilsPla {
ExportStationMethod.save(" ", periodFolder, "边长.TXT");
}
exportProjectAndControlPoint(project,projectCachedDir);
exportProjectAndControlPoint(project, projectCachedDir);
}
}
@ -355,15 +352,44 @@ public class ExportUtilsPla {
private static void collectCustomTj61365(String stationName, SurveyorStationRecord stationRecord, ToleranceDetailRecord toleranceRecord,
StringBuilder horSbTianjinOne, StringBuilder verSbTianjinOne,
StringBuilder disSbTianjinOne) {
// if (stationRecord.isSeparateObservation()) {
// collectAloneHorAngleTjUnique(stationName, stationRecord, toleranceRecord, horSbTianjinOne);
// } else {
// collectCombineAngleDistanceTjUnique(stationName, stationRecord, toleranceRecord, horSbTianjinOne, verSbTianjinOne, disSbTianjinOne);
// }
collectCombineAngleDistanceTjUnique(stationName, stationRecord, toleranceRecord, horSbTianjinOne, verSbTianjinOne, disSbTianjinOne);
if (stationRecord.isSeparateObservation()) {
collectAloneHorAngleTjUnique(stationName, stationRecord, toleranceRecord, horSbTianjinOne);
} else {
collectCombineAngleDistanceTjUnique(stationName, stationRecord, toleranceRecord, horSbTianjinOne, verSbTianjinOne, disSbTianjinOne);
}
collectAloneVerAngleTjUnique(stationName, stationRecord, toleranceRecord, verSbTianjinOne);
collectAloneDistanceTjUnique(stationName, stationRecord, toleranceRecord, disSbTianjinOne);
}
private static void collectAloneHorAngleTjUnique(String stationName, SurveyorStationRecord stationRecord,
ToleranceDetailRecord toleranceRecord, StringBuilder horSbTianjinOne) {
SurveyorAdjustMethodPla.AdjustResult adjustResultHorAngle = SurveyorAdjustMethodPla.calStationAdjust(StateConstantsPla.VALUE_MEASURE_WHAT_ANGLE_HOR, stationRecord,
CachedData.newInstance(
StateConstantsPla.VALUE_MEASURE_WHAT_ANGLE_HOR,
CachedDataPointType.ALL_POINT,
stationRecord.isAutoClose(),
stationRecord.isLeftAndRightSurveyor(),
stationRecord.getId(),
toleranceRecord
));
if (adjustResultHorAngle.errorString == null || adjustResultHorAngle.errorString.isEmpty()) {
//水平角
horSbTianjinOne.append(stationName).append(SPACE).append(formatHeight(Double.parseDouble(stationRecord.getInstrumentHeightDeal()))).append(SPACE);
//遍历测站测点
for (int i = 0; i < adjustResultHorAngle.result.size(); i++) {
SurveyorAdjustMethodPla.Item item = adjustResultHorAngle.result.get(i);
//水平角
String exportHorAngle = ExportStationMethod.radianToDmsForTj61365(item.getHorAngle(), true);
if (i != 0) {
horSbTianjinOne.append(SPACE).append(SPACE);
}
horSbTianjinOne.append(item.getPointName()).append(SPACE).append(exportHorAngle).append(SPACE).append(formatHeight(Double.parseDouble(item.getPrismHeightActual())));
horSbTianjinOne.append(NEW_LINE);
}
}
}
/**
* 收集合并观测的水平角垂直角和距离
* 距离可能存在单独测距
@ -377,7 +403,7 @@ public class ExportUtilsPla {
stationRecord.getId(), toleranceRecord);
//测距测角的平差结果
SurveyorAdjustMethod.AdjustResult adjustResult = SurveyorAdjustMethod.calStationAdjust(stationRecord, cachedData);
SurveyorAdjustMethodPla.AdjustResult adjustResult = SurveyorAdjustMethodPla.calStationAdjust(stationRecord, cachedData);
if (adjustResult.errorString == null || adjustResult.errorString.isEmpty()) {
//水平角
horSbTianjinOne.append(stationName).append(SPACE).append(formatHeight(Double.parseDouble(stationRecord.getInstrumentHeight()))).append(SPACE);
@ -386,19 +412,19 @@ public class ExportUtilsPla {
int verEverySurveyorPoint = 0;
//遍历测站测点
for (int i = 0; i < adjustResult.result.size(); i++) {
SurveyorAdjustMethod.Item item = adjustResult.result.get(i);
SurveyorAdjustMethodPla.Item item = adjustResult.result.get(i);
//水平角
String exportHorAngle = ExportStationMethod.radianToDmsForTj61365(item.getHorAngle(), true);
if (i != 0) {
horSbTianjinOne.append(SPACE).append(SPACE);
}
horSbTianjinOne.append(item.getPointName()).append(SPACE).append(exportHorAngle).append(SPACE).append(formatHeight(item.getPrismHeight()));
horSbTianjinOne.append(item.getPointName()).append(SPACE).append(exportHorAngle).append(SPACE).append(formatHeight(Double.parseDouble(item.getPrismHeight())));
horSbTianjinOne.append(NEW_LINE);
verEverySurveyorPoint++;
String exportVerAngle = ExportStationMethod.radianToDmsForTj61365(item.getVerAngle(), false);
verSbTianjinEveryStation.append(item.getPointName()).append(SPACE).append(exportVerAngle).append(SPACE).append(formatHeight(Double.parseDouble(stationRecord.getInstrumentHeight())))
.append(SPACE).append(formatHeight(item.getPrismHeight()));
.append(SPACE).append(formatHeight(Double.parseDouble(item.getPrismHeight())));
verSbTianjinEveryStation.append(NEW_LINE);
double distance = item.getDistance();
@ -416,29 +442,53 @@ public class ExportUtilsPla {
}
}
private static void collectAloneVerAngleTjUnique(String stationName, SurveyorStationRecord stationRecord,
ToleranceDetailRecord toleranceRecord, StringBuilder verSbTianjinOne) {
List<AloneAdjustItem> adjustResult = SurveyorAdjustMethodPla.calAloneVer(stationRecord.getId(),
CachedData.newInstance(
StateConstantsPla.VALUE_MEASURE_WHAT_ANGLE_VER,
CachedDataPointType.ALONE_MEASURE_VER_ANGLE_POINT,
stationRecord.isAutoClose(),
stationRecord.isLeftAndRightSurveyor(),
stationRecord.getId(),
toleranceRecord
), false);
if (!adjustResult.isEmpty()) {
verSbTianjinOne.append(stationName).append(SPACE).append(adjustResult.size()).append(NEW_LINE);
//遍历测站测点
for (int i = 0; i < adjustResult.size(); i++) {
AloneAdjustItem item = adjustResult.get(i);
String exportVerAngle = ExportStationMethod.radianToDmsForTj61365(item.getVerAngle(), false);
verSbTianjinOne.append(item.getPointName()).append(SPACE).append(exportVerAngle).append(SPACE)
.append(formatHeight(Double.parseDouble(stationRecord.getInstrumentHeightDeal()))).append(SPACE).append(formatHeight(Double.parseDouble(item.getPrismHeightActual())));
verSbTianjinOne.append(NEW_LINE);
}
}
}
/**
* 收集天津边长数据
* 合并观测和分开观测的单独测距
*/
private static void collectAloneDistanceTjUnique(String stationName, SurveyorStationRecord stationRecord,
ToleranceDetailRecord toleranceRecord, StringBuilder disSbTianjinOne) {
SurveyorAdjustMethod.calAloneDistance(stationRecord.getId(),
CachedDataAloneDistance.newInstance(stationRecord.getId()), new SurveyorAdjustMethod.ICallback() {
@Override
public void onGet(ArrayList<SurveyorAdjustMethod.Item> adjustResult, Boolean isShowSlopDistance) {
if (!adjustResult.isEmpty()) {
for (SurveyorAdjustMethod.Item item : adjustResult) {
appendAloneDistance(disSbTianjinOne, stationName, item.getPointName(), item.getDistance(),
Double.parseDouble(stationRecord.getInstrumentHeightDeal()), String.valueOf(item.getPrismHeight()));
}
}
}
@Override
public void onFailure(String error) {
List<AloneAdjustItem> adjustResult = SurveyorAdjustMethodPla.calAloneDistance(stationRecord.getId(),
CachedData.newInstance(
StateConstantsPla.VALUE_MEASURE_WHAT_DISTANCE,
CachedDataPointType.ALONE_MEASURE_DISTANCE_POINT,
stationRecord.isAutoClose(),
stationRecord.isLeftAndRightSurveyor(),
stationRecord.getId(),
toleranceRecord
), false);
}
});
if (!adjustResult.isEmpty()) {
for (AloneAdjustItem item : adjustResult) {
appendAloneDistance(disSbTianjinOne, stationName, item.getPointName(), item.getDistance(), Double.parseDouble(stationRecord.getInstrumentHeightDeal()), item.getPrismHeightActual());
}
}
}
private static void appendAloneDistance(StringBuilder disSbTianjinOne, String stationName, String pointName, double distance,
@ -506,10 +556,10 @@ public class ExportUtilsPla {
cachedData.onShowSlopDistance(false);//平距
//计算平差数据
SurveyorAdjustMethod.AdjustResult adjustResult = SurveyorAdjustMethod.calStationAdjust(stationRecord, cachedData);
SurveyorAdjustMethodPla.AdjustResult adjustResult = SurveyorAdjustMethodPla.calStationAdjust(stationRecord, cachedData);
if (TextUtils.isEmpty(adjustResult.errorString)) {
ksStringBuilder.append(stationName).append(NEW_LINE);
for (SurveyorAdjustMethod.Item item : adjustResult.result) {
for (SurveyorAdjustMethodPla.Item item : adjustResult.result) {
ksStringBuilder
.append(item.getPointName())
.append(",L,")
@ -517,7 +567,7 @@ public class ExportUtilsPla {
.append(NEW_LINE);
}
for (SurveyorAdjustMethod.Item item : adjustResult.result) {
for (SurveyorAdjustMethodPla.Item item : adjustResult.result) {
//这里兼容下钢丝测距的距离
String pointName = item.getPointName();
@ -668,9 +718,9 @@ public class ExportUtilsPla {
cachedData.onShowSlopDistance(false);
//计算平差数据
SurveyorAdjustMethod.AdjustResult adjustResult = SurveyorAdjustMethod.calStationAdjust(stationRecord, cachedData);
SurveyorAdjustMethodPla.AdjustResult adjustResult = SurveyorAdjustMethodPla.calStationAdjust(stationRecord, cachedData);
if (TextUtils.isEmpty(adjustResult.errorString)) {
for (SurveyorAdjustMethod.Item item : adjustResult.result) {
for (SurveyorAdjustMethodPla.Item item : adjustResult.result) {
//这里兼容下钢丝测距的距离
String pointName = item.getPointName();
@ -859,7 +909,7 @@ public class ExportUtilsPla {
}
StringBuilder stationSb = new StringBuilder();
Map<String, List<SurveyorAdjustMethod.Item>> tempDataMap = new LinkedHashMap<>();
Map<String, List<SurveyorAdjustMethodPla.Item>> tempDataMap = new LinkedHashMap<>();
for (Map.Entry<String, Station> stationEntry : cycle.stationMap.entrySet()) {
String stationId = stationEntry.getValue().stationId;
@ -878,7 +928,7 @@ public class ExportUtilsPla {
cachedData.onShowSlopDistance(false);
//计算平差数据
SurveyorAdjustMethod.AdjustResult adjustResult = SurveyorAdjustMethod.calStationAdjust(stationRecord, cachedData);
SurveyorAdjustMethodPla.AdjustResult adjustResult = SurveyorAdjustMethodPla.calStationAdjust(stationRecord, cachedData);
if (TextUtils.isEmpty(adjustResult.errorString)) {
stationSb.append(cycle.stationMap.keySet().size());
stationSb.append(NEW_LINE);
@ -886,7 +936,7 @@ public class ExportUtilsPla {
stationSb.append(stationName).append(",").append(adjustResult.result.size()).append(",").append(NEW_LINE);
stationSb.append("照准点").append(NEW_LINE);
for (SurveyorAdjustMethod.Item item : adjustResult.result) {
for (SurveyorAdjustMethodPla.Item item : adjustResult.result) {
//这里兼容下钢丝测距的距离
String pointName = item.getPointName();
@ -1319,16 +1369,16 @@ public class ExportUtilsPla {
final double[] verAngle = new double[1];
final double[] distance = new double[1];
SurveyorAdjustMethod.AdjustResult adjustResult = SurveyorAdjustMethod.calStationAdjust(stationRecord, cachedData);
SurveyorAdjustMethodPla.AdjustResult adjustResult = SurveyorAdjustMethodPla.calStationAdjust(stationRecord, cachedData);
if (TextUtils.isEmpty(adjustResult.errorString)) {
//展示结果数据
//检测归零值是否为负,如果是需要+2PI
for (SurveyorAdjustMethod.Item item : adjustResult.result) {
for (SurveyorAdjustMethodPla.Item item : adjustResult.result) {
if (item.getHorAngle() < 0) {
item.setHorAngle(Math.PI * 2 + item.getHorAngle());
}
}
SurveyorAdjustMethod.Item item = adjustResult.result.get(adjustResult.result.size() - 1);
SurveyorAdjustMethodPla.Item item = adjustResult.result.get(adjustResult.result.size() - 1);
horAngle[0] = item.getHorAngle();
verAngle[0] = item.getVerAngle();
distance[0] = item.getDistance();

@ -0,0 +1,181 @@
package com.bingce.controlnetwork.surveyor.method;
import androidx.annotation.NonNull;
import com.bingce.controlapphelper.model.DataCategory;
import com.bingce.controlapphelper.model.LeftOrRight;
import com.bingce.controlnetwork.surveyor.data.ICachedData;
import com.bingce.controlnetwork.util.IdUtil;
/**
* 根据移动方向和条件查找下一个符合的目标点
*/
public class FindTargetMethod {
/**
* 从指定位置在单个测期内向前或向后查找empty点
*
* @param cycleIndex 测期
* @param itemIndex 指定item索引
* @param surveyorState 测量状态盘左or盘右
* @param pointCount 测站中的测点个数含闭合点
* @param moveForward 查找方向向前or向后
* @param stationSurveyorDataSource 缓存的测站测量数据
* @return 包含目标位置和测量状态
*/
public static Target findEmptyTargetInSingleCycle(final String stationId,
final int cycleIndex,
final int itemIndex,
final LeftOrRight surveyorState,
final int pointCount,
final boolean moveForward,
final @NonNull ICachedData stationSurveyorDataSource) {
return findTargetInSingleCycle(
stationId, cycleIndex, itemIndex, surveyorState, pointCount, moveForward,
DataCategory.emptyCategory(), stationSurveyorDataSource);
}
/**
* 从指定位置在单个测期内向前或向后查找empty点
*
* @param cycleIndex 测期
* @param itemIndex 指定item索引
* @param surveyorState 测量状态盘左or盘右
* @param pointCount 测站中的测点个数含闭合点
* @param moveForward 查找方向向前or向后
* @param cachedData 缓存的测站测量数据
* @return 包含目标位置和测量状态
*/
public static Target findDirtyTargetInSingleCycle(final String stationId,
final int cycleIndex,
final int itemIndex,
final LeftOrRight surveyorState,
final int pointCount,
final boolean moveForward,
final @NonNull ICachedData cachedData) {
return findTargetInSingleCycle(
stationId, cycleIndex, itemIndex, surveyorState, pointCount, moveForward,
DataCategory.needResurvey(), cachedData);
}
/**
* 从指定位置在单个测期内向前或向后查找待测点
*
* @param cycleIndex 测期
* @param itemIndex 指定item索引
* @param leftOrRight 测量状态盘左or盘右
* @param pointCount 测站中的测点个数含闭合点
* @param moveForward 查找方向向前or向后
* @param dataCategory 要查找的数据类型
* @param cachedData 缓存的测站测量数据
* @return 包含目标位置和测量状态
*/
public static Target findTargetInSingleCycle(final String stationId,
final int cycleIndex,
final int itemIndex,
final LeftOrRight leftOrRight,
final int pointCount,
final boolean moveForward,
final DataCategory dataCategory,
final @NonNull ICachedData cachedData) {
int targetIndex = itemIndex;
LeftOrRight targetLeftOrRight = leftOrRight;
boolean findTarget = false;
while (true) {
//检测当前遍历到的状态是否完成测量
if (checkDataCategory(stationId, cycleIndex, targetIndex, targetLeftOrRight, dataCategory, cachedData)) {
//如果找到没有测量的位置,则停止查找
findTarget = true;
break;
}
if (moveForward) {
//向后移动,查找
if (LeftOrRight.left == targetLeftOrRight) {//测量盘左
if (targetIndex == pointCount - 1) {//转到测量盘右
targetLeftOrRight = LeftOrRight.right;
} else {
targetIndex = targetIndex + 1;
targetLeftOrRight = LeftOrRight.left;
}
} else if (LeftOrRight.right == targetLeftOrRight) {//测量盘右
if (targetIndex <= 0) {//本测期已经完成,则判断
break;
} else {
targetIndex = targetIndex - 1;
targetLeftOrRight = LeftOrRight.right;
}
} else {
break;
}
} else {
//向前移动,查找
if (LeftOrRight.right == targetLeftOrRight) {//测量盘右
if (targetIndex == pointCount - 1) {//转到测量盘右
targetLeftOrRight = LeftOrRight.left;
} else {
targetIndex = targetIndex + 1;
targetLeftOrRight = LeftOrRight.right;
}
} else if (LeftOrRight.left == targetLeftOrRight) {//测量盘左
if (targetIndex <= 0) {//本测期已经完成,则判断
break;
} else {
targetIndex = targetIndex - 1;
targetLeftOrRight = LeftOrRight.left;
}
} else {
break;
}
}
}
//处理回调
if (findTarget) {
return new Target(cycleIndex, targetIndex, targetLeftOrRight);
} else {
return null;
}
}
public static class Target {
public final int cycleIndex;
public final int itemIndex;
public final LeftOrRight leftOrRight;
Target(int cycleIndex, int itemIndex, LeftOrRight leftOrRight) {
this.cycleIndex = cycleIndex;
this.itemIndex = itemIndex;
this.leftOrRight = leftOrRight;
}
}
/**
* 检测目标处测量状态
*
* @param cycleIndex 测期
* @param itemIndex 测点索引
* @param surveyorState 测量状态
* @param cachedData 测站数据
* @return 是否通过检测
*/
private static boolean checkDataCategory(final String stationId, int cycleIndex, int itemIndex,
LeftOrRight surveyorState,
final DataCategory targetCategory,
ICachedData cachedData) {
if (cachedData.isAbandonPoint(cycleIndex, itemIndex)) {
return false;
}
String pointId = cachedData.pointId(cycleIndex, itemIndex);
if (LeftOrRight.left == surveyorState) {
String leftKey = IdUtil.surveyorRecordKey(stationId, cycleIndex, pointId, LeftOrRight.left);
DataCategory dataCategory = cachedData.valueState(leftKey);
return dataCategory == targetCategory;
} else if (LeftOrRight.right == surveyorState) {
String rightKey = IdUtil.surveyorRecordKey(stationId, cycleIndex, pointId, LeftOrRight.right);
DataCategory dataCategory = cachedData.valueState(rightKey);
return dataCategory == targetCategory;
}
return false;
}
}

@ -0,0 +1,147 @@
package com.bingce.controlnetwork.surveyor.method;
import com.bingce.controlapphelper.surveyor.method.model.SdAngleValueType;
import com.bingce.controlnetwork.surveyor.data.ICachedData;
import com.bingce.controlnetwork.surveyor.data.ICycleRecorder;
import com.bingce.controlnetwork.surveyor.data.ISurveyorData;
import com.bingce.controlnetwork.surveyor.method.model.CacheResult;
import com.bingce.controlnetwork.surveyor.state.base.CheckToleranceUtil;
import com.bingce.utils.Util;
import java.util.ArrayList;
import java.util.List;
public class SingleCycleCheckMethod {
/**
* 检测测回内2c互差
*
* @param hor2cDiff 水平角2c互差限制
* @param ver2cDiff 垂直角i互差限制
* @return 错误信息 为空则无错
*/
public static String check(int measureWhat, double hor2cDiff, double ver2cDiff,
String stationId,
int cycleIndex,
ISurveyorData surveyorData,
ICycleRecorder cycleRecorder,
ICachedData cachedData) {
int pointCount = cachedData.pointCount();
List<Item> horErrorList = new ArrayList<>();
if (CheckToleranceUtil.checkAngleHor(measureWhat)) {
//检测 「测回内不同方向2c互差」
for (int i = 0; i < pointCount; i++) {
boolean abandonI = cachedData.isAbandonPoint(cycleIndex, i);
if (abandonI) {
continue;
}
for (int j = i + 1; j < pointCount; j++) {
boolean abandonJ = cachedData.isAbandonPoint(cycleIndex, j);
if (abandonJ) {
continue;
}
CacheResult i2C = ValueOf2cMethod.valueOf2C(SdAngleValueType.horAngle,
stationId, cycleIndex, i, surveyorData, cycleRecorder.currentCycleIndex(), cachedData);
CacheResult j2C = ValueOf2cMethod.valueOf2C(SdAngleValueType.horAngle,
stationId, cycleIndex, j, surveyorData, cycleRecorder.currentCycleIndex(), cachedData);
double absHor = Math.abs(i2C.value - j2C.value);
if (!j2C.validate || !i2C.validate || hor2cDiff < absHor) {
//没有通过检测
horErrorList.add(new Item(i, j, absHor));
}
}
}
}
List<Item> verErrorList = new ArrayList<>();
if (CheckToleranceUtil.checkAngleVer(measureWhat)) {
//检测 「测回内不同方向i互差」
for (int i = 0; i < pointCount; i++) {
if (CheckToleranceUtil.isIgnoreVerPoint(cachedData, cycleIndex, i)) {
continue;
}
for (int j = i + 1; j < pointCount; j++) {
if (CheckToleranceUtil.isIgnoreVerPoint(cachedData, cycleIndex, j)) {
continue;
}
CacheResult i2C = ValueOf2cMethod.valueOf2C(SdAngleValueType.verAngle,
stationId, cycleIndex, i, surveyorData, cycleRecorder.currentCycleIndex(), cachedData);
CacheResult j2C = ValueOf2cMethod.valueOf2C(SdAngleValueType.verAngle,
stationId, cycleIndex, j, surveyorData, cycleRecorder.currentCycleIndex(), cachedData);
double absVer = Math.abs(i2C.value - j2C.value);
if (!j2C.validate || !i2C.validate || ver2cDiff < absVer) {
//没有通过检测
verErrorList.add(new Item(i, j, absVer));
}
}
}
}
return errorString(hor2cDiff, ver2cDiff, cycleIndex,
horErrorList, verErrorList, cachedData);
}
private static String errorString(double horLimit, double verLimit, int cycleIndex,
List<Item> horErrorList, List<Item> verErrorList,
ICachedData cachedDataSource) {
if (horErrorList.isEmpty() && verErrorList.isEmpty()) {
return null;
}
StringBuilder stringBuilder = new StringBuilder();
if (!horErrorList.isEmpty()) {
stringBuilder.append("测回内不同方向2c互差超限(")
.append("限差:")
.append(horLimit)
.append("'')\n");
for (Item item : horErrorList) {
String point1 = cachedDataSource.pointName(cycleIndex, item.item1);
String point2 = cachedDataSource.pointName(cycleIndex, item.item2);
stringBuilder
.append(" |")
.append(point1)
.append(" - ")
.append(point2)
.append("|=")
.append(Util.formatDouble2String(item.difference, 1))
.append("\n");
}
}
if (!verErrorList.isEmpty()) {
stringBuilder.append("测回内不同方向i互差超限(")
.append("限差:")
.append(verLimit)
.append("'')\n");
for (Item item : verErrorList) {
String point1 = cachedDataSource.pointName(cycleIndex, item.item1);
String point2 = cachedDataSource.pointName(cycleIndex, item.item2);
stringBuilder
.append(" |")
.append(point1)
.append(" - ")
.append(point2)
.append("|=")
.append(Util.formatDouble2String(item.difference, 1))
.append("\n");
}
}
return stringBuilder.toString();
}
private static class Item {
final int item1;
final int item2;
final double difference;
public Item(int item1, int item2, double difference) {
this.item1 = item1;
this.item2 = item2;
this.difference = difference;
}
}
}

@ -10,15 +10,13 @@ import com.bingce.controlapphelper.datasource.database.point.PointRecord;
import com.bingce.controlapphelper.datasource.database.surveyorstation.ISurveyorStationDataSource;
import com.bingce.controlapphelper.datasource.database.surveyorstation.SurveyorStationRecord;
import com.bingce.controlapphelper.datasource.database.surveyorstation.model.SurveyorPoint;
import com.bingce.controlapphelper.surveyor.method.model.IStateDelegate;
import com.bingce.controlapphelper.util.Tools;
import com.bingce.controlnetwork.fragment.SelectReSurveyorPointFragment;
import com.bingce.controlnetwork.surveyor.method.model.IStateDelegate;
import com.bingce.utils.ThreadPoolUtil;
import java.util.ArrayList;
import java.util.List;
import com.bingce.controlnetwork.R;
public class SingleCycleTipsMethod {
/*
@ -29,8 +27,8 @@ public class SingleCycleTipsMethod {
FragmentManager fragmentManager, LifecycleOwner lifecycleOwner) {
//取消
delegate.onOptionTips(msg,
Tools.getString(R.string.retest_direction),
Tools.getString(R.string.retest_cycle),
"重测方向",
"重测本测回",
() -> {//选择重测方向
ThreadPoolUtil.execute(() -> reSurveyorPoint(stationId, delegate,
fragmentManager, lifecycleOwner));
@ -87,7 +85,7 @@ public class SingleCycleTipsMethod {
private static void reSurveyorCycle(String msg, String stationId,
int currentCycleIndex, IStateDelegate delegate,
FragmentManager fragmentManager, LifecycleOwner lifecycleOwner) {
delegate.onOptionTips(Tools.getString(R.string.tips_delete_current_cycle_surveyor_record),
delegate.onOptionTips("是否确定删除该测回所有数据?",
null, null,
() -> {
delegate.deleteSingleCycleData(currentCycleIndex);

@ -0,0 +1,646 @@
package com.bingce.controlnetwork.surveyor.method;
import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;
import androidx.annotation.WorkerThread;
import com.bingce.controlapphelper.datasource.database.SurveyorDatabaseFactory;
import com.bingce.controlapphelper.datasource.database.alonedistance.AloneDistanceRecord;
import com.bingce.controlapphelper.datasource.database.alonedistance.IAloneDistanceRecordDataSource;
import com.bingce.controlapphelper.datasource.database.alonedistance.WellDistance;
import com.bingce.controlapphelper.datasource.database.point.PointRecord;
import com.bingce.controlapphelper.datasource.database.project.IProjectDataSource;
import com.bingce.controlapphelper.datasource.database.project.ProjectRecord;
import com.bingce.controlapphelper.datasource.database.surveyorstation.SurveyorStationRecord;
import com.bingce.controlapphelper.datasource.database.surveyorstation.model.SurveyorPoint;
import com.bingce.controlapphelper.datasource.database.tolerance.detail.IToleranceDetailDataSource;
import com.bingce.controlapphelper.datasource.database.tolerance.detail.ToleranceDetailRecord;
import com.bingce.controlapphelper.model.LeftOrRight;
import com.bingce.controlapphelper.surveyor.method.RadianMethod;
import com.bingce.controlapphelper.surveyor.method.model.SdAngleValueType;
import com.bingce.controlapphelper.util.Tools;
import com.bingce.controlnetwork.model.AloneAdjustItem;
import com.bingce.controlnetwork.surveyor.data.FaultTolerantData;
import com.bingce.controlnetwork.surveyor.data.ICachedData;
import com.bingce.controlnetwork.surveyor.method.model.CacheResult;
import com.bingce.controlnetwork.surveyor.state.StateConstantsPla;
import com.bingce.controlnetwork.surveyor.state.base.CheckToleranceUtil;
import com.bingce.controlnetwork.util.IdUtil;
import com.bingce.controlnetwork.util.StationUtilPla;
import com.bingce.utils.Util;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import blankj.utilcode.util.ToastUtils;
public class SurveyorAdjustMethodPla {
private final static int ERROR_CODE_LEFT_RIGHT_COUNT_NOT_EQUAL = 1;
private final static int ERROR_CODE_ZERO_VALUE_COUNT_NOT_EQUAL = ERROR_CODE_LEFT_RIGHT_COUNT_NOT_EQUAL + 1;
@WorkerThread
public static AdjustResult calStationAdjust(SurveyorStationRecord stationRecord, ICachedData cachedData) {
return calStationAdjust(StateConstantsPla.VALUE_MEASURE_WHAT_DEFAULT, stationRecord, cachedData);
}
@WorkerThread
public static AdjustResult calStationAdjust(int measureWhat, SurveyorStationRecord stationRecord, ICachedData cachedData) {
if (stationRecord == null) {
return new AdjustResult("测站数据为空");
}
//2.读取项目数据
IProjectDataSource projectDataSource =
SurveyorDatabaseFactory.instance.getProjectDataSource();
ProjectRecord projectRecord = projectDataSource.getRecord(stationRecord.projectId);
if (projectRecord == null) {
return new AdjustResult("项目数据为空");
}
//3.读取限差数据
IToleranceDetailDataSource toleranceDetailDataSource =
SurveyorDatabaseFactory.instance.getToleranceDetailDataSource();
ToleranceDetailRecord toleranceDetailRecordTj =
toleranceDetailDataSource.getRecordSync(projectRecord.getToleranceId());
if (toleranceDetailRecordTj == null) {
return new AdjustResult("限差参数为空");
}
//4.测量次数,测回数
int surveyorCount = toleranceDetailRecordTj.getSurveyorCount();
int cycleCount = StationUtilPla.getCycleCount(measureWhat, stationRecord, toleranceDetailRecordTj);
boolean leftRightSurveyor = stationRecord.isLeftAndRightSurveyor();//左右角测量
//5.如果是左右角测量,判断是否超限
if (CheckToleranceUtil.checkAngleHor(measureWhat)
&& leftRightSurveyor) {
//获取单测回归零值
int leftCycleCount = 0;//左角测量时测回个数
List<Double> leftZeroes = new ArrayList<>();//左角归零值
int rightCycleCount = 0;//右角测量时测回个数
List<Double> rightZeroes = new ArrayList<>();//右角归零值
for (int cycleIndex = 0; cycleIndex < cycleCount; cycleIndex++) {
List<DeviationValueOfRadianMethod.AngleDistValue> values =
DeviationValueOfRadianMethod.zeroValueOfSingleCycle(measureWhat, stationRecord.getId(), cycleIndex, surveyorCount, cachedData);
if (cycleIndex % 2 == 0) {//左角归零
leftCycleCount++;
if (leftZeroes.isEmpty()) {
for (DeviationValueOfRadianMethod.AngleDistValue value : values) {
leftZeroes.add(value.horRadian);
}
} else {
for (int index = 0; index < values.size(); index++) {
if (index >= leftZeroes.size()) {
continue;
}
leftZeroes.set(index, leftZeroes.get(index) + values.get(index).horRadian);
}
}
} else {//右角归零
rightCycleCount++;
if (rightZeroes.isEmpty()) {
for (DeviationValueOfRadianMethod.AngleDistValue value : values) {
rightZeroes.add(value.horRadian);
}
} else {
for (int index = 0; index < values.size(); index++) {
if (index >= rightZeroes.size()) {
continue;
}
rightZeroes.set(index, rightZeroes.get(index) + values.get(index).horRadian);
}
}
}
}
//求左右角归零平均值
for (int index = 0; index < leftZeroes.size(); index++) {
leftZeroes.set(index, leftZeroes.get(index) / leftCycleCount);
}
for (int index = 0; index < rightZeroes.size(); index++) {
rightZeroes.set(index, rightZeroes.get(index) / rightCycleCount);
}
if (leftZeroes.size() != rightZeroes.size()) {
//左右角归零值个数不一样,计算错误
return new AdjustResult("计算错误(错误码" + ERROR_CODE_LEFT_RIGHT_COUNT_NOT_EQUAL + ")");
}
//检测左右角之和是否超限
final double TOP = Util.dmsDoubleToRadian(0.0004);
final double BOTTOM = 2 * Math.PI - TOP;
for (int index = 0; index < leftZeroes.size(); index++) {
double leftAngle = leftZeroes.get(index);
double rightAngle = rightZeroes.get(index);
double resultAngle = RadianMethod.formatRadian(leftAngle + rightAngle);
if (resultAngle < BOTTOM && resultAngle > TOP) {
return new AdjustResult("左右角之和超限!");
}
}
}
//6.左右角之和通过检测,则转为左角计算整体归零值
List<_VD> vds = new ArrayList<>();
Map<Integer, List<Double>> cycle2Zeroes = new HashMap<>();
for (int cycleIndex = 0; cycleIndex < cycleCount; cycleIndex++) {
List<DeviationValueOfRadianMethod.AngleDistValue> values =
DeviationValueOfRadianMethod.zeroValueOfSingleCycleInLeftOrientation(
measureWhat, stationRecord.getId(), cycleIndex, surveyorCount, cachedData);
List<Double> horZeroes = new ArrayList<>();
for (DeviationValueOfRadianMethod.AngleDistValue value : values) {
horZeroes.add(value.horRadian);
}
cycle2Zeroes.put(cycleIndex, horZeroes);
if (vds.isEmpty()) {
for (DeviationValueOfRadianMethod.AngleDistValue v : values) {
vds.add(new _VD(v.pointId, v.pointName, v.verRadian, v.distance, v.prismHeight, v.aloneDistance, v.isMeasureDistanceNot, v.isMeasureVerNot));
}
} else {
for (int index = 0; index < values.size(); index++) {
if (vds.size() <= index) {
return new AdjustResult("计算错误(错误码" + ERROR_CODE_ZERO_VALUE_COUNT_NOT_EQUAL + ")");
}
_VD hvd = vds.get(index);
DeviationValueOfRadianMethod.AngleDistValue angleDistValue = values.get(index);
// hvd.hor = DeviationValueOfRadianMethod.similarAverage(hvd.hor, angleDistValue.horRadian);
if (angleDistValue.verRadian != FaultTolerantData.ERROR_VER_ANGLE) {
hvd.ver += angleDistValue.verRadian;
} else {
hvd.ver = FaultTolerantData.ERROR_VER_ANGLE;
}
hvd.distance += angleDistValue.distance;
}
}
}
//水平角的归零值要特殊处理
//先计算结点数量,取最小值
int minPointSize = Integer.MAX_VALUE;
for (Map.Entry<Integer, List<Double>> entry : cycle2Zeroes.entrySet()) {
minPointSize = Math.min(minPointSize, entry.getValue() == null ? 0 : entry.getValue().size());
}
List<Double> zeros = new ArrayList<>();
if (minPointSize > 0) {
for (int pointIndex = 0; pointIndex < minPointSize; pointIndex++) {
List<Double> doubles = new ArrayList<>();
for (int cycleIndex = 0; cycleIndex < cycleCount; cycleIndex++) {
List<Double> zeroList = cycle2Zeroes.get(cycleIndex);
if (zeroList == null) {
break;
}
if (zeroList.size() <= pointIndex) {
break;
}
doubles.add(zeroList.get(pointIndex));
}
//计算平均值
double average = DeviationValueOfRadianMethod.similarAverage(doubles);
zeros.add(average);
}
}
//7.求归零平均值
ArrayList<Item> result = new ArrayList<>();
for (int pointIndex = 0; pointIndex < vds.size(); pointIndex++) {
_VD hvd = vds.get(pointIndex);
Item item = new Item(
hvd.pointId,
hvd.pointName,
zeros.size() <= pointIndex ? 0 : zeros.get(pointIndex),
getFinalAdjustVerAngle(hvd.ver, cycleCount),
// getFinalAdjustDistance(stationRecord.getAdditionConstantActual(), stationRecord.getMultiplyingConstantActual(), hvd.distance / cycleCount),
hvd.distance / cycleCount,
hvd.prismHeight, hvd.aloneDistance, hvd.isMeasureDistanceNot, hvd.isMeasureVerNot);
result.add(item);
}
return new AdjustResult(result);
}
private static double getFinalAdjustVerAngle(double hdvVer, int cycleCount) {
if (hdvVer == FaultTolerantData.ERROR_VER_ANGLE) {
return hdvVer;
}
return Math.PI / 2 - hdvVer / cycleCount;
}
private static double getFinalAdjustDistance(double a, double b, double distance) {
return Tools.getAmendDistance(a, b, 0, distance);
}
public static class AdjustResult {
public ArrayList<Item> result;
public String errorString;
public AdjustResult() {
}
public AdjustResult(ArrayList<Item> result) {
this.result = result;
errorString = "";
}
public AdjustResult(String errorString) {
this.result = null;
this.errorString = errorString;
}
public void setErrorString(String errorString) {
this.errorString = errorString;
}
public void setResult(ArrayList<Item> result) {
this.result = result;
}
}
/**
* 临时变量保存 水平垂直和距离
*/
private static class _VD {
final String pointId;
final String pointName;
double ver;
double distance;
String prismHeight;
boolean aloneDistance;
boolean isMeasureDistanceNot;
boolean isMeasureVerNot;
_VD(String pointId, String pointName, double v, double d, String prismHeight,
boolean aloneDistance, boolean isMeasureDistanceNot, boolean isMeasureVerNot) {
this.pointId = pointId;
this.pointName = pointName;
this.ver = v;
this.distance = d;
this.prismHeight = prismHeight;
this.aloneDistance = aloneDistance;
this.isMeasureDistanceNot = isMeasureDistanceNot;
this.isMeasureVerNot = isMeasureVerNot;
}
}
public static class Item implements Parcelable {
private String pointId;
private String pointName;
private double horAngle;
private double verAngle;
private double distance;
private String prismHeight;
protected boolean aloneDistance;
protected boolean isMeasureDistanceNot;
protected boolean isMeasureVerNot;
public Item() {
}
public Item(String pointId, String pointName, double horAngle, double verAngle, double distance,
String prismHeight, boolean aloneDistance, boolean isMeasureDistanceNot, boolean isMeasureVerNot) {
this.pointId = pointId;
this.pointName = pointName;
this.horAngle = horAngle;
this.verAngle = verAngle;
this.distance = distance;
this.prismHeight = prismHeight;
this.aloneDistance = aloneDistance;
this.isMeasureDistanceNot = isMeasureDistanceNot;
this.isMeasureVerNot = isMeasureVerNot;
}
public String getPointId() {
return pointId;
}
public String getPointName() {
return pointName;
}
public double getHorAngle() {
return horAngle;
}
public void setHorAngle(double horAngle) {
this.horAngle = horAngle;
}
public double getVerAngle() {
return verAngle;
}
public double getDistance() {
return distance;
}
public String getPrismHeight() {
return prismHeight;
}
public String getPrismHeightActual() {
if (TextUtils.isEmpty(prismHeight)) {
return "0";
}
return prismHeight;
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(this.pointId);
dest.writeString(this.pointName);
dest.writeDouble(this.horAngle);
dest.writeDouble(this.verAngle);
dest.writeDouble(this.distance);
dest.writeString(this.prismHeight);
dest.writeByte(this.aloneDistance ? (byte) 1 : (byte) 0);
}
public void readFromParcel(Parcel source) {
this.pointId = source.readString();
this.pointName = source.readString();
this.horAngle = source.readDouble();
this.verAngle = source.readDouble();
this.distance = source.readDouble();
this.prismHeight = source.readString();
this.aloneDistance = source.readByte() != 0;
}
protected Item(Parcel in) {
this.pointId = in.readString();
this.pointName = in.readString();
this.horAngle = in.readDouble();
this.verAngle = in.readDouble();
this.distance = in.readDouble();
this.prismHeight = in.readString();
this.aloneDistance = in.readByte() != 0;
}
public static final Creator<Item> CREATOR = new Creator<Item>() {
@Override
public Item createFromParcel(Parcel source) {
return new Item(source);
}
@Override
public Item[] newArray(int size) {
return new Item[size];
}
};
}
/**
* @param stationId
* @param cachedData
* @param isExcludeEveryPointError true 包含每个点的错误信息
* @return 分开观测垂直角平差
*/
@WorkerThread
public static List<AloneAdjustItem> calAloneVer(String stationId, ICachedData cachedData, boolean isExcludeEveryPointError) {
List<AloneAdjustItem> resultAdjustList = new ArrayList<>();
if (cachedData == null || cachedData.realPointCount() == 0)
return resultAdjustList;
//1.读取测站数据
SurveyorStationRecord stationRecord = SurveyorDatabaseFactory.instance.getSurveyorStation().getRecordSync(stationId);
if (stationRecord == null) {
ToastUtils.showShort("测站数据为空");
return resultAdjustList;
}
//2.读取项目数据
ProjectRecord projectRecord = SurveyorDatabaseFactory.instance.getProjectDataSource().getRecord(stationRecord.projectId);
if (projectRecord == null) {
ToastUtils.showShort("项目数据为空");
return resultAdjustList;
}
//3.读取限差数据
ToleranceDetailRecord toleranceDetailRecordTj = SurveyorDatabaseFactory.instance.getToleranceDetailDataSource().getRecordSync(projectRecord.getToleranceId());
if (toleranceDetailRecordTj == null) {
ToastUtils.showShort("限差参数为空");
return resultAdjustList;
}
int cycleCount = StationUtilPla.getCycleCount(StateConstantsPla.VALUE_MEASURE_WHAT_ANGLE_VER, stationRecord, toleranceDetailRecordTj);
int surveyorCount = toleranceDetailRecordTj.getSurveyorCount();
//遍历所有点
for (int pointIndex = 0; pointIndex < cachedData.realPointCount(); pointIndex++) {
//从1开始循环
SurveyorPoint point = cachedData.getSurveyorPoint(0, pointIndex);
String prismHeight = point.getPrismHeight();
String pointId = point.getOriginalPointId();
PointRecord pointRecord = SurveyorDatabaseFactory.instance.getPointDataSource().findByIdSync(pointId);
String pointName = pointRecord.name;
int verCalCount = 0;
double verSum = 0;
int errorCycleIndex = -1;
for (int cycleIndex = 0; cycleIndex < cycleCount; cycleIndex++) {
String leftRecordId = IdUtil.surveyorRecordKey(stationId, cycleIndex, pointId, LeftOrRight.left);
String rightRecordId = IdUtil.surveyorRecordKey(stationId, cycleIndex, pointId, LeftOrRight.right);
CacheResult cachedVerValue = AverageValueMethod.leftAndRightValue(SdAngleValueType.verAngle,
leftRecordId,
rightRecordId,
surveyorCount,
cachedData);
if (!cachedVerValue.validate) {
//点有个测回数据出问题
errorCycleIndex = cycleIndex;
break;
}
verSum += cachedVerValue.value;
verCalCount++;
}
if (errorCycleIndex == -1) {
resultAdjustList.add(new AloneAdjustItem(pointId, pointName, 0, Math.PI / 2 - verSum / verCalCount,
0, prismHeight,
false, false, false,
null));
} else {
//当前点平差异常
if (isExcludeEveryPointError) {
resultAdjustList.add(new AloneAdjustItem(pointId, pointName, 0, 0,
0, prismHeight,
false, false, false,
"第" + (errorCycleIndex + 1) + "测回数据异常"));
}
}
}
return resultAdjustList;
}
/**
* @param stationId
* @param cachedData
* @param isExcludeEveryPointError true 包含每个点的错误信息
* @return 单独测距平差数据
*/
@WorkerThread
public static List<AloneAdjustItem> calAloneDistance(String stationId, ICachedData cachedData, boolean isExcludeEveryPointError) {
List<AloneAdjustItem> resultAdjustList = new ArrayList<>();
if (cachedData == null || cachedData.realPointCount() == 0)
return resultAdjustList;
//1.读取测站数据
SurveyorStationRecord stationRecord = SurveyorDatabaseFactory.instance.getSurveyorStation().getRecordSync(stationId);
if (stationRecord == null) {
ToastUtils.showShort("测站数据为空");
return resultAdjustList;
}
//2.读取项目数据
ProjectRecord projectRecord = SurveyorDatabaseFactory.instance.getProjectDataSource().getRecord(stationRecord.projectId);
if (projectRecord == null) {
ToastUtils.showShort("项目数据为空");
return resultAdjustList;
}
//3.读取限差数据
ToleranceDetailRecord toleranceDetailRecordTj = SurveyorDatabaseFactory.instance.getToleranceDetailDataSource().getRecordSync(projectRecord.getToleranceId());
if (toleranceDetailRecordTj == null) {
ToastUtils.showShort("限差参数为空");
return resultAdjustList;
}
//4.测量次数,测回数
int cycleCount = ToleranceDetailRecord.ALONE_DISTANCE_CYCLE_COUNT;
int surveyorCount = ToleranceDetailRecord.ALONE_DISTANCE_MEASURE_COUNT;
//遍历所有点
for (int i = 0; i < cachedData.realPointCount(); i++) {
//从1开始循环
SurveyorPoint point = cachedData.getSurveyorPoint(0, i);
String prismHeight = point.getPrismHeight();
String pointId = point.getOriginalPointId();
PointRecord pointRecord = SurveyorDatabaseFactory.instance.getPointDataSource().findByIdSync(pointId);
String pointName = pointRecord.name;
IAloneDistanceRecordDataSource wellDistanceDataSource = SurveyorDatabaseFactory.instance.getAloneDistanceRecordDataSource();
AloneDistanceRecord wellRecord = wellDistanceDataSource.getRecordSync(stationId, 0, point.getOriginalPointId());
if (AloneDistanceRecord.isCompleteSurveyorNot(wellRecord)) {
if (isExcludeEveryPointError) {
resultAdjustList.add(new AloneAdjustItem(pointId, pointName, 0, 0, 0, prismHeight,
true, false, false,
"观测数据不完整"));
}
continue;
}
//测量原始数据
List<WellDistance> distanceValues = wellRecord.distanceValues;
// //获取测点的气象修正方式
// SurveyorPointScheduleRecord lastSurveyorPointSchedule = TjDbFactory.instance.getSurveyorPointScheduleDataSource().getLastSurveyorPointSchedule(stationId, pointId);
//
// if (lastSurveyorPointSchedule == null) {
// if (isExcludeEveryPointError) {
// resultAdjustList.add(new AloneAdjustItem(pointId, pointName, 0, 0, 0, prismHeight,
// true, false, false,
// "气象修正参数不完整"));
// }
// continue;
// }
// if (lastSurveyorPointSchedule.isHighPrecision()
// && !SurveyorPointScheduleRecord.checkHighAllWeatherAmendFinish(stationId, pointId, cycleCount)) {
// //判断高精度所有测回是否完
// if (isExcludeEveryPointError) {
// resultAdjustList.add(new AloneAdjustItem(pointId, pointName, 0, 0, 0, prismHeight,
// true, false, false,
// "气象修正参数不完整"));
// }
// continue;
// }
double average = 0;
for (int cycleIndex = 0; cycleIndex < cycleCount; cycleIndex++) {
double distanceAverageEveryCycle = Tools.calculateCollectionDoubleAverage(distanceValues.subList(cycleIndex * surveyorCount, (cycleIndex + 1) * surveyorCount), projectRecord.isShowSlopDistance());
// if (lastSurveyorPointSchedule.isHighPrecision()) {
// distanceAverageEveryCycle = getHighPrecisionDistance(stationId, cycleIndex, pointId, distanceAverageEveryCycle);
// } else if (lastSurveyorPointSchedule.isOrdinary()) {
// distanceAverageEveryCycle = getOrdinaryOrNoAmendDistance(stationId, pointId, SurveyorPointScheduleRecord.AMMEND_TYPE_ORDINARY, distanceAverageEveryCycle);
// } else {
// distanceAverageEveryCycle = getOrdinaryOrNoAmendDistance(stationId, pointId, SurveyorPointScheduleRecord.AMMEND_TYPE_NO, distanceAverageEveryCycle);
// }
average += distanceAverageEveryCycle;
}
resultAdjustList.add(new AloneAdjustItem(pointId, pointName, 0, 0, average / cycleCount, prismHeight,
true, false, false,
null));
}
return resultAdjustList;
}
/**
* 获取一般修正或不修正的距离
*/
// public static double getOrdinaryOrNoAmendDistance(String stationId, String pointId, int amendType, double distanceAverageEveryCycle) {
// ISurveyorPointWeatherAmendmentDataSource surveyorPointWeatherAmendmentDataSource = TjDbFactory.instance.getSurveyorPointWeatherAmendmentDataSource();
// SurveyorPointWeatherAmendmentRecord surveyorWeatherAmendment = surveyorPointWeatherAmendmentDataSource.getSurveyorWeatherAmendmentByStationPointAmendType(stationId, pointId, amendType);
// if (surveyorWeatherAmendment == null) {
// return distanceAverageEveryCycle;
// }
//
// if (surveyorWeatherAmendment.amendType == SurveyorPointScheduleRecord.AMMEND_TYPE_ORDINARY) {
// double ppm = getPpm(surveyorWeatherAmendment.getCalDampWarm(), surveyorWeatherAmendment.getCalAirPressure(), surveyorWeatherAmendment.getCalDryTemperature());
// return ToolsTj.getAmendDistance(ppm, surveyorWeatherAmendment.additionConstant, surveyorWeatherAmendment.multiplyingConstant, surveyorWeatherAmendment.targetAdvance, distanceAverageEveryCycle);
// } else {
// return ToolsTj.getAmendDistance(surveyorWeatherAmendment.additionConstant, surveyorWeatherAmendment.multiplyingConstant, surveyorWeatherAmendment.targetAdvance, distanceAverageEveryCycle);
// }
// }
/**
* 获取高精度修正距离
*/
// private static double getHighPrecisionDistance(String stationId, int cycleIndex, String pointId, double distanceAverageEveryCycle) {
// ISurveyorPointWeatherAmendmentDataSource surveyorPointWeatherAmendmentDataSource = TjDbFactory.instance.getSurveyorPointWeatherAmendmentDataSource();
// SurveyorPointWeatherAmendmentRecord surveyorWeatherAmendment = surveyorPointWeatherAmendmentDataSource.getSurveyorWeatherAmendment(stationId, cycleIndex, pointId, SurveyorPointScheduleRecord.AMMEND_TYPE_HIGH_PRECISION);
// if (surveyorWeatherAmendment == null) {
// return distanceAverageEveryCycle;
// }
//
// Map<String, WeatherAmendmentMethod.AmendBean> amemdMap = WeatherAmendmentMethod.getAmemdMap(surveyorWeatherAmendment);
//
// double stationDryTemperatureBeforeAmended = getTemperatureAmended(surveyorWeatherAmendment.stationDryTemperatureBefore, amemdMap, WeatherAmendmentConstants.KEY_STATION_DRY_TEMPERATURE_BEFORE);
// double stationDampWarmBeforeAmended = getTemperatureAmended(surveyorWeatherAmendment.stationDampWarmBefore, amemdMap, WeatherAmendmentConstants.KEY_STATION_DAMP_WARM_BEFORE);
// double stationAirPressureBeforeAmended = getAirpressureAmended(surveyorWeatherAmendment.stationAirPressureBefore, amemdMap, WeatherAmendmentConstants.KEY_STATION_AIR_PRESSURE_BEFORE, surveyorWeatherAmendment.stationDryTemperatureBefore);
// double targetDryTemperatureBeforeAmended = getTemperatureAmended(surveyorWeatherAmendment.targetDryTemperatureBefore, amemdMap, WeatherAmendmentConstants.KEY_TARGET_DRY_TEMPERATURE_BEFORE);
// double targetDampWarmBeforeAmended = getTemperatureAmended(surveyorWeatherAmendment.targetDampWarmBefore, amemdMap, WeatherAmendmentConstants.KEY_TARGET_DAMP_WARM_BEFORE);
// double targetAirPressureBeforeAmended = getAirpressureAmended(surveyorWeatherAmendment.targetAirPressureBefore, amemdMap, WeatherAmendmentConstants.KEY_TARGET_AIR_PRESSURE_BEFORE, surveyorWeatherAmendment.targetDryTemperatureBefore);
// double stationDryTemperatureAfterAmended = getTemperatureAmended(surveyorWeatherAmendment.stationDryTemperatureAfter, amemdMap, WeatherAmendmentConstants.KEY_STATION_DRY_TEMPERATURE_AFTER);
// double stationDampWarmAfterAmended = getTemperatureAmended(surveyorWeatherAmendment.stationDampWarmAfter, amemdMap, WeatherAmendmentConstants.KEY_STATION_DAMP_WARM_AFTER);
// double stationAirPressureAfterAmended = getAirpressureAmended(surveyorWeatherAmendment.stationAirPressureAfter, amemdMap, WeatherAmendmentConstants.KEY_STATION_AIR_PRESSURE_AFTER, surveyorWeatherAmendment.stationDryTemperatureAfter);
// double targetDryTemperatureAfterAmended = getTemperatureAmended(surveyorWeatherAmendment.targetDryTemperatureAfter, amemdMap, WeatherAmendmentConstants.KEY_TARGET_DRY_TEMPERATURE_AFTER);
// double targetDampWarmAfterAmended = getTemperatureAmended(surveyorWeatherAmendment.targetDampWarmAfter, amemdMap, WeatherAmendmentConstants.KEY_TARGET_DAMP_WARM_AFTER);
// double targetAirPressureAfterAmended = getAirpressureAmended(surveyorWeatherAmendment.targetAirPressureAfter, amemdMap, WeatherAmendmentConstants.KEY_TARGET_AIR_PRESSURE_AFTER, surveyorWeatherAmendment.targetDryTemperatureAfter);
//
// //求温度气压平均值
// double dryTemperatureAverage = ((stationDryTemperatureBeforeAmended + stationDryTemperatureAfterAmended) / 2 + (targetDryTemperatureBeforeAmended + targetDryTemperatureAfterAmended) / 2) / 2;
// double dampWarmTemperatureAverage = ((stationDampWarmBeforeAmended + stationDampWarmAfterAmended) / 2 + (targetDampWarmBeforeAmended + targetDampWarmAfterAmended) / 2) / 2;
// double airPressureAverage = ((stationAirPressureBeforeAmended + stationAirPressureAfterAmended) / 2 + (targetAirPressureBeforeAmended + targetAirPressureAfterAmended) / 2) / 2;
//
// //求ppm
// double ppm = getPpm(dampWarmTemperatureAverage, airPressureAverage, dryTemperatureAverage);
//
// return ToolsTj.getAmendDistance(ppm, surveyorWeatherAmendment.additionConstant, surveyorWeatherAmendment.multiplyingConstant, surveyorWeatherAmendment.targetAdvance, distanceAverageEveryCycle);
// }
}

@ -0,0 +1,119 @@
package com.bingce.controlnetwork.surveyor.method;
import com.bingce.controlapphelper.model.LeftOrRight;
import com.bingce.controlapphelper.surveyor.method.DeviationValueOfRadianMethod;
import com.bingce.controlapphelper.surveyor.method.RadianMethod;
import com.bingce.controlapphelper.surveyor.method.model.SdAngleValueType;
import com.bingce.controlnetwork.surveyor.data.ICachedData;
import com.bingce.controlnetwork.surveyor.data.ISurveyorData;
import com.bingce.controlnetwork.surveyor.method.model.CacheResult;
public class ValueOf2cMethod {
public static CacheResult valueOf2C(SdAngleValueType type,
String stationId,
int cycleIndex,
int pointIndex,
ISurveyorData surveyorData,
int surveyorCycleIndex,
ICachedData cachedData) {
CacheResult cachedValue = _valueOf2C(type, stationId, cycleIndex, pointIndex, surveyorData, surveyorCycleIndex, cachedData);
if (!cachedValue.validate) {
return cachedValue;
}
if (type == SdAngleValueType.horAngle || type == SdAngleValueType.verAngle) {
return new CacheResult(true, RadianMethod.radian2S(cachedValue.value));
}
return new CacheResult(true, cachedValue.value * 1000);
}
public static CacheResult valueOf2C(SdAngleValueType type,
String leftRecordId,
String rightRecordId,
int surveyorCount,
ICachedData cachedData) {
CacheResult cachedValue = _valueOf2C(type, leftRecordId, rightRecordId, surveyorCount, cachedData);
if (!cachedValue.validate) {
return cachedValue;
}
if (type == SdAngleValueType.horAngle || type == SdAngleValueType.verAngle) {
return new CacheResult(true, RadianMethod.radian2S(cachedValue.value));
}
return new CacheResult(true, cachedValue.value * 1000);
}
/**
* 2C值
*
* @param type 类型水平角垂直角斜距
* @return 返回相应类型的2c
*/
private static CacheResult _valueOf2C(SdAngleValueType type,
String stationId,
int cycleIndex,
int pointIndex,
ISurveyorData surveyorData,
int surveyorCycleIndex,
ICachedData cachedData) {
CacheResult leftValue = AverageValueMethod.leftOrRightValue(
type,
stationId,
cycleIndex,
pointIndex,
surveyorData,
surveyorCycleIndex,
cachedData, LeftOrRight.left);
CacheResult rightValue = AverageValueMethod.leftOrRightValue(
type,
stationId,
cycleIndex,
pointIndex,
surveyorData,
surveyorCycleIndex,
cachedData, LeftOrRight.right);
if (leftValue.validate && rightValue.validate) {
switch (type) {
case horAngle:
return new CacheResult(true, DeviationValueOfRadianMethod.radianAngleHor2C(leftValue.value, rightValue.value));
case verAngle:
return new CacheResult(true, DeviationValueOfRadianMethod.radianAngleVer2C(leftValue.value, rightValue.value));
case distance:
return new CacheResult(true, DeviationValueOfRadianMethod.distance2C(leftValue.value, rightValue.value));
}
}
return new CacheResult(false, -1);
}
private static CacheResult _valueOf2C(
SdAngleValueType type,
String leftRecordId,
String rightRecordId,
int surveyorCount,
ICachedData cachedData) {
CacheResult leftValue = AverageValueMethod.leftOrRightValue(
type,
leftRecordId,
surveyorCount,
cachedData);
CacheResult rightValue = AverageValueMethod.leftOrRightValue(
type,
rightRecordId,
surveyorCount,
cachedData);
if (leftValue.validate && rightValue.validate) {
switch (type) {
case horAngle:
return new CacheResult(true, DeviationValueOfRadianMethod.radianAngleHor2C(leftValue.value, rightValue.value));
case verAngle:
return new CacheResult(true, DeviationValueOfRadianMethod.radianAngleVer2C(leftValue.value, rightValue.value));
case distance:
return new CacheResult(true, DeviationValueOfRadianMethod.distance2C(leftValue.value, rightValue.value));
}
}
return new CacheResult(false, -1);
}
}

@ -0,0 +1,11 @@
package com.bingce.controlnetwork.surveyor.method.model;
public class CacheResult {
public final boolean validate;
public final double value;
public CacheResult(boolean validate, double value) {
this.validate = validate;
this.value = value;
}
}

@ -0,0 +1,18 @@
package com.bingce.controlnetwork.surveyor.method.model;
import java.util.List;
public interface IStateDelegate {
void onOptionTips(String msg,
String confirmButton,
String cancelButton,
Runnable confirmCallback,
Runnable cancelCallback,
Runnable ignoreCallback);
void resetSurveyorStateAndKeepPosition();
void resurveyPoints(int cycleIndex, List<String> pointIds);
void deleteSingleCycleData(int cycleIndex);
}

@ -0,0 +1,27 @@
package com.bingce.controlnetwork.surveyor.state;
import com.bingce.controlnetwork.surveyor.method.AutoSurveyorMethod;
public interface IAutoModeSwitcher {
boolean isAutoModeOpen();
boolean isAutoModeClose();
boolean isAutoModeInit();
void openAutoMode();
void closeAutoMode();
void resetAutoMode();
void isReadyAutoSurvey(AutoSurveyorMethod.CallBackLearnResultCode callBackLearnResultCode);
/**
* 自动测量过程中检测测量数据和设计数据是否匹配
* <p>
* 返回值为null就合法否则出错
*/
void isMeasuredValueMatchDesign(AutoSurveyorMethod.CallBackCheckDesign callBackCheckDesign);
}

@ -0,0 +1,13 @@
package com.bingce.controlnetwork.surveyor.state;
public interface ISurveyState {
/**
* 是否正在测量包括单步测量自动测量
*/
boolean isSurveying();
/**
* 是否正在自动测量
*/
boolean isAutoSurveying();
}

@ -0,0 +1,10 @@
package com.bingce.controlnetwork.surveyor.state;
/**
* 测量过程中将跳转到当前item处
* <p>
* 这个委托就是做这项任务
*/
public interface ISurveyorDataScrollDelegate {
void onScrollTo(int cycleIndex, int pointIndex);
}

@ -0,0 +1,54 @@
package com.bingce.controlnetwork.surveyor.state;
public class StateConstantsPla {
/**
* --------------------------measureWhat开始--------------------------------
* 值勿改
**/
/**
* 默认的 测角测距
*/
public static final int VALUE_MEASURE_WHAT_DEFAULT = 0;
/**
* 仅测距离
*/
public static final int VALUE_MEASURE_WHAT_DISTANCE = 1;
/**
* 仅测水平角
*/
public static final int VALUE_MEASURE_WHAT_ANGLE_HOR = 2;
/**
* 仅测垂直角
*/
public static final int VALUE_MEASURE_WHAT_ANGLE_VER = 3;
/**
* --------------------------measureWhat结束--------------------------------
**/
//measureWhat对应的传值key
public static final String KEY_IS_ALREADY_REMIND_USER_AIMING_AT_WIRE = "KEY_IS_ALREADY_REMIND_USER_AIMING_AT_WIRE";
public static boolean needLeftRight(int measureWhat) {
return measureWhat == VALUE_MEASURE_WHAT_DEFAULT || measureWhat == VALUE_MEASURE_WHAT_ANGLE_HOR;
}
public static boolean isMeasureDistance(int measureWhat) {
return measureWhat == VALUE_MEASURE_WHAT_DISTANCE;
}
public static boolean isMeasureVerAngle(int measureWhat) {
return measureWhat == VALUE_MEASURE_WHAT_ANGLE_VER;
}
public static boolean isZeroMeasureWhat(int measureWhat) {
return measureWhat == VALUE_MEASURE_WHAT_DEFAULT || measureWhat == VALUE_MEASURE_WHAT_ANGLE_HOR;
}
}

@ -0,0 +1,243 @@
package com.bingce.controlnetwork.surveyor.state;
import android.content.Context;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.WorkerThread;
import androidx.fragment.app.FragmentManager;
import androidx.lifecycle.LifecycleOwner;
import com.bingce.controlapphelper.datasource.database.SurveyorDatabaseFactory;
import com.bingce.controlapphelper.datasource.database.point.PointRecord;
import com.bingce.controlapphelper.datasource.database.surveyorstation.SurveyorStationRecord;
import com.bingce.controlapphelper.datasource.database.surveyorstation.model.SurveyorPoint;
import com.bingce.controlapphelper.datasource.database.tolerance.detail.ToleranceDetailRecord;
import com.bingce.controlapphelper.util.IUIRunner;
import com.bingce.controlapphelper.util.Tools;
import com.bingce.controlnetwork.surveyor.data.ICachedData;
import com.bingce.controlnetwork.surveyor.data.ICycleRecorder;
import com.bingce.controlnetwork.surveyor.data.IStationPointRecordCollect;
import com.bingce.controlnetwork.surveyor.data.ISurveyorData;
import com.bingce.controlnetwork.surveyor.state.base.AbstructStateManager;
import com.bingce.controlnetwork.surveyor.surveyor.ISurveyorListener;
import com.bingce.controlnetwork.surveyor.surveyor.ISurveyorRemindListener;
import com.bingce.controlnetwork.util.SupportAutoSurveyorUtil;
public class StateManagerPla extends AbstructStateManager {
private StateManagerPla(final int measureWhat,
final boolean supportAutoSurvey,//是否支持自动测量
final @NonNull SurveyorStationRecord stationRecord,
final @NonNull PointRecord stationPointRecord,
final @NonNull ToleranceDetailRecord toleranceRecord,
final @NonNull Context context,
final @NonNull IStationPointRecordCollect pointRecordCollect,
final @NonNull ISurveyorData surveyorData,
final @NonNull ICycleRecorder cycleRecorder,
final @NonNull ICachedData cachedData,
final @NonNull ISurveyorDataScrollDelegate scrollDelegate,
FragmentManager fragmentManager,
LifecycleOwner lifecycleOwner,
IUIRunner iuiRunner) {
super(measureWhat, supportAutoSurvey, stationRecord, stationPointRecord,
toleranceRecord, context, pointRecordCollect, surveyorData, cycleRecorder,
cachedData, scrollDelegate, fragmentManager, lifecycleOwner, iuiRunner);
}
@Override
protected void initState() {
_DoSurveyorState doSurveyorState = new _DoSurveyorState(this, this);
stateMap.put(StateType.doSurveyor, doSurveyorState);
stateMap.put(StateType.doAutoSurveyor, new _DoAutoSurveyorState(this, this));
stateMap.put(StateType.SurveyorFailure, new _SurveyorFailureState(this));
stateMap.put(StateType.doMove2NextValidate, new _DoMove2NextValidateState(this));
stateMap.put(StateType.doMoveBack, new _DoMoveBackState(this));
stateMap.put(StateType.doRecordClean, new _DoRecordCleanState(this));
stateMap.put(StateType.checkReadData, new _CheckReadDataState(this, this));
stateMap.put(StateType.isHalfCycleZeroCheckReady, new _IsHalfCycleZeroCheckReadyState(this));
stateMap.put(StateType.checkHalfCycleZero, new _CheckHalfCycleZeroState(this));
stateMap.put(StateType.isReady2CCheck, new _Is2CCheckReadyState(this));
stateMap.put(StateType.check2C, new _Check2CState(this));
stateMap.put(StateType.isSingleCycleCompleted, new _IsSingleCycleCompletedState(this));
stateMap.put(StateType.isAllCycleCompleted, new _IsAllCycleCompletedState(this, this));
stateMap.put(StateType.checkSingleCycle, new _CheckSingleCycleState(this));
stateMap.put(StateType.checkStation, new _CheckStationState(this));
stateMap.put(StateType.stationCheckedSuccess, new _CheckStationSuccessState(this));
stateMap.put(StateType.doDeleteAllCycle, new _DoDeleteAllCycleState(this));
stateMap.put(StateType.doDeleteCurrentCycle, new _DoDeleteCurrentCycleState(this));
stateMap.put(StateType.doCalScheduleSingleCycle, new _DoCalScheduleInSingleCycleState(this, this));
stateMap.put(StateType.doCalScheduleAllCycle, new _DoCalScheduleInAllCycleState(this, this));
stateMap.put(StateType.doCalAdjust, new _DoCalAdjustState(this));
stateMap.put(StateType.idle, new _IdleState(this, this));
stateMap.put(StateType.doWellMeasureRotationReady, new _DoWellMeasureRotationReadyState(this));
}
@Override
protected void refreshUiPage() {
getCachedData().notifyDateChange();
}
@Override
protected ISurveyorListener getISurveyorListener() {
return getDoSurveyorState();
}
@Override
protected ISurveyorRemindListener getISurveyorRemindListener() {
return getDoSurveyorState();
}
private _DoSurveyorState getDoSurveyorState() {
return (_DoSurveyorState) stateMap.get(StateType.doSurveyor);
}
public void doSurveyor() {
boolean inValidate = isInValidate();
boolean wellMeasureRotationReady = isWellMeasureRotationReady();
if (!(!inValidate || wellMeasureRotationReady)) {
//!inValidate是可以通过的状态
return;
}
if (Tools.isDeviceConnectedNot()) {
return;
}
Bundle bundle = new Bundle();
if (wellMeasureRotationReady) {
//当前是钢丝准备状态
//传给测量状态isAlreadyRemindUserAimingAtWire
bundle.putBoolean(StateConstantsPla.KEY_IS_ALREADY_REMIND_USER_AIMING_AT_WIRE, true);
}
enter(StateType.doSurveyor, bundle);
}
public void doAutoSurveyor() {
if (isInValidate()) {
return;
}
enter(StateType.doAutoSurveyor);
}
public void deleteCurrentStationSurveyorData() {
if (isInValidate()) {
return;
}
enter(StateType.doDeleteAllCycle, _DoDeleteAllCycleState.args(stationId()));
}
public void deleteCurrentStationSurveyorData(int cycleIndex) {
if (isInValidate()) {
return;
}
enter(StateType.doDeleteCurrentCycle, _DoDeleteCurrentCycleState.args(stationId(), cycleIndex));
}
public void stationCheck() {
if (isInValidate()) {
return;
}
enter(StateType.checkStation);
}
public void stationAdjust() {
if (isInValidate()) {
return;
}
enter(StateType.doCalAdjust);
}
public void switch2Cycle(int cycleIndex) {
if (isInValidate()) {
return;
}
_DoCalScheduleInSingleCycleState.enter(this, cycleIndex);
}
public void calScheduleWhenEnterSurveyFragment(int cycleIndex) {
if (isInValidate()) {
return;
}
_DoCalScheduleInAllCycleState.enter(this, cycleIndex);
}
public void moveBack() {
if (isInValidate()) {
return;
}
enter(StateType.doMoveBack);
}
//检测当前状态是否支持从外界主动改变状态
//如果是空闲或者是测站通过检测是有效的状态
private boolean isInValidate() {
return currentStateType != StateType.idle && StateType.stationCheckedSuccess != currentStateType;
}
private boolean isWellMeasureRotationReady() {
return StateType.doWellMeasureRotationReady == currentStateType;
}
@WorkerThread
public static StateManagerPla newInstance(int measureWhat,//仅测量水平角还是什么...
@NonNull SurveyorStationRecord stationRecord,
@NonNull Context context,
@NonNull FragmentManager fragmentManager,
@NonNull LifecycleOwner lifecycleOwner,
@NonNull ToleranceDetailRecord toleranceRecord,
@NonNull IStationPointRecordCollect pointRecordCollect,
@NonNull ISurveyorData surveyorData,
@NonNull ICycleRecorder cycleRecorder,
@NonNull ICachedData cachedData,
ISurveyorDataScrollDelegate scrollDelegate,
IUIRunner runner) {
//读取测点record
String stationPointId = null;
if (stationRecord.getItems() != null) {
for (SurveyorPoint stationItem : stationRecord.getItems()) {
if (SurveyorPoint.TYPE_STATION.equals(stationItem.getType())) {
stationPointId = stationItem.getPointId();
break;
}
}
}
PointRecord stationPointRecord = null;
if (stationPointId != null) {
stationPointRecord = SurveyorDatabaseFactory
.instance
.getPointDataSource()
.findByIdSync(stationPointId);
}
if (stationPointRecord == null) {
return null;
}
boolean supportAuto = SupportAutoSurveyorUtil.isSupportAuto();
return new StateManagerPla(measureWhat, supportAuto,
stationRecord,
stationPointRecord,
toleranceRecord,
context,
pointRecordCollect,
surveyorData,
cycleRecorder,
cachedData,
scrollDelegate,
fragmentManager, lifecycleOwner, runner);
}
@Override
public boolean isSurveying() {
return currentStateType == StateType.doSurveyor || currentStateType == StateType.doAutoSurveyor;
}
@Override
public boolean isAutoSurveying() {
return isAutoModeOpen();
}
}

@ -0,0 +1,36 @@
package com.bingce.controlnetwork.surveyor.state;
/*
* 标识状态类型
* */
public enum StateType {
idle,//空闲状态
SurveyorFailure,//仪器导致的测量失败
doCalScheduleSingleCycle,//计算单个测回中的测量进度---不会发生跳转
doCalScheduleAllCycle,//计算所有测回中的测量进度---可能发生跳转
doCalAdjust,//平差计算
doSurveyor,//测量 1
doAutoSurveyor,//自动测量
doRecordClean,//记录测量数据--目前没有发现错误 5
doMove2NextValidate,//移动到下一点执行测量
doMoveBack,//移动到上一测量结点
doDeleteCurrentCycle,//删除本测回数据
doDeleteAllCycle,//删除所有测回数据
doWellMeasureRotationReady,
isHalfCycleZeroCheckReady,//检测是否半测回完成 3
isReady2CCheck,//是否满足进行2c检测条件 4
isSingleCycleCompleted,//检测单个测回是否完成 6
isAllCycleCompleted,//检测整个测回是否完成
checkReadData,//读数检测 2
checkHalfCycleZero,//半测回归零差检测
check2C,//2c检测
checkSingleCycle,//单个测回内不同方向2c、方向i互差检测
checkStation,//测回间数据检测-- 同方向方向值互差、2c互差、垂直角互差、i互差
stationCheckedSuccess,//测站通过检测
checkTolerance,//检测限差
}

@ -0,0 +1,186 @@
package com.bingce.controlnetwork.surveyor.state;
import android.os.Bundle;
import android.text.TextUtils;
import com.bingce.controlapphelper.datasource.database.surveyorstation.model.SurveyorPoint;
import com.bingce.controlapphelper.datasource.database.tolerance.detail.ToleranceDetailRecord;
import com.bingce.controlapphelper.surveyor.method.model.SdAngleValueType;
import com.bingce.controlnetwork.bean.SurveyorScheduleConstants;
import com.bingce.controlnetwork.surveyor.data.ICachedData;
import com.bingce.controlnetwork.surveyor.data.ISurveyorData;
import com.bingce.controlnetwork.surveyor.method.ValueOf2cMethod;
import com.bingce.controlnetwork.surveyor.method.model.CacheResult;
import com.bingce.utils.Util;
import net.tatans.tensorflowtts.tts.TtsManager;
/*
* 检测2c
* */
class _Check2CState extends __BaseState {
public _Check2CState(StateManagerPla stateManager) {
super(StateType.check2C, stateManager);
}
@Override
public void enter(Bundle args) {
String error = check2C();
if (TextUtils.isEmpty(error)) {
navigation2(StateType.doRecordClean);
} else {
if (isAutoSurveyOpen()) {
TtsManager.getInstance().speak("二西超限,请检查");
}
optionTips(error,
"重测测回",
"重测目标",
() -> optionTipsWithStandStill("是否确定删除该测回所有数据?",
() -> {
String stationId = stationId();
int currentCycleIndex = getCycleRecorder().currentCycleIndex();
if (currentCycleIndex == 0) {
deleteAllLearnBaseData(measureWhat(), stationId, this::clearSurveyData);
} else {
clearSurveyData();
}
}),
this::enterIdleAndClearSurveyState,
this::enterIdleAndClearSurveyStateAndCloseAutoMode);
}
}
private String check2C() {
int measureWhat = measureWhat();
switch (measureWhat) {
case StateConstantsPla.VALUE_MEASURE_WHAT_DEFAULT:
// case StateConstants.VALUE_MEASURE_WHAT_ANGLE:
return checkAll();
case StateConstantsPla.VALUE_MEASURE_WHAT_ANGLE_HOR:
return checkAngleHor();
case StateConstantsPla.VALUE_MEASURE_WHAT_ANGLE_VER:
return checkAngleVer();
default:
return null;
}
}
private void clearSurveyData() {
String stationId = stationId();
int currentCycleIndex = getCycleRecorder().currentCycleIndex();
//删除数据
ICachedData cachedData = getCachedData();
cachedData.deleteSurveyorRecord(stationId, currentCycleIndex);
//更新进度
setStationScheduleForSingleCycle(currentCycleIndex, SurveyorScheduleConstants.STATUE_VALUE_NO_COMPLETED);
setStationScheduleForAllCycle(SurveyorScheduleConstants.STATUE_VALUE_NO_COMPLETED);
//重新查找目标开启测量
findTargetFromBeginInCurrentCycle(true);
}
private String checkAll() {
StringBuilder stringBuilder = new StringBuilder();
int currentIndex = getSurveyorData().currentIndex();
int cycleIndex = getCurrentCycleIndex();
ICachedData cachedData = getCachedData();
//检测水平角
String errorHor = checkAngleHor();
if (!TextUtils.isEmpty(errorHor)) {
stringBuilder.append(errorHor);
}
SurveyorPoint surveyorPoint = cachedData.getSurveyorPoint(cycleIndex, currentIndex);
boolean isWellSteel = cachedData.isWellSteelPoint(cycleIndex, currentIndex);
if (!isWellSteel && !surveyorPoint.isMeasureVerNot()) {
String errorVer = checkAngleVer();
if (!TextUtils.isEmpty(errorVer)) {
stringBuilder.append(errorHor);
}
}
if (!isWellSteel && !surveyorPoint.isMeasureDistanceNot()) {
String errorDistance = checkDistance();
if (!TextUtils.isEmpty(errorDistance)) {
stringBuilder.append(errorDistance);
}
}
return stringBuilder.toString();
}
private String checkAngleHor() {
StringBuilder stringBuilder = new StringBuilder();
ISurveyorData surveyorData = getSurveyorData();
int currentIndex = getSurveyorData().currentIndex();
String stationId = stationId();
int cycleIndex = getCurrentCycleIndex();
ICachedData cachedData = getCachedData();
ToleranceDetailRecord toleranceRecord = getToleranceRecord();
CacheResult value2C = ValueOf2cMethod.valueOf2C(SdAngleValueType.horAngle, stationId, cycleIndex, currentIndex,
surveyorData, getCycleRecorder().currentCycleIndex(), cachedData);
if (!value2C.validate || toleranceRecord.getHor2C() < Math.abs(value2C.value)) {
stringBuilder.append("水平角2c绝对值超限(限差:")
.append(toleranceRecord.getHor2C())
.append("'')\n")
.append(" 测量值:")
.append(Util.formatDouble2String(Math.abs(value2C.value), 1))
.append("''");
}
return stringBuilder.toString();
}
private String checkAngleVer() {
StringBuilder stringBuilder = new StringBuilder();
ISurveyorData surveyorData = getSurveyorData();
int currentIndex = getSurveyorData().currentIndex();
String stationId = stationId();
int cycleIndex = getCurrentCycleIndex();
ICachedData cachedData = getCachedData();
ToleranceDetailRecord toleranceRecord = getToleranceRecord();
CacheResult value2C = ValueOf2cMethod.valueOf2C(SdAngleValueType.verAngle, stationId, cycleIndex, currentIndex,
surveyorData, getCycleRecorder().currentCycleIndex(), cachedData);
if (!value2C.validate || toleranceRecord.getVerI() < Math.abs(value2C.value)) {
stringBuilder.append("\n竖直角i指标超限(限差:")
.append(toleranceRecord.getVerI())
.append("'')\n")
.append(" 测量值:")
.append(Util.formatDouble2String(Math.abs(value2C.value), 1))
.append("''");
}
return stringBuilder.toString();
}
private String checkDistance() {
StringBuilder stringBuilder = new StringBuilder();
ISurveyorData surveyorData = getSurveyorData();
int currentIndex = getSurveyorData().currentIndex();
String stationId = stationId();
int cycleIndex = getCurrentCycleIndex();
ICachedData cachedData = getCachedData();
ToleranceDetailRecord toleranceRecord = getToleranceRecord();
CacheResult value2C = ValueOf2cMethod.valueOf2C(SdAngleValueType.distance, stationId, cycleIndex, currentIndex,
surveyorData, getCycleRecorder().currentCycleIndex(), cachedData);
if (!value2C.validate || toleranceRecord.getSlopeLensDistanceDifference() < Math.abs(value2C.value)) {
stringBuilder.append("\n正倒镜距离较差超限(限差:")
.append(toleranceRecord.getSlopeLensDistanceDifference())
.append("mm)\n")
.append(" 测量值:")
.append(Util.formatDouble2String(Math.abs(value2C.value), 1))
.append("mm");
}
return stringBuilder.toString();
}
}

@ -1,20 +1,19 @@
package com.bingce.controlnetwork.surveyor.state.angledistance;
package com.bingce.controlnetwork.surveyor.state;
import android.os.Bundle;
import com.bingce.controlapphelper.datasource.database.tolerance.detail.ToleranceDetailRecord;
import com.bingce.controlapphelper.model.LeftOrRight;
import com.bingce.controlapphelper.surveyor.data.ICachedData;
import com.bingce.controlapphelper.surveyor.data.ISurveyorData;
import com.bingce.controlapphelper.surveyor.method.AverageValueMethod;
import com.bingce.controlapphelper.surveyor.method.DeviationValueOfRadianMethod;
import com.bingce.controlapphelper.surveyor.method.model.CacheResult;
import com.bingce.controlapphelper.surveyor.method.model.SdAngleValueType;
import com.bingce.controlapphelper.surveyor.state.StateType;
import com.bingce.controlnetwork.R;
import com.bingce.controlnetwork.surveyor.data.ICachedData;
import com.bingce.controlnetwork.surveyor.data.ISurveyorData;
import com.bingce.controlnetwork.surveyor.method.AverageValueMethod;
import com.bingce.controlnetwork.surveyor.method.DeviationValueOfRadianMethod;
import com.bingce.controlnetwork.surveyor.method.model.CacheResult;
import net.tatans.tensorflowtts.tts.TtsManager;
import com.bingce.controlnetwork.R;
/*
* 半测回归零检测 --- 只检测水平角
@ -23,13 +22,19 @@ class _CheckHalfCycleZeroState extends __BaseState {
private final static int RESULT_SUCCESS = 0;
private final static int RESULT_FAILURE = 1;
public _CheckHalfCycleZeroState(StateManager stateManager) {
public _CheckHalfCycleZeroState(StateManagerPla stateManager) {
super(StateType.checkHalfCycleZero, stateManager);
}
@Override
public void enter(Bundle args) {
if (isStationClosed()) {
if (measureWhat() == StateConstantsPla.VALUE_MEASURE_WHAT_ANGLE_VER) {
onCompleted(RESULT_SUCCESS);
return;
}
ISurveyorData surveyorDataSource = getSurveyorData();
int cycleIndex = getCycleRecorder().currentCycleIndex();
ICachedData stationSurveyorDataSource = getCachedData();
@ -39,18 +44,18 @@ class _CheckHalfCycleZeroState extends __BaseState {
CacheResult angleHorFirst = AverageValueMethod.leftOrRightValue(SdAngleValueType.horAngle,
stationId(),
cycleIndex,
0,
leftOrRight,
surveyorDataSource,
cycleIndex,
stationSurveyorDataSource);
getCycleRecorder().currentCycleIndex(),
stationSurveyorDataSource, leftOrRight);
CacheResult angleHorEnd = AverageValueMethod.leftOrRightValue(SdAngleValueType.horAngle,
stationId(),
cycleIndex,
pointCount - 1,
leftOrRight,
surveyorDataSource,
cycleIndex,
stationSurveyorDataSource);
getCycleRecorder().currentCycleIndex(),
stationSurveyorDataSource, leftOrRight);
if (!angleHorFirst.validate || !angleHorEnd.validate) {
onCompleted(RESULT_FAILURE);
} else {
@ -73,7 +78,7 @@ class _CheckHalfCycleZeroState extends __BaseState {
if (isAutoSurveyOpen()) {
TtsManager.getInstance().speak(getContext().getString(R.string.tips_error_half_cycle_zero_stop_survey));
}
failureTipsWithAutoStandStill(getContext().getString(R.string.tips_error_half_cycle_zero_stop_survey));
failureTipsWithAutoStandStill(getContext().getString(R.string.tips_error_half_cycle_zero_stop_survey), null);
} else {
throw new RuntimeException("半测回归零差 failure");
}

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

Loading…
Cancel
Save