军测第一个版本,改版

main_modify
huangwei 8 months ago
parent bb97a0f0f2
commit f291762ab3
  1. 7
      app/src/main/AndroidManifest.xml
  2. 12
      app/src/main/java/com/bingce/controlnetwork/App.java
  3. 3
      app/src/main/java/com/bingce/controlnetwork/activity/fragmentcontainer/FragmentContainer.java
  4. 13
      app/src/main/java/com/bingce/controlnetwork/adapter/SurveyorStationRecordsAdapter.java
  5. 58
      app/src/main/java/com/bingce/controlnetwork/adapter/SurveyorStationRecordsWellAdapter.java
  6. 88
      app/src/main/java/com/bingce/controlnetwork/bean/SurveyorScheduleConstants.java
  7. 11
      app/src/main/java/com/bingce/controlnetwork/event/AutoSurveyorButtonVisibleEvent.java
  8. 35
      app/src/main/java/com/bingce/controlnetwork/event/RefreshRollBackEvent.java
  9. 4
      app/src/main/java/com/bingce/controlnetwork/event/ReplaceSurveyorFragmentEvent.java
  10. 56
      app/src/main/java/com/bingce/controlnetwork/event/SurveyStateEvent.java
  11. 144
      app/src/main/java/com/bingce/controlnetwork/fragment/ComponentSurveyorStationListFragment.java
  12. 128
      app/src/main/java/com/bingce/controlnetwork/fragment/StationDataAdjustAloneVerOrDistanceDialogFragment.java
  13. 23
      app/src/main/java/com/bingce/controlnetwork/fragment/StationDataAdjustDialogFragment.java
  14. 110
      app/src/main/java/com/bingce/controlnetwork/fragment/StationSurveyorRecordFragment.java
  15. 10
      app/src/main/java/com/bingce/controlnetwork/fragment/stationsurvey/IMeasureOperate.java
  16. 213
      app/src/main/java/com/bingce/controlnetwork/fragment/stationsurvey/StationSettingCheckUtil.java
  17. 315
      app/src/main/java/com/bingce/controlnetwork/fragment/stationsurvey/StationSurveyorFragment.java
  18. 394
      app/src/main/java/com/bingce/controlnetwork/fragment/stationsurvey/angledistance/MeasureDistanceFragment.java
  19. 180
      app/src/main/java/com/bingce/controlnetwork/fragment/stationsurvey/angledistance/MeasureFragment.java
  20. 154
      app/src/main/java/com/bingce/controlnetwork/fragment/stationsurvey/base/BaseFragmentLazy.java
  21. 2
      app/src/main/java/com/bingce/controlnetwork/fragment/stationsurvey/base/MeasureBaseFragment.java
  22. 6
      app/src/main/java/com/bingce/controlnetwork/fragment/stationsurvey/heighttraverse/MeasureHeightTraverseFragment.kt
  23. 36
      app/src/main/java/com/bingce/controlnetwork/fragment/stationsurvey/heighttraverse/MeasureHeightTraverseSubFragment.java
  24. 476
      app/src/main/java/com/bingce/controlnetwork/fragment/stationsurvey/separate/StationSurveyorSeparateDistanceFragment.java
  25. 375
      app/src/main/java/com/bingce/controlnetwork/fragment/stationsurvey/separate/StationSurveyorSeparateFragment.java
  26. 475
      app/src/main/java/com/bingce/controlnetwork/fragment/stationsurvey/separate/StationSurveyorSeparateHorAngleFragment.java
  27. 469
      app/src/main/java/com/bingce/controlnetwork/fragment/stationsurvey/separate/StationSurveyorSeparateVerAngleFragment.java
  28. 129
      app/src/main/java/com/bingce/controlnetwork/fragment/stationsurvey/separate/StationSurveyorSepatateAdapter.java
  29. 500
      app/src/main/java/com/bingce/controlnetwork/fragment/stationsurvey/well/StationSurveyorWellDistanceDataFragment.java
  30. 457
      app/src/main/java/com/bingce/controlnetwork/fragment/stationsurvey/well/StationSurveyorWellFragment.java
  31. 167
      app/src/main/java/com/bingce/controlnetwork/fragment/stationsurvey/well/StationSurveyorWellLevelAngleDataFragment.java
  32. 186
      app/src/main/java/com/bingce/controlnetwork/model/AloneAdjustItem.java
  33. 18
      app/src/main/java/com/bingce/controlnetwork/model/StationCheckErrorItem.java
  34. 14
      app/src/main/java/com/bingce/controlnetwork/model/StationCheckErrorPoint.java
  35. 8
      app/src/main/java/com/bingce/controlnetwork/newui/stationlist/StationListFragment.kt
  36. 4
      app/src/main/java/com/bingce/controlnetwork/newui/stationsetting/StationSettingsActivity.kt
  37. 16
      app/src/main/java/com/bingce/controlnetwork/newui/stationsurveyor/ISurveyorMenuOperate.java
  38. 162
      app/src/main/java/com/bingce/controlnetwork/newui/stationsurveyor/StationSurveyorHomeActivity.kt
  39. 28
      app/src/main/java/com/bingce/controlnetwork/newui/stationsurveyor/StationSurveyorHomeViewModel.kt
  40. 1086
      app/src/main/java/com/bingce/controlnetwork/surveyor/data/CachedData.java
  41. 8
      app/src/main/java/com/bingce/controlnetwork/surveyor/data/CachedDataPointType.java
  42. 16
      app/src/main/java/com/bingce/controlnetwork/surveyor/data/FaultTolerantData.java
  43. 155
      app/src/main/java/com/bingce/controlnetwork/surveyor/data/ICachedData.java
  44. 8
      app/src/main/java/com/bingce/controlnetwork/surveyor/data/ICycleRecorder.java
  45. 8
      app/src/main/java/com/bingce/controlnetwork/surveyor/data/IDistanceTypeChangeListener.java
  46. 8
      app/src/main/java/com/bingce/controlnetwork/surveyor/data/IStationPointRecordCollect.java
  47. 83
      app/src/main/java/com/bingce/controlnetwork/surveyor/data/ISurveyorData.java
  48. 39
      app/src/main/java/com/bingce/controlnetwork/surveyor/data/SpeakCache.java
  49. 245
      app/src/main/java/com/bingce/controlnetwork/surveyor/data/SurveyorData.java
  50. 276
      app/src/main/java/com/bingce/controlnetwork/surveyor/method/AutoSurveyorMethod.java
  51. 156
      app/src/main/java/com/bingce/controlnetwork/surveyor/method/AverageValueMethod.java
  52. 577
      app/src/main/java/com/bingce/controlnetwork/surveyor/method/DeviationValueOfRadianMethod.java
  53. 181
      app/src/main/java/com/bingce/controlnetwork/surveyor/method/FindTargetMethod.java
  54. 147
      app/src/main/java/com/bingce/controlnetwork/surveyor/method/SingleCycleCheckMethod.java
  55. 10
      app/src/main/java/com/bingce/controlnetwork/surveyor/method/SingleCycleTipsMethod.java
  56. 642
      app/src/main/java/com/bingce/controlnetwork/surveyor/method/SurveyorAdjustMethodTj.java
  57. 119
      app/src/main/java/com/bingce/controlnetwork/surveyor/method/ValueOf2cMethod.java
  58. 11
      app/src/main/java/com/bingce/controlnetwork/surveyor/method/model/CacheResult.java
  59. 18
      app/src/main/java/com/bingce/controlnetwork/surveyor/method/model/IStateDelegate.java
  60. 27
      app/src/main/java/com/bingce/controlnetwork/surveyor/state/IAutoModeSwitcher.java
  61. 13
      app/src/main/java/com/bingce/controlnetwork/surveyor/state/ISurveyState.java
  62. 10
      app/src/main/java/com/bingce/controlnetwork/surveyor/state/ISurveyorDataScrollDelegate.java
  63. 54
      app/src/main/java/com/bingce/controlnetwork/surveyor/state/StateConstantsTj.java
  64. 243
      app/src/main/java/com/bingce/controlnetwork/surveyor/state/StateManagerTj.java
  65. 36
      app/src/main/java/com/bingce/controlnetwork/surveyor/state/StateType.java
  66. 186
      app/src/main/java/com/bingce/controlnetwork/surveyor/state/_Check2CState.java
  67. 37
      app/src/main/java/com/bingce/controlnetwork/surveyor/state/_CheckHalfCycleZeroState.java
  68. 163
      app/src/main/java/com/bingce/controlnetwork/surveyor/state/_CheckReadDataState.java
  69. 33
      app/src/main/java/com/bingce/controlnetwork/surveyor/state/_CheckSingleCycleState.java
  70. 411
      app/src/main/java/com/bingce/controlnetwork/surveyor/state/_CheckStationState.java
  71. 13
      app/src/main/java/com/bingce/controlnetwork/surveyor/state/_CheckStationSuccessState.java
  72. 30
      app/src/main/java/com/bingce/controlnetwork/surveyor/state/_DoAutoSurveyorState.java
  73. 47
      app/src/main/java/com/bingce/controlnetwork/surveyor/state/_DoCalAdjustState.java
  74. 35
      app/src/main/java/com/bingce/controlnetwork/surveyor/state/_DoCalScheduleInAllCycleState.java
  75. 31
      app/src/main/java/com/bingce/controlnetwork/surveyor/state/_DoCalScheduleInSingleCycleState.java
  76. 51
      app/src/main/java/com/bingce/controlnetwork/surveyor/state/_DoDeleteAllCycleState.java
  77. 53
      app/src/main/java/com/bingce/controlnetwork/surveyor/state/_DoDeleteCurrentCycleState.java
  78. 19
      app/src/main/java/com/bingce/controlnetwork/surveyor/state/_DoMove2NextValidateState.java
  79. 61
      app/src/main/java/com/bingce/controlnetwork/surveyor/state/_DoMoveBackState.java
  80. 44
      app/src/main/java/com/bingce/controlnetwork/surveyor/state/_DoRecordCleanState.java
  81. 187
      app/src/main/java/com/bingce/controlnetwork/surveyor/state/_DoSurveyorState.java
  82. 34
      app/src/main/java/com/bingce/controlnetwork/surveyor/state/_DoWellMeasureRotationReadyState.java
  83. 251
      app/src/main/java/com/bingce/controlnetwork/surveyor/state/_IdleState.java
  84. 15
      app/src/main/java/com/bingce/controlnetwork/surveyor/state/_Is2CCheckReadyState.java
  85. 41
      app/src/main/java/com/bingce/controlnetwork/surveyor/state/_IsAllCycleCompletedState.java
  86. 16
      app/src/main/java/com/bingce/controlnetwork/surveyor/state/_IsHalfCycleZeroCheckReadyState.java
  87. 19
      app/src/main/java/com/bingce/controlnetwork/surveyor/state/_IsSingleCycleCompletedState.java
  88. 12
      app/src/main/java/com/bingce/controlnetwork/surveyor/state/_SurveyorFailureState.java
  89. 306
      app/src/main/java/com/bingce/controlnetwork/surveyor/state/__BaseState.java
  90. 498
      app/src/main/java/com/bingce/controlnetwork/surveyor/state/alonedistance/StateManagerAloneDistance.java
  91. 75
      app/src/main/java/com/bingce/controlnetwork/surveyor/state/alonedistance/_CheckReadDataState.java
  92. 90
      app/src/main/java/com/bingce/controlnetwork/surveyor/state/alonedistance/_CheckSingleCycleState.java
  93. 195
      app/src/main/java/com/bingce/controlnetwork/surveyor/state/alonedistance/_CheckStationState.java
  94. 33
      app/src/main/java/com/bingce/controlnetwork/surveyor/state/alonedistance/_CheckStationSuccessState.java
  95. 32
      app/src/main/java/com/bingce/controlnetwork/surveyor/state/alonedistance/_DoAutoSurveyorState.java
  96. 74
      app/src/main/java/com/bingce/controlnetwork/surveyor/state/alonedistance/_DoCalAdjustState.java
  97. 108
      app/src/main/java/com/bingce/controlnetwork/surveyor/state/alonedistance/_DoCalScheduleInSingleCycleState.java
  98. 63
      app/src/main/java/com/bingce/controlnetwork/surveyor/state/alonedistance/_DoDeleteAllCycleState.java
  99. 55
      app/src/main/java/com/bingce/controlnetwork/surveyor/state/alonedistance/_DoDeleteCurrentCycleState.java
  100. 72
      app/src/main/java/com/bingce/controlnetwork/surveyor/state/alonedistance/_DoMove2NextValidateState.java
  101. Some files were not shown because too many files have changed in this diff Show More

@ -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

@ -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);

@ -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.StateConstantsTj;
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 StateConstantsTj.VALUE_MEASURE_WHAT_DISTANCE:
return STATION_TYPE_WELL_DISTANCE;
case StateConstantsTj.VALUE_MEASURE_WHAT_ANGLE_HOR:
return STATION_TYPE_SEPARATE_HOR_ANGLE;
case StateConstantsTj.VALUE_MEASURE_WHAT_ANGLE_VER:
return STATION_TYPE_SEPARATE_VER_ANGLE;
case StateConstantsTj.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.StateConstantsTj;
/*
* 刷新回退按钮
* */
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 == StateConstantsTj.VALUE_MEASURE_WHAT_DEFAULT
// || measureWhat == StateConstants.VALUE_MEASURE_WHAT_ANGLE
|| measureWhat == StateConstantsTj.VALUE_MEASURE_WHAT_ANGLE_HOR) {
return 0;
} else if (measureWhat == StateConstantsTj.VALUE_MEASURE_WHAT_ANGLE_VER) {
return 1;
} else if (measureWhat == StateConstantsTj.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);
}
}

