diff --git a/entry/src/main/ets/common/service/timeService.ts b/entry/src/main/ets/common/service/timeService.ts index 3f1f9b43..e77540ce 100644 --- a/entry/src/main/ets/common/service/timeService.ts +++ b/entry/src/main/ets/common/service/timeService.ts @@ -1,21 +1,26 @@ import systemTime from '@ohos.systemTime'; import { timeSynchronization } from '../../api/index' -import { dateFormat,dateVersionFormat } from '../utils/tools'; +import { dateFormat, dateVersionFormat } from '../utils/tools'; //同步时时间 export async function timeSynchronize() { let date = new Date(); - console.info('jiangsong1:timeSynchronization begin ' ); + console.info('jiangsong1:timeSynchronization begin '); - let params = { time: dateFormat(date), deviceNo: globalThis.deviceNo,version:globalThis.version,judgeVersion:globalThis.judgeVersion} - let res:any = await timeSynchronization(params) + let params = { + time: dateFormat(date), + deviceNo: globalThis.deviceNo, + version: globalThis.version, + judgeVersion: globalThis.judgeVersion + } + let res: any = await timeSynchronization(params) res = res.timeSynchronizationRsp; - globalThis.timeInfo=res.body - console.log('timeInfo',JSON.stringify(res.body)) + globalThis.timeInfo = res.body + console.log('timeInfo', JSON.stringify(res.body)) return res; } -export async function setCurrentTime():Promise { +export async function setCurrentTime(): Promise { let res = await timeSynchronize(); let currentTime = res.head.time; let times = new Date(currentTime).getTime(); @@ -27,13 +32,13 @@ export async function setCurrentTime():Promise { // }).catch((error) => { // console.info(`Failed to set time. message: ${error.message}, code: ${error.code}`); // }); - } catch(e) { + } catch (e) { console.info(`Failed to set time. message: ${e.message}, code: ${e.code}`); } } //获取当前时间并转化 -export async function getCurrentTime():Promise { +export async function getCurrentTime(): Promise { const date = await systemTime.getDate(); const year = date.getFullYear(); let month = date.getMonth() + 1; @@ -55,7 +60,7 @@ export async function getCurrentTime():Promise { } //时间戳转日期 -export function formatTime(time:number):string { +export function formatTime(time: number): string { //@ts-ignore const h = parseInt(time / 3600) //@ts-ignore diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index 93baf05e..8bc9ec03 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -23,8 +23,6 @@ import IdlServiceExtProxy from '../IdlServiceExt/idl_service_ext_proxy'; import Want from '@ohos.app.ability.Want'; import emitter from '@ohos.events.emitter'; -// import VoiceAnnounce from './judgeSDK/utils/voiceAnnouncements'; - @Entry @Component struct Index { @@ -55,13 +53,9 @@ struct Index { }), customStyle: true, alignment: DialogAlignment.Center, - }, - ) - private fileUtil: FileUtil + }) private interval = null; - // private vocObj = null; private avPlayer - private workerInstance = null; private context = getContext(this) as common.UIAbilityContext; private serviceExtProxy: IdlServiceExtProxy @@ -114,14 +108,7 @@ struct Index { imageBtn({ btnWidth: '28%', btnHeight: '71%', imgSrc: $r('app.media.index_lw') }) .margin({ left: 80 * globalThis.ratio }) .onClick(async () => { - // this.vocObj.playAudio({ - // type: 1, - // name: 'button_media.wav' - // }) - // ||!this.initParamFlag if (this.loading) { - // globalThis.title = '正在初始化,请等待5s后重试' - // this.errorDialog.open() return } setTimeout(() => { @@ -130,29 +117,29 @@ struct Index { this.angle = 0 if (!globalThis.timeInfo) { globalThis.type = '1' - globalThis.title = '时间同步接口连接失败' + globalThis.title = '时间同步接口连接失败,尝试重新同步,请稍后' this.errorDialog.open() promptAction.showToast({ - message: `时间同步接口连接失败`, + message: `时间同步接口连接失败,尝试重新同步,请稍后`, duration: 3000 }); this.loading = false + await setCurrentTime() return } if (!globalThis.carInfo) { promptAction.showToast({ - message: `车辆信息接口获取失败`, + message: `车辆信息接口获取失败,尝试重新获取,请稍后`, duration: 3000 }); globalThis.type = '1' - globalThis.title = '车辆信息接口获取失败' - this.errorDialog.open() + globalThis.title = '车辆信息接口获取失败,尝试重新获取,请稍后' this.loading = false + this.errorDialog.open() + await getCarInfo() return } this.testXMLToJSONInWorker() - - }) } if (this.isSingle) { @@ -413,20 +400,6 @@ struct Index { } async aboutToAppear() { - // setInterval(() => { - // let date = new Date(); - // console.info('jiangsong1:timeSynchronization begin '); - // uploadProgressData() - // let params = { - // time: dateFormat(date), - // deviceNo: globalThis.deviceNo, - // version: globalThis.version, - // judgeVersion: globalThis.judgeVersion - // } - // timeSynchronizationHTTP(params) - // }, 1000) - - console.log('diyidiy') emitter.on({ eventId: 1 }, async () => { @@ -544,47 +517,6 @@ struct Index { } }) - // workerInstance.postMessage(param); - // workerInstance.onmessage = (e: MessageEvents): void => { - // console.log("baoyihu after postMessage :", JSON.stringify(e.data)); - // // @ts-ignore - // let workData: WorkData = e.data; - // this.loading = false - // if (workData.isComplete) { - // if(globalThis.singlePlay){ - // router.pushUrl({ - // url: 'pages/UserInfo', - // }, router.RouterMode.Single) - // return - // } - // getSyncData('MA_SYSSET').then(data => { - // console.log('datadata', JSON.stringify(data)) - // // @ts-ignore - // data.forEach(sys => { - // //判断是否能点开始考试 - // if(sys.v_no === '854'){ - // globalThis.param854Str=sys.v_value - // } - // if (sys.v_no === '824'&&decodeURIComponent(sys.v_value)=='0') { - // // this.Param612Str= decodeURIComponent(sys.v_value) - // router.pushUrl({ - // url:'pages/CarCheck', - // params: { - // 'fromIndex':true - // } - // }, router.RouterMode.Single) - // }else{ - // router.pushUrl({ - // url: 'pages/ExaminerLogin', - // }, router.RouterMode.Single) - // } - // }) - // }); - // - // } - // workerInstance.terminate(); - // - // } } async heartMsg() { @@ -610,7 +542,6 @@ struct Index { } async onPageShow() { - console.log('ttttt', 1111) await this.userAuth(); console.log('globalThis.singlePlay', globalThis.singlePlay) if (globalThis.singlePlay == undefined || globalThis.singlePlay == null) { @@ -680,12 +611,9 @@ struct Index { } async initParams() { - // deleteAllFIleLog(GlobalConfig.comoonfileWriteAddress + '/PLC/') - //设置plc udp 同步requesthost await getUDP(this.context, false) this.loading = false await getDeviceInfo(this.context) - await getCarInfo() await getUDP2(this.context, false) getTCP() @@ -715,15 +643,6 @@ struct Index { } }, 1000) this.createAlbum() - // clearInterval(globalThis.demo) - // globalThis.demo= setInterval(()=>{ - // const str= {"carId":"1062","examinationRoomId":"2","videoVersion":"1.0","judgeVersion":"2023.09.30.1","shellVersion":"2023.12.13.01","host":"http://172.37.55.191:8082"} - // initialization(str) - // },10000) - //下载模型 - // await this.getModel() - // const arr = [0x55, 0xaa, 0x01, 0x00, 0x02, 0x01, 0x03, 0x00] - // globalThis.udpClientByTopLine.sendMsg(Array2Byte(arr).buffer) } async getModel() {