[fea]
[offline]
[线路表添加租户id和项目名称]
This commit is contained in:
yangyakun
2025-01-02 10:46:26 +08:00
parent 434ea16e63
commit 3486031e93
5 changed files with 40 additions and 34 deletions

View File

@@ -2,7 +2,7 @@
"formatVersion": 1,
"database": {
"version": 6,
"identityHash": "01269591615dbf16e01fcf0281ea117b",
"identityHash": "9da3a45e98fe1252081e52f5fbc864be",
"entities": [
{
"tableName": "contrail_data_table",
@@ -87,7 +87,7 @@
},
{
"tableName": "line_data_table",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `line_id` INTEGER, `line_name` TEXT, `end_station_name` TEXT, `line_get_time` INTEGER NOT NULL)",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `line_id` INTEGER, `line_name` TEXT, `end_station_name` TEXT, `tenant_id` INTEGER, `project_name` TEXT, `line_get_time` INTEGER NOT NULL)",
"fields": [
{
"fieldPath": "id",
@@ -113,6 +113,18 @@
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "tenantId",
"columnName": "tenant_id",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "projectName",
"columnName": "project_name",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "linegetTime",
"columnName": "line_get_time",
@@ -469,7 +481,7 @@
"views": [],
"setupQueries": [
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '01269591615dbf16e01fcf0281ea117b')"
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '9da3a45e98fe1252081e52f5fbc864be')"
]
}
}

View File

@@ -31,6 +31,18 @@ data class LineDataBean(
@SerializedName("endSiteName")
var endStationName: String? = null,
/**
* 租户id
*/
@ColumnInfo(name = "tenant_id", typeAffinity = ColumnInfo.INTEGER)
var tenantId: Long? = null,
/**
* 项目类型 dali saas mogo
*/
@ColumnInfo(name = "project_name", typeAffinity = ColumnInfo.TEXT)
var projectName: String? = null,
/**
* 存储此条数据时时间戳
*/

View File

@@ -26,18 +26,13 @@ interface LineDataDao {
@Query("DELETE FROM ${LineDataBean.tableName} WHERE line_get_time < :zeroTime")
fun deleteObsoleteData(zeroTime: Long = DateTimeUtil.getCurrentDateZero()):Int
//删除非昨天添加的数据
@Query("DELETE FROM ${LineDataBean.tableName} WHERE line_get_time < :zeroTime")
fun deleteWeltData(zeroTime: Long = DateTimeUtil.getCurrentDateZero()): Int
//查询当天插入的所有数据
@Query("SELECT * FROM ${LineDataBean.tableName} WHERE line_get_time > :zeroTime and tenant_id = :tenantId and project_name = :projectName")
fun loadDataRx(zeroTime: Long = DateTimeUtil.getCurrentDateZero(),tenantId:Long,projectName:String): Observable<List<LineDataBean>?>
//查询当天插入的所有数据
@Query("SELECT * FROM ${LineDataBean.tableName} WHERE line_get_time > :zeroTime")
fun loadDataRx(zeroTime: Long = DateTimeUtil.getCurrentDateZero()): Observable<List<LineDataBean>?>
//查询当天插入的所有数据
@Query("SELECT * FROM ${LineDataBean.tableName} WHERE line_get_time > :zeroTime")
fun loadData(zeroTime: Long = DateTimeUtil.getCurrentDateZero()): List<LineDataBean>?
@Query("SELECT * FROM ${LineDataBean.tableName} WHERE line_get_time > :zeroTime and tenant_id = :tenantId and project_name = :projectName")
fun loadData(zeroTime: Long = DateTimeUtil.getCurrentDateZero(),tenantId:Long,projectName:String): List<LineDataBean>?
@Query("SELECT * FROM ${LineDataBean.tableName} WHERE line_id = :lineId")
fun queryByLineId(lineId: Int) : List<LineDataBean>?

View File

@@ -1,6 +1,8 @@
package com.mogo.och.offline.repository.db.repository
import androidx.room.Transaction
import com.mogo.commons.env.ProjectUtils
import com.mogo.och.common.module.biz.login.LoginStatusManager
import com.mogo.och.common.module.manager.logchainanalytic.OchChainLogManager
import com.mogo.och.common.module.manager.loop.BizLoopManager
import com.mogo.och.offline.repository.db.bean.LineDataBean
@@ -25,20 +27,11 @@ object LineDb: IDbRepository {
lineDao = null
}
fun cleanWeltData(){
lineDao?.deleteWeltData()
}
fun queryCanUserLine(): List<LineDataBean>? {
return lineDao?.loadData()
}
/**
* 读取可用线路
*/
fun queryCanUseLineRx(): Observable<List<LineDataBean>?>? {
return lineDao?.loadDataRx()
return lineDao?.loadDataRx(tenantId = LoginStatusManager.getLoginInfo()?.tenantId?:0L, projectName = ProjectUtils.getProjectType().value)
}
fun checkAndUpdate(serverDatalist:List<LineDataBean>){
@@ -47,7 +40,7 @@ object LineDb: IDbRepository {
override fun run() {
// 校验数据个数
lineDao?.let { lineDao->
val loadData = lineDao.loadData()
val loadData = lineDao.loadData(tenantId = LoginStatusManager.getLoginInfo()?.tenantId?:0L, projectName = ProjectUtils.getProjectType().value)
if(loadData.isNullOrEmpty()){
// 插入新的值
lineDao.insert(*serverDatalist.toTypedArray())
@@ -121,15 +114,5 @@ object LineDb: IDbRepository {
}
}
/**
* 没有线路就插入线路
*/
fun saveRunningInfo(lineId: Int, lineName: String?, endStationName: String?) {
val queryByLineId = lineDao?.queryByLineId(lineId)
if(queryByLineId.isNullOrEmpty()){
lineDao?.insert(LineDataBean(lineId = lineId.toLong(), lineName = lineName, endStationName = endStationName))
}
}
}

View File

@@ -1,7 +1,9 @@
package com.mogo.och.offline.repository.net.bean
import com.mogo.commons.env.ProjectUtils
import com.mogo.eagle.core.data.BaseData
import com.mogo.eagle.core.utilcode.util.GsonUtils
import com.mogo.och.common.module.biz.login.LoginStatusManager
import com.mogo.och.data.bean.SiteIntroduce
import com.mogo.och.offline.repository.db.bean.ContrailDataBean
import com.mogo.och.offline.repository.db.bean.LineDataBean
@@ -34,6 +36,8 @@ data class BindLineListResponse(val data: List<Result>?) : BaseData(){
tempLineInfo.lineId = lineInfo.lineId
tempLineInfo.lineName = lineInfo.lineName
tempLineInfo.endStationName = dataInfo.siteList?.last()?.name?:""
tempLineInfo.tenantId = LoginStatusManager.getLoginInfo()?.tenantId?:0
tempLineInfo.projectName = ProjectUtils.getProjectType().value
lineList.add(tempLineInfo)
}
dataInfo.contrail?.let { contrailInfo->