fix: 补充初始化代码
This commit is contained in:
parent
84bf4184e3
commit
637e41248c
@ -46,4 +46,7 @@ export const CommonFileTag = '[CommonFile]';
|
|||||||
export const HomeTag = '[Home]';
|
export const HomeTag = '[Home]';
|
||||||
|
|
||||||
//judge
|
//judge
|
||||||
export const JudgeTag = '[Judge]';
|
export const JudgeTag = '[Judge]';
|
||||||
|
|
||||||
|
//初始化表
|
||||||
|
export const InitTableTag = '[InitTable]';
|
||||||
@ -1,7 +1,7 @@
|
|||||||
import common from '@ohos.app.ability.common';
|
import common from '@ohos.app.ability.common';
|
||||||
import router from '@ohos.router';
|
import router from '@ohos.router';
|
||||||
|
|
||||||
import { HomeTag, JudgeConfig } from '../config';
|
import { HomeTag, InitTableTag, JudgeConfig } from '../config';
|
||||||
import VoiceAnnounce from './judgeSDK/utils/voiceAnnouncements';
|
import VoiceAnnounce from './judgeSDK/utils/voiceAnnouncements';
|
||||||
import { BaseInfoType } from '../model/Common';
|
import { BaseInfoType } from '../model/Common';
|
||||||
import { CarInfoType, InitializeTheCentralTableType, MASYSSETTableType, TimeSynchronizationRspBody } from '../model';
|
import { CarInfoType, InitializeTheCentralTableType, MASYSSETTableType, TimeSynchronizationRspBody } from '../model';
|
||||||
@ -147,6 +147,7 @@ struct Index {
|
|||||||
singlePlay: this.singlePlay
|
singlePlay: this.singlePlay
|
||||||
}
|
}
|
||||||
InitializeTheCentralTable(param).then((ret) => {
|
InitializeTheCentralTable(param).then((ret) => {
|
||||||
|
dConsole.log(InitTableTag, "初始化表成功", ret)
|
||||||
if (ret) {
|
if (ret) {
|
||||||
GetSyncData<MASYSSETTableType>("MA_SYSSET").then(data => {
|
GetSyncData<MASYSSETTableType>("MA_SYSSET").then(data => {
|
||||||
data.forEach(sys => {
|
data.forEach(sys => {
|
||||||
|
|||||||
@ -279,9 +279,15 @@ export async function UseAuth(context: common.UIAbilityContext): Promise<boolean
|
|||||||
if (grantStatus.every(status => status === 0)) {
|
if (grantStatus.every(status => status === 0)) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
Prompt.showToast({
|
||||||
|
message: "部分权限未授权,请全部授权,否则无法正常使用",
|
||||||
|
})
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
Prompt.showToast({
|
||||||
|
message: "授权出错,请联系开发者或检查权限设置",
|
||||||
|
})
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -5,8 +5,9 @@ import { BusinessError } from '@ohos.base';
|
|||||||
import Prompt from '@system.prompt';
|
import Prompt from '@system.prompt';
|
||||||
import { initialization } from '../../api';
|
import { initialization } from '../../api';
|
||||||
|
|
||||||
import { GlobalConfig } from '../../config';
|
import { GlobalConfig, InitTableTag } from '../../config';
|
||||||
import FileUtils from '../FileUtils';
|
import FileUtils from '../FileUtils';
|
||||||
|
import { dConsole } from '../LogWorker';
|
||||||
|
|
||||||
// 建表操作
|
// 建表操作
|
||||||
export async function InitTable() {
|
export async function InitTable() {
|
||||||
@ -137,7 +138,7 @@ export async function InitializeTheCentralTable(params: InitializeTheCentralTabl
|
|||||||
// 后端传递的字段首字母小写了,需要转换下
|
// 后端传递的字段首字母小写了,需要转换下
|
||||||
let newKey = key.charAt(0).toUpperCase() + key.slice(1)
|
let newKey = key.charAt(0).toUpperCase() + key.slice(1)
|
||||||
let isExit = CenterMap.has(newKey)
|
let isExit = CenterMap.has(newKey)
|
||||||
console.log("-------------------表名-----------------------", newKey, isExit)
|
console.log(InitTableTag, "-------------------表名-----------------------", newKey, isExit)
|
||||||
if (isExit) {
|
if (isExit) {
|
||||||
console.log("可以插入的表", newKey, CenterMap.get(newKey))
|
console.log("可以插入的表", newKey, CenterMap.get(newKey))
|
||||||
let arrList: Array<RecordType> | RecordType = []
|
let arrList: Array<RecordType> | RecordType = []
|
||||||
@ -150,18 +151,20 @@ export async function InitializeTheCentralTable(params: InitializeTheCentralTabl
|
|||||||
const folderPath = await fileUtil.initFolder(`/config/tableList`);
|
const folderPath = await fileUtil.initFolder(`/config/tableList`);
|
||||||
fileUtil.addFile(`${folderPath}/${RemappingTableName.get(newKey)}.txt`, JSON.stringify(arrList))
|
fileUtil.addFile(`${folderPath}/${RemappingTableName.get(newKey)}.txt`, JSON.stringify(arrList))
|
||||||
try {
|
try {
|
||||||
console.log("插入表操作", newKey)
|
console.log(InitTableTag, "插入表操作", newKey)
|
||||||
console.log("插入表别名", RemappingTableName.get(newKey))
|
console.log(InitTableTag, "插入表别名", RemappingTableName.get(newKey))
|
||||||
console.log("插入表长度", arrList.length)
|
console.log(InitTableTag, "插入表长度", arrList.length)
|
||||||
const result = await SqlInsertTable(RemappingTableName.get(newKey)!, arrList);
|
const result = await SqlInsertTable(RemappingTableName.get(newKey)!, arrList);
|
||||||
console.log("插入表结果,表", newKey, "结果", result)
|
console.log(InitTableTag, "插入表结果,表", newKey, "结果", result)
|
||||||
if (!result) {
|
if (!result) {
|
||||||
Prompt.showToast({
|
Prompt.showToast({
|
||||||
message: '初始化数据库失败'
|
message: '初始化数据库失败'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
console.log(InitTableTag, "~~~~~~~~~~~~~~~~~~~~~~初始化成功~~~~~~~~~~~~~~~~~~~~~~", newKey)
|
||||||
resolve(result)
|
resolve(result)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
dConsole.error(InitTableTag, "初始化表失败", JSON.stringify(e))
|
||||||
reject(e)
|
reject(e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user