批量上传之前未上传的测点记录

main
chenglifeng 6 months ago
parent 94bf0da2f1
commit e86b0ff0d3
  1. BIN
      app/libs/repository-release.aar
  2. 37
      app/src/main/java/com/project/survey/logic/viewmodel/ControlNetViewModel.kt
  3. 108
      app/src/main/java/com/project/survey/logic/viewmodel/ProjectViewModel.kt
  4. 4
      app/src/main/java/com/project/survey/model/PointEntry.kt
  5. 16
      app/src/main/java/com/project/survey/network/Api.kt
  6. 13
      app/src/main/java/com/project/survey/ui/MainActivity.kt
  7. 3
      app/src/main/java/com/project/survey/ui/instrument/basestationtranslation/RtkBaseCorrectActivity.java
  8. 3
      app/src/main/java/com/project/survey/ui/lofting/pointlofting/PointStakingActivity.java
  9. 7
      app/src/main/java/com/project/survey/ui/pointmeasure/measure/PointSurveyNewActivity.java

Binary file not shown.

@ -4,8 +4,8 @@ import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import com.project.survey.constants.SPConstants
import com.project.survey.logic.bean.ListResult
import com.project.survey.model.ControlNetworkBean
import com.project.survey.model.ControlNetCGBean
import com.project.survey.model.ControlNetworkBean
import com.project.survey.model.ControlNetworkInfoBean
import com.project.survey.model.ProjectBean
import com.project.survey.network.RetrofitClient
@ -25,9 +25,7 @@ class ControlNetViewModel : BaseViewModel() {
*/
fun fetchSpecialControlNetworkList(pageNum: Int = 1) {
launch {
val currentProject =
SPUtils.getParcelable(SPConstants.CURRENT_PROJECT, ProjectBean::class.java)
val res = api.fetchSpecialControlNetworkList(currentProject?.XMXX_ID ?: "", pageNum)
val res = api.fetchSpecialControlNetworkList(pageNum = pageNum)
if (res.success) {
_controlNetworkListResponse.postValue(res.data)
}
@ -48,13 +46,10 @@ class ControlNetViewModel : BaseViewModel() {
pageNum: Int = 1
) {
launch {
val currentProject =
SPUtils.getParcelable(SPConstants.CURRENT_PROJECT, ProjectBean::class.java)
val res = api.fetchSpecialControlNetworkInfo(
currentProject?.XMXX_ID ?: "",
controlNetworkName,
pointName,
pageNum
controlNetWorkName = controlNetworkName,
pointName = pointName,
pageNum = pageNum
)
if (res.success) {
_controlNetworkInfoResponse.postValue(res.data)
@ -71,14 +66,11 @@ class ControlNetViewModel : BaseViewModel() {
*/
fun fetchSpecialControlNetCGList(j_query: String, page: Int = 1, start: Int = 0) {
launch {
val currentProject =
SPUtils.getParcelable(SPConstants.CURRENT_PROJECT, ProjectBean::class.java)
val res = api.fetchSpecialControlNetCGList(
currentProject?.XMXX_ID ?: "",
"BD_KZWZBCG",
"BD_KZWZBCG_ZY",
j_query,
page,
tableCode = "BD_KZWZBCG",
funcCode = "BD_KZWZBCG_ZY",
j_query = j_query,
page = page,
start = start
)
if (res.success) {
@ -92,14 +84,11 @@ class ControlNetViewModel : BaseViewModel() {
*/
fun fetchFirstControlNetList(j_query: String, page: Int = 1, start: Int = 0) {
launch {
val currentProject =
SPUtils.getParcelable(SPConstants.CURRENT_PROJECT, ProjectBean::class.java)
val res = api.fetchSpecialControlNetCGList(
currentProject?.XMXX_ID ?: "",
"BD_KZWZBCG",
"BD_KZWZBCG",
j_query,
page,
tableCode = "BD_KZWZBCG",
funcCode = "BD_KZWZBCG",
j_query = j_query,
page = page,
start = start
)
if (res.success) {

@ -2,6 +2,12 @@ package com.project.survey.logic.viewmodel
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.sqlite.db.SimpleSQLiteQuery
import blankj.utilcode.util.LogUtils
import com.bingce.data.database.PointDb
import com.bingce.data.database.PointStakeDb
import com.bingce.data.surveyor.surveydata.pointstake.PointStakeRecord
import com.bingce.data.surveyor.surveydata.pointsurvey.PointRecord
import com.project.survey.constants.Constants
import com.project.survey.constants.SPConstants
import com.project.survey.logic.bean.ListResult
@ -9,7 +15,6 @@ import com.project.survey.model.ApprovalBean
import com.project.survey.model.InspectionReportBean
import com.project.survey.model.LoftingBean
import com.project.survey.model.LoftingPointBean
import com.project.survey.model.LoftingPointListBean
import com.project.survey.model.LoftingPointRecordEntry
import com.project.survey.model.MeasureBean
import com.project.survey.model.MeasureWorkStatusResult
@ -49,9 +54,7 @@ class ProjectViewModel : BaseViewModel() {
*/
fun fetchWorkTask(type: String, page: Int = 1) {
launch {
val currentProject =
SPUtils.getParcelable(SPConstants.CURRENT_PROJECT, ProjectBean::class.java)
val res = api.fetchWorkTask(currentProject?.XMXX_ID ?: "", type, page)
val res = api.fetchWorkTask(type = type, page = page)
if (res.success) {
_workTaskListResponse.postValue(res.data.data.rows)
}
@ -77,11 +80,10 @@ class ProjectViewModel : BaseViewModel() {
}
val res = api.fetchMeasureDataList(
SPUtils.getString(SPConstants.PROJECT_ID),
type,
if (type == Constants.TYPE_BD_CLJH) Constants.TYPE_BD_CLJH else "${Constants.TYPE_BD_CLGZ_GCJL}_ZB",
query,
page
tableCode = type,
funcCode = if (type == Constants.TYPE_BD_CLJH) Constants.TYPE_BD_CLJH else "${Constants.TYPE_BD_CLGZ_GCJL}_ZB",
j_qurey = query,
page = page
)
if (res.success) {
_measureBeanListResponse.postValue(res.data)
@ -100,12 +102,8 @@ class ProjectViewModel : BaseViewModel() {
*/
fun updateMeasureWorkStatus(workId: String, workType: String, status: String) {
launch {
val res = api.updateMeasureWorkStatus(
SPUtils.getString(SPConstants.PROJECT_ID),
workId,
workType,
status
)
val res =
api.updateMeasureWorkStatus(workId = workId, workType = workType, status = status)
if (res.success) {
_updateMeasureWorkStatusResponse.postValue(
MeasureWorkStatusResult(
@ -127,14 +125,14 @@ class ProjectViewModel : BaseViewModel() {
/**
* 测点记录录入
*/
fun uploadPointEntry(pointEntry: PointEntry) {
fun uploadPointEntry(pointRecord: PointRecord) {
launch {
val res =
api.uploadPointEntry(
SPUtils.getString(SPConstants.PROJECT_ID),
arrayListOf(pointEntry)
)
val res = api.uploadPointEntry(requestBody = arrayListOf(PointEntry(pointRecord)))
if (res.success) {
// 上传成功,更新数据库里状态
PointDb.getInstance().save(pointRecord.apply {
uploaded = true
})
_uploadPointEntryResponse.postValue(res.data)
} else {
errorResponse.postValue(res.message)
@ -142,14 +140,28 @@ class ProjectViewModel : BaseViewModel() {
}
}
fun uploadPointEntry(pointEntryList: List<PointEntry>) {
/**
* 批量上传 之前未上传或上传失败的点测量记录
*/
fun uploadPointEntry() {
launch {
val res =
api.uploadPointEntry(SPUtils.getString(SPConstants.PROJECT_ID), pointEntryList)
// 找出当前项目未上传的点
val sqlString =
"SELECT * FROM Point WHERE project_id=='${SPUtils.getString(SPConstants.PROJECT_ID)}' AND uploaded!=1 AND BC_DELETE != 1"
val pointRecords = PointDb.getInstance().rawQueryListData(SimpleSQLiteQuery(sqlString))
if (pointRecords.isNullOrEmpty()) {
LogUtils.d("测点上传------没有找到未上传的点测量记录")
return@launch
}
LogUtils.d("测点上传------有未上传的点测量记录")
val res = api.uploadPointEntry(requestBody = pointRecords.map { PointEntry(it) })
if (res.success) {
// 上传成功,更新数据库里状态
pointRecords.forEach { item -> item.uploaded = true }
PointDb.getInstance().save(pointRecords)
LogUtils.d("测点上传------上传点测量记录--成功")
} else {
errorResponse.postValue(res.message)
LogUtils.d("测点上传------上传点测量记录--失败:${res.message}")
}
}
}
@ -163,7 +175,7 @@ class ProjectViewModel : BaseViewModel() {
*/
fun createInspectionReport(workId: String) {
launch {
val res = api.createInspectionReport(SPUtils.getString(SPConstants.PROJECT_ID), workId)
val res = api.createInspectionReport(workId = workId)
if (res.success) {
_createInspectionReportResponse.postValue(res.data)
} else {
@ -220,14 +232,52 @@ class ProjectViewModel : BaseViewModel() {
/**
* 上传放样测点记录
*/
fun uploadLoftingPointRecord(record: LoftingPointRecordEntry) {
fun uploadLoftingPointRecord(record: PointStakeRecord) {
launch {
val res = api.uploadLoftingPointRecord(requestBody = arrayListOf(record))
val res = api.uploadLoftingPointRecord(
requestBody = arrayListOf(
LoftingPointRecordEntry(record)
)
)
if (res.success) {
// 上传成功
PointStakeDb.getInstance().save(record.apply {
uploaded = true
})
_uploadLoftingPointRecordResponse.postValue(res.data)
} else {
errorResponse.postValue(res.message)
}
}
}
/**
* 批量上传 之前未上传或上传失败的放样点记录
*/
fun uploadLoftingPointRecord() {
launch {
// 找到未上传的列表
val sqlStringLofting =
"SELECT * FROM Point_Stake WHERE project_id=='${SPUtils.getString(SPConstants.PROJECT_ID)}' AND uploaded!=1 AND BC_DELETE != 1"
val pointStakeRecords =
PointStakeDb.getInstance().rawQueryListData(SimpleSQLiteQuery(sqlStringLofting))
if (pointStakeRecords.isNullOrEmpty()) {
LogUtils.d("测点上传------没有找到未上传的放样点记录")
return@launch
}
LogUtils.d("测点上传------有未上传的放样点记录")
val res = api.uploadLoftingPointRecord(requestBody = pointStakeRecords.map {
LoftingPointRecordEntry(it)
})
if (res.success) {
// 上传成功
pointStakeRecords.forEach { item -> item.uploaded = true }
PointStakeDb.getInstance().save(pointStakeRecords)
LogUtils.d("测点上传------上传放样点记录--成功")
} else {
LogUtils.d("测点上传------上传放样点记录--失败:${res.message}")
}
}
}
}

@ -22,10 +22,10 @@ data class PointEntry(
val jzt: String, //解状态 "xx"
val satellite: String, //结算卫星 "xx"
) {
constructor(workType: String, record: PointRecord) : this(
constructor(record: PointRecord) : this(
record.name,
record.jobId,
workType,
record.workType,
if (Device.getInstance().deviceType == DeviceTypeEnum.DEVICE_TYPE_RTK) "${record.deviceInfoData.rtkStatusData?.poleHeight}" else "${record.deviceInfoData.tsStatusData?.hr}",
record.remarks?:"",
"${record.x}",

@ -82,7 +82,7 @@ interface Api {
@FormUrlEncoded
@POST("je/workflow/currentUserTask/getTask")
suspend fun fetchWorkTask(
@Header("Projectid") projectId: String,
@Header("Projectid") projectId: String = SPUtils.getString(SPConstants.PROJECT_ID),
@Field("type") type: String,
// @Field("userName") userName: String = "",
@Field("page") page: Int,
@ -94,7 +94,7 @@ interface Api {
*/
@GET("je/controlnetwork/queryControlNetwork")
suspend fun fetchSpecialControlNetworkList(
@Header("projectId") projectId: String,
@Header("projectId") projectId: String = SPUtils.getString(SPConstants.PROJECT_ID),
@Query("pageNum") pageNum: Int,
@Query("pageSize") pageSize: Int = 30
): HttpResult<ListResult<ControlNetworkBean>>
@ -115,7 +115,7 @@ interface Api {
*/
@GET("je/controlnetwork/queryControlNetworkInfoByName")
suspend fun fetchSpecialControlNetworkInfo(
@Header("projectId") projectId: String,
@Header("projectId") projectId: String = SPUtils.getString(SPConstants.PROJECT_ID),
@Query("controlNetWorkName") controlNetWorkName: String, //当前控制网name
@Query("pointName") pointName: String? = null, //关键词,搜索用
@Query("pageNum") pageNum: Int,
@ -128,7 +128,7 @@ interface Api {
@FormUrlEncoded
@POST("je/common/load")
suspend fun fetchSpecialControlNetCGList(
@Header("projectId") projectId: String,
@Header("projectId") projectId: String = SPUtils.getString(SPConstants.PROJECT_ID),
@Field("tableCode") tableCode: String,
@Field("funcCode") funcCode: String,
@Field("j_query") j_query: String = "",
@ -147,7 +147,7 @@ interface Api {
@FormUrlEncoded
@POST("je/cloud/beiDou/load")
suspend fun fetchMeasureDataList(
@Header("projectId") projectId: String,
@Header("projectId") projectId: String = SPUtils.getString(SPConstants.PROJECT_ID),
@Field("tableCode") tableCode: String,
@Field("funcCode") funcCode: String,
@Field("j_qurey") j_qurey: String = "",
@ -164,7 +164,7 @@ interface Api {
*/
@GET("je/measureWork/modifyWorkStatus")
suspend fun updateMeasureWorkStatus(
@Header("projectId") projectId: String,
@Header("projectId") projectId: String = SPUtils.getString(SPConstants.PROJECT_ID),
@Query("workId") workId: String,
@Query("workType") workType: String,
@Query("status") status: String
@ -175,7 +175,7 @@ interface Api {
*/
@POST("je/measureWork/pointsEntry")
suspend fun uploadPointEntry(
@Header("projectId") projectId: String,
@Header("projectId") projectId: String = SPUtils.getString(SPConstants.PROJECT_ID),
@Body requestBody: List<PointEntry>
): HttpResult<String>
@ -184,7 +184,7 @@ interface Api {
*/
@GET("je/measureWork/createInspectionReport")
suspend fun createInspectionReport(
@Header("projectId") projectId: String,
@Header("projectId") projectId: String = SPUtils.getString(SPConstants.PROJECT_ID),
@Query("workId") workId: String
): HttpResult<InspectionReportBean>

@ -7,6 +7,7 @@ import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentPagerAdapter
import androidx.viewpager.widget.ViewPager
import blankj.utilcode.util.LogUtils
import blankj.utilcode.util.NetworkUtils
import com.bingce.device.Device
import com.bingce.ui.TabEntity
import com.bingce.utils.SdkUtils
@ -16,6 +17,7 @@ import com.project.survey.R
import com.project.survey.databinding.ActivityMainBinding
import com.project.survey.extend.toast
import com.project.survey.logic.viewmodel.MainViewModel
import com.project.survey.logic.viewmodel.ProjectViewModel
import com.project.survey.ui.base.BaseBindingActivity
import com.project.survey.ui.home.HomeFragment
import com.project.survey.ui.home.InstrumentFragment
@ -38,6 +40,7 @@ class MainActivity : BaseBindingActivity<ActivityMainBinding>() {
override fun getBinding(): ActivityMainBinding = ActivityMainBinding.inflate(layoutInflater)
private val viewModel: MainViewModel by viewModels()
private val projectViewModel: ProjectViewModel by viewModels()
override fun initView() {
viewModel.verifySdk()
@ -47,14 +50,18 @@ class MainActivity : BaseBindingActivity<ActivityMainBinding>() {
",i=" + SdkUtils.isIntlCodeValidate() +
",a=" + SdkUtils.availableTime() +
",trialTimes=" + SdkUtils.remainingTrialTimes()
// toastLong(text)
LogUtils.d(text)
// toastLong(text) LogUtils.d(text)
}
initTabFragment()
}
override fun initData() {
// 检查网络连接,获取之前未上传的测点数据,进行上传
if (NetworkUtils.isConnected()) {
projectViewModel.uploadPointEntry()
projectViewModel.uploadLoftingPointRecord()
}
}
override fun initListener() {
@ -135,7 +142,7 @@ class MainActivity : BaseBindingActivity<ActivityMainBinding>() {
private var exitTime: Long = 0
override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean {
if (keyCode == KeyEvent.KEYCODE_BACK){
if (keyCode == KeyEvent.KEYCODE_BACK) {
if ((System.currentTimeMillis() - exitTime) > 2000) {
toast("再按一次退出程序")
exitTime = System.currentTimeMillis()

@ -16,6 +16,7 @@ import com.bingce.coordlib.model.Coordinate;
import com.bingce.coordlib.model.CoordinateSystem;
import com.bingce.data.cache.AbstractCachedObserver;
import com.bingce.data.cache.CachedCurrentCoordinateSystem;
import com.bingce.data.cache.CachedCurrentCoordinateSystemKt;
import com.bingce.data.database.ProjectDb;
import com.bingce.device.Device;
import com.bingce.device.enums.ConnectTypeEnum;
@ -46,7 +47,7 @@ public class RtkBaseCorrectActivity extends BaseSurveyNewActivity {
private int mTimes = -1;
double latSum = 0, lngSum = 0, altSum = 0;
private double originalLatitude, originalLongitude, originalAltitude;
protected final CachedCurrentCoordinateSystem cachedCoordinateSystem = new CachedCurrentCoordinateSystem(this);
protected final CachedCurrentCoordinateSystemKt cachedCoordinateSystem = new CachedCurrentCoordinateSystemKt(this);
private ActivityRtkCorrectBinding binding;

@ -1102,8 +1102,7 @@ public class PointStakingActivity extends BaseSurveyNewActivity {
PointStakeDb.getInstance().save(pointStakeRecord);
// 上传测点
LoftingPointRecordEntry entry = new LoftingPointRecordEntry(pointStakeRecord);
viewModel.uploadLoftingPointRecord(entry);
viewModel.uploadLoftingPointRecord(pointStakeRecord);
runOnUiThread(() -> {
recordPointLine.getValues().add(new PointValue(pointStakeRecord.measuredY, pointStakeRecord.measuredX).setLabel(""));

@ -625,6 +625,7 @@ public class PointSurveyNewActivity extends BaseSurveyNewActivity implements Vie
, x, y, z
, latitude, longitude, altitude
, PointConstants.POINT_FORMAT_LATITUDE, deviceInfoData);
record.workType = workType;
ThreadPoolUtil.execute(() -> {
if (!Device.getInstance().rtkAllowRepeatName) {
@ -643,10 +644,8 @@ public class PointSurveyNewActivity extends BaseSurveyNewActivity implements Vie
binding.etPointName.setText(Util.lastOfStringPlusStep(pointName, Device.getInstance().rtkPointNameAddStep));
});
PointDb.getInstance().save(record);
PointEntry pointEntry = new PointEntry(workType, record);
viewModel.uploadPointEntry(pointEntry);
// 上传测点信息到服务器
viewModel.uploadPointEntry(record);
});
}

Loading…
Cancel
Save