fix: 处理科目二多一个表问题

This commit is contained in:
wangzhongjie 2025-09-18 16:58:10 +08:00
parent 80dd24fd64
commit 0ee2b76130

View File

@ -54,7 +54,6 @@ export function SqlInsertTable(tableName: string, data: Array<RecordType>, delFl
// 参数平台 // 参数平台
// TODO 后续废弃这个方法,直接调用SqlInsertTable // TODO 后续废弃这个方法,直接调用SqlInsertTable
// 依据数组和表名更新sql表 // 依据数组和表名更新sql表
export function UpdateTableByArray(tableName: string, arr: Array<RecordType>): Promise<boolean> { export function UpdateTableByArray(tableName: string, arr: Array<RecordType>): Promise<boolean> {
@ -142,34 +141,28 @@ export async function InitializeTheCentralTable(params: InitializeTheCentralTabl
const initPromises = tableKeys.map(async (key) => { const initPromises = tableKeys.map(async (key) => {
// 后端传递的字段首字母小写了,需要转换下 // 后端传递的字段首字母小写了,需要转换下
const newKey = key.charAt(0).toUpperCase() + key.slice(1); const newKey = key.charAt(0).toUpperCase() + key.slice(1);
// TODO 先忽略这张表
if (newKey !== "GunCameraInfo") {
const isExit = CenterMap.has(newKey); const isExit = CenterMap.has(newKey);
dConsole.log(InitTableTag, "-------------------表名-----------------------", newKey, isExit); dConsole.log(InitTableTag, "-------------------表名-----------------------", newKey, isExit);
if (!isExit) { if (!isExit) {
dConsole.error(InitTableTag, newKey, "表不存在") dConsole.error(InitTableTag, newKey, "表不存在")
return false return false
} }
dConsole.log(InitTableTag, "可以插入的表", newKey, CenterMap.get(newKey)); dConsole.log(InitTableTag, "可以插入的表", newKey, CenterMap.get(newKey));
let arrList: Array<RecordType> | RecordType = []; let arrList: Array<RecordType> | RecordType = [];
const value: PublicInfoType = Reflect.get(res.body, key); const value: PublicInfoType = Reflect.get(res.body, key);
arrList = value instanceof Array ? value : [value]; arrList = value instanceof Array ? value : [value];
const folderPath = await fileUtil.initFolder(`/config/tableList`); const folderPath = await fileUtil.initFolder(`/config/tableList`);
await fileUtil.addFile( await fileUtil.addFile(
`${folderPath}/${RemappingTableName.get(newKey)}.txt`, `${folderPath}/${RemappingTableName.get(newKey)}.txt`,
JSON.stringify(arrList) JSON.stringify(arrList)
); );
dConsole.log(InitTableTag, "插入表操作", newKey); dConsole.log(InitTableTag, "插入表操作", newKey);
dConsole.log(InitTableTag, "插入表别名", RemappingTableName.get(newKey)); dConsole.log(InitTableTag, "插入表别名", RemappingTableName.get(newKey));
dConsole.log(InitTableTag, "插入表长度", arrList.length); dConsole.log(InitTableTag, "插入表长度", arrList.length);
const result = await SqlInsertTable(RemappingTableName.get(newKey)!, arrList); const result = await SqlInsertTable(RemappingTableName.get(newKey)!, arrList);
dConsole.log(InitTableTag, "插入表结果,表", newKey, "结果", result); dConsole.log(InitTableTag, "插入表结果,表", newKey, "结果", result);
if (!result) { if (!result) {
dConsole.log(InitTableTag, "初始化失败", newKey) dConsole.log(InitTableTag, "初始化失败", newKey)
Prompt.showToast({ Prompt.showToast({
@ -177,9 +170,10 @@ export async function InitializeTheCentralTable(params: InitializeTheCentralTabl
}); });
return false; return false;
} }
dConsole.log(InitTableTag, "~~~~~~~~~~~~~~~~~~~~~~初始化成功~~~~~~~~~~~~~~~~~~~~~~", newKey); dConsole.log(InitTableTag, "~~~~~~~~~~~~~~~~~~~~~~初始化成功~~~~~~~~~~~~~~~~~~~~~~", newKey);
return true; return true;
}
return true
}); });
const results = await Promise.all(initPromises); const results = await Promise.all(initPromises);