@ -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.StateConstantsTj;
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 (StateConstantsTj.isMeasureVerAngle(measureWhatAloneAngleOrDistance)) {
return "垂直角";
} else if (StateConstantsTj.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 (StateConstantsTj.isMeasureVerAngle(measureWhatAloneAngleOrDistance)) {
return RadianMethod.dmsStringOf(item.getVerAngle());
} else if (StateConstantsTj.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,11 @@ 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.surveyor.method.SurveyorAdjustMethodTj;
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 +33,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";
@ -180,4 +183,16 @@ public class StationDataAdjustDialogFragment extends DialogFragment {
dialogFragment.setArguments(args);
dialogFragment.show(fragmentManager, StationDataAdjustDialogFragment.class.getName());
}
public static void showDialog(int measureWhat, ArrayList<SurveyorAdjustMethodTj.Item> finalItemList,
Boolean isShowSlopDistance,
FragmentManager fragmentManager) {
StationDataAdjustDialogFragment dialogFragment = new StationDataAdjustDialogFragment();
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, StationDataAdjustDialogFragment.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.StateConstantsTj;
import com.bingce.controlnetwork.surveyor.state.StateManagerTj;
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 StateManagerTj 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) {
StateManagerTj 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) {
StateManagerTj 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 = StateConstantsTj.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,
StateManagerTj stateManager = StateManagerTj.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, StateManagerTj 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.StateConstantsTj;
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(StateConstantsTj.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(), StateConstantsTj.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(), StateConstantsTj.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.StateConstantsTj;
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(StateConstantsTj.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(StateConstantsTj.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 StateConstantsTj.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.StateConstantsTj;
import com.bingce.controlnetwork.surveyor.state.StateManagerTj;
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 StateManagerTj 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() {
//TODO 收集测站测量信息失败,提示
}
@Override
public void onSuccess(boolean showSlopDistance, ICachedData cachedData, SurveyorData surveyorData, StateManagerTj stateManager) {
onCollectStationData(showSlopDistance, cachedData, surveyorData, stateManager);
surveyState = stateManager;
}
}
);
}
return view;
}
@WorkerThread
private void onCollectStationData(
boolean showSlopDistance,
ICachedData cachedData,
SurveyorData surveyorData,
StateManagerTj 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, StateConstantsTj.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(StateConstantsTj.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());
StateManagerTj stateManager = StateManagerTj.newInstance(
StateConstantsTj.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, StateManagerTj 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 StateConstantsTj.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(), StateConstantsTj.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.StateConstantsTj;
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(StateConstantsTj.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(
StateConstantsTj.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 StateConstantsTj.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.StateConstantsTj;
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, StateConstantsTj.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(StateConstantsTj.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(StateConstantsTj.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 StateConstantsTj.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.StateConstantsTj;
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(StateConstantsTj.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(), StateConstantsTj.VALUE_MEASURE_WHAT_DEFAULT);
} else {
scheduleId = SurveyorScheduleConstants.stationCurrentCycleKey(stationId(), StateConstantsTj.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.StateConstantsTj;
import com.bingce.controlnetwork.surveyor.state.StateManagerTj;
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 StateManagerTj 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, StateManagerTj 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) {
StateManagerTj 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, StateConstantsTj.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(StateConstantsTj.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,
StateManagerTj stateManager = StateManagerTj.newInstance(
StateConstantsTj.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, StateManagerTj 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 StateConstantsTj.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;
}

@ -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)
}
}

@ -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)
}

@ -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;
}
}

@ -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,642 @@
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.StateConstantsTj;
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 SurveyorAdjustMethodTj {
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(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 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(StateConstantsTj.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, 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;
// }
// TODO: 2024/8/30
resultAdjustList.add(new AloneAdjustItem(pointId, pointName, 0, 0, 1, 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 StateConstantsTj {
/**
* --------------------------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;//原3
/**
* 仅测垂直角
*/
public static final int VALUE_MEASURE_WHAT_ANGLE_VER = 3;//原4
/**
* --------------------------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 StateManagerTj extends AbstructStateManager {
private StateManagerTj(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(StateConstantsTj.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 StateManagerTj 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 StateManagerTj(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(StateManagerTj 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 StateConstantsTj.VALUE_MEASURE_WHAT_DEFAULT:
// case StateConstants.VALUE_MEASURE_WHAT_ANGLE:
return checkAll();
case StateConstantsTj.VALUE_MEASURE_WHAT_ANGLE_HOR:
return checkAngleHor();
case StateConstantsTj.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(StateManagerTj stateManager) {
super(StateType.checkHalfCycleZero, stateManager);
}
@Override
public void enter(Bundle args) {
if (isStationClosed()) {
if (measureWhat() == StateConstantsTj.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");
}

@ -0,0 +1,163 @@
package com.bingce.controlnetwork.surveyor.state;
import android.os.Bundle;
import com.bingce.controlapphelper.datasource.database.surveyorstation.model.SurveyorPoint;
import com.bingce.controlapphelper.surveyor.method.RadianMethod;
import com.bingce.controlnetwork.surveyor.data.ISurveyorData;
import com.bingce.controlnetwork.surveyor.method.DeviationValueOfRadianMethod;
import net.tatans.tensorflowtts.tts.TtsManager;
/*
* 检测当前测量数据读数互差
* */
class _CheckReadDataState extends __BaseState {
private static final int RESULT_SUCCESS = 0;
private static final int RESULT_FAILURE_HOR = 1;
private static final int RESULT_FAILURE_VER = 2;
private static final int RESULT_FAILURE_DISTANCE = 3;
private final IAutoModeSwitcher autoModeSwitcher;
public _CheckReadDataState(StateManagerTj stateManager, IAutoModeSwitcher autoModeSwitcher) {
super(StateType.checkReadData, stateManager);
this.autoModeSwitcher = autoModeSwitcher;
}
@Override
public void enter(Bundle args) {
//先检测测量值和设计值是否匹配(仅在自动测量打开下检测)
autoModeSwitcher.isMeasuredValueMatchDesign(error -> {
if (error != null) {
failureTipsWithAutoStandStill(error, null);
return;
}
int surveyorCount = getToleranceRecord().getSurveyorCount();
if (surveyorCount <= 1) {//单次测量,直接通过检测
onCompleted(RESULT_SUCCESS);
} else {//多次测量,执行检测
int measureWhat = measureWhat();
int resultCode = RESULT_SUCCESS;
switch (measureWhat) {
case StateConstantsTj.VALUE_MEASURE_WHAT_DEFAULT:
// case StateConstants.VALUE_MEASURE_WHAT_ANGLE:
resultCode = checkAll();
break;
case StateConstantsTj.VALUE_MEASURE_WHAT_ANGLE_HOR:
resultCode = checkAngleHor();
break;
case StateConstantsTj.VALUE_MEASURE_WHAT_ANGLE_VER:
resultCode = checkAngleVer();
break;
}
onCompleted(resultCode);
}
});
}
private void onCompleted(int result) {
if (RESULT_SUCCESS == result) {
boolean checkLeftNot = checkLeftNot(false);
if (checkLeftNot) {
return;
}
navigation2(StateType.isHalfCycleZeroCheckReady);
} else {
String msg = "";
switch (result) {
case RESULT_FAILURE_HOR:
msg = "水平角读数超限,请重新观测该目标.";
break;
case RESULT_FAILURE_VER:
msg = "垂直角读数超限,请重新观测该目标.";
break;
case RESULT_FAILURE_DISTANCE:
msg = "斜距读数超限,请重新观测该目标.";
break;
default:
navigation2(StateType.idle);
return;
}
if (isAutoSurveyOpen()) {
TtsManager.getInstance().speak(msg);
}
failureTipsWithAutoStandStill(msg, null);
}
}
/**
* 斜距两次读数差
*
* @param distance1 读数1
* @param distance2 读数2
* @return 读数差(单位毫米)
*/
public static double distanceReadDiff(double distance1, double distance2) {
return Math.abs(distance1 - distance2) * 1000;
}
private int checkAll() {
// ISurveyorData surveyorDataSource = getSurveyorData();
SurveyorPoint surveyorPoint = getCachedData().getSurveyorPoint(getCurrentCycleIndex(), getCurrentItemIndex());
// double horDifference = getToleranceRecord().getHorReadDifference();
// double verDifference = getToleranceRecord().getVerReadDifference();
// double distanceDifference = getToleranceRecord().getSlopeReadDifference();
// double horDiffRadian = DeviationValueOfRadianMethod.similarRadianDiff(surveyorDataSource.getAngleHor1(), surveyorDataSource.getAngleHor2());
// double verDiffRadian = DeviationValueOfRadianMethod.similarRadianDiff(surveyorDataSource.getAngleVer1(), surveyorDataSource.getAngleVer2());
int resultCode = checkAngleHor();
if (resultCode == RESULT_FAILURE_HOR) {
return resultCode;
}
if (!isWellSteel() && !surveyorPoint.isMeasureVerNot()) {
resultCode = checkAngleVer();
if (resultCode == RESULT_FAILURE_VER) {
return resultCode;
}
}
if (!isWellSteel() && !surveyorPoint.isMeasureDistanceNot()) {
resultCode = checkDistance();
if (resultCode == RESULT_FAILURE_DISTANCE) {
return resultCode;
}
}
return RESULT_SUCCESS;
}
private int checkAngleVer() {
ISurveyorData surveyorDataSource = getSurveyorData();
double verDifference = getToleranceRecord().getVerReadDifference();
double verDiffRadian = DeviationValueOfRadianMethod.similarRadianDiff(surveyorDataSource.getAngleVer1(), surveyorDataSource.getAngleVer2());
int resultCode = RESULT_SUCCESS;
if (verDifference < RadianMethod.radian2S(verDiffRadian)) {
resultCode = RESULT_FAILURE_VER;
}
return resultCode;
}
private int checkAngleHor() {
ISurveyorData surveyorDataSource = getSurveyorData();
double horDifference = getToleranceRecord().getHorReadDifference();
double horDiffRadian = DeviationValueOfRadianMethod.similarRadianDiff(surveyorDataSource.getAngleHor1(), surveyorDataSource.getAngleHor2());
int resultCode = RESULT_SUCCESS;
if (horDifference < RadianMethod.radian2S(horDiffRadian)) {
resultCode = RESULT_FAILURE_HOR;
}
return resultCode;
}
private int checkDistance() {
ISurveyorData surveyorDataSource = getSurveyorData();
double distanceDifference = getToleranceRecord().getSlopeReadDifference();
int resultCode = RESULT_SUCCESS;
if (distanceDifference < distanceReadDiff(surveyorDataSource.getDistance1(), surveyorDataSource.getDistance2())) {
resultCode = RESULT_FAILURE_DISTANCE;
}
return resultCode;
}
}

@ -1,30 +1,28 @@
package com.bingce.controlnetwork.surveyor.state.angledistance;
package com.bingce.controlnetwork.surveyor.state;
import android.os.Bundle;
import com.bingce.controlapphelper.datasource.database.schedule.SurveyorScheduleConstants;
import com.bingce.controlapphelper.datasource.database.surveyorrecord.SurveyorRecord;
import com.bingce.controlapphelper.datasource.database.tolerance.detail.ToleranceDetailRecord;
import com.bingce.controlapphelper.model.DataCategory;
import com.bingce.controlapphelper.model.LeftOrRight;
import com.bingce.controlapphelper.surveyor.data.ICachedData;
import com.bingce.controlapphelper.surveyor.data.ICycleRecorder;
import com.bingce.controlapphelper.surveyor.data.ISurveyorData;
import com.bingce.controlapphelper.surveyor.method.SingleCycleCheckMethod;
import com.bingce.controlapphelper.surveyor.state.StateType;
import com.bingce.controlapphelper.util.IdUtil;
import com.bingce.controlapphelper.util.Tools;
import com.bingce.controlnetwork.R;
import com.bingce.controlnetwork.bean.SurveyorScheduleConstants;
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.SingleCycleCheckMethod;
import com.bingce.controlnetwork.surveyor.method.SingleCycleTipsMethod;
import com.bingce.controlnetwork.util.IdUtil;
import net.tatans.tensorflowtts.tts.TtsManager;
/**
* 测回内不同方向2c方向i互差检测
*/
class _CheckSingleCycleState extends __BaseState {
public _CheckSingleCycleState(StateManager stateManager) {
public _CheckSingleCycleState(StateManagerTj stateManager) {
super(StateType.checkSingleCycle, stateManager);
}
@ -39,10 +37,10 @@ class _CheckSingleCycleState extends __BaseState {
for (int index = 0; index < pointCount; index++) {
String pointId = cachedDataSource.pointId(currentCycleIndex, index);
String keyLeft = IdUtil.createSurveyorRecordId(stationId, currentCycleIndex, pointId, LeftOrRight.left);
String keyLeft = IdUtil.surveyorRecordKey(stationId, currentCycleIndex, pointId, LeftOrRight.left);
SurveyorRecord left = cachedDataSource.getSurveyorRecord(keyLeft);
_changeDirtyRecord2NormalBeforeCheck(left, cachedDataSource);
String keyRight = IdUtil.createSurveyorRecordId(stationId, currentCycleIndex, pointId, LeftOrRight.right);
String keyRight = IdUtil.surveyorRecordKey(stationId, currentCycleIndex, pointId, LeftOrRight.right);
SurveyorRecord right = cachedDataSource.getSurveyorRecord(keyRight);
_changeDirtyRecord2NormalBeforeCheck(right, cachedDataSource);
}
@ -71,15 +69,16 @@ class _CheckSingleCycleState extends __BaseState {
ToleranceDetailRecord toleranceRecord = getToleranceRecord();
ISurveyorData surveyorDataSource = getSurveyorData();
ICycleRecorder cycleRecorder = getCycleRecorder();
ICachedData stationSurveyorDataSource = getCachedData();
ICachedData cachedData = getCachedData();
//1.执行单测回内检测
String error = SingleCycleCheckMethod.check(
measureWhat(),
toleranceRecord.getHorCycleDirect2CDifference(), toleranceRecord.getVerCycleDirectIDifference(),
stationId(), cycleRecorder.currentCycleIndex(), surveyorDataSource, stationSurveyorDataSource);
stationId(), cycleRecorder.currentCycleIndex(), surveyorDataSource, cycleRecorder, cachedData);
if (error != null) {
if (isAutoSurveyOpen()) {
TtsManager.getInstance().speak(Tools.getString(R.string.check_cycle_inner_failed));
TtsManager.getInstance().speak("未通过测回内检测,请检查");
}
//TODO 这里可能存在不对测回内错误处理的情况,后面应该兼容处理下
SingleCycleTipsMethod.showTips(error, stationId(), cycleRecorder.currentCycleIndex(),
@ -93,7 +92,7 @@ class _CheckSingleCycleState extends __BaseState {
private void onSuccess() {
//更新测量进度
setSingleCycleSchedule(getCycleRecorder().currentCycleIndex(),
setStationScheduleForSingleCycle(getCycleRecorder().currentCycleIndex(),
SurveyorScheduleConstants.STATUE_VALUE_CHECKED);
//跳转

@ -0,0 +1,411 @@
package com.bingce.controlnetwork.surveyor.state;
import android.os.Bundle;
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.IPointDataSource;
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.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.SurveyorCycleUtil;
import com.bingce.controlnetwork.bean.SurveyorScheduleConstants;
import com.bingce.controlnetwork.fragment.SelectReSurveyorPointFragment;
import com.bingce.controlnetwork.model.StationCheckErrorItem;
import com.bingce.controlnetwork.model.StationCheckErrorPoint;
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.AverageValueMethod;
import com.bingce.controlnetwork.surveyor.method.DeviationValueOfRadianMethod;
import com.bingce.controlnetwork.surveyor.method.ValueOf2cMethod;
import com.bingce.controlnetwork.surveyor.method.model.CacheResult;
import com.bingce.controlnetwork.surveyor.state.base.CheckToleranceUtil;
import com.bingce.controlnetwork.util.IdUtil;
import com.bingce.utils.Util;
import java.util.ArrayList;
import java.util.List;
/**
* 执行测站检测
* <p>
* 前置条件
* 所有测回都完成测量并且通过测回内检测
*/
class _CheckStationState extends __BaseState {
public _CheckStationState(StateManagerTj stateManager) {
super(StateType.checkStation, stateManager);
}
@Override
public void enter(Bundle args) {
//执行测站检测
String error = _stationCheck(getStation(), getToleranceRecord(), getCachedData());
if (error == null || error.isEmpty()) {
//进入finish状态
navigation2(StateType.stationCheckedSuccess);
} else {
showErrorTips(error, stationId(), getCycleCount(),
getSurveyorData(), getCycleRecorder(), getCachedData(),
this,
fragmentManager(),
lifecycleOwner());
}
}
/**
* 提示错误信息并让用户选择下一步操作
*/
static void showErrorTips(String msg, String stationId, int cycleCount,
ISurveyorData surveyorDataSource,
ICycleRecorder cycleRecorder,
ICachedData stationSurveyorDataSource,
__BaseState state,
FragmentManager fragmentManager, LifecycleOwner lifecycleOwner) {
state.optionTips(msg,
"重测方向",
"重测测站",
() -> state.runOnBackground(() -> reSurveyorPoint(stationId, cycleCount,
cycleRecorder, stationSurveyorDataSource,
state, fragmentManager, lifecycleOwner)),
() -> reSurveyorStation(msg, stationId, cycleCount,
surveyorDataSource, cycleRecorder, stationSurveyorDataSource,
state, fragmentManager, lifecycleOwner),
() -> state.enterIdleAndClearSurveyStateAndResetAutoMode(true));
}
@WorkerThread
static void reSurveyorPoint(String stationId, int cycleCount,
ICycleRecorder cycleRecorder,
ICachedData cachedData,
__BaseState state,
FragmentManager fragmentManager, LifecycleOwner lifecycleOwner) {
//弹框提示选择重测数据
ISurveyorStationDataSource dataSource = SurveyorDatabaseFactory.instance.getSurveyorStation();
SurveyorStationRecord instance = dataSource.getRecordSync(stationId);
if (instance == null) {
state.enterIdleAndClearSurveyStateAndResetAutoMode(true);
return;
}
IPointDataSource pointDataSource = SurveyorDatabaseFactory.instance.getPointDataSource();
List<SurveyorPoint> stationItems = instance.getItems();
ArrayList<String> ids = new ArrayList<>();
ArrayList<String> names = new ArrayList<>();
for (SurveyorPoint item : stationItems) {
if (item.isAbandon()) {
continue;
}
if (!SurveyorPoint.TYPE_POINT.equals(item.getType())) {
continue;
}
PointRecord pointRecord = pointDataSource.findByIdSync(item.getPointId());
if (pointRecord == null) {
continue;
}
ids.add(pointRecord.id);
names.add(pointRecord.name);
}
state.runOnUI(() -> SelectReSurveyorPointFragment.pick(
fragmentManager,
lifecycleOwner,
cycleCount,
instance.leftAndRightSurveyor,
ids,
names,
(cycleIndex, pointIds) -> {
if (pointIds == null || pointIds.isEmpty()) {
state.enterIdleAndClearSurveyStateAndResetAutoMode(true);
} else {
//记录补测数据类型,切换测回
cachedData.markReSurveyor(stationId, cycleIndex, pointIds);
cycleRecorder.changeCycleIndex(cycleIndex);
//更新测量状态
state.setStationCycle(cycleIndex);
state.setStationScheduleForAllCycle(SurveyorScheduleConstants.STATUE_VALUE_NO_COMPLETED);
state.setStationScheduleForSingleCycle(cycleIndex, SurveyorScheduleConstants.STATUE_VALUE_NO_COMPLETED);
//查找新测量目标
state.findTargetFromBeginInCurrentCycle(true);
}
}
));
}
static void reSurveyorStation(String msg, String stationId, int cycleCount,
ISurveyorData surveyorData,
ICycleRecorder cycleRecorder,
ICachedData cachedData,
__BaseState state,
FragmentManager fragmentManager, LifecycleOwner lifecycleOwner) {
state.optionTips("是否确定删除该测站所有数据?", null, null,
() -> {//1.选择删除测站所有数据,则执行相应逻辑
//删除数据
cachedData.deleteSurveyorRecord(stationId);
//更新测量进度
state.setStationScheduleForAllCycle(SurveyorScheduleConstants.STATUE_VALUE_NO_COMPLETED);
for (int index = 0; index < cycleCount; index++) {
state.setStationScheduleForSingleCycle(index, SurveyorScheduleConstants.STATUE_VALUE_NO_COMPLETED);
}
//新增
state.setStationCycle(0);
//重新测量
state.findTargetFromBeginInCurrentCycle(true);
},
() -> {//2.如果用户不选择删除,则循环提示,让他重新在重测和删除做选择
//循环显示
showErrorTips(msg, stationId, cycleCount,
surveyorData, cycleRecorder, cachedData, state,
fragmentManager, lifecycleOwner);
},
() -> state.enterIdleAndClearSurveyStateAndResetAutoMode(true));//3.如果用户忽略,则停留在当前位置
}
//检测合法性
/**
* 检测所有测回数据
* <p>
* 无自动闭合情况下为了兼容左右角测量结果根据pointId将所有测量数据存入map中
* 根据左角测量来检测测回间同方向值互差所有测回的归零值使用左角第一个point来做0点
* <p>
* 如果是自动闭合情况则忽略左右角测量直接按照itemIndex依次计算第个测回的归零值
* 使用每次循环的itemIndex=0做0点
*
* @param toleranceRecord 限差
* @param cachedDataSource 缓存的测量数据
* @return 错误信息如果为null或空说明没有错误
*/
public String _stationCheck(
final SurveyorStationRecord stationRecord,
final ToleranceDetailRecord toleranceRecord,
final ICachedData cachedDataSource) {
int measureWhat = measureWhat();
String stationId = stationRecord.getId();
final int cycleCount = getCycleCount();
final int surveyorCount = toleranceRecord.getSurveyorCount();
//*****测回间同方向值互差(水平角)
double horCyclesDirectValueDifference = toleranceRecord.getHorCyclesDirectValueDifference()/*horCyclesDirectValueDifference*/;
List<StationCheckErrorItem> horValueError = new ArrayList<>();
//*****测回间垂直角互差(垂直角)
double verCyclesAngleDifference = toleranceRecord.getVerCyclesAngleDifference()/*verCyclesAngleDifference*/;
List<StationCheckErrorItem> verValueError = new ArrayList<>();
//执行计算
for (int cycleI = 0; cycleI < cycleCount; cycleI++) {
List<DeviationValueOfRadianMethod.AngleDistValue> valuesI =
DeviationValueOfRadianMethod.zeroValueOfSingleCycleInLeftOrientation(measureWhat(), stationId, cycleI, surveyorCount, cachedDataSource);
if (valuesI.isEmpty()) {
return "第" + (cycleI + 1) + "测回,数据不完整!";
}
for (int cycleJ = cycleI + 1; cycleJ < cycleCount; cycleJ++) {
List<DeviationValueOfRadianMethod.AngleDistValue> valuesJ =
DeviationValueOfRadianMethod.zeroValueOfSingleCycleInLeftOrientation(measureWhat(), stationId, cycleJ, surveyorCount, cachedDataSource);
if (valuesI.size() != valuesJ.size()) {
return "第" + (cycleJ + 1) + "测回,数据不完整!";
// return "请完成所有重测后再检测测站数据!";
}
int size = valuesI.size();
for (int index = 0; index < size; index++) {
if (CheckToleranceUtil.checkAngleHor(measureWhat)) {
double diff = Math.abs(
DeviationValueOfRadianMethod
.similarRadianDiff(
valuesI.get(index).horRadian,
valuesJ.get(index).horRadian));
if (horCyclesDirectValueDifference < RadianMethod.radian2S(diff)) {
horValueError.add(new StationCheckErrorItem(valuesI.get(index).pointName,
cycleI, cycleJ, RadianMethod.radian2S(diff)));
}
}
// if (valuesI.get(index).verRadian == FaultTolerantData.WELL_ERROR_VER_ANGLE
// && valuesJ.get(index).verRadian == FaultTolerantData.WELL_ERROR_VER_ANGLE) {
// //当是井定向的时候垂直角不验证
// continue;
// }
if (CheckToleranceUtil.checkAngleVer(measureWhat)) {
double diff = Math.abs(DeviationValueOfRadianMethod
.similarRadianDiff(valuesI.get(index).verRadian, valuesJ.get(index).verRadian));
if (verCyclesAngleDifference < RadianMethod.radian2S(diff)) {
verValueError.add(new StationCheckErrorItem(valuesI.get(index).pointName,
cycleI, cycleJ, RadianMethod.radian2S(diff)));
}
}
}
}
}
//*****测回间垂直角I互差(垂直角)
double verCyclesIDifference = toleranceRecord.getVerCyclesIDifference()/*verCyclesIDifference*/;
List<StationCheckErrorItem> verIError = new ArrayList<>();
//*****测回间斜距互差(距离)
double distCyclesDifference = toleranceRecord.getSlopeCycleDistanceDifference()/*slopeCycleDistanceDifference*/;
List<StationCheckErrorItem> distError = new ArrayList<>();
List<StationCheckErrorPoint> pointArrayList = new ArrayList<>();
//遍历第一测回,收集所有待测点id
for (int index = 0; index < cachedDataSource.pointCount(); index++) {
if (cachedDataSource.isAbandonPoint(0, index)) {
continue;
}
if (cachedDataSource.isWellSteelPoint(0, index)) {
continue;
}
if (cachedDataSource.isAloneMeasureDistancePoint(0, index)) {
continue;
}
pointArrayList.add(new StationCheckErrorPoint(cachedDataSource.pointId(0, index), cachedDataSource.pointName(0, index)));
}
//检测所有待测点i互差
for (StationCheckErrorPoint point : pointArrayList) {
for (int cycleI = 0; cycleI < cycleCount; cycleI++) {
String leftRecordId_I = IdUtil.surveyorRecordKey(stationId, cycleI, point.pointId, LeftOrRight.left);
String rightRecordId_I = IdUtil.surveyorRecordKey(stationId, cycleI, point.pointId, LeftOrRight.right);
CacheResult value2C_I = ValueOf2cMethod.valueOf2C(SdAngleValueType.verAngle, leftRecordId_I, rightRecordId_I,
toleranceRecord.getSurveyorCount(), cachedDataSource);
CacheResult distanceLeftAndRightAverageValue_I = AverageValueMethod.leftAndRightValue(SdAngleValueType.distance,
leftRecordId_I,
rightRecordId_I, surveyorCount, cachedDataSource);
for (int cycleJ = cycleI + 1; cycleJ < cycleCount; cycleJ++) {
String leftRecordId_J = IdUtil.surveyorRecordKey(stationId, cycleJ, point.pointId, LeftOrRight.left);
String rightRecordId_J = IdUtil.surveyorRecordKey(stationId, cycleJ, point.pointId, LeftOrRight.right);
CacheResult value2C_J = ValueOf2cMethod.valueOf2C(SdAngleValueType.verAngle, leftRecordId_J, rightRecordId_J,
toleranceRecord.getSurveyorCount(), cachedDataSource);
CacheResult distanceLeftAndRightAverageValue_J = AverageValueMethod.leftAndRightValue(SdAngleValueType.distance,
leftRecordId_J,
rightRecordId_J, surveyorCount, cachedDataSource);
double verI = Math.abs(value2C_I.value - value2C_J.value);
if (verCyclesIDifference < verI) {
if (CheckToleranceUtil.checkAngleVer(measureWhat)) {
verIError.add(new StationCheckErrorItem(point.pointName, cycleI, cycleJ, verI));
}
}
double distance = Math.abs(distanceLeftAndRightAverageValue_I.value - distanceLeftAndRightAverageValue_J.value);
if (distCyclesDifference < distance * 1000) {
// TODO: 2022/7/20 修改 原先不是distError
if (CheckToleranceUtil.checkDistance(measureWhat)) {
distError.add(new StationCheckErrorItem(point.pointName, cycleI, cycleJ, distance * 1000));
}
}
}
}
}
return _errorString(horCyclesDirectValueDifference, verCyclesAngleDifference, verCyclesIDifference, distCyclesDifference,
horValueError, verValueError, verIError, distError);
}
/**
* 根据超限信息生成错误描述
*
* @param horValueError 水平角同方向值互差
* @param verValueError 垂直角同方向值互差
*/
private static String _errorString(double horLimit, double verLimit, double verILimit, double distLimit,
List<StationCheckErrorItem> horValueError, List<StationCheckErrorItem> verValueError,
List<StationCheckErrorItem> verIError, List<StationCheckErrorItem> distError) {
if (horValueError.isEmpty() && verValueError.isEmpty()) {
return null;
}
StringBuilder stringBuilder = new StringBuilder();
if (!horValueError.isEmpty()) {
stringBuilder.append("测回间同方向值互差超限(限差:")
.append(Util.formatDouble2String(horLimit, 1))
.append("'')");
for (StationCheckErrorItem item : horValueError) {
stringBuilder
.append("\n ")
.append(item.pointName)
.append(":\n")
.append(" |")
.append(SurveyorCycleUtil.cycleName(item.cycleIndex1))
.append("-")
.append(SurveyorCycleUtil.cycleName(item.cycleIndex2))
.append("| = ")
.append(Util.formatDouble2String(item.difference, 1))
.append("'')");
}
}
if (!verValueError.isEmpty()) {
stringBuilder.append("\n测回间垂直角互差超限(限差:")
.append(Util.formatDouble2String(verLimit, 1))
.append("'')");
for (StationCheckErrorItem item : verValueError) {
stringBuilder
.append("\n ")
.append(item.pointName)
.append(":\n")
.append(" |")
.append(SurveyorCycleUtil.cycleName(item.cycleIndex1))
.append("-")
.append(SurveyorCycleUtil.cycleName(item.cycleIndex2))
.append("| = ")
.append(Util.formatDouble2String(item.difference, 1))
.append("'')");
}
}
if (!verIError.isEmpty()) {
stringBuilder.append("\n垂直角i指标同方向各测回较差超限(限差:")
.append(Util.formatDouble2String(verILimit, 1))
.append("'')");
for (StationCheckErrorItem item : verIError) {
stringBuilder
.append("\n ")
.append(item.pointName)
.append(":\n")
.append(" |")
.append(SurveyorCycleUtil.cycleName(item.cycleIndex1))
.append("-")
.append(SurveyorCycleUtil.cycleName(item.cycleIndex2))
.append("| = ")
.append(Util.formatDouble2String(item.difference, 1))
.append("'')");
}
}
if (!distError.isEmpty()) {
stringBuilder.append("\n测回间距离较差超限(限差:")
.append(Util.formatDouble2String(distLimit, 1))
.append("'')");
for (StationCheckErrorItem item : distError) {
stringBuilder
.append("\n ")
.append(item.pointName)
.append(":\n")
.append(" |")
.append(SurveyorCycleUtil.cycleName(item.cycleIndex1))
.append("-")
.append(SurveyorCycleUtil.cycleName(item.cycleIndex2))
.append("| = ")
.append(Util.formatDouble2String(item.difference, 1))
.append("'')");
}
}
return stringBuilder.toString();
}
}

@ -1,18 +1,17 @@
package com.bingce.controlnetwork.surveyor.state.angledistance;
package com.bingce.controlnetwork.surveyor.state;
import android.os.Bundle;
import com.bingce.controlapphelper.datasource.database.schedule.SurveyorScheduleConstants;
import com.bingce.controlapphelper.surveyor.data.ISurveyorData;
import com.bingce.controlapphelper.surveyor.state.StateType;
import com.bingce.controlnetwork.R;
import com.bingce.controlnetwork.bean.SurveyorScheduleConstants;
import com.bingce.controlnetwork.surveyor.data.ISurveyorData;
import net.tatans.tensorflowtts.tts.TtsManager;
import com.bingce.controlnetwork.R;
class _CheckStationSuccessState extends __BaseState {
public _CheckStationSuccessState(StateManager stateManager) {
public _CheckStationSuccessState(StateManagerTj stateManager) {
super(StateType.stationCheckedSuccess, stateManager);
}
@ -21,7 +20,7 @@ class _CheckStationSuccessState extends __BaseState {
ISurveyorData surveyorData = getSurveyorData();
surveyorData.clearSurveyStateAndPosition();
//设置测量进度(数据库存储)
setAllCycleSchedule(SurveyorScheduleConstants.STATUE_VALUE_CHECKED);
setStationScheduleForAllCycle(SurveyorScheduleConstants.STATUE_VALUE_CHECKED);
//通知刷新
tips(getContext().getString(R.string.tips_all_cycle_has_finish_and_checked), null);
if (isAutoSurveyOpen()) {

@ -0,0 +1,30 @@
package com.bingce.controlnetwork.surveyor.state;
import android.os.Bundle;
import com.bingce.totalstation.ControlSurveyResult;
import net.tatans.tensorflowtts.tts.TtsManager;
/**
* 先检测是否有其他未完成测回继续本次测量将删除其他测回数据
*/
class _DoAutoSurveyorState extends __BaseState {
private final IAutoModeSwitcher autoModeSwitcher;
public _DoAutoSurveyorState(StateManagerTj stateManager, IAutoModeSwitcher autoModeSwitcher) {
super(StateType.doAutoSurveyor, stateManager);
this.autoModeSwitcher = autoModeSwitcher;
}
@Override
public void enter(Bundle args) {
autoModeSwitcher.isReadyAutoSurvey(code -> {
if (code == ControlSurveyResult.CODE_SUCCESS) {
autoModeSwitcher.openAutoMode();
navigation2(StateType.doMove2NextValidate);
TtsManager.getInstance().speak("开始自动测量");
}
});
}
}

@ -0,0 +1,47 @@
package com.bingce.controlnetwork.surveyor.state;
import android.os.Bundle;
import android.text.TextUtils;
import androidx.annotation.NonNull;
import com.bingce.controlnetwork.fragment.StationDataAdjustDialogFragment;
import com.bingce.controlnetwork.surveyor.method.SurveyorAdjustMethodTj;
/**
* 平差计算
*/
public class _DoCalAdjustState extends __BaseState {
public _DoCalAdjustState(StateManagerTj stateManager) {
super(StateType.doCalAdjust, stateManager);
}
@Override
public void enter(@NonNull Bundle args) {
runOnBackground(() -> {
SurveyorAdjustMethodTj.AdjustResult adjustResult = SurveyorAdjustMethodTj.calStationAdjust(measureWhat(), getStation(), getCachedData());
if (!TextUtils.isEmpty(adjustResult.errorString)) {
runOnUI(() -> _CheckStationState.showErrorTips(adjustResult.errorString, stationId(), getCycleCount(),
getSurveyorData(), getCycleRecorder(), getCachedData(),
_DoCalAdjustState.this,
fragmentManager(),
lifecycleOwner()));
return;
}
//清除测量状态,进入idle,停止自动测量
enterIdleAndClearSurveyStateAndResetAutoMode(true);
//展示结果数据
//检测归零值是否为负,如果是需要+2PI
for (SurveyorAdjustMethodTj.Item item : adjustResult.result) {
if (item.getHorAngle() < 0) {
item.setHorAngle(Math.PI * 2 + item.getHorAngle());
}
}
StationDataAdjustDialogFragment.showDialog(measureWhat(), adjustResult.result, getStation().isShowSlopDistance(), fragmentManager());
});
}
}

@ -1,22 +1,21 @@
package com.bingce.controlnetwork.surveyor.state.angledistance;
package com.bingce.controlnetwork.surveyor.state;
import android.os.Bundle;
import com.bingce.controlapphelper.datasource.database.SurveyorDatabaseFactory;
import com.bingce.controlapphelper.datasource.database.schedule.ISurveyorScheduleDataSource;
import com.bingce.controlapphelper.datasource.database.schedule.SurveyorScheduleConstants;
import com.bingce.controlapphelper.datasource.database.schedule.SurveyorScheduleRecord;
import com.bingce.controlapphelper.datasource.database.tolerance.detail.ToleranceDetailRecord;
import com.bingce.controlapphelper.model.DataCategory;
import com.bingce.controlapphelper.model.LeftOrRight;
import com.bingce.controlapphelper.surveyor.data.ICachedData;
import com.bingce.controlapphelper.surveyor.method.FindTargetMethod;
import com.bingce.controlapphelper.surveyor.method.SingleCycleCheckMethod;
import com.bingce.controlapphelper.surveyor.state.IAutoModeSwitcher;
import com.bingce.controlapphelper.surveyor.state.StateType;
import com.bingce.controlnetwork.bean.SurveyorScheduleConstants;
import com.bingce.controlnetwork.surveyor.data.ICachedData;
import com.bingce.controlnetwork.surveyor.method.FindTargetMethod;
import com.bingce.controlnetwork.surveyor.method.SingleCycleCheckMethod;
import com.bingce.controlnetwork.surveyor.method.SingleCycleTipsMethod;
import com.bingce.utils.ThreadPoolUtil;
/**
* 在所有测回范围计算测量进度
* <p>
@ -32,7 +31,7 @@ import com.bingce.utils.ThreadPoolUtil;
*/
class _DoCalScheduleInAllCycleState extends _DoCalScheduleInSingleCycleState {
public _DoCalScheduleInAllCycleState(StateManager stateManager, IAutoModeSwitcher autoModeSwitcher) {
public _DoCalScheduleInAllCycleState(StateManagerTj stateManager, IAutoModeSwitcher autoModeSwitcher) {
super(StateType.doCalScheduleAllCycle, stateManager, autoModeSwitcher);
}
@ -40,18 +39,18 @@ class _DoCalScheduleInAllCycleState extends _DoCalScheduleInSingleCycleState {
protected boolean isNeedCancelEnterIdle(int currentCycle) {
ICachedData cachedData = getCachedData();
int pointCount = cachedData.pointCount();
ToleranceDetailRecord toleranceDetailRecord = getToleranceRecord();
ToleranceDetailRecord toleranceDetailRecordTj = getToleranceRecord();
//5.当前测回完成且通过检测,则对其他测回执行检测
FindTargetMethod.Target resurveyTarget = null;
int emptyCycleIndex = -1;
for (int cycleIndex = 0; cycleIndex < toleranceDetailRecord.getCycleCount(); cycleIndex++) {
for (int cycleIndex = 0; cycleIndex < getCycleCount(); cycleIndex++) {
if (cycleIndex == getCycleRecorder().currentCycleIndex()) {
continue;
}
if (_IsSingleCycleCompletedState.isSingleCycleCompleted(stationId(), cycleIndex, getCachedData())) {
//更新该测回进度
setSingleCycleSchedule(cycleIndex, SurveyorScheduleConstants.STATUE_VALUE_COMPLETED);
setStationScheduleForSingleCycle(cycleIndex, SurveyorScheduleConstants.STATUE_VALUE_COMPLETED);
continue;
}
//从0号位置盘左开始向后查询,找到需要补测位置
@ -78,18 +77,20 @@ class _DoCalScheduleInAllCycleState extends _DoCalScheduleInSingleCycleState {
return true;
}
//8.所有测回都完成测量(当前测回完成检测),执行检测
double horCycle2CDiff = toleranceDetailRecord.getHorCycleDirect2CDifference();
double verCycle2CDiff = toleranceDetailRecord.getVerCycleDirectIDifference();
for (int cycleIndex = 0; cycleIndex < toleranceDetailRecord.getCycleCount(); cycleIndex++) {
double horCycle2CDiff = toleranceDetailRecordTj.getHorCycleDirect2CDifference();
double verCycle2CDiff = toleranceDetailRecordTj.getVerCycleDirectIDifference();
for (int cycleIndex = 0; cycleIndex < getCycleCount(); cycleIndex++) {
if (cycleIndex == getCycleRecorder().currentCycleIndex()) {
continue;
}
String result = SingleCycleCheckMethod.check(
measureWhat(),
horCycle2CDiff,
verCycle2CDiff,
stationId(),
cycleIndex,
getSurveyorData(),
getCycleRecorder(),
getCachedData());
if (result != null && !result.isEmpty()) {
SingleCycleTipsMethod.showTips(result,
@ -101,14 +102,14 @@ class _DoCalScheduleInAllCycleState extends _DoCalScheduleInSingleCycleState {
return true;
}
//更新该测回进度
setSingleCycleSchedule(cycleIndex, SurveyorScheduleConstants.STATUE_VALUE_CHECKED);
setStationScheduleForSingleCycle(cycleIndex, SurveyorScheduleConstants.STATUE_VALUE_CHECKED);
}
//9.所有测回都通过检测,可以执行「测站检测」
//设置测量进度,但是需要注意,如果station已经通过检测,则不需要设置为completed
ThreadPoolUtil.execute(() -> {
ISurveyorScheduleDataSource scheduleDataSource =
SurveyorDatabaseFactory.instance.getScheduleDataSource();
String key = SurveyorScheduleConstants.getAllCycleScheduleKey(stationId(), null);
String key = SurveyorScheduleConstants.stationAllCycleScheduleKey(stationId(), stateManager.getMeasureWhat());
SurveyorScheduleRecord scheduleRecord = scheduleDataSource.findScheduleSync(key);
if (scheduleRecord != null) {
String statue = scheduleRecord.getStatue();
@ -126,7 +127,7 @@ class _DoCalScheduleInAllCycleState extends _DoCalScheduleInSingleCycleState {
return true;
}
static void enter(StateManager stateManager, int cycleIndex) {
static void enter(StateManagerTj stateManager, int cycleIndex) {
Bundle args = new Bundle();
args.putInt(KEY_CYCLE_INDEX, cycleIndex);
stateManager.enter(StateType.doCalScheduleAllCycle, args);

@ -1,13 +1,11 @@
package com.bingce.controlnetwork.surveyor.state.angledistance;
package com.bingce.controlnetwork.surveyor.state;
import android.os.Bundle;
import com.bingce.controlapphelper.datasource.database.schedule.SurveyorScheduleConstants;
import com.bingce.controlapphelper.datasource.database.tolerance.detail.ToleranceDetailRecord;
import com.bingce.controlapphelper.surveyor.data.ICycleRecorder;
import com.bingce.controlapphelper.surveyor.method.SingleCycleCheckMethod;
import com.bingce.controlapphelper.surveyor.state.IAutoModeSwitcher;
import com.bingce.controlapphelper.surveyor.state.StateType;
import com.bingce.controlnetwork.bean.SurveyorScheduleConstants;
import com.bingce.controlnetwork.surveyor.data.ICycleRecorder;
import com.bingce.controlnetwork.surveyor.method.SingleCycleCheckMethod;
import com.bingce.controlnetwork.surveyor.method.SingleCycleTipsMethod;
/**
@ -20,12 +18,12 @@ import com.bingce.controlnetwork.surveyor.method.SingleCycleTipsMethod;
class _DoCalScheduleInSingleCycleState extends __BaseState {
private final IAutoModeSwitcher autoModeSwitcher;
public _DoCalScheduleInSingleCycleState(StateManager stateManager, IAutoModeSwitcher autoModeSwitcher) {
public _DoCalScheduleInSingleCycleState(StateManagerTj stateManager, IAutoModeSwitcher autoModeSwitcher) {
super(StateType.doCalScheduleSingleCycle, stateManager);
this.autoModeSwitcher = autoModeSwitcher;
}
protected _DoCalScheduleInSingleCycleState(StateType stateType, final StateManager stateManager, IAutoModeSwitcher autoModeSwitcher) {
protected _DoCalScheduleInSingleCycleState(StateType stateType, final StateManagerTj stateManager, IAutoModeSwitcher autoModeSwitcher) {
super(stateType, stateManager);
this.autoModeSwitcher = autoModeSwitcher;
}
@ -49,8 +47,9 @@ class _DoCalScheduleInSingleCycleState extends __BaseState {
getSurveyorData().clearSurveyStateAndPosition();
ICycleRecorder cycleRecorder = getCycleRecorder();
cycleRecorder.changeCycleIndex(args.getInt(KEY_CYCLE_INDEX, 0));
setCurrentCycle(cycleRecorder.currentCycleIndex());
int cycleIndex = args.getInt(KEY_CYCLE_INDEX, 0);
cycleRecorder.changeCycleIndex(cycleIndex);
setStationCycle(cycleIndex);
//1.检测当前cycle是否完成测量
boolean completed = _IsSingleCycleCompletedState.isSingleCycleCompleted(
@ -64,15 +63,17 @@ class _DoCalScheduleInSingleCycleState extends __BaseState {
return;
}
//3.如果当前测回结束测量,判断是否通过检测
ToleranceDetailRecord toleranceDetailRecord = getToleranceRecord();
double horCycle2CDiff = toleranceDetailRecord.getHorCycleDirect2CDifference();
double verCycle2CDiff = toleranceDetailRecord.getVerCycleDirectIDifference();
ToleranceDetailRecord toleranceDetailRecordTj = getToleranceRecord();
double horCycle2CDiff = toleranceDetailRecordTj.getHorCycleDirect2CDifference();
double verCycle2CDiff = toleranceDetailRecordTj.getVerCycleDirectIDifference();
String error = SingleCycleCheckMethod.check(
measureWhat(),
horCycle2CDiff,
verCycle2CDiff,
stationId(),
getCycleRecorder().currentCycleIndex(),
getSurveyorData(),
getCycleRecorder(),
getCachedData());
if (error != null && !error.isEmpty()) {
SingleCycleTipsMethod.showTips(error,
@ -84,7 +85,7 @@ class _DoCalScheduleInSingleCycleState extends __BaseState {
return;
}
//4.更新测站状态
setSingleCycleSchedule(getCycleRecorder().currentCycleIndex(),
setStationScheduleForSingleCycle(getCycleRecorder().currentCycleIndex(),
SurveyorScheduleConstants.STATUE_VALUE_CHECKED);
//5.检测其他测回状态
@ -102,7 +103,7 @@ class _DoCalScheduleInSingleCycleState extends __BaseState {
protected static final String KEY_CYCLE_INDEX = "___cycle__index__";
static void enter(StateManager stateManager, int cycleIndex) {
static void enter(StateManagerTj stateManager, int cycleIndex) {
Bundle args = new Bundle();
args.putInt(KEY_CYCLE_INDEX, cycleIndex);
stateManager.enter(StateType.doCalScheduleSingleCycle, args);

@ -0,0 +1,51 @@
package com.bingce.controlnetwork.surveyor.state;
import android.os.Bundle;
import com.bingce.controlnetwork.R;
import com.bingce.controlnetwork.bean.SurveyorScheduleConstants;
import com.bingce.controlnetwork.surveyor.data.ICachedData;
/*
* 删除本测站所有测回数据
* */
class _DoDeleteAllCycleState extends __BaseState {
public _DoDeleteAllCycleState(StateManagerTj stateManager) {
super(StateType.doDeleteAllCycle, stateManager);
}
@Override
public void enter(Bundle args) {
String stationId = args.getString(KEY_STATION_ID);
optionTipsWithStandStill(getContext().getString(R.string.tips_delete_station_all_surveyor_records),
() -> {
//删除数据
ICachedData cachedData = getCachedData();
cachedData.deleteSurveyorRecord(stationId);
deleteAllLearnBaseData(measureWhat(), stationId, () -> {
//重置进度
setStationScheduleForAllCycle(SurveyorScheduleConstants.STATUE_VALUE_NO_COMPLETED);
for (int cycleIndex = 0; cycleIndex < getCycleCount(); cycleIndex++) {
setStationScheduleForSingleCycle(cycleIndex, SurveyorScheduleConstants.STATUE_VALUE_NO_COMPLETED);
}
//从第一测回开始
setStationCycle(0);
//重新测量,并刷新
findTargetFromBeginInCurrentCycle(true);
});
});
}
private static final String KEY_STATION_ID = "__station_id";
static Bundle args(String stationId) {
Bundle args = new Bundle();
args.putString(KEY_STATION_ID, stationId);
return args;
}
}

@ -0,0 +1,53 @@
package com.bingce.controlnetwork.surveyor.state;
import android.os.Bundle;
import com.bingce.controlnetwork.R;
import com.bingce.controlnetwork.bean.SurveyorScheduleConstants;
import com.bingce.controlnetwork.surveyor.data.ICachedData;
class _DoDeleteCurrentCycleState extends __BaseState {
public _DoDeleteCurrentCycleState(StateManagerTj stateManager) {
super(StateType.doDeleteCurrentCycle, stateManager);
}
@Override
public void enter(Bundle args) {
String stationId = args.getString(KEY_STATION_ID);
int cycleIndex = args.getInt(KEY_PERIOD_INDEX);
optionTipsWithStandStill(getContext().getString(R.string.tips_delete_current_cycle_surveyor_record),
() -> {
if (cycleIndex == 0) {
deleteAllLearnBaseData(measureWhat(), stationId, () -> {
clearSurveyData(stationId, cycleIndex);
});
} else {
clearSurveyData(stationId, cycleIndex);
}
});
}
private void clearSurveyData(String stationId, int cycleIndex) {
ICachedData stationSurveyorDataSource = getCachedData();
stationSurveyorDataSource.deleteSurveyorRecord(stationId, cycleIndex);
//重置进度
setStationCycle(cycleIndex);
setStationScheduleForAllCycle(SurveyorScheduleConstants.STATUE_VALUE_NO_COMPLETED);
setStationScheduleForSingleCycle(cycleIndex, SurveyorScheduleConstants.STATUE_VALUE_NO_COMPLETED);
//重新测量,并刷新
findTargetFromBeginInCurrentCycle(true);
}
private static final String KEY_STATION_ID = "__station_id";
private static final String KEY_PERIOD_INDEX = "__period_index__";
static Bundle args(String stationId, int periodIndex) {
Bundle args = new Bundle();
args.putString(KEY_STATION_ID, stationId);
args.putInt(KEY_PERIOD_INDEX, periodIndex);
return args;
}
}

@ -1,15 +1,12 @@
package com.bingce.controlnetwork.surveyor.state.angledistance;
package com.bingce.controlnetwork.surveyor.state;
import android.os.Bundle;
import com.bingce.controlapphelper.model.LeftOrRight;
import com.bingce.controlapphelper.surveyor.data.ICachedData;
import com.bingce.controlapphelper.surveyor.data.ICycleRecorder;
import com.bingce.controlapphelper.surveyor.data.ISurveyorData;
import com.bingce.controlapphelper.surveyor.method.FindTargetMethod;
import com.bingce.controlapphelper.surveyor.state.StateType;
import com.bingce.controlapphelper.util.Tools;
import com.bingce.controlnetwork.R;
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.FindTargetMethod;
import net.tatans.tensorflowtts.tts.TtsManager;
@ -22,7 +19,7 @@ import net.tatans.tensorflowtts.tts.TtsManager;
*/
class _DoMove2NextValidateState extends __BaseState {
public _DoMove2NextValidateState(StateManager stateManager) {
public _DoMove2NextValidateState(StateManagerTj stateManager) {
super(StateType.doMove2NextValidate, stateManager);
}
@ -63,7 +60,7 @@ class _DoMove2NextValidateState extends __BaseState {
if (isAutoSurveyOpen()) {
if (emptyTarget.itemIndex == getCachedData().pointCount() - 1
&& emptyTarget.leftOrRight == LeftOrRight.right) {
TtsManager.getInstance().speak(Tools.getString(R.string.start_face_right));
TtsManager.getInstance().speak("开始盘右测量");
}
}
//直接跳转到目标点,开启新测量
@ -90,6 +87,6 @@ class _DoMove2NextValidateState extends __BaseState {
enterIdleAndClearSurveyStateAndResetAutoMode(false);
//滚动
scroll2(targetIndex);
scroll2(getCurrentCycleIndex(), targetIndex);
}
}

@ -1,26 +1,25 @@
package com.bingce.controlnetwork.surveyor.state.angledistance;
package com.bingce.controlnetwork.surveyor.state;
import android.os.Bundle;
import com.bingce.controlapphelper.datasource.database.schedule.SurveyorScheduleConstants;
import com.bingce.controlapphelper.datasource.database.surveyorrecord.SurveyorRecord;
import com.bingce.controlapphelper.model.DataCategory;
import com.bingce.controlapphelper.model.LeftOrRight;
import com.bingce.controlapphelper.surveyor.data.ICachedData;
import com.bingce.controlapphelper.surveyor.data.ICycleRecorder;
import com.bingce.controlapphelper.surveyor.data.ISurveyorData;
import com.bingce.controlapphelper.surveyor.method.FindTargetMethod;
import com.bingce.controlapphelper.surveyor.state.StateType;
import com.bingce.controlapphelper.util.IdUtil;
import com.bingce.controlnetwork.R;
import com.bingce.controlnetwork.bean.SurveyorScheduleConstants;
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.FindTargetMethod;
import com.bingce.controlnetwork.util.IdUtil;
/**
* 移动到上一测量结点伴随删除上次测量数据
*/
public class _DoMoveBackState extends __BaseState {
public _DoMoveBackState(StateManager stateManager) {
public _DoMoveBackState(StateManagerTj stateManager) {
super(StateType.doMoveBack, stateManager);
}
@ -39,11 +38,11 @@ public class _DoMoveBackState extends __BaseState {
//如果测量结束,直接使用0号点盘右
int targetIndex = 0;
LeftOrRight targetState = LeftOrRight.right;
warningWithStandStill(cachedDataSource, currentCycle, targetIndex, targetState);
warningWithStandStill(currentCycle, targetIndex, targetState);
return;
}
String currentPointId = cachedDataSource.pointId(currentCycle, currentIndex);
String currentRecordKey = IdUtil.createSurveyorRecordId(stationId(), currentCycle, currentPointId, leftOrRight);
String currentRecordKey = IdUtil.surveyorRecordKey(stationId(), currentCycle, currentPointId, leftOrRight);
DataCategory dataCategory = cachedDataSource.valueState(currentRecordKey);
if (dataCategory.isNeedResurvey()) {//如果当前位置是脏数据(说明正在补测)
//回退到上一个脏数据位置
@ -72,7 +71,7 @@ public class _DoMoveBackState extends __BaseState {
//找到dirtyAndSurveyed数据,
//则将其校正为dirtyAndNeedReSurveyor
String pointId = cachedData.pointId(target.cycleIndex, target.itemIndex);
String recordKey = IdUtil.createSurveyorRecordId(stationId(), target.cycleIndex, pointId, target.leftOrRight);
String recordKey = IdUtil.surveyorRecordKey(stationId(), target.cycleIndex, pointId, target.leftOrRight);
SurveyorRecord surveyorRecord = cachedData.getSurveyorRecord(recordKey);
if (surveyorRecord != null) {
if (surveyorRecord.value1Status.isResurveyed()) {
@ -103,32 +102,42 @@ public class _DoMoveBackState extends __BaseState {
DataCategory.normalCategory(),
cachedData);
if (target == null) {
failureTipsWithAutoStandStill(getContext().getString(R.string.tips_no_more_record_2_rollback));
failureTipsWithAutoStandStill(getContext().getString(R.string.tips_no_more_record_2_rollback), null);
return;
}
warningWithStandStill(cachedData,
warningWithStandStill(
currentCycle,
target.itemIndex,
target.leftOrRight);
}
private void warningWithStandStill(
ICachedData cachedDataSource,
int currentCycle, int itemIndex, LeftOrRight leftOrRight) {
optionTipsWithStandStill(getContext().getString(R.string.tips_will_resurvey_last_record),
() -> {
//删除当前数据
cachedDataSource.deleteSurveyorRecord(stationId(),
currentCycle, itemIndex, leftOrRight);
//重置进度
setSingleCycleSchedule(currentCycle, SurveyorScheduleConstants.STATUE_VALUE_NO_COMPLETED);
setAllCycleSchedule(SurveyorScheduleConstants.STATUE_VALUE_NO_COMPLETED);
resetSchedule(this, itemIndex, leftOrRight);
if (currentCycle == 0) {
deleteLearnBaseData(measureWhat(), stationId(), getCachedData().pointId(currentCycle, itemIndex), () -> {
deleteCurrentPointData(currentCycle, itemIndex, leftOrRight);
});
} else {
deleteCurrentPointData(currentCycle, itemIndex, leftOrRight);
}
});
}
private void deleteCurrentPointData(int currentCycle, int itemIndex, LeftOrRight leftOrRight) {
//删除当前数据
getCachedData().deleteSurveyorRecord(stationId(),
currentCycle, itemIndex, leftOrRight);
//重置进度
setStationScheduleForSingleCycle(currentCycle, SurveyorScheduleConstants.STATUE_VALUE_NO_COMPLETED);
setStationScheduleForAllCycle(SurveyorScheduleConstants.STATUE_VALUE_NO_COMPLETED);
resetSchedule(this, itemIndex, leftOrRight);
}
private static void resetSchedule(__BaseState state,
int targetIndex,
LeftOrRight leftOrRight) {
@ -136,8 +145,8 @@ public class _DoMoveBackState extends __BaseState {
state.setSurveyPosition(targetIndex, leftOrRight);
//清除测量状态,进入idle
//如果当前已经关闭自动测量,就不重置自动测量开关(用户已经表示不想自动测量)
state.enterIdleAndClearSurveyStateAndResetAutoMode(!state.isAutoSurveyClosed());
state.enterIdleAndClearSurveyStateAndResetAutoMode(true);
state.scroll2(targetIndex);
state.scroll2(state.getCurrentCycleIndex(), targetIndex);
}
}

@ -0,0 +1,44 @@
package com.bingce.controlnetwork.surveyor.state;
import android.os.Bundle;
import com.bingce.controlapphelper.model.DataCategory;
import com.bingce.controlnetwork.surveyor.data.ICachedData;
import com.bingce.controlnetwork.surveyor.data.ICycleRecorder;
import com.bingce.controlnetwork.surveyor.data.ISurveyorData;
/**
* 记录测量数据
*/
class _DoRecordCleanState extends __BaseState {
public _DoRecordCleanState(StateManagerTj stateManager) {
super(StateType.doRecordClean, stateManager);
}
@Override
public void enter(Bundle args) {
ICachedData cacheData = getCachedData();
ISurveyorData surveyorDataSource = getSurveyorData();
ICycleRecorder cycleRecorder = getCycleRecorder();
//设置数据正常
surveyorDataSource.setDataCategory(DataCategory.normalCategory());
//存储(缓存+数据库)
cacheData.cache(measureWhat(), cycleRecorder.currentCycleIndex(), surveyorDataSource, new ICachedData.CallBackCache() {
@Override
public void success() {
goToIsSingleCycleCompletedState();
}
@Override
public void failure() {
goToIsSingleCycleCompletedState();
}
});
}
private void goToIsSingleCycleCompletedState() {
//检测单测回是否完成
navigation2(StateType.isSingleCycleCompleted);
}
}

@ -1,57 +1,48 @@
package com.bingce.controlnetwork.surveyor.state.angledistance;
package com.bingce.controlnetwork.surveyor.state;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.widget.Toast;
import com.bingce.controlapphelper.datasource.database.surveyorstation.model.SurveyorPoint;
import com.bingce.controlapphelper.datasource.database.tolerance.detail.ToleranceDetailRecord;
import com.bingce.controlapphelper.event.SurveyStateEvent;
import com.bingce.controlapphelper.model.DataCategory;
import com.bingce.controlapphelper.model.LeftOrRight;
import com.bingce.controlapphelper.surveyor.data.ICachedData;
import com.bingce.controlapphelper.surveyor.data.ICycleRecorder;
import com.bingce.controlapphelper.surveyor.data.ISurveyorData;
import com.bingce.controlapphelper.surveyor.state.ISurveyState;
import com.bingce.controlapphelper.surveyor.state.StateType;
import com.bingce.controlapphelper.surveyor.surveyor.ISurveyorListener;
import com.bingce.controlapphelper.surveyor.surveyor.ISurveyorRemindListener;
import com.bingce.controlapphelper.surveyor.surveyor.RequestSurveyorParam;
import com.bingce.controlapphelper.util.DebugMsgUtil;
import com.bingce.controlapphelper.util.IdUtil;
import com.bingce.controlapphelper.util.SettingValueUtil;
import com.bingce.controlapphelper.util.SurveyorCycleUtil;
import com.bingce.controlapphelper.util.Tools;
import com.bingce.controlnetwork.R;
import com.bingce.controlnetwork.surveyor.state.StateConstants;
import com.bingce.controlnetwork.event.SurveyStateEvent;
import com.bingce.controlnetwork.surveyor.data.ICachedData;
import com.bingce.controlnetwork.surveyor.data.ICycleRecorder;
import com.bingce.controlnetwork.surveyor.surveyor.ISurveyorListener;
import com.bingce.controlnetwork.surveyor.surveyor.ISurveyorRemindListener;
import com.bingce.controlnetwork.surveyor.surveyor.RequestParam;
import com.bingce.controlnetwork.util.IdUtil;
import com.bingce.device.Device;
import com.bingce.totalstation.TotalStation;
import com.bingce.totalstation.protocol.south.SouthAndroidBtInterface;
import com.bingce.totalstation.protocol.topcon.TopconInterface;
import net.tatans.tensorflowtts.tts.TtsManager;
import blankj.utilcode.util.ToastUtils;
/**
* 先检测是否有其他未完成测回继续本次测量将删除其他测回数据
*/
class _DoSurveyorState extends __BaseState implements ISurveyorListener, ISurveyorRemindListener {
private final ISurveyState surveyState;
//最多测量次数,如果3次测量都没有获取正常数据,则跳过
//最多测量次数,如果5次测量都没有获取正常数据,则跳过
private static final int MAX_SURVEYOR_COUNT = 3;
private static int failureCount = 0;
private static final int RESULT_SUCCESS = 0;
private static final int RESULT_FAILURE_EXCEED_MAX = 1;//测量失败次数超出最大限制
private static final int RESULT_FAILURE_ERROR = 2;//测量失败,又没有允许重复尝试
private static final int RESULT_FAILURE_EXCEED_MAX = 1;//测量失败次数超出最大限制 key
private static final int RESULT_FAILURE_ERROR = 2;//测量失败,又没有允许重复尝试 key
private static final boolean allowTryWhenFailure = true;//在测量失败的时候,是否允许重新测量
private int measureTimeIndex = 0;//当前测点是第几次测量
private int surveyorIndex = 0;
private boolean isAlreadyRemindUserAimingAtWire = false;
private final Handler handler;
private Handler handler;
public _DoSurveyorState(StateManager stateManager, ISurveyState surveyState) {
public _DoSurveyorState(StateManagerTj stateManager, ISurveyState surveyState) {
super(StateType.doSurveyor, stateManager);
this.surveyState = surveyState;
handler = new Handler(Looper.getMainLooper());
@ -59,11 +50,10 @@ class _DoSurveyorState extends __BaseState implements ISurveyorListener, ISurvey
@Override
public void enter(Bundle args) {
measureTimeIndex = 0;
surveyorIndex = 0;
isAlreadyRemindUserAimingAtWire = false;
if (args != null) {
isAlreadyRemindUserAimingAtWire = args.getBoolean(StateConstants.KEY_IS_ROTATION_READY_STATE);
isAlreadyRemindUserAimingAtWire = args.getBoolean(StateConstantsTj.KEY_IS_ALREADY_REMIND_USER_AIMING_AT_WIRE);
}
ToleranceDetailRecord toleranceRecord = getToleranceRecord();
@ -71,7 +61,7 @@ class _DoSurveyorState extends __BaseState implements ISurveyorListener, ISurvey
ICachedData cachedDataSource = getCachedData();
int currentCycleIndex = cycleRecorder.currentCycleIndex();
int cycleCount = toleranceRecord.getCycleCount();
int cycleCount = getCycleCount();
int pointCount = cachedDataSource.pointCount();
int otherCycle = -1;
@ -83,7 +73,7 @@ class _DoSurveyorState extends __BaseState implements ISurveyorListener, ISurvey
//遍历该测回内所有点,检测是否有测量数据
for (int itemIndex = 0; itemIndex < pointCount; itemIndex++) {
String pointId = cachedDataSource.pointId(cycleIndex, 0);
String key = IdUtil.createSurveyorRecordId(stationId(), cycleIndex, pointId, LeftOrRight.left);
String key = IdUtil.surveyorRecordKey(stationId(), cycleIndex, pointId, LeftOrRight.left);
//检测该测回是否有数据,目前应该只需要检测盘左0就可以了,因为一个测回内数据不能跳过
DataCategory dataCategory = cachedDataSource.valueState(key);
if (dataCategory.hasData()) {
@ -104,9 +94,9 @@ class _DoSurveyorState extends __BaseState implements ISurveyorListener, ISurvey
if (otherCycle != -1) {
final int targetCycleIndex = otherCycle;
optionTipsWithStandStill(
SurveyorCycleUtil.cycleName(otherCycle) + Tools.getString(R.string.unfinished_measurements_starting_this_measurement_will_delete),
SurveyorCycleUtil.cycleName(otherCycle) + "有未完成测量,开始本次测量将删除其数据,是否继续?",
() -> optionTipsWithStandStill(
Tools.getString(R.string.confirm_delete) + SurveyorCycleUtil.cycleName(targetCycleIndex) + Tools.getString(R.string.data_ask),
"确定删除" + SurveyorCycleUtil.cycleName(targetCycleIndex) + "数据?",
() -> {
String stationId = stationId();
//删除数据
@ -127,7 +117,7 @@ class _DoSurveyorState extends __BaseState implements ISurveyorListener, ISurvey
//判断设备是否连接
if (surveyorImpl().isReady()) {
//发送测量信号
SurveyStateEvent.postSurveying(positionFragment);
SurveyStateEvent.postSurveying();
//注册接收测量数据
surveyorImpl().prepareSurveyor();
sendSurveyRequest();
@ -137,66 +127,32 @@ class _DoSurveyorState extends __BaseState implements ISurveyorListener, ISurvey
}
}
@Override
public void onReceive(double originalHa, double originalVa, double sd, double clockwiseHa, double topVa, double hd, double vd) {
//重置错误读数
failureCount = 0;
if (getSurveyorData().onSurveyor(originalHa, originalVa, sd, hd)) {
//测量数据成功,可以退出测量状态
onSuccess();
} else {//测量数据不完全,需要继续测量
measureTimeIndex = 1;//更新测量索引
refreshUI();
if (TotalStation.getInstance() instanceof TopconInterface) {
//这个仪器需要延迟500毫秒发送指令
handler.postDelayed(this::sendSurveyRequest, 500);
} else if (TotalStation.getInstance() instanceof SouthAndroidBtInterface) {
handler.postDelayed(this::sendSurveyRequest, 100);
} else {
sendSurveyRequest();
}
private void sendSurveyRequestNext() {
if (isAutoSurveyOpen()) {
//当自动测量的时候继续发送测量指令
sendSurveyRequestNextInner();
} else {
//进入idle
navigation2(StateType.idle);
}
}
@Override
public void onError(String errorMsg) {
TtsManager.getInstance().speak(errorMsg);
if (allowTryWhenFailure) {//允许重新测量
if (!isLive()) {
return;
}
//测量出现异常,需要处理
failureCount++;
if (failureCount >= MAX_SURVEYOR_COUNT) {
if (isAutoSurveyOpen()) {
TtsManager.getInstance().speak(Tools.getString(R.string.many_measure_failed));
}
onCompleted(RESULT_FAILURE_EXCEED_MAX, Tools.getString(R.string.many_measure_failed_1));
} else {
//再次尝试
DebugMsgUtil.canWrite("仪器返回错误信息:" + errorMsg);
DebugMsgUtil.canWrite("开始再次测量");
sendSurveyRequest();
ToastUtils.showShort(R.string.receive_data_time_out);
}
private void sendSurveyRequestNextInner() {
if (TotalStation.getInstance() instanceof TopconInterface) {
//这个仪器需要延迟500毫秒发送指令
handler.postDelayed(this::sendSurveyRequest, 500);
} else {
onCompleted(RESULT_FAILURE_ERROR, errorMsg);
sendSurveyRequest();
}
}
private void sendSurveyRequest() {
int currentIndex = getCurrentIndex();
if (currentIndex < 0) {
currentIndex = 0;
int surveyorPointIndex = getCurrentItemIndex();
if (surveyorPointIndex < 0) {
surveyorPointIndex = 0;
}
SurveyorPoint surveyorPoint = getCachedData().getSurveyorPoint(getCycleRecorder().currentCycleIndex(), currentIndex);
ISurveyorData surveyorData = getSurveyorData();
surveyorImpl().requestSurveyor(new RequestSurveyorParam(getRequestSurveyorParamAuto(), getInstrumentHeight(), surveyorPoint, measureTimeIndex,
surveyorData.currentIndex(), surveyorData.leftOrRight(), isAlreadyRemindUserAimingAtWire));
SurveyorPoint surveyorPoint = getCachedData().getSurveyorPoint(getCycleRecorder().currentCycleIndex(), surveyorPointIndex);
surveyorImpl().requestSurveyor(new RequestParam(measureWhat(), isAlreadyRemindUserAimingAtWire, isWellSteel(), isAloneMeasureDistancePoint(), surveyorIndex, surveyorPointIndex, surveyorPoint));
}
private void onSuccess() {
@ -210,17 +166,19 @@ class _DoSurveyorState extends __BaseState implements ISurveyorListener, ISurvey
case RESULT_SUCCESS://进入读数检测状态
//检测是否处于「自动测量」
if (!surveyState.isAutoSurveying()) {
SurveyStateEvent.postSuccess(positionFragment);
SurveyStateEvent.postSuccess();
}
navigation2(StateType.checkReadData);
break;
case RESULT_FAILURE_EXCEED_MAX:
// if (SettingValueUtil.isAbandonPoint() && isAllowAbandonForVarifyIndex()) {
// boolean allowAbandon = App.getApp().isAllowSkip;
// if (allowAbandon && isAllowAbandonForVarifyIndex()) {
// dealErrorDataSkip(msg);
// } else {
// dealErrorDataNormal(msg);
// }
dealErrorDataNormal(msg);
break;
case RESULT_FAILURE_ERROR:
dealErrorDataNormal(msg);
@ -249,25 +207,23 @@ class _DoSurveyorState extends __BaseState implements ISurveyorListener, ISurvey
}
private void dealErrorDataNormal(String msg) {
SurveyStateEvent.postFailure(positionFragment);
SurveyStateEvent.postFailure();
//进入失败状态
Bundle args = _SurveyorFailureState.args(msg);
navigation2(StateType.SurveyorFailure, args);
}
private void dealErrorDataNormal(String msg, boolean isShowDialog) {
SurveyStateEvent.postFailure(positionFragment);
SurveyStateEvent.postFailure();
//进入失败状态
Bundle args = _SurveyorFailureState.args(msg, isShowDialog);
navigation2(StateType.SurveyorFailure, args);
}
private void dealErrorDataSkip(String msg) {
optionTipsCountDown(msg + Tools.getString(R.string.is_it_abandoned),
Tools.getString(R.string.switch_abandon),
Tools.getString(R.string.ignore),
optionTipsCountDown(msg + ",是否废弃?", "废弃", "忽略",
() -> {
changeSkip(getCycleRecorder().currentCycleIndex(), getCurrentIndex());
changeSkip(getCycleRecorder().currentCycleIndex(), getCurrentItemIndex());
navigation2(StateType.isSingleCycleCompleted);
},
() -> dealErrorDataNormal(msg, false),
@ -283,7 +239,7 @@ class _DoSurveyorState extends __BaseState implements ISurveyorListener, ISurvey
boolean autoClose = getStation().isAutoClose();
int pointCount = getCachedData().pointCount();
boolean abandon = true;
int currentIndex = getCurrentIndex();
int currentIndex = getCurrentItemIndex();
if (autoClose) {
if (currentIndex == 0 || currentIndex == pointCount - 1) {
abandon = false;
@ -295,4 +251,51 @@ class _DoSurveyorState extends __BaseState implements ISurveyorListener, ISurvey
}
return abandon;
}
@Override
public void onReceive(double originalHa, double originalVa, double sd, double clockwiseHa, double topVa, double hd, double vd) {
//重置错误读数
failureCount = 0;
if (getSurveyorData().onSurveyor(originalHa, originalVa, sd, hd)) {
//测量数据成功,可以退出测量状态
onSuccess();
} else {//测量数据不完全,需要继续测量
surveyorIndex = 1;//更新测量索引
refreshUI();
if (checkLeftNot(true)) {
return;
}
if (isAlreadyRemindUserAimingAtWire) {
navigation2(StateType.idle);
return;
}
sendSurveyRequestNext();
}
}
@Override
public void onError(String errorMsg) {
TtsManager.getInstance().speak(errorMsg);
if (allowTryWhenFailure) {//允许重新测量
if (!isLive()) {
return;
}
//测量出现异常,需要处理
failureCount++;
if (failureCount >= MAX_SURVEYOR_COUNT) {
if (isAutoSurveyOpen()) {
TtsManager.getInstance().speak("多次测量未成功,已暂停,请检查");
}
onCompleted(RESULT_FAILURE_EXCEED_MAX, "多次尝试测量未能成功");
} else {
//再次尝试
sendSurveyRequest();
Toast.makeText(getContext(), "接收数据超时,再次尝试测量", Toast.LENGTH_SHORT).show();
}
} else {
onCompleted(RESULT_FAILURE_ERROR, errorMsg);
}
}
}

@ -0,0 +1,34 @@
package com.bingce.controlnetwork.surveyor.state;
import android.os.Bundle;
import com.bingce.controlnetwork.R;
import com.bingce.controlnetwork.event.SurveyStateEvent;
import net.tatans.tensorflowtts.tts.TtsManager;
/**
* 钢丝测量旋转到位状态
*/
class _DoWellMeasureRotationReadyState extends __BaseState {
public _DoWellMeasureRotationReadyState(StateManagerTj stateManager) {
super(StateType.doWellMeasureRotationReady, stateManager);
}
@Override
public void enter(Bundle args) {
// TODO: 2024/8/30
// String msg;
// if (isWellSteel()) {
// msg = getContext().getString(R.string.please_aiming_at_wire_then_measure);
// } else if (isAloneMeasureDistancePoint()) {
// msg = getContext().getString(R.string.please_aiming_at_no_prism_then_measure);
// } else {
// msg = "请瞄准目标" + getCachedData().pointName(getCurrentCycleIndex(), getCurrentItemIndex()) + "后,再次点击开始测量";
// }
// runOnUI(() -> TtsManager.getInstance().speak(msg));
SurveyStateEvent.postIdle();
}
}

@ -0,0 +1,251 @@
package com.bingce.controlnetwork.surveyor.state;
import android.os.Bundle;
import android.util.Log;
import androidx.annotation.NonNull;
import com.bingce.controlapphelper.model.DataCategory;
import com.bingce.controlapphelper.model.LeftOrRight;
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.surveyor.data.ICachedData;
import com.bingce.controlnetwork.surveyor.data.ICycleRecorder;
import com.bingce.controlnetwork.surveyor.data.ISurveyorData;
import com.bingce.controlnetwork.surveyor.method.FindTargetMethod;
import com.bingce.controlnetwork.util.IdUtil;
import com.bingce.totalstation.ControlSurveyResult;
import org.greenrobot.eventbus.EventBus;
/**
* 空闲状态
* <p>
* 将刷新界面
*/
class _IdleState extends __BaseState {
private final @NonNull
IAutoModeSwitcher autoModeSwitcher;
public _IdleState(StateManagerTj stateManager, @NonNull IAutoModeSwitcher autoModeSwitcher) {
super(StateType.idle, stateManager);
this.autoModeSwitcher = autoModeSwitcher;
}
@Override
public void enter(Bundle args) {
//1.刷新界面
refreshUI();
//2.检测是否有数据,来控制goBack
refreshGoBackButton();
//3.当前cycle是否完成测量
boolean completed = _IsSingleCycleCompletedState.isSingleCycleCompleted(
stationId(),
getCycleRecorder().currentCycleIndex(),
getCachedData());
//4.检测是否满足自动测量条件
//判断当前条件是否满足自动测量
autoModeSwitcher.isReadyAutoSurvey(isReadyCode -> {
boolean isReady = isReadyCode == ControlSurveyResult.CODE_SUCCESS;
boolean isAutoSurveyOpen = false;
if (autoModeSwitcher.isAutoModeOpen() && isReady) {//如果打开着自动测量,且满足条件
if (isLive()) {
Log.d("hwhw", "从空闲状态进入测量状态");
navigation2(StateType.doSurveyor);
isAutoSurveyOpen = true;
} else {
autoModeSwitcher.resetAutoMode();
}
//发送通知,更新测量按钮UI
postEvent(true, isAutoSurveyOpen, completed);
} else if (autoModeSwitcher.isAutoModeInit() && isReady && !completed) {//自动测量状态为unknown,弹框提示用户选择
//用户选择后会发送通知,更新测量按钮UI
tips4StartAutoSurvey();
} else if (ControlSurveyResult.isAbandon(isReadyCode) != null) {
String msg = ControlSurveyResult.isAbandon(isReadyCode);
runOnUI(() -> {
optionTipsCountDown(msg + ",是否废弃?", "废弃", "重测",
() -> {
boolean success = dealSkip();
if (!success) {
resetSurveyForReadyAndComplete(isReady, completed);
}
},
() -> {
boolean success = reMeasure();
if (!success) {
resetSurveyForReadyAndComplete(isReady, completed);
}
},
() -> resetSurveyForReadyAndComplete(isReady, completed));
});
} else {
resetSurveyForReadyAndComplete(isReady, completed);
}
});
}
/**
* 弹框提示用户是否开启自动测量
*/
private void tips4StartAutoSurvey() {
// runOnUI(() ->
// TipsWith2OptionFragment.tips(
// fragmentManager(),
// lifecycleOwner(),
// getContext().getString(R.string.hint),
// null,
// null,
// null,
// getContext().getString(R.string.tips_finish_study_should_auto_survey),
// -1,
// false,
// new TipsWith2OptionFragment.SimpleCallback() {
// @Override
// public void onConfirm() {
// TtsManager.getInstance().speak("开始自动测量");
// autoModeSwitcher.openAutoMode();
// navigation2(StateType.doSurveyor);
//
// postEvent(true, true, false);
// }
//
// @Override
// public void onCancel() {
// autoModeSwitcher.closeAutoMode();
//
// postEvent(true, false, false);
// }
//
// @Override
// public void onIgnore() {
// autoModeSwitcher.closeAutoMode();
//
// postEvent(true, false, false);
// }
// }
// ));
}
private static void postEvent(boolean isReadyAutoSurvey, boolean isOpenAutoSurvey, boolean isSingleCompleted) {
EventBus.getDefault().post(new AutoSurveyorButtonVisibleEvent(isReadyAutoSurvey, isOpenAutoSurvey));
if (isSingleCompleted) {
SurveyStateEvent.postCompleted();
} else if (!isOpenAutoSurvey) {
SurveyStateEvent.postIdle();
}
}
@Override
protected void resume() {
autoModeSwitcher.resetAutoMode();
//刷新测量按钮
boolean completed = _IsSingleCycleCompletedState.isSingleCycleCompleted(
stationId(),
getCycleRecorder().currentCycleIndex(),
getCachedData());
autoModeSwitcher.isReadyAutoSurvey(code -> {
boolean isReady = code == ControlSurveyResult.CODE_SUCCESS;
postEvent(isReady, false, completed);
});
}
private void resetSurveyForReadyAndComplete(boolean isReady, boolean completed) {
//如果自动测量打开了,但是没有进入测量状态
//需要将自动测量开关重置
if (autoModeSwitcher.isAutoModeOpen()) {
autoModeSwitcher.resetAutoMode();
}
//发送通知,更新测量按钮UI
postEvent(isReady, false, completed);
}
private boolean reMeasure() {
FindTargetMethod.Target target = findLastTarget();
if (target == null) {
return false;
}
ICachedData cachedData = getCachedData();
cachedData.deleteSurveyorRecord(stationId(), target.cycleIndex
, target.itemIndex, target.leftOrRight);
//重置进度
setStationScheduleForSingleCycle(target.cycleIndex, SurveyorScheduleConstants.STATUE_VALUE_NO_COMPLETED);
setStationScheduleForAllCycle(SurveyorScheduleConstants.STATUE_VALUE_NO_COMPLETED);
//设置测量目标点
setSurveyPosition(target.itemIndex, target.leftOrRight);
scroll2(getCurrentCycleIndex(), target.itemIndex);
refreshUI();
navigation2(StateType.doSurveyor);
return true;
}
private boolean dealSkip() {
FindTargetMethod.Target lastTarget = findLastTarget();
if (lastTarget == null) {
return false;
}
changeSkip(getCycleRecorder().currentCycleIndex(), lastTarget.itemIndex);
navigation2(StateType.isSingleCycleCompleted);
return true;
}
private FindTargetMethod.Target findLastTarget() {
ICachedData cachedData = getCachedData();
ISurveyorData surveyorDataSource = getSurveyorData();
ICycleRecorder cycleRecorder = getCycleRecorder();
final int pointCount = cachedData.pointCount();
final int currentCycle = cycleRecorder.currentCycleIndex();
final int currentIndex = surveyorDataSource.currentIndex();
final LeftOrRight leftOrRight = surveyorDataSource.leftOrRight();
if (currentIndex < 0) {
return null;
}
String currentPointId = cachedData.pointId(currentCycle, currentIndex);
String currentRecordKey = IdUtil.surveyorRecordKey(stationId(), currentCycle, currentPointId, leftOrRight);
DataCategory dataCategory = cachedData.valueState(currentRecordKey);
DataCategory dataCategoryLook = null;
if (dataCategory.isNeedResurvey()) {//如果当前位置是脏数据(说明正在补测)
//回退到上一个脏数据位置
dataCategoryLook = DataCategory.dirtyAndSurveyed;
} else if (dataCategory.isEmptyData()) {
dataCategoryLook = DataCategory.normalCategory();
}
if (dataCategoryLook == null) {
return null;
}
return FindTargetMethod.findTargetInSingleCycle(
stationId(), currentCycle, currentIndex, leftOrRight, pointCount, false,
dataCategoryLook,
cachedData);
}
private void refreshGoBackButton() {
int currentCycle = getCycleRecorder().currentCycleIndex();
String pointId = getCachedData().pointId(currentCycle, 0);
DataCategory dataCategory = getCachedData().valueState(
IdUtil.surveyorRecordKey(stationId(), currentCycle, pointId, LeftOrRight.left), 0);
int fragmentPosition = RefreshRollBackEvent.getFragmentPosition(measureWhat(), getStation().isSeparateObservation());
EventBus.getDefault().post(new RefreshRollBackEvent(!dataCategory.isEmptyData(), fragmentPosition));
}
}

@ -1,14 +1,13 @@
package com.bingce.controlnetwork.surveyor.state.angledistance;
package com.bingce.controlnetwork.surveyor.state;
import android.os.Bundle;
import com.bingce.controlapphelper.model.DataCategory;
import com.bingce.controlapphelper.model.LeftOrRight;
import com.bingce.controlapphelper.surveyor.data.ICachedData;
import com.bingce.controlapphelper.surveyor.data.ICycleRecorder;
import com.bingce.controlapphelper.surveyor.data.ISurveyorData;
import com.bingce.controlapphelper.surveyor.state.StateType;
import com.bingce.controlapphelper.util.IdUtil;
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.util.IdUtil;
/**
* 判断是否满足2C检测条件
@ -17,7 +16,7 @@ class _Is2CCheckReadyState extends __BaseState {
private static final int RESULT_YES = 0;//可以检测「2C」
private static final int RESULT_NO = 1;//不可以检测「2C」
public _Is2CCheckReadyState(StateManager stateManager) {
public _Is2CCheckReadyState(StateManagerTj stateManager) {
super(StateType.isReady2CCheck, stateManager);
}
@ -35,7 +34,7 @@ class _Is2CCheckReadyState extends __BaseState {
//当前位置正处于测量,数据还没有缓存,所以不需要检测数据合法性
String pointId = cachedData.pointId(currentCycleIndex, currentIndex);
DataCategory oppositeCategory = cachedData.valueState(
IdUtil.createSurveyorRecordId(stationId(), currentCycleIndex, pointId, currentLeftOrRight.opposite()));
IdUtil.surveyorRecordKey(stationId(), currentCycleIndex, pointId, currentLeftOrRight.opposite()));
if (oppositeCategory.isFreshData()) {
onCompleted(RESULT_YES);
} else {

@ -1,21 +1,12 @@
package com.bingce.controlnetwork.surveyor.state.angledistance;
package com.bingce.controlnetwork.surveyor.state;
import android.os.Bundle;
import androidx.annotation.NonNull;
import com.bingce.controlapphelper.datasource.database.SurveyorDatabaseFactory;
import com.bingce.controlapphelper.datasource.database.config.ConfigConstants;
import com.bingce.controlapphelper.datasource.database.config.ConfigRecord;
import com.bingce.controlapphelper.datasource.database.config.IConfigDataSource;
import com.bingce.controlapphelper.datasource.database.schedule.SurveyorScheduleConstants;
import com.bingce.controlapphelper.surveyor.data.SpeakCache;
import com.bingce.controlapphelper.surveyor.state.IAutoModeSwitcher;
import com.bingce.controlapphelper.surveyor.state.StateType;
import com.bingce.controlapphelper.util.SurveyorCycleUtil;
import com.bingce.controlapphelper.util.Tools;
import com.bingce.controlnetwork.R;
import com.bingce.utils.ThreadPoolUtil;
import com.bingce.controlnetwork.bean.SurveyorScheduleConstants;
import com.bingce.controlnetwork.surveyor.data.SpeakCache;
import net.tatans.tensorflowtts.tts.TtsManager;
@ -28,14 +19,14 @@ public class _IsAllCycleCompletedState extends __BaseState {
private static final int INVALIDATE_CYCLE = -1;
private final IAutoModeSwitcher autoModeSwitcher;
public _IsAllCycleCompletedState(@NonNull StateManager stateManager, IAutoModeSwitcher autoModeSwitcher) {
public _IsAllCycleCompletedState(@NonNull StateManagerTj stateManager, IAutoModeSwitcher autoModeSwitcher) {
super(StateType.isAllCycleCompleted, stateManager);
this.autoModeSwitcher = autoModeSwitcher;
}
@Override
public void enter(Bundle args) {
int cycleCount = getToleranceRecord().getCycleCount();
int cycleCount = getCycleCount();
int theCycleNotAllDataIsValidate = INVALIDATE_CYCLE;
//查找数据不全的测回
@ -51,20 +42,14 @@ public class _IsAllCycleCompletedState extends __BaseState {
if (completed) {
if (isAutoSurveyOpen()) {
//检测是否已经提示
//检测是否需要提示测站检测
IConfigDataSource configDataSource =
SurveyorDatabaseFactory.instance.getConfigDataSource();
ThreadPoolUtil.execute(() -> {
String key = ConfigConstants.KEY_CONFIG_STATION_CHECK_REMINDED + stationId();
ConfigRecord record = configDataSource.getByKeySync(key);
if (record == null || ConfigConstants.VALUE_NO.equals(record.getConfigValue())) {
runOnUI(() -> TtsManager.getInstance().speak(Tools.getString(R.string.all_cycle_completed)));
}
});
// //检测是否已经提示
// //检测是否需要提示测站检测
// IConfigDataSource configDataSource =
// SurveyorDatabaseFactory.instance.getConfigDataSource();
runOnUI(() -> TtsManager.getInstance().speak("所有测回已完成"));
}
//标识测站完成测量(数据库存储)
setAllCycleSchedule(SurveyorScheduleConstants.STATUE_VALUE_COMPLETED);
setStationScheduleForAllCycle(SurveyorScheduleConstants.STATUE_VALUE_COMPLETED);
//进入idle状态
//清除测量状态,进入测站检测,停止自动测量
enterStationCheckAndClearSurveyStateAndResetAutoMode();
@ -74,13 +59,13 @@ public class _IsAllCycleCompletedState extends __BaseState {
//切换测回
getCycleRecorder().changeCycleIndex(theCycleNotAllDataIsValidate);
//修改当前测回
setCurrentCycle(theCycleNotAllDataIsValidate);
setStationCycle(theCycleNotAllDataIsValidate);
//存储一下已经播放切换测回的的节点
SpeakCache.getInstance().saveSpeakSwitchCycle();
//查找测量目标
findTargetFromBeginInCurrentCycle(false);
//播报
TtsManager.getInstance().speak(Tools.getString(R.string.current_cycle_complete_start_surveyor) + SurveyorCycleUtil.cycleName(theCycleNotAllDataIsValidate));
TtsManager.getInstance().speak("当前测回已完成,开始测量" + SurveyorCycleUtil.cycleName(theCycleNotAllDataIsValidate));
} else {
//提示是否进入其他未完成测回继续测量
option4Jump2OtherEmptyCycle(theCycleNotAllDataIsValidate);

@ -1,14 +1,14 @@
package com.bingce.controlnetwork.surveyor.state.angledistance;
package com.bingce.controlnetwork.surveyor.state;
import android.os.Bundle;
import com.bingce.controlapphelper.model.DataCategory;
import com.bingce.controlapphelper.model.LeftOrRight;
import com.bingce.controlapphelper.surveyor.data.ICachedData;
import com.bingce.controlapphelper.surveyor.data.ICycleRecorder;
import com.bingce.controlapphelper.surveyor.data.ISurveyorData;
import com.bingce.controlapphelper.surveyor.state.StateType;
import com.bingce.controlapphelper.util.IdUtil;
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.util.IdUtil;
/*
* 判断是否需要检测半测回归零差
@ -18,7 +18,7 @@ class _IsHalfCycleZeroCheckReadyState extends __BaseState {
private static final int RESULT_YES = 0;//可以检测「半测回归零差」
private static final int RESULT_NO = 1;//不可以检测「半测回归零差」
public _IsHalfCycleZeroCheckReadyState(StateManager stateManager) {
public _IsHalfCycleZeroCheckReadyState(StateManagerTj stateManager) {
super(StateType.isHalfCycleZeroCheckReady, stateManager);
}
@ -42,7 +42,7 @@ class _IsHalfCycleZeroCheckReadyState extends __BaseState {
int targetIndex = pointCount - 1 - currentItemIndex;
String targetPointId = cachedData.pointId(cycleRecorder.currentCycleIndex(), targetIndex);
String targetKey = IdUtil.createSurveyorRecordId(stationId, cycleIndex, targetPointId, leftOrRight);
String targetKey = IdUtil.surveyorRecordKey(stationId, cycleIndex, targetPointId, leftOrRight);
DataCategory targetDataCategory = cachedData.valueState(targetKey);
//对面数据正常,可以执行半测回归零
if (targetDataCategory.isFreshData()) {

@ -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.schedule.SurveyorScheduleConstants;
import com.bingce.controlapphelper.model.DataCategory;
import com.bingce.controlapphelper.model.LeftOrRight;
import com.bingce.controlapphelper.surveyor.data.ICachedData;
import com.bingce.controlapphelper.surveyor.state.StateType;
import com.bingce.controlapphelper.util.IdUtil;
import com.bingce.controlnetwork.bean.SurveyorScheduleConstants;
import com.bingce.controlnetwork.surveyor.data.ICachedData;
import com.bingce.controlnetwork.util.IdUtil;
public class _IsSingleCycleCompletedState extends __BaseState {
private static final int RESULT_YES = 0;//测回结束
private static final int RESULT_NO = 1;//测回未结束
public _IsSingleCycleCompletedState(StateManager stateManager) {
public _IsSingleCycleCompletedState(StateManagerTj stateManager) {
super(StateType.isSingleCycleCompleted, stateManager);
}
@ -34,7 +33,7 @@ public class _IsSingleCycleCompletedState extends __BaseState {
int cycleIndex = getCycleRecorder().currentCycleIndex();
//更新测回测量进度
setSingleCycleSchedule(cycleIndex, SurveyorScheduleConstants.STATUE_VALUE_COMPLETED);
setStationScheduleForSingleCycle(cycleIndex, SurveyorScheduleConstants.STATUE_VALUE_COMPLETED);
//状态切换
navigation2(StateType.checkSingleCycle);
} else {
@ -51,14 +50,14 @@ public class _IsSingleCycleCompletedState extends __BaseState {
//测回内所有数据都是「新鲜数据」才能执行「测回内检测」
for (int index = 0; index < cachedData.pointCount(); index++) {
if (cachedData.isPointAbandon(cycleIndex, index)) {
if (cachedData.isAbandonPoint(cycleIndex, index)) {
continue;
}
String pointId = cachedData.pointId(cycleIndex, index);
String leftKey = IdUtil.createSurveyorRecordId(stationId, cycleIndex, pointId, LeftOrRight.left);
String rightKey = IdUtil.createSurveyorRecordId(stationId, cycleIndex, pointId, LeftOrRight.right);
String leftKey = IdUtil.surveyorRecordKey(stationId, cycleIndex, pointId, LeftOrRight.left);
String rightKey = IdUtil.surveyorRecordKey(stationId, cycleIndex, pointId, LeftOrRight.right);
DataCategory leftDataCategory = cachedData.valueState(leftKey);
DataCategory rightDataCategory = cachedData.valueState(rightKey);

@ -1,19 +1,15 @@
package com.bingce.controlnetwork.surveyor.state.angledistance;
package com.bingce.controlnetwork.surveyor.state;
import android.os.Bundle;
import com.bingce.controlapphelper.surveyor.state.StateType;
import com.bingce.controlapphelper.util.Tools;
import com.bingce.controlnetwork.R;
/*
* 仪器导致的测量失败
*
* 全站仪多次测量失败进入该状态
* */
class _SurveyorFailureState extends __BaseState {
public class _SurveyorFailureState extends __BaseState {
public _SurveyorFailureState(StateManager stateManager) {
public _SurveyorFailureState(StateManagerTj stateManager) {
super(StateType.SurveyorFailure, stateManager);
}
@ -27,7 +23,7 @@ class _SurveyorFailureState extends __BaseState {
}
if (isShowDialog) {
failureTipsWithAutoStandStill(error + Tools.getString(R.string.please_observe_target));
failureTipsWithAutoStandStill(error + ",请重新观测该目标.", null);
} else {
enterIdleAndClearSurveyStateAndResetAutoMode(true);
}

@ -0,0 +1,306 @@
package com.bingce.controlnetwork.surveyor.state;
import android.util.Log;
import com.bingce.controlapphelper.datasource.database.SurveyorDatabaseFactory;
import com.bingce.controlapphelper.datasource.database.schedule.SurveyorScheduleRecord;
import com.bingce.controlapphelper.model.LeftOrRight;
import com.bingce.controlapphelper.util.SurveyorCycleUtil;
import com.bingce.controlnetwork.R;
import com.bingce.controlnetwork.bean.SurveyorScheduleConstants;
import com.bingce.controlnetwork.fragment.TipsFragment;
import com.bingce.controlnetwork.surveyor.method.model.IStateDelegate;
import com.bingce.controlnetwork.surveyor.state.base.AbstructState;
import com.bingce.controlnetwork.util.StationUtilPla;
import com.bingce.totalstation.TotalStation;
import java.util.List;
import blankj.utilcode.util.ToastUtils;
public abstract class __BaseState extends AbstructState {
/**
* 判断常量
*/
private final int DEFAULT_AUTO_MODE = 0;
private final int RESET_AUTO_MODE = 1;
private final int CLOSE_AUTO_MODE = 2;
public __BaseState(final StateType stateType, final StateManagerTj stateManager) {
super(stateType, stateManager);
}
/**
* 设置测量位置
*/
@Override
protected void setSurveyPosition(int index, LeftOrRight leftOrRight) {
getSurveyorData().setCurrentIndex(index);
getSurveyorData().setLeftOrRight(leftOrRight);
int currentCycleIndex = getCycleRecorder().currentCycleIndex();
//新增
boolean wellSteelPoint = getCachedData().isWellSteelPoint(currentCycleIndex, index);
if (wellSteelPoint)
ToastUtils.showShort("钢丝点");
}
final protected void failureTipsWithAutoStandStill(String msg, Runnable runnable) {
if (!isLive()) {
return;
}
TipsFragment.noCancelAbleTips(fragmentManager(), lifecycleOwner(),
getContext(),
msg,
-1,
() -> {
if (runnable != null) {
runnable.run();
}
enterIdleAndClearSurveyStateAndResetAutoMode(true);
});
}
final protected void optionTipsWithStandStill(String msg, Runnable confirmCallback) {
optionTips(msg, null, null,
confirmCallback,
() -> enterIdleAndClearSurveyStateAndResetAutoMode(true),
() -> enterIdleAndClearSurveyStateAndResetAutoMode(true));
}
/**
* 提供选择操作
* 如果用户选择忽略则自动保持原地不动进入idle状态
*/
final protected void optionTipsWithStandStill(
String msg, String confirmButton, String cancelButton, Runnable confirmCallback) {
optionTips(msg, confirmButton, cancelButton,
confirmCallback,
() -> enterIdleAndClearSurveyStateAndResetAutoMode(true),
() -> enterIdleAndClearSurveyStateAndResetAutoMode(true));
}
protected final void option4Jump2OtherCycle4Resurvey(int cycleIndex) {
option4Jump2OtherCycle(cycleIndex, true);
}
protected final void option4Jump2OtherEmptyCycle(int cycleIndex) {
option4Jump2OtherCycle(cycleIndex, false);
}
private void option4Jump2OtherCycle(int cycleIndex, boolean resurveyOrEmpty) {
String msg = "有待测数据,是否跳转到该处继续.";
if (resurveyOrEmpty) {
msg = "有待补测数据,是否跳转到该处继续.";
}
optionTips("在" + SurveyorCycleUtil.cycleName(cycleIndex) + msg,
null,
null,
() -> {
//切换测回
getCycleRecorder().changeCycleIndex(cycleIndex);
//数据库存储修改当前测回
setStationCycle(cycleIndex);
//查找测量目标
findTargetFromBeginInCurrentCycle(false);
},
() -> enterIdleAndClearSurveyStateAndResetAutoMode(true),
() -> enterIdleAndClearSurveyStateAndResetAutoMode(true));
}
@Override
final protected void setStationCycle(int cycle) {
getCycleRecorder().changeCycleIndex(cycle);
SurveyorDatabaseFactory
.instance
.getScheduleDataSource()
.record(
new SurveyorScheduleRecord(
SurveyorScheduleConstants.stationCurrentCycleKey(stationId(), stateManager.getMeasureWhat()),
String.valueOf(cycle)));
}
@Override
final protected void setStationScheduleForSingleCycle(int cycleIndex, String statue) {
SurveyorDatabaseFactory
.instance
.getScheduleDataSource()
.record(
new SurveyorScheduleRecord(
SurveyorScheduleConstants.stationSingleCycleScheduleKey(stationId(), stateManager.getMeasureWhat(), cycleIndex),
statue));
}
@Override
final protected void setStationScheduleForAllCycle(String statue) {
SurveyorDatabaseFactory
.instance
.getScheduleDataSource()
.record(
new SurveyorScheduleRecord(
SurveyorScheduleConstants.stationAllCycleScheduleKey(stationId(), stateManager.getMeasureWhat()),
statue));
}
/**
* 如果resetAutoSurveyState为true将重置autoSurvey状态为unknown
*/
final protected void findTargetFromBeginInCurrentCycle(boolean resetAutoSurveyState) {
getSurveyorData().clearSurveyStateAndPosition();
if (resetAutoSurveyState) {
autoModeRecorder().resetAutoMode();
}
navigation2(StateType.doMove2NextValidate);
}
final protected void enterIdleAndClearSurveyState() {
clearSurveyStateAndCloseAutoModeAndStandStill(DEFAULT_AUTO_MODE,
false, StateType.idle);
}
/**
* 取消测量会停在当前位置索引+盘左or盘右并进入idle
*/
final protected void enterIdleAndClearSurveyStateAndResetAutoMode(boolean resetAutoMode) {
clearSurveyStateAndCloseAutoModeAndStandStill(resetAutoMode ? RESET_AUTO_MODE : DEFAULT_AUTO_MODE,
false, StateType.idle);
}
final protected void enterIdleAndClearSurveyorStatePosition() {
clearSurveyStateAndCloseAutoModeAndStandStill(DEFAULT_AUTO_MODE,
true, StateType.idle);
}
final protected void enterStationCheckAndClearSurveyStateAndResetAutoMode() {
clearSurveyStateAndCloseAutoModeAndStandStill(RESET_AUTO_MODE,
false, StateType.checkStation);
}
final protected void enterIdleAndClearSurveyStateAndCloseAutoMode() {
clearSurveyStateAndCloseAutoModeAndStandStill(CLOSE_AUTO_MODE, false, StateType.idle);
}
/**
* @param autoMode
* @param clearPosition
* @param stateType
*/
private void clearSurveyStateAndCloseAutoModeAndStandStill(int autoMode, boolean clearPosition, StateType stateType) {
//重置或者关闭自动模式
if (autoMode == RESET_AUTO_MODE) {
autoModeRecorder().resetAutoMode();
} else if (autoMode == CLOSE_AUTO_MODE) {
autoModeRecorder().closeAutoMode();
}
//更新测量进度标识
if (clearPosition) {
getSurveyorData().clearSurveyStateAndPosition();
} else {
getSurveyorData().clearSurveyState();
}
//进入某个状态
navigation2(stateType);
}
protected IStateDelegate stateDelegate() {
return new IStateDelegate() {
@Override
public void onOptionTips(
String msg, String confirmButton, String cancelButton,
Runnable confirmCallback, Runnable cancelCallback, Runnable ignoreCallback) {
optionTips(
msg, confirmButton, cancelButton,
confirmCallback, cancelCallback, ignoreCallback);
}
@Override
public void resetSurveyorStateAndKeepPosition() {
//关闭自动测量
autoModeRecorder().resetAutoMode();
//更新测量进度标识
getSurveyorData().clearSurveyState();
//进入空闲状态
navigation2(StateType.idle);
}
@Override
public void resurveyPoints(int cycleIndex, List<String> pointIds) {
if (cycleIndex == -1) {
cycleIndex = getCycleRecorder().currentCycleIndex();
}
//更新记录数据,包括将数据置为dirty和切换cycle
getCachedData().markReSurveyor(stationId(), cycleIndex, pointIds);
getCycleRecorder().changeCycleIndex(cycleIndex);
//根据当前状态,查找一个目标
findTargetFromBeginInCurrentCycle(true);
//更新数据库标识
setStationCycle(cycleIndex);
setStationScheduleForAllCycle(SurveyorScheduleConstants.STATUE_VALUE_NO_COMPLETED);
setStationScheduleForSingleCycle(cycleIndex, SurveyorScheduleConstants.STATUE_VALUE_NO_COMPLETED);
}
@Override
public void deleteSingleCycleData(int cycleIndex) {
//删除数据
getCachedData().deleteSurveyorRecord(stationId(), cycleIndex);
//切换测回--一般不用,但是这里为了保险
getCycleRecorder().changeCycleIndex(cycleIndex);
//查找一个新目标开启测量
findTargetFromBeginInCurrentCycle(true);
//更新数据库标识
setStationCycle(cycleIndex);
setStationScheduleForAllCycle(SurveyorScheduleConstants.STATUE_VALUE_NO_COMPLETED);
setStationScheduleForSingleCycle(cycleIndex, SurveyorScheduleConstants.STATUE_VALUE_NO_COMPLETED);
}
};
}
@Override
protected int getCycleCount() {
return StationUtilPla.getCycleCount(stateManager.getMeasureWhat(), getStation(), getToleranceRecord());
}
/**
* 如果是测回内首次测量需要判断是否是盘左
*/
protected boolean checkLeftNot(boolean isFirst) {
int currentItem = getSurveyorData().currentIndex();
LeftOrRight leftOrRight = getSurveyorData().leftOrRight();
if (currentItem == 0 && leftOrRight == LeftOrRight.left) {
//如果是首次测量,强制要求使用盘左
double vAngle;
if (isFirst) {
vAngle = getSurveyorData().getAngleVer1();
} else {
vAngle = getSurveyorData().getAngleVer();
}
if (!isLeftVerAngle(vAngle)) {
failureTipsWithAutoStandStill(
getContext().getString(R.string.error_tips_please_start_from_left),
() -> {
Log.d("hwhw", "TotalStation.getInstance().requestChangeFace()");
TotalStation.getInstance().requestChangeFace();
});
return true;
}
}
return false;
}
private boolean isLeftVerAngle(double vAngle) {
return vAngle >= 0 && vAngle <= Math.PI;
}
}

@ -1,498 +0,0 @@
package com.bingce.controlnetwork.surveyor.state.alonedistance;
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.alonedistance.AloneDistanceRecord;
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.event.RefreshGoBackButtonAloneDistance;
import com.bingce.controlapphelper.model.LeftOrRight;
import com.bingce.controlapphelper.surveyor.data.CachedDataAloneDistance;
import com.bingce.controlapphelper.surveyor.data.ICycleRecorder;
import com.bingce.controlapphelper.surveyor.data.ISurveyorData;
import com.bingce.controlapphelper.surveyor.method.AutoSurveyorMethod;
import com.bingce.controlapphelper.surveyor.state.IAutoModeSwitcher;
import com.bingce.controlapphelper.surveyor.state.IStateType;
import com.bingce.controlapphelper.surveyor.state.ISurveyState;
import com.bingce.controlapphelper.surveyor.state.StateType;
import com.bingce.controlapphelper.surveyor.surveyor.ISurveyor;
import com.bingce.controlapphelper.surveyor.surveyor.ISurveyorListener;
import com.bingce.controlapphelper.surveyor.surveyor.ISurveyorRemindListener;
import com.bingce.controlapphelper.surveyor.surveyor.RequestSurveyorParamAuto;
import com.bingce.controlapphelper.surveyor.surveyor.SurveyorAutoImpl;
import com.bingce.controlapphelper.surveyor.surveyor.SurveyorMock;
import com.bingce.controlapphelper.surveyor.surveyor.SurveyorMockAuto;
import com.bingce.controlapphelper.surveyor.surveyor.SurveyorSingleImpl;
import com.bingce.controlapphelper.surveyor.test.Test;
import com.bingce.controlapphelper.util.DigitalUtil;
import com.bingce.controlapphelper.util.IUIRunner;
import com.bingce.controlapphelper.util.IdUtil;
import com.bingce.controlnetwork.R;
import com.bingce.controlnetwork.fragment.stationsurvey.angledistance.MeasureVm;
import com.bingce.controlnetwork.surveyor.state.AutoModeType;
import com.bingce.controlnetwork.surveyor.state.IScrollDelegate;
import com.bingce.controlnetwork.surveyor.state.StateConstants;
import com.bingce.coordlib.model.Coordinate;
import com.bingce.totalstation.ControlSurveyData;
import com.bingce.totalstation.ControlSurveyResult;
import com.bingce.utils.ThreadPoolUtil;
import com.bingce.utils.VipManager;
import org.greenrobot.eventbus.EventBus;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import blankj.utilcode.util.ToastUtils;
public class StateManagerAloneDistance implements IAutoModeSwitcher, ISurveyState, IStateType {
//单独测距代码里的cycleIndex只有一个测回
public static final int CYCLE_INDEX_DEFAULT = 0;
private final Map<StateType, __BaseState> stateMap = new HashMap<>();
private StateType currentStateType = StateType.idle;
private final FragmentManager fragmentManager;
private final LifecycleOwner lifecycleOwner;
private final IUIRunner iuiRunner;
final IScrollDelegate scrollDelegate;
@NonNull
SurveyorStationRecord stationRecord;
@NonNull
final CachedDataAloneDistance cachedData;
final @NonNull
ToleranceDetailRecord toleranceRecord;
final @NonNull
ISurveyorData surveyorData;
final @NonNull
MeasureVm measureVm;
final @NonNull
ICycleRecorder cycleRecorder;
final @NonNull
Context context;
private AutoModeType autoMode = AutoModeType.unknown;
@NonNull
final ISurveyor surveyor;
final PointRecord stationPointRecord;
final boolean supportAutoSurvey;
private StateManagerAloneDistance(final boolean supportAutoSurvey,//是否支持自动测量
final @NonNull SurveyorStationRecord stationRecord,
final @NonNull PointRecord stationPointRecord,
final @NonNull ToleranceDetailRecord toleranceRecord,
final @NonNull Context context,
final @NonNull ISurveyorData surveyorData,
final @NonNull ICycleRecorder cycleRecorder,
final @NonNull CachedDataAloneDistance cachedData,
final @NonNull MeasureVm measureVm,
final @NonNull IScrollDelegate scrollDelegate,
FragmentManager fragmentManager,
LifecycleOwner lifecycleOwner,
IUIRunner iuiRunner) {
this.supportAutoSurvey = supportAutoSurvey;
this.stationRecord = stationRecord;
this.stationPointRecord = stationPointRecord;
this.fragmentManager = fragmentManager;
this.lifecycleOwner = lifecycleOwner;
this.iuiRunner = iuiRunner;
this.scrollDelegate = scrollDelegate;
this.context = context;
this.toleranceRecord = toleranceRecord;
this.surveyorData = surveyorData;
this.cachedData = cachedData;
this.measureVm = measureVm;
this.cycleRecorder = cycleRecorder;
if (Test.DEBUG) {
surveyor = new SurveyorMockAuto(StateConstants.VALUE_MEASURE_WHAT_DISTANCE,
this.stationRecord.getId(),
this.stationRecord.isAutoClose(),
toleranceRecord.getCycleCount(),
cachedData, surveyorData, cycleRecorder, this, this);
} else {
if (supportAutoSurvey) {
surveyor = new SurveyorAutoImpl(StateConstants.VALUE_MEASURE_WHAT_DISTANCE, this);
} else {
surveyor = new SurveyorSingleImpl(StateConstants.VALUE_MEASURE_WHAT_DISTANCE);
}
}
_DoSurveyorState doSurveyorState = new _DoSurveyorState(this, this);
surveyor.register((ISurveyorListener) doSurveyorState);
surveyor.register((ISurveyorRemindListener) doSurveyorState);
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.checkReadData, new _CheckReadDataState(this, 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.doCalAdjust, new _DoCalAdjustState(this));
stateMap.put(StateType.idle, new _IdleState(this, this));
stateMap.put(StateType.doWellMeasureRotationReady, new _DoWellMeasureRotationReadyState(this));
}
public void updateStationRecord(SurveyorStationRecord stationRecord) {
this.stationRecord = stationRecord;
ThreadPoolUtil.execute(() -> {
cachedData.updateDataSouce(stationRecord);
if (Test.DEBUG && surveyor instanceof SurveyorMock) {
((SurveyorMock) surveyor).updateData();
}
_DoCalScheduleInSingleCycleState.enter(this, CYCLE_INDEX_DEFAULT);
//最后刷新下页面
runOnUI(cachedData::notifyDateChange);
});
// //更新测点棱镜信息
// if (stationRecord.getItems() != null) {
// for (SurveyorPoint item : stationRecord.getItems()) {
// if (item == null || !SurveyorPoint.TYPE_POINT.equals(item.getType())) {
// continue;
// }
// cachedData.updateSurveyPointParams(item);
// }
// }
}
String stationId() {
return stationRecord.getId();
}
@Override
public void enter(StateType type, Bundle args) {
__BaseState baseState = stateMap.get(type);
if (baseState != null) {
this.currentStateType = type;
runOnUI(() -> baseState.enter(args));
}
}
@Override
public void enter(StateType type) {
enter(type, null);
}
void runOnUI(Runnable action) {
if (iuiRunner != null) {
iuiRunner.runOnUI(action);
}
}
public void doSurveyor() {
boolean inValidate = isInValidate();
if (inValidate) {
return;
}
int pointCount = cachedData.pointCount();
if (pointCount == 0) {
ToastUtils.showShort(R.string.no_data_available_yet);
return;
}
Bundle bundle = null;
if (isRotationReadyState()) {
//当前是旋转到位状态
bundle = new Bundle();
bundle.putBoolean(StateConstants.KEY_IS_ROTATION_READY_STATE, true);
}
enter(StateType.doSurveyor, bundle);
}
private boolean isRotationReadyState() {
return currentStateType == StateType.doWellMeasureRotationReady;
}
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);
}
/**
* 切换测回时触发
*
* @param cycleIndex
*/
public void switch2Cycle(int cycleIndex) {
//由于井定向的距离测量是不用切换测回的,在一个页面展示了两个测回
// if (isInValidate()) {
// return;
// }
// _DoCalScheduleInSingleCycleState.enter(this, cycleIndex);
}
/**
* 进入开始测量的时候触发
*
* @param cycleIndex
*/
public void calScheduleWhenEnterSurveyFragment(int cycleIndex) {
if (isInValidate()) {
return;
}
_DoCalScheduleInSingleCycleState.enter(this, cycleIndex);
}
public void moveBack() {
if (isInValidate()) {
return;
}
enter(StateType.doMoveBack);
}
//检测当前状态是否支持从外界主动改变状态
//如果是空闲或者是测站通过检测是有效的状态
private boolean isInValidate() {
return currentStateType != StateType.idle
&& StateType.stationCheckedSuccess != currentStateType
&& !isRotationReadyState();
}
FragmentManager fragmentManager() {
return this.fragmentManager;
}
LifecycleOwner lifecycleOwner() {
return this.lifecycleOwner;
}
final boolean isStationAutoClosed() {
return stationRecord.isAutoClose();
}
@WorkerThread
public static StateManagerAloneDistance newInstance(
boolean isSupportAutoMode,
@NonNull SurveyorStationRecord stationRecord,
@NonNull Context context,
@NonNull FragmentManager fragmentManager,
@NonNull LifecycleOwner lifecycleOwner,
@NonNull ToleranceDetailRecord toleranceRecord,
@NonNull ISurveyorData surveyorData,
@NonNull ICycleRecorder cycleRecorder,
@NonNull CachedDataAloneDistance cachedData,
@NonNull MeasureVm measureVm,
IScrollDelegate 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 = Test.DEBUG;
//App.isDebug()
if (isSupportAutoMode &&
(VipManager.getInstance().checkReg() || VipManager.getInstance().checkControlProLevel())) {
supportAuto = true;
}
StateManagerAloneDistance manager = new StateManagerAloneDistance(supportAuto,
stationRecord,
stationPointRecord,
toleranceRecord,
context,
surveyorData,
cycleRecorder,
cachedData,
measureVm,
scrollDelegate,
fragmentManager, lifecycleOwner, runner);
return manager;
}
@Override
public boolean isAutoModeOpen() {
return autoMode == AutoModeType.start;
}
@Override
public boolean isAutoModeClose() {
return autoMode == AutoModeType.stop;
}
@Override
public boolean isAutoModeNotSpecial() {
return autoMode == AutoModeType.unknown;
}
@Override
public void openAutoMode() {
autoMode = AutoModeType.start;
}
@Override
public void closeAutoMode() {
autoMode = AutoModeType.stop;
}
@Override
public void resetAutoMode() {
autoMode = AutoModeType.unknown;
}
@Override
public int isReadyAutoSurvey() {
if (!supportAutoSurvey) {
return ControlSurveyResult.CODE_ERROR;
}
if (!surveyor.isReady()) {
return ControlSurveyResult.CODE_ERROR;
}
if (getRequestSurveyorParamAuto() == null) {
return ControlSurveyResult.CODE_ERROR;
}
double instrumentHeight = getInsturmentHeight();
Coordinate stationBasePoint = getStationCoord();
return getRequestSurveyorParamAuto().checkAutoCondition(getCachedData(), stationBasePoint, instrumentHeight);
}
@Override
public String isMeasuredValueMatchDesign() {
if (!supportAutoSurvey) return null;
double instrumentHeight = getInsturmentHeight();
Coordinate stationBasePoint = getStationCoord();
List<ControlSurveyData> originMeasureList = getRequestSurveyorParamAuto().getOriginMeasureList(getCachedData());
return AutoSurveyorMethod.checkAutoSurveyorMeasuredValue(stationBasePoint, instrumentHeight, originMeasureList);
}
@Override
public boolean isSurveying() {
return currentStateType == StateType.doSurveyor || currentStateType == StateType.doAutoSurveyor;
}
@Override
public boolean isAutoSurveying() {
return isAutoModeOpen();
}
public void switchCurrentMeasurePosition(int position) {
if (currentStateType == StateType.idle) {
__BaseState baseState = stateMap.get(currentStateType);
if (baseState != null) {
baseState.setSurveyPosition(position, LeftOrRight.left);
}
}
}
public CachedDataAloneDistance getCachedData() {
return cachedData;
}
@NonNull
public ToleranceDetailRecord getToleranceRecord() {
return toleranceRecord;
}
private Coordinate getStationCoord() {
if (PointRecord.TYPE_KNOWN_POINT.equals(stationPointRecord.getPointType())) {
return new Coordinate(
stationPointRecord.getX(),
stationPointRecord.getY(),
stationPointRecord.getZ());
}
return null;
}
public double getInsturmentHeight() {
return DigitalUtil.valueOfDoubleString(stationRecord.getInstrumentHeight(), 0);
}
public RequestSurveyorParamAuto getRequestSurveyorParamAuto() {
return measureVm.getRequestSurveyorParamAuto();
}
public void refreshGoBackBtnEnable() {
CachedDataAloneDistance cachedData = getCachedData();
int currentCycle = cycleRecorder.currentCycleIndex();
String pointId = getCachedData().pointId(currentCycle, 0);
String cacheKey = IdUtil.createSurveyorRecordId(stationId(), currentCycle, pointId, LeftOrRight.left);
AloneDistanceRecord aloneDistanceRecord = cachedData.getAloneDistanceRecord(cacheKey);
boolean isRollBackBtnEnable = aloneDistanceRecord != null && !aloneDistanceRecord.distanceValues.isEmpty();
EventBus.getDefault().post(new RefreshGoBackButtonAloneDistance(isRollBackBtnEnable));
}
}

@ -1,75 +0,0 @@
package com.bingce.controlnetwork.surveyor.state.alonedistance;
import android.os.Bundle;
import com.bingce.controlapphelper.surveyor.state.IAutoModeSwitcher;
import com.bingce.controlapphelper.surveyor.state.StateType;
import com.bingce.controlapphelper.util.Tools;
import com.bingce.controlnetwork.R;
import net.tatans.tensorflowtts.tts.TtsManager;
/**
* 检测当前测量数据读数互差
*/
class _CheckReadDataState extends __BaseState {
private static final int RESULT_SUCCESS = 0;
private static final int RESULT_FAILURE_HOR = 1;
private static final int RESULT_FAILURE_VER = 2;
private static final int RESULT_FAILURE_DISTANCE = 3;
private final IAutoModeSwitcher autoModeSwitcher;
public _CheckReadDataState(StateManagerAloneDistance stateManager, IAutoModeSwitcher autoModeSwitcher) {
super(StateType.checkReadData, stateManager);
this.autoModeSwitcher = autoModeSwitcher;
}
@Override
public void enter(Bundle args) {
//先检测测量值和设计值是否匹配(仅在自动测量打开下检测)
String error = autoModeSwitcher.isMeasuredValueMatchDesign();
if (error != null) {
failureTipsWithAutoStandStill(error);
return;
}
onCompleted(RESULT_SUCCESS);
}
private void onCompleted(int result) {
if (RESULT_SUCCESS == result) {
navigation2(StateType.checkSingleCycle);
} else {
String msg = "";
switch (result) {
case RESULT_FAILURE_HOR:
msg = Tools.getString(R.string.hor_angle_read_data_limit);
break;
case RESULT_FAILURE_VER:
msg = Tools.getString(R.string.ver_angle_read_data_limit);
break;
case RESULT_FAILURE_DISTANCE:
msg = Tools.getString(R.string.distance_read_data_limit);
break;
default:
navigation2(StateType.idle);
return;
}
if (isAutoSurveyOpen()) {
TtsManager.getInstance().speak(msg);
}
failureTipsWithAutoStandStill(msg);
}
}
/**
* 斜距两次读数差
*
* @param distance1 读数1
* @param distance2 读数2
* @return 读数差(单位毫米)
*/
public static double distanceReadDiff(double distance1, double distance2) {
return Math.abs(distance1 - distance2) * 1000;
}
}

@ -1,90 +0,0 @@
package com.bingce.controlnetwork.surveyor.state.alonedistance;
import android.os.Bundle;
import com.bingce.controlapphelper.datasource.database.alonedistance.AloneDistanceRecord;
import com.bingce.controlapphelper.datasource.database.schedule.SurveyorScheduleConstants;
import com.bingce.controlapphelper.datasource.database.tolerance.detail.ToleranceDetailRecord;
import com.bingce.controlapphelper.model.LeftOrRight;
import com.bingce.controlapphelper.surveyor.data.CachedDataAloneDistance;
import com.bingce.controlapphelper.surveyor.state.StateType;
import com.bingce.controlapphelper.util.Tools;
import com.bingce.controlnetwork.R;
import java.util.List;
/**
* 测回内不同方向2c方向i互差检测
*/
class _CheckSingleCycleState extends __BaseState {
public _CheckSingleCycleState(StateManagerAloneDistance stateManager) {
super(StateType.checkSingleCycle, stateManager);
}
@Override
public void enter(Bundle args) {
doCheck();
}
private void doCheck() {
ToleranceDetailRecord toleranceRecord = getToleranceRecord();
CachedDataAloneDistance cachedData = getCachedData();
int surveyorCount = getSurveyorCount();
int cycleIndex = getCycleRecorder().currentCycleIndex();
int currentIndex = getCurrentIndex();
double distCyclesDifference = toleranceRecord.getSlopeCycleDistanceDifference()/*slopeCycleDistanceDifference*/;
AloneDistanceRecord aloneDistanceRecord = getAloneDistanceRecord(currentIndex);
if (aloneDistanceRecord == null || aloneDistanceRecord.distanceValues.size() < surveyorCount * 2) {
//进入旋转到位状态等待点击继续测量
navigation2(StateType.doWellMeasureRotationReady);
return;
}
List<Double> valuesFirst = aloneDistanceRecord.distanceValues.subList(0, surveyorCount);
List<Double> valuesSecond = aloneDistanceRecord.distanceValues.subList(surveyorCount, surveyorCount * 2);
Double averageFirst = Tools.calculateCollectionDoubleAverage(valuesFirst);
Double averageSecond = Tools.calculateCollectionDoubleAverage(valuesSecond);
double compareValue = Math.abs(averageFirst - averageSecond);
if (compareValue * 1000 > distCyclesDifference) {
optionTips(Tools.getString(R.string.cycle_between_distance_limit) + distCyclesDifference,
Tools.getString(R.string.retest_cycle),
Tools.getString(R.string.retest_point),
() -> {
cachedData.deleteAloneDistanceRecord(stationId(), cycleIndex, currentIndex, LeftOrRight.left, true);
//更新进度
setCurrentCycle(cycleIndex);
setSingleCycleSchedule(cycleIndex, SurveyorScheduleConstants.STATUE_VALUE_NO_COMPLETED);
setAllCycleSchedule(SurveyorScheduleConstants.STATUE_VALUE_NO_COMPLETED);
findTargetFromBeginInCurrentCycle(false);
},
() -> {
//重测目标
cachedData.deleteAloneDistanceRecord(stationId(), cycleIndex, currentIndex, LeftOrRight.left, false);
//更新进度
setCurrentCycle(cycleIndex);
setSingleCycleSchedule(cycleIndex, SurveyorScheduleConstants.STATUE_VALUE_NO_COMPLETED);
setAllCycleSchedule(SurveyorScheduleConstants.STATUE_VALUE_NO_COMPLETED);
findTargetFromBeginInCurrentCycle(false);
},
() -> {
enterIdleAndClearSurveyStateAndResetAutoMode(true);
});
} else {
onSuccess();
}
}
private void onSuccess() {
//更新测量进度
setSingleCycleSchedule(getCycleRecorder().currentCycleIndex(),
SurveyorScheduleConstants.STATUE_VALUE_CHECKED);
//跳转
navigation2(StateType.isSingleCycleCompleted);
}
}

@ -1,195 +0,0 @@
package com.bingce.controlnetwork.surveyor.state.alonedistance;
import android.os.Bundle;
import com.bingce.controlapphelper.datasource.database.tolerance.detail.ToleranceDetailRecord;
import com.bingce.controlapphelper.surveyor.data.CachedDataAloneDistance;
import com.bingce.controlapphelper.surveyor.state.StateType;
import com.bingce.controlapphelper.util.SurveyorCycleUtil;
import com.bingce.controlapphelper.util.Tools;
import com.bingce.controlnetwork.R;
import com.bingce.utils.Util;
import java.util.ArrayList;
import java.util.List;
/**
* 执行测站检测
* <p>
* 前置条件
* 所有测回都完成测量并且通过测回内检测
*/
public class _CheckStationState extends __BaseState {
public _CheckStationState(StateManagerAloneDistance stateManager) {
super(StateType.checkStation, stateManager);
}
@Override
public void enter(Bundle args) {
//执行测站检测
String error = _stationCheckAloneDistance(stationId(), getToleranceRecord(), getCachedData());
if (error == null || error.isEmpty()) {
//进入finish状态
navigation2(StateType.stationCheckedSuccess);
} else {
failureTipsWithAutoStandStill(error);
}
}
public static String _stationCheckAloneDistance(final String stationId,
final ToleranceDetailRecord toleranceRecord,
final CachedDataAloneDistance cachedDataSource) {
final int cycleCount = ToleranceDetailRecord.ALONE_DISTANCE_CYCLE_COUNT;
final int surveyorCount = toleranceRecord.getSurveyorCount();
//测回间斜距互差
double distCyclesDifference = toleranceRecord.getSlopeCycleDistanceDifference()/*slopeCycleDistanceDifference*/;
List<_ErrorItem> distError = new ArrayList<>();
List<_Point> pointArrayList = new ArrayList<>();
//遍历第一测回,收集所有待测点id
for (int index = 0; index < cachedDataSource.pointCount(); index++) {
pointArrayList.add(new _Point(cachedDataSource.pointId(0, index), cachedDataSource.pointName(0, index)));
}
// if (!distError.isEmpty()) {
// stringBuilder.append("测回间距离较差超限(限差:")
// .append(Util.formatDouble2String(distLimit, 1))
// .append("'')");
// for (_ErrorItem item : distError) {
// stringBuilder
// .append("\n ")
// .append(item.pointName)
// .append(":\n")
// .append(" |")
// .append(SurveyorCycleUtil.cycleName(item.cycleIndex1))
// .append("-")
// .append(SurveyorCycleUtil.cycleName(item.cycleIndex2))
// .append("| = ")
// .append(Util.formatDouble2String(item.difference, 1))
// .append("'')");
// }
// }
return "";
}
/**
* 根据超限信息生成错误描述
*
* @param horValueError 水平角同方向值互差
* @param verValueError 垂直角同方向值互差
*/
private static String _errorString(double horLimit, double verLimit, double verILimit, double distLimit,
List<_ErrorItem> horValueError, List<_ErrorItem> verValueError, List<_ErrorItem> verIError, List<_ErrorItem> distError) {
if (horValueError.isEmpty() && verValueError.isEmpty()) {
return null;
}
StringBuilder stringBuilder = new StringBuilder();
if (!horValueError.isEmpty()) {
stringBuilder.append(Tools.getString(R.string.cycle_between_same_direction_value_limit))
.append(Util.formatDouble2String(horLimit, 1))
.append("'')");
for (_ErrorItem item : horValueError) {
stringBuilder
.append("\n ")
.append(item.pointName)
.append(":\n")
.append(" |")
.append(SurveyorCycleUtil.cycleName(item.cycleIndex1))
.append("-")
.append(SurveyorCycleUtil.cycleName(item.cycleIndex2))
.append("| = ")
.append(Util.formatDouble2String(item.difference, 1))
.append("'')");
}
}
if (!verValueError.isEmpty()) {
stringBuilder.append("\n").append(Tools.getString(R.string.cycle_between_ver_angle_limit))
.append(Util.formatDouble2String(verLimit, 1))
.append("'')");
for (_ErrorItem item : verValueError) {
stringBuilder
.append("\n ")
.append(item.pointName)
.append(":\n")
.append(" |")
.append(SurveyorCycleUtil.cycleName(item.cycleIndex1))
.append("-")
.append(SurveyorCycleUtil.cycleName(item.cycleIndex2))
.append("| = ")
.append(Util.formatDouble2String(item.difference, 1))
.append("'')");
}
}
if (!verIError.isEmpty()) {
stringBuilder.append("\n").append(Tools.getString(R.string.ver_angle_i_same_direction_each_cycle))
.append(Util.formatDouble2String(verILimit, 1))
.append("'')");
for (_ErrorItem item : verIError) {
stringBuilder
.append("\n ")
.append(item.pointName)
.append(":\n")
.append(" |")
.append(SurveyorCycleUtil.cycleName(item.cycleIndex1))
.append("-")
.append(SurveyorCycleUtil.cycleName(item.cycleIndex2))
.append("| = ")
.append(Util.formatDouble2String(item.difference, 1))
.append("'')");
}
}
if (!distError.isEmpty()) {
stringBuilder.append("\n").append(Tools.getString(R.string.cycle_between_distance_limit_brackets))
.append(Util.formatDouble2String(distLimit, 1))
.append("'')");
for (_ErrorItem item : distError) {
stringBuilder
.append("\n ")
.append(item.pointName)
.append(":\n")
.append(" |")
.append(SurveyorCycleUtil.cycleName(item.cycleIndex1))
.append("-")
.append(SurveyorCycleUtil.cycleName(item.cycleIndex2))
.append("| = ")
.append(Util.formatDouble2String(item.difference, 1))
.append("'')");
}
}
return stringBuilder.toString();
}
/**
* 存储错误信息的item
*/
private static class _ErrorItem {
final String pointName;
final int cycleIndex1;
final int cycleIndex2;
final double difference;
public _ErrorItem(String pointName, int cycleIndex1, int cycleIndex2, double difference) {
this.pointName = pointName;
this.cycleIndex1 = cycleIndex1;
this.cycleIndex2 = cycleIndex2;
this.difference = difference;
}
}
private static class _Point {
final String pointId;
final String pointName;
_Point(String pointId, String pointName) {
this.pointId = pointId;
this.pointName = pointName;
}
}
}

@ -1,33 +0,0 @@
package com.bingce.controlnetwork.surveyor.state.alonedistance;
import android.os.Bundle;
import com.bingce.controlapphelper.datasource.database.schedule.SurveyorScheduleConstants;
import com.bingce.controlapphelper.surveyor.data.ISurveyorData;
import com.bingce.controlapphelper.surveyor.state.StateType;
import net.tatans.tensorflowtts.tts.TtsManager;
import com.bingce.controlnetwork.R;
class _CheckStationSuccessState extends __BaseState {
public _CheckStationSuccessState(StateManagerAloneDistance stateManager) {
super(StateType.stationCheckedSuccess, stateManager);
}
@Override
public void enter(Bundle args) {
ISurveyorData surveyorData = getSurveyorData();
surveyorData.clearSurveyStateAndPosition();
//设置测量进度(数据库存储)
setAllCycleSchedule(SurveyorScheduleConstants.STATUE_VALUE_CHECKED);
//通知刷新
tips(getContext().getString(R.string.tips_all_cycle_has_finish_and_checked), null);
if (isAutoSurveyOpen()) {
runOnUI(() -> TtsManager.getInstance().speak(getContext().getString(R.string.tips_all_cycle_has_finish_and_checked)));
}
//清除测量状态,进入idle,停止自动测量
enterIdleAndClearSurveyStateAndResetAutoMode(true);
}
}

@ -1,32 +0,0 @@
package com.bingce.controlnetwork.surveyor.state.alonedistance;
import android.os.Bundle;
import com.bingce.controlapphelper.surveyor.state.IAutoModeSwitcher;
import com.bingce.controlapphelper.surveyor.state.StateType;
import com.bingce.controlapphelper.util.Tools;
import com.bingce.controlnetwork.R;
import com.bingce.totalstation.ControlSurveyResult;
import net.tatans.tensorflowtts.tts.TtsManager;
/**
* 先检测是否有其他未完成测回继续本次测量将删除其他测回数据
*/
class _DoAutoSurveyorState extends __BaseState {
private final IAutoModeSwitcher autoModeSwitcher;
public _DoAutoSurveyorState(StateManagerAloneDistance stateManager, IAutoModeSwitcher autoModeSwitcher) {
super(StateType.doAutoSurveyor, stateManager);
this.autoModeSwitcher = autoModeSwitcher;
}
@Override
public void enter(Bundle args) {
if (autoModeSwitcher.isReadyAutoSurvey() == ControlSurveyResult.CODE_SUCCESS) {
autoModeSwitcher.openAutoMode();
navigation2(StateType.doMove2NextValidate);
TtsManager.getInstance().speak(Tools.getString(R.string.start_auto_measure));
}
}
}

@ -1,74 +0,0 @@
package com.bingce.controlnetwork.surveyor.state.alonedistance;
import android.content.Context;
import android.os.Bundle;
import androidx.fragment.app.FragmentManager;
import androidx.lifecycle.LifecycleOwner;
import com.bingce.controlapphelper.datasource.database.SurveyorDatabaseFactory;
import com.bingce.controlapphelper.datasource.database.schedule.SurveyorScheduleConstants;
import com.bingce.controlapphelper.datasource.database.schedule.SurveyorScheduleRecord;
import com.bingce.controlapphelper.surveyor.data.CachedDataAloneDistance;
import com.bingce.controlapphelper.surveyor.method.SurveyorAdjustMethod;
import com.bingce.controlapphelper.surveyor.state.StateType;
import com.bingce.controlnetwork.fragment.StationDataAdjustDialogFragment;
import com.bingce.controlnetwork.fragment.TipsFragment;
import com.bingce.utils.ThreadPoolUtil;
import java.util.ArrayList;
/**
* 平差计算
*/
public class _DoCalAdjustState extends __BaseState {
public _DoCalAdjustState(StateManagerAloneDistance stateManager) {
super(StateType.doCalAdjust, stateManager);
}
@Override
public void enter(Bundle args) {
}
public static void doCalAdjust(String stationId, CachedDataAloneDistance cachedData, Context context, FragmentManager fragmentManager
, LifecycleOwner lifecycleOwner) {
ThreadPoolUtil.execute(() -> {
SurveyorAdjustMethod.calAloneDistance(
stationId, cachedData, new SurveyorAdjustMethod.ICallback() {
@Override
public void onGet(ArrayList<SurveyorAdjustMethod.Item> finalItemList, Boolean isShowSlopDistance) {
// //清除测量状态,进入idle,停止自动测量
// enterIdleAndClearSurveyStateAndResetAutoMode(true);
//展示结果数据
//检测归零值是否为负,如果是需要+2PI
for (SurveyorAdjustMethod.Item item : finalItemList) {
if (item.getHorAngle() < 0) {
item.setHorAngle(Math.PI * 2 + item.getHorAngle());
}
}
StationDataAdjustDialogFragment.showDialog(StationDataAdjustDialogFragment.TYPE_ALONE_DISTANCE, finalItemList, isShowSlopDistance, fragmentManager);
}
@Override
public void onFailure(String error) {
ThreadPoolUtil.executeInMain(() -> {
TipsFragment.tipsOnly(fragmentManager, lifecycleOwner, context, error);
});
}
});
//伴随平差 设置进度为通过检测
SurveyorDatabaseFactory
.instance
.getScheduleDataSource()
.record(
new SurveyorScheduleRecord(
SurveyorScheduleConstants.getAllCycleScheduleKey(stationId, SurveyorScheduleConstants.SCHEDULE_OR_CYCLE_TYPE_ALONE_DISTANCE),
SurveyorScheduleConstants.STATUE_VALUE_CHECKED));
});
}
}

@ -1,108 +0,0 @@
package com.bingce.controlnetwork.surveyor.state.alonedistance;
import android.os.Bundle;
import com.bingce.controlapphelper.datasource.database.schedule.SurveyorScheduleConstants;
import com.bingce.controlapphelper.event.SurveyStateEvent;
import com.bingce.controlapphelper.surveyor.data.ICycleRecorder;
import com.bingce.controlapphelper.surveyor.state.IAutoModeSwitcher;
import com.bingce.controlapphelper.surveyor.state.StateType;
import com.bingce.controlnetwork.fragment.stationsurvey.angledistance.MeasureFragment;
import com.bingce.controlnetwork.fragment.stationsurvey.angledistance.MeasureFragment;
/**
* 在单个测回内计算当前测量进度
* <p>
* 1.如果有没有完成测量则跳转到相应位置
* 2.如果测量完成检测数据限差
* 3.进入idle
*/
class _DoCalScheduleInSingleCycleState extends __BaseState {
private final IAutoModeSwitcher autoModeSwitcher;
public _DoCalScheduleInSingleCycleState(StateManagerAloneDistance stateManager, IAutoModeSwitcher autoModeSwitcher) {
super(StateType.doCalScheduleSingleCycle, stateManager);
this.autoModeSwitcher = autoModeSwitcher;
}
@Override
final public void enter(Bundle args) {
int pointCount = getCachedData().pointCount();
if (pointCount == 0) {
postBtnEvent();
return;
}
//重置自动测量状态
if (autoModeSwitcher.isAutoModeClose()) {
autoModeSwitcher.resetAutoMode();
}
//计算状态之前,重置测量状态
getSurveyorData().clearSurveyStateAndPosition();
ICycleRecorder cycleRecorder = getCycleRecorder();
cycleRecorder.changeCycleIndex(args.getInt(KEY_CYCLE_INDEX, 0));
setCurrentCycle(cycleRecorder.currentCycleIndex());
//1.检测当前cycle是否完成测量
boolean completed = _IsSingleCycleCompletedState.isSingleCycleCompleted(
stationId(),
getCycleRecorder().currentCycleIndex(),
getCachedData(), getSurveyorCount());
//2.如果当前测回还有待测数据,则执行测量
if (!completed) {
//从当前测回开始处查找目标并执行测量
findTargetFromBeginInCurrentCycle(false);
return;
}
//3.如果当前测回结束测量,判断是否通过检测
// ToleranceDetailRecord toleranceDetailRecord = getToleranceRecord();
// double horCycle2CDiff = toleranceDetailRecord.getHorCycleDirect2CDifference();
// double verCycle2CDiff = toleranceDetailRecord.getVerCycleDirectIDifference();
// String error = SingleCycleCheckMethod.check(
// horCycle2CDiff,
// verCycle2CDiff,
// stationId(),
// getCycleRecorder().currentCycleIndex(),
// getSurveyorData(),
// getCachedData());
// if (error != null && !error.isEmpty()) {
// SingleCycleTipsMethod.showTips(error,
// stationId(),
// getCycleRecorder().currentCycleIndex(),
// stateDelegate(),
// fragmentManager(),
// lifecycleOwner());
// return;
// }
//4.更新测站状态,在当前测回经过检测
setSingleCycleSchedule(getCycleRecorder().currentCycleIndex(),
SurveyorScheduleConstants.STATUE_VALUE_CHECKED);
//6.清空测量状态
onCompletedCheck();
}
protected void onCompletedCheck() {
enterIdleAndClearSurveyStateAndResetAutoMode(true);
}
protected static final String KEY_CYCLE_INDEX = "___cycle__index__";
static void enter(StateManagerAloneDistance stateManager, int cycleIndex) {
Bundle args = new Bundle();
args.putInt(KEY_CYCLE_INDEX, cycleIndex);
stateManager.enter(StateType.doCalScheduleSingleCycle, args);
}
private void postBtnEvent() {
int pointCount = getCachedData().pointCount();
if (pointCount == 0) {
SurveyStateEvent.postCompleted(MeasureFragment.POSITION_DISTANCE_MEASURE);
} else {
SurveyStateEvent.postIdle(MeasureFragment.POSITION_DISTANCE_MEASURE);
}
}
}

@ -1,63 +0,0 @@
package com.bingce.controlnetwork.surveyor.state.alonedistance;
import android.os.Bundle;
import com.bingce.controlapphelper.datasource.database.SurveyorDatabaseFactory;
import com.bingce.controlapphelper.datasource.database.config.ConfigConstants;
import com.bingce.controlapphelper.datasource.database.config.IConfigDataSource;
import com.bingce.controlapphelper.datasource.database.schedule.SurveyorScheduleConstants;
import com.bingce.controlapphelper.surveyor.state.StateType;
import com.bingce.utils.ThreadPoolUtil;
import com.bingce.controlnetwork.R;
/**
* 删除本测站所有测回数据
* 对于钢丝测距 所有两测回数据都在一个view里显示了不用切换
*/
class _DoDeleteAllCycleState extends __BaseState {
private static final String KEY_STATION_ID = "__station_id";
static Bundle args(String stationId) {
Bundle args = new Bundle();
args.putString(KEY_STATION_ID, stationId);
return args;
}
public _DoDeleteAllCycleState(StateManagerAloneDistance stateManager) {
super(StateType.doDeleteAllCycle, stateManager);
}
@Override
public void enter(Bundle args) {
String stationId = args.getString(KEY_STATION_ID);
optionTipsWithStandStill(getContext().getString(R.string.tips_delete_station_all_surveyor_records),
() -> deleteAllCycleData(stationId));
}
private void deleteAllCycleData(String stationId) {
ThreadPoolUtil.execute(() -> {
//删除数据
getCachedData().deleteAloneDistanceRecord(stationId);
//清除已经提示测站可以检测标识
IConfigDataSource configDataSource =
SurveyorDatabaseFactory.instance.getConfigDataSource();
String key = ConfigConstants.KEY_CONFIG_STATION_CHECK_REMINDED + stationId;
configDataSource.setSync(key, ConfigConstants.VALUE_NO);
//重置所有测回进度
setAllCycleScheduleSync(SurveyorScheduleConstants.STATUE_VALUE_NO_COMPLETED);
setSingleCycleScheduleSync(cycleIndexDefault, SurveyorScheduleConstants.STATUE_VALUE_NO_COMPLETED);
//从第一测回开始
setCurrentCycle(cycleIndexDefault);
//重新测量,并刷新
findTargetFromBeginInCurrentCycle(true);
});
}
}

@ -1,55 +0,0 @@
package com.bingce.controlnetwork.surveyor.state.alonedistance;
import android.os.Bundle;
import com.bingce.controlapphelper.datasource.database.SurveyorDatabaseFactory;
import com.bingce.controlapphelper.datasource.database.config.ConfigConstants;
import com.bingce.controlapphelper.datasource.database.config.IConfigDataSource;
import com.bingce.controlapphelper.datasource.database.schedule.SurveyorScheduleConstants;
import com.bingce.controlapphelper.surveyor.state.StateType;
import com.bingce.controlnetwork.R;
class _DoDeleteCurrentCycleState extends __BaseState {
public _DoDeleteCurrentCycleState(StateManagerAloneDistance stateManager) {
super(StateType.doDeleteCurrentCycle, stateManager);
}
@Override
public void enter(Bundle args) {
String stationId = args.getString(KEY_STATION_ID);
int cycleIndex = args.getInt(KEY_PERIOD_INDEX);
optionTipsWithStandStill(getContext().getString(R.string.tips_delete_current_cycle_surveyor_record),
() -> {
//删除数据
getCachedData().deleteAloneDistanceRecord(stationId, cycleIndex);
//清除已经提示测站可以检测标识
IConfigDataSource configDataSource =
SurveyorDatabaseFactory.instance.getConfigDataSource();
String key = ConfigConstants.KEY_CONFIG_STATION_CHECK_REMINDED + stationId;
configDataSource.set(key, ConfigConstants.VALUE_NO);
//重置进度
//当前测回
setCurrentCycle(cycleIndex);
//所有测回未完成
setAllCycleSchedule(SurveyorScheduleConstants.STATUE_VALUE_NO_COMPLETED);
//单个测回未完成
setSingleCycleSchedule(cycleIndex, SurveyorScheduleConstants.STATUE_VALUE_NO_COMPLETED);
//重新测量,并刷新
findTargetFromBeginInCurrentCycle(true);
});
}
private static final String KEY_STATION_ID = "__station_id";
private static final String KEY_PERIOD_INDEX = "__period_index__";
static Bundle args(String stationId, int periodIndex) {
Bundle args = new Bundle();
args.putString(KEY_STATION_ID, stationId);
args.putInt(KEY_PERIOD_INDEX, periodIndex);
return args;
}
}

@ -1,72 +0,0 @@
package com.bingce.controlnetwork.surveyor.state.alonedistance;
import android.os.Bundle;
import com.bingce.controlapphelper.model.LeftOrRight;
import com.bingce.controlapphelper.surveyor.data.CachedDataAloneDistance;
import com.bingce.controlapphelper.surveyor.data.ICycleRecorder;
import com.bingce.controlapphelper.surveyor.data.ISurveyorData;
import com.bingce.controlapphelper.surveyor.method.FindTargetMethod;
import com.bingce.controlapphelper.surveyor.state.StateType;
/**
* 移动到一个待测量位置
* <p>
* 不会跳转到其他测期
* <p>
* 可能涉及转向盘左->盘右
*/
class _DoMove2NextValidateState extends __BaseState {
public _DoMove2NextValidateState(StateManagerAloneDistance stateManager) {
super(StateType.doMove2NextValidate, stateManager);
}
@Override
public void enter(Bundle args) {
CachedDataAloneDistance cachedData = getCachedData();
ISurveyorData surveyorData = getSurveyorData();
ICycleRecorder cycleRecorder = getCycleRecorder();
int pointCount = cachedData.pointCount();
int currentIndex = surveyorData.currentIndex();
if (currentIndex < 0) {
currentIndex = 0;
}
final int currentCycleIndex = cycleRecorder.currentCycleIndex();
final LeftOrRight currentSurveyorState = surveyorData.leftOrRight();
FindTargetMethod.Target needMeasureForAloneDistanceTarget = FindTargetMethod.findNeedMeasureTargetInSingleCycleForAloneDistance(stationId(), currentCycleIndex,
currentIndex,
currentSurveyorState,
pointCount,
true,
cachedData);
if (needMeasureForAloneDistanceTarget != null) {
navigation2(needMeasureForAloneDistanceTarget.itemIndex, needMeasureForAloneDistanceTarget.leftOrRight);
return;
}
//3.当前测回完成测量,停留状态
//重置标识
enterIdleAndClearSurveyorStatePosition();
}
/**
* 跳转到下一目标点
*
* @param targetIndex 目标点索引
* @param targetSurveyorState 测量状态盘左or盘右
*/
private void navigation2(int targetIndex, LeftOrRight targetSurveyorState) {
//更新测量进度
setSurveyPosition(targetIndex, targetSurveyorState);
//清除测量状态,进入idle,但是不停止自动测量
enterIdleAndClearSurveyStateAndResetAutoMode(false);
//滚动
scroll2(targetIndex);
}
}

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

Loading…
Cancel
Save