From 3486031e93853cf971080c874776986202d2801f Mon Sep 17 00:00:00 2001 From: yangyakun Date: Thu, 2 Jan 2025 10:46:26 +0800 Subject: [PATCH] =?UTF-8?q?[6.9.0]=20[fea]=20[offline]=20[=E7=BA=BF?= =?UTF-8?q?=E8=B7=AF=E8=A1=A8=E6=B7=BB=E5=8A=A0=E7=A7=9F=E6=88=B7id?= =?UTF-8?q?=E5=92=8C=E9=A1=B9=E7=9B=AE=E5=90=8D=E7=A7=B0]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../6.json | 18 ++++++++++--- .../repository/db/bean/LineDataBean.kt | 12 +++++++++ .../offline/repository/db/dao/LineDataDao.kt | 15 ++++------- .../repository/db/repository/LineDb.kt | 25 +++---------------- .../net/bean/BindLineListResponse.kt | 4 +++ 5 files changed, 40 insertions(+), 34 deletions(-) diff --git a/OCH/offline/driver/schemas/com.mogo.och.offline.repository.db.MyDataBase/6.json b/OCH/offline/driver/schemas/com.mogo.och.offline.repository.db.MyDataBase/6.json index 7324120203..19a29cd84b 100644 --- a/OCH/offline/driver/schemas/com.mogo.och.offline.repository.db.MyDataBase/6.json +++ b/OCH/offline/driver/schemas/com.mogo.och.offline.repository.db.MyDataBase/6.json @@ -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')" ] } } \ No newline at end of file diff --git a/OCH/offline/driver/src/main/java/com/mogo/och/offline/repository/db/bean/LineDataBean.kt b/OCH/offline/driver/src/main/java/com/mogo/och/offline/repository/db/bean/LineDataBean.kt index 1f59252f8e..e867eeec7f 100644 --- a/OCH/offline/driver/src/main/java/com/mogo/och/offline/repository/db/bean/LineDataBean.kt +++ b/OCH/offline/driver/src/main/java/com/mogo/och/offline/repository/db/bean/LineDataBean.kt @@ -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, + /** * 存储此条数据时时间戳 */ diff --git a/OCH/offline/driver/src/main/java/com/mogo/och/offline/repository/db/dao/LineDataDao.kt b/OCH/offline/driver/src/main/java/com/mogo/och/offline/repository/db/dao/LineDataDao.kt index 0b46bfd9a3..8e8104bc68 100644 --- a/OCH/offline/driver/src/main/java/com/mogo/och/offline/repository/db/dao/LineDataDao.kt +++ b/OCH/offline/driver/src/main/java/com/mogo/och/offline/repository/db/dao/LineDataDao.kt @@ -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?> //查询当天插入的所有数据 - @Query("SELECT * FROM ${LineDataBean.tableName} WHERE line_get_time > :zeroTime") - fun loadDataRx(zeroTime: Long = DateTimeUtil.getCurrentDateZero()): Observable?> - - //查询当天插入的所有数据 - @Query("SELECT * FROM ${LineDataBean.tableName} WHERE line_get_time > :zeroTime") - fun loadData(zeroTime: Long = DateTimeUtil.getCurrentDateZero()): List? + @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? @Query("SELECT * FROM ${LineDataBean.tableName} WHERE line_id = :lineId") fun queryByLineId(lineId: Int) : List? diff --git a/OCH/offline/driver/src/main/java/com/mogo/och/offline/repository/db/repository/LineDb.kt b/OCH/offline/driver/src/main/java/com/mogo/och/offline/repository/db/repository/LineDb.kt index 685ef182bd..10b10611a3 100644 --- a/OCH/offline/driver/src/main/java/com/mogo/och/offline/repository/db/repository/LineDb.kt +++ b/OCH/offline/driver/src/main/java/com/mogo/och/offline/repository/db/repository/LineDb.kt @@ -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? { - return lineDao?.loadData() - } - /** * 读取可用线路 */ fun queryCanUseLineRx(): Observable?>? { - return lineDao?.loadDataRx() + return lineDao?.loadDataRx(tenantId = LoginStatusManager.getLoginInfo()?.tenantId?:0L, projectName = ProjectUtils.getProjectType().value) } fun checkAndUpdate(serverDatalist:List){ @@ -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)) - } - } - } \ No newline at end of file diff --git a/OCH/offline/driver/src/main/java/com/mogo/och/offline/repository/net/bean/BindLineListResponse.kt b/OCH/offline/driver/src/main/java/com/mogo/och/offline/repository/net/bean/BindLineListResponse.kt index bac287186b..9d14fa97d1 100644 --- a/OCH/offline/driver/src/main/java/com/mogo/och/offline/repository/net/bean/BindLineListResponse.kt +++ b/OCH/offline/driver/src/main/java/com/mogo/och/offline/repository/net/bean/BindLineListResponse.kt @@ -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?) : 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->