From 0ee2b761303ca27dad38c68e662ae8721616cea4 Mon Sep 17 00:00:00 2001 From: wangzhongjie Date: Thu, 18 Sep 2025 16:58:10 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=A4=84=E7=90=86=E7=A7=91=E7=9B=AE?= =?UTF-8?q?=E4=BA=8C=E5=A4=9A=E4=B8=80=E4=B8=AA=E8=A1=A8=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entry/src/main/ets/utils/table/Operation.ets | 70 +++++++++----------- 1 file changed, 32 insertions(+), 38 deletions(-) diff --git a/entry/src/main/ets/utils/table/Operation.ets b/entry/src/main/ets/utils/table/Operation.ets index 90c8555..962e1ae 100644 --- a/entry/src/main/ets/utils/table/Operation.ets +++ b/entry/src/main/ets/utils/table/Operation.ets @@ -54,7 +54,6 @@ export function SqlInsertTable(tableName: string, data: Array, delFl // 参数平台 - // TODO 后续废弃这个方法,直接调用SqlInsertTable // 依据数组和表名更新sql表 export function UpdateTableByArray(tableName: string, arr: Array): Promise { @@ -142,44 +141,39 @@ export async function InitializeTheCentralTable(params: InitializeTheCentralTabl const initPromises = tableKeys.map(async (key) => { // 后端传递的字段首字母小写了,需要转换下 const newKey = key.charAt(0).toUpperCase() + key.slice(1); - const isExit = CenterMap.has(newKey); - - dConsole.log(InitTableTag, "-------------------表名-----------------------", newKey, isExit); - - if (!isExit) { - dConsole.error(InitTableTag, newKey, "表不存在") - return false + // TODO 先忽略这张表 + if (newKey !== "GunCameraInfo") { + const isExit = CenterMap.has(newKey); + dConsole.log(InitTableTag, "-------------------表名-----------------------", newKey, isExit); + if (!isExit) { + dConsole.error(InitTableTag, newKey, "表不存在") + return false + } + dConsole.log(InitTableTag, "可以插入的表", newKey, CenterMap.get(newKey)); + let arrList: Array | RecordType = []; + const value: PublicInfoType = Reflect.get(res.body, key); + arrList = value instanceof Array ? value : [value]; + const folderPath = await fileUtil.initFolder(`/config/tableList`); + await fileUtil.addFile( + `${folderPath}/${RemappingTableName.get(newKey)}.txt`, + JSON.stringify(arrList) + ); + dConsole.log(InitTableTag, "插入表操作", newKey); + dConsole.log(InitTableTag, "插入表别名", RemappingTableName.get(newKey)); + dConsole.log(InitTableTag, "插入表长度", arrList.length); + const result = await SqlInsertTable(RemappingTableName.get(newKey)!, arrList); + dConsole.log(InitTableTag, "插入表结果,表", newKey, "结果", result); + if (!result) { + dConsole.log(InitTableTag, "初始化失败", newKey) + Prompt.showToast({ + message: `初始化表 ${newKey} 失败` + }); + return false; + } + dConsole.log(InitTableTag, "~~~~~~~~~~~~~~~~~~~~~~初始化成功~~~~~~~~~~~~~~~~~~~~~~", newKey); + return true; } - - dConsole.log(InitTableTag, "可以插入的表", newKey, CenterMap.get(newKey)); - - let arrList: Array | RecordType = []; - const value: PublicInfoType = Reflect.get(res.body, key); - arrList = value instanceof Array ? value : [value]; - - const folderPath = await fileUtil.initFolder(`/config/tableList`); - await fileUtil.addFile( - `${folderPath}/${RemappingTableName.get(newKey)}.txt`, - JSON.stringify(arrList) - ); - - dConsole.log(InitTableTag, "插入表操作", newKey); - dConsole.log(InitTableTag, "插入表别名", RemappingTableName.get(newKey)); - dConsole.log(InitTableTag, "插入表长度", arrList.length); - - const result = await SqlInsertTable(RemappingTableName.get(newKey)!, arrList); - dConsole.log(InitTableTag, "插入表结果,表", newKey, "结果", result); - - if (!result) { - dConsole.log(InitTableTag, "初始化失败", newKey) - Prompt.showToast({ - message: `初始化表 ${newKey} 失败` - }); - return false; - } - - dConsole.log(InitTableTag, "~~~~~~~~~~~~~~~~~~~~~~初始化成功~~~~~~~~~~~~~~~~~~~~~~", newKey); - return true; + return true }); const results = await Promise.all(initPromises);