fix: 处理科目二多一个表问题
This commit is contained in:
parent
80dd24fd64
commit
0ee2b76130
@ -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,44 +141,39 @@ 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);
|
||||||
const isExit = CenterMap.has(newKey);
|
// TODO 先忽略这张表
|
||||||
|
if (newKey !== "GunCameraInfo") {
|
||||||
dConsole.log(InitTableTag, "-------------------表名-----------------------", newKey, isExit);
|
const isExit = CenterMap.has(newKey);
|
||||||
|
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));
|
||||||
|
let arrList: Array<RecordType> | 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
|
||||||
dConsole.log(InitTableTag, "可以插入的表", newKey, CenterMap.get(newKey));
|
|
||||||
|
|
||||||
let arrList: Array<RecordType> | 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;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const results = await Promise.all(initPromises);
|
const results = await Promise.all(initPromises);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user