|
|
|
@ -29,7 +29,8 @@ object ParseHelper {
|
|
|
|
|
|
|
|
|
|
private val mPortRunnable = hashMapOf<Int, FlagRunnable?>()
|
|
|
|
|
private val mHandler = Handler(Looper.getMainLooper())
|
|
|
|
|
private val tempGasData = mutableListOf<GasReqBean>()
|
|
|
|
|
private val tempGasReqData = mutableListOf<GasReqBean>()
|
|
|
|
|
private val tempGasData = mutableListOf<Gas>()
|
|
|
|
|
private val devicesApi by lazy {
|
|
|
|
|
DevicesApi()
|
|
|
|
|
}
|
|
|
|
@ -245,9 +246,18 @@ object ParseHelper {
|
|
|
|
|
private suspend fun uploadGasData(gas: Gas) {
|
|
|
|
|
try {
|
|
|
|
|
// 上传实时气体数据
|
|
|
|
|
tempGasData.add(GasReqBean(gas))
|
|
|
|
|
if (tempGasData.size > GAS_CLOUD_UPLOAD_SIZE_ONCE) {
|
|
|
|
|
devicesApi.uploadGasData(tempGasData)
|
|
|
|
|
tempGasData.add(gas)
|
|
|
|
|
tempGasReqData.add(GasReqBean(gas))
|
|
|
|
|
if (tempGasReqData.size > GAS_CLOUD_UPLOAD_SIZE_ONCE) {
|
|
|
|
|
val uploadGasData = devicesApi.uploadGasData(tempGasReqData)
|
|
|
|
|
if (uploadGasData?.isOk() == true) {
|
|
|
|
|
val gasDao = DBUtils.gasDao()
|
|
|
|
|
tempGasData.forEach { item ->
|
|
|
|
|
item.syncFlag = true
|
|
|
|
|
gasDao.update(item)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
tempGasReqData.clear()
|
|
|
|
|
tempGasData.clear()
|
|
|
|
|
}
|
|
|
|
|
} catch (e: Exception) {
|
|
|
|
|