2024-01-05 11:11:15 +08:00
|
|
|
// @ts-nocheck
|
|
|
|
|
import common from '@ohos.app.ability.common';
|
|
|
|
|
import router from '@ohos.router'
|
|
|
|
|
import { getCarInfo, getDeviceInfo } from '../common/service/terminalService'
|
|
|
|
|
import { setCurrentTime } from '../common/service/timeService'
|
2024-01-31 14:35:16 +08:00
|
|
|
import { string2Bytes } from '../common/utils/tools'
|
2024-01-05 11:11:15 +08:00
|
|
|
import {
|
|
|
|
|
getDataBaseTable,
|
|
|
|
|
upDateTable,
|
|
|
|
|
getMySystemSetTable,
|
|
|
|
|
getSyncData,
|
|
|
|
|
delSyncTable,
|
|
|
|
|
getEsCarModel,
|
|
|
|
|
upDataZhongxinginitialization
|
|
|
|
|
} from '../common/service/initable'
|
|
|
|
|
import prompt from '@ohos.prompt'
|
|
|
|
|
import { dateFormat } from '../common/utils/tools'
|
|
|
|
|
import AccountTable from '../common/database/tables/AccountTable';
|
|
|
|
|
import MA_SYSSET from '../common/constants/MA_SYSSET';
|
|
|
|
|
import { getUDP, getUDP2 } from '../common/utils/GlobleUdp'
|
|
|
|
|
import {initJudgeUdp} from '../common/utils/UdpJudge'
|
|
|
|
|
import fs from '@ohos.file.fs'
|
|
|
|
|
import FileUtil from '../common/utils/File'
|
|
|
|
|
@Entry
|
|
|
|
|
@Component
|
|
|
|
|
struct Index {
|
|
|
|
|
@State carNum: string = ''
|
|
|
|
|
@State version: string = ''
|
|
|
|
|
@State url: string = ''
|
|
|
|
|
@State hasAuth: boolean = false;
|
|
|
|
|
@State isSingle: boolean = false;
|
|
|
|
|
@State deviceId: string = '';
|
|
|
|
|
private vocObj = null;
|
|
|
|
|
@State angle: number = 0
|
|
|
|
|
@State ratio: number = 850 / 960
|
|
|
|
|
@State loading: boolean = true
|
|
|
|
|
@State devPath: string = "/dev/ttyS0"
|
|
|
|
|
@State fd: number = -1;
|
|
|
|
|
private context = getContext(this) as common.UIAbilityContext;
|
|
|
|
|
build() {
|
|
|
|
|
Column() {
|
|
|
|
|
Column() {
|
|
|
|
|
Row() {
|
|
|
|
|
Image($r('app.media.logo')).width('30%').height('5.5%').margin({ left: 24 })
|
|
|
|
|
Row() {
|
|
|
|
|
Image($r('app.media.btn_setting')).width('16.7%').height('12.2%')
|
|
|
|
|
.onClick(async () => {
|
|
|
|
|
if (this.loading) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// this.url = 'pages/Settings'
|
|
|
|
|
router.pushUrl({
|
|
|
|
|
url: 'pages/Settings',
|
|
|
|
|
}, router.RouterMode.Single);
|
|
|
|
|
})
|
|
|
|
|
Image($r('app.media.btn_back')).width('14.4%').height('12.2%')
|
|
|
|
|
.onClick(() => {
|
|
|
|
|
if (this.loading) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
// getSyncData('MA_SYSSET')
|
|
|
|
|
router.back()
|
|
|
|
|
// this.url = 'back'
|
|
|
|
|
// app.terminate()
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
.width('100%')
|
|
|
|
|
.justifyContent(FlexAlign.SpaceBetween)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Column() {
|
|
|
|
|
Row() {
|
|
|
|
|
if (!this.isSingle) {
|
|
|
|
|
Image($r('app.media.index_lw')).width('30.5%').height('74%').onClick(() => {
|
|
|
|
|
if (this.loading) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
const that = this
|
|
|
|
|
this.loading = true
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
that.angle = 360
|
|
|
|
|
}, 1000)
|
|
|
|
|
that.angle = 0
|
2024-01-31 14:35:16 +08:00
|
|
|
// this.getCenterDataTable()
|
|
|
|
|
if(globalThis.timeInfo.mode=='3'){
|
|
|
|
|
this.upDateTable()
|
|
|
|
|
}else{
|
|
|
|
|
this.getCenterDataTable()
|
|
|
|
|
}
|
2024-01-05 11:11:15 +08:00
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
if (this.isSingle) {
|
|
|
|
|
Image($r('app.media.index_dj')).width('30.5%').height('74%').onClick(() => {
|
|
|
|
|
if (this.loading) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
router.pushUrl({
|
|
|
|
|
url: 'pages/userInfo',
|
|
|
|
|
}, router.RouterMode.Single);
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
Image($r('app.media.index_zj')).width('30.5%').height('74%').onClick(() => {
|
|
|
|
|
if (this.loading) {
|
|
|
|
|
return
|
|
|
|
|
}
|
2024-01-31 14:35:16 +08:00
|
|
|
// globalThis.singlePlay = !globalThis.singlePlay
|
|
|
|
|
// this.isSingle = globalThis.singlePlay
|
|
|
|
|
// return
|
2024-01-05 11:11:15 +08:00
|
|
|
router.pushUrl({
|
|
|
|
|
url: 'pages/carCheck'
|
|
|
|
|
}, router.RouterMode.Single);
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
.width('100%')
|
|
|
|
|
.justifyContent(FlexAlign.SpaceAround)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Column() {
|
|
|
|
|
Row() {
|
|
|
|
|
Column() {
|
|
|
|
|
Text('V ' + globalThis.version)
|
|
|
|
|
.fontColor('#CCAE7A')
|
|
|
|
|
.fontSize(22 * this.ratio)
|
|
|
|
|
.width('30%')
|
|
|
|
|
.margin({ bottom: 10 })
|
|
|
|
|
Text('授权信息:' + (this.hasAuth ? '已授权' : '未授权'))
|
|
|
|
|
.fontColor('#CCAE7A')
|
|
|
|
|
.fontSize(22 * this.ratio)
|
|
|
|
|
.width('30%')
|
|
|
|
|
}
|
|
|
|
|
.margin({ left: 24 })
|
|
|
|
|
.gesture(
|
|
|
|
|
GestureGroup(GestureMode.Exclusive,
|
2024-01-31 14:35:16 +08:00
|
|
|
TapGesture({ count: 2 })
|
2024-01-05 11:11:15 +08:00
|
|
|
.onAction(() => {
|
|
|
|
|
globalThis.singlePlay = !globalThis.singlePlay
|
|
|
|
|
this.isSingle = globalThis.singlePlay
|
|
|
|
|
})
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
Text('考车号:' + this.deviceId).fontColor('#CCAE7A').fontSize(22 * this.ratio).margin({ right: 24 })
|
|
|
|
|
}
|
|
|
|
|
.width('100%')
|
|
|
|
|
.justifyContent(FlexAlign.SpaceBetween)
|
|
|
|
|
.margin({ bottom: 10 })
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (this.loading) {
|
|
|
|
|
Column() {
|
|
|
|
|
Image($r('app.media.open_loading'))
|
|
|
|
|
.width(200 * this.ratio)
|
|
|
|
|
.rotate({ angle: this.angle })
|
|
|
|
|
.height(200 * this.ratio)
|
|
|
|
|
.animation({
|
|
|
|
|
duration: 5000, // 动画时长
|
|
|
|
|
curve: Curve.EaseOut, // 动画曲线
|
|
|
|
|
delay: 500, // 动画延迟
|
|
|
|
|
iterations: -1, // 播放次数
|
|
|
|
|
playMode: PlayMode.Normal, // 动画模式
|
|
|
|
|
})
|
|
|
|
|
.margin({ top: 30 * this.ratio })
|
|
|
|
|
Image($r('app.media.car'))
|
|
|
|
|
.width(80 * this.ratio)
|
|
|
|
|
.height(80 * this.ratio)
|
|
|
|
|
.position({ x: 288 * this.ratio, y: 89 * this.ratio })
|
|
|
|
|
Text('获取考车信息,请稍候……').fontSize(24 * this.ratio).margin({ top: 20 * this.ratio }).fontWeight(400)
|
|
|
|
|
}
|
|
|
|
|
.width(660 * this.ratio)
|
|
|
|
|
.height(360 * this.ratio)
|
|
|
|
|
.position({ x: 150 * this.ratio, y: 98 * this.ratio })
|
|
|
|
|
.backgroundColor('#E6E3DF')
|
|
|
|
|
.borderRadius(19 * this.ratio)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
.width('100%')
|
|
|
|
|
.height('100%')
|
|
|
|
|
.justifyContent(FlexAlign.SpaceBetween)
|
|
|
|
|
.backgroundImagePosition({ x: 0, y: 0 })
|
|
|
|
|
.backgroundImage($r('app.media.index_bg'))
|
|
|
|
|
.backgroundImageSize({ width: '100%', height: '100%' })
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
aboutToAppear() {
|
|
|
|
|
this.angle = 0
|
|
|
|
|
this.loading = false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async heartMsg(context) {
|
|
|
|
|
const fileUtil = new FileUtil(context)
|
2024-01-31 14:35:16 +08:00
|
|
|
const fileData = await fileUtil.readFile('/mnt/hmdfs/100/account/device_view/localfiles/files/config/liushui.txt');
|
|
|
|
|
let res = fs.accessSync('/mnt/hmdfs/100/account/device_view/localfiles/files/config/liushui.txt');
|
|
|
|
|
if(res&&JSON.stringify(fileData).indexOf('u0000')<0){
|
2024-01-05 11:11:15 +08:00
|
|
|
const date = new Date()
|
2024-01-31 14:35:16 +08:00
|
|
|
const time1 = JSON.parse(fileData).date.split(' ')[0]
|
2024-01-05 11:11:15 +08:00
|
|
|
const time2 = dateFormat(date).split(' ')[0]
|
|
|
|
|
if (time1 == time2) {
|
|
|
|
|
const date = new Date()
|
|
|
|
|
const param = {
|
|
|
|
|
date: dateFormat(date),
|
2024-01-31 14:35:16 +08:00
|
|
|
value: Number(JSON.parse(fileData).value) + 1
|
2024-01-05 11:11:15 +08:00
|
|
|
}
|
|
|
|
|
const folderPath = await fileUtil.initFolder(`/config`);
|
|
|
|
|
fileUtil.addFile(`${folderPath}/liushui.txt`, JSON.stringify(param))
|
|
|
|
|
} else {
|
|
|
|
|
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))
|
|
|
|
|
}
|
2024-01-31 14:35:16 +08:00
|
|
|
}else{
|
2024-01-05 11:11:15 +08:00
|
|
|
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))
|
|
|
|
|
}
|
|
|
|
|
const arr = [globalThis.signNum||0, globalThis.statue||1]
|
|
|
|
|
let tmpList = [];
|
2024-01-31 14:35:16 +08:00
|
|
|
tmpList.push(string2Bytes(arr[0], 1 * 8)[0])
|
|
|
|
|
tmpList.push(string2Bytes(arr[1], 1 * 8)[0])
|
2024-01-05 11:11:15 +08:00
|
|
|
const str =globalThis.lsh|| '0000000000000'
|
|
|
|
|
for (let i = 0;i < str.length; i++) {
|
2024-01-31 14:35:16 +08:00
|
|
|
tmpList.push(string2Bytes(str.charCodeAt(i), 1 * 8)[0])
|
2024-01-05 11:11:15 +08:00
|
|
|
}
|
|
|
|
|
const param= {id: 31,list:tmpList,carNo: globalThis.carInfo.carNo,placeId: globalThis.carInfo.examinationRoomId}
|
|
|
|
|
globalThis.udpClient2.sendMsg(param, this.context)
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
onPageShow() {
|
|
|
|
|
this.loading = false
|
|
|
|
|
this.initParams()
|
|
|
|
|
getUDP()
|
|
|
|
|
getUDP2()
|
|
|
|
|
|
|
|
|
|
setInterval(() => {
|
|
|
|
|
this.heartMsg(this.context)
|
|
|
|
|
}, 1000)
|
|
|
|
|
|
|
|
|
|
if (globalThis.singlePlay == undefined || globalThis.singlePlay == null) {
|
|
|
|
|
globalThis.singlePlay = false
|
|
|
|
|
}
|
|
|
|
|
this.isSingle = globalThis.singlePlay
|
|
|
|
|
|
|
|
|
|
console.info('Index onPageShow');
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async initParams() {
|
|
|
|
|
this.loading=false
|
|
|
|
|
await getDeviceInfo()
|
|
|
|
|
// await this.getDeviceId()
|
|
|
|
|
await setCurrentTime();
|
|
|
|
|
await getCarInfo();
|
|
|
|
|
this.carNum = globalThis.carInfo.plateNo;
|
|
|
|
|
this.version = globalThis.version;
|
|
|
|
|
this.hasAuth = globalThis.hasAuth;
|
2024-01-31 14:35:16 +08:00
|
|
|
initJudgeUdp()
|
2024-01-05 11:11:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getDeviceId() {
|
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
|
getSyncData('DeviceInfoTable').then((result: Array<any>) => {
|
|
|
|
|
if (result.length) {
|
|
|
|
|
globalThis.deviceNo = result[0].deviceId
|
|
|
|
|
this.deviceId = result[0].deviceId
|
|
|
|
|
resolve(result[0].deviceId)
|
|
|
|
|
} else {
|
|
|
|
|
resolve('')
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async getModel() {
|
|
|
|
|
const context = this.context;
|
|
|
|
|
//下载模型
|
|
|
|
|
await getEsCarModel(context)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async getCenterDataTable() {
|
2024-01-31 14:35:16 +08:00
|
|
|
const flag= await upDataZhongxinginitialization()
|
2024-01-05 11:11:15 +08:00
|
|
|
this.loading = false
|
2024-01-31 14:35:16 +08:00
|
|
|
if(flag){
|
|
|
|
|
router.pushUrl({
|
|
|
|
|
url: 'pages/ExaminerLogin',
|
|
|
|
|
}, router.RouterMode.Single)
|
|
|
|
|
}else{
|
|
|
|
|
prompt.showToast({
|
|
|
|
|
message: '联网更新失败,请检查网络后重新更新',
|
|
|
|
|
duration: 1000
|
|
|
|
|
});
|
|
|
|
|
}
|
2024-01-05 11:11:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async upDateTable() {
|
2024-01-31 14:35:16 +08:00
|
|
|
// return
|
|
|
|
|
const db = new AccountTable(() => {
|
2024-01-05 11:11:15 +08:00
|
|
|
}, MA_SYSSET);
|
|
|
|
|
db.getRdbStore(() => {
|
|
|
|
|
db.query('0', async (array) => {
|
|
|
|
|
if (array.length) {
|
|
|
|
|
delSyncTable('MA_SYSSET').then(() => {
|
|
|
|
|
// getSyncData('MA_SYSSET')
|
2024-01-31 14:35:16 +08:00
|
|
|
getDataBaseTable({ tableName: 'MA_SYSSET' })
|
2024-01-05 11:11:15 +08:00
|
|
|
})
|
|
|
|
|
} else {
|
|
|
|
|
await getDataBaseTable({ tableName: 'MA_SYSSET' })
|
|
|
|
|
}
|
|
|
|
|
// console.log(markRuleParams)
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
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
|
|
|
|
|
}
|
|
|
|
|
typeObj.MA_MARKRULE = await upDateTable({ tableName: 'MA_MARKRULE' })
|
|
|
|
|
typeObj.MA_SYSTEMPARM = await upDateTable({ tableName: 'MA_SYSTEMPARM' })
|
|
|
|
|
typeObj.MA_MAP_COLLECT = await upDateTable({ tableName: 'MA_MAP_COLLECT' })
|
|
|
|
|
typeObj.MA_MAP_COLLECT_SHAPE = await upDateTable({ tableName: 'MA_MAP_COLLECT_SHAPE' })
|
|
|
|
|
typeObj.MA_MAP_ITEMCLASS = await upDateTable({ tableName: 'MA_MAP_ITEMCLASS' })
|
|
|
|
|
typeObj.MA_MAP_POINT = await upDateTable({ tableName: 'MA_MAP_POINT' })
|
|
|
|
|
typeObj.MA_MAP_POINT_ITEM = await upDateTable({ tableName: 'MA_MAP_POINT_ITEM' })
|
|
|
|
|
typeObj.MA_MAP_ROAD = await upDateTable({ tableName: 'MA_MAP_ROAD' })
|
|
|
|
|
typeObj.MA_MAP_ROAD_LANE = await upDateTable({ tableName: 'MA_MAP_ROAD_LANE' })
|
|
|
|
|
typeObj.MA_MAP_SUBITEM = await upDateTable({ tableName: 'MA_MAP_SUBITEM' })
|
|
|
|
|
typeObj.ES_CARINFO = await upDateTable({ tableName: 'ES_CARINFO' })
|
|
|
|
|
typeObj.ES_EXAMPOINTDETAIL = await upDateTable({ tableName: 'ES_EXAMPOINTDETAIL' })
|
|
|
|
|
typeObj.MA_MARKRULESET = await upDateTable({ tableName: 'MA_MARKRULESET' })
|
|
|
|
|
typeObj.ES_CAR_VIDEO_PARAMETER = await upDateTable({ tableName: 'ES_CAR_VIDEO_PARAMETER' })
|
|
|
|
|
typeObj.MA_CDSBINFO = await upDateTable({ tableName: 'MA_CDSBINFO' })
|
|
|
|
|
typeObj.MA_ITEMINFO = await upDateTable({ tableName: 'MA_ITEMINFO' })
|
|
|
|
|
typeObj.MA_T_CARPARMSET = await upDateTable({ tableName: 'MA_T_CARPARMSET' })
|
|
|
|
|
for (let key in typeObj) {
|
|
|
|
|
if (!typeObj[key]) {
|
|
|
|
|
this.loading = false
|
|
|
|
|
prompt.showToast({
|
|
|
|
|
message: `未能查询到${key}表数据, 请先检查网络是否连接正常`,
|
|
|
|
|
duration: 3000
|
|
|
|
|
});
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
this.loading = false
|
|
|
|
|
router.pushUrl({
|
|
|
|
|
url: 'pages/ExaminerLogin',
|
|
|
|
|
}, router.RouterMode.Single);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|