From 4e4d357f7aaddefe320486b72f28204645c9245a Mon Sep 17 00:00:00 2001 From: lvyuankang <1344032923@qq.com> Date: Fri, 23 Aug 2024 09:37:47 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BD=88=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entry/src/main/ets/common/service/initable.ts | 4 + .../ets/common/utils/UdpClientByCenter.ts | 54 ++++++++++- .../src/main/ets/entryability/EntryAbility.ts | 6 +- entry/src/main/ets/pages/Index.ets | 11 ++- entry/src/main/ets/pages/UserInfo.ets | 38 ++++---- .../ets/pages/compontents/errorMsgDialog.ets | 95 ++++++++++++------- 6 files changed, 152 insertions(+), 56 deletions(-) diff --git a/entry/src/main/ets/common/service/initable.ts b/entry/src/main/ets/common/service/initable.ts index 35796ca9..6606f76b 100644 --- a/entry/src/main/ets/common/service/initable.ts +++ b/entry/src/main/ets/common/service/initable.ts @@ -338,6 +338,8 @@ export async function getEsCarModel(context) { export async function upDataZhongxinginitialization(param) { return new Promise(async(resolve, reject) => { + console.log('teststet00',JSON.stringify(param)) + if (!param.carId) { resolve(false) return @@ -352,6 +354,8 @@ export async function upDataZhongxinginitialization(param) { const result=await sqlInsertCommonFn(tableList[i], JSON.parse(data) || [], param.context) result?(flag=true):(flag=false) } + console.log('teststet1',JSON.stringify(param)) + if(!flag){ prompt.showToast({ message: '本地文件初始化数据库失败', diff --git a/entry/src/main/ets/common/utils/UdpClientByCenter.ts b/entry/src/main/ets/common/utils/UdpClientByCenter.ts index e5c2f4ea..5ad66d0f 100644 --- a/entry/src/main/ets/common/utils/UdpClientByCenter.ts +++ b/entry/src/main/ets/common/utils/UdpClientByCenter.ts @@ -25,6 +25,8 @@ import prompt from '@ohos.prompt' import promptAction from '@ohos.promptAction'; import { getUDP } from './GlobalUdp'; import { dateFormat } from '../utils/tools' +import { getSyncData } from '../service/initable'; +import VoiceAnnounce from '../../pages/judgeSDK/utils/voiceAnnouncements'; export default class UdpClientByCenter { @@ -41,6 +43,7 @@ export default class UdpClientByCenter { private lsh: string = null private context private stashFn: StashFunction + private errorStep: number=0 private interval private headLenth: number = 9 //消息头长度 @@ -49,6 +52,7 @@ export default class UdpClientByCenter { private initParam private onMessage_1Callback:Function = ()=>{} public currentValue:string = '' + private avPlayer constructor(udplocalIp: string, udplocalIpPort: string, udpOppositeIp: string, udpOppositeIpPort: string) { this.localIp = udplocalIp @@ -57,6 +61,7 @@ export default class UdpClientByCenter { this.oppositeIpPort = udpOppositeIpPort this.stashFn = () => { } + this.avPlayer = new VoiceAnnounce(); this.udp = socket.constructUDPSocketInstance(); } @@ -316,12 +321,36 @@ export default class UdpClientByCenter { if(strachArr[83]!='4'){ this.chafenFlag++ if(this.chafenFlag>=15&&!globalThis.dialogOpen){ - getUDP(globalThis.context,true) + // getUDP(globalThis.context,true) globalThis.title='差分状态异常' globalThis.type='3' AppStorage.SetOrCreate('errorMsg', 1); + if(this.errorStep!=1){ + this.errorStep=1 + this.avPlayer.playAudio(['voice/差分状态异常.wav']) + getSyncData('MA_SYSSET').then(syssetParams => { + // @ts-ignore + syssetParams.forEach(sys => { + // 差分长时间是SINGLE状态报考车故障,停止考试(0-否 1-是) + if (sys.v_no === '424'&&sys.v_value==1){ + //plc差分丢失 + console.log('sys.v_valuesys.v_valuesys.v_value',sys.v_value) + AppStorage.SetOrCreate('errorCode', 0); + AppStorage.SetOrCreate('errorCodeFlage', true); + + } + }) + // const errorParam = syssetParams.filter(sys => sys.v_no === '424') // + // that.studentRefreshStatue = studentRefreshParam?.[0]?.v_value || '0' + + + }); + } } }else{ + AppStorage.SetOrCreate('errorCode', -1); + AppStorage.SetOrCreate('errorCodeFlage', false); + this.errorStep=0 globalThis.dialogOpen=false } this.chafenFlag=0 @@ -373,6 +402,29 @@ export default class UdpClientByCenter { globalThis.type='3' if(!globalThis.dialogOpen){ AppStorage.SetOrCreate('errorMsg', 1); + if(this.errorStep!=1){ + console.log('sys.v_valuesys.v_valuesys.v_value11221') + + this.errorStep=1 + this.avPlayer.playAudio(['voice/差分状态异常.wav']) + getSyncData('MA_SYSSET').then(syssetParams => { + console.log('sys.v_valuesys.v_valuesys.v_value11221',JSON.stringify(syssetParams)) + // @ts-ignore + syssetParams.forEach(sys => { + // 差分长时间是SINGLE状态报考车故障,停止考试(0-否 1-是) + if (sys.v_no === '424'&&sys.v_value==1){ + //plc差分丢失 + AppStorage.SetOrCreate('errorCode', 0); + AppStorage.SetOrCreate('errorCodeFlage', true); + + } + }) + // const errorParam = syssetParams.filter(sys => sys.v_no === '424') // + // that.studentRefreshStatue = studentRefreshParam?.[0]?.v_value || '0' + + + }); + } } num = 0 } diff --git a/entry/src/main/ets/entryability/EntryAbility.ts b/entry/src/main/ets/entryability/EntryAbility.ts index ade24496..643a1add 100644 --- a/entry/src/main/ets/entryability/EntryAbility.ts +++ b/entry/src/main/ets/entryability/EntryAbility.ts @@ -28,10 +28,10 @@ export default class EntryAbility extends UIAbility { globalThis.examinerInfo = {} globalThis.deviceNo = ''; globalThis.hasAuth = false - globalThis.version = '2022.08.13.01'//洛阳 + // globalThis.version = '2022.08.13.01'//洛阳 + // globalThis.judgeVersion = '2022.12.05.1' globalThis.judgeVersion = '2022.12.05.1' - // globalThis.version = '2022.12.05.1' - // globalThis.judgeVersion = '2022.08.13.01' + globalThis.version = '2022.08.13.01' // globalThis.version = '2024.11.22.14'//济南 // globalThis.judgeVersion = '2024.11.22.14' globalThis.videoVersion= '1.0' diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index 5d8109f2..e4a843b7 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -76,7 +76,6 @@ struct Index { if (this.loading) { return } - router.pushUrl({ url: 'pages/Settings', }, router.RouterMode.Single); @@ -102,6 +101,13 @@ struct Index { if (this.loading) { return } + const data=AppStorage.Get('errorCode'); // returns 47 + if(data==0){ + globalThis.title='差分状态异常' + globalThis.type='3' + AppStorage.SetOrCreate('errorMsg', 1); + return + } setTimeout(() => { this.angle = 360 }, 1000) @@ -150,7 +156,6 @@ struct Index { url: 'pages/UserInfo', }, router.RouterMode.Single) } else { - this.loading = true this.testXMLToJSONInWorker() } }); @@ -437,7 +442,7 @@ struct Index { if (this.num >= 3) { this.heartMsg() } - const data=AppStorage.Get('errorMsg'); // returns 47 + const data=AppStorage.Get('errorMsg'); console.log('1123',data,globalThis.type,globalThis.dialogOpen) if(data==1){ if(globalThis.type=='3'&&!globalThis.dialogOpen){ diff --git a/entry/src/main/ets/pages/UserInfo.ets b/entry/src/main/ets/pages/UserInfo.ets index 1f7096e6..0452bf7f 100644 --- a/entry/src/main/ets/pages/UserInfo.ets +++ b/entry/src/main/ets/pages/UserInfo.ets @@ -376,7 +376,7 @@ struct UserInfo { that.jkxlh = serialNumberArr?.[0]?.v_value || '1234567' const ksxtbhArr = syssetParams.filter(sys => sys.v_no === '902') that.ksxtbh = ksxtbhArr?.[0]?.v_value || '222' - const studentRefreshParam = syssetParams.filter(sys => sys.v_no === '452') + const studentRefreshParam = syssetParams.filter(sys => sys.v_no === '452') //判断自动更新 that.studentRefreshStatue = studentRefreshParam?.[0]?.v_value || '0' const openCheckFlagParam = syssetParams.filter(sys => sys.v_no == '17') const openCheckFlag = openCheckFlagParam?.[0]?.v_value == '1' ? '1' : '0' @@ -402,25 +402,29 @@ struct UserInfo { that.openDeviceByIDCard() } } - if (that.list.length) { - return - } + //0不自动更新 1自动更新(不限次数) 2没有考生更新2次 if (that.studentRefreshStatue == '2') { - clearInterval(that.interval) - that.interval = setInterval(() => { - if (that.list.length == 0 && that.numCount < 3) { - that.numCount++ - that.getExaminationStudentInfoFn() - } - }, 5000) + if(that.list.length == 0){ + clearInterval(that.interval) + that.interval = setInterval(() => { + if (that.numCount < 3) { + that.numCount++ + that.getExaminationStudentInfoFn() + } + }, 5000) + }else{ + that.getExaminationStudentInfoFn() + } } else if (that.studentRefreshStatue == '1') { - clearInterval(that.interval) - that.interval = setInterval(() => { - if (that.list.length == 0) { - that.getExaminationStudentInfoFn() - } - }, 5000) + if(that.list.length == 0){ + clearInterval(that.interval) + that.interval = setInterval(() => { + that.getExaminationStudentInfoFn() + }, 5000) + }else{ + that.getExaminationStudentInfoFn() + } } else { // this.getExaminationItemFn() } diff --git a/entry/src/main/ets/pages/compontents/errorMsgDialog.ets b/entry/src/main/ets/pages/compontents/errorMsgDialog.ets index 5a4723e1..3f9cb382 100644 --- a/entry/src/main/ets/pages/compontents/errorMsgDialog.ets +++ b/entry/src/main/ets/pages/compontents/errorMsgDialog.ets @@ -1,3 +1,5 @@ +import router from '@ohos.router'; + @CustomDialog export default struct errorMsgDialog { private controller?: CustomDialogController @@ -5,15 +7,15 @@ export default struct errorMsgDialog { } confirm: () => void = () => { } - dialogRatio:number=0.8 + dialogRatio: number = 0.8 title?: string type: string //1 tip 2loading 3Dialog @State angle: number = 0 @Styles commStyle(){ - .width(220 * globalThis.ratio * this.dialogRatio *0.6) - .height(69 * globalThis.ratio * this.dialogRatio*0.6) + .width(220 * globalThis.ratio * this.dialogRatio * 0.6) + .height(69 * globalThis.ratio * this.dialogRatio * 0.6) .backgroundImage($r('app.media.button_nor')) .backgroundImageSize({ width: '100%', height: '100%' }) // .margin({ bottom: 12 * this.ratio }) @@ -21,12 +23,12 @@ export default struct errorMsgDialog { build() { Column() { - if(this.title){ + if (this.title) { Text(this.title) - .fontSize(30* this.dialogRatio) - .margin(120* this.dialogRatio) + .fontSize(30 * this.dialogRatio) + .margin(120 * this.dialogRatio) } - if (this.type=='2') { + if (this.type == '2') { Image($r('app.media.open_loading')) .width(200) .rotate({ angle: this.angle }) @@ -40,7 +42,7 @@ export default struct errorMsgDialog { }) .margin(50) } - if (this.type=='3') { + if (this.type == '3') { Row() { Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) { Text(' 取 消 ') @@ -51,6 +53,16 @@ export default struct errorMsgDialog { .commStyle() .onClick(() => { if (this.controller != undefined) { + const errorCode=AppStorage.Get('errorMsg'); + const errorCodeFlage=AppStorage.Get('errorCodeFlage'); + console.log('errorCode',errorCode,errorCodeFlage) + if(errorCode==0&&errorCodeFlage){ + router.replaceUrl({ + url: 'pages/Index', + }, router.RouterMode.Single); + router.clear(); + + } this.cancel() this.controller.close() } @@ -64,35 +76,54 @@ export default struct errorMsgDialog { } .commStyle() .onClick(() => { + const errorCode=AppStorage.Get('errorMsg'); + const errorCodeFlage=AppStorage.Get('errorCodeFlage'); + console.log('errorCode',errorCode,errorCodeFlage) + if(errorCode==0&&errorCodeFlage){ + router.replaceUrl({ + url: 'pages/Index', + }, router.RouterMode.Single); + router.clear(); + + } + console.log('errorCode',errorCode,errorCodeFlage) + if (this.controller != undefined){ this.confirm() this.controller.close() } - }) - }.padding({bottom:20}) - - } - }.backgroundColor('#E6E3DF') - .borderRadius(19 * globalThis.ratio) - .constraintSize({ minWidth: 520 }) - } - - aboutToAppear() { - AppStorage.SetOrCreate('errorMsg', 0); - setTimeout(() => { - console.log('this.type',this.type,this.angle) - if (this.type=='2') { - this.angle = 360 - } - },1000) - if(this.type=='1'){ - setTimeout(()=>{ - this.controller.close() - },2000) } + + ) } - aboutToDisappear() { - this.title='' - this.angle = 0 + + .padding({bottom:20}) +} +} +. +backgroundColor('#E6E3DF') + .borderRadius(19 * globalThis.ratio) + .constraintSize({ minWidth: 520 }) +} + +aboutToAppear() { + AppStorage.SetOrCreate('errorMsg', 0); + setTimeout(() => { + console.log('this.type', this.type, this.angle) + if (this.type == '2') { + this.angle = 360 + } + }, 1000) + if (this.type == '1') { + setTimeout(() => { + this.controller.close() + }, 2000) } +} + +aboutToDisappear() { + this.title = '' + this.angle = 0 + AppStorage.SetOrCreate('errorCodeFlage', false); +} } \ No newline at end of file