From 6a131afd8a623f84241a83b11276313036e2b0f7 Mon Sep 17 00:00:00 2001 From: surenjun Date: Mon, 9 Sep 2024 16:59:08 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E7=A7=91=E7=9B=AE=E4=BA=8C?= =?UTF-8?q?=E8=AF=BB=E5=8F=96=E9=A1=B9=E7=9B=AE=E6=A8=A1=E5=9E=8B=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entry/src/main/ets/common/utils/GlobalUdp.ts | 2 + entry/src/main/ets/common/utils/UdpEvent.ets | 6 +- entry/src/main/ets/pages/Index.ets | 2 +- entry/src/main/ets/pages/Judge.ets | 28 ++++- entry/src/main/ets/pages/UserInfo.ets | 123 +++++++++++-------- entry/src/main/ets/pages/judgeSDK/judge.ts | 11 +- 6 files changed, 112 insertions(+), 60 deletions(-) diff --git a/entry/src/main/ets/common/utils/GlobalUdp.ts b/entry/src/main/ets/common/utils/GlobalUdp.ts index a0c10a90..7f65a8f0 100644 --- a/entry/src/main/ets/common/utils/GlobalUdp.ts +++ b/entry/src/main/ets/common/utils/GlobalUdp.ts @@ -183,9 +183,11 @@ export async function getUDP2(context,errorFlag?) { } if(val.body[0] == 11){ + console.info('surenjun','GlobalUdp收到beginExam事件') globalThis.udpEvent.sendBeginExam() } if(val.body[0] == 12){ + console.info('surenjun','GlobalUdp收到endExam事件') globalThis.udpEvent.sendEndExam() } diff --git a/entry/src/main/ets/common/utils/UdpEvent.ets b/entry/src/main/ets/common/utils/UdpEvent.ets index 1eafa005..1bf91a95 100644 --- a/entry/src/main/ets/common/utils/UdpEvent.ets +++ b/entry/src/main/ets/common/utils/UdpEvent.ets @@ -23,6 +23,7 @@ export default class JudgeEmitter{ } init = async ()=>{ + console.info('surenjun','开始注册udp事件') emitter.on({eventId:EVENTID.beginExamEventId}, () => { this?.beginExamCallBack() }); @@ -36,6 +37,7 @@ export default class JudgeEmitter{ //监听开始考试 public onBeginExam = async (callBack?:Function)=>{ + console.info('surenjun','userInfo注册onBeginExam事件') this.beginExamCallBack = callBack } @@ -50,14 +52,14 @@ export default class JudgeEmitter{ } //开始考试 - public sendBeginExam = async(content)=>{ + public sendBeginExam = async(content:string)=>{ emitter.emit({eventId:EVENTID.beginExamEventId}, { data:{ content } }); } //结束考试 - public sendEndExam = async(content)=>{ + public sendEndExam = async(content:string)=>{ emitter.emit({eventId:EVENTID.endExamEventId}, { data:{content} }); diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index 00f330ac..23e1dbc0 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -184,7 +184,7 @@ struct Index { Column() { Row() { Column() { - Text('V 1.0') + Text('V ' + globalThis.version) .fontColor('#CCAE7A') .fontSize(22 * globalThis.ratio) .width('30%') diff --git a/entry/src/main/ets/pages/Judge.ets b/entry/src/main/ets/pages/Judge.ets index 1d907bd9..8268b7a4 100644 --- a/entry/src/main/ets/pages/Judge.ets +++ b/entry/src/main/ets/pages/Judge.ets @@ -82,6 +82,7 @@ struct Index { this.singlePlay = globalThis.singlePlay } await this.initCDSBInfo() + await this.initItemInfo() // 科目三新增读取表数据 if (examSubject == 3) { @@ -257,6 +258,7 @@ struct Index { if (no1 == 3 && no3 == 1) { if (txt1 === carName) { carNo = no2 + this.carlist = carNo console.info('surenjun carNo => ',carNo) } } @@ -355,7 +357,28 @@ struct Index { xmxh: key.split('~')[1], } } + }) + } + // 获取itemInfo表信息 + async initItemInfo(){ + const infoParams = await getSyncData('MA_ITEMINFO'); + const carlist = this.carlist; + const projectsObj = this.projectsObj + //@ts-ignore + infoParams.forEach((info)=>{ + const key = decodeURI(info.itemsno); + const carlistArr = decodeURI(info.carlist).split(',') || [] + const newKey = key.split('~').join('_') + //@ts-ignore + const xmdm = key.split('~')[0] * 1 + if(projectsObj[xmdm] && (carlistArr.length == 0 || carlistArr.includes(carlist))){ + this.itemInfoObj[newKey] = { + modelKey: newKey, + xmdm, + xmxh: key.split('~')[1], + } + } }) } @@ -1113,7 +1136,6 @@ struct Index { //里程是否达标 && 必考项目是否全完成 return jl >= Number(examMileage) && isRequiredProjectsEnd } - return true } @@ -1160,7 +1182,7 @@ struct Index { //405参数为2是,如果在最左侧车道,超车项目不能触发; if (projectCode == '10' && - judgeConfigObj['402'] == '2' && + judgeConfigObj['405'] == '2' && (num === count) && num > 0 ) { @@ -1231,6 +1253,7 @@ struct Index { @State projectsCenterObj: ProjectObj = {} @State markRuleListObj: MarkRule = {} @State cdsbInfoObj: CDSBInfo = {} + @State itemInfoObj: CDSBInfo = {} @State timer: number = 0 @State judgeConfig: { [k: string]: string }[] = [] @State judgeConfigObj: { [k: string]: any } = defaultJudgeConfigObj @@ -1288,4 +1311,5 @@ struct Index { @State passingScore: number = 80 @State dwztErrorVisible: boolean = false; @State popTimer:number =0; + @State carlist:string= '' } diff --git a/entry/src/main/ets/pages/UserInfo.ets b/entry/src/main/ets/pages/UserInfo.ets index cf64e09f..6fb9a635 100644 --- a/entry/src/main/ets/pages/UserInfo.ets +++ b/entry/src/main/ets/pages/UserInfo.ets @@ -813,8 +813,77 @@ struct UserInfo { return temp } + //开始上车准备 + prePareSCZB = async () => { + try { + await this.checkSignal() + this.isExamStart = true + this.currentUser.id = '0' + await upDateTableByArray('USER', [this.currentUser]) + globalThis.statue = 4 + this.isBoardPrePareSetPopupShow = true; + this.isFirstBoardPrePareSetPopupBtnShow = true; + this.stepFlag = false + this.stopDeviceById() + } catch (e) { + + } + } + + //开始考试准备 + prePareExam = async() => { + if (this.ksksLimit) { + return + } + console.log('routerParamrouterParam') + try { + await this.checkSignal() + this.faceCompareSucess = 0 + globalThis.statue = 2 + if (!this.currentUser.xm) { + return + } + this.ksksLimit = true + + if (globalThis.singlePlay) { + const {examSubject} = globalThis.carInfo; + this.currentUser.id = '0' + await upDateTableByArray('USER', [this.currentUser]) + router.pushUrl({ + url: examSubject == 3 ? 'pages/Roads' : 'pages/Judge', + params: { + sczb: Number(this.isBoardPrePareSetPopupOpen), + kfdm: this.sczbkf, + } + }, router.RouterMode.Single); + this.ksksLimit = false + + this.stopDeviceById() + return + } + console.log('this.FaceOpenStatuethis.FaceOpenStatue',this.FaceOpenStatue) + if (this.FaceOpenStatue != '0') { + this.showFaceCompare = true + } else { + this.sfbdinterfaceFn() + } + } catch (e) { + console.info('Throw Error', JSON.stringify(e)) + } + + } + aboutToDisappear() { this.outClick() + //监听远程开始考试 + globalThis.udpEvent.onBeginExam(async ()=>{ + console.info('surenjun','userInfo收到UdpEvent事件') + if (this.isBoardPrePareSetPopupOpen && !this.isFirstBoardPrePareSetPopupBtnShow) { + await this.prePareSCZB() + }else{ + await this.prePareExam() + } + }) } outClick() { @@ -949,63 +1018,13 @@ struct UserInfo { if (this.isBoardPrePareSetPopupOpen && !this.isFirstBoardPrePareSetPopupBtnShow) { //上车准备 Image($r('app.media.sczb_btn')).commStyle().onClick(async () => { - try { - await this.checkSignal() - this.isExamStart = true - this.currentUser.id = '0' - await upDateTableByArray('USER', [this.currentUser]) - globalThis.statue = 4 - this.isBoardPrePareSetPopupShow = true; - this.isFirstBoardPrePareSetPopupBtnShow = true; - this.stepFlag = false - this.stopDeviceById() - } catch (e) { - - } + await this.prePareSCZB() }) } else { Image($r('app.media.ksks_btn')) .commStyle() .onClick(async () => { - if (this.ksksLimit) { - return - } - console.log('routerParamrouterParam') - try { - await this.checkSignal() - this.faceCompareSucess = 0 - globalThis.statue = 2 - if (!this.currentUser.xm) { - return - } - this.ksksLimit = true - - if (globalThis.singlePlay) { - const {examSubject} = globalThis.carInfo; - this.currentUser.id = '0' - await upDateTableByArray('USER', [this.currentUser]) - router.pushUrl({ - url: examSubject == 3 ? 'pages/Roads' : 'pages/Judge', - params: { - sczb: Number(this.isBoardPrePareSetPopupOpen), - kfdm: this.sczbkf, - } - }, router.RouterMode.Single); - this.ksksLimit = false - - this.stopDeviceById() - return - } - console.log('this.FaceOpenStatuethis.FaceOpenStatue',this.FaceOpenStatue) - if (this.FaceOpenStatue != '0') { - this.showFaceCompare = true - } else { - this.sfbdinterfaceFn() - } - } catch (e) { - console.info('Throw Error', JSON.stringify(e)) - } - + await this.prePareExam() }) } } diff --git a/entry/src/main/ets/pages/judgeSDK/judge.ts b/entry/src/main/ets/pages/judgeSDK/judge.ts index 3a1acc43..2ab0f509 100644 --- a/entry/src/main/ets/pages/judgeSDK/judge.ts +++ b/entry/src/main/ets/pages/judgeSDK/judge.ts @@ -198,6 +198,9 @@ export default class Judge { handDistance(); } }) + globalThis.udpEvent.onBeginExam(async ()=>{ + this.checkExamIsEnd(true); + }) //TODO 监听远程扣分 } //实时计算gps经纬度距离 @@ -227,13 +230,13 @@ export default class Judge { const carInfo = globalThis.carInfo; const { examSubject,plateNo,carId } = carInfo; const judgeUI = this.judgeUI - const {projectsObj,cdsbInfoObj,markRuleListObj,carType,carName,systemparmArr} = judgeUI + const {projectsObj,itemInfoObj,markRuleListObj,carType,carName,systemparmArr} = judgeUI const examType = examSubject == 2 ? 'km2' : 'km3' let allitems = []; if (examSubject == 2) { - allitems = Reflect.ownKeys(cdsbInfoObj).map(cdsbKey => { - const cdsb = cdsbInfoObj[cdsbKey]; + allitems = Reflect.ownKeys(itemInfoObj).map(cdsbKey => { + const cdsb = itemInfoObj[cdsbKey]; const {xmdm,xmxh,modelKey} = cdsb return { xmdm, xmxh, model: getModelData(`${examType}/${modelKey}.txt`) @@ -254,6 +257,8 @@ export default class Judge { systemparm: systemparmArr, mark: Reflect.ownKeys(markRuleListObj).map(ruleKey => (markRuleListObj[ruleKey])) || testMarkRules, sysset: judgeUI.judgeConfig, + itemInfoObj, + carlist:judgeUI.carlist }; let km3Config = {}