Compare commits
12 Commits
main
...
main_modif
Author | SHA1 | Date |
---|---|---|
|
6bafdfb0cf | 5 months ago |
|
cf4925b468 | 5 months ago |
|
066a848348 | 7 months ago |
|
61545ff425 | 7 months ago |
|
c9ac786342 | 7 months ago |
|
d1aff74538 | 8 months ago |
|
440b773823 | 8 months ago |
|
deadaddc14 | 8 months ago |
|
da2be2784e | 8 months ago |
|
802830dfb3 | 8 months ago |
|
5d0e055511 | 9 months ago |
|
f291762ab3 | 9 months ago |
217 changed files with 17687 additions and 5888 deletions
@ -1 +1,15 @@ |
|||||||
|
#### 1. 项目简介 |
||||||
|
|
||||||
解放军信息工程导线助手 |
解放军信息工程导线助手 |
||||||
|
|
||||||
|
#### 2. 代码信息 |
||||||
|
|
||||||
|
##### 2.1 仓库地址 |
||||||
|
|
||||||
|
- 主项目:http://code.bingce.com/wangguannan/control_pla.git |
||||||
|
|
||||||
|
分支:main_modify |
||||||
|
|
||||||
|
- 子仓库(control_common):http://code.bingce.com/BingCe-Android/control_common.git |
||||||
|
|
||||||
|
分支:huangwei_level_modify |
||||||
|
Binary file not shown.
@ -0,0 +1,2 @@ |
|||||||
|
configurations.maybeCreate("default") |
||||||
|
artifacts.add("default", file('coordlib-release.aar')) |
Binary file not shown.
Binary file not shown.
@ -0,0 +1,2 @@ |
|||||||
|
configurations.maybeCreate("default") |
||||||
|
artifacts.add("default", file('sensor-release.aar')) |
Binary file not shown.
Binary file not shown.
@ -0,0 +1,88 @@ |
|||||||
|
package com.bingce.controlnetwork.bean; |
||||||
|
|
||||||
|
|
||||||
|
import com.bingce.controlnetwork.surveyor.state.StateConstantsPla; |
||||||
|
|
||||||
|
public class SurveyorScheduleConstants { |
||||||
|
public static final String KEY_ID = "id"; |
||||||
|
|
||||||
|
public static final String STATUE_VALUE_NO_COMPLETED = "0";//未完成测量
|
||||||
|
public static final String STATUE_VALUE_COMPLETED = "1";//完成测量
|
||||||
|
public static final String STATUE_VALUE_CHECKED = "2";//经过检测
|
||||||
|
|
||||||
|
public static final String DB_NAME = "___SurveyorSchedule____"; |
||||||
|
|
||||||
|
public static final String DB_SQL_SELECT_BY_ID = "SELECT * FROM " + DB_NAME + " WHERE id =:id"; |
||||||
|
|
||||||
|
|
||||||
|
//进度key //值勿改
|
||||||
|
//单独测距
|
||||||
|
private static final String STATION_TYPE_WELL_DISTANCE = "STATION_TYPE_WELL_DISTANCE"; |
||||||
|
//水平角
|
||||||
|
private static final String STATION_TYPE_SEPARATE_HOR_ANGLE = "STATION_TYPE_SEPARATE_HOR_ANGLE"; |
||||||
|
//垂直角
|
||||||
|
private static final String STATION_TYPE_SEPARATE_VER_ANGLE = "STATION_TYPE_SEPARATE_VER_ANGLE"; |
||||||
|
|
||||||
|
/** |
||||||
|
* 当前测回的key |
||||||
|
* |
||||||
|
* @param stationId |
||||||
|
* @param measureWhat |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
public static String stationCurrentCycleKey(String stationId, int measureWhat) { |
||||||
|
return stationId + getSubTypeKey(measureWhat) + "___key___current__cycle"; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 某个测回进度key |
||||||
|
* |
||||||
|
* @param stationId |
||||||
|
* @param measureWhat |
||||||
|
* @param cycleIndex |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
public static String stationSingleCycleScheduleKey(String stationId, int measureWhat, int cycleIndex) { |
||||||
|
return stationId + getSubTypeKey(measureWhat) + "_single__cycle___" + cycleIndex; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 所有测回进度key |
||||||
|
* |
||||||
|
* @param stationId |
||||||
|
* @param measureWhat |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
public static String stationAllCycleScheduleKey(String stationId, int measureWhat) { |
||||||
|
return stationId + getSubTypeKey(measureWhat) + "_all__cycle___"; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* 分开观测垂直角测站的点id |
||||||
|
* |
||||||
|
* @param stationId |
||||||
|
* @param measureWhat |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
public static String stationCurrentPointIdKey(String stationId, int measureWhat) { |
||||||
|
return stationId + getSubTypeKey(measureWhat) + "key_current_point_id"; |
||||||
|
} |
||||||
|
|
||||||
|
private static String getSubTypeKey(int measureWhat) { |
||||||
|
switch (measureWhat) { |
||||||
|
case StateConstantsPla.VALUE_MEASURE_WHAT_DISTANCE: |
||||||
|
return STATION_TYPE_WELL_DISTANCE; |
||||||
|
case StateConstantsPla.VALUE_MEASURE_WHAT_ANGLE_HOR: |
||||||
|
return STATION_TYPE_SEPARATE_HOR_ANGLE; |
||||||
|
case StateConstantsPla.VALUE_MEASURE_WHAT_ANGLE_VER: |
||||||
|
return STATION_TYPE_SEPARATE_VER_ANGLE; |
||||||
|
case StateConstantsPla.VALUE_MEASURE_WHAT_DEFAULT: |
||||||
|
// case StateConstants.VALUE_MEASURE_WHAT_ANGLE:
|
||||||
|
default: |
||||||
|
return ""; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
@ -0,0 +1,11 @@ |
|||||||
|
package com.bingce.controlnetwork.event; |
||||||
|
|
||||||
|
public class AutoSurveyorButtonVisibleEvent { |
||||||
|
public final boolean isReadyAutoSurvey;//是否具备自动测量条件
|
||||||
|
public final boolean isOpenAutoSurvey;//是否允许自动测量
|
||||||
|
|
||||||
|
public AutoSurveyorButtonVisibleEvent(boolean isReadyAutoSurvey, boolean isOpenAutoSurvey) { |
||||||
|
this.isReadyAutoSurvey = isReadyAutoSurvey; |
||||||
|
this.isOpenAutoSurvey = isOpenAutoSurvey; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,35 @@ |
|||||||
|
package com.bingce.controlnetwork.event; |
||||||
|
|
||||||
|
|
||||||
|
import com.bingce.controlnetwork.surveyor.state.StateConstantsPla; |
||||||
|
|
||||||
|
/* |
||||||
|
* 刷新「回退」按钮 |
||||||
|
* */ |
||||||
|
public class RefreshRollBackEvent { |
||||||
|
public final boolean validate; |
||||||
|
public final int fragmentPosition; |
||||||
|
|
||||||
|
public RefreshRollBackEvent(final boolean validate, final int fragmentPosition) { |
||||||
|
this.validate = validate; |
||||||
|
this.fragmentPosition = fragmentPosition; |
||||||
|
} |
||||||
|
|
||||||
|
public static int getFragmentPosition(int measureWhat, boolean isSeparateObservation) { |
||||||
|
if (measureWhat == StateConstantsPla.VALUE_MEASURE_WHAT_DEFAULT |
||||||
|
// || measureWhat == StateConstants.VALUE_MEASURE_WHAT_ANGLE
|
||||||
|
|| measureWhat == StateConstantsPla.VALUE_MEASURE_WHAT_ANGLE_HOR) { |
||||||
|
return 0; |
||||||
|
} else if (measureWhat == StateConstantsPla.VALUE_MEASURE_WHAT_ANGLE_VER) { |
||||||
|
return 1; |
||||||
|
} else if (measureWhat == StateConstantsPla.VALUE_MEASURE_WHAT_DISTANCE) { |
||||||
|
if (isSeparateObservation) { |
||||||
|
return 3; |
||||||
|
} else { |
||||||
|
return 1; |
||||||
|
} |
||||||
|
} |
||||||
|
return 0; |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,4 @@ |
|||||||
|
package com.bingce.controlnetwork.event; |
||||||
|
|
||||||
|
public class ReplaceSurveyorFragmentEvent { |
||||||
|
} |
@ -0,0 +1,56 @@ |
|||||||
|
package com.bingce.controlnetwork.event; |
||||||
|
|
||||||
|
import org.greenrobot.eventbus.EventBus; |
||||||
|
|
||||||
|
public class SurveyStateEvent { |
||||||
|
private final static int STATE_IDLE = 0; |
||||||
|
private final static int STATE_SURVEYING = STATE_IDLE + 1; |
||||||
|
private final static int STATE_SURVEY_SUCCESS = STATE_SURVEYING + 1; |
||||||
|
private final static int STATE_SURVEY_FAILURE = STATE_SURVEY_SUCCESS + 1; |
||||||
|
private final static int STATE_SURVEY_COMPLETED = STATE_SURVEY_FAILURE + 1; |
||||||
|
public final int state; |
||||||
|
|
||||||
|
private SurveyStateEvent(int state) { |
||||||
|
this.state = state; |
||||||
|
} |
||||||
|
|
||||||
|
public boolean isIdle() { |
||||||
|
return STATE_IDLE == state; |
||||||
|
} |
||||||
|
|
||||||
|
public boolean isSurveying() { |
||||||
|
return STATE_SURVEYING == state; |
||||||
|
} |
||||||
|
|
||||||
|
public boolean isSuccess() { |
||||||
|
return STATE_SURVEY_SUCCESS == state; |
||||||
|
} |
||||||
|
|
||||||
|
public boolean isFailure() { |
||||||
|
return STATE_SURVEY_FAILURE == state; |
||||||
|
} |
||||||
|
|
||||||
|
public boolean isCompleted() { |
||||||
|
return STATE_SURVEY_COMPLETED == state; |
||||||
|
} |
||||||
|
|
||||||
|
public static void postIdle() { |
||||||
|
EventBus.getDefault().post(new SurveyStateEvent(STATE_IDLE)); |
||||||
|
} |
||||||
|
|
||||||
|
public static void postSurveying() { |
||||||
|
EventBus.getDefault().post(new SurveyStateEvent(STATE_SURVEYING)); |
||||||
|
} |
||||||
|
|
||||||
|
public static void postSuccess() { |
||||||
|
EventBus.getDefault().post(new SurveyStateEvent(STATE_SURVEY_SUCCESS)); |
||||||
|
} |
||||||
|
|
||||||
|
public static void postFailure() { |
||||||
|
EventBus.getDefault().post(new SurveyStateEvent(STATE_SURVEY_FAILURE)); |
||||||
|
} |
||||||
|
|
||||||
|
public static void postCompleted() { |
||||||
|
EventBus.getDefault().post(new SurveyStateEvent(STATE_SURVEY_COMPLETED)); |
||||||
|
} |
||||||
|
} |
@ -1,144 +0,0 @@ |
|||||||
package com.bingce.controlnetwork.fragment; |
|
||||||
|
|
||||||
import android.os.Bundle; |
|
||||||
import android.view.LayoutInflater; |
|
||||||
import android.view.View; |
|
||||||
import android.view.ViewGroup; |
|
||||||
|
|
||||||
import androidx.annotation.NonNull; |
|
||||||
import androidx.annotation.Nullable; |
|
||||||
import androidx.lifecycle.LiveData; |
|
||||||
import androidx.recyclerview.widget.RecyclerView; |
|
||||||
|
|
||||||
import com.bingce.controlapphelper.datasource.database.ProjectType; |
|
||||||
import com.bingce.controlapphelper.datasource.database.SurveyorDatabaseFactory; |
|
||||||
import com.bingce.controlapphelper.datasource.database.surveyorstation.SurveyorStationRecord; |
|
||||||
import com.bingce.controlapphelper.model.BundleConstants; |
|
||||||
import com.bingce.controlapphelper.util.StationUtil; |
|
||||||
import com.bingce.controlnetwork.R; |
|
||||||
import com.bingce.controlnetwork.adapter.SurveyorStationListAdapter; |
|
||||||
import com.bingce.controlnetwork.fragment.base.BaseFragment; |
|
||||||
import com.bingce.controlnetwork.fragment.stationdetail.SingleStationDetailAndEditFragment; |
|
||||||
import com.bingce.controlnetwork.fragment.stationsurvey.StationSurveyorFragment; |
|
||||||
import com.bingce.controlnetwork.fragment.stationsurvey.angledistance.MeasureFragment; |
|
||||||
import com.bingce.utils.ThreadPoolUtil; |
|
||||||
|
|
||||||
import java.util.List; |
|
||||||
|
|
||||||
/** |
|
||||||
* 测站列表(项目和测量共用) |
|
||||||
*/ |
|
||||||
public class ComponentSurveyorStationListFragment extends BaseFragment { |
|
||||||
public static final String TAG = "cn.liuyanbing.surveyor.fragment.dummy__SurveyorStationListFragment___"; |
|
||||||
private SurveyorStationListAdapter adapter; |
|
||||||
private RecyclerView recyclerView; |
|
||||||
|
|
||||||
private LiveData<List<SurveyorStationRecord>> stationLiveData; |
|
||||||
|
|
||||||
/** |
|
||||||
* 去测量或者详情页面 |
|
||||||
*/ |
|
||||||
private void goStationMeasureOrDetail(SurveyorStationRecord item, boolean detailOrSurveyorFinal) { |
|
||||||
String stationId = item.getId(); |
|
||||||
ThreadPoolUtil.execute(() -> { |
|
||||||
SurveyorStationRecord stationRecord = SurveyorDatabaseFactory |
|
||||||
.instance |
|
||||||
.getSurveyorStation() |
|
||||||
.getRecordSync(stationId); |
|
||||||
if (stationRecord == null || stationRecord.getItems() == null || stationRecord.getItems().isEmpty()) { |
|
||||||
return; |
|
||||||
} |
|
||||||
|
|
||||||
String lineTypeFromStation = StationUtil.getLineTypeFromStation(stationRecord); |
|
||||||
|
|
||||||
//站的名称 导线+点名
|
|
||||||
String stationName = StationUtil.getStationName(stationRecord); |
|
||||||
|
|
||||||
if (detailOrSurveyorFinal) { |
|
||||||
SingleStationDetailAndEditFragment.start(getContext(), stationId, stationName, item.getProjectId(), null); |
|
||||||
} else { |
|
||||||
//StationSurveyorFragment原始测量页
|
|
||||||
if (ProjectType.isConnection(item.projectType)) { |
|
||||||
MeasureFragment.start(getContext(), stationId, stationName); |
|
||||||
} else { |
|
||||||
StationSurveyorFragment.start(getContext(), stationId, stationName); |
|
||||||
} |
|
||||||
} |
|
||||||
}); |
|
||||||
} |
|
||||||
|
|
||||||
@Nullable |
|
||||||
@Override |
|
||||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { |
|
||||||
View view = inflater.inflate(R.layout.fragment_list_layout, container, false); |
|
||||||
if (view instanceof RecyclerView) { |
|
||||||
recyclerView = (RecyclerView) view; |
|
||||||
if (getArguments() != null) { |
|
||||||
update(getArguments().getString(BundleConstants.KEY_PROJECT_ID), |
|
||||||
getArguments().getString(KEY_TIME_INDEX)); |
|
||||||
} |
|
||||||
} |
|
||||||
return view; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* 根据项目id和测期id获取测站记录 |
|
||||||
* |
|
||||||
* @param projectId |
|
||||||
* @param periodId |
|
||||||
*/ |
|
||||||
public void update(String projectId, String periodId) { |
|
||||||
if (stationLiveData != null) { |
|
||||||
stationLiveData.removeObservers(this); |
|
||||||
} |
|
||||||
|
|
||||||
stationLiveData = SurveyorDatabaseFactory |
|
||||||
.instance |
|
||||||
.getSurveyorStation().getLiveDataList(projectId, periodId); |
|
||||||
|
|
||||||
stationLiveData.observe(getViewLifecycleOwner(), this::updateUi); |
|
||||||
} |
|
||||||
|
|
||||||
private void updateUi(List<SurveyorStationRecord> dataList) { |
|
||||||
runOnUI(() -> { |
|
||||||
if (adapter == null) { |
|
||||||
boolean detailOrSurveyor = false; |
|
||||||
if (getArguments() != null) { |
|
||||||
detailOrSurveyor = getArguments().getBoolean(KEY_DETAIL_OR_SURVEYOR, false); |
|
||||||
} |
|
||||||
boolean detailOrSurveyorFinal = detailOrSurveyor; |
|
||||||
adapter = new SurveyorStationListAdapter(dataList, |
|
||||||
getChildFragmentManager(), |
|
||||||
getViewLifecycleOwner(), |
|
||||||
runnable -> { |
|
||||||
if (getActivity() != null) { |
|
||||||
getActivity().runOnUiThread(runnable); |
|
||||||
} |
|
||||||
}, |
|
||||||
getContext(), |
|
||||||
item -> goStationMeasureOrDetail(item, detailOrSurveyorFinal), |
|
||||||
detailOrSurveyor); |
|
||||||
recyclerView.setAdapter(adapter); |
|
||||||
} else { |
|
||||||
adapter.updateData(dataList); |
|
||||||
} |
|
||||||
}); |
|
||||||
} |
|
||||||
|
|
||||||
private static final String KEY_TIME_INDEX = "___time_index__"; |
|
||||||
private static final String KEY_DETAIL_OR_SURVEYOR = "___editable___";//标识点击item进入测量界面还是测站详情
|
|
||||||
|
|
||||||
public static ComponentSurveyorStationListFragment newInstance(String projectId, String surveyorPeriodId, boolean isDetail) { |
|
||||||
ComponentSurveyorStationListFragment fragment = new ComponentSurveyorStationListFragment(); |
|
||||||
Bundle bundle = new Bundle(); |
|
||||||
bundle.putString(BundleConstants.KEY_PROJECT_ID, projectId); |
|
||||||
bundle.putString(KEY_TIME_INDEX, surveyorPeriodId); |
|
||||||
bundle.putBoolean(KEY_DETAIL_OR_SURVEYOR, isDetail); |
|
||||||
fragment.setArguments(bundle); |
|
||||||
return fragment; |
|
||||||
} |
|
||||||
|
|
||||||
public static ComponentSurveyorStationListFragment newInstance(String projectId, String surveyorPeriodId) { |
|
||||||
return newInstance(projectId, surveyorPeriodId, true); |
|
||||||
} |
|
||||||
} |
|
@ -0,0 +1,128 @@ |
|||||||
|
package com.bingce.controlnetwork.fragment; |
||||||
|
|
||||||
|
import android.graphics.drawable.ColorDrawable; |
||||||
|
import android.os.Bundle; |
||||||
|
import android.os.Parcelable; |
||||||
|
import android.text.TextUtils; |
||||||
|
import android.view.LayoutInflater; |
||||||
|
import android.view.View; |
||||||
|
import android.view.ViewGroup; |
||||||
|
import android.view.Window; |
||||||
|
import android.view.WindowManager; |
||||||
|
import android.widget.TextView; |
||||||
|
|
||||||
|
import androidx.annotation.ColorRes; |
||||||
|
import androidx.annotation.NonNull; |
||||||
|
import androidx.annotation.Nullable; |
||||||
|
import androidx.fragment.app.DialogFragment; |
||||||
|
import androidx.fragment.app.FragmentManager; |
||||||
|
import androidx.recyclerview.widget.RecyclerView; |
||||||
|
|
||||||
|
import com.bingce.controlapphelper.surveyor.method.ExportUtils; |
||||||
|
import com.bingce.controlapphelper.surveyor.method.RadianMethod; |
||||||
|
import com.bingce.controlapphelper.util.Tools; |
||||||
|
import com.bingce.controlnetwork.R; |
||||||
|
import com.bingce.controlnetwork.adapter.BaseAdapter; |
||||||
|
import com.bingce.controlnetwork.model.AloneAdjustItem; |
||||||
|
import com.bingce.controlnetwork.surveyor.state.StateConstantsPla; |
||||||
|
import com.bingce.controlnetwork.ui.vh.StationAdjustAloneDistanceViewHolder; |
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull; |
||||||
|
|
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
|
||||||
|
public class StationDataAdjustAloneVerOrDistanceDialogFragment extends DialogFragment { |
||||||
|
private static final String KEY_LIST = "__key_list"; |
||||||
|
private static final String KEY_MEASURE_WHAT = "KEY_MEASURE_WHAT"; |
||||||
|
private int measureWhatAloneAngleOrDistance; |
||||||
|
|
||||||
|
@Override |
||||||
|
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { |
||||||
|
super.onViewCreated(view, savedInstanceState); |
||||||
|
if (getDialog() == null) { |
||||||
|
return; |
||||||
|
} |
||||||
|
Window window = getDialog().getWindow(); |
||||||
|
window.setBackgroundDrawable(new ColorDrawable(0x00000000)); |
||||||
|
window.setLayout( |
||||||
|
WindowManager.LayoutParams.MATCH_PARENT, |
||||||
|
WindowManager.LayoutParams.WRAP_CONTENT); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { |
||||||
|
View rootView = inflater.inflate(R.layout.fragment_station_data_adjust_dialog_alone_distance, container, false); |
||||||
|
if (getArguments() != null) { |
||||||
|
measureWhatAloneAngleOrDistance = getArguments().getInt(KEY_MEASURE_WHAT); |
||||||
|
ArrayList<AloneAdjustItem> items = getArguments().getParcelableArrayList(KEY_LIST); |
||||||
|
TextView tvTitle = rootView.findViewById(R.id.distance_angle_title); |
||||||
|
tvTitle.setText(getTitle()); |
||||||
|
RecyclerView recyclerView = rootView.findViewById(R.id.list); |
||||||
|
_Adapter adapter = new _Adapter(items); |
||||||
|
recyclerView.setAdapter(adapter); |
||||||
|
} |
||||||
|
return rootView; |
||||||
|
} |
||||||
|
|
||||||
|
private String getTitle() { |
||||||
|
if (StateConstantsPla.isMeasureVerAngle(measureWhatAloneAngleOrDistance)) { |
||||||
|
return "垂直角"; |
||||||
|
} else if (StateConstantsPla.isMeasureDistance(measureWhatAloneAngleOrDistance)) { |
||||||
|
return "距离"; |
||||||
|
} |
||||||
|
return ""; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
private class _Adapter extends BaseAdapter<AloneAdjustItem, StationAdjustAloneDistanceViewHolder> { |
||||||
|
|
||||||
|
public _Adapter(List<AloneAdjustItem> items) { |
||||||
|
super(items); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected StationAdjustAloneDistanceViewHolder createVH(@NotNull ViewGroup parent, int viewType) { |
||||||
|
return new StationAdjustAloneDistanceViewHolder(getLayoutInflater().inflate(R.layout.item_station_adjust_alone_distance, parent, false)); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void onBindViewHolder(@NonNull @NotNull StationAdjustAloneDistanceViewHolder holder, int position) { |
||||||
|
AloneAdjustItem item = getItem(position); |
||||||
|
setText(holder.pointName, item.getPointName(), R.color.text_color_1); |
||||||
|
|
||||||
|
if (!TextUtils.isEmpty(item.getErrorMsg())) { |
||||||
|
setText(holder.distance, item.getErrorMsg(), R.color.value_dirty); |
||||||
|
} else { |
||||||
|
setText(holder.distance, getShowText(item), R.color.text_color_1); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private void setText(TextView textView, String string, @ColorRes int color) { |
||||||
|
if (textView != null) { |
||||||
|
textView.setText(string); |
||||||
|
textView.setTextColor(Tools.getColor(color)); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private String getShowText(AloneAdjustItem item) { |
||||||
|
if (StateConstantsPla.isMeasureVerAngle(measureWhatAloneAngleOrDistance)) { |
||||||
|
return RadianMethod.dmsStringOf(item.getVerAngle()); |
||||||
|
} else if (StateConstantsPla.isMeasureDistance(measureWhatAloneAngleOrDistance)) { |
||||||
|
return ExportUtils.formatDistance(item.getDistance()); |
||||||
|
} |
||||||
|
return ""; |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
public static void showDialog(FragmentManager fragmentManager, int measureWhat, List<AloneAdjustItem> finalItemList) { |
||||||
|
StationDataAdjustAloneVerOrDistanceDialogFragment dialogFragment = new StationDataAdjustAloneVerOrDistanceDialogFragment(); |
||||||
|
Bundle args = new Bundle(); |
||||||
|
args.putParcelableArrayList(KEY_LIST, (ArrayList<? extends Parcelable>) finalItemList); |
||||||
|
args.putInt(KEY_MEASURE_WHAT, measureWhat); |
||||||
|
dialogFragment.setArguments(args); |
||||||
|
dialogFragment.show(fragmentManager, null); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,183 @@ |
|||||||
|
package com.bingce.controlnetwork.fragment; |
||||||
|
|
||||||
|
|
||||||
|
import android.content.Context; |
||||||
|
import android.graphics.drawable.ColorDrawable; |
||||||
|
import android.os.Bundle; |
||||||
|
import android.view.LayoutInflater; |
||||||
|
import android.view.View; |
||||||
|
import android.view.ViewGroup; |
||||||
|
import android.view.Window; |
||||||
|
import android.view.WindowManager; |
||||||
|
import android.widget.TextView; |
||||||
|
|
||||||
|
import androidx.annotation.NonNull; |
||||||
|
import androidx.annotation.Nullable; |
||||||
|
import androidx.fragment.app.DialogFragment; |
||||||
|
import androidx.fragment.app.FragmentManager; |
||||||
|
import androidx.recyclerview.widget.RecyclerView; |
||||||
|
|
||||||
|
import com.bingce.controlapphelper.model.ViewItemType; |
||||||
|
import com.bingce.controlapphelper.surveyor.method.RadianMethod; |
||||||
|
import com.bingce.controlapphelper.util.SettingValueUtil; |
||||||
|
import com.bingce.controlnetwork.R; |
||||||
|
import com.bingce.controlnetwork.adapter.BaseAdapter; |
||||||
|
import com.bingce.controlnetwork.surveyor.method.SurveyorAdjustMethodPla; |
||||||
|
import com.bingce.controlnetwork.surveyor.state.StateConstantsPla; |
||||||
|
import com.bingce.controlnetwork.ui.vh.StationAdjustItemViewHolder; |
||||||
|
import com.bingce.controlnetwork.ui.widget.ViewFactory; |
||||||
|
import com.bingce.utils.Util; |
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull; |
||||||
|
|
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
public class StationDataAdjustDialogFragmentTj extends DialogFragment { |
||||||
|
public static final String KEY_MEASURE_WHAT = "__key_measure_what"; |
||||||
|
|
||||||
|
private static final String KEY_LIST = "__key_list"; |
||||||
|
private static final String KEY_IS_SHOW_SLOP_DISTANCE = "__key_show_slop"; |
||||||
|
|
||||||
|
|
||||||
|
private int measureWhat; |
||||||
|
|
||||||
|
@Override |
||||||
|
public void onAttach(@NonNull Context context) { |
||||||
|
super.onAttach(context); |
||||||
|
Bundle arguments = getArguments(); |
||||||
|
if (arguments != null) { |
||||||
|
measureWhat = arguments.getInt(KEY_MEASURE_WHAT, StateConstantsPla.VALUE_MEASURE_WHAT_DEFAULT); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { |
||||||
|
super.onViewCreated(view, savedInstanceState); |
||||||
|
if (getDialog() == null) { |
||||||
|
return; |
||||||
|
} |
||||||
|
Window window = getDialog().getWindow(); |
||||||
|
window.setBackgroundDrawable(new ColorDrawable(0x00000000)); |
||||||
|
window.setLayout( |
||||||
|
WindowManager.LayoutParams.MATCH_PARENT, |
||||||
|
WindowManager.LayoutParams.WRAP_CONTENT); |
||||||
|
} |
||||||
|
|
||||||
|
@Nullable |
||||||
|
@org.jetbrains.annotations.Nullable |
||||||
|
@Override |
||||||
|
public View onCreateView(@NonNull @NotNull LayoutInflater inflater, @Nullable @org.jetbrains.annotations.Nullable ViewGroup container, @Nullable @org.jetbrains.annotations.Nullable Bundle savedInstanceState) { |
||||||
|
View rootView = inflater.inflate(R.layout.fragment_station_data_adjust_dialog_layout, container, false); |
||||||
|
if (getArguments() != null) { |
||||||
|
ArrayList<SurveyorAdjustMethodPla.Item> items = getArguments().getParcelableArrayList(KEY_LIST); |
||||||
|
|
||||||
|
boolean isShowSlop = getArguments().getBoolean(KEY_IS_SHOW_SLOP_DISTANCE, true); |
||||||
|
RecyclerView recyclerView = rootView.findViewById(R.id.list); |
||||||
|
TextView distanceTitle = rootView.findViewById(R.id.distance_angle_title); |
||||||
|
if (recyclerView != null) { |
||||||
|
_Adapter adapter = new _Adapter(items); |
||||||
|
recyclerView.setAdapter(adapter); |
||||||
|
if (distanceTitle != null) { |
||||||
|
distanceTitle.setText(isShowSlop ? R.string.distance_slope : R.string.distance_horizontal); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
initShowView(rootView.findViewById(R.id.hor_angle_title), |
||||||
|
rootView.findViewById(R.id.ver_angle_title), |
||||||
|
rootView.findViewById(R.id.distance_angle_title)); |
||||||
|
|
||||||
|
} |
||||||
|
return rootView; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
private void initShowView(View horView, View verView, View disView) { |
||||||
|
switch (measureWhat) { |
||||||
|
case StateConstantsPla.VALUE_MEASURE_WHAT_DISTANCE: |
||||||
|
horView.setVisibility(View.GONE); |
||||||
|
verView.setVisibility(View.GONE); |
||||||
|
disView.setVisibility(View.VISIBLE); |
||||||
|
break; |
||||||
|
case StateConstantsPla.VALUE_MEASURE_WHAT_ANGLE_HOR: |
||||||
|
horView.setVisibility(View.VISIBLE); |
||||||
|
verView.setVisibility(View.GONE); |
||||||
|
disView.setVisibility(View.GONE); |
||||||
|
break; |
||||||
|
case StateConstantsPla.VALUE_MEASURE_WHAT_ANGLE_VER: |
||||||
|
horView.setVisibility(View.GONE); |
||||||
|
verView.setVisibility(View.VISIBLE); |
||||||
|
disView.setVisibility(View.GONE); |
||||||
|
break; |
||||||
|
// case StateConstants.VALUE_MEASURE_WHAT_ANGLE:
|
||||||
|
case StateConstantsPla.VALUE_MEASURE_WHAT_DEFAULT: |
||||||
|
default: |
||||||
|
horView.setVisibility(View.VISIBLE); |
||||||
|
verView.setVisibility(View.VISIBLE); |
||||||
|
disView.setVisibility(View.VISIBLE); |
||||||
|
break; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
private class _Adapter extends BaseAdapter<SurveyorAdjustMethodPla.Item, StationAdjustItemViewHolder> { |
||||||
|
|
||||||
|
public _Adapter(List<SurveyorAdjustMethodPla.Item> items) { |
||||||
|
super(items); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected StationAdjustItemViewHolder createVH(@NotNull ViewGroup parent, int viewType) { |
||||||
|
RecyclerView.ViewHolder viewHolder = ViewFactory.generatorViewHolder(parent.getContext(), parent, ViewItemType.stationAdjust); |
||||||
|
if (viewHolder instanceof StationAdjustItemViewHolder) { |
||||||
|
return (StationAdjustItemViewHolder) viewHolder; |
||||||
|
} |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void onBindViewHolder(@NonNull @NotNull StationAdjustItemViewHolder holder, int position) { |
||||||
|
SurveyorAdjustMethodPla.Item item = getItem(position); |
||||||
|
|
||||||
|
initShowView(holder.horAngle, holder.verAngle, holder.distance); |
||||||
|
|
||||||
|
setText(holder.pointName, item.getPointName()); |
||||||
|
setText(holder.horAngle, formatAngle(item.getHorAngle())); |
||||||
|
setText(holder.verAngle, formatAngle(item.getVerAngle())); |
||||||
|
setText(holder.distance, formatDistance(item.getDistance())); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
private void setText(TextView textView, String string) { |
||||||
|
if (textView != null) { |
||||||
|
textView.setText(string); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private String formatAngle(double angle) { |
||||||
|
// if (angle < 0) {
|
||||||
|
// return "";
|
||||||
|
// }
|
||||||
|
return RadianMethod.dmsStringOf(angle); |
||||||
|
} |
||||||
|
|
||||||
|
private String formatDistance(double distance) { |
||||||
|
if (distance < 0) { |
||||||
|
return ""; |
||||||
|
} |
||||||
|
return Util.formatDouble2String(distance, SettingValueUtil.getLengthDecimalPoint()); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public static void showDialog(int measureWhat, ArrayList<SurveyorAdjustMethodPla.Item> finalItemList, |
||||||
|
Boolean isShowSlopDistance, |
||||||
|
FragmentManager fragmentManager) { |
||||||
|
StationDataAdjustDialogFragmentTj dialogFragment = new StationDataAdjustDialogFragmentTj(); |
||||||
|
Bundle args = new Bundle(); |
||||||
|
args.putInt(KEY_MEASURE_WHAT, measureWhat); |
||||||
|
args.putParcelableArrayList(KEY_LIST, finalItemList); |
||||||
|
args.putBoolean(KEY_IS_SHOW_SLOP_DISTANCE, isShowSlopDistance); |
||||||
|
dialogFragment.setArguments(args); |
||||||
|
dialogFragment.show(fragmentManager, StationDataAdjustDialogFragmentTj.class.getName()); |
||||||
|
} |
||||||
|
} |
@ -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); |
||||||
|
} |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -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> |
||||||
|
* 1、Viewpager + 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); |
||||||
|
} |
||||||
|
} |
||||||
|
|
@ -0,0 +1,476 @@ |
|||||||
|
package com.bingce.controlnetwork.fragment.stationsurvey.separate; |
||||||
|
|
||||||
|
import android.content.Context; |
||||||
|
import android.os.Bundle; |
||||||
|
import android.view.LayoutInflater; |
||||||
|
import android.view.View; |
||||||
|
import android.view.ViewGroup; |
||||||
|
|
||||||
|
import androidx.annotation.NonNull; |
||||||
|
import androidx.annotation.Nullable; |
||||||
|
import androidx.annotation.WorkerThread; |
||||||
|
import androidx.fragment.app.FragmentManager; |
||||||
|
import androidx.lifecycle.LifecycleOwner; |
||||||
|
import androidx.recyclerview.widget.RecyclerView; |
||||||
|
|
||||||
|
import com.bingce.controlapphelper.datasource.database.ProjectTypeValue; |
||||||
|
import com.bingce.controlapphelper.datasource.database.SurveyorDatabaseFactory; |
||||||
|
import com.bingce.controlapphelper.datasource.database.project.ProjectRecord; |
||||||
|
import com.bingce.controlapphelper.datasource.database.surveyorstation.SurveyorStationRecord; |
||||||
|
import com.bingce.controlapphelper.datasource.database.tolerance.detail.ToleranceDetailRecord; |
||||||
|
import com.bingce.controlapphelper.model.ViewItemType; |
||||||
|
import com.bingce.controlapphelper.surveyor.data.IDistanceTypeChangeListener; |
||||||
|
import com.bingce.controlapphelper.util.IUIRunner; |
||||||
|
import com.bingce.controlapphelper.util.Tools; |
||||||
|
import com.bingce.controlnetwork.R; |
||||||
|
import com.bingce.controlnetwork.fragment.TipsWith2OptionFragment; |
||||||
|
import com.bingce.controlnetwork.fragment.stationsurvey.IMeasureOperate; |
||||||
|
import com.bingce.controlnetwork.fragment.stationsurvey.base.BaseFragmentLazy; |
||||||
|
import com.bingce.controlnetwork.surveyor.data.CachedData; |
||||||
|
import com.bingce.controlnetwork.surveyor.data.CachedDataPointType; |
||||||
|
import com.bingce.controlnetwork.surveyor.data.ICachedData; |
||||||
|
import com.bingce.controlnetwork.surveyor.data.ISurveyorData; |
||||||
|
import com.bingce.controlnetwork.surveyor.data.SurveyorData; |
||||||
|
import com.bingce.controlnetwork.surveyor.state.ISurveyState; |
||||||
|
import com.bingce.controlnetwork.surveyor.state.ISurveyorDataScrollDelegate; |
||||||
|
import com.bingce.controlnetwork.surveyor.state.StateConstantsPla; |
||||||
|
import com.bingce.controlnetwork.surveyor.state.wellDistance.StateManagerWell; |
||||||
|
import com.bingce.controlnetwork.surveyor.state.wellDistance._CheckToleranceState; |
||||||
|
import com.bingce.utils.ThreadPoolUtil; |
||||||
|
|
||||||
|
import blankj.utilcode.util.ToastUtils; |
||||||
|
import com.bingce.controlnetwork.surveyor.state.wellDistance.IWeatherShowDialogListener; |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* 井定向钢丝测距或者单独测距 |
||||||
|
*/ |
||||||
|
public class StationSurveyorSeparateDistanceFragment extends BaseFragmentLazy |
||||||
|
implements IDistanceTypeChangeListener, ISurveyState, IMeasureOperate { |
||||||
|
|
||||||
|
private StationSurveyorSepatateAdapter adapter = null; |
||||||
|
private StateManagerWell stateManager; //这里的stateManager是克隆StateManager
|
||||||
|
private RecyclerView recyclerView; |
||||||
|
private ICachedData cachedData = null; |
||||||
|
private ISurveyorData surveyedData = null; |
||||||
|
private ISurveyState surveyState; |
||||||
|
|
||||||
|
private final IWeatherShowDialogListener weatherShowDialogListener = (stationId, currentCycleIndex, pointId, beforeOrAfter, msg) -> { |
||||||
|
if (getView() == null) return; |
||||||
|
TipsWith2OptionFragment |
||||||
|
.tips( |
||||||
|
getChildFragmentManager(), |
||||||
|
getViewLifecycleOwner(), |
||||||
|
Tools.getString(R.string.confirm), |
||||||
|
Tools.getString(R.string.cancel), |
||||||
|
msg, |
||||||
|
new TipsWith2OptionFragment.SimpleCallback() { |
||||||
|
@Override |
||||||
|
public void onConfirm() { |
||||||
|
// DistanceWeatherSettingTjActivity.launch(requireContext(), stationId, currentCycleIndex, pointId, beforeOrAfter);
|
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void onIgnore() { |
||||||
|
super.onIgnore(); |
||||||
|
} |
||||||
|
} |
||||||
|
); |
||||||
|
}; |
||||||
|
|
||||||
|
private String stationId() { |
||||||
|
if (getArguments() == null) { |
||||||
|
return null; |
||||||
|
} |
||||||
|
return getArguments().getString(KEY_STATION_ID); |
||||||
|
} |
||||||
|
|
||||||
|
@Nullable |
||||||
|
@Override |
||||||
|
public View onCreateView(@NonNull LayoutInflater inflater, |
||||||
|
@Nullable ViewGroup container, |
||||||
|
@Nullable Bundle savedInstanceState) { |
||||||
|
View view = inflater.inflate( |
||||||
|
R.layout.fragment_project_surveyor_station_point_list_layout, |
||||||
|
container, |
||||||
|
false); |
||||||
|
recyclerView = view.findViewById(R.id.recycler_view); |
||||||
|
|
||||||
|
String stationId = stationId(); |
||||||
|
if (stationId != null) { |
||||||
|
//收集信息
|
||||||
|
collectData(stationId, |
||||||
|
getContext(), |
||||||
|
getChildFragmentManager(), |
||||||
|
getViewLifecycleOwner(), |
||||||
|
this::runOnUI, |
||||||
|
this::scrollToPosition, |
||||||
|
new ICollectCacheCallback() { |
||||||
|
@Override |
||||||
|
public void onFailure() { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void onSuccess(boolean showSlopDistance, ICachedData cachedData, SurveyorData surveyorData, StateManagerWell stateManager) { |
||||||
|
onCollectStationData(showSlopDistance, cachedData, surveyorData, stateManager); |
||||||
|
surveyState = stateManager; |
||||||
|
} |
||||||
|
} |
||||||
|
); |
||||||
|
} |
||||||
|
|
||||||
|
return view; |
||||||
|
} |
||||||
|
|
||||||
|
@WorkerThread |
||||||
|
private void onCollectStationData( |
||||||
|
boolean showSlopDistance, |
||||||
|
ICachedData cachedData, |
||||||
|
SurveyorData surveyorData, |
||||||
|
StateManagerWell stateManager) { |
||||||
|
|
||||||
|
this.stateManager = stateManager; |
||||||
|
this.cachedData = cachedData; |
||||||
|
this.surveyedData = surveyorData; |
||||||
|
|
||||||
|
//更新完棱镜类型刷新页面
|
||||||
|
// stateManager.setRefreshFragmentUiListener(() -> changeCacheDataAndRefreshUi(stationId()));
|
||||||
|
|
||||||
|
|
||||||
|
//测量数据收集完毕后,就可以更新UI了
|
||||||
|
runOnUI(() -> { |
||||||
|
if (getView() == null) { |
||||||
|
return; |
||||||
|
} |
||||||
|
//刷新UI
|
||||||
|
if (adapter == null) { |
||||||
|
adapter = new StationSurveyorSepatateAdapter(stateManager.getProjectType(), stationId(), |
||||||
|
cachedData, stateManager.getTolreanceRecord(), surveyorData, surveyorData, ViewItemType.aloneDistanceMeasure); |
||||||
|
adapter.onShowSlopDistance(showSlopDistance); |
||||||
|
if (recyclerView != null) { |
||||||
|
recyclerView.setAdapter(adapter); |
||||||
|
//滚动到当前目标点
|
||||||
|
int currentItemIndex = surveyorData.currentIndex(); |
||||||
|
scrollToPosition(0, currentItemIndex); |
||||||
|
} |
||||||
|
|
||||||
|
adapter.setOnItemClickListener(position -> { |
||||||
|
if (isSurveying()) { |
||||||
|
ToastUtils.showShort("正在测量中,请稍后..."); |
||||||
|
return; |
||||||
|
} |
||||||
|
stateManager.setCurrentIndex(position); |
||||||
|
stateManager.setCurrentCycleIndex(0); |
||||||
|
stateManager.refeshRollBackBtn(); |
||||||
|
|
||||||
|
scrollToPosition(0, position); |
||||||
|
}); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
//监听测站数据,更新界面「平距」「斜距」显示
|
||||||
|
SurveyorDatabaseFactory |
||||||
|
.instance |
||||||
|
.getSurveyorStation() |
||||||
|
.getLiveDataRecord(stationId()) |
||||||
|
.observe(getViewLifecycleOwner(), |
||||||
|
surveyorStationRecord -> onShowSlopDistance(surveyorStationRecord.isShowSlopDistance())); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
private void scrollToPosition(int cycleIndex, int position) { |
||||||
|
if (position >= 0 && adapter != null && position < adapter.getItemCount()) { |
||||||
|
recyclerView.scrollToPosition(position); |
||||||
|
adapter.notifyDataSetChanged(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 收集测站信息 |
||||||
|
*/ |
||||||
|
private void collectData( |
||||||
|
String stationId, |
||||||
|
Context context, |
||||||
|
FragmentManager fragmentManager, |
||||||
|
LifecycleOwner lifecycleOwner, |
||||||
|
IUIRunner runner, |
||||||
|
ISurveyorDataScrollDelegate scrollDelegate, |
||||||
|
ICollectCacheCallback callback) { |
||||||
|
if (callback == null) { |
||||||
|
return; |
||||||
|
} |
||||||
|
ThreadPoolUtil.execute(() -> { |
||||||
|
//加载测站信息
|
||||||
|
SurveyorStationRecord stationRecord = |
||||||
|
SurveyorDatabaseFactory |
||||||
|
.instance |
||||||
|
.getSurveyorStation() |
||||||
|
.getRecordSync(stationId); |
||||||
|
//加载对应项目
|
||||||
|
ProjectRecord projectRecord = SurveyorDatabaseFactory |
||||||
|
.instance |
||||||
|
.getProjectDataSource() |
||||||
|
.getRecord(stationRecord.getProjectId()); |
||||||
|
if (projectRecord == null) { |
||||||
|
callback.onFailure(); |
||||||
|
return; |
||||||
|
} |
||||||
|
//加载对应限差
|
||||||
|
ToleranceDetailRecord toleranceRecord = SurveyorDatabaseFactory |
||||||
|
.instance |
||||||
|
.getToleranceDetailDataSource() |
||||||
|
.getRecordSync(projectRecord.getToleranceId()); |
||||||
|
if (toleranceRecord == null) { |
||||||
|
callback.onFailure(); |
||||||
|
return; |
||||||
|
} |
||||||
|
//创建缓存数据
|
||||||
|
CachedDataPointType cachedDataPointType = CachedDataPointType.ALONE_MEASURE_DISTANCE_POINT; |
||||||
|
if (isConnection(stationRecord.projectType)) { |
||||||
|
//如果是联系列表收集的是钢丝
|
||||||
|
cachedDataPointType = CachedDataPointType.STEEL_POINT; |
||||||
|
} |
||||||
|
CachedData cachedData = CachedData.newInstance(StateConstantsPla.VALUE_MEASURE_WHAT_DISTANCE, cachedDataPointType, stationRecord.isAutoClose(), |
||||||
|
stationRecord.isLeftAndRightSurveyor(), |
||||||
|
stationId, toleranceRecord); |
||||||
|
if (cachedData == null) { |
||||||
|
callback.onFailure(); |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
//是否显示斜距?
|
||||||
|
cachedData.onShowSlopDistance(stationRecord.isShowSlopDistance()); |
||||||
|
//创建stateManager实例
|
||||||
|
SurveyorData surveyorDataSource = new SurveyorData(ToleranceDetailRecord.ALONE_DISTANCE_MEASURE_COUNT); |
||||||
|
surveyorDataSource.onShowSlopDistance(stationRecord.isShowSlopDistance()); |
||||||
|
|
||||||
|
//
|
||||||
|
|
||||||
|
StateManagerWell stateManager = StateManagerWell.newInstance( |
||||||
|
stationRecord, |
||||||
|
context, |
||||||
|
fragmentManager, |
||||||
|
lifecycleOwner, |
||||||
|
toleranceRecord, |
||||||
|
cachedData, |
||||||
|
surveyorDataSource, |
||||||
|
surveyorDataSource, |
||||||
|
cachedData, |
||||||
|
scrollDelegate, |
||||||
|
runner, |
||||||
|
weatherShowDialogListener |
||||||
|
); |
||||||
|
|
||||||
|
callback.onSuccess(stationRecord.isShowSlopDistance(), cachedData, surveyorDataSource, stateManager); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 改变cacheData并刷新Ui |
||||||
|
*/ |
||||||
|
private void changeCacheDataAndRefreshUi(String stationId) { |
||||||
|
ThreadPoolUtil.execute(() -> { |
||||||
|
//加载测站信息
|
||||||
|
SurveyorStationRecord surveyorStationRecord = |
||||||
|
SurveyorDatabaseFactory |
||||||
|
.instance |
||||||
|
.getSurveyorStation() |
||||||
|
.getRecordSync(stationId); |
||||||
|
//加载对应项目
|
||||||
|
ProjectRecord projectRecord = SurveyorDatabaseFactory |
||||||
|
.instance |
||||||
|
.getProjectDataSource() |
||||||
|
.getRecord(surveyorStationRecord.getProjectId()); |
||||||
|
if (projectRecord == null) { |
||||||
|
return; |
||||||
|
} |
||||||
|
//加载对应限差
|
||||||
|
ToleranceDetailRecord toleranceRecord = SurveyorDatabaseFactory |
||||||
|
.instance |
||||||
|
.getToleranceDetailDataSource() |
||||||
|
.getRecordSync(projectRecord.getToleranceId()); |
||||||
|
if (toleranceRecord == null) { |
||||||
|
return; |
||||||
|
} |
||||||
|
//创建缓存数据
|
||||||
|
CachedDataPointType cachedDataPointType = CachedDataPointType.ALONE_MEASURE_DISTANCE_POINT; |
||||||
|
if (isConnection(surveyorStationRecord.projectType)) { |
||||||
|
cachedDataPointType = CachedDataPointType.STEEL_POINT; |
||||||
|
} |
||||||
|
CachedData cachedData = CachedData.newInstance(StateConstantsPla.VALUE_MEASURE_WHAT_DEFAULT, cachedDataPointType, surveyorStationRecord.isAutoClose(), |
||||||
|
surveyorStationRecord.isLeftAndRightSurveyor(), |
||||||
|
stationId, toleranceRecord); |
||||||
|
if (cachedData != null) { |
||||||
|
//是否显示斜距?
|
||||||
|
cachedData.onShowSlopDistance(surveyorStationRecord.isShowSlopDistance()); |
||||||
|
// stateManager.setCachedData(cachedData);
|
||||||
|
adapter.setCachedData(cachedData); |
||||||
|
runOnUI(() -> adapter.notifyDataSetChanged()); |
||||||
|
} |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
public interface ICollectCacheCallback { |
||||||
|
void onFailure(); |
||||||
|
|
||||||
|
void onSuccess(boolean showSlopDistance, ICachedData cachedData, SurveyorData surveyorData, StateManagerWell stateManager); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void doSurveyor() { |
||||||
|
if (stateManager == null) { |
||||||
|
return; |
||||||
|
} |
||||||
|
stateManager.doSurveyor(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void autoSurvey() { |
||||||
|
|
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void switchCycle(int cycleIndex) { |
||||||
|
if (stateManager == null) { |
||||||
|
return; |
||||||
|
} |
||||||
|
stateManager.switch2Cycle(cycleIndex); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void deleteStationAllCycleRecord() { |
||||||
|
if (stateManager == null) { |
||||||
|
return; |
||||||
|
} |
||||||
|
stateManager.deletePointAllCycleData(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void deleteStationOneCycleRecord(int cycleIndex) { |
||||||
|
if (stateManager == null) { |
||||||
|
return; |
||||||
|
} |
||||||
|
stateManager.deletePointCurrentCycleData(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String stationCheck() { |
||||||
|
if (stateManager == null) { |
||||||
|
return null; |
||||||
|
} |
||||||
|
stateManager.stationCheck(); |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void stationAdjust() { |
||||||
|
if (stateManager != null) { |
||||||
|
stateManager.stationAdjust(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void goBack() { |
||||||
|
if (stateManager == null) { |
||||||
|
return; |
||||||
|
} |
||||||
|
stateManager.moveBack(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void onShowSlopDistance(boolean value) { |
||||||
|
if (cachedData != null) { |
||||||
|
cachedData.onShowSlopDistance(value); |
||||||
|
} |
||||||
|
if (surveyedData != null) { |
||||||
|
surveyedData.onShowSlopDistance(value); |
||||||
|
} |
||||||
|
if (adapter != null) { |
||||||
|
adapter.onShowSlopDistance(value); |
||||||
|
adapter.notifyItemRangeChanged(0, adapter.getItemCount()); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean isSurveying() { |
||||||
|
if (surveyState != null) { |
||||||
|
return surveyState.isSurveying(); |
||||||
|
} |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean isAutoSurveying() { |
||||||
|
if (surveyState != null) { |
||||||
|
return surveyState.isAutoSurveying(); |
||||||
|
} |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
private static final String KEY_STATION_ID = "__station_id"; |
||||||
|
private static final String KEY_WELL_TYPE = "__well_type"; |
||||||
|
public static final String TAG = StationSurveyorSeparateDistanceFragment.class.getName(); |
||||||
|
|
||||||
|
public static StationSurveyorSeparateDistanceFragment newInstance(String stationId) { |
||||||
|
StationSurveyorSeparateDistanceFragment fragment = new StationSurveyorSeparateDistanceFragment(); |
||||||
|
Bundle bundle = new Bundle(); |
||||||
|
bundle.putString(KEY_STATION_ID, stationId); |
||||||
|
fragment.setArguments(bundle); |
||||||
|
return fragment; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean isCurrentCycleComplete() { |
||||||
|
if (stateManager == null) |
||||||
|
return false; |
||||||
|
return _CheckToleranceState.isCompleteAllPointForAloneDistance(stationId(), 0, stateManager.getCachedData()); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public int measureTypePosition() { |
||||||
|
return 0; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public int getMeasureWhat() { |
||||||
|
return StateConstantsPla.VALUE_MEASURE_WHAT_DISTANCE; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void onResumeState() { |
||||||
|
if (stateManager != null) { |
||||||
|
stateManager.resume(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void onPauseState() { |
||||||
|
if (stateManager != null) { |
||||||
|
stateManager.quite(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected void onFragmentFirstVisible() { |
||||||
|
if (stateManager != null) |
||||||
|
stateManager.calScheduleWhenEnterSurveyFragment(); |
||||||
|
// if (stateManager != null)
|
||||||
|
// stateManager.enter(StateType.idle);
|
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 是否联系测量 |
||||||
|
* |
||||||
|
* @param projectType 项目类型 |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
private boolean isConnection(String projectType) { |
||||||
|
return ProjectTypeValue.CONNECTION.equals(projectType); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,375 @@ |
|||||||
|
package com.bingce.controlnetwork.fragment.stationsurvey.separate; |
||||||
|
|
||||||
|
|
||||||
|
import android.content.Context; |
||||||
|
import android.graphics.Color; |
||||||
|
import android.os.Bundle; |
||||||
|
import android.view.LayoutInflater; |
||||||
|
import android.view.View; |
||||||
|
import android.view.ViewGroup; |
||||||
|
import android.view.WindowManager; |
||||||
|
import android.widget.Button; |
||||||
|
|
||||||
|
import androidx.annotation.NonNull; |
||||||
|
import androidx.annotation.Nullable; |
||||||
|
import androidx.fragment.app.Fragment; |
||||||
|
import androidx.fragment.app.FragmentActivity; |
||||||
|
import androidx.fragment.app.FragmentManager; |
||||||
|
import androidx.fragment.app.FragmentStatePagerAdapter; |
||||||
|
import androidx.viewpager.widget.PagerAdapter; |
||||||
|
import androidx.viewpager.widget.ViewPager; |
||||||
|
|
||||||
|
import com.bingce.controlapphelper.model.BundleConstants; |
||||||
|
import com.bingce.controlnetwork.R; |
||||||
|
import com.bingce.controlnetwork.activity.fragmentcontainer.FragmentContainerActivity; |
||||||
|
import com.bingce.controlnetwork.event.RefreshRollBackEvent; |
||||||
|
import com.bingce.controlnetwork.event.SurveyStateEvent; |
||||||
|
import com.bingce.controlnetwork.fragment.base.BaseFragment; |
||||||
|
import com.bingce.controlnetwork.fragment.stationsurvey.IMeasureOperate; |
||||||
|
import com.bingce.controlnetwork.newui.stationsetting.StationSettingsActivity; |
||||||
|
import com.bingce.controlnetwork.newui.stationsurveyor.ISurveyorMenuOperate; |
||||||
|
import com.bingce.controlnetwork.newui.stationsurveyor.StationSurveyorHomeActivity; |
||||||
|
import com.bingce.controlnetwork.surveyor.surveyor.TestDataSelectFragment; |
||||||
|
import com.bingce.controlnetwork.util.StationSettingCheckUtil; |
||||||
|
import com.flyco.tablayout.SlidingTabLayout; |
||||||
|
import com.github.razir.progressbutton.DrawableButtonExtensionsKt; |
||||||
|
import com.github.razir.progressbutton.ProgressButtonHolderKt; |
||||||
|
|
||||||
|
import org.greenrobot.eventbus.EventBus; |
||||||
|
import org.greenrobot.eventbus.Subscribe; |
||||||
|
import org.greenrobot.eventbus.ThreadMode; |
||||||
|
|
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* 测站测量页面(开始测量) |
||||||
|
* 水平角,垂直角,距离分开观测 |
||||||
|
*/ |
||||||
|
public class StationSurveyorSeparateFragment extends BaseFragment implements ISurveyorMenuOperate { |
||||||
|
public static final String TAG = StationSurveyorSeparateFragment.class.getName(); |
||||||
|
|
||||||
|
// private SurveyorStationRecord surveyorStationRecord;
|
||||||
|
|
||||||
|
//方位观测fragment的在adapter的索引
|
||||||
|
public static final int POSITION_ANGLE_HOR = 0; |
||||||
|
public static final int POSITION_ANGLE_VER = 1; |
||||||
|
public static final int POSITION_DISTANCE_MEASURE = 2; |
||||||
|
private final String[] tabs = { |
||||||
|
"水平角观测", "垂直角观测", "距离观测" |
||||||
|
}; |
||||||
|
|
||||||
|
private List<IMeasureOperate> fragments; |
||||||
|
private IMeasureOperate currentFragment; |
||||||
|
|
||||||
|
private ViewPager vp; |
||||||
|
|
||||||
|
private final StationSettingCheckUtil stationSettingCheckUtil = new StationSettingCheckUtil(); |
||||||
|
|
||||||
|
|
||||||
|
@Subscribe(threadMode = ThreadMode.MAIN) |
||||||
|
public void onRefreshGoBack(RefreshRollBackEvent event) { |
||||||
|
if (vp != null) { |
||||||
|
int currentItem = vp.getCurrentItem(); |
||||||
|
if (currentItem == POSITION_ANGLE_HOR) { |
||||||
|
setRollBackEnable(event.validate); |
||||||
|
} else if (currentItem == POSITION_DISTANCE_MEASURE) { |
||||||
|
setRollBackEnable(event.validate); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Subscribe(threadMode = ThreadMode.MAIN) |
||||||
|
public void onSurveyorStateChanged(SurveyStateEvent event) { |
||||||
|
if (getView() == null) { |
||||||
|
return; |
||||||
|
} |
||||||
|
Button surveyorButton = getView().findViewById(R.id.surveyor); |
||||||
|
if (surveyorButton == null) { |
||||||
|
return; |
||||||
|
} |
||||||
|
if (event.isIdle() || event.isSuccess() || event.isCompleted()) { |
||||||
|
DrawableButtonExtensionsKt.hideProgress(surveyorButton, R.string.start_surveyor); |
||||||
|
} else if (event.isSurveying()) { |
||||||
|
DrawableButtonExtensionsKt.showProgress(surveyorButton, progressParams -> { |
||||||
|
progressParams.setButtonTextRes(R.string.tips_surveying); |
||||||
|
progressParams.setProgressColor(Color.WHITE); |
||||||
|
return null; |
||||||
|
}); |
||||||
|
} else if (event.isFailure()) { |
||||||
|
DrawableButtonExtensionsKt.hideProgress(surveyorButton, R.string.tips_surveyor_failure_and_retry); |
||||||
|
} |
||||||
|
|
||||||
|
boolean enable = event.isIdle() || event.isFailure() || event.isSuccess(); |
||||||
|
|
||||||
|
setSurveyorEnable(getView(), R.id.surveyor, enable); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
private String stationId() { |
||||||
|
if (getArguments() == null) { |
||||||
|
return null; |
||||||
|
} |
||||||
|
return getArguments().getString(BundleConstants.KEY_SURVEYOR_STATION_ID); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void onStart() { |
||||||
|
super.onStart(); |
||||||
|
EventBus.getDefault().register(this); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void onStop() { |
||||||
|
super.onStop(); |
||||||
|
EventBus.getDefault().unregister(this); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void onResume() { |
||||||
|
super.onResume(); |
||||||
|
//测量界面保持常亮
|
||||||
|
if (getActivity() != null) { |
||||||
|
getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); |
||||||
|
} |
||||||
|
if (currentFragment != null) { |
||||||
|
currentFragment.onResumeState(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void onPause() { |
||||||
|
super.onPause(); |
||||||
|
//清除界面常亮
|
||||||
|
if (getActivity() != null) { |
||||||
|
getActivity().getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); |
||||||
|
} |
||||||
|
if (currentFragment != null) { |
||||||
|
currentFragment.onPauseState(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Nullable |
||||||
|
@Override |
||||||
|
public View onCreateView(@NonNull LayoutInflater inflater, |
||||||
|
@Nullable ViewGroup container, |
||||||
|
@Nullable Bundle savedInstanceState) { |
||||||
|
View view = inflater.inflate(R.layout.fragment_station_surveyor_separate, |
||||||
|
container, |
||||||
|
false); |
||||||
|
//2.设置测量按钮
|
||||||
|
Button surveyor = view.findViewById(R.id.surveyor); |
||||||
|
if (surveyor != null) { |
||||||
|
ProgressButtonHolderKt.bindProgressButton(getViewLifecycleOwner(), surveyor); |
||||||
|
} |
||||||
|
setClick(view, R.id.surveyor, this::startSurveyor); |
||||||
|
|
||||||
|
setHasOptionsMenu(true); |
||||||
|
|
||||||
|
return view; |
||||||
|
} |
||||||
|
|
||||||
|
private void initData() { |
||||||
|
// ThreadPoolUtil.execute(() -> {
|
||||||
|
// surveyorStationRecord = TjDbFactory
|
||||||
|
// .instance
|
||||||
|
// .getSurveyorStation()
|
||||||
|
// .getRecordSync(stationId());
|
||||||
|
// //监听数据变化
|
||||||
|
// ToleranceDetailRecordTj toleranceRecord = getTolerance(surveyorStationRecord);
|
||||||
|
// if (toleranceRecord == null) {
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// int cycleCount = StationUtilTj.getCycleCount(surveyorStationRecord, toleranceRecord);
|
||||||
|
// cycleList = SurveyorCycleUtil.cycleStrings(cycleCount,
|
||||||
|
// surveyorStationRecord != null && surveyorStationRecord.leftAndRightSurveyor);
|
||||||
|
// });
|
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { |
||||||
|
super.onViewCreated(view, savedInstanceState); |
||||||
|
initViewPager(view); |
||||||
|
initData(); |
||||||
|
} |
||||||
|
|
||||||
|
private void initViewPager(View view) { |
||||||
|
|
||||||
|
fragments = new ArrayList<>(); |
||||||
|
fragments.add(StationSurveyorSeparateHorAngleFragment.newInstance(stationId())); |
||||||
|
fragments.add(StationSurveyorSeparateVerAngleFragment.newInstance(stationId())); |
||||||
|
fragments.add(StationSurveyorSeparateDistanceFragment.newInstance(stationId())); |
||||||
|
|
||||||
|
SlidingTabLayout tabLayout = view.findViewById(R.id.tabLayout); |
||||||
|
vp = view.findViewById(R.id.vp); |
||||||
|
vp.setOffscreenPageLimit(3); |
||||||
|
vp.setAdapter(new MyPagerAdapter(getChildFragmentManager())); |
||||||
|
tabLayout.setViewPager(vp); |
||||||
|
|
||||||
|
vp.setCurrentItem(POSITION_ANGLE_HOR); |
||||||
|
currentFragment = fragments.get(POSITION_ANGLE_HOR); |
||||||
|
|
||||||
|
vp.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { |
||||||
|
@Override |
||||||
|
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void onPageSelected(int position) { |
||||||
|
currentFragment = fragments.get(position); |
||||||
|
|
||||||
|
//刷新按钮状态
|
||||||
|
boolean currentCycleComplete = currentFragment.isCurrentCycleComplete(); |
||||||
|
if (currentCycleComplete) { |
||||||
|
SurveyStateEvent.postCompleted(); |
||||||
|
} else { |
||||||
|
SurveyStateEvent.postIdle(); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void onPageScrollStateChanged(int state) { |
||||||
|
|
||||||
|
} |
||||||
|
}); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
private static void setClick(View rootView, int id, Runnable runnable) { |
||||||
|
View view = rootView.findViewById(id); |
||||||
|
if (view != null) { |
||||||
|
view.setOnClickListener(v -> runnable.run()); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private static void setSurveyorEnable(View rootView, int id, boolean enable) { |
||||||
|
if (rootView == null) { |
||||||
|
return; |
||||||
|
} |
||||||
|
View view = rootView.findViewById(id); |
||||||
|
if (view != null) { |
||||||
|
view.setEnabled(enable); |
||||||
|
if (enable) { |
||||||
|
view.setAlpha(1); |
||||||
|
} else { |
||||||
|
view.setAlpha(.4f); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private void setRollBackEnable(boolean validate) { |
||||||
|
FragmentActivity activity = getActivity(); |
||||||
|
if (activity != null) { |
||||||
|
StationSurveyorHomeActivity homeActivity = (StationSurveyorHomeActivity) activity; |
||||||
|
homeActivity.setRollBackEnable(validate); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public static void start(Context context, String surveyorStationId, String surveyorStationName) { |
||||||
|
Bundle bundle = new Bundle(); |
||||||
|
bundle.putString(BundleConstants.KEY_SURVEYOR_STATION_ID, surveyorStationId); |
||||||
|
FragmentContainerActivity.start(context, TAG, surveyorStationName, bundle); |
||||||
|
} |
||||||
|
|
||||||
|
public static Fragment newInstance(Bundle args) { |
||||||
|
Fragment fragment = new StationSurveyorSeparateFragment(); |
||||||
|
fragment.setArguments(args); |
||||||
|
return fragment; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void deleteCurrentPeriodRecords() { |
||||||
|
//删除当前测回记录
|
||||||
|
if (currentFragment != null) { |
||||||
|
currentFragment.deleteStationOneCycleRecord(0);//0是占位
|
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void deleteAllPeriodRecords() { |
||||||
|
//删除所有测回记录
|
||||||
|
if (currentFragment != null) { |
||||||
|
currentFragment.deleteStationAllCycleRecord(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void test() { |
||||||
|
//数据源 debug使用
|
||||||
|
TestDataSelectFragment.show(getChildFragmentManager()); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void rollBack() { |
||||||
|
//回退
|
||||||
|
currentFragment.goBack(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void stationSetting() { |
||||||
|
//环境、棱镜设置
|
||||||
|
StationSettingsActivity.start(requireContext(), stationId()); |
||||||
|
// StationSettingsFragment.start(getContext(), stationId());
|
||||||
|
} |
||||||
|
//SurveyorSettingsFragment 测量设置
|
||||||
|
|
||||||
|
@Override |
||||||
|
public void adjust() { |
||||||
|
//测站平差
|
||||||
|
if (currentFragment != null) { |
||||||
|
currentFragment.stationAdjust(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void startSurveyor() { |
||||||
|
stationSettingCheckUtil.checkStationSettings(stationId(), this, this, () -> { |
||||||
|
if (currentFragment != null) { |
||||||
|
currentFragment.doSurveyor(); |
||||||
|
} |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
private class MyPagerAdapter extends FragmentStatePagerAdapter { |
||||||
|
public MyPagerAdapter(FragmentManager fm) { |
||||||
|
super(fm); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public int getCount() { |
||||||
|
return fragments.size(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public CharSequence getPageTitle(int position) { |
||||||
|
return tabs[position]; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public Fragment getItem(int position) { |
||||||
|
return (Fragment) fragments.get(position); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public int getItemPosition(@NonNull Object object) { |
||||||
|
return PagerAdapter.POSITION_NONE; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private boolean isHorAnglePage() { |
||||||
|
return vp.getCurrentItem() == POSITION_ANGLE_HOR; |
||||||
|
} |
||||||
|
|
||||||
|
private boolean isVerAnglePage() { |
||||||
|
return vp.getCurrentItem() == POSITION_ANGLE_VER; |
||||||
|
} |
||||||
|
|
||||||
|
private boolean isDistancePage() { |
||||||
|
return vp.getCurrentItem() == POSITION_DISTANCE_MEASURE; |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,475 @@ |
|||||||
|
package com.bingce.controlnetwork.fragment.stationsurvey.separate; |
||||||
|
|
||||||
|
import android.content.Context; |
||||||
|
import android.os.Bundle; |
||||||
|
import android.view.LayoutInflater; |
||||||
|
import android.view.View; |
||||||
|
import android.view.ViewGroup; |
||||||
|
import android.widget.TextView; |
||||||
|
|
||||||
|
import androidx.annotation.NonNull; |
||||||
|
import androidx.annotation.Nullable; |
||||||
|
import androidx.annotation.WorkerThread; |
||||||
|
import androidx.fragment.app.FragmentManager; |
||||||
|
import androidx.lifecycle.LifecycleOwner; |
||||||
|
import androidx.lifecycle.LiveData; |
||||||
|
import androidx.recyclerview.widget.RecyclerView; |
||||||
|
|
||||||
|
import com.bingce.controlapphelper.datasource.database.SurveyorDatabaseFactory; |
||||||
|
import com.bingce.controlapphelper.datasource.database.project.ProjectRecord; |
||||||
|
import com.bingce.controlapphelper.datasource.database.schedule.SurveyorScheduleRecord; |
||||||
|
import com.bingce.controlapphelper.datasource.database.surveyorstation.SurveyorStationRecord; |
||||||
|
import com.bingce.controlapphelper.datasource.database.tolerance.detail.ToleranceDetailRecord; |
||||||
|
import com.bingce.controlapphelper.model.ViewItemType; |
||||||
|
import com.bingce.controlapphelper.util.DigitalUtil; |
||||||
|
import com.bingce.controlapphelper.util.IUIRunner; |
||||||
|
import com.bingce.controlapphelper.util.SurveyorCycleUtil; |
||||||
|
import com.bingce.controlnetwork.R; |
||||||
|
import com.bingce.controlnetwork.bean.SurveyorScheduleConstants; |
||||||
|
import com.bingce.controlnetwork.fragment.BottomSheetSelectListFragment; |
||||||
|
import com.bingce.controlnetwork.fragment.base.BaseFragment; |
||||||
|
import com.bingce.controlnetwork.fragment.stationsurvey.IMeasureOperate; |
||||||
|
import com.bingce.controlnetwork.surveyor.data.CachedData; |
||||||
|
import com.bingce.controlnetwork.surveyor.data.CachedDataPointType; |
||||||
|
import com.bingce.controlnetwork.surveyor.data.ICachedData; |
||||||
|
import com.bingce.controlnetwork.surveyor.data.IDistanceTypeChangeListener; |
||||||
|
import com.bingce.controlnetwork.surveyor.data.ISurveyorData; |
||||||
|
import com.bingce.controlnetwork.surveyor.data.SurveyorData; |
||||||
|
import com.bingce.controlnetwork.surveyor.state.ISurveyState; |
||||||
|
import com.bingce.controlnetwork.surveyor.state.ISurveyorDataScrollDelegate; |
||||||
|
import com.bingce.controlnetwork.surveyor.state.StateConstantsPla; |
||||||
|
import com.bingce.controlnetwork.surveyor.state.StateManagerPla; |
||||||
|
import com.bingce.controlnetwork.surveyor.state._IsSingleCycleCompletedState; |
||||||
|
import com.bingce.controlnetwork.util.StationUtilPla; |
||||||
|
import com.bingce.utils.ThreadPoolUtil; |
||||||
|
|
||||||
|
import java.util.ArrayList; |
||||||
|
|
||||||
|
import blankj.utilcode.util.ToastUtils; |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* 井定向测量-方位测量 |
||||||
|
*/ |
||||||
|
public class StationSurveyorSeparateHorAngleFragment extends BaseFragment |
||||||
|
implements IDistanceTypeChangeListener, ISurveyState, IMeasureOperate { |
||||||
|
private StationSurveyorSepatateAdapter adapter = null; |
||||||
|
private StateManagerPla stateManager; |
||||||
|
private RecyclerView recyclerView; |
||||||
|
|
||||||
|
private ICachedData cachedData = null; |
||||||
|
private ISurveyorData surveyedData = null; |
||||||
|
private ISurveyState surveyState; |
||||||
|
|
||||||
|
private LiveData<SurveyorScheduleRecord> horCycleLiveData; |
||||||
|
private int cycleIndex = 0; |
||||||
|
private ArrayList<String> cycleList; |
||||||
|
private TextView tvCycle; |
||||||
|
private View cycleLayout; |
||||||
|
private LiveData<SurveyorScheduleRecord> cycleLiveData; |
||||||
|
|
||||||
|
private String stationId() { |
||||||
|
if (getArguments() == null) { |
||||||
|
return null; |
||||||
|
} |
||||||
|
return getArguments().getString(KEY_STATION_ID); |
||||||
|
} |
||||||
|
|
||||||
|
@Nullable |
||||||
|
@Override |
||||||
|
public View onCreateView(@NonNull LayoutInflater inflater, |
||||||
|
@Nullable ViewGroup container, |
||||||
|
@Nullable Bundle savedInstanceState) { |
||||||
|
View view = inflater.inflate( |
||||||
|
R.layout.fragment_station_surveyor_separate_hor_angle, |
||||||
|
container, |
||||||
|
false); |
||||||
|
String stationId = stationId(); |
||||||
|
cycleLayout = view.findViewById(R.id.cycleLayout); |
||||||
|
tvCycle = view.findViewById(R.id.tvCycle); |
||||||
|
recyclerView = view.findViewById(R.id.recyclerView); |
||||||
|
|
||||||
|
//选择测回
|
||||||
|
cycleLayout.setOnClickListener(v -> selectCycleDialog()); |
||||||
|
|
||||||
|
if (stationId != null) { |
||||||
|
//收集信息
|
||||||
|
collectData(stationId, |
||||||
|
getContext(), |
||||||
|
getChildFragmentManager(), |
||||||
|
getViewLifecycleOwner(), |
||||||
|
this, |
||||||
|
(cycleIndex, pointIndex) -> { |
||||||
|
if (pointIndex >= 0 && adapter != null && pointIndex < adapter.getItemCount()) { |
||||||
|
recyclerView.scrollToPosition(pointIndex); |
||||||
|
} |
||||||
|
}, |
||||||
|
new ICollectCacheCallback() { |
||||||
|
@Override |
||||||
|
public void onFailure() { |
||||||
|
//收集测站测量信息失败,提示
|
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void onSuccess(boolean showSlopDistance, ICachedData cachedData, SurveyorData surveyorData, StateManagerPla stateManager) { |
||||||
|
onCollectStationData(showSlopDistance, cachedData, surveyorData, stateManager); |
||||||
|
surveyState = stateManager; |
||||||
|
} |
||||||
|
} |
||||||
|
); |
||||||
|
} |
||||||
|
|
||||||
|
return view; |
||||||
|
} |
||||||
|
|
||||||
|
@WorkerThread |
||||||
|
private void onCollectStationData( |
||||||
|
boolean showSlopDistance, |
||||||
|
ICachedData cachedData, |
||||||
|
SurveyorData surveyorData, |
||||||
|
StateManagerPla stateManager) { |
||||||
|
this.stateManager = stateManager; |
||||||
|
this.cachedData = cachedData; |
||||||
|
surveyedData = surveyorData; |
||||||
|
|
||||||
|
//测量数据收集完毕后,就可以更新UI了
|
||||||
|
runOnUI(() -> { |
||||||
|
if (getView() == null) { |
||||||
|
return; |
||||||
|
} |
||||||
|
//刷新UI
|
||||||
|
if (adapter == null) { |
||||||
|
adapter = new StationSurveyorSepatateAdapter(stateManager.getProjectType(), stationId(), |
||||||
|
cachedData, stateManager.getTolreanceRecord(), surveyorData, surveyorData, ViewItemType.sepatateHorAngle); |
||||||
|
adapter.onShowSlopDistance(showSlopDistance); |
||||||
|
if (recyclerView != null) { |
||||||
|
recyclerView.setAdapter(adapter); |
||||||
|
//滚动到当前目标点
|
||||||
|
int currentItemIndex = surveyorData.currentIndex(); |
||||||
|
if (currentItemIndex >= 0 && currentItemIndex < adapter.getItemCount()) { |
||||||
|
recyclerView.scrollToPosition(currentItemIndex); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
if (getView() != null) { |
||||||
|
initCycleObserver(stateManager.getStationRecord()); |
||||||
|
|
||||||
|
//监听测站数据
|
||||||
|
//监听「平距」「斜距」切换,更新UI显示
|
||||||
|
SurveyorDatabaseFactory |
||||||
|
.instance |
||||||
|
.getSurveyorStation() |
||||||
|
.getLiveDataRecord(stationId()) |
||||||
|
.observe(getViewLifecycleOwner(), |
||||||
|
surveyorStationRecord -> onShowSlopDistance(surveyorStationRecord.isShowSlopDistance())); |
||||||
|
} |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 收集测站信息 |
||||||
|
*/ |
||||||
|
private void collectData( |
||||||
|
String stationId, |
||||||
|
Context context, |
||||||
|
FragmentManager fragmentManager, |
||||||
|
LifecycleOwner lifecycleOwner, |
||||||
|
IUIRunner runner, |
||||||
|
ISurveyorDataScrollDelegate scrollDelegate, |
||||||
|
ICollectCacheCallback callback) { |
||||||
|
if (callback == null) { |
||||||
|
return; |
||||||
|
} |
||||||
|
ThreadPoolUtil.execute(() -> { |
||||||
|
//读取当前测站的当前测回--很重要
|
||||||
|
SurveyorScheduleRecord scheduleRecord = |
||||||
|
SurveyorDatabaseFactory |
||||||
|
.instance |
||||||
|
.getScheduleDataSource() |
||||||
|
.findScheduleSync(SurveyorScheduleConstants.stationCurrentCycleKey(stationId, StateConstantsPla.VALUE_MEASURE_WHAT_ANGLE_HOR)); |
||||||
|
int defaultCycle = scheduleRecord == null ? 0 : |
||||||
|
DigitalUtil.string2Int(scheduleRecord.getStatue(), 0); |
||||||
|
//加载测站信息
|
||||||
|
SurveyorStationRecord surveyorStationRecord = |
||||||
|
SurveyorDatabaseFactory |
||||||
|
.instance |
||||||
|
.getSurveyorStation() |
||||||
|
.getRecordSync(stationId); |
||||||
|
|
||||||
|
//加载对应项目
|
||||||
|
ProjectRecord projectRecord = SurveyorDatabaseFactory |
||||||
|
.instance |
||||||
|
.getProjectDataSource() |
||||||
|
.getRecord(surveyorStationRecord.getProjectId()); |
||||||
|
if (projectRecord == null) { |
||||||
|
callback.onFailure(); |
||||||
|
return; |
||||||
|
} |
||||||
|
//加载对应限差
|
||||||
|
ToleranceDetailRecord toleranceRecord = SurveyorDatabaseFactory |
||||||
|
.instance |
||||||
|
.getToleranceDetailDataSource() |
||||||
|
.getRecordSync(projectRecord.getToleranceId()); |
||||||
|
if (toleranceRecord == null) { |
||||||
|
callback.onFailure(); |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
int cycleCount = StationUtilPla.getCycleCount(getMeasureWhat(), surveyorStationRecord, toleranceRecord); |
||||||
|
cycleList = SurveyorCycleUtil.cycleStrings(cycleCount, |
||||||
|
surveyorStationRecord.leftAndRightSurveyor); |
||||||
|
|
||||||
|
//创建缓存数据
|
||||||
|
CachedData cachedData = |
||||||
|
CachedData.newInstance(StateConstantsPla.VALUE_MEASURE_WHAT_ANGLE_HOR, CachedDataPointType.ALL_POINT, surveyorStationRecord.isAutoClose(), |
||||||
|
surveyorStationRecord.isLeftAndRightSurveyor(), |
||||||
|
stationId, toleranceRecord); |
||||||
|
if (cachedData == null) { |
||||||
|
callback.onFailure(); |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
//是否显示斜距?
|
||||||
|
cachedData.onShowSlopDistance(surveyorStationRecord.isShowSlopDistance()); |
||||||
|
if (cachedData.pointCount() <= 0) { |
||||||
|
callback.onFailure(); |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
//创建stateManager实例
|
||||||
|
SurveyorData surveyorDataSource = new SurveyorData(toleranceRecord.getSurveyorCount()); |
||||||
|
surveyorDataSource.onShowSlopDistance(surveyorStationRecord.isShowSlopDistance()); |
||||||
|
|
||||||
|
StateManagerPla stateManager = StateManagerPla.newInstance( |
||||||
|
StateConstantsPla.VALUE_MEASURE_WHAT_ANGLE_HOR, |
||||||
|
surveyorStationRecord, |
||||||
|
context, |
||||||
|
fragmentManager, |
||||||
|
lifecycleOwner, |
||||||
|
toleranceRecord, |
||||||
|
cachedData, |
||||||
|
surveyorDataSource, |
||||||
|
surveyorDataSource, |
||||||
|
cachedData, |
||||||
|
scrollDelegate, |
||||||
|
runner); |
||||||
|
//fragment创建后立即计算当前cycle的测量状态
|
||||||
|
runner.runOnUI(() -> stateManager.calScheduleWhenEnterSurveyFragment(defaultCycle)); |
||||||
|
callback.onSuccess(surveyorStationRecord.isShowSlopDistance(), cachedData, surveyorDataSource, stateManager); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void onPause() { |
||||||
|
super.onPause(); |
||||||
|
} |
||||||
|
|
||||||
|
public interface ICollectCacheCallback { |
||||||
|
void onFailure(); |
||||||
|
|
||||||
|
void onSuccess(boolean showSlopDistance, ICachedData cachedData, SurveyorData surveyorData, StateManagerPla stateManager); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void doSurveyor() { |
||||||
|
if (stateManager == null) { |
||||||
|
return; |
||||||
|
} |
||||||
|
stateManager.doSurveyor(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void autoSurvey() { |
||||||
|
if (stateManager == null) { |
||||||
|
return; |
||||||
|
} |
||||||
|
stateManager.doAutoSurveyor(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void switchCycle(int cycleIndex) { |
||||||
|
if (stateManager == null) { |
||||||
|
return; |
||||||
|
} |
||||||
|
stateManager.switch2Cycle(cycleIndex); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void deleteStationAllCycleRecord() { |
||||||
|
if (stateManager == null) { |
||||||
|
return; |
||||||
|
} |
||||||
|
stateManager.deleteCurrentStationSurveyorData(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void deleteStationOneCycleRecord(int cycleIndexNoUse) { |
||||||
|
if (stateManager == null) { |
||||||
|
return; |
||||||
|
} |
||||||
|
stateManager.deleteCurrentStationSurveyorData(cycleIndex); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String stationCheck() { |
||||||
|
if (stateManager == null) { |
||||||
|
return null; |
||||||
|
} |
||||||
|
stateManager.stationCheck(); |
||||||
|
|
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void stationAdjust() { |
||||||
|
StationUtilPla.checkStationCanAdjust(stationId(), getMeasureWhat(), isCanAdjust -> { |
||||||
|
if (!isCanAdjust) { |
||||||
|
ToastUtils.showShort("测站未通过检测"); |
||||||
|
return; |
||||||
|
} |
||||||
|
if (stateManager != null) { |
||||||
|
stateManager.stationAdjust(); |
||||||
|
} |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void goBack() { |
||||||
|
if (stateManager == null) { |
||||||
|
return; |
||||||
|
} |
||||||
|
stateManager.moveBack(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean isCurrentCycleComplete() { |
||||||
|
if (stateManager == null) |
||||||
|
return false; |
||||||
|
boolean completed = _IsSingleCycleCompletedState.isSingleCycleCompleted( |
||||||
|
stationId(), |
||||||
|
stateManager.getCurrentCycle(), |
||||||
|
stateManager.getCachedData()); |
||||||
|
return completed; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public int measureTypePosition() { |
||||||
|
return 0; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public int getMeasureWhat() { |
||||||
|
return StateConstantsPla.VALUE_MEASURE_WHAT_ANGLE_HOR; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void onResumeState() { |
||||||
|
if (stateManager != null) { |
||||||
|
stateManager.resume(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void onPauseState() { |
||||||
|
if (stateManager != null) { |
||||||
|
stateManager.quite(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void onShowSlopDistance(boolean value) { |
||||||
|
if (cachedData != null) { |
||||||
|
cachedData.onShowSlopDistance(value); |
||||||
|
} |
||||||
|
if (surveyedData != null) { |
||||||
|
surveyedData.onShowSlopDistance(value); |
||||||
|
} |
||||||
|
if (adapter != null) { |
||||||
|
adapter.onShowSlopDistance(value); |
||||||
|
adapter.notifyItemRangeChanged(0, adapter.getItemCount()); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean isSurveying() { |
||||||
|
if (surveyState != null) { |
||||||
|
return surveyState.isSurveying(); |
||||||
|
} |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean isAutoSurveying() { |
||||||
|
if (surveyState != null) { |
||||||
|
return surveyState.isAutoSurveying(); |
||||||
|
} |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
private static final String KEY_STATION_ID = "__station_id"; |
||||||
|
|
||||||
|
public static final String TAG = StationSurveyorSeparateHorAngleFragment.class.getName(); |
||||||
|
|
||||||
|
public static StationSurveyorSeparateHorAngleFragment newInstance(String stationId) { |
||||||
|
StationSurveyorSeparateHorAngleFragment fragment = new StationSurveyorSeparateHorAngleFragment(); |
||||||
|
Bundle bundle = new Bundle(); |
||||||
|
bundle.putString(KEY_STATION_ID, stationId); |
||||||
|
fragment.setArguments(bundle); |
||||||
|
return fragment; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
private void initCycleObserver(SurveyorStationRecord record) { |
||||||
|
if (cycleLiveData != null) { |
||||||
|
cycleLiveData.removeObservers(this); |
||||||
|
} |
||||||
|
cycleLiveData = getScheduleLiveData(getHorCycleKey()); |
||||||
|
cycleLiveData |
||||||
|
.observe(getViewLifecycleOwner(), surveyorScheduleRecord -> refreshCurrentCycleUi(record, surveyorScheduleRecord)); |
||||||
|
} |
||||||
|
|
||||||
|
private void selectCycleDialog() { |
||||||
|
if (cycleList == null || cycleList.isEmpty()) { |
||||||
|
return; |
||||||
|
} |
||||||
|
BottomSheetSelectListFragment.showSelect( |
||||||
|
getChildFragmentManager(), |
||||||
|
getViewLifecycleOwner(), |
||||||
|
cycleIndex, |
||||||
|
cycleList, |
||||||
|
null,//不再限制测期
|
||||||
|
(index, string) -> { |
||||||
|
switchCycle(index); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
private void refreshCurrentCycleUi(SurveyorStationRecord stationRecord, SurveyorScheduleRecord record) { |
||||||
|
//测回发生变化的时候,更新相应ui
|
||||||
|
int cycleIndex = DigitalUtil.string2Int(record == null ? "0" : record.getStatue(), 0); |
||||||
|
//更新测回名称
|
||||||
|
if (tvCycle != null) { |
||||||
|
boolean showLeftOrRight = true; |
||||||
|
if (stationRecord != null) { |
||||||
|
showLeftOrRight = stationRecord.leftAndRightSurveyor; |
||||||
|
} |
||||||
|
tvCycle.setText(SurveyorCycleUtil.cycleName(cycleIndex, showLeftOrRight)); |
||||||
|
} |
||||||
|
this.cycleIndex = cycleIndex; |
||||||
|
} |
||||||
|
|
||||||
|
protected LiveData<SurveyorScheduleRecord> getScheduleLiveData(String key) { |
||||||
|
return SurveyorDatabaseFactory |
||||||
|
.instance |
||||||
|
.getScheduleDataSource() |
||||||
|
.findSchedule(key); |
||||||
|
} |
||||||
|
|
||||||
|
private String getHorCycleKey() { |
||||||
|
return SurveyorScheduleConstants.stationCurrentCycleKey(stationId(), StateConstantsPla.VALUE_MEASURE_WHAT_ANGLE_HOR); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,469 @@ |
|||||||
|
package com.bingce.controlnetwork.fragment.stationsurvey.separate; |
||||||
|
|
||||||
|
import android.content.Context; |
||||||
|
import android.os.Bundle; |
||||||
|
import android.view.LayoutInflater; |
||||||
|
import android.view.View; |
||||||
|
import android.view.ViewGroup; |
||||||
|
import android.widget.TextView; |
||||||
|
|
||||||
|
import androidx.annotation.NonNull; |
||||||
|
import androidx.annotation.Nullable; |
||||||
|
import androidx.annotation.WorkerThread; |
||||||
|
import androidx.fragment.app.FragmentManager; |
||||||
|
import androidx.lifecycle.LifecycleOwner; |
||||||
|
import androidx.recyclerview.widget.RecyclerView; |
||||||
|
|
||||||
|
import com.bingce.controlapphelper.datasource.database.SurveyorDatabaseFactory; |
||||||
|
import com.bingce.controlapphelper.datasource.database.project.ProjectRecord; |
||||||
|
import com.bingce.controlapphelper.datasource.database.surveyorstation.SurveyorStationRecord; |
||||||
|
import com.bingce.controlapphelper.datasource.database.tolerance.detail.ToleranceDetailRecord; |
||||||
|
import com.bingce.controlapphelper.model.ViewItemType; |
||||||
|
import com.bingce.controlapphelper.util.IUIRunner; |
||||||
|
import com.bingce.controlnetwork.R; |
||||||
|
import com.bingce.controlnetwork.event.SurveyStateEvent; |
||||||
|
import com.bingce.controlnetwork.fragment.BottomSheetSelectListFragment; |
||||||
|
import com.bingce.controlnetwork.fragment.stationsurvey.IMeasureOperate; |
||||||
|
import com.bingce.controlnetwork.fragment.stationsurvey.base.BaseFragmentLazy; |
||||||
|
import com.bingce.controlnetwork.surveyor.data.CachedData; |
||||||
|
import com.bingce.controlnetwork.surveyor.data.CachedDataPointType; |
||||||
|
import com.bingce.controlnetwork.surveyor.data.ICachedData; |
||||||
|
import com.bingce.controlnetwork.surveyor.data.IDistanceTypeChangeListener; |
||||||
|
import com.bingce.controlnetwork.surveyor.data.ISurveyorData; |
||||||
|
import com.bingce.controlnetwork.surveyor.data.SurveyorData; |
||||||
|
import com.bingce.controlnetwork.surveyor.state.ISurveyState; |
||||||
|
import com.bingce.controlnetwork.surveyor.state.ISurveyorDataScrollDelegate; |
||||||
|
import com.bingce.controlnetwork.surveyor.state.StateConstantsPla; |
||||||
|
import com.bingce.controlnetwork.surveyor.state.separateVerAngle.StateManagerSeparateVerAngle; |
||||||
|
import com.bingce.utils.ThreadPoolUtil; |
||||||
|
|
||||||
|
import java.util.ArrayList; |
||||||
|
|
||||||
|
|
||||||
|
import com.bingce.controlnetwork.surveyor.state.separateVerAngle.VerAngleCheckTolerance; |
||||||
|
import com.bingce.controlnetwork.surveyor.state.separateVerAngle.VerAngleFindIndexUtil; |
||||||
|
|
||||||
|
/** |
||||||
|
* 分开观测-垂直角 |
||||||
|
*/ |
||||||
|
public class StationSurveyorSeparateVerAngleFragment extends BaseFragmentLazy |
||||||
|
implements IDistanceTypeChangeListener, ISurveyState, IMeasureOperate { |
||||||
|
private StationSurveyorSepatateAdapter adapter = null; |
||||||
|
private StateManagerSeparateVerAngle stateManager; |
||||||
|
private RecyclerView recyclerView; |
||||||
|
private ICachedData cachedData = null; |
||||||
|
private ISurveyorData surveyorData = null; |
||||||
|
private ISurveyState surveyState; |
||||||
|
|
||||||
|
private View llPoint; |
||||||
|
private TextView tvPoint; |
||||||
|
|
||||||
|
private String stationId() { |
||||||
|
if (getArguments() == null) { |
||||||
|
return null; |
||||||
|
} |
||||||
|
return getArguments().getString(KEY_STATION_ID); |
||||||
|
} |
||||||
|
|
||||||
|
@Nullable |
||||||
|
@Override |
||||||
|
public View onCreateView(@NonNull LayoutInflater inflater, |
||||||
|
@Nullable ViewGroup container, |
||||||
|
@Nullable Bundle savedInstanceState) { |
||||||
|
View view = inflater.inflate( |
||||||
|
R.layout.fragment_station_surveyor_separate_ver_angle, |
||||||
|
container, |
||||||
|
false); |
||||||
|
recyclerView = view.findViewById(R.id.recyclerView); |
||||||
|
llPoint = view.findViewById(R.id.llPoint); |
||||||
|
tvPoint = view.findViewById(R.id.tvPoint); |
||||||
|
|
||||||
|
llPoint.setOnClickListener(v -> selectSurveyorPoint()); |
||||||
|
|
||||||
|
return view; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected void onFragmentFirstVisible() { |
||||||
|
super.onFragmentFirstVisible(); |
||||||
|
firstLoadData(); |
||||||
|
} |
||||||
|
|
||||||
|
private void firstLoadData() { |
||||||
|
String stationId = stationId(); |
||||||
|
if (stationId != null) { |
||||||
|
//收集信息
|
||||||
|
collectData(stationId, |
||||||
|
getContext(), |
||||||
|
getChildFragmentManager(), |
||||||
|
getViewLifecycleOwner(), |
||||||
|
this::runOnUI, |
||||||
|
(cycleIndex, pointIndex) -> { |
||||||
|
if (cycleIndex >= 0 && adapter != null && cycleIndex < adapter.getItemCount()) { |
||||||
|
recyclerView.scrollToPosition(cycleIndex); |
||||||
|
} |
||||||
|
setTvPointText(); |
||||||
|
}, |
||||||
|
new ICollectCacheCallback() { |
||||||
|
@Override |
||||||
|
public void onFailure() { |
||||||
|
// TODO: 收集测站测量信息失败,提示
|
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void onSuccess(boolean showSlopDistance, ICachedData cachedData, SurveyorData surveyorData, StateManagerSeparateVerAngle stateManager) { |
||||||
|
onCollectStationData(showSlopDistance, cachedData, surveyorData, stateManager); |
||||||
|
surveyState = stateManager; |
||||||
|
} |
||||||
|
} |
||||||
|
); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
@WorkerThread |
||||||
|
private void onCollectStationData( |
||||||
|
boolean showSlopDistance, |
||||||
|
ICachedData cachedData, |
||||||
|
SurveyorData surveyorData, |
||||||
|
StateManagerSeparateVerAngle stateManager) { |
||||||
|
this.stateManager = stateManager; |
||||||
|
this.cachedData = cachedData; |
||||||
|
this.surveyorData = surveyorData; |
||||||
|
|
||||||
|
//测量数据收集完毕后,就可以更新UI了
|
||||||
|
runOnUI(() -> { |
||||||
|
if (getView() == null) { |
||||||
|
return; |
||||||
|
} |
||||||
|
//刷新UI
|
||||||
|
if (adapter == null) { |
||||||
|
adapter = new StationSurveyorSepatateAdapter(stateManager.getProjectType(), stationId(), |
||||||
|
cachedData, stateManager.getTolreanceRecord(), surveyorData, surveyorData, ViewItemType.sepatateVerAngle); |
||||||
|
adapter.onShowSlopDistance(showSlopDistance); |
||||||
|
if (recyclerView != null) { |
||||||
|
recyclerView.setAdapter(adapter); |
||||||
|
//滚动到当前目标点
|
||||||
|
int currentItemIndex = surveyorData.currentCycleIndex(); |
||||||
|
if (currentItemIndex >= 0 && currentItemIndex < adapter.getItemCount()) { |
||||||
|
recyclerView.scrollToPosition(currentItemIndex); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
//设置当前点
|
||||||
|
setTvPointText(); |
||||||
|
|
||||||
|
|
||||||
|
//监听测站数据
|
||||||
|
//监听「平距」「斜距」切换,更新UI显示
|
||||||
|
SurveyorDatabaseFactory |
||||||
|
.instance |
||||||
|
.getSurveyorStation() |
||||||
|
.getLiveDataRecord(stationId()) |
||||||
|
.observe(getViewLifecycleOwner(), |
||||||
|
surveyorStationRecord -> onShowSlopDistance(surveyorStationRecord.isShowSlopDistance())); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
private void setTvPointText() { |
||||||
|
SurveyorData data = (SurveyorData) surveyorData; |
||||||
|
tvPoint.setText(stringPoint(cachedData.pointName(0, data.currentIndex()))); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 收集测站信息 |
||||||
|
*/ |
||||||
|
private void collectData( |
||||||
|
String stationId, |
||||||
|
Context context, |
||||||
|
FragmentManager fragmentManager, |
||||||
|
LifecycleOwner lifecycleOwner, |
||||||
|
IUIRunner runner, |
||||||
|
ISurveyorDataScrollDelegate scrollDelegate, |
||||||
|
ICollectCacheCallback callback) { |
||||||
|
if (callback == null) { |
||||||
|
return; |
||||||
|
} |
||||||
|
ThreadPoolUtil.execute(() -> { |
||||||
|
//加载测站信息
|
||||||
|
SurveyorStationRecord surveyorStationRecord = |
||||||
|
SurveyorDatabaseFactory |
||||||
|
.instance |
||||||
|
.getSurveyorStation() |
||||||
|
.getRecordSync(stationId); |
||||||
|
//加载对应项目
|
||||||
|
ProjectRecord projectRecord = SurveyorDatabaseFactory |
||||||
|
.instance |
||||||
|
.getProjectDataSource() |
||||||
|
.getRecord(surveyorStationRecord.getProjectId()); |
||||||
|
if (projectRecord == null) { |
||||||
|
callback.onFailure(); |
||||||
|
return; |
||||||
|
} |
||||||
|
//加载对应限差
|
||||||
|
ToleranceDetailRecord toleranceRecord = SurveyorDatabaseFactory |
||||||
|
.instance |
||||||
|
.getToleranceDetailDataSource() |
||||||
|
.getRecordSync(projectRecord.getToleranceId()); |
||||||
|
if (toleranceRecord == null) { |
||||||
|
callback.onFailure(); |
||||||
|
return; |
||||||
|
} |
||||||
|
//创建缓存数据
|
||||||
|
CachedData cachedData = |
||||||
|
CachedData.newInstance(StateConstantsPla.VALUE_MEASURE_WHAT_ANGLE_VER, CachedDataPointType.ALONE_MEASURE_VER_ANGLE_POINT, surveyorStationRecord.isAutoClose(), |
||||||
|
surveyorStationRecord.isLeftAndRightSurveyor(), |
||||||
|
stationId, toleranceRecord); |
||||||
|
if (cachedData == null) { |
||||||
|
callback.onFailure(); |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
//是否显示斜距?
|
||||||
|
cachedData.onShowSlopDistance(surveyorStationRecord.isShowSlopDistance()); |
||||||
|
if (cachedData.pointCount() <= 0) { |
||||||
|
setViewVisiableByCacheDataCount(false); |
||||||
|
callback.onFailure(); |
||||||
|
return; |
||||||
|
} |
||||||
|
setViewVisiableByCacheDataCount(true); |
||||||
|
|
||||||
|
// TODO: 2024/8/30 toleranceRecord.getCycleCount()
|
||||||
|
VerAngleFindIndexUtil.VerFindTarget verFindTarget = VerAngleFindIndexUtil.findFront(stationId, cachedData, |
||||||
|
0, toleranceRecord.getCycleCount()); |
||||||
|
|
||||||
|
refreshBtnEnable(verFindTarget.getCycleIndex() != -1); |
||||||
|
|
||||||
|
//创建stateManager实例
|
||||||
|
SurveyorData surveyorDataSource = new SurveyorData(toleranceRecord.getSurveyorCount()); |
||||||
|
surveyorDataSource.onShowSlopDistance(surveyorStationRecord.isShowSlopDistance()); |
||||||
|
surveyorDataSource.setCurrentIndex(verFindTarget.getPointIndex()); |
||||||
|
surveyorDataSource.changeCycleIndex(verFindTarget.getCycleIndex()); |
||||||
|
surveyorDataSource.setLeftOrRight(verFindTarget.getLeftOrRight()); |
||||||
|
|
||||||
|
StateManagerSeparateVerAngle stateManager = StateManagerSeparateVerAngle.newInstance( |
||||||
|
StateConstantsPla.VALUE_MEASURE_WHAT_ANGLE_VER, |
||||||
|
surveyorStationRecord, |
||||||
|
context, |
||||||
|
fragmentManager, |
||||||
|
lifecycleOwner, |
||||||
|
toleranceRecord, |
||||||
|
cachedData, |
||||||
|
surveyorDataSource, |
||||||
|
surveyorDataSource, |
||||||
|
cachedData, |
||||||
|
scrollDelegate, |
||||||
|
runner); |
||||||
|
|
||||||
|
callback.onSuccess(surveyorStationRecord.isShowSlopDistance(), cachedData, surveyorDataSource, stateManager); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
private void setViewVisiableByCacheDataCount(boolean visiable) { |
||||||
|
runOnUI(() -> { |
||||||
|
llPoint.setVisibility(visiable ? View.VISIBLE : View.GONE); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 刷新按钮状态 |
||||||
|
* |
||||||
|
* @param enable |
||||||
|
*/ |
||||||
|
private void refreshBtnEnable(boolean enable) { |
||||||
|
if (enable) { |
||||||
|
SurveyStateEvent.postIdle(); |
||||||
|
} else { |
||||||
|
SurveyStateEvent.postCompleted(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void onPause() { |
||||||
|
super.onPause(); |
||||||
|
} |
||||||
|
|
||||||
|
public interface ICollectCacheCallback { |
||||||
|
void onFailure(); |
||||||
|
|
||||||
|
void onSuccess(boolean showSlopDistance, ICachedData cachedData, SurveyorData surveyorData, StateManagerSeparateVerAngle stateManager); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void doSurveyor() { |
||||||
|
if (stateManager == null) { |
||||||
|
return; |
||||||
|
} |
||||||
|
stateManager.doSurveyor(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void autoSurvey() { |
||||||
|
if (stateManager == null) { |
||||||
|
return; |
||||||
|
} |
||||||
|
// stateManager.doAutoSurveyor();
|
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void switchCycle(int cycleIndex) { |
||||||
|
//暂无使用
|
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void deleteStationAllCycleRecord() { |
||||||
|
if (stateManager == null) { |
||||||
|
return; |
||||||
|
} |
||||||
|
stateManager.deletePointAllCycleData(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void deleteStationOneCycleRecord(int cycleIndex) { |
||||||
|
if (stateManager == null) { |
||||||
|
return; |
||||||
|
} |
||||||
|
stateManager.deleteCurrentCycleData(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String stationCheck() { |
||||||
|
//暂无使用
|
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void stationAdjust() { |
||||||
|
if (stateManager != null) { |
||||||
|
stateManager.stationAdjust(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void goBack() { |
||||||
|
if (stateManager == null) { |
||||||
|
return; |
||||||
|
} |
||||||
|
stateManager.startRollBack(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean isCurrentCycleComplete() { |
||||||
|
String stationId = stationId(); |
||||||
|
if (stationId == null || stateManager == null) { |
||||||
|
return true; |
||||||
|
} |
||||||
|
return VerAngleCheckTolerance.isAllPointMeasured(stationId, cachedData, stateManager.getCycleCount()); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public int measureTypePosition() { |
||||||
|
return 0; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public int getMeasureWhat() { |
||||||
|
return StateConstantsPla.VALUE_MEASURE_WHAT_ANGLE_VER; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void onResumeState() { |
||||||
|
if (stateManager != null) { |
||||||
|
stateManager.resume(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void onPauseState() { |
||||||
|
if (stateManager != null) { |
||||||
|
stateManager.quite(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void onShowSlopDistance(boolean value) { |
||||||
|
if (cachedData != null) { |
||||||
|
cachedData.onShowSlopDistance(value); |
||||||
|
} |
||||||
|
if (surveyorData != null) { |
||||||
|
surveyorData.onShowSlopDistance(value); |
||||||
|
} |
||||||
|
if (adapter != null) { |
||||||
|
adapter.onShowSlopDistance(value); |
||||||
|
adapter.notifyItemRangeChanged(0, adapter.getItemCount()); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean isSurveying() { |
||||||
|
if (surveyState != null) { |
||||||
|
return surveyState.isSurveying(); |
||||||
|
} |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean isAutoSurveying() { |
||||||
|
if (surveyState != null) { |
||||||
|
return surveyState.isAutoSurveying(); |
||||||
|
} |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
private static final String KEY_STATION_ID = "__station_id"; |
||||||
|
|
||||||
|
public static final String TAG = StationSurveyorSeparateVerAngleFragment.class.getName(); |
||||||
|
|
||||||
|
public static StationSurveyorSeparateVerAngleFragment newInstance(String stationId) { |
||||||
|
StationSurveyorSeparateVerAngleFragment fragment = new StationSurveyorSeparateVerAngleFragment(); |
||||||
|
Bundle bundle = new Bundle(); |
||||||
|
bundle.putString(KEY_STATION_ID, stationId); |
||||||
|
fragment.setArguments(bundle); |
||||||
|
return fragment; |
||||||
|
} |
||||||
|
|
||||||
|
private void selectSurveyorPoint() { |
||||||
|
if (stateManager == null) { |
||||||
|
return; |
||||||
|
} |
||||||
|
if (surveyorData == null) { |
||||||
|
return; |
||||||
|
} |
||||||
|
if (cachedData == null || cachedData.pointCount() == 0) { |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
int currentCycle = stateManager.getCurrentCycle(); |
||||||
|
|
||||||
|
ArrayList<String> showPointList = new ArrayList<>(); |
||||||
|
for (int i = 0; i < cachedData.realPointCount(); i++) { |
||||||
|
showPointList.add(cachedData.pointName(currentCycle, i)); |
||||||
|
} |
||||||
|
|
||||||
|
BottomSheetSelectListFragment.showSelect( |
||||||
|
getChildFragmentManager(), |
||||||
|
getViewLifecycleOwner(), |
||||||
|
surveyorData.currentIndex(), |
||||||
|
showPointList, |
||||||
|
null,//不再限制测期
|
||||||
|
(index, string) -> { |
||||||
|
//切换测点
|
||||||
|
VerAngleFindIndexUtil.VerFindTarget target = VerAngleFindIndexUtil.getTargetByPointIndexFront(stateManager.stationId(), cachedData, |
||||||
|
index, stateManager.getTolreanceRecord().cycleCount); // TODO: 2024/8/30 getTolreanceRecord().cycleCount
|
||||||
|
stateManager.setSurveyorData(target, true); |
||||||
|
//刷新ui
|
||||||
|
setTvPointText(); |
||||||
|
cachedData.notifyDateChange(); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
private String stringPoint(String name) { |
||||||
|
return String.format("测点:%s", name); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,129 @@ |
|||||||
|
package com.bingce.controlnetwork.fragment.stationsurvey.separate; |
||||||
|
|
||||||
|
import android.view.ViewGroup; |
||||||
|
|
||||||
|
import androidx.annotation.NonNull; |
||||||
|
import androidx.recyclerview.widget.RecyclerView; |
||||||
|
|
||||||
|
import com.bingce.controlapphelper.datasource.database.tolerance.detail.ToleranceDetailRecord; |
||||||
|
import com.bingce.controlapphelper.model.IAdapter; |
||||||
|
import com.bingce.controlapphelper.model.ViewItemType; |
||||||
|
import com.bingce.controlnetwork.surveyor.data.ICachedData; |
||||||
|
import com.bingce.controlnetwork.surveyor.data.ICycleRecorder; |
||||||
|
import com.bingce.controlnetwork.surveyor.data.IDistanceTypeChangeListener; |
||||||
|
import com.bingce.controlnetwork.surveyor.data.ISurveyorData; |
||||||
|
import com.bingce.controlnetwork.ui.vh.AbstractSurveyorDataViewHolder; |
||||||
|
import com.bingce.controlnetwork.ui.vh.SurveyorDataWellDistanceViewHolder; |
||||||
|
import com.bingce.controlnetwork.ui.widget.ViewFactory; |
||||||
|
|
||||||
|
import java.util.Objects; |
||||||
|
|
||||||
|
/** |
||||||
|
* 测量记录adapter |
||||||
|
* 分开观测 水平角,垂直角,距离共用 |
||||||
|
*/ |
||||||
|
public class StationSurveyorSepatateAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> |
||||||
|
implements IAdapter, IDistanceTypeChangeListener { |
||||||
|
|
||||||
|
private ICachedData cachedData; |
||||||
|
private final ISurveyorData surveyorData; |
||||||
|
private final ICycleRecorder cycleRecorder; |
||||||
|
private boolean showSlopDistance = true; |
||||||
|
private final String projectType; |
||||||
|
private final String stationId; |
||||||
|
private final ViewItemType layoutType;//区分水平还是距离
|
||||||
|
private final ToleranceDetailRecord toleranceRecord;//区分水平还是距离
|
||||||
|
|
||||||
|
|
||||||
|
public StationSurveyorSepatateAdapter( |
||||||
|
String projectType, |
||||||
|
String stationId, |
||||||
|
ICachedData cachedData, |
||||||
|
ToleranceDetailRecord toleranceRecord, |
||||||
|
ICycleRecorder cycleRecorder, |
||||||
|
ISurveyorData surveyorData, |
||||||
|
ViewItemType layoutType) { |
||||||
|
this.projectType = projectType; |
||||||
|
this.stationId = stationId; |
||||||
|
this.cachedData = cachedData; |
||||||
|
this.toleranceRecord = toleranceRecord; |
||||||
|
this.surveyorData = surveyorData; |
||||||
|
this.cycleRecorder = cycleRecorder; |
||||||
|
this.layoutType = layoutType; |
||||||
|
//注册数据监听
|
||||||
|
cachedData.register(this); |
||||||
|
} |
||||||
|
|
||||||
|
public void setCachedData(ICachedData cachedData) { |
||||||
|
this.cachedData.unregister(this); |
||||||
|
this.cachedData = cachedData; |
||||||
|
//注册数据监听
|
||||||
|
cachedData.register(this); |
||||||
|
} |
||||||
|
|
||||||
|
@NonNull |
||||||
|
@Override |
||||||
|
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { |
||||||
|
return Objects.requireNonNull(ViewFactory.generatorViewHolder(parent.getContext(), parent, layoutType)); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { |
||||||
|
if (holder instanceof SurveyorDataWellDistanceViewHolder) { |
||||||
|
SurveyorDataWellDistanceViewHolder holderDistance = (SurveyorDataWellDistanceViewHolder) holder; |
||||||
|
holderDistance.setup(position, |
||||||
|
projectType, |
||||||
|
stationId, |
||||||
|
showSlopDistance, |
||||||
|
cachedData, |
||||||
|
cycleRecorder, |
||||||
|
surveyorData); |
||||||
|
} else if (holder instanceof AbstractSurveyorDataViewHolder) { |
||||||
|
AbstractSurveyorDataViewHolder abstractSurveyorDataViewHolder = (AbstractSurveyorDataViewHolder) holder; |
||||||
|
abstractSurveyorDataViewHolder.setup(position, |
||||||
|
stationId, |
||||||
|
showSlopDistance, |
||||||
|
cachedData, |
||||||
|
cycleRecorder, |
||||||
|
surveyorData); |
||||||
|
} |
||||||
|
|
||||||
|
holder.itemView.setOnClickListener(v -> { |
||||||
|
if (iItemClickListener != null) { |
||||||
|
iItemClickListener.click(position); |
||||||
|
} |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public int getItemCount() { |
||||||
|
if (layoutType == ViewItemType.aloneDistanceMeasure) { |
||||||
|
return cachedData.realPointCount(); |
||||||
|
} else if (layoutType == ViewItemType.sepatateVerAngle) { |
||||||
|
return toleranceRecord.cycleCount;// TODO: 2024/8/30
|
||||||
|
} else { |
||||||
|
return cachedData.pointCount(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void onDataChange() { |
||||||
|
notifyDataSetChanged(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void onShowSlopDistance(boolean value) { |
||||||
|
this.showSlopDistance = value; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
private IItemClickListener iItemClickListener; |
||||||
|
|
||||||
|
public void setOnItemClickListener(IItemClickListener iItemClickListener) { |
||||||
|
this.iItemClickListener = iItemClickListener; |
||||||
|
} |
||||||
|
|
||||||
|
public interface IItemClickListener { |
||||||
|
void click(int position); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,500 @@ |
|||||||
|
package com.bingce.controlnetwork.fragment.stationsurvey.well; |
||||||
|
|
||||||
|
import android.content.Context; |
||||||
|
import android.os.Bundle; |
||||||
|
import android.view.LayoutInflater; |
||||||
|
import android.view.View; |
||||||
|
import android.view.ViewGroup; |
||||||
|
|
||||||
|
import androidx.annotation.NonNull; |
||||||
|
import androidx.annotation.Nullable; |
||||||
|
import androidx.annotation.WorkerThread; |
||||||
|
import androidx.fragment.app.FragmentManager; |
||||||
|
import androidx.lifecycle.LifecycleOwner; |
||||||
|
import androidx.recyclerview.widget.RecyclerView; |
||||||
|
|
||||||
|
import com.bingce.controlapphelper.datasource.database.ProjectTypeValue; |
||||||
|
import com.bingce.controlapphelper.datasource.database.SurveyorDatabaseFactory; |
||||||
|
import com.bingce.controlapphelper.datasource.database.project.ProjectRecord; |
||||||
|
import com.bingce.controlapphelper.datasource.database.schedule.SurveyorScheduleRecord; |
||||||
|
import com.bingce.controlapphelper.datasource.database.surveyorstation.SurveyorStationRecord; |
||||||
|
import com.bingce.controlapphelper.datasource.database.tolerance.detail.ToleranceDetailRecord; |
||||||
|
import com.bingce.controlapphelper.util.DigitalUtil; |
||||||
|
import com.bingce.controlapphelper.util.IUIRunner; |
||||||
|
import com.bingce.controlapphelper.util.Tools; |
||||||
|
import com.bingce.controlnetwork.R; |
||||||
|
import com.bingce.controlnetwork.adapter.SurveyorStationRecordsWellAdapter; |
||||||
|
import com.bingce.controlnetwork.bean.SurveyorScheduleConstants; |
||||||
|
import com.bingce.controlnetwork.fragment.TipsWith2OptionFragment; |
||||||
|
import com.bingce.controlnetwork.fragment.stationsurvey.IMeasureOperate; |
||||||
|
import com.bingce.controlnetwork.fragment.stationsurvey.base.BaseFragmentLazy; |
||||||
|
import com.bingce.controlnetwork.surveyor.data.CachedData; |
||||||
|
import com.bingce.controlnetwork.surveyor.data.CachedDataPointType; |
||||||
|
import com.bingce.controlnetwork.surveyor.data.ICachedData; |
||||||
|
import com.bingce.controlnetwork.surveyor.data.IDistanceTypeChangeListener; |
||||||
|
import com.bingce.controlnetwork.surveyor.data.ISurveyorData; |
||||||
|
import com.bingce.controlnetwork.surveyor.data.SurveyorData; |
||||||
|
import com.bingce.controlnetwork.surveyor.state.ISurveyState; |
||||||
|
import com.bingce.controlnetwork.surveyor.state.ISurveyorDataScrollDelegate; |
||||||
|
import com.bingce.controlnetwork.surveyor.state.StateConstantsPla; |
||||||
|
import com.bingce.controlnetwork.surveyor.state.wellDistance.StateManagerWell; |
||||||
|
import com.bingce.controlnetwork.surveyor.state.wellDistance._CheckToleranceState; |
||||||
|
import com.bingce.utils.ThreadPoolUtil; |
||||||
|
|
||||||
|
import blankj.utilcode.util.ToastUtils; |
||||||
|
import com.bingce.controlnetwork.surveyor.state.wellDistance.IWeatherShowDialogListener; |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* 井定向钢丝测距或者单独测距 |
||||||
|
*/ |
||||||
|
public class StationSurveyorWellDistanceDataFragment extends BaseFragmentLazy |
||||||
|
implements IDistanceTypeChangeListener, ISurveyState, IMeasureOperate { |
||||||
|
|
||||||
|
private SurveyorStationRecordsWellAdapter adapter = null; |
||||||
|
private StateManagerWell stateManager; //这里的stateManager是克隆StateManager
|
||||||
|
private RecyclerView recyclerView; |
||||||
|
private ICachedData cachedData = null; |
||||||
|
private ISurveyorData surveyedData = null; |
||||||
|
private ISurveyState surveyState; |
||||||
|
|
||||||
|
private final IWeatherShowDialogListener weatherShowDialogListener = (stationId, currentCycleIndex, pointId, beforeOrAfter, msg) -> { |
||||||
|
if (getView() == null) return; |
||||||
|
TipsWith2OptionFragment |
||||||
|
.tips( |
||||||
|
getChildFragmentManager(), |
||||||
|
getViewLifecycleOwner(), |
||||||
|
Tools.getString(R.string.confirm), |
||||||
|
Tools.getString(R.string.cancel), |
||||||
|
msg, |
||||||
|
new TipsWith2OptionFragment.SimpleCallback() { |
||||||
|
@Override |
||||||
|
public void onConfirm() { |
||||||
|
// DistanceWeatherSettingTjActivity.launch(requireContext(), stationId, currentCycleIndex, pointId, beforeOrAfter);
|
||||||
|
} |
||||||
|
} |
||||||
|
); |
||||||
|
}; |
||||||
|
|
||||||
|
|
||||||
|
private String stationId() { |
||||||
|
if (getArguments() == null) { |
||||||
|
return null; |
||||||
|
} |
||||||
|
return getArguments().getString(KEY_STATION_ID); |
||||||
|
} |
||||||
|
|
||||||
|
private String getWellType() { |
||||||
|
if (getArguments() != null) { |
||||||
|
return getArguments().getString(KEY_WELL_TYPE); |
||||||
|
} |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
@Nullable |
||||||
|
@Override |
||||||
|
public View onCreateView(@NonNull LayoutInflater inflater, |
||||||
|
@Nullable ViewGroup container, |
||||||
|
@Nullable Bundle savedInstanceState) { |
||||||
|
View view = inflater.inflate( |
||||||
|
R.layout.fragment_project_surveyor_station_point_list_layout, |
||||||
|
container, |
||||||
|
false); |
||||||
|
recyclerView = view.findViewById(R.id.recycler_view); |
||||||
|
|
||||||
|
String stationId = stationId(); |
||||||
|
if (stationId != null) { |
||||||
|
//收集信息
|
||||||
|
collectData(stationId, |
||||||
|
getContext(), |
||||||
|
getChildFragmentManager(), |
||||||
|
getViewLifecycleOwner(), |
||||||
|
this::runOnUI, |
||||||
|
this::scrollToPosition, |
||||||
|
new ICollectCacheCallback() { |
||||||
|
@Override |
||||||
|
public void onFailure() { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void onSuccess(boolean showSlopDistance, ICachedData cachedData, SurveyorData surveyorData, StateManagerWell stateManager) { |
||||||
|
onCollectStationData(showSlopDistance, cachedData, surveyorData, stateManager); |
||||||
|
surveyState = stateManager; |
||||||
|
} |
||||||
|
} |
||||||
|
); |
||||||
|
} |
||||||
|
|
||||||
|
return view; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean getUserVisibleHint() { |
||||||
|
return super.getUserVisibleHint(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { |
||||||
|
super.onViewCreated(view, savedInstanceState); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
@WorkerThread |
||||||
|
private void onCollectStationData( |
||||||
|
boolean showSlopDistance, |
||||||
|
ICachedData cachedData, |
||||||
|
SurveyorData surveyorData, |
||||||
|
StateManagerWell stateManager) { |
||||||
|
|
||||||
|
this.stateManager = stateManager; |
||||||
|
this.cachedData = cachedData; |
||||||
|
this.surveyedData = surveyorData; |
||||||
|
|
||||||
|
//更新完棱镜类型刷新页面
|
||||||
|
// stateManager.setRefreshFragmentUiListener(() -> changeCacheDataAndRefreshUi(stationId()));
|
||||||
|
|
||||||
|
//测量数据收集完毕后,就可以更新UI了
|
||||||
|
runOnUI(() -> { |
||||||
|
if (getView() == null) { |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
//刷新UI
|
||||||
|
if (adapter == null) { |
||||||
|
adapter = new SurveyorStationRecordsWellAdapter(stateManager.getProjectType(), stationId(), |
||||||
|
cachedData, surveyorData, surveyorData, getWellType()); |
||||||
|
adapter.onShowSlopDistance(showSlopDistance); |
||||||
|
if (recyclerView != null) { |
||||||
|
recyclerView.setAdapter(adapter); |
||||||
|
//滚动到当前目标点
|
||||||
|
int currentItemIndex = surveyorData.currentIndex(); |
||||||
|
scrollToPosition(0, currentItemIndex); |
||||||
|
} |
||||||
|
|
||||||
|
adapter.setOnItemClickListener(position -> { |
||||||
|
if (isSurveying()) { |
||||||
|
ToastUtils.showShort("正在测量中,请稍后..."); |
||||||
|
return; |
||||||
|
} |
||||||
|
stateManager.setCurrentIndex(position); |
||||||
|
stateManager.setCurrentCycleIndex(0); |
||||||
|
stateManager.refeshRollBackBtn(); |
||||||
|
|
||||||
|
scrollToPosition(0, position); |
||||||
|
}); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
//监听测站数据,更新界面「平距」「斜距」显示
|
||||||
|
SurveyorDatabaseFactory |
||||||
|
.instance |
||||||
|
.getSurveyorStation() |
||||||
|
.getLiveDataRecord(stationId()) |
||||||
|
.observe(getViewLifecycleOwner(), |
||||||
|
surveyorStationRecord -> onShowSlopDistance(surveyorStationRecord.isShowSlopDistance())); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
private void scrollToPosition(int cycleIndex, int position) { |
||||||
|
if (position >= 0 && adapter != null && position < adapter.getItemCount()) { |
||||||
|
runOnUI(() -> { |
||||||
|
recyclerView.scrollToPosition(position); |
||||||
|
adapter.notifyDataSetChanged(); |
||||||
|
}); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 收集测站信息 |
||||||
|
*/ |
||||||
|
private void collectData( |
||||||
|
String stationId, |
||||||
|
Context context, |
||||||
|
FragmentManager fragmentManager, |
||||||
|
LifecycleOwner lifecycleOwner, |
||||||
|
IUIRunner runner, |
||||||
|
ISurveyorDataScrollDelegate scrollDelegate, |
||||||
|
ICollectCacheCallback callback) { |
||||||
|
if (callback == null) { |
||||||
|
return; |
||||||
|
} |
||||||
|
ThreadPoolUtil.execute(() -> { |
||||||
|
//读取当前测站的当前测回--很重要
|
||||||
|
SurveyorScheduleRecord scheduleRecord = |
||||||
|
SurveyorDatabaseFactory |
||||||
|
.instance |
||||||
|
.getScheduleDataSource() |
||||||
|
.findScheduleSync(SurveyorScheduleConstants.stationCurrentCycleKey(stationId, StateConstantsPla.VALUE_MEASURE_WHAT_DISTANCE)); |
||||||
|
int defaultCycle = scheduleRecord == null ? 0 : |
||||||
|
DigitalUtil.string2Int(scheduleRecord.getStatue(), 0); |
||||||
|
//加载测站信息
|
||||||
|
SurveyorStationRecord surveyorStationRecord = |
||||||
|
SurveyorDatabaseFactory |
||||||
|
.instance |
||||||
|
.getSurveyorStation() |
||||||
|
.getRecordSync(stationId); |
||||||
|
//加载对应项目
|
||||||
|
ProjectRecord projectRecord = SurveyorDatabaseFactory |
||||||
|
.instance |
||||||
|
.getProjectDataSource() |
||||||
|
.getRecord(surveyorStationRecord.getProjectId()); |
||||||
|
if (projectRecord == null) { |
||||||
|
callback.onFailure(); |
||||||
|
return; |
||||||
|
} |
||||||
|
//加载对应限差
|
||||||
|
ToleranceDetailRecord toleranceRecord = SurveyorDatabaseFactory |
||||||
|
.instance |
||||||
|
.getToleranceDetailDataSource() |
||||||
|
.getRecordSync(projectRecord.getToleranceId()); |
||||||
|
if (toleranceRecord == null) { |
||||||
|
callback.onFailure(); |
||||||
|
return; |
||||||
|
} |
||||||
|
//创建缓存数据
|
||||||
|
CachedDataPointType cachedDataPointType = CachedDataPointType.ALONE_MEASURE_DISTANCE_POINT; |
||||||
|
if (isConnection(surveyorStationRecord.projectType)) { |
||||||
|
cachedDataPointType = CachedDataPointType.STEEL_POINT; |
||||||
|
} |
||||||
|
CachedData cachedData = CachedData.newInstance(StateConstantsPla.VALUE_MEASURE_WHAT_DEFAULT, cachedDataPointType, surveyorStationRecord.isAutoClose(), |
||||||
|
surveyorStationRecord.isLeftAndRightSurveyor(), |
||||||
|
stationId, toleranceRecord); |
||||||
|
if (cachedData == null) { |
||||||
|
callback.onFailure(); |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
//是否显示斜距?
|
||||||
|
cachedData.onShowSlopDistance(surveyorStationRecord.isShowSlopDistance()); |
||||||
|
|
||||||
|
//创建stateManager实例
|
||||||
|
SurveyorData surveyorDataSource = new SurveyorData(ToleranceDetailRecord.ALONE_DISTANCE_MEASURE_COUNT); |
||||||
|
surveyorDataSource.onShowSlopDistance(surveyorStationRecord.isShowSlopDistance()); |
||||||
|
|
||||||
|
StateManagerWell stateManager = StateManagerWell.newInstance( |
||||||
|
surveyorStationRecord, |
||||||
|
context, |
||||||
|
fragmentManager, |
||||||
|
lifecycleOwner, |
||||||
|
toleranceRecord, |
||||||
|
cachedData, |
||||||
|
surveyorDataSource, |
||||||
|
surveyorDataSource, |
||||||
|
cachedData, |
||||||
|
scrollDelegate, |
||||||
|
runner, |
||||||
|
weatherShowDialogListener |
||||||
|
); |
||||||
|
|
||||||
|
callback.onSuccess(surveyorStationRecord.isShowSlopDistance(), cachedData, surveyorDataSource, stateManager); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 改变cacheData并刷新Ui |
||||||
|
*/ |
||||||
|
private void changeCacheDataAndRefreshUi(String stationId) { |
||||||
|
ThreadPoolUtil.execute(() -> { |
||||||
|
//加载测站信息
|
||||||
|
SurveyorStationRecord surveyorStationRecord = |
||||||
|
SurveyorDatabaseFactory |
||||||
|
.instance |
||||||
|
.getSurveyorStation() |
||||||
|
.getRecordSync(stationId); |
||||||
|
//加载对应项目
|
||||||
|
ProjectRecord projectRecord = SurveyorDatabaseFactory |
||||||
|
.instance |
||||||
|
.getProjectDataSource() |
||||||
|
.getRecord(surveyorStationRecord.getProjectId()); |
||||||
|
if (projectRecord == null) { |
||||||
|
return; |
||||||
|
} |
||||||
|
//加载对应限差
|
||||||
|
ToleranceDetailRecord toleranceRecord = SurveyorDatabaseFactory |
||||||
|
.instance |
||||||
|
.getToleranceDetailDataSource() |
||||||
|
.getRecordSync(projectRecord.getToleranceId()); |
||||||
|
if (toleranceRecord == null) { |
||||||
|
return; |
||||||
|
} |
||||||
|
//创建缓存数据
|
||||||
|
CachedDataPointType cachedDataPointType = CachedDataPointType.ALONE_MEASURE_DISTANCE_POINT; |
||||||
|
if (isConnection(surveyorStationRecord.projectType)) { |
||||||
|
cachedDataPointType = CachedDataPointType.STEEL_POINT; |
||||||
|
} |
||||||
|
CachedData cachedData = CachedData.newInstance(StateConstantsPla.VALUE_MEASURE_WHAT_DEFAULT, cachedDataPointType, surveyorStationRecord.isAutoClose(), |
||||||
|
surveyorStationRecord.isLeftAndRightSurveyor(), |
||||||
|
stationId, toleranceRecord); |
||||||
|
if (cachedData != null) { |
||||||
|
//是否显示斜距?
|
||||||
|
cachedData.onShowSlopDistance(surveyorStationRecord.isShowSlopDistance()); |
||||||
|
// stateManager.setCachedData(cachedData);
|
||||||
|
adapter.setCachedData(cachedData); |
||||||
|
runOnUI(() -> adapter.notifyDataSetChanged()); |
||||||
|
} |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
public interface ICollectCacheCallback { |
||||||
|
void onFailure(); |
||||||
|
|
||||||
|
void onSuccess(boolean showSlopDistance, ICachedData cachedData, SurveyorData surveyorData, StateManagerWell stateManager); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void doSurveyor() { |
||||||
|
if (stateManager == null) { |
||||||
|
return; |
||||||
|
} |
||||||
|
stateManager.doSurveyor(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void autoSurvey() { |
||||||
|
|
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void switchCycle(int cycleIndex) { |
||||||
|
if (stateManager == null) { |
||||||
|
return; |
||||||
|
} |
||||||
|
stateManager.switch2Cycle(cycleIndex); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void deleteStationAllCycleRecord() { |
||||||
|
if (stateManager == null) { |
||||||
|
return; |
||||||
|
} |
||||||
|
stateManager.deletePointAllCycleData(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void deleteStationOneCycleRecord(int cycleIndex) { |
||||||
|
if (stateManager == null) { |
||||||
|
return; |
||||||
|
} |
||||||
|
stateManager.deletePointCurrentCycleData(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String stationCheck() { |
||||||
|
if (stateManager == null) { |
||||||
|
return null; |
||||||
|
} |
||||||
|
stateManager.stationCheck(); |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void stationAdjust() { |
||||||
|
if (stateManager != null) { |
||||||
|
stateManager.stationAdjust(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void goBack() { |
||||||
|
if (stateManager == null) { |
||||||
|
return; |
||||||
|
} |
||||||
|
stateManager.moveBack(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void onShowSlopDistance(boolean value) { |
||||||
|
if (cachedData != null) { |
||||||
|
cachedData.onShowSlopDistance(value); |
||||||
|
} |
||||||
|
if (surveyedData != null) { |
||||||
|
surveyedData.onShowSlopDistance(value); |
||||||
|
} |
||||||
|
if (adapter != null) { |
||||||
|
adapter.onShowSlopDistance(value); |
||||||
|
adapter.notifyItemRangeChanged(0, adapter.getItemCount()); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean isSurveying() { |
||||||
|
if (surveyState != null) { |
||||||
|
return surveyState.isSurveying(); |
||||||
|
} |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean isAutoSurveying() { |
||||||
|
if (surveyState != null) { |
||||||
|
return surveyState.isAutoSurveying(); |
||||||
|
} |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
private static final String KEY_STATION_ID = "__station_id"; |
||||||
|
private static final String KEY_WELL_TYPE = "__well_type"; |
||||||
|
public static final String TAG = StationSurveyorWellDistanceDataFragment.class.getName(); |
||||||
|
|
||||||
|
public static StationSurveyorWellDistanceDataFragment newInstance(String stationId, String wellType) { |
||||||
|
StationSurveyorWellDistanceDataFragment fragment = new StationSurveyorWellDistanceDataFragment(); |
||||||
|
Bundle bundle = new Bundle(); |
||||||
|
bundle.putString(KEY_STATION_ID, stationId); |
||||||
|
bundle.putString(KEY_WELL_TYPE, wellType); |
||||||
|
fragment.setArguments(bundle); |
||||||
|
return fragment; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean isCurrentCycleComplete() { |
||||||
|
if (stateManager == null) |
||||||
|
return false; |
||||||
|
return _CheckToleranceState.isCompleteAllPointForAloneDistance(stationId(), 0, stateManager.getCachedData()); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public int measureTypePosition() { |
||||||
|
return 0; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public int getMeasureWhat() { |
||||||
|
return StateConstantsPla.VALUE_MEASURE_WHAT_DISTANCE; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void onResumeState() { |
||||||
|
if (stateManager != null) { |
||||||
|
stateManager.resume(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void onPauseState() { |
||||||
|
if (stateManager != null) { |
||||||
|
stateManager.quite(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected void onFragmentFirstVisible() { |
||||||
|
if (stateManager != null) |
||||||
|
stateManager.calScheduleWhenEnterSurveyFragment(); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 是否联系测量 |
||||||
|
* |
||||||
|
* @param projectType 项目类型 |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
private boolean isConnection(String projectType) { |
||||||
|
return ProjectTypeValue.CONNECTION.equals(projectType); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,457 @@ |
|||||||
|
package com.bingce.controlnetwork.fragment.stationsurvey.well; |
||||||
|
|
||||||
|
|
||||||
|
import android.content.Context; |
||||||
|
import android.graphics.Color; |
||||||
|
import android.os.Bundle; |
||||||
|
import android.view.LayoutInflater; |
||||||
|
import android.view.MenuItem; |
||||||
|
import android.view.View; |
||||||
|
import android.view.ViewGroup; |
||||||
|
import android.view.WindowManager; |
||||||
|
import android.widget.Button; |
||||||
|
import android.widget.TextView; |
||||||
|
|
||||||
|
import androidx.annotation.NonNull; |
||||||
|
import androidx.annotation.Nullable; |
||||||
|
import androidx.annotation.WorkerThread; |
||||||
|
import androidx.fragment.app.Fragment; |
||||||
|
import androidx.fragment.app.FragmentActivity; |
||||||
|
import androidx.fragment.app.FragmentManager; |
||||||
|
import androidx.fragment.app.FragmentPagerAdapter; |
||||||
|
import androidx.viewpager.widget.ViewPager; |
||||||
|
|
||||||
|
import com.bingce.controlapphelper.datasource.database.SurveyorDatabaseFactory; |
||||||
|
import com.bingce.controlapphelper.datasource.database.project.ProjectRecord; |
||||||
|
import com.bingce.controlapphelper.datasource.database.surveyorstation.SurveyorStationRecord; |
||||||
|
import com.bingce.controlapphelper.datasource.database.tolerance.detail.ToleranceDetailRecord; |
||||||
|
import com.bingce.controlapphelper.model.BundleConstants; |
||||||
|
import com.bingce.controlapphelper.util.DigitalUtil; |
||||||
|
import com.bingce.controlapphelper.util.SurveyorCycleUtil; |
||||||
|
import com.bingce.controlnetwork.R; |
||||||
|
import com.bingce.controlnetwork.activity.fragmentcontainer.FragmentContainerActivity; |
||||||
|
import com.bingce.controlnetwork.adapter.SurveyorStationRecordsWellAdapter; |
||||||
|
import com.bingce.controlnetwork.bean.SurveyorScheduleConstants; |
||||||
|
import com.bingce.controlnetwork.event.RefreshRollBackEvent; |
||||||
|
import com.bingce.controlnetwork.event.SurveyStateEvent; |
||||||
|
import com.bingce.controlnetwork.fragment.BottomSheetSelectListFragment; |
||||||
|
import com.bingce.controlnetwork.fragment.base.BaseFragment; |
||||||
|
import com.bingce.controlnetwork.fragment.stationsurvey.IMeasureOperate; |
||||||
|
import com.bingce.controlnetwork.newui.stationsetting.StationSettingsActivity; |
||||||
|
import com.bingce.controlnetwork.newui.stationsurveyor.ISurveyorMenuOperate; |
||||||
|
import com.bingce.controlnetwork.newui.stationsurveyor.StationSurveyorHomeActivity; |
||||||
|
import com.bingce.controlnetwork.surveyor.state.StateConstantsPla; |
||||||
|
import com.bingce.controlnetwork.surveyor.surveyor.TestDataSelectFragment; |
||||||
|
import com.bingce.controlnetwork.util.StationSettingCheckUtil; |
||||||
|
import com.bingce.controlnetwork.util.StationUtilPla; |
||||||
|
import com.bingce.utils.ThreadPoolUtil; |
||||||
|
import com.flyco.tablayout.SlidingTabLayout; |
||||||
|
import com.github.razir.progressbutton.DrawableButtonExtensionsKt; |
||||||
|
import com.github.razir.progressbutton.ProgressButtonHolderKt; |
||||||
|
|
||||||
|
import org.greenrobot.eventbus.EventBus; |
||||||
|
import org.greenrobot.eventbus.Subscribe; |
||||||
|
import org.greenrobot.eventbus.ThreadMode; |
||||||
|
|
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* 测站测量页面(开始测量) |
||||||
|
*/ |
||||||
|
public class StationSurveyorWellFragment extends BaseFragment implements ISurveyorMenuOperate { |
||||||
|
public static final String TAG = StationSurveyorWellFragment.class.getName(); |
||||||
|
|
||||||
|
private MenuItem menuItemRollBack; |
||||||
|
|
||||||
|
private SurveyorStationRecord surveyorStationRecord; |
||||||
|
private int cycleIndex = 0; |
||||||
|
|
||||||
|
//方位观测fragment的在adapter的索引
|
||||||
|
public static final int POSITION_DIRECTION_MEASURE = 0; |
||||||
|
public static final int POSITION_DISTANCE_MEASURE = 1; |
||||||
|
private final String[] tabs = { |
||||||
|
"方位观测", "单独测距" |
||||||
|
}; |
||||||
|
|
||||||
|
private List<IMeasureOperate> fragments; |
||||||
|
private IMeasureOperate currentFragment; |
||||||
|
|
||||||
|
private ViewPager vp; |
||||||
|
|
||||||
|
private final StationSettingCheckUtil stationSettingCheckUtil = new StationSettingCheckUtil(); |
||||||
|
|
||||||
|
|
||||||
|
@Subscribe(threadMode = ThreadMode.MAIN) |
||||||
|
public void onRefreshGoBack(RefreshRollBackEvent event) { |
||||||
|
if (vp != null) { |
||||||
|
int currentItem = vp.getCurrentItem(); |
||||||
|
if (currentItem == POSITION_DIRECTION_MEASURE) { |
||||||
|
setRollBackEnable(event.validate); |
||||||
|
} else if (currentItem == POSITION_DISTANCE_MEASURE) { |
||||||
|
setRollBackEnable(event.validate); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private void setRollBackEnable(boolean validate) { |
||||||
|
FragmentActivity activity = getActivity(); |
||||||
|
if (activity != null) { |
||||||
|
StationSurveyorHomeActivity homeActivity = (StationSurveyorHomeActivity) activity; |
||||||
|
homeActivity.setRollBackEnable(validate); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Subscribe(threadMode = ThreadMode.MAIN) |
||||||
|
public void onSurveyorStateChanged(SurveyStateEvent event) { |
||||||
|
if (getView() == null) { |
||||||
|
return; |
||||||
|
} |
||||||
|
Button surveyorButton = getView().findViewById(R.id.surveyor); |
||||||
|
if (surveyorButton == null) { |
||||||
|
return; |
||||||
|
} |
||||||
|
if (event.isIdle() || event.isSuccess() || event.isCompleted()) { |
||||||
|
DrawableButtonExtensionsKt.hideProgress(surveyorButton, R.string.start_surveyor); |
||||||
|
} else if (event.isSurveying()) { |
||||||
|
DrawableButtonExtensionsKt.showProgress(surveyorButton, progressParams -> { |
||||||
|
progressParams.setButtonTextRes(R.string.tips_surveying); |
||||||
|
progressParams.setProgressColor(Color.WHITE); |
||||||
|
return null; |
||||||
|
}); |
||||||
|
} else if (event.isFailure()) { |
||||||
|
DrawableButtonExtensionsKt.hideProgress(surveyorButton, R.string.tips_surveyor_failure_and_retry); |
||||||
|
} |
||||||
|
|
||||||
|
boolean enable = event.isIdle() || event.isFailure() || event.isSuccess(); |
||||||
|
|
||||||
|
setSurveyorEnable(getView(), R.id.surveyor, enable); |
||||||
|
} |
||||||
|
|
||||||
|
private String stationId() { |
||||||
|
if (getArguments() == null) { |
||||||
|
return null; |
||||||
|
} |
||||||
|
return getArguments().getString(BundleConstants.KEY_SURVEYOR_STATION_ID); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void onStart() { |
||||||
|
super.onStart(); |
||||||
|
EventBus.getDefault().register(this); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void onStop() { |
||||||
|
super.onStop(); |
||||||
|
EventBus.getDefault().unregister(this); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void onResume() { |
||||||
|
super.onResume(); |
||||||
|
//测量界面保持常亮
|
||||||
|
if (getActivity() != null) { |
||||||
|
getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); |
||||||
|
} |
||||||
|
if (currentFragment != null) { |
||||||
|
currentFragment.onResumeState(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void onPause() { |
||||||
|
super.onPause(); |
||||||
|
//清除界面常亮
|
||||||
|
if (getActivity() != null) { |
||||||
|
getActivity().getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); |
||||||
|
} |
||||||
|
if (currentFragment != null) { |
||||||
|
currentFragment.onPauseState(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Nullable |
||||||
|
@Override |
||||||
|
public View onCreateView(@NonNull LayoutInflater inflater, |
||||||
|
@Nullable ViewGroup container, |
||||||
|
@Nullable Bundle savedInstanceState) { |
||||||
|
View view = inflater.inflate(R.layout.fragment_project_surveyor_station_detail_layout_well, |
||||||
|
container, |
||||||
|
false); |
||||||
|
|
||||||
|
//2.设置测量按钮
|
||||||
|
Button surveyor = view.findViewById(R.id.surveyor); |
||||||
|
if (surveyor != null) { |
||||||
|
ProgressButtonHolderKt.bindProgressButton(getViewLifecycleOwner(), surveyor); |
||||||
|
} |
||||||
|
setSurveyorClick(view, R.id.surveyor, this::startSurveyor); |
||||||
|
|
||||||
|
//3.查询测站信息
|
||||||
|
ThreadPoolUtil.execute(() -> { |
||||||
|
surveyorStationRecord = SurveyorDatabaseFactory |
||||||
|
.instance |
||||||
|
.getSurveyorStation() |
||||||
|
.getRecordSync(stationId()); |
||||||
|
//监听当前测回切换
|
||||||
|
monitorCurrentCycle(view); |
||||||
|
//监听数据变化
|
||||||
|
ToleranceDetailRecord toleranceRecord = getTolerance(surveyorStationRecord); |
||||||
|
if (toleranceRecord == null) { |
||||||
|
return; |
||||||
|
} |
||||||
|
//注册UI监听
|
||||||
|
View pick = view.findViewById(R.id.cycleLayout); |
||||||
|
if (pick == null) { |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
int cycleCount = StationUtilPla.getCycleCount(StateConstantsPla.VALUE_MEASURE_WHAT_DISTANCE, surveyorStationRecord, toleranceRecord); |
||||||
|
|
||||||
|
pick.setOnClickListener(v -> { |
||||||
|
//测回的点击事件
|
||||||
|
|
||||||
|
ArrayList<String> cycleList = SurveyorCycleUtil.cycleStrings(cycleCount, |
||||||
|
surveyorStationRecord != null && surveyorStationRecord.leftAndRightSurveyor); |
||||||
|
|
||||||
|
TextView circleText = view.findViewById(R.id.circle_text); |
||||||
|
runOnUI(() -> BottomSheetSelectListFragment.showSelect( |
||||||
|
getChildFragmentManager(), |
||||||
|
getViewLifecycleOwner(), |
||||||
|
cycleIndex, |
||||||
|
cycleList, |
||||||
|
null,//不再限制测期
|
||||||
|
(index, string) -> { |
||||||
|
if (circleText != null) { |
||||||
|
circleText.setText(string); |
||||||
|
} |
||||||
|
cycleIndex = index; |
||||||
|
if (currentFragment != null) { |
||||||
|
//检测当前测回是否完成
|
||||||
|
currentFragment.switchCycle(cycleIndex); |
||||||
|
} |
||||||
|
})); |
||||||
|
}); |
||||||
|
}); |
||||||
|
|
||||||
|
setHasOptionsMenu(true); |
||||||
|
|
||||||
|
return view; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { |
||||||
|
super.onViewCreated(view, savedInstanceState); |
||||||
|
initViewPager(view); |
||||||
|
} |
||||||
|
|
||||||
|
private void initViewPager(View view) { |
||||||
|
fragments = new ArrayList<>(); |
||||||
|
StationSurveyorWellLevelAngleDataFragment fragmentAngle = StationSurveyorWellLevelAngleDataFragment.newInstance(stationId(), SurveyorStationRecordsWellAdapter.TYPE_HORIZONTAL_ANGLE); |
||||||
|
fragments.add(fragmentAngle); |
||||||
|
StationSurveyorWellDistanceDataFragment fragmentDistance = StationSurveyorWellDistanceDataFragment.newInstance(stationId(), SurveyorStationRecordsWellAdapter.TYPE_DISTANCE); |
||||||
|
fragments.add(fragmentDistance); |
||||||
|
|
||||||
|
SlidingTabLayout tabLayout = view.findViewById(R.id.tabLayout); |
||||||
|
vp = view.findViewById(R.id.vp); |
||||||
|
vp.setAdapter(new MyPagerAdapter(getChildFragmentManager())); |
||||||
|
tabLayout.setViewPager(vp); |
||||||
|
|
||||||
|
vp.setCurrentItem(POSITION_DIRECTION_MEASURE); |
||||||
|
currentFragment = fragments.get(POSITION_DIRECTION_MEASURE); |
||||||
|
|
||||||
|
vp.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { |
||||||
|
@Override |
||||||
|
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void onPageSelected(int position) { |
||||||
|
currentFragment = fragments.get(position); |
||||||
|
View pick = view.findViewById(R.id.cycleLayout); |
||||||
|
//钢丝测距不显示选择测回
|
||||||
|
pick.setVisibility(position == POSITION_DIRECTION_MEASURE ? View.VISIBLE : View.GONE); |
||||||
|
//刷新按钮状态
|
||||||
|
boolean currentCycleComplete = currentFragment.isCurrentCycleComplete(); |
||||||
|
if (currentCycleComplete) { |
||||||
|
SurveyStateEvent.postCompleted(); |
||||||
|
} else { |
||||||
|
SurveyStateEvent.postIdle(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void onPageScrollStateChanged(int state) { |
||||||
|
|
||||||
|
} |
||||||
|
}); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
@WorkerThread |
||||||
|
private void monitorCurrentCycle(View view) { |
||||||
|
if (getActivity() != null) { |
||||||
|
getActivity().runOnUiThread(() -> SurveyorDatabaseFactory |
||||||
|
.instance |
||||||
|
.getScheduleDataSource() |
||||||
|
.findSchedule(getScheduleId()) |
||||||
|
.observe(getViewLifecycleOwner(), record -> { |
||||||
|
TextView circleText = view.findViewById(R.id.circle_text); |
||||||
|
//测回发生变化的时候,更新相应ui
|
||||||
|
int cycleIndex = DigitalUtil.string2Int(record == null ? "0" : record.getStatue(), 0); |
||||||
|
//更新测回名称
|
||||||
|
if (circleText != null) { |
||||||
|
boolean showLeftOrRight = true; |
||||||
|
if (surveyorStationRecord != null) { |
||||||
|
showLeftOrRight = surveyorStationRecord.leftAndRightSurveyor; |
||||||
|
} |
||||||
|
circleText.setText(SurveyorCycleUtil.cycleName(cycleIndex, showLeftOrRight)); |
||||||
|
} |
||||||
|
StationSurveyorWellFragment.this.cycleIndex = cycleIndex; |
||||||
|
})); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private String getScheduleId() { |
||||||
|
int currentItem = vp.getCurrentItem(); |
||||||
|
String scheduleId; |
||||||
|
if (currentItem == POSITION_DIRECTION_MEASURE) { |
||||||
|
scheduleId = SurveyorScheduleConstants.stationCurrentCycleKey(stationId(), StateConstantsPla.VALUE_MEASURE_WHAT_DEFAULT); |
||||||
|
} else { |
||||||
|
scheduleId = SurveyorScheduleConstants.stationCurrentCycleKey(stationId(), StateConstantsPla.VALUE_MEASURE_WHAT_DISTANCE); |
||||||
|
} |
||||||
|
return scheduleId; |
||||||
|
} |
||||||
|
|
||||||
|
private static void setSurveyorClick(View rootView, int id, Runnable runnable) { |
||||||
|
View view = rootView.findViewById(id); |
||||||
|
if (view != null) { |
||||||
|
view.setOnClickListener(v -> runnable.run()); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private static void setSurveyorEnable(View rootView, int id, boolean enable) { |
||||||
|
if (rootView == null) { |
||||||
|
return; |
||||||
|
} |
||||||
|
View view = rootView.findViewById(id); |
||||||
|
if (view != null) { |
||||||
|
view.setEnabled(enable); |
||||||
|
if (enable) { |
||||||
|
view.setAlpha(1); |
||||||
|
} else { |
||||||
|
view.setAlpha(.4f); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@WorkerThread |
||||||
|
private static ToleranceDetailRecord getTolerance(SurveyorStationRecord surveyorStationRecord) { |
||||||
|
if (surveyorStationRecord == null) { |
||||||
|
return null; |
||||||
|
} |
||||||
|
//获取project信息
|
||||||
|
ProjectRecord projectRecord = SurveyorDatabaseFactory |
||||||
|
.instance |
||||||
|
.getProjectDataSource() |
||||||
|
.getRecord(surveyorStationRecord.getProjectId()); |
||||||
|
if (projectRecord == null) { |
||||||
|
return null; |
||||||
|
} |
||||||
|
//获取限差数据
|
||||||
|
return SurveyorDatabaseFactory |
||||||
|
.instance |
||||||
|
.getToleranceDetailDataSource() |
||||||
|
.getRecordSync(projectRecord.getToleranceId()); |
||||||
|
} |
||||||
|
|
||||||
|
public static void start(Context context, String surveyorStationId, String surveyorStationName) { |
||||||
|
Bundle bundle = new Bundle(); |
||||||
|
bundle.putString(BundleConstants.KEY_SURVEYOR_STATION_ID, surveyorStationId); |
||||||
|
FragmentContainerActivity.start(context, TAG, surveyorStationName, bundle); |
||||||
|
} |
||||||
|
|
||||||
|
public static Fragment newInstance(Bundle args) { |
||||||
|
Fragment fragment = new StationSurveyorWellFragment(); |
||||||
|
fragment.setArguments(args); |
||||||
|
return fragment; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void deleteCurrentPeriodRecords() { |
||||||
|
//删除当前测回记录
|
||||||
|
if (surveyorStationRecord != null && currentFragment != null) { |
||||||
|
//通知fragment
|
||||||
|
currentFragment.deleteStationOneCycleRecord(cycleIndex); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void deleteAllPeriodRecords() { |
||||||
|
//删除所有测回记录
|
||||||
|
if (surveyorStationRecord != null && currentFragment != null) { |
||||||
|
//通知fragment
|
||||||
|
currentFragment.deleteStationAllCycleRecord(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void test() { |
||||||
|
//数据源 debug使用
|
||||||
|
TestDataSelectFragment.show(getChildFragmentManager()); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void rollBack() { |
||||||
|
//回退
|
||||||
|
currentFragment.goBack(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void stationSetting() { |
||||||
|
//环境、棱镜设置
|
||||||
|
StationSettingsActivity.start(requireContext(), stationId()); |
||||||
|
// StationSettingsFragment.start(getContext(), stationId());
|
||||||
|
} |
||||||
|
//SurveyorSettingsFragment 测量设置
|
||||||
|
|
||||||
|
@Override |
||||||
|
public void adjust() { |
||||||
|
//测站平差,平差检测
|
||||||
|
if (currentFragment != null) { |
||||||
|
currentFragment.stationAdjust(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void startSurveyor() { |
||||||
|
stationSettingCheckUtil.checkStationSettings(stationId(), this, this, () -> { |
||||||
|
if (currentFragment != null) { |
||||||
|
currentFragment.doSurveyor(); |
||||||
|
} |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
private class MyPagerAdapter extends FragmentPagerAdapter { |
||||||
|
public MyPagerAdapter(FragmentManager fm) { |
||||||
|
super(fm); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public int getCount() { |
||||||
|
return fragments.size(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public CharSequence getPageTitle(int position) { |
||||||
|
return tabs[position]; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public Fragment getItem(int position) { |
||||||
|
return (Fragment) fragments.get(position); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -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; |
||||||
|
} |
||||||
|
} |
@ -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) |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
File diff suppressed because it is too large
Load Diff
@ -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; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,646 @@ |
|||||||
|
package com.bingce.controlnetwork.surveyor.method; |
||||||
|
|
||||||
|
|
||||||
|
import android.os.Parcel; |
||||||
|
import android.os.Parcelable; |
||||||
|
import android.text.TextUtils; |
||||||
|
|
||||||
|
import androidx.annotation.WorkerThread; |
||||||
|
|
||||||
|
import com.bingce.controlapphelper.datasource.database.SurveyorDatabaseFactory; |
||||||
|
import com.bingce.controlapphelper.datasource.database.alonedistance.AloneDistanceRecord; |
||||||
|
import com.bingce.controlapphelper.datasource.database.alonedistance.IAloneDistanceRecordDataSource; |
||||||
|
import com.bingce.controlapphelper.datasource.database.alonedistance.WellDistance; |
||||||
|
import com.bingce.controlapphelper.datasource.database.point.PointRecord; |
||||||
|
import com.bingce.controlapphelper.datasource.database.project.IProjectDataSource; |
||||||
|
import com.bingce.controlapphelper.datasource.database.project.ProjectRecord; |
||||||
|
import com.bingce.controlapphelper.datasource.database.surveyorstation.SurveyorStationRecord; |
||||||
|
import com.bingce.controlapphelper.datasource.database.surveyorstation.model.SurveyorPoint; |
||||||
|
import com.bingce.controlapphelper.datasource.database.tolerance.detail.IToleranceDetailDataSource; |
||||||
|
import com.bingce.controlapphelper.datasource.database.tolerance.detail.ToleranceDetailRecord; |
||||||
|
import com.bingce.controlapphelper.model.LeftOrRight; |
||||||
|
import com.bingce.controlapphelper.surveyor.method.RadianMethod; |
||||||
|
import com.bingce.controlapphelper.surveyor.method.model.SdAngleValueType; |
||||||
|
import com.bingce.controlapphelper.util.Tools; |
||||||
|
import com.bingce.controlnetwork.model.AloneAdjustItem; |
||||||
|
import com.bingce.controlnetwork.surveyor.data.FaultTolerantData; |
||||||
|
import com.bingce.controlnetwork.surveyor.data.ICachedData; |
||||||
|
import com.bingce.controlnetwork.surveyor.method.model.CacheResult; |
||||||
|
import com.bingce.controlnetwork.surveyor.state.StateConstantsPla; |
||||||
|
import com.bingce.controlnetwork.surveyor.state.base.CheckToleranceUtil; |
||||||
|
import com.bingce.controlnetwork.util.IdUtil; |
||||||
|
import com.bingce.controlnetwork.util.StationUtilPla; |
||||||
|
import com.bingce.utils.Util; |
||||||
|
|
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.HashMap; |
||||||
|
import java.util.List; |
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
import blankj.utilcode.util.ToastUtils; |
||||||
|
|
||||||
|
public class SurveyorAdjustMethodPla { |
||||||
|
private final static int ERROR_CODE_LEFT_RIGHT_COUNT_NOT_EQUAL = 1; |
||||||
|
private final static int ERROR_CODE_ZERO_VALUE_COUNT_NOT_EQUAL = ERROR_CODE_LEFT_RIGHT_COUNT_NOT_EQUAL + 1; |
||||||
|
|
||||||
|
@WorkerThread |
||||||
|
public static AdjustResult calStationAdjust(SurveyorStationRecord stationRecord, ICachedData cachedData) { |
||||||
|
return calStationAdjust(StateConstantsPla.VALUE_MEASURE_WHAT_DEFAULT, stationRecord, cachedData); |
||||||
|
} |
||||||
|
|
||||||
|
@WorkerThread |
||||||
|
public static AdjustResult calStationAdjust(int measureWhat, SurveyorStationRecord stationRecord, ICachedData cachedData) { |
||||||
|
if (stationRecord == null) { |
||||||
|
return new AdjustResult("测站数据为空"); |
||||||
|
} |
||||||
|
//2.读取项目数据
|
||||||
|
IProjectDataSource projectDataSource = |
||||||
|
SurveyorDatabaseFactory.instance.getProjectDataSource(); |
||||||
|
ProjectRecord projectRecord = projectDataSource.getRecord(stationRecord.projectId); |
||||||
|
if (projectRecord == null) { |
||||||
|
return new AdjustResult("项目数据为空"); |
||||||
|
} |
||||||
|
//3.读取限差数据
|
||||||
|
IToleranceDetailDataSource toleranceDetailDataSource = |
||||||
|
SurveyorDatabaseFactory.instance.getToleranceDetailDataSource(); |
||||||
|
ToleranceDetailRecord toleranceDetailRecordTj = |
||||||
|
toleranceDetailDataSource.getRecordSync(projectRecord.getToleranceId()); |
||||||
|
if (toleranceDetailRecordTj == null) { |
||||||
|
return new AdjustResult("限差参数为空"); |
||||||
|
} |
||||||
|
//4.测量次数,测回数
|
||||||
|
int surveyorCount = toleranceDetailRecordTj.getSurveyorCount(); |
||||||
|
int cycleCount = StationUtilPla.getCycleCount(measureWhat, stationRecord, toleranceDetailRecordTj); |
||||||
|
boolean leftRightSurveyor = stationRecord.isLeftAndRightSurveyor();//左右角测量
|
||||||
|
//5.如果是左右角测量,判断是否超限
|
||||||
|
if (CheckToleranceUtil.checkAngleHor(measureWhat) |
||||||
|
&& leftRightSurveyor) { |
||||||
|
//获取单测回归零值
|
||||||
|
int leftCycleCount = 0;//左角测量时测回个数
|
||||||
|
List<Double> leftZeroes = new ArrayList<>();//左角归零值
|
||||||
|
int rightCycleCount = 0;//右角测量时测回个数
|
||||||
|
List<Double> rightZeroes = new ArrayList<>();//右角归零值
|
||||||
|
for (int cycleIndex = 0; cycleIndex < cycleCount; cycleIndex++) { |
||||||
|
List<DeviationValueOfRadianMethod.AngleDistValue> values = |
||||||
|
DeviationValueOfRadianMethod.zeroValueOfSingleCycle(measureWhat, stationRecord.getId(), cycleIndex, surveyorCount, cachedData); |
||||||
|
if (cycleIndex % 2 == 0) {//左角归零
|
||||||
|
leftCycleCount++; |
||||||
|
if (leftZeroes.isEmpty()) { |
||||||
|
for (DeviationValueOfRadianMethod.AngleDistValue value : values) { |
||||||
|
leftZeroes.add(value.horRadian); |
||||||
|
} |
||||||
|
} else { |
||||||
|
for (int index = 0; index < values.size(); index++) { |
||||||
|
if (index >= leftZeroes.size()) { |
||||||
|
continue; |
||||||
|
} |
||||||
|
leftZeroes.set(index, leftZeroes.get(index) + values.get(index).horRadian); |
||||||
|
} |
||||||
|
} |
||||||
|
} else {//右角归零
|
||||||
|
rightCycleCount++; |
||||||
|
if (rightZeroes.isEmpty()) { |
||||||
|
for (DeviationValueOfRadianMethod.AngleDistValue value : values) { |
||||||
|
rightZeroes.add(value.horRadian); |
||||||
|
} |
||||||
|
} else { |
||||||
|
for (int index = 0; index < values.size(); index++) { |
||||||
|
if (index >= rightZeroes.size()) { |
||||||
|
continue; |
||||||
|
} |
||||||
|
rightZeroes.set(index, rightZeroes.get(index) + values.get(index).horRadian); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
//求左右角归零平均值
|
||||||
|
for (int index = 0; index < leftZeroes.size(); index++) { |
||||||
|
leftZeroes.set(index, leftZeroes.get(index) / leftCycleCount); |
||||||
|
} |
||||||
|
for (int index = 0; index < rightZeroes.size(); index++) { |
||||||
|
rightZeroes.set(index, rightZeroes.get(index) / rightCycleCount); |
||||||
|
} |
||||||
|
|
||||||
|
if (leftZeroes.size() != rightZeroes.size()) { |
||||||
|
//左右角归零值个数不一样,计算错误
|
||||||
|
return new AdjustResult("计算错误(错误码" + ERROR_CODE_LEFT_RIGHT_COUNT_NOT_EQUAL + ")"); |
||||||
|
} |
||||||
|
//检测左右角之和是否超限
|
||||||
|
final double TOP = Util.dmsDoubleToRadian(0.0004); |
||||||
|
final double BOTTOM = 2 * Math.PI - TOP; |
||||||
|
for (int index = 0; index < leftZeroes.size(); index++) { |
||||||
|
double leftAngle = leftZeroes.get(index); |
||||||
|
double rightAngle = rightZeroes.get(index); |
||||||
|
double resultAngle = RadianMethod.formatRadian(leftAngle + rightAngle); |
||||||
|
if (resultAngle < BOTTOM && resultAngle > TOP) { |
||||||
|
return new AdjustResult("左右角之和超限!"); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
//6.左右角之和通过检测,则转为左角计算整体归零值
|
||||||
|
List<_VD> vds = new ArrayList<>(); |
||||||
|
Map<Integer, List<Double>> cycle2Zeroes = new HashMap<>(); |
||||||
|
for (int cycleIndex = 0; cycleIndex < cycleCount; cycleIndex++) { |
||||||
|
List<DeviationValueOfRadianMethod.AngleDistValue> values = |
||||||
|
DeviationValueOfRadianMethod.zeroValueOfSingleCycleInLeftOrientation( |
||||||
|
measureWhat, stationRecord.getId(), cycleIndex, surveyorCount, cachedData); |
||||||
|
|
||||||
|
List<Double> horZeroes = new ArrayList<>(); |
||||||
|
for (DeviationValueOfRadianMethod.AngleDistValue value : values) { |
||||||
|
horZeroes.add(value.horRadian); |
||||||
|
} |
||||||
|
cycle2Zeroes.put(cycleIndex, horZeroes); |
||||||
|
|
||||||
|
if (vds.isEmpty()) { |
||||||
|
for (DeviationValueOfRadianMethod.AngleDistValue v : values) { |
||||||
|
vds.add(new _VD(v.pointId, v.pointName, v.verRadian, v.distance, v.prismHeight, v.aloneDistance, v.isMeasureDistanceNot, v.isMeasureVerNot)); |
||||||
|
} |
||||||
|
} else { |
||||||
|
for (int index = 0; index < values.size(); index++) { |
||||||
|
if (vds.size() <= index) { |
||||||
|
return new AdjustResult("计算错误(错误码" + ERROR_CODE_ZERO_VALUE_COUNT_NOT_EQUAL + ")"); |
||||||
|
} |
||||||
|
_VD hvd = vds.get(index); |
||||||
|
DeviationValueOfRadianMethod.AngleDistValue angleDistValue = values.get(index); |
||||||
|
// hvd.hor = DeviationValueOfRadianMethod.similarAverage(hvd.hor, angleDistValue.horRadian);
|
||||||
|
|
||||||
|
if (angleDistValue.verRadian != FaultTolerantData.ERROR_VER_ANGLE) { |
||||||
|
hvd.ver += angleDistValue.verRadian; |
||||||
|
} else { |
||||||
|
hvd.ver = FaultTolerantData.ERROR_VER_ANGLE; |
||||||
|
} |
||||||
|
|
||||||
|
hvd.distance += angleDistValue.distance; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
//水平角的归零值要特殊处理
|
||||||
|
//先计算结点数量,取最小值
|
||||||
|
int minPointSize = Integer.MAX_VALUE; |
||||||
|
for (Map.Entry<Integer, List<Double>> entry : cycle2Zeroes.entrySet()) { |
||||||
|
minPointSize = Math.min(minPointSize, entry.getValue() == null ? 0 : entry.getValue().size()); |
||||||
|
} |
||||||
|
|
||||||
|
List<Double> zeros = new ArrayList<>(); |
||||||
|
if (minPointSize > 0) { |
||||||
|
for (int pointIndex = 0; pointIndex < minPointSize; pointIndex++) { |
||||||
|
List<Double> doubles = new ArrayList<>(); |
||||||
|
for (int cycleIndex = 0; cycleIndex < cycleCount; cycleIndex++) { |
||||||
|
List<Double> zeroList = cycle2Zeroes.get(cycleIndex); |
||||||
|
if (zeroList == null) { |
||||||
|
break; |
||||||
|
} |
||||||
|
if (zeroList.size() <= pointIndex) { |
||||||
|
break; |
||||||
|
} |
||||||
|
doubles.add(zeroList.get(pointIndex)); |
||||||
|
} |
||||||
|
|
||||||
|
//计算平均值
|
||||||
|
double average = DeviationValueOfRadianMethod.similarAverage(doubles); |
||||||
|
|
||||||
|
zeros.add(average); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
//7.求归零平均值
|
||||||
|
ArrayList<Item> result = new ArrayList<>(); |
||||||
|
for (int pointIndex = 0; pointIndex < vds.size(); pointIndex++) { |
||||||
|
_VD hvd = vds.get(pointIndex); |
||||||
|
Item item = new Item( |
||||||
|
hvd.pointId, |
||||||
|
hvd.pointName, |
||||||
|
zeros.size() <= pointIndex ? 0 : zeros.get(pointIndex), |
||||||
|
getFinalAdjustVerAngle(hvd.ver, cycleCount), |
||||||
|
// getFinalAdjustDistance(stationRecord.getAdditionConstantActual(), stationRecord.getMultiplyingConstantActual(), hvd.distance / cycleCount),
|
||||||
|
hvd.distance / cycleCount, |
||||||
|
hvd.prismHeight, hvd.aloneDistance, hvd.isMeasureDistanceNot, hvd.isMeasureVerNot); |
||||||
|
result.add(item); |
||||||
|
} |
||||||
|
|
||||||
|
return new AdjustResult(result); |
||||||
|
} |
||||||
|
|
||||||
|
private static double getFinalAdjustVerAngle(double hdvVer, int cycleCount) { |
||||||
|
if (hdvVer == FaultTolerantData.ERROR_VER_ANGLE) { |
||||||
|
return hdvVer; |
||||||
|
} |
||||||
|
return Math.PI / 2 - hdvVer / cycleCount; |
||||||
|
} |
||||||
|
|
||||||
|
private static double getFinalAdjustDistance(double a, double b, double distance) { |
||||||
|
return Tools.getAmendDistance(a, b, 0, distance); |
||||||
|
} |
||||||
|
|
||||||
|
public static class AdjustResult { |
||||||
|
public ArrayList<Item> result; |
||||||
|
public String errorString; |
||||||
|
|
||||||
|
public AdjustResult() { |
||||||
|
} |
||||||
|
|
||||||
|
public AdjustResult(ArrayList<Item> result) { |
||||||
|
this.result = result; |
||||||
|
errorString = ""; |
||||||
|
} |
||||||
|
|
||||||
|
public AdjustResult(String errorString) { |
||||||
|
this.result = null; |
||||||
|
this.errorString = errorString; |
||||||
|
} |
||||||
|
|
||||||
|
public void setErrorString(String errorString) { |
||||||
|
this.errorString = errorString; |
||||||
|
} |
||||||
|
|
||||||
|
public void setResult(ArrayList<Item> result) { |
||||||
|
this.result = result; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 临时变量,保存 水平、垂直、和距离 |
||||||
|
*/ |
||||||
|
private static class _VD { |
||||||
|
final String pointId; |
||||||
|
final String pointName; |
||||||
|
double ver; |
||||||
|
double distance; |
||||||
|
String prismHeight; |
||||||
|
boolean aloneDistance; |
||||||
|
boolean isMeasureDistanceNot; |
||||||
|
boolean isMeasureVerNot; |
||||||
|
|
||||||
|
|
||||||
|
_VD(String pointId, String pointName, double v, double d, String prismHeight, |
||||||
|
boolean aloneDistance, boolean isMeasureDistanceNot, boolean isMeasureVerNot) { |
||||||
|
this.pointId = pointId; |
||||||
|
this.pointName = pointName; |
||||||
|
this.ver = v; |
||||||
|
this.distance = d; |
||||||
|
this.prismHeight = prismHeight; |
||||||
|
this.aloneDistance = aloneDistance; |
||||||
|
this.isMeasureDistanceNot = isMeasureDistanceNot; |
||||||
|
this.isMeasureVerNot = isMeasureVerNot; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public static class Item implements Parcelable { |
||||||
|
private String pointId; |
||||||
|
private String pointName; |
||||||
|
private double horAngle; |
||||||
|
private double verAngle; |
||||||
|
private double distance; |
||||||
|
private String prismHeight; |
||||||
|
|
||||||
|
protected boolean aloneDistance; |
||||||
|
protected boolean isMeasureDistanceNot; |
||||||
|
protected boolean isMeasureVerNot; |
||||||
|
|
||||||
|
public Item() { |
||||||
|
} |
||||||
|
|
||||||
|
public Item(String pointId, String pointName, double horAngle, double verAngle, double distance, |
||||||
|
String prismHeight, boolean aloneDistance, boolean isMeasureDistanceNot, boolean isMeasureVerNot) { |
||||||
|
this.pointId = pointId; |
||||||
|
this.pointName = pointName; |
||||||
|
this.horAngle = horAngle; |
||||||
|
this.verAngle = verAngle; |
||||||
|
this.distance = distance; |
||||||
|
this.prismHeight = prismHeight; |
||||||
|
this.aloneDistance = aloneDistance; |
||||||
|
this.isMeasureDistanceNot = isMeasureDistanceNot; |
||||||
|
this.isMeasureVerNot = isMeasureVerNot; |
||||||
|
} |
||||||
|
|
||||||
|
public String getPointId() { |
||||||
|
return pointId; |
||||||
|
} |
||||||
|
|
||||||
|
public String getPointName() { |
||||||
|
return pointName; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
public double getHorAngle() { |
||||||
|
return horAngle; |
||||||
|
} |
||||||
|
|
||||||
|
public void setHorAngle(double horAngle) { |
||||||
|
this.horAngle = horAngle; |
||||||
|
} |
||||||
|
|
||||||
|
public double getVerAngle() { |
||||||
|
return verAngle; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
public double getDistance() { |
||||||
|
return distance; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
public String getPrismHeight() { |
||||||
|
return prismHeight; |
||||||
|
} |
||||||
|
|
||||||
|
public String getPrismHeightActual() { |
||||||
|
if (TextUtils.isEmpty(prismHeight)) { |
||||||
|
return "0"; |
||||||
|
} |
||||||
|
return prismHeight; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public int describeContents() { |
||||||
|
return 0; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void writeToParcel(Parcel dest, int flags) { |
||||||
|
dest.writeString(this.pointId); |
||||||
|
dest.writeString(this.pointName); |
||||||
|
dest.writeDouble(this.horAngle); |
||||||
|
dest.writeDouble(this.verAngle); |
||||||
|
dest.writeDouble(this.distance); |
||||||
|
dest.writeString(this.prismHeight); |
||||||
|
dest.writeByte(this.aloneDistance ? (byte) 1 : (byte) 0); |
||||||
|
} |
||||||
|
|
||||||
|
public void readFromParcel(Parcel source) { |
||||||
|
this.pointId = source.readString(); |
||||||
|
this.pointName = source.readString(); |
||||||
|
this.horAngle = source.readDouble(); |
||||||
|
this.verAngle = source.readDouble(); |
||||||
|
this.distance = source.readDouble(); |
||||||
|
this.prismHeight = source.readString(); |
||||||
|
this.aloneDistance = source.readByte() != 0; |
||||||
|
} |
||||||
|
|
||||||
|
protected Item(Parcel in) { |
||||||
|
this.pointId = in.readString(); |
||||||
|
this.pointName = in.readString(); |
||||||
|
this.horAngle = in.readDouble(); |
||||||
|
this.verAngle = in.readDouble(); |
||||||
|
this.distance = in.readDouble(); |
||||||
|
this.prismHeight = in.readString(); |
||||||
|
this.aloneDistance = in.readByte() != 0; |
||||||
|
} |
||||||
|
|
||||||
|
public static final Creator<Item> CREATOR = new Creator<Item>() { |
||||||
|
@Override |
||||||
|
public Item createFromParcel(Parcel source) { |
||||||
|
return new Item(source); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public Item[] newArray(int size) { |
||||||
|
return new Item[size]; |
||||||
|
} |
||||||
|
}; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* @param stationId |
||||||
|
* @param cachedData |
||||||
|
* @param isExcludeEveryPointError true 包含每个点的错误信息 |
||||||
|
* @return 分开观测垂直角平差 |
||||||
|
*/ |
||||||
|
@WorkerThread |
||||||
|
public static List<AloneAdjustItem> calAloneVer(String stationId, ICachedData cachedData, boolean isExcludeEveryPointError) { |
||||||
|
List<AloneAdjustItem> resultAdjustList = new ArrayList<>(); |
||||||
|
|
||||||
|
if (cachedData == null || cachedData.realPointCount() == 0) |
||||||
|
return resultAdjustList; |
||||||
|
|
||||||
|
//1.读取测站数据
|
||||||
|
SurveyorStationRecord stationRecord = SurveyorDatabaseFactory.instance.getSurveyorStation().getRecordSync(stationId); |
||||||
|
if (stationRecord == null) { |
||||||
|
ToastUtils.showShort("测站数据为空"); |
||||||
|
return resultAdjustList; |
||||||
|
} |
||||||
|
//2.读取项目数据
|
||||||
|
ProjectRecord projectRecord = SurveyorDatabaseFactory.instance.getProjectDataSource().getRecord(stationRecord.projectId); |
||||||
|
if (projectRecord == null) { |
||||||
|
ToastUtils.showShort("项目数据为空"); |
||||||
|
return resultAdjustList; |
||||||
|
} |
||||||
|
//3.读取限差数据
|
||||||
|
ToleranceDetailRecord toleranceDetailRecordTj = SurveyorDatabaseFactory.instance.getToleranceDetailDataSource().getRecordSync(projectRecord.getToleranceId()); |
||||||
|
if (toleranceDetailRecordTj == null) { |
||||||
|
ToastUtils.showShort("限差参数为空"); |
||||||
|
return resultAdjustList; |
||||||
|
} |
||||||
|
|
||||||
|
int cycleCount = StationUtilPla.getCycleCount(StateConstantsPla.VALUE_MEASURE_WHAT_ANGLE_VER, stationRecord, toleranceDetailRecordTj); |
||||||
|
int surveyorCount = toleranceDetailRecordTj.getSurveyorCount(); |
||||||
|
//遍历所有点
|
||||||
|
for (int pointIndex = 0; pointIndex < cachedData.realPointCount(); pointIndex++) { |
||||||
|
//从1开始循环
|
||||||
|
SurveyorPoint point = cachedData.getSurveyorPoint(0, pointIndex); |
||||||
|
String prismHeight = point.getPrismHeight(); |
||||||
|
String pointId = point.getOriginalPointId(); |
||||||
|
PointRecord pointRecord = SurveyorDatabaseFactory.instance.getPointDataSource().findByIdSync(pointId); |
||||||
|
String pointName = pointRecord.name; |
||||||
|
|
||||||
|
int verCalCount = 0; |
||||||
|
double verSum = 0; |
||||||
|
int errorCycleIndex = -1; |
||||||
|
for (int cycleIndex = 0; cycleIndex < cycleCount; cycleIndex++) { |
||||||
|
String leftRecordId = IdUtil.surveyorRecordKey(stationId, cycleIndex, pointId, LeftOrRight.left); |
||||||
|
String rightRecordId = IdUtil.surveyorRecordKey(stationId, cycleIndex, pointId, LeftOrRight.right); |
||||||
|
|
||||||
|
CacheResult cachedVerValue = AverageValueMethod.leftAndRightValue(SdAngleValueType.verAngle, |
||||||
|
leftRecordId, |
||||||
|
rightRecordId, |
||||||
|
surveyorCount, |
||||||
|
cachedData); |
||||||
|
|
||||||
|
if (!cachedVerValue.validate) { |
||||||
|
//点有个测回数据出问题
|
||||||
|
errorCycleIndex = cycleIndex; |
||||||
|
break; |
||||||
|
} |
||||||
|
|
||||||
|
verSum += cachedVerValue.value; |
||||||
|
verCalCount++; |
||||||
|
} |
||||||
|
|
||||||
|
if (errorCycleIndex == -1) { |
||||||
|
resultAdjustList.add(new AloneAdjustItem(pointId, pointName, 0, Math.PI / 2 - verSum / verCalCount, |
||||||
|
0, prismHeight, |
||||||
|
false, false, false, |
||||||
|
null)); |
||||||
|
} else { |
||||||
|
//当前点平差异常
|
||||||
|
if (isExcludeEveryPointError) { |
||||||
|
resultAdjustList.add(new AloneAdjustItem(pointId, pointName, 0, 0, |
||||||
|
0, prismHeight, |
||||||
|
false, false, false, |
||||||
|
"第" + (errorCycleIndex + 1) + "测回数据异常")); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
return resultAdjustList; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* @param stationId |
||||||
|
* @param cachedData |
||||||
|
* @param isExcludeEveryPointError true 包含每个点的错误信息 |
||||||
|
* @return 单独测距平差数据 |
||||||
|
*/ |
||||||
|
@WorkerThread |
||||||
|
public static List<AloneAdjustItem> calAloneDistance(String stationId, ICachedData cachedData, boolean isExcludeEveryPointError) { |
||||||
|
List<AloneAdjustItem> resultAdjustList = new ArrayList<>(); |
||||||
|
if (cachedData == null || cachedData.realPointCount() == 0) |
||||||
|
return resultAdjustList; |
||||||
|
//1.读取测站数据
|
||||||
|
SurveyorStationRecord stationRecord = SurveyorDatabaseFactory.instance.getSurveyorStation().getRecordSync(stationId); |
||||||
|
if (stationRecord == null) { |
||||||
|
ToastUtils.showShort("测站数据为空"); |
||||||
|
return resultAdjustList; |
||||||
|
} |
||||||
|
//2.读取项目数据
|
||||||
|
ProjectRecord projectRecord = SurveyorDatabaseFactory.instance.getProjectDataSource().getRecord(stationRecord.projectId); |
||||||
|
if (projectRecord == null) { |
||||||
|
ToastUtils.showShort("项目数据为空"); |
||||||
|
return resultAdjustList; |
||||||
|
} |
||||||
|
//3.读取限差数据
|
||||||
|
ToleranceDetailRecord toleranceDetailRecordTj = SurveyorDatabaseFactory.instance.getToleranceDetailDataSource().getRecordSync(projectRecord.getToleranceId()); |
||||||
|
if (toleranceDetailRecordTj == null) { |
||||||
|
ToastUtils.showShort("限差参数为空"); |
||||||
|
return resultAdjustList; |
||||||
|
} |
||||||
|
//4.测量次数,测回数
|
||||||
|
int cycleCount = ToleranceDetailRecord.ALONE_DISTANCE_CYCLE_COUNT; |
||||||
|
int surveyorCount = ToleranceDetailRecord.ALONE_DISTANCE_MEASURE_COUNT; |
||||||
|
|
||||||
|
//遍历所有点
|
||||||
|
for (int i = 0; i < cachedData.realPointCount(); i++) { |
||||||
|
//从1开始循环
|
||||||
|
SurveyorPoint point = cachedData.getSurveyorPoint(0, i); |
||||||
|
|
||||||
|
String prismHeight = point.getPrismHeight(); |
||||||
|
String pointId = point.getOriginalPointId(); |
||||||
|
PointRecord pointRecord = SurveyorDatabaseFactory.instance.getPointDataSource().findByIdSync(pointId); |
||||||
|
String pointName = pointRecord.name; |
||||||
|
|
||||||
|
IAloneDistanceRecordDataSource wellDistanceDataSource = SurveyorDatabaseFactory.instance.getAloneDistanceRecordDataSource(); |
||||||
|
AloneDistanceRecord wellRecord = wellDistanceDataSource.getRecordSync(stationId, 0, point.getOriginalPointId()); |
||||||
|
if (AloneDistanceRecord.isCompleteSurveyorNot(wellRecord)) { |
||||||
|
if (isExcludeEveryPointError) { |
||||||
|
resultAdjustList.add(new AloneAdjustItem(pointId, pointName, 0, 0, 0, prismHeight, |
||||||
|
true, false, false, |
||||||
|
"观测数据不完整")); |
||||||
|
} |
||||||
|
continue; |
||||||
|
} |
||||||
|
|
||||||
|
//测量原始数据
|
||||||
|
List<WellDistance> distanceValues = wellRecord.distanceValues; |
||||||
|
// //获取测点的气象修正方式
|
||||||
|
// SurveyorPointScheduleRecord lastSurveyorPointSchedule = TjDbFactory.instance.getSurveyorPointScheduleDataSource().getLastSurveyorPointSchedule(stationId, pointId);
|
||||||
|
//
|
||||||
|
// if (lastSurveyorPointSchedule == null) {
|
||||||
|
// if (isExcludeEveryPointError) {
|
||||||
|
// resultAdjustList.add(new AloneAdjustItem(pointId, pointName, 0, 0, 0, prismHeight,
|
||||||
|
// true, false, false,
|
||||||
|
// "气象修正参数不完整"));
|
||||||
|
// }
|
||||||
|
// continue;
|
||||||
|
// }
|
||||||
|
// if (lastSurveyorPointSchedule.isHighPrecision()
|
||||||
|
// && !SurveyorPointScheduleRecord.checkHighAllWeatherAmendFinish(stationId, pointId, cycleCount)) {
|
||||||
|
// //判断高精度所有测回是否完
|
||||||
|
// if (isExcludeEveryPointError) {
|
||||||
|
// resultAdjustList.add(new AloneAdjustItem(pointId, pointName, 0, 0, 0, prismHeight,
|
||||||
|
// true, false, false,
|
||||||
|
// "气象修正参数不完整"));
|
||||||
|
// }
|
||||||
|
// continue;
|
||||||
|
// }
|
||||||
|
|
||||||
|
double average = 0; |
||||||
|
for (int cycleIndex = 0; cycleIndex < cycleCount; cycleIndex++) { |
||||||
|
|
||||||
|
|
||||||
|
double distanceAverageEveryCycle = Tools.calculateCollectionDoubleAverage(distanceValues.subList(cycleIndex * surveyorCount, (cycleIndex + 1) * surveyorCount), projectRecord.isShowSlopDistance()); |
||||||
|
// if (lastSurveyorPointSchedule.isHighPrecision()) {
|
||||||
|
// distanceAverageEveryCycle = getHighPrecisionDistance(stationId, cycleIndex, pointId, distanceAverageEveryCycle);
|
||||||
|
// } else if (lastSurveyorPointSchedule.isOrdinary()) {
|
||||||
|
// distanceAverageEveryCycle = getOrdinaryOrNoAmendDistance(stationId, pointId, SurveyorPointScheduleRecord.AMMEND_TYPE_ORDINARY, distanceAverageEveryCycle);
|
||||||
|
// } else {
|
||||||
|
// distanceAverageEveryCycle = getOrdinaryOrNoAmendDistance(stationId, pointId, SurveyorPointScheduleRecord.AMMEND_TYPE_NO, distanceAverageEveryCycle);
|
||||||
|
// }
|
||||||
|
|
||||||
|
average += distanceAverageEveryCycle; |
||||||
|
} |
||||||
|
resultAdjustList.add(new AloneAdjustItem(pointId, pointName, 0, 0, average / cycleCount, prismHeight, |
||||||
|
true, false, false, |
||||||
|
null)); |
||||||
|
} |
||||||
|
|
||||||
|
return resultAdjustList; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 获取一般修正或不修正的距离 |
||||||
|
*/ |
||||||
|
// public static double getOrdinaryOrNoAmendDistance(String stationId, String pointId, int amendType, double distanceAverageEveryCycle) {
|
||||||
|
// ISurveyorPointWeatherAmendmentDataSource surveyorPointWeatherAmendmentDataSource = TjDbFactory.instance.getSurveyorPointWeatherAmendmentDataSource();
|
||||||
|
// SurveyorPointWeatherAmendmentRecord surveyorWeatherAmendment = surveyorPointWeatherAmendmentDataSource.getSurveyorWeatherAmendmentByStationPointAmendType(stationId, pointId, amendType);
|
||||||
|
// if (surveyorWeatherAmendment == null) {
|
||||||
|
// return distanceAverageEveryCycle;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if (surveyorWeatherAmendment.amendType == SurveyorPointScheduleRecord.AMMEND_TYPE_ORDINARY) {
|
||||||
|
// double ppm = getPpm(surveyorWeatherAmendment.getCalDampWarm(), surveyorWeatherAmendment.getCalAirPressure(), surveyorWeatherAmendment.getCalDryTemperature());
|
||||||
|
// return ToolsTj.getAmendDistance(ppm, surveyorWeatherAmendment.additionConstant, surveyorWeatherAmendment.multiplyingConstant, surveyorWeatherAmendment.targetAdvance, distanceAverageEveryCycle);
|
||||||
|
// } else {
|
||||||
|
// return ToolsTj.getAmendDistance(surveyorWeatherAmendment.additionConstant, surveyorWeatherAmendment.multiplyingConstant, surveyorWeatherAmendment.targetAdvance, distanceAverageEveryCycle);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
/** |
||||||
|
* 获取高精度修正距离 |
||||||
|
*/ |
||||||
|
// private static double getHighPrecisionDistance(String stationId, int cycleIndex, String pointId, double distanceAverageEveryCycle) {
|
||||||
|
// ISurveyorPointWeatherAmendmentDataSource surveyorPointWeatherAmendmentDataSource = TjDbFactory.instance.getSurveyorPointWeatherAmendmentDataSource();
|
||||||
|
// SurveyorPointWeatherAmendmentRecord surveyorWeatherAmendment = surveyorPointWeatherAmendmentDataSource.getSurveyorWeatherAmendment(stationId, cycleIndex, pointId, SurveyorPointScheduleRecord.AMMEND_TYPE_HIGH_PRECISION);
|
||||||
|
// if (surveyorWeatherAmendment == null) {
|
||||||
|
// return distanceAverageEveryCycle;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Map<String, WeatherAmendmentMethod.AmendBean> amemdMap = WeatherAmendmentMethod.getAmemdMap(surveyorWeatherAmendment);
|
||||||
|
//
|
||||||
|
// double stationDryTemperatureBeforeAmended = getTemperatureAmended(surveyorWeatherAmendment.stationDryTemperatureBefore, amemdMap, WeatherAmendmentConstants.KEY_STATION_DRY_TEMPERATURE_BEFORE);
|
||||||
|
// double stationDampWarmBeforeAmended = getTemperatureAmended(surveyorWeatherAmendment.stationDampWarmBefore, amemdMap, WeatherAmendmentConstants.KEY_STATION_DAMP_WARM_BEFORE);
|
||||||
|
// double stationAirPressureBeforeAmended = getAirpressureAmended(surveyorWeatherAmendment.stationAirPressureBefore, amemdMap, WeatherAmendmentConstants.KEY_STATION_AIR_PRESSURE_BEFORE, surveyorWeatherAmendment.stationDryTemperatureBefore);
|
||||||
|
// double targetDryTemperatureBeforeAmended = getTemperatureAmended(surveyorWeatherAmendment.targetDryTemperatureBefore, amemdMap, WeatherAmendmentConstants.KEY_TARGET_DRY_TEMPERATURE_BEFORE);
|
||||||
|
// double targetDampWarmBeforeAmended = getTemperatureAmended(surveyorWeatherAmendment.targetDampWarmBefore, amemdMap, WeatherAmendmentConstants.KEY_TARGET_DAMP_WARM_BEFORE);
|
||||||
|
// double targetAirPressureBeforeAmended = getAirpressureAmended(surveyorWeatherAmendment.targetAirPressureBefore, amemdMap, WeatherAmendmentConstants.KEY_TARGET_AIR_PRESSURE_BEFORE, surveyorWeatherAmendment.targetDryTemperatureBefore);
|
||||||
|
// double stationDryTemperatureAfterAmended = getTemperatureAmended(surveyorWeatherAmendment.stationDryTemperatureAfter, amemdMap, WeatherAmendmentConstants.KEY_STATION_DRY_TEMPERATURE_AFTER);
|
||||||
|
// double stationDampWarmAfterAmended = getTemperatureAmended(surveyorWeatherAmendment.stationDampWarmAfter, amemdMap, WeatherAmendmentConstants.KEY_STATION_DAMP_WARM_AFTER);
|
||||||
|
// double stationAirPressureAfterAmended = getAirpressureAmended(surveyorWeatherAmendment.stationAirPressureAfter, amemdMap, WeatherAmendmentConstants.KEY_STATION_AIR_PRESSURE_AFTER, surveyorWeatherAmendment.stationDryTemperatureAfter);
|
||||||
|
// double targetDryTemperatureAfterAmended = getTemperatureAmended(surveyorWeatherAmendment.targetDryTemperatureAfter, amemdMap, WeatherAmendmentConstants.KEY_TARGET_DRY_TEMPERATURE_AFTER);
|
||||||
|
// double targetDampWarmAfterAmended = getTemperatureAmended(surveyorWeatherAmendment.targetDampWarmAfter, amemdMap, WeatherAmendmentConstants.KEY_TARGET_DAMP_WARM_AFTER);
|
||||||
|
// double targetAirPressureAfterAmended = getAirpressureAmended(surveyorWeatherAmendment.targetAirPressureAfter, amemdMap, WeatherAmendmentConstants.KEY_TARGET_AIR_PRESSURE_AFTER, surveyorWeatherAmendment.targetDryTemperatureAfter);
|
||||||
|
//
|
||||||
|
// //求温度气压平均值
|
||||||
|
// double dryTemperatureAverage = ((stationDryTemperatureBeforeAmended + stationDryTemperatureAfterAmended) / 2 + (targetDryTemperatureBeforeAmended + targetDryTemperatureAfterAmended) / 2) / 2;
|
||||||
|
// double dampWarmTemperatureAverage = ((stationDampWarmBeforeAmended + stationDampWarmAfterAmended) / 2 + (targetDampWarmBeforeAmended + targetDampWarmAfterAmended) / 2) / 2;
|
||||||
|
// double airPressureAverage = ((stationAirPressureBeforeAmended + stationAirPressureAfterAmended) / 2 + (targetAirPressureBeforeAmended + targetAirPressureAfterAmended) / 2) / 2;
|
||||||
|
//
|
||||||
|
// //求ppm
|
||||||
|
// double ppm = getPpm(dampWarmTemperatureAverage, airPressureAverage, dryTemperatureAverage);
|
||||||
|
//
|
||||||
|
// return ToolsTj.getAmendDistance(ppm, surveyorWeatherAmendment.additionConstant, surveyorWeatherAmendment.multiplyingConstant, surveyorWeatherAmendment.targetAdvance, distanceAverageEveryCycle);
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
} |
@ -0,0 +1,119 @@ |
|||||||
|
package com.bingce.controlnetwork.surveyor.method; |
||||||
|
|
||||||
|
|
||||||
|
import com.bingce.controlapphelper.model.LeftOrRight; |
||||||
|
import com.bingce.controlapphelper.surveyor.method.DeviationValueOfRadianMethod; |
||||||
|
import com.bingce.controlapphelper.surveyor.method.RadianMethod; |
||||||
|
import com.bingce.controlapphelper.surveyor.method.model.SdAngleValueType; |
||||||
|
import com.bingce.controlnetwork.surveyor.data.ICachedData; |
||||||
|
import com.bingce.controlnetwork.surveyor.data.ISurveyorData; |
||||||
|
import com.bingce.controlnetwork.surveyor.method.model.CacheResult; |
||||||
|
|
||||||
|
public class ValueOf2cMethod { |
||||||
|
public static CacheResult valueOf2C(SdAngleValueType type, |
||||||
|
String stationId, |
||||||
|
int cycleIndex, |
||||||
|
int pointIndex, |
||||||
|
ISurveyorData surveyorData, |
||||||
|
int surveyorCycleIndex, |
||||||
|
ICachedData cachedData) { |
||||||
|
CacheResult cachedValue = _valueOf2C(type, stationId, cycleIndex, pointIndex, surveyorData, surveyorCycleIndex, cachedData); |
||||||
|
if (!cachedValue.validate) { |
||||||
|
return cachedValue; |
||||||
|
} |
||||||
|
if (type == SdAngleValueType.horAngle || type == SdAngleValueType.verAngle) { |
||||||
|
return new CacheResult(true, RadianMethod.radian2S(cachedValue.value)); |
||||||
|
} |
||||||
|
return new CacheResult(true, cachedValue.value * 1000); |
||||||
|
} |
||||||
|
|
||||||
|
public static CacheResult valueOf2C(SdAngleValueType type, |
||||||
|
String leftRecordId, |
||||||
|
String rightRecordId, |
||||||
|
int surveyorCount, |
||||||
|
ICachedData cachedData) { |
||||||
|
CacheResult cachedValue = _valueOf2C(type, leftRecordId, rightRecordId, surveyorCount, cachedData); |
||||||
|
if (!cachedValue.validate) { |
||||||
|
return cachedValue; |
||||||
|
} |
||||||
|
if (type == SdAngleValueType.horAngle || type == SdAngleValueType.verAngle) { |
||||||
|
return new CacheResult(true, RadianMethod.radian2S(cachedValue.value)); |
||||||
|
} |
||||||
|
return new CacheResult(true, cachedValue.value * 1000); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 2C值 |
||||||
|
* |
||||||
|
* @param type 类型(水平角、垂直角、斜距) |
||||||
|
* @return 返回相应类型的2c |
||||||
|
*/ |
||||||
|
private static CacheResult _valueOf2C(SdAngleValueType type, |
||||||
|
String stationId, |
||||||
|
int cycleIndex, |
||||||
|
int pointIndex, |
||||||
|
ISurveyorData surveyorData, |
||||||
|
int surveyorCycleIndex, |
||||||
|
ICachedData cachedData) { |
||||||
|
CacheResult leftValue = AverageValueMethod.leftOrRightValue( |
||||||
|
type, |
||||||
|
stationId, |
||||||
|
cycleIndex, |
||||||
|
pointIndex, |
||||||
|
surveyorData, |
||||||
|
surveyorCycleIndex, |
||||||
|
cachedData, LeftOrRight.left); |
||||||
|
CacheResult rightValue = AverageValueMethod.leftOrRightValue( |
||||||
|
type, |
||||||
|
stationId, |
||||||
|
cycleIndex, |
||||||
|
pointIndex, |
||||||
|
surveyorData, |
||||||
|
surveyorCycleIndex, |
||||||
|
cachedData, LeftOrRight.right); |
||||||
|
if (leftValue.validate && rightValue.validate) { |
||||||
|
switch (type) { |
||||||
|
case horAngle: |
||||||
|
return new CacheResult(true, DeviationValueOfRadianMethod.radianAngleHor2C(leftValue.value, rightValue.value)); |
||||||
|
case verAngle: |
||||||
|
return new CacheResult(true, DeviationValueOfRadianMethod.radianAngleVer2C(leftValue.value, rightValue.value)); |
||||||
|
case distance: |
||||||
|
return new CacheResult(true, DeviationValueOfRadianMethod.distance2C(leftValue.value, rightValue.value)); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
return new CacheResult(false, -1); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
private static CacheResult _valueOf2C( |
||||||
|
SdAngleValueType type, |
||||||
|
String leftRecordId, |
||||||
|
String rightRecordId, |
||||||
|
int surveyorCount, |
||||||
|
ICachedData cachedData) { |
||||||
|
CacheResult leftValue = AverageValueMethod.leftOrRightValue( |
||||||
|
type, |
||||||
|
leftRecordId, |
||||||
|
surveyorCount, |
||||||
|
cachedData); |
||||||
|
CacheResult rightValue = AverageValueMethod.leftOrRightValue( |
||||||
|
type, |
||||||
|
rightRecordId, |
||||||
|
surveyorCount, |
||||||
|
cachedData); |
||||||
|
if (leftValue.validate && rightValue.validate) { |
||||||
|
switch (type) { |
||||||
|
case horAngle: |
||||||
|
return new CacheResult(true, DeviationValueOfRadianMethod.radianAngleHor2C(leftValue.value, rightValue.value)); |
||||||
|
case verAngle: |
||||||
|
return new CacheResult(true, DeviationValueOfRadianMethod.radianAngleVer2C(leftValue.value, rightValue.value)); |
||||||
|
case distance: |
||||||
|
return new CacheResult(true, DeviationValueOfRadianMethod.distance2C(leftValue.value, rightValue.value)); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
return new CacheResult(false, -1); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,11 @@ |
|||||||
|
package com.bingce.controlnetwork.surveyor.method.model; |
||||||
|
|
||||||
|
public class CacheResult { |
||||||
|
public final boolean validate; |
||||||
|
public final double value; |
||||||
|
|
||||||
|
public CacheResult(boolean validate, double value) { |
||||||
|
this.validate = validate; |
||||||
|
this.value = value; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,18 @@ |
|||||||
|
package com.bingce.controlnetwork.surveyor.method.model; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
public interface IStateDelegate { |
||||||
|
void onOptionTips(String msg, |
||||||
|
String confirmButton, |
||||||
|
String cancelButton, |
||||||
|
Runnable confirmCallback, |
||||||
|
Runnable cancelCallback, |
||||||
|
Runnable ignoreCallback); |
||||||
|
|
||||||
|
void resetSurveyorStateAndKeepPosition(); |
||||||
|
|
||||||
|
void resurveyPoints(int cycleIndex, List<String> pointIds); |
||||||
|
|
||||||
|
void deleteSingleCycleData(int cycleIndex); |
||||||
|
} |
@ -0,0 +1,27 @@ |
|||||||
|
package com.bingce.controlnetwork.surveyor.state; |
||||||
|
|
||||||
|
|
||||||
|
import com.bingce.controlnetwork.surveyor.method.AutoSurveyorMethod; |
||||||
|
|
||||||
|
public interface IAutoModeSwitcher { |
||||||
|
boolean isAutoModeOpen(); |
||||||
|
|
||||||
|
boolean isAutoModeClose(); |
||||||
|
|
||||||
|
boolean isAutoModeInit(); |
||||||
|
|
||||||
|
void openAutoMode(); |
||||||
|
|
||||||
|
void closeAutoMode(); |
||||||
|
|
||||||
|
void resetAutoMode(); |
||||||
|
|
||||||
|
void isReadyAutoSurvey(AutoSurveyorMethod.CallBackLearnResultCode callBackLearnResultCode); |
||||||
|
|
||||||
|
/** |
||||||
|
* 自动测量过程中检测测量数据和设计数据是否匹配 |
||||||
|
* <p> |
||||||
|
* 返回值为null就合法,否则出错 |
||||||
|
*/ |
||||||
|
void isMeasuredValueMatchDesign(AutoSurveyorMethod.CallBackCheckDesign callBackCheckDesign); |
||||||
|
} |
@ -0,0 +1,13 @@ |
|||||||
|
package com.bingce.controlnetwork.surveyor.state; |
||||||
|
|
||||||
|
public interface ISurveyState { |
||||||
|
/** |
||||||
|
* 是否正在测量,包括「单步测量」「自动测量」 |
||||||
|
*/ |
||||||
|
boolean isSurveying(); |
||||||
|
|
||||||
|
/** |
||||||
|
* 是否正在「自动测量」 |
||||||
|
*/ |
||||||
|
boolean isAutoSurveying(); |
||||||
|
} |
@ -0,0 +1,10 @@ |
|||||||
|
package com.bingce.controlnetwork.surveyor.state; |
||||||
|
|
||||||
|
/** |
||||||
|
* 测量过程中,将跳转到当前item处 |
||||||
|
* <p> |
||||||
|
* 这个委托就是做这项任务 |
||||||
|
*/ |
||||||
|
public interface ISurveyorDataScrollDelegate { |
||||||
|
void onScrollTo(int cycleIndex, int pointIndex); |
||||||
|
} |
@ -0,0 +1,54 @@ |
|||||||
|
package com.bingce.controlnetwork.surveyor.state; |
||||||
|
|
||||||
|
public class StateConstantsPla { |
||||||
|
/** |
||||||
|
* --------------------------measureWhat开始-------------------------------- |
||||||
|
* 值勿改 |
||||||
|
**/ |
||||||
|
|
||||||
|
/** |
||||||
|
* 默认的 测角测距 |
||||||
|
*/ |
||||||
|
public static final int VALUE_MEASURE_WHAT_DEFAULT = 0; |
||||||
|
|
||||||
|
/** |
||||||
|
* 仅测距离 |
||||||
|
*/ |
||||||
|
public static final int VALUE_MEASURE_WHAT_DISTANCE = 1; |
||||||
|
|
||||||
|
/** |
||||||
|
* 仅测水平角 |
||||||
|
*/ |
||||||
|
public static final int VALUE_MEASURE_WHAT_ANGLE_HOR = 2; |
||||||
|
/** |
||||||
|
* 仅测垂直角 |
||||||
|
*/ |
||||||
|
public static final int VALUE_MEASURE_WHAT_ANGLE_VER = 3; |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* --------------------------measureWhat结束-------------------------------- |
||||||
|
**/ |
||||||
|
|
||||||
|
|
||||||
|
//measureWhat对应的传值key
|
||||||
|
public static final String KEY_IS_ALREADY_REMIND_USER_AIMING_AT_WIRE = "KEY_IS_ALREADY_REMIND_USER_AIMING_AT_WIRE"; |
||||||
|
|
||||||
|
|
||||||
|
public static boolean needLeftRight(int measureWhat) { |
||||||
|
return measureWhat == VALUE_MEASURE_WHAT_DEFAULT || measureWhat == VALUE_MEASURE_WHAT_ANGLE_HOR; |
||||||
|
} |
||||||
|
|
||||||
|
public static boolean isMeasureDistance(int measureWhat) { |
||||||
|
return measureWhat == VALUE_MEASURE_WHAT_DISTANCE; |
||||||
|
} |
||||||
|
|
||||||
|
public static boolean isMeasureVerAngle(int measureWhat) { |
||||||
|
return measureWhat == VALUE_MEASURE_WHAT_ANGLE_VER; |
||||||
|
} |
||||||
|
|
||||||
|
public static boolean isZeroMeasureWhat(int measureWhat) { |
||||||
|
return measureWhat == VALUE_MEASURE_WHAT_DEFAULT || measureWhat == VALUE_MEASURE_WHAT_ANGLE_HOR; |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,243 @@ |
|||||||
|
package com.bingce.controlnetwork.surveyor.state; |
||||||
|
|
||||||
|
import android.content.Context; |
||||||
|
import android.os.Bundle; |
||||||
|
|
||||||
|
import androidx.annotation.NonNull; |
||||||
|
import androidx.annotation.WorkerThread; |
||||||
|
import androidx.fragment.app.FragmentManager; |
||||||
|
import androidx.lifecycle.LifecycleOwner; |
||||||
|
|
||||||
|
import com.bingce.controlapphelper.datasource.database.SurveyorDatabaseFactory; |
||||||
|
import com.bingce.controlapphelper.datasource.database.point.PointRecord; |
||||||
|
import com.bingce.controlapphelper.datasource.database.surveyorstation.SurveyorStationRecord; |
||||||
|
import com.bingce.controlapphelper.datasource.database.surveyorstation.model.SurveyorPoint; |
||||||
|
import com.bingce.controlapphelper.datasource.database.tolerance.detail.ToleranceDetailRecord; |
||||||
|
import com.bingce.controlapphelper.util.IUIRunner; |
||||||
|
import com.bingce.controlapphelper.util.Tools; |
||||||
|
import com.bingce.controlnetwork.surveyor.data.ICachedData; |
||||||
|
import com.bingce.controlnetwork.surveyor.data.ICycleRecorder; |
||||||
|
import com.bingce.controlnetwork.surveyor.data.IStationPointRecordCollect; |
||||||
|
import com.bingce.controlnetwork.surveyor.data.ISurveyorData; |
||||||
|
import com.bingce.controlnetwork.surveyor.state.base.AbstructStateManager; |
||||||
|
import com.bingce.controlnetwork.surveyor.surveyor.ISurveyorListener; |
||||||
|
import com.bingce.controlnetwork.surveyor.surveyor.ISurveyorRemindListener; |
||||||
|
import com.bingce.controlnetwork.util.SupportAutoSurveyorUtil; |
||||||
|
|
||||||
|
public class StateManagerPla extends AbstructStateManager { |
||||||
|
|
||||||
|
private StateManagerPla(final int measureWhat, |
||||||
|
final boolean supportAutoSurvey,//是否支持自动测量
|
||||||
|
final @NonNull SurveyorStationRecord stationRecord, |
||||||
|
final @NonNull PointRecord stationPointRecord, |
||||||
|
final @NonNull ToleranceDetailRecord toleranceRecord, |
||||||
|
final @NonNull Context context, |
||||||
|
final @NonNull IStationPointRecordCollect pointRecordCollect, |
||||||
|
final @NonNull ISurveyorData surveyorData, |
||||||
|
final @NonNull ICycleRecorder cycleRecorder, |
||||||
|
final @NonNull ICachedData cachedData, |
||||||
|
final @NonNull ISurveyorDataScrollDelegate scrollDelegate, |
||||||
|
FragmentManager fragmentManager, |
||||||
|
LifecycleOwner lifecycleOwner, |
||||||
|
IUIRunner iuiRunner) { |
||||||
|
super(measureWhat, supportAutoSurvey, stationRecord, stationPointRecord, |
||||||
|
toleranceRecord, context, pointRecordCollect, surveyorData, cycleRecorder, |
||||||
|
cachedData, scrollDelegate, fragmentManager, lifecycleOwner, iuiRunner); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected void initState() { |
||||||
|
_DoSurveyorState doSurveyorState = new _DoSurveyorState(this, this); |
||||||
|
stateMap.put(StateType.doSurveyor, doSurveyorState); |
||||||
|
stateMap.put(StateType.doAutoSurveyor, new _DoAutoSurveyorState(this, this)); |
||||||
|
stateMap.put(StateType.SurveyorFailure, new _SurveyorFailureState(this)); |
||||||
|
stateMap.put(StateType.doMove2NextValidate, new _DoMove2NextValidateState(this)); |
||||||
|
stateMap.put(StateType.doMoveBack, new _DoMoveBackState(this)); |
||||||
|
stateMap.put(StateType.doRecordClean, new _DoRecordCleanState(this)); |
||||||
|
stateMap.put(StateType.checkReadData, new _CheckReadDataState(this, this)); |
||||||
|
stateMap.put(StateType.isHalfCycleZeroCheckReady, new _IsHalfCycleZeroCheckReadyState(this)); |
||||||
|
stateMap.put(StateType.checkHalfCycleZero, new _CheckHalfCycleZeroState(this)); |
||||||
|
stateMap.put(StateType.isReady2CCheck, new _Is2CCheckReadyState(this)); |
||||||
|
stateMap.put(StateType.check2C, new _Check2CState(this)); |
||||||
|
stateMap.put(StateType.isSingleCycleCompleted, new _IsSingleCycleCompletedState(this)); |
||||||
|
stateMap.put(StateType.isAllCycleCompleted, new _IsAllCycleCompletedState(this, this)); |
||||||
|
stateMap.put(StateType.checkSingleCycle, new _CheckSingleCycleState(this)); |
||||||
|
stateMap.put(StateType.checkStation, new _CheckStationState(this)); |
||||||
|
stateMap.put(StateType.stationCheckedSuccess, new _CheckStationSuccessState(this)); |
||||||
|
|
||||||
|
stateMap.put(StateType.doDeleteAllCycle, new _DoDeleteAllCycleState(this)); |
||||||
|
stateMap.put(StateType.doDeleteCurrentCycle, new _DoDeleteCurrentCycleState(this)); |
||||||
|
|
||||||
|
stateMap.put(StateType.doCalScheduleSingleCycle, new _DoCalScheduleInSingleCycleState(this, this)); |
||||||
|
stateMap.put(StateType.doCalScheduleAllCycle, new _DoCalScheduleInAllCycleState(this, this)); |
||||||
|
stateMap.put(StateType.doCalAdjust, new _DoCalAdjustState(this)); |
||||||
|
stateMap.put(StateType.idle, new _IdleState(this, this)); |
||||||
|
stateMap.put(StateType.doWellMeasureRotationReady, new _DoWellMeasureRotationReadyState(this)); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected void refreshUiPage() { |
||||||
|
getCachedData().notifyDateChange(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected ISurveyorListener getISurveyorListener() { |
||||||
|
return getDoSurveyorState(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected ISurveyorRemindListener getISurveyorRemindListener() { |
||||||
|
return getDoSurveyorState(); |
||||||
|
} |
||||||
|
|
||||||
|
private _DoSurveyorState getDoSurveyorState() { |
||||||
|
return (_DoSurveyorState) stateMap.get(StateType.doSurveyor); |
||||||
|
} |
||||||
|
|
||||||
|
public void doSurveyor() { |
||||||
|
boolean inValidate = isInValidate(); |
||||||
|
boolean wellMeasureRotationReady = isWellMeasureRotationReady(); |
||||||
|
|
||||||
|
if (!(!inValidate || wellMeasureRotationReady)) { |
||||||
|
//!inValidate是可以通过的状态
|
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
if (Tools.isDeviceConnectedNot()) { |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
Bundle bundle = new Bundle(); |
||||||
|
if (wellMeasureRotationReady) { |
||||||
|
//当前是钢丝准备状态
|
||||||
|
//传给测量状态isAlreadyRemindUserAimingAtWire
|
||||||
|
bundle.putBoolean(StateConstantsPla.KEY_IS_ALREADY_REMIND_USER_AIMING_AT_WIRE, true); |
||||||
|
} |
||||||
|
enter(StateType.doSurveyor, bundle); |
||||||
|
} |
||||||
|
|
||||||
|
public void doAutoSurveyor() { |
||||||
|
if (isInValidate()) { |
||||||
|
return; |
||||||
|
} |
||||||
|
enter(StateType.doAutoSurveyor); |
||||||
|
} |
||||||
|
|
||||||
|
public void deleteCurrentStationSurveyorData() { |
||||||
|
if (isInValidate()) { |
||||||
|
return; |
||||||
|
} |
||||||
|
enter(StateType.doDeleteAllCycle, _DoDeleteAllCycleState.args(stationId())); |
||||||
|
} |
||||||
|
|
||||||
|
public void deleteCurrentStationSurveyorData(int cycleIndex) { |
||||||
|
if (isInValidate()) { |
||||||
|
return; |
||||||
|
} |
||||||
|
enter(StateType.doDeleteCurrentCycle, _DoDeleteCurrentCycleState.args(stationId(), cycleIndex)); |
||||||
|
} |
||||||
|
|
||||||
|
public void stationCheck() { |
||||||
|
if (isInValidate()) { |
||||||
|
return; |
||||||
|
} |
||||||
|
enter(StateType.checkStation); |
||||||
|
} |
||||||
|
|
||||||
|
public void stationAdjust() { |
||||||
|
if (isInValidate()) { |
||||||
|
return; |
||||||
|
} |
||||||
|
enter(StateType.doCalAdjust); |
||||||
|
} |
||||||
|
|
||||||
|
public void switch2Cycle(int cycleIndex) { |
||||||
|
if (isInValidate()) { |
||||||
|
return; |
||||||
|
} |
||||||
|
_DoCalScheduleInSingleCycleState.enter(this, cycleIndex); |
||||||
|
} |
||||||
|
|
||||||
|
public void calScheduleWhenEnterSurveyFragment(int cycleIndex) { |
||||||
|
if (isInValidate()) { |
||||||
|
return; |
||||||
|
} |
||||||
|
_DoCalScheduleInAllCycleState.enter(this, cycleIndex); |
||||||
|
} |
||||||
|
|
||||||
|
public void moveBack() { |
||||||
|
if (isInValidate()) { |
||||||
|
return; |
||||||
|
} |
||||||
|
enter(StateType.doMoveBack); |
||||||
|
} |
||||||
|
|
||||||
|
//检测当前状态是否支持从外界主动改变状态
|
||||||
|
//如果是空闲或者是测站通过检测是有效的状态
|
||||||
|
private boolean isInValidate() { |
||||||
|
return currentStateType != StateType.idle && StateType.stationCheckedSuccess != currentStateType; |
||||||
|
} |
||||||
|
|
||||||
|
private boolean isWellMeasureRotationReady() { |
||||||
|
return StateType.doWellMeasureRotationReady == currentStateType; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
@WorkerThread |
||||||
|
public static StateManagerPla newInstance(int measureWhat,//仅测量水平角还是什么...
|
||||||
|
@NonNull SurveyorStationRecord stationRecord, |
||||||
|
@NonNull Context context, |
||||||
|
@NonNull FragmentManager fragmentManager, |
||||||
|
@NonNull LifecycleOwner lifecycleOwner, |
||||||
|
@NonNull ToleranceDetailRecord toleranceRecord, |
||||||
|
@NonNull IStationPointRecordCollect pointRecordCollect, |
||||||
|
@NonNull ISurveyorData surveyorData, |
||||||
|
@NonNull ICycleRecorder cycleRecorder, |
||||||
|
@NonNull ICachedData cachedData, |
||||||
|
ISurveyorDataScrollDelegate scrollDelegate, |
||||||
|
IUIRunner runner) { |
||||||
|
//读取测点record
|
||||||
|
String stationPointId = null; |
||||||
|
if (stationRecord.getItems() != null) { |
||||||
|
for (SurveyorPoint stationItem : stationRecord.getItems()) { |
||||||
|
if (SurveyorPoint.TYPE_STATION.equals(stationItem.getType())) { |
||||||
|
stationPointId = stationItem.getPointId(); |
||||||
|
break; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
PointRecord stationPointRecord = null; |
||||||
|
if (stationPointId != null) { |
||||||
|
stationPointRecord = SurveyorDatabaseFactory |
||||||
|
.instance |
||||||
|
.getPointDataSource() |
||||||
|
.findByIdSync(stationPointId); |
||||||
|
} |
||||||
|
if (stationPointRecord == null) { |
||||||
|
return null; |
||||||
|
} |
||||||
|
boolean supportAuto = SupportAutoSurveyorUtil.isSupportAuto(); |
||||||
|
return new StateManagerPla(measureWhat, supportAuto, |
||||||
|
stationRecord, |
||||||
|
stationPointRecord, |
||||||
|
toleranceRecord, |
||||||
|
context, |
||||||
|
pointRecordCollect, |
||||||
|
surveyorData, |
||||||
|
cycleRecorder, |
||||||
|
cachedData, |
||||||
|
scrollDelegate, |
||||||
|
fragmentManager, lifecycleOwner, runner); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean isSurveying() { |
||||||
|
return currentStateType == StateType.doSurveyor || currentStateType == StateType.doAutoSurveyor; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean isAutoSurveying() { |
||||||
|
return isAutoModeOpen(); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,36 @@ |
|||||||
|
package com.bingce.controlnetwork.surveyor.state; |
||||||
|
|
||||||
|
/* |
||||||
|
* 标识状态类型 |
||||||
|
* */ |
||||||
|
public enum StateType { |
||||||
|
idle,//空闲状态
|
||||||
|
SurveyorFailure,//仪器导致的测量失败
|
||||||
|
|
||||||
|
doCalScheduleSingleCycle,//计算单个测回中的测量进度---不会发生跳转
|
||||||
|
doCalScheduleAllCycle,//计算所有测回中的测量进度---可能发生跳转
|
||||||
|
doCalAdjust,//平差计算
|
||||||
|
doSurveyor,//测量 1
|
||||||
|
doAutoSurveyor,//自动测量
|
||||||
|
doRecordClean,//记录测量数据--目前没有发现错误 5
|
||||||
|
doMove2NextValidate,//移动到下一点执行测量
|
||||||
|
doMoveBack,//移动到上一测量结点
|
||||||
|
doDeleteCurrentCycle,//删除本测回数据
|
||||||
|
doDeleteAllCycle,//删除所有测回数据
|
||||||
|
doWellMeasureRotationReady, |
||||||
|
|
||||||
|
isHalfCycleZeroCheckReady,//检测是否半测回完成 3
|
||||||
|
isReady2CCheck,//是否满足进行2c检测条件 4
|
||||||
|
isSingleCycleCompleted,//检测单个测回是否完成 6
|
||||||
|
isAllCycleCompleted,//检测整个测回是否完成
|
||||||
|
|
||||||
|
checkReadData,//读数检测 2
|
||||||
|
checkHalfCycleZero,//半测回归零差检测
|
||||||
|
check2C,//2c检测
|
||||||
|
checkSingleCycle,//单个测回内不同方向2c、方向i互差检测
|
||||||
|
checkStation,//测回间数据检测-- 同方向方向值互差、2c互差、垂直角互差、i互差
|
||||||
|
|
||||||
|
stationCheckedSuccess,//测站通过检测
|
||||||
|
|
||||||
|
checkTolerance,//检测限差
|
||||||
|
} |
@ -0,0 +1,186 @@ |
|||||||
|
package com.bingce.controlnetwork.surveyor.state; |
||||||
|
|
||||||
|
import android.os.Bundle; |
||||||
|
import android.text.TextUtils; |
||||||
|
|
||||||
|
import com.bingce.controlapphelper.datasource.database.surveyorstation.model.SurveyorPoint; |
||||||
|
import com.bingce.controlapphelper.datasource.database.tolerance.detail.ToleranceDetailRecord; |
||||||
|
import com.bingce.controlapphelper.surveyor.method.model.SdAngleValueType; |
||||||
|
import com.bingce.controlnetwork.bean.SurveyorScheduleConstants; |
||||||
|
import com.bingce.controlnetwork.surveyor.data.ICachedData; |
||||||
|
import com.bingce.controlnetwork.surveyor.data.ISurveyorData; |
||||||
|
import com.bingce.controlnetwork.surveyor.method.ValueOf2cMethod; |
||||||
|
import com.bingce.controlnetwork.surveyor.method.model.CacheResult; |
||||||
|
import com.bingce.utils.Util; |
||||||
|
|
||||||
|
import net.tatans.tensorflowtts.tts.TtsManager; |
||||||
|
|
||||||
|
/* |
||||||
|
* 检测2c |
||||||
|
* */ |
||||||
|
class _Check2CState extends __BaseState { |
||||||
|
|
||||||
|
public _Check2CState(StateManagerPla stateManager) { |
||||||
|
super(StateType.check2C, stateManager); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void enter(Bundle args) { |
||||||
|
String error = check2C(); |
||||||
|
if (TextUtils.isEmpty(error)) { |
||||||
|
navigation2(StateType.doRecordClean); |
||||||
|
} else { |
||||||
|
if (isAutoSurveyOpen()) { |
||||||
|
TtsManager.getInstance().speak("二西超限,请检查"); |
||||||
|
} |
||||||
|
optionTips(error, |
||||||
|
"重测测回", |
||||||
|
"重测目标", |
||||||
|
() -> optionTipsWithStandStill("是否确定删除该测回所有数据?", |
||||||
|
() -> { |
||||||
|
String stationId = stationId(); |
||||||
|
int currentCycleIndex = getCycleRecorder().currentCycleIndex(); |
||||||
|
if (currentCycleIndex == 0) { |
||||||
|
deleteAllLearnBaseData(measureWhat(), stationId, this::clearSurveyData); |
||||||
|
} else { |
||||||
|
clearSurveyData(); |
||||||
|
} |
||||||
|
}), |
||||||
|
this::enterIdleAndClearSurveyState, |
||||||
|
this::enterIdleAndClearSurveyStateAndCloseAutoMode); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private String check2C() { |
||||||
|
int measureWhat = measureWhat(); |
||||||
|
switch (measureWhat) { |
||||||
|
case StateConstantsPla.VALUE_MEASURE_WHAT_DEFAULT: |
||||||
|
// case StateConstants.VALUE_MEASURE_WHAT_ANGLE:
|
||||||
|
return checkAll(); |
||||||
|
case StateConstantsPla.VALUE_MEASURE_WHAT_ANGLE_HOR: |
||||||
|
return checkAngleHor(); |
||||||
|
case StateConstantsPla.VALUE_MEASURE_WHAT_ANGLE_VER: |
||||||
|
return checkAngleVer(); |
||||||
|
default: |
||||||
|
return null; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private void clearSurveyData() { |
||||||
|
String stationId = stationId(); |
||||||
|
int currentCycleIndex = getCycleRecorder().currentCycleIndex(); |
||||||
|
//删除数据
|
||||||
|
ICachedData cachedData = getCachedData(); |
||||||
|
cachedData.deleteSurveyorRecord(stationId, currentCycleIndex); |
||||||
|
//更新进度
|
||||||
|
setStationScheduleForSingleCycle(currentCycleIndex, SurveyorScheduleConstants.STATUE_VALUE_NO_COMPLETED); |
||||||
|
setStationScheduleForAllCycle(SurveyorScheduleConstants.STATUE_VALUE_NO_COMPLETED); |
||||||
|
//重新查找目标开启测量
|
||||||
|
findTargetFromBeginInCurrentCycle(true); |
||||||
|
} |
||||||
|
|
||||||
|
private String checkAll() { |
||||||
|
StringBuilder stringBuilder = new StringBuilder(); |
||||||
|
|
||||||
|
int currentIndex = getSurveyorData().currentIndex(); |
||||||
|
int cycleIndex = getCurrentCycleIndex(); |
||||||
|
ICachedData cachedData = getCachedData(); |
||||||
|
//检测水平角
|
||||||
|
String errorHor = checkAngleHor(); |
||||||
|
if (!TextUtils.isEmpty(errorHor)) { |
||||||
|
stringBuilder.append(errorHor); |
||||||
|
} |
||||||
|
SurveyorPoint surveyorPoint = cachedData.getSurveyorPoint(cycleIndex, currentIndex); |
||||||
|
boolean isWellSteel = cachedData.isWellSteelPoint(cycleIndex, currentIndex); |
||||||
|
if (!isWellSteel && !surveyorPoint.isMeasureVerNot()) { |
||||||
|
String errorVer = checkAngleVer(); |
||||||
|
if (!TextUtils.isEmpty(errorVer)) { |
||||||
|
stringBuilder.append(errorHor); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
if (!isWellSteel && !surveyorPoint.isMeasureDistanceNot()) { |
||||||
|
String errorDistance = checkDistance(); |
||||||
|
if (!TextUtils.isEmpty(errorDistance)) { |
||||||
|
stringBuilder.append(errorDistance); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
return stringBuilder.toString(); |
||||||
|
} |
||||||
|
|
||||||
|
private String checkAngleHor() { |
||||||
|
StringBuilder stringBuilder = new StringBuilder(); |
||||||
|
|
||||||
|
ISurveyorData surveyorData = getSurveyorData(); |
||||||
|
int currentIndex = getSurveyorData().currentIndex(); |
||||||
|
String stationId = stationId(); |
||||||
|
int cycleIndex = getCurrentCycleIndex(); |
||||||
|
ICachedData cachedData = getCachedData(); |
||||||
|
ToleranceDetailRecord toleranceRecord = getToleranceRecord(); |
||||||
|
|
||||||
|
CacheResult value2C = ValueOf2cMethod.valueOf2C(SdAngleValueType.horAngle, stationId, cycleIndex, currentIndex, |
||||||
|
surveyorData, getCycleRecorder().currentCycleIndex(), cachedData); |
||||||
|
|
||||||
|
if (!value2C.validate || toleranceRecord.getHor2C() < Math.abs(value2C.value)) { |
||||||
|
stringBuilder.append("水平角2c绝对值超限(限差:") |
||||||
|
.append(toleranceRecord.getHor2C()) |
||||||
|
.append("'')\n") |
||||||
|
.append(" 测量值:") |
||||||
|
.append(Util.formatDouble2String(Math.abs(value2C.value), 1)) |
||||||
|
.append("''"); |
||||||
|
} |
||||||
|
|
||||||
|
return stringBuilder.toString(); |
||||||
|
} |
||||||
|
|
||||||
|
private String checkAngleVer() { |
||||||
|
StringBuilder stringBuilder = new StringBuilder(); |
||||||
|
|
||||||
|
ISurveyorData surveyorData = getSurveyorData(); |
||||||
|
int currentIndex = getSurveyorData().currentIndex(); |
||||||
|
String stationId = stationId(); |
||||||
|
int cycleIndex = getCurrentCycleIndex(); |
||||||
|
ICachedData cachedData = getCachedData(); |
||||||
|
ToleranceDetailRecord toleranceRecord = getToleranceRecord(); |
||||||
|
|
||||||
|
CacheResult value2C = ValueOf2cMethod.valueOf2C(SdAngleValueType.verAngle, stationId, cycleIndex, currentIndex, |
||||||
|
surveyorData, getCycleRecorder().currentCycleIndex(), cachedData); |
||||||
|
if (!value2C.validate || toleranceRecord.getVerI() < Math.abs(value2C.value)) { |
||||||
|
stringBuilder.append("\n竖直角i指标超限(限差:") |
||||||
|
.append(toleranceRecord.getVerI()) |
||||||
|
.append("'')\n") |
||||||
|
.append(" 测量值:") |
||||||
|
.append(Util.formatDouble2String(Math.abs(value2C.value), 1)) |
||||||
|
.append("''"); |
||||||
|
} |
||||||
|
|
||||||
|
return stringBuilder.toString(); |
||||||
|
} |
||||||
|
|
||||||
|
private String checkDistance() { |
||||||
|
StringBuilder stringBuilder = new StringBuilder(); |
||||||
|
|
||||||
|
ISurveyorData surveyorData = getSurveyorData(); |
||||||
|
int currentIndex = getSurveyorData().currentIndex(); |
||||||
|
String stationId = stationId(); |
||||||
|
int cycleIndex = getCurrentCycleIndex(); |
||||||
|
ICachedData cachedData = getCachedData(); |
||||||
|
ToleranceDetailRecord toleranceRecord = getToleranceRecord(); |
||||||
|
|
||||||
|
CacheResult value2C = ValueOf2cMethod.valueOf2C(SdAngleValueType.distance, stationId, cycleIndex, currentIndex, |
||||||
|
surveyorData, getCycleRecorder().currentCycleIndex(), cachedData); |
||||||
|
if (!value2C.validate || toleranceRecord.getSlopeLensDistanceDifference() < Math.abs(value2C.value)) { |
||||||
|
stringBuilder.append("\n正倒镜距离较差超限(限差:") |
||||||
|
.append(toleranceRecord.getSlopeLensDistanceDifference()) |
||||||
|
.append("mm)\n") |
||||||
|
.append(" 测量值:") |
||||||
|
.append(Util.formatDouble2String(Math.abs(value2C.value), 1)) |
||||||
|
.append("mm"); |
||||||
|
} |
||||||
|
|
||||||
|
return stringBuilder.toString(); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue