diff --git a/commons/basic/src/main/ets/utils/PatientsEntity.ets b/commons/basic/src/main/ets/utils/PatientsEntity.ets index 5513c84..17f5551 100644 --- a/commons/basic/src/main/ets/utils/PatientsEntity.ets +++ b/commons/basic/src/main/ets/utils/PatientsEntity.ets @@ -300,6 +300,24 @@ export class PatientDao { } } + async getPatientTypeByUuid(uuid: string): Promise { + this.checkDatabaseState(); + if (!this.rdbStore) { + throw new Error('数据库连接为空'); + } + const sql = 'SELECT type FROM patients WHERE LOWER(uuid) = LOWER(?)'; + const resultSet = await this.rdbStore.querySql(sql, [uuid]); + if (resultSet.rowCount > 0) { + resultSet.goToFirstRow(); + const typeIndex = resultSet.getColumnIndex('type'); + const type = typeIndex >= 0 ? resultSet.getDouble(typeIndex) : null; + resultSet.close(); + return type; + } + resultSet.close(); + return null; + } + // 删除指定专家的所有患者数据 async deletePatientsByExpertUuid(expertUuid: string): Promise { try { @@ -855,6 +873,16 @@ export class PatientDatabaseManager { async addPatient(patient: PatientData): Promise { return await this.addPatients(patient); } + + // 在 PatientDatabaseManager 类内添加 + async getPatientTypeByUuid(uuid: string): Promise { + if (!this.isDatabaseReady()) { + console.error('数据库未准备好,无法获取患者type'); + return null; + } + return await this.getPatientDao().getPatientTypeByUuid(uuid); + } + } // 导出单例实例 diff --git a/localconversationkit_ui/src/main/ets/viewmodel/LocalConversationViewModel.ets b/localconversationkit_ui/src/main/ets/viewmodel/LocalConversationViewModel.ets index 0a2d67a..1ea1757 100644 --- a/localconversationkit_ui/src/main/ets/viewmodel/LocalConversationViewModel.ets +++ b/localconversationkit_ui/src/main/ets/viewmodel/LocalConversationViewModel.ets @@ -236,21 +236,31 @@ export class LocalConversationViewModel { } this.offset = result.offset this.isFinished = result.finished - let newConversation = result.conversationList - if (this.conversationList.length > 0 && newConversation.length > 0) { - this.conversationList = - this.conversationList.filter(conversation => !newConversation.find((m) => m.conversationId === - conversation.conversationId)) - } - this.conversationList?.push(...newConversation) + // let newConversation = result.conversationList + // if (this.conversationList.length > 0 && newConversation.length > 0) { + // this.conversationList = + // this.conversationList.filter(conversation => !newConversation.find((m) => m.conversationId === + // conversation.conversationId)) + // } + // this.conversationList?.push(...newConversation) //异步有问题 - if (this.conversationList.length > 0 ) { - const resultconversationList =await this.conversationList.filter(async conversation => - await patientDbManager.getPatientByUuid(ChatKitClient.nim.conversationIdUtil.parseConversationTargetId(conversation.conversationId))!=null - ) - this.conversationList =resultconversationList; - + // if (this.conversationList.length > 0 ) { + // const resultconversationList =await this.conversationList.filter(async conversation => + // await patientDbManager.getPatientByUuid(ChatKitClient.nim.conversationIdUtil.parseConversationTargetId(conversation.conversationId))!=null + // ) + // this.conversationList =resultconversationList; + // + // } + const filteredConversations: V2NIMLocalConversation[] = []; + for (const conversation of result.conversationList) { + const uuid = ChatKitClient.nim.conversationIdUtil.parseConversationTargetId(conversation.conversationId); + // 假设 selectUserStyleWithModel 返回 "1" 表示 type=1 + const style = await patientDbManager.getPatientTypeByUuid(uuid); + if (style == 1) { + filteredConversations.push(conversation); + } } + this.conversationList = filteredConversations; this.conversationList?.sort((a, b) => this.sortConversation(a, b)) this.isFinishedSyncLoad = true