// @ts-nocheck import promptAction from '@ohos.promptAction' import router from '@ohos.router' import { dateFormat} from '../utils/tools' import FileUtil from '../../common/utils/File' import AccountTable from '../../common/database/tables/AccountTable'; import MA_SYSSET from '../../common/constants/MA_SYSSET'; import { getDataBaseTable, upDateTable, getMySystemSetTable, delSyncTable, upDataZhongxinginitialization } from '../../common/service/initable' import configAddress from '../../common/utils/FileConfig' //配置流水号 export async function setliushuiNum(context){ const fileUtil = new FileUtil(context) let res = fs.accessSync(configAddress.comoonfileWriteAddress+'/config/liushui.txt'); const fileData = await fileUtil.readFile(configAddress.comoonfileWriteAddress+'/config/liushui.txt'); if(res&&JSON.stringify(fileData).indexOf('u0000')<0) { const date = new Date() const time1 = JSON.parse(fileData).date.split(' ')[0] const time2 = dateFormat(date).split(' ')[0] if (time1 == time2) { const date = new Date() const param = { date: dateFormat(date), value: Number(JSON.parse(fileData).value) + 1 } const folderPath = await fileUtil.initFolder(`/config`); fileUtil.addFile(`${folderPath}/liushui.txt`, JSON.stringify(param)) return } } const date = new Date() const param = { date: dateFormat(date), value: 0 } const folderPath = await fileUtil.initFolder(`/config`); fileUtil.addFile(`${folderPath}/liushui.txt`, JSON.stringify(param)) } //双中心表 export async function getDoubleCeneterTable() { return new Promise(async (reslove,reject)=>{ // MA_SYSSET双中心下做合并表格操作 const db = new AccountTable(() => { }, MA_SYSSET); db.getRdbStore(() => { db.query('0', async (array) => { if (array.length) { delSyncTable('MA_SYSSET').then(async () => { await getDataBaseTable({ tableName: 'MA_SYSSET' }) await getMySystemSetTable({ tableName: 'MA_SYSSET' }) }) } else { await getDataBaseTable({ tableName: 'MA_SYSSET' }) await getMySystemSetTable({ tableName: 'MA_SYSSET' }) } }) }) const typeObj = { 'MA_MARKRULE': false, 'MA_SYSTEMPARM': false, 'MA_MAP_COLLECT': false, 'MA_MAP_COLLECT_SHAPE': false, 'MA_MAP_ITEMCLASS': false, 'MA_MAP_POINT': false, 'MA_MAP_POINT_ITEM': false, 'MA_MAP_ROAD': false, 'MA_MAP_ROAD_LANE': false, 'MA_MAP_SUBITEM': false, 'ES_CARINFO': false, 'ES_EXAMPOINTDETAIL': false, 'MA_MARKRULESET': false, 'ES_CAR_VIDEO_PARAMETER': false, 'MA_CDSBINFO': false, 'MA_ITEMINFO': false, 'MA_T_CARPARMSET': false } for(let key in typeObj){ typeObj[key] = await upDateTable({ tableName: key }) if (!typeObj[key]) { promptAction.showToast({ message: `未能查询到${key}表数据, 请先检查网络是否连接正常`, duration: 3000 }); reslove(false) return } } reslove(true) router.pushUrl({ url: 'pages/ExaminerLogin', }, router.RouterMode.Single); }) } //单中心存表 export async function getSingleCenterTable() { return new Promise((reslove,reject)=>{ upDataZhongxinginitialization().then((flag)=>{ if(flag){ router.pushUrl({ url: 'pages/ExaminerLogin', }, router.RouterMode.Single) reslove(true) }else{ // router.pushUrl({ // url: 'pages/ExaminerLogin', // }, router.RouterMode.Single) // reslove(true) promptAction.showToast({ message: '联网更新失败,请检查网络后重新更新', duration: 1000 }); reslove(false) } }).catch((error)=>{ console.log(error) }) }) }