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