parent
46a0d04cae
commit
3ce4e1bacb
297 changed files with 22401 additions and 2484 deletions
Binary file not shown.
@ -0,0 +1,2 @@ |
||||
configurations.maybeCreate("default") |
||||
artifacts.add("default", file('base-release.aar')) |
@ -0,0 +1,5 @@ |
||||
打包注意事项: |
||||
1.检查 Test.java 中的DEBUG是否为false; |
||||
2.检查 打包版本号; |
||||
3.检查数据库版本号; |
||||
4.检查changelog.xml内容 |
@ -0,0 +1,13 @@ |
||||
package com.bingce.controlnetwork.bean; |
||||
|
||||
public class MainUserBean { |
||||
public String userName; |
||||
public String nickName; |
||||
public String avator; |
||||
|
||||
public MainUserBean(String userName, String nickName, String avator) { |
||||
this.userName = userName; |
||||
this.nickName = nickName; |
||||
this.avator = avator; |
||||
} |
||||
} |
@ -0,0 +1,21 @@ |
||||
package com.bingce.controlnetwork.event; |
||||
|
||||
public class RefreshEvent<T> { |
||||
public static final int REFRESH_BY_LEVEL_I_DETECTION_SETTING_UPDATE = 3; |
||||
|
||||
private int type; |
||||
private T data; |
||||
|
||||
public RefreshEvent(int type, T data) { |
||||
this.type = type; |
||||
this.data = data; |
||||
} |
||||
|
||||
public int getType() { |
||||
return type; |
||||
} |
||||
|
||||
public T getData() { |
||||
return data; |
||||
} |
||||
} |
@ -0,0 +1,4 @@ |
||||
package com.bingce.controlnetwork.event; |
||||
|
||||
public class RefreshToleranceTotailEvent { |
||||
} |
@ -1,352 +0,0 @@ |
||||
package com.bingce.controlnetwork.fragment; |
||||
|
||||
import android.os.Bundle; |
||||
import android.view.LayoutInflater; |
||||
import android.view.View; |
||||
import android.view.ViewGroup; |
||||
import android.widget.TextView; |
||||
|
||||
import androidx.annotation.NonNull; |
||||
import androidx.annotation.Nullable; |
||||
|
||||
import com.bingce.controlapphelper.datasource.database.SurveyorDatabaseFactory; |
||||
import com.bingce.controlapphelper.datasource.database.config.ConfigConstants; |
||||
import com.bingce.controlapphelper.datasource.database.config.ConfigRecord; |
||||
import com.bingce.controlapphelper.datasource.database.config.IConfigDataSource; |
||||
import com.bingce.controlapphelper.datasource.database.project.IProjectDataSource; |
||||
import com.bingce.controlapphelper.datasource.database.project.ProjectRecord; |
||||
import com.bingce.controlapphelper.datasource.database.surveyorcycle.SurveyorPeriodRecord; |
||||
import com.bingce.controlnetwork.guide.GuideSequence; |
||||
import com.bingce.controlnetwork.guide.ITapTargetProvider; |
||||
import com.bingce.utils.IOnSingleGetCallback; |
||||
import com.bingce.utils.ThreadPoolUtil; |
||||
|
||||
import java.util.List; |
||||
|
||||
import com.bingce.controlnetwork.R; |
||||
import com.bingce.controlnetwork.fragment.base.BaseFragment; |
||||
import com.bingce.controlnetwork.guide.GuideSequence; |
||||
import com.bingce.controlnetwork.guide.ITapTargetProvider; |
||||
|
||||
/** |
||||
* 主页面-测量 |
||||
*/ |
||||
public class SurveyorStationListFragment extends BaseFragment { |
||||
private final ComponentSurveyorStationListFragment fragment = ComponentSurveyorStationListFragment.newInstance("", "", false); |
||||
|
||||
private String projectId; |
||||
private String periodId; |
||||
private final GuideSequence guideSequence; |
||||
private final IConfigDataSource configDataSource = |
||||
SurveyorDatabaseFactory.instance.getConfigDataSource(); |
||||
private static final int GUIDE_INDEX_SWITCH_STATION = 0;//切换测站列表
|
||||
|
||||
public SurveyorStationListFragment() { |
||||
super(); |
||||
guideSequence = new GuideSequence(GUIDE_INDEX_SWITCH_STATION + 1, new GuideSequence.IDelegate() { |
||||
@Override |
||||
public void show(int index, ITapTargetProvider provider) { |
||||
if (GUIDE_INDEX_SWITCH_STATION == index) { |
||||
provider.show4View( |
||||
getActivity(), |
||||
findViewById(R.id.select), |
||||
getString(R.string.guide_switch_station_list), |
||||
getString(R.string.guide_switch_station_list_describe) |
||||
); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public void dismiss(int index) { |
||||
if (GUIDE_INDEX_SWITCH_STATION == index) { |
||||
ConfigConstants.markGuideCompleted(ConfigConstants.KEY_GUIDE_SWITCH_STATION_LIST, configDataSource); |
||||
} |
||||
} |
||||
}); |
||||
} |
||||
|
||||
@Nullable |
||||
@Override |
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { |
||||
return inflater.inflate(R.layout.fragment_project_surveyor_station_list_layout, container, false); |
||||
} |
||||
|
||||
@Override |
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { |
||||
super.onViewCreated(view, savedInstanceState); |
||||
|
||||
|
||||
SurveyorDatabaseFactory |
||||
.instance |
||||
.getConfigDataSource() |
||||
.getLiveDataByKey(ConfigConstants.KEY_DEFAULT_PROJECT_ID) |
||||
.observe(getViewLifecycleOwner(), onProjectIdCallback::onGet); |
||||
} |
||||
|
||||
@Override |
||||
public void onResume() { |
||||
super.onResume(); |
||||
refreshUI(); |
||||
} |
||||
|
||||
private final IOnSingleGetCallback<SurveyorPeriodRecord> onSurveyorCycleRecordCallback = new IOnSingleGetCallback<SurveyorPeriodRecord>() { |
||||
@Override |
||||
public void onGet(SurveyorPeriodRecord instance) { |
||||
if (instance == null) { |
||||
update(projectId, ""); |
||||
return; |
||||
} |
||||
periodId = instance.getId(); |
||||
|
||||
update(projectId, periodId); |
||||
} |
||||
}; |
||||
|
||||
private final IOnSingleGetCallback<ProjectRecord> onProjectRecordCallback = new IOnSingleGetCallback<ProjectRecord>() { |
||||
@Override |
||||
public void onGet(ProjectRecord instance) { |
||||
if (instance == null) { |
||||
update("", ""); |
||||
return; |
||||
} |
||||
projectId = instance.id; |
||||
SurveyorDatabaseFactory |
||||
.instance |
||||
.getSurveyorPeriod() |
||||
.getDefault(projectId, onSurveyorCycleRecordCallback); |
||||
} |
||||
}; |
||||
|
||||
/** |
||||
* 第一次获取到的测其id |
||||
*/ |
||||
private final IOnSingleGetCallback<ConfigRecord> onSurveyorCycleCallback = new IOnSingleGetCallback<ConfigRecord>() { |
||||
@Override |
||||
public void onGet(ConfigRecord instance) { |
||||
if (instance == null) { |
||||
SurveyorDatabaseFactory |
||||
.instance |
||||
.getProjectDataSource() |
||||
.getDefaultRecord(onProjectRecordCallback); |
||||
return; |
||||
} |
||||
periodId = instance.getConfigValue(); |
||||
|
||||
update(projectId, periodId); |
||||
} |
||||
}; |
||||
|
||||
/** |
||||
* 第一次获取到的默认项目id |
||||
*/ |
||||
private final IOnSingleGetCallback<ConfigRecord> onProjectIdCallback = new IOnSingleGetCallback<ConfigRecord>() { |
||||
@Override |
||||
public void onGet(ConfigRecord instance) { |
||||
if (instance == null) { |
||||
SurveyorDatabaseFactory |
||||
.instance |
||||
.getProjectDataSource() |
||||
.getDefaultRecord(onProjectRecordCallback); |
||||
return; |
||||
} |
||||
projectId = instance.getConfigValue(); |
||||
//project是否被删除
|
||||
if (projectId == null || projectId.isEmpty()) { |
||||
update("", ""); |
||||
return; |
||||
} |
||||
|
||||
SurveyorDatabaseFactory |
||||
.instance |
||||
.getConfigDataSource() |
||||
.getByKey(ConfigConstants.KEY_DEFAULT_PERIOD_ID, onSurveyorCycleCallback); |
||||
} |
||||
}; |
||||
|
||||
private void refreshUI() { |
||||
ThreadPoolUtil.execute(() -> { |
||||
//检测当前项目列表是否为空
|
||||
IProjectDataSource projectDataSource = |
||||
SurveyorDatabaseFactory.instance.getProjectDataSource(); |
||||
if (projectDataSource.recordCount() > 0 && !ConfigConstants.isGuideCompleted(ConfigConstants.KEY_GUIDE_SWITCH_STATION_LIST, configDataSource)) { |
||||
//当项目记录数大于0并且没有提示过的时候 进行引导提示
|
||||
runOnUI(() -> guideSequence.start(GUIDE_INDEX_SWITCH_STATION)); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
private void updateText(String projectName, String cycleName) { |
||||
View view = getView(); |
||||
if (view == null) { |
||||
return; |
||||
} |
||||
runOnUI(() -> { |
||||
View titleLayout = view.findViewById(R.id.title); |
||||
if (titleLayout != null && |
||||
projectName != null && !projectName.isEmpty() && |
||||
cycleName != null && !cycleName.isEmpty()) { |
||||
//当项目和测期都不为空的时候设置
|
||||
titleLayout.setVisibility(View.VISIBLE); |
||||
|
||||
TextView title = view.findViewById(R.id.titleView); |
||||
if (title != null && getContext() != null) { |
||||
String string = projectName + " > " + cycleName; |
||||
title.setText(string); |
||||
} |
||||
|
||||
titleLayout.setOnClickListener(onSwitchClickListener); |
||||
} else if (titleLayout != null) { |
||||
titleLayout.setVisibility(View.INVISIBLE); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
private final View.OnClickListener onSwitchClickListener = new View.OnClickListener() { |
||||
@Override |
||||
public void onClick(View v) { |
||||
//去选择项目和测期
|
||||
// SelectProjectAndSurveyorCycleFragment.select(
|
||||
// getChildFragmentManager(),
|
||||
// getViewLifecycleOwner(),
|
||||
// projectId,
|
||||
// cycleIndex,
|
||||
// (pId, pName, cycleId, cycleName) -> {
|
||||
// //刷新数据
|
||||
// projectId = pId;
|
||||
// cycleIndex = cycleId;
|
||||
// //保存默认值
|
||||
// IConfigDataSource configDataSource =
|
||||
// SurveyorDatabaseFactory
|
||||
// .instance
|
||||
// .getConfigDataSource();
|
||||
// //数据存储
|
||||
// configDataSource.set(ConfigConstants.KEY_DEFAULT_PROJECT_ID, projectId);
|
||||
// configDataSource.set(ConfigConstants.KEY_DEFAULT_CYCLE_ID, cycleIndex);
|
||||
//
|
||||
// updateText(pName, cycleName);
|
||||
// fragment.update(pId, cycleId);
|
||||
// });
|
||||
|
||||
// BottomPageFragment.showBottom(getChildFragmentManager(), getViewLifecycleOwner(),
|
||||
// selectData,
|
||||
// selectData -> {
|
||||
//
|
||||
// });
|
||||
} |
||||
}; |
||||
|
||||
// private IData selectData = new IData() {
|
||||
//
|
||||
// @Nullable
|
||||
// @Override
|
||||
// public Object getData(@Nullable BottomBean bottomBean, @NonNull Continuation<? super List<? extends BottomBean>> $completion) {
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public String getTitle(int pageIndex) {
|
||||
// if (pageIndex == 0) {
|
||||
// return "请选择项目";
|
||||
// } else if (pageIndex == 1) {
|
||||
// return "请选择测期";
|
||||
// }
|
||||
// return "";
|
||||
// }
|
||||
|
||||
// @Nullable
|
||||
// @Override
|
||||
// public List<BottomBean> getData(@Nullable BottomBean bottomBean) {
|
||||
// List<BottomBean> dataList = new ArrayList<>();
|
||||
// if (bottomBean == null) {
|
||||
// List<ProjectRecord> projectRecords = SurveyorDatabaseFactory
|
||||
// .instance
|
||||
// .getProjectDataSource()
|
||||
// .getDataList();
|
||||
//
|
||||
// for (ProjectRecord projectRecord : projectRecords) {
|
||||
// dataList.add(new BottomBean(projectRecord.getId(), projectRecord.getProjectName(),
|
||||
// 0, false, null));
|
||||
// }
|
||||
//
|
||||
// } else {
|
||||
// if (bottomBean.getPageIndex() == 0) {
|
||||
//
|
||||
// List<SurveyorPeriodRecord> periodRecords = SurveyorDatabaseFactory.instance
|
||||
// .getSurveyorPeriod().getDataListSyncByProjectId(bottomBean.getId());
|
||||
//
|
||||
// for (SurveyorPeriodRecord projectRecord : periodRecords) {
|
||||
// dataList.add(new BottomBean(projectRecord.getId(), projectRecord.getName(),
|
||||
// 1, false, null));
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return dataList;
|
||||
// }
|
||||
|
||||
// };
|
||||
|
||||
/** |
||||
* @param projectId |
||||
* @param periodId |
||||
*/ |
||||
private void update(final String projectId, final String periodId) { |
||||
if (fragment == null) { |
||||
return; |
||||
} |
||||
View view = getView(); |
||||
if (view == null) { |
||||
return; |
||||
} |
||||
ThreadPoolUtil.execute(() -> { |
||||
String projectName = ""; |
||||
String cycleName = ""; |
||||
ProjectRecord projectRecord = |
||||
SurveyorDatabaseFactory |
||||
.instance |
||||
.getProjectDataSource() |
||||
.getRecord(projectId); |
||||
if (projectRecord != null) { |
||||
projectName = projectRecord.getProjectName(); |
||||
} |
||||
SurveyorPeriodRecord periodRecord = |
||||
SurveyorDatabaseFactory |
||||
.instance |
||||
.getSurveyorPeriod() |
||||
.getRecord(periodId); |
||||
if (periodRecord == null) { |
||||
//获取第一个测期
|
||||
List<SurveyorPeriodRecord> records = SurveyorDatabaseFactory |
||||
.instance |
||||
.getSurveyorPeriod() |
||||
.getDataListSyncByProjectId(projectId); |
||||
if (!records.isEmpty()) { |
||||
periodRecord = records.get(0); |
||||
} |
||||
} |
||||
if (periodRecord != null) { |
||||
cycleName = periodRecord.getName(); |
||||
this.periodId = periodRecord.getId(); |
||||
} |
||||
updateText(projectName, cycleName); |
||||
|
||||
this.projectId = projectId; |
||||
|
||||
fragment.update(this.projectId, this.periodId); |
||||
}); |
||||
} |
||||
|
||||
public static SurveyorStationListFragment newInstance() { |
||||
return new SurveyorStationListFragment(); |
||||
} |
||||
|
||||
private void switchContentFragment() { |
||||
getChildFragmentManager() |
||||
.beginTransaction() |
||||
.replace(R.id.fragment_container, fragment, "___station_list") |
||||
.commit(); |
||||
} |
||||
|
||||
|
||||
} |
@ -0,0 +1,145 @@ |
||||
package com.bingce.controlnetwork.func.level.activity |
||||
|
||||
import android.content.Context |
||||
import android.content.Intent |
||||
import android.view.Menu |
||||
import android.view.MenuItem |
||||
import androidx.activity.viewModels |
||||
import androidx.fragment.app.Fragment |
||||
import androidx.fragment.app.FragmentManager |
||||
import androidx.fragment.app.FragmentStatePagerAdapter |
||||
import androidx.viewpager.widget.ViewPager.OnPageChangeListener |
||||
import com.bingce.controlnetwork.func.level.fragment.LevelStationSettingConditionFragment |
||||
import com.bingce.controlnetwork.func.level.fragment.LevelStationSettingInformationFragment |
||||
import com.bingce.controlnetwork.func.level.viewmodel.LevelStationSettingVm |
||||
import com.bingce.controlapphelper.model.BundleConstants |
||||
import com.bingce.controlnetwork.R |
||||
import com.bingce.controlnetwork.databinding.ActivityLevelStationSettingBinding |
||||
import com.bingce.controlnetwork.newui.base.BaseBindingActivity |
||||
import com.bingce.controlnetwork.newui.stationsetting.IStationSettingOperate |
||||
|
||||
class LevelStationSettingActivity : BaseBindingActivity<ActivityLevelStationSettingBinding>() { |
||||
|
||||
private val viewModel by viewModels<LevelStationSettingVm>() |
||||
private val fragments = mutableListOf<Fragment>() |
||||
private val fragmentTitleList = listOf("观测信息", "观测条件") |
||||
|
||||
companion object { |
||||
private const val KEY_IS_SAVE_END_STATION = "KEY_IS_SAVE_END_STATION" |
||||
|
||||
@JvmStatic |
||||
fun start(context: Context, routeId: String, stationId: String, isSaveEndStation: Boolean) { |
||||
context.startActivity(Intent(context, LevelStationSettingActivity::class.java).apply { |
||||
putExtra(BundleConstants.KEY_ROUTE_ID, routeId) |
||||
putExtra(BundleConstants.KEY_SURVEYOR_STATION_ID, stationId) |
||||
putExtra(KEY_IS_SAVE_END_STATION, isSaveEndStation) |
||||
}) |
||||
} |
||||
} |
||||
|
||||
|
||||
override fun getBinding(): ActivityLevelStationSettingBinding { |
||||
return ActivityLevelStationSettingBinding.inflate(layoutInflater) |
||||
} |
||||
|
||||
override fun initView() { |
||||
viewModel.initRouteStationId(getRouteId(), getStationId()) |
||||
initViewPager() |
||||
} |
||||
|
||||
override fun initData() { |
||||
viewModel.getEditLastData(getStationId()) |
||||
|
||||
viewModel.getInitCurrentTabPos { |
||||
mBinding.tabLayout.currentTab = it |
||||
} |
||||
} |
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu?): Boolean { |
||||
menuInflater.inflate(R.menu.menu_confirm, menu) |
||||
return super.onCreateOptionsMenu(menu) |
||||
} |
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean { |
||||
if (R.id.menu_confirm == item.itemId) { |
||||
doConfirm() |
||||
} |
||||
return super.onOptionsItemSelected(item) |
||||
} |
||||
|
||||
private fun initViewPager() { |
||||
fragments.add(LevelStationSettingInformationFragment()) |
||||
fragments.add(LevelStationSettingConditionFragment()) |
||||
mBinding.vp.offscreenPageLimit = 3 |
||||
mBinding.vp.adapter = MyPagerAdapter(supportFragmentManager) |
||||
mBinding.tabLayout.setViewPager(mBinding.vp) |
||||
mBinding.vp.addOnPageChangeListener(object : OnPageChangeListener { |
||||
override fun onPageScrolled( |
||||
position: Int, |
||||
positionOffset: Float, |
||||
positionOffsetPixels: Int |
||||
) { |
||||
} |
||||
|
||||
override fun onPageSelected(position: Int) { |
||||
|
||||
} |
||||
|
||||
override fun onPageScrollStateChanged(state: Int) { |
||||
|
||||
} |
||||
}) |
||||
|
||||
// //设置当前tab为仪高镜高 |
||||
// mBinding.vp.currentItem = 1 |
||||
} |
||||
|
||||
|
||||
private inner class MyPagerAdapter(fm: FragmentManager) : FragmentStatePagerAdapter(fm) { |
||||
override fun getCount(): Int { |
||||
return fragments.size |
||||
} |
||||
|
||||
override fun getPageTitle(position: Int): CharSequence { |
||||
return fragmentTitleList[position] |
||||
} |
||||
|
||||
override fun getItem(position: Int): Fragment { |
||||
return fragments[position] |
||||
} |
||||
|
||||
override fun getItemPosition(`object`: Any): Int { |
||||
return POSITION_NONE |
||||
} |
||||
} |
||||
|
||||
private fun doConfirm() { |
||||
//检查未完成的选项 |
||||
for (fragment in fragments) { |
||||
val operate = fragment as IStationSettingOperate |
||||
if (operate.checkSaveNot()) { |
||||
val fragmentNotFinishPos = fragments.indexOf(fragment) |
||||
if (mBinding.vp.currentItem != fragmentNotFinishPos) { |
||||
mBinding.tabLayout.currentTab = fragmentNotFinishPos |
||||
} |
||||
return |
||||
} |
||||
} |
||||
|
||||
viewModel.createNeedSaveLevelRouteSave(getRouteId(), getStationId()) |
||||
//赋值 |
||||
for (fragment in fragments) { |
||||
val operate = fragment as IStationSettingOperate |
||||
operate.setDataToStation() |
||||
} |
||||
|
||||
viewModel.save(getIsSaveEndStation()) { |
||||
finish() |
||||
} |
||||
} |
||||
|
||||
private fun getStationId() = intent.getStringExtra(BundleConstants.KEY_SURVEYOR_STATION_ID)!! |
||||
|
||||
private fun getRouteId() = intent.getStringExtra(BundleConstants.KEY_ROUTE_ID)!! |
||||
private fun getIsSaveEndStation() = intent.getBooleanExtra(KEY_IS_SAVE_END_STATION, false) |
||||
} |
@ -0,0 +1,38 @@ |
||||
package com.bingce.controlnetwork.func.level.adapter; |
||||
|
||||
|
||||
import android.content.Context; |
||||
import android.view.ViewGroup; |
||||
|
||||
import androidx.annotation.NonNull; |
||||
|
||||
import com.bingce.controlapphelper.datasource.database.leveling.route.LevelRouteRecord; |
||||
import com.bingce.controlapphelper.model.LevelingMeasureOrderUtil; |
||||
|
||||
import com.bingce.controlnetwork.databinding.ItemLevelRouteListBinding; |
||||
import com.bingce.controlnetwork.newui.adapter.BaseAdapterNew; |
||||
|
||||
|
||||
public class LevelRouteListAdapter extends BaseAdapterNew<LevelRouteListViewHolder, LevelRouteRecord> { |
||||
|
||||
public LevelRouteListAdapter(Context context) { |
||||
super(context); |
||||
} |
||||
|
||||
@NonNull |
||||
@Override |
||||
public LevelRouteListViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { |
||||
return new LevelRouteListViewHolder(ItemLevelRouteListBinding.inflate(getInflater(), parent, false)); |
||||
} |
||||
|
||||
@Override |
||||
protected void onBindViewHolderDo(LevelRouteListViewHolder holder, int position) { |
||||
LevelRouteRecord bean = mDataList.get(position); |
||||
holder.mBinding.tvIndex.setText(String.valueOf(position + 1)); |
||||
holder.mBinding.tvRouteName.setText(bean.getRouteName()); |
||||
holder.mBinding.tvOrderType.setText(LevelingMeasureOrderUtil.INSTANCE.getTextByLevelingMeasureOrder(bean.getLevelingMeasureOrder())); |
||||
holder.mBinding.tvWay.setText(bean.getObservationDirection()); |
||||
} |
||||
|
||||
|
||||
} |
@ -0,0 +1,15 @@ |
||||
package com.bingce.controlnetwork.func.level.adapter; |
||||
|
||||
import androidx.recyclerview.widget.RecyclerView; |
||||
|
||||
import com.bingce.controlnetwork.databinding.ItemLevelRouteListBinding; |
||||
|
||||
|
||||
public class LevelRouteListViewHolder extends RecyclerView.ViewHolder { |
||||
public final ItemLevelRouteListBinding mBinding; |
||||
|
||||
public LevelRouteListViewHolder(ItemLevelRouteListBinding binding) { |
||||
super(binding.getRoot()); |
||||
mBinding = binding; |
||||
} |
||||
} |
@ -0,0 +1,13 @@ |
||||
package cn.liuyanbing.surveyor.function.level.constant |
||||
|
||||
/** |
||||
* 水准常量 |
||||
*/ |
||||
object LevelConstant { |
||||
/** |
||||
* 默认经纬度郑州 |
||||
*/ |
||||
const val LONGITUDE_DEFAULT = 113.6482317 |
||||
const val LATITUDE_DEFAULT = 34.7492133 |
||||
const val HEIGHT_DEFAULT = 0.0 |
||||
} |
@ -0,0 +1,55 @@ |
||||
package com.bingce.controlnetwork.func.level.constant |
||||
|
||||
import com.bingce.controlapphelper.util.Tools |
||||
import com.bingce.controlnetwork.R |
||||
|
||||
object LevelStationSettingContant { |
||||
val observationDirectionList = listOf("往测", "返测", "检往", "检返", "重往", "重返") |
||||
val weatherList = listOf("晴", "阴", "雨", "雪") |
||||
val imagingList = |
||||
listOf("清晰", "小雾", "中雾", "大雾") |
||||
val sunDirectionList = |
||||
listOf("无太阳", "前", "后", "左", "右") |
||||
val windDirectionList = |
||||
listOf( |
||||
"无", |
||||
"东", |
||||
"南", |
||||
"西", |
||||
"北", |
||||
"东南", |
||||
"西南", |
||||
"东北", |
||||
"西北" |
||||
) |
||||
val windSpeedList = |
||||
listOf( |
||||
"无", |
||||
"0级无风", |
||||
"1级软风", |
||||
"2级轻风", |
||||
"3级微风", |
||||
"4级和风", |
||||
"5级清劲风", |
||||
"6级强风", |
||||
"7级疾风", |
||||
"8级大风" |
||||
) |
||||
val roadsList = |
||||
listOf( |
||||
Tools.getString(R.string.please_choose), |
||||
"柏油路", "水泥路", "土路", "砂石路", "铁路", "其他" |
||||
) |
||||
|
||||
val soilList = |
||||
listOf( |
||||
Tools.getString(R.string.please_choose), |
||||
"柏油", "水泥", "实土", "沙石", "草地" |
||||
) |
||||
|
||||
val rulerTypeList = listOf("铟瓦尺", "木质", "其他") |
||||
|
||||
//尺承类型 |
||||
val rulerReceptTypeList = |
||||
listOf("钢尺桩", "5kg以上尺台", "不足5kg尺台", "钢帽钉", "木桩", "其他") |
||||
} |
@ -0,0 +1,129 @@ |
||||
package com.bingce.controlnetwork.func.level.dialog; |
||||
|
||||
import static com.bingce.controlapphelper.model.LevelToleranceNoticeKt.VALUE_IGNORE; |
||||
import static com.bingce.controlapphelper.model.LevelToleranceNoticeKt.VALUE_REMEASURE_POINT; |
||||
import static com.bingce.controlapphelper.model.LevelToleranceNoticeKt.VALUE_REMEASURE_STATION; |
||||
|
||||
import android.app.Dialog; |
||||
import android.os.Bundle; |
||||
import android.view.LayoutInflater; |
||||
import android.view.View; |
||||
import android.view.ViewGroup; |
||||
import android.view.WindowManager; |
||||
import android.widget.TextView; |
||||
|
||||
import androidx.annotation.NonNull; |
||||
import androidx.annotation.Nullable; |
||||
import androidx.appcompat.app.AppCompatDialogFragment; |
||||
import androidx.fragment.app.FragmentManager; |
||||
import androidx.lifecycle.LifecycleOwner; |
||||
|
||||
import com.bingce.controlnetwork.R; |
||||
|
||||
/** |
||||
* 水准限差超限提示框 |
||||
*/ |
||||
public class LevelToleranceTipsFragment extends AppCompatDialogFragment { |
||||
|
||||
private static final String KEY_TITLE = "__TITLE"; |
||||
private static final String KEY_CONTENT = "___CONTENT"; |
||||
private static final String KEY_RESULT = "KEY_RESULT"; |
||||
private static final String KEY_BUNDLE = "KEY_BUNDLE"; |
||||
|
||||
private static final String TAG = LevelToleranceTipsFragment.class.getName(); |
||||
|
||||
public static void tips(@NonNull FragmentManager fragmentManager, |
||||
@NonNull LifecycleOwner lifecycleOwner, |
||||
String title, |
||||
String content, |
||||
IOperatorCallback callback) { |
||||
Bundle args = new Bundle(); |
||||
LevelToleranceTipsFragment fragment = new LevelToleranceTipsFragment(); |
||||
fragment.setArguments(args); |
||||
args.putString(KEY_TITLE, title); |
||||
args.putString(KEY_CONTENT, content); |
||||
fragmentManager |
||||
.setFragmentResultListener( |
||||
KEY_BUNDLE, |
||||
lifecycleOwner, |
||||
(requestKey, result) -> { |
||||
int type = result.getInt(KEY_RESULT, -1); |
||||
if (VALUE_IGNORE == type) { |
||||
callback.onIgnore(); |
||||
} else if (VALUE_REMEASURE_STATION == type) { |
||||
callback.onReMeasureStation(); |
||||
} else if (VALUE_REMEASURE_POINT == type) { |
||||
callback.onReMeasurePoint(); |
||||
} |
||||
}); |
||||
fragment.show(fragmentManager, TAG); |
||||
} |
||||
|
||||
public interface IOperatorCallback { |
||||
void onReMeasureStation(); |
||||
|
||||
void onReMeasurePoint(); |
||||
|
||||
void onIgnore(); |
||||
} |
||||
|
||||
@Nullable |
||||
@Override |
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { |
||||
View contentView = inflater.inflate(R.layout.fragment_level_tolerance_tips, container, false); |
||||
|
||||
TextView tvTitle = contentView.findViewById(R.id.tvTitle); |
||||
tvTitle.setText(getTitle()); |
||||
TextView tvContent = contentView.findViewById(R.id.tvContent); |
||||
tvContent.setText(getContent()); |
||||
|
||||
contentView.findViewById(R.id.btnIgnore).setOnClickListener(v -> { |
||||
setBackResult(VALUE_IGNORE); |
||||
}); |
||||
contentView.findViewById(R.id.btnRemeasureStation).setOnClickListener(v -> { |
||||
setBackResult(VALUE_REMEASURE_STATION); |
||||
}); |
||||
contentView.findViewById(R.id.btnRemeasureCurrent).setOnClickListener(v -> { |
||||
setBackResult(VALUE_REMEASURE_POINT); |
||||
}); |
||||
return contentView; |
||||
} |
||||
|
||||
private void setBackResult(int clickType) { |
||||
Bundle bundle = new Bundle(); |
||||
bundle.putInt(KEY_RESULT, clickType); |
||||
getParentFragmentManager().setFragmentResult(KEY_BUNDLE, bundle); |
||||
//关闭dialog
|
||||
dismissAllowingStateLoss(); |
||||
} |
||||
|
||||
@Override |
||||
public void onStart() { |
||||
super.onStart(); |
||||
Dialog dialog = getDialog(); |
||||
if (dialog == null) { |
||||
return; |
||||
} |
||||
dialog.getWindow().setLayout( |
||||
WindowManager.LayoutParams.MATCH_PARENT, |
||||
WindowManager.LayoutParams.WRAP_CONTENT); |
||||
} |
||||
|
||||
private String getTitle() { |
||||
Bundle arguments = getArguments(); |
||||
if (arguments != null) { |
||||
return arguments.getString(KEY_TITLE); |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
private String getContent() { |
||||
Bundle arguments = getArguments(); |
||||
if (arguments != null) { |
||||
return arguments.getString(KEY_CONTENT); |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
|
||||
} |
@ -0,0 +1,231 @@ |
||||
package cn.liuyanbing.surveyor.function.level.export |
||||
|
||||
import android.util.Log |
||||
import androidx.annotation.WorkerThread |
||||
import com.bingce.controlapphelper.datasource.database.leveling.LevelingDbFactory |
||||
import com.bingce.controlapphelper.datasource.database.leveling.idetection.constants.LevelIDetectionConstant |
||||
import com.bingce.controlapphelper.datasource.database.leveling.idetection.list.LevelIDetectionList |
||||
import com.bingce.controlapphelper.datasource.database.leveling.idetection.record.LevelIDetectionRecord |
||||
import com.bingce.controlapphelper.leveling.detaction.LevelFormatUtil |
||||
import com.bingce.controlapphelper.model.getLength |
||||
import com.bingce.controlnetwork.func.level.util.LevelDateUtil |
||||
import com.bingce.controlnetwork.func.level.util.LevelDateUtil.getLevelHeadDateHourMin |
||||
|
||||
/** |
||||
* i角检测导出 |
||||
*/ |
||||
class LevelExportIDetection { |
||||
|
||||
private var levelNoIndex = 0 |
||||
|
||||
companion object { |
||||
const val _N = "\r\n" |
||||
const val _S = "\u0020" |
||||
const val LEVEL_NO = "LEVEL|No" |
||||
const val TO = "TO" |
||||
const val INF = "INF" |
||||
const val SHU = "|" |
||||
const val CHECK_RECORD_SIZE = 20 |
||||
} |
||||
|
||||
|
||||
@WorkerThread |
||||
fun export(iDetection: LevelIDetectionList): String? { |
||||
val recordList = |
||||
LevelingDbFactory.instance.iDetectionRecordDataSource.getRecordsByIDetectionId( |
||||
iDetection.id |
||||
) |
||||
|
||||
if (recordList.isEmpty() || recordList.size != CHECK_RECORD_SIZE) { |
||||
return null |
||||
} |
||||
if (iDetection.iResult == null) { |
||||
return null |
||||
} |
||||
if (iDetection.shortDistance == null || iDetection.longDistance == null |
||||
|| iDetection.measureType == null |
||||
) { |
||||
return null |
||||
} |
||||
val firstRecordCreateDate = recordList.first().createDate |
||||
val dateYMD = |
||||
LevelDateUtil.getLevelHeadDateYearMonthDay(firstRecordCreateDate) |
||||
val dateHM = getLevelHeadDateHourMin(firstRecordCreateDate) |
||||
|
||||
val settting = |
||||
LevelingDbFactory.instance.iDetectionSettingDataSource.getByIDetectionId(iDetection.id) |
||||
|
||||
val sb = StringBuilder() |
||||
|
||||
//startI |
||||
sb.append(LEVEL_NO).append(getLevelNoRightSpace()).append(getNoIndexName()).append(SHU) |
||||
.append(TO).append(getSpace2()).append("Start-I").append(getSpace10()) |
||||
.append(iDetection.measureType).append(SHU).append(getSpace30()).append(SHU) |
||||
.append(getSpace30()).append(SHU).append(getSpace30()).append(SHU) |
||||
.append(_N) |
||||
|
||||
levelNoIndexIncrease() |
||||
|
||||
//i角检测的设置 |
||||
appendSetting(sb, "instrumentModel", toString(settting.instrumentModel)) |
||||
appendSetting(sb, "deviceNumber", "No.${toString(settting.deviceNumber)}") |
||||
appendSetting(sb, "dateYMD", dateYMD) |
||||
appendSetting(sb, "dateHM", dateHM) |
||||
appendSetting(sb, "rulerNum1", toString(settting.rulerNum1)) |
||||
appendSetting(sb, "rulerNum2", toString(settting.rulerNum2)) |
||||
appendSetting(sb, "imaging", toString(settting.imaging)) |
||||
appendSetting(sb, "watcher", toString(settting.watcher)) |
||||
appendSetting(sb, "recorder", toString(settting.recorder)) |
||||
appendSetting(sb, "examiner", toString(settting.examiner)) |
||||
//D1 D2 |
||||
appendD1D2(sb, "D1", iDetection.shortDistance) |
||||
appendD1D2(sb, "D2", iDetection.longDistance) |
||||
|
||||
//先排个序 |
||||
recordList.sortWith( |
||||
Comparator.comparing(LevelIDetectionRecord::stationType) |
||||
.thenComparing(LevelIDetectionRecord::rulerType) |
||||
.thenComparing(LevelIDetectionRecord::measureTime) |
||||
) |
||||
for (record in recordList) { |
||||
Log.d( |
||||
"hwhw", |
||||
"" + record.stationType + "," + record.rulerType + "," + record.measureTime |
||||
) |
||||
appendRecord(sb, record) |
||||
} |
||||
//iResult |
||||
val iResultUnit = if (iDetection.iResult != null) { |
||||
"${iDetection.iResult} s" |
||||
} else { |
||||
"" |
||||
} |
||||
val spaceIResultLeft = getSpace(30 - 4 - iResultUnit.length - 1) |
||||
sb.append(LEVEL_NO).append(getLevelNoRightSpace()).append(getNoIndexName()).append(SHU) |
||||
.append("I").append(getSpace(29)).append(SHU) |
||||
.append(getSpace30()).append(SHU) |
||||
.append(getSpace30()).append(SHU) |
||||
.append("I").append(spaceIResultLeft).append(iResultUnit).append(getSpace4()) |
||||
.append(SHU) |
||||
.append(_N) |
||||
levelNoIndexIncrease() |
||||
//endI |
||||
sb.append(LEVEL_NO).append(getLevelNoRightSpace()).append(getNoIndexName()).append(SHU) |
||||
.append(TO).append(getSpace(4)).append("End-I").append(getSpace(19)).append(SHU) |
||||
.append(getSpace30()).append(SHU) |
||||
.append(getSpace30()).append(SHU) |
||||
.append(getSpace30()).append(SHU) |
||||
.append(_N) |
||||
|
||||
return sb.toString() |
||||
} |
||||
|
||||
private fun levelNoIndexIncrease() { |
||||
levelNoIndex++ |
||||
} |
||||
|
||||
private fun appendRecord(sb: StringBuilder, record: LevelIDetectionRecord) { |
||||
val hourMinSec = LevelDateUtil.getHourMinSec(record.createDate) |
||||
|
||||
val height = LevelFormatUtil.formatHeight(record.height) |
||||
val distance = LevelFormatUtil.formatDistance(record.distance) |
||||
val heightUnit = "$height m" |
||||
val distanceUnit = "$distance m" |
||||
|
||||
val space2 = getSpace2() |
||||
val spaceHeightLeft = getSpace(24 - 2 - heightUnit.length) |
||||
val spaceDistanceLeft = getSpace(28 - 2 - distanceUnit.length) |
||||
|
||||
sb.append(LEVEL_NO).append(getLevelNoRightSpace()).append(getNoIndexName()).append(SHU) |
||||
.append("KD1").append(getSpace10()).append("${record.measureTime + 1}") |
||||
.append(getSpace8()).append(hourMinSec).append(SHU) |
||||
.append(getRI1A(record)).append(spaceHeightLeft).append(heightUnit).append(space2) |
||||
.append(SHU) |
||||
.append("HD").append(spaceDistanceLeft).append(distanceUnit).append(space2).append(SHU) |
||||
.append(getSpace30()).append(SHU) |
||||
.append(_N) |
||||
|
||||
levelNoIndexIncrease() |
||||
} |
||||
|
||||
private fun getRI1A(record: LevelIDetectionRecord): String { |
||||
return if (record.stationType == LevelIDetectionConstant.STATION_TYPE_0) { |
||||
if (record.rulerType == LevelIDetectionConstant.RULER_TYPE_0) { |
||||
"R_I1_A" |
||||
} else { |
||||
"R_I1_B" |
||||
} |
||||
} else { |
||||
if (record.rulerType == LevelIDetectionConstant.RULER_TYPE_0) { |
||||
"R_I2_A" |
||||
} else { |
||||
"R_I2_B" |
||||
} |
||||
} |
||||
} |
||||
|
||||
private fun appendD1D2(sb: StringBuilder, d1: String, d1Value: String) { |
||||
val d1ValueFormat = LevelFormatUtil.formatHeight(toDouble(d1Value)) |
||||
val d1ValueUnit = "$d1ValueFormat m" |
||||
|
||||
val d1ValueUnitLength = d1ValueUnit.length |
||||
|
||||
val spaceValueLeft = getSpace(30 - 4 - d1ValueUnitLength - 1) |
||||
val spaceValueRight = getSpace4() |
||||
|
||||
sb.append(LEVEL_NO).append(getLevelNoRightSpace()).append(getNoIndexName()).append(SHU) |
||||
.append(d1).append(getSpace28()).append(SHU) |
||||
.append(getSpace30()).append(SHU) |
||||
.append(getSpace30()).append(SHU) |
||||
.append("D").append(spaceValueLeft).append(d1ValueUnit).append(spaceValueRight) |
||||
.append(SHU) |
||||
.append(_N) |
||||
levelNoIndexIncrease() |
||||
} |
||||
|
||||
private fun appendSetting(sb: StringBuilder, key: String, value: String) { |
||||
sb.append(LEVEL_NO).append(getLevelNoRightSpace()).append(getNoIndexName()).append(SHU) |
||||
.append(INF).append(getSpace27()).append(SHU) |
||||
.append(key).append(getSettingKeyRightSpace(key)).append(SHU) |
||||
.append(getSpace30()).append(SHU) |
||||
.append(value).append(getSettingValueRightSpace(value)).append(SHU) |
||||
.append(_N) |
||||
levelNoIndexIncrease() |
||||
} |
||||
|
||||
private fun getLevelNoRightSpace(): String { |
||||
val length = getNoIndexName().length |
||||
return getSpace(8 - length) |
||||
} |
||||
|
||||
private fun getSettingKeyRightSpace(key: String): String { |
||||
val length = key.length |
||||
return getSpace(30 - length) |
||||
} |
||||
|
||||
private fun getSettingValueRightSpace(value: String): String { |
||||
val length = getLength(value) |
||||
return getSpace(30 - length) |
||||
} |
||||
|
||||
private fun getNoIndexName() = "${levelNoIndex + 1}" |
||||
|
||||
|
||||
private fun getSpace2() = getSpace(2) |
||||
private fun getSpace4() = getSpace(4) |
||||
private fun getSpace8() = getSpace(8) |
||||
private fun getSpace10() = getSpace(10) |
||||
private fun getSpace27() = getSpace(27) |
||||
private fun getSpace28() = getSpace(28) |
||||
|
||||
private fun getSpace30() = getSpace(30) |
||||
|
||||
private fun getSpace(size: Int) = _S.repeat(size) |
||||
|
||||
private fun toString(value: String?) = value ?: "" |
||||
private fun toDouble(value: String?): Double { |
||||
return value?.toDouble() ?: 0.0 |
||||
} |
||||
|
||||
|
||||
} |
@ -0,0 +1,218 @@ |
||||
package com.bingce.controlnetwork.func.level.export |
||||
|
||||
import android.text.TextUtils |
||||
import androidx.annotation.WorkerThread |
||||
import com.bingce.controlapphelper.datasource.database.SurveyorDatabaseFactory |
||||
import com.bingce.controlapphelper.datasource.database.leveling.LevelingDbFactory |
||||
import com.bingce.controlapphelper.datasource.database.leveling.stationsetting.LevelingStationSettingRecord |
||||
import com.bingce.controlapphelper.datasource.database.point.PointRecord |
||||
import com.bingce.controlapphelper.leveling.detaction.LevelFormatUtil |
||||
import com.bingce.controlapphelper.model.LevelingMeasureOrder |
||||
import com.bingce.controlapphelper.model._N |
||||
import com.bingce.controlapphelper.model._S |
||||
import com.bingce.controlapphelper.model._T |
||||
import com.bingce.controlapphelper.surveyor.method.ExportStationMethod |
||||
import com.bingce.controlapphelper.surveyor.method.model.MeasureConstant |
||||
import java.io.File |
||||
|
||||
class LevelExportSingalHeight { |
||||
private var routeIndex = 0 |
||||
|
||||
private val singalHeightSb = StringBuilder() |
||||
private val rulerLengthSb = StringBuilder() |
||||
private val pointNumNameSb = StringBuilder() |
||||
private val heightDistanceSb = StringBuilder() |
||||
private val pointKnownSb = StringBuilder() |
||||
|
||||
|
||||
@WorkerThread |
||||
fun export(projectFolder: File, projectId: String) { |
||||
collectRulerLength(projectId) |
||||
collectPoint(projectId) |
||||
collectSingalHeight(projectId) |
||||
|
||||
val prepare4Folder = initPrepare4Folder(projectFolder) |
||||
|
||||
saveData(projectFolder, singalHeightSb, "SingalHeight.txt") |
||||
saveData(prepare4Folder, rulerLengthSb, "尺长.txt") |
||||
saveData(prepare4Folder, pointNumNameSb, "点名点号.txt") |
||||
saveData(prepare4Folder, heightDistanceSb, "高差文件.txt") |
||||
saveData(prepare4Folder, pointKnownSb, "已知.txt") |
||||
} |
||||
|
||||
private fun saveData(projectFolder: File, data: StringBuilder, fileName: String) { |
||||
if (data.isNotEmpty()) { |
||||
ExportStationMethod.save( |
||||
data.toString(), |
||||
projectFolder, |
||||
fileName |
||||
) |
||||
} |
||||
} |
||||
|
||||
private fun collectSingalHeight(projectId: String) { |
||||
val routeList = LevelingDbFactory.instance.levelDataSource.getByProjectIdSync(projectId) |
||||
|
||||
for (route in routeList) { |
||||
|
||||
val routeId = route.getId() |
||||
|
||||
val pointNameStart = getPointName(route.startPointId) |
||||
val pointNameEnd = getPointName(route.endPointId) |
||||
|
||||
val levelingMeasureOrder = route.levelingMeasureOrder |
||||
val isHasTwiceStation = when (levelingMeasureOrder) { |
||||
LevelingMeasureOrder.SIM_BF, |
||||
LevelingMeasureOrder.SIM_BFFB -> { |
||||
true |
||||
} |
||||
|
||||
else -> false |
||||
} |
||||
|
||||
val routeLastStationSetting = |
||||
LevelingDbFactory.instance.stationSettingDataSource.getLatest(routeId) |
||||
|
||||
appendData( |
||||
projectId, |
||||
routeId, |
||||
pointNameStart, |
||||
pointNameEnd, |
||||
false, |
||||
routeLastStationSetting |
||||
) |
||||
if (isHasTwiceStation) { |
||||
appendData( |
||||
projectId, |
||||
routeId, |
||||
pointNameStart, |
||||
pointNameEnd, |
||||
true, |
||||
routeLastStationSetting |
||||
) |
||||
} |
||||
} |
||||
|
||||
heightDistanceSb.append("END") |
||||
} |
||||
|
||||
/** |
||||
* 点名点号 |
||||
* 已知点 |
||||
*/ |
||||
private fun collectPoint(projectId: String) { |
||||
val pointList = SurveyorDatabaseFactory.instance.pointDataSource.findByProjectIdSync(projectId) |
||||
for (point in pointList) { |
||||
if (PointRecord.TYPE_KNOWN_POINT == point.pointType) { |
||||
pointKnownSb.append(point.getName()).append(_S).append(point.getZFormat(4)) |
||||
} |
||||
pointNumNameSb.append(point.getName()).append(_S).append("") |
||||
.append(_N) |
||||
} |
||||
pointNumNameSb.append("END") |
||||
pointKnownSb.append("END") |
||||
} |
||||
|
||||
/** |
||||
* 收集尺长 |
||||
*/ |
||||
private fun collectRulerLength(projectId: String) { |
||||
val routeList = SurveyorDatabaseFactory.instance.pointDataSource.findByProjectIdSync(projectId) |
||||
for (route in routeList) { |
||||
val latest = LevelingDbFactory.instance.stationSettingDataSource.getLatest(route.id) |
||||
|
||||
val rulerCorrectionFactor = if (!TextUtils.isEmpty(latest.rulerCorrectionFactor)) { |
||||
"${latest.rulerCorrectionFactor.toDouble() / 1000}" |
||||
} else { |
||||
"0" |
||||
} |
||||
|
||||
rulerLengthSb.append("1").append(_S).append(rulerCorrectionFactor) |
||||
.append(_N) |
||||
} |
||||
rulerLengthSb.append("END") |
||||
} |
||||
|
||||
private fun appendData( |
||||
projectId: String, |
||||
routeId: String, |
||||
pointNameStart: String, |
||||
pointNameEnd: String, |
||||
twiceStation: Boolean, |
||||
routeLatestSetting: LevelingStationSettingRecord |
||||
) { |
||||
|
||||
val stationFirst = |
||||
LevelingDbFactory.instance.stationDataSource.getStationFirstTwiceStation( |
||||
projectId, |
||||
routeId, |
||||
twiceStation |
||||
) |
||||
|
||||
val stationLatest = |
||||
LevelingDbFactory.instance.stationDataSource.getStationLatestTwiceStation( |
||||
projectId, |
||||
routeId, |
||||
twiceStation |
||||
) |
||||
|
||||
val measureStation = |
||||
LevelingDbFactory.instance.measureStationDataSource.getRecordSync(stationLatest.getId()) |
||||
?: return |
||||
|
||||
singalHeightSb.append(getRouteNum()).append(_T)//编号 |
||||
.append(pointNameStart).append(_T)//起点 |
||||
.append(pointNameEnd).append(_T)//终点 |
||||
.append(LevelFormatUtil.formatHeight(measureStation.heightDiffTotal)).append(_T)//高差 |
||||
.append(LevelFormatUtil.formatHeight(measureStation.distanceTotal)).append(_T)//距离 |
||||
.append("0.00000").append(_T)//温度改正 |
||||
.append(getExportRulerCorrectionFactor(routeLatestSetting)).append(_T)//标尺改正系数 |
||||
.append("1").append(_T)//结束标志 |
||||
.append(routeLatestSetting.soil ?: "水泥").append(_T)//土质 |
||||
.append(stationFirst.createDate.time).append(_T)//开始时间 |
||||
.append(stationLatest.createDate.time).append(_T)//结束时间 |
||||
.append(routeLatestSetting.temperature ?: MeasureConstant.DEFAULT_TEMPERATURE) |
||||
.append(_T)//温度 |
||||
.append(routeLatestSetting.firstStationFrontFootNumber ?: "").append(_T)//标尺1 |
||||
.append(routeLatestSetting.firstStationBackFootNumber ?: "").append(_T)//标尺2 |
||||
.append(measureStation.stationNumForenoonTotal).append(_T)//上午测站数 |
||||
.append(measureStation.stationNumAfternoonTotal).append(_T)//下午测站数 |
||||
.append(_N) |
||||
|
||||
heightDistanceSb.append(pointNameStart).append(_S) |
||||
.append(pointNameEnd).append(_S) |
||||
.append(LevelFormatUtil.formatHeight(measureStation.heightDiffTotal)).append(_S)//高差 |
||||
.append(LevelFormatUtil.formatHeight(measureStation.distanceTotal)).append(_S)//距离 |
||||
.append("1").append(_N)//结束标志 |
||||
|
||||
routeIndex++ |
||||
} |
||||
|
||||
private fun getExportRulerCorrectionFactor(routeLatestSetting: LevelingStationSettingRecord): String { |
||||
return if (!TextUtils.isEmpty(routeLatestSetting.rulerCorrectionFactor)) { |
||||
"${routeLatestSetting.rulerCorrectionFactor.toDouble() / 1000}" |
||||
} else { |
||||
"0" |
||||
} |
||||
} |
||||
|
||||
private fun getPointName(pointId: String): String { |
||||
return SurveyorDatabaseFactory.instance.pointDataSource.findByIdSync(pointId)?.getName() ?: "" |
||||
} |
||||
|
||||
private fun getRouteNum(): String { |
||||
return String.format("%04d", routeIndex + 1) |
||||
} |
||||
|
||||
/** |
||||
* 初始化平差准备文件夹 |
||||
*/ |
||||
private fun initPrepare4Folder(projectFolder: File): File { |
||||
val exportFolder = File(projectFolder, "平差准备文件") |
||||
if (!exportFolder.exists()) { |
||||
exportFolder.mkdir() |
||||
} |
||||
return exportFolder |
||||
} |
||||
|
||||
} |
@ -0,0 +1,86 @@ |
||||
package com.bingce.controlnetwork.func.level.fragment; |
||||
|
||||
import android.os.Bundle; |
||||
import android.view.LayoutInflater; |
||||
import android.view.View; |
||||
import android.view.ViewGroup; |
||||
import android.widget.EditText; |
||||
import android.widget.Toast; |
||||
|
||||
import androidx.annotation.NonNull; |
||||
import androidx.annotation.Nullable; |
||||
import androidx.fragment.app.FragmentManager; |
||||
import androidx.lifecycle.LifecycleOwner; |
||||
|
||||
import com.bingce.controlnetwork.R; |
||||
import com.bingce.controlnetwork.fragment.AbstractFullScreenDialogFragment; |
||||
|
||||
/** |
||||
* 新建编辑i角检测 |
||||
*/ |
||||
public class LevelIDetectionCreateFragment extends AbstractFullScreenDialogFragment { |
||||
@Override |
||||
protected View createContentView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { |
||||
View view = inflater.inflate(R.layout.fragment_level_i_detection_create_edit, container, false); |
||||
EditText editText = view.findViewById(R.id.editor); |
||||
if (editText != null && getArguments() != null) { |
||||
editText.setText(getArguments().getString(KEY_DEFAULT_STRING)); |
||||
} |
||||
return view; |
||||
} |
||||
|
||||
@Override |
||||
protected void onConfirm() { |
||||
Bundle args = new Bundle(); |
||||
if (getView() != null) { |
||||
EditText editText = getView().findViewById(R.id.editor); |
||||
if (editText.getText() != null) { |
||||
String string = editText.getText().toString(); |
||||
if (string.isEmpty()) { |
||||
Toast.makeText(getContext(), |
||||
R.string.string_no_empty, |
||||
Toast.LENGTH_SHORT).show(); |
||||
return; |
||||
} |
||||
args.putString(KEY_STRING_RESULT, string); |
||||
} |
||||
} |
||||
getParentFragmentManager() |
||||
.setFragmentResult(KEY_REQUEST_INPUT, args); |
||||
super.onConfirm(); |
||||
} |
||||
|
||||
private static final String TAG = LevelIDetectionCreateFragment.class.getName(); |
||||
private static final String KEY_REQUEST_INPUT = LevelIDetectionCreateFragment.class.getName() + "_REQUEST"; |
||||
private static final String KEY_STRING_RESULT = LevelIDetectionCreateFragment.class.getName() + "_result"; |
||||
private static final String KEY_DEFAULT_STRING = LevelIDetectionCreateFragment.class.getName() + "__DEFAULT_STRING"; |
||||
|
||||
|
||||
public static void input(FragmentManager fragmentManager, |
||||
String title, |
||||
String defaultString, |
||||
LifecycleOwner lifecycleOwner, |
||||
IInputCallback callback) { |
||||
Bundle args = new Bundle(); |
||||
LevelIDetectionCreateFragment fragment = new LevelIDetectionCreateFragment(); |
||||
fragment.setArguments(args); |
||||
if (defaultString != null) { |
||||
args.putString(KEY_DEFAULT_STRING, defaultString); |
||||
} |
||||
AbstractFullScreenDialogFragment.setArgs(args, title, null); |
||||
fragmentManager |
||||
.setFragmentResultListener( |
||||
KEY_REQUEST_INPUT, |
||||
lifecycleOwner, |
||||
(requestKey, result) -> { |
||||
if (KEY_REQUEST_INPUT.equals(requestKey)) { |
||||
callback.onGetInput(result.getString(KEY_STRING_RESULT)); |
||||
} |
||||
}); |
||||
fragment.show(fragmentManager, TAG); |
||||
} |
||||
|
||||
public interface IInputCallback { |
||||
void onGetInput(String string); |
||||
} |
||||
} |
@ -0,0 +1,91 @@ |
||||
package com.bingce.controlnetwork.func.level.fragment; |
||||
|
||||
import android.os.Bundle; |
||||
import android.view.LayoutInflater; |
||||
import android.view.View; |
||||
import android.view.ViewGroup; |
||||
import android.view.WindowManager; |
||||
|
||||
import androidx.annotation.NonNull; |
||||
import androidx.annotation.Nullable; |
||||
import androidx.appcompat.app.AppCompatDialogFragment; |
||||
import androidx.fragment.app.FragmentManager; |
||||
import androidx.lifecycle.LifecycleOwner; |
||||
|
||||
import com.bingce.controlnetwork.R; |
||||
import com.bingce.controlnetwork.newui.widget.switchtext.SwitchWithText; |
||||
|
||||
|
||||
public class LevelInputAllowFragment extends AppCompatDialogFragment { |
||||
|
||||
public static String KEY_AUTO = "KEY_AUTO"; |
||||
public static String KEY_REQUEST = "KEY_REQUEST"; |
||||
|
||||
public static void show(FragmentManager fragmentManager, LifecycleOwner lifecycleOwner, |
||||
boolean auto, IConfirmCallback callback) { |
||||
Bundle args = new Bundle(); |
||||
LevelInputAllowFragment fragment = new LevelInputAllowFragment(); |
||||
fragment.setArguments(args); |
||||
args.putBoolean(KEY_AUTO, auto); |
||||
|
||||
fragmentManager |
||||
.setFragmentResultListener( |
||||
KEY_REQUEST, |
||||
lifecycleOwner, |
||||
(requestKey, result) -> { |
||||
if (KEY_REQUEST.equals(requestKey)) { |
||||
if (callback != null) { |
||||
callback.onConfirm(result.getBoolean(KEY_AUTO)); |
||||
} |
||||
} |
||||
}); |
||||
|
||||
fragment.show(fragmentManager, null); |
||||
|
||||
} |
||||
|
||||
@Nullable |
||||
@Override |
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { |
||||
View contentView = inflater.inflate(R.layout.fragment_level_input_allow, container, false); |
||||
SwitchWithText receiveDataType = contentView.findViewById(R.id.receiveDataType); |
||||
|
||||
receiveDataType.setChecked(getAuto()); |
||||
|
||||
contentView.findViewById(R.id.btnConfirm).setOnClickListener(v -> { |
||||
Bundle bundle = new Bundle(); |
||||
bundle.putBoolean(KEY_AUTO, receiveDataType.isChecked()); |
||||
getParentFragmentManager() |
||||
.setFragmentResult(KEY_REQUEST, bundle); |
||||
dismissAllowingStateLoss(); |
||||
}); |
||||
|
||||
return contentView; |
||||
} |
||||
|
||||
@Override |
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { |
||||
super.onViewCreated(view, savedInstanceState); |
||||
if (getDialog() == null) { |
||||
return; |
||||
} |
||||
getDialog().getWindow().setLayout( |
||||
WindowManager.LayoutParams.MATCH_PARENT, |
||||
WindowManager.LayoutParams.WRAP_CONTENT); |
||||
} |
||||
|
||||
public interface IConfirmCallback { |
||||
void onConfirm(Boolean auto); |
||||
} |
||||
|
||||
/** |
||||
* 仪器获取 |
||||
*/ |
||||
private boolean getAuto() { |
||||
if (getArguments() != null) { |
||||
return getArguments().getBoolean(KEY_AUTO); |
||||
} |
||||
return true; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,102 @@ |
||||
package com.bingce.controlnetwork.func.level.fragment; |
||||
|
||||
import android.os.Bundle; |
||||
import android.text.TextUtils; |
||||
import android.view.LayoutInflater; |
||||
import android.view.View; |
||||
import android.view.ViewGroup; |
||||
import android.view.WindowManager; |
||||
import android.widget.EditText; |
||||
|
||||
import androidx.annotation.NonNull; |
||||
import androidx.annotation.Nullable; |
||||
import androidx.appcompat.app.AppCompatDialogFragment; |
||||
import androidx.fragment.app.FragmentManager; |
||||
import androidx.lifecycle.LifecycleOwner; |
||||
|
||||
import com.bingce.controlnetwork.R; |
||||
|
||||
import blankj.utilcode.util.ToastUtils; |
||||
|
||||
|
||||
public class LevelInputFragment extends AppCompatDialogFragment { |
||||
|
||||
public static String KEY_DISTANCE = "KEY_DISTANCE"; |
||||
public static String KEY_HEIGHT = "KEY_HEIGHT"; |
||||
public static String KEY_REQUEST = "KEY_REQUEST"; |
||||
|
||||
public static void show(FragmentManager fragmentManager, LifecycleOwner lifecycleOwner, |
||||
IConfirmCallback callback) { |
||||
Bundle args = new Bundle(); |
||||
LevelInputFragment fragment = new LevelInputFragment(); |
||||
fragment.setArguments(args); |
||||
|
||||
fragmentManager |
||||
.setFragmentResultListener( |
||||
KEY_REQUEST, |
||||
lifecycleOwner, |
||||
(requestKey, result) -> { |
||||
if (KEY_REQUEST.equals(requestKey)) { |
||||
if (callback != null) { |
||||
double distance = result.getDouble(KEY_DISTANCE); |
||||
double height = result.getDouble(KEY_HEIGHT); |
||||
callback.onConfirm(distance, height); |
||||
} |
||||
} |
||||
}); |
||||
|
||||
fragment.show(fragmentManager, null); |
||||
|
||||
} |
||||
|
||||
@Nullable |
||||
@Override |
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { |
||||
View contentView = inflater.inflate(R.layout.fragment_level_input, container, false); |
||||
|
||||
EditText etDisTance = contentView.findViewById(R.id.etDisTance); |
||||
EditText etHeight = contentView.findViewById(R.id.etHeight); |
||||
|
||||
contentView.findViewById(R.id.btnConfirm).setOnClickListener(v -> { |
||||
|
||||
String disTance = getEtValue(etDisTance); |
||||
String height = getEtValue(etHeight); |
||||
if (TextUtils.isEmpty(disTance)) { |
||||
ToastUtils.showShort("请输入距离"); |
||||
return; |
||||
} |
||||
if (TextUtils.isEmpty(height)) { |
||||
ToastUtils.showShort("请输入高度"); |
||||
return; |
||||
} |
||||
|
||||
Bundle bundle = new Bundle(); |
||||
bundle.putDouble(KEY_DISTANCE, Double.parseDouble(disTance)); |
||||
bundle.putDouble(KEY_HEIGHT, Double.parseDouble(height)); |
||||
getParentFragmentManager() |
||||
.setFragmentResult(KEY_REQUEST, bundle); |
||||
dismissAllowingStateLoss(); |
||||
}); |
||||
|
||||
return contentView; |
||||
} |
||||
|
||||
@Override |
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { |
||||
super.onViewCreated(view, savedInstanceState); |
||||
if (getDialog() == null) { |
||||
return; |
||||
} |
||||
getDialog().getWindow().setLayout( |
||||
WindowManager.LayoutParams.MATCH_PARENT, |
||||
WindowManager.LayoutParams.WRAP_CONTENT); |
||||
} |
||||
|
||||
private String getEtValue(EditText et) { |
||||
return et.getText().toString().trim(); |
||||
} |
||||
|
||||
public interface IConfirmCallback { |
||||
void onConfirm(double distance, double height); |
||||
} |
||||
} |
@ -0,0 +1,382 @@ |
||||
package com.bingce.controlnetwork.func.level.fragment |
||||
|
||||
import android.content.Context |
||||
import android.os.Bundle |
||||
import android.text.TextUtils |
||||
import android.view.LayoutInflater |
||||
import android.view.View |
||||
import android.view.ViewGroup |
||||
import android.widget.AdapterView |
||||
import android.widget.ArrayAdapter |
||||
import android.widget.EditText |
||||
import androidx.fragment.app.Fragment |
||||
import androidx.fragment.app.viewModels |
||||
import androidx.lifecycle.lifecycleScope |
||||
import blankj.utilcode.util.ToastUtils |
||||
import cn.liuyanbing.surveyor.function.level.constant.LevelConstant |
||||
import com.bingce.controlnetwork.func.level.constant.LevelStationSettingContant |
||||
import com.bingce.controlnetwork.func.level.util.LevelStationSettingUtil.getSpinnerText |
||||
import com.bingce.controlapphelper.model.BundleConstants |
||||
import com.bingce.controlapphelper.model.LevelRouteSave |
||||
import com.bingce.controlapphelper.model.LevelingMeasureOrder |
||||
import com.bingce.controlapphelper.model.LevelingMeasureOrderUtil |
||||
import com.bingce.controlapphelper.model.PickPointResult |
||||
import com.bingce.controlapphelper.util.CheckLocationUtil |
||||
import com.bingce.controlapphelper.util.GetLocationUtil |
||||
import com.bingce.controlnetwork.R |
||||
import com.bingce.controlnetwork.activity.fragmentcontainer.FragmentContainerActivity |
||||
import com.bingce.controlnetwork.databinding.FragmentLevelCreateRouteBinding |
||||
import com.bingce.controlnetwork.fragment.PickPointFragment |
||||
import com.bingce.controlnetwork.func.level.viewmodel.LevelCreateOrEditRouteVm |
||||
import com.bingce.controlnetwork.newui.base.BaseFragmentBinding |
||||
import com.bingce.controlnetwork.newui.projectedit.ProjectLastData |
||||
import kotlinx.coroutines.Dispatchers |
||||
import kotlinx.coroutines.launch |
||||
import kotlinx.coroutines.withContext |
||||
|
||||
class LevelRouteCreateEditFragment : BaseFragmentBinding<FragmentLevelCreateRouteBinding>() { |
||||
|
||||
private val viewModel by viewModels<LevelCreateOrEditRouteVm>() |
||||
|
||||
private val SELECT_POINT_TYPE_START = "SELECT_POINT_TYPE_START" |
||||
private val SELECT_POINT_TYPE_END = "SELECT_POINT_TYPE_END" |
||||
|
||||
private var pickPointResultStart: PickPointResult? = null |
||||
private var pickPointResultEnd: PickPointResult? = null |
||||
|
||||
private lateinit var levelingMeasureOrder: LevelingMeasureOrder |
||||
|
||||
private val getLocation by lazy { |
||||
GetLocationUtil() |
||||
} |
||||
|
||||
|
||||
private val defaultStationLauncher = PickPointFragment.createActivityLauncher( |
||||
this |
||||
) { type: String, pickPointResult: PickPointResult -> |
||||
if (SELECT_POINT_TYPE_START == type) { |
||||
pickPointResultStart = pickPointResult |
||||
} else if (SELECT_POINT_TYPE_END == type) { |
||||
pickPointResultEnd = pickPointResult |
||||
} |
||||
if (pickPointResult.selectedIds.isNullOrEmpty() |
||||
|| pickPointResult.selectedNames.isNullOrEmpty() |
||||
|| pickPointResult.selectedNames.size != pickPointResult.selectedIds.size |
||||
) { |
||||
ToastUtils.showShort(R.string.abnormal_point_selection) |
||||
return@createActivityLauncher |
||||
} |
||||
setSelectPointUi() |
||||
} |
||||
|
||||
|
||||
companion object { |
||||
@JvmField |
||||
val TAG = LevelRouteCreateEditFragment::class.java.getName() |
||||
|
||||
@JvmStatic |
||||
fun newInstance(args: Bundle?): Fragment { |
||||
val fragment: Fragment = LevelRouteCreateEditFragment() |
||||
fragment.setArguments(args) |
||||
return fragment |
||||
} |
||||
|
||||
@JvmStatic |
||||
fun start(context: Context, projectId: String, routeId: String?, title: String) { |
||||
val bundle = Bundle() |
||||
bundle.putString(BundleConstants.KEY_PROJECT_ID, projectId) |
||||
bundle.putString(BundleConstants.KEY_ROUTE_ID, routeId) |
||||
FragmentContainerActivity.start(context, TAG, title, bundle) |
||||
} |
||||
} |
||||
|
||||
|
||||
override fun getViewBinding( |
||||
inflater: LayoutInflater, |
||||
container: ViewGroup? |
||||
): FragmentLevelCreateRouteBinding { |
||||
return FragmentLevelCreateRouteBinding.inflate(inflater, container, false) |
||||
} |
||||
|
||||
override fun initView() { |
||||
lifecycle.addObserver(getLocation) |
||||
initLevelOrder() |
||||
initListener() |
||||
} |
||||
|
||||
private fun initListener() { |
||||
mBinding.btnConfirm.setOnClickListener { |
||||
checkConfirm() |
||||
} |
||||
mBinding.btnDetermineAndMeasure.setOnClickListener { |
||||
|
||||
} |
||||
|
||||
mBinding.ivSelectStartPoint.setOnClickListener { |
||||
selectPoint(SELECT_POINT_TYPE_START) |
||||
} |
||||
mBinding.ivSelectEndPoint.setOnClickListener { |
||||
selectPoint(SELECT_POINT_TYPE_END) |
||||
} |
||||
|
||||
mBinding.ivGetLocation.setOnClickListener { |
||||
getLocation { |
||||
setLocation(mBinding.etLongitude, mBinding.etLatitude, mBinding.etHeight, it) |
||||
} |
||||
} |
||||
} |
||||
|
||||
override fun initData() { |
||||
initSpinnerObservationDirection() |
||||
|
||||
initEditData() |
||||
} |
||||
|
||||
private fun initEditData() { |
||||
val routeId = getRouteId() |
||||
if (routeId != null) { |
||||
viewModel.getEditRouteData(routeId) { |
||||
mBinding.etStartPoint.setText(it.startPointName) |
||||
mBinding.etEndPoint.setText(it.endPointName) |
||||
mBinding.spinnerObservationDirection.setSelection( |
||||
LevelStationSettingContant.observationDirectionList.indexOf( |
||||
it.observationDirection |
||||
) |
||||
) |
||||
|
||||
// //经纬度 |
||||
// if (isEmpty(it.longitude) || isEmpty(it.latitude)) { |
||||
// setDefaultLocation() |
||||
// } else { |
||||
// setLocation( |
||||
// mBinding.etLongitude, |
||||
// mBinding.etLatitude, |
||||
// mBinding.etHeight, |
||||
// it.longitude, |
||||
// it.latitude, |
||||
// it.z |
||||
// ) |
||||
// } |
||||
|
||||
} |
||||
} else { |
||||
setDefaultLocation() |
||||
} |
||||
} |
||||
|
||||
private fun setSelectPointUi() { |
||||
if (pickPointResultStart == null) { |
||||
mBinding.etStartPoint.setText("") |
||||
} else { |
||||
mBinding.etStartPoint.setText(pickPointResultStart!!.selectedNames[0]) |
||||
} |
||||
if (pickPointResultEnd == null) { |
||||
mBinding.etEndPoint.setText("") |
||||
} else { |
||||
mBinding.etEndPoint.setText(pickPointResultEnd!!.selectedNames[0]) |
||||
} |
||||
} |
||||
|
||||
private fun selectPoint(type: String) { |
||||
var title: String? = null |
||||
var pickPointResultSelected: PickPointResult? = null |
||||
var filderIds: List<String>? = null |
||||
if (SELECT_POINT_TYPE_START == type) { |
||||
pickPointResultSelected = pickPointResultStart |
||||
filderIds = pickPointResultEnd?.selectedIds |
||||
title = getString(R.string.choose_starting_point) |
||||
} else if (SELECT_POINT_TYPE_END == type) { |
||||
pickPointResultSelected = pickPointResultStart |
||||
filderIds = pickPointResultStart?.selectedIds |
||||
title = getString(R.string.select_end_point) |
||||
} |
||||
PickPointFragment.pickKnownAndUnknownPoint( |
||||
context, |
||||
type, |
||||
1, |
||||
title, |
||||
filderIds, |
||||
getProjectId(), |
||||
pickPointResultSelected, |
||||
defaultStationLauncher |
||||
) |
||||
} |
||||
|
||||
/** |
||||
* 照准次序 |
||||
*/ |
||||
private fun initLevelOrder() { |
||||
val showList = LevelingMeasureOrderUtil.getShowList() |
||||
mBinding.spinner.setAdapter( |
||||
ArrayAdapter( |
||||
requireContext(), |
||||
android.R.layout.simple_list_item_1, |
||||
showList |
||||
) |
||||
) |
||||
mBinding.spinner.onItemSelectedListener = object : AdapterView.OnItemSelectedListener { |
||||
override fun onItemSelected( |
||||
parent: AdapterView<*>?, |
||||
view: View, |
||||
position: Int, |
||||
id: Long |
||||
) { |
||||
levelingMeasureOrder = LevelingMeasureOrderUtil.getLevelingMeasureOrderByCreate( |
||||
showList[position] |
||||
) |
||||
} |
||||
|
||||
override fun onNothingSelected(parent: AdapterView<*>?) {} |
||||
} |
||||
|
||||
|
||||
|
||||
mBinding.spinner.setSelection(0) |
||||
} |
||||
|
||||
/** |
||||
* 观测方向 |
||||
*/ |
||||
private fun initSpinnerObservationDirection() { |
||||
mBinding.spinnerObservationDirection.adapter = ArrayAdapter( |
||||
requireContext(), |
||||
android.R.layout.simple_list_item_1, |
||||
LevelStationSettingContant.observationDirectionList |
||||
) |
||||
mBinding.spinnerObservationDirection.onItemSelectedListener = |
||||
object : AdapterView.OnItemSelectedListener { |
||||
override fun onItemSelected( |
||||
parent: AdapterView<*>?, |
||||
view: View, |
||||
position: Int, |
||||
id: Long |
||||
) { |
||||
|
||||
} |
||||
|
||||
override fun onNothingSelected(parent: AdapterView<*>?) { |
||||
|
||||
} |
||||
} |
||||
} |
||||
|
||||
private fun checkConfirm() { |
||||
val projectId = getProjectId() |
||||
if (projectId == null) { |
||||
ToastUtils.showShort(R.string.project_data_is_empty) |
||||
return |
||||
} |
||||
|
||||
val startPointName = mBinding.etStartPoint.getText().toString().trim() |
||||
if (TextUtils.isEmpty(startPointName)) { |
||||
ToastUtils.showShort(R.string.please_enter_or_select_a_starting_point) |
||||
return |
||||
} |
||||
val endPointName = mBinding.etEndPoint.getText().toString().trim() |
||||
if (TextUtils.isEmpty(endPointName)) { |
||||
ToastUtils.showShort(R.string.please_enter_or_select_a_destination) |
||||
return |
||||
} |
||||
|
||||
val longitude = mBinding.etLongitude.getText().toString().trim() |
||||
if (TextUtils.isEmpty(longitude)) { |
||||
ToastUtils.showShort(R.string.please_input_longitude) |
||||
return |
||||
} |
||||
val latitude = mBinding.etLatitude.getText().toString().trim() |
||||
if (TextUtils.isEmpty(latitude)) { |
||||
ToastUtils.showShort(R.string.please_input_latitude) |
||||
return |
||||
} |
||||
val height = mBinding.etHeight.getText().toString().trim() |
||||
if (TextUtils.isEmpty(height)) { |
||||
ToastUtils.showShort(R.string.please_enter_elevation) |
||||
return |
||||
} |
||||
|
||||
val levelRouteSave = LevelRouteSave() |
||||
levelRouteSave.projectId = projectId |
||||
levelRouteSave.routeId = getRouteId() |
||||
levelRouteSave.routeName = "$startPointName-$endPointName" |
||||
levelRouteSave.startPointName = startPointName |
||||
levelRouteSave.endPointName = endPointName |
||||
levelRouteSave.levelingMeasureOrder = levelingMeasureOrder |
||||
|
||||
//观测方向 |
||||
levelRouteSave.observationDirection = getSpinnerText(mBinding.spinnerObservationDirection) |
||||
|
||||
viewModel.startSave(requireContext(), levelRouteSave) { isSuccess: Boolean -> |
||||
if (isSuccess) requireActivity().finish() |
||||
} |
||||
} |
||||
|
||||
private fun getProjectId() = getArgumentString(BundleConstants.KEY_PROJECT_ID) |
||||
private fun getRouteId() = getArgumentString(BundleConstants.KEY_ROUTE_ID) |
||||
|
||||
|
||||
private fun getLocation(resultListener: GetLocationUtil.IResultListener) { |
||||
CheckLocationUtil.check(requireContext()) { |
||||
getLocation.getResult(resultListener) |
||||
} |
||||
} |
||||
|
||||
private fun setLocation( |
||||
etLongitude: EditText, |
||||
etLatitude: EditText, |
||||
etHeight: EditText, |
||||
result: GetLocationUtil.Result? |
||||
) { |
||||
setLocation( |
||||
etLongitude, |
||||
etLatitude, |
||||
etHeight, |
||||
result?.longitude, |
||||
result?.latitude, |
||||
result?.altitude |
||||
) |
||||
} |
||||
|
||||
private fun setLocation( |
||||
etLongitude: EditText, |
||||
etLatitude: EditText, |
||||
etHeight: EditText, |
||||
longitude: String?, |
||||
latitude: String?, |
||||
z: String? |
||||
) { |
||||
etLongitude.setText(longitude) |
||||
etLatitude.setText(latitude) |
||||
etHeight.setText(z) |
||||
} |
||||
|
||||
private fun setDefaultLocation() { |
||||
lifecycleScope.launch(Dispatchers.IO) { |
||||
val longitude = ProjectLastData.getLongitude() |
||||
val latitude = ProjectLastData.getLatitude() |
||||
withContext(Dispatchers.Main) { |
||||
if (isEmpty(latitude) || isEmpty(latitude)) { |
||||
setLocation( |
||||
mBinding.etLongitude, |
||||
mBinding.etLatitude, |
||||
mBinding.etHeight, |
||||
LevelConstant.LONGITUDE_DEFAULT.toString(), |
||||
LevelConstant.LATITUDE_DEFAULT.toString(), |
||||
LevelConstant.HEIGHT_DEFAULT.toString() |
||||
) |
||||
} else { |
||||
setLocation( |
||||
mBinding.etLongitude, |
||||
mBinding.etLatitude, |
||||
mBinding.etHeight, |
||||
longitude, |
||||
latitude, |
||||
LevelConstant.HEIGHT_DEFAULT.toString() |
||||
) |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
private fun isEmpty(value: String?) = TextUtils.isEmpty(value) |
||||
|
||||
} |
@ -0,0 +1,158 @@ |
||||
package com.bingce.controlnetwork.func.level.fragment |
||||
|
||||
import android.os.Bundle |
||||
import android.view.LayoutInflater |
||||
import android.view.View |
||||
import android.view.ViewGroup |
||||
import androidx.fragment.app.Fragment |
||||
import androidx.fragment.app.viewModels |
||||
import androidx.lifecycle.lifecycleScope |
||||
import androidx.room.withTransaction |
||||
import com.bingce.controlapphelper.datasource.database.SurveyorDataBase |
||||
import com.bingce.controlapphelper.datasource.database.SurveyorDatabaseFactory |
||||
import com.bingce.controlapphelper.datasource.database.leveling.LevelingDbFactory |
||||
import com.bingce.controlapphelper.datasource.database.leveling.route.LevelRouteRecord |
||||
import com.bingce.controlnetwork.R |
||||
import com.bingce.controlnetwork.func.level.viewmodel.LevelCreateOrEditRouteVm |
||||
import com.bingce.controlapphelper.model.BundleConstants |
||||
import com.bingce.controlnetwork.adapter.contextmenu.ContextMenuDeleteEdit |
||||
import com.bingce.controlnetwork.databinding.FragmentListLayoutBinding |
||||
import com.bingce.controlnetwork.fragment.TipsFragment |
||||
import com.bingce.controlnetwork.func.level.adapter.LevelRouteListAdapter |
||||
import kotlinx.coroutines.Dispatchers |
||||
import kotlinx.coroutines.launch |
||||
import kotlinx.coroutines.withContext |
||||
|
||||
class LevelRouteFragment : Fragment() { |
||||
|
||||
private val createOrEditRouteVm by viewModels<LevelCreateOrEditRouteVm>() |
||||
|
||||
private var _binding: FragmentListLayoutBinding? = null |
||||
val mBinding get() = _binding!! |
||||
|
||||
private val dataList = mutableListOf<LevelRouteRecord>() |
||||
|
||||
private val adapter by lazy { |
||||
LevelRouteListAdapter(requireContext()) |
||||
} |
||||
|
||||
private fun doLookAndEditRoute(item: LevelRouteRecord) { |
||||
createOrEditRouteVm.showCreateOrEditDialog( |
||||
requireContext(), |
||||
getProjectId(), |
||||
routeId = item.getId() |
||||
) |
||||
} |
||||
|
||||
private fun doDelete(item: LevelRouteRecord) { |
||||
lifecycleScope.launch(Dispatchers.IO) { |
||||
|
||||
val stationList = SurveyorDatabaseFactory.instance.surveyorStation.getByProjectRoute( |
||||
item.projectId, |
||||
item.getId() |
||||
) |
||||
|
||||
var hasData = false |
||||
for (stationItem in stationList) { |
||||
val recordCount = |
||||
SurveyorDatabaseFactory.instance.surveyorRecordDataSource.recordCount( |
||||
stationItem.getId() |
||||
) |
||||
if (recordCount > 0) { |
||||
hasData = true |
||||
break |
||||
} |
||||
} |
||||
|
||||
if (hasData) { |
||||
withContext(Dispatchers.Main) { |
||||
TipsFragment.cancelAbleTips( |
||||
childFragmentManager, viewLifecycleOwner, context, |
||||
getString(R.string.tips_is_sure_to_delete_route_with_record), |
||||
4 |
||||
) { |
||||
deleteDatabase(item) |
||||
} |
||||
} |
||||
} else { |
||||
deleteDatabase(item) |
||||
} |
||||
} |
||||
} |
||||
|
||||
private fun deleteDatabase(routeRecord: LevelRouteRecord) { |
||||
lifecycleScope.launch(Dispatchers.IO) { |
||||
SurveyorDataBase.getInstance().withTransaction { |
||||
//删除路线 |
||||
LevelingDbFactory.instance.levelDataSource.delete(routeRecord) |
||||
//删除测站 |
||||
LevelingDbFactory.instance.stationDataSource.deleteByRouteId(routeRecord.getId()) |
||||
} |
||||
} |
||||
} |
||||
|
||||
override fun onCreateView( |
||||
inflater: LayoutInflater, |
||||
container: ViewGroup?, |
||||
savedInstanceState: Bundle? |
||||
): View { |
||||
_binding = FragmentListLayoutBinding.inflate(inflater, container, false) |
||||
return mBinding.root |
||||
} |
||||
|
||||
override fun onDestroyView() { |
||||
super.onDestroyView() |
||||
_binding = null |
||||
} |
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { |
||||
super.onViewCreated(view, savedInstanceState) |
||||
initAdapter() |
||||
|
||||
LevelingDbFactory.instance.levelDataSource.getListLiveData(getProjectId()) |
||||
.observe(viewLifecycleOwner) { |
||||
adapter.refreshData(it) |
||||
} |
||||
} |
||||
|
||||
private fun initAdapter() { |
||||
mBinding.list.adapter = adapter |
||||
|
||||
adapter.setAdapterContextMenu(object : ContextMenuDeleteEdit<LevelRouteRecord>() { |
||||
override fun delete(item: LevelRouteRecord) { |
||||
doDelete(item) |
||||
} |
||||
|
||||
override fun edit(item: LevelRouteRecord) { |
||||
doLookAndEditRoute(item) |
||||
} |
||||
}) |
||||
} |
||||
|
||||
|
||||
fun getProjectId() = requireArguments().getString(BundleConstants.KEY_PROJECT_ID)!! |
||||
|
||||
|
||||
companion object { |
||||
@JvmStatic |
||||
fun newInstance(projectId: String): LevelRouteFragment { |
||||
val bundle = Bundle() |
||||
bundle.putString(BundleConstants.KEY_PROJECT_ID, projectId) |
||||
val routeFragment = LevelRouteFragment() |
||||
routeFragment.arguments = bundle |
||||
return routeFragment |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 获取即将要测量的路线id |
||||
*/ |
||||
fun getSurveyorRouteId(): String? { |
||||
if (dataList.isNotEmpty()) { |
||||
return dataList.last().getId() |
||||
} |
||||
return null |
||||
} |
||||
|
||||
|
||||
} |
@ -0,0 +1,248 @@ |
||||
package com.bingce.controlnetwork.func.level.fragment; |
||||
|
||||
import android.content.Context; |
||||
import android.os.Bundle; |
||||
import android.os.Environment; |
||||
import android.view.LayoutInflater; |
||||
import android.view.View; |
||||
import android.view.ViewGroup; |
||||
|
||||
import androidx.annotation.NonNull; |
||||
import androidx.fragment.app.DialogFragment; |
||||
import androidx.lifecycle.ViewModelProvider; |
||||
|
||||
import com.bingce.controlapphelper.surveyor.method.ExportUtils; |
||||
import com.bingce.controlapphelper.util.CheckStorageUtil; |
||||
import com.bingce.controlapphelper.util.Tools; |
||||
import com.bingce.controlapphelper.widget.treeview.TreeNode; |
||||
import com.bingce.controlapphelper.widget.treeview.TreeView; |
||||
import com.bingce.controlapphelper.widget.treeview.custom.MyNodeViewFactory; |
||||
import com.bingce.controlnetwork.BuildConfig; |
||||
import com.bingce.controlnetwork.R; |
||||
import com.bingce.controlnetwork.activity.fragmentcontainer.FragmentContainerActivity; |
||||
import com.bingce.controlnetwork.databinding.FragmentSelectExportBinding; |
||||
import com.bingce.controlnetwork.fragment.FullLoadingFragment; |
||||
import com.bingce.controlnetwork.fragment.TipsWith2OptionFragment; |
||||
import com.bingce.controlnetwork.func.level.util.LevelExportUtilTj; |
||||
import com.bingce.controlnetwork.func.level.viewmodel.LevelSelectExportVm; |
||||
import com.bingce.controlnetwork.newui.base.BaseFragmentBinding; |
||||
import com.bingce.file.FileOperator; |
||||
import com.bingce.utils.ThreadPoolUtil; |
||||
import com.bingce.zip.ZipUtil; |
||||
|
||||
import java.io.File; |
||||
import java.text.SimpleDateFormat; |
||||
import java.util.ArrayList; |
||||
import java.util.Arrays; |
||||
import java.util.Date; |
||||
import java.util.HashSet; |
||||
import java.util.List; |
||||
import java.util.Locale; |
||||
|
||||
import blankj.utilcode.util.FileUtils; |
||||
import blankj.utilcode.util.ToastUtils; |
||||
|
||||
|
||||
/** |
||||
* 水准选择导出 |
||||
*/ |
||||
public class LevelSelectExportFragment extends BaseFragmentBinding<FragmentSelectExportBinding> { |
||||
public static final String TAG = LevelSelectExportFragment.class.getName(); |
||||
|
||||
private LevelSelectExportVm viewModel; |
||||
|
||||
private TreeNode rootNode; |
||||
|
||||
public static LevelSelectExportFragment newInstance(Bundle args) { |
||||
LevelSelectExportFragment fragment = new LevelSelectExportFragment(); |
||||
fragment.setArguments(args); |
||||
return fragment; |
||||
} |
||||
|
||||
public static void start(Context context) { |
||||
FragmentContainerActivity.start(context, TAG, R.string.level_export, null); |
||||
} |
||||
|
||||
@Override |
||||
protected FragmentSelectExportBinding getViewBinding(@NonNull LayoutInflater inflater, ViewGroup container) { |
||||
return FragmentSelectExportBinding.inflate(inflater, container, false); |
||||
} |
||||
|
||||
@Override |
||||
protected void initView() { |
||||
viewModel = new ViewModelProvider(this).get(LevelSelectExportVm.class); |
||||
mBinding.title.setText(R.string.tips_select_expected_export_data_level); |
||||
initListener(); |
||||
} |
||||
|
||||
private void initListener() { |
||||
mBinding.export.setOnClickListener(v -> { |
||||
if (ExportUtils.isCanExport()) { |
||||
CheckStorageUtil.check(requireContext(), this::startExport); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
private void startExport() { |
||||
DialogFragment dialogFragment = FullLoadingFragment.showLoading(getChildFragmentManager()); |
||||
|
||||
doExport(new ICallback() { |
||||
@Override |
||||
public void onFailureInMainThread(String msg) { |
||||
dialogFragment.dismiss(); |
||||
ToastUtils.showShort(msg); |
||||
} |
||||
|
||||
@Override |
||||
public void onSuccessInMainThread(File zip) { |
||||
if (dialogFragment.isVisible()) { |
||||
dialogFragment.dismiss(); |
||||
} |
||||
TipsWith2OptionFragment.tipsCannotCancel(getChildFragmentManager(), getViewLifecycleOwner(), |
||||
getString(R.string.share), |
||||
getString(R.string.cancel), |
||||
getString(R.string.export_successful), |
||||
new TipsWith2OptionFragment.SimpleCallback() { |
||||
@Override |
||||
public void onConfirm() { |
||||
FileOperator.shareFile(getContext(), zip, BuildConfig.APPLICATION_ID); |
||||
} |
||||
}); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
private void doExport(ICallback callback) { |
||||
List<TreeNode> projectList = rootNode.getChildren(); |
||||
|
||||
ThreadPoolUtil.execute(() -> { |
||||
List<ExportRoute> exportRouteList = new ArrayList<>(); |
||||
HashSet<String> exportProjectIdSet = new HashSet<>(); |
||||
for (TreeNode projectNode : projectList) { |
||||
List<TreeNode> children = projectNode.getChildren(); |
||||
for (TreeNode routeNode : children) { |
||||
if (routeNode.isEnable() && routeNode.isSelected()) { |
||||
String projectId = projectNode.getValue().getId(); |
||||
String projectName = projectNode.getValue().getValue().toString(); |
||||
exportProjectIdSet.add(projectId); |
||||
exportRouteList.add(new ExportRoute(projectId, projectName, |
||||
routeNode.getValue().getId(), |
||||
routeNode.getValue().getValue().toString())); |
||||
} |
||||
} |
||||
} |
||||
if (exportRouteList.isEmpty()) { |
||||
backError(callback, "没有要导出的数据"); |
||||
return; |
||||
} |
||||
|
||||
try { |
||||
LevelExportUtilTj levelExportUtilTj = new LevelExportUtilTj(); |
||||
//导出路线数据
|
||||
for (ExportRoute exportRoute : exportRouteList) { |
||||
levelExportUtilTj.doExportRouteData(exportRoute.projectId, |
||||
exportRoute.routeId); |
||||
} |
||||
|
||||
for (String projectId : exportProjectIdSet) { |
||||
//导出项目数据
|
||||
levelExportUtilTj.exportProjectTxt(projectId); |
||||
//导出点信息
|
||||
levelExportUtilTj.exportControlTxt(projectId); |
||||
//导出i角检测
|
||||
levelExportUtilTj.exportIDetection(projectId); |
||||
//导出SingalHeight和平差准备文件
|
||||
levelExportUtilTj.exportTjSingalHeight(projectId); |
||||
} |
||||
|
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
backError(callback, Tools.getString(R.string.export_failure)); |
||||
File sourceFileFolder = LevelExportUtilTj.Companion.getExportOutFolder(); |
||||
FileUtils.delete(sourceFileFolder); |
||||
return; |
||||
} |
||||
|
||||
//压缩文件
|
||||
File file = startZipFile(); |
||||
if (file == null) { |
||||
return; |
||||
} |
||||
ThreadPoolUtil.executeInMain(() -> callback.onSuccessInMainThread(file)); |
||||
}); |
||||
} |
||||
|
||||
private void backError(ICallback callback, String msg) { |
||||
ThreadPoolUtil.executeInMain(() -> callback.onFailureInMainThread(msg)); |
||||
} |
||||
|
||||
private File startZipFile() { |
||||
//源数据文件
|
||||
File sourceFileFolder = LevelExportUtilTj.Companion.getExportOutFolder(); |
||||
if (!sourceFileFolder.exists()) return null; |
||||
File[] files = sourceFileFolder.listFiles(); |
||||
if (files == null || files.length == 0) return null; |
||||
List<File> sourceFileList = Arrays.asList(files); |
||||
|
||||
//将文件存储到一个zip中
|
||||
File zipFolder = new File(Environment.getExternalStorageDirectory(), ExportUtils.getExportFirstDirectory()); |
||||
if (!zipFolder.exists()) { |
||||
zipFolder.mkdir(); |
||||
} |
||||
|
||||
Date date = new Date(); |
||||
SimpleDateFormat format = new SimpleDateFormat("yyyy_MM_dd_HH_mm_ss", Locale.getDefault()); |
||||
String dateString = format.format(date); |
||||
File zip = new File(zipFolder, "水准数据_" + dateString + ".zip"); |
||||
if (!ZipUtil.zip(zip, sourceFileList)) { |
||||
ToastUtils.showShort(R.string.export_failure); |
||||
return null; |
||||
} |
||||
try { |
||||
//存储成功,删除被压缩的源文件
|
||||
FileUtils.delete(sourceFileFolder); |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
ToastUtils.showShort(R.string.export_failure); |
||||
return null; |
||||
} |
||||
return zip; |
||||
} |
||||
|
||||
@Override |
||||
protected void initData() { |
||||
viewModel.initData(treeNode -> { |
||||
setData(treeNode); |
||||
return null; |
||||
}); |
||||
} |
||||
|
||||
private void setData(TreeNode treeNode) { |
||||
rootNode = treeNode; |
||||
TreeView treeView = new TreeView(treeNode, requireContext(), new MyNodeViewFactory()); |
||||
treeView.setup(mBinding.list); |
||||
mBinding.list.setVisibility(View.VISIBLE); |
||||
mBinding.loading.setVisibility(View.GONE); |
||||
} |
||||
|
||||
private interface ICallback { |
||||
void onFailureInMainThread(String msg); |
||||
|
||||
void onSuccessInMainThread(File zip); |
||||
} |
||||
|
||||
private static class ExportRoute { |
||||
public String projectId; |
||||
public String projectName; |
||||
public String routeId; |
||||
public String routeName; |
||||
|
||||
public ExportRoute(String projectId, String projectName, String routeId, String routeName) { |
||||
this.projectId = projectId; |
||||
this.projectName = projectName; |
||||
this.routeId = routeId; |
||||
this.routeName = routeName; |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,185 @@ |
||||
package com.bingce.controlnetwork.func.level.fragment |
||||
|
||||
import android.text.TextUtils |
||||
import android.view.LayoutInflater |
||||
import android.view.ViewGroup |
||||
import android.widget.ArrayAdapter |
||||
import androidx.fragment.app.activityViewModels |
||||
import blankj.utilcode.util.ToastUtils |
||||
import com.bingce.controlnetwork.func.level.constant.LevelStationSettingContant |
||||
import com.bingce.controlnetwork.func.level.util.LevelStationSettingUtil |
||||
import com.bingce.controlnetwork.func.level.viewmodel.LevelStationSettingVm |
||||
import com.bingce.controlapphelper.model.LevelRouteSave |
||||
import com.bingce.controlapphelper.surveyor.method.model.MeasureConstant |
||||
import com.bingce.controlnetwork.databinding.FragmentLevelStationSettingConditionBinding |
||||
import com.bingce.controlnetwork.newui.base.BaseFragmentBinding |
||||
import com.bingce.controlnetwork.newui.stationsetting.IStationSettingOperate |
||||
|
||||
/** |
||||
* 水准测站设置-观测条件 |
||||
*/ |
||||
class LevelStationSettingConditionFragment : |
||||
BaseFragmentBinding<FragmentLevelStationSettingConditionBinding>(), IStationSettingOperate { |
||||
|
||||
private val stationSettingVm by activityViewModels<LevelStationSettingVm>() |
||||
|
||||
private lateinit var levelRouteSave: LevelRouteSave |
||||
|
||||
override fun getViewBinding( |
||||
inflater: LayoutInflater, |
||||
container: ViewGroup? |
||||
): FragmentLevelStationSettingConditionBinding { |
||||
return FragmentLevelStationSettingConditionBinding.inflate(inflater, container, false) |
||||
} |
||||
|
||||
override fun initView() { |
||||
initEditTextTitle() |
||||
} |
||||
|
||||
private fun initEditTextTitle() { |
||||
mBinding.ilTemperature.tvTitle.text = "温度(℃)" |
||||
} |
||||
|
||||
override fun initData() { |
||||
initSpinnerWeather() |
||||
initSpinnerImaging() |
||||
initSpinnerSunDirection() |
||||
initSpinnerWindDirection() |
||||
initSpinnerWindSpeed() |
||||
initSpinnerRoads() |
||||
initSpinnerSoil() |
||||
|
||||
stationSettingVm.editLastDataLiveData.observe(viewLifecycleOwner) { |
||||
if (it == null) { |
||||
setTemperatureData(MeasureConstant.DEFAULT_TEMPERATURE) |
||||
} else { |
||||
setData(it) |
||||
} |
||||
} |
||||
} |
||||
|
||||
private fun initSpinnerSoil() { |
||||
mBinding.spinnerSoil.adapter = ArrayAdapter( |
||||
requireContext(), |
||||
android.R.layout.simple_list_item_1, |
||||
LevelStationSettingContant.soilList |
||||
) |
||||
} |
||||
|
||||
private fun initSpinnerRoads() { |
||||
mBinding.spinnerRoads.adapter = ArrayAdapter( |
||||
requireContext(), |
||||
android.R.layout.simple_list_item_1, |
||||
LevelStationSettingContant.roadsList |
||||
) |
||||
} |
||||
|
||||
private fun initSpinnerWindSpeed() { |
||||
mBinding.spinnerWindSpeed.adapter = ArrayAdapter( |
||||
requireContext(), |
||||
android.R.layout.simple_list_item_1, |
||||
LevelStationSettingContant.windSpeedList |
||||
) |
||||
} |
||||
|
||||
private fun initSpinnerWindDirection() { |
||||
mBinding.spinnerWindDirection.adapter = ArrayAdapter( |
||||
requireContext(), |
||||
android.R.layout.simple_list_item_1, |
||||
LevelStationSettingContant.windDirectionList |
||||
) |
||||
} |
||||
|
||||
private fun initSpinnerSunDirection() { |
||||
mBinding.spinnerSunDirection.adapter = ArrayAdapter( |
||||
requireContext(), |
||||
android.R.layout.simple_list_item_1, |
||||
LevelStationSettingContant.sunDirectionList |
||||
) |
||||
} |
||||
|
||||
private fun initSpinnerImaging() { |
||||
mBinding.spinnerImaging.adapter = ArrayAdapter( |
||||
requireContext(), |
||||
android.R.layout.simple_list_item_1, |
||||
LevelStationSettingContant.imagingList |
||||
) |
||||
} |
||||
|
||||
private fun initSpinnerWeather() { |
||||
mBinding.spinnerWeather.adapter = ArrayAdapter( |
||||
requireContext(), |
||||
android.R.layout.simple_list_item_1, |
||||
LevelStationSettingContant.weatherList |
||||
) |
||||
} |
||||
|
||||
override fun checkSaveNot(): Boolean { |
||||
if (isEmpty(mBinding.ilTemperature.editText.text.toString().trim())) { |
||||
ToastUtils.showShort("请输入温度") |
||||
return true |
||||
} |
||||
collectData() |
||||
return false |
||||
} |
||||
|
||||
override fun setDataToStation() { |
||||
stationSettingVm.addConditionDataToLevelRouteSave(levelRouteSave) |
||||
} |
||||
|
||||
private fun collectData() { |
||||
levelRouteSave = LevelRouteSave() |
||||
levelRouteSave.temperature = mBinding.ilTemperature.editText.text.toString().trim() |
||||
levelRouteSave.weather = LevelStationSettingUtil.getSpinnerText(mBinding.spinnerWeather) |
||||
levelRouteSave.imaging = LevelStationSettingUtil.getSpinnerText(mBinding.spinnerImaging) |
||||
levelRouteSave.sunDirection = |
||||
LevelStationSettingUtil.getSpinnerText(mBinding.spinnerSunDirection) |
||||
levelRouteSave.windDirection = |
||||
LevelStationSettingUtil.getSpinnerText(mBinding.spinnerWindDirection) |
||||
levelRouteSave.windSpeed = LevelStationSettingUtil.getSpinnerText(mBinding.spinnerWindSpeed) |
||||
levelRouteSave.roads = LevelStationSettingUtil.getSpinnerText(mBinding.spinnerRoads) |
||||
levelRouteSave.soil = LevelStationSettingUtil.getSpinnerText(mBinding.spinnerSoil) |
||||
} |
||||
|
||||
private fun isEmpty(value: String?) = TextUtils.isEmpty(value) |
||||
|
||||
private fun setData(levelRouteSave: LevelRouteSave) { |
||||
setTemperatureData(levelRouteSave.temperature) |
||||
|
||||
mBinding.spinnerWeather.setSelection( |
||||
LevelStationSettingContant.weatherList.indexOf( |
||||
levelRouteSave.weather |
||||
) |
||||
) |
||||
mBinding.spinnerImaging.setSelection( |
||||
LevelStationSettingContant.imagingList.indexOf( |
||||
levelRouteSave.imaging |
||||
) |
||||
) |
||||
mBinding.spinnerSunDirection.setSelection( |
||||
LevelStationSettingContant.sunDirectionList.indexOf( |
||||
levelRouteSave.sunDirection |
||||
) |
||||
) |
||||
mBinding.spinnerWindDirection.setSelection( |
||||
LevelStationSettingContant.windDirectionList.indexOf( |
||||
levelRouteSave.windDirection |
||||
) |
||||
) |
||||
mBinding.spinnerWindSpeed.setSelection( |
||||
LevelStationSettingContant.windSpeedList.indexOf( |
||||
levelRouteSave.windSpeed |
||||
) |
||||
) |
||||
mBinding.spinnerRoads.setSelection( |
||||
LevelStationSettingContant.roadsList.indexOf( |
||||
levelRouteSave.roads |
||||
) |
||||
) |
||||
mBinding.spinnerSoil.setSelection(LevelStationSettingContant.soilList.indexOf(levelRouteSave.soil)) |
||||
} |
||||
|
||||
private fun setTemperatureData(value: String?) { |
||||
mBinding.ilTemperature.editText.setText(value) |
||||
} |
||||
} |
@ -0,0 +1,201 @@ |
||||
package com.bingce.controlnetwork.func.level.fragment |
||||
|
||||
import android.text.TextUtils |
||||
import android.view.Gravity |
||||
import android.view.LayoutInflater |
||||
import android.view.View |
||||
import android.view.ViewGroup |
||||
import android.widget.ArrayAdapter |
||||
import android.widget.TextView |
||||
import androidx.fragment.app.activityViewModels |
||||
import blankj.utilcode.util.ToastUtils |
||||
import com.bingce.controlnetwork.func.level.constant.LevelStationSettingContant |
||||
import com.bingce.controlnetwork.func.level.util.LevelStationSettingUtil |
||||
import com.bingce.controlnetwork.func.level.viewmodel.LevelStationSettingVm |
||||
import com.bingce.controlapphelper.model.LevelRouteSave |
||||
import com.bingce.controlapphelper.util.Tools |
||||
import com.bingce.controlnetwork.R |
||||
import com.bingce.controlnetwork.databinding.FragmentLevelStationSettingInformationBinding |
||||
import com.bingce.controlnetwork.newui.base.BaseFragmentBinding |
||||
import com.bingce.controlnetwork.newui.stationsetting.IStationSettingOperate |
||||
import com.bingce.controlnetwork.widget.editspinner.EditSpinner |
||||
import com.bingce.controlnetwork.widget.editspinner.SimpleAdapter |
||||
|
||||
/** |
||||
* 水准测站设置-观测信息 |
||||
*/ |
||||
class LevelStationSettingInformationFragment : |
||||
BaseFragmentBinding<FragmentLevelStationSettingInformationBinding>(), IStationSettingOperate { |
||||
|
||||
private val viewModel by activityViewModels<LevelStationSettingVm>() |
||||
|
||||
private lateinit var levelRouteSave: LevelRouteSave |
||||
|
||||
override fun getViewBinding( |
||||
inflater: LayoutInflater, |
||||
container: ViewGroup? |
||||
): FragmentLevelStationSettingInformationBinding { |
||||
return FragmentLevelStationSettingInformationBinding.inflate(inflater, container, false) |
||||
} |
||||
|
||||
override fun initView() { |
||||
initEditTextTitle() |
||||
initSpinnerRulerType() |
||||
initRulerReceptType() |
||||
viewModel.initHasTwoRuler { hasTwoRuler -> |
||||
if (hasTwoRuler) { |
||||
mBinding.ilFirstStationBackFootNumber.tvTitle.setText(R.string.first_station_back_foot_number_l) |
||||
mBinding.ilFirstStationFrontFootNumber.tvTitle.setText(R.string.first_station_front_foot_number_l) |
||||
mBinding.llRuler2.visibility = View.VISIBLE |
||||
} else { |
||||
mBinding.llRuler2.visibility = View.GONE |
||||
} |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 初始化editText坐标的title |
||||
*/ |
||||
private fun initEditTextTitle() { |
||||
mBinding.ilWatcher.tvTitle.text = "观测者" |
||||
mBinding.ilRecorder.tvTitle.text = "记录者" |
||||
mBinding.ilExaminer.tvTitle.text = "检查者" |
||||
mBinding.ilFirstStationBackFootNumber.tvTitle.text = |
||||
Tools.getString(R.string.first_station_back_foot_number) |
||||
mBinding.ilFirstStationFrontFootNumber.tvTitle.text = |
||||
Tools.getString(R.string.first_station_front_foot_number) |
||||
mBinding.ilFirstStationBackFootNumber2.tvTitle.text = |
||||
Tools.getString(R.string.first_station_back_foot_number_r) |
||||
mBinding.ilFirstStationFrontFootNumber2.tvTitle.text = |
||||
Tools.getString(R.string.first_station_front_foot_number_r) |
||||
mBinding.ilInstrumentModel.tvTitle.text = "仪器型号" |
||||
mBinding.ilDeviceNumber.tvTitle.text = "仪器编号" |
||||
mBinding.ilSteelRuleParam.tvTitle.text = "标尺因瓦带膨胀系数" |
||||
mBinding.ilRulerCorrectionFactor.tvTitle.text = "标尺改正系数(mm/m)" |
||||
mBinding.ilRulerLengthProvingTemperature.tvTitle.text = "标尺长度检定温度(℃)" |
||||
} |
||||
|
||||
private fun initRulerReceptType() { |
||||
initEditSpinner( |
||||
mBinding.ilEditSpinnerRulerRecept.tvName, |
||||
"尺承类型", |
||||
mBinding.ilEditSpinnerRulerRecept.etSpinner, |
||||
"请输入或选择" |
||||
) |
||||
val adapter = |
||||
SimpleAdapter(requireContext(), LevelStationSettingContant.rulerReceptTypeList) |
||||
mBinding.ilEditSpinnerRulerRecept.etSpinner.setAdapter(adapter) |
||||
} |
||||
|
||||
private fun initSpinnerRulerType() { |
||||
mBinding.spinnerRulerType.adapter = ArrayAdapter( |
||||
requireContext(), |
||||
android.R.layout.simple_list_item_1, |
||||
LevelStationSettingContant.rulerTypeList |
||||
) |
||||
} |
||||
|
||||
override fun initData() { |
||||
viewModel.editLastDataLiveData.observe(viewLifecycleOwner) { |
||||
if (it == null) { |
||||
setRulerReceptTypeData("不足5kg尺台") |
||||
} else { |
||||
setData(it) |
||||
} |
||||
} |
||||
} |
||||
|
||||
override fun checkSaveNot(): Boolean { |
||||
collectData() |
||||
if (isEmpty(levelRouteSave.frontFootNumber)) { |
||||
ToastUtils.showShort(R.string.first_station_front_foot_number_hint) |
||||
return true |
||||
} |
||||
if (isEmpty(levelRouteSave.backFootNumber)) { |
||||
ToastUtils.showShort(R.string.first_station_back_foot_number_hint) |
||||
return true |
||||
} |
||||
|
||||
if (mBinding.llRuler2.visibility == View.VISIBLE) { |
||||
if (isEmpty(levelRouteSave.frontFootNumber2)) { |
||||
ToastUtils.showShort(R.string.first_station_front_foot_number_hint) |
||||
return true |
||||
} |
||||
if (isEmpty(levelRouteSave.backFootNumber2)) { |
||||
ToastUtils.showShort(R.string.first_station_back_foot_number_hint) |
||||
return true |
||||
} |
||||
} |
||||
|
||||
return false |
||||
} |
||||
|
||||
override fun setDataToStation() { |
||||
viewModel.addInforDataToLevelRouteSave(levelRouteSave) |
||||
} |
||||
|
||||
private fun collectData() { |
||||
levelRouteSave = LevelRouteSave() |
||||
levelRouteSave.watcher = mBinding.ilWatcher.editText.text.toString().trim() |
||||
levelRouteSave.recorder = mBinding.ilRecorder.editText.text.toString().trim() |
||||
levelRouteSave.examiner = mBinding.ilExaminer.editText.text.toString().trim() |
||||
levelRouteSave.frontFootNumber = |
||||
mBinding.ilFirstStationFrontFootNumber.editText.text.toString().trim() |
||||
levelRouteSave.backFootNumber = |
||||
mBinding.ilFirstStationBackFootNumber.editText.text.toString().trim() |
||||
if (mBinding.llRuler2.visibility == View.VISIBLE) { |
||||
levelRouteSave.frontFootNumber2 = |
||||
mBinding.ilFirstStationFrontFootNumber2.editText.text.toString().trim() |
||||
levelRouteSave.backFootNumber2 = |
||||
mBinding.ilFirstStationBackFootNumber2.editText.text.toString().trim() |
||||
} |
||||
levelRouteSave.instrumentModel = mBinding.ilInstrumentModel.editText.text.toString().trim() |
||||
levelRouteSave.deviceNumber = mBinding.ilDeviceNumber.editText.text.toString().trim() |
||||
levelRouteSave.steelRuleParam = mBinding.ilSteelRuleParam.editText.text.toString().trim() |
||||
levelRouteSave.rulerCorrectionFactor = |
||||
mBinding.ilRulerCorrectionFactor.editText.text.toString().trim() |
||||
levelRouteSave.rulerLengthProvingTemperature = |
||||
mBinding.ilRulerLengthProvingTemperature.editText.text.toString().trim() |
||||
levelRouteSave.rulerType = LevelStationSettingUtil.getSpinnerText(mBinding.spinnerRulerType) |
||||
levelRouteSave.rulerReceptType = mBinding.ilEditSpinnerRulerRecept.etSpinner.text.trim() |
||||
} |
||||
|
||||
private fun isEmpty(value: String?) = TextUtils.isEmpty(value) |
||||
|
||||
private fun setData(levelRouteSave: LevelRouteSave) { |
||||
mBinding.ilWatcher.editText.setText(levelRouteSave.watcher) |
||||
mBinding.ilRecorder.editText.setText(levelRouteSave.recorder) |
||||
mBinding.ilExaminer.editText.setText(levelRouteSave.examiner) |
||||
mBinding.ilFirstStationBackFootNumber.editText.setText(levelRouteSave.backFootNumber) |
||||
mBinding.ilFirstStationFrontFootNumber.editText.setText(levelRouteSave.frontFootNumber) |
||||
mBinding.ilFirstStationBackFootNumber2.editText.setText(levelRouteSave.backFootNumber2) |
||||
mBinding.ilFirstStationFrontFootNumber2.editText.setText(levelRouteSave.frontFootNumber2) |
||||
mBinding.ilInstrumentModel.editText.setText(levelRouteSave.instrumentModel) |
||||
mBinding.ilDeviceNumber.editText.setText(levelRouteSave.deviceNumber) |
||||
mBinding.ilSteelRuleParam.editText.setText(levelRouteSave.steelRuleParam) |
||||
mBinding.ilRulerCorrectionFactor.editText.setText(levelRouteSave.rulerCorrectionFactor) |
||||
mBinding.ilRulerLengthProvingTemperature.editText.setText(levelRouteSave.rulerLengthProvingTemperature) |
||||
|
||||
mBinding.spinnerRulerType.setSelection( |
||||
LevelStationSettingContant.rulerTypeList.indexOf( |
||||
levelRouteSave.rulerType |
||||
) |
||||
) |
||||
setRulerReceptTypeData(levelRouteSave.rulerReceptType) |
||||
} |
||||
|
||||
private fun setRulerReceptTypeData(value: String?) { |
||||
mBinding.ilEditSpinnerRulerRecept.etSpinner.text = value |
||||
} |
||||
|
||||
private fun initEditSpinner( |
||||
textView: TextView, |
||||
textViewName: String, |
||||
view: EditSpinner, |
||||
textHint: String |
||||
) { |
||||
textView.text = textViewName |
||||
view.setHint(textHint) |
||||
view.setEtGravity(Gravity.CENTER_VERTICAL or Gravity.END) |
||||
} |
||||
} |
@ -0,0 +1,497 @@ |
||||
package com.bingce.controlnetwork.func.level.fragment; |
||||
|
||||
|
||||
import android.content.Context; |
||||
import android.os.Bundle; |
||||
import android.text.TextUtils; |
||||
import android.view.LayoutInflater; |
||||
import android.view.Menu; |
||||
import android.view.MenuInflater; |
||||
import android.view.MenuItem; |
||||
import android.view.View; |
||||
import android.view.ViewGroup; |
||||
|
||||
import androidx.annotation.NonNull; |
||||
import androidx.fragment.app.Fragment; |
||||
import androidx.fragment.app.FragmentManager; |
||||
import androidx.fragment.app.FragmentStatePagerAdapter; |
||||
import androidx.lifecycle.ViewModelProvider; |
||||
import androidx.viewpager.widget.PagerAdapter; |
||||
import androidx.viewpager.widget.ViewPager; |
||||
|
||||
import com.bingce.controlapphelper.datasource.database.leveling.station.LevelingStationRecord; |
||||
import com.bingce.controlapphelper.leveling.detaction.ILevelRefreshBtn; |
||||
import com.bingce.controlapphelper.leveling.detaction.INextStation; |
||||
import com.bingce.controlapphelper.leveling.detaction.LevelCheckBtnUtil; |
||||
import com.bingce.controlapphelper.leveling.detaction.LevelReceiveData; |
||||
import com.bingce.controlapphelper.model.BundleConstants; |
||||
import com.bingce.controlapphelper.surveyor.test.Test; |
||||
import com.bingce.controlapphelper.util.Tools; |
||||
import com.bingce.controlnetwork.R; |
||||
import com.bingce.controlnetwork.activity.fragmentcontainer.FragmentContainerActivity; |
||||
import com.bingce.controlnetwork.databinding.FragmentLevelSurveyorBinding; |
||||
import com.bingce.controlnetwork.fragment.TipsFragment; |
||||
import com.bingce.controlnetwork.func.level.activity.LevelStationSettingActivity; |
||||
import com.bingce.controlnetwork.func.level.viewmodel.LevelSuveyorVm; |
||||
import com.bingce.controlnetwork.newui.base.BaseFragmentBinding; |
||||
import com.bingce.controlnetwork.util.DialogUtil; |
||||
import com.bingce.controlnetwork.util.StationSettingCheckUtil; |
||||
import com.bingce.utils.ThreadPoolUtil; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
import blankj.utilcode.util.ToastUtils; |
||||
import com.bingce.controlnetwork.func.level.sendreceive.ILevelBackData; |
||||
import com.bingce.controlnetwork.func.level.sendreceive.LevelRequest; |
||||
import cn.liuyanbing.surveyor.function.level.sendreceive.LevelRequestRelease; |
||||
import com.bingce.controlnetwork.func.level.sendreceive.LevelRequestTest; |
||||
|
||||
/** |
||||
* 水准测量页 |
||||
*/ |
||||
public class LevelSurveyFragment extends BaseFragmentBinding<FragmentLevelSurveyorBinding> { |
||||
public static final String TAG = LevelSurveyFragment.class.getName(); |
||||
|
||||
public static final String KEY_STATION_INDEX = "STATION_INDEX"; |
||||
private LevelSuveyorVm viewModel; |
||||
private List<LevelSurveySubFragment> fragments; |
||||
private MenuItem rollBackBtn; |
||||
private MenuItem reMeasureStationBtn; |
||||
|
||||
private StationSettingCheckUtil stationSettingCheckUtil; |
||||
|
||||
private final INextStation nextStationI = this::showSelectLevelNextStepDialog; |
||||
|
||||
private LevelRequest levelRequest; |
||||
private final ILevelBackData levelBackData = new ILevelBackData() { |
||||
@Override |
||||
public void receive(@NonNull LevelReceiveData data) { |
||||
receiveData(data); |
||||
} |
||||
|
||||
@Override |
||||
public void measureError(@NonNull String msg) { |
||||
if (getView() == null) { |
||||
return; |
||||
} |
||||
DialogUtil.showAlertDialog(requireContext(), getChildFragmentManager(), getViewLifecycleOwner(), msg); |
||||
} |
||||
}; |
||||
|
||||
private MyPagerAdapter myPagerAdapter; |
||||
|
||||
private void receiveData(LevelReceiveData data) { |
||||
if (getView() == null) { |
||||
return; |
||||
} |
||||
LevelSurveySubFragment currentFragment = getCurrentFragment(); |
||||
if (currentFragment != null) { |
||||
currentFragment.recieveData(data); |
||||
} |
||||
} |
||||
|
||||
private final ILevelRefreshBtn levelRefreshBtnI = new ILevelRefreshBtn() { |
||||
@Override |
||||
public void refreshMeasureBtn() { |
||||
boolean measureEnable = LevelCheckBtnUtil.getMeasureEnable(viewModel.getCurrentStationId()); |
||||
ThreadPoolUtil.executeInMain(() -> { |
||||
setViewEnable(mBinding.surveyor, measureEnable); |
||||
setViewEnable(mBinding.btnInput, measureEnable); |
||||
}); |
||||
} |
||||
|
||||
@Override |
||||
public void refreshNextStationBtn() { |
||||
boolean measureEnable = LevelCheckBtnUtil.getNextStationEnable(viewModel.getCurrentStationId()); |
||||
ThreadPoolUtil.executeInMain(() -> setViewEnable(mBinding.btnNextStation, measureEnable)); |
||||
} |
||||
|
||||
@Override |
||||
public void refreshRollBackBtn() { |
||||
doRefreshRollBackBtn(); |
||||
} |
||||
|
||||
@Override |
||||
public void refreshReMeasureBtn() { |
||||
doRefreshReMeasureBtn(); |
||||
} |
||||
}; |
||||
|
||||
private void doRefreshReMeasureBtn() { |
||||
if (reMeasureStationBtn != null) { |
||||
boolean measureEnable = LevelCheckBtnUtil.getReMeasureStationEnable(viewModel.getCurrentStationId()); |
||||
ThreadPoolUtil.executeInMain(() -> reMeasureStationBtn.setEnabled(measureEnable)); |
||||
} |
||||
} |
||||
|
||||
private void doRefreshRollBackBtn() { |
||||
if (rollBackBtn != null) { |
||||
boolean measureEnable = LevelCheckBtnUtil.getRollBackEnable(viewModel.getCurrentStationId()); |
||||
ThreadPoolUtil.executeInMain(() -> rollBackBtn.setEnabled(measureEnable)); |
||||
} |
||||
} |
||||
|
||||
public static void start(Context context, String projectId, String routeId, String routeName) { |
||||
Bundle bundle = new Bundle(); |
||||
bundle.putString(BundleConstants.KEY_PROJECT_ID, projectId); |
||||
bundle.putString(BundleConstants.KEY_ROUTE_ID, routeId); |
||||
bundle.putString(BundleConstants.KEY_ROUTE_NAME, routeName); |
||||
FragmentContainerActivity.start(context, TAG, "水准测量", bundle); |
||||
} |
||||
|
||||
public static Fragment newInstance(Bundle args) { |
||||
Fragment fragment = new LevelSurveyFragment(); |
||||
fragment.setArguments(args); |
||||
return fragment; |
||||
} |
||||
|
||||
@Override |
||||
protected FragmentLevelSurveyorBinding getViewBinding(@NonNull LayoutInflater inflater, ViewGroup container) { |
||||
return FragmentLevelSurveyorBinding.inflate(inflater, container, false); |
||||
} |
||||
|
||||
@Override |
||||
public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) { |
||||
super.onCreateOptionsMenu(menu, inflater); |
||||
inflater.inflate(R.menu.menu_level_survey, menu); |
||||
rollBackBtn = menu.findItem(R.id.rollBack); |
||||
reMeasureStationBtn = menu.findItem(R.id.reMeasureStation); |
||||
doRefreshRollBackBtn(); |
||||
doRefreshReMeasureBtn(); |
||||
} |
||||
|
||||
@Override |
||||
public void onPrepareOptionsMenu(@NonNull Menu menu) { |
||||
if (Test.DEBUG) { |
||||
menu.findItem(R.id.test).setVisible(true); |
||||
} |
||||
super.onPrepareOptionsMenu(menu); |
||||
} |
||||
|
||||
@Override |
||||
public boolean onOptionsItemSelected(@NonNull MenuItem item) { |
||||
if (R.id.rollBack == item.getItemId()) { |
||||
showConfirmDialog(getString(R.string.level_roll_back_hint), () -> { |
||||
LevelSurveySubFragment currentFragment = getCurrentFragment(); |
||||
if (currentFragment != null) { |
||||
currentFragment.startRollBack(); |
||||
} |
||||
}); |
||||
} else if (R.id.reMeasureStation == item.getItemId()) { |
||||
showConfirmDialog(getString(R.string.level_remeasure_station_hint), () -> { |
||||
LevelSurveySubFragment currentFragment = getCurrentFragment(); |
||||
if (currentFragment != null) { |
||||
currentFragment.reMeasureStation(); |
||||
} |
||||
}); |
||||
} else if (R.id.surveyorSettings == item.getItemId()) { |
||||
LevelingStationRecord currentStation = viewModel.getCurrentStation(); |
||||
if (currentStation != null) { |
||||
LevelStationSettingActivity.start(requireContext(), getRouteId(), currentStation.getId(), false); |
||||
} |
||||
} else if (R.id.levelRouteResult == item.getItemId()) { |
||||
viewModel.calLevelRouteResult(result -> { |
||||
DialogUtil.showAlertDialog(requireContext(), getChildFragmentManager(), getViewLifecycleOwner(), result); |
||||
return null; |
||||
}); |
||||
} else if (R.id.receiveDataType == item.getItemId()) { |
||||
LevelInputAllowFragment.show(getChildFragmentManager(), getViewLifecycleOwner(), |
||||
mBinding.surveyor.getVisibility() == View.VISIBLE,//是否仪器获取数据
|
||||
auto -> { |
||||
viewModel.setGetDataAuto(getRouteId(), auto); |
||||
refreshManuleAutoInput(auto); |
||||
}); |
||||
} else if (R.id.test == item.getItemId()) { |
||||
TestDataSelectLevelFragment.show(getChildFragmentManager(), position -> { |
||||
LevelRequestTest levelReceiveData1 = (LevelRequestTest) levelRequest; |
||||
levelReceiveData1.initTestData(position); |
||||
}); |
||||
} else if (R.id.rollBackStation == item.getItemId()) { |
||||
startRollBackStation(); |
||||
} |
||||
return super.onOptionsItemSelected(item); |
||||
} |
||||
|
||||
private void startRollBackStation() { |
||||
if (!viewModel.getMeasureStationList().isEmpty()) { |
||||
String lastStationId = viewModel.getMeasureStationList().get(0).lastStationId; |
||||
if (TextUtils.isEmpty(lastStationId)) { |
||||
ToastUtils.showShort("没有上一站了"); |
||||
return; |
||||
} |
||||
showConfirmDialog("是否要回退至上一站,该操作将清空当前站所有数据", () -> { |
||||
viewModel.rollBackStation(); |
||||
}); |
||||
} |
||||
} |
||||
|
||||
|
||||
@Override |
||||
public void onDestroyView() { |
||||
super.onDestroyView(); |
||||
// EventBus.getDefault().unregister(this);
|
||||
levelRequest.onDestroy(); |
||||
LevelCheckBtnUtil.destroy(); |
||||
} |
||||
|
||||
@Override |
||||
protected void initView() { |
||||
setHasOptionsMenu(true); |
||||
initLevelRequest(); |
||||
stationSettingCheckUtil = new StationSettingCheckUtil(); |
||||
viewModel = new ViewModelProvider(this).get(LevelSuveyorVm.class); |
||||
|
||||
viewModel.initData(levelRefreshBtnI, () -> { |
||||
initViewPager(); |
||||
return null; |
||||
}, integer -> { |
||||
mBinding.vp.setCurrentItem(integer); |
||||
return null; |
||||
}, nextStationI); |
||||
|
||||
viewModel.getGetDadaAuto(getRouteId(), auto -> { |
||||
refreshManuleAutoInput(auto); |
||||
return null; |
||||
}); |
||||
|
||||
initTitle(); |
||||
|
||||
initListener(); |
||||
} |
||||
|
||||
private void initLevelRequest() { |
||||
if (Test.DEBUG) { |
||||
levelRequest = new LevelRequestTest(levelBackData); |
||||
} else { |
||||
levelRequest = new LevelRequestRelease(levelBackData); |
||||
} |
||||
levelRequest.onStart(); |
||||
} |
||||
|
||||
private void initTitle() { |
||||
mBinding.tvRouteName.setText("测段:" + getRouteName()); |
||||
} |
||||
|
||||
@Override |
||||
protected void initData() { |
||||
viewModel.initDataStationList(getProjectId(), getRouteId()); |
||||
|
||||
viewModel.checkSunTime(getProjectId(), hint -> { |
||||
if (!TextUtils.isEmpty(hint)) { |
||||
DialogUtil.showAlertDialog(requireContext(), getChildFragmentManager(), getViewLifecycleOwner(), hint); |
||||
} |
||||
return null; |
||||
}); |
||||
} |
||||
|
||||
private void initListener() { |
||||
mBinding.surveyor.setOnClickListener(v -> { |
||||
stationSettingCheckUtil.checkStationSettingsLevel(viewModel.getCurrentStationId(), getChildFragmentManager(), this, |
||||
requireContext(), |
||||
this, |
||||
() -> levelRequest.requeset()); |
||||
}); |
||||
|
||||
mBinding.btnNextStation.setOnClickListener(v -> { |
||||
stationSettingCheckUtil.checkStationSettingsLevel(viewModel.getCurrentStationId(), getChildFragmentManager(), this, |
||||
requireContext(), |
||||
this, |
||||
() -> { |
||||
LevelSurveySubFragment currentFragment = getCurrentFragment(); |
||||
if (currentFragment != null) { |
||||
currentFragment.nextStation(); |
||||
} |
||||
}); |
||||
}); |
||||
|
||||
mBinding.btnInput.setOnClickListener(v -> { |
||||
stationSettingCheckUtil.checkStationSettingsLevel(viewModel.getCurrentStationId(), getChildFragmentManager(), this, |
||||
requireContext(), |
||||
this, |
||||
() -> { |
||||
runOnUI(() -> { |
||||
LevelInputFragment.show(getChildFragmentManager(), getViewLifecycleOwner(), |
||||
(distance, height) -> receiveData(new LevelReceiveData(height, distance))); |
||||
|
||||
}); |
||||
}); |
||||
}); |
||||
|
||||
} |
||||
|
||||
private String getProjectId() { |
||||
return getArgumentString(BundleConstants.KEY_PROJECT_ID); |
||||
} |
||||
|
||||
private String getRouteId() { |
||||
return getArgumentString(BundleConstants.KEY_ROUTE_ID); |
||||
} |
||||
|
||||
private String getRouteName() { |
||||
return getArgumentString(BundleConstants.KEY_ROUTE_NAME); |
||||
} |
||||
|
||||
private void initViewPager() { |
||||
fragments = new ArrayList<>(); |
||||
for (int i = 0; i < viewModel.getMeasureStationList().size(); i++) { |
||||
fragments.add(LevelSurveySubFragment.newInstance(i)); |
||||
} |
||||
|
||||
if (myPagerAdapter == null) { |
||||
mBinding.vp.setOffscreenPageLimit(3); |
||||
myPagerAdapter = new MyPagerAdapter(getChildFragmentManager()); |
||||
mBinding.vp.setAdapter(myPagerAdapter); |
||||
mBinding.tabLayout.setViewPager(mBinding.vp); |
||||
|
||||
mBinding.vp.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { |
||||
@Override |
||||
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public void onPageSelected(int position) { |
||||
viewModel.setCurrentFragmentPos(position); |
||||
viewModel.switchRefreshBtnEnable(); |
||||
} |
||||
|
||||
@Override |
||||
public void onPageScrollStateChanged(int state) { |
||||
|
||||
} |
||||
}); |
||||
} else { |
||||
myPagerAdapter.notifyDataSetChanged(); |
||||
mBinding.tabLayout.notifyDataSetChanged(); |
||||
mBinding.tabLayout.setCurrentTab(0); |
||||
} |
||||
} |
||||
|
||||
private LevelSurveySubFragment getCurrentFragment() { |
||||
int currentFragmentPos = viewModel.getCurrentFragmentPos(); |
||||
if (fragments != null && fragments.size() > currentFragmentPos) { |
||||
return fragments.get(currentFragmentPos); |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
private void setViewEnable(View view, boolean measureEnable) { |
||||
view.setEnabled(measureEnable); |
||||
if (measureEnable) { |
||||
view.setAlpha(1); |
||||
} else { |
||||
view.setAlpha(.4f); |
||||
} |
||||
} |
||||
|
||||
private class MyPagerAdapter extends FragmentStatePagerAdapter { |
||||
public MyPagerAdapter(FragmentManager fm) { |
||||
super(fm); |
||||
} |
||||
|
||||
@Override |
||||
public int getCount() { |
||||
return fragments.size(); |
||||
} |
||||
|
||||
@Override |
||||
public CharSequence getPageTitle(int position) { |
||||
return viewModel.getMeasureStationList().get(position).stationName; |
||||
} |
||||
|
||||
@Override |
||||
public Fragment getItem(int position) { |
||||
return fragments.get(position); |
||||
} |
||||
|
||||
@Override |
||||
public int getItemPosition(@NonNull Object object) { |
||||
return PagerAdapter.POSITION_NONE; |
||||
} |
||||
} |
||||
|
||||
|
||||
private void showConfirmDialog(String content, TipsFragment.IConfirmCallback callback) { |
||||
TipsFragment.cancelAbleTips(getChildFragmentManager(), getViewLifecycleOwner(), requireContext(), |
||||
content, -1, callback); |
||||
} |
||||
|
||||
/** |
||||
* 下一站的弹框 |
||||
*/ |
||||
private void showSelectLevelNextStepDialog(LevelingStationRecord station) { |
||||
runOnUI(() -> SelectLevelNextStationTypeFragment.select(getChildFragmentManager(), getViewLifecycleOwner(), type -> { |
||||
switch (type) { |
||||
case SelectLevelNextStationTypeFragment.TYPE_CONTINUE_OBSERVE: |
||||
//继续观测
|
||||
startMeasureNextStation(station); |
||||
break; |
||||
case SelectLevelNextStationTypeFragment.TYPE_INTERMITTENT: |
||||
viewModel.intermittent(station); |
||||
break; |
||||
case SelectLevelNextStationTypeFragment.TYPE_END_STATION: |
||||
checkEndStation(station); |
||||
break; |
||||
} |
||||
})); |
||||
} |
||||
|
||||
/** |
||||
* 点击结束测站时验证 |
||||
* |
||||
* @param station |
||||
*/ |
||||
private void checkEndStation(LevelingStationRecord station) { |
||||
ThreadPoolUtil.execute(() -> { |
||||
//增加确认结束测站的提醒
|
||||
if (station.isOddStation()) { |
||||
//当前是奇数站
|
||||
ToastUtils.showShort("结束测站必须是偶数站!"); |
||||
return; |
||||
} |
||||
//是否设置过结束测站的测站设置
|
||||
boolean isSetEndStationSetting = viewModel.isHaveSetEndStationSetting(station.getId()); |
||||
if (!isSetEndStationSetting) { |
||||
runOnUI(() -> StationSettingCheckUtil.showLevelSetStationSetting(getChildFragmentManager(), |
||||
getViewLifecycleOwner(), getContext(), StationSettingCheckUtil.HINT_LEVEL_END, |
||||
getRouteId(), station.getId(), true)); |
||||
return; |
||||
} |
||||
runOnUI(() -> showConfirmEndRouteStartEndStation(station)); |
||||
}); |
||||
|
||||
} |
||||
|
||||
/** |
||||
* 下一站继续观测 |
||||
*/ |
||||
public void startMeasureNextStation(LevelingStationRecord station) { |
||||
viewModel.contineObserve(station); |
||||
} |
||||
|
||||
/** |
||||
* 结束路线开始下一站的确认提醒 |
||||
* |
||||
* @param station |
||||
*/ |
||||
private void showConfirmEndRouteStartEndStation(LevelingStationRecord station) { |
||||
DialogUtil.showConfirmDialog(getChildFragmentManager(), getViewLifecycleOwner(), Tools.getString(R.string.level_end_route_hint), Tools.getString(R.string.confirm), new DialogUtil.IConfirmBack() { |
||||
@Override |
||||
public void onConfirm() { |
||||
viewModel.endStation(station); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
private void refreshManuleAutoInput(boolean receiveDataTypeAuto) { |
||||
if (receiveDataTypeAuto) { |
||||
mBinding.surveyor.setVisibility(View.VISIBLE); |
||||
mBinding.btnInput.setVisibility(View.GONE); |
||||
} else { |
||||
mBinding.btnInput.setVisibility(View.VISIBLE); |
||||
mBinding.surveyor.setVisibility(View.GONE); |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,380 @@ |
||||
package com.bingce.controlnetwork.func.level.fragment; |
||||
|
||||
|
||||
import static com.bingce.controlapphelper.model.LevelToleranceNoticeKt.VALUE_IGNORE; |
||||
import static com.bingce.controlapphelper.model.LevelToleranceNoticeKt.VALUE_REMEASURE_POINT; |
||||
import static com.bingce.controlapphelper.model.LevelToleranceNoticeKt.VALUE_REMEASURE_STATION; |
||||
|
||||
import android.content.Intent; |
||||
import android.os.Bundle; |
||||
import android.view.LayoutInflater; |
||||
import android.view.View; |
||||
import android.view.ViewGroup; |
||||
import android.widget.TextView; |
||||
|
||||
import androidx.activity.result.ActivityResultLauncher; |
||||
import androidx.annotation.NonNull; |
||||
import androidx.annotation.Nullable; |
||||
import androidx.lifecycle.ViewModelProvider; |
||||
|
||||
import com.bingce.controlapphelper.datasource.database.leveling.LevelingDbFactory; |
||||
import com.bingce.controlapphelper.datasource.database.leveling.measure.backfront.LevelingMeasureBackFrontRecord; |
||||
import com.bingce.controlapphelper.datasource.database.leveling.measure.station.LevelingMeasureStationRecord; |
||||
import com.bingce.controlapphelper.datasource.database.leveling.station.LevelingStationRecord; |
||||
import com.bingce.controlapphelper.leveling.detaction.IDetectionHint; |
||||
import com.bingce.controlapphelper.leveling.detaction.LevelReceiveData; |
||||
import com.bingce.controlapphelper.leveling.detaction.LevelSpeakMsg; |
||||
import com.bingce.controlapphelper.leveling.detaction.surveyorcache.SurveyorCacheData; |
||||
import com.bingce.controlapphelper.model.LevelToleranceNotice; |
||||
import com.bingce.controlapphelper.model.LevelingMeasureOrderUtil; |
||||
import com.bingce.controlapphelper.model.PickPointResult; |
||||
import com.bingce.controlnetwork.R; |
||||
import com.bingce.controlnetwork.databinding.FragmentLevelSurveyorSubBinding; |
||||
import com.bingce.controlnetwork.fragment.PickPointFragment; |
||||
import com.bingce.controlnetwork.fragment.TipsFragment; |
||||
import com.bingce.controlnetwork.func.level.dialog.LevelToleranceTipsFragment; |
||||
import com.bingce.controlnetwork.newui.base.BaseFragmentBinding; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
import com.bingce.controlnetwork.func.level.viewmodel.LevelSuveyorSubVm; |
||||
import com.bingce.controlnetwork.func.level.viewmodel.LevelSuveyorVm; |
||||
import com.bingce.controlnetwork.util.DialogUtil; |
||||
|
||||
/** |
||||
* 水准测量页 |
||||
*/ |
||||
public class LevelSurveySubFragment extends BaseFragmentBinding<FragmentLevelSurveyorSubBinding> { |
||||
public static final String TAG = LevelSurveySubFragment.class.getName(); |
||||
private LevelSuveyorSubVm viewModel; |
||||
private LevelSuveyorVm stationListVm; |
||||
|
||||
|
||||
private final ActivityResultLauncher<Intent> defaultStationLauncher = PickPointFragment.createActivityLauncher(this, (type, pickPointResult) -> { |
||||
// if (pickPointResult.getSelectedIds().isEmpty() || pickPointResult.getSelectedNames().isEmpty()) {
|
||||
// return;
|
||||
// }
|
||||
// //只有前视才允许选点
|
||||
// String pointId = pickPointResult.getSelectedIds().get(0);
|
||||
// viewModel.saveMeasureFrontPointId(pointId, () -> {
|
||||
// setFrontPointNameUi(pickPointResult.getSelectedNames().get(0));
|
||||
// return null;
|
||||
// });
|
||||
}); |
||||
|
||||
// private void setFrontPointNameUi(String name) {
|
||||
// mBinding.ilPoint.tvPoint.setText(name);
|
||||
// }
|
||||
|
||||
public static LevelSurveySubFragment newInstance(int stationIndex) { |
||||
Bundle args = new Bundle(); |
||||
args.putInt(LevelSurveyFragment.KEY_STATION_INDEX, stationIndex); |
||||
LevelSurveySubFragment fragment = new LevelSurveySubFragment(); |
||||
fragment.setArguments(args); |
||||
return fragment; |
||||
} |
||||
|
||||
@Override |
||||
protected FragmentLevelSurveyorSubBinding getViewBinding(@NonNull LayoutInflater inflater, ViewGroup container) { |
||||
return FragmentLevelSurveyorSubBinding.inflate(inflater, container, false); |
||||
} |
||||
|
||||
@Override |
||||
protected void initView() { |
||||
viewModel = new ViewModelProvider(this).get(LevelSuveyorSubVm.class); |
||||
stationListVm = new ViewModelProvider(requireParentFragment()).get(LevelSuveyorVm.class); |
||||
|
||||
mBinding.ilSightDistanceDiffCurrent.tvTitle.setText("视距差:"); |
||||
mBinding.ilDistanceTotal.tvTitle.setText("总距离:"); |
||||
mBinding.ilSightDistanceDiffTotal.tvTitle.setText("累积视距差:"); |
||||
mBinding.ilHeightDiffTotal.tvTitle.setText("总高差:"); |
||||
mBinding.ilZ.tvTitle.setText("高程:"); |
||||
initListener(); |
||||
initObserver(); |
||||
} |
||||
|
||||
private void initObserver() { |
||||
viewModel.getStationLiveData().observe(this, stationRecord -> { |
||||
boolean measureBack = LevelingMeasureOrderUtil.INSTANCE.isMeasureBack(stationRecord); |
||||
|
||||
String backFrontType = measureBack ? getString(R.string.rearview) : getString(R.string.forward_view); |
||||
mBinding.tvBackFrontType.setText(backFrontType); |
||||
|
||||
//除了结束测站的第一个前视点可以选择测点
|
||||
// setSelectPointShowHide(stationRecord);
|
||||
|
||||
setMeasureOrderAndCurrent(stationRecord); |
||||
|
||||
setSurveyorCacheUiVisiable(stationRecord); |
||||
|
||||
// viewModel.getMeasurePointName(stationRecord, pointName -> {
|
||||
// setFrontPointNameUi(pointName);
|
||||
// return null;
|
||||
// });
|
||||
|
||||
}); |
||||
|
||||
viewModel.getSurveyorCacheDataLiveData().observe(this, this::setSurveyorCacheUi); |
||||
|
||||
viewModel.getMeasureStationLiveData().observe(this, this::setMeasureStationUi); |
||||
|
||||
//监听路线的最后一次设置更新尺子编号
|
||||
if (stationListVm.getRouteId() != null) { |
||||
LevelingDbFactory.instance.getStationSettingDataSource().getLatestLiveData(stationListVm.getRouteId()) |
||||
.observe(getViewLifecycleOwner(), levelingStationSettingRecord -> { |
||||
if (levelingStationSettingRecord != null) { |
||||
int stationIndex = getStationIndex(); |
||||
if (stationIndex == 0) { |
||||
mBinding.tvRulerNumBack.setText(getRulerNumShow(levelingStationSettingRecord.firstStationBackFootNumber)); |
||||
mBinding.tvRulerNumFront.setText(getRulerNumShow(levelingStationSettingRecord.firstStationFrontFootNumber)); |
||||
} else { |
||||
mBinding.tvRulerNumBack.setText(getRulerNumShow(levelingStationSettingRecord.firstStationBackFootNumber2)); |
||||
mBinding.tvRulerNumFront.setText(getRulerNumShow(levelingStationSettingRecord.firstStationFrontFootNumber2)); |
||||
} |
||||
} |
||||
}); |
||||
} |
||||
|
||||
} |
||||
|
||||
private String getRulerNumShow(String rulerNum) { |
||||
if (rulerNum==null) { |
||||
rulerNum = ""; |
||||
} |
||||
return "No." + rulerNum; |
||||
} |
||||
|
||||
private void setSelectPointShowHide(LevelingStationRecord stationRecord) { |
||||
viewModel.isEndStation(stationRecord, endStation -> { |
||||
//非单程双侧,前视,非终点站可以选择测点
|
||||
boolean measureFirstFront = LevelingMeasureOrderUtil.INSTANCE.isMeasureFirstFront(stationRecord); |
||||
boolean canSelectPoint = measureFirstFront && getStationIndex() == 0 && !endStation; |
||||
// mBinding.ilPoint.ivSelectPoint.setVisibility(canSelectPoint ? View.VISIBLE : View.INVISIBLE);
|
||||
// mBinding.ilPoint.tvPoint.setClickable(canSelectPoint);
|
||||
return null; |
||||
}); |
||||
} |
||||
|
||||
private void setSurveyorCacheUiVisiable(LevelingStationRecord stationRecord) { |
||||
boolean showTwiceRead = LevelingMeasureOrderUtil.INSTANCE.isShowTwiceRead(stationRecord); |
||||
if (showTwiceRead) { |
||||
mBinding.ilB2.getRoot().setVisibility(View.VISIBLE); |
||||
mBinding.ilF2.getRoot().setVisibility(View.VISIBLE); |
||||
} else { |
||||
mBinding.ilB2.getRoot().setVisibility(View.GONE); |
||||
mBinding.ilF2.getRoot().setVisibility(View.GONE); |
||||
} |
||||
|
||||
viewModel.setMeasureTextColor(stationRecord, mBinding.ilB1, mBinding.ilB2, mBinding.ilF1, mBinding.ilF2); |
||||
} |
||||
|
||||
private void setMeasureOrderAndCurrent(LevelingStationRecord stationRecord) { |
||||
// String textByLevelingMeasureOrder = LevelingMeasureOrderUtil.INSTANCE.getTextByLevelingMeasureOrder(stationRecord.levelingMeasureOrder);
|
||||
// mBinding.tvOrderType.setText(textByLevelingMeasureOrder);
|
||||
|
||||
CharSequence[] currentOrderArray = viewModel.getCurrentOrderArray(stationRecord); |
||||
mBinding.tvCurrentOrderOdd.setText(currentOrderArray[0]); |
||||
mBinding.tvCurrentOrderEven.setText(currentOrderArray[1]); |
||||
} |
||||
|
||||
private void setSurveyorCacheUi(SurveyorCacheData surveyorCacheData) { |
||||
LevelingMeasureBackFrontRecord b1Data = surveyorCacheData.getB1Data(); |
||||
LevelingMeasureBackFrontRecord b2Data = surveyorCacheData.getB2Data(); |
||||
LevelingMeasureBackFrontRecord f1Data = surveyorCacheData.getF1Data(); |
||||
LevelingMeasureBackFrontRecord f2Data = surveyorCacheData.getF2Data(); |
||||
|
||||
setSurveyorPointData(mBinding.ilB1.tvDisTance, mBinding.ilB1.tvHeight, b1Data); |
||||
setSurveyorPointData(mBinding.ilB2.tvDisTance, mBinding.ilB2.tvHeight, b2Data); |
||||
setSurveyorPointData(mBinding.ilF1.tvDisTance, mBinding.ilF1.tvHeight, f1Data); |
||||
setSurveyorPointData(mBinding.ilF2.tvDisTance, mBinding.ilF2.tvHeight, f2Data); |
||||
|
||||
//更新视距差
|
||||
String currentFrontBackDistancceDiff = surveyorCacheData.getCurrentFrontBackDistancceDiff(); |
||||
mBinding.ilSightDistanceDiffCurrent.tvValue.setText(currentFrontBackDistancceDiff); |
||||
} |
||||
|
||||
private void setSurveyorPointData(TextView tvDisTance, TextView tvHeight, LevelingMeasureBackFrontRecord data) { |
||||
if (data == null) { |
||||
tvDisTance.setText(""); |
||||
tvHeight.setText(""); |
||||
} else { |
||||
tvDisTance.setText(data.getMeasureDistanceShow()); |
||||
tvHeight.setText(data.getMeasureHeightShow()); |
||||
} |
||||
} |
||||
|
||||
private void setMeasureStationUi(LevelingMeasureStationRecord record) { |
||||
if (record == null) { |
||||
mBinding.ilDistanceTotal.tvValue.setText(""); |
||||
mBinding.ilSightDistanceDiffTotal.tvValue.setText(""); |
||||
mBinding.ilHeightDiffTotal.tvValue.setText(""); |
||||
mBinding.ilZ.tvValue.setText(""); |
||||
return; |
||||
} |
||||
|
||||
viewModel.getZ(z -> { |
||||
mBinding.ilZ.tvValue.setText(record.getZShow(z)); |
||||
return null; |
||||
}); |
||||
|
||||
mBinding.ilDistanceTotal.tvValue.setText(record.getDistanceTotalShow()); |
||||
mBinding.ilSightDistanceDiffTotal.tvValue.setText(record.getCumulativeVisualDistanceDiffShow()); |
||||
mBinding.ilHeightDiffTotal.tvValue.setText(record.getHeightDiffTotalShow()); |
||||
} |
||||
|
||||
@Override |
||||
protected void initData() { |
||||
String currentStationId = getCurrentStationId(); |
||||
if (currentStationId != null) { |
||||
viewModel.initData(currentStationId, new IDetectionHint() { |
||||
|
||||
@Override |
||||
public void noticeHint(@NonNull LevelToleranceNotice notice) { |
||||
LevelToleranceTipsFragment.tips(getChildFragmentManager(), getViewLifecycleOwner(), |
||||
notice.getTitle(), notice.getContent(), new LevelToleranceTipsFragment.IOperatorCallback() { |
||||
@Override |
||||
public void onReMeasureStation() { |
||||
notice.getNoticeBack().levelContinue(VALUE_REMEASURE_STATION, notice.getIgnoreToleranceList()); |
||||
} |
||||
|
||||
@Override |
||||
public void onReMeasurePoint() { |
||||
notice.getNoticeBack().levelContinue(VALUE_REMEASURE_POINT, notice.getIgnoreToleranceList()); |
||||
} |
||||
|
||||
@Override |
||||
public void onIgnore() { |
||||
notice.getNoticeBack().levelContinue(VALUE_IGNORE, notice.getIgnoreToleranceList()); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
@Override |
||||
public void stationCheckFinish(@NonNull LevelingStationRecord stationRecord) { |
||||
if (stationRecord.endStation) { |
||||
LevelSpeakMsg.speakStationFinish("该测段已观测完毕"); |
||||
stationListVm.calLevelRouteResult(result -> { |
||||
DialogUtil.showAlertDialog(requireContext(), getChildFragmentManager(), getViewLifecycleOwner(), |
||||
"该测段已观测完毕\n" + result); |
||||
return null; |
||||
}); |
||||
} else { |
||||
boolean simStation = stationRecord.isSimStation(); |
||||
if (simStation && !stationRecord.twiceStation) { |
||||
String hint = "请观测单程双转第二测站"; |
||||
LevelSpeakMsg.speakStationFinish(hint); |
||||
//单程双转的第一个测站提示
|
||||
TipsFragment.cancelAbleTips(getChildFragmentManager(), getViewLifecycleOwner(), requireContext(), |
||||
hint, -1, |
||||
() -> switchTwiceStation(stationRecord)); |
||||
} else { |
||||
String hint = getString(R.string.level_check_finish_next_station_hint); |
||||
LevelSpeakMsg.speakStationFinish(hint); |
||||
|
||||
TipsFragment.tipsOnly(getChildFragmentManager(), getViewLifecycleOwner(), requireContext(), |
||||
hint); |
||||
} |
||||
} |
||||
} |
||||
}, stationListVm.getNextStationI()); |
||||
} |
||||
} |
||||
|
||||
private String getCurrentStationId() { |
||||
int stationIndex = getStationIndex(); |
||||
List<LevelingStationRecord> measureStationList = stationListVm.getMeasureStationList(); |
||||
if (stationIndex >= 0 && measureStationList.size() > stationIndex) { |
||||
return measureStationList.get(stationIndex).getId(); |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
/** |
||||
* 开始切换到第二测站(第二个tab) |
||||
*/ |
||||
private void switchTwiceStation(LevelingStationRecord record) { |
||||
LevelSurveyFragment parentFragment = (LevelSurveyFragment) getParentFragment(); |
||||
if (parentFragment != null) { |
||||
parentFragment.startMeasureNextStation(record); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 去创建测段 |
||||
*/ |
||||
private void goCreateRoute() { |
||||
String projectId = viewModel.getProjectId(); |
||||
if (projectId != null) { |
||||
LevelRouteCreateEditFragment.start(requireContext(), projectId, null, getString(R.string.create_segment_survey)); |
||||
requireActivity().finish(); |
||||
} |
||||
} |
||||
|
||||
private void initListener() { |
||||
// mBinding.ilPoint.tvPoint.setOnClickListener((v) -> {
|
||||
// StringInputFragment.input(getChildFragmentManager(), "新建点", getViewLifecycleOwner(), string -> {
|
||||
// if (TextUtils.isEmpty(string)) return;
|
||||
// viewModel.saveMeasureFrontPoint(PointRecordTj.createHidePoint(string), () -> {
|
||||
// setFrontPointNameUi(string);
|
||||
// return null;
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
//
|
||||
// mBinding.ilPoint.ivSelectPoint.setOnClickListener((v) -> {
|
||||
// if (viewModel.getProjectId() == null) return;
|
||||
// PickPointResult alreadyResult = getAlreadySelectFrontPoint();
|
||||
// PickPointFragment.pickKnownAndUnknownPoint(getChildFragmentManager(),
|
||||
// getViewLifecycleOwner(),
|
||||
// getContext(),
|
||||
// "",
|
||||
// 1,
|
||||
// getString(R.string.select_surveyor_point),
|
||||
// null,
|
||||
// viewModel.getProjectId(), alreadyResult, defaultStationLauncher);
|
||||
// });
|
||||
|
||||
} |
||||
|
||||
@Nullable |
||||
private PickPointResult getAlreadySelectFrontPoint() { |
||||
PickPointResult alreadyResult = null; |
||||
LevelingStationRecord station = viewModel.getStationLiveData().getValue(); |
||||
String measurePointId = null; |
||||
if (station != null) { |
||||
measurePointId = LevelingMeasureOrderUtil.INSTANCE.getMeasurePointId(station); |
||||
} |
||||
if (measurePointId != null) { |
||||
alreadyResult = new PickPointResult(); |
||||
List<String> ids = new ArrayList<>(); |
||||
List<String> names = new ArrayList<>(); |
||||
ids.add(measurePointId); |
||||
alreadyResult.setSelectedIds(ids); |
||||
alreadyResult.setSelectedNames(names); |
||||
} |
||||
return alreadyResult; |
||||
} |
||||
|
||||
public void startRollBack() { |
||||
viewModel.startRollBack(); |
||||
} |
||||
|
||||
public void reMeasureStation() { |
||||
viewModel.reMeasureStation(); |
||||
} |
||||
|
||||
public void recieveData(LevelReceiveData data) { |
||||
if (viewModel != null) { |
||||
viewModel.recieveData(data); |
||||
} |
||||
} |
||||
|
||||
public void nextStation() { |
||||
viewModel.nextStation(); |
||||
} |
||||
|
||||
private int getStationIndex() { |
||||
return requireArguments().getInt(LevelSurveyFragment.KEY_STATION_INDEX); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,107 @@ |
||||
package com.bingce.controlnetwork.func.level.fragment; |
||||
|
||||
import android.os.Bundle; |
||||
import android.view.LayoutInflater; |
||||
import android.view.View; |
||||
import android.view.ViewGroup; |
||||
|
||||
import androidx.annotation.NonNull; |
||||
import androidx.annotation.Nullable; |
||||
|
||||
import com.bingce.controlapphelper.datasource.database.leveling.LevelingDbFactory; |
||||
import com.bingce.controlapphelper.datasource.database.leveling.route.LevelRouteRecord; |
||||
import com.bingce.controlapphelper.model.BundleConstants; |
||||
import com.bingce.controlnetwork.databinding.FragmentLevelSurveyorHomeBinding; |
||||
import com.bingce.controlnetwork.fragment.base.BaseFragment; |
||||
import com.bingce.controlnetwork.func.level.adapter.LevelRouteListAdapter; |
||||
|
||||
import blankj.utilcode.util.ToastUtils; |
||||
|
||||
|
||||
/** |
||||
* 水准测量首页 |
||||
*/ |
||||
public class LevelSurveyorHomeFragment extends BaseFragment { |
||||
public static final String TAG = LevelSurveyorHomeFragment.class.getName(); |
||||
private LevelRouteListAdapter adapter; |
||||
private FragmentLevelSurveyorHomeBinding mBinding; |
||||
|
||||
private static final String KEY_DETAIL_OR_SURVEYOR = "___editable___";//标识点击item进入测量界面还是测站详情
|
||||
|
||||
public static LevelSurveyorHomeFragment newInstance(String projectId, String routeId) { |
||||
return newInstance(projectId, routeId, true); |
||||
} |
||||
|
||||
public static LevelSurveyorHomeFragment newInstance(String projectId, String routeId, boolean detailOrSurveyor) { |
||||
LevelSurveyorHomeFragment fragment = new LevelSurveyorHomeFragment(); |
||||
Bundle bundle = new Bundle(); |
||||
bundle.putString(BundleConstants.KEY_PROJECT_ID, projectId); |
||||
bundle.putString(BundleConstants.KEY_ROUTE_ID, routeId); |
||||
bundle.putBoolean(KEY_DETAIL_OR_SURVEYOR, detailOrSurveyor); |
||||
fragment.setArguments(bundle); |
||||
return fragment; |
||||
} |
||||
|
||||
/** |
||||
* 去测量 |
||||
*/ |
||||
private void goMeasurePage(LevelRouteRecord item) { |
||||
String projectId = item.getProjectId(); |
||||
if (projectId == null) { |
||||
ToastUtils.showShort("项目id异常"); |
||||
return; |
||||
} |
||||
LevelSurveyFragment.start(getContext(), projectId, item.getId(), item.getRouteName()); |
||||
} |
||||
|
||||
@Nullable |
||||
@Override |
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { |
||||
mBinding = FragmentLevelSurveyorHomeBinding.inflate(inflater, container, false); |
||||
return mBinding.getRoot(); |
||||
} |
||||
|
||||
@Override |
||||
public void onDestroyView() { |
||||
super.onDestroyView(); |
||||
mBinding = null; |
||||
} |
||||
|
||||
@Override |
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { |
||||
super.onViewCreated(view, savedInstanceState); |
||||
initView(); |
||||
initData(); |
||||
} |
||||
|
||||
private void initView() { |
||||
adapter = new LevelRouteListAdapter(requireContext()); |
||||
mBinding.recyclerView.setAdapter(adapter); |
||||
adapter.setOnItemClickListener(this::goMeasurePage); |
||||
} |
||||
|
||||
private void initData() { |
||||
String projectId = getProjectId(); |
||||
if (projectId != null) { |
||||
LevelingDbFactory.instance.getLevelDataSource().getListLiveData(projectId) |
||||
.observe(getViewLifecycleOwner(), routeList -> { |
||||
adapter.refreshData(routeList); |
||||
}); |
||||
} |
||||
} |
||||
|
||||
private String getProjectId() { |
||||
if (getArguments() != null) { |
||||
return getArguments().getString(BundleConstants.KEY_PROJECT_ID); |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
private String getRouteId() { |
||||
if (getArguments() != null) { |
||||
return getArguments().getString(BundleConstants.KEY_ROUTE_ID); |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,162 @@ |
||||
package com.bingce.controlnetwork.func.level.fragment; |
||||
|
||||
import android.content.Context; |
||||
import android.os.Bundle; |
||||
import android.view.LayoutInflater; |
||||
import android.view.Menu; |
||||
import android.view.MenuInflater; |
||||
import android.view.MenuItem; |
||||
import android.view.View; |
||||
import android.view.ViewGroup; |
||||
import android.widget.Button; |
||||
|
||||
import androidx.annotation.NonNull; |
||||
import androidx.annotation.Nullable; |
||||
import androidx.fragment.app.FragmentActivity; |
||||
import androidx.lifecycle.ViewModelProvider; |
||||
|
||||
import com.bingce.controlapphelper.datasource.database.config.ConfigOperate; |
||||
import com.bingce.controlapphelper.event.SwitchPageEvent; |
||||
import com.bingce.controlapphelper.model.BundleConstants; |
||||
import com.bingce.controlnetwork.R; |
||||
import com.bingce.controlnetwork.activity.fragmentcontainer.FragmentContainerActivity; |
||||
import com.bingce.controlnetwork.fragment.PointListFragment; |
||||
import com.bingce.controlnetwork.fragment.ProjectToleranceSettingFragment; |
||||
import com.bingce.controlnetwork.fragment.base.BaseFragment; |
||||
import com.bingce.controlnetwork.func.level.idetection.LevelIDetectionListActivity; |
||||
import com.bingce.controlnetwork.func.level.viewmodel.LevelCreateOrEditRouteVm; |
||||
import com.bingce.controlnetwork.ui.ViewUtil; |
||||
import com.bingce.utils.ThreadPoolUtil; |
||||
|
||||
import org.greenrobot.eventbus.EventBus; |
||||
import org.jetbrains.annotations.NotNull; |
||||
|
||||
|
||||
/** |
||||
* 水准路线列表,新建测段 |
||||
*/ |
||||
public class ProjectDetailLevelFragment extends BaseFragment { |
||||
public static final int title = R.string.project_detail; |
||||
public static final String TAG = ProjectDetailLevelFragment.class.getName(); |
||||
private String projectId = ""; |
||||
private String projectType = ""; |
||||
//测站列表
|
||||
private LevelRouteFragment fragment; |
||||
|
||||
private LevelCreateOrEditRouteVm createEditRouteVm; |
||||
|
||||
|
||||
@Override |
||||
public View onCreateView(@NotNull LayoutInflater inflater, ViewGroup container, |
||||
Bundle savedInstanceState) { |
||||
if (getArguments() != null) { |
||||
projectId = getArguments().getString(BundleConstants.KEY_PROJECT_ID); |
||||
projectType = getArguments().getString(BundleConstants.KEY_PROJECT_TYPE); |
||||
} |
||||
createEditRouteVm = new ViewModelProvider(this).get(LevelCreateOrEditRouteVm.class); |
||||
View view = inflater.inflate(R.layout.fragment_project_detail_list_level, container, false); |
||||
fragment = LevelRouteFragment.newInstance(projectId); |
||||
getChildFragmentManager() |
||||
.beginTransaction() |
||||
.replace(R.id.fragment_container, fragment, "__station_list") |
||||
.commit(); |
||||
//已知点
|
||||
View known = view.findViewById(R.id.known_point_list); |
||||
initKnownPoint(known); |
||||
//未知点
|
||||
View unknown = view.findViewById(R.id.unknown_point_list); |
||||
initUnKnownPoint(unknown); |
||||
//新建测段
|
||||
View ilBtn = view.findViewById(R.id.ilBtn); |
||||
Button createNewRoute = ilBtn.findViewById(R.id.btnOne); |
||||
createNewRoute.setText(R.string.create_segment_survey); |
||||
initCreateNewRoute(createNewRoute); |
||||
//去测量页面
|
||||
Button ivGoMeasurePage = ilBtn.findViewById(R.id.btnTwo); |
||||
ivGoMeasurePage.setText(R.string.start_surveyor); |
||||
initGoMeasurePage(ivGoMeasurePage); |
||||
|
||||
setHasOptionsMenu(true); |
||||
return view; |
||||
} |
||||
|
||||
private void initGoMeasurePage(View ivGoMeasurePage) { |
||||
ViewUtil.setOnClick(ivGoMeasurePage, v -> { |
||||
FragmentActivity activity = getActivity(); |
||||
if (activity != null) { |
||||
activity.finish(); |
||||
} |
||||
|
||||
ThreadPoolUtil.execute(() -> { |
||||
String surveyorRouteId = fragment.getSurveyorRouteId(); |
||||
ConfigOperate.changeDefaultProjectAndRoute(projectId, surveyorRouteId); |
||||
EventBus.getDefault().post(new SwitchPageEvent<>(SwitchPageEvent.TYPE_SWITCH_TO_MEASURE_PAGE_AND_DATA, null)); |
||||
}); |
||||
}); |
||||
} |
||||
|
||||
private void initUnKnownPoint(View unknown) { |
||||
ViewUtil.setOnClick(unknown, |
||||
v -> PointListFragment.go2UnknownPointList(projectId, getContext())); |
||||
} |
||||
|
||||
private void initKnownPoint(View known) { |
||||
ViewUtil.setOnClick( |
||||
known, |
||||
v -> PointListFragment.go2KnownPointList(projectId, getContext())); |
||||
} |
||||
|
||||
@Override |
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { |
||||
super.onViewCreated(view, savedInstanceState); |
||||
getData(); |
||||
} |
||||
|
||||
private void getData() { |
||||
|
||||
} |
||||
|
||||
/** |
||||
* 新建测段 |
||||
*/ |
||||
private void initCreateNewRoute(View viewCreateRoute) { |
||||
if (viewCreateRoute != null) { |
||||
viewCreateRoute.setOnClickListener((v) -> createEditRouteVm.showCreateOrEditDialog( |
||||
requireContext(), |
||||
projectId, |
||||
null |
||||
)); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) { |
||||
inflater.inflate(R.menu.project_detail_fragment_menu_level, menu); |
||||
super.onCreateOptionsMenu(menu, inflater); |
||||
} |
||||
|
||||
@Override |
||||
public boolean onOptionsItemSelected(@NonNull MenuItem item) { |
||||
if (item.getItemId() == R.id.project_parameter_setting) { |
||||
//设置参数点击事件
|
||||
ProjectToleranceSettingFragment.start(getContext(), projectId, projectType); |
||||
return true; |
||||
} else if (R.id.iAngleDetection == item.getItemId()) { |
||||
LevelIDetectionListActivity.launch(requireContext(), projectId); |
||||
} |
||||
return super.onOptionsItemSelected(item); |
||||
} |
||||
|
||||
public static void start(Context context, String projectType, String projectId, String projectName) { |
||||
Bundle bundle = new Bundle(); |
||||
bundle.putString(BundleConstants.KEY_PROJECT_ID, projectId); |
||||
bundle.putString(BundleConstants.KEY_PROJECT_TYPE, projectType); |
||||
FragmentContainerActivity.start(context, TAG, projectName, bundle); |
||||
} |
||||
|
||||
public static ProjectDetailLevelFragment newInstance(Bundle bundle) { |
||||
ProjectDetailLevelFragment fragment = new ProjectDetailLevelFragment(); |
||||
fragment.setArguments(bundle); |
||||
return fragment; |
||||
} |
||||
} |
@ -0,0 +1,282 @@ |
||||
package com.bingce.controlnetwork.func.level.fragment; |
||||
|
||||
import android.content.Context; |
||||
import android.content.Intent; |
||||
import android.os.Bundle; |
||||
import android.view.LayoutInflater; |
||||
import android.view.View; |
||||
import android.view.ViewGroup; |
||||
import android.widget.AdapterView; |
||||
import android.widget.ArrayAdapter; |
||||
import android.widget.Button; |
||||
import android.widget.EditText; |
||||
import android.widget.Spinner; |
||||
import android.widget.Toast; |
||||
|
||||
import androidx.activity.result.ActivityResultLauncher; |
||||
import androidx.annotation.NonNull; |
||||
import androidx.annotation.Nullable; |
||||
import androidx.annotation.WorkerThread; |
||||
import androidx.fragment.app.DialogFragment; |
||||
import androidx.fragment.app.FragmentManager; |
||||
|
||||
import com.bingce.controlapphelper.datasource.database.ProjectTypeValue; |
||||
import com.bingce.controlapphelper.datasource.database.SurveyorDatabaseFactory; |
||||
import com.bingce.controlapphelper.datasource.database.project.ProjectRecord; |
||||
import com.bingce.controlapphelper.datasource.database.tolerance.detail.IToleranceDetail; |
||||
import com.bingce.controlapphelper.datasource.database.tolerance.detail.ToleranceDetailRecord; |
||||
import com.bingce.controlapphelper.datasource.database.tolerance.group.ToleranceGroupRecord; |
||||
import com.bingce.controlapphelper.datasource.database.tolerance.level.ToleranceLevelRecord; |
||||
import com.bingce.controlapphelper.datasource.database.tolerance.load.IToleranceOperate; |
||||
import com.bingce.controlapphelper.model.LevelingMeasureOrder; |
||||
import com.bingce.controlapphelper.model.LevelingMeasureOrderUtil; |
||||
import com.bingce.controlapphelper.util.ToleranceUtil; |
||||
import com.bingce.controlnetwork.R; |
||||
import com.bingce.controlnetwork.fragment.AbstractFullScreenDialogFragment; |
||||
import com.bingce.controlnetwork.fragment.ToleranceSelectFragment; |
||||
import com.bingce.controlnetwork.util.tolerance.ToleranceOperateUtil; |
||||
import com.bingce.utils.DateUtils; |
||||
import com.bingce.utils.ThreadPoolUtil; |
||||
|
||||
import java.util.Date; |
||||
import java.util.List; |
||||
|
||||
import blankj.utilcode.util.ToastUtils; |
||||
|
||||
|
||||
/** |
||||
* 水准新建编辑项目 |
||||
*/ |
||||
public class ProjectEditForLevelFragment extends AbstractFullScreenDialogFragment { |
||||
public final String TAG = ProjectEditForLevelFragment.class.getSimpleName(); |
||||
private String toleranceId; |
||||
private final ActivityResultLauncher<Intent> activityResultLauncher; |
||||
|
||||
private LevelingMeasureOrder levelingMeasureOrder; |
||||
|
||||
public ProjectEditForLevelFragment() { |
||||
super(); |
||||
activityResultLauncher = ToleranceSelectFragment |
||||
.createActivityLauncher( |
||||
this, |
||||
this::dealSelectTolerance); |
||||
} |
||||
|
||||
@Override |
||||
protected View createContentView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { |
||||
View view = inflater.inflate(R.layout.fragment_project_edit_for_level, container, false); |
||||
|
||||
Button selectToleranceButton = view.findViewById(R.id.select_tolerance); |
||||
if (selectToleranceButton != null) { |
||||
selectToleranceButton.setOnClickListener(v -> |
||||
//选择限差方案
|
||||
ToleranceSelectFragment.start(getContext(), toleranceId, ProjectTypeValue.LEVEL, activityResultLauncher) |
||||
); |
||||
} |
||||
//设置项目名称
|
||||
EditText projectNameEdit = view.findViewById(R.id.editor); |
||||
if (projectNameEdit != null && getArguments() != null) { |
||||
String projectName = getArguments().getString(KEY_PROJECT_NAME); |
||||
if (projectName == null || projectName.isEmpty()) { |
||||
projectName = DateUtils.ymdWithCharacter(new Date()); |
||||
} |
||||
projectNameEdit.setText(projectName); |
||||
} |
||||
if (getArguments() != null) { |
||||
toleranceId = getArguments().getString(KEY_TOLERANCE_ID); |
||||
if (toleranceId != null && !toleranceId.isEmpty()) { |
||||
ThreadPoolUtil.execute(() -> { |
||||
ToleranceDetailRecord instance = |
||||
SurveyorDatabaseFactory |
||||
.instance |
||||
.getToleranceDetailDataSource() |
||||
.getRecordSync(toleranceId); |
||||
updateTolerance(selectToleranceButton, instance); |
||||
}); |
||||
} |
||||
|
||||
String projectId = getArguments().getString(KEY_PROJECT_ID); |
||||
if (projectId != null && !projectId.isEmpty()) { |
||||
ThreadPoolUtil.execute(() -> { |
||||
ProjectRecord projectRecord = |
||||
SurveyorDatabaseFactory |
||||
.instance |
||||
.getProjectDataSource() |
||||
.getRecord(projectId); |
||||
if (projectRecord == null) { |
||||
return; |
||||
} |
||||
}); |
||||
} |
||||
} |
||||
return view; |
||||
} |
||||
|
||||
@WorkerThread |
||||
private void updateTolerance(Button button, IToleranceDetail iToleranceDetail) { |
||||
if (iToleranceDetail == null) { |
||||
return; |
||||
} |
||||
toleranceId = iToleranceDetail.getId(); |
||||
|
||||
IToleranceOperate operate = ToleranceOperateUtil.getOperate(toleranceId); |
||||
if (operate == null) return; |
||||
ToleranceGroupRecord group = operate.getGroup(iToleranceDetail); |
||||
ToleranceLevelRecord level = operate.getLevel(iToleranceDetail); |
||||
runOnUI(() -> { |
||||
if (button != null) { |
||||
String toleranceShowName = ToleranceUtil.completedToleranceName(group, level, iToleranceDetail); |
||||
button.setText(toleranceShowName); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
@Override |
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { |
||||
super.onViewCreated(view, savedInstanceState); |
||||
List<String> showList = LevelingMeasureOrderUtil.INSTANCE.getShowList(); |
||||
Spinner spinner = view.findViewById(R.id.spinner); |
||||
spinner.setAdapter(new ArrayAdapter<>(requireContext(), android.R.layout.simple_list_item_1, showList)); |
||||
// spinner.setSelection(editTextItem.prismTypes.indexOf(editTextItem.surveyorPoint.getPrismTypeName()));
|
||||
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { |
||||
@Override |
||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { |
||||
levelingMeasureOrder = LevelingMeasureOrderUtil.INSTANCE.getLevelingMeasureOrderByCreate(showList.get(position)); |
||||
} |
||||
|
||||
@Override |
||||
public void onNothingSelected(AdapterView<?> parent) { |
||||
|
||||
} |
||||
}); |
||||
} |
||||
|
||||
private void runOnUI(Runnable runnable) { |
||||
if (getActivity() != null) { |
||||
getActivity().runOnUiThread(runnable); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
protected boolean quitWhenTouchBg() { |
||||
return true; |
||||
} |
||||
|
||||
@Override |
||||
protected void onConfirm() { |
||||
View view = getView(); |
||||
if (view == null) { |
||||
return; |
||||
} |
||||
//判断项目名称是否为空
|
||||
EditText editor = view.findViewById(R.id.editor); |
||||
String projectName = editor.getText().toString(); |
||||
if (projectName.isEmpty()) { |
||||
Toast.makeText(getContext(), R.string.tips_need_select_input_project_name, Toast.LENGTH_SHORT).show(); |
||||
return; |
||||
} |
||||
//判断限差参数
|
||||
if (toleranceId == null || toleranceId.isEmpty()) { |
||||
Toast.makeText(getContext(), R.string.tips_need_select_project_tolerance, Toast.LENGTH_SHORT).show(); |
||||
return; |
||||
} |
||||
if (levelingMeasureOrder == null) { |
||||
ToastUtils.showShort(R.string.please_select_measure_order); |
||||
return; |
||||
} |
||||
if (getArguments() == null) { |
||||
return; |
||||
} |
||||
String projectId = getArguments().getString(KEY_PROJECT_ID); |
||||
boolean showSlop = true; |
||||
if (projectId == null || projectId.isEmpty()) { |
||||
ProjectRecord projectRecord = new ProjectRecord(projectName); |
||||
projectRecord.setToleranceId(toleranceId); |
||||
projectRecord.projectType = ProjectTypeValue.LEVEL; |
||||
projectRecord.setShowSlopDistance(showSlop); |
||||
//存储
|
||||
SurveyorDatabaseFactory |
||||
.instance |
||||
.getProjectDataSource() |
||||
.saveRecordSync(projectRecord); |
||||
|
||||
|
||||
//判断是否需要记录默认项目和测期
|
||||
// ThreadPoolUtil.execute(() -> {
|
||||
// IConfigDataSource configDataSource =
|
||||
// TjDbFactory.instance.getConfigDataSource();
|
||||
// ConfigRecord defaultProject = configDataSource.getByKeySync(ConfigConstantsTj.KEY_DEFAULT_PROJECT_ID);
|
||||
// if (defaultProject != null && !defaultProject.getConfigValue().isEmpty()) {
|
||||
// return;
|
||||
// }
|
||||
// });
|
||||
} else { |
||||
ThreadPoolUtil.execute(() -> { |
||||
ProjectRecord projectRecord = |
||||
SurveyorDatabaseFactory |
||||
.instance |
||||
.getProjectDataSource() |
||||
.getRecord(projectId); |
||||
projectRecord.setProjectName(projectName); |
||||
projectRecord.setToleranceId(toleranceId); |
||||
projectRecord.setShowSlopDistance(showSlop); |
||||
//存储
|
||||
SurveyorDatabaseFactory |
||||
.instance |
||||
.getProjectDataSource() |
||||
.saveRecordSync(projectRecord); |
||||
}); |
||||
} |
||||
super.onConfirm(); |
||||
} |
||||
|
||||
private static final String KEY_PROJECT_ID = "___project__id"; |
||||
private static final String KEY_TOLERANCE_ID = "___tolerance_id"; |
||||
private static final String KEY_PROJECT_NAME = "___project___name___"; |
||||
|
||||
private static DialogFragment newInstance(Context context, String projectId, String toleranceId, String projectName) { |
||||
ProjectEditForLevelFragment fragment = new ProjectEditForLevelFragment(); |
||||
Bundle args = new Bundle(); |
||||
if (projectId == null || projectId.isEmpty()) { |
||||
setArgs(args, context.getString(R.string.title_create_new_project), null); |
||||
} else { |
||||
setArgs(args, context.getString(R.string.title_edit_project), null); |
||||
args.putString(KEY_PROJECT_ID, projectId); |
||||
args.putString(KEY_TOLERANCE_ID, toleranceId); |
||||
args.putString(KEY_PROJECT_NAME, projectName); |
||||
} |
||||
fragment.setArguments(args); |
||||
return fragment; |
||||
} |
||||
|
||||
public static void editProject(FragmentManager fragmentManager, |
||||
Context context, |
||||
String projectId, String toleranceId, String projectName) { |
||||
newInstance(context, projectId, toleranceId, projectName).show(fragmentManager, "_edit_project_fragment"); |
||||
} |
||||
|
||||
public static void createProject(FragmentManager fragmentManager, Context context) { |
||||
newInstance(context, null, null, null) |
||||
.show(fragmentManager, "__create_project_fragment__"); |
||||
} |
||||
|
||||
/** |
||||
* 处理选择返回的限差id |
||||
* |
||||
* @param id |
||||
*/ |
||||
private void dealSelectTolerance(String id) { |
||||
ThreadPoolUtil.execute(() -> { |
||||
IToleranceOperate operate = ToleranceOperateUtil.getOperate(id); |
||||
if (operate == null) return; |
||||
IToleranceDetail toleranceDetail = operate.getIToleranceDetail(id); |
||||
//存限差数据
|
||||
operate.saveToleranceDetail(toleranceDetail); |
||||
View view = getView(); |
||||
if (view != null) { |
||||
updateTolerance(view.findViewById(R.id.select_tolerance), toleranceDetail); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,136 @@ |
||||
package com.bingce.controlnetwork.func.level.fragment; |
||||
|
||||
import android.app.Dialog; |
||||
import android.content.Context; |
||||
import android.os.Bundle; |
||||
import android.view.LayoutInflater; |
||||
import android.view.View; |
||||
import android.view.ViewGroup; |
||||
import android.view.Window; |
||||
import android.view.WindowManager; |
||||
import android.widget.TextView; |
||||
|
||||
import androidx.annotation.NonNull; |
||||
import androidx.annotation.Nullable; |
||||
import androidx.fragment.app.DialogFragment; |
||||
import androidx.fragment.app.FragmentManager; |
||||
import androidx.recyclerview.widget.RecyclerView; |
||||
|
||||
import com.bingce.controlnetwork.R; |
||||
|
||||
import org.jetbrains.annotations.NotNull; |
||||
|
||||
import java.util.List; |
||||
|
||||
import com.bingce.controlnetwork.func.level.sendreceive.TestData; |
||||
|
||||
public class TestDataSelectLevelFragment extends DialogFragment { |
||||
private static IClickItem clickItem; |
||||
|
||||
@Nullable |
||||
@Override |
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { |
||||
View view = inflater.inflate(R.layout.fragment_single_list_layout, container, false); |
||||
|
||||
// Set the adapter
|
||||
if (view instanceof RecyclerView) { |
||||
RecyclerView recyclerView = (RecyclerView) view; |
||||
refreshRecyclerView(recyclerView); |
||||
} |
||||
|
||||
return view; |
||||
} |
||||
|
||||
@Override |
||||
public void onViewCreated(@NonNull @NotNull View view, @Nullable @org.jetbrains.annotations.Nullable Bundle savedInstanceState) { |
||||
super.onViewCreated(view, savedInstanceState); |
||||
Dialog dialog = getDialog(); |
||||
if (dialog == null) { |
||||
return; |
||||
} |
||||
Window window = dialog.getWindow(); |
||||
if (window == null) { |
||||
return; |
||||
} |
||||
window.setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT); |
||||
WindowManager.LayoutParams lps = window.getAttributes(); |
||||
lps.verticalMargin = 0.4F; |
||||
lps.horizontalMargin = 0.4F; |
||||
window.setAttributes(lps); |
||||
} |
||||
|
||||
protected void refreshRecyclerView(RecyclerView recyclerView) { |
||||
List<String> list = TestData.Companion.getTextShowList(); |
||||
recyclerView.setAdapter(new MyAdapter(list)); |
||||
} |
||||
|
||||
public static void show(FragmentManager fragmentManager, IClickItem clickItem) { |
||||
TestDataSelectLevelFragment.clickItem = clickItem; |
||||
TestDataSelectLevelFragment fragment = new TestDataSelectLevelFragment(); |
||||
fragment.show(fragmentManager, TestDataSelectLevelFragment.class.getName()); |
||||
} |
||||
|
||||
private class MyAdapter extends RecyclerView.Adapter<ViewHolder> { |
||||
|
||||
private final List<String> data; |
||||
|
||||
public MyAdapter(List<String> data) { |
||||
this.data = data; |
||||
} |
||||
|
||||
@NonNull |
||||
@Override |
||||
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { |
||||
Context context = parent.getContext(); |
||||
LayoutInflater inflater = LayoutInflater.from(context); |
||||
|
||||
// Inflate the custom layout
|
||||
View itemView = inflater.inflate(R.layout.list_item_index_text_layout, parent, false); |
||||
|
||||
// Return a new holder instance
|
||||
return new ViewHolder(itemView); |
||||
} |
||||
|
||||
@Override |
||||
public void onBindViewHolder(@NonNull ViewHolder holder, int position) { |
||||
// Get the data model based on position
|
||||
String item = data.get(position); |
||||
|
||||
// Set item views based on your views and data model
|
||||
holder.index.setText(String.valueOf(position + 1)); |
||||
holder.text.setText(item); |
||||
|
||||
holder.itemView.setOnClickListener(v -> { |
||||
if (clickItem != null) { |
||||
clickItem.click(holder.getBindingAdapterPosition()); |
||||
|
||||
dismissAllowingStateLoss(); |
||||
} |
||||
|
||||
}); |
||||
} |
||||
|
||||
@Override |
||||
public int getItemCount() { |
||||
return data.size(); |
||||
} |
||||
|
||||
// Provide a reference to the views for each data item
|
||||
|
||||
} |
||||
|
||||
private static class ViewHolder extends RecyclerView.ViewHolder { |
||||
public TextView index; |
||||
public TextView text; |
||||
|
||||
public ViewHolder(View itemView) { |
||||
super(itemView); |
||||
index = itemView.findViewById(R.id.index); |
||||
text = itemView.findViewById(R.id.text); |
||||
} |
||||
} |
||||
|
||||
public interface IClickItem { |
||||
void click(int position); |
||||
} |
||||
} |
@ -0,0 +1,234 @@ |
||||
package com.bingce.controlnetwork.func.level.idetection |
||||
|
||||
import com.bingce.controlapphelper.datasource.database.leveling.idetection.constants.LevelIDetectionConstant |
||||
import com.bingce.controlapphelper.datasource.database.leveling.idetection.record.LevelIDetectionRecord |
||||
import kotlin.math.pow |
||||
|
||||
object LevelIDetectionCalUtil { |
||||
private val station1 = LevelIDetectionConstant.STATION_TYPE_0 |
||||
private val station2 = LevelIDetectionConstant.STATION_TYPE_1 |
||||
private val ruler1 = LevelIDetectionConstant.RULER_TYPE_0 |
||||
private val ruler2 = LevelIDetectionConstant.RULER_TYPE_1 |
||||
private val measureTime1 = LevelIDetectionConstant.MEASURE_TIME_0 |
||||
private val measureTime2 = LevelIDetectionConstant.MEASURE_TIME_1 |
||||
private val measureTime3 = LevelIDetectionConstant.MEASURE_TIME_2 |
||||
private val measureTime4 = LevelIDetectionConstant.MEASURE_TIME_3 |
||||
private val measureTime5 = LevelIDetectionConstant.MEASURE_TIME_4 |
||||
|
||||
/** |
||||
* 单位mm |
||||
* d1短距 |
||||
* d2长距 |
||||
*/ |
||||
fun getIResult( |
||||
iDetectionId: String, |
||||
measureType: String, |
||||
d1: Double, |
||||
d2: Double, |
||||
stationRecordMap: HashMap<String, LevelIDetectionRecord> |
||||
): Double { |
||||
val a1 = getA1(iDetectionId, stationRecordMap) |
||||
val b1 = getB1(iDetectionId, stationRecordMap) |
||||
val a2 = getA2(iDetectionId, stationRecordMap) |
||||
val b2 = getB2(iDetectionId, stationRecordMap) |
||||
val deTa = getDeTa(measureType, a1, b1, a2, b2) |
||||
return getI(deTa, d1, d2) |
||||
} |
||||
|
||||
private fun getI(deTa: Double, d1: Double, d2: Double) = |
||||
deTa * 206265 / (d2 - d1) - 1.61 * 10.0.pow(-5.0) * (d1 + d2) |
||||
|
||||
|
||||
private fun getDeTa( |
||||
measureType: String, |
||||
a1: Double, |
||||
b1: Double, |
||||
a2: Double, |
||||
b2: Double |
||||
): Double { |
||||
return if (LevelIDetectionConstant.A_I_I_B == measureType || LevelIDetectionConstant.I_A_B_I == measureType) { |
||||
((a2 - b2) - (a1 - b1)) / 2 |
||||
} else { |
||||
(a2 - b2) - (a1 - b1) |
||||
} |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 一站一尺 |
||||
*/ |
||||
private fun getA1( |
||||
iDetectionId: String, |
||||
stationRecordMap: HashMap<String, LevelIDetectionRecord> |
||||
): Double { |
||||
val height1 = getHeight( |
||||
stationRecordMap[LevelIDetectionRecord.getRecordId( |
||||
iDetectionId, station1, ruler1, |
||||
measureTime1 |
||||
)] |
||||
) |
||||
val height2 = getHeight( |
||||
stationRecordMap[LevelIDetectionRecord.getRecordId( |
||||
iDetectionId, station1, ruler1, |
||||
measureTime2 |
||||
)] |
||||
) |
||||
val height3 = getHeight( |
||||
stationRecordMap[LevelIDetectionRecord.getRecordId( |
||||
iDetectionId, station1, ruler1, |
||||
measureTime3 |
||||
)] |
||||
) |
||||
val height4 = getHeight( |
||||
stationRecordMap[LevelIDetectionRecord.getRecordId( |
||||
iDetectionId, station1, ruler1, |
||||
measureTime4 |
||||
)] |
||||
) |
||||
val height5 = getHeight( |
||||
stationRecordMap[LevelIDetectionRecord.getRecordId( |
||||
iDetectionId, station1, ruler1, |
||||
measureTime5 |
||||
)] |
||||
) |
||||
return getAverage(height1, height2, height3, height4, height5) |
||||
} |
||||
|
||||
/** |
||||
* 一站二尺 |
||||
*/ |
||||
private fun getB1( |
||||
iDetectionId: String, |
||||
stationRecordMap: HashMap<String, LevelIDetectionRecord> |
||||
): Double { |
||||
val height1 = getHeight( |
||||
stationRecordMap[LevelIDetectionRecord.getRecordId( |
||||
iDetectionId, station1, ruler2, |
||||
measureTime1 |
||||
)] |
||||
) |
||||
val height2 = getHeight( |
||||
stationRecordMap[LevelIDetectionRecord.getRecordId( |
||||
iDetectionId, station1, ruler2, |
||||
measureTime2 |
||||
)] |
||||
) |
||||
val height3 = getHeight( |
||||
stationRecordMap[LevelIDetectionRecord.getRecordId( |
||||
iDetectionId, station1, ruler2, |
||||
measureTime3 |
||||
)] |
||||
) |
||||
val height4 = getHeight( |
||||
stationRecordMap[LevelIDetectionRecord.getRecordId( |
||||
iDetectionId, station1, ruler2, |
||||
measureTime4 |
||||
)] |
||||
) |
||||
val height5 = getHeight( |
||||
stationRecordMap[LevelIDetectionRecord.getRecordId( |
||||
iDetectionId, station1, ruler2, |
||||
measureTime5 |
||||
)] |
||||
) |
||||
return getAverage(height1, height2, height3, height4, height5) |
||||
} |
||||
|
||||
/** |
||||
* 二站一尺 |
||||
*/ |
||||
private fun getA2( |
||||
iDetectionId: String, |
||||
stationRecordMap: HashMap<String, LevelIDetectionRecord> |
||||
): Double { |
||||
val height1 = getHeight( |
||||
stationRecordMap[LevelIDetectionRecord.getRecordId( |
||||
iDetectionId, station2, ruler1, |
||||
measureTime1 |
||||
)] |
||||
) |
||||
val height2 = getHeight( |
||||
stationRecordMap[LevelIDetectionRecord.getRecordId( |
||||
iDetectionId, station2, ruler1, |
||||
measureTime2 |
||||
)] |
||||
) |
||||
val height3 = getHeight( |
||||
stationRecordMap[LevelIDetectionRecord.getRecordId( |
||||
iDetectionId, station2, ruler1, |
||||
measureTime3 |
||||
)] |
||||
) |
||||
val height4 = getHeight( |
||||
stationRecordMap[LevelIDetectionRecord.getRecordId( |
||||
iDetectionId, station2, ruler1, |
||||
measureTime4 |
||||
)] |
||||
) |
||||
val height5 = getHeight( |
||||
stationRecordMap[LevelIDetectionRecord.getRecordId( |
||||
iDetectionId, station2, ruler1, |
||||
measureTime5 |
||||
)] |
||||
) |
||||
return getAverage(height1, height2, height3, height4, height5) |
||||
} |
||||
|
||||
/** |
||||
* 二站二尺 |
||||
*/ |
||||
private fun getB2( |
||||
iDetectionId: String, |
||||
stationRecordMap: HashMap<String, LevelIDetectionRecord> |
||||
): Double { |
||||
val height1 = getHeight( |
||||
stationRecordMap[LevelIDetectionRecord.getRecordId( |
||||
iDetectionId, station2, ruler2, |
||||
measureTime1 |
||||
)] |
||||
) |
||||
val height2 = getHeight( |
||||
stationRecordMap[LevelIDetectionRecord.getRecordId( |
||||
iDetectionId, station2, ruler2, |
||||
measureTime2 |
||||
)] |
||||
) |
||||
val height3 = getHeight( |
||||
stationRecordMap[LevelIDetectionRecord.getRecordId( |
||||
iDetectionId, station2, ruler2, |
||||
measureTime3 |
||||
)] |
||||
) |
||||
val height4 = getHeight( |
||||
stationRecordMap[LevelIDetectionRecord.getRecordId( |
||||
iDetectionId, station2, ruler2, |
||||
measureTime4 |
||||
)] |
||||
) |
||||
val height5 = getHeight( |
||||
stationRecordMap[LevelIDetectionRecord.getRecordId( |
||||
iDetectionId, station2, ruler2, |
||||
measureTime5 |
||||
)] |
||||
) |
||||
return getAverage(height1, height2, height3, height4, height5) |
||||
} |
||||
|
||||
private fun getHeight(record: LevelIDetectionRecord?): Double { |
||||
return record?.height ?: 0.0 |
||||
} |
||||
|
||||
/** |
||||
* 返回单位mm |
||||
*/ |
||||
private fun getAverage( |
||||
height1: Double, |
||||
height2: Double, |
||||
height3: Double, |
||||
height4: Double, |
||||
height5: Double |
||||
): Double { |
||||
return (height1 + height2 + height3 + height4 + height5) / 5 * 1000 |
||||
} |
||||
|
||||
} |
@ -0,0 +1,101 @@ |
||||
package com.bingce.controlnetwork.func.level.idetection |
||||
|
||||
import android.content.Context |
||||
import android.content.Intent |
||||
import androidx.activity.viewModels |
||||
import com.bingce.controlapphelper.datasource.database.leveling.idetection.list.LevelIDetectionList |
||||
import com.bingce.controlapphelper.model.BundleConstants |
||||
import com.bingce.controlapphelper.util.Tools |
||||
import com.bingce.controlapphelper.widget.swiperecyclerview.widget.DefaultItemDecoration |
||||
import com.bingce.controlnetwork.R |
||||
import com.bingce.controlnetwork.databinding.ActivityLevelIDetectionListBinding |
||||
import com.bingce.controlnetwork.func.level.fragment.LevelIDetectionCreateFragment |
||||
import com.bingce.controlnetwork.func.level.idetection.adapter.LevelIDetectionListAdapter |
||||
import com.bingce.controlnetwork.func.level.idetection.viewmodel.LevelIDetectionListVm |
||||
import com.bingce.controlnetwork.newui.base.BaseBindingActivity |
||||
import com.bingce.controlnetwork.newui.widget.swipemenu.SwipeMenuDelete |
||||
import com.bingce.controlnetwork.util.DialogUtil |
||||
import com.bingce.utils.DateUtils |
||||
import java.util.Date |
||||
|
||||
/** |
||||
* 水准i角检测列表 |
||||
*/ |
||||
class LevelIDetectionListActivity : BaseBindingActivity<ActivityLevelIDetectionListBinding>() { |
||||
private val viewModel by viewModels<LevelIDetectionListVm>() |
||||
|
||||
private val adater by lazy { |
||||
LevelIDetectionListAdapter(this) |
||||
} |
||||
|
||||
companion object { |
||||
@JvmStatic |
||||
fun launch(context: Context, projectId: String) { |
||||
context.startActivity(Intent(context, LevelIDetectionListActivity::class.java).apply { |
||||
putExtra(BundleConstants.KEY_PROJECT_ID, projectId) |
||||
}) |
||||
} |
||||
} |
||||
|
||||
override fun getBinding(): ActivityLevelIDetectionListBinding { |
||||
return ActivityLevelIDetectionListBinding.inflate(layoutInflater) |
||||
} |
||||
|
||||
override fun initView() { |
||||
initAdapter() |
||||
initListener() |
||||
} |
||||
|
||||
private fun initListener() { |
||||
mBinding.tvCreateIAngleDetection.setOnClickListener { |
||||
LevelIDetectionCreateFragment.input( |
||||
supportFragmentManager, |
||||
"i角检测名称", |
||||
DateUtils.ymdHMSWithCharacter(Date()), |
||||
this |
||||
) { name -> viewModel.saveNewRecord(getProjectId(), name) } |
||||
|
||||
} |
||||
} |
||||
|
||||
private fun initAdapter() { |
||||
mBinding.ilSwipeList.swipeRecyclerView.addItemDecoration( |
||||
DefaultItemDecoration( |
||||
Tools.getColor(R.color.transparent), 1, 1 |
||||
) |
||||
) |
||||
mBinding.ilSwipeList.swipeRecyclerView.setSwipeMenuCreator( |
||||
SwipeMenuDelete(this) |
||||
) |
||||
mBinding.ilSwipeList.swipeRecyclerView.setOnItemMenuClickListener { menuBridge, adapterPosition -> |
||||
menuBridge.closeMenu() |
||||
dealMenuClick(menuBridge.position, adater.getBean(adapterPosition)) |
||||
} |
||||
mBinding.ilSwipeList.swipeRecyclerView.setOnItemClickListener { view, adapterPosition -> |
||||
val bean = adater.getBean(adapterPosition) |
||||
LevelIDetectionRecordActivity.launch(this, bean.id) |
||||
} |
||||
mBinding.ilSwipeList.swipeRecyclerView.adapter = adater |
||||
} |
||||
|
||||
private fun dealMenuClick(position: Int, bean: LevelIDetectionList?) { |
||||
DialogUtil.showConfirmDialog( |
||||
supportFragmentManager, this, "您确定要删除该i角检测吗?", |
||||
Tools.getString(R.string.confirm) |
||||
) { |
||||
bean?.let { |
||||
viewModel.deleteRecord(it) |
||||
} |
||||
} |
||||
} |
||||
|
||||
override fun initData() { |
||||
viewModel.getListLiveData(getProjectId()).observe(this) { |
||||
adater.refreshData(it) |
||||
} |
||||
} |
||||
|
||||
private fun getProjectId() = intent.getStringExtra(BundleConstants.KEY_PROJECT_ID)!! |
||||
|
||||
|
||||
} |
@ -0,0 +1,371 @@ |
||||
package com.bingce.controlnetwork.func.level.idetection |
||||
|
||||
import android.content.Context |
||||
import android.content.Intent |
||||
import android.text.TextUtils |
||||
import android.view.Menu |
||||
import android.view.MenuItem |
||||
import android.view.View |
||||
import android.widget.EditText |
||||
import androidx.activity.viewModels |
||||
import blankj.utilcode.util.ToastUtils |
||||
import com.bingce.controlnetwork.func.level.idetection.viewmodel.LevelIDetectionRecordVm |
||||
import com.bingce.controlnetwork.func.level.sendreceive.ILevelBackData |
||||
import com.bingce.controlnetwork.func.level.sendreceive.LevelRequest |
||||
import cn.liuyanbing.surveyor.function.level.sendreceive.LevelRequestRelease |
||||
import com.bingce.controlnetwork.newui.widget.selectitem.SelectIDetectionStationFragment |
||||
import com.bingce.controlapphelper.datasource.database.leveling.idetection.constants.LevelIDetectionConstant |
||||
import com.bingce.controlapphelper.datasource.database.leveling.idetection.constants.LevelIDetectionConstant.I_A_B_I |
||||
import com.bingce.controlapphelper.datasource.database.leveling.idetection.list.LevelIDetectionList |
||||
import com.bingce.controlapphelper.leveling.detaction.LevelReceiveData |
||||
import com.bingce.controlapphelper.model.BundleConstants |
||||
import com.bingce.controlapphelper.util.Tools |
||||
import com.bingce.controlapphelper.widget.swiperecyclerview.widget.DefaultItemDecoration |
||||
import com.bingce.controlnetwork.R |
||||
import com.bingce.controlnetwork.databinding.ActivityLevelIDetectionRecordBinding |
||||
import com.bingce.controlnetwork.event.RefreshEvent |
||||
import com.bingce.controlnetwork.fragment.TipsFragment |
||||
import com.bingce.controlnetwork.func.level.fragment.LevelInputAllowFragment |
||||
import com.bingce.controlnetwork.func.level.fragment.LevelInputFragment |
||||
import com.bingce.controlnetwork.func.level.idetection.adapter.LevelIDetectionRecordAdapter |
||||
import com.bingce.controlnetwork.newui.base.BaseBindingActivity |
||||
import com.bingce.controlnetwork.newui.widget.selectitem.BaseSelectItemFragment |
||||
import com.bingce.controlnetwork.newui.widget.selectitem.SelectIDetectionStationMeasureTypeFragment |
||||
import com.bingce.controlnetwork.util.DialogUtil |
||||
import com.bingce.controlnetwork.util.StationSettingCheckUtil |
||||
import com.bingce.utils.ScreenUtil |
||||
import org.greenrobot.eventbus.EventBus |
||||
import org.greenrobot.eventbus.Subscribe |
||||
import org.greenrobot.eventbus.ThreadMode |
||||
|
||||
/** |
||||
* 水准i角检测-测量 |
||||
*/ |
||||
class LevelIDetectionRecordActivity : BaseBindingActivity<ActivityLevelIDetectionRecordBinding>() { |
||||
private val viewModel by viewModels<LevelIDetectionRecordVm>() |
||||
|
||||
private val stationSettingCheckUtil = StationSettingCheckUtil() |
||||
|
||||
private val adapter by lazy { |
||||
LevelIDetectionRecordAdapter(this, surveyorData) |
||||
} |
||||
|
||||
private val surveyorData by lazy { |
||||
LevelIDetectionSurveyorData(getIDetectionId()) |
||||
} |
||||
|
||||
private val levelReceiveData: LevelRequest = LevelRequestRelease(object : ILevelBackData { |
||||
override fun receive(data: LevelReceiveData) { |
||||
receiveData(data) |
||||
} |
||||
|
||||
override fun measureError(msg: String) { |
||||
if (isDestroyed || isFinishing) { |
||||
return |
||||
} |
||||
DialogUtil.showAlertDialog( |
||||
this@LevelIDetectionRecordActivity, |
||||
supportFragmentManager, |
||||
this@LevelIDetectionRecordActivity, |
||||
msg |
||||
) |
||||
} |
||||
}) |
||||
|
||||
@Subscribe(threadMode = ThreadMode.BACKGROUND) |
||||
fun refresh(event: RefreshEvent<*>) { |
||||
if (event.type == RefreshEvent.REFRESH_BY_LEVEL_I_DETECTION_SETTING_UPDATE) { |
||||
viewModel.updateStationSetting() |
||||
adapter.setStationSetting(viewModel.stationSetting) |
||||
runOnUiThread { |
||||
adapter.notifyDataSetChanged() |
||||
} |
||||
} |
||||
} |
||||
|
||||
companion object { |
||||
@JvmStatic |
||||
fun launch(context: Context, levelIDetectionId: String) { |
||||
context.startActivity(Intent(context, LevelIDetectionRecordActivity::class.java).apply { |
||||
putExtra(BundleConstants.KEY_I_DETECTION_ID, levelIDetectionId) |
||||
}) |
||||
} |
||||
} |
||||
|
||||
override fun getBinding(): ActivityLevelIDetectionRecordBinding { |
||||
return ActivityLevelIDetectionRecordBinding.inflate(layoutInflater) |
||||
} |
||||
|
||||
override fun onDestroy() { |
||||
super.onDestroy() |
||||
levelReceiveData.onDestroy() |
||||
EventBus.getDefault().unregister(this) |
||||
} |
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu?): Boolean { |
||||
menuInflater.inflate(R.menu.menu_level_survey_i_detection, menu) |
||||
return super.onCreateOptionsMenu(menu) |
||||
} |
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean { |
||||
if (R.id.result == item.itemId) { |
||||
startIResult() |
||||
} else if (R.id.stationSetting == item.itemId) { |
||||
goLevelIDetectionSetting() |
||||
} else if (R.id.rollBack == item.itemId) { |
||||
startRollBack() |
||||
} else if (R.id.level_i_detection_sample == item.itemId) { |
||||
LevelIDetectionSampleActivity.launch(this) |
||||
} else if (R.id.receiveDataType == item.itemId) { |
||||
showReceiveDataTypeDialog() |
||||
} |
||||
return super.onOptionsItemSelected(item) |
||||
} |
||||
|
||||
/** |
||||
* i角检测的测站设置 |
||||
*/ |
||||
private fun goLevelIDetectionSetting() { |
||||
LevelIDetectionStationSettingActivity.launch(this, getIDetectionId()) |
||||
} |
||||
|
||||
private fun showReceiveDataTypeDialog() { |
||||
LevelInputAllowFragment.show( |
||||
supportFragmentManager, |
||||
this, |
||||
mBinding.surveyor.visibility == View.VISIBLE |
||||
) { |
||||
viewModel.setGetDataAuto(getIDetectionId(), it) |
||||
refreshManuleAutoInput(it) |
||||
} |
||||
} |
||||
|
||||
private fun startIResult() { |
||||
val d1String = getEtText(mBinding.etShortDistance) |
||||
if (TextUtils.isEmpty(d1String)) { |
||||
ToastUtils.showShort("请输入短距") |
||||
return |
||||
} |
||||
val d2String = getEtText(mBinding.etLongDistance) |
||||
if (TextUtils.isEmpty(d2String)) { |
||||
ToastUtils.showShort("请输入长距") |
||||
return |
||||
} |
||||
|
||||
if (viewModel.measureType == null) { |
||||
ToastUtils.showShort("请选择测量方式") |
||||
return |
||||
} |
||||
|
||||
//存短长距和测量方式 |
||||
viewModel.saveShortLongDistanceMeasureType(d1String, d2String) |
||||
//计算结果 |
||||
val result = viewModel.startResult(getD(d1String), getD(d2String)) |
||||
if (!TextUtils.isEmpty(result)) { |
||||
DialogUtil.showAlertDialog( |
||||
this, |
||||
supportFragmentManager, |
||||
this, |
||||
result |
||||
) |
||||
} |
||||
} |
||||
|
||||
private fun getEtText(et: EditText): String { |
||||
return et.text.toString().trim() |
||||
} |
||||
|
||||
/** |
||||
* 返回mm的D |
||||
*/ |
||||
private fun getD(value: String): Double { |
||||
return value.toDouble() * 1000 |
||||
} |
||||
|
||||
private fun startRollBack() { |
||||
val findRollBackData = viewModel.findRollBackData() |
||||
if (findRollBackData == null) { |
||||
ToastUtils.showShort("没有可以回退的数据") |
||||
return |
||||
} |
||||
|
||||
val deleteStationShow = |
||||
LevelIDetectionConstant.getStationTypeShow(findRollBackData.currentStationType) |
||||
val deleteRuleShow = |
||||
LevelIDetectionConstant.getRulerTypeShow(findRollBackData.currentRulerType) |
||||
|
||||
val hint = "回退操作将删除 $deleteStationShow $deleteRuleShow 的数据,您是否还要回退?" |
||||
|
||||
showConfirmDialog(hint) { |
||||
viewModel.deleteStationRulerData(findRollBackData) { |
||||
refreshAdapterAndButton() |
||||
} |
||||
} |
||||
} |
||||
|
||||
override fun initView() { |
||||
EventBus.getDefault().register(this) |
||||
levelReceiveData.onStart() |
||||
initAdapter() |
||||
|
||||
initListener() |
||||
|
||||
viewModel.getGetDadaAuto(getIDetectionId()) { |
||||
refreshManuleAutoInput(it) |
||||
} |
||||
} |
||||
|
||||
private fun initListener() { |
||||
mBinding.llStation.setOnClickListener { |
||||
if (adapter.itemCount == 0) { |
||||
ToastUtils.showShort("数据加载中,请稍后尝试") |
||||
return@setOnClickListener |
||||
} |
||||
BaseSelectItemFragment.select( |
||||
SelectIDetectionStationFragment(), |
||||
supportFragmentManager, |
||||
this, object : BaseSelectItemFragment.ISelectItem { |
||||
override fun onBack(value: String) { |
||||
//value stationType |
||||
viewModel.switchStation(value.toInt()) |
||||
setCurrentStation() |
||||
refreshAdapterAndButton() |
||||
} |
||||
}) |
||||
} |
||||
|
||||
mBinding.llMeasureType.setOnClickListener { |
||||
BaseSelectItemFragment.select( |
||||
SelectIDetectionStationMeasureTypeFragment(), |
||||
supportFragmentManager, |
||||
this, object : BaseSelectItemFragment.ISelectItem { |
||||
override fun onBack(value: String) { |
||||
switchMeasureType(value) |
||||
} |
||||
}) |
||||
} |
||||
|
||||
mBinding.surveyor.setOnClickListener { |
||||
stationSettingCheckUtil.checkStationSettingsIDetection( |
||||
getIDetectionId(), |
||||
this, |
||||
this::runOnUiThread |
||||
) { |
||||
levelReceiveData.requeset() |
||||
} |
||||
} |
||||
|
||||
mBinding.btnInput.setOnClickListener { |
||||
LevelInputFragment.show( |
||||
supportFragmentManager, this |
||||
) { distance: Double, height: Double -> |
||||
receiveData(LevelReceiveData(height, distance)) |
||||
} |
||||
} |
||||
} |
||||
|
||||
private fun receiveData(data: LevelReceiveData) { |
||||
if (isFinishing || isDestroyed) { |
||||
return |
||||
} |
||||
viewModel.receiveData(data.height, data.distance) |
||||
refreshAdapterAndButton() |
||||
} |
||||
|
||||
/** |
||||
* 切换测量方法带存储 |
||||
*/ |
||||
private fun switchMeasureType(measureType: String) { |
||||
setCurrentMeasureType(measureType) |
||||
viewModel.saveMeasureType(getIDetectionId(), measureType) |
||||
} |
||||
|
||||
private fun setCurrentMeasureType(measureType: String?) { |
||||
mBinding.tvMeasureType.text = measureType |
||||
viewModel.measureType = measureType |
||||
} |
||||
|
||||
private fun setCurrentStation() { |
||||
val stationTypeShow = |
||||
LevelIDetectionConstant.getStationTypeShow(surveyorData.currentStationType) |
||||
mBinding.tvStation.text = stationTypeShow |
||||
} |
||||
|
||||
private fun initAdapter() { |
||||
mBinding.recyclerView.adapter = adapter |
||||
mBinding.recyclerView.addItemDecoration( |
||||
DefaultItemDecoration( |
||||
Tools.getColor(R.color.transparent), |
||||
1, |
||||
ScreenUtil.dp2px(this, 10f) |
||||
) |
||||
) |
||||
} |
||||
|
||||
override fun initData() { |
||||
viewModel.initData(surveyorData) { |
||||
adapter.setStationSetting(viewModel.stationSetting) |
||||
|
||||
setCurrentStation() |
||||
|
||||
if (it.measureType == null) { |
||||
switchMeasureType(I_A_B_I) |
||||
} else { |
||||
setCurrentMeasureType(it.measureType) |
||||
} |
||||
|
||||
//设置短长距 |
||||
setShortLongDistance(it) |
||||
|
||||
refreshButton() |
||||
|
||||
adapter.refreshData(viewModel.dataListAdapter) |
||||
} |
||||
} |
||||
|
||||
private fun setShortLongDistance(it: LevelIDetectionList) { |
||||
mBinding.etShortDistance.setText(it.shortDistance) |
||||
mBinding.etLongDistance.setText(it.longDistance) |
||||
} |
||||
|
||||
private fun getIDetectionId() = intent.getStringExtra(BundleConstants.KEY_I_DETECTION_ID)!! |
||||
|
||||
|
||||
private fun showConfirmDialog(content: String, callback: TipsFragment.IConfirmCallback) { |
||||
TipsFragment.cancelAbleTips( |
||||
supportFragmentManager, this, this, |
||||
content, -1, callback |
||||
) |
||||
} |
||||
|
||||
private fun refreshAdapterAndButton() { |
||||
adapter.notifyDataSetChanged() |
||||
refreshButton() |
||||
} |
||||
|
||||
private fun refreshButton() { |
||||
//刷新测量按钮 |
||||
setViewEnable(mBinding.surveyor, surveyorData.isHaveSurveyor()) |
||||
setViewEnable(mBinding.btnInput, surveyorData.isHaveSurveyor()) |
||||
} |
||||
|
||||
private fun setViewEnable(view: View, measureEnable: Boolean) { |
||||
view.isEnabled = measureEnable |
||||
if (measureEnable) { |
||||
view.alpha = 1f |
||||
} else { |
||||
view.alpha = .4f |
||||
} |
||||
} |
||||
|
||||
private fun refreshManuleAutoInput(receiveDataTypeAuto: Boolean) { |
||||
if (receiveDataTypeAuto) { |
||||
mBinding.surveyor.visibility = View.VISIBLE |
||||
mBinding.btnInput.visibility = View.GONE |
||||
} else { |
||||
mBinding.btnInput.visibility = View.VISIBLE |
||||
mBinding.surveyor.visibility = View.GONE |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,31 @@ |
||||
package com.bingce.controlnetwork.func.level.idetection |
||||
|
||||
import android.content.Context |
||||
import android.content.Intent |
||||
import com.bingce.controlnetwork.databinding.ActivityLevelIDetectionSampleBinding |
||||
import com.bingce.controlnetwork.newui.base.BaseBindingActivity |
||||
|
||||
/** |
||||
* 水准i角检测示例图 |
||||
*/ |
||||
class LevelIDetectionSampleActivity : BaseBindingActivity<ActivityLevelIDetectionSampleBinding>() { |
||||
|
||||
companion object { |
||||
@JvmStatic |
||||
fun launch(context: Context) { |
||||
context.startActivity(Intent(context, LevelIDetectionSampleActivity::class.java)) |
||||
} |
||||
} |
||||
|
||||
override fun getBinding(): ActivityLevelIDetectionSampleBinding { |
||||
return ActivityLevelIDetectionSampleBinding.inflate(layoutInflater) |
||||
} |
||||
|
||||
override fun initView() { |
||||
|
||||
} |
||||
|
||||
override fun initData() { |
||||
} |
||||
|
||||
} |
@ -0,0 +1,173 @@ |
||||
package com.bingce.controlnetwork.func.level.idetection |
||||
|
||||
import android.content.Context |
||||
import android.content.Intent |
||||
import android.text.TextUtils |
||||
import android.view.Menu |
||||
import android.view.MenuItem |
||||
import android.widget.ArrayAdapter |
||||
import androidx.lifecycle.lifecycleScope |
||||
import blankj.utilcode.util.ToastUtils |
||||
import com.bingce.controlnetwork.func.level.constant.LevelStationSettingContant |
||||
import com.bingce.controlnetwork.func.level.util.LevelStationSettingUtil |
||||
import com.bingce.controlapphelper.datasource.database.leveling.LevelingDbFactory |
||||
import com.bingce.controlapphelper.datasource.database.leveling.idetection.isetting.LevelIDetectionSetting |
||||
import com.bingce.controlapphelper.model.BundleConstants |
||||
import com.bingce.controlnetwork.R |
||||
import com.bingce.controlnetwork.databinding.ActivityLevelIDetectionStationSettingBinding |
||||
import com.bingce.controlnetwork.event.RefreshEvent |
||||
import com.bingce.controlnetwork.newui.base.BaseBindingActivity |
||||
import kotlinx.coroutines.Dispatchers |
||||
import kotlinx.coroutines.launch |
||||
import kotlinx.coroutines.withContext |
||||
import org.greenrobot.eventbus.EventBus |
||||
|
||||
/** |
||||
* i角检测测站设置 |
||||
*/ |
||||
class LevelIDetectionStationSettingActivity : |
||||
BaseBindingActivity<ActivityLevelIDetectionStationSettingBinding>() { |
||||
|
||||
companion object { |
||||
@JvmStatic |
||||
fun launch(context: Context, iDetectionId: String) { |
||||
context.startActivity( |
||||
Intent( |
||||
context, |
||||
LevelIDetectionStationSettingActivity::class.java |
||||
).apply { |
||||
putExtra(BundleConstants.KEY_I_DETECTION_ID, iDetectionId) |
||||
}) |
||||
} |
||||
} |
||||
|
||||
override fun getBinding(): ActivityLevelIDetectionStationSettingBinding { |
||||
return ActivityLevelIDetectionStationSettingBinding.inflate(layoutInflater) |
||||
} |
||||
|
||||
override fun initView() { |
||||
initEditTextTitle() |
||||
initSpinnerImaging() |
||||
} |
||||
|
||||
override fun initData() { |
||||
getEditData() |
||||
} |
||||
|
||||
private fun getEditData() { |
||||
lifecycleScope.launch(Dispatchers.IO) { |
||||
val iDetectionId = getIDetectionId() |
||||
val record = |
||||
LevelingDbFactory.instance.iDetectionSettingDataSource.getByIDetectionId( |
||||
iDetectionId |
||||
) |
||||
|
||||
if (record != null) { |
||||
withContext(Dispatchers.Main) { |
||||
setData(record) |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 初始化editText坐标的title |
||||
*/ |
||||
private fun initEditTextTitle() { |
||||
mBinding.ilWatcher.tvTitle.text = "观测者" |
||||
mBinding.ilRecorder.tvTitle.text = "记录者" |
||||
mBinding.ilExaminer.tvTitle.text = "检查者" |
||||
mBinding.ilRuler1.tvTitle.text = "尺一编号" |
||||
mBinding.ilRuler2.tvTitle.text = "尺二编号" |
||||
mBinding.ilInstrumentModel.tvTitle.text = "仪器型号" |
||||
mBinding.ilDeviceNumber.tvTitle.text = "仪器编号" |
||||
} |
||||
|
||||
private fun setData(record: LevelIDetectionSetting) { |
||||
mBinding.ilWatcher.editText.setText(record.watcher) |
||||
mBinding.ilRecorder.editText.setText(record.recorder) |
||||
mBinding.ilExaminer.editText.setText(record.examiner) |
||||
mBinding.ilRuler1.editText.setText(record.rulerNum1) |
||||
mBinding.ilRuler2.editText.setText(record.rulerNum2) |
||||
mBinding.ilInstrumentModel.editText.setText(record.instrumentModel) |
||||
mBinding.ilDeviceNumber.editText.setText(record.deviceNumber) |
||||
mBinding.spinnerImaging.setSelection(LevelStationSettingContant.imagingList.indexOf(record.imaging)) |
||||
} |
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu?): Boolean { |
||||
menuInflater.inflate(R.menu.menu_save, menu) |
||||
return super.onCreateOptionsMenu(menu) |
||||
} |
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean { |
||||
if (item.itemId == R.id.menuSave) { |
||||
startSave() |
||||
} |
||||
return super.onOptionsItemSelected(item) |
||||
} |
||||
|
||||
private fun initSpinnerImaging() { |
||||
mBinding.spinnerImaging.adapter = ArrayAdapter( |
||||
this, |
||||
android.R.layout.simple_list_item_1, |
||||
LevelStationSettingContant.imagingList |
||||
) |
||||
} |
||||
|
||||
private fun startSave() { |
||||
val watcher = mBinding.ilWatcher.editText.text.toString().trim() |
||||
val recorder = mBinding.ilRecorder.editText.text.toString().trim() |
||||
val examiner = mBinding.ilExaminer.editText.text.toString().trim() |
||||
val ruler1 = mBinding.ilRuler1.editText.text.toString().trim() |
||||
val ruler2 = mBinding.ilRuler2.editText.text.toString().trim() |
||||
val instrumentModel = mBinding.ilInstrumentModel.editText.text.toString().trim() |
||||
val deviceNumber = mBinding.ilDeviceNumber.editText.text.toString().trim() |
||||
val imaging = LevelStationSettingUtil.getSpinnerText(mBinding.spinnerImaging) |
||||
|
||||
if (isEmpty(ruler1)) { |
||||
ToastUtils.showShort("请输入尺一编号") |
||||
return |
||||
} |
||||
if (isEmpty(ruler2)) { |
||||
ToastUtils.showShort("请输入尺二编号") |
||||
return |
||||
} |
||||
|
||||
lifecycleScope.launch(Dispatchers.IO) { |
||||
val iDetectionId = getIDetectionId() |
||||
val record = |
||||
LevelingDbFactory.instance.iDetectionSettingDataSource.getByIDetectionId( |
||||
iDetectionId |
||||
) |
||||
|
||||
val saveRecord = record ?: LevelIDetectionSetting(iDetectionId) |
||||
|
||||
saveRecord.watcher = watcher |
||||
saveRecord.recorder = recorder |
||||
saveRecord.examiner = examiner |
||||
saveRecord.rulerNum1 = ruler1 |
||||
saveRecord.rulerNum2 = ruler2 |
||||
saveRecord.instrumentModel = instrumentModel |
||||
saveRecord.deviceNumber = deviceNumber |
||||
saveRecord.imaging = imaging |
||||
|
||||
if (record == null) { |
||||
LevelingDbFactory.instance.iDetectionSettingDataSource.save(saveRecord) |
||||
} else { |
||||
LevelingDbFactory.instance.iDetectionSettingDataSource.update(saveRecord) |
||||
} |
||||
|
||||
EventBus.getDefault() |
||||
.post(RefreshEvent(RefreshEvent.REFRESH_BY_LEVEL_I_DETECTION_SETTING_UPDATE, null)) |
||||
|
||||
finish() |
||||
} |
||||
|
||||
} |
||||
|
||||
private fun isEmpty(value: String?) = TextUtils.isEmpty(value) |
||||
|
||||
|
||||
private fun getIDetectionId() = intent.getStringExtra(BundleConstants.KEY_I_DETECTION_ID)!! |
||||
|
||||
} |
@ -0,0 +1,14 @@ |
||||
package com.bingce.controlnetwork.func.level.idetection |
||||
|
||||
import com.bingce.controlapphelper.datasource.database.leveling.idetection.constants.LevelIDetectionConstant |
||||
|
||||
/** |
||||
* 当前测量的测站,尺子,第几个 |
||||
*/ |
||||
class LevelIDetectionSurveyorData(val currentIDetectionId: String) { |
||||
var currentStationType = LevelIDetectionConstant.STATION_TYPE_0 |
||||
var currentMeasureTime = LevelIDetectionConstant.MEASURE_TIME_0 |
||||
var currentRulerType = -1//默认不选中尺寸,因为可能已经测完 |
||||
|
||||
fun isHaveSurveyor() = currentRulerType != -1 |
||||
} |
@ -0,0 +1,34 @@ |
||||
package com.bingce.controlnetwork.func.level.idetection.adapter; |
||||
|
||||
import android.content.Context; |
||||
import android.view.ViewGroup; |
||||
|
||||
import androidx.annotation.NonNull; |
||||
|
||||
import com.bingce.controlapphelper.datasource.database.leveling.idetection.list.LevelIDetectionList; |
||||
import com.bingce.controlnetwork.databinding.ItemLevelIDetectionListBinding; |
||||
import com.bingce.controlnetwork.newui.adapter.BaseAdapterNew; |
||||
|
||||
|
||||
/** |
||||
* i角检测列表 |
||||
*/ |
||||
public class LevelIDetectionListAdapter extends BaseAdapterNew<LevelIDetectionListHolder, LevelIDetectionList> { |
||||
|
||||
public LevelIDetectionListAdapter(Context context) { |
||||
super(context); |
||||
} |
||||
|
||||
@Override |
||||
protected void onBindViewHolderDo(LevelIDetectionListHolder holder, int position) { |
||||
LevelIDetectionList bean = mDataList.get(position); |
||||
holder.mBinding.tvIndex.setText(String.valueOf(position + 1)); |
||||
holder.mBinding.tvName.setText(bean.name); |
||||
} |
||||
|
||||
@NonNull |
||||
@Override |
||||
public LevelIDetectionListHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { |
||||
return new LevelIDetectionListHolder(ItemLevelIDetectionListBinding.inflate(getInflater(), parent, false)); |
||||
} |
||||
} |
@ -0,0 +1,15 @@ |
||||
package com.bingce.controlnetwork.func.level.idetection.adapter; |
||||
|
||||
import androidx.recyclerview.widget.RecyclerView; |
||||
|
||||
import com.bingce.controlnetwork.databinding.ItemLevelIDetectionListBinding; |
||||
|
||||
|
||||
public class LevelIDetectionListHolder extends RecyclerView.ViewHolder { |
||||
public final ItemLevelIDetectionListBinding mBinding; |
||||
|
||||
public LevelIDetectionListHolder(ItemLevelIDetectionListBinding binding) { |
||||
super(binding.getRoot()); |
||||
mBinding = binding; |
||||
} |
||||
} |
@ -0,0 +1,120 @@ |
||||
package com.bingce.controlnetwork.func.level.idetection.adapter; |
||||
|
||||
import static com.bingce.controlapphelper.datasource.database.leveling.idetection.constants.LevelIDetectionConstant.MEASURE_TIME_0; |
||||
import static com.bingce.controlapphelper.datasource.database.leveling.idetection.constants.LevelIDetectionConstant.MEASURE_TIME_1; |
||||
import static com.bingce.controlapphelper.datasource.database.leveling.idetection.constants.LevelIDetectionConstant.MEASURE_TIME_2; |
||||
import static com.bingce.controlapphelper.datasource.database.leveling.idetection.constants.LevelIDetectionConstant.MEASURE_TIME_3; |
||||
import static com.bingce.controlapphelper.datasource.database.leveling.idetection.constants.LevelIDetectionConstant.MEASURE_TIME_4; |
||||
import static com.bingce.controlapphelper.datasource.database.leveling.idetection.constants.LevelIDetectionConstant.RULER_TYPE_0; |
||||
import static com.bingce.controlapphelper.datasource.database.leveling.idetection.constants.LevelIDetectionConstant.RULER_TYPE_1; |
||||
|
||||
import android.content.Context; |
||||
import android.view.ViewGroup; |
||||
|
||||
import androidx.annotation.NonNull; |
||||
|
||||
import com.bingce.controlapphelper.datasource.database.leveling.idetection.constants.LevelIDetectionConstant; |
||||
import com.bingce.controlapphelper.datasource.database.leveling.idetection.isetting.LevelIDetectionSetting; |
||||
import com.bingce.controlapphelper.datasource.database.leveling.idetection.record.LevelIDetectionRecord; |
||||
import com.bingce.controlapphelper.leveling.detaction.LevelFormatUtil; |
||||
import com.bingce.controlapphelper.util.Tools; |
||||
import com.bingce.controlnetwork.R; |
||||
import com.bingce.controlnetwork.databinding.ItemLevelIDetectionRecordBinding; |
||||
import com.bingce.controlnetwork.newui.adapter.BaseAdapterNew; |
||||
|
||||
import java.util.Map; |
||||
|
||||
import com.bingce.controlnetwork.func.level.idetection.LevelIDetectionSurveyorData; |
||||
|
||||
|
||||
/** |
||||
* i角检测列表 |
||||
*/ |
||||
public class LevelIDetectionRecordAdapter extends BaseAdapterNew<LevelIDetectionRecordHolder, Map<String, LevelIDetectionRecord>> { |
||||
|
||||
private final LevelIDetectionSurveyorData surveyorData; |
||||
private LevelIDetectionSetting stationSetting; |
||||
|
||||
public LevelIDetectionRecordAdapter(Context context, LevelIDetectionSurveyorData surveyorData) { |
||||
super(context); |
||||
this.surveyorData = surveyorData; |
||||
} |
||||
|
||||
@NonNull |
||||
@Override |
||||
public LevelIDetectionRecordHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { |
||||
return new LevelIDetectionRecordHolder(ItemLevelIDetectionRecordBinding.inflate(getInflater(), parent, false)); |
||||
} |
||||
|
||||
@Override |
||||
protected void onBindViewHolderDo(LevelIDetectionRecordHolder holder, int position) { |
||||
Map<String, LevelIDetectionRecord> recordMap = mDataList.get(0); |
||||
|
||||
//尺子
|
||||
int rulerType; |
||||
if (position == 0) { |
||||
rulerType = RULER_TYPE_0; |
||||
} else { |
||||
rulerType = RULER_TYPE_1; |
||||
} |
||||
|
||||
|
||||
//当前测的尺子选中
|
||||
boolean isSelect = rulerType == surveyorData.getCurrentRulerType(); |
||||
if (isSelect) { |
||||
holder.mBinding.getRoot().setBackgroundDrawable(Tools.getDrawable(R.drawable.select_mask)); |
||||
} else { |
||||
holder.mBinding.getRoot().setBackgroundColor(Tools.getColor(R.color.white)); |
||||
} |
||||
|
||||
LevelIDetectionRecord record1 = getRecord(recordMap, rulerType, MEASURE_TIME_0); |
||||
LevelIDetectionRecord record2 = getRecord(recordMap, rulerType, MEASURE_TIME_1); |
||||
LevelIDetectionRecord record3 = getRecord(recordMap, rulerType, MEASURE_TIME_2); |
||||
LevelIDetectionRecord record4 = getRecord(recordMap, rulerType, MEASURE_TIME_3); |
||||
LevelIDetectionRecord record5 = getRecord(recordMap, rulerType, MEASURE_TIME_4); |
||||
|
||||
//尺几
|
||||
holder.mBinding.tvRulerType.setText(LevelIDetectionConstant.getRulerTypeShow(rulerType)); |
||||
//尺号
|
||||
holder.mBinding.tvRulerNum.setText(LevelIDetectionConstant.getRulerNumShow(rulerType, stationSetting)); |
||||
|
||||
holder.mBinding.tvHeight1.setText(getHeight(record1)); |
||||
holder.mBinding.tvDistance1.setText(getDistance(record1)); |
||||
holder.mBinding.tvHeight2.setText(getHeight(record2)); |
||||
holder.mBinding.tvDistance2.setText(getDistance(record2)); |
||||
holder.mBinding.tvHeight3.setText(getHeight(record3)); |
||||
holder.mBinding.tvDistance3.setText(getDistance(record3)); |
||||
holder.mBinding.tvHeight4.setText(getHeight(record4)); |
||||
holder.mBinding.tvDistance4.setText(getDistance(record4)); |
||||
holder.mBinding.tvHeight5.setText(getHeight(record5)); |
||||
holder.mBinding.tvDistance5.setText(getDistance(record5)); |
||||
} |
||||
|
||||
private LevelIDetectionRecord getRecord(Map<String, LevelIDetectionRecord> map, int rulerType, int measureTime) { |
||||
String recordId = LevelIDetectionRecord.getRecordId(surveyorData.getCurrentIDetectionId(), surveyorData.getCurrentStationType(), rulerType, measureTime); |
||||
return map.get(recordId); |
||||
} |
||||
|
||||
private String getHeight(LevelIDetectionRecord record) { |
||||
if (record == null) { |
||||
return ""; |
||||
} |
||||
return LevelFormatUtil.INSTANCE.formatHeight(record.height); |
||||
} |
||||
|
||||
private String getDistance(LevelIDetectionRecord record) { |
||||
if (record == null) { |
||||
return ""; |
||||
} |
||||
return LevelFormatUtil.INSTANCE.formatDistance(record.distance); |
||||
} |
||||
|
||||
@Override |
||||
public int getItemCount() { |
||||
return mDataList == null ? 0 : 2; |
||||
} |
||||
|
||||
public void setStationSetting(LevelIDetectionSetting stationSetting) { |
||||
this.stationSetting = stationSetting; |
||||
} |
||||
} |
@ -0,0 +1,15 @@ |
||||
package com.bingce.controlnetwork.func.level.idetection.adapter; |
||||
|
||||
import androidx.recyclerview.widget.RecyclerView; |
||||
|
||||
import com.bingce.controlnetwork.databinding.ItemLevelIDetectionRecordBinding; |
||||
|
||||
|
||||
public class LevelIDetectionRecordHolder extends RecyclerView.ViewHolder { |
||||
public final ItemLevelIDetectionRecordBinding mBinding; |
||||
|
||||
public LevelIDetectionRecordHolder(ItemLevelIDetectionRecordBinding binding) { |
||||
super(binding.getRoot()); |
||||
mBinding = binding; |
||||
} |
||||
} |
@ -0,0 +1,247 @@ |
||||
package com.bingce.controlnetwork.func.level.idetection.util |
||||
|
||||
import com.bingce.controlnetwork.func.level.idetection.LevelIDetectionSurveyorData |
||||
import com.bingce.controlapphelper.datasource.database.leveling.idetection.constants.LevelIDetectionConstant.MEASURE_TIME_0 |
||||
import com.bingce.controlapphelper.datasource.database.leveling.idetection.constants.LevelIDetectionConstant.MEASURE_TIME_1 |
||||
import com.bingce.controlapphelper.datasource.database.leveling.idetection.constants.LevelIDetectionConstant.MEASURE_TIME_2 |
||||
import com.bingce.controlapphelper.datasource.database.leveling.idetection.constants.LevelIDetectionConstant.MEASURE_TIME_3 |
||||
import com.bingce.controlapphelper.datasource.database.leveling.idetection.constants.LevelIDetectionConstant.MEASURE_TIME_4 |
||||
import com.bingce.controlapphelper.datasource.database.leveling.idetection.constants.LevelIDetectionConstant.RULER_TYPE_0 |
||||
import com.bingce.controlapphelper.datasource.database.leveling.idetection.constants.LevelIDetectionConstant.RULER_TYPE_1 |
||||
import com.bingce.controlapphelper.datasource.database.leveling.idetection.constants.LevelIDetectionConstant.STATION_TYPE_0 |
||||
import com.bingce.controlapphelper.datasource.database.leveling.idetection.constants.LevelIDetectionConstant.STATION_TYPE_1 |
||||
import com.bingce.controlapphelper.datasource.database.leveling.idetection.record.LevelIDetectionRecord |
||||
|
||||
/** |
||||
* 查找工具 |
||||
*/ |
||||
class LevelIDetectionFindUtil { |
||||
|
||||
fun getFindMeasureList(iDetectionId: String): List<LevelIDetectionRecord> { |
||||
val station1 = STATION_TYPE_0 |
||||
val station2 = STATION_TYPE_1 |
||||
val ruler1 = RULER_TYPE_0 |
||||
val ruler2 = RULER_TYPE_1 |
||||
val measureTime1 = MEASURE_TIME_0 |
||||
val measureTime2 = MEASURE_TIME_1 |
||||
val measureTime3 = MEASURE_TIME_2 |
||||
val measureTime4 = MEASURE_TIME_3 |
||||
val measureTime5 = MEASURE_TIME_4 |
||||
|
||||
return listOf( |
||||
LevelIDetectionRecord.create( |
||||
iDetectionId, |
||||
station1, |
||||
ruler1, |
||||
measureTime1 |
||||
), |
||||
LevelIDetectionRecord.create( |
||||
iDetectionId, |
||||
station1, |
||||
ruler1, |
||||
measureTime2 |
||||
), |
||||
LevelIDetectionRecord.create( |
||||
iDetectionId, |
||||
station1, |
||||
ruler1, |
||||
measureTime3 |
||||
), |
||||
LevelIDetectionRecord.create( |
||||
iDetectionId, |
||||
station1, |
||||
ruler1, |
||||
measureTime4 |
||||
), |
||||
LevelIDetectionRecord.create( |
||||
iDetectionId, |
||||
station1, |
||||
ruler1, |
||||
measureTime5 |
||||
), |
||||
LevelIDetectionRecord.create( |
||||
iDetectionId, |
||||
station1, |
||||
ruler2, |
||||
measureTime1 |
||||
), |
||||
LevelIDetectionRecord.create( |
||||
iDetectionId, |
||||
station1, |
||||
ruler2, |
||||
measureTime2 |
||||
), |
||||
LevelIDetectionRecord.create( |
||||
iDetectionId, |
||||
station1, |
||||
ruler2, |
||||
measureTime3 |
||||
), |
||||
LevelIDetectionRecord.create( |
||||
iDetectionId, |
||||
station1, |
||||
ruler2, |
||||
measureTime4 |
||||
), |
||||
LevelIDetectionRecord.create( |
||||
iDetectionId, |
||||
station1, |
||||
ruler2, |
||||
measureTime5 |
||||
), |
||||
LevelIDetectionRecord.create( |
||||
iDetectionId, |
||||
station2, |
||||
ruler1, |
||||
measureTime1 |
||||
), |
||||
LevelIDetectionRecord.create( |
||||
iDetectionId, |
||||
station2, |
||||
ruler1, |
||||
measureTime2 |
||||
), |
||||
LevelIDetectionRecord.create( |
||||
iDetectionId, |
||||
station2, |
||||
ruler1, |
||||
measureTime3 |
||||
), |
||||
LevelIDetectionRecord.create( |
||||
iDetectionId, |
||||
station2, |
||||
ruler1, |
||||
measureTime4 |
||||
), |
||||
LevelIDetectionRecord.create( |
||||
iDetectionId, |
||||
station2, |
||||
ruler1, |
||||
measureTime5 |
||||
), |
||||
LevelIDetectionRecord.create( |
||||
iDetectionId, |
||||
station2, |
||||
ruler2, |
||||
measureTime1 |
||||
), |
||||
LevelIDetectionRecord.create( |
||||
iDetectionId, |
||||
station2, |
||||
ruler2, |
||||
measureTime2 |
||||
), |
||||
LevelIDetectionRecord.create( |
||||
iDetectionId, |
||||
station2, |
||||
ruler2, |
||||
measureTime3 |
||||
), |
||||
LevelIDetectionRecord.create( |
||||
iDetectionId, |
||||
station2, |
||||
ruler2, |
||||
measureTime4 |
||||
), |
||||
LevelIDetectionRecord.create( |
||||
iDetectionId, |
||||
station2, |
||||
ruler2, |
||||
measureTime5 |
||||
) |
||||
) |
||||
} |
||||
|
||||
fun getFindMeasureList( |
||||
iDetectionId: String, |
||||
stationType: Int |
||||
): List<LevelIDetectionRecord> { |
||||
val ruler1 = RULER_TYPE_0 |
||||
val ruler2 = RULER_TYPE_1 |
||||
val measureTime1 = MEASURE_TIME_0 |
||||
val measureTime2 = MEASURE_TIME_1 |
||||
val measureTime3 = MEASURE_TIME_2 |
||||
val measureTime4 = MEASURE_TIME_3 |
||||
val measureTime5 = MEASURE_TIME_4 |
||||
|
||||
return listOf( |
||||
LevelIDetectionRecord.create( |
||||
iDetectionId, |
||||
stationType, |
||||
ruler1, |
||||
measureTime1 |
||||
), |
||||
LevelIDetectionRecord.create( |
||||
iDetectionId, |
||||
stationType, |
||||
ruler1, |
||||
measureTime2 |
||||
), |
||||
LevelIDetectionRecord.create( |
||||
iDetectionId, |
||||
stationType, |
||||
ruler1, |
||||
measureTime3 |
||||
), |
||||
LevelIDetectionRecord.create( |
||||
iDetectionId, |
||||
stationType, |
||||
ruler1, |
||||
measureTime4 |
||||
), |
||||
LevelIDetectionRecord.create( |
||||
iDetectionId, |
||||
stationType, |
||||
ruler1, |
||||
measureTime5 |
||||
), |
||||
LevelIDetectionRecord.create( |
||||
iDetectionId, |
||||
stationType, |
||||
ruler2, |
||||
measureTime1 |
||||
), |
||||
LevelIDetectionRecord.create( |
||||
iDetectionId, |
||||
stationType, |
||||
ruler2, |
||||
measureTime2 |
||||
), |
||||
LevelIDetectionRecord.create( |
||||
iDetectionId, |
||||
stationType, |
||||
ruler2, |
||||
measureTime3 |
||||
), |
||||
LevelIDetectionRecord.create( |
||||
iDetectionId, |
||||
stationType, |
||||
ruler2, |
||||
measureTime4 |
||||
), |
||||
LevelIDetectionRecord.create( |
||||
iDetectionId, |
||||
stationType, |
||||
ruler2, |
||||
measureTime5 |
||||
) |
||||
) |
||||
} |
||||
|
||||
fun find( |
||||
recordList: List<LevelIDetectionRecord>, |
||||
findCase: (LevelIDetectionRecord) -> Boolean |
||||
): LevelIDetectionSurveyorData? { |
||||
for (record in recordList) { |
||||
if (findCase(record)) { |
||||
val surveyorData = LevelIDetectionSurveyorData("") |
||||
surveyorData.currentStationType = record.stationType |
||||
surveyorData.currentRulerType = record.rulerType |
||||
surveyorData.currentMeasureTime = record.measureTime |
||||
return surveyorData |
||||
} |
||||
} |
||||
return null |
||||
} |
||||
|
||||
} |
@ -0,0 +1,39 @@ |
||||
package com.bingce.controlnetwork.func.level.idetection.viewmodel |
||||
|
||||
import androidx.lifecycle.LiveData |
||||
import androidx.lifecycle.ViewModel |
||||
import androidx.lifecycle.viewModelScope |
||||
import com.bingce.controlapphelper.datasource.database.leveling.LevelingDbFactory |
||||
import com.bingce.controlapphelper.datasource.database.leveling.idetection.list.LevelIDetectionList |
||||
import kotlinx.coroutines.Dispatchers |
||||
import kotlinx.coroutines.launch |
||||
|
||||
class LevelIDetectionListVm : ViewModel() { |
||||
|
||||
fun getListLiveData(projectId: String): LiveData<List<LevelIDetectionList>> { |
||||
return LevelingDbFactory.instance.iDetectionListDataSource.getListByProjectIdDescLiveData( |
||||
projectId |
||||
) |
||||
} |
||||
|
||||
/** |
||||
* 创建i角检测 |
||||
*/ |
||||
fun saveNewRecord(projectId: String, name: String) { |
||||
viewModelScope.launch(Dispatchers.IO) { |
||||
val bean = LevelIDetectionList.create(projectId, name) |
||||
LevelingDbFactory.instance.iDetectionListDataSource.save(bean) |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 创建i角检测 |
||||
*/ |
||||
fun deleteRecord(bean: LevelIDetectionList) { |
||||
viewModelScope.launch(Dispatchers.IO) { |
||||
LevelingDbFactory.instance.iDetectionListDataSource.delete(bean) |
||||
} |
||||
} |
||||
|
||||
|
||||
} |
@ -0,0 +1,361 @@ |
||||
package com.bingce.controlnetwork.func.level.idetection.viewmodel |
||||
|
||||
import androidx.annotation.WorkerThread |
||||
import androidx.lifecycle.ViewModel |
||||
import androidx.lifecycle.viewModelScope |
||||
import blankj.utilcode.util.ToastUtils |
||||
import com.bingce.controlnetwork.func.level.idetection.LevelIDetectionCalUtil |
||||
import com.bingce.controlnetwork.func.level.idetection.LevelIDetectionSurveyorData |
||||
import com.bingce.controlnetwork.func.level.idetection.util.LevelIDetectionFindUtil |
||||
import com.bingce.controlapphelper.datasource.database.leveling.LevelingDb |
||||
import com.bingce.controlapphelper.datasource.database.leveling.LevelingDbFactory |
||||
import com.bingce.controlapphelper.datasource.database.leveling.idetection.constants.LevelIDetectionConstant |
||||
import com.bingce.controlapphelper.datasource.database.leveling.idetection.constants.LevelIDetectionConstant.MEASURE_TIME_0 |
||||
import com.bingce.controlapphelper.datasource.database.leveling.idetection.constants.LevelIDetectionConstant.MEASURE_TIME_1 |
||||
import com.bingce.controlapphelper.datasource.database.leveling.idetection.constants.LevelIDetectionConstant.MEASURE_TIME_2 |
||||
import com.bingce.controlapphelper.datasource.database.leveling.idetection.constants.LevelIDetectionConstant.MEASURE_TIME_3 |
||||
import com.bingce.controlapphelper.datasource.database.leveling.idetection.constants.LevelIDetectionConstant.MEASURE_TIME_4 |
||||
import com.bingce.controlapphelper.datasource.database.leveling.idetection.constants.LevelIDetectionConstant.RULER_TYPE_1 |
||||
import com.bingce.controlapphelper.datasource.database.leveling.idetection.isetting.LevelIDetectionSetting |
||||
import com.bingce.controlapphelper.datasource.database.leveling.idetection.list.LevelIDetectionList |
||||
import com.bingce.controlapphelper.datasource.database.leveling.idetection.record.LevelIDetectionRecord |
||||
import com.bingce.controlapphelper.leveling.detaction.LevelFormatUtil |
||||
import com.bingce.controlapphelper.util.Tools |
||||
import kotlinx.coroutines.Dispatchers |
||||
import kotlinx.coroutines.launch |
||||
import kotlinx.coroutines.withContext |
||||
|
||||
class LevelIDetectionRecordVm : ViewModel() { |
||||
|
||||
//key 记录id |
||||
val dataListAdapter = mutableListOf<Map<String, LevelIDetectionRecord>>() |
||||
|
||||
//key 记录id |
||||
private val stationRecordMap = hashMapOf<String, LevelIDetectionRecord>() |
||||
|
||||
lateinit var surveyorData: LevelIDetectionSurveyorData |
||||
|
||||
var measureType: String? = null |
||||
|
||||
var stationSetting: LevelIDetectionSetting? = null |
||||
|
||||
val findUtil = LevelIDetectionFindUtil() |
||||
|
||||
fun initData( |
||||
surveyorData: LevelIDetectionSurveyorData, |
||||
callBack: (LevelIDetectionList) -> Unit |
||||
) { |
||||
this.surveyorData = surveyorData |
||||
viewModelScope.launch(Dispatchers.IO) { |
||||
dataListAdapter.clear() |
||||
dataListAdapter.add(stationRecordMap) |
||||
val records = |
||||
LevelingDbFactory.instance.iDetectionRecordDataSource.getRecordsByIDetectionId( |
||||
surveyorData.currentIDetectionId |
||||
) |
||||
//更新测站设置 |
||||
updateStationSetting() |
||||
|
||||
for (record in records) { |
||||
stationRecordMap[record.id] = record |
||||
} |
||||
|
||||
//查询第一个需要测量的数据 |
||||
val findMeasureDataAll = findMeasureDataAll() |
||||
if (findMeasureDataAll != null) { |
||||
changeCurrentSurveyorData(findMeasureDataAll) |
||||
} |
||||
|
||||
val iDetectionRecord = |
||||
LevelingDbFactory.instance.iDetectionListDataSource.getById(surveyorData.currentIDetectionId) |
||||
|
||||
withContext(Dispatchers.Main) { |
||||
callBack(iDetectionRecord) |
||||
} |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 存数据 |
||||
*/ |
||||
fun receiveData(height: Double, distance: Double) { |
||||
if (surveyorData.currentRulerType == -1) { |
||||
ToastUtils.showShort("未找到观测尺") |
||||
return |
||||
} |
||||
|
||||
//存当前测量的数据 |
||||
val recordId = LevelIDetectionRecord.getRecordId( |
||||
surveyorData.currentIDetectionId, |
||||
surveyorData.currentStationType, |
||||
surveyorData.currentRulerType, |
||||
surveyorData.currentMeasureTime |
||||
) |
||||
val record = LevelIDetectionRecord.create( |
||||
surveyorData.currentIDetectionId, surveyorData.currentStationType, |
||||
surveyorData.currentRulerType, surveyorData.currentMeasureTime, |
||||
height, distance |
||||
) |
||||
|
||||
stationRecordMap[recordId] = record |
||||
|
||||
//测完一个数据更新尺子和测量次数 |
||||
if (surveyorData.currentMeasureTime == MEASURE_TIME_4) { |
||||
//最后一个测完了 |
||||
if (surveyorData.currentRulerType == RULER_TYPE_1) { |
||||
//该站全部测完 |
||||
surveyorData.currentRulerType = -1 |
||||
surveyorData.currentMeasureTime = MEASURE_TIME_0 |
||||
|
||||
Tools.speak("该测站测量完毕") |
||||
} else { |
||||
//一尺测量完 |
||||
surveyorData.currentRulerType = RULER_TYPE_1 |
||||
surveyorData.currentMeasureTime = MEASURE_TIME_0 |
||||
Tools.speak("尺一测量完毕") |
||||
} |
||||
} else { |
||||
//不是最后一次直接加 |
||||
surveyorData.currentMeasureTime++ |
||||
if (surveyorData.currentMeasureTime > MEASURE_TIME_4) { |
||||
surveyorData.currentMeasureTime = MEASURE_TIME_4 |
||||
} |
||||
} |
||||
|
||||
//存数据库 |
||||
viewModelScope.launch(Dispatchers.IO) { |
||||
LevelingDb.getInstance().iDetectionRecordDao().save(record) |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 找第一个没有数据的 |
||||
*/ |
||||
private fun findMeasureDataAll(): LevelIDetectionSurveyorData? { |
||||
val recordList = findUtil.getFindMeasureList(surveyorData.currentIDetectionId) |
||||
return findUtil.find(recordList) { |
||||
stationRecordMap[it.id] == null |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 找第一个没有数据的 |
||||
*/ |
||||
fun switchStation(stationType: Int) { |
||||
val recordList = findUtil.getFindMeasureList(surveyorData.currentIDetectionId, stationType) |
||||
val find = findUtil.find(recordList) { |
||||
stationRecordMap[it.id] == null |
||||
} |
||||
if (find != null) { |
||||
changeCurrentSurveyorData(find) |
||||
} else { |
||||
val surveyorData = LevelIDetectionSurveyorData("") |
||||
surveyorData.currentStationType = stationType |
||||
changeCurrentSurveyorData(surveyorData) |
||||
} |
||||
} |
||||
|
||||
private fun changeCurrentSurveyorData(surveyorData: LevelIDetectionSurveyorData) { |
||||
this.surveyorData.currentStationType = surveyorData.currentStationType |
||||
this.surveyorData.currentRulerType = surveyorData.currentRulerType |
||||
this.surveyorData.currentMeasureTime = surveyorData.currentMeasureTime |
||||
} |
||||
|
||||
/** |
||||
* 找最后一个有数据的 |
||||
*/ |
||||
fun findRollBackData(): LevelIDetectionSurveyorData? { |
||||
val recordList = findUtil.getFindMeasureList( |
||||
surveyorData.currentIDetectionId, |
||||
surveyorData.currentStationType |
||||
).reversed() |
||||
return findUtil.find(recordList) { |
||||
stationRecordMap[it.id] != null |
||||
} |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 回退删除数据 |
||||
* 一次删一个测站的一个尺子的数据 |
||||
*/ |
||||
fun deleteStationRulerData(findRollBackData: LevelIDetectionSurveyorData, success: () -> Unit) { |
||||
viewModelScope.launch(Dispatchers.IO) { |
||||
val deleteIDetectionId = surveyorData.currentIDetectionId |
||||
val deleteStationType = findRollBackData.currentStationType |
||||
val deleteRulerType = findRollBackData.currentRulerType |
||||
|
||||
val recordId1 = LevelIDetectionRecord.getRecordId( |
||||
deleteIDetectionId, |
||||
deleteStationType, |
||||
deleteRulerType, |
||||
MEASURE_TIME_0 |
||||
) |
||||
val recordId2 = LevelIDetectionRecord.getRecordId( |
||||
deleteIDetectionId, |
||||
deleteStationType, |
||||
deleteRulerType, |
||||
MEASURE_TIME_1 |
||||
) |
||||
val recordId3 = LevelIDetectionRecord.getRecordId( |
||||
deleteIDetectionId, |
||||
deleteStationType, |
||||
deleteRulerType, |
||||
MEASURE_TIME_2 |
||||
) |
||||
val recordId4 = LevelIDetectionRecord.getRecordId( |
||||
deleteIDetectionId, |
||||
deleteStationType, |
||||
deleteRulerType, |
||||
MEASURE_TIME_3 |
||||
) |
||||
val recordId5 = LevelIDetectionRecord.getRecordId( |
||||
deleteIDetectionId, |
||||
deleteStationType, |
||||
deleteRulerType, |
||||
MEASURE_TIME_4 |
||||
) |
||||
//删除缓存 |
||||
stationRecordMap.remove(recordId1) |
||||
stationRecordMap.remove(recordId2) |
||||
stationRecordMap.remove(recordId3) |
||||
stationRecordMap.remove(recordId4) |
||||
stationRecordMap.remove(recordId5) |
||||
//删除数据 |
||||
LevelingDbFactory.instance.iDetectionRecordDataSource.deleteById(recordId1) |
||||
LevelingDbFactory.instance.iDetectionRecordDataSource.deleteById(recordId2) |
||||
LevelingDbFactory.instance.iDetectionRecordDataSource.deleteById(recordId3) |
||||
LevelingDbFactory.instance.iDetectionRecordDataSource.deleteById(recordId4) |
||||
LevelingDbFactory.instance.iDetectionRecordDataSource.deleteById(recordId5) |
||||
|
||||
//确定要测哪个 |
||||
findRollBackData.currentMeasureTime = MEASURE_TIME_0 |
||||
changeCurrentSurveyorData(findRollBackData) |
||||
|
||||
withContext(Dispatchers.Main) { |
||||
success() |
||||
} |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 保存测量方式 |
||||
*/ |
||||
fun saveMeasureType(iDetectionId: String, measureType: String) { |
||||
viewModelScope.launch(Dispatchers.IO) { |
||||
val record = |
||||
LevelingDbFactory.instance.iDetectionListDataSource.getById(iDetectionId) |
||||
record.measureType = measureType |
||||
LevelingDbFactory.instance.iDetectionListDataSource.update(record) |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 单位mm |
||||
* d1短距 |
||||
* d2长距 |
||||
*/ |
||||
fun startResult(d1: Double, d2: Double): String? { |
||||
val findMeasureList = findUtil.getFindMeasureList(surveyorData.currentIDetectionId) |
||||
for (needCheckItem in findMeasureList) { |
||||
val levelIDetectionRecord = stationRecordMap[needCheckItem.id] |
||||
if (levelIDetectionRecord == null) { |
||||
ToastUtils.showShort(LevelIDetectionConstant.getStationTypeShow(needCheckItem.stationType) + "数据不完整") |
||||
return null |
||||
} |
||||
} |
||||
|
||||
val iResult = LevelIDetectionCalUtil.getIResult( |
||||
surveyorData.currentIDetectionId, |
||||
measureType!!, |
||||
d1, |
||||
d2, |
||||
stationRecordMap |
||||
) |
||||
|
||||
val hint = if (iResult.isFinite()) { |
||||
val formatAngle = LevelFormatUtil.formatAngle(iResult) |
||||
saveIResult(formatAngle) |
||||
if (iResult > 15) { |
||||
"i角计算结果:$formatAngle\"\n大于15\",请校正仪器" |
||||
} else { |
||||
"i角计算结果:$formatAngle\"\n合限" |
||||
} |
||||
} else { |
||||
saveIResult(null) |
||||
"i角计算结果:数据异常,请检查" |
||||
} |
||||
return hint |
||||
} |
||||
|
||||
/** |
||||
* 存短长距和测量方法 |
||||
* 这些变化快,统一存 |
||||
*/ |
||||
private fun saveIResult(iResult: String?) { |
||||
viewModelScope.launch(Dispatchers.IO) { |
||||
val iDetectionItem = |
||||
LevelingDbFactory.instance.iDetectionListDataSource.getById(surveyorData.currentIDetectionId) |
||||
iDetectionItem.iResult = iResult |
||||
LevelingDbFactory.instance.iDetectionListDataSource.update(iDetectionItem) |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 存短长距和测量方法 |
||||
* 这些变化快,统一存 |
||||
*/ |
||||
fun saveShortLongDistanceMeasureType(d1Short: String, d2Long: String) { |
||||
viewModelScope.launch(Dispatchers.IO) { |
||||
val iDetectionItem = |
||||
LevelingDbFactory.instance.iDetectionListDataSource.getById(surveyorData.currentIDetectionId) |
||||
iDetectionItem.shortDistance = d1Short |
||||
iDetectionItem.longDistance = d2Long |
||||
iDetectionItem.measureType = measureType |
||||
LevelingDbFactory.instance.iDetectionListDataSource.update(iDetectionItem) |
||||
} |
||||
} |
||||
|
||||
fun getGetDadaAuto(iDetectionId: String, callBack: (Boolean) -> Unit) { |
||||
viewModelScope.launch(Dispatchers.IO) { |
||||
val record = |
||||
LevelingDbFactory.instance.iDetectionSettingDataSource.getByIDetectionId( |
||||
iDetectionId |
||||
) |
||||
withContext(Dispatchers.Main) { |
||||
if (record == null) { |
||||
callBack(true) |
||||
} else { |
||||
callBack(!record.getDataManually) |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
fun setGetDataAuto(iDetectionId: String, auto: Boolean) { |
||||
viewModelScope.launch(Dispatchers.IO) { |
||||
var record = |
||||
LevelingDbFactory.instance.iDetectionSettingDataSource.getByIDetectionId( |
||||
iDetectionId |
||||
) |
||||
if (record == null) { |
||||
record = LevelIDetectionSetting(iDetectionId) |
||||
record.getDataManually = !auto |
||||
LevelingDbFactory.instance.iDetectionSettingDataSource.save(record) |
||||
} else { |
||||
record.getDataManually = !auto |
||||
LevelingDbFactory.instance.iDetectionSettingDataSource.update(record) |
||||
} |
||||
} |
||||
} |
||||
|
||||
@WorkerThread |
||||
fun updateStationSetting() { |
||||
stationSetting = |
||||
LevelingDbFactory.instance.iDetectionSettingDataSource.getByIDetectionId( |
||||
surveyorData.currentIDetectionId |
||||
) |
||||
} |
||||
|
||||
|
||||
} |
@ -0,0 +1,8 @@ |
||||
package com.bingce.controlnetwork.func.level.sendreceive |
||||
|
||||
import com.bingce.controlapphelper.leveling.detaction.LevelReceiveData |
||||
|
||||
interface ILevelBackData { |
||||
fun receive(data: LevelReceiveData) |
||||
fun measureError(msg: String) |
||||
} |
@ -0,0 +1,85 @@ |
||||
package com.bingce.controlnetwork.func.level.sendreceive |
||||
|
||||
import blankj.utilcode.util.ToastUtils |
||||
import cn.liuyanbing.surveyor.function.level.sendreceive.LevelRequestState |
||||
import com.bingce.controlapphelper.leveling.detaction.LevelReceiveData |
||||
import com.bingce.controlnetwork.App |
||||
|
||||
abstract class LevelRequest(protected val backDataI: ILevelBackData) { |
||||
|
||||
private var requestTime = 0L |
||||
private var requestState = LevelRequestState.INIT |
||||
|
||||
private val receiveDataList = mutableListOf<LevelReceiveData>() |
||||
|
||||
abstract fun doRequest() |
||||
abstract fun onStart() |
||||
abstract fun onDestroy() |
||||
abstract fun sendCommand() |
||||
|
||||
|
||||
fun requeset() { |
||||
if (checkRequestNot()) { |
||||
return |
||||
} |
||||
requestState = LevelRequestState.REQUEST_ING |
||||
requestTime = System.currentTimeMillis() |
||||
|
||||
//获取数据 |
||||
doRequest() |
||||
} |
||||
|
||||
private fun checkRequestNot(): Boolean { |
||||
val intervalTime = System.currentTimeMillis() - requestTime |
||||
// if (intervalTime < 600) { |
||||
// return true |
||||
// } |
||||
if (requestState == LevelRequestState.REQUEST_ING) { |
||||
ToastUtils.showShort("测量中,请稍后...") |
||||
return true |
||||
} |
||||
|
||||
if (requestState == LevelRequestState.REQUEST_ING) { |
||||
if (intervalTime > 20000) { |
||||
//超过20秒回复默认状态 |
||||
requestState = LevelRequestState.INIT |
||||
} |
||||
} |
||||
return false |
||||
} |
||||
|
||||
protected fun resetInit() { |
||||
requestTime = 0 |
||||
requestState = LevelRequestState.INIT |
||||
} |
||||
|
||||
protected fun addReceiveData(data: LevelReceiveData) { |
||||
receiveDataList.add(data) |
||||
} |
||||
|
||||
protected fun clearReceiveDataList() { |
||||
receiveDataList.clear() |
||||
} |
||||
|
||||
protected fun isNeedRequestAgain(): Boolean { |
||||
val levelSurveyorTime = App.getApp().levelSurveyorTime.toInt() |
||||
return receiveDataList.size < levelSurveyorTime |
||||
} |
||||
|
||||
/** |
||||
* 获取返回的数据 |
||||
*/ |
||||
protected fun getBackData(): LevelReceiveData { |
||||
var height = 0.0 |
||||
var distance = 0.0 |
||||
for (item in receiveDataList) { |
||||
height += item.height |
||||
distance += item.distance |
||||
} |
||||
val size = receiveDataList.size |
||||
return LevelReceiveData(height / size, distance / size) |
||||
} |
||||
|
||||
protected fun hasData() = receiveDataList.isNotEmpty() |
||||
|
||||
} |
@ -0,0 +1,60 @@ |
||||
package cn.liuyanbing.surveyor.function.level.sendreceive |
||||
|
||||
import blankj.utilcode.util.ToastUtils |
||||
import com.bingce.controlapphelper.leveling.detaction.LevelReceiveData |
||||
import com.bingce.controlnetwork.func.level.sendreceive.ILevelBackData |
||||
import com.bingce.controlnetwork.func.level.sendreceive.LevelRequest |
||||
import com.bingce.device.Device |
||||
import com.bingce.level.Level |
||||
import com.bingce.level.LevelListener |
||||
|
||||
/** |
||||
* 发布版 |
||||
*/ |
||||
class LevelRequestRelease(backDataI: ILevelBackData) : LevelRequest(backDataI), |
||||
LevelListener.LevelReadListener { |
||||
|
||||
override fun doRequest() { |
||||
if (!Device.getInstance().isDeviceConnected) { |
||||
ToastUtils.showShort("设备未连接,请连接设备") |
||||
resetInit() |
||||
return |
||||
} |
||||
ToastUtils.showShort("开始测量") |
||||
sendCommand() |
||||
} |
||||
|
||||
override fun onStart() { |
||||
//LevelListener |
||||
LevelListener.getInstance().addLevelReadListener(this) |
||||
} |
||||
|
||||
override fun onDestroy() { |
||||
LevelListener.getInstance().removeLevelReadListener(this) |
||||
} |
||||
|
||||
override fun onReadSuccess(height: Double, distance: Double) { |
||||
addReceiveData(LevelReceiveData(height, distance)) |
||||
if (isNeedRequestAgain()) { |
||||
sendCommand() |
||||
return |
||||
} |
||||
if (hasData()) { |
||||
backDataI.receive(getBackData()) |
||||
} |
||||
clearReceiveDataList() |
||||
resetInit() |
||||
} |
||||
|
||||
override fun onReadFailed(errorCode: String?, errorMsg: String?, original: String?) { |
||||
val error = errorMsg ?: "" |
||||
backDataI.measureError(error) |
||||
clearReceiveDataList() |
||||
resetInit() |
||||
} |
||||
|
||||
override fun sendCommand() { |
||||
Level.getInstance().requestMeasure() |
||||
} |
||||
|
||||
} |
@ -0,0 +1,8 @@ |
||||
package cn.liuyanbing.surveyor.function.level.sendreceive |
||||
|
||||
import androidx.annotation.Keep |
||||
|
||||
@Keep |
||||
enum class LevelRequestState { |
||||
INIT,REQUEST_ING |
||||
} |
File diff suppressed because one or more lines are too long
@ -0,0 +1,84 @@ |
||||
package com.bingce.controlnetwork.func.level.util; |
||||
|
||||
import com.bingce.controlnetwork.func.level.util.suntime.SunTimes; |
||||
|
||||
import java.text.SimpleDateFormat; |
||||
import java.time.Duration; |
||||
import java.time.LocalTime; |
||||
import java.time.ZonedDateTime; |
||||
import java.util.Date; |
||||
|
||||
|
||||
|
||||
public class LevelDateUtil { |
||||
/** |
||||
* 34.757975, 113.665412 |
||||
* |
||||
* @param lat |
||||
* @param lng |
||||
*/ |
||||
public static String getLevelOperateSunTimeHint(double lat, double lng) { |
||||
ZonedDateTime now = ZonedDateTime.now(); |
||||
SunTimes times = SunTimes.compute() |
||||
.on(now.with(LocalTime.MIN)) // set a date
|
||||
.at(lat, lng) // set a location
|
||||
.execute(); // get the results
|
||||
|
||||
ZonedDateTime rise = times.getRise(); |
||||
ZonedDateTime set = times.getSet(); |
||||
if (rise == null || set == null) { |
||||
//未计算出日出和日落时间
|
||||
return null; |
||||
} |
||||
// 计算日中时间
|
||||
ZonedDateTime noon = rise.plus(Duration.between(rise, set).dividedBy(2)); |
||||
|
||||
// 计算前后两个小时的时间窗口
|
||||
ZonedDateTime startWindow = noon.minusHours(2); |
||||
ZonedDateTime endWindow = noon.plusHours(2); |
||||
|
||||
ZonedDateTime riseAfter2 = rise.plusMinutes(30); |
||||
ZonedDateTime setBefore2 = set.minusMinutes(30); |
||||
|
||||
boolean isWithinTwoHoursOfNoon = !now.isBefore(startWindow) && !now.isAfter(endWindow); |
||||
|
||||
if (now.isBefore(riseAfter2)) { |
||||
//当前时间在日出前2小时内
|
||||
return "请在日出后30分钟进行作业"; |
||||
} |
||||
|
||||
if (now.isAfter(setBefore2)) { |
||||
//当前时间在日落后2小时
|
||||
return "请在日落前30分钟进行作业"; |
||||
} |
||||
|
||||
// 输出结果
|
||||
if (isWithinTwoHoursOfNoon) { |
||||
//当前时间在日中前后2小时内
|
||||
return "请勿在日中前后2小时内进行作业"; |
||||
} |
||||
|
||||
return null; |
||||
} |
||||
|
||||
public static String dateToYearMonthDayHourMin(Date date) { |
||||
SimpleDateFormat simple = new SimpleDateFormat("yyyy年MM月dd日HH:mm"); |
||||
return simple.format(date); |
||||
} |
||||
|
||||
public static String getLevelHeadDateYearMonthDay(Date date) { |
||||
SimpleDateFormat simple = new SimpleDateFormat("yyyy年MM月dd日"); |
||||
return simple.format(date); |
||||
} |
||||
|
||||
public static String getLevelHeadDateHourMin(Date date) { |
||||
SimpleDateFormat simple = new SimpleDateFormat("HH:mm"); |
||||
return simple.format(date); |
||||
} |
||||
|
||||
public static String getHourMinSec(Date date) { |
||||
SimpleDateFormat simple = new SimpleDateFormat("HH:mm:ss"); |
||||
return simple.format(date); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,704 @@ |
||||
package com.bingce.controlnetwork.func.level.util |
||||
|
||||
import android.text.TextUtils |
||||
import androidx.annotation.WorkerThread |
||||
import blankj.utilcode.util.Utils |
||||
|
||||
import cn.liuyanbing.surveyor.function.level.export.LevelExportIDetection |
||||
import com.bingce.controlnetwork.func.level.export.LevelExportSingalHeight |
||||
import com.bingce.controlapphelper.datasource.database.SurveyorDatabaseFactory |
||||
import com.bingce.controlapphelper.datasource.database.leveling.LevelingDbFactory |
||||
import com.bingce.controlapphelper.datasource.database.leveling.measure.backfront.LevelingMeasureBackFrontRecord |
||||
import com.bingce.controlapphelper.datasource.database.leveling.route.LevelRouteRecord |
||||
import com.bingce.controlapphelper.datasource.database.leveling.station.LevelingStationRecord |
||||
import com.bingce.controlapphelper.datasource.database.point.PointRecord |
||||
import com.bingce.controlapphelper.leveling.detaction.LevelFormatUtil |
||||
import com.bingce.controlapphelper.model.LevelExportLine |
||||
import com.bingce.controlapphelper.model.LevelingMeasureOrder |
||||
import com.bingce.controlapphelper.model.LevelingMeasureOrderUtil |
||||
import com.bingce.controlapphelper.model.LevelingStationState |
||||
import com.bingce.controlapphelper.model._N |
||||
import com.bingce.controlapphelper.surveyor.method.ExportStationMethod |
||||
import com.bingce.controlapphelper.surveyor.method.ExportUtils |
||||
import com.bingce.controlapphelper.util.DateUtil |
||||
import com.bingce.utils.DateUtils |
||||
import com.bingce.utils.Util |
||||
import java.io.File |
||||
|
||||
|
||||
class LevelExportUtilTj { |
||||
|
||||
companion object { |
||||
const val EXPORT_LEVEL_FOLDER = "Leveling" |
||||
|
||||
//导出的外层目录 |
||||
val exportOutFolder = File(Utils.getApp().externalCacheDir, EXPORT_LEVEL_FOLDER) |
||||
} |
||||
|
||||
private lateinit var exportRouteFolder: File |
||||
private lateinit var exportProjectFolder: File |
||||
|
||||
private var column1Index = 0 |
||||
|
||||
private var startPointHeight = 0.0 |
||||
private var startPointName = "" |
||||
private var endPointName = "" |
||||
|
||||
|
||||
private val printSbLev = StringBuilder() |
||||
|
||||
/** |
||||
* 导出路线文件夹下的数据 |
||||
*/ |
||||
@WorkerThread |
||||
fun doExportRouteData(projectId: String, routeId: String) { |
||||
val routeRecord = LevelingDbFactory.instance.levelDataSource.getByIdSync(routeId) |
||||
?: throw IllegalArgumentException("routeRecord==null") |
||||
//路线的基础数据 |
||||
confirmRouteCommonData(routeRecord) |
||||
//收集路线的具体数据 |
||||
collectRouteLevData(projectId, routeRecord) |
||||
} |
||||
|
||||
private fun confirmRouteCommonData(it: LevelRouteRecord) { |
||||
val startPoint = |
||||
SurveyorDatabaseFactory.instance.pointDataSource.findByIdSync(it.startPointId) |
||||
startPointHeight = getPointHeight(startPoint) |
||||
startPointName = getPointName(startPoint) |
||||
val endPoint = SurveyorDatabaseFactory.instance.pointDataSource.findByIdSync(it.endPointId) |
||||
endPointName = getPointName(endPoint) |
||||
} |
||||
|
||||
private fun collectRouteLevData(projectId: String, it: LevelRouteRecord) { |
||||
val routeId = it.getId() |
||||
val routeName = it.routeName |
||||
val levelingMeasureOrder = it.levelingMeasureOrder |
||||
val isHasTwiceStation = when (levelingMeasureOrder) { |
||||
LevelingMeasureOrder.SIM_BF, |
||||
LevelingMeasureOrder.SIM_BFFB -> { |
||||
true |
||||
} |
||||
|
||||
else -> false |
||||
} |
||||
|
||||
collectRouteLevDataLeftOrRight( |
||||
projectId, |
||||
routeId, |
||||
false, |
||||
levelingMeasureOrder |
||||
) |
||||
if (isHasTwiceStation) { |
||||
collectRouteLevDataLeftOrRight( |
||||
projectId, |
||||
routeId, |
||||
true, |
||||
levelingMeasureOrder |
||||
) |
||||
} |
||||
|
||||
if (printSbLev.isNotEmpty()) { |
||||
initExportFile(projectId, routeName) |
||||
if (::exportRouteFolder.isInitialized) { |
||||
saveRouteLevFile(exportRouteFolder, routeName) |
||||
saveRouteTxtFile(exportRouteFolder, routeId, routeName) |
||||
saveRouteInfoFile(exportRouteFolder, projectId, routeId, routeName) |
||||
} |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* INF 观测记录 |
||||
*/ |
||||
private fun saveRouteInfoFile( |
||||
exportFolder: File, |
||||
projectId: String, |
||||
routeId: String, |
||||
routeName: String |
||||
) { |
||||
val projectRecord = SurveyorDatabaseFactory.instance.projectDataSource.getRecord(projectId) |
||||
val routeRecord = LevelingDbFactory.instance.levelDataSource.getByIdSync(routeId)!! |
||||
val toleranceTetail = |
||||
LevelingDbFactory.instance.toleranceDetailDataSource.getRecordSync(projectRecord.toleranceId) |
||||
|
||||
val startPointNameRoute = |
||||
SurveyorDatabaseFactory.instance.pointDataSource.findByIdSync(routeRecord.startPointId) |
||||
.getName() |
||||
val endPointNameRoute = |
||||
SurveyorDatabaseFactory.instance.pointDataSource.findByIdSync(routeRecord.endPointId) |
||||
.getName() |
||||
|
||||
//作业单位 |
||||
val measureUnit = projectRecord.measureUnit ?: "" |
||||
//限差等级 |
||||
val exportGrade = toleranceTetail.exportGrade |
||||
|
||||
//测站数量 单程双转的按照twiceStaion false处理 |
||||
val stationCount = |
||||
LevelingDbFactory.instance.stationDataSource.getCountByRoute(projectId, routeId, false) |
||||
|
||||
val stationListLeft = |
||||
LevelingDbFactory.instance.stationDataSource.getStationList(projectId, routeId, false) |
||||
val stationListRight = |
||||
LevelingDbFactory.instance.stationDataSource.getStationList(projectId, routeId, true) |
||||
|
||||
val remeasureCountAll = |
||||
getRemeasureCount(stationListLeft) + getRemeasureCount(stationListRight) |
||||
|
||||
//8,9,10行 |
||||
val routeDistanceHeightInfo = |
||||
getRouteDistanceHeightInfo( |
||||
stationListLeft?.lastOrNull(), |
||||
stationListRight?.lastOrNull() |
||||
) |
||||
|
||||
val record = LevelingDbFactory.instance.stationSettingDataSource.getLatest(routeId) |
||||
record?.let { |
||||
val sb = StringBuilder() |
||||
//第一行 |
||||
sb.append(measureUnit).append(",") |
||||
sb.append(exportToString(it.watcher)).append(",") |
||||
sb.append(exportToString(it.recorder)).append(",") |
||||
sb.append(exportToString(it.examiner)).append("\n") |
||||
//第二行 |
||||
sb.append(exportGrade).append(",") |
||||
sb.append("").append(",")//观测方法:自动采集法 |
||||
sb.append(routeRecord.observationDirection).append(",") |
||||
sb.append(stationCount).append(",")//测站数 |
||||
sb.append(remeasureCountAll).append("\n")//重测数 |
||||
//第三行 |
||||
sb.append(exportToString(it.instrumentModel)).append(",") |
||||
sb.append("No.${exportToString(it.deviceNumber)}").append(",") |
||||
sb.append("").append(",")//测微读数精度 |
||||
sb.append("").append(",")//视距乘常数 |
||||
sb.append("").append("\n")//视距加常数 |
||||
//第四行 |
||||
sb.append(exportToString(it.rulerType)).append(",") |
||||
sb.append("").append(",")//标尺分划 |
||||
sb.append(exportToString(it.rulerReceptType)).append("\n")//尺承类型 |
||||
//第五行 |
||||
sb.append(startPointNameRoute).append(",")//起点 |
||||
sb.append(endPointNameRoute).append("\n")//终点 |
||||
//第六行 |
||||
sb.append(exportToString(it.firstStationBackFootNumber)).append(",") |
||||
sb.append(exportToString(it.firstStationFrontFootNumber)).append("\n") |
||||
//第七行 |
||||
sb.append(exportToString(it.firstStationBackFootNumber2)).append(",") |
||||
sb.append(exportToString(it.firstStationFrontFootNumber2)).append("\n") |
||||
//第八行 |
||||
sb.append(routeDistanceHeightInfo) |
||||
|
||||
ExportStationMethod.save(sb.toString(), exportFolder, "${routeName}.INF") |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* INFO文件里的距离和高差 |
||||
*/ |
||||
private fun getRouteDistanceHeightInfo( |
||||
leftEndStation: LevelingStationRecord?, |
||||
rightEndStation: LevelingStationRecord? |
||||
): String { |
||||
val sb = StringBuilder() |
||||
if (leftEndStation == null && rightEndStation == null) { |
||||
sb.append("").append(",").append("").append(",").append("").append(",").append("") |
||||
.append("\n") |
||||
.append(",").append("\n") |
||||
.append("").append("\n") |
||||
.append("").append("\n") |
||||
return sb.toString() |
||||
} |
||||
|
||||
val left = |
||||
LevelingDbFactory.instance.measureStationDataSource.getRecordSync(leftEndStation?.getId()) |
||||
val right = |
||||
LevelingDbFactory.instance.measureStationDataSource.getRecordSync(rightEndStation?.getId()) |
||||
|
||||
val distanceTotalLeft = formatDistance(left?.distanceTotal) |
||||
val heightDiffTotalLeft = formatDistance(left?.heightDiffTotal) |
||||
val distanceTotalRight = formatDistance(right?.distanceTotal) |
||||
val heightDiffTotalRight = formatDistance(right?.heightDiffTotal) |
||||
|
||||
val heightAverage = if (left?.heightDiffTotal != null && right?.heightDiffTotal != null) { |
||||
formatDistance((left.heightDiffTotal + right.heightDiffTotal) / 2) |
||||
} else if (left?.heightDiffTotal != null) { |
||||
formatDistance(left.heightDiffTotal) |
||||
} else { |
||||
"" |
||||
} |
||||
|
||||
//测段不符值 右-左 |
||||
val rightLeftHeightDiff = |
||||
if (left?.heightDiffTotal != null && right?.heightDiffTotal != null) { |
||||
formatDistance(right.heightDiffTotal - left.heightDiffTotal) |
||||
} else { |
||||
"0" |
||||
} |
||||
|
||||
sb.append(distanceTotalLeft).append(",").append(heightDiffTotalLeft).append(",") |
||||
.append(distanceTotalRight).append(",").append(heightDiffTotalRight).append("\n") |
||||
//第二行 |
||||
.append(heightAverage).append("\n") |
||||
//第三行 |
||||
.append(rightLeftHeightDiff).append("\n") |
||||
|
||||
return sb.toString() |
||||
} |
||||
|
||||
private fun formatDistance(value: Double?): String { |
||||
if (value == null) { |
||||
return "" |
||||
} |
||||
return ExportUtils.formatDistance(value) |
||||
} |
||||
|
||||
private fun exportToString(value: String?) = value ?: "" |
||||
|
||||
/** |
||||
* 通过测站列表获取重测数量 |
||||
*/ |
||||
@WorkerThread |
||||
private fun getRemeasureCount(stationList: List<LevelingStationRecord>): Int { |
||||
var count = 0 |
||||
for (station in stationList) { |
||||
val remeasureCountByStationId = |
||||
LevelingDbFactory.instance.measureBackFrontDataSource.getRemeasureCountByStationId( |
||||
station.getId() |
||||
) |
||||
count += remeasureCountByStationId |
||||
} |
||||
return count |
||||
} |
||||
|
||||
/** |
||||
* TXT 观测条件 |
||||
*/ |
||||
private fun saveRouteTxtFile(exportFolder: File, routeId: String, routeName: String) { |
||||
// //起点,终点,照准次序,测站数量,路线总长度(km),路线总高差 |
||||
// val routeRecord = TjDbFactory.instance.routeDataSource.getByIdSync(routeId) ?: return |
||||
// val startPointName = |
||||
// TjDbFactory.instance.pointDataSource.findByIdSync(routeRecord.startPointId).name |
||||
// val endPointName = |
||||
// TjDbFactory.instance.pointDataSource.findByIdSync(routeRecord.endPointId).name |
||||
// val orderText = |
||||
// LevelingMeasureOrderUtil.getTextByLevelingMeasureOrder(routeRecord.levelingMeasureOrder) |
||||
// |
||||
// val stationCount = LevelingDbFactory.instance.stationDataSource.getCountByRoute( |
||||
// routeRecord.projectId, |
||||
// routeId, |
||||
// false |
||||
// ) |
||||
// |
||||
// val stationLatest = LevelingDbFactory.instance.stationDataSource.getStationLatest( |
||||
// routeRecord.projectId, |
||||
// routeId |
||||
// ) |
||||
// |
||||
// val measureStationList = mutableListOf<LevelingMeasureStationRecord>() |
||||
// val measureStationRecordLast = |
||||
// LevelingDbFactory.instance.measureStationDataSource.getRecordSync(stationLatest.getId()) |
||||
// if (stationLatest.twiceStation) { |
||||
// val measureStationRecordLeft = |
||||
// LevelingDbFactory.instance.measureStationDataSource.getRecordSync(stationLatest.lastStationId) |
||||
// measureStationList.add(measureStationRecordLeft) |
||||
// measureStationList.add(measureStationRecordLast) |
||||
// } else { |
||||
// measureStationList.add(measureStationRecordLast) |
||||
// } |
||||
// |
||||
// val sb = StringBuilder() |
||||
// for (item in measureStationList) { |
||||
// sb.append(startPointName).append(",") |
||||
// sb.append(endPointName).append(",") |
||||
// sb.append(orderText).append(",") |
||||
// sb.append(stationCount).append(",") |
||||
// |
||||
// sb.append(ExportUtilsTj.formatDistance(item.distanceTotal)).append(",") |
||||
// sb.append(ExportUtilsTj.formatDistance(item.heightDiffTotal)) |
||||
// sb.append("\n") |
||||
// } |
||||
|
||||
//观测条件list |
||||
val observationConditionList = |
||||
LevelingDbFactory.instance.stationSettingDataSource.getByRouteId(routeId) |
||||
|
||||
val sb = StringBuilder() |
||||
for (item in observationConditionList) { |
||||
val station = |
||||
LevelingDbFactory.instance.stationDataSource.getRecordSync(item.stationId) |
||||
val stationNum = station.stationName.replace("测站", "") |
||||
|
||||
//第一行 |
||||
sb.append(stationNum).append(",") |
||||
.append(LevelDateUtil.dateToYearMonthDayHourMin(item.createDate)).append("\n") |
||||
//第二行 |
||||
sb.append(exportToString(item.temperature)).append(",") |
||||
.append(exportToString(item.sunDirection)).append(",") |
||||
.append(exportToString(item.imaging)).append(",") |
||||
.append(exportToString(item.weather)).append("\n") |
||||
//第三行 |
||||
sb.append(exportToString(item.windDirection)).append(",") |
||||
.append(exportToString(item.windSpeed)).append(",") |
||||
.append(exportToString(item.roads)).append(",") |
||||
.append(exportToString(item.soil)).append("\n") |
||||
} |
||||
|
||||
ExportStationMethod.save(sb.toString(), exportFolder, "${routeName}.TXT") |
||||
} |
||||
|
||||
private fun removeLastBuilder(sb: StringBuilder) { |
||||
if (sb.isNotEmpty()) { |
||||
sb.deleteCharAt(sb.lastIndex) |
||||
} |
||||
} |
||||
|
||||
private fun saveRouteLevFile(exportFolder: File, routeName: String) { |
||||
ExportStationMethod.save(printSbLev.toString(), exportFolder, "${routeName}.LEV") |
||||
} |
||||
|
||||
private fun initExportFile(projectId: String, routeName: String) { |
||||
exportProjectFolder = initExportProjectFolder(projectId) |
||||
confirmRouteFolder(exportProjectFolder, routeName) |
||||
} |
||||
|
||||
private fun initExportProjectFolder(projectId: String): File { |
||||
val exportFolder = File(Utils.getApp().externalCacheDir, EXPORT_LEVEL_FOLDER) |
||||
if (!exportFolder.exists()) { |
||||
exportFolder.mkdirs() |
||||
} |
||||
val projectName = |
||||
SurveyorDatabaseFactory.instance.projectDataSource.getRecord(projectId).projectName |
||||
val projectFolder = File(exportFolder, projectName) |
||||
if (!projectFolder.exists()) { |
||||
projectFolder.mkdir() |
||||
} |
||||
return projectFolder |
||||
} |
||||
|
||||
/** |
||||
* 重名项目或路线文件夹增加_1 |
||||
*/ |
||||
private fun confirmRouteFolder(exportProjectFolder: File, name: String) { |
||||
val exportFolderTarget = File(exportProjectFolder, name) |
||||
if (!exportFolderTarget.exists()) { |
||||
exportFolderTarget.mkdir() |
||||
this.exportRouteFolder = exportFolderTarget |
||||
return |
||||
} |
||||
confirmRouteFolder(exportProjectFolder, name + "_1") |
||||
} |
||||
|
||||
/** |
||||
* 收集左线或者右线的数据 |
||||
*/ |
||||
private fun collectRouteLevDataLeftOrRight( |
||||
projectId: String, |
||||
routeId: String, |
||||
twiceStation: Boolean, |
||||
levelingMeasureOrder: LevelingMeasureOrder |
||||
) { |
||||
val orderText = |
||||
LevelingMeasureOrderUtil.getTextByLevelingMeasureOrder(levelingMeasureOrder) |
||||
|
||||
val stationList = LevelingDbFactory.instance.stationDataSource.getStationList( |
||||
projectId, |
||||
routeId, |
||||
twiceStation |
||||
) |
||||
|
||||
var finishIndex = 0 |
||||
for ((index, station) in stationList.withIndex()) { |
||||
if (station.stationState != LevelingStationState.FINISH) |
||||
break |
||||
|
||||
if (index == 0) { |
||||
appendStartOrEndLine("Start-Line", orderText) |
||||
appendRouteStationHead(routeId, station) |
||||
appendZ(station.backSightPointId, startPointHeight) |
||||
} |
||||
|
||||
//测量数据 |
||||
appendMeasureData(station) |
||||
finishIndex = index |
||||
column1Index++ |
||||
} |
||||
|
||||
//最后完成测站 |
||||
val lastFinishStation = stationList[finishIndex] |
||||
val stationHeightDiffTotal = getStationHeightDiffTotal(lastFinishStation) |
||||
|
||||
//结束点高程 |
||||
appendZ( |
||||
lastFinishStation.frontSightPointId, |
||||
getFrontPointZ(stationHeightDiffTotal) |
||||
) |
||||
column1Index++ |
||||
//end-line |
||||
appendStartOrEndLine("End-Line", "") |
||||
} |
||||
|
||||
private fun getStationHeightDiffTotal(stationRecord: LevelingStationRecord): Double { |
||||
//当前站的累积高差 |
||||
return LevelingDbFactory.instance.measureStationDataSource.getRecordSync(stationRecord.getId()).heightDiffTotal |
||||
} |
||||
|
||||
private fun getFrontPointZ(heightDiffTotal: Double) = startPointHeight + heightDiffTotal |
||||
|
||||
private fun appendStartOrEndLine(startOrEndLine: String, column2Name3: String) { |
||||
val dataFirstLine = LevelExportLine( |
||||
LevelExportLine.Column1(column1Index), |
||||
LevelExportLine.Column2("TO", startOrEndLine, column2Name3), |
||||
LevelExportLine.ColumnHeight("", ""), |
||||
LevelExportLine.ColumnDistance(""), |
||||
LevelExportLine.ColumnEnd(null, null) |
||||
).getData() |
||||
printSbLev.append(dataFirstLine).append(_N) |
||||
|
||||
column1Index++ |
||||
} |
||||
|
||||
/** |
||||
* 路线的首站头 |
||||
* 起点,终点等 |
||||
*/ |
||||
private fun appendRouteStationHead(routeId: String, station: LevelingStationRecord) { |
||||
val stationSetting = LevelingDbFactory.instance.stationSettingDataSource.getLatest(routeId) |
||||
|
||||
val measureDataList = |
||||
LevelingDbFactory.instance.measureBackFrontDataSource.getMeasureDataList(station.getId()) |
||||
val firstRecordDate = measureDataList.first().createDate |
||||
val endRecordDate = measureDataList.last().createDate |
||||
|
||||
val levelHeadDateYearMonthDay = |
||||
LevelDateUtil.getLevelHeadDateYearMonthDay(firstRecordDate) |
||||
val startHourMin = LevelDateUtil.getLevelHeadDateHourMin(firstRecordDate) |
||||
val endHourMin = LevelDateUtil.getLevelHeadDateHourMin(endRecordDate) |
||||
|
||||
val line1 = getRouteStationHeadLine("startName", startPointName) |
||||
printSbLev.append(line1).append(_N) |
||||
val line2 = getRouteStationHeadLine("endName", endPointName) |
||||
printSbLev.append(line2).append(_N) |
||||
val line3 = getRouteStationHeadLine("observationDate", levelHeadDateYearMonthDay) |
||||
printSbLev.append(line3).append(_N) |
||||
val line4 = getRouteStationHeadLine("observationStartTime", startHourMin) |
||||
printSbLev.append(line4).append(_N) |
||||
val line5 = getRouteStationHeadLine("observationEndTime", endHourMin) |
||||
printSbLev.append(line5).append(_N) |
||||
val line6 = getRouteStationHeadLine("weather", stationSetting.weather ?: "") |
||||
printSbLev.append(line6).append(_N) |
||||
val line7 = getRouteStationHeadLine("imaging", stationSetting.imaging ?: "") |
||||
printSbLev.append(line7).append(_N) |
||||
|
||||
column1Index++ |
||||
} |
||||
|
||||
private fun getRouteStationHeadLine(key: String, value: String): String { |
||||
return LevelExportLine( |
||||
LevelExportLine.Column1(column1Index), |
||||
LevelExportLine.Column2("INF", "", ""), |
||||
LevelExportLine.ColumnHeight(key, ""), |
||||
LevelExportLine.ColumnDistance(""), |
||||
LevelExportLine.ColumnEnd(value, "") |
||||
).getData() |
||||
} |
||||
|
||||
/** |
||||
* 测量数据 |
||||
*/ |
||||
private fun appendMeasureData(station: LevelingStationRecord) { |
||||
val measureDataList = |
||||
LevelingDbFactory.instance.measureBackFrontDataSource.getMeasureDataList(station.getId()) |
||||
|
||||
val stationHeightDiffTotal = getStationHeightDiffTotal(station) |
||||
|
||||
val backDataList = mutableListOf<LevelingMeasureBackFrontRecord>() |
||||
val frontDataList = mutableListOf<LevelingMeasureBackFrontRecord>() |
||||
|
||||
for ((index, record) in measureDataList.withIndex()) { |
||||
val point = getPoint(record.measurePointId) |
||||
val pointName = getPointName(point) |
||||
|
||||
var rbOrRf: String |
||||
if (record.measurePointId == station.backSightPointId) { |
||||
rbOrRf = "Rb" |
||||
backDataList.add(record) |
||||
} else { |
||||
rbOrRf = "Rf" |
||||
frontDataList.add(record) |
||||
} |
||||
|
||||
val time = DateUtil.formatDateHHmmss(record.createDate) |
||||
|
||||
val line = LevelExportLine( |
||||
LevelExportLine.Column1(column1Index), |
||||
LevelExportLine.Column2("KD1", pointName, time), |
||||
LevelExportLine.ColumnHeight(rbOrRf, "${record.measureHeightShow} m"), |
||||
LevelExportLine.ColumnDistance(record.measureDistanceShow), |
||||
LevelExportLine.ColumnEnd(null, null) |
||||
).getData() |
||||
printSbLev.append(line).append(_N) |
||||
|
||||
//最后再增加一行 |
||||
if (index == measureDataList.lastIndex) { |
||||
//每一站的结果 |
||||
column1Index++ |
||||
appendZ(point.getId(), getFrontPointZ(stationHeightDiffTotal)) |
||||
} |
||||
|
||||
column1Index++ |
||||
} |
||||
} |
||||
|
||||
private fun getPointHeight(point: PointRecord?): Double { |
||||
return point?.getZ() ?: 0.0 |
||||
} |
||||
|
||||
private fun getPointName(point: PointRecord?): String { |
||||
return point?.getName() ?: "" |
||||
} |
||||
|
||||
private fun getPoint(pointId: String): PointRecord { |
||||
return SurveyorDatabaseFactory.instance.pointDataSource.findByIdSync(pointId) |
||||
} |
||||
|
||||
private fun appendZ(pointId: String, height: Double) { |
||||
val startPoint = getPoint(pointId) |
||||
val z = LevelFormatUtil.formatHeight(height) |
||||
val dataSecondLine = LevelExportLine( |
||||
LevelExportLine.Column1(column1Index), |
||||
LevelExportLine.Column2("KD1", getPointName(startPoint), ""), |
||||
LevelExportLine.ColumnHeight("", ""), |
||||
LevelExportLine.ColumnDistance(""), |
||||
LevelExportLine.ColumnEnd("Z", "$z m") |
||||
).getData() |
||||
printSbLev.append(dataSecondLine).append(_N) |
||||
column1Index++ |
||||
} |
||||
|
||||
|
||||
data class CalTotal(var heightDiffTotal: Double = 0.0, var distanceTotal: Double = 0.0) { |
||||
fun addHeightDiffTotal(heightDiffTotal: Double) { |
||||
this.heightDiffTotal += heightDiffTotal |
||||
} |
||||
|
||||
fun addDistanceTotal(distanceTotal: Double) { |
||||
this.distanceTotal += distanceTotal |
||||
} |
||||
} |
||||
|
||||
@WorkerThread |
||||
fun exportProjectTxt(projectId: String) { |
||||
val projectFolder = initExportProjectFolder(projectId) |
||||
val projectRecord = SurveyorDatabaseFactory.instance.projectDataSource.getRecord(projectId) |
||||
|
||||
val text = projectRecord.projectName + |
||||
"," + |
||||
"" + |
||||
"," + |
||||
"," + |
||||
"," + |
||||
"," + |
||||
"," + |
||||
"," + |
||||
"," + |
||||
(if (projectRecord == null) "" else projectRecord.getMeasureUnit()) + |
||||
"," + |
||||
(if (projectRecord == null) "" else DateUtils.toDate(projectRecord.getCreateDate())) + |
||||
"\n" |
||||
ExportStationMethod.save( |
||||
text, |
||||
projectFolder, |
||||
"project.TXT" |
||||
) |
||||
} |
||||
|
||||
fun exportControlTxt(projectId: String) { |
||||
val projectFolder = initExportProjectFolder(projectId) |
||||
val knownList = SurveyorDatabaseFactory.instance.pointDataSource.getListByProjectId( |
||||
projectId, |
||||
PointRecord.TYPE_KNOWN_POINT |
||||
) |
||||
val unknownList = SurveyorDatabaseFactory.instance.pointDataSource.getListByProjectId( |
||||
projectId, |
||||
PointRecord.TYPE_UNKNOWN_POINT |
||||
) |
||||
|
||||
val stringBuilder = StringBuilder() |
||||
appendExportPoint(stringBuilder, knownList) |
||||
appendExportPoint(stringBuilder, unknownList) |
||||
|
||||
ExportStationMethod.save( |
||||
stringBuilder.toString(), |
||||
projectFolder, |
||||
"controlpoint.TXT" |
||||
) |
||||
} |
||||
|
||||
private fun appendExportPoint(sb: StringBuilder, list: List<PointRecord>) { |
||||
for (pointRecord in list) { |
||||
sb |
||||
.append(pointRecord.getName()) |
||||
.append(",") |
||||
.append(pointRecord.getCode()) |
||||
.append(",") |
||||
.append(getXyzFormat(pointRecord.getX())) |
||||
.append(",") |
||||
.append(getXyzFormat(pointRecord.getY())) |
||||
.append(",") |
||||
.append(getXyzFormat(pointRecord.getZ())) |
||||
.append(",") |
||||
// .append(pointRecord.getLongitude()) |
||||
.append(",") |
||||
// .append(pointRecord.getLatitude()) |
||||
.append(",") |
||||
.append("") |
||||
.append("\n") |
||||
} |
||||
} |
||||
|
||||
private fun getXyzFormat(xyz: Double): String { |
||||
return Util.formatDouble2String(xyz, 4) |
||||
} |
||||
|
||||
/** |
||||
* 导出i角检测 |
||||
*/ |
||||
@WorkerThread |
||||
fun exportIDetection(projectId: String) { |
||||
val projectName = |
||||
SurveyorDatabaseFactory.instance.projectDataSource.getRecord(projectId).projectName |
||||
|
||||
val iDetectionList = |
||||
LevelingDbFactory.instance.iDetectionListDataSource.getListByProjectIdDesc(projectId) |
||||
|
||||
val sb = StringBuilder() |
||||
val levelExportIDetection = LevelExportIDetection() |
||||
for (iDetection in iDetectionList) { |
||||
val export = levelExportIDetection.export(iDetection) |
||||
if (!TextUtils.isEmpty(export)) { |
||||
sb.append(export) |
||||
} |
||||
} |
||||
|
||||
if (sb.isNotEmpty()) { |
||||
val projectFolder = initExportProjectFolder(projectId) |
||||
ExportStationMethod.save( |
||||
sb.toString(), |
||||
projectFolder, |
||||
"$projectName.IAC" |
||||
) |
||||
} |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 导出 |
||||
*/ |
||||
fun exportTjSingalHeight(projectId: String) { |
||||
val levelExportSingalHeight = LevelExportSingalHeight() |
||||
val projectFolder = initExportProjectFolder(projectId) |
||||
levelExportSingalHeight.export(projectFolder, projectId) |
||||
} |
||||
|
||||
|
||||
} |
@ -0,0 +1,38 @@ |
||||
package com.bingce.controlnetwork.func.level.util |
||||
|
||||
import androidx.annotation.WorkerThread |
||||
import com.bingce.controlapphelper.datasource.database.SurveyorDatabaseFactory |
||||
import com.bingce.controlapphelper.datasource.database.leveling.LevelingDbFactory |
||||
import com.bingce.controlapphelper.datasource.database.point.PointRecord |
||||
import com.bingce.controlapphelper.util.RegExUtil |
||||
|
||||
object LevelPointUtilTj { |
||||
@WorkerThread |
||||
@JvmStatic |
||||
fun createFrontPointByBackPointId( |
||||
routeId: String, |
||||
backPointId: String, |
||||
firstStaion: Boolean = false, |
||||
endStattion: Boolean = false, |
||||
): PointRecord { |
||||
val frontPoint = if (endStattion) { |
||||
val route = LevelingDbFactory.instance.levelDataSource.getByIdSync(routeId) |
||||
SurveyorDatabaseFactory.instance.pointDataSource.findByIdSync(route?.endPointId) |
||||
} else if (firstStaion) { |
||||
createHidePoint("1") |
||||
} else { |
||||
val backPoint = SurveyorDatabaseFactory.instance.pointDataSource.findByIdSync(backPointId) |
||||
val frontPointName = RegExUtil.getPointNameIncrease(backPoint.getName()) |
||||
createHidePoint(frontPointName) |
||||
} |
||||
return frontPoint |
||||
} |
||||
|
||||
private fun createHidePoint(pointName: String): PointRecord { |
||||
val point = PointRecord.createHidePoint(pointName) |
||||
//存点 |
||||
SurveyorDatabaseFactory.instance.pointDataSource.saveSync(point) |
||||
return point |
||||
} |
||||
|
||||
} |
@ -0,0 +1,271 @@ |
||||
package com.bingce.controlnetwork.func.level.util |
||||
|
||||
import androidx.annotation.WorkerThread |
||||
import com.bingce.controlapphelper.datasource.database.SurveyorDatabaseFactory |
||||
|
||||
/** |
||||
* 水准测站设置上次值 |
||||
*/ |
||||
object LevelStationSettingLastData { |
||||
|
||||
private const val KEY_WATCHER = "LEVEL_STATION_SETTING_LAST_DATA_WATCHER" |
||||
private const val KEY_RECORDER = "LEVEL_STATION_SETTING_LAST_DATA_RECORDER" |
||||
private const val KEY_EXAMINER = "LEVEL_STATION_SETTING_LAST_DATA_EXAMINER" |
||||
private const val KEY_FRONT_FOOT_NUMBER = "LEVEL_STATION_SETTING_LAST_DATA_FRONT_FOOT_NUMBER" |
||||
private const val KEY_BACK_FOOT_NUMBER = "LEVEL_STATION_SETTING_LAST_DATA_BACK_FOOT_NUMBER" |
||||
private const val KEY_FRONT_FOOT_NUMBER_2 = |
||||
"LEVEL_STATION_SETTING_LAST_DATA_FRONT_FOOT_NUMBER_2" |
||||
private const val KEY_BACK_FOOT_NUMBER_2 = "LEVEL_STATION_SETTING_LAST_DATA_BACK_FOOT_NUMBER_2" |
||||
private const val KEY_INSTRUMENT_MODEL = "LEVEL_STATION_SETTING_LAST_DATA_INSTRUMENT_MODEL" |
||||
private const val KEY_DEVICE_NUMBER = "LEVEL_STATION_SETTING_LAST_DATA_DEVICE_NUMBER" |
||||
private const val KEY_STEEL_RULE_PARAM = "LEVEL_STATION_SETTING_LAST_DATA_STEEL_RULE_PARAM" |
||||
private const val KEY_RULER_LENGTH_PROVING_TEMPERATURE = |
||||
"LEVEL_STATION_SETTING_LAST_DATA_RULER_LENGTH_PROVING_TEMPERATURE" |
||||
private const val KEY_TEMPERATURE = "LEVEL_STATION_SETTING_LAST_DATA_TEMPERATURE" |
||||
private const val KEY_WEATHER = "LEVEL_STATION_SETTING_LAST_DATA_WEATHER" |
||||
private const val KEY_IMAGING = "LEVEL_STATION_SETTING_LAST_DATA_IMAGING" |
||||
private const val KEY_SUN_DIRECTION = "LEVEL_STATION_SETTING_LAST_DATA_SUN_DIRECTION" |
||||
private const val KEY_WIND_DIRECTION = "LEVEL_STATION_SETTING_LAST_DATA_WIND_DIRECTION" |
||||
private const val KEY_WIND_SPEED = "LEVEL_STATION_SETTING_LAST_DATA_WIND_SPEED" |
||||
private const val KEY_ROADS = "LEVEL_STATION_SETTING_LAST_DATA_ROADS" |
||||
private const val KEY_SOIL = "LEVEL_STATION_SETTING_LAST_DATA_SOIL" |
||||
private const val KEY_RULER_TYPE = "LEVEL_STATION_SETTING_LAST_DATA_RULER_TYPE" |
||||
private const val KEY_RULER_RECEPT_TYPE = "LEVEL_STATION_SETTING_LAST_DATA_RULER_RECEPT_TYPE" |
||||
private const val KEY_RULER_CORRECTION_FACTOR = |
||||
"LEVEL_STATION_SETTING_LAST_DATA_RULER_CORRECTION_FACTOR" |
||||
|
||||
@WorkerThread |
||||
fun getExaminer(): String? { |
||||
return get(KEY_EXAMINER) |
||||
} |
||||
|
||||
@WorkerThread |
||||
fun setExaminer(examiner: String?) { |
||||
save(KEY_EXAMINER, examiner) |
||||
} |
||||
|
||||
@WorkerThread |
||||
fun getRecorder(): String? { |
||||
return get(KEY_RECORDER) |
||||
} |
||||
|
||||
@WorkerThread |
||||
fun setRecorder(recorder: String?) { |
||||
save(KEY_RECORDER, recorder) |
||||
} |
||||
|
||||
@WorkerThread |
||||
fun getWatcher(): String? { |
||||
return get(KEY_WATCHER) |
||||
} |
||||
|
||||
@WorkerThread |
||||
fun setWatcher(watcher: String?) { |
||||
save(KEY_WATCHER, watcher) |
||||
} |
||||
|
||||
@WorkerThread |
||||
fun getFrontFootNumber(): String? { |
||||
return get(KEY_FRONT_FOOT_NUMBER) |
||||
} |
||||
|
||||
@WorkerThread |
||||
fun setFrontFootNumber(watcher: String?) { |
||||
save(KEY_FRONT_FOOT_NUMBER, watcher) |
||||
} |
||||
|
||||
@WorkerThread |
||||
fun getFrontFootNumber2(): String? { |
||||
return get(KEY_FRONT_FOOT_NUMBER_2) |
||||
} |
||||
|
||||
@WorkerThread |
||||
fun setFrontFootNumber2(watcher: String?) { |
||||
save(KEY_FRONT_FOOT_NUMBER_2, watcher) |
||||
} |
||||
|
||||
@WorkerThread |
||||
fun getBackFootNumber(): String? { |
||||
return get(KEY_BACK_FOOT_NUMBER) |
||||
} |
||||
|
||||
@WorkerThread |
||||
fun setBackFootNumber(watcher: String?) { |
||||
save(KEY_BACK_FOOT_NUMBER, watcher) |
||||
} |
||||
|
||||
@WorkerThread |
||||
fun getBackFootNumber2(): String? { |
||||
return get(KEY_BACK_FOOT_NUMBER_2) |
||||
} |
||||
|
||||
@WorkerThread |
||||
fun setBackFootNumber2(watcher: String?) { |
||||
save(KEY_BACK_FOOT_NUMBER_2, watcher) |
||||
} |
||||
|
||||
@WorkerThread |
||||
fun getInstrumentModel(): String? { |
||||
return get(KEY_INSTRUMENT_MODEL) |
||||
} |
||||
|
||||
@WorkerThread |
||||
fun setInstrumentModel(watcher: String?) { |
||||
save(KEY_INSTRUMENT_MODEL, watcher) |
||||
} |
||||
|
||||
@WorkerThread |
||||
fun getDeviceNumber(): String? { |
||||
return get(KEY_DEVICE_NUMBER) |
||||
} |
||||
|
||||
@WorkerThread |
||||
fun setDeviceNumber(watcher: String?) { |
||||
save(KEY_DEVICE_NUMBER, watcher) |
||||
} |
||||
|
||||
@WorkerThread |
||||
fun getSteelRuleParam(): String? { |
||||
return get(KEY_STEEL_RULE_PARAM) |
||||
} |
||||
|
||||
@WorkerThread |
||||
fun setTemperature(watcher: String?) { |
||||
save(KEY_TEMPERATURE, watcher) |
||||
} |
||||
|
||||
@WorkerThread |
||||
fun getTemperature(): String? { |
||||
return get(KEY_TEMPERATURE) |
||||
} |
||||
|
||||
@WorkerThread |
||||
fun setWeather(watcher: String?) { |
||||
save(KEY_WEATHER, watcher) |
||||
} |
||||
|
||||
@WorkerThread |
||||
fun getWeather(): String? { |
||||
return get(KEY_WEATHER) |
||||
} |
||||
|
||||
@WorkerThread |
||||
fun setImaging(watcher: String?) { |
||||
save(KEY_IMAGING, watcher) |
||||
} |
||||
|
||||
@WorkerThread |
||||
fun getImaging(): String? { |
||||
return get(KEY_IMAGING) |
||||
} |
||||
|
||||
|
||||
///////////// |
||||
@WorkerThread |
||||
fun setSteelRuleParam(watcher: String?) { |
||||
save(KEY_STEEL_RULE_PARAM, watcher) |
||||
} |
||||
|
||||
@WorkerThread |
||||
fun getRulerLengthProvingTemperature(): String? { |
||||
return get(KEY_RULER_LENGTH_PROVING_TEMPERATURE) |
||||
} |
||||
|
||||
@WorkerThread |
||||
fun setRulerLengthProvingTemperature(watcher: String?) { |
||||
save(KEY_RULER_LENGTH_PROVING_TEMPERATURE, watcher) |
||||
} |
||||
|
||||
@WorkerThread |
||||
fun getSunDirection(): String? { |
||||
return get(KEY_SUN_DIRECTION) |
||||
} |
||||
|
||||
@WorkerThread |
||||
fun setSunDirection(watcher: String?) { |
||||
save(KEY_SUN_DIRECTION, watcher) |
||||
} |
||||
|
||||
@WorkerThread |
||||
fun getWindDirection(): String? { |
||||
return get(KEY_WIND_DIRECTION) |
||||
} |
||||
|
||||
@WorkerThread |
||||
fun setWindDirection(watcher: String?) { |
||||
save(KEY_WIND_DIRECTION, watcher) |
||||
} |
||||
|
||||
@WorkerThread |
||||
fun getWindSpeed(): String? { |
||||
return get(KEY_WIND_SPEED) |
||||
} |
||||
|
||||
@WorkerThread |
||||
fun setWindSpeed(watcher: String?) { |
||||
save(KEY_WIND_SPEED, watcher) |
||||
} |
||||
|
||||
@WorkerThread |
||||
fun getRoads(): String? { |
||||
return get(KEY_ROADS) |
||||
} |
||||
|
||||
@WorkerThread |
||||
fun setRoads(watcher: String?) { |
||||
save(KEY_ROADS, watcher) |
||||
} |
||||
|
||||
@WorkerThread |
||||
fun getSoil(): String? { |
||||
return get(KEY_SOIL) |
||||
} |
||||
|
||||
@WorkerThread |
||||
fun setSoil(watcher: String?) { |
||||
save(KEY_SOIL, watcher) |
||||
} |
||||
|
||||
@WorkerThread |
||||
fun getRulerType(): String? { |
||||
return get(KEY_RULER_TYPE) |
||||
} |
||||
|
||||
@WorkerThread |
||||
fun setRulerType(watcher: String?) { |
||||
save(KEY_RULER_TYPE, watcher) |
||||
} |
||||
|
||||
@WorkerThread |
||||
fun getRulerReceptType(): String? { |
||||
return get(KEY_RULER_RECEPT_TYPE) |
||||
} |
||||
|
||||
@WorkerThread |
||||
fun setRulerReceptType(watcher: String?) { |
||||
save(KEY_RULER_RECEPT_TYPE, watcher) |
||||
} |
||||
|
||||
@WorkerThread |
||||
fun getRulerCorrectionFactor(): String? { |
||||
return get(KEY_RULER_CORRECTION_FACTOR) |
||||
} |
||||
|
||||
@WorkerThread |
||||
fun setRulerCorrectionFactor(watcher: String?) { |
||||
save(KEY_RULER_CORRECTION_FACTOR, watcher) |
||||
} |
||||
|
||||
|
||||
private fun save(key: String, value: String?) { |
||||
SurveyorDatabaseFactory.instance.getConfigDataSource().setSync(key, value) |
||||
} |
||||
|
||||
private fun get(key: String): String? { |
||||
val measureUnitRecord = |
||||
SurveyorDatabaseFactory.instance.getConfigDataSource() |
||||
.getByKeySync(key) |
||||
return measureUnitRecord?.getConfigValue() |
||||
} |
||||
|
||||
} |
@ -0,0 +1,132 @@ |
||||
package com.bingce.controlnetwork.func.level.util |
||||
|
||||
import android.widget.Spinner |
||||
import androidx.annotation.WorkerThread |
||||
import com.bingce.controlapphelper.datasource.database.leveling.LevelingDbFactory |
||||
import com.bingce.controlapphelper.datasource.database.leveling.stationsetting.LevelingStationSettingRecord |
||||
import com.bingce.controlapphelper.model.LevelRouteSave |
||||
import com.bingce.controlapphelper.util.Tools |
||||
import com.bingce.controlnetwork.R |
||||
|
||||
object LevelStationSettingUtil { |
||||
|
||||
/** |
||||
* 保存测站设置 |
||||
*/ |
||||
fun saveStationSetting( |
||||
isSaveEndStationToStationSetting: Boolean, |
||||
levelRouteSave: LevelRouteSave |
||||
) { |
||||
|
||||
var saveEndStation = isSaveEndStationToStationSetting |
||||
|
||||
val stationSetting = if (levelRouteSave.stationId != null) { |
||||
val before = |
||||
LevelingDbFactory.instance.stationSettingDataSource.getByStationId(levelRouteSave.stationId) |
||||
|
||||
if (before != null) { |
||||
saveEndStation = before.setEndStationSetting or saveEndStation |
||||
} |
||||
|
||||
before ?: LevelingStationSettingRecord() |
||||
} else { |
||||
LevelingStationSettingRecord() |
||||
} |
||||
|
||||
//初始化保存的endStation |
||||
stationSetting.setEndStationSetting = saveEndStation |
||||
|
||||
stationSetting.routeId = levelRouteSave.routeId |
||||
stationSetting.stationId = levelRouteSave.stationId |
||||
stationSetting.watcher = levelRouteSave.watcher |
||||
stationSetting.recorder = levelRouteSave.recorder |
||||
stationSetting.examiner = levelRouteSave.examiner |
||||
stationSetting.firstStationBackFootNumber = levelRouteSave.backFootNumber |
||||
stationSetting.firstStationFrontFootNumber = levelRouteSave.frontFootNumber |
||||
stationSetting.firstStationBackFootNumber2 = levelRouteSave.backFootNumber2 |
||||
stationSetting.firstStationFrontFootNumber2 = levelRouteSave.frontFootNumber2 |
||||
stationSetting.instrumentModel = levelRouteSave.instrumentModel |
||||
stationSetting.deviceNumber = levelRouteSave.deviceNumber |
||||
stationSetting.steelRuleParam = levelRouteSave.steelRuleParam |
||||
stationSetting.rulerLengthProvingTemperature = levelRouteSave.rulerLengthProvingTemperature |
||||
stationSetting.rulerCorrectionFactor = levelRouteSave.rulerCorrectionFactor |
||||
stationSetting.rulerType = levelRouteSave.rulerType |
||||
stationSetting.rulerReceptType = levelRouteSave.rulerReceptType |
||||
|
||||
stationSetting.temperature = levelRouteSave.temperature |
||||
stationSetting.weather = levelRouteSave.weather |
||||
stationSetting.imaging = levelRouteSave.imaging |
||||
stationSetting.sunDirection = levelRouteSave.sunDirection |
||||
stationSetting.windDirection = levelRouteSave.windDirection |
||||
stationSetting.windSpeed = levelRouteSave.windSpeed |
||||
stationSetting.roads = levelRouteSave.roads |
||||
stationSetting.soil = levelRouteSave.soil |
||||
|
||||
LevelingDbFactory.instance.stationSettingDataSource.save(stationSetting) |
||||
} |
||||
|
||||
fun getSpinnerText(spinner: Spinner): String { |
||||
val text = spinner.selectedItem.toString() |
||||
if (text.contains(Tools.getString(R.string.please_choose))) { |
||||
return "" |
||||
} |
||||
return text |
||||
} |
||||
|
||||
@WorkerThread |
||||
fun saveStationSettingLastData(levelRouteSave: LevelRouteSave) { |
||||
LevelStationSettingLastData.setWatcher(levelRouteSave.watcher) |
||||
LevelStationSettingLastData.setRecorder(levelRouteSave.recorder) |
||||
LevelStationSettingLastData.setExaminer(levelRouteSave.examiner) |
||||
LevelStationSettingLastData.setBackFootNumber(levelRouteSave.backFootNumber) |
||||
LevelStationSettingLastData.setFrontFootNumber(levelRouteSave.frontFootNumber) |
||||
LevelStationSettingLastData.setBackFootNumber2(levelRouteSave.backFootNumber2) |
||||
LevelStationSettingLastData.setFrontFootNumber2(levelRouteSave.frontFootNumber2) |
||||
LevelStationSettingLastData.setInstrumentModel(levelRouteSave.instrumentModel) |
||||
LevelStationSettingLastData.setDeviceNumber(levelRouteSave.deviceNumber) |
||||
LevelStationSettingLastData.setSteelRuleParam(levelRouteSave.steelRuleParam) |
||||
LevelStationSettingLastData.setRulerLengthProvingTemperature(levelRouteSave.rulerLengthProvingTemperature) |
||||
LevelStationSettingLastData.setRulerCorrectionFactor(levelRouteSave.rulerCorrectionFactor) |
||||
LevelStationSettingLastData.setRulerType(levelRouteSave.rulerType) |
||||
LevelStationSettingLastData.setRulerReceptType(levelRouteSave.rulerReceptType) |
||||
|
||||
LevelStationSettingLastData.setTemperature(levelRouteSave.temperature) |
||||
LevelStationSettingLastData.setWeather(levelRouteSave.weather) |
||||
LevelStationSettingLastData.setImaging(levelRouteSave.imaging) |
||||
LevelStationSettingLastData.setSunDirection(levelRouteSave.sunDirection) |
||||
LevelStationSettingLastData.setWindDirection(levelRouteSave.windDirection) |
||||
LevelStationSettingLastData.setWindSpeed(levelRouteSave.windSpeed) |
||||
LevelStationSettingLastData.setRoads(levelRouteSave.roads) |
||||
LevelStationSettingLastData.setSoil(levelRouteSave.soil) |
||||
} |
||||
|
||||
@WorkerThread |
||||
fun getStationSettingLastData(): LevelRouteSave { |
||||
return LevelRouteSave.createLastData( |
||||
LevelStationSettingLastData.getWatcher(), |
||||
LevelStationSettingLastData.getRecorder(), |
||||
LevelStationSettingLastData.getExaminer(), |
||||
LevelStationSettingLastData.getBackFootNumber(), |
||||
LevelStationSettingLastData.getFrontFootNumber(), |
||||
LevelStationSettingLastData.getBackFootNumber2(), |
||||
LevelStationSettingLastData.getFrontFootNumber2(), |
||||
LevelStationSettingLastData.getInstrumentModel(), |
||||
LevelStationSettingLastData.getDeviceNumber(), |
||||
LevelStationSettingLastData.getSteelRuleParam(), |
||||
LevelStationSettingLastData.getRulerLengthProvingTemperature(), |
||||
LevelStationSettingLastData.getRulerCorrectionFactor(), |
||||
LevelStationSettingLastData.getRulerType(), |
||||
LevelStationSettingLastData.getRulerReceptType(), |
||||
|
||||
LevelStationSettingLastData.getTemperature(), |
||||
LevelStationSettingLastData.getWeather(), |
||||
LevelStationSettingLastData.getImaging(), |
||||
LevelStationSettingLastData.getSunDirection(), |
||||
LevelStationSettingLastData.getWindDirection(), |
||||
LevelStationSettingLastData.getWindSpeed(), |
||||
LevelStationSettingLastData.getRoads(), |
||||
LevelStationSettingLastData.getSoil() |
||||
) |
||||
} |
||||
|
||||
} |
@ -0,0 +1,237 @@ |
||||
package com.bingce.controlnetwork.func.level.util |
||||
|
||||
import androidx.annotation.WorkerThread |
||||
import blankj.utilcode.util.ToastUtils |
||||
import com.bingce.controlapphelper.datasource.database.SurveyorDatabaseFactory |
||||
import com.bingce.controlapphelper.datasource.database.leveling.LevelingDbFactory |
||||
import com.bingce.controlapphelper.datasource.database.leveling.measure.station.LevelingMeasureStationRecord |
||||
import com.bingce.controlapphelper.datasource.database.leveling.station.LevelingStationRecord |
||||
import com.bingce.controlapphelper.model.LevelingMeasureOrder |
||||
import com.bingce.controlapphelper.model.StationOddEven |
||||
import com.bingce.controlapphelper.util.RegExUtil |
||||
import com.bingce.utils.DateUtils |
||||
|
||||
object LevelStationUtilTj { |
||||
@WorkerThread |
||||
@JvmStatic |
||||
fun createStation( |
||||
projectId: String, |
||||
routeId: String, |
||||
backPointId: String, |
||||
firstStation: Boolean = false, |
||||
endStation: Boolean = false |
||||
) { |
||||
val routeRecord = LevelingDbFactory.instance.levelDataSource.getByIdSync(routeId) |
||||
routeRecord?.let { |
||||
val levelingMeasureOrder = it.levelingMeasureOrder |
||||
|
||||
//新建路线的时候创建一个水准测站 |
||||
val frontPoint = |
||||
LevelPointUtilTj.createFrontPointByBackPointId( |
||||
routeId, |
||||
backPointId, |
||||
firstStation, |
||||
endStation |
||||
) |
||||
|
||||
val stationNamePrefix = "测站" |
||||
val lastStationNameIndex = getLastStationNameIndex(projectId, routeId) |
||||
|
||||
//创建测站的奇偶站 |
||||
val createStationOdd = getCreateStationOdd(projectId, routeId) |
||||
|
||||
when (levelingMeasureOrder) { |
||||
LevelingMeasureOrder.SIM_BF, LevelingMeasureOrder.SIM_BFFB -> { |
||||
val relationId = DateUtils.genRandomTimeId() |
||||
saveOneStationRecord( |
||||
projectId, |
||||
routeId, |
||||
"${stationNamePrefix}${lastStationNameIndex.plus(1)}_L", |
||||
backPointId, |
||||
frontPoint.getId(), |
||||
false, |
||||
createStationOdd, |
||||
relationId, |
||||
endStation = false |
||||
) |
||||
saveOneStationRecord( |
||||
projectId, |
||||
routeId, |
||||
"${stationNamePrefix}${lastStationNameIndex.plus(1)}_R", |
||||
backPointId, |
||||
frontPoint.getId(), |
||||
true, |
||||
createStationOdd, |
||||
relationId, |
||||
endStation = endStation |
||||
) |
||||
} |
||||
|
||||
LevelingMeasureOrder.A_BF, LevelingMeasureOrder.A_BFFB, LevelingMeasureOrder.A_FBBF -> { |
||||
saveOneStationRecord( |
||||
projectId, |
||||
routeId, |
||||
"${stationNamePrefix}${lastStationNameIndex.plus(1)}", |
||||
backPointId, |
||||
frontPoint.getId(), |
||||
false, |
||||
createStationOdd, |
||||
endStation = endStation |
||||
) |
||||
} |
||||
|
||||
else -> { |
||||
saveOneStationRecord( |
||||
projectId, |
||||
routeId, |
||||
"${stationNamePrefix}${lastStationNameIndex.plus(1)}", |
||||
backPointId, |
||||
frontPoint.getId(), |
||||
false, |
||||
createStationOdd, |
||||
endStation = endStation |
||||
) |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
@WorkerThread |
||||
private fun getLastStationNameIndex(projectId: String, routeId: String): Int { |
||||
val stationLatest = |
||||
LevelingDbFactory.instance.stationDataSource.getStationLatest(projectId, routeId) |
||||
return stationLatest?.stationName?.let { |
||||
val findNum = RegExUtil.findNum(it) |
||||
findNum?.toInt() ?: 0 |
||||
} ?: 0 |
||||
} |
||||
|
||||
@WorkerThread |
||||
private fun getLastStationId(projectId: String, routeId: String): String? { |
||||
return getStationLatest(projectId, routeId)?.id |
||||
} |
||||
|
||||
private fun getStationLatest(projectId: String, routeId: String) = |
||||
LevelingDbFactory.instance.stationDataSource.getStationLatest(projectId, routeId) |
||||
|
||||
@WorkerThread |
||||
private fun saveOneStationRecord( |
||||
projectId: String, |
||||
routeId: String, |
||||
stationName: String, |
||||
backPointId: String, |
||||
frontPointId: String, |
||||
twiceStation: Boolean, |
||||
oddStation: StationOddEven, |
||||
relationId: String? = null, |
||||
endStation: Boolean = false |
||||
) { |
||||
val lastStationId = getLastStationId(projectId, routeId) |
||||
|
||||
val station = LevelingStationRecord.createStation( |
||||
projectId, |
||||
routeId, |
||||
stationName, |
||||
lastStationId, |
||||
twiceStation, |
||||
backPointId, |
||||
frontPointId, |
||||
0, |
||||
oddStation, |
||||
endStation |
||||
) |
||||
station.relationStationId = relationId |
||||
LevelingDbFactory.instance.stationDataSource.save(station) |
||||
} |
||||
|
||||
private fun getCreateStationOdd( |
||||
projectId: String, |
||||
routeId: String |
||||
): StationOddEven { |
||||
val stationLatest = getStationLatest(projectId, routeId) |
||||
?: return StationOddEven.ODD_STATION |
||||
return if (stationLatest.isOddStation) { |
||||
StationOddEven.EVEN_STATION |
||||
} else { |
||||
StationOddEven.ODD_STATION |
||||
} |
||||
} |
||||
|
||||
@JvmStatic |
||||
fun checkStationForResult(stationId: String): Boolean { |
||||
val stationRecord = LevelingDbFactory.instance.stationDataSource.getRecordSync(stationId) |
||||
if (stationRecord.isFinish) { |
||||
return true |
||||
} else { |
||||
if (stationRecord == null || !stationRecord.isFull) { |
||||
ToastUtils.showShort("该测站数据不完整!") |
||||
} |
||||
if (!stationRecord.isFinish) { |
||||
ToastUtils.showShort("该测站未通过检测!") |
||||
} |
||||
return false |
||||
} |
||||
} |
||||
|
||||
@JvmStatic |
||||
fun getStationFinishCount(projectId: String, routeId: String): Int { |
||||
return LevelingDbFactory.instance.stationDataSource.getCountFinish(projectId, routeId) |
||||
} |
||||
|
||||
/** |
||||
* 获取要测量的测站列表 |
||||
*/ |
||||
fun getMeasureStationList(projectId: String, routeId: String): List<LevelingStationRecord> { |
||||
val stationLatest = |
||||
LevelingDbFactory.instance.stationDataSource.getStationLatest(projectId, routeId) |
||||
val returnList = mutableListOf<LevelingStationRecord>() |
||||
if (stationLatest != null) { |
||||
if (stationLatest.twiceStation) { |
||||
//单程双转点 |
||||
val statonList = |
||||
LevelingDbFactory.instance.stationDataSource.getStationListByRelationId( |
||||
projectId, |
||||
routeId, |
||||
stationLatest.relationStationId |
||||
) |
||||
returnList.addAll(statonList) |
||||
} else { |
||||
returnList.add(stationLatest) |
||||
} |
||||
} |
||||
return returnList |
||||
} |
||||
|
||||
@WorkerThread |
||||
fun getStationRouteResult(stationRecord: LevelingStationRecord): String { |
||||
val routeName = |
||||
LevelingDbFactory.instance.levelDataSource.getByIdSync(stationRecord.routeId)?.routeName ?: "" |
||||
|
||||
val sb = StringBuilder() |
||||
|
||||
if (stationRecord.twiceStation) { |
||||
val relationStation = LevelingDbFactory.instance.stationDataSource |
||||
.getRelationStation(stationRecord.relationStationId, false) |
||||
val twiceStationMeasureRecord = getMeasureStationRecord(relationStation.getId()) |
||||
appendMeasureResult(sb, routeName, twiceStationMeasureRecord) |
||||
} |
||||
|
||||
val measureStationRecord = getMeasureStationRecord(stationRecord.getId()) |
||||
appendMeasureResult(sb, routeName, measureStationRecord) |
||||
|
||||
return sb.toString() |
||||
} |
||||
|
||||
private fun appendMeasureResult( |
||||
sb: StringBuilder, |
||||
routeName: String, |
||||
measureStationRecord: LevelingMeasureStationRecord |
||||
) { |
||||
sb.append("${routeName}的总高差${measureStationRecord.heightDiffTotalShow},总距离${measureStationRecord.distanceTotalShow}") |
||||
.append("\n") |
||||
} |
||||
|
||||
private fun getMeasureStationRecord(stationId: String) = |
||||
LevelingDbFactory.instance.measureStationDataSource.getRecordSync(stationId) |
||||
|
||||
} |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue